-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
626 lines (578 loc) · 22.7 KB
/
Copy pathindex.html
File metadata and controls
626 lines (578 loc) · 22.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Claude Code Token Analyzer</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600&display=swap" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.js"></script>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #0d0f12;
--bg2: #13161b;
--bg3: #1a1e25;
--border: #252a33;
--border2: #2e3440;
--text: #e8eaf0;
--text2: #b8bdd0;
--text3: #8890a8;
--green: #4ade9a;
--green-dim: #1a3d2b;
--blue: #60a5fa;
--blue-dim: #1a2a3d;
--amber: #fbbf24;
--amber-dim: #3d2e0a;
--red: #f87171;
--mono: 'IBM Plex Mono', monospace;
--sans: 'IBM Plex Sans', sans-serif;
}
html, body {
background: var(--bg);
color: var(--text);
font-family: var(--sans);
font-size: 14px;
line-height: 1.5;
min-height: 100vh;
}
/* Header */
.header {
border-bottom: 1px solid var(--border);
padding: 0 2rem;
display: flex;
align-items: center;
justify-content: space-between;
height: 52px;
position: sticky;
top: 0;
background: var(--bg);
z-index: 100;
}
.logo {
display: flex;
align-items: center;
gap: 10px;
font-family: var(--mono);
font-size: 13px;
font-weight: 600;
color: var(--text);
letter-spacing: -0.01em;
}
.logo-mark {
width: 22px; height: 22px;
background: var(--green);
border-radius: 4px;
display: flex; align-items: center; justify-content: center;
flex-shrink: 0;
}
.logo-mark svg { width: 12px; height: 12px; }
.header-meta {
font-family: var(--mono);
font-size: 11px;
color: var(--text3);
}
.header-meta a { color: var(--text3); text-decoration: none; }
.header-meta a:hover { color: var(--text2); }
/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem; }
/* Input area */
.input-zone {
background: var(--bg2);
border: 1px solid var(--border);
border-radius: 8px;
padding: 1.25rem;
margin-bottom: 1.5rem;
}
.input-label {
font-family: var(--mono);
font-size: 11px;
color: var(--text3);
text-transform: uppercase;
letter-spacing: 0.08em;
margin-bottom: 0.75rem;
display: flex;
align-items: center;
gap: 6px;
}
.input-label::before {
content: '';
display: inline-block;
width: 6px; height: 6px;
background: var(--green);
border-radius: 50%;
animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.3; }
}
.input-row {
display: flex;
gap: 10px;
align-items: flex-start;
}
textarea {
flex: 1;
background: var(--bg);
border: 1px solid var(--border2);
border-radius: 6px;
color: var(--text);
font-family: var(--mono);
font-size: 11px;
padding: 10px 12px;
height: 80px;
resize: vertical;
outline: none;
transition: border-color 0.15s;
line-height: 1.6;
}
textarea:focus { border-color: var(--green); }
textarea::placeholder { color: var(--text3); }
.btn-group { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
button {
font-family: var(--mono);
font-size: 11px;
font-weight: 500;
padding: 7px 14px;
border-radius: 5px;
border: 1px solid var(--border2);
cursor: pointer;
transition: all 0.15s;
white-space: nowrap;
letter-spacing: 0.02em;
}
.btn-primary {
background: var(--green);
color: #000;
border-color: var(--green);
}
.btn-primary:hover { background: #6ee7b7; }
.btn-secondary {
background: transparent;
color: var(--text2);
}
.btn-secondary:hover { border-color: var(--text2); color: var(--text); }
/* Status bar */
#status-bar {
font-family: var(--mono);
font-size: 11px;
color: var(--text3);
margin-bottom: 1.5rem;
padding: 8px 12px;
background: var(--bg2);
border: 1px solid var(--border);
border-radius: 5px;
display: flex;
align-items: center;
gap: 8px;
}
#status-bar::before { content: '›'; color: var(--green); font-size: 14px; line-height: 1; }
/* Metric grid */
.metric-grid {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: 1px;
background: var(--border);
border: 1px solid var(--border);
border-radius: 8px;
overflow: hidden;
margin-bottom: 1.5rem;
}
.metric {
background: var(--bg2);
padding: 1rem 1.1rem;
position: relative;
}
.metric-label {
font-family: var(--mono);
font-size: 10px;
color: var(--text3);
text-transform: uppercase;
letter-spacing: 0.07em;
margin-bottom: 6px;
}
.metric-value {
font-family: var(--mono);
font-size: 24px;
font-weight: 600;
color: var(--text);
line-height: 1;
margin-bottom: 4px;
letter-spacing: -0.02em;
}
.metric-value.good { color: var(--green); }
.metric-value.warn { color: var(--amber); }
.metric-sub {
font-family: var(--mono);
font-size: 10px;
color: var(--text3);
}
/* Tabs */
.tab-row {
display: flex;
gap: 0;
margin-bottom: 1rem;
border-bottom: 1px solid var(--border);
}
.tab {
font-family: var(--mono);
font-size: 12px;
color: var(--text3);
background: transparent;
border: none;
border-bottom: 2px solid transparent;
border-radius: 0;
padding: 8px 16px;
margin-bottom: -1px;
cursor: pointer;
transition: all 0.15s;
}
.tab:hover { color: var(--text2); }
.tab.active { color: var(--green); border-bottom-color: var(--green); }
/* Cards */
.card {
background: var(--bg2);
border: 1px solid var(--border);
border-radius: 8px;
padding: 1rem 1.25rem;
margin-bottom: 1rem;
}
.card-title {
font-family: var(--mono);
font-size: 10px;
color: var(--text3);
text-transform: uppercase;
letter-spacing: 0.08em;
margin-bottom: 1rem;
}
/* Session table */
.session-header, .session-row {
display: grid;
grid-template-columns: 96px 140px 80px 1fr 72px;
gap: 12px;
align-items: center;
font-family: var(--mono);
font-size: 11px;
}
.session-header {
color: var(--text3);
text-transform: uppercase;
letter-spacing: 0.06em;
font-size: 10px;
padding-bottom: 8px;
border-bottom: 1px solid var(--border);
margin-bottom: 4px;
}
.session-row {
color: var(--text2);
padding: 6px 0;
border-bottom: 1px solid var(--border);
transition: background 0.1s;
}
.session-row:last-child { border-bottom: none; }
.session-row:hover { background: var(--bg3); margin: 0 -1.25rem; padding: 6px 1.25rem; }
/* Badges */
.badge {
display: inline-block;
font-family: var(--mono);
font-size: 10px;
font-weight: 500;
padding: 2px 8px;
border-radius: 3px;
letter-spacing: 0.02em;
}
.badge-g { background: var(--green-dim); color: var(--green); border: 1px solid rgba(74,222,154,0.2); }
.badge-m { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(96,165,250,0.2); }
.badge-b { background: var(--bg3); color: var(--text3); border: 1px solid var(--border); }
/* Progress bar */
.bar-wrap { background: var(--bg3); border-radius: 2px; height: 4px; overflow: hidden; flex: 1; }
.bar-fill { height: 100%; border-radius: 2px; transition: width 0.4s ease; }
.bar-g { background: var(--green); }
.bar-m { background: var(--blue); }
.bar-b { background: var(--text3); }
.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-pct { min-width: 38px; text-align: right; }
/* Charts */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.chart-wrap { position: relative; height: 200px; }
/* Insights */
.insight-box {
background: var(--bg3);
border: 1px solid var(--border);
border-left: 3px solid var(--green);
border-radius: 0 6px 6px 0;
padding: 0.875rem 1rem;
margin-bottom: 0.75rem;
font-size: 13px;
color: var(--text2);
line-height: 1.6;
}
.insight-box.warn { border-left-color: var(--amber); }
.insight-box.neutral { border-left-color: var(--border2); }
/* Command hint */
.cmd-hint {
font-family: var(--mono);
font-size: 11px;
background: var(--bg3);
border: 1px solid var(--border);
border-radius: 4px;
padding: 6px 10px;
color: var(--text3);
margin-top: 6px;
display: inline-block;
}
.cmd-hint span { color: var(--green); }
@media (max-width: 768px) {
.metric-grid { grid-template-columns: repeat(3, 1fr); }
.two-col { grid-template-columns: 1fr; }
.container { padding: 1rem; }
.header { padding: 0 1rem; }
.session-header, .session-row { grid-template-columns: 88px 1fr 64px; }
.col-hide { display: none; }
}
@media (max-width: 480px) {
.metric-grid { grid-template-columns: repeat(2, 1fr); }
}
</style>
</head>
<body>
<header class="header">
<div class="logo">
<div class="logo-mark">
<svg viewBox="0 0 12 12" fill="none">
<rect x="1" y="1" width="4" height="4" fill="#000" rx="0.5"/>
<rect x="7" y="1" width="4" height="4" fill="#000" rx="0.5" opacity="0.5"/>
<rect x="1" y="7" width="4" height="4" fill="#000" rx="0.5" opacity="0.5"/>
<rect x="7" y="7" width="4" height="4" fill="#000" rx="0.5" opacity="0.3"/>
</svg>
</div>
Claude Code Token Analyzer
</div>
<div class="header-meta">
by <a href="https://www.linkedin.com/in/frankpizzuta/" target="_blank">Frank Pizzuta</a>
·
<a href="https://github.com/frank-prfrm/claude-code-token-analyzer" target="_blank">GitHub</a>
</div>
</header>
<main class="container">
<div class="input-zone">
<div class="input-label">Session data input</div>
<div class="input-row">
<textarea id="json-input" placeholder="Paste output of: ccusage session --json"></textarea>
<div class="btn-group">
<button class="btn-primary" onclick="parseInput()">Analyze</button>
<button class="btn-secondary" onclick="loadSample()">Load sample</button>
</div>
</div>
<div class="cmd-hint">Run: <span>ccusage session --json > output.json</span> then paste contents above</div>
</div>
<div id="status-bar">Waiting for data — paste your ccusage JSON or load sample to begin.</div>
<div id="dashboard" style="display:none;">
<div class="metric-grid" id="metric-grid"></div>
<div class="tab-row">
<button class="tab active" onclick="showTab('sessions',this)">Sessions</button>
<button class="tab" onclick="showTab('trends',this)">Trends</button>
<button class="tab" onclick="showTab('insights',this)">Insights</button>
</div>
<div id="tab-sessions">
<div class="card">
<div class="card-title">Session breakdown</div>
<div class="session-header">
<span>Date</span>
<span>Profile</span>
<span class="col-hide">Input</span>
<span>Cache hit</span>
<span>Cost</span>
</div>
<div id="session-list"></div>
</div>
</div>
<div id="tab-trends" style="display:none;">
<div class="two-col">
<div class="card">
<div class="card-title">Cache hit ratio — Graphify signal</div>
<div class="chart-wrap"><canvas id="chart-cache"></canvas></div>
</div>
<div class="card">
<div class="card-title">Total tokens per session</div>
<div class="chart-wrap"><canvas id="chart-tokens"></canvas></div>
</div>
</div>
<div class="card">
<div class="card-title">Session cost (API-equivalent)</div>
<div class="chart-wrap" style="height:160px;"><canvas id="chart-cost"></canvas></div>
</div>
</div>
<div id="tab-insights" style="display:none;">
<div id="insights-list"></div>
</div>
</div>
</main>
<script>
let sessions = [], charts = {};
function showTab(name, btn) {
['sessions','trends','insights'].forEach(t => {
document.getElementById('tab-'+t).style.display = t===name?'':'none';
});
document.querySelectorAll('.tab').forEach(b=>b.classList.remove('active'));
btn.classList.add('active');
if (name==='trends') renderCharts();
}
function parseInput() {
const raw = document.getElementById('json-input').value.trim();
let data;
try { data = JSON.parse(raw); } catch(e) {
setStatus('Invalid JSON — check your paste.'); return;
}
const arr = data.session || data.sessions || (Array.isArray(data)?data:[]);
if (!arr.length) { setStatus('No session data found. Run: ccusage session --json'); return; }
sessions = arr.map(enrich);
render();
}
function enrich(s) {
const inp = s.inputTokens||0, cacheRead = s.cacheReadTokens||0, cacheCreate = s.cacheCreationTokens||0;
const total = inp+(s.outputTokens||0)+cacheRead+cacheCreate;
const cacheHit = total>0?(cacheRead/total):0;
let profile='baseline';
if (cacheHit>0.35) profile='graphify-strong';
else if (cacheHit>0.15) profile='graphify-light';
else if (cacheCreate>inp*0.1) profile='mem-active';
return {...s,cacheHit,total,profile};
}
const fmtK = n => n>=1e6?(n/1e6).toFixed(1)+'M':n>=1000?Math.round(n/1000)+'K':String(n);
const fmtPct = n => (n*100).toFixed(1)+'%';
const fmtCost = n => '$'+(n||0).toFixed(4);
function setStatus(msg) {
document.getElementById('status-bar').textContent = msg;
}
function render() {
document.getElementById('dashboard').style.display='';
setStatus(sessions.length+' sessions loaded · '+new Date().toLocaleTimeString());
renderMetrics(); renderSessions(); renderInsights();
}
function renderMetrics() {
const total = sessions.reduce((a,s)=>a+s.total,0);
const totalCost = sessions.reduce((a,s)=>a+(s.totalCost||0),0);
const avgCacheHit = sessions.reduce((a,s)=>a+s.cacheHit,0)/sessions.length;
const graphSessions = sessions.filter(s=>s.profile.startsWith('graphify')).length;
const memSessions = sessions.filter(s=>s.profile==='mem-active').length;
document.getElementById('metric-grid').innerHTML = `
<div class="metric"><div class="metric-label">Sessions</div><div class="metric-value neutral">${sessions.length}</div><div class="metric-sub">in dataset</div></div>
<div class="metric"><div class="metric-label">Total tokens</div><div class="metric-value neutral">${fmtK(total)}</div><div class="metric-sub">all sessions</div></div>
<div class="metric"><div class="metric-label">API-equiv cost</div><div class="metric-value neutral">$${totalCost.toFixed(2)}</div><div class="metric-sub">not actual spend</div></div>
<div class="metric"><div class="metric-label">Avg cache hit</div><div class="metric-value ${avgCacheHit>0.2?'good':'warn'}">${fmtPct(avgCacheHit)}</div><div class="metric-sub">Graphify signal</div></div>
<div class="metric"><div class="metric-label">Graphify sessions</div><div class="metric-value ${graphSessions>0?'good':'neutral'}">${graphSessions}</div><div class="metric-sub">of ${sessions.length} total</div></div>
<div class="metric"><div class="metric-label">Mem-active</div><div class="metric-value ${memSessions>0?'good':'neutral'}">${memSessions}</div><div class="metric-sub">Claude-Mem signal</div></div>
`;
}
function profileLabel(p) {
if (p==='graphify-strong') return '<span class="badge badge-g">Graphify ●●●</span>';
if (p==='graphify-light') return '<span class="badge badge-g" style="opacity:.65">Graphify ●●○</span>';
if (p==='mem-active') return '<span class="badge badge-m">Mem active</span>';
return '<span class="badge badge-b">baseline</span>';
}
function renderSessions() {
const el = document.getElementById('session-list');
if (!sessions.length) { el.innerHTML=''; return; }
const getDate = s => (s.startTime||s.date||(s.metadata&&s.metadata.lastActivity)||'');
const sorted = [...sessions].sort((a,b)=>getDate(b).localeCompare(getDate(a)));
el.innerHTML = sorted.map(s => {
const date = getDate(s).slice(0,10);
const barPct = Math.round(s.cacheHit*100);
const barClass = s.profile.startsWith('graphify')?'bar-g':s.profile==='mem-active'?'bar-m':'bar-b';
return `<div class="session-row">
<span style="color:var(--text3)">${date}</span>
<div>${profileLabel(s.profile)}</div>
<span class="col-hide">${fmtK(s.inputTokens||0)}</span>
<div class="bar-row">
<div class="bar-wrap"><div class="bar-fill ${barClass}" style="width:${barPct}%"></div></div>
<span class="bar-pct" style="color:var(--text2)">${fmtPct(s.cacheHit)}</span>
</div>
<span>${fmtCost(s.totalCost)}</span>
</div>`;
}).join('');
}
function renderCharts() {
const getDate = s => (s.startTime||s.date||(s.metadata&&s.metadata.lastActivity)||'');
const sorted = [...sessions].sort((a,b)=>getDate(a).localeCompare(getDate(b)));
const labels = sorted.map((s,i)=>getDate(s).slice(0,10)||'S'+(i+1));
const cacheData = sorted.map(s=>parseFloat((s.cacheHit*100).toFixed(1)));
const tokenData = sorted.map(s=>Math.round(s.total/1000));
const costData = sorted.map(s=>parseFloat(((s.totalCost||0)).toFixed(4)));
const grid = 'rgba(255,255,255,0.05)', tick = '#555c6e';
function mk(id, type, data, color, suffix) {
const ctx = document.getElementById(id);
if (!ctx) return;
if (charts[id]) charts[id].destroy();
charts[id] = new Chart(ctx, {
type,
data: { labels, datasets: [{ data, borderColor: color, backgroundColor: type==='bar'?color+'55':color+'18',
borderWidth: type==='bar'?0:1.5, fill: type!=='bar', tension: 0.3, pointRadius: 2, pointHoverRadius: 4 }] },
options: { responsive: true, maintainAspectRatio: false,
plugins: { legend: { display: false } },
scales: {
x: { ticks: { color: tick, font: { family: "'IBM Plex Mono'", size: 9 }, maxRotation: 45, autoSkip: true, maxTicksLimit: 8 }, grid: { color: grid } },
y: { ticks: { color: tick, font: { family: "'IBM Plex Mono'", size: 9 }, callback: v=>v+suffix }, grid: { color: grid } }
}
}
});
}
mk('chart-cache','line',cacheData,'#4ade9a','%');
mk('chart-tokens','bar',tokenData,'#60a5fa','K');
mk('chart-cost','line',costData,'#fbbf24','$');
}
function renderInsights() {
const el = document.getElementById('insights-list');
if (!sessions.length) return;
const avgCache = sessions.reduce((a,s)=>a+s.cacheHit,0)/sessions.length;
const graphCount = sessions.filter(s=>s.profile.startsWith('graphify')).length;
const baseCount = sessions.filter(s=>s.profile==='baseline').length;
const getDate = s => (s.startTime||s.date||(s.metadata&&s.metadata.lastActivity)||'');
const sorted = [...sessions].sort((a,b)=>getDate(a).localeCompare(getDate(b)));
const half = Math.floor(sorted.length/2);
const avgFirst = sorted.slice(0,half).reduce((a,s)=>a+s.total,0)/(half||1);
const avgSecond = sorted.slice(half).reduce((a,s)=>a+s.total,0)/((sorted.length-half)||1);
const trend = avgSecond<avgFirst?'down':'up';
const trendPct = Math.abs((avgSecond-avgFirst)/avgFirst*100).toFixed(1);
let html='';
if (avgCache<0.05) {
html+=`<div class="insight-box warn">Cache hit ratio is very low (${fmtPct(avgCache)}). Graphify may not be indexing yet, or sessions are bypassing the graph. Try a structural query like "what calls X" to trigger traversal.</div>`;
} else if (avgCache>0.3) {
html+=`<div class="insight-box">Cache hit ratio is strong at ${fmtPct(avgCache)}. Graphify is actively serving pre-indexed graph structure. This is the primary signal the tool is working.</div>`;
} else {
html+=`<div class="insight-box warn">Cache hit ratio is moderate (${fmtPct(avgCache)}). Graphify is contributing but sessions may be mixing structural and open-ended queries. Track which query types drive higher cache hits.</div>`;
}
if (graphCount>0 && baseCount>0) {
const gAvg = sessions.filter(s=>s.profile.startsWith('graphify')).reduce((a,s)=>a+s.total,0)/graphCount;
const bAvg = sessions.filter(s=>s.profile==='baseline').reduce((a,s)=>a+s.total,0)/baseCount;
const diff = ((bAvg-gAvg)/bAvg*100).toFixed(1);
html+=`<div class="insight-box">Graphify sessions average ${fmtK(Math.round(gAvg))} tokens vs ${fmtK(Math.round(bAvg))} for baseline — a ${Math.abs(diff)}% ${diff>0?'reduction':'increase'}. Note: correlation only. Task type matters more than tool state.</div>`;
}
if (sorted.length>=4) {
html+=`<div class="insight-box ${trend==='up'?'warn':''}">Token trend is ${trend==='down'?'decreasing':'increasing'} ${trendPct}% from first to second half. ${trend==='down'?'Positive — tools compounding.':'Worth reviewing — session complexity may be growing faster than efficiency gains.'}</div>`;
}
html+=`<div class="insight-box neutral">Claude-Mem is harder to fingerprint from session-level data. Its signal is low raw input tokens at session start on returning project sessions. Compare sessions on the same project within 24h vs. after a gap for a cleaner read.</div>`;
html+=`<div class="insight-box neutral" style="font-size:12px;color:var(--text3);">Cost figures are API-equivalent at standard pricing (Opus 4.7 $5/$25, Sonnet 4.6 $3/$15, Haiku 4.5 $1/$5 per million tokens). If you're on Claude Max, these show relative weight, not actual spend.</div>`;
el.innerHTML = html;
}
function loadSample() {
const now = new Date();
const day = d => { const t=new Date(now); t.setDate(t.getDate()-d); return t.toISOString().slice(0,10); };
const sample = { session: [
{sessionId:'aaa1',startTime:day(14)+'T09:00:00Z',inputTokens:45000,outputTokens:8200,cacheReadTokens:3200,cacheCreationTokens:12000,totalCost:0.0821},
{sessionId:'bbb2',startTime:day(12)+'T14:00:00Z',inputTokens:38000,outputTokens:9100,cacheReadTokens:4100,cacheCreationTokens:9800,totalCost:0.0710},
{sessionId:'ccc3',startTime:day(10)+'T10:30:00Z',inputTokens:29000,outputTokens:7800,cacheReadTokens:18200,cacheCreationTokens:8100,totalCost:0.0481},
{sessionId:'ddd4',startTime:day(8)+'T16:00:00Z',inputTokens:31000,outputTokens:8900,cacheReadTokens:22000,cacheCreationTokens:7200,totalCost:0.0440},
{sessionId:'eee5',startTime:day(6)+'T09:15:00Z',inputTokens:27500,outputTokens:7200,cacheReadTokens:31000,cacheCreationTokens:6800,totalCost:0.0390},
{sessionId:'fff6',startTime:day(4)+'T11:00:00Z',inputTokens:22000,outputTokens:6900,cacheReadTokens:38000,cacheCreationTokens:5900,totalCost:0.0332},
{sessionId:'ggg7',startTime:day(2)+'T15:30:00Z',inputTokens:19500,outputTokens:6400,cacheReadTokens:41200,cacheCreationTokens:5400,totalCost:0.0298},
{sessionId:'hhh8',startTime:day(0)+'T10:00:00Z',inputTokens:18000,outputTokens:6100,cacheReadTokens:44000,cacheCreationTokens:5100,totalCost:0.0271},
]};
document.getElementById('json-input').value = JSON.stringify(sample,null,2);
sessions = sample.session.map(enrich);
render();
}
</script>
</body>
</html>