@astryxdesign/cli 0.6.3-canary.1f30d4e → 0.6.3-canary.1ffe66d

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 (181) 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 +20 -3
  10. package/api/docs/docs.d.mts +5 -3
  11. package/api/docs/docs.doc.mjs +35 -15
  12. package/api/docs/docs.mjs +44 -8
  13. package/api/docs/docs.test.mjs +158 -4
  14. package/api/docs/docs.type.d.mts +165 -2
  15. package/api/docs/docs.type.mjs +101 -3
  16. package/api/docs/index/index.mjs +11 -3
  17. package/api/docs/index/index.test.mjs +1 -1
  18. package/api/docs/integration-tree.test.mjs +547 -0
  19. package/api/docs/integrationDocs.test.mjs +14 -14
  20. package/api/docs/list/list.mjs +25 -5
  21. package/api/docs/node/node.d.mts +43 -0
  22. package/api/docs/node/node.mjs +192 -0
  23. package/api/doctor/doctor.d.mts +30 -2
  24. package/api/doctor/doctor.mjs +146 -7
  25. package/api/doctor/doctor.test.mjs +89 -1
  26. package/api/index.d.mts +1 -1
  27. package/api/index.mjs +1 -0
  28. package/api/init/init.doc.mjs +1 -1
  29. package/api/integration/add-contribution.d.mts +2 -1
  30. package/api/integration/add-contribution.mjs +107 -5
  31. package/api/integration/add-contribution.test.mjs +137 -0
  32. package/api/integration/authoring-checks.mjs +125 -28
  33. package/api/integration/authoring-checks.test.mjs +171 -3
  34. package/api/integration/authoring-checks.type.mjs +6 -1
  35. package/api/integration/integration-authoring.type.d.mts +2 -0
  36. package/api/integration/integration-authoring.type.mjs +2 -0
  37. package/api/integration/integrationAdd.doc.mjs +6 -0
  38. package/api/integration/integrationAddDoc.doc.mjs +7 -1
  39. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  40. package/api/integration/integrationPackCheck.doc.mjs +1 -1
  41. package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
  42. package/api/integration/integrationTemplateConflicts.doc.mjs +3 -0
  43. package/api/integration/pack-check.mjs +34 -0
  44. package/api/integration/pack-check.test.mjs +121 -0
  45. package/api/integration/pack-check.type.d.mts +26 -2
  46. package/api/integration/pack-check.type.mjs +14 -1
  47. package/api/integration/template-conflict-compatibility.test.mjs +73 -0
  48. package/api/integration/validate-integration.test.mjs +3 -3
  49. package/api/integration/validateIntegration.doc.mjs +1 -1
  50. package/api/json/index.ts +2 -0
  51. package/api/layout/_adapter.mjs +20 -5
  52. package/api/search/search.d.mts +26 -1
  53. package/api/search/search.doc.mjs +4 -3
  54. package/api/search/search.mjs +308 -29
  55. package/api/search/search.test.mjs +91 -2
  56. package/api/search/search.type.d.mts +13 -1
  57. package/api/search/search.type.mjs +4 -1
  58. package/api/template/list/list.mjs +1 -0
  59. package/api/template/template-integration.test.mjs +1022 -3
  60. package/api/template/template.doc.mjs +27 -7
  61. package/api/template/template.mjs +45 -8
  62. package/api/template/template.type.d.mts +6 -8
  63. package/api/template/template.type.mjs +3 -2
  64. package/api/theme/template/template.test.mjs +5 -0
  65. package/api/theme/themeTemplate.doc.mjs +1 -1
  66. package/assets/docs/getting-started.doc.mjs +2 -2
  67. package/assets/docs/principles.doc.mjs +6 -6
  68. package/assets/docs/styling-libraries.doc.mjs +2 -2
  69. package/assets/docs/styling.doc.mjs +4 -4
  70. package/assets/docs/theme.doc.mjs +3 -3
  71. package/assets/docs/tokens.doc.mjs +1 -1
  72. package/assets/docs/tree/api.doc.mjs +30 -0
  73. package/assets/docs/tree/cli.doc.mjs +23 -0
  74. package/assets/docs/tree/commands.doc.mjs +25 -0
  75. package/assets/docs/{cli-integrations.doc.mjs → tree/integrations.doc.mjs} +37 -9
  76. package/assets/docs/tree/integrations.test.mjs +62 -0
  77. package/assets/docs/tree/writing-docs.doc.mjs +286 -0
  78. package/authoring/debug/parse.d.mts +3 -3
  79. package/authoring/doctypes/base/graph-fields.doc.mjs +7 -5
  80. package/authoring/doctypes/base/type.ts +6 -5
  81. package/authoring/doctypes/command/command.doc.mjs +1 -1
  82. package/authoring/doctypes/command/type.ts +2 -2
  83. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  84. package/authoring/doctypes/enum/type.ts +1 -1
  85. package/authoring/doctypes/function/function.doc.mjs +3 -2
  86. package/authoring/doctypes/function/type.ts +3 -2
  87. package/authoring/doctypes/namespace/namespace.doc.mjs +5 -9
  88. package/authoring/doctypes/reference/reference.doc.mjs +3 -3
  89. package/authoring/doctypes/reference/type.ts +3 -0
  90. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  91. package/authoring/doctypes/schema/type.ts +1 -1
  92. package/authoring/doctypes/template/parse.d.mts +2 -0
  93. package/authoring/doctypes/template/parse.mjs +4 -0
  94. package/authoring/doctypes/template/parse.test.mjs +18 -0
  95. package/authoring/doctypes/template/template.doc.mjs +6 -0
  96. package/authoring/doctypes/template/type.ts +8 -0
  97. package/authoring/identity/identity.doc.mjs +2 -2
  98. package/authoring/integration/type.ts +1 -1
  99. package/clients/cli/commands/build-theme.mjs +1 -1
  100. package/clients/cli/commands/build.mjs +5 -2
  101. package/clients/cli/commands/component/index.mjs +1 -1
  102. package/clients/cli/commands/component-ownership.test.mjs +3 -3
  103. package/clients/cli/commands/discover.broken-integration.test.mjs +7 -8
  104. package/clients/cli/commands/discover.mjs +1 -1
  105. package/clients/cli/commands/docs.doc.mjs +20 -8
  106. package/clients/cli/commands/docs.mjs +175 -18
  107. package/clients/cli/commands/docs.test.mjs +114 -7
  108. package/clients/cli/commands/doctor-integration-docs.doc.mjs +2 -2
  109. package/clients/cli/commands/doctor-integration-templates.doc.mjs +14 -7
  110. package/clients/cli/commands/doctor-integration.test.mjs +75 -1
  111. package/clients/cli/commands/doctor.mjs +53 -16
  112. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  113. package/clients/cli/commands/integration.mjs +1 -0
  114. package/clients/cli/commands/search.mjs +11 -2
  115. package/clients/cli/commands/setup-nudge.test.mjs +6 -0
  116. package/clients/cli/commands/template.doc.mjs +23 -6
  117. package/clients/cli/commands/template.mjs +4 -91
  118. package/clients/cli/commands/text-json-parity.test.mjs +2 -1
  119. package/clients/cli/index.mjs +8 -0
  120. package/clients/cli/lib/manifest.mjs +9 -2
  121. package/foundation/agent-docs/agent-docs.mjs +1 -0
  122. package/foundation/agent-docs/agent-docs.test.mjs +10 -1
  123. package/foundation/config/project.d.mts +12 -11
  124. package/foundation/config/project.mjs +73 -59
  125. package/foundation/config/project.test.mjs +141 -5
  126. package/foundation/discovery/authoring-self-docs.test.mjs +17 -7
  127. package/foundation/discovery/cli-self-docs.d.mts +40 -34
  128. package/foundation/discovery/cli-self-docs.mjs +91 -115
  129. package/foundation/discovery/cli-self-docs.test.mjs +104 -166
  130. package/foundation/discovery/component-discovery.d.mts +38 -0
  131. package/foundation/discovery/component-discovery.mjs +48 -0
  132. package/foundation/discovery/docs-discovery.d.mts +105 -8
  133. package/foundation/discovery/docs-discovery.mjs +177 -13
  134. package/foundation/discovery/docs-discovery.test.mjs +56 -17
  135. package/foundation/discovery/docs-output-budget.d.mts +2 -2
  136. package/foundation/discovery/docs-output-budget.mjs +1 -1
  137. package/foundation/discovery/docs-section-key.d.mts +9 -2
  138. package/foundation/discovery/docs-section-key.mjs +15 -1
  139. package/foundation/discovery/template-adapter.d.mts +92 -6
  140. package/foundation/discovery/template-adapter.mjs +453 -17
  141. package/foundation/discovery/template-adapter.test.mjs +42 -0
  142. package/foundation/discovery/template-conflict-release.d.mts +13 -0
  143. package/foundation/discovery/template-conflict-release.mjs +40 -0
  144. package/foundation/discovery/template-conflict-release.test.mjs +40 -0
  145. package/foundation/doc-compiler/bundle.mjs +61 -1
  146. package/foundation/doc-compiler/bundle.test.mjs +21 -10
  147. package/foundation/doc-compiler/compile.d.mts +113 -132
  148. package/foundation/doc-compiler/compile.mjs +52 -6
  149. package/foundation/doc-compiler/diagnostics.mjs +28 -0
  150. package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
  151. package/foundation/doc-compiler/inputs.d.mts +2 -2
  152. package/foundation/doc-compiler/inputs.mjs +6 -1
  153. package/foundation/doc-compiler/ir.mjs +7 -0
  154. package/foundation/doc-compiler/lenses.d.mts +3 -2
  155. package/foundation/doc-compiler/lenses.mjs +2 -1
  156. package/foundation/doc-compiler/links.d.mts +135 -0
  157. package/foundation/doc-compiler/links.mjs +253 -0
  158. package/foundation/doc-compiler/links.test.mjs +139 -0
  159. package/foundation/doc-compiler/lower-doc.test.mjs +5 -2
  160. package/foundation/doc-compiler/read.d.mts +3 -2
  161. package/foundation/doc-compiler/read.mjs +6 -1
  162. package/foundation/doc-compiler/tree.d.mts +288 -0
  163. package/foundation/doc-compiler/tree.mjs +876 -0
  164. package/foundation/doc-compiler/tree.test.mjs +598 -0
  165. package/foundation/integrations/autolink.test.mjs +1 -1
  166. package/foundation/integrations/cli-requirement.d.mts +45 -0
  167. package/foundation/integrations/cli-requirement.mjs +154 -0
  168. package/foundation/integrations/cli-requirement.test.mjs +109 -0
  169. package/foundation/integrations/contribution-inventory.d.mts +2 -1
  170. package/foundation/integrations/contribution-inventory.mjs +10 -4
  171. package/foundation/integrations/contribution-inventory.test.mjs +19 -0
  172. package/foundation/integrations/integration-warnings.d.mts +9 -2
  173. package/foundation/integrations/integration-warnings.mjs +51 -26
  174. package/foundation/integrations/integration-warnings.test.mjs +74 -1
  175. package/foundation/integrations/validate-contributions.mjs +25 -27
  176. package/foundation/response/response-types.doc.d.mts +5 -1
  177. package/foundation/response/response-types.doc.mjs +18 -9
  178. package/foundation/xle/expand.mjs +1 -1
  179. package/foundation/xle/xle.test.mjs +13 -0
  180. package/package.json +9 -9
  181. package/assets/docs/cli.doc.mjs +0 -15
@@ -4,12 +4,9 @@
4
4
  * @file template command — thin CLI wrapper around api/template.mjs
5
5
  */
6
6
 
7
- import * as path from 'node:path';
8
- import * as fs from 'node:fs';
9
7
  import {jsonOut} from '../../../foundation/response/json.mjs';
10
8
  import {emit, section, text, records, code} from '../formatters/index.mjs';
11
9
  import {cliError} from '../lib/cli-error.mjs';
12
- import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
13
10
  import {template as templateApi} from '../../../api/template/template.mjs';
14
11
  import {Project} from '../../../foundation/config/project.mjs';
15
12
  import {warnOnIntegrationIssues} from '../../../foundation/integrations/integration-warnings.mjs';
@@ -21,18 +18,6 @@ import {doc as templateFn} from '../../../api/template/template.doc.mjs';
21
18
 
22
19
  export {discoverTemplates, listTemplates} from '../../../api/template/template.mjs';
23
20
 
24
- /**
25
- * A template entry as produced by the discover* helpers in api/template.mjs.
26
- * The api layer returns these as `object[]`; this local shape captures the
27
- * fields the command consumes. Remove once api/template.mjs exports a precise
28
- * type for its discovered templates.
29
- * @typedef {object} DiscoveredTemplate
30
- * @property {'page' | 'block'} type
31
- * @property {string} dirName
32
- * @property {string} name
33
- * @property {string} filePath
34
- */
35
-
36
21
  /**
37
22
  * The discriminated response returned by the template API. The api layer
38
23
  * currently declares `{type: string, data: unknown}`; narrow it here to the
@@ -89,36 +74,11 @@ export function registerTemplate(program) {
89
74
  // doctor integration validate. Best-effort; suppressed in --json mode.
90
75
  try {
91
76
  const project = await Project.load(process.cwd());
92
- await warnOnIntegrationIssues(
93
- /** @type {Array<import('../../../foundation/integrations/integrations.mjs').LoadedIntegration>} */ (
94
- project.loadedIntegrations
95
- ),
96
- {json},
97
- );
77
+ await warnOnIntegrationIssues(project, {json});
98
78
  } catch {
99
79
  // Never let the nudge break the command.
100
80
  }
101
81
 
102
- // Pre-flight overwrite check (only when we'd actually copy a file).
103
- // The API resolves the destination; we need to mirror its logic
104
- // narrowly enough to detect collisions before invoking it.
105
- if (
106
- name &&
107
- targetPath &&
108
- !options.list &&
109
- !options.skeleton &&
110
- !options.cdn
111
- ) {
112
- const collision = await detectTemplateCollision(name, targetPath);
113
- if (collision && !options.overwrite) {
114
- const rel = path.relative(process.cwd(), collision) || collision;
115
- const msg =
116
- `Refusing to overwrite existing file ${rel}. ` +
117
- `Re-run with --overwrite (or -f) to replace it.`;
118
- return cliError(msg, {code: ERROR_CODES.ERR_FILE_EXISTS});
119
- }
120
- }
121
-
122
82
  /** @type {TemplateResponse} */
123
83
  let result;
124
84
  try {
@@ -156,12 +116,14 @@ export function registerTemplate(program) {
156
116
  // isn't the built-in core package.
157
117
  /** @param {import('../../../api/template/template.type.mjs').TemplateListEntry} t */
158
118
  const toRow = t => ({
119
+ id: t.id,
159
120
  name: t.isReady ? t.name : `${t.name} (WIP)`,
160
121
  description: t.description,
161
122
  package:
162
123
  t.package && t.package !== '@astryxdesign/core' ? t.package : '',
124
+ replaces: t.replaces ?? '',
163
125
  });
164
- const fields = ['name', 'description', 'package'];
126
+ const fields = ['id', 'name', 'description', 'package', 'replaces'];
165
127
  emit(
166
128
  pages.length > 0 && section('Page Templates'),
167
129
  pages.length > 0 && records(pages.map(toRow), {fields}),
@@ -229,52 +191,3 @@ export function registerTemplate(program) {
229
191
  },
230
192
  });
231
193
  }
232
-
233
- /**
234
- * Mirror the destination-resolution logic in api/template.mjs so we can
235
- * detect a clobber before invoking the API.
236
- *
237
- * Returns the absolute destination file path if it already exists, or
238
- * `null` otherwise (template missing, no collision, or list/skeleton mode).
239
- *
240
- * Path-safety enforcement happens inside the API; here we only need
241
- * enough precision to check existence — a false negative just means the
242
- * API will catch the issue and abort.
243
- *
244
- * @param {string} name
245
- * @param {string} targetPath
246
- * @returns {Promise<string | null>}
247
- */
248
- async function detectTemplateCollision(name, targetPath) {
249
- const {discoverTemplates} = await import('../../../api/template/template.mjs');
250
- /** @type {DiscoveredTemplate[]} */
251
- let templates;
252
- try {
253
- templates = /** @type {DiscoveredTemplate[]} */ (
254
- await discoverTemplates(process.cwd())
255
- );
256
- } catch {
257
- return null;
258
- }
259
- const match = templates.find(t => t.dirName === name);
260
- if (!match) return null;
261
-
262
- // Resolve target as the API will. We can't call assertWithin here
263
- // because the API does it itself; we just need to know "is there a
264
- // file at the destination?".
265
- const resolved = path.resolve(process.cwd(), targetPath);
266
-
267
- // File-arg branch: targetPath looks like `./foo.tsx`.
268
- const {isFilePathArg} = await import('../../../foundation/fs/path-safety.mjs');
269
- let dest;
270
- if (isFilePathArg(targetPath)) {
271
- dest = resolved;
272
- } else {
273
- const fileName = match.type === 'block'
274
- ? path.basename(match.filePath)
275
- : 'page.tsx';
276
- dest = path.join(resolved, fileName);
277
- }
278
-
279
- return fs.existsSync(dest) ? dest : null;
280
- }
@@ -310,7 +310,8 @@ const CASES = [
310
310
  name: 'docs',
311
311
  args: ['docs'],
312
312
  jsonFieldAllowlist: [
313
- 'package — omitted to preserve the published 0.6 docs list text contract',
313
+ 'topic — inline layout lead column, not a key: value record',
314
+ 'description — inline layout trailing column',
314
315
  ],
315
316
  },
316
317
  {
@@ -276,6 +276,12 @@ const commands = [
276
276
  ];
277
277
 
278
278
  const SETUP_NUDGE_EXEMPT = new Set(['init', 'agent-docs']);
279
+ /** An integration package's manifest: the package is not an app to set up. */
280
+ const INTEGRATION_MANIFEST_FILES = [
281
+ 'astryx.integration.ts',
282
+ 'astryx.integration.mjs',
283
+ 'astryx.integration.js',
284
+ ];
279
285
 
280
286
  /**
281
287
  * Build a fresh, fully-wired Astryx CLI program (root options, hooks, all
@@ -519,6 +525,8 @@ export async function createProgram() {
519
525
  if (SETUP_NUDGE_EXEMPT.has(actionCommand.name())) return;
520
526
  const cwd = process.cwd();
521
527
  if (!fs.existsSync(path.join(cwd, 'package.json'))) return; // not a project
528
+ // An integration package is not an app: `init` is not its next step.
529
+ if (INTEGRATION_MANIFEST_FILES.some(file => fs.existsSync(path.join(cwd, file)))) return;
522
530
  if (isAstryxInitialized(cwd)) return; // already set up — stay quiet
523
531
  // Same wording as the core/cli postinstall nudges. #4151's getCliInvocation()
524
532
  // renders the correct form for THIS project — scoped `npx @astryxdesign/cli`
@@ -57,7 +57,13 @@ export const RESPONSE_TYPES = {
57
57
  'component.detail.showcase',
58
58
  'component.detail.blocks',
59
59
  ],
60
- docs: ['docs.list', 'docs.index', 'docs.detail', 'docs.detail.section'],
60
+ docs: [
61
+ 'docs.list',
62
+ 'docs.index',
63
+ 'docs.detail',
64
+ 'docs.detail.section',
65
+ 'docs.node',
66
+ ],
61
67
  blog: ['blog.list', 'blog.detail'],
62
68
  discover: [
63
69
  'discover.list',
@@ -110,8 +116,9 @@ const EXAMPLES = {
110
116
  docs: [
111
117
  'astryx docs',
112
118
  'astryx docs spacing --json',
113
- 'astryx docs theme --index',
119
+ 'astryx docs theme',
114
120
  'astryx docs theme quick-start',
121
+ 'astryx docs cli/integrations --full',
115
122
  ],
116
123
  discover: ['astryx discover --json'],
117
124
  search: [
@@ -486,6 +486,7 @@ export function generateCompressedIndex(
486
486
  if (resolvedTopics.length > 0) {
487
487
  lines.push(` docs <topic> ${resolvedTopics.join(', ')}`);
488
488
  }
489
+ lines.push(' docs cli commands, API reference, integration authoring (one level at a time)');
489
490
  lines.push(' swizzle <Name> eject component source for deep customization');
490
491
  lines.push(' upgrade --apply run after any Astryx or integration dependency bump');
491
492
  const appendCount = agentDocs.reduce(
@@ -134,7 +134,6 @@ describe('generateCompressedIndex', () => {
134
134
  const line = topicLine(generateCompressedIndex('1.0.0'));
135
135
  for (const topic of [
136
136
  'getting-started',
137
- 'cli-integrations',
138
137
  'browser-support',
139
138
  'styling-libraries',
140
139
  'working-with-ai',
@@ -143,6 +142,16 @@ describe('generateCompressedIndex', () => {
143
142
  }
144
143
  });
145
144
 
145
+ it('points to the CLI docs tree on a line of its own', () => {
146
+ // The integration guide lives in the docs tree now (cli/integrations), so
147
+ // the topic line no longer names it; the tree's entry point does.
148
+ const block = generateCompressedIndex('1.0.0');
149
+ expect(block).toContain(
150
+ ' docs cli commands, API reference, integration authoring (one level at a time)',
151
+ );
152
+ expect(topicLine(block)).not.toContain('cli-integrations');
153
+ });
154
+
146
155
  it('lists the topics it is given, so an integration’s reach the agent', () => {
147
156
  const line = topicLine(
148
157
  generateCompressedIndex('1.0.0', {topics: ['tokens', 'deploying']}),
@@ -95,9 +95,9 @@ export class Project {
95
95
  /**
96
96
  * Core + integration component ownership records. Wraps
97
97
  * discoverOwnedComponents for core and discoverIntegrationComponents (via
98
- * discoverOwnedComponents) for integrations, but applies the skip+warn
99
- * policy per integration: a broken integration's components are skipped and
100
- * its issues collected, never thrown. Memoized per instance.
98
+ * discoverOwnedComponents) for integrations. Invalid component records are
99
+ * omitted and reported; valid component siblings and other contribution kinds
100
+ * remain available. Memoized per instance.
101
101
  *
102
102
  * @returns {Promise<Array<{name: string, package: string, group: string|null, docPath: string|null, sourcePath: string|null, issuesUrl: string|undefined}>>}
103
103
  */
@@ -110,10 +110,11 @@ export class Project {
110
110
  issuesUrl: string | undefined;
111
111
  }>>;
112
112
  /**
113
- * Core + integration templates, type-tagged. Wraps discoverTemplates (core +
114
- * external blocks) and discoverIntegrationTemplatesForOne per integration so
115
- * a broken integration's templates are skipped and its issues collected.
116
- * Memoized per instance.
113
+ * Core + integration templates, type-tagged, with valid integration
114
+ * replacements projected over their Core targets. Wraps raw template discovery
115
+ * (Core + external blocks) and discoverIntegrationTemplatesForOne per integration
116
+ * so unusable template files are reported and omitted while valid siblings
117
+ * remain available. Memoized per instance.
117
118
  *
118
119
  * @returns {Promise<Array<object>>}
119
120
  */
@@ -121,8 +122,8 @@ export class Project {
121
122
  /**
122
123
  * Bundled source themes plus themes contributed by installed integrations.
123
124
  * Each record keeps its package owner and source directory so callers can
124
- * both list and copy it without reconstructing paths. A broken integration's
125
- * themes are skipped under the same issue policy as every other kind.
125
+ * both list and copy it without reconstructing paths. A broken theme
126
+ * contribution is reported without hiding the package's other valid kinds.
126
127
  *
127
128
  * @returns {Promise<import('../discovery/theme-discovery.mjs').DiscoveredTheme[]>}
128
129
  */
@@ -145,8 +146,8 @@ export class Project {
145
146
  /**
146
147
  * Core registry transforms + integration codemods for an upgrade range.
147
148
  * Wraps getTransformsBetween (core) and discoverIntegrationCodemods /
148
- * selectIntegrationCodemods (integrations). A broken integration's codemods
149
- * are skipped (issue collected) rather than failing the whole resolution.
149
+ * selectIntegrationCodemods (integrations). An invalid codemod contribution
150
+ * is reported and omitted without hiding other valid contribution kinds.
150
151
  * Memoized per (from, to) key.
151
152
  *
152
153
  * @param {string} fromVersion exclusive lower bound
@@ -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
  }