@behavioral-agentic-design-system/core 0.40.0 → 0.45.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 (148) hide show
  1. package/README.md +2 -0
  2. package/package.json +41 -9
  3. package/scripts/a11y-lint.cjs +66 -3
  4. package/scripts/check-spec.mjs +73 -0
  5. package/scripts/deal-directions.mjs +186 -0
  6. package/scripts/health-report.mjs +23 -3
  7. package/scripts/lib/counted-lint.mjs +100 -0
  8. package/scripts/lib/marketing-library.mjs +129 -0
  9. package/scripts/lib/on-system.mjs +249 -0
  10. package/scripts/lib/random.mjs +22 -0
  11. package/scripts/lib/spec-parse.d.mts +25 -0
  12. package/scripts/lib/spec-parse.mjs +188 -0
  13. package/scripts/lib/tells.mjs +128 -0
  14. package/scripts/lint-css-vars.mjs +175 -0
  15. package/scripts/lint-html-nesting.mjs +116 -0
  16. package/scripts/lint-live-ctas.mjs +138 -0
  17. package/scripts/lint-slop.mjs +25 -1
  18. package/scripts/on-system-score.mjs +95 -0
  19. package/scripts/slop-rules.mjs +1 -1
  20. package/scripts/source-images.mjs +180 -0
  21. package/scripts/ux-tells.mjs +78 -0
  22. package/scripts/wcag-audit.cjs +72 -5
  23. package/src/api/brand-colors.ts +3 -0
  24. package/src/api/brand-fonts.ts +3 -0
  25. package/src/api/brand-mark.ts +6 -1
  26. package/src/api/dev-write-guard.ts +53 -0
  27. package/src/api/layers/file.ts +7 -4
  28. package/src/api/onboarding-extract.ts +85 -30
  29. package/src/api/onboarding.ts +3 -0
  30. package/src/api/save-tokens.ts +3 -0
  31. package/src/app/layout.tsx +6 -0
  32. package/src/app/opengraph-image.tsx +5 -0
  33. package/src/app/preview/canvas/page.tsx +12 -0
  34. package/src/app/preview/components/page.tsx +2003 -2
  35. package/src/app/preview/studio/blank-screen.tsx +143 -0
  36. package/src/app/preview/studio/page.tsx +7 -0
  37. package/src/app/shell.tsx +168 -49
  38. package/src/components/Foundations/Motion.stories.tsx +1 -0
  39. package/src/components/canvas/canvas.tsx +458 -0
  40. package/src/components/canvas/layout.ts +72 -0
  41. package/src/components/canvas/parse-canvas.ts +32 -0
  42. package/src/components/canvas/sample.ts +90 -0
  43. package/src/components/canvas/spec-frame.tsx +43 -0
  44. package/src/components/canvas/types.ts +33 -0
  45. package/src/components/customize/design-controls.tsx +16 -1
  46. package/src/components/docs-tab.tsx +7 -7
  47. package/src/components/home-recent.tsx +73 -0
  48. package/src/components/home-tab.tsx +13 -13
  49. package/src/components/layers-tab.tsx +2 -2
  50. package/src/components/markdown-preview.tsx +60 -12
  51. package/src/components/studio/control-panel.tsx +299 -0
  52. package/src/components/studio/control-row.tsx +77 -0
  53. package/src/components/studio/preview-frame.tsx +165 -0
  54. package/src/components/studio/preview-pane.tsx +247 -0
  55. package/src/components/studio/studio.tsx +158 -0
  56. package/src/components/studio/types.ts +218 -0
  57. package/src/components/studio/use-studio-tweaks.ts +128 -0
  58. package/src/components/studio/use-studio-view-state.ts +72 -0
  59. package/src/components/ui/anchor.tsx +37 -3
  60. package/src/components/ui/attachment.tsx +211 -0
  61. package/src/components/ui/autocomplete.tsx +1 -1
  62. package/src/components/ui/chart.tsx +3 -0
  63. package/src/components/ui/code.tsx +1 -1
  64. package/src/components/ui/color-picker.tsx +21 -5
  65. package/src/components/ui/data-table.tsx +64 -3
  66. package/src/components/ui/date-field.tsx +1 -1
  67. package/src/components/ui/editable.tsx +1 -0
  68. package/src/components/ui/faceted-filter.tsx +187 -0
  69. package/src/components/ui/gauge-chart.tsx +252 -0
  70. package/src/components/ui/heatmap.tsx +256 -0
  71. package/src/components/ui/index.ts +9 -0
  72. package/src/components/ui/infinite-scroll.tsx +103 -0
  73. package/src/components/ui/inline-edit.tsx +175 -0
  74. package/src/components/ui/json-input.tsx +351 -0
  75. package/src/components/ui/month-picker.tsx +1 -1
  76. package/src/components/ui/navigation-progress.tsx +281 -0
  77. package/src/components/ui/number-input.tsx +27 -7
  78. package/src/components/ui/otp-input.tsx +208 -0
  79. package/src/components/ui/password-input.tsx +2 -1
  80. package/src/components/ui/password-strength-input.tsx +288 -0
  81. package/src/components/ui/phone-input.tsx +274 -0
  82. package/src/components/ui/pill.tsx +140 -0
  83. package/src/components/ui/popover.tsx +27 -4
  84. package/src/components/ui/scroll-progress.tsx +100 -0
  85. package/src/components/ui/search-input.tsx +1 -1
  86. package/src/components/ui/snackbar.tsx +393 -0
  87. package/src/components/ui/sortable-list.tsx +342 -0
  88. package/src/components/ui/squircle.tsx +1 -1
  89. package/src/components/ui/table.tsx +1 -1
  90. package/src/components/ui/tags-input.tsx +1 -1
  91. package/src/components/ui/timer.tsx +1 -0
  92. package/src/components/ui/tour.tsx +1 -3
  93. package/src/components/ui/transfer-list.tsx +13 -26
  94. package/src/components/ui/week-picker.tsx +1 -1
  95. package/src/components/ui/year-picker.tsx +1 -1
  96. package/src/data/component-added.json +958 -0
  97. package/src/data/docs-index.ts +36 -0
  98. package/src/hooks/use-global-mono-font.ts +1 -0
  99. package/src/hooks/use-global-primary-color.ts +1 -0
  100. package/src/hooks/use-global-sans-font.ts +1 -0
  101. package/src/hooks/use-global-serif-font.ts +1 -0
  102. package/src/hooks/use-global-type-scale.ts +17 -2
  103. package/src/hooks/use-mobile.ts +2 -0
  104. package/src/hooks/use-sync-type-scale.ts +7 -11
  105. package/src/lib/clamp.ts +2 -0
  106. package/src/lib/spec-parse.ts +4 -0
  107. package/src/lib/svg-sanitize.ts +19 -9
  108. package/src/stories/Anchor.stories.tsx +54 -0
  109. package/src/stories/Attachment.stories.tsx +189 -0
  110. package/src/stories/Autocomplete.stories.tsx +2 -0
  111. package/src/stories/Canvas.stories.tsx +45 -0
  112. package/src/stories/Chart.stories.tsx +4 -0
  113. package/src/stories/Code.stories.tsx +1 -0
  114. package/src/stories/ColorPicker.stories.tsx +41 -0
  115. package/src/stories/DataTable.stories.tsx +30 -0
  116. package/src/stories/DateField.stories.tsx +21 -0
  117. package/src/stories/Editable.stories.tsx +2 -0
  118. package/src/stories/FacetedFilter.stories.tsx +197 -0
  119. package/src/stories/GaugeChart.stories.tsx +169 -0
  120. package/src/stories/Heatmap.stories.tsx +172 -0
  121. package/src/stories/InfiniteScroll.stories.tsx +225 -0
  122. package/src/stories/InlineEdit.stories.tsx +106 -0
  123. package/src/stories/JsonInput.stories.tsx +212 -0
  124. package/src/stories/MarkdownPreview.stories.tsx +53 -0
  125. package/src/stories/MonthPicker.stories.tsx +21 -0
  126. package/src/stories/NavigationProgress.stories.tsx +159 -0
  127. package/src/stories/NumberInput.stories.tsx +26 -0
  128. package/src/stories/OtpInput.stories.tsx +110 -0
  129. package/src/stories/PasswordInput.stories.tsx +4 -0
  130. package/src/stories/PasswordStrengthInput.stories.tsx +211 -0
  131. package/src/stories/PhoneInput.stories.tsx +127 -0
  132. package/src/stories/Pill.stories.tsx +201 -0
  133. package/src/stories/Popover.stories.tsx +29 -1
  134. package/src/stories/Portal.stories.tsx +3 -1
  135. package/src/stories/ScrollProgress.stories.tsx +117 -0
  136. package/src/stories/SearchInput.stories.tsx +2 -0
  137. package/src/stories/Snackbar.stories.tsx +315 -0
  138. package/src/stories/SortableList.stories.tsx +263 -0
  139. package/src/stories/Squircle.stories.tsx +1 -0
  140. package/src/stories/Table.stories.tsx +1 -0
  141. package/src/stories/TagsInput.stories.tsx +2 -0
  142. package/src/stories/Timer.stories.tsx +26 -0
  143. package/src/stories/Tour.stories.tsx +1 -0
  144. package/src/stories/TransferList.stories.tsx +4 -0
  145. package/src/stories/WeekPicker.stories.tsx +21 -0
  146. package/src/stories/YearPicker.stories.tsx +21 -0
  147. package/src/stories/story-groups.json +33 -16
  148. package/src/tokens.json +82 -54
package/README.md CHANGED
@@ -15,6 +15,8 @@ import { Button } from "@behavioral-agentic-design-system/core/components/ui/but
15
15
  import tokens from "@behavioral-agentic-design-system/core/tokens.json";
16
16
  ```
17
17
 
18
+ Import one file per component, from its own subpath, as above. The package root doesn't export components, and the `components/ui` index loads every component, including ones that need peer dependencies you may not have installed. Peer dependencies are optional: install the ones for the components you use (for example, `@tanstack/react-table` for `data-table`).
19
+
18
20
  For client repos that fork the BADS template, this package is consumed via pnpm workspace protocol (`"@behavioral-agentic-design-system/core": "workspace:*"`). For client repos that just want the components, install from the registry.
19
21
 
20
22
  ## Publishing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behavioral-agentic-design-system/core",
3
- "version": "0.40.0",
3
+ "version": "0.45.0",
4
4
  "description": "BADS core — tokens, shadcn/ui components, and the BADS template shell (app routes, customize tab, theme hooks). Forks consume this and re-export, keeping client repos to ~30 lines of glue.",
5
5
  "license": "MIT",
6
6
  "author": "Matthew Stephens <work@matthewstephens.com> (https://github.com/matthewlarn)",
@@ -41,24 +41,32 @@
41
41
  "bads-a11y-ratchet": "scripts/a11y-ratchet.mjs",
42
42
  "bads-build-fonts": "scripts/build-fonts.cjs",
43
43
  "bads-build-tokens": "scripts/build-tokens.cjs",
44
+ "bads-check-spec": "scripts/check-spec.mjs",
44
45
  "bads-check-stories": "scripts/check-stories.mjs",
45
46
  "bads-check-sync": "scripts/check-sync.mjs",
46
47
  "bads-components": "scripts/bads-components.mjs",
48
+ "bads-deal-directions": "scripts/deal-directions.mjs",
47
49
  "bads-doctor": "scripts/bads-doctor.mjs",
48
50
  "bads-fix-stories": "scripts/fix-stories.mjs",
49
51
  "bads-generate-stories": "scripts/generate-stories.cjs",
50
52
  "bads-health-report": "scripts/health-report.mjs",
51
53
  "bads-lint-accent-text": "scripts/accent-as-text.mjs",
52
54
  "bads-lint-component-source": "scripts/lint-component-source.mjs",
55
+ "bads-lint-css-vars": "scripts/lint-css-vars.mjs",
53
56
  "bads-lint-ethics": "scripts/lint-ethics-contract.mjs",
57
+ "bads-lint-html-nesting": "scripts/lint-html-nesting.mjs",
58
+ "bads-lint-live-ctas": "scripts/lint-live-ctas.mjs",
54
59
  "bads-lint-microanimation": "./scripts/lint-microanimation.mjs",
55
60
  "bads-lint-slop": "scripts/lint-slop.mjs",
56
61
  "bads-lint-token-intent": "scripts/lint-token-intent.mjs",
57
62
  "bads-oklch-to-hex": "scripts/oklch-to-hex.cjs",
63
+ "bads-on-system": "scripts/on-system-score.mjs",
58
64
  "bads-size-audit": "scripts/size-audit.cjs",
65
+ "bads-source-images": "scripts/source-images.mjs",
59
66
  "bads-sync": "scripts/bads-sync.mjs",
60
67
  "bads-token-nearest": "scripts/token-nearest.mjs",
61
68
  "bads-ux-smoke": "./scripts/ux-smoke.mjs",
69
+ "bads-ux-tells": "scripts/ux-tells.mjs",
62
70
  "bads-wcag-audit": "scripts/wcag-audit.cjs"
63
71
  },
64
72
  "exports": {
@@ -88,6 +96,10 @@
88
96
  "./components/dev-identity-badge": "./src/components/dev-identity-badge.tsx",
89
97
  "./components/onboarding-wizard": "./src/components/onboarding-wizard.tsx",
90
98
  "./components/customize/*": "./src/components/customize/*.tsx",
99
+ "./components/canvas/*": "./src/components/canvas/*.tsx",
100
+ "./components/canvas/parse-canvas": "./src/components/canvas/parse-canvas.ts",
101
+ "./components/canvas/types": "./src/components/canvas/types.ts",
102
+ "./components/canvas/sample": "./src/components/canvas/sample.ts",
91
103
  "./components/motion/*": "./src/components/motion/*.tsx",
92
104
  "./components/Foundations/*": "./src/components/Foundations/*.tsx",
93
105
  "./app/page": "./src/app/page.tsx",
@@ -103,6 +115,7 @@
103
115
  "./app/preview/dashboard/page": "./src/app/preview/dashboard/page.tsx",
104
116
  "./app/preview/mail/page": "./src/app/preview/mail/page.tsx",
105
117
  "./app/preview/pricing/page": "./src/app/preview/pricing/page.tsx",
118
+ "./app/preview/studio/page": "./src/app/preview/studio/page.tsx",
106
119
  "./app/preview/typography/page": "./src/app/preview/typography/page.tsx",
107
120
  "./api/bads-update-check": "./src/api/bads-update-check.ts",
108
121
  "./api/layers": "./src/api/layers.ts",
@@ -121,17 +134,22 @@
121
134
  "access": "public"
122
135
  },
123
136
  "dependencies": {
124
- "@radix-ui/react-alert-dialog": "^1.1.23",
137
+ "@radix-ui/react-alert-dialog": "^1.1.24",
125
138
  "@xmldom/xmldom": "^0.9.12",
139
+ "@xyflow/react": "12.12.0",
126
140
  "cheerio": "^1.0.0",
127
141
  "class-variance-authority": "^0.7.0",
128
142
  "clsx": "^2.1.0",
143
+ "react-colorful": "^5.8.1",
129
144
  "react-markdown": "^10.1.0",
130
145
  "remark-gfm": "^4.0.1",
131
- "tailwind-merge": "^3.6.0",
146
+ "tailwind-merge": "^3.7.0",
132
147
  "uqr": "^0.1.3"
133
148
  },
134
149
  "peerDependencies": {
150
+ "@dnd-kit/core": ">=6",
151
+ "@dnd-kit/sortable": ">=7",
152
+ "@dnd-kit/utilities": ">=3",
135
153
  "@radix-ui/react-accordion": "*",
136
154
  "@radix-ui/react-aspect-ratio": "*",
137
155
  "@radix-ui/react-avatar": "*",
@@ -157,8 +175,10 @@
157
175
  "@radix-ui/react-toggle": "*",
158
176
  "@radix-ui/react-toggle-group": "*",
159
177
  "@radix-ui/react-tooltip": "*",
178
+ "@tanstack/react-table": "^8",
160
179
  "cmdk": "*",
161
180
  "lucide-react": "*",
181
+ "next": ">=15",
162
182
  "next-themes": "*",
163
183
  "react": ">=18",
164
184
  "react-day-picker": "^10.0.1",
@@ -168,6 +188,15 @@
168
188
  "sonner": "*"
169
189
  },
170
190
  "peerDependenciesMeta": {
191
+ "@dnd-kit/core": {
192
+ "optional": true
193
+ },
194
+ "@dnd-kit/sortable": {
195
+ "optional": true
196
+ },
197
+ "@dnd-kit/utilities": {
198
+ "optional": true
199
+ },
171
200
  "@radix-ui/react-accordion": {
172
201
  "optional": true
173
202
  },
@@ -189,9 +218,6 @@
189
218
  "@radix-ui/react-dialog": {
190
219
  "optional": true
191
220
  },
192
- "@radix-ui/react-navigation-menu": {
193
- "optional": true
194
- },
195
221
  "@radix-ui/react-dropdown-menu": {
196
222
  "optional": true
197
223
  },
@@ -204,6 +230,9 @@
204
230
  "@radix-ui/react-menubar": {
205
231
  "optional": true
206
232
  },
233
+ "@radix-ui/react-navigation-menu": {
234
+ "optional": true
235
+ },
207
236
  "@radix-ui/react-popover": {
208
237
  "optional": true
209
238
  },
@@ -243,19 +272,22 @@
243
272
  "@radix-ui/react-tooltip": {
244
273
  "optional": true
245
274
  },
275
+ "@tanstack/react-table": {
276
+ "optional": true
277
+ },
246
278
  "cmdk": {
247
279
  "optional": true
248
280
  },
249
281
  "lucide-react": {
250
282
  "optional": true
251
283
  },
252
- "next-themes": {
284
+ "next": {
253
285
  "optional": true
254
286
  },
255
- "react-day-picker": {
287
+ "next-themes": {
256
288
  "optional": true
257
289
  },
258
- "react-resizable-panels": {
290
+ "react-day-picker": {
259
291
  "optional": true
260
292
  },
261
293
  "recharts": {
@@ -18,11 +18,13 @@
18
18
  * 3.3.2 Labels or Instructions — <input> without associated <Label> or aria-label
19
19
  * 4.1.2 Name, Role, Value — <button> with no text and no aria-label
20
20
  * BADS-WEIGHT Font weight floor — text-xs/text-sm must be font-medium (500) or heavier
21
+ * BADS-LIVE Conditional aria-live — aria-live/role="status|alert|log" inside a JSX conditional
21
22
  *
22
23
  * Run:
23
24
  * bads-a11y-lint # report violations, exit 1 on fail
24
25
  * bads-a11y-lint --warn # report but exit 0 (advisory)
25
26
  * bads-a11y-lint path/to.tsx # scan a specific file
27
+ * bads-a11y-lint path/to/dir # scan every .tsx under a directory
26
28
  */
27
29
 
28
30
  'use strict';
@@ -44,6 +46,18 @@ const { readSourceOfTruth } = require('./source-of-truth.cjs');
44
46
  const ROOT = process.cwd();
45
47
  const advisory = process.argv.includes('--warn');
46
48
 
49
+ // allowDirArgs: this script used to take file paths only (no directory-arg
50
+ // support, unlike size-audit/a11y-ratchet), but a positional directory
51
+ // argument wasn't rejected — it fell into resolveScanFiles' "explicit path"
52
+ // branch, got handed straight to fs.readFileSync, threw EISDIR, and the
53
+ // per-file try/catch below swallowed that as if the file just couldn't be
54
+ // read. `bads-a11y-lint <directory>` printed "no AAA violations found"
55
+ // having read zero files (found 2026-09-15, from a real consumer fork run —
56
+ // the exact false-green class this scan-roots module exists to prevent, just
57
+ // via a different door: an EXPLICIT arg treated as a file, not a missing
58
+ // default root). Turning this on makes a directory arg behave the same way
59
+ // it already does for size-audit and a11y-ratchet.
60
+
47
61
  // Client-owned mode (.client-identity.json → sourceOfTruth.components ===
48
62
  // "client") downgrades the AAA and house-opinion rules below to warnings —
49
63
  // still reported, never silently dropped — while every Level A rule keeps
@@ -60,14 +74,14 @@ const CLIENT_OWNED = readSourceOfTruth(ROOT).components === 'client';
60
74
  // weight floor) and BADS-CHART (hand-rolled chart) all belong here. The four
61
75
  // Level A codes (1.1.1, 2.1.1, 2.4.4, 4.1.2) are deliberately absent — those
62
76
  // are real defects in anyone's markup and keep blocking in every mode.
63
- const WARN_IN_CLIENT_MODE = new Set(['1.4.4', '1.4.6', '2.4.13', 'BADS-WEIGHT', 'BADS-CHART']);
77
+ const WARN_IN_CLIENT_MODE = new Set(['1.4.4', '1.4.6', '2.4.13', 'BADS-WEIGHT', 'BADS-CHART', 'BADS-LIVE']);
64
78
  const CLIENT_OWNED_NOTE = ' (warned, not failed: components are client-owned)';
65
79
 
66
80
  function isDowngraded(it) {
67
81
  return CLIENT_OWNED && WARN_IN_CLIENT_MODE.has(it.sc);
68
82
  }
69
83
 
70
- const scan = resolveScanFiles({ root: ROOT, argv: process.argv.slice(2) });
84
+ const scan = resolveScanFiles({ root: ROOT, argv: process.argv.slice(2), allowDirArgs: true });
71
85
  const files = scan.files;
72
86
 
73
87
  const issues = [];
@@ -165,9 +179,24 @@ const VAGUE_LINK_TEXT = /^(?:click here|here|read more|learn more|more|click)\.?
165
179
  // comment), so the violation only ever exists in this one upstream copy.
166
180
  const SATORI_TOKEN_EXEMPT_FILE = /\bopengraph-image\.tsx$/;
167
181
 
182
+ // A file discovered via walk() (scan.mode 'default' | 'dir-args' | 'env') was
183
+ // just confirmed to exist and be a regular file by readdirSync moments ago —
184
+ // it cannot fail the read below. The only paths that can are explicit ones a
185
+ // user typed (scan.mode 'explicit'): a typo, a path that doesn't exist, a
186
+ // permissions error. Report those instead of silently dropping them — the
187
+ // same "explicit path silently produces zero findings" failure class as the
188
+ // directory-arg bug above, just triggered by a bad path instead of a good
189
+ // directory.
190
+ const unreadableExplicitPaths = [];
191
+
168
192
  for (const file of files) {
169
193
  let src;
170
- try { src = fs.readFileSync(file, 'utf8'); } catch { continue; }
194
+ try {
195
+ src = fs.readFileSync(file, 'utf8');
196
+ } catch (err) {
197
+ if (scan.mode === 'explicit') unreadableExplicitPaths.push({ file, message: err.message });
198
+ continue;
199
+ }
171
200
  // Skip generated files.
172
201
  if (src.startsWith('/* GENERATED FROM tokens.json')) continue;
173
202
  // Skip tests + e2e specs.
@@ -240,6 +269,29 @@ for (const file of files) {
240
269
  `font-normal (or lighter) on a step below ${WEIGHT_FLOOR_PX}px (${TS.smallStepsDesc}). Weight floor: font-medium (500) minimum. Add "// allow-font-normal-small" above to intentionally bypass.`);
241
270
  }
242
271
 
272
+ // BADS-LIVE — aria-live region inside a JSX conditional.
273
+ // A <div aria-live> (or role="status/alert/log") that is conditionally
274
+ // rendered gets unmounted and remounted when the condition toggles. Screen
275
+ // readers don't re-announce a newly mounted live region — the live region
276
+ // silently breaks. Fix: persistently-mounted/empty-content pattern (keep
277
+ // the element in the DOM, set children based on state).
278
+ // Escape hatch: `// allow-conditional-aria-live <one-sentence reason>`
279
+ // on the flagged line or the line above.
280
+ if (!isStory) {
281
+ const ARIA_LIVE_ATTR = /\baria-live\s*=|\brole\s*=\s*["'](?:status|alert|log)["']/;
282
+ const JSX_CONDITIONAL = /\{[^}]*&&|\?[^:]*<[A-Z]/;
283
+ if (ARIA_LIVE_ATTR.test(line)) {
284
+ const prevLine = i > 0 ? lines[i - 1] : '';
285
+ const inConditional = JSX_CONDITIONAL.test(line) || JSX_CONDITIONAL.test(prevLine);
286
+ const allowed = /\/\/\s*allow-conditional-aria-live/.test(line)
287
+ || (i > 0 && /allow-conditional-aria-live/.test(lines[i - 1]));
288
+ if (inConditional && !allowed) {
289
+ flag(file, lineNum, 'BADS-LIVE', 'conditional-aria-live',
290
+ 'aria-live region (or role="status/alert/log") inside a JSX conditional. Conditionally unmounting a live region breaks screen reader announcements on remount. Use the persistently-mounted/empty-content pattern: keep the element in the DOM and set its children based on state. Add "// allow-conditional-aria-live" with a reason to bypass.');
291
+ }
292
+ }
293
+ }
294
+
243
295
  if (FOCUS_OUTLINE_NONE.test(line) && !/ring-|outline-|focus-visible:/.test(line)) {
244
296
  flag(file, lineNum, '2.4.13', 'focus-removed',
245
297
  'outline-none without a replacement focus indicator. AAA 2.4.13 requires a visible focus marker.');
@@ -314,6 +366,17 @@ for (const file of files) {
314
366
 
315
367
  // ---- output ------------------------------------------------------------
316
368
 
369
+ if (unreadableExplicitPaths.length) {
370
+ console.error(
371
+ `a11y-lint: ${unreadableExplicitPaths.length} path argument${unreadableExplicitPaths.length === 1 ? '' : 's'} ` +
372
+ `could not be read — nothing under ${unreadableExplicitPaths.length === 1 ? 'it was' : 'them was'} scanned:\n\n` +
373
+ unreadableExplicitPaths.map((p) => ` ${p.file} — ${p.message}`).join('\n') +
374
+ `\n\nA directory argument is walked automatically now — this means the path doesn't exist, ` +
375
+ `isn't readable, or is neither a file nor a directory.`
376
+ );
377
+ process.exit(1);
378
+ }
379
+
317
380
  if (issues.length === 0) {
318
381
  if (guardEmptyScan(scan, 'a11y-lint')) { /* exited */ }
319
382
  console.log(
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * bads-check-spec: gate a prototype's spec.md.
4
+ *
5
+ * Layout it reads (default root: ./prototypes):
6
+ * prototypes/<slug>/prototype.meta.ts status: "draft" | "review" | "approved" | "shipped"
7
+ * prototypes/<slug>/spec.md
8
+ *
9
+ * For a prototype at review, approved, or shipped, any spec problem is an error
10
+ * and the exit code is 1. A draft reports problems as warnings. The status comes
11
+ * from prototype.meta.ts, the single source, so the spec carries no status of
12
+ * its own.
13
+ *
14
+ * npx bads-check-spec [root] [--warn]
15
+ */
16
+ import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from "node:fs"
17
+ import { join, resolve } from "node:path"
18
+ import { fileURLToPath } from "node:url"
19
+ import { analyzeSpec } from "./lib/spec-parse.mjs"
20
+
21
+ const GATED = new Set(["review", "approved", "shipped"])
22
+
23
+ export function readStatus(metaSource) {
24
+ const m = /status\s*:\s*["'](draft|review|approved|shipped)["']/.exec(metaSource)
25
+ return m ? m[1] : null
26
+ }
27
+
28
+ /** Check every prototype folder under `root`. Returns { errors, warnings }. */
29
+ export function checkPrototypes(root) {
30
+ const errors = []
31
+ const warnings = []
32
+ if (!existsSync(root)) return { errors, warnings, checked: 0 }
33
+ let checked = 0
34
+ for (const slug of readdirSync(root).sort()) {
35
+ const dir = join(root, slug)
36
+ if (!statSync(dir).isDirectory()) continue
37
+ const metaPath = join(dir, "prototype.meta.ts")
38
+ if (!existsSync(metaPath)) continue
39
+ checked += 1
40
+ const status = readStatus(readFileSync(metaPath, "utf8"))
41
+ const out = status && GATED.has(status) ? errors : warnings
42
+ if (!status) {
43
+ errors.push(`${slug}: prototype.meta.ts has no readable status`)
44
+ continue
45
+ }
46
+ const specPath = join(dir, "spec.md")
47
+ if (!existsSync(specPath)) {
48
+ out.push(`${slug} (${status}): no spec.md`)
49
+ continue
50
+ }
51
+ const { frontMatter, problems } = analyzeSpec(readFileSync(specPath, "utf8"))
52
+ if (frontMatter.prototype && frontMatter.prototype !== slug && !frontMatter.prototype.includes("<")) {
53
+ problems.push(`front matter \`prototype\` is "${frontMatter.prototype}" but the folder is "${slug}"`)
54
+ }
55
+ for (const p of problems) out.push(`${slug} (${status}): ${p}`)
56
+ }
57
+ return { errors, warnings, checked }
58
+ }
59
+
60
+ // A bin runs through a symlink, so compare real paths, not argv[1] as given.
61
+ const isMain = process.argv[1] && realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)
62
+
63
+ if (isMain) {
64
+ const args = process.argv.slice(2)
65
+ const warnOnly = args.includes("--warn")
66
+ const root = resolve(args.find((a) => !a.startsWith("--")) ?? "prototypes")
67
+ const { errors, warnings, checked } = checkPrototypes(root)
68
+ for (const w of warnings) console.log(`warn ${w}`)
69
+ for (const e of errors) console.log(`error ${e}`)
70
+ if (checked === 0) console.log(`bads-check-spec: no prototypes found under ${root}`)
71
+ else console.log(`bads-check-spec: ${checked} prototype(s), ${errors.length} error(s), ${warnings.length} warning(s)`)
72
+ process.exit(errors.length > 0 && !warnOnly ? 1 : 0)
73
+ }
@@ -0,0 +1,186 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * deal-directions — deal three starting directions for a Path B build, so the
4
+ * agent chooses among them instead of inventing the category default.
5
+ *
6
+ * Why a script: asked to invent a look, a model returns the safest shape for the
7
+ * category every time. design-exploration step 3.7 already says to pick a named
8
+ * macrostructure and diversify against the fork's last three; this makes the
9
+ * draw mechanical. The idea of dealing a few researched directions, rather than
10
+ * asking for one, is from Leonxlnx/taste-skill (MIT); the pool, the exclusion
11
+ * rule and the ledger memory are BADS's own (prompts/macrostructures.md,
12
+ * ledgers/prototypes.jsonl).
13
+ *
14
+ * What it deals: three macrostructures with a visual register and an interaction
15
+ * paradigm each. The three differ on every axis, so they meet the "differ on at
16
+ * least two axes" rule by construction. It skips the fork's last three
17
+ * macrostructures (ledger `macrostructure` field) and flags the two safest
18
+ * shapes, which need a written reason if chosen.
19
+ *
20
+ * Marketing, with the composition library present (disciplines/marketing/library/), deals
21
+ * full directions from it, and then a direction sheet: a hero and a section per role.
22
+ * Product surfaces, and marketing without the library, deal macrostructures.
23
+ *
24
+ * Usage (from the repo root):
25
+ * bads-deal-directions --surface product [--seed 42] [--count 3] [--json]
26
+ * bads-deal-directions --surface marketing --sector restaurant --tone warm
27
+ * bads-deal-directions --surface marketing --direction <id> --sections intro,features,proof,cta
28
+ * bads-deal-directions --surface marketing --direction <id> --alternatives features
29
+ * bads-deal-directions --list sectors|tones|roles|directions
30
+ *
31
+ * Same seed, same ledger, same deal. Without --seed the deal is random.
32
+ * It never writes anything. Record the direction you choose on the prototype's
33
+ * ledgers/prototypes.jsonl row, as `macrostructure`.
34
+ */
35
+ import fs from "node:fs";
36
+ import path from "node:path";
37
+ import { fileURLToPath } from "node:url";
38
+ import { rng, shuffle } from "./lib/random.mjs";
39
+
40
+ export const REGISTERS = ["editorial-magazine", "pro-tool-terminal", "brutalist", "consumer-playful", "motion-led", "retro", "art-direction-led"];
41
+ export const PARADIGMS = { product: ["click-driven", "keyboard-first", "voice", "gesture", "scroll-driven", "command-palette"], marketing: ["click-driven", "scroll-driven", "keyboard-first", "gesture"] };
42
+ // The two shapes a model reaches for unprompted. Allowed, but only with a written reason.
43
+ export const SAFE_DEFAULTS = ["Dashboard-of-tiles", "Split master–detail"];
44
+
45
+ export { rng, shuffle };
46
+
47
+ /** Macrostructures named in prompts/macrostructures.md, by surface. */
48
+ export function parseMacrostructures(md) {
49
+ const out = { product: [], marketing: [] };
50
+ let into = null;
51
+ let current = null;
52
+ const flush = () => { if (current) out[into].push({ name: current.name, note: current.text.replace(/\s+/g, " ").trim() }); current = null; };
53
+ for (const line of md.replace(/\r\n/g, "\n").split("\n")) {
54
+ if (/^##\s+Product/i.test(line)) { flush(); into = "product"; continue; }
55
+ if (/^##\s+Marketing/i.test(line)) { flush(); into = "marketing"; continue; }
56
+ if (/^##\s+/.test(line) || /^---\s*$/.test(line)) { flush(); into = /^##\s+/.test(line) ? null : into; continue; }
57
+ if (!into) continue;
58
+ const m = line.match(/^-\s+\*\*(.+?)\*\*\s*(?:—|-)?\s*(.*)$/);
59
+ if (m) { flush(); current = { name: m[1].trim(), text: m[2] }; } else if (current && /^\s+\S/.test(line)) current.text += " " + line.trim();
60
+ }
61
+ flush();
62
+ return out;
63
+ }
64
+
65
+ /** The newest `n` non-empty values of one ledger field, oldest first. Malformed rows are skipped. */
66
+ export function recentField(jsonl, field, n = 3) {
67
+ const rows = [];
68
+ for (const line of jsonl.split("\n")) {
69
+ if (!line.trim()) continue;
70
+ try { rows.push(JSON.parse(line)); } catch { /* skip a malformed row */ }
71
+ }
72
+ return rows.map((r) => r[field]).filter(Boolean).slice(-n);
73
+ }
74
+
75
+ /** The macrostructures used by this fork's recent builds, newest last. */
76
+ export const recentMacrostructures = (jsonl, n = 3) => recentField(jsonl, "macrostructure", n);
77
+
78
+ const norm = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
79
+
80
+ /** Deal `count` directions. Pure: pass the pool, the exclusions and a random source. */
81
+ export function deal({ pool, exclude = [], surface, count = 3, random = Math.random }) {
82
+ const skip = new Set(exclude.map(norm));
83
+ let candidates = pool.filter((m) => !skip.has(norm(m.name)));
84
+ const excluded = pool.length - candidates.length;
85
+ // If the exclusions leave too few, say so and relax rather than returning short.
86
+ let relaxed = false;
87
+ if (candidates.length < count) { candidates = pool; relaxed = true; }
88
+ const picks = shuffle(candidates, random).slice(0, count);
89
+ const registers = shuffle(REGISTERS, random);
90
+ const paradigms = shuffle(PARADIGMS[surface] || PARADIGMS.product, random);
91
+ const directions = picks.map((m, i) => ({
92
+ macrostructure: m.name,
93
+ register: registers[i % registers.length],
94
+ paradigm: paradigms[i % paradigms.length],
95
+ note: m.note,
96
+ safeDefault: SAFE_DEFAULTS.some((s) => norm(s) === norm(m.name)),
97
+ }));
98
+ return { surface, excluded, relaxed, directions };
99
+ }
100
+
101
+ export function format(result, recent) {
102
+ const lines = [];
103
+ lines.push(`Dealt ${result.directions.length} directions for a ${result.surface} surface.`);
104
+ lines.push(recent.length ? `Skipped this fork's last ${recent.length}: ${recent.join(", ")}.` : "No macrostructure recorded in ledgers/prototypes.jsonl yet, so nothing is skipped.");
105
+ if (result.relaxed) lines.push("The pool is too small to skip them all, so a recent one may appear. Say why in the sketch.");
106
+ lines.push("");
107
+ result.directions.forEach((d, i) => {
108
+ lines.push(`${i + 1}. ${d.macrostructure} · ${d.register} · ${d.paradigm}`);
109
+ if (d.note) lines.push(` ${d.note.length > 240 ? d.note.slice(0, 237) + "…" : d.note}`);
110
+ if (d.safeDefault) lines.push(" ⚠ A safe default. Choose it only with a written reason.");
111
+ });
112
+ lines.push("");
113
+ lines.push("Hold each against the subject inventory (prompts/subject-inventory.md): which can carry something only this client has? Choose one, write why in one line, then sketch within it. Redraw only for a reason you can state, such as a brand constraint, and record the redraw.");
114
+ return lines.join("\n");
115
+ }
116
+
117
+ /** Parse a comma list flag. */
118
+ const list = (v) => (v ? String(v).split(",").map((x) => x.trim()).filter(Boolean) : []);
119
+
120
+ async function main(argv) {
121
+ const arg = (name, fallback) => { const i = argv.indexOf(name); return i >= 0 ? argv[i + 1] : fallback; };
122
+ const root = process.cwd();
123
+ const json = argv.includes("--json");
124
+ const seed = arg("--seed");
125
+ const random = seed !== undefined ? rng(Number(seed)) : Math.random;
126
+ const { loadLibrary, vocab, dealDirections, dealSheet, alternatives, formatDirections, formatSheet } = await import("./lib/marketing-library.mjs");
127
+ const lib = loadLibrary(root);
128
+
129
+ const listing = arg("--list");
130
+ if (listing) {
131
+ if (!lib) { console.error("deal-directions: no marketing library here. Run it from the repo root."); return 2; }
132
+ const v = vocab(lib);
133
+ const out = listing === "directions" ? lib.directions.map((d) => `${d.id} ${d.name}`) : v[listing];
134
+ if (!out) { console.error("usage: --list sectors|tones|roles|directions"); return 2; }
135
+ console.log(out.join("\n"));
136
+ return 0;
137
+ }
138
+
139
+ const surface = arg("--surface");
140
+ if (!["marketing", "product"].includes(surface)) {
141
+ console.error("usage: deal-directions --surface marketing|product [--seed N] [--json]\n marketing: [--sector S] [--tone T] [--have product-photo,product-ui] [--software]\n [--direction ID --sections intro,features,proof,cta | --alternatives ROLE]\n list: --list sectors|tones|roles|directions");
142
+ return 2;
143
+ }
144
+
145
+ // Marketing with the library present: deal full directions and sheets. Otherwise the macrostructure deal.
146
+ if (surface === "marketing" && lib && !argv.includes("--macrostructures")) {
147
+ const have = list(arg("--have")), software = argv.includes("--software");
148
+ const direction = arg("--direction");
149
+ try {
150
+ if (direction && arg("--alternatives")) {
151
+ const alts = alternatives(lib, { direction, role: arg("--alternatives"), have, software });
152
+ console.log(json ? JSON.stringify(alts, null, 2) : alts.map((x) => `${x.id} ${x.name} (${x.shape})`).join("\n") || "none");
153
+ return 0;
154
+ }
155
+ if (direction) {
156
+ const roles = list(arg("--sections"));
157
+ if (!roles.length) { console.error("--direction needs --sections, e.g. --sections intro,features,proof,cta. Roles: " + vocab(lib).roles.join(", ")); return 2; }
158
+ const bad = roles.filter((r) => !vocab(lib).roles.includes(r));
159
+ if (bad.length) { console.error(`unknown role: ${bad.join(", ")}. Roles: ${vocab(lib).roles.join(", ")}`); return 2; }
160
+ const sheet = dealSheet(lib, { direction, roles, have, software, random });
161
+ console.log(json ? JSON.stringify(sheet, null, 2) : formatSheet(sheet));
162
+ return 0;
163
+ }
164
+ const sector = arg("--sector"), tone = arg("--tone");
165
+ const v = vocab(lib);
166
+ if (sector && !v.sectors.includes(sector)) { console.error(`unknown sector "${sector}". Sectors: ${v.sectors.join(", ")}`); return 2; }
167
+ if (tone && !v.tones.includes(tone)) { console.error(`unknown tone "${tone}". Tones: ${v.tones.join(", ")}`); return 2; }
168
+ const ledger = path.join(root, "ledgers/prototypes.jsonl");
169
+ const recent = fs.existsSync(ledger) ? recentField(fs.readFileSync(ledger, "utf8"), "libraryDirection", 3) : [];
170
+ const result = dealDirections(lib, { sector, tone, have, software, exclude: recent, count: Number(arg("--options", 3)), random });
171
+ console.log(json ? JSON.stringify(result, null, 2) : formatDirections(result, { sector, tone }));
172
+ return 0;
173
+ } catch (e) { console.error(`deal-directions: ${e.message}`); return 2; }
174
+ }
175
+
176
+ const mdPath = path.join(root, "prompts/macrostructures.md");
177
+ if (!fs.existsSync(mdPath)) { console.error(`deal-directions: ${path.relative(root, mdPath)} not found. Run it from the repo root.`); return 2; }
178
+ const pool = parseMacrostructures(fs.readFileSync(mdPath, "utf8"))[surface];
179
+ const ledger = path.join(root, "ledgers/prototypes.jsonl");
180
+ const recent = fs.existsSync(ledger) ? recentMacrostructures(fs.readFileSync(ledger, "utf8")) : [];
181
+ const result = deal({ pool, exclude: recent, surface, count: Number(arg("--count", 3)), random });
182
+ console.log(json ? JSON.stringify({ ...result, skipped: recent }, null, 2) : format(result, recent));
183
+ return 0;
184
+ }
185
+
186
+ if (process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) process.exit(await main(process.argv.slice(2)));
@@ -91,6 +91,24 @@ function uxRowText(row) {
91
91
  return String(row.finding ?? row.summary ?? "");
92
92
  }
93
93
 
94
+ /**
95
+ * Whether `name` is demonstrated in the showcase page source. The registry
96
+ * key is not always the JSX tag actually rendered: TreeView's primitive
97
+ * exports as <Tree>, not <TreeView> (same alias gap as corrections.md
98
+ * #009/#010). Caught 2026-10-05 when TreeView scored a false "not
99
+ * demonstrated" despite a full showcase section titled "Tree View". Checks
100
+ * every costModel.jsxNames alias too, and loosens the title match to ignore
101
+ * case/spacing so "Tree View" matches title="TreeView".
102
+ */
103
+ function isDemonstratedInShowcase(name, jsxNames, showcaseSource) {
104
+ const aliases = [name, ...(jsxNames ?? [])];
105
+ const looseTitle = new RegExp(`title=["']${name.replace(/\s+/g, "")}["']`, "i");
106
+ return (
107
+ aliases.some((a) => showcaseSource.includes(`<${a}`) || showcaseSource.includes(`${a}Showcase`)) ||
108
+ looseTitle.test(showcaseSource.replace(/\s+/g, ""))
109
+ );
110
+ }
111
+
94
112
  function main() {
95
113
  // Repo-root resolution is cwd-based (not file-relative) so this works both in
96
114
  // upstream BADS (scripts/ -> repo root) and after shipping as a package bin
@@ -201,8 +219,10 @@ function main() {
201
219
  }
202
220
  if (showcase === null) {
203
221
  penalties.push({ source: "showcase", points: 0, why: "showcase-presence signal unavailable (showcase page not found locally or in the package)" });
204
- } else if (!showcase.includes(`<${name}`) && !showcase.includes(`${name}Showcase`) && !showcase.includes(`title="${name}"`)) {
205
- penalties.push({ source: "showcase", points: 5, why: "not demonstrated in the components showcase" });
222
+ } else {
223
+ if (!isDemonstratedInShowcase(name, e.costModel?.jsxNames, showcase)) {
224
+ penalties.push({ source: "showcase", points: 5, why: "not demonstrated in the components showcase" });
225
+ }
206
226
  }
207
227
  }
208
228
 
@@ -286,4 +306,4 @@ function isMainModule() {
286
306
 
287
307
  if (isMainModule()) main();
288
308
 
289
- export { resolvePackageOwned, isMainModule, main, activeCorrectionsNaming, buildRowComponent, uxRowPenalizes, uxRowText };
309
+ export { resolvePackageOwned, isMainModule, main, activeCorrectionsNaming, buildRowComponent, uxRowPenalizes, uxRowText, isDemonstratedInShowcase };