@astryxdesign/cli 0.6.3-canary.e59d786 → 0.6.3-canary.e7723cd

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 (201) hide show
  1. package/README.md +19 -17
  2. package/api/component/_adapter.d.mts +6 -12
  3. package/api/component/_adapter.mjs +20 -10
  4. package/api/component/component.mjs +60 -12
  5. package/api/component/list/list.mjs +3 -2
  6. package/api/docs/_adapter.d.mts +209 -28
  7. package/api/docs/_adapter.mjs +667 -35
  8. package/api/docs/detail/detail.mjs +11 -3
  9. package/api/docs/detail/section/section.mjs +24 -13
  10. package/api/docs/detail/section/section.test.mjs +15 -6
  11. package/api/docs/docs.d.mts +5 -3
  12. package/api/docs/docs.doc.mjs +35 -15
  13. package/api/docs/docs.mjs +44 -8
  14. package/api/docs/docs.test.mjs +158 -4
  15. package/api/docs/docs.type.d.mts +165 -2
  16. package/api/docs/docs.type.mjs +101 -3
  17. package/api/docs/index/index.mjs +11 -3
  18. package/api/docs/index/index.test.mjs +1 -1
  19. package/api/docs/integration-tree.test.mjs +547 -0
  20. package/api/docs/integrationDocs.test.mjs +14 -14
  21. package/api/docs/list/list.mjs +25 -5
  22. package/api/docs/node/node.d.mts +43 -0
  23. package/api/docs/node/node.mjs +192 -0
  24. package/api/doctor/doctor.d.mts +30 -2
  25. package/api/doctor/doctor.mjs +147 -8
  26. package/api/doctor/doctor.test.mjs +95 -7
  27. package/api/index.d.mts +1 -1
  28. package/api/index.mjs +1 -0
  29. package/api/init/init.doc.mjs +1 -1
  30. package/api/integration/add-contribution.d.mts +2 -1
  31. package/api/integration/add-contribution.mjs +107 -5
  32. package/api/integration/add-contribution.test.mjs +137 -0
  33. package/api/integration/authoring-checks.mjs +125 -28
  34. package/api/integration/authoring-checks.test.mjs +171 -3
  35. package/api/integration/authoring-checks.type.mjs +6 -1
  36. package/api/integration/integration-authoring.type.d.mts +2 -0
  37. package/api/integration/integration-authoring.type.mjs +2 -0
  38. package/api/integration/integrationAdd.doc.mjs +6 -0
  39. package/api/integration/integrationAddDoc.doc.mjs +7 -1
  40. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  41. package/api/integration/integrationPackCheck.doc.mjs +1 -1
  42. package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
  43. package/api/integration/integrationTemplateConflicts.doc.mjs +3 -0
  44. package/api/integration/pack-check.mjs +34 -0
  45. package/api/integration/pack-check.test.mjs +121 -0
  46. package/api/integration/pack-check.type.d.mts +26 -2
  47. package/api/integration/pack-check.type.mjs +14 -1
  48. package/api/integration/template-conflict-compatibility.test.mjs +73 -0
  49. package/api/integration/validate-integration.test.mjs +3 -3
  50. package/api/integration/validateIntegration.doc.mjs +1 -1
  51. package/api/json/index.ts +2 -0
  52. package/api/layout/_adapter.mjs +20 -5
  53. package/api/search/search.d.mts +26 -1
  54. package/api/search/search.doc.mjs +4 -3
  55. package/api/search/search.mjs +308 -29
  56. package/api/search/search.test.mjs +91 -2
  57. package/api/search/search.type.d.mts +13 -1
  58. package/api/search/search.type.mjs +4 -1
  59. package/api/template/list/list.mjs +1 -0
  60. package/api/template/template-integration.test.mjs +1022 -3
  61. package/api/template/template.doc.mjs +27 -7
  62. package/api/template/template.mjs +45 -8
  63. package/api/template/template.type.d.mts +6 -8
  64. package/api/template/template.type.mjs +3 -2
  65. package/api/theme/template/template.test.mjs +5 -0
  66. package/api/theme/themeTemplate.doc.mjs +1 -1
  67. package/assets/codemods/transforms/next/__tests__/migrate-native-picker-to-presentation.test.mjs +63 -0
  68. package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +4 -0
  69. package/assets/codemods/transforms/next/index.mjs +8 -0
  70. package/assets/codemods/transforms/next/migrate-native-picker-to-presentation.mjs +148 -0
  71. package/assets/docs/getting-started.doc.mjs +2 -2
  72. package/assets/docs/principles.doc.mjs +6 -6
  73. package/assets/docs/styling-libraries.doc.mjs +2 -2
  74. package/assets/docs/styling.doc.mjs +4 -4
  75. package/assets/docs/theme.doc.mjs +3 -3
  76. package/assets/docs/tokens.doc.mjs +1 -1
  77. package/assets/docs/tree/api.doc.mjs +30 -0
  78. package/assets/docs/tree/cli.doc.mjs +23 -0
  79. package/assets/docs/tree/commands.doc.mjs +25 -0
  80. package/assets/docs/{cli-integrations.doc.mjs → tree/integrations.doc.mjs} +37 -9
  81. package/assets/docs/tree/integrations.test.mjs +62 -0
  82. package/assets/docs/tree/writing-docs.doc.mjs +286 -0
  83. package/assets/templates/blocks/components/DateInput/DateInputDateRange.tsx +1 -1
  84. package/assets/templates/blocks/components/TimeInput/TimeInputConstrained.tsx +1 -0
  85. package/authoring/debug/parse.d.mts +3 -3
  86. package/authoring/doctypes/_schema.d.mts +71 -141
  87. package/authoring/doctypes/_schema.mjs +29 -2
  88. package/authoring/doctypes/base/graph-fields.doc.mjs +7 -5
  89. package/authoring/doctypes/base/type.ts +6 -5
  90. package/authoring/doctypes/command/command.doc.mjs +1 -1
  91. package/authoring/doctypes/command/type.ts +2 -2
  92. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  93. package/authoring/doctypes/enum/type.ts +1 -1
  94. package/authoring/doctypes/function/function.doc.mjs +3 -2
  95. package/authoring/doctypes/function/type.ts +3 -2
  96. package/authoring/doctypes/load-contract.test.mjs +1 -1
  97. package/authoring/doctypes/namespace/namespace.doc.mjs +6 -10
  98. package/authoring/doctypes/namespace/parse.test.mjs +23 -25
  99. package/authoring/doctypes/namespace/type.ts +5 -2
  100. package/authoring/doctypes/parse.mjs +3 -2
  101. package/authoring/doctypes/reference/reference.doc.mjs +6 -4
  102. package/authoring/doctypes/reference/type.ts +10 -8
  103. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  104. package/authoring/doctypes/schema/type.ts +1 -1
  105. package/authoring/doctypes/template/parse.d.mts +2 -0
  106. package/authoring/doctypes/template/parse.mjs +4 -0
  107. package/authoring/doctypes/template/parse.test.mjs +18 -0
  108. package/authoring/doctypes/template/template.doc.mjs +6 -0
  109. package/authoring/doctypes/template/type.ts +8 -0
  110. package/authoring/identity/identity.doc.mjs +2 -2
  111. package/authoring/index.d.ts +1 -0
  112. package/authoring/integration/type.ts +1 -1
  113. package/clients/cli/commands/build-theme.adaptations.test.mjs +100 -1
  114. package/clients/cli/commands/build-theme.mjs +11 -45
  115. package/clients/cli/commands/build.mjs +5 -2
  116. package/clients/cli/commands/component/index.mjs +1 -1
  117. package/clients/cli/commands/component-ownership.test.mjs +3 -3
  118. package/clients/cli/commands/discover.broken-integration.test.mjs +7 -8
  119. package/clients/cli/commands/discover.mjs +1 -1
  120. package/clients/cli/commands/docs.doc.mjs +20 -8
  121. package/clients/cli/commands/docs.mjs +182 -68
  122. package/clients/cli/commands/docs.test.mjs +120 -16
  123. package/clients/cli/commands/doctor-integration-docs.doc.mjs +2 -2
  124. package/clients/cli/commands/doctor-integration-templates.doc.mjs +14 -7
  125. package/clients/cli/commands/doctor-integration.test.mjs +75 -1
  126. package/clients/cli/commands/doctor.mjs +53 -16
  127. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  128. package/clients/cli/commands/integration.mjs +1 -0
  129. package/clients/cli/commands/search.mjs +11 -2
  130. package/clients/cli/commands/setup-nudge.test.mjs +6 -0
  131. package/clients/cli/commands/template.doc.mjs +23 -6
  132. package/clients/cli/commands/template.mjs +4 -91
  133. package/clients/cli/commands/text-json-parity.test.mjs +719 -0
  134. package/clients/cli/commands/theme-targets.behavior.test.mjs +4 -3
  135. package/clients/cli/commands/upgrade.mjs +26 -7
  136. package/clients/cli/formatters/index.mjs +2 -0
  137. package/clients/cli/formatters/index.test.mjs +6 -0
  138. package/clients/cli/index.mjs +8 -0
  139. package/clients/cli/lib/manifest.mjs +9 -2
  140. package/foundation/agent-docs/agent-docs.mjs +1 -0
  141. package/foundation/agent-docs/agent-docs.test.mjs +10 -1
  142. package/foundation/config/project.d.mts +12 -11
  143. package/foundation/config/project.mjs +73 -59
  144. package/foundation/config/project.test.mjs +141 -5
  145. package/foundation/discovery/authoring-self-docs.test.mjs +20 -9
  146. package/foundation/discovery/cli-self-docs.d.mts +40 -34
  147. package/foundation/discovery/cli-self-docs.mjs +91 -115
  148. package/foundation/discovery/cli-self-docs.test.mjs +104 -166
  149. package/foundation/discovery/component-discovery.d.mts +38 -0
  150. package/foundation/discovery/component-discovery.mjs +48 -0
  151. package/foundation/discovery/docs-discovery.d.mts +105 -8
  152. package/foundation/discovery/docs-discovery.mjs +183 -18
  153. package/foundation/discovery/docs-discovery.test.mjs +63 -27
  154. package/foundation/discovery/docs-output-budget.d.mts +2 -2
  155. package/foundation/discovery/docs-output-budget.mjs +1 -1
  156. package/foundation/discovery/docs-section-key.d.mts +28 -10
  157. package/foundation/discovery/docs-section-key.mjs +134 -33
  158. package/foundation/discovery/docs-section-key.test.mjs +41 -19
  159. package/foundation/discovery/template-adapter.d.mts +92 -6
  160. package/foundation/discovery/template-adapter.mjs +453 -17
  161. package/foundation/discovery/template-adapter.test.mjs +42 -0
  162. package/foundation/discovery/template-conflict-release.d.mts +13 -0
  163. package/foundation/discovery/template-conflict-release.mjs +40 -0
  164. package/foundation/discovery/template-conflict-release.test.mjs +40 -0
  165. package/foundation/doc-compiler/bundle.mjs +61 -1
  166. package/foundation/doc-compiler/bundle.test.mjs +21 -10
  167. package/foundation/doc-compiler/compile.d.mts +113 -132
  168. package/foundation/doc-compiler/compile.mjs +57 -10
  169. package/foundation/doc-compiler/diagnostics.mjs +28 -0
  170. package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
  171. package/foundation/doc-compiler/inputs.d.mts +2 -2
  172. package/foundation/doc-compiler/inputs.mjs +6 -1
  173. package/foundation/doc-compiler/ir.mjs +7 -0
  174. package/foundation/doc-compiler/lenses.d.mts +3 -2
  175. package/foundation/doc-compiler/lenses.mjs +2 -1
  176. package/foundation/doc-compiler/links.d.mts +135 -0
  177. package/foundation/doc-compiler/links.mjs +253 -0
  178. package/foundation/doc-compiler/links.test.mjs +139 -0
  179. package/foundation/doc-compiler/lower-doc.test.mjs +5 -2
  180. package/foundation/doc-compiler/read.d.mts +3 -2
  181. package/foundation/doc-compiler/read.mjs +6 -1
  182. package/foundation/doc-compiler/tree.d.mts +288 -0
  183. package/foundation/doc-compiler/tree.mjs +876 -0
  184. package/foundation/doc-compiler/tree.test.mjs +598 -0
  185. package/foundation/integrations/autolink.test.mjs +1 -1
  186. package/foundation/integrations/cli-requirement.d.mts +45 -0
  187. package/foundation/integrations/cli-requirement.mjs +154 -0
  188. package/foundation/integrations/cli-requirement.test.mjs +109 -0
  189. package/foundation/integrations/contribution-inventory.d.mts +2 -1
  190. package/foundation/integrations/contribution-inventory.mjs +10 -4
  191. package/foundation/integrations/contribution-inventory.test.mjs +19 -0
  192. package/foundation/integrations/integration-warnings.d.mts +9 -2
  193. package/foundation/integrations/integration-warnings.mjs +51 -26
  194. package/foundation/integrations/integration-warnings.test.mjs +74 -1
  195. package/foundation/integrations/validate-contributions.mjs +25 -27
  196. package/foundation/response/response-types.doc.d.mts +5 -1
  197. package/foundation/response/response-types.doc.mjs +18 -9
  198. package/foundation/xle/expand.mjs +1 -1
  199. package/foundation/xle/xle.test.mjs +13 -0
  200. package/package.json +9 -9
  201. package/assets/docs/cli.doc.mjs +0 -15
@@ -8,14 +8,14 @@
8
8
  * English `description` is read from its file; a contributed topic already
9
9
  * carries the one discovery read. The listing never applies --dense/--zh
10
10
  * overlays.
11
- * @output { type: 'docs.list', data: DocsListEntry[] } — one entry per topic in
12
- * read order, each naming the package that owns it, matching
13
- * `astryx --json docs`.
11
+ * @output { type: 'docs.list', data: DocsListEntry[] } — one entry per topic
12
+ * in read order, then one per top-level docs-tree namespace, each naming the
13
+ * package that owns it, matching `astryx --json docs`.
14
14
  * @position Leaf under api/docs. Sibling of detail; both share _adapter.mjs.
15
15
  */
16
16
 
17
17
  import {loadTopicFile} from '../../../foundation/doc-compiler/read.mjs';
18
- import {loadDocsCatalog} from '../_adapter.mjs';
18
+ import {holdsOwnName, loadDocsCatalog, projectTree} from '../_adapter.mjs';
19
19
 
20
20
  /**
21
21
  * @param {object} [options]
@@ -24,9 +24,13 @@ import {loadDocsCatalog} from '../_adapter.mjs';
24
24
  */
25
25
  export async function list({cwd} = {}) {
26
26
  const catalog = await loadDocsCatalog(cwd);
27
+ const tree = await projectTree(catalog);
27
28
  /** @type {Array<import('../docs.type.mjs').DocsListEntry>} */
28
29
  const entries = [];
29
30
  for (const entry of catalog.entries()) {
31
+ // A topic whose name opens another doc is not listed (spec:AST-046
32
+ // FR11); `astryx doctor` names the clash.
33
+ if (!holdsOwnName(tree, catalog, entry)) continue;
30
34
  let description = entry.description ?? '';
31
35
  if (entry.description == null) {
32
36
  const file = await loadTopicFile(entry.path, null);
@@ -41,5 +45,21 @@ export async function list({cwd} = {}) {
41
45
  if (entry.replaces != null) listed.replaces = entry.replaces;
42
46
  entries.push(listed);
43
47
  }
44
- return {type: 'docs.list', data: entries};
48
+ // The docs tree's top-level namespaces, the CLI's and each integration's,
49
+ // each the way into a whole branch (spec:AST-046 FR7). They go in `meta`,
50
+ // so `data` stays the topic list 0.6 returned: every entry reads as a topic.
51
+ const namespaces = tree.roots().map(root => ({
52
+ topic: root.route,
53
+ description: root.summary,
54
+ package: root.provider,
55
+ }));
56
+ /** @type {NonNullable<import('../docs.type.mjs').DocsListResponse['meta']>} */
57
+ const meta = {};
58
+ if (namespaces.length > 0) meta.namespaces = namespaces;
59
+ // A package whose docs did not load is named, so its author knows why its
60
+ // topics are missing.
61
+ if (catalog.issues.length > 0) meta.notLoaded = [...catalog.issues];
62
+ return Object.keys(meta).length === 0
63
+ ? {type: 'docs.list', data: entries}
64
+ : {type: 'docs.list', data: entries, meta};
45
65
  }
@@ -0,0 +1,43 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @typedef {import('../../../foundation/doc-compiler/tree.mjs').DocsTree} DocsTree
6
+ * @typedef {import('../../../foundation/doc-compiler/tree.mjs').TreeNode} TreeNode
7
+ */
8
+ /**
9
+ * The docs.node view of one tree node.
10
+ * @param {import('../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} catalog
11
+ * @param {DocsTree} tree
12
+ * @param {TreeNode} node
13
+ * @returns {Promise<import('../docs.type.mjs').DocsNode>}
14
+ */
15
+ export function nodeView(catalog: import("../../../foundation/discovery/docs-discovery.mjs").DocsCatalog, tree: DocsTree, node: TreeNode): Promise<import("../docs.type.mjs").DocsNode>;
16
+ /**
17
+ * The typed edges a doc declares (spec:AST-047 FR5), resolved to routes: a
18
+ * function doc's `command` and `related`, and a command doc's `fn` and
19
+ * `related`. A bare name resolves among the kinds its field allows; a name
20
+ * that matches docs of more than one allowed kind is an error, never a silent
21
+ * pick. A `command` resolves to the command doc its leading words name, so
22
+ * `integration add theme` (the `integration add` command with its kind
23
+ * argument) opens `integration add`. Every name that resolves to no doc, or to
24
+ * more than one, is returned in `unresolved`; the graph walk test fails on it,
25
+ * so no edge a doc declares can go stale.
26
+ * @param {DocsTree} tree
27
+ * @param {TreeNode} node
28
+ * @returns {{routes: string[], unresolved: string[]}}
29
+ */
30
+ export function typedEdges(tree: DocsTree, node: TreeNode): {
31
+ routes: string[];
32
+ unresolved: string[];
33
+ };
34
+ /**
35
+ * @param {string} route
36
+ * @param {{cwd?: string}} [options]
37
+ * @returns {Promise<import('../docs.type.mjs').DocsNodeResponse>}
38
+ */
39
+ export function node(route: string, options?: {
40
+ cwd?: string;
41
+ }): Promise<import("../docs.type.mjs").DocsNodeResponse>;
42
+ export type DocsTree = import("../../../foundation/doc-compiler/tree.mjs").DocsTree;
43
+ export type TreeNode = import("../../../foundation/doc-compiler/tree.mjs").TreeNode;
@@ -0,0 +1,192 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file docs.node leaf — one namespace or typed doc in the docs tree.
5
+ *
6
+ * @input A route the docs tree resolves: a namespace such as `cli/api`, or a
7
+ * typed doc such as `cli/api/functions/search`, plus {cwd}.
8
+ * @output { type: 'docs.node', data: DocsNode } — the node's identity, title
9
+ * and summary, the namespaces above it, and either its slots with their
10
+ * children (a namespace) or its content (a typed doc). A namespace never
11
+ * lists its grandchildren, so a reader goes down one level at a time.
12
+ * Matches `astryx --json docs <route>`.
13
+ * @position Leaf under api/docs, beside the topic leaves. A guide the tree
14
+ * places is a topic: the detail leaf reads it by its route.
15
+ */
16
+
17
+ import {
18
+ nodeContent,
19
+ placeLinks,
20
+ resolveDocsArgument,
21
+ unknownTopicError,
22
+ } from '../_adapter.mjs';
23
+
24
+ /**
25
+ * @typedef {import('../../../foundation/doc-compiler/tree.mjs').DocsTree} DocsTree
26
+ * @typedef {import('../../../foundation/doc-compiler/tree.mjs').TreeNode} TreeNode
27
+ */
28
+
29
+ /**
30
+ * The docs.node view of one tree node.
31
+ * @param {import('../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} catalog
32
+ * @param {DocsTree} tree
33
+ * @param {TreeNode} node
34
+ * @returns {Promise<import('../docs.type.mjs').DocsNode>}
35
+ */
36
+ export async function nodeView(catalog, tree, node) {
37
+ const {content} = await nodeContent(catalog, tree, node);
38
+ return {
39
+ id: node.id,
40
+ route: node.route,
41
+ kind: node.kind,
42
+ package: node.provider,
43
+ title: node.title,
44
+ summary: node.summary,
45
+ breadcrumb: tree
46
+ .ancestors(node)
47
+ .map(ancestor => ({route: ancestor.route, title: ancestor.title})),
48
+ slots: node.slots
49
+ .filter(slot => slot.children.length > 0)
50
+ .map(slot => ({
51
+ name: slot.name,
52
+ title: slot.title,
53
+ children: slot.children.map(route => {
54
+ const child = /** @type {TreeNode} */ (tree.get(route));
55
+ return {
56
+ route: child.route,
57
+ name: child.route.slice(child.route.lastIndexOf('/') + 1),
58
+ kind: child.kind,
59
+ title: child.title,
60
+ summary: child.summary,
61
+ };
62
+ }),
63
+ })),
64
+ content,
65
+ links: nodeLinks(tree, node),
66
+ };
67
+ }
68
+
69
+ /**
70
+ * The moves a node offers (spec:AST-047): up to the level it sits in (the
71
+ * topic list, for a top-level namespace), and across to the nodes before and
72
+ * after it in its parent's slot.
73
+ * @param {DocsTree} tree
74
+ * @param {TreeNode} node
75
+ * @returns {import('../docs.type.mjs').DocsLinks}
76
+ */
77
+ function nodeLinks(tree, node) {
78
+ const links = placeLinks(tree, node);
79
+ const related = typedEdges(tree, node).routes;
80
+ if (related.length > 0) {
81
+ links.related = related.map(
82
+ route =>
83
+ /** @type {import('../docs.type.mjs').DocsCommand} */ (
84
+ `astryx docs ${route}`
85
+ ),
86
+ );
87
+ }
88
+ return links;
89
+ }
90
+
91
+ /** @type {WeakMap<DocsTree, Map<string, string>>} */
92
+ const routeIndexes = new WeakMap();
93
+
94
+ /**
95
+ * The route of each node, by its kind and name.
96
+ * @param {DocsTree} tree
97
+ * @returns {Map<string, string>}
98
+ */
99
+ function routeIndex(tree) {
100
+ let routes = routeIndexes.get(tree);
101
+ if (!routes) {
102
+ routes = new Map();
103
+ for (const each of tree.nodes.values()) {
104
+ routes.set(`${each.kind}\u0000${each.name}`, each.route);
105
+ }
106
+ routeIndexes.set(tree, routes);
107
+ }
108
+ return routes;
109
+ }
110
+
111
+ /**
112
+ * The kinds of doc each typed field may name. A bare name in one of these
113
+ * fields names a doc of the same provider and one of these kinds, so it is a
114
+ * doc identity (spec:AST-047 FR9).
115
+ */
116
+ const EDGE_KINDS = {
117
+ function: {command: ['command'], related: ['function']},
118
+ command: {fn: ['function'], related: ['command']},
119
+ };
120
+
121
+ /**
122
+ * The typed edges a doc declares (spec:AST-047 FR5), resolved to routes: a
123
+ * function doc's `command` and `related`, and a command doc's `fn` and
124
+ * `related`. A bare name resolves among the kinds its field allows; a name
125
+ * that matches docs of more than one allowed kind is an error, never a silent
126
+ * pick. A `command` resolves to the command doc its leading words name, so
127
+ * `integration add theme` (the `integration add` command with its kind
128
+ * argument) opens `integration add`. Every name that resolves to no doc, or to
129
+ * more than one, is returned in `unresolved`; the graph walk test fails on it,
130
+ * so no edge a doc declares can go stale.
131
+ * @param {DocsTree} tree
132
+ * @param {TreeNode} node
133
+ * @returns {{routes: string[], unresolved: string[]}}
134
+ */
135
+ export function typedEdges(tree, node) {
136
+ const doc = /** @type {any} */ (node.ref)?.selfDoc;
137
+ /** @type {string[]} */
138
+ const routes = [];
139
+ /** @type {string[]} */
140
+ const unresolved = [];
141
+ const fields = /** @type {Record<string, string[]> | undefined} */ (
142
+ /** @type {any} */ (EDGE_KINDS)[node.kind]
143
+ );
144
+ if (!doc || !fields) return {routes, unresolved};
145
+ const index = routeIndex(tree);
146
+ /** @param {string[]} kinds @param {string} name */
147
+ const among = (kinds, name) =>
148
+ kinds
149
+ .map(kind => index.get(`${kind}\u0000${name}`))
150
+ .filter(route => typeof route === 'string');
151
+ for (const [field, kinds] of Object.entries(fields)) {
152
+ const value = doc[field];
153
+ const names = Array.isArray(value) ? value : value == null ? [] : [value];
154
+ for (const name of names) {
155
+ if (typeof name !== 'string' || name.trim() === '') continue;
156
+ let found = among(kinds, name);
157
+ if (found.length === 0 && field === 'command') {
158
+ const words = name.trim().split(/\s+/);
159
+ for (let n = words.length - 1; n > 0 && found.length === 0; n--) {
160
+ found = among(kinds, words.slice(0, n).join(' '));
161
+ }
162
+ }
163
+ if (found.length === 1) routes.push(/** @type {string} */ (found[0]));
164
+ else if (found.length === 0) {
165
+ unresolved.push(`${field} "${name}" names no ${kinds.join(' or ')} doc`);
166
+ } else {
167
+ unresolved.push(
168
+ `${field} "${name}" names more than one doc (${found.join(', ')})`,
169
+ );
170
+ }
171
+ }
172
+ }
173
+ return {
174
+ routes: [...new Set(routes)].filter(route => route !== node.route),
175
+ unresolved,
176
+ };
177
+ }
178
+
179
+ /**
180
+ * @param {string} route
181
+ * @param {{cwd?: string}} [options]
182
+ * @returns {Promise<import('../docs.type.mjs').DocsNodeResponse>}
183
+ */
184
+ export async function node(route, options = {}) {
185
+ const found = await resolveDocsArgument(route, options);
186
+ if (found.kind !== 'node')
187
+ throw await unknownTopicError(route, found.catalog);
188
+ return {
189
+ type: 'docs.node',
190
+ data: await nodeView(found.catalog, found.tree, found.node),
191
+ };
192
+ }
@@ -68,7 +68,13 @@ export function checkAgentDocs(ctx: DoctorContext): DoctorCheck;
68
68
  */
69
69
  export function checkPeerDeps(ctx: DoctorContext): DoctorCheck;
70
70
  /**
71
- * Check 9 — report the detected package manager, and say so when the project's
71
+ * Summarize the combined integration graph, including cross-package warnings.
72
+ * @param {DoctorContext} ctx
73
+ * @returns {DoctorCheck}
74
+ */
75
+ export function checkIntegrationIssues(ctx: DoctorContext): DoctorCheck;
76
+ /**
77
+ * Check 10 — report the detected package manager, and say so when the project's
72
78
  * own declaration disagrees with what is on disk.
73
79
  *
74
80
  * Two states are worth surfacing rather than guessing past, because in both the
@@ -116,7 +122,7 @@ export function checkAuthoringDocs(_ctx?: DoctorContext, options?: {
116
122
  }): Promise<DoctorCheck>;
117
123
  /**
118
124
  * Every command, API function, schema, and enum doc the CLI ships declares a
119
- * namespace, and the topic that namespace names reads it: `astryx docs cli`
125
+ * namespace, and something reads it: the docs tree under `astryx docs cli`
120
126
  * for `cli/commands` and `cli/api`, `astryx docs authoring` for `authoring`.
121
127
  * @param {DoctorContext | Partial<DoctorContext>} _ctx
122
128
  * @param {{root?: string, sources?: string[], authoringSources?: string[]}} [options]
@@ -128,6 +134,19 @@ export function checkCliDocs(_ctx: DoctorContext | Partial<DoctorContext>, optio
128
134
  sources?: string[];
129
135
  authoringSources?: string[];
130
136
  }): Promise<DoctorCheck>;
137
+ /**
138
+ * The docs tree builds with no error, and every CLI typed doc in a `cli/...`
139
+ * group has a route in it (spec:AST-046): each placement names a namespace of
140
+ * its own package and a slot that accepts it, exactly one namespace adopts
141
+ * each doc, and each route belongs to one doc.
142
+ * @param {DoctorContext | Partial<DoctorContext>} _ctx
143
+ * @param {{tree?: import('../../foundation/doc-compiler/tree.mjs').DocsTree}} [options]
144
+ * test seam: a tree to check instead of the CLI's own
145
+ * @returns {Promise<DoctorCheck>}
146
+ */
147
+ export function checkDocsTree(_ctx: DoctorContext | Partial<DoctorContext>, options?: {
148
+ tree?: import("../../foundation/doc-compiler/tree.mjs").DocsTree;
149
+ }): Promise<DoctorCheck>;
131
150
  /**
132
151
  * Every topic reads progressively, in every language it ships: it loads, its
133
152
  * section index and each of its sections fit in one read, and no contributed
@@ -238,6 +257,15 @@ export type DoctorContext = {
238
257
  * could not be built, when it could not.
239
258
  */
240
259
  docsCatalogError?: string | null | undefined;
260
+ /**
261
+ * Combined project-level integration issues, including cross-package template replacement warnings.
262
+ */
263
+ integrationIssues?: {
264
+ package: string;
265
+ code: string;
266
+ severity: "warning" | "error";
267
+ message: string;
268
+ }[] | null | undefined;
241
269
  /**
242
270
  * - Error thrown while resolving the config
243
271
  * path (e.g. multiple config files present), surfaced by checkConfig as a FAIL.
@@ -34,7 +34,16 @@ import {
34
34
  docsIndexBytes,
35
35
  oversizedDocSections,
36
36
  } from '../../foundation/discovery/docs-output-budget.mjs';
37
- import {compileTopic, lowerTopic, overlayLanguages} from '../docs/_adapter.mjs';
37
+ import {
38
+ builtinCatalog,
39
+ compileTopic,
40
+ docsLinkProblems,
41
+ guideEntry,
42
+ lowerTopic,
43
+ overlayLanguages,
44
+ projectTree,
45
+ } from '../docs/_adapter.mjs';
46
+ import {typedEdges} from '../docs/node/node.mjs';
38
47
  import {detailView, indexView} from '../../foundation/doc-compiler/lenses.mjs';
39
48
  import {semverCompare, isValidSemver, satisfiesRange} from '../../foundation/env/semver.mjs';
40
49
 
@@ -66,6 +75,8 @@ import {semverCompare, isValidSemver, satisfiesRange} from '../../foundation/env
66
75
  * `invalid_doc` issues from the project's contributed docs.
67
76
  * @property {string|null} [docsCatalogError] - Why the project's docs catalog
68
77
  * could not be built, when it could not.
78
+ * @property {Array<{package: string, code: string, severity: 'warning'|'error', message: string}>|null} [integrationIssues]
79
+ * Combined project-level integration issues, including cross-package template replacement warnings.
69
80
  * @property {Error|null} [configError] - Error thrown while resolving the config
70
81
  * path (e.g. multiple config files present), surfaced by checkConfig as a FAIL.
71
82
  */
@@ -585,7 +596,45 @@ export function checkPeerDeps(ctx) {
585
596
  }
586
597
 
587
598
  /**
588
- * Check 9 — report the detected package manager, and say so when the project's
599
+ * Summarize the combined integration graph, including cross-package warnings.
600
+ * @param {DoctorContext} ctx
601
+ * @returns {DoctorCheck}
602
+ */
603
+ export function checkIntegrationIssues(ctx) {
604
+ const issues = ctx.integrationIssues;
605
+ if (issues == null) {
606
+ return {
607
+ id: 'integration-issues',
608
+ label: 'Integration contributions',
609
+ status: 'info',
610
+ message: 'Skipped — the project integration graph could not be loaded.',
611
+ };
612
+ }
613
+ if (issues.length === 0) {
614
+ return {
615
+ id: 'integration-issues',
616
+ label: 'Integration contributions',
617
+ status: 'pass',
618
+ message: 'Integration contributions and cross-package relationships are valid.',
619
+ };
620
+ }
621
+ const errors = issues.filter(issue => issue.severity === 'error').length;
622
+ const details = issues
623
+ .map(issue => `${issue.package}: ${issue.message}`)
624
+ .join(' | ');
625
+ // This check is new, so it warns: a project that passed before keeps
626
+ // passing (spec:AST-046 FR8). `astryx doctor integration` fails on errors.
627
+ return {
628
+ id: 'integration-issues',
629
+ label: 'Integration contributions',
630
+ status: 'warn',
631
+ message: `${issues.length} integration issue(s)${errors > 0 ? `, ${errors} of them errors` : ''}: ${details}`,
632
+ fix: 'Run `astryx doctor integration` for package-specific diagnostics and resolve cross-package precedence in astryx.config.',
633
+ };
634
+ }
635
+
636
+ /**
637
+ * Check 10 — report the detected package manager, and say so when the project's
589
638
  * own declaration disagrees with what is on disk.
590
639
  *
591
640
  * Two states are worth surfacing rather than guessing past, because in both the
@@ -882,9 +931,13 @@ export async function checkAuthoringDocs(_ctx, options = {}) {
882
931
  const CLI_DOCS_FIX =
883
932
  "Set `namespace` on each CLI doc to the one that reads it: cli/commands for a command, cli/api for an API function or the output schema, error codes, and response types, and authoring for a file an author writes (and list it in AUTHORING_SELF_DOCS).";
884
933
 
934
+ /** How the docs-tree check's problems are fixed. */
935
+ const DOCS_TREE_FIX =
936
+ 'Fix each placement, adoption rule, or link the message names: a placement names a namespace of its own package, one of its slots, and a slot that accepts its kind; exactly one namespace adopts each doc; every route belongs to one doc; every link names a doc that exists, as `[<provider>:]<kind>:<name>`.';
937
+
885
938
  /**
886
939
  * Every command, API function, schema, and enum doc the CLI ships declares a
887
- * namespace, and the topic that namespace names reads it: `astryx docs cli`
940
+ * namespace, and something reads it: the docs tree under `astryx docs cli`
888
941
  * for `cli/commands` and `cli/api`, `astryx docs authoring` for `authoring`.
889
942
  * @param {DoctorContext | Partial<DoctorContext>} _ctx
890
943
  * @param {{root?: string, sources?: string[], authoringSources?: string[]}} [options]
@@ -911,10 +964,9 @@ export async function checkCliDocs(_ctx, options = {}) {
911
964
  ...audit.failed.map(
912
965
  ({source, error}) => `${source} failed to load: ${error}`,
913
966
  ),
914
- ...audit.keyProblems.map(problem => `\`astryx docs cli\`: ${problem}`),
915
967
  ...audit.oversized.map(
916
968
  ({key, bytes}) =>
917
- `cli section "${key}" is ${kilobytes(bytes)}, over the ${kilobytes(DOC_OUTPUT_BUDGET_BYTES)} one read may return`,
969
+ `CLI doc "${key}" is ${kilobytes(bytes)}, over the ${kilobytes(DOC_OUTPUT_BUDGET_BYTES)} one read may return`,
918
970
  ),
919
971
  ];
920
972
  if (problems.length > 0) {
@@ -930,7 +982,7 @@ export async function checkCliDocs(_ctx, options = {}) {
930
982
  id,
931
983
  label,
932
984
  status: 'pass',
933
- message: `All ${audit.docs} CLI docs are readable: ${audit.sections} in \`astryx docs cli\` and ${audit.authoring} in \`astryx docs authoring\`.`,
985
+ message: `All ${audit.docs} CLI docs are readable: ${audit.tree} in the \`astryx docs cli\` tree and ${audit.authoring} in \`astryx docs authoring\`.`,
934
986
  };
935
987
  } catch (err) {
936
988
  return {
@@ -943,6 +995,81 @@ export async function checkCliDocs(_ctx, options = {}) {
943
995
  }
944
996
  }
945
997
 
998
+ /**
999
+ * The docs tree builds with no error, and every CLI typed doc in a `cli/...`
1000
+ * group has a route in it (spec:AST-046): each placement names a namespace of
1001
+ * its own package and a slot that accepts it, exactly one namespace adopts
1002
+ * each doc, and each route belongs to one doc.
1003
+ * @param {DoctorContext | Partial<DoctorContext>} _ctx
1004
+ * @param {{tree?: import('../../foundation/doc-compiler/tree.mjs').DocsTree}} [options]
1005
+ * test seam: a tree to check instead of the CLI's own
1006
+ * @returns {Promise<DoctorCheck>}
1007
+ */
1008
+ export async function checkDocsTree(_ctx, options = {}) {
1009
+ const id = 'docs-tree';
1010
+ const label = 'Docs tree';
1011
+ try {
1012
+ const catalog =
1013
+ /** @type {any} */ (_ctx)?.docsCatalog ?? builtinCatalog();
1014
+ const tree = options.tree ?? (await projectTree(catalog, {fresh: true}));
1015
+ const problems = tree.diagnostics
1016
+ .filter(d => d.severity === 'error')
1017
+ .map(d => `${d.source ?? d.provider ?? 'docs tree'}: ${d.message}`);
1018
+ if (options.tree === undefined) {
1019
+ const {loadCliSelfDocs, CLI_DOC_NAMESPACES} =
1020
+ await import('../../foundation/discovery/cli-self-docs.mjs');
1021
+ const placed = new Set(
1022
+ [...tree.nodes.values()].map(
1023
+ node => `${node.provider}\u0000${node.kind}\u0000${node.name}`,
1024
+ ),
1025
+ );
1026
+ for (const {source, doc} of (await loadCliSelfDocs()).loaded) {
1027
+ if (CLI_DOC_NAMESPACES[doc.namespace]?.reader !== 'tree') continue;
1028
+ if (!placed.has(`@astryxdesign/cli\u0000${doc.type}\u0000${doc.name}`)) {
1029
+ problems.push(
1030
+ `${source} has namespace "${doc.namespace}", but no docs-tree namespace adopts it`,
1031
+ );
1032
+ }
1033
+ }
1034
+ // Every link between docs names a doc that exists (spec:AST-047 FR9):
1035
+ // typed fields, reference and workflow blocks, and inline links.
1036
+ for (const node of tree.nodes.values()) {
1037
+ for (const edge of typedEdges(tree, node).unresolved) {
1038
+ problems.push(`${node.route}: ${edge}`);
1039
+ }
1040
+ }
1041
+ problems.push(...(await docsLinkProblems(catalog, tree)));
1042
+ }
1043
+ // New findings warn: a project that passed before keeps passing
1044
+ // (0.6 compatibility), and the warning names what to fix.
1045
+ if (problems.length > 0) {
1046
+ return {
1047
+ id,
1048
+ label,
1049
+ status: 'warn',
1050
+ message: joinProblems(problems),
1051
+ fix: DOCS_TREE_FIX,
1052
+ };
1053
+ }
1054
+ const nodes = [...tree.nodes.values()];
1055
+ const namespaces = nodes.filter(node => node.kind === 'namespace').length;
1056
+ return {
1057
+ id,
1058
+ label,
1059
+ status: 'pass',
1060
+ message: `The docs tree has ${nodes.length - namespaces} docs in ${namespaces} sections (${tree.roots().length} at the top), each at one route.`,
1061
+ };
1062
+ } catch (err) {
1063
+ return {
1064
+ id,
1065
+ label,
1066
+ status: 'warn',
1067
+ message: `The docs tree could not be built: ${err instanceof Error ? err.message : String(err)}`,
1068
+ fix: 'Reinstall @astryxdesign/cli.',
1069
+ };
1070
+ }
1071
+ }
1072
+
946
1073
  /**
947
1074
  * Every topic reads progressively, in every language it ships: it loads, its
948
1075
  * section index and each of its sections fit in one read, and no contributed
@@ -965,7 +1092,13 @@ export async function checkDocsProgressiveDisclosure(ctx) {
965
1092
  let topics = 0;
966
1093
  const catalog = ctx.docsCatalog;
967
1094
  if (catalog) {
968
- for (const entry of catalog.entries()) {
1095
+ // A guide the docs tree places is a topic read by its route; it is held
1096
+ // to the same budget as every flat topic.
1097
+ const guides = [...(await projectTree(catalog)).nodes.values()]
1098
+ // A flat topic in the Unorganized level is checked above, as a topic.
1099
+ .filter(node => node.kind === 'generic' && !node.ref?.flatTopic)
1100
+ .map(guideEntry);
1101
+ for (const entry of [...catalog.entries(), ...guides]) {
969
1102
  for (const lang of [null, ...overlayLanguages(entry)]) {
970
1103
  const where = lang ? `${entry.name} [${lang}]` : entry.name;
971
1104
  try {
@@ -994,7 +1127,7 @@ export async function checkDocsProgressiveDisclosure(ctx) {
994
1127
  return {
995
1128
  id,
996
1129
  label,
997
- status: 'fail',
1130
+ status: 'warn',
998
1131
  message: joinProblems(problems),
999
1132
  fix: 'Fix the doc each problem names; split a section that is too large into smaller ones, each with its own key.',
1000
1133
  };
@@ -1019,6 +1152,7 @@ export const SYNC_CHECKS = [
1019
1152
  checkThemes,
1020
1153
  checkImplicitIntegrations,
1021
1154
  checkProviderIdentity,
1155
+ checkIntegrationIssues,
1022
1156
  checkAgentDocs,
1023
1157
  checkPeerDeps,
1024
1158
  checkPackageManager,
@@ -1058,6 +1192,8 @@ export async function runChecks(options = {}) {
1058
1192
  let docsCatalogIssues = [];
1059
1193
  /** @type {string|null} */
1060
1194
  let docsCatalogError = null;
1195
+ /** @type {Array<{package: string, code: string, severity: 'warning'|'error', message: string}>|null} */
1196
+ let integrationIssues = null;
1061
1197
  try {
1062
1198
  const project = await Project.load(cwd);
1063
1199
  configTheme =
@@ -1072,6 +1208,7 @@ export async function runChecks(options = {}) {
1072
1208
  docsCatalog = null;
1073
1209
  docsCatalogError = err instanceof Error ? err.message : String(err);
1074
1210
  }
1211
+ integrationIssues = await project.issues();
1075
1212
  } catch {
1076
1213
  // Best-effort: a missing/invalid config leaves configTheme null.
1077
1214
  }
@@ -1087,6 +1224,7 @@ export async function runChecks(options = {}) {
1087
1224
  docsCatalog,
1088
1225
  docsCatalogIssues,
1089
1226
  docsCatalogError,
1227
+ integrationIssues,
1090
1228
  configError,
1091
1229
  };
1092
1230
 
@@ -1101,6 +1239,7 @@ export async function runChecks(options = {}) {
1101
1239
  }
1102
1240
  checks.push(await checkAuthoringDocs(ctx));
1103
1241
  checks.push(await checkCliDocs(ctx));
1242
+ checks.push(await checkDocsTree(ctx));
1104
1243
  checks.push(await checkDocsProgressiveDisclosure(ctx));
1105
1244
 
1106
1245
  const summary = {pass: 0, warn: 0, fail: 0, info: 0};