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