nx 23.2.0-beta.0 → 23.2.0-beta.10

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 (374) hide show
  1. package/dist/bin/init-local.js +3 -5
  2. package/dist/bin/nx.js +3 -1
  3. package/dist/release/changelog-renderer/index.js +4 -5
  4. package/dist/release/index.d.ts +1 -1
  5. package/dist/src/adapter/ngcli-adapter.js +60 -1
  6. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +35 -15
  7. package/dist/src/analytics/analytics.d.ts +6 -0
  8. package/dist/src/analytics/analytics.js +16 -10
  9. package/dist/src/analytics/index.d.ts +1 -1
  10. package/dist/src/analytics/index.js +2 -1
  11. package/dist/src/command-line/add/add.js +5 -0
  12. package/dist/src/command-line/affected/affected.js +1 -0
  13. package/dist/src/command-line/completion/command-object.js +7 -12
  14. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +19 -25
  15. package/dist/src/command-line/format/format.js +84 -101
  16. package/dist/src/command-line/generate/generate.js +35 -35
  17. package/dist/src/command-line/graph/graph.d.ts +1 -0
  18. package/dist/src/command-line/graph/graph.js +15 -6
  19. package/dist/src/command-line/import/import.js +30 -40
  20. package/dist/src/command-line/init/ai-agent-prompts.d.ts +1 -1
  21. package/dist/src/command-line/init/ai-agent-prompts.js +12 -17
  22. package/dist/src/command-line/init/command-object.js +14 -4
  23. package/dist/src/command-line/init/configure-plugins.js +4 -1
  24. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
  25. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +17 -21
  26. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
  27. package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +3 -17
  28. package/dist/src/command-line/init/implementation/angular/index.js +10 -15
  29. package/dist/src/command-line/init/implementation/angular/integrated-workspace.js +2 -5
  30. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +5 -0
  31. package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +8 -2
  32. package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +2 -0
  33. package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +9 -1
  34. package/dist/src/command-line/init/implementation/format.d.ts +18 -0
  35. package/dist/src/command-line/init/implementation/format.js +114 -0
  36. package/dist/src/command-line/init/implementation/utils.js +8 -0
  37. package/dist/src/command-line/init/init-v1.js +15 -18
  38. package/dist/src/command-line/init/init-v2.js +40 -57
  39. package/dist/src/command-line/migrate/agentic/definitions.js +36 -9
  40. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +37 -22
  41. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +30 -39
  42. package/dist/src/command-line/migrate/agentic/handoff.d.ts +7 -7
  43. package/dist/src/command-line/migrate/agentic/handoff.js +13 -10
  44. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +7 -12
  45. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +7 -0
  46. package/dist/src/command-line/migrate/agentic/run-step.d.ts +10 -0
  47. package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
  48. package/dist/src/command-line/migrate/agentic/runner.js +24 -24
  49. package/dist/src/command-line/migrate/agentic/select.d.ts +10 -2
  50. package/dist/src/command-line/migrate/agentic/select.js +30 -32
  51. package/dist/src/command-line/migrate/agentic/types.d.ts +33 -3
  52. package/dist/src/command-line/migrate/agentic/types.js +35 -0
  53. package/dist/src/command-line/migrate/command-object.d.ts +6 -0
  54. package/dist/src/command-line/migrate/command-object.js +19 -1
  55. package/dist/src/command-line/migrate/execute-migration.d.ts +91 -0
  56. package/dist/src/command-line/migrate/execute-migration.js +474 -0
  57. package/dist/src/command-line/migrate/migrate-analytics.d.ts +35 -0
  58. package/dist/src/command-line/migrate/migrate-analytics.js +64 -0
  59. package/dist/src/command-line/migrate/migrate-commits.d.ts +38 -8
  60. package/dist/src/command-line/migrate/migrate-commits.js +130 -15
  61. package/dist/src/command-line/migrate/migrate-config.d.ts +13 -12
  62. package/dist/src/command-line/migrate/migrate-config.js +22 -14
  63. package/dist/src/command-line/migrate/migrate-output.d.ts +45 -7
  64. package/dist/src/command-line/migrate/migrate-output.js +52 -8
  65. package/dist/src/command-line/migrate/migrate-ui-api.d.ts +2 -1
  66. package/dist/src/command-line/migrate/migrate-ui-api.js +33 -19
  67. package/dist/src/command-line/migrate/migrate.d.ts +29 -113
  68. package/dist/src/command-line/migrate/migrate.js +666 -664
  69. package/dist/src/command-line/migrate/migration-shape.d.ts +8 -0
  70. package/dist/src/command-line/migrate/multi-major.js +7 -10
  71. package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
  72. package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
  73. package/dist/src/command-line/migrate/run/agent-output.js +65 -0
  74. package/dist/src/command-line/migrate/run/index.d.ts +9 -0
  75. package/dist/src/command-line/migrate/run/index.js +23 -0
  76. package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
  77. package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
  78. package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
  79. package/dist/src/command-line/migrate/run/run-id.js +56 -0
  80. package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
  81. package/dist/src/command-line/migrate/run/run-state.js +438 -0
  82. package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
  83. package/dist/src/command-line/migrate/run/state-lock.js +76 -0
  84. package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
  85. package/dist/src/command-line/migrate/run/state-machine.js +315 -0
  86. package/dist/src/command-line/migrate/run/util.d.ts +59 -0
  87. package/dist/src/command-line/migrate/run/util.js +148 -0
  88. package/dist/src/command-line/migrate/run/worker.d.ts +16 -0
  89. package/dist/src/command-line/migrate/run/worker.js +682 -0
  90. package/dist/src/command-line/migrate/run-migration-process.js +6 -5
  91. package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
  92. package/dist/src/command-line/migrate/safe-prompt.js +32 -43
  93. package/dist/src/command-line/migrate/sort-migrations.d.ts +16 -0
  94. package/dist/src/command-line/migrate/sort-migrations.js +32 -0
  95. package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
  96. package/dist/src/command-line/migrate/step-actions.js +12 -0
  97. package/dist/src/command-line/migrate/text.d.ts +18 -0
  98. package/dist/src/command-line/migrate/text.js +26 -0
  99. package/dist/src/command-line/migrate/version-skew-guard.d.ts +60 -0
  100. package/dist/src/command-line/migrate/version-skew-guard.js +175 -0
  101. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +17 -21
  102. package/dist/src/command-line/nx-cloud/connect/view-logs.js +2 -0
  103. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.d.ts +2 -0
  104. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.js +16 -0
  105. package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.d.ts +4 -0
  106. package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.js +13 -0
  107. package/dist/src/command-line/nx-commands.js +26 -24
  108. package/dist/src/command-line/release/changelog.js +11 -17
  109. package/dist/src/command-line/release/index.d.ts +1 -1
  110. package/dist/src/command-line/release/plan.js +15 -28
  111. package/dist/src/command-line/release/publish.js +5 -0
  112. package/dist/src/command-line/release/release.js +6 -17
  113. package/dist/src/command-line/release/utils/git.js +1 -1
  114. package/dist/src/command-line/release/utils/release-graph.d.ts +20 -2
  115. package/dist/src/command-line/release/utils/release-graph.js +81 -21
  116. package/dist/src/command-line/release/utils/remote-release-clients/github.js +17 -23
  117. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +14 -23
  118. package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
  119. package/dist/src/command-line/release/utils/shared.d.ts +2 -2
  120. package/dist/src/command-line/release/version/release-group-processor.d.ts +24 -0
  121. package/dist/src/command-line/release/version/release-group-processor.js +80 -6
  122. package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
  123. package/dist/src/command-line/release/version/version-actions.d.ts +27 -2
  124. package/dist/src/command-line/release/version/version-actions.js +9 -1
  125. package/dist/src/command-line/release/version.js +10 -6
  126. package/dist/src/command-line/reset/reset.js +6 -1
  127. package/dist/src/command-line/run/run-one.js +1 -0
  128. package/dist/src/command-line/run-many/run-many.js +1 -0
  129. package/dist/src/command-line/show/show-target/inputs.js +50 -153
  130. package/dist/src/command-line/show/show-target/outputs.js +48 -173
  131. package/dist/src/command-line/show/show-target/utils.d.ts +28 -0
  132. package/dist/src/command-line/show/show-target/utils.js +83 -3
  133. package/dist/src/command-line/watch/watch.js +13 -0
  134. package/dist/src/command-line/yargs-utils/shared-options.d.ts +2 -2
  135. package/dist/src/command-line/yargs-utils/shared-options.js +3 -1
  136. package/dist/src/commands-runner/create-command-graph.js +5 -0
  137. package/dist/src/config/misc-interfaces.d.ts +19 -7
  138. package/dist/src/config/nx-json.d.ts +5 -3
  139. package/dist/src/core/graph/main.js +1 -1
  140. package/dist/src/core/graph/styles.js +1 -1
  141. package/dist/src/daemon/client/client.d.ts +52 -1
  142. package/dist/src/daemon/client/client.js +160 -36
  143. package/dist/src/daemon/client/daemon-environment.d.ts +17 -0
  144. package/dist/src/daemon/client/daemon-environment.js +110 -2
  145. package/dist/src/daemon/client/daemon-socket-messenger.js +4 -0
  146. package/dist/src/daemon/message-types/daemon-message.d.ts +32 -0
  147. package/dist/src/daemon/message-types/daemon-message.js +25 -0
  148. package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +5 -0
  149. package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +16 -0
  150. package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +1 -1
  151. package/dist/src/daemon/server/latest-nx.js +5 -2
  152. package/dist/src/daemon/server/server.js +31 -4
  153. package/dist/src/daemon/server/shutdown-utils.d.ts +5 -0
  154. package/dist/src/daemon/server/shutdown-utils.js +11 -4
  155. package/dist/src/daemon/socket-utils.d.ts +1 -0
  156. package/dist/src/daemon/socket-utils.js +24 -3
  157. package/dist/src/daemon/tmp-dir.d.ts +43 -3
  158. package/dist/src/daemon/tmp-dir.js +437 -15
  159. package/dist/src/devkit-internals.d.ts +105 -8
  160. package/dist/src/devkit-internals.js +223 -7
  161. package/dist/src/executors/run-commands/running-tasks.js +46 -29
  162. package/dist/src/generators/internal-utils/format-changed-files.d.ts +24 -0
  163. package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
  164. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
  165. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
  166. package/dist/src/generators/tree.d.ts +4 -2
  167. package/dist/src/generators/utils/nx-json.js +13 -3
  168. package/dist/src/hasher/check-task-files.d.ts +86 -0
  169. package/dist/src/hasher/check-task-files.js +378 -0
  170. package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
  171. package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
  172. package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
  173. package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
  174. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
  175. package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
  176. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
  177. package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
  178. package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
  179. package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
  180. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
  181. package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
  182. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
  183. package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
  184. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
  185. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
  186. package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
  187. package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
  188. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
  189. package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
  190. package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
  191. package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
  192. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
  193. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
  194. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
  195. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
  196. package/dist/src/native/index.d.ts +37 -4
  197. package/dist/src/native/index.js +71 -28
  198. package/dist/src/native/native-bindings.js +3 -0
  199. package/dist/src/native/native-file-cache-location.d.ts +17 -1
  200. package/dist/src/native/native-file-cache-location.js +86 -12
  201. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  202. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  203. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
  204. package/dist/src/nx-cloud/utilities/get-cloud-options.js +5 -2
  205. package/dist/src/nx-cloud/utilities/onboarding.js +5 -2
  206. package/dist/src/nx-cloud/utilities/url-shorten.d.ts +1 -4
  207. package/dist/src/nx-cloud/utilities/url-shorten.js +9 -8
  208. package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
  209. package/dist/src/plugins/js/lock-file/lock-file.d.ts +46 -4
  210. package/dist/src/plugins/js/lock-file/lock-file.js +192 -15
  211. package/dist/src/plugins/js/lock-file/pnpm-parser.js +420 -64
  212. package/dist/src/plugins/js/lock-file/project-graph-pruning.d.ts +25 -1
  213. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +92 -12
  214. package/dist/src/plugins/js/lock-file/pruned-output.d.ts +330 -0
  215. package/dist/src/plugins/js/lock-file/pruned-output.js +1441 -0
  216. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +1 -0
  217. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +9 -5
  218. package/dist/src/plugins/js/project-graph/affected/npm-packages.js +51 -20
  219. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +14 -4
  220. package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +1 -1
  221. package/dist/src/project-graph/affected/affected-project-graph.d.ts +1 -1
  222. package/dist/src/project-graph/affected/affected-project-graph.js +2 -2
  223. package/dist/src/project-graph/affected/locators/project-glob-changes.js +5 -2
  224. package/dist/src/project-graph/build-project-graph.js +7 -1
  225. package/dist/src/project-graph/error-types.d.ts +12 -1
  226. package/dist/src/project-graph/error-types.js +27 -2
  227. package/dist/src/project-graph/file-utils.js +6 -1
  228. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +1 -0
  229. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +18 -1
  230. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +16 -3
  231. package/dist/src/project-graph/plugins/isolation/messaging.js +3 -0
  232. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +58 -8
  233. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +1 -0
  234. package/dist/src/project-graph/project-graph.js +23 -0
  235. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +1 -0
  236. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.js +16 -2
  237. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +12 -8
  238. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +30 -21
  239. package/dist/src/project-graph/utils/project-configuration/source-maps.d.ts +12 -5
  240. package/dist/src/project-graph/utils/project-configuration/source-maps.js +21 -7
  241. package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +1 -1
  242. package/dist/src/project-graph/utils/project-configuration/target-defaults.js +26 -27
  243. package/dist/src/project-graph/utils/project-configuration/target-merging.js +50 -8
  244. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +149 -6
  245. package/dist/src/project-graph/utils/project-configuration/utils.d.ts +15 -0
  246. package/dist/src/project-graph/utils/project-configuration/utils.js +42 -6
  247. package/dist/src/project-graph/utils/project-configuration-utils.d.ts +15 -12
  248. package/dist/src/project-graph/utils/project-configuration-utils.js +79 -99
  249. package/dist/src/tasks-runner/is-tui-enabled.js +3 -1
  250. package/dist/src/tasks-runner/life-cycle.d.ts +2 -2
  251. package/dist/src/tasks-runner/life-cycle.js +2 -2
  252. package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +9 -4
  253. package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +5 -4
  254. package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +28 -8
  255. package/dist/src/tasks-runner/life-cycles/performance-report.js +117 -30
  256. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +26 -1
  257. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +99 -5
  258. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +26 -0
  259. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +113 -17
  260. package/dist/src/tasks-runner/pseudo-terminal.d.ts +17 -3
  261. package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
  262. package/dist/src/tasks-runner/run-command.js +28 -35
  263. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +55 -0
  264. package/dist/src/tasks-runner/running-tasks/batch-process.js +161 -8
  265. package/dist/src/tasks-runner/task-env.d.ts +9 -0
  266. package/dist/src/tasks-runner/task-env.js +31 -4
  267. package/dist/src/tasks-runner/task-orchestrator.d.ts +72 -1
  268. package/dist/src/tasks-runner/task-orchestrator.js +182 -18
  269. package/dist/src/tasks-runner/utils.js +2 -6
  270. package/dist/src/utils/acknowledge-build-scripts.js +7 -5
  271. package/dist/src/utils/analytics-enabled.d.ts +7 -0
  272. package/dist/src/utils/analytics-enabled.js +11 -0
  273. package/dist/src/utils/analytics-prompt.d.ts +0 -6
  274. package/dist/src/utils/analytics-prompt.js +4 -58
  275. package/dist/src/utils/assert-workspace-validity.js +7 -2
  276. package/dist/src/utils/catalog/bun-manager-utils.d.ts +8 -0
  277. package/dist/src/utils/catalog/bun-manager-utils.js +174 -0
  278. package/dist/src/utils/catalog/bun-manager.d.ts +28 -0
  279. package/dist/src/utils/catalog/bun-manager.js +130 -0
  280. package/dist/src/utils/catalog/index.d.ts +1 -1
  281. package/dist/src/utils/catalog/index.js +1 -1
  282. package/dist/src/utils/catalog/manager-factory.js +3 -0
  283. package/dist/src/utils/catalog/manager-utils.d.ts +8 -1
  284. package/dist/src/utils/catalog/manager-utils.js +9 -4
  285. package/dist/src/utils/catalog/manager.d.ts +13 -1
  286. package/dist/src/utils/catalog/manager.js +30 -0
  287. package/dist/src/utils/catalog/pnpm-manager.d.ts +2 -1
  288. package/dist/src/utils/catalog/pnpm-manager.js +3 -0
  289. package/dist/src/utils/catalog/types.d.ts +4 -0
  290. package/dist/src/utils/catalog/yarn-manager.d.ts +6 -2
  291. package/dist/src/utils/catalog/yarn-manager.js +23 -32
  292. package/dist/src/utils/child-process.d.ts +31 -1
  293. package/dist/src/utils/child-process.js +103 -0
  294. package/dist/src/utils/chunkify.d.ts +7 -1
  295. package/dist/src/utils/chunkify.js +10 -3
  296. package/dist/src/utils/command-line-utils.js +30 -20
  297. package/dist/src/utils/exit-codes.d.ts +9 -0
  298. package/dist/src/utils/exit-codes.js +19 -0
  299. package/dist/src/utils/fileutils.d.ts +5 -0
  300. package/dist/src/utils/fileutils.js +7 -2
  301. package/dist/src/utils/formatters/index.d.ts +13 -0
  302. package/dist/src/utils/formatters/index.js +74 -0
  303. package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
  304. package/dist/src/utils/formatters/oxfmt.js +764 -0
  305. package/dist/src/utils/formatters/prettier.d.ts +26 -0
  306. package/dist/src/utils/formatters/prettier.js +201 -0
  307. package/dist/src/utils/formatters/shared.d.ts +5 -0
  308. package/dist/src/utils/formatters/shared.js +8 -0
  309. package/dist/src/utils/git-revision.d.ts +12 -0
  310. package/dist/src/utils/git-revision.js +25 -0
  311. package/dist/src/utils/git-utils.d.ts +48 -2
  312. package/dist/src/utils/git-utils.js +220 -14
  313. package/dist/src/utils/git-worktrees.d.ts +30 -0
  314. package/dist/src/utils/git-worktrees.js +212 -0
  315. package/dist/src/utils/ignore.d.ts +170 -1
  316. package/dist/src/utils/ignore.js +263 -11
  317. package/dist/src/utils/long-running-target.d.ts +10 -0
  318. package/dist/src/utils/long-running-target.js +19 -0
  319. package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
  320. package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
  321. package/dist/src/utils/min-release-age/packument.js +1 -1
  322. package/dist/src/utils/nx-console-prompt.js +3 -6
  323. package/dist/src/utils/nx-tmp-dir.d.ts +18 -0
  324. package/dist/src/utils/nx-tmp-dir.js +40 -0
  325. package/dist/src/utils/output.d.ts +153 -0
  326. package/dist/src/utils/output.js +289 -5
  327. package/dist/src/utils/owned-private-dir.d.ts +132 -0
  328. package/dist/src/utils/owned-private-dir.js +323 -0
  329. package/dist/src/utils/package-json.d.ts +2 -0
  330. package/dist/src/utils/package-json.js +11 -7
  331. package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
  332. package/dist/src/utils/package-manager-config/bunfig.js +49 -0
  333. package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
  334. package/dist/src/utils/package-manager-config/npmrc.js +124 -0
  335. package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
  336. package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
  337. package/dist/src/utils/package-manager.d.ts +23 -2
  338. package/dist/src/utils/package-manager.js +268 -44
  339. package/dist/src/utils/params.d.ts +7 -1
  340. package/dist/src/utils/params.js +64 -6
  341. package/dist/src/utils/plugins/core-plugins.js +4 -0
  342. package/dist/src/utils/prompt-helpers.d.ts +53 -0
  343. package/dist/src/utils/prompt-helpers.js +111 -0
  344. package/dist/src/utils/provenance.js +6 -14
  345. package/dist/src/utils/registry-config/bun.d.ts +2 -0
  346. package/dist/src/utils/registry-config/bun.js +257 -0
  347. package/dist/src/utils/registry-config/index.d.ts +13 -0
  348. package/dist/src/utils/registry-config/index.js +102 -0
  349. package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
  350. package/dist/src/utils/registry-config/pnpm.js +1551 -0
  351. package/dist/src/utils/registry-config/utils.d.ts +195 -0
  352. package/dist/src/utils/registry-config/utils.js +496 -0
  353. package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
  354. package/dist/src/utils/registry-config/yarn-berry.js +612 -0
  355. package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
  356. package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
  357. package/dist/src/utils/safe-spawn.d.ts +24 -0
  358. package/dist/src/utils/safe-spawn.js +104 -0
  359. package/dist/src/utils/shell-quoting.d.ts +15 -0
  360. package/dist/src/utils/shell-quoting.js +35 -0
  361. package/dist/src/utils/wait-for-socket-connection.d.ts +11 -0
  362. package/dist/src/utils/wait-for-socket-connection.js +14 -8
  363. package/dist/src/utils/workspace-id.d.ts +20 -0
  364. package/dist/src/utils/workspace-id.js +54 -0
  365. package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
  366. package/dist/src/utils/write-formatted-json-file.js +5 -4
  367. package/migrations.json +6 -0
  368. package/package.json +29 -19
  369. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +0 -19
  370. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -81
  371. package/dist/src/utils/is-using-prettier.d.ts +0 -3
  372. package/dist/src/utils/is-using-prettier.js +0 -62
  373. package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
  374. package/dist/src/utils/min-release-age/npmrc.js +0 -45
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isHandoffGitignoreMigration = isHandoffGitignoreMigration;
4
3
  exports.applyAgenticHandoffGitignoreFallback = applyAgenticHandoffGitignoreFallback;
5
4
  const tslib_1 = require("tslib");
6
5
  const semver_1 = require("semver");
@@ -9,50 +8,42 @@ const add_migrate_runs_to_git_ignore_1 = tslib_1.__importDefault(require("../../
9
8
  const tree_1 = require("../../../generators/tree");
10
9
  const git_utils_1 = require("../../../utils/git-utils");
11
10
  const logger_1 = require("../../../utils/logger");
11
+ const types_1 = require("./types");
12
12
  /**
13
- * Composite identity of the v23 migration that adds `.nx/migrate-runs` to
14
- * `.gitignore`. Hard-coded because the agentic preflight is a deliberate
15
- * one-off coupling: this exact migration owns the entry that keeps
16
- * `.nx/migrate-runs/<run-id>/...` scratch out of per-migration commits. If
17
- * the migration is ever renamed, this entry must move with it.
18
- */
19
- const HANDOFF_GITIGNORE_MIGRATION_PACKAGE = 'nx';
20
- const HANDOFF_GITIGNORE_MIGRATION_NAME = '23-0-0-add-migrate-runs-to-git-ignore';
21
- function isHandoffGitignoreMigration(m) {
22
- return (m.package === HANDOFF_GITIGNORE_MIGRATION_PACKAGE &&
23
- m.name === HANDOFF_GITIGNORE_MIGRATION_NAME);
24
- }
25
- /**
26
- * Under `--agentic`, the runner writes per-run scratch under
27
- * `.nx/migrate-runs/<run-id>/`. The v23 migration
13
+ * Both the agentic runner and the orchestrator write per-run scratch under
14
+ * `.nx/migrate-runs/<run-id>/`: handoff files in both cases, plus the durable
15
+ * run state and its plan snapshots for the orchestrator. The v23 migration
28
16
  * `23-0-0-add-migrate-runs-to-git-ignore` adds `.nx/migrate-runs` to
29
- * `.gitignore`; without intervention it would run in its declared slot
30
- * (typically late), so earlier per-migration commits would absorb the
31
- * scratch into the user-visible diff.
17
+ * `.gitignore`; in its declared slot (typically late) earlier per-migration
18
+ * commits would absorb the scratch into the user-visible diff.
32
19
  *
33
20
  * Two paths cover the leak, with no overlap:
34
21
  *
35
- * 1. HOIST — handled by the sort comparator in `executeMigrations`. When
36
- * the v23 migration is in the queue, it sorts to position 0 and runs
37
- * first via the normal migration runner (with its own log line and
38
- * commit). Fully traceable in `git log`.
22
+ * 1. HOIST: `sortMigrations`, which `executeMigrations` applies, sorts the
23
+ * v23 migration to position 0 when it is in the queue, so it runs first
24
+ * through the normal runner with its own log line and commit. A
25
+ * single-migration worker run needs no hoisting: the requested migration
26
+ * is the entire queue.
39
27
  *
40
- * 2. INLINE FALLBACK — this function. When the migration is NOT in the
41
- * queue AND the highest target version is < v23 (intra-pre-v23
42
- * `--agentic` run), the migration won't run at all. Apply its body
43
- * inline against an `FsTree` and commit it as a standalone preflight
44
- * commit (or leave in the working tree under `--no-create-commits`).
28
+ * 2. INLINE FALLBACK, this function. When the migration is NOT in the queue
29
+ * AND the highest target version is < v23 (intra-pre-v23 `--agentic`
30
+ * run) it will never run, so apply its body inline against an `FsTree`
31
+ * and commit it as a standalone preflight commit (or leave it in the
32
+ * working tree under `--no-create-commits`).
45
33
  *
46
- * When the migration is not in the queue AND target >= v23, the user is
47
- * past v23 already. They had the entry historically; if it's gone, that's
48
- * a conscious removal we respect.
34
+ * Not in the queue AND target >= v23 means the user is already past v23. They
35
+ * had the entry historically; if it is gone, that is a conscious removal we
36
+ * respect.
49
37
  */
50
- async function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion, effectiveCreateCommits, commitPrefix, root, }) {
51
- if (migrations.some(isHandoffGitignoreMigration)) {
52
- // The hoist path handles this via the sort comparator.
53
- return;
38
+ async function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion, effectiveCreateCommits, commitPrefix, root, applyWhenPlanned = false, commitStandalone = true, }) {
39
+ if (migrations.some(types_1.isHandoffGitignoreMigration)) {
40
+ if (!applyWhenPlanned) {
41
+ // The queue runs it itself: hoisted to the front by the sort comparator
42
+ // in a full run, or as the single requested migration in a worker run.
43
+ return;
44
+ }
54
45
  }
55
- if ((0, semver_1.major)(installedNxVersion) >= 23) {
46
+ else if ((0, semver_1.major)(installedNxVersion) >= 23) {
56
47
  // User is past v23. Respect their `.gitignore` state — if the entry
57
48
  // is missing, that's a conscious removal.
58
49
  return;
@@ -66,13 +57,13 @@ async function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVer
66
57
  return;
67
58
  }
68
59
  (0, tree_1.flushChanges)(root, changes);
69
- logger_1.logger.info(pc.dim(`- Added .nx/migrate-runs to .gitignore so this --agentic run's handoff scratch is ignored.`));
70
- if (!effectiveCreateCommits)
60
+ logger_1.logger.info(pc.dim(`- Added ${types_1.MIGRATE_RUNS_RELATIVE_DIR} to .gitignore so this run's scratch state is ignored.`));
61
+ if (!effectiveCreateCommits || !commitStandalone)
71
62
  return;
72
63
  if (!(0, git_utils_1.hasUncommittedChanges)(root))
73
64
  return;
74
65
  try {
75
- const sha = (0, git_utils_1.tryCommitChanges)(`${commitPrefix}add .nx/migrate-runs to .gitignore`, root);
66
+ const sha = (0, git_utils_1.tryCommitChanges)(`${commitPrefix}add ${types_1.MIGRATE_RUNS_RELATIVE_DIR} to .gitignore`, root, [types_1.MIGRATE_RUNS_RELATIVE_DIR]);
76
67
  if (sha) {
77
68
  logger_1.logger.info(pc.dim(` Commit: ${sha}`));
78
69
  }
@@ -1,12 +1,10 @@
1
1
  import { HandoffFile } from './types';
2
- /**
3
- * Workspace-relative directory holding all migrate-run scratch (handoff
4
- * files). Shared with the agent permission rules in `definitions.ts` so the
5
- * pre-authorized write scope can't drift from the actual layout.
6
- */
7
- export declare const MIGRATE_RUNS_RELATIVE_DIR = ".nx/migrate-runs";
8
2
  /** Returns the run directory for a given workspace + run id (target version). */
9
3
  export declare function runDirPath(workspaceRoot: string, runId: string): string;
4
+ /** The version-derived run id: the highest target version in the plan. */
5
+ export declare function resolveAgenticRunId(migrations: ReadonlyArray<{
6
+ version: string;
7
+ }>): string;
10
8
  /**
11
9
  * `mkdir -p` with a contextual error wrapper. Without this, the raw
12
10
  * ENOSPC/EACCES/EROFS surfaces with no indication of which directory the
@@ -22,7 +20,9 @@ export declare function mkdirSafely(dir: string, purpose: string): void;
22
20
  */
23
21
  export declare function initRunDir(workspaceRoot: string, runId: string): string;
24
22
  /**
25
- * Absolute path of the handoff file for a migration step within a run.
23
+ * Absolute path of the handoff file for a migration step within a run, under
24
+ * the run directory's `handoffs/` subtree: the pre-authorized write scope
25
+ * stops there, so a handoff placed anywhere else costs an approval prompt.
26
26
  * The package's scope (if any) becomes a real subdirectory so the package name
27
27
  * stays readable; two packages can ship a migration with the same name without
28
28
  * colliding because they land in different package subdirectories. Each
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MIGRATE_RUNS_RELATIVE_DIR = void 0;
4
3
  exports.runDirPath = runDirPath;
4
+ exports.resolveAgenticRunId = resolveAgenticRunId;
5
5
  exports.mkdirSafely = mkdirSafely;
6
6
  exports.initRunDir = initRunDir;
7
7
  exports.stepHandoffPath = stepHandoffPath;
@@ -10,15 +10,16 @@ exports.readHandoff = readHandoff;
10
10
  exports.waitForValidHandoff = waitForValidHandoff;
11
11
  const fs_1 = require("fs");
12
12
  const path_1 = require("path");
13
- /**
14
- * Workspace-relative directory holding all migrate-run scratch (handoff
15
- * files). Shared with the agent permission rules in `definitions.ts` so the
16
- * pre-authorized write scope can't drift from the actual layout.
17
- */
18
- exports.MIGRATE_RUNS_RELATIVE_DIR = '.nx/migrate-runs';
13
+ const semver_1 = require("semver");
14
+ const version_utils_1 = require("../version-utils");
15
+ const types_1 = require("./types");
19
16
  /** Returns the run directory for a given workspace + run id (target version). */
20
17
  function runDirPath(workspaceRoot, runId) {
21
- return (0, path_1.join)(workspaceRoot, exports.MIGRATE_RUNS_RELATIVE_DIR, runId);
18
+ return (0, path_1.join)(workspaceRoot, types_1.MIGRATE_RUNS_RELATIVE_DIR, runId);
19
+ }
20
+ /** The version-derived run id: the highest target version in the plan. */
21
+ function resolveAgenticRunId(migrations) {
22
+ return (0, semver_1.rsort)(migrations.map((m) => (0, version_utils_1.normalizeVersion)(m.version)))[0];
22
23
  }
23
24
  /**
24
25
  * `mkdir -p` with a contextual error wrapper. Without this, the raw
@@ -71,14 +72,16 @@ function sanitizeSegment(value) {
71
72
  return sanitized || '_';
72
73
  }
73
74
  /**
74
- * Absolute path of the handoff file for a migration step within a run.
75
+ * Absolute path of the handoff file for a migration step within a run, under
76
+ * the run directory's `handoffs/` subtree: the pre-authorized write scope
77
+ * stops there, so a handoff placed anywhere else costs an approval prompt.
75
78
  * The package's scope (if any) becomes a real subdirectory so the package name
76
79
  * stays readable; two packages can ship a migration with the same name without
77
80
  * colliding because they land in different package subdirectories. Each
78
81
  * segment is sanitized so the path is always writable on every platform.
79
82
  */
80
83
  function stepHandoffPath(runDir, migration) {
81
- return (0, path_1.join)(runDir, ...migration.package.split('/').map(sanitizeSegment), `${sanitizeSegment(migration.name)}.json`);
84
+ return (0, path_1.join)(runDir, types_1.HANDOFFS_DIR_NAME, ...migration.package.split('/').map(sanitizeSegment), `${sanitizeSegment(migration.name)}.json`);
82
85
  }
83
86
  /**
84
87
  * Reads and validates a handoff file written by an agent. Returns a tagged
@@ -1,15 +1,3 @@
1
- /**
2
- * Surfaces a migration's `agentContext` to stdout in an XML-tagged block so an
3
- * outer AI agent driving `nx migrate` can ingest the hints when no inner agent
4
- * step ran to consume them.
5
- *
6
- * Used only when `agentic.kind === 'inside-agent'`. Under `enabled`, the inner
7
- * step consumes `agentContext` via the prompt builders. Under `disabled` the
8
- * run is human-driven and printing agent-targeted context would only add noise.
9
- *
10
- * The label format is unambiguous so the outer agent can locate the block
11
- * within the mixed stdout stream (logger output, migration progress, etc.).
12
- */
13
1
  export interface DroppedAgentContextInput {
14
2
  migration: {
15
3
  package: string;
@@ -19,4 +7,11 @@ export interface DroppedAgentContextInput {
19
7
  agentContext: string[];
20
8
  }
21
9
  export declare function formatDroppedAgentContextForOuterAgent(input: DroppedAgentContextInput): string;
10
+ export declare function escapeXmlAttr(value: string): string;
11
+ /**
12
+ * Both the classic loop and the single-migration worker call this only under
13
+ * `agentic.kind === 'inside-agent'`. Under `enabled` the inner agent step
14
+ * consumes `agentContext` through the prompt builders; under `disabled` the
15
+ * run is human-driven and agent-targeted context is only noise.
16
+ */
22
17
  export declare function printDroppedAgentContextForOuterAgent(input: DroppedAgentContextInput): void;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatDroppedAgentContextForOuterAgent = formatDroppedAgentContextForOuterAgent;
4
+ exports.escapeXmlAttr = escapeXmlAttr;
4
5
  exports.printDroppedAgentContextForOuterAgent = printDroppedAgentContextForOuterAgent;
5
6
  const shared_rendering_1 = require("./prompts/shared-rendering");
6
7
  function formatDroppedAgentContextForOuterAgent(input) {
@@ -40,6 +41,12 @@ function escapeXmlAttr(value) {
40
41
  .replace(/"/g, '&quot;')
41
42
  .replace(/'/g, '&apos;');
42
43
  }
44
+ /**
45
+ * Both the classic loop and the single-migration worker call this only under
46
+ * `agentic.kind === 'inside-agent'`. Under `enabled` the inner agent step
47
+ * consumes `agentContext` through the prompt builders; under `disabled` the
48
+ * run is human-driven and agent-targeted context is only noise.
49
+ */
43
50
  function printDroppedAgentContextForOuterAgent(input) {
44
51
  const block = formatDroppedAgentContextForOuterAgent(input);
45
52
  if (block) {
@@ -22,6 +22,16 @@ export interface AgenticStepResult {
22
22
  */
23
23
  ambiguous: boolean;
24
24
  }
25
+ /**
26
+ * `runStep` travels in the context rather than being imported by its call
27
+ * sites, so this module loads only where the context is built, behind an
28
+ * agentic-enabled gate.
29
+ */
30
+ export interface AgenticRunContext {
31
+ agentic: EnabledResolvedAgentic;
32
+ runDir: string;
33
+ runStep: typeof runAgenticPromptStep;
34
+ }
25
35
  export interface RunAgenticPromptStepInput {
26
36
  root: string;
27
37
  migration: {
@@ -83,6 +83,7 @@ async function runAgenticPromptStep(input) {
83
83
  systemContext,
84
84
  userPrompt,
85
85
  workspaceRoot: root,
86
+ runDirName: (0, path_1.basename)(runDir),
86
87
  },
87
88
  handoffFilePath,
88
89
  });
@@ -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
  }
@@ -10,7 +10,15 @@ export interface ResolveAgenticInput {
10
10
  interactive?: boolean;
11
11
  }
12
12
  /**
13
- * Resolves the agentic state for a `--run-migrations` invocation. Runs once,
14
- * before the migration loop, and its result is cached for every entry.
13
+ * Callers resolve this once per run-phase invocation and reuse the result for
14
+ * every migration it covers.
15
15
  */
16
16
  export declare function resolveAgentic(input: ResolveAgenticInput): Promise<ResolvedAgentic>;
17
+ /**
18
+ * No warning when `--validate` is passed with the agentic flow off: validation
19
+ * requires an active agent session by definition.
20
+ */
21
+ export declare function resolveShouldRunValidation(args: {
22
+ validate: boolean | undefined;
23
+ agenticKind: ResolvedAgentic['kind'];
24
+ }): boolean;
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveAgentic = resolveAgentic;
4
- const tslib_1 = require("tslib");
4
+ exports.resolveShouldRunValidation = resolveShouldRunValidation;
5
5
  const fs_1 = require("fs");
6
6
  const jsonc_parser_1 = require("jsonc-parser");
7
7
  const path_1 = require("path");
8
- const pc = tslib_1.__importStar(require("picocolors"));
9
8
  const output_1 = require("../../../utils/output");
10
9
  const workspace_root_1 = require("../../../utils/workspace-root");
11
10
  const migrate_analytics_1 = require("../migrate-analytics");
@@ -18,8 +17,8 @@ const INSTALL_SUPPORTED_AGENTS_HINT = [
18
17
  ...definitions_1.AGENT_DEFINITIONS.map((def) => ` - ${def.displayName}`),
19
18
  ];
20
19
  /**
21
- * Resolves the agentic state for a `--run-migrations` invocation. Runs once,
22
- * before the migration loop, and its result is cached for every entry.
20
+ * Callers resolve this once per run-phase invocation and reuse the result for
21
+ * every migration it covers.
23
22
  */
24
23
  async function resolveAgentic(input) {
25
24
  if ((0, inception_1.isInsideAgent)()) {
@@ -57,6 +56,13 @@ async function resolveAgentic(input) {
57
56
  }
58
57
  return { kind: 'enabled', selectedAgent: selected };
59
58
  }
59
+ /**
60
+ * No warning when `--validate` is passed with the agentic flow off: validation
61
+ * requires an active agent session by definition.
62
+ */
63
+ function resolveShouldRunValidation(args) {
64
+ return args.validate !== false && args.agenticKind === 'enabled';
65
+ }
60
66
  async function resolveFlag(input, isInteractive, detected) {
61
67
  if (input.agentic === true) {
62
68
  if (!isInteractive) {
@@ -121,46 +127,40 @@ async function firePromptForAgentic(migrations, detected) {
121
127
  const pinChoice = multipleAgents
122
128
  ? [
123
129
  {
124
- name: 'yes-pin',
125
- message: 'Yes, always with the same agent',
126
- description: rememberHint,
130
+ value: 'yes-pin',
131
+ label: 'Yes, always with the same agent',
132
+ hint: rememberHint,
127
133
  },
128
134
  ]
129
135
  : [];
130
136
  const choices = [
131
137
  {
132
- name: 'yes-once',
133
- message: 'Yes, just this time',
134
- description: applyHint,
138
+ value: 'yes-once',
139
+ label: 'Yes, just this time',
140
+ hint: applyHint,
135
141
  },
136
142
  {
137
- name: 'yes-flex',
138
- message: multipleAgents
143
+ value: 'yes-flex',
144
+ label: multipleAgents
139
145
  ? "Yes, always (I'll pick the agent each run)"
140
146
  : 'Yes, always',
141
- description: rememberHint,
147
+ hint: rememberHint,
142
148
  },
143
149
  ...pinChoice,
144
- { name: 'no-once', message: 'No, just this time', description: skipHint },
145
- { 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 },
146
152
  ];
147
153
  // Blank line keeps the prompt from gluing to the previous `npm install`
148
154
  // output or any earlier orchestrator line.
149
155
  console.log();
150
- // `as any`: `footer` and per-choice `description` aren't in enquirer's .d.ts.
151
- const response = await (0, safe_prompt_1.migratePrompt)({
152
- name: 'choice',
153
- 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)({
154
159
  message: 'Enable the agentic flow?',
155
160
  choices,
156
- initial: 0,
157
- footer: function () {
158
- const focused = this.focused;
159
- return focused?.description ? pc.dim(` ${focused.description}`) : '';
160
- },
161
161
  });
162
- (0, migrate_analytics_1.reportMigratePrompt)('agentic', response.choice);
163
- switch (response.choice) {
162
+ (0, migrate_analytics_1.reportMigratePrompt)('agentic', choice);
163
+ switch (choice) {
164
164
  case 'yes-once':
165
165
  return { enabled: true };
166
166
  case 'yes-flex':
@@ -242,12 +242,10 @@ async function selectAgent(detected, explicitId, isInteractive) {
242
242
  requireInteractiveOrAbort(isInteractive);
243
243
  // Blank line keeps the prompt from gluing to the preceding output.
244
244
  console.log();
245
- const response = await (0, safe_prompt_1.migratePrompt)({
246
- name: 'id',
247
- type: 'select',
245
+ const id = await (0, safe_prompt_1.migrateChoice)({
248
246
  message: 'Multiple AI agents detected. Which one should Nx use?',
249
- choices: detected.map((d) => ({ name: d.id, message: d.displayName })),
247
+ choices: detected.map((d) => ({ value: d.id, label: d.displayName })),
250
248
  });
251
- (0, migrate_analytics_1.reportMigratePrompt)('agent_select', response.id);
252
- 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);
253
251
  }
@@ -1,5 +1,27 @@
1
1
  import type { AgentId } from './cli-args';
2
2
  export type { AgentId };
3
+ /**
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
+ * can't drift from the actual layout. It lives here so `definitions.ts`,
8
+ * loaded whenever the agentic flow is resolved, doesn't pull in the handoff
9
+ * runtime for the path alone.
10
+ */
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";
21
+ export declare function isHandoffGitignoreMigration(m: {
22
+ package: string;
23
+ name: string;
24
+ }): boolean;
3
25
  /**
4
26
  * A coding agent that was found on the user's machine, ready to be spawned.
5
27
  *
@@ -21,6 +43,13 @@ export interface InvocationContext {
21
43
  systemContext: string;
22
44
  userPrompt: string;
23
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;
24
53
  }
25
54
  /**
26
55
  * What an agent definition returns from `buildInteractive`. The runner combines
@@ -78,11 +107,12 @@ export type HandoffOutcome = {
78
107
  causeSummary?: string[];
79
108
  };
80
109
  /**
81
- * Result of the up-front resolution phase that runs once per `--run-migrations`
82
- * invocation, before the migration loop. Cached and consulted for every entry.
110
+ * Result of the up-front resolution phase, run once per run-phase invocation
111
+ * and applied to every migration it covers.
83
112
  *
84
113
  * - `inside-agent`: nx detected it is itself running inside another agent;
85
- * every agentic step is skipped and prompt migrations go to `nextSteps`.
114
+ * every agentic step is skipped and prompt migrations are surfaced for the
115
+ * outer agent to apply.
86
116
  * - `disabled`: the user opted out (explicit `--agentic=false`, declined the
87
117
  * up-front prompt, or non-TTY without the flag).
88
118
  * - `enabled`: the agentic flow runs and `selectedAgent` is the agent it
@@ -1,2 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HANDOFFS_DIR_NAME = exports.MIGRATE_RUNS_RELATIVE_DIR = void 0;
4
+ exports.isHandoffGitignoreMigration = isHandoffGitignoreMigration;
5
+ /**
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
+ * can't drift from the actual layout. It lives here so `definitions.ts`,
10
+ * loaded whenever the agentic flow is resolved, doesn't pull in the handoff
11
+ * runtime for the path alone.
12
+ */
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';
23
+ /**
24
+ * Composite identity of the v23 migration that adds `.nx/migrate-runs` to
25
+ * `.gitignore`. Hard-coded because the agentic preflight is a deliberate
26
+ * one-off coupling: this exact migration owns the entry that keeps
27
+ * `.nx/migrate-runs/<run-id>/...` scratch out of per-migration commits. If
28
+ * the migration is ever renamed, this entry must move with it. It lives here
29
+ * rather than in `handoff-gitignore.ts` so `sortMigrations`' hoist check
30
+ * doesn't load that module's migration-execution machinery.
31
+ */
32
+ const HANDOFF_GITIGNORE_MIGRATION_PACKAGE = 'nx';
33
+ const HANDOFF_GITIGNORE_MIGRATION_NAME = '23-0-0-add-migrate-runs-to-git-ignore';
34
+ function isHandoffGitignoreMigration(m) {
35
+ return (m.package === HANDOFF_GITIGNORE_MIGRATION_PACKAGE &&
36
+ m.name === HANDOFF_GITIGNORE_MIGRATION_NAME);
37
+ }
@@ -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] ";
@@ -17,6 +18,9 @@ export type MultiMajorMode = (typeof MULTI_MAJOR_MODES)[number];
17
18
  export interface MigrateArgs {
18
19
  packageAndVersion?: string;
19
20
  runMigrations?: string;
21
+ runMigration?: string;
22
+ runId?: string;
23
+ stepAction?: StepAction;
20
24
  include?: MigrateInclude;
21
25
  /**
22
26
  * nx.json `migrate.include` default. Consumed by `resolveInclude` only when the
@@ -30,6 +34,8 @@ export interface MigrateArgs {
30
34
  commitPrefix?: string;
31
35
  agentic?: AgenticArg;
32
36
  validate?: boolean;
37
+ ifExists?: boolean;
38
+ interactive?: boolean;
33
39
  [key: string]: any;
34
40
  }
35
41
  /**
@@ -6,11 +6,13 @@ 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.
12
13
  - Migrate packages and create migrations.json (e.g., nx migrate @nx/workspace@latest)
13
- - Run migrations (e.g., nx migrate --run-migrations=migrations.json). Use flag --if-exists to run migrations only if the migrations file exists.`,
14
+ - Run migrations (e.g., nx migrate --run-migrations=migrations.json). Use flag --if-exists to run migrations only if the migrations file exists.
15
+ - Run a single migration from migrations.json by id (e.g., nx migrate --run-migration=@nx/js:my-migration).`,
14
16
  builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)(withMigrationOptions(yargs), 'migrate'),
15
17
  handler: async () => process.exit(await (await (0, handle_import_1.handleImport)('./migrate.js', __dirname)).runMigration()),
16
18
  };
@@ -51,6 +53,22 @@ function withMigrationOptions(yargs) {
51
53
  .option('runMigrations', {
52
54
  describe: `Execute migrations from a file (when the file isn't provided, execute migrations from migrations.json).`,
53
55
  type: 'string',
56
+ })
57
+ .option('runMigration', {
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.",
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,
54
72
  })
55
73
  .option('ifExists', {
56
74
  describe: `Run migrations only if the migrations file exists, if not continues successfully.`,