@astryxdesign/cli 0.6.6 → 0.6.7-canary.796bcc2

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 (399) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/README.md +84 -82
  3. package/api/build/_adapter.d.mts +20 -0
  4. package/api/build/_adapter.mjs +24 -0
  5. package/api/build/build.doc.mjs +1 -1
  6. package/api/build/build.test.mjs +1 -1
  7. package/api/build/build.type.d.mts +12 -0
  8. package/api/build/build.type.mjs +3 -0
  9. package/api/build/help/help.mjs +1 -1
  10. package/api/build/kit/kit.mjs +13 -1
  11. package/api/component/_adapter.d.mts +19 -0
  12. package/api/component/_adapter.mjs +33 -0
  13. package/api/component/component-replacement.test.mjs +615 -0
  14. package/api/component/component.doc.mjs +5 -2
  15. package/api/component/component.mjs +49 -15
  16. package/api/component/component.test.mjs +32 -0
  17. package/api/component/component.type.d.mts +33 -3
  18. package/api/component/component.type.mjs +10 -3
  19. package/api/component/detail/blocks/blocks.d.mts +2 -1
  20. package/api/component/detail/blocks/blocks.mjs +5 -2
  21. package/api/component/detail/detail.mjs +5 -1
  22. package/api/component/detail/props/props.d.mts +2 -1
  23. package/api/component/detail/props/props.mjs +3 -2
  24. package/api/component/detail/showcase/showcase.d.mts +3 -1
  25. package/api/component/detail/showcase/showcase.mjs +3 -1
  26. package/api/component/detail/source/source.d.mts +3 -2
  27. package/api/component/detail/source/source.mjs +7 -3
  28. package/api/component/list/list.mjs +128 -10
  29. package/api/docs/_adapter.d.mts +11 -0
  30. package/api/docs/_adapter.mjs +73 -1
  31. package/api/docs/compiled-topics.test.mjs +1 -1
  32. package/api/docs/detail/detail.mjs +19 -3
  33. package/api/docs/detail/section/section.d.mts +44 -0
  34. package/api/docs/detail/section/section.mjs +171 -14
  35. package/api/docs/detail/section/section.test.mjs +4 -4
  36. package/api/docs/docOverlays.test.mjs +38 -23
  37. package/api/docs/docs.depth.test.mjs +2 -0
  38. package/api/docs/docs.doc.mjs +3 -3
  39. package/api/docs/docs.mjs +13 -16
  40. package/api/docs/docs.test.mjs +9 -10
  41. package/api/docs/docs.type.d.mts +43 -3
  42. package/api/docs/docs.type.mjs +23 -3
  43. package/api/docs/index/index.mjs +11 -2
  44. package/api/docs/index/index.test.mjs +7 -2
  45. package/api/docs/integration-tree.test.mjs +26 -26
  46. package/api/docs/integrationDocs.test.mjs +8 -7
  47. package/api/docs/namespace-section.test.mjs +260 -0
  48. package/api/docs/node/node.mjs +3 -0
  49. package/api/docs/token-tables.test.mjs +93 -0
  50. package/api/doctor/_adapter.d.mts +50 -0
  51. package/api/doctor/_adapter.mjs +190 -0
  52. package/api/doctor/doctor.d.mts +6 -10
  53. package/api/doctor/doctor.doc.mjs +1 -3
  54. package/api/doctor/doctor.mjs +144 -150
  55. package/api/doctor/doctor.test.mjs +104 -0
  56. package/api/doctor/theme-checks.d.mts +24 -0
  57. package/api/doctor/theme-checks.mjs +1231 -0
  58. package/api/doctor/theme-checks.test.mjs +667 -0
  59. package/api/gap-report/gap-report.doc.mjs +2 -1
  60. package/api/gap-report/gap-report.mjs +15 -1
  61. package/api/hook/_adapter.d.mts +1 -0
  62. package/api/hook/_adapter.mjs +3 -0
  63. package/api/hook/detail/detail.mjs +2 -2
  64. package/api/hook/detail/params/params.mjs +2 -2
  65. package/api/hook/hook.type.d.mts +12 -0
  66. package/api/hook/hook.type.mjs +3 -0
  67. package/api/hook/list/list.mjs +8 -8
  68. package/api/index.d.mts +1 -1
  69. package/api/index.mjs +4 -0
  70. package/api/init/run/run.d.mts +3 -5
  71. package/api/init/run/run.mjs +11 -11
  72. package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
  73. package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
  74. package/api/integration/add-helpers.d.mts +26 -5
  75. package/api/integration/add-helpers.mjs +50 -5
  76. package/api/integration/add-theme.mjs +16 -2
  77. package/api/integration/add-theme.test.mjs +66 -15
  78. package/api/integration/authoring-checks.mjs +21 -1
  79. package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
  80. package/api/integration/pack-check.component-replaces.test.mjs +126 -0
  81. package/api/integration/pack-check.d.mts +10 -0
  82. package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
  83. package/api/integration/pack-check.mjs +485 -3
  84. package/api/integration/pack-check.test.mjs +578 -10
  85. package/api/integration/validate-integration.mjs +20 -4
  86. package/api/integration/validate-integration.test.mjs +73 -0
  87. package/api/layout/check/check.d.mts +1 -0
  88. package/api/layout/check/check.mjs +1 -0
  89. package/api/layout/expand/expand.d.mts +1 -0
  90. package/api/layout/expand/expand.mjs +1 -0
  91. package/api/layout/grammar/grammar.d.mts +1 -0
  92. package/api/layout/grammar/grammar.mjs +1 -0
  93. package/api/layout/layoutCheck.doc.mjs +1 -1
  94. package/api/layout/layoutExpand.doc.mjs +1 -1
  95. package/api/layout/layoutGrammar.doc.mjs +1 -1
  96. package/api/search/search.d.mts +47 -3
  97. package/api/search/search.doc.mjs +1 -1
  98. package/api/search/search.domain-priority.test.mjs +261 -0
  99. package/api/search/search.mjs +247 -43
  100. package/api/search/search.test.mjs +5 -1
  101. package/api/search/search.type.d.mts +3 -3
  102. package/api/search/search.type.mjs +2 -2
  103. package/api/swizzle/_adapter.d.mts +10 -0
  104. package/api/swizzle/_adapter.mjs +23 -0
  105. package/api/swizzle/copy/copy.d.mts +5 -6
  106. package/api/swizzle/copy/copy.mjs +29 -10
  107. package/api/swizzle/list/list.mjs +2 -2
  108. package/api/swizzle/swizzle.doc.mjs +5 -2
  109. package/api/swizzle/swizzle.test.mjs +55 -5
  110. package/api/swizzle/swizzle.type.d.mts +8 -0
  111. package/api/swizzle/swizzle.type.mjs +2 -0
  112. package/api/template/copy/copy.mjs +14 -1
  113. package/api/template/show/show.mjs +2 -0
  114. package/api/template/skeleton/skeleton.mjs +2 -1
  115. package/api/template/template.d.mts +1 -1
  116. package/api/template/template.doc.mjs +1 -1
  117. package/api/template/template.mjs +1 -0
  118. package/api/template/template.type.d.mts +15 -0
  119. package/api/template/template.type.mjs +6 -0
  120. package/api/theme/_adapter.d.mts +106 -6
  121. package/api/theme/_adapter.mjs +687 -18
  122. package/api/theme/add/add.binary.test.mjs +76 -3
  123. package/api/theme/add/add.d.mts +5 -9
  124. package/api/theme/add/add.mjs +87 -64
  125. package/api/theme/add/add.rollback.test.mjs +9 -9
  126. package/api/theme/add/add.staging.test.mjs +9 -9
  127. package/api/theme/add/add.test.mjs +461 -55
  128. package/api/theme/add/add.types.test.mjs +151 -0
  129. package/api/theme/build/build.d.mts +96 -2
  130. package/api/theme/build/build.family.test.mjs +13 -4
  131. package/api/theme/build/build.mjs +286 -118
  132. package/api/theme/build/build.test.mjs +30 -0
  133. package/api/theme/build/font-warning.d.mts +11 -0
  134. package/api/theme/build/font-warning.mjs +28 -3
  135. package/api/theme/eject/eject.binary.test.mjs +90 -0
  136. package/api/theme/eject/eject.d.mts +17 -0
  137. package/api/theme/eject/eject.mjs +65 -0
  138. package/api/theme/eject/eject.rollback.test.mjs +158 -0
  139. package/api/theme/eject/eject.staging.test.mjs +83 -0
  140. package/api/theme/eject/eject.test.mjs +160 -0
  141. package/api/theme/integration-themes.test.mjs +30 -6
  142. package/api/theme/list/list.d.mts +10 -0
  143. package/api/theme/list/list.mjs +75 -7
  144. package/api/theme/list/list.test.mjs +155 -4
  145. package/api/theme/remove/remove.d.mts +12 -0
  146. package/api/theme/remove/remove.mjs +15 -0
  147. package/api/theme/remove/remove.test.mjs +94 -0
  148. package/api/theme/template/template.mjs +3 -4
  149. package/api/theme/theme.d.mts +5 -2
  150. package/api/theme/theme.mjs +13 -8
  151. package/api/theme/theme.type.d.mts +106 -2
  152. package/api/theme/theme.type.mjs +54 -5
  153. package/api/theme/themeAdd.doc.d.mts +1 -3
  154. package/api/theme/themeAdd.doc.mjs +35 -22
  155. package/api/theme/themeBuild.doc.mjs +1 -1
  156. package/api/theme/themeEject.doc.d.mts +8 -0
  157. package/api/theme/themeEject.doc.mjs +89 -0
  158. package/api/theme/themeListAvailable.doc.mjs +4 -4
  159. package/api/theme/themeListCopySources.doc.d.mts +8 -0
  160. package/api/theme/themeListCopySources.doc.mjs +60 -0
  161. package/api/theme/themeRemove.doc.d.mts +6 -0
  162. package/api/theme/themeRemove.doc.mjs +50 -0
  163. package/api/theme/themeTemplate.doc.mjs +4 -3
  164. package/api/theme/themeUse.doc.d.mts +6 -0
  165. package/api/theme/themeUse.doc.mjs +47 -0
  166. package/api/theme/use/use.d.mts +12 -0
  167. package/api/theme/use/use.mjs +15 -0
  168. package/api/theme/use/use.test.mjs +98 -0
  169. package/api/upgrade/_adapter.d.mts +1 -0
  170. package/api/upgrade/_adapter.mjs +3 -0
  171. package/api/upgrade/list/list.mjs +9 -3
  172. package/api/upgrade/upgrade.type.d.mts +4 -0
  173. package/api/upgrade/upgrade.type.mjs +1 -0
  174. package/assets/codemods/__tests__/registry.test.mjs +1 -0
  175. package/assets/codemods/integration-discovery.mjs +1 -1
  176. package/assets/codemods/integration-discovery.test.mjs +64 -0
  177. package/assets/codemods/registry.mjs +1 -0
  178. package/assets/codemods/transforms/v0.6.7/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
  179. package/assets/codemods/transforms/v0.6.7/index.mjs +23 -0
  180. package/assets/codemods/transforms/v0.6.7/migrate-copied-themes-to-descriptors.mjs +54 -0
  181. package/assets/docs/author-a-theme.doc.mjs +166 -0
  182. package/assets/docs/getting-started.doc.mjs +61 -17
  183. package/assets/docs/principles.doc.dense.mjs +4 -4
  184. package/assets/docs/principles.doc.mjs +6 -6
  185. package/assets/docs/principles.doc.zh.mjs +4 -4
  186. package/assets/docs/styling-overview.doc.mjs +211 -0
  187. package/assets/docs/theme.doc.dense.mjs +10 -198
  188. package/assets/docs/theme.doc.mjs +13 -771
  189. package/assets/docs/theme.doc.zh.mjs +31 -12
  190. package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
  191. package/assets/docs/tree/checks.doc.mjs +6 -5
  192. package/assets/docs/tree/component-migration.doc.mjs +107 -0
  193. package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
  194. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  195. package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
  196. package/assets/docs/tree/font-setup.doc.mjs +122 -0
  197. package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
  198. package/assets/docs/tree/headers-and-footers.doc.mjs +67 -0
  199. package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
  200. package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
  201. package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
  202. package/assets/docs/tree/internationalization.doc.mjs +29 -0
  203. package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
  204. package/assets/docs/tree/layout.doc.mjs +55 -0
  205. package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
  206. package/assets/docs/tree/migration-verification.doc.mjs +67 -0
  207. package/assets/docs/tree/migration.doc.mjs +28 -0
  208. package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
  209. package/assets/docs/tree/other-libraries.doc.mjs +218 -0
  210. package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
  211. package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
  212. package/assets/docs/tree/responsive.doc.mjs +98 -0
  213. package/assets/docs/tree/scaffold.doc.mjs +140 -0
  214. package/assets/docs/tree/side-panels.doc.mjs +81 -0
  215. package/assets/docs/tree/structure.doc.mjs +140 -0
  216. package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
  217. package/assets/docs/tree/styling-basics.doc.mjs +181 -0
  218. package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
  219. package/assets/docs/tree/styling.doc.mjs +29 -0
  220. package/assets/docs/tree/tailwind.doc.mjs +65 -0
  221. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  222. package/assets/docs/tree/themes.doc.mjs +2 -2
  223. package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
  224. package/assets/docs/tree/tokens-border.doc.mjs +46 -0
  225. package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
  226. package/assets/docs/tree/tokens-color.doc.mjs +438 -0
  227. package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
  228. package/assets/docs/tree/tokens-data.doc.mjs +323 -0
  229. package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
  230. package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
  231. package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
  232. package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
  233. package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
  234. package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
  235. package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
  236. package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
  237. package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
  238. package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
  239. package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
  240. package/assets/docs/tree/tokens-size.doc.mjs +54 -0
  241. package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
  242. package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
  243. package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
  244. package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
  245. package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
  246. package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
  247. package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
  248. package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
  249. package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
  250. package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
  251. package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
  252. package/assets/docs/tree/tokens.doc.mjs +28 -0
  253. package/assets/docs/tree/troubleshooting.doc.mjs +7 -3
  254. package/assets/docs/tree/type-scale.doc.mjs +147 -0
  255. package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
  256. package/assets/docs/tree/typography.doc.mjs +29 -0
  257. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
  258. package/assets/docs/tree/versioning.doc.mjs +6 -3
  259. package/assets/docs/use-a-theme.doc.mjs +212 -0
  260. package/assets/templates/pages/incident-console/page.tsx +1 -1
  261. package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
  262. package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
  263. package/assets/templates/pages/table-comparison/page.tsx +1449 -0
  264. package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
  265. package/assets/theme.template.ts +4 -3
  266. package/authoring/doctypes/command/command.doc.mjs +5 -0
  267. package/authoring/doctypes/command/type.ts +2 -0
  268. package/authoring/doctypes/component/component.doc.mjs +1 -1
  269. package/authoring/doctypes/component/type.ts +8 -4
  270. package/authoring/doctypes/template/template.doc.mjs +2 -2
  271. package/authoring/doctypes/template/type.ts +5 -3
  272. package/authoring/integration/integration.doc.mjs +1 -1
  273. package/clients/cli/commands/blog.mjs +3 -3
  274. package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
  275. package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
  276. package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
  277. package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
  278. package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
  279. package/clients/cli/commands/build-theme.mjs +338 -45
  280. package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
  281. package/clients/cli/commands/build.mjs +8 -6
  282. package/clients/cli/commands/build.text-fields.test.mjs +1 -1
  283. package/clients/cli/commands/component/index.mjs +91 -12
  284. package/clients/cli/commands/component-replacement.text.test.mjs +316 -0
  285. package/clients/cli/commands/component.doc.mjs +9 -2
  286. package/clients/cli/commands/docs.doc.mjs +2 -1
  287. package/clients/cli/commands/docs.mjs +63 -23
  288. package/clients/cli/commands/docs.test.mjs +17 -15
  289. package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
  290. package/clients/cli/commands/doctor.doc.mjs +1 -1
  291. package/clients/cli/commands/doctor.test.mjs +59 -52
  292. package/clients/cli/commands/gap-report.doc.mjs +2 -2
  293. package/clients/cli/commands/hook/index.mjs +7 -2
  294. package/clients/cli/commands/import-hint-correctness.test.mjs +28 -5
  295. package/clients/cli/commands/init.next-steps.test.mjs +18 -23
  296. package/clients/cli/commands/integration-real-world.test.mjs +61 -12
  297. package/clients/cli/commands/layout-check.doc.mjs +2 -0
  298. package/clients/cli/commands/layout-expand.doc.mjs +2 -0
  299. package/clients/cli/commands/layout-grammar.doc.mjs +2 -0
  300. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
  301. package/clients/cli/commands/layout.doc.mjs +2 -0
  302. package/clients/cli/commands/layout.mjs +40 -4
  303. package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
  304. package/clients/cli/commands/search.test.mjs +10 -4
  305. package/clients/cli/commands/swizzle.doc.mjs +12 -3
  306. package/clients/cli/commands/swizzle.mjs +2 -1
  307. package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
  308. package/clients/cli/commands/template.mjs +56 -5
  309. package/clients/cli/commands/text-json-parity.test.mjs +40 -0
  310. package/clients/cli/commands/theme-add-lifecycle.test.mjs +135 -0
  311. package/clients/cli/commands/theme-add.doc.mjs +19 -19
  312. package/clients/cli/commands/theme-build.doc.mjs +3 -1
  313. package/clients/cli/commands/theme-eject.doc.mjs +47 -0
  314. package/clients/cli/commands/theme-list.behavior.test.mjs +5 -2
  315. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  316. package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
  317. package/clients/cli/commands/theme-remove.doc.mjs +22 -0
  318. package/clients/cli/commands/theme-template.doc.mjs +4 -3
  319. package/clients/cli/commands/theme-use.doc.mjs +22 -0
  320. package/clients/cli/commands/theme.doc.mjs +21 -16
  321. package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
  322. package/clients/cli/commands/upgrade.mjs +1 -1
  323. package/clients/cli/index.mjs +5 -2
  324. package/clients/cli/lib/component-format.mjs +29 -2
  325. package/clients/cli/lib/component-format.test.mjs +1 -1
  326. package/clients/cli/lib/define-command.mjs +4 -0
  327. package/clients/cli/lib/resolve-theme.mjs +80 -78
  328. package/clients/cli/lib/resolve-theme.test.mjs +523 -27
  329. package/foundation/agent-docs/agent-docs.mjs +48 -30
  330. package/foundation/agent-docs/agent-docs.test.mjs +47 -34
  331. package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
  332. package/foundation/config/project.d.mts +20 -5
  333. package/foundation/config/project.mjs +43 -6
  334. package/foundation/config/project.test.mjs +1 -1
  335. package/foundation/config/theme-private-vars.d.mts +12 -0
  336. package/foundation/config/theme-private-vars.mjs +107 -0
  337. package/foundation/config/theme-private-vars.test.mjs +55 -0
  338. package/foundation/config/theme-state.d.mts +145 -0
  339. package/foundation/config/theme-state.mjs +417 -0
  340. package/foundation/config/theme-state.test.mjs +182 -0
  341. package/foundation/discovery/component-discovery.d.mts +5 -2
  342. package/foundation/discovery/component-discovery.mjs +12 -6
  343. package/foundation/discovery/component-replacement.d.mts +91 -0
  344. package/foundation/discovery/component-replacement.mjs +417 -0
  345. package/foundation/discovery/component-replacement.test.mjs +480 -0
  346. package/foundation/discovery/docs-discovery.test.mjs +1 -1
  347. package/foundation/discovery/docs-output-budget.d.mts +6 -2
  348. package/foundation/discovery/docs-output-budget.mjs +2 -1
  349. package/foundation/discovery/docs-section-key.d.mts +4 -2
  350. package/foundation/discovery/docs-section-key.mjs +1 -1
  351. package/foundation/discovery/module-exports.d.mts +10 -0
  352. package/foundation/discovery/module-exports.mjs +146 -0
  353. package/foundation/discovery/package-exports.d.mts +29 -0
  354. package/foundation/discovery/package-exports.mjs +200 -0
  355. package/foundation/discovery/template-needs.d.mts +31 -0
  356. package/foundation/discovery/template-needs.mjs +156 -0
  357. package/foundation/discovery/template-needs.test.mjs +203 -0
  358. package/foundation/discovery/theme-discovery.d.mts +72 -5
  359. package/foundation/discovery/theme-discovery.mjs +134 -18
  360. package/foundation/discovery/theme-discovery.test.mjs +9 -3
  361. package/foundation/discovery/theme-imports.d.mts +15 -0
  362. package/foundation/discovery/theme-imports.mjs +217 -0
  363. package/foundation/discovery/theme-imports.test.mjs +173 -0
  364. package/foundation/doc-compiler/bundle.mjs +52 -1
  365. package/foundation/doc-compiler/doc-loads.test.mjs +15 -5
  366. package/foundation/doc-compiler/inputs.mjs +2 -1
  367. package/foundation/doc-compiler/lenses.d.mts +4 -2
  368. package/foundation/doc-compiler/lenses.mjs +1 -1
  369. package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
  370. package/foundation/doc-compiler/tree.d.mts +10 -0
  371. package/foundation/doc-compiler/tree.mjs +22 -0
  372. package/foundation/doc-compiler/tree.test.mjs +3 -2
  373. package/foundation/env/package-manager.d.mts +31 -8
  374. package/foundation/env/package-manager.mjs +120 -13
  375. package/foundation/env/package-manager.test.mjs +174 -1
  376. package/foundation/fs/module-loader.d.mts +9 -0
  377. package/foundation/fs/module-loader.mjs +71 -2
  378. package/foundation/integrations/cli-requirement.d.mts +43 -10
  379. package/foundation/integrations/cli-requirement.mjs +56 -13
  380. package/foundation/integrations/cli-requirement.test.mjs +160 -23
  381. package/foundation/integrations/contribution-inventory.mjs +3 -3
  382. package/foundation/integrations/validate-contributions.d.mts +16 -0
  383. package/foundation/integrations/validate-contributions.mjs +56 -8
  384. package/foundation/response/base.d.ts +9 -3
  385. package/foundation/response/json.d.mts +7 -4
  386. package/foundation/response/json.mjs +10 -6
  387. package/foundation/response/response-types.doc.mjs +41 -26
  388. package/foundation/response/response.doc.mjs +18 -4
  389. package/foundation/text/copyright-header.mjs +1 -1
  390. package/foundation/text/copyright-header.test.mjs +1 -1
  391. package/package.json +9 -9
  392. package/assets/docs/layout.doc.dense.mjs +0 -388
  393. package/assets/docs/layout.doc.mjs +0 -550
  394. package/assets/docs/styling-libraries.doc.mjs +0 -469
  395. package/assets/docs/styling.doc.mjs +0 -412
  396. package/assets/docs/tokens.doc.dense.mjs +0 -15
  397. package/assets/docs/tokens.doc.mjs +0 -1491
  398. package/assets/docs/tokens.doc.zh.mjs +0 -15
  399. package/assets/docs/typography.doc.mjs +0 -286
@@ -54,6 +54,13 @@
54
54
  * description hold both words of `troubleshoot integration` answers it better
55
55
  * than a doc named `integration`.
56
56
  *
57
+ * Between domains, ranking adds one rule ahead of the score: domain priority
58
+ * (see {@link domainPriority}). A component, hook, template, or theme whose
59
+ * name or keyword a query word hits ranks ahead of every doc the reader did not
60
+ * ask for by name or title, so `font size` finds `Text` before a typography
61
+ * topic that declares the phrase. A doc the query names, or whose title the
62
+ * query holds, keeps its place.
63
+ *
57
64
  * Description and guidance are separate tiers on purpose. A component's own
58
65
  * one-line description saying "notification" is a claim about what it IS; the
59
66
  * same word inside another component's best-practice advice is a passing
@@ -80,12 +87,16 @@ import {
80
87
  findComponentReadme,
81
88
  resolveImportPath,
82
89
  resolveIntegrationImportPath,
90
+ CORE_PACKAGE,
83
91
  } from '../../foundation/discovery/component-discovery.mjs';
84
92
  import {
85
93
  discoverHooks,
86
94
  findHookDoc,
87
95
  } from '../../foundation/discovery/hook-discovery.mjs';
88
- import {loadIntegrationsSafely} from '../component/_adapter.mjs';
96
+ import {
97
+ loadComponentReplacements,
98
+ loadIntegrationsSafely,
99
+ } from '../component/_adapter.mjs';
89
100
  import {levenshteinDistance} from '../../foundation/text/string-utils.mjs';
90
101
  import {discoverTemplates, extractComponents} from '../template/template.mjs';
91
102
  import {templateLookupIds} from '../../foundation/discovery/template-adapter.mjs';
@@ -130,9 +141,9 @@ import {setResultCoverage} from './coverage.mjs';
130
141
  * @property {string} [_command] - The command that reads exactly this doc part.
131
142
  * @property {string} [_parent] - The command that opens the level above a doc
132
143
  * part: its topic's section list, or the docs-tree namespace it sits in.
133
- * @property {string} [_package] - The npm package that authored a docs-tree
134
- * doc part. Flat topics carry none: an extension's sections can come from
135
- * another package.
144
+ * @property {string} [_package] - The npm package that owns the candidate:
145
+ * Core's package for its components, hooks, and templates, the integration's
146
+ * for what it contributed, and for a doc part the package that wrote it.
136
147
  * @property {string} [_displayName]
137
148
  * @property {'page'|'block'} [_kind]
138
149
  * @property {string} [_resultName]
@@ -472,13 +483,110 @@ const FULL_COVERAGE_SCORE = 151;
472
483
  */
473
484
  const STRONG_TOKEN_SCORE = 70;
474
485
 
486
+ /**
487
+ * A match's domain priority: 0 (none), 1, or 2 (a doc the whole query names).
488
+ * A component, hook, template, or theme with priority ranks ahead of any doc
489
+ * without it, whatever the two scores are. Docs among themselves rank by
490
+ * priority, then score; everything else ranks among itself by score.
491
+ *
492
+ * A component, hook, template, or theme has priority (1) when one of the
493
+ * query's words, or the whole query, hits its name or an authored keyword at
494
+ * {@link STRONG_TOKEN_SCORE} or above, or when it matches every word.
495
+ *
496
+ * A doc has priority when the reader asked for that doc:
497
+ * - 2: the whole query is the topic's name, its last route segment, or its
498
+ * own title, as words and whatever the plural (`font setup` is
499
+ * typography/font-setup, `side panel` is "Side panels");
500
+ * - 1: a word of the query is the topic's name (`illustration` in a longer
501
+ * question is the illustrations guide);
502
+ * - 1: the query holds one of the doc's titles whole (`resizable side panels`
503
+ * names "Side panels"; `light dark mode button` names "Light/Dark Mode");
504
+ * - 1: the doc matches every word of the query and one of them is a word of
505
+ * its title (`switch to a dark theme` and "Use a theme").
506
+ * A section answers to its topic's name.
507
+ *
508
+ * A doc that matched only by keyword, by a heading holding the query, or by
509
+ * words spread through its text has no priority. Docs are split into many
510
+ * small topics, and each declares its own keywords and headings, so a common
511
+ * phrase such as `font size` hits a guide's keyword or heading exactly
512
+ * (170-190) while the component the reader is after matches one word by
513
+ * keyword (`Text`, 98). Ranked on text alone, every split adds another doc
514
+ * above the component. Broad reference pages match every word of many queries
515
+ * in their text the same way. The score stays the text-match strength the
516
+ * result reports, so callers that gate on it (`build`) see the same numbers.
517
+ *
518
+ * @param {string} term - Lowercased search term.
519
+ * @param {string[]} tokens - Content tokens from tokenizeQuery(term).
520
+ * @param {Candidate} candidate
521
+ * @param {{score: number, matched: number, total: number}} hit - The
522
+ * candidate's scoreQuery result.
523
+ * @returns {0 | 1 | 2}
524
+ */
525
+ export function domainPriority(term, tokens, candidate, hit) {
526
+ const words = [term, ...tokens];
527
+ if (candidate.domain === 'doc') {
528
+ const topic = String(candidate._topic ?? candidate.name).toLowerCase();
529
+ // The whole query, read as words, is the topic's route, its last
530
+ // segment, or its own title, whatever the plural: `side panel` is
531
+ // layout/side-panels, and `header and footer` is "Headers and footers".
532
+ // A section's title is a heading inside a topic, not the topic's name.
533
+ const named = [topic, topic.slice(topic.lastIndexOf('/') + 1)];
534
+ if (candidate._section == null && candidate.titles?.[0]) {
535
+ named.push(candidate.titles[0]);
536
+ }
537
+ if (named.some(n => samePhrase(term, n))) {
538
+ return 2;
539
+ }
540
+ if (
541
+ words.some(
542
+ w =>
543
+ (scoreCandidate(w, {name: topic}, {fuzzy: false})?.score ?? 0) >= 95,
544
+ )
545
+ ) {
546
+ return 1;
547
+ }
548
+ // A whole title inside the query is the only path to 160-169.
549
+ if (hit.score >= TITLE_IN_QUERY_SCORE && hit.score < TITLE_PHRASE_SCORE) {
550
+ return 1;
551
+ }
552
+ // Every word matched, and one of them names the doc in its title.
553
+ if (
554
+ hit.score >= FULL_COVERAGE_SCORE &&
555
+ hit.score < TITLE_IN_QUERY_SCORE &&
556
+ hit.matched === hit.total
557
+ ) {
558
+ const titleWords = phraseWords(candidate.titles?.[0] ?? '');
559
+ if (
560
+ (tokens.length ? tokens : [term]).some(t =>
561
+ titleWords.some(w => samePhraseWord(t, w) || sameWord(t, w)),
562
+ )
563
+ ) {
564
+ return 1;
565
+ }
566
+ }
567
+ return 0;
568
+ }
569
+ if (hit.score >= FULL_COVERAGE_SCORE) return 1;
570
+ const fuzzy = tokens.length <= 1;
571
+ return words.some(
572
+ w =>
573
+ (bestForToken(w, candidate, {fuzzy})?.score ?? 0) >= STRONG_TOKEN_SCORE,
574
+ )
575
+ ? 1
576
+ : 0;
577
+ }
578
+
475
579
  /**
476
580
  * The words of a title or query, lowercased, without punctuation or code ticks.
477
581
  * @param {string} text
478
582
  * @returns {string[]}
479
583
  */
480
584
  function phraseWords(text) {
481
- return unlinkText(text).toLowerCase().match(/[a-z0-9]+/g) ?? [];
585
+ return (
586
+ unlinkText(text)
587
+ .toLowerCase()
588
+ .match(/[a-z0-9]+/g) ?? []
589
+ );
482
590
  }
483
591
 
484
592
  /**
@@ -497,6 +605,24 @@ function samePhraseWord(a, b) {
497
605
  );
498
606
  }
499
607
 
608
+ /**
609
+ * Whether two phrases are the same words, in order, ignoring case,
610
+ * punctuation, and a plural on any word: `side panel` is "Side panels", and
611
+ * `headers and footers` is `header-and-footer`.
612
+ * @param {string} a
613
+ * @param {string} b
614
+ * @returns {boolean}
615
+ */
616
+ function samePhrase(a, b) {
617
+ const x = phraseWords(a);
618
+ const y = phraseWords(b);
619
+ return (
620
+ x.length > 0 &&
621
+ x.length === y.length &&
622
+ x.every((w, k) => samePhraseWord(w, y[k]) || sameWord(w, y[k]))
623
+ );
624
+ }
625
+
500
626
  /**
501
627
  * Whether `plural` is the plural of `word`: `integrations` of `integration`,
502
628
  * `boxes` of `box`. `es` only follows s, x, z, ch, or sh, so `notes` is not a
@@ -675,9 +801,7 @@ export function scoreQuery(term, tokens, candidate) {
675
801
  score:
676
802
  FULL_COVERAGE_SCORE +
677
803
  Math.min(
678
- Math.floor(
679
- (tokenSum - matched * MIN_TOKEN_SCORE) / (matched * 5),
680
- ),
804
+ Math.floor((tokenSum - matched * MIN_TOKEN_SCORE) / (matched * 5)),
681
805
  8,
682
806
  ),
683
807
  reason,
@@ -967,6 +1091,7 @@ async function gatherCoreComponents(coreDir) {
967
1091
  keywords,
968
1092
  description,
969
1093
  guidance,
1094
+ _package: CORE_PACKAGE,
970
1095
  _import: resolveImportPath(coreDir, comp),
971
1096
  });
972
1097
  }
@@ -980,11 +1105,10 @@ async function gatherCoreComponents(coreDir) {
980
1105
  * this, an integration component is invisible to `search`/`build` even
981
1106
  * though `component --list`/`component <Name>` already resolve it — the two
982
1107
  * discovery paths silently disagreed.
983
- * @param {string} cwd
1108
+ * @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
984
1109
  * @returns {Promise<Candidate[]>}
985
1110
  */
986
- async function gatherIntegrationComponents(cwd) {
987
- const loadedIntegrations = await loadIntegrationsSafely(cwd);
1111
+ async function gatherIntegrationComponents(loadedIntegrations) {
988
1112
  /** @type {Candidate[]} */
989
1113
  const candidates = [];
990
1114
  for (const integration of loadedIntegrations) {
@@ -997,6 +1121,7 @@ async function gatherIntegrationComponents(cwd) {
997
1121
  keywords: doc && Array.isArray(doc.keywords) ? doc.keywords : [],
998
1122
  description: doc ? doc.usage?.description || doc.description || '' : '',
999
1123
  guidance: guidanceFrom(doc),
1124
+ _package: rec.package ?? integration.name,
1000
1125
  // Exactly what `component` reports: a doc may state its own specifier
1001
1126
  // (one entry point exporting several components), and only when it
1002
1127
  // does not do we resolve the subpath against the owning package's
@@ -1028,11 +1153,40 @@ async function gatherIntegrationComponents(cwd) {
1028
1153
  * @returns {Promise<Candidate[]>}
1029
1154
  */
1030
1155
  async function gatherComponents(coreDir, cwd) {
1031
- const [core, integrations] = await Promise.all([
1156
+ const loadedIntegrations = await loadIntegrationsSafely(cwd);
1157
+ const [core, integrations, replacements] = await Promise.all([
1032
1158
  gatherCoreComponents(coreDir),
1033
- gatherIntegrationComponents(cwd),
1159
+ gatherIntegrationComponents(loadedIntegrations),
1160
+ loadComponentReplacements(coreDir, loadedIntegrations),
1034
1161
  ]);
1035
- return [...core, ...integrations];
1162
+ // An active replacement answers to the Core name it replaces, so a search
1163
+ // for that name finds the replacement and not the Core original
1164
+ // (spec:AST-035 FR11).
1165
+ /** @type {Map<string, string>} */
1166
+ const targetOf = new Map(
1167
+ replacements.active.map(active => [
1168
+ `${active.package}\0${active.name}`,
1169
+ active.target,
1170
+ ]),
1171
+ );
1172
+ return [
1173
+ ...core.filter(candidate => !replacements.forTarget(candidate.name)),
1174
+ ...integrations.map(candidate => {
1175
+ const target = targetOf.get(`${candidate._package}\0${candidate.name}`);
1176
+ if (target != null) {
1177
+ return {...candidate, aliases: [...(candidate.aliases ?? []), target]};
1178
+ }
1179
+ // Another package's component named after a replaced Core component is
1180
+ // shadowed for the bare name (FR14): its command names its package.
1181
+ const shadowedBy = replacements.forTarget(candidate.name);
1182
+ return shadowedBy && shadowedBy.package !== candidate._package
1183
+ ? {
1184
+ ...candidate,
1185
+ _command: `astryx component ${candidate.name} --package ${candidate._package}`,
1186
+ }
1187
+ : candidate;
1188
+ }),
1189
+ ];
1036
1190
  }
1037
1191
 
1038
1192
  /**
@@ -1076,19 +1230,24 @@ export async function componentKeywords(coreDir, cwd) {
1076
1230
  : null;
1077
1231
  return {name, keywords: keywordsOf(doc)};
1078
1232
  });
1079
- const integrations = (await loadIntegrationsSafely(cwd)).map(
1080
- async integration => {
1081
- const {components} = await discoverValidIntegrationComponents(integration);
1082
- return Promise.all(
1083
- components.map(async rec => ({
1084
- name: rec.name,
1085
- keywords: keywordsOf(await loadModuleDoc(rec.docPath)),
1086
- })),
1087
- );
1088
- },
1233
+ const loadedIntegrations = await loadIntegrationsSafely(cwd);
1234
+ const replacements = await loadComponentReplacements(
1235
+ coreDir,
1236
+ loadedIntegrations,
1089
1237
  );
1238
+ const integrations = loadedIntegrations.map(async integration => {
1239
+ const {components} = await discoverValidIntegrationComponents(integration);
1240
+ return Promise.all(
1241
+ components.map(async rec => ({
1242
+ name: rec.name,
1243
+ keywords: keywordsOf(await loadModuleDoc(rec.docPath)),
1244
+ })),
1245
+ );
1246
+ });
1090
1247
  return [
1091
- ...(await Promise.all(core)),
1248
+ ...(await Promise.all(core)).filter(
1249
+ component => !replacements.forTarget(component.name),
1250
+ ),
1092
1251
  ...(await Promise.all(integrations)).flat(),
1093
1252
  ];
1094
1253
  }
@@ -1123,6 +1282,7 @@ async function gatherHooks(coreDir) {
1123
1282
  name: hookName,
1124
1283
  keywords,
1125
1284
  description,
1285
+ _package: CORE_PACKAGE,
1126
1286
  _import: importPath,
1127
1287
  });
1128
1288
  }
@@ -1179,7 +1339,11 @@ async function gatherDocs(cwd) {
1179
1339
  const packages = new Map([
1180
1340
  [entry.providerId ?? entry.package, entry.package],
1181
1341
  ...entry.extensions.map(
1182
- ext => /** @type {[string, string]} */ ([ext.providerId ?? ext.package, ext.package]),
1342
+ ext =>
1343
+ /** @type {[string, string]} */ ([
1344
+ ext.providerId ?? ext.package,
1345
+ ext.package,
1346
+ ]),
1183
1347
  ),
1184
1348
  ]);
1185
1349
  candidates.push(
@@ -1257,7 +1421,8 @@ async function gatherDocs(cwd) {
1257
1421
  _topic: node.route,
1258
1422
  _title: path.join(' › '),
1259
1423
  _command: `astryx docs ${node.route}`,
1260
- _parent: node.parent == null ? 'astryx docs' : `astryx docs ${node.parent}`,
1424
+ _parent:
1425
+ node.parent == null ? 'astryx docs' : `astryx docs ${node.parent}`,
1261
1426
  _package: node.provider,
1262
1427
  });
1263
1428
  }
@@ -1421,7 +1586,9 @@ function topicCandidates(
1421
1586
  _title: `${docTitle} › ${section.title}`,
1422
1587
  _command: `astryx docs ${name} ${key}`,
1423
1588
  _parent: `astryx docs ${name} --index`,
1424
- ...((sectionPackage?.(key) ?? pkg) ? {_package: sectionPackage?.(key) ?? pkg} : {}),
1589
+ ...((sectionPackage?.(key) ?? pkg)
1590
+ ? {_package: sectionPackage?.(key) ?? pkg}
1591
+ : {}),
1425
1592
  });
1426
1593
  }
1427
1594
  return out;
@@ -1484,6 +1651,7 @@ async function gatherTemplates(cwd) {
1484
1651
  // short idea is not a direct match.
1485
1652
  prose: t.keywords ?? [],
1486
1653
  _displayName: t.name,
1654
+ _package: t.package ?? CORE_PACKAGE,
1487
1655
  _kind: t.type, // 'page' | 'block'
1488
1656
  _resultName: t.dirName,
1489
1657
  _commandName: commandName,
@@ -1536,6 +1704,7 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
1536
1704
  const base = {
1537
1705
  domain: c.domain,
1538
1706
  name: c._resultName ?? c.name,
1707
+ package: c._package,
1539
1708
  score,
1540
1709
  reason,
1541
1710
  description: c.description || '',
@@ -1546,7 +1715,7 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
1546
1715
  result = {
1547
1716
  ...base,
1548
1717
  import: c._import,
1549
- command: `astryx component ${c.name}`,
1718
+ command: c._command ?? `astryx component ${c.name}`,
1550
1719
  };
1551
1720
  break;
1552
1721
  case 'hook':
@@ -1566,7 +1735,6 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
1566
1735
  title: c._title,
1567
1736
  command: c._command ?? `astryx docs ${c.name}`,
1568
1737
  ...(c._parent ? {parent: c._parent} : {}),
1569
- ...(c._package ? {package: c._package} : {}),
1570
1738
  };
1571
1739
  break;
1572
1740
  case 'template':
@@ -1581,8 +1749,7 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
1581
1749
  result = {
1582
1750
  ...base,
1583
1751
  displayName: c._displayName,
1584
- command: `astryx theme add ${c.name}`,
1585
- ...(c._package ? {package: c._package} : {}),
1752
+ command: `astryx theme add --import ${c.name}`,
1586
1753
  };
1587
1754
  break;
1588
1755
  default:
@@ -1669,24 +1836,61 @@ export async function search(query, options = {}) {
1669
1836
  // role (page / block / component) and takes the top of each, so there's no
1670
1837
  // cross-role competition to engineer — a target page only needs to be the
1671
1838
  // strongest PAGE, not outrank every component.
1672
- const scored = [];
1839
+ /** @type {{result: any, priority: 0 | 1 | 2}[]} */
1840
+ const ranked = [];
1673
1841
  for (const candidate of all) {
1674
1842
  const hit = scoreQuery(term, tokens, candidate);
1675
1843
  if (hit)
1676
- scored.push(
1677
- toResult(candidate, hit.score, hit.reason, hit.matched, hit.total),
1678
- );
1844
+ ranked.push({
1845
+ result: toResult(
1846
+ candidate,
1847
+ hit.score,
1848
+ hit.reason,
1849
+ hit.matched,
1850
+ hit.total,
1851
+ ),
1852
+ priority: domainPriority(term, tokens, candidate, hit),
1853
+ });
1679
1854
  }
1680
1855
 
1681
- // Sort by score desc, then domain (stable order), then name.
1856
+ // Docs and everything else are each sorted by score desc, then domain
1857
+ // (stable order), then name. The two are merged: at each step the stronger
1858
+ // head goes next, except that a head with domain priority goes ahead of a
1859
+ // doc head without it (see domainPriority). Each side keeps its own order.
1682
1860
  /** @type {Record<string, number>} */
1683
1861
  const domainOrder = {component: 0, hook: 1, doc: 2, template: 3, theme: 4};
1684
- scored.sort(
1685
- (a, b) =>
1686
- b.score - a.score ||
1687
- (domainOrder[a.domain] ?? 9) - (domainOrder[b.domain] ?? 9) ||
1688
- a.name.localeCompare(b.name),
1689
- );
1862
+ /**
1863
+ * @param {{result: any}} x
1864
+ * @param {{result: any}} y
1865
+ */
1866
+ const byScore = ({result: a}, {result: b}) =>
1867
+ b.score - a.score ||
1868
+ (domainOrder[a.domain] ?? 9) - (domainOrder[b.domain] ?? 9) ||
1869
+ a.name.localeCompare(b.name);
1870
+ const others = ranked.filter(r => r.result.domain !== 'doc').sort(byScore);
1871
+ // Against other domains, a doc the reader asked for competes ahead of docs
1872
+ // they did not, so it is not held behind a broad page that outscores it.
1873
+ // Docs alone keep their text-match order, with a doc the whole query names
1874
+ // first.
1875
+ const docs = ranked
1876
+ .filter(r => r.result.domain === 'doc')
1877
+ .sort((x, y) =>
1878
+ others.length > 0
1879
+ ? y.priority - x.priority || byScore(x, y)
1880
+ : Number(y.priority === 2) - Number(x.priority === 2) || byScore(x, y),
1881
+ );
1882
+ const scored = [];
1883
+ let i = 0;
1884
+ let j = 0;
1885
+ while (i < others.length || j < docs.length) {
1886
+ const other = others[i];
1887
+ const doc = docs[j];
1888
+ const otherFirst =
1889
+ !doc ||
1890
+ (other != null &&
1891
+ ((other.priority && !doc.priority) || byScore(other, doc) < 0));
1892
+ scored.push(otherFirst ? others[i++].result : docs[j++].result);
1893
+ }
1690
1894
 
1691
1895
  // `results` is bounded by `limit` so a caller (and the recorded run that
1692
1896
  // quotes it) never carries an unbounded payload. `matchCount` is the number
@@ -367,7 +367,11 @@ describe('search leaf — a whole-query phrase in a title or heading is top tier
367
367
  it('puts the dark mode section first for a docs search', async () => {
368
368
  for (const query of ['dark mode', 'how do I add dark mode']) {
369
369
  const r = await search(query, {cwd, type: 'doc'});
370
- expect(r.data.results[0]).toMatchObject({name: 'theme', section: 'light-dark-mode'});
370
+ // The topic-level hit and the section can tie; either is correct.
371
+ const top = r.data.results[0];
372
+ const hasDarkMode = top.section === 'light-dark-mode' ||
373
+ top.name === 'use-a-theme' || top.name === 'theme';
374
+ expect(hasDarkMode).toBe(true);
371
375
  }
372
376
  }, SLOW);
373
377
  });
@@ -30,7 +30,7 @@ export type SearchResultEntry = {
30
30
  */
31
31
  description: string;
32
32
  /**
33
- * - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add neutral` for a theme).
33
+ * - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add --import neutral` for a theme).
34
34
  */
35
35
  command: string;
36
36
  /**
@@ -46,9 +46,9 @@ export type SearchResultEntry = {
46
46
  */
47
47
  section?: string | undefined;
48
48
  /**
49
- * - The npm package that authored a doc result (for a section, the package whose file the section came from), or that ships a theme result.
49
+ * - The npm package that owns the result: `@astryxdesign/core` for a Core component, hook, or template, `@astryxdesign/cli` for a doc the CLI ships, or the integration package that contributed it. For a doc section, the package whose file the section came from.
50
50
  */
51
- package?: string | undefined;
51
+ package: string;
52
52
  /**
53
53
  * - Command that opens the level above a doc result — its topic's section list for a section, the docs-tree namespace it sits in for a tree node — so a reader can see the siblings and open another.
54
54
  */
@@ -20,11 +20,11 @@
20
20
  * @property {number} score - Relevance score (higher is better).
21
21
  * @property {string} reason - Human-readable reason the candidate matched (e.g. `keyword "button"`).
22
22
  * @property {string} description - One-line description, when available.
23
- * @property {string} command - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add neutral` for a theme).
23
+ * @property {string} command - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add --import neutral` for a theme).
24
24
  * @property {string} [import] - Import path — present for component and hook results.
25
25
  * @property {string} [title] - Doc title — present for doc results.
26
26
  * @property {string} [section] - Section key — present when a doc result is one section of a topic; `command` reads only that section.
27
- * @property {string} [package] - The npm package that authored a doc result (for a section, the package whose file the section came from), or that ships a theme result.
27
+ * @property {string} package - The npm package that owns the result: `@astryxdesign/core` for a Core component, hook, or template, `@astryxdesign/cli` for a doc the CLI ships, or the integration package that contributed it. For a doc section, the package whose file the section came from.
28
28
  * @property {string} [parent] - Command that opens the level above a doc result — its topic's section list for a section, the docs-tree namespace it sits in for a tree node — so a reader can see the siblings and open another.
29
29
  * @property {string} [displayName] - Friendly display name — present for template and theme results.
30
30
  * @property {'page' | 'block'} [kind] - Template kind (`page` | `block`) — present for template results.
@@ -1,6 +1,15 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * The integration component that replaces the Core component `name`
6
+ * (spec:AST-035 FR11), or undefined when none does.
7
+ * @param {string} coreDir
8
+ * @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
9
+ * @param {string} name
10
+ * @returns {Promise<import('../../foundation/discovery/component-replacement.mjs').ActiveComponentReplacement | undefined>}
11
+ */
12
+ export function resolveComponentReplacement(coreDir: string, loadedIntegrations: import("../../foundation/integrations/integrations.mjs").LoadedIntegration[], name: string): Promise<import("../../foundation/discovery/component-replacement.mjs").ActiveComponentReplacement | undefined>;
4
13
  /**
5
14
  * Locate @astryxdesign/core for `cwd` and list its swizzlable components.
6
15
  * @param {string} cwd
@@ -10,3 +19,4 @@ export function resolveCore(cwd: string): {
10
19
  coreDir: string;
11
20
  components: string[];
12
21
  };
22
+ export { CORE_PROVIDER_ID as CORE_PACKAGE } from "../../foundation/identity/providers.mjs";
@@ -12,9 +12,32 @@
12
12
  */
13
13
 
14
14
  import {findCoreDir, listComponents} from '../../foundation/fs/paths.mjs';
15
+ import {resolveComponentReplacements} from '../../foundation/discovery/component-replacement.mjs';
15
16
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
16
17
  import {AstryxError} from '../error.mjs';
17
18
 
19
+ /** The package that owns Core's components, hooks, and codemods. */
20
+ export {CORE_PROVIDER_ID as CORE_PACKAGE} from '../../foundation/identity/providers.mjs';
21
+
22
+ /**
23
+ * The integration component that replaces the Core component `name`
24
+ * (spec:AST-035 FR11), or undefined when none does.
25
+ * @param {string} coreDir
26
+ * @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
27
+ * @param {string} name
28
+ * @returns {Promise<import('../../foundation/discovery/component-replacement.mjs').ActiveComponentReplacement | undefined>}
29
+ */
30
+ export async function resolveComponentReplacement(
31
+ coreDir,
32
+ loadedIntegrations,
33
+ name,
34
+ ) {
35
+ if (loadedIntegrations.length === 0) return undefined;
36
+ return (
37
+ await resolveComponentReplacements(coreDir, loadedIntegrations)
38
+ ).forTarget(name);
39
+ }
40
+
18
41
  /**
19
42
  * Locate @astryxdesign/core for `cwd` and list its swizzlable components.
20
43
  * @param {string} cwd
@@ -17,12 +17,11 @@
17
17
  * - Asset files (`.json`, `.css`): exported by full subpath (e.g.
18
18
  * `./locales/*.json`, `./reset.css`), and collapsing a two-levels-up
19
19
  * `../../locales/x.json` would emit the invalid `<pkg>/..`.
20
- * - The theme StyleX token module (`../theme/tokens.stylex`): the StyleX
21
- * compiler needs the real module, which core ships as the dedicated
22
- * `./theme/tokens.stylex` export (the in-repo charts consumer imports it
23
- * by that exact subpath). Other `.stylex` files (e.g. a component-local
24
- * `../Layer/layerAnimations.stylex`) are NOT exported by subpath, so they
25
- * keep the barrel collapse.
20
+ * - StyleX modules (`*.stylex`): the StyleX compiler needs the real module
21
+ * path so it can resolve the styles at compile time. The barrel re-export
22
+ * loses the module identity. Core exports every `.stylex` file by its
23
+ * deep subpath (e.g. `./utils/focusOutline.stylex`,
24
+ * `./theme/tokens.stylex`).
26
25
  *
27
26
  * @param {string} content
28
27
  * @param {string} [ownerPackage]
@@ -15,7 +15,7 @@
15
15
 
16
16
  import * as fs from 'node:fs';
17
17
  import * as path from 'node:path';
18
- import {resolveCore} from '../_adapter.mjs';
18
+ import {resolveComponentReplacement, resolveCore} from '../_adapter.mjs';
19
19
  import {assertWithin, sanitizeName, PathSafetyError} from '../../../foundation/fs/path-safety.mjs';
20
20
  import {checkGhCli} from '../_github.mjs';
21
21
  import {Project} from '../../../foundation/config/project.mjs';
@@ -46,12 +46,11 @@ const DEFAULT_ISSUES_URL = 'https://github.com/facebook/astryx/issues/new';
46
46
  * - Asset files (`.json`, `.css`): exported by full subpath (e.g.
47
47
  * `./locales/*.json`, `./reset.css`), and collapsing a two-levels-up
48
48
  * `../../locales/x.json` would emit the invalid `<pkg>/..`.
49
- * - The theme StyleX token module (`../theme/tokens.stylex`): the StyleX
50
- * compiler needs the real module, which core ships as the dedicated
51
- * `./theme/tokens.stylex` export (the in-repo charts consumer imports it
52
- * by that exact subpath). Other `.stylex` files (e.g. a component-local
53
- * `../Layer/layerAnimations.stylex`) are NOT exported by subpath, so they
54
- * keep the barrel collapse.
49
+ * - StyleX modules (`*.stylex`): the StyleX compiler needs the real module
50
+ * path so it can resolve the styles at compile time. The barrel re-export
51
+ * loses the module identity. Core exports every `.stylex` file by its
52
+ * deep subpath (e.g. `./utils/focusOutline.stylex`,
53
+ * `./theme/tokens.stylex`).
55
54
  *
56
55
  * @param {string} content
57
56
  * @param {string} [ownerPackage]
@@ -67,8 +66,8 @@ export function rewriteImports(content, ownerPackage = CORE_PACKAGE) {
67
66
  if (/\.(?:json|css)$/.test(last)) {
68
67
  return `${ownerPackage}/${rest}`;
69
68
  }
70
- // The theme token module is a dedicated deep StyleX export.
71
- if (parts[0] === 'theme' && /\.stylex(?:\.[cm]?[jt]sx?)?$/.test(last)) {
69
+ // StyleX modules need the deep path so the compiler can resolve them.
70
+ if (/\.stylex(?:\.[cm]?[jt]sx?)?$/.test(last)) {
72
71
  return `${ownerPackage}/${rest}`;
73
72
  }
74
73
  return `${ownerPackage}/${parts[0]}`;
@@ -221,6 +220,26 @@ export async function swizzleCopy(component, options = {}) {
221
220
  const coreIssuesUrl = project
222
221
  ? project.issuesUrl({package: CORE_PACKAGE})
223
222
  : undefined;
223
+ // An active integration replacement answers to the Core name it replaces,
224
+ // bare or qualified by its own package (spec:AST-035 FR11): copy it under its
225
+ // own name. `--package @astryxdesign/core` still copies the Core original.
226
+ if (pkg !== CORE_PACKAGE) {
227
+ const replacement = await resolveComponentReplacement(
228
+ coreDir,
229
+ loadedIntegrations,
230
+ dirName,
231
+ );
232
+ if (
233
+ replacement &&
234
+ (!pkg || (pkg === replacement.package && replacement.name !== dirName))
235
+ ) {
236
+ return swizzleCopy(replacement.name, {
237
+ ...options,
238
+ package: replacement.package,
239
+ });
240
+ }
241
+ }
242
+
224
243
  const allOwners = resolveOwners(coreDir, loadedIntegrations, dirName, coreIssuesUrl);
225
244
 
226
245
  if (allOwners.length === 0) {
@@ -359,7 +378,7 @@ export async function swizzleCopy(component, options = {}) {
359
378
  usesStyleX,
360
379
  };
361
380
  if (feedback) data.feedback = feedback;
362
- return {type: 'swizzle.copy', data};
381
+ return {type: 'swizzle.copy', package: data.package, data};
363
382
  }
364
383
 
365
384
  /**
@@ -8,7 +8,7 @@
8
8
  * shared seam. All human prose / usage hints live in the CLI renderer.
9
9
  */
10
10
 
11
- import {resolveCore} from '../_adapter.mjs';
11
+ import {CORE_PACKAGE, resolveCore} from '../_adapter.mjs';
12
12
 
13
13
  /**
14
14
  * List swizzlable components discoverable from `cwd`'s @astryxdesign/core.
@@ -17,5 +17,5 @@ import {resolveCore} from '../_adapter.mjs';
17
17
  */
18
18
  export function swizzleList(cwd = process.cwd()) {
19
19
  const {components} = resolveCore(cwd);
20
- return {type: 'swizzle.list', data: components};
20
+ return {type: 'swizzle.list', package: CORE_PACKAGE, data: components};
21
21
  }