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

@@ -25,13 +25,17 @@ outputs with sensitivity-aware **Floor / Realistic / Stretch** analysis.
```bash
cd ctm-token-calculator
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
pip install -e ".[app,notebook,dev]"
# Streamlit app (7 pages: Inputs → Export)
streamlit run app/streamlit_app.py
# Serve the notebooks as interactive web apps (Mercury)
mercury --working-dir notebooks/
# JupyterLab notebook variant (same numbers, same library)
jupyter lab notebooks/ctm_token_calculator.ipynb
# Or work on them directly in JupyterLab
jupyter lab notebooks/
# Export the corrected business case as LLM-readable report sources
# (exports/*.html for review, exports/*.md for feeding an LLM)
python scripts/export_report.py
# Tests
pytest
@@ -39,10 +43,21 @@ pytest
## Architecture
All math lives in the pure-Python `tokencalc/` library; the notebook and
Streamlit app are thin presentation layers calling the same functions —
Run-All in the notebook produces identical headline numbers to the app on
default inputs.
**The notebooks are the deliverables.** All math lives in the pure-Python
`tokencalc/` library; the notebooks are thin presentation layers over it.
[Mercury](https://runmercury.com) serves them as interactive web apps — the
`mercury` input widgets in `ctm_business_case_corrected.ipynb` let you tune
contract values, termination dates, token assumptions, and implementation
pricing live for a client, and headless runs (nbconvert, the section-10 regression
gate) simply use the widget defaults. `scripts/export_report.py` executes the
notebook and writes HTML + markdown to `exports/`; the notebook's section-12
machine-readable appendix carries every number behind the figures so an LLM
can draft the client report from the export.
| Notebook | Purpose |
|---|---|
| `notebooks/ctm_business_case_corrected.ipynb` | Client-facing corrected business case (Mercury-interactive) |
| `notebooks/ctm_token_calculator.ipynb` | Full token-cost / scenario workbench |
| Module | Purpose |
|---|---|