@alexgreensh/token-optimizer 5.13.63 → 5.13.65
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/hooks/sessionstart_runner.py +5 -0
- package/package.json +1 -1
- package/skills/fleet-auditor/SKILL.md +1 -1
- package/skills/token-coach/SKILL.md +49 -40
- package/skills/token-coach/references/deterministic-stages.md +1 -1
- package/skills/token-coach/references/keepwarm-consent.md +7 -7
- package/skills/token-dashboard/SKILL.md +30 -6
- package/skills/token-optimizer/SKILL.md +42 -44
- package/skills/token-optimizer/assets/dashboard.html +180 -44
- package/skills/token-optimizer/references/agent-prompts.md +4 -1
- package/skills/token-optimizer/references/codex-workflow.md +30 -12
- package/skills/token-optimizer/references/cursor-workflow.md +9 -7
- package/skills/token-optimizer/references/implementation-playbook.md +4 -4
- package/skills/token-optimizer/references/keepwarm-consent.md +7 -7
- package/skills/token-optimizer/references/opencode-workflow.md +4 -2
- package/skills/token-optimizer/references/optimization-checklist.md +9 -9
- package/skills/token-optimizer/references/phase0-setup.md +9 -9
- package/skills/token-optimizer/references/presentation-workflow.md +3 -3
- package/skills/token-optimizer/references/session-continuity.md +1 -1
- package/skills/token-optimizer/references/token-flow-architecture.md +2 -1
- package/skills/token-optimizer/scripts/archive_result.py +6 -1
- package/skills/token-optimizer/scripts/archive_window.py +274 -0
- package/skills/token-optimizer/scripts/checkpoint_state.py +385 -0
- package/skills/token-optimizer/scripts/codex_session.py +149 -1
- package/skills/token-optimizer/scripts/devin_source.py +2 -2
- package/skills/token-optimizer/scripts/measure.py +3498 -1111
- package/skills/token-optimizer/scripts/read_cache.py +20 -7
- package/skills/token-optimizer/scripts/recovery_output.py +67 -18
- package/skills/token-optimizer/scripts/session_activity.py +169 -0
- package/skills/token-optimizer/scripts/session_store.py +63 -9
- package/skills/token-optimizer/scripts/statusline.js +4 -6
|
@@ -2398,6 +2398,16 @@ function codexMemCardHtml(mr, fn) { return '<div class="card"><div class="card-h
|
|
|
2398
2398
|
'<div style="text-align:center;padding:0 0 var(--s-3);font-size:12px;color:var(--c-text-dim);">Measured from Codex state; no file structure audit</div>' +
|
|
2399
2399
|
'</div>'; }
|
|
2400
2400
|
function memCountSuffix(mr) { return mr && mr.scan_partial ? '+' : ''; }
|
|
2401
|
+
// Cursor and Antigravity have no CLAUDE.md or MEMORY.md and no ~/.claude
|
|
2402
|
+
// folder to manage, and the /token-optimizer audit is Claude Code only (see
|
|
2403
|
+
// references/cursor-workflow.md), so the Claude-shaped labels, cards and
|
|
2404
|
+
// pointers are replaced for them.
|
|
2405
|
+
function isNoInstructionHost(data) {
|
|
2406
|
+
return !!data && (data.runtime === 'cursor' || data.runtime === 'antigravity');
|
|
2407
|
+
}
|
|
2408
|
+
function hostRefreshHtml(data) {
|
|
2409
|
+
return tcliHtml('<span class="update-cmd">TOKEN_OPTIMIZER_RUNTIME=' + esc(data.runtime) + ' python3 measure.py dashboard</span>');
|
|
2410
|
+
}
|
|
2401
2411
|
function hermesComponentDetails(c) {
|
|
2402
2412
|
function fileSub(x, missing) {
|
|
2403
2413
|
return (x && x.exists) ? (x.lines || 0) + ' lines loaded every session' : missing;
|
|
@@ -2529,7 +2539,16 @@ function getComponentDetails(data) {
|
|
|
2529
2539
|
{
|
|
2530
2540
|
key: 'mcp_tools', name: 'MCP Tools',
|
|
2531
2541
|
tokens: c.mcp_tools ? c.mcp_tools.tokens : 0,
|
|
2532
|
-
sub: (
|
|
2542
|
+
sub: (function() {
|
|
2543
|
+
var m = c.mcp_tools;
|
|
2544
|
+
var s = (m ? m.server_count : '?') + ' servers, ~' + (m ? m.tool_count_estimate : '?') + ' tools';
|
|
2545
|
+
if (m) {
|
|
2546
|
+
var dis = m.disabled_for_project || [], pen = m.pending_project_approval || [];
|
|
2547
|
+
if (dis.length) s += ', ' + dis.length + ' disabled for this project';
|
|
2548
|
+
if (pen.length) s += ', ' + pen.length + ' pending approval';
|
|
2549
|
+
}
|
|
2550
|
+
return s;
|
|
2551
|
+
})(),
|
|
2533
2552
|
what: isCodex
|
|
2534
2553
|
? 'Codex MCP servers can expand the active tool surface with names, descriptions, and schemas. The dashboard counts configured servers and uses conservative metadata estimates when exact schemas are not exposed.'
|
|
2535
2554
|
: "MCP server tool definitions are loaded when servers connect. Each tool's name, description, and parameter schema contribute to token cost.",
|
|
@@ -2551,6 +2570,13 @@ function getComponentDetails(data) {
|
|
|
2551
2570
|
}
|
|
2552
2571
|
];
|
|
2553
2572
|
|
|
2573
|
+
if (isNoInstructionHost(data)) {
|
|
2574
|
+
// Drop the rows that name files and commands this runtime does not have.
|
|
2575
|
+
components = components.filter(function(comp) {
|
|
2576
|
+
return comp.key !== 'claude_md' && comp.key !== 'memory_md' && comp.key !== 'commands';
|
|
2577
|
+
});
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2554
2580
|
// Override with detailed data if available
|
|
2555
2581
|
components.forEach(function(comp) {
|
|
2556
2582
|
var d = cd[comp.key];
|
|
@@ -3026,7 +3052,7 @@ var DB = (function() {
|
|
|
3026
3052
|
var ts = data.generated_at ? new Date(data.generated_at).toLocaleString() : 'unknown';
|
|
3027
3053
|
var staleMinutes = data.generated_at ? Math.round((Date.now() - new Date(data.generated_at).getTime()) / 60000) : 0;
|
|
3028
3054
|
var isStale = staleMinutes > 60;
|
|
3029
|
-
var refreshHint = data.runtime === 'codex' ? 'run the Codex dashboard refresh command' : 'run /token-optimizer';
|
|
3055
|
+
var refreshHint = data.runtime === 'codex' ? 'run the Codex dashboard refresh command' : isNoInstructionHost(data) ? 'regenerate the dashboard' : 'run /token-optimizer';
|
|
3030
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>' : '';
|
|
3031
3057
|
var headerEl = document.querySelector('#view-overview .header');
|
|
3032
3058
|
if (headerEl) {
|
|
@@ -3038,11 +3064,15 @@ var DB = (function() {
|
|
|
3038
3064
|
tsDiv.innerHTML = 'Last updated: ' + esc(ts) + staleWarning +
|
|
3039
3065
|
(data.runtime === 'codex'
|
|
3040
3066
|
? tcliHtml(' · Run <span class="update-cmd">TOKEN_OPTIMIZER_RUNTIME=codex python3 measure.py session-end-flush --trigger manual</span> for a fresh Codex audit.')
|
|
3067
|
+
: isNoInstructionHost(data)
|
|
3068
|
+
? ' · To refresh, run ' + hostRefreshHtml(data) + '.'
|
|
3041
3069
|
: ' · Run <span class="update-cmd">/token-optimizer</span> for a full audit with recommendations.');
|
|
3042
3070
|
} else {
|
|
3043
3071
|
tsDiv.innerHTML = 'Last updated: ' + esc(ts) + staleWarning +
|
|
3044
3072
|
(data.runtime === 'codex'
|
|
3045
3073
|
? tcliHtml(' · To refresh, run <span class="update-cmd">TOKEN_OPTIMIZER_RUNTIME=codex python3 measure.py session-end-flush --trigger manual</span>.')
|
|
3074
|
+
: isNoInstructionHost(data)
|
|
3075
|
+
? ' · To refresh, run ' + hostRefreshHtml(data) + '.'
|
|
3046
3076
|
: ' · To refresh, run <span class="update-cmd">/token-optimizer</span> again.');
|
|
3047
3077
|
}
|
|
3048
3078
|
headerEl.appendChild(tsDiv);
|
|
@@ -3055,6 +3085,7 @@ var DB = (function() {
|
|
|
3055
3085
|
var c = data.snapshot.components;
|
|
3056
3086
|
var isCodexOverview = data.runtime === 'codex';
|
|
3057
3087
|
var isHermesOverview = data.runtime === 'hermes';
|
|
3088
|
+
var isHostOverview = isNoInstructionHost(data);
|
|
3058
3089
|
var vals = [];
|
|
3059
3090
|
var ct = 0; for (var k in c) {
|
|
3060
3091
|
if (!c[k] || !c[k].tokens) continue;
|
|
@@ -3092,6 +3123,13 @@ var DB = (function() {
|
|
|
3092
3123
|
barLabels = hc.map(function(x) { return x.name; });
|
|
3093
3124
|
memoryExists = !!(c.hermes_memory && c.hermes_memory.exists);
|
|
3094
3125
|
}
|
|
3126
|
+
if (isHostOverview) {
|
|
3127
|
+
vals = [(c.skills ? c.skills.tokens : 0) + (c.plugin_skills ? c.plugin_skills.tokens : 0),
|
|
3128
|
+
c.mcp_tools ? c.mcp_tools.tokens : 0,
|
|
3129
|
+
c.core_system ? c.core_system.tokens : 0];
|
|
3130
|
+
barLabels = ['Skills', 'MCP Tools', 'Core System'];
|
|
3131
|
+
memoryExists = true;
|
|
3132
|
+
}
|
|
3095
3133
|
var barsHtml = vals.map(function(v, i) {
|
|
3096
3134
|
var w = logBar(v);
|
|
3097
3135
|
var fixedClass = i === vals.length - 1 ? ' fixed' : '';
|
|
@@ -3136,7 +3174,7 @@ var DB = (function() {
|
|
|
3136
3174
|
} else if (data.standalone) {
|
|
3137
3175
|
document.getElementById('stat-potential').innerHTML = fn(ctrl) + ' <span class="mini-label">controllable tokens</span>';
|
|
3138
3176
|
document.getElementById('potential-desc').textContent =
|
|
3139
|
-
fn(ctrl) + ' of your ' + fn(total) + ' tokens are things you can change. ' + (isCodexOverview ? 'Use the Codex dashboard refresh command for a full local audit with specific savings estimates.' : 'Run /token-optimizer for a full audit with specific savings estimates.');
|
|
3177
|
+
fn(ctrl) + ' of your ' + fn(total) + ' tokens are things you can change. ' + (isCodexOverview ? 'Use the Codex dashboard refresh command for a full local audit with specific savings estimates.' : (isHostOverview ? '' : 'Run /token-optimizer for a full audit with specific savings estimates.'));
|
|
3140
3178
|
} else {
|
|
3141
3179
|
document.getElementById('stat-potential').innerHTML = fn(ctrl) + ' <span class="mini-label">controllable tokens</span>';
|
|
3142
3180
|
document.getElementById('potential-desc').textContent =
|
|
@@ -3248,11 +3286,11 @@ var DB = (function() {
|
|
|
3248
3286
|
ctaEl.innerHTML = '<div class="card-header"><span>Auto-Detected Recommendations</span></div>' +
|
|
3249
3287
|
'<div class="empty-state" style="text-align:left;color:var(--c-text-dim);font-size:14px;">' +
|
|
3250
3288
|
'These recommendations are auto-generated from your config. Browse them in the tabs on the left.<br>' +
|
|
3251
|
-
(isCodexOverview ? 'For deeper analysis, refresh the Codex dashboard after a few real turns so quality and continuity signals are available.' : '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>';
|
|
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>';
|
|
3252
3290
|
} else {
|
|
3253
3291
|
ctaEl.innerHTML = '<div class="card-header"><span>Optimization Recommendations</span></div>' +
|
|
3254
3292
|
'<div class="empty-state">No auto-detected issues. Your setup looks clean.<br>' +
|
|
3255
|
-
(isCodexOverview ? 'Refresh the Codex dashboard after live usage for deeper quality analysis.' : 'Run <code style="color:var(--c-accent-cyan)">/token-optimizer</code> for a full audit with deeper analysis.') + '</div>';
|
|
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>';
|
|
3256
3294
|
}
|
|
3257
3295
|
gridEl.parentNode.insertBefore(ctaEl, gridEl.nextSibling);
|
|
3258
3296
|
}
|
|
@@ -3317,20 +3355,20 @@ var DB = (function() {
|
|
|
3317
3355
|
|
|
3318
3356
|
if (data.auto_plan) {
|
|
3319
3357
|
html += '<div class="last-updated">Last updated: ' + esc(ts) +
|
|
3320
|
-
(data.runtime === 'codex' ? ' · Auto-detected from Codex local config and logs.</div>' : ' · Auto-detected. Run <span class="update-cmd">/token-optimizer</span> for deeper LLM-powered analysis.</div>');
|
|
3358
|
+
(data.runtime === 'codex' ? ' · Auto-detected from Codex local config and logs.</div>' : (isNoInstructionHost(data) ? ' · Auto-detected from local config and logs.</div>' : ' · Auto-detected. Run <span class="update-cmd">/token-optimizer</span> for deeper LLM-powered analysis.</div>'));
|
|
3321
3359
|
} else if (data.standalone) {
|
|
3322
3360
|
html += '<div class="last-updated">Last updated: ' + esc(ts) +
|
|
3323
|
-
(data.runtime === 'codex' ? ' · Optimization data is limited until Codex session logs are collected.</div>' : ' · Optimization data not available in standalone mode. Run <span class="update-cmd">/token-optimizer</span> for a full audit with recommendations.</div>');
|
|
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>'));
|
|
3324
3362
|
} else {
|
|
3325
3363
|
html += '<div class="last-updated">Last updated: ' + esc(ts) +
|
|
3326
|
-
(data.runtime === 'codex' ? ' · To refresh, use the Codex dashboard refresh command.</div>' : ' · To refresh, run <span class="update-cmd">/token-optimizer</span> again.</div>');
|
|
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>'));
|
|
3327
3365
|
}
|
|
3328
3366
|
|
|
3329
3367
|
if (secItems.length === 0) {
|
|
3330
3368
|
if (!data.plan && !data.auto_plan) {
|
|
3331
3369
|
html += '<div class="empty-state" style="text-align:center;padding:2rem 1rem;">' +
|
|
3332
3370
|
'<div style="font-size:1.5rem;margin-bottom:0.5rem;">No optimization plan yet</div>' +
|
|
3333
|
-
'<div style="color:var(--c-text-dim);margin-bottom:1rem;">' + (data.runtime === 'codex' ? 'Use live Codex sessions and refresh the dashboard to generate personalized recommendations with toggle items here.' : 'Run <span class="update-cmd" style="cursor:pointer">/token-optimizer</span> in ' + esc(data.runtime_label || 'Claude Code') + ' to generate personalized recommendations with toggle items here.') + '</div>' +
|
|
3371
|
+
'<div style="color:var(--c-text-dim);margin-bottom:1rem;">' + (data.runtime === 'codex' ? 'Use live Codex sessions and refresh the dashboard to generate personalized recommendations with toggle items here.' : (isNoInstructionHost(data) ? 'Refresh the dashboard to generate recommendations from your ' + esc(data.runtime_label || 'runtime') + ' config here.' : 'Run <span class="update-cmd" style="cursor:pointer">/token-optimizer</span> in ' + esc(data.runtime_label || 'Claude Code') + ' to generate personalized recommendations with toggle items here.')) + '</div>' +
|
|
3334
3372
|
'</div>';
|
|
3335
3373
|
} else {
|
|
3336
3374
|
html += '<div class="empty-state">No items in this category.</div>';
|
|
@@ -3490,34 +3528,23 @@ var DB = (function() {
|
|
|
3490
3528
|
// renderSavings render it identically without duplicating the body logic.
|
|
3491
3529
|
// Reads trends data from the global `data`; the savings object is passed as
|
|
3492
3530
|
// `savings` (data.savings in renderTrends, the in-scope `s` in renderSavings).
|
|
3493
|
-
// SPENT =
|
|
3494
|
-
//
|
|
3495
|
-
// transcripts, with cache read/write classes excluded. NOT sum(model_mix):
|
|
3531
|
+
// SPENT = deduplicated fresh input + output on actual activity days.
|
|
3532
|
+
// Cache reads and writes are excluded. NOT sum(model_mix):
|
|
3496
3533
|
// model_mix can omit unattributed tokens. Fail-open to that sum rather than 0.
|
|
3497
|
-
// SAVED = savings.total_tokens. Fail-open:
|
|
3498
|
-
// entirely);
|
|
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.
|
|
3499
3538
|
// The model-mix "where the spent went" bar reconciles to SPENT via a trailing
|
|
3500
3539
|
// "untracked" segment for SPENT - sum(model_mix) (tokens billed without a
|
|
3501
3540
|
// model tag). Returns '' when the card should not render.
|
|
3502
3541
|
function tokensSavedCardHtml(savings) {
|
|
3503
3542
|
var s = savings || {};
|
|
3504
3543
|
var tsSavedTokens = Number(s.total_tokens) || 0;
|
|
3505
|
-
if (tsSavedTokens <= 0) return '';
|
|
3506
|
-
var tsTrends = data.trends || {};
|
|
3507
|
-
var tsSpentBasis = tsTrends.spent_token_basis || {};
|
|
3508
|
-
var tsModelMix = tsTrends.model_mix || {};
|
|
3509
|
-
var tsModelTotal = 0;
|
|
3510
|
-
for (var tsMk in tsModelMix) { tsModelTotal += tsModelMix[tsMk]; }
|
|
3511
|
-
var tsIsCodex = data.runtime === 'codex';
|
|
3512
|
-
var tsPeriodDays = Number(tsTrends.period_days) || Number(s.period_days) || 30;
|
|
3513
|
-
// SPENT = provider-stats-compatible total, fail-open to sum(model_mix).
|
|
3514
|
-
var tsReportedTotal = Number(tsTrends.total_tokens) || 0;
|
|
3515
|
-
var tsSpentTokens = tsReportedTotal > 0 ? tsReportedTotal : tsModelTotal;
|
|
3516
|
-
// (tsWouldSendTotal / percentages are computed below, AFTER the estimated
|
|
3517
|
-
// tier is summed: the card headlines the FULL saved total in every state.)
|
|
3518
3544
|
// Estimated-tier tokens (kept OUT of the measured SAVED total by
|
|
3519
|
-
// _get_savings_summary). Surfaced
|
|
3520
|
-
//
|
|
3545
|
+
// _get_savings_summary). Surfaced in the footer as the estimated slice,
|
|
3546
|
+
// labelled with whichever estimated categories are present, and they keep
|
|
3547
|
+
// the card alive when the measured floor is zero.
|
|
3521
3548
|
// Field names match _get_merged_savings' re-export: mcp_cap_estimated
|
|
3522
3549
|
// keeps its suffix; hint_followed and verbosity_steer drop the _estimated
|
|
3523
3550
|
// suffix (the summary's *_estimated locals are re-keyed without it).
|
|
@@ -3540,8 +3567,25 @@ var DB = (function() {
|
|
|
3540
3567
|
var tk = Number(obj && obj.tokens_saved) || 0;
|
|
3541
3568
|
if (tk > 0) tsEstItems.push({ label: label, tokens: tk });
|
|
3542
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');
|
|
3543
3574
|
var tsEstTokens = tsEstItems.reduce(function(a, b) { return a + b.tokens; }, 0);
|
|
3544
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.)
|
|
3545
3589
|
// FULL saved total = measured floor + estimated tier. The headline is
|
|
3546
3590
|
// ALWAYS the full number, never the floor alone; the measured-vs-estimated
|
|
3547
3591
|
// split stays visible right under it so the honesty travels with the size,
|
|
@@ -3614,6 +3658,10 @@ var DB = (function() {
|
|
|
3614
3658
|
return;
|
|
3615
3659
|
}
|
|
3616
3660
|
|
|
3661
|
+
if (t.activity_coverage && t.activity_coverage.complete === false) {
|
|
3662
|
+
html += '<div class="empty-state">Usage coverage incomplete: ' + fn(t.activity_coverage.undated_sessions || 0) + ' sessions have missing activity dates. Undated usage is excluded from period totals.</div>';
|
|
3663
|
+
}
|
|
3664
|
+
|
|
3617
3665
|
// Pricing tier display
|
|
3618
3666
|
var tierLabel = (data.pricing_tier_label || t.pricing_tier_label || (isCodex ? 'OpenAI API-equivalent pricing' : 'Anthropic API'));
|
|
3619
3667
|
var tiers = data.pricing_tiers || {};
|
|
@@ -3703,7 +3751,7 @@ var DB = (function() {
|
|
|
3703
3751
|
// hoisted tokensSavedCardHtml + modelMixBodyHtml helpers). Replaces the
|
|
3704
3752
|
// former standalone Model Mix card — the model-mix-as-usage section is
|
|
3705
3753
|
// now inside the Tokens Saved card, reconciled to the billable SPENT.
|
|
3706
|
-
// Fail-open: returns '' when
|
|
3754
|
+
// Fail-open: returns '' only when measured AND estimated are both ≤ 0.
|
|
3707
3755
|
html += tokensSavedCardHtml(data.savings || {});
|
|
3708
3756
|
|
|
3709
3757
|
// Daily breakdown with date navigation
|
|
@@ -4247,12 +4295,57 @@ var DB = (function() {
|
|
|
4247
4295
|
: '<div class="metric-large" style="text-wrap:balance;text-shadow:none;">' + (usdHeadline || '<em style="font-style:normal;color:var(--c-accent-cyan);">more work</em>') + '</div>');
|
|
4248
4296
|
// Visible: one short plain line. The technical explanation of how each
|
|
4249
4297
|
// figure is built goes to the fold at the bottom of the card.
|
|
4298
|
+
// Lever copy follows each factor's own value: a routing factor below 1 is
|
|
4299
|
+
// a heavier mix and is never called lighter; pending or unavailable
|
|
4300
|
+
// routing is stated instead of shown as a number.
|
|
4301
|
+
var rwContextMult = Number(rw.context_multiplier);
|
|
4302
|
+
var rwContextLighter = isFinite(rwContextMult) && rwContextMult > 1;
|
|
4303
|
+
var rwContextText = rwContextLighter
|
|
4304
|
+
? 'Lighter context (×' + rw.context_multiplier + ')'
|
|
4305
|
+
: 'Context is unchanged (×1)';
|
|
4306
|
+
var rwRoutingMult = rw.routing_multiplier == null ? NaN : Number(rw.routing_multiplier);
|
|
4307
|
+
var rwRoutingKnown = isFinite(rwRoutingMult) && rwRoutingMult > 0;
|
|
4308
|
+
var rwPendingSessions = Number(rw.routing_pending_sessions);
|
|
4309
|
+
var rwRoutingMissing = rw.routing_state === 'pending'
|
|
4310
|
+
? 'model routing is pending while ' + (rwPendingSessions > 0 ? rwPendingSessions + ' sessions are' : 'sessions are') + ' re-measured, so it is not included yet'
|
|
4311
|
+
: 'model routing could not be measured, so it is not included';
|
|
4312
|
+
var rwLeverDetail;
|
|
4313
|
+
if (rwRoutingKnown && rwRoutingMult > 1) {
|
|
4314
|
+
rwLeverDetail = rwContextText + (rwContextLighter
|
|
4315
|
+
? ' and a lighter model mix (×' + rwRoutingMult + ') let each token do more.'
|
|
4316
|
+
: '; a lighter model mix (×' + rwRoutingMult + ') lets each token do more.');
|
|
4317
|
+
} else if (rwRoutingKnown && rwRoutingMult < 1) {
|
|
4318
|
+
rwLeverDetail = rwContextText + (rwContextLighter ? ' lets each token do more; a' : '; a') + ' heavier model mix (×' + rwRoutingMult + ') means each token uses more of your plan.';
|
|
4319
|
+
} else if (rwRoutingKnown) {
|
|
4320
|
+
rwLeverDetail = rwContextText + (rwContextLighter ? ' lets each token do more;' : ';') + ' the model mix is unchanged (×1).';
|
|
4321
|
+
} else {
|
|
4322
|
+
rwLeverDetail = rwContextText + (rwContextLighter ? ' lets each token do more;' : ';') + ' ' + rwRoutingMissing + '.';
|
|
4323
|
+
}
|
|
4324
|
+
var rwRoutingMethod = rwRoutingKnown
|
|
4325
|
+
? 'model mix ×' + rwRoutingMult + ' (above 1 lighter, below 1 heavier, from the routing estimate on the Savings tab)'
|
|
4326
|
+
: 'no model-mix factor (' + (rw.routing_state === 'pending' ? 'routing pending' : 'routing unavailable') + ')';
|
|
4327
|
+
var rwRoutingCoverage = Number(rw.routing_coverage);
|
|
4328
|
+
var rwRoutingExcluded = rw.routing_excluded_models || {};
|
|
4329
|
+
var rwRoutingOut = [].concat(rwRoutingExcluded.premium || [], rwRoutingExcluded.unpriced || [], rwRoutingExcluded.free || []);
|
|
4330
|
+
// The coverage line names the window the snapshot actually computed over
|
|
4331
|
+
// (routing_window_days); payloads from before the field fall back to 30.
|
|
4332
|
+
var rwRoutingDays = Number(rw.routing_window_days);
|
|
4333
|
+
if (!isFinite(rwRoutingDays) || rwRoutingDays <= 0) rwRoutingDays = 30;
|
|
4334
|
+
var rwRoutingWindowTxt = 'the last ' + rwRoutingDays + (rwRoutingDays === 1 ? ' day’s' : ' days’');
|
|
4335
|
+
var rwRoutingScope = (rwRoutingKnown && isFinite(rwRoutingCoverage) && rwRoutingCoverage > 0)
|
|
4336
|
+
? ' The model mix compares ' + Math.round(rwRoutingCoverage * 100) + '% of ' + rwRoutingWindowTxt + ' tokens' + (rwRoutingOut.length ? '; left out: ' + esc(rwRoutingOut.join(', ')) : '') + '.'
|
|
4337
|
+
: '';
|
|
4338
|
+
var rwRoutingUnsplit = Number(rw.routing_unsplit_tokens);
|
|
4339
|
+
if (rwRoutingUnsplit > 0) {
|
|
4340
|
+
rwRoutingScope += ' Left out of the model-mix comparison: ' + fn(rwRoutingUnsplit) + ' tokens without a token-class split.';
|
|
4341
|
+
}
|
|
4250
4342
|
var rwEfficiencyDetail = rwHasCostEfficiency
|
|
4251
4343
|
? 'A comparable session fell from <strong>' + rwMoney(rwBeforeCost) + '</strong> to <strong>' + rwMoney(rwAfterCost) + '</strong>' + (rwCostCutDisplay !== null ? ' (about ' + rwCostCutDisplay + '% cheaper)' : '') + '.'
|
|
4252
|
-
:
|
|
4344
|
+
: rwLeverDetail;
|
|
4253
4345
|
var rwEfficiencyMethod = rwHasCostEfficiency
|
|
4254
4346
|
? 'This cost-efficiency lens combines lighter context, the cache re-read cascade, and model routing.'
|
|
4255
|
-
: '
|
|
4347
|
+
: 'Context ×' + rw.context_multiplier + ' and ' + rwRoutingMethod + ' give a per-token throughput multiplier, shown separately from the window headroom and dollar figures.';
|
|
4348
|
+
rwEfficiencyMethod += rwRoutingScope;
|
|
4256
4349
|
var rwTokenFloorDetail = (rwTokenFloorPct !== null)
|
|
4257
4350
|
? '<div class="plain-line">About <strong>' + fn(rwSavedTokens) + '</strong> tokens never had to be sent, roughly ' + rwTokenFloorPct + '% of what would have been.</div>'
|
|
4258
4351
|
: '';
|
|
@@ -4285,7 +4378,7 @@ var DB = (function() {
|
|
|
4285
4378
|
// limits.", a continuation of the headline that reads as a truncated
|
|
4286
4379
|
// fragment once it wraps to its own line, and the limit panels below
|
|
4287
4380
|
// already establish which limits are meant.
|
|
4288
|
-
'<p style="margin:var(--s-3) 0 var(--s-4);color:var(--c-text-main);font-size:17px;line-height:1.6;text-wrap:pretty;">Token Optimizer keeps junk out of context and runs routine turns on lighter models, so more of your plan goes to real work instead of waste.</p>' +
|
|
4381
|
+
'<p style="margin:var(--s-3) 0 var(--s-4);color:var(--c-text-main);font-size:17px;line-height:1.6;text-wrap:pretty;">Token Optimizer keeps junk out of context' + (rwRoutingKnown && rwRoutingMult > 1 ? ' and runs routine turns on lighter models' : '') + ', so more of your plan goes to real work instead of waste.</p>' +
|
|
4289
4382
|
// Per-window bars when the meter is fresh enough; otherwise a note so the
|
|
4290
4383
|
// card degrades instead of vanishing (the multiplier + savings above still
|
|
4291
4384
|
// stand without the live meter).
|
|
@@ -4354,7 +4447,9 @@ var DB = (function() {
|
|
|
4354
4447
|
(rwTokenFloorMethod ? '<p>' + rwTokenFloorMethod + '</p>' : '') +
|
|
4355
4448
|
'<p>' + (rwHasCostEfficiency
|
|
4356
4449
|
? 'The ≈' + rwEfficiencyMult.toFixed(1) + '× figure is the before/after per-session cost ratio, not a sum of the token floor or per-window dollar figures.'
|
|
4357
|
-
:
|
|
4450
|
+
: (rwHasLegacyMultiplier
|
|
4451
|
+
? 'The ≈' + rw.extra_work_pct + '% is a separate per-token throughput multiplier, not a sum of the per-window dollar figures.'
|
|
4452
|
+
: 'The per-token throughput multiplier is separate from the per-window dollar figures.')) + '</p>' +
|
|
4358
4453
|
'</div></details>' +
|
|
4359
4454
|
'</div>' +
|
|
4360
4455
|
'</div>';
|
|
@@ -4440,11 +4535,13 @@ var DB = (function() {
|
|
|
4440
4535
|
var rs = s.retrieval_serve || {};
|
|
4441
4536
|
var rle = s.resume_lean_estimated || {};
|
|
4442
4537
|
var vs = s.verbosity_steer || {};
|
|
4538
|
+
var cr = s.checkpoint_restore_estimated || {};
|
|
4443
4539
|
var cp = s.counted_period || {};
|
|
4444
4540
|
var rereadMo = cp.available ? mo(cp.reread_usd) : 0;
|
|
4445
4541
|
var hf = s.hint_followed || {};
|
|
4446
|
-
// Avoided-search: prefer the
|
|
4447
|
-
//
|
|
4542
|
+
// Avoided-search: prefer the hint->read estimate (hint_followed; the
|
|
4543
|
+
// hint->read pair is observed, the avoided-search magnitude is a fixed
|
|
4544
|
+
// estimate); fall back to the cohort estimate only before any hint has
|
|
4448
4545
|
// fired, so the two are never summed (no double-count).
|
|
4449
4546
|
var hfHasData = (Number(hf.events) || 0) > 0;
|
|
4450
4547
|
var avoidedSearchMo = hfHasData ? mo(hf.cost_saved_usd) : mo(rs.cost_saved_usd);
|
|
@@ -4457,7 +4554,7 @@ var DB = (function() {
|
|
|
4457
4554
|
// always reconcile exactly to gettingMo (measured + estimated). Every estItems
|
|
4458
4555
|
// entry maps to exactly one pillar: loops/sub-agent/mcp_cap -> runtime;
|
|
4459
4556
|
// heeded/handover/avoided-search/lean-resumes -> behavioral.
|
|
4460
|
-
var behavMo = mo(mr.realized_cost_usd) + 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);
|
|
4557
|
+
var behavMo = mo(mr.realized_cost_usd) + 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);
|
|
4461
4558
|
// ---- trust tiers: measured / estimated / opportunity. Opportunity NEVER folds into the headline. ----
|
|
4462
4559
|
// Measured = billable events we metered (runtime compression + realized model routing).
|
|
4463
4560
|
// Routing joins the measured tier only when its valuation is measured; the
|
|
@@ -4473,8 +4570,9 @@ var DB = (function() {
|
|
|
4473
4570
|
{ key: 'mcp_cap_estimated', label: 'MCP output cap', amt: mo(mce.cost_saved_usd), n: Number(mce.events) || 0, unit: 'capped results' },
|
|
4474
4571
|
{ 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 },
|
|
4475
4572
|
{ key: 'handover_rerun', label: 'continuity handover', amt: mo(hr.cost_saved_usd), n: Number(hr.restored_sessions) || 0, unit: 'restored', conf: hr.confidence },
|
|
4476
|
-
{ key: 'avoided_search', label: 'avoided search (hints)', amt: avoidedSearchMo, n: avoidedSearchN, unit: avoidedSearchUnit, conf: hfHasData ? 'observed' : rs.confidence },
|
|
4573
|
+
{ key: 'avoided_search', label: 'avoided search (hints)', amt: avoidedSearchMo, n: avoidedSearchN, unit: avoidedSearchUnit, conf: hfHasData ? 'trigger observed, size estimated' : rs.confidence },
|
|
4477
4574
|
{ key: 'resume_lean_estimated', label: 'lean resumes (cold reload avoided)', amt: mo(rle.cost_saved_usd), n: Number(rle.events) || 0, unit: 'resumes' },
|
|
4575
|
+
{ key: 'checkpoint_restore_estimated', label: 'checkpoint restores (working-set re-reads)', amt: mo(cr.cost_saved_usd), n: Number(cr.events) || 0, unit: 'restores' },
|
|
4478
4576
|
{ key: 'verbosity_steer', label: 'concise output nudges', amt: mo(vs.cost_saved_usd), n: Number(vs.events) || 0, unit: 'nudges' }
|
|
4479
4577
|
].filter(function(it){ return it.amt > 0 || it.conf; });
|
|
4480
4578
|
var estimatedMo = estItems.reduce(function(a, b){ return a + b.amt; }, 0);
|
|
@@ -4570,6 +4668,14 @@ var DB = (function() {
|
|
|
4570
4668
|
// larger, uncapped percentage implied by the counterfactual arms.
|
|
4571
4669
|
var shownSaving = Number(ba.monthly_savings_usd) || 0;
|
|
4572
4670
|
var costCut = oldCost > 0 ? Math.max(0, shownSaving / oldCost * 100) : 0;
|
|
4671
|
+
// A neutral add-back reprice (routing pending or unavailable) shrinks the
|
|
4672
|
+
// transformation figure without any visible reason -- say why, plainly.
|
|
4673
|
+
var baRepriceBasis = ba.compression_reprice_basis;
|
|
4674
|
+
var baRepriceNote = (baRepriceBasis === 'routing_pending')
|
|
4675
|
+
? 'Model-mix repricing is paused while sessions finish re-measuring, so the add-backs in this estimate show their measured value.'
|
|
4676
|
+
: (baRepriceBasis === 'routing_unavailable'
|
|
4677
|
+
? 'Model-mix repricing could not be measured, so the add-backs in this estimate show their measured value.'
|
|
4678
|
+
: '');
|
|
4573
4679
|
html += '<div class="card wide savings-transformation" style="padding:var(--s-4);margin-bottom:var(--s-3);">' +
|
|
4574
4680
|
'<div class="label">Transformation · last ' + days + ' days · estimated</div>' +
|
|
4575
4681
|
'<div class="savings-amount">' + money(ba.monthly_savings_usd) +
|
|
@@ -4578,6 +4684,7 @@ var DB = (function() {
|
|
|
4578
4684
|
'<div class="savings-split"><span>Now <strong>' + money(nowCost) + '</strong></span>' +
|
|
4579
4685
|
'<span>Earlier workflow <strong>' + money(oldCost) + '</strong></span></div>' +
|
|
4580
4686
|
'<div class="plain-line">Overlaps with the action savings below. Do not add the two totals.</div>' +
|
|
4687
|
+
(baRepriceNote ? '<div class="plain-line">' + baRepriceNote + '</div>' : '') +
|
|
4581
4688
|
fold('How this is estimated',
|
|
4582
4689
|
countedList([ba.savings_capped && ba.savings_cap_note ? esc(ba.savings_cap_note) : '']) +
|
|
4583
4690
|
(wp
|
|
@@ -4684,6 +4791,12 @@ var DB = (function() {
|
|
|
4684
4791
|
(mr.evidence === 'pending'
|
|
4685
4792
|
? '<p class="plain-line routing-pending">Model routing: re-measuring (' + Number(mr.pending_sessions || 0).toLocaleString() +
|
|
4686
4793
|
' session' + (Number(mr.pending_sessions) === 1 ? '' : 's') + ' left). It is added to this total when the re-measurement finishes.</p>' : '') +
|
|
4794
|
+
// Usage without a token-class split (Cursor totals, model-daily-only
|
|
4795
|
+
// history, legacy rows) sits outside both routing arms. Say so instead of
|
|
4796
|
+
// letting an empty or partial routing figure read as complete coverage.
|
|
4797
|
+
(Number(mr.unsplit_tokens) > 0
|
|
4798
|
+
? '<p class="plain-line">' + Number(mr.unsplit_tokens).toLocaleString() +
|
|
4799
|
+
' tokens without a token-class split are left out of model routing.</p>' : '') +
|
|
4687
4800
|
fold('Breakdown and method',
|
|
4688
4801
|
countedList([
|
|
4689
4802
|
'Includes the later benefit of context removed during this period. Initial removals are counted once.',
|
|
@@ -4761,6 +4874,9 @@ var DB = (function() {
|
|
|
4761
4874
|
'<p class="plain-line">Same four parts as the monthly total, added up since install.</p>' +
|
|
4762
4875
|
fold('Breakdown and history',
|
|
4763
4876
|
'<p>Model routing: <strong>' + money(siaRouting) + '</strong> (estimated).</p>' +
|
|
4877
|
+
(Number(sia.routing_unsplit_tokens) > 0
|
|
4878
|
+
? '<p>' + Number(sia.routing_unsplit_tokens).toLocaleString() +
|
|
4879
|
+
' tokens without a token-class split are left out of model routing.</p>' : '') +
|
|
4764
4880
|
'<p>Repeat reads avoided: <strong>' + money(siaParts.reread) + '</strong> (modeled).</p>' +
|
|
4765
4881
|
'<p>Logged actions: <strong>' + money(siaParts.logged) + '</strong>.</p>' +
|
|
4766
4882
|
'<p>Other estimates: <strong>' + money(sia.estimated_usd) + '</strong>.</p>' +
|
|
@@ -4879,7 +4995,7 @@ var DB = (function() {
|
|
|
4879
4995
|
'<div style="font-size:18px;color:var(--c-text-main);line-height:1.7;max-width:760px;">' + esc(p) + '</div></div>';
|
|
4880
4996
|
});
|
|
4881
4997
|
html += '</div>';
|
|
4882
|
-
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-amber);">/token-optimizer</span> and follow its suggestions to claim the rest →</div>';
|
|
4998
|
+
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-amber);">/token-optimizer</span> and follow its suggestions to claim the rest →</div>';
|
|
4883
4999
|
html += '</details></div>';
|
|
4884
5000
|
}
|
|
4885
5001
|
|
|
@@ -5320,11 +5436,19 @@ var DB = (function() {
|
|
|
5320
5436
|
{ key: 'stale_reads', label: 'Stale Reads', icon: '\uD83D\uDCC4', tip: 'Files read earlier that have since changed. The model may be working with outdated content.' },
|
|
5321
5437
|
{ key: 'bloated_results', label: 'Bloated Results', icon: '\uD83D\uDCE6', tip: 'Tool outputs sitting in context that were never referenced. Wasted space.' },
|
|
5322
5438
|
{ key: 'duplicates', label: 'Duplicates', icon: '\uD83D\uDD04', tip: 'Same system reminders or content injected multiple times. Pure waste.' },
|
|
5323
|
-
{ key: 'compaction_depth', label: 'Compactions', icon: '\uD83D\uDDDC', tip: 'Each compaction loses 60-70% of conversation. After 2: ~88% gone.' },
|
|
5324
5439
|
{ key: 'decision_density', label: 'Decision Density', icon: '\uD83C\uDFAF', tip: 'Ratio of actual decisions and work vs overhead and boilerplate.' },
|
|
5325
5440
|
{ key: 'agent_efficiency', label: 'Agent Efficiency', icon: '\u2699\uFE0F', tip: 'Whether dispatched agents produced useful output relative to their token cost.' }
|
|
5326
5441
|
];
|
|
5327
5442
|
html += '<div style="padding:0 var(--s-3) var(--s-3);">';
|
|
5443
|
+
// Compactions are metadata, with no health bar or fixed loss claim.
|
|
5444
|
+
var compactData = bd.compactions || bd.compaction_depth;
|
|
5445
|
+
var recoveryData = bd.compaction_recovery;
|
|
5446
|
+
if (compactData || recoveryData) {
|
|
5447
|
+
var compactCount = compactData ? (compactData.count != null ? compactData.count : compactData.compactions) : q.compactions;
|
|
5448
|
+
html += '<div style="display:flex;flex-wrap:wrap;gap:var(--s-2);margin-bottom:10px;font-size:15px;color:var(--c-text-dim);">' +
|
|
5449
|
+
'<span>Compactions: ' + esc(compactCount == null ? 'unknown' : compactCount + ' compactions') + '</span>' +
|
|
5450
|
+
'<span>Recovery: ' + (compactCount === 0 ? 'no compactions' : 'observing') + '</span></div>';
|
|
5451
|
+
}
|
|
5328
5452
|
signals.forEach(function(sig) {
|
|
5329
5453
|
var d = bd[sig.key];
|
|
5330
5454
|
if (!d) return;
|
|
@@ -5493,7 +5617,7 @@ var DB = (function() {
|
|
|
5493
5617
|
|
|
5494
5618
|
// Snapshot summary
|
|
5495
5619
|
var snap = c.snapshot || {};
|
|
5496
|
-
var instructionLabel = snap.instruction_label || (isCodex ? 'AGENTS.md' : 'CLAUDE.md');
|
|
5620
|
+
var instructionLabel = snap.instruction_label || (isCodex ? 'AGENTS.md' : isNoInstructionHost(data) ? 'agent instructions' : 'CLAUDE.md');
|
|
5497
5621
|
html += '<div class="dashboard-grid">' +
|
|
5498
5622
|
'<div class="card"><div class="card-header"><span>Startup Overhead</span></div>' +
|
|
5499
5623
|
'<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>' +
|
|
@@ -5939,7 +6063,7 @@ var DB = (function() {
|
|
|
5939
6063
|
: m && m.read_only
|
|
5940
6064
|
? 'Your ' + esc(data.runtime_label || 'runtime') + ' skills and MCP servers, read from its own files. Token Optimizer feature toggles are below.'
|
|
5941
6065
|
: window.__TOKEN_API_LIVE
|
|
5942
|
-
? '<span style="color:var(--c-accent-cyan);font-weight:600;">Live mode</span> — toggles apply instantly to settings. <strong>Restart ' + (isCodex ? 'Codex' : 'Claude') + '</strong> to activate changes.'
|
|
6066
|
+
? '<span style="color:var(--c-accent-cyan);font-weight:600;">Live mode</span> — toggles apply instantly to settings. <strong>Restart ' + (isCodex ? 'Codex' : isNoInstructionHost(data) ? esc(data.runtime_label || 'the runtime') : 'Claude') + '</strong> to activate changes.'
|
|
5943
6067
|
: tcliHtml('Open in serve mode for live toggles: <code style="background:var(--c-bg);padding:2px 5px;border-radius:4px;">python3 measure.py dashboard --serve</code>')) +
|
|
5944
6068
|
'</p>' +
|
|
5945
6069
|
'</div>';
|
|
@@ -5948,6 +6072,7 @@ var DB = (function() {
|
|
|
5948
6072
|
html += '<div style="padding:12px var(--s-3);margin-bottom:var(--s-2);background:var(--c-bg);border-left:3px solid var(--c-accent-cyan);border-radius:4px;font-size:14px;color:var(--c-text-dim);">' +
|
|
5949
6073
|
(isCodex
|
|
5950
6074
|
? 'Showing default Codex feature state. Run a Codex dashboard refresh to reflect your actual config.'
|
|
6075
|
+
: isNoInstructionHost(data) ? 'Showing default feature state.'
|
|
5951
6076
|
: 'Showing default feature state. Run <code style="background:var(--c-bg);padding:2px 5px;border-radius:4px;">/token-optimizer</code> once to reflect your actual config and enable live toggles.') +
|
|
5952
6077
|
'</div>';
|
|
5953
6078
|
}
|
|
@@ -6164,8 +6289,19 @@ var DB = (function() {
|
|
|
6164
6289
|
'\'s own skills folder and config.yaml. Change them in ' + esc(roLabel) + '; this list updates on the next refresh.</p>';
|
|
6165
6290
|
}
|
|
6166
6291
|
|
|
6292
|
+
// --- NO SKILL/MCP MANAGEMENT (Cursor, Antigravity) ---
|
|
6293
|
+
// The skill and MCP controls below act on a Claude Code setup, so they are
|
|
6294
|
+
// not shown for runtimes that have no such folder.
|
|
6295
|
+
if (isNoInstructionHost(data)) {
|
|
6296
|
+
html += '<div class="card wide"><div class="card-header"><span>Skills and MCP servers</span></div>' +
|
|
6297
|
+
'<div style="padding:var(--s-3);color:var(--c-text-dim);font-size:14px;line-height:1.6;">' +
|
|
6298
|
+
'Skill and MCP management is not available under ' + esc(data.runtime_label || 'this runtime') +
|
|
6299
|
+
'. It applies to a Claude Code setup, and Token Optimizer does not change ' + esc(data.runtime_label || 'this runtime') + ' skills or servers.' +
|
|
6300
|
+
'</div></div>';
|
|
6301
|
+
}
|
|
6302
|
+
|
|
6167
6303
|
// --- SKILLS SECTION ---
|
|
6168
|
-
if (!isCodex && !m.read_only) {
|
|
6304
|
+
if (!isCodex && !m.read_only && !isNoInstructionHost(data)) {
|
|
6169
6305
|
var activeSkills = (m.skills && m.skills.active) || [];
|
|
6170
6306
|
var archivedSkills = (m.skills && m.skills.archived) || [];
|
|
6171
6307
|
var totalTokens = activeSkills.reduce(function(s, sk) { return s + (sk.tokens || 100); }, 0);
|
|
@@ -6537,7 +6673,7 @@ var DB = (function() {
|
|
|
6537
6673
|
|
|
6538
6674
|
if (count === 0) {
|
|
6539
6675
|
if (!data.plan && !data.auto_plan) {
|
|
6540
|
-
listEl.innerHTML = '<div class="empty-state">Run <span class="update-cmd">/token-optimizer</span> to generate optimization items you can toggle here.</div>';
|
|
6676
|
+
listEl.innerHTML = (isNoInstructionHost(data) ? '<div class="empty-state">No optimization items to toggle for ' + esc(data.runtime_label || 'this runtime') + ' yet.</div>' : '<div class="empty-state">Run <span class="update-cmd">/token-optimizer</span> to generate optimization items you can toggle here.</div>');
|
|
6541
6677
|
} else {
|
|
6542
6678
|
listEl.innerHTML = '<div class="empty-state">Toggle items in Quick Wins, Medium, or Deep to build your optimization prompt.</div>';
|
|
6543
6679
|
}
|
|
@@ -446,7 +446,10 @@ Output file: {COORD_PATH}/audit/advanced.md
|
|
|
446
446
|
- Does the user have ANY model routing guidance? (Yes/No)
|
|
447
447
|
- If yes, is it specific (task-to-model table) or vague ("use appropriate models")?
|
|
448
448
|
b. If measure.py trends DB exists (~/.claude/_backups/token-optimizer/trends.db):
|
|
449
|
-
- Run:
|
|
449
|
+
- Run: "$PY" "$MEASURE_PY" trends --json --days 30
|
|
450
|
+
(if either variable is unset in your shell, re-resolve them with the
|
|
451
|
+
SKILL.md Step 0b snippet first; `$PY` is the verified interpreter, never
|
|
452
|
+
the bare `python3` name)
|
|
450
453
|
- If the command fails (non-zero exit) or output is not valid JSON (e.g., prints
|
|
451
454
|
"No session logs found"), treat as "no trends data" and skip to step (d)
|
|
452
455
|
- The JSON output has raw token counts per full model ID (a full id such as a dated Haiku id mapped to a count, e.g. 50000).
|
|
@@ -41,21 +41,39 @@ done <<EOF
|
|
|
41
41
|
$(find -L "$HOME/.claude/skills" "$HOME/.claude/plugins/cache" "$HOME/.claude/token-optimizer" "$HOME/.codex/skills" "$HOME/.codex/plugins/cache" "$HOME/.config/opencode/plugins" -type f -name measure.py -path '*token-optimizer*/scripts/measure.py' 2>/dev/null)
|
|
42
42
|
EOF
|
|
43
43
|
if [ -z "$MEASURE_PY" ]; then echo "[Error] measure.py not found. Is Token Optimizer installed?"; exit 1; fi
|
|
44
|
-
|
|
44
|
+
|
|
45
|
+
# Resolve an interpreter that really runs Python. On native-Windows Git Bash
|
|
46
|
+
# `python3` is often the Microsoft Store alias stub, which prints "Python was
|
|
47
|
+
# not found" instead of running -- and a gate piped to `head` then looks like
|
|
48
|
+
# a pass (#301). Probe `python` first there, `python3` first elsewhere, and
|
|
49
|
+
# accept only a clean >=3.9 version reply (same ladder install.sh uses).
|
|
50
|
+
PY=""; _py_candidates="python3 python"
|
|
51
|
+
case "$(uname -s 2>/dev/null)" in MINGW*|MSYS*|CYGWIN*) _py_candidates="python python3" ;; esac
|
|
52
|
+
for _py in $_py_candidates; do
|
|
53
|
+
command -v "$_py" >/dev/null 2>&1 || continue
|
|
54
|
+
_py_ver="$("$_py" -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")' 2>/dev/null)" || _py_ver=""
|
|
55
|
+
_py_major="$(echo "$_py_ver" | cut -d. -f1)"; _py_minor="$(echo "$_py_ver" | cut -d. -f2)"
|
|
56
|
+
[ -n "$_py_major" ] && [ -n "$_py_minor" ] || continue
|
|
57
|
+
case "$_py_major$_py_minor" in *[!0-9]*) continue ;; esac
|
|
58
|
+
if [ "$_py_major" -lt 3 ] 2>/dev/null || { [ "$_py_major" -eq 3 ] && [ "$_py_minor" -lt 9 ]; } 2>/dev/null; then continue; fi
|
|
59
|
+
PY="$_py"; break
|
|
60
|
+
done
|
|
61
|
+
if [ -z "$PY" ]; then echo "[Error] Python 3.9+ not found (the Windows Store python3 stub does not count). Install Python, then retry."; exit 1; fi
|
|
62
|
+
echo "Using: $MEASURE_PY" >&2
|
|
45
63
|
```
|
|
46
64
|
|
|
47
|
-
Use `TOKEN_OPTIMIZER_RUNTIME=codex
|
|
65
|
+
Use `TOKEN_OPTIMIZER_RUNTIME=codex "$PY" "$MEASURE_PY" ...` for Codex commands.
|
|
48
66
|
|
|
49
67
|
## 1. Start With Chat Status
|
|
50
68
|
|
|
51
69
|
Run these before giving advice:
|
|
52
70
|
|
|
53
71
|
```bash
|
|
54
|
-
TOKEN_OPTIMIZER_RUNTIME=codex
|
|
55
|
-
TOKEN_OPTIMIZER_RUNTIME=codex
|
|
56
|
-
TOKEN_OPTIMIZER_RUNTIME=codex
|
|
57
|
-
TOKEN_OPTIMIZER_RUNTIME=codex
|
|
58
|
-
TOKEN_OPTIMIZER_RUNTIME=codex
|
|
72
|
+
TOKEN_OPTIMIZER_RUNTIME=codex "$PY" "$MEASURE_PY" report
|
|
73
|
+
TOKEN_OPTIMIZER_RUNTIME=codex "$PY" "$MEASURE_PY" coach --json
|
|
74
|
+
TOKEN_OPTIMIZER_RUNTIME=codex "$PY" "$MEASURE_PY" quality current --json
|
|
75
|
+
TOKEN_OPTIMIZER_RUNTIME=codex "$PY" "$MEASURE_PY" codex-state --json
|
|
76
|
+
TOKEN_OPTIMIZER_RUNTIME=codex "$PY" "$MEASURE_PY" codex-doctor --project "$PWD" --json
|
|
59
77
|
```
|
|
60
78
|
|
|
61
79
|
`codex-state` reads Codex's versioned SQLite state read-only (`state_*.sqlite`, `goals_*.sqlite`): subagent count and token cost (with leaked/never-closed subagents), memory overhead from `stage1_outputs`, and goal budget utilization. It is empty-safe when those tables have no rows yet.
|
|
@@ -105,8 +123,8 @@ Use `codex-doctor` as the setup truth source.
|
|
|
105
123
|
If hooks are missing or stale:
|
|
106
124
|
|
|
107
125
|
```bash
|
|
108
|
-
TOKEN_OPTIMIZER_RUNTIME=codex
|
|
109
|
-
TOKEN_OPTIMIZER_RUNTIME=codex
|
|
126
|
+
TOKEN_OPTIMIZER_RUNTIME=codex "$PY" "$MEASURE_PY" codex-install --project "$PWD" --dry-run
|
|
127
|
+
TOKEN_OPTIMIZER_RUNTIME=codex "$PY" "$MEASURE_PY" codex-install --project "$PWD"
|
|
110
128
|
```
|
|
111
129
|
|
|
112
130
|
Default to the balanced profile. Balanced means:
|
|
@@ -120,9 +138,9 @@ Default to the balanced profile. Balanced means:
|
|
|
120
138
|
Only suggest these when the user accepts the tradeoff:
|
|
121
139
|
|
|
122
140
|
```bash
|
|
123
|
-
TOKEN_OPTIMIZER_RUNTIME=codex
|
|
124
|
-
TOKEN_OPTIMIZER_RUNTIME=codex
|
|
125
|
-
TOKEN_OPTIMIZER_RUNTIME=codex
|
|
141
|
+
TOKEN_OPTIMIZER_RUNTIME=codex "$PY" "$MEASURE_PY" codex-install --project "$PWD" --profile quiet
|
|
142
|
+
TOKEN_OPTIMIZER_RUNTIME=codex "$PY" "$MEASURE_PY" codex-install --project "$PWD" --profile telemetry
|
|
143
|
+
TOKEN_OPTIMIZER_RUNTIME=codex "$PY" "$MEASURE_PY" codex-install --project "$PWD" --profile aggressive
|
|
126
144
|
```
|
|
127
145
|
|
|
128
146
|
Quiet is Stop-only. Telemetry adds visible PostToolUse rows. Aggressive enables all current hooks, including experimental Bash PreToolUse. Do not make aggressive the default.
|
|
@@ -34,13 +34,15 @@ The audit phases do not run under Cursor. Use the Cursor-native commands
|
|
|
34
34
|
instead. Manual `cursor-summary` / `cursor-rollup` require the runtime prefix
|
|
35
35
|
(the bridge sets it automatically):
|
|
36
36
|
|
|
37
|
+
Resolve `$MEASURE_PY` and `$PY` first with the SKILL.md Step 0b snippet (this file is followed instead of the audit phases, so they are not set yet).
|
|
38
|
+
|
|
37
39
|
```bash
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
TOKEN_OPTIMIZER_RUNTIME=cursor
|
|
42
|
-
TOKEN_OPTIMIZER_RUNTIME=cursor
|
|
43
|
-
|
|
40
|
+
"$PY" "$MEASURE_PY" cursor-install # wire Token Optimizer into ~/.cursor/hooks.json
|
|
41
|
+
"$PY" "$MEASURE_PY" cursor-doctor # readiness report (checks + fix hints)
|
|
42
|
+
"$PY" "$MEASURE_PY" cursor-doctor --probe # replay each wired event through the installed command
|
|
43
|
+
TOKEN_OPTIMIZER_RUNTIME=cursor "$PY" "$MEASURE_PY" cursor-summary
|
|
44
|
+
TOKEN_OPTIMIZER_RUNTIME=cursor "$PY" "$MEASURE_PY" cursor-rollup
|
|
45
|
+
"$PY" "$MEASURE_PY" cursor-uninstall # remove only Token Optimizer's entries + payload
|
|
44
46
|
```
|
|
45
47
|
|
|
46
48
|
Install from a checkout with `bash install.sh --cursor` (merges into Cursor's
|
|
@@ -67,7 +69,7 @@ If the user genuinely wants to audit a Claude Code setup *from* Cursor (rare),
|
|
|
67
69
|
they can force the runtime:
|
|
68
70
|
|
|
69
71
|
```bash
|
|
70
|
-
TOKEN_OPTIMIZER_RUNTIME=claude
|
|
72
|
+
TOKEN_OPTIMIZER_RUNTIME=claude "$PY" "$MEASURE_PY" report
|
|
71
73
|
```
|
|
72
74
|
|
|
73
75
|
This is opt-in and explicit. The default under Cursor is to never touch
|