@astryxdesign/cli 0.6.5 → 0.6.6-canary.e1dda17

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 (433) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +58 -55
  3. package/api/build/_adapter.d.mts +55 -2
  4. package/api/build/_adapter.mjs +100 -10
  5. package/api/build/build.doc.mjs +2 -2
  6. package/api/build/build.test.mjs +111 -2
  7. package/api/build/build.type.d.mts +8 -0
  8. package/api/build/build.type.mjs +2 -0
  9. package/api/build/kit/kit.mjs +99 -22
  10. package/api/build/kit/rank.d.mts +32 -8
  11. package/api/build/kit/rank.mjs +291 -97
  12. package/api/build/kit/rank.test.mjs +231 -48
  13. package/api/build/kit/weights.d.mts +82 -0
  14. package/api/build/kit/weights.json +1 -0
  15. package/api/build/kit/weights.mjs +305 -0
  16. package/api/build/kit/weights.test.mjs +190 -0
  17. package/api/component/_adapter.d.mts +19 -0
  18. package/api/component/_adapter.mjs +33 -0
  19. package/api/component/component-replacement.test.mjs +603 -0
  20. package/api/component/component.mjs +49 -15
  21. package/api/component/component.test.mjs +32 -0
  22. package/api/component/component.type.d.mts +33 -3
  23. package/api/component/component.type.mjs +10 -3
  24. package/api/component/detail/blocks/blocks.d.mts +2 -1
  25. package/api/component/detail/blocks/blocks.mjs +5 -2
  26. package/api/component/detail/detail.mjs +5 -1
  27. package/api/component/detail/props/props.d.mts +2 -1
  28. package/api/component/detail/props/props.mjs +3 -2
  29. package/api/component/detail/showcase/showcase.d.mts +3 -1
  30. package/api/component/detail/showcase/showcase.mjs +3 -1
  31. package/api/component/detail/source/source.d.mts +3 -2
  32. package/api/component/detail/source/source.mjs +7 -3
  33. package/api/component/list/list.mjs +128 -10
  34. package/api/docs/_adapter.d.mts +11 -0
  35. package/api/docs/_adapter.mjs +25 -0
  36. package/api/docs/detail/detail.mjs +19 -3
  37. package/api/docs/detail/section/section.mjs +7 -1
  38. package/api/docs/docOverlays.test.mjs +10 -6
  39. package/api/docs/docs.d.mts +6 -0
  40. package/api/docs/docs.depth.test.mjs +134 -0
  41. package/api/docs/docs.doc.mjs +31 -2
  42. package/api/docs/docs.mjs +46 -1
  43. package/api/docs/docs.test.mjs +279 -0
  44. package/api/docs/docs.type.d.mts +81 -4
  45. package/api/docs/docs.type.mjs +41 -4
  46. package/api/docs/index/index.mjs +11 -2
  47. package/api/docs/index/index.test.mjs +7 -2
  48. package/api/docs/integration-tree.test.mjs +572 -0
  49. package/api/docs/integrationDocs.test.mjs +337 -0
  50. package/api/docs/node/node.d.mts +28 -3
  51. package/api/docs/node/node.mjs +149 -23
  52. package/api/doctor/_adapter.d.mts +43 -0
  53. package/api/doctor/_adapter.mjs +142 -0
  54. package/api/doctor/doctor.d.mts +0 -10
  55. package/api/doctor/doctor.doc.mjs +1 -3
  56. package/api/doctor/doctor.mjs +6 -123
  57. package/api/doctor/theme-checks.d.mts +12 -0
  58. package/api/doctor/theme-checks.mjs +1117 -0
  59. package/api/doctor/theme-checks.test.mjs +526 -0
  60. package/api/error.d.mts +22 -0
  61. package/api/error.mjs +42 -0
  62. package/api/gap-report/gap-report.d.mts +3 -1
  63. package/api/gap-report/gap-report.mjs +27 -3
  64. package/api/gap-report/gap-report.test.mjs +106 -0
  65. package/api/hook/_adapter.d.mts +1 -0
  66. package/api/hook/_adapter.mjs +3 -0
  67. package/api/hook/detail/detail.mjs +2 -2
  68. package/api/hook/detail/params/params.mjs +2 -2
  69. package/api/hook/hook.type.d.mts +12 -0
  70. package/api/hook/hook.type.mjs +3 -0
  71. package/api/hook/list/list.d.mts +1 -1
  72. package/api/hook/list/list.mjs +8 -8
  73. package/api/index.d.mts +1 -1
  74. package/api/index.mjs +4 -0
  75. package/api/init/run/run.d.mts +3 -5
  76. package/api/init/run/run.mjs +10 -11
  77. package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
  78. package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
  79. package/api/integration/add-contribution.d.mts +2 -1
  80. package/api/integration/add-contribution.mjs +7 -3
  81. package/api/integration/add-contribution.test.mjs +3 -3
  82. package/api/integration/add-helpers.d.mts +26 -5
  83. package/api/integration/add-helpers.mjs +50 -5
  84. package/api/integration/add-theme.mjs +354 -28
  85. package/api/integration/add-theme.test.mjs +380 -16
  86. package/api/integration/authoring-checks.mjs +31 -8
  87. package/api/integration/authoring-checks.type.d.mts +8 -0
  88. package/api/integration/authoring-checks.type.mjs +7 -3
  89. package/api/integration/integration-authoring.type.d.mts +4 -1
  90. package/api/integration/integration-authoring.type.mjs +6 -1
  91. package/api/integration/integrationAdd.doc.mjs +6 -0
  92. package/api/integration/integrationAddTheme.doc.mjs +10 -0
  93. package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
  94. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  95. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
  96. package/api/integration/pack-check.component-replaces.test.mjs +126 -0
  97. package/api/integration/pack-check.d.mts +10 -0
  98. package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
  99. package/api/integration/pack-check.mjs +495 -4
  100. package/api/integration/pack-check.test.mjs +619 -10
  101. package/api/integration/validate-integration.d.mts +4 -2
  102. package/api/integration/validate-integration.mjs +7 -2
  103. package/api/integration/validate-integration.test.mjs +55 -0
  104. package/api/integration/validate-integration.type.d.mts +5 -0
  105. package/api/integration/validate-integration.type.mjs +5 -1
  106. package/api/integration/validateIntegration.doc.mjs +1 -1
  107. package/api/layout/expand/expand.mjs +12 -7
  108. package/api/layout/expand/expand.receipt.test.mjs +74 -0
  109. package/api/layout/layout.type.d.mts +1 -0
  110. package/api/layout/layout.type.mjs +1 -0
  111. package/api/layout/layoutExpand.doc.mjs +1 -1
  112. package/api/search/search.d.mts +39 -8
  113. package/api/search/search.doc.mjs +4 -4
  114. package/api/search/search.mjs +248 -66
  115. package/api/search/search.test.mjs +829 -0
  116. package/api/search/search.type.d.mts +6 -6
  117. package/api/search/search.type.mjs +5 -5
  118. package/api/swizzle/_adapter.d.mts +10 -0
  119. package/api/swizzle/_adapter.mjs +23 -0
  120. package/api/swizzle/copy/copy.d.mts +5 -6
  121. package/api/swizzle/copy/copy.mjs +95 -13
  122. package/api/swizzle/list/list.mjs +2 -2
  123. package/api/swizzle/swizzle.doc.mjs +4 -0
  124. package/api/swizzle/swizzle.test.mjs +55 -5
  125. package/api/swizzle/swizzle.type.d.mts +8 -0
  126. package/api/swizzle/swizzle.type.mjs +2 -0
  127. package/api/template/copy/copy.mjs +15 -8
  128. package/api/template/copy/copy.receipt.test.mjs +77 -0
  129. package/api/template/show/show.mjs +17 -4
  130. package/api/template/show/show.test.mjs +76 -0
  131. package/api/template/skeleton/skeleton.mjs +2 -1
  132. package/api/template/template-integration.test.mjs +14 -0
  133. package/api/template/template.d.mts +1 -1
  134. package/api/template/template.doc.mjs +6 -2
  135. package/api/template/template.mjs +2 -0
  136. package/api/template/template.type.d.mts +14 -0
  137. package/api/template/template.type.mjs +5 -0
  138. package/api/theme/_adapter.d.mts +106 -6
  139. package/api/theme/_adapter.mjs +687 -18
  140. package/api/theme/add/add.binary.test.mjs +76 -3
  141. package/api/theme/add/add.d.mts +5 -9
  142. package/api/theme/add/add.mjs +87 -64
  143. package/api/theme/add/add.rollback.test.mjs +9 -9
  144. package/api/theme/add/add.staging.test.mjs +9 -9
  145. package/api/theme/add/add.test.mjs +461 -55
  146. package/api/theme/add/add.types.test.mjs +151 -0
  147. package/api/theme/build/build.d.mts +50 -2
  148. package/api/theme/build/build.family.test.mjs +13 -4
  149. package/api/theme/build/build.icon-lineage.test.mjs +117 -0
  150. package/api/theme/build/build.icon-preservation.test.mjs +639 -0
  151. package/api/theme/build/build.mjs +463 -155
  152. package/api/theme/build/build.project-core.test.mjs +165 -0
  153. package/api/theme/build/build.test.mjs +220 -1
  154. package/api/theme/build/icon-imports.d.mts +47 -0
  155. package/api/theme/build/icon-imports.mjs +691 -0
  156. package/api/theme/eject/eject.binary.test.mjs +90 -0
  157. package/api/theme/eject/eject.d.mts +17 -0
  158. package/api/theme/eject/eject.mjs +65 -0
  159. package/api/theme/eject/eject.rollback.test.mjs +158 -0
  160. package/api/theme/eject/eject.staging.test.mjs +83 -0
  161. package/api/theme/eject/eject.test.mjs +160 -0
  162. package/api/theme/integration-themes.test.mjs +30 -6
  163. package/api/theme/list/list.d.mts +10 -0
  164. package/api/theme/list/list.mjs +75 -7
  165. package/api/theme/list/list.test.mjs +155 -4
  166. package/api/theme/remove/remove.d.mts +12 -0
  167. package/api/theme/remove/remove.mjs +15 -0
  168. package/api/theme/remove/remove.test.mjs +94 -0
  169. package/api/theme/template/template.mjs +3 -4
  170. package/api/theme/theme.d.mts +5 -2
  171. package/api/theme/theme.mjs +13 -8
  172. package/api/theme/theme.type.d.mts +106 -2
  173. package/api/theme/theme.type.mjs +54 -5
  174. package/api/theme/themeAdd.doc.d.mts +1 -3
  175. package/api/theme/themeAdd.doc.mjs +35 -22
  176. package/api/theme/themeBuild.doc.d.mts +4 -1
  177. package/api/theme/themeBuild.doc.mjs +15 -4
  178. package/api/theme/themeEject.doc.d.mts +8 -0
  179. package/api/theme/themeEject.doc.mjs +89 -0
  180. package/api/theme/themeListAvailable.doc.mjs +4 -4
  181. package/api/theme/themeListCopySources.doc.d.mts +8 -0
  182. package/api/theme/themeListCopySources.doc.mjs +60 -0
  183. package/api/theme/themeRemove.doc.d.mts +6 -0
  184. package/api/theme/themeRemove.doc.mjs +50 -0
  185. package/api/theme/themeTemplate.doc.mjs +4 -3
  186. package/api/theme/themeUse.doc.d.mts +6 -0
  187. package/api/theme/themeUse.doc.mjs +47 -0
  188. package/api/theme/use/use.d.mts +12 -0
  189. package/api/theme/use/use.mjs +15 -0
  190. package/api/theme/use/use.test.mjs +98 -0
  191. package/api/upgrade/_adapter.d.mts +1 -0
  192. package/api/upgrade/_adapter.mjs +3 -0
  193. package/api/upgrade/list/list.mjs +9 -3
  194. package/api/upgrade/run/run.mjs +20 -3
  195. package/api/upgrade/run/run.test.mjs +45 -1
  196. package/api/upgrade/upgrade.doc.mjs +1 -1
  197. package/api/upgrade/upgrade.type.d.mts +5 -0
  198. package/api/upgrade/upgrade.type.mjs +2 -0
  199. package/assets/codemods/integration-discovery.mjs +1 -1
  200. package/assets/codemods/integration-discovery.test.mjs +64 -0
  201. package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
  202. package/assets/codemods/transforms/next/index.mjs +14 -1
  203. package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
  204. package/assets/docs/author-a-theme.doc.mjs +161 -0
  205. package/assets/docs/getting-started.doc.mjs +59 -15
  206. package/assets/docs/icons.doc.mjs +1 -0
  207. package/assets/docs/principles.doc.dense.mjs +2 -2
  208. package/assets/docs/principles.doc.mjs +2 -2
  209. package/assets/docs/principles.doc.zh.mjs +2 -2
  210. package/assets/docs/styling-libraries.doc.mjs +1 -1
  211. package/assets/docs/styling.doc.mjs +2 -2
  212. package/assets/docs/theme.doc.dense.mjs +10 -198
  213. package/assets/docs/theme.doc.mjs +13 -770
  214. package/assets/docs/theme.doc.zh.mjs +31 -12
  215. package/assets/docs/tokens.doc.mjs +4 -4
  216. package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
  217. package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
  218. package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
  219. package/assets/docs/tree/checks.doc.mjs +6 -5
  220. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
  221. package/assets/docs/tree/define-the-theme.doc.mjs +2 -2
  222. package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
  223. package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
  224. package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
  225. package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
  226. package/assets/docs/tree/layout.doc.mjs +32 -0
  227. package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
  228. package/assets/docs/tree/responsive.doc.mjs +102 -0
  229. package/assets/docs/tree/scaffold.doc.mjs +145 -0
  230. package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
  231. package/assets/docs/tree/side-panels.doc.mjs +82 -0
  232. package/assets/docs/tree/structure.doc.mjs +144 -0
  233. package/assets/docs/tree/template-doc-overview.doc.mjs +13 -1
  234. package/assets/docs/tree/themes.doc.mjs +2 -2
  235. package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
  236. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
  237. package/assets/docs/tree/versioning.doc.mjs +11 -7
  238. package/assets/docs/use-a-theme.doc.mjs +97 -0
  239. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
  240. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
  241. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
  242. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
  243. package/assets/templates/pages/ai-chat/template.doc.mjs +16 -1
  244. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +9 -1
  245. package/assets/templates/pages/blank/template.doc.mjs +3 -1
  246. package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -1
  247. package/assets/templates/pages/centered-hero/template.doc.mjs +3 -1
  248. package/assets/templates/pages/checkout-wizard/template.doc.mjs +1 -0
  249. package/assets/templates/pages/classic-gallery/template.doc.mjs +3 -1
  250. package/assets/templates/pages/contact-form/template.doc.mjs +16 -1
  251. package/assets/templates/pages/dashboard/template.doc.mjs +15 -1
  252. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +23 -1
  253. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +10 -1
  254. package/assets/templates/pages/dashboard-comparison/template.doc.mjs +9 -1
  255. package/assets/templates/pages/dashboard-composition/template.doc.mjs +10 -1
  256. package/assets/templates/pages/dashboard-progress/template.doc.mjs +17 -1
  257. package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -1
  258. package/assets/templates/pages/detail-page/template.doc.mjs +8 -0
  259. package/assets/templates/pages/documentation/template.doc.mjs +10 -1
  260. package/assets/templates/pages/documentation-design/template.doc.mjs +10 -1
  261. package/assets/templates/pages/documentation-technical/template.doc.mjs +10 -1
  262. package/assets/templates/pages/editor/template.doc.mjs +9 -1
  263. package/assets/templates/pages/file-explorer/template.doc.mjs +3 -1
  264. package/assets/templates/pages/form-two-column/template.doc.mjs +17 -1
  265. package/assets/templates/pages/form-wizard/template.doc.mjs +14 -1
  266. package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +1 -0
  267. package/assets/templates/pages/gallery-hero/template.doc.mjs +10 -1
  268. package/assets/templates/pages/ide/template.doc.mjs +9 -1
  269. package/assets/templates/pages/incident-console/template.doc.mjs +10 -1
  270. package/assets/templates/pages/kanban-board/template.doc.mjs +11 -1
  271. package/assets/templates/pages/library/template.doc.mjs +15 -1
  272. package/assets/templates/pages/login/template.doc.mjs +10 -1
  273. package/assets/templates/pages/login-card/template.doc.mjs +11 -1
  274. package/assets/templates/pages/login-split/template.doc.mjs +10 -1
  275. package/assets/templates/pages/login-sso/template.doc.mjs +10 -1
  276. package/assets/templates/pages/messaging-shell/template.doc.mjs +11 -1
  277. package/assets/templates/pages/mixed-gallery/template.doc.mjs +10 -1
  278. package/assets/templates/pages/payment-form/template.doc.mjs +3 -1
  279. package/assets/templates/pages/product-detail/template.doc.mjs +9 -1
  280. package/assets/templates/pages/product-gallery/template.doc.mjs +10 -1
  281. package/assets/templates/pages/settings/template.doc.mjs +3 -1
  282. package/assets/templates/pages/settings-dialog/template.doc.mjs +9 -1
  283. package/assets/templates/pages/settings-sidebar/template.doc.mjs +9 -1
  284. package/assets/templates/pages/shell-nav/template.doc.mjs +10 -1
  285. package/assets/templates/pages/shell-side-nav/template.doc.mjs +14 -1
  286. package/assets/templates/pages/shell-top-nav/template.doc.mjs +11 -1
  287. package/assets/templates/pages/side-gallery/template.doc.mjs +3 -1
  288. package/assets/templates/pages/table/template.doc.mjs +11 -1
  289. package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
  290. package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
  291. package/assets/templates/pages/table-comparison/page.tsx +1449 -0
  292. package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
  293. package/assets/templates/pages/table-filter/template.doc.mjs +21 -1
  294. package/assets/templates/pages/table-grouped/template.doc.mjs +15 -1
  295. package/assets/templates/pages/table-inbox/template.doc.mjs +18 -6
  296. package/assets/templates/pages/table-page/template.doc.mjs +20 -1
  297. package/assets/templates/pages/table-tree/template.doc.mjs +14 -1
  298. package/assets/templates/pages/theme-showcase/template.doc.mjs +10 -1
  299. package/assets/templates/pages/work-item-detail/template.doc.mjs +10 -0
  300. package/assets/templates/themes/butter/icons.tsx +2 -0
  301. package/assets/templates/themes/chocolate/icons.tsx +2 -0
  302. package/assets/templates/themes/gothic/icons.tsx +2 -0
  303. package/assets/templates/themes/matcha/icons.tsx +2 -0
  304. package/assets/templates/themes/neutral/icons.tsx +2 -0
  305. package/assets/templates/themes/stone/icons.tsx +2 -0
  306. package/assets/templates/themes/y2k/icons.tsx +2 -0
  307. package/authoring/doctypes/command/command.doc.mjs +5 -0
  308. package/authoring/doctypes/command/type.ts +2 -0
  309. package/authoring/doctypes/component/component.doc.mjs +1 -1
  310. package/authoring/doctypes/component/type.ts +8 -4
  311. package/authoring/doctypes/template/parse.d.mts +2 -0
  312. package/authoring/doctypes/template/parse.mjs +1 -0
  313. package/authoring/doctypes/template/parse.test.mjs +21 -0
  314. package/authoring/doctypes/template/template.doc.mjs +6 -0
  315. package/authoring/doctypes/template/type.ts +10 -0
  316. package/authoring/integration/integration.doc.mjs +1 -1
  317. package/clients/cli/commands/build-theme.mjs +279 -30
  318. package/clients/cli/commands/build.mjs +7 -6
  319. package/clients/cli/commands/build.text-fields.test.mjs +1 -1
  320. package/clients/cli/commands/component/index.mjs +88 -12
  321. package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
  322. package/clients/cli/commands/component.doc.mjs +9 -2
  323. package/clients/cli/commands/discover.mjs +29 -1
  324. package/clients/cli/commands/discover.no-source.test.mjs +75 -0
  325. package/clients/cli/commands/docs.depth.test.mjs +219 -0
  326. package/clients/cli/commands/docs.doc.mjs +15 -2
  327. package/clients/cli/commands/docs.mjs +273 -16
  328. package/clients/cli/commands/docs.test.mjs +382 -0
  329. package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
  330. package/clients/cli/commands/doctor.doc.mjs +1 -1
  331. package/clients/cli/commands/doctor.mjs +4 -4
  332. package/clients/cli/commands/doctor.test.mjs +9 -51
  333. package/clients/cli/commands/gap-report.doc.mjs +2 -2
  334. package/clients/cli/commands/gap-report.mjs +12 -0
  335. package/clients/cli/commands/gap-report.test.mjs +63 -0
  336. package/clients/cli/commands/hook/index.mjs +7 -2
  337. package/clients/cli/commands/import-hint-correctness.test.mjs +5 -5
  338. package/clients/cli/commands/init.next-steps.test.mjs +18 -23
  339. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  340. package/clients/cli/commands/integration-authoring.test.mjs +12 -2
  341. package/clients/cli/commands/integration-real-world.test.mjs +61 -12
  342. package/clients/cli/commands/integration.mjs +3 -1
  343. package/clients/cli/commands/layout-check.doc.mjs +1 -0
  344. package/clients/cli/commands/layout-expand.doc.mjs +4 -1
  345. package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
  346. package/clients/cli/commands/layout.doc.mjs +1 -0
  347. package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
  348. package/clients/cli/commands/layout.mjs +61 -4
  349. package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
  350. package/clients/cli/commands/search.doc.mjs +5 -4
  351. package/clients/cli/commands/search.mjs +30 -6
  352. package/clients/cli/commands/search.test.mjs +63 -17
  353. package/clients/cli/commands/swizzle.doc.mjs +12 -3
  354. package/clients/cli/commands/swizzle.mjs +2 -1
  355. package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
  356. package/clients/cli/commands/template.mjs +70 -6
  357. package/clients/cli/commands/template.show-media.test.mjs +62 -0
  358. package/clients/cli/commands/text-json-parity.test.mjs +40 -0
  359. package/clients/cli/commands/theme-add-lifecycle.test.mjs +132 -0
  360. package/clients/cli/commands/theme-add.doc.mjs +19 -19
  361. package/clients/cli/commands/theme-eject.doc.mjs +47 -0
  362. package/clients/cli/commands/theme-list.behavior.test.mjs +44 -0
  363. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  364. package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
  365. package/clients/cli/commands/theme-remove.doc.mjs +22 -0
  366. package/clients/cli/commands/theme-template.doc.mjs +4 -3
  367. package/clients/cli/commands/theme-use.doc.mjs +22 -0
  368. package/clients/cli/commands/theme.doc.mjs +21 -16
  369. package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
  370. package/clients/cli/commands/upgrade.mjs +1 -1
  371. package/clients/cli/commands/write-failure.test.mjs +175 -0
  372. package/clients/cli/index.mjs +4 -1
  373. package/clients/cli/lib/component-format.mjs +19 -2
  374. package/clients/cli/lib/manifest.mjs +44 -165
  375. package/clients/cli/lib/manifest.test.mjs +98 -7
  376. package/clients/cli/lib/resolve-theme.mjs +80 -78
  377. package/clients/cli/lib/resolve-theme.test.mjs +523 -27
  378. package/foundation/agent-docs/agent-docs.mjs +31 -28
  379. package/foundation/agent-docs/agent-docs.test.mjs +1163 -0
  380. package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
  381. package/foundation/config/project.d.mts +20 -5
  382. package/foundation/config/project.mjs +43 -6
  383. package/foundation/config/theme-private-vars.d.mts +12 -0
  384. package/foundation/config/theme-private-vars.mjs +107 -0
  385. package/foundation/config/theme-private-vars.test.mjs +55 -0
  386. package/foundation/config/theme-state.d.mts +145 -0
  387. package/foundation/config/theme-state.mjs +417 -0
  388. package/foundation/config/theme-state.test.mjs +182 -0
  389. package/foundation/discovery/component-discovery.d.mts +5 -2
  390. package/foundation/discovery/component-discovery.mjs +12 -6
  391. package/foundation/discovery/component-replacement.d.mts +91 -0
  392. package/foundation/discovery/component-replacement.mjs +417 -0
  393. package/foundation/discovery/component-replacement.test.mjs +480 -0
  394. package/foundation/discovery/docs-output-budget.d.mts +6 -2
  395. package/foundation/discovery/docs-output-budget.mjs +2 -1
  396. package/foundation/discovery/docs-section-key.d.mts +4 -2
  397. package/foundation/discovery/docs-section-key.mjs +1 -1
  398. package/foundation/discovery/module-exports.d.mts +10 -0
  399. package/foundation/discovery/module-exports.mjs +146 -0
  400. package/foundation/discovery/package-exports.d.mts +29 -0
  401. package/foundation/discovery/package-exports.mjs +200 -0
  402. package/foundation/discovery/template-adapter.d.mts +14 -0
  403. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
  404. package/foundation/discovery/template-adapter.mjs +21 -1
  405. package/foundation/discovery/theme-discovery.d.mts +78 -5
  406. package/foundation/discovery/theme-discovery.mjs +143 -18
  407. package/foundation/discovery/theme-discovery.test.mjs +9 -3
  408. package/foundation/discovery/theme-imports.d.mts +15 -0
  409. package/foundation/discovery/theme-imports.mjs +217 -0
  410. package/foundation/discovery/theme-imports.test.mjs +173 -0
  411. package/foundation/doc-compiler/doc-loads.test.mjs +18 -8
  412. package/foundation/doc-compiler/inputs.mjs +2 -1
  413. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  414. package/foundation/doc-compiler/lenses.d.mts +4 -2
  415. package/foundation/doc-compiler/lenses.mjs +1 -1
  416. package/foundation/doc-compiler/tree.test.mjs +649 -0
  417. package/foundation/fs/module-loader.d.mts +9 -0
  418. package/foundation/fs/module-loader.mjs +71 -2
  419. package/foundation/integrations/cli-requirement.d.mts +79 -13
  420. package/foundation/integrations/cli-requirement.mjs +115 -22
  421. package/foundation/integrations/cli-requirement.test.mjs +205 -8
  422. package/foundation/integrations/contribution-inventory.mjs +3 -3
  423. package/foundation/response/base.d.ts +9 -3
  424. package/foundation/response/json.d.mts +7 -4
  425. package/foundation/response/json.mjs +10 -6
  426. package/foundation/response/response-types.doc.d.mts +5 -5
  427. package/foundation/response/response-types.doc.mjs +50 -35
  428. package/foundation/response/response.doc.mjs +18 -4
  429. package/foundation/text/copyright-header.mjs +1 -1
  430. package/foundation/text/copyright-header.test.mjs +1 -1
  431. package/package.json +9 -9
  432. package/assets/docs/layout.doc.dense.mjs +0 -388
  433. package/assets/docs/layout.doc.mjs +0 -550
@@ -0,0 +1,305 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Word weights for `build`'s START (spec:AST-048): a checked-in table of
5
+ * per-template word weights, blended with the page ranker's own scores, picks
6
+ * the template an idea starts from.
7
+ *
8
+ * @input An idea, the ranker's output for it (`rankPages`, `pickStart`), the
9
+ * project's ready page templates, and the weights (`weights.json` beside this
10
+ * file, read by the adapter): the candidates (the app shell as `SHELL`, then page template ids), one or more
11
+ * word tables (stemmed words, a bias per candidate, and one row of weights
12
+ * per word, a character per candidate) and the blend numbers.
13
+ * @output `weighStart(idea, ranked, pick, catalog)`: the template id to start
14
+ * from, null for the app shell, or undefined when no table is available, in
15
+ * which case the ranker's own pick stands.
16
+ * @position Beside rank.mjs (api/build/kit/); kit.mjs calls it for every
17
+ * whole page (a part or an edit follows the ranker's placement rules). The
18
+ * ranker's pick of a template the tables do not list stands, so a new
19
+ * template can start a build.
20
+ */
21
+
22
+ /** The app shell, as one candidate. */
23
+ export const SHELL = 'SHELL';
24
+ const SHELL_FAMILY = 'Shell';
25
+
26
+ // The Porter (1980) stemmer.
27
+ /** @type {Record<string, string>} */
28
+ const STEP2 = {
29
+ ational: 'ate',
30
+ tional: 'tion',
31
+ enci: 'ence',
32
+ anci: 'ance',
33
+ izer: 'ize',
34
+ bli: 'ble',
35
+ alli: 'al',
36
+ entli: 'ent',
37
+ eli: 'e',
38
+ ousli: 'ous',
39
+ ization: 'ize',
40
+ ation: 'ate',
41
+ ator: 'ate',
42
+ alism: 'al',
43
+ iveness: 'ive',
44
+ fulness: 'ful',
45
+ ousness: 'ous',
46
+ aliti: 'al',
47
+ iviti: 'ive',
48
+ biliti: 'ble',
49
+ logi: 'log',
50
+ };
51
+ /** @type {Record<string, string>} */
52
+ const STEP3 = {
53
+ icate: 'ic',
54
+ ative: '',
55
+ alize: 'al',
56
+ iciti: 'ic',
57
+ ical: 'ic',
58
+ ful: '',
59
+ ness: '',
60
+ };
61
+ const CONS = '[^aeiou][^aeiouy]*';
62
+ const VOW = '[aeiouy][aeiou]*';
63
+ const MGR0 = new RegExp(`^(${CONS})?${VOW}${CONS}`);
64
+ const MEQ1 = new RegExp(`^(${CONS})?${VOW}${CONS}(${VOW})?$`);
65
+ const MGR1 = new RegExp(`^(${CONS})?${VOW}${CONS}${VOW}${CONS}`);
66
+ const HAS_VOWEL = new RegExp(`^(${CONS})?[aeiouy]`);
67
+ const CVC = new RegExp(`^${CONS}[aeiouy][^aeiouwxy]$`);
68
+ const stems = new Map();
69
+
70
+ /**
71
+ * The Porter stem of a lowercase word.
72
+ * @param {string} word
73
+ * @returns {string}
74
+ */
75
+ export function stem(word) {
76
+ const cached = stems.get(word);
77
+ if (cached !== undefined) return cached;
78
+ let w = word;
79
+ if (w.length < 3 || /\d/.test(w)) {
80
+ stems.set(word, w);
81
+ return w;
82
+ }
83
+ const leadingY = w[0] === 'y';
84
+ if (leadingY) w = 'Y' + w.slice(1);
85
+ let m;
86
+ if ((m = /^(.+?)(ss|i)es$/.exec(w))) w = m[1] + m[2];
87
+ else if ((m = /^(.+?)([^s])s$/.exec(w))) w = m[1] + m[2];
88
+ if ((m = /^(.+?)eed$/.exec(w))) {
89
+ if (MGR0.test(m[1])) w = w.slice(0, -1);
90
+ } else if ((m = /^(.+?)(ed|ing)$/.exec(w)) && HAS_VOWEL.test(m[1])) {
91
+ w = m[1];
92
+ if (/(at|bl|iz)$/.test(w)) w += 'e';
93
+ else if (/([^aeiouylsz])\1$/.test(w)) w = w.slice(0, -1);
94
+ else if (CVC.test(w)) w += 'e';
95
+ }
96
+ if ((m = /^(.+?)y$/.exec(w)) && HAS_VOWEL.test(m[1])) w = m[1] + 'i';
97
+ if (
98
+ (m =
99
+ /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/.exec(
100
+ w,
101
+ )) &&
102
+ MGR0.test(m[1])
103
+ ) {
104
+ w = m[1] + STEP2[m[2]];
105
+ }
106
+ if (
107
+ (m = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/.exec(w)) &&
108
+ MGR0.test(m[1])
109
+ ) {
110
+ w = m[1] + STEP3[m[2]];
111
+ }
112
+ if (
113
+ (m =
114
+ /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/.exec(
115
+ w,
116
+ ))
117
+ ) {
118
+ if (MGR1.test(m[1])) w = m[1];
119
+ } else if ((m = /^(.+?)(s|t)(ion)$/.exec(w)) && MGR1.test(m[1] + m[2])) {
120
+ w = m[1] + m[2];
121
+ }
122
+ if (
123
+ (m = /^(.+?)e$/.exec(w)) &&
124
+ (MGR1.test(m[1]) || (MEQ1.test(m[1]) && !CVC.test(m[1])))
125
+ ) {
126
+ w = m[1];
127
+ }
128
+ if (/ll$/.test(w) && MGR1.test(w)) w = w.slice(0, -1);
129
+ if (leadingY) w = 'y' + w.slice(1);
130
+ stems.set(word, w);
131
+ return w;
132
+ }
133
+
134
+ /**
135
+ * Lowercase words of an idea that can carry weight: letters only, two or more.
136
+ * @param {string} idea
137
+ * @returns {string[]}
138
+ */
139
+ export function weightWords(idea) {
140
+ return String(idea ?? '')
141
+ .toLowerCase()
142
+ .split(/[^a-z0-9]+/)
143
+ .filter(w => w.length >= 2 && !/\d/.test(w));
144
+ }
145
+
146
+ /**
147
+ * @typedef {object} WeightTable
148
+ * @property {string[]} words stemmed words
149
+ * @property {number[]} bias one per candidate
150
+ * @property {number} clip
151
+ * @property {number} step
152
+ * @property {string[]} rows one per word: a character per candidate,
153
+ * weight = (charCode - 97) * step - clip
154
+ *
155
+ * @typedef {object} WeightsFile
156
+ * @property {number} version
157
+ * @property {string[]} candidates `SHELL`, then page template ids
158
+ * @property {WeightTable[]} tables
159
+ * @property {number[]} blend three numbers per member (the tables, in order,
160
+ * with the ranker second), then one for `SHELL`
161
+ */
162
+
163
+ /**
164
+ * A table's score for every candidate.
165
+ * @param {WeightTable} table
166
+ * @param {Map<string, number>} index word -> row
167
+ * @param {Set<string>} words the idea's stemmed words
168
+ * @param {number} n candidates
169
+ */
170
+ function tableScores(table, index, words, n) {
171
+ const out = Float64Array.from(table.bias.slice(0, n));
172
+ for (const w of words) {
173
+ const i = index.get(w);
174
+ if (i === undefined) continue;
175
+ const row = table.rows[i];
176
+ for (let c = 0; c < n; c++) {
177
+ out[c] += (row.charCodeAt(c) - 97) * table.step - table.clip;
178
+ }
179
+ }
180
+ return out;
181
+ }
182
+
183
+ /** @param {number} x */
184
+ const round4 = x => Math.round(x * 1e4) / 1e4;
185
+
186
+ /**
187
+ * The ranker's scores as a blend member: every non-shell template's rank
188
+ * score, the ranker's own start lifted above the rest, and the app shell above
189
+ * them all when the ranker would start from it.
190
+ * @param {import('./rank.mjs').RankedPage[]} ranked
191
+ * @param {import('./rank.mjs').RankedPage | null} pick
192
+ */
193
+ function rankerScores(ranked, pick) {
194
+ /** @type {Map<string, number>} */
195
+ const out = new Map();
196
+ for (const r of ranked)
197
+ if (r.family !== SHELL_FAMILY) out.set(r.name, r.score);
198
+ const top = Math.max(0, ...out.values());
199
+ const pageStart = pick && pick.family !== SHELL_FAMILY ? pick.name : null;
200
+ out.set(SHELL, pageStart ? -1 : top + 1);
201
+ if (pageStart) out.set(pageStart, top + 2);
202
+ return out;
203
+ }
204
+
205
+ /**
206
+ * Per-candidate features of one member's scores: z-score, 1/(rank+1), is-top.
207
+ * @param {(number | undefined)[]} v a score per candidate (undefined: none)
208
+ */
209
+ function memberFeatures(v) {
210
+ const finite = /** @type {number[]} */ (v.filter(x => x !== undefined));
211
+ const mean = finite.reduce((a, b) => a + b, 0) / Math.max(1, finite.length);
212
+ const sd =
213
+ Math.sqrt(
214
+ finite.reduce((a, b) => a + (b - mean) ** 2, 0) /
215
+ Math.max(1, finite.length),
216
+ ) || 1;
217
+ const val = v.map(x => (x === undefined ? -1e9 : x));
218
+ const order = [...val.keys()].sort((a, b) => val[b] - val[a]);
219
+ const rank = new Array(v.length);
220
+ order.forEach((ci, r) => (rank[ci] = r));
221
+ return v.map((x, i) => [
222
+ x === undefined ? -4 : Math.max(-4, Math.min(4, (x - mean) / sd)),
223
+ 1 / (rank[i] + 1),
224
+ rank[i] === 0 ? 1 : 0,
225
+ ]);
226
+ }
227
+
228
+ /**
229
+ * Where an idea starts, by the blended weights.
230
+ * @param {string} idea
231
+ * @param {import('./rank.mjs').RankedPage[]} ranked the ranker's output for the idea
232
+ * @param {import('./rank.mjs').RankedPage | null} pick the ranker's own start
233
+ * @param {{name: string}[]} catalog the project's ready page templates
234
+ * @param {{weights?: WeightsFile | null, newPage?: boolean}} [options]
235
+ * `newPage`: the idea asks for a new page (rank.mjs `asksForNewPage`)
236
+ * @returns {string | null | undefined} a template id, null for the app shell,
237
+ * undefined without weights
238
+ */
239
+ export function weighStart(
240
+ idea,
241
+ ranked,
242
+ pick,
243
+ catalog,
244
+ {weights = null, newPage = false} = {},
245
+ ) {
246
+ if (!weights) return undefined;
247
+ const ready = new Set(catalog.map(t => t.name));
248
+ const shellIds = new Set(
249
+ ranked.filter(r => r.family === SHELL_FAMILY).map(r => r.name),
250
+ );
251
+ // Candidates: the app shell and every ready, non-shell template, the
252
+ // table's first, then any the table does not list.
253
+ const listed = weights.candidates.filter(c => c === SHELL || ready.has(c));
254
+ const extra = catalog
255
+ .map(t => t.name)
256
+ .filter(n => !shellIds.has(n) && !weights.candidates.includes(n));
257
+ const cands = [...listed, ...extra];
258
+ const position = new Map(weights.candidates.map((c, i) => [c, i]));
259
+ const words = new Set(weightWords(idea).map(stem));
260
+ /** @type {(number | undefined)[][]} */
261
+ const members = weights.tables.map(table => {
262
+ const index = new Map(table.words.map((w, i) => [w, i]));
263
+ const s = tableScores(table, index, words, weights.candidates.length);
264
+ return cands.map(c => {
265
+ const i = position.get(c);
266
+ return i === undefined ? undefined : round4(s[i]);
267
+ });
268
+ });
269
+ const fromRanker = rankerScores(ranked, pick);
270
+ const rankerMember = cands.map(c => {
271
+ const x = fromRanker.get(c);
272
+ return x === undefined ? undefined : round4(x);
273
+ });
274
+ // The ranker is the blend's second member, after the first table.
275
+ members.splice(1, 0, rankerMember);
276
+ const feats = members.map(memberFeatures);
277
+ const scores = cands.map((c, i) => {
278
+ let s = 0;
279
+ let j = 0;
280
+ for (const f of feats) for (const x of f[i]) s += x * weights.blend[j++];
281
+ return s + (c === SHELL ? 1 : 0) * weights.blend[j];
282
+ });
283
+ /** @param {(c: string) => boolean} ok */
284
+ const best = ok => {
285
+ let at = -1;
286
+ for (let c = 0; c < cands.length; c++) {
287
+ if (ok(cands[c]) && (at < 0 || scores[c] > scores[at])) at = c;
288
+ }
289
+ return at < 0 ? null : cands[at];
290
+ };
291
+ const kept =
292
+ pick && pick.family !== SHELL_FAMILY && cands.includes(pick.name)
293
+ ? pick.name
294
+ : null;
295
+ // The tables cannot judge a template they do not list, and a template the
296
+ // ranker placed by its frame stays (spec:AST-048/FR3): the ranker's pick
297
+ // stands for both.
298
+ if (kept && (!position.has(kept) || pick?.containerMatched)) return kept;
299
+ const top = best(() => true);
300
+ if (top !== SHELL) return top;
301
+ // An idea that asks for a new page keeps the ranker's template rather than
302
+ // the shell.
303
+ if (newPage && kept) return kept;
304
+ return null;
305
+ }
@@ -0,0 +1,190 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ import {describe, expect, it} from 'vitest';
4
+
5
+ import {isWeightsFile} from '../_adapter.mjs';
6
+ import {SHELL, stem, weighStart, weightWords} from './weights.mjs';
7
+
8
+ // A made-up table for tests only: three page templates and the app shell.
9
+ const CANDIDATES = [SHELL, 'board', 'charts', 'grid'];
10
+
11
+ /**
12
+ * @param {Record<string, number[]>} weights per word, one value per candidate
13
+ * @param {number[]} [bias]
14
+ * @param {number} [step]
15
+ * @param {number} [clip]
16
+ */
17
+ function table(weights, bias = [0, 0, 0, 0], step = 0.5, clip = 4) {
18
+ return {
19
+ words: Object.keys(weights),
20
+ bias,
21
+ clip,
22
+ step,
23
+ rows: Object.values(weights).map(ws =>
24
+ ws
25
+ .map(w => String.fromCharCode(97 + Math.round((w + clip) / step)))
26
+ .join(''),
27
+ ),
28
+ };
29
+ }
30
+
31
+ const WEIGHTS = {
32
+ version: 1,
33
+ candidates: CANDIDATES,
34
+ tables: [
35
+ table({
36
+ [stem('kanban')]: [0, 3, 0, 0],
37
+ [stem('existing')]: [3, 0, 0, 0],
38
+ [stem('charts')]: [0, 0, 2, 0],
39
+ }),
40
+ table({[stem('cards')]: [0, 0, 0, 1]}, [0, 0, 0, 0], 1, 4),
41
+ ],
42
+ // three numbers per member (table 1, the ranker, table 2), then one for SHELL
43
+ blend: [1, 0, 0, 0.5, 0, 0, 0.2, 0, 0, 0],
44
+ };
45
+ const CATALOG = [
46
+ {name: 'board'},
47
+ {name: 'charts'},
48
+ {name: 'grid'},
49
+ {name: 'top-nav'},
50
+ ];
51
+
52
+ /**
53
+ * @param {string} name
54
+ * @param {number} score
55
+ * @param {string} family
56
+ */
57
+ const page = (name, score, family) => ({
58
+ name,
59
+ score,
60
+ hits: 1,
61
+ family,
62
+ base: true,
63
+ familyNamed: false,
64
+ containerMatched: false,
65
+ matched: new Set(),
66
+ });
67
+ /** A ranker output that prefers `charts`. */
68
+ const RANKED = [
69
+ page('charts', 3, 'Charts'),
70
+ page('grid', 1, 'Grid'),
71
+ page('board', 0.5, 'Board'),
72
+ page('top-nav', 0, 'Shell'),
73
+ ];
74
+
75
+ describe('weighStart', () => {
76
+ it('lets the word weights outvote the ranker', () => {
77
+ const start = weighStart(
78
+ 'a kanban for launches',
79
+ RANKED,
80
+ RANKED[0],
81
+ CATALOG,
82
+ {
83
+ weights: WEIGHTS,
84
+ },
85
+ );
86
+ expect(start).toBe('board');
87
+ });
88
+
89
+ it('keeps the ranker when the words carry no weight', () => {
90
+ const start = weighStart('something else', RANKED, RANKED[0], CATALOG, {
91
+ weights: WEIGHTS,
92
+ });
93
+ expect(start).toBe('charts');
94
+ });
95
+
96
+ it('returns null for the app shell', () => {
97
+ const start = weighStart('tweak the existing page', RANKED, null, CATALOG, {
98
+ weights: WEIGHTS,
99
+ });
100
+ expect(start).toBeNull();
101
+ });
102
+
103
+ it('returns undefined without weights, so the ranker decides', () => {
104
+ const start = weighStart('a kanban', RANKED, RANKED[0], CATALOG, {
105
+ weights: null,
106
+ });
107
+ expect(start).toBeUndefined();
108
+ });
109
+
110
+ it('never starts from a template the project does not have', () => {
111
+ const catalog = CATALOG.filter(t => t.name !== 'board');
112
+ const ranked = RANKED.filter(r => r.name !== 'board');
113
+ const start = weighStart('a kanban', ranked, ranked[0], catalog, {
114
+ weights: WEIGHTS,
115
+ });
116
+ expect(start).not.toBe('board');
117
+ });
118
+
119
+ it("keeps the ranker's pick of a template the tables do not list", () => {
120
+ const catalog = [...CATALOG, {name: 'fresh'}];
121
+ const ranked = [page('fresh', 9, 'Fresh'), ...RANKED];
122
+ const start = weighStart('a kanban', ranked, ranked[0], catalog, {
123
+ weights: WEIGHTS,
124
+ });
125
+ expect(start).toBe('fresh');
126
+ });
127
+
128
+ it("keeps the ranker's template for an idea that asks for a new page", () => {
129
+ const start = weighStart('the existing page', RANKED, RANKED[0], CATALOG, {
130
+ weights: WEIGHTS,
131
+ newPage: true,
132
+ });
133
+ expect(start).toBe('charts');
134
+ });
135
+
136
+ it('starts a new page from the shell when the ranker has no template', () => {
137
+ const start = weighStart('the existing page', RANKED, null, CATALOG, {
138
+ weights: WEIGHTS,
139
+ newPage: true,
140
+ });
141
+ expect(start).toBeNull();
142
+ });
143
+
144
+ it('keeps a template the ranker placed by its frame', () => {
145
+ const framed = {...RANKED[1], containerMatched: true};
146
+ for (const idea of ['the existing page', 'a kanban']) {
147
+ const start = weighStart(idea, RANKED, framed, CATALOG, {
148
+ weights: WEIGHTS,
149
+ });
150
+ expect(start).toBe('grid');
151
+ }
152
+ });
153
+
154
+ it('is deterministic', () => {
155
+ const run = () =>
156
+ weighStart('kanban charts cards', RANKED, RANKED[0], CATALOG, {
157
+ weights: WEIGHTS,
158
+ });
159
+ expect(run()).toBe(run());
160
+ });
161
+ });
162
+
163
+ describe('weightWords', () => {
164
+ it('keeps letter words of two or more characters', () => {
165
+ expect(weightWords('A 3-col Dashboard, v2 KPIs!')).toEqual([
166
+ 'col',
167
+ 'dashboard',
168
+ 'kpis',
169
+ ]);
170
+ });
171
+ });
172
+
173
+ describe('isWeightsFile', () => {
174
+ it('accepts a well-formed file', () => {
175
+ expect(isWeightsFile(WEIGHTS)).toBe(true);
176
+ });
177
+
178
+ it('rejects a file whose rows, bias or blend do not fit the candidates', () => {
179
+ const [first, second] = WEIGHTS.tables;
180
+ expect(isWeightsFile({...WEIGHTS, blend: [1, 2, 3]})).toBe(false);
181
+ expect(
182
+ isWeightsFile({...WEIGHTS, tables: [{...first, rows: ['ab']}, second]}),
183
+ ).toBe(false);
184
+ expect(
185
+ isWeightsFile({...WEIGHTS, tables: [{...first, bias: [0]}, second]}),
186
+ ).toBe(false);
187
+ expect(isWeightsFile({version: 1})).toBe(false);
188
+ expect(isWeightsFile(null)).toBe(false);
189
+ });
190
+ });
@@ -68,6 +68,25 @@ export function requireCoreDir(cwd: string): string;
68
68
  * @returns {Promise<import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]>}
69
69
  */
70
70
  export function loadIntegrationsSafely(cwd: string): Promise<import("../../foundation/integrations/integrations.mjs").LoadedIntegration[]>;
71
+ /**
72
+ * Every component replacement the loaded integrations declare
73
+ * (spec:AST-035 FR10–FR15): the active one for each replaced Core component,
74
+ * and the findings Doctor reports. With no Core directory, only the opt-in
75
+ * and value findings are computed.
76
+ * @param {string|null} coreDir
77
+ * @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
78
+ * @returns {Promise<import('../../foundation/discovery/component-replacement.mjs').ComponentReplacements>}
79
+ */
80
+ export function loadComponentReplacements(coreDir: string | null, loadedIntegrations: import("../../foundation/integrations/integrations.mjs").LoadedIntegration[]): Promise<import("../../foundation/discovery/component-replacement.mjs").ComponentReplacements>;
81
+ /**
82
+ * The integration component that answers to the Core component name
83
+ * `dirName` for unqualified lookup, or undefined when none replaces it.
84
+ * @param {string} coreDir
85
+ * @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
86
+ * @param {string} dirName
87
+ * @returns {Promise<import('../../foundation/discovery/component-replacement.mjs').ActiveComponentReplacement | undefined>}
88
+ */
89
+ export function resolveComponentReplacement(coreDir: string, loadedIntegrations: import("../../foundation/integrations/integrations.mjs").LoadedIntegration[], dirName: string): Promise<import("../../foundation/discovery/component-replacement.mjs").ActiveComponentReplacement | undefined>;
71
90
  /**
72
91
  * Read the exact installed version available to a package-qualified component
73
92
  * selector. Legacy docs packages do not expose a reliable version here, so a
@@ -38,6 +38,7 @@ import {
38
38
  } from '../../foundation/discovery/component-discovery.mjs';
39
39
  import {Project} from '../../foundation/config/project.mjs';
40
40
  import {loadComponentDoc as loadValidatedComponentDoc} from '../../foundation/discovery/component-loader.mjs';
41
+ import {resolveComponentReplacements} from '../../foundation/discovery/component-replacement.mjs';
41
42
  import {searchComponents} from '../../foundation/text/string-utils.mjs';
42
43
  import {AstryxError} from '../error.mjs';
43
44
 
@@ -138,6 +139,38 @@ export async function loadIntegrationsSafely(cwd) {
138
139
  }
139
140
  }
140
141
 
142
+ /**
143
+ * Every component replacement the loaded integrations declare
144
+ * (spec:AST-035 FR10–FR15): the active one for each replaced Core component,
145
+ * and the findings Doctor reports. With no Core directory, only the opt-in
146
+ * and value findings are computed.
147
+ * @param {string|null} coreDir
148
+ * @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
149
+ * @returns {Promise<import('../../foundation/discovery/component-replacement.mjs').ComponentReplacements>}
150
+ */
151
+ export function loadComponentReplacements(coreDir, loadedIntegrations) {
152
+ return resolveComponentReplacements(coreDir, loadedIntegrations);
153
+ }
154
+
155
+ /**
156
+ * The integration component that answers to the Core component name
157
+ * `dirName` for unqualified lookup, or undefined when none replaces it.
158
+ * @param {string} coreDir
159
+ * @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
160
+ * @param {string} dirName
161
+ * @returns {Promise<import('../../foundation/discovery/component-replacement.mjs').ActiveComponentReplacement | undefined>}
162
+ */
163
+ export async function resolveComponentReplacement(
164
+ coreDir,
165
+ loadedIntegrations,
166
+ dirName,
167
+ ) {
168
+ if (loadedIntegrations.length === 0) return undefined;
169
+ return (
170
+ await resolveComponentReplacements(coreDir, loadedIntegrations)
171
+ ).forTarget(dirName);
172
+ }
173
+
141
174
  /**
142
175
  * Resolve a loaded integration by package name.
143
176
  * @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations