@astryxdesign/cli 0.7.2-canary.7c0f850 → 0.7.2-canary.80d2f41

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.
@@ -15,12 +15,18 @@
15
15
  * ShadCN-copied compositions → post-codemod hooks → render + refresh agent docs
16
16
  * from final post-upgrade state. Integration DISCOVERY errors skip that
17
17
  * integration; execution errors abort before the agent-doc write.
18
+ *
19
+ * Core codemods ship inside the CLI, so a CLI older than the installed Core
20
+ * has none for the releases after its own version. Every result past the
21
+ * up-to-date exit then carries `cliBehindCore`, and no human line says the
22
+ * upgrade finished; the warning names the same upgrade on the matching CLI.
18
23
  */
19
24
 
20
25
  import * as fs from 'node:fs';
21
26
  import * as path from 'node:path';
22
27
  import {
23
28
  detectInstalledTargetVersion,
29
+ detectCliBehindCore,
24
30
  prepareAgentDocsRefresh,
25
31
  applyAgentDocsRefresh,
26
32
  inspectAgentDocs,
@@ -42,6 +48,7 @@ import {
42
48
  statusUpToDate,
43
49
  statusNoCodemods,
44
50
  statusConfigFixable,
51
+ logCliBehindCore,
45
52
  } from '../status/status.mjs';
46
53
  import {semverGte} from '../../../foundation/env/semver.mjs';
47
54
  import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
@@ -195,6 +202,17 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
195
202
  });
196
203
  }
197
204
 
205
+ // Past the up-to-date exit, codemods are needed through targetVersion. A
206
+ // CLI older than that has none for the releases after its own version.
207
+ const cliBehindCore = detectCliBehindCore({
208
+ from: currentVersion,
209
+ to: targetVersion,
210
+ packageName: installed.packageName,
211
+ options,
212
+ cwd,
213
+ sourcePath: path_,
214
+ });
215
+
198
216
  const versionManifests = await getCoreVersionManifests(
199
217
  currentVersion,
200
218
  targetVersion,
@@ -243,6 +261,7 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
243
261
  skipCodemods,
244
262
  root: cwd,
245
263
  protection,
264
+ coversTarget: !cliBehindCore,
246
265
  });
247
266
  const coreResult =
248
267
  codemodResult && 'totalFilesChanged' in codemodResult
@@ -271,6 +290,7 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
271
290
  for (const item of protectedFiles) {
272
291
  logger.error(` ${item.file} — ${item.declarations.join('; ')}`);
273
292
  }
293
+ if (cliBehindCore) logCliBehindCore(cliBehindCore, targetVersion);
274
294
  logger.log('Upgrade incomplete: protected changes remain\n');
275
295
  return {
276
296
  type: 'upgrade.run',
@@ -299,6 +319,7 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
299
319
  complete: false,
300
320
  errorCode: 'ERR_CODEMOD_PROTECTED',
301
321
  errors: coreResult?.errors ?? [],
322
+ ...(cliBehindCore ? {cliBehindCore} : {}),
302
323
  },
303
324
  };
304
325
  }
@@ -316,6 +337,7 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
316
337
  to: targetVersion,
317
338
  configError: configErr.message,
318
339
  configCodemods: coreConfigCodemodNames,
340
+ cliBehindCore,
319
341
  agentDocs:
320
342
  /** @type {import('../upgrade.type.mjs').AgentDocsSummary} */ ({
321
343
  status: inspection.status,
@@ -381,6 +403,7 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
381
403
  to: targetVersion,
382
404
  agentDocs,
383
405
  ...(registryResult ? {registryCompositions: registryResult.summary} : {}),
406
+ cliBehindCore,
384
407
  });
385
408
  }
386
409
 
@@ -620,6 +643,7 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
620
643
  }
621
644
  receipt.errors = finalErrors;
622
645
  if (registryResult) receipt.registryCompositions = registryResult.summary;
646
+ if (cliBehindCore) receipt.cliBehindCore = cliBehindCore;
623
647
 
624
648
  if (protectedFiles.length > 0) {
625
649
  logger.error(
@@ -655,7 +679,12 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
655
679
  }
656
680
 
657
681
  const registryOk = receipt.registryCompositions?.ok ?? true;
658
- const done = apply ? 'Upgrade complete' : 'Dry run complete';
682
+ if (cliBehindCore) logCliBehindCore(cliBehindCore, targetVersion);
683
+ const done = cliBehindCore
684
+ ? 'Upgrade incomplete'
685
+ : apply
686
+ ? 'Upgrade complete'
687
+ : 'Dry run complete';
659
688
  logger.log(
660
689
  protectedFiles.length > 0
661
690
  ? 'Upgrade incomplete: protected changes remain\n'
@@ -13,27 +13,43 @@ export function statusUpToDate({ from, to, agentDocs, registryCompositions }: {
13
13
  registryCompositions?: import("../upgrade.type.mjs").RegistryCompositionSummary;
14
14
  }): import("../upgrade.type.mjs").UpgradeStatusResponse;
15
15
  /**
16
- * No core or integration codemods apply to the requested version range.
17
- * @param {{from: string, to: string, agentDocs: import('../upgrade.type.mjs').AgentDocsSummary, registryCompositions?: import('../upgrade.type.mjs').RegistryCompositionSummary}} data
16
+ * The one warning for a CLI older than the installed Core: it has no codemods
17
+ * for the releases after its own version, and the pinned command does. The
18
+ * command gets a line of its own, so it copies exactly, whatever quotes or
19
+ * backticks its arguments carry. On Windows it is written for PowerShell, and
20
+ * the warning says so.
21
+ * @param {import('../upgrade.type.mjs').CliBehindCore} cliBehindCore
22
+ * @param {string} to the installed Core version
23
+ * @param {string} [platform] the `process.platform` the command was printed
24
+ * for, as `quoteCommandArgument` and `commandInFolder` take it
25
+ */
26
+ export function logCliBehindCore({ cliVersion, command }: import("../upgrade.type.mjs").CliBehindCore, to: string, platform?: string): void;
27
+ /**
28
+ * No core or integration codemods apply to the requested version range. When
29
+ * the CLI is older than the installed Core, that only means this CLI has none:
30
+ * the result carries `cliBehindCore` and the human lines say so.
31
+ * @param {{from: string, to: string, agentDocs: import('../upgrade.type.mjs').AgentDocsSummary, registryCompositions?: import('../upgrade.type.mjs').RegistryCompositionSummary, cliBehindCore?: import('../upgrade.type.mjs').CliBehindCore | null}} data
18
32
  * @returns {import('../upgrade.type.mjs').UpgradeStatusResponse}
19
33
  */
20
- export function statusNoCodemods({ from, to, agentDocs, registryCompositions }: {
34
+ export function statusNoCodemods({ from, to, agentDocs, registryCompositions, cliBehindCore }: {
21
35
  from: string;
22
36
  to: string;
23
37
  agentDocs: import("../upgrade.type.mjs").AgentDocsSummary;
24
38
  registryCompositions?: import("../upgrade.type.mjs").RegistryCompositionSummary;
39
+ cliBehindCore?: import("../upgrade.type.mjs").CliBehindCore | null;
25
40
  }): import("../upgrade.type.mjs").UpgradeStatusResponse;
26
41
  /**
27
42
  * DRY-RUN only: the consumer's astryx.config fails strict validation, but a
28
43
  * pending core CONFIG codemod previewed a change that would repair it. Preview
29
44
  * the fix + report the exact `--apply` command; integrations are skipped here.
30
- * @param {{from: string, to: string, configError: string, configCodemods: string[], agentDocs: import('../upgrade.type.mjs').AgentDocsSummary}} data
45
+ * @param {{from: string, to: string, configError: string, configCodemods: string[], agentDocs: import('../upgrade.type.mjs').AgentDocsSummary, cliBehindCore?: import('../upgrade.type.mjs').CliBehindCore | null}} data
31
46
  * @returns {import('../upgrade.type.mjs').UpgradeStatusResponse}
32
47
  */
33
- export function statusConfigFixable({ from, to, configError, configCodemods, agentDocs }: {
48
+ export function statusConfigFixable({ from, to, configError, configCodemods, agentDocs, cliBehindCore }: {
34
49
  from: string;
35
50
  to: string;
36
51
  configError: string;
37
52
  configCodemods: string[];
38
53
  agentDocs: import("../upgrade.type.mjs").AgentDocsSummary;
54
+ cliBehindCore?: import("../upgrade.type.mjs").CliBehindCore | null;
39
55
  }): import("../upgrade.type.mjs").UpgradeStatusResponse;
@@ -10,6 +10,10 @@
10
10
  * - `config_fixable` — DRY-RUN only: the config fails strict validation but a
11
11
  * pending core CONFIG codemod would repair it; preview the fix, don't write.
12
12
  *
13
+ * `no_codemods` and `config_fixable` also carry `cliBehindCore` when the
14
+ * installed Core is newer than this CLI: the run cannot finish the upgrade, so
15
+ * neither says it is done, and `logCliBehindCore` names the command that can.
16
+ *
13
17
  * These builders own the exact human progress lines for their path (emitted via
14
18
  * the shared `logger`) and return the `upgrade.status` envelope; the caller
15
19
  * just returns what they hand back.
@@ -40,13 +44,43 @@ export function statusUpToDate({from, to, agentDocs, registryCompositions}) {
40
44
  }
41
45
 
42
46
  /**
43
- * No core or integration codemods apply to the requested version range.
44
- * @param {{from: string, to: string, agentDocs: import('../upgrade.type.mjs').AgentDocsSummary, registryCompositions?: import('../upgrade.type.mjs').RegistryCompositionSummary}} data
47
+ * The one warning for a CLI older than the installed Core: it has no codemods
48
+ * for the releases after its own version, and the pinned command does. The
49
+ * command gets a line of its own, so it copies exactly, whatever quotes or
50
+ * backticks its arguments carry. On Windows it is written for PowerShell, and
51
+ * the warning says so.
52
+ * @param {import('../upgrade.type.mjs').CliBehindCore} cliBehindCore
53
+ * @param {string} to the installed Core version
54
+ * @param {string} [platform] the `process.platform` the command was printed
55
+ * for, as `quoteCommandArgument` and `commandInFolder` take it
56
+ */
57
+ export function logCliBehindCore({cliVersion, command}, to, platform = process.platform) {
58
+ const shell = platform === 'win32' ? ' in PowerShell' : '';
59
+ logger.warn(
60
+ `This CLI (${cliVersion}) is older than the installed @astryxdesign/core (${to}): ` +
61
+ `it has no codemods for releases after ${cliVersion}, so it cannot finish this upgrade. ` +
62
+ `Run it${shell} with the CLI that matches your Core:`,
63
+ );
64
+ logger.warn(` ${command}`);
65
+ }
66
+
67
+ /**
68
+ * No core or integration codemods apply to the requested version range. When
69
+ * the CLI is older than the installed Core, that only means this CLI has none:
70
+ * the result carries `cliBehindCore` and the human lines say so.
71
+ * @param {{from: string, to: string, agentDocs: import('../upgrade.type.mjs').AgentDocsSummary, registryCompositions?: import('../upgrade.type.mjs').RegistryCompositionSummary, cliBehindCore?: import('../upgrade.type.mjs').CliBehindCore | null}} data
45
72
  * @returns {import('../upgrade.type.mjs').UpgradeStatusResponse}
46
73
  */
47
- export function statusNoCodemods({from, to, agentDocs, registryCompositions}) {
48
- logger.log('[ok] No codemods available for this version range.');
49
- logger.log(registryCompositions?.ok === false ? 'Finished with unresolved registry items\n' : 'Done\n');
74
+ export function statusNoCodemods({from, to, agentDocs, registryCompositions, cliBehindCore}) {
75
+ if (cliBehindCore) logCliBehindCore(cliBehindCore, to);
76
+ else logger.log('[ok] No codemods available for this version range.');
77
+ logger.log(
78
+ registryCompositions?.ok === false
79
+ ? 'Finished with unresolved registry items\n'
80
+ : cliBehindCore
81
+ ? 'Upgrade incomplete\n'
82
+ : 'Done\n',
83
+ );
50
84
  return {
51
85
  type: 'upgrade.status',
52
86
  data: {
@@ -55,6 +89,7 @@ export function statusNoCodemods({from, to, agentDocs, registryCompositions}) {
55
89
  to,
56
90
  agentDocs,
57
91
  ...(registryCompositions ? {registryCompositions} : {}),
92
+ ...(cliBehindCore ? {cliBehindCore} : {}),
58
93
  },
59
94
  };
60
95
  }
@@ -63,10 +98,10 @@ export function statusNoCodemods({from, to, agentDocs, registryCompositions}) {
63
98
  * DRY-RUN only: the consumer's astryx.config fails strict validation, but a
64
99
  * pending core CONFIG codemod previewed a change that would repair it. Preview
65
100
  * the fix + report the exact `--apply` command; integrations are skipped here.
66
- * @param {{from: string, to: string, configError: string, configCodemods: string[], agentDocs: import('../upgrade.type.mjs').AgentDocsSummary}} data
101
+ * @param {{from: string, to: string, configError: string, configCodemods: string[], agentDocs: import('../upgrade.type.mjs').AgentDocsSummary, cliBehindCore?: import('../upgrade.type.mjs').CliBehindCore | null}} data
67
102
  * @returns {import('../upgrade.type.mjs').UpgradeStatusResponse}
68
103
  */
69
- export function statusConfigFixable({from, to, configError, configCodemods, agentDocs}) {
104
+ export function statusConfigFixable({from, to, configError, configCodemods, agentDocs, cliBehindCore}) {
70
105
  const codemodFlags = configCodemods.map(name => `--codemod ${name}`).join(' ');
71
106
  const suggestedCommand = `astryx upgrade --from ${from} ${codemodFlags} --apply`;
72
107
  const guidance =
@@ -77,7 +112,8 @@ export function statusConfigFixable({from, to, configError, configCodemods, agen
77
112
  logger.warn(guidance);
78
113
  logger.log(` ${formatCliCommand(suggestedCommand)}`);
79
114
  logger.log('Integrations are skipped in this preview; they will be processed on the --apply run.');
80
- logger.log('Dry run complete\n');
115
+ if (cliBehindCore) logCliBehindCore(cliBehindCore, to);
116
+ logger.log(cliBehindCore ? 'Upgrade incomplete\n' : 'Dry run complete\n');
81
117
  return {
82
118
  type: 'upgrade.status',
83
119
  data: {
@@ -90,6 +126,7 @@ export function statusConfigFixable({from, to, configError, configCodemods, agen
90
126
  message: guidance,
91
127
  note: 'Integrations are skipped in this preview; they will be processed on the --apply run.',
92
128
  agentDocs,
129
+ ...(cliBehindCore ? {cliBehindCore} : {}),
93
130
  },
94
131
  };
95
132
  }
@@ -22,7 +22,9 @@ export const doc = {
22
22
  'loaded, so they can repair an invalid config. Also updates copied compositions from ' +
23
23
  'their install receipts: unchanged files are updated, non-overlapping edits are merged, ' +
24
24
  'and conflicts are left untouched. `list` only lists codemods; `registry` only updates ' +
25
- 'copied compositions.',
25
+ 'copied compositions. Core codemods ship inside the CLI, so a CLI older than the installed ' +
26
+ 'Core has none for the releases after its own version: the result then carries ' +
27
+ '`cliBehindCore` with the command that runs the same upgrade on the matching CLI.',
26
28
  importPath: '@astryxdesign/cli/api',
27
29
  signature:
28
30
  'upgrade(options?: UpgradeOptions, ctx?: {cwd?: string}): Promise<UpgradeListResponse | UpgradeRegistryResponse | UpgradeStatusResponse | UpgradeRunResponse>',
@@ -118,12 +120,12 @@ export const doc = {
118
120
  {
119
121
  type: 'upgrade.status',
120
122
  description:
121
- 'A short-circuit outcome (no codemods executed): `up_to_date` (`from` is at/after the installed target and no `force`), `no_codemods` (none apply to the range), or `config_fixable` (dry-run preview that a pending config codemod would repair an invalid astryx.config). up_to_date and no_codemods carry the agent-docs summary and, when receipts are found, the copied-composition summary; config_fixable carries configError, configCodemods, suggestedCommand, message, note, and the agent-docs summary.',
123
+ 'A short-circuit outcome (no codemods executed): `up_to_date` (`from` is at/after the installed target and no `force`), `no_codemods` (none apply to the range), or `config_fixable` (dry-run preview that a pending config codemod would repair an invalid astryx.config). up_to_date and no_codemods carry the agent-docs summary and, when receipts are found, the copied-composition summary; config_fixable carries configError, configCodemods, suggestedCommand, message, note, and the agent-docs summary. When the installed Core is newer than the CLI, no_codemods and config_fixable also carry cliBehindCore ({cliVersion, command}): this CLI has no codemods for the releases after cliVersion, and command runs the same upgrade with the CLI release that matches the installed Core.',
122
124
  },
123
125
  {
124
126
  type: 'upgrade.run',
125
127
  description:
126
- 'The terminal run receipt: from, to, codemods (count), integrations, agentDocs, agentDocsRefreshed, registryCompositions (when receipts are found), sourcePathFound (false when the resolved `path` does not exist, so nothing was scanned), filesChanged, transformsApplied, modifiedFiles, protectedFiles, declinedCandidates, errors, and complete. When a protected file still requires a change, complete is false and errorCode is ERR_CODEMOD_PROTECTED; the CLI exits nonzero while preserving the structured receipt.',
128
+ 'The terminal run receipt: from, to, codemods (count), integrations, agentDocs, agentDocsRefreshed, registryCompositions (when receipts are found), sourcePathFound (false when the resolved `path` does not exist, so nothing was scanned), filesChanged, transformsApplied, modifiedFiles, protectedFiles, declinedCandidates, errors, and complete. When a protected file still requires a change, complete is false and errorCode is ERR_CODEMOD_PROTECTED; the CLI exits nonzero while preserving the structured receipt. When the installed Core is newer than the CLI, it also carries cliBehindCore ({cliVersion, command}): codemods for the releases after cliVersion did not run, and command runs the same upgrade with the matching CLI.',
127
129
  },
128
130
  ],
129
131
  throws: [
@@ -160,6 +160,22 @@ export type ProtectedCodemodFile = {
160
160
  */
161
161
  commands: string[];
162
162
  };
163
+ /**
164
+ * Present only when the installed `@astryxdesign/core` (the response's `to`) is
165
+ * newer than the running CLI. Core codemods ship inside the CLI, so this CLI
166
+ * has none for the releases after `cliVersion`: the run could not migrate them,
167
+ * whatever else the response reports.
168
+ */
169
+ export type CliBehindCore = {
170
+ /**
171
+ * The running CLI's version, the last release it has codemods for.
172
+ */
173
+ cliVersion: string;
174
+ /**
175
+ * The same upgrade, run with the CLI release that matches the installed Core. It first changes to the folder this run used, then names the directory this run scanned as an absolute `--path`, both with symbolic links resolved, so pasted from any folder it finds the same Core and scans the same directory. It is written for a POSIX shell (sh, bash, zsh), or for PowerShell on Windows, with each argument quoted for that shell; cmd.exe is not a target.
176
+ */
177
+ command: string;
178
+ };
163
179
  /**
164
180
  * astryx --json upgrade [--apply]
165
181
  */
@@ -190,6 +206,7 @@ export type UpgradeRunResponse = {
190
206
  codemod: string;
191
207
  error: string;
192
208
  }[] | undefined;
209
+ cliBehindCore?: CliBehindCore | undefined;
193
210
  };
194
211
  };
195
212
  /**
@@ -202,6 +219,10 @@ export type UpgradeRunResponse = {
202
219
  * range) would repair it. The dry run previews the fix without writing and
203
220
  * reports the exact command to apply it; integrations are skipped for the
204
221
  * preview (they will be processed on the `--apply` run).
222
+ *
223
+ * `no_codemods` and `config_fixable` carry `cliBehindCore` when the installed
224
+ * Core is newer than this CLI; `no_codemods` then means only that this CLI has
225
+ * no codemods for the range.
205
226
  */
206
227
  export type UpgradeStatusResponse = {
207
228
  type: "upgrade.status";
@@ -217,6 +238,7 @@ export type UpgradeStatusResponse = {
217
238
  to: string;
218
239
  agentDocs: AgentDocsSummary;
219
240
  registryCompositions?: RegistryCompositionSummary;
241
+ cliBehindCore?: CliBehindCore;
220
242
  } | {
221
243
  status: "config_fixable";
222
244
  from: string;
@@ -227,6 +249,7 @@ export type UpgradeStatusResponse = {
227
249
  message: string;
228
250
  note: string;
229
251
  agentDocs: AgentDocsSummary;
252
+ cliBehindCore?: CliBehindCore;
230
253
  };
231
254
  };
232
255
  /**
@@ -106,6 +106,16 @@
106
106
  * @property {string[]} commands Exact regeneration commands found in generated headers, when present.
107
107
  */
108
108
 
109
+ /**
110
+ * Present only when the installed `@astryxdesign/core` (the response's `to`) is
111
+ * newer than the running CLI. Core codemods ship inside the CLI, so this CLI
112
+ * has none for the releases after `cliVersion`: the run could not migrate them,
113
+ * whatever else the response reports.
114
+ * @typedef {object} CliBehindCore
115
+ * @property {string} cliVersion The running CLI's version, the last release it has codemods for.
116
+ * @property {string} command The same upgrade, run with the CLI release that matches the installed Core. It first changes to the folder this run used, then names the directory this run scanned as an absolute `--path`, both with symbolic links resolved, so pasted from any folder it finds the same Core and scans the same directory. It is written for a POSIX shell (sh, bash, zsh), or for PowerShell on Windows, with each argument quoted for that shell; cmd.exe is not a target.
117
+ */
118
+
109
119
  /**
110
120
  * astryx --json upgrade [--apply]
111
121
  * @typedef {object} UpgradeRunResponse
@@ -127,6 +137,7 @@
127
137
  * @property {Array<{file: string, location?: string, reason: string}>} [data.declinedCandidates] Candidates left unchanged because proof was insufficient.
128
138
  * @property {number} [data.transformsApplied] Total codemod changes. A code or config codemod counts once for each file it changed, so one file changed by four of them counts four times; a project codemod counts once, however many files it writes.
129
139
  * @property {Array<{file: string, codemod: string, error: string}>} [data.errors] Per-codemod errors, when any codemod failed.
140
+ * @property {CliBehindCore} [data.cliBehindCore] Present only when the installed Core is newer than this CLI: codemods for the releases after `cliBehindCore.cliVersion` did not run.
130
141
  */
131
142
 
132
143
  /**
@@ -140,9 +151,13 @@
140
151
  * reports the exact command to apply it; integrations are skipped for the
141
152
  * preview (they will be processed on the `--apply` run).
142
153
  *
154
+ * `no_codemods` and `config_fixable` carry `cliBehindCore` when the installed
155
+ * Core is newer than this CLI; `no_codemods` then means only that this CLI has
156
+ * no codemods for the range.
157
+ *
143
158
  * @typedef {object} UpgradeStatusResponse
144
159
  * @property {'upgrade.status'} type
145
- * @property {{status: 'up_to_date', from: string, to: string, agentDocs: AgentDocsSummary, registryCompositions?: RegistryCompositionSummary} | {status: 'no_codemods', from: string, to: string, agentDocs: AgentDocsSummary, registryCompositions?: RegistryCompositionSummary} | {status: 'config_fixable', from: string, to: string, configError: string, configCodemods: string[], suggestedCommand: string, message: string, note: string, agentDocs: AgentDocsSummary}} data
160
+ * @property {{status: 'up_to_date', from: string, to: string, agentDocs: AgentDocsSummary, registryCompositions?: RegistryCompositionSummary} | {status: 'no_codemods', from: string, to: string, agentDocs: AgentDocsSummary, registryCompositions?: RegistryCompositionSummary, cliBehindCore?: CliBehindCore} | {status: 'config_fixable', from: string, to: string, configError: string, configCodemods: string[], suggestedCommand: string, message: string, note: string, agentDocs: AgentDocsSummary, cliBehindCore?: CliBehindCore}} data
146
161
  */
147
162
 
148
163
  /**
@@ -418,6 +418,7 @@ async function runProjectCodemod(
418
418
  * @param {boolean} [options.silent] - Suppress all human-facing output (for --json)
419
419
  * @param {string} [options.root] - Project root a project codemod reads (default: the process cwd)
420
420
  * @param {{root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}} [options.protection] - Preloaded protection resolver
421
+ * @param {boolean} [options.coversTarget] - False when these codemods stop before the installed target (the CLI is older than Core), so a run with no changes does not say the code is up to date. Default true.
421
422
  * @returns {Promise<{totalFilesChanged: number, totalTransformsApplied: number, totalValidationBlocked: number, changedFiles: string[], writtenFiles: string[], stagedContents: Map<string, string>, protectedFiles: import('../../authoring/codemod/type').CodemodRunResult['protectedFiles'], errors: Array<{file: string, codemod: string, error: string}>, skippedOptional: Array<{name: string, meta: {title: string, description?: string, fileExtensions?: string[], codemodType?: string}, version: string}>} | {ok: false, reason: string, resolvedPath: string}>}
422
423
  */
423
424
  export async function runCodemods(
@@ -430,6 +431,7 @@ export async function runCodemods(
430
431
  silent = false,
431
432
  root = process.cwd(),
432
433
  protection: providedProtection,
434
+ coversTarget = true,
433
435
  },
434
436
  ) {
435
437
  // No-op stub object so silent mode skips log output entirely without
@@ -643,7 +645,11 @@ export async function runCodemods(
643
645
  errors.length === 0 &&
644
646
  protectedFiles.length === 0
645
647
  ) {
646
- log.success('No changes needed — your code is already up to date!');
648
+ // Codemods that stop before the installed target cannot vouch for the
649
+ // code; the caller says what is missing.
650
+ if (coversTarget) {
651
+ log.success('No changes needed — your code is already up to date!');
652
+ }
647
653
  } else if (apply && protectedFiles.length > 0) {
648
654
  log.warn(
649
655
  `Applied ${totalTransformsApplied} owned change${totalTransformsApplied === 1 ? '' : 's'} across ${totalFilesChanged} file${totalFilesChanged === 1 ? '' : 's'}; protected changes remain.`,
@@ -167,5 +167,25 @@ message: Rerun with --confirm-public to file this report.`,
167
167
  },
168
168
  ],
169
169
  },
170
+ {
171
+ id: 'choose-a-destination',
172
+ title: 'Let the person choose where a report goes',
173
+ content: [
174
+ {
175
+ type: 'prose',
176
+ text: 'When an app loads packages that name their own `issuesUrl`, a report can go to the default (the handlers, or the fallback above) or to one of those packages. `astryx gap-report --list-categories` and the receipt of a report filed without `--to` list every destination, with a line telling the agent to ask the person.',
177
+ },
178
+ {
179
+ type: 'list',
180
+ style: 'unordered',
181
+ items: [
182
+ 'An agent asks the person where to file. It never picks a package destination on its own.',
183
+ "`--to <package>` carries the person's choice: the report goes only to that package's `issuesUrl`, under the same `--confirm-public` rule, and the handlers do not run.",
184
+ 'Without a choice, leave out `--to`; the report goes to the default.',
185
+ 'A `--to` that names no destination fails before anything is sent and lists the destinations.',
186
+ ],
187
+ },
188
+ ],
189
+ },
170
190
  ],
171
191
  };
@@ -16,6 +16,8 @@ export const doc = {
16
16
  'Reports a missing component, variant, layout, styling, accessibility, API, or documentation capability to the package that owns it: the --package you name, else the integration whose component replaces it, else the one package that provides the component, else Core. ' +
17
17
  'Every configured handler receives the report: the project config handler first, then each integration handler in config order. Public handlers run only with --confirm-public; internal handlers always run. A failing handler does not stop the others. ' +
18
18
  "With no handler it files a GitHub issue for the owning package, only with --confirm-public (without it nothing is sent), or returns the package's issues URL when that is not on GitHub. " +
19
+ "With --to <package>, the report goes only to that integration's issues URL instead, under the same --confirm-public rule. " +
20
+ 'When loaded integrations name their own issues URLs, the output lists every destination: an agent asks the person where to file and passes their choice with --to; it never picks a package itself, and without a choice the default is used. ' +
19
21
  'The report records whether an agent or a person ran it.',
20
22
  fn: 'gapReport',
21
23
  args: [
@@ -55,13 +57,19 @@ export const doc = {
55
57
  flag: '--confirm-public',
56
58
  param: 'options.confirmPublic',
57
59
  description:
58
- 'Allow public delivery: public handlers run, and with no handler it files a GitHub issue with your gh login',
60
+ 'Allow public delivery: public handlers run, and a GitHub issues URL gets an issue filed with your gh login',
61
+ },
62
+ {
63
+ flag: '--to <package>',
64
+ param: 'options.to',
65
+ description:
66
+ "Send the report only to this loaded integration's issues URL, as the person chose; the destinations the output lists are the choices",
59
67
  },
60
68
  {
61
69
  flag: '--list-categories',
62
70
  param: 'options.listCategories',
63
71
  description:
64
- 'List valid report categories without filing; the component and the other gap-report options are refused with ERR_INVALID_ARGUMENT',
72
+ 'List valid report categories, and the destinations when there is more than one, without filing; the component and the other gap-report options are refused with ERR_INVALID_ARGUMENT',
65
73
  },
66
74
  ],
67
75
  examples: [
@@ -70,6 +78,10 @@ export const doc = {
70
78
  label: 'Prepare a report (nothing public happens without --confirm-public)',
71
79
  cli: "astryx gap-report Button --category missing_variant --reason 'Need a compact size'",
72
80
  },
81
+ {
82
+ label: 'File where the person chose',
83
+ cli: "astryx gap-report Button --category missing_variant --reason 'Need a compact size' --to @acme/widgets",
84
+ },
73
85
  ],
74
86
  exitCodes: [
75
87
  {
@@ -7,7 +7,7 @@
7
7
  import {gapReport as gapReportApi} from '../../../api/gap-report/gap-report.mjs';
8
8
  import {NO_RESULT_SET, resultSet} from '../../../foundation/debug/index.mjs';
9
9
  import {jsonOut} from '../../../foundation/response/json.mjs';
10
- import {emit, record, records, section} from '../formatters/index.mjs';
10
+ import {emit, record, records, section, text} from '../formatters/index.mjs';
11
11
  import {cliError} from '../lib/cli-error.mjs';
12
12
  import {defineCommand} from '../lib/define-command.mjs';
13
13
  import {doc as gapReportCommand} from './gap-report.doc.mjs';
@@ -19,7 +19,7 @@ export function registerGapReport(program) {
19
19
  fn: gapReportFn,
20
20
  action: async (
21
21
  /** @type {string|undefined} */ component,
22
- /** @type {{category?: string, reason?: string, additionalContext?: string, package?: string, confirmPublic?: boolean, listCategories?: boolean}} */ options,
22
+ /** @type {{category?: string, reason?: string, additionalContext?: string, package?: string, confirmPublic?: boolean, listCategories?: boolean, to?: string}} */ options,
23
23
  ) => {
24
24
  /** @type {Awaited<ReturnType<typeof gapReportApi>>} */
25
25
  let result;
@@ -35,6 +35,7 @@ export function registerGapReport(program) {
35
35
  package: options.package,
36
36
  confirmPublic: options.confirmPublic,
37
37
  listCategories: options.listCategories,
38
+ to: options.to,
38
39
  });
39
40
  } catch (error) {
40
41
  const err =
@@ -78,6 +79,9 @@ export function registerGapReport(program) {
78
79
  section('Gap report categories'),
79
80
  records(result.data, {fields: ['value', 'label']}),
80
81
  );
82
+ if (result.meta) {
83
+ emit(...destinationBlocks(result.meta.destinations, result.meta.ask));
84
+ }
81
85
  return answered;
82
86
  }
83
87
 
@@ -119,8 +123,26 @@ export function registerGapReport(program) {
119
123
  );
120
124
  }
121
125
 
126
+ if (result.data.destinations && result.data.ask) {
127
+ emit(...destinationBlocks(result.data.destinations, result.data.ask));
128
+ }
129
+
122
130
  if (isFailure) process.exitCode = 1;
123
131
  return answered;
124
132
  },
125
133
  });
126
134
  }
135
+
136
+ /**
137
+ * The destinations a report can go to, then the line telling an agent to ask
138
+ * the person (architecture:cli-surface INV36).
139
+ * @param {import('../../../api/gap-report/gap-report.type.mjs').GapReportDestination[]} destinations
140
+ * @param {string} ask
141
+ */
142
+ function destinationBlocks(destinations, ask) {
143
+ return [
144
+ section('Destinations'),
145
+ records(destinations, {fields: ['to', 'default', 'issuesUrl']}),
146
+ text(ask),
147
+ ];
148
+ }
@@ -331,3 +331,82 @@ describe('gap-report control docs', () => {
331
331
  ).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
332
332
  });
333
333
  });
334
+
335
+ describe('gap-report destinations in text', () => {
336
+ it('lists the destinations and tells the agent to ask the person', async () => {
337
+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-gap-dest-'));
338
+ try {
339
+ fs.writeFileSync(
340
+ path.join(cwd, 'package.json'),
341
+ JSON.stringify({name: 'fixture-app'}),
342
+ );
343
+ const pkg = path.join(cwd, 'node_modules', '@test', 'widgets');
344
+ fs.mkdirSync(pkg, {recursive: true});
345
+ fs.writeFileSync(
346
+ path.join(pkg, 'package.json'),
347
+ JSON.stringify({name: '@test/widgets', version: '1.0.0'}),
348
+ );
349
+ fs.writeFileSync(
350
+ path.join(pkg, 'astryx.integration.mjs'),
351
+ "export default {issuesUrl: 'https://tracker.example/widgets'};\n",
352
+ );
353
+ fs.writeFileSync(
354
+ path.join(cwd, 'astryx.config.mjs'),
355
+ `export default {
356
+ integrations: ['@test/widgets'],
357
+ gapReport: {audience: 'internal', handle: () => ({status: 'filed', message: 'shared'})},
358
+ };\n`,
359
+ );
360
+
361
+ const listed = await runCli(['gap-report', '--list-categories'], {cwd});
362
+ expect(listed.status).toBe(0);
363
+ expect(listed.stdout).toContain('Destinations');
364
+ expect(listed.stdout).toMatch(/^default:\s+true$/m);
365
+ expect(listed.stdout).toMatch(/^to:\s+@test\/widgets$/m);
366
+ expect(listed.stdout).toMatch(
367
+ /^issuesUrl:\s+https:\/\/tracker\.example\/widgets$/m,
368
+ );
369
+ expect(listed.stdout).toMatch(/ask the person/i);
370
+
371
+ const filed = await runCli(
372
+ [
373
+ 'gap-report',
374
+ 'Button',
375
+ '--category',
376
+ 'docs_gap',
377
+ '--reason',
378
+ 'Need a keyboard example',
379
+ ],
380
+ {cwd},
381
+ );
382
+ expect(filed.status).toBe(0);
383
+ expect(filed.stdout).toContain('Destinations');
384
+ expect(filed.stdout).toMatch(/ask the person/i);
385
+
386
+ const chosen = await runCli(
387
+ [
388
+ 'gap-report',
389
+ 'Button',
390
+ '--category',
391
+ 'docs_gap',
392
+ '--reason',
393
+ 'Need a keyboard example',
394
+ '--to',
395
+ '@test/widgets',
396
+ '--json',
397
+ ],
398
+ {cwd},
399
+ );
400
+ expect(chosen.status).toBe(0);
401
+ expect(JSON.parse(chosen.stdout).data.deliveries).toEqual([
402
+ expect.objectContaining({
403
+ handler: 'issuesUrl',
404
+ status: 'routed_only',
405
+ url: 'https://tracker.example/widgets',
406
+ }),
407
+ ]);
408
+ } finally {
409
+ fs.rmSync(cwd, {recursive: true, force: true});
410
+ }
411
+ });
412
+ });
@@ -117,6 +117,23 @@ describe('astryx integration check', () => {
117
117
  expect(run.status).toBe(1);
118
118
  });
119
119
 
120
+ it('--strict prints each finding once: its message above, its code in the failing list', async () => {
121
+ const id = await coreTemplateId();
122
+ writePackage({id});
123
+
124
+ const run = await runCli(['integration', 'check', '--strict'], tmpDir);
125
+ const json = await runCli(
126
+ ['integration', 'check', '--strict', '--json'],
127
+ tmpDir,
128
+ );
129
+ const [failure] = JSON.parse(json.stdout.trim()).data.failures;
130
+
131
+ expect(run.stdout.split(failure.message).length - 1).toBe(1);
132
+ expect(
133
+ run.stdout.slice(run.stdout.indexOf('Failing under --strict')),
134
+ ).toContain('template_id_conflict');
135
+ });
136
+
120
137
  it('--json carries each check with its own envelope, the --strict failures, and exits as the text does', async () => {
121
138
  const id = await coreTemplateId();
122
139
  writePackage({id});