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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/README.md +21 -19
  2. package/api/build/_adapter.d.mts +50 -0
  3. package/api/build/_adapter.mjs +60 -0
  4. package/api/build/build.doc.mjs +13 -7
  5. package/api/build/build.test.mjs +184 -6
  6. package/api/build/build.type.d.mts +57 -2
  7. package/api/build/build.type.mjs +30 -7
  8. package/api/build/help/help.d.mts +4 -0
  9. package/api/build/help/help.mjs +24 -11
  10. package/api/build/kit/kit.d.mts +4 -1
  11. package/api/build/kit/kit.mjs +165 -49
  12. package/api/build/kit/rank.d.mts +44 -0
  13. package/api/build/kit/rank.mjs +432 -0
  14. package/api/build/kit/rank.test.mjs +196 -0
  15. package/api/component/_adapter.d.mts +6 -12
  16. package/api/component/_adapter.mjs +20 -10
  17. package/api/component/component.mjs +60 -12
  18. package/api/component/list/list.mjs +3 -2
  19. package/api/docs/_adapter.d.mts +251 -28
  20. package/api/docs/_adapter.mjs +918 -35
  21. package/api/docs/detail/detail.mjs +11 -3
  22. package/api/docs/detail/section/section.mjs +24 -13
  23. package/api/docs/detail/section/section.test.mjs +15 -6
  24. package/api/docs/docs.d.mts +5 -3
  25. package/api/docs/docs.doc.mjs +38 -17
  26. package/api/docs/docs.mjs +44 -8
  27. package/api/docs/docs.test.mjs +158 -4
  28. package/api/docs/docs.type.d.mts +181 -2
  29. package/api/docs/docs.type.mjs +117 -3
  30. package/api/docs/index/index.mjs +11 -3
  31. package/api/docs/index/index.test.mjs +1 -1
  32. package/api/docs/integration-tree.test.mjs +555 -0
  33. package/api/docs/integrationDocs.test.mjs +14 -14
  34. package/api/docs/list/list.mjs +25 -5
  35. package/api/docs/node/node.d.mts +43 -0
  36. package/api/docs/node/node.mjs +192 -0
  37. package/api/docs/reference-blocks.test.mjs +406 -0
  38. package/api/doctor/doctor.d.mts +30 -2
  39. package/api/doctor/doctor.mjs +151 -8
  40. package/api/doctor/doctor.test.mjs +95 -7
  41. package/api/index.d.mts +1 -1
  42. package/api/index.mjs +1 -0
  43. package/api/init/init.doc.mjs +1 -1
  44. package/api/integration/add-contribution.d.mts +2 -1
  45. package/api/integration/add-contribution.mjs +107 -5
  46. package/api/integration/add-contribution.test.mjs +137 -0
  47. package/api/integration/authoring-checks.mjs +138 -28
  48. package/api/integration/authoring-checks.test.mjs +171 -3
  49. package/api/integration/authoring-checks.type.mjs +6 -1
  50. package/api/integration/integration-authoring.type.d.mts +2 -0
  51. package/api/integration/integration-authoring.type.mjs +2 -0
  52. package/api/integration/integrationAdd.doc.mjs +6 -0
  53. package/api/integration/integrationAddDoc.doc.mjs +7 -1
  54. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  55. package/api/integration/integrationPackCheck.doc.mjs +1 -1
  56. package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
  57. package/api/integration/integrationTemplateConflicts.doc.mjs +3 -0
  58. package/api/integration/pack-check.mjs +34 -0
  59. package/api/integration/pack-check.test.mjs +121 -0
  60. package/api/integration/pack-check.type.d.mts +26 -2
  61. package/api/integration/pack-check.type.mjs +14 -1
  62. package/api/integration/template-conflict-compatibility.test.mjs +73 -0
  63. package/api/integration/validate-integration.test.mjs +3 -3
  64. package/api/integration/validateIntegration.doc.mjs +1 -1
  65. package/api/json/index.ts +2 -0
  66. package/api/layout/_adapter.mjs +20 -5
  67. package/api/search/search.d.mts +59 -1
  68. package/api/search/search.doc.mjs +4 -3
  69. package/api/search/search.mjs +442 -71
  70. package/api/search/search.test.mjs +91 -2
  71. package/api/search/search.type.d.mts +13 -1
  72. package/api/search/search.type.mjs +4 -1
  73. package/api/template/list/list.mjs +1 -0
  74. package/api/template/table-floating-bulk-actions.test.mjs +66 -0
  75. package/api/template/template-integration.test.mjs +1072 -3
  76. package/api/template/template.doc.mjs +27 -7
  77. package/api/template/template.mjs +45 -8
  78. package/api/template/template.type.d.mts +6 -8
  79. package/api/template/template.type.mjs +3 -2
  80. package/api/theme/template/template.test.mjs +5 -0
  81. package/api/theme/themeTemplate.doc.mjs +1 -1
  82. package/assets/docs/getting-started.doc.mjs +2 -2
  83. package/assets/docs/layout.doc.dense.mjs +2 -2
  84. package/assets/docs/layout.doc.mjs +1 -1
  85. package/assets/docs/principles.doc.mjs +6 -6
  86. package/assets/docs/styling-libraries.doc.mjs +3 -3
  87. package/assets/docs/styling.doc.mjs +4 -4
  88. package/assets/docs/theme.doc.mjs +4 -4
  89. package/assets/docs/tokens.doc.mjs +1 -1
  90. package/assets/docs/tree/api.doc.mjs +30 -0
  91. package/assets/docs/tree/cli.doc.mjs +23 -0
  92. package/assets/docs/tree/commands.doc.mjs +25 -0
  93. package/assets/docs/{cli-integrations.doc.mjs → tree/integrations.doc.mjs} +37 -9
  94. package/assets/docs/tree/integrations.test.mjs +62 -0
  95. package/assets/docs/tree/writing-docs.doc.mjs +286 -0
  96. package/assets/docs/working-with-ai.doc.mjs +3 -3
  97. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
  98. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
  99. package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
  100. package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
  101. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
  102. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
  103. package/authoring/debug/parse.d.mts +3 -3
  104. package/authoring/doctypes/_schema.d.mts +119 -117
  105. package/authoring/doctypes/_schema.mjs +54 -3
  106. package/authoring/doctypes/base/graph-fields.doc.mjs +7 -5
  107. package/authoring/doctypes/base/type.ts +6 -5
  108. package/authoring/doctypes/command/command.doc.mjs +1 -1
  109. package/authoring/doctypes/command/type.ts +2 -2
  110. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  111. package/authoring/doctypes/enum/type.ts +1 -1
  112. package/authoring/doctypes/function/function.doc.mjs +3 -2
  113. package/authoring/doctypes/function/type.ts +3 -2
  114. package/authoring/doctypes/load-contract.test.mjs +26 -1
  115. package/authoring/doctypes/namespace/namespace.doc.mjs +6 -10
  116. package/authoring/doctypes/namespace/parse.test.mjs +23 -25
  117. package/authoring/doctypes/namespace/type.ts +5 -2
  118. package/authoring/doctypes/parse.mjs +3 -2
  119. package/authoring/doctypes/reference/reference.doc.mjs +34 -5
  120. package/authoring/doctypes/reference/type.ts +28 -11
  121. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  122. package/authoring/doctypes/schema/type.ts +1 -1
  123. package/authoring/doctypes/template/parse.d.mts +2 -0
  124. package/authoring/doctypes/template/parse.mjs +4 -0
  125. package/authoring/doctypes/template/parse.test.mjs +18 -0
  126. package/authoring/doctypes/template/template.doc.mjs +6 -0
  127. package/authoring/doctypes/template/type.ts +8 -0
  128. package/authoring/identity/identity.doc.mjs +2 -2
  129. package/authoring/index.d.ts +1 -0
  130. package/authoring/integration/type.ts +1 -1
  131. package/clients/cli/commands/build-theme.adaptations.test.mjs +100 -1
  132. package/clients/cli/commands/build-theme.mjs +1 -1
  133. package/clients/cli/commands/build.doc.mjs +11 -6
  134. package/clients/cli/commands/build.mjs +105 -67
  135. package/clients/cli/commands/build.text-fields.test.mjs +41 -0
  136. package/clients/cli/commands/component/index.mjs +1 -1
  137. package/clients/cli/commands/component-ownership.test.mjs +3 -3
  138. package/clients/cli/commands/discover.broken-integration.test.mjs +7 -8
  139. package/clients/cli/commands/discover.mjs +1 -1
  140. package/clients/cli/commands/docs.doc.mjs +20 -8
  141. package/clients/cli/commands/docs.mjs +183 -69
  142. package/clients/cli/commands/docs.test.mjs +120 -16
  143. package/clients/cli/commands/doctor-integration-docs.doc.mjs +2 -2
  144. package/clients/cli/commands/doctor-integration-templates.doc.mjs +14 -7
  145. package/clients/cli/commands/doctor-integration.test.mjs +75 -1
  146. package/clients/cli/commands/doctor.mjs +53 -16
  147. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  148. package/clients/cli/commands/integration.mjs +1 -0
  149. package/clients/cli/commands/search.mjs +11 -2
  150. package/clients/cli/commands/setup-nudge.test.mjs +6 -0
  151. package/clients/cli/commands/template.doc.mjs +23 -6
  152. package/clients/cli/commands/template.mjs +4 -91
  153. package/clients/cli/index.mjs +8 -0
  154. package/clients/cli/lib/manifest.mjs +9 -2
  155. package/foundation/agent-docs/agent-docs.d.mts +3 -2
  156. package/foundation/agent-docs/agent-docs.mjs +13 -9
  157. package/foundation/agent-docs/agent-docs.test.mjs +19 -1
  158. package/foundation/config/project.d.mts +12 -11
  159. package/foundation/config/project.mjs +73 -59
  160. package/foundation/config/project.test.mjs +141 -5
  161. package/foundation/discovery/authoring-self-docs.d.mts +12 -0
  162. package/foundation/discovery/authoring-self-docs.mjs +20 -8
  163. package/foundation/discovery/authoring-self-docs.test.mjs +25 -9
  164. package/foundation/discovery/cli-self-docs.d.mts +40 -34
  165. package/foundation/discovery/cli-self-docs.mjs +91 -115
  166. package/foundation/discovery/cli-self-docs.test.mjs +104 -166
  167. package/foundation/discovery/component-discovery.d.mts +38 -0
  168. package/foundation/discovery/component-discovery.mjs +48 -0
  169. package/foundation/discovery/docs-discovery.d.mts +109 -9
  170. package/foundation/discovery/docs-discovery.mjs +223 -24
  171. package/foundation/discovery/docs-discovery.test.mjs +103 -27
  172. package/foundation/discovery/docs-output-budget.d.mts +2 -2
  173. package/foundation/discovery/docs-output-budget.mjs +1 -1
  174. package/foundation/discovery/docs-section-key.d.mts +28 -10
  175. package/foundation/discovery/docs-section-key.mjs +134 -33
  176. package/foundation/discovery/docs-section-key.test.mjs +41 -19
  177. package/foundation/discovery/template-adapter.d.mts +92 -6
  178. package/foundation/discovery/template-adapter.mjs +453 -17
  179. package/foundation/discovery/template-adapter.test.mjs +42 -0
  180. package/foundation/discovery/template-conflict-release.d.mts +13 -0
  181. package/foundation/discovery/template-conflict-release.mjs +40 -0
  182. package/foundation/discovery/template-conflict-release.test.mjs +40 -0
  183. package/foundation/doc-compiler/bundle.mjs +61 -1
  184. package/foundation/doc-compiler/bundle.test.mjs +21 -10
  185. package/foundation/doc-compiler/compile.d.mts +113 -132
  186. package/foundation/doc-compiler/compile.mjs +57 -10
  187. package/foundation/doc-compiler/diagnostics.mjs +28 -0
  188. package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
  189. package/foundation/doc-compiler/inputs.d.mts +2 -2
  190. package/foundation/doc-compiler/inputs.mjs +6 -1
  191. package/foundation/doc-compiler/ir.mjs +7 -0
  192. package/foundation/doc-compiler/lenses.d.mts +8 -5
  193. package/foundation/doc-compiler/lenses.mjs +50 -4
  194. package/foundation/doc-compiler/links.d.mts +162 -0
  195. package/foundation/doc-compiler/links.mjs +294 -0
  196. package/foundation/doc-compiler/links.test.mjs +192 -0
  197. package/foundation/doc-compiler/lower-doc.test.mjs +5 -2
  198. package/foundation/doc-compiler/read.d.mts +3 -2
  199. package/foundation/doc-compiler/read.mjs +6 -1
  200. package/foundation/doc-compiler/tree.d.mts +288 -0
  201. package/foundation/doc-compiler/tree.mjs +876 -0
  202. package/foundation/doc-compiler/tree.test.mjs +598 -0
  203. package/foundation/integrations/autolink.test.mjs +1 -1
  204. package/foundation/integrations/cli-requirement.d.mts +45 -0
  205. package/foundation/integrations/cli-requirement.mjs +154 -0
  206. package/foundation/integrations/cli-requirement.test.mjs +84 -0
  207. package/foundation/integrations/contribution-inventory.d.mts +2 -1
  208. package/foundation/integrations/contribution-inventory.mjs +10 -4
  209. package/foundation/integrations/contribution-inventory.test.mjs +19 -0
  210. package/foundation/integrations/integration-warnings.d.mts +9 -2
  211. package/foundation/integrations/integration-warnings.mjs +51 -26
  212. package/foundation/integrations/integration-warnings.test.mjs +74 -1
  213. package/foundation/integrations/validate-contributions.mjs +25 -27
  214. package/foundation/response/response-types.doc.d.mts +5 -1
  215. package/foundation/response/response-types.doc.mjs +19 -10
  216. package/foundation/text/string-utils.d.mts +8 -0
  217. package/foundation/text/string-utils.mjs +18 -0
  218. package/foundation/xle/expand.mjs +1 -1
  219. package/foundation/xle/xle.test.mjs +13 -0
  220. package/package.json +9 -9
  221. package/assets/docs/cli.doc.mjs +0 -15
@@ -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,85 @@ 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. A
1036
+ // reference block also includes all it names.
1037
+ for (const node of tree.nodes.values()) {
1038
+ for (const edge of typedEdges(tree, node).unresolved) {
1039
+ problems.push(`${node.route}: ${edge}`);
1040
+ }
1041
+ }
1042
+ problems.push(...(await docsLinkProblems(catalog, tree)));
1043
+ problems.push(
1044
+ ...(await docsLinkProblems(catalog, tree, {references: true})),
1045
+ );
1046
+ }
1047
+ // New findings warn: a project that passed before keeps passing
1048
+ // (0.6 compatibility), and the warning names what to fix.
1049
+ if (problems.length > 0) {
1050
+ return {
1051
+ id,
1052
+ label,
1053
+ status: 'warn',
1054
+ message: joinProblems(problems),
1055
+ fix: DOCS_TREE_FIX,
1056
+ };
1057
+ }
1058
+ const nodes = [...tree.nodes.values()];
1059
+ const namespaces = nodes.filter(node => node.kind === 'namespace').length;
1060
+ return {
1061
+ id,
1062
+ label,
1063
+ status: 'pass',
1064
+ message: `The docs tree has ${nodes.length - namespaces} docs in ${namespaces} sections (${tree.roots().length} at the top), each at one route.`,
1065
+ };
1066
+ } catch (err) {
1067
+ return {
1068
+ id,
1069
+ label,
1070
+ status: 'warn',
1071
+ message: `The docs tree could not be built: ${err instanceof Error ? err.message : String(err)}`,
1072
+ fix: 'Reinstall @astryxdesign/cli.',
1073
+ };
1074
+ }
1075
+ }
1076
+
946
1077
  /**
947
1078
  * Every topic reads progressively, in every language it ships: it loads, its
948
1079
  * section index and each of its sections fit in one read, and no contributed
@@ -965,7 +1096,13 @@ export async function checkDocsProgressiveDisclosure(ctx) {
965
1096
  let topics = 0;
966
1097
  const catalog = ctx.docsCatalog;
967
1098
  if (catalog) {
968
- for (const entry of catalog.entries()) {
1099
+ // A guide the docs tree places is a topic read by its route; it is held
1100
+ // to the same budget as every flat topic.
1101
+ const guides = [...(await projectTree(catalog)).nodes.values()]
1102
+ // A flat topic in the Unorganized level is checked above, as a topic.
1103
+ .filter(node => node.kind === 'generic' && !node.ref?.flatTopic)
1104
+ .map(guideEntry);
1105
+ for (const entry of [...catalog.entries(), ...guides]) {
969
1106
  for (const lang of [null, ...overlayLanguages(entry)]) {
970
1107
  const where = lang ? `${entry.name} [${lang}]` : entry.name;
971
1108
  try {
@@ -994,7 +1131,7 @@ export async function checkDocsProgressiveDisclosure(ctx) {
994
1131
  return {
995
1132
  id,
996
1133
  label,
997
- status: 'fail',
1134
+ status: 'warn',
998
1135
  message: joinProblems(problems),
999
1136
  fix: 'Fix the doc each problem names; split a section that is too large into smaller ones, each with its own key.',
1000
1137
  };
@@ -1019,6 +1156,7 @@ export const SYNC_CHECKS = [
1019
1156
  checkThemes,
1020
1157
  checkImplicitIntegrations,
1021
1158
  checkProviderIdentity,
1159
+ checkIntegrationIssues,
1022
1160
  checkAgentDocs,
1023
1161
  checkPeerDeps,
1024
1162
  checkPackageManager,
@@ -1058,6 +1196,8 @@ export async function runChecks(options = {}) {
1058
1196
  let docsCatalogIssues = [];
1059
1197
  /** @type {string|null} */
1060
1198
  let docsCatalogError = null;
1199
+ /** @type {Array<{package: string, code: string, severity: 'warning'|'error', message: string}>|null} */
1200
+ let integrationIssues = null;
1061
1201
  try {
1062
1202
  const project = await Project.load(cwd);
1063
1203
  configTheme =
@@ -1072,6 +1212,7 @@ export async function runChecks(options = {}) {
1072
1212
  docsCatalog = null;
1073
1213
  docsCatalogError = err instanceof Error ? err.message : String(err);
1074
1214
  }
1215
+ integrationIssues = await project.issues();
1075
1216
  } catch {
1076
1217
  // Best-effort: a missing/invalid config leaves configTheme null.
1077
1218
  }
@@ -1087,6 +1228,7 @@ export async function runChecks(options = {}) {
1087
1228
  docsCatalog,
1088
1229
  docsCatalogIssues,
1089
1230
  docsCatalogError,
1231
+ integrationIssues,
1090
1232
  configError,
1091
1233
  };
1092
1234
 
@@ -1101,6 +1243,7 @@ export async function runChecks(options = {}) {
1101
1243
  }
1102
1244
  checks.push(await checkAuthoringDocs(ctx));
1103
1245
  checks.push(await checkCliDocs(ctx));
1246
+ checks.push(await checkDocsTree(ctx));
1104
1247
  checks.push(await checkDocsProgressiveDisclosure(ctx));
1105
1248
 
1106
1249
  const summary = {pass: 0, warn: 0, fail: 0, info: 0};
@@ -23,9 +23,11 @@ import {
23
23
  doctor,
24
24
  checkAuthoringDocs,
25
25
  checkCliDocs,
26
+ checkDocsTree,
26
27
  checkDocsProgressiveDisclosure,
27
28
  checkImplicitIntegrations,
28
29
  checkProviderIdentity,
30
+ checkIntegrationIssues,
29
31
  checkVersionAlignment,
30
32
  checkPackageManager,
31
33
  } from './doctor.mjs';
@@ -84,6 +86,27 @@ describe('doctor leaf', () => {
84
86
  }, SLOW);
85
87
  });
86
88
 
89
+ describe('integration issue check', () => {
90
+ it('surfaces cross-package replacement warnings', () => {
91
+ const check = checkIntegrationIssues({
92
+ integrationIssues: [
93
+ {
94
+ package: '@acme/later',
95
+ code: 'ambiguous_template_replacement',
96
+ severity: 'warning',
97
+ message: 'Later configured replacement wins.',
98
+ },
99
+ ],
100
+ });
101
+
102
+ expect(check).toMatchObject({
103
+ id: 'integration-issues',
104
+ status: 'warn',
105
+ message: expect.stringContaining('Later configured replacement wins.'),
106
+ });
107
+ });
108
+ });
109
+
87
110
  describe('doctor leaf — degradation & error paths', () => {
88
111
  it('does not crash on multiple config files; reports a config FAIL', async () => {
89
112
  const dir = mkProject({
@@ -391,7 +414,7 @@ describe('checkDocsProgressiveDisclosure', () => {
391
414
  expect(c.message).toMatch(/^\d+ topics: /);
392
415
  }, SLOW);
393
416
 
394
- it('fails on an invalid doc an integration contributed', async () => {
417
+ it('warns on an invalid doc an integration contributed', async () => {
395
418
  const c = await checkDocsProgressiveDisclosure({
396
419
  docsCatalogIssues: [
397
420
  {
@@ -402,13 +425,13 @@ describe('checkDocsProgressiveDisclosure', () => {
402
425
  },
403
426
  ],
404
427
  });
405
- expect(c.status).toBe('fail');
428
+ expect(c.status).toBe('warn');
406
429
  expect(c.message).toBe('@acme/widgets: bad.doc.mjs exports no doc');
407
430
  });
408
431
 
409
- it('fails when the docs catalog cannot be built', async () => {
432
+ it('warns when the docs catalog cannot be built', async () => {
410
433
  const c = await checkDocsProgressiveDisclosure({docsCatalogError: 'boom'});
411
- expect(c.status).toBe('fail');
434
+ expect(c.status).toBe('warn');
412
435
  expect(c.message).toContain('boom');
413
436
  });
414
437
 
@@ -436,7 +459,7 @@ describe('checkDocsProgressiveDisclosure', () => {
436
459
  }),
437
460
  docsCatalogIssues: [],
438
461
  });
439
- expect(c.status).toBe('fail');
462
+ expect(c.status).toBe('warn');
440
463
  expect(c.message).toMatch(/^2 problems: /);
441
464
  expect(c.message).toContain('huge everything: 41 KB, over the 32 KB one read may return');
442
465
  expect(c.message).toContain('broken: ');
@@ -476,7 +499,7 @@ describe('checkCliDocs', () => {
476
499
  id: 'cli-docs',
477
500
  label: 'CLI docs',
478
501
  status: 'pass',
479
- message: `All ${audit.docs} CLI docs are readable: ${audit.sections} in \`astryx docs cli\` and ${audit.authoring} in \`astryx docs authoring\`.`,
502
+ message: `All ${audit.docs} CLI docs are readable: ${audit.tree} in the \`astryx docs cli\` tree and ${audit.authoring} in \`astryx docs authoring\`.`,
480
503
  });
481
504
  },
482
505
  SLOW,
@@ -518,6 +541,71 @@ describe('checkCliDocs', () => {
518
541
  );
519
542
  });
520
543
 
544
+ describe('checkDocsTree', () => {
545
+ it(
546
+ 'passes on this repo: every CLI doc in a cli group has one route',
547
+ async () => {
548
+ const {loadDocsTree} = await import(
549
+ '../../foundation/doc-compiler/tree.mjs'
550
+ );
551
+ const tree = await loadDocsTree({fresh: true});
552
+ const nodes = [...tree.nodes.values()];
553
+ const namespaces = nodes.filter(node => node.kind === 'namespace').length;
554
+ expect(await checkDocsTree()).toEqual({
555
+ id: 'docs-tree',
556
+ label: 'Docs tree',
557
+ status: 'pass',
558
+ message: expect.stringMatching(
559
+ /^The docs tree has \d+ docs in \d+ sections \(\d+ at the top\), each at one route\.$/,
560
+ ),
561
+ });
562
+ },
563
+ SLOW,
564
+ );
565
+
566
+ it('fails on a tree with a broken placement, and names the fix', async () => {
567
+ const {buildDocsTree} = await import(
568
+ '../../foundation/doc-compiler/tree.mjs'
569
+ );
570
+ const tree = buildDocsTree({
571
+ namespaces: [
572
+ {
573
+ provider: '@acme/kit',
574
+ providerId: '@acme/kit',
575
+ source: '@acme/kit/tree/guides.doc.mjs',
576
+ doc: {
577
+ type: 'namespace',
578
+ name: 'guides',
579
+ title: 'Guides',
580
+ summary: 'Every guide.',
581
+ slots: {all: {title: 'All', accepts: {kinds: ['generic']}}},
582
+ },
583
+ },
584
+ ],
585
+ docs: [
586
+ {
587
+ provider: '@acme/kit',
588
+ providerId: '@acme/kit',
589
+ source: '@acme/kit/tree/setup.doc.mjs',
590
+ kind: 'generic',
591
+ name: 'setup',
592
+ title: 'Setup',
593
+ summary: 'Set it up.',
594
+ group: null,
595
+ placement: {parent: 'namespace:guidez'},
596
+ },
597
+ ],
598
+ });
599
+ const c = await checkDocsTree(undefined, {tree});
600
+ // New findings warn (0.6 compatibility): a broken tree is named, not fatal.
601
+ expect(c).toMatchObject({id: 'docs-tree', status: 'warn'});
602
+ expect(c.message).toContain(
603
+ '@acme/kit/tree/setup.doc.mjs: placement.parent "namespace:guidez" names no namespace; @acme/kit declares "guides".',
604
+ );
605
+ expect(c.fix).toMatch(/a placement names a namespace of its own package/);
606
+ });
607
+ });
608
+
521
609
  describe('checkAuthoringDocs against the public authoring surface', () => {
522
610
  const NAMESPACE = 'doctypes/namespace/namespace.doc.mjs';
523
611
  const NAMESPACE_TYPES =
@@ -812,7 +900,7 @@ describe('checkDocsProgressiveDisclosure languages', () => {
812
900
  docsCatalog: DocsCatalog.fromBuiltins({deploying: path.join(dir, 'deploying.doc.mjs')}),
813
901
  docsCatalogIssues: [],
814
902
  });
815
- expect(c.status).toBe('fail');
903
+ expect(c.status).toBe('warn');
816
904
  expect(c.message).toContain('deploying [zh]: zh overlay broken');
817
905
  expect(c.message).toContain('deploying [dense] overview: 41 KB');
818
906
  expect(c.message).not.toMatch(/deploying overview:/);
package/api/index.d.mts CHANGED
@@ -38,7 +38,7 @@ export * from "./integration/pack-check.type.mjs";
38
38
  export * from "./integration/validate-integration.type.mjs";
39
39
  export * from "./integration/authoring-checks.type.mjs";
40
40
  export type Logger = import("./logger.mjs").Logger;
41
- export { themeBuild, themeAdd, themeList, themeListAvailable, themeTargets, themePaletteGenerate, generateTonalPalette, listThemes } from "./theme/theme.mjs";
41
+ export { themeBuild, themeAdd, themeTemplate, themeList, themeListAvailable, themeTargets, themePaletteGenerate, generateTonalPalette, listThemes } from "./theme/theme.mjs";
42
42
  export { layoutExpand, layoutCheck, layoutGrammar } from "./layout/layout.mjs";
43
43
  export { integrationAdd, integrationAddAgentDoc, integrationAddCodemod, integrationAddComponent, integrationAddDoc, integrationAddTemplate } from "./integration/add-contribution.mjs";
44
44
  export { validateIntegration, summarizeIssues } from "./integration/validate-integration.mjs";
package/api/index.mjs CHANGED
@@ -28,6 +28,7 @@ export {template} from './template/template.mjs';
28
28
  export {
29
29
  themeBuild,
30
30
  themeAdd,
31
+ themeTemplate,
31
32
  themeList,
32
33
  themeListAvailable,
33
34
  themeTargets,
@@ -102,5 +102,5 @@ export const doc = {
102
102
  {label: 'Remove agent docs', code: 'await init({removeAgents: true});'},
103
103
  ],
104
104
  command: 'init',
105
- related: ['doctor', 'upgrade', 'build', 'theme'],
105
+ related: ['doctor', 'upgrade', 'build', 'themeTemplate'],
106
106
  };
@@ -31,7 +31,7 @@ export function integrationAddAgentDoc(line: string, options?: import("./integra
31
31
  *
32
32
  * @param {'component'|'doc'|'template'|'codemod'|'agent-doc'|'theme'} kind
33
33
  * @param {string} name
34
- * @param {{cwd?: string, dryRun?: boolean, templateType?: 'page'|'block', to?: string, replaces?: string, extends?: string}} [options]
34
+ * @param {{cwd?: string, dryRun?: boolean, templateType?: 'page'|'block', to?: string, replaces?: string, extends?: string, parent?: string}} [options]
35
35
  * @returns {Promise<import('./integration-authoring.type.mjs').IntegrationAddResponse>}
36
36
  */
37
37
  export function integrationAdd(kind: "component" | "doc" | "template" | "codemod" | "agent-doc" | "theme", name: string, options?: {
@@ -41,4 +41,5 @@ export function integrationAdd(kind: "component" | "doc" | "template" | "codemod
41
41
  to?: string;
42
42
  replaces?: string;
43
43
  extends?: string;
44
+ parent?: string;
44
45
  }): Promise<import("./integration-authoring.type.mjs").IntegrationAddResponse>;