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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/README.md +19 -17
  2. package/api/component/_adapter.d.mts +6 -12
  3. package/api/component/_adapter.mjs +20 -10
  4. package/api/component/component.mjs +60 -12
  5. package/api/component/list/list.mjs +3 -2
  6. package/api/docs/_adapter.d.mts +209 -28
  7. package/api/docs/_adapter.mjs +667 -35
  8. package/api/docs/detail/detail.mjs +11 -3
  9. package/api/docs/detail/section/section.mjs +24 -13
  10. package/api/docs/detail/section/section.test.mjs +15 -6
  11. package/api/docs/docs.d.mts +5 -3
  12. package/api/docs/docs.doc.mjs +35 -15
  13. package/api/docs/docs.mjs +44 -8
  14. package/api/docs/docs.test.mjs +158 -4
  15. package/api/docs/docs.type.d.mts +165 -2
  16. package/api/docs/docs.type.mjs +101 -3
  17. package/api/docs/index/index.mjs +11 -3
  18. package/api/docs/index/index.test.mjs +1 -1
  19. package/api/docs/integration-tree.test.mjs +547 -0
  20. package/api/docs/integrationDocs.test.mjs +14 -14
  21. package/api/docs/list/list.mjs +25 -5
  22. package/api/docs/node/node.d.mts +43 -0
  23. package/api/docs/node/node.mjs +192 -0
  24. package/api/doctor/doctor.d.mts +30 -2
  25. package/api/doctor/doctor.mjs +147 -8
  26. package/api/doctor/doctor.test.mjs +95 -7
  27. package/api/index.d.mts +1 -1
  28. package/api/index.mjs +1 -0
  29. package/api/init/init.doc.mjs +1 -1
  30. package/api/integration/add-contribution.d.mts +2 -1
  31. package/api/integration/add-contribution.mjs +107 -5
  32. package/api/integration/add-contribution.test.mjs +137 -0
  33. package/api/integration/authoring-checks.mjs +125 -28
  34. package/api/integration/authoring-checks.test.mjs +171 -3
  35. package/api/integration/authoring-checks.type.mjs +6 -1
  36. package/api/integration/integration-authoring.type.d.mts +2 -0
  37. package/api/integration/integration-authoring.type.mjs +2 -0
  38. package/api/integration/integrationAdd.doc.mjs +6 -0
  39. package/api/integration/integrationAddDoc.doc.mjs +7 -1
  40. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  41. package/api/integration/integrationPackCheck.doc.mjs +1 -1
  42. package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
  43. package/api/integration/integrationTemplateConflicts.doc.mjs +3 -0
  44. package/api/integration/pack-check.mjs +34 -0
  45. package/api/integration/pack-check.test.mjs +121 -0
  46. package/api/integration/pack-check.type.d.mts +26 -2
  47. package/api/integration/pack-check.type.mjs +14 -1
  48. package/api/integration/template-conflict-compatibility.test.mjs +73 -0
  49. package/api/integration/validate-integration.test.mjs +3 -3
  50. package/api/integration/validateIntegration.doc.mjs +1 -1
  51. package/api/json/index.ts +2 -0
  52. package/api/layout/_adapter.mjs +20 -5
  53. package/api/search/search.d.mts +26 -1
  54. package/api/search/search.doc.mjs +4 -3
  55. package/api/search/search.mjs +308 -29
  56. package/api/search/search.test.mjs +91 -2
  57. package/api/search/search.type.d.mts +13 -1
  58. package/api/search/search.type.mjs +4 -1
  59. package/api/template/list/list.mjs +1 -0
  60. package/api/template/template-integration.test.mjs +1022 -3
  61. package/api/template/template.doc.mjs +27 -7
  62. package/api/template/template.mjs +45 -8
  63. package/api/template/template.type.d.mts +6 -8
  64. package/api/template/template.type.mjs +3 -2
  65. package/api/theme/template/template.test.mjs +5 -0
  66. package/api/theme/themeTemplate.doc.mjs +1 -1
  67. package/assets/codemods/transforms/next/__tests__/migrate-native-picker-to-presentation.test.mjs +63 -0
  68. package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +4 -0
  69. package/assets/codemods/transforms/next/index.mjs +8 -0
  70. package/assets/codemods/transforms/next/migrate-native-picker-to-presentation.mjs +148 -0
  71. package/assets/docs/getting-started.doc.mjs +2 -2
  72. package/assets/docs/principles.doc.mjs +6 -6
  73. package/assets/docs/styling-libraries.doc.mjs +2 -2
  74. package/assets/docs/styling.doc.mjs +4 -4
  75. package/assets/docs/theme.doc.mjs +3 -3
  76. package/assets/docs/tokens.doc.mjs +1 -1
  77. package/assets/docs/tree/api.doc.mjs +30 -0
  78. package/assets/docs/tree/cli.doc.mjs +23 -0
  79. package/assets/docs/tree/commands.doc.mjs +25 -0
  80. package/assets/docs/{cli-integrations.doc.mjs → tree/integrations.doc.mjs} +37 -9
  81. package/assets/docs/tree/integrations.test.mjs +62 -0
  82. package/assets/docs/tree/writing-docs.doc.mjs +286 -0
  83. package/assets/templates/blocks/components/DateInput/DateInputDateRange.tsx +1 -1
  84. package/assets/templates/blocks/components/TimeInput/TimeInputConstrained.tsx +1 -0
  85. package/authoring/debug/parse.d.mts +3 -3
  86. package/authoring/doctypes/_schema.d.mts +71 -141
  87. package/authoring/doctypes/_schema.mjs +29 -2
  88. package/authoring/doctypes/base/graph-fields.doc.mjs +7 -5
  89. package/authoring/doctypes/base/type.ts +6 -5
  90. package/authoring/doctypes/command/command.doc.mjs +1 -1
  91. package/authoring/doctypes/command/type.ts +2 -2
  92. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  93. package/authoring/doctypes/enum/type.ts +1 -1
  94. package/authoring/doctypes/function/function.doc.mjs +3 -2
  95. package/authoring/doctypes/function/type.ts +3 -2
  96. package/authoring/doctypes/load-contract.test.mjs +1 -1
  97. package/authoring/doctypes/namespace/namespace.doc.mjs +6 -10
  98. package/authoring/doctypes/namespace/parse.test.mjs +23 -25
  99. package/authoring/doctypes/namespace/type.ts +5 -2
  100. package/authoring/doctypes/parse.mjs +3 -2
  101. package/authoring/doctypes/reference/reference.doc.mjs +6 -4
  102. package/authoring/doctypes/reference/type.ts +10 -8
  103. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  104. package/authoring/doctypes/schema/type.ts +1 -1
  105. package/authoring/doctypes/template/parse.d.mts +2 -0
  106. package/authoring/doctypes/template/parse.mjs +4 -0
  107. package/authoring/doctypes/template/parse.test.mjs +18 -0
  108. package/authoring/doctypes/template/template.doc.mjs +6 -0
  109. package/authoring/doctypes/template/type.ts +8 -0
  110. package/authoring/identity/identity.doc.mjs +2 -2
  111. package/authoring/index.d.ts +1 -0
  112. package/authoring/integration/type.ts +1 -1
  113. package/clients/cli/commands/build-theme.adaptations.test.mjs +100 -1
  114. package/clients/cli/commands/build-theme.mjs +11 -45
  115. package/clients/cli/commands/build.mjs +5 -2
  116. package/clients/cli/commands/component/index.mjs +1 -1
  117. package/clients/cli/commands/component-ownership.test.mjs +3 -3
  118. package/clients/cli/commands/discover.broken-integration.test.mjs +7 -8
  119. package/clients/cli/commands/discover.mjs +1 -1
  120. package/clients/cli/commands/docs.doc.mjs +20 -8
  121. package/clients/cli/commands/docs.mjs +182 -68
  122. package/clients/cli/commands/docs.test.mjs +120 -16
  123. package/clients/cli/commands/doctor-integration-docs.doc.mjs +2 -2
  124. package/clients/cli/commands/doctor-integration-templates.doc.mjs +14 -7
  125. package/clients/cli/commands/doctor-integration.test.mjs +75 -1
  126. package/clients/cli/commands/doctor.mjs +53 -16
  127. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  128. package/clients/cli/commands/integration.mjs +1 -0
  129. package/clients/cli/commands/search.mjs +11 -2
  130. package/clients/cli/commands/setup-nudge.test.mjs +6 -0
  131. package/clients/cli/commands/template.doc.mjs +23 -6
  132. package/clients/cli/commands/template.mjs +4 -91
  133. package/clients/cli/commands/text-json-parity.test.mjs +719 -0
  134. package/clients/cli/commands/theme-targets.behavior.test.mjs +4 -3
  135. package/clients/cli/commands/upgrade.mjs +26 -7
  136. package/clients/cli/formatters/index.mjs +2 -0
  137. package/clients/cli/formatters/index.test.mjs +6 -0
  138. package/clients/cli/index.mjs +8 -0
  139. package/clients/cli/lib/manifest.mjs +9 -2
  140. package/foundation/agent-docs/agent-docs.mjs +1 -0
  141. package/foundation/agent-docs/agent-docs.test.mjs +10 -1
  142. package/foundation/config/project.d.mts +12 -11
  143. package/foundation/config/project.mjs +73 -59
  144. package/foundation/config/project.test.mjs +141 -5
  145. package/foundation/discovery/authoring-self-docs.test.mjs +20 -9
  146. package/foundation/discovery/cli-self-docs.d.mts +40 -34
  147. package/foundation/discovery/cli-self-docs.mjs +91 -115
  148. package/foundation/discovery/cli-self-docs.test.mjs +104 -166
  149. package/foundation/discovery/component-discovery.d.mts +38 -0
  150. package/foundation/discovery/component-discovery.mjs +48 -0
  151. package/foundation/discovery/docs-discovery.d.mts +105 -8
  152. package/foundation/discovery/docs-discovery.mjs +183 -18
  153. package/foundation/discovery/docs-discovery.test.mjs +63 -27
  154. package/foundation/discovery/docs-output-budget.d.mts +2 -2
  155. package/foundation/discovery/docs-output-budget.mjs +1 -1
  156. package/foundation/discovery/docs-section-key.d.mts +28 -10
  157. package/foundation/discovery/docs-section-key.mjs +134 -33
  158. package/foundation/discovery/docs-section-key.test.mjs +41 -19
  159. package/foundation/discovery/template-adapter.d.mts +92 -6
  160. package/foundation/discovery/template-adapter.mjs +453 -17
  161. package/foundation/discovery/template-adapter.test.mjs +42 -0
  162. package/foundation/discovery/template-conflict-release.d.mts +13 -0
  163. package/foundation/discovery/template-conflict-release.mjs +40 -0
  164. package/foundation/discovery/template-conflict-release.test.mjs +40 -0
  165. package/foundation/doc-compiler/bundle.mjs +61 -1
  166. package/foundation/doc-compiler/bundle.test.mjs +21 -10
  167. package/foundation/doc-compiler/compile.d.mts +113 -132
  168. package/foundation/doc-compiler/compile.mjs +57 -10
  169. package/foundation/doc-compiler/diagnostics.mjs +28 -0
  170. package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
  171. package/foundation/doc-compiler/inputs.d.mts +2 -2
  172. package/foundation/doc-compiler/inputs.mjs +6 -1
  173. package/foundation/doc-compiler/ir.mjs +7 -0
  174. package/foundation/doc-compiler/lenses.d.mts +3 -2
  175. package/foundation/doc-compiler/lenses.mjs +2 -1
  176. package/foundation/doc-compiler/links.d.mts +135 -0
  177. package/foundation/doc-compiler/links.mjs +253 -0
  178. package/foundation/doc-compiler/links.test.mjs +139 -0
  179. package/foundation/doc-compiler/lower-doc.test.mjs +5 -2
  180. package/foundation/doc-compiler/read.d.mts +3 -2
  181. package/foundation/doc-compiler/read.mjs +6 -1
  182. package/foundation/doc-compiler/tree.d.mts +288 -0
  183. package/foundation/doc-compiler/tree.mjs +876 -0
  184. package/foundation/doc-compiler/tree.test.mjs +598 -0
  185. package/foundation/integrations/autolink.test.mjs +1 -1
  186. package/foundation/integrations/cli-requirement.d.mts +45 -0
  187. package/foundation/integrations/cli-requirement.mjs +154 -0
  188. package/foundation/integrations/cli-requirement.test.mjs +109 -0
  189. package/foundation/integrations/contribution-inventory.d.mts +2 -1
  190. package/foundation/integrations/contribution-inventory.mjs +10 -4
  191. package/foundation/integrations/contribution-inventory.test.mjs +19 -0
  192. package/foundation/integrations/integration-warnings.d.mts +9 -2
  193. package/foundation/integrations/integration-warnings.mjs +51 -26
  194. package/foundation/integrations/integration-warnings.test.mjs +74 -1
  195. package/foundation/integrations/validate-contributions.mjs +25 -27
  196. package/foundation/response/response-types.doc.d.mts +5 -1
  197. package/foundation/response/response-types.doc.mjs +18 -9
  198. package/foundation/xle/expand.mjs +1 -1
  199. package/foundation/xle/xle.test.mjs +13 -0
  200. package/package.json +9 -9
  201. package/assets/docs/cli.doc.mjs +0 -15
@@ -17,8 +17,9 @@ describe('astryx theme targets', () => {
17
17
  const {status, stdout} = await runCli(['theme', 'targets', 'Switch']);
18
18
 
19
19
  expect(status).toBe(0);
20
- expect(stdout).toMatch(/^switch\s+Switch\s+size\s+checked, disabled$/m);
21
- expect(stdout).toMatch(/^switch-thumb\s+Switch\s+size\s+checked$/m);
20
+ // Inline layout: key component - props - states - className
21
+ expect(stdout).toMatch(/^switch\s+Switch - size - checked, disabled - astryx-switch$/m);
22
+ expect(stdout).toMatch(/^switch-thumb\s+Switch - size - checked - astryx-switch-thumb$/m);
22
23
  expect(stdout).toMatch(/4 across 1 component/);
23
24
  });
24
25
 
@@ -28,7 +29,7 @@ describe('astryx theme targets', () => {
28
29
  expect(status).toBe(0);
29
30
  expect(stdout).toMatch(/^popover\s{2,}Popover/m);
30
31
  expect(stdout).toMatch(
31
- /^popover-surface \[deprecated; use popover\]\s{2,}Popover/m,
32
+ /^popover-surface\s{2,}Popover - astryx-popover-surface - deprecated; use popover$/m,
32
33
  );
33
34
  });
34
35
 
@@ -13,6 +13,7 @@
13
13
  */
14
14
 
15
15
  import {jsonOut, jsonError} from '../../../foundation/response/json.mjs';
16
+ import {emit, section, records} from '../formatters/index.mjs';
16
17
  import {logger} from '../../../api/logger.mjs';
17
18
  import {AstryxError} from '../../../api/error.mjs';
18
19
  import {defineCommand} from '../lib/define-command.mjs';
@@ -33,27 +34,45 @@ export function registerUpgrade(program) {
33
34
  */
34
35
  async options => {
35
36
  const json = program.opts().json || false;
36
- logger.setSilent(json);
37
+ const isList = Boolean(options.list);
38
+ // Silence the logger for --list so the handler renders from the
39
+ // result (parity with --json), and for --json as before.
40
+ // Re-enable on error so handled failures still print.
41
+ logger.setSilent(json || isList);
37
42
 
38
43
  /** @type {import('../../../api/upgrade/upgrade.type.mjs').UpgradeListResponse | import('../../../api/upgrade/upgrade.type.mjs').UpgradeRegistryResponse | import('../../../api/upgrade/upgrade.type.mjs').UpgradeStatusResponse | import('../../../api/upgrade/upgrade.type.mjs').UpgradeRunResponse} */
39
44
  let result;
40
45
  try {
41
46
  result = await upgradeApi(options, {cwd: process.cwd()});
42
47
  } catch (e) {
43
- // Handled failures throw AstryxError: --json emits the structured
44
- // envelope (byte-identical to the old inline jsonError) + exits 1;
45
- // human mode already saw the error line + outro via the logger, so we
46
- // just set the exit code. Anything else is unexpected — let the
47
- // top-level boundary in bin/astryx.mjs format it as before.
48
+ // Re-enable the logger so the error is visible in text mode.
49
+ // For --list the logger was silent; for other modes the API
50
+ // already printed the error before throwing.
51
+ logger.setSilent(json);
48
52
  if (e instanceof AstryxError) {
49
53
  if (json) jsonError(e.message, undefined, e.code);
50
- else process.exitCode = 1;
54
+ else {
55
+ // The logger was silent only for --list; replay the error there.
56
+ // Non-list failures were already printed by the API.
57
+ if (isList) logger.error(e.message);
58
+ process.exitCode = 1;
59
+ }
51
60
  return NO_RESULT_SET;
52
61
  }
53
62
  throw e;
54
63
  }
55
64
 
56
65
  if (json) jsonOut(result);
66
+ else if (result.type === 'upgrade.list') {
67
+ // Render the list from the result, not the API logger, so the text
68
+ // carries the same fields the JSON does (name, title, version, optional).
69
+ emit(
70
+ section('Available codemods'),
71
+ records(result.data, {
72
+ fields: ['name', 'title', 'version', 'optional'],
73
+ }),
74
+ );
75
+ }
57
76
 
58
77
  const registrySummary =
59
78
  result.type === 'upgrade.registry'
@@ -152,6 +152,8 @@ function toAscii(s) {
152
152
  .replace(/[\u2018\u2019]/g, "'")
153
153
  .replace(/[\u201C\u201D]/g, '"')
154
154
  .replace(/\u2026/g, '...')
155
+ .replace(/\u2192/g, '->')
156
+ .replace(/\u2190/g, '<-')
155
157
  .replace(/\u00a0/g, ' ');
156
158
  }
157
159
 
@@ -117,6 +117,12 @@ describe('ASCII normalization', () => {
117
117
  expect(list(['Avatar \u2014 Group']).toString()).toBe('- Avatar - Group');
118
118
  });
119
119
 
120
+ it('converts Unicode arrows to ASCII arrows', () => {
121
+ expect(text('Rename items \u2192 options').toString()).toBe('Rename items -> options');
122
+ expect(text('options \u2190 items').toString()).toBe('options <- items');
123
+ expect(record({title: 'a \u2192 b'}).toString()).toBe('title: a -> b');
124
+ });
125
+
120
126
  it('leaves code verbatim (no normalization)', () => {
121
127
  expect(code('a \u2014 b').toString()).toBe('a \u2014 b');
122
128
  });
@@ -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
  }