nx 23.0.0-beta.2 → 23.0.0-beta.21

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 (274) hide show
  1. package/dist/bin/init-local.js +11 -20
  2. package/dist/bin/nx.d.ts +1 -0
  3. package/dist/bin/nx.js +28 -2
  4. package/dist/plugins/package-json.js +4 -2
  5. package/dist/src/adapter/ngcli-adapter.d.ts +2 -1
  6. package/dist/src/adapter/ngcli-adapter.js +25 -2
  7. package/dist/src/ai/clone-ai-config-repo.js +20 -3
  8. package/dist/src/analytics/analytics.js +10 -1
  9. package/dist/src/command-line/add/completion.d.ts +1 -0
  10. package/dist/src/command-line/add/completion.js +15 -0
  11. package/dist/src/command-line/affected/completion.d.ts +1 -0
  12. package/dist/src/command-line/affected/completion.js +15 -0
  13. package/dist/src/command-line/completion/argv-layout.d.ts +6 -0
  14. package/dist/src/command-line/completion/argv-layout.js +19 -0
  15. package/dist/src/command-line/completion/command-completions.d.ts +19 -0
  16. package/dist/src/command-line/completion/command-completions.js +120 -0
  17. package/dist/src/command-line/completion/command-handlers.d.ts +30 -0
  18. package/dist/src/command-line/completion/command-handlers.js +69 -0
  19. package/dist/src/command-line/completion/command-object.d.ts +10 -0
  20. package/dist/src/command-line/completion/command-object.js +95 -0
  21. package/dist/src/command-line/completion/completion-providers.d.ts +21 -0
  22. package/dist/src/command-line/completion/completion-providers.js +194 -0
  23. package/dist/src/command-line/completion/infix-targets.d.ts +1 -0
  24. package/dist/src/command-line/completion/infix-targets.js +48 -0
  25. package/dist/src/command-line/completion/metadata.d.ts +22 -0
  26. package/dist/src/command-line/completion/metadata.js +71 -0
  27. package/dist/src/command-line/completion/registrations.d.ts +9 -0
  28. package/dist/src/command-line/completion/registrations.js +16 -0
  29. package/dist/src/command-line/completion/scripts/bash.sh +51 -0
  30. package/dist/src/command-line/completion/scripts/fish.fish +47 -0
  31. package/dist/src/command-line/completion/scripts/powershell.ps1 +52 -0
  32. package/dist/src/command-line/completion/scripts/zsh.zsh +69 -0
  33. package/dist/src/command-line/completion/scripts.d.ts +18 -0
  34. package/dist/src/command-line/completion/scripts.js +140 -0
  35. package/dist/src/command-line/completion/trigger.d.ts +3 -0
  36. package/dist/src/command-line/completion/trigger.js +21 -0
  37. package/dist/src/command-line/completion/value-completions.d.ts +3 -0
  38. package/dist/src/command-line/completion/value-completions.js +21 -0
  39. package/dist/src/command-line/examples.js +1 -1
  40. package/dist/src/command-line/format/format.js +15 -5
  41. package/dist/src/command-line/generate/completion.d.ts +1 -0
  42. package/dist/src/command-line/generate/completion.js +9 -0
  43. package/dist/src/command-line/graph/completion.d.ts +1 -0
  44. package/dist/src/command-line/graph/completion.js +13 -0
  45. package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +14 -18
  46. package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +1 -0
  47. package/dist/src/command-line/init/implementation/utils.d.ts +7 -1
  48. package/dist/src/command-line/init/implementation/utils.js +51 -14
  49. package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +22 -0
  50. package/dist/src/command-line/migrate/agentic/capture-generator-output.js +100 -0
  51. package/dist/src/command-line/migrate/agentic/cli-args.d.ts +12 -0
  52. package/dist/src/command-line/migrate/agentic/cli-args.js +38 -0
  53. package/dist/src/command-line/migrate/agentic/definitions.d.ts +6 -0
  54. package/dist/src/command-line/migrate/agentic/definitions.js +98 -0
  55. package/dist/src/command-line/migrate/agentic/detect-installed.d.ts +10 -0
  56. package/dist/src/command-line/migrate/agentic/detect-installed.js +68 -0
  57. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +46 -0
  58. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +87 -0
  59. package/dist/src/command-line/migrate/agentic/handoff.d.ts +63 -0
  60. package/dist/src/command-line/migrate/agentic/handoff.js +183 -0
  61. package/dist/src/command-line/migrate/agentic/inception.d.ts +9 -0
  62. package/dist/src/command-line/migrate/agentic/inception.js +15 -0
  63. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +22 -0
  64. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +50 -0
  65. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +51 -0
  66. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +65 -0
  67. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +44 -0
  68. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +52 -0
  69. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +21 -0
  70. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +26 -0
  71. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +18 -0
  72. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +130 -0
  73. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +46 -0
  74. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +88 -0
  75. package/dist/src/command-line/migrate/agentic/run-step.d.ts +51 -0
  76. package/dist/src/command-line/migrate/agentic/run-step.js +121 -0
  77. package/dist/src/command-line/migrate/agentic/runner.d.ts +33 -0
  78. package/dist/src/command-line/migrate/agentic/runner.js +442 -0
  79. package/dist/src/command-line/migrate/agentic/select.d.ts +14 -0
  80. package/dist/src/command-line/migrate/agentic/select.js +150 -0
  81. package/dist/src/command-line/migrate/agentic/types.d.ts +102 -0
  82. package/dist/src/command-line/migrate/agentic/types.js +2 -0
  83. package/dist/src/command-line/migrate/command-object.d.ts +1 -0
  84. package/dist/src/command-line/migrate/command-object.js +32 -7
  85. package/dist/src/command-line/migrate/migrate-commits.d.ts +50 -0
  86. package/dist/src/command-line/migrate/migrate-commits.js +102 -0
  87. package/dist/src/command-line/migrate/migrate-output.d.ts +180 -0
  88. package/dist/src/command-line/migrate/migrate-output.js +258 -0
  89. package/dist/src/command-line/migrate/migrate.d.ts +122 -12
  90. package/dist/src/command-line/migrate/migrate.js +1036 -217
  91. package/dist/src/command-line/migrate/migration-shape.d.ts +8 -0
  92. package/dist/src/command-line/migrate/migration-shape.js +13 -0
  93. package/dist/src/command-line/migrate/multi-major.d.ts +30 -0
  94. package/dist/src/command-line/migrate/multi-major.js +185 -0
  95. package/dist/src/command-line/migrate/prompt-files.d.ts +31 -0
  96. package/dist/src/command-line/migrate/prompt-files.js +141 -0
  97. package/dist/src/command-line/migrate/run-migration-process.js +28 -6
  98. package/dist/src/command-line/migrate/safe-prompt.d.ts +28 -0
  99. package/dist/src/command-line/migrate/safe-prompt.js +49 -0
  100. package/dist/src/command-line/migrate/update-filters.d.ts +11 -0
  101. package/dist/src/command-line/migrate/update-filters.js +44 -0
  102. package/dist/src/command-line/migrate/version-utils.d.ts +6 -0
  103. package/dist/src/command-line/migrate/version-utils.js +59 -0
  104. package/dist/src/command-line/nx-commands.js +9 -0
  105. package/dist/src/command-line/release/config/config.d.ts +3 -6
  106. package/dist/src/command-line/release/config/config.js +77 -45
  107. package/dist/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
  108. package/dist/src/command-line/release/config/use-legacy-versioning.js +8 -0
  109. package/dist/src/command-line/release/utils/release-graph.js +2 -3
  110. package/dist/src/command-line/release/utils/repository-git-tags.js +1 -1
  111. package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +7 -19
  112. package/dist/src/command-line/release/version/resolve-current-version.js +1 -1
  113. package/dist/src/command-line/release/version/version-actions.js +3 -7
  114. package/dist/src/command-line/report/report.js +2 -2
  115. package/dist/src/command-line/run/completion.d.ts +1 -0
  116. package/dist/src/command-line/run/completion.js +7 -0
  117. package/dist/src/command-line/run-many/completion.d.ts +1 -0
  118. package/dist/src/command-line/run-many/completion.js +13 -0
  119. package/dist/src/command-line/show/completion.d.ts +1 -0
  120. package/dist/src/command-line/show/completion.js +27 -0
  121. package/dist/src/command-line/show/show-target/info.d.ts +1 -0
  122. package/dist/src/command-line/show/show-target/info.js +100 -19
  123. package/dist/src/command-line/watch/command-object.js +24 -4
  124. package/dist/src/command-line/watch/completion.d.ts +1 -0
  125. package/dist/src/command-line/watch/completion.js +10 -0
  126. package/dist/src/command-line/watch/watch.d.ts +7 -0
  127. package/dist/src/command-line/watch/watch.js +1 -1
  128. package/dist/src/config/misc-interfaces.d.ts +25 -2
  129. package/dist/src/config/nx-json.d.ts +43 -56
  130. package/dist/src/config/schema-utils.d.ts +21 -0
  131. package/dist/src/config/schema-utils.js +92 -18
  132. package/dist/src/config/task-graph.d.ts +4 -107
  133. package/dist/src/core/graph/main.js +1 -1
  134. package/dist/src/core/graph/styles.css +2 -3
  135. package/dist/src/core/graph/styles.js +1 -1
  136. package/dist/src/daemon/client/client.d.ts +1 -1
  137. package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +1 -1
  138. package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +1 -1
  139. package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +9 -0
  140. package/dist/src/daemon/server/file-watching/route-workspace-changes.js +76 -0
  141. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +45 -11
  142. package/dist/src/daemon/server/server.js +4 -43
  143. package/dist/src/daemon/server/start.d.ts +1 -1
  144. package/dist/src/daemon/server/start.js +2 -0
  145. package/dist/src/devkit-exports.d.ts +2 -2
  146. package/dist/src/devkit-internals.d.ts +5 -1
  147. package/dist/src/devkit-internals.js +17 -1
  148. package/dist/src/executors/run-commands/running-tasks.d.ts +7 -0
  149. package/dist/src/executors/run-commands/running-tasks.js +178 -105
  150. package/dist/src/executors/run-script/run-script.impl.js +3 -10
  151. package/dist/src/executors/utils/convert-nx-executor.js +1 -1
  152. package/dist/src/hasher/hash-plan-inspector.d.ts +1 -1
  153. package/dist/src/hasher/task-hasher.js +6 -4
  154. package/dist/src/index.d.ts +1 -1
  155. package/dist/src/index.js +0 -3
  156. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +6 -2
  157. package/dist/src/migrations/update-17-0-0/move-cache-directory.md +31 -0
  158. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +20 -4
  159. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.md +27 -0
  160. package/dist/src/migrations/update-20-0-1/use-legacy-cache.md +24 -0
  161. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.md +49 -0
  162. package/dist/src/migrations/update-21-0-0/release-version-config-changes.md +54 -0
  163. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.md +28 -0
  164. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.md +22 -0
  165. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.md +11 -0
  166. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.d.ts +2 -0
  167. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +16 -0
  168. package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +9 -0
  169. package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +18 -0
  170. package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.d.ts +35 -0
  171. package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.js +139 -0
  172. package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.md +66 -0
  173. package/dist/src/native/index.d.ts +79 -2
  174. package/dist/src/native/native-bindings.js +3 -0
  175. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  176. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  177. package/dist/src/plugins/js/lock-file/npm-parser.js +37 -19
  178. package/dist/src/plugins/js/lock-file/pnpm-parser.js +51 -4
  179. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +12 -4
  180. package/dist/src/plugins/js/utils/packages.js +1 -1
  181. package/dist/src/plugins/js/utils/register.d.ts +103 -14
  182. package/dist/src/plugins/js/utils/register.js +434 -39
  183. package/dist/src/plugins/js/utils/typescript.d.ts +7 -0
  184. package/dist/src/plugins/js/utils/typescript.js +39 -0
  185. package/dist/src/plugins/package-json/create-nodes.d.ts +3 -2
  186. package/dist/src/plugins/package-json/create-nodes.js +7 -5
  187. package/dist/src/project-graph/affected/locators/project-glob-changes.js +2 -1
  188. package/dist/src/project-graph/build-project-graph.d.ts +5 -0
  189. package/dist/src/project-graph/build-project-graph.js +6 -2
  190. package/dist/src/project-graph/file-map-utils.d.ts +5 -0
  191. package/dist/src/project-graph/file-map-utils.js +10 -1
  192. package/dist/src/project-graph/plugins/get-plugins.d.ts +7 -2
  193. package/dist/src/project-graph/plugins/get-plugins.js +8 -5
  194. package/dist/src/project-graph/plugins/isolation/plugin-worker.d.ts +1 -0
  195. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +2 -0
  196. package/dist/src/project-graph/plugins/resolve-plugin.d.ts +7 -4
  197. package/dist/src/project-graph/plugins/resolve-plugin.js +152 -33
  198. package/dist/src/project-graph/plugins/tasks-execution-hooks.js +4 -2
  199. package/dist/src/project-graph/plugins/transpiler.d.ts +12 -0
  200. package/dist/src/project-graph/plugins/transpiler.js +37 -0
  201. package/dist/src/project-graph/plugins/utils.js +13 -7
  202. package/dist/src/project-graph/project-graph.js +1 -1
  203. package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +95 -4
  204. package/dist/src/project-graph/utils/project-configuration/target-defaults.js +515 -68
  205. package/dist/src/project-graph/utils/project-configuration-utils.d.ts +13 -5
  206. package/dist/src/project-graph/utils/project-configuration-utils.js +14 -6
  207. package/dist/src/project-graph/utils/retrieve-workspace-files.js +1 -1
  208. package/dist/src/tasks-runner/create-task-graph.d.ts +4 -4
  209. package/dist/src/tasks-runner/create-task-graph.js +1 -1
  210. package/dist/src/tasks-runner/default-tasks-runner.d.ts +0 -2
  211. package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
  212. package/dist/src/tasks-runner/forked-process-task-runner.js +11 -6
  213. package/dist/src/tasks-runner/init-tasks-runner.d.ts +0 -15
  214. package/dist/src/tasks-runner/init-tasks-runner.js +0 -63
  215. package/dist/src/tasks-runner/legacy-depends-on-warning.d.ts +18 -0
  216. package/dist/src/tasks-runner/legacy-depends-on-warning.js +109 -0
  217. package/dist/src/tasks-runner/life-cycle.d.ts +7 -8
  218. package/dist/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +6 -6
  219. package/dist/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +13 -2
  220. package/dist/src/tasks-runner/life-cycles/task-history-life-cycle.js +16 -5
  221. package/dist/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +11 -2
  222. package/dist/src/tasks-runner/pseudo-terminal.d.ts +1 -1
  223. package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
  224. package/dist/src/tasks-runner/run-command.js +8 -11
  225. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +1 -1
  226. package/dist/src/tasks-runner/running-tasks/batch-process.js +3 -5
  227. package/dist/src/tasks-runner/running-tasks/node-child-process.d.ts +2 -2
  228. package/dist/src/tasks-runner/running-tasks/node-child-process.js +5 -7
  229. package/dist/src/tasks-runner/task-env.d.ts +1 -1
  230. package/dist/src/tasks-runner/task-env.js +6 -1
  231. package/dist/src/tasks-runner/task-orchestrator.d.ts +11 -1
  232. package/dist/src/tasks-runner/task-orchestrator.js +112 -38
  233. package/dist/src/tasks-runner/tasks-schedule.js +3 -3
  234. package/dist/src/tasks-runner/utils.d.ts +7 -8
  235. package/dist/src/tasks-runner/utils.js +23 -27
  236. package/dist/src/utils/child-process.js +2 -2
  237. package/dist/src/utils/compile-cache.d.ts +24 -0
  238. package/dist/src/utils/compile-cache.js +49 -0
  239. package/dist/src/utils/enable-compile-cache.d.ts +1 -0
  240. package/dist/src/utils/enable-compile-cache.js +7 -0
  241. package/dist/src/utils/fileutils.d.ts +0 -8
  242. package/dist/src/utils/fileutils.js +0 -40
  243. package/dist/src/utils/git-utils.d.ts +15 -0
  244. package/dist/src/utils/git-utils.js +138 -0
  245. package/dist/src/utils/handle-import.d.ts +4 -1
  246. package/dist/src/utils/handle-import.js +56 -2
  247. package/dist/src/utils/has-nx-js-plugin.d.ts +9 -0
  248. package/dist/src/utils/has-nx-js-plugin.js +24 -0
  249. package/dist/src/utils/installed-nx-version.d.ts +14 -4
  250. package/dist/src/utils/installed-nx-version.js +54 -7
  251. package/dist/src/utils/logger.d.ts +12 -1
  252. package/dist/src/utils/logger.js +57 -36
  253. package/dist/src/utils/nx-key.d.ts +0 -1
  254. package/dist/src/utils/nx-key.js +20 -23
  255. package/dist/src/utils/nx-package-group.d.ts +8 -0
  256. package/dist/src/utils/nx-package-group.js +15 -0
  257. package/dist/src/utils/output.d.ts +3 -2
  258. package/dist/src/utils/output.js +29 -28
  259. package/dist/src/utils/package-json.d.ts +14 -1
  260. package/dist/src/utils/package-json.js +20 -21
  261. package/dist/src/utils/perf-logging.js +3 -1
  262. package/dist/src/utils/plugin-cache-utils.d.ts +13 -4
  263. package/dist/src/utils/plugin-cache-utils.js +23 -13
  264. package/dist/src/utils/plugins/local-plugins.d.ts +18 -0
  265. package/dist/src/utils/plugins/local-plugins.js +30 -0
  266. package/dist/src/utils/tar.d.ts +8 -0
  267. package/dist/src/utils/tar.js +44 -0
  268. package/migrations.json +16 -0
  269. package/package.json +28 -28
  270. package/schemas/nx-schema.json +114 -80
  271. package/dist/src/plugins/js/project-graph/build-dependencies/strip-source-code.d.ts +0 -7
  272. package/dist/src/plugins/js/project-graph/build-dependencies/strip-source-code.js +0 -155
  273. package/dist/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.d.ts +0 -16
  274. package/dist/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.js +0 -121
@@ -0,0 +1,102 @@
1
+ import type { AgentId } from './cli-args';
2
+ export type { AgentId };
3
+ /**
4
+ * A coding agent that was found on the user's machine, ready to be spawned.
5
+ *
6
+ * Produced by `detect-installed.ts`. The `binary` is an absolute path so the
7
+ * runner can spawn it directly without re-resolving against PATH.
8
+ */
9
+ export interface DetectedInstalledAgent {
10
+ id: AgentId;
11
+ displayName: string;
12
+ binary: string;
13
+ source: 'path' | 'well-known';
14
+ }
15
+ /**
16
+ * Inputs the runner provides when asking an agent definition to build its
17
+ * spawn arguments. Kept minimal — agent-specific quirks (e.g. transient agent
18
+ * name for OpenCode) are encoded inside the definition, not here.
19
+ */
20
+ export interface InvocationContext {
21
+ systemContext: string;
22
+ userPrompt: string;
23
+ workspaceRoot: string;
24
+ }
25
+ /**
26
+ * What an agent definition returns from `buildInteractive`. The runner combines
27
+ * this with the detected binary path to actually spawn.
28
+ */
29
+ export interface InvocationSpec {
30
+ args: string[];
31
+ env?: NodeJS.ProcessEnv;
32
+ cwd?: string;
33
+ }
34
+ /**
35
+ * Static description of an agent the migrate command knows how to dispatch to.
36
+ */
37
+ export interface AgentDefinition {
38
+ id: AgentId;
39
+ displayName: string;
40
+ /** Binary names to probe via `which` (PATHEXT handled by `which` on Windows). */
41
+ binaryNames: string[];
42
+ /** Absolute paths to probe as a fallback when PATH lookup misses. */
43
+ wellKnownPaths(): string[];
44
+ buildInteractive(ctx: InvocationContext): InvocationSpec;
45
+ }
46
+ /**
47
+ * Output of the agent's handoff file, written at the end of an agentic step.
48
+ * The two locked fields drive the failure-handling matrix in the design doc;
49
+ * extra fields are tolerated and surfaced via `extras`.
50
+ */
51
+ export interface HandoffFile {
52
+ status: 'success' | 'failed';
53
+ summary: string;
54
+ extras?: Record<string, unknown>;
55
+ }
56
+ /**
57
+ * Outcome the runner reports back to the migrate orchestrator after a single
58
+ * agentic step. The four kinds mirror the (a)/(b)/(c) matrix plus the user's
59
+ * choice when (c) fires.
60
+ *
61
+ * `ambiguous-abort.causeSummary`: pre-rendered explanation lines. Populated
62
+ * when Ctrl+C bypasses the ambiguous prompt (so the cause was never shown
63
+ * inline) and forwarded so the caller can surface it. Omitted when the user
64
+ * chose "abort" at the prompt — the cause was already shown there.
65
+ */
66
+ export type HandoffOutcome = {
67
+ kind: 'success';
68
+ summary: string;
69
+ extras?: Record<string, unknown>;
70
+ } | {
71
+ kind: 'failed';
72
+ summary: string;
73
+ extras?: Record<string, unknown>;
74
+ } | {
75
+ kind: 'ambiguous-continue';
76
+ } | {
77
+ kind: 'ambiguous-abort';
78
+ causeSummary?: string[];
79
+ };
80
+ /**
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.
83
+ *
84
+ * - `inside-agent`: nx detected it is itself running inside another agent;
85
+ * every agentic step is skipped and prompt migrations go to `nextSteps`.
86
+ * - `disabled`: the user opted out (explicit `--agentic=false`, declined the
87
+ * up-front prompt, or non-TTY without the flag).
88
+ * - `enabled`: the agentic flow runs and `selectedAgent` is the agent it
89
+ * dispatches to.
90
+ */
91
+ export type ResolvedAgentic = {
92
+ kind: 'inside-agent';
93
+ } | {
94
+ kind: 'disabled';
95
+ } | {
96
+ kind: 'enabled';
97
+ selectedAgent: DetectedInstalledAgent;
98
+ };
99
+ /** The `enabled` variant, useful for narrowed function signatures. */
100
+ export type EnabledResolvedAgentic = Extract<ResolvedAgentic, {
101
+ kind: 'enabled';
102
+ }>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,4 @@
1
1
  import { CommandModule } from 'yargs';
2
2
  export declare const yargsMigrateCommand: CommandModule;
3
3
  export declare const yargsInternalMigrateCommand: CommandModule;
4
+ export declare const DEFAULT_MIGRATION_COMMIT_PREFIX = "chore: [nx migration] ";
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.yargsInternalMigrateCommand = exports.yargsMigrateCommand = void 0;
3
+ exports.DEFAULT_MIGRATION_COMMIT_PREFIX = exports.yargsInternalMigrateCommand = exports.yargsMigrateCommand = void 0;
4
4
  const handle_import_1 = require("../../utils/handle-import");
5
5
  const documentation_1 = require("../yargs-utils/documentation");
6
6
  const shared_options_1 = require("../yargs-utils/shared-options");
7
+ const cli_args_1 = require("./agentic/cli-args");
7
8
  exports.yargsMigrateCommand = {
8
9
  command: 'migrate [packageAndVersion]',
9
10
  describe: `Creates a migrations file or runs migrations from the migrations file.
@@ -18,8 +19,8 @@ exports.yargsInternalMigrateCommand = {
18
19
  builder: (yargs) => withMigrationOptions(yargs),
19
20
  handler: async (args) => process.exit(await (await (0, handle_import_1.handleImport)('./migrate.js', __dirname)).migrate(process.cwd(), args, process.argv.slice(3))),
20
21
  };
22
+ exports.DEFAULT_MIGRATION_COMMIT_PREFIX = 'chore: [nx migration] ';
21
23
  function withMigrationOptions(yargs) {
22
- const defaultCommitPrefix = 'chore: [nx migration] ';
23
24
  return (0, shared_options_1.withVerbose)(yargs)
24
25
  .positional('packageAndVersion', {
25
26
  describe: `The target package and version (e.g, @nx/workspace@16.0.0).`,
@@ -46,12 +47,11 @@ function withMigrationOptions(yargs) {
46
47
  describe: 'Automatically create a git commit after each migration runs.',
47
48
  type: 'boolean',
48
49
  alias: ['C'],
49
- default: false,
50
50
  })
51
51
  .option('commitPrefix', {
52
52
  describe: 'Commit prefix to apply to the commit for each migration, when --create-commits is enabled.',
53
53
  type: 'string',
54
- default: defaultCommitPrefix,
54
+ default: exports.DEFAULT_MIGRATION_COMMIT_PREFIX,
55
55
  })
56
56
  .option('interactive', {
57
57
  describe: 'Enable prompts to confirm whether to collect optional package updates and migrations.',
@@ -67,13 +67,38 @@ function withMigrationOptions(yargs) {
67
67
  type: 'boolean',
68
68
  default: false,
69
69
  })
70
- .check(({ createCommits, commitPrefix, from, excludeAppliedMigrations }) => {
71
- if (!createCommits && commitPrefix !== defaultCommitPrefix) {
70
+ .option('mode', {
71
+ describe: "Restrict which packages to migrate. Only applies when migrating Nx itself. 'first-party' processes only Nx and its plugins (the target package plus its nx.packageGroup); 'third-party' processes only the third-party dependencies referenced by Nx packageJsonUpdates entries, catching up on any updates that may have been skipped previously; 'all' processes everything. When targeting Nx in an interactive terminal, prompts for the value if not provided; otherwise defaults to 'all'.",
72
+ type: 'string',
73
+ choices: ['first-party', 'third-party', 'all'],
74
+ })
75
+ .option('multiMajorMode', {
76
+ describe: "Skip the multi-major migration prompt/warning and pick how to handle the jump. 'direct' migrates straight to the requested target. 'gradual' migrates to the smallest recommended step (re-run `nx migrate` to continue toward the original target). Equivalent env var: NX_MULTI_MAJOR_MODE=direct|gradual.",
77
+ type: 'string',
78
+ choices: ['direct', 'gradual'],
79
+ })
80
+ .option('agentic', {
81
+ describe: 'Enable the agentic flow for prompt-based migrations and AI-driven review. Pass `--agentic=<agent>` to pin a specific agent (claude-code, codex, or opencode). Pass `--agentic=false` or `--no-agentic` to disable.',
82
+ coerce: cli_args_1.coerceAgenticArg,
83
+ })
84
+ .option('validate', {
85
+ describe: 'When `--agentic` resolves to an enabled agent, run agent-driven validation after generator-only migrations that have no `prompt:` field. Defaults to on; pass `--no-validate` to opt out. Has no effect when `--agentic` is disabled, when running inside an outer agent, or when running non-interactively without an explicit agent.',
86
+ type: 'boolean',
87
+ })
88
+ .check(({ createCommits, commitPrefix, from, excludeAppliedMigrations, mode, agentic, }) => {
89
+ const agenticMayEnableCommits = agentic !== undefined && agentic !== false && createCommits !== false;
90
+ if (createCommits !== true &&
91
+ !agenticMayEnableCommits &&
92
+ commitPrefix !== exports.DEFAULT_MIGRATION_COMMIT_PREFIX) {
72
93
  throw new Error('Error: Providing a custom commit prefix requires --create-commits to be enabled');
73
94
  }
74
- if (excludeAppliedMigrations && !from) {
95
+ if (excludeAppliedMigrations && !from && mode !== 'third-party') {
75
96
  throw new Error('Error: Excluding migrations that should have been previously applied requires --from to be set');
76
97
  }
98
+ if (typeof agentic === 'string' &&
99
+ !cli_args_1.AGENT_IDS.includes(agentic)) {
100
+ throw new Error(`Error: Invalid --agentic value "${agentic}". Allowed: ${cli_args_1.AGENT_IDS.join(', ')}, true, false.`);
101
+ }
77
102
  return true;
78
103
  });
79
104
  }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Discriminated result for `commitMigrationIfRequested`. Distinguishes the
3
+ * shapes the executor needs to react to:
4
+ *
5
+ * - `committed`: a commit landed. `sha` is `null` only when `git rev-parse
6
+ * HEAD` failed transiently — by contract the diff is no longer in the
7
+ * working tree.
8
+ * - `no-changes`: commits were requested but there was nothing to commit.
9
+ * - `failed`: the commit attempt itself errored. The diff remains in the
10
+ * working tree; the executor uses this signal to track pending migrations
11
+ * so the next successful commit can annotate its body.
12
+ * - `disabled`: commits are off for this run.
13
+ */
14
+ export type CommitResult = {
15
+ status: 'committed';
16
+ sha: string | null;
17
+ } | {
18
+ status: 'no-changes';
19
+ } | {
20
+ status: 'failed';
21
+ reason: string;
22
+ } | {
23
+ status: 'disabled';
24
+ };
25
+ /**
26
+ * Creates a per-migration commit when `shouldCreateCommits` is true.
27
+ *
28
+ * When `pendingMigrations` is non-empty, the commit message body lists
29
+ * those entries so a reader of `git log -p` can see which prior migrations'
30
+ * diffs were absorbed into this commit (because their own commits failed and
31
+ * `git add -A` here captured their working-tree state too). Each entry is
32
+ * rendered as `<package>: <name>` for unambiguous attribution across
33
+ * packages.
34
+ */
35
+ export declare function commitMigrationIfRequested(root: string, migration: {
36
+ name: string;
37
+ }, shouldCreateCommits: boolean, commitPrefix: string, installDepsIfChanged: () => Promise<void>, pendingMigrations?: ReadonlyArray<{
38
+ package: string;
39
+ name: string;
40
+ }>): Promise<CommitResult>;
41
+ /**
42
+ * Commits any pre-existing working-tree state into a dedicated "checkpoint"
43
+ * commit before the first migration runs. Without this, the first migration's
44
+ * commit would absorb whatever was already pending — most commonly the
45
+ * package.json edit `nx migrate latest` produces and the lockfile churn from
46
+ * the orchestrator's `npm install --ignore-scripts` step — and migration 1's
47
+ * validation would see that mixed in with the generator output. No-op when
48
+ * the working tree is already clean.
49
+ */
50
+ export declare function commitCheckpointBeforeMigrations(root: string, commitPrefix: string): void;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.commitMigrationIfRequested = commitMigrationIfRequested;
4
+ exports.commitCheckpointBeforeMigrations = commitCheckpointBeforeMigrations;
5
+ const tslib_1 = require("tslib");
6
+ const pc = tslib_1.__importStar(require("picocolors"));
7
+ const git_utils_1 = require("../../utils/git-utils");
8
+ const logger_1 = require("../../utils/logger");
9
+ const output_1 = require("../../utils/output");
10
+ /**
11
+ * Creates a per-migration commit when `shouldCreateCommits` is true.
12
+ *
13
+ * When `pendingMigrations` is non-empty, the commit message body lists
14
+ * those entries so a reader of `git log -p` can see which prior migrations'
15
+ * diffs were absorbed into this commit (because their own commits failed and
16
+ * `git add -A` here captured their working-tree state too). Each entry is
17
+ * rendered as `<package>: <name>` for unambiguous attribution across
18
+ * packages.
19
+ */
20
+ async function commitMigrationIfRequested(root, migration, shouldCreateCommits, commitPrefix, installDepsIfChanged, pendingMigrations = []) {
21
+ if (!shouldCreateCommits)
22
+ return { status: 'disabled' };
23
+ await installDepsIfChanged();
24
+ // Generator may have only touched gitignored paths, or the prompt half
25
+ // made no change — log neutrally instead of as an error.
26
+ if (!(0, git_utils_1.hasUncommittedChanges)(root)) {
27
+ logger_1.logger.info(pc.dim(`- No changes to commit for ${migration.name}.`));
28
+ return { status: 'no-changes' };
29
+ }
30
+ const commitMessage = buildCommitMessage(`${commitPrefix}${migration.name}`, pendingMigrations);
31
+ try {
32
+ const sha = (0, git_utils_1.tryCommitChanges)(commitMessage, root);
33
+ if (sha)
34
+ return { status: 'committed', sha };
35
+ // null = commit landed but `git rev-parse HEAD` failed (see
36
+ // `tryCommitChanges`). Degraded-but-correct — log yellow, not red.
37
+ logger_1.logger.info(pc.yellow(`The commit for ${migration.name} was created, but its sha could not be resolved (\`git rev-parse HEAD\` failed transiently). Continuing without recording the sha for this step.`));
38
+ return { status: 'committed', sha: null };
39
+ }
40
+ catch (err) {
41
+ const reason = err instanceof Error ? err.message : String(err);
42
+ logger_1.logger.info(pc.red(`Could not create a commit for ${migration.name}:\n${reason}\nThe migration's diff remains in the working tree; inspect with \`git status\` / \`git diff\` to review. The next successful commit will absorb it and reference this migration in its body; if no later commit lands, the end-of-run output will list this migration so you can commit or revert manually.`));
43
+ return { status: 'failed', reason };
44
+ }
45
+ }
46
+ // Migration names come from migrations.json (third-party plugin authored);
47
+ // they cannot be trusted to be single-line. Strip CR/LF so a hostile name
48
+ // cannot inject body lines or fake `Co-Authored-By:` / similar trailers.
49
+ function sanitizeMigrationLine(value) {
50
+ return value.replace(/[\r\n]+/g, ' ').trim();
51
+ }
52
+ function buildCommitMessage(subject, pendingMigrations) {
53
+ if (pendingMigrations.length === 0)
54
+ return subject;
55
+ // Two newlines separate the subject from the body per the
56
+ // conventional-commits convention.
57
+ const lines = [
58
+ subject,
59
+ '',
60
+ 'Includes changes from prior migrations whose own commits failed:',
61
+ ...pendingMigrations.map((p) => ` - ${sanitizeMigrationLine(p.package)}: ${sanitizeMigrationLine(p.name)}`),
62
+ ];
63
+ return lines.join('\n');
64
+ }
65
+ /**
66
+ * Commits any pre-existing working-tree state into a dedicated "checkpoint"
67
+ * commit before the first migration runs. Without this, the first migration's
68
+ * commit would absorb whatever was already pending — most commonly the
69
+ * package.json edit `nx migrate latest` produces and the lockfile churn from
70
+ * the orchestrator's `npm install --ignore-scripts` step — and migration 1's
71
+ * validation would see that mixed in with the generator output. No-op when
72
+ * the working tree is already clean.
73
+ */
74
+ function commitCheckpointBeforeMigrations(root, commitPrefix) {
75
+ if (!(0, git_utils_1.hasUncommittedChanges)(root))
76
+ return;
77
+ try {
78
+ const sha = (0, git_utils_1.tryCommitChanges)(`${commitPrefix}checkpoint before running migrations`, root);
79
+ if (sha) {
80
+ logger_1.logger.info(pc.dim(`- Checkpoint commit created: ${sha}`));
81
+ return;
82
+ }
83
+ // null = commit landed but `git rev-parse HEAD` failed (see
84
+ // `tryCommitChanges`). State is captured, just unanchored.
85
+ output_1.output.warn({
86
+ title: 'Could not resolve checkpoint commit sha',
87
+ bodyLines: [
88
+ 'The checkpoint commit was created, but its sha could not be resolved (`git rev-parse HEAD` failed transiently).',
89
+ ],
90
+ });
91
+ }
92
+ catch (err) {
93
+ const reason = err instanceof Error ? err.message : String(err);
94
+ output_1.output.warn({
95
+ title: 'Could not create checkpoint commit before migrations',
96
+ bodyLines: [
97
+ reason,
98
+ `Migration 1's commit will absorb any pre-existing working-tree state.`,
99
+ ],
100
+ });
101
+ }
102
+ }
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Presentation layer for `nx migrate --run-migrations`. Pure helpers — every
3
+ * function maps (state) → (terminal output or string lines). Shared visual
4
+ * vocabulary across the migrate run:
5
+ * `→` start · `✓` success · `✗` failure · `↷` skipped · `ℹ` info · `─` boundary
6
+ *
7
+ * Inputs are typed structurally (e.g. `{ name: string }[]`) so this module
8
+ * stays decoupled from `ExecutableMigration` and the executor in migrate.ts.
9
+ */
10
+ /**
11
+ * Some agent TUIs (codex, opencode) don't fully reset their cursor / SGR state
12
+ * when they exit, which corrupts subsequent orchestrator output. Emit an SGR
13
+ * reset + newline so our log lines land on a clean row instead of being
14
+ * overlaid by leftover status bars.
15
+ */
16
+ export declare function resetSgrAfterAgent(): void;
17
+ /**
18
+ * Per-migration boundary header. Anchors the orchestrator log at the start of
19
+ * each migration with the migration index and identity.
20
+ */
21
+ export declare function logMigrationBoundary(index: number, total: number, pkg: string, name: string): void;
22
+ /**
23
+ * Logs the outcome line that closes an agentic phase. Vocabulary:
24
+ * ✓ <label>[ (<sha>)]: <summary>
25
+ */
26
+ export declare function logAgenticSuccessOutcome(label: string, sha: string | null, summary: string): void;
27
+ /**
28
+ * Per-migration outcome record consumed by the failure recap. One entry is
29
+ * appended per iteration that returned without throwing; the failing migration
30
+ * has no record.
31
+ *
32
+ * - `applied`: ran fully to completion, including any agentic step.
33
+ * - `no-changes`: generator ran but produced no diff (counts as applied work).
34
+ * - `deferred`: prompt half was not applied (agent disabled or inside-agent
35
+ * mode hands it off). For hybrid migrations the deterministic half still ran.
36
+ *
37
+ * `committedAsPartOf` is set when this migration's own commit attempt failed
38
+ * but its diff was later absorbed into a successor migration's commit (which
39
+ * stages the working tree's accumulated state via `git add -A`). The recap
40
+ * uses this to anchor "last applied" honestly when the last-named commit
41
+ * landed multiple migrations' contributions.
42
+ */
43
+ export type MigrationOutcomeKind = 'applied' | 'no-changes' | 'deferred';
44
+ /**
45
+ * The state of a migration's commit attempt. Tagged union so consumers don't
46
+ * have to re-derive legal combinations from nullable fields.
47
+ *
48
+ * - `none` — no commit was attempted (`--no-create-commits` or no diff to
49
+ * commit).
50
+ * - `landed` — a commit was actually created. `sha: null` only when
51
+ * `git rev-parse HEAD` failed transiently right after the
52
+ * commit landed; by contract the diff did clear.
53
+ * - `failed` — commit was attempted and errored (signing, hook rejection,
54
+ * lock, install error mid-attempt, etc.). The diff stays in
55
+ * the working tree until a later migration's commit absorbs
56
+ * it (then transitions to `absorbed`) or until the run ends
57
+ * (then surfaces as retained state).
58
+ * - `absorbed` — own commit failed but a later migration's commit absorbed
59
+ * this diff via `git add -A`. `into.sha: null` means that
60
+ * absorbing commit itself hit a HEAD-resolve race; the recap
61
+ * renders an anchor without a sha.
62
+ */
63
+ export type CommitState = {
64
+ kind: 'none';
65
+ } | {
66
+ kind: 'landed';
67
+ sha: string | null;
68
+ } | {
69
+ kind: 'failed';
70
+ } | {
71
+ kind: 'absorbed';
72
+ into: {
73
+ name: string;
74
+ sha: string | null;
75
+ };
76
+ };
77
+ /**
78
+ * Per-migration record produced by the executor loop. `status: 'completed'`
79
+ * carries the kind (applied / no-changes / deferred); `status: 'aborted'`
80
+ * means the migration threw before completing — the executor's catch block
81
+ * records it so the recap can list it under retained-state alongside any
82
+ * other migrations whose commits never landed.
83
+ */
84
+ export type MigrationOutcome = {
85
+ migration: {
86
+ package: string;
87
+ name: string;
88
+ };
89
+ status: 'completed';
90
+ kind: MigrationOutcomeKind;
91
+ commit: CommitState;
92
+ } | {
93
+ migration: {
94
+ package: string;
95
+ name: string;
96
+ };
97
+ status: 'aborted';
98
+ commit: CommitState;
99
+ };
100
+ /**
101
+ * Counts the migrations whose own commit actually landed — including the
102
+ * HEAD-resolve-race case (`commit: { kind: 'landed', sha: null }`). Used by
103
+ * the end-of-run "<K> commits created" tally and by the success-path
104
+ * accounting in `executeMigrations`. Counts landed-commit *records* rather
105
+ * than distinct shas; absorbed predecessors (`kind: 'absorbed'`) are not
106
+ * counted because the absorbing commit's record already contributes one.
107
+ */
108
+ export declare function countLandedCommits(outcomes: ReadonlyArray<MigrationOutcome>): number;
109
+ /**
110
+ * Migrations whose own commit attempt failed and whose diff was never
111
+ * absorbed by a later commit. Surfaces what the user has to commit or
112
+ * revert after the run. Filters on `commit.kind === 'failed'` exactly —
113
+ * `'absorbed'` means the diff cleared into a later commit, `'none'` means
114
+ * no commit was attempted (intentional `--no-create-commits` or no-op).
115
+ */
116
+ export declare function retainedMigrations(outcomes: ReadonlyArray<MigrationOutcome>): Array<{
117
+ package: string;
118
+ name: string;
119
+ }>;
120
+ /**
121
+ * Logs a structured recap when a migration throws mid-loop. Inserted between
122
+ * the "Failed to run X" error block and the re-throw so the user (or AI agent
123
+ * driving the run) can see what completed before the failure without scrolling
124
+ * back through the per-migration log to count shas.
125
+ *
126
+ * Counts-based rather than full migration lists so a 24-migration run that
127
+ * fails at #12 doesn't dump 24 names into the recap — readers scroll up to
128
+ * see specifics in the per-migration log. The "last applied" anchor pairs the
129
+ * most recent fully-applied migration with the sha its commit actually
130
+ * produced, so a skipped/deferred step trailing an applied one can't borrow
131
+ * the earlier sha.
132
+ */
133
+ export declare function logFailureRecap(opts: {
134
+ migrationIndex: number;
135
+ totalMigrations: number;
136
+ outcomes: ReadonlyArray<MigrationOutcome>;
137
+ migrationEmittedNextSteps: string[];
138
+ insideAgent: boolean;
139
+ }): void;
140
+ /**
141
+ * Builds the tally body line shown under the top end-of-run NX block. Returns
142
+ * `null` when there is nothing meaningful to tally (e.g. an empty
143
+ * migrations.json), so the caller can omit the body entirely instead of
144
+ * emitting a misleading `0 prompt migrations skipped.` line.
145
+ *
146
+ * Rule (kept coherent across every scenario):
147
+ * - When at least one migration was applied: `<N> migrations applied, <K> commits created[, <D> prompt migrations <skipped|deferred>]`.
148
+ * The `<K> commits created` part stays even at 0 — it tells the reader work
149
+ * was applied but not committed (the J4/J8 information made explicit).
150
+ * - When zero migrations were applied but some prompt halves were
151
+ * skipped/deferred: `<D> prompt migrations <skipped|deferred>` only.
152
+ * - When zero of either: no body line.
153
+ */
154
+ export declare function buildTallyBodyLine(opts: {
155
+ appliedCount: number;
156
+ committedShasCount: number;
157
+ skippedPromptsCount: number;
158
+ insideAgent: boolean;
159
+ }): string | null;
160
+ /**
161
+ * Body lines for the end-of-run retained-state warning. Fires on the success
162
+ * path — the run completed but one or more migrations' own commits failed
163
+ * and were never absorbed.
164
+ */
165
+ export declare function buildRetainedAtSuccessBody(retainedNames: ReadonlyArray<string>): string[];
166
+ /**
167
+ * Builds the body lines for the inside-agent directive block. Sub-sections
168
+ * drop independently when empty. Returns an empty array when the block has
169
+ * nothing actionable (no deferred prompts AND no migration-emitted notes) —
170
+ * the caller skips emitting the block entirely in that case.
171
+ */
172
+ export declare function buildDirectiveBlockBodyLines(opts: {
173
+ skippedPrompts: ReadonlyArray<{
174
+ prompt?: string;
175
+ name: string;
176
+ implementation?: string;
177
+ factory?: string;
178
+ }>;
179
+ migrationEmittedNextSteps: string[];
180
+ }): string[];