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,7 +1,8 @@
|
|||
#!/usr/bin/env node
|
||||
// Development server: http://localhost:8080 (PORT=… to change). The page is assembled from src/ on every
|
||||
// request, static files come straight from site/, and the browser reloads itself when you save a file.
|
||||
// The page is not version-stamped, so the game runs in dev mode (IS_DEV) like a local copy always has.
|
||||
// The page is not version-stamped, so the game runs in dev mode (IS_DEV) like a local copy always has, and it is
|
||||
// the development page: with the agent facade (src/agent/, window.TUBES) that the page players get has not.
|
||||
// No dependencies: plain node:http. For the production build as GitHub Pages will serve it: npm run serve.
|
||||
const fs = require('node:fs');
|
||||
const http = require('node:http');
|
||||
|
|
@ -17,7 +18,7 @@ const RELOAD = '<script>new EventSource("/__dev").onmessage=()=>location.reload(
|
|||
const clients = new Set();
|
||||
|
||||
function page() {
|
||||
const { html, map } = assemble();
|
||||
const { html, map } = assemble({ dev: true });
|
||||
// Errors report a line of the assembled page; the console also says which file under src/ that is.
|
||||
const hint = `<script>addEventListener('error',e=>{const n=e.lineno,m=n&&(${JSON.stringify(map)}).find(m=>n>=m.from&&n<=m.to);if(m)console.warn('↑ src/'+m.file+':'+(n-m.from+1))});</script>`;
|
||||
return html.replace('</body>', `${hint}${RELOAD}</body>`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue