@astryxdesign/cli 0.6.5 → 0.6.6-canary.e1dda17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (433) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +58 -55
  3. package/api/build/_adapter.d.mts +55 -2
  4. package/api/build/_adapter.mjs +100 -10
  5. package/api/build/build.doc.mjs +2 -2
  6. package/api/build/build.test.mjs +111 -2
  7. package/api/build/build.type.d.mts +8 -0
  8. package/api/build/build.type.mjs +2 -0
  9. package/api/build/kit/kit.mjs +99 -22
  10. package/api/build/kit/rank.d.mts +32 -8
  11. package/api/build/kit/rank.mjs +291 -97
  12. package/api/build/kit/rank.test.mjs +231 -48
  13. package/api/build/kit/weights.d.mts +82 -0
  14. package/api/build/kit/weights.json +1 -0
  15. package/api/build/kit/weights.mjs +305 -0
  16. package/api/build/kit/weights.test.mjs +190 -0
  17. package/api/component/_adapter.d.mts +19 -0
  18. package/api/component/_adapter.mjs +33 -0
  19. package/api/component/component-replacement.test.mjs +603 -0
  20. package/api/component/component.mjs +49 -15
  21. package/api/component/component.test.mjs +32 -0
  22. package/api/component/component.type.d.mts +33 -3
  23. package/api/component/component.type.mjs +10 -3
  24. package/api/component/detail/blocks/blocks.d.mts +2 -1
  25. package/api/component/detail/blocks/blocks.mjs +5 -2
  26. package/api/component/detail/detail.mjs +5 -1
  27. package/api/component/detail/props/props.d.mts +2 -1
  28. package/api/component/detail/props/props.mjs +3 -2
  29. package/api/component/detail/showcase/showcase.d.mts +3 -1
  30. package/api/component/detail/showcase/showcase.mjs +3 -1
  31. package/api/component/detail/source/source.d.mts +3 -2
  32. package/api/component/detail/source/source.mjs +7 -3
  33. package/api/component/list/list.mjs +128 -10
  34. package/api/docs/_adapter.d.mts +11 -0
  35. package/api/docs/_adapter.mjs +25 -0
  36. package/api/docs/detail/detail.mjs +19 -3
  37. package/api/docs/detail/section/section.mjs +7 -1
  38. package/api/docs/docOverlays.test.mjs +10 -6
  39. package/api/docs/docs.d.mts +6 -0
  40. package/api/docs/docs.depth.test.mjs +134 -0
  41. package/api/docs/docs.doc.mjs +31 -2
  42. package/api/docs/docs.mjs +46 -1
  43. package/api/docs/docs.test.mjs +279 -0
  44. package/api/docs/docs.type.d.mts +81 -4
  45. package/api/docs/docs.type.mjs +41 -4
  46. package/api/docs/index/index.mjs +11 -2
  47. package/api/docs/index/index.test.mjs +7 -2
  48. package/api/docs/integration-tree.test.mjs +572 -0
  49. package/api/docs/integrationDocs.test.mjs +337 -0
  50. package/api/docs/node/node.d.mts +28 -3
  51. package/api/docs/node/node.mjs +149 -23
  52. package/api/doctor/_adapter.d.mts +43 -0
  53. package/api/doctor/_adapter.mjs +142 -0
  54. package/api/doctor/doctor.d.mts +0 -10
  55. package/api/doctor/doctor.doc.mjs +1 -3
  56. package/api/doctor/doctor.mjs +6 -123
  57. package/api/doctor/theme-checks.d.mts +12 -0
  58. package/api/doctor/theme-checks.mjs +1117 -0
  59. package/api/doctor/theme-checks.test.mjs +526 -0
  60. package/api/error.d.mts +22 -0
  61. package/api/error.mjs +42 -0
  62. package/api/gap-report/gap-report.d.mts +3 -1
  63. package/api/gap-report/gap-report.mjs +27 -3
  64. package/api/gap-report/gap-report.test.mjs +106 -0
  65. package/api/hook/_adapter.d.mts +1 -0
  66. package/api/hook/_adapter.mjs +3 -0
  67. package/api/hook/detail/detail.mjs +2 -2
  68. package/api/hook/detail/params/params.mjs +2 -2
  69. package/api/hook/hook.type.d.mts +12 -0
  70. package/api/hook/hook.type.mjs +3 -0
  71. package/api/hook/list/list.d.mts +1 -1
  72. package/api/hook/list/list.mjs +8 -8
  73. package/api/index.d.mts +1 -1
  74. package/api/index.mjs +4 -0
  75. package/api/init/run/run.d.mts +3 -5
  76. package/api/init/run/run.mjs +10 -11
  77. package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
  78. package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
  79. package/api/integration/add-contribution.d.mts +2 -1
  80. package/api/integration/add-contribution.mjs +7 -3
  81. package/api/integration/add-contribution.test.mjs +3 -3
  82. package/api/integration/add-helpers.d.mts +26 -5
  83. package/api/integration/add-helpers.mjs +50 -5
  84. package/api/integration/add-theme.mjs +354 -28
  85. package/api/integration/add-theme.test.mjs +380 -16
  86. package/api/integration/authoring-checks.mjs +31 -8
  87. package/api/integration/authoring-checks.type.d.mts +8 -0
  88. package/api/integration/authoring-checks.type.mjs +7 -3
  89. package/api/integration/integration-authoring.type.d.mts +4 -1
  90. package/api/integration/integration-authoring.type.mjs +6 -1
  91. package/api/integration/integrationAdd.doc.mjs +6 -0
  92. package/api/integration/integrationAddTheme.doc.mjs +10 -0
  93. package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
  94. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  95. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
  96. package/api/integration/pack-check.component-replaces.test.mjs +126 -0
  97. package/api/integration/pack-check.d.mts +10 -0
  98. package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
  99. package/api/integration/pack-check.mjs +495 -4
  100. package/api/integration/pack-check.test.mjs +619 -10
  101. package/api/integration/validate-integration.d.mts +4 -2
  102. package/api/integration/validate-integration.mjs +7 -2
  103. package/api/integration/validate-integration.test.mjs +55 -0
  104. package/api/integration/validate-integration.type.d.mts +5 -0
  105. package/api/integration/validate-integration.type.mjs +5 -1
  106. package/api/integration/validateIntegration.doc.mjs +1 -1
  107. package/api/layout/expand/expand.mjs +12 -7
  108. package/api/layout/expand/expand.receipt.test.mjs +74 -0
  109. package/api/layout/layout.type.d.mts +1 -0
  110. package/api/layout/layout.type.mjs +1 -0
  111. package/api/layout/layoutExpand.doc.mjs +1 -1
  112. package/api/search/search.d.mts +39 -8
  113. package/api/search/search.doc.mjs +4 -4
  114. package/api/search/search.mjs +248 -66
  115. package/api/search/search.test.mjs +829 -0
  116. package/api/search/search.type.d.mts +6 -6
  117. package/api/search/search.type.mjs +5 -5
  118. package/api/swizzle/_adapter.d.mts +10 -0
  119. package/api/swizzle/_adapter.mjs +23 -0
  120. package/api/swizzle/copy/copy.d.mts +5 -6
  121. package/api/swizzle/copy/copy.mjs +95 -13
  122. package/api/swizzle/list/list.mjs +2 -2
  123. package/api/swizzle/swizzle.doc.mjs +4 -0
  124. package/api/swizzle/swizzle.test.mjs +55 -5
  125. package/api/swizzle/swizzle.type.d.mts +8 -0
  126. package/api/swizzle/swizzle.type.mjs +2 -0
  127. package/api/template/copy/copy.mjs +15 -8
  128. package/api/template/copy/copy.receipt.test.mjs +77 -0
  129. package/api/template/show/show.mjs +17 -4
  130. package/api/template/show/show.test.mjs +76 -0
  131. package/api/template/skeleton/skeleton.mjs +2 -1
  132. package/api/template/template-integration.test.mjs +14 -0
  133. package/api/template/template.d.mts +1 -1
  134. package/api/template/template.doc.mjs +6 -2
  135. package/api/template/template.mjs +2 -0
  136. package/api/template/template.type.d.mts +14 -0
  137. package/api/template/template.type.mjs +5 -0
  138. package/api/theme/_adapter.d.mts +106 -6
  139. package/api/theme/_adapter.mjs +687 -18
  140. package/api/theme/add/add.binary.test.mjs +76 -3
  141. package/api/theme/add/add.d.mts +5 -9
  142. package/api/theme/add/add.mjs +87 -64
  143. package/api/theme/add/add.rollback.test.mjs +9 -9
  144. package/api/theme/add/add.staging.test.mjs +9 -9
  145. package/api/theme/add/add.test.mjs +461 -55
  146. package/api/theme/add/add.types.test.mjs +151 -0
  147. package/api/theme/build/build.d.mts +50 -2
  148. package/api/theme/build/build.family.test.mjs +13 -4
  149. package/api/theme/build/build.icon-lineage.test.mjs +117 -0
  150. package/api/theme/build/build.icon-preservation.test.mjs +639 -0
  151. package/api/theme/build/build.mjs +463 -155
  152. package/api/theme/build/build.project-core.test.mjs +165 -0
  153. package/api/theme/build/build.test.mjs +220 -1
  154. package/api/theme/build/icon-imports.d.mts +47 -0
  155. package/api/theme/build/icon-imports.mjs +691 -0
  156. package/api/theme/eject/eject.binary.test.mjs +90 -0
  157. package/api/theme/eject/eject.d.mts +17 -0
  158. package/api/theme/eject/eject.mjs +65 -0
  159. package/api/theme/eject/eject.rollback.test.mjs +158 -0
  160. package/api/theme/eject/eject.staging.test.mjs +83 -0
  161. package/api/theme/eject/eject.test.mjs +160 -0
  162. package/api/theme/integration-themes.test.mjs +30 -6
  163. package/api/theme/list/list.d.mts +10 -0
  164. package/api/theme/list/list.mjs +75 -7
  165. package/api/theme/list/list.test.mjs +155 -4
  166. package/api/theme/remove/remove.d.mts +12 -0
  167. package/api/theme/remove/remove.mjs +15 -0
  168. package/api/theme/remove/remove.test.mjs +94 -0
  169. package/api/theme/template/template.mjs +3 -4
  170. package/api/theme/theme.d.mts +5 -2
  171. package/api/theme/theme.mjs +13 -8
  172. package/api/theme/theme.type.d.mts +106 -2
  173. package/api/theme/theme.type.mjs +54 -5
  174. package/api/theme/themeAdd.doc.d.mts +1 -3
  175. package/api/theme/themeAdd.doc.mjs +35 -22
  176. package/api/theme/themeBuild.doc.d.mts +4 -1
  177. package/api/theme/themeBuild.doc.mjs +15 -4
  178. package/api/theme/themeEject.doc.d.mts +8 -0
  179. package/api/theme/themeEject.doc.mjs +89 -0
  180. package/api/theme/themeListAvailable.doc.mjs +4 -4
  181. package/api/theme/themeListCopySources.doc.d.mts +8 -0
  182. package/api/theme/themeListCopySources.doc.mjs +60 -0
  183. package/api/theme/themeRemove.doc.d.mts +6 -0
  184. package/api/theme/themeRemove.doc.mjs +50 -0
  185. package/api/theme/themeTemplate.doc.mjs +4 -3
  186. package/api/theme/themeUse.doc.d.mts +6 -0
  187. package/api/theme/themeUse.doc.mjs +47 -0
  188. package/api/theme/use/use.d.mts +12 -0
  189. package/api/theme/use/use.mjs +15 -0
  190. package/api/theme/use/use.test.mjs +98 -0
  191. package/api/upgrade/_adapter.d.mts +1 -0
  192. package/api/upgrade/_adapter.mjs +3 -0
  193. package/api/upgrade/list/list.mjs +9 -3
  194. package/api/upgrade/run/run.mjs +20 -3
  195. package/api/upgrade/run/run.test.mjs +45 -1
  196. package/api/upgrade/upgrade.doc.mjs +1 -1
  197. package/api/upgrade/upgrade.type.d.mts +5 -0
  198. package/api/upgrade/upgrade.type.mjs +2 -0
  199. package/assets/codemods/integration-discovery.mjs +1 -1
  200. package/assets/codemods/integration-discovery.test.mjs +64 -0
  201. package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
  202. package/assets/codemods/transforms/next/index.mjs +14 -1
  203. package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
  204. package/assets/docs/author-a-theme.doc.mjs +161 -0
  205. package/assets/docs/getting-started.doc.mjs +59 -15
  206. package/assets/docs/icons.doc.mjs +1 -0
  207. package/assets/docs/principles.doc.dense.mjs +2 -2
  208. package/assets/docs/principles.doc.mjs +2 -2
  209. package/assets/docs/principles.doc.zh.mjs +2 -2
  210. package/assets/docs/styling-libraries.doc.mjs +1 -1
  211. package/assets/docs/styling.doc.mjs +2 -2
  212. package/assets/docs/theme.doc.dense.mjs +10 -198
  213. package/assets/docs/theme.doc.mjs +13 -770
  214. package/assets/docs/theme.doc.zh.mjs +31 -12
  215. package/assets/docs/tokens.doc.mjs +4 -4
  216. package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
  217. package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
  218. package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
  219. package/assets/docs/tree/checks.doc.mjs +6 -5
  220. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
  221. package/assets/docs/tree/define-the-theme.doc.mjs +2 -2
  222. package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
  223. package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
  224. package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
  225. package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
  226. package/assets/docs/tree/layout.doc.mjs +32 -0
  227. package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
  228. package/assets/docs/tree/responsive.doc.mjs +102 -0
  229. package/assets/docs/tree/scaffold.doc.mjs +145 -0
  230. package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
  231. package/assets/docs/tree/side-panels.doc.mjs +82 -0
  232. package/assets/docs/tree/structure.doc.mjs +144 -0
  233. package/assets/docs/tree/template-doc-overview.doc.mjs +13 -1
  234. package/assets/docs/tree/themes.doc.mjs +2 -2
  235. package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
  236. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
  237. package/assets/docs/tree/versioning.doc.mjs +11 -7
  238. package/assets/docs/use-a-theme.doc.mjs +97 -0
  239. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
  240. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
  241. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
  242. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
  243. package/assets/templates/pages/ai-chat/template.doc.mjs +16 -1
  244. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +9 -1
  245. package/assets/templates/pages/blank/template.doc.mjs +3 -1
  246. package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -1
  247. package/assets/templates/pages/centered-hero/template.doc.mjs +3 -1
  248. package/assets/templates/pages/checkout-wizard/template.doc.mjs +1 -0
  249. package/assets/templates/pages/classic-gallery/template.doc.mjs +3 -1
  250. package/assets/templates/pages/contact-form/template.doc.mjs +16 -1
  251. package/assets/templates/pages/dashboard/template.doc.mjs +15 -1
  252. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +23 -1
  253. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +10 -1
  254. package/assets/templates/pages/dashboard-comparison/template.doc.mjs +9 -1
  255. package/assets/templates/pages/dashboard-composition/template.doc.mjs +10 -1
  256. package/assets/templates/pages/dashboard-progress/template.doc.mjs +17 -1
  257. package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -1
  258. package/assets/templates/pages/detail-page/template.doc.mjs +8 -0
  259. package/assets/templates/pages/documentation/template.doc.mjs +10 -1
  260. package/assets/templates/pages/documentation-design/template.doc.mjs +10 -1
  261. package/assets/templates/pages/documentation-technical/template.doc.mjs +10 -1
  262. package/assets/templates/pages/editor/template.doc.mjs +9 -1
  263. package/assets/templates/pages/file-explorer/template.doc.mjs +3 -1
  264. package/assets/templates/pages/form-two-column/template.doc.mjs +17 -1
  265. package/assets/templates/pages/form-wizard/template.doc.mjs +14 -1
  266. package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +1 -0
  267. package/assets/templates/pages/gallery-hero/template.doc.mjs +10 -1
  268. package/assets/templates/pages/ide/template.doc.mjs +9 -1
  269. package/assets/templates/pages/incident-console/template.doc.mjs +10 -1
  270. package/assets/templates/pages/kanban-board/template.doc.mjs +11 -1
  271. package/assets/templates/pages/library/template.doc.mjs +15 -1
  272. package/assets/templates/pages/login/template.doc.mjs +10 -1
  273. package/assets/templates/pages/login-card/template.doc.mjs +11 -1
  274. package/assets/templates/pages/login-split/template.doc.mjs +10 -1
  275. package/assets/templates/pages/login-sso/template.doc.mjs +10 -1
  276. package/assets/templates/pages/messaging-shell/template.doc.mjs +11 -1
  277. package/assets/templates/pages/mixed-gallery/template.doc.mjs +10 -1
  278. package/assets/templates/pages/payment-form/template.doc.mjs +3 -1
  279. package/assets/templates/pages/product-detail/template.doc.mjs +9 -1
  280. package/assets/templates/pages/product-gallery/template.doc.mjs +10 -1
  281. package/assets/templates/pages/settings/template.doc.mjs +3 -1
  282. package/assets/templates/pages/settings-dialog/template.doc.mjs +9 -1
  283. package/assets/templates/pages/settings-sidebar/template.doc.mjs +9 -1
  284. package/assets/templates/pages/shell-nav/template.doc.mjs +10 -1
  285. package/assets/templates/pages/shell-side-nav/template.doc.mjs +14 -1
  286. package/assets/templates/pages/shell-top-nav/template.doc.mjs +11 -1
  287. package/assets/templates/pages/side-gallery/template.doc.mjs +3 -1
  288. package/assets/templates/pages/table/template.doc.mjs +11 -1
  289. package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
  290. package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
  291. package/assets/templates/pages/table-comparison/page.tsx +1449 -0
  292. package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
  293. package/assets/templates/pages/table-filter/template.doc.mjs +21 -1
  294. package/assets/templates/pages/table-grouped/template.doc.mjs +15 -1
  295. package/assets/templates/pages/table-inbox/template.doc.mjs +18 -6
  296. package/assets/templates/pages/table-page/template.doc.mjs +20 -1
  297. package/assets/templates/pages/table-tree/template.doc.mjs +14 -1
  298. package/assets/templates/pages/theme-showcase/template.doc.mjs +10 -1
  299. package/assets/templates/pages/work-item-detail/template.doc.mjs +10 -0
  300. package/assets/templates/themes/butter/icons.tsx +2 -0
  301. package/assets/templates/themes/chocolate/icons.tsx +2 -0
  302. package/assets/templates/themes/gothic/icons.tsx +2 -0
  303. package/assets/templates/themes/matcha/icons.tsx +2 -0
  304. package/assets/templates/themes/neutral/icons.tsx +2 -0
  305. package/assets/templates/themes/stone/icons.tsx +2 -0
  306. package/assets/templates/themes/y2k/icons.tsx +2 -0
  307. package/authoring/doctypes/command/command.doc.mjs +5 -0
  308. package/authoring/doctypes/command/type.ts +2 -0
  309. package/authoring/doctypes/component/component.doc.mjs +1 -1
  310. package/authoring/doctypes/component/type.ts +8 -4
  311. package/authoring/doctypes/template/parse.d.mts +2 -0
  312. package/authoring/doctypes/template/parse.mjs +1 -0
  313. package/authoring/doctypes/template/parse.test.mjs +21 -0
  314. package/authoring/doctypes/template/template.doc.mjs +6 -0
  315. package/authoring/doctypes/template/type.ts +10 -0
  316. package/authoring/integration/integration.doc.mjs +1 -1
  317. package/clients/cli/commands/build-theme.mjs +279 -30
  318. package/clients/cli/commands/build.mjs +7 -6
  319. package/clients/cli/commands/build.text-fields.test.mjs +1 -1
  320. package/clients/cli/commands/component/index.mjs +88 -12
  321. package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
  322. package/clients/cli/commands/component.doc.mjs +9 -2
  323. package/clients/cli/commands/discover.mjs +29 -1
  324. package/clients/cli/commands/discover.no-source.test.mjs +75 -0
  325. package/clients/cli/commands/docs.depth.test.mjs +219 -0
  326. package/clients/cli/commands/docs.doc.mjs +15 -2
  327. package/clients/cli/commands/docs.mjs +273 -16
  328. package/clients/cli/commands/docs.test.mjs +382 -0
  329. package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
  330. package/clients/cli/commands/doctor.doc.mjs +1 -1
  331. package/clients/cli/commands/doctor.mjs +4 -4
  332. package/clients/cli/commands/doctor.test.mjs +9 -51
  333. package/clients/cli/commands/gap-report.doc.mjs +2 -2
  334. package/clients/cli/commands/gap-report.mjs +12 -0
  335. package/clients/cli/commands/gap-report.test.mjs +63 -0
  336. package/clients/cli/commands/hook/index.mjs +7 -2
  337. package/clients/cli/commands/import-hint-correctness.test.mjs +5 -5
  338. package/clients/cli/commands/init.next-steps.test.mjs +18 -23
  339. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  340. package/clients/cli/commands/integration-authoring.test.mjs +12 -2
  341. package/clients/cli/commands/integration-real-world.test.mjs +61 -12
  342. package/clients/cli/commands/integration.mjs +3 -1
  343. package/clients/cli/commands/layout-check.doc.mjs +1 -0
  344. package/clients/cli/commands/layout-expand.doc.mjs +4 -1
  345. package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
  346. package/clients/cli/commands/layout.doc.mjs +1 -0
  347. package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
  348. package/clients/cli/commands/layout.mjs +61 -4
  349. package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
  350. package/clients/cli/commands/search.doc.mjs +5 -4
  351. package/clients/cli/commands/search.mjs +30 -6
  352. package/clients/cli/commands/search.test.mjs +63 -17
  353. package/clients/cli/commands/swizzle.doc.mjs +12 -3
  354. package/clients/cli/commands/swizzle.mjs +2 -1
  355. package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
  356. package/clients/cli/commands/template.mjs +70 -6
  357. package/clients/cli/commands/template.show-media.test.mjs +62 -0
  358. package/clients/cli/commands/text-json-parity.test.mjs +40 -0
  359. package/clients/cli/commands/theme-add-lifecycle.test.mjs +132 -0
  360. package/clients/cli/commands/theme-add.doc.mjs +19 -19
  361. package/clients/cli/commands/theme-eject.doc.mjs +47 -0
  362. package/clients/cli/commands/theme-list.behavior.test.mjs +44 -0
  363. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  364. package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
  365. package/clients/cli/commands/theme-remove.doc.mjs +22 -0
  366. package/clients/cli/commands/theme-template.doc.mjs +4 -3
  367. package/clients/cli/commands/theme-use.doc.mjs +22 -0
  368. package/clients/cli/commands/theme.doc.mjs +21 -16
  369. package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
  370. package/clients/cli/commands/upgrade.mjs +1 -1
  371. package/clients/cli/commands/write-failure.test.mjs +175 -0
  372. package/clients/cli/index.mjs +4 -1
  373. package/clients/cli/lib/component-format.mjs +19 -2
  374. package/clients/cli/lib/manifest.mjs +44 -165
  375. package/clients/cli/lib/manifest.test.mjs +98 -7
  376. package/clients/cli/lib/resolve-theme.mjs +80 -78
  377. package/clients/cli/lib/resolve-theme.test.mjs +523 -27
  378. package/foundation/agent-docs/agent-docs.mjs +31 -28
  379. package/foundation/agent-docs/agent-docs.test.mjs +1163 -0
  380. package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
  381. package/foundation/config/project.d.mts +20 -5
  382. package/foundation/config/project.mjs +43 -6
  383. package/foundation/config/theme-private-vars.d.mts +12 -0
  384. package/foundation/config/theme-private-vars.mjs +107 -0
  385. package/foundation/config/theme-private-vars.test.mjs +55 -0
  386. package/foundation/config/theme-state.d.mts +145 -0
  387. package/foundation/config/theme-state.mjs +417 -0
  388. package/foundation/config/theme-state.test.mjs +182 -0
  389. package/foundation/discovery/component-discovery.d.mts +5 -2
  390. package/foundation/discovery/component-discovery.mjs +12 -6
  391. package/foundation/discovery/component-replacement.d.mts +91 -0
  392. package/foundation/discovery/component-replacement.mjs +417 -0
  393. package/foundation/discovery/component-replacement.test.mjs +480 -0
  394. package/foundation/discovery/docs-output-budget.d.mts +6 -2
  395. package/foundation/discovery/docs-output-budget.mjs +2 -1
  396. package/foundation/discovery/docs-section-key.d.mts +4 -2
  397. package/foundation/discovery/docs-section-key.mjs +1 -1
  398. package/foundation/discovery/module-exports.d.mts +10 -0
  399. package/foundation/discovery/module-exports.mjs +146 -0
  400. package/foundation/discovery/package-exports.d.mts +29 -0
  401. package/foundation/discovery/package-exports.mjs +200 -0
  402. package/foundation/discovery/template-adapter.d.mts +14 -0
  403. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
  404. package/foundation/discovery/template-adapter.mjs +21 -1
  405. package/foundation/discovery/theme-discovery.d.mts +78 -5
  406. package/foundation/discovery/theme-discovery.mjs +143 -18
  407. package/foundation/discovery/theme-discovery.test.mjs +9 -3
  408. package/foundation/discovery/theme-imports.d.mts +15 -0
  409. package/foundation/discovery/theme-imports.mjs +217 -0
  410. package/foundation/discovery/theme-imports.test.mjs +173 -0
  411. package/foundation/doc-compiler/doc-loads.test.mjs +18 -8
  412. package/foundation/doc-compiler/inputs.mjs +2 -1
  413. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  414. package/foundation/doc-compiler/lenses.d.mts +4 -2
  415. package/foundation/doc-compiler/lenses.mjs +1 -1
  416. package/foundation/doc-compiler/tree.test.mjs +649 -0
  417. package/foundation/fs/module-loader.d.mts +9 -0
  418. package/foundation/fs/module-loader.mjs +71 -2
  419. package/foundation/integrations/cli-requirement.d.mts +79 -13
  420. package/foundation/integrations/cli-requirement.mjs +115 -22
  421. package/foundation/integrations/cli-requirement.test.mjs +205 -8
  422. package/foundation/integrations/contribution-inventory.mjs +3 -3
  423. package/foundation/response/base.d.ts +9 -3
  424. package/foundation/response/json.d.mts +7 -4
  425. package/foundation/response/json.mjs +10 -6
  426. package/foundation/response/response-types.doc.d.mts +5 -5
  427. package/foundation/response/response-types.doc.mjs +50 -35
  428. package/foundation/response/response.doc.mjs +18 -4
  429. package/foundation/text/copyright-header.mjs +1 -1
  430. package/foundation/text/copyright-header.test.mjs +1 -1
  431. package/package.json +9 -9
  432. package/assets/docs/layout.doc.dense.mjs +0 -388
  433. package/assets/docs/layout.doc.mjs +0 -550
package/api/docs/docs.mjs CHANGED
@@ -11,6 +11,7 @@
11
11
  * docs(topic, undefined, {index: true}) -> index -> docs.index
12
12
  * docs(topic, section) -> section -> docs.detail.section
13
13
  * docs(route) -> node -> docs.node
14
+ * docs(route, undefined, {depth: 2}) -> node -> docs.node, two levels
14
15
  *
15
16
  * A topic read returns the whole doc, as it always has; `index` returns its
16
17
  * sections, so a reader can open one by its key (spec:AST-047). The CLI's text
@@ -33,6 +34,43 @@ import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
33
34
 
34
35
  export {list, index, detail, sectionLeaf as section, nodeLeaf as node};
35
36
 
37
+ const DETAILS = ['brief', 'compact', 'full'];
38
+
39
+ /**
40
+ * How far a docs-tree read goes, from the options: `depth` levels below the
41
+ * node, or every level for `'all'`, and `detail` for each doc below it (brief
42
+ * by default). `detail` alone reads one level down. Neither: the plain read.
43
+ * @param {import('./docs.type.mjs').DocsOptions} options
44
+ * @returns {import('./node/node.mjs').DepthRead | undefined}
45
+ */
46
+ function depthRead(options) {
47
+ const {depth, detail} = options;
48
+ if (detail != null && !DETAILS.includes(detail)) {
49
+ throw new AstryxError(
50
+ `detail is brief, compact, or full, not ${JSON.stringify(detail)}.`,
51
+ undefined,
52
+ ERROR_CODES.ERR_INVALID_DETAIL,
53
+ );
54
+ }
55
+ if (
56
+ depth != null &&
57
+ depth !== 'all' &&
58
+ !(Number.isInteger(depth) && /** @type {number} */ (depth) >= 0)
59
+ ) {
60
+ throw new AstryxError(
61
+ `depth is a number of levels (0, 1, 2, ...) or "all", not ${JSON.stringify(depth)}.`,
62
+ undefined,
63
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
64
+ );
65
+ }
66
+ if (depth == null && detail == null) return undefined;
67
+ return {
68
+ depth: depth === 'all' ? Infinity : (depth ?? 1),
69
+ detail: /** @type {'brief' | 'compact' | 'full'} */ (detail ?? 'brief'),
70
+ lang: options.lang || (options.dense ? 'dense' : options.zh ? 'zh' : null),
71
+ };
72
+ }
73
+
36
74
  /**
37
75
  * @param {string} [topic]
38
76
  * @param {string} [section]
@@ -42,6 +80,10 @@ export {list, index, detail, sectionLeaf as section, nodeLeaf as node};
42
80
  * @param {boolean} [options.dense]
43
81
  * @param {boolean} [options.index] return the topic's section index instead of
44
82
  * the whole doc
83
+ * @param {number | 'all'} [options.depth] how many levels below a docs-tree
84
+ * namespace to read; a doc with nothing below it reads the same at any depth
85
+ * @param {'brief' | 'compact' | 'full'} [options.detail] how much of each doc
86
+ * below the named one a depth read returns (brief by default)
45
87
  * @param {string} [options.cwd]
46
88
  * @returns {Promise<
47
89
  * import('./docs.type.mjs').DocsListResponse |
@@ -52,6 +94,7 @@ export {list, index, detail, sectionLeaf as section, nodeLeaf as node};
52
94
  * >}
53
95
  */
54
96
  export async function docs(topic, section, options = {}) {
97
+ const read = depthRead(options);
55
98
  if (!topic) return list(options);
56
99
  const found = await resolveDocsArgument(topic, options);
57
100
  if (found.kind === 'node') {
@@ -77,7 +120,9 @@ export async function docs(topic, section, options = {}) {
77
120
  }
78
121
  return {
79
122
  type: 'docs.node',
80
- data: await nodeView(found.catalog, found.tree, found.node),
123
+ // The docs tree names each node's npm package as its provider.
124
+ package: found.node.provider,
125
+ data: await nodeView(found.catalog, found.tree, found.node, read),
81
126
  };
82
127
  }
83
128
  if (section) return sectionLeaf(topic, section, options);
@@ -0,0 +1,279 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Dispatcher-level tests for docs() — the argument-shape routing that
5
+ * sits above the list/detail/section leaves. The leaves have their own tests;
6
+ * this pins the router: docs() -> list, docs(topic) -> detail,
7
+ * docs(topic, section) -> section, plus the unknown-topic/section error codes.
8
+ * Runs against the real CLI-bundled docs (no cwd/project needed).
9
+ */
10
+
11
+ import {describe, it, expect} from 'vitest';
12
+ import {docs} from './docs.mjs';
13
+ import {AstryxError} from '../error.mjs';
14
+
15
+ const SLOW = 30_000;
16
+
17
+ /**
18
+ * The first guide a namespace places, read from the tree rather than named,
19
+ * so a restructure of the guides does not break the reads under test.
20
+ * @param {any} node the data of a docs.node read
21
+ * @returns {string}
22
+ */
23
+ function placedGuide(node) {
24
+ const guide = node.slots
25
+ .flatMap((/** @type {any} */ slot) => slot.children)
26
+ .find((/** @type {any} */ child) => child.kind === 'generic');
27
+ if (guide == null) throw new Error(`${node.route} places no guide`);
28
+ return guide.route;
29
+ }
30
+
31
+ describe('docs() dispatcher routing', () => {
32
+ it('no topic -> docs.list', async () => {
33
+ const r = await docs();
34
+ expect(r.type).toBe('docs.list');
35
+ expect(Array.isArray(r.data)).toBe(true);
36
+ expect(r.data.length).toBeGreaterThan(0);
37
+ }, SLOW);
38
+
39
+ it('empty topic -> docs.list (falsy topic routes to list)', async () => {
40
+ expect((await docs('')).type).toBe('docs.list');
41
+ }, SLOW);
42
+
43
+ it('topic only -> docs.detail, the whole doc', async () => {
44
+ const {data} = await docs();
45
+ expect((await docs(data[0].topic)).type).toBe('docs.detail');
46
+ }, SLOW);
47
+
48
+ it('topic + index -> docs.index', async () => {
49
+ const {data} = await docs();
50
+ const r = await docs(data[0].topic, undefined, {index: true});
51
+ expect(r.type).toBe('docs.index');
52
+ }, SLOW);
53
+
54
+ it('reads a shortened section by its old key, which its title still derives', async () => {
55
+ const r = await docs(
56
+ 'styling',
57
+ 'stylex-build-setup-required-for-swizzled-components',
58
+ );
59
+ expect(r.type).toBe('docs.detail.section');
60
+ expect(r.data).toMatchObject({id: 'stylex-setup'});
61
+ }, SLOW);
62
+
63
+ it('topic + section -> docs.detail.section', async () => {
64
+ const {data} = await docs();
65
+ let routed = null;
66
+ for (const {topic} of data) {
67
+ const detail = await docs(topic);
68
+ const sections = detail.data.sections;
69
+ if (Array.isArray(sections) && sections.length > 0) {
70
+ routed = await docs(topic, sections[0].title);
71
+ break;
72
+ }
73
+ }
74
+ expect(routed).not.toBeNull();
75
+ expect(routed.type).toBe('docs.detail.section');
76
+ }, SLOW);
77
+
78
+ it('unknown topic -> ERR_UNKNOWN_TOPIC', async () => {
79
+ await expect(docs('zzz-not-a-real-topic')).rejects.toBeInstanceOf(AstryxError);
80
+ await expect(docs('zzz-not-a-real-topic')).rejects.toMatchObject({
81
+ code: 'ERR_UNKNOWN_TOPIC',
82
+ });
83
+ }, SLOW);
84
+
85
+ it('known topic + unknown section -> ERR_UNKNOWN_SECTION', async () => {
86
+ const {data} = await docs();
87
+ const topic = data[0].topic;
88
+ await expect(docs(topic, 'zzz-not-a-real-section')).rejects.toMatchObject({
89
+ code: 'ERR_UNKNOWN_SECTION',
90
+ });
91
+ }, SLOW);
92
+
93
+ it("lists the docs tree's namespaces in meta, so every data entry reads as a topic", async () => {
94
+ const res = await docs();
95
+ expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['cli', 'layout', 'unorganized']);
96
+ for (const entry of res.data) {
97
+ expect((await docs(entry.topic)).type).toBe('docs.detail');
98
+ }
99
+ }, SLOW);
100
+
101
+ it('opens a route typed in another case', async () => {
102
+ const r = await docs('CLI/API');
103
+ expect(r.type).toBe('docs.node');
104
+ expect(r.data).toMatchObject({route: 'cli/api', links: {up: 'astryx docs cli'}});
105
+ }, SLOW);
106
+
107
+ it('a section of a typed doc -> ERR_UNKNOWN_SECTION, suggesting the doc itself', async () => {
108
+ const err = await docs('cli/api/functions/search', 'x').catch(e => e);
109
+ expect(err.code).toBe('ERR_UNKNOWN_SECTION');
110
+ expect(err.message).toContain('astryx docs cli/api/functions/search');
111
+ expect(err.suggestions.map(s => s.name)).toEqual(['cli/api/functions/search']);
112
+ }, SLOW);
113
+
114
+ it('a namespace route -> docs.node, one level of children', async () => {
115
+ const r = await docs('cli/api');
116
+ expect(r.type).toBe('docs.node');
117
+ expect(r.data).toMatchObject({
118
+ id: 'astryx:artifact:v1/%40astryxdesign%2Fcli/namespace/api',
119
+ route: 'cli/api',
120
+ kind: 'namespace',
121
+ package: '@astryxdesign/cli',
122
+ breadcrumb: [{route: 'cli', title: 'Astryx CLI'}],
123
+ content: [],
124
+ });
125
+ expect(r.data.slots.flatMap(slot => slot.children.map(c => c.route))).toEqual([
126
+ 'cli/api/functions',
127
+ 'cli/api/schemas',
128
+ 'cli/api/enums',
129
+ ]);
130
+ }, SLOW);
131
+
132
+ it('a typed doc route -> docs.node with its content', async () => {
133
+ const r = await docs('cli/api/functions/search');
134
+ expect(r.type).toBe('docs.node');
135
+ expect(r.data).toMatchObject({
136
+ id: 'astryx:artifact:v1/%40astryxdesign%2Fcli/function/search',
137
+ kind: 'function',
138
+ title: 'search()',
139
+ slots: [],
140
+ });
141
+ expect(r.data.breadcrumb.map(link => link.route)).toEqual([
142
+ 'cli',
143
+ 'cli/api',
144
+ 'cli/api/functions',
145
+ ]);
146
+ expect(JSON.stringify(r.data.content)).toContain(
147
+ '`astryx search` runs it. Read it with `astryx docs cli/commands/search`.',
148
+ );
149
+ }, SLOW);
150
+
151
+ it('a guide the tree places reads like a topic: the whole doc, its index, a section', async () => {
152
+ // cli/integrations is a namespace of short guides; each guide reads like a topic.
153
+ const integrations = await docs('cli/integrations');
154
+ expect(integrations.type).toBe('docs.node');
155
+ const guide = placedGuide(integrations.data);
156
+ expect((await docs(guide)).type).toBe('docs.detail');
157
+ const index = await docs(guide, undefined, {index: true});
158
+ expect(index).toMatchObject({type: 'docs.index', data: {name: guide}});
159
+ expect(index.data.sections.length).toBeGreaterThan(1);
160
+ expect((await docs(guide, index.data.sections[0].id)).type).toBe(
161
+ 'docs.detail.section',
162
+ );
163
+ }, SLOW);
164
+
165
+ it('every read carries its moves (spec:AST-047)', async () => {
166
+ const root = (await docs('cli')).data;
167
+ expect(root.links).toEqual({up: 'astryx docs'});
168
+ const leaf = (await docs('cli/api/functions/search')).data;
169
+ expect(leaf.links.up).toBe('astryx docs cli/api/functions');
170
+ expect(leaf.links.previous).toMatch(/^astryx docs cli\/api\/functions\/[a-z-]+$/);
171
+ expect(leaf.links.next).toMatch(/^astryx docs cli\/api\/functions\/[a-z-]+$/);
172
+ const integrations = (await docs('cli/integrations')).data;
173
+ const guide = placedGuide(integrations);
174
+ const siblings = integrations.slots
175
+ .find(slot => slot.children.some(child => child.route === guide))
176
+ .children.map(child => child.route);
177
+ const at = siblings.indexOf(guide);
178
+ const index = await docs(guide, undefined, {index: true});
179
+ // A guide moves across its namespace's slot, as any tree node does.
180
+ expect(index.data.links).toEqual({
181
+ up: 'astryx docs cli/integrations',
182
+ ...(at > 0 ? {previous: `astryx docs ${siblings[at - 1]}`} : {}),
183
+ ...(at < siblings.length - 1
184
+ ? {next: `astryx docs ${siblings[at + 1]}`}
185
+ : {}),
186
+ });
187
+ const first = (await docs(guide, index.data.sections[0].id)).data;
188
+ expect(first.links).toEqual({
189
+ up: `astryx docs ${guide} --index`,
190
+ next: `astryx docs ${guide} ${index.data.sections[1].id}`,
191
+ });
192
+ const last = index.data.sections.at(-1).id;
193
+ const end = (await docs(guide, last)).data;
194
+ expect(end.links.next).toBeUndefined();
195
+ expect(end.links.previous).toBe(
196
+ `astryx docs ${guide} ${index.data.sections.at(-2).id}`,
197
+ );
198
+ // A flat topic's home is the Unorganized level, and it moves across it.
199
+ const flat = (await docs('principles')).data.links;
200
+ expect(flat.up).toBe('astryx docs unorganized');
201
+ expect(flat.previous).toMatch(/^astryx docs [a-z-]+$/);
202
+ expect(flat.next).toMatch(/^astryx docs [a-z-]+$/);
203
+ const home = (await docs('unorganized')).data;
204
+ expect(home).toMatchObject({id: null, kind: 'namespace', links: {up: 'astryx docs'}});
205
+ expect(home.slots[0].children.map(child => child.route)).toEqual(
206
+ (await docs()).data.map(entry => entry.topic),
207
+ );
208
+ }, SLOW);
209
+
210
+ it('names a node by its doc identity; a generated level has id null', async () => {
211
+ const level = (await docs('cli/api/functions')).data;
212
+ expect(level).toHaveProperty('id', null);
213
+ expect(level.route).toBe('cli/api/functions');
214
+ }, SLOW);
215
+
216
+ it("offers a typed doc's related docs as moves", async () => {
217
+ const fn = (await docs('cli/api/functions/search')).data;
218
+ expect(fn.links.related).toContain('astryx docs cli/commands/search');
219
+ const cmd = (await docs('cli/commands/search')).data;
220
+ expect(cmd.links.related).toContain('astryx docs cli/api/functions/search');
221
+ }, SLOW);
222
+
223
+ it('a topic read returns the whole doc; index returns its sections', async () => {
224
+ expect((await docs('principles')).type).toBe('docs.detail');
225
+ const index = await docs('principles', undefined, {index: true});
226
+ expect(index.type).toBe('docs.index');
227
+ expect(index.data.sections.length).toBeGreaterThan(1);
228
+ expect((await docs('principles', undefined, {dense: true})).type).toBe(
229
+ 'docs.detail',
230
+ );
231
+ }, SLOW);
232
+
233
+ it("the guide's old flat name is gone, and its error names the new route", async () => {
234
+ await expect(docs('cli-integrations')).rejects.toMatchObject({
235
+ code: 'ERR_UNKNOWN_TOPIC',
236
+ suggestions: [expect.objectContaining({name: 'cli/integrations'})],
237
+ });
238
+ expect((await docs()).data.map(entry => entry.topic)).not.toContain(
239
+ 'cli-integrations',
240
+ );
241
+ }, SLOW);
242
+
243
+ it('a section of a namespace -> ERR_UNKNOWN_SECTION, naming its children', async () => {
244
+ const err = await docs('cli', 'commands').catch(e => e);
245
+ expect(err).toBeInstanceOf(AstryxError);
246
+ expect(err.code).toBe('ERR_UNKNOWN_SECTION');
247
+ // It names the namespace's children, in the order its slots list them.
248
+ const cli = (await docs('cli')).data;
249
+ expect(err.suggestions.map(s => s.name)).toEqual(
250
+ cli.slots.flatMap(slot => slot.children.map(child => child.route)),
251
+ );
252
+ expect(err.suggestions.map(s => s.name)).toContain('cli/commands');
253
+ }, SLOW);
254
+
255
+ it('an unknown route suggests the children of the deepest namespace it reaches', async () => {
256
+ const err = await docs('cli/api/functions/serch').catch(e => e);
257
+ expect(err.code).toBe('ERR_UNKNOWN_TOPIC');
258
+ expect(err.suggestions.map(s => s.name)).toContain('cli/api/functions/search');
259
+ expect(err.suggestions.every(s => s.name.startsWith('cli/api/functions/'))).toBe(true);
260
+ }, SLOW);
261
+
262
+ it('non-string topic -> ERR_UNKNOWN_TOPIC (not a raw TypeError)', async () => {
263
+ for (const bad of [123, {}, ['tokens'], true]) {
264
+ const err = await docs(/** @type {any} */ (bad)).catch(e => e);
265
+ expect(err).toBeInstanceOf(AstryxError);
266
+ expect(err.code).toBe('ERR_UNKNOWN_TOPIC');
267
+ }
268
+ }, SLOW);
269
+
270
+ it('non-string section -> ERR_UNKNOWN_SECTION (not a raw TypeError)', async () => {
271
+ const {data} = await docs();
272
+ const topic = data[0].topic;
273
+ for (const bad of [456, {}, ['x']]) {
274
+ const err = await docs(topic, /** @type {any} */ (bad)).catch(e => e);
275
+ expect(err).toBeInstanceOf(AstryxError);
276
+ expect(err.code).toBe('ERR_UNKNOWN_SECTION');
277
+ }
278
+ }, SLOW);
279
+ });
@@ -57,6 +57,10 @@ export type DocsListNamespace = {
57
57
  */
58
58
  export type DocsIndexResponse = {
59
59
  type: "docs.index";
60
+ /**
61
+ * the npm package that owns the topic
62
+ */
63
+ package: string;
60
64
  data: DocsIndex;
61
65
  };
62
66
  /**
@@ -65,9 +69,15 @@ export type DocsIndexResponse = {
65
69
  export type DocsDetailResponse = {
66
70
  type: "docs.detail";
67
71
  /**
68
- * the whole doc, and the moves from it
72
+ * the npm package that owns the topic
73
+ */
74
+ package: string;
75
+ /**
76
+ * the whole doc, each section naming the package that wrote it, and the
77
+ * moves from it
69
78
  */
70
- data: DocsReadDoc & {
79
+ data: Omit<DocsReadDoc, "sections"> & {
80
+ sections: DocsDetailSection[];
71
81
  links: DocsLinks;
72
82
  };
73
83
  };
@@ -79,6 +89,13 @@ export type DocsDetailResponse = {
79
89
  export type DocsReadSection = Omit<import("@astryxdesign/cli/authoring").ReferenceSection, "content"> & {
80
90
  content: import("@astryxdesign/cli/authoring").ReferenceContentBlock[];
81
91
  };
92
+ /**
93
+ * A section of a whole-topic read: the read section, naming the package that
94
+ * wrote it.
95
+ */
96
+ export type DocsDetailSection = DocsReadSection & {
97
+ package: string;
98
+ };
82
99
  /**
83
100
  * A topic as a read returns it: every section a {@link DocsReadSection}.
84
101
  */
@@ -141,7 +158,10 @@ export type DocsIndex = {
141
158
  */
142
159
  links: DocsLinks;
143
160
  };
144
- export type DocsIndexSection = {
161
+ /**
162
+ * One section of a topic's index, before it names its package.
163
+ */
164
+ export type DocsIndexEntry = {
145
165
  /**
146
166
  * stable key; pass it as the section argument
147
167
  */
@@ -153,11 +173,23 @@ export type DocsIndexSection = {
153
173
  */
154
174
  summary: string;
155
175
  };
176
+ /**
177
+ * One section of a topic's index, naming the package that wrote it: the
178
+ * topic's own, or the extension's that contributed it.
179
+ */
180
+ export type DocsIndexSection = DocsIndexEntry & {
181
+ package: string;
182
+ };
156
183
  /**
157
184
  * astryx --json docs <topic> <section>
158
185
  */
159
186
  export type DocsDetailSectionResponse = {
160
187
  type: "docs.detail.section";
188
+ /**
189
+ * the npm package that wrote the section: the
190
+ * topic's own, or the extension's that contributed it
191
+ */
192
+ package: string;
161
193
  /**
162
194
  * the section, and the moves from it: up to its topic's index, and across to
163
195
  * the sections before and after it
@@ -171,6 +203,10 @@ export type DocsDetailSectionResponse = {
171
203
  */
172
204
  export type DocsNodeResponse = {
173
205
  type: "docs.node";
206
+ /**
207
+ * the package that owns the node
208
+ */
209
+ package: string;
174
210
  data: DocsNode;
175
211
  };
176
212
  /**
@@ -205,9 +241,14 @@ export type DocsNode = {
205
241
  breadcrumb: DocsNodeLink[];
206
242
  /**
207
243
  * a namespace's slots that hold children, in
208
- * order; empty for a typed doc
244
+ * order; empty for a typed doc, and for a depth read of 0
209
245
  */
210
246
  slots: DocsNodeSlot[];
247
+ /**
248
+ * with a depth read of 0, how many docs sit
249
+ * right below the namespace
250
+ */
251
+ childCount?: number | undefined;
211
252
  /**
212
253
  * a typed doc's content; empty for a namespace
213
254
  */
@@ -243,9 +284,33 @@ export type DocsNodeChild = {
243
284
  * the last segment of its route
244
285
  */
245
286
  name: string;
287
+ /**
288
+ * the package that owns the child
289
+ */
290
+ package: string;
246
291
  kind: string;
247
292
  title: string;
248
293
  summary: string;
294
+ /**
295
+ * with a depth read, its own slots, while
296
+ * the read goes deeper
297
+ */
298
+ slots?: DocsNodeSlot[] | undefined;
299
+ /**
300
+ * with a depth read, how many docs sit right
301
+ * below it where the read stops
302
+ */
303
+ childCount?: number | undefined;
304
+ /**
305
+ * with a depth read at compact or full detail: a namespace's intro or a typed
306
+ * doc's content
307
+ */
308
+ content?: import("@astryxdesign/cli/authoring").ReferenceContentBlock[] | undefined;
309
+ /**
310
+ * with a depth read at compact or full
311
+ * detail: a guide's sections
312
+ */
313
+ sections?: DocsReadSection[] | undefined;
249
314
  };
250
315
  /**
251
316
  * Options for `docs()`.
@@ -259,6 +324,18 @@ export type DocsOptions = {
259
324
  * whole doc
260
325
  */
261
326
  index?: boolean | undefined;
327
+ /**
328
+ * how many levels below a docs-tree
329
+ * namespace to read: 0 for the namespace alone, 1 for its children (the
330
+ * default), 'all' for every level
331
+ */
332
+ depth?: number | "all" | undefined;
333
+ /**
334
+ * how much of each doc below
335
+ * the named one a depth read returns: brief (the default) is its identity,
336
+ * compact and full add its text
337
+ */
338
+ detail?: "compact" | "full" | "brief" | undefined;
262
339
  /**
263
340
  * project directory whose configured integrations
264
341
  * contribute topics; defaults to process.cwd()
@@ -49,6 +49,7 @@
49
49
  * astryx --json docs <topic> --index
50
50
  * @typedef {object} DocsIndexResponse
51
51
  * @property {'docs.index'} type
52
+ * @property {string} package the npm package that owns the topic
52
53
  * @property {DocsIndex} data
53
54
  */
54
55
 
@@ -56,8 +57,10 @@
56
57
  * astryx --json docs <topic>
57
58
  * @typedef {object} DocsDetailResponse
58
59
  * @property {'docs.detail'} type
59
- * @property {DocsReadDoc & {links: DocsLinks}} data
60
- * the whole doc, and the moves from it
60
+ * @property {string} package the npm package that owns the topic
61
+ * @property {Omit<DocsReadDoc, 'sections'> & {sections: DocsDetailSection[], links: DocsLinks}} data
62
+ * the whole doc, each section naming the package that wrote it, and the
63
+ * moves from it
61
64
  */
62
65
 
63
66
  /**
@@ -68,6 +71,12 @@
68
71
  * & {content: import('@astryxdesign/cli/authoring').ReferenceContentBlock[]}} DocsReadSection
69
72
  */
70
73
 
74
+ /**
75
+ * A section of a whole-topic read: the read section, naming the package that
76
+ * wrote it.
77
+ * @typedef {DocsReadSection & {package: string}} DocsDetailSection
78
+ */
79
+
71
80
  /**
72
81
  * A topic as a read returns it: every section a {@link DocsReadSection}.
73
82
  * @typedef {Omit<import('@astryxdesign/cli/authoring').ReferenceDoc, 'sections'>
@@ -115,17 +124,26 @@
115
124
  */
116
125
 
117
126
  /**
118
- * @typedef {object} DocsIndexSection
127
+ * One section of a topic's index, before it names its package.
128
+ * @typedef {object} DocsIndexEntry
119
129
  * @property {string} id stable key; pass it as the section argument
120
130
  * @property {string} title
121
131
  * @property {string} summary the section's first line of text, at most 240
122
132
  * characters
123
133
  */
124
134
 
135
+ /**
136
+ * One section of a topic's index, naming the package that wrote it: the
137
+ * topic's own, or the extension's that contributed it.
138
+ * @typedef {DocsIndexEntry & {package: string}} DocsIndexSection
139
+ */
140
+
125
141
  /**
126
142
  * astryx --json docs <topic> <section>
127
143
  * @typedef {object} DocsDetailSectionResponse
128
144
  * @property {'docs.detail.section'} type
145
+ * @property {string} package the npm package that wrote the section: the
146
+ * topic's own, or the extension's that contributed it
129
147
  * @property {DocsReadSection & {links: DocsLinks}} data
130
148
  * the section, and the moves from it: up to its topic's index, and across to
131
149
  * the sections before and after it
@@ -135,6 +153,7 @@
135
153
  * astryx --json docs <route>, for a namespace or a typed doc in the docs tree
136
154
  * @typedef {object} DocsNodeResponse
137
155
  * @property {'docs.node'} type
156
+ * @property {string} package the package that owns the node
138
157
  * @property {DocsNode} data
139
158
  */
140
159
 
@@ -153,7 +172,9 @@
153
172
  * @property {string} summary
154
173
  * @property {DocsNodeLink[]} breadcrumb the namespaces above it, top first
155
174
  * @property {DocsNodeSlot[]} slots a namespace's slots that hold children, in
156
- * order; empty for a typed doc
175
+ * order; empty for a typed doc, and for a depth read of 0
176
+ * @property {number} [childCount] with a depth read of 0, how many docs sit
177
+ * right below the namespace
157
178
  * @property {import('@astryxdesign/cli/authoring').ReferenceContentBlock[]} content
158
179
  * a typed doc's content; empty for a namespace
159
180
  * @property {DocsLinks} links the moves from the node: up to its parent (the
@@ -178,9 +199,19 @@
178
199
  * @typedef {object} DocsNodeChild
179
200
  * @property {string} route pass it to `astryx docs` to go one level down
180
201
  * @property {string} name the last segment of its route
202
+ * @property {string} package the package that owns the child
181
203
  * @property {string} kind
182
204
  * @property {string} title
183
205
  * @property {string} summary
206
+ * @property {DocsNodeSlot[]} [slots] with a depth read, its own slots, while
207
+ * the read goes deeper
208
+ * @property {number} [childCount] with a depth read, how many docs sit right
209
+ * below it where the read stops
210
+ * @property {import('@astryxdesign/cli/authoring').ReferenceContentBlock[]} [content]
211
+ * with a depth read at compact or full detail: a namespace's intro or a typed
212
+ * doc's content
213
+ * @property {DocsReadSection[]} [sections] with a depth read at compact or full
214
+ * detail: a guide's sections
184
215
  */
185
216
 
186
217
  /**
@@ -191,6 +222,12 @@
191
222
  * @property {boolean} [dense]
192
223
  * @property {boolean} [index] return a topic's section index instead of its
193
224
  * whole doc
225
+ * @property {number | 'all'} [depth] how many levels below a docs-tree
226
+ * namespace to read: 0 for the namespace alone, 1 for its children (the
227
+ * default), 'all' for every level
228
+ * @property {'brief' | 'compact' | 'full'} [detail] how much of each doc below
229
+ * the named one a depth read returns: brief (the default) is its identity,
230
+ * compact and full add its text
194
231
  * @property {string} [cwd] project directory whose configured integrations
195
232
  * contribute topics; defaults to process.cwd()
196
233
  */
@@ -15,7 +15,7 @@
15
15
  */
16
16
 
17
17
  import {indexView} from '../../../foundation/doc-compiler/lenses.mjs';
18
- import {resolveTopicDocs, topicLinks} from '../_adapter.mjs';
18
+ import {resolveTopicDocs, sectionPackageOf, topicLinks} from '../_adapter.mjs';
19
19
 
20
20
  /**
21
21
  * @param {string} topic
@@ -29,12 +29,21 @@ import {resolveTopicDocs, topicLinks} from '../_adapter.mjs';
29
29
  export async function index(topic, options = {}) {
30
30
  const {node, entry, catalog} = await resolveTopicDocs(topic, options);
31
31
  const view = indexView(node);
32
+ const sectionPackage = sectionPackageOf(entry, node);
32
33
  /** @type {import('../docs.type.mjs').DocsIndex} */
33
34
  const data = {
34
35
  ...view,
35
36
  // A guide the docs tree places is read by its route, not its doc name.
36
37
  name: entry.tree ? entry.name : view.name,
38
+ // Each section names the package that wrote it: the topic's own, or an
39
+ // extension's.
40
+ sections: view.sections.map(s => ({
41
+ id: s.id,
42
+ title: s.title,
43
+ package: sectionPackage(s.id),
44
+ summary: s.summary,
45
+ })),
37
46
  links: await topicLinks(catalog, entry),
38
47
  };
39
- return {type: 'docs.index', data};
48
+ return {type: 'docs.index', package: entry.package, data};
40
49
  }
@@ -3,7 +3,7 @@
3
3
  import {describe, expect, it} from 'vitest';
4
4
  import {docs} from '../docs.mjs';
5
5
  import {index} from './index.mjs';
6
- import {loadDocsCatalog} from '../_adapter.mjs';
6
+ import {loadDocsCatalog, holdsOwnName, projectTree} from '../_adapter.mjs';
7
7
 
8
8
  const SLOW = 60_000;
9
9
 
@@ -15,7 +15,8 @@ describe('docs.index leaf', () => {
15
15
  const keys = res.data.sections.map(s => s.id);
16
16
  expect(new Set(keys).size).toBe(keys.length);
17
17
  for (const entry of res.data.sections) {
18
- expect(Object.keys(entry)).toEqual(['id', 'title', 'summary']);
18
+ expect(Object.keys(entry)).toEqual(['id', 'title', 'package', 'summary']);
19
+ expect(entry.package).toBe(res.package);
19
20
  expect(entry.summary.length).toBeLessThanOrEqual(240);
20
21
  }
21
22
  }, SLOW);
@@ -38,7 +39,11 @@ describe('docs.index leaf', () => {
38
39
 
39
40
  it('lists keys every section can be read by', async () => {
40
41
  const catalog = await loadDocsCatalog();
42
+ const tree = await projectTree(catalog);
41
43
  for (const entry of catalog.entries()) {
44
+ // A flat topic whose name is now owned by a namespace (e.g. layout)
45
+ // cannot be read as a topic — skip it.
46
+ if (!holdsOwnName(tree, catalog, entry)) continue;
42
47
  const {data} = await index(entry.name);
43
48
  for (const {id, title} of data.sections) {
44
49
  const read = await docs(entry.name, id);