@astryxdesign/cli 0.7.3 → 0.7.4-canary.1a552f2

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 (244) hide show
  1. package/README.md +63 -63
  2. package/api/component/_adapter.mjs +4 -3
  3. package/api/component/component.mjs +13 -6
  4. package/api/component/doc-links.test.mjs +33 -0
  5. package/api/discover/_adapter.mjs +22 -10
  6. package/api/discover/_catalog-view.d.mts +2 -0
  7. package/api/discover/_catalog-view.mjs +1 -0
  8. package/api/discover/_catalog-view.test.mjs +1 -0
  9. package/api/discover/detail/detail.mjs +1 -0
  10. package/api/discover/detail/detail.test.mjs +3 -0
  11. package/api/discover/detail/doc/doc.mjs +5 -1
  12. package/api/discover/detail/doc/doc.test.mjs +1 -0
  13. package/api/discover/detail/item/item.mjs +2 -0
  14. package/api/discover/detail/item/item.test.mjs +2 -0
  15. package/api/discover/discover.doc.mjs +4 -4
  16. package/api/discover/discover.type.d.mts +20 -0
  17. package/api/discover/discover.type.mjs +5 -0
  18. package/api/discover/list/list.test.mjs +2 -0
  19. package/api/discover/search/search.d.mts +3 -2
  20. package/api/discover/search/search.mjs +26 -7
  21. package/api/discover/search/search.test.mjs +67 -0
  22. package/api/docs/_adapter.d.mts +80 -0
  23. package/api/docs/_adapter.mjs +261 -11
  24. package/api/docs/detail/detail.mjs +8 -0
  25. package/api/docs/docOverlays.test.mjs +2 -1
  26. package/api/docs/docs.d.mts +16 -6
  27. package/api/docs/docs.doc.mjs +1 -1
  28. package/api/docs/docs.mjs +55 -6
  29. package/api/docs/docs.type.d.mts +28 -2
  30. package/api/docs/docs.type.mjs +13 -3
  31. package/api/docs/guide-route-targets.test.mjs +1002 -0
  32. package/api/docs/index/index.mjs +9 -0
  33. package/api/docs/integration-tree.test.mjs +22 -0
  34. package/api/docs/integrationDocs.test.mjs +85 -0
  35. package/api/docs/list/list.mjs +7 -1
  36. package/api/docs/node/node.mjs +9 -1
  37. package/api/docs/reference-blocks.test.mjs +1 -1
  38. package/api/doctor/_adapter.d.mts +40 -0
  39. package/api/doctor/_adapter.mjs +171 -1
  40. package/api/doctor/built-checks.d.mts +85 -0
  41. package/api/doctor/built-checks.mjs +837 -0
  42. package/api/doctor/built-checks.test.mjs +531 -0
  43. package/api/doctor/doctor.d.mts +6 -5
  44. package/api/doctor/doctor.doc.mjs +11 -1
  45. package/api/doctor/doctor.mjs +18 -3
  46. package/api/doctor/doctor.type.d.mts +6 -0
  47. package/api/doctor/doctor.type.mjs +3 -0
  48. package/api/hook/list/list.d.mts +1 -1
  49. package/api/integration/_adapter.d.mts +11 -2
  50. package/api/integration/_adapter.mjs +30 -4
  51. package/api/integration/authoring-checks.mjs +29 -2
  52. package/api/integration/authoring-checks.test.mjs +131 -1
  53. package/api/integration/check/check.d.mts +4 -1
  54. package/api/integration/check/check.mjs +34 -4
  55. package/api/integration/check/check.test.mjs +49 -0
  56. package/api/integration/integration-check.type.d.mts +8 -0
  57. package/api/integration/integration-check.type.mjs +4 -1
  58. package/api/integration/integrationCheck.doc.mjs +8 -1
  59. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  60. package/api/integration/pack-check.mjs +71 -2
  61. package/api/integration/pack-check.test.mjs +77 -0
  62. package/api/integration/validate-integration-case-disk.test.mjs +2 -0
  63. package/api/integration/validate-integration-gaps.test.mjs +7 -4
  64. package/api/integration/validate-integration.mjs +96 -14
  65. package/api/integration/validate-integration.type.d.mts +10 -4
  66. package/api/integration/validate-integration.type.mjs +10 -5
  67. package/api/integration/validateIntegration.doc.mjs +1 -1
  68. package/api/search/_candidate-score.d.mts +3 -2
  69. package/api/search/_candidate-score.mjs +66 -3
  70. package/api/search/_gather-docs.mjs +12 -2
  71. package/api/search/_priority.mjs +2 -1
  72. package/api/search/_score.d.mts +2 -1
  73. package/api/search/_score.mjs +2 -2
  74. package/api/search/search.doc.mjs +1 -1
  75. package/api/search/search.family-members.test.mjs +124 -0
  76. package/api/search/search.mjs +28 -0
  77. package/api/theme/palette/generate/generate.d.mts +8 -0
  78. package/api/theme/palette/generate/generate.mjs +38 -11
  79. package/api/theme/palette/generate/generate.test.mjs +83 -4
  80. package/api/theme/palette/generate/generator.d.mts +6 -0
  81. package/api/theme/palette/generate/generator.mjs +6 -0
  82. package/api/theme/theme.type.d.mts +12 -1
  83. package/api/theme/theme.type.mjs +7 -1
  84. package/api/theme/themeBuild.doc.mjs +1 -1
  85. package/api/theme/themeList.doc.mjs +1 -1
  86. package/api/theme/themePaletteGenerate.doc.mjs +1 -1
  87. package/api/theme/themeTargets.doc.mjs +1 -1
  88. package/assets/discover/official-packages.json +16 -0
  89. package/assets/docs/author-a-theme.doc.mjs +15 -15
  90. package/assets/docs/browser-support.doc.mjs +1 -1
  91. package/assets/docs/getting-started.doc.mjs +16 -16
  92. package/assets/docs/is-my-code-good.doc.mjs +6 -6
  93. package/assets/docs/styling-overview.doc.mjs +5 -5
  94. package/assets/docs/theme.doc.mjs +5 -5
  95. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  96. package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
  97. package/assets/docs/tree/add-a-topic.doc.mjs +6 -6
  98. package/assets/docs/tree/agent-guidance.doc.mjs +5 -5
  99. package/assets/docs/tree/authoring.doc.mjs +2 -2
  100. package/assets/docs/tree/block-template.doc.mjs +1 -1
  101. package/assets/docs/tree/check-the-props.doc.mjs +3 -3
  102. package/assets/docs/tree/check-your-docs.doc.mjs +6 -6
  103. package/assets/docs/tree/checks.doc.mjs +11 -11
  104. package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
  105. package/assets/docs/tree/cli-command.doc.mjs +6 -6
  106. package/assets/docs/tree/codemods.doc.mjs +7 -7
  107. package/assets/docs/tree/component-family.doc.mjs +1 -1
  108. package/assets/docs/tree/component-imports.doc.mjs +2 -2
  109. package/assets/docs/tree/component-lookups.doc.mjs +6 -5
  110. package/assets/docs/tree/computer-agent-guide.doc.mjs +7 -7
  111. package/assets/docs/tree/computer-integrations.doc.mjs +5 -5
  112. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +3 -3
  113. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  114. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  115. package/assets/docs/tree/doc-syntax.doc.mjs +219 -0
  116. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  117. package/assets/docs/tree/extend-or-replace.doc.mjs +39 -7
  118. package/assets/docs/tree/font-setup.doc.mjs +1 -1
  119. package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
  120. package/assets/docs/tree/global-integrations.doc.mjs +11 -11
  121. package/assets/docs/tree/global.doc.mjs +2 -2
  122. package/assets/docs/tree/host-entry.doc.mjs +1 -1
  123. package/assets/docs/tree/install-once.doc.mjs +4 -4
  124. package/assets/docs/tree/layout.doc.mjs +1 -1
  125. package/assets/docs/tree/links.doc.mjs +2 -2
  126. package/assets/docs/tree/migration-setup.doc.mjs +15 -15
  127. package/assets/docs/tree/migration.doc.mjs +2 -1
  128. package/assets/docs/tree/other-libraries.doc.mjs +1 -1
  129. package/assets/docs/tree/page-template.doc.mjs +2 -2
  130. package/assets/docs/tree/problems.doc.mjs +8 -8
  131. package/assets/docs/tree/project-global-or-both.doc.mjs +2 -2
  132. package/assets/docs/tree/publishing.doc.mjs +7 -7
  133. package/assets/docs/tree/quick-start.doc.mjs +9 -9
  134. package/assets/docs/tree/reference.doc.mjs +2 -2
  135. package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
  136. package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
  137. package/assets/docs/tree/scaffold.doc.mjs +1 -1
  138. package/assets/docs/tree/sections-and-placement.doc.mjs +3 -3
  139. package/assets/docs/tree/see-it-in-an-app.doc.mjs +3 -3
  140. package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
  141. package/assets/docs/tree/single-component.doc.mjs +4 -4
  142. package/assets/docs/tree/start-a-template.doc.mjs +5 -5
  143. package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
  144. package/assets/docs/tree/styling-libraries.doc.mjs +2 -1
  145. package/assets/docs/tree/styling.doc.mjs +1 -1
  146. package/assets/docs/tree/tailwind.doc.mjs +1 -1
  147. package/assets/docs/tree/test-in-an-app.doc.mjs +5 -5
  148. package/assets/docs/tree/test-template-in-app.doc.mjs +6 -6
  149. package/assets/docs/tree/tokens-and-setup.doc.mjs +1 -1
  150. package/assets/docs/tree/troubleshooting.doc.mjs +24 -20
  151. package/assets/docs/tree/uninstall.doc.mjs +2 -2
  152. package/assets/docs/tree/updates.doc.mjs +1 -1
  153. package/assets/docs/tree/upgrading.doc.mjs +3 -3
  154. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
  155. package/assets/docs/tree/verify-packed-template.doc.mjs +3 -3
  156. package/assets/docs/tree/versioning.doc.mjs +4 -4
  157. package/assets/docs/tree/who-answers.doc.mjs +4 -4
  158. package/assets/docs/tree/write-the-template-file.doc.mjs +4 -4
  159. package/assets/docs/use-a-theme.doc.mjs +10 -10
  160. package/assets/docs/use-integrations.doc.mjs +1 -1
  161. package/assets/docs/working-with-ai.doc.mjs +15 -15
  162. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +1 -1
  163. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.doc.mjs +1 -1
  164. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
  165. package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
  166. package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
  167. package/assets/templates/themes/butter/butterTheme.ts +274 -234
  168. package/assets/templates/themes/butter/palette.config.json +484 -0
  169. package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +41 -0
  170. package/assets/templates/themes/gothic/gothicPalettes.generated.receipt.json +979 -0
  171. package/assets/templates/themes/gothic/gothicPalettes.generated.ts +271 -0
  172. package/assets/templates/themes/gothic/gothicTheme.ts +130 -160
  173. package/assets/templates/themes/gothic/palette.config.json +371 -0
  174. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
  175. package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
  176. package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
  177. package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
  178. package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
  179. package/assets/templates/themes/matcha/palette.config.json +448 -0
  180. package/assets/templates/themes/stone/palette.config.json +262 -0
  181. package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +51 -0
  182. package/assets/templates/themes/stone/stonePalettes.generated.receipt.json +840 -0
  183. package/assets/templates/themes/stone/stonePalettes.generated.ts +501 -0
  184. package/assets/templates/themes/stone/stoneTheme.ts +190 -207
  185. package/assets/templates/themes/y2k/palette.config.json +166 -0
  186. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
  187. package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
  188. package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
  189. package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
  190. package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
  191. package/authoring/codemod/codemod.doc.mjs +1 -1
  192. package/authoring/config/config.doc.mjs +4 -4
  193. package/authoring/debug/parse.d.mts +1 -1
  194. package/authoring/discover/discover.doc.mjs +1 -1
  195. package/authoring/doctypes/_schema.d.mts +4 -0
  196. package/authoring/doctypes/_schema.mjs +4 -0
  197. package/authoring/doctypes/reference/type.ts +14 -2
  198. package/authoring/gap-report/gap-report.doc.mjs +1 -1
  199. package/authoring/integration/integration.doc.mjs +6 -6
  200. package/clients/cli/commands/discover.mjs +1 -1
  201. package/clients/cli/commands/discover.sources.test.mjs +6 -0
  202. package/clients/cli/commands/docs.doc.mjs +1 -1
  203. package/clients/cli/commands/docs.mjs +27 -2
  204. package/clients/cli/commands/docs.test.mjs +1 -1
  205. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  206. package/clients/cli/commands/doctor.doc.mjs +13 -1
  207. package/clients/cli/commands/doctor.mjs +25 -9
  208. package/clients/cli/commands/integration-check.doc.mjs +11 -0
  209. package/clients/cli/commands/integration-check.test.mjs +36 -3
  210. package/clients/cli/commands/integration-pack.doc.mjs +1 -1
  211. package/clients/cli/commands/integration-verify.doc.mjs +1 -1
  212. package/clients/cli/commands/integration.mjs +15 -3
  213. package/clients/cli/commands/theme-targets.doc.mjs +1 -1
  214. package/clients/cli/commands/upgrade.doc.mjs +2 -2
  215. package/clients/cli/lib/define-command.mjs +5 -3
  216. package/foundation/agent-docs/agent-docs.d.mts +14 -2
  217. package/foundation/agent-docs/agent-docs.mjs +65 -4
  218. package/foundation/agent-docs/agent-docs.test.mjs +107 -0
  219. package/foundation/discovery/docs-discovery.d.mts +93 -2
  220. package/foundation/discovery/docs-discovery.mjs +237 -8
  221. package/foundation/discovery/runner-allowlist.d.mts +2 -0
  222. package/foundation/discovery/runner-allowlist.mjs +4 -0
  223. package/foundation/discovery/runner-commands.d.mts +29 -13
  224. package/foundation/discovery/runner-commands.mjs +253 -17
  225. package/foundation/discovery/stray-pointers.mjs +11 -5
  226. package/foundation/discovery/stray-pointers.test.mjs +6 -0
  227. package/foundation/doc-compiler/compile.mjs +8 -1
  228. package/foundation/doc-compiler/doc-loads.test.mjs +3 -0
  229. package/foundation/doc-compiler/doc-syntax.d.mts +194 -0
  230. package/foundation/doc-compiler/doc-syntax.mjs +739 -0
  231. package/foundation/doc-compiler/doc-syntax.test.mjs +383 -0
  232. package/foundation/doc-compiler/links.d.mts +13 -16
  233. package/foundation/doc-compiler/links.mjs +40 -7
  234. package/foundation/doc-compiler/tree.d.mts +5 -0
  235. package/foundation/doc-compiler/tree.mjs +9 -0
  236. package/foundation/env/package-manager.d.mts +18 -0
  237. package/foundation/env/package-manager.mjs +40 -0
  238. package/foundation/integrations/cli-requirement.d.mts +29 -0
  239. package/foundation/integrations/cli-requirement.mjs +47 -0
  240. package/foundation/integrations/cli-requirement.test.mjs +23 -2
  241. package/foundation/response/error-codes.test.mjs +9 -0
  242. package/foundation/response/response-types.doc.mjs +11 -11
  243. package/foundation/response/response-types.doc.test.mjs +29 -0
  244. package/package.json +9 -9
@@ -155,6 +155,39 @@ export function packageDocsProblems(integration: {
155
155
  severity: "error" | "warning";
156
156
  message: string;
157
157
  }>>;
158
+ /**
159
+ * What one doc that replaces or extends another does, as a package's own
160
+ * check sees it.
161
+ * @typedef {object} DocTarget
162
+ * @property {string} topic the doc's own name
163
+ * @property {'replaces' | 'extends'} relationship
164
+ * @property {string} target the topic name or route it names
165
+ * @property {'topic' | 'guide' | 'namespace' | null} kind what the target
166
+ * is: a flat topic, a guide the docs tree places, a namespace (which neither
167
+ * takes), or null when it names nothing
168
+ * @property {string | null} guide for a guide, the route it is placed at now,
169
+ * which an old route resolves to
170
+ * @property {string[]} guidesBelow for a namespace, the routes of the guides
171
+ * placed below it, any of which the doc could name instead
172
+ * @property {string | null} owner the package whose topic or guide it is
173
+ * @property {Array<{section: string, field: 'before' | 'after', key: string}>} unplaced
174
+ * each section whose `before` or `after` names no section of the target, so
175
+ * it is added at the end instead
176
+ */
177
+ /**
178
+ * Each doc in one integration's docs that replaces or extends a topic, or a
179
+ * guide the docs tree places by its route, read against the CLI's docs and the
180
+ * package's own: what it names and whether that exists, and each section an
181
+ * extension places with `before` or `after` that finds no section there.
182
+ * @param {any} integration
183
+ * @param {{records: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicRecord[], namespaces: import('../../foundation/doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../../foundation/doc-compiler/tree.mjs').TreeDocInput[]}} discovered
184
+ * @returns {Promise<DocTarget[]>}
185
+ */
186
+ export function packageDocTargets(integration: any, discovered: {
187
+ records: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicRecord[];
188
+ namespaces: import("../../foundation/doc-compiler/tree.mjs").TreeNamespaceInput[];
189
+ guides: import("../../foundation/doc-compiler/tree.mjs").TreeDocInput[];
190
+ }): Promise<DocTarget[]>;
158
191
  /**
159
192
  * How a token reference finds its target: the topic it names in `catalog`,
160
193
  * lowered for the same language.
@@ -190,6 +223,9 @@ export function compileTopic(catalog: DocsCatalog, entry: import("../../foundati
190
223
  /**
191
224
  * A guide the docs tree places, as a topic entry the topic readers open by its
192
225
  * route. It is never a flat topic: `astryx docs <route>` is its only name.
226
+ * What integrations do to it by its route applies: a replacement is read in
227
+ * its place and names its own package, and each extension's sections merge
228
+ * onto it, each naming the package that wrote it (INV28).
193
229
  * @param {import('../../foundation/doc-compiler/tree.mjs').TreeNode} node
194
230
  * @returns {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry}
195
231
  */
@@ -363,6 +399,50 @@ export type FoundDoc = {
363
399
  tree: boolean;
364
400
  } | null;
365
401
  };
402
+ /**
403
+ * What one doc that replaces or extends another does, as a package's own
404
+ * check sees it.
405
+ */
406
+ export type DocTarget = {
407
+ /**
408
+ * the doc's own name
409
+ */
410
+ topic: string;
411
+ relationship: "replaces" | "extends";
412
+ /**
413
+ * the topic name or route it names
414
+ */
415
+ target: string;
416
+ /**
417
+ * what the target
418
+ * is: a flat topic, a guide the docs tree places, a namespace (which neither
419
+ * takes), or null when it names nothing
420
+ */
421
+ kind: "topic" | "guide" | "namespace" | null;
422
+ /**
423
+ * for a guide, the route it is placed at now,
424
+ * which an old route resolves to
425
+ */
426
+ guide: string | null;
427
+ /**
428
+ * for a namespace, the routes of the guides
429
+ * placed below it, any of which the doc could name instead
430
+ */
431
+ guidesBelow: string[];
432
+ /**
433
+ * the package whose topic or guide it is
434
+ */
435
+ owner: string | null;
436
+ /**
437
+ * each section whose `before` or `after` names no section of the target, so
438
+ * it is added at the end instead
439
+ */
440
+ unplaced: Array<{
441
+ section: string;
442
+ field: "before" | "after";
443
+ key: string;
444
+ }>;
445
+ };
366
446
  export type DocsTree = import("../../foundation/doc-compiler/tree.mjs").DocsTree;
367
447
  export type TreeNode = import("../../foundation/doc-compiler/tree.mjs").TreeNode;
368
448
  export type LinkProblem = import("../../foundation/doc-compiler/links.mjs").LinkProblem;
@@ -19,7 +19,11 @@
19
19
 
20
20
  import * as path from 'node:path';
21
21
  import {Project} from '../../foundation/config/project.mjs';
22
- import {DocsCatalog} from '../../foundation/discovery/docs-discovery.mjs';
22
+ import {
23
+ DocsCatalog,
24
+ isGuideRoute,
25
+ mergeTopicReport,
26
+ } from '../../foundation/discovery/docs-discovery.mjs';
23
27
  import {checkDocTypes} from '../../foundation/discovery/doc-types.mjs';
24
28
  import {integrationDocFiles} from '../../foundation/discovery/integration-doc-files.mjs';
25
29
  import {
@@ -42,6 +46,7 @@ import {
42
46
  linkBlocks,
43
47
  linkFields,
44
48
  parseLinkTarget,
49
+ renderTokens,
45
50
  } from '../../foundation/doc-compiler/links.mjs';
46
51
  import {
47
52
  createDocId,
@@ -311,7 +316,8 @@ function topicTextFields(doc) {
311
316
  * @returns {Promise<string>}
312
317
  */
313
318
  export async function linkDocText(catalog, providerId, text) {
314
- if (typeof text !== 'string' || !text.includes('{@link')) return text;
319
+ if (typeof text !== 'string') return text;
320
+ if (!text.includes('{@link')) return renderTokens(text);
315
321
  let provider;
316
322
  try {
317
323
  provider = normalizeProviderId(providerId);
@@ -339,7 +345,8 @@ export async function linkDocText(catalog, providerId, text) {
339
345
  * @returns {Promise<{doc: T, problems: LinkProblem[]}>}
340
346
  */
341
347
  export async function linkComponentDoc(catalog, providerId, doc) {
342
- if (!JSON.stringify(doc ?? null).includes('{@link')) {
348
+ // Doc tokens render in the same pass as links (resolveInline).
349
+ if (!JSON.stringify(doc ?? null).includes('{@')) {
343
350
  return {doc, problems: []};
344
351
  }
345
352
  return linkFields(
@@ -412,6 +419,7 @@ async function flatTopicInputs(catalog) {
412
419
  providerId: entry.providerId ?? entry.package,
413
420
  name: entry.name,
414
421
  title: title ?? entry.name,
422
+ // Rendered once, with the tree's other summaries (buildProjectTree).
415
423
  summary: description ?? '',
416
424
  category: category ?? null,
417
425
  source: `${entry.package}:${entry.name}`,
@@ -437,14 +445,61 @@ async function buildProjectTree(catalog, fresh) {
437
445
  docs: [...cli.docs, ...added.flatMap(each => each.guides)],
438
446
  topics: await flatTopicInputs(catalog),
439
447
  });
448
+ // A guide the tree places that an integration replaces or extends by its
449
+ // route, or by the route it had before it moved: reads apply what it does,
450
+ // and a replacement lists under its own title and summary.
451
+ // Each doc applies in configured order to the guide its route names, so a
452
+ // doc naming a guide's old route and one naming its new route stack as if
453
+ // both named the same one.
454
+ for (const record of catalog.guideTargeters) {
455
+ const node = placedGuideAt(
456
+ result,
457
+ /** @type {string} */ (record.replaces ?? record.extendsTopic),
458
+ );
459
+ if (!node) continue;
460
+ /** @type {import('../../foundation/discovery/docs-discovery.mjs').GuideOverlay} */
461
+ const overlay = node.guideOverlay ?? {replacement: null, extensions: []};
462
+ if (record.replaces != null) {
463
+ node.guideOverlay = {
464
+ replacement: record,
465
+ // Extensions were authored against the content that just went away.
466
+ extensions: [],
467
+ ...(overlay.replacement
468
+ ? {replacedPackage: overlay.replacement.package}
469
+ : {}),
470
+ };
471
+ } else {
472
+ node.guideOverlay = {
473
+ ...overlay,
474
+ extensions: [
475
+ ...overlay.extensions,
476
+ {
477
+ package: record.package,
478
+ path: record.path,
479
+ ...(record.providerId ? {providerId: record.providerId} : {}),
480
+ },
481
+ ],
482
+ };
483
+ }
484
+ }
485
+ for (const node of result.nodes.values()) {
486
+ const replacement = node.guideOverlay?.replacement;
487
+ if (replacement) {
488
+ node.title = replacement.title ?? node.title;
489
+ node.summary = replacement.description ?? node.summary;
490
+ }
491
+ }
440
492
  // A summary is a doc's text too: each link in it reads as the command that
441
493
  // opens its doc, wherever the tree's summaries print (spec:AST-047 FR9).
442
494
  for (const node of result.nodes.values()) {
443
- if (typeof node.summary === 'string' && node.summary.includes('{@link')) {
495
+ if (typeof node.summary === 'string' && node.summary.includes('{@')) {
496
+ const replacement = node.guideOverlay?.replacement;
444
497
  node.summary = await linkSummary(
445
498
  catalog,
446
499
  result,
447
- node.providerId,
500
+ replacement
501
+ ? (replacement.providerId ?? replacement.package)
502
+ : node.providerId,
448
503
  node.summary,
449
504
  );
450
505
  }
@@ -466,7 +521,7 @@ async function buildProjectTree(catalog, fresh) {
466
521
  * @returns {Promise<string>}
467
522
  */
468
523
  async function linkSummary(catalog, tree, providerId, summary) {
469
- if (!summary.includes('{@link')) return summary;
524
+ if (!summary.includes('{@link')) return renderTokens(summary);
470
525
  let provider;
471
526
  try {
472
527
  provider = normalizeProviderId(providerId);
@@ -623,7 +678,7 @@ function docFinderOver(catalog, tree, fromProvider, summaries = true) {
623
678
  id: createDocId(provider, authored.type, authored.name),
624
679
  route: AUTHORING_REFERENCE_ROUTE,
625
680
  title: authored.displayName ?? authored.name,
626
- summary: authored.description ?? '',
681
+ summary: renderTokens(authored.description ?? ''),
627
682
  command: `astryx docs authoring ${authored.name}`,
628
683
  },
629
684
  kind: parsed.kind,
@@ -681,13 +736,16 @@ function docFinderOver(catalog, tree, fromProvider, summaries = true) {
681
736
  // The summary is the target doc's own text, so its links resolve
682
737
  // against the target's provider, never the linking doc's: a Core
683
738
  // component's against the CLI's docs, like its other fields.
684
- if (summaries && link.summary.includes('{@link')) {
739
+ // contributedDocLink returns the authored text; it renders once here.
740
+ if (summaries && link.summary.includes('{@')) {
685
741
  link.summary = await linkSummary(
686
742
  catalog,
687
743
  tree,
688
744
  provider === CORE_COMPONENT_PROVIDER ? CLI_PROVIDER_ID : provider,
689
745
  link.summary,
690
746
  );
747
+ } else {
748
+ link.summary = renderTokens(link.summary);
691
749
  }
692
750
  return {link: {target, ...link}, kind: parsed.kind, typed: null};
693
751
  }
@@ -1103,7 +1161,16 @@ export async function docsLinkProblems(
1103
1161
  }
1104
1162
  }
1105
1163
  for (const node of tree.nodes.values()) {
1106
- if (owner != null && node.provider !== owner) continue;
1164
+ // A package owns a guide it placed, and a guide it replaces or extends by
1165
+ // its route.
1166
+ if (
1167
+ owner != null &&
1168
+ node.provider !== owner &&
1169
+ node.guideOverlay?.replacement?.package !== owner &&
1170
+ !node.guideOverlay?.extensions.some(each => each.package === owner)
1171
+ ) {
1172
+ continue;
1173
+ }
1107
1174
  if (node.kind === 'generic' && node.ref?.topicFile) {
1108
1175
  try {
1109
1176
  note(node.route, await topicLinkProblems(catalog, guideEntry(node)));
@@ -1234,6 +1301,168 @@ export async function packageDocsProblems(integration, discovered) {
1234
1301
  return problems;
1235
1302
  }
1236
1303
 
1304
+ /**
1305
+ * The guide the docs tree places at a route, compared without case, or at the
1306
+ * route it moved to; null when the route holds no placed guide.
1307
+ * @param {DocsTree} tree
1308
+ * @param {string} route
1309
+ * @returns {TreeNode | null}
1310
+ */
1311
+ function placedGuideAt(tree, route) {
1312
+ const node =
1313
+ tree.get(route) ?? tree.getFolded(route) ?? movedRoute(route, tree);
1314
+ return node?.kind === 'generic' && node.ref?.topicFile ? node : null;
1315
+ }
1316
+
1317
+ /**
1318
+ * The routes of every guide the tree places below a namespace, nearest first,
1319
+ * in reading order.
1320
+ * @param {DocsTree} tree
1321
+ * @param {TreeNode} namespace
1322
+ * @returns {string[]}
1323
+ */
1324
+ function placedGuidesBelow(tree, namespace) {
1325
+ /** @type {string[]} */
1326
+ const routes = [];
1327
+ /** @type {TreeNode[]} */
1328
+ let level = [namespace];
1329
+ while (level.length > 0) {
1330
+ /** @type {TreeNode[]} */
1331
+ const next = [];
1332
+ for (const parent of level) {
1333
+ for (const slot of parent.slots) {
1334
+ for (const route of slot.children) {
1335
+ const child = tree.get(route);
1336
+ if (!child || child.parent !== parent.route) continue;
1337
+ if (child.kind === 'generic' && child.ref?.topicFile) {
1338
+ routes.push(child.route);
1339
+ }
1340
+ if (child.slots.length > 0) next.push(child);
1341
+ }
1342
+ }
1343
+ }
1344
+ level = next;
1345
+ }
1346
+ return routes;
1347
+ }
1348
+
1349
+ /**
1350
+ * What one doc that replaces or extends another does, as a package's own
1351
+ * check sees it.
1352
+ * @typedef {object} DocTarget
1353
+ * @property {string} topic the doc's own name
1354
+ * @property {'replaces' | 'extends'} relationship
1355
+ * @property {string} target the topic name or route it names
1356
+ * @property {'topic' | 'guide' | 'namespace' | null} kind what the target
1357
+ * is: a flat topic, a guide the docs tree places, a namespace (which neither
1358
+ * takes), or null when it names nothing
1359
+ * @property {string | null} guide for a guide, the route it is placed at now,
1360
+ * which an old route resolves to
1361
+ * @property {string[]} guidesBelow for a namespace, the routes of the guides
1362
+ * placed below it, any of which the doc could name instead
1363
+ * @property {string | null} owner the package whose topic or guide it is
1364
+ * @property {Array<{section: string, field: 'before' | 'after', key: string}>} unplaced
1365
+ * each section whose `before` or `after` names no section of the target, so
1366
+ * it is added at the end instead
1367
+ */
1368
+
1369
+ /**
1370
+ * Each doc in one integration's docs that replaces or extends a topic, or a
1371
+ * guide the docs tree places by its route, read against the CLI's docs and the
1372
+ * package's own: what it names and whether that exists, and each section an
1373
+ * extension places with `before` or `after` that finds no section there.
1374
+ * @param {any} integration
1375
+ * @param {{records: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicRecord[], namespaces: import('../../foundation/doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../../foundation/doc-compiler/tree.mjs').TreeDocInput[]}} discovered
1376
+ * @returns {Promise<DocTarget[]>}
1377
+ */
1378
+ export async function packageDocTargets(integration, discovered) {
1379
+ const catalog = packageCatalog(integration, discovered);
1380
+ const tree = await projectTree(catalog);
1381
+ /** @type {DocTarget[]} */
1382
+ const targets = [];
1383
+ for (const record of discovered.records) {
1384
+ const relationship = record.replaces != null ? 'replaces' : 'extends';
1385
+ const target =
1386
+ relationship === 'replaces' ? record.replaces : record.extendsTopic;
1387
+ if (target == null) continue;
1388
+ /** @type {DocTarget['kind']} */
1389
+ let kind = null;
1390
+ /** @type {string | null} */
1391
+ let owner = null;
1392
+ /** @type {string | null} */
1393
+ let basePath = null;
1394
+ /** @type {ReadonlyArray<{path: string}>} every extension of the target, in configured order */
1395
+ let extensions = [];
1396
+ /** @type {string[]} */
1397
+ let guidesBelow = [];
1398
+ /** @type {string | null} */
1399
+ let guide = null;
1400
+ if (isGuideRoute(target)) {
1401
+ const node = placedGuideAt(tree, target);
1402
+ if (node) {
1403
+ kind = 'guide';
1404
+ guide = node.route;
1405
+ owner = node.provider;
1406
+ basePath = node.guideOverlay?.replacement?.path ?? node.ref.topicFile;
1407
+ extensions = node.guideOverlay?.extensions ?? [];
1408
+ }
1409
+ } else {
1410
+ // A replacement already holds the topic's place in the catalog, and
1411
+ // names the package it took it from.
1412
+ const entry = catalog.resolve(target);
1413
+ if (entry?.path === record.path) {
1414
+ kind = 'topic';
1415
+ owner = entry.replacedPackage ?? null;
1416
+ } else if (entry) {
1417
+ kind = 'topic';
1418
+ owner = entry.package;
1419
+ basePath = entry.path;
1420
+ extensions = entry.extensions;
1421
+ }
1422
+ }
1423
+ if (kind == null) {
1424
+ // A namespace holds no sections to take over or merge onto; the guides
1425
+ // below it do.
1426
+ const node =
1427
+ tree.get(target) ?? tree.getFolded(target) ?? movedRoute(target, tree);
1428
+ if (node?.kind === 'namespace') {
1429
+ kind = 'namespace';
1430
+ owner = node.provider;
1431
+ guidesBelow = placedGuidesBelow(tree, node);
1432
+ }
1433
+ }
1434
+ /** @type {DocTarget['unplaced']} */
1435
+ let unplaced = [];
1436
+ if (relationship === 'extends' && basePath != null) {
1437
+ // Merge every extension in configured order, as a read does, so a key
1438
+ // an earlier extension adds counts as a section of the target.
1439
+ let doc = (await loadTopicFile(basePath, null)).doc;
1440
+ for (const extension of extensions) {
1441
+ if (doc == null) break;
1442
+ const file = (await loadTopicFile(extension.path, null)).doc;
1443
+ if (file == null) continue;
1444
+ const merged = mergeTopicReport(doc, file);
1445
+ if (extension.path === record.path) {
1446
+ unplaced = merged.unplaced;
1447
+ break;
1448
+ }
1449
+ doc = merged.doc;
1450
+ }
1451
+ }
1452
+ targets.push({
1453
+ topic: record.name,
1454
+ relationship,
1455
+ target,
1456
+ kind,
1457
+ owner,
1458
+ guide,
1459
+ guidesBelow,
1460
+ unplaced,
1461
+ });
1462
+ }
1463
+ return targets;
1464
+ }
1465
+
1237
1466
  /**
1238
1467
  * How a token reference finds its target: the topic it names in `catalog`,
1239
1468
  * lowered for the same language.
@@ -1335,20 +1564,41 @@ export async function compileTopic(catalog, entry, lang = null) {
1335
1564
  /**
1336
1565
  * A guide the docs tree places, as a topic entry the topic readers open by its
1337
1566
  * route. It is never a flat topic: `astryx docs <route>` is its only name.
1567
+ * What integrations do to it by its route applies: a replacement is read in
1568
+ * its place and names its own package, and each extension's sections merge
1569
+ * onto it, each naming the package that wrote it (INV28).
1338
1570
  * @param {import('../../foundation/doc-compiler/tree.mjs').TreeNode} node
1339
1571
  * @returns {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry}
1340
1572
  */
1341
1573
  export function guideEntry(node) {
1342
- return {
1574
+ const base = {
1343
1575
  name: node.route,
1344
1576
  route: node.route,
1345
1577
  package: node.provider,
1346
1578
  providerId: node.providerId,
1347
1579
  path: node.ref.topicFile,
1348
1580
  extensions: [],
1349
- tree: true,
1581
+ tree: /** @type {const} */ (true),
1350
1582
  parent: node.parent ?? undefined,
1351
1583
  };
1584
+ const overlay = node.guideOverlay;
1585
+ if (!overlay) return base;
1586
+ const replacement = overlay.replacement;
1587
+ return {
1588
+ ...base,
1589
+ ...(replacement
1590
+ ? {
1591
+ package: replacement.package,
1592
+ providerId: replacement.providerId ?? replacement.package,
1593
+ path: replacement.path,
1594
+ replaces: node.route,
1595
+ // The package whose guide it took over: an earlier replacement's,
1596
+ // when the guide was already replaced.
1597
+ replacedPackage: overlay.replacedPackage ?? node.provider,
1598
+ }
1599
+ : {}),
1600
+ extensions: [...overlay.extensions],
1601
+ };
1352
1602
  }
1353
1603
 
1354
1604
  /** @type {WeakMap<DocsTree, ReturnType<typeof cliDocIndex>>} */
@@ -52,6 +52,14 @@ export async function detail(topic, options = {}) {
52
52
  ),
53
53
  // A guide the docs tree places is read by its route, not its doc name.
54
54
  ...(entry.tree ? {name: entry.name} : {}),
55
+ // Whose topic or guide it took the place of, beside `replaces` (INV28).
56
+ // What it took the place of, as the list, the index and the listing
57
+ // name it: a guide's route, even when the doc named a route the guide
58
+ // moved from, and a topic replaced twice by the earlier replacement.
59
+ ...(entry.replaces != null ? {replaces: entry.replaces} : {}),
60
+ ...(entry.replaces != null && entry.replacedPackage != null
61
+ ? {replacedPackage: entry.replacedPackage}
62
+ : {}),
55
63
  links: await topicLinks(catalog, entry),
56
64
  },
57
65
  };
@@ -176,8 +176,9 @@ describe('the reported defect: docs tokens --dense (#2182)', () => {
176
176
  for (const options of [{}, {dense: true}, {zh: true}]) {
177
177
  const result = await docs('theme', null, options);
178
178
  const rendered = JSON.stringify(result.data.sections);
179
+ // The command, as `{@command …}` or bare `astryx …`: both print it.
179
180
  expect(rendered).toContain(
180
- 'astryx theme palette generate palette.config.json --out palette.generated.ts',
181
+ 'theme palette generate palette.config.json --out palette.generated.ts',
181
182
  );
182
183
  expect(rendered).toContain(
183
184
  "import {palette} from './palette.generated';",
@@ -32,9 +32,19 @@ export function docs(topic?: string, section?: string, options?: {
32
32
  detail?: "compact" | "full" | "brief" | undefined;
33
33
  cwd?: string | undefined;
34
34
  }): Promise<import("./docs.type.mjs").DocsListResponse | import("./docs.type.mjs").DocsIndexResponse | import("./docs.type.mjs").DocsDetailResponse | import("./docs.type.mjs").DocsDetailSectionResponse | import("./docs.type.mjs").DocsNodeResponse>;
35
- import { list } from './list/list.mjs';
36
- import { index } from './index/index.mjs';
37
- import { detail } from './detail/detail.mjs';
38
- import { section as sectionLeaf } from './detail/section/section.mjs';
39
- import { node as nodeLeaf } from './node/node.mjs';
40
- export { list, index, detail, sectionLeaf as section, nodeLeaf as node };
35
+ /** @type {typeof listRead} */
36
+ export const list: typeof listRead;
37
+ /** @type {typeof indexRead} */
38
+ export const index: typeof indexRead;
39
+ /** @type {typeof detailRead} */
40
+ export const detail: typeof detailRead;
41
+ /** @type {typeof sectionRead} */
42
+ declare const sectionLeaf: typeof sectionRead;
43
+ /** @type {typeof nodeRead} */
44
+ declare const nodeLeaf: typeof nodeRead;
45
+ import { list as listRead } from './list/list.mjs';
46
+ import { index as indexRead } from './index/index.mjs';
47
+ import { detail as detailRead } from './detail/detail.mjs';
48
+ import { section as sectionRead } from './detail/section/section.mjs';
49
+ import { node as nodeRead } from './node/node.mjs';
50
+ export { sectionLeaf as section, nodeLeaf as node };
@@ -107,7 +107,7 @@ export const doc = {
107
107
  {
108
108
  type: 'docs.list',
109
109
  description:
110
- "Every reference-doc topic in read order, as DocsListEntry[] ({topic, description, package, replaces?}), each readable with docs(topic). meta.namespaces lists the docs tree's top-level namespaces ({topic, description, package}), and meta.notLoaded each package whose docs did not load ({package, message}).",
110
+ "Every reference-doc topic in read order, as DocsListEntry[] ({topic, description, package, replaces?, replacedPackage?}), each readable with docs(topic). meta.namespaces lists the docs tree's top-level namespaces ({topic, description, package}), and meta.notLoaded each package whose docs did not load ({package, message}).",
111
111
  },
112
112
  {
113
113
  type: 'docs.detail',
package/api/docs/docs.mjs CHANGED
@@ -23,18 +23,50 @@
23
23
  * overlay loading, and resolution they share sit in _adapter.mjs.
24
24
  */
25
25
 
26
- import {list} from './list/list.mjs';
27
- import {index} from './index/index.mjs';
28
- import {detail} from './detail/detail.mjs';
26
+ import {list as listRead} from './list/list.mjs';
27
+ import {index as indexRead} from './index/index.mjs';
28
+ import {detail as detailRead} from './detail/detail.mjs';
29
29
  import {
30
30
  namespaceSection,
31
- section as sectionLeaf,
31
+ section as sectionRead,
32
32
  } from './detail/section/section.mjs';
33
- import {node as nodeLeaf, nodeView} from './node/node.mjs';
33
+ import {node as nodeRead, nodeView} from './node/node.mjs';
34
34
  import {resolveDocsArgument} from './_adapter.mjs';
35
35
  import {AstryxError} from '../error.mjs';
36
36
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
37
- import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
37
+ import {
38
+ docPackageManager,
39
+ formatCliCommand,
40
+ runWithDocPackageManager,
41
+ } from '../../foundation/env/package-manager.mjs';
42
+
43
+ /**
44
+ * Run a docs read with `{@pm}` steps rendered for the project in `cwd`, the
45
+ * folder the read is about, not the process's working directory. A host that
46
+ * already chose a package manager keeps its choice.
47
+ * @template T
48
+ * @param {string | undefined} cwd
49
+ * @param {() => T} fn
50
+ * @returns {T}
51
+ */
52
+ function inProject(cwd, fn) {
53
+ return runWithDocPackageManager(docPackageManager(cwd ?? process.cwd()), fn);
54
+ }
55
+
56
+ /** @type {typeof listRead} */
57
+ const list = (options = {}) => inProject(options?.cwd, () => listRead(options));
58
+ /** @type {typeof indexRead} */
59
+ const index = (topic, options = {}) =>
60
+ inProject(options?.cwd, () => indexRead(topic, options));
61
+ /** @type {typeof detailRead} */
62
+ const detail = (topic, options = {}) =>
63
+ inProject(options?.cwd, () => detailRead(topic, options));
64
+ /** @type {typeof sectionRead} */
65
+ const sectionLeaf = (topic, sectionName, options = {}) =>
66
+ inProject(options?.cwd, () => sectionRead(topic, sectionName, options));
67
+ /** @type {typeof nodeRead} */
68
+ const nodeLeaf = (route, options = {}) =>
69
+ inProject(options?.cwd, () => nodeRead(route, options));
38
70
 
39
71
  export {list, index, detail, sectionLeaf as section, nodeLeaf as node};
40
72
 
@@ -98,6 +130,23 @@ function depthRead(options) {
98
130
  * >}
99
131
  */
100
132
  export async function docs(topic, section, options = {}) {
133
+ return inProject(options.cwd, () => docsRead(topic, section, options));
134
+ }
135
+
136
+ /**
137
+ * The docs read itself, inside its project's package-manager scope.
138
+ * @param {string} [topic]
139
+ * @param {string} [section]
140
+ * @param {any} [options]
141
+ * @returns {Promise<
142
+ * import('./docs.type.mjs').DocsListResponse |
143
+ * import('./docs.type.mjs').DocsIndexResponse |
144
+ * import('./docs.type.mjs').DocsDetailResponse |
145
+ * import('./docs.type.mjs').DocsDetailSectionResponse |
146
+ * import('./docs.type.mjs').DocsNodeResponse
147
+ * >}
148
+ */
149
+ async function docsRead(topic, section, options = {}) {
101
150
  const read = depthRead(options);
102
151
  if (!topic) return list(options);
103
152
  const found = await resolveDocsArgument(topic, options);