@astryxdesign/cli 0.6.5-canary.f27f749 → 0.6.5-canary.f2f43e1

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 (312) hide show
  1. package/README.md +45 -43
  2. package/api/build/_adapter.d.mts +19 -0
  3. package/api/build/_adapter.mjs +60 -1
  4. package/api/build/build.test.mjs +74 -1
  5. package/api/build/build.type.d.mts +8 -0
  6. package/api/build/build.type.mjs +2 -0
  7. package/api/build/kit/kit.mjs +40 -7
  8. package/api/build/kit/rank.d.mts +8 -0
  9. package/api/build/kit/rank.mjs +14 -0
  10. package/api/build/kit/weights.d.mts +82 -0
  11. package/api/build/kit/weights.json +1 -0
  12. package/api/build/kit/weights.mjs +305 -0
  13. package/api/build/kit/weights.test.mjs +190 -0
  14. package/api/component/_adapter.d.mts +19 -0
  15. package/api/component/_adapter.mjs +33 -0
  16. package/api/component/component-replacement.test.mjs +603 -0
  17. package/api/component/component.mjs +49 -15
  18. package/api/component/component.test.mjs +32 -0
  19. package/api/component/component.type.d.mts +33 -3
  20. package/api/component/component.type.mjs +10 -3
  21. package/api/component/detail/blocks/blocks.d.mts +2 -1
  22. package/api/component/detail/blocks/blocks.mjs +5 -2
  23. package/api/component/detail/detail.mjs +5 -1
  24. package/api/component/detail/props/props.d.mts +2 -1
  25. package/api/component/detail/props/props.mjs +3 -2
  26. package/api/component/detail/showcase/showcase.d.mts +3 -1
  27. package/api/component/detail/showcase/showcase.mjs +3 -1
  28. package/api/component/detail/source/source.d.mts +3 -2
  29. package/api/component/detail/source/source.mjs +7 -3
  30. package/api/component/list/list.mjs +128 -10
  31. package/api/docs/_adapter.d.mts +11 -0
  32. package/api/docs/_adapter.mjs +25 -0
  33. package/api/docs/detail/detail.mjs +19 -3
  34. package/api/docs/detail/section/section.mjs +7 -1
  35. package/api/docs/docOverlays.test.mjs +10 -6
  36. package/api/docs/docs.d.mts +6 -0
  37. package/api/docs/docs.depth.test.mjs +134 -0
  38. package/api/docs/docs.doc.mjs +31 -2
  39. package/api/docs/docs.mjs +46 -1
  40. package/api/docs/docs.test.mjs +1 -1
  41. package/api/docs/docs.type.d.mts +81 -4
  42. package/api/docs/docs.type.mjs +41 -4
  43. package/api/docs/index/index.mjs +11 -2
  44. package/api/docs/index/index.test.mjs +7 -2
  45. package/api/docs/integrationDocs.test.mjs +6 -5
  46. package/api/docs/node/node.d.mts +28 -3
  47. package/api/docs/node/node.mjs +149 -23
  48. package/api/doctor/_adapter.d.mts +43 -0
  49. package/api/doctor/_adapter.mjs +142 -0
  50. package/api/doctor/doctor.d.mts +0 -10
  51. package/api/doctor/doctor.doc.mjs +1 -3
  52. package/api/doctor/doctor.mjs +6 -123
  53. package/api/doctor/theme-checks.d.mts +12 -0
  54. package/api/doctor/theme-checks.mjs +1117 -0
  55. package/api/doctor/theme-checks.test.mjs +526 -0
  56. package/api/gap-report/gap-report.d.mts +3 -1
  57. package/api/gap-report/gap-report.mjs +27 -3
  58. package/api/gap-report/gap-report.test.mjs +106 -0
  59. package/api/hook/_adapter.d.mts +1 -0
  60. package/api/hook/_adapter.mjs +3 -0
  61. package/api/hook/detail/detail.mjs +2 -2
  62. package/api/hook/detail/params/params.mjs +2 -2
  63. package/api/hook/hook.type.d.mts +12 -0
  64. package/api/hook/hook.type.mjs +3 -0
  65. package/api/hook/list/list.d.mts +1 -1
  66. package/api/hook/list/list.mjs +8 -8
  67. package/api/index.d.mts +1 -1
  68. package/api/index.mjs +4 -0
  69. package/api/init/run/run.d.mts +3 -5
  70. package/api/init/run/run.mjs +10 -11
  71. package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
  72. package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
  73. package/api/integration/add-helpers.d.mts +26 -5
  74. package/api/integration/add-helpers.mjs +50 -5
  75. package/api/integration/add-theme.mjs +109 -5
  76. package/api/integration/add-theme.test.mjs +166 -15
  77. package/api/integration/authoring-checks.mjs +21 -1
  78. package/api/integration/integrationAddTheme.doc.mjs +1 -1
  79. package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
  80. package/api/integration/pack-check.component-replaces.test.mjs +126 -0
  81. package/api/integration/pack-check.d.mts +10 -0
  82. package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
  83. package/api/integration/pack-check.mjs +483 -1
  84. package/api/integration/pack-check.test.mjs +568 -8
  85. package/api/search/search.d.mts +15 -8
  86. package/api/search/search.doc.mjs +4 -4
  87. package/api/search/search.mjs +179 -67
  88. package/api/search/search.test.mjs +128 -9
  89. package/api/search/search.type.d.mts +6 -6
  90. package/api/search/search.type.mjs +5 -5
  91. package/api/swizzle/_adapter.d.mts +10 -0
  92. package/api/swizzle/_adapter.mjs +23 -0
  93. package/api/swizzle/copy/copy.d.mts +5 -6
  94. package/api/swizzle/copy/copy.mjs +29 -10
  95. package/api/swizzle/list/list.mjs +2 -2
  96. package/api/swizzle/swizzle.test.mjs +55 -5
  97. package/api/swizzle/swizzle.type.d.mts +8 -0
  98. package/api/swizzle/swizzle.type.mjs +2 -0
  99. package/api/template/copy/copy.mjs +2 -1
  100. package/api/template/show/show.mjs +2 -0
  101. package/api/template/skeleton/skeleton.mjs +2 -1
  102. package/api/template/template.d.mts +1 -1
  103. package/api/template/template.mjs +1 -0
  104. package/api/template/template.type.d.mts +12 -0
  105. package/api/template/template.type.mjs +3 -0
  106. package/api/theme/_adapter.d.mts +106 -6
  107. package/api/theme/_adapter.mjs +687 -18
  108. package/api/theme/add/add.binary.test.mjs +76 -3
  109. package/api/theme/add/add.d.mts +5 -9
  110. package/api/theme/add/add.mjs +87 -64
  111. package/api/theme/add/add.rollback.test.mjs +9 -9
  112. package/api/theme/add/add.staging.test.mjs +9 -9
  113. package/api/theme/add/add.test.mjs +461 -55
  114. package/api/theme/add/add.types.test.mjs +151 -0
  115. package/api/theme/build/build.d.mts +26 -2
  116. package/api/theme/build/build.family.test.mjs +13 -4
  117. package/api/theme/build/build.icon-lineage.test.mjs +117 -0
  118. package/api/theme/build/build.icon-preservation.test.mjs +639 -0
  119. package/api/theme/build/build.mjs +228 -147
  120. package/api/theme/build/build.test.mjs +220 -1
  121. package/api/theme/build/icon-imports.d.mts +47 -0
  122. package/api/theme/build/icon-imports.mjs +691 -0
  123. package/api/theme/eject/eject.binary.test.mjs +90 -0
  124. package/api/theme/eject/eject.d.mts +17 -0
  125. package/api/theme/eject/eject.mjs +65 -0
  126. package/api/theme/eject/eject.rollback.test.mjs +158 -0
  127. package/api/theme/eject/eject.staging.test.mjs +83 -0
  128. package/api/theme/eject/eject.test.mjs +160 -0
  129. package/api/theme/integration-themes.test.mjs +30 -6
  130. package/api/theme/list/list.d.mts +10 -0
  131. package/api/theme/list/list.mjs +75 -7
  132. package/api/theme/list/list.test.mjs +155 -4
  133. package/api/theme/remove/remove.d.mts +12 -0
  134. package/api/theme/remove/remove.mjs +15 -0
  135. package/api/theme/remove/remove.test.mjs +94 -0
  136. package/api/theme/template/template.mjs +3 -4
  137. package/api/theme/theme.d.mts +5 -2
  138. package/api/theme/theme.mjs +13 -8
  139. package/api/theme/theme.type.d.mts +106 -2
  140. package/api/theme/theme.type.mjs +54 -5
  141. package/api/theme/themeAdd.doc.d.mts +1 -3
  142. package/api/theme/themeAdd.doc.mjs +35 -22
  143. package/api/theme/themeBuild.doc.d.mts +4 -1
  144. package/api/theme/themeBuild.doc.mjs +15 -4
  145. package/api/theme/themeEject.doc.d.mts +8 -0
  146. package/api/theme/themeEject.doc.mjs +89 -0
  147. package/api/theme/themeListAvailable.doc.mjs +4 -4
  148. package/api/theme/themeListCopySources.doc.d.mts +8 -0
  149. package/api/theme/themeListCopySources.doc.mjs +60 -0
  150. package/api/theme/themeRemove.doc.d.mts +6 -0
  151. package/api/theme/themeRemove.doc.mjs +50 -0
  152. package/api/theme/themeTemplate.doc.mjs +4 -3
  153. package/api/theme/themeUse.doc.d.mts +6 -0
  154. package/api/theme/themeUse.doc.mjs +47 -0
  155. package/api/theme/use/use.d.mts +12 -0
  156. package/api/theme/use/use.mjs +15 -0
  157. package/api/theme/use/use.test.mjs +98 -0
  158. package/api/upgrade/_adapter.d.mts +1 -0
  159. package/api/upgrade/_adapter.mjs +3 -0
  160. package/api/upgrade/list/list.mjs +9 -3
  161. package/api/upgrade/upgrade.type.d.mts +4 -0
  162. package/api/upgrade/upgrade.type.mjs +1 -0
  163. package/assets/codemods/integration-discovery.mjs +1 -1
  164. package/assets/codemods/integration-discovery.test.mjs +64 -0
  165. package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
  166. package/assets/codemods/transforms/next/index.mjs +14 -1
  167. package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
  168. package/assets/docs/author-a-theme.doc.mjs +161 -0
  169. package/assets/docs/getting-started.doc.mjs +59 -15
  170. package/assets/docs/principles.doc.dense.mjs +2 -2
  171. package/assets/docs/principles.doc.mjs +2 -2
  172. package/assets/docs/principles.doc.zh.mjs +2 -2
  173. package/assets/docs/styling-libraries.doc.mjs +1 -1
  174. package/assets/docs/styling.doc.mjs +2 -2
  175. package/assets/docs/theme.doc.dense.mjs +10 -198
  176. package/assets/docs/theme.doc.mjs +13 -770
  177. package/assets/docs/theme.doc.zh.mjs +31 -12
  178. package/assets/docs/tokens.doc.mjs +4 -4
  179. package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
  180. package/assets/docs/tree/checks.doc.mjs +5 -4
  181. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
  182. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  183. package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
  184. package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
  185. package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
  186. package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
  187. package/assets/docs/tree/layout.doc.mjs +32 -0
  188. package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
  189. package/assets/docs/tree/responsive.doc.mjs +102 -0
  190. package/assets/docs/tree/scaffold.doc.mjs +145 -0
  191. package/assets/docs/tree/side-panels.doc.mjs +82 -0
  192. package/assets/docs/tree/structure.doc.mjs +144 -0
  193. package/assets/docs/tree/themes.doc.mjs +2 -2
  194. package/assets/docs/tree/troubleshooting.doc.mjs +4 -0
  195. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
  196. package/assets/docs/tree/versioning.doc.mjs +4 -1
  197. package/assets/docs/use-a-theme.doc.mjs +97 -0
  198. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
  199. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
  200. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
  201. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
  202. package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
  203. package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
  204. package/assets/templates/pages/table-comparison/page.tsx +1449 -0
  205. package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
  206. package/authoring/doctypes/command/command.doc.mjs +5 -0
  207. package/authoring/doctypes/command/type.ts +2 -0
  208. package/authoring/doctypes/component/component.doc.mjs +1 -1
  209. package/authoring/doctypes/component/type.ts +8 -4
  210. package/authoring/integration/integration.doc.mjs +1 -1
  211. package/clients/cli/commands/build-theme.mjs +279 -30
  212. package/clients/cli/commands/build.mjs +7 -6
  213. package/clients/cli/commands/build.text-fields.test.mjs +1 -1
  214. package/clients/cli/commands/component/index.mjs +88 -12
  215. package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
  216. package/clients/cli/commands/component.doc.mjs +9 -2
  217. package/clients/cli/commands/discover.mjs +29 -1
  218. package/clients/cli/commands/discover.no-source.test.mjs +75 -0
  219. package/clients/cli/commands/docs.depth.test.mjs +219 -0
  220. package/clients/cli/commands/docs.doc.mjs +15 -2
  221. package/clients/cli/commands/docs.mjs +273 -16
  222. package/clients/cli/commands/docs.test.mjs +2 -3
  223. package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
  224. package/clients/cli/commands/doctor.doc.mjs +1 -1
  225. package/clients/cli/commands/doctor.test.mjs +9 -51
  226. package/clients/cli/commands/gap-report.doc.mjs +2 -2
  227. package/clients/cli/commands/gap-report.mjs +12 -0
  228. package/clients/cli/commands/gap-report.test.mjs +63 -0
  229. package/clients/cli/commands/hook/index.mjs +7 -2
  230. package/clients/cli/commands/import-hint-correctness.test.mjs +5 -5
  231. package/clients/cli/commands/init.next-steps.test.mjs +18 -23
  232. package/clients/cli/commands/integration-add.doc.mjs +1 -1
  233. package/clients/cli/commands/integration-real-world.test.mjs +61 -12
  234. package/clients/cli/commands/layout-check.doc.mjs +1 -0
  235. package/clients/cli/commands/layout-expand.doc.mjs +1 -0
  236. package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
  237. package/clients/cli/commands/layout.doc.mjs +1 -0
  238. package/clients/cli/commands/layout.mjs +45 -4
  239. package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
  240. package/clients/cli/commands/search.doc.mjs +5 -4
  241. package/clients/cli/commands/search.mjs +30 -6
  242. package/clients/cli/commands/search.test.mjs +63 -17
  243. package/clients/cli/commands/swizzle.doc.mjs +12 -3
  244. package/clients/cli/commands/swizzle.mjs +2 -1
  245. package/clients/cli/commands/template.mjs +54 -4
  246. package/clients/cli/commands/text-json-parity.test.mjs +40 -0
  247. package/clients/cli/commands/theme-add-lifecycle.test.mjs +132 -0
  248. package/clients/cli/commands/theme-add.doc.mjs +19 -19
  249. package/clients/cli/commands/theme-eject.doc.mjs +47 -0
  250. package/clients/cli/commands/theme-list.behavior.test.mjs +44 -0
  251. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  252. package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
  253. package/clients/cli/commands/theme-remove.doc.mjs +22 -0
  254. package/clients/cli/commands/theme-template.doc.mjs +4 -3
  255. package/clients/cli/commands/theme-use.doc.mjs +22 -0
  256. package/clients/cli/commands/theme.doc.mjs +21 -16
  257. package/clients/cli/commands/upgrade.mjs +1 -1
  258. package/clients/cli/index.mjs +4 -1
  259. package/clients/cli/lib/component-format.mjs +19 -2
  260. package/clients/cli/lib/resolve-theme.mjs +80 -78
  261. package/clients/cli/lib/resolve-theme.test.mjs +523 -27
  262. package/foundation/agent-docs/agent-docs.mjs +31 -28
  263. package/foundation/agent-docs/agent-docs.test.mjs +35 -32
  264. package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
  265. package/foundation/config/project.d.mts +20 -5
  266. package/foundation/config/project.mjs +43 -6
  267. package/foundation/config/theme-private-vars.d.mts +12 -0
  268. package/foundation/config/theme-private-vars.mjs +107 -0
  269. package/foundation/config/theme-private-vars.test.mjs +55 -0
  270. package/foundation/config/theme-state.d.mts +145 -0
  271. package/foundation/config/theme-state.mjs +417 -0
  272. package/foundation/config/theme-state.test.mjs +182 -0
  273. package/foundation/discovery/component-discovery.d.mts +5 -2
  274. package/foundation/discovery/component-discovery.mjs +12 -6
  275. package/foundation/discovery/component-replacement.d.mts +91 -0
  276. package/foundation/discovery/component-replacement.mjs +417 -0
  277. package/foundation/discovery/component-replacement.test.mjs +480 -0
  278. package/foundation/discovery/docs-output-budget.d.mts +6 -2
  279. package/foundation/discovery/docs-output-budget.mjs +2 -1
  280. package/foundation/discovery/docs-section-key.d.mts +4 -2
  281. package/foundation/discovery/docs-section-key.mjs +1 -1
  282. package/foundation/discovery/module-exports.d.mts +10 -0
  283. package/foundation/discovery/module-exports.mjs +146 -0
  284. package/foundation/discovery/package-exports.d.mts +29 -0
  285. package/foundation/discovery/package-exports.mjs +200 -0
  286. package/foundation/discovery/theme-discovery.d.mts +78 -5
  287. package/foundation/discovery/theme-discovery.mjs +143 -18
  288. package/foundation/discovery/theme-discovery.test.mjs +9 -3
  289. package/foundation/discovery/theme-imports.d.mts +15 -0
  290. package/foundation/discovery/theme-imports.mjs +217 -0
  291. package/foundation/discovery/theme-imports.test.mjs +173 -0
  292. package/foundation/doc-compiler/doc-loads.test.mjs +16 -6
  293. package/foundation/doc-compiler/inputs.mjs +2 -1
  294. package/foundation/doc-compiler/lenses.d.mts +4 -2
  295. package/foundation/doc-compiler/lenses.mjs +1 -1
  296. package/foundation/doc-compiler/tree.test.mjs +2 -2
  297. package/foundation/fs/module-loader.d.mts +9 -0
  298. package/foundation/fs/module-loader.mjs +71 -2
  299. package/foundation/integrations/cli-requirement.d.mts +22 -0
  300. package/foundation/integrations/cli-requirement.mjs +31 -0
  301. package/foundation/integrations/cli-requirement.test.mjs +70 -0
  302. package/foundation/integrations/contribution-inventory.mjs +3 -3
  303. package/foundation/response/base.d.ts +9 -3
  304. package/foundation/response/json.d.mts +7 -4
  305. package/foundation/response/json.mjs +10 -6
  306. package/foundation/response/response-types.doc.mjs +38 -23
  307. package/foundation/response/response.doc.mjs +18 -4
  308. package/foundation/text/copyright-header.mjs +1 -1
  309. package/foundation/text/copyright-header.test.mjs +1 -1
  310. package/package.json +9 -9
  311. package/assets/docs/layout.doc.dense.mjs +0 -388
  312. 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);
@@ -92,7 +92,7 @@ describe('docs() dispatcher routing', () => {
92
92
 
93
93
  it("lists the docs tree's namespaces in meta, so every data entry reads as a topic", async () => {
94
94
  const res = await docs();
95
- expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['cli', 'unorganized']);
95
+ expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['cli', 'layout', 'unorganized']);
96
96
  for (const entry of res.data) {
97
97
  expect((await docs(entry.topic)).type).toBe('docs.detail');
98
98
  }
@@ -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);
@@ -243,7 +243,7 @@ describe('integration-contributed topics', () => {
243
243
  const english = await docs('theme', undefined, {full: true});
244
244
  const englishTitles = english.data.sections.map(section => section.title);
245
245
  expect(englishTitles).toEqual(
246
- expect.arrayContaining(['Available Themes', 'Theme Props']),
246
+ expect.arrayContaining(['Wrap your app in a theme', 'Dark mode']),
247
247
  );
248
248
  scaffold({
249
249
  'theme-internal.doc.mjs': topic({
@@ -251,12 +251,13 @@ describe('integration-contributed topics', () => {
251
251
  extends: 'theme',
252
252
  sections: [
253
253
  {
254
- id: 'acme-available-themes',
255
- title: 'Available Themes',
254
+ id: 'quick-start',
255
+ title: 'Wrap your app in a theme',
256
256
  content: [{type: 'prose', text: 'Acme themes.'}],
257
257
  },
258
258
  {
259
- title: 'Theme Props',
259
+ id: 'light-dark-mode',
260
+ title: 'Dark mode',
260
261
  content: [{type: 'prose', text: 'Acme props.'}],
261
262
  },
262
263
  ],
@@ -271,7 +272,7 @@ describe('integration-contributed topics', () => {
271
272
  expect(extended.data.sections).toHaveLength(base.data.sections.length);
272
273
  expect(
273
274
  extended.data.sections.filter(
274
- section => section.id === 'acme-available-themes',
275
+ section => section.id === 'quick-start',
275
276
  ),
276
277
  ).toHaveLength(1);
277
278
  expect(
@@ -4,15 +4,28 @@
4
4
  /**
5
5
  * @typedef {import('../../../foundation/doc-compiler/tree.mjs').DocsTree} DocsTree
6
6
  * @typedef {import('../../../foundation/doc-compiler/tree.mjs').TreeNode} TreeNode
7
+ * @typedef {import('../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} DocsCatalog
7
8
  */
8
9
  /**
9
- * The docs.node view of one tree node.
10
- * @param {import('../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} catalog
10
+ * How far a read goes below the node it names, and how much of each doc below
11
+ * it shows: `depth` levels (Infinity for every level), and `detail` brief (its
12
+ * identity), or compact or full (with its text: a namespace's intro, a guide's
13
+ * sections, a typed doc's content). `lang` selects the guides' language.
14
+ * @typedef {object} DepthRead
15
+ * @property {number} depth
16
+ * @property {'brief' | 'compact' | 'full'} detail
17
+ * @property {string | null} lang
18
+ */
19
+ /**
20
+ * The docs.node view of one tree node. Without a depth read, a namespace lists
21
+ * its children one level down.
22
+ * @param {DocsCatalog} catalog
11
23
  * @param {DocsTree} tree
12
24
  * @param {TreeNode} node
25
+ * @param {DepthRead} [read] how far down to go, and how much of each doc below
13
26
  * @returns {Promise<import('../docs.type.mjs').DocsNode>}
14
27
  */
15
- export function nodeView(catalog: import("../../../foundation/discovery/docs-discovery.mjs").DocsCatalog, tree: DocsTree, node: TreeNode): Promise<import("../docs.type.mjs").DocsNode>;
28
+ export function nodeView(catalog: DocsCatalog, tree: DocsTree, node: TreeNode, read?: DepthRead): Promise<import("../docs.type.mjs").DocsNode>;
16
29
  /**
17
30
  * The typed edges a doc declares (spec:AST-047 FR5), resolved to routes: a
18
31
  * function doc's `command` and `related`, and a command doc's `fn` and
@@ -41,3 +54,15 @@ export function node(route: string, options?: {
41
54
  }): Promise<import("../docs.type.mjs").DocsNodeResponse>;
42
55
  export type DocsTree = import("../../../foundation/doc-compiler/tree.mjs").DocsTree;
43
56
  export type TreeNode = import("../../../foundation/doc-compiler/tree.mjs").TreeNode;
57
+ export type DocsCatalog = import("../../../foundation/discovery/docs-discovery.mjs").DocsCatalog;
58
+ /**
59
+ * How far a read goes below the node it names, and how much of each doc below
60
+ * it shows: `depth` levels (Infinity for every level), and `detail` brief (its
61
+ * identity), or compact or full (with its text: a namespace's intro, a guide's
62
+ * sections, a typed doc's content). `lang` selects the guides' language.
63
+ */
64
+ export type DepthRead = {
65
+ depth: number;
66
+ detail: "brief" | "compact" | "full";
67
+ lang: string | null;
68
+ };