@behavioral-agentic-design-system/core 0.36.0 → 0.38.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.
@@ -0,0 +1,333 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * token-nearest — resolve a raw value to the nearest token in the live system.
4
+ *
5
+ * Why this exists: BADS's token lints answer "is this off-token?" and stop
6
+ * there. `lint-tokens` reports a hardcoded `#3b82f6` as a violation without
7
+ * saying what to use instead, which puts the burden of the fix on the reader
8
+ * every single time. The reader then guesses, and a guess is how a second
9
+ * near-duplicate blue enters a palette.
10
+ *
11
+ * The pattern is lifted from ClosedLoop's design-inventory pipeline
12
+ * (`extract-visual-spec.ts`, Apache 2.0, used with permission — audited
13
+ * 2026-09-03, see docs/roadmap-closedloop-import.md item 2). Their framing is
14
+ * the useful part: drift is inventory signal, not a rule violation. A value
15
+ * that resolves to a token IS that token. A value that resolves to nothing is
16
+ * a question — "did you mean this one?" — with the nearest legal answer
17
+ * attached.
18
+ *
19
+ * One deviation from the source. They measure colour distance in RGB. BADS
20
+ * authors its palette in oklch, and oklch-to-hex.cjs already carries the
21
+ * transform, so distance here is Euclidean in OKLab. Perceptual distance is
22
+ * what "nearest" should mean, and RGB distance ranks a dark navy and a dark
23
+ * maroon as neighbours when the eye does not.
24
+ *
25
+ * Scope: colours, and the three dimension scales (fontSize, spacing,
26
+ * borderRadius). A dimension answer doubles as the AAA-floor helper — the
27
+ * nearest LEGAL step is a better error message than "11px is below the floor".
28
+ *
29
+ * Run:
30
+ * node packages/core/scripts/token-nearest.mjs "#3b82f6"
31
+ * node packages/core/scripts/token-nearest.mjs "11px" --kind fontSize
32
+ * node packages/core/scripts/token-nearest.mjs "oklch(0.55 0.15 150)" --mode dark
33
+ * npx bads-token-nearest "#3b82f6" --json
34
+ *
35
+ * Exit codes: 0 a match was reported, 1 usage or input error.
36
+ */
37
+
38
+ import fs from "node:fs";
39
+ import path from "node:path";
40
+ import { createRequire } from "node:module";
41
+ import { fileURLToPath } from "node:url";
42
+
43
+ const require = createRequire(import.meta.url);
44
+ const { colorToHex } = require("./oklch-to-hex.cjs");
45
+
46
+ // ---------------------------------------------------------------------------
47
+ // Token loading
48
+ // ---------------------------------------------------------------------------
49
+
50
+ /** Candidate tokens.json locations, consumer repo first, then this package. */
51
+ export function tokenPaths(root = process.cwd()) {
52
+ const here = path.dirname(fileURLToPath(import.meta.url));
53
+ return [
54
+ path.join(root, "packages/core/src/tokens.json"),
55
+ path.join(root, "tokens.json"),
56
+ path.join(root, "src/tokens.json"),
57
+ path.join(here, "../src/tokens.json"),
58
+ ];
59
+ }
60
+
61
+ export function loadTokens(root = process.cwd()) {
62
+ for (const p of tokenPaths(root)) {
63
+ if (fs.existsSync(p)) return { tokens: JSON.parse(fs.readFileSync(p, "utf8")), source: p };
64
+ }
65
+ return { tokens: null, source: null };
66
+ }
67
+
68
+ /**
69
+ * Flatten a DTCG token tree to `{ "dotted.path": "$value" }`.
70
+ * Groups are plain objects; a leaf is any object carrying `$value`.
71
+ */
72
+ export function flattenTokens(node, prefix = "") {
73
+ const out = {};
74
+ if (!node || typeof node !== "object") return out;
75
+ for (const [key, value] of Object.entries(node)) {
76
+ if (key.startsWith("$")) continue;
77
+ if (!value || typeof value !== "object") continue;
78
+ if ("$value" in value) out[prefix + key] = value.$value;
79
+ else Object.assign(out, flattenTokens(value, `${prefix}${key}.`));
80
+ }
81
+ return out;
82
+ }
83
+
84
+ // ---------------------------------------------------------------------------
85
+ // Colour
86
+ // ---------------------------------------------------------------------------
87
+
88
+ /** sRGB hex to OKLab. The forward direction of oklch-to-hex's transform. */
89
+ export function hexToOklab(hex) {
90
+ const body = hex.replace("#", "");
91
+ const full = body.length === 3 ? body.split("").map((c) => c + c).join("") : body.slice(0, 6);
92
+ const toLinear = (v) => {
93
+ const s = parseInt(v, 16) / 255;
94
+ return s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
95
+ };
96
+ const r = toLinear(full.slice(0, 2));
97
+ const g = toLinear(full.slice(2, 4));
98
+ const b = toLinear(full.slice(4, 6));
99
+
100
+ const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
101
+ const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
102
+ const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
103
+
104
+ return [
105
+ 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
106
+ 1.9779984951 * l - 0.2428592205 * m + 0.4505937099 * s,
107
+ 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
108
+ ];
109
+ }
110
+
111
+ /** Perceptual distance between two hex colours. 0 is identical. */
112
+ export function oklabDistance(hexA, hexB) {
113
+ const a = hexToOklab(hexA);
114
+ const b = hexToOklab(hexB);
115
+ return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
116
+ }
117
+
118
+ /**
119
+ * Resolve one token value to hex, chasing `var(--x)` references through the
120
+ * same table. Returns null for anything not resolvable to a flat colour —
121
+ * `color-mix()` and unresolvable references included. A null is honest: a
122
+ * half-resolved colour would poison every distance computed against it.
123
+ */
124
+ export function resolveColor(value, table, depth = 0) {
125
+ if (typeof value !== "string" || depth > 8) return null;
126
+ const v = value.trim();
127
+
128
+ const ref = v.match(/^var\(\s*--([\w-]+)\s*\)$/);
129
+ if (ref) {
130
+ const target = table[ref[1]];
131
+ return target === undefined ? null : resolveColor(target, table, depth + 1);
132
+ }
133
+ if (/^color-mix\(/i.test(v)) return null;
134
+
135
+ try {
136
+ return colorToHex(v);
137
+ } catch {
138
+ return null;
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Build `{ tokenName: hex }` for one theme mode, plus the raw palette.
144
+ * Theme tokens win a name collision: they are what a consumer actually types.
145
+ */
146
+ export function buildColorTable(tokens, { mode = "light", includePrimitives = true } = {}) {
147
+ const theme = tokens?.theme?.[mode] ?? {};
148
+ const raw = flattenTokens(theme);
149
+
150
+ const table = {};
151
+ for (const [name, value] of Object.entries(raw)) {
152
+ const hex = resolveColor(value, raw);
153
+ if (hex) table[name] = hex;
154
+ }
155
+
156
+ if (includePrimitives) {
157
+ for (const [name, value] of Object.entries(flattenTokens(tokens?.color ?? {}))) {
158
+ if (name in table) continue;
159
+ const hex = resolveColor(value, raw);
160
+ if (hex) table[name] = hex;
161
+ }
162
+ }
163
+ return table;
164
+ }
165
+
166
+ /**
167
+ * Nearest colour tokens to a raw value, closest first.
168
+ *
169
+ * `exact` means the value IS this token, so the correct report is "you wrote
170
+ * the literal for a token you already have", which is a different and much
171
+ * more actionable finding than "this is near primary".
172
+ */
173
+ export function nearestColorToken(value, table, { limit = 3 } = {}) {
174
+ const hex = resolveColor(value, {});
175
+ if (!hex) return null;
176
+ const ranked = Object.entries(table)
177
+ .map(([token, tokenHex]) => ({
178
+ token,
179
+ hex: tokenHex,
180
+ distance: Number(oklabDistance(hex, tokenHex).toFixed(4)),
181
+ }))
182
+ .sort((a, b) => a.distance - b.distance);
183
+ if (!ranked.length) return null;
184
+ return {
185
+ input: hex,
186
+ exact: ranked[0].distance === 0,
187
+ matches: ranked.slice(0, limit),
188
+ };
189
+ }
190
+
191
+ // ---------------------------------------------------------------------------
192
+ // Dimension scales
193
+ // ---------------------------------------------------------------------------
194
+
195
+ export const SCALE_KINDS = ["fontSize", "spacing", "borderRadius"];
196
+
197
+ const toPx = (value) => {
198
+ if (typeof value !== "string") return null;
199
+ const m = value.trim().match(/^(-?[\d.]+)(px|rem)?$/);
200
+ if (!m) return null;
201
+ const n = Number(m[1]);
202
+ if (!Number.isFinite(n)) return null;
203
+ return m[2] === "rem" ? n * 16 : n;
204
+ };
205
+
206
+ /** `[{ name, px }]` for one scale, ascending. */
207
+ export function buildScale(tokens, kind) {
208
+ const flat = flattenTokens(tokens?.[kind] ?? {});
209
+ return Object.entries(flat)
210
+ .map(([name, value]) => ({ name, px: toPx(value) }))
211
+ .filter((s) => s.px !== null)
212
+ .sort((a, b) => a.px - b.px);
213
+ }
214
+
215
+ /**
216
+ * Nearest step on a scale.
217
+ *
218
+ * `floor` is the smallest step at or above the value, and it is the field the
219
+ * AAA type rule wants: when 11px is below the floor, "the nearest legal step
220
+ * is xs (14px)" is a fix, while "11px is below the floor" is only a verdict.
221
+ */
222
+ export function nearestScaleStep(value, scale) {
223
+ const px = toPx(value);
224
+ if (px === null || !scale.length) return null;
225
+ const ranked = [...scale].sort((a, b) => Math.abs(a.px - px) - Math.abs(b.px - px));
226
+ const floor = scale.find((s) => s.px >= px) ?? null;
227
+ return {
228
+ input: px,
229
+ exact: ranked[0].px === px,
230
+ nearest: ranked[0],
231
+ floor,
232
+ };
233
+ }
234
+
235
+ // ---------------------------------------------------------------------------
236
+ // One-call helper for lint integrations
237
+ // ---------------------------------------------------------------------------
238
+
239
+ /**
240
+ * A short, human-readable "did you mean" suffix for a lint message, or "" when
241
+ * nothing useful can be said. Returning "" rather than a hedge keeps a lint
242
+ * line from growing a tail that carries no information.
243
+ */
244
+ export function suggestion(value, { tokens, mode = "light", kind = "color" } = {}) {
245
+ if (!tokens) return "";
246
+ if (kind === "color") {
247
+ const table = buildColorTable(tokens, { mode });
248
+ const hit = nearestColorToken(value, table, { limit: 1 });
249
+ if (!hit) return "";
250
+ const best = hit.matches[0];
251
+ if (hit.exact) return ` This is exactly --${best.token}; use the token.`;
252
+ if (best.distance > 0.12) return "";
253
+ return ` Nearest token: --${best.token} (${best.hex}, ΔOKLab ${best.distance}).`;
254
+ }
255
+ const hit = nearestScaleStep(value, buildScale(tokens, kind));
256
+ if (!hit) return "";
257
+ if (hit.exact) return ` This is exactly ${kind}.${hit.nearest.name}; use the token.`;
258
+ const floor = hit.floor ? `, nearest step at or above it is ${hit.floor.name} (${hit.floor.px}px)` : "";
259
+ return ` Nearest ${kind} step: ${hit.nearest.name} (${hit.nearest.px}px)${floor}.`;
260
+ }
261
+
262
+ // ---------------------------------------------------------------------------
263
+ // CLI
264
+ // ---------------------------------------------------------------------------
265
+
266
+ function main(argv) {
267
+ const flags = argv.filter((a) => a.startsWith("--"));
268
+ const positional = argv.filter((a) => !a.startsWith("--"));
269
+ const flagValue = (name, fallback) => {
270
+ const i = argv.indexOf(`--${name}`);
271
+ return i >= 0 && argv[i + 1] && !argv[i + 1].startsWith("--") ? argv[i + 1] : fallback;
272
+ };
273
+
274
+ const value = positional.find((a) => a !== flagValue("kind") && a !== flagValue("mode"));
275
+ if (!value) {
276
+ console.error('usage: bads-token-nearest "<value>" [--kind color|fontSize|spacing|borderRadius] [--mode light|dark] [--json]');
277
+ return 1;
278
+ }
279
+
280
+ const kind = flagValue("kind", "color");
281
+ const mode = flagValue("mode", "light");
282
+ const asJson = flags.includes("--json");
283
+
284
+ const { tokens, source } = loadTokens();
285
+ if (!tokens) {
286
+ console.error("token-nearest: no tokens.json found. Run from a BADS repo root or a fork of one.");
287
+ return 1;
288
+ }
289
+
290
+ let result;
291
+ if (kind === "color") {
292
+ const table = buildColorTable(tokens, { mode });
293
+ result = nearestColorToken(value, table);
294
+ if (!result) {
295
+ console.error(`token-nearest: could not resolve ${JSON.stringify(value)} to a colour.`);
296
+ return 1;
297
+ }
298
+ } else if (SCALE_KINDS.includes(kind)) {
299
+ result = nearestScaleStep(value, buildScale(tokens, kind));
300
+ if (!result) {
301
+ console.error(`token-nearest: could not read ${JSON.stringify(value)} as a ${kind} value.`);
302
+ return 1;
303
+ }
304
+ } else {
305
+ console.error(`token-nearest: unknown --kind ${kind}. One of: color, ${SCALE_KINDS.join(", ")}.`);
306
+ return 1;
307
+ }
308
+
309
+ if (asJson) {
310
+ console.log(JSON.stringify({ value, kind, mode, source, ...result }, null, 2));
311
+ return 0;
312
+ }
313
+
314
+ console.log(`token-nearest: ${value} (${kind}${kind === "color" ? `, ${mode} mode` : ""})`);
315
+ if (kind === "color") {
316
+ console.log(` resolved to ${result.input}`);
317
+ for (const m of result.matches) {
318
+ const tag = m.distance === 0 ? "EXACT" : `Δ ${m.distance}`;
319
+ console.log(` ${tag.padEnd(10)} --${m.token} ${m.hex}`);
320
+ }
321
+ if (!result.exact) console.log("\n Off-token. Use the nearest token above, or add a new one deliberately.");
322
+ } else {
323
+ console.log(` ${result.input}px`);
324
+ console.log(` nearest ${result.nearest.name} (${result.nearest.px}px)`);
325
+ if (result.floor) console.log(` floor ${result.floor.name} (${result.floor.px}px) — smallest step at or above the value`);
326
+ if (result.exact) console.log("\n Exact match. Use the token rather than the literal.");
327
+ }
328
+ return 0;
329
+ }
330
+
331
+ if (process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) {
332
+ process.exit(main(process.argv.slice(2)));
333
+ }
@@ -43,6 +43,44 @@
43
43
  const fs = require('fs');
44
44
  const path = require('path');
45
45
 
46
+ /**
47
+ * Documented exceptions (tokens.json -> wcagExceptions.pairs) whose fgKey/bgKey
48
+ * no longer matches an "exception"-status row in `results`.
49
+ *
50
+ * An exception outlives the problem it documented when someone fixes the pair
51
+ * it was written for: the entry stays in tokens.json, silently matching
52
+ * nothing, and would quietly hide a real regression if that same pair failed
53
+ * again later. Detecting that is the same failure class this audit already
54
+ * exists to prevent, arriving from the other direction.
55
+ *
56
+ * Pure so the stale-exceptions logic can be unit tested against a fixture,
57
+ * without running the rest of this script (which reads the real tokens.json,
58
+ * prints to stdout, and can call process.exit) just to reach it.
59
+ */
60
+ function findStaleExceptions(pairs, results) {
61
+ const list = pairs || [];
62
+ const rows = results || [];
63
+ return list.filter(
64
+ (entry) => !rows.some(
65
+ (r) => r.status === 'exception' && r.fgKey === entry.fgKey && r.bgKey === entry.bgKey,
66
+ ),
67
+ );
68
+ }
69
+
70
+ module.exports = { findStaleExceptions };
71
+
72
+ // Everything below this line is the script's CLI behaviour: it reads the real
73
+ // tokens.json, prints a report, and can call process.exit. Guard it behind
74
+ // the main-module check so `require("./wcag-audit.cjs")` from a test can pull
75
+ // in findStaleExceptions above without any of that running. This is a plain
76
+ // top-level return, legal in a CommonJS module because Node wraps the whole
77
+ // file in a function. require.main resolves correctly through a symlink by
78
+ // default (unlike the import.meta.url / process.argv[1] mismatch fixed for
79
+ // the .mjs scripts), so this holds for the shipped bads-wcag-audit bin too.
80
+ if (require.main !== module) {
81
+ return;
82
+ }
83
+
46
84
  // Shipped as the `bads-wcag-audit` bin. The token file is consumer-owned, but
47
85
  // "consumer" means three different repo layouts and only one of them has a
48
86
  // packages/ directory:
@@ -428,21 +466,28 @@ for (const brand of brandColorsRaw.colors ?? []) {
428
466
  brandResults.push(...simulateBrand(brand, 'dark', tokens.theme.dark));
429
467
  }
430
468
 
469
+ // Documented exceptions live in tokens.json next to the tokens they concern, each with a
470
+ // required reason. A pair listed there is reported as an exception rather than failing the
471
+ // build: the point is that it stays visible, not that it disappears. Computed ahead of the
472
+ // json/human-readable split so both report the same promoted statuses and the same stale list.
473
+ const exceptions = (tokens.wcagExceptions && tokens.wcagExceptions.pairs) || [];
474
+ const exceptionFor = (r) => exceptions.find((e) => e.fgKey === r.fgKey && e.bgKey === r.bgKey && e.reason);
475
+ for (const r of all) {
476
+ if (r.status === 'fail' && exceptionFor(r)) r.status = 'exception';
477
+ }
478
+ // An entry whose fgKey/bgKey matches no 'exception'-status row is stale: either its pair now
479
+ // passes (the common case -- someone fixed the token and the promotion above never fired), or
480
+ // it never matched a real row at all. Reported, never build-failing: see findStaleExceptions.
481
+ const staleExceptions = findStaleExceptions(exceptions, all);
482
+
431
483
  if (json) {
432
484
  console.log(JSON.stringify({
433
485
  floor: { normal: NORMAL_FLOOR, large: LARGE_FLOOR },
434
486
  results: all,
435
487
  runtimeMutated: brandResults,
488
+ staleExceptions,
436
489
  }, null, 2));
437
490
  } else {
438
- // Documented exceptions live in tokens.json next to the tokens they concern, each with a
439
- // required reason. A pair listed there is reported as an exception rather than failing the
440
- // build — the point is that it stays visible, not that it disappears.
441
- const exceptions = (tokens.wcagExceptions && tokens.wcagExceptions.pairs) || [];
442
- const exceptionFor = (r) => exceptions.find((e) => e.fgKey === r.fgKey && e.bgKey === r.bgKey && e.reason);
443
- for (const r of all) {
444
- if (r.status === 'fail' && exceptionFor(r)) r.status = 'exception';
445
- }
446
491
  const excepted = all.filter((r) => r.status === 'exception');
447
492
  const failed = all.filter((r) => r.status === 'fail');
448
493
  const warned = all.filter((r) => r.status === 'warn');
@@ -490,6 +535,12 @@ if (json) {
490
535
  console.log(` ! ${r.label} — ${exceptionFor(r).reason}`);
491
536
  }
492
537
  }
538
+ if (staleExceptions.length) {
539
+ console.log('\nStale exceptions (these pairs now pass; remove them from tokens.json):');
540
+ for (const e of staleExceptions) {
541
+ console.log(` ! ${e.fgKey} on ${e.bgKey}`);
542
+ }
543
+ }
493
544
  if (warned.length || brandWarnings) {
494
545
  console.log(
495
546
  `\nWarnings are brand-derived pairs below AAA. The brand picker surfaces` +
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
 
3
+ // allow-slop:BADS-SLOP-13 Component gallery: the centered blocks are Stepper titles under their step icons, which is the correct centered pattern for that primitive, not a centered page.
3
4
  import { sectionId, useSectionVisible } from "@behavioral-agentic-design-system/core/app/preview/showcase-filter";
4
5
  import * as React from "react";
5
6
  import {
@@ -31,6 +31,12 @@ export interface ComboboxProps {
31
31
  emptyText?: string
32
32
  disabled?: boolean
33
33
  className?: string
34
+ /**
35
+ * Trigger button height. Maps directly to the Button size prop.
36
+ * Use "xl" (h-11, 44px) for flow-changing CTAs to meet WCAG SC 2.5.5 Enhanced.
37
+ * Default "default" (h-9) is for dense form chrome.
38
+ */
39
+ size?: "sm" | "default" | "lg" | "xl"
34
40
  /**
35
41
  * When true, shows a "Create [typed text]" option at the bottom of the dropdown
36
42
  * if the typed text does not exactly match any existing option label.
@@ -53,6 +59,7 @@ function Combobox({
53
59
  emptyText = "No results found.",
54
60
  disabled = false,
55
61
  className,
62
+ size = "default",
56
63
  creatable = false,
57
64
  onCreateOption,
58
65
  }: ComboboxProps) {
@@ -81,6 +88,7 @@ function Combobox({
81
88
  <Button
82
89
  data-slot="combobox"
83
90
  variant="outline"
91
+ size={size}
84
92
  aria-expanded={open}
85
93
  aria-haspopup="listbox"
86
94
  disabled={disabled}
@@ -30,8 +30,21 @@ export interface MultiSelectProps {
30
30
  disabled?: boolean
31
31
  maxCount?: number
32
32
  className?: string
33
+ /**
34
+ * Trigger container minimum height. "xl" (min-h-11, 44px) meets WCAG SC 2.5.5
35
+ * Enhanced — use it for flow-changing filter controls and form CTAs.
36
+ * "default" (min-h-9, 36px) is correct for dense form chrome.
37
+ */
38
+ size?: "sm" | "default" | "lg" | "xl"
33
39
  }
34
40
 
41
+ const SIZE_STYLES = {
42
+ sm: "min-h-7 py-0.5 px-2.5",
43
+ default: "min-h-9 py-1.5 px-3",
44
+ lg: "min-h-10 py-2 px-3",
45
+ xl: "min-h-11 py-2.5 px-3",
46
+ } as const
47
+
35
48
  function MultiSelect({
36
49
  options,
37
50
  value = [],
@@ -42,6 +55,7 @@ function MultiSelect({
42
55
  disabled = false,
43
56
  maxCount,
44
57
  className,
58
+ size = "default",
45
59
  }: MultiSelectProps) {
46
60
  const [open, setOpen] = React.useState(false)
47
61
 
@@ -87,7 +101,8 @@ function MultiSelect({
87
101
  data-slot="multi-select"
88
102
  aria-disabled={disabled || undefined}
89
103
  className={cn(
90
- "relative flex w-full min-h-9 h-auto items-center justify-between gap-1 rounded-md border border-input bg-background px-3 py-1.5 text-sm font-medium shadow-xs",
104
+ "relative flex w-full h-auto items-center justify-between gap-1 rounded-md border border-input bg-background text-sm font-medium shadow-xs",
105
+ SIZE_STYLES[size],
91
106
  "cursor-default select-none",
92
107
  "hover:bg-accent/50",
93
108
  "has-[:focus-visible]:outline-none has-[:focus-visible]:ring-[3px] has-[:focus-visible]:ring-ring/50 has-[:focus-visible]:border-ring",
@@ -75,6 +75,7 @@ export const DOCS_INDEX: DocGroup[] = [
75
75
  { title: "Storybook rule", path: "STORYBOOK_RULE.md" },
76
76
  { title: "CTA size contract", path: "prompts/cta-size-contract.md" },
77
77
  { title: "Motion spec", path: "prompts/motion-spec.md" },
78
+ { title: "Elevation and shadow", path: "docs/elevation.md", summary: "The shadow MODEL behind the shadow scale: raised vs inset are opposite treatments, the contact/cast alpha crossover as elevation rises, why inset values can't be copied between light and dark surfaces, and the box-shadow trap where a second declaration silently discards the first. Reconciles the ≥40px-blur anti-slop rule with legitimate modal elevation." },
78
79
  { title: "Motion choreography", path: "prompts/motion-choreography.md", summary: "Page-scale motion for expressive/motion-led surfaces (hero, landing) — timing budget, stagger-by-hierarchy, coverage sweep, signature-techniques menu, linear() springs. Opt-in, gated on the brand's motion dial; reconciled with BADS' anti-defaults. Adapted from VibeCurb's awwwards-motion." },
79
80
  ],
80
81
  },
@@ -109,6 +110,7 @@ export const DOCS_INDEX: DocGroup[] = [
109
110
  { title: "Prompt — conceptual model", path: "prompts/conceptual-model.md", summary: "Before sketching a product surface, name its domain objects, states, relationships, and vocabulary — Jamie Mill's 'most neglected layer,' wired into Path B as design-exploration step 3.5. Feeds the real-content pool, state patterns, and primitive selection." },
110
111
  { title: "Prompt — parallel rollout", path: "prompts/parallel-rollout.md", summary: "For a Path B build that's N similar surfaces: build one reference screen, turn it into an explicit contract, sign off on the contract, then fan the rest out against it (via Workflow) and verify each to the contract. Stops multi-screen drift. Adapted from the design-spec-framework." },
111
112
  { title: "Prompt — design directions", path: "prompts/design-directions.md" },
113
+ { title: "Prompt — color ramp", path: "prompts/color-ramp.md", summary: "Build a 9-shade ramp from the single brand hex a client hands you: place 500, find the edges, fill inward, and move with hue rotation (capped 20-30°) rather than lightness alone so dark shades don't go grey. Adapted to BADS's AAA floor, which is stricter than the source and pushes the dark end further than it looks." },
112
114
  { title: "Prompt — plan & spec", path: "prompts/plan-and-spec.md", summary: "Lightweight per-feature convention: a matched plan (how you'll build it) + spec (the durable contract, in RFC-2119 language) under docs/plans/ and docs/specs/, dated and slugged the same. The trail that lets the next agent — or the client's team after the engagement — reconstruct why. Adapted from web-common's superpowers/plans + specs." },
113
115
  { title: "Prompt — macrostructures", path: "prompts/macrostructures.md", summary: "Named menu of ~16 structural paradigms (the positive counterpart to the anti-defaults) with when-it-fits / what-it-costs each, plus a diversification rule so a fork's screens don't converge on one shape. Consumed at design-exploration step 3.7. Adapted BADS-native from Nutlope's Hallmark." },
114
116
  { title: "Prompt — design critique", path: "prompts/design-critique.md" },
@@ -127,6 +129,9 @@ export const DOCS_INDEX: DocGroup[] = [
127
129
  { title: "Release-please evaluation", path: "docs/release-please-evaluation.md", summary: "Decision record: release-please vs changesets. Recommendation — stay on changesets (BADS ships one package; human-authored changelogs fit the intentional-output ethos), revisit release-please when BADS goes multi-package or Night Shift's auto-merge cadence outpaces manual changeset authoring. Item 12 from the web-common spec." },
128
130
  { title: "Oxlint + anti-slop evaluation", path: "docs/oxlint-anti-slop-evaluation.md", summary: "Spike (paused): dmmulroy/anti-slop TS rules + oxlint adoption (web-common Item 3). Finding — BADS's TypeScript is already clean of the low-signal patterns; the cheap win is oxlint's baseline (72 mostly-autofixable warnings), not the anti-slop pack. Recommended split: baseline + web-common React/cn rules + a few zero-cost ratchet rules; skip the high-backlog ones." },
129
131
  { title: "StyleX evaluation", path: "docs/stylex-evaluation.md", summary: "Scouting note (not adopted): Meta's compile-time atomic CSS-in-JS. Verdict — a replacement for BADS's Tailwind-v4 foundation, not an addition; rewriting it would invalidate the className-scanning lint suite that is BADS's value. Worth remembering only for a green-field v2 'creative OS' layer, for its deterministic cross-boundary token merge." },
132
+ { title: "lieflat-charts evaluation", path: "docs/lieflat-charts-evaluation.md", summary: "Scouting note (not adopted): an editorial data-viz agent skill. Blocker — PolyForm Noncommercial license; its code must never be vendored into a commercial fork. BADS already holds the philosophy (chart-design.md). One license-clean idea borrowed: a data-shape → chart-type selector added to chart-design.md." },
133
+ { title: "PRAXIST evaluation", path: "docs/praxist-evaluation.md", summary: "Scouting note (not vendored): sapientinc/PRAXIST, an autonomous measurable-research engine. Blocker — Fair Source License, and it optimizes a single number where most BADS research is qualitative. The loop shape (iterate-search-evaluate) is borrowed via the existing auto-research skill for the Night Shift weekly deep-dive (step 3a); the measurable-metric optimization lab is designed here but deferred." },
134
+ { title: "Deep-dive research questions", path: "docs/research-questions.md", summary: "Sir-curated queue for the Night Shift's weekly deep-dive (step 3a, Monday). The agent takes the top open question, runs the auto-research skill against it, and lands a report in ledgers/reports/. Empty queue is fine — the agent derives a question from recurring open ledger themes." },
130
135
  { title: "Token migration", path: "docs/token-migration.md", summary: "The pattern for renaming/restructuring tokens in a fork without a heroic all-at-once PR: a token-migration.json old→new mapping enforced diff-aware (changed files held to new names, legacy tolerated in untouched files) via pnpm check:token-migration, plus a copy-pasteable mapping table. Adapted from web-common." },
131
136
  { title: "Chart color palette", path: "docs/chart-color-palette.md", summary: "Accessible 5-color categorical palette for data viz — Okabe-Ito-derived, reviewed against WCAG 1.4.11 non-text contrast." },
132
137
  { title: "Chart design", path: "docs/chart-design.md", summary: "Chart composition rules — grid, axes, labels, legend, tooltip, number formatting, states, motion. The 'data is the only saturated thing' register; companion to the color palette." },
@@ -1,4 +1,10 @@
1
- import tokens from "../tokens.json";
1
+ // Relative "../tokens.json" resolves to upstream's own copy — indistinguishable
2
+ // from the alias inside this repo, but a fork's own tokens.json never gets read
3
+ // once published. "@/" is transpiled against the CONSUMER's tsconfig per the
4
+ // alias contract in CLIENT_ONBOARDING.md, so this reaches the fork's real
5
+ // tokens.json instead. See scripts/check-consumer-imports.mjs, which enforces
6
+ // this for every file under packages/core/src/.
7
+ import tokens from "@/packages/core/src/tokens.json";
2
8
  import { storageKey, readMigrated } from "@behavioral-agentic-design-system/core/lib/storage";
3
9
 
4
10
  // Both keys derive from the runtime slug so a renamed fork uses
@@ -138,6 +138,54 @@ export const Variant_Creatable: Story = {
138
138
  },
139
139
  };
140
140
 
141
+ export const Size_Sm: Story = {
142
+ name: "Size — sm",
143
+ render: () => {
144
+ const [value, setValue] = React.useState("");
145
+ return (
146
+ <Combobox
147
+ options={frameworks}
148
+ value={value}
149
+ onValueChange={setValue}
150
+ placeholder="Select framework..."
151
+ size="sm"
152
+ />
153
+ );
154
+ },
155
+ };
156
+
157
+ export const Size_Lg: Story = {
158
+ name: "Size — lg",
159
+ render: () => {
160
+ const [value, setValue] = React.useState("");
161
+ return (
162
+ <Combobox
163
+ options={frameworks}
164
+ value={value}
165
+ onValueChange={setValue}
166
+ placeholder="Select framework..."
167
+ size="lg"
168
+ />
169
+ );
170
+ },
171
+ };
172
+
173
+ export const Size_Xl: Story = {
174
+ name: "Size — xl (CTA floor, 44px)",
175
+ render: () => {
176
+ const [value, setValue] = React.useState("");
177
+ return (
178
+ <Combobox
179
+ options={frameworks}
180
+ value={value}
181
+ onValueChange={setValue}
182
+ placeholder="Select framework..."
183
+ size="xl"
184
+ />
185
+ );
186
+ },
187
+ };
188
+
141
189
  export const RealisticUse: Story = {
142
190
  decorators: [
143
191
  (Story) => (
@@ -92,6 +92,42 @@ export const EmptyState: Story = {
92
92
  ),
93
93
  }
94
94
 
95
+ export const Size_Sm: Story = {
96
+ name: "Size — sm",
97
+ render: () => {
98
+ const [val, setVal] = React.useState<string[]>([])
99
+ return (
100
+ <div className="w-72">
101
+ <MultiSelect options={FRAMEWORKS} value={val} onValueChange={setVal} size="sm" placeholder="Select frameworks..." />
102
+ </div>
103
+ )
104
+ },
105
+ }
106
+
107
+ export const Size_Lg: Story = {
108
+ name: "Size — lg",
109
+ render: () => {
110
+ const [val, setVal] = React.useState<string[]>([])
111
+ return (
112
+ <div className="w-72">
113
+ <MultiSelect options={FRAMEWORKS} value={val} onValueChange={setVal} size="lg" placeholder="Select frameworks..." />
114
+ </div>
115
+ )
116
+ },
117
+ }
118
+
119
+ export const Size_Xl: Story = {
120
+ name: "Size — xl (CTA floor, 44 px)",
121
+ render: () => {
122
+ const [val, setVal] = React.useState<string[]>([])
123
+ return (
124
+ <div className="w-72">
125
+ <MultiSelect options={FRAMEWORKS} value={val} onValueChange={setVal} size="xl" placeholder="Select frameworks..." />
126
+ </div>
127
+ )
128
+ },
129
+ }
130
+
95
131
  export const RealisticUse: Story = {
96
132
  render: () => {
97
133
  const [tags, setTags] = React.useState<string[]>(["next", "remix"])