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
73 lines
3.4 KiB
JavaScript
73 lines
3.4 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Compare this repository's engines with a checkout of the course site.
|
|
*
|
|
* pixi run engines-diff ../course/static
|
|
*
|
|
* <static> is the course repository's static/ directory. This repository owns
|
|
* the engines and the course copies from here (pixi run engines-export), so
|
|
* this shows what the course has not taken yet. For each engine module (pseudo,
|
|
* asm86, shared) it compares the file the course would receive (src/engines/
|
|
* as written, or dist/engines/ for a module written in TypeScript) with the
|
|
* course's copy (the course's stylesheets are compared in pplus-web);
|
|
* prints whether they are the same, differ only in whitespace and line
|
|
* endings, or differ in content (with the number of changed lines, whitespace
|
|
* ignored), and lists files only one side has. It changes nothing.
|
|
*/
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { engineModules, ENGINE_DIRS } 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-diff <the course repository\'s static/ directory>');
|
|
process.exit(2);
|
|
}
|
|
|
|
const squash = (s) => s.replace(/\r/g, '').split('\n').map((l) => l.replace(/\s+/g, ' ').trim()).filter(Boolean);
|
|
|
|
/** Lines changed, whitespace ignored: the size of the symmetric difference of the two line multisets. */
|
|
function changed(a, b) {
|
|
const count = new Map();
|
|
for (const l of a) count.set(l, (count.get(l) || 0) + 1);
|
|
for (const l of b) count.set(l, (count.get(l) || 0) - 1);
|
|
let n = 0;
|
|
for (const v of count.values()) n += Math.abs(v);
|
|
return n;
|
|
}
|
|
|
|
function compare(ours, theirs) {
|
|
const a = fs.readFileSync(ours, 'utf8'), b = fs.readFileSync(theirs, 'utf8');
|
|
if (a === b) return { kind: 'same' };
|
|
const n = changed(squash(a), squash(b));
|
|
return n === 0 ? { kind: 'whitespace' } : { kind: 'content', n };
|
|
}
|
|
|
|
const rows = [];
|
|
const strip = (t) => t.replace(/\n\/\/# sourceMappingURL=.*\n?$/, '\n');
|
|
const mine = engineModules(ROOT);
|
|
for (const m of mine) {
|
|
const theirs = path.join(dir, 'js', m.dir, m.file);
|
|
if (!fs.existsSync(m.ours)) rows.push([m.label, 'not built: run pixi run build']);
|
|
else if (!fs.existsSync(theirs)) rows.push([m.label, 'only here']);
|
|
else {
|
|
const a = strip(fs.readFileSync(m.ours, 'utf8')), b = fs.readFileSync(theirs, 'utf8');
|
|
const r = a === b ? { kind: 'same' } : (changed(squash(a), squash(b)) === 0 ? { kind: 'whitespace' } : { kind: 'content', n: changed(squash(a), squash(b)) });
|
|
rows.push([m.label, r.kind === 'content' ? `differs: ${r.n} lines` : r.kind === 'whitespace' ? 'whitespace only' : 'same']);
|
|
}
|
|
}
|
|
for (const d of ENGINE_DIRS) {
|
|
const c = path.join(dir, 'js', d);
|
|
if (!fs.existsSync(c)) continue;
|
|
for (const f of fs.readdirSync(c).filter((x) => x.endsWith('.js')).sort()) {
|
|
if (!mine.some((m) => m.dir === d && m.file === f)) rows.push([`js/${d}/${f}`, 'only in the course']);
|
|
}
|
|
}
|
|
|
|
const w = Math.max(...rows.map((r) => r[0].length));
|
|
for (const [f, v] of rows) console.log(`${f.padEnd(w)} ${v}`);
|
|
const content = rows.filter((r) => r[1].startsWith('differs')).length;
|
|
console.log(`\n${rows.length} files: ${rows.filter((r) => r[1] === 'same').length} same, ${rows.filter((r) => r[1] === 'whitespace only').length} whitespace only, ${content} differ in content`);
|