roast-my-design-system 5.7.2 → 5.8.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/README.md CHANGED
@@ -60,17 +60,17 @@ One scan powers all of it; the flags decide what lands on disk. Combine freely.
60
60
 
61
61
  The full report for vercel/ai-chatbot, top to bottom — including "What the numbers mean", Claude's read of the scan, embedded right under the verdict:
62
62
 
63
- ![The full diagnosis report for vercel/ai-chatbot in dark mode: health score, the What the numbers mean analysis written by Claude, priced Where to start moves each with its copy-the-fix-prompt button, the wrapped present with the agent rules, an agent trap callout, three-yardstick tiles, the adoption map treemap, palette forensics, spacing receipts, typography specimens, offenders, duplicates, and the component usage ledger](https://raw.githubusercontent.com/gregkozakiewicz/roast-my-design-system/main/assets/report-full-dark.png?v=5.7.2)
63
+ ![The full diagnosis report for vercel/ai-chatbot in dark mode: health score, the What the numbers mean analysis written by Claude, priced Where to start moves each with its copy-the-fix-prompt button, the wrapped present with the agent rules, an agent trap callout, three-yardstick tiles, the adoption map treemap, palette forensics, spacing receipts, typography specimens, offenders, duplicates, and the component usage ledger](https://raw.githubusercontent.com/gregkozakiewicz/roast-my-design-system/main/assets/report-full-dark.png?v=5.8.0)
64
64
 
65
65
  The same report in light mode (one file, built-in toggle):
66
66
 
67
- ![The diagnosis report in light mode](https://raw.githubusercontent.com/gregkozakiewicz/roast-my-design-system/main/assets/report-light-hero.png?v=5.2.3)
67
+ ![The diagnosis report in light mode](https://raw.githubusercontent.com/gregkozakiewicz/roast-my-design-system/main/assets/report-light-hero.png?v=5.8.0)
68
68
 
69
69
  ## What makes the numbers trustworthy
70
70
 
71
71
  - **Deterministic scanner, not AI sampling.** A zero-dependency Node script reads *every* file (about a second on a normal repo, a few on a large monorepo) and returns the same numbers every run. Claude narrates; it never counts.
72
72
  - **Read-only.** Nothing in your repo is modified. The only outputs are a temp JSON and the HTML report.
73
- - **No network, no telemetry.** Everything runs locally. Nothing about your code leaves your machine.
73
+ - **No network, no telemetry.** Everything runs locally. Nothing about your code leaves your machine. Dependency scanners such as Socket may flag URL strings in this package; they are product links and format identifiers written into generated reports, never fetched.
74
74
  - **Zero dependencies, enforced by the test suite.** The package installs nothing but itself, and that is a tested promise rather than a habit: the suite fails if package.json ever declares a dependency, and the exact file list npm ships is a photographed contract, so nothing can stow away in a release.
75
75
  - **Honest gaps.** When a repo's components register in a pattern the scan cannot read, the component tiles say "not measured" and drop out of the score. A zero the scanner never earned is presented as blindness, not discipline.
76
76
  - **Honest exclusions.** Test files, Storybook stories, docs sites, example apps, SVG artwork, and email templates (which *must* inline styles) are excluded, so you can't discredit the numbers on a technicality. Your own exclusions (`.roastignore`, `--exclude`) are printed in the report header with file counts, so a scoped scan can never pass itself off as the whole repo.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roast-my-design-system",
3
- "version": "5.7.2",
3
+ "version": "5.8.0",
4
4
  "mcpName": "io.github.gregkozakiewicz/roast-my-design-system",
5
5
  "description": "Your AI can write the UI. This makes sure it writes your UI. A deterministic scanner scores your design system 0-100 against 34 public repos, reads React and web components (Stencil, Lit), hands you a copy-paste fix prompt for each top finding, writes rules for Claude, Cursor, Copilot and Windsurf with --apply, and runs as a local MCP server with --mcp.",
6
6
  "keywords": [
@@ -29,6 +29,7 @@ import { neverImportedComponents } from '../lib/neverimported.mjs';
29
29
  import { VERSION } from '../lib/version.mjs';
30
30
  import { feedbackUrl, FEEDBACK_ASK, FEEDBACK_CTA } from '../lib/feedback.mjs';
31
31
  import { fixPrompt } from '../lib/fixprompt.mjs';
32
+ import { WHY } from './why.mjs';
32
33
 
33
34
  // The benchmark (Ideal-2026 norms + scanned-repo stats) ships next to the
34
35
  // code so the page works offline; degrade gracefully when absent.
@@ -343,18 +344,22 @@ function healthOf(metric, value) {
343
344
  if (value <= warnCap) return 'warn';
344
345
  return 'bad';
345
346
  }
347
+ // Our own marks, drawn by hand for this report: a tick that starts at the
348
+ // left foot, a full-bleed cross, a round exclamation, a quiet dash. Generic
349
+ // glyphs on purpose, and our own coordinates on purpose: nothing here is
350
+ // copied from any icon set.
346
351
  const ICONS = {
347
- good: '<svg class="ic ic-good" viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"/></svg>',
348
- warn: '<svg class="ic ic-warn" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12" y2="16.01"/></svg>',
349
- bad: '<svg class="ic ic-bad" viewBox="0 0 24 24"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',
352
+ good: '<svg class="ic ic-good" viewBox="0 0 24 24"><polyline points="4.5 12.5 9.5 17.5 19.5 6.5"/></svg>',
353
+ warn: '<svg class="ic ic-warn" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9.5"/><line x1="12" y1="7.5" x2="12" y2="13"/><line x1="12" y1="16.5" x2="12" y2="16.51"/></svg>',
354
+ bad: '<svg class="ic ic-bad" viewBox="0 0 24 24"><line x1="18.5" y1="5.5" x2="5.5" y2="18.5"/><line x1="5.5" y1="5.5" x2="18.5" y2="18.5"/></svg>',
350
355
  info: '',
351
- na: '<svg class="ic ic-na" viewBox="0 0 24 24"><line x1="7" y1="12" x2="17" y2="12"/></svg>',
356
+ na: '<svg class="ic ic-na" viewBox="0 0 24 24"><line x1="6.5" y1="12" x2="17.5" y2="12"/></svg>',
352
357
  };
353
358
 
354
- // Feather "activity", the pulse line, points reversed so it traces left to
355
- // right. Sits before the footer's feedback link
356
- // and inherits its colour through currentColor, so it follows the theme.
357
- const PULSE_ICON = '<svg class="pulse" viewBox="0 0 24 24" aria-hidden="true"><polyline points="2 12 6 12 9 3 15 21 18 12 22 12"/></svg>';
359
+ // The heartbeat line, drawn by hand: flat, one beat, flat. It traces left to
360
+ // right, sits before the footer's feedback link and inherits its colour
361
+ // through currentColor, so it follows the theme.
362
+ const PULSE_ICON = '<svg class="pulse" viewBox="0 0 24 24" aria-hidden="true"><polyline points="2 12.5 6.5 12.5 9.5 4 15 20.5 18 12.5 22 12.5"/></svg>';
358
363
 
359
364
  // Comparison rows inside a tile: your number vs each yardstick.
360
365
  // ▼ mint = you sit at or under the reference, ▲ coral = you're over it.
@@ -468,6 +473,12 @@ const statTile = (s) => `<div class="stat glass st-${s.health}">
468
473
  const eyebrow = (text) => `<div class="eyebrow">${text}</div>`;
469
474
  const sectionHead = (title, subtitle) => `<div class="sec-head"><h2>${title}</h2>${subtitle ? `<p class="sub">${subtitle}</p>` : ''}</div>`;
470
475
 
476
+ // "Why this matters": the calm explanation folded under a brutal finding,
477
+ // same unfold mechanics as the fix-prompt viewer. One per finding, rendered
478
+ // only where that finding's evidence block rendered.
479
+ const WHY_ICON = '<svg class="why-ic" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9.5"/><path d="M9.3 9.1a2.8 2.8 0 1 1 4 3.1c-.9.5-1.3 1.1-1.3 2.1"/><line x1="12" y1="17.2" x2="12" y2="17.21"/></svg>';
480
+ const whyToggle = (key) => (WHY[key] ? `<div class="whywrap"><button type="button" class="whybtn" data-why="${key}">${WHY_ICON}<span class="why-lab">why this matters</span></button><div class="whytext" hidden id="why-${key}">${WHY[key].map((p) => `<p>${p}</p>`).join('')}</div></div>` : '');
481
+
471
482
  function paletteSection() {
472
483
  if (!colors.length) return '';
473
484
  const tokens = colors.filter((c) => c.isToken).length;
@@ -491,7 +502,8 @@ function paletteSection() {
491
502
  const ramp = greys.length >= 4 ? `
492
503
  <div class="ramp-head">${eyebrow('Grey ramp · sorted dark → light · how many can you tell apart?')}</div>
493
504
  <div class="only-dark">${rampFor(greys)}</div>
494
- <div class="only-light">${rampFor(greysLight)}</div>` : '';
505
+ <div class="only-light">${rampFor(greysLight)}</div>
506
+ ${whyToggle('greys')}` : '';
495
507
 
496
508
  return `<section class="palette-grid">
497
509
  <div class="glass pal-hero grad">
@@ -502,6 +514,7 @@ function paletteSection() {
502
514
  <div class="split-track"><div class="split"><span class="sp-tok" style="width:${tokenPct}%"></span><span class="sp-stray" style="width:${100 - tokenPct}%"></span></div></div>
503
515
  <div class="split-legend"><span>${n(tokens)} tokens</span><span>${n(strays)} strays</span></div>
504
516
  ${tokens ? '' : `<p class="sub warn-text">None of these are defined as CSS variables. Every single one is a hardcoded value.</p>`}
517
+ ${whyToggle('colors')}
505
518
  </div>
506
519
  <div class="glass pal-usage">
507
520
  <div class="pal-usage-head">
@@ -512,7 +525,8 @@ function paletteSection() {
512
525
  ${ramp}
513
526
  ${nearPairs.length ? `
514
527
  <div class="receipts">${eyebrow(`${nearPairs.length} nearly identical pair${nearPairs.length === 1 ? '' : 's'} · copy-paste, not decisions`)}
515
- <div class="chips-row">${nearPairs.slice(0, 8).map((pr) => `<span class="vchip" title="every channel within ${pr.d} of its twin"><i class="ndot" style="background:${esc(pr.a.value)}"></i>${esc(pr.a.value)} ×${pr.a.count} <b class="nsim">≈</b> <i class="ndot" style="background:${esc(pr.b.value)}"></i>${esc(pr.b.value)} ×${pr.b.count}</span>`).join('')}${nearPairs.length > 8 ? `<span class="vchip dim">+${nearPairs.length - 8} more</span>` : ''}</div></div>` : ''}
528
+ <div class="chips-row">${nearPairs.slice(0, 8).map((pr) => `<span class="vchip" title="every channel within ${pr.d} of its twin"><i class="ndot" style="background:${esc(pr.a.value)}"></i>${esc(pr.a.value)} ×${pr.a.count} <b class="nsim">≈</b> <i class="ndot" style="background:${esc(pr.b.value)}"></i>${esc(pr.b.value)} ×${pr.b.count}</span>`).join('')}${nearPairs.length > 8 ? `<span class="vchip dim">+${nearPairs.length - 8} more</span>` : ''}</div>
529
+ ${whyToggle('nearPairs')}</div>` : ''}
516
530
  </div>
517
531
  </section>`;
518
532
  }
@@ -580,10 +594,12 @@ function spacingBars() {
580
594
  <span class="bar-count">${n(s.count)}</span></div>`).join('');
581
595
  const arb = arbitraryCount ? `
582
596
  <div class="receipts">${eyebrow(`${n(arbitraryCount)} arbitrary values punched through the scale, one bracket at a time`)}
583
- <div class="chips-row">${arbitrary.slice(0, 10).map((a) => `<span class="vchip bad" title="${esc(a.files?.[0]?.file ?? '')}">${esc(a.value)} ×${a.count}</span>`).join('')}${arbitrary.length > 10 ? `<span class="vchip dim">+${arbitrary.length - 10} more</span>` : ''}</div></div>` : '';
597
+ <div class="chips-row">${arbitrary.slice(0, 10).map((a) => `<span class="vchip bad" title="${esc(a.files?.[0]?.file ?? '')}">${esc(a.value)} ×${a.count}</span>`).join('')}${arbitrary.length > 10 ? `<span class="vchip dim">+${arbitrary.length - 10} more</span>` : ''}</div>
598
+ ${whyToggle('arbitrary')}</div>` : '';
584
599
  return `<section class="glass pad">
585
600
  ${sectionHead(`${n(spacingTotal)} off-scale spacing values`, `a disciplined repo keeps these around a dozen · on-scale Tailwind steps (·) shown for context · off-scale in coral`)}
586
- <div class="bars">${rows}</div>${arb}</section>`;
601
+ <div class="bars">${rows}</div>
602
+ ${whyToggle('spacing')}${arb}</section>`;
587
603
  }
588
604
 
589
605
  function duplicatesSection() {
@@ -612,7 +628,8 @@ function duplicatesSection() {
612
628
  </div>`).join('');
613
629
  return `<div class="glass pad half">
614
630
  ${sectionHead('Duplicated components', 'an agent asking which one is canonical gets several plausible answers. Paths open in VS Code')}
615
- <div class="fams">${iconCard}${dupeCards}${famCards}</div></div>`;
631
+ <div class="fams">${iconCard}${dupeCards}${famCards}</div>
632
+ ${whyToggle('duplicates')}</div>`;
616
633
  }
617
634
 
618
635
  // Scanned values get injected into style attributes below (a radius, a shadow,
@@ -695,6 +712,7 @@ function typographySection() {
695
712
  return `<section>
696
713
  ${sectionHead('Typography &amp; shape', '')}
697
714
  <div class="stats minis">${mini.map((s) => statTile(s)).join('')}</div>
715
+ ${typefaces.length ? whyToggle('typefaces') : ''}
698
716
  ${typeSpecimens || receipts('the font sizes, by use', sizeChips)}
699
717
  ${radiiSpecimens || receipts('the radii, by use', radiiChips)}
700
718
  ${shadowSpecimens}
@@ -723,7 +741,8 @@ function inlineSection() {
723
741
  const max = Math.max(...inline.files.slice(0, 6).map((f) => f.count), 1);
724
742
  const importantRow = important.count ? `
725
743
  <div class="receipts">${eyebrow(`${n(important.count)} !important declaration${important.count === 1 ? '' : 's'} · the cascade admitting defeat`)}
726
- <div class="chips-row">${important.files.map((f) => `<span class="vchip bad" title="${esc(f.file)}">${esc(basename(f.file))} ×${f.count}</span>`).join('')}</div></div>` : '';
744
+ <div class="chips-row">${important.files.map((f) => `<span class="vchip bad" title="${esc(f.file)}">${esc(basename(f.file))} ×${f.count}</span>`).join('')}</div>
745
+ ${whyToggle('important')}</div>` : '';
727
746
  const blocks = inline.count >= 5 ? `<div class="fam-rows">${inline.files.slice(0, 6).map((f) => `
728
747
  <div class="mini-card col">
729
748
  <div class="mc-row">${fileLink(f.file)}<span class="mc-count">×${f.count}</span></div>
@@ -731,7 +750,7 @@ function inlineSection() {
731
750
  </div>`).join('')}</div>` : '';
732
751
  return `<div class="glass pad half">
733
752
  ${sectionHead(inline.count >= 5 ? `${n(inline.count)} inline style blocks` : `${n(important.count)} !important declarations`, 'styling no system can see')}
734
- ${blocks}${importantRow}</div>`;
753
+ ${blocks}${inline.count >= 5 ? whyToggle('inline') : ''}${importantRow}</div>`;
735
754
  }
736
755
 
737
756
  // The adoption map: the real system drawn to scale as a treemap. Every
@@ -842,7 +861,8 @@ function componentsSection() {
842
861
  ${neverImported.length >= 2 ? `
843
862
  <div class="receipts">${eyebrow(isLibrary ? `${n(neverImported.length)} components unused internally · showroom stock to review, not dead weight: consumers in other repos are invisible from here` : `${n(neverImported.length)} components defined but never imported · they sit in the system as wrong answers waiting to be picked`)}
844
863
  ${orphanRows()}
845
- <p class="sub" style="margin-top:8px">Routers, dynamic imports and barrel files can hide real usage, so treat this as a shortlist to check, not a demolition order.</p>` : ''}</section>`;
864
+ <p class="sub" style="margin-top:8px">Routers, dynamic imports and barrel files can hide real usage, so treat this as a shortlist to check, not a demolition order.</p>
865
+ ${isLibrary ? '' : whyToggle('neverImported')}` : ''}</section>`;
846
866
  }
847
867
 
848
868
  // "Where to start" — at most three moves, every one derived from this repo's
@@ -1336,14 +1356,28 @@ const html = `<!doctype html>
1336
1356
  .only-light { display:none; }
1337
1357
  html[data-theme="light"] .only-light { display:block; }
1338
1358
  html[data-theme="light"] .only-dark { display:none; }
1339
- /* theme toggle */
1340
- .theme-toggle { position:fixed; top:18px; right:18px; z-index:10; width:40px; height:40px; border-radius:99px;
1341
- display:grid; place-items:center; cursor:pointer; color:var(--dim); }
1359
+ /* theme toggle: a slide switch. The knob is a lightly rounded square that
1360
+ carries the current mode's icon (moon in dark, sun in light) and slides
1361
+ to the other side on click. The icons themselves never animate. */
1362
+ .theme-toggle { position:fixed; top:18px; right:18px; z-index:10; width:88px; height:32px; border-radius:10px;
1363
+ cursor:pointer; color:var(--dim); padding:0; }
1342
1364
  .theme-toggle:hover { color:var(--text); }
1343
- .theme-toggle svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
1344
- .theme-toggle .only-light, html[data-theme="light"] .theme-toggle .only-light { display:none; }
1345
- html[data-theme="light"] .theme-toggle .only-light { display:block; }
1346
- .theme-toggle .only-dark { display:block; }
1365
+ .tt-lab { position:absolute; top:0; bottom:0; display:flex; align-items:center; font:700 9px var(--sans);
1366
+ letter-spacing:.14em; text-transform:uppercase; transition:opacity .3s ease; }
1367
+ .tt-day { left:13px; opacity:0; }
1368
+ .tt-night { right:13px; opacity:1; }
1369
+ html[data-theme="light"] .tt-day { opacity:1; }
1370
+ html[data-theme="light"] .tt-night { opacity:0; }
1371
+ .tt-knob { position:absolute; top:calc(50% - 13px); left:3px; width:26px; height:26px; border-radius:8px;
1372
+ background:var(--card-solid); box-shadow:0 1px 4px rgba(0,0,0,.3), 0 0 0 1px var(--line-soft);
1373
+ display:grid; place-items:center; transition:left .3s ease; }
1374
+ html[data-theme="light"] .theme-toggle .tt-knob { left:59px; }
1375
+ .tt-knob svg { grid-area:1/1; width:15px; height:15px; fill:none; stroke:currentColor; stroke-width:2;
1376
+ stroke-linecap:round; stroke-linejoin:round; transition:opacity .3s ease; }
1377
+ .tt-moon { opacity:1; } .tt-sun { opacity:0; }
1378
+ html[data-theme="light"] .tt-moon { opacity:0; }
1379
+ html[data-theme="light"] .tt-sun { opacity:1; }
1380
+ @media (prefers-reduced-motion: reduce) { .tt-knob, .tt-knob svg, .tt-lab { transition:none; } }
1347
1381
 
1348
1382
  /* palette */
1349
1383
  .palette-grid { display:grid; grid-template-columns:1fr 1.6fr; gap:16px; }
@@ -1413,6 +1447,23 @@ const html = `<!doctype html>
1413
1447
  user-select:all; -webkit-user-select:all; }
1414
1448
  @media print { .start-actions { display:none; } }
1415
1449
 
1450
+ .whywrap { margin-top:12px; }
1451
+ .whybtn { font:500 11.5px/1 var(--sans); color:var(--dim); background:none; border:none; padding:0; cursor:pointer;
1452
+ display:inline-flex; align-items:center; gap:5px; }
1453
+ .whybtn .why-lab { text-decoration:underline; text-underline-offset:3px; }
1454
+ .why-ic { width:15.5px; height:15.5px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
1455
+ .whybtn:hover { color:var(--accent); }
1456
+ /* On the light-mode gradient hero the dim grey is unreadable: follow the
1457
+ card's own white text treatment instead. */
1458
+ html[data-theme="light"] .grad .whybtn { color:rgba(255,255,255,.82); }
1459
+ html[data-theme="light"] .grad .whybtn:hover { color:#fff; }
1460
+ html[data-theme="light"] .grad .whytext.shown { border-color:rgba(255,255,255,.35); }
1461
+ html[data-theme="light"] .grad .whytext p { color:rgba(255,255,255,.88); }
1462
+ .whytext.shown { display:block; border:1px solid var(--line); border-radius:10px; padding:12px 14px; margin-top:8px; }
1463
+ .whytext p { font:13px/1.7 var(--sans); color:var(--dim); margin:0 0 10px; }
1464
+ .whytext p:last-child { margin-bottom:0; }
1465
+ @media print { .whybtn { display:none; } .whytext.shown { border:none; padding:0; } }
1466
+
1416
1467
  .pill { border-radius:99px; padding:3px 10px; font:500 10.5px/1.5 var(--sans); white-space:nowrap; }
1417
1468
  .pill-mint { background:var(--ok-soft); color:var(--ok); }
1418
1469
  .pill-coral { background:var(--coral-soft); color:var(--coral); }
@@ -1478,10 +1529,10 @@ const html = `<!doctype html>
1478
1529
  .foot-sub .feedback:hover { text-decoration:underline; }
1479
1530
  .foot-sub .pulse { width:14px; height:14px; vertical-align:-3px; margin-right:5px; fill:none;
1480
1531
  stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
1481
- /* The line traces itself and sweeps out, like a heart monitor. 46 is the
1532
+ /* The line traces itself and sweeps out, like a heart monitor. 44 is the
1482
1533
  polyline's own length, so the dash covers it exactly. */
1483
- .foot-sub .pulse polyline { stroke-dasharray:46; animation:pulse-trace 3.4s cubic-bezier(.5,0,.5,1) infinite; }
1484
- @keyframes pulse-trace { 0% { stroke-dashoffset:46; } 55% { stroke-dashoffset:0; } 100% { stroke-dashoffset:-46; } }
1534
+ .foot-sub .pulse polyline { stroke-dasharray:44; animation:pulse-trace 3.4s cubic-bezier(.5,0,.5,1) infinite; }
1535
+ @keyframes pulse-trace { 0% { stroke-dashoffset:44; } 55% { stroke-dashoffset:0; } 100% { stroke-dashoffset:-44; } }
1485
1536
  @media (prefers-reduced-motion: reduce) {
1486
1537
  .foot-sub .pulse polyline { animation:none; stroke-dashoffset:0; }
1487
1538
  }
@@ -1560,8 +1611,12 @@ const html = `<!doctype html>
1560
1611
  <!-- rmds-schema: ${NS_TAG} -->
1561
1612
  </head><body>
1562
1613
  <button class="theme-toggle glass" aria-label="Switch between light and dark mode" onclick="(function(){var r=document.documentElement,t=r.getAttribute('data-theme')==='light'?'dark':'light';r.setAttribute('data-theme',t);try{localStorage.setItem('roast-theme',t)}catch(e){}})()">
1563
- <svg class="only-dark" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="5"/><line x1="12" y1="19" x2="12" y2="22"/><line x1="2" y1="12" x2="5" y2="12"/><line x1="19" y1="12" x2="22" y2="12"/><line x1="4.9" y1="4.9" x2="7" y2="7"/><line x1="17" y1="17" x2="19.1" y2="19.1"/><line x1="4.9" y1="19.1" x2="7" y2="17"/><line x1="17" y1="7" x2="19.1" y2="4.9"/></svg>
1564
- <svg class="only-light" viewBox="0 0 24 24"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg>
1614
+ <span class="tt-lab tt-day">Day</span>
1615
+ <span class="tt-lab tt-night">Night</span>
1616
+ <span class="tt-knob">
1617
+ <svg class="tt-moon" viewBox="0 0 24 24"><path d="M20.5 13.2A8.8 8.8 0 1 1 10.8 3.5a6.9 6.9 0 0 0 9.7 9.7z"/></svg>
1618
+ <svg class="tt-sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4.2"/><line x1="12" y1="2.2" x2="12" y2="5.4"/><line x1="12" y1="18.6" x2="12" y2="21.8"/><line x1="2.2" y1="12" x2="5.4" y2="12"/><line x1="18.6" y1="12" x2="21.8" y2="12"/><line x1="5.1" y1="5.1" x2="7.3" y2="7.3"/><line x1="16.7" y1="16.7" x2="18.9" y2="18.9"/><line x1="5.1" y1="18.9" x2="7.3" y2="16.7"/><line x1="16.7" y1="7.3" x2="18.9" y2="5.1"/></svg>
1619
+ </span>
1565
1620
  </button>
1566
1621
  <script>try{var t=localStorage.getItem('roast-theme');if(t==='light'||t==='dark')document.documentElement.setAttribute('data-theme',t)}catch(e){}</script>
1567
1622
  <div class="wrap">
@@ -1673,6 +1728,15 @@ ${componentsSection()}
1673
1728
  v.textContent=show?'hide it':'view it first';
1674
1729
  });
1675
1730
  });
1731
+ document.querySelectorAll('.whybtn').forEach(function(b){
1732
+ b.addEventListener('click', function(){
1733
+ var holder=document.getElementById('why-'+b.getAttribute('data-why'));
1734
+ if(!holder) return;
1735
+ var show=holder.hidden;
1736
+ holder.hidden=!show; holder.classList.toggle('shown', show);
1737
+ var lab=b.querySelector('.why-lab'); if(lab) lab.textContent=show?'hide':'why this matters';
1738
+ });
1739
+ });
1676
1740
  var copyBtn=document.getElementById('gift-copy');
1677
1741
  function rulesText(){ return document.getElementById('gift-md').textContent; }
1678
1742
  copyBtn.addEventListener('click', function(){
@@ -0,0 +1,61 @@
1
+ // "Why this matters" toggle copy — one entry per finding, unfolds under the
2
+ // finding's own evidence block. The finding stays brutal; this text is the calm
3
+ // explanation behind it: innocent mechanism, compounding cost, agent amplifier,
4
+ // why the ideal sits where it sits.
5
+ //
6
+ // The copy is Greg-approved word for word (docs/why-behind-copy-approved.md,
7
+ // 2026-09-04) and follows docs/greg-copy-style.md. Do not edit casually: every
8
+ // number in these texts is a published calibration (ideals + benchmark medians)
9
+ // and must move together with benchmark.json if the norms are ever re-tuned.
10
+
11
+ export const WHY = {
12
+ colors: [
13
+ 'Look, nobody consciously chooses 100 colours to start with. They were added with each change, and the change after that. No one was checking for the drift, because no one expected it. Then come the multipliers: a rebrand, a dark-mode pass, ad hoc files, each one multiplying the values again.',
14
+ 'When an agent looks for Brand Blue it scans the repo, sees dozens of blues and logically picks the one used most often, which is how the most-used stray outvotes the actual token.',
15
+ '24 covers a whole product: a brand hue with its tints, an accent, the greys, the status colours. The median across 10 reputable design systems is exactly 24.',
16
+ ],
17
+ nearPairs: [
18
+ 'A palette is a set of decisions, and two colours a screen can not tell apart are one decision recorded twice. Nobody chooses to own both: someone could not find the first value quickly enough, made a twin by eye, and it stayed.',
19
+ 'The cost is never tonight’s screen, which looks fine. It is every choice that comes after: colour pickers now offer both, a search for one misses the other, a dark-mode pass updates one twin and ships the other unchanged, and an agent asked for the dark surface copies whichever it happens to find, so the pair breeds.',
20
+ 'The ideal is 0 because each pair collapses in minutes: keep the one that is already a token, point the stray at it, and the multiplication stops. Pound for pound, the cheapest credibility on this page.',
21
+ ],
22
+ greys: [
23
+ 'A grey scale is a ladder: each step needs a job (background, border, muted text, disabled) and a visible gap to its neighbours. Around 12 rungs covers every job a real interface has; the reputable systems median is 5.',
24
+ 'Past 13 the gaps close, steps stop being distinguishable, and each new grey is no longer a rung but a guess between rungs, which is exactly where twins come from.',
25
+ ],
26
+ spacing: [
27
+ 'Nobody starts a design system with 50 spacing values. A deadline, a last-minute change, and someone nudged a layout until it sat right, and 13px honestly sat better than 12px. The next person can not tell a deliberate exception from a new value, or honestly never noticed, and copies it either way.',
28
+ 'That is how layout rhythm starts drifting. Two lists almost align, two cards almost match, and the page stops looking right. An agent copies nudge after nudge, because to an agent 13px looks as intentional as 12px. And once one page carries enough exceptions, the agent treats them as canonical, and the poison spreads to the other pages.',
29
+ 'The 12 is a budget for values outside the scale, and it is a generous one: the 10 reputable design systems we scanned hold a median of 6. The average product repo carries 34, which is a second, unwritten scale.',
30
+ ],
31
+ typefaces: [
32
+ 'One product should have a maximum of 3 font families. When they arrive on their own, it is usually one with a component library, one with a marketing page, one left over from an old logo. Bold and italic do not count; those are weights of one family. And no one will take the risk of removing a font, because nobody is sure what still uses it and what will break.',
33
+ 'Every extra font makes pages heavier to load, adds a licence to track, and splits the product’s voice. An agent starting a new page scans the repo, sees several fonts in use, and may feel obligated to use all of them. The split grows on its own.',
34
+ 'The ideal is 3, one for each real job: a sans for the interface, a serif if the brand wants an accent, a mono for code.',
35
+ ],
36
+ duplicates: [
37
+ 'Nobody builds a second Button on purpose. The first one was hard to find, or almost right but easier to rewrite than to change. On the day, rewriting was the faster choice. And no one deletes the old one later, because nobody is sure what still uses it and what will break.',
38
+ 'From then on, every fix reaches one copy and misses the other. Every search has a wrong answer on offer. An agent picks whichever version it happens to find, and every new page makes the more common copy stronger. Common wins over correct, and the drift only deepens.',
39
+ 'The ideal is 0, because the fix is cheap: point one copy at the other and the multiplying stops. The average product repo carries 20 duplicated components.',
40
+ ],
41
+ inline: [
42
+ 'An inline style is the fastest way to make one element behave. A deadline, one stubborn element, done. On the day, a fair trade.',
43
+ 'The cost is that the design system can not see it. Theming misses it, dark mode misses it, a token change misses it. Every inline style is a private exception and requires someone to find it by hand. And agents like inline styles, because they always work and they need no knowledge of your system. Every block already in the repo teaches the agent that this is how styling is done here, so the habit spreads.',
44
+ 'The ideal is 0, and the count is fair: only fully static blocks are counted, runtime positioning and canvas work are exempt. The average product repo carries 49 blocks. The 10 reputable systems hold a median of 12.',
45
+ ],
46
+ important: [
47
+ 'Every !important marks a styling fight someone had to win by the end of the day. One is harmless. And no one removes it later, because nobody is sure what will break.',
48
+ 'But each one raises the floor. The next override in that area has to shout at least as loud, so the count only climbs. An agent that loses a styling fight reaches for !important straight away, because it is the most common CSS fix it has ever seen.',
49
+ 'The ideal is 0, because !important is CSS admitting defeat. Fix the rule that kept losing, and the next one is never needed. The average product repo carries 7.',
50
+ ],
51
+ neverImported: [
52
+ 'A component nobody imports was built for a future that moved, or replaced and never removed. Writing it was probably right at the time. Leaving it on the shelf is the only mistake.',
53
+ 'Every dead component makes the catalogue slower to search and harder to trust. An agent reading your components folder can not tell retired from current, so a dead component becomes a live example to copy.',
54
+ 'The ideal is 0, because a design system is the set of things actually in use. And these are the safest deletes in the repo: nothing imports them, so nothing can break. Delete, or mark as deprecated where the agent will read it.',
55
+ ],
56
+ arbitrary: [
57
+ 'Brackets exist for a reason. Sometimes the scale really lacks a value, and one w-[137px] for a stubborn third-party embed is craft, done on purpose.',
58
+ 'But a bracket is a value with no name. A search for the token will never find it, and a scale change leaves it untouched. An agent that sees brackets in the repo learns that the scale is optional. It can not tell which brackets were deliberate, so it feels free to add its own, and the escape hatch becomes the main door.',
59
+ 'The 20 is a budget for real exceptions, and it is a generous one: 9 of the 10 reputable systems we scanned sit at 0, including systems built on Tailwind. The average product repo carries 70.',
60
+ ],
61
+ };
@@ -1,4 +1,4 @@
1
1
  // Single version constant for the engine — imported by diagnose (report
2
2
  // footer) and rules (generated-by line). This is the bump spot that used to
3
3
  // live as a const inside diagnose/index.mjs.
4
- export const VERSION = '5.7.2';
4
+ export const VERSION = '5.8.0';