nx 23.2.0-beta.7 → 23.2.0-beta.9

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 (188) hide show
  1. package/dist/bin/init-local.js +3 -5
  2. package/dist/release/changelog-renderer/index.js +4 -5
  3. package/dist/src/adapter/ngcli-adapter.js +60 -1
  4. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +2 -2
  5. package/dist/src/command-line/completion/command-object.js +7 -12
  6. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +17 -23
  7. package/dist/src/command-line/format/format.js +84 -101
  8. package/dist/src/command-line/generate/generate.js +35 -35
  9. package/dist/src/command-line/import/import.js +30 -40
  10. package/dist/src/command-line/init/ai-agent-prompts.js +5 -11
  11. package/dist/src/command-line/init/command-object.js +4 -2
  12. package/dist/src/command-line/init/configure-plugins.js +4 -1
  13. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
  14. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +17 -21
  15. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
  16. package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +3 -17
  17. package/dist/src/command-line/init/implementation/angular/index.js +10 -15
  18. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +2 -0
  19. package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +8 -2
  20. package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +2 -0
  21. package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +5 -0
  22. package/dist/src/command-line/init/implementation/format.d.ts +18 -0
  23. package/dist/src/command-line/init/implementation/format.js +114 -0
  24. package/dist/src/command-line/init/implementation/utils.js +8 -0
  25. package/dist/src/command-line/init/init-v1.js +15 -18
  26. package/dist/src/command-line/init/init-v2.js +37 -56
  27. package/dist/src/command-line/migrate/agentic/definitions.js +35 -8
  28. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +22 -3
  29. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +13 -10
  30. package/dist/src/command-line/migrate/agentic/handoff.d.ts +3 -1
  31. package/dist/src/command-line/migrate/agentic/handoff.js +4 -2
  32. package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
  33. package/dist/src/command-line/migrate/agentic/runner.js +24 -24
  34. package/dist/src/command-line/migrate/agentic/select.js +20 -30
  35. package/dist/src/command-line/migrate/agentic/types.d.ts +19 -3
  36. package/dist/src/command-line/migrate/agentic/types.js +13 -4
  37. package/dist/src/command-line/migrate/command-object.d.ts +3 -0
  38. package/dist/src/command-line/migrate/command-object.js +13 -0
  39. package/dist/src/command-line/migrate/execute-migration.d.ts +14 -0
  40. package/dist/src/command-line/migrate/execute-migration.js +30 -9
  41. package/dist/src/command-line/migrate/migrate-analytics.d.ts +28 -0
  42. package/dist/src/command-line/migrate/migrate-analytics.js +51 -1
  43. package/dist/src/command-line/migrate/migrate-commits.d.ts +8 -2
  44. package/dist/src/command-line/migrate/migrate-commits.js +66 -19
  45. package/dist/src/command-line/migrate/migrate-config.d.ts +4 -2
  46. package/dist/src/command-line/migrate/migrate-config.js +12 -4
  47. package/dist/src/command-line/migrate/migrate.d.ts +13 -2
  48. package/dist/src/command-line/migrate/migrate.js +243 -80
  49. package/dist/src/command-line/migrate/multi-major.js +7 -10
  50. package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
  51. package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
  52. package/dist/src/command-line/migrate/run/agent-output.js +65 -0
  53. package/dist/src/command-line/migrate/run/index.d.ts +7 -0
  54. package/dist/src/command-line/migrate/run/index.js +19 -1
  55. package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
  56. package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
  57. package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
  58. package/dist/src/command-line/migrate/run/run-id.js +56 -0
  59. package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
  60. package/dist/src/command-line/migrate/run/run-state.js +438 -0
  61. package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
  62. package/dist/src/command-line/migrate/run/state-lock.js +76 -0
  63. package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
  64. package/dist/src/command-line/migrate/run/state-machine.js +315 -0
  65. package/dist/src/command-line/migrate/run/util.d.ts +58 -0
  66. package/dist/src/command-line/migrate/run/util.js +139 -7
  67. package/dist/src/command-line/migrate/run/worker.d.ts +1 -0
  68. package/dist/src/command-line/migrate/run/worker.js +308 -45
  69. package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
  70. package/dist/src/command-line/migrate/safe-prompt.js +32 -43
  71. package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
  72. package/dist/src/command-line/migrate/step-actions.js +12 -0
  73. package/dist/src/command-line/migrate/text.d.ts +18 -0
  74. package/dist/src/command-line/migrate/text.js +26 -0
  75. package/dist/src/command-line/migrate/version-skew-guard.d.ts +6 -4
  76. package/dist/src/command-line/migrate/version-skew-guard.js +34 -14
  77. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +16 -20
  78. package/dist/src/command-line/release/changelog.js +6 -17
  79. package/dist/src/command-line/release/plan.js +15 -28
  80. package/dist/src/command-line/release/release.js +6 -17
  81. package/dist/src/command-line/release/utils/remote-release-clients/github.js +16 -22
  82. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +13 -22
  83. package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
  84. package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
  85. package/dist/src/command-line/release/version.js +2 -2
  86. package/dist/src/core/graph/main.js +1 -1
  87. package/dist/src/daemon/client/client.js +11 -2
  88. package/dist/src/devkit-internals.d.ts +7 -2
  89. package/dist/src/devkit-internals.js +22 -6
  90. package/dist/src/generators/internal-utils/{format-changed-files-with-prettier-if-available.d.ts → format-changed-files.d.ts} +6 -6
  91. package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
  92. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
  93. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
  94. package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
  95. package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
  96. package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
  97. package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
  98. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
  99. package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
  100. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
  101. package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
  102. package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
  103. package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
  104. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
  105. package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
  106. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
  107. package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
  108. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
  109. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
  110. package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
  111. package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
  112. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
  113. package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
  114. package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
  115. package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
  116. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
  117. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
  118. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
  119. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
  120. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  121. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  122. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
  123. package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
  124. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +128 -2
  125. package/dist/src/tasks-runner/run-command.js +17 -32
  126. package/dist/src/tasks-runner/task-env.js +5 -2
  127. package/dist/src/tasks-runner/utils.js +2 -6
  128. package/dist/src/utils/analytics-prompt.js +4 -7
  129. package/dist/src/utils/chunkify.d.ts +7 -1
  130. package/dist/src/utils/chunkify.js +10 -3
  131. package/dist/src/utils/exit-codes.d.ts +9 -0
  132. package/dist/src/utils/exit-codes.js +19 -0
  133. package/dist/src/utils/fileutils.d.ts +5 -0
  134. package/dist/src/utils/fileutils.js +7 -2
  135. package/dist/src/utils/formatters/index.d.ts +13 -0
  136. package/dist/src/utils/formatters/index.js +74 -0
  137. package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
  138. package/dist/src/utils/formatters/oxfmt.js +764 -0
  139. package/dist/src/utils/formatters/prettier.d.ts +26 -0
  140. package/dist/src/utils/formatters/prettier.js +201 -0
  141. package/dist/src/utils/formatters/shared.d.ts +5 -0
  142. package/dist/src/utils/formatters/shared.js +8 -0
  143. package/dist/src/utils/git-utils.d.ts +33 -2
  144. package/dist/src/utils/git-utils.js +156 -8
  145. package/dist/src/utils/ignore.d.ts +47 -5
  146. package/dist/src/utils/ignore.js +93 -11
  147. package/dist/src/utils/long-running-target.d.ts +10 -0
  148. package/dist/src/utils/long-running-target.js +19 -0
  149. package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
  150. package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
  151. package/dist/src/utils/min-release-age/packument.js +1 -1
  152. package/dist/src/utils/nx-console-prompt.js +3 -6
  153. package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
  154. package/dist/src/utils/package-manager-config/bunfig.js +49 -0
  155. package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
  156. package/dist/src/utils/package-manager-config/npmrc.js +124 -0
  157. package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
  158. package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
  159. package/dist/src/utils/package-manager.d.ts +21 -2
  160. package/dist/src/utils/package-manager.js +244 -47
  161. package/dist/src/utils/params.d.ts +7 -1
  162. package/dist/src/utils/params.js +64 -6
  163. package/dist/src/utils/prompt-helpers.d.ts +53 -0
  164. package/dist/src/utils/prompt-helpers.js +111 -0
  165. package/dist/src/utils/provenance.js +6 -14
  166. package/dist/src/utils/registry-config/bun.d.ts +2 -0
  167. package/dist/src/utils/registry-config/bun.js +257 -0
  168. package/dist/src/utils/registry-config/index.d.ts +13 -0
  169. package/dist/src/utils/registry-config/index.js +102 -0
  170. package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
  171. package/dist/src/utils/registry-config/pnpm.js +1551 -0
  172. package/dist/src/utils/registry-config/utils.d.ts +195 -0
  173. package/dist/src/utils/registry-config/utils.js +496 -0
  174. package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
  175. package/dist/src/utils/registry-config/yarn-berry.js +612 -0
  176. package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
  177. package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
  178. package/dist/src/utils/safe-spawn.d.ts +24 -0
  179. package/dist/src/utils/safe-spawn.js +104 -0
  180. package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
  181. package/dist/src/utils/write-formatted-json-file.js +5 -4
  182. package/migrations.json +6 -0
  183. package/package.json +17 -13
  184. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -88
  185. package/dist/src/utils/is-using-prettier.d.ts +0 -3
  186. package/dist/src/utils/is-using-prettier.js +0 -62
  187. package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
  188. package/dist/src/utils/min-release-age/npmrc.js +0 -45
@@ -41,10 +41,11 @@ async function runAgentic(args) {
41
41
  });
42
42
  }
43
43
  // Counts SIGINTs while the agent runs. Non-zero after exit means the
44
- // user pressed Ctrl+C → skip the ambiguous abort/continue prompt, because
45
- // enquirer misbehaves in the TTY state left by a SIGINT-killed child
46
- // (ERR_USE_AFTER_CLOSE, setRawMode EIO) and the errors surface from async
47
- // chains that `await` cannot catch.
44
+ // user pressed Ctrl+C → skip the ambiguous abort/continue prompt. Prompting
45
+ // in the TTY state left by a SIGINT-killed child misbehaved under enquirer
46
+ // (ERR_USE_AFTER_CLOSE, setRawMode EIO) from async chains `await` could not
47
+ // catch. Whether @clack/prompts shares that fault is unverified, so the skip
48
+ // stays; reproducing it needs a real terminal.
48
49
  let userInterruptCount = 0;
49
50
  const swallowSigint = () => {
50
51
  userInterruptCount++;
@@ -279,9 +280,10 @@ async function resolveFromHandoffOrPrompt(handoffFilePath, userInterrupted = fal
279
280
  };
280
281
  if (userInterrupted) {
281
282
  // User pressed Ctrl+C. Don't show the abort/continue prompt — they
282
- // already told us what they want, and the TTY state after a
283
- // SIGINT-killed child trips enquirer's setRawMode-EIO and
284
- // ERR_USE_AFTER_CLOSE bugs. The orchestrator's standard failure
283
+ // already told us what they want. Prompting in the TTY state left by a
284
+ // SIGINT-killed child also tripped enquirer's setRawMode-EIO and
285
+ // ERR_USE_AFTER_CLOSE bugs; whether @clack/prompts shares that fault is
286
+ // unverified, so the skip stays. The orchestrator's standard failure
285
287
  // cascade surfaces the abort outcome.
286
288
  //
287
289
  // Forward the underlying cause as pre-rendered summary lines so the
@@ -357,13 +359,14 @@ function escapeCmdCommand(arg) {
357
359
  }
358
360
  async function promptAmbiguous(cause) {
359
361
  // stderr blank line so the spacer lands in the same stream as output.warn
360
- // and the enquirer prompt — buffered stdout could otherwise reorder it
361
- // and glue the prompt to the agent's trailing exit message.
362
+ // and the prompt — buffered stdout could otherwise reorder it and glue the
363
+ // prompt to the agent's trailing exit message.
362
364
  process.stderr.write('\n');
363
- // Cause rendered ABOVE the prompt rather than inlined into prompt.message:
364
- // enquirer's select redraw uses different math for clear (wrap-aware) vs
365
- // restore (raw \n-split count), so a multi-line message can leave orphaned
366
- // cells on arrow-key re-renders. Keeping message single-line sidesteps it.
365
+ // Cause rendered ABOVE the prompt rather than inlined into its message:
366
+ // enquirer's select redraw used different math for clear (wrap-aware) vs
367
+ // restore (raw \n-split count), so a multi-line message could leave orphaned
368
+ // cells on arrow-key re-renders. Kept single-line because that constraint is
369
+ // unverified under @clack/prompts, not because the cause still applies.
367
370
  const causeLines = describeAmbiguousCause(cause);
368
371
  if (causeLines.length > 0) {
369
372
  output_1.output.warn({
@@ -371,24 +374,21 @@ async function promptAmbiguous(cause) {
371
374
  bodyLines: causeLines,
372
375
  });
373
376
  }
374
- // `migratePrompt` injects `options.cancel` so Ctrl+C and Esc exit cleanly
375
- // via `process.exit(130)` before enquirer's broken cancel cleanup runs.
376
- // Any other rejection we treat as abort.
377
+ // Cancelling exits 130 from inside the prompt; any other rejection is an
378
+ // abort.
377
379
  try {
378
- const response = await (0, safe_prompt_1.migratePrompt)({
379
- name: 'choice',
380
- type: 'select',
380
+ const choice = await (0, safe_prompt_1.migrateChoice)({
381
381
  message: 'How should nx migrate proceed?',
382
382
  choices: [
383
- { name: 'abort', message: 'Treat as failed — abort the run' },
383
+ { value: 'abort', label: 'Treat as failed — abort the run' },
384
384
  {
385
- name: 'continue',
386
- message: 'Treat as completed — mark done and continue',
385
+ value: 'continue',
386
+ label: 'Treat as completed — mark done and continue',
387
387
  },
388
388
  ],
389
389
  });
390
- (0, migrate_analytics_1.reportMigratePrompt)('ambiguous_agent_outcome', response.choice);
391
- return response.choice === 'continue'
390
+ (0, migrate_analytics_1.reportMigratePrompt)('ambiguous_agent_outcome', choice);
391
+ return choice === 'continue'
392
392
  ? { kind: 'ambiguous-continue' }
393
393
  : { kind: 'ambiguous-abort' };
394
394
  }
@@ -2,11 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveAgentic = resolveAgentic;
4
4
  exports.resolveShouldRunValidation = resolveShouldRunValidation;
5
- const tslib_1 = require("tslib");
6
5
  const fs_1 = require("fs");
7
6
  const jsonc_parser_1 = require("jsonc-parser");
8
7
  const path_1 = require("path");
9
- const pc = tslib_1.__importStar(require("picocolors"));
10
8
  const output_1 = require("../../../utils/output");
11
9
  const workspace_root_1 = require("../../../utils/workspace-root");
12
10
  const migrate_analytics_1 = require("../migrate-analytics");
@@ -129,46 +127,40 @@ async function firePromptForAgentic(migrations, detected) {
129
127
  const pinChoice = multipleAgents
130
128
  ? [
131
129
  {
132
- name: 'yes-pin',
133
- message: 'Yes, always with the same agent',
134
- description: rememberHint,
130
+ value: 'yes-pin',
131
+ label: 'Yes, always with the same agent',
132
+ hint: rememberHint,
135
133
  },
136
134
  ]
137
135
  : [];
138
136
  const choices = [
139
137
  {
140
- name: 'yes-once',
141
- message: 'Yes, just this time',
142
- description: applyHint,
138
+ value: 'yes-once',
139
+ label: 'Yes, just this time',
140
+ hint: applyHint,
143
141
  },
144
142
  {
145
- name: 'yes-flex',
146
- message: multipleAgents
143
+ value: 'yes-flex',
144
+ label: multipleAgents
147
145
  ? "Yes, always (I'll pick the agent each run)"
148
146
  : 'Yes, always',
149
- description: rememberHint,
147
+ hint: rememberHint,
150
148
  },
151
149
  ...pinChoice,
152
- { name: 'no-once', message: 'No, just this time', description: skipHint },
153
- { name: 'no-never', message: 'No, never', description: rememberHint },
150
+ { value: 'no-once', label: 'No, just this time', hint: skipHint },
151
+ { value: 'no-never', label: 'No, never', hint: rememberHint },
154
152
  ];
155
153
  // Blank line keeps the prompt from gluing to the previous `npm install`
156
154
  // output or any earlier orchestrator line.
157
155
  console.log();
158
- // `as any`: `footer` and per-choice `description` aren't in enquirer's .d.ts.
159
- const response = await (0, safe_prompt_1.migratePrompt)({
160
- name: 'choice',
161
- type: 'select',
156
+ // Each choice's hint renders beside it, so the description no longer needs a
157
+ // footer that tracks the cursor.
158
+ const choice = await (0, safe_prompt_1.migrateChoice)({
162
159
  message: 'Enable the agentic flow?',
163
160
  choices,
164
- initial: 0,
165
- footer: function () {
166
- const focused = this.focused;
167
- return focused?.description ? pc.dim(` ${focused.description}`) : '';
168
- },
169
161
  });
170
- (0, migrate_analytics_1.reportMigratePrompt)('agentic', response.choice);
171
- switch (response.choice) {
162
+ (0, migrate_analytics_1.reportMigratePrompt)('agentic', choice);
163
+ switch (choice) {
172
164
  case 'yes-once':
173
165
  return { enabled: true };
174
166
  case 'yes-flex':
@@ -250,12 +242,10 @@ async function selectAgent(detected, explicitId, isInteractive) {
250
242
  requireInteractiveOrAbort(isInteractive);
251
243
  // Blank line keeps the prompt from gluing to the preceding output.
252
244
  console.log();
253
- const response = await (0, safe_prompt_1.migratePrompt)({
254
- name: 'id',
255
- type: 'select',
245
+ const id = await (0, safe_prompt_1.migrateChoice)({
256
246
  message: 'Multiple AI agents detected. Which one should Nx use?',
257
- choices: detected.map((d) => ({ name: d.id, message: d.displayName })),
247
+ choices: detected.map((d) => ({ value: d.id, label: d.displayName })),
258
248
  });
259
- (0, migrate_analytics_1.reportMigratePrompt)('agent_select', response.id);
260
- return detected.find((d) => d.id === response.id);
249
+ (0, migrate_analytics_1.reportMigratePrompt)('agent_select', id);
250
+ return detected.find((d) => d.id === id);
261
251
  }
@@ -1,14 +1,23 @@
1
1
  import type { AgentId } from './cli-args';
2
2
  export type { AgentId };
3
3
  /**
4
- * Workspace-relative directory holding all migrate-run scratch (handoff
5
- * files). Shared by the run-dir layout in `handoff.ts` and the agent
6
- * permission rules in `definitions.ts` so the pre-authorized write scope
4
+ * Workspace-relative directory holding all migrate-run scratch: a run
5
+ * directory per run id. Shared by the run-dir layout in `handoff.ts` and the
6
+ * agent permission rules in `definitions.ts` so the pre-authorized write scope
7
7
  * can't drift from the actual layout. It lives here so `definitions.ts`,
8
8
  * loaded whenever the agentic flow is resolved, doesn't pull in the handoff
9
9
  * runtime for the path alone.
10
10
  */
11
11
  export declare const MIGRATE_RUNS_RELATIVE_DIR = ".nx/migrate-runs";
12
+ /**
13
+ * The one subtree of a run directory an agent writes: its handoff files.
14
+ * Everything beside it is state Nx owns and reads back, the orchestrator's
15
+ * run state and plan snapshots included, so the pre-authorized write scope
16
+ * stops at this segment. Package names make up the rest of a handoff path,
17
+ * so without it they would occupy the run directory's top level and leave Nx
18
+ * no name it could add there safely.
19
+ */
20
+ export declare const HANDOFFS_DIR_NAME = "handoffs";
12
21
  export declare function isHandoffGitignoreMigration(m: {
13
22
  package: string;
14
23
  name: string;
@@ -34,6 +43,13 @@ export interface InvocationContext {
34
43
  systemContext: string;
35
44
  userPrompt: string;
36
45
  workspaceRoot: string;
46
+ /**
47
+ * Name of the run directory under `MIGRATE_RUNS_RELATIVE_DIR` holding this
48
+ * invocation's handoff. A workspace can carry several run directories at
49
+ * once, so a definition that pre-authorizes the handoff write narrows it to
50
+ * this one: the others belong to runs this invocation is not executing.
51
+ */
52
+ runDirName: string;
37
53
  }
38
54
  /**
39
55
  * What an agent definition returns from `buildInteractive`. The runner combines
@@ -1,16 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MIGRATE_RUNS_RELATIVE_DIR = void 0;
3
+ exports.HANDOFFS_DIR_NAME = exports.MIGRATE_RUNS_RELATIVE_DIR = void 0;
4
4
  exports.isHandoffGitignoreMigration = isHandoffGitignoreMigration;
5
5
  /**
6
- * Workspace-relative directory holding all migrate-run scratch (handoff
7
- * files). Shared by the run-dir layout in `handoff.ts` and the agent
8
- * permission rules in `definitions.ts` so the pre-authorized write scope
6
+ * Workspace-relative directory holding all migrate-run scratch: a run
7
+ * directory per run id. Shared by the run-dir layout in `handoff.ts` and the
8
+ * agent permission rules in `definitions.ts` so the pre-authorized write scope
9
9
  * can't drift from the actual layout. It lives here so `definitions.ts`,
10
10
  * loaded whenever the agentic flow is resolved, doesn't pull in the handoff
11
11
  * runtime for the path alone.
12
12
  */
13
13
  exports.MIGRATE_RUNS_RELATIVE_DIR = '.nx/migrate-runs';
14
+ /**
15
+ * The one subtree of a run directory an agent writes: its handoff files.
16
+ * Everything beside it is state Nx owns and reads back, the orchestrator's
17
+ * run state and plan snapshots included, so the pre-authorized write scope
18
+ * stops at this segment. Package names make up the rest of a handoff path,
19
+ * so without it they would occupy the run directory's top level and leave Nx
20
+ * no name it could add there safely.
21
+ */
22
+ exports.HANDOFFS_DIR_NAME = 'handoffs';
14
23
  /**
15
24
  * Composite identity of the v23 migration that adds `.nx/migrate-runs` to
16
25
  * `.gitignore`. Hard-coded because the agentic preflight is a deliberate
@@ -1,5 +1,6 @@
1
1
  import { CommandModule } from 'yargs';
2
2
  import type { AgenticArg } from './agentic/select';
3
+ import { type StepAction } from './step-actions';
3
4
  export declare const yargsMigrateCommand: CommandModule;
4
5
  export declare const yargsInternalMigrateCommand: CommandModule;
5
6
  export declare const DEFAULT_MIGRATION_COMMIT_PREFIX = "chore: [nx migration] ";
@@ -18,6 +19,8 @@ export interface MigrateArgs {
18
19
  packageAndVersion?: string;
19
20
  runMigrations?: string;
20
21
  runMigration?: string;
22
+ runId?: string;
23
+ stepAction?: StepAction;
21
24
  include?: MigrateInclude;
22
25
  /**
23
26
  * nx.json `migrate.include` default. Consumed by `resolveInclude` only when the
@@ -6,6 +6,7 @@ const handle_import_1 = require("../../utils/handle-import");
6
6
  const documentation_1 = require("../yargs-utils/documentation");
7
7
  const shared_options_1 = require("../yargs-utils/shared-options");
8
8
  const cli_args_1 = require("./agentic/cli-args");
9
+ const step_actions_1 = require("./step-actions");
9
10
  exports.yargsMigrateCommand = {
10
11
  command: 'migrate [packageAndVersion]',
11
12
  describe: `Creates a migrations file or runs migrations from the migrations file.
@@ -56,6 +57,18 @@ function withMigrationOptions(yargs) {
56
57
  .option('runMigration', {
57
58
  describe: "Run a single migration from migrations.json by id. The id is '<package>:<name>'; a bare '<name>' is accepted when it matches exactly one migration. A name that contains ':' must use the full '<package>:<name>' form.",
58
59
  type: 'string',
60
+ })
61
+ .option('runId', {
62
+ // Hidden with the orchestrator itself.
63
+ describe: 'The orchestrated migrate run to record a single migration into, or to reconcile when given without --run-migration.',
64
+ type: 'string',
65
+ hidden: true,
66
+ })
67
+ .option('stepAction', {
68
+ describe: 'How an orchestrated reconcile resolves its single failed or died step.',
69
+ choices: step_actions_1.STEP_ACTIONS,
70
+ type: 'string',
71
+ hidden: true,
59
72
  })
60
73
  .option('ifExists', {
61
74
  describe: `Run migrations only if the migrations file exists, if not continues successfully.`,
@@ -28,8 +28,15 @@ export declare class ChangedDepInstaller {
28
28
  private readonly rerunCommand?;
29
29
  private initialDeps;
30
30
  private _skippedInstall;
31
+ private _installed;
31
32
  constructor(root: string, shouldSkipInstall?: boolean, rerunCommand?: string);
32
33
  get skippedInstall(): boolean;
34
+ /**
35
+ * Whether an install actually ran. Distinct from `!skippedInstall`, which is
36
+ * only about the skip-install flag: dependencies that never changed leave
37
+ * both false.
38
+ */
39
+ get installed(): boolean;
33
40
  installDepsIfChanged(): Promise<void>;
34
41
  }
35
42
  export declare function runNxOrAngularMigration(root: string, migration: {
@@ -45,6 +52,13 @@ export declare function runNxOrAngularMigration(root: string, migration: {
45
52
  logs: string;
46
53
  madeChanges: boolean;
47
54
  }>;
55
+ /**
56
+ * The workspace's declared dependencies, serialized for equality comparison,
57
+ * or `null` when package.json could not be read or parsed. Callers that
58
+ * persist the value across processes need that distinction: an unreadable
59
+ * package.json is not an empty dependency set.
60
+ */
61
+ export declare function readPackageJsonDeps(root: string): string | null;
48
62
  export declare function getStringifiedPackageJsonDeps(root: string): string;
49
63
  export declare function runNxMigration(root: string, collectionPath: string, collection: MigrationsJson, name: string, migrationVersion: string | undefined, captureGeneratorOutput: boolean): Promise<{
50
64
  changes: FileChange[];
@@ -8,6 +8,7 @@ exports.formatSingleMigrationRerunCommand = formatSingleMigrationRerunCommand;
8
8
  exports.logNpmPeerDepsError = logNpmPeerDepsError;
9
9
  exports.logSkippedPostMigrationInstall = logSkippedPostMigrationInstall;
10
10
  exports.runNxOrAngularMigration = runNxOrAngularMigration;
11
+ exports.readPackageJsonDeps = readPackageJsonDeps;
11
12
  exports.getStringifiedPackageJsonDeps = getStringifiedPackageJsonDeps;
12
13
  exports.runNxMigration = runNxMigration;
13
14
  exports.parseMigrationReturn = parseMigrationReturn;
@@ -25,6 +26,7 @@ const handle_import_1 = require("../../utils/handle-import");
25
26
  const tree_1 = require("../../generators/tree");
26
27
  const fileutils_1 = require("../../utils/fileutils");
27
28
  const logger_1 = require("../../utils/logger");
29
+ const text_1 = require("./text");
28
30
  const package_json_1 = require("../../utils/package-json");
29
31
  const package_manager_1 = require("../../utils/package-manager");
30
32
  const output_1 = require("../../utils/output");
@@ -199,11 +201,20 @@ class ChangedDepInstaller {
199
201
  this.shouldSkipInstall = shouldSkipInstall;
200
202
  this.rerunCommand = rerunCommand;
201
203
  this._skippedInstall = false;
204
+ this._installed = false;
202
205
  this.initialDeps = getStringifiedPackageJsonDeps(root);
203
206
  }
204
207
  get skippedInstall() {
205
208
  return this._skippedInstall;
206
209
  }
210
+ /**
211
+ * Whether an install actually ran. Distinct from `!skippedInstall`, which is
212
+ * only about the skip-install flag: dependencies that never changed leave
213
+ * both false.
214
+ */
215
+ get installed() {
216
+ return this._installed;
217
+ }
207
218
  async installDepsIfChanged() {
208
219
  const currentDeps = getStringifiedPackageJsonDeps(this.root);
209
220
  if (this.initialDeps !== currentDeps) {
@@ -212,6 +223,7 @@ class ChangedDepInstaller {
212
223
  }
213
224
  else {
214
225
  await runInstall(this.root, 'post-migration', this.rerunCommand);
226
+ this._installed = true;
215
227
  }
216
228
  }
217
229
  this.initialDeps = currentDeps;
@@ -235,9 +247,9 @@ async function runNxOrAngularMigration(root, migration, isVerbose, captureGenera
235
247
  ({ nextSteps, changes, agentContext, skipAgentic, logs } =
236
248
  await runNxMigration(root, collectionPath, collection, migration.name, migration.version, captureGeneratorOutput));
237
249
  madeChanges = changes.length > 0;
238
- logger_1.logger.info(`Ran ${migration.name} from ${migration.package}`);
250
+ logger_1.logger.info((0, text_1.singleLine)(`Ran ${migration.name} from ${migration.package}`));
239
251
  if (migration.description) {
240
- logger_1.logger.info(` ${migration.description}`);
252
+ logger_1.logger.info((0, text_1.singleLine)(` ${migration.description}`));
241
253
  }
242
254
  logger_1.logger.info('');
243
255
  if (!madeChanges) {
@@ -262,9 +274,9 @@ async function runNxOrAngularMigration(root, migration, isVerbose, captureGenera
262
274
  changes = ngResult.changes;
263
275
  madeChanges = ngResult.madeChanges;
264
276
  logs = ngResult.loggingQueue.join('\n');
265
- logger_1.logger.info(`Ran ${migration.name} from ${migration.package}`);
277
+ logger_1.logger.info((0, text_1.singleLine)(`Ran ${migration.name} from ${migration.package}`));
266
278
  if (migration.description) {
267
- logger_1.logger.info(` ${migration.description}`);
279
+ logger_1.logger.info((0, text_1.singleLine)(` ${migration.description}`));
268
280
  }
269
281
  logger_1.logger.info('');
270
282
  if (!madeChanges) {
@@ -279,22 +291,31 @@ async function runNxOrAngularMigration(root, migration, isVerbose, captureGenera
279
291
  };
280
292
  }
281
293
  logger_1.logger.info('Changes:');
282
- ngResult.loggingQueue.forEach((log) => logger_1.logger.info(' ' + log));
294
+ ngResult.loggingQueue.forEach((log) => logger_1.logger.info((0, text_1.singleLine)(' ' + log)));
283
295
  logger_1.logger.info('');
284
296
  }
285
297
  return { changes, nextSteps, agentContext, skipAgentic, logs, madeChanges };
286
298
  }
287
- function getStringifiedPackageJsonDeps(root) {
299
+ /**
300
+ * The workspace's declared dependencies, serialized for equality comparison,
301
+ * or `null` when package.json could not be read or parsed. Callers that
302
+ * persist the value across processes need that distinction: an unreadable
303
+ * package.json is not an empty dependency set.
304
+ */
305
+ function readPackageJsonDeps(root) {
288
306
  try {
289
307
  const { dependencies, devDependencies } = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, 'package.json'));
290
308
  return JSON.stringify([dependencies, devDependencies]);
291
309
  }
292
310
  catch {
293
- // We don't really care if the .nx/installation property changes,
294
- // whenever nxw is invoked it will handle the dep updates.
295
- return '';
311
+ return null;
296
312
  }
297
313
  }
314
+ function getStringifiedPackageJsonDeps(root) {
315
+ // We don't really care if the .nx/installation property changes,
316
+ // whenever nxw is invoked it will handle the dep updates.
317
+ return readPackageJsonDeps(root) ?? '';
318
+ }
298
319
  async function runNxMigration(root, collectionPath, collection, name, migrationVersion, captureGeneratorOutput) {
299
320
  const { path: implPath, fnSymbol } = getImplementationPath(collection, collectionPath, name, migrationVersion);
300
321
  const fn = require(implPath)[fnSymbol];
@@ -67,12 +67,40 @@ export declare function reportMigrateRunError(opts: {
67
67
  migrationCount?: number;
68
68
  error?: unknown;
69
69
  }): void;
70
+ export declare function reportMigrateOrchestratorInit(opts: {
71
+ migrationCount: number;
72
+ createCommits: boolean;
73
+ }): void;
74
+ /**
75
+ * One event per orchestrator dispense. The `action` (dispense case) is a
76
+ * closed enum carried on a reused dimension, read conditioned on the event
77
+ * name (the same multiplexing pattern as {@link reportMigratePrompt});
78
+ * `attempt` rides the migration-count dimension.
79
+ */
80
+ export declare function reportMigrateOrchestratorDispense(opts: {
81
+ action: string;
82
+ attempt: number;
83
+ }): void;
84
+ /**
85
+ * Terminal funnel event. The two step tallies and the total dispense count
86
+ * ride reused numeric dimensions, read conditioned on the event name.
87
+ */
88
+ export declare function reportMigrateOrchestratorComplete(opts: {
89
+ completed: number;
90
+ skipped: number;
91
+ dispenseCount: number;
92
+ }): void;
70
93
  /**
71
94
  * Counts invocations, not completions: emitted as soon as the migration id
72
95
  * resolves, while the worker can still stop before running anything.
96
+ *
97
+ * An invocation recorded into an orchestrated run (`--run-id`) gets its own
98
+ * event name. Every other one keeps the name `--run-migration` shipped with,
99
+ * so that series stays continuous for users who never enable the orchestrator.
73
100
  */
74
101
  export declare function reportMigrateSingleMigrationInvocation(opts: {
75
102
  migrationType: 'generator' | 'prompt' | 'hybrid';
103
+ orchestrated: boolean;
76
104
  }): void;
77
105
  export declare function computeMajorsCrossed(installed: string | null | undefined, target: string | null | undefined): number | undefined;
78
106
  export declare function safeReport(emit: () => void): void;
@@ -11,6 +11,9 @@ exports.reportMigrateRunStart = reportMigrateRunStart;
11
11
  exports.hasMigrateRunStarted = hasMigrateRunStarted;
12
12
  exports.reportMigrateRunComplete = reportMigrateRunComplete;
13
13
  exports.reportMigrateRunError = reportMigrateRunError;
14
+ exports.reportMigrateOrchestratorInit = reportMigrateOrchestratorInit;
15
+ exports.reportMigrateOrchestratorDispense = reportMigrateOrchestratorDispense;
16
+ exports.reportMigrateOrchestratorComplete = reportMigrateOrchestratorComplete;
14
17
  exports.reportMigrateSingleMigrationInvocation = reportMigrateSingleMigrationInvocation;
15
18
  exports.computeMajorsCrossed = computeMajorsCrossed;
16
19
  exports.safeReport = safeReport;
@@ -181,15 +184,62 @@ function reportMigrateRunError(opts) {
181
184
  });
182
185
  });
183
186
  }
187
+ function reportMigrateOrchestratorInit(opts) {
188
+ safeReport(() => {
189
+ if (!analytics_1.customDimensions)
190
+ return;
191
+ (0, analytics_1.reportEvent)('migrate_orchestrator_init', {
192
+ [analytics_1.customDimensions.createCommits]: opts.createCommits,
193
+ [analytics_1.customDimensions.migrationCount]: opts.migrationCount,
194
+ });
195
+ });
196
+ }
197
+ /**
198
+ * One event per orchestrator dispense. The `action` (dispense case) is a
199
+ * closed enum carried on a reused dimension, read conditioned on the event
200
+ * name (the same multiplexing pattern as {@link reportMigratePrompt});
201
+ * `attempt` rides the migration-count dimension.
202
+ */
203
+ function reportMigrateOrchestratorDispense(opts) {
204
+ safeReport(() => {
205
+ if (!analytics_1.customDimensions)
206
+ return;
207
+ (0, analytics_1.reportEvent)('migrate_orchestrator_dispense', {
208
+ [analytics_1.customDimensions.promptChoice]: opts.action,
209
+ [analytics_1.customDimensions.migrationCount]: opts.attempt,
210
+ });
211
+ });
212
+ }
213
+ /**
214
+ * Terminal funnel event. The two step tallies and the total dispense count
215
+ * ride reused numeric dimensions, read conditioned on the event name.
216
+ */
217
+ function reportMigrateOrchestratorComplete(opts) {
218
+ safeReport(() => {
219
+ if (!analytics_1.customDimensions)
220
+ return;
221
+ (0, analytics_1.reportEvent)('migrate_orchestrator_complete', {
222
+ [analytics_1.customDimensions.appliedCount]: opts.completed,
223
+ [analytics_1.customDimensions.taskCount]: opts.skipped,
224
+ [analytics_1.customDimensions.migrationCount]: opts.dispenseCount,
225
+ });
226
+ });
227
+ }
184
228
  /**
185
229
  * Counts invocations, not completions: emitted as soon as the migration id
186
230
  * resolves, while the worker can still stop before running anything.
231
+ *
232
+ * An invocation recorded into an orchestrated run (`--run-id`) gets its own
233
+ * event name. Every other one keeps the name `--run-migration` shipped with,
234
+ * so that series stays continuous for users who never enable the orchestrator.
187
235
  */
188
236
  function reportMigrateSingleMigrationInvocation(opts) {
189
237
  safeReport(() => {
190
238
  if (!analytics_1.customDimensions)
191
239
  return;
192
- (0, analytics_1.reportEvent)('migrate_single_migration_invocation', {
240
+ (0, analytics_1.reportEvent)(opts.orchestrated
241
+ ? 'migrate_single_migration_recorded'
242
+ : 'migrate_single_migration_invocation', {
193
243
  [analytics_1.customDimensions.promptChoice]: opts.migrationType,
194
244
  });
195
245
  });
@@ -55,7 +55,7 @@ export declare function commitCheckpointBeforeMigrations(root: string, commitPre
55
55
  */
56
56
  export declare function resolveCreateCommits(args: {
57
57
  createCommits: boolean | undefined;
58
- agenticKind: ResolvedAgentic['kind'];
58
+ mode: ResolvedAgentic['kind'] | 'orchestrated';
59
59
  isGitRepo: boolean;
60
60
  commitPrefixIsCustom?: boolean;
61
61
  }): {
@@ -65,9 +65,15 @@ export declare function resolveCreateCommits(args: {
65
65
  error?: string;
66
66
  };
67
67
  /**
68
+ * Asks before a run starts committing on the workspace's default branch, and
69
+ * reports the decision when the answer is no. Returns whether to proceed.
70
+ *
68
71
  * Callers gate this on commits being effective and on prompting being
69
- * possible, so non-interactive runs (CI, `--no-interactive`) never reach here.
72
+ * possible, so non-interactive runs (CI, `--no-interactive`) never reach here;
73
+ * `confirmCommitsOnDefaultBranch` has no guard of its own and would block on a
74
+ * prompt nobody can answer.
70
75
  */
76
+ export declare function confirmMigrationCommitsOnDefaultBranch(root: string, whatWouldRun: 'running migrations' | 'running the migration'): Promise<boolean>;
71
77
  export declare function confirmCommitsOnDefaultBranch(args: {
72
78
  currentBranch: string | null;
73
79
  defaultBranch: string | null;