diff --git a/assets/demo/site.py b/assets/demo/site.py index e3053753..f83fdbf8 100644 --- a/assets/demo/site.py +++ b/assets/demo/site.py @@ -211,14 +211,18 @@ def art(step: list[str]) -> list[str]: return out -def timing(typed: str, count: int, questions: int) -> str: - """CSS for when each step shows: the opening waits for a reader, the report streams.""" - typing = 0.03 * len(typed) - rules = [ - f".term.play .typed {{ animation: type {typing:.1f}s steps({len(typed)}) 0.3s both; }}", - f"@keyframes type {{ from {{ width: 0; }} to {{ width: {len(typed)}ch; }} }}", - ] - t = typing + 0.7 +def timing(typed: list[str], count: int, questions: int) -> str: + """CSS for when each step shows: the command types line by line, the opening waits for a + reader, the report streams.""" + rules, start = [], 0.3 + for n, line in enumerate(typed, 1): + typing = 0.03 * len(line) + rules += [ + f".term.play .typed:nth-of-type({n}) {{ animation: type{n} {typing:.1f}s steps({len(line)}) {start:.1f}s both; }}", + f"@keyframes type{n} {{ from {{ width: 0; }} to {{ width: {len(line)}ch; }} }}", + ] + start += typing + t = start + 0.4 for n in range(count): # The first step is the command line's sibling at nth-child(2). gap = 1.4 if n < questions else 0 @@ -229,6 +233,18 @@ def timing(typed: str, count: int, questions: int) -> str: return "\n".join(rules) + "\n" +def wrap(command: list[str]) -> list[str]: + """The command as shell lines that fit the terminal: each continued with a backslash, after + the first's "$ " prompt or a two-space indent.""" + lines = [command[0]] + for arg in command[1:]: + if len(lines[-1]) + len(arg) + len(" \\") + 3 <= COLUMNS: + lines[-1] += " " + arg + else: + lines.append(arg) + return [line + " \\" for line in lines[:-1]] + lines[-1:] + + def plain_lines(transcript: str) -> list[str]: """The run's lines without colors, each as its last overwrite left it.""" return [SGR.sub("", line.split("\r")[-1]) for line in transcript.replace("\r\n", "\n").split("\n")] @@ -539,8 +555,8 @@ def main() -> None: sys.exit("pass one --since YYYY-MM-DD, so the usage boxes can name their window") since = date.fromisoformat(starts[0]) billing = [f"--billing={profile}={answer}" for profile, answer in answers.items()] - # The page shows the command as run, answers included. - typed = " ".join(command + billing) + # The page shows the command as run, answers included, wrapped to fit the terminal. + typed = wrap(command + billing) # Doctor dates its window in UTC, ending when it runs. now = datetime.now(timezone.utc) transcript = run(command + billing, COLUMNS) @@ -552,7 +568,8 @@ def main() -> None: run_steps, questions = steps(transcript) figures, bars = results(transcript, plan, api, {p for p, a in answers.items() if a == "api"}, since, now) body = "".join(f'{chr(10).join(s)}\n' for s in run_steps) - fragment = f'
$ {typed}\n{body}
' + cmdline = "\n ".join(f'{html.escape(line)}' for line in typed) + fragment = f'
$ {cmdline}\n{body}
' replace(site / "index.html", "", "", fragment) replace(site / "index.html", "", "", figures) replace( diff --git a/quest/m2/agent-ergonomics/site-billing-refresh.md b/quest/m2/agent-ergonomics/site-billing-refresh.md deleted file mode 100644 index aa6a8e6e..00000000 --- a/quest/m2/agent-ergonomics/site-billing-refresh.md +++ /dev/null @@ -1,22 +0,0 @@ -# [XS] Regenerate max.kixel.me's terminal with --billing - -## Goal - -The site's recorded `doctor --defaults` run and its results come from the -`--billing` flow that `assets/demo/site.py` now uses. The page's first step is -the opening that lists what doctor read, the typed command shows the -`--billing` answers, and no billing question appears. - -## Plan - -Decided 2026-12-01 (maintainer, /quest-run, at the pick of -[kixel-ai/token-max#356](https://github.com/kixel-ai/token-max/pull/356)): ✅ -keep this follow-up (rejected: drop it). - -Run after the non-interactive doctor controls land on `main`, because site.py -needs the new `--billing` flag in the release build. The command, with -`PROFILE=plan|api` answers, is in `docs/releasing.md`. - -## Waiting - -- Maintainer (PC): on `nixos`, from an up-to-date `main` checkout after `cargo build --release`, run the site refresh command in `docs/releasing.md` (`python3 assets/demo/site.py site/public ~/.claude=plan ... --since "$(date -u -d '29 days ago' +%F)" --ssh desktop --ssh fedora`). Read the diff of `site/public/index.html` and `site/public/style.css` for private names before committing it. Then open the page and check that the opening shows first, then the report, and that the typed command fits the run box. This needs the maintainer's real transcripts on their hosts, which an agent cannot reach. diff --git a/site/public/index.html b/site/public/index.html index d7868841..e5bff8ca 100644 --- a/site/public/index.html +++ b/site/public/index.html @@ -75,37 +75,33 @@

Maximize your tokens

-
$ token-max doctor --defaults --since 2026-11-01 --ssh desktop --ssh fedora --ssh kixtop
+    
$ token-max doctor --defaults --since 2026-11-02 --ssh desktop --ssh fedora --ssh kixtop \
+  --billing=~/.claude=plan --billing=~/.claude-api-credits=api \
+  --billing=~/.claude-personal.merged-20261106=api --billing=desktop:~/.claude=plan \
+  --billing=desktop:~/.claude-api-credits=api --billing=fedora:~/.claude=plan \
+  --billing=kixtop:~/.claude=plan
   ▀█▀ █▀█ █▄▀ █▀▀ █▄ █ ▄▄ █▀▄▀█ ▄▀█ ▀▄▀  ●
    █  █▄█ █ █ ██▄ █ ▀█    █ ▀ █ █▀█ █ █  0.1.0
 
   About to scan this host's Claude Code and Codex transcripts for cost savings.
   Replays them at public API prices; prints no prompt or reply text.
 
-  ✓ Claude Code  ~/.claude                           4,076 transcripts  3.6 GB
+  ✓ Claude Code  ~/.claude                           4,264 transcripts  3.7 GB
   ✓ Claude Code  ~/.claude-api-credits                  66 transcripts   62 MB
   ✓ Claude Code  ~/.claude-personal.merged-20261106     11 transcripts  601 kB
-  ✓ Codex        ~/.codex                            3,444 transcripts  3.1 GB
+  ✓ Codex        ~/.codex                            3,533 transcripts  3.2 GB
   + desktop over SSH
   + fedora over SSH
   + kixtop over SSH
-
-  How is ~/.claude paid for? [p]lan, [a]PI key or usage credits, [s]kip: p
-  How is ~/.claude-api-credits paid for? [p]lan, [a]PI key or usage credits, [s]kip: a
-  How is ~/.claude-personal.merged-20261106 paid for? [p]lan, [a]PI key or usage credits, [s]kip: a
-  How is desktop:~/.claude paid for? [p]lan, [a]PI key or usage credits, [s]kip: p
-  How is desktop:~/.claude-api-credits paid for? [p]lan, [a]PI key or usage credits, [s]kip: a
-  How is fedora:~/.claude paid for? [p]lan, [a]PI key or usage credits, [s]kip: p
-  How is kixtop:~/.claude paid for? [p]lan, [a]PI key or usage credits, [s]kip: p
 
-token-max: total over 4 hosts  1,461,455 requests and 199,542,743,064 tokens in 45,123 sessions,
-                               ~$77,632 ± $19 at API prices
-  112 changes recommended and 87 worth considering.
-  From the defaults, these changes save ~$7,387/mo ± $12, 10% of these hosts' spend; overlapping
+token-max: total over 4 hosts  1,452,581 requests and 197,400,970,570 tokens in 45,632 sessions,
+                               ~$77,050 ± $19 at API prices
+  128 changes recommended and 80 worth considering.
+  From the defaults, these changes save ~$7,370/mo ± $13, 9% of these hosts' spend; overlapping
   changes may save less.
 
-  Left out or assumed: 3 unsupported T3 instances, 487 unattributed T3 requests, 221,132 removed T3
-  requests, 4,731 requests with no usage, 65 unreadable lines, 194,473 requests at an assumed
+  Left out or assumed: 3 unsupported T3 instances, 543 unattributed T3 requests, 197,847 removed T3
+  requests, 4,692 requests with no usage, 65 unreadable lines, 200,873 requests at an assumed
   service tier. --details says why.
   A ~ figure extrapolates from the priced requests to the unpriced ones, assuming they resemble each
   other; ± is its 95% margin of error.
@@ -114,61 +110,61 @@ 

Maximize your tokens

CHANGES biggest saving first ──────────────────────────────────────────────────────────────────── ● Prompt cache TTL subagent (fedora:~/.claude/settings.json) 5m → 1h, subagent (desktop:~/.claude/settings.json) 5m → 1h, subagent (kixtop:~/.claude/settings.json) 5m - → 1h, main (desktop:~/.claude-api-credits/settings.json) 5m (default) → 1h, subagent - (~/.claude/settings.json) 5m → 1h, subagent (desktop:~/.claude-api-credits/settings.json) 5m → - 1h saves ~$5,976/mo ± $9.82 8% [fedora:~/.claude/settings.json, - desktop:~/.claude/settings.json, kixtop:~/.claude/settings.json, - desktop:~/.claude-api-credits/settings.json, ~/.claude/settings.json] + → 1h, subagent (~/.claude/settings.json) 5m → 1h, main + (desktop:~/.claude-api-credits/settings.json) 5m (default) → 1h saves ~$5,903/mo ± $10 7% + [fedora:~/.claude/settings.json, desktop:~/.claude/settings.json, + kixtop:~/.claude/settings.json, ~/.claude/settings.json, + desktop:~/.claude-api-credits/settings.json] fedora:~/.claude/settings.json:subagentPromptCacheTtl; desktop:~/.claude/settings.json:subagentPromptCacheTtl; kixtop:~/.claude/settings.json:subagentPromptCacheTtl; - desktop:~/.claude-api-credits/settings.json:promptCacheTtl, subagentPromptCacheTtl; - ~/.claude/settings.json:subagentPromptCacheTtl - ● Auto memory 3 → off saves ~$336/mo ± $2.47 <1% + ~/.claude/settings.json:subagentPromptCacheTtl; + desktop:~/.claude-api-credits/settings.json:promptCacheTtl + ● Auto memory 3 → off saves ~$354/mo ± $2.50 <1% [desktop:~/.claude/settings.json, fedora:~/.claude/settings.json, ~/.claude/settings.json] desktop:~/.claude/settings.json:autoMemoryEnabled; fedora:~/.claude/settings.json:autoMemoryEnabled; ~/.claude/settings.json:autoMemoryEnabled - ● Tools over $1 per use 4 → off saves ~$215/mo ± $0.04 <1% + ● Tools over $1 per use 4 → off saves ~$225/mo ± $0.04 <1% [desktop:~/.claude/settings.json, fedora:~/.claude/settings.json, ~/.claude/settings.json] desktop:~/.claude/settings.json:enableWorkflows; fedora:~/.claude/settings.json:permissions.deny; ~/.claude/settings.json:permissions.deny - ● Skills over $1 per use 14 → typed only saves ~$184/mo ± $0.17 <1% + ● Skills over $1 per use 14 → typed only saves ~$192/mo ± $0.17 <1% [fedora:~/.claude/settings.json, desktop:~/.claude/settings.json, ~/.claude/settings.json] fedora:~/.claude/settings.json:skillOverrides.*; desktop:~/.claude/settings.json:skillOverrides.*; ~/.claude/settings.json:skillOverrides.* - ● Never-used tools 30 → off saves ~$176/mo ± $0.04 <1% + ● Never-used tools 40 → off saves ~$178/mo ± $0.04 <1% [fedora:~/.claude/settings.json, ~/.claude/settings.json, desktop:~/.claude-api-credits/settings.json] fedora:~/.claude/settings.json:enableWorkflows, permissions.deny; ~/.claude/settings.json:enableWorkflows, permissions.deny; - desktop:~/.claude-api-credits/settings.json:enableWorkflows, permissions.deny - ● Skills with no recorded use 40 → typed only saves ~$169/mo ± $1.12 <1% + desktop:~/.claude-api-credits/settings.json:permissions.deny, enableWorkflows + ● Skills with no recorded use 37 → typed only saves ~$175/mo ± $1.17 <1% [desktop:~/.claude/settings.json, fedora:~/.claude/settings.json, - kixtop:~/.claude/settings.json, ~/.claude/settings.json, - desktop:~/.claude-api-credits/settings.json] desktop:~/.claude/settings.json:skillOverrides.*; + kixtop:~/.claude/settings.json, ~/.claude/settings.json] + desktop:~/.claude/settings.json:skillOverrides.*; fedora:~/.claude/settings.json:skillOverrides.*; - kixtop:~/.claude/settings.json:skillOverrides.*; ~/.claude/settings.json:skillOverrides.*; - desktop:~/.claude-api-credits/settings.json:skillOverrides.* - ● Skills the model never used 41 → typed only saves ~$153/mo ± $0.16 <1% + kixtop:~/.claude/settings.json:skillOverrides.*; ~/.claude/settings.json:skillOverrides.* + ● Skills the model never used 47 → typed only saves ~$155/mo ± $0.16 <1% [fedora:~/.claude/settings.json, ~/.claude/settings.json, desktop:~/.claude-api-credits/settings.json] fedora:~/.claude/settings.json:skillOverrides.*; ~/.claude/settings.json:skillOverrides.*; desktop:~/.claude-api-credits/settings.json:skillOverrides.* - ● Tools with no recorded use 22 → off saves ~$131/mo ± $0.07 <1% - [desktop:~/.claude/settings.json, kixtop:~/.claude/settings.json, - desktop:~/.claude-api-credits/settings.json] desktop:~/.claude/settings.json:permissions.deny; - kixtop:~/.claude/settings.json:enableWorkflows, permissions.deny; - desktop:~/.claude-api-credits/settings.json:permissions.deny - ● MCP tools over $1 per use 2 → off saves ~$48/mo ± <$0.01 <1% + ● Tools with no recorded use 18 → off saves ~$138/mo ± $0.06 <1% + [desktop:~/.claude/settings.json, kixtop:~/.claude/settings.json] + desktop:~/.claude/settings.json:permissions.deny; + kixtop:~/.claude/settings.json:enableWorkflows, permissions.deny + ● MCP tools over $1 per use 2 → off saves ~$50/mo ± <$0.01 <1% [fedora:~/.claude/settings.json, desktop:~/.claude/settings.json] fedora:~/.claude/settings.json:permissions.deny; desktop:~/.claude/settings.json:permissions.deny + ● MCP tools with no recorded use 2 → off saves ~$0.32/mo ± <$0.01 <1% + [kixtop:~/.claude/settings.json] permissions.deny ● Never-used skills 35 → off saves $0.28/mo <1% [desktop:T3 opencode] desktop:~/.config/opencode/opencode.jsonc:permission.skill.* - ● MCP tools with no recorded use 2 → off saves ~$0.20/mo ± <$0.01 <1% - [kixtop:~/.claude/settings.json] permissions.deny + ● Auto memory on → off saves ~$0.05/mo ± <$0.01 <1% + [desktop:~/.claude-api-credits/settings.json] autoMemoryEnabled (default)
EVERYTHING ELSE biggest cost first ────────────────────────────────────────────────────────────── - … 141 lines on every other setting and feature, cut from this page + … 139 lines on every other setting and feature, cut from this page Prices: bundled from https://models.dev/api.json (2026-11-30). Each line compares one setting with everything else unchanged, so a sum of savings may count the @@ -176,13 +172,13 @@

Maximize your tokens

--details lists each line a row sums, with the evidence, assumptions and sources behind each.
EDITS ~/.claude/settings.json ─────────────────────────────────────────────────────────────────── - … 9 lines naming each edit, cut from this page + … 8 lines naming each edit, cut from this page EDITS desktop:~/.claude/settings.json ─────────────────────────────────────────────────────────── … 9 lines naming each edit, cut from this page EDITS desktop:~/.claude-api-credits/settings.json ─────────────────────────────────────────────── - … 10 lines naming each edit, cut from this page + … 12 lines naming each edit, cut from this page EDITS desktop:~/.config/opencode/opencode.jsonc ───────────────────────────────────────────────── … 5 lines naming each edit, cut from this page @@ -201,34 +197,34 @@

Maximize your tokens

My usage:

-

Tokens

199.5B

-

Requests

1,461,455

-

API price, 30 days

~$77,632

+

Tokens

197.4B

+

Requests

1,452,581

+

API price, 29 days

~$77,050

What token-max saves

On my subscription

-

10% saved

-

~$7,387/mo at API rates

+

9% saved

+

~$7,370/mo at API rates

If I used the API

32% saved

-

~$24,611/mo

+

~$25,039/mo

Where it comes from, at API rates

    -
  1. Main-agent prompt cache TTL API only~$17,478/mo
  2. -
  3. Subagent prompt cache TTL~$5,744/mo, all of it on my subscription too
  4. -
  5. Skills (59)~$505/mo, ~$500/mo of it on my subscription too
  6. -
  7. Auto memory~$335/mo, all of it on my subscription too
  8. -
  9. Workflow tool~$216/mo, ~$213/mo of it on my subscription too
  10. -
  11. Everything else (19 settings)~$331/mo, ~$328/mo of it on my subscription too
  12. +
  13. Main-agent prompt cache TTL API only~$17,683/mo
  14. +
  15. Subagent prompt cache TTL~$5,888/mo, all of it on my subscription too
  16. +
  17. Skills (58)~$524/mo, all of it on my subscription too
  18. +
  19. Auto memory~$354/mo, all of it on my subscription too
  20. +
  21. Workflow tool~$223/mo, all of it on my subscription too
  22. +
  23. Everything else (24 settings)~$367/mo, all of it on my subscription too

saves on my subscription toosaves only at API rates

-

Replayed at public API prices on 4 of my machines on 2026-11-30, each change +

Replayed at public API prices on 4 of my machines on 2026-12-01, each change priced alone, so together they may save less. ~ marks figures extrapolated over unpriced requests, assuming they resemble the priced ones.

diff --git a/site/public/style.css b/site/public/style.css index 285198c7..8d32fb86 100644 --- a/site/public/style.css +++ b/site/public/style.css @@ -166,35 +166,37 @@ h1 { margin: 0; text-wrap: balance; } animation: blink 1s step-end infinite; } /* run: assets/demo/site.py writes the run's timing and the breakdown's bars here */ -.term.play .typed { animation: type 2.6s steps(86) 0.3s both; } -@keyframes type { from { width: 0; } to { width: 86ch; } } -.step:nth-child(2) { --t: 3.3s; --gap: 1.4s; } -.step:nth-child(3) { --t: 5.3s; --gap: 1.4s; } -.step:nth-child(4) { --t: 7.3s; --gap: 1.4s; } -.step:nth-child(5) { --t: 9.3s; --gap: 1.4s; } -.step:nth-child(6) { --t: 11.3s; --gap: 1.4s; } -.step:nth-child(7) { --t: 13.3s; --gap: 1.4s; } -.step:nth-child(8) { --t: 15.3s; --gap: 1.4s; } -.step:nth-child(9) { --t: 18.2s; --gap: 0.0s; } -.step:nth-child(10) { --t: 20.7s; --gap: 0.0s; } -.step:nth-child(11) { --t: 21.3s; --gap: 0.0s; } -.step:nth-child(12) { --t: 21.9s; --gap: 0.0s; } -.step:nth-child(13) { --t: 22.5s; --gap: 0.0s; } -.step:nth-child(14) { --t: 23.1s; --gap: 0.0s; } -.step:nth-child(15) { --t: 23.7s; --gap: 0.0s; } -.step:nth-child(16) { --t: 24.3s; --gap: 0.0s; } -.step:nth-child(17) { --t: 24.9s; --gap: 0.0s; } +.term.play .typed:nth-of-type(1) { animation: type1 2.6s steps(88) 0.3s both; } +@keyframes type1 { from { width: 0; } to { width: 88ch; } } +.term.play .typed:nth-of-type(2) { animation: type2 1.9s steps(62) 2.9s both; } +@keyframes type2 { from { width: 0; } to { width: 62ch; } } +.term.play .typed:nth-of-type(3) { animation: type3 2.5s steps(83) 4.8s both; } +@keyframes type3 { from { width: 0; } to { width: 83ch; } } +.term.play .typed:nth-of-type(4) { animation: type4 2.3s steps(77) 7.3s both; } +@keyframes type4 { from { width: 0; } to { width: 77ch; } } +.term.play .typed:nth-of-type(5) { animation: type5 0.9s steps(31) 9.6s both; } +@keyframes type5 { from { width: 0; } to { width: 31ch; } } +.step:nth-child(2) { --t: 10.9s; --gap: 1.4s; } +.step:nth-child(3) { --t: 13.8s; --gap: 0.0s; } +.step:nth-child(4) { --t: 16.3s; --gap: 0.0s; } +.step:nth-child(5) { --t: 16.9s; --gap: 0.0s; } +.step:nth-child(6) { --t: 17.5s; --gap: 0.0s; } +.step:nth-child(7) { --t: 18.1s; --gap: 0.0s; } +.step:nth-child(8) { --t: 18.7s; --gap: 0.0s; } +.step:nth-child(9) { --t: 19.3s; --gap: 0.0s; } +.step:nth-child(10) { --t: 19.9s; --gap: 0.0s; } +.step:nth-child(11) { --t: 20.5s; --gap: 0.0s; } .breakdown li:nth-child(1) .plan { width: 0.0%; } .breakdown li:nth-child(1) .api { width: 100.0%; } -.breakdown li:nth-child(2) .plan { width: 32.9%; } +.breakdown li:nth-child(2) .plan { width: 33.3%; } .breakdown li:nth-child(2) .api { width: 0.0%; } -.breakdown li:nth-child(3) .plan { width: 2.9%; } +.breakdown li:nth-child(3) .plan { width: 3.0%; } .breakdown li:nth-child(3) .api { width: 0.3%; } -.breakdown li:nth-child(4) .plan { width: 1.9%; } -.breakdown li:nth-child(4) .api { width: 0.0%; } -.breakdown li:nth-child(5) .plan { width: 1.2%; } +.breakdown li:nth-child(4) .plan { width: 2.0%; } +.breakdown li:nth-child(4) .api { width: 0.3%; } +.breakdown li:nth-child(5) .plan { width: 1.3%; } .breakdown li:nth-child(5) .api { width: 0.3%; } -.breakdown li:nth-child(6) .plan { width: 1.9%; } +.breakdown li:nth-child(6) .plan { width: 2.1%; } .breakdown li:nth-child(6) .api { width: 0.3%; } /* /run */ @keyframes blink { 50% { opacity: 0; } }