@depup/nx 23.1.3-depup.0 → 23.2.0-depup.0

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 (294) hide show
  1. package/README.md +5 -4
  2. package/changes.json +10 -6
  3. package/dist/bin/init-local.js +3 -5
  4. package/dist/bin/nx.js +1 -0
  5. package/dist/src/adapter/ngcli-adapter.js +60 -1
  6. package/dist/src/ai/constants.d.ts +15 -0
  7. package/dist/src/ai/constants.js +17 -1
  8. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +57 -9
  9. package/dist/src/ai/utils.d.ts +13 -0
  10. package/dist/src/ai/utils.js +29 -0
  11. package/dist/src/analytics/analytics.js +2 -4
  12. package/dist/src/command-line/completion/command-object.js +7 -12
  13. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +42 -31
  14. package/dist/src/command-line/format/format.js +84 -101
  15. package/dist/src/command-line/generate/generate.js +35 -35
  16. package/dist/src/command-line/import/import.js +29 -38
  17. package/dist/src/command-line/init/ai-agent-prompts.js +5 -11
  18. package/dist/src/command-line/init/command-object.js +4 -2
  19. package/dist/src/command-line/init/configure-plugins.js +4 -1
  20. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
  21. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +17 -21
  22. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
  23. package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +3 -17
  24. package/dist/src/command-line/init/implementation/angular/index.js +10 -15
  25. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +2 -0
  26. package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +8 -2
  27. package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +2 -0
  28. package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +5 -0
  29. package/dist/src/command-line/init/implementation/format.d.ts +18 -0
  30. package/dist/src/command-line/init/implementation/format.js +114 -0
  31. package/dist/src/command-line/init/implementation/utils.js +8 -8
  32. package/dist/src/command-line/init/init-v1.js +15 -18
  33. package/dist/src/command-line/init/init-v2.js +77 -66
  34. package/dist/src/command-line/migrate/agentic/definitions.js +36 -9
  35. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +37 -22
  36. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +30 -39
  37. package/dist/src/command-line/migrate/agentic/handoff.d.ts +7 -7
  38. package/dist/src/command-line/migrate/agentic/handoff.js +13 -10
  39. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +7 -12
  40. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +7 -0
  41. package/dist/src/command-line/migrate/agentic/run-step.d.ts +10 -0
  42. package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
  43. package/dist/src/command-line/migrate/agentic/runner.js +24 -24
  44. package/dist/src/command-line/migrate/agentic/select.d.ts +10 -2
  45. package/dist/src/command-line/migrate/agentic/select.js +30 -32
  46. package/dist/src/command-line/migrate/agentic/types.d.ts +33 -3
  47. package/dist/src/command-line/migrate/agentic/types.js +35 -0
  48. package/dist/src/command-line/migrate/command-object.d.ts +6 -0
  49. package/dist/src/command-line/migrate/command-object.js +19 -1
  50. package/dist/src/command-line/migrate/execute-migration.d.ts +28 -9
  51. package/dist/src/command-line/migrate/execute-migration.js +112 -27
  52. package/dist/src/command-line/migrate/migrate-analytics.d.ts +35 -0
  53. package/dist/src/command-line/migrate/migrate-analytics.js +64 -0
  54. package/dist/src/command-line/migrate/migrate-commits.d.ts +38 -8
  55. package/dist/src/command-line/migrate/migrate-commits.js +130 -15
  56. package/dist/src/command-line/migrate/migrate-config.d.ts +13 -12
  57. package/dist/src/command-line/migrate/migrate-config.js +22 -14
  58. package/dist/src/command-line/migrate/migrate-output.d.ts +45 -7
  59. package/dist/src/command-line/migrate/migrate-output.js +52 -8
  60. package/dist/src/command-line/migrate/migrate-ui-api.d.ts +2 -1
  61. package/dist/src/command-line/migrate/migrate-ui-api.js +16 -7
  62. package/dist/src/command-line/migrate/migrate.d.ts +24 -55
  63. package/dist/src/command-line/migrate/migrate.js +553 -226
  64. package/dist/src/command-line/migrate/migration-shape.d.ts +8 -0
  65. package/dist/src/command-line/migrate/multi-major.js +7 -10
  66. package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
  67. package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
  68. package/dist/src/command-line/migrate/run/agent-output.js +65 -0
  69. package/dist/src/command-line/migrate/run/index.d.ts +9 -0
  70. package/dist/src/command-line/migrate/run/index.js +23 -0
  71. package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
  72. package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
  73. package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
  74. package/dist/src/command-line/migrate/run/run-id.js +56 -0
  75. package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
  76. package/dist/src/command-line/migrate/run/run-state.js +438 -0
  77. package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
  78. package/dist/src/command-line/migrate/run/state-lock.js +76 -0
  79. package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
  80. package/dist/src/command-line/migrate/run/state-machine.js +315 -0
  81. package/dist/src/command-line/migrate/run/util.d.ts +59 -0
  82. package/dist/src/command-line/migrate/run/util.js +148 -0
  83. package/dist/src/command-line/migrate/run/worker.d.ts +16 -0
  84. package/dist/src/command-line/migrate/run/worker.js +682 -0
  85. package/dist/src/command-line/migrate/run-migration-process.js +6 -5
  86. package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
  87. package/dist/src/command-line/migrate/safe-prompt.js +32 -43
  88. package/dist/src/command-line/migrate/sort-migrations.d.ts +16 -0
  89. package/dist/src/command-line/migrate/sort-migrations.js +32 -0
  90. package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
  91. package/dist/src/command-line/migrate/step-actions.js +12 -0
  92. package/dist/src/command-line/migrate/text.d.ts +18 -0
  93. package/dist/src/command-line/migrate/text.js +26 -0
  94. package/dist/src/command-line/migrate/version-skew-guard.d.ts +60 -0
  95. package/dist/src/command-line/migrate/version-skew-guard.js +175 -0
  96. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +16 -20
  97. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.d.ts +2 -0
  98. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.js +16 -0
  99. package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.d.ts +4 -0
  100. package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.js +13 -0
  101. package/dist/src/command-line/nx-commands.js +26 -24
  102. package/dist/src/command-line/release/changelog.js +6 -17
  103. package/dist/src/command-line/release/plan.js +15 -28
  104. package/dist/src/command-line/release/publish.js +5 -0
  105. package/dist/src/command-line/release/release.js +6 -17
  106. package/dist/src/command-line/release/utils/release-graph.d.ts +1 -0
  107. package/dist/src/command-line/release/utils/release-graph.js +10 -2
  108. package/dist/src/command-line/release/utils/remote-release-clients/github.js +10 -22
  109. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +13 -22
  110. package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
  111. package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
  112. package/dist/src/command-line/release/version.js +2 -2
  113. package/dist/src/command-line/reset/reset.js +17 -15
  114. package/dist/src/command-line/yargs-utils/shared-options.d.ts +1 -1
  115. package/dist/src/command-line/yargs-utils/shared-options.js +3 -1
  116. package/dist/src/config/misc-interfaces.d.ts +19 -7
  117. package/dist/src/core/graph/main.js +1 -1
  118. package/dist/src/core/graph/styles.js +1 -1
  119. package/dist/src/daemon/client/client.d.ts +2 -7
  120. package/dist/src/daemon/client/client.js +113 -28
  121. package/dist/src/daemon/client/daemon-environment.d.ts +35 -0
  122. package/dist/src/daemon/client/daemon-environment.js +106 -6
  123. package/dist/src/daemon/client/daemon-socket-messenger.d.ts +1 -1
  124. package/dist/src/daemon/client/daemon-socket-messenger.js +8 -3
  125. package/dist/src/daemon/is-v8-serializer-enabled.d.ts +2 -2
  126. package/dist/src/daemon/is-v8-serializer-enabled.js +2 -2
  127. package/dist/src/daemon/sandbox-socket-hint.d.ts +27 -0
  128. package/dist/src/daemon/sandbox-socket-hint.js +136 -0
  129. package/dist/src/daemon/server/client-socket-context.d.ts +1 -1
  130. package/dist/src/daemon/server/client-socket-context.js +2 -3
  131. package/dist/src/daemon/server/dotenv-graph-changes.d.ts +97 -0
  132. package/dist/src/daemon/server/dotenv-graph-changes.js +284 -0
  133. package/dist/src/daemon/server/handle-client-env.d.ts +8 -0
  134. package/dist/src/daemon/server/handle-client-env.js +92 -0
  135. package/dist/src/daemon/server/handle-outputs-changes.d.ts +10 -0
  136. package/dist/src/daemon/server/handle-outputs-changes.js +86 -0
  137. package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +21 -0
  138. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +159 -6
  139. package/dist/src/daemon/server/server.js +36 -72
  140. package/dist/src/daemon/server/shutdown-utils.d.ts +1 -1
  141. package/dist/src/daemon/server/shutdown-utils.js +2 -2
  142. package/dist/src/daemon/socket-utils.d.ts +26 -7
  143. package/dist/src/daemon/socket-utils.js +45 -31
  144. package/dist/src/daemon/tmp-dir.d.ts +10 -0
  145. package/dist/src/daemon/tmp-dir.js +21 -37
  146. package/dist/src/devkit-internals.d.ts +19 -8
  147. package/dist/src/devkit-internals.js +47 -6
  148. package/dist/src/executors/run-commands/running-tasks.js +46 -29
  149. package/dist/src/generators/internal-utils/{format-changed-files-with-prettier-if-available.d.ts → format-changed-files.d.ts} +6 -6
  150. package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
  151. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
  152. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
  153. package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
  154. package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
  155. package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
  156. package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
  157. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
  158. package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
  159. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
  160. package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
  161. package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
  162. package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
  163. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
  164. package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
  165. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
  166. package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
  167. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
  168. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
  169. package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
  170. package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
  171. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
  172. package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
  173. package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
  174. package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
  175. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
  176. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +2 -2
  177. package/dist/src/native/index.d.ts +7 -3
  178. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  179. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  180. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
  181. package/dist/src/nx-cloud/utilities/url-shorten.d.ts +1 -4
  182. package/dist/src/nx-cloud/utilities/url-shorten.js +9 -8
  183. package/dist/src/plugins/js/lock-file/lock-file.d.ts +46 -4
  184. package/dist/src/plugins/js/lock-file/lock-file.js +192 -15
  185. package/dist/src/plugins/js/lock-file/npm-parser.js +10 -3
  186. package/dist/src/plugins/js/lock-file/pnpm-parser.js +356 -62
  187. package/dist/src/plugins/js/lock-file/project-graph-pruning.d.ts +25 -1
  188. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +78 -4
  189. package/dist/src/plugins/js/lock-file/pruned-output.d.ts +330 -0
  190. package/dist/src/plugins/js/lock-file/pruned-output.js +1441 -0
  191. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +1 -0
  192. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +6 -5
  193. package/dist/src/plugins/js/utils/register.d.ts +11 -0
  194. package/dist/src/plugins/js/utils/register.js +40 -6
  195. package/dist/src/project-graph/plugins/get-plugins.d.ts +27 -1
  196. package/dist/src/project-graph/plugins/get-plugins.js +110 -5
  197. package/dist/src/project-graph/plugins/isolation/enabled.js +1 -4
  198. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +16 -0
  199. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +69 -11
  200. package/dist/src/project-graph/plugins/isolation/messaging.js +1 -3
  201. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +23 -2
  202. package/dist/src/project-graph/project-graph.js +27 -2
  203. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +7 -0
  204. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +14 -6
  205. package/dist/src/project-graph/utils/project-configuration/target-defaults.js +47 -21
  206. package/dist/src/tasks-runner/is-tui-enabled.js +3 -1
  207. package/dist/src/tasks-runner/life-cycle.d.ts +2 -2
  208. package/dist/src/tasks-runner/life-cycle.js +2 -2
  209. package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +12 -0
  210. package/dist/src/tasks-runner/life-cycles/performance-report.js +62 -3
  211. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +26 -1
  212. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +99 -5
  213. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +26 -0
  214. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +113 -17
  215. package/dist/src/tasks-runner/pseudo-ipc.js +14 -13
  216. package/dist/src/tasks-runner/pseudo-terminal.d.ts +17 -3
  217. package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
  218. package/dist/src/tasks-runner/run-command.js +32 -39
  219. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +55 -0
  220. package/dist/src/tasks-runner/running-tasks/batch-process.js +161 -8
  221. package/dist/src/tasks-runner/task-env.d.ts +25 -0
  222. package/dist/src/tasks-runner/task-env.js +39 -0
  223. package/dist/src/tasks-runner/task-orchestrator.d.ts +68 -0
  224. package/dist/src/tasks-runner/task-orchestrator.js +159 -8
  225. package/dist/src/utils/analytics-enabled.d.ts +7 -0
  226. package/dist/src/utils/analytics-enabled.js +11 -0
  227. package/dist/src/utils/analytics-prompt.js +4 -7
  228. package/dist/src/utils/cache-directory.d.ts +62 -3
  229. package/dist/src/utils/cache-directory.js +276 -25
  230. package/dist/src/utils/catalog/bun-manager-utils.d.ts +8 -0
  231. package/dist/src/utils/catalog/bun-manager-utils.js +174 -0
  232. package/dist/src/utils/catalog/bun-manager.d.ts +28 -0
  233. package/dist/src/utils/catalog/bun-manager.js +130 -0
  234. package/dist/src/utils/catalog/index.d.ts +1 -1
  235. package/dist/src/utils/catalog/index.js +1 -1
  236. package/dist/src/utils/catalog/manager-factory.js +3 -0
  237. package/dist/src/utils/catalog/manager-utils.d.ts +8 -1
  238. package/dist/src/utils/catalog/manager-utils.js +9 -4
  239. package/dist/src/utils/catalog/manager.d.ts +13 -1
  240. package/dist/src/utils/catalog/manager.js +30 -0
  241. package/dist/src/utils/catalog/pnpm-manager.d.ts +2 -1
  242. package/dist/src/utils/catalog/pnpm-manager.js +3 -0
  243. package/dist/src/utils/catalog/types.d.ts +4 -0
  244. package/dist/src/utils/catalog/yarn-manager.d.ts +6 -2
  245. package/dist/src/utils/catalog/yarn-manager.js +23 -32
  246. package/dist/src/utils/child-process.d.ts +31 -1
  247. package/dist/src/utils/child-process.js +103 -0
  248. package/dist/src/utils/chunkify.d.ts +7 -1
  249. package/dist/src/utils/chunkify.js +10 -3
  250. package/dist/src/utils/consume-messages-from-socket.d.ts +42 -7
  251. package/dist/src/utils/consume-messages-from-socket.js +273 -38
  252. package/dist/src/utils/db-connection.js +8 -16
  253. package/dist/src/utils/exit-codes.d.ts +9 -0
  254. package/dist/src/utils/exit-codes.js +19 -0
  255. package/dist/src/utils/formatters/index.d.ts +13 -0
  256. package/dist/src/utils/formatters/index.js +74 -0
  257. package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
  258. package/dist/src/utils/formatters/oxfmt.js +764 -0
  259. package/dist/src/utils/formatters/prettier.d.ts +26 -0
  260. package/dist/src/utils/formatters/prettier.js +201 -0
  261. package/dist/src/utils/formatters/shared.d.ts +5 -0
  262. package/dist/src/utils/formatters/shared.js +8 -0
  263. package/dist/src/utils/git-utils.d.ts +38 -2
  264. package/dist/src/utils/git-utils.js +422 -19
  265. package/dist/src/utils/has-nx-js-plugin.d.ts +1 -1
  266. package/dist/src/utils/has-nx-js-plugin.js +1 -1
  267. package/dist/src/utils/ignore.d.ts +47 -5
  268. package/dist/src/utils/ignore.js +93 -11
  269. package/dist/src/utils/kill-child-on-host-exit.d.ts +7 -0
  270. package/dist/src/utils/kill-child-on-host-exit.js +42 -0
  271. package/dist/src/utils/nx-console-prompt.js +3 -6
  272. package/dist/src/utils/nx-tmp-dir.d.ts +5 -0
  273. package/dist/src/utils/nx-tmp-dir.js +7 -2
  274. package/dist/src/utils/output.d.ts +153 -0
  275. package/dist/src/utils/output.js +289 -5
  276. package/dist/src/utils/owned-private-dir.d.ts +13 -0
  277. package/dist/src/utils/owned-private-dir.js +39 -0
  278. package/dist/src/utils/package-json.d.ts +2 -0
  279. package/dist/src/utils/package-manager.js +17 -7
  280. package/dist/src/utils/params.d.ts +7 -1
  281. package/dist/src/utils/params.js +64 -6
  282. package/dist/src/utils/permission-errors.d.ts +11 -0
  283. package/dist/src/utils/permission-errors.js +17 -0
  284. package/dist/src/utils/plugins/core-plugins.js +4 -0
  285. package/dist/src/utils/prompt-helpers.d.ts +53 -0
  286. package/dist/src/utils/prompt-helpers.js +111 -0
  287. package/dist/src/utils/socket-refused-exit-code.d.ts +15 -0
  288. package/dist/src/utils/socket-refused-exit-code.js +18 -0
  289. package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
  290. package/dist/src/utils/write-formatted-json-file.js +5 -4
  291. package/package.json +29 -20
  292. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -88
  293. package/dist/src/utils/is-using-prettier.d.ts +0 -3
  294. package/dist/src/utils/is-using-prettier.js +0 -62
@@ -5,7 +5,7 @@ exports.getPluginReason = getPluginReason;
5
5
  exports.detectPlugins = detectPlugins;
6
6
  const fs_1 = require("fs");
7
7
  const path_1 = require("path");
8
- const enquirer_1 = require("enquirer");
8
+ const prompt_helpers_1 = require("../../utils/prompt-helpers");
9
9
  const semver_1 = require("semver");
10
10
  const nx_json_1 = require("../../config/nx-json");
11
11
  const fileutils_1 = require("../../utils/fileutils");
@@ -20,6 +20,7 @@ const configure_plugins_1 = require("./configure-plugins");
20
20
  const ai_agent_prompts_1 = require("./ai-agent-prompts");
21
21
  const set_up_ai_agents_1 = require("../../ai/set-up-ai-agents/set-up-ai-agents");
22
22
  const tree_1 = require("../../generators/tree");
23
+ const format_1 = require("./implementation/format");
23
24
  const add_nx_to_monorepo_1 = require("./implementation/add-nx-to-monorepo");
24
25
  const add_nx_to_npm_repo_1 = require("./implementation/add-nx-to-npm-repo");
25
26
  const add_nx_to_turborepo_1 = require("./implementation/add-nx-to-turborepo");
@@ -29,11 +30,14 @@ const utils_1 = require("./implementation/utils");
29
30
  const provenance_1 = require("../../utils/provenance");
30
31
  const handle_import_1 = require("../../utils/handle-import");
31
32
  const native_1 = require("../../native");
33
+ const utils_2 = require("../../ai/utils");
34
+ const permission_errors_1 = require("../../utils/permission-errors");
32
35
  const detect_ai_agent_1 = require("../../ai/detect-ai-agent");
33
36
  const ab_testing_1 = require("../../utils/ab-testing");
34
37
  const analytics_prompt_1 = require("../../utils/analytics-prompt");
35
38
  const is_ci_1 = require("../../utils/is-ci");
36
39
  const ai_output_1 = require("./utils/ai-output");
40
+ const is_sandbox_1 = require("../../utils/is-sandbox");
37
41
  async function initHandler(options, inner = false) {
38
42
  // Use environment variable to force local execution
39
43
  if (process.env.NX_USE_LOCAL === 'true' || inner) {
@@ -118,8 +122,15 @@ async function runInit(options, baseMeta) {
118
122
  }
119
123
  // AI agent mode: apply defaults for non-interactive operation
120
124
  const aiMode = (0, native_1.isAiAgent)();
125
+ const isSandboxed = (0, is_sandbox_1.isSandbox)();
121
126
  if (aiMode) {
122
127
  options.interactive = false; // Force non-interactive
128
+ if (isSandboxed) {
129
+ // During init, before configuring AI agents, the daemon and
130
+ // plugin socket connections are not available
131
+ process.env.NX_DAEMON = 'false';
132
+ process.env.NX_ISOLATE_PLUGINS = 'false';
133
+ }
123
134
  if (options.nxCloud === undefined) {
124
135
  options.nxCloud = false; // Default to skip Nx Cloud
125
136
  }
@@ -148,6 +159,7 @@ async function runInit(options, baseMeta) {
148
159
  ...options,
149
160
  integrated: !!options.integrated,
150
161
  });
162
+ await (0, format_1.formatInitWrites)(process.cwd());
151
163
  (0, utils_1.printFinalMessage)({
152
164
  learnMoreLink: 'https://nx.dev/technologies/angular/migration/angular',
153
165
  });
@@ -161,21 +173,17 @@ async function runInit(options, baseMeta) {
161
173
  options.interactive &&
162
174
  !aiMode &&
163
175
  process.stdin.isTTY) {
164
- const setupMode = await (0, enquirer_1.prompt)([
165
- {
166
- type: 'select',
167
- name: 'setupMode',
168
- message: 'How would you like to set up Nx in this directory?',
169
- choices: [
170
- {
171
- name: '.nx installation (recommended for non-JavaScript projects)',
172
- },
173
- {
174
- name: 'package.json installation (recommended for JavaScript/TypeScript projects)',
175
- },
176
- ],
177
- },
178
- ]).then((r) => r.setupMode);
176
+ const setupMode = await (0, prompt_helpers_1.selectPrompt)({
177
+ message: 'How would you like to set up Nx in this directory?',
178
+ choices: [
179
+ {
180
+ value: '.nx installation (recommended for non-JavaScript projects)',
181
+ },
182
+ {
183
+ value: 'package.json installation (recommended for JavaScript/TypeScript projects)',
184
+ },
185
+ ],
186
+ });
179
187
  if (setupMode.startsWith('package.json')) {
180
188
  // Create a minimal package.json so the JS/TS workflow takes over
181
189
  const workspaceName = (0, path_1.basename)(process.cwd());
@@ -184,6 +192,7 @@ async function runInit(options, baseMeta) {
184
192
  version: '0.0.0',
185
193
  private: true,
186
194
  });
195
+ (0, format_1.recordInitWrite)('package.json');
187
196
  }
188
197
  else {
189
198
  options.useDotNxInstallation = true;
@@ -198,14 +207,10 @@ async function runInit(options, baseMeta) {
198
207
  // AI mode defaults to minimum setup, humans can choose
199
208
  let guided = !aiMode; // Default to minimum (false) for AI, guided (true) for humans
200
209
  if (options.interactive && !(_isTurborepo || _isNonJs)) {
201
- const setupType = await (0, enquirer_1.prompt)([
202
- {
203
- type: 'select',
204
- name: 'setupPreference',
205
- message: 'Would you like a minimum or guided setup?',
206
- choices: [{ name: 'Minimum' }, { name: 'Guided' }],
207
- },
208
- ]).then((r) => r.setupPreference);
210
+ const setupType = await (0, prompt_helpers_1.selectPrompt)({
211
+ message: 'Would you like a minimum or guided setup?',
212
+ choices: [{ value: 'Minimum' }, { value: 'Guided' }],
213
+ });
209
214
  guided = setupType === 'Guided';
210
215
  }
211
216
  /**
@@ -221,6 +226,7 @@ async function runInit(options, baseMeta) {
221
226
  await (0, add_nx_to_turborepo_1.addNxToTurborepo)({
222
227
  interactive: options.interactive,
223
228
  });
229
+ await (0, format_1.formatInitWrites)(process.cwd());
224
230
  (0, utils_1.printFinalMessage)({
225
231
  learnMoreLink: 'https://nx.dev/recipes/adopting-nx/from-turborepo',
226
232
  });
@@ -295,6 +301,9 @@ async function runInit(options, baseMeta) {
295
301
  reason: getPluginReason(name),
296
302
  }));
297
303
  (0, ai_output_1.logProgress)('detecting', `Detected ${detectedPluginNames.length} plugin(s): ${detectedPluginNames.join(', ')}`);
304
+ // This path exits without reaching the drain below, and `nx.json` has
305
+ // already been written by now.
306
+ await (0, format_1.formatInitWrites)(repoRoot);
298
307
  (0, ai_output_1.writeAiOutput)((0, ai_output_1.buildNeedsInputResult)(detectedPlugins));
299
308
  process.exit(0);
300
309
  }
@@ -321,21 +330,38 @@ async function runInit(options, baseMeta) {
321
330
  await (0, configure_plugins_1.configurePlugins)(pluginsToInstall, updatePackageScripts, pmc, repoRoot, options.verbose);
322
331
  }
323
332
  }
324
- const selectedAgents = await (0, ai_agent_prompts_1.determineAiAgents)(options.aiAgents, options.interactive && guided);
333
+ // AI agent mode configures the detected agent automatically (aiAgents is
334
+ // pre-filled above); interactive humans are always prompted — even in the
335
+ // minimum setup — since agent configuration also writes the sandbox
336
+ // allowances the Nx daemon needs when driven by an agent later.
337
+ const selectedAgents = await (0, ai_agent_prompts_1.determineAiAgents)(options.aiAgents, options.interactive);
325
338
  if (selectedAgents && selectedAgents.length > 0) {
326
- const tree = new tree_1.FsTree(repoRoot, false);
327
- const aiAgentsCallback = await (0, set_up_ai_agents_1.setupAiAgentsGenerator)(tree, {
328
- directory: '.',
329
- writeNxCloudRules: options.nxCloud !== false,
330
- packageVersion: 'latest',
331
- agents: [...selectedAgents],
332
- });
333
- const changes = tree.listChanges();
334
- (0, tree_1.flushChanges)(repoRoot, changes);
335
- if (aiAgentsCallback) {
336
- const results = await aiAgentsCallback();
337
- results.messages.forEach((m) => output_1.output.log(m));
338
- results.errors.forEach((e) => output_1.output.error(e));
339
+ try {
340
+ const tree = new tree_1.FsTree(repoRoot, false);
341
+ const aiAgentsCallback = await (0, set_up_ai_agents_1.setupAiAgentsGenerator)(tree, {
342
+ directory: '.',
343
+ writeNxCloudRules: options.nxCloud !== false,
344
+ packageVersion: 'latest',
345
+ agents: [...selectedAgents],
346
+ });
347
+ const changes = tree.listChanges();
348
+ (0, tree_1.flushChanges)(repoRoot, changes);
349
+ if (aiAgentsCallback) {
350
+ const results = await aiAgentsCallback();
351
+ results.messages.forEach((m) => output_1.output.log(m));
352
+ results.errors.forEach((e) => output_1.output.error(e));
353
+ }
354
+ }
355
+ catch (e) {
356
+ if (!(0, permission_errors_1.isPermissionDenied)(e)) {
357
+ throw e;
358
+ }
359
+ // Don't fail the whole init over this — everything else succeeded.
360
+ // Warned rather than thrown so the rest of the init result still stands.
361
+ output_1.output.warn({
362
+ title: 'AI agent configuration could not be written from this process',
363
+ bodyLines: (0, utils_2.agentConfigWriteBlockedLines)(e),
364
+ });
339
365
  }
340
366
  }
341
367
  let nxCloudChoice;
@@ -373,6 +399,10 @@ async function runInit(options, baseMeta) {
373
399
  pluginsInstalled: pluginsToInstall.join(','),
374
400
  },
375
401
  });
402
+ // Before the AI record, not after: the formatters write to stdout
403
+ // (`--list-different`, oxfmt's summary), which would otherwise land after the
404
+ // NDJSON result and corrupt the tail an agent parses.
405
+ await (0, format_1.formatInitWrites)(repoRoot);
376
406
  // Output success result for AI agents
377
407
  if (aiMode) {
378
408
  (0, ai_output_1.writeAiOutput)((0, ai_output_1.buildSuccessResult)({
@@ -400,6 +430,7 @@ async function runInit(options, baseMeta) {
400
430
  function getPluginReason(plugin) {
401
431
  const reasonMap = {
402
432
  '@nx/eslint': 'eslint detected in dependencies',
433
+ '@nx/oxlint': 'oxlint detected in dependencies',
403
434
  '@nx/storybook': 'storybook detected in dependencies',
404
435
  '@nx/vite': 'vite detected in dependencies',
405
436
  '@nx/vitest': 'vitest detected in dependencies',
@@ -447,6 +478,7 @@ function parsePluginsFlag(value) {
447
478
  const npmPackageToPluginMap = {
448
479
  // Generic JS tools
449
480
  eslint: '@nx/eslint',
481
+ oxlint: '@nx/oxlint',
450
482
  storybook: '@nx/storybook',
451
483
  // Bundlers
452
484
  vite: '@nx/vite',
@@ -573,39 +605,18 @@ async function detectPlugins(nxJson, packageJson, interactive, includeAngularCli
573
605
  `Add these Nx plugins to integrate with the tools used in your workspace.`,
574
606
  ],
575
607
  });
576
- const pluginsToInstall = await (0, enquirer_1.prompt)([
577
- {
578
- name: 'plugins',
579
- type: 'multiselect',
580
- message: `Which plugins would you like to add? Press <Space> to select and <Enter> to submit.`,
581
- choices: plugins.map((p) => ({ name: p, value: p })),
582
- /**
583
- * limit is missing from the interface but it limits the amount of options shown
584
- */
585
- limit: process.stdout.rows - 4, // 4 leaves room for the header above, the prompt and some whitespace
586
- },
587
- ]).then((r) => r.plugins);
608
+ const pluginsToInstall = await (0, prompt_helpers_1.multiselectPrompt)({
609
+ message: `Which plugins would you like to add? Press <Space> to select and <Enter> to submit.`,
610
+ choices: plugins,
611
+ });
588
612
  if (pluginsToInstall?.length === 0)
589
613
  return {
590
614
  plugins: [],
591
615
  updatePackageScripts: false,
592
616
  };
593
617
  const updatePackageScripts = (0, fs_1.existsSync)('package.json') &&
594
- (await (0, enquirer_1.prompt)([
595
- {
596
- name: 'updatePackageScripts',
597
- type: 'autocomplete',
598
- message: `Do you want to start using Nx in your package.json scripts?`,
599
- choices: [
600
- {
601
- name: 'Yes',
602
- },
603
- {
604
- name: 'No',
605
- },
606
- ],
607
- initial: 0,
608
- },
609
- ]).then((r) => r.updatePackageScripts === 'Yes'));
618
+ (await (0, prompt_helpers_1.confirmationPrompt)({
619
+ message: `Do you want to start using Nx in your package.json scripts?`,
620
+ }));
610
621
  return { plugins: pluginsToInstall, updatePackageScripts };
611
622
  }
@@ -4,7 +4,7 @@ exports.AGENT_DEFINITIONS = exports.opencodeDefinition = exports.codexDefinition
4
4
  exports.getAgentDefinition = getAgentDefinition;
5
5
  const os_1 = require("os");
6
6
  const path_1 = require("path");
7
- const handoff_1 = require("./handoff");
7
+ const types_1 = require("./types");
8
8
  // --- Claude Code ---------------------------------------------------------
9
9
  function claudeCodeWellKnownPaths() {
10
10
  if (process.platform === 'win32') {
@@ -13,21 +13,48 @@ function claudeCodeWellKnownPaths() {
13
13
  }
14
14
  return [(0, path_1.join)((0, os_1.homedir)(), '.claude', 'local', 'claude')];
15
15
  }
16
- // Pre-authorizes the handoff write: Claude Code's default permission mode
17
- // asks before file writes it has no allow rule for, so without this each step
18
- // ends with an approval prompt for nx's own handoff scratch. Prefix-less
19
- // patterns resolve against the session cwd (pinned to the workspace root
20
- // below); `Edit` covers corrections to an already-written handoff.
21
- const CLAUDE_CODE_HANDOFF_ALLOWED_TOOLS = `Write(${handoff_1.MIGRATE_RUNS_RELATIVE_DIR}/**),Edit(${handoff_1.MIGRATE_RUNS_RELATIVE_DIR}/**)`;
16
+ /**
17
+ * The run directory names Nx will interpolate into a permission rule. A rule
18
+ * is a gitignore pattern, which reads `*?[]\` as syntax, and `--allowedTools`
19
+ * splits its value on commas and spaces, so a name carrying any of those
20
+ * would change what the rule authorizes rather than what it names. Run
21
+ * directory names derive from a migration's own version string, which nothing
22
+ * upstream constrains to this alphabet. The leading character rejects `.`
23
+ * and `..`.
24
+ */
25
+ const RULE_SAFE_RUN_DIR_NAME = /^[A-Za-z0-9][A-Za-z0-9._+-]*$/;
26
+ /**
27
+ * Pre-authorizes the handoff write. Claude Code's default permission mode
28
+ * asks before a file write it has no allow rule for, so without this every
29
+ * step ends on an approval prompt for Nx's own handoff scratch.
30
+ *
31
+ * The rule reaches one run's handoffs and nothing else. Its own run
32
+ * directory also holds state Nx wrote and reads back, and the sibling
33
+ * directories belong to other runs, including an orchestrated run whose
34
+ * handoffs decide how its steps settle. `Edit` is the only tool name file
35
+ * rules are matched against, and it covers creating the file as well as
36
+ * correcting one already written. Prefix-less patterns resolve against the
37
+ * session cwd, pinned to the workspace root below.
38
+ *
39
+ * Returns null for a name it cannot express, which costs the approval prompt
40
+ * this exists to avoid. That beats widening the rule, and nothing narrower is
41
+ * available: Claude Code has no escape for a literal path.
42
+ */
43
+ function claudeCodeHandoffAllowedTools(runDirName) {
44
+ if (!RULE_SAFE_RUN_DIR_NAME.test(runDirName)) {
45
+ return null;
46
+ }
47
+ return `Edit(${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runDirName}/${types_1.HANDOFFS_DIR_NAME}/**)`;
48
+ }
22
49
  function claudeCodeBuildInteractive(ctx) {
50
+ const allowedTools = claudeCodeHandoffAllowedTools(ctx.runDirName);
23
51
  return {
24
52
  // `--allowedTools` is variadic (space/comma separated): a positional
25
53
  // placed right after its value gets swallowed as another rule. The rules
26
54
  // must stay in one comma-joined element with a non-variadic flag
27
55
  // (`--system-prompt`) between them and the user prompt.
28
56
  args: [
29
- '--allowedTools',
30
- CLAUDE_CODE_HANDOFF_ALLOWED_TOOLS,
57
+ ...(allowedTools ? ['--allowedTools', allowedTools] : []),
31
58
  '--system-prompt',
32
59
  ctx.systemContext,
33
60
  ctx.userPrompt,
@@ -1,33 +1,30 @@
1
- export declare function isHandoffGitignoreMigration(m: {
2
- package: string;
3
- name: string;
4
- }): boolean;
5
1
  /**
6
- * Under `--agentic`, the runner writes per-run scratch under
7
- * `.nx/migrate-runs/<run-id>/`. The v23 migration
2
+ * Both the agentic runner and the orchestrator write per-run scratch under
3
+ * `.nx/migrate-runs/<run-id>/`: handoff files in both cases, plus the durable
4
+ * run state and its plan snapshots for the orchestrator. The v23 migration
8
5
  * `23-0-0-add-migrate-runs-to-git-ignore` adds `.nx/migrate-runs` to
9
- * `.gitignore`; without intervention it would run in its declared slot
10
- * (typically late), so earlier per-migration commits would absorb the
11
- * scratch into the user-visible diff.
6
+ * `.gitignore`; in its declared slot (typically late) earlier per-migration
7
+ * commits would absorb the scratch into the user-visible diff.
12
8
  *
13
9
  * Two paths cover the leak, with no overlap:
14
10
  *
15
- * 1. HOIST — handled by the sort comparator in `executeMigrations`. When
16
- * the v23 migration is in the queue, it sorts to position 0 and runs
17
- * first via the normal migration runner (with its own log line and
18
- * commit). Fully traceable in `git log`.
11
+ * 1. HOIST: `sortMigrations`, which `executeMigrations` applies, sorts the
12
+ * v23 migration to position 0 when it is in the queue, so it runs first
13
+ * through the normal runner with its own log line and commit. A
14
+ * single-migration worker run needs no hoisting: the requested migration
15
+ * is the entire queue.
19
16
  *
20
- * 2. INLINE FALLBACK — this function. When the migration is NOT in the
21
- * queue AND the highest target version is < v23 (intra-pre-v23
22
- * `--agentic` run), the migration won't run at all. Apply its body
23
- * inline against an `FsTree` and commit it as a standalone preflight
24
- * commit (or leave in the working tree under `--no-create-commits`).
17
+ * 2. INLINE FALLBACK, this function. When the migration is NOT in the queue
18
+ * AND the highest target version is < v23 (intra-pre-v23 `--agentic`
19
+ * run) it will never run, so apply its body inline against an `FsTree`
20
+ * and commit it as a standalone preflight commit (or leave it in the
21
+ * working tree under `--no-create-commits`).
25
22
  *
26
- * When the migration is not in the queue AND target >= v23, the user is
27
- * past v23 already. They had the entry historically; if it's gone, that's
28
- * a conscious removal we respect.
23
+ * Not in the queue AND target >= v23 means the user is already past v23. They
24
+ * had the entry historically; if it is gone, that is a conscious removal we
25
+ * respect.
29
26
  */
30
- export declare function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion, effectiveCreateCommits, commitPrefix, root, }: {
27
+ export declare function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion, effectiveCreateCommits, commitPrefix, root, applyWhenPlanned, commitStandalone, }: {
31
28
  migrations: ReadonlyArray<{
32
29
  package: string;
33
30
  name: string;
@@ -43,4 +40,22 @@ export declare function applyAgenticHandoffGitignoreFallback({ migrations, insta
43
40
  effectiveCreateCommits: boolean;
44
41
  commitPrefix: string;
45
42
  root: string;
43
+ /**
44
+ * Apply the entry even when the hoisted migration is in the plan. The
45
+ * classic loop can defer to that migration because its run scratch appears
46
+ * only after migration 1 has run; the orchestrator creates its run dir at
47
+ * init, before any migration, so it needs the entry immediately. A planned
48
+ * migration also means the missing entry is not a conscious removal, so the
49
+ * v23 cutoff does not apply.
50
+ */
51
+ applyWhenPlanned?: boolean;
52
+ /**
53
+ * Commit the applied entry as its own preflight commit (the default). The
54
+ * orchestrator suppresses this: it applies the fallback before its init
55
+ * checkpoint so the checkpoint's `git add -A` cannot sweep in older
56
+ * scratch, and in that ordering a standalone commit here would carry the
57
+ * user's pre-existing changes along with the entry. The checkpoint that
58
+ * follows captures both instead.
59
+ */
60
+ commitStandalone?: boolean;
46
61
  }): Promise<void>;
@@ -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) {