diff --git a/.claude/skills/edit-the-game/SKILL.md b/.claude/skills/edit-the-game/SKILL.md index 7dc75dd..db249cb 100644 --- a/.claude/skills/edit-the-game/SKILL.md +++ b/.claude/skills/edit-the-game/SKILL.md @@ -14,6 +14,7 @@ load, so splitting code across files costs nothing at runtime. Why it works this src/index.html the shell:
, static markup, ``, `` src/styles/NN-*.css CSS, in order (phones last) src/game/NN-area/NN-*.js the game script, in order (see the map in docs/ARCHITECTURE.md) +src/agent/NN-*.js the agent facade the MCP server drives: in the development page only site/ static files copied as they are (dictionaries, icons, service worker) ``` @@ -34,7 +35,8 @@ npm test -- tests/peering.test.js # one suite ``` A browser error points at a line of the assembled page; the dev server prints the `src/` file and line -next to it. `npm run page -- -o /tmp/page.html` writes the assembled page if you want to look at it. +next to it. `npm run page -- -o /tmp/page.html` writes the page players get if you want to look at it; +`npm run page -- --source --dev -o /tmp/page.html` the development page `npm run dev` serves. ## Where new code goes @@ -48,9 +50,13 @@ next to it. `npm run page -- -o /tmp/page.html` writes the assembled page if you - **Actions:** add `name:(args)=>{…},` to the matching `src/game/90-actions/*.js`. Only `10-interface.js` declares `const ACT={`; the others are `Object.assign(ACT,{ … });`. A new area can get a new `NN-area.js` file of that second form. The MCP server types every action: a new one also gets - an entry in `scripts/lib/mcp-commands.js` (a game command with its argument domains, a view, a draft - or a session action) or in the server's `DENY` list in `scripts/lib/mcp-page.js`; - `tests/mcp-commands.test.js` fails until it has one. + an entry in `src/agent/20-commands.js` (a game command with its argument domains, a view, a draft, + a session action, or `API_DENY`); `tests/mcp-commands.test.js` fails until it has one. +- **Agent code** (`src/agent/`, the facade the MCP server plays through) is assembled into the + development page only (``): players never download it. Its top-level names + start with `api`/`API_`, and **nothing in `src/game/` may name them**: that would work in `npm run dev` + and break for players (`tests/build.test.js` checks). Tests load the players' page; a test of the + facade asks for `load({ agent: true })`. See docs/adr/0004-dev-only-code.md. - **Panels and modals:** `93-ui/` (HUD, side panels), `94-dashboard/` (NOC dashboard, bank), `95-modals/`. - **Styles:** the matching `src/styles/*.css`; phone rules go in `60-phone.css`. - **Data tables** (cities, cables, networks): one entry per line, and keep id-keyed objects such as diff --git a/.claude/skills/write-tests/SKILL.md b/.claude/skills/write-tests/SKILL.md index efe406c..42937b9 100644 --- a/.claude/skills/write-tests/SKILL.md +++ b/.claude/skills/write-tests/SKILL.md @@ -7,7 +7,8 @@ description: Write deterministic jsdom tests for Series of Tubes features and fi Tests use `node:test` and `tests/harness.js`, which assembles the game page from `src/` (once per test file) and loads it in jsdom with the animation loop off, a seeded `Math.random` and a recording fake canvas. -Code runs inside the page through `ev()`. +Code runs inside the page through `ev()`. `load()` is the page players get; tests of the agent facade +(`src/agent/`, `window.TUBES`) ask for the development page with `load({ agent: true })`. ## Pattern diff --git a/CLAUDE.md b/CLAUDE.md index e383fa1..ac8bdd0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -5,7 +5,8 @@ https://seriesoftub.es, hosted on GitHub Pages. The game is one static page with Its source is many small files in `src/` (`src/styles/*.css`, `src/game/**/*.js`, the shell `src/index.html`); the build pastes them together, in path order, into a single `index.html`, the same one-file page players have always loaded. Static files (dictionaries, icons, service worker) -live in `site/`. +live in `site/`. `src/agent/` (the facade the MCP server plays through) goes into the development page only, +never into the page players get, and nothing in `src/game/` may use it (`docs/adr/0004-dev-only-code.md`). Read these before larger changes: diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 9729449..e8bd6f5 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -11,8 +11,10 @@ src/ the game page, in pieces i18n/en.js the English for every label → inlined at the top of the page's `; return html.replace('', `${hint}${RELOAD}