@ohos-ports/nx 23.3.0-beta.2 → 24.0.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. package/README.md +3 -6
  2. package/dist/bin/nx.js +2 -2
  3. package/dist/bin/post-install.js +5 -3
  4. package/dist/nx-cloud-internals.d.ts +1 -0
  5. package/dist/nx-cloud-internals.js +7 -1
  6. package/dist/src/adapter/ngcli-adapter.js +2 -2
  7. package/dist/src/ai/clone-ai-config-repo.js +49 -12
  8. package/dist/src/command-line/add/add.d.ts +2 -0
  9. package/dist/src/command-line/add/add.js +23 -5
  10. package/dist/src/command-line/affected/affected.js +2 -2
  11. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +0 -12
  12. package/dist/src/command-line/graph/graph.js +38 -10
  13. package/dist/src/command-line/init/command-object.js +0 -12
  14. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +21 -62
  15. package/dist/src/command-line/init/init-v2.js +0 -2
  16. package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +1 -1
  17. package/dist/src/command-line/migrate/agentic/close-agent-session.js +4 -3
  18. package/dist/src/command-line/migrate/agentic/definitions.d.ts +1 -3
  19. package/dist/src/command-line/migrate/agentic/definitions.js +5 -97
  20. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +7 -45
  21. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +9 -51
  22. package/dist/src/command-line/migrate/agentic/handoff.d.ts +1 -43
  23. package/dist/src/command-line/migrate/agentic/handoff.js +3 -119
  24. package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +0 -21
  25. package/dist/src/command-line/migrate/agentic/instruction-files.js +6 -27
  26. package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +19 -1
  27. package/dist/src/command-line/migrate/agentic/master/run-master-session.js +88 -49
  28. package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +1 -0
  29. package/dist/src/command-line/migrate/agentic/master/spawn-master.js +86 -24
  30. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +2 -2
  31. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +2 -2
  32. package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +1 -12
  33. package/dist/src/command-line/migrate/agentic/prompts/fragments.js +8 -17
  34. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +0 -15
  35. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +3 -100
  36. package/dist/src/command-line/migrate/agentic/select.d.ts +12 -6
  37. package/dist/src/command-line/migrate/agentic/select.js +38 -8
  38. package/dist/src/command-line/migrate/agentic/types.d.ts +9 -68
  39. package/dist/src/command-line/migrate/agentic/types.js +6 -8
  40. package/dist/src/command-line/migrate/command-object.js +6 -10
  41. package/dist/src/command-line/migrate/execute-migration.d.ts +6 -6
  42. package/dist/src/command-line/migrate/execute-migration.js +25 -15
  43. package/dist/src/command-line/migrate/migrate-analytics.d.ts +18 -1
  44. package/dist/src/command-line/migrate/migrate-analytics.js +38 -0
  45. package/dist/src/command-line/migrate/migrate-commits.d.ts +29 -17
  46. package/dist/src/command-line/migrate/migrate-commits.js +86 -32
  47. package/dist/src/command-line/migrate/migrate-config.d.ts +6 -6
  48. package/dist/src/command-line/migrate/migrate-config.js +12 -6
  49. package/dist/src/command-line/migrate/migrate-output.d.ts +1 -6
  50. package/dist/src/command-line/migrate/migrate-output.js +1 -10
  51. package/dist/src/command-line/migrate/migrate.d.ts +6 -30
  52. package/dist/src/command-line/migrate/migrate.js +257 -255
  53. package/dist/src/command-line/migrate/resolve-package-version.d.ts +2 -4
  54. package/dist/src/command-line/migrate/resolve-package-version.js +2 -35
  55. package/dist/src/command-line/migrate/run/agent-output.d.ts +2 -0
  56. package/dist/src/command-line/migrate/run/agent-output.js +9 -0
  57. package/dist/src/command-line/migrate/run/broker.d.ts +14 -5
  58. package/dist/src/command-line/migrate/run/broker.js +69 -21
  59. package/dist/src/command-line/migrate/run/clean-retry.js +4 -2
  60. package/dist/src/command-line/migrate/run/existing-run-report.d.ts +1 -1
  61. package/dist/src/command-line/migrate/run/existing-run-report.js +7 -5
  62. package/dist/src/command-line/migrate/run/give-up.d.ts +4 -3
  63. package/dist/src/command-line/migrate/run/give-up.js +8 -5
  64. package/dist/src/command-line/migrate/run/index.d.ts +7 -5
  65. package/dist/src/command-line/migrate/run/index.js +16 -1
  66. package/dist/src/command-line/migrate/run/issues.js +7 -2
  67. package/dist/src/command-line/migrate/run/orchestrator.d.ts +61 -4
  68. package/dist/src/command-line/migrate/run/orchestrator.js +397 -133
  69. package/dist/src/command-line/migrate/run/run-state.d.ts +17 -1
  70. package/dist/src/command-line/migrate/run/run-state.js +41 -2
  71. package/dist/src/command-line/migrate/run/runbook.d.ts +1 -0
  72. package/dist/src/command-line/migrate/run/runbook.js +115 -18
  73. package/dist/src/command-line/migrate/run/state-lock.d.ts +29 -4
  74. package/dist/src/command-line/migrate/run/state-lock.js +102 -10
  75. package/dist/src/command-line/migrate/run/state-machine.js +4 -1
  76. package/dist/src/command-line/migrate/run/util.d.ts +7 -2
  77. package/dist/src/command-line/migrate/run/util.js +30 -3
  78. package/dist/src/command-line/migrate/run/worker.d.ts +1 -1
  79. package/dist/src/command-line/migrate/run/worker.js +252 -250
  80. package/dist/src/command-line/migrate/sort-migrations.d.ts +1 -7
  81. package/dist/src/command-line/migrate/sort-migrations.js +1 -12
  82. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +17 -12
  83. package/dist/src/command-line/release/changelog.js +9 -6
  84. package/dist/src/command-line/release/config/config.d.ts +1 -0
  85. package/dist/src/command-line/release/config/config.js +48 -9
  86. package/dist/src/command-line/release/release.js +2 -2
  87. package/dist/src/command-line/release/utils/git.js +8 -7
  88. package/dist/src/command-line/release/utils/interpolate-release-config.d.ts +6 -0
  89. package/dist/src/command-line/release/utils/interpolate-release-config.js +39 -0
  90. package/dist/src/command-line/release/utils/release-graph.d.ts +5 -0
  91. package/dist/src/command-line/release/utils/release-graph.js +1 -0
  92. package/dist/src/command-line/release/utils/remote-release-clients/github.js +5 -6
  93. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +5 -6
  94. package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +2 -2
  95. package/dist/src/command-line/release/utils/shared.js +10 -10
  96. package/dist/src/command-line/release/utils/version-plan-utils.d.ts +3 -12
  97. package/dist/src/command-line/release/utils/version-plan-utils.js +33 -55
  98. package/dist/src/command-line/release/version/version-actions.js +2 -1
  99. package/dist/src/command-line/release/version.js +5 -2
  100. package/dist/src/command-line/reset/reset.js +58 -62
  101. package/dist/src/command-line/run/executor-utils.js +1 -0
  102. package/dist/src/command-line/run/run-one.d.ts +20 -1
  103. package/dist/src/command-line/run/run-one.js +153 -5
  104. package/dist/src/command-line/run/run.js +2 -1
  105. package/dist/src/command-line/show/projects.js +5 -3
  106. package/dist/src/command-line/show/show-target/info.d.ts +10 -1
  107. package/dist/src/command-line/show/show-target/info.js +100 -15
  108. package/dist/src/command-line/show/show-target/inputs.js +10 -2
  109. package/dist/src/command-line/show/show-target/utils.js +1 -0
  110. package/dist/src/command-line/watch/command-object.js +3 -22
  111. package/dist/src/command-line/watch/watch.d.ts +0 -7
  112. package/dist/src/command-line/watch/watch.js +1 -1
  113. package/dist/src/command-line/yargs-utils/shared-options.js +1 -1
  114. package/dist/src/config/misc-interfaces.d.ts +18 -0
  115. package/dist/src/config/nx-json.d.ts +22 -11
  116. package/dist/src/config/task-graph.d.ts +1 -1
  117. package/dist/src/config/workspace-json-project-json.d.ts +88 -0
  118. package/dist/src/core/graph/main.js +1 -1
  119. package/dist/src/core/graph/runtime.js +1 -1
  120. package/dist/src/core/graph/styles.css +1 -1
  121. package/dist/src/core/graph/styles.js +1 -1
  122. package/dist/src/daemon/client/client.d.ts +15 -0
  123. package/dist/src/daemon/client/client.js +181 -71
  124. package/dist/src/daemon/client/daemon-socket-messenger.d.ts +1 -1
  125. package/dist/src/daemon/client/daemon-socket-messenger.js +2 -2
  126. package/dist/src/daemon/server/client-socket-context.js +1 -1
  127. package/dist/src/daemon/server/handle-process-in-background.js +21 -9
  128. package/dist/src/daemon/server/handle-select-affected-tasks.d.ts +2 -1
  129. package/dist/src/daemon/server/handle-select-affected-tasks.js +21 -13
  130. package/dist/src/daemon/server/native-js-loader.d.ts +1 -0
  131. package/dist/src/daemon/server/native-js-loader.js +21 -0
  132. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +4 -8
  133. package/dist/src/daemon/server/server.d.ts +2 -1
  134. package/dist/src/daemon/server/server.js +17 -4
  135. package/dist/src/daemon/server/shutdown-utils.js +0 -3
  136. package/dist/src/daemon/server/start.d.ts +1 -0
  137. package/dist/src/daemon/server/start.js +2 -0
  138. package/dist/src/daemon/socket-utils.d.ts +11 -9
  139. package/dist/src/daemon/socket-utils.js +31 -61
  140. package/dist/src/daemon/tmp-dir.d.ts +19 -14
  141. package/dist/src/daemon/tmp-dir.js +142 -354
  142. package/dist/src/devkit-exports.d.ts +9 -1
  143. package/dist/src/devkit-exports.js +12 -1
  144. package/dist/src/devkit-internals.d.ts +6 -5
  145. package/dist/src/devkit-internals.js +13 -4
  146. package/dist/src/executors/run-commands/run-commands.impl.d.ts +4 -2
  147. package/dist/src/executors/run-commands/run-commands.impl.js +53 -27
  148. package/dist/src/executors/run-commands/running-tasks.d.ts +13 -4
  149. package/dist/src/executors/run-commands/running-tasks.js +148 -95
  150. package/dist/src/executors/run-commands/schema.json +1 -1
  151. package/dist/src/hasher/check-task-files.js +5 -8
  152. package/dist/src/hasher/file-hasher.js +9 -7
  153. package/dist/src/hasher/hash-task.js +4 -0
  154. package/dist/src/hasher/native-task-hasher-impl.js +3 -1
  155. package/dist/src/hasher/task-hasher.d.ts +2 -0
  156. package/dist/src/hasher/task-hasher.js +4 -1
  157. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +1 -2
  158. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +6 -11
  159. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +2 -2
  160. package/dist/src/migrations/update-24-0-0/enable-legacy-affected.d.ts +4 -0
  161. package/dist/src/migrations/update-24-0-0/enable-legacy-affected.js +15 -0
  162. package/dist/src/migrations/update-24-0-0/enable-legacy-affected.md +30 -0
  163. package/dist/src/migrations/update-24-0-0/find-custom-hashers.d.ts +3 -0
  164. package/dist/src/migrations/update-24-0-0/find-custom-hashers.js +100 -0
  165. package/dist/src/migrations/update-24-0-0/find-custom-hashers.md +63 -0
  166. package/dist/src/migrations/update-24-0-0/move-custom-hashers-to-inputs.md +146 -0
  167. package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.d.ts +3 -0
  168. package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.js +130 -0
  169. package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.md +62 -0
  170. package/dist/src/native/assert-supported-platform.js +1 -1
  171. package/dist/src/native/index.d.ts +238 -18
  172. package/dist/src/native/index.js +6 -1
  173. package/dist/src/native/native-bindings.js +15 -6
  174. package/dist/src/native/nx.openharmony-arm64.node +0 -0
  175. package/dist/src/native/nx.wasi-browser.js +1 -0
  176. package/dist/src/native/nx.wasi.cjs +1 -0
  177. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  178. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  179. package/dist/src/nx-cloud/update-manager.d.ts +14 -0
  180. package/dist/src/nx-cloud/update-manager.js +237 -50
  181. package/dist/src/plugins/js/lock-file/pnpm-parser.js +3 -4
  182. package/dist/src/plugins/js/lock-file/pruned-output.d.ts +2 -2
  183. package/dist/src/plugins/js/lock-file/pruned-output.js +4 -4
  184. package/dist/src/plugins/js/utils/register.js +9 -4
  185. package/dist/src/project-graph/affected/affected-tasks.d.ts +9 -6
  186. package/dist/src/project-graph/affected/affected-tasks.js +31 -7
  187. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +7 -0
  188. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +49 -6
  189. package/dist/src/project-graph/utils/project-configuration/target-merging.js +1 -1
  190. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +12 -133
  191. package/dist/src/project-graph/utils/project-configuration-utils.js +2 -2
  192. package/dist/src/project-graph/utils/retrieve-workspace-files.js +27 -6
  193. package/dist/src/tasks-runner/create-task-graph.d.ts +8 -7
  194. package/dist/src/tasks-runner/create-task-graph.js +50 -27
  195. package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
  196. package/dist/src/tasks-runner/init-tasks-runner.js +116 -59
  197. package/dist/src/tasks-runner/life-cycle.d.ts +4 -1
  198. package/dist/src/tasks-runner/life-cycle.js +7 -0
  199. package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +5 -2
  200. package/dist/src/tasks-runner/life-cycles/performance-analysis.js +13 -7
  201. package/dist/src/tasks-runner/life-cycles/performance-life-cycle.d.ts +4 -3
  202. package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +9 -2
  203. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +5 -2
  204. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +4 -1
  205. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +5 -1
  206. package/dist/src/tasks-runner/pseudo-ipc.d.ts +1 -0
  207. package/dist/src/tasks-runner/pseudo-ipc.js +4 -0
  208. package/dist/src/tasks-runner/pseudo-terminal.d.ts +1 -1
  209. package/dist/src/tasks-runner/pseudo-terminal.js +2 -2
  210. package/dist/src/tasks-runner/readiness/executor-ready-signal.d.ts +7 -0
  211. package/dist/src/tasks-runner/readiness/executor-ready-signal.js +43 -0
  212. package/dist/src/tasks-runner/readiness/probes.d.ts +14 -0
  213. package/dist/src/tasks-runner/readiness/probes.js +101 -0
  214. package/dist/src/tasks-runner/readiness/ready-signal-server.d.ts +18 -0
  215. package/dist/src/tasks-runner/readiness/ready-signal-server.js +72 -0
  216. package/dist/src/tasks-runner/readiness/ready-signal.d.ts +33 -0
  217. package/dist/src/tasks-runner/readiness/ready-signal.js +92 -0
  218. package/dist/src/tasks-runner/readiness/ready-when.d.ts +84 -0
  219. package/dist/src/tasks-runner/readiness/ready-when.js +371 -0
  220. package/dist/src/tasks-runner/readiness/startup-host.d.ts +1 -0
  221. package/dist/src/tasks-runner/readiness/startup-host.js +32 -0
  222. package/dist/src/tasks-runner/run-command.d.ts +6 -2
  223. package/dist/src/tasks-runner/run-command.js +21 -31
  224. package/dist/src/tasks-runner/run-outcome.d.ts +16 -0
  225. package/dist/src/tasks-runner/run-outcome.js +39 -0
  226. package/dist/src/tasks-runner/running-tasks/batch-process.js +6 -0
  227. package/dist/src/tasks-runner/running-tasks/node-child-process.js +5 -4
  228. package/dist/src/tasks-runner/running-tasks/running-task.d.ts +1 -1
  229. package/dist/src/tasks-runner/task-env.d.ts +10 -0
  230. package/dist/src/tasks-runner/task-env.js +37 -5
  231. package/dist/src/tasks-runner/task-graph-utils.d.ts +9 -6
  232. package/dist/src/tasks-runner/task-graph-utils.js +17 -12
  233. package/dist/src/tasks-runner/task-orchestrator.d.ts +62 -18
  234. package/dist/src/tasks-runner/task-orchestrator.js +750 -150
  235. package/dist/src/tasks-runner/tasks-runner.d.ts +1 -1
  236. package/dist/src/tasks-runner/tasks-schedule.d.ts +18 -1
  237. package/dist/src/tasks-runner/tasks-schedule.js +63 -6
  238. package/dist/src/tasks-runner/tokens.d.ts +54 -0
  239. package/dist/src/tasks-runner/tokens.js +161 -0
  240. package/dist/src/tasks-runner/utils.d.ts +35 -6
  241. package/dist/src/tasks-runner/utils.js +149 -68
  242. package/dist/src/ultracache/ci-status.d.ts +24 -0
  243. package/dist/src/ultracache/ci-status.js +87 -0
  244. package/dist/src/ultracache/config.d.ts +3 -3
  245. package/dist/src/ultracache/config.js +4 -4
  246. package/dist/src/ultracache/fetch.d.ts +2 -0
  247. package/dist/src/ultracache/fetch.js +1 -0
  248. package/dist/src/ultracache/overrides.js +4 -0
  249. package/dist/src/utils/acknowledge-build-scripts.d.ts +34 -1
  250. package/dist/src/utils/acknowledge-build-scripts.js +171 -32
  251. package/dist/src/utils/child-process.js +2 -1
  252. package/dist/src/utils/find-matching-projects.js +9 -6
  253. package/dist/src/utils/git-utils.d.ts +12 -5
  254. package/dist/src/utils/git-utils.js +69 -11
  255. package/dist/src/utils/long-running-target.d.ts +1 -3
  256. package/dist/src/utils/long-running-target.js +1 -3
  257. package/dist/src/utils/output.d.ts +4 -3
  258. package/dist/src/utils/output.js +4 -3
  259. package/dist/src/utils/owned-private-dir.d.ts +1 -17
  260. package/dist/src/utils/owned-private-dir.js +10 -62
  261. package/dist/src/utils/package-manager.d.ts +8 -0
  262. package/dist/src/utils/package-manager.js +65 -8
  263. package/dist/src/utils/perf-hooks.d.ts +1 -0
  264. package/dist/src/utils/plugins/core-plugins.js +5 -1
  265. package/dist/src/utils/progress-topics.d.ts +1 -0
  266. package/dist/src/utils/progress-topics.js +1 -0
  267. package/dist/src/utils/safe-spawn.js +1 -5
  268. package/dist/src/utils/shell-quoting.d.ts +8 -1
  269. package/dist/src/utils/shell-quoting.js +12 -1
  270. package/dist/src/utils/spawn-without-terminal.d.ts +27 -0
  271. package/dist/src/utils/spawn-without-terminal.js +110 -0
  272. package/dist/src/utils/string-similarity.d.ts +38 -0
  273. package/dist/src/utils/string-similarity.js +108 -0
  274. package/migrations.json +20 -6
  275. package/package.json +15 -24
  276. package/schemas/migrations-schema.json +11 -0
  277. package/schemas/nx-schema.json +133 -11
  278. package/schemas/project-schema.json +114 -4
  279. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +0 -56
  280. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +0 -67
  281. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +0 -49
  282. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +0 -53
  283. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +0 -26
  284. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +0 -27
  285. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +0 -70
  286. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +0 -113
  287. package/dist/src/command-line/migrate/agentic/run-step.d.ts +0 -68
  288. package/dist/src/command-line/migrate/agentic/run-step.js +0 -148
  289. package/dist/src/command-line/migrate/agentic/runner.d.ts +0 -21
  290. package/dist/src/command-line/migrate/agentic/runner.js +0 -262
  291. package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +0 -9
  292. package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +0 -18
  293. package/dist/src/tasks-runner/legacy-depends-on-warning.d.ts +0 -18
  294. package/dist/src/tasks-runner/legacy-depends-on-warning.js +0 -109
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AGENT_DEFINITIONS = exports.opencodeDefinition = exports.codexDefinition = exports.claudeCodeDefinition = void 0;
3
+ exports.AGENT_DEFINITIONS = exports.opencodeDefinition = exports.claudeCodeDefinition = void 0;
4
4
  exports.claudeCodeHandoffAllowedTools = claudeCodeHandoffAllowedTools;
5
5
  exports.encodeTomlString = encodeTomlString;
6
- exports.getAgentDefinition = getAgentDefinition;
7
6
  const os_1 = require("os");
8
7
  const path_1 = require("path");
9
8
  const smol_toml_1 = require("smol-toml");
@@ -20,10 +19,8 @@ function claudeCodeWellKnownPaths() {
20
19
  * The run directory names Nx will interpolate into a permission rule. A rule
21
20
  * is a gitignore pattern, which reads `*?[]\` as syntax, and `--allowedTools`
22
21
  * splits its value on commas and spaces, so a name carrying any of those
23
- * would change what the rule authorizes rather than what it names. Run
24
- * directory names derive from a migration's own version string, which nothing
25
- * upstream constrains to this alphabet. The leading character rejects `.`
26
- * and `..`.
22
+ * would change what the rule authorizes rather than what it names. The
23
+ * leading character rejects `.` and `..`.
27
24
  */
28
25
  const RULE_SAFE_RUN_DIR_NAME = /^[A-Za-z0-9][A-Za-z0-9._+-]*$/;
29
26
  /**
@@ -49,49 +46,16 @@ function claudeCodeHandoffAllowedTools(runDirName) {
49
46
  }
50
47
  return `Edit(${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runDirName}/${types_1.HANDOFFS_DIR_NAME}/**)`;
51
48
  }
52
- function claudeCodeBuildInteractive(ctx) {
53
- const allowedTools = claudeCodeHandoffAllowedTools(ctx.runDirName);
54
- return {
55
- // `--allowedTools` is variadic, so a positional right after it is read as
56
- // another rule: keep the rules in one comma-joined element and a flag
57
- // between them and the instructions pointer.
58
- args: [
59
- ...(allowedTools ? ['--allowedTools', allowedTools] : []),
60
- '--system-prompt-file',
61
- ctx.systemPromptFilePath,
62
- ctx.instructionsPointer,
63
- ],
64
- cwd: ctx.workspaceRoot,
65
- };
66
- }
67
49
  exports.claudeCodeDefinition = {
68
50
  id: 'claude-code',
69
51
  displayName: 'Claude Code',
70
52
  binaryNames: ['claude'],
71
53
  wellKnownPaths: claudeCodeWellKnownPaths,
72
- buildInteractive: claudeCodeBuildInteractive,
73
54
  };
74
55
  // --- OpenAI Codex --------------------------------------------------------
75
56
  function codexWellKnownPaths() {
76
57
  return [];
77
58
  }
78
- // No handoff permission flag: codex's default sandbox already allows writes
79
- // inside the cwd tree (`.git` excepted), and a user-hardened read-only config
80
- // is theirs to keep.
81
- //
82
- // `-c model_instructions_file` replaces codex's built-in instructions rather
83
- // than adding this context to them, so the context stays on the command line,
84
- // reduced rather than the full prompt.
85
- function codexBuildInteractive(ctx) {
86
- return {
87
- args: [
88
- '-c',
89
- `developer_instructions=${encodeTomlString(ctx.inlineSystemContext)}`,
90
- ctx.instructionsPointer,
91
- ],
92
- cwd: ctx.workspaceRoot,
93
- };
94
- }
95
59
  /**
96
60
  * Encodes a single-line TOML string for codex overrides. Codex treats a parse
97
61
  * failure as literal text instead of reporting it, so the result is parsed
@@ -112,15 +76,13 @@ function encodeTomlString(value) {
112
76
  }
113
77
  return encoded;
114
78
  }
115
- exports.codexDefinition = {
79
+ const codexDefinition = {
116
80
  id: 'codex',
117
81
  displayName: 'OpenAI Codex',
118
82
  binaryNames: ['codex'],
119
83
  wellKnownPaths: codexWellKnownPaths,
120
- buildInteractive: codexBuildInteractive,
121
84
  };
122
85
  // --- OpenCode ------------------------------------------------------------
123
- const OPENCODE_TRANSIENT_AGENT_NAME = 'nx-migrate';
124
86
  function opencodeWellKnownPaths() {
125
87
  if (process.platform === 'win32') {
126
88
  return [];
@@ -139,69 +101,15 @@ function opencodeWellKnownPaths() {
139
101
  candidates.push((0, path_1.join)(home, '.opencode', 'bin', 'opencode'));
140
102
  return candidates;
141
103
  }
142
- // No handoff permission config: opencode's `edit` permission defaults to
143
- // allow, and injecting one would clobber a user's own patterns rather than
144
- // merge with them.
145
- //
146
- // The config travels through OPENCODE_CONFIG_CONTENT rather than
147
- // OPENCODE_CONFIG. Both merge with the user's own config, but the runner
148
- // spreads `env` over `process.env`, so the latter would overwrite a value the
149
- // user had set.
150
- function opencodeBuildInteractive(ctx) {
151
- return {
152
- args: [
153
- '--agent',
154
- OPENCODE_TRANSIENT_AGENT_NAME,
155
- '--prompt',
156
- ctx.instructionsPointer,
157
- ],
158
- env: { OPENCODE_CONFIG_CONTENT: opencodeConfigContent(ctx) },
159
- cwd: ctx.workspaceRoot,
160
- };
161
- }
162
- /**
163
- * Escapes inline prompt patterns before opencode's pre-JSON substitution pass.
164
- * Excludes generator instructions from the config; cmd.exe drops inherited
165
- * variables longer than 8191 characters.
166
- */
167
- function opencodeConfigContent(ctx) {
168
- // Windows separators become `/`, which its APIs accept just as well.
169
- // Elsewhere a `\` belongs to the file name.
170
- const filePath = process.platform === 'win32'
171
- ? ctx.systemPromptFilePath.replace(/\\/g, '/')
172
- : ctx.systemPromptFilePath;
173
- const prompt = isSubstitutionSafePath(filePath)
174
- ? JSON.stringify(`{file:${filePath}}`)
175
- : // `\u007b` starts no pattern and JSON decodes it back to `{`, so the
176
- // prompt survives expansion whatever the workspace path put in it.
177
- JSON.stringify(ctx.systemPrompt).replace(/\{/g, '\\u007b');
178
- // Assembled rather than serialized whole: `JSON.stringify` over the object
179
- // would re-escape the backslashes the `\u007b` encoding introduced.
180
- return `{"agent":{${JSON.stringify(OPENCODE_TRANSIENT_AGENT_NAME)}:{"prompt":${prompt}}}}`;
181
- }
182
- /**
183
- * Whether opencode would read back the path nx wrote. A `}` closes the
184
- * reference early, and a character JSON escapes arrives escaped. Braces are
185
- * rejected wholesale rather than matched against `{env:` and `{file:`, since a
186
- * pattern opening inside the path swallows the reference's closing brace.
187
- */
188
- function isSubstitutionSafePath(filePath) {
189
- return (!/[{}]/.test(filePath) && JSON.stringify(filePath).slice(1, -1) === filePath);
190
- }
191
104
  exports.opencodeDefinition = {
192
105
  id: 'opencode',
193
106
  displayName: 'OpenCode',
194
107
  binaryNames: ['opencode'],
195
108
  wellKnownPaths: opencodeWellKnownPaths,
196
- buildInteractive: opencodeBuildInteractive,
197
109
  };
198
110
  // --- Registry ------------------------------------------------------------
199
111
  exports.AGENT_DEFINITIONS = [
200
112
  exports.claudeCodeDefinition,
201
- exports.codexDefinition,
113
+ codexDefinition,
202
114
  exports.opencodeDefinition,
203
115
  ];
204
- const byId = new Map(exports.AGENT_DEFINITIONS.map((definition) => [definition.id, definition]));
205
- function getAgentDefinition(id) {
206
- return byId.get(id);
207
- }
@@ -1,30 +1,12 @@
1
1
  /**
2
- * Both the agentic runner and the orchestrator write per-run scratch under
3
- * `.nx/migrate-runs/<run-id>/`: handoff and prompt files in both cases, plus
4
- * the durable run state and its plan snapshots for the orchestrator. The v23
5
- * migration `23-0-0-add-migrate-runs-to-git-ignore` adds `.nx/migrate-runs` to
6
- * `.gitignore`; in its declared slot (typically late) earlier per-migration
7
- * commits would absorb the scratch into the user-visible diff.
8
- *
9
- * Two paths cover the leak, with no overlap:
10
- *
11
- * 1. HOIST: `sortMigrations`, which `executeMigrations` applies, sorts the
12
- * v23 migration to position 0 when it is in the queue, so it runs first
13
- * through the normal runner with its own log line and commit. A
14
- * single-migration worker run needs no hoisting: the requested migration
15
- * is the entire queue.
16
- *
17
- * 2. INLINE FALLBACK, this function. When the migration is NOT in the queue
18
- * AND the highest target version is < v23 (intra-pre-v23 `--agentic`
19
- * run) it will never run, so apply its body inline against an `FsTree`
20
- * and commit it as a standalone preflight commit (or leave it in the
21
- * working tree under `--no-create-commits`).
22
- *
23
- * Not in the queue AND target >= v23 means the user is already past v23. They
24
- * had the entry historically; if it is gone, that is a conscious removal we
25
- * respect.
2
+ * Applies the v23 migration `23-0-0-add-migrate-runs-to-git-ignore` inline:
3
+ * the orchestrator writes run scratch at init, before that migration runs, and
4
+ * the run's commits would otherwise absorb it. Commits nothing; the init
5
+ * checkpoint carries the edit when commits are on and the checkpoint succeeds.
6
+ * Skipped at nx v23 or later unless the v23 migration is planned: a missing
7
+ * entry is then a conscious removal.
26
8
  */
27
- export declare function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion, effectiveCreateCommits, commitPrefix, root, applyWhenPlanned, commitStandalone, }: {
9
+ export declare function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion, root, }: {
28
10
  migrations: ReadonlyArray<{
29
11
  package: string;
30
12
  name: string;
@@ -37,25 +19,5 @@ export declare function applyAgenticHandoffGitignoreFallback({ migrations, insta
37
19
  * version is irrelevant to whether `nx` itself crossed v23.
38
20
  */
39
21
  installedNxVersion: string;
40
- effectiveCreateCommits: boolean;
41
- commitPrefix: string;
42
22
  root: string;
43
- /**
44
- * Apply the entry even when the hoisted migration is in the plan. The
45
- * classic loop can defer to that migration because its run scratch appears
46
- * only after migration 1 has run; the orchestrator creates its run dir at
47
- * init, before any migration, so it needs the entry immediately. A planned
48
- * migration also means the missing entry is not a conscious removal, so the
49
- * v23 cutoff does not apply.
50
- */
51
- applyWhenPlanned?: boolean;
52
- /**
53
- * Commit the applied entry as its own preflight commit (the default). The
54
- * orchestrator suppresses this: it applies the fallback before its init
55
- * checkpoint so the checkpoint's `git add -A` cannot sweep in older
56
- * scratch, and in that ordering a standalone commit here would carry the
57
- * user's pre-existing changes along with the entry. The checkpoint that
58
- * follows captures both instead.
59
- */
60
- commitStandalone?: boolean;
61
23
  }): Promise<void>;
@@ -6,44 +6,19 @@ const semver_1 = require("semver");
6
6
  const pc = tslib_1.__importStar(require("picocolors"));
7
7
  const add_migrate_runs_to_git_ignore_1 = tslib_1.__importDefault(require("../../../migrations/update-23-0-0/add-migrate-runs-to-git-ignore"));
8
8
  const tree_1 = require("../../../generators/tree");
9
- const git_utils_1 = require("../../../utils/git-utils");
10
9
  const logger_1 = require("../../../utils/logger");
11
10
  const types_1 = require("./types");
12
11
  /**
13
- * Both the agentic runner and the orchestrator write per-run scratch under
14
- * `.nx/migrate-runs/<run-id>/`: handoff and prompt files in both cases, plus
15
- * the durable run state and its plan snapshots for the orchestrator. The v23
16
- * migration `23-0-0-add-migrate-runs-to-git-ignore` adds `.nx/migrate-runs` to
17
- * `.gitignore`; in its declared slot (typically late) earlier per-migration
18
- * commits would absorb the scratch into the user-visible diff.
19
- *
20
- * Two paths cover the leak, with no overlap:
21
- *
22
- * 1. HOIST: `sortMigrations`, which `executeMigrations` applies, sorts the
23
- * v23 migration to position 0 when it is in the queue, so it runs first
24
- * through the normal runner with its own log line and commit. A
25
- * single-migration worker run needs no hoisting: the requested migration
26
- * is the entire queue.
27
- *
28
- * 2. INLINE FALLBACK, this function. When the migration is NOT in the queue
29
- * AND the highest target version is < v23 (intra-pre-v23 `--agentic`
30
- * run) it will never run, so apply its body inline against an `FsTree`
31
- * and commit it as a standalone preflight commit (or leave it in the
32
- * working tree under `--no-create-commits`).
33
- *
34
- * Not in the queue AND target >= v23 means the user is already past v23. They
35
- * had the entry historically; if it is gone, that is a conscious removal we
36
- * respect.
12
+ * Applies the v23 migration `23-0-0-add-migrate-runs-to-git-ignore` inline:
13
+ * the orchestrator writes run scratch at init, before that migration runs, and
14
+ * the run's commits would otherwise absorb it. Commits nothing; the init
15
+ * checkpoint carries the edit when commits are on and the checkpoint succeeds.
16
+ * Skipped at nx v23 or later unless the v23 migration is planned: a missing
17
+ * entry is then a conscious removal.
37
18
  */
38
- async function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion, effectiveCreateCommits, commitPrefix, root, applyWhenPlanned = false, commitStandalone = true, }) {
39
- if (migrations.some(types_1.isHandoffGitignoreMigration)) {
40
- if (!applyWhenPlanned) {
41
- // The queue runs it itself: hoisted to the front by the sort comparator
42
- // in a full run, or as the single requested migration in a worker run.
43
- return;
44
- }
45
- }
46
- else if ((0, semver_1.major)(installedNxVersion) >= 23) {
19
+ async function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion, root, }) {
20
+ if (!migrations.some(types_1.isHandoffGitignoreMigration) &&
21
+ (0, semver_1.major)(installedNxVersion) >= 23) {
47
22
  // User is past v23. Respect their `.gitignore` state — if the entry
48
23
  // is missing, that's a conscious removal.
49
24
  return;
@@ -58,21 +33,4 @@ async function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVer
58
33
  }
59
34
  (0, tree_1.flushChanges)(root, changes);
60
35
  logger_1.logger.info(pc.dim(`- Added ${types_1.MIGRATE_RUNS_RELATIVE_DIR} to .gitignore so this run's scratch state is ignored.`));
61
- if (!effectiveCreateCommits || !commitStandalone)
62
- return;
63
- if (!(0, git_utils_1.hasUncommittedChanges)(root))
64
- return;
65
- try {
66
- const sha = (0, git_utils_1.tryCommitChanges)(`${commitPrefix}add ${types_1.MIGRATE_RUNS_RELATIVE_DIR} to .gitignore`, root, [types_1.MIGRATE_RUNS_RELATIVE_DIR]);
67
- if (sha) {
68
- logger_1.logger.info(pc.dim(` Commit: ${sha}`));
69
- }
70
- // `null` return = commit landed but `git rev-parse HEAD` raced. The
71
- // diff cleared from the working tree; nothing more to say.
72
- }
73
- catch (err) {
74
- const reason = err instanceof Error ? err.message : String(err);
75
- logger_1.logger.info(pc.yellow(`Could not create the agentic preflight commit:\n${reason}\n` +
76
- `The .gitignore change remains in the working tree; commit it manually or it will be absorbed into the first per-migration commit.`));
77
- }
78
36
  }
@@ -1,36 +1,13 @@
1
1
  import { type BigIntStats } from 'fs';
2
2
  import { HandoffFile } from './types';
3
- /** Returns the run directory for a given workspace + run id (target version). */
4
- export declare function runDirPath(workspaceRoot: string, runId: string): string;
5
- /** The version-derived run id: the highest target version in the plan. */
6
- export declare function resolveAgenticRunId(migrations: ReadonlyArray<{
7
- version: string;
8
- }>): string;
9
3
  /**
10
4
  * `mkdir -p` with a contextual error wrapper. Without this, the raw
11
5
  * ENOSPC/EACCES/EROFS surfaces with no indication of which directory the
12
6
  * migrate orchestrator was trying to create.
13
7
  */
14
8
  export declare function mkdirSafely(dir: string, purpose: string): void;
15
- /**
16
- * Wipes any prior contents for this run id and recreates an empty directory.
17
- *
18
- * Scope of the wipe is intentionally narrow (only `<run-id>/`) so that handoff
19
- * artifacts from prior runs targeting different versions remain on disk for
20
- * inspection.
21
- */
22
- export declare function initRunDir(workspaceRoot: string, runId: string): string;
23
9
  export declare function truncateUtf8(value: string, maxBytes: number): string;
24
- export declare function stepHandoffPath(runDir: string, migration: {
25
- package: string;
26
- name: string;
27
- }): string;
28
- /** Handoff path for a run step. No hash needed: step ids are unique within the run. */
29
10
  export declare function runStepHandoffPath(runDir: string, stepId: string): string;
30
- export declare function stepPromptsDir(runDir: string, migration: {
31
- package: string;
32
- name: string;
33
- }): string;
34
11
  export type HandoffReadFailureReason = 'missing' | 'read-error' | 'parse-error' | 'shape-mismatch';
35
12
  export type HandoffReadResult = {
36
13
  ok: true;
@@ -78,25 +55,6 @@ export declare function readInspectedFile(filePath: string, stat: BigIntStats, r
78
55
  export declare function readAtomicallyPublishedFile(filePath: string, notRegularMessage: string): string;
79
56
  /**
80
57
  * Splits "not written yet" from "written but garbage" so callers can surface a
81
- * malformed handoff instead of collapsing it into the generic
82
- * ambiguous-outcome prompt.
58
+ * malformed handoff instead of treating it as not written.
83
59
  */
84
60
  export declare function readHandoffWithReason(filePath: string, handoffsDir: string): HandoffReadResult;
85
- /**
86
- * Convenience wrapper preserving the original null-on-any-failure contract.
87
- * Used by the polling loop (`waitForValidHandoff`) where every failure mode
88
- * is "keep waiting" — the file may be missing, mid-write, or being rewritten.
89
- */
90
- export declare function readHandoff(filePath: string, handoffsDir: string): HandoffFile | null;
91
- /**
92
- * Polls for a valid handoff file. Resolves once `readHandoff` accepts the
93
- * file's contents. Used to detect when the agent has finished its work so the
94
- * orchestrator can close the agent's session without depending on the agent
95
- * exiting on its own.
96
- *
97
- * Rejects with the abort reason when `options.signal` is aborted.
98
- */
99
- export declare function waitForValidHandoff(handoffFilePath: string, handoffsDir: string, options?: {
100
- intervalMs?: number;
101
- signal?: AbortSignal;
102
- }): Promise<void>;
@@ -1,35 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FileReplacedDuringReadError = void 0;
4
- exports.runDirPath = runDirPath;
5
- exports.resolveAgenticRunId = resolveAgenticRunId;
6
4
  exports.mkdirSafely = mkdirSafely;
7
- exports.initRunDir = initRunDir;
8
5
  exports.truncateUtf8 = truncateUtf8;
9
- exports.stepHandoffPath = stepHandoffPath;
10
6
  exports.runStepHandoffPath = runStepHandoffPath;
11
- exports.stepPromptsDir = stepPromptsDir;
12
7
  exports.handoffsDirState = handoffsDirState;
13
8
  exports.ensureRunSubdir = ensureRunSubdir;
14
9
  exports.readInspectedFile = readInspectedFile;
15
10
  exports.readAtomicallyPublishedFile = readAtomicallyPublishedFile;
16
11
  exports.readHandoffWithReason = readHandoffWithReason;
17
- exports.readHandoff = readHandoff;
18
- exports.waitForValidHandoff = waitForValidHandoff;
19
- const crypto_1 = require("crypto");
20
12
  const fs_1 = require("fs");
21
13
  const path_1 = require("path");
22
- const semver_1 = require("semver");
23
- const version_utils_1 = require("../version-utils");
24
14
  const types_1 = require("./types");
25
- /** Returns the run directory for a given workspace + run id (target version). */
26
- function runDirPath(workspaceRoot, runId) {
27
- return (0, path_1.join)(workspaceRoot, types_1.MIGRATE_RUNS_RELATIVE_DIR, runId);
28
- }
29
- /** The version-derived run id: the highest target version in the plan. */
30
- function resolveAgenticRunId(migrations) {
31
- return (0, semver_1.rsort)(migrations.map((m) => (0, version_utils_1.normalizeVersion)(m.version)))[0];
32
- }
33
15
  /**
34
16
  * `mkdir -p` with a contextual error wrapper. Without this, the raw
35
17
  * ENOSPC/EACCES/EROFS surfaces with no indication of which directory the
@@ -48,35 +30,6 @@ function mkdirSafely(dir, purpose) {
48
30
  throw new Error(`Could not create ${purpose} at ${dir}${code ? ` (${code})` : ''}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
49
31
  }
50
32
  }
51
- /**
52
- * Wipes any prior contents for this run id and recreates an empty directory.
53
- *
54
- * Scope of the wipe is intentionally narrow (only `<run-id>/`) so that handoff
55
- * artifacts from prior runs targeting different versions remain on disk for
56
- * inspection.
57
- */
58
- function initRunDir(workspaceRoot, runId) {
59
- const dir = runDirPath(workspaceRoot, runId);
60
- (0, fs_1.rmSync)(dir, { recursive: true, force: true });
61
- mkdirSafely(dir, 'nx migrate run directory');
62
- return dir;
63
- }
64
- // Windows reserved device names fail to open even with an extension —
65
- // a migration named `CON` would otherwise produce a `CON.json` that the
66
- // agent can't write to.
67
- const WINDOWS_RESERVED_NAMES = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;
68
- function sanitizeSegment(value) {
69
- if (value === '.' || value === '..')
70
- return '_';
71
- let sanitized = value.replace(/[\x00-\x1f<>:"/\\|?*+]/g, '_');
72
- // Windows forbids trailing dots/spaces on file/directory names.
73
- sanitized = sanitized.replace(/[. ]+$/, '');
74
- if (WINDOWS_RESERVED_NAMES.test(sanitized)) {
75
- sanitized = `_${sanitized}`;
76
- }
77
- return sanitized || '_';
78
- }
79
- const STEP_NAME_PREFIX_MAX_BYTES = 64;
80
33
  // Truncates to a UTF-8 byte budget without splitting a code point.
81
34
  function truncateUtf8(value, maxBytes) {
82
35
  let out = '';
@@ -90,29 +43,9 @@ function truncateUtf8(value, maxBytes) {
90
43
  }
91
44
  return out;
92
45
  }
93
- /**
94
- * The name a step's own files are keyed by, bounded to fit one path component.
95
- * Sanitizing folds many characters to `_` and the prefix is cut to fit, so the
96
- * SHA-256 of the raw package and name is what keeps two migrations apart.
97
- */
98
- function stepStem(migration) {
99
- const prefix = truncateUtf8([...migration.package.split('/'), migration.name]
100
- .map(sanitizeSegment)
101
- .join('+'), STEP_NAME_PREFIX_MAX_BYTES);
102
- const hash = (0, crypto_1.createHash)('sha256')
103
- .update(JSON.stringify([migration.package, migration.name]))
104
- .digest('hex');
105
- return `${prefix}-${hash}`;
106
- }
107
- function stepHandoffPath(runDir, migration) {
108
- return (0, path_1.join)(runDir, types_1.HANDOFFS_DIR_NAME, `${stepStem(migration)}.json`);
109
- }
110
- /** Handoff path for a run step. No hash needed: step ids are unique within the run. */
46
+ // Step ids match run-state's STEP_ID (`step-<n>`), so they are safe file names.
111
47
  function runStepHandoffPath(runDir, stepId) {
112
- return (0, path_1.join)(runDir, types_1.HANDOFFS_DIR_NAME, `${sanitizeSegment(stepId)}.json`);
113
- }
114
- function stepPromptsDir(runDir, migration) {
115
- return (0, path_1.join)(runDir, types_1.PROMPTS_DIR_NAME, stepStem(migration));
48
+ return (0, path_1.join)(runDir, types_1.HANDOFFS_DIR_NAME, `${stepId}.json`);
116
49
  }
117
50
  /**
118
51
  * `lstat`, not `stat`: a symlink in the handoffs dir's place would send every
@@ -211,8 +144,7 @@ function readAtomicallyPublishedFile(filePath, notRegularMessage) {
211
144
  }
212
145
  /**
213
146
  * Splits "not written yet" from "written but garbage" so callers can surface a
214
- * malformed handoff instead of collapsing it into the generic
215
- * ambiguous-outcome prompt.
147
+ * malformed handoff instead of treating it as not written.
216
148
  */
217
149
  function readHandoffWithReason(filePath, handoffsDir) {
218
150
  let raw;
@@ -285,51 +217,3 @@ function readHandoffWithReason(filePath, handoffsDir) {
285
217
  }
286
218
  return { ok: true, handoff };
287
219
  }
288
- /**
289
- * Convenience wrapper preserving the original null-on-any-failure contract.
290
- * Used by the polling loop (`waitForValidHandoff`) where every failure mode
291
- * is "keep waiting" — the file may be missing, mid-write, or being rewritten.
292
- */
293
- function readHandoff(filePath, handoffsDir) {
294
- const result = readHandoffWithReason(filePath, handoffsDir);
295
- return result.ok ? result.handoff : null;
296
- }
297
- /**
298
- * Polls for a valid handoff file. Resolves once `readHandoff` accepts the
299
- * file's contents. Used to detect when the agent has finished its work so the
300
- * orchestrator can close the agent's session without depending on the agent
301
- * exiting on its own.
302
- *
303
- * Rejects with the abort reason when `options.signal` is aborted.
304
- */
305
- function waitForValidHandoff(handoffFilePath, handoffsDir, options = {}) {
306
- const intervalMs = options.intervalMs ?? 500;
307
- const { signal } = options;
308
- return new Promise((resolve, reject) => {
309
- if (signal?.aborted) {
310
- reject(signal.reason ?? new Error('aborted'));
311
- return;
312
- }
313
- let timer;
314
- const onAbort = () => {
315
- if (timer)
316
- clearTimeout(timer);
317
- signal?.removeEventListener('abort', onAbort);
318
- reject(signal.reason ?? new Error('aborted'));
319
- };
320
- const tick = () => {
321
- if (signal?.aborted) {
322
- onAbort();
323
- return;
324
- }
325
- if (readHandoff(handoffFilePath, handoffsDir) !== null) {
326
- signal?.removeEventListener('abort', onAbort);
327
- resolve();
328
- return;
329
- }
330
- timer = setTimeout(tick, intervalMs);
331
- };
332
- signal?.addEventListener('abort', onAbort);
333
- timer = setTimeout(tick, intervalMs);
334
- });
335
- }
@@ -1,23 +1,2 @@
1
- export interface StepInstructionFiles {
2
- /** Absolute path: config loaders resolve it, not the agent from its cwd. */
3
- systemPromptFilePath: string;
4
- /** Single-line command-line text pointing the agent at its instructions. */
5
- instructionsPointer: string;
6
- }
7
- export interface WriteStepInstructionFilesArgs {
8
- workspaceRoot: string;
9
- runDir: string;
10
- migration: {
11
- package: string;
12
- name: string;
13
- };
14
- systemPrompt: string;
15
- instructions: string;
16
- }
17
- /**
18
- * Writes prompts as files on every platform to keep one delivery path.
19
- * Windows npm shims cannot carry multi-line prompts within cmd.exe's limit.
20
- */
21
- export declare function writeStepInstructionFiles(args: WriteStepInstructionFilesArgs): StepInstructionFiles;
22
1
  /** Writes `instructions.md` into an existing `promptsDir`; returns its path. */
23
2
  export declare function writeInstructionsFile(workspaceRoot: string, promptsDir: string, instructions: string): string;
@@ -1,41 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeStepInstructionFiles = writeStepInstructionFiles;
4
3
  exports.writeInstructionsFile = writeInstructionsFile;
5
4
  const fs_1 = require("fs");
6
5
  const path_1 = require("path");
7
- const handoff_1 = require("./handoff");
8
- /**
9
- * Writes prompts as files on every platform to keep one delivery path.
10
- * Windows npm shims cannot carry multi-line prompts within cmd.exe's limit.
11
- */
12
- function writeStepInstructionFiles(args) {
13
- const { workspaceRoot, runDir, migration, systemPrompt, instructions } = args;
14
- const promptsDir = (0, handoff_1.stepPromptsDir)(runDir, migration);
15
- (0, handoff_1.mkdirSafely)(promptsDir, `prompt directory for ${migration.name}`);
16
- const systemPromptFilePath = (0, path_1.join)(promptsDir, 'system.md');
17
- writeStepFile(systemPromptFilePath, systemPrompt, 'system prompt');
18
- const instructionsFilePath = writeInstructionsFile(workspaceRoot, promptsDir, instructions);
19
- return {
20
- systemPromptFilePath,
21
- instructionsPointer: `Your instructions for this migration step are in the file ${instructionsFilePath} (path is relative to the workspace root). Read it in full, then follow it.`,
22
- };
23
- }
24
6
  /** Writes `instructions.md` into an existing `promptsDir`; returns its path. */
25
7
  function writeInstructionsFile(workspaceRoot, promptsDir, instructions) {
26
8
  const absolutePath = (0, path_1.join)(promptsDir, 'instructions.md');
27
- writeStepFile(absolutePath, instructions, 'instructions');
28
- // Workspace-relative: the agent resolves this one itself with its cwd pinned
29
- // to the workspace root. Forward slashes because it is read as prose out of
30
- // the agent's prompt, where a `\` is an escape.
31
- return (0, path_1.relative)(workspaceRoot, absolutePath).replace(/\\/g, '/');
32
- }
33
- function writeStepFile(filePath, contents, purpose) {
34
9
  try {
35
- (0, fs_1.writeFileSync)(filePath, contents, 'utf-8');
10
+ (0, fs_1.writeFileSync)(absolutePath, instructions, 'utf-8');
36
11
  }
37
12
  catch (err) {
38
13
  const code = err?.code;
39
- throw new Error(`Could not write the step's ${purpose} to ${filePath}${code ? ` (${code})` : ''}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
14
+ throw new Error(`Could not write the step's instructions to ${absolutePath}${code ? ` (${code})` : ''}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
40
15
  }
16
+ // Workspace-relative: the agent resolves this one itself with its cwd pinned
17
+ // to the workspace root. Forward slashes because it is read as prose out of
18
+ // the agent's prompt, where a `\` is an escape.
19
+ return (0, path_1.relative)(workspaceRoot, absolutePath).replace(/\\/g, '/');
41
20
  }
@@ -1,4 +1,4 @@
1
- import { type RunOrchestratorInitInput } from '../../run';
1
+ import { type MigrateRunPolicy, type MigrateRunState, type OrchestratorInitResult, type RunOrchestratorInitInput } from '../../run';
2
2
  import type { DetectedInstalledAgent } from '../types';
3
3
  export interface RunMasterSessionInput extends Omit<RunOrchestratorInitInput, 'emitAgentInstructions' | 'onExistingRun'> {
4
4
  agent: DetectedInstalledAgent;
@@ -14,3 +14,21 @@ export interface RunMasterSessionInput extends Omit<RunOrchestratorInitInput, 'e
14
14
  * session ends, not what the agent process returned.
15
15
  */
16
16
  export declare function runMasterSession(input: RunMasterSessionInput): Promise<number | undefined>;
17
+ /**
18
+ * Hands a ready run to one agent session and reads the run's state once the
19
+ * session ends. `migration` is set for a `--run-migration` run. Returns null
20
+ * once it has printed why the session could not start or why its outcome is
21
+ * unknown; `notStartedHint` tells the user what to do when it could not start.
22
+ */
23
+ export declare function driveMasterSession(input: {
24
+ agent: DetectedInstalledAgent;
25
+ ready: Extract<OrchestratorInitResult, {
26
+ kind: 'ready';
27
+ }>;
28
+ policy: MigrateRunPolicy;
29
+ migration?: {
30
+ package: string;
31
+ name: string;
32
+ };
33
+ notStartedHint: string;
34
+ }): Promise<MigrateRunState | null>;