claude-rpc 1.5.2 → 1.5.4

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.
Files changed (46) hide show
  1. package/README.md +34 -24
  2. package/SECURITY.md +99 -20
  3. package/package.json +1 -1
  4. package/src/atomic-rename.js +45 -2
  5. package/src/badge.js +3 -4
  6. package/src/card.js +1 -22
  7. package/src/cli-path.js +286 -0
  8. package/src/cli.js +310 -383
  9. package/src/community.js +101 -60
  10. package/src/config.js +4 -1
  11. package/src/daemon.js +45 -47
  12. package/src/default-config.js +4 -3
  13. package/src/discord-ipc.js +24 -13
  14. package/src/doctor.js +63 -37
  15. package/src/ensure-daemon.js +11 -4
  16. package/src/fmt.js +8 -6
  17. package/src/format.js +8 -13
  18. package/src/gist.js +8 -18
  19. package/src/git.js +4 -1
  20. package/src/hook.js +27 -32
  21. package/src/insights.js +3 -4
  22. package/src/install.js +100 -79
  23. package/src/leaderboard.js +3 -2
  24. package/src/mcp.js +2 -8
  25. package/src/nudge.js +8 -3
  26. package/src/pricing.js +24 -2
  27. package/src/privacy.js +22 -7
  28. package/src/profile.js +0 -6
  29. package/src/recap.js +4 -17
  30. package/src/scanner.js +103 -71
  31. package/src/server/api.js +64 -36
  32. package/src/server/assets/dashboard.client.js +75 -44
  33. package/src/server/assets/dashboard.css +18 -18
  34. package/src/server/assets/dashboard.html +13 -15
  35. package/src/server/assets/wrapped.client.js +26 -11
  36. package/src/server/assets/wrapped.css +2 -2
  37. package/src/server/index.js +43 -32
  38. package/src/server/page.js +6 -3
  39. package/src/server/sse.js +90 -34
  40. package/src/session-card.js +3 -1
  41. package/src/state.js +14 -24
  42. package/src/tui.js +3 -12
  43. package/src/ui.js +7 -5
  44. package/src/verify.js +3 -7
  45. package/src/version.js +1 -1
  46. package/src/week.js +4 -4
@@ -26,7 +26,9 @@
26
26
  let heatmapByDay = null; // dedicated fixed-90d source, independent of the range pill
27
27
  let allFrames = [];
28
28
  let currentLiveIdx = 0;
29
- let rotationTimer = null;
29
+ let framesStatus = null; // status the frames belong to — a change restarts on the base frame
30
+ let avatarSrc = null; // currently shown large image (re-set only on change, so GIFs don't restart)
31
+ let daySeq = 0; // latest openDay request; older responses are dropped
30
32
  let chartSeries = []; // [{ d: Date, ms }] — for the activity-chart hover tooltip
31
33
  let churnSeries = []; // [{ d: Date, add, rem }] — for the churn-sparkline tooltip
32
34
 
@@ -84,18 +86,6 @@
84
86
  return m + 'm ' + (s % 60) + 's';
85
87
  };
86
88
 
87
- // ── Theme ───────────────────────────────────────────────
88
- function applyTheme() {
89
- const saved = localStorage.getItem('theme') || 'dark';
90
- document.documentElement.classList.toggle('light', saved === 'light');
91
- }
92
- $('theme-btn').addEventListener('click', () => {
93
- const cur = localStorage.getItem('theme') || 'dark';
94
- localStorage.setItem('theme', cur === 'dark' ? 'light' : 'dark');
95
- applyTheme();
96
- });
97
- applyTheme();
98
-
99
89
  // ── Range pills ─────────────────────────────────────────
100
90
  document.querySelectorAll('#range-pills button').forEach((b) => {
101
91
  b.addEventListener('click', () => {
@@ -243,10 +233,9 @@
243
233
  rows.forEach((r) => {
244
234
  const tr = document.createElement('tr');
245
235
  if (r.onClick) tr.classList.add('clickable');
246
- const ico = r.color ? '<span class="ico" style="background:' + r.color + '"></span>' : '';
247
236
  const nameHtml = opts.mono
248
- ? '<code style="font-family: JetBrains Mono, monospace; font-size: 12px;">' + ico + esc(r.name) + '</code>'
249
- : ico + esc(r.name);
237
+ ? '<code style="font-family: JetBrains Mono, monospace; font-size: 12px;">' + esc(r.name) + '</code>'
238
+ : esc(r.name);
250
239
  tr.innerHTML = '<td class="name">' + nameHtml + '</td>' +
251
240
  '<td class="val">' + esc(r.val) + (r.unit ? '<span class="u">' + esc(r.unit) + '</span>' : '') + '</td>';
252
241
  if (r.onClick) tr.addEventListener('click', r.onClick);
@@ -294,7 +283,8 @@
294
283
  '<span class="val">' + fmtCost(cost) + '</span>';
295
284
  bars.appendChild(row);
296
285
  }
297
- if (!entries.length) bars.innerHTML = '<div style="color: var(--text-3); font-size: 12px;">No data in range</div>';
286
+ // costByModel is a lifetime roll-up (the bars are captioned "all time").
287
+ if (!entries.length) bars.innerHTML = '<div style="color: var(--text-3); font-size: 12px;">No model data yet</div>';
298
288
  }
299
289
 
300
290
  // ── Languages panel ─────────────────────────────────────
@@ -355,14 +345,18 @@
355
345
  });
356
346
  }
357
347
 
348
+ // Label/value rows shared by the project drawer and the day modal.
349
+ const kvRows = (rows) => rows.map(([k, v]) =>
350
+ '<div class="kv"><span class="k">' + k + '</span><span class="v">' + v + '</span></div>').join('');
351
+
358
352
  // ── Drawer (project) ────────────────────────────────────
359
- async function openProject(name) {
353
+ function openProject(name) {
360
354
  location.hash = '#projects/' + encodeURIComponent(name);
361
355
  const p = (aggData?.projects || {})[name];
362
356
  if (!p) return;
363
357
  $('drawer-title').textContent = name;
364
358
  $('drawer-sub').textContent = p.sessions + ' sessions · ' + fmtH(p.activeMs) + ' active';
365
- $('drawer-body').innerHTML = [
359
+ $('drawer-body').innerHTML = kvRows([
366
360
  ['Active time', fmtH(p.activeMs)],
367
361
  ['Prompts', fmtN(p.userMessages)],
368
362
  ['Tool calls', fmtN(p.toolCalls)],
@@ -371,7 +365,7 @@
371
365
  ['Estimated cost', fmtCost(p.cost || 0)],
372
366
  ['Tokens in', fmtN(p.inputTokens)],
373
367
  ['Tokens out', fmtN(p.outputTokens)],
374
- ].map(([k, v]) => '<div class="kv"><span class="k">' + k + '</span><span class="v">' + v + '</span></div>').join('');
368
+ ]);
375
369
  $('scrim').classList.add('open');
376
370
  $('drawer').classList.add('open');
377
371
  }
@@ -384,9 +378,22 @@
384
378
  $('drawer-close').addEventListener('click', closeDrawer);
385
379
 
386
380
  // ── Modal (day) ─────────────────────────────────────────
381
+ // Fetches the day from /api/day/:day rather than reading aggData.byDay:
382
+ // aggData is trimmed to the range pill, but the heatmap is a fixed ~90-day
383
+ // window and #days/ deep links can name any date, so a lit cell outside
384
+ // the selected range used to open as "No activity".
387
385
  async function openDay(k) {
388
386
  location.hash = '#days/' + k;
389
- const day = (aggData?.byDay || {})[k];
387
+ const seq = ++daySeq;
388
+ let day;
389
+ try {
390
+ const r = await fetch('/api/day/' + encodeURIComponent(k), { cache: 'no-store' });
391
+ day = r.ok ? await r.json() : null; // 404 = no activity that day
392
+ } catch {
393
+ // Server unreachable — fall back to what this page already holds.
394
+ day = (heatmapByDay || {})[k] || (aggData?.byDay || {})[k] || null;
395
+ }
396
+ if (seq !== daySeq) return; // a newer click already owns the modal
390
397
  if (!day) {
391
398
  $('modal-title').textContent = k;
392
399
  $('modal-sub').textContent = 'No activity';
@@ -394,7 +401,7 @@
394
401
  } else {
395
402
  $('modal-title').textContent = new Date(k + 'T00:00:00').toLocaleDateString('en-US', { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' });
396
403
  $('modal-sub').textContent = fmtH(day.activeMs) + ' active · ' + (day.sessions || 0) + ' sessions';
397
- $('modal-body').innerHTML = [
404
+ $('modal-body').innerHTML = kvRows([
398
405
  ['Prompts', fmtN(day.userMessages)],
399
406
  ['Tool calls', fmtN(day.toolCalls)],
400
407
  ['Lines added', fmtN(day.linesAdded || 0)],
@@ -402,12 +409,13 @@
402
409
  ['Cost', fmtCost(day.cost || 0)],
403
410
  ['Tokens', fmtN((day.inputTokens || 0) + (day.outputTokens || 0) + (day.cacheReadTokens || 0) + (day.cacheWriteTokens || 0))],
404
411
  ['Notifications', day.notifications || 0],
405
- ].map(([k, v]) => '<div class="kv" style="display:flex;justify-content:space-between;padding:7px 0;border-bottom:1px solid var(--border);font-size:13px;"><span style="color:var(--text-3);">' + k + '</span><span style="font-weight:500;">' + v + '</span></div>').join('');
412
+ ]);
406
413
  }
407
414
  $('modal').classList.add('open');
408
415
  $('scrim').classList.add('open');
409
416
  }
410
417
  function closeModal() {
418
+ daySeq++; // a still-pending openDay must not reopen the modal
411
419
  $('modal').classList.remove('open');
412
420
  $('scrim').classList.remove('open');
413
421
  if (location.hash.startsWith('#days/')) location.hash = '';
@@ -421,10 +429,6 @@
421
429
  if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
422
430
  if (e.key === '?') { e.preventDefault(); $('help').classList.toggle('open'); }
423
431
  if (e.key === 'Escape') { closeDrawer(); closeModal(); $('help').classList.remove('open'); }
424
- if (e.key === 't') {
425
- const cur = localStorage.getItem('theme') || 'dark';
426
- localStorage.setItem('theme', cur === 'dark' ? 'light' : 'dark'); applyTheme();
427
- }
428
432
  if (e.key >= '1' && e.key <= '5') {
429
433
  const pills = ['7d', '30d', '90d', '1y', 'all'];
430
434
  const target = document.querySelector('[data-range="' + pills[parseInt(e.key, 10) - 1] + '"]');
@@ -467,15 +471,25 @@
467
471
  } catch (e) { console.error(e); }
468
472
  }
469
473
 
474
+ // 'All time' charts every day since the first recorded one (byDay is
475
+ // complete), not a fixed 365-day window.
476
+ function daysSinceFirstDay(byDay) {
477
+ let first = null;
478
+ for (const k of Object.keys(byDay)) if (first === null || k < first) first = k;
479
+ if (!first) return 1;
480
+ const today = new Date(); today.setHours(0, 0, 0, 0);
481
+ return Math.max(1, Math.round((today - new Date(first + 'T00:00:00')) / 86_400_000) + 1);
482
+ }
483
+
470
484
  function drawAggregate() {
471
485
  if (!aggData) return;
472
- const days = range === '7d' ? 7 : range === '30d' ? 30 : range === '1y' ? 365 : range === 'all' ? 365 : 90;
486
+ const days = range === '7d' ? 7 : range === '30d' ? 30 : range === '1y' ? 365
487
+ : range === 'all' ? daysSinceFirstDay(aggData.byDay || {}) : 90;
473
488
  renderChart(aggData.byDay || {}, days);
474
489
  renderHeatmap(heatmapByDay || aggData.byDay || {});
475
490
  renderChurn(aggData.byDay || {}, Math.min(days, 90));
476
491
  renderCost(aggData);
477
492
  renderLanguages(aggData.languages);
478
- renderAchievements(aggData);
479
493
 
480
494
  // Range stat card
481
495
  const [rn, ru] = splitTime(fmtH(aggData.activeMs || 0));
@@ -496,7 +510,7 @@
496
510
  $('cost-num').textContent = fmtCost(aggData.estimatedCost || 0);
497
511
  $('cost-sub').textContent = fmtN(aggData.grandTokens || 0) + ' tokens';
498
512
 
499
- // Lifetime tokens card
513
+ // Tokens section: range-scoped, summed from byDay by windowedAggregate.
500
514
  const grand = (aggData.inputTokens || 0) + (aggData.outputTokens || 0) + (aggData.cacheReadTokens || 0) + (aggData.cacheWriteTokens || 0);
501
515
  $('tok-grand').textContent = fmtN(grand);
502
516
  $('tok-out').textContent = fmtN(aggData.outputTokens || 0);
@@ -512,7 +526,9 @@
512
526
  const net = (aggData.linesAdded || 0) - (aggData.linesRemoved || 0);
513
527
  $('churn-net').textContent = (net >= 0 ? '+' : '−') + fmtN(Math.abs(net));
514
528
 
515
- // Leaderboards
529
+ // Leaderboards + shell/web/subagents: lifetime roll-ups the aggregate
530
+ // doesn't keep per day, so these ignore the range pill (labelled
531
+ // "all time" in the page).
516
532
  const projs = Object.entries(aggData.projects || {}).sort((x, y) => y[1].activeMs - x[1].activeMs).slice(0, 8);
517
533
  renderTable('projects-tbl', projs.map(([name, p]) => {
518
534
  const h = p.activeMs / 3_600_000;
@@ -522,7 +538,8 @@
522
538
  const tools = Object.entries(aggData.toolBreakdown || {}).sort((x, y) => y[1] - x[1]).slice(0, 8);
523
539
  renderTable('tools-tbl', tools.map(([name, count]) => ({ name, val: fmtN(count), unit: '' })), { mono: true });
524
540
  const files = (aggData.topEditedFiles || []).slice(0, 8);
525
- renderTable('files-tbl', files.map((f) => ({ name: f.file || (f.path || '').split('/').pop(), val: fmtN(f.count), unit: '' })), { mono: true });
541
+ // Either separator: Windows paths arrive with backslashes.
542
+ renderTable('files-tbl', files.map((f) => ({ name: f.file || (f.path || '').split(/[\\/]/).pop(), val: fmtN(f.count), unit: '' })), { mono: true });
526
543
 
527
544
  // Bash / domains / subagents
528
545
  const bash = Object.entries(aggData.bashCommands || {}).sort((x, y) => y[1] - x[1]).slice(0, 8);
@@ -534,8 +551,6 @@
534
551
 
535
552
  const tot = (aggData.mcpToolCalls || 0) + (aggData.builtinToolCalls || 0);
536
553
  $('mcp-label').textContent = tot ? Math.round(((aggData.mcpToolCalls || 0) / tot) * 100) + '% MCP · ' + Math.round(((aggData.builtinToolCalls || 0) / tot) * 100) + '% built-in' : '—';
537
-
538
- $('lb-sessions').textContent = fmtN(aggData.sessions || 0);
539
554
  }
540
555
 
541
556
  function drawState() {
@@ -545,17 +560,25 @@
545
560
  const s = liveData.state;
546
561
 
547
562
  // Top bar
548
- const now = new Date();
549
- $('meta').textContent = 'No. ' + (v.daysSinceFirst || '—') + ' · ' + now.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric' });
550
563
  $('model').textContent = v.modelPretty;
551
564
  $('statustext').textContent = v.statusVerbose;
552
- $('dot').className = 'dot ' + (s.status === 'working' || s.status === 'thinking' ? '' : s.status === 'idle' ? 'idle' : 'stale');
553
565
 
554
- // Live avatar
555
- const cfgAvatar = (s.status && liveData.config?.statusAssets?.[s.status]) || '';
556
- $('live-avatar').innerHTML = cfgAvatar
557
- ? '<img src="' + cfgAvatar.replace(/"/g, '&quot;') + '" alt="" />'
558
- : '';
566
+ // Live avatar: the card's large image as the server resolved it. Only
567
+ // http(s) URLs render here; a Discord art-asset key isn't loadable from a
568
+ // browser. Re-set only on change so an animated GIF doesn't restart on
569
+ // every refresh.
570
+ const src = /^https?:\/\//i.test(liveData.largeImage || '') ? liveData.largeImage : '';
571
+ if (src !== avatarSrc) {
572
+ avatarSrc = src;
573
+ const box = $('live-avatar');
574
+ box.textContent = '';
575
+ if (src) {
576
+ const img = document.createElement('img');
577
+ img.src = src;
578
+ img.alt = '';
579
+ box.appendChild(img);
580
+ }
581
+ }
559
582
  $('elapsed').textContent = elapsedStr(s.sessionStart);
560
583
 
561
584
  // Hero
@@ -582,7 +605,15 @@
582
605
  $('streak-num').textContent = v.streak;
583
606
  $('streak-sub').textContent = 'Longest ' + v.longestStreak + ' · best ' + (v.bestDayHours || '—');
584
607
 
585
- // Discord
608
+ // Lifetime milestones and the leaderboards' session count come from the
609
+ // lifetime aggregate, not the range-trimmed one (a 7d range used to
610
+ // re-lock "100 sessions").
611
+ renderAchievements(a);
612
+ $('lb-sessions').textContent = fmtN(a.sessions || 0);
613
+
614
+ // Discord: frames for the current status. A status change restarts on
615
+ // the base frame, like the daemon's rotation cursor.
616
+ if (s.status !== framesStatus) { framesStatus = s.status; currentLiveIdx = 0; }
586
617
  allFrames = liveData.frames || [];
587
618
  renderRotation();
588
619
  }
@@ -626,7 +657,7 @@
626
657
  }, 1000);
627
658
 
628
659
  // Rotation cycle
629
- rotationTimer = setInterval(() => { currentLiveIdx++; renderRotation(); }, 4000);
660
+ setInterval(() => { currentLiveIdx++; renderRotation(); }, 4000);
630
661
 
631
662
  // ── Chart hover tooltips ────────────────────────────────────────────────
632
663
  // Native SVG charts, no library. preserveAspectRatio="none" means the
@@ -16,21 +16,14 @@
16
16
 
17
17
  --shadow: 3px 3px 0 var(--ink);
18
18
  --shadow-hover: 5px 5px 0 var(--ink);
19
- --radius: 0;
20
-
21
- /* Fallbacks for existing variables used by page.js */
22
- --bg: var(--paper);
19
+
20
+ /* Older names still referenced by this sheet, dashboard.html inline
21
+ styles and dashboard.client.js markup strings. */
23
22
  --text: var(--ink);
24
- --text-2: var(--ink-soft);
25
23
  --text-3: var(--ink-mute);
26
24
  --text-4: var(--ink-faint);
27
25
  --border: var(--ink);
28
- --surface: #fff;
29
- --surface-hover: var(--paper);
30
- --green: var(--grass);
31
- --red: #c54a3a;
32
26
  --purple: #5865f2; /* using blurple */
33
- --amber: var(--tape);
34
27
  }
35
28
 
36
29
  * { box-sizing: border-box; margin: 0; padding: 0; }
@@ -71,8 +64,6 @@ h1, h2, h3 { font-family: var(--font-disp); }
71
64
  box-shadow: 2px 2px 0 var(--rust);
72
65
  transform: rotate(-3deg);
73
66
  }
74
- .brand .sep { display: none; }
75
- .brand .meta { display: none; }
76
67
  .top-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
77
68
 
78
69
  .range-pills {
@@ -100,8 +91,6 @@ h1, h2, h3 { font-family: var(--font-disp); }
100
91
  padding: 6px 12px; border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink);
101
92
  transform: rotate(-2deg);
102
93
  }
103
- .status .dot { display: none; }
104
- .theme-btn { display: none; } /* Hide theme toggle, we only use paper now */
105
94
  .model { font-family: var(--font-mono); font-size: 12px; font-weight: 700; background: #fff; padding: 4px 8px; border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
106
95
 
107
96
  /* ── Live rail ───────────────────────────────────────── */
@@ -123,7 +112,6 @@ h1, h2, h3 { font-family: var(--font-disp); }
123
112
  border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink) inset; overflow: hidden;
124
113
  }
125
114
  .live-rail .avatar img { width: 100%; height: 100%; object-fit: cover; }
126
- .live-rail .frame-app { display: none; }
127
115
  .live-rail .frame-details { font-family: var(--font-disp); font-size: 22px; font-weight: 700; margin-bottom: 4px; }
128
116
  .live-rail .frame-state { font-family: var(--font-mono); font-size: 13px; color: var(--ink-mute); }
129
117
  .live-rail .right { text-align: right; border-left: 2px dashed var(--ink); padding-left: 24px; }
@@ -154,7 +142,6 @@ svg.chart .grid { stroke: var(--ink-faint); stroke-width: 1; stroke-dasharray: 2
154
142
  svg.chart .area { fill: url(#whiteGrad); }
155
143
  svg.chart .line { fill: none; stroke: var(--rust); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
156
144
  svg.chart .dot { fill: var(--rust); stroke: #fff; stroke-width: 2px; }
157
- svg.chart .ax { fill: var(--ink-mute); font-size: 10px; font-family: var(--font-mono); font-weight: 700; }
158
145
  .chart-wrap, .churn-spark { cursor: crosshair; }
159
146
 
160
147
  /* Cursor-following hover tooltip shared by the activity chart + churn spark. */
@@ -201,6 +188,7 @@ svg.chart .ax { fill: var(--ink-mute); font-size: 10px; font-family: var(--fon
201
188
  .cost-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: center; }
202
189
  .cost-figure { font-family: var(--font-disp); font-size: 48px; font-weight: 700; line-height: 1; }
203
190
  .cost-sub { font-family: var(--font-mono); color: var(--ink-mute); font-size: 12px; margin-top: 8px; font-weight: 700; }
191
+ .cost-bars-cap { font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--ink-mute); margin-bottom: 10px; }
204
192
  .cost-bars { display: grid; gap: 12px; font-family: var(--font-mono); font-size: 12px; font-weight: 700; }
205
193
  .cost-bar { display: grid; grid-template-columns: 60px 1fr auto; gap: 8px; align-items: center; }
206
194
  .cost-bar .name { color: var(--ink-soft); }
@@ -247,7 +235,7 @@ section { margin-bottom: 48px; }
247
235
  .lb tr:hover td { background: var(--paper); }
248
236
  .lb td.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 1px; color: var(--ink); }
249
237
  .lb td.val { color: var(--ink-soft); text-align: right; white-space: nowrap; }
250
- .lb td.name .ico { width: 12px; height: 12px; border: 1.5px solid var(--ink); margin-right: 8px; vertical-align: -2px; }
238
+ .lb tr.clickable { cursor: pointer; }
251
239
 
252
240
  /* ── Discord card ────────────────────────────────────── */
253
241
  .discord { background: #fff; border: 2px solid var(--ink); padding: 32px; box-shadow: var(--shadow); position: relative; }
@@ -255,7 +243,6 @@ section { margin-bottom: 48px; }
255
243
  .discord-h .t { font-size: 14px; text-transform: uppercase; border-bottom: 2px solid var(--rust); padding-bottom: 4px; }
256
244
  .live-frame { padding: 24px 0; border-top: 2px solid var(--ink); border-bottom: 2px dashed var(--ink); }
257
245
  .live-frame .label-tag { font-family: var(--font-mono); font-size: 11px; font-weight: 700; background: var(--grass); color: #fff; padding: 4px 8px; border: 1.5px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); display: inline-block; margin-bottom: 12px; transform: rotate(-2deg); }
258
- .live-frame .label-tag::before { display: none; }
259
246
  .live-frame .details { font-family: var(--font-disp); font-size: 24px; font-weight: 700; margin-bottom: 4px; }
260
247
  .live-frame .state { font-family: var(--font-mono); font-size: 13px; color: var(--ink-soft); font-weight: 600; }
261
248
  .rotation-list { list-style: none; margin-top: 24px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 24px; font-family: var(--font-mono); font-size: 12px; font-weight: 700; }
@@ -287,6 +274,19 @@ section { margin-bottom: 48px; }
287
274
  .modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.96); background: var(--paper); border: 2px solid var(--ink); padding: 40px; box-shadow: 10px 10px 0 var(--ink); z-index: 60; opacity: 0; pointer-events: none; transition: all 0.2s; }
288
275
  .modal.open { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }
289
276
  .modal h4 { font-family: var(--font-disp); font-size: 24px; margin-bottom: 8px; }
277
+ .modal .sub { font-family: var(--font-mono); color: var(--ink-mute); font-weight: 700; margin-bottom: 16px; }
278
+
279
+ /* Label/value rows in the project drawer + day modal (kvRows in the client). */
280
+ .kv { display: flex; justify-content: space-between; gap: 24px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
281
+ .kv .k { color: var(--text-3); }
282
+ .kv .v { font-weight: 500; font-variant-numeric: tabular-nums; }
283
+ .drawer .close, .modal .close {
284
+ position: absolute; top: 14px; right: 14px; width: 32px; height: 32px;
285
+ display: grid; place-items: center;
286
+ font-family: var(--font-mono); font-size: 18px; font-weight: 700; line-height: 1;
287
+ background: #fff; border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink);
288
+ }
289
+ .drawer .close:hover, .modal .close:hover { background: var(--tape); }
290
290
 
291
291
  footer { margin-top: 60px; padding-top: 32px; border-top: 2px dashed var(--ink); display: flex; justify-content: space-between; align-items: center; font-family: var(--font-mono); font-weight: 700; font-size: 12px; color: var(--ink-mute); }
292
292
  footer .pulse-dot { background: var(--grass); border: 1.5px solid var(--ink); }
@@ -18,8 +18,6 @@
18
18
  <div class="brand">
19
19
  <span class="mark">◆</span>
20
20
  <span>Claude</span>
21
- <span class="sep">·</span>
22
- <span class="meta" id="meta">—</span>
23
21
  </div>
24
22
  <div class="top-right">
25
23
  <div class="range-pills" id="range-pills">
@@ -30,17 +28,15 @@
30
28
  <button data-range="all">All</button>
31
29
  </div>
32
30
  <a class="wrapped-link" href="/wrapped" title="Your animated year-in-review">✦ Wrapped</a>
33
- <button class="theme-btn" id="theme-btn" title="Toggle theme">◐</button>
34
31
  <span class="model" id="model">—</span>
35
- <span class="status"><span class="dot" id="dot"></span><span id="statustext">—</span></span>
32
+ <span class="status"><span id="statustext">—</span></span>
36
33
  </div>
37
34
  </header>
38
35
 
39
36
  <!-- ── Live rail ───────────────────────────────────── -->
40
- <section class="live-rail" id="live-rail">
37
+ <section class="live-rail">
41
38
  <div class="avatar" id="live-avatar"></div>
42
39
  <div>
43
- <div class="frame-app">Claude Code</div>
44
40
  <div class="frame-details" id="frame-details">—</div>
45
41
  <div class="frame-state" id="frame-state">—</div>
46
42
  </div>
@@ -109,7 +105,7 @@
109
105
  <section>
110
106
  <div class="section-head">
111
107
  <h2>Activity</h2>
112
- <div class="right" id="heatmap-meta">click a day for details</div>
108
+ <div class="right">click a day for details</div>
113
109
  </div>
114
110
  <div class="card heatmap-card">
115
111
  <div class="heatmap">
@@ -122,17 +118,20 @@
122
118
  <!-- ── Split: cost + languages ─────────────────────── -->
123
119
  <section class="split-row">
124
120
  <div class="card">
125
- <div class="card-h"><h3>Cost</h3><div class="meta" id="cost-card-meta">approximate · range</div></div>
121
+ <div class="card-h"><h3>Cost</h3><div class="meta">approximate · range</div></div>
126
122
  <div class="cost-grid">
127
123
  <div>
128
124
  <div class="cost-figure" id="cost-figure">—</div>
129
125
  <div class="cost-sub" id="cost-figure-sub">—</div>
130
126
  </div>
131
- <div class="cost-bars" id="cost-bars"></div>
127
+ <div>
128
+ <div class="cost-bars-cap">by model · all time</div>
129
+ <div class="cost-bars" id="cost-bars"></div>
130
+ </div>
132
131
  </div>
133
132
  </div>
134
133
  <div class="card">
135
- <div class="card-h"><h3>Languages</h3><div class="meta" id="lang-meta">by edits</div></div>
134
+ <div class="card-h"><h3>Languages</h3><div class="meta">by edits · all time</div></div>
136
135
  <div class="lang-stack" id="lang-stack"></div>
137
136
  <div class="lang-list" id="lang-list"></div>
138
137
  </div>
@@ -140,7 +139,7 @@
140
139
 
141
140
  <!-- ── Code churn ──────────────────────────────────── -->
142
141
  <section class="card" style="margin-bottom: 28px;">
143
- <div class="card-h"><h3>Code churn</h3><div class="meta" id="churn-meta">lines added / removed · range</div></div>
142
+ <div class="card-h"><h3>Code churn</h3><div class="meta">lines added / removed · range</div></div>
144
143
  <div class="churn-row">
145
144
  <div class="churn-spark">
146
145
  <svg id="churn-svg" viewBox="0 0 800 60" preserveAspectRatio="none"></svg>
@@ -160,7 +159,7 @@
160
159
  <div class="right"><span id="tok-cache-pct">—</span> from cache</div>
161
160
  </div>
162
161
  <div class="stat-row" style="margin-bottom: 0; grid-template-columns: repeat(3, 1fr);">
163
- <div class="stat-card"><div class="label">Grand total</div><div class="value"><span id="tok-grand">—</span></div><div class="meta"><span class="num" id="tok-grand-sub">in + out + cache</span></div></div>
162
+ <div class="stat-card"><div class="label">Grand total</div><div class="value"><span id="tok-grand">—</span></div><div class="meta"><span class="num">in + out + cache</span></div></div>
164
163
  <div class="stat-card"><div class="label">Output</div><div class="value"><span id="tok-out">—</span></div><div class="meta"><span class="num" id="tok-in-sub">input —</span></div></div>
165
164
  <div class="stat-card"><div class="label">Cache</div><div class="value"><span id="tok-cache">—</span></div><div class="meta"><span class="num" id="tok-cache-sub">read — · write —</span></div></div>
166
165
  </div>
@@ -170,7 +169,7 @@
170
169
  <section>
171
170
  <div class="section-head">
172
171
  <h2>Projects · tools · files</h2>
173
- <div class="right" id="lb-meta">across <span id="lb-sessions">—</span> sessions</div>
172
+ <div class="right">all time · across <span id="lb-sessions">—</span> sessions</div>
174
173
  </div>
175
174
  <div class="lb-grid">
176
175
  <div class="lb">
@@ -192,7 +191,7 @@
192
191
  <section>
193
192
  <div class="section-head">
194
193
  <h2>Shell · web · subagents</h2>
195
- <div class="right"><span id="mcp-label">—</span></div>
194
+ <div class="right">all time · <span id="mcp-label">—</span></div>
196
195
  </div>
197
196
  <div class="lb-grid">
198
197
  <div class="lb">
@@ -265,7 +264,6 @@
265
264
  <div class="help-card">
266
265
  <h4>Keyboard shortcuts</h4>
267
266
  <div class="row"><span class="keys"><span class="kbd">1</span><span class="kbd">5</span></span><span>switch range</span></div>
268
- <div class="row"><span class="keys"><span class="kbd">t</span></span><span>toggle theme</span></div>
269
267
  <div class="row"><span class="keys"><span class="kbd">esc</span></span><span>close drawer / modal</span></div>
270
268
  <div class="row"><span class="keys"><span class="kbd">?</span></span><span>this help</span></div>
271
269
  </div>
@@ -3,20 +3,30 @@
3
3
  const app = document.getElementById('app');
4
4
 
5
5
  // ── format helpers ───────────────────────────────────────────
6
+ // fmtNum is an inline copy of src/fmt.js fmtNum (this is a browser asset, it
7
+ // can't import it) — the same formatter the site's web Wrapped uses, so both
8
+ // pages print 1500000 as "1.50M". The unit is picked from the ROUNDED value
9
+ // (999999 → "1.00M"). Keep the copies in sync.
6
10
  const fmtNum = (n) => {
7
- n = +n || 0;
8
- if (n < 1000) return String(Math.round(n));
9
- if (n < 1e6) return (n / 1e3).toFixed(1).replace(/\.0$/, '') + 'k';
10
- if (n < 1e9) return (n / 1e6).toFixed(2).replace(/\.?0+$/, '') + 'M';
11
- if (n < 1e12) return (n / 1e9).toFixed(2).replace(/\.?0+$/, '') + 'B';
12
- return (n / 1e12).toFixed(2).replace(/\.?0+$/, '') + 'T';
11
+ if (!n) return '0';
12
+ const neg = n < 0 ? '-' : '';
13
+ const v = Math.abs(n);
14
+ if (v < 1000) return neg + Math.round(v);
15
+ for (const [suf, div, prec] of [['k', 1e3, 1], ['M', 1e6, 2], ['B', 1e9, 2], ['T', 1e12, 2]]) {
16
+ const s = (v / div).toFixed(prec);
17
+ if (Number(s) < 1000) return neg + s + suf;
18
+ }
19
+ return neg + (v / 1e12).toFixed(2) + 'T';
13
20
  };
14
21
  const fmtHours = (ms) => { const h = (ms || 0) / 3.6e6; return h < 1 ? Math.round(h * 60) + 'm' : h < 10 ? h.toFixed(1) + 'h' : Math.round(h) + 'h'; };
15
22
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;' }[c]));
16
23
  const GIF = 'https://cdn.qualit.ly/';
17
24
 
18
- // anim-stagger style helper
19
- let _i = 0; const A = () => `style="--i:${_i++}"`;
25
+ // anim-stagger style helper. Extra declarations go INTO this one attribute:
26
+ // a second style="" on the same tag is dropped by the HTML parser (the first
27
+ // duplicate attribute wins). Don't put `opacity` here — the rise animation
28
+ // runs with fill-mode forwards and owns opacity on .anim elements.
29
+ let _i = 0; const A = (extra) => `style="--i:${_i++}${extra ? ';' + extra : ''}"`;
20
30
 
21
31
  // Landing-page CTA used by the finale share. The dashboard is served on
22
32
  // localhost, so sharing `location.href` hands the recipient a dead link —
@@ -80,7 +90,7 @@
80
90
  const age = d.hotspot.daysSinceLastEdit == null ? '' : d.hotspot.daysSinceLastEdit === 0 ? ' · still warm today' : ` · last touched ${d.hotspot.daysSinceLastEdit}d ago`;
81
91
  S('ink', `
82
92
  <div class="kicker anim" ${A()}>you kept coming back to</div>
83
- <div class="big anim" ${A()} style="font-family:'JetBrains Mono',monospace;font-size:clamp(30px,9vw,68px);--i:1">${esc(d.hotspot.name)}</div>
93
+ <div class="big anim" ${A("font-family:'JetBrains Mono',monospace;font-size:clamp(30px,9vw,68px)")}>${esc(d.hotspot.name)}</div>
84
94
  <div class="sub anim" ${A()}>${fmtNum(d.hotspot.count)} edits${age}</div>`);
85
95
  }
86
96
 
@@ -93,14 +103,19 @@
93
103
 
94
104
  // 9. model split
95
105
  if (d.modelSplit && d.modelSplit.length) {
106
+ // The rows are built before the slide markup, so stagger slot 0 is
107
+ // reserved for the kicker that sits above them.
108
+ const kicker = A();
96
109
  const rows = d.modelSplit.filter((m) => m.costPct > 0).map((m) => {
97
110
  const pct = Math.round(m.costPct * 100);
98
111
  return `<div class="msrow anim" ${A()}><span class="lbl">${esc(m.model)}</span><span class="mstrack"><span class="msfill" style="--w:${pct}%"></span></span><span class="pct">${pct}%</span></div>`;
99
112
  }).join('');
113
+ // The dimming sits on an inner span: on the .anim element itself the
114
+ // rise animation (fill-mode forwards) would override it.
100
115
  S('paper', `
101
- <div class="kicker anim" ${A()} style="--i:0">your models, by spend</div>
116
+ <div class="kicker anim" ${kicker}>your models, by spend</div>
102
117
  <div class="msplit">${rows}</div>
103
- <div class="sub anim" ${A()} style="opacity:.7">${esc((d.modelSplit[0] || {}).model || '')} did most of the heavy lifting</div>`);
118
+ <div class="sub anim" ${A()}><span style="opacity:.7">${esc((d.modelSplit[0] || {}).model || '')} did most of the heavy lifting</span></div>`);
104
119
  }
105
120
 
106
121
  // 10. lines
@@ -1,8 +1,8 @@
1
1
  /* Claude Wrapped — full-screen, animated, Spotify-Wrapped-style story. */
2
2
  * { margin: 0; padding: 0; box-sizing: border-box; }
3
3
  :root {
4
- --ink: #1a1611; --paper: #f4ede0; --rust: #c2491e; --rust3: #f08a4a;
5
- --tape: #f2d76e; --grass: #4a9462; --blurple: #5865f2; --plum: #7b3f6b;
4
+ --ink: #1a1611; --paper: #f4ede0; --rust: #c2491e;
5
+ --tape: #f2d76e; --grass: #4a9462;
6
6
  }
7
7
  html, body { height: 100%; overflow: hidden; background: var(--ink); }
8
8
  body {