@depup/nx 23.2.1-depup.7 → 23.3.0-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (350) hide show
  1. package/README.md +8 -19
  2. package/changes.json +10 -54
  3. package/dist/bin/init-local.js +7 -1
  4. package/dist/nx-cloud-internals.d.ts +1 -0
  5. package/dist/nx-cloud-internals.js +9 -0
  6. package/dist/plugins/package-json.js +1 -1
  7. package/dist/src/command-line/add/add.js +5 -1
  8. package/dist/src/command-line/affected/affected.js +70 -9
  9. package/dist/src/command-line/affected/command-object.js +1 -1
  10. package/dist/src/command-line/format/format.js +2 -18
  11. package/dist/src/command-line/graph/graph.d.ts +31 -0
  12. package/dist/src/command-line/graph/graph.js +113 -20
  13. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +0 -3
  14. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +0 -3
  15. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +0 -3
  16. package/dist/src/command-line/init/implementation/angular/index.js +0 -3
  17. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +0 -3
  18. package/dist/src/command-line/init/implementation/format.js +2 -3
  19. package/dist/src/command-line/init/implementation/utils.d.ts +0 -1
  20. package/dist/src/command-line/init/implementation/utils.js +6 -9
  21. package/dist/src/command-line/init/init-v2.js +0 -3
  22. package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +25 -0
  23. package/dist/src/command-line/migrate/agentic/capture-generator-output.js +121 -5
  24. package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +21 -0
  25. package/dist/src/command-line/migrate/agentic/close-agent-session.js +126 -0
  26. package/dist/src/command-line/migrate/agentic/definitions.d.ts +24 -0
  27. package/dist/src/command-line/migrate/agentic/definitions.js +79 -20
  28. package/dist/src/command-line/migrate/agentic/format-command.d.ts +14 -0
  29. package/dist/src/command-line/migrate/agentic/format-command.js +44 -0
  30. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +3 -3
  31. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +3 -3
  32. package/dist/src/command-line/migrate/agentic/handoff.d.ts +50 -17
  33. package/dist/src/command-line/migrate/agentic/handoff.js +166 -24
  34. package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +23 -0
  35. package/dist/src/command-line/migrate/agentic/instruction-files.js +41 -0
  36. package/dist/src/command-line/migrate/agentic/master/invocations.d.ts +12 -0
  37. package/dist/src/command-line/migrate/agentic/master/invocations.js +54 -0
  38. package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +16 -0
  39. package/dist/src/command-line/migrate/agentic/master/run-master-session.js +175 -0
  40. package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +31 -0
  41. package/dist/src/command-line/migrate/agentic/master/spawn-master.js +222 -0
  42. package/dist/src/command-line/migrate/agentic/prompts/final-validation.d.ts +13 -0
  43. package/dist/src/command-line/migrate/agentic/prompts/final-validation.js +41 -0
  44. package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +17 -0
  45. package/dist/src/command-line/migrate/agentic/prompts/fragments.js +90 -0
  46. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +4 -3
  47. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +25 -1
  48. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +57 -34
  49. package/dist/src/command-line/migrate/agentic/run-step.js +28 -4
  50. package/dist/src/command-line/migrate/agentic/runner.d.ts +3 -15
  51. package/dist/src/command-line/migrate/agentic/runner.js +57 -239
  52. package/dist/src/command-line/migrate/agentic/terminal-repair.d.ts +1 -0
  53. package/dist/src/command-line/migrate/agentic/terminal-repair.js +27 -0
  54. package/dist/src/command-line/migrate/agentic/types.d.ts +23 -8
  55. package/dist/src/command-line/migrate/agentic/types.js +10 -7
  56. package/dist/src/command-line/migrate/agentic/windows-cmd.d.ts +33 -0
  57. package/dist/src/command-line/migrate/agentic/windows-cmd.js +88 -0
  58. package/dist/src/command-line/migrate/command-object.d.ts +2 -0
  59. package/dist/src/command-line/migrate/command-object.js +11 -1
  60. package/dist/src/command-line/migrate/deferred-output.d.ts +44 -0
  61. package/dist/src/command-line/migrate/deferred-output.js +92 -0
  62. package/dist/src/command-line/migrate/execute-migration.d.ts +9 -3
  63. package/dist/src/command-line/migrate/execute-migration.js +53 -16
  64. package/dist/src/command-line/migrate/migrate-analytics.d.ts +34 -9
  65. package/dist/src/command-line/migrate/migrate-analytics.js +71 -10
  66. package/dist/src/command-line/migrate/migrate-commits.d.ts +5 -4
  67. package/dist/src/command-line/migrate/migrate-commits.js +16 -6
  68. package/dist/src/command-line/migrate/migrate-config.d.ts +5 -2
  69. package/dist/src/command-line/migrate/migrate-config.js +19 -11
  70. package/dist/src/command-line/migrate/migrate-output.d.ts +3 -7
  71. package/dist/src/command-line/migrate/migrate-output.js +3 -7
  72. package/dist/src/command-line/migrate/migrate.d.ts +3 -0
  73. package/dist/src/command-line/migrate/migrate.js +183 -46
  74. package/dist/src/command-line/migrate/resolve-package-version.js +2 -19
  75. package/dist/src/command-line/migrate/run/agent-output.d.ts +11 -0
  76. package/dist/src/command-line/migrate/run/agent-output.js +21 -2
  77. package/dist/src/command-line/migrate/run/agent-work-payload.d.ts +37 -0
  78. package/dist/src/command-line/migrate/run/agent-work-payload.js +156 -0
  79. package/dist/src/command-line/migrate/run/atomic-write.d.ts +8 -0
  80. package/dist/src/command-line/migrate/run/atomic-write.js +17 -0
  81. package/dist/src/command-line/migrate/run/broker.d.ts +150 -0
  82. package/dist/src/command-line/migrate/run/broker.js +568 -0
  83. package/dist/src/command-line/migrate/run/clean-retry.d.ts +12 -0
  84. package/dist/src/command-line/migrate/run/clean-retry.js +99 -0
  85. package/dist/src/command-line/migrate/run/existing-run-report.d.ts +55 -0
  86. package/dist/src/command-line/migrate/run/existing-run-report.js +227 -0
  87. package/dist/src/command-line/migrate/run/give-up.d.ts +41 -0
  88. package/dist/src/command-line/migrate/run/give-up.js +148 -0
  89. package/dist/src/command-line/migrate/run/index.d.ts +9 -6
  90. package/dist/src/command-line/migrate/run/index.js +21 -2
  91. package/dist/src/command-line/migrate/run/issues.d.ts +127 -0
  92. package/dist/src/command-line/migrate/run/issues.js +1121 -0
  93. package/dist/src/command-line/migrate/run/orchestrator.d.ts +59 -1
  94. package/dist/src/command-line/migrate/run/orchestrator.js +1529 -457
  95. package/dist/src/command-line/migrate/run/run-id.d.ts +0 -8
  96. package/dist/src/command-line/migrate/run/run-id.js +0 -30
  97. package/dist/src/command-line/migrate/run/run-state.d.ts +77 -17
  98. package/dist/src/command-line/migrate/run/run-state.js +263 -32
  99. package/dist/src/command-line/migrate/run/runbook.d.ts +18 -0
  100. package/dist/src/command-line/migrate/run/runbook.js +118 -0
  101. package/dist/src/command-line/migrate/run/state-lock.d.ts +33 -2
  102. package/dist/src/command-line/migrate/run/state-lock.js +128 -2
  103. package/dist/src/command-line/migrate/run/state-machine.d.ts +50 -1
  104. package/dist/src/command-line/migrate/run/state-machine.js +339 -26
  105. package/dist/src/command-line/migrate/run/util.d.ts +3 -1
  106. package/dist/src/command-line/migrate/run/util.js +24 -3
  107. package/dist/src/command-line/migrate/run/worker.js +290 -129
  108. package/dist/src/command-line/migrate/step-actions.d.ts +1 -1
  109. package/dist/src/command-line/migrate/step-actions.js +7 -1
  110. package/dist/src/command-line/migrate/text.d.ts +6 -0
  111. package/dist/src/command-line/migrate/text.js +25 -0
  112. package/dist/src/command-line/migrate/version-skew-guard.js +2 -0
  113. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +5 -11
  114. package/dist/src/command-line/release/publish.js +11 -8
  115. package/dist/src/command-line/release/utils/get-touched-projects-for-group.js +3 -3
  116. package/dist/src/command-line/release/utils/release-graph.js +1 -1
  117. package/dist/src/command-line/release/utils/remote-release-clients/github.js +5 -8
  118. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +3 -3
  119. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +4 -2
  120. package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +37 -3
  121. package/dist/src/command-line/release/version/version-actions.d.ts +3 -0
  122. package/dist/src/command-line/reset/reset.js +10 -4
  123. package/dist/src/command-line/run/run-one.js +5 -1
  124. package/dist/src/command-line/run-many/run-many.js +6 -12
  125. package/dist/src/command-line/show/command-object.js +1 -1
  126. package/dist/src/command-line/show/projects.js +52 -1
  127. package/dist/src/command-line/yargs-utils/shared-options.d.ts +5 -1
  128. package/dist/src/command-line/yargs-utils/shared-options.js +38 -4
  129. package/dist/src/config/task-graph.d.ts +1 -1
  130. package/dist/src/config/workspace-json-project-json.d.ts +23 -1
  131. package/dist/src/core/graph/main.js +1 -1
  132. package/dist/src/core/graph/runtime.js +1 -1
  133. package/dist/src/core/graph/styles.js +1 -1
  134. package/dist/src/daemon/client/client.d.ts +14 -8
  135. package/dist/src/daemon/client/client.js +41 -12
  136. package/dist/src/daemon/message-types/get-plugin-capabilities.d.ts +5 -0
  137. package/dist/src/daemon/message-types/get-plugin-capabilities.js +11 -0
  138. package/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts +3 -2
  139. package/dist/src/daemon/message-types/select-affected-tasks.d.ts +21 -0
  140. package/dist/src/daemon/message-types/select-affected-tasks.js +11 -0
  141. package/dist/src/daemon/message-types/ultracache-configuration-version.d.ts +8 -0
  142. package/dist/src/daemon/message-types/ultracache-configuration-version.js +2 -0
  143. package/dist/src/daemon/server/dotenv-graph-changes.d.ts +1 -1
  144. package/dist/src/daemon/server/dotenv-graph-changes.js +2 -2
  145. package/dist/src/daemon/server/handle-get-plugin-capabilities.d.ts +2 -0
  146. package/dist/src/daemon/server/handle-get-plugin-capabilities.js +13 -0
  147. package/dist/src/daemon/server/handle-hash-tasks.d.ts +10 -2
  148. package/dist/src/daemon/server/handle-hash-tasks.js +18 -3
  149. package/dist/src/daemon/server/handle-select-affected-tasks.d.ts +3 -0
  150. package/dist/src/daemon/server/handle-select-affected-tasks.js +26 -0
  151. package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +3 -2
  152. package/dist/src/daemon/server/{handle-outputs-changes.d.ts → handle-watch-events.d.ts} +4 -4
  153. package/dist/src/daemon/server/{handle-outputs-changes.js → handle-watch-events.js} +36 -37
  154. package/dist/src/daemon/server/outputs-tracking.d.ts +7 -19
  155. package/dist/src/daemon/server/outputs-tracking.js +7 -107
  156. package/dist/src/daemon/server/planning-context.d.ts +8 -0
  157. package/dist/src/daemon/server/planning-context.js +18 -0
  158. package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +22 -7
  159. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +104 -74
  160. package/dist/src/daemon/server/restart-checks.d.ts +22 -0
  161. package/dist/src/daemon/server/restart-checks.js +77 -0
  162. package/dist/src/daemon/server/server.d.ts +1 -0
  163. package/dist/src/daemon/server/server.js +54 -30
  164. package/dist/src/daemon/server/shutdown-utils.d.ts +0 -5
  165. package/dist/src/daemon/server/shutdown-utils.js +3 -26
  166. package/dist/src/daemon/server/ultracache-configuration-state.d.ts +7 -0
  167. package/dist/src/daemon/server/ultracache-configuration-state.js +36 -0
  168. package/dist/src/devkit-internals.d.ts +3 -1
  169. package/dist/src/devkit-internals.js +8 -3
  170. package/dist/src/executors/run-commands/run-commands.impl.d.ts +2 -1
  171. package/dist/src/executors/run-commands/run-commands.impl.js +19 -5
  172. package/dist/src/executors/run-commands/running-tasks.d.ts +5 -4
  173. package/dist/src/executors/run-commands/running-tasks.js +13 -13
  174. package/dist/src/hasher/create-task-hasher.d.ts +8 -1
  175. package/dist/src/hasher/create-task-hasher.js +13 -3
  176. package/dist/src/hasher/hash-plan-inspector.js +2 -2
  177. package/dist/src/hasher/hash-task.d.ts +2 -2
  178. package/dist/src/hasher/hash-task.js +28 -17
  179. package/dist/src/hasher/native-task-hasher-impl.d.ts +20 -4
  180. package/dist/src/hasher/native-task-hasher-impl.js +75 -9
  181. package/dist/src/hasher/task-hasher.d.ts +24 -7
  182. package/dist/src/hasher/task-hasher.js +27 -8
  183. package/dist/src/hasher/task-planning-context.d.ts +13 -0
  184. package/dist/src/hasher/task-planning-context.js +12 -0
  185. package/dist/src/native/index.d.ts +582 -21
  186. package/dist/src/native/index.js +3 -3
  187. package/dist/src/native/native-bindings.js +13 -1
  188. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  189. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  190. package/dist/src/native/transform-objects.d.ts +11 -2
  191. package/dist/src/native/transform-objects.js +46 -0
  192. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +15 -8
  193. package/dist/src/nx-cloud/update-manager.d.ts +3 -0
  194. package/dist/src/nx-cloud/update-manager.js +19 -13
  195. package/dist/src/nx-cloud/utilities/client.d.ts +1 -1
  196. package/dist/src/nx-cloud/utilities/client.js +1 -1
  197. package/dist/src/nx-cloud/utilities/is-workspace-claimed.js +2 -1
  198. package/dist/src/nx-cloud/utilities/nx-cloud-http-client.d.ts +5 -0
  199. package/dist/src/nx-cloud/utilities/nx-cloud-http-client.js +16 -0
  200. package/dist/src/nx-cloud/utilities/url-shorten.js +17 -10
  201. package/dist/src/plugins/js/index.js +45 -64
  202. package/dist/src/plugins/js/lock-file/lock-file.d.ts +4 -4
  203. package/dist/src/plugins/js/lock-file/lock-file.js +6 -7
  204. package/dist/src/plugins/js/lock-file/pnpm-parser.js +1 -1
  205. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +2 -0
  206. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +22 -0
  207. package/dist/src/plugins/js/project-graph/affected/lock-file-changes.d.ts +10 -2
  208. package/dist/src/plugins/js/project-graph/affected/lock-file-changes.js +51 -29
  209. package/dist/src/plugins/js/project-graph/affected/npm-packages.d.ts +10 -2
  210. package/dist/src/plugins/js/project-graph/affected/npm-packages.js +32 -11
  211. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +22 -18
  212. package/dist/src/plugins/js/utils/register.js +13 -4
  213. package/dist/src/plugins/package-json/create-nodes.d.ts +2 -2
  214. package/dist/src/plugins/package-json/create-nodes.js +13 -13
  215. package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +14 -0
  216. package/dist/src/project-graph/affected/affected-project-graph.js +5 -18
  217. package/dist/src/project-graph/affected/affected-projects.d.ts +7 -0
  218. package/dist/src/project-graph/affected/affected-projects.js +42 -0
  219. package/dist/src/project-graph/affected/affected-reasons.d.ts +116 -0
  220. package/dist/src/project-graph/affected/affected-reasons.js +459 -0
  221. package/dist/src/project-graph/affected/affected-tasks.d.ts +103 -0
  222. package/dist/src/project-graph/affected/affected-tasks.js +386 -0
  223. package/dist/src/project-graph/affected/print-explanation.d.ts +11 -0
  224. package/dist/src/project-graph/affected/print-explanation.js +44 -0
  225. package/dist/src/project-graph/error-types.d.ts +5 -0
  226. package/dist/src/project-graph/error-types.js +44 -5
  227. package/dist/src/project-graph/file-utils.d.ts +2 -0
  228. package/dist/src/project-graph/file-utils.js +12 -3
  229. package/dist/src/project-graph/nx-deps-cache.d.ts +5 -2
  230. package/dist/src/project-graph/nx-deps-cache.js +4 -4
  231. package/dist/src/project-graph/plugins/get-plugins.d.ts +3 -1
  232. package/dist/src/project-graph/plugins/get-plugins.js +60 -82
  233. package/dist/src/project-graph/plugins/in-process-loader.d.ts +1 -1
  234. package/dist/src/project-graph/plugins/in-process-loader.js +1 -4
  235. package/dist/src/project-graph/plugins/isolation/index.d.ts +1 -1
  236. package/dist/src/project-graph/plugins/isolation/index.js +3 -1
  237. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +8 -0
  238. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +42 -6
  239. package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.d.ts +10 -1
  240. package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.js +67 -17
  241. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +3 -2
  242. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +5 -1
  243. package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +5 -2
  244. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +14 -1
  245. package/dist/src/project-graph/plugins/nx-plugin-capabilities.d.ts +6 -0
  246. package/dist/src/project-graph/plugins/nx-plugin-capabilities.js +28 -0
  247. package/dist/src/project-graph/plugins/task-results-stub.d.ts +50 -0
  248. package/dist/src/project-graph/plugins/task-results-stub.js +111 -0
  249. package/dist/src/project-graph/plugins/tasks-execution-hooks.d.ts +3 -2
  250. package/dist/src/project-graph/plugins/tasks-execution-hooks.js +14 -1
  251. package/dist/src/project-graph/project-graph.js +43 -42
  252. package/dist/src/project-graph/utils/project-configuration/target-merging.js +67 -0
  253. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +83 -0
  254. package/dist/src/project-graph/utils/project-configuration/utils.d.ts +1 -0
  255. package/dist/src/project-graph/utils/project-configuration/utils.js +1 -0
  256. package/dist/src/tasks-runner/batch/run-batch.js +15 -0
  257. package/dist/src/tasks-runner/cache.d.ts +37 -2
  258. package/dist/src/tasks-runner/cache.js +42 -1
  259. package/dist/src/tasks-runner/create-task-graph.d.ts +24 -1
  260. package/dist/src/tasks-runner/create-task-graph.js +57 -2
  261. package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
  262. package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
  263. package/dist/src/tasks-runner/forked-process-task-runner.js +11 -10
  264. package/dist/src/tasks-runner/init-tasks-runner.d.ts +7 -2
  265. package/dist/src/tasks-runner/init-tasks-runner.js +15 -7
  266. package/dist/src/tasks-runner/is-tui-enabled.js +4 -3
  267. package/dist/src/tasks-runner/life-cycle.d.ts +7 -0
  268. package/dist/src/tasks-runner/life-cycle.js +7 -0
  269. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.d.ts +35 -0
  270. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +146 -0
  271. package/dist/src/tasks-runner/prune-task-graph.d.ts +17 -0
  272. package/dist/src/tasks-runner/prune-task-graph.js +45 -0
  273. package/dist/src/tasks-runner/run-command.d.ts +41 -5
  274. package/dist/src/tasks-runner/run-command.js +98 -22
  275. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +93 -19
  276. package/dist/src/tasks-runner/running-tasks/batch-process.js +184 -88
  277. package/dist/src/tasks-runner/task-io-service.d.ts +11 -3
  278. package/dist/src/tasks-runner/task-io-service.js +14 -5
  279. package/dist/src/tasks-runner/task-orchestrator.d.ts +71 -4
  280. package/dist/src/tasks-runner/task-orchestrator.js +266 -66
  281. package/dist/src/tasks-runner/tasks-runner.d.ts +2 -0
  282. package/dist/src/tasks-runner/terminal-output-path.d.ts +11 -0
  283. package/dist/src/tasks-runner/terminal-output-path.js +18 -0
  284. package/dist/src/tasks-runner/utils.d.ts +5 -0
  285. package/dist/src/tasks-runner/utils.js +14 -2
  286. package/dist/src/ultracache/config.d.ts +21 -0
  287. package/dist/src/ultracache/config.js +29 -0
  288. package/dist/src/ultracache/fetch.d.ts +21 -0
  289. package/dist/src/ultracache/fetch.js +43 -0
  290. package/dist/src/ultracache/overrides.d.ts +17 -0
  291. package/dist/src/ultracache/overrides.js +61 -0
  292. package/dist/src/ultracache/report.d.ts +13 -0
  293. package/dist/src/ultracache/report.js +62 -0
  294. package/dist/src/ultracache/store.d.ts +41 -0
  295. package/dist/src/ultracache/store.js +158 -0
  296. package/dist/src/utils/ab-testing.d.ts +4 -1
  297. package/dist/src/utils/ab-testing.js +22 -19
  298. package/dist/src/utils/chunkify.d.ts +1 -7
  299. package/dist/src/utils/chunkify.js +2 -8
  300. package/dist/src/utils/command-line-utils.d.ts +20 -0
  301. package/dist/src/utils/command-line-utils.js +10 -3
  302. package/dist/src/utils/create-cli-options.d.ts +6 -0
  303. package/dist/src/utils/create-cli-options.js +29 -0
  304. package/dist/src/utils/db-connection.d.ts +2 -0
  305. package/dist/src/utils/db-connection.js +2 -0
  306. package/dist/src/utils/formatters/index.d.ts +6 -0
  307. package/dist/src/utils/formatters/index.js +5 -0
  308. package/dist/src/utils/formatters/prettier.d.ts +0 -8
  309. package/dist/src/utils/formatters/prettier.js +4 -26
  310. package/dist/src/utils/git-utils.d.ts +19 -0
  311. package/dist/src/utils/git-utils.js +97 -39
  312. package/dist/src/utils/handle-errors.js +5 -43
  313. package/dist/src/utils/http-client.d.ts +27 -0
  314. package/dist/src/utils/http-client.js +193 -0
  315. package/dist/src/utils/installed-nx-version.js +2 -48
  316. package/dist/src/utils/json-diff.d.ts +4 -2
  317. package/dist/src/utils/json-diff.js +6 -94
  318. package/dist/src/utils/min-release-age/packument.js +1 -1
  319. package/dist/src/utils/nx-cloud-utils.d.ts +2 -0
  320. package/dist/src/utils/nx-cloud-utils.js +6 -1
  321. package/dist/src/utils/output.d.ts +22 -3
  322. package/dist/src/utils/output.js +28 -5
  323. package/dist/src/utils/package-json.d.ts +25 -0
  324. package/dist/src/utils/package-json.js +49 -6
  325. package/dist/src/utils/package-manager.d.ts +6 -0
  326. package/dist/src/utils/package-manager.js +10 -0
  327. package/dist/src/utils/plugins/plugin-capabilities.js +7 -2
  328. package/dist/src/utils/project-graph-utils.d.ts +2 -0
  329. package/dist/src/utils/project-graph-utils.js +12 -0
  330. package/dist/src/utils/provenance.js +20 -4
  331. package/dist/src/utils/serialize-overrides-into-command-line.js +2 -4
  332. package/dist/src/utils/workspace-context.d.ts +51 -3
  333. package/dist/src/utils/workspace-context.js +174 -10
  334. package/package.json +38 -100
  335. package/schemas/nx-schema.json +38 -0
  336. package/schemas/project-schema.json +35 -0
  337. package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +0 -9
  338. package/dist/src/daemon/server/file-watching/route-workspace-changes.js +0 -76
  339. package/dist/src/daemon/server/watcher.d.ts +0 -18
  340. package/dist/src/daemon/server/watcher.js +0 -126
  341. package/dist/src/nx-cloud/utilities/axios.d.ts +0 -4
  342. package/dist/src/nx-cloud/utilities/axios.js +0 -17
  343. package/dist/src/project-graph/affected/locators/project-glob-changes.d.ts +0 -2
  344. package/dist/src/project-graph/affected/locators/project-glob-changes.js +0 -47
  345. package/dist/src/project-graph/affected/locators/workspace-json-changes.d.ts +0 -4
  346. package/dist/src/project-graph/affected/locators/workspace-json-changes.js +0 -47
  347. package/dist/src/project-graph/affected/locators/workspace-projects.d.ts +0 -3
  348. package/dist/src/project-graph/affected/locators/workspace-projects.js +0 -74
  349. package/dist/src/utils/collapse-expanded-outputs.d.ts +0 -10
  350. package/dist/src/utils/collapse-expanded-outputs.js +0 -72
@@ -130,6 +130,12 @@ export declare function getWorkspaceRegistryUrlForDisplay(pkg: string): string |
130
130
  export declare function packageRegistryView(pkg: string, version: string, args: string[], options?: {
131
131
  forceNpm?: boolean;
132
132
  }): Promise<string>;
133
+ /**
134
+ * Parses `npm view --json` output. npm 12 wraps the result in an array even
135
+ * when a single version matches; npm <= 11 and pnpm print the bare value. A
136
+ * multi-version match (range spec) stays an array.
137
+ */
138
+ export declare function parseRegistryViewJson<T = unknown>(raw: string): T;
133
139
  /**
134
140
  * Only `npm pack` supports downloading a tarball of a specified remote
135
141
  * package. `yarn` packs the active workspace, `pnpm pack` only packs
@@ -15,6 +15,7 @@ exports.resolvePackageVersionUsingRegistry = resolvePackageVersionUsingRegistry;
15
15
  exports.resolvePackageVersionUsingInstallation = resolvePackageVersionUsingInstallation;
16
16
  exports.getWorkspaceRegistryUrlForDisplay = getWorkspaceRegistryUrlForDisplay;
17
17
  exports.packageRegistryView = packageRegistryView;
18
+ exports.parseRegistryViewJson = parseRegistryViewJson;
18
19
  exports.packageRegistryPack = packageRegistryPack;
19
20
  exports.clearPackageManagerVersionCache = clearPackageManagerVersionCache;
20
21
  exports.getPackageWorkspaces = getPackageWorkspaces;
@@ -705,6 +706,15 @@ options) {
705
706
  throw redactErrorCause(e);
706
707
  }
707
708
  }
709
+ /**
710
+ * Parses `npm view --json` output. npm 12 wraps the result in an array even
711
+ * when a single version matches; npm <= 11 and pnpm print the bare value. A
712
+ * multi-version match (range spec) stays an array.
713
+ */
714
+ function parseRegistryViewJson(raw) {
715
+ const parsed = JSON.parse(raw);
716
+ return Array.isArray(parsed) && parsed.length === 1 ? parsed[0] : parsed;
717
+ }
708
718
  /**
709
719
  * Only `npm pack` supports downloading a tarball of a specified remote
710
720
  * package. `yarn` packs the active workspace, `pnpm pack` only packs
@@ -63,12 +63,17 @@ async function tryGetModule(packageJson, workspaceRoot) {
63
63
  packageJson['nx-migrations'] ??
64
64
  packageJson['schematics'] ??
65
65
  packageJson['builders']) {
66
- const [pluginPromise] = (0, in_process_loader_1.loadNxPlugin)(packageJson.name, workspaceRoot);
67
- return await pluginPromise;
66
+ return await (0, in_process_loader_1.loadNxPlugin)(packageJson.name, workspaceRoot);
68
67
  }
69
68
  else {
70
69
  return {
71
70
  name: packageJson.name,
71
+ capabilities: () => ({
72
+ hasCreateDependencies: false,
73
+ hasCreateMetadata: false,
74
+ hasPreTasksExecution: false,
75
+ hasPostTasksExecution: false,
76
+ }),
72
77
  };
73
78
  }
74
79
  }
@@ -1,6 +1,8 @@
1
1
  import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
2
2
  import type { ProjectConfiguration } from '../config/workspace-json-project-json';
3
3
  export declare function projectHasTarget(project: ProjectGraphProjectNode, target: string): boolean;
4
+ /** The projects that define at least one of `targets`. */
5
+ export declare function runnableForTarget(projects: Record<string, ProjectGraphProjectNode>, targets: string[]): Set<string>;
4
6
  export declare function projectHasTargetAndConfiguration(project: ProjectGraphProjectNode, target: string, configuration: string): any;
5
7
  export declare function getSourceDirOfDependentProjects(projectName: string, projectGraph?: ProjectGraph): [
6
8
  projectDirs: string[],
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.projectHasTarget = projectHasTarget;
4
+ exports.runnableForTarget = runnableForTarget;
4
5
  exports.projectHasTargetAndConfiguration = projectHasTargetAndConfiguration;
5
6
  exports.getSourceDirOfDependentProjects = getSourceDirOfDependentProjects;
6
7
  exports.findAllProjectNodeDependencies = findAllProjectNodeDependencies;
@@ -13,6 +14,17 @@ function projectHasTarget(project, target) {
13
14
  project.data.targets &&
14
15
  project.data.targets[target]);
15
16
  }
17
+ /** The projects that define at least one of `targets`. */
18
+ function runnableForTarget(projects, targets) {
19
+ const runnable = new Set();
20
+ for (const projectName in projects) {
21
+ const project = projects[projectName];
22
+ if (targets.some((target) => projectHasTarget(project, target))) {
23
+ runnable.add(projectName);
24
+ }
25
+ }
26
+ return runnable;
27
+ }
16
28
  function projectHasTargetAndConfiguration(project, target, configuration) {
17
29
  return (projectHasTarget(project, target) &&
18
30
  project.data.targets[target].configurations &&
@@ -13,6 +13,15 @@ const package_manager_1 = require("./package-manager");
13
13
  *
14
14
  * Will throw if the package does not have valid provenance.
15
15
  */
16
+ /**
17
+ * A build the publish workflow cuts from master rather than from a tag:
18
+ * `23.3.0-pr.36841.f66e88b` from a pull request, `23.2.0-canary.20260908-89f02c1`
19
+ * from the nightly. Each segment is matched with its leading digits so an
20
+ * ordinary prerelease like `1.0.0-preview.1` does not qualify.
21
+ */
22
+ function isPublishedFromMaster(version) {
23
+ return /-pr\.\d+\./.test(version) || /-canary\.\d/.test(version);
24
+ }
16
25
  async function ensurePackageHasProvenance(packageName, packageVersion) {
17
26
  // this is used for locally released versions without provenance
18
27
  // do not set this for other reasons or you might be exposed to security risks
@@ -25,8 +34,8 @@ async function ensurePackageHasProvenance(packageName, packageVersion) {
25
34
  '--silent',
26
35
  ]);
27
36
  const parsed = JSON.parse(result);
28
- // `npm view <pkg>@<spec> --json` returns a bare object on npm <= 11 but an
29
- // array on npm 12 and pnpm, even for a single resolved version. A version
37
+ // `npm view <pkg>@<spec> --json` returns a bare object on npm <= 11 and
38
+ // pnpm but an array on npm 12, even for a single resolved version. A version
30
39
  // range matches several versions and the registry lists all of them
31
40
  // (including deprecated ones the installer skips), so we cannot tell which
32
41
  // one will actually be installed; refuse rather than verify the wrong
@@ -57,8 +66,15 @@ async function ensurePackageHasProvenance(packageName, packageVersion) {
57
66
  if (workflowParameters.path !== '.github/workflows/publish.yml') {
58
67
  throw new ProvenanceError(packageName, packageVersion, 'Publishing workflow does not match .github/workflows/publish.yml');
59
68
  }
60
- if (workflowParameters.ref !== `refs/tags/${npmViewResult.version}`) {
61
- throw new ProvenanceError(packageName, packageVersion, `Version ref does not match refs/tags/${npmViewResult.version}`);
69
+ // PR and canary releases are published by this same workflow running on
70
+ // master, so a tag for them does not exist and never will. Repository,
71
+ // workflow path and the artifact digest are still checked, so this only
72
+ // widens which ref of nrwl/nx is allowed to have built it.
73
+ const allowedRefs = isPublishedFromMaster(npmViewResult.version)
74
+ ? [`refs/tags/${npmViewResult.version}`, 'refs/heads/master']
75
+ : [`refs/tags/${npmViewResult.version}`];
76
+ if (!allowedRefs.includes(workflowParameters.ref)) {
77
+ throw new ProvenanceError(packageName, packageVersion, `Version ref does not match ${allowedRefs.join(' or ')}`);
62
78
  }
63
79
  // verify that provenance was generated from the exact same artifact as the one we are installing
64
80
  const distSha = Buffer.from(npmViewResult.dist.integrity.replace('sha512-', ''), 'base64').toString('hex');
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.serializeOverridesIntoCommandLine = serializeOverridesIntoCommandLine;
4
- const flat_1 = require("flat");
5
4
  const shell_quoting_1 = require("./shell-quoting");
6
5
  function serializeOverridesIntoCommandLine(options) {
7
6
  const unparsed = options._ ? [...options._] : [];
@@ -24,9 +23,8 @@ function serializeOption(key, value, unparsed) {
24
23
  value.forEach((item) => serializeOption(key, item, unparsed));
25
24
  }
26
25
  else if (Object.prototype.toString.call(value) === '[object Object]') {
27
- const flattened = (0, flat_1.flatten)(value, { safe: true });
28
- for (const flattenedKey in flattened) {
29
- serializeOption(`${key}.${flattenedKey}`, flattened[flattenedKey], unparsed);
26
+ for (const nestedKey of Object.keys(value)) {
27
+ serializeOption(`${key}.${nestedKey}`, value[nestedKey], unparsed);
30
28
  }
31
29
  }
32
30
  else if (typeof value === 'string' &&
@@ -1,5 +1,9 @@
1
- import type { NxWorkspaceFilesExternals } from '../native';
2
- export declare function setupWorkspaceContext(workspaceRoot: string): void;
1
+ import type { ChangeBatch, NxWorkspaceFilesExternals, TaskOutputs, WorkspaceContext, WorkspaceContextOptions } from '../native';
2
+ /** The shapes the native watch calls back with, taken from the binding. A
3
+ * failure arrives as an Error with no batch or events, so both are nullable. */
4
+ export type WorkspaceChangesListener = Parameters<WorkspaceContext['onChanges']>[0];
5
+ export type WatchEventsListener = Parameters<WorkspaceContext['onWatchEvents']>[0];
6
+ export declare function setupWorkspaceContext(workspaceRoot: string, options?: WorkspaceContextOptions): void;
3
7
  export declare function getNxWorkspaceFilesFromContext(workspaceRoot: string, projectRootMap: Record<string, string>, useDaemonProcess?: boolean): Promise<import("../native").NxWorkspaceFiles>;
4
8
  /**
5
9
  * Sync method to get files matching globs from workspace context.
@@ -14,8 +18,52 @@ export declare function multiGlobWithWorkspaceContext(workspaceRoot: string, glo
14
18
  export declare function hashWithWorkspaceContext(workspaceRoot: string, globs: string[], exclude?: string[]): Promise<string>;
15
19
  export declare function hashMultiGlobWithWorkspaceContext(workspaceRoot: string, globGroups: string[][]): Promise<string[]>;
16
20
  export declare function updateContextWithChangedFiles(workspaceRoot: string, createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): Promise<void>;
17
- export declare function updateFilesInContext(workspaceRoot: string, updatedFiles: string[], deletedFiles: string[]): Record<string, string>;
21
+ /**
22
+ * The subset of `paths` the workspace file map holds: what the watch tracks,
23
+ * with the ignore rules applied.
24
+ */
25
+ export declare function trackedFilesInContext(workspaceRoot: string, paths: string[]): string[];
26
+ /** Remembers each task's outputs, as given or else as they are on disk now. */
27
+ export declare function recordOutputsInContext(workspaceRoot: string, entries: TaskOutputs[]): void;
28
+ /** Whether each task's outputs are still as last recorded for its hash. */
29
+ export declare function outputsUnchangedInContext(workspaceRoot: string, entries: TaskOutputs[]): boolean[];
30
+ export declare function updateFilesInContext(workspaceRoot: string, updatedFiles: string[], deletedFiles: string[]): ChangeBatch;
18
31
  export declare function getAllFileDataInContext(workspaceRoot: string): Promise<import("../native").FileData[]>;
32
+ /**
33
+ * Listens for the changes a watching context applies: each change reaches the
34
+ * listeners once, here or in `settleWorkspaceContext`, whichever takes it
35
+ * first. Any number of listeners may listen. Returns a function that stops
36
+ * this one.
37
+ */
38
+ export declare function subscribeToWorkspaceChanges(workspaceRoot: string, listener: WorkspaceChangesListener): () => void;
39
+ /**
40
+ * Applies every change the watcher has delivered, waiting out the kernel hop,
41
+ * and takes every change applied and not yet handed out. Empty when the
42
+ * context is not watching.
43
+ */
44
+ export declare function settleWorkspaceContext(workspaceRoot: string): ChangeBatch;
45
+ /**
46
+ * Takes every change applied and not yet handed out, without waiting for the
47
+ * watcher: for a caller that has just applied changes itself.
48
+ */
49
+ export declare function takeAppliedWorkspaceChanges(workspaceRoot: string): ChangeBatch;
50
+ export declare function isWatchingWorkspaceContext(): boolean;
51
+ /**
52
+ * Listens for every event the context's watch delivers, including writes
53
+ * under ignored directories and the `rescan` marker. Any number of listeners
54
+ * may listen. Returns a function that stops this one.
55
+ */
56
+ export declare function subscribeToWatchEvents(workspaceRoot: string, listener: WatchEventsListener): () => void;
57
+ /** Whether a batch carries no change at all. */
58
+ export declare function isEmptyBatch(batch: ChangeBatch): boolean;
59
+ export declare function stopWatchingWorkspaceContext(): void;
19
60
  export declare function getFilesInDirectoryUsingContext(workspaceRoot: string, dir: string): Promise<string[]>;
20
61
  export declare function updateProjectFiles(projectRootMappings: Record<string, string>, rustReferences: NxWorkspaceFilesExternals, updatedFiles: Record<string, string>, deletedFiles: string[]): import("../native").UpdatedWorkspaceFiles;
62
+ /**
63
+ * Re-walks the host's files so the archive its plugin workers load includes
64
+ * writes made since the last walk, such as a migration flushing to disk. The
65
+ * walk is selective and shared through the files lock; one still running is
66
+ * reused rather than repeated.
67
+ */
68
+ export declare function refreshWorkspaceContext(workspaceRoot: string): void;
21
69
  export declare function resetWorkspaceContext(): void;
@@ -8,10 +8,21 @@ exports.multiGlobWithWorkspaceContext = multiGlobWithWorkspaceContext;
8
8
  exports.hashWithWorkspaceContext = hashWithWorkspaceContext;
9
9
  exports.hashMultiGlobWithWorkspaceContext = hashMultiGlobWithWorkspaceContext;
10
10
  exports.updateContextWithChangedFiles = updateContextWithChangedFiles;
11
+ exports.trackedFilesInContext = trackedFilesInContext;
12
+ exports.recordOutputsInContext = recordOutputsInContext;
13
+ exports.outputsUnchangedInContext = outputsUnchangedInContext;
11
14
  exports.updateFilesInContext = updateFilesInContext;
12
15
  exports.getAllFileDataInContext = getAllFileDataInContext;
16
+ exports.subscribeToWorkspaceChanges = subscribeToWorkspaceChanges;
17
+ exports.settleWorkspaceContext = settleWorkspaceContext;
18
+ exports.takeAppliedWorkspaceChanges = takeAppliedWorkspaceChanges;
19
+ exports.isWatchingWorkspaceContext = isWatchingWorkspaceContext;
20
+ exports.subscribeToWatchEvents = subscribeToWatchEvents;
21
+ exports.isEmptyBatch = isEmptyBatch;
22
+ exports.stopWatchingWorkspaceContext = stopWatchingWorkspaceContext;
13
23
  exports.getFilesInDirectoryUsingContext = getFilesInDirectoryUsingContext;
14
24
  exports.updateProjectFiles = updateProjectFiles;
25
+ exports.refreshWorkspaceContext = refreshWorkspaceContext;
15
26
  exports.resetWorkspaceContext = resetWorkspaceContext;
16
27
  const perf_hooks_1 = require("perf_hooks");
17
28
  const cache_directory_1 = require("./cache-directory");
@@ -19,16 +30,36 @@ const is_on_daemon_1 = require("../daemon/is-on-daemon");
19
30
  const client_1 = require("../daemon/client/client");
20
31
  const handle_import_1 = require("./handle-import");
21
32
  let workspaceContext;
22
- function setupWorkspaceContext(workspaceRoot) {
33
+ let filesReady;
34
+ // Survive a reset: the daemon tears its context down and lets the next read
35
+ // recreate it, and that context must watch and report like the one before.
36
+ let contextOptions;
37
+ let contextRoot;
38
+ let contextGeneration = 0;
39
+ const changeListeners = new Set();
40
+ const eventListeners = new Set();
41
+ function setupWorkspaceContext(workspaceRoot, options) {
23
42
  const { WorkspaceContext } = require('../native');
24
43
  perf_hooks_1.performance.mark('workspace-context');
25
- workspaceContext = new WorkspaceContext(workspaceRoot, (0, cache_directory_1.workspaceDataDirectoryForWorkspace)(workspaceRoot));
44
+ const cacheDir = (0, cache_directory_1.workspaceDataDirectoryForWorkspace)(workspaceRoot);
45
+ // A plugin worker is only asked for files after its host finished walking
46
+ // and wrote the archive, so it loads that rather than walking again.
47
+ workspaceContext = global.NX_PLUGIN_WORKER
48
+ ? WorkspaceContext.fromArchive(workspaceRoot, cacheDir, options)
49
+ : new WorkspaceContext(workspaceRoot, cacheDir, options);
50
+ contextOptions = options;
51
+ contextRoot = workspaceRoot;
52
+ contextGeneration++;
53
+ filesReady = undefined;
54
+ if (options?.watch) {
55
+ attachSubscribers();
56
+ }
26
57
  perf_hooks_1.performance.mark('workspace-context:end');
27
58
  perf_hooks_1.performance.measure('workspace context init', 'workspace-context', 'workspace-context:end');
28
59
  }
29
60
  async function getNxWorkspaceFilesFromContext(workspaceRoot, projectRootMap, useDaemonProcess = true) {
30
61
  if (!useDaemonProcess || (0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
31
- ensureContextAvailable(workspaceRoot);
62
+ await ensureFilesReady(workspaceRoot);
32
63
  return workspaceContext.getWorkspaceFiles(projectRootMap);
33
64
  }
34
65
  return client_1.daemonClient.getWorkspaceFiles(projectRootMap);
@@ -46,7 +77,7 @@ function globWithWorkspaceContextSync(workspaceRoot, globs, exclude) {
46
77
  }
47
78
  async function globWithWorkspaceContext(workspaceRoot, globs, exclude) {
48
79
  if (workspaceRoot === '/virtual' || (0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
49
- ensureContextAvailable(workspaceRoot);
80
+ await ensureFilesReady(workspaceRoot);
50
81
  return workspaceContext.glob(globs, exclude);
51
82
  }
52
83
  else {
@@ -55,21 +86,21 @@ async function globWithWorkspaceContext(workspaceRoot, globs, exclude) {
55
86
  }
56
87
  async function multiGlobWithWorkspaceContext(workspaceRoot, globs, exclude) {
57
88
  if (workspaceRoot === '/virtual' || (0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
58
- ensureContextAvailable(workspaceRoot);
89
+ await ensureFilesReady(workspaceRoot);
59
90
  return workspaceContext.multiGlob(globs, exclude);
60
91
  }
61
92
  return client_1.daemonClient.multiGlob(globs, exclude);
62
93
  }
63
94
  async function hashWithWorkspaceContext(workspaceRoot, globs, exclude) {
64
95
  if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
65
- ensureContextAvailable(workspaceRoot);
96
+ await ensureFilesReady(workspaceRoot);
66
97
  return workspaceContext.hashFilesMatchingGlob(globs, exclude);
67
98
  }
68
99
  return client_1.daemonClient.hashGlob(globs, exclude);
69
100
  }
70
101
  async function hashMultiGlobWithWorkspaceContext(workspaceRoot, globGroups) {
71
102
  if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
72
- ensureContextAvailable(workspaceRoot);
103
+ await ensureFilesReady(workspaceRoot);
73
104
  return workspaceContext.hashFilesMatchingGlobs(globGroups);
74
105
  }
75
106
  return client_1.daemonClient.hashMultiGlob(globGroups);
@@ -89,20 +120,116 @@ async function updateContextWithChangedFiles(workspaceRoot, createdFiles, update
89
120
  await client_1.daemonClient.updateWorkspaceContext(createdFiles, updatedFiles, deletedFiles);
90
121
  }
91
122
  }
123
+ /**
124
+ * The subset of `paths` the workspace file map holds: what the watch tracks,
125
+ * with the ignore rules applied.
126
+ */
127
+ function trackedFilesInContext(workspaceRoot, paths) {
128
+ ensureContextAvailable(workspaceRoot);
129
+ return workspaceContext?.trackedFiles(paths) ?? [];
130
+ }
131
+ /** Remembers each task's outputs, as given or else as they are on disk now. */
132
+ function recordOutputsInContext(workspaceRoot, entries) {
133
+ ensureContextAvailable(workspaceRoot);
134
+ workspaceContext?.recordOutputs(entries);
135
+ }
136
+ /** Whether each task's outputs are still as last recorded for its hash. */
137
+ function outputsUnchangedInContext(workspaceRoot, entries) {
138
+ ensureContextAvailable(workspaceRoot);
139
+ return (workspaceContext?.outputsUnchanged(entries) ?? entries.map(() => false));
140
+ }
92
141
  function updateFilesInContext(workspaceRoot, updatedFiles, deletedFiles) {
93
142
  ensureContextAvailable(workspaceRoot);
94
143
  return workspaceContext?.incrementalUpdate(updatedFiles, deletedFiles);
95
144
  }
96
145
  async function getAllFileDataInContext(workspaceRoot) {
97
146
  if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
98
- ensureContextAvailable(workspaceRoot);
147
+ await ensureFilesReady(workspaceRoot);
99
148
  return workspaceContext.allFileData();
100
149
  }
101
150
  return client_1.daemonClient.getWorkspaceContextFileData();
102
151
  }
152
+ /**
153
+ * Listens for the changes a watching context applies: each change reaches the
154
+ * listeners once, here or in `settleWorkspaceContext`, whichever takes it
155
+ * first. Any number of listeners may listen. Returns a function that stops
156
+ * this one.
157
+ */
158
+ function subscribeToWorkspaceChanges(workspaceRoot, listener) {
159
+ changeListeners.add(listener);
160
+ ensureContextAvailable(workspaceRoot);
161
+ attachSubscribers();
162
+ return () => changeListeners.delete(listener);
163
+ }
164
+ /**
165
+ * Applies every change the watcher has delivered, waiting out the kernel hop,
166
+ * and takes every change applied and not yet handed out. Empty when the
167
+ * context is not watching.
168
+ */
169
+ function settleWorkspaceContext(workspaceRoot) {
170
+ ensureContextAvailable(workspaceRoot);
171
+ return workspaceContext.settle();
172
+ }
173
+ /**
174
+ * Takes every change applied and not yet handed out, without waiting for the
175
+ * watcher: for a caller that has just applied changes itself.
176
+ */
177
+ function takeAppliedWorkspaceChanges(workspaceRoot) {
178
+ ensureContextAvailable(workspaceRoot);
179
+ return workspaceContext.takeAppliedChanges();
180
+ }
181
+ function isWatchingWorkspaceContext() {
182
+ return !!contextOptions?.watch;
183
+ }
184
+ /**
185
+ * Listens for every event the context's watch delivers, including writes
186
+ * under ignored directories and the `rescan` marker. Any number of listeners
187
+ * may listen. Returns a function that stops this one.
188
+ */
189
+ function subscribeToWatchEvents(workspaceRoot, listener) {
190
+ eventListeners.add(listener);
191
+ ensureContextAvailable(workspaceRoot);
192
+ attachSubscribers();
193
+ return () => eventListeners.delete(listener);
194
+ }
195
+ /** Whether a batch carries no change at all. */
196
+ function isEmptyBatch(batch) {
197
+ return (batch.createdFiles.length === 0 &&
198
+ batch.updatedFiles.length === 0 &&
199
+ batch.deletedFiles.length === 0);
200
+ }
201
+ /**
202
+ * The native context takes one subscriber per stream; it fans out here. A
203
+ * delivery a replaced context had already queued does not reach listeners as
204
+ * if it came from the current one.
205
+ */
206
+ function attachSubscribers() {
207
+ if (!workspaceContext || !contextOptions?.watch)
208
+ return;
209
+ const generation = contextGeneration;
210
+ const current = () => generation === contextGeneration;
211
+ workspaceContext.onChanges((err, batch) => {
212
+ if (!current() || (!err && (!batch || isEmptyBatch(batch))))
213
+ return;
214
+ for (const listener of changeListeners)
215
+ listener(err, batch);
216
+ });
217
+ workspaceContext.onWatchEvents((err, events) => {
218
+ if (!current())
219
+ return;
220
+ for (const listener of eventListeners)
221
+ listener(err, events);
222
+ });
223
+ }
224
+ function stopWatchingWorkspaceContext() {
225
+ changeListeners.clear();
226
+ eventListeners.clear();
227
+ contextOptions = undefined;
228
+ workspaceContext?.stopWatching();
229
+ }
103
230
  async function getFilesInDirectoryUsingContext(workspaceRoot, dir) {
104
231
  if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
105
- ensureContextAvailable(workspaceRoot);
232
+ await ensureFilesReady(workspaceRoot);
106
233
  return workspaceContext.getFilesInDirectory(dir);
107
234
  }
108
235
  return client_1.daemonClient.getFilesInDirectory(dir);
@@ -110,11 +237,48 @@ async function getFilesInDirectoryUsingContext(workspaceRoot, dir) {
110
237
  function updateProjectFiles(projectRootMappings, rustReferences, updatedFiles, deletedFiles) {
111
238
  return workspaceContext?.updateProjectFiles(projectRootMappings, rustReferences.projectFiles, rustReferences.globalFiles, updatedFiles, deletedFiles);
112
239
  }
240
+ /**
241
+ * Waits for the walk behind the context without holding the event loop. The
242
+ * native readers block the calling thread until the files exist, so the async
243
+ * entry points await this first; a plugin host is then never frozen while a
244
+ * worker is connecting to it.
245
+ */
246
+ async function ensureFilesReady(workspaceRoot) {
247
+ ensureContextAvailable(workspaceRoot);
248
+ // A binding without `ready` (an older native build, a mocked one) reads
249
+ // synchronously as before.
250
+ filesReady ??= workspaceContext.ready?.() ?? Promise.resolve();
251
+ await filesReady;
252
+ }
253
+ /**
254
+ * Re-walks the host's files so the archive its plugin workers load includes
255
+ * writes made since the last walk, such as a migration flushing to disk. The
256
+ * walk is selective and shared through the files lock; one still running is
257
+ * reused rather than repeated.
258
+ */
259
+ function refreshWorkspaceContext(workspaceRoot) {
260
+ if (workspaceRoot === '/virtual' || (0, is_on_daemon_1.isOnDaemon)() || client_1.daemonClient.enabled()) {
261
+ return;
262
+ }
263
+ if (workspaceContext?.workspaceRoot !== workspaceRoot) {
264
+ setupWorkspaceContext(workspaceRoot);
265
+ return;
266
+ }
267
+ workspaceContext.refresh();
268
+ filesReady = undefined;
269
+ }
113
270
  function ensureContextAvailable(workspaceRoot) {
114
271
  if (!workspaceContext || workspaceContext?.workspaceRoot !== workspaceRoot) {
115
- setupWorkspaceContext(workspaceRoot);
272
+ setupWorkspaceContext(workspaceRoot, contextOptions);
116
273
  }
117
274
  }
118
275
  function resetWorkspaceContext() {
276
+ workspaceContext?.stopWatching?.();
119
277
  workspaceContext = undefined;
278
+ filesReady = undefined;
279
+ // A watching context is the daemon's only watch; left for the next read to
280
+ // re-create, output and dotenv events in between would be lost.
281
+ if (contextOptions?.watch && contextRoot) {
282
+ setupWorkspaceContext(contextRoot, contextOptions);
283
+ }
120
284
  }