Files
threshing-atlas/site/build.js
T
d04b88e7b4 Site: show precomputed statistics; drop the upload and the click-to-select route map (#12)
Step 4a of the Python-first core.

- analysis/stats/measures.yaml (declarative): outcomes and denominators, route targets and
  comparison groups, encounter contexts, the route map's stages, six filter presets and the
  route thresholds (5, 10, 20, 30).
- analysis/stats/site_stats.py computes every number the page shows, for every preset, and
  writes data/public/stats.json: factor tables, models, chance events, encounters, the route map
  for every outcome, route rankings with q-values at every threshold, the valley map's place and
  step counts, and The Odds' summary cards.
- The page now only displays: app.js, ui.js and explorer.js read stats.json; engine.js is no
  longer loaded. The three filter controls become one "Runs" menu; minimum runs become fixed
  thresholds. Removed: "Load a newer route export", click-to-select and "Follow" on the Deep
  Dive route map, and the unused old valley renderer. The coded runs are a CSV download.
- tests/parity/compare_stats.py: every number matches what engine.js computed, for all six
  presets (factor tables, models, encounters, route rankings at every threshold, route map).


Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 21:37:10 +00:00

36 lines
1.8 KiB
JavaScript

// Assemble the static Atlas site into dist/ (no dependencies).
// node site/build.js [outDir]
const fs = require("fs");
const path = require("path");
const root = path.resolve(__dirname, "..");
const out = path.resolve(root, process.argv[2] || "dist");
const copy = (from, to) => {
fs.mkdirSync(path.dirname(path.join(out, to)), { recursive: true });
fs.copyFileSync(path.join(root, from), path.join(out, to));
};
fs.rmSync(out, { recursive: true, force: true });
for (const f of fs.readdirSync(path.join(root, "site/atlas"))) copy(`site/atlas/${f}`, f);
// The page is written as an Artifact body (the artifact host adds the document skeleton). For GitHub Pages and
// local serving, give it its own doctype, charset and viewport.
{
const p = path.join(out, "index.html");
const html = fs.readFileSync(p, "utf8");
if (!/^\s*<!doctype/i.test(html))
fs.writeFileSync(p, `<!doctype html>\n<meta charset="utf-8">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n${html}`);
}
// The route advisor and the bot's text mapping (Ken's bot downloads these two from the published site)
copy("core/graph.js", "graph.js");
copy("core/solver.js", "solver.js");
// The numbers the page shows (all computed in Python) and the published data
for (const f of ["stats.json", "register.json", "graph.json", "policy.json"]) copy(`data/public/${f}`, `data/${f}`);
copy("data/derived/runs_clean.csv", "data/runs_clean.csv");
// Source files shown in the page's "view the code" panel
copy("core/atlas/coding.py", "python/coding.py");
copy("core/spec/form.yaml", "python/form.yaml");
for (const f of ["measures.yaml", "site_stats.py", "stats_core.py"]) copy(`analysis/stats/${f}`, `python/${f}`);
copy("README.md", "README.md");
fs.writeFileSync(path.join(out, ".nojekyll"), "");
console.log(`Site built in ${path.relative(root, out) || "."}`);