@ohos-ports/nx 23.2.1-beta.0 → 23.3.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +60 -13
- package/dist/bin/init-local.d.ts +8 -0
- package/dist/bin/init-local.js +192 -0
- package/dist/bin/nx-cloud.d.ts +3 -0
- package/dist/bin/nx-cloud.js +47 -0
- package/dist/bin/nx.d.ts +3 -0
- package/dist/bin/nx.js +341 -0
- package/dist/bin/post-install.d.ts +1 -0
- package/dist/bin/post-install.js +52 -0
- package/dist/bin/run-executor.d.ts +1 -0
- package/dist/bin/run-executor.js +66 -0
- package/dist/nx-cloud-internals.d.ts +1 -0
- package/dist/nx-cloud-internals.js +9 -0
- package/dist/plugins/package-json.d.ts +4 -0
- package/dist/plugins/package-json.js +40 -0
- package/dist/presets/core.json +1 -0
- package/dist/presets/npm.json +7 -0
- package/dist/release/changelog-renderer/index.d.ts +114 -0
- package/dist/release/changelog-renderer/index.js +397 -0
- package/dist/release/index.d.ts +4 -0
- package/dist/release/index.js +13 -0
- package/dist/src/adapter/angular-json.d.ts +10 -0
- package/dist/src/adapter/angular-json.js +129 -0
- package/dist/src/adapter/compat.d.ts +2 -0
- package/dist/src/adapter/compat.js +154 -0
- package/dist/src/adapter/ngcli-adapter.d.ts +105 -0
- package/dist/src/adapter/ngcli-adapter.js +1083 -0
- package/dist/src/adapter/rxjs-for-await.d.ts +109 -0
- package/dist/src/adapter/rxjs-for-await.js +362 -0
- package/dist/src/ai/clone-ai-config-repo.d.ts +11 -0
- package/dist/src/ai/clone-ai-config-repo.js +155 -0
- package/dist/src/ai/configure-ai-agents-disclaimer.d.ts +5 -0
- package/dist/src/ai/configure-ai-agents-disclaimer.js +31 -0
- package/dist/src/ai/constants.d.ts +46 -0
- package/dist/src/ai/constants.js +92 -0
- package/dist/src/ai/detect-ai-agent.d.ts +2 -0
- package/dist/src/ai/detect-ai-agent.js +12 -0
- package/dist/src/ai/set-up-ai-agents/get-agent-rules.d.ts +5 -0
- package/dist/src/ai/set-up-ai-agents/get-agent-rules.js +26 -0
- package/dist/src/ai/set-up-ai-agents/schema.d.ts +11 -0
- package/dist/src/ai/set-up-ai-agents/schema.json +34 -0
- package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.d.ts +10 -0
- package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +578 -0
- package/dist/src/ai/utils.d.ts +33 -0
- package/dist/src/ai/utils.js +246 -0
- package/dist/src/analytics/analytics.d.ts +16 -0
- package/dist/src/analytics/analytics.js +246 -0
- package/dist/src/analytics/index.d.ts +1 -0
- package/dist/src/analytics/index.js +12 -0
- package/dist/src/command-line/add/add.d.ts +3 -0
- package/dist/src/command-line/add/add.js +142 -0
- package/dist/src/command-line/add/command-object.d.ts +8 -0
- package/dist/src/command-line/add/command-object.js +28 -0
- package/dist/src/command-line/add/completion.d.ts +1 -0
- package/dist/src/command-line/add/completion.js +15 -0
- package/dist/src/command-line/affected/affected.d.ts +10 -0
- package/dist/src/command-line/affected/affected.js +151 -0
- package/dist/src/command-line/affected/command-object.d.ts +6 -0
- package/dist/src/command-line/affected/command-object.js +83 -0
- package/dist/src/command-line/affected/completion.d.ts +1 -0
- package/dist/src/command-line/affected/completion.js +15 -0
- package/dist/src/command-line/ai/ai-output.d.ts +46 -0
- package/dist/src/command-line/ai/ai-output.js +86 -0
- package/dist/src/command-line/completion/argv-layout.d.ts +6 -0
- package/dist/src/command-line/completion/argv-layout.js +19 -0
- package/dist/src/command-line/completion/command-completions.d.ts +19 -0
- package/dist/src/command-line/completion/command-completions.js +120 -0
- package/dist/src/command-line/completion/command-handlers.d.ts +30 -0
- package/dist/src/command-line/completion/command-handlers.js +69 -0
- package/dist/src/command-line/completion/command-object.d.ts +10 -0
- package/dist/src/command-line/completion/command-object.js +102 -0
- package/dist/src/command-line/completion/completion-providers.d.ts +21 -0
- package/dist/src/command-line/completion/completion-providers.js +194 -0
- package/dist/src/command-line/completion/infix-targets.d.ts +1 -0
- package/dist/src/command-line/completion/infix-targets.js +48 -0
- package/dist/src/command-line/completion/metadata.d.ts +22 -0
- package/dist/src/command-line/completion/metadata.js +71 -0
- package/dist/src/command-line/completion/registrations.d.ts +9 -0
- package/dist/src/command-line/completion/registrations.js +16 -0
- package/dist/src/command-line/completion/scripts/bash.sh +51 -0
- package/dist/src/command-line/completion/scripts/fish.fish +47 -0
- package/dist/src/command-line/completion/scripts/powershell.ps1 +52 -0
- package/dist/src/command-line/completion/scripts/zsh.zsh +69 -0
- package/dist/src/command-line/completion/scripts.d.ts +18 -0
- package/dist/src/command-line/completion/scripts.js +140 -0
- package/dist/src/command-line/completion/trigger.d.ts +3 -0
- package/dist/src/command-line/completion/trigger.js +21 -0
- package/dist/src/command-line/completion/value-completions.d.ts +3 -0
- package/dist/src/command-line/completion/value-completions.js +21 -0
- package/dist/src/command-line/configure-ai-agents/command-object.d.ts +8 -0
- package/dist/src/command-line/configure-ai-agents/command-object.js +59 -0
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.d.ts +3 -0
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +436 -0
- package/dist/src/command-line/daemon/command-object.d.ts +3 -0
- package/dist/src/command-line/daemon/command-object.js +29 -0
- package/dist/src/command-line/daemon/daemon.d.ts +2 -0
- package/dist/src/command-line/daemon/daemon.js +31 -0
- package/dist/src/command-line/deprecated/command-objects.d.ts +9 -0
- package/dist/src/command-line/deprecated/command-objects.js +48 -0
- package/dist/src/command-line/examples.d.ts +12 -0
- package/dist/src/command-line/examples.js +403 -0
- package/dist/src/command-line/exec/command-object.d.ts +2 -0
- package/dist/src/command-line/exec/command-object.js +20 -0
- package/dist/src/command-line/exec/exec.d.ts +1 -0
- package/dist/src/command-line/exec/exec.js +143 -0
- package/dist/src/command-line/format/command-object.d.ts +3 -0
- package/dist/src/command-line/format/command-object.js +58 -0
- package/dist/src/command-line/format/format.d.ts +2 -0
- package/dist/src/command-line/format/format.js +200 -0
- package/dist/src/command-line/generate/command-object.d.ts +2 -0
- package/dist/src/command-line/generate/command-object.js +67 -0
- package/dist/src/command-line/generate/completion.d.ts +1 -0
- package/dist/src/command-line/generate/completion.js +9 -0
- package/dist/src/command-line/generate/generate.d.ts +21 -0
- package/dist/src/command-line/generate/generate.js +281 -0
- package/dist/src/command-line/generate/generator-utils.d.ts +18 -0
- package/dist/src/command-line/generate/generator-utils.js +91 -0
- package/dist/src/command-line/graph/command-object.d.ts +25 -0
- package/dist/src/command-line/graph/command-object.js +76 -0
- package/dist/src/command-line/graph/completion.d.ts +1 -0
- package/dist/src/command-line/graph/completion.js +13 -0
- package/dist/src/command-line/graph/graph.d.ts +101 -0
- package/dist/src/command-line/graph/graph.js +1080 -0
- package/dist/src/command-line/import/command-object.d.ts +2 -0
- package/dist/src/command-line/import/command-object.js +63 -0
- package/dist/src/command-line/import/import.d.ts +26 -0
- package/dist/src/command-line/import/import.js +590 -0
- package/dist/src/command-line/import/utils/ai-output.d.ts +93 -0
- package/dist/src/command-line/import/utils/ai-output.js +209 -0
- package/dist/src/command-line/import/utils/merge-remote-source.d.ts +2 -0
- package/dist/src/command-line/import/utils/merge-remote-source.js +14 -0
- package/dist/src/command-line/import/utils/prepare-source-repo.d.ts +2 -0
- package/dist/src/command-line/import/utils/prepare-source-repo.js +27 -0
- package/dist/src/command-line/index.d.ts +22 -0
- package/dist/src/command-line/index.js +26 -0
- package/dist/src/command-line/init/ai-agent-prompts.d.ts +2 -0
- package/dist/src/command-line/init/ai-agent-prompts.js +30 -0
- package/dist/src/command-line/init/command-object.d.ts +2 -0
- package/dist/src/command-line/init/command-object.js +118 -0
- package/dist/src/command-line/init/configure-plugins.d.ts +34 -0
- package/dist/src/command-line/init/configure-plugins.js +214 -0
- package/dist/src/command-line/init/implementation/add-nx-to-monorepo.d.ts +6 -0
- package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +119 -0
- package/dist/src/command-line/init/implementation/add-nx-to-nest.d.ts +5 -0
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +350 -0
- package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.d.ts +6 -0
- package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +67 -0
- package/dist/src/command-line/init/implementation/add-nx-to-turborepo.d.ts +4 -0
- package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +37 -0
- package/dist/src/command-line/init/implementation/angular/index.d.ts +2 -0
- package/dist/src/command-line/init/implementation/angular/index.js +127 -0
- package/dist/src/command-line/init/implementation/angular/integrated-workspace.d.ts +1 -0
- package/dist/src/command-line/init/implementation/angular/integrated-workspace.js +9 -0
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.d.ts +2 -0
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +152 -0
- package/dist/src/command-line/init/implementation/angular/standalone-workspace.d.ts +1 -0
- package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +204 -0
- package/dist/src/command-line/init/implementation/angular/types.d.ts +20 -0
- package/dist/src/command-line/init/implementation/angular/types.js +2 -0
- package/dist/src/command-line/init/implementation/check-compatible-with-plugins.d.ts +15 -0
- package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +136 -0
- package/dist/src/command-line/init/implementation/deduce-default-base.d.ts +1 -0
- package/dist/src/command-line/init/implementation/deduce-default-base.js +53 -0
- package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.d.ts +11 -0
- package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +151 -0
- package/dist/src/command-line/init/implementation/dot-nx/nxw.d.ts +1 -0
- package/dist/src/command-line/init/implementation/dot-nx/nxw.js +123 -0
- package/dist/src/command-line/init/implementation/format.d.ts +18 -0
- package/dist/src/command-line/init/implementation/format.js +113 -0
- package/dist/src/command-line/init/implementation/utils.d.ts +34 -0
- package/dist/src/command-line/init/implementation/utils.js +419 -0
- package/dist/src/command-line/init/init-v1.d.ts +8 -0
- package/dist/src/command-line/init/init-v1.js +101 -0
- package/dist/src/command-line/init/init-v2.d.ts +23 -0
- package/dist/src/command-line/init/init-v2.js +619 -0
- package/dist/src/command-line/init/utils/ai-output.d.ts +72 -0
- package/dist/src/command-line/init/utils/ai-output.js +180 -0
- package/dist/src/command-line/list/command-object.d.ts +2 -0
- package/dist/src/command-line/list/command-object.js +21 -0
- package/dist/src/command-line/list/list.d.ts +15 -0
- package/dist/src/command-line/list/list.js +48 -0
- package/dist/src/command-line/mcp/command-object.d.ts +2 -0
- package/dist/src/command-line/mcp/command-object.js +29 -0
- package/dist/src/command-line/mcp/mcp.d.ts +2 -0
- package/dist/src/command-line/mcp/mcp.js +60 -0
- package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +47 -0
- package/dist/src/command-line/migrate/agentic/capture-generator-output.js +216 -0
- package/dist/src/command-line/migrate/agentic/cli-args.d.ts +12 -0
- package/dist/src/command-line/migrate/agentic/cli-args.js +38 -0
- 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 +30 -0
- package/dist/src/command-line/migrate/agentic/definitions.js +207 -0
- package/dist/src/command-line/migrate/agentic/detect-installed.d.ts +10 -0
- package/dist/src/command-line/migrate/agentic/detect-installed.js +68 -0
- 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 +61 -0
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +78 -0
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +102 -0
- package/dist/src/command-line/migrate/agentic/handoff.js +335 -0
- package/dist/src/command-line/migrate/agentic/inception.d.ts +9 -0
- package/dist/src/command-line/migrate/agentic/inception.js +15 -0
- 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/print-dropped-agent-context.d.ts +17 -0
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +57 -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.d.ts +56 -0
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +67 -0
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +49 -0
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +53 -0
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +26 -0
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +27 -0
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +19 -0
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +145 -0
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +70 -0
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +113 -0
- package/dist/src/command-line/migrate/agentic/run-step.d.ts +68 -0
- package/dist/src/command-line/migrate/agentic/run-step.js +148 -0
- package/dist/src/command-line/migrate/agentic/runner.d.ts +21 -0
- package/dist/src/command-line/migrate/agentic/runner.js +262 -0
- package/dist/src/command-line/migrate/agentic/select.d.ts +24 -0
- package/dist/src/command-line/migrate/agentic/select.js +251 -0
- 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 +147 -0
- package/dist/src/command-line/migrate/agentic/types.js +40 -0
- 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 +55 -0
- package/dist/src/command-line/migrate/command-object.js +162 -0
- 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 +97 -0
- package/dist/src/command-line/migrate/execute-migration.js +511 -0
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +131 -0
- package/dist/src/command-line/migrate/migrate-analytics.js +378 -0
- package/dist/src/command-line/migrate/migrate-commits.d.ts +81 -0
- package/dist/src/command-line/migrate/migrate-commits.js +227 -0
- package/dist/src/command-line/migrate/migrate-config.d.ts +32 -0
- package/dist/src/command-line/migrate/migrate-config.js +120 -0
- package/dist/src/command-line/migrate/migrate-output.d.ts +214 -0
- package/dist/src/command-line/migrate/migrate-output.js +298 -0
- package/dist/src/command-line/migrate/migrate-ui-api.d.ts +89 -0
- package/dist/src/command-line/migrate/migrate-ui-api.js +437 -0
- package/dist/src/command-line/migrate/migrate.d.ts +245 -0
- package/dist/src/command-line/migrate/migrate.js +2944 -0
- package/dist/src/command-line/migrate/migration-shape.d.ts +16 -0
- package/dist/src/command-line/migrate/migration-shape.js +13 -0
- package/dist/src/command-line/migrate/multi-major.d.ts +37 -0
- package/dist/src/command-line/migrate/multi-major.js +215 -0
- package/dist/src/command-line/migrate/prompt-files.d.ts +31 -0
- package/dist/src/command-line/migrate/prompt-files.js +134 -0
- package/dist/src/command-line/migrate/resolve-package-version.d.ts +24 -0
- package/dist/src/command-line/migrate/resolve-package-version.js +228 -0
- package/dist/src/command-line/migrate/run/agent-output.d.ts +31 -0
- package/dist/src/command-line/migrate/run/agent-output.js +84 -0
- 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 +12 -0
- package/dist/src/command-line/migrate/run/index.js +42 -0
- 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 +78 -0
- package/dist/src/command-line/migrate/run/orchestrator.js +2272 -0
- package/dist/src/command-line/migrate/run/run-id.d.ts +8 -0
- package/dist/src/command-line/migrate/run/run-id.js +26 -0
- package/dist/src/command-line/migrate/run/run-state.d.ts +217 -0
- package/dist/src/command-line/migrate/run/run-state.js +669 -0
- 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 +56 -0
- package/dist/src/command-line/migrate/run/state-lock.js +202 -0
- package/dist/src/command-line/migrate/run/state-machine.d.ts +133 -0
- package/dist/src/command-line/migrate/run/state-machine.js +628 -0
- package/dist/src/command-line/migrate/run/util.d.ts +61 -0
- package/dist/src/command-line/migrate/run/util.js +169 -0
- package/dist/src/command-line/migrate/run/worker.d.ts +16 -0
- package/dist/src/command-line/migrate/run/worker.js +843 -0
- package/dist/src/command-line/migrate/run-migration-process.js +110 -0
- package/dist/src/command-line/migrate/safe-prompt.d.ts +21 -0
- package/dist/src/command-line/migrate/safe-prompt.js +47 -0
- package/dist/src/command-line/migrate/sort-migrations.d.ts +16 -0
- package/dist/src/command-line/migrate/sort-migrations.js +32 -0
- package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
- package/dist/src/command-line/migrate/step-actions.js +18 -0
- package/dist/src/command-line/migrate/text.d.ts +24 -0
- package/dist/src/command-line/migrate/text.js +51 -0
- package/dist/src/command-line/migrate/update-filters.d.ts +11 -0
- package/dist/src/command-line/migrate/update-filters.js +45 -0
- package/dist/src/command-line/migrate/version-skew-guard.d.ts +60 -0
- package/dist/src/command-line/migrate/version-skew-guard.js +177 -0
- package/dist/src/command-line/migrate/version-utils.d.ts +5 -0
- package/dist/src/command-line/migrate/version-utils.js +52 -0
- package/dist/src/command-line/new/command-object.d.ts +2 -0
- package/dist/src/command-line/new/command-object.js +26 -0
- package/dist/src/command-line/new/new.d.ts +3 -0
- package/dist/src/command-line/new/new.js +30 -0
- package/dist/src/command-line/nx-cloud/apply-locally/apply-locally.d.ts +4 -0
- package/dist/src/command-line/nx-cloud/apply-locally/apply-locally.js +13 -0
- package/dist/src/command-line/nx-cloud/apply-locally/command-object.d.ts +2 -0
- package/dist/src/command-line/nx-cloud/apply-locally/command-object.js +16 -0
- package/dist/src/command-line/nx-cloud/complete-run/command-object.d.ts +2 -0
- package/dist/src/command-line/nx-cloud/complete-run/command-object.js +17 -0
- package/dist/src/command-line/nx-cloud/complete-run/stop-all-agents.d.ts +4 -0
- package/dist/src/command-line/nx-cloud/complete-run/stop-all-agents.js +13 -0
- package/dist/src/command-line/nx-cloud/connect/command-object.d.ts +3 -0
- package/dist/src/command-line/nx-cloud/connect/command-object.js +28 -0
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.d.ts +13 -0
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +260 -0
- package/dist/src/command-line/nx-cloud/connect/view-logs.d.ts +1 -0
- package/dist/src/command-line/nx-cloud/connect/view-logs.js +55 -0
- package/dist/src/command-line/nx-cloud/download-cloud-client/command-object.d.ts +2 -0
- package/dist/src/command-line/nx-cloud/download-cloud-client/command-object.js +13 -0
- package/dist/src/command-line/nx-cloud/download-cloud-client/download-cloud-client.d.ts +4 -0
- package/dist/src/command-line/nx-cloud/download-cloud-client/download-cloud-client.js +32 -0
- package/dist/src/command-line/nx-cloud/fix-ci/command-object.d.ts +2 -0
- package/dist/src/command-line/nx-cloud/fix-ci/command-object.js +16 -0
- package/dist/src/command-line/nx-cloud/fix-ci/fix-ci.d.ts +4 -0
- package/dist/src/command-line/nx-cloud/fix-ci/fix-ci.js +13 -0
- package/dist/src/command-line/nx-cloud/login/command-object.d.ts +2 -0
- package/dist/src/command-line/nx-cloud/login/command-object.js +20 -0
- package/dist/src/command-line/nx-cloud/login/login.d.ts +5 -0
- package/dist/src/command-line/nx-cloud/login/login.js +10 -0
- package/dist/src/command-line/nx-cloud/logout/command-object.d.ts +2 -0
- package/dist/src/command-line/nx-cloud/logout/command-object.js +16 -0
- package/dist/src/command-line/nx-cloud/logout/logout.d.ts +4 -0
- package/dist/src/command-line/nx-cloud/logout/logout.js +7 -0
- package/dist/src/command-line/nx-cloud/record/command-object.d.ts +2 -0
- package/dist/src/command-line/nx-cloud/record/command-object.js +19 -0
- package/dist/src/command-line/nx-cloud/record/record.d.ts +5 -0
- package/dist/src/command-line/nx-cloud/record/record.js +33 -0
- package/dist/src/command-line/nx-cloud/start-agent/command-object.d.ts +2 -0
- package/dist/src/command-line/nx-cloud/start-agent/command-object.js +16 -0
- package/dist/src/command-line/nx-cloud/start-agent/start-agent.d.ts +4 -0
- package/dist/src/command-line/nx-cloud/start-agent/start-agent.js +13 -0
- package/dist/src/command-line/nx-cloud/start-ci-run/command-object.d.ts +2 -0
- package/dist/src/command-line/nx-cloud/start-ci-run/command-object.js +16 -0
- package/dist/src/command-line/nx-cloud/start-ci-run/start-ci-run.d.ts +4 -0
- package/dist/src/command-line/nx-cloud/start-ci-run/start-ci-run.js +13 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.d.ts +2 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.js +16 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.d.ts +4 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.js +13 -0
- package/dist/src/command-line/nx-cloud/utils.d.ts +2 -0
- package/dist/src/command-line/nx-cloud/utils.js +34 -0
- package/dist/src/command-line/nx-commands.d.ts +10 -0
- package/dist/src/command-line/nx-commands.js +183 -0
- package/dist/src/command-line/register/command-object.d.ts +6 -0
- package/dist/src/command-line/register/command-object.js +27 -0
- package/dist/src/command-line/register/register.d.ts +2 -0
- package/dist/src/command-line/register/register.js +9 -0
- package/dist/src/command-line/release/changelog/commit-utils.d.ts +13 -0
- package/dist/src/command-line/release/changelog/commit-utils.js +63 -0
- package/dist/src/command-line/release/changelog/version-plan-filtering.d.ts +43 -0
- package/dist/src/command-line/release/changelog/version-plan-filtering.js +156 -0
- package/dist/src/command-line/release/changelog/version-plan-utils.d.ts +31 -0
- package/dist/src/command-line/release/changelog/version-plan-utils.js +92 -0
- package/dist/src/command-line/release/changelog.d.ts +28 -0
- package/dist/src/command-line/release/changelog.js +907 -0
- package/dist/src/command-line/release/command-object.d.ts +96 -0
- package/dist/src/command-line/release/command-object.js +342 -0
- package/dist/src/command-line/release/config/config.d.ts +70 -0
- package/dist/src/command-line/release/config/config.js +1204 -0
- package/dist/src/command-line/release/config/conventional-commits.d.ts +2 -0
- package/dist/src/command-line/release/config/conventional-commits.js +106 -0
- package/dist/src/command-line/release/config/deep-merge-json.d.ts +1 -0
- package/dist/src/command-line/release/config/deep-merge-json.js +28 -0
- package/dist/src/command-line/release/config/filter-release-groups.d.ts +23 -0
- package/dist/src/command-line/release/config/filter-release-groups.js +157 -0
- package/dist/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
- package/dist/src/command-line/release/config/use-legacy-versioning.js +8 -0
- package/dist/src/command-line/release/config/version-plans.d.ts +42 -0
- package/dist/src/command-line/release/config/version-plans.js +278 -0
- package/dist/src/command-line/release/index.d.ts +49 -0
- package/dist/src/command-line/release/index.js +49 -0
- package/dist/src/command-line/release/plan-check.d.ts +4 -0
- package/dist/src/command-line/release/plan-check.js +170 -0
- package/dist/src/command-line/release/plan.d.ts +4 -0
- package/dist/src/command-line/release/plan.js +248 -0
- package/dist/src/command-line/release/publish.d.ts +9 -0
- package/dist/src/command-line/release/publish.js +298 -0
- package/dist/src/command-line/release/release.d.ts +5 -0
- package/dist/src/command-line/release/release.js +299 -0
- package/dist/src/command-line/release/utils/diff.d.ts +21 -0
- package/dist/src/command-line/release/utils/diff.js +168 -0
- package/dist/src/command-line/release/utils/exec-command.d.ts +1 -0
- package/dist/src/command-line/release/utils/exec-command.js +34 -0
- package/dist/src/command-line/release/utils/generate-version-plan-content.d.ts +1 -0
- package/dist/src/command-line/release/utils/generate-version-plan-content.js +20 -0
- package/dist/src/command-line/release/utils/get-touched-projects-for-group.d.ts +7 -0
- package/dist/src/command-line/release/utils/get-touched-projects-for-group.js +78 -0
- package/dist/src/command-line/release/utils/git.d.ts +126 -0
- package/dist/src/command-line/release/utils/git.js +597 -0
- package/dist/src/command-line/release/utils/launch-editor.d.ts +1 -0
- package/dist/src/command-line/release/utils/launch-editor.js +46 -0
- package/dist/src/command-line/release/utils/markdown.d.ts +6 -0
- package/dist/src/command-line/release/utils/markdown.js +28 -0
- package/dist/src/command-line/release/utils/print-changes.d.ts +6 -0
- package/dist/src/command-line/release/utils/print-changes.js +63 -0
- package/dist/src/command-line/release/utils/print-config.d.ts +7 -0
- package/dist/src/command-line/release/utils/print-config.js +36 -0
- package/dist/src/command-line/release/utils/release-graph.d.ts +248 -0
- package/dist/src/command-line/release/utils/release-graph.js +769 -0
- package/dist/src/command-line/release/utils/remote-release-clients/extract-repo-slug.d.ts +9 -0
- package/dist/src/command-line/release/utils/remote-release-clients/extract-repo-slug.js +61 -0
- package/dist/src/command-line/release/utils/remote-release-clients/github.d.ts +58 -0
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +333 -0
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.d.ts +62 -0
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +259 -0
- package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +113 -0
- package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +172 -0
- package/dist/src/command-line/release/utils/repository-git-tags.d.ts +25 -0
- package/dist/src/command-line/release/utils/repository-git-tags.js +125 -0
- package/dist/src/command-line/release/utils/resolve-changelog-renderer.d.ts +2 -0
- package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +22 -0
- package/dist/src/command-line/release/utils/resolve-nx-json-error-message.d.ts +1 -0
- package/dist/src/command-line/release/utils/resolve-nx-json-error-message.js +53 -0
- package/dist/src/command-line/release/utils/resolve-semver-specifier.d.ts +7 -0
- package/dist/src/command-line/release/utils/resolve-semver-specifier.js +41 -0
- package/dist/src/command-line/release/utils/semver.d.ts +26 -0
- package/dist/src/command-line/release/utils/semver.js +111 -0
- package/dist/src/command-line/release/utils/shared-legacy.d.ts +25 -0
- package/dist/src/command-line/release/utils/shared-legacy.js +2 -0
- package/dist/src/command-line/release/utils/shared.d.ts +64 -0
- package/dist/src/command-line/release/utils/shared.js +379 -0
- package/dist/src/command-line/release/utils/version-plan-utils.d.ts +40 -0
- package/dist/src/command-line/release/utils/version-plan-utils.js +111 -0
- package/dist/src/command-line/release/version/derive-specifier-from-conventional-commits.d.ts +8 -0
- package/dist/src/command-line/release/version/derive-specifier-from-conventional-commits.js +61 -0
- package/dist/src/command-line/release/version/deriver-specifier-from-version-plans.d.ts +8 -0
- package/dist/src/command-line/release/version/deriver-specifier-from-version-plans.js +59 -0
- package/dist/src/command-line/release/version/project-logger.d.ts +8 -0
- package/dist/src/command-line/release/version/project-logger.js +47 -0
- package/dist/src/command-line/release/version/release-group-processor.d.ts +139 -0
- package/dist/src/command-line/release/version/release-group-processor.js +706 -0
- package/dist/src/command-line/release/version/resolve-current-version.d.ts +32 -0
- package/dist/src/command-line/release/version/resolve-current-version.js +240 -0
- package/dist/src/command-line/release/version/topological-sort.d.ts +9 -0
- package/dist/src/command-line/release/version/topological-sort.js +41 -0
- package/dist/src/command-line/release/version/version-actions.d.ts +227 -0
- package/dist/src/command-line/release/version/version-actions.js +255 -0
- package/dist/src/command-line/release/version.d.ts +28 -0
- package/dist/src/command-line/release/version.js +382 -0
- package/dist/src/command-line/repair/command-object.d.ts +2 -0
- package/dist/src/command-line/repair/command-object.js +21 -0
- package/dist/src/command-line/repair/repair.d.ts +3 -0
- package/dist/src/command-line/repair/repair.js +41 -0
- package/dist/src/command-line/report/command-object.d.ts +2 -0
- package/dist/src/command-line/report/command-object.js +12 -0
- package/dist/src/command-line/report/report.d.ts +73 -0
- package/dist/src/command-line/report/report.js +432 -0
- package/dist/src/command-line/reset/command-object.d.ts +8 -0
- package/dist/src/command-line/reset/command-object.js +27 -0
- package/dist/src/command-line/reset/reset.d.ts +2 -0
- package/dist/src/command-line/reset/reset.js +189 -0
- package/dist/src/command-line/run/command-object.d.ts +6 -0
- package/dist/src/command-line/run/command-object.js +43 -0
- package/dist/src/command-line/run/completion.d.ts +1 -0
- package/dist/src/command-line/run/completion.js +7 -0
- package/dist/src/command-line/run/executor-utils.d.ts +12 -0
- package/dist/src/command-line/run/executor-utils.js +96 -0
- package/dist/src/command-line/run/run-one.d.ts +17 -0
- package/dist/src/command-line/run/run-one.js +159 -0
- package/dist/src/command-line/run/run.d.ts +51 -0
- package/dist/src/command-line/run/run.js +179 -0
- package/dist/src/command-line/run-many/command-object.d.ts +2 -0
- package/dist/src/command-line/run-many/command-object.js +18 -0
- package/dist/src/command-line/run-many/completion.d.ts +1 -0
- package/dist/src/command-line/run-many/completion.js +13 -0
- package/dist/src/command-line/run-many/run-many.d.ts +10 -0
- package/dist/src/command-line/run-many/run-many.js +84 -0
- package/dist/src/command-line/show/command-object.d.ts +40 -0
- package/dist/src/command-line/show/command-object.js +237 -0
- package/dist/src/command-line/show/completion.d.ts +1 -0
- package/dist/src/command-line/show/completion.js +27 -0
- package/dist/src/command-line/show/project.d.ts +2 -0
- package/dist/src/command-line/show/project.js +103 -0
- package/dist/src/command-line/show/projects.d.ts +2 -0
- package/dist/src/command-line/show/projects.js +131 -0
- package/dist/src/command-line/show/show-target/index.d.ts +3 -0
- package/dist/src/command-line/show/show-target/index.js +9 -0
- package/dist/src/command-line/show/show-target/info.d.ts +28 -0
- package/dist/src/command-line/show/show-target/info.js +389 -0
- package/dist/src/command-line/show/show-target/inputs.d.ts +2 -0
- package/dist/src/command-line/show/show-target/inputs.js +83 -0
- package/dist/src/command-line/show/show-target/outputs.d.ts +2 -0
- package/dist/src/command-line/show/show-target/outputs.js +70 -0
- package/dist/src/command-line/show/show-target/utils.d.ts +54 -0
- package/dist/src/command-line/show/show-target/utils.js +265 -0
- package/dist/src/command-line/sync/command-object.d.ts +6 -0
- package/dist/src/command-line/sync/command-object.js +21 -0
- package/dist/src/command-line/sync/sync.d.ts +6 -0
- package/dist/src/command-line/sync/sync.js +120 -0
- package/dist/src/command-line/watch/command-object.d.ts +2 -0
- package/dist/src/command-line/watch/command-object.js +91 -0
- package/dist/src/command-line/watch/completion.d.ts +1 -0
- package/dist/src/command-line/watch/completion.js +10 -0
- package/dist/src/command-line/watch/watch.d.ts +31 -0
- package/dist/src/command-line/watch/watch.js +211 -0
- package/dist/src/command-line/yargs-utils/arguments-of.d.ts +11 -0
- package/dist/src/command-line/yargs-utils/arguments-of.js +9 -0
- package/dist/src/command-line/yargs-utils/documentation.d.ts +2 -0
- package/dist/src/command-line/yargs-utils/documentation.js +12 -0
- package/dist/src/command-line/yargs-utils/shared-options.d.ts +95 -0
- package/dist/src/command-line/yargs-utils/shared-options.js +431 -0
- package/dist/src/commands-runner/command-graph.d.ts +13 -0
- package/dist/src/commands-runner/command-graph.js +2 -0
- package/dist/src/commands-runner/create-command-graph.d.ts +4 -0
- package/dist/src/commands-runner/create-command-graph.js +72 -0
- package/dist/src/commands-runner/get-command-projects.d.ts +3 -0
- package/dist/src/commands-runner/get-command-projects.js +33 -0
- package/dist/src/config/calculate-default-project-name.d.ts +4 -0
- package/dist/src/config/calculate-default-project-name.js +41 -0
- package/dist/src/config/configuration.d.ts +8 -0
- package/dist/src/config/configuration.js +17 -0
- package/dist/src/config/misc-interfaces.d.ts +266 -0
- package/dist/src/config/misc-interfaces.js +2 -0
- package/dist/src/config/nx-json.d.ts +963 -0
- package/dist/src/config/nx-json.js +40 -0
- package/dist/src/config/project-graph.d.ts +137 -0
- package/dist/src/config/project-graph.js +45 -0
- package/dist/src/config/schema-utils.d.ts +37 -0
- package/dist/src/config/schema-utils.js +199 -0
- package/dist/src/config/task-graph.d.ts +6 -0
- package/dist/src/config/task-graph.js +2 -0
- package/dist/src/config/to-project-name.d.ts +5 -0
- package/dist/src/config/to-project-name.js +12 -0
- package/dist/src/config/workspace-json-project-json.d.ts +295 -0
- package/dist/src/config/workspace-json-project-json.js +2 -0
- package/dist/src/core/graph/environment.js +1 -0
- package/dist/src/core/graph/favicon.ico +0 -0
- package/dist/src/core/graph/index.html +32 -0
- package/dist/src/core/graph/main.js +1 -0
- package/dist/src/core/graph/runtime.js +1 -0
- package/dist/src/core/graph/styles.css +2 -0
- package/dist/src/core/graph/styles.js +1 -0
- package/dist/src/daemon/cache.d.ts +10 -0
- package/dist/src/daemon/cache.js +58 -0
- package/dist/src/daemon/client/client.d.ts +167 -0
- package/dist/src/daemon/client/client.js +1284 -0
- package/dist/src/daemon/client/daemon-environment.d.ts +74 -0
- package/dist/src/daemon/client/daemon-environment.js +422 -0
- package/dist/src/daemon/client/daemon-socket-messenger.d.ts +12 -0
- package/dist/src/daemon/client/daemon-socket-messenger.js +63 -0
- package/dist/src/daemon/is-nx-version-mismatch.d.ts +1 -0
- package/dist/src/daemon/is-nx-version-mismatch.js +8 -0
- package/dist/src/daemon/is-on-daemon.d.ts +1 -0
- package/dist/src/daemon/is-on-daemon.js +6 -0
- package/dist/src/daemon/is-v8-serializer-enabled.d.ts +5 -0
- package/dist/src/daemon/is-v8-serializer-enabled.js +10 -0
- package/dist/src/daemon/logger.d.ts +39 -0
- package/dist/src/daemon/logger.js +80 -0
- package/dist/src/daemon/message-types/configure-ai-agents.d.ts +20 -0
- package/dist/src/daemon/message-types/configure-ai-agents.js +19 -0
- package/dist/src/daemon/message-types/daemon-message.d.ts +39 -0
- package/dist/src/daemon/message-types/daemon-message.js +54 -0
- package/dist/src/daemon/message-types/flush-sync-generator-changes-to-disk.d.ts +6 -0
- package/dist/src/daemon/message-types/flush-sync-generator-changes-to-disk.js +11 -0
- package/dist/src/daemon/message-types/force-shutdown.d.ts +5 -0
- package/dist/src/daemon/message-types/force-shutdown.js +11 -0
- package/dist/src/daemon/message-types/get-context-file-data.d.ts +5 -0
- package/dist/src/daemon/message-types/get-context-file-data.js +11 -0
- package/dist/src/daemon/message-types/get-files-in-directory.d.ts +6 -0
- package/dist/src/daemon/message-types/get-files-in-directory.js +11 -0
- package/dist/src/daemon/message-types/get-nx-workspace-files.d.ts +6 -0
- package/dist/src/daemon/message-types/get-nx-workspace-files.js +11 -0
- 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/get-registered-sync-generators.d.ts +5 -0
- package/dist/src/daemon/message-types/get-registered-sync-generators.js +11 -0
- package/dist/src/daemon/message-types/get-sync-generator-changes.d.ts +6 -0
- package/dist/src/daemon/message-types/get-sync-generator-changes.js +11 -0
- package/dist/src/daemon/message-types/glob.d.ts +14 -0
- package/dist/src/daemon/message-types/glob.js +19 -0
- package/dist/src/daemon/message-types/hash-glob.d.ts +13 -0
- package/dist/src/daemon/message-types/hash-glob.js +19 -0
- package/dist/src/daemon/message-types/nx-console.d.ts +17 -0
- package/dist/src/daemon/message-types/nx-console.js +19 -0
- package/dist/src/daemon/message-types/register-project-graph-listener.d.ts +5 -0
- package/dist/src/daemon/message-types/register-project-graph-listener.js +11 -0
- package/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts +14 -0
- package/dist/src/daemon/message-types/run-tasks-execution-hooks.js +19 -0
- 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/streaming-messages.d.ts +14 -0
- package/dist/src/daemon/message-types/streaming-messages.js +19 -0
- package/dist/src/daemon/message-types/task-history.d.ts +19 -0
- package/dist/src/daemon/message-types/task-history.js +27 -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/message-types/update-workspace-context.d.ts +8 -0
- package/dist/src/daemon/message-types/update-workspace-context.js +11 -0
- package/dist/src/daemon/sandbox-socket-hint.d.ts +27 -0
- package/dist/src/daemon/sandbox-socket-hint.js +136 -0
- package/dist/src/daemon/server/client-socket-context.d.ts +23 -0
- package/dist/src/daemon/server/client-socket-context.js +88 -0
- package/dist/src/daemon/server/dotenv-graph-changes.d.ts +97 -0
- package/dist/src/daemon/server/dotenv-graph-changes.js +284 -0
- package/dist/src/daemon/server/file-watching/changed-projects.d.ts +10 -0
- package/dist/src/daemon/server/file-watching/changed-projects.js +53 -0
- package/dist/src/daemon/server/file-watching/file-change-events.d.ts +7 -0
- package/dist/src/daemon/server/file-watching/file-change-events.js +19 -0
- package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +17 -0
- package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +82 -0
- package/dist/src/daemon/server/handle-client-env.d.ts +8 -0
- package/dist/src/daemon/server/handle-client-env.js +113 -0
- package/dist/src/daemon/server/handle-configure-ai-agents.d.ts +3 -0
- package/dist/src/daemon/server/handle-configure-ai-agents.js +101 -0
- package/dist/src/daemon/server/handle-context-file-data.d.ts +2 -0
- package/dist/src/daemon/server/handle-context-file-data.js +12 -0
- package/dist/src/daemon/server/handle-flush-sync-generator-changes-to-disk.d.ts +2 -0
- package/dist/src/daemon/server/handle-flush-sync-generator-changes-to-disk.js +11 -0
- package/dist/src/daemon/server/handle-force-shutdown.d.ts +5 -0
- package/dist/src/daemon/server/handle-force-shutdown.js +18 -0
- package/dist/src/daemon/server/handle-get-files-in-directory.d.ts +2 -0
- package/dist/src/daemon/server/handle-get-files-in-directory.js +12 -0
- 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-get-registered-sync-generators.d.ts +2 -0
- package/dist/src/daemon/server/handle-get-registered-sync-generators.js +11 -0
- package/dist/src/daemon/server/handle-get-sync-generator-changes.d.ts +2 -0
- package/dist/src/daemon/server/handle-get-sync-generator-changes.js +20 -0
- package/dist/src/daemon/server/handle-glob.d.ts +3 -0
- package/dist/src/daemon/server/handle-glob.js +20 -0
- package/dist/src/daemon/server/handle-hash-glob.d.ts +3 -0
- package/dist/src/daemon/server/handle-hash-glob.js +20 -0
- package/dist/src/daemon/server/handle-hash-tasks.d.ts +20 -0
- package/dist/src/daemon/server/handle-hash-tasks.js +43 -0
- package/dist/src/daemon/server/handle-nx-console.d.ts +3 -0
- package/dist/src/daemon/server/handle-nx-console.js +54 -0
- package/dist/src/daemon/server/handle-nx-workspace-files.d.ts +2 -0
- package/dist/src/daemon/server/handle-nx-workspace-files.js +12 -0
- package/dist/src/daemon/server/handle-outputs-tracking.d.ts +15 -0
- package/dist/src/daemon/server/handle-outputs-tracking.js +35 -0
- package/dist/src/daemon/server/handle-process-in-background.d.ts +6 -0
- package/dist/src/daemon/server/handle-process-in-background.js +32 -0
- package/dist/src/daemon/server/handle-request-project-graph.d.ts +3 -0
- package/dist/src/daemon/server/handle-request-project-graph.js +36 -0
- package/dist/src/daemon/server/handle-request-shutdown.d.ts +5 -0
- package/dist/src/daemon/server/handle-request-shutdown.js +27 -0
- 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-task-history.d.ts +13 -0
- package/dist/src/daemon/server/handle-task-history.js +30 -0
- package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +20 -0
- package/dist/src/daemon/server/handle-tasks-execution-hooks.js +35 -0
- package/dist/src/daemon/server/handle-update-workspace-context.d.ts +2 -0
- package/dist/src/daemon/server/handle-update-workspace-context.js +11 -0
- package/dist/src/daemon/server/handle-watch-events.d.ts +10 -0
- package/dist/src/daemon/server/handle-watch-events.js +85 -0
- package/dist/src/daemon/server/latest-nx.d.ts +10 -0
- package/dist/src/daemon/server/latest-nx.js +56 -0
- package/dist/src/daemon/server/nx-console-operations.d.ts +26 -0
- package/dist/src/daemon/server/nx-console-operations.js +97 -0
- package/dist/src/daemon/server/outputs-tracking.d.ts +11 -0
- package/dist/src/daemon/server/outputs-tracking.js +20 -0
- 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 +62 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +690 -0
- package/dist/src/daemon/server/project-graph-listener-sockets.d.ts +7 -0
- package/dist/src/daemon/server/project-graph-listener-sockets.js +25 -0
- 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 +11 -0
- package/dist/src/daemon/server/server.js +489 -0
- package/dist/src/daemon/server/shutdown-utils.d.ts +18 -0
- package/dist/src/daemon/server/shutdown-utils.js +136 -0
- package/dist/src/daemon/server/start.d.ts +1 -0
- package/dist/src/daemon/server/start.js +20 -0
- package/dist/src/daemon/server/sync-generators.d.ts +14 -0
- package/dist/src/daemon/server/sync-generators.js +368 -0
- 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/daemon/socket-utils.d.ts +43 -0
- package/dist/src/daemon/socket-utils.js +131 -0
- package/dist/src/daemon/tmp-dir.d.ts +62 -0
- package/dist/src/daemon/tmp-dir.js +477 -0
- package/dist/src/devkit-exports.d.ts +139 -0
- package/dist/src/devkit-exports.js +143 -0
- package/dist/src/devkit-internals.d.ts +146 -0
- package/dist/src/devkit-internals.js +336 -0
- package/dist/src/devkit-testing-exports.d.ts +2 -0
- package/dist/src/devkit-testing-exports.js +8 -0
- package/dist/src/executors/noop/noop.impl.d.ts +3 -0
- package/dist/src/executors/noop/noop.impl.js +6 -0
- package/dist/src/executors/noop/schema.json +10 -0
- package/dist/src/executors/run-commands/run-commands.impl.d.ts +60 -0
- package/dist/src/executors/run-commands/run-commands.impl.js +315 -0
- package/dist/src/executors/run-commands/running-tasks.d.ts +53 -0
- package/dist/src/executors/run-commands/running-tasks.js +603 -0
- package/dist/src/executors/run-commands/schema.json +198 -0
- package/dist/src/executors/run-script/run-script.impl.d.ts +8 -0
- package/dist/src/executors/run-script/run-script.impl.js +86 -0
- package/dist/src/executors/run-script/schema.json +28 -0
- package/dist/src/executors/utils/convert-nx-executor.d.ts +10 -0
- package/dist/src/executors/utils/convert-nx-executor.js +83 -0
- package/dist/src/generators/internal-utils/format-changed-files.d.ts +24 -0
- package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
- package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +26 -0
- package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +70 -0
- package/dist/src/generators/testing-utils/create-tree.d.ts +5 -0
- package/dist/src/generators/testing-utils/create-tree.js +14 -0
- package/dist/src/generators/tree.d.ts +127 -0
- package/dist/src/generators/tree.js +310 -0
- package/dist/src/generators/utils/generate-files.d.ts +44 -0
- package/dist/src/generators/utils/generate-files.js +114 -0
- package/dist/src/generators/utils/glob.d.ts +22 -0
- package/dist/src/generators/utils/glob.js +51 -0
- package/dist/src/generators/utils/json.d.ts +28 -0
- package/dist/src/generators/utils/json.js +48 -0
- package/dist/src/generators/utils/nx-json.d.ts +10 -0
- package/dist/src/generators/utils/nx-json.js +62 -0
- package/dist/src/generators/utils/project-configuration.d.ts +51 -0
- package/dist/src/generators/utils/project-configuration.js +299 -0
- package/dist/src/hasher/check-task-files.d.ts +86 -0
- package/dist/src/hasher/check-task-files.js +378 -0
- package/dist/src/hasher/create-task-hasher.d.ts +11 -0
- package/dist/src/hasher/create-task-hasher.js +25 -0
- package/dist/src/hasher/file-hasher.d.ts +3 -0
- package/dist/src/hasher/file-hasher.js +23 -0
- package/dist/src/hasher/hash-plan-inspector.d.ts +33 -0
- package/dist/src/hasher/hash-plan-inspector.js +70 -0
- package/dist/src/hasher/hash-task.d.ts +17 -0
- package/dist/src/hasher/hash-task.js +202 -0
- package/dist/src/hasher/native-task-hasher-impl.d.ts +34 -0
- package/dist/src/hasher/native-task-hasher-impl.js +104 -0
- package/dist/src/hasher/task-hasher.d.ts +177 -0
- package/dist/src/hasher/task-hasher.js +320 -0
- package/dist/src/hasher/task-planning-context.d.ts +13 -0
- package/dist/src/hasher/task-planning-context.js +12 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/migrations/update-15-0-0/prefix-outputs.d.ts +2 -0
- package/dist/src/migrations/update-15-0-0/prefix-outputs.js +54 -0
- package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.d.ts +2 -0
- package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +16 -0
- package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.d.ts +2 -0
- package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +82 -0
- package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.d.ts +2 -0
- package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +29 -0
- package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.d.ts +2 -0
- package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +50 -0
- package/dist/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.d.ts +12 -0
- package/dist/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.js +67 -0
- package/dist/src/migrations/update-17-0-0/move-cache-directory.d.ts +2 -0
- package/dist/src/migrations/update-17-0-0/move-cache-directory.js +35 -0
- package/dist/src/migrations/update-17-0-0/move-cache-directory.md +31 -0
- package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.d.ts +2 -0
- package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +72 -0
- package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +2 -0
- package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +126 -0
- package/dist/src/migrations/update-17-2-0/move-default-base.d.ts +5 -0
- package/dist/src/migrations/update-17-2-0/move-default-base.js +20 -0
- package/dist/src/migrations/update-17-3-0/update-nxw.d.ts +2 -0
- package/dist/src/migrations/update-17-3-0/update-nxw.js +7 -0
- package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +2 -0
- package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +11 -0
- package/dist/src/migrations/update-19-2-0/move-workspace-data-directory.d.ts +4 -0
- package/dist/src/migrations/update-19-2-0/move-workspace-data-directory.js +33 -0
- package/dist/src/migrations/update-19-2-4/set-project-name.d.ts +2 -0
- package/dist/src/migrations/update-19-2-4/set-project-name.js +34 -0
- package/dist/src/migrations/update-20-0-0/move-use-daemon-process.d.ts +2 -0
- package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +25 -0
- package/dist/src/migrations/update-20-0-0/move-use-daemon-process.md +27 -0
- package/dist/src/migrations/update-20-0-1/use-legacy-cache.d.ts +2 -0
- package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +20 -0
- package/dist/src/migrations/update-20-0-1/use-legacy-cache.md +24 -0
- package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.d.ts +2 -0
- package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +38 -0
- package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.md +49 -0
- package/dist/src/migrations/update-21-0-0/release-version-config-changes.d.ts +2 -0
- package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +101 -0
- package/dist/src/migrations/update-21-0-0/release-version-config-changes.md +54 -0
- package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.d.ts +2 -0
- package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +38 -0
- package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.md +28 -0
- package/dist/src/migrations/update-21-0-0/remove-legacy-cache.d.ts +2 -0
- package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +17 -0
- package/dist/src/migrations/update-21-0-0/remove-legacy-cache.md +22 -0
- package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.d.ts +2 -0
- package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +100 -0
- package/dist/src/migrations/update-22-0-0/release-version-config-changes.d.ts +2 -0
- package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +101 -0
- package/dist/src/migrations/update-22-1-0/update-nx-wrapper.d.ts +2 -0
- package/dist/src/migrations/update-22-1-0/update-nx-wrapper.js +7 -0
- package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.d.ts +2 -0
- package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +19 -0
- package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.md +11 -0
- package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.d.ts +2 -0
- package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +16 -0
- package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.d.ts +2 -0
- package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +16 -0
- package/dist/src/migrations/update-22-6-0/enable-analytics-prompt.d.ts +2 -0
- package/dist/src/migrations/update-22-6-0/enable-analytics-prompt.js +23 -0
- package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.d.ts +2 -0
- package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +16 -0
- package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.d.ts +2 -0
- package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +16 -0
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +9 -0
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +18 -0
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
- package/dist/src/migrations/utils/target-defaults.d.ts +28 -0
- package/dist/src/migrations/utils/target-defaults.js +46 -0
- package/dist/src/native/assert-supported-platform.d.ts +1 -0
- package/dist/src/native/assert-supported-platform.js +38 -0
- package/dist/src/native/browser.js +1 -0
- package/dist/src/native/index.d.ts +1419 -0
- package/dist/src/native/index.js +216 -0
- package/dist/src/native/native-bindings.js +654 -0
- package/dist/src/native/native-file-cache-location.d.ts +17 -0
- package/dist/src/native/native-file-cache-location.js +97 -0
- package/dist/src/native/nx.openharmony-arm64.node +0 -0
- package/dist/src/native/nx.wasi-browser.js +131 -0
- package/dist/src/native/nx.wasi.cjs +161 -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/native/transform-objects.d.ts +12 -0
- package/dist/src/native/transform-objects.js +97 -0
- package/dist/src/native/wasi-worker-browser.mjs +30 -0
- package/dist/src/native/wasi-worker.mjs +63 -0
- package/dist/src/nx-cloud/debug-logger.d.ts +1 -0
- package/dist/src/nx-cloud/debug-logger.js +8 -0
- package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +14 -0
- package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +166 -0
- package/dist/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +41 -0
- package/dist/src/nx-cloud/models/onboarding-status.d.ts +1 -0
- package/dist/src/nx-cloud/models/onboarding-status.js +2 -0
- package/dist/src/nx-cloud/nx-cloud-tasks-runner-shell.d.ts +16 -0
- package/dist/src/nx-cloud/nx-cloud-tasks-runner-shell.js +41 -0
- package/dist/src/nx-cloud/resolution-helpers.d.ts +1 -0
- package/dist/src/nx-cloud/resolution-helpers.js +19 -0
- package/dist/src/nx-cloud/update-manager.d.ts +26 -0
- package/dist/src/nx-cloud/update-manager.js +274 -0
- package/dist/src/nx-cloud/utilities/client.d.ts +10 -0
- package/dist/src/nx-cloud/utilities/client.js +42 -0
- package/dist/src/nx-cloud/utilities/environment.d.ts +3 -0
- package/dist/src/nx-cloud/utilities/environment.js +48 -0
- package/dist/src/nx-cloud/utilities/get-cloud-options.d.ts +5 -0
- package/dist/src/nx-cloud/utilities/get-cloud-options.js +26 -0
- package/dist/src/nx-cloud/utilities/is-workspace-claimed.d.ts +1 -0
- package/dist/src/nx-cloud/utilities/is-workspace-claimed.js +26 -0
- 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/onboarding.d.ts +5 -0
- package/dist/src/nx-cloud/utilities/onboarding.js +31 -0
- package/dist/src/nx-cloud/utilities/url-shorten.d.ts +2 -0
- package/dist/src/nx-cloud/utilities/url-shorten.js +92 -0
- package/dist/src/plugins/js/hasher/hasher.d.ts +5 -0
- package/dist/src/plugins/js/hasher/hasher.js +51 -0
- package/dist/src/plugins/js/index.d.ts +4 -0
- package/dist/src/plugins/js/index.js +182 -0
- package/dist/src/plugins/js/lock-file/bun-parser.d.ts +14 -0
- package/dist/src/plugins/js/lock-file/bun-parser.js +992 -0
- package/dist/src/plugins/js/lock-file/lock-file.d.ts +85 -0
- package/dist/src/plugins/js/lock-file/lock-file.js +441 -0
- package/dist/src/plugins/js/lock-file/npm-parser.d.ts +10 -0
- package/dist/src/plugins/js/lock-file/npm-parser.js +595 -0
- package/dist/src/plugins/js/lock-file/pnpm-parser.d.ts +10 -0
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +1047 -0
- package/dist/src/plugins/js/lock-file/project-graph-pruning.d.ts +35 -0
- package/dist/src/plugins/js/lock-file/project-graph-pruning.js +290 -0
- package/dist/src/plugins/js/lock-file/pruned-output.d.ts +331 -0
- package/dist/src/plugins/js/lock-file/pruned-output.js +1465 -0
- package/dist/src/plugins/js/lock-file/utils/package-json.d.ts +10 -0
- package/dist/src/plugins/js/lock-file/utils/package-json.js +38 -0
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +23 -0
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +897 -0
- package/dist/src/plugins/js/lock-file/yarn-parser.d.ts +10 -0
- package/dist/src/plugins/js/lock-file/yarn-parser.js +536 -0
- package/dist/src/plugins/js/package-json/create-package-json.d.ts +29 -0
- package/dist/src/plugins/js/package-json/create-package-json.js +312 -0
- package/dist/src/plugins/js/project-graph/affected/lock-file-changes.d.ts +11 -0
- package/dist/src/plugins/js/project-graph/affected/lock-file-changes.js +172 -0
- package/dist/src/plugins/js/project-graph/affected/npm-packages.d.ts +12 -0
- package/dist/src/plugins/js/project-graph/affected/npm-packages.js +145 -0
- package/dist/src/plugins/js/project-graph/affected/touched-projects.d.ts +2 -0
- package/dist/src/plugins/js/project-graph/affected/touched-projects.js +18 -0
- package/dist/src/plugins/js/project-graph/affected/tsconfig-json-changes.d.ts +4 -0
- package/dist/src/plugins/js/project-graph/affected/tsconfig-json-changes.js +63 -0
- package/dist/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +6 -0
- package/dist/src/plugins/js/project-graph/build-dependencies/build-dependencies.js +45 -0
- package/dist/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +4 -0
- package/dist/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.js +88 -0
- package/dist/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +4 -0
- package/dist/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +75 -0
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +81 -0
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +468 -0
- package/dist/src/plugins/js/project-graph/build-nodes/build-npm-package-nodes.d.ts +2 -0
- package/dist/src/plugins/js/project-graph/build-nodes/build-npm-package-nodes.js +31 -0
- package/dist/src/plugins/js/utils/config.d.ts +2 -0
- package/dist/src/plugins/js/utils/config.js +61 -0
- package/dist/src/plugins/js/utils/get-workspace-packages-from-graph.d.ts +2 -0
- package/dist/src/plugins/js/utils/get-workspace-packages-from-graph.js +13 -0
- package/dist/src/plugins/js/utils/packages.d.ts +8 -0
- package/dist/src/plugins/js/utils/packages.js +91 -0
- package/dist/src/plugins/js/utils/register.d.ts +350 -0
- package/dist/src/plugins/js/utils/register.js +1279 -0
- package/dist/src/plugins/js/utils/resolve-relative-to-dir.d.ts +5 -0
- package/dist/src/plugins/js/utils/resolve-relative-to-dir.js +17 -0
- package/dist/src/plugins/js/utils/typescript.d.ts +32 -0
- package/dist/src/plugins/js/utils/typescript.js +157 -0
- package/dist/src/plugins/js/versions.d.ts +1 -0
- package/dist/src/plugins/js/versions.js +4 -0
- package/dist/src/plugins/package-json/create-nodes.d.ts +28 -0
- package/dist/src/plugins/package-json/create-nodes.js +243 -0
- package/dist/src/plugins/package-json/index.d.ts +2 -0
- package/dist/src/plugins/package-json/index.js +6 -0
- package/dist/src/plugins/project-json/build-nodes/project-json.d.ts +5 -0
- package/dist/src/plugins/project-json/build-nodes/project-json.js +33 -0
- package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +25 -0
- package/dist/src/project-graph/affected/affected-project-graph-models.js +2 -0
- package/dist/src/project-graph/affected/affected-project-graph.d.ts +4 -0
- package/dist/src/project-graph/affected/affected-project-graph.js +77 -0
- 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/build-project-graph.d.ts +26 -0
- package/dist/src/project-graph/build-project-graph.js +309 -0
- package/dist/src/project-graph/error-types.d.ts +156 -0
- package/dist/src/project-graph/error-types.js +523 -0
- package/dist/src/project-graph/file-map-utils.d.ts +18 -0
- package/dist/src/project-graph/file-map-utils.js +61 -0
- package/dist/src/project-graph/file-utils.d.ts +33 -0
- package/dist/src/project-graph/file-utils.js +196 -0
- package/dist/src/project-graph/nx-deps-cache.d.ts +65 -0
- package/dist/src/project-graph/nx-deps-cache.js +345 -0
- package/dist/src/project-graph/operators.d.ts +11 -0
- package/dist/src/project-graph/operators.js +70 -0
- package/dist/src/project-graph/plugins/get-plugins.d.ts +53 -0
- package/dist/src/project-graph/plugins/get-plugins.js +379 -0
- package/dist/src/project-graph/plugins/in-process-loader.d.ts +10 -0
- package/dist/src/project-graph/plugins/in-process-loader.js +58 -0
- package/dist/src/project-graph/plugins/index.d.ts +4 -0
- package/dist/src/project-graph/plugins/index.js +12 -0
- package/dist/src/project-graph/plugins/isolation/enabled.d.ts +1 -0
- package/dist/src/project-graph/plugins/isolation/enabled.js +19 -0
- package/dist/src/project-graph/plugins/isolation/index.d.ts +1 -0
- package/dist/src/project-graph/plugins/isolation/index.js +7 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +103 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +626 -0
- package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.d.ts +12 -0
- package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.js +74 -0
- package/dist/src/project-graph/plugins/isolation/message-types.d.ts +59 -0
- package/dist/src/project-graph/plugins/isolation/message-types.js +9 -0
- package/dist/src/project-graph/plugins/isolation/messaging.d.ts +156 -0
- package/dist/src/project-graph/plugins/isolation/messaging.js +87 -0
- package/dist/src/project-graph/plugins/isolation/plugin-lifecycle-manager.d.ts +82 -0
- package/dist/src/project-graph/plugins/isolation/plugin-lifecycle-manager.js +188 -0
- package/dist/src/project-graph/plugins/isolation/plugin-worker.d.ts +2 -0
- package/dist/src/project-graph/plugins/isolation/plugin-worker.js +225 -0
- package/dist/src/project-graph/plugins/isolation/worker-streaming.d.ts +14 -0
- package/dist/src/project-graph/plugins/isolation/worker-streaming.js +39 -0
- package/dist/src/project-graph/plugins/load-resolved-plugin.d.ts +3 -0
- package/dist/src/project-graph/plugins/load-resolved-plugin.js +24 -0
- package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +44 -0
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +117 -0
- 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/public-api.d.ts +139 -0
- package/dist/src/project-graph/plugins/public-api.js +4 -0
- package/dist/src/project-graph/plugins/resolve-plugin.d.ts +25 -0
- package/dist/src/project-graph/plugins/resolve-plugin.js +277 -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 +4 -0
- package/dist/src/project-graph/plugins/tasks-execution-hooks.js +80 -0
- package/dist/src/project-graph/plugins/transpiler.d.ts +20 -0
- package/dist/src/project-graph/plugins/transpiler.js +99 -0
- package/dist/src/project-graph/plugins/utils.d.ts +4 -0
- package/dist/src/project-graph/plugins/utils.js +32 -0
- package/dist/src/project-graph/project-graph-builder.d.ts +133 -0
- package/dist/src/project-graph/project-graph-builder.js +395 -0
- package/dist/src/project-graph/project-graph.d.ts +54 -0
- package/dist/src/project-graph/project-graph.js +461 -0
- package/dist/src/project-graph/utils/build-all-workspace-files.d.ts +2 -0
- package/dist/src/project-graph/utils/build-all-workspace-files.js +14 -0
- package/dist/src/project-graph/utils/find-project-for-path.d.ts +20 -0
- package/dist/src/project-graph/utils/find-project-for-path.js +55 -0
- package/dist/src/project-graph/utils/implicit-project-dependencies.d.ts +3 -0
- package/dist/src/project-graph/utils/implicit-project-dependencies.js +18 -0
- package/dist/src/project-graph/utils/normalize-project-nodes.d.ts +6 -0
- package/dist/src/project-graph/utils/normalize-project-nodes.js +117 -0
- package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +48 -0
- package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.js +270 -0
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +49 -0
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +296 -0
- package/dist/src/project-graph/utils/project-configuration/source-maps.d.ts +34 -0
- package/dist/src/project-graph/utils/project-configuration/source-maps.js +85 -0
- package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +50 -0
- package/dist/src/project-graph/utils/project-configuration/target-defaults.js +466 -0
- package/dist/src/project-graph/utils/project-configuration/target-merging.d.ts +32 -0
- package/dist/src/project-graph/utils/project-configuration/target-merging.js +574 -0
- package/dist/src/project-graph/utils/project-configuration/target-normalization.d.ts +12 -0
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +396 -0
- package/dist/src/project-graph/utils/project-configuration/utils.d.ts +39 -0
- package/dist/src/project-graph/utils/project-configuration/utils.js +216 -0
- package/dist/src/project-graph/utils/project-configuration-utils.d.ts +86 -0
- package/dist/src/project-graph/utils/project-configuration-utils.js +325 -0
- package/dist/src/project-graph/utils/retrieve-workspace-files.d.ts +35 -0
- package/dist/src/project-graph/utils/retrieve-workspace-files.js +110 -0
- package/dist/src/tasks-runner/batch/batch-messages.d.ts +35 -0
- package/dist/src/tasks-runner/batch/batch-messages.js +9 -0
- package/dist/src/tasks-runner/batch/run-batch.d.ts +1 -0
- package/dist/src/tasks-runner/batch/run-batch.js +93 -0
- package/dist/src/tasks-runner/cache.d.ts +129 -0
- package/dist/src/tasks-runner/cache.js +645 -0
- package/dist/src/tasks-runner/create-task-graph.d.ts +64 -0
- package/dist/src/tasks-runner/create-task-graph.js +360 -0
- package/dist/src/tasks-runner/default-tasks-runner.d.ts +25 -0
- package/dist/src/tasks-runner/default-tasks-runner.js +74 -0
- package/dist/src/tasks-runner/fork.d.ts +1 -0
- package/dist/src/tasks-runner/fork.js +73 -0
- package/dist/src/tasks-runner/forked-process-task-runner.d.ts +45 -0
- package/dist/src/tasks-runner/forked-process-task-runner.js +309 -0
- package/dist/src/tasks-runner/init-tasks-runner.d.ts +12 -0
- package/dist/src/tasks-runner/init-tasks-runner.js +124 -0
- package/dist/src/tasks-runner/is-tui-enabled.d.ts +18 -0
- package/dist/src/tasks-runner/is-tui-enabled.js +94 -0
- package/dist/src/tasks-runner/legacy-depends-on-warning.d.ts +18 -0
- package/dist/src/tasks-runner/legacy-depends-on-warning.js +109 -0
- package/dist/src/tasks-runner/life-cycle.d.ts +93 -0
- package/dist/src/tasks-runner/life-cycle.js +155 -0
- package/dist/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.d.ts +25 -0
- package/dist/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +366 -0
- package/dist/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.d.ts +24 -0
- package/dist/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +238 -0
- package/dist/src/tasks-runner/life-cycles/empty-terminal-output-life-cycle.d.ts +5 -0
- package/dist/src/tasks-runner/life-cycles/empty-terminal-output-life-cycle.js +16 -0
- package/dist/src/tasks-runner/life-cycles/formatting-utils.d.ts +3 -0
- package/dist/src/tasks-runner/life-cycles/formatting-utils.js +55 -0
- package/dist/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.d.ts +13 -0
- package/dist/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +67 -0
- package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +173 -0
- package/dist/src/tasks-runner/life-cycles/performance-analysis.js +508 -0
- package/dist/src/tasks-runner/life-cycles/performance-life-cycle.d.ts +59 -0
- package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +193 -0
- package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +77 -0
- package/dist/src/tasks-runner/life-cycles/performance-report.js +428 -0
- package/dist/src/tasks-runner/life-cycles/pretty-time.d.ts +4 -0
- package/dist/src/tasks-runner/life-cycles/pretty-time.js +73 -0
- package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +54 -0
- package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +203 -0
- package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +54 -0
- package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +193 -0
- package/dist/src/tasks-runner/life-cycles/store-run-information-life-cycle.d.ts +17 -0
- package/dist/src/tasks-runner/life-cycles/store-run-information-life-cycle.js +87 -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/life-cycles/task-history-life-cycle-old.d.ts +11 -0
- package/dist/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +91 -0
- package/dist/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts +16 -0
- package/dist/src/tasks-runner/life-cycles/task-history-life-cycle.js +117 -0
- package/dist/src/tasks-runner/life-cycles/task-profiling-life-cycle.d.ts +14 -0
- package/dist/src/tasks-runner/life-cycles/task-profiling-life-cycle.js +73 -0
- package/dist/src/tasks-runner/life-cycles/task-results-life-cycle.d.ts +6 -0
- package/dist/src/tasks-runner/life-cycles/task-results-life-cycle.js +17 -0
- package/dist/src/tasks-runner/life-cycles/task-telemetry-life-cycle.d.ts +9 -0
- package/dist/src/tasks-runner/life-cycles/task-telemetry-life-cycle.js +42 -0
- package/dist/src/tasks-runner/life-cycles/task-timings-life-cycle.d.ts +8 -0
- package/dist/src/tasks-runner/life-cycles/task-timings-life-cycle.js +39 -0
- package/dist/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts +19 -0
- package/dist/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +339 -0
- package/dist/src/tasks-runner/life-cycles/view-logs-utils.d.ts +1 -0
- package/dist/src/tasks-runner/life-cycles/view-logs-utils.js +15 -0
- package/dist/src/tasks-runner/process-metrics-service.d.ts +53 -0
- package/dist/src/tasks-runner/process-metrics-service.js +161 -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/pseudo-ipc.d.ts +48 -0
- package/dist/src/tasks-runner/pseudo-ipc.js +157 -0
- package/dist/src/tasks-runner/pseudo-terminal.d.ts +72 -0
- package/dist/src/tasks-runner/pseudo-terminal.js +209 -0
- package/dist/src/tasks-runner/remove-old-cache-records.d.ts +1 -0
- package/dist/src/tasks-runner/remove-old-cache-records.js +60 -0
- package/dist/src/tasks-runner/run-command.d.ts +78 -0
- package/dist/src/tasks-runner/run-command.js +971 -0
- package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +148 -0
- package/dist/src/tasks-runner/running-tasks/batch-process.js +362 -0
- package/dist/src/tasks-runner/running-tasks/node-child-process.d.ts +40 -0
- package/dist/src/tasks-runner/running-tasks/node-child-process.js +175 -0
- package/dist/src/tasks-runner/running-tasks/noop-child-process.d.ts +16 -0
- package/dist/src/tasks-runner/running-tasks/noop-child-process.js +22 -0
- package/dist/src/tasks-runner/running-tasks/output-prefix.d.ts +13 -0
- package/dist/src/tasks-runner/running-tasks/output-prefix.js +63 -0
- package/dist/src/tasks-runner/running-tasks/running-task.d.ts +11 -0
- package/dist/src/tasks-runner/running-tasks/running-task.js +6 -0
- package/dist/src/tasks-runner/running-tasks/shared-running-task.d.ts +15 -0
- package/dist/src/tasks-runner/running-tasks/shared-running-task.js +41 -0
- package/dist/src/tasks-runner/task-env-paths.d.ts +1 -0
- package/dist/src/tasks-runner/task-env-paths.js +45 -0
- package/dist/src/tasks-runner/task-env.d.ts +56 -0
- package/dist/src/tasks-runner/task-env.js +237 -0
- package/dist/src/tasks-runner/task-graph-utils.d.ts +30 -0
- package/dist/src/tasks-runner/task-graph-utils.js +225 -0
- package/dist/src/tasks-runner/task-io-service.d.ts +104 -0
- package/dist/src/tasks-runner/task-io-service.js +131 -0
- package/dist/src/tasks-runner/task-orchestrator.d.ts +330 -0
- package/dist/src/tasks-runner/task-orchestrator.js +1749 -0
- package/dist/src/tasks-runner/tasks-runner.d.ts +26 -0
- package/dist/src/tasks-runner/tasks-runner.js +2 -0
- package/dist/src/tasks-runner/tasks-schedule.d.ts +48 -0
- package/dist/src/tasks-runner/tasks-schedule.js +258 -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 +66 -0
- package/dist/src/tasks-runner/utils.js +459 -0
- 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 +62 -0
- package/dist/src/utils/ab-testing.js +145 -0
- package/dist/src/utils/acknowledge-build-scripts.d.ts +13 -0
- package/dist/src/utils/acknowledge-build-scripts.js +102 -0
- package/dist/src/utils/all-file-data.d.ts +2 -0
- package/dist/src/utils/all-file-data.js +8 -0
- package/dist/src/utils/analytics-enabled.d.ts +7 -0
- package/dist/src/utils/analytics-enabled.js +11 -0
- package/dist/src/utils/analytics-prompt.d.ts +9 -0
- package/dist/src/utils/analytics-prompt.js +81 -0
- package/dist/src/utils/assert-workspace-validity.d.ts +3 -0
- package/dist/src/utils/assert-workspace-validity.js +90 -0
- package/dist/src/utils/async-iterator.d.ts +2 -0
- package/dist/src/utils/async-iterator.js +18 -0
- package/dist/src/utils/binary-extensions.d.ts +1 -0
- package/dist/src/utils/binary-extensions.js +279 -0
- package/dist/src/utils/cache-directory.d.ts +68 -0
- package/dist/src/utils/cache-directory.js +337 -0
- package/dist/src/utils/call-sites.d.ts +14 -0
- package/dist/src/utils/call-sites.js +28 -0
- package/dist/src/utils/catalog/bun-manager-utils.d.ts +8 -0
- package/dist/src/utils/catalog/bun-manager-utils.js +174 -0
- package/dist/src/utils/catalog/bun-manager.d.ts +28 -0
- package/dist/src/utils/catalog/bun-manager.js +130 -0
- package/dist/src/utils/catalog/index.d.ts +22 -0
- package/dist/src/utils/catalog/index.js +87 -0
- package/dist/src/utils/catalog/manager-factory.d.ts +5 -0
- package/dist/src/utils/catalog/manager-factory.js +23 -0
- package/dist/src/utils/catalog/manager-utils.d.ts +15 -0
- package/dist/src/utils/catalog/manager-utils.js +237 -0
- package/dist/src/utils/catalog/manager.d.ts +52 -0
- package/dist/src/utils/catalog/manager.js +43 -0
- package/dist/src/utils/catalog/pnpm-manager.d.ts +23 -0
- package/dist/src/utils/catalog/pnpm-manager.js +142 -0
- package/dist/src/utils/catalog/types.d.ts +15 -0
- package/dist/src/utils/catalog/types.js +2 -0
- package/dist/src/utils/catalog/yarn-manager.d.ts +26 -0
- package/dist/src/utils/catalog/yarn-manager.js +130 -0
- package/dist/src/utils/child-process.d.ts +52 -0
- package/dist/src/utils/child-process.js +194 -0
- package/dist/src/utils/chunkify.d.ts +11 -0
- package/dist/src/utils/chunkify.js +45 -0
- package/dist/src/utils/code-frames.d.ts +14 -0
- package/dist/src/utils/code-frames.js +116 -0
- package/dist/src/utils/command-line-utils.d.ts +77 -0
- package/dist/src/utils/command-line-utils.js +266 -0
- package/dist/src/utils/compile-cache.d.ts +24 -0
- package/dist/src/utils/compile-cache.js +49 -0
- package/dist/src/utils/consume-messages-from-socket.d.ts +44 -0
- package/dist/src/utils/consume-messages-from-socket.js +291 -0
- 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 +16 -0
- package/dist/src/utils/db-connection.js +58 -0
- package/dist/src/utils/default-base.d.ts +1 -0
- package/dist/src/utils/default-base.js +17 -0
- package/dist/src/utils/delayed-spinner.d.ts +51 -0
- package/dist/src/utils/delayed-spinner.js +88 -0
- package/dist/src/utils/dotenv.d.ts +7 -0
- package/dist/src/utils/dotenv.js +19 -0
- package/dist/src/utils/enable-compile-cache.d.ts +1 -0
- package/dist/src/utils/enable-compile-cache.js +7 -0
- package/dist/src/utils/exit-codes.d.ts +24 -0
- package/dist/src/utils/exit-codes.js +94 -0
- package/dist/src/utils/fileutils.d.ts +72 -0
- package/dist/src/utils/fileutils.js +117 -0
- package/dist/src/utils/find-matching-projects.d.ts +18 -0
- package/dist/src/utils/find-matching-projects.js +222 -0
- package/dist/src/utils/find-workspace-root.d.ts +11 -0
- package/dist/src/utils/find-workspace-root.js +33 -0
- package/dist/src/utils/formatters/index.d.ts +19 -0
- package/dist/src/utils/formatters/index.js +79 -0
- package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
- package/dist/src/utils/formatters/oxfmt.js +764 -0
- package/dist/src/utils/formatters/prettier.d.ts +18 -0
- package/dist/src/utils/formatters/prettier.js +179 -0
- package/dist/src/utils/formatters/shared.d.ts +5 -0
- package/dist/src/utils/formatters/shared.js +8 -0
- package/dist/src/utils/get-package-name-from-import-path.d.ts +1 -0
- package/dist/src/utils/get-package-name-from-import-path.js +17 -0
- package/dist/src/utils/git-revision.d.ts +12 -0
- package/dist/src/utils/git-revision.js +25 -0
- package/dist/src/utils/git-utils.d.ts +125 -0
- package/dist/src/utils/git-utils.index-filter.d.ts +1 -0
- package/dist/src/utils/git-utils.index-filter.js +23 -0
- package/dist/src/utils/git-utils.js +991 -0
- package/dist/src/utils/git-utils.tree-filter.d.ts +1 -0
- package/dist/src/utils/git-utils.tree-filter.js +47 -0
- package/dist/src/utils/git-worktrees.d.ts +30 -0
- package/dist/src/utils/git-worktrees.js +212 -0
- package/dist/src/utils/globs.d.ts +3 -0
- package/dist/src/utils/globs.js +18 -0
- package/dist/src/utils/handle-errors.d.ts +1 -0
- package/dist/src/utils/handle-errors.js +53 -0
- package/dist/src/utils/handle-import.d.ts +15 -0
- package/dist/src/utils/handle-import.js +86 -0
- package/dist/src/utils/has-nx-js-plugin.d.ts +9 -0
- package/dist/src/utils/has-nx-js-plugin.js +24 -0
- package/dist/src/utils/http-client.d.ts +27 -0
- package/dist/src/utils/http-client.js +193 -0
- package/dist/src/utils/ignore.d.ts +178 -0
- package/dist/src/utils/ignore.js +294 -0
- package/dist/src/utils/installation-directory.d.ts +2 -0
- package/dist/src/utils/installation-directory.js +12 -0
- package/dist/src/utils/installed-nx-version.d.ts +23 -0
- package/dist/src/utils/installed-nx-version.js +67 -0
- package/dist/src/utils/is-ci.d.ts +1 -0
- package/dist/src/utils/is-ci.js +26 -0
- package/dist/src/utils/is-sandbox.d.ts +1 -0
- package/dist/src/utils/is-sandbox.js +11 -0
- package/dist/src/utils/json-diff.d.ts +20 -0
- package/dist/src/utils/json-diff.js +24 -0
- package/dist/src/utils/json.d.ts +44 -0
- package/dist/src/utils/json.js +62 -0
- package/dist/src/utils/kill-child-on-host-exit.d.ts +7 -0
- package/dist/src/utils/kill-child-on-host-exit.js +42 -0
- package/dist/src/utils/legacy-task-history.d.ts +8 -0
- package/dist/src/utils/legacy-task-history.js +87 -0
- package/dist/src/utils/logger.d.ts +23 -0
- package/dist/src/utils/logger.js +74 -0
- package/dist/src/utils/long-running-target.d.ts +10 -0
- package/dist/src/utils/long-running-target.js +19 -0
- package/dist/src/utils/machine-id-cache.d.ts +5 -0
- package/dist/src/utils/machine-id-cache.js +93 -0
- package/dist/src/utils/min-release-age/behavior/bun.d.ts +30 -0
- package/dist/src/utils/min-release-age/behavior/bun.js +274 -0
- package/dist/src/utils/min-release-age/behavior/npm.d.ts +21 -0
- package/dist/src/utils/min-release-age/behavior/npm.js +296 -0
- package/dist/src/utils/min-release-age/behavior/pnpm.d.ts +23 -0
- package/dist/src/utils/min-release-age/behavior/pnpm.js +535 -0
- package/dist/src/utils/min-release-age/behavior/yarn.d.ts +22 -0
- package/dist/src/utils/min-release-age/behavior/yarn.js +314 -0
- package/dist/src/utils/min-release-age/constants.d.ts +3 -0
- package/dist/src/utils/min-release-age/constants.js +8 -0
- package/dist/src/utils/min-release-age/errors.d.ts +28 -0
- package/dist/src/utils/min-release-age/errors.js +22 -0
- package/dist/src/utils/min-release-age/packument.d.ts +13 -0
- package/dist/src/utils/min-release-age/packument.js +34 -0
- package/dist/src/utils/min-release-age/pick.d.ts +72 -0
- package/dist/src/utils/min-release-age/pick.js +206 -0
- package/dist/src/utils/min-release-age/pnpm-exclude-writer.d.ts +12 -0
- package/dist/src/utils/min-release-age/pnpm-exclude-writer.js +58 -0
- package/dist/src/utils/min-release-age/policy.d.ts +38 -0
- package/dist/src/utils/min-release-age/policy.js +59 -0
- package/dist/src/utils/min-release-age/resolve.d.ts +8 -0
- package/dist/src/utils/min-release-age/resolve.js +14 -0
- package/dist/src/utils/nx-cloud-utils.d.ts +6 -0
- package/dist/src/utils/nx-cloud-utils.js +33 -0
- package/dist/src/utils/nx-console-prompt.d.ts +1 -0
- package/dist/src/utils/nx-console-prompt.js +61 -0
- package/dist/src/utils/nx-key.d.ts +6 -0
- package/dist/src/utils/nx-key.js +50 -0
- package/dist/src/utils/nx-package-group.d.ts +8 -0
- package/dist/src/utils/nx-package-group.js +15 -0
- package/dist/src/utils/nx-tmp-dir.d.ts +23 -0
- package/dist/src/utils/nx-tmp-dir.js +45 -0
- package/dist/src/utils/object-sort.d.ts +1 -0
- package/dist/src/utils/object-sort.js +9 -0
- package/dist/src/utils/output.d.ts +251 -0
- package/dist/src/utils/output.js +571 -0
- package/dist/src/utils/owned-private-dir.d.ts +145 -0
- package/dist/src/utils/owned-private-dir.js +362 -0
- package/dist/src/utils/package-json.d.ts +256 -0
- package/dist/src/utils/package-json.js +441 -0
- package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
- package/dist/src/utils/package-manager-config/bunfig.js +49 -0
- package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
- package/dist/src/utils/package-manager-config/npmrc.js +124 -0
- package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
- package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
- package/dist/src/utils/package-manager.d.ts +167 -0
- package/dist/src/utils/package-manager.js +860 -0
- package/dist/src/utils/params.d.ts +146 -0
- package/dist/src/utils/params.js +768 -0
- package/dist/src/utils/path.d.ts +25 -0
- package/dist/src/utils/path.js +53 -0
- package/dist/src/utils/perf-hooks.d.ts +19 -0
- package/dist/src/utils/perf-logging.d.ts +1 -0
- package/dist/src/utils/perf-logging.js +46 -0
- package/dist/src/utils/permission-errors.d.ts +11 -0
- package/dist/src/utils/permission-errors.js +17 -0
- package/dist/src/utils/plugin-cache-utils.d.ts +82 -0
- package/dist/src/utils/plugin-cache-utils.js +212 -0
- package/dist/src/utils/plugin-progress-text.d.ts +1 -0
- package/dist/src/utils/plugin-progress-text.js +15 -0
- package/dist/src/utils/plugins/atomizer-utils.d.ts +11 -0
- package/dist/src/utils/plugins/atomizer-utils.js +23 -0
- package/dist/src/utils/plugins/core-plugins.d.ts +6 -0
- package/dist/src/utils/plugins/core-plugins.js +117 -0
- package/dist/src/utils/plugins/index.d.ts +5 -0
- package/dist/src/utils/plugins/index.js +15 -0
- package/dist/src/utils/plugins/installed-plugins.d.ts +5 -0
- package/dist/src/utils/plugins/installed-plugins.js +76 -0
- package/dist/src/utils/plugins/local-plugins.d.ts +22 -0
- package/dist/src/utils/plugins/local-plugins.js +60 -0
- package/dist/src/utils/plugins/output.d.ts +34 -0
- package/dist/src/utils/plugins/output.js +201 -0
- package/dist/src/utils/plugins/plugin-capabilities.d.ts +15 -0
- package/dist/src/utils/plugins/plugin-capabilities.js +83 -0
- package/dist/src/utils/pnpm-workspace.d.ts +8 -0
- package/dist/src/utils/pnpm-workspace.js +2 -0
- package/dist/src/utils/print-help.d.ts +11 -0
- package/dist/src/utils/print-help.js +259 -0
- package/dist/src/utils/progress-topics.d.ts +19 -0
- package/dist/src/utils/progress-topics.js +21 -0
- package/dist/src/utils/project-graph-utils.d.ts +20 -0
- package/dist/src/utils/project-graph-utils.js +90 -0
- package/dist/src/utils/promised-based-queue.d.ts +6 -0
- package/dist/src/utils/promised-based-queue.js +43 -0
- package/dist/src/utils/prompt-helpers.d.ts +53 -0
- package/dist/src/utils/prompt-helpers.js +111 -0
- package/dist/src/utils/provenance.d.ts +47 -0
- package/dist/src/utils/provenance.js +123 -0
- package/dist/src/utils/registry-config/bun.d.ts +2 -0
- package/dist/src/utils/registry-config/bun.js +257 -0
- package/dist/src/utils/registry-config/index.d.ts +13 -0
- package/dist/src/utils/registry-config/index.js +102 -0
- package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
- package/dist/src/utils/registry-config/pnpm.js +1551 -0
- package/dist/src/utils/registry-config/utils.d.ts +195 -0
- package/dist/src/utils/registry-config/utils.js +496 -0
- package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
- package/dist/src/utils/registry-config/yarn-berry.js +612 -0
- package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
- package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
- package/dist/src/utils/require-nx-key.d.ts +1 -0
- package/dist/src/utils/require-nx-key.js +23 -0
- package/dist/src/utils/safe-spawn.d.ts +24 -0
- package/dist/src/utils/safe-spawn.js +104 -0
- package/dist/src/utils/serializable-error.d.ts +4 -0
- package/dist/src/utils/serializable-error.js +33 -0
- package/dist/src/utils/serialize-overrides-into-command-line.d.ts +3 -0
- package/dist/src/utils/serialize-overrides-into-command-line.js +39 -0
- package/dist/src/utils/serialize-target.d.ts +1 -0
- package/dist/src/utils/serialize-target.js +6 -0
- package/dist/src/utils/shell-quoting.d.ts +25 -0
- package/dist/src/utils/shell-quoting.js +76 -0
- package/dist/src/utils/socket-refused-exit-code.d.ts +15 -0
- package/dist/src/utils/socket-refused-exit-code.js +18 -0
- package/dist/src/utils/spinner.d.ts +24 -0
- package/dist/src/utils/spinner.js +77 -0
- package/dist/src/utils/split-target.d.ts +15 -0
- package/dist/src/utils/split-target.js +239 -0
- package/dist/src/utils/strip-indents.d.ts +14 -0
- package/dist/src/utils/strip-indents.js +23 -0
- package/dist/src/utils/sync-generators.d.ts +66 -0
- package/dist/src/utils/sync-generators.js +355 -0
- package/dist/src/utils/tar.d.ts +8 -0
- package/dist/src/utils/tar.js +44 -0
- package/dist/src/utils/task-history.d.ts +17 -0
- package/dist/src/utils/task-history.js +51 -0
- package/dist/src/utils/terminal-link.d.ts +20 -0
- package/dist/src/utils/terminal-link.js +85 -0
- package/dist/src/utils/update-nxw.d.ts +2 -0
- package/dist/src/utils/update-nxw.js +22 -0
- package/dist/src/utils/versions.d.ts +1 -0
- package/dist/src/utils/versions.js +4 -0
- package/dist/src/utils/wait-for-socket-connection.d.ts +26 -0
- package/dist/src/utils/wait-for-socket-connection.js +59 -0
- package/dist/src/utils/workspace-context.d.ts +69 -0
- package/dist/src/utils/workspace-context.js +284 -0
- package/dist/src/utils/workspace-id.d.ts +20 -0
- package/dist/src/utils/workspace-id.js +54 -0
- package/dist/src/utils/workspace-root.d.ts +6 -0
- package/dist/src/utils/workspace-root.js +40 -0
- package/dist/src/utils/write-formatted-json-file.d.ts +7 -0
- package/dist/src/utils/write-formatted-json-file.js +24 -0
- package/dist/src/utils/yarn-syml/index.d.ts +23 -0
- package/dist/src/utils/yarn-syml/index.js +151 -0
- package/dist/src/utils/yarn-syml/syml-grammar.js +1911 -0
- package/dist/tasks-runners/default.d.ts +1 -0
- package/dist/tasks-runners/default.js +5 -0
- package/executors.json +19 -0
- package/generators.json +16 -0
- package/migrations.json +195 -0
- package/package.json +516 -9
- package/readme-template.md +16 -0
- package/schemas/migrations-schema.json +186 -0
- package/schemas/nx-schema.json +1653 -0
- package/schemas/project-schema.json +461 -0
- package/schemas/workspace-schema.json +185 -0
- package/local-natives.js +0 -59
|
@@ -0,0 +1,2272 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runOrchestratorInit = runOrchestratorInit;
|
|
4
|
+
exports.runOrchestratorResume = runOrchestratorResume;
|
|
5
|
+
exports.holdRunToContinue = holdRunToContinue;
|
|
6
|
+
exports.activeRunToReplace = activeRunToReplace;
|
|
7
|
+
exports.releaseRunToHandOff = releaseRunToHandOff;
|
|
8
|
+
exports.runOrchestratorReconcile = runOrchestratorReconcile;
|
|
9
|
+
exports.completionWarnings = completionWarnings;
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const crypto_1 = require("crypto");
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const path_1 = require("path");
|
|
14
|
+
const native_1 = require("../../../native");
|
|
15
|
+
const fileutils_1 = require("../../../utils/fileutils");
|
|
16
|
+
const atomic_write_1 = require("./atomic-write");
|
|
17
|
+
const clean_retry_1 = require("./clean-retry");
|
|
18
|
+
const broker_1 = require("./broker");
|
|
19
|
+
const git_utils_1 = require("../../../utils/git-utils");
|
|
20
|
+
const versions_1 = require("../../../utils/versions");
|
|
21
|
+
const handoff_1 = require("../agentic/handoff");
|
|
22
|
+
const format_command_1 = require("../agentic/format-command");
|
|
23
|
+
const handoff_gitignore_1 = require("../agentic/handoff-gitignore");
|
|
24
|
+
const instruction_files_1 = require("../agentic/instruction-files");
|
|
25
|
+
const final_validation_1 = require("../agentic/prompts/final-validation");
|
|
26
|
+
const fragments_1 = require("../agentic/prompts/fragments");
|
|
27
|
+
const types_1 = require("../agentic/types");
|
|
28
|
+
const migrate_commits_1 = require("../migrate-commits");
|
|
29
|
+
const migrate_analytics_1 = require("../migrate-analytics");
|
|
30
|
+
const sort_migrations_1 = require("../sort-migrations");
|
|
31
|
+
const run_id_1 = require("./run-id");
|
|
32
|
+
const run_state_1 = require("./run-state");
|
|
33
|
+
const state_lock_1 = require("./state-lock");
|
|
34
|
+
const state_machine_1 = require("./state-machine");
|
|
35
|
+
const give_up_1 = require("./give-up");
|
|
36
|
+
const migration_shape_1 = require("../migration-shape");
|
|
37
|
+
const util_1 = require("./util");
|
|
38
|
+
const text_1 = require("../text");
|
|
39
|
+
const agent_output_1 = require("./agent-output");
|
|
40
|
+
const agent_work_payload_1 = require("./agent-work-payload");
|
|
41
|
+
const issues_1 = require("./issues");
|
|
42
|
+
const runbook_1 = require("./runbook");
|
|
43
|
+
const existing_run_report_1 = require("./existing-run-report");
|
|
44
|
+
const package_manager_1 = require("../../../utils/package-manager");
|
|
45
|
+
// The dark migrate orchestrator: drives a durable run one dispense at a time.
|
|
46
|
+
// An outer AI agent runs each dispensed command and re-invokes `nx migrate
|
|
47
|
+
// --run-id=<id>` to reconcile; there is no long-lived process.
|
|
48
|
+
const PLAN_SNAPSHOT_0 = 'plan-0.json';
|
|
49
|
+
// A running worker older than this may be hung; the still-running dispense
|
|
50
|
+
// escalates so the agent can verify or kill it.
|
|
51
|
+
const HANG_THRESHOLD_MS = 15 * 60 * 1000;
|
|
52
|
+
// Identical responses in a row before the dispense escalates to a
|
|
53
|
+
// 'no-progress' action. A still-running worker is exempt until the hang
|
|
54
|
+
// threshold: waiting on a live worker is not looping.
|
|
55
|
+
const NO_PROGRESS_THRESHOLD = 3;
|
|
56
|
+
// Two rearms per step: one for the diagnosed fix and one for its correction.
|
|
57
|
+
const REARM_ESCALATION_CAP = 2;
|
|
58
|
+
const INIT_CONTINUE_HINT = 're-run the command, or unset NX_MIGRATE_ORCHESTRATOR to use the standard migrate flow.';
|
|
59
|
+
function continueRunHint(runId) {
|
|
60
|
+
return `re-run the command to continue run '${runId}'.`;
|
|
61
|
+
}
|
|
62
|
+
// Refuses to proceed when the run's `git add -A` commits could sweep in the
|
|
63
|
+
// scratch under .nx/migrate-runs. Only commit-creating runs probe: without
|
|
64
|
+
// commits the worst case is git-status noise. Fails closed on an unusable
|
|
65
|
+
// probe: createCommits reaching the orchestrator means git was a repository
|
|
66
|
+
// at resolution time (resolveCreateCommits), so an unusable git here is an
|
|
67
|
+
// anomaly, and proceeding would risk absorbing run state into commits, where
|
|
68
|
+
// a later retry-clean `git reset --hard` could roll the tracked state back
|
|
69
|
+
// to a stale snapshot.
|
|
70
|
+
function assertScratchDirSafeForCommits(root, thenWhat) {
|
|
71
|
+
refuseUnsafeScratchExposure((0, git_utils_1.getPathCommitExposure)(types_1.MIGRATE_RUNS_RELATIVE_DIR, root), thenWhat);
|
|
72
|
+
}
|
|
73
|
+
function refuseUnsafeScratchExposure(exposure, thenWhat) {
|
|
74
|
+
switch (exposure) {
|
|
75
|
+
case 'ignored':
|
|
76
|
+
return;
|
|
77
|
+
case 'tracked':
|
|
78
|
+
throw new Error(`Files under ${types_1.MIGRATE_RUNS_RELATIVE_DIR} are committed to git, and ignore rules do not apply to tracked files, so migrate's commits would keep capturing this run's scratch state. ` +
|
|
79
|
+
`Untrack them with \`git rm -r --cached ${types_1.MIGRATE_RUNS_RELATIVE_DIR}\`, commit that change, make sure .gitignore lists ${types_1.MIGRATE_RUNS_RELATIVE_DIR}, then ${thenWhat}`);
|
|
80
|
+
case 'unignored':
|
|
81
|
+
throw new Error(`${types_1.MIGRATE_RUNS_RELATIVE_DIR} is not ignored by git, so migrate's commits would capture this run's scratch state. ` +
|
|
82
|
+
`Add a \`${types_1.MIGRATE_RUNS_RELATIVE_DIR}\` entry to .gitignore, then ${thenWhat}`);
|
|
83
|
+
case 'unknown':
|
|
84
|
+
throw new Error(`Could not verify with git that ${types_1.MIGRATE_RUNS_RELATIVE_DIR} is ignored, so migrate's commits could capture this run's scratch state. ` +
|
|
85
|
+
`Make sure git is usable in this workspace, then ${thenWhat}`);
|
|
86
|
+
default: {
|
|
87
|
+
const exhaustive = exposure;
|
|
88
|
+
throw new Error(`Unrecognized scratch exposure '${exhaustive}'.`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async function runOrchestratorInit(input) {
|
|
93
|
+
const { root, migrationsJson, migrationsPath, createCommits, commitPrefix, skipInstall, installedNxVersion, validate, finalValidation, emitAgentInstructions = true, onExistingRun = 'report', replaceRunId, confirmStart, } = input;
|
|
94
|
+
const migrations = (migrationsJson.migrations ?? []);
|
|
95
|
+
const sorted = (0, sort_migrations_1.sortMigrations)(migrations.slice(), {
|
|
96
|
+
hoistHandoffGitignore: true,
|
|
97
|
+
});
|
|
98
|
+
const plannedIds = sorted.map((m) => `${m.package}:${m.name}`);
|
|
99
|
+
// An active run means a prior init already happened (e.g. it crashed before
|
|
100
|
+
// the agent's first reconcile); starting a second run would compete with it,
|
|
101
|
+
// and whether to continue it or replace it is the user's call, not a guess
|
|
102
|
+
// from the plans. Reported before the migration id check below: this plan
|
|
103
|
+
// is not being started. NewerRunStateFormatError propagates.
|
|
104
|
+
const active = onExistingRun === 'start-fresh'
|
|
105
|
+
? activeRunToReplace(root, replaceRunId)
|
|
106
|
+
: findActiveRunForInit(root);
|
|
107
|
+
if (active &&
|
|
108
|
+
(onExistingRun === 'report' ||
|
|
109
|
+
(replaceRunId !== undefined && active.runId !== replaceRunId))) {
|
|
110
|
+
return reportExistingRun(root, active.runId, active.state, plannedIds, migrationsPath, emitAgentInstructions, replaceRunId);
|
|
111
|
+
}
|
|
112
|
+
// Held through confirmStart so a concurrent start-fresh cannot delete the
|
|
113
|
+
// run while the user is asked. The refusals run here first, before the
|
|
114
|
+
// prompt, the .gitignore fallback and the checkpoint; the locked pass below
|
|
115
|
+
// is authoritative. Skipped without the scratch dir: the lock would create it.
|
|
116
|
+
if (active) {
|
|
117
|
+
(0, state_lock_1.holdRunActivity)(root, active.runId);
|
|
118
|
+
}
|
|
119
|
+
if ((0, fs_1.existsSync)((0, run_state_1.migrateRunsDir)(root))) {
|
|
120
|
+
(0, state_lock_1.withRunCreationLock)(root, () => {
|
|
121
|
+
refuseLiveReservation(root);
|
|
122
|
+
if (active) {
|
|
123
|
+
refuseUndeletableRun(root, active.runId, active.state);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
// Dispensed commands interpolate migration ids verbatim, so every init
|
|
128
|
+
// validates the incoming plan's ids. Before the delete below: a run must
|
|
129
|
+
// not be thrown away for a plan that cannot start.
|
|
130
|
+
for (const id of plannedIds) {
|
|
131
|
+
if (!run_state_1.SHELL_SAFE_VALUE.test(id)) {
|
|
132
|
+
throw new Error(`The migration id '${id}' contains characters that are not shell-safe. Orchestrated runs require shell-safe migration ids.`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (confirmStart && !(await confirmStart())) {
|
|
136
|
+
return { kind: 'refused' };
|
|
137
|
+
}
|
|
138
|
+
const runId = (0, run_id_1.createRunId)();
|
|
139
|
+
const dir = (0, run_state_1.runDir)(root, runId);
|
|
140
|
+
// Probe before any git side effect: the checkpoint below is a `git add -A`
|
|
141
|
+
// commit, so on a workspace where scratch is committable it would sweep in
|
|
142
|
+
// prior runs' directories and manufacture the very tracked state the probe
|
|
143
|
+
// refuses. Missing ignore coverage alone is not refused yet, because the
|
|
144
|
+
// fallback below may still add the entry. 'ignored' also stands in for
|
|
145
|
+
// "no hazard" when commits are off.
|
|
146
|
+
const scratchExposure = createCommits
|
|
147
|
+
? (0, git_utils_1.getPathCommitExposure)(types_1.MIGRATE_RUNS_RELATIVE_DIR, root)
|
|
148
|
+
: 'ignored';
|
|
149
|
+
if (scratchExposure !== 'unignored') {
|
|
150
|
+
refuseUnsafeScratchExposure(scratchExposure, INIT_CONTINUE_HINT);
|
|
151
|
+
}
|
|
152
|
+
// Applied before the checkpoint so the entry (when it can be added) already
|
|
153
|
+
// covers older scratch by the time the checkpoint's `git add -A` runs; the
|
|
154
|
+
// fallback's standalone commit is suppressed because that checkpoint
|
|
155
|
+
// carries the edit. Unlike the classic loop, a planned ignore migration
|
|
156
|
+
// can't be deferred to: the run dir is created below, before that
|
|
157
|
+
// migration runs.
|
|
158
|
+
await (0, handoff_gitignore_1.applyAgenticHandoffGitignoreFallback)({
|
|
159
|
+
migrations: sorted,
|
|
160
|
+
installedNxVersion,
|
|
161
|
+
effectiveCreateCommits: createCommits,
|
|
162
|
+
commitPrefix,
|
|
163
|
+
root,
|
|
164
|
+
applyWhenPlanned: true,
|
|
165
|
+
commitStandalone: false,
|
|
166
|
+
});
|
|
167
|
+
if (scratchExposure === 'unignored') {
|
|
168
|
+
// The fallback was the workspace's last chance at ignore coverage;
|
|
169
|
+
// refuse when it could not add the entry (v23+ conscious removal, no
|
|
170
|
+
// .gitignore, Lerna without nx.json).
|
|
171
|
+
refuseUnsafeScratchExposure((0, git_utils_1.getPathCommitExposure)(types_1.MIGRATE_RUNS_RELATIVE_DIR, root), INIT_CONTINUE_HINT);
|
|
172
|
+
}
|
|
173
|
+
// One creation-lock section: two inits cannot both create a run, and a
|
|
174
|
+
// start-fresh's delete and the new directory's reservation (no run.json
|
|
175
|
+
// yet) land together. Git stays outside the lock: a hook re-entering nx
|
|
176
|
+
// migrate would wait on this process. The .gitignore fallback is idempotent.
|
|
177
|
+
let deleted = false;
|
|
178
|
+
const reserved = (0, state_lock_1.withRunCreationLock)(root, () => {
|
|
179
|
+
refuseLiveReservation(root);
|
|
180
|
+
const nowActive = findActiveRunForInit(root, active !== null);
|
|
181
|
+
if (nowActive && nowActive.runId !== active?.runId) {
|
|
182
|
+
return nowActive;
|
|
183
|
+
}
|
|
184
|
+
if (active) {
|
|
185
|
+
// Completed meanwhile (a reconcile finished it): nothing to replace.
|
|
186
|
+
if (!nowActive) {
|
|
187
|
+
throw new Error(noActiveRunToReplace(active.runId));
|
|
188
|
+
}
|
|
189
|
+
deleted = deleteRunRecord(root, active.runId);
|
|
190
|
+
}
|
|
191
|
+
// The snapshot must exist before run.json makes the run discoverable: a
|
|
192
|
+
// crash in between must not leave an active run without its plan.
|
|
193
|
+
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
194
|
+
(0, fileutils_1.writeJsonFile)((0, path_1.join)(dir, PLAN_SNAPSHOT_0), migrationsJson);
|
|
195
|
+
// Held from here until run.json is written below and past it: a run must
|
|
196
|
+
// never be discoverable, or reserved, without a holder.
|
|
197
|
+
(0, state_lock_1.registerRunActivity)(dir);
|
|
198
|
+
return null;
|
|
199
|
+
});
|
|
200
|
+
if (reserved) {
|
|
201
|
+
// A run created concurrently since the check above. Reported, not
|
|
202
|
+
// deleted, even under 'start-fresh': that consent covered the run the
|
|
203
|
+
// user saw, not one that appeared while this init was running.
|
|
204
|
+
return reportExistingRun(root, reserved.runId, reserved.state, plannedIds, migrationsPath, emitAgentInstructions);
|
|
205
|
+
}
|
|
206
|
+
if (deleted) {
|
|
207
|
+
removeDeletedRunDir(root, active.runId);
|
|
208
|
+
}
|
|
209
|
+
// Checkpoint pre-existing working-tree state BEFORE run.json exists, so a
|
|
210
|
+
// clean tree stays uncommitted (writing run.json would otherwise dirty it
|
|
211
|
+
// and fire a spurious checkpoint). A crash between here and createRun
|
|
212
|
+
// leaves the committed changes orphaned but never lost, and the reserved
|
|
213
|
+
// directory unlocked, which discovery ignores; the next init re-checkpoints
|
|
214
|
+
// a now-clean tree as a no-op.
|
|
215
|
+
// Read before the checkpoint so its content (the planning phase's package
|
|
216
|
+
// bump and lockfile churn) is inside the whole-run diff the pass selects
|
|
217
|
+
// from; on the run because a step's gitRefBefore moves on re-dispense.
|
|
218
|
+
const gitRefAtInit = (0, git_utils_1.getLatestCommitSha)(root);
|
|
219
|
+
const checkpoint = createCommits
|
|
220
|
+
? checkpointEntry(root, commitPrefix, gitRefAtInit)
|
|
221
|
+
: null;
|
|
222
|
+
// The preflight checkpoint swallows its own failures, so the tree itself is
|
|
223
|
+
// the only reliable signal: anything still uncommitted here predates every
|
|
224
|
+
// step's gitRefBefore and rules out clean retries for the whole run. A
|
|
225
|
+
// failed probe counts as dirty: mistaking it for clean would let a later
|
|
226
|
+
// retry-clean reset destroy the very work this flag exists to protect.
|
|
227
|
+
const checkpointFailed = createCommits && (0, git_utils_1.getWorkingTreeStatus)(root) !== 'clean';
|
|
228
|
+
const branch = (0, git_utils_1.getGitCurrentBranch)(root);
|
|
229
|
+
const state = {
|
|
230
|
+
formatVersion: run_state_1.CURRENT_RUN_STATE_FORMAT_VERSION,
|
|
231
|
+
runId,
|
|
232
|
+
createdAt: (0, util_1.nowIso)(),
|
|
233
|
+
nxVersion: versions_1.nxVersion,
|
|
234
|
+
status: 'active',
|
|
235
|
+
createCommits,
|
|
236
|
+
commitPrefix,
|
|
237
|
+
...(skipInstall ? { skipInstall: true } : {}),
|
|
238
|
+
validate: validate !== false,
|
|
239
|
+
...(gitRefAtInit ? { gitRefAtInit } : {}),
|
|
240
|
+
runbookPath: runbook_1.RUNBOOK_FILE_NAME,
|
|
241
|
+
...(branch ? { branch } : {}),
|
|
242
|
+
rounds: [
|
|
243
|
+
{
|
|
244
|
+
index: 0,
|
|
245
|
+
planSnapshot: PLAN_SNAPSHOT_0,
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
steps: buildSteps(sorted, finalValidation !== false),
|
|
249
|
+
commits: checkpoint ? [checkpoint] : [],
|
|
250
|
+
...(checkpointFailed ? { checkpointFailed: true } : {}),
|
|
251
|
+
analytics: { startEmitted: false, completeEmitted: false },
|
|
252
|
+
};
|
|
253
|
+
(0, state_lock_1.withRunCreationLock)(root, () => {
|
|
254
|
+
// The runbook gets the snapshot's crash guarantee: a discoverable run
|
|
255
|
+
// always has the runbook a resume re-emits from disk. 'wx' creates
|
|
256
|
+
// without following links, so nothing pre-planted at the path can
|
|
257
|
+
// redirect it.
|
|
258
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(dir, runbook_1.RUNBOOK_FILE_NAME), (0, runbook_1.renderRunbook)(runbookContext(root, runId, state)), { flag: 'wx' });
|
|
259
|
+
(0, run_state_1.createRun)(root, state);
|
|
260
|
+
});
|
|
261
|
+
return finishInit(root, dir, runId, state, 'created', emitAgentInstructions);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Continues the active run `runId` names: the `--run-migrations --run-id`
|
|
265
|
+
* shape on both paths. Refuses as holdRunToContinue does.
|
|
266
|
+
*/
|
|
267
|
+
function runOrchestratorResume(input) {
|
|
268
|
+
const { root, runId, policy, emitAgentInstructions = true } = input;
|
|
269
|
+
const state = holdRunToContinue(root, runId);
|
|
270
|
+
return resumeRun(root, runId, state, policy, emitAgentInstructions);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Holds the active run `runId` names and returns its state. A continue calls
|
|
274
|
+
* this before the install and the agent selection: a concurrent start-fresh
|
|
275
|
+
* must not delete the run meanwhile. Throws when the id names no run or a
|
|
276
|
+
* finished one, and while another process holds the run: continuing would
|
|
277
|
+
* open a second session over a live one. Under WASM nothing is held and no
|
|
278
|
+
* holder refuses.
|
|
279
|
+
*/
|
|
280
|
+
function holdRunToContinue(root, runId) {
|
|
281
|
+
if (!run_id_1.RUN_ID_SAFE.test(runId)) {
|
|
282
|
+
throw new Error(`Invalid run id '${runId}'.`);
|
|
283
|
+
}
|
|
284
|
+
const dir = (0, run_state_1.runDir)(root, runId);
|
|
285
|
+
if (!(0, run_state_1.hasRunState)(dir)) {
|
|
286
|
+
throw new Error(`No migrate run '${runId}' was found under ${types_1.MIGRATE_RUNS_RELATIVE_DIR}.`);
|
|
287
|
+
}
|
|
288
|
+
const state = (0, run_state_1.readRunState)(dir);
|
|
289
|
+
if (state.status !== 'active') {
|
|
290
|
+
throw new Error(`Migrate run '${runId}' is already complete; there is nothing to continue.`);
|
|
291
|
+
}
|
|
292
|
+
(0, state_lock_1.holdRunActivity)(root, runId, true);
|
|
293
|
+
return state;
|
|
294
|
+
}
|
|
295
|
+
// The active run a start-fresh naming `runId` finds, read-only: init's first
|
|
296
|
+
// check, which the CLI also runs before the install. None refuses, since a
|
|
297
|
+
// completed run means the plan already ran. A different active run is returned
|
|
298
|
+
// too: init reports it instead of deleting it.
|
|
299
|
+
function activeRunToReplace(root, runId) {
|
|
300
|
+
if (runId !== undefined && !run_id_1.RUN_ID_SAFE.test(runId)) {
|
|
301
|
+
throw new Error(`Invalid run id '${runId}'.`);
|
|
302
|
+
}
|
|
303
|
+
const active = findActiveRunForInit(root, true);
|
|
304
|
+
if (!active) {
|
|
305
|
+
throw new Error(noActiveRunToReplace(runId));
|
|
306
|
+
}
|
|
307
|
+
return active;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Drops the hold holdRunToContinue took, for a wrapper that hands the
|
|
311
|
+
* continue to the workspace-local nx: the child takes its own hold, and an
|
|
312
|
+
* exclusive one refuses while this process still holds.
|
|
313
|
+
*/
|
|
314
|
+
function releaseRunToHandOff(root, runId) {
|
|
315
|
+
(0, state_lock_1.releaseRunActivity)((0, run_state_1.runDir)(root, runId));
|
|
316
|
+
}
|
|
317
|
+
// Reads the newest active run; null when no run is active. Uninterpretable
|
|
318
|
+
// run dirs refuse a fresh start (one of them could be an active run this
|
|
319
|
+
// init would compete with) but only warn when a healthy active run is found,
|
|
320
|
+
// unless `refuseUninterpretable`: a start-fresh would delete that run and
|
|
321
|
+
// then find only the unreadable ones. NewerRunStateFormatError propagates
|
|
322
|
+
// from the read.
|
|
323
|
+
function findActiveRunForInit(root, refuseUninterpretable = false) {
|
|
324
|
+
const { active, uninterpretable } = (0, run_state_1.findActiveRun)(root);
|
|
325
|
+
if (uninterpretable.length > 0) {
|
|
326
|
+
const noun = uninterpretable.length === 1 ? 'directory' : 'directories';
|
|
327
|
+
// A directory name is whatever is on disk and a reason quotes what it
|
|
328
|
+
// found, so neither can be trusted to stay on the line it is put on.
|
|
329
|
+
// Sanitized here rather than left to the gateway: these same lines are
|
|
330
|
+
// joined into the throw below, which leaves through handleErrors.
|
|
331
|
+
const details = uninterpretable.map((u) => `${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${(0, text_1.singleLine)(u.dirName)}: ${(0, text_1.singleLine)(u.reason)}`);
|
|
332
|
+
if (!active || refuseUninterpretable) {
|
|
333
|
+
throw new Error([
|
|
334
|
+
`Whether a migrate run is still active could not be determined; starting a new run could re-apply migrations an unfinished run already applied.`,
|
|
335
|
+
...details,
|
|
336
|
+
`Fix or remove the listed ${noun}, then re-run the command.`,
|
|
337
|
+
].join('\n'));
|
|
338
|
+
}
|
|
339
|
+
(0, agent_output_1.warnToAgent)({
|
|
340
|
+
title: `Ignoring ${uninterpretable.length} migrate run ${noun} that could not be read.`,
|
|
341
|
+
bodyLines: details,
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
return active;
|
|
345
|
+
}
|
|
346
|
+
// A run directory without run.json but with a live activity lock is an init
|
|
347
|
+
// between reserving the directory and writing run.json: the checkpoint commit
|
|
348
|
+
// is in flight and no run may start alongside it. Refused at once, never
|
|
349
|
+
// waited for: a git hook re-entering nx migrate during that commit would
|
|
350
|
+
// otherwise wait on the process waiting for the hook. An unlocked one is the
|
|
351
|
+
// remains of an init that died, which discovery ignores like any other
|
|
352
|
+
// directory without run.json. Call under the creation lock.
|
|
353
|
+
function refuseLiveReservation(root) {
|
|
354
|
+
for (const entry of (0, fs_1.readdirSync)((0, run_state_1.migrateRunsDir)(root), {
|
|
355
|
+
withFileTypes: true,
|
|
356
|
+
})) {
|
|
357
|
+
if (!entry.isDirectory())
|
|
358
|
+
continue;
|
|
359
|
+
const dir = (0, path_1.join)((0, run_state_1.migrateRunsDir)(root), entry.name);
|
|
360
|
+
if ((0, run_state_1.hasRunState)(dir) || !(0, state_lock_1.hasAnyLiveRunActivity)(dir))
|
|
361
|
+
continue;
|
|
362
|
+
throw new Error(`Another nx migrate process is starting a run (${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${(0, text_1.singleLine)(entry.name)}). Wait for it to finish, then re-run the command.`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
// The report for an init that found a run already active. On the agent path
|
|
366
|
+
// the report and both ways forward go to stdout, in a block of its own kind:
|
|
367
|
+
// an `error` block would read as a crash, and this is a decision for the
|
|
368
|
+
// user. Held before the facts are read: a concurrent start-fresh must not
|
|
369
|
+
// delete the run under the report or the prompt after it.
|
|
370
|
+
function reportExistingRun(root, runId, state, plannedIds, migrationsPath, emitAgentInstructions, replaceRunId) {
|
|
371
|
+
(0, state_lock_1.holdRunActivity)(root, runId);
|
|
372
|
+
const facts = (0, existing_run_report_1.collectExistingRunFacts)(root, runId, state, plannedIds);
|
|
373
|
+
if (replaceRunId !== undefined) {
|
|
374
|
+
facts.replacedRunId = replaceRunId;
|
|
375
|
+
}
|
|
376
|
+
(0, migrate_analytics_1.reportMigrateOrchestratorExistingRun)({
|
|
377
|
+
...(0, state_machine_1.runTallies)(state),
|
|
378
|
+
activity: facts.otherHolders === 'unknown'
|
|
379
|
+
? 'unknown'
|
|
380
|
+
: facts.otherHolders.length > 0
|
|
381
|
+
? 'held'
|
|
382
|
+
: 'idle',
|
|
383
|
+
});
|
|
384
|
+
if (emitAgentInstructions) {
|
|
385
|
+
const report = (0, existing_run_report_1.renderExistingRunReport)(facts, (0, existing_run_report_1.renderExistingRunCommands)(root, facts, migrationsPath));
|
|
386
|
+
(0, agent_output_1.logToAgent)(report);
|
|
387
|
+
const lines = (0, agent_output_1.safeLines)([
|
|
388
|
+
report.title,
|
|
389
|
+
...report.bodyLines,
|
|
390
|
+
``,
|
|
391
|
+
`No migration step ran in this response. Show this report to the user and let them choose; run neither command until they do.`,
|
|
392
|
+
]);
|
|
393
|
+
(0, agent_output_1.emitStepBlock)(runId, '-', 'existing-run', {
|
|
394
|
+
instructions: lines.join('\n'),
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
return { kind: 'existing-run', runId, facts };
|
|
398
|
+
}
|
|
399
|
+
// Throws when the run's record must not be deleted: a worker the run
|
|
400
|
+
// dispensed or another nx migrate process is still acting on it, or another
|
|
401
|
+
// run is active alongside it and would be reported in place of the
|
|
402
|
+
// replacement. `state` is the run state the worker check reads.
|
|
403
|
+
function refuseUndeletableRun(root, runId, state) {
|
|
404
|
+
if (native_1.IS_WASM) {
|
|
405
|
+
throw new Error(`Not deleting migrate run '${runId}': without a native file lock nx cannot tell whether another nx migrate process is acting on it. Make sure none is, remove ${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runId}, then re-run the command.`);
|
|
406
|
+
}
|
|
407
|
+
const holders = (0, state_lock_1.liveRunActivityPids)((0, run_state_1.runDir)(root, runId));
|
|
408
|
+
if (holders === 'unknown' || holders.length > 0) {
|
|
409
|
+
throw (0, state_lock_1.heldRunError)('deleting', runId, holders);
|
|
410
|
+
}
|
|
411
|
+
const workers = (0, existing_run_report_1.liveWorkers)(state);
|
|
412
|
+
if (workers.length > 0) {
|
|
413
|
+
throw new Error(`Not deleting migrate run '${runId}': ${(0, existing_run_report_1.workersLine)(workers)}. ` +
|
|
414
|
+
`Wait for it to finish, then re-run the command. If that pid is not an nx migrate worker, stop it or remove ${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runId}, then re-run the command.`);
|
|
415
|
+
}
|
|
416
|
+
const others = (0, run_state_1.findActiveRun)(root).activeRunIds.filter((id) => id !== runId);
|
|
417
|
+
if (others.length > 0) {
|
|
418
|
+
throw new Error(`Not deleting migrate run '${runId}': other migrate runs are active on disk (${others.join(', ')}), and a new run cannot start alongside them. Remove ${types_1.MIGRATE_RUNS_RELATIVE_DIR}/<run id> for each one that should not be continued, then re-run the command.`);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
function noActiveRunToReplace(runId) {
|
|
422
|
+
return `Not starting fresh: ${runId === undefined ? 'no migrate run' : `no migrate run '${runId}'`} is active, so there is nothing to replace. To start a run, re-run the command without --start-fresh and --run-id.`;
|
|
423
|
+
}
|
|
424
|
+
// Removes run.json under the state lock, so no reconcile or worker can start
|
|
425
|
+
// against a directory about to disappear. The refusals run again on fresh
|
|
426
|
+
// state: the early pass predates the prompt. False when already gone.
|
|
427
|
+
function deleteRunRecord(root, runId) {
|
|
428
|
+
const dir = (0, run_state_1.runDir)(root, runId);
|
|
429
|
+
return (0, state_lock_1.withRunStateLock)(dir, () => {
|
|
430
|
+
if (!(0, run_state_1.hasRunState)(dir))
|
|
431
|
+
return false;
|
|
432
|
+
refuseUndeletableRun(root, runId, (0, run_state_1.readRunState)(dir));
|
|
433
|
+
// The hold's lock file is inside the directory removeDeletedRunDir removes.
|
|
434
|
+
(0, state_lock_1.releaseRunActivity)(dir);
|
|
435
|
+
(0, fs_1.rmSync)((0, path_1.join)(dir, run_state_1.RUN_STATE_FILE_NAME), { force: true });
|
|
436
|
+
return true;
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
// The rest of a deleted run's directory, removed outside the locks and best
|
|
440
|
+
// effort: what is left holds no run.
|
|
441
|
+
function removeDeletedRunDir(root, runId) {
|
|
442
|
+
try {
|
|
443
|
+
(0, fs_1.rmSync)((0, run_state_1.runDir)(root, runId), { recursive: true, force: true });
|
|
444
|
+
}
|
|
445
|
+
catch (e) {
|
|
446
|
+
(0, agent_output_1.warnToAgent)({
|
|
447
|
+
title: `Could not remove the rest of ${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runId}: ${(0, util_1.summarizeError)(e)}. It no longer holds a run; remove it when convenient.`,
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
(0, agent_output_1.logToAgent)({ title: `Deleted the record of migrate run ${runId}.` });
|
|
451
|
+
}
|
|
452
|
+
// The continue tail behind runOrchestratorResume: the runbook, checkpoint and
|
|
453
|
+
// analytics steps a paused run needs before it can be driven again.
|
|
454
|
+
function resumeRun(root, runId, state, policy, emitAgentInstructions) {
|
|
455
|
+
// Refused before the checkpoint retry below, which commits.
|
|
456
|
+
if (state.createCommits !== policy.createCommits ||
|
|
457
|
+
(state.skipInstall === true) !== policy.skipInstall) {
|
|
458
|
+
throw new Error(`Nx did not resume the active migrate run because its recorded install and commit policy differs from this invocation's. ` +
|
|
459
|
+
`Nx takes that policy from --create-commits and --skip-install on the command line. ` +
|
|
460
|
+
`Re-run with the flags run '${runId}' recorded (its report shows them). To start fresh, re-run with --start-fresh --run-id=${runId}, keeping the same --run-migrations[=<path>] argument used to start the run.`);
|
|
461
|
+
}
|
|
462
|
+
const dir = (0, run_state_1.runDir)(root, runId);
|
|
463
|
+
// Ignore/index state can change while a durable run is paused (a checkout,
|
|
464
|
+
// a .gitignore edit, a forced add). Probe before the checkpoint retry:
|
|
465
|
+
// ensureCheckpoint is a `git add -A` commit, so on a workspace that became
|
|
466
|
+
// unsafe it would absorb the run's own scratch.
|
|
467
|
+
if (state.createCommits) {
|
|
468
|
+
assertScratchDirSafeForCommits(root, continueRunHint(runId));
|
|
469
|
+
}
|
|
470
|
+
// Read, repair, or refuse the runbook before the checkpoint retry and the
|
|
471
|
+
// analytics watermark: an invocation that cannot provide the run's
|
|
472
|
+
// contract must not first change git history or durable run state.
|
|
473
|
+
const runbook = ensureRunbook(root, dir, runId, state);
|
|
474
|
+
if (runbook === null) {
|
|
475
|
+
return { kind: 'refused' };
|
|
476
|
+
}
|
|
477
|
+
// A run flagged checkpointFailed gets one more chance to capture the
|
|
478
|
+
// pre-existing tree state before its first migration commit absorbs it.
|
|
479
|
+
const resumed = ensureCheckpoint(root, dir, state);
|
|
480
|
+
announceResume(runId, resumed);
|
|
481
|
+
return finishInit(root, dir, runId, resumed, 'resumed', emitAgentInstructions, runbook);
|
|
482
|
+
}
|
|
483
|
+
function announceResume(runId, state) {
|
|
484
|
+
(0, agent_output_1.logToAgent)({
|
|
485
|
+
title: `nx migrate: resuming run ${runId}`,
|
|
486
|
+
bodyLines: [
|
|
487
|
+
` started: ${state.createdAt}`,
|
|
488
|
+
` progress: ${(0, existing_run_report_1.progressLine)((0, state_machine_1.tallySteps)(state))}`,
|
|
489
|
+
],
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
// Resume-only checkpoint retry, gated on checkpointFailed: a fresh init always
|
|
493
|
+
// evaluates the checkpoint before run.json exists, so an unflagged run
|
|
494
|
+
// without a checkpoint entry started from a clean tree and there is nothing to
|
|
495
|
+
// capture (retrying there would commit the run's own scratch instead). Skipped
|
|
496
|
+
// once any step has advanced (a late checkpoint would absorb an already-run
|
|
497
|
+
// migration's changes, or the parked validation pass's in-flight edits).
|
|
498
|
+
function ensureCheckpoint(root, dir, state) {
|
|
499
|
+
if (!state.createCommits || !state.checkpointFailed)
|
|
500
|
+
return state;
|
|
501
|
+
if (state.steps.some((s) => s.status !== 'pending'))
|
|
502
|
+
return state;
|
|
503
|
+
// Reserved so no step is dispensed into the tree the checkpoint captures;
|
|
504
|
+
// a run that moved on since the snapshot has nothing left to capture.
|
|
505
|
+
let lease;
|
|
506
|
+
try {
|
|
507
|
+
lease = (0, broker_1.acquireTreeOperation)(dir, { kind: 'checkpoint' });
|
|
508
|
+
}
|
|
509
|
+
catch (e) {
|
|
510
|
+
if (e instanceof broker_1.BrokerStaleRequestError)
|
|
511
|
+
return state;
|
|
512
|
+
throw e;
|
|
513
|
+
}
|
|
514
|
+
try {
|
|
515
|
+
// The checkpoint commit is a git side effect, so it runs before the lock;
|
|
516
|
+
// the ledger append and flag clear then apply to the fresh on-disk state.
|
|
517
|
+
const checkpoint = checkpointEntry(root, state.commitPrefix, (0, git_utils_1.getLatestCommitSha)(root));
|
|
518
|
+
// The retried checkpoint captured everything, so clean retries are safe
|
|
519
|
+
// again. Only a verified-clean tree clears the flag: a failed probe proves
|
|
520
|
+
// nothing was captured.
|
|
521
|
+
const cleared = (0, git_utils_1.getWorkingTreeStatus)(root) === 'clean';
|
|
522
|
+
if (!checkpoint && !cleared)
|
|
523
|
+
return state;
|
|
524
|
+
return (0, state_lock_1.updateRunState)(dir, (fresh) => {
|
|
525
|
+
// Re-check both guards on the fresh state: a concurrent reconcile may
|
|
526
|
+
// have cleared the flag or advanced a step while the commit ran.
|
|
527
|
+
// Skipping here can leave that commit unledgered, the documented
|
|
528
|
+
// crash-window shape.
|
|
529
|
+
if (!fresh.checkpointFailed ||
|
|
530
|
+
fresh.steps.some((s) => s.status !== 'pending')) {
|
|
531
|
+
return null;
|
|
532
|
+
}
|
|
533
|
+
// gitRefAtInit stays: no step has moved HEAD since init, so the late
|
|
534
|
+
// checkpoint sits right after it and inside the whole-run diff.
|
|
535
|
+
const next = checkpoint ? (0, state_machine_1.appendCommit)(fresh, checkpoint) : fresh;
|
|
536
|
+
return cleared ? { ...next, checkpointFailed: false } : next;
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
finally {
|
|
540
|
+
lease.release();
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
// Commits pre-existing working-tree state so the first migration's commit can't
|
|
544
|
+
// absorb it, returning the ledger entry only when a commit verifiably landed
|
|
545
|
+
// past `before`, the HEAD the caller read. A clean tree is a no-op. Failure
|
|
546
|
+
// detection is the caller's job: the commit helper swallows failures, so
|
|
547
|
+
// callers re-check the tree afterwards.
|
|
548
|
+
function checkpointEntry(root, commitPrefix, before) {
|
|
549
|
+
// Skip only on a verified-clean tree; on a failed probe the commit attempt
|
|
550
|
+
// below re-probes and may succeed once the transient failure passes.
|
|
551
|
+
if ((0, git_utils_1.getWorkingTreeStatus)(root) === 'clean') {
|
|
552
|
+
return null;
|
|
553
|
+
}
|
|
554
|
+
(0, migrate_commits_1.commitCheckpointBeforeMigrations)(root, commitPrefix);
|
|
555
|
+
const after = (0, git_utils_1.getLatestCommitSha)(root);
|
|
556
|
+
if (after && after !== before) {
|
|
557
|
+
return { kind: 'checkpoint', sha: after, stepIds: [] };
|
|
558
|
+
}
|
|
559
|
+
return null;
|
|
560
|
+
}
|
|
561
|
+
// No migration step is dispensed here: the agent reads the runbook first and
|
|
562
|
+
// asks for the run's current step by reconciling, so the contract always lands
|
|
563
|
+
// before the first command does.
|
|
564
|
+
function finishInit(root, dir, runId, state, origin, emitAgentInstructions,
|
|
565
|
+
// The runbook bytes when the caller already ensured them (the resume path,
|
|
566
|
+
// which must fail before its git and state side effects).
|
|
567
|
+
runbook) {
|
|
568
|
+
let current = state;
|
|
569
|
+
if (!current.analytics.startEmitted) {
|
|
570
|
+
// Claim the watermark on the fresh state first: of two concurrent inits
|
|
571
|
+
// exactly one flips it, and only that one reports.
|
|
572
|
+
let claimed = false;
|
|
573
|
+
current = (0, state_lock_1.updateRunState)(dir, (fresh) => {
|
|
574
|
+
if (fresh.analytics.startEmitted)
|
|
575
|
+
return null;
|
|
576
|
+
claimed = true;
|
|
577
|
+
return {
|
|
578
|
+
...fresh,
|
|
579
|
+
analytics: { ...fresh.analytics, startEmitted: true },
|
|
580
|
+
};
|
|
581
|
+
});
|
|
582
|
+
if (claimed) {
|
|
583
|
+
(0, migrate_analytics_1.reportMigrateOrchestratorInit)({
|
|
584
|
+
// The pass is a step, not a migration.
|
|
585
|
+
migrationCount: current.steps.filter((s) => s.kind === 'migration')
|
|
586
|
+
.length,
|
|
587
|
+
createCommits: current.createCommits,
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
if (origin === 'resumed') {
|
|
592
|
+
(0, migrate_analytics_1.reportMigrateOrchestratorResume)((0, state_machine_1.runTallies)(current));
|
|
593
|
+
}
|
|
594
|
+
const content = runbook ?? ensureRunbook(root, dir, runId, current);
|
|
595
|
+
if (content === null) {
|
|
596
|
+
return { kind: 'refused' };
|
|
597
|
+
}
|
|
598
|
+
const ready = {
|
|
599
|
+
kind: 'ready',
|
|
600
|
+
runId,
|
|
601
|
+
runRoot: root,
|
|
602
|
+
runbookPath: (0, path_1.join)(dir, current.runbookPath ?? runbook_1.RUNBOOK_FILE_NAME),
|
|
603
|
+
reconcileCommand: reconcileCommand(root, runId),
|
|
604
|
+
};
|
|
605
|
+
if (!emitAgentInstructions) {
|
|
606
|
+
return ready;
|
|
607
|
+
}
|
|
608
|
+
(0, agent_output_1.emitRunbookBlock)(runId, content);
|
|
609
|
+
const instructionLines = [
|
|
610
|
+
`Nx ${origin} migrate run ${runId}. No migration step ran in this response.`,
|
|
611
|
+
`Read the runbook above; it is the contract for driving this run. Then run the "next" command to get the run's current step.`,
|
|
612
|
+
...runbookFooterLines(root, runId),
|
|
613
|
+
];
|
|
614
|
+
const lines = (0, agent_output_1.safeLines)(instructionLines);
|
|
615
|
+
(0, agent_output_1.logToAgent)({ title: `nx migrate: run ${origin}`, bodyLines: lines });
|
|
616
|
+
(0, agent_output_1.emitStepBlock)(runId, '-', 'initialized', {
|
|
617
|
+
next: ready.reconcileCommand,
|
|
618
|
+
instructions: lines.join('\n'),
|
|
619
|
+
});
|
|
620
|
+
return ready;
|
|
621
|
+
}
|
|
622
|
+
// A missing runbook is re-rendered only by the nx version that created the
|
|
623
|
+
// run: its content is version-locked, and a different nx re-rendering it would
|
|
624
|
+
// silently hand the agent a contract the run was not created under. Returns
|
|
625
|
+
// null after emitting the exit-0 refusal instead.
|
|
626
|
+
function ensureRunbook(root, dir, runId, state) {
|
|
627
|
+
const filePath = (0, path_1.join)(dir, state.runbookPath ?? runbook_1.RUNBOOK_FILE_NAME);
|
|
628
|
+
const stat = lstatRunbook(filePath);
|
|
629
|
+
if (stat?.isFile()) {
|
|
630
|
+
// The read is the proof the entry is usable: read errors (an unreadable
|
|
631
|
+
// mode, an I/O failure) propagate rather than letting an unreadable
|
|
632
|
+
// runbook pass the guard.
|
|
633
|
+
return (0, handoff_1.readInspectedFile)(filePath, stat, `${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runId}/${runbook_1.RUNBOOK_FILE_NAME} was replaced while being read; ${continueRunHint(runId)}`);
|
|
634
|
+
}
|
|
635
|
+
if (stat) {
|
|
636
|
+
// A directory here is a corrupted run dir; erasing its contents as a side
|
|
637
|
+
// effect of a reconcile is not this code's call to make.
|
|
638
|
+
if (stat.isDirectory()) {
|
|
639
|
+
throw new Error(`${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runId}/${runbook_1.RUNBOOK_FILE_NAME} is a directory, not the runbook file nx wrote there. Remove it, then ${continueRunHint(runId)}`);
|
|
640
|
+
}
|
|
641
|
+
// Any other non-regular entry (a symlink most likely) is cleared before the
|
|
642
|
+
// rename publish below: POSIX rename replaces it in place, but not every
|
|
643
|
+
// platform guarantees that, and a removal failure must propagate rather
|
|
644
|
+
// than leave the entry standing.
|
|
645
|
+
(0, fs_1.rmSync)(filePath, { force: true });
|
|
646
|
+
}
|
|
647
|
+
if (state.nxVersion !== versions_1.nxVersion) {
|
|
648
|
+
const reason = [
|
|
649
|
+
`The runbook for run '${runId}' is missing from ${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runId}, and this nx (${versions_1.nxVersion}) cannot re-render the one nx ${(0, text_1.singleLine)(state.nxVersion)} wrote.`,
|
|
650
|
+
`Restore the file (or, if the run was created before runbooks existed, re-run with the nx version that created it). To start fresh, re-run with --start-fresh --run-id=${runId}, keeping the same --run-migrations[=<path>] argument used to start the run.`,
|
|
651
|
+
];
|
|
652
|
+
(0, agent_output_1.warnToAgent)({ title: reason[0], bodyLines: [reason[1]] });
|
|
653
|
+
(0, agent_output_1.emitStepBlock)(runId, '-', 'error', {
|
|
654
|
+
instructions: reason.join('\n'),
|
|
655
|
+
});
|
|
656
|
+
return null;
|
|
657
|
+
}
|
|
658
|
+
const content = (0, runbook_1.renderRunbook)(runbookContext(root, runId, state));
|
|
659
|
+
// A crashed repair leaves the path missing rather than truncated. 'wx'
|
|
660
|
+
// creates without following links, so anything planted at the temp name
|
|
661
|
+
// fails the repair instead of redirecting it.
|
|
662
|
+
(0, atomic_write_1.publishFileAtomically)(filePath, (tmpPath) => (0, fs_1.writeFileSync)(tmpPath, content, { flag: 'wx' }));
|
|
663
|
+
(0, state_lock_1.updateRunState)(dir, (fresh) => fresh.runbookPath ? null : { ...fresh, runbookPath: runbook_1.RUNBOOK_FILE_NAME });
|
|
664
|
+
(0, agent_output_1.warnToAgent)({
|
|
665
|
+
title: `The runbook for run '${runId}' was missing; it has been re-rendered.`,
|
|
666
|
+
});
|
|
667
|
+
return content;
|
|
668
|
+
}
|
|
669
|
+
// lstat that treats only a missing entry as null; other inspection failures
|
|
670
|
+
// (permissions, I/O) propagate rather than masquerading as "missing". Bigint
|
|
671
|
+
// stats so the inode identity compared above cannot lose precision.
|
|
672
|
+
function lstatRunbook(filePath) {
|
|
673
|
+
try {
|
|
674
|
+
return (0, fs_1.lstatSync)(filePath, { bigint: true });
|
|
675
|
+
}
|
|
676
|
+
catch (e) {
|
|
677
|
+
if (e?.code === 'ENOENT') {
|
|
678
|
+
return null;
|
|
679
|
+
}
|
|
680
|
+
throw e;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
function runbookContext(root, runId, state) {
|
|
684
|
+
return {
|
|
685
|
+
runId,
|
|
686
|
+
packageManager: (0, package_manager_1.detectPackageManager)(root),
|
|
687
|
+
nxInvocation: `${(0, util_1.pmExecPrefix)(root)} nx`,
|
|
688
|
+
pmExec: (0, util_1.pmExecPrefix)(root),
|
|
689
|
+
reconcileCommand: reconcileCommand(root, runId),
|
|
690
|
+
createCommits: state.createCommits,
|
|
691
|
+
// The same `!== false` read the flag itself gets, so a run recorded
|
|
692
|
+
// without the field renders validation on.
|
|
693
|
+
validate: state.validate !== false,
|
|
694
|
+
// The pass guidance follows the plan: an opted-out run, or one recorded
|
|
695
|
+
// before the pass existed, has no pass step to dispense.
|
|
696
|
+
finalValidation: state.steps.some((s) => s.kind === 'final-validation'),
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
// Only the newest recorded commit is checked, so the warning stops on its own
|
|
700
|
+
// once the next step commits on the new history; checking every ledger entry
|
|
701
|
+
// would repeat it on every reconcile after a rebase.
|
|
702
|
+
function warnIfHistoryRewound(root, runId, state) {
|
|
703
|
+
const commits = (0, existing_run_report_1.recordedCommits)(state);
|
|
704
|
+
const newest = commits[commits.length - 1]?.sha;
|
|
705
|
+
if (!newest)
|
|
706
|
+
return;
|
|
707
|
+
const head = (0, git_utils_1.getLatestCommitSha)(root);
|
|
708
|
+
if (!head || (0, git_utils_1.getAncestorStatus)(newest, head, root) !== 'not-ancestor') {
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
const facts = (0, existing_run_report_1.collectExistingRunFacts)(root, runId, state);
|
|
712
|
+
(0, agent_output_1.warnToAgent)({
|
|
713
|
+
title: `The newest commit migrate run ${runId} recorded is not reachable from HEAD. Continuing the run as asked.`,
|
|
714
|
+
bodyLines: (0, existing_run_report_1.renderExistingRunReport)(facts).bodyLines,
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
async function runOrchestratorReconcile(input) {
|
|
718
|
+
const { root, runId, stepAction } = input;
|
|
719
|
+
if (!run_id_1.RUN_ID_SAFE.test(runId)) {
|
|
720
|
+
throw new Error(`Invalid run id '${runId}'.`);
|
|
721
|
+
}
|
|
722
|
+
const dir = (0, run_state_1.runDir)(root, runId);
|
|
723
|
+
if (!(0, run_state_1.hasRunState)(dir)) {
|
|
724
|
+
// No remediation beyond the id: starting a run is a separate, gated entry
|
|
725
|
+
// point, so pointing at it here would hand most callers a command that
|
|
726
|
+
// does something else entirely.
|
|
727
|
+
throw new Error(`No migrate run '${runId}' was found under ${types_1.MIGRATE_RUNS_RELATIVE_DIR}.`);
|
|
728
|
+
}
|
|
729
|
+
(0, state_lock_1.holdRunActivity)(root, runId);
|
|
730
|
+
// Version refusal (NewerRunStateFormatError) propagates.
|
|
731
|
+
let state = (0, run_state_1.readRunState)(dir);
|
|
732
|
+
warnIfHistoryRewound(root, runId, state);
|
|
733
|
+
// Ignore/index state can change while a durable run is paused (a checkout,
|
|
734
|
+
// a .gitignore edit, a forced add); re-verify before foldHandoffs, which
|
|
735
|
+
// can itself commit a settled prompt step.
|
|
736
|
+
if (state.createCommits) {
|
|
737
|
+
assertScratchDirSafeForCommits(root, continueRunHint(runId));
|
|
738
|
+
}
|
|
739
|
+
// The runbook is the run's persisted contract; read, repair, or refuse it
|
|
740
|
+
// before any fold or dispense, so the run can never advance while the
|
|
741
|
+
// contract is unavailable. A completed run, and an active run whose steps are
|
|
742
|
+
// all terminal, are exempt: no work can advance, the only thing left is the
|
|
743
|
+
// self-contained terminal response, and hiding it behind a missing contract
|
|
744
|
+
// would leave the run active forever.
|
|
745
|
+
if (state.status !== 'completed' &&
|
|
746
|
+
firstActionableStep(state) !== undefined &&
|
|
747
|
+
ensureRunbook(root, dir, runId, state) === null) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
// (a) fold handoffs into prompt outcomes (committing completed ones).
|
|
751
|
+
state = await foldHandoffs(root, dir, state);
|
|
752
|
+
// (b) reclassify running steps whose worker process is gone.
|
|
753
|
+
state = detectDeaths(dir, state);
|
|
754
|
+
// (c) apply the decision relay to the single failed/died step.
|
|
755
|
+
if (stepAction) {
|
|
756
|
+
// Owns the tree reservation a clean retry's reset, an adopt's commit, a
|
|
757
|
+
// give-up or a skip's install takes, released once the transition that
|
|
758
|
+
// records it is written.
|
|
759
|
+
const scope = {};
|
|
760
|
+
try {
|
|
761
|
+
const result = await applyReconcileStepAction(root, dir, state, stepAction, scope);
|
|
762
|
+
if (result.kind === 'error') {
|
|
763
|
+
emitError(root, runId, result.reason);
|
|
764
|
+
return; // no transition was written
|
|
765
|
+
}
|
|
766
|
+
const target = result.targetStep;
|
|
767
|
+
// Unless a reset ran, give-up.ts commits the partial result under the
|
|
768
|
+
// migration's name and settles the step in one operation; a failed
|
|
769
|
+
// install or commit settles it with the debt recorded.
|
|
770
|
+
if (stepAction === 'unresolved' &&
|
|
771
|
+
state.createCommits &&
|
|
772
|
+
!result.resetTree) {
|
|
773
|
+
const outcome = await (0, broker_1.giveUpStepTree)(root, dir, target, state.skipInstall === true, reconcileCommand(root, runId), scope);
|
|
774
|
+
if (outcome.kind === 'refused') {
|
|
775
|
+
emitError(root, runId, outcome.reason);
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
(0, give_up_1.warnAboutGiveUp)(target, outcome);
|
|
779
|
+
// Settled already; the dispense refuses a tree still held.
|
|
780
|
+
scope.lease?.release();
|
|
781
|
+
scope.lease = undefined;
|
|
782
|
+
advanceAndDispense(root, dir, runId);
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
// The commit is a git side effect, so it runs before the lock (locked
|
|
786
|
+
// sections stay synchronous); the transition and any unrecorded entry then
|
|
787
|
+
// land in one write. Adopt and skip keep the tree, so the install they owe
|
|
788
|
+
// runs here: the next dispense would take the changed deps as its baseline.
|
|
789
|
+
// Giving up keeps it the same way when the run does not commit. Retries
|
|
790
|
+
// owe nothing: the rearmed attempt reconciles itself.
|
|
791
|
+
const { entry, installFailed, recorded } = await stepActionSideEffects(root, dir, state, target, stepAction, result.resetTree, scope);
|
|
792
|
+
// A rearm starts a fresh attempt; drop the stale handoff before the rearm
|
|
793
|
+
// is persisted so a crash in between can't refold the old outcome into the
|
|
794
|
+
// new attempt. Losing the handoff without the rearm is safe: the step is
|
|
795
|
+
// still failed/died and the agent re-issues the action.
|
|
796
|
+
if (stepAction === 'retry' || stepAction === 'retry-clean') {
|
|
797
|
+
removeHandoff(dir, target.id);
|
|
798
|
+
// A reset-backed retry reruns the generator, so payloads from earlier
|
|
799
|
+
// attempts describe a tree that was reset away. Hygiene only: the persisted
|
|
800
|
+
// generatorCompletedAtAttempt bound is the correctness gate.
|
|
801
|
+
if (stepAction === 'retry-clean' &&
|
|
802
|
+
result.state.steps.find((s) => s.id === target.id)
|
|
803
|
+
.generatorCompleted !== true) {
|
|
804
|
+
(0, agent_work_payload_1.removeAgentWorkPayloads)(dir, target.id, target.attempt);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
// Re-validate against fresh disk state so a concurrent reconcile's own
|
|
808
|
+
// rejection surfaces through emitError instead of being written over. The
|
|
809
|
+
// bound attempt keeps the snapshot checks above honest.
|
|
810
|
+
let freshRejection;
|
|
811
|
+
let unresolvedArchiveError;
|
|
812
|
+
const written = (0, state_lock_1.updateRunState)(dir, (fresh) => {
|
|
813
|
+
// A plain retry takes no reservation of its own, so this is where it
|
|
814
|
+
// learns that a live process still commits or installs for the step.
|
|
815
|
+
const held = (0, broker_1.liveTreeOperation)(fresh, scope.lease?.owner);
|
|
816
|
+
if (held) {
|
|
817
|
+
freshRejection = (0, broker_1.treeBusyMessage)(held);
|
|
818
|
+
return null;
|
|
819
|
+
}
|
|
820
|
+
// A plain retry's acceptance read the generator marker on the
|
|
821
|
+
// snapshot; a clean retry that started meanwhile forgets the marker
|
|
822
|
+
// without moving the attempt, so the attempt check cannot see it.
|
|
823
|
+
const freshStep = fresh.steps.find((s) => s.id === target.id);
|
|
824
|
+
if (stepAction === 'retry' &&
|
|
825
|
+
freshStep !== undefined &&
|
|
826
|
+
generatorPending(freshStep) !== generatorPending(target)) {
|
|
827
|
+
freshRejection = `Cannot apply action 'retry' to step '${target.id}': whether its generator ran changed since this reconcile read it. Run the reconcile again.`;
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
const reapplied = (0, state_machine_1.applyStepEvent)(fresh, {
|
|
831
|
+
type: 'stepAction',
|
|
832
|
+
stepId: target.id,
|
|
833
|
+
action: stepAction,
|
|
834
|
+
attempt: target.attempt,
|
|
835
|
+
});
|
|
836
|
+
if (reapplied.kind === 'error') {
|
|
837
|
+
freshRejection = reapplied.reason;
|
|
838
|
+
return null;
|
|
839
|
+
}
|
|
840
|
+
let settled = reapplied.state;
|
|
841
|
+
// The unresolved status and its issue are persisted together.
|
|
842
|
+
if (stepAction === 'unresolved') {
|
|
843
|
+
const recorded = (0, give_up_1.recordUnresolvedIssue)(dir, settled, target.id);
|
|
844
|
+
unresolvedArchiveError = recorded.archiveError;
|
|
845
|
+
settled = recorded.state;
|
|
846
|
+
}
|
|
847
|
+
const next = installFailed
|
|
848
|
+
? (0, state_machine_1.markInstallFailed)(settled, target.id)
|
|
849
|
+
: settled;
|
|
850
|
+
// An adopted commit absorbs uncovered failed steps the same way a fold
|
|
851
|
+
// commit does, so it carries their resolved issues too. A session's
|
|
852
|
+
// parent records its own commits as it answers.
|
|
853
|
+
return entry && !recorded
|
|
854
|
+
? (0, state_machine_1.appendCommit)(next, (0, issues_1.attachIssueIdsToCommitEntry)(next, entry))
|
|
855
|
+
: next;
|
|
856
|
+
});
|
|
857
|
+
if (freshRejection) {
|
|
858
|
+
emitError(root, runId, entry?.kind === 'landed' && entry.sha
|
|
859
|
+
? `${freshRejection} Note: this action's commit ${entry.sha} had already landed and stays in history; resolve the step against the tree as it stands now.`
|
|
860
|
+
: freshRejection);
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
if (unresolvedArchiveError !== undefined) {
|
|
864
|
+
(0, give_up_1.warnUnresolvedNotArchived)((0, state_machine_1.stepLabel)(target), unresolvedArchiveError);
|
|
865
|
+
}
|
|
866
|
+
state = written;
|
|
867
|
+
}
|
|
868
|
+
finally {
|
|
869
|
+
scope.lease?.release();
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
// (d) choose and emit the next dispense.
|
|
873
|
+
advanceAndDispense(root, dir, runId);
|
|
874
|
+
}
|
|
875
|
+
// The final validation pass has no generator half: a retry re-hands the pass
|
|
876
|
+
// over the tree it left.
|
|
877
|
+
function buildSteps(sortedMigrations, finalValidation) {
|
|
878
|
+
const migrations = sortedMigrations.map((m, index) => ({
|
|
879
|
+
id: `step-${index + 1}`,
|
|
880
|
+
roundIndex: 0,
|
|
881
|
+
kind: 'migration',
|
|
882
|
+
migrationId: `${m.package}:${m.name}`,
|
|
883
|
+
status: 'pending',
|
|
884
|
+
attempt: 1,
|
|
885
|
+
dispenseCount: 0,
|
|
886
|
+
hasGenerator: !(0, migration_shape_1.isPromptOnlyMigration)(m),
|
|
887
|
+
}));
|
|
888
|
+
if (!finalValidation)
|
|
889
|
+
return migrations;
|
|
890
|
+
return [
|
|
891
|
+
...migrations,
|
|
892
|
+
{
|
|
893
|
+
id: `step-${migrations.length + 1}`,
|
|
894
|
+
roundIndex: 0,
|
|
895
|
+
kind: 'final-validation',
|
|
896
|
+
status: 'pending',
|
|
897
|
+
attempt: 1,
|
|
898
|
+
dispenseCount: 0,
|
|
899
|
+
hasGenerator: false,
|
|
900
|
+
},
|
|
901
|
+
];
|
|
902
|
+
}
|
|
903
|
+
async function foldHandoffs(root, dir, state) {
|
|
904
|
+
let current = state;
|
|
905
|
+
// Step ids are fixed for the life of a run, so the ids come from the caller's
|
|
906
|
+
// snapshot while every status read comes from `current`: each iteration can
|
|
907
|
+
// have advanced the run.
|
|
908
|
+
for (const { id } of state.steps) {
|
|
909
|
+
const step = current.steps.find((s) => s.id === id);
|
|
910
|
+
if (step.status !== 'awaiting-prompt-outcome')
|
|
911
|
+
continue;
|
|
912
|
+
const result = readStepHandoff(dir, step.id);
|
|
913
|
+
if (!result.ok)
|
|
914
|
+
continue; // still awaiting; the dispense asks to settle it
|
|
915
|
+
let promptOutcome = handoffToPromptOutcome(result.handoff);
|
|
916
|
+
// A skipped handoff completes a step whose generator changed the tree.
|
|
917
|
+
// Prompt-only and no-op hybrid steps remain skipped so they cannot commit
|
|
918
|
+
// unrelated pending diffs.
|
|
919
|
+
if (generatorChangesApplied(step) && promptOutcome.status === 'skipped') {
|
|
920
|
+
promptOutcome = { ...promptOutcome, status: 'completed' };
|
|
921
|
+
}
|
|
922
|
+
// Archive under the lock before committing or marking the step terminal.
|
|
923
|
+
// Failure leaves the handoff retryable instead of landing an unrecorded
|
|
924
|
+
// commit or a ledger entry without detail; replayed archive writes are
|
|
925
|
+
// idempotent.
|
|
926
|
+
let ready = false;
|
|
927
|
+
let archiveError = null;
|
|
928
|
+
const reconstructedIssueIds = [];
|
|
929
|
+
(0, state_lock_1.withRunStateLock)(dir, () => {
|
|
930
|
+
const fresh = (0, run_state_1.readRunState)(dir);
|
|
931
|
+
const applied = (0, state_machine_1.applyStepEvent)(fresh, {
|
|
932
|
+
type: 'foldPromptOutcome',
|
|
933
|
+
stepId: step.id,
|
|
934
|
+
attempt: step.attempt,
|
|
935
|
+
promptOutcome,
|
|
936
|
+
});
|
|
937
|
+
if (applied.kind === 'error')
|
|
938
|
+
return;
|
|
939
|
+
// A corrupt receipt refuses the fold here, before the commit below
|
|
940
|
+
// could land unrecorded.
|
|
941
|
+
(0, state_machine_1.commitReceipt)(fresh, fresh.steps.find((s) => s.id === step.id));
|
|
942
|
+
const issues = (0, issues_1.parseHandoffIssues)(result.handoff.extras, fresh, step);
|
|
943
|
+
if (issues.ok !== true)
|
|
944
|
+
return;
|
|
945
|
+
try {
|
|
946
|
+
// The sink survives a throw: a shell rebuilt before the failure is
|
|
947
|
+
// durable and reads healthy on the retry, so only this pass can
|
|
948
|
+
// warn that its original detail is gone.
|
|
949
|
+
(0, issues_1.archiveIssues)(dir, (0, issues_1.applyReportedIssues)(applied.state, step, issues.issues, issues.updates), reconstructedIssueIds);
|
|
950
|
+
}
|
|
951
|
+
catch (e) {
|
|
952
|
+
archiveError = e;
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
ready = true;
|
|
956
|
+
});
|
|
957
|
+
(0, issues_1.warnReconstructedArchives)(reconstructedIssueIds);
|
|
958
|
+
if (archiveError !== null) {
|
|
959
|
+
(0, agent_output_1.warnToAgent)({
|
|
960
|
+
title: `The issue details reported by ${(0, state_machine_1.stepLabel)(step)} could not be archived (${(0, util_1.summarizeError)(archiveError)}).`,
|
|
961
|
+
bodyLines: [
|
|
962
|
+
`The step's outcome was not folded; fix the underlying problem, then run the reconcile again.`,
|
|
963
|
+
],
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
if (!ready)
|
|
967
|
+
continue;
|
|
968
|
+
// Phase 2: the commit and the install are side effects, so they run outside
|
|
969
|
+
// the lock; the transition, the issue application and any unrecorded ledger
|
|
970
|
+
// entry then land in one fresh-state write.
|
|
971
|
+
let folded = false;
|
|
972
|
+
let updateArchiveError = null;
|
|
973
|
+
let detailArchiveError = null;
|
|
974
|
+
let archivesDegraded = false;
|
|
975
|
+
const refoldReconstructedIds = [];
|
|
976
|
+
const scope = {};
|
|
977
|
+
try {
|
|
978
|
+
const { entry, installFailed, recorded } = await foldLedgerEntry(root, dir, current, step, promptOutcome, scope);
|
|
979
|
+
// Bound to the attempt this handoff was read for: the window is wide (a
|
|
980
|
+
// commit plus an install) and 'awaiting-prompt-outcome' recurs, so a
|
|
981
|
+
// concurrent retry could otherwise take this outcome as its own. Under the
|
|
982
|
+
// lock so the issue application re-archives on the state it lands on.
|
|
983
|
+
current = (0, state_lock_1.withRunStateLock)(dir, () => {
|
|
984
|
+
const fresh = (0, run_state_1.readRunState)(dir);
|
|
985
|
+
if ((0, broker_1.liveTreeOperation)(fresh, scope.lease?.owner))
|
|
986
|
+
return fresh;
|
|
987
|
+
const applied = (0, state_machine_1.applyStepEvent)(fresh, {
|
|
988
|
+
type: 'foldPromptOutcome',
|
|
989
|
+
stepId: step.id,
|
|
990
|
+
attempt: step.attempt,
|
|
991
|
+
promptOutcome,
|
|
992
|
+
});
|
|
993
|
+
if (applied.kind === 'error')
|
|
994
|
+
return fresh;
|
|
995
|
+
const issues = (0, issues_1.parseHandoffIssues)(result.handoff.extras, fresh, step);
|
|
996
|
+
if (issues.ok !== true)
|
|
997
|
+
return fresh;
|
|
998
|
+
// A commit this process ran takes the handoff's resolutions when it is
|
|
999
|
+
// appended below; otherwise the entry already recorded for this attempt
|
|
1000
|
+
// takes them, stamped at its index.
|
|
1001
|
+
const receipt = (0, state_machine_1.commitReceipt)(applied.state, applied.state.steps.find((s) => s.id === step.id));
|
|
1002
|
+
const carrier = entry && !recorded ? undefined : receipt;
|
|
1003
|
+
const application = (0, issues_1.applyReportedIssues)(applied.state, step, issues.issues, issues.updates, carrier?.index);
|
|
1004
|
+
try {
|
|
1005
|
+
// Phase 1 wrote these files, so a reconstruction here means one
|
|
1006
|
+
// vanished between the phases; the ids surface that loss. The sink
|
|
1007
|
+
// survives a throw, so a shell rebuilt before a later batch failed
|
|
1008
|
+
// still gets warned.
|
|
1009
|
+
(0, issues_1.archiveIssues)(dir, application, refoldReconstructedIds);
|
|
1010
|
+
}
|
|
1011
|
+
catch (e) {
|
|
1012
|
+
// A landed commit outranks the drop: refolding would re-attempt
|
|
1013
|
+
// its commit against a clean tree as no-changes and lose the entry
|
|
1014
|
+
// for good. Phase 1 already archived this handoff's records durably
|
|
1015
|
+
// once; the fold proceeds and the loss is warned.
|
|
1016
|
+
const intact = (0, issues_1.applicationArchivesIntact)(dir, application);
|
|
1017
|
+
if (entry?.kind !== 'landed' && intact !== true) {
|
|
1018
|
+
detailArchiveError = e;
|
|
1019
|
+
return fresh;
|
|
1020
|
+
}
|
|
1021
|
+
updateArchiveError = e;
|
|
1022
|
+
archivesDegraded = intact !== true;
|
|
1023
|
+
}
|
|
1024
|
+
folded = true;
|
|
1025
|
+
let next = installFailed
|
|
1026
|
+
? (0, state_machine_1.markInstallFailed)(application.state, step.id)
|
|
1027
|
+
: application.state;
|
|
1028
|
+
// A landed commit carries the fixes of every issue resolved by a step it
|
|
1029
|
+
// names, absorbed steps included.
|
|
1030
|
+
if (carrier)
|
|
1031
|
+
next = (0, issues_1.enrichCommitEntryIssueIds)(next, carrier.index);
|
|
1032
|
+
const written = entry && !recorded
|
|
1033
|
+
? (0, state_machine_1.appendCommit)(next, (0, issues_1.attachIssueIdsToCommitEntry)(next, entry))
|
|
1034
|
+
: next;
|
|
1035
|
+
(0, run_state_1.writeRunState)(dir, written);
|
|
1036
|
+
return written;
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
finally {
|
|
1040
|
+
scope.lease?.release();
|
|
1041
|
+
}
|
|
1042
|
+
// The written state still names the lease just released; the caller's
|
|
1043
|
+
// own reservation checks must not read it as another process's hold.
|
|
1044
|
+
if (scope.lease)
|
|
1045
|
+
current = (0, run_state_1.readRunState)(dir);
|
|
1046
|
+
(0, issues_1.warnReconstructedArchives)(refoldReconstructedIds);
|
|
1047
|
+
if (detailArchiveError !== null) {
|
|
1048
|
+
(0, agent_output_1.warnToAgent)({
|
|
1049
|
+
title: `The issue details reported by ${(0, state_machine_1.stepLabel)(step)} could not be archived (${(0, util_1.summarizeError)(detailArchiveError)}).`,
|
|
1050
|
+
bodyLines: [
|
|
1051
|
+
`The step's outcome was not folded; fix the underlying problem, then run the reconcile again.`,
|
|
1052
|
+
],
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
if (updateArchiveError !== null) {
|
|
1056
|
+
(0, agent_output_1.warnToAgent)(archivesDegraded
|
|
1057
|
+
? {
|
|
1058
|
+
title: `Some issue transition records for ${(0, state_machine_1.stepLabel)(step)} could not be archived (${(0, util_1.summarizeError)(updateArchiveError)}).`,
|
|
1059
|
+
bodyLines: [
|
|
1060
|
+
`run.json stays authoritative for the dispositions; the archived files under the run's issues directory are missing or incomplete for this fold's issues, and its landed commit takes precedence over retrying the archive.`,
|
|
1061
|
+
],
|
|
1062
|
+
}
|
|
1063
|
+
: {
|
|
1064
|
+
title: `Re-archiving the issue records for ${(0, state_machine_1.stepLabel)(step)} failed (${(0, util_1.summarizeError)(updateArchiveError)}).`,
|
|
1065
|
+
bodyLines: [
|
|
1066
|
+
`Nothing was lost: the fold's records were verified on disk and recorded in run.json. The failed write may point at a disk problem worth checking.`,
|
|
1067
|
+
],
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
// A rejected fold leaves the handoff in place: it belongs to whichever
|
|
1071
|
+
// attempt is on disk now, and that attempt's own reconcile still has to
|
|
1072
|
+
// read it. The stored agent-work payloads go with a terminal outcome; a
|
|
1073
|
+
// failed fold keeps them, since a retry re-hands the newest surviving copy.
|
|
1074
|
+
if (folded) {
|
|
1075
|
+
removeHandoff(dir, step.id);
|
|
1076
|
+
if (promptOutcome.status !== 'failed') {
|
|
1077
|
+
(0, agent_work_payload_1.removeAgentWorkPayloads)(dir, step.id, step.attempt);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
return current;
|
|
1082
|
+
}
|
|
1083
|
+
// What a folded prompt outcome owes the run state. Only a completed prompt
|
|
1084
|
+
// with commits on rides its install in on the commit path; every other
|
|
1085
|
+
// outcome installs here, or the next dispense takes the unreconciled
|
|
1086
|
+
// package.json edit as its own baseline. A tree that is not verifiably clean
|
|
1087
|
+
// records debt; a failed probe counts as dirty.
|
|
1088
|
+
async function foldLedgerEntry(root, dir, state, step, promptOutcome, scope) {
|
|
1089
|
+
if (promptOutcome.status === 'completed') {
|
|
1090
|
+
if (state.createCommits) {
|
|
1091
|
+
return commitForStep(root, dir, state, step, scope);
|
|
1092
|
+
}
|
|
1093
|
+
return {
|
|
1094
|
+
entry: null,
|
|
1095
|
+
installFailed: await installFailedForStep(root, dir, state, step, 'fold-install', scope),
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
return retainedTreeSideEffects(root, dir, state, step, 'fold-install', scope);
|
|
1099
|
+
}
|
|
1100
|
+
// Shared by prompts that did not complete and by skipped failed or died steps:
|
|
1101
|
+
// the tree is kept as it stands, so the step still owes the install of any
|
|
1102
|
+
// dependency edits it left and, with commits on, a debt record when the tree
|
|
1103
|
+
// is not verifiably clean (see foldLedgerEntry for why).
|
|
1104
|
+
async function retainedTreeSideEffects(root, dir, state, step, seam, scope) {
|
|
1105
|
+
const installFailed = await installFailedForStep(root, dir, state, step, seam, scope);
|
|
1106
|
+
const entry = state.createCommits && (0, git_utils_1.getWorkingTreeStatus)(root) !== 'clean'
|
|
1107
|
+
? { kind: 'failed', stepIds: [step.id] }
|
|
1108
|
+
: null;
|
|
1109
|
+
return { entry, installFailed };
|
|
1110
|
+
}
|
|
1111
|
+
// Installs the dependency changes a step's tree may carry when no commit path
|
|
1112
|
+
// will, returning whether the install failed. A failure is recorded rather
|
|
1113
|
+
// than thrown: reconcile still owes the agent a dispense. Broker errors do
|
|
1114
|
+
// throw, as in commitForStep: the next reconcile redoes the action.
|
|
1115
|
+
async function installFailedForStep(root, dir, state, step, seam, scope) {
|
|
1116
|
+
const skipInstall = state.skipInstall === true;
|
|
1117
|
+
try {
|
|
1118
|
+
await (0, broker_1.installStepTree)(dir, step, seam, () => (0, util_1.installDepsChangedSinceDispense)(root, dir, step, skipInstall, reconcileCommand(root, state.runId)), scope);
|
|
1119
|
+
return false;
|
|
1120
|
+
}
|
|
1121
|
+
catch (e) {
|
|
1122
|
+
if (e instanceof broker_1.BrokerStaleRequestError ||
|
|
1123
|
+
e instanceof broker_1.BrokerUnavailableError ||
|
|
1124
|
+
e instanceof broker_1.TreeBusyError) {
|
|
1125
|
+
throw e;
|
|
1126
|
+
}
|
|
1127
|
+
(0, agent_output_1.warnToAgent)({
|
|
1128
|
+
title: `The dependencies changed by ${(0, state_machine_1.stepLabel)(step)} could not be installed (${(0, util_1.summarizeError)(e)}).`,
|
|
1129
|
+
bodyLines: [`Run \`${(0, util_1.pmInstallCommand)(root)}\` before continuing.`],
|
|
1130
|
+
});
|
|
1131
|
+
return true;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
// A failed handoff fails the prompt; a success handoff completes it, unless it
|
|
1135
|
+
// marks the prompt not applicable via `extras.outcome === 'skipped'`.
|
|
1136
|
+
function handoffToPromptOutcome(handoff) {
|
|
1137
|
+
if (handoff.status === 'failed') {
|
|
1138
|
+
return { status: 'failed', summary: handoff.summary };
|
|
1139
|
+
}
|
|
1140
|
+
if (handoff.extras && handoff.extras['outcome'] === 'skipped') {
|
|
1141
|
+
return { status: 'skipped', summary: handoff.summary };
|
|
1142
|
+
}
|
|
1143
|
+
return { status: 'completed', summary: handoff.summary };
|
|
1144
|
+
}
|
|
1145
|
+
function detectDeaths(dir, state) {
|
|
1146
|
+
let current = state;
|
|
1147
|
+
// As in foldHandoffs: ids from the caller's snapshot, statuses from
|
|
1148
|
+
// `current`, so an earlier iteration's write is visible to the next.
|
|
1149
|
+
for (const { id } of state.steps) {
|
|
1150
|
+
const step = current.steps.find((s) => s.id === id);
|
|
1151
|
+
if (step.status !== 'running')
|
|
1152
|
+
continue;
|
|
1153
|
+
if (step.pid === undefined || (0, util_1.isPidAlive)(step.pid))
|
|
1154
|
+
continue;
|
|
1155
|
+
// markDied re-validates against fresh disk state, on the attempt and pid
|
|
1156
|
+
// this observation was made for: if the worker finished between the
|
|
1157
|
+
// snapshot and the write, or a retry already put a live worker on the
|
|
1158
|
+
// step, the transition is rejected and the step is left as recorded.
|
|
1159
|
+
current = (0, state_lock_1.updateRunState)(dir, (fresh) => {
|
|
1160
|
+
// A dead worker's commit or install may still be running in the
|
|
1161
|
+
// session's parent; the step stays running until that lands.
|
|
1162
|
+
if ((0, broker_1.liveTreeOperation)(fresh))
|
|
1163
|
+
return null;
|
|
1164
|
+
const applied = (0, state_machine_1.applyStepEvent)(fresh, {
|
|
1165
|
+
type: 'markDied',
|
|
1166
|
+
stepId: step.id,
|
|
1167
|
+
attempt: step.attempt,
|
|
1168
|
+
});
|
|
1169
|
+
return applied.kind === 'ok' ? applied.state : null;
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
return current;
|
|
1173
|
+
}
|
|
1174
|
+
async function applyReconcileStepAction(root, dir, state, action, scope) {
|
|
1175
|
+
const candidates = state.steps.filter((s) => s.status === 'failed' || s.status === 'died');
|
|
1176
|
+
if (candidates.length === 0) {
|
|
1177
|
+
return {
|
|
1178
|
+
kind: 'error',
|
|
1179
|
+
reason: `No step is failed or died, so there is nothing for --step-action=${action} to target.`,
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
if (candidates.length > 1) {
|
|
1183
|
+
return {
|
|
1184
|
+
kind: 'error',
|
|
1185
|
+
reason: `More than one step is failed or died; --step-action targets exactly one. Resolve them one at a time.`,
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
const step = candidates[0];
|
|
1189
|
+
const held = (0, broker_1.liveTreeOperation)(state);
|
|
1190
|
+
if (held) {
|
|
1191
|
+
return { kind: 'error', reason: (0, broker_1.treeBusyMessage)(held) };
|
|
1192
|
+
}
|
|
1193
|
+
if ((action === 'retry' || action === 'retry-clean') &&
|
|
1194
|
+
rearmCapReached(step)) {
|
|
1195
|
+
return {
|
|
1196
|
+
kind: 'error',
|
|
1197
|
+
reason: `Cannot apply action '${action}' to step '${step.id}': ${rearmCapLine(step, (0, state_machine_1.commitMayBeInHistory)(state, step))}`,
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
// A retry-clean the dispense would not have offered must be refused here
|
|
1201
|
+
// too, or a hand-crafted reconcile could reset a tree with no restore point
|
|
1202
|
+
// and destroy prior steps' work.
|
|
1203
|
+
if (action === 'retry-clean') {
|
|
1204
|
+
const head = (0, git_utils_1.getLatestCommitSha)(root);
|
|
1205
|
+
const fallback = `Use ${actionList([
|
|
1206
|
+
...(step.status === 'died' ? [] : ['retry']),
|
|
1207
|
+
'adopt',
|
|
1208
|
+
...((0, state_machine_1.commitMayBeInHistory)(state, step) ? [] : ['skip', 'unresolved']),
|
|
1209
|
+
])} instead.`;
|
|
1210
|
+
if (!(0, clean_retry_1.canOfferCleanRetry)(root, state, step, head)) {
|
|
1211
|
+
return {
|
|
1212
|
+
kind: 'error',
|
|
1213
|
+
reason: `Cannot apply action 'retry-clean' to step '${step.id}': ${(0, clean_retry_1.cleanRetryUnavailableReason)(root, state, step, head)} ${fallback}`,
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
// Reset under the reservation: the checks above ran on a snapshot, and
|
|
1217
|
+
// resetForCleanRetry re-checks against the state read once it is held.
|
|
1218
|
+
try {
|
|
1219
|
+
await (0, broker_1.resetStepTree)(dir, step, () => (0, clean_retry_1.resetForCleanRetry)(root, dir, step.id), scope);
|
|
1220
|
+
}
|
|
1221
|
+
catch (e) {
|
|
1222
|
+
if (e instanceof broker_1.BrokerStaleRequestError ||
|
|
1223
|
+
e instanceof broker_1.BrokerUnavailableError ||
|
|
1224
|
+
e instanceof broker_1.TreeBusyError) {
|
|
1225
|
+
throw e;
|
|
1226
|
+
}
|
|
1227
|
+
return {
|
|
1228
|
+
kind: 'error',
|
|
1229
|
+
reason: `Cannot apply action 'retry-clean' to step '${step.id}': the reset to ${step.gitRefBefore} failed: ${e instanceof Error ? e.message : String(e)} ${fallback}`,
|
|
1230
|
+
};
|
|
1231
|
+
}
|
|
1232
|
+
// Only the tree can say whether the reset left it clean. Anything else is
|
|
1233
|
+
// refused: accepting would rearm a step whose next attempt reruns the
|
|
1234
|
+
// generator over the previous attempt's output.
|
|
1235
|
+
if ((0, git_utils_1.getWorkingTreeStatus)(root) !== 'clean') {
|
|
1236
|
+
return {
|
|
1237
|
+
kind: 'error',
|
|
1238
|
+
reason: `Cannot apply action 'retry-clean' to step '${step.id}': the working tree is not verifiably clean after the reset to ${step.gitRefBefore}. Inspect it with \`git status\`, then re-run it. ${fallback}`,
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
// Giving up discards what a generator that never completed left behind
|
|
1243
|
+
// when the same restore point a clean retry needs exists, through the same
|
|
1244
|
+
// reserved reset. When there is no such point the tree is kept: what an
|
|
1245
|
+
// agent authored is never discarded, and a reset here would have no
|
|
1246
|
+
// verified target.
|
|
1247
|
+
const resetTree = action === 'unresolved' &&
|
|
1248
|
+
unresolvedResetsTree(state, step, (0, clean_retry_1.canOfferCleanRetry)(root, state, step, (0, git_utils_1.getLatestCommitSha)(root)));
|
|
1249
|
+
if (resetTree) {
|
|
1250
|
+
try {
|
|
1251
|
+
await (0, broker_1.resetStepTree)(dir, step, () => (0, clean_retry_1.resetForCleanRetry)(root, dir, step.id), scope);
|
|
1252
|
+
}
|
|
1253
|
+
catch (e) {
|
|
1254
|
+
if (e instanceof broker_1.BrokerStaleRequestError ||
|
|
1255
|
+
e instanceof broker_1.BrokerUnavailableError ||
|
|
1256
|
+
e instanceof broker_1.TreeBusyError) {
|
|
1257
|
+
throw e;
|
|
1258
|
+
}
|
|
1259
|
+
return {
|
|
1260
|
+
kind: 'error',
|
|
1261
|
+
reason: `Cannot apply action 'unresolved' to step '${step.id}': the reset to ${step.gitRefBefore} failed: ${e instanceof Error ? e.message : String(e)}`,
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
if ((0, git_utils_1.getWorkingTreeStatus)(root) !== 'clean') {
|
|
1265
|
+
return {
|
|
1266
|
+
kind: 'error',
|
|
1267
|
+
reason: `Cannot apply action 'unresolved' to step '${step.id}': the working tree is not verifiably clean after the reset to ${step.gitRefBefore}. Inspect it with \`git status\`, then re-run it.`,
|
|
1268
|
+
};
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
// A failed generator can have written to the tree before throwing, and a
|
|
1272
|
+
// plain retry reruns it, so a pre-marker retry is accepted only when git
|
|
1273
|
+
// can see nothing of the failed attempt in the tree. The state machine is
|
|
1274
|
+
// pure and cannot read the tree, which is why the gate lives here.
|
|
1275
|
+
if (action === 'retry' &&
|
|
1276
|
+
step.status === 'failed' &&
|
|
1277
|
+
generatorPending(step)) {
|
|
1278
|
+
const safety = assessPreMarkerRetry(root, step);
|
|
1279
|
+
if (safety.kind === 'unsafe') {
|
|
1280
|
+
return {
|
|
1281
|
+
kind: 'error',
|
|
1282
|
+
reason: `Cannot apply action 'retry' to step '${step.id}': ${safety.reason} Use 'retry-clean' where offered${(0, state_machine_1.commitMayBeInHistory)(state, step) ? '' : `, 'skip' or 'unresolved'`}, or 'adopt'.`,
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
if (safety.kind === 'warned') {
|
|
1286
|
+
(0, agent_output_1.warnToAgent)({
|
|
1287
|
+
title: `Retrying ${(0, state_machine_1.stepLabel)(step)} without verification`,
|
|
1288
|
+
bodyLines: [safety.warning],
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
const applied = (0, state_machine_1.applyStepEvent)(state, {
|
|
1293
|
+
type: 'stepAction',
|
|
1294
|
+
stepId: step.id,
|
|
1295
|
+
action,
|
|
1296
|
+
attempt: step.attempt,
|
|
1297
|
+
});
|
|
1298
|
+
if (applied.kind === 'error') {
|
|
1299
|
+
return applied;
|
|
1300
|
+
}
|
|
1301
|
+
return { kind: 'ok', state: applied.state, targetStep: step, resetTree };
|
|
1302
|
+
}
|
|
1303
|
+
function actionList(actions) {
|
|
1304
|
+
const quoted = actions.map((a) => `'${a}'`);
|
|
1305
|
+
return quoted.length === 1
|
|
1306
|
+
? quoted[0]
|
|
1307
|
+
: `${quoted.slice(0, -1).join(', ')} or ${quoted[quoted.length - 1]}`;
|
|
1308
|
+
}
|
|
1309
|
+
// The reset runs before the transition, so it is withheld where the
|
|
1310
|
+
// transition refuses the give-up.
|
|
1311
|
+
function unresolvedResetsTree(state, step, cleanRetry) {
|
|
1312
|
+
return (generatorPending(step) && !(0, state_machine_1.commitMayBeInHistory)(state, step) && cleanRetry);
|
|
1313
|
+
}
|
|
1314
|
+
// Git and install side effects run here, before the transition and outside the
|
|
1315
|
+
// synchronous state lock.
|
|
1316
|
+
async function stepActionSideEffects(root, dir, state, step, action, resetTree, scope) {
|
|
1317
|
+
switch (action) {
|
|
1318
|
+
case 'adopt':
|
|
1319
|
+
// A died worker's unrecorded commit request is reused. A failed step, or
|
|
1320
|
+
// a recorded commit, needs an adopt request of its own, or the old answer
|
|
1321
|
+
// would be replayed.
|
|
1322
|
+
return state.createCommits
|
|
1323
|
+
? commitForStep(root, dir, state, step, scope, step.status === 'failed' ||
|
|
1324
|
+
(0, state_machine_1.coveringLandedEntries)(state, step.id).length > 0
|
|
1325
|
+
? 'adopt'
|
|
1326
|
+
: undefined)
|
|
1327
|
+
: {
|
|
1328
|
+
entry: null,
|
|
1329
|
+
installFailed: await installFailedForStep(root, dir, state, step, 'action-install', scope),
|
|
1330
|
+
};
|
|
1331
|
+
case 'unresolved':
|
|
1332
|
+
// A reset restored the tree the step was dispensed against, so nothing
|
|
1333
|
+
// is left to install or to record as debt.
|
|
1334
|
+
if (resetTree)
|
|
1335
|
+
return { entry: null, installFailed: false };
|
|
1336
|
+
// A run that commits settles the step in giveUpStepTree instead.
|
|
1337
|
+
return retainedTreeSideEffects(root, dir, state, step, 'action-install', scope);
|
|
1338
|
+
case 'skip':
|
|
1339
|
+
return retainedTreeSideEffects(root, dir, state, step, 'action-install', scope);
|
|
1340
|
+
case 'retry':
|
|
1341
|
+
case 'retry-clean':
|
|
1342
|
+
return { entry: null, installFailed: false };
|
|
1343
|
+
default: {
|
|
1344
|
+
const exhaustive = action;
|
|
1345
|
+
throw new Error(`Unhandled step action '${exhaustive}'.`);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
// Commits the working tree left by a folded prompt outcome or an adopted step
|
|
1350
|
+
// (failed or died). The caller persists `entry` with the step transition
|
|
1351
|
+
// unless `recorded` says a session's parent already did; null when nothing to
|
|
1352
|
+
// commit. A crash between the git commit and the state write leaves that
|
|
1353
|
+
// commit in history and out of the ledger, with the failures it absorbed
|
|
1354
|
+
// uncovered; completion rechecks the tree before warning about that debt.
|
|
1355
|
+
async function commitForStep(root, dir, state, step, scope, commitAs) {
|
|
1356
|
+
const name = (0, state_machine_1.commitNameForStep)(step);
|
|
1357
|
+
const absorbedStepIds = (0, state_machine_1.uncoveredFailedStepIds)(state).filter((id) => id !== step.id);
|
|
1358
|
+
const skipInstall = state.skipInstall === true;
|
|
1359
|
+
let commit;
|
|
1360
|
+
try {
|
|
1361
|
+
commit = await (0, broker_1.commitStepTree)(dir, step, absorbedStepIds, () => (0, migrate_commits_1.commitMigrationIfRequested)(root, { name }, true, state.commitPrefix, () => (0, util_1.installDepsChangedSinceDispense)(root, dir, step, skipInstall, reconcileCommand(root, state.runId)), (0, state_machine_1.stepsToPendingMigrations)(state, absorbedStepIds)), scope, commitAs);
|
|
1362
|
+
}
|
|
1363
|
+
catch (e) {
|
|
1364
|
+
// Nothing to record: the step moved on, another process holds the tree, or
|
|
1365
|
+
// the parent never answered. The next reconcile redoes this fold or adopt.
|
|
1366
|
+
if (e instanceof broker_1.BrokerStaleRequestError ||
|
|
1367
|
+
e instanceof broker_1.BrokerUnavailableError ||
|
|
1368
|
+
e instanceof broker_1.TreeBusyError) {
|
|
1369
|
+
throw e;
|
|
1370
|
+
}
|
|
1371
|
+
// The dependency install is the only other thrower: the commit attempt
|
|
1372
|
+
// reports through result.status. The debt cannot stand in for the install
|
|
1373
|
+
// failure, since a later commit absorbing this diff clears the debt while
|
|
1374
|
+
// the dependencies are still missing.
|
|
1375
|
+
(0, util_1.warnCommitFailed)(name, e);
|
|
1376
|
+
return {
|
|
1377
|
+
entry: { kind: 'failed', stepIds: [step.id] },
|
|
1378
|
+
installFailed: true,
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1381
|
+
if (commit.result.status === 'failed') {
|
|
1382
|
+
(0, util_1.warnCommitFailed)(name);
|
|
1383
|
+
}
|
|
1384
|
+
return {
|
|
1385
|
+
entry: (0, state_machine_1.commitResultToLedgerEntry)(commit.result, step.id, commit.absorbedStepIds),
|
|
1386
|
+
installFailed: false,
|
|
1387
|
+
recorded: commit.recorded,
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
function advanceAndDispense(root, dir, runId) {
|
|
1391
|
+
// Demote recorded issues no remaining step can claim before anything is
|
|
1392
|
+
// rendered. Done here, at the single choke point every dispense, retry
|
|
1393
|
+
// prompt, and completion goes through, on a fresh locked read: a step
|
|
1394
|
+
// turned terminal by a concurrent reconcile or worker since the caller's
|
|
1395
|
+
// read must not leave an unclaimable issue labeled recorded in a digest
|
|
1396
|
+
// or the completion report.
|
|
1397
|
+
const state = (0, state_lock_1.updateRunState)(dir, (fresh) => {
|
|
1398
|
+
const settled = (0, issues_1.settleUnclaimableIssues)(fresh);
|
|
1399
|
+
return settled === fresh ? null : settled;
|
|
1400
|
+
});
|
|
1401
|
+
const step = firstActionableStep(state);
|
|
1402
|
+
if (!step) {
|
|
1403
|
+
completeRun(root, dir, runId, state);
|
|
1404
|
+
return;
|
|
1405
|
+
}
|
|
1406
|
+
// Track the response streak before emitting: a crash in between costs at
|
|
1407
|
+
// most a count one ahead of what was emitted, and the escalation is
|
|
1408
|
+
// advisory. Only the step responses below count: the completion response
|
|
1409
|
+
// above repeats by design, and a rejected --step-action ends the reconcile
|
|
1410
|
+
// before reaching here, already naming its own fix.
|
|
1411
|
+
const noProgress = trackNoProgress(dir, step);
|
|
1412
|
+
// Another live process holds the tree: the responses below would offer
|
|
1413
|
+
// actions it refuses or name a pid already gone. A running step's own
|
|
1414
|
+
// operation with a live worker keeps still-running, which offers none.
|
|
1415
|
+
const held = (0, broker_1.liveTreeOperation)(state);
|
|
1416
|
+
if (held && !isOwnOperation(step, held)) {
|
|
1417
|
+
emitHeld(root, runId, state, step, held, noProgress);
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
switch (step.status) {
|
|
1421
|
+
case 'pending':
|
|
1422
|
+
dispenseNextStep(root, dir, runId, state, step, noProgress);
|
|
1423
|
+
break;
|
|
1424
|
+
case 'dispensed':
|
|
1425
|
+
// Re-entry before the worker advanced the step; re-emit its command.
|
|
1426
|
+
emitNextStep(root, runId, state, step, noProgress);
|
|
1427
|
+
break;
|
|
1428
|
+
case 'failed':
|
|
1429
|
+
emitRetryFailed(root, runId, state, step, noProgress);
|
|
1430
|
+
break;
|
|
1431
|
+
case 'died':
|
|
1432
|
+
emitDied(root, runId, state, step, noProgress);
|
|
1433
|
+
break;
|
|
1434
|
+
case 'running':
|
|
1435
|
+
emitStillRunning(root, runId, state, step, held, noProgress);
|
|
1436
|
+
break;
|
|
1437
|
+
case 'awaiting-prompt-outcome':
|
|
1438
|
+
emitAwaitPrompt(root, dir, runId, step, noProgress);
|
|
1439
|
+
break;
|
|
1440
|
+
case 'succeeded':
|
|
1441
|
+
case 'skipped':
|
|
1442
|
+
case 'unresolved':
|
|
1443
|
+
// firstActionableStep already excludes these via TERMINAL_STEP_STATUSES;
|
|
1444
|
+
// landing here means an already-terminal step slipped through
|
|
1445
|
+
// unclassified rather than being left to stall the run silently.
|
|
1446
|
+
throw new Error(`Orchestrator could not dispense step '${step.id}': step is already ${step.status}.`);
|
|
1447
|
+
default: {
|
|
1448
|
+
// A new MigrateStepStatus member with no case above fails typecheck
|
|
1449
|
+
// here until it is classified.
|
|
1450
|
+
const exhaustive = step.status;
|
|
1451
|
+
throw new Error(`Orchestrator could not dispense step '${step.id}': unrecognized status '${exhaustive}'.`);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
function isOwnOperation(step, held) {
|
|
1456
|
+
return (step.status === 'running' &&
|
|
1457
|
+
held.stepId === step.id &&
|
|
1458
|
+
step.pid !== undefined &&
|
|
1459
|
+
(0, util_1.isPidAlive)(step.pid));
|
|
1460
|
+
}
|
|
1461
|
+
function firstActionableStep(state) {
|
|
1462
|
+
return state.steps.find((s) => !run_state_1.TERMINAL_STEP_STATUSES.has(s.status));
|
|
1463
|
+
}
|
|
1464
|
+
// The fingerprint digests the whole persisted state (minus the streak itself),
|
|
1465
|
+
// so any durable change resets the count with no per-field enumeration to fall
|
|
1466
|
+
// out of date. A response whose own production writes state after the streak
|
|
1467
|
+
// is tracked fingerprints the pre-write state, so its first repeat resets
|
|
1468
|
+
// rather than increments.
|
|
1469
|
+
function responseFingerprint(state) {
|
|
1470
|
+
return (0, crypto_1.createHash)('sha256')
|
|
1471
|
+
.update(JSON.stringify({ ...state, noProgress: undefined }))
|
|
1472
|
+
.digest('hex');
|
|
1473
|
+
}
|
|
1474
|
+
// A young, parseably-started worker neither increments nor resets the
|
|
1475
|
+
// actionable-response streak. Unproven age counts normally.
|
|
1476
|
+
function trackNoProgress(dir, step) {
|
|
1477
|
+
if (step.status === 'running') {
|
|
1478
|
+
const startedAt = step.startedAt ? Date.parse(step.startedAt) : NaN;
|
|
1479
|
+
if (Number.isFinite(startedAt) &&
|
|
1480
|
+
Date.now() - startedAt < HANG_THRESHOLD_MS) {
|
|
1481
|
+
return null;
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
let streak;
|
|
1485
|
+
(0, state_lock_1.updateRunState)(dir, (fresh) => {
|
|
1486
|
+
const fingerprint = responseFingerprint(fresh);
|
|
1487
|
+
const prev = fresh.noProgress;
|
|
1488
|
+
streak =
|
|
1489
|
+
prev && prev.fingerprint === fingerprint
|
|
1490
|
+
? { ...prev, consecutiveCount: prev.consecutiveCount + 1 }
|
|
1491
|
+
: {
|
|
1492
|
+
fingerprint,
|
|
1493
|
+
consecutiveCount: 1,
|
|
1494
|
+
firstSeenAt: new Date().toISOString(),
|
|
1495
|
+
};
|
|
1496
|
+
return { ...fresh, noProgress: streak };
|
|
1497
|
+
});
|
|
1498
|
+
return streak.consecutiveCount >= NO_PROGRESS_THRESHOLD ? streak : null;
|
|
1499
|
+
}
|
|
1500
|
+
function dispenseNextStep(root, dir, runId, state, step, noProgress) {
|
|
1501
|
+
// Read the pre-step baselines (git and package.json reads) before the
|
|
1502
|
+
// lock; the dispense transition and the baselines then apply to the fresh
|
|
1503
|
+
// state in one write.
|
|
1504
|
+
const baselines = {
|
|
1505
|
+
gitRefBefore: (0, git_utils_1.getLatestCommitSha)(root) ?? undefined,
|
|
1506
|
+
treeCleanAtDispense: (0, git_utils_1.getWorkingTreeStatus)(root) === 'clean',
|
|
1507
|
+
depsHashAtDispense: (0, util_1.depsHash)(root),
|
|
1508
|
+
};
|
|
1509
|
+
let advancedElsewhere = false;
|
|
1510
|
+
let held;
|
|
1511
|
+
const current = (0, state_lock_1.updateRunState)(dir, (fresh) => {
|
|
1512
|
+
// A concurrent init or reconcile may have dispensed (or further advanced)
|
|
1513
|
+
// this step since the caller's read; reclassify against the fresh state
|
|
1514
|
+
// below instead of failing the duplicate transition.
|
|
1515
|
+
if (fresh.steps.find((s) => s.id === step.id)?.status !== 'pending') {
|
|
1516
|
+
advancedElsewhere = true;
|
|
1517
|
+
return null;
|
|
1518
|
+
}
|
|
1519
|
+
// A checkpoint in flight would capture the dispensed step's changes;
|
|
1520
|
+
// checked in the write that dispenses, since it can start after any
|
|
1521
|
+
// earlier read.
|
|
1522
|
+
held = (0, broker_1.liveTreeOperation)(fresh);
|
|
1523
|
+
if (held)
|
|
1524
|
+
return null;
|
|
1525
|
+
const dispensed = applyEventOrThrow(fresh, dispenseEvent(step));
|
|
1526
|
+
return setDispenseBaselines(dispensed, step.id, baselines);
|
|
1527
|
+
});
|
|
1528
|
+
if (advancedElsewhere) {
|
|
1529
|
+
// Terminates: step statuses only advance, so each re-entry observes
|
|
1530
|
+
// strictly later state and lands in a non-pending branch of the dispatch.
|
|
1531
|
+
advanceAndDispense(root, dir, runId);
|
|
1532
|
+
return;
|
|
1533
|
+
}
|
|
1534
|
+
if (held) {
|
|
1535
|
+
emitHeld(root, runId, current, step, held, noProgress);
|
|
1536
|
+
return;
|
|
1537
|
+
}
|
|
1538
|
+
const dispensed = current.steps.find((s) => s.id === step.id);
|
|
1539
|
+
(0, migrate_analytics_1.reportMigrateOrchestratorStepDispensed)({
|
|
1540
|
+
attempt: dispensed.attempt,
|
|
1541
|
+
ordinal: (0, state_machine_1.runTallies)(current).dispenseCount,
|
|
1542
|
+
});
|
|
1543
|
+
switch (dispensed.kind) {
|
|
1544
|
+
case 'migration':
|
|
1545
|
+
emitNextStep(root, runId, current, dispensed, noProgress);
|
|
1546
|
+
break;
|
|
1547
|
+
case 'final-validation':
|
|
1548
|
+
emitAwaitPrompt(root, dir, runId, dispensed, noProgress);
|
|
1549
|
+
break;
|
|
1550
|
+
default: {
|
|
1551
|
+
const exhaustive = dispensed;
|
|
1552
|
+
throw new Error(`Unrecognized step: ${JSON.stringify(exhaustive)}`);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
function dispenseEvent(step) {
|
|
1557
|
+
switch (step.kind) {
|
|
1558
|
+
case 'migration':
|
|
1559
|
+
return { type: 'dispense', stepId: step.id };
|
|
1560
|
+
case 'final-validation':
|
|
1561
|
+
// No worker runs the pass, so its dispense parks it for the agent.
|
|
1562
|
+
return {
|
|
1563
|
+
type: 'parkForFinalValidation',
|
|
1564
|
+
stepId: step.id,
|
|
1565
|
+
finishedAt: (0, util_1.nowIso)(),
|
|
1566
|
+
};
|
|
1567
|
+
default: {
|
|
1568
|
+
const exhaustive = step;
|
|
1569
|
+
throw new Error(`Unrecognized step: ${JSON.stringify(exhaustive)}`);
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
function emitNextStep(root, runId, state, step, noProgress) {
|
|
1574
|
+
let migrationId;
|
|
1575
|
+
switch (step.kind) {
|
|
1576
|
+
case 'migration':
|
|
1577
|
+
migrationId = step.migrationId;
|
|
1578
|
+
break;
|
|
1579
|
+
case 'final-validation':
|
|
1580
|
+
// Parked straight from 'pending', so it is never 'dispensed'.
|
|
1581
|
+
throw new Error(`Step '${step.id}' is the final validation pass, which has no worker command.`);
|
|
1582
|
+
default: {
|
|
1583
|
+
const exhaustive = step;
|
|
1584
|
+
throw new Error(`Unrecognized step: ${JSON.stringify(exhaustive)}`);
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
emit(root, runId, state, step, 'next-step', {
|
|
1588
|
+
command: workerCommand(root, migrationId, runId),
|
|
1589
|
+
next: reconcileCommand(root, runId),
|
|
1590
|
+
instructionLines: [
|
|
1591
|
+
`Apply migration ${migrationId} by running the command below, then run the "next" command to record the outcome and get the next step.`,
|
|
1592
|
+
...(0, issues_1.renderIssueDigestLines)(state, step.id, runId),
|
|
1593
|
+
],
|
|
1594
|
+
}, noProgress);
|
|
1595
|
+
}
|
|
1596
|
+
function emitRetryFailed(root, runId, state, step, noProgress) {
|
|
1597
|
+
let subject;
|
|
1598
|
+
switch (step.kind) {
|
|
1599
|
+
case 'migration':
|
|
1600
|
+
subject = `Migration ${step.migrationId}`;
|
|
1601
|
+
break;
|
|
1602
|
+
case 'final-validation':
|
|
1603
|
+
subject = 'The final validation pass';
|
|
1604
|
+
break;
|
|
1605
|
+
default: {
|
|
1606
|
+
const exhaustive = step;
|
|
1607
|
+
throw new Error(`Unrecognized step: ${JSON.stringify(exhaustive)}`);
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
// A worker failure records its summary on the outcome; a prompt the agent
|
|
1611
|
+
// reported as failed carries the agent's own reason on the prompt outcome.
|
|
1612
|
+
const summary = step.outcome?.summary ?? step.promptOutcome?.summary;
|
|
1613
|
+
const head = (0, git_utils_1.getLatestCommitSha)(root);
|
|
1614
|
+
const tree = dirtyTreeSummary(root);
|
|
1615
|
+
const cleanRetry = (0, clean_retry_1.canOfferCleanRetry)(root, state, step, head);
|
|
1616
|
+
const landed = lastCoveringLandedEntry(state, step);
|
|
1617
|
+
const committed = (0, state_machine_1.commitMayBeInHistory)(state, step);
|
|
1618
|
+
// A failure recorded before the generator marker can still have written to
|
|
1619
|
+
// the tree (a direct fs or exec side effect, or a crash mid-flush); a
|
|
1620
|
+
// marker means only the handed-back half (a prompt or a validation pass)
|
|
1621
|
+
// or the install and commit are left, so plain retry is safe outright. So
|
|
1622
|
+
// is retrying a step with no generator half to rerun.
|
|
1623
|
+
const pending = generatorPending(step);
|
|
1624
|
+
const retrySafety = pending
|
|
1625
|
+
? assessPreMarkerRetry(root, step)
|
|
1626
|
+
: { kind: 'safe' };
|
|
1627
|
+
const capReached = rearmCapReached(step);
|
|
1628
|
+
const lines = [
|
|
1629
|
+
`${subject} failed${summary ? `: ${summary}` : ''}.`,
|
|
1630
|
+
` started from: ${step.gitRefBefore ?? '(unknown)'}`,
|
|
1631
|
+
` current HEAD: ${head ?? '(unknown)'}`,
|
|
1632
|
+
` working tree: ${tree === null ? '(unknown)' : tree ? `\n${tree}` : '(clean)'}`,
|
|
1633
|
+
``,
|
|
1634
|
+
retryBudgetLine(step, committed),
|
|
1635
|
+
``,
|
|
1636
|
+
`Decide how to proceed and re-run reconcile with one of:`,
|
|
1637
|
+
...(capReached
|
|
1638
|
+
? []
|
|
1639
|
+
: [retryOptionLine(retrySafety, reconcileCommand(root, runId, 'retry'))]),
|
|
1640
|
+
];
|
|
1641
|
+
if (cleanRetry && !capReached) {
|
|
1642
|
+
lines.push(` retry-clean: reset the tree to ${step.gitRefBefore ?? 'the pre-migration ref'} (discarding its uncommitted tracked changes and the untracked files git does not ignore, ${types_1.MIGRATE_RUNS_RELATIVE_DIR} kept) and retry from that clean state by running: ${reconcileCommand(root, runId, 'retry-clean')}`);
|
|
1643
|
+
}
|
|
1644
|
+
lines.push(landed
|
|
1645
|
+
? ` adopt: keep the landed commit${landed.sha ? ` ${landed.sha}` : ''} and the current working-tree state as the ${(0, state_machine_1.stepNoun)(step)}'s result, then run: ${reconcileCommand(root, runId, 'adopt')}`
|
|
1646
|
+
: ` adopt: ${committed
|
|
1647
|
+
? `a commit of this ${(0, state_machine_1.stepNoun)(step)}'s changes was started and never recorded`
|
|
1648
|
+
: `the ${(0, state_machine_1.stepNoun)(step)} was ${step.kind === 'migration' ? 'applied' : 'done'} by hand`}; keep the current working-tree state as its result, then run: ${reconcileCommand(root, runId, 'adopt')}`);
|
|
1649
|
+
// Refused by the state machine: the migration is, or may be, committed.
|
|
1650
|
+
if (!committed) {
|
|
1651
|
+
lines.push(` skip: ${reconcileCommand(root, runId, 'skip')}`, unresolvedOptionLine(root, runId, state, step, unresolvedResetsTree(state, step, cleanRetry)));
|
|
1652
|
+
}
|
|
1653
|
+
if (pending) {
|
|
1654
|
+
lines.push(UNVERIFIABLE_WRITES_LINE);
|
|
1655
|
+
}
|
|
1656
|
+
// No preselected retry while the generator may still run: git cannot vouch
|
|
1657
|
+
// for every write. Past the cap no retry is offered or accepted.
|
|
1658
|
+
emit(root, runId, state, step, 'retry-failed', {
|
|
1659
|
+
...(pending || capReached
|
|
1660
|
+
? {}
|
|
1661
|
+
: { next: reconcileCommand(root, runId, 'retry') }),
|
|
1662
|
+
instructionLines: lines,
|
|
1663
|
+
}, noProgress);
|
|
1664
|
+
}
|
|
1665
|
+
// Whether the step has used up its rearms: attempts beyond the first are all
|
|
1666
|
+
// rearms, whichever retry action produced them.
|
|
1667
|
+
function rearmCapReached(step) {
|
|
1668
|
+
return step.attempt - 1 >= REARM_ESCALATION_CAP;
|
|
1669
|
+
}
|
|
1670
|
+
function retryBudgetLine(step, committed) {
|
|
1671
|
+
if (rearmCapReached(step))
|
|
1672
|
+
return rearmCapLine(step, committed);
|
|
1673
|
+
const left = REARM_ESCALATION_CAP - (step.attempt - 1);
|
|
1674
|
+
return `Retries left for this ${(0, state_machine_1.stepNoun)(step)}: ${left}. Diagnose the failure first and retry only with a plausible fix in hand; ${left === 1
|
|
1675
|
+
? 'this is the last one, so ask the user before using it'
|
|
1676
|
+
: 'ask the user before using the last one'}. When no user can answer, ${committed
|
|
1677
|
+
? `adopt only once you have inspected the tree and finished the ${(0, state_machine_1.stepNoun)(step)}; otherwise stop and report`
|
|
1678
|
+
: 'give the step up with unresolved and continue'}.`;
|
|
1679
|
+
}
|
|
1680
|
+
// Opens a capped dispense and is the reason a retry past the cap is refused.
|
|
1681
|
+
function rearmCapLine(step, committed) {
|
|
1682
|
+
return `This ${(0, state_machine_1.stepNoun)(step)} has already been retried ${step.attempt - 1} times without completing, and no further retry is accepted. ${committed
|
|
1683
|
+
? `Adopt only once you have inspected the tree and finished the ${(0, state_machine_1.stepNoun)(step)}; otherwise ask the user how to proceed, or stop and report.`
|
|
1684
|
+
: 'Choose adopt, skip or unresolved, or ask the user how to proceed.'}`;
|
|
1685
|
+
}
|
|
1686
|
+
// Whether the step's generator half may still have to run: it exists and no
|
|
1687
|
+
// attempt has recorded running it. Only then can a retry apply a generator
|
|
1688
|
+
// twice, so only then is a continuation withheld from `next`. A step with no
|
|
1689
|
+
// generator (prompt-only) is retried by re-prompting the agent over the tree
|
|
1690
|
+
// it already knows, which is the designed recovery; a step recorded before the
|
|
1691
|
+
// kind was persisted counts as having one.
|
|
1692
|
+
function generatorPending(step) {
|
|
1693
|
+
return step.generatorCompleted !== true && step.hasGenerator !== false;
|
|
1694
|
+
}
|
|
1695
|
+
// Absent generatorMadeChanges (a marker an older nx wrote) counts as applied,
|
|
1696
|
+
// keeping that version's fold behavior.
|
|
1697
|
+
function generatorChangesApplied(step) {
|
|
1698
|
+
return (step.generatorCompleted === true && step.generatorMadeChanges !== false);
|
|
1699
|
+
}
|
|
1700
|
+
// Appended to the failed and died dispenses of a step whose generator may rerun.
|
|
1701
|
+
const UNVERIFIABLE_WRITES_LINE = `None of these can be verified against writes git does not see (ignored paths, files outside the repository); if this migration writes there, inspect that state before choosing.`;
|
|
1702
|
+
function retryOptionLine(safety, command) {
|
|
1703
|
+
switch (safety.kind) {
|
|
1704
|
+
case 'safe':
|
|
1705
|
+
return ` retry: re-run over the current tree: ${command}`;
|
|
1706
|
+
case 'warned':
|
|
1707
|
+
return ` retry: re-run over the current tree; without git nothing can verify what the failed attempt left, so inspect the tree first: ${command}`;
|
|
1708
|
+
case 'unsafe':
|
|
1709
|
+
return ` retry: re-run over the current tree; refused until the working tree is clean and HEAD is at the started-from ref: ${command}`;
|
|
1710
|
+
default: {
|
|
1711
|
+
const exhaustive = safety;
|
|
1712
|
+
return exhaustive;
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
function assessPreMarkerRetry(root, step) {
|
|
1717
|
+
const repo = (0, git_utils_1.getGitRepositoryStatus)(root);
|
|
1718
|
+
if (repo === 'not-git') {
|
|
1719
|
+
return {
|
|
1720
|
+
kind: 'warned',
|
|
1721
|
+
warning: `The workspace is not a git repository, so nothing can verify whether the failed attempt left partial changes in the tree. The retry reruns the generator over whatever is there; confirm the tree yourself first.`,
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
if (repo === 'unknown') {
|
|
1725
|
+
return {
|
|
1726
|
+
kind: 'unsafe',
|
|
1727
|
+
reason: `the git repository state could not be determined, so nothing can verify whether the failed attempt left changes in the tree.`,
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1730
|
+
const head = (0, git_utils_1.getLatestCommitSha)(root);
|
|
1731
|
+
if (!step.gitRefBefore || head !== step.gitRefBefore) {
|
|
1732
|
+
return {
|
|
1733
|
+
kind: 'unsafe',
|
|
1734
|
+
reason: `HEAD is at ${head ?? '(unreadable)'} rather than the ${step.gitRefBefore ?? '(unrecorded)'} this migration started from, so the failed attempt's changes may already be committed and rerunning the generator could apply them twice.`,
|
|
1735
|
+
};
|
|
1736
|
+
}
|
|
1737
|
+
if ((0, git_utils_1.getWorkingTreeStatus)(root) !== 'clean') {
|
|
1738
|
+
return {
|
|
1739
|
+
kind: 'unsafe',
|
|
1740
|
+
reason: `the working tree is not verifiably clean, and the failed attempt may have written to it before failing; rerunning the generator over those changes could apply them twice.`,
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
return { kind: 'safe' };
|
|
1744
|
+
}
|
|
1745
|
+
// Whichever attempt landed it, the commit is this migration's result.
|
|
1746
|
+
function lastCoveringLandedEntry(state, step) {
|
|
1747
|
+
const entries = (0, state_machine_1.coveringLandedEntries)(state, step.id);
|
|
1748
|
+
return entries.length > 0 ? entries[entries.length - 1] : null;
|
|
1749
|
+
}
|
|
1750
|
+
// The give-up option, worded for what happens to the tree: the reserved
|
|
1751
|
+
// reset, a partial commit, or the tree left as it stands.
|
|
1752
|
+
function unresolvedOptionLine(root, runId, state, step, resetTree) {
|
|
1753
|
+
const command = reconcileCommand(root, runId, 'unresolved');
|
|
1754
|
+
const recorded = `The failure is recorded as a run issue and listed in the completion report.`;
|
|
1755
|
+
const noun = (0, state_machine_1.stepNoun)(step);
|
|
1756
|
+
if (resetTree) {
|
|
1757
|
+
return ` unresolved: give up on this ${noun}, resetting the tree to ${step.gitRefBefore ?? 'the pre-migration ref'} (discarding what the failed attempt left, ${types_1.MIGRATE_RUNS_RELATIVE_DIR} kept), then run: ${command}. ${recorded}`;
|
|
1758
|
+
}
|
|
1759
|
+
if (state.createCommits) {
|
|
1760
|
+
return ` unresolved: give up on this ${noun}; its partial changes are committed under its name, marked unresolved, and the run moves on. Then run: ${command}. ${recorded}`;
|
|
1761
|
+
}
|
|
1762
|
+
return ` unresolved: give up on this ${noun}, leaving the tree as it stands, and move on. Then run: ${command}. ${recorded}`;
|
|
1763
|
+
}
|
|
1764
|
+
function emitDied(root, runId, state, step, noProgress) {
|
|
1765
|
+
const label = (0, state_machine_1.stepLabel)(step);
|
|
1766
|
+
const ref = step.gitRefBefore;
|
|
1767
|
+
const head = (0, git_utils_1.getLatestCommitSha)(root);
|
|
1768
|
+
const tree = dirtyTreeSummary(root);
|
|
1769
|
+
const cleanRetry = (0, clean_retry_1.canOfferCleanRetry)(root, state, step, head);
|
|
1770
|
+
const committed = (0, state_machine_1.commitMayBeInHistory)(state, step);
|
|
1771
|
+
const resume = !generatorPending(step);
|
|
1772
|
+
const capReached = rearmCapReached(step);
|
|
1773
|
+
const lines = [
|
|
1774
|
+
`The worker for ${label} died; its process is gone.`,
|
|
1775
|
+
` started from: ${ref ?? '(unknown)'}`,
|
|
1776
|
+
` current HEAD: ${head ?? '(unknown)'}`,
|
|
1777
|
+
` working tree: ${tree === null ? '(unknown)' : tree ? `\n${tree}` : '(clean)'}`,
|
|
1778
|
+
``,
|
|
1779
|
+
retryBudgetLine(step, committed),
|
|
1780
|
+
``,
|
|
1781
|
+
];
|
|
1782
|
+
const options = [];
|
|
1783
|
+
if (resume && !capReached) {
|
|
1784
|
+
options.push(` retry: keep everything this migration already produced (its commit, if any, and the current tree) and run only the part that did not complete, then run: ${reconcileCommand(root, runId, 'retry')}`);
|
|
1785
|
+
}
|
|
1786
|
+
if (cleanRetry && !capReached) {
|
|
1787
|
+
options.push(` retry-clean: reset the tree to ${ref ?? 'the pre-migration ref'} (discarding its uncommitted tracked changes and the untracked files git does not ignore, ${types_1.MIGRATE_RUNS_RELATIVE_DIR} kept) and retry from that clean state by running: ${reconcileCommand(root, runId, 'retry-clean')}`);
|
|
1788
|
+
}
|
|
1789
|
+
else if (!capReached) {
|
|
1790
|
+
lines.push(`A clean retry is unavailable: ${(0, clean_retry_1.cleanRetryUnavailableReason)(root, state, step, head)}`);
|
|
1791
|
+
}
|
|
1792
|
+
options.push(` adopt: keep the current working-tree state as this migration's result, then run: ${reconcileCommand(root, runId, 'adopt')}`);
|
|
1793
|
+
// Refused by the state machine: the migration is, or may be, committed.
|
|
1794
|
+
if (!committed) {
|
|
1795
|
+
options.push(` skip: leave the tree as it stands and move on without this migration, then run: ${reconcileCommand(root, runId, 'skip')}`, unresolvedOptionLine(root, runId, state, step, unresolvedResetsTree(state, step, cleanRetry)));
|
|
1796
|
+
}
|
|
1797
|
+
lines.push(`Choose exactly one:`);
|
|
1798
|
+
lines.push(...options);
|
|
1799
|
+
if (!resume) {
|
|
1800
|
+
lines.push(UNVERIFIABLE_WRITES_LINE);
|
|
1801
|
+
}
|
|
1802
|
+
// `retry` is preselected only when no generator remains to run and the cap
|
|
1803
|
+
// allows it: a reset cannot be verified against writes git does not see, and
|
|
1804
|
+
// adopting records a result nothing checked, so neither is automatic.
|
|
1805
|
+
emit(root, runId, state, step, 'died', {
|
|
1806
|
+
...(resume && !capReached
|
|
1807
|
+
? { next: reconcileCommand(root, runId, 'retry') }
|
|
1808
|
+
: {}),
|
|
1809
|
+
instructionLines: lines,
|
|
1810
|
+
}, noProgress);
|
|
1811
|
+
}
|
|
1812
|
+
function emitHeld(root, runId, state, step, held, noProgress) {
|
|
1813
|
+
emit(root, runId, state, step, 'held', {
|
|
1814
|
+
next: reconcileCommand(root, runId),
|
|
1815
|
+
instructionLines: [(0, broker_1.treeBusyMessage)(held)],
|
|
1816
|
+
}, noProgress);
|
|
1817
|
+
}
|
|
1818
|
+
function emitStillRunning(root, runId, state, step, held, noProgress) {
|
|
1819
|
+
const ageMs = step.startedAt ? Date.now() - Date.parse(step.startedAt) : 0;
|
|
1820
|
+
const lines = [
|
|
1821
|
+
`The worker for ${(0, state_machine_1.stepLabel)(step)} (pid ${step.pid}) is still running. Wait for it to finish, then run the "next" command.`,
|
|
1822
|
+
];
|
|
1823
|
+
// A holder pid other than the worker's is the session's parent process.
|
|
1824
|
+
const parentOperation = held !== undefined && held.pid !== step.pid
|
|
1825
|
+
? (0, broker_1.treeOperationLabel)(held)
|
|
1826
|
+
: undefined;
|
|
1827
|
+
if (parentOperation) {
|
|
1828
|
+
lines.push(`The nx process ${held.pid} is running ${parentOperation} for it; killing the worker does not stop that, and the step can be classified as died only once it finishes.`);
|
|
1829
|
+
}
|
|
1830
|
+
if (ageMs >= HANG_THRESHOLD_MS) {
|
|
1831
|
+
const hung = `It has been running for ${Math.floor(ageMs / 60000)} minutes and may be hung.`;
|
|
1832
|
+
lines.push(parentOperation
|
|
1833
|
+
? `${hung} Report this to the user: they can quit this session, then press Ctrl+C in the terminal to end ${parentOperation}, and resume the run afterwards.`
|
|
1834
|
+
: `${hung} Verify pid ${step.pid}; either keep waiting, or kill it so the next reconcile can classify it as died.`);
|
|
1835
|
+
}
|
|
1836
|
+
emit(root, runId, state, step, 'still-running', {
|
|
1837
|
+
next: reconcileCommand(root, runId),
|
|
1838
|
+
instructionLines: lines,
|
|
1839
|
+
}, noProgress);
|
|
1840
|
+
}
|
|
1841
|
+
function emitAwaitPrompt(root, dir, runId, step, noProgress) {
|
|
1842
|
+
const filePath = (0, handoff_1.runStepHandoffPath)(dir, step.id);
|
|
1843
|
+
// Recreated if the agent removed it, so the handed-over path always has its
|
|
1844
|
+
// parent (an agent that has to `mkdir -p` pays a permission prompt).
|
|
1845
|
+
const handoffsDir = (0, run_state_1.runHandoffsDir)(dir);
|
|
1846
|
+
const handoffsDirIs = (0, handoff_1.handoffsDirState)(handoffsDir);
|
|
1847
|
+
if (handoffsDirIs === 'missing') {
|
|
1848
|
+
(0, fs_1.mkdirSync)(handoffsDir, { recursive: true });
|
|
1849
|
+
}
|
|
1850
|
+
// Claim only while fresh state still awaits this handoff. Steps that never
|
|
1851
|
+
// park cannot report updates; serial dispensing fixes order, and stale
|
|
1852
|
+
// attempts redispatch.
|
|
1853
|
+
let advancedElsewhere = false;
|
|
1854
|
+
const claimed = (0, state_lock_1.updateRunState)(dir, (fresh) => {
|
|
1855
|
+
const freshStep = fresh.steps.find((s) => s.id === step.id);
|
|
1856
|
+
if (freshStep?.status !== 'awaiting-prompt-outcome' ||
|
|
1857
|
+
freshStep.attempt !== step.attempt) {
|
|
1858
|
+
advancedElsewhere = true;
|
|
1859
|
+
return null;
|
|
1860
|
+
}
|
|
1861
|
+
const next = (0, issues_1.claimIssuesForStep)(fresh, step.id, runId);
|
|
1862
|
+
return next === fresh ? null : next;
|
|
1863
|
+
});
|
|
1864
|
+
if (advancedElsewhere) {
|
|
1865
|
+
// Terminates like dispenseNextStep's redispatch: step state only
|
|
1866
|
+
// advances, so each re-entry observes strictly later state.
|
|
1867
|
+
advanceAndDispense(root, dir, runId);
|
|
1868
|
+
return;
|
|
1869
|
+
}
|
|
1870
|
+
let lines;
|
|
1871
|
+
switch (step.kind) {
|
|
1872
|
+
case 'migration':
|
|
1873
|
+
lines = awaitMigrationWorkLines(root, dir, claimed, step, filePath);
|
|
1874
|
+
break;
|
|
1875
|
+
case 'final-validation':
|
|
1876
|
+
lines = awaitFinalValidationLines(root, dir, claimed, step, filePath);
|
|
1877
|
+
break;
|
|
1878
|
+
default: {
|
|
1879
|
+
const exhaustive = step;
|
|
1880
|
+
throw new Error(`Unrecognized step: ${JSON.stringify(exhaustive)}`);
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
lines.push(...(0, issues_1.renderIssueDigestLines)(claimed, step.id, runId));
|
|
1884
|
+
// A handoff that exists but can't be read/parsed/validated is a rejection,
|
|
1885
|
+
// not a still-awaited outcome. Naming why stops the run from re-emitting the
|
|
1886
|
+
// same await forever while the agent leaves the bad file in place.
|
|
1887
|
+
// A non-directory in the handoffs dir's place is never read through, so a
|
|
1888
|
+
// rewritten handoff cannot cure it: name the replacement instead.
|
|
1889
|
+
const rejection = handoffsDirIs === 'other'
|
|
1890
|
+
? [
|
|
1891
|
+
`${handoffsDir} is not a directory, so no handoff can be read from it. Replace it with a directory, then write the handoff file and run the "next" command.`,
|
|
1892
|
+
]
|
|
1893
|
+
: describeRejectedHandoff(dir, claimed, step);
|
|
1894
|
+
if (rejection.length > 0) {
|
|
1895
|
+
lines.push('', ...rejection);
|
|
1896
|
+
}
|
|
1897
|
+
emit(root, runId, claimed, step, 'await-prompt', {
|
|
1898
|
+
next: reconcileCommand(root, runId),
|
|
1899
|
+
instructionLines: lines,
|
|
1900
|
+
}, noProgress);
|
|
1901
|
+
}
|
|
1902
|
+
// Re-hands a migration's prompt or validation work and returns the lines the
|
|
1903
|
+
// await-prompt dispense states it with.
|
|
1904
|
+
function awaitMigrationWorkLines(root, dir, claimed, step, filePath) {
|
|
1905
|
+
const migrationId = step.migrationId;
|
|
1906
|
+
const validating = step.awaitingKind === 'generator-validation';
|
|
1907
|
+
// The plan's prompt path is the ground truth for a prompt park: a stored copy
|
|
1908
|
+
// naming different instructions is rejected against it.
|
|
1909
|
+
const planPrompt = validating
|
|
1910
|
+
? null
|
|
1911
|
+
: planPromptPath(dir, claimed, migrationId);
|
|
1912
|
+
// Re-emit the payload the worker stored when it parked the step, so a
|
|
1913
|
+
// session that lost the original block gets the work restated. An awaiting
|
|
1914
|
+
// step offers no retry action, so a dispense that only pointed backward
|
|
1915
|
+
// could stall a valid run forever; only a plan that cannot name the prompt
|
|
1916
|
+
// falls back to that pointer.
|
|
1917
|
+
const payload = (0, agent_work_payload_1.readAgentWorkPayload)((0, agent_work_payload_1.agentWorkPayloadPath)(dir, step.id, step.attempt), {
|
|
1918
|
+
migrationId,
|
|
1919
|
+
kind: validating ? 'generator-validation' : 'migration-prompt',
|
|
1920
|
+
...(planPrompt === null ? {} : { promptPath: planPrompt }),
|
|
1921
|
+
}) ??
|
|
1922
|
+
(validating
|
|
1923
|
+
? { migrationId, kind: 'generator-validation' }
|
|
1924
|
+
: planPrompt === null
|
|
1925
|
+
? null
|
|
1926
|
+
: { migrationId, prompt: planPrompt });
|
|
1927
|
+
if (payload) {
|
|
1928
|
+
(0, agent_output_1.emitPromptBlock)(migrationId, payload);
|
|
1929
|
+
}
|
|
1930
|
+
const blockRef = payload
|
|
1931
|
+
? 'the <nx_migrate_prompt> block above'
|
|
1932
|
+
: "the worker's earlier <nx_migrate_prompt> block";
|
|
1933
|
+
const lines = validating
|
|
1934
|
+
? [
|
|
1935
|
+
`Migration ${migrationId} ran its generator; its changes are awaiting your validation.`,
|
|
1936
|
+
`Validate them (see ${blockRef} and the runbook's validation scope rules), then write the handoff file and run the "next" command.`,
|
|
1937
|
+
]
|
|
1938
|
+
: [
|
|
1939
|
+
`Migration ${migrationId} is a prompt-based migration awaiting your outcome.`,
|
|
1940
|
+
`Apply the prompt (see ${blockRef}), then write the handoff file and run the "next" command.`,
|
|
1941
|
+
// Resolved per dispense: an earlier step may have changed the formatter
|
|
1942
|
+
// since the runbook was written.
|
|
1943
|
+
`Format command: ${(0, format_command_1.resolveFormatCommand)(root, (0, util_1.pmExecPrefix)(root)) ??
|
|
1944
|
+
'none (no configured formatter is installed)'}`,
|
|
1945
|
+
];
|
|
1946
|
+
lines.push(`Handoff file: ${filePath}`,
|
|
1947
|
+
// The skipped outcome is offered only while nothing of the migration is in
|
|
1948
|
+
// the tree: once a generator's changes are applied, the fold treats a
|
|
1949
|
+
// skipped handoff as completed anyway.
|
|
1950
|
+
validating
|
|
1951
|
+
? `Handoff JSON: ${(0, fragments_1.renderHandoffShapeInline)('what you verified')}. If validation does not apply here, use "status": "success" and say so in the summary.`
|
|
1952
|
+
: generatorChangesApplied(step)
|
|
1953
|
+
? `Handoff JSON: ${(0, fragments_1.renderHandoffShapeInline)('what you did')}. If the prompt does not apply here, use "status": "success" and say so in the summary; the migration's generator changes are already applied.`
|
|
1954
|
+
: `Handoff JSON: ${(0, fragments_1.renderHandoffShapeInline)('what you did')}. To mark the prompt not applicable, use "status": "success" with "outcome": "skipped".`);
|
|
1955
|
+
return lines;
|
|
1956
|
+
}
|
|
1957
|
+
// Writes the pass's instructions file and emits the block pointing at it. The
|
|
1958
|
+
// file is derived from run state alone, so a re-emit after a restart, or after
|
|
1959
|
+
// the agent removed the file, rewrites it instead of re-reading a stored copy.
|
|
1960
|
+
function awaitFinalValidationLines(root, dir, state, step, filePath) {
|
|
1961
|
+
const promptsDir = (0, path_1.join)(dir, types_1.PROMPTS_DIR_NAME, step.id);
|
|
1962
|
+
(0, handoff_1.mkdirSafely)(promptsDir, 'prompt directory for the final validation pass');
|
|
1963
|
+
const instructions = (0, instruction_files_1.writeInstructionsFile)(root, promptsDir, (0, final_validation_1.buildFinalValidationInstructions)({
|
|
1964
|
+
runId: state.runId,
|
|
1965
|
+
baseRef: state.gitRefAtInit ?? null,
|
|
1966
|
+
checkpointRef: state.commits.find((c) => c.kind === 'checkpoint')?.sha ?? null,
|
|
1967
|
+
nxInvocation: `${(0, util_1.pmExecPrefix)(root)} nx`,
|
|
1968
|
+
handoffFileAbsolutePath: filePath,
|
|
1969
|
+
}));
|
|
1970
|
+
(0, agent_output_1.emitStepPromptBlock)(step.id, { kind: 'final-validation', instructions });
|
|
1971
|
+
return [
|
|
1972
|
+
`Every migration step is done; the run's final validation pass over the workspace is awaiting your outcome.`,
|
|
1973
|
+
`Follow the instructions file named in the <nx_migrate_prompt> block above (${instructions}), then write the handoff file and run the "next" command.`,
|
|
1974
|
+
`Handoff file: ${filePath}`,
|
|
1975
|
+
`Handoff JSON: ${(0, fragments_1.renderHandoffShapeInline)('what you ran, fixed and left')}. If the workspace has nothing to validate, use "status": "success" and say so in the summary.`,
|
|
1976
|
+
];
|
|
1977
|
+
}
|
|
1978
|
+
// The prompt path the run's latest plan snapshot records for the migration.
|
|
1979
|
+
// Every failure lands on null, damaged-but-parseable snapshots included: this
|
|
1980
|
+
// runs while re-handing an awaiting step's work, and throwing here would keep
|
|
1981
|
+
// the run from re-dispensing that work at all. The snapshot name is validated
|
|
1982
|
+
// as a bare `plan-<round>.json` at state read, so the join cannot leave the run
|
|
1983
|
+
// directory.
|
|
1984
|
+
function planPromptPath(dir, state, migrationId) {
|
|
1985
|
+
const round = (0, state_machine_1.latestRound)(state);
|
|
1986
|
+
if (!round)
|
|
1987
|
+
return null;
|
|
1988
|
+
let migrations;
|
|
1989
|
+
try {
|
|
1990
|
+
migrations = (0, fileutils_1.readJsonFile)((0, path_1.join)(dir, round.planSnapshot)).migrations;
|
|
1991
|
+
}
|
|
1992
|
+
catch {
|
|
1993
|
+
return null;
|
|
1994
|
+
}
|
|
1995
|
+
if (!Array.isArray(migrations))
|
|
1996
|
+
return null;
|
|
1997
|
+
for (const entry of migrations) {
|
|
1998
|
+
if (typeof entry !== 'object' || entry === null)
|
|
1999
|
+
continue;
|
|
2000
|
+
const migration = entry;
|
|
2001
|
+
if (`${migration.package}:${migration.name}` !== migrationId)
|
|
2002
|
+
continue;
|
|
2003
|
+
return typeof migration.prompt === 'string' ? migration.prompt : null;
|
|
2004
|
+
}
|
|
2005
|
+
return null;
|
|
2006
|
+
}
|
|
2007
|
+
// Wording mirrors the classic runner's ambiguous-outcome cause lines. A
|
|
2008
|
+
// readable handoff whose issue report is invalid is a rejection too: the fold
|
|
2009
|
+
// refused to consume it, and only this response can tell the agent why.
|
|
2010
|
+
function describeRejectedHandoff(dir, state, step) {
|
|
2011
|
+
const result = readStepHandoff(dir, step.id);
|
|
2012
|
+
const followUp = 'Rewrite the handoff file, then run the "next" command.';
|
|
2013
|
+
if (result.ok === true) {
|
|
2014
|
+
const issues = (0, issues_1.parseHandoffIssues)(result.handoff.extras, state, step);
|
|
2015
|
+
if (issues.ok !== true) {
|
|
2016
|
+
return [
|
|
2017
|
+
`The handoff file was rejected: ${issues.reason}.`,
|
|
2018
|
+
followUp,
|
|
2019
|
+
];
|
|
2020
|
+
}
|
|
2021
|
+
return [];
|
|
2022
|
+
}
|
|
2023
|
+
const { reason, detail } = result;
|
|
2024
|
+
if (reason === 'missing')
|
|
2025
|
+
return [];
|
|
2026
|
+
switch (reason) {
|
|
2027
|
+
case 'read-error':
|
|
2028
|
+
return [
|
|
2029
|
+
`The handoff file was rejected: it could not be read${detail ? ` (${detail})` : ''}.`,
|
|
2030
|
+
followUp,
|
|
2031
|
+
];
|
|
2032
|
+
case 'parse-error':
|
|
2033
|
+
return [
|
|
2034
|
+
`The handoff file was rejected: it contained invalid JSON${detail ? ` (${detail})` : ''}.`,
|
|
2035
|
+
followUp,
|
|
2036
|
+
];
|
|
2037
|
+
case 'shape-mismatch':
|
|
2038
|
+
return [
|
|
2039
|
+
'The handoff file was rejected: it was missing required fields or had an unexpected shape.',
|
|
2040
|
+
followUp,
|
|
2041
|
+
];
|
|
2042
|
+
default: {
|
|
2043
|
+
const exhaustive = reason;
|
|
2044
|
+
throw new Error(`Unrecognized handoff rejection reason '${exhaustive}'.`);
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
// A refused --step-action still exits 0: the tagged error block is the answer
|
|
2049
|
+
// to the request, and it carries the reconcile command to run next. A non-zero
|
|
2050
|
+
// exit would tell the driving agent that reconcile itself crashed, and it
|
|
2051
|
+
// would stop reading for the correction it is being handed.
|
|
2052
|
+
function emitError(root, runId, reason) {
|
|
2053
|
+
// A rejected action is an active response like any dispense, so it carries
|
|
2054
|
+
// the runbook footer: the master receiving it may have just lost its
|
|
2055
|
+
// context. One sanitized array feeds both outputs, as in emit().
|
|
2056
|
+
const lines = (0, agent_output_1.safeLines)([reason, ...runbookFooterLines(root, runId)]);
|
|
2057
|
+
(0, agent_output_1.warnToAgent)({
|
|
2058
|
+
title: 'The requested --step-action could not be applied.',
|
|
2059
|
+
bodyLines: lines,
|
|
2060
|
+
});
|
|
2061
|
+
(0, agent_output_1.emitStepBlock)(runId, '-', 'error', {
|
|
2062
|
+
next: reconcileCommand(root, runId),
|
|
2063
|
+
instructions: lines.join('\n'),
|
|
2064
|
+
});
|
|
2065
|
+
(0, migrate_analytics_1.reportMigrateOrchestratorDispense)({ action: 'error', attempt: 0 });
|
|
2066
|
+
}
|
|
2067
|
+
/**
|
|
2068
|
+
* What a completed run leaves behind for whoever reads its summary, one line
|
|
2069
|
+
* group per warning: commit debt, uninstalled dependency changes, unresolved
|
|
2070
|
+
* issues. Empty when nothing is left.
|
|
2071
|
+
*/
|
|
2072
|
+
function completionWarnings(root, runId, state) {
|
|
2073
|
+
// The crash-refold window can strand a failed ledger entry whose diff was in
|
|
2074
|
+
// fact absorbed; suppress the warning only on a verified-clean tree. A dirty
|
|
2075
|
+
// tree can still be unrelated edits, so the warning only claims the changes
|
|
2076
|
+
// "may remain".
|
|
2077
|
+
const commitDebt = (0, state_machine_1.hasPendingCommitDebt)(state) && (0, git_utils_1.getWorkingTreeStatus)(root) !== 'clean';
|
|
2078
|
+
const uninstalled = state.steps.filter((s) => s.installFailed);
|
|
2079
|
+
const issueLines = (0, issues_1.renderUnresolvedIssueLines)(state, runId);
|
|
2080
|
+
return [
|
|
2081
|
+
...(commitDebt
|
|
2082
|
+
? [
|
|
2083
|
+
[
|
|
2084
|
+
'Some migration changes could not be committed and may remain in the working tree; review and commit them manually.',
|
|
2085
|
+
],
|
|
2086
|
+
]
|
|
2087
|
+
: []),
|
|
2088
|
+
...(uninstalled.length > 0
|
|
2089
|
+
? [
|
|
2090
|
+
[
|
|
2091
|
+
`The dependency changes made by ${uninstalled
|
|
2092
|
+
.map(state_machine_1.stepLabel)
|
|
2093
|
+
.join(', ')} were not installed; run \`${(0, util_1.pmInstallCommand)(root)}\` before using the workspace.`,
|
|
2094
|
+
],
|
|
2095
|
+
]
|
|
2096
|
+
: []),
|
|
2097
|
+
...(issueLines.length > 0 ? [issueLines] : []),
|
|
2098
|
+
];
|
|
2099
|
+
}
|
|
2100
|
+
function completeRun(root, dir, runId, state) {
|
|
2101
|
+
let current = state;
|
|
2102
|
+
// Persist the terminal status and claim the watermark in one fresh-state
|
|
2103
|
+
// write before emitting: a crash between the write and the output can't
|
|
2104
|
+
// double-count the completion, and of two concurrent reconciles exactly one
|
|
2105
|
+
// claims the report.
|
|
2106
|
+
let shouldEmit = false;
|
|
2107
|
+
if (current.status !== 'completed' || !current.analytics.completeEmitted) {
|
|
2108
|
+
current = (0, state_lock_1.updateRunState)(dir, (fresh) => {
|
|
2109
|
+
if (fresh.status === 'completed' && fresh.analytics.completeEmitted) {
|
|
2110
|
+
return null;
|
|
2111
|
+
}
|
|
2112
|
+
shouldEmit = !fresh.analytics.completeEmitted;
|
|
2113
|
+
return {
|
|
2114
|
+
...fresh,
|
|
2115
|
+
status: 'completed',
|
|
2116
|
+
analytics: { ...fresh.analytics, completeEmitted: true },
|
|
2117
|
+
};
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2120
|
+
if (shouldEmit) {
|
|
2121
|
+
(0, migrate_analytics_1.reportMigrateOrchestratorComplete)((0, state_machine_1.runTallies)(current));
|
|
2122
|
+
}
|
|
2123
|
+
const warnings = completionWarnings(root, runId, current);
|
|
2124
|
+
for (const lines of warnings) {
|
|
2125
|
+
(0, agent_output_1.warnToAgent)({ title: lines[0], bodyLines: lines.slice(1) });
|
|
2126
|
+
}
|
|
2127
|
+
const instructionLines = [
|
|
2128
|
+
`Migrate run ${runId} is complete.`,
|
|
2129
|
+
...(0, state_machine_1.completionSummaryLines)(current),
|
|
2130
|
+
...warnings.flat(),
|
|
2131
|
+
];
|
|
2132
|
+
(0, agent_output_1.logToAgent)({ title: 'nx migrate: complete', bodyLines: instructionLines });
|
|
2133
|
+
(0, agent_output_1.emitStepBlock)(runId, '-', 'complete', {
|
|
2134
|
+
instructions: instructionLines.join('\n'),
|
|
2135
|
+
});
|
|
2136
|
+
}
|
|
2137
|
+
function emit(root, runId, state, step, action, payload, noProgress) {
|
|
2138
|
+
// At the escalation threshold the whole response becomes the 'no-progress'
|
|
2139
|
+
// action, with the step's own instructions kept below so acting on them stays
|
|
2140
|
+
// possible. Never a step status: nothing durable changed, and a status would
|
|
2141
|
+
// have to be walked back once the agent acts.
|
|
2142
|
+
const escalated = noProgress !== null;
|
|
2143
|
+
const effectiveAction = escalated ? 'no-progress' : action;
|
|
2144
|
+
const { instructionLines, ...rest } = payload;
|
|
2145
|
+
const allLines = escalated
|
|
2146
|
+
? [...noProgressLines(step, noProgress), ...(instructionLines ?? [])]
|
|
2147
|
+
: instructionLines;
|
|
2148
|
+
const withFooter = allLines
|
|
2149
|
+
? [...allLines, ...runbookFooterLines(root, runId)]
|
|
2150
|
+
: undefined;
|
|
2151
|
+
// One sanitized array feeds both, so the block payload says exactly what the
|
|
2152
|
+
// human echo said.
|
|
2153
|
+
const lines = withFooter ? (0, agent_output_1.safeLines)(withFooter) : undefined;
|
|
2154
|
+
(0, agent_output_1.logToAgent)({ title: `nx migrate: ${effectiveAction}`, bodyLines: lines });
|
|
2155
|
+
(0, agent_output_1.emitStepBlock)(runId, step.id, effectiveAction, {
|
|
2156
|
+
...rest,
|
|
2157
|
+
...(lines ? { instructions: lines.join('\n') } : {}),
|
|
2158
|
+
});
|
|
2159
|
+
(0, migrate_analytics_1.reportMigrateOrchestratorDispense)({
|
|
2160
|
+
action: effectiveAction,
|
|
2161
|
+
attempt: step.attempt,
|
|
2162
|
+
ordinal: (0, state_machine_1.runTallies)(state).dispenseCount,
|
|
2163
|
+
});
|
|
2164
|
+
}
|
|
2165
|
+
function noProgressLines(step, streak) {
|
|
2166
|
+
let subject;
|
|
2167
|
+
switch (step.kind) {
|
|
2168
|
+
case 'migration':
|
|
2169
|
+
subject = `migration ${step.migrationId}`;
|
|
2170
|
+
break;
|
|
2171
|
+
case 'final-validation':
|
|
2172
|
+
subject = 'the final validation pass';
|
|
2173
|
+
break;
|
|
2174
|
+
default: {
|
|
2175
|
+
const exhaustive = step;
|
|
2176
|
+
throw new Error(`Unrecognized step: ${JSON.stringify(exhaustive)}`);
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
return [
|
|
2180
|
+
`No progress: this is response ${streak.consecutiveCount} in a row for ${subject} with no change in the run's recorded state since ${streak.firstSeenAt}.`,
|
|
2181
|
+
`Re-running the reconcile command changes nothing on its own; act on the instructions below. If something is blocking you from acting on them, stop looping and report the blocker to the user.`,
|
|
2182
|
+
``,
|
|
2183
|
+
];
|
|
2184
|
+
}
|
|
2185
|
+
// Append the runbook path to init, active and rejected responses so a
|
|
2186
|
+
// compacted, truncated or restarted session can recover the contract. Missing
|
|
2187
|
+
// or non-regular runbooks stand alone.
|
|
2188
|
+
function runbookFooterLines(root, runId) {
|
|
2189
|
+
if (lstatRunbook((0, path_1.join)((0, run_state_1.runDir)(root, runId), runbook_1.RUNBOOK_FILE_NAME))?.isFile() !==
|
|
2190
|
+
true) {
|
|
2191
|
+
return [];
|
|
2192
|
+
}
|
|
2193
|
+
return [
|
|
2194
|
+
``,
|
|
2195
|
+
`Runbook: ${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runId}/${runbook_1.RUNBOOK_FILE_NAME}. After a compaction or restart, re-read it and run \`${reconcileCommand(root, runId)}\`; never infer the run's progress from memory.`,
|
|
2196
|
+
];
|
|
2197
|
+
}
|
|
2198
|
+
// Raw argv is forwarded verbatim across the wrapper hops, so every flag is a
|
|
2199
|
+
// single `--flag=value` token. Interpolated values are validated shell-safe at
|
|
2200
|
+
// init (migration ids; resumed run ids are gated by the run-dir scan) and
|
|
2201
|
+
// reconcile entry (run id).
|
|
2202
|
+
function workerCommand(root, migrationId, runId) {
|
|
2203
|
+
return `${(0, util_1.pmExecPrefix)(root)} nx migrate --run-migration=${migrationId} --run-id=${runId}`;
|
|
2204
|
+
}
|
|
2205
|
+
function reconcileCommand(root, runId, action) {
|
|
2206
|
+
const base = `${(0, util_1.pmExecPrefix)(root)} nx migrate --run-id=${runId}`;
|
|
2207
|
+
return action ? `${base} --step-action=${action}` : base;
|
|
2208
|
+
}
|
|
2209
|
+
// Records what the workspace looked like as this attempt starts. The git ref
|
|
2210
|
+
// and the tree state are re-captured per dispense, since a retry restarts from
|
|
2211
|
+
// wherever the tree is now. The dependency baseline is not: it tracks the last
|
|
2212
|
+
// dependencies that were actually installed, moving only when an install
|
|
2213
|
+
// lands, so a retry that only has the commit left to do still sees the
|
|
2214
|
+
// previous attempt's package.json edits as needing one.
|
|
2215
|
+
function setDispenseBaselines(state, stepId, baselines) {
|
|
2216
|
+
const depsBaseline = state.steps.find((s) => s.id === stepId)?.depsHashAtDispense;
|
|
2217
|
+
return {
|
|
2218
|
+
...state,
|
|
2219
|
+
steps: state.steps.map((s) => s.id === stepId
|
|
2220
|
+
? {
|
|
2221
|
+
...s,
|
|
2222
|
+
gitRefBefore: baselines.gitRefBefore,
|
|
2223
|
+
treeCleanAtDispense: baselines.treeCleanAtDispense,
|
|
2224
|
+
depsHashAtDispense: depsBaseline ?? baselines.depsHashAtDispense ?? undefined,
|
|
2225
|
+
}
|
|
2226
|
+
: s),
|
|
2227
|
+
};
|
|
2228
|
+
}
|
|
2229
|
+
// Applies a step event to fresh state or throws the orchestrator's advance
|
|
2230
|
+
// error. Pure; callers persist the result via updateRunState.
|
|
2231
|
+
function applyEventOrThrow(state, event) {
|
|
2232
|
+
const result = (0, state_machine_1.applyStepEvent)(state, event);
|
|
2233
|
+
if (result.kind === 'error') {
|
|
2234
|
+
throw new Error(`Orchestrator could not advance the run: ${result.reason}`);
|
|
2235
|
+
}
|
|
2236
|
+
return result.state;
|
|
2237
|
+
}
|
|
2238
|
+
function readStepHandoff(dir, stepId) {
|
|
2239
|
+
return (0, handoff_1.readHandoffWithReason)((0, handoff_1.runStepHandoffPath)(dir, stepId), (0, run_state_1.runHandoffsDir)(dir));
|
|
2240
|
+
}
|
|
2241
|
+
// Probe-time guard: a handoffs dir the agent swapped for a symlink into a
|
|
2242
|
+
// directory holding a file of the step's fixed name would otherwise have the
|
|
2243
|
+
// orchestrator delete that file. A swap between the probe and the rm is not
|
|
2244
|
+
// caught. A probe failure skips the rm too; the next read reports it.
|
|
2245
|
+
function removeHandoff(dir, stepId) {
|
|
2246
|
+
let state;
|
|
2247
|
+
try {
|
|
2248
|
+
state = (0, handoff_1.handoffsDirState)((0, run_state_1.runHandoffsDir)(dir));
|
|
2249
|
+
}
|
|
2250
|
+
catch {
|
|
2251
|
+
return;
|
|
2252
|
+
}
|
|
2253
|
+
if (state === 'directory') {
|
|
2254
|
+
(0, fs_1.rmSync)((0, handoff_1.runStepHandoffPath)(dir, stepId), { force: true });
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
// null means the probe itself failed; the death dispense renders that as
|
|
2258
|
+
// '(unknown)', because '(clean)' would invite a retry-clean reset over
|
|
2259
|
+
// evidence that was never gathered (getWorkingTreeStatus's contract).
|
|
2260
|
+
function dirtyTreeSummary(root) {
|
|
2261
|
+
try {
|
|
2262
|
+
return (0, child_process_1.execSync)('git status --porcelain', {
|
|
2263
|
+
encoding: 'utf8',
|
|
2264
|
+
cwd: root,
|
|
2265
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
2266
|
+
windowsHide: true,
|
|
2267
|
+
}).trim();
|
|
2268
|
+
}
|
|
2269
|
+
catch {
|
|
2270
|
+
return null;
|
|
2271
|
+
}
|
|
2272
|
+
}
|