feat: update ctm-token-calculator to use Mercury and notebook deliverables

Replace Streamlit and JupyterLab commands with Mercury for serving interactive
notebooks as web apps. Update README to reflect new architecture where
notebooks are the primary deliverables, utilizing Mercury input widgets for
live client tuning. Add export_report.py script to generate LLM-readable
HTML/Markdown reports from the notebooks. Update corrected business case
notebook to include Mercury dependency and usage instructions.
This commit is contained in:
2026-07-07 17:04:53 -04:00
parent 0fa2091a25
commit c187bde188
10 changed files with 2970 additions and 1174 deletions

View File

@@ -0,0 +1,39 @@
"""Export the corrected business case notebook as LLM-readable report sources.
Executes the notebook fresh (widget defaults — or whatever defaults you edit in),
then writes both formats to exports/:
exports/ctm_business_case_corrected.html — human-reviewable, tables render
exports/ctm_business_case_corrected.md — leanest LLM input
Plotly figures export as JavaScript an LLM cannot read; the notebook's section-12
machine-readable appendix carries every number behind them.
Run from the project root: python scripts/export_report.py
"""
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
NOTEBOOK = ROOT / "notebooks" / "ctm_business_case_corrected.ipynb"
EXPORTS = ROOT / "exports"
def main() -> None:
EXPORTS.mkdir(exist_ok=True)
for fmt in ("html", "markdown"):
subprocess.run(
[sys.executable, "-m", "nbconvert", "--execute",
"--to", fmt, "--output-dir", str(EXPORTS), str(NOTEBOOK)],
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()