An extension is an npm package adding what a game system lacks: rules as text, master’s instructions, a calendar, code. A campaign plays one system and any number of extensions. Ours: rpg-engine-weather, rpg-engine-lockpicking.
rpg-engine-<name>/
package.json name, version, main, the "rpg-engine" field, the keyword rpg-engine-package
extension.yaml what it is (section 2)
instructions/*.md its parts of the master's instructions
words/<code>.yaml its words in other languages (section 4)
images/ pictures its widgets show
src/, dist/ its TypeScript code, built to dist/
test/ its tests, not shipped
"rpg-engine" key
Meaning
kind
"extension"
api
the package API it is made for
system
the game system it needs, so the catalog warns before downloading
page
its page module (section 3)
bugs, or a GitHub repository, gives the dashboard’s “Report a problem” link.
The name without scope prefixes its commands: @rpgengine/weather gives weather, weather-set.
api covers the code contract and what the yaml may declare; it rises with each addition an older engine would misread. Name the lowest API with what you use (the list is in declarations.ts).
The engine reads extensions from API 1, systems from 5, up to its own. Newer is refused before installing; older than the range asks for a newer package.
2. extension.yaml
title:the weather by the climate score, by Stefano Caroniaabout:the sky changes each dawn by a rolllanguage:enattribution:Weather by the climate score, by Stefano Caronia, under CC BY 4.0.needs:{system:5e}calendar:months:-{name:Thaw,days:90,season:spring}
Key
Meaning
title, about, language
required; status gives about to the master
attribution
the licence line it requires
needs
{system} it is made for
calendar
months replacing the core’s; the campaign’s own wins
A widget has title (40 characters), icon (from icons), place, page (with place: page), where (with place: top) and order (lowest first). Its hook of the same name draws it.
place
Where
top
a chip in the top row; where: top puts it beside the campaign’s name; hidden on a phone
side
a card in the table’s column
page
a card at the end of scene, sheet, world or journal
person
on each party member
card
only in a question’s card its code asks
campaign.yaml moves or hides one (Settings writes it): widgets: {weather.today: side}, with top, side, person, a page, off or {place, page, order}.
A person widget can only be off; a card widget cannot move.
3. Code
main is a module whose default export takes the kit and returns the package’s code, every part optional. A game system’s code has the same contract; the types come from rpg-engine.
importtype{PackageEntry}from"rpg-engine";constweather:PackageEntry=({z})=>({commands:[{name:"weather",description:"…",input:z.object({}),readOnly:true,run:(input,game)=>"…"}],timePassed:({from,to},game)=>["Weather this morning: …"],});exportdefaultweather;
Command descriptions are at most 150 words. player: true lets page code run it; needsPlayer: true (it calls game.ask) tells MCP hosts it waits for the player.
Hooks after writes run the system’s first, then extensions in order; synchronous, at most five lines and 600 characters per package. A failure is a line; the change stands.
rolled: target carries met and natural; asked: {check} only for the package that asked. asking: target.screened when the player may not see it.
An extension may not share its campaign’s system’s name.
The game
game is all the code reaches; widgets and asking get only the reading part.
Member
What it does
now(), calendarDay(day), units()
game moment, calendar date, metric/imperial
setting(name), sameName(a, b)
a campaign setting; names compared as the engine does
party()
{places, environment, members: {name, pc}[]}
page(name)
by name or alias, or a copy in the scene: name, pc, party, value(field), counter(field), has(effect), carries(thing), formula(text)
scene()
{title, opened, round?, turn?}
state.read(), state.write(v)
its state, extensions/<name>/state.yaml
log(text, visibility?)
a public or hidden log line
roll(notation, by?)
unlogged; with {who, why, check?, values?, says?, tones?} logged for who, values being physical dice. Gives {notation, total, faces, dice, text, id?, hidden?}
ask(asked)
asks the player for a roll (below)
set(page, values, why)
writes fields as write --set; throws what it refuses
change(page, field, {by \| to \| spend}, why)
as change, for counters the rules watch; hooks run only from a command
addEffect, endEffect(page, name, why)
add an endless effect, end one
It writes no other file. After the call stops (as while ask waits), writes and rolls with who throw.
Code runs in the chat server: a loop that never yields stops the dashboard and the master’s tools.
target as the core’s (">= 15, natural 1 fails"); roll, decline are button words, text or {label, note}; decline: false forces the roll; rule is a line under the buttons.
says(faces) replaces the total (4 pins, no 1); tones(faces) marks each die good or bad.
card: {widget, key} asks in one of its widgets, one key per attempt; it shows before and after the dice, so write the state first.
Gives {rolled: {id, total, faces, text, met?, natural?}}, {declined: true}, {said}, or {inWords, physical} where no buttons show.
Reads only; all hooks share two seconds, and a late one is skipped until it answers. asked is {key, who} in a question’s card, {who} in person or when page code names it.
The player sees what it returns: no secrets. Checked and cut at about 12,000 characters; /api/widgets says why one shows nothing.
Words are translated as whole texts; numbers go in values: {text: "From {low} to {high}", values: {low: 10, high: 15}}. A value is a number, text, {number, unit} or {from, to, unit}.
track: pips to ten, else a bar; lookpips (to twenty), bar or steps; field names the counter. In a question card, stage places it and held, marked, coming light pips.
person: read per member. A chip given only while down says their state; others are small cards of boxes.
Code in the dashboard’s page
An extension or a game system may draw in the page with its own code, in the dashboard’s style.
page names an ES module inside the package, served at /pkg/<package>/<version>~<print>/ and listed at /api/modules. It imports preact and rpg-engine/page from the page.
A widget’s data (short JSON) reaches only the page. A card or page naming a widget as widget gets its data for the character shown.
An error shows in its card, saying whose; a failing group falls back to the dashboard’s.
Default export
What it gives
figures
components drawing a track or lead with figure, declared in the yaml
bodies
components drawing a roll card’s inside, named by body
style
a style sheet over the dashboard’s layers, not its focus ring and tooltips
cards
{page, title, icon, order} cards at a page’s end
pages
{title, icon, nav?} pages at #/pkg/<package>/<name>; nav: "tab" for a tab
groups
system only: components for its sheet groups, as {Stats: StatsDial}
pageStyle
system only: unlayered style over the whole page; classes are no contract
Prop
For
Meaning
data, before
figure, body
the data now and before
name, part, place, size
figure
the part it draws, where, its room
words, number, field, fieldName
all
the page’s words and numbers, a field’s short and full name
language, dir, theme, reducedMotion
all
page context
freeRoll(field, who?)
all
an unlogged roll of a sheet number
run(command, input)
all
runs a player: true command via POST /api/run
buttons, answer(button), sent, ended
body
the question’s buttons and state
prompt, rule, parts, target, rolled, rest
body
the question, its target, the last roll, a rest’s dice
its fields, any sheet field, rolls, the check it answers
A screened target is {screened: true}, then {met, natural?, screened: true}.
Parts: Button, Icon, Dice, Track and the rest, statusIcons, and <Counter value={…} />, a sheet value drawn as the sheet does; as="bar"/"marks" and label override.
4. Words
words/<code>.yaml gives its words in a language; pt serves pt-BR.
title:la météo selon le score de climatwords:{Weather:Météo,"From{low}to{high}":"De{low}à{high}"}fields:{lockpicking-rerolls:Relances de crochetage}
A missing word stays as written; the first letter’s case does not matter. A broken file is ignored and validate names it.
5. Installing
The package command; --json returns data.
Action
What it does
list
packages on this computer and in the campaign
available
what npm has for this API, and updates
install <name>
installs or updates without its scripts; adds it to campaign.yaml
remove <name>
takes it out of the campaign
uninstall <name>
takes it off the computer
new "<title>" --kind extension
a skeleton with example, tests and CI; --kind system too
A bare name is ours, under @rpgengine/, verified. Others need their scope or npm:name; folders and .tgz files are never verified.
It installs the newest version this engine reads; offline, from npm’s cache.
status tells the master of updates, at most daily; it never updates.
A package not ours installs and runs only after the player’s yes in the host’s form or an OS window, valid for that version and files; another version or a changed file asks again.
The same command installs every kind, told by the file at its top: a game system (system.yaml), a language (language.yaml, from npm too), an adventure (adventure.yaml), a theme (theme.yaml).
Data packages (adventures, themes, languages) come from a GitHub link, a .zip or a folder. A GitHub repository carries the topic rpg-engine-adventure, rpg-engine-theme or rpg-engine-language; its link reads the default branch, or the branch or tag after /tree/.
A theme or a language is unpacked once for every campaign on the computer, and updated only from the repository it came from. Its engine in the yaml, quoted (engine: "0.22"), is the lowest RPG Engine that reads it.
package install <folder> --link reads a theme where it is, so its author sees each change live; package new "<name>" makes a theme from a template and links it.
The dashboard’s Packages page installs by a link, an npm name, a folder or a file, and lists what npm and GitHub’s topics offer.
6. Tests
A package tests itself with rpg-engine/testing, part of the package API.