@astryxdesign/cli 0.6.3-canary.2bb99ed → 0.6.3-canary.2bdba84

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 (216) 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 +20 -3
  23. package/api/docs/docs.d.mts +5 -3
  24. package/api/docs/docs.doc.mjs +38 -17
  25. package/api/docs/docs.mjs +44 -8
  26. package/api/docs/docs.test.mjs +158 -4
  27. package/api/docs/docs.type.d.mts +181 -2
  28. package/api/docs/docs.type.mjs +117 -3
  29. package/api/docs/index/index.mjs +11 -3
  30. package/api/docs/index/index.test.mjs +1 -1
  31. package/api/docs/integration-tree.test.mjs +555 -0
  32. package/api/docs/integrationDocs.test.mjs +14 -14
  33. package/api/docs/list/list.mjs +25 -5
  34. package/api/docs/node/node.d.mts +43 -0
  35. package/api/docs/node/node.mjs +192 -0
  36. package/api/docs/reference-blocks.test.mjs +406 -0
  37. package/api/doctor/doctor.d.mts +30 -2
  38. package/api/doctor/doctor.mjs +150 -7
  39. package/api/doctor/doctor.test.mjs +89 -1
  40. package/api/index.d.mts +1 -1
  41. package/api/index.mjs +1 -0
  42. package/api/init/init.doc.mjs +1 -1
  43. package/api/integration/add-contribution.d.mts +2 -1
  44. package/api/integration/add-contribution.mjs +107 -5
  45. package/api/integration/add-contribution.test.mjs +137 -0
  46. package/api/integration/authoring-checks.mjs +138 -28
  47. package/api/integration/authoring-checks.test.mjs +171 -3
  48. package/api/integration/authoring-checks.type.mjs +6 -1
  49. package/api/integration/integration-authoring.type.d.mts +2 -0
  50. package/api/integration/integration-authoring.type.mjs +2 -0
  51. package/api/integration/integrationAdd.doc.mjs +6 -0
  52. package/api/integration/integrationAddDoc.doc.mjs +7 -1
  53. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  54. package/api/integration/integrationPackCheck.doc.mjs +1 -1
  55. package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
  56. package/api/integration/integrationTemplateConflicts.doc.mjs +3 -0
  57. package/api/integration/pack-check.mjs +34 -0
  58. package/api/integration/pack-check.test.mjs +121 -0
  59. package/api/integration/pack-check.type.d.mts +26 -2
  60. package/api/integration/pack-check.type.mjs +14 -1
  61. package/api/integration/template-conflict-compatibility.test.mjs +73 -0
  62. package/api/integration/validate-integration.test.mjs +3 -3
  63. package/api/integration/validateIntegration.doc.mjs +1 -1
  64. package/api/json/index.ts +2 -0
  65. package/api/layout/_adapter.mjs +20 -5
  66. package/api/search/search.d.mts +59 -1
  67. package/api/search/search.doc.mjs +4 -3
  68. package/api/search/search.mjs +442 -71
  69. package/api/search/search.test.mjs +91 -2
  70. package/api/search/search.type.d.mts +13 -1
  71. package/api/search/search.type.mjs +4 -1
  72. package/api/template/list/list.mjs +1 -0
  73. package/api/template/table-floating-bulk-actions.test.mjs +66 -0
  74. package/api/template/template-integration.test.mjs +1072 -3
  75. package/api/template/template.doc.mjs +27 -7
  76. package/api/template/template.mjs +45 -8
  77. package/api/template/template.type.d.mts +6 -8
  78. package/api/template/template.type.mjs +3 -2
  79. package/api/theme/template/template.test.mjs +5 -0
  80. package/api/theme/themeTemplate.doc.mjs +1 -1
  81. package/assets/docs/getting-started.doc.mjs +2 -2
  82. package/assets/docs/layout.doc.dense.mjs +2 -2
  83. package/assets/docs/layout.doc.mjs +1 -1
  84. package/assets/docs/principles.doc.mjs +6 -6
  85. package/assets/docs/styling-libraries.doc.mjs +3 -3
  86. package/assets/docs/styling.doc.mjs +4 -4
  87. package/assets/docs/theme.doc.mjs +4 -4
  88. package/assets/docs/tokens.doc.mjs +1 -1
  89. package/assets/docs/tree/api.doc.mjs +30 -0
  90. package/assets/docs/tree/cli.doc.mjs +23 -0
  91. package/assets/docs/tree/commands.doc.mjs +25 -0
  92. package/assets/docs/{cli-integrations.doc.mjs → tree/integrations.doc.mjs} +37 -9
  93. package/assets/docs/tree/integrations.test.mjs +62 -0
  94. package/assets/docs/tree/writing-docs.doc.mjs +286 -0
  95. package/assets/docs/working-with-ai.doc.mjs +3 -3
  96. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
  97. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
  98. package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
  99. package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
  100. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
  101. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
  102. package/authoring/debug/parse.d.mts +3 -3
  103. package/authoring/doctypes/_schema.d.mts +72 -0
  104. package/authoring/doctypes/_schema.mjs +25 -1
  105. package/authoring/doctypes/base/graph-fields.doc.mjs +7 -5
  106. package/authoring/doctypes/base/type.ts +6 -5
  107. package/authoring/doctypes/command/command.doc.mjs +1 -1
  108. package/authoring/doctypes/command/type.ts +2 -2
  109. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  110. package/authoring/doctypes/enum/type.ts +1 -1
  111. package/authoring/doctypes/function/function.doc.mjs +3 -2
  112. package/authoring/doctypes/function/type.ts +3 -2
  113. package/authoring/doctypes/load-contract.test.mjs +25 -0
  114. package/authoring/doctypes/namespace/namespace.doc.mjs +5 -9
  115. package/authoring/doctypes/reference/reference.doc.mjs +31 -4
  116. package/authoring/doctypes/reference/type.ts +23 -5
  117. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  118. package/authoring/doctypes/schema/type.ts +1 -1
  119. package/authoring/doctypes/template/parse.d.mts +2 -0
  120. package/authoring/doctypes/template/parse.mjs +4 -0
  121. package/authoring/doctypes/template/parse.test.mjs +18 -0
  122. package/authoring/doctypes/template/template.doc.mjs +6 -0
  123. package/authoring/doctypes/template/type.ts +8 -0
  124. package/authoring/identity/identity.doc.mjs +2 -2
  125. package/authoring/integration/type.ts +1 -1
  126. package/clients/cli/commands/build-theme.adaptations.test.mjs +100 -1
  127. package/clients/cli/commands/build-theme.mjs +1 -1
  128. package/clients/cli/commands/build.doc.mjs +11 -6
  129. package/clients/cli/commands/build.mjs +105 -67
  130. package/clients/cli/commands/build.text-fields.test.mjs +41 -0
  131. package/clients/cli/commands/component/index.mjs +1 -1
  132. package/clients/cli/commands/component-ownership.test.mjs +3 -3
  133. package/clients/cli/commands/discover.broken-integration.test.mjs +7 -8
  134. package/clients/cli/commands/discover.mjs +1 -1
  135. package/clients/cli/commands/docs.doc.mjs +20 -8
  136. package/clients/cli/commands/docs.mjs +177 -20
  137. package/clients/cli/commands/docs.test.mjs +114 -7
  138. package/clients/cli/commands/doctor-integration-docs.doc.mjs +2 -2
  139. package/clients/cli/commands/doctor-integration-templates.doc.mjs +14 -7
  140. package/clients/cli/commands/doctor-integration.test.mjs +75 -1
  141. package/clients/cli/commands/doctor.mjs +53 -16
  142. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  143. package/clients/cli/commands/integration.mjs +1 -0
  144. package/clients/cli/commands/search.mjs +11 -2
  145. package/clients/cli/commands/setup-nudge.test.mjs +6 -0
  146. package/clients/cli/commands/template.doc.mjs +23 -6
  147. package/clients/cli/commands/template.mjs +4 -91
  148. package/clients/cli/commands/text-json-parity.test.mjs +2 -1
  149. package/clients/cli/index.mjs +8 -0
  150. package/clients/cli/lib/manifest.mjs +9 -2
  151. package/foundation/agent-docs/agent-docs.d.mts +3 -2
  152. package/foundation/agent-docs/agent-docs.mjs +13 -9
  153. package/foundation/agent-docs/agent-docs.test.mjs +19 -1
  154. package/foundation/config/project.d.mts +12 -11
  155. package/foundation/config/project.mjs +73 -59
  156. package/foundation/config/project.test.mjs +141 -5
  157. package/foundation/discovery/authoring-self-docs.d.mts +12 -0
  158. package/foundation/discovery/authoring-self-docs.mjs +20 -8
  159. package/foundation/discovery/authoring-self-docs.test.mjs +24 -9
  160. package/foundation/discovery/cli-self-docs.d.mts +40 -34
  161. package/foundation/discovery/cli-self-docs.mjs +91 -115
  162. package/foundation/discovery/cli-self-docs.test.mjs +104 -166
  163. package/foundation/discovery/component-discovery.d.mts +38 -0
  164. package/foundation/discovery/component-discovery.mjs +48 -0
  165. package/foundation/discovery/docs-discovery.d.mts +109 -9
  166. package/foundation/discovery/docs-discovery.mjs +217 -19
  167. package/foundation/discovery/docs-discovery.test.mjs +96 -17
  168. package/foundation/discovery/docs-output-budget.d.mts +2 -2
  169. package/foundation/discovery/docs-output-budget.mjs +1 -1
  170. package/foundation/discovery/docs-section-key.d.mts +9 -2
  171. package/foundation/discovery/docs-section-key.mjs +15 -1
  172. package/foundation/discovery/template-adapter.d.mts +92 -6
  173. package/foundation/discovery/template-adapter.mjs +453 -17
  174. package/foundation/discovery/template-adapter.test.mjs +42 -0
  175. package/foundation/discovery/template-conflict-release.d.mts +13 -0
  176. package/foundation/discovery/template-conflict-release.mjs +40 -0
  177. package/foundation/discovery/template-conflict-release.test.mjs +40 -0
  178. package/foundation/doc-compiler/bundle.mjs +61 -1
  179. package/foundation/doc-compiler/bundle.test.mjs +21 -10
  180. package/foundation/doc-compiler/compile.d.mts +113 -132
  181. package/foundation/doc-compiler/compile.mjs +52 -6
  182. package/foundation/doc-compiler/diagnostics.mjs +28 -0
  183. package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
  184. package/foundation/doc-compiler/inputs.d.mts +2 -2
  185. package/foundation/doc-compiler/inputs.mjs +6 -1
  186. package/foundation/doc-compiler/ir.mjs +7 -0
  187. package/foundation/doc-compiler/lenses.d.mts +8 -5
  188. package/foundation/doc-compiler/lenses.mjs +50 -4
  189. package/foundation/doc-compiler/links.d.mts +162 -0
  190. package/foundation/doc-compiler/links.mjs +294 -0
  191. package/foundation/doc-compiler/links.test.mjs +192 -0
  192. package/foundation/doc-compiler/lower-doc.test.mjs +5 -2
  193. package/foundation/doc-compiler/read.d.mts +3 -2
  194. package/foundation/doc-compiler/read.mjs +6 -1
  195. package/foundation/doc-compiler/tree.d.mts +288 -0
  196. package/foundation/doc-compiler/tree.mjs +876 -0
  197. package/foundation/doc-compiler/tree.test.mjs +598 -0
  198. package/foundation/integrations/autolink.test.mjs +1 -1
  199. package/foundation/integrations/cli-requirement.d.mts +45 -0
  200. package/foundation/integrations/cli-requirement.mjs +154 -0
  201. package/foundation/integrations/cli-requirement.test.mjs +84 -0
  202. package/foundation/integrations/contribution-inventory.d.mts +2 -1
  203. package/foundation/integrations/contribution-inventory.mjs +10 -4
  204. package/foundation/integrations/contribution-inventory.test.mjs +19 -0
  205. package/foundation/integrations/integration-warnings.d.mts +9 -2
  206. package/foundation/integrations/integration-warnings.mjs +51 -26
  207. package/foundation/integrations/integration-warnings.test.mjs +74 -1
  208. package/foundation/integrations/validate-contributions.mjs +25 -27
  209. package/foundation/response/response-types.doc.d.mts +5 -1
  210. package/foundation/response/response-types.doc.mjs +19 -10
  211. package/foundation/text/string-utils.d.mts +8 -0
  212. package/foundation/text/string-utils.mjs +18 -0
  213. package/foundation/xle/expand.mjs +1 -1
  214. package/foundation/xle/xle.test.mjs +13 -0
  215. package/package.json +9 -9
  216. package/assets/docs/cli.doc.mjs +0 -15
@@ -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
 
@@ -271,6 +310,46 @@ describe('problemsInTopic', () => {
271
310
  }
272
311
  });
273
312
 
313
+ it('takes a reference block, and checks its projection and presentation', () => {
314
+ /** @param {any[]} content */
315
+ const withBlocks = content =>
316
+ problemsInTopic(topic({sections: [{title: 'Overview', content}]}));
317
+ expect(
318
+ withBlocks([
319
+ {type: 'reference', target: 'schema:integration'},
320
+ {
321
+ type: 'reference',
322
+ target: '@astryxdesign/cli:schema:integration',
323
+ projection: {fields: ['docs']},
324
+ presentation: 'compact',
325
+ },
326
+ ]),
327
+ ).toEqual([]);
328
+ expect(
329
+ withBlocks([
330
+ {type: 'reference', target: ''},
331
+ {type: 'reference', target: 'schema:x', presentation: 'card'},
332
+ {type: 'reference', target: 'schema:x', projection: {fields: []}},
333
+ {type: 'reference', target: 'schema:x', projection: {rows: ['a']}},
334
+ {type: 'reference', target: 'schema:x', projection: ['docs']},
335
+ {type: 'reference', target: 'schema:x', link: {}},
336
+ ]),
337
+ ).toEqual([
338
+ 'sections[0].content[0].target: expected a non-empty string',
339
+ 'sections[0].content[1].presentation: "card" is not one of summary, compact, full',
340
+ 'sections[0].content[2].projection.fields: expected a non-empty array of names',
341
+ 'sections[0].content[3].projection.rows: not a field of a projection',
342
+ 'sections[0].content[4].projection: expected {fields?, sections?}, naming the parts of the doc to include',
343
+ 'sections[0].content[5].link: not a field of a reference block',
344
+ ]);
345
+ // Workflow and collection blocks stay in a namespace doc's `blocks`.
346
+ for (const type of ['workflow', 'collection']) {
347
+ expect(withBlocks([{type}]).join('\n')).toContain(
348
+ 'requires the compiled graph renderer',
349
+ );
350
+ }
351
+ });
352
+
274
353
  it('rejects a name that is not URL-safe', () => {
275
354
  expect(problemsInTopic(topic({name: 'not a topic'})).join('\n')).toContain(
276
355
  'URL-safe',
@@ -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
  *
@@ -93,6 +93,20 @@ function legacyTitleMatchIndex(sections, query) {
93
93
  });
94
94
  }
95
95
 
96
+ /**
97
+ * A name as a docs-tree route segment: lowercase words joined by hyphens, so
98
+ * `integrationPackCheck` and `integration pack` both read naturally.
99
+ * @param {string} name
100
+ * @returns {string}
101
+ */
102
+ export function routeSegment(name) {
103
+ return String(name)
104
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
105
+ .toLowerCase()
106
+ .replace(/[^a-z0-9]+/g, '-')
107
+ .replace(/^-+|-+$/g, '');
108
+ }
109
+
96
110
  /**
97
111
  * Fatal key problems: only an explicitly authored `id` can make a previously
98
112
  * readable topic invalid. Derived-key collisions and titles with no Latin
@@ -292,7 +306,7 @@ export function sectionSummary(section, max = SECTION_SUMMARY_MAX) {
292
306
  * The index a topic-only read returns: what the topic is, and one entry per
293
307
  * section with the key to read it by.
294
308
  * @param {{name: string, title: string, description: string, sections: any[]}} doc
295
- * @returns {import('../../api/docs/docs.type.mjs').DocsIndex}
309
+ * @returns {Omit<import('../../api/docs/docs.type.mjs').DocsIndex, 'links'>}
296
310
  */
297
311
  export function buildDocsIndexData(doc) {
298
312
  return {
@@ -10,6 +10,25 @@
10
10
  export function pkgOf(t: {
11
11
  package?: string;
12
12
  }): string;
13
+ /**
14
+ * Every id that should resolve to a discovered template. Replacements keep
15
+ * their own integration id and also own the Core id they replace.
16
+ * @param {{dirName: string, replaces?: string}} template
17
+ * @returns {string[]}
18
+ */
19
+ export function templateLookupIds(template: {
20
+ dirName: string;
21
+ replaces?: string;
22
+ }): string[];
23
+ /**
24
+ * Remove entries shadowed in the default discovery view while retaining them in
25
+ * package-scoped views. An active replacement owns its target id. A rejected
26
+ * same-id declaration falls back to Core when a Core template of the same kind
27
+ * owns that id; otherwise the integration template remains available by kind.
28
+ * @param {DiscoveredTemplate[]} templates
29
+ * @returns {DiscoveredTemplate[]}
30
+ */
31
+ export function effectiveTemplateDiscovery(templates: DiscoveredTemplate[]): DiscoveredTemplate[];
13
32
  /**
14
33
  * Replace each Astryx template fixture reference with a placeholder so
15
34
  * scaffolded pages render with zero setup. Images get a self-contained data
@@ -51,22 +70,54 @@ export function findPageDocFile(dirPath: string): string | null;
51
70
  * @returns {Promise<DiscoveredTemplate[]>}
52
71
  */
53
72
  export function discoverCoreTemplates(): Promise<DiscoveredTemplate[]>;
73
+ /**
74
+ * Apply valid integration replacements to a raw template set.
75
+ *
76
+ * One declaration owns its Core target. When different configured packages
77
+ * replace the same target, the later package wins and discovery returns a
78
+ * warning, matching integration-doc replacement order. Multiple declarations
79
+ * inside one package are invalid and fail closed. Missing targets and kind
80
+ * mismatches also fail closed: Core stays selected and every integration
81
+ * template remains addressable by its own id.
82
+ *
83
+ * @param {DiscoveredTemplate[]} templates
84
+ * @param {TemplateDiscoveryError[]} [declarationErrors]
85
+ * @returns {{templates: DiscoveredTemplate[], errors: TemplateReplacementError[]}}
86
+ */
87
+ export function applyTemplateReplacements(templates: DiscoveredTemplate[], declarationErrors?: TemplateDiscoveryError[]): {
88
+ templates: DiscoveredTemplate[];
89
+ errors: TemplateReplacementError[];
90
+ };
91
+ /**
92
+ * Discover every template without hiding replaced Core originals. Internal
93
+ * package-qualified selection uses this view.
94
+ * @param {string} [cwd]
95
+ * @returns {Promise<DiscoveredTemplate[]>}
96
+ */
97
+ export function discoverAllUnresolved(cwd?: string): Promise<DiscoveredTemplate[]>;
98
+ /**
99
+ * Discover the resolved catalog before default-view shadowing. Internal
100
+ * package-qualified selection uses this view.
101
+ * @param {string} [cwd]
102
+ * @returns {Promise<DiscoveredTemplate[]>}
103
+ */
104
+ export function discoverAllResolved(cwd?: string): Promise<DiscoveredTemplate[]>;
54
105
  /**
55
106
  * @param {string} [cwd]
56
107
  * @returns {Promise<DiscoveredTemplate[]>}
57
108
  */
58
109
  export function discoverAll(cwd?: string): Promise<DiscoveredTemplate[]>;
59
110
  /**
60
- * Like {@link discoverAll} but also returns integration-template discovery
61
- * errors (missing same-stem source, missing `type`, load failure). Use this
62
- * when the caller wants to warn about malformed integration templates.
111
+ * Like {@link discoverAll} but also returns integration-template discovery and
112
+ * replacement-declaration errors. Use this when the caller wants to warn about
113
+ * malformed integration templates or inactive replacement declarations.
63
114
  *
64
115
  * @param {string} [cwd]
65
- * @returns {Promise<{templates: DiscoveredTemplate[], errors: TemplateDiscoveryError[]}>}
116
+ * @returns {Promise<{templates: DiscoveredTemplate[], errors: Array<TemplateDiscoveryError | TemplateReplacementError>}>}
66
117
  */
67
118
  export function discoverAllWithErrors(cwd?: string): Promise<{
68
119
  templates: DiscoveredTemplate[];
69
- errors: TemplateDiscoveryError[];
120
+ errors: Array<TemplateDiscoveryError | TemplateReplacementError>;
70
121
  }>;
71
122
  /**
72
123
  * Discover the templates contributed by a SINGLE integration. Same per-template
@@ -74,12 +125,13 @@ export function discoverAllWithErrors(cwd?: string): Promise<{
74
125
  * page|block type required); broken templates are recorded in `errors` rather
75
126
  * than thrown. Exposed for `doctor integration validate` and template authoring checks.
76
127
  *
77
- * @param {{name?: string, __spec?: string, templates?: string}} integration
128
+ * @param {{name?: string, __spec?: string, __autolinked?: boolean, templates?: string}} integration
78
129
  * @returns {Promise<{templates: DiscoveredTemplate[], errors: TemplateDiscoveryError[]}>}
79
130
  */
80
131
  export function discoverIntegrationTemplatesForOne(integration: {
81
132
  name?: string;
82
133
  __spec?: string;
134
+ __autolinked?: boolean;
83
135
  templates?: string;
84
136
  }): Promise<{
85
137
  templates: DiscoveredTemplate[];
@@ -133,6 +185,23 @@ export type DiscoveredTemplate = {
133
185
  filePath: string;
134
186
  docPath: string;
135
187
  package?: string | undefined;
188
+ /**
189
+ * whether the owning integration was discovered
190
+ * from package.json rather than named in astryx.config
191
+ */
192
+ autolinked?: boolean | undefined;
193
+ /**
194
+ * active Core template id this integration template replaces
195
+ */
196
+ replaces?: string | undefined;
197
+ /**
198
+ * whether an invalid declaration was disabled
199
+ */
200
+ replacementRejected?: boolean | undefined;
201
+ /**
202
+ * disabled declaration target
203
+ */
204
+ replacementTarget?: string | undefined;
136
205
  };
137
206
  /**
138
207
  * An integration-template discovery error.
@@ -141,6 +210,23 @@ export type TemplateDiscoveryError = {
141
210
  package: string;
142
211
  template?: string | undefined;
143
212
  message: string;
213
+ code?: string | undefined;
214
+ severity?: "error" | "warning" | undefined;
215
+ /**
216
+ * Core target whose replacement set is invalid
217
+ */
218
+ replacementTarget?: string | undefined;
219
+ /**
220
+ * whether the declaration came from an autolinked integration
221
+ */
222
+ autolinked?: boolean | undefined;
223
+ };
224
+ /**
225
+ * A semantic error in an integration template replacement declaration.
226
+ */
227
+ export type TemplateReplacementError = TemplateDiscoveryError & {
228
+ code: "missing_template_replacement_target" | "ambiguous_template_replacement" | "invalid_template_replacement";
229
+ severity: "warning" | "error";
144
230
  };
145
231
  /**
146
232
  * The loaded metadata object from a template spec (loose — authored shape).