MCP: the agent facade moves into src/agent/, assembled into the development page only
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.
This commit is contained in:
parent
b2366ed260
commit
5b76685e5c
27 changed files with 1052 additions and 869 deletions
|
|
@ -1,17 +1,21 @@
|
|||
// Loads the game page in jsdom with the animation loop disabled, so tests can drive the simulation
|
||||
// directly through the game's globals (ACT, S, R, dayTick…). The page is assembled from src/ once per
|
||||
// test process (scripts/lib/page.js), so tests always run what is in src/, never a stale build.
|
||||
// It is the page players get; {agent: true} loads the development page instead, with the agent facade
|
||||
// (src/agent/) the MCP server drives. Only the tests of that facade ask for it, so core code that leans on
|
||||
// it fails here rather than in production.
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { JSDOM, VirtualConsole } = require('jsdom');
|
||||
const { assemble } = require('../scripts/lib/page');
|
||||
|
||||
let PAGE = null;
|
||||
const page = () => PAGE || (PAGE = assemble().html);
|
||||
const PAGE = {};
|
||||
const page = (dev) => PAGE[dev] || (PAGE[dev] = assemble({ dev }).html);
|
||||
|
||||
// opts.file: a built or older page to load instead (the perf bench, the release build test).
|
||||
// opts.agent: the development page, with src/agent/.
|
||||
function load(opts = {}) {
|
||||
const html = opts.file ? fs.readFileSync(opts.file, 'utf8') : page();
|
||||
const html = opts.file ? fs.readFileSync(opts.file, 'utf8') : page(!!opts.agent);
|
||||
const errors = [];
|
||||
const vc = new VirtualConsole();
|
||||
vc.on('jsdomError', (e) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue