@depup/nx 23.2.1-depup.7 → 23.3.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 (350) hide show
  1. package/README.md +8 -19
  2. package/changes.json +10 -54
  3. package/dist/bin/init-local.js +7 -1
  4. package/dist/nx-cloud-internals.d.ts +1 -0
  5. package/dist/nx-cloud-internals.js +9 -0
  6. package/dist/plugins/package-json.js +1 -1
  7. package/dist/src/command-line/add/add.js +5 -1
  8. package/dist/src/command-line/affected/affected.js +70 -9
  9. package/dist/src/command-line/affected/command-object.js +1 -1
  10. package/dist/src/command-line/format/format.js +2 -18
  11. package/dist/src/command-line/graph/graph.d.ts +31 -0
  12. package/dist/src/command-line/graph/graph.js +113 -20
  13. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +0 -3
  14. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +0 -3
  15. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +0 -3
  16. package/dist/src/command-line/init/implementation/angular/index.js +0 -3
  17. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +0 -3
  18. package/dist/src/command-line/init/implementation/format.js +2 -3
  19. package/dist/src/command-line/init/implementation/utils.d.ts +0 -1
  20. package/dist/src/command-line/init/implementation/utils.js +6 -9
  21. package/dist/src/command-line/init/init-v2.js +0 -3
  22. package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +25 -0
  23. package/dist/src/command-line/migrate/agentic/capture-generator-output.js +121 -5
  24. package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +21 -0
  25. package/dist/src/command-line/migrate/agentic/close-agent-session.js +126 -0
  26. package/dist/src/command-line/migrate/agentic/definitions.d.ts +24 -0
  27. package/dist/src/command-line/migrate/agentic/definitions.js +79 -20
  28. package/dist/src/command-line/migrate/agentic/format-command.d.ts +14 -0
  29. package/dist/src/command-line/migrate/agentic/format-command.js +44 -0
  30. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +3 -3
  31. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +3 -3
  32. package/dist/src/command-line/migrate/agentic/handoff.d.ts +50 -17
  33. package/dist/src/command-line/migrate/agentic/handoff.js +166 -24
  34. package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +23 -0
  35. package/dist/src/command-line/migrate/agentic/instruction-files.js +41 -0
  36. package/dist/src/command-line/migrate/agentic/master/invocations.d.ts +12 -0
  37. package/dist/src/command-line/migrate/agentic/master/invocations.js +54 -0
  38. package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +16 -0
  39. package/dist/src/command-line/migrate/agentic/master/run-master-session.js +175 -0
  40. package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +31 -0
  41. package/dist/src/command-line/migrate/agentic/master/spawn-master.js +222 -0
  42. package/dist/src/command-line/migrate/agentic/prompts/final-validation.d.ts +13 -0
  43. package/dist/src/command-line/migrate/agentic/prompts/final-validation.js +41 -0
  44. package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +17 -0
  45. package/dist/src/command-line/migrate/agentic/prompts/fragments.js +90 -0
  46. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +4 -3
  47. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +25 -1
  48. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +57 -34
  49. package/dist/src/command-line/migrate/agentic/run-step.js +28 -4
  50. package/dist/src/command-line/migrate/agentic/runner.d.ts +3 -15
  51. package/dist/src/command-line/migrate/agentic/runner.js +57 -239
  52. package/dist/src/command-line/migrate/agentic/terminal-repair.d.ts +1 -0
  53. package/dist/src/command-line/migrate/agentic/terminal-repair.js +27 -0
  54. package/dist/src/command-line/migrate/agentic/types.d.ts +23 -8
  55. package/dist/src/command-line/migrate/agentic/types.js +10 -7
  56. package/dist/src/command-line/migrate/agentic/windows-cmd.d.ts +33 -0
  57. package/dist/src/command-line/migrate/agentic/windows-cmd.js +88 -0
  58. package/dist/src/command-line/migrate/command-object.d.ts +2 -0
  59. package/dist/src/command-line/migrate/command-object.js +11 -1
  60. package/dist/src/command-line/migrate/deferred-output.d.ts +44 -0
  61. package/dist/src/command-line/migrate/deferred-output.js +92 -0
  62. package/dist/src/command-line/migrate/execute-migration.d.ts +9 -3
  63. package/dist/src/command-line/migrate/execute-migration.js +53 -16
  64. package/dist/src/command-line/migrate/migrate-analytics.d.ts +34 -9
  65. package/dist/src/command-line/migrate/migrate-analytics.js +71 -10
  66. package/dist/src/command-line/migrate/migrate-commits.d.ts +5 -4
  67. package/dist/src/command-line/migrate/migrate-commits.js +16 -6
  68. package/dist/src/command-line/migrate/migrate-config.d.ts +5 -2
  69. package/dist/src/command-line/migrate/migrate-config.js +19 -11
  70. package/dist/src/command-line/migrate/migrate-output.d.ts +3 -7
  71. package/dist/src/command-line/migrate/migrate-output.js +3 -7
  72. package/dist/src/command-line/migrate/migrate.d.ts +3 -0
  73. package/dist/src/command-line/migrate/migrate.js +183 -46
  74. package/dist/src/command-line/migrate/resolve-package-version.js +2 -19
  75. package/dist/src/command-line/migrate/run/agent-output.d.ts +11 -0
  76. package/dist/src/command-line/migrate/run/agent-output.js +21 -2
  77. package/dist/src/command-line/migrate/run/agent-work-payload.d.ts +37 -0
  78. package/dist/src/command-line/migrate/run/agent-work-payload.js +156 -0
  79. package/dist/src/command-line/migrate/run/atomic-write.d.ts +8 -0
  80. package/dist/src/command-line/migrate/run/atomic-write.js +17 -0
  81. package/dist/src/command-line/migrate/run/broker.d.ts +150 -0
  82. package/dist/src/command-line/migrate/run/broker.js +568 -0
  83. package/dist/src/command-line/migrate/run/clean-retry.d.ts +12 -0
  84. package/dist/src/command-line/migrate/run/clean-retry.js +99 -0
  85. package/dist/src/command-line/migrate/run/existing-run-report.d.ts +55 -0
  86. package/dist/src/command-line/migrate/run/existing-run-report.js +227 -0
  87. package/dist/src/command-line/migrate/run/give-up.d.ts +41 -0
  88. package/dist/src/command-line/migrate/run/give-up.js +148 -0
  89. package/dist/src/command-line/migrate/run/index.d.ts +9 -6
  90. package/dist/src/command-line/migrate/run/index.js +21 -2
  91. package/dist/src/command-line/migrate/run/issues.d.ts +127 -0
  92. package/dist/src/command-line/migrate/run/issues.js +1121 -0
  93. package/dist/src/command-line/migrate/run/orchestrator.d.ts +59 -1
  94. package/dist/src/command-line/migrate/run/orchestrator.js +1529 -457
  95. package/dist/src/command-line/migrate/run/run-id.d.ts +0 -8
  96. package/dist/src/command-line/migrate/run/run-id.js +0 -30
  97. package/dist/src/command-line/migrate/run/run-state.d.ts +77 -17
  98. package/dist/src/command-line/migrate/run/run-state.js +263 -32
  99. package/dist/src/command-line/migrate/run/runbook.d.ts +18 -0
  100. package/dist/src/command-line/migrate/run/runbook.js +118 -0
  101. package/dist/src/command-line/migrate/run/state-lock.d.ts +33 -2
  102. package/dist/src/command-line/migrate/run/state-lock.js +128 -2
  103. package/dist/src/command-line/migrate/run/state-machine.d.ts +50 -1
  104. package/dist/src/command-line/migrate/run/state-machine.js +339 -26
  105. package/dist/src/command-line/migrate/run/util.d.ts +3 -1
  106. package/dist/src/command-line/migrate/run/util.js +24 -3
  107. package/dist/src/command-line/migrate/run/worker.js +290 -129
  108. package/dist/src/command-line/migrate/step-actions.d.ts +1 -1
  109. package/dist/src/command-line/migrate/step-actions.js +7 -1
  110. package/dist/src/command-line/migrate/text.d.ts +6 -0
  111. package/dist/src/command-line/migrate/text.js +25 -0
  112. package/dist/src/command-line/migrate/version-skew-guard.js +2 -0
  113. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +5 -11
  114. package/dist/src/command-line/release/publish.js +11 -8
  115. package/dist/src/command-line/release/utils/get-touched-projects-for-group.js +3 -3
  116. package/dist/src/command-line/release/utils/release-graph.js +1 -1
  117. package/dist/src/command-line/release/utils/remote-release-clients/github.js +5 -8
  118. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +3 -3
  119. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +4 -2
  120. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +37 -3
  121. package/dist/src/command-line/release/version/version-actions.d.ts +3 -0
  122. package/dist/src/command-line/reset/reset.js +10 -4
  123. package/dist/src/command-line/run/run-one.js +5 -1
  124. package/dist/src/command-line/run-many/run-many.js +6 -12
  125. package/dist/src/command-line/show/command-object.js +1 -1
  126. package/dist/src/command-line/show/projects.js +52 -1
  127. package/dist/src/command-line/yargs-utils/shared-options.d.ts +5 -1
  128. package/dist/src/command-line/yargs-utils/shared-options.js +38 -4
  129. package/dist/src/config/task-graph.d.ts +1 -1
  130. package/dist/src/config/workspace-json-project-json.d.ts +23 -1
  131. package/dist/src/core/graph/main.js +1 -1
  132. package/dist/src/core/graph/runtime.js +1 -1
  133. package/dist/src/core/graph/styles.js +1 -1
  134. package/dist/src/daemon/client/client.d.ts +14 -8
  135. package/dist/src/daemon/client/client.js +41 -12
  136. package/dist/src/daemon/message-types/get-plugin-capabilities.d.ts +5 -0
  137. package/dist/src/daemon/message-types/get-plugin-capabilities.js +11 -0
  138. package/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts +3 -2
  139. package/dist/src/daemon/message-types/select-affected-tasks.d.ts +21 -0
  140. package/dist/src/daemon/message-types/select-affected-tasks.js +11 -0
  141. package/dist/src/daemon/message-types/ultracache-configuration-version.d.ts +8 -0
  142. package/dist/src/daemon/message-types/ultracache-configuration-version.js +2 -0
  143. package/dist/src/daemon/server/dotenv-graph-changes.d.ts +1 -1
  144. package/dist/src/daemon/server/dotenv-graph-changes.js +2 -2
  145. package/dist/src/daemon/server/handle-get-plugin-capabilities.d.ts +2 -0
  146. package/dist/src/daemon/server/handle-get-plugin-capabilities.js +13 -0
  147. package/dist/src/daemon/server/handle-hash-tasks.d.ts +10 -2
  148. package/dist/src/daemon/server/handle-hash-tasks.js +18 -3
  149. package/dist/src/daemon/server/handle-select-affected-tasks.d.ts +3 -0
  150. package/dist/src/daemon/server/handle-select-affected-tasks.js +26 -0
  151. package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +3 -2
  152. package/dist/src/daemon/server/{handle-outputs-changes.d.ts → handle-watch-events.d.ts} +4 -4
  153. package/dist/src/daemon/server/{handle-outputs-changes.js → handle-watch-events.js} +36 -37
  154. package/dist/src/daemon/server/outputs-tracking.d.ts +7 -19
  155. package/dist/src/daemon/server/outputs-tracking.js +7 -107
  156. package/dist/src/daemon/server/planning-context.d.ts +8 -0
  157. package/dist/src/daemon/server/planning-context.js +18 -0
  158. package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +22 -7
  159. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +104 -74
  160. package/dist/src/daemon/server/restart-checks.d.ts +22 -0
  161. package/dist/src/daemon/server/restart-checks.js +77 -0
  162. package/dist/src/daemon/server/server.d.ts +1 -0
  163. package/dist/src/daemon/server/server.js +54 -30
  164. package/dist/src/daemon/server/shutdown-utils.d.ts +0 -5
  165. package/dist/src/daemon/server/shutdown-utils.js +3 -26
  166. package/dist/src/daemon/server/ultracache-configuration-state.d.ts +7 -0
  167. package/dist/src/daemon/server/ultracache-configuration-state.js +36 -0
  168. package/dist/src/devkit-internals.d.ts +3 -1
  169. package/dist/src/devkit-internals.js +8 -3
  170. package/dist/src/executors/run-commands/run-commands.impl.d.ts +2 -1
  171. package/dist/src/executors/run-commands/run-commands.impl.js +19 -5
  172. package/dist/src/executors/run-commands/running-tasks.d.ts +5 -4
  173. package/dist/src/executors/run-commands/running-tasks.js +13 -13
  174. package/dist/src/hasher/create-task-hasher.d.ts +8 -1
  175. package/dist/src/hasher/create-task-hasher.js +13 -3
  176. package/dist/src/hasher/hash-plan-inspector.js +2 -2
  177. package/dist/src/hasher/hash-task.d.ts +2 -2
  178. package/dist/src/hasher/hash-task.js +28 -17
  179. package/dist/src/hasher/native-task-hasher-impl.d.ts +20 -4
  180. package/dist/src/hasher/native-task-hasher-impl.js +75 -9
  181. package/dist/src/hasher/task-hasher.d.ts +24 -7
  182. package/dist/src/hasher/task-hasher.js +27 -8
  183. package/dist/src/hasher/task-planning-context.d.ts +13 -0
  184. package/dist/src/hasher/task-planning-context.js +12 -0
  185. package/dist/src/native/index.d.ts +582 -21
  186. package/dist/src/native/index.js +3 -3
  187. package/dist/src/native/native-bindings.js +13 -1
  188. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  189. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  190. package/dist/src/native/transform-objects.d.ts +11 -2
  191. package/dist/src/native/transform-objects.js +46 -0
  192. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +15 -8
  193. package/dist/src/nx-cloud/update-manager.d.ts +3 -0
  194. package/dist/src/nx-cloud/update-manager.js +19 -13
  195. package/dist/src/nx-cloud/utilities/client.d.ts +1 -1
  196. package/dist/src/nx-cloud/utilities/client.js +1 -1
  197. package/dist/src/nx-cloud/utilities/is-workspace-claimed.js +2 -1
  198. package/dist/src/nx-cloud/utilities/nx-cloud-http-client.d.ts +5 -0
  199. package/dist/src/nx-cloud/utilities/nx-cloud-http-client.js +16 -0
  200. package/dist/src/nx-cloud/utilities/url-shorten.js +17 -10
  201. package/dist/src/plugins/js/index.js +45 -64
  202. package/dist/src/plugins/js/lock-file/lock-file.d.ts +4 -4
  203. package/dist/src/plugins/js/lock-file/lock-file.js +6 -7
  204. package/dist/src/plugins/js/lock-file/pnpm-parser.js +1 -1
  205. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +2 -0
  206. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +22 -0
  207. package/dist/src/plugins/js/project-graph/affected/lock-file-changes.d.ts +10 -2
  208. package/dist/src/plugins/js/project-graph/affected/lock-file-changes.js +51 -29
  209. package/dist/src/plugins/js/project-graph/affected/npm-packages.d.ts +10 -2
  210. package/dist/src/plugins/js/project-graph/affected/npm-packages.js +32 -11
  211. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +22 -18
  212. package/dist/src/plugins/js/utils/register.js +13 -4
  213. package/dist/src/plugins/package-json/create-nodes.d.ts +2 -2
  214. package/dist/src/plugins/package-json/create-nodes.js +13 -13
  215. package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +14 -0
  216. package/dist/src/project-graph/affected/affected-project-graph.js +5 -18
  217. package/dist/src/project-graph/affected/affected-projects.d.ts +7 -0
  218. package/dist/src/project-graph/affected/affected-projects.js +42 -0
  219. package/dist/src/project-graph/affected/affected-reasons.d.ts +116 -0
  220. package/dist/src/project-graph/affected/affected-reasons.js +459 -0
  221. package/dist/src/project-graph/affected/affected-tasks.d.ts +103 -0
  222. package/dist/src/project-graph/affected/affected-tasks.js +386 -0
  223. package/dist/src/project-graph/affected/print-explanation.d.ts +11 -0
  224. package/dist/src/project-graph/affected/print-explanation.js +44 -0
  225. package/dist/src/project-graph/error-types.d.ts +5 -0
  226. package/dist/src/project-graph/error-types.js +44 -5
  227. package/dist/src/project-graph/file-utils.d.ts +2 -0
  228. package/dist/src/project-graph/file-utils.js +12 -3
  229. package/dist/src/project-graph/nx-deps-cache.d.ts +5 -2
  230. package/dist/src/project-graph/nx-deps-cache.js +4 -4
  231. package/dist/src/project-graph/plugins/get-plugins.d.ts +3 -1
  232. package/dist/src/project-graph/plugins/get-plugins.js +60 -82
  233. package/dist/src/project-graph/plugins/in-process-loader.d.ts +1 -1
  234. package/dist/src/project-graph/plugins/in-process-loader.js +1 -4
  235. package/dist/src/project-graph/plugins/isolation/index.d.ts +1 -1
  236. package/dist/src/project-graph/plugins/isolation/index.js +3 -1
  237. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +8 -0
  238. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +42 -6
  239. package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.d.ts +10 -1
  240. package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.js +67 -17
  241. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +3 -2
  242. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +5 -1
  243. package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +5 -2
  244. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +14 -1
  245. package/dist/src/project-graph/plugins/nx-plugin-capabilities.d.ts +6 -0
  246. package/dist/src/project-graph/plugins/nx-plugin-capabilities.js +28 -0
  247. package/dist/src/project-graph/plugins/task-results-stub.d.ts +50 -0
  248. package/dist/src/project-graph/plugins/task-results-stub.js +111 -0
  249. package/dist/src/project-graph/plugins/tasks-execution-hooks.d.ts +3 -2
  250. package/dist/src/project-graph/plugins/tasks-execution-hooks.js +14 -1
  251. package/dist/src/project-graph/project-graph.js +43 -42
  252. package/dist/src/project-graph/utils/project-configuration/target-merging.js +67 -0
  253. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +83 -0
  254. package/dist/src/project-graph/utils/project-configuration/utils.d.ts +1 -0
  255. package/dist/src/project-graph/utils/project-configuration/utils.js +1 -0
  256. package/dist/src/tasks-runner/batch/run-batch.js +15 -0
  257. package/dist/src/tasks-runner/cache.d.ts +37 -2
  258. package/dist/src/tasks-runner/cache.js +42 -1
  259. package/dist/src/tasks-runner/create-task-graph.d.ts +24 -1
  260. package/dist/src/tasks-runner/create-task-graph.js +57 -2
  261. package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
  262. package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
  263. package/dist/src/tasks-runner/forked-process-task-runner.js +11 -10
  264. package/dist/src/tasks-runner/init-tasks-runner.d.ts +7 -2
  265. package/dist/src/tasks-runner/init-tasks-runner.js +15 -7
  266. package/dist/src/tasks-runner/is-tui-enabled.js +4 -3
  267. package/dist/src/tasks-runner/life-cycle.d.ts +7 -0
  268. package/dist/src/tasks-runner/life-cycle.js +7 -0
  269. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.d.ts +35 -0
  270. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +146 -0
  271. package/dist/src/tasks-runner/prune-task-graph.d.ts +17 -0
  272. package/dist/src/tasks-runner/prune-task-graph.js +45 -0
  273. package/dist/src/tasks-runner/run-command.d.ts +41 -5
  274. package/dist/src/tasks-runner/run-command.js +98 -22
  275. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +93 -19
  276. package/dist/src/tasks-runner/running-tasks/batch-process.js +184 -88
  277. package/dist/src/tasks-runner/task-io-service.d.ts +11 -3
  278. package/dist/src/tasks-runner/task-io-service.js +14 -5
  279. package/dist/src/tasks-runner/task-orchestrator.d.ts +71 -4
  280. package/dist/src/tasks-runner/task-orchestrator.js +266 -66
  281. package/dist/src/tasks-runner/tasks-runner.d.ts +2 -0
  282. package/dist/src/tasks-runner/terminal-output-path.d.ts +11 -0
  283. package/dist/src/tasks-runner/terminal-output-path.js +18 -0
  284. package/dist/src/tasks-runner/utils.d.ts +5 -0
  285. package/dist/src/tasks-runner/utils.js +14 -2
  286. package/dist/src/ultracache/config.d.ts +21 -0
  287. package/dist/src/ultracache/config.js +29 -0
  288. package/dist/src/ultracache/fetch.d.ts +21 -0
  289. package/dist/src/ultracache/fetch.js +43 -0
  290. package/dist/src/ultracache/overrides.d.ts +17 -0
  291. package/dist/src/ultracache/overrides.js +61 -0
  292. package/dist/src/ultracache/report.d.ts +13 -0
  293. package/dist/src/ultracache/report.js +62 -0
  294. package/dist/src/ultracache/store.d.ts +41 -0
  295. package/dist/src/ultracache/store.js +158 -0
  296. package/dist/src/utils/ab-testing.d.ts +4 -1
  297. package/dist/src/utils/ab-testing.js +22 -19
  298. package/dist/src/utils/chunkify.d.ts +1 -7
  299. package/dist/src/utils/chunkify.js +2 -8
  300. package/dist/src/utils/command-line-utils.d.ts +20 -0
  301. package/dist/src/utils/command-line-utils.js +10 -3
  302. package/dist/src/utils/create-cli-options.d.ts +6 -0
  303. package/dist/src/utils/create-cli-options.js +29 -0
  304. package/dist/src/utils/db-connection.d.ts +2 -0
  305. package/dist/src/utils/db-connection.js +2 -0
  306. package/dist/src/utils/formatters/index.d.ts +6 -0
  307. package/dist/src/utils/formatters/index.js +5 -0
  308. package/dist/src/utils/formatters/prettier.d.ts +0 -8
  309. package/dist/src/utils/formatters/prettier.js +4 -26
  310. package/dist/src/utils/git-utils.d.ts +19 -0
  311. package/dist/src/utils/git-utils.js +97 -39
  312. package/dist/src/utils/handle-errors.js +5 -43
  313. package/dist/src/utils/http-client.d.ts +27 -0
  314. package/dist/src/utils/http-client.js +193 -0
  315. package/dist/src/utils/installed-nx-version.js +2 -48
  316. package/dist/src/utils/json-diff.d.ts +4 -2
  317. package/dist/src/utils/json-diff.js +6 -94
  318. package/dist/src/utils/min-release-age/packument.js +1 -1
  319. package/dist/src/utils/nx-cloud-utils.d.ts +2 -0
  320. package/dist/src/utils/nx-cloud-utils.js +6 -1
  321. package/dist/src/utils/output.d.ts +22 -3
  322. package/dist/src/utils/output.js +28 -5
  323. package/dist/src/utils/package-json.d.ts +25 -0
  324. package/dist/src/utils/package-json.js +49 -6
  325. package/dist/src/utils/package-manager.d.ts +6 -0
  326. package/dist/src/utils/package-manager.js +10 -0
  327. package/dist/src/utils/plugins/plugin-capabilities.js +7 -2
  328. package/dist/src/utils/project-graph-utils.d.ts +2 -0
  329. package/dist/src/utils/project-graph-utils.js +12 -0
  330. package/dist/src/utils/provenance.js +20 -4
  331. package/dist/src/utils/serialize-overrides-into-command-line.js +2 -4
  332. package/dist/src/utils/workspace-context.d.ts +51 -3
  333. package/dist/src/utils/workspace-context.js +174 -10
  334. package/package.json +38 -100
  335. package/schemas/nx-schema.json +38 -0
  336. package/schemas/project-schema.json +35 -0
  337. package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +0 -9
  338. package/dist/src/daemon/server/file-watching/route-workspace-changes.js +0 -76
  339. package/dist/src/daemon/server/watcher.d.ts +0 -18
  340. package/dist/src/daemon/server/watcher.js +0 -126
  341. package/dist/src/nx-cloud/utilities/axios.d.ts +0 -4
  342. package/dist/src/nx-cloud/utilities/axios.js +0 -17
  343. package/dist/src/project-graph/affected/locators/project-glob-changes.d.ts +0 -2
  344. package/dist/src/project-graph/affected/locators/project-glob-changes.js +0 -47
  345. package/dist/src/project-graph/affected/locators/workspace-json-changes.d.ts +0 -4
  346. package/dist/src/project-graph/affected/locators/workspace-json-changes.js +0 -47
  347. package/dist/src/project-graph/affected/locators/workspace-projects.d.ts +0 -3
  348. package/dist/src/project-graph/affected/locators/workspace-projects.js +0 -74
  349. package/dist/src/utils/collapse-expanded-outputs.d.ts +0 -10
  350. package/dist/src/utils/collapse-expanded-outputs.js +0 -72
@@ -7,7 +7,6 @@ const git_utils_1 = require("../../../utils/git-utils");
7
7
  const fileutils_1 = require("../../../utils/fileutils");
8
8
  const installation_directory_1 = require("../../../utils/installation-directory");
9
9
  const package_json_1 = require("../../../utils/package-json");
10
- const inception_1 = require("../agentic/inception");
11
10
  const print_dropped_agent_context_1 = require("../agentic/print-dropped-agent-context");
12
11
  const select_1 = require("../agentic/select");
13
12
  const types_1 = require("../agentic/types");
@@ -23,8 +22,11 @@ const run_id_1 = require("./run-id");
23
22
  const state_machine_1 = require("./state-machine");
24
23
  const state_lock_1 = require("./state-lock");
25
24
  const util_1 = require("./util");
25
+ const broker_1 = require("./broker");
26
26
  const text_1 = require("../text");
27
27
  const agent_output_1 = require("./agent-output");
28
+ const agent_work_payload_1 = require("./agent-work-payload");
29
+ const issues_1 = require("./issues");
28
30
  async function runSingleMigrationWorker(input) {
29
31
  const { root, runMigration, runId, commitPrefix, interactive, skipInstall, isVerbose, } = input;
30
32
  // The worker is a second CLI entry point: the run id reaches runDir() (where
@@ -97,13 +99,15 @@ async function runSingleMigrationWorker(input) {
97
99
  function readMigrationsSource(root, runId) {
98
100
  if (runId) {
99
101
  const dir = (0, run_state_1.runDir)(root, runId);
100
- // A missing run.json would surface a raw ENOENT from readRunState's
101
- // readFileSync; report it the way the orchestrator does instead, down to
102
- // carrying no remediation: starting a run is a separate, gated entry point,
103
- // and `--run-migrations` would run the whole plan in process instead.
102
+ // A missing run.json would surface a raw ENOENT from readRunState; report
103
+ // it the way the orchestrator does instead, with no remediation: starting
104
+ // a run is a gated entry point of its own.
104
105
  if (!(0, run_state_1.hasRunState)(dir)) {
105
106
  throw new Error(`No migrate run '${runId}' was found under ${types_1.MIGRATE_RUNS_RELATIVE_DIR}.`);
106
107
  }
108
+ // Before the state and plan reads: a concurrent start-fresh must not
109
+ // delete the run while this worker resolves its migration.
110
+ (0, state_lock_1.holdRunActivity)(root, runId);
107
111
  // Version refusal (NewerRunStateFormatError) propagates.
108
112
  const state = (0, run_state_1.readRunState)(dir);
109
113
  const round = (0, state_machine_1.latestRound)(state);
@@ -317,27 +321,31 @@ async function runStandalone(root, migration, opts) {
317
321
  // and no "apply this manually" block for the user either.
318
322
  if ((0, migration_shape_1.isHybridMigration)(migration) && !skipAgentic) {
319
323
  emitOrPrintPrompt(root, migration, agentic.kind, {
320
- logs,
321
- changes,
322
- agentContext,
323
- }, resolvedCollection);
324
+ impl: {
325
+ logs,
326
+ changes,
327
+ agentContext,
328
+ },
329
+ resolvedCollection,
330
+ });
324
331
  }
325
332
  }
326
333
  async function runRecorded(root, runId, migration, skipInstall, isVerbose) {
327
334
  const dir = (0, run_state_1.runDir)(root, runId);
328
335
  // Version refusal (NewerRunStateFormatError) propagates.
329
336
  let state = (0, run_state_1.readRunState)(dir);
330
- // A recorded run never resolves the agentic flow (the outer agent drives
331
- // it); prompts are emitted for that agent or printed for a user hand-running
332
- // the dispensed command.
333
- const agenticKind = (0, inception_1.isInsideAgent)()
334
- ? 'inside-agent'
335
- : 'disabled';
337
+ // A recorded run never resolves the agentic flow: the outer agent drives it,
338
+ // and the dispensed command is part of the orchestrated protocol whoever
339
+ // re-runs it. Gating the block on ambient agent detection would park the
340
+ // step awaiting an outcome whose payload was never emitted.
341
+ const agenticKind = 'inside-agent';
336
342
  const migrationId = `${migration.package}:${migration.name}`;
337
343
  // The plan was read from the latest round's snapshot, so only that round's
338
344
  // step may match; a same-id step from an older round must not.
339
345
  const latest = (0, state_machine_1.latestRound)(state);
340
- const step = state.steps.find((s) => s.migrationId === migrationId && s.roundIndex === latest?.index);
346
+ const step = state.steps.find((s) => s.kind === 'migration' &&
347
+ s.migrationId === migrationId &&
348
+ s.roundIndex === latest?.index);
341
349
  if (!step) {
342
350
  throw new Error(`The migrate run '${runId}' has no step for migration '${migrationId}'.`);
343
351
  }
@@ -350,99 +358,185 @@ async function runRecorded(root, runId, migration, skipInstall, isVerbose) {
350
358
  startedAt: (0, util_1.nowIso)(),
351
359
  });
352
360
  // A prior attempt's generator half already ran, so this attempt must not
353
- // reapply it against a tree that already holds its changes: a hybrid
354
- // re-emits only its prompt, and a plain generator step has nothing left to
355
- // do but the install and commit its previous attempt failed on.
356
- // Read from the state the start transition returned: a delayed invocation
357
- // may have claimed a later attempt whose flag its entry snapshot predates.
361
+ // reapply it against a tree that already holds its changes. Read from the
362
+ // state the start transition returned, not the entry snapshot: a delayed
363
+ // invocation may have claimed a later attempt whose flag `step` predates.
358
364
  const startedStep = state.steps.find((s) => s.id === step.id);
359
365
  const generatorAlreadyCompleted = startedStep.generatorCompleted === true;
360
- // The run records its own install policy because dispensed worker commands
361
- // are re-invoked by the loop and never carry the user's flags; an explicit
362
- // --skip-install on this invocation still applies on top of it.
366
+ // Dispensed worker commands never carry the user's flags, so the run records
367
+ // its install policy. An explicit --skip-install here applies only to the
368
+ // installs this process runs itself; a parent session answers from its own.
363
369
  const effectiveSkipInstall = state.skipInstall === true || skipInstall;
370
+ // The run records the resolved validation policy at init; absent (a state
371
+ // predating the field) falls back to the same default init applies.
372
+ const shouldValidate = state.validate !== false;
373
+ // The tree reservation an in-process install or commit takes is held until
374
+ // the transition that records this attempt's outcome is written.
375
+ const scope = {};
376
+ // Called before a retry hands the step's work back: the prompt or validation
377
+ // may need the dependencies the earlier attempt's generator added.
378
+ const reinstallFromBaseline = () => (0, broker_1.installStepTree)(dir, startedStep, 'install', () => recordingInstallFailure(dir, step.id, () => (0, util_1.installDepsChangedSinceDispense)(root, dir, startedStep, effectiveSkipInstall, `${(0, execute_migration_1.formatSingleMigrationRerunCommand)(migrationId)} --run-id=${runId}`)), scope);
364
379
  let outcome;
380
+ let awaitingKind;
381
+ const payloadPath = (0, agent_work_payload_1.agentWorkPayloadPath)(dir, step.id, startedStep.attempt);
365
382
  try {
366
- if ((0, migration_shape_1.isPromptOnlyMigration)(migration) ||
367
- (generatorAlreadyCompleted && (0, migration_shape_1.isHybridMigration)(migration))) {
368
- emitOrPrintPrompt(root, migration, agenticKind);
369
- }
370
- else if (generatorAlreadyCompleted) {
371
- state = await finishCompletedGenerator(dir, root, state, startedStep, migration, effectiveSkipInstall, runId);
372
- outcome = buildOutcome([], [], 'The generator ran in an earlier attempt; this attempt completed its install and commit.', root);
373
- }
374
- else {
375
- const installer = new execute_migration_1.ChangedDepInstaller(root, effectiveSkipInstall, `${(0, execute_migration_1.formatSingleMigrationRerunCommand)(migrationId)} --run-id=${runId}`);
376
- // Read once; the run and the hybrid documentation resolution share it.
377
- const resolvedCollection = (0, execute_migration_1.readMigrationCollection)(migration.package, root);
378
- const { changes, nextSteps, agentContext, logs, madeChanges } = await (0, execute_migration_1.runNxOrAngularMigration)(root, migration, isVerbose, (0, migration_shape_1.isHybridMigration)(migration), resolvedCollection);
379
- // Recorded before the commit is attempted: from here on the changes are
380
- // in the tree, so a failed install or commit must leave a retry with
381
- // only those left to do rather than running the generator again.
382
- state = transition(dir, {
383
- type: 'markGeneratorCompleted',
384
- stepId: step.id,
385
- });
386
- if (!(0, migration_shape_1.isHybridMigration)(migration)) {
387
- forwardDroppedAgentContext(migration, agentContext, agenticKind);
388
- }
389
- const install = () => recordingInstallFailure(dir, step.id, () => installer.installDepsIfChanged());
390
- // Commits follow the run config, not CLI flags, and only when the
391
- // generator changed something: a no-op step must not create a commit (nor
392
- // a ledger entry) that absorbs prior pending diffs under its name.
393
- if (state.createCommits && madeChanges) {
394
- state = await commitStepChanges(dir, root, state, step, migration, install);
395
- }
396
- else {
397
- await install();
383
+ try {
384
+ if ((0, migration_shape_1.isPromptOnlyMigration)(migration)) {
385
+ emitOrPrintPrompt(root, migration, agenticKind, {
386
+ persistPath: payloadPath,
387
+ });
388
+ awaitingKind = 'migration-prompt';
398
389
  }
399
- if (installer.skippedInstall) {
400
- (0, execute_migration_1.logSkippedPostMigrationInstall)(root);
390
+ else if (generatorAlreadyCompleted &&
391
+ startedStep.agenticWaived !== true &&
392
+ (0, migration_shape_1.isHybridMigration)(migration)) {
393
+ await reinstallFromBaseline();
394
+ const carried = (0, agent_work_payload_1.latestStoredAgentWorkPayload)(dir, step.id, startedStep.attempt, startedStep.generatorCompletedAtAttempt, {
395
+ migrationId,
396
+ kind: 'migration-prompt',
397
+ promptPath: migration.prompt,
398
+ });
399
+ if (carried) {
400
+ reemitCarriedAgentWork(migrationId, 'migration-prompt', payloadPath, carried);
401
+ }
402
+ else {
403
+ emitOrPrintPrompt(root, migration, agenticKind, {
404
+ persistPath: payloadPath,
405
+ });
406
+ }
407
+ awaitingKind = 'migration-prompt';
401
408
  }
402
- else if (installer.installed) {
403
- (0, util_1.recordInstallLanded)(root, dir, step.id);
409
+ else if (generatorAlreadyCompleted &&
410
+ startedStep.validationOwed === true) {
411
+ // The flag is the only record that these changes still owe a validation
412
+ // pass; the decision needed the generator result, which is gone with the
413
+ // attempt that made it. The commit stays with the fold.
414
+ await reinstallFromBaseline();
415
+ const carried = (0, agent_work_payload_1.latestStoredAgentWorkPayload)(dir, step.id, startedStep.attempt, startedStep.generatorCompletedAtAttempt, { migrationId, kind: 'generator-validation' });
416
+ if (carried) {
417
+ reemitCarriedAgentWork(migrationId, 'generator-validation', payloadPath, carried);
418
+ }
419
+ else {
420
+ emitValidationBlock(root, migration, undefined, {
421
+ persistPath: payloadPath,
422
+ });
423
+ }
424
+ awaitingKind = 'generator-validation';
404
425
  }
405
- printNextSteps(migration, nextSteps);
406
- if ((0, migration_shape_1.isHybridMigration)(migration)) {
407
- emitOrPrintPrompt(root, migration, agenticKind, {
408
- logs,
409
- changes,
410
- agentContext,
411
- }, resolvedCollection);
426
+ else if (generatorAlreadyCompleted) {
427
+ state = await finishCompletedGenerator(dir, root, state, startedStep, migration, effectiveSkipInstall, runId, scope);
428
+ outcome = buildOutcome([], [], 'The generator ran in an earlier attempt; this attempt completed its install and commit.', root);
412
429
  }
413
430
  else {
414
- outcome = buildOutcome(changes, nextSteps, migration.description, root);
431
+ const installer = new execute_migration_1.ChangedDepInstaller(root, effectiveSkipInstall, `${(0, execute_migration_1.formatSingleMigrationRerunCommand)(migrationId)} --run-id=${runId}`);
432
+ // Read once; the run and the hybrid documentation resolution share it.
433
+ const resolvedCollection = (0, execute_migration_1.readMigrationCollection)(migration.package, root);
434
+ const { changes, nextSteps, agentContext, skipAgentic, logs, madeChanges, } = await (0, execute_migration_1.runNxOrAngularMigration)(root, migration, isVerbose,
435
+ // Captured whenever an agent step may consume it: a hybrid's prompt
436
+ // payload, or the validation pass over the generator's changes.
437
+ (0, migration_shape_1.isHybridMigration)(migration) || shouldValidate, resolvedCollection);
438
+ // Mirrors the classic loop's waiver semantics (migrate.ts): the two must
439
+ // agree on when an AI step was owed for skipAgentic to waive.
440
+ const validationApplies = shouldValidate && !(0, migration_shape_1.isHybridMigration)(migration) && changes.length > 0;
441
+ const waivedAgenticStep = skipAgentic && ((0, migration_shape_1.isHybridMigration)(migration) || validationApplies);
442
+ const validationOwed = validationApplies && !waivedAgenticStep;
443
+ const promptOwed = (0, migration_shape_1.isHybridMigration)(migration) && !waivedAgenticStep;
444
+ // Recorded before the commit is attempted: from here on the changes are
445
+ // in the tree, so a failed install or commit must leave a retry with
446
+ // only those left to do rather than running the generator again.
447
+ state = transition(dir, {
448
+ type: 'markGeneratorCompleted',
449
+ stepId: step.id,
450
+ agenticWaived: waivedAgenticStep,
451
+ validationOwed,
452
+ madeChanges,
453
+ });
454
+ if (waivedAgenticStep) {
455
+ (0, migrate_output_1.logWaivedAgenticStep)(migration, agentContext);
456
+ }
457
+ else if (!(0, migration_shape_1.isHybridMigration)(migration) && !validationApplies) {
458
+ forwardDroppedAgentContext(migration, agentContext, agenticKind);
459
+ }
460
+ // Stored before the install: a failed install fails the attempt, and
461
+ // the retry re-hands this payload instead of a context-free one.
462
+ const impl = { logs, changes, agentContext };
463
+ const owed = validationOwed
464
+ ? validationPayload(root, migration, impl, resolvedCollection)
465
+ : promptOwed
466
+ ? promptPayload(root, migration, impl, resolvedCollection)
467
+ : undefined;
468
+ if (owed) {
469
+ (0, agent_work_payload_1.persistAgentWorkPayload)(payloadPath, owed);
470
+ }
471
+ const install = () => recordingInstallFailure(dir, step.id, () => installer.installDepsIfChanged());
472
+ // A no-op step's commit would absorb prior pending diffs under its name;
473
+ // a step handing work back defers its commit to the fold, so the
474
+ // migration still lands as one commit. The install runs either way: the
475
+ // agent may run tasks that need what the generator added.
476
+ if (state.createCommits &&
477
+ madeChanges &&
478
+ !validationOwed &&
479
+ !promptOwed) {
480
+ state = await commitStepChanges(dir, root, state, startedStep, migration, install, scope);
481
+ }
482
+ else {
483
+ await (0, broker_1.installStepTree)(dir, startedStep, 'install', install, scope);
484
+ }
485
+ if (installer.skippedInstall) {
486
+ (0, execute_migration_1.logSkippedPostMigrationInstall)(root);
487
+ }
488
+ else if (installer.installed) {
489
+ (0, util_1.recordInstallLanded)(root, dir, step.id);
490
+ }
491
+ printNextSteps(migration, nextSteps);
492
+ if (validationOwed) {
493
+ emitValidationPayload(migrationId, owed);
494
+ awaitingKind = 'generator-validation';
495
+ }
496
+ else if (promptOwed) {
497
+ emitPromptForOuterAgent(migrationId, owed, true);
498
+ awaitingKind = 'migration-prompt';
499
+ }
500
+ else {
501
+ outcome = buildOutcome(changes, nextSteps, migration.description, root);
502
+ }
415
503
  }
416
504
  }
417
- }
418
- catch (e) {
419
- // The failed-step dispense surfaces this so the agent can decide
420
- // retry-vs-skip; carry the error's first line, not a full stack.
505
+ catch (e) {
506
+ // Another attempt owns the step, and `fail` is not attempt-bound.
507
+ if (e instanceof broker_1.BrokerStaleRequestError)
508
+ throw e;
509
+ // The failed-step dispense surfaces this so the agent can decide
510
+ // retry-vs-skip; carry the error's first line, not a full stack.
511
+ transition(dir, {
512
+ type: 'fail',
513
+ stepId: step.id,
514
+ finishedAt: (0, util_1.nowIso)(),
515
+ outcome: { summary: (0, util_1.summarizeError)(e) },
516
+ });
517
+ throw e;
518
+ }
519
+ // Handed-back work is applied by a separate actor, so parking exits
520
+ // successfully rather than failing the step.
521
+ if (awaitingKind !== undefined) {
522
+ transition(dir, {
523
+ type: 'awaitPromptOutcome',
524
+ stepId: step.id,
525
+ finishedAt: (0, util_1.nowIso)(),
526
+ awaitingKind,
527
+ });
528
+ return;
529
+ }
421
530
  transition(dir, {
422
- type: 'fail',
531
+ type: 'succeed',
423
532
  stepId: step.id,
424
533
  finishedAt: (0, util_1.nowIso)(),
425
- outcome: { summary: (0, util_1.summarizeError)(e) },
534
+ ...(outcome ? { outcome } : {}),
426
535
  });
427
- throw e;
428
536
  }
429
- // A prompt half (prompt-only, or the prompt phase of a hybrid) is applied by
430
- // a separate actor, so the step parks in awaiting-prompt-outcome and this
431
- // process exits successfully.
432
- if ((0, migration_shape_1.isPromptOnlyMigration)(migration) || (0, migration_shape_1.isHybridMigration)(migration)) {
433
- transition(dir, {
434
- type: 'awaitPromptOutcome',
435
- stepId: step.id,
436
- finishedAt: (0, util_1.nowIso)(),
437
- });
438
- return;
537
+ finally {
538
+ scope.lease?.release();
439
539
  }
440
- transition(dir, {
441
- type: 'succeed',
442
- stepId: step.id,
443
- finishedAt: (0, util_1.nowIso)(),
444
- ...(outcome ? { outcome } : {}),
445
- });
446
540
  }
447
541
  // Applies a step event to the freshest on-disk state under the lock, writes it,
448
542
  // and returns it. Reading fresh is what makes a racing worker's 'start' see the
@@ -475,44 +569,52 @@ async function recordingInstallFailure(dir, stepId, install) {
475
569
  // on the install or the commit. The generator's changes are already in the
476
570
  // tree, so only those two are left, and the install compares against the
477
571
  // step's persisted baseline rather than against what that generator wrote.
478
- async function finishCompletedGenerator(dir, root, state, step, migration, skipInstall, runId) {
572
+ async function finishCompletedGenerator(dir, root, state, step, migration, skipInstall, runId, scope) {
479
573
  const migrationId = `${migration.package}:${migration.name}`;
480
574
  const installDeps = () => recordingInstallFailure(dir, step.id, () => (0, util_1.installDepsChangedSinceDispense)(root, dir, step, skipInstall, `${(0, execute_migration_1.formatSingleMigrationRerunCommand)(migrationId)} --run-id=${runId}`));
481
- if (!state.createCommits) {
482
- await installDeps();
575
+ // Same no-op guard as the first attempt. Only an explicit false skips the
576
+ // commit: absent means an older nx wrote the marker without recording the
577
+ // answer, and the commit is kept as that version's retries did.
578
+ if (!state.createCommits || step.generatorMadeChanges === false) {
579
+ await (0, broker_1.installStepTree)(dir, step, 'install', installDeps, scope);
483
580
  return state;
484
581
  }
485
- return commitStepChanges(dir, root, state, step, migration, installDeps);
582
+ return commitStepChanges(dir, root, state, step, migration, installDeps, scope);
486
583
  }
487
584
  // Installs what the step changed, commits it, and records the result in the
488
585
  // ledger, shared by a step's first attempt and by one that only has the commit
489
586
  // left to do. The absorbed step ids are computed before the commit so the
490
587
  // ledger entry and the commit body name the same ones.
491
- async function commitStepChanges(dir, root, state, step, migration, installDeps) {
588
+ async function commitStepChanges(dir, root, state, step, migration, installDeps, scope) {
492
589
  const absorbedStepIds = (0, state_machine_1.uncoveredFailedStepIds)(state).filter((id) => id !== step.id);
493
- let result;
590
+ let commit;
494
591
  try {
495
- result = await (0, migrate_commits_1.commitMigrationIfRequested)(root, migration, true, state.commitPrefix, installDeps, (0, state_machine_1.stepsToPendingMigrations)(state, absorbedStepIds));
592
+ commit = await (0, broker_1.commitStepTree)(dir, step, absorbedStepIds, () => (0, migrate_commits_1.commitMigrationIfRequested)(root, migration, true, state.commitPrefix, installDeps, (0, state_machine_1.stepsToPendingMigrations)(state, absorbedStepIds)), scope);
496
593
  }
497
594
  catch (commitError) {
498
- // A post-migration install failure leaves the diff uncommitted; record the
499
- // debt so only a landed entry can cover it.
500
- appendCommit(dir, { kind: 'failed', stepIds: [step.id] });
595
+ // Nothing ran for a stale or refused request, so there is no debt.
596
+ if (commitError instanceof broker_1.BrokerStaleRequestError ||
597
+ commitError instanceof broker_1.TreeBusyError) {
598
+ throw commitError;
599
+ }
600
+ // The install failed, or the session ended unanswered and the commit may
601
+ // or may not have landed; record the debt until a landed entry covers it.
602
+ recordCommitEntry(dir, { kind: 'failed', stepIds: [step.id] });
501
603
  throw commitError;
502
604
  }
503
- if (result.status === 'failed') {
605
+ if (commit.result.status === 'failed') {
504
606
  (0, util_1.warnCommitFailed)(migration.name);
505
607
  }
506
- const entry = (0, state_machine_1.commitResultToLedgerEntry)(result, step.id, absorbedStepIds);
507
- return entry ? appendCommit(dir, entry) : state;
608
+ const entry = (0, state_machine_1.commitResultToLedgerEntry)(commit.result, step.id, commit.absorbedStepIds);
609
+ // A session's parent records what it commits itself, receipt included.
610
+ return entry && !commit.recorded ? recordCommitEntry(dir, entry) : state;
508
611
  }
509
- // Appends a ledger entry to the freshest on-disk state under the lock. The git
510
- // commit itself already ran outside the lock; only this pure append is locked.
511
- function appendCommit(dir, entry) {
512
- return (0, state_lock_1.updateRunState)(dir, (fresh) => ({
513
- ...fresh,
514
- commits: [...fresh.commits, entry],
515
- }));
612
+ // The git commit itself already ran outside the lock; only this pure append is
613
+ // locked. A landed entry carries the resolved issues of every step it names,
614
+ // same as the orchestrator's fold and adopt appends: an absorbed step's
615
+ // resolutions would otherwise land unattached.
616
+ function recordCommitEntry(dir, entry) {
617
+ return (0, state_lock_1.updateRunState)(dir, (fresh) => (0, state_machine_1.appendCommit)(fresh, (0, issues_1.attachIssueIdsToCommitEntry)(fresh, entry)));
516
618
  }
517
619
  function buildOutcome(changes, nextSteps, description, root) {
518
620
  const outcome = {};
@@ -577,7 +679,7 @@ async function runAgenticStep(agenticRun, input) {
577
679
  // commit's diff, so it passes its own guidance instead of the default.
578
680
  // `commitMigrationIfRequested` logs a failed commit itself with that guidance.
579
681
  function attemptStandaloneCommit(root, migration, createCommits, commitPrefix, installDepsIfChanged) {
580
- return (0, migrate_commits_1.commitMigrationIfRequested)(root, migration, createCommits, commitPrefix, installDepsIfChanged, [], 'Commit or revert the changes manually.');
682
+ return (0, migrate_commits_1.commitMigrationIfRequested)(root, migration, createCommits, commitPrefix, installDepsIfChanged, [], 'Commit or revert any remaining uncommitted changes manually.');
581
683
  }
582
684
  async function commitAndLogAgenticOutcome(args) {
583
685
  const commit = await attemptStandaloneCommit(args.root, args.migration, args.createCommits, args.commitPrefix, args.installDepsIfChanged);
@@ -598,32 +700,60 @@ function printNextSteps(migration, nextSteps) {
598
700
  bodyLines: nextSteps.map((line) => `- ${(0, text_1.singleLine)(line)}`),
599
701
  });
600
702
  }
601
- function emitOrPrintPrompt(root, migration, agenticKind, impl, resolvedCollection) {
703
+ function emitOrPrintPrompt(root, migration, agenticKind, opts = {}) {
602
704
  const migrationId = `${migration.package}:${migration.name}`;
603
- const promptPath = migration.prompt;
604
- const documentationPath = resolveDocumentationPath(root, migration, resolvedCollection);
605
705
  if (agenticKind === 'inside-agent') {
606
- emitPromptForOuterAgent(migrationId, promptPath, documentationPath, impl);
706
+ const payload = promptPayload(root, migration, opts.impl, opts.resolvedCollection);
707
+ if (opts.persistPath) {
708
+ (0, agent_work_payload_1.persistAgentWorkPayload)(opts.persistPath, payload);
709
+ }
710
+ emitPromptForOuterAgent(migrationId, payload, opts.persistPath !== undefined);
607
711
  }
608
712
  else {
609
- printPromptForUser(root, migration, promptPath, documentationPath);
713
+ printPromptForUser(root, migration, migration.prompt, resolveDocumentationPath(root, migration, opts.resolvedCollection));
610
714
  }
611
715
  }
612
- function emitPromptForOuterAgent(migrationId, promptPath, documentationPath, impl) {
613
- const payload = { migrationId, prompt: promptPath };
716
+ function promptPayload(root, migration, impl, resolvedCollection) {
717
+ const payload = {
718
+ migrationId: `${migration.package}:${migration.name}`,
719
+ prompt: migration.prompt,
720
+ };
721
+ const documentationPath = resolveDocumentationPath(root, migration, resolvedCollection);
614
722
  if (documentationPath)
615
723
  payload.documentationPath = documentationPath;
616
- if (impl) {
617
- payload.impl = {
618
- logs: impl.logs,
619
- changes: impl.changes.map((c) => ({ type: c.type, path: c.path })),
620
- ...(impl.agentContext.length > 0
621
- ? { agentContext: impl.agentContext }
622
- : {}),
623
- };
624
- }
724
+ if (impl)
725
+ payload.impl = implPayload(impl);
726
+ return payload;
727
+ }
728
+ const PROMPT_NOT_APPLIED = `The following prompt-based migration was not applied automatically.`;
729
+ // Recorded steps hand work back through the orchestrator, per the runbook's loop.
730
+ const RUN_NEXT_FIRST = `Run the dispensed "next" command first: its response restates this work and names the handoff file to write.`;
731
+ const CHANGES_AWAIT_VALIDATION = `The following migration's generator ran in an earlier attempt and its changes still await validation.`;
732
+ function emitPromptForOuterAgent(migrationId, payload, recorded) {
625
733
  (0, agent_output_1.logToAgent)({
626
- title: `The following prompt-based migration was not applied automatically. Apply it to this workspace, then continue.`,
734
+ title: recorded
735
+ ? `${PROMPT_NOT_APPLIED} ${RUN_NEXT_FIRST}`
736
+ : `${PROMPT_NOT_APPLIED} Apply it to this workspace, then continue.`,
737
+ });
738
+ (0, agent_output_1.emitPromptBlock)(migrationId, payload);
739
+ }
740
+ function implPayload(impl) {
741
+ return {
742
+ logs: impl.logs,
743
+ changes: impl.changes.map((c) => ({ type: c.type, path: c.path })),
744
+ ...(impl.agentContext.length > 0
745
+ ? { agentContext: impl.agentContext }
746
+ : {}),
747
+ };
748
+ }
749
+ // Re-hands what an earlier attempt stored. The payload is re-persisted under
750
+ // this attempt because the dispense reads only the current attempt's file.
751
+ function reemitCarriedAgentWork(migrationId, kind, payloadPath, payload) {
752
+ (0, agent_work_payload_1.persistAgentWorkPayload)(payloadPath, payload);
753
+ (0, agent_output_1.logToAgent)({
754
+ title: `${kind === 'migration-prompt'
755
+ ? PROMPT_NOT_APPLIED
756
+ : CHANGES_AWAIT_VALIDATION} ${RUN_NEXT_FIRST}`,
627
757
  });
628
758
  (0, agent_output_1.emitPromptBlock)(migrationId, payload);
629
759
  }
@@ -660,6 +790,37 @@ function printPromptForUser(root, migration, promptPath, documentationPath) {
660
790
  bodyLines,
661
791
  });
662
792
  }
793
+ // `impl` is absent on a retry whose earlier attempt left no stored payload;
794
+ // the emission then points at the tree.
795
+ function emitValidationBlock(root, migration, impl, opts = {}) {
796
+ const payload = validationPayload(root, migration, impl, opts.resolvedCollection);
797
+ if (opts.persistPath) {
798
+ (0, agent_work_payload_1.persistAgentWorkPayload)(opts.persistPath, payload);
799
+ }
800
+ emitValidationPayload(`${migration.package}:${migration.name}`, payload);
801
+ }
802
+ function emitValidationPayload(migrationId, payload) {
803
+ (0, agent_output_1.logToAgent)({
804
+ title: payload.impl !== undefined
805
+ ? `The following migration's generator ran without an AI-driven part. ${RUN_NEXT_FIRST}`
806
+ : `${CHANGES_AWAIT_VALIDATION} ${RUN_NEXT_FIRST} Inspect the changes with git.`,
807
+ });
808
+ (0, agent_output_1.emitPromptBlock)(migrationId, payload);
809
+ }
810
+ function validationPayload(root, migration, impl, resolvedCollection) {
811
+ // `kind` is what tells the block apart from an applied-prompt payload,
812
+ // which carries `prompt` instead.
813
+ const payload = {
814
+ migrationId: `${migration.package}:${migration.name}`,
815
+ kind: 'generator-validation',
816
+ };
817
+ const documentationPath = resolveDocumentationPath(root, migration, resolvedCollection);
818
+ if (documentationPath)
819
+ payload.documentationPath = documentationPath;
820
+ if (impl)
821
+ payload.impl = implPayload(impl);
822
+ return payload;
823
+ }
663
824
  // Non-fatal: documentation is supplementary, so a failure warns and the
664
825
  // prompt still runs without it.
665
826
  function resolveDocumentationPath(root, migration, resolvedCollection) {
@@ -1,5 +1,5 @@
1
1
  /** Allowed values for `--step-action`, the orchestrated reconcile's decision relay. */
2
- export declare const STEP_ACTIONS: readonly ['retry', 'skip', 'retry-clean', 'adopt'];
2
+ export declare const STEP_ACTIONS: readonly ['retry', 'skip', 'retry-clean', 'adopt', 'unresolved'];
3
3
  export type StepAction = (typeof STEP_ACTIONS)[number];
4
4
  /** Runtime guard backed by {@link STEP_ACTIONS} so the two can't drift apart. */
5
5
  export declare function isStepAction(value: unknown): value is StepAction;
@@ -5,7 +5,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.STEP_ACTIONS = void 0;
6
6
  exports.isStepAction = isStepAction;
7
7
  /** Allowed values for `--step-action`, the orchestrated reconcile's decision relay. */
8
- exports.STEP_ACTIONS = ['retry', 'skip', 'retry-clean', 'adopt'];
8
+ exports.STEP_ACTIONS = [
9
+ 'retry',
10
+ 'skip',
11
+ 'retry-clean',
12
+ 'adopt',
13
+ 'unresolved',
14
+ ];
9
15
  /** Runtime guard backed by {@link STEP_ACTIONS} so the two can't drift apart. */
10
16
  function isStepAction(value) {
11
17
  return exports.STEP_ACTIONS.includes(value);
@@ -16,3 +16,9 @@
16
16
  * real terminator can put a value at the start of a line.
17
17
  */
18
18
  export declare function singleLine(value: string): string;
19
+ export declare function hasLineBreak(value: string): boolean;
20
+ /**
21
+ * Renders an ISO timestamp as a human age ("6 hours ago"), falling back to
22
+ * the raw value when it is not parseable or lies in the future.
23
+ */
24
+ export declare function formatAge(timestamp: string): string;
@@ -4,6 +4,8 @@
4
4
  // run/util.ts without a cycle through run/state-lock.ts.
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.singleLine = singleLine;
7
+ exports.hasLineBreak = hasLineBreak;
8
+ exports.formatAge = formatAge;
7
9
  /**
8
10
  * Collapses every character a reader could take for a line break, so a value
9
11
  * cannot break out of the line it is rendered on. The driving agent scans the
@@ -24,3 +26,26 @@ exports.singleLine = singleLine;
24
26
  function singleLine(value) {
25
27
  return value.replace(/[\r\n\u000b\u000c\u0085\u2028\u2029]+/g, ' ');
26
28
  }
29
+ function hasLineBreak(value) {
30
+ return singleLine(value) !== value;
31
+ }
32
+ /**
33
+ * Renders an ISO timestamp as a human age ("6 hours ago"), falling back to
34
+ * the raw value when it is not parseable or lies in the future.
35
+ */
36
+ function formatAge(timestamp) {
37
+ const elapsedMs = Date.now() - Date.parse(timestamp);
38
+ if (!Number.isFinite(elapsedMs) || elapsedMs < 0) {
39
+ return timestamp;
40
+ }
41
+ const minutes = Math.floor(elapsedMs / 60_000);
42
+ if (minutes < 60) {
43
+ return `${minutes} minute${minutes === 1 ? '' : 's'} ago`;
44
+ }
45
+ const hours = Math.floor(elapsedMs / 3_600_000);
46
+ if (hours < 48) {
47
+ return `${hours} hour${hours === 1 ? '' : 's'} ago`;
48
+ }
49
+ const days = Math.floor(elapsedMs / 86_400_000);
50
+ return `${days} day${days === 1 ? '' : 's'} ago`;
51
+ }
@@ -19,6 +19,8 @@ const version_utils_1 = require("./version-utils");
19
19
  // pass this floor and route to a temp CLI that drops the new flags and runs
20
20
  // the plan phase instead.
21
21
  exports.NEW_MIGRATE_FLAGS_FLOOR = '23.2.0';
22
+ // List only flags that pick which migrate path runs: an older nx drops them
23
+ // and runs another one. Flags read only by --run-migrations do not belong.
22
24
  // yargs accepts both spellings of each flag and the raw argv is forwarded
23
25
  // across both migrate hops, so detection must catch every one.
24
26
  exports.NEW_MIGRATE_FLAGS = [