agentplane 0.3.6 → 0.3.8
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/assets/AGENTS.md +11 -1
- package/assets/RUNNER.md +17 -0
- package/bin/agentplane.js +16 -7
- package/bin/framework-dev-contract.d.ts +6 -0
- package/bin/framework-dev-contract.js +13 -0
- package/bin/stale-dist-policy.js +6 -1
- package/dist/.build-manifest.json +724 -359
- package/dist/adapters/task-backend/task-backend-adapter.d.ts +4 -2
- package/dist/adapters/task-backend/task-backend-adapter.d.ts.map +1 -1
- package/dist/adapters/task-backend/task-backend-adapter.js +15 -2
- package/dist/backends/task-backend/local-backend-doc.d.ts +5 -0
- package/dist/backends/task-backend/local-backend-doc.d.ts.map +1 -0
- package/dist/backends/task-backend/local-backend-doc.js +98 -0
- package/dist/backends/task-backend/local-backend-read.d.ts +7 -0
- package/dist/backends/task-backend/local-backend-read.d.ts.map +1 -0
- package/dist/backends/task-backend/local-backend-read.js +186 -0
- package/dist/backends/task-backend/local-backend-state.d.ts +17 -0
- package/dist/backends/task-backend/local-backend-state.d.ts.map +1 -0
- package/dist/backends/task-backend/local-backend-state.js +50 -0
- package/dist/backends/task-backend/local-backend-write.d.ts +15 -0
- package/dist/backends/task-backend/local-backend-write.d.ts.map +1 -0
- package/dist/backends/task-backend/local-backend-write.js +254 -0
- package/dist/backends/task-backend/local-backend.d.ts +10 -6
- package/dist/backends/task-backend/local-backend.d.ts.map +1 -1
- package/dist/backends/task-backend/local-backend.js +32 -337
- package/dist/backends/task-backend/redmine/backend-cache-doc.d.ts +40 -0
- package/dist/backends/task-backend/redmine/backend-cache-doc.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-cache-doc.js +178 -0
- package/dist/backends/task-backend/redmine/backend-report.d.ts +10 -0
- package/dist/backends/task-backend/redmine/backend-report.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-report.js +43 -0
- package/dist/backends/task-backend/redmine/backend-sync.d.ts +67 -0
- package/dist/backends/task-backend/redmine/backend-sync.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-sync.js +367 -0
- package/dist/backends/task-backend/redmine/env.d.ts +1 -1
- package/dist/backends/task-backend/redmine/env.d.ts.map +1 -1
- package/dist/backends/task-backend/redmine/env.js +3 -0
- package/dist/backends/task-backend/redmine/inspect.d.ts +11 -0
- package/dist/backends/task-backend/redmine/inspect.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/inspect.js +75 -0
- package/dist/backends/task-backend/redmine/mapping.d.ts +2 -1
- package/dist/backends/task-backend/redmine/mapping.d.ts.map +1 -1
- package/dist/backends/task-backend/redmine/mapping.js +32 -3
- package/dist/backends/task-backend/redmine/parse.d.ts +2 -1
- package/dist/backends/task-backend/redmine/parse.d.ts.map +1 -1
- package/dist/backends/task-backend/redmine/parse.js +5 -3
- package/dist/backends/task-backend/redmine/state.d.ts +19 -0
- package/dist/backends/task-backend/redmine/state.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/state.js +109 -0
- package/dist/backends/task-backend/redmine-backend.d.ts +14 -17
- package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
- package/dist/backends/task-backend/redmine-backend.js +121 -379
- package/dist/backends/task-backend/shared/constants.d.ts +2 -1
- package/dist/backends/task-backend/shared/constants.d.ts.map +1 -1
- package/dist/backends/task-backend/shared/constants.js +1 -1
- package/dist/backends/task-backend/shared/doc.d.ts.map +1 -1
- package/dist/backends/task-backend/shared/doc.js +25 -39
- package/dist/backends/task-backend/shared/export.d.ts +2 -9
- package/dist/backends/task-backend/shared/export.d.ts.map +1 -1
- package/dist/backends/task-backend/shared/export.js +73 -8
- package/dist/backends/task-backend/shared/normalize.d.ts +5 -1
- package/dist/backends/task-backend/shared/normalize.d.ts.map +1 -1
- package/dist/backends/task-backend/shared/normalize.js +166 -0
- package/dist/backends/task-backend/shared/record.d.ts +1 -1
- package/dist/backends/task-backend/shared/record.d.ts.map +1 -1
- package/dist/backends/task-backend/shared/record.js +27 -3
- package/dist/backends/task-backend/shared/types.d.ts +76 -36
- package/dist/backends/task-backend/shared/types.d.ts.map +1 -1
- package/dist/backends/task-backend/shared.d.ts +2 -2
- package/dist/backends/task-backend/shared.d.ts.map +1 -1
- package/dist/backends/task-backend/shared.js +1 -1
- package/dist/backends/task-backend.d.ts +1 -1
- package/dist/backends/task-backend.d.ts.map +1 -1
- package/dist/backends/task-backend.js +1 -1
- package/dist/backends/task-index.d.ts +2 -2
- package/dist/backends/task-index.d.ts.map +1 -1
- package/dist/backends/task-index.js +9 -5
- package/dist/cli/bootstrap-guide.d.ts +2 -2
- package/dist/cli/bootstrap-guide.d.ts.map +1 -1
- package/dist/cli/bootstrap-guide.js +10 -10
- package/dist/cli/command-guide.d.ts.map +1 -1
- package/dist/cli/command-guide.js +11 -9
- package/dist/cli/command-invocations.d.ts +4 -0
- package/dist/cli/command-invocations.d.ts.map +1 -0
- package/dist/cli/command-invocations.js +35 -0
- package/dist/cli/command-snippets.d.ts +12 -8
- package/dist/cli/command-snippets.d.ts.map +1 -1
- package/dist/cli/command-snippets.js +14 -8
- package/dist/cli/exit-codes.d.ts.map +1 -1
- package/dist/cli/exit-codes.js +1 -0
- package/dist/cli/group-command.d.ts +18 -0
- package/dist/cli/group-command.d.ts.map +1 -0
- package/dist/cli/group-command.js +45 -0
- package/dist/cli/output.d.ts +29 -0
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +76 -0
- package/dist/cli/prompts.d.ts.map +1 -1
- package/dist/cli/prompts.js +5 -1
- package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/core.js +38 -29
- package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/lifecycle.js +9 -6
- package/dist/cli/run-cli/command-catalog/project.d.ts +1 -1
- package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/project.js +11 -7
- package/dist/cli/run-cli/command-catalog/shared.d.ts +12 -3
- package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/shared.js +6 -3
- package/dist/cli/run-cli/command-catalog/task.d.ts +1 -1
- package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/task.js +46 -11
- package/dist/cli/run-cli/command-catalog.d.ts +11 -1
- package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog.js +29 -0
- package/dist/cli/run-cli/commands/config.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/config.js +52 -6
- package/dist/cli/run-cli/commands/core/agent-profiles.d.ts +34 -0
- package/dist/cli/run-cli/commands/core/agent-profiles.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/core/agent-profiles.js +97 -0
- package/dist/cli/run-cli/commands/core/agents.d.ts +7 -0
- package/dist/cli/run-cli/commands/core/agents.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/core/agents.js +97 -0
- package/dist/cli/run-cli/commands/core/preflight.d.ts +10 -0
- package/dist/cli/run-cli/commands/core/preflight.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/core/preflight.js +286 -0
- package/dist/cli/run-cli/commands/core/quickstart.d.ts +8 -0
- package/dist/cli/run-cli/commands/core/quickstart.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/core/quickstart.js +43 -0
- package/dist/cli/run-cli/commands/core/role.d.ts +9 -0
- package/dist/cli/run-cli/commands/core/role.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/core/role.js +128 -0
- package/dist/cli/run-cli/commands/core.d.ts +4 -24
- package/dist/cli/run-cli/commands/core.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/core.js +4 -630
- package/dist/cli/run-cli/commands/init/write-env.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/write-env.js +12 -0
- package/dist/cli/run-cli/error-guidance.js +10 -0
- package/dist/cli/run-cli/globals.d.ts +5 -2
- package/dist/cli/run-cli/globals.d.ts.map +1 -1
- package/dist/cli/run-cli/globals.js +82 -86
- package/dist/cli/run-cli.d.ts.map +1 -1
- package/dist/cli/run-cli.js +137 -100
- package/dist/cli/run-cli.test-helpers.d.ts +21 -0
- package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
- package/dist/cli/run-cli.test-helpers.js +90 -4
- package/dist/cli/spec/help.d.ts +10 -2
- package/dist/cli/spec/help.d.ts.map +1 -1
- package/dist/cli/spec/help.js +7 -5
- package/dist/cli/spec/registry.d.ts +27 -1
- package/dist/cli/spec/registry.d.ts.map +1 -1
- package/dist/cli/spec/registry.js +98 -25
- package/dist/commands/backend/sync.command.d.ts +8 -6
- package/dist/commands/backend/sync.command.d.ts.map +1 -1
- package/dist/commands/backend/sync.command.js +75 -14
- package/dist/commands/backend.d.ts +22 -0
- package/dist/commands/backend.d.ts.map +1 -1
- package/dist/commands/backend.js +111 -1
- package/dist/commands/branch/base.command.d.ts +2 -3
- package/dist/commands/branch/base.command.d.ts.map +1 -1
- package/dist/commands/branch/base.command.js +8 -12
- package/dist/commands/branch/base.d.ts.map +1 -1
- package/dist/commands/branch/base.js +11 -7
- package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
- package/dist/commands/branch/cleanup-merged.js +9 -8
- package/dist/commands/branch/remove.d.ts.map +1 -1
- package/dist/commands/branch/remove.js +4 -3
- package/dist/commands/branch/status.d.ts.map +1 -1
- package/dist/commands/branch/status.js +4 -3
- package/dist/commands/branch/work-start.d.ts.map +1 -1
- package/dist/commands/branch/work-start.js +48 -5
- package/dist/commands/cleanup/merged.command.d.ts +2 -3
- package/dist/commands/cleanup/merged.command.d.ts.map +1 -1
- package/dist/commands/cleanup/merged.command.js +8 -12
- package/dist/commands/commit.spec.d.ts.map +1 -1
- package/dist/commands/commit.spec.js +30 -6
- package/dist/commands/docs/cli.command.js +2 -2
- package/dist/commands/doctor/runtime.js +1 -1
- package/dist/commands/doctor/workflow.d.ts.map +1 -1
- package/dist/commands/doctor/workflow.js +10 -1
- package/dist/commands/doctor/workspace.d.ts +8 -0
- package/dist/commands/doctor/workspace.d.ts.map +1 -1
- package/dist/commands/doctor/workspace.js +127 -3
- package/dist/commands/finish.spec.d.ts.map +1 -1
- package/dist/commands/finish.spec.js +7 -0
- package/dist/commands/guard/commit.command.d.ts.map +1 -1
- package/dist/commands/guard/commit.command.js +30 -6
- package/dist/commands/guard/guard.command.d.ts +3 -3
- package/dist/commands/guard/guard.command.d.ts.map +1 -1
- package/dist/commands/guard/guard.command.js +9 -14
- package/dist/commands/guard/impl/allow.d.ts +4 -0
- package/dist/commands/guard/impl/allow.d.ts.map +1 -1
- package/dist/commands/guard/impl/allow.js +14 -3
- package/dist/commands/guard/impl/commands.d.ts +2 -0
- package/dist/commands/guard/impl/commands.d.ts.map +1 -1
- package/dist/commands/guard/impl/commands.js +66 -9
- package/dist/commands/guard/impl/policy.d.ts +1 -0
- package/dist/commands/guard/impl/policy.d.ts.map +1 -1
- package/dist/commands/guard/impl/policy.js +9 -6
- package/dist/commands/hooks/hooks.command.d.ts +3 -3
- package/dist/commands/hooks/hooks.command.d.ts.map +1 -1
- package/dist/commands/hooks/hooks.command.js +9 -11
- package/dist/commands/pr/check.d.ts.map +1 -1
- package/dist/commands/pr/check.js +90 -18
- package/dist/commands/pr/integrate/cmd.d.ts.map +1 -1
- package/dist/commands/pr/integrate/cmd.js +31 -3
- package/dist/commands/pr/integrate/internal/cleanup.d.ts +12 -0
- package/dist/commands/pr/integrate/internal/cleanup.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/cleanup.js +46 -0
- package/dist/commands/pr/integrate/internal/finalize.d.ts +4 -0
- package/dist/commands/pr/integrate/internal/finalize.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/finalize.js +34 -40
- package/dist/commands/pr/integrate/internal/merge.d.ts +6 -0
- package/dist/commands/pr/integrate/internal/merge.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/merge.js +92 -0
- package/dist/commands/pr/integrate/internal/prepare.d.ts +1 -0
- package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/prepare.js +1 -0
- package/dist/commands/pr/integrate/verify.d.ts.map +1 -1
- package/dist/commands/pr/integrate/verify.js +4 -3
- package/dist/commands/pr/note.d.ts.map +1 -1
- package/dist/commands/pr/note.js +3 -2
- package/dist/commands/pr/open.d.ts.map +1 -1
- package/dist/commands/pr/open.js +9 -12
- package/dist/commands/pr/pr.command.d.ts +3 -4
- package/dist/commands/pr/pr.command.d.ts.map +1 -1
- package/dist/commands/pr/pr.command.js +6 -11
- package/dist/commands/pr/update.d.ts.map +1 -1
- package/dist/commands/pr/update.js +5 -10
- package/dist/commands/recipes/cache.command.d.ts +3 -4
- package/dist/commands/recipes/cache.command.d.ts.map +1 -1
- package/dist/commands/recipes/cache.command.js +8 -26
- package/dist/commands/recipes/impl/apply.d.ts +1 -1
- package/dist/commands/recipes/impl/apply.d.ts.map +1 -1
- package/dist/commands/recipes/impl/apply.js +1 -1
- package/dist/commands/recipes/impl/commands/explain.js +1 -1
- package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/install.js +1 -2
- package/dist/commands/recipes/impl/installed-recipes.d.ts +1 -1
- package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -1
- package/dist/commands/recipes/impl/installed-recipes.js +1 -2
- package/dist/commands/recipes/impl/manifest.d.ts.map +1 -1
- package/dist/commands/recipes/impl/manifest.js +0 -10
- package/dist/commands/recipes/impl/project-installed-recipes.d.ts +1 -1
- package/dist/commands/recipes/impl/project-installed-recipes.d.ts.map +1 -1
- package/dist/commands/recipes/impl/project-installed-recipes.js +1 -2
- package/dist/commands/recipes/impl/resolver.d.ts +1 -1
- package/dist/commands/recipes/impl/resolver.d.ts.map +1 -1
- package/dist/commands/recipes/impl/resolver.js +26 -16
- package/dist/commands/recipes/impl/scenario.d.ts.map +1 -1
- package/dist/commands/recipes/impl/scenario.js +80 -0
- package/dist/commands/recipes/impl/types.d.ts +27 -13
- package/dist/commands/recipes/impl/types.d.ts.map +1 -1
- package/dist/commands/recipes/recipes.command.d.ts +3 -4
- package/dist/commands/recipes/recipes.command.d.ts.map +1 -1
- package/dist/commands/recipes/recipes.command.js +8 -34
- package/dist/commands/recipes.d.ts +4 -4
- package/dist/commands/recipes.d.ts.map +1 -1
- package/dist/commands/recipes.js +3 -3
- package/dist/commands/recipes.test-helpers.d.ts +17 -0
- package/dist/commands/recipes.test-helpers.d.ts.map +1 -1
- package/dist/commands/recipes.test-helpers.js +56 -2
- package/dist/commands/release/apply.command.d.ts.map +1 -1
- package/dist/commands/release/apply.command.js +77 -56
- package/dist/commands/release/plan.command.d.ts.map +1 -1
- package/dist/commands/release/plan.command.js +7 -3
- package/dist/commands/release/release.command.d.ts +3 -3
- package/dist/commands/release/release.command.d.ts.map +1 -1
- package/dist/commands/release/release.command.js +9 -11
- package/dist/commands/release.test-helpers.d.ts +20 -0
- package/dist/commands/release.test-helpers.d.ts.map +1 -0
- package/dist/commands/release.test-helpers.js +37 -0
- package/dist/commands/runtime.command.d.ts +7 -7
- package/dist/commands/runtime.command.d.ts.map +1 -1
- package/dist/commands/runtime.command.js +29 -33
- package/dist/commands/scenario/execute.command.d.ts +8 -0
- package/dist/commands/scenario/execute.command.d.ts.map +1 -0
- package/dist/commands/scenario/execute.command.js +117 -0
- package/dist/commands/scenario/impl/commands.d.ts.map +1 -1
- package/dist/commands/scenario/impl/commands.js +45 -32
- package/dist/commands/scenario/run.command.js +2 -2
- package/dist/commands/scenario/scenario.command.d.ts +3 -4
- package/dist/commands/scenario/scenario.command.d.ts.map +1 -1
- package/dist/commands/scenario/scenario.command.js +8 -26
- package/dist/commands/shared/git-context.d.ts +1 -0
- package/dist/commands/shared/git-context.d.ts.map +1 -1
- package/dist/commands/shared/git-context.js +4 -2
- package/dist/commands/shared/git-ops.d.ts +1 -0
- package/dist/commands/shared/git-ops.d.ts.map +1 -1
- package/dist/commands/shared/git-ops.js +13 -0
- package/dist/commands/shared/operator-pipeline.d.ts +10 -0
- package/dist/commands/shared/operator-pipeline.d.ts.map +1 -0
- package/dist/commands/shared/operator-pipeline.js +16 -0
- package/dist/commands/shared/pr-meta.d.ts +32 -12
- package/dist/commands/shared/pr-meta.d.ts.map +1 -1
- package/dist/commands/shared/pr-meta.js +49 -14
- package/dist/commands/shared/reconcile-check.d.ts.map +1 -1
- package/dist/commands/shared/reconcile-check.js +28 -3
- package/dist/commands/shared/task-backend.d.ts +11 -7
- package/dist/commands/shared/task-backend.d.ts.map +1 -1
- package/dist/commands/shared/task-backend.js +107 -24
- package/dist/commands/shared/task-handoff.d.ts +64 -0
- package/dist/commands/shared/task-handoff.d.ts.map +1 -0
- package/dist/commands/shared/task-handoff.js +151 -0
- package/dist/commands/shared/task-mutation.d.ts +36 -0
- package/dist/commands/shared/task-mutation.d.ts.map +1 -0
- package/dist/commands/shared/task-mutation.js +67 -0
- package/dist/commands/shared/task-store.d.ts +65 -2
- package/dist/commands/shared/task-store.d.ts.map +1 -1
- package/dist/commands/shared/task-store.js +309 -91
- package/dist/commands/task/add.d.ts.map +1 -1
- package/dist/commands/task/add.js +41 -39
- package/dist/commands/task/block.d.ts.map +1 -1
- package/dist/commands/task/block.js +31 -89
- package/dist/commands/task/close-duplicate.d.ts.map +1 -1
- package/dist/commands/task/close-duplicate.js +0 -7
- package/dist/commands/task/close-noop.d.ts.map +1 -1
- package/dist/commands/task/close-noop.js +0 -21
- package/dist/commands/task/close-shared.d.ts +0 -2
- package/dist/commands/task/close-shared.d.ts.map +1 -1
- package/dist/commands/task/close-shared.js +24 -57
- package/dist/commands/task/comment.d.ts.map +1 -1
- package/dist/commands/task/comment.js +48 -42
- package/dist/commands/task/derive.command.d.ts +1 -0
- package/dist/commands/task/derive.command.d.ts.map +1 -1
- package/dist/commands/task/derive.command.js +15 -2
- package/dist/commands/task/derive.d.ts +1 -0
- package/dist/commands/task/derive.d.ts.map +1 -1
- package/dist/commands/task/derive.js +37 -7
- package/dist/commands/task/doc.command.d.ts.map +1 -1
- package/dist/commands/task/doc.command.js +7 -6
- package/dist/commands/task/doc.d.ts.map +1 -1
- package/dist/commands/task/doc.js +68 -61
- package/dist/commands/task/finish-shared.d.ts +60 -0
- package/dist/commands/task/finish-shared.d.ts.map +1 -0
- package/dist/commands/task/finish-shared.js +181 -0
- package/dist/commands/task/finish.d.ts +1 -0
- package/dist/commands/task/finish.d.ts.map +1 -1
- package/dist/commands/task/finish.js +73 -204
- package/dist/commands/task/handoff-record.command.d.ts +17 -0
- package/dist/commands/task/handoff-record.command.d.ts.map +1 -0
- package/dist/commands/task/handoff-record.command.js +140 -0
- package/dist/commands/task/handoff-show.command.d.ts +8 -0
- package/dist/commands/task/handoff-show.command.d.ts.map +1 -0
- package/dist/commands/task/handoff-show.command.js +77 -0
- package/dist/commands/task/handoff.command.d.ts +7 -0
- package/dist/commands/task/handoff.command.d.ts.map +1 -0
- package/dist/commands/task/handoff.command.js +21 -0
- package/dist/commands/task/handoff.shared.d.ts +39 -0
- package/dist/commands/task/handoff.shared.d.ts.map +1 -0
- package/dist/commands/task/handoff.shared.js +134 -0
- package/dist/commands/task/hosted-close.command.d.ts +9 -0
- package/dist/commands/task/hosted-close.command.d.ts.map +1 -0
- package/dist/commands/task/hosted-close.command.js +190 -0
- package/dist/commands/task/hosted-merge-sync.d.ts +40 -0
- package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -0
- package/dist/commands/task/hosted-merge-sync.js +277 -0
- package/dist/commands/task/list.d.ts.map +1 -1
- package/dist/commands/task/list.js +7 -24
- package/dist/commands/task/migrate-doc.d.ts +15 -0
- package/dist/commands/task/migrate-doc.d.ts.map +1 -1
- package/dist/commands/task/migrate-doc.js +126 -35
- package/dist/commands/task/new.d.ts.map +1 -1
- package/dist/commands/task/new.js +26 -4
- package/dist/commands/task/next.d.ts.map +1 -1
- package/dist/commands/task/next.js +10 -28
- package/dist/commands/task/normalize.command.d.ts +1 -0
- package/dist/commands/task/normalize.command.d.ts.map +1 -1
- package/dist/commands/task/normalize.command.js +12 -0
- package/dist/commands/task/normalize.d.ts +1 -0
- package/dist/commands/task/normalize.d.ts.map +1 -1
- package/dist/commands/task/normalize.js +21 -9
- package/dist/commands/task/plan.command.d.ts +3 -4
- package/dist/commands/task/plan.command.d.ts.map +1 -1
- package/dist/commands/task/plan.command.js +6 -12
- package/dist/commands/task/plan.d.ts.map +1 -1
- package/dist/commands/task/plan.js +118 -125
- package/dist/commands/task/reclaim.command.d.ts +11 -0
- package/dist/commands/task/reclaim.command.d.ts.map +1 -0
- package/dist/commands/task/reclaim.command.js +102 -0
- package/dist/commands/task/resume-context.command.d.ts +9 -0
- package/dist/commands/task/resume-context.command.d.ts.map +1 -0
- package/dist/commands/task/resume-context.command.js +60 -0
- package/dist/commands/task/run-cancel.command.d.ts +6 -0
- package/dist/commands/task/run-cancel.command.d.ts.map +1 -0
- package/dist/commands/task/run-cancel.command.js +45 -0
- package/dist/commands/task/run-cancel.spec.d.ts +7 -0
- package/dist/commands/task/run-cancel.spec.d.ts.map +1 -0
- package/dist/commands/task/run-cancel.spec.js +20 -0
- package/dist/commands/task/run-resume.command.d.ts +6 -0
- package/dist/commands/task/run-resume.command.d.ts.map +1 -0
- package/dist/commands/task/run-resume.command.js +55 -0
- package/dist/commands/task/run-resume.spec.d.ts +7 -0
- package/dist/commands/task/run-resume.spec.d.ts.map +1 -0
- package/dist/commands/task/run-resume.spec.js +20 -0
- package/dist/commands/task/run-retry.command.d.ts +6 -0
- package/dist/commands/task/run-retry.command.d.ts.map +1 -0
- package/dist/commands/task/run-retry.command.js +56 -0
- package/dist/commands/task/run-retry.spec.d.ts +7 -0
- package/dist/commands/task/run-retry.spec.d.ts.map +1 -0
- package/dist/commands/task/run-retry.spec.js +20 -0
- package/dist/commands/task/run-show.command.d.ts +6 -0
- package/dist/commands/task/run-show.command.d.ts.map +1 -0
- package/dist/commands/task/run-show.command.js +133 -0
- package/dist/commands/task/run-show.spec.d.ts +8 -0
- package/dist/commands/task/run-show.spec.d.ts.map +1 -0
- package/dist/commands/task/run-show.spec.js +44 -0
- package/dist/commands/task/run-tail.command.d.ts +6 -0
- package/dist/commands/task/run-tail.command.d.ts.map +1 -0
- package/dist/commands/task/run-tail.command.js +26 -0
- package/dist/commands/task/run-tail.spec.d.ts +8 -0
- package/dist/commands/task/run-tail.spec.d.ts.map +1 -0
- package/dist/commands/task/run-tail.spec.js +51 -0
- package/dist/commands/task/run-trace.command.d.ts +6 -0
- package/dist/commands/task/run-trace.command.d.ts.map +1 -0
- package/dist/commands/task/run-trace.command.js +25 -0
- package/dist/commands/task/run-trace.spec.d.ts +7 -0
- package/dist/commands/task/run-trace.spec.d.ts.map +1 -0
- package/dist/commands/task/run-trace.spec.js +31 -0
- package/dist/commands/task/run.command.d.ts +6 -0
- package/dist/commands/task/run.command.d.ts.map +1 -0
- package/dist/commands/task/run.command.js +74 -0
- package/dist/commands/task/run.spec.d.ts +7 -0
- package/dist/commands/task/run.spec.d.ts.map +1 -0
- package/dist/commands/task/run.spec.js +26 -0
- package/dist/commands/task/scaffold.d.ts.map +1 -1
- package/dist/commands/task/scaffold.js +4 -2
- package/dist/commands/task/scrub.d.ts.map +1 -1
- package/dist/commands/task/scrub.js +27 -24
- package/dist/commands/task/search.d.ts.map +1 -1
- package/dist/commands/task/search.js +21 -31
- package/dist/commands/task/set-status.d.ts.map +1 -1
- package/dist/commands/task/set-status.js +38 -111
- package/dist/commands/task/shared/dependencies.d.ts +5 -4
- package/dist/commands/task/shared/dependencies.d.ts.map +1 -1
- package/dist/commands/task/shared/dependencies.js +20 -2
- package/dist/commands/task/shared/docs.d.ts +6 -1
- package/dist/commands/task/shared/docs.d.ts.map +1 -1
- package/dist/commands/task/shared/docs.js +14 -1
- package/dist/commands/task/shared/listing.d.ts +16 -2
- package/dist/commands/task/shared/listing.d.ts.map +1 -1
- package/dist/commands/task/shared/listing.js +56 -0
- package/dist/commands/task/shared/transition-command.d.ts +15 -0
- package/dist/commands/task/shared/transition-command.d.ts.map +1 -0
- package/dist/commands/task/shared/transition-command.js +43 -0
- package/dist/commands/task/shared/transitions.d.ts +56 -0
- package/dist/commands/task/shared/transitions.d.ts.map +1 -1
- package/dist/commands/task/shared/transitions.js +82 -8
- package/dist/commands/task/shared/workflow-transition-service.d.ts +75 -0
- package/dist/commands/task/shared/workflow-transition-service.d.ts.map +1 -0
- package/dist/commands/task/shared/workflow-transition-service.js +226 -0
- package/dist/commands/task/shared.d.ts +6 -4
- package/dist/commands/task/shared.d.ts.map +1 -1
- package/dist/commands/task/shared.js +6 -4
- package/dist/commands/task/show.d.ts.map +1 -1
- package/dist/commands/task/show.js +37 -3
- package/dist/commands/task/start.d.ts.map +1 -1
- package/dist/commands/task/start.js +32 -113
- package/dist/commands/task/task.command.d.ts +3 -4
- package/dist/commands/task/task.command.d.ts.map +1 -1
- package/dist/commands/task/task.command.js +22 -37
- package/dist/commands/task/verify-record.d.ts.map +1 -1
- package/dist/commands/task/verify-record.js +21 -146
- package/dist/commands/task/verify.command.d.ts.map +1 -1
- package/dist/commands/task/verify.command.js +7 -6
- package/dist/commands/task.test-helpers.d.ts +13 -0
- package/dist/commands/task.test-helpers.d.ts.map +1 -0
- package/dist/commands/task.test-helpers.js +65 -0
- package/dist/commands/upgrade/apply.d.ts +2 -0
- package/dist/commands/upgrade/apply.d.ts.map +1 -1
- package/dist/commands/upgrade/apply.js +33 -1
- package/dist/commands/upgrade/materialize.d.ts +28 -0
- package/dist/commands/upgrade/materialize.d.ts.map +1 -0
- package/dist/commands/upgrade/materialize.js +154 -0
- package/dist/commands/upgrade/plan.d.ts +18 -0
- package/dist/commands/upgrade/plan.d.ts.map +1 -0
- package/dist/commands/upgrade/plan.js +219 -0
- package/dist/commands/upgrade/policy.d.ts +24 -0
- package/dist/commands/upgrade/policy.d.ts.map +1 -0
- package/dist/commands/upgrade/policy.js +182 -0
- package/dist/commands/upgrade/report.d.ts.map +1 -1
- package/dist/commands/upgrade/report.js +7 -5
- package/dist/commands/upgrade.command.d.ts.map +1 -1
- package/dist/commands/upgrade.command.js +25 -0
- package/dist/commands/upgrade.d.ts +1 -0
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +164 -618
- package/dist/commands/workflow.command.d.ts +3 -4
- package/dist/commands/workflow.command.d.ts.map +1 -1
- package/dist/commands/workflow.command.js +8 -25
- package/dist/policy/rules/allowlist.d.ts.map +1 -1
- package/dist/policy/rules/allowlist.js +12 -9
- package/dist/ports/task-backend-port.d.ts +4 -2
- package/dist/ports/task-backend-port.d.ts.map +1 -1
- package/dist/runner/adapters/codex.d.ts +9 -0
- package/dist/runner/adapters/codex.d.ts.map +1 -0
- package/dist/runner/adapters/codex.js +414 -0
- package/dist/runner/adapters/custom.d.ts +12 -0
- package/dist/runner/adapters/custom.d.ts.map +1 -0
- package/dist/runner/adapters/custom.js +512 -0
- package/dist/runner/adapters/index.d.ts +8 -0
- package/dist/runner/adapters/index.d.ts.map +1 -0
- package/dist/runner/adapters/index.js +15 -0
- package/dist/runner/adapters/recipe-run-profile.d.ts +8 -0
- package/dist/runner/adapters/recipe-run-profile.d.ts.map +1 -0
- package/dist/runner/adapters/recipe-run-profile.js +53 -0
- package/dist/runner/adapters/shared.d.ts +45 -0
- package/dist/runner/adapters/shared.d.ts.map +1 -0
- package/dist/runner/adapters/shared.js +58 -0
- package/dist/runner/artifacts.d.ts +31 -0
- package/dist/runner/artifacts.d.ts.map +1 -0
- package/dist/runner/artifacts.js +153 -0
- package/dist/runner/codex-approval-probe.d.ts +23 -0
- package/dist/runner/codex-approval-probe.d.ts.map +1 -0
- package/dist/runner/codex-approval-probe.js +55 -0
- package/dist/runner/codex-smoke.d.ts +11 -0
- package/dist/runner/codex-smoke.d.ts.map +1 -0
- package/dist/runner/codex-smoke.js +45 -0
- package/dist/runner/config.d.ts +6 -0
- package/dist/runner/config.d.ts.map +1 -0
- package/dist/runner/config.js +15 -0
- package/dist/runner/context/base-prompts.d.ts +10 -0
- package/dist/runner/context/base-prompts.d.ts.map +1 -0
- package/dist/runner/context/base-prompts.js +255 -0
- package/dist/runner/context/recipe-context.d.ts +17 -0
- package/dist/runner/context/recipe-context.d.ts.map +1 -0
- package/dist/runner/context/recipe-context.js +48 -0
- package/dist/runner/context/task-context.d.ts +24 -0
- package/dist/runner/context/task-context.d.ts.map +1 -0
- package/dist/runner/context/task-context.js +266 -0
- package/dist/runner/index.d.ts +12 -0
- package/dist/runner/index.d.ts.map +1 -0
- package/dist/runner/index.js +11 -0
- package/dist/runner/policy-decision.d.ts +12 -0
- package/dist/runner/policy-decision.d.ts.map +1 -0
- package/dist/runner/policy-decision.js +89 -0
- package/dist/runner/policy-display.d.ts +4 -0
- package/dist/runner/policy-display.d.ts.map +1 -0
- package/dist/runner/policy-display.js +41 -0
- package/dist/runner/process-supervision.d.ts +48 -0
- package/dist/runner/process-supervision.d.ts.map +1 -0
- package/dist/runner/process-supervision.js +490 -0
- package/dist/runner/result-manifest-policy.d.ts +9 -0
- package/dist/runner/result-manifest-policy.d.ts.map +1 -0
- package/dist/runner/result-manifest-policy.js +96 -0
- package/dist/runner/result-manifest.d.ts +30 -0
- package/dist/runner/result-manifest.d.ts.map +1 -0
- package/dist/runner/result-manifest.js +322 -0
- package/dist/runner/run-id.d.ts +2 -0
- package/dist/runner/run-id.d.ts.map +1 -0
- package/dist/runner/run-id.js +3 -0
- package/dist/runner/run-repository.d.ts +51 -0
- package/dist/runner/run-repository.d.ts.map +1 -0
- package/dist/runner/run-repository.js +222 -0
- package/dist/runner/task-run-paths.d.ts +19 -0
- package/dist/runner/task-run-paths.d.ts.map +1 -0
- package/dist/runner/task-run-paths.js +25 -0
- package/dist/runner/task-state.d.ts +9 -0
- package/dist/runner/task-state.d.ts.map +1 -0
- package/dist/runner/task-state.js +354 -0
- package/dist/runner/test-helpers.d.ts +30 -0
- package/dist/runner/test-helpers.d.ts.map +1 -0
- package/dist/runner/test-helpers.js +97 -0
- package/dist/runner/trace-artifacts.d.ts +14 -0
- package/dist/runner/trace-artifacts.d.ts.map +1 -0
- package/dist/runner/trace-artifacts.js +80 -0
- package/dist/runner/trace.d.ts +10 -0
- package/dist/runner/trace.d.ts.map +1 -0
- package/dist/runner/trace.js +37 -0
- package/dist/runner/types.d.ts +317 -0
- package/dist/runner/types.d.ts.map +1 -0
- package/dist/runner/types.js +3 -0
- package/dist/runner/usecases/scenario-materialize-task.d.ts +29 -0
- package/dist/runner/usecases/scenario-materialize-task.d.ts.map +1 -0
- package/dist/runner/usecases/scenario-materialize-task.js +151 -0
- package/dist/runner/usecases/task-run-inspect.d.ts +41 -0
- package/dist/runner/usecases/task-run-inspect.d.ts.map +1 -0
- package/dist/runner/usecases/task-run-inspect.js +74 -0
- package/dist/runner/usecases/task-run-lifecycle-cancel.d.ts +10 -0
- package/dist/runner/usecases/task-run-lifecycle-cancel.d.ts.map +1 -0
- package/dist/runner/usecases/task-run-lifecycle-cancel.js +172 -0
- package/dist/runner/usecases/task-run-lifecycle-replay.d.ts +18 -0
- package/dist/runner/usecases/task-run-lifecycle-replay.d.ts.map +1 -0
- package/dist/runner/usecases/task-run-lifecycle-replay.js +128 -0
- package/dist/runner/usecases/task-run-lifecycle-shared.d.ts +45 -0
- package/dist/runner/usecases/task-run-lifecycle-shared.d.ts.map +1 -0
- package/dist/runner/usecases/task-run-lifecycle-shared.js +172 -0
- package/dist/runner/usecases/task-run-lifecycle.d.ts +4 -0
- package/dist/runner/usecases/task-run-lifecycle.d.ts.map +1 -0
- package/dist/runner/usecases/task-run-lifecycle.js +2 -0
- package/dist/runner/usecases/task-run.d.ts +32 -0
- package/dist/runner/usecases/task-run.d.ts.map +1 -0
- package/dist/runner/usecases/task-run.js +278 -0
- package/dist/shared/agent-emoji.d.ts.map +1 -1
- package/dist/shared/agent-emoji.js +1 -0
- package/dist/shared/errors.d.ts +1 -1
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/guards.d.ts.map +1 -1
- package/dist/shared/guards.js +1 -0
- package/dist/shared/protected-paths.d.ts +10 -0
- package/dist/shared/protected-paths.d.ts.map +1 -1
- package/dist/shared/protected-paths.js +33 -0
- package/dist/shared/repo-cli-version.d.ts.map +1 -1
- package/dist/shared/repo-cli-version.js +7 -5
- package/dist/shared/task-doc-conflicts.d.ts +12 -0
- package/dist/shared/task-doc-conflicts.d.ts.map +1 -0
- package/dist/shared/task-doc-conflicts.js +40 -0
- package/dist/shared/task-doc-state.d.ts +10 -0
- package/dist/shared/task-doc-state.d.ts.map +1 -0
- package/dist/shared/task-doc-state.js +15 -0
- package/dist/test-helpers/fs.d.ts +2 -0
- package/dist/test-helpers/fs.d.ts.map +1 -0
- package/dist/test-helpers/fs.js +9 -0
- package/dist/usecases/context/resolve-context.d.ts +2 -0
- package/dist/usecases/context/resolve-context.d.ts.map +1 -1
- package/dist/usecases/context/resolve-context.js +4 -1
- package/dist/usecases/task/task-list-usecase.d.ts.map +1 -1
- package/dist/usecases/task/task-list-usecase.js +2 -8
- package/dist/workflow-runtime/fix.d.ts +9 -1
- package/dist/workflow-runtime/fix.d.ts.map +1 -1
- package/dist/workflow-runtime/fix.js +9 -1
- package/package.json +3 -2
- package/dist/backends/task-backend.test-helpers.d.ts +0 -4
- package/dist/backends/task-backend.test-helpers.d.ts.map +0 -1
- package/dist/backends/task-backend.test-helpers.js +0 -33
- package/dist/cli/run-cli/catalog.d.ts +0 -7
- package/dist/cli/run-cli/catalog.d.ts.map +0 -1
- package/dist/cli/run-cli/catalog.js +0 -22
- package/dist/cli/run-cli.core.pr-flow.test-helpers.d.ts +0 -3
- package/dist/cli/run-cli.core.pr-flow.test-helpers.d.ts.map +0 -1
- package/dist/cli/run-cli.core.pr-flow.test-helpers.js +0 -41
- package/dist/cli/run-cli.core.tasks.test-helpers.d.ts +0 -2
- package/dist/cli/run-cli.core.tasks.test-helpers.d.ts.map +0 -1
- package/dist/cli/run-cli.core.tasks.test-helpers.js +0 -6
- package/dist/commands/block.command.d.ts +0 -4
- package/dist/commands/block.command.d.ts.map +0 -1
- package/dist/commands/block.command.js +0 -2
- package/dist/commands/doctor.command.d.ts +0 -3
- package/dist/commands/doctor.command.d.ts.map +0 -1
- package/dist/commands/doctor.command.js +0 -2
- package/dist/commands/finish.command.d.ts +0 -4
- package/dist/commands/finish.command.d.ts.map +0 -1
- package/dist/commands/finish.command.js +0 -2
- package/dist/commands/recipes/install.command.d.ts +0 -3
- package/dist/commands/recipes/install.command.d.ts.map +0 -1
- package/dist/commands/recipes/install.command.js +0 -2
- package/dist/commands/start.command.d.ts +0 -4
- package/dist/commands/start.command.d.ts.map +0 -1
- package/dist/commands/start.command.js +0 -2
- package/dist/commands/task/list.command.d.ts +0 -4
- package/dist/commands/task/list.command.d.ts.map +0 -1
- package/dist/commands/task/list.command.js +0 -2
- package/dist/commands/task/next.command.d.ts +0 -4
- package/dist/commands/task/next.command.d.ts.map +0 -1
- package/dist/commands/task/next.command.js +0 -2
- package/dist/commands/task/search.command.d.ts +0 -4
- package/dist/commands/task/search.command.d.ts.map +0 -1
- package/dist/commands/task/search.command.js +0 -2
- package/dist/commands/task/show.command.d.ts +0 -4
- package/dist/commands/task/show.command.d.ts.map +0 -1
- package/dist/commands/task/show.command.js +0 -2
- package/dist/commands/verify.command.d.ts +0 -4
- package/dist/commands/verify.command.d.ts.map +0 -1
- package/dist/commands/verify.command.js +0 -2
package/dist/commands/upgrade.js
CHANGED
|
@@ -1,199 +1,23 @@
|
|
|
1
|
-
import { mkdir,
|
|
2
|
-
import os from "node:os";
|
|
1
|
+
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
3
2
|
import path from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
3
|
import { loadConfig, resolveProject } from "@agentplaneorg/core";
|
|
6
|
-
import { fileExists
|
|
7
|
-
import { downloadToFile, fetchJson } from "../cli/http.js";
|
|
8
|
-
import { parseSha256Text, sha256File } from "../cli/checksum.js";
|
|
9
|
-
import { extractArchive } from "../cli/archive.js";
|
|
4
|
+
import { fileExists } from "../cli/fs-utils.js";
|
|
10
5
|
import { exitCodeForError } from "../cli/exit-codes.js";
|
|
11
6
|
import { warnMessage } from "../cli/output.js";
|
|
12
7
|
import { CliError } from "../shared/errors.js";
|
|
13
8
|
import { ensureWorkflowArtifacts } from "../shared/workflow-artifacts.js";
|
|
9
|
+
import { checkTaskReadmeMigrationState } from "./doctor/workspace.js";
|
|
10
|
+
import { runOperatorPipeline } from "./shared/operator-pipeline.js";
|
|
11
|
+
import { loadCommandContext } from "./shared/task-backend.js";
|
|
14
12
|
import { ensureNetworkApproved } from "./shared/network-approval.js";
|
|
15
|
-
import {
|
|
13
|
+
import { migrateTaskDocsInWorkspace } from "./task/migrate-doc.js";
|
|
16
14
|
import { applyManagedFiles, cleanupAutoUpgradeArtifacts, createUpgradeCommit, ensureCleanTrackedTreeForUpgrade, persistUpgradeState, } from "./upgrade/apply.js";
|
|
15
|
+
import { materializeUpgradeSource } from "./upgrade/materialize.js";
|
|
16
|
+
import { planManagedUpgrade } from "./upgrade/plan.js";
|
|
17
|
+
import { CONFIG_REL_PATH, normalizeVersionForConfig, toUpgradeBaselineKey, } from "./upgrade/policy.js";
|
|
17
18
|
import { printUpgradeDryRun, writeUpgradeAgentReview } from "./upgrade/report.js";
|
|
18
|
-
import { describeUpgradeSource
|
|
19
|
-
const DEFAULT_UPGRADE_ASSET = "agentplane-upgrade.tar.gz";
|
|
20
|
-
const DEFAULT_UPGRADE_CHECKSUM_ASSET = "agentplane-upgrade.tar.gz.sha256";
|
|
21
|
-
const UPGRADE_DOWNLOAD_TIMEOUT_MS = 60_000;
|
|
22
|
-
const UPGRADE_RELEASE_METADATA_TIMEOUT_MS = 15_000;
|
|
19
|
+
import { describeUpgradeSource } from "./upgrade/source.js";
|
|
23
20
|
const ASSETS_DIR_URL = new URL("../../assets/", import.meta.url);
|
|
24
|
-
function isDeniedUpgradePath(relPath) {
|
|
25
|
-
if (relPath === ".agentplane/config.json")
|
|
26
|
-
return true;
|
|
27
|
-
if (relPath === ".agentplane/tasks.json")
|
|
28
|
-
return true;
|
|
29
|
-
if (relPath.startsWith(".agentplane/backends/"))
|
|
30
|
-
return true;
|
|
31
|
-
if (relPath.startsWith(".agentplane/worktrees/"))
|
|
32
|
-
return true;
|
|
33
|
-
if (relPath.startsWith(".agentplane/recipes/"))
|
|
34
|
-
return true;
|
|
35
|
-
if (relPath.startsWith(".agentplane/tasks/"))
|
|
36
|
-
return true;
|
|
37
|
-
if (relPath.startsWith(".agentplane/.upgrade/"))
|
|
38
|
-
return true;
|
|
39
|
-
if (relPath === ".git" || relPath.startsWith(".git/"))
|
|
40
|
-
return true;
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
function isAllowedUpgradePath(relPath) {
|
|
44
|
-
if (relPath === "AGENTS.md")
|
|
45
|
-
return true;
|
|
46
|
-
if (relPath === "CLAUDE.md")
|
|
47
|
-
return true;
|
|
48
|
-
if (relPath.startsWith(".agentplane/agents/") && relPath.endsWith(".json"))
|
|
49
|
-
return true;
|
|
50
|
-
if (relPath.startsWith(".agentplane/policy/") &&
|
|
51
|
-
(relPath.endsWith(".md") ||
|
|
52
|
-
relPath.endsWith(".ts") ||
|
|
53
|
-
relPath.endsWith(".js") ||
|
|
54
|
-
relPath.endsWith(".mjs"))) {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
const INCIDENTS_POLICY_PATH = ".agentplane/policy/incidents.md";
|
|
60
|
-
const INCIDENTS_APPEND_MARKER = "<!-- AGENTPLANE:UPGRADE-APPEND incidents.md -->";
|
|
61
|
-
const CONFIG_REL_PATH = ".agentplane/config.json";
|
|
62
|
-
function isJsonRecord(value) {
|
|
63
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
64
|
-
}
|
|
65
|
-
function canonicalizeJson(value) {
|
|
66
|
-
if (Array.isArray(value))
|
|
67
|
-
return value.map((v) => canonicalizeJson(v));
|
|
68
|
-
if (isJsonRecord(value)) {
|
|
69
|
-
const out = {};
|
|
70
|
-
for (const k of Object.keys(value).toSorted()) {
|
|
71
|
-
out[k] = canonicalizeJson(value[k]);
|
|
72
|
-
}
|
|
73
|
-
return out;
|
|
74
|
-
}
|
|
75
|
-
return value;
|
|
76
|
-
}
|
|
77
|
-
function jsonEqual(a, b) {
|
|
78
|
-
const ca = JSON.stringify(canonicalizeJson(a)) ?? "__undefined__";
|
|
79
|
-
const cb = JSON.stringify(canonicalizeJson(b)) ?? "__undefined__";
|
|
80
|
-
return ca === cb;
|
|
81
|
-
}
|
|
82
|
-
function textChangedForType(opts) {
|
|
83
|
-
if (opts.aText === null && opts.bText === null)
|
|
84
|
-
return false;
|
|
85
|
-
if (opts.aText === null || opts.bText === null)
|
|
86
|
-
return true;
|
|
87
|
-
if (opts.type === "json") {
|
|
88
|
-
try {
|
|
89
|
-
const a = JSON.parse(opts.aText);
|
|
90
|
-
const b = JSON.parse(opts.bText);
|
|
91
|
-
return !jsonEqual(a, b);
|
|
92
|
-
}
|
|
93
|
-
catch {
|
|
94
|
-
return opts.aText.trim() !== opts.bText.trim();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return opts.aText.trimEnd() !== opts.bText.trimEnd();
|
|
98
|
-
}
|
|
99
|
-
function parseIncidentEntryBlocks(entriesBody) {
|
|
100
|
-
const lines = entriesBody.replaceAll("\r\n", "\n").split("\n");
|
|
101
|
-
const starts = [];
|
|
102
|
-
for (const [index, line] of lines.entries()) {
|
|
103
|
-
if (/^\s*-\s*id:\s+/i.test(line ?? ""))
|
|
104
|
-
starts.push(index);
|
|
105
|
-
}
|
|
106
|
-
const blocks = [];
|
|
107
|
-
for (const [idx, start] of starts.entries()) {
|
|
108
|
-
const end = starts.at(idx + 1) ?? lines.length;
|
|
109
|
-
const slice = lines.slice(start, end);
|
|
110
|
-
while (slice.length > 0 && !(slice[0] ?? "").trim())
|
|
111
|
-
slice.shift();
|
|
112
|
-
while (slice.length > 0 && !(slice.at(-1) ?? "").trim())
|
|
113
|
-
slice.pop();
|
|
114
|
-
const block = slice.join("\n").trim();
|
|
115
|
-
if (block)
|
|
116
|
-
blocks.push(block);
|
|
117
|
-
}
|
|
118
|
-
return blocks;
|
|
119
|
-
}
|
|
120
|
-
function normalizeEntryBlock(block) {
|
|
121
|
-
return block
|
|
122
|
-
.replaceAll("\r\n", "\n")
|
|
123
|
-
.split("\n")
|
|
124
|
-
.map((line) => line.trimEnd())
|
|
125
|
-
.join("\n")
|
|
126
|
-
.trim();
|
|
127
|
-
}
|
|
128
|
-
function splitEntriesSection(text) {
|
|
129
|
-
const lines = text.replaceAll("\r\n", "\n").split("\n");
|
|
130
|
-
const headingIndex = lines.findIndex((line) => /^\s*##\s+Entries\s*$/i.test(line));
|
|
131
|
-
if (headingIndex === -1)
|
|
132
|
-
return null;
|
|
133
|
-
let nextHeadingIndex = lines.length;
|
|
134
|
-
for (let i = headingIndex + 1; i < lines.length; i++) {
|
|
135
|
-
if (/^\s*##\s+/.test(lines[i] ?? "")) {
|
|
136
|
-
nextHeadingIndex = i;
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return {
|
|
141
|
-
before: lines.slice(0, headingIndex + 1).join("\n"),
|
|
142
|
-
entriesBody: lines.slice(headingIndex + 1, nextHeadingIndex).join("\n"),
|
|
143
|
-
after: lines.slice(nextHeadingIndex).join("\n"),
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function mergeIncidentsPolicy(opts) {
|
|
147
|
-
const incomingTrimmed = opts.incomingText.trim();
|
|
148
|
-
if (!incomingTrimmed)
|
|
149
|
-
return { nextText: opts.currentText, appended: false, appendedCount: 0 };
|
|
150
|
-
const incomingSection = splitEntriesSection(opts.incomingText);
|
|
151
|
-
const currentSection = splitEntriesSection(opts.currentText);
|
|
152
|
-
if (!incomingSection || !currentSection) {
|
|
153
|
-
return { nextText: opts.incomingText, appended: false, appendedCount: 0 };
|
|
154
|
-
}
|
|
155
|
-
const incomingBlocks = parseIncidentEntryBlocks(incomingSection.entriesBody).map((block) => normalizeEntryBlock(block));
|
|
156
|
-
const currentBlocks = parseIncidentEntryBlocks(currentSection.entriesBody).map((block) => normalizeEntryBlock(block));
|
|
157
|
-
if (currentBlocks.length === 0) {
|
|
158
|
-
return { nextText: opts.incomingText, appended: false, appendedCount: 0 };
|
|
159
|
-
}
|
|
160
|
-
const baselineSection = opts.baselineText ? splitEntriesSection(opts.baselineText) : null;
|
|
161
|
-
const baselineBlocks = baselineSection
|
|
162
|
-
? parseIncidentEntryBlocks(baselineSection.entriesBody).map((block) => normalizeEntryBlock(block))
|
|
163
|
-
: [];
|
|
164
|
-
const baselineSet = new Set(baselineBlocks);
|
|
165
|
-
const incomingSet = new Set(incomingBlocks);
|
|
166
|
-
const userAdded = currentBlocks.filter((block) => {
|
|
167
|
-
if (baselineSet.size > 0 && baselineSet.has(block))
|
|
168
|
-
return false;
|
|
169
|
-
return true;
|
|
170
|
-
});
|
|
171
|
-
const toAppend = userAdded.filter((block) => !incomingSet.has(block));
|
|
172
|
-
if (toAppend.length === 0) {
|
|
173
|
-
return { nextText: opts.incomingText, appended: false, appendedCount: 0 };
|
|
174
|
-
}
|
|
175
|
-
const mergedBlocks = [...incomingBlocks, ...toAppend];
|
|
176
|
-
const renderedEntries = mergedBlocks.length > 0 ? `\n\n${mergedBlocks.join("\n\n")}\n` : "\n\n- None yet.\n";
|
|
177
|
-
const afterSuffix = incomingSection.after ? `\n${incomingSection.after.trimStart()}` : "";
|
|
178
|
-
const nextText = `${incomingSection.before.trimEnd()}` +
|
|
179
|
-
`${renderedEntries}` +
|
|
180
|
-
`${INCIDENTS_APPEND_MARKER}\n` +
|
|
181
|
-
`${afterSuffix}` +
|
|
182
|
-
`\n`;
|
|
183
|
-
return { nextText, appended: true, appendedCount: toAppend.length };
|
|
184
|
-
}
|
|
185
|
-
function normalizeUpgradeVersionLabel(input) {
|
|
186
|
-
const trimmed = input.trim();
|
|
187
|
-
if (!trimmed)
|
|
188
|
-
return "unknown";
|
|
189
|
-
if (/^v\d/i.test(trimmed))
|
|
190
|
-
return trimmed;
|
|
191
|
-
return `v${trimmed}`;
|
|
192
|
-
}
|
|
193
|
-
function normalizeVersionForConfig(input) {
|
|
194
|
-
const trimmed = input.trim().replace(/^v/i, "");
|
|
195
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
196
|
-
}
|
|
197
21
|
export async function cmdUpgradeParsed(opts) {
|
|
198
22
|
const flags = opts.flags;
|
|
199
23
|
if ((flags.bundle && !flags.checksum) || (!flags.bundle && flags.checksum)) {
|
|
@@ -210,6 +34,12 @@ export async function cmdUpgradeParsed(opts) {
|
|
|
210
34
|
rootOverride: opts.rootOverride ?? null,
|
|
211
35
|
});
|
|
212
36
|
const loaded = await loadConfig(resolved.agentplaneDir);
|
|
37
|
+
const commandCtx = await loadCommandContext({
|
|
38
|
+
cwd: opts.cwd,
|
|
39
|
+
rootOverride: opts.rootOverride ?? null,
|
|
40
|
+
resolvedProject: resolved,
|
|
41
|
+
config: loaded.config,
|
|
42
|
+
});
|
|
213
43
|
if (flags.mode === "auto" && !flags.dryRun) {
|
|
214
44
|
await ensureCleanTrackedTreeForUpgrade(resolved.gitRoot);
|
|
215
45
|
}
|
|
@@ -241,457 +71,173 @@ export async function cmdUpgradeParsed(opts) {
|
|
|
241
71
|
Boolean(flags.asset) ||
|
|
242
72
|
Boolean(flags.checksumAsset);
|
|
243
73
|
const useRemote = flags.remote === true || hasRemoteHints;
|
|
244
|
-
let tempRoot = null;
|
|
245
|
-
let extractRoot = null;
|
|
246
74
|
const createdBackups = [];
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
bundleLayout = "local_assets";
|
|
257
|
-
bundleRoot = fileURLToPath(ASSETS_DIR_URL);
|
|
258
|
-
}
|
|
259
|
-
else if (flags.bundle) {
|
|
260
|
-
const isUrl = flags.bundle.startsWith("http://") || flags.bundle.startsWith("https://");
|
|
261
|
-
bundlePath = isUrl ? path.join(tempRoot, "bundle.tar.gz") : path.resolve(flags.bundle);
|
|
262
|
-
if (isUrl) {
|
|
263
|
-
await ensureApproved("upgrade downloads the bundle/checksum from the network");
|
|
264
|
-
await downloadToFile(flags.bundle, bundlePath, UPGRADE_DOWNLOAD_TIMEOUT_MS);
|
|
265
|
-
}
|
|
266
|
-
const checksumValue = flags.checksum ?? "";
|
|
267
|
-
const checksumIsUrl = checksumValue.startsWith("http://") || checksumValue.startsWith("https://");
|
|
268
|
-
checksumPath = checksumIsUrl
|
|
269
|
-
? path.join(tempRoot, "bundle.tar.gz.sha256")
|
|
270
|
-
: path.resolve(checksumValue);
|
|
271
|
-
if (checksumIsUrl) {
|
|
272
|
-
await ensureApproved("upgrade downloads the bundle/checksum from the network");
|
|
273
|
-
await downloadToFile(checksumValue, checksumPath, UPGRADE_DOWNLOAD_TIMEOUT_MS);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
const sourceFromFlags = typeof flags.source === "string" && flags.source.trim().length > 0;
|
|
278
|
-
const originalSource = flags.source ?? loaded.config.framework.source;
|
|
279
|
-
const normalized = normalizeFrameworkSourceForUpgrade(originalSource);
|
|
280
|
-
if (!sourceFromFlags && normalized.migrated) {
|
|
281
|
-
normalizedSourceToPersist = normalized.source;
|
|
282
|
-
}
|
|
283
|
-
if (normalized.migrated) {
|
|
284
|
-
process.stderr.write(`${warnMessage(`config.framework.source uses deprecated repo basilisk-labs/agent-plane; using ${normalized.source}`)}\n`);
|
|
285
|
-
}
|
|
286
|
-
const { owner, repo } = normalized;
|
|
287
|
-
const releaseUrl = flags.tag
|
|
288
|
-
? `https://api.github.com/repos/${owner}/${repo}/releases/tags/${flags.tag}`
|
|
289
|
-
: `https://api.github.com/repos/${owner}/${repo}/releases/latest`;
|
|
290
|
-
await ensureApproved("upgrade fetches release metadata and downloads assets from the network");
|
|
291
|
-
const assetName = flags.asset ?? DEFAULT_UPGRADE_ASSET;
|
|
292
|
-
const checksumName = flags.checksumAsset ?? DEFAULT_UPGRADE_CHECKSUM_ASSET;
|
|
293
|
-
const release = (await fetchJson(releaseUrl, UPGRADE_RELEASE_METADATA_TIMEOUT_MS));
|
|
294
|
-
const releaseTag = (typeof release.tag_name === "string" && release.tag_name.trim()) ||
|
|
295
|
-
(typeof flags.tag === "string" && flags.tag.trim()) ||
|
|
296
|
-
"";
|
|
297
|
-
if (releaseTag) {
|
|
298
|
-
upgradeVersionLabel = normalizeUpgradeVersionLabel(releaseTag);
|
|
299
|
-
}
|
|
300
|
-
const download = resolveUpgradeDownloadFromRelease({
|
|
301
|
-
release,
|
|
302
|
-
owner,
|
|
303
|
-
repo,
|
|
304
|
-
assetName,
|
|
305
|
-
checksumName,
|
|
75
|
+
let materialized = null;
|
|
76
|
+
return await runOperatorPipeline({
|
|
77
|
+
init: () => null,
|
|
78
|
+
materialize: async () => {
|
|
79
|
+
materialized = await materializeUpgradeSource({
|
|
80
|
+
flags,
|
|
81
|
+
frameworkSource: loaded.config.framework.source,
|
|
82
|
+
assetsDirUrl: ASSETS_DIR_URL,
|
|
83
|
+
ensureApproved,
|
|
306
84
|
});
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
message: `Upgrade assets ${assetName}/${checksumName} not found in ${owner}/${repo} release. ` +
|
|
319
|
-
"Publish the upgrade bundle assets, or re-run with --allow-tarball to download a repo tarball (no checksum verification).",
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
process.stderr.write(`${warnMessage(`upgrade release does not include ${assetName}/${checksumName}; falling back to repo tarball without checksum verification`)}\n`);
|
|
323
|
-
bundleLayout = "repo_tarball";
|
|
324
|
-
bundlePath = path.join(tempRoot, "source.tar.gz");
|
|
325
|
-
const tarballUrl = resolveRepoTarballUrl({
|
|
326
|
-
release,
|
|
327
|
-
owner,
|
|
328
|
-
repo,
|
|
329
|
-
explicitTag: flags.tag,
|
|
330
|
-
});
|
|
331
|
-
await downloadToFile(tarballUrl, bundlePath, UPGRADE_DOWNLOAD_TIMEOUT_MS);
|
|
332
|
-
checksumPath = "";
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
if (bundleLayout !== "local_assets" && checksumPath) {
|
|
336
|
-
const expected = parseSha256Text(await readFile(checksumPath, "utf8"));
|
|
337
|
-
if (!expected) {
|
|
338
|
-
throw new CliError({
|
|
339
|
-
exitCode: 3,
|
|
340
|
-
code: "E_VALIDATION",
|
|
341
|
-
message: "Upgrade checksum file is empty or invalid",
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
const actual = await sha256File(bundlePath);
|
|
345
|
-
if (actual !== expected) {
|
|
346
|
-
throw new CliError({
|
|
347
|
-
exitCode: 3,
|
|
348
|
-
code: "E_VALIDATION",
|
|
349
|
-
message: `Upgrade checksum mismatch (expected ${expected}, got ${actual})`,
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
if (bundleLayout !== "local_assets") {
|
|
354
|
-
extractRoot = await mkdtemp(path.join(os.tmpdir(), "agentplane-upgrade-extract-"));
|
|
355
|
-
await extractArchive({
|
|
356
|
-
archivePath: bundlePath,
|
|
357
|
-
destDir: extractRoot,
|
|
358
|
-
});
|
|
359
|
-
const extractedRoot = await resolveUpgradeRoot(extractRoot);
|
|
360
|
-
bundleRoot =
|
|
361
|
-
bundleLayout === "repo_tarball"
|
|
362
|
-
? path.join(extractedRoot, "packages", "agentplane", "assets")
|
|
363
|
-
: extractedRoot;
|
|
364
|
-
}
|
|
365
|
-
const manifestPath = bundleLayout === "local_assets"
|
|
366
|
-
? fileURLToPath(new URL("../../assets/framework.manifest.json", import.meta.url))
|
|
367
|
-
: path.join(bundleRoot, "framework.manifest.json");
|
|
368
|
-
const manifest = await loadFrameworkManifestFromPath(manifestPath);
|
|
369
|
-
const modeLabel = flags.dryRun ? "dry-run" : flags.mode === "agent" ? "review" : "apply";
|
|
370
|
-
process.stdout.write(`Upgrade source: ${describeUpgradeSource({
|
|
371
|
-
bundleLayout,
|
|
372
|
-
hasExplicitBundle: hasBundle,
|
|
373
|
-
useRemote,
|
|
374
|
-
})}\n` +
|
|
375
|
-
`Upgrade version: ${upgradeVersionLabel}\n` +
|
|
376
|
-
`Upgrade mode: ${modeLabel}\n`);
|
|
377
|
-
const additions = [];
|
|
378
|
-
const updates = [];
|
|
379
|
-
const skipped = [];
|
|
380
|
-
const fileContents = new Map();
|
|
381
|
-
const merged = [];
|
|
382
|
-
const missingRequired = [];
|
|
383
|
-
const reviewRecords = [];
|
|
384
|
-
let incidentsAppendedCount = 0;
|
|
385
|
-
const readBaselineText = async (baselineKey) => {
|
|
386
|
-
try {
|
|
387
|
-
return await readFile(path.join(baselineDirNew, baselineKey), "utf8");
|
|
388
|
-
}
|
|
389
|
-
catch {
|
|
390
|
-
// Back-compat: older upgrades wrote baselines under .agentplane/upgrade/baseline.
|
|
391
|
-
try {
|
|
392
|
-
return await readFile(path.join(baselineDirLegacy, baselineKey), "utf8");
|
|
393
|
-
}
|
|
394
|
-
catch {
|
|
395
|
-
return null;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
const toBaselineKey = (rel) => {
|
|
400
|
-
if (rel === "AGENTS.md")
|
|
401
|
-
return "AGENTS.md";
|
|
402
|
-
if (rel === "CLAUDE.md")
|
|
403
|
-
return "CLAUDE.md";
|
|
404
|
-
if (rel.startsWith(".agentplane/"))
|
|
405
|
-
return rel.slice(".agentplane/".length);
|
|
406
|
-
return null;
|
|
407
|
-
};
|
|
408
|
-
const policyGatewayRel = (await fileExists(path.join(resolved.gitRoot, "AGENTS.md")))
|
|
409
|
-
? "AGENTS.md"
|
|
410
|
-
: (await fileExists(path.join(resolved.gitRoot, "CLAUDE.md")))
|
|
411
|
-
? "CLAUDE.md"
|
|
412
|
-
: "AGENTS.md";
|
|
413
|
-
const remapManagedGatewayRel = (rel) => {
|
|
414
|
-
if (rel === "AGENTS.md" && policyGatewayRel === "CLAUDE.md")
|
|
415
|
-
return "CLAUDE.md";
|
|
416
|
-
return rel;
|
|
417
|
-
};
|
|
418
|
-
for (const entry of manifest.files) {
|
|
419
|
-
const relRaw = entry.path.replaceAll("\\", "/").trim();
|
|
420
|
-
if (!relRaw || relRaw.startsWith("..") || path.isAbsolute(relRaw)) {
|
|
421
|
-
throw new CliError({
|
|
422
|
-
exitCode: 3,
|
|
423
|
-
code: "E_VALIDATION",
|
|
424
|
-
message: `Invalid manifest path: ${entry.path}`,
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
if (isDeniedUpgradePath(relRaw)) {
|
|
428
|
-
throw new CliError({
|
|
429
|
-
exitCode: 3,
|
|
430
|
-
code: "E_VALIDATION",
|
|
431
|
-
message: `Manifest includes a denied path: ${relRaw}`,
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
if (!isAllowedUpgradePath(relRaw)) {
|
|
435
|
-
throw new CliError({
|
|
436
|
-
exitCode: 3,
|
|
437
|
-
code: "E_VALIDATION",
|
|
438
|
-
message: `Manifest path not allowed: ${relRaw}`,
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
const rel = remapManagedGatewayRel(relRaw);
|
|
442
|
-
const destPath = path.join(resolved.gitRoot, rel);
|
|
443
|
-
const kind = await getPathKind(destPath);
|
|
444
|
-
if (kind === "dir") {
|
|
85
|
+
const modeLabel = flags.dryRun ? "dry-run" : flags.mode === "agent" ? "review" : "apply";
|
|
86
|
+
process.stdout.write(`Upgrade source: ${describeUpgradeSource({
|
|
87
|
+
bundleLayout: materialized.bundleLayout,
|
|
88
|
+
hasExplicitBundle: hasBundle,
|
|
89
|
+
useRemote,
|
|
90
|
+
})}\n` +
|
|
91
|
+
`Upgrade version: ${materialized.upgradeVersionLabel}\n` +
|
|
92
|
+
`Upgrade mode: ${modeLabel}\n`);
|
|
93
|
+
},
|
|
94
|
+
execute: async () => {
|
|
95
|
+
if (!materialized) {
|
|
445
96
|
throw new CliError({
|
|
446
97
|
exitCode: exitCodeForError("E_IO"),
|
|
447
98
|
code: "E_IO",
|
|
448
|
-
message:
|
|
99
|
+
message: "Upgrade bundle did not materialize correctly",
|
|
449
100
|
});
|
|
450
101
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
catch {
|
|
463
|
-
// try next candidate
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
if (!loaded) {
|
|
467
|
-
if (entry.required)
|
|
468
|
-
missingRequired.push(rel);
|
|
469
|
-
continue;
|
|
470
|
-
}
|
|
471
|
-
data = loaded;
|
|
472
|
-
}
|
|
473
|
-
let existingBuf = null;
|
|
474
|
-
let existingText = null;
|
|
475
|
-
if (kind !== null) {
|
|
476
|
-
existingBuf = await readFile(destPath);
|
|
477
|
-
}
|
|
478
|
-
const incomingTextOriginal = data.toString("utf8");
|
|
479
|
-
const currentTextForReview = existingBuf ? existingBuf.toString("utf8") : null;
|
|
480
|
-
const baselineKey = toBaselineKey(rel);
|
|
481
|
-
const baselineText = baselineKey ? await readBaselineText(baselineKey) : null;
|
|
482
|
-
const hasBaseline = baselineText !== null;
|
|
483
|
-
const changedCurrentVsBaseline = hasBaseline && currentTextForReview !== null
|
|
484
|
-
? textChangedForType({
|
|
485
|
-
type: entry.type,
|
|
486
|
-
aText: currentTextForReview,
|
|
487
|
-
bText: baselineText,
|
|
488
|
-
})
|
|
489
|
-
: null;
|
|
490
|
-
const changedIncomingVsBaseline = hasBaseline
|
|
491
|
-
? textChangedForType({
|
|
492
|
-
type: entry.type,
|
|
493
|
-
aText: incomingTextOriginal,
|
|
494
|
-
bText: baselineText,
|
|
495
|
-
})
|
|
496
|
-
: null;
|
|
497
|
-
const currentAndIncomingEqual = currentTextForReview === null
|
|
498
|
-
? false
|
|
499
|
-
: textChangedForType({
|
|
500
|
-
type: entry.type,
|
|
501
|
-
aText: currentTextForReview,
|
|
502
|
-
bText: incomingTextOriginal,
|
|
503
|
-
}) === false;
|
|
504
|
-
// Fast-path: incoming already equals local.
|
|
505
|
-
if (currentTextForReview !== null && currentAndIncomingEqual) {
|
|
506
|
-
skipped.push(rel);
|
|
507
|
-
reviewRecords.push({
|
|
508
|
-
relPath: rel,
|
|
509
|
-
mergeStrategy: entry.merge_strategy,
|
|
510
|
-
hasBaseline,
|
|
511
|
-
changedCurrentVsBaseline,
|
|
512
|
-
changedIncomingVsBaseline,
|
|
513
|
-
currentDiffersFromIncoming: false,
|
|
514
|
-
needsSemanticReview: false,
|
|
515
|
-
mergeApplied: false,
|
|
516
|
-
mergePath: "none",
|
|
517
|
-
});
|
|
518
|
-
continue;
|
|
519
|
-
}
|
|
520
|
-
// No local edits vs baseline: file can be safely replaced with incoming.
|
|
521
|
-
if (currentTextForReview !== null && changedCurrentVsBaseline === false) {
|
|
522
|
-
updates.push(rel);
|
|
523
|
-
fileContents.set(rel, data);
|
|
524
|
-
reviewRecords.push({
|
|
525
|
-
relPath: rel,
|
|
526
|
-
mergeStrategy: entry.merge_strategy,
|
|
527
|
-
hasBaseline,
|
|
528
|
-
changedCurrentVsBaseline,
|
|
529
|
-
changedIncomingVsBaseline,
|
|
530
|
-
currentDiffersFromIncoming: true,
|
|
531
|
-
needsSemanticReview: false,
|
|
532
|
-
mergeApplied: false,
|
|
533
|
-
mergePath: "none",
|
|
534
|
-
});
|
|
535
|
-
continue;
|
|
102
|
+
const { additions, updates, skipped, merged, fileContents, reviewRecords, incidentsAppendedCount, } = await planManagedUpgrade({
|
|
103
|
+
gitRoot: resolved.gitRoot,
|
|
104
|
+
manifest: materialized.manifest,
|
|
105
|
+
bundleRoot: materialized.bundleRoot,
|
|
106
|
+
baselineDirNew,
|
|
107
|
+
baselineDirLegacy,
|
|
108
|
+
});
|
|
109
|
+
if (flags.dryRun) {
|
|
110
|
+
printUpgradeDryRun({ additions, updates, skipped, merged });
|
|
111
|
+
return 0;
|
|
536
112
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
const mergedIncidents = mergeIncidentsPolicy({
|
|
545
|
-
incomingText: data.toString("utf8"),
|
|
546
|
-
currentText: existingText,
|
|
547
|
-
baselineText,
|
|
548
|
-
});
|
|
549
|
-
data = Buffer.from(mergedIncidents.nextText, "utf8");
|
|
550
|
-
if (mergedIncidents.appended) {
|
|
551
|
-
merged.push(rel);
|
|
552
|
-
mergeApplied = true;
|
|
553
|
-
mergePath = "incidentsAppend";
|
|
554
|
-
incidentsAppendedCount += mergedIncidents.appendedCount;
|
|
113
|
+
const needsReview = reviewRecords.filter((r) => r.needsSemanticReview);
|
|
114
|
+
if (flags.mode === "agent") {
|
|
115
|
+
// Fast no-op path: nothing to apply and no semantic review candidates.
|
|
116
|
+
// Skip generating per-run artifacts to keep agent-mode upgrades cheap.
|
|
117
|
+
if (additions.length === 0 && updates.length === 0 && needsReview.length === 0) {
|
|
118
|
+
process.stdout.write("Upgrade plan: no managed changes detected\n");
|
|
119
|
+
return 0;
|
|
555
120
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
121
|
+
const { relRunDir, needsReviewCount } = await writeUpgradeAgentReview({
|
|
122
|
+
gitRoot: resolved.gitRoot,
|
|
123
|
+
runRoot: path.join(upgradeStateDir, "agent"),
|
|
124
|
+
manifest: materialized.manifest,
|
|
125
|
+
additions,
|
|
126
|
+
updates,
|
|
127
|
+
skipped,
|
|
128
|
+
merged,
|
|
129
|
+
reviewRecords,
|
|
563
130
|
});
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
relPath: rel,
|
|
567
|
-
mergeStrategy: entry.merge_strategy,
|
|
568
|
-
hasBaseline,
|
|
569
|
-
changedCurrentVsBaseline,
|
|
570
|
-
changedIncomingVsBaseline,
|
|
571
|
-
currentDiffersFromIncoming,
|
|
572
|
-
needsSemanticReview,
|
|
573
|
-
mergeApplied,
|
|
574
|
-
mergePath,
|
|
575
|
-
});
|
|
576
|
-
fileContents.set(rel, data);
|
|
577
|
-
if (kind === null)
|
|
578
|
-
additions.push(rel);
|
|
579
|
-
else if (existingBuf && Buffer.compare(existingBuf, data) === 0)
|
|
580
|
-
skipped.push(rel);
|
|
581
|
-
else
|
|
582
|
-
updates.push(rel);
|
|
583
|
-
}
|
|
584
|
-
if (missingRequired.length > 0) {
|
|
585
|
-
throw new CliError({
|
|
586
|
-
exitCode: 3,
|
|
587
|
-
code: "E_VALIDATION",
|
|
588
|
-
message: `Upgrade bundle is missing required managed files: ${missingRequired.join(", ")}`,
|
|
589
|
-
});
|
|
590
|
-
}
|
|
591
|
-
if (flags.dryRun) {
|
|
592
|
-
printUpgradeDryRun({ additions, updates, skipped, merged });
|
|
593
|
-
return 0;
|
|
594
|
-
}
|
|
595
|
-
const needsReview = reviewRecords.filter((r) => r.needsSemanticReview);
|
|
596
|
-
if (flags.mode === "agent") {
|
|
597
|
-
// Fast no-op path: nothing to apply and no semantic review candidates.
|
|
598
|
-
// Skip generating per-run artifacts to keep agent-mode upgrades cheap.
|
|
599
|
-
if (additions.length === 0 && updates.length === 0 && needsReview.length === 0) {
|
|
600
|
-
process.stdout.write("Upgrade plan: no managed changes detected\n");
|
|
131
|
+
process.stdout.write(`Upgrade plan written: ${relRunDir}\n`);
|
|
132
|
+
process.stdout.write(`Review-required files: ${needsReviewCount}\n`);
|
|
601
133
|
return 0;
|
|
602
134
|
}
|
|
603
|
-
|
|
135
|
+
await applyManagedFiles({
|
|
604
136
|
gitRoot: resolved.gitRoot,
|
|
605
|
-
runRoot: path.join(upgradeStateDir, "agent"),
|
|
606
|
-
manifest,
|
|
607
137
|
additions,
|
|
608
138
|
updates,
|
|
609
|
-
|
|
610
|
-
|
|
139
|
+
backup: flags.backup,
|
|
140
|
+
fileContents,
|
|
141
|
+
baselineDir: baselineDirNew,
|
|
142
|
+
createdBackups,
|
|
143
|
+
toBaselineKey: toUpgradeBaselineKey,
|
|
144
|
+
});
|
|
145
|
+
const migratedTaskDocs = flags.migrateTaskDocs
|
|
146
|
+
? await migrateTaskDocsInWorkspace({
|
|
147
|
+
cwd: opts.cwd,
|
|
148
|
+
rootOverride: opts.rootOverride ?? null,
|
|
149
|
+
all: true,
|
|
150
|
+
taskIds: [],
|
|
151
|
+
resolvedProject: resolved,
|
|
152
|
+
config: loaded.config,
|
|
153
|
+
ctx: commandCtx,
|
|
154
|
+
})
|
|
155
|
+
: { changed: 0, changedPaths: [] };
|
|
156
|
+
if (flags.migrateTaskDocs) {
|
|
157
|
+
const details = migratedTaskDocs.changed > 0 ? `changed=${migratedTaskDocs.changed}` : "already current";
|
|
158
|
+
process.stdout.write(`Task README migration: ${details}\n`);
|
|
159
|
+
}
|
|
160
|
+
const hasManagedMutations = additions.length > 0 || updates.length > 0;
|
|
161
|
+
const shouldMutateConfig = await persistUpgradeState({
|
|
162
|
+
agentplaneDir: resolved.agentplaneDir,
|
|
163
|
+
rawConfig: loaded.raw,
|
|
164
|
+
normalizedSourceToPersist: materialized.normalizedSourceToPersist,
|
|
165
|
+
expectedCliVersionToPersist: normalizeVersionForConfig(materialized.upgradeVersionLabel),
|
|
166
|
+
hasManagedMutations,
|
|
167
|
+
statePath,
|
|
168
|
+
upgradeStateDir,
|
|
169
|
+
source: materialized.bundleLayout,
|
|
611
170
|
reviewRecords,
|
|
171
|
+
additions: additions.length,
|
|
172
|
+
updates: updates.length,
|
|
173
|
+
skipped: skipped.length,
|
|
612
174
|
});
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
upgradeStateDir,
|
|
636
|
-
source: bundleLayout,
|
|
637
|
-
reviewRecords,
|
|
638
|
-
additions: additions.length,
|
|
639
|
-
updates: updates.length,
|
|
640
|
-
skipped: skipped.length,
|
|
641
|
-
});
|
|
642
|
-
const orchestratorProfilePath = path.join(resolved.agentplaneDir, "agents", "ORCHESTRATOR.json");
|
|
643
|
-
const workflowArtifacts = (await fileExists(orchestratorProfilePath))
|
|
644
|
-
? await ensureWorkflowArtifacts({
|
|
175
|
+
const orchestratorProfilePath = path.join(resolved.agentplaneDir, "agents", "ORCHESTRATOR.json");
|
|
176
|
+
const workflowArtifacts = (await fileExists(orchestratorProfilePath))
|
|
177
|
+
? await ensureWorkflowArtifacts({
|
|
178
|
+
gitRoot: resolved.gitRoot,
|
|
179
|
+
workflowMode: loaded.config.workflow_mode,
|
|
180
|
+
approvals: {
|
|
181
|
+
requirePlanApproval: loaded.config.agents?.approvals?.require_plan ?? true,
|
|
182
|
+
requireVerifyApproval: loaded.config.agents?.approvals?.require_verify ?? true,
|
|
183
|
+
requireNetworkApproval: loaded.config.agents?.approvals?.require_network ?? true,
|
|
184
|
+
},
|
|
185
|
+
})
|
|
186
|
+
: { installPaths: [], commitPaths: [], changedPaths: [] };
|
|
187
|
+
const commitPaths = [
|
|
188
|
+
...new Set([
|
|
189
|
+
...additions,
|
|
190
|
+
...updates,
|
|
191
|
+
...migratedTaskDocs.changedPaths,
|
|
192
|
+
...workflowArtifacts.commitPaths,
|
|
193
|
+
...(shouldMutateConfig ? [CONFIG_REL_PATH] : []),
|
|
194
|
+
]),
|
|
195
|
+
];
|
|
196
|
+
const commit = await createUpgradeCommit({
|
|
645
197
|
gitRoot: resolved.gitRoot,
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
}
|
|
677
|
-
if (commit) {
|
|
678
|
-
process.stdout.write(`Upgrade commit: ${commit.hash.slice(0, 12)} ${commit.subject}\n`);
|
|
679
|
-
}
|
|
680
|
-
return 0;
|
|
681
|
-
}
|
|
682
|
-
finally {
|
|
683
|
-
if (extractRoot)
|
|
684
|
-
await rm(extractRoot, { recursive: true, force: true });
|
|
685
|
-
if (tempRoot)
|
|
686
|
-
await rm(tempRoot, { recursive: true, force: true });
|
|
687
|
-
if (lockAcquired) {
|
|
688
|
-
try {
|
|
689
|
-
await rm(lockPath, { force: true });
|
|
198
|
+
paths: commitPaths,
|
|
199
|
+
tasksPath: loaded.config.paths.tasks_path,
|
|
200
|
+
workflowDir: loaded.config.paths.workflow_dir,
|
|
201
|
+
versionLabel: materialized.upgradeVersionLabel,
|
|
202
|
+
source: materialized.bundleLayout,
|
|
203
|
+
additions: additions.length,
|
|
204
|
+
updates: updates.length,
|
|
205
|
+
unchanged: skipped.length,
|
|
206
|
+
incidentsAppendedCount,
|
|
207
|
+
});
|
|
208
|
+
await cleanupAutoUpgradeArtifacts({ upgradeStateDir, createdBackups });
|
|
209
|
+
process.stdout.write(`Upgrade applied: ${additions.length} add, ${updates.length} update, ${skipped.length} unchanged\n`);
|
|
210
|
+
if (workflowArtifacts.changedPaths.length > 0) {
|
|
211
|
+
process.stdout.write(`Workflow artifacts refreshed: ${workflowArtifacts.commitPaths.join(", ")}\n`);
|
|
212
|
+
}
|
|
213
|
+
if (commit) {
|
|
214
|
+
process.stdout.write(`Upgrade commit: ${commit.hash.slice(0, 12)} ${commit.subject}\n`);
|
|
215
|
+
}
|
|
216
|
+
const taskReadmeMigrationFindings = await checkTaskReadmeMigrationState(resolved.gitRoot, commandCtx);
|
|
217
|
+
if (taskReadmeMigrationFindings.length > 0) {
|
|
218
|
+
process.stderr.write(`${warnMessage("upgrade post-check: task README migration follow-up detected")}\n`);
|
|
219
|
+
for (const finding of taskReadmeMigrationFindings) {
|
|
220
|
+
process.stderr.write(`- ${finding}\n`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return 0;
|
|
224
|
+
},
|
|
225
|
+
cleanup: async () => {
|
|
226
|
+
if (materialized?.extractRoot) {
|
|
227
|
+
await rm(materialized.extractRoot, { recursive: true, force: true });
|
|
690
228
|
}
|
|
691
|
-
|
|
692
|
-
|
|
229
|
+
if (materialized?.tempRoot) {
|
|
230
|
+
await rm(materialized.tempRoot, { recursive: true, force: true });
|
|
693
231
|
}
|
|
694
|
-
|
|
695
|
-
|
|
232
|
+
if (lockAcquired) {
|
|
233
|
+
try {
|
|
234
|
+
await rm(lockPath, { force: true });
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// best-effort cleanup
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
});
|
|
696
242
|
}
|
|
697
243
|
export { normalizeFrameworkSourceForUpgrade, resolveRepoTarballUrl, resolveUpgradeDownloadFromRelease, } from "./upgrade/source.js";
|