@astryxdesign/cli 0.6.3-canary.1f30d4e → 0.6.3-canary.1ffe66d

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 (181) hide show
  1. package/README.md +19 -17
  2. package/api/component/_adapter.d.mts +6 -12
  3. package/api/component/_adapter.mjs +20 -10
  4. package/api/component/component.mjs +60 -12
  5. package/api/component/list/list.mjs +3 -2
  6. package/api/docs/_adapter.d.mts +209 -28
  7. package/api/docs/_adapter.mjs +667 -35
  8. package/api/docs/detail/detail.mjs +11 -3
  9. package/api/docs/detail/section/section.mjs +20 -3
  10. package/api/docs/docs.d.mts +5 -3
  11. package/api/docs/docs.doc.mjs +35 -15
  12. package/api/docs/docs.mjs +44 -8
  13. package/api/docs/docs.test.mjs +158 -4
  14. package/api/docs/docs.type.d.mts +165 -2
  15. package/api/docs/docs.type.mjs +101 -3
  16. package/api/docs/index/index.mjs +11 -3
  17. package/api/docs/index/index.test.mjs +1 -1
  18. package/api/docs/integration-tree.test.mjs +547 -0
  19. package/api/docs/integrationDocs.test.mjs +14 -14
  20. package/api/docs/list/list.mjs +25 -5
  21. package/api/docs/node/node.d.mts +43 -0
  22. package/api/docs/node/node.mjs +192 -0
  23. package/api/doctor/doctor.d.mts +30 -2
  24. package/api/doctor/doctor.mjs +146 -7
  25. package/api/doctor/doctor.test.mjs +89 -1
  26. package/api/index.d.mts +1 -1
  27. package/api/index.mjs +1 -0
  28. package/api/init/init.doc.mjs +1 -1
  29. package/api/integration/add-contribution.d.mts +2 -1
  30. package/api/integration/add-contribution.mjs +107 -5
  31. package/api/integration/add-contribution.test.mjs +137 -0
  32. package/api/integration/authoring-checks.mjs +125 -28
  33. package/api/integration/authoring-checks.test.mjs +171 -3
  34. package/api/integration/authoring-checks.type.mjs +6 -1
  35. package/api/integration/integration-authoring.type.d.mts +2 -0
  36. package/api/integration/integration-authoring.type.mjs +2 -0
  37. package/api/integration/integrationAdd.doc.mjs +6 -0
  38. package/api/integration/integrationAddDoc.doc.mjs +7 -1
  39. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  40. package/api/integration/integrationPackCheck.doc.mjs +1 -1
  41. package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
  42. package/api/integration/integrationTemplateConflicts.doc.mjs +3 -0
  43. package/api/integration/pack-check.mjs +34 -0
  44. package/api/integration/pack-check.test.mjs +121 -0
  45. package/api/integration/pack-check.type.d.mts +26 -2
  46. package/api/integration/pack-check.type.mjs +14 -1
  47. package/api/integration/template-conflict-compatibility.test.mjs +73 -0
  48. package/api/integration/validate-integration.test.mjs +3 -3
  49. package/api/integration/validateIntegration.doc.mjs +1 -1
  50. package/api/json/index.ts +2 -0
  51. package/api/layout/_adapter.mjs +20 -5
  52. package/api/search/search.d.mts +26 -1
  53. package/api/search/search.doc.mjs +4 -3
  54. package/api/search/search.mjs +308 -29
  55. package/api/search/search.test.mjs +91 -2
  56. package/api/search/search.type.d.mts +13 -1
  57. package/api/search/search.type.mjs +4 -1
  58. package/api/template/list/list.mjs +1 -0
  59. package/api/template/template-integration.test.mjs +1022 -3
  60. package/api/template/template.doc.mjs +27 -7
  61. package/api/template/template.mjs +45 -8
  62. package/api/template/template.type.d.mts +6 -8
  63. package/api/template/template.type.mjs +3 -2
  64. package/api/theme/template/template.test.mjs +5 -0
  65. package/api/theme/themeTemplate.doc.mjs +1 -1
  66. package/assets/docs/getting-started.doc.mjs +2 -2
  67. package/assets/docs/principles.doc.mjs +6 -6
  68. package/assets/docs/styling-libraries.doc.mjs +2 -2
  69. package/assets/docs/styling.doc.mjs +4 -4
  70. package/assets/docs/theme.doc.mjs +3 -3
  71. package/assets/docs/tokens.doc.mjs +1 -1
  72. package/assets/docs/tree/api.doc.mjs +30 -0
  73. package/assets/docs/tree/cli.doc.mjs +23 -0
  74. package/assets/docs/tree/commands.doc.mjs +25 -0
  75. package/assets/docs/{cli-integrations.doc.mjs → tree/integrations.doc.mjs} +37 -9
  76. package/assets/docs/tree/integrations.test.mjs +62 -0
  77. package/assets/docs/tree/writing-docs.doc.mjs +286 -0
  78. package/authoring/debug/parse.d.mts +3 -3
  79. package/authoring/doctypes/base/graph-fields.doc.mjs +7 -5
  80. package/authoring/doctypes/base/type.ts +6 -5
  81. package/authoring/doctypes/command/command.doc.mjs +1 -1
  82. package/authoring/doctypes/command/type.ts +2 -2
  83. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  84. package/authoring/doctypes/enum/type.ts +1 -1
  85. package/authoring/doctypes/function/function.doc.mjs +3 -2
  86. package/authoring/doctypes/function/type.ts +3 -2
  87. package/authoring/doctypes/namespace/namespace.doc.mjs +5 -9
  88. package/authoring/doctypes/reference/reference.doc.mjs +3 -3
  89. package/authoring/doctypes/reference/type.ts +3 -0
  90. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  91. package/authoring/doctypes/schema/type.ts +1 -1
  92. package/authoring/doctypes/template/parse.d.mts +2 -0
  93. package/authoring/doctypes/template/parse.mjs +4 -0
  94. package/authoring/doctypes/template/parse.test.mjs +18 -0
  95. package/authoring/doctypes/template/template.doc.mjs +6 -0
  96. package/authoring/doctypes/template/type.ts +8 -0
  97. package/authoring/identity/identity.doc.mjs +2 -2
  98. package/authoring/integration/type.ts +1 -1
  99. package/clients/cli/commands/build-theme.mjs +1 -1
  100. package/clients/cli/commands/build.mjs +5 -2
  101. package/clients/cli/commands/component/index.mjs +1 -1
  102. package/clients/cli/commands/component-ownership.test.mjs +3 -3
  103. package/clients/cli/commands/discover.broken-integration.test.mjs +7 -8
  104. package/clients/cli/commands/discover.mjs +1 -1
  105. package/clients/cli/commands/docs.doc.mjs +20 -8
  106. package/clients/cli/commands/docs.mjs +175 -18
  107. package/clients/cli/commands/docs.test.mjs +114 -7
  108. package/clients/cli/commands/doctor-integration-docs.doc.mjs +2 -2
  109. package/clients/cli/commands/doctor-integration-templates.doc.mjs +14 -7
  110. package/clients/cli/commands/doctor-integration.test.mjs +75 -1
  111. package/clients/cli/commands/doctor.mjs +53 -16
  112. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  113. package/clients/cli/commands/integration.mjs +1 -0
  114. package/clients/cli/commands/search.mjs +11 -2
  115. package/clients/cli/commands/setup-nudge.test.mjs +6 -0
  116. package/clients/cli/commands/template.doc.mjs +23 -6
  117. package/clients/cli/commands/template.mjs +4 -91
  118. package/clients/cli/commands/text-json-parity.test.mjs +2 -1
  119. package/clients/cli/index.mjs +8 -0
  120. package/clients/cli/lib/manifest.mjs +9 -2
  121. package/foundation/agent-docs/agent-docs.mjs +1 -0
  122. package/foundation/agent-docs/agent-docs.test.mjs +10 -1
  123. package/foundation/config/project.d.mts +12 -11
  124. package/foundation/config/project.mjs +73 -59
  125. package/foundation/config/project.test.mjs +141 -5
  126. package/foundation/discovery/authoring-self-docs.test.mjs +17 -7
  127. package/foundation/discovery/cli-self-docs.d.mts +40 -34
  128. package/foundation/discovery/cli-self-docs.mjs +91 -115
  129. package/foundation/discovery/cli-self-docs.test.mjs +104 -166
  130. package/foundation/discovery/component-discovery.d.mts +38 -0
  131. package/foundation/discovery/component-discovery.mjs +48 -0
  132. package/foundation/discovery/docs-discovery.d.mts +105 -8
  133. package/foundation/discovery/docs-discovery.mjs +177 -13
  134. package/foundation/discovery/docs-discovery.test.mjs +56 -17
  135. package/foundation/discovery/docs-output-budget.d.mts +2 -2
  136. package/foundation/discovery/docs-output-budget.mjs +1 -1
  137. package/foundation/discovery/docs-section-key.d.mts +9 -2
  138. package/foundation/discovery/docs-section-key.mjs +15 -1
  139. package/foundation/discovery/template-adapter.d.mts +92 -6
  140. package/foundation/discovery/template-adapter.mjs +453 -17
  141. package/foundation/discovery/template-adapter.test.mjs +42 -0
  142. package/foundation/discovery/template-conflict-release.d.mts +13 -0
  143. package/foundation/discovery/template-conflict-release.mjs +40 -0
  144. package/foundation/discovery/template-conflict-release.test.mjs +40 -0
  145. package/foundation/doc-compiler/bundle.mjs +61 -1
  146. package/foundation/doc-compiler/bundle.test.mjs +21 -10
  147. package/foundation/doc-compiler/compile.d.mts +113 -132
  148. package/foundation/doc-compiler/compile.mjs +52 -6
  149. package/foundation/doc-compiler/diagnostics.mjs +28 -0
  150. package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
  151. package/foundation/doc-compiler/inputs.d.mts +2 -2
  152. package/foundation/doc-compiler/inputs.mjs +6 -1
  153. package/foundation/doc-compiler/ir.mjs +7 -0
  154. package/foundation/doc-compiler/lenses.d.mts +3 -2
  155. package/foundation/doc-compiler/lenses.mjs +2 -1
  156. package/foundation/doc-compiler/links.d.mts +135 -0
  157. package/foundation/doc-compiler/links.mjs +253 -0
  158. package/foundation/doc-compiler/links.test.mjs +139 -0
  159. package/foundation/doc-compiler/lower-doc.test.mjs +5 -2
  160. package/foundation/doc-compiler/read.d.mts +3 -2
  161. package/foundation/doc-compiler/read.mjs +6 -1
  162. package/foundation/doc-compiler/tree.d.mts +288 -0
  163. package/foundation/doc-compiler/tree.mjs +876 -0
  164. package/foundation/doc-compiler/tree.test.mjs +598 -0
  165. package/foundation/integrations/autolink.test.mjs +1 -1
  166. package/foundation/integrations/cli-requirement.d.mts +45 -0
  167. package/foundation/integrations/cli-requirement.mjs +154 -0
  168. package/foundation/integrations/cli-requirement.test.mjs +109 -0
  169. package/foundation/integrations/contribution-inventory.d.mts +2 -1
  170. package/foundation/integrations/contribution-inventory.mjs +10 -4
  171. package/foundation/integrations/contribution-inventory.test.mjs +19 -0
  172. package/foundation/integrations/integration-warnings.d.mts +9 -2
  173. package/foundation/integrations/integration-warnings.mjs +51 -26
  174. package/foundation/integrations/integration-warnings.test.mjs +74 -1
  175. package/foundation/integrations/validate-contributions.mjs +25 -27
  176. package/foundation/response/response-types.doc.d.mts +5 -1
  177. package/foundation/response/response-types.doc.mjs +18 -9
  178. package/foundation/xle/expand.mjs +1 -1
  179. package/foundation/xle/xle.test.mjs +13 -0
  180. package/package.json +9 -9
  181. package/assets/docs/cli.doc.mjs +0 -15
@@ -5,6 +5,8 @@
5
5
  * @typedef {object} DocsTopicRecord A doc file discovered under a docs root.
6
6
  * @property {string} name
7
7
  * @property {string} package owner package
8
+ * @property {string} [providerId] the owner's ProviderId, when it differs from
9
+ * the package name
8
10
  * @property {string} path absolute path to the doc file
9
11
  * @property {string} [title]
10
12
  * @property {string} [description]
@@ -16,13 +18,21 @@
16
18
  * @typedef {object} DocsTopicEntry A resolved topic in the catalog.
17
19
  * @property {string} name
18
20
  * @property {string} package owner package
21
+ * @property {string} [providerId] the owner's ProviderId; the package name when
22
+ * absent. Links in the topic resolve against it.
19
23
  * @property {string} path absolute path to the doc file
20
24
  * @property {string} [title]
21
25
  * @property {string} [description]
22
26
  * @property {string|null} [category]
23
27
  * @property {string} [replaces] the topic this one took the place of
24
- * @property {Array<{package: string, path: string}>} extensions overlays to
25
- * merge onto the base doc, in the order their integrations were configured
28
+ * @property {Array<{package: string, path: string, providerId?: string}>} extensions
29
+ * overlays to merge onto the base doc, in the order their integrations were
30
+ * configured; each section an extension adds resolves its links against the
31
+ * extension's provider id (its package name when absent)
32
+ * @property {string} [parent] the route of the namespace a tree guide sits in
33
+ * @property {string} [route] a tree guide's route
34
+ * @property {boolean} [tree] a guide that only the docs tree reads, by its
35
+ * route; never a flat topic
26
36
  */
27
37
  /**
28
38
  * Discover the CLI's own topics.
@@ -48,9 +58,19 @@ export function loadTopicModule(file: string): Promise<unknown>;
48
58
  * where the file that needs fixing can be named.
49
59
  *
50
60
  * @param {any} doc a parsed doc
61
+ * @param {{placement?: boolean}} [options] `placement`: the doc is a guide the
62
+ * docs tree places, so its `placement` field is read, not rejected
51
63
  * @returns {string[]} problems, each already pointed at a place in the doc
52
64
  */
53
- export function problemsInTopic(doc: any): string[];
65
+ export function problemsInTopic(doc: any, { placement }?: {
66
+ placement?: boolean;
67
+ }): string[];
68
+ /**
69
+ * The fields the docs tree reads from a namespace doc an integration ships.
70
+ * @param {any} doc
71
+ * @returns {string[]}
72
+ */
73
+ export function problemsInNamespace(doc: any): string[];
54
74
  /**
55
75
  * Discover the topics contributed by a single loaded integration. Mirrors
56
76
  * `discoverIntegrationComponents`: walk the resolved root, take every
@@ -58,18 +78,25 @@ export function problemsInTopic(doc: any): string[];
58
78
  * discovery this loads each doc, because a topic's name and its relationship
59
79
  * to an existing topic are fields inside the file.
60
80
  *
81
+ * A namespace doc and a guide with `placement` go to the docs tree instead of
82
+ * the topic list (spec:AST-046): they come back in `namespaces` and `guides`,
83
+ * named by the integration's provider id.
84
+ *
61
85
  * Errors are returned, not thrown: one unusable doc is reported as an issue
62
86
  * against its package while the rest of the CLI keeps working.
63
87
  *
64
- * @param {{name: string, docs?: string}} integration a loaded integration
65
- * @returns {Promise<{records: DocsTopicRecord[], errors: Error[]}>}
88
+ * @param {{name: string, docs?: string, providerId?: string}} integration a loaded integration
89
+ * @returns {Promise<{records: DocsTopicRecord[], errors: Error[], namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>}
66
90
  */
67
91
  export function discoverIntegrationDocs(integration: {
68
92
  name: string;
69
93
  docs?: string;
94
+ providerId?: string;
70
95
  }): Promise<{
71
96
  records: DocsTopicRecord[];
72
97
  errors: Error[];
98
+ namespaces: import("../doc-compiler/tree.mjs").TreeNamespaceInput[];
99
+ guides: import("../doc-compiler/tree.mjs").TreeDocInput[];
73
100
  }>;
74
101
  /**
75
102
  * Merge an extension onto a base topic: a section with a stable `id` replaces
@@ -97,7 +124,10 @@ export { withSourceTitle };
97
124
  export const BUILTIN_DOCS_PACKAGE: import("../../authoring/index.js").ProviderId;
98
125
  /** Blocks that are valid authoring but require the compiled graph renderer. */
99
126
  export const GRAPH_BLOCK_TYPES: Set<string>;
100
- /** Doc fields only the docs graph reads; a topic that sets one fails to load. */
127
+ /**
128
+ * Doc fields only the docs tree reads. A flat topic that sets one fails to
129
+ * load; a guide the tree places may set `placement` (spec:AST-046).
130
+ */
101
131
  export const GRAPH_ONLY_FIELDS: string[];
102
132
  /**
103
133
  * Every topic a project can read, and the relationships between them.
@@ -114,6 +144,40 @@ export class DocsCatalog {
114
144
  * @returns {DocsCatalog}
115
145
  */
116
146
  static fromBuiltins(builtins?: Record<string, string>): DocsCatalog;
147
+ /**
148
+ * Record a doc file a package ships that did not load. Its package's docs
149
+ * are withdrawn; readers name the package so an author knows where to look.
150
+ * @param {{package: string, message: string}} issue
151
+ */
152
+ addIssue(issue: {
153
+ package: string;
154
+ message: string;
155
+ }): void;
156
+ /**
157
+ * The doc files that did not load, by package.
158
+ * @returns {ReadonlyArray<{package: string, message: string}>}
159
+ */
160
+ get issues(): ReadonlyArray<{
161
+ package: string;
162
+ message: string;
163
+ }>;
164
+ /**
165
+ * Add the namespace docs and placed guides one integration ships to the
166
+ * docs tree (spec:AST-046).
167
+ * @param {{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}} inputs
168
+ */
169
+ addTreeInputs(inputs: {
170
+ namespaces: import("../doc-compiler/tree.mjs").TreeNamespaceInput[];
171
+ guides: import("../doc-compiler/tree.mjs").TreeDocInput[];
172
+ }): void;
173
+ /**
174
+ * What the integrations add to the docs tree, in configured order.
175
+ * @returns {ReadonlyArray<{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>}
176
+ */
177
+ get treeInputs(): ReadonlyArray<{
178
+ namespaces: import("../doc-compiler/tree.mjs").TreeNamespaceInput[];
179
+ guides: import("../doc-compiler/tree.mjs").TreeDocInput[];
180
+ }>;
117
181
  /**
118
182
  * Add one integration-contributed doc, honoring what it declares. Returns
119
183
  * the issue it caused, or null when it applied cleanly — the caller owns
@@ -123,6 +187,14 @@ export class DocsCatalog {
123
187
  * @returns {import('../integrations/issue').AstryxIntegrationIssue | null}
124
188
  */
125
189
  add(record: DocsTopicRecord): import("../integrations/issue").AstryxIntegrationIssue | null;
190
+ /**
191
+ * Every other name a topic answers to, lowercased: the names of the topics
192
+ * it replaced, directly or through a chain of replacements. `resolve` finds
193
+ * the topic by each of them.
194
+ * @param {DocsTopicEntry} entry
195
+ * @returns {string[]}
196
+ */
197
+ aliasesOf(entry: DocsTopicEntry): string[];
126
198
  /**
127
199
  * Look a topic up by name, case-insensitively, following the alias a renamed
128
200
  * replacement left behind.
@@ -145,6 +217,11 @@ export type DocsTopicRecord = {
145
217
  * owner package
146
218
  */
147
219
  package: string;
220
+ /**
221
+ * the owner's ProviderId, when it differs from
222
+ * the package name
223
+ */
224
+ providerId?: string | undefined;
148
225
  /**
149
226
  * absolute path to the doc file
150
227
  */
@@ -170,6 +247,11 @@ export type DocsTopicEntry = {
170
247
  * owner package
171
248
  */
172
249
  package: string;
250
+ /**
251
+ * the owner's ProviderId; the package name when
252
+ * absent. Links in the topic resolve against it.
253
+ */
254
+ providerId?: string | undefined;
173
255
  /**
174
256
  * absolute path to the doc file
175
257
  */
@@ -182,12 +264,27 @@ export type DocsTopicEntry = {
182
264
  */
183
265
  replaces?: string | undefined;
184
266
  /**
185
- * overlays to
186
- * merge onto the base doc, in the order their integrations were configured
267
+ * overlays to merge onto the base doc, in the order their integrations were
268
+ * configured; each section an extension adds resolves its links against the
269
+ * extension's provider id (its package name when absent)
187
270
  */
188
271
  extensions: Array<{
189
272
  package: string;
190
273
  path: string;
274
+ providerId?: string;
191
275
  }>;
276
+ /**
277
+ * the route of the namespace a tree guide sits in
278
+ */
279
+ parent?: string | undefined;
280
+ /**
281
+ * a tree guide's route
282
+ */
283
+ route?: string | undefined;
284
+ /**
285
+ * a guide that only the docs tree reads, by its
286
+ * route; never a flat topic
287
+ */
288
+ tree?: boolean | undefined;
192
289
  };
193
290
  import { withSourceTitle } from './docs-section-key.mjs';
@@ -71,6 +71,8 @@ const TOPIC_NAME_RE = /^[\w-]+$/;
71
71
  * @typedef {object} DocsTopicRecord A doc file discovered under a docs root.
72
72
  * @property {string} name
73
73
  * @property {string} package owner package
74
+ * @property {string} [providerId] the owner's ProviderId, when it differs from
75
+ * the package name
74
76
  * @property {string} path absolute path to the doc file
75
77
  * @property {string} [title]
76
78
  * @property {string} [description]
@@ -83,13 +85,21 @@ const TOPIC_NAME_RE = /^[\w-]+$/;
83
85
  * @typedef {object} DocsTopicEntry A resolved topic in the catalog.
84
86
  * @property {string} name
85
87
  * @property {string} package owner package
88
+ * @property {string} [providerId] the owner's ProviderId; the package name when
89
+ * absent. Links in the topic resolve against it.
86
90
  * @property {string} path absolute path to the doc file
87
91
  * @property {string} [title]
88
92
  * @property {string} [description]
89
93
  * @property {string|null} [category]
90
94
  * @property {string} [replaces] the topic this one took the place of
91
- * @property {Array<{package: string, path: string}>} extensions overlays to
92
- * merge onto the base doc, in the order their integrations were configured
95
+ * @property {Array<{package: string, path: string, providerId?: string}>} extensions
96
+ * overlays to merge onto the base doc, in the order their integrations were
97
+ * configured; each section an extension adds resolves its links against the
98
+ * extension's provider id (its package name when absent)
99
+ * @property {string} [parent] the route of the namespace a tree guide sits in
100
+ * @property {string} [route] a tree guide's route
101
+ * @property {boolean} [tree] a guide that only the docs tree reads, by its
102
+ * route; never a flat topic
93
103
  */
94
104
 
95
105
  /**
@@ -144,7 +154,10 @@ export const GRAPH_BLOCK_TYPES = new Set([
144
154
  'reference',
145
155
  ]);
146
156
 
147
- /** Doc fields only the docs graph reads; a topic that sets one fails to load. */
157
+ /**
158
+ * Doc fields only the docs tree reads. A flat topic that sets one fails to
159
+ * load; a guide the tree places may set `placement` (spec:AST-046).
160
+ */
148
161
  export const GRAPH_ONLY_FIELDS = ['placement', 'aliases', 'audience'];
149
162
 
150
163
  /**
@@ -180,14 +193,16 @@ const SECTION_FIELDS = ['id', 'title', 'category', 'content', 'previewType'];
180
193
  * where the file that needs fixing can be named.
181
194
  *
182
195
  * @param {any} doc a parsed doc
196
+ * @param {{placement?: boolean}} [options] `placement`: the doc is a guide the
197
+ * docs tree places, so its `placement` field is read, not rejected
183
198
  * @returns {string[]} problems, each already pointed at a place in the doc
184
199
  */
185
- export function problemsInTopic(doc) {
186
- // A namespace doc is valid authoring that only the docs graph reads. Said
200
+ export function problemsInTopic(doc, {placement = false} = {}) {
201
+ // A namespace doc is valid authoring that only the docs tree reads. Said
187
202
  // plainly, instead of as the topic fields it does not have.
188
203
  if (doc?.type === 'namespace') {
189
204
  return [
190
- `"${doc.name}" is a namespace doc. Only the docs graph reads namespace docs, and it is not built yet; remove this file from the docs directory.`,
205
+ `"${doc.name}" is a namespace doc, which the docs tree reads, not the topic list. The CLI keeps its own in assets/docs/tree; an integration ships its namespace docs in its docs directory.`,
191
206
  ];
192
207
  }
193
208
  /** @type {string[]} */
@@ -203,6 +218,8 @@ export function problemsInTopic(doc) {
203
218
  );
204
219
  }
205
220
  for (const field of GRAPH_ONLY_FIELDS) {
221
+ // A guide the docs tree places carries `placement`; the tree reads it.
222
+ if (field === 'placement' && placement) continue;
206
223
  if (doc?.[field] != null) {
207
224
  problems.push(
208
225
  `${field}: requires the compiled graph reader and is not supported by legacy topic readers`,
@@ -319,6 +336,35 @@ export function problemsInTopic(doc) {
319
336
  return problems;
320
337
  }
321
338
 
339
+ /**
340
+ * The fields the docs tree reads from a namespace doc an integration ships.
341
+ * @param {any} doc
342
+ * @returns {string[]}
343
+ */
344
+ export function problemsInNamespace(doc) {
345
+ /** @type {string[]} */
346
+ const problems = [];
347
+ for (const field of ['name', 'title', 'summary']) {
348
+ if (typeof doc?.[field] !== 'string' || doc[field] === '') {
349
+ problems.push(`${field}: expected a non-empty string`);
350
+ }
351
+ }
352
+ const slots = doc?.slots;
353
+ if (slots == null || typeof slots !== 'object' || Object.keys(slots).length === 0) {
354
+ problems.push('slots: expected at least one slot');
355
+ return problems;
356
+ }
357
+ for (const [name, slot] of Object.entries(slots)) {
358
+ if (typeof slot?.title !== 'string' || slot.title === '') {
359
+ problems.push(`slots.${name}.title: expected a non-empty string`);
360
+ }
361
+ if (!Array.isArray(slot?.accepts?.kinds) || slot.accepts.kinds.length === 0) {
362
+ problems.push(`slots.${name}.accepts.kinds: expected at least one kind`);
363
+ }
364
+ }
365
+ return problems;
366
+ }
367
+
322
368
  /**
323
369
  * Discover the topics contributed by a single loaded integration. Mirrors
324
370
  * `discoverIntegrationComponents`: walk the resolved root, take every
@@ -326,11 +372,15 @@ export function problemsInTopic(doc) {
326
372
  * discovery this loads each doc, because a topic's name and its relationship
327
373
  * to an existing topic are fields inside the file.
328
374
  *
375
+ * A namespace doc and a guide with `placement` go to the docs tree instead of
376
+ * the topic list (spec:AST-046): they come back in `namespaces` and `guides`,
377
+ * named by the integration's provider id.
378
+ *
329
379
  * Errors are returned, not thrown: one unusable doc is reported as an issue
330
380
  * against its package while the rest of the CLI keeps working.
331
381
  *
332
- * @param {{name: string, docs?: string}} integration a loaded integration
333
- * @returns {Promise<{records: DocsTopicRecord[], errors: Error[]}>}
382
+ * @param {{name: string, docs?: string, providerId?: string}} integration a loaded integration
383
+ * @returns {Promise<{records: DocsTopicRecord[], errors: Error[], namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>}
334
384
  */
335
385
  export async function discoverIntegrationDocs(integration) {
336
386
  const docsDir = integration?.docs;
@@ -338,7 +388,14 @@ export async function discoverIntegrationDocs(integration) {
338
388
  const records = [];
339
389
  /** @type {Error[]} */
340
390
  const errors = [];
341
- if (!docsDir || !fs.existsSync(docsDir)) return {records, errors};
391
+ /** @type {import('../doc-compiler/tree.mjs').TreeNamespaceInput[]} */
392
+ const namespaces = [];
393
+ /** @type {import('../doc-compiler/tree.mjs').TreeDocInput[]} */
394
+ const guides = [];
395
+ if (!docsDir || !fs.existsSync(docsDir)) {
396
+ return {records, errors, namespaces, guides};
397
+ }
398
+ const providerId = integration.providerId ?? integration.name;
342
399
 
343
400
  /** @type {string[]} */
344
401
  const files = [];
@@ -373,11 +430,34 @@ export async function discoverIntegrationDocs(integration) {
373
430
  );
374
431
  continue;
375
432
  }
376
- const problems = problemsInTopic(doc);
433
+ const relative = path.relative(docsDir, file);
434
+ const source = `${integration.name}/${relative.split(path.sep).join('/')}`;
435
+ if (/** @type {any} */ (doc)?.type === 'namespace') {
436
+ const problems = problemsInNamespace(doc);
437
+ if (problems.length > 0) {
438
+ errors.push(
439
+ new Error(
440
+ `${relative} is not a usable namespace doc:\n${problems
441
+ .map(problem => ` ${problem}`)
442
+ .join('\n')}`,
443
+ ),
444
+ );
445
+ continue;
446
+ }
447
+ namespaces.push({
448
+ provider: integration.name,
449
+ providerId,
450
+ source,
451
+ doc: /** @type {any} */ (doc),
452
+ });
453
+ continue;
454
+ }
455
+ const placed = /** @type {any} */ (doc)?.placement != null;
456
+ const problems = problemsInTopic(doc, {placement: placed});
377
457
  if (problems.length > 0) {
378
458
  errors.push(
379
459
  new Error(
380
- `${path.relative(docsDir, file)} is not a usable topic:\n${problems
460
+ `${relative} is not a usable topic:\n${problems
381
461
  .map(problem => ` ${problem}`)
382
462
  .join('\n')}`,
383
463
  ),
@@ -398,6 +478,29 @@ export async function discoverIntegrationDocs(integration) {
398
478
  continue;
399
479
  }
400
480
  seen.set(topicKey, path.relative(docsDir, file));
481
+ if (placed) {
482
+ if (parsed.replaces != null || parsed.extends != null) {
483
+ errors.push(
484
+ new Error(
485
+ `${relative} is placed in the docs tree and also declares \`${parsed.replaces != null ? 'replaces' : 'extends'}\`. A placed guide has its own route; only a flat topic takes over or extends another.`,
486
+ ),
487
+ );
488
+ continue;
489
+ }
490
+ guides.push({
491
+ provider: integration.name,
492
+ providerId,
493
+ source,
494
+ kind: 'generic',
495
+ name: parsed.name,
496
+ title: parsed.title,
497
+ summary: parsed.description,
498
+ group: null,
499
+ placement: parsed.placement,
500
+ ref: {topicFile: file},
501
+ });
502
+ continue;
503
+ }
401
504
  if (parsed.replaces != null && parsed.extends != null) {
402
505
  errors.push(
403
506
  new Error(
@@ -415,10 +518,11 @@ export async function discoverIntegrationDocs(integration) {
415
518
  category: parsed.category ?? null,
416
519
  replaces: parsed.replaces,
417
520
  extendsTopic: parsed.extends,
521
+ ...(providerId === integration.name ? {} : {providerId}),
418
522
  });
419
523
  }
420
524
 
421
- return {records, errors};
525
+ return {records, errors, namespaces, guides};
422
526
  }
423
527
 
424
528
  /**
@@ -504,6 +608,46 @@ export class DocsCatalog {
504
608
  #topics = new Map();
505
609
  /** @type {Map<string, string>} old topic name → the name that replaced it */
506
610
  #aliases = new Map();
611
+ /** @type {Array<{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>} */
612
+ #treeInputs = [];
613
+ /** @type {Array<{package: string, message: string}>} */
614
+ #issues = [];
615
+
616
+ /**
617
+ * Record a doc file a package ships that did not load. Its package's docs
618
+ * are withdrawn; readers name the package so an author knows where to look.
619
+ * @param {{package: string, message: string}} issue
620
+ */
621
+ addIssue(issue) {
622
+ this.#issues.push(issue);
623
+ }
624
+
625
+ /**
626
+ * The doc files that did not load, by package.
627
+ * @returns {ReadonlyArray<{package: string, message: string}>}
628
+ */
629
+ get issues() {
630
+ return this.#issues;
631
+ }
632
+
633
+ /**
634
+ * Add the namespace docs and placed guides one integration ships to the
635
+ * docs tree (spec:AST-046).
636
+ * @param {{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}} inputs
637
+ */
638
+ addTreeInputs(inputs) {
639
+ if (inputs.namespaces.length > 0 || inputs.guides.length > 0) {
640
+ this.#treeInputs.push(inputs);
641
+ }
642
+ }
643
+
644
+ /**
645
+ * What the integrations add to the docs tree, in configured order.
646
+ * @returns {ReadonlyArray<{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>}
647
+ */
648
+ get treeInputs() {
649
+ return this.#treeInputs;
650
+ }
507
651
 
508
652
  /**
509
653
  * Seed a catalog with the CLI's own topics.
@@ -541,7 +685,11 @@ export class DocsCatalog {
541
685
  message: `"${record.name}" extends "${record.extendsTopic}", which is not a topic in this project.`,
542
686
  };
543
687
  }
544
- target.extensions.push({package: record.package, path: record.path});
688
+ target.extensions.push({
689
+ package: record.package,
690
+ path: record.path,
691
+ ...(record.providerId ? {providerId: record.providerId} : {}),
692
+ });
545
693
  return null;
546
694
  }
547
695
 
@@ -579,6 +727,7 @@ export class DocsCatalog {
579
727
  description: record.description,
580
728
  category: record.category,
581
729
  replaces: replaced,
730
+ ...(record.providerId ? {providerId: record.providerId} : {}),
582
731
  // Extensions were authored against the content that just went away.
583
732
  extensions: [],
584
733
  });
@@ -608,11 +757,26 @@ export class DocsCatalog {
608
757
  title: record.title,
609
758
  description: record.description,
610
759
  category: record.category,
760
+ ...(record.providerId ? {providerId: record.providerId} : {}),
611
761
  extensions: [],
612
762
  });
613
763
  return null;
614
764
  }
615
765
 
766
+ /**
767
+ * Every other name a topic answers to, lowercased: the names of the topics
768
+ * it replaced, directly or through a chain of replacements. `resolve` finds
769
+ * the topic by each of them.
770
+ * @param {DocsTopicEntry} entry
771
+ * @returns {string[]}
772
+ */
773
+ aliasesOf(entry) {
774
+ const key = entry.name.toLowerCase();
775
+ return [...this.#aliases]
776
+ .filter(([, to]) => to === key)
777
+ .map(([from]) => from);
778
+ }
779
+
616
780
  /**
617
781
  * Look a topic up by name, case-insensitively, following the alias a renamed
618
782
  * replacement left behind.
@@ -74,16 +74,16 @@ describe('discoverBuiltinTopics', () => {
74
74
 
75
75
  describe('discoverIntegrationDocs', () => {
76
76
  it('contributes nothing when no docs root is declared or the root is gone', async () => {
77
- expect(await discoverIntegrationDocs({name: '@acme/widgets'})).toEqual({
78
- records: [],
79
- errors: [],
80
- });
77
+ const nothing = {records: [], errors: [], namespaces: [], guides: []};
78
+ expect(await discoverIntegrationDocs({name: '@acme/widgets'})).toEqual(
79
+ nothing,
80
+ );
81
81
  expect(
82
82
  await discoverIntegrationDocs({
83
83
  name: '@acme/widgets',
84
84
  docs: path.join(tmpDir, 'nope'),
85
85
  }),
86
- ).toEqual({records: [], errors: []});
86
+ ).toEqual(nothing);
87
87
  });
88
88
 
89
89
  it('reads every topic under the root, with what it declares', async () => {
@@ -169,10 +169,7 @@ describe('discoverIntegrationDocs', () => {
169
169
  id: 'steps',
170
170
  title: 'Steps',
171
171
  content: [
172
- {
173
- type: 'workflow',
174
- steps: [{title: 'Install', description: 'Run install.'}],
175
- },
172
+ {type: 'collection', source: {slot: 'guides'}},
176
173
  ],
177
174
  },
178
175
  ],
@@ -183,9 +180,9 @@ describe('discoverIntegrationDocs', () => {
183
180
  expect(errors[0].message).toContain('Invalid discriminator value');
184
181
  });
185
182
 
186
- it('names a namespace doc instead of listing topic fields it lacks', async () => {
187
- const {records, errors} = await discoverIntegrationDocs(
188
- integration('@acme/namespace', {
183
+ it('hands namespace docs and placed guides to the docs tree, by provider id', async () => {
184
+ const found = await discoverIntegrationDocs({
185
+ ...integration('@acme/namespace', {
189
186
  'guides.doc.mjs': {
190
187
  type: 'namespace',
191
188
  name: 'guides',
@@ -193,14 +190,56 @@ describe('discoverIntegrationDocs', () => {
193
190
  summary: 'Every guide.',
194
191
  slots: {guides: {title: 'Guides', accepts: {kinds: ['generic']}}},
195
192
  },
193
+ 'setup.doc.mjs': topic({
194
+ name: 'setup',
195
+ title: 'Set up',
196
+ placement: {parent: 'namespace:guides', slot: 'guides', order: 1},
197
+ }),
198
+ 'deploying.doc.mjs': topic(),
199
+ }),
200
+ providerId: '@acme/tree-provider',
201
+ });
202
+ expect(found.errors).toEqual([]);
203
+ expect(found.records.map(record => record.name)).toEqual(['deploying']);
204
+ expect(found.records[0].providerId).toBe('@acme/tree-provider');
205
+ expect(found.namespaces).toMatchObject([
206
+ {
207
+ provider: '@acme/namespace',
208
+ providerId: '@acme/tree-provider',
209
+ source: '@acme/namespace/guides.doc.mjs',
210
+ doc: {name: 'guides'},
211
+ },
212
+ ]);
213
+ expect(found.guides).toMatchObject([
214
+ {
215
+ provider: '@acme/namespace',
216
+ providerId: '@acme/tree-provider',
217
+ kind: 'generic',
218
+ name: 'setup',
219
+ placement: {parent: 'namespace:guides', slot: 'guides', order: 1},
220
+ },
221
+ ]);
222
+ });
223
+
224
+ it('names what a namespace doc lacks, and refuses a placed guide that replaces a topic', async () => {
225
+ const {errors, namespaces, guides} = await discoverIntegrationDocs(
226
+ integration('@acme/namespace', {
227
+ 'guides.doc.mjs': {type: 'namespace', name: 'guides', title: 'Guides'},
228
+ 'setup.doc.mjs': topic({
229
+ name: 'setup',
230
+ replaces: 'getting-started',
231
+ placement: {parent: 'namespace:guides', slot: 'guides'},
232
+ }),
196
233
  }),
197
234
  );
198
- expect(records).toEqual([]);
199
- expect(errors).toHaveLength(1);
200
- expect(errors[0].message).toContain(
201
- '"guides" is a namespace doc. Only the docs graph reads namespace docs',
235
+ expect(namespaces).toEqual([]);
236
+ expect(guides).toEqual([]);
237
+ expect(errors.map(error => error.message).join('\n')).toMatch(
238
+ /guides\.doc\.mjs.*slots/,
239
+ );
240
+ expect(errors.map(error => error.message).join('\n')).toContain(
241
+ 'is placed in the docs tree and also declares `replaces`',
202
242
  );
203
- expect(errors[0].message).not.toContain('sections:');
204
243
  });
205
244
  });
206
245
 
@@ -9,10 +9,10 @@
9
9
  */
10
10
  export function docPayloadBytes(payload: unknown): number;
11
11
  /**
12
- * @param {import('../../api/docs/docs.type.mjs').DocsIndex} index
12
+ * @param {Omit<import('../../api/docs/docs.type.mjs').DocsIndex, 'links'> | import('../../api/docs/docs.type.mjs').DocsIndex} index
13
13
  * @returns {number}
14
14
  */
15
- export function docsIndexBytes(index: import("../../api/docs/docs.type.mjs").DocsIndex): number;
15
+ export function docsIndexBytes(index: Omit<import("../../api/docs/docs.type.mjs").DocsIndex, "links"> | import("../../api/docs/docs.type.mjs").DocsIndex): number;
16
16
  /**
17
17
  * The sections a single read would return more than `budget` bytes for.
18
18
  * @param {any[]} sections
@@ -26,7 +26,7 @@ export function docPayloadBytes(payload) {
26
26
  }
27
27
 
28
28
  /**
29
- * @param {import('../../api/docs/docs.type.mjs').DocsIndex} index
29
+ * @param {Omit<import('../../api/docs/docs.type.mjs').DocsIndex, 'links'> | import('../../api/docs/docs.type.mjs').DocsIndex} index
30
30
  * @returns {number}
31
31
  */
32
32
  export function docsIndexBytes(index) {
@@ -30,6 +30,13 @@ export function sectionTitleKey(title: unknown): string;
30
30
  * @returns {string}
31
31
  */
32
32
  export function sectionKey(section: any): string;
33
+ /**
34
+ * A name as a docs-tree route segment: lowercase words joined by hyphens, so
35
+ * `integrationPackCheck` and `integration pack` both read naturally.
36
+ * @param {string} name
37
+ * @returns {string}
38
+ */
39
+ export function routeSegment(name: string): string;
33
40
  /**
34
41
  * Fatal key problems: only an explicitly authored `id` can make a previously
35
42
  * readable topic invalid. Derived-key collisions and titles with no Latin
@@ -84,14 +91,14 @@ export function sectionSummary(section: any, max?: number): string;
84
91
  * The index a topic-only read returns: what the topic is, and one entry per
85
92
  * section with the key to read it by.
86
93
  * @param {{name: string, title: string, description: string, sections: any[]}} doc
87
- * @returns {import('../../api/docs/docs.type.mjs').DocsIndex}
94
+ * @returns {Omit<import('../../api/docs/docs.type.mjs').DocsIndex, 'links'>}
88
95
  */
89
96
  export function buildDocsIndexData(doc: {
90
97
  name: string;
91
98
  title: string;
92
99
  description: string;
93
100
  sections: any[];
94
- }): import("../../api/docs/docs.type.mjs").DocsIndex;
101
+ }): Omit<import("../../api/docs/docs.type.mjs").DocsIndex, "links">;
95
102
  /**
96
103
  * @file Stable section keys, section lookup, and the topic index.
97
104
  *