Structure

Where things are in the repository, what each module depends on, and where new code goes. How the parts work together is in architecture.md; the development rules are in AGENTS.md. This page changes in the same commit that adds, moves or removes a folder.

1. The repository

Path What it holds
src/ The engine: core, modules, commands, CLI, MCP server, the dashboard’s server and page
systems/ free, the one game system the engine ships; the others are packages of their own, as the 5e
instructions/ The game master’s instructions, installed into each campaign
plugins/ The engine’s plugin for OpenCode, installed into each campaign as .opencode/plugins/rpg.js; it runs the doorbell on OpenCode’s events
test/ The tests, with the fake game system (systems/fake), the test extensions (extensions/), the demo campaign and the look at the page (demo/), betasim’s flows (betasim/), the fake hosts and recorded flows of the master’s drivers (master/), the packages’ tests against this engine (downstream/) and the site’s build (site/)
playtests/ Playtest scenarios: player profiles, starting points, checklists
docs/ These docs and the guides to make a package (guides/); npm run site and site.yml make the site from them

2. Inside src/

Path What it holds
src/core/ Shared utilities every module may use: registry.ts (commands), context.ts, store.ts (files), log.ts, process.ts (processes the engine starts), hosts.ts; a package’s contract in packages/api.ts
src/<module>/ One job each, behind its index.ts (table below)
src/commands/ The commands, a file each; a topic with helpers of its own is a folder, such as view/ or scene/; helpers several topics use are in shared/, a folder per topic
src/cli/ The rpg binary (cli.ts, command-line.ts); rpg open, which opens the launcher (open.ts); rpg icon (icon.ts)
src/server/ The MCP server (mcp.ts) and its context (context.ts); the hooks init writes: Antigravity’s and Codex’s approver (approver.ts), the fence of the engine’s own agents (fence.ts); a character subagent limited to view (subagent.ts); the copies of chats into sessions/ (chats.ts)
src/server/bell/ rpg --listen, the doorbell: the Stop hook that waits at its chat’s dashboard and wakes the chat when the player acts there (listener.ts); Antigravity’s own handling (antigravity.ts)
src/server/route/ The router of Antigravity’s app: rpg mcp started outside a campaign keeps a child server per campaign and passes each line to the right one (router.ts, front.ts, notes.ts)
src/server/table/ rpg table, a campaign’s table: a process that serves its page with no chat open and runs the chats’ commands one at a time. Main files: serve.ts, door.ts and seat.ts (who comes in and sits), pipe.ts (rpg mcp piped to it), place.ts (where it is found), chat.ts (its own chat with the master)
src/server/launcher/ rpg launcher, the page of this computer’s campaigns: lists, makes and opens them by starting their table (serve.ts, start.ts, campaigns.ts, make.ts). It imports the table and the page’s server, never the dashboard’s, and loads the commands only to make a campaign and to read the campaigns’ faces
src/server/page/ What the dashboard and the launcher serve alike: the gate that lets in only their own page (gate.ts), HTTP helpers (http.ts), the page’s built files (files.ts)
src/server/dashboard/ The dashboard’s server: its routes, the page’s API by path (routes.ts), what the page writes (writes.ts), the player’s words to the master (player.ts), the ports the doorbell reads (ports.ts), the phone’s door on the home network (phone/)
src/dashboard/ The dashboard’s page and the launcher’s (Preact), one app; see section 4
src/desktop/ The player’s desktop: a page in an application window of its own (browser.ts), the window’s sizes and placing (window/), the icon on the desktop and in the menu (icon/)
src/index.ts, src/page.ts What packages import: rpg-engine, the types of their code, and rpg-engine/page, the page’s kit, from src/dashboard/kit.tsx
src/testing/ rpg-engine/testing, the test kit for extensions and game systems, and the checks of a system’s folder; see extensions.md
Module Job
pages Page files, frontmatter, sections and secrets, links, inheritance, containers, environment, checks
campaign Finding and creating a campaign; campaign.yaml; state.yaml, with the choices waiting for the player
systems The installed game systems and their system.yaml; a new system’s template
extensions The installed extensions, their extension.yaml and their words; a new extension’s template
packages npm for every package, game systems and the engine included: install, update, a .tgz read
adventures Adventures as packages of content: their manifest, a .zip or folder checked whole, the .zip an export writes
languages Languages as packages: the dashboard’s phrases, its Guide and a system’s words
themes Dashboard themes, a system’s or installed on their own: read, checked, written as CSS; a new theme’s template
dice Dice notation, digital or physical faces, proofs for hidden rolls, random tables, the yes/no oracle, a target to reach
counters Counters such as 5/12
money Coins and amounts, paying with change
effects Effect lines: name, keeper, values, end
scene The open scene: participants, numbered copies, turn order
time Game dates and durations; the calendar
rules Rules as text: sections, word search
triggers Event conditions such as party in [[Ossario]]
instructions Reads instructions/ from the package
progression Tables of levels: rows and features up to a level
images Picture formats and finding a picture file
helpers The AI hosts’ programs as the player’s own: found, installed, signed in, stopped; those inside the desktop apps (desktop.ts); each host’s account and sign-in from a page (access.ts); the writers and readers they run for imports, pictures and translations (opencode.ts, antigravity.ts)
documents The player’s documents as text and pictures: PDF (by OCR where it has no text), Word, OpenDocument, EPUB, HTML, RTF, text
importer The import’s folder: a document in pieces, how far it is, the adventure the helper writes
library The player’s books: their text indexed once in the local data folder, read apart one at a time
confirm A yes or no asked in a window of the operating system, and a folder chosen in another
map The world map: roads, quickest way, compass, distances
grid The map of a place: squares, legend, reach, adjacency
saves Saves as zips
git Git in a folder through the computer’s git, never asking: commit, push, remotes, the engine’s .gitignore block, GitHub’s device flow
player-notes The player’s notes, outside the game
chats The chats Claude Code and Codex keep of a campaign, read and written into it as text
master A chat with the master in the AI host’s own program, driven by its protocol so the table can show it: the events every host shares (chat.ts, state.ts, failures.ts), a driver per host (claude-code/, codex/, opencode/, antigravity/), the Agent Client Protocol’s client (acp/), the registry of hosts (index.ts)

No module names a game’s concepts: hit points or conditions exist only as data in a system.

3. Dependencies

A module imports only its own files, src/core/, Node and packages: never another module, a command, the CLI or the server, from any of its folders. Commands are the glue. Only the store and the files listed in test/architecture.test.ts, which read the package or what lies outside the campaign, touch node:fs; everything else reads and writes through files(). That test enforces both.

4. Where new code goes

  • A job of its own that makes sense for a game very different from D&D: a module, src/<module>/ with its index.ts, and its row above.
  • Work that joins modules: a command, src/commands/<name>.ts, or its topic’s folder; a helper several topics use goes in commands/shared/, in the folder of its topic.
  • A part of the page: in src/dashboard/, in the folder of its area (shell/ the frame, parts/ what every section draws with, play/, sheet/, journal/, settings/, world/, place/, packages/, acts/, chat/, dice/, help/, and launcher/, the launcher’s page with an entry of its own); its style in style/, its phrases in i18n/, Help’s guide in guide/. The page is one app: its folders need no index.ts.
  • A game’s concept: not in src/, but data in a game system or an extension, their code only when data is not enough.
  • Folders, not prefixes: a file name never repeats its folder (pages/file.ts, not pages/page-file.ts); a module that grows splits into subfolders, each with its index.ts.

© 2026 Stefano Caronia · code under the MIT license