claude-code-cost 0.16.0 → 0.17.0
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/package.json +1 -1
- package/public/app.js +45 -13
- package/public/index.html +1 -0
- package/public/style.css +10 -5
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -819,11 +819,11 @@ function renderInsights() {
|
|
|
819
819
|
<div class="stat-card">
|
|
820
820
|
<div class="card-label">Active 5h Block</div>
|
|
821
821
|
<div class="card-value cost">${ab ? formatCost(ab.cost) : '—'}</div>
|
|
822
|
-
<div class="card-sub">${ab ? `${blockHours(ab)} · ${formatDuration(ab.burn.remainingMin)} left${ab.usedPct != null ? ` · ${ab.usedPct}% used` : ''}` : 'no live window data'}</div>
|
|
822
|
+
<div class="card-sub">${ab ? `${blockHours(ab)} · ${formatDuration(ab.burn.remainingMin)} left${ab.usedPct != null ? ` · ${Math.round(ab.usedPct)}% used` : ''}` : 'no live window data'}</div>
|
|
823
823
|
</div>
|
|
824
824
|
<div class="stat-card">
|
|
825
825
|
<div class="card-label">Burn Rate</div>
|
|
826
|
-
<div class="card-value${pace ? `
|
|
826
|
+
<div class="card-value ${esc(pace ? `pace-${pace.cls}` : '')}">${ab ? `${formatCost(ab.burn.costPerHour)}/h` : '—'}</div>
|
|
827
827
|
<div class="card-sub">${ab ? `${formatTokens(Math.round(ab.burn.tokensPerMin))} tok/min · proj. ${formatCost(ab.burn.projectedCost)} by block end${pace ? ` · ${pace.note}` : ''}` : 'no active block'}</div>
|
|
828
828
|
</div>
|
|
829
829
|
<div class="stat-card">
|
|
@@ -1087,9 +1087,8 @@ function renderDetail() {
|
|
|
1087
1087
|
</div>`;
|
|
1088
1088
|
|
|
1089
1089
|
requestAnimationFrame(() => {
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
renderTokenBreakdownChart(parentMessages);
|
|
1090
|
+
renderCumulativeChart(d.messages);
|
|
1091
|
+
renderTokenBreakdownChart(d.messages);
|
|
1093
1092
|
});
|
|
1094
1093
|
}
|
|
1095
1094
|
|
|
@@ -1171,6 +1170,13 @@ function hexToRgba(hex, alpha) {
|
|
|
1171
1170
|
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
1172
1171
|
}
|
|
1173
1172
|
|
|
1173
|
+
// Tooltip title for per-message charts: names the subagent when the point is a folded-in agent run.
|
|
1174
|
+
function messageTooltipTitle(messages, items) {
|
|
1175
|
+
const m = messages[items[0]?.dataIndex];
|
|
1176
|
+
if (!m) return '';
|
|
1177
|
+
return `#${m.index}${m._subagent ? ` · ${m._subagent.agentType}` : ''}`;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1174
1180
|
function chartDefaults() {
|
|
1175
1181
|
const c = getChartColors();
|
|
1176
1182
|
return {
|
|
@@ -1376,7 +1382,7 @@ function renderCumulativeChart(messages) {
|
|
|
1376
1382
|
charts.cumulative = new Chart(canvas, {
|
|
1377
1383
|
type: 'line',
|
|
1378
1384
|
data: {
|
|
1379
|
-
labels: messages.map((
|
|
1385
|
+
labels: messages.map((m) => m.index),
|
|
1380
1386
|
datasets: [
|
|
1381
1387
|
{
|
|
1382
1388
|
label: 'Cumulative Cost',
|
|
@@ -1386,13 +1392,16 @@ function renderCumulativeChart(messages) {
|
|
|
1386
1392
|
fill: true,
|
|
1387
1393
|
borderWidth: 2,
|
|
1388
1394
|
pointRadius: messages.length > 50 ? 0 : 3,
|
|
1389
|
-
|
|
1395
|
+
// Subagent points render hollow so they read as folded-in cost, not main-loop turns.
|
|
1396
|
+
pointBackgroundColor: messages.length > 50 ? c.accent : messages.map((m) => (m._subagent ? c.bg : c.accent)),
|
|
1397
|
+
pointBorderColor: c.accent,
|
|
1390
1398
|
tension: 0.2,
|
|
1391
1399
|
},
|
|
1392
1400
|
],
|
|
1393
1401
|
},
|
|
1394
1402
|
options: {
|
|
1395
1403
|
...defaults,
|
|
1404
|
+
plugins: withTooltip(defaults, { title: (items) => messageTooltipTitle(messages, items) }),
|
|
1396
1405
|
scales: {
|
|
1397
1406
|
...defaults.scales,
|
|
1398
1407
|
x: {
|
|
@@ -1416,23 +1425,39 @@ function renderTokenBreakdownChart(messages) {
|
|
|
1416
1425
|
const c = getChartColors();
|
|
1417
1426
|
const defaults = chartDefaults();
|
|
1418
1427
|
|
|
1428
|
+
// Subagent bars render translucent so they read as folded-in usage, not main-loop turns.
|
|
1429
|
+
const barColors = (hex) => {
|
|
1430
|
+
const faded = hexToRgba(hex, 0.45);
|
|
1431
|
+
return messages.map((m) => (m._subagent ? faded : hex));
|
|
1432
|
+
};
|
|
1433
|
+
|
|
1419
1434
|
charts.tokenBreakdown = new Chart(canvas, {
|
|
1420
1435
|
type: 'bar',
|
|
1421
1436
|
data: {
|
|
1422
|
-
labels: messages.map((
|
|
1437
|
+
labels: messages.map((m) => m.index),
|
|
1423
1438
|
datasets: [
|
|
1424
|
-
{
|
|
1425
|
-
|
|
1439
|
+
{
|
|
1440
|
+
label: 'Input',
|
|
1441
|
+
data: messages.map((m) => m.inputTokens),
|
|
1442
|
+
backgroundColor: barColors(c.chart1),
|
|
1443
|
+
borderRadius: 2,
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
label: 'Output',
|
|
1447
|
+
data: messages.map((m) => m.outputTokens),
|
|
1448
|
+
backgroundColor: barColors(c.chart2),
|
|
1449
|
+
borderRadius: 2,
|
|
1450
|
+
},
|
|
1426
1451
|
{
|
|
1427
1452
|
label: 'Cache Create',
|
|
1428
1453
|
data: messages.map((m) => m.cacheCreationTokens),
|
|
1429
|
-
backgroundColor: c.chart3,
|
|
1454
|
+
backgroundColor: barColors(c.chart3),
|
|
1430
1455
|
borderRadius: 2,
|
|
1431
1456
|
},
|
|
1432
1457
|
{
|
|
1433
1458
|
label: 'Cache Read',
|
|
1434
1459
|
data: messages.map((m) => m.cacheReadTokens),
|
|
1435
|
-
backgroundColor: c.chart4,
|
|
1460
|
+
backgroundColor: barColors(c.chart4),
|
|
1436
1461
|
borderRadius: 2,
|
|
1437
1462
|
},
|
|
1438
1463
|
],
|
|
@@ -1440,7 +1465,7 @@ function renderTokenBreakdownChart(messages) {
|
|
|
1440
1465
|
options: {
|
|
1441
1466
|
...defaults,
|
|
1442
1467
|
plugins: {
|
|
1443
|
-
...defaults
|
|
1468
|
+
...withTooltip(defaults, { title: (items) => messageTooltipTitle(messages, items) }),
|
|
1444
1469
|
legend: {
|
|
1445
1470
|
display: true,
|
|
1446
1471
|
position: 'bottom',
|
|
@@ -2015,6 +2040,8 @@ async function navigate(view, params) {
|
|
|
2015
2040
|
if (view === 'sessions') {
|
|
2016
2041
|
currentSessionId = null;
|
|
2017
2042
|
}
|
|
2043
|
+
// Remember the last top-level tab so a fresh load lands on it again.
|
|
2044
|
+
if (view === 'overview' || view === 'insights') localStorage.setItem('cc-cost:view', view);
|
|
2018
2045
|
|
|
2019
2046
|
updateUrl();
|
|
2020
2047
|
await loadAndRender(view);
|
|
@@ -2566,10 +2593,15 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|
|
2566
2593
|
currentProjectPath = state.project;
|
|
2567
2594
|
currentProjectName = state.projectName;
|
|
2568
2595
|
await navigate('sessions', { project: state.project, projectName: state.projectName });
|
|
2596
|
+
} else if (state.view === 'insights') {
|
|
2597
|
+
await navigate('insights');
|
|
2569
2598
|
} else if (scopeProject) {
|
|
2570
2599
|
// Same landing rule as applyScope: a scope with no cursor of its own opens its sessions.
|
|
2571
2600
|
currentProjectName = scopeProjectName;
|
|
2572
2601
|
await navigate('sessions', { project: scopeProject, projectName: scopeProjectName });
|
|
2602
|
+
} else if (localStorage.getItem('cc-cost:view') === 'insights') {
|
|
2603
|
+
// No nav state for this tab — fall back to the last top-level tab from any session.
|
|
2604
|
+
await navigate('insights');
|
|
2573
2605
|
} else {
|
|
2574
2606
|
await navigate('overview');
|
|
2575
2607
|
}
|
package/public/index.html
CHANGED
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
</button>
|
|
88
88
|
<button class="topbar-btn" id="infoBtn" title="Help & About (?)" onclick="toggleHelpModal()">
|
|
89
89
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><circle cx="12" cy="17" r="0.5" fill="currentColor"/></svg>
|
|
90
|
+
<kbd>?</kbd>
|
|
90
91
|
</button>
|
|
91
92
|
<a class="topbar-btn" href="https://github.com/NikiforovAll/claude-code-cost" target="_blank" rel="noopener" title="GitHub">
|
|
92
93
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" stroke="none"><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>
|
package/public/style.css
CHANGED
|
@@ -47,9 +47,8 @@ body {
|
|
|
47
47
|
background: var(--bg-deep);
|
|
48
48
|
color: var(--text-primary);
|
|
49
49
|
line-height: 1.5;
|
|
50
|
-
height:
|
|
50
|
+
height: 100vh;
|
|
51
51
|
display: flex;
|
|
52
|
-
zoom: 1.1;
|
|
53
52
|
flex-direction: column;
|
|
54
53
|
overflow: hidden;
|
|
55
54
|
-webkit-font-smoothing: antialiased;
|
|
@@ -1158,13 +1157,19 @@ body {
|
|
|
1158
1157
|
color: var(--text-primary);
|
|
1159
1158
|
}
|
|
1160
1159
|
|
|
1161
|
-
|
|
1160
|
+
kbd {
|
|
1162
1161
|
background: var(--bg-hover);
|
|
1163
|
-
padding:
|
|
1162
|
+
padding: 2px 6px;
|
|
1164
1163
|
border-radius: 4px;
|
|
1165
1164
|
font-family: var(--mono);
|
|
1166
1165
|
font-size: 11px;
|
|
1167
1166
|
border: 1px solid var(--border);
|
|
1167
|
+
color: var(--text-secondary);
|
|
1168
|
+
white-space: nowrap;
|
|
1169
|
+
}
|
|
1170
|
+
.topbar-btn kbd {
|
|
1171
|
+
font-size: 10px;
|
|
1172
|
+
line-height: 1;
|
|
1168
1173
|
}
|
|
1169
1174
|
|
|
1170
1175
|
/* #endregion */
|
|
@@ -1324,7 +1329,7 @@ body {
|
|
|
1324
1329
|
body.light {
|
|
1325
1330
|
--bg-deep: #e8e6e3;
|
|
1326
1331
|
--bg-surface: #efede9;
|
|
1327
|
-
--bg-elevated: #
|
|
1332
|
+
--bg-elevated: #f7f4f0;
|
|
1328
1333
|
--bg-hover: #d2d0cc;
|
|
1329
1334
|
--border: #cfcbc4;
|
|
1330
1335
|
--text-primary: #0a0a0a;
|