@behavioral-agentic-design-system/core 0.39.1 → 0.40.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 (69) hide show
  1. package/package.json +8 -3
  2. package/scripts/a11y-lint.cjs +47 -6
  3. package/scripts/bads-components.mjs +118 -0
  4. package/scripts/build-tokens.cjs +133 -12
  5. package/scripts/check-stories.mjs +1 -1
  6. package/scripts/lint-component-source.mjs +100 -0
  7. package/scripts/lint-microanimation.mjs +267 -0
  8. package/scripts/size-audit.cjs +79 -0
  9. package/scripts/source-of-truth.cjs +58 -0
  10. package/scripts/ux-smoke.mjs +438 -0
  11. package/scripts/wcag-audit.cjs +49 -1
  12. package/src/api/layers/file.ts +1 -0
  13. package/src/app/preview/components/page.tsx +968 -0
  14. package/src/app/shell.tsx +11 -13
  15. package/src/components/customize/brand-mark-section.tsx +4 -2
  16. package/src/components/customize/design-controls.tsx +1 -1
  17. package/src/components/customize/discipline-section.tsx +3 -6
  18. package/src/components/customize/font-pickers.tsx +1 -1
  19. package/src/components/customize/letter-spacing.tsx +1 -1
  20. package/src/components/customize/save-bar.tsx +2 -2
  21. package/src/components/customize/theme-io.tsx +7 -7
  22. package/src/components/customize/type-scale.tsx +1 -1
  23. package/src/components/customize-tab.tsx +7 -4
  24. package/src/components/home-tab.tsx +3 -0
  25. package/src/components/ui/accordion.tsx +7 -0
  26. package/src/components/ui/alert.tsx +1 -0
  27. package/src/components/ui/announcement-bar.tsx +256 -0
  28. package/src/components/ui/badge.tsx +1 -0
  29. package/src/components/ui/callout.tsx +218 -0
  30. package/src/components/ui/chart.tsx +2 -14
  31. package/src/components/ui/color-picker.tsx +1 -1
  32. package/src/components/ui/format-relative-time.tsx +139 -0
  33. package/src/components/ui/grid.tsx +255 -0
  34. package/src/components/ui/icon.tsx +108 -0
  35. package/src/components/ui/index.ts +8 -0
  36. package/src/components/ui/page-header.tsx +63 -0
  37. package/src/components/ui/portal.tsx +111 -0
  38. package/src/components/ui/presence.tsx +172 -0
  39. package/src/components/ui/progress-stack.tsx +258 -0
  40. package/src/components/ui/select.tsx +89 -4
  41. package/src/components/ui/separator.tsx +1 -0
  42. package/src/components/ui/slider.tsx +83 -3
  43. package/src/components/ui/sparkline.tsx +2 -14
  44. package/src/components/ui/textarea.tsx +28 -1
  45. package/src/data/docs-index.ts +1 -0
  46. package/src/hooks/use-reduced-motion.ts +6 -0
  47. package/src/stories/Accordion.stories.tsx +59 -0
  48. package/src/stories/Alert.stories.tsx +3 -1
  49. package/src/stories/AnnouncementBar.stories.tsx +261 -0
  50. package/src/stories/Badge.stories.tsx +3 -0
  51. package/src/stories/Calendar.stories.tsx +1 -1
  52. package/src/stories/Callout.stories.tsx +219 -0
  53. package/src/stories/Chart.stories.tsx +4 -0
  54. package/src/stories/ColorPicker.stories.tsx +23 -0
  55. package/src/stories/FormatRelativeTime.stories.tsx +116 -0
  56. package/src/stories/Grid.stories.tsx +197 -0
  57. package/src/stories/Icon.stories.tsx +175 -0
  58. package/src/stories/MultiSelect.stories.tsx +1 -1
  59. package/src/stories/PageHeader.stories.tsx +102 -0
  60. package/src/stories/Portal.stories.tsx +189 -0
  61. package/src/stories/Presence.stories.tsx +228 -0
  62. package/src/stories/ProgressStack.stories.tsx +287 -0
  63. package/src/stories/Select.stories.tsx +25 -0
  64. package/src/stories/Separator.stories.tsx +3 -0
  65. package/src/stories/Slider.stories.tsx +54 -5
  66. package/src/stories/Sparkline.stories.tsx +3 -0
  67. package/src/stories/Textarea.stories.tsx +18 -0
  68. package/src/stories/story-groups.json +14 -5
  69. package/src/styles.css +133 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behavioral-agentic-design-system/core",
3
- "version": "0.39.1",
3
+ "version": "0.40.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)",
@@ -43,23 +43,28 @@
43
43
  "bads-build-tokens": "scripts/build-tokens.cjs",
44
44
  "bads-check-stories": "scripts/check-stories.mjs",
45
45
  "bads-check-sync": "scripts/check-sync.mjs",
46
+ "bads-components": "scripts/bads-components.mjs",
46
47
  "bads-doctor": "scripts/bads-doctor.mjs",
47
48
  "bads-fix-stories": "scripts/fix-stories.mjs",
48
49
  "bads-generate-stories": "scripts/generate-stories.cjs",
49
50
  "bads-health-report": "scripts/health-report.mjs",
50
51
  "bads-lint-accent-text": "scripts/accent-as-text.mjs",
52
+ "bads-lint-component-source": "scripts/lint-component-source.mjs",
51
53
  "bads-lint-ethics": "scripts/lint-ethics-contract.mjs",
54
+ "bads-lint-microanimation": "./scripts/lint-microanimation.mjs",
52
55
  "bads-lint-slop": "scripts/lint-slop.mjs",
53
56
  "bads-lint-token-intent": "scripts/lint-token-intent.mjs",
54
- "bads-token-nearest": "scripts/token-nearest.mjs",
55
57
  "bads-oklch-to-hex": "scripts/oklch-to-hex.cjs",
56
58
  "bads-size-audit": "scripts/size-audit.cjs",
57
59
  "bads-sync": "scripts/bads-sync.mjs",
60
+ "bads-token-nearest": "scripts/token-nearest.mjs",
61
+ "bads-ux-smoke": "./scripts/ux-smoke.mjs",
58
62
  "bads-wcag-audit": "scripts/wcag-audit.cjs"
59
63
  },
60
64
  "exports": {
61
65
  ".": "./src/index.ts",
62
66
  "./package.json": "./package.json",
67
+ "./scripts/*": "./scripts/*",
63
68
  "./styles.css": "./src/styles.css",
64
69
  "./fonts.css": "./src/fonts.css",
65
70
  "./fonts-cdn.css": "./src/fonts-cdn.css",
@@ -261,6 +266,6 @@
261
266
  }
262
267
  },
263
268
  "devDependencies": {
264
- "@types/react-dom": "^19.2.7"
269
+ "@types/react-dom": "^19.3.0"
265
270
  }
266
271
  }
@@ -17,7 +17,7 @@
17
17
  * 2.4.13 Focus Appearance — outline-none / focus:outline-none w/o replacement
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
- * SADS-1 Font weight floor — text-xs/text-sm must be font-medium (500) or heavier
20
+ * BADS-WEIGHT Font weight floor — text-xs/text-sm must be font-medium (500) or heavier
21
21
  *
22
22
  * Run:
23
23
  * bads-a11y-lint # report violations, exit 1 on fail
@@ -30,6 +30,7 @@
30
30
  const fs = require('fs');
31
31
  const path = require('path');
32
32
  const { resolveScanFiles, guardEmptyScan } = require('./lib/scan-roots.cjs');
33
+ const { readSourceOfTruth } = require('./source-of-truth.cjs');
33
34
 
34
35
  // Shipped as the `bads-a11y-lint` bin. process.cwd() means the same script
35
36
  // scans the right tree whether it runs in upstream BADS (CWD = repo root) or
@@ -43,6 +44,29 @@ const { resolveScanFiles, guardEmptyScan } = require('./lib/scan-roots.cjs');
43
44
  const ROOT = process.cwd();
44
45
  const advisory = process.argv.includes('--warn');
45
46
 
47
+ // Client-owned mode (.client-identity.json → sourceOfTruth.components ===
48
+ // "client") downgrades the AAA and house-opinion rules below to warnings —
49
+ // still reported, never silently dropped — while every Level A rule keeps
50
+ // blocking. See docs/superpowers/specs/2026-09-10-client-owned-components-design.md
51
+ // → "Accessibility floor: flag, do not enforce" and CLAUDE.md → Accessibility
52
+ // Floor. readSourceOfTruth() never throws and defaults to "bads" when there's
53
+ // no identity file, so upstream BADS and every fork that hasn't opted in see
54
+ // zero behaviour change.
55
+ const CLIENT_OWNED = readSourceOfTruth(ROOT).components === 'client';
56
+
57
+ // SC codes that are a matter of AAA standard or a BADS house opinion, not a
58
+ // Level A defect. 1.4.6 (hex-literal contrast), 1.4.4 (inline-px-font,
59
+ // tiny-text — BADS' 14px floor), 2.4.13 (focus-removed), BADS-WEIGHT (font
60
+ // weight floor) and BADS-CHART (hand-rolled chart) all belong here. The four
61
+ // Level A codes (1.1.1, 2.1.1, 2.4.4, 4.1.2) are deliberately absent — those
62
+ // 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']);
64
+ const CLIENT_OWNED_NOTE = ' (warned, not failed: components are client-owned)';
65
+
66
+ function isDowngraded(it) {
67
+ return CLIENT_OWNED && WARN_IN_CLIENT_MODE.has(it.sc);
68
+ }
69
+
46
70
  const scan = resolveScanFiles({ root: ROOT, argv: process.argv.slice(2) });
47
71
  const files = scan.files;
48
72
 
@@ -208,12 +232,12 @@ for (const file of files) {
208
232
  `${step} resolves to ${TS.scale[step]}px under ${TS.label}, below the ${TEXT_FLOOR_PX}px AAA floor. Use ${TS.smallestCompliant} or larger, or add "// allow-small-text" above if a vendored component forces it.`);
209
233
  }
210
234
 
211
- // SADS-1 — small text (text-xs/text-sm, <18px) must be font-medium (500) or heavier.
235
+ // BADS-WEIGHT — small text (text-xs/text-sm, <18px) must be font-medium (500) or heavier.
212
236
  if (TS.smallTextLightWeight && TS.smallTextLightWeight.test(line)
213
237
  && !/\/\/\s*allow-font-normal-small/.test(line)
214
238
  && !(i > 0 && /allow-font-normal-small/.test(lines[i - 1]))) {
215
- flag(file, lineNum, 'SADS-1', 'small-text-light-weight',
216
- `font-normal (or lighter) on a step below ${WEIGHT_FLOOR_PX}px (${TS.smallStepsDesc}). SADS weight floor: font-medium (500) minimum. Add "// allow-font-normal-small" above to intentionally bypass.`);
239
+ flag(file, lineNum, 'BADS-WEIGHT', 'small-text-light-weight',
240
+ `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.`);
217
241
  }
218
242
 
219
243
  if (FOCUS_OUTLINE_NONE.test(line) && !/ring-|outline-|focus-visible:/.test(line)) {
@@ -309,9 +333,26 @@ for (const file of Object.keys(grouped).sort()) {
309
333
  console.log(`\n${file}`);
310
334
  for (const it of grouped[file]) {
311
335
  const tag = `[SC ${it.sc} ${it.rule}]`;
312
- console.log(` L${it.line} ${tag.padEnd(28)} ${it.message}`);
336
+ const note = isDowngraded(it) ? CLIENT_OWNED_NOTE : '';
337
+ console.log(` L${it.line} ${tag.padEnd(28)} ${it.message}${note}`);
313
338
  }
314
339
  }
315
340
 
341
+ const blocking = issues.filter((it) => !isDowngraded(it));
342
+ const downgraded = issues.length - blocking.length;
343
+
316
344
  console.log(`\n${issues.length} issue${issues.length === 1 ? '' : 's'} across ${Object.keys(grouped).length} file${Object.keys(grouped).length === 1 ? '' : 's'}.`);
317
- process.exit(advisory ? 0 : 1);
345
+ if (downgraded > 0) {
346
+ // Indented deliberately: a11y-ratchet.mjs parses this script's stdout and
347
+ // treats any *unindented* line that doesn't match /^\d+ issues?/ as a new
348
+ // file-header — an unindented "N of those are warned..." line would get
349
+ // mistaken for a bogus file path. Indenting keeps it inert to that parser
350
+ // (it fails the finding regex and is simply skipped) without changing the
351
+ // line the ratchet and bads-doctor.mjs already key off.
352
+ console.log(
353
+ ` ${downgraded} of those ${downgraded === 1 ? 'is' : 'are'} warned, not failed: components are ` +
354
+ `client-owned (sourceOfTruth.components === "client"), so the AAA and BADS house-opinion floor ` +
355
+ `is informational here. ${blocking.length} blocking issue${blocking.length === 1 ? '' : 's'} remain${blocking.length === 1 ? 's' : ''}.`,
356
+ );
357
+ }
358
+ process.exit(advisory || blocking.length === 0 ? 0 : 1);
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * bads-components — flip the component ownership switch for a fork.
4
+ *
5
+ * pnpm bads:components-off --library @/components/acme [--docs URL] [--scan-roots app,components/acme]
6
+ * pnpm bads:components-on
7
+ *
8
+ * It writes `.client-identity.json`, and it patches the fork's CLAUDE.md in
9
+ * place. That patch is not a convenience: CLAUDE.md is fork-owned and never
10
+ * syncs over npm, so editing the fork's own copy is the ONLY way the agent
11
+ * layer of this feature reaches an existing fork.
12
+ */
13
+ import { readFileSync, writeFileSync, existsSync } from "node:fs";
14
+ import { join } from "node:path";
15
+
16
+ const ROOT = process.cwd();
17
+ const IDENTITY = join(ROOT, ".client-identity.json");
18
+ const CLAUDE = join(ROOT, "CLAUDE.md");
19
+ const OPEN = "<!-- bads:component-ownership -->";
20
+ const CLOSE = "<!-- /bads:component-ownership -->";
21
+
22
+ const [command, ...rest] = process.argv.slice(2);
23
+ const flag = (name) => {
24
+ const i = rest.indexOf(`--${name}`);
25
+ return i === -1 ? null : rest[i + 1] ?? null;
26
+ };
27
+
28
+ function die(message) {
29
+ console.error(`FAIL bads-components: ${message}`);
30
+ process.exit(1);
31
+ }
32
+
33
+ if (!["on", "off"].includes(command)) {
34
+ console.error("Usage: bads-components off --library <specifier> [--docs <url>] [--scan-roots a,b]");
35
+ console.error(" bads-components on");
36
+ process.exit(1);
37
+ }
38
+
39
+ if (!existsSync(IDENTITY)) {
40
+ die("no .client-identity.json here. Run `pnpm rename \"<Name>\" <slug>` first; this switch is a fork setting, not an upstream one.");
41
+ }
42
+
43
+ const identity = JSON.parse(readFileSync(IDENTITY, "utf8"));
44
+
45
+ function section(library, docs) {
46
+ return [
47
+ OPEN,
48
+ "",
49
+ "## Component ownership",
50
+ "",
51
+ `**This fork's components are client-owned.** They come from \`${library}\`${docs ? ` (docs: ${docs})` : ""}.`,
52
+ "",
53
+ "- Do not propose, build, or reach for a BADS primitive. Use the client's library.",
54
+ "- Do not add entries to `layer-5-component-registry/component-registry.json`.",
55
+ "- Do not run the component-builder skill against `@behavioral-agentic-design-system/core`.",
56
+ "- `pnpm lint:component-source` enforces this. The escape hatch is `// allow-bads-component <reason>`.",
57
+ "",
58
+ "Everything else in BADS still applies: the AAA accessibility floor, the CTA size contract, voice and tone, the ethics layers, the futures check, and the slop lint. Those are what this engagement is buying.",
59
+ "",
60
+ CLOSE,
61
+ ].join("\n");
62
+ }
63
+
64
+ function patchClaudeMd(block) {
65
+ if (!existsSync(CLAUDE)) {
66
+ console.log(" note: no CLAUDE.md here, skipping the agent-layer patch.");
67
+ return;
68
+ }
69
+ const current = readFileSync(CLAUDE, "utf8");
70
+ const start = current.indexOf(OPEN);
71
+ const end = current.indexOf(CLOSE);
72
+
73
+ if (start !== -1 && end !== -1) {
74
+ const next = current.slice(0, start) + (block ?? "").trimEnd() + current.slice(end + CLOSE.length);
75
+ writeFileSync(CLAUDE, block ? next : next.replace(/\n{3,}/g, "\n\n"));
76
+ } else if (block) {
77
+ writeFileSync(CLAUDE, `${current.trimEnd()}\n\n${block}\n`);
78
+ }
79
+ }
80
+
81
+ if (command === "off") {
82
+ const library = flag("library");
83
+ if (!library) die("`off` needs --library <specifier>. It accepts an npm package (@acme/ui) or a path alias (@/components/acme).");
84
+
85
+ const docs = flag("docs");
86
+ const scanRoots = (flag("scan-roots") || "").split(",").map((s) => s.trim()).filter(Boolean);
87
+
88
+ identity.sourceOfTruth = {
89
+ components: "client",
90
+ clientLibrary: library,
91
+ ...(docs ? { clientDocs: docs } : {}),
92
+ ...(scanRoots.length ? { scanRoots } : {}),
93
+ };
94
+ writeFileSync(IDENTITY, JSON.stringify(identity, null, 2) + "\n");
95
+ patchClaudeMd(section(library, docs));
96
+
97
+ console.log(`OK bads-components: components are now client-owned (${library}).`);
98
+ console.log(" - lint:component-source is now active");
99
+ console.log(` - it scans ${scanRoots.length ? scanRoots.join(", ") : "app/ (pass --scan-roots to widen)"}`);
100
+ console.log(" - CLAUDE.md now carries the component-ownership section");
101
+ } else {
102
+ delete identity.sourceOfTruth;
103
+ writeFileSync(IDENTITY, JSON.stringify(identity, null, 2) + "\n");
104
+ patchClaudeMd(null);
105
+ console.log("OK bads-components: BADS owns components again.");
106
+ }
107
+
108
+ // Follow-ups this script cannot perform, because they live at the fork's repo
109
+ // root and this script does not own that code.
110
+ for (const [path, pattern, note] of [
111
+ ["app/page.tsx", /DEFAULT_TABS/, "references DEFAULT_TABS directly; it needs visibleTabs() to drop the component tabs"],
112
+ [".storybook/main.ts", /core\/src\/stories/, "still globs the BADS component stories"],
113
+ ]) {
114
+ const full = join(ROOT, path);
115
+ if (existsSync(full) && pattern.test(readFileSync(full, "utf8"))) {
116
+ console.log(` follow-up: ${path} ${note}`);
117
+ }
118
+ }
@@ -362,10 +362,18 @@ const themeInline = `@theme inline {
362
362
  :root above already defines --font-sans, and Tailwind picks it up
363
363
  for the font-sans utility automatically. */
364
364
 
365
- --radius-sm: calc(var(--radius) - 4px);
366
- --radius-md: calc(var(--radius) - 2px);
367
- --radius-lg: var(--radius);
368
- --radius-xl: calc(var(--radius) + 4px);
365
+ /* Per-step override hook, same shape as the type scale above: a fork whose
366
+ brand radius ramp isn't linear-from-one-base (e.g. Furnished Finder's
367
+ 4/8/12/16, which no single --radius value produces from these calc()s)
368
+ sets --radius-sm-size etc. directly. Also closes the duplicate-value
369
+ trap this used to have — a brand file that declared --radius-lg in
370
+ :root created a second, silently-losing value under the same name as
371
+ this computed one; the override name is now distinct from the utility
372
+ name it feeds. */
373
+ --radius-sm: var(--radius-sm-size, calc(var(--radius) - 4px));
374
+ --radius-md: var(--radius-md-size, calc(var(--radius) - 2px));
375
+ --radius-lg: var(--radius-lg-size, var(--radius));
376
+ --radius-xl: var(--radius-xl-size, calc(var(--radius) + 4px));
369
377
 
370
378
  /* Map Tailwind's shadow-* utilities through to the :root --shadow-* tokens
371
379
  so the Customize tab's Shadow Opacity slider takes effect. Without this
@@ -418,12 +426,15 @@ const themeInline = `@theme inline {
418
426
  /* Marketing tier — display sizes for landing pages, hero blocks, editorial.
419
427
  Tailwind only emits utilities that get used, so a non-marketing fork pays
420
428
  nothing for these. line-height drops to 1.1 at scale to keep big type
421
- readable; tracking tightens slightly to compensate for optical loosening. */
422
- --text-4xl: calc(${text4xl} * var(--font-size-scale, 1));
423
- --text-5xl: calc(${text5xl} * var(--font-size-scale, 1));
424
- --text-6xl: calc(${text6xl} * var(--font-size-scale, 1));
425
- --text-7xl: calc(${text7xl} * var(--font-size-scale, 1));
426
- --text-8xl: calc(${text8xl} * var(--font-size-scale, 1));
429
+ readable; tracking tightens slightly to compensate for optical loosening.
430
+ Same --text-*-size override hook as the body tier above, so a fork with
431
+ its own display scale (corrections.md-class drift otherwise) can retarget
432
+ these steps too instead of hitting a cliff at text-4xl. */
433
+ --text-4xl: calc(var(--text-4xl-size, ${text4xl}) * var(--font-size-scale, 1));
434
+ --text-5xl: calc(var(--text-5xl-size, ${text5xl}) * var(--font-size-scale, 1));
435
+ --text-6xl: calc(var(--text-6xl-size, ${text6xl}) * var(--font-size-scale, 1));
436
+ --text-7xl: calc(var(--text-7xl-size, ${text7xl}) * var(--font-size-scale, 1));
437
+ --text-8xl: calc(var(--text-8xl-size, ${text8xl}) * var(--font-size-scale, 1));
427
438
  --text-4xl--line-height: 1.15;
428
439
  --text-5xl--line-height: 1.10;
429
440
  --text-6xl--line-height: 1.05;
@@ -517,8 +528,19 @@ const baseLayer = `@layer base {
517
528
  body { transition: none; }
518
529
  }
519
530
  /* WCAG AAA 1.4.8: paragraph spacing ≥ 1.5× line-height inside running
520
- text. Scope to <p> only — UI primitives stay tight. Last-child has
521
- no trailing margin so containers don't get extra padding. */
531
+ text. Last-child has no trailing margin so containers don't get extra
532
+ padding.
533
+
534
+ "UI primitives stay tight" is NOT this rule's doing — it is the flex/grid
535
+ carve-out immediately below, and you cannot tell that by reading this
536
+ selector. Measured 2026-09-11 across all eight rail destinations: exactly
537
+ 18 paragraphs in the whole app compute to 1.5em, all of them section
538
+ descriptions on the Components showcase, which is running text and is
539
+ what the rule is for. EmptyState, Stepper, Questionnaire, FileUpload and
540
+ HoverCard all compute to margin-bottom 0 because their content sits in a
541
+ flex column. Every one of those five had been reported as "loosened by
542
+ this rule" from counting <p> tags in source rather than reading the DOM.
543
+ If you are about to rescope or delete this rule, measure first. */
522
544
  p:not(:last-child) {
523
545
  margin-bottom: 1.5em;
524
546
  }
@@ -882,6 +904,105 @@ html, body {
882
904
  animation: progress-stripe var(--progress-stripe-duration, 1s) linear infinite;
883
905
  }
884
906
 
907
+ /* Presence enter/exit keyframes — applied via the data-slot + data-transition
908
+ + data-state selectors the Presence primitive sets (spec §4 pattern (b):
909
+ plain CSS in the design-system layer, no Tailwind utility generation in
910
+ the path). The component flips data-state to "closed" and waits on
911
+ element.getAnimations() before unmounting, so the -out keyframe is what
912
+ the user actually sees.
913
+
914
+ - fill-mode "both" is load-bearing: the -out keyframe must HOLD its final
915
+ frame (opacity 0) until React commits the unmount, otherwise the element
916
+ pops back to fully visible for one frame after animationend.
917
+ - Translate distances are small (0.5rem) so the motion reads as a settle,
918
+ not a slide; scale starts at .96 for the same reason.
919
+ - Reduced motion: the base layer forces animation-duration to 0.01ms; the
920
+ finished promise still resolves, so the unmount is effectively instant. */
921
+ @keyframes presence-fade-in {
922
+ from { opacity: 0; }
923
+ to { opacity: 1; }
924
+ }
925
+ @keyframes presence-fade-out {
926
+ from { opacity: 1; }
927
+ to { opacity: 0; }
928
+ }
929
+ @keyframes presence-scale-in {
930
+ from { opacity: 0; transform: scale(0.96); }
931
+ to { opacity: 1; transform: scale(1); }
932
+ }
933
+ @keyframes presence-scale-out {
934
+ from { opacity: 1; transform: scale(1); }
935
+ to { opacity: 0; transform: scale(0.96); }
936
+ }
937
+ @keyframes presence-slide-up-in {
938
+ from { opacity: 0; transform: translateY(0.5rem); }
939
+ to { opacity: 1; transform: translateY(0); }
940
+ }
941
+ @keyframes presence-slide-up-out {
942
+ from { opacity: 1; transform: translateY(0); }
943
+ to { opacity: 0; transform: translateY(0.5rem); }
944
+ }
945
+ @keyframes presence-slide-down-in {
946
+ from { opacity: 0; transform: translateY(-0.5rem); }
947
+ to { opacity: 1; transform: translateY(0); }
948
+ }
949
+ @keyframes presence-slide-down-out {
950
+ from { opacity: 1; transform: translateY(0); }
951
+ to { opacity: 0; transform: translateY(-0.5rem); }
952
+ }
953
+ @keyframes presence-slide-left-in {
954
+ from { opacity: 0; transform: translateX(0.5rem); }
955
+ to { opacity: 1; transform: translateX(0); }
956
+ }
957
+ @keyframes presence-slide-left-out {
958
+ from { opacity: 1; transform: translateX(0); }
959
+ to { opacity: 0; transform: translateX(0.5rem); }
960
+ }
961
+ @keyframes presence-slide-right-in {
962
+ from { opacity: 0; transform: translateX(-0.5rem); }
963
+ to { opacity: 1; transform: translateX(0); }
964
+ }
965
+ @keyframes presence-slide-right-out {
966
+ from { opacity: 1; transform: translateX(0); }
967
+ to { opacity: 0; transform: translateX(-0.5rem); }
968
+ }
969
+ [data-slot="presence"][data-transition="fade"][data-state="open"] {
970
+ animation: presence-fade-in var(--duration-base) var(--ease-out) both;
971
+ }
972
+ [data-slot="presence"][data-transition="fade"][data-state="closed"] {
973
+ animation: presence-fade-out var(--duration-base) var(--ease-out) both;
974
+ }
975
+ [data-slot="presence"][data-transition="scale"][data-state="open"] {
976
+ animation: presence-scale-in var(--duration-base) var(--ease-out) both;
977
+ }
978
+ [data-slot="presence"][data-transition="scale"][data-state="closed"] {
979
+ animation: presence-scale-out var(--duration-base) var(--ease-out) both;
980
+ }
981
+ [data-slot="presence"][data-transition="slide-up"][data-state="open"] {
982
+ animation: presence-slide-up-in var(--duration-base) var(--ease-out) both;
983
+ }
984
+ [data-slot="presence"][data-transition="slide-up"][data-state="closed"] {
985
+ animation: presence-slide-up-out var(--duration-base) var(--ease-out) both;
986
+ }
987
+ [data-slot="presence"][data-transition="slide-down"][data-state="open"] {
988
+ animation: presence-slide-down-in var(--duration-base) var(--ease-out) both;
989
+ }
990
+ [data-slot="presence"][data-transition="slide-down"][data-state="closed"] {
991
+ animation: presence-slide-down-out var(--duration-base) var(--ease-out) both;
992
+ }
993
+ [data-slot="presence"][data-transition="slide-left"][data-state="open"] {
994
+ animation: presence-slide-left-in var(--duration-base) var(--ease-out) both;
995
+ }
996
+ [data-slot="presence"][data-transition="slide-left"][data-state="closed"] {
997
+ animation: presence-slide-left-out var(--duration-base) var(--ease-out) both;
998
+ }
999
+ [data-slot="presence"][data-transition="slide-right"][data-state="open"] {
1000
+ animation: presence-slide-right-in var(--duration-base) var(--ease-out) both;
1001
+ }
1002
+ [data-slot="presence"][data-transition="slide-right"][data-state="closed"] {
1003
+ animation: presence-slide-right-out var(--duration-base) var(--ease-out) both;
1004
+ }
1005
+
885
1006
  /* Prose — long-form typographic rhythm for arbitrary HTML descendants
886
1007
  (MDX output, CMS articles, rendered markdown). Keyed off the .prose
887
1008
  class the Prose primitive (data-slot="prose") applies — same
@@ -18,7 +18,7 @@
18
18
  * co-located story at components/<PascalCase>.stories.tsx (matching upstream
19
19
  * pairs like components/activity-feed.tsx + components/ActivityFeed.stories.tsx),
20
20
  * and this also covers exactly one level of subdirectory, the depth at
21
- * which a fork vendors its own components (components/closedloop/*.tsx),
21
+ * which a fork vendors its own components (components/acme/*.tsx),
22
22
  * accepting a story at either the co-located subdirectory path or the
23
23
  * top-level components/<PascalCase>.stories.tsx path, since only the
24
24
  * top-level location is guaranteed to actually render in Storybook today.
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * lint-component-source — when the client owns the components, stop new code
4
+ * importing BADS primitives.
5
+ *
6
+ * This is the enforcement half of the sourceOfTruth switch. The agent rules in
7
+ * CLAUDE.md are framing and drift; this is the ratchet.
8
+ *
9
+ * It scans `sourceOfTruth.scanRoots` (default ["app"], from
10
+ * source-of-truth.cjs's DEFAULTS). It deliberately does NOT default to
11
+ * scanning `components/`: upstream ships ~127 files there that import core
12
+ * UI, and a fork is a clone of upstream, so scanning it wholesale would flag
13
+ * the whole template library on day one and the lint would get bypassed
14
+ * rather than obeyed. A fork names its own authored directories.
15
+ *
16
+ * File discovery is delegated to ./lib/scan-roots.cjs — the same
17
+ * resolveScanFiles()/guardEmptyScan() pair a11y-lint.cjs, size-audit.cjs, and
18
+ * lint-slop.mjs use. That module exists precisely because a hand-rolled walk
19
+ * over a fixed root list silently reports "clean" when none of its roots
20
+ * exist on disk (0 files read, 0 findings, exit 0) — indistinguishable from a
21
+ * real pass. guardEmptyScan() is what turns that into a loud failure instead.
22
+ * scanRoots here comes from the fork's own sourceOfTruth block, not the
23
+ * module's built-in default list, so it's passed in explicitly.
24
+ *
25
+ * Escape hatch: `// allow-bads-component <reason>` on the line above the
26
+ * import.
27
+ *
28
+ * Run:
29
+ * node lint-component-source.mjs # exit 1 on findings
30
+ * node lint-component-source.mjs --warn # advisory, exit 0
31
+ */
32
+ import { readFileSync } from "node:fs";
33
+ import { relative } from "node:path";
34
+ import { createRequire } from "node:module";
35
+
36
+ const require = createRequire(import.meta.url);
37
+ const { readSourceOfTruth } = require("./source-of-truth.cjs");
38
+ // scan-roots.cjs is CommonJS (shared with the .cjs bins); the default import
39
+ // is Node's CJS→ESM interop and always carries the full module.exports
40
+ // object, unlike named imports off an arbitrary CJS module. Mirrors how
41
+ // lint-slop.mjs consumes the same module.
42
+ import scanRootsLib from "./lib/scan-roots.cjs";
43
+ const { resolveScanFiles, guardEmptyScan } = scanRootsLib;
44
+
45
+ const ROOT = process.cwd();
46
+ const warn = process.argv.includes("--warn");
47
+
48
+ // The package name never changes on rename, so this specifier is literal —
49
+ // never a @<slug>/ placeholder.
50
+ const BADS_UI = /from\s+["']@behavioral-agentic-design-system\/core\/components\/ui\/[^"']*["']/;
51
+ const ESCAPE = /\/\/\s*allow-bads-component\s+\S/;
52
+
53
+ const sot = readSourceOfTruth(ROOT);
54
+
55
+ if (sot.components !== "client") {
56
+ console.log("OK lint-component-source: BADS owns components here, nothing to check.");
57
+ process.exit(0);
58
+ }
59
+
60
+ // scanRoots is the fork's own sourceOfTruth.scanRoots (default ["app"]), not
61
+ // scan-roots.cjs's built-in DEFAULT_SCAN_ROOTS list — the switch owns this
62
+ // scope, the shared module only owns the walk + false-green guard.
63
+ const scan = resolveScanFiles({
64
+ root: ROOT,
65
+ argv: process.argv.slice(2),
66
+ scanRoots: sot.scanRoots,
67
+ });
68
+
69
+ const findings = [];
70
+ for (const file of scan.files) {
71
+ const lines = readFileSync(file, "utf8").split("\n");
72
+ lines.forEach((line, i) => {
73
+ if (!BADS_UI.test(line)) return;
74
+ if (i > 0 && ESCAPE.test(lines[i - 1])) return;
75
+ findings.push({ file: relative(ROOT, file), line: i + 1, text: line.trim() });
76
+ });
77
+ }
78
+
79
+ if (findings.length === 0) {
80
+ // Must run before any success message prints: this is the guard against
81
+ // the false-green the 2026-09-14 plan revision exists to prevent. It exits
82
+ // the process (non-zero, listing what it looked for) when none of
83
+ // sot.scanRoots exist on disk, rather than letting the line below claim a
84
+ // clean scan over zero files read.
85
+ if (guardEmptyScan(scan, "lint-component-source")) {
86
+ /* exited */
87
+ }
88
+ console.log(`OK lint-component-source: no BADS component imports under ${sot.scanRoots.join(", ")}.`);
89
+ process.exit(0);
90
+ }
91
+
92
+ const label = warn ? "WARN" : "FAIL";
93
+ console.error(`${label} lint-component-source: ${findings.length} BADS component import(s) in a client-owned fork.`);
94
+ console.error(` This fork's components come from ${sot.clientLibrary}.`);
95
+ for (const f of findings) {
96
+ console.error(` ${f.file}:${f.line}`);
97
+ console.error(` ${f.text}`);
98
+ }
99
+ console.error(` escape: add "// allow-bads-component <reason>" on the line above.`);
100
+ process.exit(warn ? 0 : 1);