@ohos-ports/nx 23.2.1-beta.1 → 23.3.0-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 (351) hide show
  1. package/README.md +1 -1
  2. package/dist/bin/init-local.js +7 -1
  3. package/dist/nx-cloud-internals.d.ts +1 -0
  4. package/dist/nx-cloud-internals.js +9 -0
  5. package/dist/plugins/package-json.js +1 -1
  6. package/dist/src/command-line/add/add.js +5 -1
  7. package/dist/src/command-line/affected/affected.js +70 -9
  8. package/dist/src/command-line/affected/command-object.js +1 -1
  9. package/dist/src/command-line/format/format.js +2 -18
  10. package/dist/src/command-line/graph/graph.d.ts +31 -0
  11. package/dist/src/command-line/graph/graph.js +113 -20
  12. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +0 -3
  13. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +0 -3
  14. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +0 -3
  15. package/dist/src/command-line/init/implementation/angular/index.js +0 -3
  16. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +0 -3
  17. package/dist/src/command-line/init/implementation/format.js +2 -3
  18. package/dist/src/command-line/init/implementation/utils.d.ts +0 -1
  19. package/dist/src/command-line/init/implementation/utils.js +6 -9
  20. package/dist/src/command-line/init/init-v2.js +0 -3
  21. package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +25 -0
  22. package/dist/src/command-line/migrate/agentic/capture-generator-output.js +121 -5
  23. package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +21 -0
  24. package/dist/src/command-line/migrate/agentic/close-agent-session.js +126 -0
  25. package/dist/src/command-line/migrate/agentic/definitions.d.ts +24 -0
  26. package/dist/src/command-line/migrate/agentic/definitions.js +79 -20
  27. package/dist/src/command-line/migrate/agentic/format-command.d.ts +14 -0
  28. package/dist/src/command-line/migrate/agentic/format-command.js +44 -0
  29. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +3 -3
  30. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +3 -3
  31. package/dist/src/command-line/migrate/agentic/handoff.d.ts +50 -17
  32. package/dist/src/command-line/migrate/agentic/handoff.js +166 -24
  33. package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +23 -0
  34. package/dist/src/command-line/migrate/agentic/instruction-files.js +41 -0
  35. package/dist/src/command-line/migrate/agentic/master/invocations.d.ts +12 -0
  36. package/dist/src/command-line/migrate/agentic/master/invocations.js +54 -0
  37. package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +16 -0
  38. package/dist/src/command-line/migrate/agentic/master/run-master-session.js +175 -0
  39. package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +31 -0
  40. package/dist/src/command-line/migrate/agentic/master/spawn-master.js +222 -0
  41. package/dist/src/command-line/migrate/agentic/prompts/final-validation.d.ts +13 -0
  42. package/dist/src/command-line/migrate/agentic/prompts/final-validation.js +41 -0
  43. package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +17 -0
  44. package/dist/src/command-line/migrate/agentic/prompts/fragments.js +90 -0
  45. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +4 -3
  46. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +25 -1
  47. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +57 -34
  48. package/dist/src/command-line/migrate/agentic/run-step.js +28 -4
  49. package/dist/src/command-line/migrate/agentic/runner.d.ts +3 -15
  50. package/dist/src/command-line/migrate/agentic/runner.js +57 -239
  51. package/dist/src/command-line/migrate/agentic/terminal-repair.d.ts +1 -0
  52. package/dist/src/command-line/migrate/agentic/terminal-repair.js +27 -0
  53. package/dist/src/command-line/migrate/agentic/types.d.ts +23 -8
  54. package/dist/src/command-line/migrate/agentic/types.js +10 -7
  55. package/dist/src/command-line/migrate/agentic/windows-cmd.d.ts +33 -0
  56. package/dist/src/command-line/migrate/agentic/windows-cmd.js +88 -0
  57. package/dist/src/command-line/migrate/command-object.d.ts +2 -0
  58. package/dist/src/command-line/migrate/command-object.js +11 -1
  59. package/dist/src/command-line/migrate/deferred-output.d.ts +44 -0
  60. package/dist/src/command-line/migrate/deferred-output.js +92 -0
  61. package/dist/src/command-line/migrate/execute-migration.d.ts +9 -3
  62. package/dist/src/command-line/migrate/execute-migration.js +53 -16
  63. package/dist/src/command-line/migrate/migrate-analytics.d.ts +34 -9
  64. package/dist/src/command-line/migrate/migrate-analytics.js +71 -10
  65. package/dist/src/command-line/migrate/migrate-commits.d.ts +5 -4
  66. package/dist/src/command-line/migrate/migrate-commits.js +16 -6
  67. package/dist/src/command-line/migrate/migrate-config.d.ts +5 -2
  68. package/dist/src/command-line/migrate/migrate-config.js +19 -11
  69. package/dist/src/command-line/migrate/migrate-output.d.ts +3 -7
  70. package/dist/src/command-line/migrate/migrate-output.js +3 -7
  71. package/dist/src/command-line/migrate/migrate.d.ts +3 -0
  72. package/dist/src/command-line/migrate/migrate.js +183 -46
  73. package/dist/src/command-line/migrate/resolve-package-version.js +2 -19
  74. package/dist/src/command-line/migrate/run/agent-output.d.ts +11 -0
  75. package/dist/src/command-line/migrate/run/agent-output.js +21 -2
  76. package/dist/src/command-line/migrate/run/agent-work-payload.d.ts +37 -0
  77. package/dist/src/command-line/migrate/run/agent-work-payload.js +156 -0
  78. package/dist/src/command-line/migrate/run/atomic-write.d.ts +8 -0
  79. package/dist/src/command-line/migrate/run/atomic-write.js +17 -0
  80. package/dist/src/command-line/migrate/run/broker.d.ts +150 -0
  81. package/dist/src/command-line/migrate/run/broker.js +568 -0
  82. package/dist/src/command-line/migrate/run/clean-retry.d.ts +12 -0
  83. package/dist/src/command-line/migrate/run/clean-retry.js +99 -0
  84. package/dist/src/command-line/migrate/run/existing-run-report.d.ts +55 -0
  85. package/dist/src/command-line/migrate/run/existing-run-report.js +227 -0
  86. package/dist/src/command-line/migrate/run/give-up.d.ts +41 -0
  87. package/dist/src/command-line/migrate/run/give-up.js +148 -0
  88. package/dist/src/command-line/migrate/run/index.d.ts +9 -6
  89. package/dist/src/command-line/migrate/run/index.js +21 -2
  90. package/dist/src/command-line/migrate/run/issues.d.ts +127 -0
  91. package/dist/src/command-line/migrate/run/issues.js +1121 -0
  92. package/dist/src/command-line/migrate/run/orchestrator.d.ts +59 -1
  93. package/dist/src/command-line/migrate/run/orchestrator.js +1529 -457
  94. package/dist/src/command-line/migrate/run/run-id.d.ts +0 -8
  95. package/dist/src/command-line/migrate/run/run-id.js +0 -30
  96. package/dist/src/command-line/migrate/run/run-state.d.ts +77 -17
  97. package/dist/src/command-line/migrate/run/run-state.js +263 -32
  98. package/dist/src/command-line/migrate/run/runbook.d.ts +18 -0
  99. package/dist/src/command-line/migrate/run/runbook.js +118 -0
  100. package/dist/src/command-line/migrate/run/state-lock.d.ts +33 -2
  101. package/dist/src/command-line/migrate/run/state-lock.js +128 -2
  102. package/dist/src/command-line/migrate/run/state-machine.d.ts +50 -1
  103. package/dist/src/command-line/migrate/run/state-machine.js +339 -26
  104. package/dist/src/command-line/migrate/run/util.d.ts +3 -1
  105. package/dist/src/command-line/migrate/run/util.js +24 -3
  106. package/dist/src/command-line/migrate/run/worker.js +290 -129
  107. package/dist/src/command-line/migrate/step-actions.d.ts +1 -1
  108. package/dist/src/command-line/migrate/step-actions.js +7 -1
  109. package/dist/src/command-line/migrate/text.d.ts +6 -0
  110. package/dist/src/command-line/migrate/text.js +25 -0
  111. package/dist/src/command-line/migrate/version-skew-guard.js +2 -0
  112. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +5 -11
  113. package/dist/src/command-line/release/publish.js +11 -8
  114. package/dist/src/command-line/release/utils/get-touched-projects-for-group.js +3 -3
  115. package/dist/src/command-line/release/utils/release-graph.js +1 -1
  116. package/dist/src/command-line/release/utils/remote-release-clients/github.js +5 -8
  117. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +3 -3
  118. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +4 -2
  119. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +37 -3
  120. package/dist/src/command-line/release/version/version-actions.d.ts +3 -0
  121. package/dist/src/command-line/reset/reset.js +10 -4
  122. package/dist/src/command-line/run/run-one.js +5 -1
  123. package/dist/src/command-line/run-many/run-many.js +6 -12
  124. package/dist/src/command-line/show/command-object.js +1 -1
  125. package/dist/src/command-line/show/projects.js +52 -1
  126. package/dist/src/command-line/yargs-utils/shared-options.d.ts +5 -1
  127. package/dist/src/command-line/yargs-utils/shared-options.js +38 -4
  128. package/dist/src/config/task-graph.d.ts +1 -1
  129. package/dist/src/config/workspace-json-project-json.d.ts +23 -1
  130. package/dist/src/core/graph/main.js +1 -1
  131. package/dist/src/core/graph/runtime.js +1 -1
  132. package/dist/src/core/graph/styles.js +1 -1
  133. package/dist/src/daemon/client/client.d.ts +14 -8
  134. package/dist/src/daemon/client/client.js +41 -12
  135. package/dist/src/daemon/message-types/get-plugin-capabilities.d.ts +5 -0
  136. package/dist/src/daemon/message-types/get-plugin-capabilities.js +11 -0
  137. package/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts +3 -2
  138. package/dist/src/daemon/message-types/select-affected-tasks.d.ts +21 -0
  139. package/dist/src/daemon/message-types/select-affected-tasks.js +11 -0
  140. package/dist/src/daemon/message-types/ultracache-configuration-version.d.ts +8 -0
  141. package/dist/src/daemon/message-types/ultracache-configuration-version.js +2 -0
  142. package/dist/src/daemon/server/dotenv-graph-changes.d.ts +1 -1
  143. package/dist/src/daemon/server/dotenv-graph-changes.js +2 -2
  144. package/dist/src/daemon/server/handle-get-plugin-capabilities.d.ts +2 -0
  145. package/dist/src/daemon/server/handle-get-plugin-capabilities.js +13 -0
  146. package/dist/src/daemon/server/handle-hash-tasks.d.ts +10 -2
  147. package/dist/src/daemon/server/handle-hash-tasks.js +18 -3
  148. package/dist/src/daemon/server/handle-select-affected-tasks.d.ts +3 -0
  149. package/dist/src/daemon/server/handle-select-affected-tasks.js +26 -0
  150. package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +3 -2
  151. package/dist/src/daemon/server/{handle-outputs-changes.d.ts → handle-watch-events.d.ts} +4 -4
  152. package/dist/src/daemon/server/{handle-outputs-changes.js → handle-watch-events.js} +36 -37
  153. package/dist/src/daemon/server/outputs-tracking.d.ts +7 -19
  154. package/dist/src/daemon/server/outputs-tracking.js +7 -107
  155. package/dist/src/daemon/server/planning-context.d.ts +8 -0
  156. package/dist/src/daemon/server/planning-context.js +18 -0
  157. package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +22 -7
  158. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +104 -74
  159. package/dist/src/daemon/server/restart-checks.d.ts +22 -0
  160. package/dist/src/daemon/server/restart-checks.js +77 -0
  161. package/dist/src/daemon/server/server.d.ts +1 -0
  162. package/dist/src/daemon/server/server.js +54 -30
  163. package/dist/src/daemon/server/shutdown-utils.d.ts +0 -5
  164. package/dist/src/daemon/server/shutdown-utils.js +3 -26
  165. package/dist/src/daemon/server/ultracache-configuration-state.d.ts +7 -0
  166. package/dist/src/daemon/server/ultracache-configuration-state.js +36 -0
  167. package/dist/src/devkit-internals.d.ts +3 -1
  168. package/dist/src/devkit-internals.js +8 -3
  169. package/dist/src/executors/run-commands/run-commands.impl.d.ts +2 -1
  170. package/dist/src/executors/run-commands/run-commands.impl.js +19 -5
  171. package/dist/src/executors/run-commands/running-tasks.d.ts +5 -4
  172. package/dist/src/executors/run-commands/running-tasks.js +13 -13
  173. package/dist/src/hasher/create-task-hasher.d.ts +8 -1
  174. package/dist/src/hasher/create-task-hasher.js +13 -3
  175. package/dist/src/hasher/hash-plan-inspector.js +2 -2
  176. package/dist/src/hasher/hash-task.d.ts +2 -2
  177. package/dist/src/hasher/hash-task.js +28 -17
  178. package/dist/src/hasher/native-task-hasher-impl.d.ts +20 -4
  179. package/dist/src/hasher/native-task-hasher-impl.js +75 -9
  180. package/dist/src/hasher/task-hasher.d.ts +24 -7
  181. package/dist/src/hasher/task-hasher.js +27 -8
  182. package/dist/src/hasher/task-planning-context.d.ts +13 -0
  183. package/dist/src/hasher/task-planning-context.js +12 -0
  184. package/dist/src/native/index.d.ts +582 -21
  185. package/dist/src/native/index.js +3 -5
  186. package/dist/src/native/native-bindings.js +13 -1
  187. package/dist/src/native/nx.openharmony-arm64.node +0 -0
  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 +31 -48
  335. package/readme-template.md +16 -0
  336. package/schemas/nx-schema.json +38 -0
  337. package/schemas/project-schema.json +35 -0
  338. package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +0 -9
  339. package/dist/src/daemon/server/file-watching/route-workspace-changes.js +0 -76
  340. package/dist/src/daemon/server/watcher.d.ts +0 -18
  341. package/dist/src/daemon/server/watcher.js +0 -126
  342. package/dist/src/nx-cloud/utilities/axios.d.ts +0 -4
  343. package/dist/src/nx-cloud/utilities/axios.js +0 -17
  344. package/dist/src/project-graph/affected/locators/project-glob-changes.d.ts +0 -2
  345. package/dist/src/project-graph/affected/locators/project-glob-changes.js +0 -47
  346. package/dist/src/project-graph/affected/locators/workspace-json-changes.d.ts +0 -4
  347. package/dist/src/project-graph/affected/locators/workspace-json-changes.js +0 -47
  348. package/dist/src/project-graph/affected/locators/workspace-projects.d.ts +0 -3
  349. package/dist/src/project-graph/affected/locators/workspace-projects.js +0 -74
  350. package/dist/src/utils/collapse-expanded-outputs.d.ts +0 -10
  351. package/dist/src/utils/collapse-expanded-outputs.js +0 -72
@@ -10,7 +10,6 @@ exports.toErrorString = toErrorString;
10
10
  exports.readErrorStderr = readErrorStderr;
11
11
  exports.extractErrorName = extractErrorName;
12
12
  exports.initCloud = initCloud;
13
- exports.setNeverConnectToCloud = setNeverConnectToCloud;
14
13
  exports.addVsCodeRecommendedExtensions = addVsCodeRecommendedExtensions;
15
14
  exports.markRootPackageJsonAsNxProjectLegacy = markRootPackageJsonAsNxProjectLegacy;
16
15
  exports.markPackageJsonAsNxProject = markPackageJsonAsNxProject;
@@ -253,13 +252,17 @@ function updateGitIgnore(root) {
253
252
  }
254
253
  function runInstall(repoRoot, packageManager = (0, package_manager_1.detectPackageManager)(repoRoot), pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager)) {
255
254
  let command = pmc.install;
255
+ const env = { ...process.env };
256
256
  // Plugins added during init can pull build-script deps whose allowBuilds
257
257
  // entries are only recorded by their init generators after this install;
258
- // warn and skip for this one install, like pnpm 10 did.
258
+ // warn and skip for this one install, like pnpm 10 did. pnpm 12 gave
259
+ // `--config` a meaning of its own and takes the setting from the
260
+ // environment instead.
259
261
  if (packageManager === 'pnpm') {
260
262
  try {
261
263
  if ((0, semver_1.gte)((0, package_manager_1.getPackageManagerVersion)('pnpm', repoRoot), '11.0.0')) {
262
264
  command += ' --config.strictDepBuilds=false';
265
+ env.PNPM_CONFIG_STRICT_DEP_BUILDS = 'false';
263
266
  }
264
267
  }
265
268
  catch {
@@ -272,6 +275,7 @@ function runInstall(repoRoot, packageManager = (0, package_manager_1.detectPacka
272
275
  encoding: 'utf8',
273
276
  cwd: repoRoot,
274
277
  windowsHide: true,
278
+ env,
275
279
  });
276
280
  }
277
281
  catch (e) {
@@ -341,13 +345,6 @@ async function initCloud(installationSource) {
341
345
  });
342
346
  await (0, connect_to_nx_cloud_1.printSuccessMessage)(token, installationSource);
343
347
  }
344
- function setNeverConnectToCloud(repoRoot) {
345
- const nxJsonPath = (0, path_1.join)(repoRoot, 'nx.json');
346
- const nxJson = (0, fileutils_1.readJsonFile)(nxJsonPath);
347
- nxJson.neverConnectToCloud = true;
348
- (0, fileutils_1.writeJsonFile)(nxJsonPath, nxJson);
349
- (0, format_1.recordInitWrite)(nxJsonPath);
350
- }
351
348
  function addVsCodeRecommendedExtensions(repoRoot, extensions) {
352
349
  const vsCodeExtensionsPath = (0, path_1.join)(repoRoot, '.vscode/extensions.json');
353
350
  if ((0, fileutils_1.fileExists)(vsCodeExtensionsPath)) {
@@ -379,9 +379,6 @@ async function runInit(options, baseMeta) {
379
379
  if (nxCloudChoice === 'yes') {
380
380
  await (0, utils_1.initCloud)('nx-init');
381
381
  }
382
- else if (nxCloudChoice === 'never') {
383
- (0, utils_1.setNeverConnectToCloud)(repoRoot);
384
- }
385
382
  const analyticsPrompt = await (0, analytics_prompt_1.ensureAnalyticsPreferenceSet)(repoRoot, options.interactive);
386
383
  await (0, ab_testing_1.recordStat)({
387
384
  command: 'init',
@@ -3,11 +3,36 @@
3
3
  * preserving the original behavior. Does not intercept
4
4
  * `process.{stdout,stderr}.write` — those bypass `console` and would also
5
5
  * pick up unrelated framework output. Restoration is idempotent.
6
+ *
7
+ * `flush()` returns at most `MAX_GENERATOR_OUTPUT_BYTES`: up to the first
8
+ * `HEAD_BYTES` of output, a marker with the omitted byte count, and the most
9
+ * recent output. The terminal still receives everything through the tee.
6
10
  */
7
11
  export interface GeneratorOutputCapture {
8
12
  flush(): string;
9
13
  restore(): void;
10
14
  }
15
+ export declare const MAX_GENERATOR_OUTPUT_BYTES = 16384;
16
+ export declare const MARKER_BYTES: number;
17
+ export declare class BoundedOutput {
18
+ private readonly head;
19
+ private headBytes;
20
+ private headOpen;
21
+ private headSplit;
22
+ private readonly tail;
23
+ private tailBytes;
24
+ private omitted;
25
+ append(record: string): void;
26
+ render(): string;
27
+ }
28
+ export declare class BoundedChunks {
29
+ private head;
30
+ private headOpen;
31
+ private tail;
32
+ private omitted;
33
+ append(chunk: string): void;
34
+ render(): string;
35
+ }
11
36
  export declare function installGeneratorOutputCapture(): GeneratorOutputCapture;
12
37
  /**
13
38
  * Convenience wrapper that installs the capture, runs `fn`, restores on
@@ -1,9 +1,127 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BoundedChunks = exports.BoundedOutput = exports.MARKER_BYTES = exports.MAX_GENERATOR_OUTPUT_BYTES = void 0;
3
4
  exports.installGeneratorOutputCapture = installGeneratorOutputCapture;
4
5
  exports.withGeneratorOutputCapture = withGeneratorOutputCapture;
5
6
  const node_util_1 = require("node:util");
6
7
  const logger_1 = require("../../../utils/logger");
8
+ const handoff_1 = require("./handoff");
9
+ exports.MAX_GENERATOR_OUTPUT_BYTES = 16384;
10
+ const HEAD_BYTES = 4096;
11
+ const omittedMarker = (omitted) => `[nx migrate: ${omitted} bytes of output omitted]`;
12
+ // Reserved at the widest number spelling so a growing count cannot push a
13
+ // flush over the cap.
14
+ exports.MARKER_BYTES = Buffer.byteLength(`\n${omittedMarker(Number.MAX_VALUE)}\n`);
15
+ const TAIL_LIMIT = exports.MAX_GENERATOR_OUTPUT_BYTES - HEAD_BYTES - exports.MARKER_BYTES;
16
+ // Keeps the last `maxBytes` of `value`, cut on a code point.
17
+ function keepTailUtf8(value, maxBytes) {
18
+ let start = value.length;
19
+ let kept = 0;
20
+ while (start > 0) {
21
+ const low = value.charCodeAt(start - 1);
22
+ const high = start > 1 ? value.charCodeAt(start - 2) : 0;
23
+ const from = low >= 0xdc00 && low <= 0xdfff && high >= 0xd800 && high <= 0xdbff
24
+ ? start - 2
25
+ : start - 1;
26
+ const bytes = Buffer.byteLength(value.slice(from, start));
27
+ if (kept + bytes > maxBytes)
28
+ break;
29
+ kept += bytes;
30
+ start = from;
31
+ }
32
+ return value.slice(start);
33
+ }
34
+ // The head/marker/tail buffer behind `flush()` above.
35
+ class BoundedOutput {
36
+ constructor() {
37
+ this.head = [];
38
+ this.headBytes = 0;
39
+ this.headOpen = true;
40
+ // The head ends mid-record, so no newline separates it from the tail.
41
+ this.headSplit = false;
42
+ this.tail = [];
43
+ this.tailBytes = 0;
44
+ this.omitted = 0;
45
+ }
46
+ append(record) {
47
+ if (this.headOpen) {
48
+ const separator = this.head.length ? 1 : 0;
49
+ const bytes = Buffer.byteLength(record);
50
+ if (this.headBytes + separator + bytes <= HEAD_BYTES) {
51
+ this.head.push(record);
52
+ this.headBytes += separator + bytes;
53
+ return;
54
+ }
55
+ this.headOpen = false;
56
+ const prefix = (0, handoff_1.truncateUtf8)(record, HEAD_BYTES - this.headBytes - separator);
57
+ if (prefix) {
58
+ this.head.push(prefix);
59
+ this.headBytes += separator + Buffer.byteLength(prefix);
60
+ this.headSplit = true;
61
+ record = record.slice(prefix.length);
62
+ }
63
+ }
64
+ // Each tail record is charged its bytes plus a following newline; the last
65
+ // record's unused newline is one byte of slack at render time.
66
+ const cost = Buffer.byteLength(record) + 1;
67
+ this.tail.push({ text: record, cost });
68
+ this.tailBytes += cost;
69
+ while (this.tailBytes > TAIL_LIMIT && this.tail.length > 1) {
70
+ const dropped = this.tail.shift().cost;
71
+ this.tailBytes -= dropped;
72
+ this.omitted += dropped;
73
+ }
74
+ if (this.tailBytes > TAIL_LIMIT) {
75
+ const text = keepTailUtf8(this.tail[0].text, TAIL_LIMIT - 1);
76
+ const kept = Buffer.byteLength(text) + 1;
77
+ this.omitted += this.tailBytes - kept;
78
+ this.tail[0] = { text, cost: kept };
79
+ this.tailBytes = kept;
80
+ }
81
+ }
82
+ render() {
83
+ const head = this.head.join('\n');
84
+ const tail = this.tail.map((record) => record.text).join('\n');
85
+ if (this.omitted > 0) {
86
+ return `${head}\n${omittedMarker(this.omitted)}\n${tail}`;
87
+ }
88
+ if (!this.tail.length)
89
+ return head;
90
+ return this.headSplit ? head + tail : `${head}\n${tail}`;
91
+ }
92
+ }
93
+ exports.BoundedOutput = BoundedOutput;
94
+ // The same head/marker/tail bound over a byte stream: chunks carry no record
95
+ // boundary, so the cuts land on code points wherever the budgets run out and
96
+ // the result does not depend on how the stream was chunked.
97
+ class BoundedChunks {
98
+ constructor() {
99
+ this.head = '';
100
+ this.headOpen = true;
101
+ this.tail = '';
102
+ this.omitted = 0;
103
+ }
104
+ append(chunk) {
105
+ if (this.headOpen) {
106
+ const prefix = (0, handoff_1.truncateUtf8)(chunk, HEAD_BYTES - Buffer.byteLength(this.head));
107
+ this.head += prefix;
108
+ chunk = chunk.slice(prefix.length);
109
+ if (!chunk)
110
+ return;
111
+ this.headOpen = false;
112
+ }
113
+ const joined = this.tail + chunk;
114
+ this.tail = keepTailUtf8(joined, TAIL_LIMIT);
115
+ this.omitted += Buffer.byteLength(joined) - Buffer.byteLength(this.tail);
116
+ }
117
+ render() {
118
+ if (this.omitted > 0) {
119
+ return `${this.head}\n${omittedMarker(this.omitted)}\n${this.tail}`;
120
+ }
121
+ return this.head + this.tail;
122
+ }
123
+ }
124
+ exports.BoundedChunks = BoundedChunks;
7
125
  const CONSOLE_METHODS = [
8
126
  'log',
9
127
  'warn',
@@ -20,15 +138,13 @@ const NOOP_CAPTURE = {
20
138
  restore: () => { },
21
139
  };
22
140
  function installGeneratorOutputCapture() {
23
- // Refuse to layer if the previous install never restored. Returns a noop
24
- // handle so callers' `flush()` / `restore()` calls remain safe.
25
141
  for (const method of CONSOLE_METHODS) {
26
142
  if (console[method][CAPTURED_MARKER]) {
27
143
  logger_1.logger.verbose(`nx migrate: refusing to layer a second generator-output capture; the previous one was not restored. This typically means a caller skipped its \`try/finally\`. The inner caller's \`flush()\` will return empty, but its console output is still being captured by the outer install.`);
28
144
  return NOOP_CAPTURE;
29
145
  }
30
146
  }
31
- const buffer = [];
147
+ const buffer = new BoundedOutput();
32
148
  const originals = new Map();
33
149
  for (const method of CONSOLE_METHODS) {
34
150
  originals.set(method, console[method]);
@@ -36,7 +152,7 @@ function installGeneratorOutputCapture() {
36
152
  const wrapper = ((...args) => {
37
153
  original(...args);
38
154
  try {
39
- buffer.push((0, node_util_1.format)(...args));
155
+ buffer.append((0, node_util_1.format)(...args));
40
156
  }
41
157
  catch {
42
158
  // `format` is robust against the common pathologies but a user arg
@@ -55,7 +171,7 @@ function installGeneratorOutputCapture() {
55
171
  let restored = false;
56
172
  return {
57
173
  flush() {
58
- return buffer.join('\n');
174
+ return buffer.render();
59
175
  },
60
176
  restore() {
61
177
  if (restored)
@@ -0,0 +1,21 @@
1
+ import { type ChildProcess } from 'child_process';
2
+ export declare const AGENT_GRACEFUL_EXIT_MS = 5000;
3
+ export declare const FORCE_KILL_WAIT_MS = 500;
4
+ export interface ExitInfo {
5
+ code?: number | null;
6
+ signal?: NodeJS.Signals | null;
7
+ error?: Error;
8
+ }
9
+ export declare function waitForExit(child: ChildProcess): Promise<ExitInfo>;
10
+ /**
11
+ * Stops a running agent process.
12
+ *
13
+ * POSIX: SIGINT, then SIGKILL after a bounded wait. SIGTERM is skipped so a
14
+ * child that ignored the first graceful signal does not get a second one.
15
+ *
16
+ * Windows: `taskkill /T /F`. `child.kill` is a `TerminateProcess` call whatever
17
+ * the signal name, which on the `cmd.exe` shim path would kill the shim and
18
+ * orphan the agent. `taskkill` failures are swallowed.
19
+ */
20
+ export declare function closeAgentSession(child: ChildProcess, exitPromise: Promise<ExitInfo>, gracefulExitMs: number, forceKillWaitMs: number): Promise<void>;
21
+ export declare function raceWithTimeout(promise: Promise<unknown>, timeoutMs: number): Promise<void>;
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FORCE_KILL_WAIT_MS = exports.AGENT_GRACEFUL_EXIT_MS = void 0;
4
+ exports.waitForExit = waitForExit;
5
+ exports.closeAgentSession = closeAgentSession;
6
+ exports.raceWithTimeout = raceWithTimeout;
7
+ const child_process_1 = require("child_process");
8
+ exports.AGENT_GRACEFUL_EXIT_MS = 5_000;
9
+ // Safety bound after force-kill. SIGKILL normally reaps in microseconds;
10
+ // the bound exists for uninterruptible kernel calls or taskkill returning
11
+ // before the process actually exits.
12
+ exports.FORCE_KILL_WAIT_MS = 500;
13
+ // Merge window so a paired exit + error both land in one ExitInfo. On
14
+ // error-only paths like spawn ENOENT, where Node fires error but never exit,
15
+ // this timer is the only settlement mechanism.
16
+ const EXIT_MERGE_WINDOW_MS = 10;
17
+ function waitForExit(child) {
18
+ return new Promise((resolve) => {
19
+ const info = {};
20
+ let pending = null;
21
+ let settled = false;
22
+ const settle = () => {
23
+ if (settled)
24
+ return;
25
+ settled = true;
26
+ if (pending)
27
+ clearTimeout(pending);
28
+ resolve(info);
29
+ };
30
+ const onFirst = () => {
31
+ if (settled || pending)
32
+ return;
33
+ pending = setTimeout(settle, EXIT_MERGE_WINDOW_MS);
34
+ };
35
+ child.on('exit', (code, signal) => {
36
+ info.code = code;
37
+ info.signal = signal;
38
+ onFirst();
39
+ });
40
+ child.on('error', (error) => {
41
+ info.error = error;
42
+ onFirst();
43
+ });
44
+ });
45
+ }
46
+ /**
47
+ * Stops a running agent process.
48
+ *
49
+ * POSIX: SIGINT, then SIGKILL after a bounded wait. SIGTERM is skipped so a
50
+ * child that ignored the first graceful signal does not get a second one.
51
+ *
52
+ * Windows: `taskkill /T /F`. `child.kill` is a `TerminateProcess` call whatever
53
+ * the signal name, which on the `cmd.exe` shim path would kill the shim and
54
+ * orphan the agent. `taskkill` failures are swallowed.
55
+ */
56
+ async function closeAgentSession(child, exitPromise, gracefulExitMs, forceKillWaitMs) {
57
+ if (child.exitCode !== null || child.signalCode !== null)
58
+ return;
59
+ if (process.platform === 'win32') {
60
+ await forceKillWindowsTree(child, exitPromise, forceKillWaitMs);
61
+ return;
62
+ }
63
+ try {
64
+ child.kill('SIGINT');
65
+ }
66
+ catch {
67
+ // child already gone between the check above and here
68
+ return;
69
+ }
70
+ let escalation;
71
+ try {
72
+ await Promise.race([
73
+ exitPromise,
74
+ new Promise((resolve) => {
75
+ escalation = setTimeout(resolve, gracefulExitMs);
76
+ }),
77
+ ]);
78
+ }
79
+ finally {
80
+ if (escalation)
81
+ clearTimeout(escalation);
82
+ }
83
+ if (child.exitCode !== null || child.signalCode !== null)
84
+ return;
85
+ try {
86
+ child.kill('SIGKILL');
87
+ }
88
+ catch {
89
+ /* child already gone */
90
+ }
91
+ await raceWithTimeout(exitPromise, forceKillWaitMs);
92
+ }
93
+ async function forceKillWindowsTree(child, exitPromise, forceKillWaitMs) {
94
+ const pid = child.pid;
95
+ // No pid means spawn itself failed, which the guard in `closeAgentSession`
96
+ // normally short-circuits. Without one there is nothing to taskkill.
97
+ if (pid !== undefined) {
98
+ try {
99
+ (0, child_process_1.execSync)(`taskkill /T /F /PID ${pid}`, {
100
+ stdio: 'ignore',
101
+ windowsHide: true,
102
+ // Bound so a hung Windows shell can't block the orchestrator.
103
+ timeout: 2_000,
104
+ });
105
+ }
106
+ catch {
107
+ /* taskkill missing, pid already dead, or timed out */
108
+ }
109
+ }
110
+ await raceWithTimeout(exitPromise, forceKillWaitMs);
111
+ }
112
+ async function raceWithTimeout(promise, timeoutMs) {
113
+ let timer;
114
+ try {
115
+ await Promise.race([
116
+ promise,
117
+ new Promise((resolve) => {
118
+ timer = setTimeout(resolve, timeoutMs);
119
+ }),
120
+ ]);
121
+ }
122
+ finally {
123
+ if (timer)
124
+ clearTimeout(timer);
125
+ }
126
+ }
@@ -1,5 +1,29 @@
1
1
  import { AgentDefinition, AgentId } from './types';
2
+ /**
3
+ * Pre-authorizes the handoff write. Claude Code's default permission mode
4
+ * asks before a file write it has no allow rule for, so without this every
5
+ * step ends on an approval prompt for Nx's own handoff scratch.
6
+ *
7
+ * The rule reaches one run's handoffs and nothing else. Its own run
8
+ * directory also holds state Nx wrote and reads back, and the sibling
9
+ * directories belong to other runs, including an orchestrated run whose
10
+ * handoffs decide how its steps settle. `Edit` is the only tool name file
11
+ * rules are matched against, and it covers creating the file as well as
12
+ * correcting one already written. Prefix-less patterns resolve against the
13
+ * session cwd, which every caller pins to the workspace root.
14
+ *
15
+ * Returns null for a name it cannot express, which costs the approval prompt
16
+ * this exists to avoid. That beats widening the rule, and nothing narrower is
17
+ * available: Claude Code has no escape for a literal path.
18
+ */
19
+ export declare function claudeCodeHandoffAllowedTools(runDirName: string): string | null;
2
20
  export declare const claudeCodeDefinition: AgentDefinition;
21
+ /**
22
+ * Encodes a single-line TOML string for codex overrides. Codex treats a parse
23
+ * failure as literal text instead of reporting it, so the result is parsed
24
+ * back before it reaches the command line.
25
+ */
26
+ export declare function encodeTomlString(value: string): string;
3
27
  export declare const codexDefinition: AgentDefinition;
4
28
  export declare const opencodeDefinition: AgentDefinition;
5
29
  export declare const AGENT_DEFINITIONS: readonly AgentDefinition[];
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AGENT_DEFINITIONS = exports.opencodeDefinition = exports.codexDefinition = exports.claudeCodeDefinition = void 0;
4
+ exports.claudeCodeHandoffAllowedTools = claudeCodeHandoffAllowedTools;
5
+ exports.encodeTomlString = encodeTomlString;
4
6
  exports.getAgentDefinition = getAgentDefinition;
5
7
  const os_1 = require("os");
6
8
  const path_1 = require("path");
9
+ const smol_toml_1 = require("smol-toml");
7
10
  const types_1 = require("./types");
8
11
  // --- Claude Code ---------------------------------------------------------
9
12
  function claudeCodeWellKnownPaths() {
@@ -34,7 +37,7 @@ const RULE_SAFE_RUN_DIR_NAME = /^[A-Za-z0-9][A-Za-z0-9._+-]*$/;
34
37
  * handoffs decide how its steps settle. `Edit` is the only tool name file
35
38
  * rules are matched against, and it covers creating the file as well as
36
39
  * correcting one already written. Prefix-less patterns resolve against the
37
- * session cwd, pinned to the workspace root below.
40
+ * session cwd, which every caller pins to the workspace root.
38
41
  *
39
42
  * Returns null for a name it cannot express, which costs the approval prompt
40
43
  * this exists to avoid. That beats widening the rule, and nothing narrower is
@@ -49,15 +52,14 @@ function claudeCodeHandoffAllowedTools(runDirName) {
49
52
  function claudeCodeBuildInteractive(ctx) {
50
53
  const allowedTools = claudeCodeHandoffAllowedTools(ctx.runDirName);
51
54
  return {
52
- // `--allowedTools` is variadic (space/comma separated): a positional
53
- // placed right after its value gets swallowed as another rule. The rules
54
- // must stay in one comma-joined element with a non-variadic flag
55
- // (`--system-prompt`) between them and the user prompt.
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.
56
58
  args: [
57
59
  ...(allowedTools ? ['--allowedTools', allowedTools] : []),
58
- '--system-prompt',
59
- ctx.systemContext,
60
- ctx.userPrompt,
60
+ '--system-prompt-file',
61
+ ctx.systemPromptFilePath,
62
+ ctx.instructionsPointer,
61
63
  ],
62
64
  cwd: ctx.workspaceRoot,
63
65
  };
@@ -74,14 +76,42 @@ function codexWellKnownPaths() {
74
76
  return [];
75
77
  }
76
78
  // No handoff permission flag: codex's default sandbox already allows writes
77
- // inside the cwd tree without prompting, and a user-hardened read-only config
78
- // is a deliberate choice we don't override.
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.
79
85
  function codexBuildInteractive(ctx) {
80
86
  return {
81
- args: ['-c', `developer_instructions=${ctx.systemContext}`, ctx.userPrompt],
87
+ args: [
88
+ '-c',
89
+ `developer_instructions=${encodeTomlString(ctx.inlineSystemContext)}`,
90
+ ctx.instructionsPointer,
91
+ ],
82
92
  cwd: ctx.workspaceRoot,
83
93
  };
84
94
  }
95
+ /**
96
+ * Encodes a single-line TOML string for codex overrides. Codex treats a parse
97
+ * failure as literal text instead of reporting it, so the result is parsed
98
+ * back before it reaches the command line.
99
+ */
100
+ function encodeTomlString(value) {
101
+ // JSON escapes every control TOML rejects except DEL, which it leaves raw.
102
+ const encoded = JSON.stringify(value).replace(/\x7f/g, '\\u007F');
103
+ let decoded;
104
+ try {
105
+ decoded = (0, smol_toml_1.parse)(`value = ${encoded}`).value;
106
+ }
107
+ catch (err) {
108
+ throw new Error(`Could not encode the agent's system context as TOML for OpenAI Codex: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
109
+ }
110
+ if (decoded !== value) {
111
+ throw new Error(`Encoding the agent's system context as TOML for OpenAI Codex did not round-trip; refusing to run the agent on altered instructions.`);
112
+ }
113
+ return encoded;
114
+ }
85
115
  exports.codexDefinition = {
86
116
  id: 'codex',
87
117
  displayName: 'OpenAI Codex',
@@ -110,25 +140,54 @@ function opencodeWellKnownPaths() {
110
140
  return candidates;
111
141
  }
112
142
  // No handoff permission config: opencode's `edit` permission defaults to
113
- // allow, and injecting one would clobber (not merge with) a user's own
114
- // permission patterns.
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.
115
150
  function opencodeBuildInteractive(ctx) {
116
- const config = {
117
- agent: {
118
- [OPENCODE_TRANSIENT_AGENT_NAME]: { prompt: ctx.systemContext },
119
- },
120
- };
121
151
  return {
122
152
  args: [
123
153
  '--agent',
124
154
  OPENCODE_TRANSIENT_AGENT_NAME,
125
155
  '--prompt',
126
- ctx.userPrompt,
156
+ ctx.instructionsPointer,
127
157
  ],
128
- env: { OPENCODE_CONFIG_CONTENT: JSON.stringify(config) },
158
+ env: { OPENCODE_CONFIG_CONTENT: opencodeConfigContent(ctx) },
129
159
  cwd: ctx.workspaceRoot,
130
160
  };
131
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
+ }
132
191
  exports.opencodeDefinition = {
133
192
  id: 'opencode',
134
193
  displayName: 'OpenCode',
@@ -0,0 +1,14 @@
1
+ import { FormatterType } from '../../../utils/formatters';
2
+ /**
3
+ * The command the agent runs over the files it changed, with a `<paths>`
4
+ * placeholder. `--` keeps a path that starts with `-` from being read as an
5
+ * option.
6
+ */
7
+ export declare function formatCommandFor(formatter: FormatterType, pmExec: string): string;
8
+ /**
9
+ * Resolved per dispense so a migration's formatter change takes effect; the
10
+ * scope rules name the replacement commands for the step that made it. `null`
11
+ * when no formatter is configured or its binary cannot be resolved: under npm
12
+ * the command would otherwise make `npx` download it.
13
+ */
14
+ export declare function resolveFormatCommand(root: string, pmExec: string): string | null;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatCommandFor = formatCommandFor;
4
+ exports.resolveFormatCommand = resolveFormatCommand;
5
+ const formatters_1 = require("../../../utils/formatters");
6
+ /**
7
+ * The command the agent runs over the files it changed, with a `<paths>`
8
+ * placeholder. `--` keeps a path that starts with `-` from being read as an
9
+ * option.
10
+ */
11
+ function formatCommandFor(formatter, pmExec) {
12
+ switch (formatter) {
13
+ case 'prettier':
14
+ // --ignore-unknown skips files prettier has no parser for.
15
+ return `${pmExec} prettier --write --ignore-unknown -- <paths>`;
16
+ case 'oxfmt':
17
+ // oxfmt exits 2 when every path was skipped; the flag makes that
18
+ // success. Unlike prettier it skips unparseable files on its own.
19
+ return `${pmExec} oxfmt --no-error-on-unmatched-pattern -- <paths>`;
20
+ default: {
21
+ const unhandled = formatter;
22
+ throw new Error(`Unhandled formatter: ${unhandled}`);
23
+ }
24
+ }
25
+ }
26
+ /**
27
+ * Resolved per dispense so a migration's formatter change takes effect; the
28
+ * scope rules name the replacement commands for the step that made it. `null`
29
+ * when no formatter is configured or its binary cannot be resolved: under npm
30
+ * the command would otherwise make `npx` download it.
31
+ */
32
+ function resolveFormatCommand(root, pmExec) {
33
+ const formatter = (0, formatters_1.detectFormatter)(root);
34
+ if (formatter === null) {
35
+ return null;
36
+ }
37
+ try {
38
+ formatters_1.resolveFormatterBin[formatter]();
39
+ }
40
+ catch {
41
+ return null;
42
+ }
43
+ return formatCommandFor(formatter, pmExec);
44
+ }
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Both the agentic runner and the orchestrator write per-run scratch under
3
- * `.nx/migrate-runs/<run-id>/`: handoff files in both cases, plus the durable
4
- * run state and its plan snapshots for the orchestrator. The v23 migration
5
- * `23-0-0-add-migrate-runs-to-git-ignore` adds `.nx/migrate-runs` to
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
6
  * `.gitignore`; in its declared slot (typically late) earlier per-migration
7
7
  * commits would absorb the scratch into the user-visible diff.
8
8
  *