What programs mean (the languages, translators, Mojo checker and
interpreter, prover, fuzzer, machine model, catalog problems and the Mojo
corpus with godbolt's stored answers) was mixed into the site's tree, so a
change to the prover and a change to a button went through the same gate
and the same docs. This moves all of it under core/, laid out as its own
repository, ready to be extracted with its history and pinned here as a
git submodule.
- core/: src/{engines,services,sync,mojo,exercises,curriculum,common},
mojo/, syntax/mojo.xml, its tests (with Workspace and workForProblem in
place of the site's Session), scripts (corpus pipeline, play, the
exercise and probe starters, engines export/diff), and its docs
(engines, trust, mojo-corpus, exercises, coverage). Its own pixi.toml,
package.json, README, AGENTS.md and CI workflow.
- core/tests/boundary.test.mjs: library modules use no DOM, import no
page widget, and import nothing outside src/.
- core/scripts/cli.mjs: pixi run cli check|run|prove|fuzz|translate.
- core/scripts/dafny.py: Dafny 4.11.0 pinned by version and SHA-256 per
platform, fetched into .tools/ (pixi run dafny-fetch, pixi run dafny).
- The site imports core only as #core/<path>.js: an import map in
index.html, "imports" in package.json for node, core's declarations for
tsc. The site's TypeScript builds core first (npm run build).
- assemble.sh, the Quarto engine copy, the render cache key, check-pages,
quarto-export and quarto-css read core/dist and core/mojo; quarto-css
copies core's syntax/mojo.xml into the extension.
- Site tests that covered engines moved to core; the rest keep Session.
- README, AGENTS.md, docs/app.md, docs/deploy.md and the CI workflow
describe the split (checkout with submodules; core's tests and corpus
status run against the pinned commit).
Gate: site 110 pass; core 307 pass; corpus status --strict passes.
Manual check: the assembled site opens Bridge (count-base-proved),
Developer and Hardware (count-base) with the editor, the stepper and the
board, and no module errors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
44 lines
2.1 KiB
JavaScript
44 lines
2.1 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Copy this repository's language engines into a checkout of the course site.
|
|
*
|
|
* pixi run engines-export ../course/static
|
|
*
|
|
* This repository owns the engines (docs/engines.md); the course copies from
|
|
* here. <static> is the course repository's static/ directory. For each
|
|
* engine directory (pseudo, asm86, shared) every module goes to
|
|
* <static>/js/<directory>/: a JavaScript module as written in src/engines/,
|
|
* a TypeScript one (logic, solver, vcgen) as built into dist/engines/, which
|
|
* is plain ES-module JavaScript the course's pages can import unchanged.
|
|
* Source maps are not copied. Prints what it wrote, and changes nothing else
|
|
* in the course. Review the course's diff before committing it there.
|
|
*/
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { engineModules } from './engines-files.mjs';
|
|
|
|
const ROOT = fileURLToPath(new URL('..', import.meta.url));
|
|
const dir = process.argv[2];
|
|
if (!dir || !fs.existsSync(path.join(dir, 'js'))) {
|
|
console.error('usage: pixi run engines-export <the course repository\'s static/ directory>');
|
|
process.exit(2);
|
|
}
|
|
|
|
let wrote = 0, same = 0, added = 0;
|
|
for (const m of engineModules(ROOT)) {
|
|
if (!fs.existsSync(m.ours)) {
|
|
console.error(`${m.label}: ${path.relative(ROOT, m.ours)} is missing; run pixi run build first`);
|
|
process.exit(1);
|
|
}
|
|
const target = path.join(dir, 'js', m.dir, m.file);
|
|
const text = fs.readFileSync(m.ours, 'utf8').replace(/\n\/\/# sourceMappingURL=.*\n?$/, '\n');
|
|
const before = fs.existsSync(target) ? fs.readFileSync(target, 'utf8') : null;
|
|
if (before === text) { same++; continue; }
|
|
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
fs.writeFileSync(target, text);
|
|
if (before === null) { added++; console.log(`added js/${m.dir}/${m.file}${m.built ? ' (built from TypeScript)' : ''}`); }
|
|
else { wrote++; console.log(`updated js/${m.dir}/${m.file}${m.built ? ' (built from TypeScript)' : ''}`); }
|
|
}
|
|
console.log(`\n${wrote} updated, ${added} added, ${same} already the same`);
|