@astryxdesign/cli 0.6.3-canary.039a67e → 0.6.3-canary.0550afd

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 (209) 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 +209 -28
  20. package/api/docs/_adapter.mjs +667 -35
  21. package/api/docs/detail/detail.mjs +11 -3
  22. package/api/docs/detail/section/section.mjs +20 -3
  23. package/api/docs/docs.d.mts +5 -3
  24. package/api/docs/docs.doc.mjs +35 -15
  25. package/api/docs/docs.mjs +44 -8
  26. package/api/docs/docs.test.mjs +158 -4
  27. package/api/docs/docs.type.d.mts +165 -2
  28. package/api/docs/docs.type.mjs +101 -3
  29. package/api/docs/index/index.mjs +11 -3
  30. package/api/docs/index/index.test.mjs +1 -1
  31. package/api/docs/integration-tree.test.mjs +547 -0
  32. package/api/docs/integrationDocs.test.mjs +14 -14
  33. package/api/docs/list/list.mjs +25 -5
  34. package/api/docs/node/node.d.mts +43 -0
  35. package/api/docs/node/node.mjs +192 -0
  36. package/api/doctor/doctor.d.mts +30 -2
  37. package/api/doctor/doctor.mjs +146 -7
  38. package/api/doctor/doctor.test.mjs +89 -1
  39. package/api/index.d.mts +1 -1
  40. package/api/index.mjs +1 -0
  41. package/api/init/init.doc.mjs +1 -1
  42. package/api/integration/add-contribution.d.mts +2 -1
  43. package/api/integration/add-contribution.mjs +107 -5
  44. package/api/integration/add-contribution.test.mjs +137 -0
  45. package/api/integration/authoring-checks.mjs +125 -28
  46. package/api/integration/authoring-checks.test.mjs +171 -3
  47. package/api/integration/authoring-checks.type.mjs +6 -1
  48. package/api/integration/integration-authoring.type.d.mts +2 -0
  49. package/api/integration/integration-authoring.type.mjs +2 -0
  50. package/api/integration/integrationAdd.doc.mjs +6 -0
  51. package/api/integration/integrationAddDoc.doc.mjs +7 -1
  52. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  53. package/api/integration/integrationPackCheck.doc.mjs +1 -1
  54. package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
  55. package/api/integration/integrationTemplateConflicts.doc.mjs +3 -0
  56. package/api/integration/pack-check.mjs +34 -0
  57. package/api/integration/pack-check.test.mjs +121 -0
  58. package/api/integration/pack-check.type.d.mts +26 -2
  59. package/api/integration/pack-check.type.mjs +14 -1
  60. package/api/integration/template-conflict-compatibility.test.mjs +73 -0
  61. package/api/integration/validate-integration.test.mjs +3 -3
  62. package/api/integration/validateIntegration.doc.mjs +1 -1
  63. package/api/json/index.ts +2 -0
  64. package/api/layout/_adapter.mjs +20 -5
  65. package/api/search/search.d.mts +59 -1
  66. package/api/search/search.doc.mjs +4 -3
  67. package/api/search/search.mjs +442 -71
  68. package/api/search/search.test.mjs +91 -2
  69. package/api/search/search.type.d.mts +13 -1
  70. package/api/search/search.type.mjs +4 -1
  71. package/api/template/list/list.mjs +1 -0
  72. package/api/template/table-floating-bulk-actions.test.mjs +66 -0
  73. package/api/template/template-integration.test.mjs +1072 -3
  74. package/api/template/template.doc.mjs +27 -7
  75. package/api/template/template.mjs +45 -8
  76. package/api/template/template.type.d.mts +6 -8
  77. package/api/template/template.type.mjs +3 -2
  78. package/api/theme/template/template.test.mjs +5 -0
  79. package/api/theme/themeTemplate.doc.mjs +1 -1
  80. package/assets/docs/getting-started.doc.mjs +2 -2
  81. package/assets/docs/layout.doc.dense.mjs +2 -2
  82. package/assets/docs/layout.doc.mjs +1 -1
  83. package/assets/docs/principles.doc.mjs +6 -6
  84. package/assets/docs/styling-libraries.doc.mjs +2 -2
  85. package/assets/docs/styling.doc.mjs +4 -4
  86. package/assets/docs/theme.doc.mjs +3 -3
  87. package/assets/docs/tokens.doc.mjs +1 -1
  88. package/assets/docs/tree/api.doc.mjs +30 -0
  89. package/assets/docs/tree/cli.doc.mjs +23 -0
  90. package/assets/docs/tree/commands.doc.mjs +25 -0
  91. package/assets/docs/{cli-integrations.doc.mjs → tree/integrations.doc.mjs} +37 -9
  92. package/assets/docs/tree/integrations.test.mjs +62 -0
  93. package/assets/docs/tree/writing-docs.doc.mjs +286 -0
  94. package/assets/docs/working-with-ai.doc.mjs +3 -3
  95. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
  96. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
  97. package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
  98. package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
  99. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
  100. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
  101. package/authoring/debug/parse.d.mts +3 -3
  102. package/authoring/doctypes/base/graph-fields.doc.mjs +7 -5
  103. package/authoring/doctypes/base/type.ts +6 -5
  104. package/authoring/doctypes/command/command.doc.mjs +1 -1
  105. package/authoring/doctypes/command/type.ts +2 -2
  106. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  107. package/authoring/doctypes/enum/type.ts +1 -1
  108. package/authoring/doctypes/function/function.doc.mjs +3 -2
  109. package/authoring/doctypes/function/type.ts +3 -2
  110. package/authoring/doctypes/namespace/namespace.doc.mjs +5 -9
  111. package/authoring/doctypes/reference/reference.doc.mjs +3 -3
  112. package/authoring/doctypes/reference/type.ts +3 -0
  113. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  114. package/authoring/doctypes/schema/type.ts +1 -1
  115. package/authoring/doctypes/template/parse.d.mts +2 -0
  116. package/authoring/doctypes/template/parse.mjs +4 -0
  117. package/authoring/doctypes/template/parse.test.mjs +18 -0
  118. package/authoring/doctypes/template/template.doc.mjs +6 -0
  119. package/authoring/doctypes/template/type.ts +8 -0
  120. package/authoring/identity/identity.doc.mjs +2 -2
  121. package/authoring/integration/type.ts +1 -1
  122. package/clients/cli/commands/build-theme.mjs +1 -1
  123. package/clients/cli/commands/build.doc.mjs +11 -6
  124. package/clients/cli/commands/build.mjs +105 -67
  125. package/clients/cli/commands/build.text-fields.test.mjs +41 -0
  126. package/clients/cli/commands/component/index.mjs +1 -1
  127. package/clients/cli/commands/component-ownership.test.mjs +3 -3
  128. package/clients/cli/commands/discover.broken-integration.test.mjs +7 -8
  129. package/clients/cli/commands/discover.mjs +1 -1
  130. package/clients/cli/commands/docs.doc.mjs +20 -8
  131. package/clients/cli/commands/docs.mjs +175 -18
  132. package/clients/cli/commands/docs.test.mjs +114 -7
  133. package/clients/cli/commands/doctor-integration-docs.doc.mjs +2 -2
  134. package/clients/cli/commands/doctor-integration-templates.doc.mjs +14 -7
  135. package/clients/cli/commands/doctor-integration.test.mjs +75 -1
  136. package/clients/cli/commands/doctor.mjs +53 -16
  137. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  138. package/clients/cli/commands/integration.mjs +1 -0
  139. package/clients/cli/commands/search.mjs +11 -2
  140. package/clients/cli/commands/setup-nudge.test.mjs +6 -0
  141. package/clients/cli/commands/template.doc.mjs +23 -6
  142. package/clients/cli/commands/template.mjs +4 -91
  143. package/clients/cli/commands/text-json-parity.test.mjs +2 -1
  144. package/clients/cli/index.mjs +8 -0
  145. package/clients/cli/lib/manifest.mjs +9 -2
  146. package/foundation/agent-docs/agent-docs.d.mts +3 -2
  147. package/foundation/agent-docs/agent-docs.mjs +13 -9
  148. package/foundation/agent-docs/agent-docs.test.mjs +19 -1
  149. package/foundation/config/project.d.mts +12 -11
  150. package/foundation/config/project.mjs +73 -59
  151. package/foundation/config/project.test.mjs +141 -5
  152. package/foundation/discovery/authoring-self-docs.test.mjs +17 -7
  153. package/foundation/discovery/cli-self-docs.d.mts +40 -34
  154. package/foundation/discovery/cli-self-docs.mjs +91 -115
  155. package/foundation/discovery/cli-self-docs.test.mjs +104 -166
  156. package/foundation/discovery/component-discovery.d.mts +38 -0
  157. package/foundation/discovery/component-discovery.mjs +48 -0
  158. package/foundation/discovery/docs-discovery.d.mts +105 -8
  159. package/foundation/discovery/docs-discovery.mjs +177 -13
  160. package/foundation/discovery/docs-discovery.test.mjs +56 -17
  161. package/foundation/discovery/docs-output-budget.d.mts +2 -2
  162. package/foundation/discovery/docs-output-budget.mjs +1 -1
  163. package/foundation/discovery/docs-section-key.d.mts +9 -2
  164. package/foundation/discovery/docs-section-key.mjs +15 -1
  165. package/foundation/discovery/template-adapter.d.mts +92 -6
  166. package/foundation/discovery/template-adapter.mjs +453 -17
  167. package/foundation/discovery/template-adapter.test.mjs +42 -0
  168. package/foundation/discovery/template-conflict-release.d.mts +13 -0
  169. package/foundation/discovery/template-conflict-release.mjs +40 -0
  170. package/foundation/discovery/template-conflict-release.test.mjs +40 -0
  171. package/foundation/doc-compiler/bundle.mjs +61 -1
  172. package/foundation/doc-compiler/bundle.test.mjs +21 -10
  173. package/foundation/doc-compiler/compile.d.mts +113 -132
  174. package/foundation/doc-compiler/compile.mjs +52 -6
  175. package/foundation/doc-compiler/diagnostics.mjs +28 -0
  176. package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
  177. package/foundation/doc-compiler/inputs.d.mts +2 -2
  178. package/foundation/doc-compiler/inputs.mjs +6 -1
  179. package/foundation/doc-compiler/ir.mjs +7 -0
  180. package/foundation/doc-compiler/lenses.d.mts +3 -2
  181. package/foundation/doc-compiler/lenses.mjs +2 -1
  182. package/foundation/doc-compiler/links.d.mts +135 -0
  183. package/foundation/doc-compiler/links.mjs +253 -0
  184. package/foundation/doc-compiler/links.test.mjs +139 -0
  185. package/foundation/doc-compiler/lower-doc.test.mjs +5 -2
  186. package/foundation/doc-compiler/read.d.mts +3 -2
  187. package/foundation/doc-compiler/read.mjs +6 -1
  188. package/foundation/doc-compiler/tree.d.mts +288 -0
  189. package/foundation/doc-compiler/tree.mjs +876 -0
  190. package/foundation/doc-compiler/tree.test.mjs +598 -0
  191. package/foundation/integrations/autolink.test.mjs +1 -1
  192. package/foundation/integrations/cli-requirement.d.mts +45 -0
  193. package/foundation/integrations/cli-requirement.mjs +154 -0
  194. package/foundation/integrations/cli-requirement.test.mjs +109 -0
  195. package/foundation/integrations/contribution-inventory.d.mts +2 -1
  196. package/foundation/integrations/contribution-inventory.mjs +10 -4
  197. package/foundation/integrations/contribution-inventory.test.mjs +19 -0
  198. package/foundation/integrations/integration-warnings.d.mts +9 -2
  199. package/foundation/integrations/integration-warnings.mjs +51 -26
  200. package/foundation/integrations/integration-warnings.test.mjs +74 -1
  201. package/foundation/integrations/validate-contributions.mjs +25 -27
  202. package/foundation/response/response-types.doc.d.mts +5 -1
  203. package/foundation/response/response-types.doc.mjs +19 -10
  204. package/foundation/text/string-utils.d.mts +8 -0
  205. package/foundation/text/string-utils.mjs +18 -0
  206. package/foundation/xle/expand.mjs +1 -1
  207. package/foundation/xle/xle.test.mjs +13 -0
  208. package/package.json +9 -9
  209. package/assets/docs/cli.doc.mjs +0 -15
@@ -21,10 +21,10 @@
21
21
  * - Discovery methods (components/templates/codemods/docs/themes) are MEMOIZED per
22
22
  * instance (via the pluggable cache) and orchestrate the EXISTING discovery
23
23
  * functions — Project never reimplements discovery.
24
- * - SKIP + WARN policy: as a discovery method runs, per-integration work is
25
- * guarded so one broken integration never throws out of discovery. Any
26
- * AstryxIntegrationIssue encountered is collected into a private set and
27
- * that integration's contributions are skipped.
24
+ * - SKIP + WARN policy: discovery records each integration issue. Other valid
25
+ * contribution kinds remain available; invalid template and component files
26
+ * do not hide valid siblings. A manifest load failure still withdraws the
27
+ * package because its roots cannot be trusted.
28
28
  * - `issues()` returns the deduped accumulated set, and (when called
29
29
  * directly) fills in validation for any configured integration not yet
30
30
  * visited by a discovery call, so it is always complete on demand.
@@ -52,11 +52,13 @@ import {
52
52
  import {
53
53
  CORE_PACKAGE,
54
54
  discoverOwnedComponents,
55
- discoverIntegrationComponents,
55
+ discoverValidIntegrationComponents,
56
56
  } from '../discovery/component-discovery.mjs';
57
57
  import {findCoreDir} from '../fs/paths.mjs';
58
58
  import {
59
- discoverAll as discoverTemplates,
59
+ applyTemplateReplacements,
60
+ effectiveTemplateDiscovery,
61
+ discoverAllUnresolved as discoverTemplates,
60
62
  discoverIntegrationTemplatesForOne,
61
63
  } from '../discovery/template-adapter.mjs';
62
64
  import {
@@ -72,10 +74,7 @@ import {
72
74
  discoverIntegrationCodemods,
73
75
  selectIntegrationCodemods,
74
76
  } from '../../assets/codemods/integration-discovery.mjs';
75
- import {
76
- INVALID_AGENT_DOCS,
77
- validateLoadedIntegration,
78
- } from '../integrations/validate-contributions.mjs';
77
+ import {validateLoadedIntegration} from '../integrations/validate-contributions.mjs';
79
78
  import {
80
79
  InMemoryConfigCache,
81
80
  cacheKey,
@@ -346,6 +345,8 @@ export class Project {
346
345
  * @type {Set<object>}
347
346
  */
348
347
  #visitedIssues = new Set();
348
+ /** @type {Promise<Array<object>> | null} */
349
+ #templatesPromise = null;
349
350
 
350
351
  /**
351
352
  * @param {object} init
@@ -597,22 +598,6 @@ export class Project {
597
598
  return integration?.name ?? integration?.__spec ?? '(integration)';
598
599
  }
599
600
 
600
- /**
601
- * Whether this package has an error that invalidates its regular manifest
602
- * contributions. Invalid `agentDocs` blocks agent-doc writes only; it must not
603
- * withdraw components, templates, docs, or codemods.
604
- * @param {string} pkg
605
- * @returns {boolean}
606
- */
607
- #hasBlockingContributionIssue(pkg) {
608
- return this.#issues.some(
609
- issue =>
610
- issue.package === pkg &&
611
- issue.severity === 'error' &&
612
- issue.code !== INVALID_AGENT_DOCS,
613
- );
614
- }
615
-
616
601
  /**
617
602
  * Validate one loaded integration and collect any issues. Marks the
618
603
  * integration visited so issues() won't redo the work. Best-effort: a
@@ -649,9 +634,9 @@ export class Project {
649
634
  /**
650
635
  * Core + integration component ownership records. Wraps
651
636
  * discoverOwnedComponents for core and discoverIntegrationComponents (via
652
- * discoverOwnedComponents) for integrations, but applies the skip+warn
653
- * policy per integration: a broken integration's components are skipped and
654
- * its issues collected, never thrown. Memoized per instance.
637
+ * discoverOwnedComponents) for integrations. Invalid component records are
638
+ * omitted and reported; valid component siblings and other contribution kinds
639
+ * remain available. Memoized per instance.
655
640
  *
656
641
  * @returns {Promise<Array<{name: string, package: string, group: string|null, docPath: string|null, sourcePath: string|null, issuesUrl: string|undefined}>>}
657
642
  */
@@ -671,18 +656,17 @@ export class Project {
671
656
  }
672
657
  }
673
658
 
674
- // Each integration in isolation so one broken integration is skipped.
659
+ // Each integration is discovered independently. Invalid records are
660
+ // omitted below without hiding valid siblings or other contribution kinds.
675
661
  for (const integration of this.#loadedIntegrations) {
676
662
  await this.#collectIssues(integration);
677
663
  const pkg = this.#pkgLabel(integration);
678
- if (this.#hasBlockingContributionIssue(pkg)) continue;
679
664
  try {
680
- // discoverOwnedComponents owns the core+integration record shape;
681
- // here we add only this integration's records (core is handled
682
- // above) so a single broken integration can be skipped in isolation.
683
- for (const rec of discoverIntegrationComponents(integration)) {
684
- records.push(rec);
685
- }
665
+ // #collectIssues (above) already reported each withdrawn record,
666
+ // with its fix, through the same discovery.
667
+ const {components} =
668
+ await discoverValidIntegrationComponents(integration);
669
+ records.push(...components);
686
670
  } catch (err) {
687
671
  this.#pushIssue(pkg, {
688
672
  code: 'invalid_component',
@@ -697,17 +681,21 @@ export class Project {
697
681
  }
698
682
 
699
683
  /**
700
- * Core + integration templates, type-tagged. Wraps discoverTemplates (core +
701
- * external blocks) and discoverIntegrationTemplatesForOne per integration so
702
- * a broken integration's templates are skipped and its issues collected.
703
- * Memoized per instance.
684
+ * Core + integration templates, type-tagged, with valid integration
685
+ * replacements projected over their Core targets. Wraps raw template discovery
686
+ * (Core + external blocks) and discoverIntegrationTemplatesForOne per integration
687
+ * so unusable template files are reported and omitted while valid siblings
688
+ * remain available. Memoized per instance.
704
689
  *
705
690
  * @returns {Promise<Array<object>>}
706
691
  */
707
692
  async templates() {
708
- return this.#memo('templates', async () => {
693
+ if (this.#templatesPromise) return this.#templatesPromise;
694
+ this.#templatesPromise = (async () => {
709
695
  /** @type {any[]} */
710
696
  const templates = [];
697
+ /** @type {import('../discovery/template-adapter.mjs').TemplateDiscoveryError[]} */
698
+ const replacementErrors = [];
711
699
 
712
700
  // Core + external-package templates (discoverTemplates internally also
713
701
  // loads integration templates via loadConfig today; we intentionally
@@ -728,20 +716,24 @@ export class Project {
728
716
  for (const integration of this.#loadedIntegrations) {
729
717
  await this.#collectIssues(integration);
730
718
  const pkg = this.#pkgLabel(integration);
731
- if (this.#hasBlockingContributionIssue(pkg)) continue;
719
+ // Template discovery already isolates invalid template files and returns
720
+ // every valid sibling. Do not withdraw templates because another
721
+ // contribution kind in this package is broken.
732
722
  try {
733
723
  const {templates: ts, errors} =
734
724
  await discoverIntegrationTemplatesForOne(integration);
735
725
  for (const e of errors) {
736
726
  this.#pushIssue(pkg, {
737
- code: 'invalid_template',
738
- severity: 'error',
727
+ code: e.code ?? 'invalid_template',
728
+ severity: e.severity ?? 'error',
739
729
  message: e.message,
740
730
  });
731
+ if (e.replacementTarget != null) replacementErrors.push(e);
741
732
  }
742
- // Only contribute templates when the integration had no per-template
743
- // errors (skip the whole integration's templates on any error).
744
- if (errors.length === 0) templates.push(...ts);
733
+ // Discovery already omits each unusable template from `ts`. Keep all
734
+ // valid siblings, while the collected errors remain visible through
735
+ // issues() and replacement errors disable only their own targets.
736
+ templates.push(...ts);
745
737
  } catch (err) {
746
738
  this.#pushIssue(pkg, {
747
739
  code: 'invalid_template',
@@ -751,15 +743,24 @@ export class Project {
751
743
  }
752
744
  }
753
745
 
754
- return templates.sort((a, b) => a.name.localeCompare(b.name));
755
- });
746
+ const resolved = applyTemplateReplacements(templates, replacementErrors);
747
+ for (const error of resolved.errors) {
748
+ this.#pushIssue(error.package, {
749
+ code: error.code,
750
+ severity: error.severity,
751
+ message: error.message,
752
+ });
753
+ }
754
+ return effectiveTemplateDiscovery(resolved.templates);
755
+ })();
756
+ return this.#templatesPromise;
756
757
  }
757
758
 
758
759
  /**
759
760
  * Bundled source themes plus themes contributed by installed integrations.
760
761
  * Each record keeps its package owner and source directory so callers can
761
- * both list and copy it without reconstructing paths. A broken integration's
762
- * themes are skipped under the same issue policy as every other kind.
762
+ * both list and copy it without reconstructing paths. A broken theme
763
+ * contribution is reported without hiding the package's other valid kinds.
763
764
  *
764
765
  * @returns {Promise<import('../discovery/theme-discovery.mjs').DiscoveredTheme[]>}
765
766
  */
@@ -770,7 +771,6 @@ export class Project {
770
771
  for (const integration of this.#loadedIntegrations) {
771
772
  await this.#collectIssues(integration);
772
773
  const pkg = this.#pkgLabel(integration);
773
- if (this.#hasBlockingContributionIssue(pkg)) continue;
774
774
  if (!integration?.themes) continue;
775
775
  try {
776
776
  themes.push(...(await discoverIntegrationThemes(integration)));
@@ -804,14 +804,16 @@ export class Project {
804
804
  async docs() {
805
805
  return this.#memo('docs', async () => {
806
806
  const catalog = DocsCatalog.fromBuiltins();
807
+ let rank = 0;
807
808
 
808
809
  for (const integration of this.#loadedIntegrations) {
810
+ rank += 1;
809
811
  await this.#collectIssues(integration);
810
812
  const pkg = this.#pkgLabel(integration);
811
- if (this.#hasBlockingContributionIssue(pkg)) continue;
812
813
  if (!integration?.docs) continue;
813
814
  try {
814
- const {records, errors} = await discoverIntegrationDocs(integration);
815
+ const {records, errors, namespaces, guides} =
816
+ await discoverIntegrationDocs(integration);
815
817
  for (const e of errors) {
816
818
  this.#pushIssue(pkg, {
817
819
  code: 'invalid_doc',
@@ -823,11 +825,20 @@ export class Project {
823
825
  // how a bad template withdraws its package's templates: a partial
824
826
  // docs contribution is the state where a `replaces` silently does
825
827
  // nothing and a reader gets the topic it was meant to replace.
826
- if (errors.length > 0) continue;
828
+ if (errors.length > 0) {
829
+ for (const e of errors) {
830
+ catalog.addIssue({package: integration.name ?? pkg, message: e.message});
831
+ }
832
+ continue;
833
+ }
827
834
  for (const record of records) {
828
835
  const issue = catalog.add(record);
829
836
  if (issue) this.#pushIssue(pkg, issue);
830
837
  }
838
+ catalog.addTreeInputs({
839
+ namespaces: namespaces.map(input => ({...input, rank})),
840
+ guides: guides.map(input => ({...input, rank})),
841
+ });
831
842
  } catch (err) {
832
843
  this.#pushIssue(pkg, {
833
844
  code: 'invalid_doc',
@@ -844,8 +855,8 @@ export class Project {
844
855
  /**
845
856
  * Core registry transforms + integration codemods for an upgrade range.
846
857
  * Wraps getTransformsBetween (core) and discoverIntegrationCodemods /
847
- * selectIntegrationCodemods (integrations). A broken integration's codemods
848
- * are skipped (issue collected) rather than failing the whole resolution.
858
+ * selectIntegrationCodemods (integrations). An invalid codemod contribution
859
+ * is reported and omitted without hiding other valid contribution kinds.
849
860
  * Memoized per (from, to) key.
850
861
  *
851
862
  * @param {string} fromVersion exclusive lower bound
@@ -863,7 +874,6 @@ export class Project {
863
874
  for (const integration of this.#loadedIntegrations) {
864
875
  await this.#collectIssues(integration);
865
876
  const pkg = this.#pkgLabel(integration);
866
- if (this.#hasBlockingContributionIssue(pkg)) continue;
867
877
  if (!integration?.codemods) continue;
868
878
  try {
869
879
  // Validate this integration's codemods discover cleanly in
@@ -918,6 +928,10 @@ export class Project {
918
928
  * @returns {Promise<ProjectIntegrationIssue[]>}
919
929
  */
920
930
  async issues() {
931
+ // Template replacement validity depends on the combined Core + integration
932
+ // catalog. Resolve it first so issue results never depend on which discovery
933
+ // method the caller happened to invoke earlier.
934
+ await this.templates();
921
935
  for (const integration of this.#loadedIntegrations) {
922
936
  await this.#collectIssues(integration);
923
937
  }
@@ -6,6 +6,7 @@ import * as path from 'node:path';
6
6
  import {Project, DEFAULT_ISSUES_URL, findConfigPath} from './project.mjs';
7
7
  import {InMemoryConfigCache} from './config-cache.mjs';
8
8
  import * as componentDiscovery from '../discovery/component-discovery.mjs';
9
+ import {discoverCoreTemplates} from '../discovery/template-adapter.mjs';
9
10
 
10
11
  let tmpDir;
11
12
  let originalCwd;
@@ -21,6 +22,9 @@ function scaffold({
21
22
  issuesUrl,
22
23
  withComponents = true,
23
24
  withTemplates = true,
25
+ templateId = 'hero',
26
+ templateType = 'block',
27
+ templateReplaces = null,
24
28
  withCodemods = true,
25
29
  brokenComponent = false,
26
30
  brokenCodemod = false,
@@ -65,7 +69,7 @@ function scaffold({
65
69
  fs.mkdirSync(compDir, {recursive: true});
66
70
  fs.writeFileSync(
67
71
  path.join(compDir, 'Widget.doc.mjs'),
68
- `export const docs = { name: 'Widget', usage: {description: 'A widget'} };\n`,
72
+ `export const docs = { name: 'Widget', usage: {description: 'A widget'}, props: [] };\n`,
69
73
  );
70
74
  if (!brokenComponent) {
71
75
  fs.writeFileSync(
@@ -80,12 +84,12 @@ function scaffold({
80
84
  const tDir = path.join(pkgDir, 'templates');
81
85
  fs.mkdirSync(tDir, {recursive: true});
82
86
  fs.writeFileSync(
83
- path.join(tDir, 'hero.doc.mjs'),
84
- `export default { type: 'block', name: 'Hero', description: 'A hero' };\n`,
87
+ path.join(tDir, `${templateId}.doc.mjs`),
88
+ `export default { type: '${templateType}', name: 'Fixture template', description: 'A fixture template'${templateReplaces == null ? '' : `, replaces: ${JSON.stringify(templateReplaces)}`} };\n`,
85
89
  );
86
90
  fs.writeFileSync(
87
- path.join(tDir, 'hero.tsx'),
88
- `export default function Hero() { return null; }\n`,
91
+ path.join(tDir, `${templateId}.tsx`),
92
+ `export default function FixtureTemplate() { return null; }\n`,
89
93
  );
90
94
  }
91
95
 
@@ -324,6 +328,91 @@ describe('Project discovery', () => {
324
328
  expect(hero.type).toBe('block');
325
329
  });
326
330
 
331
+ it('templates() projects a valid integration replacement instead of its Core target', async () => {
332
+ const corePage = (await discoverCoreTemplates()).find(
333
+ template => template.type === 'page',
334
+ );
335
+ expect(corePage).toBeDefined();
336
+ scaffold({
337
+ templateId: 'acme-app-shell',
338
+ templateType: 'page',
339
+ templateReplaces: corePage.dirName,
340
+ });
341
+ const project = await Project.load(tmpDir);
342
+
343
+ const templates = await project.templates();
344
+
345
+ expect(
346
+ templates.find(template => template.dirName === 'acme-app-shell'),
347
+ ).toMatchObject({
348
+ package: '@acme/widgets',
349
+ replaces: corePage.dirName,
350
+ });
351
+ expect(
352
+ templates.find(
353
+ template =>
354
+ template.dirName === corePage.dirName &&
355
+ template.package !== '@acme/widgets',
356
+ ),
357
+ ).toBeUndefined();
358
+ expect(await project.issues()).toEqual([]);
359
+ });
360
+
361
+ it('reports replacement issues regardless of discovery call order without hiding other contributions', async () => {
362
+ scaffold({
363
+ templateReplaces: 'missing-core-template',
364
+ });
365
+
366
+ const componentsFirst = await Project.load(tmpDir);
367
+ expect(
368
+ (await componentsFirst.components()).some(
369
+ component => component.package === '@acme/widgets',
370
+ ),
371
+ ).toBe(true);
372
+ expect(await componentsFirst.issues()).toEqual(
373
+ expect.arrayContaining([
374
+ expect.objectContaining({
375
+ code: 'missing_template_replacement_target',
376
+ package: '@acme/widgets',
377
+ }),
378
+ ]),
379
+ );
380
+
381
+ const issuesFirst = await Project.load(tmpDir, {fresh: true});
382
+ expect(await issuesFirst.issues()).toEqual(
383
+ expect.arrayContaining([
384
+ expect.objectContaining({
385
+ code: 'missing_template_replacement_target',
386
+ package: '@acme/widgets',
387
+ }),
388
+ ]),
389
+ );
390
+ expect(
391
+ (await issuesFirst.components()).some(
392
+ component => component.package === '@acme/widgets',
393
+ ),
394
+ ).toBe(true);
395
+ const ownTemplate = (await issuesFirst.templates()).find(
396
+ template =>
397
+ template.package === '@acme/widgets' && template.dirName === 'hero',
398
+ );
399
+ expect(ownTemplate).toBeDefined();
400
+ expect(ownTemplate).not.toHaveProperty('replaces');
401
+
402
+ const sharedCache = new InMemoryConfigCache();
403
+ const warm = await Project.load(tmpDir, {cache: sharedCache});
404
+ await warm.templates();
405
+ const cached = await Project.load(tmpDir, {cache: sharedCache});
406
+ expect(await cached.issues()).toEqual(
407
+ expect.arrayContaining([
408
+ expect.objectContaining({
409
+ code: 'missing_template_replacement_target',
410
+ package: '@acme/widgets',
411
+ }),
412
+ ]),
413
+ );
414
+ });
415
+
327
416
  it('codemods() returns core registry groups + integration groups', async () => {
328
417
  scaffold();
329
418
  const project = await Project.load(tmpDir);
@@ -468,6 +557,53 @@ describe('Project issues (skip + warn)', () => {
468
557
  expect(issues.some(i => i.package === '@acme/widgets')).toBe(true);
469
558
  });
470
559
 
560
+ it('keeps valid contribution kinds and siblings when others are broken', async () => {
561
+ const pkgDir = scaffold({brokenComponent: true});
562
+ fs.writeFileSync(
563
+ path.join(pkgDir, 'templates', 'broken.template.mjs'),
564
+ `export default {type: 'block', name: 'Broken', description: 'Missing source'};\n`,
565
+ );
566
+ fs.writeFileSync(
567
+ path.join(pkgDir, 'components', 'ValidWidget.doc.mjs'),
568
+ `export default {type: 'component', name: 'ValidWidget', props: []};\n`,
569
+ );
570
+ fs.writeFileSync(
571
+ path.join(pkgDir, 'components', 'ValidWidget.tsx'),
572
+ `export function ValidWidget() { return null; }\n`,
573
+ );
574
+ const project = await Project.load(tmpDir);
575
+
576
+ const templates = await project.templates();
577
+ const components = await project.components();
578
+ const issues = await project.issues();
579
+
580
+ expect(
581
+ templates.find(
582
+ template =>
583
+ template.dirName === 'hero' && template.package === '@acme/widgets',
584
+ ),
585
+ ).toBeDefined();
586
+ expect(
587
+ components.find(
588
+ component =>
589
+ component.name === 'ValidWidget' &&
590
+ component.package === '@acme/widgets',
591
+ ),
592
+ ).toBeDefined();
593
+ expect(
594
+ components.find(
595
+ component =>
596
+ component.name === 'Widget' && component.package === '@acme/widgets',
597
+ ),
598
+ ).toBeUndefined();
599
+ expect(issues).toEqual(
600
+ expect.arrayContaining([
601
+ expect.objectContaining({code: 'invalid_component'}),
602
+ expect.objectContaining({code: 'invalid_template'}),
603
+ ]),
604
+ );
605
+ });
606
+
471
607
  it('does not throw when an integration codemod is broken', async () => {
472
608
  scaffold({brokenCodemod: true});
473
609
  const project = await Project.load(tmpDir);
@@ -60,17 +60,25 @@ describe('authoring self-docs', () => {
60
60
  );
61
61
  });
62
62
 
63
- describe('what the authoring docs say about the unbuilt docs graph', () => {
64
- it('marks exactly the fields topic loading rejects as not read yet', () => {
63
+ describe('what the authoring docs say about the docs tree', () => {
64
+ it('marks exactly the fields the docs tree does not read yet', () => {
65
65
  const notReadYet = graphFieldsDoc.fields
66
66
  .filter(field => /Not read yet/.test(field.description))
67
67
  .map(field => field.name);
68
- expect(notReadYet.sort()).toEqual([...GRAPH_ONLY_FIELDS].sort());
68
+ // The tree reads `placement` for every guide (spec:AST-046); the other
69
+ // graph fields are still refused by every topic reader.
70
+ expect(notReadYet.sort()).toEqual(
71
+ GRAPH_ONLY_FIELDS.filter(field => field !== 'placement').sort(),
72
+ );
69
73
  for (const field of graphFieldsDoc.fields) {
70
- if (notReadYet.includes(field.name)) {
74
+ if (GRAPH_ONLY_FIELDS.includes(field.name)) {
71
75
  expect(field.description).toMatch(/fails to load/);
72
76
  }
73
77
  }
78
+ const placement = graphFieldsDoc.fields.find(f => f.name === 'placement');
79
+ expect(placement.description).toMatch(
80
+ /Read for every guide, the CLI's and each integration's/,
81
+ );
74
82
  expect(graphFieldsDoc.description).toMatch(/not built yet/);
75
83
  });
76
84
 
@@ -85,8 +93,10 @@ describe('what the authoring docs say about the unbuilt docs graph', () => {
85
93
  }
86
94
  });
87
95
 
88
- it('says namespace docs are not loaded yet', () => {
89
- expect(namespaceDoc.description).toMatch(/Not loaded yet/);
96
+ it('says where namespace docs live: the CLI tree, and each integration', () => {
97
+ expect(namespaceDoc.description).toMatch(
98
+ /an integration ships its own in its docs directory/,
99
+ );
90
100
  expect(
91
101
  problemsInTopic({
92
102
  ...namespaceDoc.examples?.[0],
@@ -94,7 +104,7 @@ describe('what the authoring docs say about the unbuilt docs graph', () => {
94
104
  name: 'x',
95
105
  }),
96
106
  ).toEqual([
97
- '"x" is a namespace doc. Only the docs graph reads namespace docs, and it is not built yet; remove this file from the docs directory.',
107
+ '"x" is a namespace doc, which the docs tree reads, not the topic list. The CLI keeps its own in assets/docs/tree; an integration ships its namespace docs in its docs directory.',
98
108
  ]);
99
109
  });
100
110
  });
@@ -27,46 +27,45 @@ export function loadCliSelfDocs(sources?: string[], root?: string): Promise<{
27
27
  }[];
28
28
  }>;
29
29
  /**
30
- * A name as a section-key segment: lowercase words joined by hyphens.
31
- * `integrationPackCheck` and `integration pack` both read naturally.
32
- * @param {string} name
33
- * @returns {string}
30
+ * What cross-links need: the loaded function docs by name, the command names,
31
+ * and the route the docs tree gave a doc, if it gave one.
32
+ * @typedef {object} CliDocIndex
33
+ * @property {Map<string, any>} functions
34
+ * @property {Set<string>} commands
35
+ * @property {(kind: string, name: string) => string | null} route
34
36
  */
35
- export function keySegment(name: string): string;
36
37
  /**
37
- * The section key a doc is read by in `astryx docs cli`, or null when its
38
- * namespace is not one of the topic's.
39
- * @param {any} doc
40
- * @returns {string | null}
41
- */
42
- export function cliSectionKey(doc: any): string | null;
43
- /**
44
- * The `cli` topic: one section per doc whose namespace is `cli/…`.
45
- * @param {any[]} docs every loaded CLI doc; the ones in other namespaces are
46
- * left out
47
- * @returns {import('../../authoring/doctypes/reference/type').ReferenceDoc}
38
+ * @param {any[]} docs every loaded CLI typed doc
39
+ * @param {(kind: string, name: string) => string | null} [route]
40
+ * @returns {CliDocIndex}
48
41
  */
49
- export function buildCliReferenceDoc(docs: any[]): import("../../authoring/doctypes/reference/type").ReferenceDoc;
42
+ export function cliDocIndex(docs: any[], route?: (kind: string, name: string) => string | null): CliDocIndex;
50
43
  /**
51
- * The `cli` topic from every CLI doc that loads. One that fails is left out
52
- * here and reported by {@link auditCliSelfDocs}.
53
- * @returns {Promise<import('../../authoring/doctypes/reference/type').ReferenceDoc>}
44
+ * What `astryx docs <route>` prints for one CLI typed doc: its title and the
45
+ * blocks of its content, with cross-links to the routes the tree gave.
46
+ * @param {any} doc
47
+ * @param {CliDocIndex} index
48
+ * @returns {{id: string, title: string, content: any[]}}
54
49
  */
55
- export function buildCliTopic(): Promise<import("../../authoring/doctypes/reference/type").ReferenceDoc>;
50
+ export function cliDocSection(doc: any, index: CliDocIndex): {
51
+ id: string;
52
+ title: string;
53
+ content: any[];
54
+ };
56
55
  /**
57
- * What stands between a CLI doc and a reader: a missing namespace, one no
58
- * topic reads, one that disagrees with the authoring topic's list, a doc that
59
- * fails to load, and a `cli` section that clashes or is too large.
56
+ * What stands between a CLI doc and a reader: a missing namespace, one nothing
57
+ * reads, one that disagrees with the authoring topic's list, a doc that fails
58
+ * to load, and a tree leaf too large for one read. Whether the tree gives
59
+ * every `cli/...` doc a route is the docs-tree check's job.
60
60
  * @param {{root?: string, sources?: string[], budget?: number, authoringSources?: string[]}} [options]
61
61
  * @returns {Promise<{
62
62
  * docs: number,
63
- * sections: number,
63
+ * tree: number,
64
64
  * authoring: number,
65
65
  * missing: string[],
66
66
  * unknown: {source: string, namespace: string}[],
67
67
  * misfiled: {source: string, message: string}[],
68
68
  * failed: {source: string, error: string}[],
69
- * keyProblems: string[],
70
69
  * oversized: {key: string, title: string, bytes: number}[],
71
70
  * }>}
72
71
  */
@@ -77,7 +76,7 @@ export function auditCliSelfDocs({ root, sources, budget, authoringSources, }?:
77
76
  authoringSources?: string[];
78
77
  }): Promise<{
79
78
  docs: number;
80
- sections: number;
79
+ tree: number;
81
80
  authoring: number;
82
81
  missing: string[];
83
82
  unknown: {
@@ -92,7 +91,6 @@ export function auditCliSelfDocs({ root, sources, budget, authoringSources, }?:
92
91
  source: string;
93
92
  error: string;
94
93
  }[];
95
- keyProblems: string[];
96
94
  oversized: {
97
95
  key: string;
98
96
  title: string;
@@ -102,12 +100,20 @@ export function auditCliSelfDocs({ root, sources, budget, authoringSources, }?:
102
100
  /** The directories, relative to the CLI root, that hold the CLI's own docs. */
103
101
  export const CLI_SELF_DOC_DIRS: string[];
104
102
  /**
105
- * Every namespace a CLI doc may declare, and the topic that reads it. A doc in
106
- * a `cli/` namespace is the section `<key prefix>-<name>` of `astryx docs cli`;
107
- * a doc in `authoring` is a section of `astryx docs authoring`.
108
- * @type {Record<string, {topic: string, keyPrefix?: string}>}
103
+ * Every namespace a CLI doc may declare, and what reads it. The docs tree
104
+ * adopts `cli/commands` (under `cli/commands`) and `cli/api` (under
105
+ * `cli/api/<kind>s`); `astryx docs authoring` reads `authoring` from its list.
106
+ * @type {Record<string, {reader: 'tree' | 'authoring'}>}
109
107
  */
110
108
  export const CLI_DOC_NAMESPACES: Record<string, {
111
- topic: string;
112
- keyPrefix?: string;
109
+ reader: "tree" | "authoring";
113
110
  }>;
111
+ /**
112
+ * What cross-links need: the loaded function docs by name, the command names,
113
+ * and the route the docs tree gave a doc, if it gave one.
114
+ */
115
+ export type CliDocIndex = {
116
+ functions: Map<string, any>;
117
+ commands: Set<string>;
118
+ route: (kind: string, name: string) => string | null;
119
+ };