The command tables and the page-side reads, screens and dispatch (scripts/lib/mcp-commands.js and
mcp-page.js) become src/agent/, the facade window.TUBES.call(tool, args) in the page's own scope.
A new <!-- @include-dev agent --> line in src/index.html pastes it in after the game, but only in the
development page (npm run dev, the MCP server, i18n-check, tests that ask with load({agent:true})).
The build drops the line whole: _site/ is byte for byte what main builds.
Tests load the page players get by default, the build test fails if anything outside src/agent/ names
the facade's api/API_ names, and the pages test checks the built page carries none of it and still
plays. ADR 0004 records the rule.
2.9 KiB
2.9 KiB
ADR 0004: Development-only code, assembled into the development page only
- Status: accepted
- Date: 2026-11-03
Context
The MCP server (npm run mcp, MCP.md) plays the game through a facade of typed commands, reads and
screens. That facade has to run inside the game page, in its top-level scope: it reads S, R, ACT and the
catalogs directly, and a page in the player's own browser can only run code it was served (nothing may be sent to
it as code). So it belongs in src/, next to the game.
But it is about 110 KB of JavaScript (some 40 KB gzipped) that no player can use: seriesoftub.es has no way to reach it. Shipping it would make every player, most of them on phones, download and parse it on every load, against the rule that structure costs nothing at runtime (ADR 0002).
Decision
- Code only tools use lives in
src/agent/(and later folders like it), named and ordered likesrc/game/. src/index.htmlincludes it with<!-- @include-dev agent -->, right after<!-- @include game -->, inside the same script, so it shares the game's top-level scope.scripts/lib/page.jsexpands an@include-devline only when asked (assemble({ dev: true }),--source --dev). Otherwise the line is dropped whole, so the page players get is byte for byte what it would be without the feature.- The development page (with
src/agent/) is whatnpm run devserves, what the MCP server loads and whati18n-checkreads. The players' page (without it) is whatnpm run buildandnpm run serveship, whatnpm run perfmeasures and what the tests load unless a test asks forload({ agent: true }).
Rules that come with it
- The game never names agent code. Nothing in
src/game/,src/styles/orsrc/index.htmlmay refer to anythingsrc/agent/defines: it would work in development and break for players. Every top-level name insrc/agent/starts withapiorAPI_(the facade itself iswindow.TUBES), andtests/build.test.jsfails on any use of those names outsidesrc/agent/. - Agent code runs after the game. Its files come after
99-loop.js, so its top level may use anything the game defines, and must not assumeboot()has or has not run yet. In practice it only defines tables and functions. - Tests load the players' page by default. So a core change that quietly leans on agent code fails the suite
instead of the release.
tests/pages.test.jschecks that the built page carries no agent code and still plays.
Consequences
- Players pay nothing for the facade: the build is unchanged by it, and the performance benchmark measures exactly what ships.
npm run servestays what it says: the built site as GitHub Pages serves it, without the agent.- The development page and the players' page differ, by design and only by what
@include-devadds. Anything that must behave like production (perf, the release build test) uses the players' page.