@alexgreensh/token-optimizer 5.13.69 → 5.13.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/PRIVACY.md +4 -0
- package/hooks/hooks.json +11 -1
- package/hooks/module_runner.py +4 -1
- package/hooks/posttooluse_runner.py +44 -48
- package/hooks/sessionstart_runner.py +24 -5
- package/hooks/stop_runner.py +6 -6
- package/package.json +1 -1
- package/skills/token-optimizer/assets/dashboard.html +729 -767
- package/skills/token-optimizer/assets/savings_story.js +765 -0
- package/skills/token-optimizer/pricing/prices.json +1 -0
- package/skills/token-optimizer/references/cli-reference.md +1 -1
- package/skills/token-optimizer/references/implementation-playbook.md +3 -0
- package/skills/token-optimizer/scripts/_measure/__init__.py +3 -1
- package/skills/token-optimizer/scripts/_measure/archive_health.py +14 -0
- package/skills/token-optimizer/scripts/_measure/archive_void_codex.py +163 -0
- package/skills/token-optimizer/scripts/_measure/archive_void_evidence.py +165 -0
- package/skills/token-optimizer/scripts/_measure/audit.py +27 -135
- package/skills/token-optimizer/scripts/_measure/baseline_provenance.py +339 -0
- package/skills/token-optimizer/scripts/_measure/cache_policy.py +261 -581
- package/skills/token-optimizer/scripts/_measure/checkpoint_direction.py +97 -0
- package/skills/token-optimizer/scripts/_measure/checkpoint_retention.py +20 -0
- package/skills/token-optimizer/scripts/_measure/cli.py +12 -8
- package/skills/token-optimizer/scripts/_measure/codex_quality.py +246 -0
- package/skills/token-optimizer/scripts/_measure/compaction_survival.py +158 -0
- package/skills/token-optimizer/scripts/_measure/compression_fixture_void.py +147 -0
- package/skills/token-optimizer/scripts/_measure/compression_scan_checkpoint.py +72 -0
- package/skills/token-optimizer/scripts/_measure/context_reset_marker.py +66 -0
- package/skills/token-optimizer/scripts/_measure/continuity.py +64 -118
- package/skills/token-optimizer/scripts/_measure/cost_per_message_trend.py +40 -0
- package/skills/token-optimizer/scripts/_measure/counted_cap.py +30 -0
- package/skills/token-optimizer/scripts/_measure/counted_orphans.py +190 -0
- package/skills/token-optimizer/scripts/_measure/counted_position.py +20 -0
- package/skills/token-optimizer/scripts/_measure/counted_pricing_v5.py +267 -0
- package/skills/token-optimizer/scripts/_measure/counted_subagents.py +371 -0
- package/skills/token-optimizer/scripts/_measure/coverage_report.py +295 -0
- package/skills/token-optimizer/scripts/_measure/daemon.py +53 -74
- package/skills/token-optimizer/scripts/_measure/dashboard.py +90 -151
- package/skills/token-optimizer/scripts/_measure/dashboard_heal_claim.py +36 -0
- package/skills/token-optimizer/scripts/_measure/evidence_parallel.py +95 -0
- package/skills/token-optimizer/scripts/_measure/feature_health.py +256 -0
- package/skills/token-optimizer/scripts/_measure/file_refetch.py +250 -0
- package/skills/token-optimizer/scripts/_measure/first_call_context.py +216 -0
- package/skills/token-optimizer/scripts/_measure/first_read_outcomes.py +261 -0
- package/skills/token-optimizer/scripts/_measure/first_read_revive.py +137 -0
- package/skills/token-optimizer/scripts/_measure/fixture_context.py +65 -0
- package/skills/token-optimizer/scripts/_measure/headline.py +100 -0
- package/skills/token-optimizer/scripts/_measure/holdout_fallback.py +96 -0
- package/skills/token-optimizer/scripts/_measure/holdout_report.py +129 -0
- package/skills/token-optimizer/scripts/_measure/keepwarm_economics.py +201 -0
- package/skills/token-optimizer/scripts/_measure/keepwarm_linux.py +121 -0
- package/skills/token-optimizer/scripts/_measure/keepwarm_safety.py +260 -0
- package/skills/token-optimizer/scripts/_measure/lean_resume_receivers.py +260 -0
- package/skills/token-optimizer/scripts/_measure/lean_resume_threshold.py +76 -0
- package/skills/token-optimizer/scripts/_measure/lease_candidate_cleanup.py +82 -0
- package/skills/token-optimizer/scripts/_measure/lifecycle.py +54 -162
- package/skills/token-optimizer/scripts/_measure/mcp_archive_tripwire.py +120 -0
- package/skills/token-optimizer/scripts/_measure/mod_action_booking.py +178 -0
- package/skills/token-optimizer/scripts/_measure/mod_compaction_booking.py +276 -0
- package/skills/token-optimizer/scripts/_measure/mod_fresh_booking.py +105 -0
- package/skills/token-optimizer/scripts/_measure/output_reread.py +629 -0
- package/skills/token-optimizer/scripts/_measure/own_price_card.py +268 -0
- package/skills/token-optimizer/scripts/_measure/periphery_exposure.py +85 -0
- package/skills/token-optimizer/scripts/_measure/pricing.py +152 -87
- package/skills/token-optimizer/scripts/_measure/quality_archive.py +159 -215
- package/skills/token-optimizer/scripts/_measure/quality_checkpoint.py +174 -0
- package/skills/token-optimizer/scripts/_measure/quality_continuity.py +43 -0
- package/skills/token-optimizer/scripts/_measure/rework_metrics.py +194 -0
- package/skills/token-optimizer/scripts/_measure/routing_period.py +48 -0
- package/skills/token-optimizer/scripts/_measure/savings.py +439 -864
- package/skills/token-optimizer/scripts/_measure/savings_headline.py +130 -0
- package/skills/token-optimizer/scripts/_measure/savings_story.py +187 -0
- package/skills/token-optimizer/scripts/_measure/session_best.py +24 -0
- package/skills/token-optimizer/scripts/_measure/session_effect.py +557 -0
- package/skills/token-optimizer/scripts/_measure/session_flush_lock.py +75 -0
- package/skills/token-optimizer/scripts/_measure/session_store_spool.py +220 -0
- package/skills/token-optimizer/scripts/_measure/sessions.py +103 -196
- package/skills/token-optimizer/scripts/_measure/setup_attachment_counter.py +196 -0
- package/skills/token-optimizer/scripts/_measure/setup_budget_monitor.py +180 -0
- package/skills/token-optimizer/scripts/_measure/setup_connector_ledger.py +126 -0
- package/skills/token-optimizer/scripts/_measure/setup_step.py +220 -0
- package/skills/token-optimizer/scripts/_measure/status_bar_lock.py +117 -0
- package/skills/token-optimizer/scripts/_measure/structural_archives.py +79 -0
- package/skills/token-optimizer/scripts/_measure/structural_dedupe.py +91 -0
- package/skills/token-optimizer/scripts/_measure/structural_ledger.py +418 -0
- package/skills/token-optimizer/scripts/_measure/structural_listing.py +163 -0
- package/skills/token-optimizer/scripts/_measure/structural_report.py +339 -0
- package/skills/token-optimizer/scripts/_measure/structural_seed.py +164 -0
- package/skills/token-optimizer/scripts/_measure/structural_value.py +248 -0
- package/skills/token-optimizer/scripts/_measure/structure_funnel.py +97 -0
- package/skills/token-optimizer/scripts/_measure/timestamp_cache.py +11 -0
- package/skills/token-optimizer/scripts/_measure/token_type_split.py +29 -0
- package/skills/token-optimizer/scripts/_measure/transcript_backfill.py +419 -0
- package/skills/token-optimizer/scripts/_measure/transcript_product.py +228 -0
- package/skills/token-optimizer/scripts/_measure/transcript_stream.py +279 -0
- package/skills/token-optimizer/scripts/_measure/trends.py +44 -185
- package/skills/token-optimizer/scripts/_measure/ttl_period.py +6 -0
- package/skills/token-optimizer/scripts/_measure/upgrade_drain_control.py +287 -0
- package/skills/token-optimizer/scripts/activity_tracker.py +4 -33
- package/skills/token-optimizer/scripts/antigravity_install.py +2 -0
- package/skills/token-optimizer/scripts/archive_result.py +15 -19
- package/skills/token-optimizer/scripts/archive_verify.py +165 -0
- package/skills/token-optimizer/scripts/bash_compress.py +14 -43
- package/skills/token-optimizer/scripts/bash_compress_hook.py +132 -2
- package/skills/token-optimizer/scripts/checkpoint_state.py +2 -2
- package/skills/token-optimizer/scripts/cloud_kit.py +3 -6
- package/skills/token-optimizer/scripts/codemap.py +274 -0
- package/skills/token-optimizer/scripts/codemap_hint.py +153 -0
- package/skills/token-optimizer/scripts/codemap_index.py +656 -0
- package/skills/token-optimizer/scripts/codemap_ledger.py +309 -0
- package/skills/token-optimizer/scripts/codemap_reread.py +161 -0
- package/skills/token-optimizer/scripts/codex_doctor.py +9 -1
- package/skills/token-optimizer/scripts/codex_log_index.py +34 -15
- package/skills/token-optimizer/scripts/codex_session.py +16 -216
- package/skills/token-optimizer/scripts/compression_backfill.py +4 -35
- package/skills/token-optimizer/scripts/context_intel.py +5 -3
- package/skills/token-optimizer/scripts/copilot_install.py +2 -0
- package/skills/token-optimizer/scripts/coverage_funnel.py +261 -0
- package/skills/token-optimizer/scripts/cursor_install.py +12 -0
- package/skills/token-optimizer/scripts/cursor_quality.py +16 -64
- package/skills/token-optimizer/scripts/dashboard_assets.py +21 -0
- package/skills/token-optimizer/scripts/deterministic_candidates.py +2 -10
- package/skills/token-optimizer/scripts/devin_source.py +8 -3
- package/skills/token-optimizer/scripts/devin_verify.py +7 -1
- package/skills/token-optimizer/scripts/grok_install.py +2 -0
- package/skills/token-optimizer/scripts/heal_report.py +7 -6
- package/skills/token-optimizer/scripts/hermes_doctor.py +9 -1
- package/skills/token-optimizer/scripts/hermes_install.py +7 -1
- package/skills/token-optimizer/scripts/hermes_session.py +14 -136
- package/skills/token-optimizer/scripts/hint_paths.py +21 -0
- package/skills/token-optimizer/scripts/holdout.py +136 -0
- package/skills/token-optimizer/scripts/hook_runtime.py +1 -0
- package/skills/token-optimizer/scripts/hook_skip_log.py +89 -0
- package/skills/token-optimizer/scripts/large_transcripts.py +31 -0
- package/skills/token-optimizer/scripts/lean_resume_carry.py +518 -0
- package/skills/token-optimizer/scripts/measure.py +34 -76
- package/skills/token-optimizer/scripts/post_run_classify.py +349 -0
- package/skills/token-optimizer/scripts/preserved_reinject.py +54 -0
- package/skills/token-optimizer/scripts/read_cache.py +99 -100
- package/skills/token-optimizer/scripts/reset_epoch.py +3 -3
- package/skills/token-optimizer/scripts/session_store.py +49 -99
- package/skills/token-optimizer/scripts/session_store_guard.py +75 -0
- package/skills/token-optimizer/scripts/settings_backup.py +379 -0
- package/skills/token-optimizer/scripts/shipped_hook_templates.py +1 -0
- package/skills/token-optimizer/scripts/statusline.js +144 -30
- package/skills/token-optimizer/scripts/structural.py +25 -0
- package/skills/token-optimizer/scripts/structure_map.py +4 -26
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
@media (prefers-reduced-motion: reduce) {
|
|
21
21
|
*, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
|
|
22
22
|
}
|
|
23
|
-
|
|
24
23
|
/* ========== THEME TOKENS ==========
|
|
25
24
|
Dark is the DEFAULT and is pixel-unchanged: every value below is the exact
|
|
26
25
|
literal the dashboard already shipped, just lifted into a named token. The
|
|
@@ -135,7 +134,6 @@
|
|
|
135
134
|
--glow-sm: 0 0 10px var(--c-accent-glow);
|
|
136
135
|
--glow-text: 0 0 8px rgba(0, 240, 255, 0.6);
|
|
137
136
|
}
|
|
138
|
-
|
|
139
137
|
/* ========== LIGHT THEME ==========
|
|
140
138
|
Same visual language (cyan-accent technical dashboard), inverted lightness.
|
|
141
139
|
Activation order (no FOUC, see inline boot script in <head>):
|
|
@@ -274,7 +272,7 @@ th, td { padding: 10px !important; }
|
|
|
274
272
|
gap: 8px; font-family: var(--font-mono); font-size: 14px;
|
|
275
273
|
color: var(--c-accent-cyan); user-select: none; padding: 6px 0;
|
|
276
274
|
}
|
|
277
|
-
.fold > summary::-webkit-details-marker { display: none; }
|
|
275
|
+
.fold > summary { position:relative; min-height:40px; } .fold__body { opacity:1; transform:translateY(0); transition:opacity .18s ease-out, transform .18s ease-out; } @starting-style { .fold[open] > .fold__body { opacity:0; transform:translateY(4px); } } .fold > summary::-webkit-details-marker { display: none; }
|
|
278
276
|
.fold > summary::before {
|
|
279
277
|
content: "\25B8"; font-size: 11px; display: inline-block;
|
|
280
278
|
transition: transform .15s ease;
|
|
@@ -396,13 +394,12 @@ h1, h2, h3, h4 { font-weight: 400; }
|
|
|
396
394
|
text-transform: uppercase;
|
|
397
395
|
letter-spacing: 0.1em;
|
|
398
396
|
font-size: 15px;
|
|
399
|
-
border-
|
|
397
|
+
border-radius: 6px;
|
|
400
398
|
}
|
|
401
399
|
|
|
402
400
|
.nav-item:hover, .nav-item.active {
|
|
403
401
|
color: var(--c-text-main);
|
|
404
402
|
background: var(--c-accent-soft);
|
|
405
|
-
border-left-color: var(--c-accent-cyan);
|
|
406
403
|
text-shadow: var(--glow-text);
|
|
407
404
|
}
|
|
408
405
|
|
|
@@ -431,7 +428,7 @@ h1, h2, h3, h4 { font-weight: 400; }
|
|
|
431
428
|
|
|
432
429
|
.user-profile i {
|
|
433
430
|
font-family: var(--font-mono);
|
|
434
|
-
font-style:
|
|
431
|
+
font-style: normal;
|
|
435
432
|
color: var(--c-accent-cyan);
|
|
436
433
|
}
|
|
437
434
|
|
|
@@ -1375,9 +1372,8 @@ input:checked + .slider:before {
|
|
|
1375
1372
|
.metric-unit {
|
|
1376
1373
|
font-family: var(--font-sans);
|
|
1377
1374
|
font-weight: 500;
|
|
1378
|
-
font-size:
|
|
1379
|
-
color: var(--c-text-
|
|
1380
|
-
letter-spacing: 0.03em;
|
|
1375
|
+
font-size: 22px;
|
|
1376
|
+
color: var(--c-text-main);
|
|
1381
1377
|
}
|
|
1382
1378
|
.metric-sub.tight {
|
|
1383
1379
|
font-size: 18px;
|
|
@@ -1392,18 +1388,17 @@ input:checked + .slider:before {
|
|
|
1392
1388
|
.ts-divider { height: 1px; background: var(--c-border); margin: var(--s-4) 0 var(--s-3); }
|
|
1393
1389
|
|
|
1394
1390
|
.ts-section-label {
|
|
1395
|
-
font-family: var(--font-
|
|
1396
|
-
font-size:
|
|
1397
|
-
|
|
1398
|
-
text-
|
|
1399
|
-
letter-spacing: 0.08em;
|
|
1391
|
+
font-family: var(--font-sans);
|
|
1392
|
+
font-size: 17px;
|
|
1393
|
+
font-weight: 600;
|
|
1394
|
+
color: var(--c-text-main);
|
|
1400
1395
|
margin-bottom: var(--s-2);
|
|
1401
1396
|
display: flex;
|
|
1402
1397
|
justify-content: space-between;
|
|
1403
1398
|
align-items: baseline;
|
|
1404
1399
|
gap: var(--s-3);
|
|
1405
1400
|
}
|
|
1406
|
-
.ts-section-label .muted {
|
|
1401
|
+
.ts-section-label .muted { color: var(--c-text-main); font-weight: 400; font-size: 14px; }
|
|
1407
1402
|
|
|
1408
1403
|
/* spent-vs-saved combined bar: one row, two proportional segments. */
|
|
1409
1404
|
.sv-bar {
|
|
@@ -1424,9 +1419,9 @@ input:checked + .slider:before {
|
|
|
1424
1419
|
|
|
1425
1420
|
.ts-foot {
|
|
1426
1421
|
margin-top: var(--s-4);
|
|
1427
|
-
font-family: var(--font-
|
|
1428
|
-
font-size:
|
|
1429
|
-
color: var(--c-text-
|
|
1422
|
+
font-family: var(--font-sans);
|
|
1423
|
+
font-size: 15px;
|
|
1424
|
+
color: var(--c-text-main);
|
|
1430
1425
|
line-height: 1.6;
|
|
1431
1426
|
text-wrap: pretty;
|
|
1432
1427
|
}
|
|
@@ -1546,7 +1541,6 @@ input:checked + .slider:before {
|
|
|
1546
1541
|
.rec-callout {
|
|
1547
1542
|
background: var(--c-surface);
|
|
1548
1543
|
border: 1px solid var(--c-border);
|
|
1549
|
-
border-left: 3px solid var(--c-accent-cyan);
|
|
1550
1544
|
border-radius: 8px;
|
|
1551
1545
|
padding: var(--s-3) var(--s-4);
|
|
1552
1546
|
margin-bottom: var(--s-2);
|
|
@@ -1714,6 +1708,124 @@ input:checked + .slider:before {
|
|
|
1714
1708
|
border: 1px solid var(--c-border);
|
|
1715
1709
|
}
|
|
1716
1710
|
|
|
1711
|
+
/* ========== SAVINGS STORY (U9, assets/savings_story.js) ==========
|
|
1712
|
+
Card titles are headings (no small-caps labels above them). Sans for words,
|
|
1713
|
+
mono only for standalone figures; numbers inside sentences use the sans face
|
|
1714
|
+
with tabular figures. Secondary lines stay in --c-text-main for readability. */
|
|
1715
|
+
html { -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; } em, i { font-style: normal; } h1,h2,h3 { text-wrap: balance; } p,li { text-wrap: pretty; } .st-enter .st > * { animation: st-enter .32s ease-out both; } .st-enter .st > :nth-child(2) { animation-delay:90ms; } .st-enter .st > :nth-child(3) { animation-delay:180ms; } .st-enter .st > :nth-child(4) { animation-delay:270ms; } .st-enter .st > :nth-child(5) { animation-delay:360ms; } .st-enter .st > :nth-child(6) { animation-delay:450ms; } @keyframes st-enter { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } } @media (prefers-reduced-motion:reduce) { .st-enter .st > * { animation:none; } .fold__body { transition:none; } .fold > summary::before { transition:none; } } .st { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); margin-bottom: var(--s-3); } .st .card.wide { grid-column: auto; }
|
|
1716
|
+
.st .card { padding: var(--s-4); border: 0; box-shadow: 0 0 0 1px rgba(255,255,255,.09), 0 2px 6px rgba(0,0,0,.12); } [data-theme="light"] .st .card { box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 2px 5px rgba(0,0,0,.06); } .st .st-table { box-shadow: 0 0 0 1px rgba(251,191,36,.4), 0 0 44px rgba(251,191,36,.1); }
|
|
1717
|
+
.st .st-limits-card { padding: var(--s-4); display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--s-4) var(--s-6, 48px); align-items: start; }
|
|
1718
|
+
.st-limits__mega { margin: var(--s-2) 0 0; }
|
|
1719
|
+
.st-limits__mega .st-mega { font-size: clamp(64px, 7vw, 104px); }
|
|
1720
|
+
.st-limits__body .fold { margin-top: var(--s-3); }
|
|
1721
|
+
.st-limitbar { margin-bottom: var(--s-4); }
|
|
1722
|
+
.st-limitbar__label { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-2) var(--s-4); flex-wrap: wrap; font: 500 15px/1.4 var(--font-sans); color: var(--c-text-main); margin-bottom: 6px; }
|
|
1723
|
+
.st-limitbar__val { color: var(--c-text-main); font-size: 14px; }
|
|
1724
|
+
.st-limitbar__track { position: relative; height: 14px; border-radius: 7px; overflow: hidden; background: var(--c-elev-3); box-shadow: inset 0 0 0 1px var(--c-border); }
|
|
1725
|
+
.st-limitbar__fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 7px; background: var(--c-accent-cyan); box-shadow: 0 0 10px var(--c-accent-cyan); transition: width 600ms cubic-bezier(0.2, 0, 0, 1); }
|
|
1726
|
+
.st-limitbar__fill--ghost { background: repeating-linear-gradient(135deg, var(--c-warning-2) 0 3px, transparent 3px 7px); opacity: 0.75; box-shadow: none; }
|
|
1727
|
+
.st-fixcell { display: inline-flex; align-items: center; gap: var(--s-3); flex: none; }
|
|
1728
|
+
.st-fix { min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--c-border-strong); background: var(--c-elev-2); color: var(--c-text-main); font: 600 14px/1 var(--font-sans); cursor: pointer; white-space: nowrap; }
|
|
1729
|
+
.st-fix:hover { border-color: var(--c-accent-cyan); color: var(--c-accent-cyan); }
|
|
1730
|
+
.st-fix:focus-visible { outline: 2px solid var(--c-accent-cyan); outline-offset: 2px; }
|
|
1731
|
+
.st-mega__item { position: relative; }
|
|
1732
|
+
.st-tip { font: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: help; color: inherit; text-decoration: underline dotted var(--c-text-dim); text-decoration-thickness: 2px; text-underline-offset: 8px; }
|
|
1733
|
+
.st-tip:focus-visible { outline: 2px solid var(--c-accent-cyan); outline-offset: 4px; border-radius: 4px; }
|
|
1734
|
+
.st-tipcard { position: absolute; left: 0; top: calc(100% + 10px); z-index: 60; display: block; width: max-content; max-width: min(360px, calc(100vw - 32px)); padding: 14px 16px; background: var(--c-surface-hover); border: 0; border-radius: 12px; box-shadow: 0 0 0 1px var(--c-border-strong), 0 12px 32px rgba(0,0,0,.5); opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .15s ease, transform .15s ease, visibility .15s; pointer-events: none; text-align: left; }
|
|
1735
|
+
[data-theme="light"] .st-tipcard { background: var(--c-surface); box-shadow: 0 0 0 1px rgba(0,0,0,.12), 0 12px 28px rgba(14,22,34,.18); }
|
|
1736
|
+
.st-mega__item:last-child .st-tipcard { left: auto; right: 0; }
|
|
1737
|
+
.st .card:hover, .st .card:focus-within, .st .card:has(.st-tip--open) { position: relative; z-index: 20; }
|
|
1738
|
+
.st-tipcard__t { display: block; font: 600 15px/1.4 var(--font-sans); color: var(--c-text-main); margin-bottom: 6px; }
|
|
1739
|
+
.st-tipcard__l { display: block; font: 400 14px/1.5 var(--font-sans); color: var(--c-text-main); margin-top: 4px; }
|
|
1740
|
+
.st-tipcard__note { color: var(--c-text-main); margin-top: 8px; }
|
|
1741
|
+
.st-mega__item:hover .st-tipcard, .st-tip:focus + .st-tipcard, .st-tipcard:hover, .st-tipcard:focus-within, .st-tip--open + .st-tipcard { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
|
|
1742
|
+
.st-flash { animation: st-flash 1.6s ease-out; }
|
|
1743
|
+
@keyframes st-flash { 0% { box-shadow: 0 0 0 3px var(--c-accent-cyan); } 100% { box-shadow: 0 0 0 0 transparent; } }
|
|
1744
|
+
.st-tag { font: 500 13px/1 var(--font-sans); letter-spacing: 0.01em; color: var(--c-text-main); border: 1px solid var(--c-border-strong); border-radius: 999px; padding: 5px 10px; }
|
|
1745
|
+
.st-num { font-family: var(--font-sans); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--c-accent-cyan); white-space: nowrap; }
|
|
1746
|
+
.st-v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--c-text-main); text-align: right; white-space: nowrap; }
|
|
1747
|
+
.st-lead { font-size: 17px; line-height: 1.6; color: var(--c-text-main); margin-top: var(--s-3); max-width: 60ch; text-wrap: pretty; }
|
|
1748
|
+
.st-lead strong { font-weight: 600; }
|
|
1749
|
+
.st-big { font: 400 22px/1.45 var(--font-sans); color: var(--c-text-main); margin-top: var(--s-3); text-wrap: pretty; }
|
|
1750
|
+
.st-big .st-num { font-size: 34px; }
|
|
1751
|
+
.st-hero { padding: var(--s-4) !important; }
|
|
1752
|
+
/* The big numbers: the Tokens Saved card's display treatment (thin mono,
|
|
1753
|
+
saturated savings green or accent cyan, soft glow in dark mode). */
|
|
1754
|
+
.st-mega__row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3) var(--s-6, 48px); margin: var(--s-3) 0 12px; }
|
|
1755
|
+
.st-mega__item { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
|
|
1756
|
+
.st-mega__item--card { margin-top: var(--s-3); }
|
|
1757
|
+
.st-mega { font: 300 clamp(72px, 8.4vw, 116px)/0.9 var(--font-mono); letter-spacing: -0.035em; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
1758
|
+
.st-mega--usd { color: var(--c-savings); text-shadow: 0 0 26px rgba(74,222,128,0.34), 0 0 2px rgba(74,222,128,0.4); }
|
|
1759
|
+
.st-mega--tok { color: var(--c-accent-cyan); text-shadow: 0 0 26px rgba(0,240,255,0.32), 0 0 2px rgba(0,240,255,0.4); }
|
|
1760
|
+
.st-mega--card { font-size: clamp(60px, 5.6vw, 84px); }
|
|
1761
|
+
.st-mega__unit { font: 500 19px/1.3 var(--font-sans); color: var(--c-text-main); }
|
|
1762
|
+
[data-theme="light"] .st-mega { text-shadow: none; }
|
|
1763
|
+
.st-bar { display: flex; gap: 3px; height: 8px; border-radius: 4px; overflow: hidden; opacity: 0.85; }
|
|
1764
|
+
.st-bar__m { background: var(--c-savings); border-radius: 7px 0 0 7px; }
|
|
1765
|
+
.st-bar__e { background: repeating-linear-gradient(135deg, var(--c-savings) 0 3px, transparent 3px 7px); box-shadow: inset 0 0 0 1.5px var(--c-savings); border-radius: 0 7px 7px 0; }
|
|
1766
|
+
.st-bands { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2) var(--s-5); margin-top: var(--s-3); }
|
|
1767
|
+
.st-legend { display: flex; align-items: center; gap: 10px; font: 600 17px/1.3 var(--font-sans); color: var(--c-text-main); }
|
|
1768
|
+
.st-legend .st-v { margin-left: auto; font-size: 19px; font-weight: 500; }
|
|
1769
|
+
.st-sw { width: 14px; height: 14px; border-radius: 3px; flex: none; }
|
|
1770
|
+
.st-sw.st-m { background: var(--c-savings); }
|
|
1771
|
+
.st-sw.st-e { background: repeating-linear-gradient(135deg, var(--c-savings) 0 2px, transparent 2px 4px); box-shadow: inset 0 0 0 1.5px var(--c-savings); }
|
|
1772
|
+
.st-rows { list-style: none; margin-top: var(--s-2); border-top: 1px solid var(--c-border); }
|
|
1773
|
+
.st-rows li { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); padding: 9px 0; border-bottom: 1px solid var(--c-border); font-size: 16px; line-height: 1.4; color: var(--c-text-main); }
|
|
1774
|
+
.st-rows--card { margin-top: var(--s-3); }
|
|
1775
|
+
.st-sub { display: block; font: 400 14px/1.5 var(--font-sans); color: var(--c-text-main); margin-top: 2px; }
|
|
1776
|
+
.st-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: var(--s-3); }
|
|
1777
|
+
.st-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--s-5); }
|
|
1778
|
+
.st-mega__row--hero { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: var(--s-4); }
|
|
1779
|
+
.st-mega__row--hero .st-mega { font-size: clamp(60px, 6.2vw, 96px); }
|
|
1780
|
+
.st-mega__note { font: 600 17px/1.3 var(--font-sans); color: var(--c-savings); }
|
|
1781
|
+
.st-mega__note--worse { color: var(--c-waste); }
|
|
1782
|
+
.st-mega--route { color: var(--c-info); text-shadow: 0 0 26px rgba(96,165,250,0.36), 0 0 2px rgba(96,165,250,0.4); }
|
|
1783
|
+
.st-table { border: 0; box-shadow: 0 0 0 1px rgba(251,191,36,0.35), 0 0 44px rgba(251,191,36,0.10); }
|
|
1784
|
+
[data-theme="light"] .st-table { box-shadow: 0 0 0 1px rgba(150,95,0,.3), 0 2px 5px rgba(0,0,0,.06); }
|
|
1785
|
+
.st-table__body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--s-3) var(--s-5); align-items: center; }
|
|
1786
|
+
.st-table__rows .st-rows--card { margin-top: 0; }
|
|
1787
|
+
.st-bar__title { font: 600 17px/1.3 var(--font-sans); color: var(--c-text-main); margin: var(--s-4) 0 var(--s-2); }
|
|
1788
|
+
.st-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
|
|
1789
|
+
.st-ratio__track { display: block; height: 12px; border-radius: 6px; background: var(--c-elev-3); overflow: hidden; }
|
|
1790
|
+
.st-ratio__carry { display: block; height: 100%; border-radius: 6px; background: var(--c-accent-cyan); }
|
|
1791
|
+
.st-quality { margin-top: var(--s-3); max-width: 640px; }
|
|
1792
|
+
.st-cov { font-size: 17px; line-height: 1.6; color: var(--c-text-main); padding: 0 var(--s-1); max-width: 90ch; }
|
|
1793
|
+
.st-morerow { display: flex; flex-wrap: wrap; gap: 0 var(--s-4); padding: var(--s-2) var(--s-1) 0; border-top: 1px solid var(--c-border); margin-bottom: var(--s-4); }
|
|
1794
|
+
.st-morerow > .fold { margin-top: 0; }
|
|
1795
|
+
.st-morerow > .fold[open] { flex-basis: 100%; }
|
|
1796
|
+
.st-morerow > .fold > summary { font-size: 15px; }
|
|
1797
|
+
.st-morerow .fold__body { max-width: none; }
|
|
1798
|
+
.st-health { margin-top: var(--s-3); }
|
|
1799
|
+
.st-gap { margin-top: var(--s-4); }
|
|
1800
|
+
.st-limits { display: grid; gap: 10px; flex: 1 1 520px; min-width: 0; }
|
|
1801
|
+
.st-limit { display: grid; grid-template-columns: max-content minmax(120px, 1fr) max-content max-content; align-items: center; gap: 8px 20px; font: 500 15px/1.3 var(--font-sans); color: var(--c-text-main); }
|
|
1802
|
+
.st-limit__name { font-weight: 600; }
|
|
1803
|
+
.st-limit__meter { position: relative; height: 10px; border-radius: 999px; overflow: hidden; background: var(--c-elev-3); box-shadow: inset 0 0 0 1px var(--c-border); }
|
|
1804
|
+
.st-limit__ghost, .st-limit__fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; transition-property: width; transition-duration: 600ms; transition-timing-function: cubic-bezier(0.2, 0, 0, 1); }
|
|
1805
|
+
.st-limit__ghost { background: repeating-linear-gradient(135deg, var(--c-warning-2) 0 3px, transparent 3px 7px); opacity: 0.7; }
|
|
1806
|
+
.st-limit__fill { background: var(--c-accent-cyan); box-shadow: 0 0 10px var(--c-accent-cyan); }
|
|
1807
|
+
.st-limit__stat { display: inline-flex; align-items: baseline; gap: 6px; white-space: normal; }
|
|
1808
|
+
@media (max-width: 720px) { .st-limit { grid-template-columns: 1fr max-content max-content; } .st-limit__meter { grid-column: 1 / -1; grid-row: 2; } }
|
|
1809
|
+
.st-mega__per { font: 500 clamp(20px, 2vw, 26px)/1 var(--font-sans); letter-spacing: 0; text-shadow: none; color: var(--c-text-main); }
|
|
1810
|
+
.st-limit__used, .st-limit__num { font: 500 24px/1 var(--font-mono); font-variant-numeric: tabular-nums; text-shadow: 0 0 18px currentColor; } .st-limit__used { color: var(--c-accent-cyan); }
|
|
1811
|
+
.st-limit__num { color: var(--c-text-main); }
|
|
1812
|
+
@media (max-width: 900px) {
|
|
1813
|
+
.st-grid, .st-bands, .st-mega__row--hero, .st-table__body, .st-cols, .st-limits-card { grid-template-columns: 1fr; }
|
|
1814
|
+
.st-grid > :last-child:nth-child(odd) { grid-column: auto; }
|
|
1815
|
+
.st-mega__row--hero .st-mega { font-size: 72px; }
|
|
1816
|
+
}
|
|
1817
|
+
@media (max-width: 520px) {
|
|
1818
|
+
.st-limits__bottom, .st-reread__body { flex-wrap:wrap; } .st-limits__bottom { gap:0 16px; } .st-reread__body { gap:8px; }
|
|
1819
|
+
.st .card { padding: var(--s-3); }
|
|
1820
|
+
.st-hero { padding: var(--s-4) var(--s-3) var(--s-3) !important; }
|
|
1821
|
+
.st-hero .st-rows { display: none; }
|
|
1822
|
+
.st-bands { gap: var(--s-2); }
|
|
1823
|
+
.st-mega, .st-mega__row--hero .st-mega { font-size: 64px; }
|
|
1824
|
+
.st-mega--card { font-size: 56px; }
|
|
1825
|
+
.st-mega__row { gap: var(--s-3); }
|
|
1826
|
+
.st-morerow { flex-direction: column; }
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1717
1829
|
/* ========== RESPONSIVE ========== */
|
|
1718
1830
|
@media (max-width: 1024px) {
|
|
1719
1831
|
.layout { grid-template-columns: 200px 1fr; }
|
|
@@ -1728,8 +1840,14 @@ input:checked + .slider:before {
|
|
|
1728
1840
|
padding: var(--s-3);
|
|
1729
1841
|
}
|
|
1730
1842
|
.main-col { padding: var(--s-3); }
|
|
1843
|
+
.nav-col .brand { margin-bottom: var(--s-2); font-size: 20px; }
|
|
1844
|
+
.nav-menu { flex-direction: row; overflow-x: auto; gap: 4px; margin: 0 calc(-1 * var(--s-3)); padding: 0 var(--s-3) 2px; scrollbar-width: none; }
|
|
1845
|
+
.nav-menu::-webkit-scrollbar { display: none; }
|
|
1846
|
+
.nav-menu .nav-item { flex: none; white-space: nowrap; padding: 8px 12px; gap: 8px; }
|
|
1847
|
+
.nav-menu .nav-separator { display: none; }
|
|
1848
|
+
.user-profile { display: none; }
|
|
1731
1849
|
.dashboard-grid { grid-template-columns: 1fr; }
|
|
1732
|
-
.stat-row { grid-template-columns: 1fr; }
|
|
1850
|
+
.stat-row { grid-template-columns: 1fr !important; } /* rows set 3 columns inline */
|
|
1733
1851
|
}
|
|
1734
1852
|
/* ========== HOOK TOGGLES ========== */
|
|
1735
1853
|
.hook-toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
|
|
@@ -1765,11 +1883,7 @@ input:checked + .slider:before {
|
|
|
1765
1883
|
.hook-command-pre { white-space: pre-wrap; word-break: break-word; background: var(--c-bg); border: 1px solid var(--c-border); border-radius: 8px; padding: 12px; color: var(--c-accent-cyan); font-family: var(--font-mono); font-size: 13px; line-height: 1.5; margin: 10px 0 12px; }
|
|
1766
1884
|
.hook-command-meta { color: var(--c-text-dim); font-size: 13px; line-height: 1.45; }
|
|
1767
1885
|
|
|
1768
|
-
/*
|
|
1769
|
-
.quality-good { border-left: 4px solid var(--c-savings-strong, #22c55e) !important; }
|
|
1770
|
-
.quality-fair { border-left: 4px solid transparent !important; }
|
|
1771
|
-
.quality-needs-work { border-left: 4px solid var(--c-warning-yellow, #eab308) !important; }
|
|
1772
|
-
.quality-poor { border-left: 4px solid var(--c-waste-strong, #ef4444) !important; }
|
|
1886
|
+
/* Section 6: quality rows carry a badge, not a left accent stripe. */
|
|
1773
1887
|
.quality-badge {
|
|
1774
1888
|
display: inline-block;
|
|
1775
1889
|
font-family: var(--font-mono);
|
|
@@ -1862,7 +1976,7 @@ tr.token-spike td {
|
|
|
1862
1976
|
background: var(--c-warning-fill-2, rgba(251, 146, 60, 0.08)) !important;
|
|
1863
1977
|
}
|
|
1864
1978
|
tr.token-spike td:first-child {
|
|
1865
|
-
border-left:
|
|
1979
|
+
border-left: none;
|
|
1866
1980
|
}
|
|
1867
1981
|
|
|
1868
1982
|
/* ========== PROMPT PREVIEW MODAL ========== */
|
|
@@ -2054,8 +2168,8 @@ window.__TOKEN_DATA__ = null;
|
|
|
2054
2168
|
<div>
|
|
2055
2169
|
<div class="brand"><span></span> Token Optimizer <small id="brand-meta" style="display:block;margin-left:27px;margin-top:2px;font-size:11px;letter-spacing:.18em;text-transform:uppercase;color:var(--c-text-dim);font-weight:600;"></small></div>
|
|
2056
2170
|
<div class="nav-menu">
|
|
2057
|
-
<a class="nav-item active" data-view="
|
|
2058
|
-
<a class="nav-item" data-view="
|
|
2171
|
+
<a class="nav-item active" data-view="savings">Savings</a>
|
|
2172
|
+
<a class="nav-item" data-view="overview">Overview</a>
|
|
2059
2173
|
<a class="nav-item" data-view="quick">Quick Wins <span class="nav-badge" id="badge-quick"></span></a>
|
|
2060
2174
|
<a class="nav-item" data-view="medium">Medium <span class="nav-badge" id="badge-medium"></span></a>
|
|
2061
2175
|
<a class="nav-item" data-view="deep">Deep <span class="nav-badge" id="badge-deep"></span></a>
|
|
@@ -2068,15 +2182,13 @@ window.__TOKEN_DATA__ = null;
|
|
|
2068
2182
|
<a class="nav-item" data-view="manage">Manage</a>
|
|
2069
2183
|
</div>
|
|
2070
2184
|
</div>
|
|
2071
|
-
<div class="user-profile">workspace: <i id="nav-date"></i></div>
|
|
2072
2185
|
</nav>
|
|
2073
2186
|
|
|
2074
2187
|
<!-- MAIN -->
|
|
2075
2188
|
<main class="main-col">
|
|
2076
2189
|
<!-- Overview View -->
|
|
2077
|
-
<div class="view
|
|
2190
|
+
<div class="view" id="view-overview">
|
|
2078
2191
|
<header class="header">
|
|
2079
|
-
<div class="label">Token Overhead Analysis <span id="overview-version-badge" style="opacity:.7;margin-left:.5rem;font-family:var(--font-mono);font-size:12px;"></span></div>
|
|
2080
2192
|
<h1>Overview</h1>
|
|
2081
2193
|
<p>Your current config overhead, measured against your detected context window. <span id="overview-view-source" style="color:var(--c-text-dim);font-size:13px;"></span></p>
|
|
2082
2194
|
</header>
|
|
@@ -2116,7 +2228,7 @@ window.__TOKEN_DATA__ = null;
|
|
|
2116
2228
|
</div>
|
|
2117
2229
|
|
|
2118
2230
|
<!-- Savings View -->
|
|
2119
|
-
<div class="view" id="view-savings"></div>
|
|
2231
|
+
<div class="view active" id="view-savings"></div>
|
|
2120
2232
|
<!-- Quick Wins View -->
|
|
2121
2233
|
<div class="view" id="view-quick"></div>
|
|
2122
2234
|
<!-- Medium View -->
|
|
@@ -2136,6 +2248,8 @@ window.__TOKEN_DATA__ = null;
|
|
|
2136
2248
|
<div class="view" id="view-manage"></div>
|
|
2137
2249
|
|
|
2138
2250
|
<div class="main-footer">
|
|
2251
|
+
<span class="footer-version" id="footer-version"></span>
|
|
2252
|
+
<span class="footer-updated" id="footer-updated"></span>
|
|
2139
2253
|
<span class="footer-byline">Built by <a href="https://linkedin.com/in/alexgreensh" target="_blank" rel="noopener">Alex Greenshpun</a></span>
|
|
2140
2254
|
<a class="gh-star" href="https://github.com/alexgreensh/token-optimizer" target="_blank" rel="noopener" title="Star Token Optimizer on GitHub">
|
|
2141
2255
|
<svg class="gh-star-icon" width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2.5l2.9 6.06 6.6.59-5 4.38 1.5 6.47L12 16.98 5.99 20.5l1.5-6.47-5-4.38 6.6-.59L12 2.5z"/></svg>
|
|
@@ -2167,29 +2281,10 @@ window.__TOKEN_DATA__ = null;
|
|
|
2167
2281
|
</div>
|
|
2168
2282
|
|
|
2169
2283
|
<div class="section-title">Notes</div>
|
|
2170
|
-
<textarea class="notes-area" id="notes-input" placeholder="
|
|
2284
|
+
<textarea class="notes-area" id="notes-input" placeholder="Anything to keep or skip?"></textarea>
|
|
2171
2285
|
|
|
2172
2286
|
<button class="apply-btn" id="copy-btn" disabled>Preview & Copy</button>
|
|
2173
2287
|
|
|
2174
|
-
<div class="version-footer">
|
|
2175
|
-
<div class="footer-byline">Built by <a href="https://linkedin.com/in/alexgreensh" target="_blank" rel="noopener">Alex Greenshpun</a></div>
|
|
2176
|
-
<a class="gh-star" href="https://github.com/alexgreensh/token-optimizer" target="_blank" rel="noopener" title="Star Token Optimizer on GitHub">
|
|
2177
|
-
<svg class="gh-star-icon" width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2.5l2.9 6.06 6.6.59-5 4.38 1.5 6.47L12 16.98 5.99 20.5l1.5-6.47-5-4.38 6.6-.59L12 2.5z"/></svg>
|
|
2178
|
-
<span>Star on GitHub</span>
|
|
2179
|
-
<span class="gh-star-count" data-gh-stars hidden></span>
|
|
2180
|
-
</a>
|
|
2181
|
-
<div class="social-icons">
|
|
2182
|
-
<a href="https://github.com/alexgreensh/token-optimizer" target="_blank" rel="noopener" title="GitHub" class="social-link">
|
|
2183
|
-
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"/></svg>
|
|
2184
|
-
</a>
|
|
2185
|
-
<a href="https://x.com/alexgreensh" target="_blank" rel="noopener" title="X (Twitter)" class="social-link">
|
|
2186
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24h-6.66l-5.214-6.817-5.97 6.817H1.673l7.73-8.835L1.254 2.25h6.83l4.713 6.231 5.447-6.231zm-1.161 17.52h1.833L7.084 4.126H5.117l11.966 15.644z"/></svg>
|
|
2187
|
-
</a>
|
|
2188
|
-
<a href="https://linkedin.com/in/alexgreensh" target="_blank" rel="noopener" title="LinkedIn" class="social-link">
|
|
2189
|
-
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>
|
|
2190
|
-
</a>
|
|
2191
|
-
</div>
|
|
2192
|
-
</div>
|
|
2193
2288
|
</aside>
|
|
2194
2289
|
</div>
|
|
2195
2290
|
|
|
@@ -2405,6 +2500,29 @@ function memCountSuffix(mr) { return mr && mr.scan_partial ? '+' : ''; }
|
|
|
2405
2500
|
function isNoInstructionHost(data) {
|
|
2406
2501
|
return !!data && (data.runtime === 'cursor' || data.runtime === 'antigravity');
|
|
2407
2502
|
}
|
|
2503
|
+
// U8: the removed pool is split by what it is, never called "fresh" (it holds
|
|
2504
|
+
// resume and output tokens). Old payloads without the split keep one total.
|
|
2505
|
+
function tokenSplitText(h, fmt) {
|
|
2506
|
+
var parts = [];
|
|
2507
|
+
if (h.context_removed_tokens != null) {
|
|
2508
|
+
parts.push('~' + fmt(h.context_removed_tokens || 0) + ' context removed');
|
|
2509
|
+
if (h.output_not_generated_tokens) parts.push('~' + fmt(h.output_not_generated_tokens) + ' output not generated');
|
|
2510
|
+
if (h.reload_avoided_tokens) parts.push('~' + fmt(h.reload_avoided_tokens) + ' reload avoided');
|
|
2511
|
+
} else {
|
|
2512
|
+
parts.push('~' + fmt(h.removed_tokens || 0) + ' removed');
|
|
2513
|
+
}
|
|
2514
|
+
parts.push(h.reread_available ? '~' + fmt(h.reread_tokens || 0) + ' re-reads avoided' : 're-reads unavailable');
|
|
2515
|
+
return parts.join(' · ');
|
|
2516
|
+
}
|
|
2517
|
+
/*@include savings_story.js*//*@include first_call_context.js*/
|
|
2518
|
+
// Feature health card (Health tab): assets/feature_health.js.
|
|
2519
|
+
/*@include feature_health.js*/
|
|
2520
|
+
// Command-output coverage card (Health tab): assets/coverage_funnel.js.
|
|
2521
|
+
/*@include coverage_funnel.js*/
|
|
2522
|
+
// Control-group card (Health tab, shown only when the holdout is on): assets/holdout_card.js.
|
|
2523
|
+
/*@include holdout_card.js*/
|
|
2524
|
+
/*@include keepwarm_health.js*/
|
|
2525
|
+
|
|
2408
2526
|
function hostRefreshHtml(data) {
|
|
2409
2527
|
return tcliHtml('<span class="update-cmd">TOKEN_OPTIMIZER_RUNTIME=' + esc(data.runtime) + ' python3 measure.py dashboard --user</span>');
|
|
2410
2528
|
}
|
|
@@ -2701,6 +2819,17 @@ var DB = (function() {
|
|
|
2701
2819
|
safeRender('RightPanel', null, updateRightPanel);
|
|
2702
2820
|
safeRender('EventBinding', null, bind);
|
|
2703
2821
|
|
|
2822
|
+
// Deep links: a hash naming a view opens that view; with no usable hash,
|
|
2823
|
+
// open Savings when the story payload is present, else Overview. The
|
|
2824
|
+
// replaceState write keeps the landing URL bookmarkable without adding a
|
|
2825
|
+
// history entry.
|
|
2826
|
+
var initialView = viewFromHash();
|
|
2827
|
+
if (initialView) {
|
|
2828
|
+
showView(initialView, { skipHash: true });
|
|
2829
|
+
} else {
|
|
2830
|
+
showView((typeof savingsStoryOn === 'function' && savingsStoryOn(data)) ? 'savings' : 'overview', { replace: true });
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2704
2833
|
// Kill stale session buttons (v2.6)
|
|
2705
2834
|
var killStaleBtn = document.getElementById('kill-stale-btn');
|
|
2706
2835
|
if (killStaleBtn) {
|
|
@@ -2760,21 +2889,33 @@ var DB = (function() {
|
|
|
2760
2889
|
hasAnyItems = true;
|
|
2761
2890
|
}
|
|
2762
2891
|
});
|
|
2763
|
-
//
|
|
2764
|
-
|
|
2765
|
-
if (trendsNav) trendsNav.click();
|
|
2892
|
+
// Standalone files still open on Savings/Overview per the initial
|
|
2893
|
+
// showView() above; the F4 default is not overridden here.
|
|
2766
2894
|
}
|
|
2767
2895
|
}
|
|
2768
2896
|
|
|
2897
|
+
// Section 5 cuts: habits items that say "no action needed" or give generic
|
|
2898
|
+
// advice with no figure from this user's data are not rendered (see
|
|
2899
|
+
// renderSectionViews) and do not count toward the nav badge.
|
|
2900
|
+
function habitsItemCut(it) {
|
|
2901
|
+
var t = (it.title || '') + ' ' + (it.shortDesc || '');
|
|
2902
|
+
return /effortLevel/i.test(t) || /Use \/clear/i.test(t) || /Batch related/i.test(t);
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2769
2905
|
function renderNav() {
|
|
2770
2906
|
var counts = { quick: 0, medium: 0, deep: 0, habits: 0 };
|
|
2771
|
-
items.forEach(function(it) {
|
|
2907
|
+
items.forEach(function(it) {
|
|
2908
|
+
if (counts[it.section] === undefined) return;
|
|
2909
|
+
if (it.section === 'habits' && habitsItemCut(it)) return;
|
|
2910
|
+
counts[it.section]++;
|
|
2911
|
+
});
|
|
2772
2912
|
for (var k in counts) {
|
|
2773
2913
|
var el = document.getElementById('badge-' + k);
|
|
2774
2914
|
if (el) el.textContent = counts[k] || '';
|
|
2775
2915
|
}
|
|
2776
2916
|
var ts = data.generated_at || new Date().toISOString();
|
|
2777
|
-
document.getElementById('nav-date')
|
|
2917
|
+
var navDate = document.getElementById('nav-date');
|
|
2918
|
+
if (navDate) navDate.textContent = ts.slice(0,10);
|
|
2778
2919
|
}
|
|
2779
2920
|
|
|
2780
2921
|
// v5.4.18: v5 feature metadata mirrors V5_FEATURES in measure.py. Used as a
|
|
@@ -2841,7 +2982,7 @@ var DB = (function() {
|
|
|
2841
2982
|
label: 'First-Read Skeleton (serve, not just measure)',
|
|
2842
2983
|
what: "When on, validated CODE cohorts are served a structural skeleton (signatures/imports) on first read instead of the full file. When off, those cohorts are measured only and served full.",
|
|
2843
2984
|
value: "A large first-read code file comes back as a compact API skeleton, with the full content one `expand` away. As of v5.11.27 markdown/prose is NOT skeletoned -- only code.",
|
|
2844
|
-
how: "
|
|
2985
|
+
how: "When enabled, the target is read in full and bounded maps of related files may be added. Outcome comparisons are diagnostic; existing cohort demotions remain in place.",
|
|
2845
2986
|
risk: "Low. Code skeletons preserve structure; the full file is always recoverable. Set TOKEN_OPTIMIZER_FIRST_READ_ACTIVE=0 (or toggle here) to serve full content while keeping measurement.",
|
|
2846
2987
|
env_var: 'TOKEN_OPTIMIZER_FIRST_READ_ACTIVE'
|
|
2847
2988
|
}
|
|
@@ -2971,11 +3112,10 @@ var DB = (function() {
|
|
|
2971
3112
|
}
|
|
2972
3113
|
|
|
2973
3114
|
// Hero card
|
|
2974
|
-
var remaining = Math.max(0, ctxWindow - total);
|
|
2975
3115
|
document.getElementById('hero-tag').textContent = fn(total) + ' tokens';
|
|
2976
3116
|
document.getElementById('hero-total').textContent = fn(total);
|
|
2977
3117
|
document.getElementById('hero-sub').innerHTML =
|
|
2978
|
-
'tokens loaded before you type a word (' + ctxLabel + ' window).
|
|
3118
|
+
'tokens loaded before you type a word (' + ctxLabel + ' window).';
|
|
2979
3119
|
|
|
2980
3120
|
// v5 Active Compression recommendation card. v5.4.18: fall back to
|
|
2981
3121
|
// client-side synthesis when the dashboard has no real data yet so a
|
|
@@ -3018,7 +3158,7 @@ var DB = (function() {
|
|
|
3018
3158
|
var recBadge = f.recommended
|
|
3019
3159
|
? '<span style="background:var(--c-badge-savings);color:#000;font-size:11px;padding:2px 7px;border-radius:3px;margin-left:8px;font-weight:700;">RECOMMENDED</span>'
|
|
3020
3160
|
: '<span style="background:var(--c-border);color:var(--c-text-dim);font-size:11px;padding:2px 7px;border-radius:3px;margin-left:8px;">OPT-IN</span>';
|
|
3021
|
-
cardHtml += '<div style="padding:14px;background:var(--c-bg);border-radius:6px;
|
|
3161
|
+
cardHtml += '<div style="padding:14px;background:var(--c-bg);border-radius:6px;">' +
|
|
3022
3162
|
'<div style="display:flex;justify-content:space-between;align-items:baseline;margin-bottom:6px;">' +
|
|
3023
3163
|
'<div style="font-size:17px;font-weight:600;">' + esc(f.label) + recBadge + '</div>' +
|
|
3024
3164
|
'<div style="font-size:20px;font-weight:700;color:var(--c-accent-cyan);">+' + f.impact_pct + '%</div>' +
|
|
@@ -3038,13 +3178,9 @@ var DB = (function() {
|
|
|
3038
3178
|
cardHtml += '</div></div>';
|
|
3039
3179
|
v5card.innerHTML = cardHtml;
|
|
3040
3180
|
} else {
|
|
3041
|
-
// All features enabled
|
|
3042
|
-
v5card.innerHTML = '<div
|
|
3043
|
-
'
|
|
3044
|
-
'<span class="label" style="background:var(--c-badge-savings);color:#000;padding:4px 10px;border-radius:4px;font-weight:700;font-size:13px;">MAXED OUT</span></div>' +
|
|
3045
|
-
'<div style="padding: var(--s-2) var(--s-3);font-size:17px;">' +
|
|
3046
|
-
'<span style="font-size:24px;">\u2713</span> ' + esc(v5rec.recommendation) +
|
|
3047
|
-
'</div></div>';
|
|
3181
|
+
// All features enabled: one line, the detail lives in Manage.
|
|
3182
|
+
v5card.innerHTML = '<div style="font-size:15px;color:var(--c-text-dim);margin:0 0 var(--s-3);">' +
|
|
3183
|
+
'\u2713 All compression features are on.</div>';
|
|
3048
3184
|
}
|
|
3049
3185
|
}
|
|
3050
3186
|
|
|
@@ -3052,8 +3188,7 @@ var DB = (function() {
|
|
|
3052
3188
|
var ts = data.generated_at ? new Date(data.generated_at).toLocaleString() : 'unknown';
|
|
3053
3189
|
var staleMinutes = data.generated_at ? Math.round((Date.now() - new Date(data.generated_at).getTime()) / 60000) : 0;
|
|
3054
3190
|
var isStale = staleMinutes > 60;
|
|
3055
|
-
var
|
|
3056
|
-
var staleWarning = isStale ? ' <span style="color:var(--c-warning, #ff9f43);font-weight:500;">(data is ' + (staleMinutes > 1440 ? Math.round(staleMinutes / 1440) + 'd' : Math.round(staleMinutes / 60) + 'h') + ' old — ' + refreshHint + ' to refresh)</span>' : '';
|
|
3191
|
+
var staleWarning = isStale ? ' <span style="color:var(--c-text-dim);font-weight:500;">(updated ' + (staleMinutes > 1440 ? Math.round(staleMinutes / 1440) + ' days' : Math.round(staleMinutes / 60) + ' hours') + ' ago)</span>' : '';
|
|
3057
3192
|
var headerEl = document.querySelector('#view-overview .header');
|
|
3058
3193
|
if (headerEl) {
|
|
3059
3194
|
var existingTs = headerEl.querySelector('.last-updated');
|
|
@@ -3131,10 +3266,11 @@ var DB = (function() {
|
|
|
3131
3266
|
memoryExists = true;
|
|
3132
3267
|
}
|
|
3133
3268
|
var barsHtml = vals.map(function(v, i) {
|
|
3269
|
+
if (i === 1 && !memoryExists) return '';
|
|
3134
3270
|
var w = logBar(v);
|
|
3135
3271
|
var fixedClass = i === vals.length - 1 ? ' fixed' : '';
|
|
3136
3272
|
var pctText = (v / ctxWindow * 100).toFixed(1) + '%';
|
|
3137
|
-
var valText =
|
|
3273
|
+
var valText = fn(v) + ' (' + pctText + ')';
|
|
3138
3274
|
return '<div class="bar-row">' +
|
|
3139
3275
|
'<span class="bar-label">' + barLabels[i] + '</span>' +
|
|
3140
3276
|
'<div class="bar-track"><div class="bar-fill' + fixedClass + '" style="width:' + w + '%"></div></div>' +
|
|
@@ -3146,21 +3282,8 @@ var DB = (function() {
|
|
|
3146
3282
|
isCodexOverview
|
|
3147
3283
|
? 'Bars show % of the logged Codex context window each component uses. Core System is fixed by Codex. AGENTS.md, memories, skills/plugins, MCP, and hooks are yours to tune.'
|
|
3148
3284
|
: 'Bars show % of context window each component uses. Core System is fixed by ' + (data.runtime_label || 'Claude Code') + '. Everything else is yours to trim.';
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
caveatEl = document.createElement('div');
|
|
3152
|
-
caveatEl.id = 'sat-caveat';
|
|
3153
|
-
caveatEl.style.cssText = 'font-size:11px;color:var(--c-text-dim);margin-top:6px;font-style:italic;';
|
|
3154
|
-
document.getElementById('sat-desc').parentNode.appendChild(caveatEl);
|
|
3155
|
-
}
|
|
3156
|
-
var cal = data.snapshot.calibration;
|
|
3157
|
-
if (cal && cal.has_data && cal.significant) {
|
|
3158
|
-
caveatEl.textContent = 'Note: real session baseline averages ' + fn(cal.avg_real_baseline) +
|
|
3159
|
-
' tokens (' + (cal.gap_pct > 0 ? '+' : '') + cal.gap_pct + '% vs estimate). ' +
|
|
3160
|
-
'Gap is from unmeasured system overhead (XML framing, MCP instructions).';
|
|
3161
|
-
} else {
|
|
3162
|
-
caveatEl.textContent = 'Estimate based on file sizes. Actual overhead includes XML framing and system wrappers not measured here.';
|
|
3163
|
-
}
|
|
3285
|
+
// The italic calibration footnote is cut (section 5): the headline now
|
|
3286
|
+
// carries the measured number, and an 11px dim aside only repeated it.
|
|
3164
3287
|
|
|
3165
3288
|
// What You'd Save card
|
|
3166
3289
|
var planTokens = Math.min(
|
|
@@ -3181,15 +3304,15 @@ var DB = (function() {
|
|
|
3181
3304
|
fn(ctrl) + ' of your ' + fn(total) + ' tokens are controllable. No specific token-saving optimizations identified, but check the behavioral recommendations below.';
|
|
3182
3305
|
}
|
|
3183
3306
|
|
|
3184
|
-
// Component cards (expandable)
|
|
3185
3307
|
var componentData = getComponentDetails(data);
|
|
3186
3308
|
var cardsHtml = '';
|
|
3187
3309
|
componentData.forEach(function(comp, ci) {
|
|
3310
|
+
if (comp.key === 'memory_md' && comp.tokens === 0 && c.memory_md && c.memory_md.exists === false) return;
|
|
3188
3311
|
cardsHtml += '<div class="component-card" data-comp="' + ci + '">' +
|
|
3189
3312
|
'<div class="component-card-header">' +
|
|
3190
3313
|
'<span class="cc-name">' + esc(comp.name) + '</span>' +
|
|
3191
3314
|
'<span class="cc-right">' +
|
|
3192
|
-
'<span class="cc-tokens">' +
|
|
3315
|
+
'<span class="cc-tokens">' + fn(comp.tokens) + ' tokens</span>' +
|
|
3193
3316
|
'<span class="chevron">▾</span></span></div>' +
|
|
3194
3317
|
'<div class="component-card-sub">' + esc(comp.sub) + '</div>' +
|
|
3195
3318
|
'<div class="component-card-detail" id="comp-detail-' + ci + '">' +
|
|
@@ -3224,24 +3347,11 @@ var DB = (function() {
|
|
|
3224
3347
|
gridEl.className = 'component-cards';
|
|
3225
3348
|
gridEl.innerHTML = cardsHtml;
|
|
3226
3349
|
|
|
3227
|
-
// Health cards: runtime
|
|
3350
|
+
// Health cards: runtime memory files. The instruction-file (CLAUDE.md /
|
|
3351
|
+
// AGENTS.md) health card is cut (section 5): its one number is already in
|
|
3352
|
+
// the component breakdown above.
|
|
3228
3353
|
var healthCardsHtml = '<div style="display:grid;grid-template-columns:1fr 1fr;gap:var(--s-3);margin-top:var(--s-3);">';
|
|
3229
3354
|
|
|
3230
|
-
// Instruction-file health card
|
|
3231
|
-
var cmh = data.claude_md_health;
|
|
3232
|
-
if (cmh) {
|
|
3233
|
-
var instructionLabel = isCodexOverview ? 'AGENTS.md Health' : 'CLAUDE.md Health';
|
|
3234
|
-
var cmColor = cmh.status === 'good' ? 'var(--c-accent-cyan)' : cmh.status === 'warning' ? 'var(--c-warning, #ff9f43)' : 'var(--c-text-dim, #7d8ca3)';
|
|
3235
|
-
healthCardsHtml += '<div class="card"><div class="card-header"><span>' + instructionLabel + '</span></div>' +
|
|
3236
|
-
'<div style="text-align:center;padding:var(--s-3) 0;">' +
|
|
3237
|
-
'<div style="font-size:28px;font-weight:700;font-family:var(--font-mono);color:' + cmColor + ';">' + fn(cmh.tokens) + '</div>' +
|
|
3238
|
-
'<div style="font-size:13px;color:var(--c-text-dim);">tokens (' + cmh.pct + '% of context)</div>' +
|
|
3239
|
-
'</div>' +
|
|
3240
|
-
'<div style="text-align:center;padding:0 0 var(--s-3) 0;font-size:13px;color:' + cmColor + ';">' +
|
|
3241
|
-
(cmh.status === 'good' ? 'Lean and efficient' : cmh.status === 'warning' ? 'Consider restructuring' : 'Growing') +
|
|
3242
|
-
'</div></div>';
|
|
3243
|
-
}
|
|
3244
|
-
|
|
3245
3355
|
// Memory health card
|
|
3246
3356
|
var mr = data.memory_review;
|
|
3247
3357
|
if (mr && !mr.error && mr.codex) {
|
|
@@ -3278,20 +3388,15 @@ var DB = (function() {
|
|
|
3278
3388
|
healthCardsHtml += '</div>';
|
|
3279
3389
|
gridEl.insertAdjacentHTML('afterend', healthCardsHtml);
|
|
3280
3390
|
|
|
3281
|
-
// Standalone mode: CTA
|
|
3282
|
-
|
|
3391
|
+
// Standalone mode: CTA when there is nothing auto-detected. The
|
|
3392
|
+
// "Auto-Detected Recommendations" card is cut (section 5): its whole body
|
|
3393
|
+
// was "browse them in the tabs on the left".
|
|
3394
|
+
if (data.standalone && !(data.auto_plan && items.length > 0)) {
|
|
3283
3395
|
var ctaEl = document.createElement('div');
|
|
3284
3396
|
ctaEl.className = 'card wide';
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
'These recommendations are auto-generated from your config. Browse them in the tabs on the left.<br>' +
|
|
3289
|
-
(isCodexOverview ? 'For deeper analysis, refresh the Codex dashboard after a few real turns so quality and continuity signals are available.' : isHostOverview ? '' : 'For deeper analysis (semantic duplication, content quality), run <code style="color:var(--c-accent-cyan)">/token-optimizer</code> for a full LLM-powered audit.') + '</div>';
|
|
3290
|
-
} else {
|
|
3291
|
-
ctaEl.innerHTML = '<div class="card-header"><span>Optimization Recommendations</span></div>' +
|
|
3292
|
-
'<div class="empty-state">No auto-detected issues. Your setup looks clean.<br>' +
|
|
3293
|
-
(isCodexOverview ? 'Refresh the Codex dashboard after live usage for deeper quality analysis.' : isHostOverview ? '' : 'Run <code style="color:var(--c-accent-cyan)">/token-optimizer</code> for a full audit with deeper analysis.') + '</div>';
|
|
3294
|
-
}
|
|
3397
|
+
ctaEl.innerHTML = '<div class="card-header"><span>Optimization Recommendations</span></div>' +
|
|
3398
|
+
'<div class="empty-state">No auto-detected issues. Your setup looks clean.<br>' +
|
|
3399
|
+
(isCodexOverview ? 'Refresh the Codex dashboard after live usage for deeper quality analysis.' : isHostOverview ? '' : 'Run <code style="color:var(--c-accent-cyan)">/token-optimizer</code> for a full audit with deeper analysis.') + '</div>';
|
|
3295
3400
|
gridEl.parentNode.insertBefore(ctaEl, gridEl.nextSibling);
|
|
3296
3401
|
}
|
|
3297
3402
|
|
|
@@ -3345,24 +3450,20 @@ var DB = (function() {
|
|
|
3345
3450
|
if (!el) return;
|
|
3346
3451
|
var secItems = items.filter(function(it) { return it.section === sec; });
|
|
3347
3452
|
var isHabits = (sec === 'habits');
|
|
3453
|
+
if (isHabits) {
|
|
3454
|
+
// Section 5 cuts: the FYI effortLevel card says "no action needed" and
|
|
3455
|
+
// the two generic advice items cite no number from this user's data.
|
|
3456
|
+
secItems = secItems.filter(function(it) { return !habitsItemCut(it); });
|
|
3457
|
+
}
|
|
3348
3458
|
|
|
3349
|
-
var ts = data.generated_at ? new Date(data.generated_at).toLocaleString() : 'unknown';
|
|
3350
3459
|
var html = '<div class="section-header">' +
|
|
3351
|
-
'<div class="label">' + (isHabits ? 'Recommendations' : 'Optimization Plan') + '</div>' +
|
|
3352
3460
|
'<h1>' + (groupLabels[sec] || sec) + '</h1>' +
|
|
3353
3461
|
'<p>' + (groupDescs[sec] || '') + '</p>' +
|
|
3354
3462
|
'</div>';
|
|
3355
3463
|
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
} else if (data.standalone) {
|
|
3360
|
-
html += '<div class="last-updated">Last updated: ' + esc(ts) +
|
|
3361
|
-
(data.runtime === 'codex' ? ' · Optimization data is limited until Codex session logs are collected.</div>' : (isNoInstructionHost(data) ? ' · Optimization data is limited in standalone mode.</div>' : ' · Optimization data not available in standalone mode. Run <span class="update-cmd">/token-optimizer</span> for a full audit with recommendations.</div>'));
|
|
3362
|
-
} else {
|
|
3363
|
-
html += '<div class="last-updated">Last updated: ' + esc(ts) +
|
|
3364
|
-
(data.runtime === 'codex' ? ' · To refresh, use the Codex dashboard refresh command.</div>' : (isNoInstructionHost(data) ? ' · To refresh, run ' + hostRefreshHtml(data) + '.</div>' : ' · To refresh, run <span class="update-cmd">/token-optimizer</span> again.</div>'));
|
|
3365
|
-
}
|
|
3464
|
+
// The "Last updated … Auto-detected" line is cut (section 5): freshness
|
|
3465
|
+
// lives once in the footer, and the auto-detect note repeated on all
|
|
3466
|
+
// four tabs.
|
|
3366
3467
|
|
|
3367
3468
|
if (secItems.length === 0) {
|
|
3368
3469
|
if (!data.plan && !data.auto_plan) {
|
|
@@ -3446,7 +3547,7 @@ var DB = (function() {
|
|
|
3446
3547
|
return [{ heading: 'Details', text: detail }];
|
|
3447
3548
|
}
|
|
3448
3549
|
|
|
3449
|
-
var analyticsViews = { savings: true, trends: true, health: true, hooks: true, manage: true };
|
|
3550
|
+
var analyticsViews = { savings: true, trends: true, health: true, hooks: true, manage: true, overview: true, coach: true };
|
|
3450
3551
|
|
|
3451
3552
|
// Emits the per-model note + stacked bar + legend (the existing USAGE
|
|
3452
3553
|
// breakdown). Hoisted to module scope so the Tokens Saved card (in BOTH
|
|
@@ -3475,12 +3576,7 @@ var DB = (function() {
|
|
|
3475
3576
|
var untrackedTokens = (denom > modelTotal) ? (denom - modelTotal) : 0;
|
|
3476
3577
|
var out = '';
|
|
3477
3578
|
if (isCodex) {
|
|
3478
|
-
out += '<p style="font-size:
|
|
3479
|
-
} else if (modelCount <= 1) {
|
|
3480
|
-
var singleModel = Object.keys(modelMix)[0] || 'unknown';
|
|
3481
|
-
out += '<p style="font-size:13px;color:var(--c-text-dim);font-family:var(--font-mono);margin-bottom:var(--s-2);">All sessions use ' + esc(singleModel) + '. Consider defaulting agents to haiku (5x cheaper) or sonnet for data-gathering tasks.</p>';
|
|
3482
|
-
} else {
|
|
3483
|
-
out += '<p style="font-size:13px;color:var(--c-text-dim);font-family:var(--font-mono);margin-bottom:var(--s-2);">Haiku is 5x cheaper for data-gathering. If you see mostly Opus, consider defaulting agents to Sonnet/Haiku.</p>';
|
|
3579
|
+
out += '<p style="font-size:15px;color:var(--c-text-main);margin-bottom:var(--s-2);">Codex model names are read from session logs when available. Unknown future model IDs are shown by name but left unpriced until rates are known.</p>';
|
|
3484
3580
|
}
|
|
3485
3581
|
out += '<div class="model-bar">';
|
|
3486
3582
|
modelOrder.forEach(function(m) {
|
|
@@ -3523,113 +3619,52 @@ var DB = (function() {
|
|
|
3523
3619
|
return out;
|
|
3524
3620
|
}
|
|
3525
3621
|
|
|
3526
|
-
//
|
|
3527
|
-
// usage bar + footer. Hoisted to module scope so BOTH renderTrends and
|
|
3528
|
-
// renderSavings render it identically without duplicating the body logic.
|
|
3529
|
-
// Reads trends data from the global `data`; the savings object is passed as
|
|
3530
|
-
// `savings` (data.savings in renderTrends, the in-scope `s` in renderSavings).
|
|
3531
|
-
// SPENT = deduplicated fresh input + output on actual activity days.
|
|
3532
|
-
// Cache reads and writes are excluded. NOT sum(model_mix):
|
|
3533
|
-
// model_mix can omit unattributed tokens. Fail-open to that sum rather than 0.
|
|
3534
|
-
// SAVED = savings.total_tokens. Fail-open: measured AND estimated both ≤ 0 →
|
|
3535
|
-
// return '' (omit card entirely); either > 0 → render (estimates still show
|
|
3536
|
-
// when the measured floor is zero). SAVED > 0 but SPENT missing/zero →
|
|
3537
|
-
// render hero + footer only.
|
|
3538
|
-
// The model-mix "where the spent went" bar reconciles to SPENT via a trailing
|
|
3539
|
-
// "untracked" segment for SPENT - sum(model_mix) (tokens billed without a
|
|
3540
|
-
// model tag). Returns '' when the card should not render.
|
|
3622
|
+
// Share the Savings story calculation and period, including its eligibility rules.
|
|
3541
3623
|
function tokensSavedCardHtml(savings) {
|
|
3542
3624
|
var s = savings || {};
|
|
3543
|
-
var
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
var
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
(function
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
})(
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
}
|
|
3566
|
-
|
|
3567
|
-
var tk = Number(obj && obj.tokens_saved) || 0;
|
|
3568
|
-
if (tk > 0) tsEstItems.push({ label: label, tokens: tk });
|
|
3569
|
-
})(s.resume_lean_estimated, 'lean resumes');
|
|
3570
|
-
(function pushEst(obj, label) {
|
|
3571
|
-
var tk = Number(obj && obj.tokens_saved) || 0;
|
|
3572
|
-
if (tk > 0) tsEstItems.push({ label: label, tokens: tk });
|
|
3573
|
-
})(s.checkpoint_restore_estimated, 'checkpoint restores');
|
|
3574
|
-
var tsEstTokens = tsEstItems.reduce(function(a, b) { return a + b.tokens; }, 0);
|
|
3575
|
-
var tsEstLabelList = tsEstItems.map(function(it) { return it.label; }).join(', ');
|
|
3576
|
-
if (tsSavedTokens <= 0 && tsEstTokens <= 0) return '';
|
|
3577
|
-
var tsTrends = data.trends || {};
|
|
3578
|
-
var tsSpentBasis = tsTrends.spent_token_basis || {};
|
|
3579
|
-
var tsModelMix = tsTrends.model_mix || {};
|
|
3580
|
-
var tsModelTotal = 0;
|
|
3581
|
-
for (var tsMk in tsModelMix) { tsModelTotal += tsModelMix[tsMk]; }
|
|
3582
|
-
var tsIsCodex = data.runtime === 'codex';
|
|
3583
|
-
var tsPeriodDays = Number(tsTrends.period_days) || Number(s.period_days) || 30;
|
|
3584
|
-
// Missing dated coverage must not be replaced by lifetime model totals.
|
|
3585
|
-
var tsReportedTotal = Number(tsTrends.total_tokens) || 0;
|
|
3586
|
-
var tsSpentTokens = Object.prototype.hasOwnProperty.call(tsTrends, 'total_tokens') ? Math.max(0, tsReportedTotal) : tsModelTotal;
|
|
3587
|
-
// (tsWouldSendTotal / percentages are computed below, AFTER the estimated
|
|
3588
|
-
// tier is summed: the card headlines the FULL saved total in every state.)
|
|
3589
|
-
// FULL saved total = measured floor + estimated tier. The headline is
|
|
3590
|
-
// ALWAYS the full number, never the floor alone; the measured-vs-estimated
|
|
3591
|
-
// split stays visible right under it so the honesty travels with the size,
|
|
3592
|
-
// and the %-prevented / spent-vs-saved bar / would-send total are all
|
|
3593
|
-
// computed against the same full figure.
|
|
3594
|
-
var tsFullSaved = tsSavedTokens + tsEstTokens;
|
|
3595
|
-
var tsWouldSendTotal = tsSpentTokens + tsFullSaved;
|
|
3596
|
-
var tsSavedPct = (tsWouldSendTotal > 0) ? Math.round(tsFullSaved / tsWouldSendTotal * 100) : 0;
|
|
3597
|
-
var tsSpentPct = 100 - tsSavedPct; // no 101% rounding
|
|
3598
|
-
var tsSplitShort = fn(tsSavedTokens) + ' measured' + (tsEstTokens > 0 ? ' + ' + fn(tsEstTokens) + ' estimated' : '');
|
|
3599
|
-
|
|
3600
|
-
var out = '<div class="card wide"><div class="card-header"><span>Tokens Saved</span><span class="label">Last ' + tsPeriodDays + ' days · measured + estimated</span></div>';
|
|
3601
|
-
// HERO: total tokens saved, savings-green, mono, tabular-nums.
|
|
3602
|
-
out += '<div style="display:flex;align-items:baseline;gap:var(--s-3);flex-wrap:wrap;margin-top:var(--s-2)"><div class="metric-large savings-hero">' + fn(tsFullSaved) + '</div><div class="metric-unit">tokens saved</div></div>';
|
|
3603
|
-
out += '<div class="metric-sub tight" style="margin-top:2px;">' + fn(tsFullSaved) + ' saved · ' + tsSplitShort + '</div>';
|
|
3604
|
-
if (tsSpentTokens > 0) {
|
|
3605
|
-
out += '<div class="metric-sub tight">Token Optimizer prevented <span class="pct">≈' + tsSavedPct + '%</span> of the tokens this workload would otherwise have sent. Claude <code>/stats</code>-compatible spent: <b>' + fn(tsSpentTokens) + '</b>; tokens never sent: <b>' + fn(tsFullSaved) + '</b> (' + tsSplitShort + ').</div>';
|
|
3606
|
-
// Spent vs Saved bar: one row, two proportional segments (spent+saved).
|
|
3607
|
-
out += '<div class="ts-divider"></div>';
|
|
3608
|
-
out += '<div class="ts-section-label"><span>Spent vs Saved</span><span class="muted">without Token Optimizer: ≈' + fn(tsWouldSendTotal) + '</span></div>';
|
|
3609
|
-
out += '<div class="sv-bar" title="spent ' + fn(tsSpentTokens) + ' + saved ' + fn(tsFullSaved) + ' (' + tsSplitShort + ') = ' + fn(tsWouldSendTotal) + ' would-be total">';
|
|
3610
|
-
out += '<div class="sv-seg spent" style="width:' + tsSpentPct + '%">spent · ' + fn(tsSpentTokens) + '</div>';
|
|
3611
|
-
out += '<div class="sv-seg saved" style="width:' + tsSavedPct + '%">saved · ' + fn(tsFullSaved) + '</div>';
|
|
3612
|
-
out += '</div>';
|
|
3613
|
-
out += '<div class="sv-caption">Without Token Optimizer you\'d have sent <b>≈' + fn(tsWouldSendTotal) + '</b> to do the same work.</div>';
|
|
3614
|
-
// Model mix relabeled as USAGE: where the SPENT went. Bar + legend
|
|
3615
|
-
// reconcile to SPENT via a trailing "untracked" segment for tokens
|
|
3616
|
-
// billed without a model tag (SPENT - sum(model_mix)).
|
|
3617
|
-
if (tsModelTotal > 0) {
|
|
3618
|
-
out += '<div class="ts-divider"></div>';
|
|
3619
|
-
out += '<div class="ts-section-label"><span>Where the ' + fn(tsSpentTokens) + ' you spent went</span><span class="muted">which models do the work</span></div>';
|
|
3620
|
-
out += modelMixBodyHtml(tsModelMix, tsIsCodex, tsSpentTokens);
|
|
3621
|
-
}
|
|
3622
|
-
} else {
|
|
3623
|
-
// SAVED exists but SPENT is unknown (no billable total AND no
|
|
3624
|
-
// model_mix). Render the hero + footer only.
|
|
3625
|
-
out += '<div class="metric-sub tight">Token Optimizer saved <b>' + fn(tsFullSaved) + '</b> tokens that never had to be sent (' + tsSplitShort + ').</div>';
|
|
3626
|
-
}
|
|
3627
|
-
// Footer: metered floor + optional estimated-slice sentence + plan note.
|
|
3628
|
-
out += '<div class="ts-foot"><span class="tier">Measured + estimated.</span> ' + fn(tsSavedTokens) + ' of these tokens are metered action by action (the floor)' + (tsEstTokens > 0 ? '; ≈' + fn(tsEstTokens) + ' are estimated (' + esc(tsEstLabelList) + ') and are included in the headline, labelled.' : '.') + (tsSpentBasis.basis ? ' Spent basis: ' + esc(tsSpentBasis.basis) + '.' : '') + ' Subscription plan — counted in tokens, no per-token cost.</div>';
|
|
3629
|
-
out += '</div>';
|
|
3625
|
+
var bands = typeof savingsStoryBands === 'function' ? savingsStoryBands(data) : null;
|
|
3626
|
+
var total = bands ? bands.totalTok : Number((s.token_headline || {}).total_tokens) || 0;
|
|
3627
|
+
if (total <= 0) return '';
|
|
3628
|
+
var formatTokens = typeof savingsStoryFmt === 'function' ? savingsStoryFmt().tok : fn;
|
|
3629
|
+
var removed = Number((s.token_headline || {}).removed_tokens) || 0;
|
|
3630
|
+
var trends = data.trends || {};
|
|
3631
|
+
var mix = trends.model_mix || {};
|
|
3632
|
+
var modelTotal = 0;
|
|
3633
|
+
for (var model in mix) { modelTotal += Number(mix[model]) || 0; }
|
|
3634
|
+
var spent = Object.prototype.hasOwnProperty.call(trends, 'total_tokens') ? Math.max(0, Number(trends.total_tokens) || 0) : modelTotal;
|
|
3635
|
+
var days = Number(s.period_days) || 30;
|
|
3636
|
+
var out = '<div class="card wide"><div class="card-header"><span>Tokens Saved</span></div>';
|
|
3637
|
+
out += '<div style="display:flex;align-items:baseline;gap:var(--s-3);flex-wrap:wrap;margin-top:var(--s-2)"><div class="metric-large savings-hero">' + formatTokens(total) + '</div><div class="metric-unit">tokens kept out of context in the last ' + days + ' days</div></div>';
|
|
3638
|
+
var types = s.token_type_breakdown || {};
|
|
3639
|
+
var typeRows = [['cache_reread', 'Modeled cache re-reads avoided'], ['cache_write', 'Modeled cache writes avoided'], ['fresh', 'Fresh input and output avoided']];
|
|
3640
|
+
typeRows = typeRows.filter(function(row) { return typeof types[row[0]] === 'number' && isFinite(types[row[0]]); });
|
|
3641
|
+
if (typeRows.length) out += '<div class="ts-divider"></div><h3 class="ts-section-label">Tokens by type, partial ledger</h3><div class="st-bands">' + typeRows.map(function(row) {
|
|
3642
|
+
return '<div class="st-band">' + row[1] + '<br><strong>' + formatTokens(types[row[0]]) + '</strong></div>';
|
|
3643
|
+
}).join('') + '</div>';
|
|
3644
|
+
if (modelTotal > 0) {
|
|
3645
|
+
out += '<div class="ts-divider"></div><h3 class="ts-section-label">Model usage</h3>';
|
|
3646
|
+
out += modelMixBodyHtml(mix, data.runtime === 'codex', spent > 0 ? spent : modelTotal);
|
|
3647
|
+
}
|
|
3648
|
+
out += '<div class="ts-foot">' + formatTokens(removed) + ' tokens removed once.</div></div>';
|
|
3630
3649
|
return out;
|
|
3631
3650
|
}
|
|
3632
3651
|
|
|
3652
|
+
// Trends keeps only the model-usage bar from the old Tokens Saved card
|
|
3653
|
+
// (section 5): the savings figures live on the Savings tab now, and the
|
|
3654
|
+
// "Your limits go further" twin is removed (F8).
|
|
3655
|
+
function trendsModelMixCardHtml() {
|
|
3656
|
+
var t = data.trends || {};
|
|
3657
|
+
var mix = t.model_mix || {};
|
|
3658
|
+
var modelTotal = 0;
|
|
3659
|
+
for (var m in mix) { modelTotal += Number(mix[m]) || 0; }
|
|
3660
|
+
if (modelTotal <= 0) return '';
|
|
3661
|
+
var spent = Object.prototype.hasOwnProperty.call(t, 'total_tokens') ? Math.max(0, Number(t.total_tokens) || 0) : modelTotal;
|
|
3662
|
+
var days = Number(t.period_days) || 30;
|
|
3663
|
+
return '<div class="card wide"><div class="card-header"><span>Model usage</span></div>' +
|
|
3664
|
+
'<div style="font-size:13px;color:var(--c-text-dim);margin:0 0 var(--s-2);">Share of logged tokens by model, last ' + days + ' days.</div>' +
|
|
3665
|
+
modelMixBodyHtml(mix, data.runtime === 'codex', spent > modelTotal ? spent : modelTotal) + '</div>';
|
|
3666
|
+
}
|
|
3667
|
+
|
|
3633
3668
|
function renderTrends() {
|
|
3634
3669
|
var el = document.getElementById('view-trends');
|
|
3635
3670
|
if (!el) return;
|
|
@@ -3639,15 +3674,17 @@ var DB = (function() {
|
|
|
3639
3674
|
|
|
3640
3675
|
var ts = data.generated_at ? new Date(data.generated_at).toLocaleString() : 'unknown';
|
|
3641
3676
|
var html = '<div class="section-header">' +
|
|
3642
|
-
'<div class="label">Analytics</div>' +
|
|
3643
3677
|
'<h1>Usage Trends</h1>' +
|
|
3644
3678
|
'<p>How you use ' + esc(runtimeLabel) + ' across sessions.</p>' +
|
|
3645
3679
|
'</div>' +
|
|
3646
3680
|
'<div class="last-updated">Last updated: ' + esc(ts) + '</div>';
|
|
3647
3681
|
|
|
3648
|
-
//
|
|
3649
|
-
//
|
|
3650
|
-
|
|
3682
|
+
// The Tokens Saved card and the "Your limits go further" twin are cut
|
|
3683
|
+
// (sections 5 and F8): savings figures live on the Savings tab. Only the
|
|
3684
|
+
// model-usage bar was new information here.
|
|
3685
|
+
html += trendsModelMixCardHtml();
|
|
3686
|
+
// Context before the first message is not a saving: it lives here, not on Savings.
|
|
3687
|
+
if (typeof firstCallContextHtml === 'function') html += firstCallContextHtml((t || {}).first_call_context);
|
|
3651
3688
|
|
|
3652
3689
|
if (!t) {
|
|
3653
3690
|
var collectNote = isCodex
|
|
@@ -3677,48 +3714,35 @@ var DB = (function() {
|
|
|
3677
3714
|
html += '</select><span class="pricing-tier-badge">costs reflect this tier</span></div>';
|
|
3678
3715
|
}
|
|
3679
3716
|
|
|
3680
|
-
// Compute global cache hit rate
|
|
3717
|
+
// Compute global cache hit rate
|
|
3681
3718
|
var globalCacheRead = 0, globalCacheTotal = 0;
|
|
3682
|
-
var globalTtl1h = 0, globalTtl5m = 0;
|
|
3683
|
-
var globalMixedSessions = 0, globalFiveOnlySessions = 0;
|
|
3684
3719
|
(t.daily || []).forEach(function(dd) {
|
|
3685
3720
|
(dd.session_details || []).forEach(function(sd) {
|
|
3686
3721
|
if (sd.continuation) return; // multi-day session: count it once
|
|
3687
3722
|
var chr = sd.cache_hit_rate || 0;
|
|
3688
3723
|
if (chr > 0) { globalCacheRead += chr; globalCacheTotal++; }
|
|
3689
|
-
var ttl1h = sd.cache_create_1h_tokens || 0;
|
|
3690
|
-
var ttl5m = sd.cache_create_5m_tokens || 0;
|
|
3691
|
-
globalTtl1h += ttl1h;
|
|
3692
|
-
globalTtl5m += ttl5m;
|
|
3693
|
-
if (ttl1h && ttl5m) globalMixedSessions += 1;
|
|
3694
|
-
else if (ttl5m && !ttl1h) globalFiveOnlySessions += 1;
|
|
3695
3724
|
});
|
|
3696
3725
|
});
|
|
3697
3726
|
var avgCacheHit = globalCacheTotal > 0 ? (globalCacheRead / globalCacheTotal * 100).toFixed(0) : 'N/A';
|
|
3698
|
-
|
|
3699
|
-
var
|
|
3700
|
-
? ('Mixed sessions: ' + globalMixedSessions + ' | 5m-only: ' + globalFiveOnlySessions)
|
|
3701
|
-
: 'Recent main sessions were 1h-only';
|
|
3702
|
-
var ttlPeriodSummary = (data.ttl_period_summary || [])
|
|
3703
|
-
.map(function(item) { return item && item.label ? item.label : ''; })
|
|
3704
|
-
.filter(function(label) { return !!label; })
|
|
3705
|
-
.join(' | ');
|
|
3706
|
-
|
|
3707
|
-
var tokenLabel = isCodex ? 'Measured/Estimated Tokens' : 'Billable Tokens';
|
|
3727
|
+
|
|
3728
|
+
var tokenLabel = isCodex ? 'Measured/Estimated Tokens' : 'Deduplicated Fresh Input + Output';
|
|
3708
3729
|
var tokenNote = isCodex
|
|
3709
3730
|
? 'Codex logs use token_count snapshots when present; older sessions fall back to local estimates.'
|
|
3710
|
-
: '
|
|
3731
|
+
: 'Deduplicated usage; the raw token classes below use a different basis.';
|
|
3711
3732
|
var pop = t.population_metrics || {};
|
|
3712
3733
|
var eligibleCacheHit = Number(pop.cache_eligible_main_hit_rate);
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
var
|
|
3716
|
-
var
|
|
3717
|
-
|
|
3718
|
-
:
|
|
3734
|
+
// Claude: lead with the token-weighted rate across every scanned session;
|
|
3735
|
+
// the per-session averages become secondary lines.
|
|
3736
|
+
var overallCacheHit = Number((data.cache_health || {}).overall_cache_hit_rate);
|
|
3737
|
+
var cacheOverall = !isCodex && (data.cache_health || {}).overall_cache_hit_rate != null && Number.isFinite(overallCacheHit) && overallCacheHit >= 0;
|
|
3738
|
+
var avgCacheDisplay = cacheOverall ? (overallCacheHit * 100).toFixed(1).replace(/\.0$/, '')
|
|
3739
|
+
: (Number.isFinite(eligibleCacheHit) && pop.cache_eligible_main_sessions ? Math.round(eligibleCacheHit * 100) : avgCacheHit);
|
|
3740
|
+
var cacheLabel = isCodex ? 'Cached Input Share' : (cacheOverall ? 'Cache hit rate (all tokens)' : 'Main-work cache hit rate');
|
|
3741
|
+
// The six grey sub-lines under the cache number are cut (section 5):
|
|
3742
|
+
// session-mix and TTL debug output. The number and its label stand alone.
|
|
3719
3743
|
var tokenBreakdownNote = isCodex
|
|
3720
3744
|
? 'fresh:' + fn(t.total_fresh_input || 0) + ' · cached input:' + fn(t.total_cache_read || 0) + ' · out:' + fn(t.total_output_tokens || 0)
|
|
3721
|
-
: 'fresh:' + fn(t.total_fresh_input || 0) + ' · cache-write:' + fn(t.total_cache_create || 0) + ' · out:' + fn(t.total_output_tokens || 0);
|
|
3745
|
+
: 'raw fresh:' + fn(t.total_fresh_input || 0) + ' · cache-write:' + fn(t.total_cache_create || 0) + ' · out:' + fn(t.total_output_tokens || 0);
|
|
3722
3746
|
var codexCostNote = '';
|
|
3723
3747
|
if (isCodex && typeof t.total_cost_usd === 'number') {
|
|
3724
3748
|
codexCostNote = '<div style="font-size:10px;color:var(--c-text-dim);margin-top:2px">API-equivalent known cost: $' + t.total_cost_usd.toFixed(2);
|
|
@@ -3730,10 +3754,6 @@ var DB = (function() {
|
|
|
3730
3754
|
codexCostNote += '<div style="font-size:10px;color:var(--c-warning);margin-top:2px">' + esc(t.cost_note) + '</div>';
|
|
3731
3755
|
}
|
|
3732
3756
|
}
|
|
3733
|
-
var cacheExtra = isCodex
|
|
3734
|
-
? '<div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">' + cacheNote + '</div>'
|
|
3735
|
-
: '<div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">Cache writes: ' + esc(globalTtlMix) + '</div><div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">' + esc(globalTtlSessionLabel) + '</div><div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">' + esc(ttlPeriodSummary || 'TTL period summary unavailable') + '</div><div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">' + cacheNote + '</div>';
|
|
3736
|
-
|
|
3737
3757
|
html += '<div class="stat-row" style="grid-template-columns:repeat(3,1fr);margin-bottom:var(--s-3)">' +
|
|
3738
3758
|
'<div class="stat-card"><div class="stat-card-value">' + t.session_count + '</div><div class="stat-card-label">All logged sessions (' + t.period_days + 'd)</div><div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">' + (pop.main_work_sessions || 0) + ' main-work · ' + (pop.delegated_sessions || 0) + ' delegated/subagent</div></div>' +
|
|
3739
3759
|
'<div class="stat-card"><div class="stat-card-value">' + fn(t.total_tokens || 0) + '</div><div class="stat-card-label">' + tokenLabel + ', all logged (' + t.period_days + 'd)</div><div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">' + tokenNote + '</div><div style="font-size:10px;color:var(--c-text-dim);margin-top:2px">' + tokenBreakdownNote + '</div>' + codexCostNote + '</div>' +
|
|
@@ -3742,19 +3762,11 @@ var DB = (function() {
|
|
|
3742
3762
|
'<div class="stat-row" style="grid-template-columns:repeat(3,1fr)">' +
|
|
3743
3763
|
'<div class="stat-card"><div class="stat-card-value">' + Math.round(t.avg_duration_minutes || 0) + 'm</div><div class="stat-card-label">Avg duration, all logged</div></div>' +
|
|
3744
3764
|
'<div class="stat-card"><div class="stat-card-value">' + fn((t.avg_input_tokens || 0) + (t.avg_output_tokens || 0)) + '</div><div class="stat-card-label">Avg tokens, all logged sessions</div></div>' +
|
|
3745
|
-
'<div class="stat-card"><div class="stat-card-value" style="color:var(--c-savings-strong, #22c55e)">' + avgCacheDisplay +
|
|
3765
|
+
(avgCacheDisplay === 'N/A' ? '' : '<div class="stat-card"><div class="stat-card-value" style="color:var(--c-savings-strong, #22c55e)">' + avgCacheDisplay + '%</div><div class="stat-card-label">' + cacheLabel + '</div></div>') +
|
|
3746
3766
|
'</div>';
|
|
3747
3767
|
|
|
3748
|
-
// Shared data for skills sections
|
|
3749
3768
|
var skillsDetail = (data.snapshot && data.snapshot.components && data.snapshot.components.skills_detail) || {};
|
|
3750
3769
|
|
|
3751
|
-
// Tokens Saved card: the full card (hero + spent-vs-saved + model-mix-as-
|
|
3752
|
-
// usage + footer). Rendered in BOTH Trends and Savings (sharing the
|
|
3753
|
-
// hoisted tokensSavedCardHtml + modelMixBodyHtml helpers). Replaces the
|
|
3754
|
-
// former standalone Model Mix card — the model-mix-as-usage section is
|
|
3755
|
-
// now inside the Tokens Saved card, reconciled to the billable SPENT.
|
|
3756
|
-
// Fail-open: returns '' only when measured AND estimated are both ≤ 0.
|
|
3757
|
-
html += tokensSavedCardHtml(data.savings || {});
|
|
3758
3770
|
|
|
3759
3771
|
// Daily breakdown with date navigation
|
|
3760
3772
|
var daily = t.daily || [];
|
|
@@ -3805,9 +3817,9 @@ var DB = (function() {
|
|
|
3805
3817
|
topSkills.forEach(function(entry) {
|
|
3806
3818
|
var w = Math.max(3, (entry[1] / maxSkill) * 100);
|
|
3807
3819
|
var sd = skillsDetail[entry[0]];
|
|
3808
|
-
var tokNote = sd ? sd.frontmatter_tokens + '
|
|
3820
|
+
var tokNote = sd && typeof sd.frontmatter_tokens === 'number' ? ' (' + sd.frontmatter_tokens + ' frontmatter tokens)' : '';
|
|
3809
3821
|
html += '<div class="bar-row" data-skill-name="' + esc(entry[0]) + '" style="cursor:pointer;">' +
|
|
3810
|
-
'<span class="bar-label" style="width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" title="' + esc(entry[0]
|
|
3822
|
+
'<span class="bar-label" style="width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" title="' + esc(entry[0] + tokNote) + '">' + esc(entry[0]) + '</span>' +
|
|
3811
3823
|
'<div class="bar-track"><div class="bar-fill" style="width:' + w + '%"></div></div>' +
|
|
3812
3824
|
'<span class="bar-value" style="width:60px;text-align:right;">' + entry[1] + ' sess</span></div>';
|
|
3813
3825
|
});
|
|
@@ -3817,11 +3829,10 @@ var DB = (function() {
|
|
|
3817
3829
|
// Never-used skills with expandable detail (half-folded)
|
|
3818
3830
|
var neverUsed = t.skills ? t.skills.never_used : [];
|
|
3819
3831
|
if (!isCodex && neverUsed.length > 0) {
|
|
3820
|
-
var overhead = t.skills.never_used_overhead || (neverUsed.length * 100);
|
|
3821
3832
|
var PREVIEW_COUNT = 4;
|
|
3822
|
-
html += '<div class="card wide"><div class="card-header"><span>Not Invoked (' + neverUsed.length + ' skills)</span
|
|
3833
|
+
html += '<div class="card wide"><div class="card-header"><span>Not Invoked (' + neverUsed.length + ' skills)</span></div>' +
|
|
3823
3834
|
'<p style="font-size:13px;color:var(--c-text-dim);font-family:var(--font-mono);margin-bottom:var(--s-2);">' +
|
|
3824
|
-
'No Skill call or slash command for these in the window.
|
|
3835
|
+
'No Skill call or slash command for these in the window. A skill you drive by slash command counts as invoked; if one you use often shows here, open an issue. Click a skill for details, or "Quick Wins" to archive.</p>';
|
|
3825
3836
|
|
|
3826
3837
|
function buildSkillRow(name) {
|
|
3827
3838
|
var sd = skillsDetail[name];
|
|
@@ -3829,7 +3840,7 @@ var DB = (function() {
|
|
|
3829
3840
|
'<div class="skill-detail-header">' +
|
|
3830
3841
|
'<input type="checkbox" class="skill-archive-check" data-skill="' + esc(name) + '" title="Select to archive">' +
|
|
3831
3842
|
'<span class="skill-name">' + esc(name) + '</span>' +
|
|
3832
|
-
'<span class="skill-tokens">' +
|
|
3843
|
+
(sd && typeof sd.frontmatter_tokens === 'number' ? '<span class="skill-tokens">' + sd.frontmatter_tokens + ' frontmatter tokens</span>' : '') +
|
|
3833
3844
|
'<span class="expand-arrow">\u25B6</span>' +
|
|
3834
3845
|
'</div>' +
|
|
3835
3846
|
'<div class="skill-detail-body"><div class="skill-detail-content">';
|
|
@@ -3841,7 +3852,7 @@ var DB = (function() {
|
|
|
3841
3852
|
row += '</div>';
|
|
3842
3853
|
}
|
|
3843
3854
|
} else {
|
|
3844
|
-
row += '<div class="skill-desc"
|
|
3855
|
+
row += '<div class="skill-desc">No detail available</div>';
|
|
3845
3856
|
}
|
|
3846
3857
|
row += '</div></div></div>';
|
|
3847
3858
|
return row;
|
|
@@ -4015,7 +4026,7 @@ var DB = (function() {
|
|
|
4015
4026
|
}
|
|
4016
4027
|
|
|
4017
4028
|
function gapSummary(avgGap, maxGap) {
|
|
4018
|
-
if (avgGap == null && maxGap == null) return '
|
|
4029
|
+
if (avgGap == null && maxGap == null) return '';
|
|
4019
4030
|
if (avgGap == null) return 'max ' + fmtGap(maxGap);
|
|
4020
4031
|
if (maxGap == null) return 'avg ' + fmtGap(avgGap);
|
|
4021
4032
|
return 'avg ' + fmtGap(avgGap) + ' | max ' + fmtGap(maxGap);
|
|
@@ -4143,7 +4154,7 @@ var DB = (function() {
|
|
|
4143
4154
|
(isCodex ? '' : '<td style="font-family:var(--font-mono);font-size:11px;">' + esc(ttlStr) + '</td>') +
|
|
4144
4155
|
'<td style="font-family:var(--font-mono);font-size:11px;">' + esc(pacingStr) + '</td>' +
|
|
4145
4156
|
'<td style="color:var(--c-accent-cyan);font-family:var(--font-mono);font-size:12px;">' + costStr + '</td>' +
|
|
4146
|
-
'<td><span class="quality-badge ' + qBadgeClass + '">' + qGrade + ' (' + qs + ')</span></td>' +
|
|
4157
|
+
'<td><span class="quality-badge ' + qBadgeClass + '">' + (sd.quality_measured === false ? (sd.quality_score == null ? '--' : '~' + qs) : qGrade + ' (' + qs + ')') + '</span></td>' +
|
|
4147
4158
|
'<td style="color:var(--c-text-dim);font-size:11px;">' + esc(modelStr) + '</td>' +
|
|
4148
4159
|
'<td style="color:var(--c-text-dim);font-size:12px;" title="' + esc(sdTopic) + '">' + esc(sdTopic.length > 35 ? sdTopic.slice(0,33) + '\u2026' : sdTopic) + '</td>' +
|
|
4149
4160
|
'</tr>';
|
|
@@ -4274,6 +4285,11 @@ var DB = (function() {
|
|
|
4274
4285
|
'</div>' +
|
|
4275
4286
|
'</div>';
|
|
4276
4287
|
}).join('');
|
|
4288
|
+
// With the story module inlined, windows render as "X% used / would be Y%
|
|
4289
|
+
// without" (live, else the last stored reading); the older per-window cards
|
|
4290
|
+
// remain only for a template without it.
|
|
4291
|
+
var rwLimitsHtml = '';
|
|
4292
|
+
if (typeof savingsLimitWindows === 'function') { rwLimitsHtml = savingsLimitWindows(rw); rwCards = ''; }
|
|
4277
4293
|
// Savings remain available when the quota meter has no weekly reading.
|
|
4278
4294
|
var standaloneWeek = rw.weekly_full_value;
|
|
4279
4295
|
if (standaloneWeek && Number(standaloneWeek.saved_usd) >= 15 &&
|
|
@@ -4302,9 +4318,9 @@ var DB = (function() {
|
|
|
4302
4318
|
var rwCostCut = Number(rw.per_session_cost_reduction_pct);
|
|
4303
4319
|
var rwCostCutDisplay = isFinite(rwCostCut) ? Math.round(rwCostCut / 5) * 5 : null;
|
|
4304
4320
|
var rwSpentTokens = Number(rw.tokens_consumed);
|
|
4305
|
-
var rwSavedTokens = Number(rw.
|
|
4321
|
+
var rwSavedTokens = Number(rw.context_tokens_saved);
|
|
4306
4322
|
var rwTokenFloorPct = (isFinite(rwSpentTokens) && rwSpentTokens > 0 && isFinite(rwSavedTokens) && rwSavedTokens > 0)
|
|
4307
|
-
? Math.round(
|
|
4323
|
+
? Math.round((1 - 1 / Number(rw.context_multiplier)) * 1000) / 10
|
|
4308
4324
|
: null;
|
|
4309
4325
|
var rwEfficiencyHeadline = rwHasCostEfficiency
|
|
4310
4326
|
? '<div class="metric-large" style="text-wrap:balance;text-shadow:none;"><em style="font-style:normal;color:var(--c-accent-cyan);">≈' + rwEfficiencyMult.toFixed(1) + '×</em> work per dollar</div>'
|
|
@@ -4365,25 +4381,13 @@ var DB = (function() {
|
|
|
4365
4381
|
: 'Context ×' + rw.context_multiplier + ' and ' + rwRoutingMethod + ' give a per-token throughput multiplier, shown separately from the window headroom and dollar figures.';
|
|
4366
4382
|
rwEfficiencyMethod += rwRoutingScope;
|
|
4367
4383
|
var rwTokenFloorDetail = (rwTokenFloorPct !== null)
|
|
4368
|
-
? '<div class="plain-line">
|
|
4384
|
+
? '<div class="plain-line">Estimated <strong>~' + fn(rwSavedTokens) + '</strong> tokens kept out of context · ' + tokenSplitText(rw.token_headline || {}, fn) + ', roughly ' + rwTokenFloorPct + '% of would-be input and output including cache.' + (rw.tokens_consumed_basis_complete === false ? ' Traffic coverage is incomplete.' : '') + '</div>'
|
|
4369
4385
|
: '';
|
|
4370
4386
|
var rwTokenFloorMethod = (rwTokenFloorPct !== null)
|
|
4371
|
-
? '
|
|
4387
|
+
? 'Estimated savings on ' + fn(rwSpentTokens) + ' input and output tokens, including cache reads and writes; repeat reads assume the same trajectory until compaction.'
|
|
4372
4388
|
: '';
|
|
4373
|
-
// Tier chip reflects the USD spine's measured-vs-estimated boundary:
|
|
4374
|
-
// context $ is metered, routing $ is an estimated counterfactual.
|
|
4375
|
-
// When routing savings contribute, the dollar figure is estimated; when
|
|
4376
|
-
// only context $ contributes, it is measured. None -> no chip change.
|
|
4377
|
-
var usdTierChip = (rw.saved_usd_tier === 'measured') ? 'METERED $'
|
|
4378
|
-
: (rw.saved_usd_tier === 'estimated') ? 'ESTIMATED $' : 'ESTIMATED';
|
|
4379
4389
|
html += '<div class="card" style="margin-bottom:18px;border-color:rgba(0,240,255,.28);box-shadow:0 4px 20px rgba(0,0,0,.3),0 0 40px rgba(0,240,255,.05);">' +
|
|
4380
|
-
|
|
4381
|
-
// siblings the chip inherits the label's block layout and stretches to the
|
|
4382
|
-
// full card width, which reads as a broken banner.
|
|
4383
|
-
'<div style="display:flex;align-items:center;gap:var(--s-2);flex-wrap:wrap;">' +
|
|
4384
|
-
'<span class="label">Your plan goes further</span>' +
|
|
4385
|
-
'<span style="font-size:12px;letter-spacing:.12em;color:var(--c-text-dim);border:1px solid var(--c-border);border-radius:20px;padding:3px 12px;white-space:nowrap;">' + usdTierChip + '</span>' +
|
|
4386
|
-
'</div>' +
|
|
4390
|
+
'<h2 class="st-h">Your limits go further</h2>' +
|
|
4387
4391
|
// No glow on this headline. `.metric-large` carries a text-shadow built
|
|
4388
4392
|
// from --c-border-strong, which is a light veil on dark but resolves to a
|
|
4389
4393
|
// DARK halo in light mode, so the words read as smudged rather than lit.
|
|
@@ -4400,9 +4404,8 @@ var DB = (function() {
|
|
|
4400
4404
|
// Per-window bars when the meter is fresh enough; otherwise a note so the
|
|
4401
4405
|
// card degrades instead of vanishing (the multiplier + savings above still
|
|
4402
4406
|
// stand without the live meter).
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
: '<div style="padding:var(--s-3);border:1px dashed var(--c-border);border-radius:8px;color:var(--c-text-dim);font-size:15px;line-height:1.5;text-wrap:pretty;">Your live 5-hour and weekly limit view refreshes while you are actively working — it reappears here on your next session.</div>') +
|
|
4407
|
+
rwLimitsHtml +
|
|
4408
|
+
(rwCards ? '<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:var(--s-3);">' + rwCards + '</div>' : '') +
|
|
4406
4409
|
// Freshness of the WINDOW reading itself (not the dashboard build). The
|
|
4407
4410
|
// meter only refreshes while Claude Code is actively running, so a
|
|
4408
4411
|
// dashboard opened later shows the last real reading -- label it with its
|
|
@@ -4441,10 +4444,10 @@ var DB = (function() {
|
|
|
4441
4444
|
: '';
|
|
4442
4445
|
return '<div style="margin-top:var(--s-3);font-size:13px;color:' + col + ';">' +
|
|
4443
4446
|
(stale ? '⚠ ' : '') + 'Window reading as of ' + esc(whenStr) + ' (' + ageStr + ').' + staleNote +
|
|
4444
|
-
' <button id="to-regen-btn" onclick="window.__TOKEN_REGENERATE&&window.__TOKEN_REGENERATE()" ' +
|
|
4447
|
+
(window.location.protocol === 'file:' ? (window.__TOKEN_FILE_DAEMON_LIVE ? ' Open ' + DAEMON_URL + '/token-optimizer for live numbers.' : ' Run <code>python3 skills/token-optimizer/scripts/measure.py setup-daemon</code> to see live numbers.') : ' <button id="to-regen-btn" onclick="window.__TOKEN_REGENERATE&&window.__TOKEN_REGENERATE()" ' +
|
|
4445
4448
|
'style="margin-left:8px;padding:2px 10px;font:inherit;font-size:12px;cursor:pointer;' +
|
|
4446
4449
|
'background:transparent;color:inherit;border:1px solid currentColor;border-radius:4px;">' +
|
|
4447
|
-
'Regenerate savings</button>' +
|
|
4450
|
+
'Regenerate savings</button>') +
|
|
4448
4451
|
'<span id="to-regen-msg" style="margin-left:8px;"></span>' +
|
|
4449
4452
|
'<span id="to-live-stamp" hidden style="margin-left:8px;font-size:12px;color:var(--c-savings-alt, #10b981);"></span>' +
|
|
4450
4453
|
// Persistent regenerate failure surfaces here, not in the tiny
|
|
@@ -4454,7 +4457,6 @@ var DB = (function() {
|
|
|
4454
4457
|
'<div id="to-regen-error" hidden style="margin-top:10px;padding:10px 14px;font-size:15px;font-weight:500;color:var(--c-waste);background:rgba(255,95,95,.08);border:1px solid rgba(255,95,95,.35);border-radius:8px;line-height:1.5;text-wrap:pretty;"></div></div>';
|
|
4455
4458
|
})() +
|
|
4456
4459
|
'<div style="margin-top:var(--s-4);padding-top:var(--s-3);border-top:1px solid var(--c-border);font-size:15px;color:var(--c-text-main);line-height:1.6;text-wrap:pretty;">' +
|
|
4457
|
-
'Your window usage is measured. The savings comparison is an estimate.' +
|
|
4458
4460
|
// Technical method lives in a fold. rw.proxy is the single source of the
|
|
4459
4461
|
// measured-vs-estimated boundary AND the ledger detail; we add only the
|
|
4460
4462
|
// one fact proxy can't carry -- the headline figure is its own unit, not
|
|
@@ -4478,7 +4480,6 @@ var DB = (function() {
|
|
|
4478
4480
|
function renderSavings() {
|
|
4479
4481
|
var el = document.getElementById('view-savings');
|
|
4480
4482
|
if (!el) return;
|
|
4481
|
-
// Live refresh must not close the explanation someone is reading.
|
|
4482
4483
|
var openFolds = Array.from(el.querySelectorAll('details[open] > summary')).map(function(summary) {
|
|
4483
4484
|
return summary.textContent;
|
|
4484
4485
|
});
|
|
@@ -4530,7 +4531,6 @@ var DB = (function() {
|
|
|
4530
4531
|
if (v >= 1e3) return Math.round(v / 1e3) + 'K';
|
|
4531
4532
|
return String(Math.round(v));
|
|
4532
4533
|
}
|
|
4533
|
-
// Foldable "read more". Pass body as ready HTML (wrap prose in <p>...</p>).
|
|
4534
4534
|
// Native <details> means click-to-unfold works with no event wiring.
|
|
4535
4535
|
function fold(summary, bodyHtml) {
|
|
4536
4536
|
// summary is escaped (it is always plain label text); bodyHtml is trusted
|
|
@@ -4549,11 +4549,12 @@ var DB = (function() {
|
|
|
4549
4549
|
// ---- mechanism pillars (structural / runtime / behavioral). Behavioral holds only
|
|
4550
4550
|
// what you're actually getting (realized routing + estimated loop prevention); cache-drop
|
|
4551
4551
|
// and output-waste are OPPORTUNITY (avoidable waste TO does not yet prevent), not here. ----
|
|
4552
|
-
var
|
|
4552
|
+
var ce = s.contamination_exit || {}, hr = s.handover_rerun || {};
|
|
4553
4553
|
var rs = s.retrieval_serve || {};
|
|
4554
|
-
var rle =
|
|
4555
|
-
var vs =
|
|
4556
|
-
var
|
|
4554
|
+
var rle = {}; // The avoided reload is diagnostic, not a credited saving.
|
|
4555
|
+
var vs = {};
|
|
4556
|
+
var vo = {};
|
|
4557
|
+
var cr = {}; // Historical restore sizes may include injected context.
|
|
4557
4558
|
var cp = s.counted_period || {};
|
|
4558
4559
|
var rereadMo = cp.available ? mo(cp.reread_usd) : 0;
|
|
4559
4560
|
var hf = s.hint_followed || {};
|
|
@@ -4566,32 +4567,29 @@ var DB = (function() {
|
|
|
4566
4567
|
var avoidedSearchN = hfHasData ? (Number(hf.events) || 0) : (Number(rs.served_sessions) || 0);
|
|
4567
4568
|
var avoidedSearchUnit = hfHasData ? 'hints used' : 'served';
|
|
4568
4569
|
var structMo = mo(sd.cost_saved_usd);
|
|
4569
|
-
var runtimeMo = Math.max(0, mo(s.total_cost_usd) - structMo) + mo(unc.cost_saved_usd)
|
|
4570
|
-
// behavioral holds every estimated behavioral item (
|
|
4570
|
+
var runtimeMo = Math.max(0, mo(s.total_cost_usd) - structMo) + mo(unc.cost_saved_usd);
|
|
4571
|
+
// behavioral holds every estimated behavioral item (loops + the cohort
|
|
4571
4572
|
// estimators + avoided-search), so the pillars (struct + runtime + behavioral)
|
|
4572
4573
|
// always reconcile exactly to gettingMo (measured + estimated). Every estItems
|
|
4573
4574
|
// entry maps to exactly one pillar: loops/sub-agent/mcp_cap -> runtime;
|
|
4574
4575
|
// heeded/handover/avoided-search/lean-resumes -> behavioral.
|
|
4575
|
-
var behavMo = mo(
|
|
4576
|
-
// ---- trust tiers: measured / estimated / opportunity. Opportunity
|
|
4577
|
-
//
|
|
4578
|
-
//
|
|
4579
|
-
|
|
4580
|
-
var routingEstimated = mr.evidence === 'estimated';
|
|
4581
|
-
var measuredMo = mo(s.total_cost_usd) + (routingEstimated ? 0 : mo(mr.realized_cost_usd));
|
|
4576
|
+
var behavMo = mo(beh.cost_saved_usd) + mo(ce.cost_saved_usd) + mo(hr.cost_saved_usd) + avoidedSearchMo + mo(rle.cost_saved_usd) + mo(vs.cost_saved_usd) + mo(cr.cost_saved_usd);
|
|
4577
|
+
// ---- trust tiers: measured / estimated / opportunity. Opportunity and the
|
|
4578
|
+
// routing assumption NEVER fold into the headline. ----
|
|
4579
|
+
// Measured = billable events we metered (runtime compression).
|
|
4580
|
+
var measuredMo = mo(s.total_cost_usd);
|
|
4582
4581
|
// Estimated = genuine TO-realized counterfactuals grounded in YOUR behavior; each carries a sample size.
|
|
4583
|
-
//
|
|
4582
|
+
// Pillars and estimated amounts reconcile to gettingMo.
|
|
4584
4583
|
var estItems = [
|
|
4585
|
-
{ key: 'routing_estimated', label: 'model routing', amt: routingEstimated ? mo(mr.realized_cost_usd) : 0, n: (mr.baseline_reference_priced || []).length, unit: 'model families on one newest-card price list' },
|
|
4586
4584
|
{ key: 'behavioral_estimate', label: 'loops prevented', amt: mo(beh.cost_saved_usd), n: Number(beh.loop_events) || 0, unit: 'events' },
|
|
4587
4585
|
{ key: 'uncaptured_runtime', label: 'sub-agent runtime', amt: mo(unc.cost_saved_usd), n: Number(unc.subagent_dispatches) || 0, unit: 'dispatches' },
|
|
4588
|
-
{ key: 'mcp_cap_estimated', label: 'MCP output cap', amt: mo(mce.cost_saved_usd), n: Number(mce.events) || 0, unit: 'capped results' },
|
|
4589
4586
|
{ key: 'contamination_exit', label: 'avoided rework (heeded nudges)', amt: mo(ce.cost_saved_usd), n: Number(ce.heeded_sessions) || 0, unit: 'heeded', conf: ce.confidence },
|
|
4590
4587
|
{ key: 'handover_rerun', label: 'continuity handover', amt: mo(hr.cost_saved_usd), n: Number(hr.restored_sessions) || 0, unit: 'restored', conf: hr.confidence },
|
|
4591
4588
|
{ key: 'avoided_search', label: 'avoided search (hints)', amt: avoidedSearchMo, n: avoidedSearchN, unit: avoidedSearchUnit, conf: hfHasData ? 'trigger observed, size estimated' : rs.confidence },
|
|
4592
|
-
{ key: 'resume_lean_estimated', label: 'lean resumes (cold reload avoided)', amt: mo(rle.cost_saved_usd), n: Number(rle.events) || 0, unit: 'resumes' },
|
|
4593
4589
|
{ key: 'checkpoint_restore_estimated', label: 'checkpoint restores (working-set re-reads)', amt: mo(cr.cost_saved_usd), n: Number(cr.events) || 0, unit: 'restores' },
|
|
4594
|
-
{ key: 'verbosity_steer', label: 'concise output nudges', amt: mo(vs.cost_saved_usd), n: Number(vs.events) || 0, unit: 'nudges' }
|
|
4590
|
+
{ key: 'verbosity_steer', label: 'concise output nudges', amt: mo(vs.cost_saved_usd), n: Number(vs.events) || 0, unit: 'nudges' },
|
|
4591
|
+
{ key: 'verbosity_output_estimated', label: 'shorter replies and their re-reads (net of un-nudged replies)', amt: mo(vo.cost_saved_usd), n: Number(vo.events) || 0, unit: 'calibrated nudges',
|
|
4592
|
+
conf: vo.basis === 'no_reduction_net_of_control' ? 'no reduction net of the control' : (vo.basis === 'not_measured' && vo.events ? 'NOT MEASURED: no un-nudged control yet' : undefined) }
|
|
4595
4593
|
].filter(function(it){ return it.amt > 0 || it.conf; });
|
|
4596
4594
|
var estimatedMo = estItems.reduce(function(a, b){ return a + b.amt; }, 0);
|
|
4597
4595
|
// What you're getting = measured + estimated (both real value; estimated shown split-out, never hidden).
|
|
@@ -4600,9 +4598,9 @@ var DB = (function() {
|
|
|
4600
4598
|
// retain the component calculation above until their next regeneration.
|
|
4601
4599
|
var actionSavings = s.action_savings;
|
|
4602
4600
|
if (actionSavings) {
|
|
4603
|
-
measuredMo = mo(actionSavings.logged_usd) + mo(actionSavings.
|
|
4601
|
+
measuredMo = mo(actionSavings.logged_usd) + mo(actionSavings.class_premium_usd || 0);
|
|
4604
4602
|
rereadMo = mo(actionSavings.reread_usd);
|
|
4605
|
-
estimatedMo = mo(actionSavings.estimated_usd)
|
|
4603
|
+
estimatedMo = mo(actionSavings.estimated_usd);
|
|
4606
4604
|
gettingMo = mo(actionSavings.total_usd);
|
|
4607
4605
|
}
|
|
4608
4606
|
// Whole-cent display values from the payload: the parts shown on the card
|
|
@@ -4614,11 +4612,11 @@ var DB = (function() {
|
|
|
4614
4612
|
var estSumCents = Object.keys(de).reduce(function(a, k) { return a + de[k]; }, 0);
|
|
4615
4613
|
exactCents = {
|
|
4616
4614
|
total: dispCents.total_cents,
|
|
4617
|
-
logged: dc.logged + dc.
|
|
4615
|
+
logged: dc.logged + (Number(dc.class_premium) || 0),
|
|
4616
|
+
premium: Number(dc.class_premium) || 0,
|
|
4618
4617
|
reread: dc.reread,
|
|
4619
|
-
other: estSumCents
|
|
4618
|
+
other: estSumCents,
|
|
4620
4619
|
est: de,
|
|
4621
|
-
routingEstimated: dc.routing_estimated,
|
|
4622
4620
|
avoidedKey: actionSavings.avoided_search_source
|
|
4623
4621
|
};
|
|
4624
4622
|
}
|
|
@@ -4627,14 +4625,20 @@ var DB = (function() {
|
|
|
4627
4625
|
}
|
|
4628
4626
|
function estCents(item) {
|
|
4629
4627
|
var key = item.key === 'avoided_search' ? exactCents.avoidedKey : item.key;
|
|
4630
|
-
return
|
|
4628
|
+
return exactCents.est[key];
|
|
4631
4629
|
}
|
|
4632
4630
|
// Opportunity = realizable if you act; never realized, never summed into "getting".
|
|
4633
4631
|
// output-waste is $ here; cache-drop is shown separately in TOKENS (re-written prefix) —
|
|
4634
4632
|
// its $ is Anthropic-specific (OpenAI/OpenCode cache writes are free), but the token count
|
|
4635
4633
|
// is a provider-neutral fact, matching Claude Code's own token-denominated display.
|
|
4636
4634
|
var recl = s.stale_reads_reclaimable || {};
|
|
4637
|
-
var cdTokensMo = Math.round((Number(cd.
|
|
4635
|
+
var cdTokensMo = Math.round((Number(cd.rebuilt_tokens) > 0 ? Number(cd.rebuilt_tokens)
|
|
4636
|
+
: (Number(cd.est_drops) || 0) * (Number(cd.prefix_tokens) || 0)) / Math.max(days, 1) * 30);
|
|
4637
|
+
// The cache TTL this user's own writes show: 1 hour (Claude Code) or 5 minutes.
|
|
4638
|
+
var cdShortTtl = Number(cd.ttl_seconds) > 0 && Number(cd.ttl_seconds) < 3600;
|
|
4639
|
+
var cdCacheName = cdShortTtl ? 'the 5-minute cache' : (Number(cd.ttl_seconds) >= 3600 ? 'the 1-hour cache' : 'the cache window');
|
|
4640
|
+
var cdResume = cdShortTtl ? 'Resume within 5 minutes' : 'Resume within the hour';
|
|
4641
|
+
var cdRebuilds = Number(cd.est_drops) || 0;
|
|
4638
4642
|
// The big opportunity number holds only evidence-backed items (unused skills,
|
|
4639
4643
|
// stale re-reads, full-file Writes). Routing rests on an assumed share of your
|
|
4640
4644
|
// Opus work, so it gets its own line below the number and is never added in.
|
|
@@ -4663,117 +4667,75 @@ var DB = (function() {
|
|
|
4663
4667
|
var routingTarget = mr.target_model || "Sonnet";
|
|
4664
4668
|
var unusedSkills = Number(sp.unused_skills) || 0;
|
|
4665
4669
|
var currOpus = Math.round((Number(mr.current_opus_share) || 0) * 100);
|
|
4670
|
+
var fmtPct = function(x) { return Math.round((Number(x) || 0) * 1000) / 10; };
|
|
4671
|
+
var routingRealizedMo = mo(actionSavings && actionSavings.routing_usd != null
|
|
4672
|
+
? actionSavings.routing_usd : mr.realized_cost_usd);
|
|
4673
|
+
var routingBaselinePct = fmtPct(mr.baseline_opus_share);
|
|
4674
|
+
var routingAssumption = (mr.baseline_provenance && mr.baseline_provenance.short) ? String(mr.baseline_provenance.short)
|
|
4675
|
+
: mr.baseline_source === 'pretool_baseline'
|
|
4676
|
+
? 'assuming ' + routingBaselinePct + '% Opus before Token Optimizer'
|
|
4677
|
+
: (mr.baseline_opus_share != null
|
|
4678
|
+
? 'against a measured ' + routingBaselinePct + '% Opus baseline'
|
|
4679
|
+
: 'against an Opus baseline');
|
|
4680
|
+
var routingAltShare = mr.measured_baseline_opus_share;
|
|
4681
|
+
var routingAltMo = mr.measured_baseline_realized_cost_usd != null ? mo(mr.measured_baseline_realized_cost_usd) : null;
|
|
4666
4682
|
var ts = data.generated_at ? new Date(data.generated_at).toLocaleString() : 'unknown';
|
|
4683
|
+
var storyOn = (typeof savingsStoryOn === 'function') && savingsStoryOn(data);
|
|
4684
|
+
|
|
4685
|
+
// ---- SAVE MORE: suggestions, promoted right under the hero ----
|
|
4686
|
+
// Built before the story render: in story mode they fold into "Still on
|
|
4687
|
+
// the table" ("More changes you could make") so the two never contradict;
|
|
4688
|
+
// in legacy mode they feed the "Money on the table" card below.
|
|
4689
|
+
var parts = [];
|
|
4690
|
+
if ((Number(sp.cost_saved_usd) || 0) > 0 && unusedSkills > 0) {
|
|
4691
|
+
parts.push('Review ' + unusedSkills + ' skill' + (unusedSkills === 1 ? '' : 's') + ' not invoked in this window.');
|
|
4692
|
+
}
|
|
4693
|
+
if ((Number(recl.cost_usd) || 0) > 0) {
|
|
4694
|
+
parts.push('Avoid re-reading files that have not changed, or add them to .contextignore. ' + (Number(recl.tokens) || 0).toLocaleString() + ' tokens of stale re-reads across ' + (Number(recl.sessions) || 0).toLocaleString() + ' sessions are worth about ' + moneyCents(oppCents.reclaimable) + per + '.');
|
|
4695
|
+
}
|
|
4696
|
+
if (!storyOn && (Number(mr.potential_cost_usd) || 0) > 0) {
|
|
4697
|
+
parts.push('Route routine work to lighter models and keep Opus for the work that needs it. The routing line above shows the size of that assumption.');
|
|
4698
|
+
}
|
|
4699
|
+
if (cdTokensMo > 0) {
|
|
4700
|
+
parts.push(cdResume + ', or batch related work before stepping away. ' + (Number(cd.drop_sessions) || 0) + ' of your sessions idled past ' + cdCacheName + ' and re-wrote the prefix' + (cdRebuilds > 0 ? ' ' + cdRebuilds.toLocaleString() + ' time' + (cdRebuilds === 1 ? '' : 's') : '') + ', about ' + cdTokensMo.toLocaleString() + ' tokens' + per + (cdCostMo > 0 ? ', worth about ' + money(cdCostMo) + per + ' at API rates' : '') + '.');
|
|
4701
|
+
}
|
|
4702
|
+
if ((Number(ow.cost_saved_usd) || 0) > 0) {
|
|
4703
|
+
parts.push('Favor targeted Edits over full-file Writes. About ' + (Number(ow.avoidable_writes) || 0) + ' of your Writes could have been Edits, worth about ' + moneyCents(oppCents.output) + per + ' in output.');
|
|
4704
|
+
}
|
|
4705
|
+
|
|
4706
|
+
// U9: the savings story leads when the payload carries session_effect;
|
|
4707
|
+
// older payloads (or a template without the inlined module) keep the
|
|
4708
|
+
// previous layout unchanged. extras carries the "Still on the table" fix
|
|
4709
|
+
// targets and the merged "More changes you could make" parts.
|
|
4710
|
+
var story = '';
|
|
4711
|
+
if (storyOn) {
|
|
4712
|
+
try {
|
|
4713
|
+
story = (typeof savingsStoryHtml === 'function') ? savingsStoryHtml(data, {
|
|
4714
|
+
fixes: (typeof savingsOnTableFixes === 'function') ? savingsOnTableFixes() : {},
|
|
4715
|
+
parts: parts,
|
|
4716
|
+
optimizerHint: data.runtime !== 'cursor' && data.runtime !== 'antigravity'
|
|
4717
|
+
}) : '';
|
|
4718
|
+
} catch (e) { story = ''; }
|
|
4719
|
+
}
|
|
4720
|
+
|
|
4721
|
+
// F13: "Updated today at 8:33 PM", not a raw locale timestamp.
|
|
4722
|
+
var updTxt = 'unknown';
|
|
4723
|
+
var updDate = data.generated_at ? new Date(data.generated_at) : null;
|
|
4724
|
+
if (updDate && !isNaN(updDate.getTime())) {
|
|
4725
|
+
var updNow = new Date();
|
|
4726
|
+
var updDay = Math.floor((new Date(updNow.getFullYear(), updNow.getMonth(), updNow.getDate()) - new Date(updDate.getFullYear(), updDate.getMonth(), updDate.getDate())) / 86400000);
|
|
4727
|
+
var updWhen = updDate.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' });
|
|
4728
|
+
updTxt = (updDay <= 0 ? 'today' : updDay === 1 ? 'yesterday' : updDate.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })) + ' at ' + updWhen;
|
|
4729
|
+
}
|
|
4667
4730
|
|
|
4668
4731
|
var html = '<div class="section-header">' +
|
|
4669
|
-
'<div class="label">Value</div><h1>Savings</h1>' +
|
|
4670
|
-
|
|
4732
|
+
(story ? '<h1>Savings</h1>' : '<div class="label">Value</div><h1>Savings</h1>' +
|
|
4733
|
+
'<p>Your savings, with the time period and method shown for each total.</p>') +
|
|
4671
4734
|
'</div>' +
|
|
4672
|
-
'<div class="last-updated">Updated ' + esc(
|
|
4673
|
-
|
|
4674
|
-
html += runwayCardHtml();
|
|
4675
|
-
|
|
4676
|
-
// ---- HERO: the before/after transformation (THE headline). Current activity priced at
|
|
4677
|
-
// your pre-TO per-session weight + mix vs actual — comprehensive (volume + structural +
|
|
4678
|
-
// routing + sub-agents), grounded in your own earliest-vs-recent sessions. ----
|
|
4679
|
-
var ba = s.before_after || {};
|
|
4680
|
-
if (Number(ba.monthly_savings_usd) > 0) {
|
|
4681
|
-
var wp = ba.session_weight_pool || null;
|
|
4682
|
-
var wpUnit = (wp && wp.work_unit === 'message') ? 'message' : 'API call';
|
|
4683
|
-
var oldCost = Number(ba.counterfactual_monthly_usd) || 0;
|
|
4684
|
-
var nowCost = Number(ba.actual_monthly_usd) || 0;
|
|
4685
|
-
// Use the displayed saving so a spend-capped headline cannot retain the
|
|
4686
|
-
// larger, uncapped percentage implied by the counterfactual arms.
|
|
4687
|
-
var shownSaving = Number(ba.monthly_savings_usd) || 0;
|
|
4688
|
-
var costCut = oldCost > 0 ? Math.max(0, shownSaving / oldCost * 100) : 0;
|
|
4689
|
-
// A neutral add-back reprice (routing pending or unavailable) shrinks the
|
|
4690
|
-
// transformation figure without any visible reason -- say why, plainly.
|
|
4691
|
-
var baRepriceBasis = ba.compression_reprice_basis;
|
|
4692
|
-
var baRepriceNote = (baRepriceBasis === 'routing_pending')
|
|
4693
|
-
? 'Model-mix repricing is paused while sessions finish re-measuring, so the add-backs in this estimate show their measured value.'
|
|
4694
|
-
: (baRepriceBasis === 'routing_unavailable'
|
|
4695
|
-
? 'Model-mix repricing could not be measured, so the add-backs in this estimate show their measured value.'
|
|
4696
|
-
: '');
|
|
4697
|
-
html += '<div class="card wide savings-transformation" style="padding:var(--s-4);margin-bottom:var(--s-3);">' +
|
|
4698
|
-
'<div class="label">Transformation · last ' + days + ' days · estimated</div>' +
|
|
4699
|
-
'<div class="savings-amount">' + money(ba.monthly_savings_usd) +
|
|
4700
|
-
'<span class="savings-unit"> saved · ~' + Math.round(costCut) + '% lower cost</span></div>' +
|
|
4701
|
-
'<p class="lede">Your recent workload compared with your earlier way of working, at the same token prices.</p>' +
|
|
4702
|
-
'<div class="savings-split"><span>Now <strong>' + money(nowCost) + '</strong></span>' +
|
|
4703
|
-
'<span>Earlier workflow <strong>' + money(oldCost) + '</strong></span></div>' +
|
|
4704
|
-
'<div class="plain-line">Overlaps with the action savings below. Do not add the two totals.</div>' +
|
|
4705
|
-
(baRepriceNote ? '<div class="plain-line">' + baRepriceNote + '</div>' : '') +
|
|
4706
|
-
fold('How this is estimated',
|
|
4707
|
-
countedList([ba.savings_capped && ba.savings_cap_note ? esc(ba.savings_cap_note) : '']) +
|
|
4708
|
-
(wp
|
|
4709
|
-
? '<p>Baseline: <strong>' + esc(wp.anchor_month) + '</strong>. We compare cost per ' + wpUnit +
|
|
4710
|
-
' at constant prices, then apply the difference to the <strong>' +
|
|
4711
|
-
(Number(wp.now_units) || 0).toLocaleString() + '</strong> ' + wpUnit +
|
|
4712
|
-
's in this period. Current cost: ' + money(Number(wp.after_cost_per_unit)) +
|
|
4713
|
-
' per ' + wpUnit + '; baseline: ' + money(Number(wp.before_cost_per_unit)) + '.</p>' +
|
|
4714
|
-
'<p>More, smaller sessions are not counted as dollar savings. Changes in model prices and model mix are excluded. ' +
|
|
4715
|
-
'Delegated work attached to a main session is included in its cost; it is not added again.</p>'
|
|
4716
|
-
: '<p>We price your frozen baseline session using your earlier and current model and cache patterns, ' +
|
|
4717
|
-
'then scale the difference to this period. Context savings and normalized delegated work complete the estimate.</p>') +
|
|
4718
|
-
'<p>This comparison includes changes in your own habits. It cannot isolate Token Optimizer’s contribution. ' +
|
|
4719
|
-
'An API call is a workload proxy, not a measure of task difficulty or quality.</p>' +
|
|
4720
|
-
'<p>' + billingCaption + '</p>') +
|
|
4721
|
-
'</div>';
|
|
4722
|
-
} else if (ba.baseline_building) {
|
|
4723
|
-
// New install: no frozen baseline yet, so the headline transformation can't be
|
|
4724
|
-
// computed. Explain WHY (it uses the user's OWN history, never a fake anchor) and
|
|
4725
|
-
// show progress, instead of silently rendering nothing and leaving only the small
|
|
4726
|
-
// measured floor below (which reads as "TO only saved me $X").
|
|
4727
|
-
var bb = ba.baseline_building;
|
|
4728
|
-
var sNeed = Number(bb.sessions_needed) || 30;
|
|
4729
|
-
var sHave = Math.min(sNeed, Number(bb.sessions_in_window) || 0);
|
|
4730
|
-
var dLeft = Number(bb.days_left) || 0;
|
|
4731
|
-
var pct = sNeed > 0 ? Math.min(100, Math.round(sHave / sNeed * 100)) : 0;
|
|
4732
|
-
html += '<div class="card wide" style="padding:var(--s-5) var(--s-4);margin-bottom:var(--s-3);border:1px solid var(--c-accent-blue);box-shadow:0 0 0 1px rgba(0,102,255,0.12);">' +
|
|
4733
|
-
'<div class="label" style="margin-bottom:var(--s-2);color:var(--c-accent-cyan);">Your savings baseline is still building</div>' +
|
|
4734
|
-
'<div class="lede">Token Optimizer measures your savings against <strong>your own</strong> pre-optimization baseline, frozen from your first ' + (Number(bb.early_window_days) || 30) + ' days of real sessions. It never uses anyone else\'s numbers, and never freezes a half-formed anchor.</div>' +
|
|
4735
|
-
'<div class="lede" style="margin-top:var(--s-2);"><strong>' + sHave + ' of ~' + sNeed + ' sessions</strong> collected in your baseline window' + (dLeft > 0 ? ', about <strong>' + dLeft + ' day' + (dLeft === 1 ? '' : 's') + '</strong> until it locks in' : '') + '. Until then, the figure below is the directly-metered floor, not your full savings.</div>' +
|
|
4736
|
-
'<div style="margin-top:var(--s-4);height:8px;background:rgba(255,255,255,0.08);border-radius:4px;overflow:hidden;"><div style="height:100%;width:' + pct + '%;background:var(--c-accent-cyan);box-shadow:0 0 12px var(--c-accent-glow);transition:width .3s;"></div></div>' +
|
|
4737
|
-
'</div>';
|
|
4738
|
-
} else if (ba.reason === 'net_negative') {
|
|
4739
|
-
// Baseline is frozen, but efficiency was flat-to-negative this period (now costs about
|
|
4740
|
-
// the same as — or slightly more than — the frozen baseline would have). We show NO
|
|
4741
|
-
// counterfactual headline (a saving we didn't make), just an honest neutral note plus
|
|
4742
|
-
// the arms; the directly-metered floor card below still reports realized savings. This
|
|
4743
|
-
// is the net<=0 branch — parity with OpenClaw/OpenCode.
|
|
4744
|
-
html += '<div class="card wide" style="padding:var(--s-5) var(--s-4);margin-bottom:var(--s-3);">' +
|
|
4745
|
-
'<div class="label" style="margin-bottom:var(--s-2);">At or above your baseline this period</div>' +
|
|
4746
|
-
'<div class="lede">Your recent sessions cost about what your frozen baseline would have — est. <strong>' + money(ba.actual_monthly_usd) + '</strong> now vs <strong>' + money(ba.counterfactual_monthly_usd) + '</strong> the old way in the last ' + days + ' days. There is no net saving to headline this period, so we are not showing one. The figure below is what Token Optimizer counted directly, action by action.</div>' +
|
|
4747
|
-
'</div>';
|
|
4748
|
-
} else if (ba.reason === 'flat') {
|
|
4749
|
-
// Both work-unit methods sit within a few percent of spend: no
|
|
4750
|
-
// measurable whole-workload change, so no headline and no scary number.
|
|
4751
|
-
html += '<div class="card wide" style="padding:var(--s-5) var(--s-4);margin-bottom:var(--s-3);">' +
|
|
4752
|
-
'<div class="label" style="margin-bottom:var(--s-2);">No measurable change in cost per unit of work</div>' +
|
|
4753
|
-
'<div class="plain-line">Your recent work costs about the same per request as before install (' + money(ba.actual_monthly_usd) + ' now vs ' + money(ba.counterfactual_monthly_usd) + ' the old way over ' + days + ' days). The savings below are counted action by action.</div>' +
|
|
4754
|
-
'</div>';
|
|
4755
|
-
} else if (ba.reason === 'methods_disagree') {
|
|
4756
|
-
// The two independent work-unit methods (per-API-call and per-message)
|
|
4757
|
-
// landed more than 10% apart, so neither figure is trustworthy enough to
|
|
4758
|
-
// headline. Show both, headline nothing; the metered floor card below
|
|
4759
|
-
// still reports realized savings. Same neutral-card shape as
|
|
4760
|
-
// net_negative, with signed money for the cross-check figure.
|
|
4761
|
-
var swp = ba.session_weight_pool || {};
|
|
4762
|
-
var swpCross = swp.crosscheck || {};
|
|
4763
|
-
var mainUsd = Number(swp.transformation_usd) || 0;
|
|
4764
|
-
var crossUsd = Number(swpCross.transformation_usd) || 0;
|
|
4765
|
-
var mainUnit = swp.work_unit === 'message' ? 'per-message' : 'per-API-call';
|
|
4766
|
-
var crossUnit = swpCross.unit === 'api_call' ? 'per-API-call' : 'per-message';
|
|
4767
|
-
var signedMoney = function (n) {
|
|
4768
|
-
var v = Number(n) || 0;
|
|
4769
|
-
return (v < 0 ? '-' : '') + money(Math.abs(v));
|
|
4770
|
-
};
|
|
4771
|
-
html += '<div class="card wide" style="padding:var(--s-5) var(--s-4);margin-bottom:var(--s-3);">' +
|
|
4772
|
-
'<div class="label" style="margin-bottom:var(--s-2);">Two estimates disagree this period</div>' +
|
|
4773
|
-
'<div class="lede">The ' + mainUnit + ' estimate is <strong>' + signedMoney(mainUsd) + '</strong> and the ' + crossUnit +
|
|
4774
|
-
' estimate is <strong>' + signedMoney(crossUsd) + '</strong> over ' + days + ' days. They are too far apart to headline either one. The figure below is what Token Optimizer counted directly, action by action.</div>' +
|
|
4775
|
-
'</div>';
|
|
4776
|
-
}
|
|
4735
|
+
'<div class="last-updated">Updated ' + esc(updTxt) + ' · refreshes after every session</div>';
|
|
4736
|
+
|
|
4737
|
+
html += story || runwayCardHtml();
|
|
4738
|
+
var storyHead = html; html = '';
|
|
4777
4739
|
|
|
4778
4740
|
// ---- Tokens Saved card: the full card (hero + spent-vs-saved + model-
|
|
4779
4741
|
// mix-as-usage + footer). Rendered as the 2nd card in the Savings view,
|
|
@@ -4781,15 +4743,14 @@ var DB = (function() {
|
|
|
4781
4743
|
// "Counted directly" measured-floor card below. Also rendered in the
|
|
4782
4744
|
// Trends view — both call the shared hoisted tokensSavedCardHtml helper
|
|
4783
4745
|
// so the card is identical across views. SPENT = trends.total_tokens
|
|
4784
|
-
// (billable total)
|
|
4746
|
+
// (billable total); the savings total comes from savingsStoryBands. See tokensSavedCardHtml
|
|
4785
4747
|
// for the full fail-open spec. ----
|
|
4786
4748
|
// Add only rereads to the one-shot ledger. Adding the counted-period total
|
|
4787
4749
|
// would count its initial removals twice and discard unmatched logged events.
|
|
4788
4750
|
html += '<div style="display:flex;gap:var(--s-3);flex-wrap:wrap;margin-bottom:var(--s-3);">';
|
|
4789
4751
|
var periodLabel = runRate ? 'last ' + days + ' days' : trackedDays + ' days tracked';
|
|
4790
4752
|
var heroAmt = gettingMo;
|
|
4791
|
-
//
|
|
4792
|
-
// other counting note lives in the card's "Breakdown and method" fold.
|
|
4753
|
+
// Incomplete pricing is disclosed here; the full method is in the fold.
|
|
4793
4754
|
var actionPricingIncomplete = !!(cp.reread_pricing_note ||
|
|
4794
4755
|
(actionSavings && actionSavings.reread_prices_available === false) || cp.reread_prices_available === false ||
|
|
4795
4756
|
Number(s.compression_unpriced_tokens) > 0 ||
|
|
@@ -4797,18 +4758,17 @@ var DB = (function() {
|
|
|
4797
4758
|
html += '<div class="card savings-actions" style="flex:2;min-width:min(100%,320px);padding:var(--s-4);">' +
|
|
4798
4759
|
'<div class="label">Action savings · ' + periodLabel + '</div>' +
|
|
4799
4760
|
'<div class="savings-amount">' + (exactCents ? moneyCents(exactCents.total) : money(periodValue(heroAmt))) + '<span class="savings-unit"> logged + estimated</span></div>' +
|
|
4761
|
+
(s.token_headline ? '<p class="plain-line">~' + fmtTok(s.token_headline.total_tokens) + ' tokens kept out of context · ' + tokenSplitText(s.token_headline, fmtTok) + ' (estimated)' + (s.token_headline.refresh_incomplete_events || s.token_headline.unmeasured_events ? ', incomplete coverage' : '') + '.</p>' : '') +
|
|
4800
4762
|
'<div class="savings-split"><span>Logged actions <strong>' + (exactCents ? moneyCents(exactCents.logged) : money(periodValue(measuredMo))) + '</strong></span>' +
|
|
4801
|
-
|
|
4802
|
-
(
|
|
4803
|
-
((actionSavings && actionSavings.reread_prices_available === false) || cp.reread_prices_available === false ?
|
|
4804
|
-
'Unpriced' : '~' + (exactCents ? moneyCents(exactCents.reread) : money(periodValue(rereadMo))))) + '</strong></span>' +
|
|
4763
|
+
((!cp.available && !(actionSavings && actionSavings.reread_available === true)) || (actionSavings && (actionSavings.reread_available === false || actionSavings.reread_prices_available === false)) || cp.reread_prices_available === false ? '' :
|
|
4764
|
+
'<span>Repeat reads avoided <strong>~' + (exactCents ? moneyCents(exactCents.reread) : money(periodValue(rereadMo))) + '</strong></span>') +
|
|
4805
4765
|
'<span>Other estimates <strong>~' + (exactCents ? moneyCents(exactCents.other) : money(periodValue(estimatedMo))) + '</strong></span></div>' +
|
|
4766
|
+
(Number(routingRealizedMo) > 0
|
|
4767
|
+
? '<p class="plain-line"><strong>Model routing:</strong> ~' + money(periodValue(routingRealizedMo)) + esc(per) +
|
|
4768
|
+
' ' + esc(routingAssumption) + (currOpus ? ' (now ' + currOpus + '% Opus)' : '') + '. Not in this total.</p>' : '') +
|
|
4806
4769
|
(actionPricingIncomplete
|
|
4807
4770
|
? '<p class="plain-line">Some older history has no exact price, so this is a priced subtotal.</p>'
|
|
4808
4771
|
: (!cp.available ? '<p class="plain-line">Repeat reads are not available here. Logged actions are still counted.</p>' : '')) +
|
|
4809
|
-
(mr.evidence === 'pending'
|
|
4810
|
-
? '<p class="plain-line routing-pending">Model routing: re-measuring (' + Number(mr.pending_sessions || 0).toLocaleString() +
|
|
4811
|
-
' session' + (Number(mr.pending_sessions) === 1 ? '' : 's') + ' left). It is added to this total when the re-measurement finishes.</p>' : '') +
|
|
4812
4772
|
// Usage without a token-class split (Cursor totals, model-daily-only
|
|
4813
4773
|
// history, legacy rows) sits outside both routing arms. Say so instead of
|
|
4814
4774
|
// letting an empty or partial routing figure read as complete coverage.
|
|
@@ -4817,6 +4777,7 @@ var DB = (function() {
|
|
|
4817
4777
|
' tokens without a token-class split are left out of model routing.</p>' : '') +
|
|
4818
4778
|
fold('Breakdown and method',
|
|
4819
4779
|
countedList([
|
|
4780
|
+
s.token_type_breakdown && Object.keys(s.token_type_breakdown).length ? 'Token types cover only ledger events with recorded turn classes. Repeat reads are modeled as cache reads except for detected cache rebuilds; write totals include detected rebuilds and initial removals recorded at a write rate. Unclassified tokens are excluded.' : '',
|
|
4820
4781
|
'Includes the later benefit of context removed during this period. Initial removals are counted once.',
|
|
4821
4782
|
cp.reread_pricing_note ? esc(cp.reread_pricing_note) : '',
|
|
4822
4783
|
actionSavings && actionSavings.total_clamped ? 'Signed adjustments give a net total of ' +
|
|
@@ -4831,13 +4792,19 @@ var DB = (function() {
|
|
|
4831
4792
|
Math.round(Number(s.reprice_detail.unpriced_tokens)).toLocaleString() +
|
|
4832
4793
|
' logged tokens ran on models with no known rate; their dollar value is not included.' : '',
|
|
4833
4794
|
op.removal_events > 0 ? 'Initial removals above are priced at the input rate, a minimum.' +
|
|
4834
|
-
(
|
|
4835
|
-
?
|
|
4836
|
-
|
|
4837
|
-
|
|
4795
|
+
(actionSavings && 'class_premium_usd' in actionSavings
|
|
4796
|
+
? (Number(actionSavings.class_premium_usd) >= 0.005
|
|
4797
|
+
? ' The next call billed new context at a cache-write rate for ' +
|
|
4798
|
+
Math.round(Number(op.class_events) || 0).toLocaleString() + ' removals. That write-class premium, ' +
|
|
4799
|
+
(exactCents ? moneyCents(exactCents.premium) : money(periodValue(mo(actionSavings.class_premium_usd)))) +
|
|
4800
|
+
', is measured and included in Logged actions.' : '')
|
|
4801
|
+
: (Number(op.class_premium_usd) >= 0.005
|
|
4802
|
+
? ' The next call billed new context at a cache-write rate for ' +
|
|
4803
|
+
Math.round(Number(op.class_events) || 0).toLocaleString() + ' removals: about ' +
|
|
4804
|
+
money(Number(op.class_premium_usd)) + ' more, not in the total.' : '')) : '',
|
|
4838
4805
|
!cp.available ? 'Repeat-read coverage is unavailable here; logged actions are still included.' : ''
|
|
4839
4806
|
]) +
|
|
4840
|
-
'<p>Logged actions include output trims, context reductions
|
|
4807
|
+
'<p>Logged actions include output trims, context reductions and setup changes. ' +
|
|
4841
4808
|
'Prices may be allocated from each session’s recorded model mix.</p>' +
|
|
4842
4809
|
'<p>Repeat reads use recorded later turns up to each session’s next compaction. ' +
|
|
4843
4810
|
'This assumes the removed context would otherwise have stayed until that compaction. ' +
|
|
@@ -4852,7 +4819,10 @@ var DB = (function() {
|
|
|
4852
4819
|
((mr.baseline_reference_priced || []).length
|
|
4853
4820
|
? '<p>Routing compares your earlier and current mix on one price list, the newest card of each family (' +
|
|
4854
4821
|
esc(mr.baseline_reference_priced.map(function(f) { return f.charAt(0).toUpperCase() + f.slice(1); }).join(', ')) +
|
|
4855
|
-
'), because your earlier mix records no model generations.
|
|
4822
|
+
'), because your earlier mix records no model generations. It is shown separately from the totals above.</p>' : '') +
|
|
4823
|
+
(routingAltShare != null
|
|
4824
|
+
? '<p>Measured alternative: your earliest tracked month had ' + fmtPct(routingAltShare) + '% Opus' +
|
|
4825
|
+
(routingAltMo != null ? '; the same comparison gives ~' + money(periodValue(routingAltMo)) + esc(per) : '') + '.</p>' : '') +
|
|
4856
4826
|
(Math.abs(mo(mr.generation_price_delta_usd)) >= 0.01
|
|
4857
4827
|
? '<p>At the exact cards you ran, the same work cost about ' + money(Math.abs(mo(mr.generation_price_delta_usd))) +
|
|
4858
4828
|
(Number(mr.generation_price_delta_usd) > 0 ? ' more' : ' less') +
|
|
@@ -4880,27 +4850,36 @@ var DB = (function() {
|
|
|
4880
4850
|
var sia = (si && si.all_in) || null;
|
|
4881
4851
|
if (sia && Number(sia.total_usd) > 0) {
|
|
4882
4852
|
var siaParts = sia.components_usd || {};
|
|
4883
|
-
var siaRouting = (Number(siaParts.routing_measured) || 0) + (Number(siaParts.routing_estimated) || 0);
|
|
4853
|
+
var siaRouting = Number(sia.routing_usd) || ((Number(siaParts.routing_measured) || 0) + (Number(siaParts.routing_estimated) || 0));
|
|
4854
|
+
var siaRoutingNote = (sia.routing_baseline_provenance && sia.routing_baseline_provenance.short) ? String(sia.routing_baseline_provenance.short)
|
|
4855
|
+
: sia.routing_baseline_opus_share != null
|
|
4856
|
+
? ((sia.routing_baseline_source === 'stated' || sia.routing_baseline_source === 'pretool_baseline' ? 'assuming ' : 'against a measured ') +
|
|
4857
|
+
fmtPct(sia.routing_baseline_opus_share) + '% Opus' +
|
|
4858
|
+
(sia.routing_baseline_source === 'stated' || sia.routing_baseline_source === 'pretool_baseline' ? ' before Token Optimizer' : ' baseline'))
|
|
4859
|
+
: 'an estimate';
|
|
4884
4860
|
var siaPending = sia.routing_pending || sia.remeasuring;
|
|
4885
4861
|
var siaLeft = Math.max(Number(sia.routing_pending_sessions) || 0, Number(sia.remeasuring_sessions) || 0);
|
|
4886
4862
|
html += '<div class="card savings-history" style="flex:1;min-width:min(100%,260px);padding:var(--s-4);">' +
|
|
4887
4863
|
'<div class="label">Saved since ' + esc(prettyDate(si.install_date)) + '</div>' +
|
|
4888
4864
|
'<div class="savings-amount">' + money(sia.total_usd) +
|
|
4889
4865
|
(siaPending ? ' <span class="remeasuring-tag" style="font-size:0.45em;color:var(--c-text-dim);">so far</span>' : '') + '</div>' +
|
|
4890
|
-
(siaPending ? '<p class="plain-line remeasuring">
|
|
4866
|
+
(siaPending ? '<p class="plain-line remeasuring">Updating older history (' + siaLeft.toLocaleString() +
|
|
4891
4867
|
' session' + (siaLeft === 1 ? '' : 's') + ' left). This total will grow when they finish.</p>' : '') +
|
|
4892
|
-
'<p class="plain-line">Same
|
|
4868
|
+
'<p class="plain-line">Same parts as the monthly total, added up since install.</p>' +
|
|
4893
4869
|
fold('Breakdown and history',
|
|
4894
|
-
'<p>Model routing: <strong>' + money(siaRouting) + '</strong> (
|
|
4870
|
+
'<p>Model routing: <strong>' + money(siaRouting) + '</strong> (' + esc(siaRoutingNote) + '), not in the total above.</p>' +
|
|
4871
|
+
(sia.routing_measured_baseline_opus_share != null
|
|
4872
|
+
? '<p>Measured alternative: your earliest tracked month had ' + fmtPct(sia.routing_measured_baseline_opus_share) + '% Opus' +
|
|
4873
|
+
(sia.routing_measured_baseline_realized_cost_usd != null ? '; the same comparison gives ' + money(sia.routing_measured_baseline_realized_cost_usd) : '') + '.</p>' : '') +
|
|
4895
4874
|
(Number(sia.routing_unsplit_tokens) > 0
|
|
4896
4875
|
? '<p>' + Number(sia.routing_unsplit_tokens).toLocaleString() +
|
|
4897
4876
|
' tokens without a token-class split are left out of model routing.</p>' : '') +
|
|
4898
4877
|
'<p>Repeat reads avoided: <strong>' + money(siaParts.reread) + '</strong> (modeled).</p>' +
|
|
4899
|
-
'<p>Logged actions: <strong>' + money(siaParts.logged) + '</strong>.</p>' +
|
|
4878
|
+
'<p>Logged actions: <strong>' + money((Number(siaParts.logged) || 0) + (Number(siaParts.class_premium) || 0)) + '</strong>.</p>' +
|
|
4900
4879
|
'<p>Other estimates: <strong>' + money(sia.estimated_usd) + '</strong>.</p>' +
|
|
4901
|
-
((Number(cc.total_usd) > 0 || cc.available) ?
|
|
4880
|
+
((Number(cc.total_usd) > 0 || cc.available) && cc.prices_available !== false ?
|
|
4902
4881
|
'<p>Context trimming on its own (initial removals + repeat reads): ' +
|
|
4903
|
-
|
|
4882
|
+
money(Math.max(0, Number(cc.total_usd) || 0)) + '.</p>' : '') +
|
|
4904
4883
|
countedList([
|
|
4905
4884
|
cc.pricing_note ? esc(cc.pricing_note) : '',
|
|
4906
4885
|
cc.media_note ? esc(cc.media_note) : ''
|
|
@@ -4908,14 +4887,14 @@ var DB = (function() {
|
|
|
4908
4887
|
'<p>Tracked over ' + Number(si.days || 0).toLocaleString() + ' days. Historical entries remain after their source transcripts rotate.</p>' +
|
|
4909
4888
|
'<p>' + billingCaption + '</p>') +
|
|
4910
4889
|
'</div>';
|
|
4911
|
-
} else if (Number(cc.total_usd) > 0 || (cc.available && Number(cc.events) > 0)) {
|
|
4890
|
+
} else if (cc.prices_available !== false && (Number(cc.total_usd) > 0 || (cc.available && Number(cc.events) > 0))) {
|
|
4912
4891
|
html += '<div class="card savings-history" style="flex:1;min-width:min(100%,260px);padding:var(--s-4);">' +
|
|
4913
4892
|
'<div class="label">Context savings · all time</div>' +
|
|
4914
|
-
'<div class="savings-amount">' +
|
|
4893
|
+
'<div class="savings-amount">' + money(Math.max(0, Number(cc.total_usd) || 0)) +
|
|
4915
4894
|
(cc.remeasuring ? ' <span class="remeasuring-tag" style="font-size:0.45em;color:var(--c-text-dim);">so far</span>' : '') + '</div>' +
|
|
4916
|
-
(cc.remeasuring ? '<p class="plain-line remeasuring">
|
|
4895
|
+
(cc.remeasuring ? '<p class="plain-line remeasuring">Updating history (' + Number(cc.remeasuring_sessions || 0).toLocaleString() +
|
|
4917
4896
|
' session' + (Number(cc.remeasuring_sessions) === 1 ? '' : 's') + ' left). This subtotal is in progress and will change when they finish.</p>' : '') +
|
|
4918
|
-
'<p class="plain-line">' + (cp.available
|
|
4897
|
+
'<p class="plain-line">' + (cp.available && cp.prices_available !== false ? '<strong>' + money(cp.total_usd) + '</strong> from removals in the last ' + days + ' days. ' : '') +
|
|
4919
4898
|
'Overlaps with action savings.</p>' +
|
|
4920
4899
|
fold('History and coverage',
|
|
4921
4900
|
countedList([
|
|
@@ -4925,8 +4904,8 @@ var DB = (function() {
|
|
|
4925
4904
|
Number(cc.total_usd) < 0 ? 'Signed net: ' + money(cc.total_usd) + '. Savings headline is floored at zero.' : '',
|
|
4926
4905
|
'Excludes routing, setup and other estimates.'
|
|
4927
4906
|
]) +
|
|
4928
|
-
|
|
4929
|
-
|
|
4907
|
+
(cc.oneshot_prices_available === false ? '' : '<p>' + money(cc.oneshot_usd) + ' initial removals.</p>') +
|
|
4908
|
+
(cc.reread_prices_available === false ? '' : '<p>' + money(cc.reread_usd) + ' modeled repeat reads.</p>') +
|
|
4930
4909
|
'<p>Stored history since ' + esc(prettyDate(cc.window_start)) + '. ' +
|
|
4931
4910
|
'Same removal-date method as the period total. Historical entries remain after their source transcripts rotate.</p>' +
|
|
4932
4911
|
'<p>Repeat reads assume the removed context would otherwise have stayed until the session’s next compaction. ' +
|
|
@@ -4943,30 +4922,43 @@ var DB = (function() {
|
|
|
4943
4922
|
}
|
|
4944
4923
|
html += '</div>';
|
|
4945
4924
|
html += fold('Token savings and model usage', tokensSavedCardHtml(s));
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
if (
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4925
|
+
var ledgerHtml = html;
|
|
4926
|
+
html = storyHead + (story ? '' : ledgerHtml);
|
|
4927
|
+
|
|
4928
|
+
// ---- SAVE MORE: the parts list was built before the story render (see
|
|
4929
|
+
// above); story mode already folded it into "Still on the table". ----
|
|
4930
|
+
var moreFolds = [];
|
|
4931
|
+
if (story) {
|
|
4932
|
+
// U9: nothing else on the tab. Coverage detail, the previous cards and
|
|
4933
|
+
// diagnostics sit in one row of folds at the bottom; the
|
|
4934
|
+
// whole-workload comparison is no longer shown here.
|
|
4935
|
+
var covFold = (typeof savingsCoverageFold === 'function') ? savingsCoverageFold(data) : '';
|
|
4936
|
+
if (covFold) moreFolds.push(covFold);
|
|
4937
|
+
// F13 merged "Room to save more" into the Still-on-the-table fold. When
|
|
4938
|
+
// that card does not render (nothing sized), the parts still need a home:
|
|
4939
|
+
// keep them as their own fold rather than dropping the copy entirely.
|
|
4940
|
+
if (parts.length > 0 && story.indexOf('st-table') === -1) {
|
|
4941
|
+
moreFolds.push('<details class="fold"><summary>More changes you could make</summary><div class="fold__body">' +
|
|
4942
|
+
'<p>More changes to your setup or habits. None of this is in any total above.</p>' +
|
|
4943
|
+
parts.map(function(p) { return '<p>' + esc(p) + '</p>'; }).join('') +
|
|
4944
|
+
(data.runtime !== 'cursor' && data.runtime !== 'antigravity'
|
|
4945
|
+
? '<p>Run <strong>/token-optimizer</strong> and follow its suggestions to claim it.</p>' : '') +
|
|
4946
|
+
'</div></details>');
|
|
4947
|
+
}
|
|
4948
|
+
// The previous action-savings, since-install and Tokens Saved cards are not
|
|
4949
|
+
// shown in story mode: they still add routing to their totals and count
|
|
4950
|
+
// tokens on another basis, so they would contradict the hero.
|
|
4951
|
+
var ledgerBody = (typeof savingsLedgerHtml === 'function') ? savingsLedgerHtml(data) : ledgerHtml;
|
|
4952
|
+
var mixTotal = 0, mix = (data.trends && data.trends.model_mix) || {};
|
|
4953
|
+
for (var mixK in mix) { mixTotal += Number(mix[mixK]) || 0; }
|
|
4954
|
+
if (mixTotal > 0 && typeof modelMixBodyHtml === 'function') ledgerBody += '<h3 class="ts-section-label st-gap">Which models did the work</h3>' + modelMixBodyHtml(mix, data.runtime === 'codex', mixTotal);
|
|
4955
|
+
moreFolds.push('<details class="fold"><summary>Full ledger and history</summary><div class="fold__body">' + ledgerBody + '</div></details>');
|
|
4956
|
+
} else if (parts.length > 0) {
|
|
4965
4957
|
html += '<div class="card wide" style="padding:var(--s-5) var(--s-4);margin-bottom:var(--s-3);border:1px solid var(--c-amber);box-shadow:0 0 0 1px rgba(217,164,65,0.18), 0 0 44px rgba(217,164,65,0.12);">';
|
|
4966
|
-
html += '<div class="label" style="margin-bottom:var(--s-2);color:var(--c-
|
|
4958
|
+
html += '<div class="label" style="margin-bottom:var(--s-2);color:var(--c-text-dim);">Money on the table · opportunity</div>';
|
|
4967
4959
|
if (opportunityMo > 0) {
|
|
4968
4960
|
html += '<div style="display:flex;align-items:baseline;gap:var(--s-2);flex-wrap:wrap;">' +
|
|
4969
|
-
'<span style="font-family:var(--font-mono);font-weight:300;font-size:76px;line-height:0.9;color:var(--c-
|
|
4961
|
+
'<span style="font-family:var(--font-mono);font-weight:300;font-size:76px;line-height:0.9;color:var(--c-text-main);text-shadow:0 0 30px rgba(217,164,65,0.5);letter-spacing:-0.02em;">' + moneyCents(oppCents.total) + '</span>' +
|
|
4970
4962
|
'<span style="font-size:23px;color:var(--c-text-dim);font-family:var(--font-mono);">' + per + ' still on the table</span>' +
|
|
4971
4963
|
'</div>';
|
|
4972
4964
|
html += '<div class="lede" style="margin-top:var(--s-2);">Potential savings if you change your setup or habits. Excluded from the totals above.</div>';
|
|
@@ -4975,16 +4967,16 @@ var DB = (function() {
|
|
|
4975
4967
|
}
|
|
4976
4968
|
if (cdTokensMo > 0) {
|
|
4977
4969
|
html += '<div class="cache-drop-opportunity" style="margin-top:var(--s-3);font-family:var(--font-mono);font-size:17px;line-height:1.6;color:var(--c-text-main);max-width:820px;">' +
|
|
4978
|
-
'Cache drops (an opportunity, not a measurement): ' + (Number(cd.drop_sessions) || 0) + ' sessions idled past
|
|
4979
|
-
(cdCostMo > 0 ? ', about <span style="color:var(--c-
|
|
4970
|
+
'Cache drops (an opportunity, not a measurement): ' + (Number(cd.drop_sessions) || 0) + ' sessions idled past ' + cdCacheName + ' and re-wrote ~' + fmtTok(cdTokensMo) + ' tokens' + esc(per) + ' of prefix' +
|
|
4971
|
+
(cdCostMo > 0 ? ', about <span style="color:var(--c-text-main);font-weight:600;">' + money(cdCostMo) + esc(per) + '</span> at API rates' : '') + '.' +
|
|
4980
4972
|
'</div>';
|
|
4981
4973
|
html += '<div class="plain-line">Not part of the savings number above.</div>';
|
|
4982
|
-
html += fold('How the cache drop figure is priced', '<p>
|
|
4974
|
+
html += fold('How the cache drop figure is priced', '<p>Each rebuild is the prefix the cache had held before the gap, priced at its own cache write rate (1 hour or 5 minutes) minus the cache read it would have cost, at the models you ran and at API rates. It is not part of the number above.</p>' + ((Number(cd.unscanned_large_sessions) || 0) > 0 ? '<p>' + Number(cd.unscanned_large_sessions) + ' very large session' + (Number(cd.unscanned_large_sessions) === 1 ? ' was' : 's were') + ' not scanned; savings there are understated.</p>' : ''));
|
|
4983
4975
|
}
|
|
4984
4976
|
if (routingPotentialMo > 0) {
|
|
4985
4977
|
html += '<div class="routing-assumption" style="margin-top:var(--s-3);font-family:var(--font-mono);font-size:17px;line-height:1.6;color:var(--c-text-main);max-width:820px;">' +
|
|
4986
4978
|
'Routing (an assumption, not a measurement): if about ' + routingFracPct + '% of your Opus work (grunt tasks) ran on ' + esc(routingTarget) + ': new input and output only' +
|
|
4987
|
-
(mo(mr.potential_unsplit_excluded_tokens) > 0 ? ' (~' + fmtTok(mo(mr.potential_unsplit_excluded_tokens)) + ' Opus tokens' + esc(per) + ' without a class split are left out)' : '') + ', about <span style="color:var(--c-
|
|
4979
|
+
(mo(mr.potential_unsplit_excluded_tokens) > 0 ? ' (~' + fmtTok(mo(mr.potential_unsplit_excluded_tokens)) + ' Opus tokens' + esc(per) + ' without a class split are left out)' : '') + ', about <span style="color:var(--c-text-main);font-weight:600;">' + money(routingPotentialMo) + esc(per) + '</span> at API rates.' +
|
|
4988
4980
|
(routingTokensMo > 0 ? ' ~' + fmtTok(routingTokensMo) + ' tokens' + esc(per) + '.' : '') +
|
|
4989
4981
|
'</div>';
|
|
4990
4982
|
html += '<div class="plain-line">An assumption about your own work, not a measured saving, and not part of the number above.</div>';
|
|
@@ -5009,11 +5001,11 @@ var DB = (function() {
|
|
|
5009
5001
|
html += '<p>' + billingCaption + '</p>';
|
|
5010
5002
|
parts.forEach(function(p, i){
|
|
5011
5003
|
html += '<div style="display:flex;gap:var(--s-3);align-items:flex-start;">' +
|
|
5012
|
-
'<div style="flex-shrink:0;width:34px;height:34px;border-radius:50%;border:1.5px solid var(--c-amber);background:rgba(217,164,65,0.08);display:flex;align-items:center;justify-content:center;font-family:var(--font-mono);font-size:16px;color:var(--c-
|
|
5004
|
+
'<div style="flex-shrink:0;width:34px;height:34px;border-radius:50%;border:1.5px solid var(--c-amber);background:rgba(217,164,65,0.08);display:flex;align-items:center;justify-content:center;font-family:var(--font-mono);font-size:16px;color:var(--c-text-main);margin-top:2px;">' + (i+1) + '</div>' +
|
|
5013
5005
|
'<div style="font-size:18px;color:var(--c-text-main);line-height:1.7;max-width:760px;">' + esc(p) + '</div></div>';
|
|
5014
5006
|
});
|
|
5015
5007
|
html += '</div>';
|
|
5016
|
-
if (data.runtime !== 'cursor' && data.runtime !== 'antigravity') html += '<div style="margin-top:var(--s-5);padding:var(--s-4);background:rgba(217,164,65,0.07);border:1px solid var(--c-amber);border-radius:10px;font-family:var(--font-mono);font-size:17px;line-height:1.6;color:var(--c-text-main);font-weight:500;">Run <span style="color:var(--c-
|
|
5008
|
+
if (data.runtime !== 'cursor' && data.runtime !== 'antigravity') html += '<div style="margin-top:var(--s-5);padding:var(--s-4);background:rgba(217,164,65,0.07);border:1px solid var(--c-amber);border-radius:10px;font-family:var(--font-mono);font-size:17px;line-height:1.6;color:var(--c-text-main);font-weight:500;">Run <span style="color:var(--c-accent-cyan);">/token-optimizer</span> and follow its suggestions to claim the rest →</div>';
|
|
5017
5009
|
html += '</details></div>';
|
|
5018
5010
|
}
|
|
5019
5011
|
|
|
@@ -5040,7 +5032,7 @@ var DB = (function() {
|
|
|
5040
5032
|
trendTxt = dd > 3 ? 'trending up' : (dd < -3 ? 'trending down' : 'holding steady');
|
|
5041
5033
|
}
|
|
5042
5034
|
}
|
|
5043
|
-
if (avgQ !== null) {
|
|
5035
|
+
if (avgQ !== null && !story) {
|
|
5044
5036
|
var barPct = Math.min(100, Math.max(0, avgQ));
|
|
5045
5037
|
html += '<div class="card wide" style="margin-top:var(--s-3);"><div class="card-header"><span>Context quality · 30-day average</span>' +
|
|
5046
5038
|
(trendTxt ? '<span class="label">' + esc(trendTxt) + '</span>' : '') + '</div>';
|
|
@@ -5086,44 +5078,13 @@ var DB = (function() {
|
|
|
5086
5078
|
bucket.forEach(function(e) { ccHtml += covRow(e); });
|
|
5087
5079
|
ccHtml += '</div>';
|
|
5088
5080
|
});
|
|
5089
|
-
|
|
5090
|
-
if (pr) {
|
|
5091
|
-
var ready = pr.promotion_ready;
|
|
5092
|
-
ccHtml += '<div style="margin-top:var(--s-3);padding-top:var(--s-2);border-top:1px solid rgba(255,255,255,0.08);">' +
|
|
5093
|
-
'<div style="font-weight:500;">First-read skeleton — safety check</div>' +
|
|
5094
|
-
'<div class="plain-line">' + (Number(pr.edits_after_read) || 0) + ' of ' + (Number(pr.shadow_reads) || 0) +
|
|
5095
|
-
' large files were edited soon after the read (' + (Number(pr.edit_rate_pct) || 0).toFixed(1) + '%). ' +
|
|
5096
|
-
'Currently <strong>' + (ready ? 'ready to promote' : 'still measuring') + '</strong>.</div>' +
|
|
5097
|
-
fold('How this check works', '<p>' +
|
|
5098
|
-
'Of ' + (Number(pr.shadow_reads) || 0) + ' large files where a skeleton would have saved tokens, ' +
|
|
5099
|
-
(Number(pr.edits_after_read) || 0) + ' were edited soon after the read — an edit rate of ' +
|
|
5100
|
-
'<span style="font-family:var(--font-mono);color:' + (ready ? 'var(--c-accent-cyan)' : 'var(--c-text-main)') + ';">' + (Number(pr.edit_rate_pct) || 0).toFixed(1) + '%</span>. ' +
|
|
5101
|
-
'Skeletons turn on automatically only once this stays under ' + (Number(pr.promotion_gate_pct) || 15) + '% (the model rarely needed the full file).</p>') +
|
|
5102
|
-
'</div>';
|
|
5103
|
-
}
|
|
5104
|
-
// Runtime tripwire: per-cohort LIVE edit-rate + any auto-demotions.
|
|
5081
|
+
// Existing demotions remain until explicitly reviewed.
|
|
5105
5082
|
var tw = cc.cohort_tripwire || {};
|
|
5106
|
-
var twCohorts = tw.cohorts || [];
|
|
5107
5083
|
var twDemoted = tw.demoted || [];
|
|
5108
|
-
if (
|
|
5084
|
+
if (twDemoted.length) {
|
|
5109
5085
|
ccHtml += '<div style="margin-top:var(--s-3);padding-top:var(--s-2);border-top:1px solid rgba(255,255,255,0.08);">' +
|
|
5110
|
-
'<div style="font-weight:500;">
|
|
5111
|
-
fold('How
|
|
5112
|
-
twCohorts.forEach(function(c) {
|
|
5113
|
-
var dem = !!c.demoted;
|
|
5114
|
-
// T9: interpolated cohorts (promoted on a thin sample via an adjacent
|
|
5115
|
-
// passing band) carry a higher exposure risk — label them so the
|
|
5116
|
-
// edit-rate is read with that context.
|
|
5117
|
-
var interp = c.basis === 'interpolated';
|
|
5118
|
-
ccHtml += '<div style="display:flex;justify-content:space-between;gap:var(--s-3);padding:4px 0;' + (dem ? 'opacity:0.72;' : '') + '">' +
|
|
5119
|
-
'<span>' + esc(String(c.language)) + ' · ' + esc(String(c.band)) +
|
|
5120
|
-
(interp ? ' <span title="Promoted on a thin sample because an adjacent size band of the same language passed the full gate. Higher exposure; tighter tripwire floor." style="font-size:11px;color:var(--c-text-dim);border:1px solid var(--c-border-strong, rgba(255,255,255,0.2));border-radius:4px;padding:1px 5px;">interpolated</span>' : '') +
|
|
5121
|
-
(dem ? ' <span style="font-size:11px;color:var(--c-warning);border:1px solid rgba(230,162,60,0.4);border-radius:4px;padding:1px 5px;">demoted</span>' : '') + '</span>' +
|
|
5122
|
-
'<span style="font-family:var(--font-mono);color:var(--c-text-dim);">' +
|
|
5123
|
-
(Number(c.skeletons) || 0) + ' reads · ' + (Number(c.followups) || 0) + ' edits · ' +
|
|
5124
|
-
(Number(c.edit_rate_pct) || 0).toFixed(1) + '%</span>' +
|
|
5125
|
-
'</div>';
|
|
5126
|
-
});
|
|
5086
|
+
'<div style="font-weight:500;">First-read cohorts</div>' +
|
|
5087
|
+
fold('How this works', '<p>Existing demotions stay in place. Outcome comparisons run in shadow and do not automatically promote or demote cohorts.</p>');
|
|
5127
5088
|
if (twDemoted.length) {
|
|
5128
5089
|
var demStr = twDemoted.map(function(c) { return esc(String(c[0])) + ':' + esc(String(c[1])); }).join(', ');
|
|
5129
5090
|
ccHtml += '<div style="font-size:13px;color:var(--c-text-dim);margin-top:4px;">' +
|
|
@@ -5133,7 +5094,8 @@ var DB = (function() {
|
|
|
5133
5094
|
ccHtml += '</div>';
|
|
5134
5095
|
}
|
|
5135
5096
|
ccHtml += '</div>';
|
|
5136
|
-
|
|
5097
|
+
if (story) moreFolds.push('<details class="fold"><summary>Compression coverage (diagnostic)</summary><div class="fold__body">' + ccHtml + '</div></details>');
|
|
5098
|
+
else html += ccHtml;
|
|
5137
5099
|
}
|
|
5138
5100
|
|
|
5139
5101
|
// ---- Cache Health: TTL-expiry watchdog (opportunity tier). Observed
|
|
@@ -5218,89 +5180,9 @@ var DB = (function() {
|
|
|
5218
5180
|
chHtml += '</div>';
|
|
5219
5181
|
if (!CACHE_HEALTH_HIDDEN) html += chHtml;
|
|
5220
5182
|
|
|
5221
|
-
|
|
5222
|
-
// In probe-only mode it renders $0 realized / $0 spend / $0 NET, which reads
|
|
5223
|
-
// as "zero value" / broken to users. The keepwarm data is still computed
|
|
5224
|
-
// (measure.py keepwarm_cache_health_block) and carried in
|
|
5225
|
-
// data.cache_health.keepwarm; restore the panel by reverting this hunk.
|
|
5226
|
-
var kw = null;
|
|
5227
|
-
if (kw) {
|
|
5228
|
-
var kwState = kw.state || 'platform-gap';
|
|
5229
|
-
var kwBadge = ({
|
|
5230
|
-
'active-probe': 'probe-only · active',
|
|
5231
|
-
'active-sustain': 'sustain · active',
|
|
5232
|
-
'off-subscription': 'off · subscription',
|
|
5233
|
-
'demoted-by-tripwire': 'off · tripwire',
|
|
5234
|
-
'platform-gap': 'platform gap'
|
|
5235
|
-
})[kwState] || kwState;
|
|
5236
|
-
var kwHtml = '<div class="card wide" style="margin-top:var(--s-3);"><div class="card-header">' +
|
|
5237
|
-
'<span>Keep-warm cache automation</span>' +
|
|
5238
|
-
'<span class="label" style="border:1px solid rgba(255,255,255,0.12);border-radius:4px;padding:1px 5px;">' + esc(kwBadge) + '</span>' +
|
|
5239
|
-
'</div>';
|
|
5240
|
-
if (kwState === 'platform-gap') {
|
|
5241
|
-
kwHtml += '<div style="margin-top:var(--s-2);font-size:13px;color:var(--c-text-dim);line-height:1.6;">' +
|
|
5242
|
-
esc(kw.note || 'Keep-warm ships for Claude Code only.') + '</div>';
|
|
5243
|
-
} else if (kwState === 'off-subscription') {
|
|
5244
|
-
kwHtml += '<div style="margin-top:var(--s-2);font-size:13px;color:var(--c-text-dim);line-height:1.6;">' +
|
|
5245
|
-
esc(kw.honest_line || 'Keep-warm is off on subscription billing: pings spend quota and recover no write premium.') + '</div>';
|
|
5246
|
-
} else {
|
|
5247
|
-
if (kwState === 'demoted-by-tripwire') {
|
|
5248
|
-
kwHtml += '<div style="margin-top:var(--s-2);font-size:13px;color:var(--c-amber, #d9a441);line-height:1.6;">' +
|
|
5249
|
-
'Auto-demoted to OFF by the tripwire (rolling 7d realized/spend ≤ 1.0). Re-enable with keepwarm-enable to reset the ladder.</div>';
|
|
5250
|
-
}
|
|
5251
|
-
// Realized vs spend vs NET (30d) — NET prominent.
|
|
5252
|
-
var net = Number(kw.net_usd) || 0;
|
|
5253
|
-
var netColor = net >= 0 ? 'var(--c-savings, #4ade80)' : 'var(--c-waste, #f87171)';
|
|
5254
|
-
kwHtml += '<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:var(--s-3);margin-top:var(--s-2);">' +
|
|
5255
|
-
'<div><div style="font-size:12px;color:var(--c-text-dim);">Realized (30d)</div>' +
|
|
5256
|
-
'<div style="font-family:var(--font-mono);font-size:20px;">$' + (Number(kw.realized_usd) || 0).toFixed(2) + '</div></div>' +
|
|
5257
|
-
'<div><div style="font-size:12px;color:var(--c-text-dim);">Ping spend (30d)</div>' +
|
|
5258
|
-
'<div style="font-family:var(--font-mono);font-size:20px;color:var(--c-text-dim);">$' + (Number(kw.spend_usd) || 0).toFixed(2) + '</div></div>' +
|
|
5259
|
-
'<div><div style="font-size:12px;color:var(--c-text-dim);">NET (30d)</div>' +
|
|
5260
|
-
'<div style="font-family:var(--font-mono);font-size:20px;color:' + netColor + ';">$' + net.toFixed(2) + '</div></div>' +
|
|
5261
|
-
'<div><div style="font-size:12px;color:var(--c-text-dim);">Tripwire ratio (7d)</div>' +
|
|
5262
|
-
'<div style="font-family:var(--font-mono);font-size:20px;">' + (kw.tripwire_ratio_7d == null ? 'n/a' : (Number(kw.tripwire_ratio_7d)).toFixed(2)) + '</div></div>' +
|
|
5263
|
-
'</div>';
|
|
5264
|
-
if (!kw.has_pings) {
|
|
5265
|
-
kwHtml += '<div style="margin-top:var(--s-2);font-size:12px;color:var(--c-text-dim);">No keep-warm pings yet — numbers fill in once an eligible paused session is probe-refreshed.</div>';
|
|
5266
|
-
}
|
|
5267
|
-
// Health signal.
|
|
5268
|
-
var hh = kw.health || {};
|
|
5269
|
-
if (Number(hh.total_pings) > 0) {
|
|
5270
|
-
kwHtml += '<div style="margin-top:var(--s-2);font-size:12px;color:' + (hh.alarm ? 'var(--c-waste, #f87171)' : 'var(--c-text-dim)') + ';">' +
|
|
5271
|
-
'Pings on never-resumed pauses: ' + (Number(hh.pings_on_never_resumed) || 0) + '/' + (Number(hh.total_pings) || 0) +
|
|
5272
|
-
' (' + Math.round((Number(hh.fraction) || 0) * 100) + '%)' + (hh.alarm ? ' — ALARM (>50%)' : '') + '</div>';
|
|
5273
|
-
}
|
|
5274
|
-
// Predictor transparency (feature names; relevant when sustain activates).
|
|
5275
|
-
var feats = kw.predictor_features || [];
|
|
5276
|
-
if (kwState === 'active-sustain' && feats.length) {
|
|
5277
|
-
kwHtml += '<div style="margin-top:var(--s-2);font-size:12px;color:var(--c-text-dim);line-height:1.5;">' +
|
|
5278
|
-
'Sustain predictor (threshold ' + (Number(kw.predictor_threshold) || 0).toFixed(2) + '): ' +
|
|
5279
|
-
feats.map(function(f) { return esc(f); }).join(', ') + '</div>';
|
|
5280
|
-
}
|
|
5281
|
-
// Top sessions by realized.
|
|
5282
|
-
var ts2 = kw.top_sessions || [];
|
|
5283
|
-
if (ts2.length) {
|
|
5284
|
-
kwHtml += '<div style="margin-top:var(--s-3);"><div style="font-size:12px;color:var(--c-text-dim);margin-bottom:6px;">Top sessions by realized</div>' +
|
|
5285
|
-
'<table style="width:100%;border-collapse:collapse;font-size:12px;">' +
|
|
5286
|
-
'<thead><tr style="color:var(--c-text-dim);text-align:left;">' +
|
|
5287
|
-
'<th style="padding:4px 6px;">Session</th><th style="padding:4px 6px;">Realized $</th>' +
|
|
5288
|
-
'<th style="padding:4px 6px;">Spend $</th><th style="padding:4px 6px;">Pings</th></tr></thead><tbody>';
|
|
5289
|
-
ts2.forEach(function(t) {
|
|
5290
|
-
kwHtml += '<tr style="border-top:1px solid rgba(255,255,255,0.06);">' +
|
|
5291
|
-
'<td style="padding:4px 6px;font-family:var(--font-mono);">' + esc(String(t.session_id || '').slice(0, 28)) + '</td>' +
|
|
5292
|
-
'<td style="padding:4px 6px;font-family:var(--font-mono);">$' + (Number(t.realized_usd) || 0).toFixed(2) + '</td>' +
|
|
5293
|
-
'<td style="padding:4px 6px;font-family:var(--font-mono);color:var(--c-text-dim);">$' + (Number(t.spend_usd) || 0).toFixed(2) + '</td>' +
|
|
5294
|
-
'<td style="padding:4px 6px;font-family:var(--font-mono);">' + (Number(t.pings) || 0) + '</td></tr>';
|
|
5295
|
-
});
|
|
5296
|
-
kwHtml += '</tbody></table></div>';
|
|
5297
|
-
}
|
|
5298
|
-
}
|
|
5299
|
-
kwHtml += '</div>';
|
|
5300
|
-
html += kwHtml;
|
|
5301
|
-
}
|
|
5183
|
+
if (moreFolds.length) html += '<div class="st-morerow">' + moreFolds.join('') + '</div>';
|
|
5302
5184
|
|
|
5303
|
-
el.innerHTML = html;
|
|
5185
|
+
if (el.classList && el.dataset) { el.classList.toggle('st-enter', !el.dataset.storyRendered); el.dataset.storyRendered = '1'; } el.innerHTML = html;
|
|
5304
5186
|
el.querySelectorAll('details > summary').forEach(function(summary) {
|
|
5305
5187
|
if (openFolds.indexOf(summary.textContent) >= 0) summary.parentElement.open = true;
|
|
5306
5188
|
});
|
|
@@ -5314,27 +5196,41 @@ var DB = (function() {
|
|
|
5314
5196
|
|
|
5315
5197
|
var ts = data.generated_at ? new Date(data.generated_at).toLocaleString() : 'unknown';
|
|
5316
5198
|
var html = '<div class="section-header">' +
|
|
5317
|
-
'<div class="label">Analytics</div>' +
|
|
5318
5199
|
'<h1>Session Health</h1>' +
|
|
5319
|
-
'<p>Running sessions
|
|
5200
|
+
'<p>Running sessions and context quality.</p>' +
|
|
5320
5201
|
'</div>' +
|
|
5321
5202
|
'<div class="last-updated">Last updated: ' + esc(ts) + '</div>';
|
|
5322
5203
|
|
|
5204
|
+
// The keep-warm card is cut from Health (section 5): its paused-state
|
|
5205
|
+
// detail lives as one line in Manage. The coverage funnel renders only
|
|
5206
|
+
// when the counters were actually read — a card that says it has nothing
|
|
5207
|
+
// to say is hidden.
|
|
5323
5208
|
if (!h) {
|
|
5324
5209
|
html += '<div class="empty-state">No health data available. This usually means no ' + esc(data.runtime_label || 'Claude Code') + ' processes are currently running.</div>';
|
|
5210
|
+
try { if (typeof featureHealthHtml === 'function') html += featureHealthHtml(data); } catch (e) {}
|
|
5211
|
+
try {
|
|
5212
|
+
var cfData = data.coverage_funnel;
|
|
5213
|
+
if (cfData && cfData.available && typeof coverageFunnelHtml === 'function') html += coverageFunnelHtml(data);
|
|
5214
|
+
} catch (e) {}
|
|
5215
|
+
try { if (typeof holdoutHtml === 'function') html += holdoutHtml(data); } catch (e) {}
|
|
5325
5216
|
el.innerHTML = html;
|
|
5326
5217
|
return;
|
|
5327
5218
|
}
|
|
5328
5219
|
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
'<div class="label">' + esc(data.runtime_label || 'Claude Code') + '</div></div>';
|
|
5333
|
-
} else {
|
|
5220
|
+
// The "Installed Version" card is cut (section 5): one line in the
|
|
5221
|
+
// sessions context is enough; the version lives in the footer.
|
|
5222
|
+
if (isCodex) {
|
|
5334
5223
|
html += '<div class="card wide"><div class="card-header"><span>Codex Health</span><span class="label">local session logs</span></div>' +
|
|
5335
5224
|
'<p style="font-size:13px;color:var(--c-text-dim);margin-bottom:0;">Codex process version comparison is not exposed reliably in local session data, so version/outdated rows are hidden. This tab focuses on running sessions, hook health, and context quality.</p></div>';
|
|
5336
5225
|
}
|
|
5337
5226
|
|
|
5227
|
+
// Archive replacement self-check (scripts/archive_verify.py)
|
|
5228
|
+
var arc = data.archive_replacement_check;
|
|
5229
|
+
if (arc && arc.status === 'warning') {
|
|
5230
|
+
html += '<div class="card wide" style="background:rgba(239,68,68,0.08);border:1px solid rgba(239,68,68,0.2)"><div class="card-header"><span>Tool archive not applied</span><span class="label">' + esc(String(arc.full_streak)) + ' in a row</span></div>' +
|
|
5231
|
+
'<p style="font-size:13px;line-height:1.5;margin-bottom:0;">' + esc(arc.message || '') + '</p></div>';
|
|
5232
|
+
}
|
|
5233
|
+
|
|
5338
5234
|
// Running sessions table
|
|
5339
5235
|
var sessions = h.running_sessions || [];
|
|
5340
5236
|
html += '<div class="card wide"><div class="card-header"><span>Running Sessions</span><span class="label">' + sessions.length + ' active</span></div>';
|
|
@@ -5413,49 +5309,47 @@ var DB = (function() {
|
|
|
5413
5309
|
}
|
|
5414
5310
|
html += '</div>';
|
|
5415
5311
|
|
|
5416
|
-
// Automated
|
|
5312
|
+
// The "Automated Processes" card is cut (section 5): two launchd labels
|
|
5313
|
+
// with a zero in front, no reader, no action.
|
|
5417
5314
|
var automated = h.automated || [];
|
|
5418
|
-
if (automated.length > 0) {
|
|
5419
|
-
html += '<div class="card wide"><div class="card-header"><span>Automated Processes</span><span class="label">' + automated.length + ' found</span></div>';
|
|
5420
|
-
automated.forEach(function(proc) {
|
|
5421
|
-
html += '<div style="font-family:var(--font-mono);font-size:13px;color:var(--c-text-dim);padding:4px 0;border-bottom:1px solid var(--c-border);">' + esc(proc) + '</div>';
|
|
5422
|
-
});
|
|
5423
|
-
html += '</div>';
|
|
5424
|
-
}
|
|
5425
5315
|
|
|
5426
5316
|
// Context Quality Gauge (v2.0)
|
|
5427
5317
|
var q = data.quality;
|
|
5428
5318
|
if (q && typeof q.score === 'number') {
|
|
5429
5319
|
var qs = q.score;
|
|
5430
5320
|
var qColor = qs >= 85 ? 'var(--c-accent-cyan)' : qs >= 70 ? 'var(--c-chart-teal, #4ecdc4)' : qs >= 50 ? 'var(--c-warning, #ff9f43)' : 'var(--c-chart-coral, #ff6b6b)';
|
|
5321
|
+
// Section 6: warm colour stays on non-text marks; score, band and drag
|
|
5322
|
+
// labels are ink.
|
|
5323
|
+
var qInk = 'var(--c-text-main)';
|
|
5431
5324
|
var qBand = qs >= 85 ? 'Excellent' : qs >= 70 ? 'Good' : qs >= 50 ? 'Degraded' : 'Critical';
|
|
5432
5325
|
var sessionFile = q.session_file ? q.session_file.replace(/.*\//, '') : null;
|
|
5433
5326
|
var runtimeLabel = q.runtime_label || data.runtime_label || 'Claude Code';
|
|
5434
5327
|
var estimateNote = q.estimated ? ' Some Codex quality signals are inferred from local session events and should be read as an operational estimate, not model self-evaluation.' : '';
|
|
5435
5328
|
html += '<div class="card wide"><div class="card-header"><span>Context quality · latest session</span><span class="label">v2.0</span></div>' +
|
|
5436
|
-
'<div style="padding:8px var(--s-3) 0;font-size:12px;color:var(--c-text-dim);">This score measures your most recently active ' + esc(runtimeLabel) + ' session, not an average across sessions. It reflects context quality based on 7 signals.' + estimateNote + '
|
|
5329
|
+
'<div style="padding:8px var(--s-3) 0;font-size:12px;color:var(--c-text-dim);">This score measures your most recently active ' + esc(runtimeLabel) + ' session, not an average across sessions. It reflects context quality based on 7 signals.' + estimateNote + ' For the rolling cross-session average, see the Savings tab.</div>' +
|
|
5437
5330
|
(sessionFile ? '<div style="padding:4px var(--s-3) 0;font-size:13px;color:var(--c-text-dim);">Session: <code style="font-family:var(--font-mono);color:var(--c-text-main);">' + esc(sessionFile) + '</code><span style="margin-left:8px;color:var(--c-text-dim);font-size:12px;">(most recently active)</span></div>' : '') +
|
|
5438
5331
|
'<div style="text-align:center;padding:var(--s-3) 0;">' +
|
|
5439
|
-
'<div style="font-size:56px;font-weight:700;font-family:var(--font-mono);color:' +
|
|
5440
|
-
'<div class="label" style="font-size:16px;color:' +
|
|
5332
|
+
'<div style="font-size:56px;font-weight:700;font-family:var(--font-mono);color:' + qInk + ';text-shadow:0 0 15px ' + qColor + '55;">' + qs + '</div>' +
|
|
5333
|
+
'<div class="label" style="font-size:16px;color:' + qInk + ';">' + qBand + '</div>' +
|
|
5441
5334
|
'</div>' +
|
|
5442
5335
|
// Biggest drag: the actual weighted deficit (fill / compactions /
|
|
5443
5336
|
// dominant waste), computed upstream — not inferred from waste keys.
|
|
5444
5337
|
(q.top_drag && q.top_drag.label
|
|
5445
|
-
? '<div style="text-align:center;padding:0 var(--s-3) var(--s-2);font-size:13px;color:var(--c-text-dim);">Biggest drag: <strong style="color:' +
|
|
5338
|
+
? '<div style="text-align:center;padding:0 var(--s-3) var(--s-2);font-size:13px;color:var(--c-text-dim);">Biggest drag: <strong style="color:' + qInk + ';">' + esc(q.top_drag.label) + '</strong>' +
|
|
5446
5339
|
(typeof q.top_drag.points === 'number' ? ' <span style="font-family:var(--font-mono);font-size:12px;">(-' + esc(String(q.top_drag.points)) + ' pts)</span>' : '') +
|
|
5447
5340
|
'</div>'
|
|
5448
5341
|
: '');
|
|
5449
5342
|
|
|
5450
5343
|
// Breakdown bars
|
|
5451
5344
|
var bd = q.breakdown || {};
|
|
5345
|
+
// Section 6: no emoji — the labels carry the meaning.
|
|
5452
5346
|
var signals = [
|
|
5453
|
-
{ key: 'context_fill_degradation', label: 'Context Fill',
|
|
5454
|
-
{ key: 'stale_reads', label: 'Stale Reads',
|
|
5455
|
-
{ key: 'bloated_results', label: 'Bloated Results',
|
|
5456
|
-
{ key: 'duplicates', label: 'Duplicates',
|
|
5457
|
-
{ key: 'decision_density', label: 'Decision Density',
|
|
5458
|
-
{ key: 'agent_efficiency', label: 'Agent Efficiency',
|
|
5347
|
+
{ key: 'context_fill_degradation', label: 'Context Fill', tip: 'How full the active context is. Higher fill raises degradation risk.' },
|
|
5348
|
+
{ key: 'stale_reads', label: 'Stale Reads', tip: 'Files read earlier that have since changed. The model may be working with outdated content.' },
|
|
5349
|
+
{ key: 'bloated_results', label: 'Bloated Results', tip: 'Tool outputs sitting in context that were never referenced. Wasted space.' },
|
|
5350
|
+
{ key: 'duplicates', label: 'Duplicates', tip: 'Same system reminders or content injected multiple times. Pure waste.' },
|
|
5351
|
+
{ key: 'decision_density', label: 'Decision Density', tip: 'Ratio of actual decisions and work vs overhead and boilerplate.' },
|
|
5352
|
+
{ key: 'agent_efficiency', label: 'Agent Efficiency', tip: 'Whether dispatched agents produced useful output relative to their token cost.' }
|
|
5459
5353
|
];
|
|
5460
5354
|
html += '<div style="padding:0 var(--s-3) var(--s-3);">';
|
|
5461
5355
|
// Compactions are metadata, with no health bar or fixed loss claim.
|
|
@@ -5478,7 +5372,7 @@ var DB = (function() {
|
|
|
5478
5372
|
else if (d.ratio !== undefined) detail = d.ratio;
|
|
5479
5373
|
else if (d.detail) detail = d.detail;
|
|
5480
5374
|
html += '<div style="display:flex;align-items:center;gap:var(--s-2);margin-bottom:10px;font-size:15px;" title="' + esc(sig.tip) + '">' +
|
|
5481
|
-
'<span style="width:165px;color:var(--c-text-main);font-weight:500;cursor:help;">' + sig.
|
|
5375
|
+
'<span style="width:165px;color:var(--c-text-main);font-weight:500;cursor:help;">' + sig.label + '</span>' +
|
|
5482
5376
|
'<div style="flex:1;height:10px;background:var(--c-surface);border-radius:5px;overflow:hidden;">' +
|
|
5483
5377
|
'<div style="width:' + sigScore + '%;height:100%;background:' + barColor + ';border-radius:5px;transition:width 0.3s;"></div>' +
|
|
5484
5378
|
'</div>' +
|
|
@@ -5490,7 +5384,7 @@ var DB = (function() {
|
|
|
5490
5384
|
var waste = bd.total_estimated_waste_tokens;
|
|
5491
5385
|
if (waste && waste > 0) {
|
|
5492
5386
|
html += '<div style="margin-top:var(--s-2);padding:var(--s-2);background:var(--c-surface);border-radius:8px;font-size:13px;color:var(--c-text-dim);">' +
|
|
5493
|
-
'<strong style="color:' +
|
|
5387
|
+
'<strong style="color:' + qInk + ';">' + waste.toLocaleString() + ' tokens</strong> of estimated waste. ' +
|
|
5494
5388
|
(qs < 70 ? 'Consider <code>/compact</code> to reclaim.' : 'Minor bloat, manageable.') +
|
|
5495
5389
|
'</div>';
|
|
5496
5390
|
}
|
|
@@ -5512,7 +5406,7 @@ var DB = (function() {
|
|
|
5512
5406
|
var latestAvg = last7[last7.length - 1].avg_quality;
|
|
5513
5407
|
var trendColor = latestAvg >= 80 ? 'var(--c-accent-cyan)' : latestAvg >= 60 ? 'var(--c-chart-teal, #4ecdc4)' : latestAvg >= 50 ? 'var(--c-warning, #ff9f43)' : 'var(--c-chart-coral, #ff6b6b)';
|
|
5514
5408
|
|
|
5515
|
-
html += '<div class="card wide"><div class="card-header"><span>Quality Trend</span><span class="label">' + last7.length + '
|
|
5409
|
+
html += '<div class="card wide"><div class="card-header"><span>Quality Trend</span><span class="label">last ' + last7.length + ' days</span></div>' +
|
|
5516
5410
|
'<div style="padding:var(--s-2) var(--s-3);font-size:12px;color:var(--c-text-dim);">Rolling daily average quality score across sessions. Dashed line shows daily minimum.</div>' +
|
|
5517
5411
|
'<div style="padding:0 var(--s-3) var(--s-3);overflow-x:auto;">' +
|
|
5518
5412
|
'<svg viewBox="0 0 ' + chartW + ' ' + chartH + '" style="width:100%;max-width:' + chartW + 'px;height:auto;">' +
|
|
@@ -5540,6 +5434,14 @@ var DB = (function() {
|
|
|
5540
5434
|
});
|
|
5541
5435
|
html += '</div>';
|
|
5542
5436
|
}
|
|
5437
|
+
// U9: context quality and hook time limits moved here from the Savings tab.
|
|
5438
|
+
try { if (typeof healthNotesHtml === 'function') html += healthNotesHtml(data); } catch (e) {}
|
|
5439
|
+
try { if (typeof featureHealthHtml === 'function') html += featureHealthHtml(data); } catch (e) {}
|
|
5440
|
+
try {
|
|
5441
|
+
var cfData2 = data.coverage_funnel;
|
|
5442
|
+
if (cfData2 && cfData2.available && typeof coverageFunnelHtml === 'function') html += coverageFunnelHtml(data);
|
|
5443
|
+
} catch (e) {}
|
|
5444
|
+
try { if (typeof holdoutHtml === 'function') html += holdoutHtml(data); } catch (e) {}
|
|
5543
5445
|
|
|
5544
5446
|
el.innerHTML = html;
|
|
5545
5447
|
}
|
|
@@ -5552,7 +5454,6 @@ var DB = (function() {
|
|
|
5552
5454
|
var isCodex = data.runtime === 'codex';
|
|
5553
5455
|
|
|
5554
5456
|
var html = '<div class="section-header">' +
|
|
5555
|
-
'<div class="label">Advisory</div>' +
|
|
5556
5457
|
'<h1>Token Coach</h1>' +
|
|
5557
5458
|
'<p>Health score, pattern analysis, and coaching prompts for your setup.</p>' +
|
|
5558
5459
|
'</div>';
|
|
@@ -5573,15 +5474,13 @@ var DB = (function() {
|
|
|
5573
5474
|
return it && it.state !== 'not_applicable';
|
|
5574
5475
|
});
|
|
5575
5476
|
var urWins = ur.wins || [];
|
|
5576
|
-
if (urItems.length > 0
|
|
5477
|
+
if (urItems.length > 0) {
|
|
5577
5478
|
html += '<div class="card wide"><div class="card-header"><span>From your own usage</span>' +
|
|
5578
5479
|
(ur.measured_ts
|
|
5579
5480
|
? '<span class="label">measured ' + esc(timeAgo(new Date(ur.measured_ts * 1000))) + ', last ' + esc(String(ur.window_days || 30)) + ' days</span>'
|
|
5580
5481
|
: '') +
|
|
5581
5482
|
'</div>' +
|
|
5582
|
-
|
|
5583
|
-
? '<div style="color:var(--c-text-dim);font-size:14px;">Measuring in the background, check back after your next session</div>'
|
|
5584
|
-
: '');
|
|
5483
|
+
'';
|
|
5585
5484
|
var urCap = function(s) { s = String(s || ''); return s.charAt(0).toUpperCase() + s.slice(1); };
|
|
5586
5485
|
urItems.forEach(function(it, urIdx) {
|
|
5587
5486
|
// The card header already draws a line above the first row.
|
|
@@ -5633,64 +5532,38 @@ var DB = (function() {
|
|
|
5633
5532
|
'<div style="font-size:28px;font-weight:500;font-family:var(--font-mono);color:' + scoreColor + ';">' + esc(score) + '/100</div>' +
|
|
5634
5533
|
'</div></div>';
|
|
5635
5534
|
|
|
5636
|
-
//
|
|
5535
|
+
// The "Startup Overhead" and "Usable context" tiles are cut (section 5):
|
|
5536
|
+
// they repeat Overview. The snapshot numbers stay available in the
|
|
5537
|
+
// health-score description above.
|
|
5637
5538
|
var snap = c.snapshot || {};
|
|
5638
5539
|
var instructionLabel = snap.instruction_label || (isCodex ? 'AGENTS.md' : isNoInstructionHost(data) ? 'agent instructions' : 'CLAUDE.md');
|
|
5639
|
-
html += '<div class="dashboard-grid">' +
|
|
5640
|
-
'<div class="card"><div class="card-header"><span>Startup Overhead</span></div>' +
|
|
5641
|
-
'<div style="font-size:11px;color:var(--c-text-dim);padding:0 0 4px 0;">Tokens loaded before you type. Includes ' + esc(instructionLabel) + ', skills/plugin metadata, MCP tools, and system prompt.</div>' +
|
|
5642
|
-
'<div class="mini-stat">' + fn(snap.total_overhead || 0) + '</div>' +
|
|
5643
|
-
'<div class="label">' + esc(snap.overhead_pct || 0) + '% of ' + ((snap.context_window || data.snapshot.context_window || 1000000) >= 1000000 ? ((snap.context_window || data.snapshot.context_window || 1000000) / 1000000) + 'M' : ((snap.context_window || data.snapshot.context_window || 1000000) / 1000) + 'K') + '</div></div>' +
|
|
5644
|
-
'<div class="card"><div class="card-header"><span>Usable Context</span></div>' +
|
|
5645
|
-
'<div style="font-size:11px;color:var(--c-text-dim);padding:0 0 4px 0;">Context window minus startup overhead and ~33K autocompact buffer. This is how much room you actually have for conversation.</div>' +
|
|
5646
|
-
'<div class="mini-stat" style="color:var(--c-accent-cyan);">~' + fn(snap.usable_tokens || 0) + '</div>' +
|
|
5647
|
-
'<div class="label">After overhead + autocompact buffer</div></div>' +
|
|
5648
|
-
'</div>';
|
|
5649
5540
|
|
|
5650
5541
|
// Pattern cards
|
|
5651
5542
|
var bad = c.patterns_bad || [];
|
|
5652
5543
|
var good = c.patterns_good || [];
|
|
5653
5544
|
|
|
5654
5545
|
if (bad.length > 0) {
|
|
5546
|
+
// Section 6: no left stripes, no orange type. Severity is a small dot
|
|
5547
|
+
// before the title; the title itself is ink.
|
|
5655
5548
|
html += '<div class="card wide"><div class="card-header"><span>Issues Detected</span><span class="label">' + bad.length + ' found</span></div>';
|
|
5656
5549
|
bad.forEach(function(p) {
|
|
5657
5550
|
var sevColor = p.severity === 'high' ? 'var(--c-chart-coral, #ff6b6b)' : p.severity === 'medium' ? 'var(--c-warning, #ff9f43)' : 'var(--c-text-dim, #7d8ca3)';
|
|
5658
|
-
html += '<div style="
|
|
5659
|
-
'<div style="font-weight:500;color:' + sevColor + ';">' + esc(p.name) + '</div>' +
|
|
5551
|
+
html += '<div style="padding:var(--s-3);margin-bottom:var(--s-2);background:rgba(255,255,255,0.02);border-radius:8px;">' +
|
|
5552
|
+
'<div style="font-weight:500;color:var(--c-text-main);"><span style="display:inline-block;width:8px;height:8px;border-radius:50%;background:' + sevColor + ';margin-right:8px;"></span>' + esc(p.name) + '</div>' +
|
|
5660
5553
|
'<div style="color:var(--c-text-dim);font-size:14px;margin-top:4px;">' + esc(p.detail) + '</div>' +
|
|
5661
5554
|
'<div style="font-size:13px;margin-top:4px;"><span style="color:var(--c-accent-cyan);">Fix:</span> ' + esc(p.fix) + '</div>' +
|
|
5662
|
-
|
|
5555
|
+
// Section 6: only a real figure is a savings claim; "Not estimated"
|
|
5556
|
+
// and friends are not shown as savings.
|
|
5557
|
+
(/\d/.test(p.savings || '')
|
|
5558
|
+
? '<div style="font-size:13px;color:var(--c-text-dim);">Savings: ' + esc(p.savings) + '</div>'
|
|
5559
|
+
: '') +
|
|
5663
5560
|
'</div>';
|
|
5664
5561
|
});
|
|
5665
5562
|
html += '</div>';
|
|
5666
5563
|
}
|
|
5667
5564
|
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
var neutral = good.filter(function(p) { return !p.earned; });
|
|
5671
|
-
|
|
5672
|
-
if (earned.length > 0) {
|
|
5673
|
-
html += '<div class="card wide"><div class="card-header"><span>Working Well</span></div>';
|
|
5674
|
-
earned.forEach(function(p) {
|
|
5675
|
-
html += '<div style="border-left:3px solid var(--c-accent-cyan);padding:var(--s-3);margin-bottom:var(--s-2);background:rgba(0,240,255,0.02);border-radius:0 6px 6px 0;">' +
|
|
5676
|
-
'<div style="font-weight:500;color:var(--c-accent-cyan);">' + esc(p.name) + '</div>' +
|
|
5677
|
-
'<div style="color:var(--c-text-dim);font-size:14px;margin-top:4px;">' + esc(p.detail) + '</div>' +
|
|
5678
|
-
'</div>';
|
|
5679
|
-
});
|
|
5680
|
-
html += '</div>';
|
|
5681
|
-
}
|
|
5682
|
-
|
|
5683
|
-
if (neutral.length > 0) {
|
|
5684
|
-
html += '<div class="card wide"><div class="card-header"><span>Setup Summary</span></div>';
|
|
5685
|
-
neutral.forEach(function(p) {
|
|
5686
|
-
html += '<div style="border-left:3px solid var(--c-border);padding:var(--s-3);margin-bottom:var(--s-2);background:rgba(255,255,255,0.015);border-radius:0 6px 6px 0;">' +
|
|
5687
|
-
'<div style="font-weight:500;color:var(--c-text-main);">' + esc(p.name) + '</div>' +
|
|
5688
|
-
'<div style="color:var(--c-text-dim);font-size:14px;margin-top:4px;">' + esc(p.detail) + '</div>' +
|
|
5689
|
-
'</div>';
|
|
5690
|
-
});
|
|
5691
|
-
html += '</div>';
|
|
5692
|
-
}
|
|
5693
|
-
}
|
|
5565
|
+
// "Working well" and "Setup summary" are cut (section 5): five rows
|
|
5566
|
+
// restating Overview.
|
|
5694
5567
|
|
|
5695
5568
|
// Compaction timing guide
|
|
5696
5569
|
var cg = c.compaction_guide;
|
|
@@ -5700,12 +5573,12 @@ var DB = (function() {
|
|
|
5700
5573
|
'<div>' +
|
|
5701
5574
|
'<div style="font-weight:500;color:var(--c-accent-cyan);margin-bottom:var(--s-2);">Compact after</div>';
|
|
5702
5575
|
(cg.compact_after || []).forEach(function(item) {
|
|
5703
|
-
html += '<div style="font-size:14px;color:var(--c-text-dim);padding:4px 0;"
|
|
5576
|
+
html += '<div style="font-size:14px;color:var(--c-text-dim);padding:4px 0;">' + esc(item) + '</div>';
|
|
5704
5577
|
});
|
|
5705
5578
|
html += '</div><div>' +
|
|
5706
5579
|
'<div style="font-weight:500;color:var(--c-chart-coral, #ff6b6b);margin-bottom:var(--s-2);">Avoid during</div>';
|
|
5707
5580
|
(cg.avoid_during || []).forEach(function(item) {
|
|
5708
|
-
html += '<div style="font-size:14px;color:var(--c-text-dim);padding:4px 0;"
|
|
5581
|
+
html += '<div style="font-size:14px;color:var(--c-text-dim);padding:4px 0;">' + esc(item) + '</div>';
|
|
5709
5582
|
});
|
|
5710
5583
|
html += '</div></div></div>';
|
|
5711
5584
|
}
|
|
@@ -5750,21 +5623,13 @@ var DB = (function() {
|
|
|
5750
5623
|
html += '<div style="padding:10px var(--s-3);border-bottom:1px solid var(--c-border);">' +
|
|
5751
5624
|
'<div style="display:flex;justify-content:space-between;margin-bottom:4px;">' +
|
|
5752
5625
|
'<span style="font-size:13px;color:var(--c-text-dim);">#' + (i + 1) + ' (' + breakdown + ')</span>' +
|
|
5753
|
-
'<span style="font-family:var(--font-mono);font-weight:500;color:
|
|
5754
|
-
'<div style="font-size:14px;color:var(--c-text-dim);
|
|
5626
|
+
'<span style="font-family:var(--font-mono);font-weight:500;color:var(--c-text-main);">$' + p.cost_usd.toFixed(2) + '</span></div>' +
|
|
5627
|
+
'<div style="font-size:14px;color:var(--c-text-dim);">"' + esc(preview) + '..."</div></div>';
|
|
5755
5628
|
});
|
|
5756
5629
|
html += '</div>';
|
|
5757
5630
|
}
|
|
5758
5631
|
|
|
5759
|
-
// Coaching
|
|
5760
|
-
var questions = c.questions || [];
|
|
5761
|
-
if (questions.length > 0) {
|
|
5762
|
-
html += '<div class="card wide"><div class="card-header"><span>Coaching Questions</span></div>';
|
|
5763
|
-
questions.forEach(function(q) {
|
|
5764
|
-
html += '<div style="padding:var(--s-2) var(--s-3);color:var(--c-text-dim);font-size:14px;border-bottom:1px solid var(--c-border);">' + esc(q) + '</div>';
|
|
5765
|
-
});
|
|
5766
|
-
html += '</div>';
|
|
5767
|
-
}
|
|
5632
|
+
// "Coaching Questions" is cut (section 5): one generic question.
|
|
5768
5633
|
|
|
5769
5634
|
// Ask Coach prompt
|
|
5770
5635
|
html += '<div class="card wide">' +
|
|
@@ -5823,7 +5688,6 @@ var DB = (function() {
|
|
|
5823
5688
|
: tcli('python3 measure.py dashboard --user');
|
|
5824
5689
|
|
|
5825
5690
|
var html = '<div class="section-header">' +
|
|
5826
|
-
'<div class="label">Configuration</div>' +
|
|
5827
5691
|
'<h1>Hooks</h1>' +
|
|
5828
5692
|
'<p>' + (isCodex
|
|
5829
5693
|
? 'Codex hooks collect real local telemetry. Balanced mode is the default; per-tool hooks are opt-in because Codex Desktop shows hook rows.'
|
|
@@ -6073,7 +5937,6 @@ var DB = (function() {
|
|
|
6073
5937
|
}
|
|
6074
5938
|
|
|
6075
5939
|
var html = '<div class="section-header">' +
|
|
6076
|
-
'<div class="label">Control Panel</div>' +
|
|
6077
5940
|
'<h1>Manage</h1>' +
|
|
6078
5941
|
'<p id="manage-mode-desc">' +
|
|
6079
5942
|
(isCodex
|
|
@@ -6087,7 +5950,7 @@ var DB = (function() {
|
|
|
6087
5950
|
'</div>';
|
|
6088
5951
|
|
|
6089
5952
|
if (v5Synthesized) {
|
|
6090
|
-
html += '<div style="padding:12px var(--s-3);margin-bottom:var(--s-2);background:var(--c-bg);border
|
|
5953
|
+
html += '<div style="padding:12px var(--s-3);margin-bottom:var(--s-2);background:var(--c-bg);border:1px solid var(--c-border);border-radius:8px;font-size:14px;color:var(--c-text-dim);">' +
|
|
6091
5954
|
(isCodex
|
|
6092
5955
|
? 'Showing default Codex feature state. Run a Codex dashboard refresh to reflect your actual config.'
|
|
6093
5956
|
: isNoInstructionHost(data) ? 'Showing default feature state.'
|
|
@@ -6102,7 +5965,7 @@ var DB = (function() {
|
|
|
6102
5965
|
var onCount = 0;
|
|
6103
5966
|
var offRecommended = 0;
|
|
6104
5967
|
v5Names.forEach(function(n) {
|
|
6105
|
-
if (v5Features[n].enabled) onCount++;
|
|
5968
|
+
if (n === 'keepwarm') return; if (v5Features[n].enabled) onCount++;
|
|
6106
5969
|
else if (v5Features[n].recommended) offRecommended++;
|
|
6107
5970
|
});
|
|
6108
5971
|
|
|
@@ -6115,7 +5978,7 @@ var DB = (function() {
|
|
|
6115
5978
|
'<div class="card-header" style="padding:18px var(--s-3);">' +
|
|
6116
5979
|
'<span style="font-size:22px;font-weight:700;">' + v5Title + '</span>' +
|
|
6117
5980
|
'<span class="label" style="font-size:14px;background:' + headerColor + ';color:var(--c-bg);padding:6px 12px;border-radius:4px;font-weight:700;">' +
|
|
6118
|
-
onCount + '/' + v5Names.length + ' ON' +
|
|
5981
|
+
onCount + '/' + v5Names.filter(function(n) { return n !== 'keepwarm'; }).length + ' ON' +
|
|
6119
5982
|
'</span>' +
|
|
6120
5983
|
'</div>' +
|
|
6121
5984
|
'<p style="font-size:17px;color:var(--c-text-main);padding:0 var(--s-3) var(--s-2);line-height:1.6;">' +
|
|
@@ -6124,7 +5987,7 @@ var DB = (function() {
|
|
|
6124
5987
|
'</p>';
|
|
6125
5988
|
|
|
6126
5989
|
v5Names.forEach(function(fname) {
|
|
6127
|
-
var f = v5Features[fname];
|
|
5990
|
+
var f = v5Features[fname]; if (fname === 'keepwarm') { html += '<div class="hook-row" style="padding:20px var(--s-3);border-top:1px solid var(--c-border);">Keep-warm: paused while we prove it is safe and saves you money</div>'; return; }
|
|
6128
5991
|
var unavailable = !!f.unavailable || f.source === 'codex api gap';
|
|
6129
5992
|
var managedByHooks = !!f.managed_by_hooks || (isCodex && (f.source === 'codex hook' || f.source === 'codex opt-in' || f.source === 'codex hook-managed'));
|
|
6130
5993
|
var riskBg = 'var(--c-badge-savings)';
|
|
@@ -6151,10 +6014,8 @@ var DB = (function() {
|
|
|
6151
6014
|
: unavailable
|
|
6152
6015
|
? '<span style="font-size:12px;color:var(--c-text-dim);margin-left:10px;">(shown for parity; not toggleable in Codex yet)</span>'
|
|
6153
6016
|
: '';
|
|
6154
|
-
|
|
6155
|
-
var impactBadge =
|
|
6156
|
-
? '<span style="font-size:20px;font-weight:800;color:var(--c-accent-cyan);margin-left:auto;">' + impactPct + '</span>'
|
|
6157
|
-
: '';
|
|
6017
|
+
// Section 5: the "+N%" badge was a percent with no noun; it is cut.
|
|
6018
|
+
var impactBadge = '';
|
|
6158
6019
|
|
|
6159
6020
|
html += '<div class="hook-row" style="padding:20px var(--s-3);align-items:flex-start;border-top:1px solid var(--c-border);">' +
|
|
6160
6021
|
'<label class="hook-toggle" style="margin-top:4px;transform:scale(1.2);transform-origin:left top;">' +
|
|
@@ -6178,7 +6039,7 @@ var DB = (function() {
|
|
|
6178
6039
|
'</div>' +
|
|
6179
6040
|
'<div style="margin-top:12px;display:inline-block;padding:6px 12px;background:' + riskBg + ';color:#000;font-size:13px;font-weight:700;border-radius:4px;">' +
|
|
6180
6041
|
riskLabel + '</div>' +
|
|
6181
|
-
'<div style="font-size:14px;color:var(--c-text-dim);margin-top:8px;line-height:1.6;
|
|
6042
|
+
'<div style="font-size:14px;color:var(--c-text-dim);margin-top:8px;line-height:1.6;">' +
|
|
6182
6043
|
esc(f.risk) +
|
|
6183
6044
|
'</div>' +
|
|
6184
6045
|
'</div></div>';
|
|
@@ -6803,28 +6664,96 @@ var DB = (function() {
|
|
|
6803
6664
|
document.getElementById('prompt-modal-overlay').classList.remove('visible');
|
|
6804
6665
|
}
|
|
6805
6666
|
|
|
6667
|
+
// ---- View switching with deep links (F4) ----
|
|
6668
|
+
// location.hash names the view (#savings, #quick, ...). showView is the one
|
|
6669
|
+
// place that activates a view, syncs the nav, the right rail and the hash.
|
|
6670
|
+
function viewFromHash() {
|
|
6671
|
+
var h = (window.location.hash || '').replace(/^#/, '');
|
|
6672
|
+
if (h.indexOf('view-') === 0) h = h.slice(5);
|
|
6673
|
+
return h && document.querySelector('.nav-item[data-view="' + h + '"]') ? h : null;
|
|
6674
|
+
}
|
|
6675
|
+
function showView(v, opts) {
|
|
6676
|
+
opts = opts || {};
|
|
6677
|
+
var target = document.getElementById('view-' + v);
|
|
6678
|
+
var nav = document.querySelector('.nav-item[data-view="' + v + '"]');
|
|
6679
|
+
if (!target || !nav) return false;
|
|
6680
|
+
document.querySelectorAll('.view').forEach(function(el) { el.classList.remove('active'); });
|
|
6681
|
+
document.querySelectorAll('.nav-item').forEach(function(n) { n.classList.remove('active'); });
|
|
6682
|
+
target.classList.add('active');
|
|
6683
|
+
nav.classList.add('active');
|
|
6684
|
+
var layout = document.querySelector('.layout');
|
|
6685
|
+
if (layout) layout.classList.toggle('panel-hidden', !!analyticsViews[v]);
|
|
6686
|
+
var mc = document.querySelector('.main-col');
|
|
6687
|
+
if (mc) mc.scrollTop = 0;
|
|
6688
|
+
if (!opts.skipHash) {
|
|
6689
|
+
try {
|
|
6690
|
+
if (opts.replace) history.replaceState(null, '', '#' + v);
|
|
6691
|
+
else if (window.location.hash !== '#' + v) window.location.hash = v;
|
|
6692
|
+
} catch (e) { /* file:// or locked history: leave the hash alone */ }
|
|
6693
|
+
}
|
|
6694
|
+
return true;
|
|
6695
|
+
}
|
|
6696
|
+
|
|
6697
|
+
// ---- "Still on the table" fix buttons (F5) ----
|
|
6698
|
+
// Each row's button lands on the exact plan item that fixes it: the tab it
|
|
6699
|
+
// lives on plus the item, expanded and highlighted.
|
|
6700
|
+
function savingsOnTableFixes() {
|
|
6701
|
+
function find(patterns, fallback) {
|
|
6702
|
+
for (var i = 0; i < items.length; i++) {
|
|
6703
|
+
var it = items[i];
|
|
6704
|
+
var hay = (it.title || '') + ' ' + (it.shortDesc || '') + ' ' + (it.detail || '');
|
|
6705
|
+
for (var p = 0; p < patterns.length; p++) {
|
|
6706
|
+
if (patterns[p].test(hay)) return { view: it.section || 'quick', idx: it._i };
|
|
6707
|
+
}
|
|
6708
|
+
}
|
|
6709
|
+
return { view: fallback };
|
|
6710
|
+
}
|
|
6711
|
+
return {
|
|
6712
|
+
routing: find([/hardcoded model/i, /route subagents/i, /model.{0,20}(routing|mix|task)/i, /lighter model/i], 'quick'),
|
|
6713
|
+
skills: find([/skills? not invoked/i, /skill.{0,40}(archive|budget|listing|inventory|trim|unused)/i, /unused skills?/i], 'manage')
|
|
6714
|
+
};
|
|
6715
|
+
}
|
|
6716
|
+
function gotoFix(view, idx) {
|
|
6717
|
+
if (!showView(view)) return;
|
|
6718
|
+
if (idx == null || idx === '') return;
|
|
6719
|
+
var scope = document.getElementById('view-' + view);
|
|
6720
|
+
var target = scope && scope.querySelector('[data-idx="' + idx + '"]');
|
|
6721
|
+
if (!target) return;
|
|
6722
|
+
var row = target.classList.contains('setting-row') ? target : target.closest('.setting-row');
|
|
6723
|
+
if (row && !row.classList.contains('expanded')) {
|
|
6724
|
+
row.classList.add('expanded');
|
|
6725
|
+
var detail = scope.querySelector('[data-detail-for="' + idx + '"]');
|
|
6726
|
+
if (detail) detail.style.maxHeight = detail.scrollHeight + 'px';
|
|
6727
|
+
}
|
|
6728
|
+
target.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
6729
|
+
target.classList.remove('st-flash');
|
|
6730
|
+
void target.offsetWidth;
|
|
6731
|
+
target.classList.add('st-flash');
|
|
6732
|
+
setTimeout(function() { target.classList.remove('st-flash'); }, 1700);
|
|
6733
|
+
}
|
|
6734
|
+
|
|
6806
6735
|
function bind() {
|
|
6807
6736
|
// Nav clicks
|
|
6808
6737
|
document.querySelectorAll('.nav-item[data-view]').forEach(function(lnk) {
|
|
6809
6738
|
lnk.addEventListener('click', function(e) {
|
|
6810
6739
|
e.preventDefault();
|
|
6811
|
-
|
|
6812
|
-
document.querySelectorAll('.view').forEach(function(el) { el.classList.remove('active'); });
|
|
6813
|
-
document.querySelectorAll('.nav-item').forEach(function(n) { n.classList.remove('active'); });
|
|
6814
|
-
document.getElementById('view-' + v).classList.add('active');
|
|
6815
|
-
this.classList.add('active');
|
|
6816
|
-
// Toggle panel visibility for analytics views
|
|
6817
|
-
var layout = document.querySelector('.layout');
|
|
6818
|
-
if (analyticsViews[v]) {
|
|
6819
|
-
layout.classList.add('panel-hidden');
|
|
6820
|
-
} else {
|
|
6821
|
-
layout.classList.remove('panel-hidden');
|
|
6822
|
-
}
|
|
6823
|
-
document.querySelector('.main-col').scrollTop = 0;
|
|
6740
|
+
showView(this.getAttribute('data-view'));
|
|
6824
6741
|
});
|
|
6825
6742
|
});
|
|
6826
6743
|
|
|
6744
|
+
// Back/forward and hand-edited hashes switch the view too.
|
|
6745
|
+
window.addEventListener('hashchange', function() {
|
|
6746
|
+
var v = viewFromHash();
|
|
6747
|
+
if (v) showView(v, { skipHash: true });
|
|
6748
|
+
});
|
|
6749
|
+
|
|
6827
6750
|
// Individual toggles (delegated)
|
|
6751
|
+
document.addEventListener('keydown', function(e) {
|
|
6752
|
+
if (e.key === 'Escape') {
|
|
6753
|
+
var any = document.querySelector('.st-tip--open');
|
|
6754
|
+
if (any) { any.classList.remove('st-tip--open'); any.blur(); }
|
|
6755
|
+
}
|
|
6756
|
+
});
|
|
6828
6757
|
document.addEventListener('change', function(e) {
|
|
6829
6758
|
var toggleLabel = e.target.closest('[data-toggle]');
|
|
6830
6759
|
if (toggleLabel) {
|
|
@@ -6857,7 +6786,7 @@ var DB = (function() {
|
|
|
6857
6786
|
var td = document.createElement('td');
|
|
6858
6787
|
td.colSpan = 12;
|
|
6859
6788
|
td.style.padding = '0';
|
|
6860
|
-
var html = '<div style="background:var(--c-bg);padding:var(--s-2) var(--s-3);margin:2px 0;border
|
|
6789
|
+
var html = '<div style="background:var(--c-bg);padding:var(--s-2) var(--s-3);margin:2px 0;border:1px solid var(--c-border);border-radius:8px;">' +
|
|
6861
6790
|
'<div style="font-size:12px;font-family:var(--font-mono);color:var(--c-accent-cyan);margin-bottom:6px;">Per-Turn Breakdown (' + turns.length + ' API calls)</div>' +
|
|
6862
6791
|
'<table class="session-table" style="margin:0;font-size:12px;"><thead><tr>' +
|
|
6863
6792
|
'<th title="Assistant API call number inside this session." style="cursor:help">#</th>' +
|
|
@@ -6960,6 +6889,27 @@ var DB = (function() {
|
|
|
6960
6889
|
// Stop propagation on toggle clicks so expand doesn't fire
|
|
6961
6890
|
if (e.target.closest('.toggle')) return;
|
|
6962
6891
|
|
|
6892
|
+
// Savings hero hover cards: tap toggles the card open on touch; a
|
|
6893
|
+
// click anywhere else closes it. Hover and focus are pure CSS.
|
|
6894
|
+
var tipBtn = e.target.closest('.st-tip');
|
|
6895
|
+
if (tipBtn) {
|
|
6896
|
+
var wasOpen = tipBtn.classList.contains('st-tip--open');
|
|
6897
|
+
document.querySelectorAll('.st-tip--open').forEach(function(b) { b.classList.remove('st-tip--open'); });
|
|
6898
|
+
if (!wasOpen) tipBtn.classList.add('st-tip--open');
|
|
6899
|
+
return;
|
|
6900
|
+
}
|
|
6901
|
+
if (!e.target.closest('.st-mega__item')) {
|
|
6902
|
+
document.querySelectorAll('.st-tip--open').forEach(function(b) { b.classList.remove('st-tip--open'); });
|
|
6903
|
+
}
|
|
6904
|
+
|
|
6905
|
+
// "Still on the table" fix buttons: jump to the exact fix (tab + item).
|
|
6906
|
+
var fixBtn = e.target.closest('.st-fix[data-goto-view]');
|
|
6907
|
+
if (fixBtn) {
|
|
6908
|
+
e.preventDefault();
|
|
6909
|
+
gotoFix(fixBtn.getAttribute('data-goto-view'), fixBtn.getAttribute('data-goto-idx'));
|
|
6910
|
+
return;
|
|
6911
|
+
}
|
|
6912
|
+
|
|
6963
6913
|
// Setting row expand/collapse
|
|
6964
6914
|
var row = e.target.closest('.setting-row[data-idx]');
|
|
6965
6915
|
if (row) {
|
|
@@ -7511,10 +7461,22 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
7511
7461
|
var brandMeta = document.getElementById('brand-meta');
|
|
7512
7462
|
if (brandMeta) {
|
|
7513
7463
|
var brandParts = [];
|
|
7514
|
-
if (data.version) brandParts.push('v' + data.version);
|
|
7515
7464
|
if (data.runtime === 'codex') brandParts.push('Codex');
|
|
7516
7465
|
brandMeta.textContent = brandParts.join(' \u00b7 ');
|
|
7517
7466
|
}
|
|
7467
|
+
// Version and freshness live once, in the footer.
|
|
7468
|
+
var footerVersion = document.getElementById('footer-version');
|
|
7469
|
+
if (footerVersion && data.version) footerVersion.textContent = 'v' + data.version;
|
|
7470
|
+
var footerUpdated = document.getElementById('footer-updated');
|
|
7471
|
+
if (footerUpdated && data.generated_at) {
|
|
7472
|
+
var fuDate = new Date(data.generated_at);
|
|
7473
|
+
if (!isNaN(fuDate.getTime())) {
|
|
7474
|
+
var fuNow = new Date();
|
|
7475
|
+
var fuDay = Math.floor((new Date(fuNow.getFullYear(), fuNow.getMonth(), fuNow.getDate()) - new Date(fuDate.getFullYear(), fuDate.getMonth(), fuDate.getDate())) / 86400000);
|
|
7476
|
+
var fuDayTxt = fuDay <= 0 ? 'today' : fuDay === 1 ? 'yesterday' : fuDate.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: fuDate.getFullYear() === fuNow.getFullYear() ? undefined : 'numeric' });
|
|
7477
|
+
footerUpdated.textContent = 'Updated ' + fuDayTxt + ' at ' + fuDate.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' });
|
|
7478
|
+
}
|
|
7479
|
+
}
|
|
7518
7480
|
|
|
7519
7481
|
function startApp() {
|
|
7520
7482
|
DB.init(data); refreshSavingsLive();
|
|
@@ -7564,24 +7526,15 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
7564
7526
|
}, 60000);
|
|
7565
7527
|
}
|
|
7566
7528
|
|
|
7567
|
-
// Probe
|
|
7568
|
-
// When served from the daemon (http://localhost:*), a relative /api/health works.
|
|
7569
|
-
// When viewed as file://, stay in static read-only mode to avoid CORS noise.
|
|
7529
|
+
// Probe the daemon; file pages stay read-only.
|
|
7570
7530
|
var DAEMON_URL = data.runtime === 'codex' ? 'http://localhost:24843' : 'http://localhost:24842';
|
|
7571
7531
|
function _setApiLive(baseUrl) {
|
|
7572
7532
|
window.__TOKEN_API_LIVE = true;
|
|
7573
7533
|
window.__TOKEN_API_BASE = baseUrl || '';
|
|
7574
7534
|
}
|
|
7575
|
-
//
|
|
7576
|
-
// CSRF token header so the server accepts the request. Without this, POSTs
|
|
7577
|
-
// are rejected with 403 -- that's the whole point of the CSRF hardening.
|
|
7578
|
-
//
|
|
7579
|
-
// Surface auth errors as a distinct message
|
|
7580
|
-
// rather than letting callers hit r.json() on a text body ("Forbidden:
|
|
7581
|
-
// invalid token") and seeing a confusing JSON parse error. The helper
|
|
7582
|
-
// intercepts 403 responses and rejects with an Error whose .authError flag
|
|
7583
|
-
// lets call sites show a reload-page hint.
|
|
7535
|
+
// All mutations carry the per-install token and surface authorization failures.
|
|
7584
7536
|
window.__TOKEN_API_POST = function(path, body) {
|
|
7537
|
+
if (window.location && window.location.protocol === 'file:') return Promise.reject(new Error('Open the live dashboard to make changes.'));
|
|
7585
7538
|
var base = window.__TOKEN_API_BASE || '';
|
|
7586
7539
|
var headers = { 'Content-Type': 'application/json' };
|
|
7587
7540
|
if (window.__TOKEN_API_TOKEN) headers['X-TO-Token'] = window.__TOKEN_API_TOKEN;
|
|
@@ -7601,6 +7554,21 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
7601
7554
|
});
|
|
7602
7555
|
};
|
|
7603
7556
|
|
|
7557
|
+
function waitForRegen(result, message) {
|
|
7558
|
+
if (!result.ok) return Promise.reject(new Error('Could not update the dashboard. Please try again.'));
|
|
7559
|
+
if (!result.job_id) return Promise.resolve();
|
|
7560
|
+
function poll() {
|
|
7561
|
+
return window.__TOKEN_API_POST('/api/regenerate/status', {job_id: result.job_id})
|
|
7562
|
+
.then(function(r) { return r.json(); }).then(function(state) {
|
|
7563
|
+
if (message) message.textContent = state.progress || 'Updating the dashboard.';
|
|
7564
|
+
if (state.state === 'done') return;
|
|
7565
|
+
if (state.state !== 'running') throw new Error('Could not update the dashboard. Please try again.');
|
|
7566
|
+
return new Promise(function(resolve) { setTimeout(resolve, 1000); }).then(poll);
|
|
7567
|
+
});
|
|
7568
|
+
}
|
|
7569
|
+
return poll();
|
|
7570
|
+
}
|
|
7571
|
+
|
|
7604
7572
|
window.__TOKEN_LOAD_HISTORY = function(choice, message) {
|
|
7605
7573
|
if (choice === 'all') { try { localStorage.setItem('to-daily-range', 'all'); } catch (e) {} }
|
|
7606
7574
|
if (!window.__TOKEN_API_LIVE) {
|
|
@@ -7611,25 +7579,23 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
7611
7579
|
function attempt(retried) {
|
|
7612
7580
|
window.__TOKEN_API_POST('/api/regenerate', {days: choice}).then(function(r) { return r.json(); })
|
|
7613
7581
|
.then(function(result) {
|
|
7614
|
-
|
|
7582
|
+
return waitForRegen(result, message);
|
|
7583
|
+
}).then(function() {
|
|
7615
7584
|
try { sessionStorage.setItem('to-history-return', '1'); } catch (e) {}
|
|
7616
7585
|
location.reload();
|
|
7617
7586
|
}).catch(function(err) {
|
|
7618
7587
|
if (err.authError && !retried) {
|
|
7619
7588
|
_fetchToken(window.__TOKEN_API_BASE || '').then(function() { attempt(true); })
|
|
7620
|
-
.catch(function(
|
|
7621
|
-
} else message.textContent = 'Could not load history
|
|
7589
|
+
.catch(function() { message.textContent = 'Could not load history. Please try again.'; });
|
|
7590
|
+
} else message.textContent = 'Could not load history. Please try again.';
|
|
7622
7591
|
});
|
|
7623
7592
|
}
|
|
7624
7593
|
if (window.__TOKEN_API_TOKEN) attempt(false);
|
|
7625
7594
|
else _fetchToken(window.__TOKEN_API_BASE || '').then(function() { attempt(false); })
|
|
7626
|
-
.catch(function(
|
|
7595
|
+
.catch(function() { message.textContent = 'Could not load history. Please try again.'; });
|
|
7627
7596
|
};
|
|
7628
7597
|
|
|
7629
|
-
// Manual regeneration
|
|
7630
|
-
// it serves the current file and refreshes for NEXT time, so a reader who wants
|
|
7631
|
-
// current numbers now would have to reload twice and never knows that. This is
|
|
7632
|
-
// synchronous on the daemon side and reloads on success, so one click is enough.
|
|
7598
|
+
// Manual regeneration waits for the background job before reloading.
|
|
7633
7599
|
window.__TOKEN_REGENERATE = function() {
|
|
7634
7600
|
var btn = document.getElementById('to-regen-btn');
|
|
7635
7601
|
var msg = document.getElementById('to-regen-msg');
|
|
@@ -7653,16 +7619,15 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
7653
7619
|
}
|
|
7654
7620
|
function fail(e) {
|
|
7655
7621
|
btn.disabled = false; btn.textContent = was;
|
|
7656
|
-
var txt = (e && e.authError)
|
|
7657
|
-
? 'Auth failed after a token refresh — reload the page.'
|
|
7658
|
-
: ('Failed: ' + ((e && e.message) || e || 'unknown error'));
|
|
7622
|
+
var txt = (e && e.authError) ? 'Authentication failed. Reload the page and try again.' : 'Could not update the dashboard. Please try again.';
|
|
7659
7623
|
if (msg) msg.textContent = '';
|
|
7660
7624
|
if (errBox) { errBox.textContent = txt; errBox.hidden = false; }
|
|
7661
7625
|
else if (msg) { msg.textContent = txt; }
|
|
7662
7626
|
}
|
|
7663
7627
|
function succeed(d) {
|
|
7664
|
-
|
|
7665
|
-
|
|
7628
|
+
return waitForRegen(d || {}, msg).then(function() {
|
|
7629
|
+
location.reload();
|
|
7630
|
+
}).catch(fail);
|
|
7666
7631
|
}
|
|
7667
7632
|
// At most ONE 403->refetch->retry. Without the cap a persistently-bad token
|
|
7668
7633
|
// loops forever; without the retry a stale/empty page token silently 403'd
|
|
@@ -7706,17 +7671,14 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
7706
7671
|
}
|
|
7707
7672
|
if (typeof fetch === 'function') {
|
|
7708
7673
|
var isHttp = window.location.protocol.indexOf('http') === 0;
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
return;
|
|
7712
|
-
}
|
|
7713
|
-
var probe = '/api/health';
|
|
7674
|
+
var base = isHttp ? '' : DAEMON_URL;
|
|
7675
|
+
var probe = base + '/api/health';
|
|
7714
7676
|
try {
|
|
7715
|
-
fetch(probe, { method: 'GET' })
|
|
7716
|
-
.then(function(r) { return r.json(); })
|
|
7677
|
+
fetch(probe, isHttp ? { method: 'GET' } : { method: 'GET', mode: 'no-cors' })
|
|
7678
|
+
.then(function(r) { return !isHttp && r.type === 'opaque' ? {ok: true} : r.json(); })
|
|
7717
7679
|
.then(function(d) {
|
|
7718
7680
|
if (d && d.ok) {
|
|
7719
|
-
|
|
7681
|
+
if (!isHttp) { window.__TOKEN_FILE_DAEMON_LIVE = true; return; }
|
|
7720
7682
|
_setApiLive(base);
|
|
7721
7683
|
return _fetchToken(base);
|
|
7722
7684
|
}
|