@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
@@ -0,0 +1,361 @@
1
+ /**
2
+ * Pure text edits for `bads connect`. Every function takes the current file text (or null when the file does
3
+ * not exist) and returns the new text. Nothing here touches the disk, so each edit is unit-testable.
4
+ *
5
+ * Three edit kinds, one per config shape the agent tools use:
6
+ * - JSON: set one key path (for example mcpServers.bads) and leave every other key as it was.
7
+ * - Marked block: a Markdown or TOML block between start and end markers, appended once and replaced in place.
8
+ * - Diff: a small unified diff, so --dry-run and --global can show the exact change before it happens.
9
+ */
10
+ import { createHash } from "node:crypto";
11
+
12
+ export const MD_START = "<!-- bads-connect:start -->";
13
+ export const MD_END = "<!-- bads-connect:end -->";
14
+ export const TOML_START = "# bads-connect:start";
15
+ export const TOML_END = "# bads-connect:end";
16
+
17
+ export const sha256 = (text) => createHash("sha256").update(text ?? "").digest("hex");
18
+
19
+ export class EditConflict extends Error {}
20
+
21
+ const isPlainObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
22
+
23
+ export function deepEqual(a, b) {
24
+ if (a === b) return true;
25
+ if (Array.isArray(a) && Array.isArray(b)) return a.length === b.length && a.every((v, i) => deepEqual(v, b[i]));
26
+ if (isPlainObject(a) && isPlainObject(b)) {
27
+ const ka = Object.keys(a);
28
+ const kb = Object.keys(b);
29
+ return ka.length === kb.length && ka.every((k) => deepEqual(a[k], b[k]));
30
+ }
31
+ return false;
32
+ }
33
+
34
+ /** The indent the file already uses (2 spaces, 4 spaces or a tab), so a merge does not reformat it. */
35
+ export function detectIndent(text) {
36
+ const m = /^([ \t]+)"/m.exec(text || "");
37
+ return m ? m[1] : " ";
38
+ }
39
+
40
+ /**
41
+ * Parse a JSON config. Returns { ok, value } or { ok: false, reason }. A file with comments (JSONC) does not
42
+ * parse, and connect then refuses to edit it rather than drop the comments.
43
+ */
44
+ export function parseJsonConfig(text) {
45
+ if (text == null || text.trim() === "") return { ok: true, value: {} };
46
+ try {
47
+ const value = JSON.parse(text);
48
+ if (!isPlainObject(value)) return { ok: false, reason: "the top level is not a JSON object" };
49
+ return { ok: true, value };
50
+ } catch (e) {
51
+ return { ok: false, reason: `it is not plain JSON (${e.message.split("\n")[0]}). Comments are not supported` };
52
+ }
53
+ }
54
+
55
+ export function getPath(obj, keyPath) {
56
+ let cur = obj;
57
+ for (const k of keyPath) {
58
+ if (!isPlainObject(cur) || !(k in cur)) return undefined;
59
+ cur = cur[k];
60
+ }
61
+ return cur;
62
+ }
63
+
64
+ function serialize(value, original) {
65
+ const indent = detectIndent(original);
66
+ const trailing = original == null || original === "" || original.endsWith("\n") ? "\n" : "";
67
+ return JSON.stringify(value, null, indent) + trailing;
68
+ }
69
+
70
+ /**
71
+ * A tiny JSON scanner that records where each object and member sits in the text, so an edit can touch only the
72
+ * bytes it changes and the rest of the file keeps its exact formatting.
73
+ */
74
+ function scanJson(text) {
75
+ let i = 0;
76
+ const ws = () => {
77
+ while (i < text.length && /\s/.test(text[i])) i += 1;
78
+ };
79
+ const str = () => {
80
+ const start = i;
81
+ i += 1;
82
+ while (text[i] !== '"') i += text[i] === "\\" ? 2 : 1;
83
+ i += 1;
84
+ return JSON.parse(text.slice(start, i));
85
+ };
86
+ const value = () => {
87
+ ws();
88
+ const start = i;
89
+ if (text[i] === "{") {
90
+ i += 1;
91
+ const members = [];
92
+ ws();
93
+ if (text[i] === "}") {
94
+ i += 1;
95
+ return { type: "object", start, end: i, members };
96
+ }
97
+ for (;;) {
98
+ ws();
99
+ const keyStart = i;
100
+ const key = str();
101
+ ws();
102
+ i += 1; // colon
103
+ const v = value();
104
+ members.push({ key, keyStart, value: v });
105
+ ws();
106
+ if (text[i] === ",") {
107
+ i += 1;
108
+ continue;
109
+ }
110
+ i += 1; // closing brace
111
+ return { type: "object", start, end: i, members };
112
+ }
113
+ }
114
+ if (text[i] === "[") {
115
+ i += 1;
116
+ ws();
117
+ if (text[i] === "]") {
118
+ i += 1;
119
+ return { type: "array", start, end: i };
120
+ }
121
+ for (;;) {
122
+ value();
123
+ ws();
124
+ if (text[i] === ",") {
125
+ i += 1;
126
+ continue;
127
+ }
128
+ i += 1;
129
+ return { type: "array", start, end: i };
130
+ }
131
+ }
132
+ if (text[i] === '"') {
133
+ str();
134
+ return { type: "string", start, end: i };
135
+ }
136
+ while (i < text.length && !/[\s,}\]]/.test(text[i])) i += 1;
137
+ return { type: "literal", start, end: i };
138
+ };
139
+ return value();
140
+ }
141
+
142
+ const lineIndentAt = (text, offset) => /^[ \t]*/.exec(text.slice(text.lastIndexOf("\n", offset - 1) + 1))[0];
143
+
144
+ /** Serialize `value` as a member of an object whose own line starts at `baseIndent`. */
145
+ function memberText(key, value, baseIndent, unit) {
146
+ const inner = baseIndent + unit;
147
+ const body = JSON.stringify(value, null, unit).split("\n").join(`\n${inner}`);
148
+ return `${inner}${JSON.stringify(key)}: ${body}`;
149
+ }
150
+
151
+ /** Insert or replace keyPath in the text without reformatting anything else. Returns the new text or null. */
152
+ function surgicalSet(original, keyPath, entry, unit) {
153
+ const root = scanJson(original);
154
+ if (root.type !== "object") return null;
155
+ let obj = root;
156
+ let depth = 0;
157
+ for (; depth < keyPath.length - 1; depth += 1) {
158
+ const m = obj.members.find((x) => x.key === keyPath[depth]);
159
+ if (!m) break;
160
+ if (m.value.type !== "object") return null;
161
+ obj = m.value;
162
+ }
163
+ const last = obj.members.find((x) => x.key === keyPath[depth]);
164
+ if (depth === keyPath.length - 1 && last) {
165
+ const base = lineIndentAt(original, last.keyStart);
166
+ const body = JSON.stringify(entry, null, unit).split("\n").join(`\n${base}`);
167
+ return original.slice(0, last.value.start) + body + original.slice(last.value.end);
168
+ }
169
+ // Build what is missing from keyPath[depth] down, as one member of `obj`.
170
+ let value = entry;
171
+ for (let k = keyPath.length - 1; k > depth; k -= 1) value = { [keyPath[k]]: value };
172
+ const objIndent = lineIndentAt(original, obj.start);
173
+ const member = memberText(keyPath[depth], value, objIndent, unit);
174
+ const close = obj.end - 1;
175
+ if (obj.members.length === 0) return `${original.slice(0, obj.start)}{\n${member}\n${objIndent}}${original.slice(obj.end)}`;
176
+ const lastMember = obj.members[obj.members.length - 1];
177
+ return `${original.slice(0, lastMember.value.end)},\n${member}${original.slice(lastMember.value.end, close)}${original.slice(close)}`;
178
+ }
179
+
180
+ /** Remove keyPath (and `dropParents` parents connect created, once empty) without reformatting anything else. */
181
+ function surgicalDelete(original, keyPath, dropParents) {
182
+ const root = scanJson(original);
183
+ const chain = [root];
184
+ const members = [];
185
+ for (const k of keyPath) {
186
+ const m = chain[chain.length - 1].members?.find((x) => x.key === k);
187
+ if (!m) return original;
188
+ members.push(m);
189
+ chain.push(m.value);
190
+ }
191
+ // Walk up while the parent would be left empty and connect created it.
192
+ let level = keyPath.length - 1;
193
+ for (let dropped = 0; dropped < dropParents && level > 0 && chain[level].members.length === 1; dropped += 1) level -= 1;
194
+ const parent = chain[level];
195
+ const target = members[level];
196
+ const idx = parent.members.indexOf(target);
197
+ let start;
198
+ let end;
199
+ if (parent.members.length === 1) {
200
+ start = parent.start + 1;
201
+ end = parent.end - 1;
202
+ return original.slice(0, start) + original.slice(end).replace(/^\s*(?=})/, "") ;
203
+ }
204
+ if (idx > 0) {
205
+ start = parent.members[idx - 1].value.end;
206
+ end = target.value.end;
207
+ } else {
208
+ start = target.keyStart;
209
+ end = parent.members[1].keyStart;
210
+ }
211
+ return original.slice(0, start) + original.slice(end);
212
+ }
213
+
214
+ /**
215
+ * Set keyPath to entry. `owned` says the existing value (if any) was written by connect, so it may be replaced.
216
+ * Returns { text, changed, createdParents } where createdParents counts the parent objects connect added.
217
+ * Throws EditConflict when a different value is already there and connect did not write it.
218
+ */
219
+ export function mergeJsonEntry(original, keyPath, entry, { owned = false } = {}) {
220
+ const parsed = parseJsonConfig(original);
221
+ if (!parsed.ok) throw new EditConflict(`cannot merge: ${parsed.reason}`);
222
+ const root = parsed.value;
223
+ const current = getPath(root, keyPath);
224
+ if (current !== undefined && deepEqual(current, entry)) return { text: original, changed: false, createdParents: 0 };
225
+ if (current !== undefined && !owned) {
226
+ throw new EditConflict(`"${keyPath.join(".")}" already exists with different settings. connect leaves it as it is`);
227
+ }
228
+ let cur = root;
229
+ let createdParents = 0;
230
+ for (const k of keyPath.slice(0, -1)) {
231
+ if (cur[k] === undefined) {
232
+ cur[k] = {};
233
+ createdParents += 1;
234
+ } else if (!isPlainObject(cur[k])) {
235
+ throw new EditConflict(`"${k}" is not an object, so connect cannot add a server under it`);
236
+ }
237
+ cur = cur[k];
238
+ }
239
+ cur[keyPath[keyPath.length - 1]] = entry;
240
+ return { text: editText(original, root, (o) => surgicalSet(o, keyPath, entry, detectIndent(o))), changed: true, createdParents };
241
+ }
242
+
243
+ /** Apply a surgical edit, and fall back to a full rewrite if the result does not parse to the expected value. */
244
+ function editText(original, expected, surgical) {
245
+ if (original != null && original.trim() !== "") {
246
+ try {
247
+ const text = surgical(original);
248
+ if (text != null && deepEqual(JSON.parse(text), expected)) return text;
249
+ } catch {
250
+ /* fall through to a full rewrite */
251
+ }
252
+ }
253
+ return serialize(expected, original);
254
+ }
255
+
256
+ /**
257
+ * Delete keyPath. Parent objects connect created (dropParents of them, innermost first) are deleted once empty.
258
+ * Returns { text, changed, empty } where empty means nothing is left in the file.
259
+ */
260
+ export function removeJsonEntry(original, keyPath, { dropParents = 0 } = {}) {
261
+ const parsed = parseJsonConfig(original);
262
+ if (!parsed.ok) throw new EditConflict(`cannot edit: ${parsed.reason}`);
263
+ const root = parsed.value;
264
+ if (getPath(root, keyPath) === undefined) return { text: original, changed: false, empty: Object.keys(root).length === 0 };
265
+ const parents = [root];
266
+ for (const k of keyPath.slice(0, -1)) parents.push(parents[parents.length - 1][k]);
267
+ delete parents[parents.length - 1][keyPath[keyPath.length - 1]];
268
+ for (let i = parents.length - 1, dropped = 0; i > 0 && dropped < dropParents; i -= 1, dropped += 1) {
269
+ if (Object.keys(parents[i]).length > 0) break;
270
+ delete parents[i - 1][keyPath[i - 1]];
271
+ }
272
+ const text = editText(original, root, (o) => surgicalDelete(o, keyPath, dropParents));
273
+ return { text, changed: true, empty: Object.keys(root).length === 0 };
274
+ }
275
+
276
+ function markers(style) {
277
+ return style === "toml" ? [TOML_START, TOML_END] : [MD_START, MD_END];
278
+ }
279
+
280
+ /** Locate a marked block. Returns { start, end } offsets (end is after the end marker), or null. */
281
+ export function findBlock(text, style = "md") {
282
+ if (text == null) return null;
283
+ const [s, e] = markers(style);
284
+ const start = text.indexOf(s);
285
+ if (start === -1) return null;
286
+ const endAt = text.indexOf(e, start);
287
+ if (endAt === -1) throw new EditConflict(`found "${s}" with no "${e}". Fix the file by hand, then run connect again`);
288
+ return { start, end: endAt + e.length };
289
+ }
290
+
291
+ /** Wrap body lines in markers. */
292
+ export function wrapBlock(body, style = "md") {
293
+ const [s, e] = markers(style);
294
+ return `${s}\n${body.replace(/\n+$/, "")}\n${e}`;
295
+ }
296
+
297
+ /**
298
+ * Put the block in the file: replace an existing marked block in place, or append it after one blank line.
299
+ * `header` is written only when the file is created (for example Cursor's .mdc frontmatter).
300
+ */
301
+ export function upsertBlock(original, block, { style = "md", header = "" } = {}) {
302
+ if (original == null) return { text: `${header}${block}\n`, changed: true };
303
+ const found = findBlock(original, style);
304
+ if (found) {
305
+ const text = original.slice(0, found.start) + block + original.slice(found.end);
306
+ return { text, changed: text !== original };
307
+ }
308
+ if (original === "") return { text: `${block}\n`, changed: true };
309
+ const sep = original.endsWith("\n\n") ? "" : original.endsWith("\n") ? "\n" : "\n\n";
310
+ return { text: `${original}${sep}${block}\n`, changed: true };
311
+ }
312
+
313
+ /**
314
+ * Take the block out. Used when the file changed after connect wrote it, so the backup cannot be restored
315
+ * byte for byte: the block and the blank line connect put before it go, the rest stays.
316
+ */
317
+ export function removeBlock(original, { style = "md" } = {}) {
318
+ const found = findBlock(original, style);
319
+ if (!found) return { text: original, changed: false };
320
+ let { start, end } = found;
321
+ if (original[end] === "\n") end += 1;
322
+ if (start >= 2 && original.slice(start - 2, start) === "\n\n") start -= 1;
323
+ return { text: original.slice(0, start) + original.slice(end), changed: true };
324
+ }
325
+
326
+ /** A small unified diff. Trims the shared head and tail first, so a large config with a local edit stays cheap. */
327
+ export function unifiedDiff(before, after, label) {
328
+ const a = before == null ? [] : before.split("\n");
329
+ const b = after == null ? [] : after.split("\n");
330
+ let head = 0;
331
+ while (head < a.length && head < b.length && a[head] === b[head]) head += 1;
332
+ let tail = 0;
333
+ while (tail < a.length - head && tail < b.length - head && a[a.length - 1 - tail] === b[b.length - 1 - tail]) tail += 1;
334
+ const am = a.slice(head, a.length - tail);
335
+ const bm = b.slice(head, b.length - tail);
336
+ // LCS over the changed middle only.
337
+ const dp = Array.from({ length: am.length + 1 }, () => new Array(bm.length + 1).fill(0));
338
+ for (let i = am.length - 1; i >= 0; i -= 1)
339
+ for (let j = bm.length - 1; j >= 0; j -= 1) dp[i][j] = am[i] === bm[j] ? dp[i + 1][j + 1] + 1 : Math.max(dp[i + 1][j], dp[i][j + 1]);
340
+ const body = [];
341
+ let i = 0;
342
+ let j = 0;
343
+ while (i < am.length || j < bm.length) {
344
+ if (i < am.length && j < bm.length && am[i] === bm[j]) {
345
+ body.push(` ${am[i]}`);
346
+ i += 1;
347
+ j += 1;
348
+ } else if (j < bm.length && (i >= am.length || dp[i][j + 1] >= dp[i + 1][j])) body.push(`+${bm[j++]}`);
349
+ else body.push(`-${am[i++]}`);
350
+ }
351
+ const ctx = 3;
352
+ const pre = a.slice(Math.max(0, head - ctx), head).map((l) => ` ${l}`);
353
+ const post = a.slice(a.length - tail, Math.min(a.length, a.length - tail + ctx)).map((l) => ` ${l}`);
354
+ const from = before == null ? "/dev/null" : `a/${label}`;
355
+ const to = after == null ? "/dev/null" : `b/${label}`;
356
+ const startLine = head - pre.length + 1;
357
+ const oldCount = pre.length + post.length + body.filter((l) => l[0] !== "+").length;
358
+ const newCount = pre.length + post.length + body.filter((l) => l[0] !== "-").length;
359
+ const range = (n) => `${n ? startLine : startLine - 1},${n}`;
360
+ return [`--- ${from}`, `+++ ${to}`, `@@ -${range(oldCount)} +${range(newCount)} @@`, ...pre, ...body, ...post].join("\n");
361
+ }
@@ -0,0 +1,170 @@
1
+ /**
2
+ * The agent tools `bads connect` knows, where each one reads an MCP server entry and a rules file, and the
3
+ * documentation that says so. Every target was checked against the tool's own docs on 2026-11-19. A target whose
4
+ * format the docs did not confirm is `verified: false`, and connect writes it only with --unverified.
5
+ *
6
+ * Scopes:
7
+ * project a path inside the project directory. The default writes only these.
8
+ * global a user-level path (home directory or app support folder). Written only with --global, after the
9
+ * exact diff is shown.
10
+ *
11
+ * Server entry styles (how the entry finds the BADS MCP server):
12
+ * relative `node packages/mcp/bin/stdio.mjs`. The tool starts servers from the project root, and the
13
+ * server reads the project from its working directory.
14
+ * workspaceFolder `${workspaceFolder}/...` plus BADS_ROOT, for editors whose server process does not start in
15
+ * the project (Cursor and VS Code both document the variable).
16
+ * absolute absolute paths plus BADS_ROOT, for user-level files that are not tied to one project.
17
+ *
18
+ * Sources:
19
+ * Claude Code https://code.claude.com/docs/en/mcp (project .mcp.json, mcpServers; user scope in ~/.claude.json)
20
+ * https://code.claude.com/docs/en/memory (CLAUDE.md loaded every session)
21
+ * Cursor https://cursor.com/docs/context/mcp (.cursor/mcp.json, ~/.cursor/mcp.json, ${workspaceFolder})
22
+ * https://cursor.com/docs/context/rules (.cursor/rules/*.mdc with description, globs, alwaysApply)
23
+ * Codex CLI https://developers.openai.com/codex/mcp (now learn.chatgpt.com/docs/extend/mcp): [mcp_servers.<name>]
24
+ * in ~/.codex/config.toml, or .codex/config.toml for trusted projects only
25
+ * https://developers.openai.com/codex/guides/agents-md (AGENTS.md)
26
+ * Windsurf https://docs.devin.ai/desktop/cascade/memories (Windsurf is now Devin Desktop; .windsurf/rules/*.md
27
+ * is still imported, trigger frontmatter: always_on, glob, model_decision, manual)
28
+ * https://docs.devin.ai/desktop/cascade/mcp and https://docs.devin.ai/cli/extensibility/mcp/configuration
29
+ * name .devin/mcp_config.json for the Devin CLI only. The older ~/.codeium/windsurf/mcp_config.json
30
+ * path no longer appears in the official docs. Both MCP targets are unverified.
31
+ * GitHub Copilot https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions
32
+ * (.github/copilot-instructions.md)
33
+ * https://code.visualstudio.com/docs/agents/reference/mcp-configuration (workspace-root .mcp.json with
34
+ * mcpServers for the Copilot harness, user file $COPILOT_HOME/mcp-config.json or ~/.copilot/mcp-config.json)
35
+ * Gemini CLI https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md (.gemini/settings.json,
36
+ * ~/.gemini/settings.json, mcpServers with command, args, env, cwd)
37
+ * https://geminicli.com/docs/cli/gemini-md/ (GEMINI.md)
38
+ * VS Code https://code.visualstudio.com/docs/agents/reference/mcp-configuration (.vscode/mcp.json, top-level
39
+ * `servers`, `type: "stdio"` required, ${workspaceFolder}). The user-profile path is not given, so
40
+ * connect has no user-level VS Code target.
41
+ * Claude Desktop https://modelcontextprotocol.io/docs/develop/connect-local-servers (claude_desktop_config.json on
42
+ * macOS, Windows and Linux, mcpServers)
43
+ */
44
+ import { join } from "node:path";
45
+
46
+ export const SERVER_NAME = "bads";
47
+
48
+ /** Claude Desktop's config folder for this platform. */
49
+ export function claudeDesktopDir({ home, env, platform }) {
50
+ if (platform === "darwin") return join(home, "Library", "Application Support", "Claude");
51
+ if (platform === "win32") return join(env.APPDATA || join(home, "AppData", "Roaming"), "Claude");
52
+ return join(env.XDG_CONFIG_HOME || join(home, ".config"), "Claude");
53
+ }
54
+
55
+ const RULES_DESCRIPTION = "How to use the design system in this project";
56
+
57
+ /**
58
+ * Each tool: id, name, how to detect it, and its targets. A target is
59
+ * { role: "mcp" | "rules", scope, kind: "json" | "toml" | "block", path (project-relative) or globalPath(ctx),
60
+ * keyPath (json), style (mcp), header (block files connect creates), verified, docs, note }
61
+ */
62
+ export const TOOLS = [
63
+ {
64
+ id: "claude-code",
65
+ name: "Claude Code",
66
+ detect: { project: [".claude", "CLAUDE.md", ".mcp.json"], home: [".claude", ".claude.json"], bin: ["claude"] },
67
+ targets: [
68
+ { role: "mcp", scope: "project", kind: "json", path: ".mcp.json", keyPath: ["mcpServers", SERVER_NAME], style: "relative", typeField: true, verified: true, docs: "https://code.claude.com/docs/en/mcp" },
69
+ { role: "rules", scope: "project", kind: "block", path: "CLAUDE.md", verified: true, docs: "https://code.claude.com/docs/en/memory" },
70
+ {
71
+ role: "mcp", scope: "global", kind: "json", globalPath: (c) => join(c.home, ".claude.json"), keyPath: ["mcpServers", SERVER_NAME], style: "absolute", typeField: true, verified: false,
72
+ docs: "https://code.claude.com/docs/en/mcp",
73
+ note: "The docs say user-scoped servers are stored in ~/.claude.json but do not name the key. Prefer `claude mcp add --scope user`.",
74
+ },
75
+ ],
76
+ },
77
+ {
78
+ id: "cursor",
79
+ name: "Cursor",
80
+ detect: { project: [".cursor", ".cursorrules"], home: [".cursor"], bin: ["cursor"] },
81
+ targets: [
82
+ { role: "mcp", scope: "project", kind: "json", path: ".cursor/mcp.json", keyPath: ["mcpServers", SERVER_NAME], style: "workspaceFolder", typeField: true, verified: true, docs: "https://cursor.com/docs/context/mcp" },
83
+ {
84
+ role: "rules", scope: "project", kind: "block", path: ".cursor/rules/bads.mdc", verified: true, docs: "https://cursor.com/docs/context/rules",
85
+ header: `---\ndescription: ${RULES_DESCRIPTION}\nalwaysApply: true\n---\n\n`,
86
+ },
87
+ { role: "mcp", scope: "global", kind: "json", globalPath: (c) => join(c.home, ".cursor", "mcp.json"), keyPath: ["mcpServers", SERVER_NAME], style: "absolute", typeField: true, verified: true, docs: "https://cursor.com/docs/context/mcp" },
88
+ ],
89
+ },
90
+ {
91
+ id: "codex",
92
+ name: "Codex CLI",
93
+ detect: { project: [".codex"], home: [".codex"], bin: ["codex"] },
94
+ targets: [
95
+ {
96
+ role: "mcp", scope: "project", kind: "toml", path: ".codex/config.toml", style: "relative", verified: true, docs: "https://developers.openai.com/codex/mcp",
97
+ note: "Codex reads a project .codex/config.toml only in a trusted project.",
98
+ },
99
+ { role: "rules", scope: "project", kind: "block", path: "AGENTS.md", verified: true, docs: "https://developers.openai.com/codex/guides/agents-md" },
100
+ { role: "mcp", scope: "global", kind: "toml", globalPath: (c) => join(c.env.CODEX_HOME || join(c.home, ".codex"), "config.toml"), style: "absolute", verified: true, docs: "https://developers.openai.com/codex/mcp" },
101
+ ],
102
+ },
103
+ {
104
+ id: "windsurf",
105
+ name: "Windsurf",
106
+ detect: { project: [".windsurf", ".windsurfrules", ".devin"], home: [".codeium/windsurf", ".devin", ".config/devin"], bin: ["windsurf", "devin"] },
107
+ targets: [
108
+ {
109
+ role: "rules", scope: "project", kind: "block", path: ".windsurf/rules/bads.md", verified: true, docs: "https://docs.devin.ai/desktop/cascade/memories",
110
+ header: "---\ntrigger: always_on\n---\n\n",
111
+ },
112
+ {
113
+ role: "mcp", scope: "project", kind: "json", path: ".devin/mcp_config.json", keyPath: ["mcpServers", SERVER_NAME], style: "relative", verified: false,
114
+ docs: "https://docs.devin.ai/cli/extensibility/mcp/configuration",
115
+ note: "Documented for the Devin CLI. The docs do not say Windsurf or Devin Desktop reads it.",
116
+ },
117
+ {
118
+ role: "mcp", scope: "global", kind: "json", globalPath: (c) => join(c.home, ".codeium", "windsurf", "mcp_config.json"), keyPath: ["mcpServers", SERVER_NAME], style: "absolute", verified: false,
119
+ docs: "https://docs.devin.ai/desktop/cascade/mcp",
120
+ note: "This older path no longer appears in the official docs.",
121
+ },
122
+ ],
123
+ },
124
+ {
125
+ id: "copilot",
126
+ name: "GitHub Copilot",
127
+ detect: { project: [".github/copilot-instructions.md", ".github/instructions", ".copilot"], home: [".copilot"], bin: ["copilot"] },
128
+ targets: [
129
+ { role: "rules", scope: "project", kind: "block", path: ".github/copilot-instructions.md", verified: true, docs: "https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions" },
130
+ {
131
+ role: "mcp", scope: "project", kind: "json", path: ".mcp.json", keyPath: ["mcpServers", SERVER_NAME], style: "relative", typeField: true, verified: true,
132
+ docs: "https://code.visualstudio.com/docs/agents/reference/mcp-configuration",
133
+ note: "VS Code reads a workspace-root .mcp.json for Copilot when chat.mcp.workspaceRootConfig.enabled is on. Claude Code reads the same file.",
134
+ },
135
+ { role: "mcp", scope: "global", kind: "json", globalPath: (c) => join(c.env.COPILOT_HOME || join(c.home, ".copilot"), "mcp-config.json"), keyPath: ["mcpServers", SERVER_NAME], style: "absolute", typeField: true, verified: true, docs: "https://code.visualstudio.com/docs/agents/reference/mcp-configuration" },
136
+ ],
137
+ },
138
+ {
139
+ id: "gemini",
140
+ name: "Gemini CLI",
141
+ detect: { project: [".gemini", "GEMINI.md"], home: [".gemini"], bin: ["gemini"] },
142
+ targets: [
143
+ { role: "mcp", scope: "project", kind: "json", path: ".gemini/settings.json", keyPath: ["mcpServers", SERVER_NAME], style: "relative", verified: true, docs: "https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md" },
144
+ { role: "rules", scope: "project", kind: "block", path: "GEMINI.md", verified: true, docs: "https://geminicli.com/docs/cli/gemini-md/" },
145
+ { role: "mcp", scope: "global", kind: "json", globalPath: (c) => join(c.home, ".gemini", "settings.json"), keyPath: ["mcpServers", SERVER_NAME], style: "absolute", cwdField: true, verified: true, docs: "https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md" },
146
+ ],
147
+ },
148
+ {
149
+ id: "vscode",
150
+ name: "VS Code",
151
+ detect: { project: [".vscode"], home: [".vscode"], bin: ["code"] },
152
+ targets: [
153
+ {
154
+ role: "mcp", scope: "project", kind: "json", path: ".vscode/mcp.json", keyPath: ["servers", SERVER_NAME], style: "workspaceFolder", typeField: true, verified: true,
155
+ docs: "https://code.visualstudio.com/docs/agents/reference/mcp-configuration",
156
+ note: "Editor-managed file. A file with comments is left alone and connect prints the entry to paste.",
157
+ },
158
+ ],
159
+ },
160
+ {
161
+ id: "claude-desktop",
162
+ name: "Claude Desktop",
163
+ detect: { project: [], homeAbs: (c) => [claudeDesktopDir(c)], bin: [] },
164
+ targets: [
165
+ { role: "mcp", scope: "global", kind: "json", globalPath: (c) => join(claudeDesktopDir(c), "claude_desktop_config.json"), keyPath: ["mcpServers", SERVER_NAME], style: "absolute", verified: true, docs: "https://modelcontextprotocol.io/docs/develop/connect-local-servers" },
166
+ ],
167
+ },
168
+ ];
169
+
170
+ export const TOOL_IDS = TOOLS.map((t) => t.id);
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The one network call `bads connect` may make: ask the public npm registry for the latest version of the core
3
+ * package. It is a plain GET with no body, no query string, and nothing from the project. It runs only in an
4
+ * interactive terminal, never in CI, and never when BADS_NO_UPDATE_CHECK=1. A failure is silent.
5
+ */
6
+ export const UPDATE_URL = "https://registry.npmjs.org/@behavioral-agentic-design-system/core/latest";
7
+
8
+ export function updateCheckEnabled({ env = process.env, isTTY = process.stdout.isTTY } = {}) {
9
+ return env.BADS_NO_UPDATE_CHECK !== "1" && !env.CI && !!isTTY;
10
+ }
11
+
12
+ const newer = (a, b) => {
13
+ const pa = String(a).split(/[.-]/).map(Number);
14
+ const pb = String(b).split(/[.-]/).map(Number);
15
+ for (let i = 0; i < 3; i += 1) if ((pa[i] || 0) !== (pb[i] || 0)) return (pa[i] || 0) > (pb[i] || 0);
16
+ return false;
17
+ };
18
+
19
+ export async function checkForUpdate(current, { env = process.env, isTTY = process.stdout.isTTY, fetchImpl = globalThis.fetch } = {}) {
20
+ if (!updateCheckEnabled({ env, isTTY }) || typeof fetchImpl !== "function") return null;
21
+ try {
22
+ const res = await fetchImpl(UPDATE_URL, { method: "GET", headers: { accept: "application/json" }, signal: AbortSignal.timeout(1500) });
23
+ if (!res.ok) return null;
24
+ const { version } = await res.json();
25
+ return version && newer(version, current) ? version : null;
26
+ } catch {
27
+ return null;
28
+ }
29
+ }
@@ -26,6 +26,12 @@
26
26
  // ethicsContract is assumed to collect nothing. A present-but-incomplete
27
27
  // contract is never allowed.
28
28
  //
29
+ // Not-applicable form (added 2026-11-18 with the unified component contract,
30
+ // layer-5-component-registry/contract.schema.json): pnpm lint:contracts now
31
+ // requires an ethicsContract on EVERY entry, so a component with nothing to
32
+ // declare says so explicitly: { notApplicable: true, reason }. This lint fails
33
+ // that form on a detected data-entry primitive, and fails it without a reason.
34
+ //
29
35
  // Informational (warnings, non-blocking): darkPatternRisk outside the enum,
30
36
  // aiDisclosure missing on a contract that names AI in dataCollected.
31
37
  //
@@ -46,6 +52,7 @@ let errors = 0;
46
52
  let warnings = 0;
47
53
  let withContract = 0;
48
54
  let collecting = 0;
55
+ let notApplicable = 0;
49
56
 
50
57
  function err(name, msg) {
51
58
  console.log(`❌ ${name}: ${msg}`);
@@ -89,12 +96,23 @@ for (const name of requiresContract) {
89
96
  const c = registry[name]?.ethicsContract;
90
97
  if (!c || typeof c !== "object") {
91
98
  err(name, `renders a data-entry surface but declares no ethicsContract — declare one (dataCollected may be [] with a notes field explaining why)`);
99
+ } else if (c.notApplicable === true) {
100
+ // The not-applicable form (layer-5-component-registry/contract.schema.json) is for components with no
101
+ // data-entry surface. A field that takes input always has an ethics posture, even if it is "collects nothing".
102
+ err(name, `renders a data-entry surface, so its ethicsContract cannot be notApplicable — declare dataCollected (may be []) with a notes field`);
92
103
  }
93
104
  }
94
105
 
95
106
  for (const name of names) {
96
107
  const c = registry[name]?.ethicsContract;
97
108
  if (!c || typeof c !== "object") continue; // absent == collects nothing (non-data-entry components)
109
+ if (c.notApplicable === true) {
110
+ notApplicable++;
111
+ if (typeof c.reason !== "string" || c.reason.trim().length < 20) {
112
+ err(name, `ethicsContract is notApplicable but gives no reason (20+ characters) a reviewer can check`);
113
+ }
114
+ continue;
115
+ }
98
116
  withContract++;
99
117
 
100
118
  if (c.darkPatternRisk !== undefined && !RISK.has(c.darkPatternRisk)) {
@@ -118,7 +136,7 @@ for (const name of names) {
118
136
  }
119
137
 
120
138
  console.log(
121
- `\nlint-ethics-contract: ${names.length} components · ${required} data-entry primitives detected · ${withContract} declare an ethicsContract · ${collecting} collect data`,
139
+ `\nlint-ethics-contract: ${names.length} components · ${required} data-entry primitives detected · ${withContract} declare an ethicsContract · ${notApplicable} declare it not applicable · ${collecting} collect data`,
122
140
  );
123
141
  console.log(
124
142
  errors === 0
@@ -79,7 +79,11 @@ mkdirSync(SCREENS_DIR, { recursive: true });
79
79
  function chromiumExecutable() {
80
80
  if (process.env.PW_CHROMIUM && existsSync(process.env.PW_CHROMIUM)) return process.env.PW_CHROMIUM;
81
81
  for (const c of [
82
+ "/opt/pw-browsers/chromium_headless_shell-1243/chrome-headless-shell-linux64/chrome-headless-shell.real",
83
+ "/opt/pw-browsers/chromium_headless_shell-1243/chrome-headless-shell-linux64/chrome-headless-shell",
84
+ "/opt/pw-browsers/chromium-1243/chrome-linux64/chrome",
82
85
  "/opt/pw-browsers/chromium-1194/chrome-linux/chrome",
86
+ "/opt/pw-browsers/chromium/chrome-linux64/chrome",
83
87
  "/opt/pw-browsers/chromium/chrome-linux/chrome",
84
88
  ]) if (existsSync(c)) return c;
85
89
  return undefined;
@@ -102,7 +106,7 @@ const exe = chromiumExecutable();
102
106
  const browser = await chromium.launch(exe ? { executablePath: exe } : {});
103
107
 
104
108
  async function openPage(theme, opts = {}) {
105
- const ctx = await browser.newContext({ viewport: { width: 1280, height: 1400 }, deviceScaleFactor: 2, ...opts });
109
+ const ctx = await browser.newContext({ viewport: { width: 1280, height: 1400 }, deviceScaleFactor: 2, reducedMotion: "reduce", ...opts });
106
110
  const page = await ctx.newPage();
107
111
  // Track subresources that never arrived. A missing image does not throw; it
108
112
  // degrades into whatever is painted underneath, and no contrast gate can