@astryxdesign/cli 0.6.3-canary.7ada42e → 0.6.3-canary.7ec7be0

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 (221) hide show
  1. package/README.md +21 -19
  2. package/api/build/_adapter.d.mts +50 -0
  3. package/api/build/_adapter.mjs +60 -0
  4. package/api/build/build.doc.mjs +13 -7
  5. package/api/build/build.test.mjs +184 -6
  6. package/api/build/build.type.d.mts +57 -2
  7. package/api/build/build.type.mjs +30 -7
  8. package/api/build/help/help.d.mts +4 -0
  9. package/api/build/help/help.mjs +24 -11
  10. package/api/build/kit/kit.d.mts +4 -1
  11. package/api/build/kit/kit.mjs +165 -49
  12. package/api/build/kit/rank.d.mts +44 -0
  13. package/api/build/kit/rank.mjs +432 -0
  14. package/api/build/kit/rank.test.mjs +196 -0
  15. package/api/component/_adapter.d.mts +6 -12
  16. package/api/component/_adapter.mjs +20 -10
  17. package/api/component/component.mjs +60 -12
  18. package/api/component/list/list.mjs +3 -2
  19. package/api/docs/_adapter.d.mts +251 -28
  20. package/api/docs/_adapter.mjs +918 -35
  21. package/api/docs/detail/detail.mjs +11 -3
  22. package/api/docs/detail/section/section.mjs +24 -13
  23. package/api/docs/detail/section/section.test.mjs +15 -6
  24. package/api/docs/docs.d.mts +5 -3
  25. package/api/docs/docs.doc.mjs +38 -17
  26. package/api/docs/docs.mjs +44 -8
  27. package/api/docs/docs.test.mjs +158 -4
  28. package/api/docs/docs.type.d.mts +181 -2
  29. package/api/docs/docs.type.mjs +117 -3
  30. package/api/docs/index/index.mjs +11 -3
  31. package/api/docs/index/index.test.mjs +1 -1
  32. package/api/docs/integration-tree.test.mjs +555 -0
  33. package/api/docs/integrationDocs.test.mjs +14 -14
  34. package/api/docs/list/list.mjs +25 -5
  35. package/api/docs/node/node.d.mts +43 -0
  36. package/api/docs/node/node.mjs +192 -0
  37. package/api/docs/reference-blocks.test.mjs +406 -0
  38. package/api/doctor/doctor.d.mts +30 -2
  39. package/api/doctor/doctor.mjs +151 -8
  40. package/api/doctor/doctor.test.mjs +95 -7
  41. package/api/index.d.mts +1 -1
  42. package/api/index.mjs +1 -0
  43. package/api/init/init.doc.mjs +1 -1
  44. package/api/integration/add-contribution.d.mts +2 -1
  45. package/api/integration/add-contribution.mjs +107 -5
  46. package/api/integration/add-contribution.test.mjs +137 -0
  47. package/api/integration/authoring-checks.mjs +138 -28
  48. package/api/integration/authoring-checks.test.mjs +171 -3
  49. package/api/integration/authoring-checks.type.mjs +6 -1
  50. package/api/integration/integration-authoring.type.d.mts +2 -0
  51. package/api/integration/integration-authoring.type.mjs +2 -0
  52. package/api/integration/integrationAdd.doc.mjs +6 -0
  53. package/api/integration/integrationAddDoc.doc.mjs +7 -1
  54. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  55. package/api/integration/integrationPackCheck.doc.mjs +1 -1
  56. package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
  57. package/api/integration/integrationTemplateConflicts.doc.mjs +3 -0
  58. package/api/integration/pack-check.mjs +34 -0
  59. package/api/integration/pack-check.test.mjs +121 -0
  60. package/api/integration/pack-check.type.d.mts +26 -2
  61. package/api/integration/pack-check.type.mjs +14 -1
  62. package/api/integration/template-conflict-compatibility.test.mjs +73 -0
  63. package/api/integration/validate-integration.test.mjs +3 -3
  64. package/api/integration/validateIntegration.doc.mjs +1 -1
  65. package/api/json/index.ts +2 -0
  66. package/api/layout/_adapter.mjs +20 -5
  67. package/api/search/search.d.mts +59 -1
  68. package/api/search/search.doc.mjs +4 -3
  69. package/api/search/search.mjs +442 -71
  70. package/api/search/search.test.mjs +91 -2
  71. package/api/search/search.type.d.mts +13 -1
  72. package/api/search/search.type.mjs +4 -1
  73. package/api/template/list/list.mjs +1 -0
  74. package/api/template/table-floating-bulk-actions.test.mjs +66 -0
  75. package/api/template/template-integration.test.mjs +1072 -3
  76. package/api/template/template.doc.mjs +27 -7
  77. package/api/template/template.mjs +45 -8
  78. package/api/template/template.type.d.mts +6 -8
  79. package/api/template/template.type.mjs +3 -2
  80. package/api/theme/template/template.test.mjs +5 -0
  81. package/api/theme/themeTemplate.doc.mjs +1 -1
  82. package/assets/docs/getting-started.doc.mjs +2 -2
  83. package/assets/docs/layout.doc.dense.mjs +2 -2
  84. package/assets/docs/layout.doc.mjs +1 -1
  85. package/assets/docs/principles.doc.mjs +6 -6
  86. package/assets/docs/styling-libraries.doc.mjs +3 -3
  87. package/assets/docs/styling.doc.mjs +4 -4
  88. package/assets/docs/theme.doc.mjs +4 -4
  89. package/assets/docs/tokens.doc.mjs +1 -1
  90. package/assets/docs/tree/api.doc.mjs +30 -0
  91. package/assets/docs/tree/cli.doc.mjs +23 -0
  92. package/assets/docs/tree/commands.doc.mjs +25 -0
  93. package/assets/docs/{cli-integrations.doc.mjs → tree/integrations.doc.mjs} +37 -9
  94. package/assets/docs/tree/integrations.test.mjs +62 -0
  95. package/assets/docs/tree/writing-docs.doc.mjs +286 -0
  96. package/assets/docs/working-with-ai.doc.mjs +3 -3
  97. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
  98. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
  99. package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
  100. package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
  101. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
  102. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
  103. package/authoring/debug/parse.d.mts +3 -3
  104. package/authoring/doctypes/_schema.d.mts +119 -117
  105. package/authoring/doctypes/_schema.mjs +54 -3
  106. package/authoring/doctypes/base/graph-fields.doc.mjs +7 -5
  107. package/authoring/doctypes/base/type.ts +6 -5
  108. package/authoring/doctypes/command/command.doc.mjs +1 -1
  109. package/authoring/doctypes/command/type.ts +2 -2
  110. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  111. package/authoring/doctypes/enum/type.ts +1 -1
  112. package/authoring/doctypes/function/function.doc.mjs +3 -2
  113. package/authoring/doctypes/function/type.ts +3 -2
  114. package/authoring/doctypes/load-contract.test.mjs +26 -1
  115. package/authoring/doctypes/namespace/namespace.doc.mjs +6 -10
  116. package/authoring/doctypes/namespace/parse.test.mjs +23 -25
  117. package/authoring/doctypes/namespace/type.ts +5 -2
  118. package/authoring/doctypes/parse.mjs +3 -2
  119. package/authoring/doctypes/reference/reference.doc.mjs +34 -5
  120. package/authoring/doctypes/reference/type.ts +28 -11
  121. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  122. package/authoring/doctypes/schema/type.ts +1 -1
  123. package/authoring/doctypes/template/parse.d.mts +2 -0
  124. package/authoring/doctypes/template/parse.mjs +4 -0
  125. package/authoring/doctypes/template/parse.test.mjs +18 -0
  126. package/authoring/doctypes/template/template.doc.mjs +6 -0
  127. package/authoring/doctypes/template/type.ts +8 -0
  128. package/authoring/identity/identity.doc.mjs +2 -2
  129. package/authoring/index.d.ts +1 -0
  130. package/authoring/integration/type.ts +1 -1
  131. package/clients/cli/commands/build-theme.adaptations.test.mjs +100 -1
  132. package/clients/cli/commands/build-theme.mjs +1 -1
  133. package/clients/cli/commands/build.doc.mjs +11 -6
  134. package/clients/cli/commands/build.mjs +105 -67
  135. package/clients/cli/commands/build.text-fields.test.mjs +41 -0
  136. package/clients/cli/commands/component/index.mjs +1 -1
  137. package/clients/cli/commands/component-ownership.test.mjs +3 -3
  138. package/clients/cli/commands/discover.broken-integration.test.mjs +7 -8
  139. package/clients/cli/commands/discover.mjs +1 -1
  140. package/clients/cli/commands/docs.doc.mjs +20 -8
  141. package/clients/cli/commands/docs.mjs +183 -69
  142. package/clients/cli/commands/docs.test.mjs +120 -16
  143. package/clients/cli/commands/doctor-integration-docs.doc.mjs +2 -2
  144. package/clients/cli/commands/doctor-integration-templates.doc.mjs +14 -7
  145. package/clients/cli/commands/doctor-integration.test.mjs +75 -1
  146. package/clients/cli/commands/doctor.mjs +53 -16
  147. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  148. package/clients/cli/commands/integration.mjs +1 -0
  149. package/clients/cli/commands/search.mjs +11 -2
  150. package/clients/cli/commands/setup-nudge.test.mjs +6 -0
  151. package/clients/cli/commands/template.doc.mjs +23 -6
  152. package/clients/cli/commands/template.mjs +4 -91
  153. package/clients/cli/index.mjs +8 -0
  154. package/clients/cli/lib/manifest.mjs +9 -2
  155. package/foundation/agent-docs/agent-docs.d.mts +3 -2
  156. package/foundation/agent-docs/agent-docs.mjs +13 -9
  157. package/foundation/agent-docs/agent-docs.test.mjs +19 -1
  158. package/foundation/config/project.d.mts +12 -11
  159. package/foundation/config/project.mjs +73 -59
  160. package/foundation/config/project.test.mjs +141 -5
  161. package/foundation/discovery/authoring-self-docs.d.mts +12 -0
  162. package/foundation/discovery/authoring-self-docs.mjs +20 -8
  163. package/foundation/discovery/authoring-self-docs.test.mjs +25 -9
  164. package/foundation/discovery/cli-self-docs.d.mts +40 -34
  165. package/foundation/discovery/cli-self-docs.mjs +91 -115
  166. package/foundation/discovery/cli-self-docs.test.mjs +104 -166
  167. package/foundation/discovery/component-discovery.d.mts +38 -0
  168. package/foundation/discovery/component-discovery.mjs +48 -0
  169. package/foundation/discovery/docs-discovery.d.mts +109 -9
  170. package/foundation/discovery/docs-discovery.mjs +223 -24
  171. package/foundation/discovery/docs-discovery.test.mjs +103 -27
  172. package/foundation/discovery/docs-output-budget.d.mts +2 -2
  173. package/foundation/discovery/docs-output-budget.mjs +1 -1
  174. package/foundation/discovery/docs-section-key.d.mts +28 -10
  175. package/foundation/discovery/docs-section-key.mjs +134 -33
  176. package/foundation/discovery/docs-section-key.test.mjs +41 -19
  177. package/foundation/discovery/template-adapter.d.mts +92 -6
  178. package/foundation/discovery/template-adapter.mjs +453 -17
  179. package/foundation/discovery/template-adapter.test.mjs +42 -0
  180. package/foundation/discovery/template-conflict-release.d.mts +13 -0
  181. package/foundation/discovery/template-conflict-release.mjs +40 -0
  182. package/foundation/discovery/template-conflict-release.test.mjs +40 -0
  183. package/foundation/doc-compiler/bundle.mjs +61 -1
  184. package/foundation/doc-compiler/bundle.test.mjs +21 -10
  185. package/foundation/doc-compiler/compile.d.mts +113 -132
  186. package/foundation/doc-compiler/compile.mjs +57 -10
  187. package/foundation/doc-compiler/diagnostics.mjs +28 -0
  188. package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
  189. package/foundation/doc-compiler/inputs.d.mts +2 -2
  190. package/foundation/doc-compiler/inputs.mjs +6 -1
  191. package/foundation/doc-compiler/ir.mjs +7 -0
  192. package/foundation/doc-compiler/lenses.d.mts +8 -5
  193. package/foundation/doc-compiler/lenses.mjs +50 -4
  194. package/foundation/doc-compiler/links.d.mts +162 -0
  195. package/foundation/doc-compiler/links.mjs +294 -0
  196. package/foundation/doc-compiler/links.test.mjs +192 -0
  197. package/foundation/doc-compiler/lower-doc.test.mjs +5 -2
  198. package/foundation/doc-compiler/read.d.mts +3 -2
  199. package/foundation/doc-compiler/read.mjs +6 -1
  200. package/foundation/doc-compiler/tree.d.mts +288 -0
  201. package/foundation/doc-compiler/tree.mjs +876 -0
  202. package/foundation/doc-compiler/tree.test.mjs +598 -0
  203. package/foundation/integrations/autolink.test.mjs +1 -1
  204. package/foundation/integrations/cli-requirement.d.mts +45 -0
  205. package/foundation/integrations/cli-requirement.mjs +154 -0
  206. package/foundation/integrations/cli-requirement.test.mjs +84 -0
  207. package/foundation/integrations/contribution-inventory.d.mts +2 -1
  208. package/foundation/integrations/contribution-inventory.mjs +10 -4
  209. package/foundation/integrations/contribution-inventory.test.mjs +19 -0
  210. package/foundation/integrations/integration-warnings.d.mts +9 -2
  211. package/foundation/integrations/integration-warnings.mjs +51 -26
  212. package/foundation/integrations/integration-warnings.test.mjs +74 -1
  213. package/foundation/integrations/validate-contributions.mjs +25 -27
  214. package/foundation/response/response-types.doc.d.mts +5 -1
  215. package/foundation/response/response-types.doc.mjs +19 -10
  216. package/foundation/text/string-utils.d.mts +8 -0
  217. package/foundation/text/string-utils.mjs +18 -0
  218. package/foundation/xle/expand.mjs +1 -1
  219. package/foundation/xle/xle.test.mjs +13 -0
  220. package/package.json +9 -9
  221. 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
@@ -95,9 +122,15 @@ export { withSourceTitle };
95
122
  * unlike component discovery, whose built-ins belong to core.
96
123
  */
97
124
  export const BUILTIN_DOCS_PACKAGE: import("../../authoring/index.js").ProviderId;
98
- /** Blocks that are valid authoring but require the compiled graph renderer. */
125
+ /**
126
+ * Blocks that are valid authoring but require the compiled graph renderer: a
127
+ * namespace doc's `blocks` hold them, a topic section does not.
128
+ */
99
129
  export const GRAPH_BLOCK_TYPES: Set<string>;
100
- /** Doc fields only the docs graph reads; a topic that sets one fails to load. */
130
+ /**
131
+ * Doc fields only the docs tree reads. A flat topic that sets one fails to
132
+ * load; a guide the tree places may set `placement` (spec:AST-046).
133
+ */
101
134
  export const GRAPH_ONLY_FIELDS: string[];
102
135
  /**
103
136
  * Every topic a project can read, and the relationships between them.
@@ -114,6 +147,40 @@ export class DocsCatalog {
114
147
  * @returns {DocsCatalog}
115
148
  */
116
149
  static fromBuiltins(builtins?: Record<string, string>): DocsCatalog;
150
+ /**
151
+ * Record a doc file a package ships that did not load. Its package's docs
152
+ * are withdrawn; readers name the package so an author knows where to look.
153
+ * @param {{package: string, message: string}} issue
154
+ */
155
+ addIssue(issue: {
156
+ package: string;
157
+ message: string;
158
+ }): void;
159
+ /**
160
+ * The doc files that did not load, by package.
161
+ * @returns {ReadonlyArray<{package: string, message: string}>}
162
+ */
163
+ get issues(): ReadonlyArray<{
164
+ package: string;
165
+ message: string;
166
+ }>;
167
+ /**
168
+ * Add the namespace docs and placed guides one integration ships to the
169
+ * docs tree (spec:AST-046).
170
+ * @param {{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}} inputs
171
+ */
172
+ addTreeInputs(inputs: {
173
+ namespaces: import("../doc-compiler/tree.mjs").TreeNamespaceInput[];
174
+ guides: import("../doc-compiler/tree.mjs").TreeDocInput[];
175
+ }): void;
176
+ /**
177
+ * What the integrations add to the docs tree, in configured order.
178
+ * @returns {ReadonlyArray<{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>}
179
+ */
180
+ get treeInputs(): ReadonlyArray<{
181
+ namespaces: import("../doc-compiler/tree.mjs").TreeNamespaceInput[];
182
+ guides: import("../doc-compiler/tree.mjs").TreeDocInput[];
183
+ }>;
117
184
  /**
118
185
  * Add one integration-contributed doc, honoring what it declares. Returns
119
186
  * the issue it caused, or null when it applied cleanly — the caller owns
@@ -123,6 +190,14 @@ export class DocsCatalog {
123
190
  * @returns {import('../integrations/issue').AstryxIntegrationIssue | null}
124
191
  */
125
192
  add(record: DocsTopicRecord): import("../integrations/issue").AstryxIntegrationIssue | null;
193
+ /**
194
+ * Every other name a topic answers to, lowercased: the names of the topics
195
+ * it replaced, directly or through a chain of replacements. `resolve` finds
196
+ * the topic by each of them.
197
+ * @param {DocsTopicEntry} entry
198
+ * @returns {string[]}
199
+ */
200
+ aliasesOf(entry: DocsTopicEntry): string[];
126
201
  /**
127
202
  * Look a topic up by name, case-insensitively, following the alias a renamed
128
203
  * replacement left behind.
@@ -145,6 +220,11 @@ export type DocsTopicRecord = {
145
220
  * owner package
146
221
  */
147
222
  package: string;
223
+ /**
224
+ * the owner's ProviderId, when it differs from
225
+ * the package name
226
+ */
227
+ providerId?: string | undefined;
148
228
  /**
149
229
  * absolute path to the doc file
150
230
  */
@@ -170,6 +250,11 @@ export type DocsTopicEntry = {
170
250
  * owner package
171
251
  */
172
252
  package: string;
253
+ /**
254
+ * the owner's ProviderId; the package name when
255
+ * absent. Links in the topic resolve against it.
256
+ */
257
+ providerId?: string | undefined;
173
258
  /**
174
259
  * absolute path to the doc file
175
260
  */
@@ -182,12 +267,27 @@ export type DocsTopicEntry = {
182
267
  */
183
268
  replaces?: string | undefined;
184
269
  /**
185
- * overlays to
186
- * merge onto the base doc, in the order their integrations were configured
270
+ * overlays to merge onto the base doc, in the order their integrations were
271
+ * configured; each section an extension adds resolves its links against the
272
+ * extension's provider id (its package name when absent)
187
273
  */
188
274
  extensions: Array<{
189
275
  package: string;
190
276
  path: string;
277
+ providerId?: string;
191
278
  }>;
279
+ /**
280
+ * the route of the namespace a tree guide sits in
281
+ */
282
+ parent?: string | undefined;
283
+ /**
284
+ * a tree guide's route
285
+ */
286
+ route?: string | undefined;
287
+ /**
288
+ * a guide that only the docs tree reads, by its
289
+ * route; never a flat topic
290
+ */
291
+ tree?: boolean | undefined;
192
292
  };
193
293
  import { withSourceTitle } from './docs-section-key.mjs';
@@ -37,7 +37,7 @@ import {CLI_PROVIDER_ID} from '../identity/providers.mjs';
37
37
  import {parseReadableDoc} from '../doc-compiler/parse-readable.mjs';
38
38
  import {
39
39
  sectionKey,
40
- sectionKeyProblems,
40
+ sectionKeyErrors,
41
41
  sourceTitle,
42
42
  withSourceTitle,
43
43
  } 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
  /**
@@ -135,16 +145,20 @@ const BLOCK_FIELDS = {
135
145
  table: ['headers', 'rows'],
136
146
  list: ['style', 'items'],
137
147
  'token-ref': ['topic', 'section'],
148
+ // A read inlines it as the doc it names includes (spec:AST-047 FR9).
149
+ reference: ['target'],
138
150
  };
139
151
 
140
- /** Blocks that are valid authoring but require the compiled graph renderer. */
141
- export const GRAPH_BLOCK_TYPES = new Set([
142
- 'workflow',
143
- 'collection',
144
- 'reference',
145
- ]);
152
+ /**
153
+ * Blocks that are valid authoring but require the compiled graph renderer: a
154
+ * namespace doc's `blocks` hold them, a topic section does not.
155
+ */
156
+ export const GRAPH_BLOCK_TYPES = new Set(['workflow', 'collection']);
146
157
 
147
- /** Doc fields only the docs graph reads; a topic that sets one fails to load. */
158
+ /**
159
+ * Doc fields only the docs tree reads. A flat topic that sets one fails to
160
+ * load; a guide the tree places may set `placement` (spec:AST-046).
161
+ */
148
162
  export const GRAPH_ONLY_FIELDS = ['placement', 'aliases', 'audience'];
149
163
 
150
164
  /**
@@ -155,6 +169,7 @@ export const GRAPH_ONLY_FIELDS = ['placement', 'aliases', 'audience'];
155
169
  /** @type {Record<string, string[]>} */
156
170
  const OPTIONAL_BLOCK_FIELDS = {
157
171
  code: ['label'],
172
+ reference: ['projection', 'presentation'],
158
173
  };
159
174
 
160
175
  /**
@@ -166,8 +181,12 @@ const OPTIONAL_BLOCK_FIELDS = {
166
181
  const BLOCK_FIELD_VALUES = {
167
182
  heading: {level: [3, 4, 5, 6]},
168
183
  list: {style: ['ordered', 'unordered', 'do', 'dont']},
184
+ reference: {presentation: ['summary', 'compact', 'full']},
169
185
  };
170
186
 
187
+ /** The parts of a doc a reference block's `projection` may select. */
188
+ const PROJECTION_FIELDS = ['fields', 'sections'];
189
+
171
190
  /** Keys a section may carry. */
172
191
  const SECTION_FIELDS = ['id', 'title', 'category', 'content', 'previewType'];
173
192
 
@@ -180,14 +199,16 @@ const SECTION_FIELDS = ['id', 'title', 'category', 'content', 'previewType'];
180
199
  * where the file that needs fixing can be named.
181
200
  *
182
201
  * @param {any} doc a parsed doc
202
+ * @param {{placement?: boolean}} [options] `placement`: the doc is a guide the
203
+ * docs tree places, so its `placement` field is read, not rejected
183
204
  * @returns {string[]} problems, each already pointed at a place in the doc
184
205
  */
185
- export function problemsInTopic(doc) {
186
- // A namespace doc is valid authoring that only the docs graph reads. Said
206
+ export function problemsInTopic(doc, {placement = false} = {}) {
207
+ // A namespace doc is valid authoring that only the docs tree reads. Said
187
208
  // plainly, instead of as the topic fields it does not have.
188
209
  if (doc?.type === 'namespace') {
189
210
  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.`,
211
+ `"${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
212
  ];
192
213
  }
193
214
  /** @type {string[]} */
@@ -203,6 +224,8 @@ export function problemsInTopic(doc) {
203
224
  );
204
225
  }
205
226
  for (const field of GRAPH_ONLY_FIELDS) {
227
+ // A guide the docs tree places carries `placement`; the tree reads it.
228
+ if (field === 'placement' && placement) continue;
206
229
  if (doc?.[field] != null) {
207
230
  problems.push(
208
231
  `${field}: requires the compiled graph reader and is not supported by legacy topic readers`,
@@ -308,13 +331,71 @@ export function problemsInTopic(doc) {
308
331
  );
309
332
  }
310
333
  }
334
+ // A projection names the parts of the doc to include, so each part
335
+ // it names is a non-empty list of names.
336
+ if (block.type === 'reference' && block.projection != null) {
337
+ const projection = block.projection;
338
+ if (typeof projection !== 'object' || Array.isArray(projection)) {
339
+ problems.push(
340
+ `${blockAt}.projection: expected {fields?, sections?}, naming the parts of the doc to include`,
341
+ );
342
+ } else {
343
+ for (const [key, names] of Object.entries(projection)) {
344
+ if (!PROJECTION_FIELDS.includes(key)) {
345
+ problems.push(
346
+ `${blockAt}.projection.${key}: not a field of a projection`,
347
+ );
348
+ } else if (
349
+ !Array.isArray(names) ||
350
+ names.length === 0 ||
351
+ names.some(
352
+ name => typeof name !== 'string' || name.trim() === '',
353
+ )
354
+ ) {
355
+ problems.push(
356
+ `${blockAt}.projection.${key}: expected a non-empty array of names`,
357
+ );
358
+ }
359
+ }
360
+ }
361
+ }
311
362
  },
312
363
  );
313
364
  },
314
365
  );
315
- // Readers address a section by its key, so two sections sharing one would
316
- // make one of them unreachable.
317
- problems.push(...sectionKeyProblems(doc.sections));
366
+ // Explicit authored IDs are a new opt-in contract and remain strict. Topics
367
+ // that relied on 0.6.x title-only sections keep loading; the compiler assigns
368
+ // deterministic fallback/suffixed keys for the additive index API.
369
+ problems.push(...sectionKeyErrors(doc.sections));
370
+ return problems;
371
+ }
372
+
373
+ /**
374
+ * The fields the docs tree reads from a namespace doc an integration ships.
375
+ * @param {any} doc
376
+ * @returns {string[]}
377
+ */
378
+ export function problemsInNamespace(doc) {
379
+ /** @type {string[]} */
380
+ const problems = [];
381
+ for (const field of ['name', 'title', 'summary']) {
382
+ if (typeof doc?.[field] !== 'string' || doc[field] === '') {
383
+ problems.push(`${field}: expected a non-empty string`);
384
+ }
385
+ }
386
+ const slots = doc?.slots;
387
+ if (slots == null || typeof slots !== 'object' || Object.keys(slots).length === 0) {
388
+ problems.push('slots: expected at least one slot');
389
+ return problems;
390
+ }
391
+ for (const [name, slot] of Object.entries(slots)) {
392
+ if (typeof slot?.title !== 'string' || slot.title === '') {
393
+ problems.push(`slots.${name}.title: expected a non-empty string`);
394
+ }
395
+ if (!Array.isArray(slot?.accepts?.kinds) || slot.accepts.kinds.length === 0) {
396
+ problems.push(`slots.${name}.accepts.kinds: expected at least one kind`);
397
+ }
398
+ }
318
399
  return problems;
319
400
  }
320
401
 
@@ -325,11 +406,15 @@ export function problemsInTopic(doc) {
325
406
  * discovery this loads each doc, because a topic's name and its relationship
326
407
  * to an existing topic are fields inside the file.
327
408
  *
409
+ * A namespace doc and a guide with `placement` go to the docs tree instead of
410
+ * the topic list (spec:AST-046): they come back in `namespaces` and `guides`,
411
+ * named by the integration's provider id.
412
+ *
328
413
  * Errors are returned, not thrown: one unusable doc is reported as an issue
329
414
  * against its package while the rest of the CLI keeps working.
330
415
  *
331
- * @param {{name: string, docs?: string}} integration a loaded integration
332
- * @returns {Promise<{records: DocsTopicRecord[], errors: Error[]}>}
416
+ * @param {{name: string, docs?: string, providerId?: string}} integration a loaded integration
417
+ * @returns {Promise<{records: DocsTopicRecord[], errors: Error[], namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>}
333
418
  */
334
419
  export async function discoverIntegrationDocs(integration) {
335
420
  const docsDir = integration?.docs;
@@ -337,7 +422,14 @@ export async function discoverIntegrationDocs(integration) {
337
422
  const records = [];
338
423
  /** @type {Error[]} */
339
424
  const errors = [];
340
- if (!docsDir || !fs.existsSync(docsDir)) return {records, errors};
425
+ /** @type {import('../doc-compiler/tree.mjs').TreeNamespaceInput[]} */
426
+ const namespaces = [];
427
+ /** @type {import('../doc-compiler/tree.mjs').TreeDocInput[]} */
428
+ const guides = [];
429
+ if (!docsDir || !fs.existsSync(docsDir)) {
430
+ return {records, errors, namespaces, guides};
431
+ }
432
+ const providerId = integration.providerId ?? integration.name;
341
433
 
342
434
  /** @type {string[]} */
343
435
  const files = [];
@@ -372,11 +464,34 @@ export async function discoverIntegrationDocs(integration) {
372
464
  );
373
465
  continue;
374
466
  }
375
- const problems = problemsInTopic(doc);
467
+ const relative = path.relative(docsDir, file);
468
+ const source = `${integration.name}/${relative.split(path.sep).join('/')}`;
469
+ if (/** @type {any} */ (doc)?.type === 'namespace') {
470
+ const problems = problemsInNamespace(doc);
471
+ if (problems.length > 0) {
472
+ errors.push(
473
+ new Error(
474
+ `${relative} is not a usable namespace doc:\n${problems
475
+ .map(problem => ` ${problem}`)
476
+ .join('\n')}`,
477
+ ),
478
+ );
479
+ continue;
480
+ }
481
+ namespaces.push({
482
+ provider: integration.name,
483
+ providerId,
484
+ source,
485
+ doc: /** @type {any} */ (doc),
486
+ });
487
+ continue;
488
+ }
489
+ const placed = /** @type {any} */ (doc)?.placement != null;
490
+ const problems = problemsInTopic(doc, {placement: placed});
376
491
  if (problems.length > 0) {
377
492
  errors.push(
378
493
  new Error(
379
- `${path.relative(docsDir, file)} is not a usable topic:\n${problems
494
+ `${relative} is not a usable topic:\n${problems
380
495
  .map(problem => ` ${problem}`)
381
496
  .join('\n')}`,
382
497
  ),
@@ -397,6 +512,29 @@ export async function discoverIntegrationDocs(integration) {
397
512
  continue;
398
513
  }
399
514
  seen.set(topicKey, path.relative(docsDir, file));
515
+ if (placed) {
516
+ if (parsed.replaces != null || parsed.extends != null) {
517
+ errors.push(
518
+ new Error(
519
+ `${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.`,
520
+ ),
521
+ );
522
+ continue;
523
+ }
524
+ guides.push({
525
+ provider: integration.name,
526
+ providerId,
527
+ source,
528
+ kind: 'generic',
529
+ name: parsed.name,
530
+ title: parsed.title,
531
+ summary: parsed.description,
532
+ group: null,
533
+ placement: parsed.placement,
534
+ ref: {topicFile: file},
535
+ });
536
+ continue;
537
+ }
400
538
  if (parsed.replaces != null && parsed.extends != null) {
401
539
  errors.push(
402
540
  new Error(
@@ -414,10 +552,11 @@ export async function discoverIntegrationDocs(integration) {
414
552
  category: parsed.category ?? null,
415
553
  replaces: parsed.replaces,
416
554
  extendsTopic: parsed.extends,
555
+ ...(providerId === integration.name ? {} : {providerId}),
417
556
  });
418
557
  }
419
558
 
420
- return {records, errors};
559
+ return {records, errors, namespaces, guides};
421
560
  }
422
561
 
423
562
  /**
@@ -487,7 +626,7 @@ function findMergeTarget(sections, section) {
487
626
  const sameTitle = sections.findIndex(
488
627
  candidate => sourceTitle(candidate) === title,
489
628
  );
490
- return sameTitle === -1 ? byKey() : sameTitle;
629
+ return sameTitle;
491
630
  }
492
631
 
493
632
  /**
@@ -503,6 +642,46 @@ export class DocsCatalog {
503
642
  #topics = new Map();
504
643
  /** @type {Map<string, string>} old topic name → the name that replaced it */
505
644
  #aliases = new Map();
645
+ /** @type {Array<{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>} */
646
+ #treeInputs = [];
647
+ /** @type {Array<{package: string, message: string}>} */
648
+ #issues = [];
649
+
650
+ /**
651
+ * Record a doc file a package ships that did not load. Its package's docs
652
+ * are withdrawn; readers name the package so an author knows where to look.
653
+ * @param {{package: string, message: string}} issue
654
+ */
655
+ addIssue(issue) {
656
+ this.#issues.push(issue);
657
+ }
658
+
659
+ /**
660
+ * The doc files that did not load, by package.
661
+ * @returns {ReadonlyArray<{package: string, message: string}>}
662
+ */
663
+ get issues() {
664
+ return this.#issues;
665
+ }
666
+
667
+ /**
668
+ * Add the namespace docs and placed guides one integration ships to the
669
+ * docs tree (spec:AST-046).
670
+ * @param {{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}} inputs
671
+ */
672
+ addTreeInputs(inputs) {
673
+ if (inputs.namespaces.length > 0 || inputs.guides.length > 0) {
674
+ this.#treeInputs.push(inputs);
675
+ }
676
+ }
677
+
678
+ /**
679
+ * What the integrations add to the docs tree, in configured order.
680
+ * @returns {ReadonlyArray<{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>}
681
+ */
682
+ get treeInputs() {
683
+ return this.#treeInputs;
684
+ }
506
685
 
507
686
  /**
508
687
  * Seed a catalog with the CLI's own topics.
@@ -540,7 +719,11 @@ export class DocsCatalog {
540
719
  message: `"${record.name}" extends "${record.extendsTopic}", which is not a topic in this project.`,
541
720
  };
542
721
  }
543
- target.extensions.push({package: record.package, path: record.path});
722
+ target.extensions.push({
723
+ package: record.package,
724
+ path: record.path,
725
+ ...(record.providerId ? {providerId: record.providerId} : {}),
726
+ });
544
727
  return null;
545
728
  }
546
729
 
@@ -578,6 +761,7 @@ export class DocsCatalog {
578
761
  description: record.description,
579
762
  category: record.category,
580
763
  replaces: replaced,
764
+ ...(record.providerId ? {providerId: record.providerId} : {}),
581
765
  // Extensions were authored against the content that just went away.
582
766
  extensions: [],
583
767
  });
@@ -607,11 +791,26 @@ export class DocsCatalog {
607
791
  title: record.title,
608
792
  description: record.description,
609
793
  category: record.category,
794
+ ...(record.providerId ? {providerId: record.providerId} : {}),
610
795
  extensions: [],
611
796
  });
612
797
  return null;
613
798
  }
614
799
 
800
+ /**
801
+ * Every other name a topic answers to, lowercased: the names of the topics
802
+ * it replaced, directly or through a chain of replacements. `resolve` finds
803
+ * the topic by each of them.
804
+ * @param {DocsTopicEntry} entry
805
+ * @returns {string[]}
806
+ */
807
+ aliasesOf(entry) {
808
+ const key = entry.name.toLowerCase();
809
+ return [...this.#aliases]
810
+ .filter(([, to]) => to === key)
811
+ .map(([from]) => from);
812
+ }
813
+
615
814
  /**
616
815
  * Look a topic up by name, case-insensitively, following the alias a renamed
617
816
  * replacement left behind.