"""Export the deliverable notebook as LLM-readable report sources. Executes the notebook fresh (widget seeds — the mock scenario, or whatever seeds you edit in), then writes both formats to exports/: exports/diagnostic.html — human-reviewable, tables render exports/diagnostic.md — leanest LLM input Plotly figures export as JavaScript an LLM cannot read; the notebook's machine-readable appendix section carries every number behind them. Run from the project root: python scripts/export_report.py [name-filter] An optional argument exports only notebooks whose filename contains it. """ from __future__ import annotations import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parent.parent NOTEBOOKS = [ ROOT / "notebooks" / "diagnostic.ipynb", ] EXPORTS = ROOT / "exports" def main() -> None: picked = [nb for nb in NOTEBOOKS if len(sys.argv) < 2 or sys.argv[1] in nb.name] if not picked: sys.exit(f"no notebook matches {sys.argv[1]!r}") EXPORTS.mkdir(exist_ok=True) for nb in picked: for fmt in ("html", "markdown"): subprocess.run( [sys.executable, "-m", "nbconvert", "--execute", "--to", fmt, "--output-dir", str(EXPORTS), str(nb)], check=True, cwd=ROOT, ) for p in sorted(EXPORTS.iterdir()): if p.suffix in (".html", ".md"): print(f"wrote {p.relative_to(ROOT)} ({p.stat().st_size / 1024:,.0f} KB)") if __name__ == "__main__": main()