@reqvire-org/ads 0.3.53 → 0.4.2

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 (401) hide show
  1. package/README.md +114 -94
  2. package/dist/a11y.mjs +108 -29
  3. package/dist/analysis/compiler-options.mjs +13 -0
  4. package/dist/analysis/context.mjs +46 -0
  5. package/dist/analysis/file-tree.mjs +52 -0
  6. package/dist/analysis/helpers.mjs +140 -0
  7. package/dist/analysis/impact.mjs +20 -0
  8. package/dist/analysis/inputs.mjs +15 -0
  9. package/dist/analysis/native-adapter.mjs +180 -0
  10. package/dist/analysis/native-project.mjs +323 -0
  11. package/dist/analysis/queries.mjs +133 -0
  12. package/dist/analysis/service.mjs +146 -0
  13. package/dist/analysis/standalone.mjs +57 -0
  14. package/dist/analysis/syntax.mjs +164 -0
  15. package/dist/analysis/worker.mjs +182 -0
  16. package/dist/assets.mjs +6 -6
  17. package/dist/atomic-composition.mjs +191 -70
  18. package/dist/atomic-trace.mjs +120 -50
  19. package/dist/behavior-libraries.mjs +106 -37
  20. package/dist/behaviors.mjs +222 -79
  21. package/dist/boundaries.mjs +137 -40
  22. package/dist/brand-assets.mjs +219 -47
  23. package/dist/brands.mjs +86 -27
  24. package/dist/bun-compiler.mjs +34 -13
  25. package/dist/bun-worker.mjs +7 -5
  26. package/dist/capture/worker.mjs +15 -4
  27. package/dist/capture-store.mjs +4 -2
  28. package/dist/capture.mjs +17 -14
  29. package/dist/check-service.mjs +66 -0
  30. package/dist/check.mjs +756 -196
  31. package/dist/cli.mjs +203 -100
  32. package/dist/color-values.mjs +21 -21
  33. package/dist/component-contrast.mjs +2 -2
  34. package/dist/config.mjs +308 -163
  35. package/dist/construction-styles.cjs +10 -0
  36. package/dist/contracts.d.mts +9 -0
  37. package/dist/control-padding.mjs +45 -25
  38. package/dist/css-values.mjs +3 -2
  39. package/dist/declarative-flow.mjs +209 -109
  40. package/dist/design-values.mjs +136 -51
  41. package/dist/development-runtime.mjs +4 -6
  42. package/dist/draft-boundary.mjs +11 -6
  43. package/dist/evidence.mjs +1 -1
  44. package/dist/finding-rules.mjs +7 -5
  45. package/dist/font-rules.mjs +2 -2
  46. package/dist/fonts-generated.mjs +4 -2
  47. package/dist/foundation-views.mjs +238 -0
  48. package/dist/foundation.mjs +63 -39
  49. package/dist/generated-entries.mjs +198 -0
  50. package/dist/icons.mjs +80 -33
  51. package/dist/image-attributes.mjs +109 -36
  52. package/dist/image-size.mjs +1 -1
  53. package/dist/index.mjs +0 -2
  54. package/dist/init.mjs +128 -68
  55. package/dist/investigations.mjs +2 -2
  56. package/dist/layers.mjs +300 -127
  57. package/dist/layout-widths.mjs +180 -85
  58. package/dist/linaria/preserve-values.cjs +7 -0
  59. package/dist/linaria/spatial-inputs.cjs +56 -0
  60. package/dist/lockup-composition.mjs +44 -0
  61. package/dist/lockup-model.cjs +64 -0
  62. package/dist/mcp/THIRD_PARTY_NOTICES.md +51 -1
  63. package/dist/mcp/apps.mjs +4 -30
  64. package/dist/mcp/behavior-pages.mjs +72 -24
  65. package/dist/mcp/build-status.mjs +257 -64
  66. package/dist/mcp/catalog.mjs +91 -26
  67. package/dist/mcp/context.mjs +17 -18
  68. package/dist/mcp/draft-discovery.mjs +44 -21
  69. package/dist/mcp/drafts.mjs +978 -343
  70. package/dist/mcp/execution-coordinator.mjs +417 -167
  71. package/dist/mcp/execution-results.mjs +7 -7
  72. package/dist/mcp/mutations.mjs +701 -219
  73. package/dist/mcp/preview-watch.mjs +465 -161
  74. package/dist/mcp/preview-widget.bundle.js +44 -50
  75. package/dist/mcp/prompts.mjs +6 -6
  76. package/dist/mcp/result-pages.mjs +1 -1
  77. package/dist/mcp/sandbox-host.mjs +1 -1
  78. package/dist/mcp/server.mjs +2436 -570
  79. package/dist/mcp/showcase-host.mjs +176 -39
  80. package/dist/mcp/skills.mjs +1 -1
  81. package/dist/mcp/text-diff.mjs +29 -10
  82. package/dist/paint-contracts.mjs +174 -81
  83. package/dist/palette-generated.mjs +2 -2
  84. package/dist/preview-bun.mjs +493 -187
  85. package/dist/preview-failure.mjs +1 -1
  86. package/dist/preview-files.mjs +13 -13
  87. package/dist/preview-imports.mjs +104 -55
  88. package/dist/preview-inputs.mjs +2 -2
  89. package/dist/preview-requests.mjs +24 -0
  90. package/dist/preview-resources.mjs +288 -147
  91. package/dist/preview-scope.mjs +5 -4
  92. package/dist/program-cache.mjs +10 -0
  93. package/dist/project-documents.mjs +1 -1
  94. package/dist/public-api.mjs +70 -31
  95. package/dist/public-props.mjs +39 -22
  96. package/dist/{browser-audit → render-audit}/axe-run.mjs +3 -3
  97. package/dist/{browser-audit → render-audit}/image-shape.mjs +2 -2
  98. package/dist/{browser-audit → render-audit}/layout-overflow.mjs +86 -23
  99. package/dist/{browser-audit → render-audit}/non-text-contrast.mjs +86 -27
  100. package/dist/{browser-audit → render-audit}/render-states.mjs +208 -52
  101. package/dist/{browser-audit → render-audit}/worker.mjs +86 -30
  102. package/dist/render-audit.mjs +828 -0
  103. package/dist/render-color-probe.mjs +96 -42
  104. package/dist/resource-limits.mjs +229 -97
  105. package/dist/runtime-contracts.mjs +467 -185
  106. package/dist/scenario-groups.mjs +22 -10
  107. package/dist/scenario-inspector.mjs +6 -43
  108. package/dist/scenario-program.mjs +8 -25
  109. package/dist/scenario-registry.mjs +72 -30
  110. package/dist/scenario-selectors.mjs +161 -64
  111. package/dist/scenario-slots.mjs +149 -56
  112. package/dist/scenario-trace.mjs +215 -109
  113. package/dist/scenarios-compiler.mjs +768 -359
  114. package/dist/scenarios-vite.d.mts +1 -3
  115. package/dist/scenarios-vite.mjs +2 -81
  116. package/dist/scenarios.mjs +424 -159
  117. package/dist/selector-match.mjs +2 -2
  118. package/dist/showcase/client.bundle.js +57 -56
  119. package/dist/showcase/draft-navigation.js +18 -0
  120. package/dist/showcase/favicon.ico +0 -0
  121. package/dist/showcase/favicon.svg +1 -0
  122. package/dist/showcase/foundation-view.css +55 -0
  123. package/dist/showcase/foundation-view.mjs +252 -0
  124. package/dist/showcase/guide-controls.ads.review.mjs +32 -0
  125. package/dist/showcase/icons.js +1 -145
  126. package/dist/showcase/index.html +3 -31
  127. package/dist/showcase/preview-frame.ads.review.css +46 -0
  128. package/dist/showcase/preview-frame.ads.review.d.mts +11 -0
  129. package/dist/showcase/preview-frame.ads.review.mjs +22 -0
  130. package/dist/showcase/preview-state.js +0 -9
  131. package/dist/showcase/refresh-scheduler.js +23 -0
  132. package/dist/showcase/style.css +5 -47
  133. package/dist/showcase/ui/ui.css +1353 -0
  134. package/dist/showcase/ui/ui.js +1062 -0
  135. package/dist/showcase-coverage.mjs +58 -37
  136. package/dist/skills/README.md +24 -23
  137. package/dist/skills/ads-designer/README.md +8 -2
  138. package/dist/skills/ads-designer/SKILL.md +152 -144
  139. package/dist/skills/ads-designer/references/accessibility.md +14 -11
  140. package/dist/skills/ads-designer/references/atomic-styles.md +4 -4
  141. package/dist/skills/ads-designer/references/behaviors.md +34 -30
  142. package/dist/skills/ads-designer/references/branding.md +98 -10
  143. package/dist/skills/ads-designer/references/captures.md +31 -31
  144. package/dist/skills/ads-designer/references/cli.md +21 -20
  145. package/dist/skills/ads-designer/references/contracts.md +63 -29
  146. package/dist/skills/ads-designer/references/design-data.md +49 -52
  147. package/dist/skills/ads-designer/references/drafts.md +71 -52
  148. package/dist/skills/ads-designer/references/evidence.md +1 -5
  149. package/dist/skills/ads-designer/references/guarded-editing.md +58 -51
  150. package/dist/skills/ads-designer/references/layers.md +1 -1
  151. package/dist/skills/ads-designer/references/layout.md +347 -0
  152. package/dist/skills/ads-designer/references/mobile.md +2 -1
  153. package/dist/skills/{ads-motion/references/performance.md → ads-designer/references/motion-performance.md} +5 -1
  154. package/dist/skills/{ads-motion/references/build.md → ads-designer/references/motion.md} +73 -5
  155. package/dist/skills/ads-designer/references/performance.md +3 -2
  156. package/dist/skills/ads-designer/references/review.md +42 -38
  157. package/dist/skills/ads-designer/references/runtimes.md +33 -30
  158. package/dist/skills/ads-designer/references/scenarios.md +17 -19
  159. package/dist/skills/{ads-break-ui/references/catalog.md → ads-designer/references/stress-catalog.md} +3 -1
  160. package/dist/skills/ads-designer/references/stress-test.md +68 -0
  161. package/dist/skills/ads-designer/references/validation.md +83 -71
  162. package/dist/skills/ads-designer/references/workflows.md +19 -37
  163. package/dist/skills/ads-import/SKILL.md +43 -328
  164. package/dist/skills/ads-import/references/atomic-styles.md +4 -4
  165. package/dist/skills/ads-import/references/behaviors.md +34 -30
  166. package/dist/skills/ads-import/references/branding.md +5 -5
  167. package/dist/skills/ads-import/references/captures.md +31 -31
  168. package/dist/skills/ads-import/references/cli.md +21 -20
  169. package/dist/skills/ads-import/references/compatibility.md +1 -1
  170. package/dist/skills/ads-import/references/contracts.md +63 -29
  171. package/dist/skills/ads-import/references/design-data.md +49 -52
  172. package/dist/skills/ads-import/references/drafts.md +71 -52
  173. package/dist/skills/ads-import/references/evidence.md +1 -5
  174. package/dist/skills/ads-import/references/guarded-editing.md +58 -51
  175. package/dist/skills/ads-import/references/implementation.md +2 -1
  176. package/dist/skills/ads-import/references/layers.md +1 -1
  177. package/dist/skills/ads-import/references/layout.md +347 -0
  178. package/dist/skills/ads-import/references/review.md +42 -38
  179. package/dist/skills/ads-import/references/runtimes.md +33 -30
  180. package/dist/skills/ads-import/references/scenarios.md +17 -19
  181. package/dist/skills/ads-import/references/tokens.md +3 -3
  182. package/dist/skills/ads-import/references/validation.md +83 -71
  183. package/dist/skills/ads-import/references/workflows.md +19 -37
  184. package/dist/skills/ads-migrate/SKILL.md +56 -0
  185. package/dist/skills/ads-migrate/references/0.4.1-to-0.4.2.md +602 -0
  186. package/dist/skills/ads-port/SKILL.md +54 -346
  187. package/dist/skills/ads-port/references/atomic-styles.md +4 -4
  188. package/dist/skills/ads-port/references/behaviors.md +34 -30
  189. package/dist/skills/ads-port/references/captures.md +31 -31
  190. package/dist/skills/ads-port/references/cli.md +21 -20
  191. package/dist/skills/ads-port/references/contracts.md +63 -29
  192. package/dist/skills/ads-port/references/design-data.md +49 -52
  193. package/dist/skills/ads-port/references/drafts.md +71 -52
  194. package/dist/skills/ads-port/references/evidence.md +1 -5
  195. package/dist/skills/ads-port/references/guarded-editing.md +58 -51
  196. package/dist/skills/ads-port/references/layers.md +1 -1
  197. package/dist/skills/ads-port/references/layout.md +347 -0
  198. package/dist/skills/ads-port/references/lint-and-docs.md +8 -11
  199. package/dist/skills/ads-port/references/native-implementation.md +8 -7
  200. package/dist/skills/ads-port/references/review.md +42 -38
  201. package/dist/skills/ads-port/references/runtimes.md +33 -30
  202. package/dist/skills/ads-port/references/scenarios.md +17 -19
  203. package/dist/skills/ads-port/references/validation.md +83 -71
  204. package/dist/skills/ads-port/references/workflows.md +19 -37
  205. package/dist/source-symbols.mjs +1 -8
  206. package/dist/source-values.mjs +266 -128
  207. package/dist/spatial-composition.mjs +322 -0
  208. package/dist/spatial-contexts.cjs +56 -0
  209. package/dist/spatial-css.cjs +351 -0
  210. package/dist/spatial-inputs.cjs +80 -0
  211. package/dist/spatial-metadata.mjs +18 -0
  212. package/dist/spatial-model.cjs +322 -0
  213. package/dist/spatial.mjs +21 -0
  214. package/dist/stage-timing.cjs +20 -0
  215. package/dist/starters/preact/design-system/patterns/Conversation/Conversation.tsx +105 -0
  216. package/dist/starters/preact/design-system/patterns/Shell/Shell.tsx +275 -0
  217. package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
  218. package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
  219. package/dist/starters/preact/design-system/showcase/mcp/main.ads.mount.tsx +8 -0
  220. package/dist/starters/preact/ds.config.json +24 -19
  221. package/dist/starters/preact/package.json +4 -8
  222. package/dist/starters/preact/tsconfig.json +4 -5
  223. package/dist/starters/preact/vite.config.ts +3 -3
  224. package/dist/starters/react/ADS.md +42 -47
  225. package/dist/starters/react/README.md +54 -52
  226. package/dist/starters/react/design-system/components/Actions/Button/Button.ads.exports.ts +1 -0
  227. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.exports.ts +1 -0
  228. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +18 -2
  229. package/dist/starters/react/design-system/components/Actions/IconButton/README.md +3 -0
  230. package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.exports.ts +1 -0
  231. package/dist/starters/react/design-system/components/Content/Image/Image.ads.exports.ts +1 -0
  232. package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.exports.ts +1 -0
  233. package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.exports.ts +1 -0
  234. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/README.md +5 -0
  235. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.fixture.ts +13 -0
  236. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.scenario.tsx +22 -0
  237. package/dist/starters/react/design-system/controllers/Palette/Palette.ads.exports.ts +1 -0
  238. package/dist/starters/react/design-system/index.ts +5 -8
  239. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.exports.ts +1 -0
  240. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.fixture.ts +7 -0
  241. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.scenario.tsx +15 -0
  242. package/dist/starters/react/design-system/patterns/Conversation/Conversation.tsx +105 -0
  243. package/dist/starters/react/design-system/patterns/Conversation/README.md +9 -0
  244. package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.exports.ts +1 -0
  245. package/dist/starters/react/design-system/patterns/Shell/Floating.ads.fixture.ts +5 -0
  246. package/dist/starters/react/design-system/patterns/Shell/Floating.ads.scenario.tsx +21 -0
  247. package/dist/starters/react/design-system/patterns/Shell/README.md +43 -0
  248. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.exports.ts +1 -0
  249. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.fixture.ts +5 -0
  250. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.scenario.tsx +21 -0
  251. package/dist/starters/react/design-system/patterns/Shell/Shell.tsx +274 -0
  252. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +1 -0
  253. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
  254. package/dist/starters/react/design-system/review/index.ads.review.ts +4 -0
  255. package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.exports.ts +1 -0
  256. package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.review.tsx +6 -0
  257. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +1 -0
  258. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
  259. package/dist/starters/react/design-system/showcase/mcp/{main.tsx → main.ads.mount.tsx} +4 -2
  260. package/dist/starters/react/design-system/styles.css +1 -0
  261. package/dist/starters/react/design-system/tokens/catalog.ads.json +1221 -0
  262. package/dist/starters/react/design-system/tokens/colors.css +1 -1
  263. package/dist/starters/react/design-system/tokens/spacing.css +22 -32
  264. package/dist/starters/react/design-system/tokens/spatial.ads.json +70 -0
  265. package/dist/starters/react/design-system/tokens/themes.generated.ts +1 -1
  266. package/dist/starters/react/ds.config.json +24 -19
  267. package/dist/starters/react/package.json +2 -6
  268. package/dist/starters/react/tsconfig.json +2 -3
  269. package/dist/starters/react/vite.config.ts +3 -3
  270. package/dist/style-boundaries.mjs +73 -27
  271. package/dist/task-cache.mjs +173 -72
  272. package/dist/task-worker.mjs +22 -11
  273. package/dist/test-boundaries.mjs +133 -60
  274. package/dist/themes-generated.mjs +1 -1
  275. package/dist/themes-watch.mjs +60 -19
  276. package/dist/themes.mjs +176 -73
  277. package/dist/token-export.mjs +39 -14
  278. package/dist/token-policy.mjs +6 -3
  279. package/dist/token-quality.mjs +6 -6
  280. package/dist/token-samples.mjs +16 -5
  281. package/dist/tokens.mjs +71 -26
  282. package/dist/ui-framework.mjs +16 -14
  283. package/dist/unit-contracts.mjs +270 -89
  284. package/dist/units.mjs +215 -180
  285. package/dist/usage.mjs +138 -38
  286. package/dist/validation-checks.mjs +121 -38
  287. package/dist/validation-inputs.mjs +187 -78
  288. package/dist/validation.mjs +268 -102
  289. package/dist/verification/browser.mjs +27 -5
  290. package/dist/verification.mjs +711 -187
  291. package/docs/ADS.md +100 -89
  292. package/docs/ARCHITECTURE.md +353 -159
  293. package/docs/BEHAVIORS.md +33 -28
  294. package/docs/CACHING.md +55 -11
  295. package/docs/CHANGELOG.md +358 -17
  296. package/docs/COMPARISON.md +1 -1
  297. package/docs/CONTRACTS.md +22 -29
  298. package/docs/DESIGN-REFERENCES.md +40 -0
  299. package/docs/GUIDE.md +313 -292
  300. package/docs/MCP.md +261 -439
  301. package/docs/SPATIAL-CHECKS.md +69 -0
  302. package/docs/benchmarks/README.md +39 -0
  303. package/package.json +42 -34
  304. package/dist/browser-audit.mjs +0 -424
  305. package/dist/contract-migration.mjs +0 -110
  306. package/dist/create.mjs +0 -48
  307. package/dist/lint-config.mjs +0 -48
  308. package/dist/mcp/draft-exports.mjs +0 -40
  309. package/dist/mcp/edit-preparation.mjs +0 -115
  310. package/dist/mcp/project-widget.bundle.js +0 -114
  311. package/dist/mcp/reports.mjs +0 -101
  312. package/dist/mcp/widget.bundle.js +0 -147
  313. package/dist/oxlint.mjs +0 -88
  314. package/dist/preview-builder.mjs +0 -133
  315. package/dist/preview-workers.mjs +0 -184
  316. package/dist/showcase.mjs +0 -77
  317. package/dist/skills/ads-break-ui/LICENSE.upstream +0 -21
  318. package/dist/skills/ads-break-ui/README.md +0 -16
  319. package/dist/skills/ads-break-ui/SKILL.md +0 -415
  320. package/dist/skills/ads-break-ui/agents/openai.yaml +0 -4
  321. package/dist/skills/ads-break-ui/references/atomic-styles.md +0 -293
  322. package/dist/skills/ads-break-ui/references/behaviors.md +0 -411
  323. package/dist/skills/ads-break-ui/references/captures.md +0 -160
  324. package/dist/skills/ads-break-ui/references/contracts.md +0 -284
  325. package/dist/skills/ads-break-ui/references/design-data.md +0 -354
  326. package/dist/skills/ads-break-ui/references/drafts.md +0 -178
  327. package/dist/skills/ads-break-ui/references/evidence.md +0 -128
  328. package/dist/skills/ads-break-ui/references/guarded-editing.md +0 -154
  329. package/dist/skills/ads-break-ui/references/layers.md +0 -145
  330. package/dist/skills/ads-break-ui/references/reporting.md +0 -101
  331. package/dist/skills/ads-break-ui/references/review.md +0 -96
  332. package/dist/skills/ads-break-ui/references/runtimes.md +0 -203
  333. package/dist/skills/ads-break-ui/references/scenarios.md +0 -246
  334. package/dist/skills/ads-break-ui/references/validation.md +0 -162
  335. package/dist/skills/ads-break-ui/references/verification.md +0 -58
  336. package/dist/skills/ads-break-ui/references/workflows.md +0 -83
  337. package/dist/skills/ads-designer/references/reporting.md +0 -101
  338. package/dist/skills/ads-import/references/reporting.md +0 -101
  339. package/dist/skills/ads-motion/LICENSE.upstream +0 -21
  340. package/dist/skills/ads-motion/README.md +0 -22
  341. package/dist/skills/ads-motion/SKILL.md +0 -388
  342. package/dist/skills/ads-motion/agents/openai.yaml +0 -4
  343. package/dist/skills/ads-motion/references/atomic-styles.md +0 -293
  344. package/dist/skills/ads-motion/references/audit.md +0 -44
  345. package/dist/skills/ads-motion/references/behaviors.md +0 -411
  346. package/dist/skills/ads-motion/references/captures.md +0 -160
  347. package/dist/skills/ads-motion/references/contracts.md +0 -284
  348. package/dist/skills/ads-motion/references/design-data.md +0 -354
  349. package/dist/skills/ads-motion/references/drafts.md +0 -178
  350. package/dist/skills/ads-motion/references/evidence.md +0 -128
  351. package/dist/skills/ads-motion/references/guarded-editing.md +0 -154
  352. package/dist/skills/ads-motion/references/layers.md +0 -145
  353. package/dist/skills/ads-motion/references/motion-review.md +0 -35
  354. package/dist/skills/ads-motion/references/reporting.md +0 -101
  355. package/dist/skills/ads-motion/references/review.md +0 -96
  356. package/dist/skills/ads-motion/references/runtimes.md +0 -203
  357. package/dist/skills/ads-motion/references/scenarios.md +0 -246
  358. package/dist/skills/ads-motion/references/validation.md +0 -162
  359. package/dist/skills/ads-motion/references/verification.md +0 -39
  360. package/dist/skills/ads-motion/references/workflows.md +0 -83
  361. package/dist/skills/ads-port/references/reporting.md +0 -101
  362. package/dist/starters/preact/design-system/components/Layout/Grid/Grid.tsx +0 -76
  363. package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.tsx +0 -29
  364. package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
  365. package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +0 -137
  366. package/dist/starters/preact/design-system/showcase/mcp/main.tsx +0 -6
  367. package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +0 -7
  368. package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.scenario.tsx +0 -4
  369. package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +0 -7
  370. package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.scenario.tsx +0 -4
  371. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.fixture.ts +0 -12
  372. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.scenario.tsx +0 -17
  373. package/dist/starters/react/design-system/components/Layout/Grid/Grid.tsx +0 -75
  374. package/dist/starters/react/design-system/components/Layout/Grid/README.md +0 -21
  375. package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +0 -112
  376. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.tsx +0 -29
  377. package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +0 -18
  378. package/dist/starters/react/design-system/review/index.ts +0 -5
  379. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
  380. package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +0 -137
  381. package/dist/starters/react/design-system/showcase/mcp/index.html +0 -1
  382. package/dist/starters/react/design-system/tokens/Color.ads.fixture.ts +0 -124
  383. package/dist/starters/react/design-system/tokens/Color.ads.scenario.tsx +0 -4
  384. package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +0 -39
  385. package/dist/starters/react/design-system/tokens/Layout.ads.scenario.tsx +0 -4
  386. package/dist/starters/react/design-system/tokens/Motion.ads.fixture.ts +0 -18
  387. package/dist/starters/react/design-system/tokens/Motion.ads.scenario.tsx +0 -4
  388. package/dist/starters/react/design-system/tokens/Shape.ads.fixture.ts +0 -30
  389. package/dist/starters/react/design-system/tokens/Shape.ads.scenario.tsx +0 -4
  390. package/dist/starters/react/design-system/tokens/Space.ads.fixture.ts +0 -37
  391. package/dist/starters/react/design-system/tokens/Space.ads.scenario.tsx +0 -4
  392. package/dist/starters/react/design-system/tokens/Type.ads.fixture.ts +0 -29
  393. package/dist/starters/react/design-system/tokens/Type.ads.scenario.tsx +0 -4
  394. package/dist/starters/react/package-lock.json +0 -4707
  395. package/dist/token-fixtures.mjs +0 -30
  396. package/docs/benchmarks/bun-previews.md +0 -91
  397. package/docs/benchmarks/preview-memory.md +0 -147
  398. package/docs/benchmarks/turbo-poc.md +0 -284
  399. package/docs/plans/execution-coordination.md +0 -57
  400. /package/dist/{browser-audit → render-audit}/first-render.mjs +0 -0
  401. /package/dist/{browser-audit → render-audit}/layout-shift.mjs +0 -0
@@ -1,424 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import { createRequire } from "node:module";
3
- import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
4
- import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import { loadConfig } from "./config.mjs";
7
- import { discoverScenarioRegistry } from "./scenario-registry.mjs";
8
- import { executeDevelopmentCommand } from "./verification.mjs";
9
- import { findingSeverity, routeFindings } from "./finding-rules.mjs";
10
- import { inspectScenarios } from "./scenarios.mjs";
11
- import { inspectUnits } from "./units.mjs";
12
- import { globMatcher, smallPartLimitPx } from "./layout-widths.mjs";
13
- import { affectedScenarios } from "./verification.mjs";
14
-
15
- // Browser accessibility audit: axe-core (Deque, MPL-2.0, an unmodified ADS dependency
16
- // injected at run time, never bundled) runs inside each rendered scenario document, once per
17
- // declared brand and theme, followed by ADS's own non-text contrast check (WCAG 1.4.11),
18
- // which axe does not cover, and its layout-overflow check, which resizes the same page. Only the scenario's #root is audited; the preview status chrome is excluded.
19
- // Findings are errors: they fail `ads audit` and the validation and acceptance policies,
20
- // which audit by default (browserAudit: false turns a policy's audit off). Automated rules catch a subset of WCAG failures; passing proves nothing more.
21
-
22
- export const AUDIT_RULE = "a11y-axe";
23
- /** What axe could not decide on its own, such as contrast over a gradient: to check by hand. */
24
- export const INCOMPLETE_RULE = "a11y-incomplete";
25
- /** ADS's own rendered check: WCAG 1.4.11 non-text contrast of control boundaries and icons (axe does not check it). */
26
- export const NON_TEXT_RULE = "a11y-non-text-contrast";
27
- /** ADS's own rendered layout check: horizontal overflow at each of overflowWidths. */
28
- export const OVERFLOW_RULE = "layout-overflow";
29
- export const NARROW_RULE = "layout-overflow-narrow";
30
- /** ADS's own rendered check: a scenario's layout shift above the Core Web Vitals 0.1 threshold. */
31
- export const SHIFT_RULE = "layout-shift";
32
- const shiftLimit = 0.1;
33
- /** WCAG A/AA rule tags. Best-practice and page-level rules (landmarks, one h1) don't fit isolated scenarios. */
34
- export const auditTags = Object.freeze(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"]);
35
- const viewport = { width: 1280, height: 800 };
36
- /** Viewport widths layout-overflow renders every scenario at: phone, tablet and desktop. */
37
- export const overflowWidths = Object.freeze([390, 768, 1280]);
38
- export const auditedKinds = Object.freeze(["components", "patterns", "composition"]);
39
- /** The width layout-overflow also renders scenarios of these kinds at, inside the widest viewport
40
- * and in the first theme, since layout does not follow color: a narrow side pane. A composition is
41
- * a whole screen, and is never hosted in one. */
42
- export const containerWidth = 240;
43
- export const containerKinds = Object.freeze(["components", "patterns"]);
44
- /** Attempts for one render, against a dropped preview connection or a slow preview. */
45
- export const auditAttempts = 3;
46
- /** overlays and controls bound what each render opens and hovers: distinct ones, in document order. */
47
- const limits = { scenarios: 500, nodes: 5, findings: 2000, reportBytes: 8 * 1024 * 1024, pages: 4, overlays: 3, controls: 6, contentQuietMs: 500, contentLimitMs: 5000 };
48
-
49
- /** WCAG success criteria named by axe tags such as wcag143 or wcag1412. */
50
- export function wcagCriteria(tags) {
51
- return [...new Set(tags.map(tag => tag.match(/^wcag(\d)(\d)(\d{1,2})$/)).filter(Boolean).map(([, a, b, c]) => `${a}.${b}.${c}`))];
52
- }
53
-
54
- /** Collapse per-brand, per-theme axe violations into ADS errors: one per scenario, rule and failing element set. */
55
- export function auditFindings(runs, scenarios) {
56
- const files = new Map(scenarios.map(scenario => [scenario.id, scenario.file])), groups = new Map();
57
- const add = (list, value) => { if (value !== undefined && !list.includes(value)) list.push(value); };
58
- for (const run of runs) for (const violation of run.violations) {
59
- const selectors = violation.nodes.map(node => node.selector);
60
- const key = JSON.stringify([run.scenario, violation.id, [...selectors].sort()]);
61
- const group = groups.get(key) ?? { scenario: run.scenario, themes: [], brands: [], violation };
62
- groups.set(key, group); add(group.themes, run.theme); add(group.brands, run.brand);
63
- }
64
- return [...groups.values()].slice(0, limits.findings).map(({ scenario, themes, brands, violation }) => {
65
- const wcag = wcagCriteria(violation.tags), contrast = violation.id === "color-contrast";
66
- const where = violation.nodes.map(node => node.selector).slice(0, 3).join(", ") + (violation.nodeCount > 3 ? ` and ${violation.nodeCount - 3} more` : "");
67
- return {
68
- rule: AUDIT_RULE, severity: findingSeverity(AUDIT_RULE), file: files.get(scenario) ?? scenario, line: 1, column: 1, source: "axe-core",
69
- axeRule: violation.id, impact: violation.impact ?? null, wcag, tags: violation.tags, scenario, themes, ...(brands.length ? { brands } : {}),
70
- nodes: violation.nodes, nodeCount: violation.nodeCount, helpUrl: violation.helpUrl, guidanceUri: "ads://guides/accessibility",
71
- ...(contrast ? { overlaps: "token-contrast" } : {}),
72
- message: `${contrast ? "Rendered contrast (browser audit; token-contrast checks declared token pairs statically): " : ""}axe ${violation.id}${violation.impact ? ` (${violation.impact})` : ""}${wcag.length ? `, WCAG ${wcag.join("/")}` : ""} in ${scenario} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]: ${violation.help}. ${violation.nodeCount} element${violation.nodeCount === 1 ? "" : "s"}: ${where}. ${violation.helpUrl}`,
73
- };
74
- });
75
- }
76
-
77
- /** One info item per scenario, axe rule and element set, across brands and themes. */
78
- export function incompleteFindings(runs, scenarios) {
79
- const files = new Map(scenarios.map(scenario => [scenario.id, scenario.file])), groups = new Map();
80
- const add = (list, value) => { if (value !== undefined && !list.includes(value)) list.push(value); };
81
- for (const run of runs) for (const item of run.incomplete ?? []) {
82
- const key = JSON.stringify([run.scenario, item.id, item.nodes.map(node => node.selector).sort()]);
83
- const group = groups.get(key) ?? { scenario: run.scenario, themes: [], brands: [], item };
84
- groups.set(key, group); add(group.themes, run.theme); add(group.brands, run.brand);
85
- }
86
- return [...groups.values()].slice(0, limits.findings).map(({ scenario, themes, brands, item }) => {
87
- const where = item.nodes.slice(0, 3).map(node => `${node.selector}${node.reason ? ` (${node.reason})` : ""}`).join(", ") + (item.nodeCount > 3 ? ` and ${item.nodeCount - 3} more` : "");
88
- return {
89
- rule: INCOMPLETE_RULE, severity: findingSeverity(INCOMPLETE_RULE), file: files.get(scenario) ?? scenario, line: 1, column: 1, source: "axe-core", axeRule: item.id, impact: item.impact ?? null, scenario, themes, ...(brands.length ? { brands } : {}),
90
- nodes: item.nodes, nodeCount: item.nodeCount, helpUrl: item.helpUrl, guidanceUri: "ads://guides/accessibility",
91
- message: `axe could not decide ${item.id} in ${scenario} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]: check it by hand. ${item.help}. ${item.nodeCount} element${item.nodeCount === 1 ? "" : "s"}: ${where}. ${item.helpUrl}`,
92
- };
93
- });
94
- }
95
-
96
- const nonTextKinds = {
97
- border: { what: count => count === 1 ? "control's border is its only boundary and has" : "controls' borders are their only boundary and have", against: "the background around it", fix: "Give the boundary a border token with 3:1 against the surface it sits on, such as --border-strong, or a background with 3:1 against it." },
98
- icon: { what: count => count === 1 ? "icon-only control's icon has" : "icon-only controls' icons have", against: "its control's background", fix: "Paint the icon with a text or foreground token that has 3:1 against the control's background." },
99
- focus: { what: count => count === 1 ? "control's focus outline has" : "controls' focus outlines have", against: "the background around it", fix: "Paint the focus outline with --border-focus or a token with 3:1 against the surface it sits on." },
100
- };
101
-
102
- /** Collapse per-brand, per-theme non-text contrast issues into ADS errors: one per scenario, kind
103
- * and failing element set, keeping each element's lowest ratio. */
104
- export function nonTextContrastFindings(runs, scenarios) {
105
- const files = new Map(scenarios.map(scenario => [scenario.id, scenario.file])), groups = new Map();
106
- const add = (list, value) => { if (value !== undefined && !list.includes(value)) list.push(value); };
107
- for (const run of runs) for (const kind of Object.keys(nonTextKinds)) {
108
- const issues = (run.nonText?.issues ?? []).filter(issue => issue.kind === kind);
109
- if (!issues.length) continue;
110
- const key = JSON.stringify([run.scenario, kind, issues.map(issue => issue.selector).sort()]);
111
- const group = groups.get(key) ?? { scenario: run.scenario, kind, themes: [], brands: [], nodes: new Map(), nodeCount: 0 };
112
- groups.set(key, group); add(group.themes, run.theme); add(group.brands, run.brand);
113
- group.nodeCount = Math.max(group.nodeCount, run.nonText.counts?.[kind] ?? issues.length);
114
- for (const issue of issues) {
115
- const previous = group.nodes.get(issue.selector);
116
- if (!previous || issue.ratio < previous.ratio) group.nodes.set(issue.selector, { ...issue, theme: run.theme, ...(run.brand ? { brand: run.brand } : {}) });
117
- }
118
- }
119
- return [...groups.values()].slice(0, limits.findings).map(({ scenario, kind, themes, brands, nodes, nodeCount }) => {
120
- const list = [...nodes.values()], ratio = Math.min(...list.map(node => node.ratio));
121
- const where = list.slice(0, 3).map(node => `${node.selector} (${node.ratio.toFixed(2)}:1, ${node.foreground} on ${node.background})`).join(", ") + (nodeCount > 3 ? ` and ${nodeCount - 3} more` : "");
122
- return {
123
- rule: NON_TEXT_RULE, severity: findingSeverity(NON_TEXT_RULE), file: files.get(scenario) ?? scenario, line: 1, column: 1, source: "ads", kind, wcag: ["1.4.11"], scenario, themes, ...(brands.length ? { brands } : {}),
124
- ratio, nodes: list, nodeCount, guidanceUri: "ads://guides/accessibility",
125
- message: `Non-text contrast (WCAG 1.4.11) in ${scenario} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]: ${nodeCount} ${nonTextKinds[kind].what(nodeCount)} less than 3:1 against ${nonTextKinds[kind].against}: ${where}. ${nonTextKinds[kind].fix}`,
126
- };
127
- });
128
- }
129
-
130
- const skipReasons = {
131
- "overlay-did-not-open": "a control with aria-haspopup opened nothing with a dialog, menu or listbox role",
132
- "overlay-trigger-gone": "a trigger left the page before its turn",
133
- "overlay-left-open": "an overlay did not close on Escape, so later triggers could not be reached",
134
- "overlay-timeout": "a trigger could not be clicked in time",
135
- "overlay-detached": "a trigger left the page or was covered while it was being clicked",
136
- "overlay-failed": "opening an overlay failed",
137
- "overlay-cap": "the limit of 3 triggers per render was reached and no other scenario has them",
138
- "control-gone": "a control left the page before its turn",
139
- "control-timeout": "a control could not be hovered in time",
140
- "control-detached": "a control left the page while it was being measured",
141
- "control-failed": "measuring a control failed",
142
- "control-cap": "the limit of 6 controls per render was reached and no other scenario has them",
143
- "content-still-changing": "the page kept changing past 5 s, so what it measured may be mid-change",
144
- "focus-not-reachable": "a control a keyboard cannot reach (aria-hidden, inert, or tabindex -1 outside a roving widget): hover measured, focus not",
145
- };
146
-
147
- const overflowKinds = {
148
- document: { what: "the page scrolls horizontally", fix: "Find the element wider than its container; use fluid widths, min-width: 0 on flex and grid children, and let long text wrap." },
149
- viewport: { what: "content reaches past the viewport", fix: "Make the element fluid (%, fr, a --grid-span-N token in a container query), wrap it, or put it in an overflow-x: auto scroller." },
150
- container: { what: "content reaches past its container", fix: "Make the element fluid (%, fr, min(100%, ...)), wrap it, or put it in an overflow-x: auto scroller. A width that truly stays this wide only fits an overlay: list its owner in layout.fixedWidthUnits." },
151
- clipped: { what: "content is cut off by overflow hidden or clip", fix: "Make the content fit, truncate it with text-overflow: ellipsis, or use overflow-x: auto if it should scroll." },
152
- };
153
-
154
- /** Collapse overflow issues into ADS errors: one per scenario, kind and failing element set, with
155
- * the widths, themes and brands it fails in. */
156
- export function layoutOverflowFindings(runs, scenarios) {
157
- const files = new Map(scenarios.map(scenario => [scenario.id, scenario.file])), groups = new Map();
158
- const add = (list, value) => { if (value !== undefined && !list.includes(value)) list.push(value); };
159
- for (const run of runs) for (const { width, container = false, issues = [], counts = {} } of run.layout ?? []) for (const kind of Object.keys(overflowKinds)) {
160
- const found = issues.filter(issue => issue.kind === kind);
161
- if (!found.length) continue;
162
- const key = JSON.stringify([run.scenario, kind, container, found.map(issue => issue.selector).sort()]);
163
- const group = groups.get(key) ?? { scenario: run.scenario, kind, container, widths: [], themes: [], brands: [], nodes: new Map(), nodeCount: 0 };
164
- groups.set(key, group); add(group.widths, width); add(group.themes, run.theme); add(group.brands, run.brand);
165
- group.nodeCount = Math.max(group.nodeCount, counts[kind] ?? found.length);
166
- for (const issue of found) if (!(group.nodes.get(issue.selector)?.overflow >= issue.overflow)) group.nodes.set(issue.selector, { ...issue, width });
167
- }
168
- return [...groups.values()].slice(0, limits.findings).map(({ scenario, kind, container, widths, themes, brands, nodes, nodeCount }) => {
169
- const list = [...nodes.values()], sorted = [...widths].sort((a, b) => a - b);
170
- const where = list.slice(0, 3).map(node => `${node.selector} (${node.overflow}px at ${node.width}px)`).join(", ") + (nodeCount > 3 ? ` and ${nodeCount - 3} more` : "");
171
- return {
172
- rule: container ? NARROW_RULE : OVERFLOW_RULE, severity: findingSeverity(container ? NARROW_RULE : OVERFLOW_RULE), file: files.get(scenario) ?? scenario, line: 1, column: 1, source: "ads", kind, ...(container ? { container: sorted[0] } : { widths: sorted }), scenario, themes, ...(brands.length ? { brands } : {}),
173
- nodes: list, nodeCount, guidanceUri: "ads://guides/tokens",
174
- message: `Layout overflow in ${scenario} ${container ? `in a ${sorted[0]} px container` : `at ${sorted.join(", ")} px wide`} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]: ${overflowKinds[kind].what}: ${where}. ${overflowKinds[kind].fix}`,
175
- };
176
- });
177
- }
178
-
179
- /** One error per scenario and image rendered at a shape other than the one it declares. */
180
- export function imageShapeFindings(runs, scenarios) {
181
- const files = new Map(scenarios.map(scenario => [scenario.id, scenario.file])), groups = new Map();
182
- const add = (list, value) => { if (value !== undefined && !list.includes(value)) list.push(value); };
183
- for (const run of runs) for (const issue of run.imageShape ?? []) {
184
- const key = JSON.stringify([run.scenario, issue.selector]);
185
- const group = groups.get(key) ?? { scenario: run.scenario, issue, themes: [], brands: [] };
186
- groups.set(key, group); add(group.themes, run.theme); add(group.brands, run.brand);
187
- }
188
- return [...groups.values()].slice(0, limits.findings).map(({ scenario, issue, themes, brands }) => ({
189
- rule: "img-shape", severity: findingSeverity("img-shape"), file: files.get(scenario) ?? scenario, line: 1, column: 1, source: "ads", scenario, themes, ...(brands.length ? { brands } : {}), nodes: [issue], rendered: issue.rendered, declared: issue.declared, guidanceUri: "ads://guides/performance",
190
- message: `Image shape in ${scenario} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]: ${issue.selector} renders at ${issue.rendered} at the ${issue.width} px viewport but declares ${issue.declared}, so it is cropped or stretched. A height attribute beats aspect-ratio: add height: auto. For a deliberate crop in a box of its own, set object-fit and no aspect-ratio.`,
191
- }));
192
- }
193
-
194
- /** What a run measured, and what it skipped and why: per reason, with a few examples. An info finding
195
- * for each reason, and a review item for a render assigned targets that measured none of them. */
196
- export function auditCoverage(runs, capped, scenarios) {
197
- const files = new Map(scenarios.map(scenario => [scenario.id, scenario.file])), reasons = new Map();
198
- const claimedNow = new Set(runs.flatMap(run => run.coverage?.claimed ?? []));
199
- const note = (reason, example) => { const entry = reasons.get(reason) ?? { count: 0, examples: [] }; reasons.set(reason, entry); entry.count++; if (entry.examples.length < limits.nodes) entry.examples.push(example); };
200
- for (const run of runs) for (const { reason, name } of run.coverage?.skipped ?? []) note(reason, { scenario: run.scenario, theme: run.theme, ...(run.brand ? { brand: run.brand } : {}), name });
201
- for (const { claim, reason, ...example } of capped) if (!claimedNow.has(claim)) note(reason, example);
202
- const coverage = { renders: runs.length, overlaysOpened: 0, controlsMeasured: 0, skipped: Object.fromEntries([...reasons].sort(([a], [b]) => a.localeCompare(b))) };
203
- const empty = [];
204
- for (const run of runs) if (run.coverage) {
205
- coverage.overlaysOpened += run.coverage.overlays; coverage.controlsMeasured += run.coverage.controls;
206
- // A trigger that opened nothing is not a failure to measure: that is a skip, and the rest of the render stands.
207
- const failed = run.coverage.skipped.filter(item => /^(?:overlay|control)-(?:gone|timeout|detached|failed)$/.test(item.reason)).length;
208
- if (failed && !run.coverage.overlays && !run.coverage.controls) empty.push(run);
209
- }
210
- const findings = [...reasons].map(([reason, { count, examples }]) => ({
211
- rule: "browser-audit-skipped", severity: findingSeverity("browser-audit-skipped"), file: files.get(examples[0].scenario) ?? examples[0].scenario, line: 1, column: 1, source: "ads", reason, count, examples, guidanceUri: "ads://guides/accessibility",
212
- message: `The audit skipped ${count} target${count === 1 ? "" : "s"}: ${skipReasons[reason] ?? reason}. ${examples.slice(0, 3).map(item => `"${item.name}" in ${item.scenario} [${item.theme}]`).join(", ")}${count > 3 ? ` and ${count - 3} more` : ""}.`,
213
- }));
214
- for (const run of empty) findings.push({ rule: "browser-audit-nothing-measured", severity: findingSeverity("browser-audit-nothing-measured"), file: files.get(run.scenario) ?? run.scenario, line: 1, column: 1, source: "ads", scenario: run.scenario, themes: [run.theme], message: `Nothing the audit tried to open or hover in ${run.scenario} [${run.theme}] could be measured: ${[...new Set(run.coverage.skipped.map(item => item.reason))].join(", ")}.` });
215
- return { coverage, findings };
216
- }
217
-
218
- /** One error per scenario above the threshold, with its worst score, themes, brands and elements. */
219
- export function layoutShiftFindings(runs, scenarios) {
220
- const files = new Map(scenarios.map(scenario => [scenario.id, scenario.file])), groups = new Map();
221
- const add = (list, value) => { if (value !== undefined && !list.includes(value)) list.push(value); };
222
- for (const run of runs) {
223
- if (!(run.layoutShift?.value > shiftLimit)) continue;
224
- const group = groups.get(run.scenario) ?? { scenario: run.scenario, themes: [], brands: [], value: 0, nodes: [] };
225
- groups.set(run.scenario, group); add(group.themes, run.theme); add(group.brands, run.brand);
226
- group.value = Math.max(group.value, run.layoutShift.value);
227
- for (const node of run.layoutShift.nodes) add(group.nodes, node);
228
- }
229
- return [...groups.values()].slice(0, limits.findings).map(({ scenario, themes, brands, value, nodes }) => ({
230
- rule: SHIFT_RULE, severity: findingSeverity(SHIFT_RULE), file: files.get(scenario) ?? scenario, line: 1, column: 1, source: "ads", scenario, value, themes, ...(brands.length ? { brands } : {}), nodes: nodes.slice(0, limits.nodes).map(selector => ({ selector })), guidanceUri: "ads://guides/performance",
231
- message: `Layout shift ${value} in ${scenario} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}], above ${shiftLimit}${nodes.length ? `: ${nodes.slice(0, 3).join(", ")}` : ""}. Give images and media width and height, reserve space for late content, and load the fonts the first text uses early.`,
232
- }));
233
- }
234
-
235
- /**
236
- * UI scenarios a candidate change can affect, for acceptance audits. Changes to configuration,
237
- * foundation, tokens, assets or files outside every unit affect all rendering and select every UI
238
- * scenario; so does a failure to trace imports. Public/review entry re-exports are bookkeeping
239
- * for their own units and do not widen the selection.
240
- */
241
- export function auditScenarioSelection(options, changedFiles) {
242
- const scenarios = inspectScenarios(options).scenarios.filter(scenario => auditedKinds.includes(scenario.kind));
243
- const all = reason => ({ mode: "all", reason, scenarios: scenarios.map(scenario => scenario.id) });
244
- const inventory = inspectUnits(options), entries = [inventory.publicEntry, inventory.reviewEntry];
245
- const traced = changedFiles.filter(file => !entries.includes(inventory.relative(file)));
246
- const shared = traced.find(file => {
247
- const owner = inventory.owner(inventory.relative(file));
248
- return [null, "configuration", "foundation", "tokens"].includes(owner) || owner.startsWith("assets") || !inventory.units.some(unit => unit.id === owner);
249
- });
250
- if (shared) return all(`${shared} is shared configuration, foundation, token, asset or unowned input.`);
251
- try { return { mode: "affected", scenarios: affectedScenarios(options, traced, scenarios) }; }
252
- catch (error) { return all(`Affected scenario selection failed: ${error.message}`); }
253
- }
254
-
255
- /** Policy check entry and routed findings for one audit result. */
256
- export function auditCheck(audit, extra = {}) {
257
- const routed = routeFindings([], audit.findings);
258
- return { routed, check: { name: "browser-accessibility-audit", passed: !routed.diagnostics.length, engine: audit.engine, scenarios: audit.scenarios, themes: audit.themes, ...(audit.brands ? { brands: audit.brands } : {}),
259
- renders: audit.runs, ...(audit.coverage ? { coverage: audit.coverage } : {}), ...(audit.retries ? { retries: audit.retries } : {}), errors: routed.diagnostics.length, reviews: routed.advisories.filter(item => item.severity === "review").length, infos: routed.advisories.filter(item => item.severity === "info").length, elapsedMs: audit.elapsedMs, ...extra } };
260
- }
261
-
262
- function projectPlaywright(root) {
263
- const require = createRequire(path.join(root, "package.json"));
264
- for (const name of ["@playwright/test", "playwright"]) { try { return require.resolve(name); } catch { /* Try the other supported project-installed entry. */ } }
265
- return null;
266
- }
267
-
268
- const installHint = "`npm install -D @playwright/test` and `npx playwright install chromium` (Bun: `bun add -d @playwright/test` and `bunx playwright install chromium`)";
269
-
270
- /** Whether the project can run the audit: project-local Playwright, as for captures. */
271
- export const browserAuditAvailable = root => !!projectPlaywright(path.resolve(root));
272
-
273
- /** Scenarios of an owner in layout.fixedWidthUnits float above the layout, and have no container to fit. */
274
- function floatingScenarios(options, scenarios) {
275
- const globs = options.config.layout.fixedWidthUnits, floating = globMatcher(globs);
276
- if (!globs.length) return new Set();
277
- const inventory = inspectUnits(options);
278
- return new Set(scenarios.filter(scenario => {
279
- const owner = inventory.owner(inventory.relative(scenario.file));
280
- return owner && (floating(owner) || inventory.units.find(unit => unit.id === owner)?.files.some(floating));
281
- }).map(scenario => scenario.id));
282
- }
283
-
284
- const renderKey = ({ scenario, theme, brand }) => JSON.stringify([scenario, theme, brand ?? null]);
285
- const clipCause = text => String(text).replace(/\s+/g, " ").trim().slice(0, 500);
286
-
287
- /** Warm scenarios, separating those that cannot build. A project that fails validation fails
288
- * every scenario the same way, so it stops the audit as it always has; anything else is one
289
- * scenario's trouble (a slow or dropped build) and comes back as its cause. */
290
- async function warmScenariosApart(host, ids, signal) {
291
- const unbuilt = new Map();
292
- const projectWide = error => signal.aborted || error.build?.failure?.scope === "project" || error.build?.failure?.phase === "validation";
293
- try { await host.warmScenarios?.(ids, signal); return unbuilt; }
294
- catch (error) { if (projectWide(error)) throw error; }
295
- for (const id of ids) {
296
- try { await host.warmScenarios?.([id], signal); }
297
- catch (error) { if (projectWide(error)) throw error; unbuilt.set(id, clipCause(error.message)); }
298
- }
299
- return unbuilt;
300
- }
301
-
302
- /** One browser process over the given renders. Its report grows as they finish, so a worker that
303
- * dies keeps what it finished. A browser that is not installed stops the audit. */
304
- async function runAuditWorker({ root, temporary, playwright, settings, apps, signal, claimed }) {
305
- const request = path.join(temporary, "request.json"), report = path.join(temporary, "report.json"), runId = randomUUID();
306
- rmSync(report, { force: true });
307
- writeFileSync(request, JSON.stringify({ schemaVersion: 1, runId, playwright, axe: requireTool.resolve("axe-core/axe.min.js"), settings, viewport, overflowWidths, smallPart: smallPartLimitPx, overlayLimit: limits.overlays, stateLimit: limits.controls, contentQuietMs: limits.contentQuietMs, contentLimitMs: limits.contentLimitMs, claimed, tags: auditTags, nodeLimit: limits.nodes, concurrency: limits.pages, apps, output: temporary }));
308
- const timeoutMs = Math.min(30 * 60 * 1000, settings.timeoutMs + apps.length * Math.min(settings.timeoutMs, 15000));
309
- let cause;
310
- try {
311
- const run = await executeDevelopmentCommand({ command: "runtime", timeoutMs, label: "Accessibility audit" }, [fileURLToPath(new URL("./browser-audit/worker.mjs", import.meta.url)), request], root, {}, signal);
312
- if (run.code !== 0 && /Executable doesn't exist|playwright install/i.test(run.output)) throw Object.assign(new Error(`The browser accessibility audit needs Playwright's ${settings.browser} browser. Install it with \`npx playwright install ${settings.browser}\` (Bun: \`bunx playwright install ${settings.browser}\`), or select an installed Chrome with mcp.capture.channel "chrome".`), { code: "ADS_AUDIT_UNAVAILABLE" });
313
- if (run.code !== 0) cause = `Accessibility audit browser failed (${run.code}): ${clipCause(run.output.slice(-400))}`;
314
- } catch (error) {
315
- if (signal.aborted || error.code === "ADS_AUDIT_UNAVAILABLE") throw error;
316
- cause = clipCause(error.message);
317
- }
318
- if (!existsSync(report) || realpathSync(report) !== report || lstatSync(report).size > limits.reportBytes) return { runs: [], capped: [], cause: cause ?? "Accessibility audit produced no bounded report." };
319
- const value = JSON.parse(readFileSync(report, "utf8"));
320
- if (value.schemaVersion !== 1 || value.runId !== runId || !Array.isArray(value.runs)) return { runs: [], capped: [], cause: cause ?? "Accessibility audit returned the wrong run identity." };
321
- return { runs: value.runs, capped: value.capped ?? [], cause };
322
- }
323
-
324
- /** A scenario that could not be audited is an error naming it and its last cause, never a pass. */
325
- function unauditedFindings(renders, scenarios) {
326
- const files = new Map(scenarios.map(scenario => [scenario.id, scenario.file])), groups = new Map();
327
- for (const { app, attempts, causes } of renders) {
328
- const group = groups.get(app.scenario) ?? { scenario: app.scenario, themes: [], brands: [], attempts, cause: "" };
329
- groups.set(app.scenario, group);
330
- if (!group.themes.includes(app.theme)) group.themes.push(app.theme);
331
- if (app.brand && !group.brands.includes(app.brand)) group.brands.push(app.brand);
332
- group.cause = causes.at(-1) ?? group.cause;
333
- }
334
- return [...groups.values()].map(({ scenario, themes, brands, attempts, cause }) => ({
335
- rule: "browser-audit", severity: findingSeverity("browser-audit"), file: files.get(scenario) ?? scenario, line: 1, column: 1, source: "ads", scenario, themes, ...(brands.length ? { brands } : {}), attempts, cause, guidanceUri: "ads://guides/accessibility",
336
- message: `Could not audit ${scenario} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}] in ${attempts} attempt${attempts === 1 ? "" : "s"}: ${cause}`,
337
- }));
338
- }
339
-
340
- /**
341
- * Render every selected scenario in every declared brand and theme and run axe-core on it.
342
- * Without declared brands it renders the single default brand.
343
- * Reuses a showcase-serving preview host when given one; otherwise starts and closes its own.
344
- * A render that fails is retried on its own, up to auditAttempts, and the rest keep their results.
345
- * Findings never cause a retry; a retried pass is listed in retries.
346
- */
347
- export async function runBrowserAudit(root, { scenarios: selected, themes: selectedThemes, brands: selectedBrands, previewHost, signal = new AbortController().signal, onProgress } = {}) {
348
- root = path.resolve(root);
349
- const startedAt = Date.now(), options = loadConfig(root);
350
- const playwright = projectPlaywright(root);
351
- if (!playwright) throw Object.assign(new Error(`The browser accessibility audit needs Playwright in the project. Install it with ${installHint}, or set browserAudit to false in the acceptance and validation policies of ds.config.json.`), { code: "ADS_AUDIT_UNAVAILABLE" });
352
- const registry = discoverScenarioRegistry(options);
353
- if (registry.diagnostics.length) throw new Error(`Scenario registration failed: ${registry.diagnostics[0].message}`);
354
- const unknown = (selected ?? []).filter(id => !registry.scenarios.some(scenario => scenario.id === id));
355
- if (unknown.length) throw new Error(`Unknown scenario ${unknown[0]}. Discover exact IDs with ads_scenarios.`);
356
- // Token and brand scenarios display raw values (token-contrast reviews those pairs); UI scenarios are audited.
357
- // An explicit selection may still name one.
358
- const scenarios = registry.scenarios.filter(scenario => selected?.length ? selected.includes(scenario.id) : auditedKinds.includes(scenario.kind)).slice(0, limits.scenarios);
359
- const themes = options.config.themes.filter(theme => !selectedThemes?.length || selectedThemes.includes(theme.name));
360
- if (selectedThemes?.length && themes.length !== new Set(selectedThemes).size) throw new Error(`Unknown theme; the project declares ${options.config.themes.map(theme => theme.name).join(", ")}.`);
361
- const declaredBrands = options.config.brands ?? [];
362
- if (selectedBrands?.length && !declaredBrands.length) throw new Error("Unknown brand; the project declares no brands.");
363
- const brands = declaredBrands.filter(brand => !selectedBrands?.length || selectedBrands.includes(brand.name));
364
- if (selectedBrands?.length && brands.length !== new Set(selectedBrands).size) throw new Error(`Unknown brand; the project declares ${declaredBrands.map(brand => brand.name).join(", ")}.`);
365
- const summary = { scenarios: scenarios.length, themes: themes.map(theme => theme.name), ...(brands.length ? { brands: brands.map(brand => brand.name) } : {}), tags: auditTags, engine: `axe-core ${axeVersion()}` };
366
- if (!scenarios.length) return { ...summary, runs: 0, findings: [], elapsedMs: Date.now() - startedAt };
367
- const outputRoot = path.join(root, ".ds");
368
- mkdirSync(outputRoot, { recursive: true });
369
- if (realpathSync(outputRoot) !== outputRoot) throw new Error("Audit work output cannot resolve through a symlink.");
370
- const temporary = mkdtempSync(path.join(outputRoot, "audit-work-"));
371
- let host = previewHost;
372
- try {
373
- onProgress?.({ stage: "browser-audit", message: `Accessibility audit: building ${scenarios.length} scenario previews.`, elapsedMs: Date.now() - startedAt });
374
- const startHost = async () => { const { startAdsMcp } = await import("./mcp/server.mjs"); return startAdsMcp(root, { stdio: false, showcase: true, despitePolicy: true }); };
375
- if (!host?.url) host = await startHost();
376
- const settings = { browser: "chromium", timeoutMs: 60000, ...options.config.mcp.capture };
377
- const floating = floatingScenarios(options, scenarios);
378
- const wanted = themes.flatMap(theme => (brands.length ? brands : [undefined]).flatMap(brand => scenarios.map(scenario => ({ scenario: scenario.id, theme: theme.name, ...(brand ? { brand: brand.name } : {}), scheme: theme.scheme, ...(theme === themes[0] && containerKinds.includes(scenario.kind) && !floating.has(scenario.id) ? { container: containerWidth } : {}) }))));
379
- const renders = new Map(wanted.map(app => [renderKey(app), { app, attempts: 0, causes: [] }])), capped = new Map();
380
- onProgress?.({ stage: "browser-audit", message: `Accessibility audit: ${wanted.length} renders (${scenarios.length} scenarios × ${themes.length} themes${brands.length ? ` × ${brands.length} brands` : ""}).`, elapsedMs: Date.now() - startedAt });
381
- for (let attempt = 1; attempt <= auditAttempts; attempt++) {
382
- const pending = [...renders.values()].filter(render => !render.result);
383
- if (!pending.length) break;
384
- signal.throwIfAborted();
385
- for (const render of pending) render.attempts = attempt;
386
- if (!host) {
387
- try { host = await startHost(); }
388
- catch (error) { if (signal.aborted) throw error; for (const render of pending) render.causes.push(clipCause(error.message)); continue; }
389
- }
390
- const unbuilt = await warmScenariosApart(host, [...new Set(pending.map(render => render.app.scenario))], signal);
391
- for (const render of pending) if (unbuilt.has(render.app.scenario)) render.causes.push(unbuilt.get(render.app.scenario));
392
- const apps = pending.filter(render => !unbuilt.has(render.app.scenario)).map(({ app }) => {
393
- const url = new URL(host.url); url.searchParams.set("scenario", app.scenario); url.searchParams.set("capture", "1"); url.searchParams.set("theme", app.theme);
394
- if (app.brand) url.searchParams.set("brand", app.brand);
395
- return { ...app, url: url.href };
396
- });
397
- const reached = apps.length ? await runAuditWorker({ root, temporary, playwright, settings, apps, signal, claimed: [...renders.values()].flatMap(render => render.result?.coverage?.claimed ?? []) }) : { runs: [], capped: [] };
398
- for (const item of reached.capped ?? []) capped.set(item.claim, item);
399
- for (const run of reached.runs) {
400
- const render = renders.get(renderKey(run));
401
- if (!render) continue;
402
- if (run.failed) { render.causes.push(run.cause); if (run.violations) render.partial = run; }
403
- else render.result = run;
404
- }
405
- for (const { app } of pending.filter(render => !render.result && apps.some(app => renderKey(app) === renderKey(render.app)) && !reached.runs.some(run => renderKey(run) === renderKey(render.app)))) renders.get(renderKey(app)).causes.push(reached.cause ?? "The audit browser stopped before this render.");
406
- // The next attempt gets a new browser and, when this audit owns it, a new preview host.
407
- if (attempt < auditAttempts && host !== previewHost && [...renders.values()].some(render => !render.result)) {
408
- const previous = host; host = undefined;
409
- await previous.close().catch(() => {});
410
- }
411
- }
412
- const all = [...renders.values()], runs = all.map(render => render.result ?? render.partial).filter(Boolean);
413
- const retries = all.filter(render => render.result && render.attempts > 1).map(({ app, attempts, causes }) => ({ scenario: app.scenario, theme: app.theme, ...(app.brand ? { brand: app.brand } : {}), attempts, causes }));
414
- const { coverage, findings: coverageItems } = auditCoverage(all.map(render => render.result).filter(Boolean), [...capped.values()], scenarios);
415
- const findings = [...coverageItems, ...auditFindings(runs, scenarios), ...nonTextContrastFindings(runs, scenarios), ...layoutOverflowFindings(runs, scenarios), ...layoutShiftFindings(runs, scenarios), ...imageShapeFindings(runs, scenarios), ...unauditedFindings(all.filter(render => !render.result), scenarios), ...incompleteFindings(runs, scenarios)];
416
- const shifts = runs.filter(run => run.layoutShift).sort((a, b) => b.layoutShift.value - a.layoutShift.value);
417
- return { ...summary, ...(shifts.length ? { worstLayoutShift: { value: shifts[0].layoutShift.value, scenario: shifts[0].scenario } } : {}), runs: all.filter(render => render.result).length, incomplete: findings.filter(finding => finding.rule === INCOMPLETE_RULE).length, overlaysOpened: coverage.overlaysOpened, controlsMeasured: coverage.controlsMeasured, coverage, findings, ...(retries.length ? { retries } : {}), elapsedMs: Date.now() - startedAt };
418
- } finally {
419
- try { if (host !== previewHost) await host?.close(); } finally { rmSync(temporary, { recursive: true, force: true }); }
420
- }
421
- }
422
-
423
- const requireTool = createRequire(import.meta.url);
424
- function axeVersion() { return JSON.parse(readFileSync(requireTool.resolve("axe-core/package.json"), "utf8")).version; }
@@ -1,110 +0,0 @@
1
- import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
2
- import path from "node:path";
3
- import ts from "typescript";
4
- import { adsFileRole, isBehaviorFile, isScenarioFile, loadConfig, scenarioIdentity } from "./config.mjs";
5
- import { inspectUnitContracts } from "./unit-contracts.mjs";
6
- import { publicApi } from "./public-api.mjs";
7
- import { projectCompilerOptions } from "./boundaries.mjs";
8
-
9
- const slash=value=>value.replaceAll("\\","/");
10
-
11
- /** Mechanical edits in an ordinary owner draft. Never writes live source. */
12
- export function migrateContractDraft(options, prepared) {
13
- const base=prepared.directory, name=path.posix.basename(prepared.unit), renames=new Map(), notes=[];
14
- const relative=file=>slash(path.relative(base,file));
15
- const resolve=file=>path.join(base,file);
16
- const files=prepared.files.filter(file=>!file.endsWith("ds.config.json")&&file.startsWith(options.config.dsDir+"/"));
17
- const owned=files.filter(file=>!file.endsWith("/"+options.config.publicEntry)&&!file.endsWith("/"+options.config.reviewEntry));
18
- for(const file of owned) {
19
- if(adsFileRole(file)||!/\.[cm]?[jt]sx?$/.test(file))continue;
20
- let next;
21
- if(isScenarioFile(file))next=path.basename(file).startsWith("Scenario.")?path.join(path.dirname(file),`${name}.ads.scenario${path.extname(file)}`):file.replace(/\.scenario\./,".ads.scenario.");
22
- else if(/(?:^|\/)fixture\.[cm]?[jt]sx?$/.test(file))next=path.join(path.dirname(file),`${name}.ads.fixture${path.extname(file)}`);
23
- else if(/\.(?:fixture|fixtures|test|spec)\.[cm]?[jt]sx?$/.test(file))next=file.replace(/\.(behavior\.spec|fixture|fixtures|test|spec)(\.[^.]+)$/,".ads.$1$2");
24
- else if(/\.scenario-adapter\.[cm]?[jt]sx?$/.test(file))next=file.replace(/\.scenario-adapter\./,".ads.helpers.");
25
- if(next&&next!==file) {
26
- next=slash(next);
27
- if(isScenarioFile(file)&&scenarioIdentity(path.join(options.root,file),options.dsRoot)===prepared.unit&&scenarioIdentity(path.join(options.root,next),options.dsRoot)!==prepared.unit){notes.push(`Kept ${file}: a default-directory rename would change this flat owner's identity. Review a deliberate owner migration separately.`);continue;}
28
- if([...renames.values()].includes(next)&&isScenarioFile(file))next=next.replace(".ads.scenario.",".named.ads.scenario.");
29
- if(existsSync(resolve(next)))throw new Error(`Migration would overwrite ${next}; resolve the naming conflict in this draft.`);
30
- renames.set(file,next);
31
- }
32
- }
33
- for(const file of owned.filter(isScenarioFile)) {
34
- const fixtureBase=path.basename(file).startsWith("Scenario.")?path.join(path.dirname(file),"fixture"):file.replace(/\.scenario\.[^.]+$/,".fixture");
35
- const fixture=owned.find(candidate=>candidate.startsWith(fixtureBase+".")&&/\.(?:[cm]?[jt]sx?|json)$/.test(candidate));
36
- if(!fixture)continue;
37
- const scenario=renames.get(file);
38
- if(scenario)renames.set(fixture,scenario.replace(/\.scenario\.[^.]+$/,".fixture")+path.extname(fixture));
39
- else renames.delete(fixture);
40
- }
41
- if(new Set(renames.values()).size!==renames.size)throw new Error("Migration has colliding development filenames; resolve the owner draft deliberately.");
42
- const jsonFiles=owned.filter(isBehaviorFile);
43
- for(const [from,to]of renames)if(isScenarioFile(from)&&scenarioIdentity(path.join(options.root,from),options.dsRoot)!==scenarioIdentity(path.join(options.root,to),options.dsRoot)) {
44
- const text=readFileSync(resolve(from),"utf8"),source=ts.createSourceFile(from,text,ts.ScriptTarget.Latest,true,ts.ScriptKind.TSX);
45
- const declaration=source.statements.filter(ts.isVariableStatement).flatMap(statement=>statement.declarationList.declarations).find(declaration=>ts.isIdentifier(declaration.name)&&declaration.name.text==="scenario");
46
- let expression=declaration?.initializer;while(expression&&(ts.isAsExpression(expression)||ts.isSatisfiesExpression(expression)||ts.isParenthesizedExpression(expression)))expression=expression.expression;
47
- if(expression&&ts.isObjectLiteralExpression(expression)) {
48
- if(!expression.properties.some(property=>property.name?.getText()==="id")){const at=expression.getStart()+1;writeFileSync(resolve(from),text.slice(0,at)+`id:${JSON.stringify(scenarioIdentity(path.join(options.root,from),options.dsRoot))},`+text.slice(at));}
49
- }else {renames.delete(from);notes.push(`Kept ${from}: its indirect metadata needs an explicit stable id before this rename.`);}
50
- }
51
- const runtime=owned.find(file=>!adsFileRole(file)&&!isScenarioFile(file)&&new RegExp(`(?:^|/)${name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\.[cm]?[jt]sx?$`).test(file));
52
- const directory=runtime?path.dirname(runtime):path.dirname(owned[0]??path.join(options.config.dsDir,prepared.unit,"entry.ts"));
53
- const contractFile=slash(path.join(directory,`${name}.ads.contract.ts`));
54
- const contract={schemaVersion:1},imports=[],references=new Map();
55
- const compiler=ts.createProgram(files.filter(file=>/\.[cm]?[jt]sx?$/.test(file)).map(file=>path.resolve(options.root,file)),{...projectCompilerOptions(options),allowJs:true});
56
- const checker=compiler.getTypeChecker(),apis=publicApi(compiler,options);
57
- function importReference(file,symbol) {
58
- const source=compiler.getSourceFile(path.resolve(options.root,file));
59
- const module=source&&checker.getSymbolAtLocation(source);
60
- const exported=module&&checker.getExportsOfModule(module).find(item=>item.name===symbol);
61
- if(!exported)throw new Error(`${file}#${symbol} is not an importable internal export; keep the legacy section until its owner deliberately exposes a local contract reference.`);
62
- const key=`${file}#${symbol}`;
63
- if(!references.has(key)) {
64
- const alias=`subject${references.size}`;references.set(key,alias);
65
- let specifier=slash(path.relative(path.dirname(contractFile),file)).replace(/\.[cm]?[jt]sx?$/,"");if(!specifier.startsWith("."))specifier="./"+specifier;
66
- imports.push(`import { ${symbol} as ${alias} } from ${JSON.stringify(specifier)};`);
67
- }
68
- return `__ads_reference_${references.get(key)}__`;
69
- }
70
- const remove=[];
71
- if(!existsSync(resolve(contractFile)))for(const file of jsonFiles) {
72
- const value=JSON.parse(readFileSync(resolve(file),"utf8"));
73
- if(isBehaviorFile(file)) {
74
- try {
75
- const subjects={};
76
- for(const [id,subject]of Object.entries(value.subjects??{})) {
77
- if(subject.api) {const api=apis.find(api=>api.name===subject.api);if(!api)throw new Error(`Unknown API ${subject.api}`);subjects[id]={api:importReference(slash(path.relative(options.root,api.file)),api.declaration.name?.text??subject.api)};}
78
- else if(subject.symbol)subjects[id]={implementation:importReference(slash(path.normalize(path.join(path.dirname(file),subject.source))),subject.symbol),...(subject.role!==undefined?{role:subject.role}:{})};
79
- else throw new Error(`Subject ${id} names a whole file. Select an actual implementation symbol before migrating this behavior section.`);
80
- }
81
- const {schemaVersion:_version,...behavior}=value;contract.behavior={...behavior,subjects};remove.push(file);
82
- }catch(error){notes.push(error.message);}
83
- }
84
- }
85
- for(const file of files) {
86
- if(!/\.[cm]?[jt]sx?$|\.json$|\.md$/.test(file)||remove.includes(file))continue;
87
- const original=readFileSync(resolve(file),"utf8");let text=original;
88
- for(const [before,after]of renames) {
89
- let from=slash(path.relative(path.dirname(file),before)),to=slash(path.relative(path.dirname(renames.get(file)??file),after));
90
- if(!from.startsWith("."))from="./"+from;if(!to.startsWith("."))to="./"+to;
91
- for(const [left,right]of [[before,after],[from,to],[from.replace(/\.[cm]?[jt]sx?$/,""),to.replace(/\.[cm]?[jt]sx?$/,"")]]) {
92
- for(const quote of ['"',"'","`"] )text=text.replaceAll(quote+left+quote,quote+right+quote);
93
- if(file.endsWith(".md"))text=text.replaceAll(`](${left})`,`](${right})`);
94
- }
95
- }
96
- if(text!==original)writeFileSync(resolve(file),text);
97
- }
98
- if(remove.length) {
99
- if(contract.behavior)for(const check of Object.values(contract.behavior.checks)) {
100
- const old=slash(path.normalize(path.join(directory,check.file))),next=renames.get(old);
101
- if(next)check.file="./"+slash(path.relative(directory,next));
102
- }
103
- let text=JSON.stringify(contract,null,2);
104
- for(const alias of references.values())text=text.replaceAll(JSON.stringify(`__ads_reference_${alias}__`),alias);
105
- writeFileSync(resolve(contractFile),`import type { UnitContract } from "@reqvire-org/ads/contracts";\n${imports.filter(line=>[...references.values()].some(alias=>line.includes(` as ${alias} `)&&new RegExp(`\\b${alias}\\b`).test(text))).join("\n")}\nexport default ${text} satisfies UnitContract;\n`);
106
- for(const file of remove) {const fsPath=resolve(file);renameSync(fsPath,path.join(base,"..",`migrated-${path.basename(file)}`));}
107
- }else if(inspectUnitContracts(loadConfig(options.root)).contracts.some(contract=>contract.unit===prepared.unit))notes.push("Existing TypeScript contract retained. Only legacy file roles/references were renamed.");
108
- for(const [from,to]of renames)renameSync(resolve(from),resolve(to));
109
- return {...prepared,migration:{renamed:[...renames].map(([from,to])=>({from,to})),converted:remove,contractFile:remove.length?relative(resolve(contractFile)):null,notes},next:"Review the migrated draft and its references, then use action: diff and ads_apply_patch dryRun: true. Live source is unchanged; unresolved sections retain their legacy registration. Migrate one passing owner at a time."};
110
- }
package/dist/create.mjs DELETED
@@ -1,48 +0,0 @@
1
- import { cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { supportedFrameworks } from "./config.mjs";
5
- import { initProject } from "./init.mjs";
6
-
7
- // The starters ship in this package: the React starter, and per framework the files that
8
- // replace it. A created project therefore always matches the tool that checks it.
9
- const starters = fileURLToPath(new URL("./starters/", import.meta.url));
10
-
11
- /** An npm package name from a folder name. */
12
- function packageName(value) {
13
- const name = value.toLowerCase().replace(/[^a-z0-9._~-]+/g, "-").replace(/^[._-]+|[-.]+$/g, "");
14
- return name || "design-system";
15
- }
16
-
17
- /** Creates a new design-system project in `directory` from this version's starter, then
18
- * initializes ADS in it. The directory must be missing or empty. */
19
- export function createProject(directory, { framework, packageManager = "npm", name, toolPackage } = {}) {
20
- if (!supportedFrameworks.includes(framework)) throw new Error("Specify --framework react or --framework preact.");
21
- if (!["npm", "bun"].includes(packageManager)) throw new Error("packageManager must be npm or bun.");
22
- if (name !== undefined && (typeof name !== "string" || !name.trim())) throw new Error("Specify a package name after --name.");
23
- const root = path.resolve(directory);
24
- const stat = lstatSync(root, { throwIfNoEntry: false });
25
- if (stat && (!stat.isDirectory() || stat.isSymbolicLink())) throw new Error(`${root} exists and is not a folder.`);
26
- if (stat && readdirSync(root).length) throw new Error(`${root} is not empty. Create a project in a new or empty folder; run ads init inside an existing app.`);
27
- mkdirSync(root, { recursive: true });
28
- try {
29
- cpSync(path.join(starters, "react"), root, { recursive: true });
30
- // npm drops .gitignore files from packages, so the starter carries a template.
31
- if (existsSync(path.join(root, "gitignore.template"))) renameSync(path.join(root, "gitignore.template"), path.join(root, ".gitignore"));
32
- if (framework !== "react") cpSync(path.join(starters, framework), root, { recursive: true });
33
- const packageFile = path.join(root, "package.json");
34
- const pkg = JSON.parse(readFileSync(packageFile, "utf8"));
35
- pkg.name = name?.trim() ?? packageName(path.basename(root));
36
- // The starter's lockfile is React's npm lock; other frameworks and Bun create their own.
37
- if (framework !== "react" || packageManager === "bun") rmSync(path.join(root, "package-lock.json"), { force: true });
38
- if (packageManager === "bun") for (const [script, command] of Object.entries(pkg.scripts ?? {})) pkg.scripts[script] = command.replaceAll("npm run ", "bun run ");
39
- writeFileSync(packageFile, `${JSON.stringify(pkg, null, 2)}\n`);
40
- const initialized = initProject(root, { framework, packageManager, toolPackage });
41
- return { ...initialized, created: true, name: pkg.name };
42
- } catch (error) {
43
- // A failed creation leaves the folder as it was found.
44
- if (!stat) rmSync(root, { recursive: true, force: true });
45
- else for (const entry of readdirSync(root)) rmSync(path.join(root, entry), { recursive: true, force: true });
46
- throw error;
47
- }
48
- }