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
60 lines
2.7 KiB
JavaScript
60 lines
2.7 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Start a Mojo program of our own in the corpus: a probe or a stress program.
|
|
* (An exercise's program in mojo/local/ is made by `pixi run new-exercise <id>`,
|
|
* which also writes the exercise that shows it.)
|
|
*
|
|
* pixi run new-probe int-floordiv-negative "does // floor toward negative infinity?"
|
|
* pixi run new-stress ring-buffer "a fixed-size queue with wraparound"
|
|
*
|
|
* probe mojo/probes/<name>.mojo one question about the pinned compiler; godbolt's
|
|
* answer is the point (expectation: observe)
|
|
* stress mojo/stress/<name>.mojo realistic Mojo for the interpreter; its
|
|
* `# expect-stdout:` lines are the prediction that
|
|
* godbolt confirms or refutes (expectation: pass)
|
|
*
|
|
* Then: edit the file, `pixi run mojo-verify-item '<kind>/<name>'` (network), and
|
|
* `pixi run test`. docs/mojo-corpus.md, "Mojo of our own", has the header keys.
|
|
*/
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const ROOT = fileURLToPath(new URL('../..', import.meta.url));
|
|
const KINDS = {
|
|
probe: { dir: 'mojo/probes', corpus: 'probes' },
|
|
stress: { dir: 'mojo/stress', corpus: 'stress' },
|
|
};
|
|
|
|
function die(msg) { console.error(`new-program: ${msg}`); process.exit(1); }
|
|
|
|
const [kind, name, ...rest] = process.argv.slice(2);
|
|
const about = rest.join(' ').trim();
|
|
if (!KINDS[kind]) die('usage: new-program.mjs probe|stress <name> "<one line: the question, or what it exercises>"');
|
|
if (!name || !/^[a-z0-9]+(-[a-z0-9]+)*$/.test(name)) die(`"${name ?? ''}" is not a valid name: lowercase letters and digits, joined by single hyphens`);
|
|
if (!about) die(`say in one line what the ${kind} is about, after its name`);
|
|
|
|
const file = path.join(ROOT, KINDS[kind].dir, `${name}.mojo`);
|
|
if (fs.existsSync(file)) die(`${path.relative(ROOT, file)} already exists; nothing was changed`);
|
|
|
|
const text = kind === 'probe'
|
|
? `# probe: ${about}
|
|
def main():
|
|
print("replace this with the smallest program that answers the question")
|
|
`
|
|
: `# probe: ${about}
|
|
# status: the expected output is Programming+'s interpreter's prediction; corpus.py verify confirms or refutes it on godbolt
|
|
# expect-stdout: replace with the first line the program should print
|
|
def main():
|
|
print("replace with the first line the program should print")
|
|
`;
|
|
|
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
fs.writeFileSync(file, text);
|
|
console.log(`created ${path.relative(ROOT, file)}
|
|
|
|
next:
|
|
edit it (the header block is read by corpus.py verify; the program starts at the first other line)
|
|
pixi run mojo-verify-item '${KINDS[kind].corpus}/${name}' # ask godbolt (network)
|
|
pixi run test`);
|