basalt-ui 2.14.0 → 2.16.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.
Files changed (134) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/MIGRATING.md +81 -13
  3. package/agent/agents/basalt-design-reviewer.md +83 -0
  4. package/agent/rules/basalt-batteries.md +1 -2
  5. package/agent/rules/basalt-charts.md +1 -1
  6. package/agent/rules/basalt-controls.md +3 -3
  7. package/agent/rules/basalt-mantine.md +2 -3
  8. package/agent/rules/basalt-state.md +1 -2
  9. package/agent/rules/basalt-tokens.md +1 -3
  10. package/agent/skills/basalt-design/SKILL.md +26 -8
  11. package/agent/templates/AGENTS-block.md.tpl +7 -0
  12. package/configs/card-inset.test.ts +57 -0
  13. package/configs/oxlint-basalt.json +1 -1
  14. package/configs/oxlint-plugin.js +81 -20
  15. package/configs/oxlint-plugin.test.ts +85 -6
  16. package/dist/agent/chat/thread-message.js +1 -1
  17. package/dist/agent/chat/thread-outcome-card.js +1 -1
  18. package/dist/charts/ChartCard.js +1 -1
  19. package/dist/charts/chart-card.module.css +2 -2
  20. package/dist/charts/legend.d.ts +4 -4
  21. package/dist/cli/board-freshness.d.ts +25 -0
  22. package/dist/cli/board-freshness.d.ts.map +1 -0
  23. package/dist/cli/board-freshness.js +88 -0
  24. package/dist/cli/doctor.d.ts +2 -1
  25. package/dist/cli/doctor.d.ts.map +1 -1
  26. package/dist/cli/doctor.js +3 -1
  27. package/dist/cli/help.d.ts.map +1 -1
  28. package/dist/cli/help.js +9 -3
  29. package/dist/cli/index.d.ts +15 -1
  30. package/dist/cli/index.d.ts.map +1 -1
  31. package/dist/cli/index.js +57 -7
  32. package/dist/cli/init.d.ts.map +1 -1
  33. package/dist/cli/init.js +6 -1
  34. package/dist/cli/shot/board.d.ts +5 -0
  35. package/dist/cli/shot/board.d.ts.map +1 -0
  36. package/dist/cli/shot/board.js +96 -0
  37. package/dist/cli/shot/capture.d.ts +59 -0
  38. package/dist/cli/shot/capture.d.ts.map +1 -0
  39. package/dist/cli/shot/capture.js +473 -0
  40. package/dist/cli/shot/index.d.ts +45 -0
  41. package/dist/cli/shot/index.d.ts.map +1 -0
  42. package/dist/cli/shot/index.js +289 -0
  43. package/dist/cli/shot/measure.d.ts +47 -0
  44. package/dist/cli/shot/measure.d.ts.map +1 -0
  45. package/dist/cli/shot/measure.js +191 -0
  46. package/dist/cli/shot/playwright.d.ts +101 -0
  47. package/dist/cli/shot/playwright.d.ts.map +1 -0
  48. package/dist/cli/shot/playwright.js +60 -0
  49. package/dist/cli/shot/serve.d.ts +6 -0
  50. package/dist/cli/shot/serve.d.ts.map +1 -0
  51. package/dist/cli/shot/serve.js +33 -0
  52. package/dist/cli/shot/types.d.ts +98 -0
  53. package/dist/cli/shot/types.d.ts.map +1 -0
  54. package/dist/cli/shot/types.js +17 -0
  55. package/dist/cli/sync.d.ts.map +1 -1
  56. package/dist/cli/sync.js +2 -1
  57. package/dist/dashboard/settings-section.d.ts.map +1 -1
  58. package/dist/dashboard/settings-section.js +5 -2
  59. package/dist/dashboard/stat-card.js +12 -12
  60. package/dist/dashboard/stat-card.module.css +4 -4
  61. package/dist/dashboard/widget-header.module.css +3 -3
  62. package/dist/guard/guard-hook.d.ts.map +1 -1
  63. package/dist/guard/index.d.ts +4 -2
  64. package/dist/guard/index.d.ts.map +1 -1
  65. package/dist/guard/index.js +18 -4
  66. package/dist/guard/vx-names.d.ts.map +1 -1
  67. package/dist/guard/vx-names.js +1 -0
  68. package/dist/shell/app-mobile-nav.module.css +2 -2
  69. package/dist/shell/app-sidebar-account.js +1 -1
  70. package/dist/shell/app-sidebar.js +2 -2
  71. package/dist/shell/app-sidebar.module.css +8 -8
  72. package/dist/shell/index.js +5 -1
  73. package/dist/shell/page-bar.js +1 -1
  74. package/dist/surfaces.d.ts +2 -0
  75. package/dist/surfaces.d.ts.map +1 -1
  76. package/dist/surfaces.js +2 -0
  77. package/dist/table/data-table.d.ts.map +1 -1
  78. package/dist/table/data-table.js +3 -0
  79. package/dist/theme/index.d.ts.map +1 -1
  80. package/dist/theme/index.js +31 -21
  81. package/dist/tokens/core.d.ts +10 -4
  82. package/dist/tokens/core.d.ts.map +1 -1
  83. package/dist/tokens/core.js +16 -10
  84. package/dist/tokens/ctl-vars.d.ts +15 -0
  85. package/dist/tokens/ctl-vars.d.ts.map +1 -0
  86. package/dist/tokens/ctl-vars.js +22 -0
  87. package/dist/tokens/palette.d.ts +37 -29
  88. package/dist/tokens/palette.d.ts.map +1 -1
  89. package/dist/tokens/palette.js +32 -21
  90. package/dist/tokens/space-scale.d.ts +14 -0
  91. package/dist/tokens/space-scale.d.ts.map +1 -0
  92. package/dist/tokens/space-scale.js +10 -0
  93. package/llms.txt +2 -2
  94. package/package.json +1 -1
  95. package/src/agent/chat/thread-message.tsx +1 -1
  96. package/src/agent/chat/thread-outcome-card.tsx +2 -2
  97. package/src/charts/ChartCard.tsx +1 -1
  98. package/src/charts/chart-card.module.css +2 -2
  99. package/src/charts/legend.tsx +4 -4
  100. package/src/cli/board-freshness.ts +132 -0
  101. package/src/cli/doctor.ts +10 -1
  102. package/src/cli/help.ts +14 -2
  103. package/src/cli/index.ts +80 -10
  104. package/src/cli/init.ts +8 -1
  105. package/src/cli/shot/board.ts +154 -0
  106. package/src/cli/shot/capture.ts +650 -0
  107. package/src/cli/shot/index.ts +362 -0
  108. package/src/cli/shot/measure.ts +252 -0
  109. package/src/cli/shot/playwright.ts +152 -0
  110. package/src/cli/shot/serve.ts +35 -0
  111. package/src/cli/shot/types.ts +92 -0
  112. package/src/cli/sync.ts +2 -1
  113. package/src/dashboard/settings-section.tsx +5 -2
  114. package/src/dashboard/stat-card.module.css +4 -4
  115. package/src/dashboard/stat-card.tsx +13 -13
  116. package/src/dashboard/widget-header.module.css +3 -3
  117. package/src/guard/guard-hook.ts +3 -1
  118. package/src/guard/index.ts +27 -13
  119. package/src/guard/vx-names.ts +1 -0
  120. package/src/shell/app-mobile-nav.module.css +2 -2
  121. package/src/shell/app-sidebar-account.tsx +1 -1
  122. package/src/shell/app-sidebar.module.css +8 -8
  123. package/src/shell/app-sidebar.tsx +2 -2
  124. package/src/shell/index.tsx +10 -4
  125. package/src/shell/page-bar.tsx +1 -1
  126. package/src/surfaces.ts +5 -0
  127. package/src/table/data-table.tsx +10 -4
  128. package/src/theme/__snapshots__/plain-theme.test.ts.snap +57 -45
  129. package/src/theme/ctl-theme.tsx +1 -1
  130. package/src/theme/index.ts +43 -23
  131. package/src/tokens/core.ts +16 -8
  132. package/src/tokens/ctl-vars.ts +32 -0
  133. package/src/tokens/palette.ts +40 -29
  134. package/src/tokens/space-scale.ts +13 -0
@@ -1,3 +1,4 @@
1
+ import { SPACE_SCALE_LEVEL0 } from "./space-scale.js";
1
2
  import { DEFAULT_DERIVE_CONFIG, deriveTokens, isDefaultDeriveConfig } from "./derive.js";
2
3
  const BP = {
3
4
  black: "#18181b",
@@ -94,7 +95,7 @@ function deriveRadius(level) {
94
95
  `deriveRadius: level must be an integer in [${RADIUS_LEVEL_RANGE.min}, ${RADIUS_LEVEL_RANGE.max}], got ${level}`
95
96
  );
96
97
  }
97
- const card = clampRadius(7 + level);
98
+ const card = clampRadius(10 + level);
98
99
  const ctrl = clampRadius(6 + level);
99
100
  return {
100
101
  card,
@@ -116,7 +117,7 @@ const RADIUS_STEP = {
116
117
  /** Tooltip / Popover / Modal / Notification (`docs/DESIGN-SPEC.md` §5 floating tier) — one step
117
118
  * above the card radius. */
118
119
  floating: DEFAULT_RADIUS_VALUES.floating,
119
- // 8
120
+ // 11
120
121
  /** SegmentedControl's active indicator, Kbd, Code — one step below the control radius. */
121
122
  tight: DEFAULT_RADIUS_VALUES.tight,
122
123
  // 5
@@ -174,18 +175,18 @@ const SPACE_ANCHORS_BASE = {
174
175
  * 32, up from 30. At 30 this tier was the ONLY chrome number in the shell that did not agree with
175
176
  * its neighbours: the sidebar search trigger is 32 (`sidebarSearchTriggerHeight`), a sidebar block
176
177
  * row is 32 (`sidebarBlockRowHeight`), and a NavLink row resolves to ~32 (`2 * rowInsetY +
177
- * rowLineHeight * text.md`) — so a `size="ctl"` button sitting beside any of them read 2px short
178
+ * rowLineHeight * text.sm`, 12 + 1.54 * 13 = 32.02) — so a `size="ctl"` button sitting beside any of them read 2px short
178
179
  * and the whole band looked unresolved. 32 lands the entire chrome tier on ONE number, which is
179
180
  * also the smallest square that still holds a 16px icon with a 8px surround. */
180
- controlHeightCtl: 32
181
- };
182
- const SPACE_SCALE_BASE = {
183
- xs: 11,
184
- sm: 13,
185
- md: 18,
186
- lg: 20,
187
- xl: 26
181
+ controlHeightCtl: 32,
182
+ /** The DENSE control tier (`docs/waves/design-parity/SPEC.md` § 5, D6) — INTERNAL, no public export.
183
+ * `BasaltDataTable`'s toolbar and `FilterSet` rows re-point the `ctl` tier's size vars at this
184
+ * (`styles.css`, `[data-basalt-dense]`) at FINE pointers only, so a search, its filter pills and the
185
+ * actions share one row at 1440. A coarse pointer keeps `ctl` and the 44px hit overlay. Floored at
186
+ * 24px in {@link deriveSpacing} (WCAG 2.5.8). */
187
+ controlHeightDense: 28
188
188
  };
189
+ const SPACE_SCALE_BASE = SPACE_SCALE_LEVEL0;
189
190
  const SPACE_STEP_BASE = {
190
191
  /** Timeline `defaultProps.bulletSize`. */
191
192
  timelineBullet: 22,
@@ -462,6 +463,11 @@ const SPACE_STEP_BASE = {
462
463
  * (`shell/app-brand.module.css`), so the page gutter is free to be a gutter. The header's
463
464
  * breadcrumb, the page-bar band and Main all land on this one number. */
464
465
  appShellInset: 16,
466
+ /** The page gutter at the EXPANDED size class only — a TRIAL (`docs/waves/design-parity/SPEC.md`
467
+ * D7): the reference measures 24 at 1440, and 16 was a deliberate earlier choice down from 20, so
468
+ * the wider gutter applies where the evidence is and is reverted by setting this to
469
+ * `appShellInset` (one line). Medium keeps `appShellInset`, compact keeps `appShellInsetMobile`. */
470
+ appShellInsetExpanded: 24,
465
471
  /** The page gutter BELOW `sm` — the phone half of `appShellInset` above. A separate entry rather
466
472
  * than one responsive value for the same reason `appShellNavbarWidth` is one: there is no sidebar
467
473
  * seam to align to on a phone, so the number is answering a different question (how much of a
@@ -560,7 +566,7 @@ const SPACE_STEP_BASE = {
560
566
  // it never moved, so a 390px phone still read "content spacing too big" after the gutter fix.
561
567
  //
562
568
  // Each value is deliberately the rung of an existing ladder rather than a fresh literal: the card
563
- // inset IS `SPACE_SCALE.xs`/`.sm` (which is what `StatCard`/`ChartCard` spelled as
569
+ // inset IS `SPACE_SCALE.sm`/`.md` (12/16; the compact horizontal step is `.sm`) (which is what `StatCard`/`ChartCard` spelled as
564
570
  // `--mantine-spacing-xs`/`-sm` before they were named here) and the Section gap IS
565
571
  // `SPACE.stackMd`. Naming them buys the ROLE, not a new number — a role the `< sm` override can
566
572
  // then re-point without touching the scale every other consumer of `xs`/`sm` reads.
@@ -574,10 +580,10 @@ const SPACE_STEP_BASE = {
574
580
  * must render identically (a StatCard and a ChartCard sit in the same grid row). Does NOT step
575
581
  * below `sm`: the phone is short of WIDTH, and shaving the vertical inset of a card that already
576
582
  * hugs its content buys a few pixels at the cost of the card's own breathing room. */
577
- cardInsetY: 11,
583
+ cardInsetY: 12,
578
584
  /** Card inset, HORIZONTAL — same two files, same must-match reason. This IS the half that steps
579
- * below `sm` (to `SPACE_SCALE.xs`), because horizontal is where a 390px viewport is short. */
580
- cardInsetX: 13,
585
+ * in a compact container (to `SPACE_SCALE.sm`, 12), because horizontal is where a 390px viewport is short. */
586
+ cardInsetX: 16,
581
587
  /** `dashboard/section.module.css`'s header→body and body-child gap — a page-level GROUPING
582
588
  * rhythm, which is why it reads the stack scale rather than the card-inset one. Steps to
583
589
  * `SPACE.stackSm` below `sm`. Distinct from `sidebarSectionGap` above, which is the gap between
@@ -625,10 +631,11 @@ const SPACE_FIXED = {
625
631
  readingProgressHeight: 2,
626
632
  /** SegmentedControl track's optical inset (`styles.root` padding) — moved OUT of `SPACE_STEP` and
627
633
  * exempted from the density knob because it is load-bearing for the nested-corner law
628
- * (docs/DESIGN-SPEC.md §4): `RADIUS.card === RADIUS_STEP.tight + segmentedTrackInset` (`7 = 5 +
629
- * 2`). `RADIUS.card`/`RADIUS_STEP.tight` both shift together under the RADIUS knob (`card = 7 +
630
- * level`, `tight = ctrl - 1 = 5 + level`), so their difference is ALWAYS exactly 2 regardless of
631
- * that knob — a density-tracking inset would break concentricity in both directions (verified: this
634
+ * (docs/DESIGN-SPEC.md §4): `RADIUS.ctrl === RADIUS_STEP.fine + segmentedTrackInset` (`6 = 4 +
635
+ * 2`; the track takes the control radius, the indicator the `fine` tier). `RADIUS.ctrl`/
636
+ * `RADIUS_STEP.fine` both shift together under the RADIUS knob (`ctrl = 6 + level`, `fine = ctrl
637
+ * - 2`), so their difference is exactly 2 regardless of that knob (down to level -4; at -5 `fine`
638
+ * clamps to 0 against `ctrl` 1) — a density-tracking inset would break concentricity in both directions (verified: this
632
639
  * inset's own value, HAD it stayed density-tracking, resolves via `scaleSpace(2, level, multiplier)`
633
640
  * to 1 at density's floor level -3 and 3 at its ceiling level +3 — the widest swing `deriveSpacing`'s
634
641
  * `[-3, 3]` range can produce) for no compensating benefit, since the two radii it sits between
@@ -665,6 +672,7 @@ function deriveSpacing(level) {
665
672
  anchors.controlHeightTag = Math.max(18, anchors.controlHeightTag);
666
673
  anchors.controlHeightWidget = Math.max(22, anchors.controlHeightWidget);
667
674
  anchors.controlHeightCtl = Math.max(28, anchors.controlHeightCtl);
675
+ anchors.controlHeightDense = Math.max(24, anchors.controlHeightDense);
668
676
  const mappedStep = mapSpaceGroup(SPACE_STEP_BASE, level, multiplier);
669
677
  mappedStep.sidebarSearchTriggerHeight = Math.max(24, mappedStep.sidebarSearchTriggerHeight);
670
678
  mappedStep.mobileNavBarHeight = Math.max(49, mappedStep.mobileNavBarHeight);
@@ -684,7 +692,7 @@ function deriveSpacing(level) {
684
692
  step,
685
693
  // Additive, gentler, INDEPENDENT law than the multiplier — see `ROW_LINE_HEIGHT_STEP`'s own doc
686
694
  // for why it must NOT be computed from `multiplier`.
687
- rowLineHeight: Math.round((1.35 + ROW_LINE_HEIGHT_STEP * level) * 100) / 100
695
+ rowLineHeight: Math.round((1.54 + ROW_LINE_HEIGHT_STEP * level) * 100) / 100
688
696
  };
689
697
  }
690
698
  const DEFAULT_SPACE_VALUES = deriveSpacing(0);
@@ -723,7 +731,10 @@ function buildPaletteDataUncached(config) {
723
731
  // primary line
724
732
  line2: { light: BP.gray[1], dark: BP.gray[2] },
725
733
  // secondary line
726
- axis: { light: inkRgba(inkLight, 0.6), dark: "rgba(255, 255, 255, 0.6)" },
734
+ // Axis ticks / small chart labels at 10–11px: the DERIVED `faint` ink (opaque, tone stops in
735
+ // `derive.ts`'s `INK_TONE`, ≥ 4.5:1 on every text surface), not an ink-at-60% alpha — that
736
+ // measured 4.06:1 on the light panel (`docs/waves/design-parity/w31/s4-baseline.md`, Craft 5).
737
+ axis: DERIVED.ink.faint,
727
738
  axisStroke: { light: inkRgba(inkLight, 0.12), dark: "rgba(255, 255, 255, 0.12)" },
728
739
  grid: { light: inkRgba(inkLight, 0.07), dark: "rgba(255, 255, 255, 0.06)" },
729
740
  crosshair: { light: inkRgba(inkLight, 0.32), dark: "rgba(255, 255, 255, 0.42)" },
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The Mantine `spacing` size-scale at level 0, in its own dependency-free module so the headless
3
+ * guard core (`guard/index.ts`, which runs on every Write/Edit) can read the SAME constant the token
4
+ * layer derives from without dragging `derive.ts`/`hct.ts`'s colour math in. `tokens/palette.ts`
5
+ * documents the scale's role (`SPACE_SCALE_BASE`); this file only owns the numbers.
6
+ */
7
+ export declare const SPACE_SCALE_LEVEL0: {
8
+ readonly xs: 8;
9
+ readonly sm: 12;
10
+ readonly md: 16;
11
+ readonly lg: 20;
12
+ readonly xl: 24;
13
+ };
14
+ //# sourceMappingURL=space-scale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-scale.d.ts","sourceRoot":"","sources":["../../src/tokens/space-scale.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;;CAMrB,CAAA"}
@@ -0,0 +1,10 @@
1
+ const SPACE_SCALE_LEVEL0 = {
2
+ xs: 8,
3
+ sm: 12,
4
+ md: 16,
5
+ lg: 20,
6
+ xl: 24
7
+ };
8
+ export {
9
+ SPACE_SCALE_LEVEL0
10
+ };
package/llms.txt CHANGED
@@ -1,4 +1,4 @@
1
- # basalt-ui v2.14.0
1
+ # basalt-ui v2.16.0
2
2
  # Opinionated framework for Mantine-based React apps — theme, app shell, TanStack Charts, toolchain presets
3
3
  #
4
4
  # Entry points: use the exact import specifier below; do not guess.
@@ -13,7 +13,7 @@
13
13
  # A subpath's `Install:` line is its required peers; `OptionalPeers:` are import()-only, install on use.
14
14
 
15
15
  Package: basalt-ui
16
- Version: 2.14.0
16
+ Version: 2.16.0
17
17
 
18
18
  ## basalt-ui
19
19
  Import: import { ... } from 'basalt-ui'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "basalt-ui",
3
- "version": "2.14.0",
3
+ "version": "2.16.0",
4
4
  "description": "Opinionated framework for Mantine-based React apps — theme, app shell, TanStack Charts, toolchain presets",
5
5
  "keywords": [
6
6
  "charts",
@@ -349,7 +349,7 @@ function MessageAffordanceRow({
349
349
 
350
350
  return (
351
351
  <Group
352
- gap={8}
352
+ gap="xs"
353
353
  data-testid={`message-affordances-${message.id}`}
354
354
  style={{ opacity: visible ? 1 : 0, transition: 'opacity 120ms ease' }}
355
355
  >
@@ -149,7 +149,7 @@ export function ThreadOutcomeCard({
149
149
  const isPreviewing =
150
150
  thread.outcome === null && (thread.status === 'pending' || thread.status === 'streaming')
151
151
 
152
- // Card idiom (docs/DESIGN-SPEC.md §5): panel + shadow-card, radius 7 (VX.radiusCard), xs/sm
152
+ // Card idiom (docs/DESIGN-SPEC.md §5): panel + shadow-card, radius 10 (VX.radiusCard), card
153
153
  // inset — each outcome row reads as its own card lifted off the feed pane, not a flat
154
154
  // highlighted list row.
155
155
  const background = selected
@@ -166,7 +166,7 @@ export function ThreadOutcomeCard({
166
166
  className={cx(className)}
167
167
  style={{
168
168
  display: 'block',
169
- padding: 'var(--mantine-spacing-xs) var(--mantine-spacing-sm)',
169
+ padding: 'var(--vx-space-card-inset-y, 0.75rem) var(--vx-space-card-inset-x, 1rem)',
170
170
  borderRadius: VX.radiusCard,
171
171
  boxShadow: VX.shadowCard,
172
172
  backgroundColor: background,
@@ -84,7 +84,7 @@ const bodyClipStyle: CSSProperties = {
84
84
  minHeight: 0,
85
85
  display: 'flex',
86
86
  flexDirection: 'column',
87
- padding: '2px var(--vx-space-card-inset-x, 0.8125rem) var(--vx-space-card-inset-y, 0.6875rem)',
87
+ padding: '2px var(--vx-space-card-inset-x, 1rem) var(--vx-space-card-inset-y, 0.75rem)',
88
88
  }
89
89
 
90
90
  /** The three boxes a `ChartCard` paints. */
@@ -7,12 +7,12 @@
7
7
  */
8
8
 
9
9
  .header {
10
- padding: 4px var(--vx-space-card-inset-x, 0.8125rem) 4px;
10
+ padding: 4px var(--vx-space-card-inset-x, 1rem) 4px;
11
11
  }
12
12
 
13
13
  @container (min-width: 480px) {
14
14
  .header {
15
- padding-top: var(--vx-space-card-inset-y, 0.6875rem);
15
+ padding-top: var(--vx-space-card-inset-y, 0.75rem);
16
16
  }
17
17
  }
18
18
 
@@ -109,10 +109,10 @@ const swatchFill = (s: SwatchStyle): string =>
109
109
  s.colorNegative ? `linear-gradient(90deg, ${s.color} 50%, ${s.colorNegative} 50%)` : s.color
110
110
 
111
111
  /**
112
- * A line series' key: a stroke with its dash, compact below 480px and wide from 480px. Both are at
113
- * least 14px with two or more clear dashes: a shorter key reads as two dots. A
114
- * dashed swatch has BUTT caps: a round cap grows each dash by half the stroke width per end and
115
- * would close the gap.
112
+ * A line series' key: a stroke with its dash, compact below 480px of CHART width (a container
113
+ * query, not the viewport) and wide from 480px. Both are at least 14px with two or more clear
114
+ * dashes: a shorter key reads as two dots. A dashed swatch has BUTT caps: a round cap grows each
115
+ * dash by half the stroke width per end and would close the gap.
116
116
  */
117
117
  export const LINE_SWATCH = {
118
118
  compact: { width: 14, dash: '4 3' },
@@ -0,0 +1,132 @@
1
+ // Doctor's design-loop section: the stale-board notice and the optional-Playwright probe. A leaf:
2
+ // imports nothing from `./index`. Stat-walk only — never reads a file body, never throws.
3
+ import { readFileSync, readdirSync, statSync } from 'node:fs'
4
+ import type { Dirent } from 'node:fs'
5
+ import { createRequire } from 'node:module'
6
+ import { join, resolve } from 'node:path'
7
+
8
+ const LAST_SHOT = join('.basalt', 'shots', 'last.json')
9
+ const SKIPPED_DIRS = new Set(['node_modules', 'dist', '.git', '.basalt'])
10
+ const UI_FILE = /\.(tsx|css)$/
11
+ /** Directories plus UI files visited before the walk gives up; other files are free, so a big non-UI tree cannot pin the notice on. */
12
+ const WALK_CAP = 5000
13
+
14
+ export const BOARD_NOTICE =
15
+ 'UI changed since the last board — run basalt-ui shot <routes> and the basalt-design-reviewer (/basalt-design)'
16
+ export const PLAYWRIGHT_INSTALL = 'bun add -d playwright && bunx playwright install chromium'
17
+
18
+ /** `newest`: latest UI mtime in ms, null when none. `truncated`: the cap hit, so `newest` may be stale. */
19
+ type Walk = { newest: number | null; truncated: boolean }
20
+
21
+ function mtimeOf(path: string): number | null {
22
+ try {
23
+ return statSync(path, { throwIfNoEntry: false })?.mtimeMs ?? null
24
+ } catch {
25
+ return null
26
+ }
27
+ }
28
+
29
+ function walkUi(cwd: string, roots: string[], cap: number): Walk {
30
+ const walk: Walk = { newest: null, truncated: false }
31
+ const stack = roots.map((root) => resolve(cwd, root))
32
+ let visited = 0
33
+ for (let dir = stack.pop(); dir !== undefined; dir = stack.pop()) {
34
+ if (++visited > cap) return { ...walk, truncated: true }
35
+ let entries: Dirent[]
36
+ try {
37
+ entries = readdirSync(dir, { withFileTypes: true })
38
+ } catch (error) {
39
+ // Only a missing dir means "no UI here"; anything else leaves the scan unknown.
40
+ if ((error as NodeJS.ErrnoException).code !== 'ENOENT') walk.truncated = true
41
+ continue
42
+ }
43
+ for (const entry of entries) {
44
+ const path = join(dir, entry.name)
45
+ if (entry.isDirectory()) {
46
+ if (!SKIPPED_DIRS.has(entry.name)) stack.push(path)
47
+ continue
48
+ }
49
+ if (!UI_FILE.test(entry.name)) continue
50
+ if (++visited > cap) return { ...walk, truncated: true }
51
+ const mtime = mtimeOf(path)
52
+ if (mtime !== null && (walk.newest === null || mtime > walk.newest)) walk.newest = mtime
53
+ }
54
+ }
55
+ return walk
56
+ }
57
+
58
+ /** The last board's time (ms), or null when `last.json` is absent, corrupt or has no parseable `at`. */
59
+ function lastBoardAt(cwd: string): number | null {
60
+ try {
61
+ const last: unknown = JSON.parse(readFileSync(resolve(cwd, LAST_SHOT), 'utf8'))
62
+ if (typeof last !== 'object' || last === null) return null
63
+ const at = (last as { at?: unknown }).at
64
+ if (typeof at !== 'string') return null
65
+ const ms = Date.parse(at)
66
+ return Number.isNaN(ms) ? null : ms
67
+ } catch {
68
+ return null
69
+ }
70
+ }
71
+
72
+ /**
73
+ * The notice line when a UI file is newer than the last board, no valid board exists, or the walk
74
+ * hit its cap (unknown is reported, never "fresh"); else null. The signal is mtime-based, so a
75
+ * checkout or rebase can fire it on unchanged UI — a documented trade-off for a stat-only check.
76
+ */
77
+ export function staleBoardNotice(
78
+ cwd: string,
79
+ roots: string[],
80
+ walkCap: number = WALK_CAP,
81
+ ): string | null {
82
+ const { newest, truncated } = walkUi(cwd, roots, walkCap)
83
+ if (truncated) return BOARD_NOTICE
84
+ if (newest === null) return null
85
+ const at = lastBoardAt(cwd)
86
+ return at === null || newest > at ? BOARD_NOTICE : null
87
+ }
88
+
89
+ /** Loads `<id>/package.json` from the consumer; throws when unresolvable. Injectable for tests. */
90
+ export type PackageLoader = (id: string) => { version?: string }
91
+
92
+ /** The consumer's Playwright version (`playwright`, then `playwright-core`), or null when absent. */
93
+ export function playwrightVersion(
94
+ cwd: string,
95
+ load: PackageLoader = createRequire(resolve(cwd, 'package.json')),
96
+ ): string | null {
97
+ for (const name of ['playwright', 'playwright-core']) {
98
+ try {
99
+ return load(`${name}/package.json`).version ?? 'unknown'
100
+ } catch {
101
+ // try the next candidate
102
+ }
103
+ }
104
+ return null
105
+ }
106
+
107
+ /** Test seams for {@link designLoopLines}. */
108
+ export type DesignLoopProbes = {
109
+ notice?: (cwd: string, roots: string[]) => string | null
110
+ playwright?: (cwd: string) => string | null
111
+ }
112
+
113
+ /**
114
+ * Doctor's design-loop section: advisory info lines only. They never count as a warning, so they
115
+ * cannot change doctor's verdict or its "All checks passed" line.
116
+ */
117
+ export function designLoopLines(
118
+ cwd: string,
119
+ roots: string[],
120
+ probes: DesignLoopProbes = {},
121
+ ): string[] {
122
+ const lines: string[] = []
123
+ const notice = (probes.notice ?? staleBoardNotice)(cwd, roots)
124
+ if (notice !== null) lines.push(` → ${notice}`)
125
+ const playwright = (probes.playwright ?? playwrightVersion)(cwd)
126
+ lines.push(
127
+ playwright === null
128
+ ? ` → playwright is not installed (optional, needed by basalt-ui shot): ${PLAYWRIGHT_INSTALL}`
129
+ : ` ✓ playwright resolves (${playwright === 'unknown' ? 'version unknown' : playwright}; optional: basalt-ui shot)`,
130
+ )
131
+ return lines
132
+ }
package/src/cli/doctor.ts CHANGED
@@ -33,6 +33,8 @@ import {
33
33
  scannableFiles,
34
34
  shippedAssetPath,
35
35
  } from './index'
36
+ import { designLoopLines } from './board-freshness'
37
+ import type { DesignLoopProbes } from './board-freshness'
36
38
  import { parseJsonc } from './source-text'
37
39
  import { resolveRoots } from './config'
38
40
  import {
@@ -121,7 +123,11 @@ function aiMajorsAt(dir: string): Partial<Record<AiMajorField, number>> {
121
123
  *
122
124
  * Returns the exit code: 0 = all good, 1 = one or more hard failures or skipped checks.
123
125
  */
124
- export function doctor(invocationCwd: string = process.cwd(), flags: string[] = []): number {
126
+ export function doctor(
127
+ invocationCwd: string = process.cwd(),
128
+ flags: string[] = [],
129
+ designLoop: DesignLoopProbes = {},
130
+ ): number {
125
131
  if (conflictingProfileFlags('doctor', flags)) return 1
126
132
  const project = resolveProjectDir(invocationCwd)
127
133
  // Inside the app package of a monorepo the manifest is above: read the install root instead.
@@ -420,6 +426,9 @@ export function doctor(invocationCwd: string = process.cwd(), flags: string[] =
420
426
  for (const line of shell.warnings) warn(line)
421
427
  }
422
428
 
429
+ // ── Design loop: advisory info lines (no warning count — they never change the verdict) ─────
430
+ if (profile !== 'tokens-only') lines.push(...designLoopLines(cwd, resolveRoots(cfg), designLoop))
431
+
423
432
  // ── Report ──────────────────────────────────────────────────────────────────
424
433
  lines.push('')
425
434
  if (result.hardFailures === 0 && result.warnings === 0 && result.skipped === 0) {
package/src/cli/help.ts CHANGED
@@ -43,6 +43,12 @@ export const COMMAND_OPTIONS: Record<string, Record<string, { type: 'string' | '
43
43
  only: { type: 'string' },
44
44
  },
45
45
  'fonts:css': { out: { type: 'string' }, check: { type: 'boolean' } },
46
+ shot: {
47
+ base: { type: 'string' },
48
+ dist: { type: 'string' },
49
+ out: { type: 'string' },
50
+ states: { type: 'string' },
51
+ },
46
52
  }
47
53
 
48
54
  /** The first flag `cmd` does not accept, or null. Unknown commands return null — the dispatcher's
@@ -51,7 +57,7 @@ export function unknownFlag(cmd: string, flags: readonly string[]): string | nul
51
57
  const options = COMMAND_OPTIONS[cmd]
52
58
  if (options === undefined) return null
53
59
  try {
54
- parseArgs({ args: [...flags], options, strict: true, allowPositionals: false })
60
+ parseArgs({ args: [...flags], options, strict: true, allowPositionals: cmd === 'shot' })
55
61
  return null
56
62
  } catch (err) {
57
63
  const message = err instanceof Error ? err.message : String(err)
@@ -65,7 +71,8 @@ export const USAGE =
65
71
  'Usage: basalt-ui <--version | init [--no-merge-lint] |\n' +
66
72
  ' sync [--force] [--check] [--verbose] [--tokens-only|--framework] |\n' +
67
73
  ' check-theme [--audit-allows] |\n' +
68
- ' doctor [--tokens-only|--framework] | guard-hook | tokens:css | fonts:css | help>\n\n' +
74
+ ' doctor [--tokens-only|--framework] | guard-hook | tokens:css | fonts:css |\n' +
75
+ ' shot <route…> | help>\n\n' +
69
76
  'check-theme [--tokens-only|--framework] [--audit-allows]\n' +
70
77
  ' --audit-allows reports instead of scanning: every `theme-allow` annotation and every\n' +
71
78
  ' `basalt.exemptRules` entry, with what each one still suppresses — proved by re-running the\n' +
@@ -81,6 +88,11 @@ export const USAGE =
81
88
  'fonts:css [--out <path>] [--check]\n' +
82
89
  ' Emit the shipped --basalt-font-* stacks as plain CSS — the typeface half of the token layer,\n' +
83
90
  ' otherwise reachable only by importing styles.css.\n\n' +
91
+ 'shot <route…> (--base <url> | --dist <dir>) [--out <dir>] [--states <list>]\n' +
92
+ ' Render routes in Chromium (Playwright from YOUR project: bun add -d playwright) and write\n' +
93
+ ' board.html, metrics.json and png/* — every data-shot anchor × light/dark × desktop/mobile ×\n' +
94
+ ' rest, hover, focus, tooltip, empty, loading, error. --dist serves a built SPA dir itself.\n' +
95
+ ' Default --out .basalt/shots (emptied each run); .basalt/shots/last.json names the last out dir.\n\n' +
84
96
  'doctor [--tokens-only|--framework]\n' +
85
97
  ' Checks THIS project only: the manifest exists, the oxlint preset is wired, the pre-commit\n' +
86
98
  ' hook runs check-theme (via `lefthook dump`), and the ai package major is consistent within\n' +
package/src/cli/index.ts CHANGED
@@ -22,12 +22,13 @@ import { fileURLToPath } from 'node:url'
22
22
 
23
23
  import { DEFAULT_GUARD_CONFIG, guardWaiverHint } from '../guard'
24
24
  import type { GuardConfig, GuardKind, GuardSeverity } from '../guard'
25
- import { RULE_NAMES, SKILL_NAMES } from '../surfaces'
25
+ import { AGENT_NAMES, RULE_NAMES, SKILL_NAMES } from '../surfaces'
26
26
  import { checkTheme } from './check-theme'
27
27
  import { doctor } from './doctor'
28
28
  import { guardHook } from './guard-hook'
29
29
  import { COMMAND_OPTIONS, USAGE, unknownFlag } from './help'
30
30
  import { init } from './init'
31
+ import { shot } from './shot'
31
32
  import { sync } from './sync'
32
33
  import type { BasaltInstall } from './basalt-install'
33
34
  import {
@@ -454,6 +455,8 @@ type TemplateVars = {
454
455
  SERIES_MODULE_PATH: string
455
456
  /** The consumer's configured roots as space-separated quoted oxfmt globs, e.g. `'apps/web/src/**'`. */
456
457
  ROOTS_GLOBS: string
458
+ /** The roots a rule's `paths:` renders from: `basalt.roots` (init/sync write the inferred ones first), else {@link LEGACY_RULE_ROOTS}. */
459
+ RULE_ROOTS: string[]
457
460
  /** Path to the shipped oxlint preset from the consumer dir — RESOLVED, never assumed at the root. */
458
461
  OXLINT_PRESET_PATH: string
459
462
  /** Path to the shipped lefthook preset from the consumer dir — same resolution. */
@@ -538,6 +541,7 @@ function buildTemplateVars(pkgRoot: string, cwd: string, cfg: BasaltConfig): Tem
538
541
  ACCENT_HUE: cfg.accentHue ?? 'blue',
539
542
  SERIES_MODULE_PATH: resolveSeriesModulePath(cfg),
540
543
  ROOTS_GLOBS: resolveRoots(cfg).map(toRootGlob).join(' '),
544
+ RULE_ROOTS: cfg.roots ?? [],
541
545
  OXLINT_PRESET_PATH: shippedAssetPath(install, cwd, OXLINT_FILES.preset),
542
546
  LEFTHOOK_PRESET_PATH: shippedAssetPath(install, cwd, 'configs/lefthook.yml'),
543
547
  BASALT_BIN: basaltBinCommand(install, cwd),
@@ -545,12 +549,42 @@ function buildTemplateVars(pkgRoot: string, cwd: string, cfg: BasaltConfig): Tem
545
549
  }
546
550
  }
547
551
 
552
+ /** Rule roots when nothing is declared or inferable — what the shipped rules matched before roots. */
553
+ const LEGACY_RULE_ROOTS = ['src', 'apps/**/src', 'packages/**/src']
554
+
555
+ const FRONT_MATTER = /^---\n[\s\S]*?\n---\n/
556
+ const RULE_PATHS_BLOCK = /^paths:\n(?: {2}- .*\n)+/m
557
+
558
+ /**
559
+ * A rule's front-matter `paths:` block rendered from `roots`: one `'<root>/**'` item per root,
560
+ * normalised (no `./`, no trailing slash) and single-quoted for YAML. Only the leading `---…---`
561
+ * block is touched. Front matter without `paths:` is returned unchanged; a `paths:` that is not the
562
+ * expected list shape, or a root that would match everywhere (`''`, `/`, absolute), throws.
563
+ */
564
+ export function renderRulePaths(text: string, roots: readonly string[]): string {
565
+ const front = FRONT_MATTER.exec(text)?.[0]
566
+ if (front === undefined || !/^paths:/m.test(front)) return text
567
+ if (!RULE_PATHS_BLOCK.test(front)) throw new Error('rule `paths:` is not a list of ` - …` items')
568
+ const items = (roots.length > 0 ? roots : LEGACY_RULE_ROOTS).map((raw) => {
569
+ const root = raw.replace(/^(?:\.\/)+/, '').replace(/\/+$/, '')
570
+ if (/[\n\r]/.test(root)) throw new Error(`basalt.roots entry has a line break: ${raw}`)
571
+ if (raw.startsWith('/') || root === '') {
572
+ throw new Error(`basalt.roots entry must be a relative directory, got ${JSON.stringify(raw)}`)
573
+ }
574
+ return ` - '${(root === '.' ? '**' : `${root}/**`).replace(/'/g, "''")}'`
575
+ })
576
+ return (
577
+ front.replace(RULE_PATHS_BLOCK, () => `paths:\n${items.join('\n')}\n`) +
578
+ text.slice(front.length)
579
+ )
580
+ }
581
+
548
582
  /** Substitute every `{{KEY}}` placeholder from the variable map; unknown keys are left verbatim. */
549
583
  function fillTemplate(tpl: string, vars: TemplateVars): string {
550
584
  const fill = (text: string): string =>
551
585
  text.replace(/\{\{(\w+)\}\}/g, (m, key: string) => {
552
- const v = (vars as Record<string, string>)[key]
553
- return v ?? m
586
+ const v = (vars as Record<string, unknown>)[key]
587
+ return typeof v === 'string' ? v : m
554
588
  })
555
589
  // The marker is a YAML comment so the template stays valid YAML; GATE_STEPS itself carries
556
590
  // placeholders, so it expands before the generic pass.
@@ -792,7 +826,10 @@ export function managedFiles(placement: PlacementFlags = ROOT_PLACEMENT): Manage
792
826
  dest: `.claude/rules/basalt-${name}.md`,
793
827
  mode: 'managed' as const,
794
828
  source: `agent/rules/basalt-${name}.md`,
795
- render: (ctx: RenderContext) => readSource(ctx.pkgRoot, `agent/rules/basalt-${name}.md`),
829
+ render: (ctx: RenderContext) => {
830
+ const text = readSource(ctx.pkgRoot, `agent/rules/basalt-${name}.md`)
831
+ return text === null ? null : renderRulePaths(text, ctx.vars.RULE_ROOTS)
832
+ },
796
833
  }))
797
834
 
798
835
  // Skills take the same managed path the rules do — Claude Code cannot load skills from
@@ -805,6 +842,14 @@ export function managedFiles(placement: PlacementFlags = ROOT_PLACEMENT): Manage
805
842
  render: (ctx: RenderContext) => readSource(ctx.pkgRoot, `agent/skills/${name}/SKILL.md`),
806
843
  }))
807
844
 
845
+ // Subagents load only walking UP from the session cwd, so the consumer root is the right home.
846
+ const agents: ManagedFile[] = AGENT_NAMES.map((name) => ({
847
+ dest: `.claude/agents/${name}.md`,
848
+ mode: 'managed' as const,
849
+ source: `agent/agents/${name}.md`,
850
+ render: (ctx: RenderContext) => readSource(ctx.pkgRoot, `agent/agents/${name}.md`),
851
+ }))
852
+
808
853
  // AGENTS.md, not CLAUDE.md: Claude Code loads a repo-root AGENTS.md directly, but ANY CLAUDE.md
809
854
  // in or above the cwd suppresses it — so the block must not be the reason a CLAUDE.md exists.
810
855
  const agentsBlock: ManagedFile = {
@@ -940,7 +985,17 @@ export function managedFiles(placement: PlacementFlags = ROOT_PLACEMENT): Manage
940
985
  // lefthook/CI config, and writing over or beside it is worse than not writing at all.
941
986
  const rootTooling: ManagedFile[] = placement.isPackageRepoRoot ? [lefthook, ci] : []
942
987
 
943
- return [...rules, ...skills, agentsBlock, design, oxfmt, ...rootTooling, oxlintrc, ...scaffolds]
988
+ return [
989
+ ...rules,
990
+ ...skills,
991
+ ...agents,
992
+ agentsBlock,
993
+ design,
994
+ oxfmt,
995
+ ...rootTooling,
996
+ oxlintrc,
997
+ ...scaffolds,
998
+ ]
944
999
  }
945
1000
 
946
1001
  /**
@@ -1016,11 +1071,11 @@ export function readManifest(cwd: string): Manifest {
1016
1071
  }
1017
1072
 
1018
1073
  /**
1019
- * The two managed NAMESPACES whose membership is derived, not fixed: `RULE_NAMES` and `SKILL_NAMES`
1020
- * decide which files `managedFiles()` places under them, so a rule or skill that is RETIRED
1074
+ * The managed NAMESPACES whose membership is derived, not fixed: `RULE_NAMES`, `SKILL_NAMES` and
1075
+ * `AGENT_NAMES` decide which files `managedFiles()` places under them, so a rule, skill or agent that is RETIRED
1021
1076
  * upstream leaves a file behind in every consumer that ever synced it — and Claude keeps loading it.
1022
1077
  *
1023
- * Scoped to these two patterns on purpose, and never applied to the manifest wholesale: several
1078
+ * Scoped to these patterns on purpose, and never applied to the manifest wholesale: several
1024
1079
  * managed/seed entries are legitimately absent from `managedFiles()` for a run (`lefthook.yml` and
1025
1080
  * `check.yml` when the package is not the repo root). Deleting a dest just because this run did not place it would
1026
1081
  * remove a consumer's CI workflow on a monorepo.
@@ -1028,6 +1083,7 @@ export function readManifest(cwd: string): Manifest {
1028
1083
  const RETIREABLE_DEST_PATTERNS: readonly RegExp[] = [
1029
1084
  /^\.claude\/rules\/basalt-[a-z0-9-]+\.md$/,
1030
1085
  /^\.claude\/skills\/basalt-[a-z0-9-]+\/SKILL\.md$/,
1086
+ /^\.claude\/agents\/basalt-[a-z0-9-]+\.md$/,
1031
1087
  ]
1032
1088
 
1033
1089
  /** A tracked dest inside a derived namespace that this basalt version no longer ships. */
@@ -1222,9 +1278,21 @@ export function diffSummary(file: ManagedFile, state: UnitState): string {
1222
1278
  }
1223
1279
 
1224
1280
  /** Build the render context for a run from the package root + consumer cwd/config. */
1225
- export function renderContext(cwd: string): RenderContext {
1281
+ export function renderContext(cwd: string, ruleRoots?: readonly string[]): RenderContext {
1226
1282
  const pkgRoot = packageRoot()
1227
- return { pkgRoot, vars: buildTemplateVars(pkgRoot, cwd, readBasaltConfig(cwd)) }
1283
+ const vars = buildTemplateVars(pkgRoot, cwd, readBasaltConfig(cwd))
1284
+ return { pkgRoot, vars: ruleRoots === undefined ? vars : { ...vars, RULE_ROOTS: [...ruleRoots] } }
1285
+ }
1286
+
1287
+ /**
1288
+ * The rule roots a run renders with: what `reconcileRoots` wrote, or — on `--check`, which writes
1289
+ * nothing — what a real sync would have written, so check and write never disagree.
1290
+ */
1291
+ export function ruleRootsFor(state: RootsState): readonly string[] | undefined {
1292
+ if (state.kind === 'wrote') return state.roots
1293
+ return state.kind === 'declared' && state.declared.length === 0 && state.unscanned.length > 0
1294
+ ? state.unscanned
1295
+ : undefined
1228
1296
  }
1229
1297
 
1230
1298
  // ──────────────────────────────────────────────────────────────────────────────
@@ -1700,6 +1768,8 @@ export function run(argv: string[], cwd: string = process.cwd()): number | Promi
1700
1768
  return tokensCss(flags, cwd)
1701
1769
  case 'fonts:css':
1702
1770
  return fontsCss(flags, cwd)
1771
+ case 'shot':
1772
+ return shot(flags, cwd)
1703
1773
  default:
1704
1774
  // Named, not just implied by a usage dump: a full-screen help block with no error line reads
1705
1775
  // like the command ran and chose to print help. Reported by a consumer who passed