@depup/nx 23.2.1-depup.8 → 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 +7 -18
  2. package/changes.json +9 -53
  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 +36 -98
  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
@@ -0,0 +1,18 @@
1
+ export declare const RUNBOOK_FILE_NAME = "RUNBOOK.md";
2
+ export interface RunbookContext {
3
+ runId: string;
4
+ packageManager: string;
5
+ nxInvocation: string;
6
+ pmExec: string;
7
+ reconcileCommand: string;
8
+ createCommits: boolean;
9
+ validate: boolean;
10
+ finalValidation: boolean;
11
+ }
12
+ /**
13
+ * Every interpolated value is collapsed to a single line: the rendered content
14
+ * is written to disk and emitted verbatim inside a `<nx_migrate_runbook>`
15
+ * block, so a value carrying its own line break could otherwise open a forged
16
+ * block at a line start.
17
+ */
18
+ export declare function renderRunbook(ctx: RunbookContext): string;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ // Written to the run directory at init and re-emitted from disk on resume, so
3
+ // the contract is version-locked to the Nx that created the run and never
4
+ // depends on plugin skills or the session's memory.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RUNBOOK_FILE_NAME = void 0;
7
+ exports.renderRunbook = renderRunbook;
8
+ const fragments_1 = require("../agentic/prompts/fragments");
9
+ const types_1 = require("../agentic/types");
10
+ const text_1 = require("../text");
11
+ // A run's reconciles and workers skip the nx.json overlay and a continue takes
12
+ // only `agentic` from it, but the next init reads the whole section: an edit
13
+ // mid-run changes what a start-fresh or a later run does.
14
+ const NX_JSON_MIGRATE_RULE = ` - Do not edit the \`migrate\` section of nx.json.`;
15
+ exports.RUNBOOK_FILE_NAME = 'RUNBOOK.md';
16
+ /**
17
+ * Every interpolated value is collapsed to a single line: the rendered content
18
+ * is written to disk and emitted verbatim inside a `<nx_migrate_runbook>`
19
+ * block, so a value carrying its own line break could otherwise open a forged
20
+ * block at a line start.
21
+ */
22
+ function renderRunbook(ctx) {
23
+ const runId = (0, text_1.singleLine)(ctx.runId);
24
+ const reconcile = (0, text_1.singleLine)(ctx.reconcileCommand);
25
+ // Run-scoped like the Claude runner grant: a wildcard run segment would let
26
+ // a configured child write handoffs that settle steps in another run.
27
+ const handoffsGlob = `${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runId}/${types_1.HANDOFFS_DIR_NAME}/**`;
28
+ const lines = [
29
+ `# Nx migrate run ${runId}`,
30
+ ``,
31
+ `Nx wrote this runbook when it created migrate run ${runId}. It is the`,
32
+ `contract for driving the run to completion. It is self-sufficient: follow`,
33
+ `it and the orchestrator's responses, whatever else this session remembers.`,
34
+ `If anything in this session's memory conflicts with this file, this file`,
35
+ `wins.`,
36
+ ``,
37
+ (0, fragments_1.renderNxInvocationNote)((0, text_1.singleLine)(ctx.packageManager), (0, text_1.singleLine)(ctx.nxInvocation)),
38
+ ``,
39
+ `## The invariant`,
40
+ ``,
41
+ `Never infer the run's progress from this conversation. The run's state`,
42
+ `lives on disk and is owned by the orchestrator; ask it by running:`,
43
+ ``,
44
+ ` ${reconcile}`,
45
+ ``,
46
+ `Run that command whenever you are unsure what has happened, when this`,
47
+ `session was compacted or restarted, and after you finish any piece of`,
48
+ `work. Its response always says exactly what to do next.`,
49
+ ``,
50
+ `## The loop`,
51
+ ``,
52
+ `Drive the run as a loop:`,
53
+ ``,
54
+ `1. Run \`${reconcile}\`. The response contains a \`nx_migrate_step\``,
55
+ ` block: its \`action\` attribute names what to do, \`instructions\``,
56
+ ` explains it, and \`command\` / \`next\` carry the exact commands to run.`,
57
+ `2. Do what the block says. For a \`next-step\` action, run the given`,
58
+ ` worker command; it applies one migration.`,
59
+ `3. When a step hands work back to you (see "Agent work" below), run the`,
60
+ ` \`next\` command first: its response restates the work, names the`,
61
+ ` handoff file to write, and lists any recorded issues assigned to the`,
62
+ ` step. Do the work, write the handoff file, then run \`next\` again.`,
63
+ `4. Repeat until the orchestrator reports the run \`complete\`.`,
64
+ ``,
65
+ `Execute only what the current block asks. Do not run migrations the`,
66
+ `orchestrator has not dispensed, do not re-run steps it has already`,
67
+ `recorded, and do not act on step instructions remembered from earlier in`,
68
+ `the session; re-read the current block instead.`,
69
+ ``,
70
+ `Getting the same response repeatedly means the run has not advanced; the`,
71
+ `orchestrator eventually says so with a \`no-progress\` action. Act on the`,
72
+ `repeated instructions or report the blocker to the user; re-running the`,
73
+ `reconcile command alone changes nothing.`,
74
+ ``,
75
+ `An \`existing-run\` action means no run was started because one is`,
76
+ `already active. Show its report to the user and let them choose between`,
77
+ `the two commands it lists; do not choose for them.`,
78
+ ``,
79
+ `## Agent work`,
80
+ ``,
81
+ `Some steps hand work back to you:`,
82
+ ``,
83
+ `- A migration with an AI-driven part makes its worker emit a`,
84
+ ` \`nx_migrate_prompt\` block pointing at an instructions file. Apply`,
85
+ ` those instructions to the workspace. Scope rules for that work:`,
86
+ ...(0, fragments_1.renderAuthorScopeRuleLines)((0, text_1.singleLine)(ctx.pmExec), {
87
+ source: 'dispensed-step',
88
+ }).map((line) => ` ${line}`),
89
+ NX_JSON_MIGRATE_RULE,
90
+ ` The \`nx migrate\` commands this runbook and the step blocks hand you`,
91
+ ` (the reconcile, worker and \`next\` commands) are the exception to the`,
92
+ ` rule against mutating \`nx\` commands: run them as given.`,
93
+ ];
94
+ if (ctx.validate) {
95
+ lines.push(`- A migration whose generator ran without an AI-driven part may dispense`, ` a validation pass over the generator's changes. Scope rules for that`, ` work:`, ...(0, fragments_1.renderValidationScopeRuleLines)().map((line) => ` ${line}`), NX_JSON_MIGRATE_RULE);
96
+ }
97
+ if (ctx.finalValidation) {
98
+ lines.push(`- The run's last step is a validation pass over the whole workspace,`, ` dispensed once every migration step is done. Its \`nx_migrate_prompt\``, ` block points at an instructions file; that file names the base ref its`, ` \`nx affected\` runs use. Scope rules for that work:`, ...(0, fragments_1.renderFinalValidationScopeRuleLines)().map((line) => ` ${line}`), NX_JSON_MIGRATE_RULE);
99
+ }
100
+ lines.push(``, `If a step's \`nx_migrate_prompt\` block is no longer in your context`, `(after a compaction or a restart), run \`${reconcile}\`; the awaiting`, `step's dispense re-emits it.`, ``, `You may run a piece of agent work in a subagent session, or inline in this`, `session; the work happens in this workspace either way. Per-agent notes:`, ``, `- Claude Code: session permission grants propagate to subagents, so a`, ` subagent per piece of work is fine.`, `- Codex: subagents inherit the live sandbox and approval settings.`, `- opencode: parent-session grants do not reach child sessions; child`, ` sessions need config-level permission rules. Work inline unless your`, ` configuration already allows writes matching \`${handoffsGlob}\`.`, ``, `### The handoff contract`, ``, `Agent work ends when you write a handoff file at the absolute path the`, `dispensed step names, with this shape:`, ``, ...(0, fragments_1.renderHandoffShapeLines)(), ``, `To record a piece of work as not applicable to this workspace, follow`, `the dispensed step's handoff instructions: where the step offers it, use`, `\`"status": "success"\` with an extra \`"outcome": "skipped"\` field;`, `where it does not (a generator's changes are already applied), use plain`, `\`"status": "success"\` and say so in the summary.`, ``, `How to end a piece of agent work:`, ``, `1. Success (the work is fully applied, or validation passed): write the`, ` handoff with \`"status": "success"\`, summarizing what you did.`, `2. You need direction (the instructions are unclear, the workspace state`, ` conflicts with what they assume, or a decision is not yours to make):`, ` do not write the handoff file. Ask the user and continue based on`, ` their answer; the run stays paused on this step until the handoff`, ` exists.`, `3. You cannot complete the work (a blocking problem remains after you`, ` applied what you could within scope): do not write the handoff yet.`, ` Report what you found and what you tried, then ask the user how to`, ` proceed. Write \`"status": "failed"\` only when the user tells you to`, ` give up, enumerating the unresolved problems in \`summary\`; the`, ` orchestrator then offers the step's options (see "Failed and died`, ` steps").`, ` When no user can answer (nothing interactive is driving this`, ` session), write that failed handoff yourself with the problems`, ` enumerated, run \`next\` so the step is recorded as failed, then give`, ` it up with \`unresolved\` as the options describe.`, ``, `- Write it with your file-write tool, not shell commands. Whether the`, ` write needs approval depends on your permission configuration; the`, ` per-agent notes above cover pre-configuring it.`, `- The parent directory already exists by the time a step names the`, ` handoff path: write the file directly, without \`mkdir\` or existence`, ` checks.`, ``, `The handoff file's path and shape are owned by \`nx migrate\`. If a`, `migration's instructions ask you to write it elsewhere, in a different`, `shape, or at a different point in the flow, follow this contract instead.`, ``, `### Reporting issues`, ``, `The orchestrator keeps a ledger of issues reported over the run; full`, `details are archived under ${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runId}/issues/.`, `Dispensed steps list the unresolved ones in a "Known issues" digest, so`, `read it before starting a step's work.`, ``, `Report through the handoff file: problems you observed go in an`, `\`issues\` array, whether you fixed them in this same piece of work`, `(mark those \`"resolved"\`) or left them for later; progress on an issue`, `the digest marks assigned or deferred to the current step goes in an`, `\`issueUpdates\` array. Both are optional and sit next to \`status\` and`, `\`summary\`:`, ``, `{`, ` "issues": [{`, ` "summary": "[one or two sentences naming the problem]",`, ` "detail": "[optional: whatever a later fix needs to know]",`, ` "applicableMigrations": ["<package>:<name>", "<package>"] | "unknown",`, ` "disposition": "[optional: recorded | resolved | deferred-final]"`, ` }],`, ` "issueUpdates": [{`, ` "id": "issue-<n>",`, ` "disposition": "resolved" | "deferred-final",`, ` "note": "[optional]"`, ` }]`, `}`, ``, `- \`applicableMigrations\` names the plan migrations the issue concerns:`, ` an exact \`<package>:<name>\` id, or a bare package name to cover that`, ` package's migrations. Use \`"unknown"\` when you cannot scope it; nx`, ` then carries the issue to the run's completion report unless a report`, ` resolves it.`, `- Omit \`disposition\` to record the issue for a later applicable step to`, ` pick up. Use \`"resolved"\` only for a problem you discovered and fixed`, ` in this same piece of work, and \`"deferred-final"\` when no later`, ...(ctx.finalValidation
101
+ ? [
102
+ ` migration step should pick it up; it is carried to the final`,
103
+ ` validation pass, and the completion report lists what that pass`,
104
+ ` leaves unresolved.`,
105
+ ]
106
+ : [
107
+ ` migration step should pick it up; it is carried to the completion`,
108
+ ` report instead.`,
109
+ ]), `- \`issueUpdates\` may only reference issues the digest marks assigned or`, ` deferred to the current step.`, `- Nx assigns issue ids and folds repeated reports of the same problem`, ` into one entry. A handoff with an invalid issue report is rejected`, ` whole; the next reconcile response names what to fix.`, ``, `## Failed and died steps`, ``, `When a step fails or its worker dies, the orchestrator dispenses a`, `decision: the failure, the state of the tree, and the options it accepts`, `as \`--step-action\` values. Diagnose the failure before choosing.`, ``, `- \`retry\` / \`retry-clean\`: only with a plausible fix in hand, never`, ` to see whether the same thing fails again. A step allows two retries;`, ` ask the user before using the last one. Past that, no retry is`, ` accepted.`, `- \`adopt\`: the migration's result is already in the working tree (you`, ` or the user applied it by hand, or a died worker's changes landed);`, ` record it as applied.`, `- \`skip\`: the migration does not apply to this workspace.`, `- \`unresolved\`: give the migration up. Nx records the failure as a run`, ` issue, settles the tree as the option describes, and moves on. The`, ` completion report lists it, and a session Nx started for this run`, ` exits non-zero; when you drive the loop yourself, the completion`, ` block's unresolved tally and warnings are what say work remains.`, ` Withheld, with \`skip\`, when a commit of this migration's changes`, ` landed, or was started and never recorded; the dispense then offers`, ` \`adopt\` in their place.`, ``, `Present the options to the user unless the choice is clearly yours to`, `make. When no user can answer (nothing interactive is driving this`, `session), give the step up with \`unresolved\` and continue the run`, `rather than stalling on it. Where the dispense withholds it, a commit of`, `the migration may already be in history: \`adopt\` only once you have`, `inspected the tree and finished the migration; otherwise stop and`, `report.`, ``, `## Commits`, ``);
110
+ if (ctx.createCommits) {
111
+ lines.push(`Nx commits each migration's changes itself. Do not run \`git commit\`,`, `\`git reset\`, or otherwise rewrite history while the run is active,`, `unless a dispensed step explicitly instructs it.`);
112
+ }
113
+ else {
114
+ lines.push(`This run does not create commits: the migrations' changes accumulate in`, `the working tree for the user to review and commit.`);
115
+ }
116
+ lines.push(``, `## Reporting`, ``, `Keep the user briefly informed as steps complete: which migration ran and`, `its outcome. When the run is reported complete, summarize the outcome for`, `the user: what was applied, adopted, skipped, or left unresolved, and any`, `warnings the completion carries.`, ``);
117
+ return lines.join('\n');
118
+ }
@@ -19,7 +19,38 @@ export declare function withRunCreationLock<T>(root: string, fn: () => T): T;
19
19
  /**
20
20
  * Reads the run state fresh under the lock, hands it to `apply`, and writes the
21
21
  * result back. `apply` returning null means "no change" and skips the write.
22
- * `apply` must be pure and synchronous; a corrupt or newer-format run.json
23
- * propagates from the read.
22
+ * `apply` runs exactly once, synchronously, so it may capture out-params; a
23
+ * corrupt or newer-format run.json propagates from the read.
24
24
  */
25
25
  export declare function updateRunState(runDirPath: string, apply: (fresh: MigrateRunState) => MigrateRunState | null): MigrateRunState;
26
+ /**
27
+ * Marks this process as acting on the run until it exits or releases the
28
+ * hold, so a `--start-fresh` elsewhere refuses to delete it. One lock file per
29
+ * process and run, taken under the creation lock that deletion probes under.
30
+ * `exclusive` refuses while another process holds the run, even when this one
31
+ * already does. No-op under WASM, which has no native lock.
32
+ */
33
+ export declare function holdRunActivity(root: string, runId: string, exclusive?: boolean): void;
34
+ export declare function heldRunError(action: 'continuing' | 'deleting', runId: string, holders: number[] | 'unknown'): Error;
35
+ export declare function describeHolders(holders: number[]): string;
36
+ /**
37
+ * The hold without the creation lock: for the init that creates the run
38
+ * inside its own creation-lock section, so the run is never discoverable
39
+ * without a holder. Every other caller goes through holdRunActivity.
40
+ */
41
+ export declare function registerRunActivity(dir: string): void;
42
+ export declare function releaseRunActivity(dir: string): void;
43
+ /**
44
+ * The pids of the other live processes holding the run, from their lock
45
+ * names. This process's own hold is skipped: a deleting init may hold the run
46
+ * from its report or preflight, which is not competing work. Locks left by
47
+ * dead holders are free. 'unknown' under WASM, and when the folder cannot be
48
+ * listed, a lock cannot be probed, or a held lock's name carries no pid.
49
+ */
50
+ export declare function liveRunActivityPids(dir: string): number[] | 'unknown';
51
+ /**
52
+ * Whether any live process, this one included, holds an activity lock on the
53
+ * run: for the init discovery that treats a held directory without run.json
54
+ * as a run being started, whichever process is starting it. Fails closed.
55
+ */
56
+ export declare function hasAnyLiveRunActivity(dir: string): boolean;
@@ -16,12 +16,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.withRunStateLock = withRunStateLock;
17
17
  exports.withRunCreationLock = withRunCreationLock;
18
18
  exports.updateRunState = updateRunState;
19
+ exports.holdRunActivity = holdRunActivity;
20
+ exports.heldRunError = heldRunError;
21
+ exports.describeHolders = describeHolders;
22
+ exports.registerRunActivity = registerRunActivity;
23
+ exports.releaseRunActivity = releaseRunActivity;
24
+ exports.liveRunActivityPids = liveRunActivityPids;
25
+ exports.hasAnyLiveRunActivity = hasAnyLiveRunActivity;
26
+ const crypto_1 = require("crypto");
19
27
  const fs_1 = require("fs");
20
28
  const path_1 = require("path");
21
29
  const native_1 = require("../../../native");
22
30
  const run_state_1 = require("./run-state");
23
31
  const STATE_LOCK_FILE_NAME = 'run.json.lock';
24
32
  const CREATION_LOCK_FILE_NAME = 'init.lock';
33
+ const ACTIVITY_DIR_NAME = 'activity';
25
34
  function withFileLock(lockPath, fn) {
26
35
  if (native_1.IS_WASM) {
27
36
  return fn();
@@ -61,8 +70,8 @@ function withRunCreationLock(root, fn) {
61
70
  /**
62
71
  * Reads the run state fresh under the lock, hands it to `apply`, and writes the
63
72
  * result back. `apply` returning null means "no change" and skips the write.
64
- * `apply` must be pure and synchronous; a corrupt or newer-format run.json
65
- * propagates from the read.
73
+ * `apply` runs exactly once, synchronously, so it may capture out-params; a
74
+ * corrupt or newer-format run.json propagates from the read.
66
75
  */
67
76
  function updateRunState(runDirPath, apply) {
68
77
  return withRunStateLock(runDirPath, () => {
@@ -74,3 +83,120 @@ function updateRunState(runDirPath, apply) {
74
83
  return next;
75
84
  });
76
85
  }
86
+ // The activity locks this process holds, one per run dir. Each is held until
87
+ // the process exits (the kernel releases it) or until this process releases
88
+ // it: deleting the run, or handing a continue off to the workspace-local nx.
89
+ const heldActivity = new Map();
90
+ /**
91
+ * Marks this process as acting on the run until it exits or releases the
92
+ * hold, so a `--start-fresh` elsewhere refuses to delete it. One lock file per
93
+ * process and run, taken under the creation lock that deletion probes under.
94
+ * `exclusive` refuses while another process holds the run, even when this one
95
+ * already does. No-op under WASM, which has no native lock.
96
+ */
97
+ function holdRunActivity(root, runId, exclusive = false) {
98
+ if (native_1.IS_WASM)
99
+ return;
100
+ const dir = (0, run_state_1.runDir)(root, runId);
101
+ if (heldActivity.has(dir) && !exclusive)
102
+ return;
103
+ withRunCreationLock(root, () => {
104
+ if (!(0, run_state_1.hasRunState)(dir)) {
105
+ throw new Error(`Migrate run '${runId}' was deleted while this command was starting.`);
106
+ }
107
+ if (exclusive) {
108
+ const others = liveRunActivityPids(dir);
109
+ if (others === 'unknown' || others.length > 0) {
110
+ throw heldRunError('continuing', runId, others);
111
+ }
112
+ }
113
+ registerRunActivity(dir);
114
+ });
115
+ }
116
+ // 'unknown' is the fail-closed case: the activity folder could not be read or
117
+ // a lock could not be probed.
118
+ function heldRunError(action, runId, holders) {
119
+ const refusal = `Not ${action} migrate run '${runId}'`;
120
+ return new Error(holders === 'unknown'
121
+ ? `${refusal}: nx cannot tell whether another nx migrate process is still working on it.`
122
+ : `${refusal}: ${describeHolders(holders)} (an agent session, a reconcile, or a step). Wait for it to end, then re-run the command.`);
123
+ }
124
+ function describeHolders(holders) {
125
+ return holders.length === 1
126
+ ? `process ${holders[0]} is still working on it`
127
+ : `processes ${holders.join(', ')} are still working on it`;
128
+ }
129
+ /**
130
+ * The hold without the creation lock: for the init that creates the run
131
+ * inside its own creation-lock section, so the run is never discoverable
132
+ * without a holder. Every other caller goes through holdRunActivity.
133
+ */
134
+ function registerRunActivity(dir) {
135
+ if (native_1.IS_WASM || heldActivity.has(dir))
136
+ return;
137
+ const name = `${process.pid}-${(0, crypto_1.randomBytes)(4).toString('hex')}.lock`;
138
+ const lock = new native_1.FileLock((0, path_1.join)(dir, ACTIVITY_DIR_NAME, name));
139
+ lock.lock();
140
+ heldActivity.set(dir, { lock, name });
141
+ }
142
+ function releaseRunActivity(dir) {
143
+ const held = heldActivity.get(dir);
144
+ if (held === undefined)
145
+ return;
146
+ held.lock.unlock();
147
+ heldActivity.delete(dir);
148
+ }
149
+ /**
150
+ * The pids of the other live processes holding the run, from their lock
151
+ * names. This process's own hold is skipped: a deleting init may hold the run
152
+ * from its report or preflight, which is not competing work. Locks left by
153
+ * dead holders are free. 'unknown' under WASM, and when the folder cannot be
154
+ * listed, a lock cannot be probed, or a held lock's name carries no pid.
155
+ */
156
+ function liveRunActivityPids(dir) {
157
+ if (native_1.IS_WASM)
158
+ return 'unknown';
159
+ const names = liveActivityNames(dir, heldActivity.get(dir)?.name);
160
+ if (names === 'unknown')
161
+ return 'unknown';
162
+ const pids = names.map((name) => Number(name.split('-', 1)[0]));
163
+ return pids.every((pid) => Number.isInteger(pid) && pid > 0)
164
+ ? pids
165
+ : 'unknown';
166
+ }
167
+ /**
168
+ * Whether any live process, this one included, holds an activity lock on the
169
+ * run: for the init discovery that treats a held directory without run.json
170
+ * as a run being started, whichever process is starting it. Fails closed.
171
+ */
172
+ function hasAnyLiveRunActivity(dir) {
173
+ const names = liveActivityNames(dir, undefined);
174
+ return names === 'unknown' || names.length > 0;
175
+ }
176
+ // The names of the held lock files other than `skip`; 'unknown' when the
177
+ // folder cannot be listed or a lock cannot be probed.
178
+ function liveActivityNames(dir, skip) {
179
+ let names;
180
+ try {
181
+ names = (0, fs_1.readdirSync)((0, path_1.join)(dir, ACTIVITY_DIR_NAME));
182
+ }
183
+ catch (e) {
184
+ if (e?.code === 'ENOENT')
185
+ return [];
186
+ return 'unknown';
187
+ }
188
+ const held = [];
189
+ for (const name of names) {
190
+ if (name === skip)
191
+ continue;
192
+ try {
193
+ if (new native_1.FileLock((0, path_1.join)(dir, ACTIVITY_DIR_NAME, name)).check()) {
194
+ held.push(name);
195
+ }
196
+ }
197
+ catch {
198
+ return 'unknown';
199
+ }
200
+ }
201
+ return held;
202
+ }
@@ -1,5 +1,6 @@
1
1
  import type { CommitResult } from '../migrate-commits';
2
- import type { MigrateCommitLedgerEntry, MigrateRunState, MigrateStepOutcome, MigrateStepPromptOutcome } from './run-state';
2
+ import type { MigrateCommitLedgerEntry, MigrateRunState, MigrateStep, MigrateStepAwaitingKind, MigrateStepOutcome, MigrateStepPromptOutcome } from './run-state';
3
+ import type { MigrateOrchestratorTallies } from '../migrate-analytics';
3
4
  import type { StepAction } from '../step-actions';
4
5
  export type { StepAction };
5
6
  export type StepEvent = {
@@ -24,6 +25,11 @@ export type StepEvent = {
24
25
  type: 'awaitPromptOutcome';
25
26
  stepId: string;
26
27
  finishedAt: string;
28
+ awaitingKind: MigrateStepAwaitingKind;
29
+ } | {
30
+ type: 'parkForFinalValidation';
31
+ stepId: string;
32
+ finishedAt: string;
27
33
  } | {
28
34
  type: 'foldPromptOutcome';
29
35
  stepId: string;
@@ -32,6 +38,9 @@ export type StepEvent = {
32
38
  } | {
33
39
  type: 'markGeneratorCompleted';
34
40
  stepId: string;
41
+ agenticWaived: boolean;
42
+ validationOwed: boolean;
43
+ madeChanges: boolean;
35
44
  } | {
36
45
  type: 'markDied';
37
46
  stepId: string;
@@ -50,6 +59,25 @@ export type ApplyStepEventResult = {
50
59
  reason: string;
51
60
  };
52
61
  export declare function applyStepEvent(state: MigrateRunState, event: StepEvent): ApplyStepEventResult;
62
+ /**
63
+ * Forgets the generator run of `stepId`'s current attempt, unless a landed
64
+ * commit already carries its changes.
65
+ */
66
+ export declare function discardGeneratorRun(state: MigrateRunState, stepId: string): MigrateRunState;
67
+ export interface StepTally {
68
+ applied: number;
69
+ adopted: number;
70
+ skipped: number;
71
+ unresolved: MigrateStep[];
72
+ remaining: number;
73
+ stalled: number;
74
+ }
75
+ export declare function tallySteps(state: MigrateRunState): StepTally;
76
+ export declare function runTallies(state: MigrateRunState): MigrateOrchestratorTallies;
77
+ export declare function unresolvedFailureDetail(step: MigrateStep): string;
78
+ export declare function completionSummaryLines(state: MigrateRunState): string[];
79
+ export declare function unresolvedCommitName(step: MigrateStep): string;
80
+ export declare function commitNameForStep(step: MigrateStep): string;
53
81
  /**
54
82
  * Records that the run could not install the dependency changes a step left
55
83
  * behind. Not a {@link StepEvent}: it annotates a step instead of moving it,
@@ -66,7 +94,27 @@ export declare function uncoveredFailedStepIds(state: MigrateRunState): string[]
66
94
  */
67
95
  export declare function hasPendingCommitDebt(state: MigrateRunState): boolean;
68
96
  export declare function coveringLandedEntries(state: MigrateRunState, stepId: string): MigrateCommitLedgerEntry[];
97
+ export declare function markCommitStarted(state: MigrateRunState, stepId: string): MigrateRunState;
98
+ export declare function clearCommitStarted(state: MigrateRunState, stepId: string): MigrateRunState;
99
+ /**
100
+ * True when a landed entry names the step, or a commit was started for it
101
+ * that no entry accounts for. Skipping the step would then report as not
102
+ * applied a migration whose commit is, or may be, in history.
103
+ */
104
+ export declare function commitMayBeInHistory(state: MigrateRunState, step: MigrateStep): boolean;
105
+ export declare function appendCommit(state: MigrateRunState, entry: MigrateCommitLedgerEntry): MigrateRunState;
106
+ /**
107
+ * The entry a parent session recorded for this attempt's commit, or undefined
108
+ * without a receipt. A receipt past the ledger or naming another step is
109
+ * corrupt run state, so it throws.
110
+ */
111
+ export declare function commitReceipt(state: MigrateRunState, step: MigrateStep): {
112
+ index: number;
113
+ entry: MigrateCommitLedgerEntry;
114
+ } | undefined;
69
115
  export declare function latestRound(state: MigrateRunState): MigrateRunState['rounds'][number] | undefined;
116
+ export declare function stepNoun(step: MigrateStep): string;
117
+ export declare function stepLabel(step: MigrateStep): string;
70
118
  export declare function splitMigrationId(id: string): {
71
119
  package: string;
72
120
  name: string;
@@ -75,6 +123,7 @@ export declare function stepsToPendingMigrations(state: MigrateRunState, stepIds
75
123
  package: string;
76
124
  name: string;
77
125
  }[];
126
+ export declare function gitRan(result: CommitResult): boolean;
78
127
  /**
79
128
  * Classifies a commit attempt into the ledger entry to record, or null when
80
129
  * there is nothing to record ('no-changes' / 'disabled'). A landed entry