@astryxdesign/cli 0.1.8-canary.08a0957 → 0.1.8-canary.0db5dfd

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 (325) hide show
  1. package/{src/api → api/blog}/blog.mjs +42 -6
  2. package/{src/api → api/blog}/blog.test.mjs +2 -2
  3. package/api/build/build.mjs +92 -0
  4. package/api/build/build.test.mjs +92 -0
  5. package/{src/api → api/component}/component.mjs +49 -26
  6. package/{src/api → api/discover}/discover.mjs +55 -18
  7. package/{src/api → api/docs}/docs.mjs +47 -21
  8. package/{src/api → api/doctor}/doctor.mjs +11 -8
  9. package/{src/api → api}/error.mjs +2 -2
  10. package/{src/api → api/hook}/hook.mjs +11 -11
  11. package/{src/api → api}/index.mjs +16 -9
  12. package/{src/api → api/integration}/validate-integration.mjs +48 -15
  13. package/{src/api → api/integration}/validate-integration.test.mjs +1 -1
  14. package/{src/api → api/layout}/layout.mjs +66 -17
  15. package/{src/api → api/layout}/layout.test.mjs +1 -1
  16. package/{src/api → api/search}/search.mjs +71 -12
  17. package/api/swizzle/swizzle.mjs +283 -0
  18. package/{src/commands → api/swizzle}/swizzle.test.mjs +26 -1
  19. package/{src/api → api/template}/template-integration.test.mjs +2 -2
  20. package/{src/api → api/template}/template-suffix.test.mjs +3 -3
  21. package/{src/api → api/template}/template.mjs +96 -19
  22. package/{src/api → api/theme}/theme-add.mjs +35 -7
  23. package/{src → authoring}/codemod.mjs +6 -6
  24. package/{src → authoring}/config.test.mjs +1 -1
  25. package/{src → authoring}/doc.mjs +1 -1
  26. package/{src → authoring}/doc.test.mjs +1 -1
  27. package/{src → authoring}/template.mjs +1 -1
  28. package/bin/astryx.mjs +12 -10
  29. package/{src → cli}/commands/blog.mjs +48 -7
  30. package/{src → cli}/commands/build-theme.mjs +125 -46
  31. package/{src → cli}/commands/build.mjs +33 -57
  32. package/{src → cli}/commands/component/index.mjs +49 -22
  33. package/{src → cli}/commands/component-ownership.test.mjs +3 -3
  34. package/{src → cli}/commands/component-package.test.mjs +1 -1
  35. package/{src → cli}/commands/component-resolution.test.mjs +2 -2
  36. package/{src → cli}/commands/discover.mjs +17 -8
  37. package/{src → cli}/commands/docs.mjs +39 -7
  38. package/{src → cli}/commands/docs.test.mjs +1 -1
  39. package/{src → cli}/commands/doctor.mjs +3 -3
  40. package/{src → cli}/commands/doctor.test.mjs +2 -2
  41. package/{src → cli}/commands/ensure-core-built.mjs +3 -2
  42. package/{src → cli}/commands/external-showcase.test.mjs +1 -1
  43. package/{src → cli}/commands/hook/index.mjs +37 -14
  44. package/{src → cli}/commands/import-hint-correctness.test.mjs +1 -1
  45. package/{src → cli}/commands/init.mjs +20 -9
  46. package/{src → cli}/commands/layout.mjs +58 -18
  47. package/{src → cli}/commands/search.mjs +19 -12
  48. package/{src → cli}/commands/search.test.mjs +1 -1
  49. package/{src → cli}/commands/setup-nudge.test.mjs +1 -1
  50. package/cli/commands/swizzle.mjs +103 -0
  51. package/{src → cli}/commands/template.mjs +73 -22
  52. package/{src → cli}/commands/template.path-safety.test.mjs +2 -2
  53. package/{src → cli}/commands/upgrade.integration-policy.test.mjs +1 -1
  54. package/{src → cli}/commands/upgrade.mjs +160 -52
  55. package/{src → cli}/commands/upgrade.test.mjs +1 -1
  56. package/{src → cli}/commands/validate-integration.mjs +17 -37
  57. package/{src → cli}/index.mjs +17 -15
  58. package/{src/codemods → codemods}/ensure-jscodeshift.mjs +1 -1
  59. package/{src/codemods → codemods}/integration-discovery.mjs +6 -3
  60. package/{src/codemods → codemods}/integration-discovery.test.mjs +1 -1
  61. package/{src/codemods → codemods}/integration-runner.mjs +8 -3
  62. package/{src/codemods → codemods}/registry.mjs +3 -1
  63. package/{src/codemods → codemods}/run-codemod.mjs +17 -10
  64. package/{src/codemods → codemods}/runner.mjs +22 -12
  65. package/{src/codemods → codemods}/transforms/v0.0.10/remove-size-props.mjs +9 -4
  66. package/{src/codemods → codemods}/transforms/v0.0.12/add-is-icon-only.mjs +27 -22
  67. package/{src/codemods → codemods}/transforms/v0.0.13/icon-name-deprecations.mjs +12 -5
  68. package/{src/codemods → codemods}/transforms/v0.0.13/rename-attachments-to-drawer.mjs +15 -8
  69. package/{src/codemods → codemods}/transforms/v0.0.13/toolbar-density-to-size.mjs +10 -4
  70. package/{src/codemods → codemods}/transforms/v0.0.14/rename-action-props.mjs +11 -5
  71. package/{src/codemods → codemods}/transforms/v0.0.14/rename-section-wash-to-muted.mjs +11 -6
  72. package/{src/codemods → codemods}/transforms/v0.0.14/rename-status-variants.mjs +15 -10
  73. package/{src/codemods → codemods}/transforms/v0.0.15/migrate-item-children-to-endcontent.mjs +13 -8
  74. package/{src/codemods → codemods}/transforms/v0.0.15/migrate-selector-children-to-render-option.mjs +18 -13
  75. package/{src/codemods → codemods}/transforms/v0.0.15/migrate-theme-selectors-to-data-attrs.mjs +8 -4
  76. package/{src/codemods → codemods}/transforms/v0.0.15/rename-date-picker-to-input.mjs +11 -6
  77. package/{src/codemods → codemods}/transforms/v0.0.15/rename-imperative-ref-to-handleRef.mjs +6 -1
  78. package/{src/codemods → codemods}/transforms/v0.0.15/rename-isStreaming-to-isStopShown.mjs +6 -1
  79. package/{src/codemods → codemods}/transforms/v0.0.15/rename-stack-element-to-as.mjs +8 -3
  80. package/{src/codemods → codemods}/transforms/v0.0.2/migrate-badge-dot-to-statusdot.mjs +17 -10
  81. package/{src/codemods → codemods}/transforms/v0.0.2/migrate-gap-to-numeric.mjs +7 -1
  82. package/{src/codemods → codemods}/transforms/v0.0.2/migrate-isFullBleed-to-padding.mjs +9 -4
  83. package/{src/codemods → codemods}/transforms/v0.0.2/migrate-useXDSIcon-to-getIcon.mjs +12 -7
  84. package/{src/codemods → codemods}/transforms/v0.0.2/rename-banner-endButton-to-endContent.mjs +7 -2
  85. package/{src/codemods → codemods}/transforms/v0.0.2/rename-form-tooltip-startIcon.mjs +8 -2
  86. package/{src/codemods → codemods}/transforms/v0.0.2/rename-isShown-to-isOpen.mjs +7 -2
  87. package/{src/codemods → codemods}/transforms/v0.0.2/rename-selector-items-to-options.mjs +7 -2
  88. package/{src/codemods → codemods}/transforms/v0.0.2/rename-sidenav-header-to-heading.mjs +11 -4
  89. package/{src/codemods → codemods}/transforms/v0.0.2/rename-topnav-title-to-heading.mjs +10 -4
  90. package/{src/codemods → codemods}/transforms/v0.0.2/unify-uncontrolled-to-defaultX.mjs +7 -2
  91. package/{src/codemods → codemods}/transforms/v0.0.2/unify-visibility-to-onOpenChange.mjs +10 -5
  92. package/{src/codemods → codemods}/transforms/v0.0.6/migrate-badge-children-to-label.mjs +7 -2
  93. package/{src/codemods → codemods}/transforms/v0.0.6/migrate-collapse-to-collapsible.mjs +9 -3
  94. package/{src/codemods → codemods}/transforms/v0.0.6/migrate-radius-tokens.mjs +11 -5
  95. package/{src/codemods → codemods}/transforms/v0.0.6/migrate-shadow-tokens.mjs +13 -6
  96. package/{src/codemods → codemods}/transforms/v0.0.6/migrate-skeleton-radius.mjs +7 -1
  97. package/{src/codemods → codemods}/transforms/v0.0.6/migrate-token-names.mjs +11 -5
  98. package/{src/codemods → codemods}/transforms/v0.0.7/rename-banner-variant-to-container.mjs +8 -3
  99. package/{src/codemods → codemods}/transforms/v0.0.8/migrate-token-renames.mjs +15 -8
  100. package/{src/codemods → codemods}/transforms/v0.0.8/rename-endslot-to-endcontent.mjs +7 -2
  101. package/{src/codemods → codemods}/transforms/v0.1.0/drop-xds-prefix-imports.mjs +19 -14
  102. package/{src/codemods → codemods}/transforms/v0.1.0/migrate-xds-css-surfaces.mjs +21 -17
  103. package/{src/codemods → codemods}/transforms/v0.1.0/migrate-xds-declare-module.mjs +7 -2
  104. package/{src/codemods → codemods}/transforms/v0.1.0/migrate-xds-module-specifiers.mjs +16 -11
  105. package/{src/codemods → codemods}/transforms/v0.1.2/rename-text-color-active-to-accent.mjs +15 -9
  106. package/{src/codemods → codemods}/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs +17 -12
  107. package/{src/codemods → codemods}/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +15 -9
  108. package/{src/codemods → codemods}/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +17 -10
  109. package/{src/codemods → codemods}/transforms/v0.1.7/rename-table-renderprops-styles-to-xstyle.mjs +18 -13
  110. package/{src/codemods → codemods}/transforms/v0.1.8/rename-avatar-size-scale.mjs +15 -10
  111. package/docs/elevation.doc.mjs +79 -1
  112. package/docs/internationalization.doc.mjs +92 -46
  113. package/{src/commands → lib/agent-docs}/agent-docs.mjs +30 -11
  114. package/{src/commands → lib/agent-docs}/agent-docs.path-safety.test.mjs +1 -1
  115. package/{src/lib → lib}/cli-error.mjs +2 -2
  116. package/{src/lib → lib}/component-discovery.mjs +44 -2
  117. package/{src/lib → lib}/component-format.mjs +65 -24
  118. package/{src/lib → lib}/component-loader.mjs +27 -13
  119. package/{src/lib → lib}/componentDocOverlay.test.mjs +0 -1
  120. package/{src/lib → lib}/error-codes.test.mjs +1 -1
  121. package/{src/lib → lib}/hook-discovery.mjs +14 -1
  122. package/{src/lib → lib}/hook-format.mjs +29 -5
  123. package/{src/lib → lib}/integration-warnings.mjs +2 -2
  124. package/{src/lib → lib}/integrations.mjs +20 -0
  125. package/{src/lib → lib}/integrations.test.mjs +1 -1
  126. package/{src/lib → lib}/json-contract.test.mjs +1 -1
  127. package/{src/lib → lib}/json-shim.mjs +11 -6
  128. package/{src/lib → lib}/json-shim.test.mjs +1 -1
  129. package/{src/lib → lib}/json.mjs +3 -3
  130. package/{src/lib → lib}/levenshtein.mjs +6 -0
  131. package/{src/lib → lib}/manifest.mjs +7 -5
  132. package/{src/lib → lib}/manifest.test.mjs +2 -2
  133. package/{src/lib → lib}/module-loader.mjs +1 -0
  134. package/{src/lib → lib}/package-scanner.mjs +47 -0
  135. package/{src/lib → lib}/project.mjs +48 -18
  136. package/{src/lib → lib}/project.test.mjs +1 -1
  137. package/{src/lib → lib}/resolve-theme.mjs +5 -0
  138. package/{src/lib → lib}/string-utils.mjs +15 -0
  139. package/{src/lib → lib}/term-log.mjs +12 -3
  140. package/{src/lib → lib}/xle/browser.mjs +18 -8
  141. package/{src/lib → lib}/xle/expand.mjs +155 -22
  142. package/{src/lib → lib}/xle/parse.mjs +119 -13
  143. package/{src/lib → lib}/xle/print.mjs +54 -14
  144. package/{src/lib → lib}/xle/registry-core.mjs +28 -3
  145. package/{src/lib → lib}/xle/registry.mjs +9 -4
  146. package/{src/lib → lib}/xle/splice.mjs +13 -2
  147. package/{src/lib → lib}/xle/validate.mjs +95 -14
  148. package/lib/xle/xle-ast.d.ts +214 -0
  149. package/package.json +35 -27
  150. package/scripts/postinstall.mjs +4 -4
  151. package/templates/blocks/components/Avatar/AvatarShowcase.tsx +1 -1
  152. package/templates/blocks/components/Banner/BannerFloating.doc.mjs +14 -0
  153. package/templates/blocks/components/Banner/BannerFloating.tsx +16 -0
  154. package/templates/blocks/components/Button/ButtonFloating.doc.mjs +14 -0
  155. package/templates/blocks/components/Button/ButtonFloating.tsx +37 -0
  156. package/templates/blocks/components/ButtonGroup/ButtonGroupFloating.doc.mjs +14 -0
  157. package/templates/blocks/components/ButtonGroup/ButtonGroupFloating.tsx +23 -0
  158. package/templates/blocks/components/Card/CardElevations.doc.mjs +14 -0
  159. package/templates/blocks/components/Card/CardElevations.tsx +32 -0
  160. package/templates/blocks/components/Card/ClickableCardElevated.doc.mjs +14 -0
  161. package/templates/blocks/components/Card/ClickableCardElevated.tsx +21 -0
  162. package/templates/blocks/components/Card/SelectableCardElevated.doc.mjs +14 -0
  163. package/templates/blocks/components/Card/SelectableCardElevated.tsx +37 -0
  164. package/templates/blocks/components/ChatComposer/ChatComposerFlat.doc.mjs +14 -0
  165. package/templates/blocks/components/ChatComposer/ChatComposerFlat.tsx +75 -0
  166. package/templates/blocks/components/IconButton/IconButtonFloating.doc.mjs +14 -0
  167. package/templates/blocks/components/IconButton/IconButtonFloating.tsx +37 -0
  168. package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.doc.mjs +19 -0
  169. package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +46 -0
  170. package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.doc.mjs +14 -0
  171. package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.tsx +33 -0
  172. package/templates/blocks/components/OverflowList/OverflowListCappedToolbar.doc.mjs +14 -0
  173. package/templates/blocks/components/OverflowList/OverflowListCappedToolbar.tsx +39 -0
  174. package/templates/blocks/components/OverflowList/OverflowListMultiRowTags.doc.mjs +14 -0
  175. package/templates/blocks/components/OverflowList/OverflowListMultiRowTags.tsx +44 -0
  176. package/templates/blocks/components/Thumbnail/ThumbnailElevated.doc.mjs +14 -0
  177. package/templates/blocks/components/Thumbnail/ThumbnailElevated.tsx +31 -0
  178. package/{src/types → types}/api.contract.assert.ts +17 -8
  179. package/{src/types → types}/api.d.ts +110 -9
  180. package/{src/types → types}/base.d.ts +40 -4
  181. package/types/build.d.ts +53 -0
  182. package/types/codemod.d.ts +166 -0
  183. package/{src/types → types}/component.d.ts +1 -1
  184. package/{src/types → types}/discover.d.ts +1 -1
  185. package/{src/types → types}/docs.d.ts +1 -4
  186. package/{src/types → types}/hook.d.ts +1 -1
  187. package/{src/types → types}/index.d.ts +1 -0
  188. package/types/jscodeshift.d.ts +19 -0
  189. package/types/layout.d.ts +74 -0
  190. package/{src/types → types}/swizzle.d.ts +4 -0
  191. package/types/theme.d.ts +53 -0
  192. package/{src/types → types}/upgrade.d.ts +8 -1
  193. package/{src/utils → utils}/package-manager.mjs +30 -4
  194. package/{src/utils → utils}/paths.mjs +4 -1
  195. package/{src/utils → utils}/update-check.mjs +3 -3
  196. package/{src/utils → utils}/update-check.test.mjs +3 -3
  197. package/src/commands/swizzle.mjs +0 -417
  198. package/src/types/codemod.d.ts +0 -81
  199. package/src/types/theme.d.ts +0 -23
  200. /package/{src/api → api/docs}/docOverlays.test.mjs +0 -0
  201. /package/{src/api → api/integration}/integration-block-exports.test.mjs +0 -0
  202. /package/{src/api → api/template}/template.test.mjs +0 -0
  203. /package/{src → authoring}/codemod.test.mjs +0 -0
  204. /package/{src → authoring}/config.mjs +0 -0
  205. /package/{src → authoring}/integration.mjs +0 -0
  206. /package/{src → authoring}/template.test.mjs +0 -0
  207. /package/{src → cli}/cli-exit-codes.test.mjs +0 -0
  208. /package/{src → cli}/commands/build-theme.color-scheme.test.mjs +0 -0
  209. /package/{src → cli}/commands/build-theme.import-path.test.mjs +0 -0
  210. /package/{src → cli}/commands/build-theme.path-safety.test.mjs +0 -0
  211. /package/{src → cli}/commands/build-theme.prose.test.mjs +0 -0
  212. /package/{src → cli}/commands/build-theme.variants.test.mjs +0 -0
  213. /package/{src → cli}/commands/build-theme.watch.test.mjs +0 -0
  214. /package/{src → cli}/commands/cli-postinstall.test.mjs +0 -0
  215. /package/{src → cli}/commands/component.test.mjs +0 -0
  216. /package/{src → cli}/commands/detail-levels.test.mjs +0 -0
  217. /package/{src → cli}/commands/init.next-steps.test.mjs +0 -0
  218. /package/{src → cli}/commands/interactive-guard.test.mjs +0 -0
  219. /package/{src → cli}/commands/json-contract.test.mjs +0 -0
  220. /package/{src → cli}/commands/swizzle.path-safety.test.mjs +0 -0
  221. /package/{src → cli}/commands/swizzle.routing.test.mjs +0 -0
  222. /package/{src → cli}/commands/template.test.mjs +0 -0
  223. /package/{src → cli}/commands/upgrade.config-ordering.test.mjs +0 -0
  224. /package/{src → cli}/commands/validate-integration.test.mjs +0 -0
  225. /package/{src → cli}/update-hint-commands.test.mjs +0 -0
  226. /package/{src/codemods → codemods}/__tests__/registry.test.mjs +0 -0
  227. /package/{src/codemods → codemods}/__tests__/rename-imperative-ref-to-handleRef.test.mjs +0 -0
  228. /package/{src/codemods → codemods}/__tests__/rename-isStreaming-to-isStopShown.test.mjs +0 -0
  229. /package/{src/codemods → codemods}/__tests__/rename-section-wash-to-muted.test.mjs +0 -0
  230. /package/{src/codemods → codemods}/__tests__/runner.test.mjs +0 -0
  231. /package/{src/codemods → codemods}/__tests__/toolbar-density-to-size.test.mjs +0 -0
  232. /package/{src/codemods → codemods}/__tests__/validation.test.mjs +0 -0
  233. /package/{src/codemods → codemods}/transforms/v0.0.10/__tests__/remove-size-props.test.mjs +0 -0
  234. /package/{src/codemods → codemods}/transforms/v0.0.10/index.mjs +0 -0
  235. /package/{src/codemods → codemods}/transforms/v0.0.12/__tests__/add-is-icon-only.test.mjs +0 -0
  236. /package/{src/codemods → codemods}/transforms/v0.0.12/index.mjs +0 -0
  237. /package/{src/codemods → codemods}/transforms/v0.0.13/__tests__/icon-name-deprecations.test.mjs +0 -0
  238. /package/{src/codemods → codemods}/transforms/v0.0.13/__tests__/rename-attachments-to-drawer.test.mjs +0 -0
  239. /package/{src/codemods → codemods}/transforms/v0.0.13/index.mjs +0 -0
  240. /package/{src/codemods → codemods}/transforms/v0.0.14/__tests__/rename-action-props.test.mjs +0 -0
  241. /package/{src/codemods → codemods}/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +0 -0
  242. /package/{src/codemods → codemods}/transforms/v0.0.14/index.mjs +0 -0
  243. /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/migrate-item-children-to-endcontent.test.mjs +0 -0
  244. /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/migrate-selector-children-to-render-option.test.mjs +0 -0
  245. /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/migrate-theme-selectors-to-data-attrs.test.mjs +0 -0
  246. /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/rename-date-picker-to-input.test.mjs +0 -0
  247. /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/rename-stack-element-to-as.test.mjs +0 -0
  248. /package/{src/codemods → codemods}/transforms/v0.0.15/index.mjs +0 -0
  249. /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-badge-dot-to-statusdot.test.mjs +0 -0
  250. /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-gap-to-numeric.test.mjs +0 -0
  251. /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-isFullBleed-to-padding.test.mjs +0 -0
  252. /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-useXDSIcon-to-getIcon.test.mjs +0 -0
  253. /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-banner-endButton-to-endContent.test.mjs +0 -0
  254. /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-form-tooltip-startIcon.test.mjs +0 -0
  255. /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-isShown-to-isOpen.test.mjs +0 -0
  256. /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-selector-items-to-options.test.mjs +0 -0
  257. /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-sidenav-header-to-heading.test.mjs +0 -0
  258. /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-topnav-title-to-heading.test.mjs +0 -0
  259. /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/unify-uncontrolled-to-defaultX.test.mjs +0 -0
  260. /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/unify-visibility-to-onOpenChange.test.mjs +0 -0
  261. /package/{src/codemods → codemods}/transforms/v0.0.2/index.mjs +0 -0
  262. /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-collapse-to-collapsible.test.mjs +0 -0
  263. /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-radius-tokens.test.mjs +0 -0
  264. /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-shadow-tokens.test.mjs +0 -0
  265. /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-skeleton-radius.test.mjs +0 -0
  266. /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-token-names.test.mjs +0 -0
  267. /package/{src/codemods → codemods}/transforms/v0.0.6/index.mjs +0 -0
  268. /package/{src/codemods → codemods}/transforms/v0.0.7/__tests__/rename-banner-variant-to-container.test.mjs +0 -0
  269. /package/{src/codemods → codemods}/transforms/v0.0.7/index.mjs +0 -0
  270. /package/{src/codemods → codemods}/transforms/v0.0.8/__tests__/migrate-token-renames.test.mjs +0 -0
  271. /package/{src/codemods → codemods}/transforms/v0.0.8/__tests__/rename-endslot-to-endcontent.test.mjs +0 -0
  272. /package/{src/codemods → codemods}/transforms/v0.0.8/index.mjs +0 -0
  273. /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/drop-xds-prefix-imports.test.mjs +0 -0
  274. /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs +0 -0
  275. /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/migrate-xds-declare-module.test.mjs +0 -0
  276. /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +0 -0
  277. /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/v0.1.0-ordering.test.mjs +0 -0
  278. /package/{src/codemods → codemods}/transforms/v0.1.0/index.mjs +0 -0
  279. /package/{src/codemods → codemods}/transforms/v0.1.2/__tests__/rename-text-color-active-to-accent.test.mjs +0 -0
  280. /package/{src/codemods → codemods}/transforms/v0.1.2/index.mjs +0 -0
  281. /package/{src/codemods → codemods}/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +0 -0
  282. /package/{src/codemods → codemods}/transforms/v0.1.3/index.mjs +0 -0
  283. /package/{src/codemods → codemods}/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -0
  284. /package/{src/codemods → codemods}/transforms/v0.1.5/index.mjs +0 -0
  285. /package/{src/codemods → codemods}/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -0
  286. /package/{src/codemods → codemods}/transforms/v0.1.7/__tests__/rename-table-renderprops-styles-to-xstyle.test.mjs +0 -0
  287. /package/{src/codemods → codemods}/transforms/v0.1.7/index.mjs +0 -0
  288. /package/{src/codemods → codemods}/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +0 -0
  289. /package/{src/codemods → codemods}/transforms/v0.1.8/index.mjs +0 -0
  290. /package/{src/commands → lib/agent-docs}/agent-docs.test.mjs +0 -0
  291. /package/{src/lib → lib}/cli-error.test.mjs +0 -0
  292. /package/{src/lib → lib}/component-discovery.importpath.test.mjs +0 -0
  293. /package/{src/lib → lib}/component-format.test.mjs +0 -0
  294. /package/{src/lib → lib}/component-loader.test.mjs +0 -0
  295. /package/{src/lib → lib}/config-cache.mjs +0 -0
  296. /package/{src/lib → lib}/config-cache.test.mjs +0 -0
  297. /package/{src/lib → lib}/config-schema.mjs +0 -0
  298. /package/{src/lib → lib}/error-codes.mjs +0 -0
  299. /package/{src/lib → lib}/integration-warnings.test.mjs +0 -0
  300. /package/{src/lib → lib}/module-loader.test.mjs +0 -0
  301. /package/{src/lib → lib}/node-version.mjs +0 -0
  302. /package/{src/lib → lib}/node-version.test.mjs +0 -0
  303. /package/{src/lib → lib}/parse.mjs +0 -0
  304. /package/{src/lib → lib}/site.mjs +0 -0
  305. /package/{src/lib → lib}/xle/browser.d.ts +0 -0
  306. /package/{src/lib → lib}/xle/xle.test.mjs +0 -0
  307. /package/{src/schemas → schemas}/doc-schema.mjs +0 -0
  308. /package/{src/schemas → schemas}/template-schema.mjs +0 -0
  309. /package/{src/types → types}/config.d.ts +0 -0
  310. /package/{src/types → types}/doc.d.ts +0 -0
  311. /package/{src/types → types}/doctor.d.ts +0 -0
  312. /package/{src/types → types}/error-codes.d.ts +0 -0
  313. /package/{src/types → types}/integration.d.ts +0 -0
  314. /package/{src/types → types}/manifest.d.ts +0 -0
  315. /package/{src/types → types}/search.d.ts +0 -0
  316. /package/{src/types → types}/template-api.d.ts +0 -0
  317. /package/{src/types → types}/template.d.ts +0 -0
  318. /package/{src/types → types}/validate-integration.d.ts +0 -0
  319. /package/{src/utils → utils}/github.mjs +0 -0
  320. /package/{src/utils → utils}/package-manager.test.mjs +0 -0
  321. /package/{src/utils → utils}/path-safety.mjs +0 -0
  322. /package/{src/utils → utils}/path-safety.test.mjs +0 -0
  323. /package/{src/utils → utils}/paths.test.mjs +0 -0
  324. /package/{src/utils → utils}/semver.mjs +0 -0
  325. /package/{src/utils → utils}/semver.test.mjs +0 -0
@@ -10,9 +10,9 @@
10
10
  * blog's structure can change freely without touching the CLI.
11
11
  */
12
12
 
13
- import {AstryxError} from './error.mjs';
14
- import {ERROR_CODES} from '../lib/error-codes.mjs';
15
- import {SITE_URL, SITE_ORIGIN} from '../lib/site.mjs';
13
+ import {AstryxError} from '../error.mjs';
14
+ import {ERROR_CODES} from '../../lib/error-codes.mjs';
15
+ import {SITE_URL, SITE_ORIGIN} from '../../lib/site.mjs';
16
16
 
17
17
  /** Abort a feed/post fetch that hangs, and cap how much we'll read. */
18
18
  const FETCH_TIMEOUT_MS = 15000;
@@ -20,6 +20,10 @@ const MAX_BYTES = 5 * 1024 * 1024; // 5 MB — a blog feed is never larger.
20
20
 
21
21
  const FEED_URL = new URL('/rss.xml', SITE_URL).toString();
22
22
 
23
+ /**
24
+ * @param {string} url
25
+ * @returns {Promise<string>}
26
+ */
23
27
  async function fetchText(url) {
24
28
  const controller = new AbortController();
25
29
  const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
@@ -31,7 +35,12 @@ async function fetchText(url) {
31
35
  });
32
36
  } catch (e) {
33
37
  clearTimeout(timer);
34
- const reason = e.name === 'AbortError' ? 'timed out' : e.message;
38
+ const reason =
39
+ e instanceof Error
40
+ ? e.name === 'AbortError'
41
+ ? 'timed out'
42
+ : e.message
43
+ : String(e);
35
44
  throw new AstryxError(
36
45
  `Could not reach ${url}: ${reason}`,
37
46
  [],
@@ -61,6 +70,7 @@ async function fetchText(url) {
61
70
  * Defense in depth: a post's plaintext URL comes from feed content. Require it
62
71
  * to live on the canonical origin so even a tampered feed can't redirect the
63
72
  * CLI to another host.
73
+ * @param {string} target
64
74
  */
65
75
  function assertCanonicalOrigin(target) {
66
76
  let targetOrigin;
@@ -82,6 +92,10 @@ function assertCanonicalOrigin(target) {
82
92
  }
83
93
  }
84
94
 
95
+ /**
96
+ * @param {string} value
97
+ * @returns {string}
98
+ */
85
99
  function unescapeXml(value) {
86
100
  return value
87
101
  .replace(/&lt;/g, '<')
@@ -91,12 +105,23 @@ function unescapeXml(value) {
91
105
  .replace(/&amp;/g, '&');
92
106
  }
93
107
 
108
+ /**
109
+ * @param {string} item
110
+ * @param {string} name
111
+ * @returns {string}
112
+ */
94
113
  function tag(item, name) {
95
114
  const m = item.match(new RegExp(`<${name}[^>]*>([\\s\\S]*?)</${name}>`));
96
115
  return m ? unescapeXml(m[1].trim()) : '';
97
116
  }
98
117
 
118
+ /**
119
+ * @param {string} item
120
+ * @param {string} name
121
+ * @returns {string[]}
122
+ */
99
123
  function tagAll(item, name) {
124
+ /** @type {string[]} */
100
125
  const out = [];
101
126
  const re = new RegExp(`<${name}[^>]*>([\\s\\S]*?)</${name}>`, 'g');
102
127
  let m;
@@ -104,7 +129,11 @@ function tagAll(item, name) {
104
129
  return out;
105
130
  }
106
131
 
107
- /** Extract the plaintext alternate href from an <item>. */
132
+ /**
133
+ * Extract the plaintext alternate href from an <item>.
134
+ * @param {string} item
135
+ * @returns {string | null}
136
+ */
108
137
  function textHref(item) {
109
138
  // Match the atom:link alternate regardless of attribute order/quoting; then
110
139
  // confirm it's the text/plain alternate before trusting the href.
@@ -121,7 +150,11 @@ function textHref(item) {
121
150
  return null;
122
151
  }
123
152
 
124
- /** Derive a slug from a post link (last path segment). */
153
+ /**
154
+ * Derive a slug from a post link (last path segment).
155
+ * @param {string} link
156
+ * @returns {string}
157
+ */
125
158
  function slugFromLink(link) {
126
159
  try {
127
160
  const path = new URL(link).pathname.replace(/\/$/, '');
@@ -131,6 +164,9 @@ function slugFromLink(link) {
131
164
  }
132
165
  }
133
166
 
167
+ /**
168
+ * @param {string} xml
169
+ */
134
170
  function parseFeed(xml) {
135
171
  const items = [];
136
172
  const re = /<item>([\s\S]*?)<\/item>/g;
@@ -9,8 +9,8 @@
9
9
 
10
10
  import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
11
11
  import {blog} from './blog.mjs';
12
- import {AstryxError} from './error.mjs';
13
- import {SITE_URL} from '../lib/site.mjs';
12
+ import {AstryxError} from '../error.mjs';
13
+ import {SITE_URL} from '../../lib/site.mjs';
14
14
 
15
15
  const FEED = `<?xml version="1.0" encoding="UTF-8"?>
16
16
  <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
@@ -0,0 +1,92 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file build API — the "assemble a page" assistant, as data.
5
+ *
6
+ * `build()` with no query signals the workflow playbook (`build.help`). With a
7
+ * query it runs the unified search and groups the results into a composition
8
+ * KIT (`build.kit`): the closest page templates, the blocks that cover parts,
9
+ * and the domain components to fill gaps, plus the always-on frame + foundation.
10
+ *
11
+ * The kit carries RAW `SearchResultEntry` objects and static name arrays only —
12
+ * never pre-formatted command strings. All CLI prefixing (formatCliCommand /
13
+ * getCliInvocation) and the section prose live in the command renderer, so the
14
+ * JSON shape stays package-manager-agnostic and stable across environments.
15
+ */
16
+
17
+ import {search} from '../search/search.mjs';
18
+
19
+ /** A page at/above this score is a confident direct match. */
20
+ const PAGE_DIRECT = 95;
21
+ /** Below this a page is too weak to offer even as a layout reference. */
22
+ const PAGE_FLOOR = 50;
23
+ /** Below this a block/domain-component match is incidental noise. */
24
+ const DOMAIN_FLOOR = 55;
25
+
26
+ /**
27
+ * Always-surfaced primitives. Every page needs a shell + layout/typography/
28
+ * action atoms, but these never keyword-match an idea ("dashboard" != "Stack"),
29
+ * so search alone never returns them. Kept here (not the renderer) because they
30
+ * are ALSO used to exclude these names from the idea-specific `domain` group.
31
+ */
32
+ const FRAME = ['AppShell', 'TopNav', 'SideNav', 'Layout'];
33
+ const FOUNDATION = [
34
+ 'VStack', 'HStack', 'Grid', 'StackItem', 'Card', 'Section',
35
+ 'Text', 'Heading', 'Button', 'Icon', 'Badge', 'Divider',
36
+ ];
37
+ const ALWAYS = new Set([...FRAME, ...FOUNDATION]);
38
+
39
+ /**
40
+ * The page-building assistant. No query → the playbook signal; a query → the
41
+ * grouped composition kit.
42
+ *
43
+ * @param {string} [query] what you're building (e.g. "analytics dashboard")
44
+ * @param {{cwd?: string, type?: import('../../types/search').SearchDomain, limit?: number}} [options]
45
+ * @returns {Promise<import('../../types/build').BuildHelpResponse | import('../../types/build').BuildKitResponse>}
46
+ */
47
+ export async function build(query, options = {}) {
48
+ if (!query || !String(query).trim()) {
49
+ return {type: 'build.help', data: {playbook: true}};
50
+ }
51
+
52
+ const {cwd = process.cwd(), type, limit = 60} = options;
53
+ // search()'s JSDoc @returns widens results to object[]; the SearchResponse
54
+ // shape is the contract (api.d.ts). Cast locally rather than tightening the
55
+ // search @returns (a separate follow-up).
56
+ const result = /** @type {import('../../types/search').SearchResponse} */ (
57
+ await search(query, {cwd, type, limit})
58
+ );
59
+ const results = result.data.results;
60
+
61
+ const pages = results
62
+ .filter(r => r.domain === 'template' && r.kind !== 'block' && r.score >= PAGE_FLOOR)
63
+ .slice(0, 3);
64
+ const blocks = results
65
+ .filter(r => r.domain === 'template' && r.kind === 'block' && r.score >= DOMAIN_FLOOR)
66
+ .slice(0, 5);
67
+ const domain = results
68
+ .filter(
69
+ r =>
70
+ (r.domain === 'component' || r.domain === 'hook') &&
71
+ r.score >= DOMAIN_FLOOR &&
72
+ !ALWAYS.has(r.name),
73
+ )
74
+ .slice(0, 6);
75
+ const directMatch = pages.length > 0 && pages[0].score >= PAGE_DIRECT;
76
+
77
+ return {
78
+ type: 'build.kit',
79
+ data: {
80
+ query: result.data.query,
81
+ // Distinguishes "search found nothing" (renderer shows "No matches")
82
+ // from a weak-but-non-empty result set (renderer still shows the kit).
83
+ hasResults: results.length > 0,
84
+ directMatch,
85
+ pages,
86
+ blocks,
87
+ domain,
88
+ frame: FRAME,
89
+ foundation: FOUNDATION,
90
+ },
91
+ };
92
+ }
@@ -0,0 +1,92 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Tests for the build API (playbook signal + composition kit).
5
+ */
6
+
7
+ import {describe, it, expect, vi} from 'vitest';
8
+ import * as path from 'node:path';
9
+ import {fileURLToPath} from 'node:url';
10
+ import {build} from './build.mjs';
11
+
12
+ // api/build/ -> up 3 = packages/cli, up 4 = repo root (has packages/core).
13
+ const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../..');
14
+
15
+ // build() delegates to search(), whose first (cold) call is slow under vitest.
16
+ vi.setConfig({testTimeout: 30000});
17
+
18
+ describe('build API', () => {
19
+ it('no query → build.help playbook signal', async () => {
20
+ const r = await build();
21
+ expect(r.type).toBe('build.help');
22
+ expect(r.data).toEqual({playbook: true});
23
+ });
24
+
25
+ it('query → build.kit with raw entries + static frame/foundation', async () => {
26
+ const r = await build('dashboard', {cwd: REPO});
27
+ expect(r.type).toBe('build.kit');
28
+ if (r.type !== 'build.kit') return;
29
+ expect(r.data.query).toBe('dashboard');
30
+ expect(r.data.hasResults).toBe(true);
31
+ expect(r.data.frame).toContain('AppShell');
32
+ expect(r.data.foundation).toContain('Button');
33
+ expect(Array.isArray(r.data.pages)).toBe(true);
34
+
35
+ // Entries are RAW SearchResultEntry objects — never package-manager-prefixed
36
+ // command strings (that formatting is the CLI renderer's job).
37
+ for (const e of [...r.data.pages, ...r.data.blocks, ...r.data.domain]) {
38
+ expect(typeof e.name).toBe('string');
39
+ expect(typeof e.score).toBe('number');
40
+ expect(e.command).not.toMatch(/^(pnpm|npm|yarn|bun|npx)\b/);
41
+ }
42
+ });
43
+
44
+ it('excludes always-on frame/foundation names from the domain group', async () => {
45
+ const r = await build('dashboard', {cwd: REPO});
46
+ if (r.type !== 'build.kit') throw new Error('expected build.kit');
47
+ const names = r.data.domain.map(d => d.name);
48
+ expect(names).not.toContain('Button');
49
+ expect(names).not.toContain('AppShell');
50
+ });
51
+
52
+ it('applies grouping caps, score floors, and directMatch threshold', async () => {
53
+ const r = await build('dashboard', {cwd: REPO});
54
+ if (r.type !== 'build.kit') throw new Error('expected build.kit');
55
+ const {pages, blocks, domain, directMatch} = r.data;
56
+
57
+ // Caps: pages ≤ 3, blocks ≤ 5, domain ≤ 6.
58
+ expect(pages.length).toBeLessThanOrEqual(3);
59
+ expect(blocks.length).toBeLessThanOrEqual(5);
60
+ expect(domain.length).toBeLessThanOrEqual(6);
61
+
62
+ // Score floors: pages ≥ PAGE_FLOOR(50); blocks/domain ≥ DOMAIN_FLOOR(55).
63
+ for (const p of pages) expect(p.score).toBeGreaterThanOrEqual(50);
64
+ for (const b of blocks) expect(b.score).toBeGreaterThanOrEqual(55);
65
+ for (const d of domain) expect(d.score).toBeGreaterThanOrEqual(55);
66
+
67
+ // directMatch iff the top page is a confident match (PAGE_DIRECT = 95).
68
+ expect(directMatch).toBe(pages.length > 0 && pages[0].score >= 95);
69
+
70
+ // Domain partitioning: pages = non-block templates, blocks = block templates,
71
+ // domain = components/hooks.
72
+ for (const p of pages) {
73
+ expect(p.domain).toBe('template');
74
+ expect(p.kind).not.toBe('block');
75
+ }
76
+ for (const b of blocks) {
77
+ expect(b.domain).toBe('template');
78
+ expect(b.kind).toBe('block');
79
+ }
80
+ for (const d of domain) expect(['component', 'hook']).toContain(d.domain);
81
+ });
82
+
83
+ it('no matches → build.kit with hasResults=false and empty groups', async () => {
84
+ const r = await build('zzznomatch99', {cwd: REPO});
85
+ expect(r.type).toBe('build.kit');
86
+ if (r.type !== 'build.kit') return;
87
+ expect(r.data.hasResults).toBe(false);
88
+ expect(r.data.pages).toHaveLength(0);
89
+ expect(r.data.blocks).toHaveLength(0);
90
+ expect(r.data.domain).toHaveLength(0);
91
+ });
92
+ });
@@ -9,8 +9,8 @@
9
9
 
10
10
  import * as fs from 'node:fs';
11
11
  import * as path from 'node:path';
12
- import {ERROR_CODES} from '../lib/error-codes.mjs';
13
- import {findCoreDir, discoverExternalPackages} from '../utils/paths.mjs';
12
+ import {ERROR_CODES} from '../../lib/error-codes.mjs';
13
+ import {findCoreDir, discoverExternalPackages} from '../../utils/paths.mjs';
14
14
  import {
15
15
  CORE_PACKAGE,
16
16
  discoverComponents,
@@ -22,24 +22,46 @@ import {
22
22
  findIntegrationComponentDoc,
23
23
  findIntegrationComponentSource,
24
24
  resolveImportPath,
25
- } from '../lib/component-discovery.mjs';
26
- import {Project} from '../lib/project.mjs';
27
- import {loadDocs} from '../lib/component-loader.mjs';
28
- import {searchComponents} from '../lib/string-utils.mjs';
29
- import {AstryxError} from './error.mjs';
30
- import {findShowcase, findRelatedBlocks} from './template.mjs';
25
+ } from '../../lib/component-discovery.mjs';
26
+ import {Project} from '../../lib/project.mjs';
27
+ import {loadDocs} from '../../lib/component-loader.mjs';
28
+ import {searchComponents} from '../../lib/string-utils.mjs';
29
+ import {AstryxError} from '../error.mjs';
30
+ import {findShowcase, findRelatedBlocks} from '../template/template.mjs';
31
+
32
+ /**
33
+ * A loaded component doc. `loadDocs` returns the authored `.doc.mjs` shape,
34
+ * which is either a single-component or multi-component doc; this loose view
35
+ * captures the fields the API reads across both forms.
36
+ * @typedef {object} LoadedComponentDoc
37
+ * @property {string} [name]
38
+ * @property {string} [description]
39
+ * @property {any[]} [props]
40
+ * @property {any[]} [components]
41
+ * @property {{description?: string}} [usage]
42
+ * @property {any} [theming]
43
+ */
44
+
45
+ /**
46
+ * Options object for `loadDocs`, matching its declared parameter shape (used
47
+ * as a cast target so `lang` (which the API may hold as `string|null`) type
48
+ * checks against `loadDocs`'s `lang?: string`).
49
+ * @typedef {{zh?: boolean, dense?: boolean, lang?: string}} LoadDocsOpts
50
+ */
31
51
 
32
52
  /**
33
53
  * Load the configured integrations for `cwd`, swallowing any config errors so
34
54
  * component discovery never hard-fails on a malformed/absent integration. An
35
55
  * empty list means "core only".
36
56
  * @param {string} cwd
37
- * @returns {Promise<Array<{name: string, components?: string, issuesUrl?: string}>>}
57
+ * @returns {Promise<import('../../lib/integrations.mjs').LoadedIntegration[]>}
38
58
  */
39
59
  async function loadIntegrationsSafely(cwd) {
40
60
  try {
41
61
  const project = await Project.load(cwd);
42
- return project.loadedIntegrations;
62
+ return /** @type {import('../../lib/integrations.mjs').LoadedIntegration[]} */ (
63
+ project.loadedIntegrations
64
+ );
43
65
  } catch {
44
66
  return [];
45
67
  }
@@ -47,7 +69,7 @@ async function loadIntegrationsSafely(cwd) {
47
69
 
48
70
  /**
49
71
  * Resolve a loaded integration by package name.
50
- * @param {Array<{name: string}>} loadedIntegrations
72
+ * @param {import('../../lib/integrations.mjs').LoadedIntegration[]} loadedIntegrations
51
73
  * @param {string} packageName
52
74
  */
53
75
  function findLoadedIntegration(loadedIntegrations, packageName) {
@@ -133,7 +155,7 @@ export async function component(name, options = {}) {
133
155
  const readme = findComponentReadme(coreDir, comp);
134
156
  if (readme && readme.endsWith('.doc.mjs')) {
135
157
  try {
136
- const docs = await loadDocs(readme, {zh, lang});
158
+ const docs = /** @type {LoadedComponentDoc} */ (await loadDocs(readme, /** @type {LoadDocsOpts} */ ({zh, lang})));
137
159
  entries.push({name: comp, description: docs.usage?.description || docs.description || '', import: resolveImportPath(coreDir, comp)});
138
160
  } catch {
139
161
  entries.push({name: comp, description: '', import: resolveImportPath(coreDir, comp)});
@@ -151,7 +173,7 @@ export async function component(name, options = {}) {
151
173
  const readme = findComponentReadme(coreDir, comp);
152
174
  if (readme && readme.endsWith('.doc.mjs')) {
153
175
  try {
154
- entries.push(await loadDocs(readme, {zh, lang, dense}));
176
+ entries.push(await loadDocs(readme, /** @type {LoadDocsOpts} */ ({zh, lang, dense})));
155
177
  } catch {
156
178
  entries.push({name: `XDS${comp}`, description: ''});
157
179
  }
@@ -173,7 +195,7 @@ export async function component(name, options = {}) {
173
195
 
174
196
  // All components — merge core + external packages with grouped subcategories
175
197
  if (detail === 'compact') {
176
- /** @type {Record<string, Array<import('../types/component').ComponentBriefEntry>>} */
198
+ /** @type {Record<string, Array<import('../../types/component').ComponentBriefEntry>>} */
177
199
  const result = {};
178
200
  for (const [cat, comps] of Object.entries(components)) {
179
201
  result[cat] = [];
@@ -181,7 +203,7 @@ export async function component(name, options = {}) {
181
203
  const readme = findComponentReadme(coreDir, comp);
182
204
  if (readme && readme.endsWith('.doc.mjs')) {
183
205
  try {
184
- const docs = await loadDocs(readme, {zh, lang});
206
+ const docs = /** @type {LoadedComponentDoc} */ (await loadDocs(readme, /** @type {LoadDocsOpts} */ ({zh, lang})));
185
207
  result[cat].push({name: comp, description: docs.usage?.description || docs.description || '', import: resolveImportPath(coreDir, comp)});
186
208
  } catch {
187
209
  result[cat].push({name: comp, description: '', import: resolveImportPath(coreDir, comp)});
@@ -203,7 +225,7 @@ export async function component(name, options = {}) {
203
225
  const readme = findComponentReadme(coreDir, comp);
204
226
  if (readme && readme.endsWith('.doc.mjs')) {
205
227
  try {
206
- result[cat].push(await loadDocs(readme, {zh, lang, dense}));
228
+ result[cat].push(await loadDocs(readme, /** @type {LoadDocsOpts} */ ({zh, lang, dense})));
207
229
  } catch {
208
230
  result[cat].push({name: `XDS${comp}`, description: ''});
209
231
  }
@@ -238,7 +260,7 @@ export async function component(name, options = {}) {
238
260
  const groupLabel = rec.group ?? integration.name;
239
261
  const key = `${groupLabel} (${integration.name})`;
240
262
  if (!byGroup.has(key)) byGroup.set(key, []);
241
- byGroup.get(key).push({name: rec.name, package: integration.name});
263
+ byGroup.get(key)?.push({name: rec.name, package: integration.name});
242
264
  }
243
265
  for (const [key, members] of byGroup) {
244
266
  members.sort((a, b) => a.name.localeCompare(b.name));
@@ -334,14 +356,14 @@ export async function component(name, options = {}) {
334
356
  * `package`, the resolved `import` specifier, and `sourceAvailable` (whether
335
357
  * a swizzleable source file exists for the owner). Existing doc fields
336
358
  * (name, usage, props, …) are preserved.
337
- * @param {object} docs
359
+ * @param {LoadedComponentDoc} docs
338
360
  * @param {{package: string, sourcePath: string|null}} owner
339
361
  * @param {string} componentName
340
362
  */
341
363
  function withOwnership(docs, owner, componentName) {
342
364
  const importSpec =
343
365
  owner.package === CORE_PACKAGE
344
- ? resolveImportPath(coreDir, componentName)
366
+ ? resolveImportPath(/** @type {string} */ (coreDir), componentName)
345
367
  : `${owner.package}/${componentName}`;
346
368
  return {
347
369
  ...docs,
@@ -368,7 +390,7 @@ export async function component(name, options = {}) {
368
390
  }
369
391
  return {type: 'component.detail.source', data: {component: dirName, source: fs.readFileSync(owner.sourcePath, 'utf-8')}};
370
392
  }
371
- const docs = await loadDocs(owner.docPath, {zh, dense, lang});
393
+ const docs = /** @type {LoadedComponentDoc} */ (await loadDocs(owner.docPath, /** @type {LoadDocsOpts} */ ({zh, dense, lang})));
372
394
  if (props) {
373
395
  const p = docs.props || (docs.components ? docs.components.flatMap(c => c.props || []) : []);
374
396
  return {type: 'component.detail.props', data: p};
@@ -389,7 +411,7 @@ export async function component(name, options = {}) {
389
411
  }
390
412
  return {type: 'component.detail.source', data: {component: dirName, source: fs.readFileSync(owner.sourcePath, 'utf-8')}};
391
413
  }
392
- const docs = await loadDocs(owner.docPath, {zh, dense, lang});
414
+ const docs = /** @type {LoadedComponentDoc} */ (await loadDocs(owner.docPath, /** @type {LoadDocsOpts} */ ({zh, dense, lang})));
393
415
  if (props) {
394
416
  const p = docs.props || (docs.components ? docs.components.flatMap(c => c.props || []) : []);
395
417
  return {type: 'component.detail.props', data: p};
@@ -420,7 +442,7 @@ export async function component(name, options = {}) {
420
442
 
421
443
  const extDocPath = findExternalComponentDoc(ext.docsDir, dirName);
422
444
  if (extDocPath && extDocPath.endsWith('.doc.mjs')) {
423
- const docs = await loadDocs(extDocPath, {zh, dense, lang});
445
+ const docs = /** @type {LoadedComponentDoc} */ (await loadDocs(extDocPath, /** @type {LoadDocsOpts} */ ({zh, dense, lang})));
424
446
 
425
447
  if (props) {
426
448
  const p = docs.props || (docs.components ? docs.components.flatMap(c => c.props || []) : []);
@@ -461,7 +483,7 @@ export async function component(name, options = {}) {
461
483
  if (showcase) {
462
484
  throw new AstryxError(`No showcase found for "${name}"`, undefined, ERROR_CODES.ERR_NO_SHOWCASE);
463
485
  }
464
- const docs = await loadDocs(owner.docPath, {zh, dense, lang});
486
+ const docs = /** @type {LoadedComponentDoc} */ (await loadDocs(owner.docPath, /** @type {LoadDocsOpts} */ ({zh, dense, lang})));
465
487
  if (props) {
466
488
  const p = docs.props || (docs.components ? docs.components.flatMap(c => c.props || []) : []);
467
489
  return {type: 'component.detail.props', data: p};
@@ -546,12 +568,12 @@ export async function component(name, options = {}) {
546
568
  throw new AstryxError(`No .doc.mjs found for "${resolvedName}". The component needs a typed doc file.`, undefined, ERROR_CODES.ERR_NO_DOC);
547
569
  }
548
570
 
549
- const docs = await loadDocs(readmePath, {zh, dense, lang});
571
+ const docs = /** @type {LoadedComponentDoc} */ (await loadDocs(readmePath, /** @type {LoadDocsOpts} */ ({zh, dense, lang})));
550
572
 
551
573
  // ── Blocks mode ──────────────────────────────────────────────
552
574
  if (blocks) {
553
575
  const allBlocks = await findRelatedBlocks(dirName);
554
- const toEntry = (b) => ({
576
+ const toEntry = (/** @type {any} */ b) => ({
555
577
  name: b.dirName,
556
578
  displayName: b.name,
557
579
  description: b.description,
@@ -561,7 +583,7 @@ export async function component(name, options = {}) {
561
583
 
562
584
  // Examples: blocks in the component's own directory, or
563
585
  // componentsUsed match for sub-components without a directory.
564
- const ownDir = allBlocks.filter(b => path.basename(b.category) === dirName);
586
+ const ownDir = allBlocks.filter((/** @type {any} */ b) => path.basename(b.category) === dirName);
565
587
  const examples = ownDir.length > 0
566
588
  ? ownDir
567
589
  : allBlocks.filter(b => b.componentsUsed?.some(c => c === dirName));
@@ -595,6 +617,7 @@ export async function component(name, options = {}) {
595
617
  : null;
596
618
 
597
619
  if (matchingComponent) {
620
+ /** @type {LoadedComponentDoc & {parentDoc?: string, import?: string}} */
598
621
  const scoped = {
599
622
  name: dirName,
600
623
  description: matchingComponent.description,
@@ -4,28 +4,37 @@
4
4
  * @file Programmatic API for the discover command.
5
5
  */
6
6
 
7
- import {Project} from '../lib/project.mjs';
7
+ import {Project} from '../../lib/project.mjs';
8
8
  import {
9
9
  scanAllPackages,
10
10
  findComponentInPackages,
11
- } from '../lib/package-scanner.mjs';
12
- import {loadDocs} from '../lib/component-loader.mjs';
13
- import {levenshteinDistance} from '../lib/string-utils.mjs';
14
- import {AstryxError} from './error.mjs';
15
- import {ERROR_CODES} from '../lib/error-codes.mjs';
11
+ } from '../../lib/package-scanner.mjs';
12
+ import {loadDocs} from '../../lib/component-loader.mjs';
13
+ import {levenshteinDistance} from '../../lib/string-utils.mjs';
14
+ import {AstryxError} from '../error.mjs';
15
+ import {ERROR_CODES} from '../../lib/error-codes.mjs';
16
16
 
17
+ /**
18
+ * @typedef {import('../../lib/package-scanner.mjs').ScannedPackage} ScannedPackage
19
+ */
20
+
21
+ /**
22
+ * @param {unknown} docs
23
+ * @returns {string | null}
24
+ */
17
25
  function validateDocs(docs) {
18
26
  if (!docs || typeof docs !== 'object')
19
27
  return 'docs export is missing or not an object';
20
- if (typeof docs.name !== 'string' || !docs.name)
28
+ const d = /** @type {Record<string, any>} */ (docs);
29
+ if (typeof d.name !== 'string' || !d.name)
21
30
  return 'docs.name is missing or not a string';
22
- if (!docs.usage || typeof docs.usage.description !== 'string')
31
+ if (!d.usage || typeof d.usage.description !== 'string')
23
32
  return 'docs.usage.description is missing or not a string';
24
- if (docs.props && !Array.isArray(docs.props))
33
+ if (d.props && !Array.isArray(d.props))
25
34
  return 'docs.props must be an array';
26
- if (docs.components && !Array.isArray(docs.components))
35
+ if (d.components && !Array.isArray(d.components))
27
36
  return 'docs.components must be an array';
28
- if (docs.usage?.bestPractices && !Array.isArray(docs.usage.bestPractices))
37
+ if (d.usage?.bestPractices && !Array.isArray(d.usage.bestPractices))
29
38
  return 'docs.usage.bestPractices must be an array';
30
39
  return null;
31
40
  }
@@ -36,11 +45,21 @@ function validateDocs(docs) {
36
45
  * @param {boolean} [options.components]
37
46
  * @param {string} [options.lang]
38
47
  * @param {boolean} [options.zh]
39
- * @returns {Promise<{type: string, data: unknown}>}
48
+ * @returns {Promise<
49
+ * import('../../types/discover').DiscoverListResponse |
50
+ * import('../../types/discover').DiscoverDetailResponse |
51
+ * import('../../types/discover').DiscoverDetailDocResponse |
52
+ * import('../../types/discover').DiscoverSearchResponse
53
+ * >}
40
54
  */
41
55
  export async function discover(query, options = {}) {
42
56
  const {lang = null, zh = false} = options;
43
57
  const project = await Project.load();
58
+ const loadedIntegrations =
59
+ /** @type {import('../../lib/integrations.mjs').LoadedIntegration[]} */ (
60
+ project.loadedIntegrations
61
+ );
62
+ /** @param {ScannedPackage} pkg */
44
63
  const toEntry = pkg => ({
45
64
  name: pkg.name,
46
65
  category: pkg.category,
@@ -52,7 +71,7 @@ export async function discover(query, options = {}) {
52
71
 
53
72
  // External packages come from configured integrations that declare a
54
73
  // components root. Each becomes a scannable package keyed by its docsDir.
55
- const explicitPackages = project.loadedIntegrations
74
+ const explicitPackages = loadedIntegrations
56
75
  .filter(integration => integration.components)
57
76
  .map(integration => ({
58
77
  name: integration.name,
@@ -64,7 +83,10 @@ export async function discover(query, options = {}) {
64
83
  return {type: 'discover.list', data: [], meta: {configured: false}};
65
84
  }
66
85
 
67
- const packages = scanAllPackages([], explicitPackages);
86
+ const packages = scanAllPackages(
87
+ [],
88
+ /** @type {ScannedPackage[]} */ (/** @type {unknown} */ (explicitPackages)),
89
+ );
68
90
 
69
91
  if (packages.length === 0) {
70
92
  return {type: 'discover.list', data: [], meta: {configured: true}};
@@ -105,7 +127,7 @@ export async function discover(query, options = {}) {
105
127
  return await loadAndValidate(exact, {lang, zh});
106
128
  }
107
129
 
108
- const substringMatches = [];
130
+ const substringMatches = /** @type {Array<{pkg: ScannedPackage, comp: string}>} */ ([]);
109
131
  for (const pkg of packages) {
110
132
  for (const comp of pkg.components) {
111
133
  if (comp.toLowerCase().includes(lower)) {
@@ -134,7 +156,7 @@ export async function discover(query, options = {}) {
134
156
  }
135
157
 
136
158
  // Fuzzy fallback
137
- const allComponents = [];
159
+ const allComponents = /** @type {Array<{pkg: ScannedPackage, comp: string}>} */ ([]);
138
160
  for (const pkg of packages) {
139
161
  for (const comp of pkg.components) {
140
162
  allComponents.push({pkg, comp});
@@ -167,6 +189,13 @@ export async function discover(query, options = {}) {
167
189
  );
168
190
  }
169
191
 
192
+ /**
193
+ * @param {ScannedPackage[]} packages
194
+ * @param {string} compName
195
+ * @param {string} pkgName
196
+ * @param {{lang?: string|null, zh?: boolean}} opts
197
+ * @returns {Promise<import('../../types/discover').DiscoverDetailDocResponse>}
198
+ */
170
199
  async function resolveComponentDocs(packages, compName, pkgName, {lang, zh}) {
171
200
  const pkg = packages.find(p => p.name === pkgName);
172
201
  if (!pkg)
@@ -202,13 +231,21 @@ async function resolveComponentDocs(packages, compName, pkgName, {lang, zh}) {
202
231
  return await loadAndValidate(result, {lang, zh});
203
232
  }
204
233
 
234
+ /**
235
+ * @param {{docPath: string, componentName: string, pkg: ScannedPackage}} result
236
+ * @param {{lang?: string|null, zh?: boolean}} opts
237
+ * @returns {Promise<import('../../types/discover').DiscoverDetailDocResponse>}
238
+ */
205
239
  async function loadAndValidate(result, {lang, zh}) {
206
240
  let docs;
207
241
  try {
208
- docs = await loadDocs(result.docPath, {zh, lang});
242
+ docs = await loadDocs(
243
+ result.docPath,
244
+ /** @type {{zh?: boolean, dense?: boolean, lang?: string}} */ ({zh, lang}),
245
+ );
209
246
  } catch (e) {
210
247
  throw new AstryxError(
211
- `Failed to load docs for ${result.componentName}: ${e.message}`,
248
+ `Failed to load docs for ${result.componentName}: ${/** @type {any} */ (e).message}`,
212
249
  undefined,
213
250
  ERROR_CODES.ERR_INVALID_DOC,
214
251
  );