@astryxdesign/cli 0.6.5-canary.4b7cb3a → 0.6.5-canary.4cdaedc

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 (283) hide show
  1. package/README.md +44 -42
  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.type.d.mts +33 -3
  19. package/api/component/component.type.mjs +10 -3
  20. package/api/component/detail/blocks/blocks.d.mts +2 -1
  21. package/api/component/detail/blocks/blocks.mjs +5 -2
  22. package/api/component/detail/detail.mjs +5 -1
  23. package/api/component/detail/props/props.d.mts +2 -1
  24. package/api/component/detail/props/props.mjs +3 -2
  25. package/api/component/detail/showcase/showcase.d.mts +3 -1
  26. package/api/component/detail/showcase/showcase.mjs +3 -1
  27. package/api/component/detail/source/source.d.mts +3 -2
  28. package/api/component/detail/source/source.mjs +7 -3
  29. package/api/component/list/list.mjs +128 -10
  30. package/api/docs/_adapter.d.mts +11 -0
  31. package/api/docs/_adapter.mjs +25 -0
  32. package/api/docs/detail/detail.mjs +19 -3
  33. package/api/docs/detail/section/section.mjs +7 -1
  34. package/api/docs/docs.d.mts +6 -0
  35. package/api/docs/docs.depth.test.mjs +134 -0
  36. package/api/docs/docs.doc.mjs +31 -2
  37. package/api/docs/docs.mjs +46 -1
  38. package/api/docs/docs.test.mjs +1 -1
  39. package/api/docs/docs.type.d.mts +81 -4
  40. package/api/docs/docs.type.mjs +41 -4
  41. package/api/docs/index/index.mjs +11 -2
  42. package/api/docs/index/index.test.mjs +7 -2
  43. package/api/docs/node/node.d.mts +28 -3
  44. package/api/docs/node/node.mjs +149 -23
  45. package/api/doctor/_adapter.d.mts +43 -0
  46. package/api/doctor/_adapter.mjs +142 -0
  47. package/api/doctor/doctor.d.mts +0 -10
  48. package/api/doctor/doctor.doc.mjs +1 -3
  49. package/api/doctor/doctor.mjs +6 -123
  50. package/api/doctor/theme-checks.d.mts +12 -0
  51. package/api/doctor/theme-checks.mjs +1117 -0
  52. package/api/doctor/theme-checks.test.mjs +483 -0
  53. package/api/gap-report/gap-report.mjs +15 -1
  54. package/api/hook/_adapter.d.mts +1 -0
  55. package/api/hook/_adapter.mjs +3 -0
  56. package/api/hook/detail/detail.mjs +2 -2
  57. package/api/hook/detail/params/params.mjs +2 -2
  58. package/api/hook/hook.type.d.mts +12 -0
  59. package/api/hook/hook.type.mjs +3 -0
  60. package/api/hook/list/list.d.mts +1 -1
  61. package/api/hook/list/list.mjs +8 -8
  62. package/api/index.d.mts +1 -1
  63. package/api/index.mjs +4 -0
  64. package/api/init/run/run.d.mts +3 -5
  65. package/api/init/run/run.mjs +10 -11
  66. package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
  67. package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
  68. package/api/integration/add-helpers.d.mts +26 -5
  69. package/api/integration/add-helpers.mjs +50 -5
  70. package/api/integration/add-theme.mjs +109 -5
  71. package/api/integration/add-theme.test.mjs +166 -15
  72. package/api/integration/authoring-checks.mjs +21 -1
  73. package/api/integration/integrationAddTheme.doc.mjs +1 -1
  74. package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
  75. package/api/integration/pack-check.component-replaces.test.mjs +126 -0
  76. package/api/integration/pack-check.d.mts +10 -0
  77. package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
  78. package/api/integration/pack-check.mjs +483 -1
  79. package/api/integration/pack-check.test.mjs +568 -8
  80. package/api/search/search.d.mts +11 -4
  81. package/api/search/search.doc.mjs +1 -1
  82. package/api/search/search.mjs +106 -53
  83. package/api/search/search.test.mjs +115 -2
  84. package/api/search/search.type.d.mts +3 -3
  85. package/api/search/search.type.mjs +2 -2
  86. package/api/swizzle/_adapter.d.mts +10 -0
  87. package/api/swizzle/_adapter.mjs +23 -0
  88. package/api/swizzle/copy/copy.mjs +22 -2
  89. package/api/swizzle/list/list.mjs +2 -2
  90. package/api/swizzle/swizzle.type.d.mts +8 -0
  91. package/api/swizzle/swizzle.type.mjs +2 -0
  92. package/api/template/copy/copy.mjs +2 -1
  93. package/api/template/show/show.mjs +2 -0
  94. package/api/template/skeleton/skeleton.mjs +2 -1
  95. package/api/template/template.d.mts +1 -1
  96. package/api/template/template.mjs +1 -0
  97. package/api/template/template.type.d.mts +12 -0
  98. package/api/template/template.type.mjs +3 -0
  99. package/api/theme/_adapter.d.mts +106 -6
  100. package/api/theme/_adapter.mjs +679 -18
  101. package/api/theme/add/add.binary.test.mjs +76 -3
  102. package/api/theme/add/add.d.mts +5 -9
  103. package/api/theme/add/add.mjs +87 -64
  104. package/api/theme/add/add.rollback.test.mjs +9 -9
  105. package/api/theme/add/add.staging.test.mjs +9 -9
  106. package/api/theme/add/add.test.mjs +461 -55
  107. package/api/theme/add/add.types.test.mjs +151 -0
  108. package/api/theme/build/build.d.mts +26 -2
  109. package/api/theme/build/build.family.test.mjs +13 -4
  110. package/api/theme/build/build.mjs +82 -78
  111. package/api/theme/build/build.test.mjs +30 -0
  112. package/api/theme/eject/eject.binary.test.mjs +90 -0
  113. package/api/theme/eject/eject.d.mts +17 -0
  114. package/api/theme/eject/eject.mjs +65 -0
  115. package/api/theme/eject/eject.rollback.test.mjs +158 -0
  116. package/api/theme/eject/eject.staging.test.mjs +83 -0
  117. package/api/theme/eject/eject.test.mjs +160 -0
  118. package/api/theme/integration-themes.test.mjs +30 -6
  119. package/api/theme/list/list.d.mts +10 -0
  120. package/api/theme/list/list.mjs +75 -7
  121. package/api/theme/list/list.test.mjs +155 -4
  122. package/api/theme/remove/remove.d.mts +12 -0
  123. package/api/theme/remove/remove.mjs +15 -0
  124. package/api/theme/remove/remove.test.mjs +94 -0
  125. package/api/theme/template/template.mjs +3 -4
  126. package/api/theme/theme.d.mts +5 -2
  127. package/api/theme/theme.mjs +13 -8
  128. package/api/theme/theme.type.d.mts +101 -2
  129. package/api/theme/theme.type.mjs +52 -5
  130. package/api/theme/themeAdd.doc.d.mts +1 -3
  131. package/api/theme/themeAdd.doc.mjs +35 -22
  132. package/api/theme/themeBuild.doc.mjs +1 -1
  133. package/api/theme/themeEject.doc.d.mts +8 -0
  134. package/api/theme/themeEject.doc.mjs +89 -0
  135. package/api/theme/themeListAvailable.doc.mjs +4 -4
  136. package/api/theme/themeListCopySources.doc.d.mts +8 -0
  137. package/api/theme/themeListCopySources.doc.mjs +60 -0
  138. package/api/theme/themeRemove.doc.d.mts +6 -0
  139. package/api/theme/themeRemove.doc.mjs +50 -0
  140. package/api/theme/themeTemplate.doc.mjs +4 -3
  141. package/api/theme/themeUse.doc.d.mts +6 -0
  142. package/api/theme/themeUse.doc.mjs +47 -0
  143. package/api/theme/use/use.d.mts +12 -0
  144. package/api/theme/use/use.mjs +15 -0
  145. package/api/theme/use/use.test.mjs +98 -0
  146. package/api/upgrade/_adapter.d.mts +1 -0
  147. package/api/upgrade/_adapter.mjs +3 -0
  148. package/api/upgrade/list/list.mjs +9 -3
  149. package/api/upgrade/upgrade.type.d.mts +4 -0
  150. package/api/upgrade/upgrade.type.mjs +1 -0
  151. package/assets/codemods/integration-discovery.mjs +1 -1
  152. package/assets/codemods/integration-discovery.test.mjs +64 -0
  153. package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
  154. package/assets/codemods/transforms/next/index.mjs +14 -1
  155. package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
  156. package/assets/docs/getting-started.doc.mjs +58 -14
  157. package/assets/docs/principles.doc.dense.mjs +2 -2
  158. package/assets/docs/principles.doc.mjs +2 -2
  159. package/assets/docs/principles.doc.zh.mjs +2 -2
  160. package/assets/docs/styling-libraries.doc.mjs +1 -1
  161. package/assets/docs/theme.doc.dense.mjs +23 -4
  162. package/assets/docs/theme.doc.mjs +75 -66
  163. package/assets/docs/theme.doc.zh.mjs +158 -12
  164. package/assets/docs/tokens.doc.mjs +3 -3
  165. package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
  166. package/assets/docs/tree/checks.doc.mjs +5 -4
  167. package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
  168. package/assets/docs/tree/fonts-and-assets.doc.mjs +24 -19
  169. package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
  170. package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
  171. package/assets/docs/tree/layout.doc.mjs +32 -0
  172. package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
  173. package/assets/docs/tree/responsive.doc.mjs +102 -0
  174. package/assets/docs/tree/scaffold.doc.mjs +145 -0
  175. package/assets/docs/tree/side-panels.doc.mjs +82 -0
  176. package/assets/docs/tree/structure.doc.mjs +144 -0
  177. package/assets/docs/tree/themes.doc.mjs +2 -2
  178. package/assets/docs/tree/troubleshooting.doc.mjs +4 -0
  179. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
  180. package/assets/docs/tree/versioning.doc.mjs +4 -1
  181. package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
  182. package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
  183. package/assets/templates/pages/table-comparison/page.tsx +1449 -0
  184. package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
  185. package/authoring/doctypes/command/command.doc.mjs +5 -0
  186. package/authoring/doctypes/command/type.ts +2 -0
  187. package/authoring/doctypes/component/component.doc.mjs +1 -1
  188. package/authoring/doctypes/component/type.ts +8 -4
  189. package/authoring/integration/integration.doc.mjs +1 -1
  190. package/clients/cli/commands/build-theme.mjs +266 -27
  191. package/clients/cli/commands/build.mjs +7 -6
  192. package/clients/cli/commands/build.text-fields.test.mjs +1 -1
  193. package/clients/cli/commands/component/index.mjs +88 -12
  194. package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
  195. package/clients/cli/commands/component.doc.mjs +9 -2
  196. package/clients/cli/commands/docs.depth.test.mjs +219 -0
  197. package/clients/cli/commands/docs.doc.mjs +15 -2
  198. package/clients/cli/commands/docs.mjs +273 -16
  199. package/clients/cli/commands/docs.test.mjs +2 -2
  200. package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
  201. package/clients/cli/commands/doctor.doc.mjs +1 -1
  202. package/clients/cli/commands/doctor.test.mjs +9 -51
  203. package/clients/cli/commands/gap-report.doc.mjs +2 -2
  204. package/clients/cli/commands/hook/index.mjs +7 -2
  205. package/clients/cli/commands/init.next-steps.test.mjs +18 -23
  206. package/clients/cli/commands/integration-add.doc.mjs +1 -1
  207. package/clients/cli/commands/integration-real-world.test.mjs +61 -12
  208. package/clients/cli/commands/layout-check.doc.mjs +1 -0
  209. package/clients/cli/commands/layout-expand.doc.mjs +1 -0
  210. package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
  211. package/clients/cli/commands/layout.doc.mjs +1 -0
  212. package/clients/cli/commands/layout.mjs +45 -4
  213. package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
  214. package/clients/cli/commands/search.test.mjs +23 -14
  215. package/clients/cli/commands/swizzle.doc.mjs +12 -3
  216. package/clients/cli/commands/swizzle.mjs +2 -1
  217. package/clients/cli/commands/template.mjs +8 -4
  218. package/clients/cli/commands/text-json-parity.test.mjs +40 -0
  219. package/clients/cli/commands/theme-add-lifecycle.test.mjs +129 -0
  220. package/clients/cli/commands/theme-add.doc.mjs +19 -19
  221. package/clients/cli/commands/theme-eject.doc.mjs +47 -0
  222. package/clients/cli/commands/theme-list.behavior.test.mjs +5 -2
  223. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  224. package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
  225. package/clients/cli/commands/theme-remove.doc.mjs +22 -0
  226. package/clients/cli/commands/theme-template.doc.mjs +4 -3
  227. package/clients/cli/commands/theme-use.doc.mjs +22 -0
  228. package/clients/cli/commands/theme.doc.mjs +21 -16
  229. package/clients/cli/commands/upgrade.mjs +1 -1
  230. package/clients/cli/index.mjs +4 -1
  231. package/clients/cli/lib/component-format.mjs +19 -2
  232. package/clients/cli/lib/resolve-theme.mjs +80 -78
  233. package/clients/cli/lib/resolve-theme.test.mjs +523 -27
  234. package/foundation/agent-docs/agent-docs.mjs +2 -2
  235. package/foundation/agent-docs/app-theme-workflow.test.mjs +16 -0
  236. package/foundation/config/project.d.mts +20 -5
  237. package/foundation/config/project.mjs +43 -6
  238. package/foundation/config/theme-private-vars.d.mts +12 -0
  239. package/foundation/config/theme-private-vars.mjs +107 -0
  240. package/foundation/config/theme-private-vars.test.mjs +55 -0
  241. package/foundation/config/theme-state.d.mts +145 -0
  242. package/foundation/config/theme-state.mjs +417 -0
  243. package/foundation/config/theme-state.test.mjs +182 -0
  244. package/foundation/discovery/component-discovery.d.mts +5 -2
  245. package/foundation/discovery/component-discovery.mjs +12 -6
  246. package/foundation/discovery/component-replacement.d.mts +91 -0
  247. package/foundation/discovery/component-replacement.mjs +417 -0
  248. package/foundation/discovery/component-replacement.test.mjs +480 -0
  249. package/foundation/discovery/docs-output-budget.d.mts +6 -2
  250. package/foundation/discovery/docs-output-budget.mjs +2 -1
  251. package/foundation/discovery/docs-section-key.d.mts +4 -2
  252. package/foundation/discovery/docs-section-key.mjs +1 -1
  253. package/foundation/discovery/module-exports.d.mts +10 -0
  254. package/foundation/discovery/module-exports.mjs +146 -0
  255. package/foundation/discovery/package-exports.d.mts +29 -0
  256. package/foundation/discovery/package-exports.mjs +200 -0
  257. package/foundation/discovery/theme-discovery.d.mts +78 -5
  258. package/foundation/discovery/theme-discovery.mjs +143 -18
  259. package/foundation/discovery/theme-discovery.test.mjs +9 -3
  260. package/foundation/discovery/theme-imports.d.mts +15 -0
  261. package/foundation/discovery/theme-imports.mjs +217 -0
  262. package/foundation/discovery/theme-imports.test.mjs +173 -0
  263. package/foundation/doc-compiler/doc-loads.test.mjs +15 -5
  264. package/foundation/doc-compiler/inputs.mjs +2 -1
  265. package/foundation/doc-compiler/lenses.d.mts +4 -2
  266. package/foundation/doc-compiler/lenses.mjs +1 -1
  267. package/foundation/doc-compiler/tree.test.mjs +2 -2
  268. package/foundation/fs/module-loader.d.mts +9 -0
  269. package/foundation/fs/module-loader.mjs +71 -2
  270. package/foundation/integrations/cli-requirement.d.mts +22 -0
  271. package/foundation/integrations/cli-requirement.mjs +31 -0
  272. package/foundation/integrations/cli-requirement.test.mjs +70 -0
  273. package/foundation/integrations/contribution-inventory.mjs +3 -3
  274. package/foundation/response/base.d.ts +9 -3
  275. package/foundation/response/json.d.mts +7 -4
  276. package/foundation/response/json.mjs +10 -6
  277. package/foundation/response/response-types.doc.mjs +38 -23
  278. package/foundation/response/response.doc.mjs +18 -4
  279. package/foundation/text/copyright-header.mjs +1 -1
  280. package/foundation/text/copyright-header.test.mjs +1 -1
  281. package/package.json +9 -9
  282. package/assets/docs/layout.doc.dense.mjs +0 -388
  283. package/assets/docs/layout.doc.mjs +0 -550
@@ -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);
@@ -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
+ };
@@ -7,14 +7,18 @@
7
7
  * typed doc such as `cli/api/functions/search`, plus {cwd}.
8
8
  * @output { type: 'docs.node', data: DocsNode } — the node's identity, title
9
9
  * and summary, the namespaces above it, and either its slots with their
10
- * children (a namespace) or its content (a typed doc). A namespace never
11
- * lists its grandchildren, so a reader goes down one level at a time.
12
- * Matches `astryx --json docs <route>`.
10
+ * children (a namespace) or its content (a typed doc). By default a
11
+ * namespace lists its children one level down; a depth read goes as far
12
+ * down as asked, with each doc below as its identity (brief) or with its
13
+ * text (compact, full). Matches `astryx --json docs <route> [--depth <n>]`.
13
14
  * @position Leaf under api/docs, beside the topic leaves. A guide the tree
14
15
  * places is a topic: the detail leaf reads it by its route.
15
16
  */
16
17
 
18
+ import {detailView} from '../../../foundation/doc-compiler/lenses.mjs';
17
19
  import {
20
+ compileTopic,
21
+ guideEntry,
18
22
  nodeContent,
19
23
  placeLinks,
20
24
  resolveDocsArgument,
@@ -24,18 +28,34 @@ import {
24
28
  /**
25
29
  * @typedef {import('../../../foundation/doc-compiler/tree.mjs').DocsTree} DocsTree
26
30
  * @typedef {import('../../../foundation/doc-compiler/tree.mjs').TreeNode} TreeNode
31
+ * @typedef {import('../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} DocsCatalog
27
32
  */
28
33
 
29
34
  /**
30
- * The docs.node view of one tree node.
31
- * @param {import('../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} catalog
35
+ * How far a read goes below the node it names, and how much of each doc below
36
+ * it shows: `depth` levels (Infinity for every level), and `detail` brief (its
37
+ * identity), or compact or full (with its text: a namespace's intro, a guide's
38
+ * sections, a typed doc's content). `lang` selects the guides' language.
39
+ * @typedef {object} DepthRead
40
+ * @property {number} depth
41
+ * @property {'brief' | 'compact' | 'full'} detail
42
+ * @property {string | null} lang
43
+ */
44
+
45
+ /**
46
+ * The docs.node view of one tree node. Without a depth read, a namespace lists
47
+ * its children one level down.
48
+ * @param {DocsCatalog} catalog
32
49
  * @param {DocsTree} tree
33
50
  * @param {TreeNode} node
51
+ * @param {DepthRead} [read] how far down to go, and how much of each doc below
34
52
  * @returns {Promise<import('../docs.type.mjs').DocsNode>}
35
53
  */
36
- export async function nodeView(catalog, tree, node) {
54
+ export async function nodeView(catalog, tree, node, read) {
37
55
  const {content} = await nodeContent(catalog, tree, node);
38
- return {
56
+ const slots = node.slots.filter(slot => slot.children.length > 0);
57
+ /** @type {import('../docs.type.mjs').DocsNode} */
58
+ const view = {
39
59
  id: node.id,
40
60
  route: node.route,
41
61
  kind: node.kind,
@@ -45,25 +65,129 @@ export async function nodeView(catalog, tree, node) {
45
65
  breadcrumb: tree
46
66
  .ancestors(node)
47
67
  .map(ancestor => ({route: ancestor.route, title: ancestor.title})),
48
- slots: node.slots
49
- .filter(slot => slot.children.length > 0)
50
- .map(slot => ({
51
- name: slot.name,
52
- title: slot.title,
53
- children: slot.children.map(route => {
54
- const child = /** @type {TreeNode} */ (tree.get(route));
55
- return {
56
- route: child.route,
57
- name: child.route.slice(child.route.lastIndexOf('/') + 1),
58
- kind: child.kind,
59
- title: child.title,
60
- summary: child.summary,
61
- };
62
- }),
63
- })),
68
+ slots: !read
69
+ ? slots.map(slot => ({
70
+ name: slot.name,
71
+ title: slot.title,
72
+ children: slot.children.map(route =>
73
+ childIdentity(/** @type {TreeNode} */ (tree.get(route))),
74
+ ),
75
+ }))
76
+ : read.depth >= 1
77
+ ? await slotsBelow(catalog, tree, slots, 1, read)
78
+ : [],
64
79
  content,
65
80
  links: nodeLinks(tree, node),
66
81
  };
82
+ if (read && read.depth < 1 && slots.length > 0) {
83
+ view.childCount = countChildren(slots);
84
+ }
85
+ return view;
86
+ }
87
+
88
+ /**
89
+ * The fields every child carries: what it is, and the route that opens it.
90
+ * @param {TreeNode} child
91
+ * @returns {import('../docs.type.mjs').DocsNodeChild}
92
+ */
93
+ function childIdentity(child) {
94
+ return {
95
+ route: child.route,
96
+ name: child.route.slice(child.route.lastIndexOf('/') + 1),
97
+ package: child.provider,
98
+ kind: child.kind,
99
+ title: child.title,
100
+ summary: child.summary,
101
+ };
102
+ }
103
+
104
+ /**
105
+ * @param {TreeNode['slots']} slots
106
+ * @returns {number}
107
+ */
108
+ function countChildren(slots) {
109
+ return slots.reduce((count, slot) => count + slot.children.length, 0);
110
+ }
111
+
112
+ /**
113
+ * Slots read `level` levels below the named node: each child at the read's
114
+ * detail, and its own slots while the read goes deeper.
115
+ * @param {DocsCatalog} catalog
116
+ * @param {DocsTree} tree
117
+ * @param {TreeNode['slots']} slots
118
+ * @param {number} level
119
+ * @param {DepthRead} read
120
+ * @returns {Promise<import('../docs.type.mjs').DocsNodeSlot[]>}
121
+ */
122
+ async function slotsBelow(catalog, tree, slots, level, read) {
123
+ return Promise.all(
124
+ slots.map(async slot => ({
125
+ name: slot.name,
126
+ title: slot.title,
127
+ children: await Promise.all(
128
+ slot.children.map(route =>
129
+ childBelow(
130
+ catalog,
131
+ tree,
132
+ /** @type {TreeNode} */ (tree.get(route)),
133
+ level,
134
+ read,
135
+ ),
136
+ ),
137
+ ),
138
+ })),
139
+ );
140
+ }
141
+
142
+ /**
143
+ * One child of a depth read. Where the read stops, a child with docs below it
144
+ * says how many, so a reader knows to go deeper.
145
+ * @param {DocsCatalog} catalog
146
+ * @param {DocsTree} tree
147
+ * @param {TreeNode} child
148
+ * @param {number} level
149
+ * @param {DepthRead} read
150
+ * @returns {Promise<import('../docs.type.mjs').DocsNodeChild>}
151
+ */
152
+ async function childBelow(catalog, tree, child, level, read) {
153
+ const view = childIdentity(child);
154
+ if (read.detail !== 'brief') {
155
+ Object.assign(view, await childText(catalog, tree, child, read.lang));
156
+ }
157
+ const slots = child.slots.filter(slot => slot.children.length > 0);
158
+ if (slots.length > 0) {
159
+ if (level < read.depth) {
160
+ view.slots = await slotsBelow(catalog, tree, slots, level + 1, read);
161
+ } else {
162
+ view.childCount = countChildren(slots);
163
+ }
164
+ }
165
+ return view;
166
+ }
167
+
168
+ /**
169
+ * A child's text: a guide's compiled sections, or the content of a namespace
170
+ * or typed doc.
171
+ * @param {DocsCatalog} catalog
172
+ * @param {DocsTree} tree
173
+ * @param {TreeNode} child
174
+ * @param {string | null} lang
175
+ * @returns {Promise<{content?: any[], sections?: any[]}>}
176
+ */
177
+ async function childText(catalog, tree, child, lang) {
178
+ if (child.kind === 'generic') {
179
+ const entry = child.ref?.topicFile
180
+ ? guideEntry(child)
181
+ : child.ref?.flatTopic
182
+ ? catalog.resolve(child.ref.flatTopic)
183
+ : null;
184
+ if (!entry) return {};
185
+ return {
186
+ sections: detailView(await compileTopic(catalog, entry, lang)).sections,
187
+ };
188
+ }
189
+ const {content} = await nodeContent(catalog, tree, child);
190
+ return {content};
67
191
  }
68
192
 
69
193
  /**
@@ -187,6 +311,8 @@ export async function node(route, options = {}) {
187
311
  throw await unknownTopicError(route, found.catalog);
188
312
  return {
189
313
  type: 'docs.node',
314
+ // The docs tree names each node's npm package as its provider.
315
+ package: found.node.provider,
190
316
  data: await nodeView(found.catalog, found.tree, found.node),
191
317
  };
192
318
  }
@@ -0,0 +1,43 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * Package written to the generated app record for one discovered theme.
6
+ * @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
7
+ */
8
+ export function themeRecordOwner(theme: import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme): string;
9
+ /** @param {string} file */
10
+ export function readTextFile(file: string): string;
11
+ /** @param {string} file */
12
+ export function readTextFileIfExists(file: string): string | null;
13
+ /**
14
+ * A bounded app-source walk that excludes dependencies, generated output, and
15
+ * links. The doctor parses the returned bytes without executing app code.
16
+ * @param {string} root
17
+ * @param {string} generatedModule
18
+ */
19
+ export function listProjectSourceFiles(root: string, generatedModule: string): string[];
20
+ /** @param {string} projectDir */
21
+ export function discoverDoctorThemes(projectDir: string): Promise<import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme[]>;
22
+ /**
23
+ * Resolve one discovered theme's built module and stylesheets.
24
+ * @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
25
+ * @param {{cwd: string, ownerThemeCount: number}} options
26
+ */
27
+ export function resolveDoctorThemeImports(theme: import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme, options: {
28
+ cwd: string;
29
+ ownerThemeCount: number;
30
+ }): import("../../foundation/config/theme-state.mjs").ResolvedAppTheme;
31
+ /** @param {string} projectDir */
32
+ export function discoverDoctorUnmigratedCopies(projectDir: string): import("../../foundation/discovery/theme-discovery.mjs").UnmigratedThemeCopy[];
33
+ /** @param {string} projectDir */
34
+ export function findDoctorCoreDir(projectDir: string): string | null;
35
+ /** @param {string} projectDir @param {string} packageName */
36
+ export function findDoctorInstalledPackage(projectDir: string, packageName: string): string | null;
37
+ /** @param {string} file */
38
+ export function readPackageJson(file: string): any;
39
+ export { resolveRecordedTheme } from "../theme/theme.mjs";
40
+ export { collectUnloadedFonts } from "../theme/build/font-warning.mjs";
41
+ export const SOURCE_EXTENSIONS: Set<string>;
42
+ export { isLocalThemeOwner, planThemeAppWrite, readThemeState, resolveThemeModule } from "../../foundation/config/theme-state.mjs";
43
+ export { themeBuild, validateThemePrivateInputs } from "../theme/build/build.mjs";