Make an extension

An extension adds something to the game a campaign plays, whatever its system: commands the master calls, fields and counters on the sheet, lines in the master’s instructions, widgets on the dashboard. Our weather and lockpicking are extensions. It is data (extension.yaml) and code in TypeScript.

An extension is an npm package. Its name without the scope is the name its commands start with: @you/tide-clock gives tide-clock and tide-clock-advance.

You need Node 24, npm, and RPG Engine (npm install -g rpg-engine). The engine does not rule: an extension keeps a count or a state the master would get wrong, and leaves the judgement to the master.

Steps

  1. Make the extension. In a terminal, from the folder where you want it:

    rpg package new "Tide Clock" --kind extension
    

    You should see:

    Made the extension Tide Clock in ...\tide-clock: tide-clock on npm, its commands tide-clock and tide-clock-advance.
    Next, in that folder: npm install, then npm test, which builds it and runs its tests.
    Then, in a campaign's folder, rpg package install "...\tide-clock" adds it to the campaign, its code from the dist/ the build made.
    

    Give a title, as here, or an npm name, as @me/tide-clock. The folder must be empty or new; --folder <path> puts it somewhere else. It holds a small extension that works, a clock of six steps the master fills as a danger draws near:

    File What it is
    extension.yaml its title, its line for the master (about), its icon and its widget; the other keys in comments
    instructions/play.md lines added to the master’s instructions while playing
    src/index.ts its code: the commands tide-clock and tide-clock-advance, and the widget’s hook
    test/extension.test.ts its tests, on the engine’s test kit
    package.json its npm name, version, and rpg-engine: {kind: extension, api}
    README.md, LICENSE.md, .github/workflows/ci.yml to fill in; CI runs the tests on Linux, Windows and macOS
    tsconfig.json, vitest.config.ts, .gitignore the build’s and the tests’ settings, as they are
  2. Build and test it, in its folder:

    cd tide-clock
    npm install
    npm test
    

    npm test builds dist/ and runs the tests: Tests 2 passed (2). They run the commands in a campaign made for the test (testCampaign) and read the widget as the dashboard shows it (campaign.widgets).

  3. Make it yours. Change extension.yaml, instructions/, src/ and the tests with them; run npm test after each change. The code reaches the game only through game: it reads pages and settings, rolls, asks the player, writes fields and counters, and keeps its own state. It uses the engine’s dice and time, never Math.random or Date. Beyond the clock it can act as time passes or after a roll, show more widgets, and draw in the page with a page module: what code can do.

  4. Try it in a campaign. Make one for testing and install the extension from its folder:

    rpg init clock-test --system free
    cd clock-test
    rpg package install "<path of tide-clock>"
    

    A window asks you to allow it, as for any package that is not ours: its code runs on your computer. Then:

    Installed tide-clock 0.1.0, not verified: at the player's risk, and the campaign uses it: a clock of six steps the master fills as a danger draws near, shown beside the rolls. Its commands: tide-clock, tide-clock-advance. Its parts of your instructions are given when they apply: play.
    

    Run its commands by hand:

    rpg tide-clock-advance --by 2
    
    The clock is at 2 of 6.
    

    Then play a scene with your AI app in that folder: the master reads about and the instructions, calls the commands, and the widget shows on the dashboard, in a card beside the rolls.

  5. Publish it on npm. Choose a licence (LICENSE.md and license in package.json), give any credit its text needs in attribution in extension.yaml, write description in package.json, then:

    npm publish --access public
    

    --access public is needed only for a scoped name (@you/...). Keep the keyword rpg-engine-package in package.json: rpg package available and the dashboard’s Packages page list the npm packages that have it. If it is made for one game system, say so with needs: {system: <name>} in extension.yaml and "system": "<name>" under rpg-engine in package.json.

What a player gets

A player installs your extension from the dashboard’s Packages page, or by its npm name: rpg package install @you/tide-clock, or rpg package install npm:tide-clock for a name without a scope (a name alone means one of RPG Engine’s own). A window asks them to allow it first, since its code runs on their computer. It installs on the computer and adds it to that campaign alone; another campaign adds it with its own package install.

Update it

  • After a change, run npm test, then rpg package install "<its folder>" again in your campaign. The command line uses the new code at once. An AI app’s MCP server keeps the code it started with: start a new chat, or reconnect the server.
  • To release, raise version in package.json and npm publish. Players see the update in the Packages page and in rpg package available, and the master is told of it at the start of a session.
  • rpg-engine.api in package.json is the version of the package API the extension is written for. Raise it only when you use a key or a function that a newer API added: what each API number added. An older engine then asks its player to update, instead of misreading the extension.
  • devDependencies names the RPG Engine your tests run on. Raise it to test with a newer engine.

When something fails

  • Unknown command "tide-clock": the campaign does not use the extension. Install it from that campaign’s folder (step 4).
  • There is no campaign here: run package install from a campaign folder.
  • ... is no npm package name, or ... cannot name an extension: the npm name you gave does not work. package new takes a title, which it turns into a name, or an npm name in lowercase such as tide-clock.
  • roll is one of the engine's commands: an extension’s commands start with its name, so it cannot take the name of one of the engine’s. Pick another title.
  • ... is not empty: package new needs an empty or new folder.
  • A widget shows nothing: campaign.widgets() in a test gives its problem, the reason.
  • The master does not see a change: rebuild, install again, and start a new chat.

To take it out of a campaign: rpg package remove tide-clock. To take it off the computer: rpg package uninstall tide-clock.

Reference


© 2026 Stefano Caronia · code under the MIT license