@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.
- package/README.md +8 -19
- package/changes.json +10 -54
- package/dist/bin/init-local.js +7 -1
- package/dist/nx-cloud-internals.d.ts +1 -0
- package/dist/nx-cloud-internals.js +9 -0
- package/dist/plugins/package-json.js +1 -1
- package/dist/src/command-line/add/add.js +5 -1
- package/dist/src/command-line/affected/affected.js +70 -9
- package/dist/src/command-line/affected/command-object.js +1 -1
- package/dist/src/command-line/format/format.js +2 -18
- package/dist/src/command-line/graph/graph.d.ts +31 -0
- package/dist/src/command-line/graph/graph.js +113 -20
- package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +0 -3
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +0 -3
- package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +0 -3
- package/dist/src/command-line/init/implementation/angular/index.js +0 -3
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +0 -3
- package/dist/src/command-line/init/implementation/format.js +2 -3
- package/dist/src/command-line/init/implementation/utils.d.ts +0 -1
- package/dist/src/command-line/init/implementation/utils.js +6 -9
- package/dist/src/command-line/init/init-v2.js +0 -3
- package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +25 -0
- package/dist/src/command-line/migrate/agentic/capture-generator-output.js +121 -5
- package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +21 -0
- package/dist/src/command-line/migrate/agentic/close-agent-session.js +126 -0
- package/dist/src/command-line/migrate/agentic/definitions.d.ts +24 -0
- package/dist/src/command-line/migrate/agentic/definitions.js +79 -20
- package/dist/src/command-line/migrate/agentic/format-command.d.ts +14 -0
- package/dist/src/command-line/migrate/agentic/format-command.js +44 -0
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +3 -3
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +3 -3
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +50 -17
- package/dist/src/command-line/migrate/agentic/handoff.js +166 -24
- package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +23 -0
- package/dist/src/command-line/migrate/agentic/instruction-files.js +41 -0
- package/dist/src/command-line/migrate/agentic/master/invocations.d.ts +12 -0
- package/dist/src/command-line/migrate/agentic/master/invocations.js +54 -0
- package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +16 -0
- package/dist/src/command-line/migrate/agentic/master/run-master-session.js +175 -0
- package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +31 -0
- package/dist/src/command-line/migrate/agentic/master/spawn-master.js +222 -0
- package/dist/src/command-line/migrate/agentic/prompts/final-validation.d.ts +13 -0
- package/dist/src/command-line/migrate/agentic/prompts/final-validation.js +41 -0
- package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +17 -0
- package/dist/src/command-line/migrate/agentic/prompts/fragments.js +90 -0
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +4 -3
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +25 -1
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +57 -34
- package/dist/src/command-line/migrate/agentic/run-step.js +28 -4
- package/dist/src/command-line/migrate/agentic/runner.d.ts +3 -15
- package/dist/src/command-line/migrate/agentic/runner.js +57 -239
- package/dist/src/command-line/migrate/agentic/terminal-repair.d.ts +1 -0
- package/dist/src/command-line/migrate/agentic/terminal-repair.js +27 -0
- package/dist/src/command-line/migrate/agentic/types.d.ts +23 -8
- package/dist/src/command-line/migrate/agentic/types.js +10 -7
- package/dist/src/command-line/migrate/agentic/windows-cmd.d.ts +33 -0
- package/dist/src/command-line/migrate/agentic/windows-cmd.js +88 -0
- package/dist/src/command-line/migrate/command-object.d.ts +2 -0
- package/dist/src/command-line/migrate/command-object.js +11 -1
- package/dist/src/command-line/migrate/deferred-output.d.ts +44 -0
- package/dist/src/command-line/migrate/deferred-output.js +92 -0
- package/dist/src/command-line/migrate/execute-migration.d.ts +9 -3
- package/dist/src/command-line/migrate/execute-migration.js +53 -16
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +34 -9
- package/dist/src/command-line/migrate/migrate-analytics.js +71 -10
- package/dist/src/command-line/migrate/migrate-commits.d.ts +5 -4
- package/dist/src/command-line/migrate/migrate-commits.js +16 -6
- package/dist/src/command-line/migrate/migrate-config.d.ts +5 -2
- package/dist/src/command-line/migrate/migrate-config.js +19 -11
- package/dist/src/command-line/migrate/migrate-output.d.ts +3 -7
- package/dist/src/command-line/migrate/migrate-output.js +3 -7
- package/dist/src/command-line/migrate/migrate.d.ts +3 -0
- package/dist/src/command-line/migrate/migrate.js +183 -46
- package/dist/src/command-line/migrate/resolve-package-version.js +2 -19
- package/dist/src/command-line/migrate/run/agent-output.d.ts +11 -0
- package/dist/src/command-line/migrate/run/agent-output.js +21 -2
- package/dist/src/command-line/migrate/run/agent-work-payload.d.ts +37 -0
- package/dist/src/command-line/migrate/run/agent-work-payload.js +156 -0
- package/dist/src/command-line/migrate/run/atomic-write.d.ts +8 -0
- package/dist/src/command-line/migrate/run/atomic-write.js +17 -0
- package/dist/src/command-line/migrate/run/broker.d.ts +150 -0
- package/dist/src/command-line/migrate/run/broker.js +568 -0
- package/dist/src/command-line/migrate/run/clean-retry.d.ts +12 -0
- package/dist/src/command-line/migrate/run/clean-retry.js +99 -0
- package/dist/src/command-line/migrate/run/existing-run-report.d.ts +55 -0
- package/dist/src/command-line/migrate/run/existing-run-report.js +227 -0
- package/dist/src/command-line/migrate/run/give-up.d.ts +41 -0
- package/dist/src/command-line/migrate/run/give-up.js +148 -0
- package/dist/src/command-line/migrate/run/index.d.ts +9 -6
- package/dist/src/command-line/migrate/run/index.js +21 -2
- package/dist/src/command-line/migrate/run/issues.d.ts +127 -0
- package/dist/src/command-line/migrate/run/issues.js +1121 -0
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +59 -1
- package/dist/src/command-line/migrate/run/orchestrator.js +1529 -457
- package/dist/src/command-line/migrate/run/run-id.d.ts +0 -8
- package/dist/src/command-line/migrate/run/run-id.js +0 -30
- package/dist/src/command-line/migrate/run/run-state.d.ts +77 -17
- package/dist/src/command-line/migrate/run/run-state.js +263 -32
- package/dist/src/command-line/migrate/run/runbook.d.ts +18 -0
- package/dist/src/command-line/migrate/run/runbook.js +118 -0
- package/dist/src/command-line/migrate/run/state-lock.d.ts +33 -2
- package/dist/src/command-line/migrate/run/state-lock.js +128 -2
- package/dist/src/command-line/migrate/run/state-machine.d.ts +50 -1
- package/dist/src/command-line/migrate/run/state-machine.js +339 -26
- package/dist/src/command-line/migrate/run/util.d.ts +3 -1
- package/dist/src/command-line/migrate/run/util.js +24 -3
- package/dist/src/command-line/migrate/run/worker.js +290 -129
- package/dist/src/command-line/migrate/step-actions.d.ts +1 -1
- package/dist/src/command-line/migrate/step-actions.js +7 -1
- package/dist/src/command-line/migrate/text.d.ts +6 -0
- package/dist/src/command-line/migrate/text.js +25 -0
- package/dist/src/command-line/migrate/version-skew-guard.js +2 -0
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +5 -11
- package/dist/src/command-line/release/publish.js +11 -8
- package/dist/src/command-line/release/utils/get-touched-projects-for-group.js +3 -3
- package/dist/src/command-line/release/utils/release-graph.js +1 -1
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +5 -8
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +3 -3
- package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +4 -2
- package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +37 -3
- package/dist/src/command-line/release/version/version-actions.d.ts +3 -0
- package/dist/src/command-line/reset/reset.js +10 -4
- package/dist/src/command-line/run/run-one.js +5 -1
- package/dist/src/command-line/run-many/run-many.js +6 -12
- package/dist/src/command-line/show/command-object.js +1 -1
- package/dist/src/command-line/show/projects.js +52 -1
- package/dist/src/command-line/yargs-utils/shared-options.d.ts +5 -1
- package/dist/src/command-line/yargs-utils/shared-options.js +38 -4
- package/dist/src/config/task-graph.d.ts +1 -1
- package/dist/src/config/workspace-json-project-json.d.ts +23 -1
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/runtime.js +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/client.d.ts +14 -8
- package/dist/src/daemon/client/client.js +41 -12
- package/dist/src/daemon/message-types/get-plugin-capabilities.d.ts +5 -0
- package/dist/src/daemon/message-types/get-plugin-capabilities.js +11 -0
- package/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts +3 -2
- package/dist/src/daemon/message-types/select-affected-tasks.d.ts +21 -0
- package/dist/src/daemon/message-types/select-affected-tasks.js +11 -0
- package/dist/src/daemon/message-types/ultracache-configuration-version.d.ts +8 -0
- package/dist/src/daemon/message-types/ultracache-configuration-version.js +2 -0
- package/dist/src/daemon/server/dotenv-graph-changes.d.ts +1 -1
- package/dist/src/daemon/server/dotenv-graph-changes.js +2 -2
- package/dist/src/daemon/server/handle-get-plugin-capabilities.d.ts +2 -0
- package/dist/src/daemon/server/handle-get-plugin-capabilities.js +13 -0
- package/dist/src/daemon/server/handle-hash-tasks.d.ts +10 -2
- package/dist/src/daemon/server/handle-hash-tasks.js +18 -3
- package/dist/src/daemon/server/handle-select-affected-tasks.d.ts +3 -0
- package/dist/src/daemon/server/handle-select-affected-tasks.js +26 -0
- package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +3 -2
- package/dist/src/daemon/server/{handle-outputs-changes.d.ts → handle-watch-events.d.ts} +4 -4
- package/dist/src/daemon/server/{handle-outputs-changes.js → handle-watch-events.js} +36 -37
- package/dist/src/daemon/server/outputs-tracking.d.ts +7 -19
- package/dist/src/daemon/server/outputs-tracking.js +7 -107
- package/dist/src/daemon/server/planning-context.d.ts +8 -0
- package/dist/src/daemon/server/planning-context.js +18 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +22 -7
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +104 -74
- package/dist/src/daemon/server/restart-checks.d.ts +22 -0
- package/dist/src/daemon/server/restart-checks.js +77 -0
- package/dist/src/daemon/server/server.d.ts +1 -0
- package/dist/src/daemon/server/server.js +54 -30
- package/dist/src/daemon/server/shutdown-utils.d.ts +0 -5
- package/dist/src/daemon/server/shutdown-utils.js +3 -26
- package/dist/src/daemon/server/ultracache-configuration-state.d.ts +7 -0
- package/dist/src/daemon/server/ultracache-configuration-state.js +36 -0
- package/dist/src/devkit-internals.d.ts +3 -1
- package/dist/src/devkit-internals.js +8 -3
- package/dist/src/executors/run-commands/run-commands.impl.d.ts +2 -1
- package/dist/src/executors/run-commands/run-commands.impl.js +19 -5
- package/dist/src/executors/run-commands/running-tasks.d.ts +5 -4
- package/dist/src/executors/run-commands/running-tasks.js +13 -13
- package/dist/src/hasher/create-task-hasher.d.ts +8 -1
- package/dist/src/hasher/create-task-hasher.js +13 -3
- package/dist/src/hasher/hash-plan-inspector.js +2 -2
- package/dist/src/hasher/hash-task.d.ts +2 -2
- package/dist/src/hasher/hash-task.js +28 -17
- package/dist/src/hasher/native-task-hasher-impl.d.ts +20 -4
- package/dist/src/hasher/native-task-hasher-impl.js +75 -9
- package/dist/src/hasher/task-hasher.d.ts +24 -7
- package/dist/src/hasher/task-hasher.js +27 -8
- package/dist/src/hasher/task-planning-context.d.ts +13 -0
- package/dist/src/hasher/task-planning-context.js +12 -0
- package/dist/src/native/index.d.ts +582 -21
- package/dist/src/native/index.js +3 -3
- package/dist/src/native/native-bindings.js +13 -1
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/native/transform-objects.d.ts +11 -2
- package/dist/src/native/transform-objects.js +46 -0
- package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +15 -8
- package/dist/src/nx-cloud/update-manager.d.ts +3 -0
- package/dist/src/nx-cloud/update-manager.js +19 -13
- package/dist/src/nx-cloud/utilities/client.d.ts +1 -1
- package/dist/src/nx-cloud/utilities/client.js +1 -1
- package/dist/src/nx-cloud/utilities/is-workspace-claimed.js +2 -1
- package/dist/src/nx-cloud/utilities/nx-cloud-http-client.d.ts +5 -0
- package/dist/src/nx-cloud/utilities/nx-cloud-http-client.js +16 -0
- package/dist/src/nx-cloud/utilities/url-shorten.js +17 -10
- package/dist/src/plugins/js/index.js +45 -64
- package/dist/src/plugins/js/lock-file/lock-file.d.ts +4 -4
- package/dist/src/plugins/js/lock-file/lock-file.js +6 -7
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +1 -1
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +2 -0
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +22 -0
- package/dist/src/plugins/js/project-graph/affected/lock-file-changes.d.ts +10 -2
- package/dist/src/plugins/js/project-graph/affected/lock-file-changes.js +51 -29
- package/dist/src/plugins/js/project-graph/affected/npm-packages.d.ts +10 -2
- package/dist/src/plugins/js/project-graph/affected/npm-packages.js +32 -11
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +22 -18
- package/dist/src/plugins/js/utils/register.js +13 -4
- package/dist/src/plugins/package-json/create-nodes.d.ts +2 -2
- package/dist/src/plugins/package-json/create-nodes.js +13 -13
- package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +14 -0
- package/dist/src/project-graph/affected/affected-project-graph.js +5 -18
- package/dist/src/project-graph/affected/affected-projects.d.ts +7 -0
- package/dist/src/project-graph/affected/affected-projects.js +42 -0
- package/dist/src/project-graph/affected/affected-reasons.d.ts +116 -0
- package/dist/src/project-graph/affected/affected-reasons.js +459 -0
- package/dist/src/project-graph/affected/affected-tasks.d.ts +103 -0
- package/dist/src/project-graph/affected/affected-tasks.js +386 -0
- package/dist/src/project-graph/affected/print-explanation.d.ts +11 -0
- package/dist/src/project-graph/affected/print-explanation.js +44 -0
- package/dist/src/project-graph/error-types.d.ts +5 -0
- package/dist/src/project-graph/error-types.js +44 -5
- package/dist/src/project-graph/file-utils.d.ts +2 -0
- package/dist/src/project-graph/file-utils.js +12 -3
- package/dist/src/project-graph/nx-deps-cache.d.ts +5 -2
- package/dist/src/project-graph/nx-deps-cache.js +4 -4
- package/dist/src/project-graph/plugins/get-plugins.d.ts +3 -1
- package/dist/src/project-graph/plugins/get-plugins.js +60 -82
- package/dist/src/project-graph/plugins/in-process-loader.d.ts +1 -1
- package/dist/src/project-graph/plugins/in-process-loader.js +1 -4
- package/dist/src/project-graph/plugins/isolation/index.d.ts +1 -1
- package/dist/src/project-graph/plugins/isolation/index.js +3 -1
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +8 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +42 -6
- package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.d.ts +10 -1
- package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.js +67 -17
- package/dist/src/project-graph/plugins/isolation/messaging.d.ts +3 -2
- package/dist/src/project-graph/plugins/isolation/plugin-worker.js +5 -1
- package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +5 -2
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +14 -1
- package/dist/src/project-graph/plugins/nx-plugin-capabilities.d.ts +6 -0
- package/dist/src/project-graph/plugins/nx-plugin-capabilities.js +28 -0
- package/dist/src/project-graph/plugins/task-results-stub.d.ts +50 -0
- package/dist/src/project-graph/plugins/task-results-stub.js +111 -0
- package/dist/src/project-graph/plugins/tasks-execution-hooks.d.ts +3 -2
- package/dist/src/project-graph/plugins/tasks-execution-hooks.js +14 -1
- package/dist/src/project-graph/project-graph.js +43 -42
- package/dist/src/project-graph/utils/project-configuration/target-merging.js +67 -0
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +83 -0
- package/dist/src/project-graph/utils/project-configuration/utils.d.ts +1 -0
- package/dist/src/project-graph/utils/project-configuration/utils.js +1 -0
- package/dist/src/tasks-runner/batch/run-batch.js +15 -0
- package/dist/src/tasks-runner/cache.d.ts +37 -2
- package/dist/src/tasks-runner/cache.js +42 -1
- package/dist/src/tasks-runner/create-task-graph.d.ts +24 -1
- package/dist/src/tasks-runner/create-task-graph.js +57 -2
- package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
- package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
- package/dist/src/tasks-runner/forked-process-task-runner.js +11 -10
- package/dist/src/tasks-runner/init-tasks-runner.d.ts +7 -2
- package/dist/src/tasks-runner/init-tasks-runner.js +15 -7
- package/dist/src/tasks-runner/is-tui-enabled.js +4 -3
- package/dist/src/tasks-runner/life-cycle.d.ts +7 -0
- package/dist/src/tasks-runner/life-cycle.js +7 -0
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.d.ts +35 -0
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +146 -0
- package/dist/src/tasks-runner/prune-task-graph.d.ts +17 -0
- package/dist/src/tasks-runner/prune-task-graph.js +45 -0
- package/dist/src/tasks-runner/run-command.d.ts +41 -5
- package/dist/src/tasks-runner/run-command.js +98 -22
- package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +93 -19
- package/dist/src/tasks-runner/running-tasks/batch-process.js +184 -88
- package/dist/src/tasks-runner/task-io-service.d.ts +11 -3
- package/dist/src/tasks-runner/task-io-service.js +14 -5
- package/dist/src/tasks-runner/task-orchestrator.d.ts +71 -4
- package/dist/src/tasks-runner/task-orchestrator.js +266 -66
- package/dist/src/tasks-runner/tasks-runner.d.ts +2 -0
- package/dist/src/tasks-runner/terminal-output-path.d.ts +11 -0
- package/dist/src/tasks-runner/terminal-output-path.js +18 -0
- package/dist/src/tasks-runner/utils.d.ts +5 -0
- package/dist/src/tasks-runner/utils.js +14 -2
- package/dist/src/ultracache/config.d.ts +21 -0
- package/dist/src/ultracache/config.js +29 -0
- package/dist/src/ultracache/fetch.d.ts +21 -0
- package/dist/src/ultracache/fetch.js +43 -0
- package/dist/src/ultracache/overrides.d.ts +17 -0
- package/dist/src/ultracache/overrides.js +61 -0
- package/dist/src/ultracache/report.d.ts +13 -0
- package/dist/src/ultracache/report.js +62 -0
- package/dist/src/ultracache/store.d.ts +41 -0
- package/dist/src/ultracache/store.js +158 -0
- package/dist/src/utils/ab-testing.d.ts +4 -1
- package/dist/src/utils/ab-testing.js +22 -19
- package/dist/src/utils/chunkify.d.ts +1 -7
- package/dist/src/utils/chunkify.js +2 -8
- package/dist/src/utils/command-line-utils.d.ts +20 -0
- package/dist/src/utils/command-line-utils.js +10 -3
- package/dist/src/utils/create-cli-options.d.ts +6 -0
- package/dist/src/utils/create-cli-options.js +29 -0
- package/dist/src/utils/db-connection.d.ts +2 -0
- package/dist/src/utils/db-connection.js +2 -0
- package/dist/src/utils/formatters/index.d.ts +6 -0
- package/dist/src/utils/formatters/index.js +5 -0
- package/dist/src/utils/formatters/prettier.d.ts +0 -8
- package/dist/src/utils/formatters/prettier.js +4 -26
- package/dist/src/utils/git-utils.d.ts +19 -0
- package/dist/src/utils/git-utils.js +97 -39
- package/dist/src/utils/handle-errors.js +5 -43
- package/dist/src/utils/http-client.d.ts +27 -0
- package/dist/src/utils/http-client.js +193 -0
- package/dist/src/utils/installed-nx-version.js +2 -48
- package/dist/src/utils/json-diff.d.ts +4 -2
- package/dist/src/utils/json-diff.js +6 -94
- package/dist/src/utils/min-release-age/packument.js +1 -1
- package/dist/src/utils/nx-cloud-utils.d.ts +2 -0
- package/dist/src/utils/nx-cloud-utils.js +6 -1
- package/dist/src/utils/output.d.ts +22 -3
- package/dist/src/utils/output.js +28 -5
- package/dist/src/utils/package-json.d.ts +25 -0
- package/dist/src/utils/package-json.js +49 -6
- package/dist/src/utils/package-manager.d.ts +6 -0
- package/dist/src/utils/package-manager.js +10 -0
- package/dist/src/utils/plugins/plugin-capabilities.js +7 -2
- package/dist/src/utils/project-graph-utils.d.ts +2 -0
- package/dist/src/utils/project-graph-utils.js +12 -0
- package/dist/src/utils/provenance.js +20 -4
- package/dist/src/utils/serialize-overrides-into-command-line.js +2 -4
- package/dist/src/utils/workspace-context.d.ts +51 -3
- package/dist/src/utils/workspace-context.js +174 -10
- package/package.json +38 -100
- package/schemas/nx-schema.json +38 -0
- package/schemas/project-schema.json +35 -0
- package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +0 -9
- package/dist/src/daemon/server/file-watching/route-workspace-changes.js +0 -76
- package/dist/src/daemon/server/watcher.d.ts +0 -18
- package/dist/src/daemon/server/watcher.js +0 -126
- package/dist/src/nx-cloud/utilities/axios.d.ts +0 -4
- package/dist/src/nx-cloud/utilities/axios.js +0 -17
- package/dist/src/project-graph/affected/locators/project-glob-changes.d.ts +0 -2
- package/dist/src/project-graph/affected/locators/project-glob-changes.js +0 -47
- package/dist/src/project-graph/affected/locators/workspace-json-changes.d.ts +0 -4
- package/dist/src/project-graph/affected/locators/workspace-json-changes.js +0 -47
- package/dist/src/project-graph/affected/locators/workspace-projects.d.ts +0 -3
- package/dist/src/project-graph/affected/locators/workspace-projects.js +0 -74
- package/dist/src/utils/collapse-expanded-outputs.d.ts +0 -10
- package/dist/src/utils/collapse-expanded-outputs.js +0 -72
|
@@ -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,
|
|
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
|
|
53
|
-
//
|
|
54
|
-
//
|
|
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.
|
|
60
|
-
ctx.
|
|
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
|
|
78
|
-
// is
|
|
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: [
|
|
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
|
|
114
|
-
//
|
|
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.
|
|
156
|
+
ctx.instructionsPointer,
|
|
127
157
|
],
|
|
128
|
-
env: { OPENCODE_CONFIG_CONTENT:
|
|
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
|
|
4
|
-
* run state and its plan snapshots for the orchestrator. The v23
|
|
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
|
*
|
|
@@ -11,9 +11,9 @@ const logger_1 = require("../../../utils/logger");
|
|
|
11
11
|
const types_1 = require("./types");
|
|
12
12
|
/**
|
|
13
13
|
* Both the agentic runner and the orchestrator write per-run scratch under
|
|
14
|
-
* `.nx/migrate-runs/<run-id>/`: handoff files in both cases, plus
|
|
15
|
-
* run state and its plan snapshots for the orchestrator. The v23
|
|
16
|
-
* `23-0-0-add-migrate-runs-to-git-ignore` adds `.nx/migrate-runs` to
|
|
14
|
+
* `.nx/migrate-runs/<run-id>/`: handoff and prompt files in both cases, plus
|
|
15
|
+
* the durable run state and its plan snapshots for the orchestrator. The v23
|
|
16
|
+
* migration `23-0-0-add-migrate-runs-to-git-ignore` adds `.nx/migrate-runs` to
|
|
17
17
|
* `.gitignore`; in its declared slot (typically late) earlier per-migration
|
|
18
18
|
* commits would absorb the scratch into the user-visible diff.
|
|
19
19
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BigIntStats } from 'fs';
|
|
1
2
|
import { HandoffFile } from './types';
|
|
2
3
|
/** Returns the run directory for a given workspace + run id (target version). */
|
|
3
4
|
export declare function runDirPath(workspaceRoot: string, runId: string): string;
|
|
@@ -19,19 +20,17 @@ export declare function mkdirSafely(dir: string, purpose: string): void;
|
|
|
19
20
|
* inspection.
|
|
20
21
|
*/
|
|
21
22
|
export declare function initRunDir(workspaceRoot: string, runId: string): string;
|
|
22
|
-
|
|
23
|
-
* Absolute path of the handoff file for a migration step within a run, under
|
|
24
|
-
* the run directory's `handoffs/` subtree: the pre-authorized write scope
|
|
25
|
-
* stops there, so a handoff placed anywhere else costs an approval prompt.
|
|
26
|
-
* The package's scope (if any) becomes a real subdirectory so the package name
|
|
27
|
-
* stays readable; two packages can ship a migration with the same name without
|
|
28
|
-
* colliding because they land in different package subdirectories. Each
|
|
29
|
-
* segment is sanitized so the path is always writable on every platform.
|
|
30
|
-
*/
|
|
23
|
+
export declare function truncateUtf8(value: string, maxBytes: number): string;
|
|
31
24
|
export declare function stepHandoffPath(runDir: string, migration: {
|
|
32
25
|
package: string;
|
|
33
26
|
name: string;
|
|
34
27
|
}): string;
|
|
28
|
+
/** Handoff path for a run step. No hash needed: step ids are unique within the run. */
|
|
29
|
+
export declare function runStepHandoffPath(runDir: string, stepId: string): string;
|
|
30
|
+
export declare function stepPromptsDir(runDir: string, migration: {
|
|
31
|
+
package: string;
|
|
32
|
+
name: string;
|
|
33
|
+
}): string;
|
|
35
34
|
export type HandoffReadFailureReason = 'missing' | 'read-error' | 'parse-error' | 'shape-mismatch';
|
|
36
35
|
export type HandoffReadResult = {
|
|
37
36
|
ok: true;
|
|
@@ -42,19 +41,53 @@ export type HandoffReadResult = {
|
|
|
42
41
|
detail?: string;
|
|
43
42
|
};
|
|
44
43
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
* `lstat`, not `stat`: a symlink in the handoffs dir's place would send every
|
|
45
|
+
* handoff read and removal wherever it points.
|
|
46
|
+
*/
|
|
47
|
+
export declare function handoffsDirState(handoffsDir: string): 'directory' | 'missing' | 'other';
|
|
48
|
+
/**
|
|
49
|
+
* Non-recursive mkdir: the run dir exists, and a symlink created after the
|
|
50
|
+
* missing-path check fails with EEXIST instead of being followed.
|
|
51
|
+
*/
|
|
52
|
+
export declare function ensureRunSubdir(dir: string, notADirectory: () => Error): void;
|
|
53
|
+
/**
|
|
54
|
+
* Thrown by {@link readInspectedFile} when the opened descriptor is not the
|
|
55
|
+
* file the caller's lstat described: a symlink followed on Windows, or an
|
|
56
|
+
* atomic replacement between the lstat and the open.
|
|
57
|
+
*/
|
|
58
|
+
export declare class FileReplacedDuringReadError extends Error {
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Reads the file `stat` describes, refusing a symlink swapped in after the
|
|
62
|
+
* caller's lstat: O_NOFOLLOW fails the open with ELOOP, and O_NONBLOCK keeps a
|
|
63
|
+
* planted FIFO from blocking it. Windows has neither flag, so there the inode
|
|
64
|
+
* comparison is what catches a followed symlink. It does not guard against an
|
|
65
|
+
* unlink and recreate reusing the inode number. Read errors propagate: a file
|
|
66
|
+
* the agent cannot read must not pass.
|
|
67
|
+
*/
|
|
68
|
+
export declare function readInspectedFile(filePath: string, stat: BigIntStats, replacedMessage: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Reads a file its owner publishes atomically (tmp + rename), with
|
|
71
|
+
* {@link readInspectedFile}'s refusal of a symlink or FIFO but tolerant of the
|
|
72
|
+
* publish: a rename swaps the inode between the lstat and the open, read as a
|
|
73
|
+
* replacement, so re-lstat and retry to read the new file. A pre-existing
|
|
74
|
+
* symlink or FIFO fails the isFile check before any open; a file that keeps
|
|
75
|
+
* changing past the retry budget is refused. Throws `notRegularMessage` for a
|
|
76
|
+
* non-regular file; ENOENT and ELOOP propagate.
|
|
77
|
+
*/
|
|
78
|
+
export declare function readAtomicallyPublishedFile(filePath: string, notRegularMessage: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Splits "not written yet" from "written but garbage" so callers can surface a
|
|
81
|
+
* malformed handoff instead of collapsing it into the generic
|
|
82
|
+
* ambiguous-outcome prompt.
|
|
50
83
|
*/
|
|
51
|
-
export declare function readHandoffWithReason(filePath: string): HandoffReadResult;
|
|
84
|
+
export declare function readHandoffWithReason(filePath: string, handoffsDir: string): HandoffReadResult;
|
|
52
85
|
/**
|
|
53
86
|
* Convenience wrapper preserving the original null-on-any-failure contract.
|
|
54
87
|
* Used by the polling loop (`waitForValidHandoff`) where every failure mode
|
|
55
88
|
* is "keep waiting" — the file may be missing, mid-write, or being rewritten.
|
|
56
89
|
*/
|
|
57
|
-
export declare function readHandoff(filePath: string): HandoffFile | null;
|
|
90
|
+
export declare function readHandoff(filePath: string, handoffsDir: string): HandoffFile | null;
|
|
58
91
|
/**
|
|
59
92
|
* Polls for a valid handoff file. Resolves once `readHandoff` accepts the
|
|
60
93
|
* file's contents. Used to detect when the agent has finished its work so the
|
|
@@ -63,7 +96,7 @@ export declare function readHandoff(filePath: string): HandoffFile | null;
|
|
|
63
96
|
*
|
|
64
97
|
* Rejects with the abort reason when `options.signal` is aborted.
|
|
65
98
|
*/
|
|
66
|
-
export declare function waitForValidHandoff(handoffFilePath: string, options?: {
|
|
99
|
+
export declare function waitForValidHandoff(handoffFilePath: string, handoffsDir: string, options?: {
|
|
67
100
|
intervalMs?: number;
|
|
68
101
|
signal?: AbortSignal;
|
|
69
102
|
}): Promise<void>;
|