@behavioral-agentic-design-system/core 0.48.0 → 0.49.1-beta-20261119021055

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 (229) hide show
  1. package/package.json +2 -1
  2. package/scripts/bads.mjs +247 -0
  3. package/scripts/build-tokens.cjs +24 -3
  4. package/scripts/lib/connect/check.mjs +102 -0
  5. package/scripts/lib/connect/connect.mjs +411 -0
  6. package/scripts/lib/connect/edits.mjs +361 -0
  7. package/scripts/lib/connect/tools.mjs +170 -0
  8. package/scripts/lib/connect/update-check.mjs +29 -0
  9. package/scripts/lint-ethics-contract.mjs +19 -1
  10. package/scripts/ux-smoke.mjs +5 -1
  11. package/src/api/save-tokens.ts +170 -24
  12. package/src/app/layout.tsx +12 -1
  13. package/src/app/preview/components/page.tsx +25 -18
  14. package/src/app/preview/global-font-client.tsx +2 -0
  15. package/src/app/providers.tsx +2 -0
  16. package/src/app/shell.tsx +50 -156
  17. package/src/components/customize/brand-mark-section.tsx +65 -95
  18. package/src/components/customize/font-pickers.tsx +25 -2
  19. package/src/components/customize/save-bar.tsx +120 -7
  20. package/src/components/customize/theme-io.tsx +62 -21
  21. package/src/components/customize-tab.tsx +3 -5
  22. package/src/components/home-recent.tsx +58 -25
  23. package/src/components/motion/reveal.tsx +168 -12
  24. package/src/components/studio/control-panel.tsx +98 -19
  25. package/src/components/studio/import-theme-dialog.tsx +167 -0
  26. package/src/components/studio/tokens-panel.tsx +215 -0
  27. package/src/components/studio/types.ts +5 -2
  28. package/src/components/studio/use-studio-tweaks.ts +36 -4
  29. package/src/components/studio/use-token-edits.ts +160 -0
  30. package/src/components/ui/date-picker.tsx +1 -8
  31. package/src/components/ui/date-range-picker.tsx +1 -8
  32. package/src/components/ui/json-input.tsx +0 -1
  33. package/src/components/ui/navigation-progress.tsx +5 -8
  34. package/src/components/ui/segmented-control.tsx +1 -5
  35. package/src/components/ui/sortable-list.tsx +1 -1
  36. package/src/components/ui/toggle-tip.tsx +38 -29
  37. package/src/components/ui/tree-view.tsx +0 -2
  38. package/src/data/component-stories.json +1214 -0
  39. package/src/data/docs-index.ts +10 -2
  40. package/src/data/hidden-views.ts +22 -0
  41. package/src/data/history.json +38 -38
  42. package/src/data/sticker-sheet.json +1878 -1821
  43. package/src/fonts/Figtree-OFL.txt +93 -0
  44. package/src/fonts/figtree-latin-ext-wght-normal.woff2 +0 -0
  45. package/src/fonts/figtree-latin-wght-italic.woff2 +0 -0
  46. package/src/fonts/figtree-latin-wght-normal.woff2 +0 -0
  47. package/src/fonts-cdn.css +3 -1
  48. package/src/fonts.css +44 -0
  49. package/src/hooks/use-global-heading-font.ts +104 -0
  50. package/src/hooks/use-global-sans-font.ts +8 -3
  51. package/src/hooks/use-global-theme.ts +2 -2
  52. package/src/hooks/use-token-overrides.ts +62 -14
  53. package/src/lib/component-contract.ts +148 -0
  54. package/src/lib/css-color.ts +42 -0
  55. package/src/lib/format-date.ts +7 -0
  56. package/src/lib/storybook-url.ts +28 -0
  57. package/src/lib/theme-editor.ts +7 -1
  58. package/src/lib/theme-import.ts +99 -0
  59. package/src/lib/theme-transition.ts +93 -0
  60. package/src/lib/token-list.ts +133 -0
  61. package/src/lib/token-value.ts +31 -0
  62. package/src/stories/Accordion.stories.tsx +1 -1
  63. package/src/stories/Affix.stories.tsx +1 -1
  64. package/src/stories/AiBadge.stories.tsx +1 -1
  65. package/src/stories/Alert.stories.tsx +1 -1
  66. package/src/stories/AlertDialog.stories.tsx +1 -1
  67. package/src/stories/AngleSlider.stories.tsx +1 -1
  68. package/src/stories/AnnouncementBar.stories.tsx +2 -2
  69. package/src/stories/AspectRatio.stories.tsx +1 -1
  70. package/src/stories/Attachment.stories.tsx +1 -1
  71. package/src/stories/Autocomplete.stories.tsx +1 -1
  72. package/src/stories/Avatar.stories.tsx +1 -1
  73. package/src/stories/Badge.stories.tsx +1 -1
  74. package/src/stories/Blockquote.stories.tsx +1 -1
  75. package/src/stories/Burger.stories.tsx +1 -1
  76. package/src/stories/Button.stories.tsx +1 -1
  77. package/src/stories/ButtonGroup.stories.tsx +1 -1
  78. package/src/stories/Calendar.stories.tsx +1 -1
  79. package/src/stories/Callout.stories.tsx +1 -1
  80. package/src/stories/Canvas.stories.tsx +1 -1
  81. package/src/stories/Card.stories.tsx +1 -1
  82. package/src/stories/Carousel.stories.tsx +1 -1
  83. package/src/stories/Cascader.stories.tsx +1 -1
  84. package/src/stories/Chart.stories.tsx +1 -1
  85. package/src/stories/ChatBubble.stories.tsx +1 -1
  86. package/src/stories/ChatMarker.stories.tsx +1 -1
  87. package/src/stories/Checkbox.stories.tsx +1 -1
  88. package/src/stories/CheckboxCard.stories.tsx +1 -1
  89. package/src/stories/CheckboxGroup.stories.tsx +1 -1
  90. package/src/stories/Chip.stories.tsx +1 -1
  91. package/src/stories/CircularProgress.stories.tsx +1 -1
  92. package/src/stories/Clipboard.stories.tsx +1 -1
  93. package/src/stories/CloseButton.stories.tsx +1 -1
  94. package/src/stories/Code.stories.tsx +1 -1
  95. package/src/stories/Collapsible.stories.tsx +1 -1
  96. package/src/stories/ColorPicker.stories.tsx +1 -1
  97. package/src/stories/ColorSwatch.stories.tsx +1 -1
  98. package/src/stories/Combobox.stories.tsx +1 -1
  99. package/src/stories/Container.stories.tsx +1 -1
  100. package/src/stories/ContextMenu.stories.tsx +1 -1
  101. package/src/stories/CopyButton.stories.tsx +1 -1
  102. package/src/stories/DataList.stories.tsx +1 -1
  103. package/src/stories/DataTable.stories.tsx +1 -1
  104. package/src/stories/DateField.stories.tsx +1 -1
  105. package/src/stories/DatePicker.stories.tsx +1 -1
  106. package/src/stories/DateRangePicker.stories.tsx +1 -1
  107. package/src/stories/Dialog.stories.tsx +1 -1
  108. package/src/stories/Drawer.stories.tsx +1 -1
  109. package/src/stories/DropdownMenu.stories.tsx +1 -1
  110. package/src/stories/Editable.stories.tsx +1 -1
  111. package/src/stories/EmptyState.stories.tsx +1 -1
  112. package/src/stories/FacetedFilter.stories.tsx +1 -1
  113. package/src/stories/Field.stories.tsx +1 -1
  114. package/src/stories/Fieldset.stories.tsx +1 -1
  115. package/src/stories/FileButton.stories.tsx +1 -1
  116. package/src/stories/FileUpload.stories.tsx +1 -1
  117. package/src/stories/FloatLabel.stories.tsx +1 -1
  118. package/src/stories/FloatingActionButton.stories.tsx +1 -1
  119. package/src/stories/FloatingIndicator.stories.tsx +1 -1
  120. package/src/stories/FloatingPanel.stories.tsx +1 -1
  121. package/src/stories/FocusTrap.stories.tsx +1 -1
  122. package/src/stories/FormatByte.stories.tsx +1 -1
  123. package/src/stories/FormatDate.stories.tsx +1 -1
  124. package/src/stories/FormatNumber.stories.tsx +1 -1
  125. package/src/stories/FormatRelativeTime.stories.tsx +1 -1
  126. package/src/stories/GaugeChart.stories.tsx +1 -1
  127. package/src/stories/Grid.stories.tsx +1 -1
  128. package/src/stories/Heatmap.stories.tsx +1 -1
  129. package/src/stories/Highlight.stories.tsx +1 -1
  130. package/src/stories/HoverCard.stories.tsx +1 -1
  131. package/src/stories/Icon.stories.tsx +1 -1
  132. package/src/stories/Image.stories.tsx +1 -1
  133. package/src/stories/Indicator.stories.tsx +1 -1
  134. package/src/stories/InfiniteScroll.stories.tsx +1 -1
  135. package/src/stories/InlineEdit.stories.tsx +1 -1
  136. package/src/stories/Input.stories.tsx +1 -1
  137. package/src/stories/InputClearButton.stories.tsx +1 -1
  138. package/src/stories/InputGroup.stories.tsx +1 -1
  139. package/src/stories/JsonInput.stories.tsx +2 -2
  140. package/src/stories/Kbd.stories.tsx +1 -1
  141. package/src/stories/KeyboardShortcut.stories.tsx +1 -1
  142. package/src/stories/Label.stories.tsx +1 -1
  143. package/src/stories/List.stories.tsx +1 -1
  144. package/src/stories/Listbox.stories.tsx +1 -1
  145. package/src/stories/LoadingDots.stories.tsx +1 -1
  146. package/src/stories/LoadingOverlay.stories.tsx +1 -1
  147. package/src/stories/Mark.stories.tsx +1 -1
  148. package/src/stories/MarkdownPreview.stories.tsx +1 -1
  149. package/src/stories/Marquee.stories.tsx +1 -1
  150. package/src/stories/Masonry.stories.tsx +1 -1
  151. package/src/stories/Meter.stories.tsx +1 -1
  152. package/src/stories/MonthPicker.stories.tsx +1 -1
  153. package/src/stories/MotionToggle.stories.tsx +1 -1
  154. package/src/stories/MultiSelect.stories.tsx +1 -1
  155. package/src/stories/NativeSelect.stories.tsx +1 -1
  156. package/src/stories/NavigationProgress.stories.tsx +1 -1
  157. package/src/stories/Notification.stories.tsx +1 -1
  158. package/src/stories/NumberField.stories.tsx +1 -1
  159. package/src/stories/NumberInput.stories.tsx +1 -1
  160. package/src/stories/OtpInput.stories.tsx +1 -1
  161. package/src/stories/Overlay.stories.tsx +1 -1
  162. package/src/stories/PageHeader.stories.tsx +1 -1
  163. package/src/stories/PasswordInput.stories.tsx +1 -1
  164. package/src/stories/PasswordStrengthInput.stories.tsx +1 -1
  165. package/src/stories/PhoneInput.stories.tsx +1 -1
  166. package/src/stories/Pill.stories.tsx +1 -1
  167. package/src/stories/PinInput.stories.tsx +1 -1
  168. package/src/stories/Popover.stories.tsx +1 -1
  169. package/src/stories/Portal.stories.tsx +1 -1
  170. package/src/stories/Presence.stories.tsx +1 -1
  171. package/src/stories/Progress.stories.tsx +1 -1
  172. package/src/stories/ProgressStack.stories.tsx +1 -1
  173. package/src/stories/Prose.stories.tsx +1 -1
  174. package/src/stories/QrCode.stories.tsx +1 -1
  175. package/src/stories/Questionnaire.stories.tsx +1 -1
  176. package/src/stories/RadioGroup.stories.tsx +1 -1
  177. package/src/stories/RatingGroup.stories.tsx +1 -1
  178. package/src/stories/Resizable.stories.tsx +1 -1
  179. package/src/stories/Result.stories.tsx +1 -1
  180. package/src/stories/Reveal.stories.tsx +1 -1
  181. package/src/stories/RollingNumber.stories.tsx +1 -1
  182. package/src/stories/ScrollArea.stories.tsx +1 -1
  183. package/src/stories/ScrollProgress.stories.tsx +1 -1
  184. package/src/stories/SearchInput.stories.tsx +1 -1
  185. package/src/stories/SegmentedControl.stories.tsx +2 -2
  186. package/src/stories/Select.stories.tsx +1 -1
  187. package/src/stories/Separator.stories.tsx +1 -1
  188. package/src/stories/Sheet.stories.tsx +1 -1
  189. package/src/stories/SignaturePad.stories.tsx +1 -1
  190. package/src/stories/SimpleGrid.stories.tsx +1 -1
  191. package/src/stories/Skeleton.stories.tsx +1 -1
  192. package/src/stories/SkeletonTable.stories.tsx +1 -1
  193. package/src/stories/Slider.stories.tsx +1 -1
  194. package/src/stories/Snackbar.stories.tsx +1 -1
  195. package/src/stories/Sonner.stories.tsx +1 -1
  196. package/src/stories/SortableList.stories.tsx +2 -1
  197. package/src/stories/Sparkline.stories.tsx +1 -1
  198. package/src/stories/Spinner.stories.tsx +1 -1
  199. package/src/stories/Spoiler.stories.tsx +1 -1
  200. package/src/stories/Squircle.stories.tsx +1 -1
  201. package/src/stories/Stack.stories.tsx +1 -1
  202. package/src/stories/StatusBadge.stories.tsx +1 -1
  203. package/src/stories/Switch.stories.tsx +1 -1
  204. package/src/stories/Table.stories.tsx +1 -1
  205. package/src/stories/Tag.stories.tsx +1 -1
  206. package/src/stories/TagsInput.stories.tsx +1 -1
  207. package/src/stories/Text.stories.tsx +1 -1
  208. package/src/stories/Textarea.stories.tsx +1 -1
  209. package/src/stories/ThemeIcon.stories.tsx +1 -1
  210. package/src/stories/TimePicker.stories.tsx +1 -1
  211. package/src/stories/Timeline.stories.tsx +1 -1
  212. package/src/stories/Timer.stories.tsx +1 -1
  213. package/src/stories/Toggle.stories.tsx +1 -1
  214. package/src/stories/ToggleGroup.stories.tsx +1 -1
  215. package/src/stories/ToggleTip.stories.tsx +106 -1
  216. package/src/stories/Tooltip.stories.tsx +56 -1
  217. package/src/stories/TransferList.stories.tsx +1 -1
  218. package/src/stories/TreeSelect.stories.tsx +1 -1
  219. package/src/stories/TreeView.stories.tsx +1 -0
  220. package/src/stories/TypingIndicator.stories.tsx +1 -1
  221. package/src/stories/VisuallyHidden.stories.tsx +1 -1
  222. package/src/stories/Watermark.stories.tsx +1 -1
  223. package/src/stories/WeekPicker.stories.tsx +1 -1
  224. package/src/stories/WordRotate.stories.tsx +1 -1
  225. package/src/stories/YearPicker.stories.tsx +1 -1
  226. package/src/stories/story-groups.json +216 -224
  227. package/src/styles.css +20 -3
  228. package/src/tokens.default.json +6 -1
  229. package/src/tokens.json +7 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behavioral-agentic-design-system/core",
3
- "version": "0.48.0",
3
+ "version": "0.49.1-beta-20261119021055",
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)",
@@ -48,6 +48,7 @@
48
48
  "bads-check-sync": "scripts/check-sync.mjs",
49
49
  "bads-components": "scripts/bads-components.mjs",
50
50
  "bads-deal-directions": "scripts/deal-directions.mjs",
51
+ "bads": "scripts/bads.mjs",
51
52
  "bads-doctor": "scripts/bads-doctor.mjs",
52
53
  "bads-ds-advisory": "scripts/design-system-advisory/run.mjs",
53
54
  "bads-fix-stories": "scripts/fix-stories.mjs",
@@ -0,0 +1,247 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * bads: the umbrella command for BADS forks. One subcommand today.
4
+ *
5
+ * npx bads connect wire the BADS MCP server and a rules file into every agent tool found
6
+ * npx bads connect --dry-run print every change and write nothing
7
+ * npx bads connect --list show the tools, the files connect would write, and what is wired now
8
+ * npx bads connect --check start each wired MCP server and ask it a question
9
+ * npx bads connect --remove undo exactly what connect wrote
10
+ *
11
+ * Full reference: docs/connect.md. The other bads-* commands (bads-doctor, bads-sync, the lints) keep their names.
12
+ */
13
+ import { readFileSync, realpathSync } from "node:fs";
14
+ import { dirname, join } from "node:path";
15
+ import { createInterface } from "node:readline/promises";
16
+ import { fileURLToPath } from "node:url";
17
+ import { apply, detectTools, displayPath, makeContext, plan, readEntry, remove, selectTools, targetPath, targetStatus } from "./lib/connect/connect.mjs";
18
+ import { probeContracts, probeServer } from "./lib/connect/check.mjs";
19
+ import { unifiedDiff } from "./lib/connect/edits.mjs";
20
+ import { TOOL_IDS } from "./lib/connect/tools.mjs";
21
+ import { checkForUpdate } from "./lib/connect/update-check.mjs";
22
+
23
+ const here = dirname(fileURLToPath(import.meta.url));
24
+ const VERSION = JSON.parse(readFileSync(join(here, "..", "package.json"), "utf8")).version;
25
+
26
+ const HELP = `Usage: bads connect [options]
27
+
28
+ Wires the BADS MCP server and a short rules file into the agent tools in this project.
29
+ By default it writes only inside the project directory.
30
+
31
+ Options:
32
+ --dry-run Print every change as a diff. Write nothing.
33
+ --list Show each tool, whether it was found, its files, and what is wired now.
34
+ --check Start each wired MCP server and call guide or get_contract.
35
+ --remove Undo what connect wrote, using its manifest in .bads/connect/.
36
+ --tools <ids> Only these tools, comma-separated: ${TOOL_IDS.join(", ")}.
37
+ --all Every tool, found or not.
38
+ --global Also write user-level files (home directory, Claude Desktop). Shows the diff and asks first.
39
+ --unverified Also write formats the tool's docs did not confirm. Off by default.
40
+ --yes Answer yes to the --global question (for scripts).
41
+ -h, --help Show this help.
42
+
43
+ Environment:
44
+ BADS_NO_UPDATE_CHECK=1 Skip the version check (the only network call, which sends nothing from the project).
45
+
46
+ Docs: docs/connect.md`;
47
+
48
+ export function parseArgs(argv) {
49
+ const opts = { tools: null, all: false, global: false, unverified: false, dryRun: false, yes: false, mode: "write" };
50
+ for (let i = 0; i < argv.length; i += 1) {
51
+ const a = argv[i];
52
+ if (a === "--dry-run") opts.dryRun = true;
53
+ else if (a === "--list") opts.mode = "list";
54
+ else if (a === "--check") opts.mode = "check";
55
+ else if (a === "--remove") opts.mode = "remove";
56
+ else if (a === "--all") opts.all = true;
57
+ else if (a === "--global") opts.global = true;
58
+ else if (a === "--unverified") opts.unverified = true;
59
+ else if (a === "--yes" || a === "-y") opts.yes = true;
60
+ else if (a === "-h" || a === "--help") opts.mode = "help";
61
+ else if (a === "--tools") opts.tools = (argv[++i] ?? "").split(",").filter(Boolean);
62
+ else if (a.startsWith("--tools=")) opts.tools = a.slice(8).split(",").filter(Boolean);
63
+ else throw new Error(`Unknown option: ${a}`);
64
+ }
65
+ return opts;
66
+ }
67
+
68
+ async function confirm(question, { yes, io }) {
69
+ if (yes) return true;
70
+ if (!io.stdin.isTTY) {
71
+ io.log("Not written: no terminal to ask. Run again with --yes to accept the diff above.");
72
+ return false;
73
+ }
74
+ const rl = createInterface({ input: io.stdin, output: io.stdout });
75
+ const answer = await rl.question(`${question} [y/N] `);
76
+ rl.close();
77
+ return /^y(es)?$/i.test(answer.trim());
78
+ }
79
+
80
+ function printSkipped(skipped, log) {
81
+ if (!skipped.length) return;
82
+ log("\nNot written:");
83
+ for (const s of skipped) log(` ${s.path} (${s.tool}): ${s.reason}`);
84
+ }
85
+
86
+ async function runWrite(ctx, opts, io) {
87
+ const { log } = io;
88
+ const p = plan(ctx, opts);
89
+ if (!p.selected.length) {
90
+ log("No agent tools found in this project or on this machine.");
91
+ log(`Name them with --tools <ids> (${TOOL_IDS.join(", ")}) or use --all. Run --list to see what connect looks for.`);
92
+ return 0;
93
+ }
94
+ log(`Tools: ${p.selected.join(", ")}`);
95
+ if (ctx.identity.components === "client") log(`Client-owned components: the rules point agents at ${ctx.identity.clientLibrary ?? "the client library"}.`);
96
+ if (!ctx.server) log("No BADS MCP server in this project, so connect writes the rules files only.");
97
+ const project = p.changes.filter((c) => c.scope === "project");
98
+ const global = p.changes.filter((c) => c.scope === "global");
99
+ for (const u of p.unchanged) log(` unchanged ${u.display}`);
100
+ if (opts.dryRun) {
101
+ for (const c of p.changes) log(`\n${unifiedDiff(c.before, c.after, c.display)}`);
102
+ printSkipped(p.skipped, log);
103
+ log(`\nDry run: ${p.changes.length} file(s) would change. Nothing was written.`);
104
+ return 0;
105
+ }
106
+ apply(ctx, p, { onlyScopes: ["project"] });
107
+ for (const c of project) log(` ${c.before == null ? "created" : "updated"} ${c.display} (${c.tools.join(", ")})`);
108
+ if (global.length) {
109
+ log("\nUser-level files, outside this project. This is the exact change:");
110
+ for (const c of global) log(`\n${unifiedDiff(c.before, c.after, c.display)}`);
111
+ if (await confirm(`\nWrite these ${global.length} user-level file(s)?`, { yes: opts.yes, io })) {
112
+ apply(ctx, p, { onlyScopes: ["global"] });
113
+ for (const c of global) log(` ${c.before == null ? "created" : "updated"} ${c.display} (backup kept beside it)`);
114
+ } else log("User-level files left as they were.");
115
+ }
116
+ printSkipped(p.skipped, log);
117
+ if (p.changes.length) log("\nUndo with `bads connect --remove`. Test the wiring with `bads connect --check`.");
118
+ else log("\nNothing to change: everything is already wired.");
119
+ return 0;
120
+ }
121
+
122
+ function runList(ctx, opts, io) {
123
+ const { log } = io;
124
+ log(`Project: ${ctx.root}`);
125
+ log(`MCP server: ${ctx.server ? ctx.server.rel : "none found (rules only)"}`);
126
+ log(`Components: ${ctx.identity.components === "client" ? `client-owned (${ctx.identity.clientLibrary ?? "library not named"})` : "BADS"}`);
127
+ const shown = opts.tools?.length || opts.all ? selectTools(ctx, opts) : detectTools(ctx);
128
+ for (const d of shown) {
129
+ const where = [...d.project, ...d.machine];
130
+ log(`\n${d.tool.name} (${d.tool.id}): ${d.detected ? `found (${where.join(", ")})` : "not found"}`);
131
+ for (const t of d.tool.targets) {
132
+ const flags = [t.scope === "global" ? "needs --global" : "project", t.verified ? "verified" : "unverified, off by default"].join(", ");
133
+ log(` ${t.role.padEnd(5)} ${displayPath(ctx, targetPath(ctx, t)).padEnd(42)} ${targetStatus(ctx, t).padEnd(8)} ${flags}`);
134
+ }
135
+ }
136
+ return 0;
137
+ }
138
+
139
+ async function runCheck(ctx, opts, io) {
140
+ const { log } = io;
141
+ const seen = new Map();
142
+ for (const { tool } of selectTools(ctx, { ...opts, all: opts.all || !opts.tools })) {
143
+ for (const t of tool.targets) {
144
+ if (t.role !== "mcp" || (t.scope === "global" && !opts.global)) continue;
145
+ const entry = readEntry(ctx, t);
146
+ if (!entry) continue;
147
+ const key = `${targetPath(ctx, t)}#${(t.keyPath ?? []).join(".")}`;
148
+ if (!seen.has(key)) seen.set(key, { display: displayPath(ctx, targetPath(ctx, t)), tools: [], entry });
149
+ seen.get(key).tools.push(tool.id);
150
+ }
151
+ }
152
+ let failed = 0;
153
+ if (!seen.size && !ctx.contracts) {
154
+ log("Nothing is wired yet. Run `bads connect` first.");
155
+ return 1;
156
+ }
157
+ for (const s of seen.values()) {
158
+ const r = await probeServer(s.entry, { root: ctx.root });
159
+ if (!r.ok) failed += 1;
160
+ log(`${r.ok ? "pass" : "FAIL"} ${s.display} (${s.tools.join(", ")}): ${r.detail}`);
161
+ }
162
+ if (ctx.contracts && (!ctx.server || ctx.identity.components === "client")) {
163
+ const r = probeContracts(ctx);
164
+ if (!r.ok) failed += 1;
165
+ log(`${r.ok ? "pass" : "FAIL"} contracts command: ${r.detail}`);
166
+ }
167
+ log(failed ? `\n${failed} check(s) failed.` : "\nEvery wired tool answered.");
168
+ return failed ? 1 : 0;
169
+ }
170
+
171
+ async function runRemove(ctx, opts, io) {
172
+ const { log } = io;
173
+ if (opts.global && !opts.dryRun) {
174
+ const preview = remove(ctx, { global: true, dryRun: true });
175
+ const globals = preview.diffs.filter((d) => d.scope === "global");
176
+ if (globals.length) {
177
+ log("User-level files, outside this project. This is the exact change:");
178
+ for (const d of globals) log(`\n${unifiedDiff(d.before, d.after, d.display)}`);
179
+ if (!(await confirm("\nUndo these user-level changes?", { yes: opts.yes, io }))) {
180
+ log("Nothing removed.");
181
+ return 0;
182
+ }
183
+ }
184
+ }
185
+ const r = remove(ctx, opts);
186
+ if (opts.dryRun) {
187
+ for (const d of r.diffs) log(`\n${unifiedDiff(d.before, d.after, d.display)}`);
188
+ log("\nDry run: nothing was removed.");
189
+ return 0;
190
+ }
191
+ for (const f of r.restored) log(` restored ${f} (byte for byte from the backup)`);
192
+ for (const f of r.deleted) log(` deleted ${f} (connect created it)`);
193
+ for (const f of r.stripped) log(` edited ${f} (changed since connect wrote it, so only connect's part was taken out)`);
194
+ for (const f of r.missing) log(` missing ${f} (already gone)`);
195
+ for (const f of r.kept) log(` kept ${f} (user-level: run --remove --global to undo it)`);
196
+ if (![r.restored, r.deleted, r.stripped, r.missing, r.kept].some((l) => l.length)) log("Nothing to remove: connect has not written anything here.");
197
+ return 0;
198
+ }
199
+
200
+ export async function main(argv, { cwd = process.cwd(), env = process.env, io = { log: console.log, stdin: process.stdin, stdout: process.stdout } } = {}) {
201
+ const [cmd, ...rest] = argv;
202
+ if (!cmd || cmd === "-h" || cmd === "--help" || cmd === "help") {
203
+ io.log(HELP);
204
+ return cmd ? 0 : 2;
205
+ }
206
+ if (cmd !== "connect") {
207
+ io.log(`Unknown command: ${cmd}\n\n${HELP}`);
208
+ return 2;
209
+ }
210
+ let opts;
211
+ try {
212
+ opts = parseArgs(rest);
213
+ } catch (e) {
214
+ io.log(`${e.message}\n\n${HELP}`);
215
+ return 2;
216
+ }
217
+ if (opts.mode === "help") {
218
+ io.log(HELP);
219
+ return 0;
220
+ }
221
+ const ctx = makeContext({ cwd, env });
222
+ let code;
223
+ try {
224
+ if (opts.mode === "list") code = runList(ctx, opts, io);
225
+ else if (opts.mode === "check") code = await runCheck(ctx, opts, io);
226
+ else if (opts.mode === "remove") code = await runRemove(ctx, opts, io);
227
+ else code = await runWrite(ctx, opts, io);
228
+ } catch (e) {
229
+ io.log(`bads connect: ${e.message}`);
230
+ return 1;
231
+ }
232
+ const latest = await checkForUpdate(VERSION, { env });
233
+ if (latest) io.log(`\nA newer @behavioral-agentic-design-system/core is out: ${latest} (you have ${VERSION}).`);
234
+ return code;
235
+ }
236
+
237
+ // Run when started as a command. The bin is a symlink in node_modules/.bin, so compare real paths.
238
+ const invokedPath = (() => {
239
+ try {
240
+ return process.argv[1] ? realpathSync(process.argv[1]) : null;
241
+ } catch {
242
+ return null;
243
+ }
244
+ })();
245
+ if (invokedPath && realpathSync(fileURLToPath(import.meta.url)) === invokedPath) {
246
+ process.exitCode = await main(process.argv.slice(2));
247
+ }
@@ -120,6 +120,7 @@ const darkVars = emitVars(tokens.theme.dark);
120
120
  const fontSans = tokens.fontFamily.sans.$value;
121
121
  const fontMono = tokens.fontFamily.mono.$value;
122
122
  const fontSerif = tokens.fontFamily.serif.$value;
123
+ const fontHeading = tokens.fontFamily.heading?.$value ?? fontSans;
123
124
 
124
125
  // One font stack from several pieces, each family once, in the order it first
125
126
  // appears. The token value is joined to a fixed fallback tail below, so a fork
@@ -727,6 +728,13 @@ const baseLayer = `@layer base {
727
728
  h1, h2, h3, h4, h5, h6 {
728
729
  text-wrap: balance;
729
730
  }
731
+ /* Headings read --font-heading (Figtree by default), independent of the
732
+ body font. Components that set a font utility on a heading still win:
733
+ this is base layer. The Studio and Customize tab change --font-heading
734
+ live; a fork changes it in tokens.json fontFamily.heading. */
735
+ h1, h2, h3, h4, h5, h6 {
736
+ font-family: var(--font-heading, var(--font-sans));
737
+ }
730
738
  /* text-wrap: pretty prevents orphaned last words on paragraphs by
731
739
  considering the last four lines when breaking. Supported Chrome 117+,
732
740
  Firefox 130+ (Baseline 2025). Falls back to normal wrap — no adverse
@@ -812,6 +820,15 @@ html, body {
812
820
  ::view-transition {
813
821
  background-color: var(--background);
814
822
  }
823
+ /* While a theme switch runs (lib/theme-transition.ts sets the attribute on <html>, and on same-origin iframe
824
+ documents), nothing may fade its own colours. The new-theme snapshot is taken a frame after the class flips,
825
+ and a transition-colors element is still mid-fade then, so the reveal showed some parts new and some old.
826
+ Pseudo-elements of the view transition itself are not matched by *, so the iris still animates. */
827
+ html[data-theme-switching] *,
828
+ html[data-theme-switching] *::before,
829
+ html[data-theme-switching] *::after {
830
+ transition: none !important;
831
+ }
815
832
  @keyframes theme-old-out {
816
833
  0%, 92% { opacity: 1; }
817
834
  98%, 100% { opacity: 0; }
@@ -1218,12 +1235,12 @@ html, body {
1218
1235
  }
1219
1236
 
1220
1237
  ::view-transition-new(root) {
1221
- animation: theme-reveal 0.4s ease-in-out forwards;
1238
+ animation: theme-reveal 0.4s ${easeInOut} forwards;
1222
1239
  }
1223
1240
  /* Same duration/easing as theme-reveal so the 92%/98% offsets line up with
1224
1241
  the reveal's coverage math. */
1225
1242
  ::view-transition-old(root) {
1226
- animation: theme-old-out 0.4s ease-in-out forwards;
1243
+ animation: theme-old-out 0.4s ${easeInOut} forwards;
1227
1244
  }
1228
1245
 
1229
1246
  /* Honor the app-level MotionToggle for the iris wipe too (same three-state
@@ -1391,6 +1408,7 @@ const pkgCss = `${banner}
1391
1408
  Google Fonts @import above) is the canonical fallback so unbranded
1392
1409
  consumers still get a high-legibility face out of the box. */
1393
1410
  --font-sans: ${fontStack(fontSans, "'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui")};
1411
+ --font-heading: ${fontStack(fontHeading, "'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui")};
1394
1412
  --font-mono: ${fontStack(fontMono)};
1395
1413
  --font-serif: ${fontStack(fontSerif)};
1396
1414
  --font-variation-settings: ${fontVariationSettings};
@@ -1449,12 +1467,14 @@ const pkgFontsCdnCss = `${banner}
1449
1467
  * the local @font-face rules in fonts.css win over it either way.
1450
1468
  *
1451
1469
  * Inter Variable leads as the default sans; Atkinson Hyperlegible stays as
1452
- * the accessibility-preserving secondary.
1470
+ * the accessibility-preserving secondary. Figtree is the heading face
1471
+ * (--font-heading), so this path keeps headings off the system UI font.
1453
1472
  *
1454
1473
  * This file must contain NO rules of its own — a single rule here would make
1455
1474
  * the @import statements below invalid for anyone importing it. */
1456
1475
  @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
1457
1476
  @import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&display=swap');
1477
+ @import url('https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300..900;1,300..900&display=swap');
1458
1478
  `;
1459
1479
 
1460
1480
  fs.writeFileSync(PKG_FONTS_CDN_CSS, pkgFontsCdnCss);
@@ -1537,6 +1557,7 @@ const appCss = `${banner}
1537
1557
  custom-property value at computed-value time, leaving --font-sans
1538
1558
  empty and text falling through to browser default ("Times"). */
1539
1559
  --font-sans: ${fontStack(fontSans, "var(--font-inter, 'Inter'), var(--font-atkinson, 'Atkinson Hyperlegible'), 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui")};
1560
+ --font-heading: ${fontStack(fontHeading, "var(--font-inter, 'Inter'), var(--font-atkinson, 'Atkinson Hyperlegible'), 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui")};
1540
1561
  --font-serif: ${fontStack(fontSerif, "var(--font-source-serif, 'Source Serif 4'), 'Source Serif 4', Georgia, ui-serif, serif")};
1541
1562
  --font-mono: ${fontStack(fontMono, "var(--font-jetbrains, 'JetBrains Mono'), 'JetBrains Mono', ui-monospace, monospace")};
1542
1563
  --font-variation-settings: ${fontVariationSettings};
@@ -0,0 +1,102 @@
1
+ /**
2
+ * `bads connect --check`: start each wired MCP server exactly as its config says and ask it a question.
3
+ *
4
+ * Speaks MCP over stdio by hand (newline-delimited JSON-RPC 2.0, https://modelcontextprotocol.io/specification),
5
+ * so the core package needs no MCP SDK: initialize, notifications/initialized, tools/list, then one tools/call to
6
+ * `guide` when the server has it, otherwise `get_contract`. A server that answers the call passes, even when the
7
+ * answer is "no such component", because the question was whether the wiring works.
8
+ */
9
+ import { spawn, spawnSync } from "node:child_process";
10
+ import { isAbsolute, resolve } from "node:path";
11
+
12
+ const PROTOCOL_VERSION = "2025-06-18";
13
+
14
+ /** Replace ${workspaceFolder} the way Cursor and VS Code do, so the probe starts what the editor would start. */
15
+ export function resolveEntry(entry, root) {
16
+ const sub = (s) => (typeof s === "string" ? s.split("${workspaceFolder}").join(root) : s);
17
+ const cwd = entry.cwd ? (isAbsolute(sub(entry.cwd)) ? sub(entry.cwd) : resolve(root, sub(entry.cwd))) : root;
18
+ return {
19
+ command: sub(entry.command),
20
+ args: (entry.args ?? []).map(sub),
21
+ env: Object.fromEntries(Object.entries(entry.env ?? {}).map(([k, v]) => [k, sub(v)])),
22
+ cwd,
23
+ };
24
+ }
25
+
26
+ /**
27
+ * Start the server and ask it one question. Resolves to { ok, tool, detail, tools } and never rejects.
28
+ * `probeName` is the component asked about when the server has no `guide` tool.
29
+ */
30
+ export function probeServer(entry, { root, probeName = "Button", timeoutMs = 20000, env = process.env } = {}) {
31
+ const r = resolveEntry(entry, root);
32
+ return new Promise((done) => {
33
+ let settled = false;
34
+ let stderr = "";
35
+ let buf = "";
36
+ const pending = new Map();
37
+ const child = spawn(r.command, r.args, { cwd: r.cwd, env: { ...env, ...r.env }, stdio: ["pipe", "pipe", "pipe"] });
38
+ const finish = (result) => {
39
+ if (settled) return;
40
+ settled = true;
41
+ clearTimeout(timer);
42
+ child.kill();
43
+ done(result);
44
+ };
45
+ const timer = setTimeout(() => finish({ ok: false, detail: `no answer in ${timeoutMs / 1000}s${stderr ? `: ${stderr.trim().split("\n").pop()}` : ""}` }), timeoutMs);
46
+ child.on("error", (e) => finish({ ok: false, detail: `could not start \`${r.command}\`: ${e.message}` }));
47
+ child.on("exit", (code) => finish({ ok: false, detail: `the server exited (code ${code})${stderr ? `: ${stderr.trim().split("\n").pop()}` : ""}` }));
48
+ child.stderr.on("data", (d) => {
49
+ stderr += d;
50
+ });
51
+ child.stdout.on("data", (d) => {
52
+ buf += d;
53
+ let nl;
54
+ while ((nl = buf.indexOf("\n")) !== -1) {
55
+ const line = buf.slice(0, nl).trim();
56
+ buf = buf.slice(nl + 1);
57
+ if (!line) continue;
58
+ let msg;
59
+ try {
60
+ msg = JSON.parse(line);
61
+ } catch {
62
+ continue;
63
+ }
64
+ const waiter = pending.get(msg.id);
65
+ if (waiter) {
66
+ pending.delete(msg.id);
67
+ waiter(msg);
68
+ }
69
+ }
70
+ });
71
+ let nextId = 1;
72
+ const request = (method, params) =>
73
+ new Promise((res) => {
74
+ const id = nextId++;
75
+ pending.set(id, res);
76
+ child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}\n`);
77
+ });
78
+ (async () => {
79
+ const init = await request("initialize", { protocolVersion: PROTOCOL_VERSION, capabilities: {}, clientInfo: { name: "bads-connect-check", version: "1" } });
80
+ if (init.error) return finish({ ok: false, detail: `initialize failed: ${init.error.message}` });
81
+ child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", method: "notifications/initialized" })}\n`);
82
+ const list = await request("tools/list", {});
83
+ if (list.error) return finish({ ok: false, detail: `tools/list failed: ${list.error.message}` });
84
+ const tools = (list.result?.tools ?? []).map((t) => t.name);
85
+ const tool = tools.includes("guide") ? "guide" : tools.includes("get_contract") ? "get_contract" : null;
86
+ if (!tool) return finish({ ok: false, tools, detail: `the server has neither guide nor get_contract (${tools.length} tools)` });
87
+ const call = await request("tools/call", { name: tool, arguments: tool === "guide" ? {} : { name: probeName } });
88
+ if (call.error) return finish({ ok: false, tool, tools, detail: `${tool} failed: ${call.error.message}` });
89
+ const text = call.result?.content?.find((c) => c.type === "text")?.text ?? "";
90
+ const found = call.result?.isError ? "answered (not found)" : "answered";
91
+ finish({ ok: true, tool, tools, detail: `${tools.length} tools, ${tool}${tool === "get_contract" ? `(${probeName})` : ""} ${found}, ${text.length} chars` });
92
+ })().catch((e) => finish({ ok: false, detail: e.message }));
93
+ });
94
+ }
95
+
96
+ /** Run the fork's own contract command once, for a client fork with no BADS MCP server. */
97
+ export function probeContracts(ctx) {
98
+ const [cmd, args] = ctx.contracts.argv;
99
+ const r = spawnSync(cmd, [...args, "components", "--json"], { cwd: ctx.root, encoding: "utf8", timeout: 60000, shell: process.platform === "win32" });
100
+ if (r.error) return { ok: false, detail: `could not run ${cmd}: ${r.error.message}` };
101
+ return r.status === 0 ? { ok: true, detail: "the contracts command answered `components`" } : { ok: false, detail: `the contracts command exited ${r.status}: ${(r.stderr || r.stdout || "").trim().split("\n").pop()}` };
102
+ }