@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
@@ -8,13 +8,16 @@ const child_process_1 = require("../../../utils/child-process");
8
8
  const logger_1 = require("../../../utils/logger");
9
9
  const package_manager_1 = require("../../../utils/package-manager");
10
10
  const migrate_output_1 = require("../migrate-output");
11
+ const format_command_1 = require("./format-command");
11
12
  const handoff_1 = require("./handoff");
13
+ const instruction_files_1 = require("./instruction-files");
12
14
  const generic_validation_1 = require("./prompts/generic-validation");
13
15
  const hybrid_prompt_migration_1 = require("./prompts/hybrid-prompt-migration");
14
16
  const prompt_migration_1 = require("./prompts/prompt-migration");
15
17
  const system_prompt_1 = require("./prompts/system-prompt");
16
18
  const definitions_1 = require("./definitions");
17
19
  const runner_1 = require("./runner");
20
+ const types_1 = require("./types");
18
21
  /**
19
22
  * Spawns the configured AI agent against a migration step, awaits its handoff,
20
23
  * and translates the outcome into a structured result the executor can branch
@@ -34,12 +37,19 @@ async function runAgenticPromptStep(input) {
34
37
  // prompt in agents like Claude Code every run).
35
38
  (0, handoff_1.mkdirSafely)((0, path_1.dirname)(handoffFilePath), `handoff directory for ${migration.name}`);
36
39
  const pm = (0, package_manager_1.detectPackageManager)(root);
37
- const systemContext = (0, system_prompt_1.buildSystemPrompt)({
40
+ const pmCommand = (0, package_manager_1.getPackageManagerCommand)(pm, root);
41
+ const systemPrompt = (0, system_prompt_1.buildSystemPrompt)({
38
42
  workspaceRoot: root,
39
43
  handoffFileAbsolutePath: handoffFilePath,
40
44
  packageManager: pm,
41
- nxInvocation: (0, child_process_1.getRunNxBaseCommand)((0, package_manager_1.getPackageManagerCommand)(pm, root), root),
45
+ nxInvocation: (0, child_process_1.getRunNxBaseCommand)(pmCommand, root),
42
46
  mode,
47
+ pmExec: pmCommand.exec,
48
+ // Validation prompts carry no format rule, so don't probe the workspace
49
+ // (detectFormatter can warn) for a command the prompt would discard.
50
+ formatCommand: mode === 'generic-validation'
51
+ ? null
52
+ : (0, format_command_1.resolveFormatCommand)(root, pmCommand.exec),
43
53
  });
44
54
  let userPrompt;
45
55
  if (mode === 'generic-validation') {
@@ -74,18 +84,32 @@ async function runAgenticPromptStep(input) {
74
84
  if (!definition) {
75
85
  throw new Error(`No agent definition registered for "${agentic.selectedAgent.id}".`);
76
86
  }
87
+ const { systemPromptFilePath, instructionsPointer } = (0, instruction_files_1.writeStepInstructionFiles)({
88
+ workspaceRoot: root,
89
+ runDir,
90
+ migration,
91
+ systemPrompt,
92
+ instructions: userPrompt,
93
+ });
77
94
  const phase = mode === 'generic-validation' ? 'Validating' : 'Running prompt';
78
95
  logger_1.logger.info(pc.dim(`→ ${phase} with ${agentic.selectedAgent.displayName}…`));
79
96
  const outcome = await (0, runner_1.runAgentic)({
80
97
  detected: agentic.selectedAgent,
81
98
  definition,
82
99
  invocationContext: {
83
- systemContext,
84
- userPrompt,
100
+ systemPrompt,
101
+ systemPromptFilePath,
102
+ instructionsPointer,
103
+ inlineSystemContext: (0, system_prompt_1.buildInlineSystemContext)({
104
+ handoffFileAbsolutePath: handoffFilePath,
105
+ systemPromptFilePath,
106
+ }),
107
+ inlineSystemContextFallback: (0, system_prompt_1.buildMinimalSystemContext)(systemPromptFilePath),
85
108
  workspaceRoot: root,
86
109
  runDirName: (0, path_1.basename)(runDir),
87
110
  },
88
111
  handoffFilePath,
112
+ handoffsDir: (0, path_1.join)(runDir, types_1.HANDOFFS_DIR_NAME),
89
113
  });
90
114
  // Some agent TUIs leave cursor/SGR state behind on exit. Reset before our
91
115
  // own log lines so the outcome line lands clean instead of overlaid on the
@@ -1,13 +1,14 @@
1
- import { SpawnOptions } from 'child_process';
2
1
  import { AgentDefinition, DetectedInstalledAgent, HandoffOutcome, InvocationContext } from './types';
3
2
  export interface RunAgenticArgs {
4
3
  detected: DetectedInstalledAgent;
5
4
  definition: AgentDefinition;
6
5
  invocationContext: InvocationContext;
7
6
  handoffFilePath: string;
7
+ /** Directory the handoff sits in; passing a parent instead skips the symlink guard. */
8
+ handoffsDir: string;
8
9
  /** Override the handoff-file poll interval (test seam). */
9
10
  handoffPollIntervalMs?: number;
10
- /** Override the SIGINT-to-SIGTERM grace period (test seam). */
11
+ /** Override the SIGINT-to-SIGKILL grace period (test seam). */
11
12
  gracefulExitMs?: number;
12
13
  /** Override the post-force-kill safety bound (test seam). */
13
14
  forceKillWaitMs?: number;
@@ -18,16 +19,3 @@ export interface RunAgenticArgs {
18
19
  * the handoff file (or the user when the file is missing).
19
20
  */
20
21
  export declare function runAgentic(args: RunAgenticArgs): Promise<HandoffOutcome>;
21
- /**
22
- * Node's `spawn` cannot directly execute `.cmd` / `.bat` shims on Windows;
23
- * `which` resolves to those when an agent was installed via npm. Wrap them in
24
- * a `cmd.exe /d /s /c` invocation with `windowsVerbatimArguments` so quoting
25
- * follows the cmd.exe convention rather than Node's default cooking.
26
- *
27
- * On non-Windows or for non-shim binaries this is a passthrough.
28
- */
29
- export declare function adaptSpawnForWindowsShim(binary: string, args: readonly string[], options: SpawnOptions): {
30
- binary: string;
31
- args: string[];
32
- options: SpawnOptions;
33
- };
@@ -1,32 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runAgentic = runAgentic;
4
- exports.adaptSpawnForWindowsShim = adaptSpawnForWindowsShim;
4
+ const tslib_1 = require("tslib");
5
5
  const child_process_1 = require("child_process");
6
- const path_1 = require("path");
6
+ const pc = tslib_1.__importStar(require("picocolors"));
7
+ const logger_1 = require("../../../utils/logger");
7
8
  const output_1 = require("../../../utils/output");
8
9
  const migrate_analytics_1 = require("../migrate-analytics");
9
10
  const safe_prompt_1 = require("../safe-prompt");
11
+ const close_agent_session_1 = require("./close-agent-session");
10
12
  const handoff_1 = require("./handoff");
11
- // How long to wait for the agent to exit gracefully after sending SIGINT once
12
- // a valid handoff has been written. Long enough for an interactive agent to
13
- // finish its current render and clean up; short enough that a frozen child
14
- // still gets escalated to SIGTERM in a sensible time.
15
- const AGENT_GRACEFUL_EXIT_MS = 5_000;
13
+ const terminal_repair_1 = require("./terminal-repair");
14
+ const windows_cmd_1 = require("./windows-cmd");
16
15
  /**
17
16
  * Spawns the selected agent with `stdio: 'inherit'`, swallows SIGINT while the
18
17
  * child is alive, waits for it to exit, and resolves the run's outcome from
19
18
  * the handoff file (or the user when the file is missing).
20
19
  */
21
20
  async function runAgentic(args) {
22
- const { detected, definition, invocationContext, handoffFilePath, handoffPollIntervalMs, gracefulExitMs = AGENT_GRACEFUL_EXIT_MS, forceKillWaitMs = FORCE_KILL_WAIT_MS, } = args;
23
- const spec = definition.buildInteractive(invocationContext);
24
- const adapted = adaptSpawnForWindowsShim(detected.binary, spec.args, {
25
- stdio: 'inherit',
26
- cwd: spec.cwd ?? invocationContext.workspaceRoot,
27
- env: spec.env ? { ...process.env, ...spec.env } : process.env,
28
- windowsHide: true,
29
- });
21
+ const { detected, definition, invocationContext, handoffFilePath, handoffsDir, handoffPollIntervalMs, gracefulExitMs = close_agent_session_1.AGENT_GRACEFUL_EXIT_MS, forceKillWaitMs = close_agent_session_1.FORCE_KILL_WAIT_MS, } = args;
22
+ const adapted = adaptWithinCommandLineBudget(detected, definition, invocationContext);
30
23
  let child;
31
24
  // Local alias so `@nx/workspace-require-windows-hide` recognizes the
32
25
  // options arg as a tracked Identifier rather than giving up on a
@@ -36,7 +29,7 @@ async function runAgentic(args) {
36
29
  child = (0, child_process_1.spawn)(adapted.binary, adapted.args, spawnOptions);
37
30
  }
38
31
  catch (err) {
39
- return resolveFromHandoffOrPrompt(handoffFilePath, false, {
32
+ return resolveFromHandoffOrPrompt(handoffFilePath, handoffsDir, false, {
40
33
  spawnError: err instanceof Error ? err.message : String(err),
41
34
  });
42
35
  }
@@ -52,8 +45,8 @@ async function runAgentic(args) {
52
45
  };
53
46
  process.on('SIGINT', swallowSigint);
54
47
  const handoffWatchAbort = new AbortController();
55
- const exitPromise = waitForExit(child);
56
- const handoffPromise = (0, handoff_1.waitForValidHandoff)(handoffFilePath, {
48
+ const exitPromise = (0, close_agent_session_1.waitForExit)(child);
49
+ const handoffPromise = (0, handoff_1.waitForValidHandoff)(handoffFilePath, handoffsDir, {
57
50
  signal: handoffWatchAbort.signal,
58
51
  intervalMs: handoffPollIntervalMs,
59
52
  });
@@ -70,19 +63,57 @@ async function runAgentic(args) {
70
63
  handoffPromise.then(() => 'handoff', () => 'exit'),
71
64
  ]);
72
65
  if (winner === 'handoff') {
73
- await closeAgentSession(child, exitPromise, gracefulExitMs, forceKillWaitMs);
66
+ await (0, close_agent_session_1.closeAgentSession)(child, exitPromise, gracefulExitMs, forceKillWaitMs);
74
67
  // Extra safety bound so the orchestrator can't hang if the child
75
68
  // stays stuck after SIGKILL / taskkill (e.g. D-state on a hung NFS
76
69
  // read, or taskkill returning before the process actually exits).
77
- await raceWithTimeout(exitPromise, forceKillWaitMs);
70
+ await (0, close_agent_session_1.raceWithTimeout)(exitPromise, forceKillWaitMs);
78
71
  }
79
72
  }
80
73
  finally {
81
74
  handoffWatchAbort.abort();
82
75
  process.removeListener('SIGINT', swallowSigint);
83
- restoreTermiosAfterAgent();
76
+ (0, terminal_repair_1.restoreTermiosAfterAgent)();
77
+ }
78
+ return resolveFromHandoffOrPrompt(handoffFilePath, handoffsDir, userInterruptCount > 0, exitInfoToCause(exitInfo));
79
+ }
80
+ /**
81
+ * Builds Windows shim arguments within budget, trying the shorter context
82
+ * before aborting. Rejects overflow to avoid truncated instructions.
83
+ * Leaves command lines unmeasured off the shim path.
84
+ */
85
+ function adaptWithinCommandLineBudget(detected, definition, invocationContext) {
86
+ const adapt = (ctx) => {
87
+ const spec = definition.buildInteractive(ctx);
88
+ return (0, windows_cmd_1.adaptSpawnForWindowsShim)(detected.binary, spec.args, {
89
+ stdio: 'inherit',
90
+ cwd: spec.cwd ?? ctx.workspaceRoot,
91
+ env: spec.env ? { ...process.env, ...spec.env } : process.env,
92
+ windowsHide: true,
93
+ });
94
+ };
95
+ const adapted = adapt(invocationContext);
96
+ if ((0, windows_cmd_1.withinCommandLineBudget)(adapted)) {
97
+ return adapted;
84
98
  }
85
- return resolveFromHandoffOrPrompt(handoffFilePath, userInterruptCount > 0, exitInfoToCause(exitInfo));
99
+ const reduced = adapt({
100
+ ...invocationContext,
101
+ inlineSystemContext: invocationContext.inlineSystemContextFallback,
102
+ });
103
+ if ((0, windows_cmd_1.withinCommandLineBudget)(reduced)) {
104
+ logger_1.logger.info(pc.dim(` Passing the agent a reduced system context. The full one does not fit on a Windows command line alongside these paths.`));
105
+ return reduced;
106
+ }
107
+ output_1.output.error({
108
+ title: `${detected.displayName} cannot be started for this migration step`,
109
+ bodyLines: [
110
+ `Launching it needs a ${reduced.commandLineLength}-character command line. cmd.exe runs at most ${windows_cmd_1.WINDOWS_COMMAND_LINE_LIMIT} characters, and nx stops at ${windows_cmd_1.WINDOWS_COMMAND_LINE_BUDGET} to leave room for what it cannot measure from here.`,
111
+ `The length is paths: the workspace root, at ${invocationContext.workspaceRoot.length} characters, and the migration's package and name, each repeated across several of them.`,
112
+ ``,
113
+ `Re-run with \`--agentic=false\` to apply the remaining migrations yourself. Moving the workspace to a shorter path can help too, but only for agents that put it on the command line.`,
114
+ ],
115
+ });
116
+ throw new Error(`Cannot start ${detected.displayName}: the command line exceeds the Windows limit.`);
86
117
  }
87
118
  function exitInfoToCause(info) {
88
119
  const cause = {};
@@ -101,172 +132,8 @@ function exitInfoToCause(info) {
101
132
  cause.exitError = info.error.message;
102
133
  return cause;
103
134
  }
104
- function restoreTermiosAfterAgent() {
105
- if (process.platform === 'win32')
106
- return;
107
- if (!process.stdin.isTTY)
108
- return;
109
- try {
110
- // `stty sane` resets termios to a known cooked state via the kernel —
111
- // independent of Node's libuv mode tracking (Node's setRawMode(false)
112
- // short-circuits when libuv's per-handle mode is already NORMAL, even
113
- // if the OS-level termios was changed out-of-band by the agent).
114
- (0, child_process_1.execSync)('stty sane < /dev/tty', {
115
- stdio: ['ignore', 'ignore', 'ignore'],
116
- windowsHide: true,
117
- });
118
- // Carriage-return + clear to end of screen, to wipe any agent TUI
119
- // cells below our row that subsequent log lines won't overwrite
120
- // (e.g. a status footer past where our text wraps).
121
- process.stdout.write('\r\x1B[J');
122
- }
123
- catch {
124
- // best-effort — if stty isn't on PATH or /dev/tty isn't accessible,
125
- // the worst case is the pre-existing staircase + cell-bleed output.
126
- }
127
- }
128
- // Safety bound after force-kill. SIGKILL normally reaps in microseconds;
129
- // the bound exists for uninterruptible kernel calls or taskkill returning
130
- // before the process actually exits.
131
- const FORCE_KILL_WAIT_MS = 500;
132
- /**
133
- * Stops the agent process after a successful handoff. Platform-branched:
134
- *
135
- * - POSIX: SIGINT (graceful, equivalent to user Ctrl+C) → wait
136
- * `gracefulExitMs` for the child to exit → SIGKILL → wait
137
- * `FORCE_KILL_WAIT_MS` (bounded) → return. SIGTERM is intentionally
138
- * skipped: a process that ignores SIGINT for 5s will hit the same
139
- * handler on SIGTERM, the extra step only delays the inevitable.
140
- *
141
- * - Windows: skip SIGINT entirely. `child.kill('*')` on Windows is a
142
- * `TerminateProcess` call regardless of the signal name (Windows has
143
- * no POSIX signals), and on the `cmd.exe /d /s /c "..."` shim path it
144
- * would terminate cmd.exe while leaving the agent orphaned (parent
145
- * death doesn't cascade to children on Windows). `taskkill /T /F`
146
- * walks the process tree and kills cmd.exe AND the agent atomically;
147
- * that's the only reliable shutdown path here. `taskkill` failures
148
- * (binary missing, race with already-dead pid) are swallowed; the
149
- * safety bound returns regardless.
150
- */
151
- async function closeAgentSession(child, exitPromise, gracefulExitMs, forceKillWaitMs) {
152
- if (child.exitCode !== null || child.signalCode !== null)
153
- return;
154
- if (process.platform === 'win32') {
155
- await forceKillWindowsTree(child, exitPromise, forceKillWaitMs);
156
- return;
157
- }
158
- // POSIX path.
159
- try {
160
- child.kill('SIGINT');
161
- }
162
- catch {
163
- // child already gone between the check above and here
164
- return;
165
- }
166
- let escalation;
167
- try {
168
- await Promise.race([
169
- exitPromise,
170
- new Promise((resolve) => {
171
- escalation = setTimeout(resolve, gracefulExitMs);
172
- }),
173
- ]);
174
- }
175
- finally {
176
- if (escalation)
177
- clearTimeout(escalation);
178
- }
179
- if (child.exitCode !== null || child.signalCode !== null)
180
- return;
181
- // Graceful timeout elapsed without the agent exiting. SIGKILL is
182
- // uncatchable; bound the post-kill wait so a pathological uninterruptible
183
- // syscall can't hang us forever.
184
- try {
185
- child.kill('SIGKILL');
186
- }
187
- catch {
188
- /* child already gone */
189
- }
190
- await raceWithTimeout(exitPromise, forceKillWaitMs);
191
- }
192
- async function forceKillWindowsTree(child, exitPromise, forceKillWaitMs) {
193
- const pid = child.pid;
194
- // `child.pid` is undefined only when spawn itself failed; the early-return
195
- // guard in `closeAgentSession` should short-circuit that path. Reaching
196
- // here without a pid means a narrow race between handoff-detection and
197
- // error-event propagation — without a pid we can't taskkill, so wait
198
- // briefly and return.
199
- if (pid !== undefined) {
200
- try {
201
- (0, child_process_1.execSync)(`taskkill /T /F /PID ${pid}`, {
202
- stdio: 'ignore',
203
- windowsHide: true,
204
- // Bound so a hung Windows shell can't block the orchestrator.
205
- timeout: 2_000,
206
- });
207
- }
208
- catch {
209
- /* taskkill missing, pid already dead, or timed out — fall through */
210
- }
211
- }
212
- await raceWithTimeout(exitPromise, forceKillWaitMs);
213
- }
214
- async function raceWithTimeout(promise, timeoutMs) {
215
- let timer;
216
- try {
217
- await Promise.race([
218
- promise,
219
- new Promise((resolve) => {
220
- timer = setTimeout(resolve, timeoutMs);
221
- }),
222
- ]);
223
- }
224
- finally {
225
- if (timer)
226
- clearTimeout(timer);
227
- }
228
- }
229
- // Merge window so a paired exit + error both land in the same ExitInfo
230
- // (e.g. error from IPC followed by exit when the process actually
231
- // terminates). For error-only paths like spawn ENOENT — where Node fires
232
- // error but never exit — this timer is the SOLE settlement mechanism.
233
- const EXIT_MERGE_WINDOW_MS = 10;
234
- function waitForExit(child) {
235
- return new Promise((resolve) => {
236
- const info = {};
237
- let pending = null;
238
- let settled = false;
239
- const settle = () => {
240
- if (settled)
241
- return;
242
- settled = true;
243
- if (pending)
244
- clearTimeout(pending);
245
- resolve(info);
246
- };
247
- const onFirst = () => {
248
- if (settled || pending)
249
- return;
250
- pending = setTimeout(settle, EXIT_MERGE_WINDOW_MS);
251
- };
252
- child.on('exit', (code, signal) => {
253
- info.code = code;
254
- info.signal = signal;
255
- onFirst();
256
- });
257
- // `error` fires when spawn itself fails (e.g. binary disappeared between
258
- // detection and run) OR alongside `exit` when the process started but
259
- // emitted an error event later. Treat both as exit with no handoff so
260
- // the ambiguous flow kicks in; field-merge so we don't drop the loser's
261
- // contribution when both fire.
262
- child.on('error', (error) => {
263
- info.error = error;
264
- onFirst();
265
- });
266
- });
267
- }
268
- async function resolveFromHandoffOrPrompt(handoffFilePath, userInterrupted = false, cause = {}) {
269
- const read = (0, handoff_1.readHandoffWithReason)(handoffFilePath);
135
+ async function resolveFromHandoffOrPrompt(handoffFilePath, handoffsDir, userInterrupted = false, cause = {}) {
136
+ const read = (0, handoff_1.readHandoffWithReason)(handoffFilePath, handoffsDir);
270
137
  if (read.ok === true) {
271
138
  return {
272
139
  kind: read.handoff.status,
@@ -286,18 +153,8 @@ async function resolveFromHandoffOrPrompt(handoffFilePath, userInterrupted = fal
286
153
  // unverified, so the skip stays. The orchestrator's standard failure
287
154
  // cascade surfaces the abort outcome.
288
155
  //
289
- // Forward the underlying cause as pre-rendered summary lines so the
290
- // caller can log it before "Aborted by user" — a Ctrl+C that masked
291
- // a SEPARATE crash still needs to show the user what crashed. Scrub
292
- // fields that are just the Ctrl+C itself reverberating: exit code
293
- // 130 (SIGINT) / 143 (SIGTERM from our escalation) and signals
294
- // SIGINT / SIGTERM reflect the user's own keystroke (and our
295
- // graceful-exit handling of it); surfacing them as "agent crashed"
296
- // would be noise. Anything else — code 1, code 137 (OOM), an
297
- // unrelated signal — is a separate diagnostic worth keeping. Note
298
- // that `spawnError` is structurally impossible here: the spawn-throw
299
- // path returns directly without registering the SIGINT listener, so
300
- // `userInterrupted` can never be true on that branch.
156
+ // After user interruption, suppress conventional stop statuses and retain
157
+ // independent failure diagnostics for the caller to display.
301
158
  const exitWasCtrlC = cause.exitCode === 130 ||
302
159
  cause.exitCode === 143 ||
303
160
  cause.exitSignal === 'SIGINT' ||
@@ -318,45 +175,6 @@ async function resolveFromHandoffOrPrompt(handoffFilePath, userInterrupted = fal
318
175
  }
319
176
  return promptAmbiguous(fullCause);
320
177
  }
321
- /**
322
- * Node's `spawn` cannot directly execute `.cmd` / `.bat` shims on Windows;
323
- * `which` resolves to those when an agent was installed via npm. Wrap them in
324
- * a `cmd.exe /d /s /c` invocation with `windowsVerbatimArguments` so quoting
325
- * follows the cmd.exe convention rather than Node's default cooking.
326
- *
327
- * On non-Windows or for non-shim binaries this is a passthrough.
328
- */
329
- function adaptSpawnForWindowsShim(binary, args, options) {
330
- if (process.platform !== 'win32') {
331
- return { binary, args: [...args], options };
332
- }
333
- const ext = (0, path_1.extname)(binary).toLowerCase();
334
- if (ext !== '.cmd' && ext !== '.bat') {
335
- return { binary, args: [...args], options };
336
- }
337
- const cmdLine = [escapeCmdCommand(binary), ...args.map(escapeCmdArg)].join(' ');
338
- return {
339
- binary: process.env.comspec || 'cmd.exe',
340
- // Outer pair of quotes is required so cmd.exe /c does not strip the inner
341
- // quotes around the binary path.
342
- args: ['/d', '/s', '/c', `"${cmdLine}"`],
343
- options: { ...options, windowsVerbatimArguments: true },
344
- };
345
- }
346
- const CMD_META_CHARS = /([()\][%!^"`<>&|;, ])/g;
347
- // Backslash-escape embedded quotes per MS C runtime convention, wrap in
348
- // quotes, then caret-escape cmd.exe metacharacters.
349
- function escapeCmdArg(arg) {
350
- const quoted = `"${arg
351
- .replace(/(\\*)"/g, '$1$1\\"')
352
- .replace(/(\\*)$/, '$1$1')}"`;
353
- return quoted.replace(CMD_META_CHARS, '^$1');
354
- }
355
- function escapeCmdCommand(arg) {
356
- // cmd.exe interprets the command portion through an extra parsing pass;
357
- // apply the caret-escape twice so the .cmd shim sees the original.
358
- return escapeCmdArg(arg).replace(CMD_META_CHARS, '^$1');
359
- }
360
178
  async function promptAmbiguous(cause) {
361
179
  // stderr blank line so the spacer lands in the same stream as output.warn
362
180
  // and the prompt — buffered stdout could otherwise reorder it and glue the
@@ -0,0 +1 @@
1
+ export declare function restoreTermiosAfterAgent(): void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.restoreTermiosAfterAgent = restoreTermiosAfterAgent;
4
+ const child_process_1 = require("child_process");
5
+ function restoreTermiosAfterAgent() {
6
+ if (process.platform === 'win32')
7
+ return;
8
+ if (!process.stdin.isTTY)
9
+ return;
10
+ try {
11
+ // Not setRawMode(false): it short-circuits when libuv's per-handle mode
12
+ // is already NORMAL, even after the agent changed termios out-of-band.
13
+ // `stty sane` goes through the kernel instead.
14
+ (0, child_process_1.execSync)('stty sane < /dev/tty', {
15
+ stdio: ['ignore', 'ignore', 'ignore'],
16
+ windowsHide: true,
17
+ });
18
+ // Carriage-return + clear to end of screen, to wipe any agent TUI
19
+ // cells below our row that subsequent log lines won't overwrite
20
+ // (e.g. a status footer past where our text wraps).
21
+ process.stdout.write('\r\x1B[J');
22
+ }
23
+ catch {
24
+ // Best-effort: if stty isn't on PATH or /dev/tty isn't accessible, the
25
+ // worst case is the pre-existing staircase + cell-bleed output.
26
+ }
27
+ }
@@ -10,14 +10,17 @@ export type { AgentId };
10
10
  */
11
11
  export declare const MIGRATE_RUNS_RELATIVE_DIR = ".nx/migrate-runs";
12
12
  /**
13
- * The one subtree of a run directory an agent writes: its handoff files.
14
- * Everything beside it is state Nx owns and reads back, the orchestrator's
15
- * run state and plan snapshots included, so the pre-authorized write scope
16
- * stops at this segment. Package names make up the rest of a handoff path,
17
- * so without it they would occupy the run directory's top level and leave Nx
18
- * no name it could add there safely.
13
+ * The one subtree of a run directory an agent writes; everything beside it is
14
+ * state Nx owns, so the pre-authorized write scope stops here. Handoff names
15
+ * derive from step ids or package and migration names, so flattening them into
16
+ * the run dir would leave Nx no name it could safely add.
19
17
  */
20
18
  export declare const HANDOFFS_DIR_NAME = "handoffs";
19
+ /**
20
+ * Sibling subtree holding the per-step prompt files Nx writes for the agent
21
+ * to read. They stay out of `handoffs/`, which is the agent's to write.
22
+ */
23
+ export declare const PROMPTS_DIR_NAME = "prompts";
21
24
  export declare function isHandoffGitignoreMigration(m: {
22
25
  package: string;
23
26
  name: string;
@@ -38,10 +41,22 @@ export interface DetectedInstalledAgent {
38
41
  * Inputs the runner provides when asking an agent definition to build its
39
42
  * spawn arguments. Kept minimal — agent-specific quirks (e.g. transient agent
40
43
  * name for OpenCode) are encoded inside the definition, not here.
44
+ *
45
+ * Both prompts are written to disk (see `instruction-files.ts`) and reached
46
+ * through `systemPromptFilePath` / `instructionsPointer`. The inline fields
47
+ * below are the exception, for agents that cannot be pointed at a file.
41
48
  */
42
49
  export interface InvocationContext {
43
- systemContext: string;
44
- userPrompt: string;
50
+ /** Absolute path of the file holding the step's system prompt. */
51
+ systemPromptFilePath: string;
52
+ /** Verbatim system prompt, only for a step with no file-loading path. */
53
+ systemPrompt: string;
54
+ /** Single-line command-line text pointing the agent at its instructions. */
55
+ instructionsPointer: string;
56
+ /** Inline handoff contract and pointer to `systemPromptFilePath`. */
57
+ inlineSystemContext: string;
58
+ /** Shorter `inlineSystemContext`, substituted on Windows shim overflow. */
59
+ inlineSystemContextFallback: string;
45
60
  workspaceRoot: string;
46
61
  /**
47
62
  * Name of the run directory under `MIGRATE_RUNS_RELATIVE_DIR` holding this
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HANDOFFS_DIR_NAME = exports.MIGRATE_RUNS_RELATIVE_DIR = void 0;
3
+ exports.PROMPTS_DIR_NAME = exports.HANDOFFS_DIR_NAME = exports.MIGRATE_RUNS_RELATIVE_DIR = void 0;
4
4
  exports.isHandoffGitignoreMigration = isHandoffGitignoreMigration;
5
5
  /**
6
6
  * Workspace-relative directory holding all migrate-run scratch: a run
@@ -12,14 +12,17 @@ exports.isHandoffGitignoreMigration = isHandoffGitignoreMigration;
12
12
  */
13
13
  exports.MIGRATE_RUNS_RELATIVE_DIR = '.nx/migrate-runs';
14
14
  /**
15
- * The one subtree of a run directory an agent writes: its handoff files.
16
- * Everything beside it is state Nx owns and reads back, the orchestrator's
17
- * run state and plan snapshots included, so the pre-authorized write scope
18
- * stops at this segment. Package names make up the rest of a handoff path,
19
- * so without it they would occupy the run directory's top level and leave Nx
20
- * no name it could add there safely.
15
+ * The one subtree of a run directory an agent writes; everything beside it is
16
+ * state Nx owns, so the pre-authorized write scope stops here. Handoff names
17
+ * derive from step ids or package and migration names, so flattening them into
18
+ * the run dir would leave Nx no name it could safely add.
21
19
  */
22
20
  exports.HANDOFFS_DIR_NAME = 'handoffs';
21
+ /**
22
+ * Sibling subtree holding the per-step prompt files Nx writes for the agent
23
+ * to read. They stay out of `handoffs/`, which is the agent's to write.
24
+ */
25
+ exports.PROMPTS_DIR_NAME = 'prompts';
23
26
  /**
24
27
  * Composite identity of the v23 migration that adds `.nx/migrate-runs` to
25
28
  * `.gitignore`. Hard-coded because the agentic preflight is a deliberate
@@ -0,0 +1,33 @@
1
+ import type { SpawnOptions } from 'child_process';
2
+ export declare function quoteCmdArg(arg: string): string;
3
+ export declare function caretEscape(quoted: string): string;
4
+ /**
5
+ * Stops cmd.exe expanding `%VAR%` inside an argument. A caret cannot escape
6
+ * `%`, since expansion runs before caret processing, so each `%` becomes
7
+ * `%%cd:~,%`: `%cd:~,%` is a zero-length substring of a built-in and expands to
8
+ * nothing, leaving the leading `%`. Runs after the caret passes so the `,` it
9
+ * introduces stays uncareted, which the substring syntax requires.
10
+ */
11
+ export declare function neutralizePercent(escaped: string): string;
12
+ export declare const WINDOWS_COMMAND_LINE_LIMIT = 8191;
13
+ export declare const WINDOWS_COMMAND_LINE_BUDGET: number;
14
+ export interface AdaptedSpawn {
15
+ binary: string;
16
+ args: string[];
17
+ options: SpawnOptions;
18
+ /**
19
+ * Length of the command line Windows will receive. Set only on the `cmd.exe`
20
+ * wrapper path.
21
+ */
22
+ commandLineLength?: number;
23
+ }
24
+ export declare function withinCommandLineBudget(adapted: AdaptedSpawn): boolean;
25
+ /**
26
+ * Node's `spawn` cannot directly execute `.cmd` / `.bat` shims on Windows;
27
+ * `which` resolves to those when an agent was installed via npm. Wrap them in
28
+ * a `cmd.exe /c` invocation with `windowsVerbatimArguments` so quoting follows
29
+ * the cmd.exe convention rather than Node's default cooking.
30
+ *
31
+ * On non-Windows or for non-shim binaries this is a passthrough.
32
+ */
33
+ export declare function adaptSpawnForWindowsShim(binary: string, args: readonly string[], options: SpawnOptions): AdaptedSpawn;