agentplane 0.3.15 → 0.3.17
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/policy/incidents.md +7 -0
- package/bin/agentplane.js +1 -1
- package/bin/framework-dev-contract.js +1 -0
- package/dist/.build-manifest.json +641 -351
- package/dist/backends/task-backend/load.d.ts.map +1 -1
- package/dist/backends/task-backend/load.js +32 -19
- package/dist/backends/task-backend/local-backend-doc.d.ts.map +1 -1
- package/dist/backends/task-backend/local-backend-doc.js +1 -1
- package/dist/backends/task-backend/redmine/backend-runtime.d.ts +5 -0
- package/dist/backends/task-backend/redmine/backend-runtime.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-runtime.js +4 -0
- package/dist/backends/task-backend/redmine/backend-sync/context.d.ts +44 -0
- package/dist/backends/task-backend/redmine/backend-sync/context.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-sync/context.js +8 -0
- package/dist/backends/task-backend/redmine/backend-sync/ids.d.ts +6 -0
- package/dist/backends/task-backend/redmine/backend-sync/ids.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-sync/ids.js +21 -0
- package/dist/backends/task-backend/redmine/backend-sync/migration.d.ts +4 -0
- package/dist/backends/task-backend/redmine/backend-sync/migration.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-sync/migration.js +87 -0
- package/dist/backends/task-backend/redmine/backend-sync/status.d.ts +10 -0
- package/dist/backends/task-backend/redmine/backend-sync/status.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-sync/status.js +78 -0
- package/dist/backends/task-backend/redmine/backend-sync/sync.d.ts +12 -0
- package/dist/backends/task-backend/redmine/backend-sync/sync.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-sync/sync.js +82 -0
- package/dist/backends/task-backend/redmine/backend-sync/write.d.ts +5 -0
- package/dist/backends/task-backend/redmine/backend-sync/write.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/backend-sync/write.js +100 -0
- package/dist/backends/task-backend/redmine/backend-sync.d.ts +6 -66
- package/dist/backends/task-backend/redmine/backend-sync.d.ts.map +1 -1
- package/dist/backends/task-backend/redmine/backend-sync.js +5 -367
- package/dist/backends/task-backend/redmine/mapping.js +1 -1
- package/dist/backends/task-backend/redmine/runtime-context.d.ts +98 -0
- package/dist/backends/task-backend/redmine/runtime-context.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/runtime-context.js +57 -0
- package/dist/backends/task-backend/redmine/runtime-methods.d.ts +33 -0
- package/dist/backends/task-backend/redmine/runtime-methods.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/runtime-methods.js +86 -0
- package/dist/backends/task-backend/redmine/runtime-operations.d.ts +19 -0
- package/dist/backends/task-backend/redmine/runtime-operations.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/runtime-operations.js +83 -0
- package/dist/backends/task-backend/redmine/runtime-state.d.ts +10 -0
- package/dist/backends/task-backend/redmine/runtime-state.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/runtime-state.js +45 -0
- package/dist/backends/task-backend/redmine-backend.d.ts +2 -33
- package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
- package/dist/backends/task-backend/redmine-backend.js +26 -241
- package/dist/backends/task-backend/shared/constants.d.ts +1 -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/errors.d.ts +12 -0
- package/dist/backends/task-backend/shared/errors.d.ts.map +1 -1
- package/dist/backends/task-backend/shared/errors.js +12 -0
- package/dist/backends/task-index.d.ts +0 -4
- package/dist/backends/task-index.d.ts.map +1 -1
- package/dist/backends/task-index.js +0 -33
- package/dist/cli/archive.d.ts.map +1 -1
- package/dist/cli/archive.js +3 -5
- package/dist/cli/error-map.d.ts +7 -1
- package/dist/cli/error-map.d.ts.map +1 -1
- package/dist/cli/error-map.js +231 -19
- package/dist/cli/exit-codes.d.ts +14 -2
- package/dist/cli/exit-codes.d.ts.map +1 -1
- package/dist/cli/exit-codes.js +25 -11
- package/dist/cli/http.d.ts.map +1 -1
- package/dist/cli/http.js +34 -15
- package/dist/cli/output.d.ts +3 -0
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +25 -14
- package/dist/cli/prompts.d.ts.map +1 -1
- package/dist/cli/prompts.js +44 -0
- package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/core.js +34 -76
- package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/lifecycle.js +23 -26
- package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/project.js +39 -54
- package/dist/cli/run-cli/command-catalog/shared.d.ts +15 -3
- package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/shared.js +19 -6
- package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/task.js +63 -57
- package/dist/cli/run-cli/command-loaders.d.ts +170 -0
- package/dist/cli/run-cli/command-loaders.d.ts.map +1 -0
- package/dist/cli/run-cli/command-loaders.js +128 -0
- package/dist/cli/run-cli/commands/init/model.d.ts +42 -0
- package/dist/cli/run-cli/commands/init/model.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/orchestrate.d.ts +9 -0
- package/dist/cli/run-cli/commands/init/orchestrate.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/orchestrate.js +321 -0
- package/dist/cli/run-cli/commands/init/parsers.d.ts +5 -0
- package/dist/cli/run-cli/commands/init/parsers.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/parsers.js +36 -0
- package/dist/cli/run-cli/commands/init/presets.d.ts +15 -0
- package/dist/cli/run-cli/commands/init/presets.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/presets.js +63 -0
- package/dist/cli/run-cli/commands/init/spec.d.ts +5 -0
- package/dist/cli/run-cli/commands/init/spec.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/spec.js +212 -0
- package/dist/cli/run-cli/commands/init/write-config.d.ts +1 -0
- package/dist/cli/run-cli/commands/init/write-config.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/write-config.js +1 -0
- package/dist/cli/run-cli/commands/init/write-gitignore.js +1 -1
- package/dist/cli/run-cli/commands/init.d.ts +1 -28
- package/dist/cli/run-cli/commands/init.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init.js +1 -596
- package/dist/cli/run-cli/update-warning.d.ts +1 -0
- package/dist/cli/run-cli/update-warning.d.ts.map +1 -1
- package/dist/cli/run-cli/update-warning.js +10 -2
- package/dist/cli/run-cli.d.ts.map +1 -1
- package/dist/cli/run-cli.js +1 -2
- package/dist/cli/spec/errors.d.ts +18 -1
- package/dist/cli/spec/errors.d.ts.map +1 -1
- package/dist/cli/spec/errors.js +27 -4
- package/dist/cli/spec/parse.d.ts.map +1 -1
- package/dist/cli/spec/parse.js +8 -1
- package/dist/commands/backend.d.ts.map +1 -1
- package/dist/commands/backend.js +66 -118
- package/dist/commands/block.spec.js +1 -1
- package/dist/commands/branch/work-start.d.ts.map +1 -1
- package/dist/commands/branch/work-start.direct.d.ts +13 -0
- package/dist/commands/branch/work-start.direct.d.ts.map +1 -0
- package/dist/commands/branch/work-start.direct.js +75 -0
- package/dist/commands/branch/work-start.git.d.ts +3 -0
- package/dist/commands/branch/work-start.git.d.ts.map +1 -0
- package/dist/commands/branch/work-start.git.js +19 -0
- package/dist/commands/branch/work-start.hook-shim.d.ts +2 -0
- package/dist/commands/branch/work-start.hook-shim.d.ts.map +1 -0
- package/dist/commands/branch/work-start.hook-shim.js +38 -0
- package/dist/commands/branch/work-start.js +6 -235
- package/dist/commands/branch/work-start.materialize.d.ts +16 -0
- package/dist/commands/branch/work-start.materialize.d.ts.map +1 -0
- package/dist/commands/branch/work-start.materialize.js +110 -0
- package/dist/commands/commit.spec.js +1 -1
- package/dist/commands/doctor/branch-pr.js +1 -1
- package/dist/commands/doctor/fixes.d.ts +0 -5
- package/dist/commands/doctor/fixes.d.ts.map +1 -1
- package/dist/commands/doctor/fixes.js +1 -71
- package/dist/commands/doctor/runtime.d.ts.map +1 -1
- package/dist/commands/doctor/runtime.js +2 -2
- package/dist/commands/doctor/workflow.d.ts.map +1 -1
- package/dist/commands/doctor/workflow.js +2 -23
- package/dist/commands/doctor/workspace.js +1 -1
- package/dist/commands/doctor.run.d.ts.map +1 -1
- package/dist/commands/doctor.run.js +1 -3
- package/dist/commands/finish.spec.js +1 -1
- package/dist/commands/guard/commit.command.js +1 -1
- package/dist/commands/guard/impl/clean.d.ts +6 -0
- package/dist/commands/guard/impl/clean.d.ts.map +1 -0
- package/dist/commands/guard/impl/clean.js +29 -0
- package/dist/commands/guard/impl/close-dirt.d.ts +6 -0
- package/dist/commands/guard/impl/close-dirt.d.ts.map +1 -0
- package/dist/commands/guard/impl/close-dirt.js +56 -0
- package/dist/commands/guard/impl/commands.d.ts +4 -36
- package/dist/commands/guard/impl/commands.d.ts.map +1 -1
- package/dist/commands/guard/impl/commands.js +4 -549
- package/dist/commands/guard/impl/comment-commit.js +1 -1
- package/dist/commands/guard/impl/commit-diagnostics.d.ts +4 -0
- package/dist/commands/guard/impl/commit-diagnostics.d.ts.map +1 -0
- package/dist/commands/guard/impl/commit-diagnostics.js +150 -0
- package/dist/commands/guard/impl/commit.d.ts +25 -0
- package/dist/commands/guard/impl/commit.d.ts.map +1 -0
- package/dist/commands/guard/impl/commit.js +366 -0
- package/dist/commands/guard/impl/guard-commit.d.ts +3 -0
- package/dist/commands/guard/impl/guard-commit.d.ts.map +1 -0
- package/dist/commands/guard/impl/guard-commit.js +21 -0
- 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 -2
- package/dist/commands/guard/impl/suggest.d.ts +6 -0
- package/dist/commands/guard/impl/suggest.d.ts.map +1 -0
- package/dist/commands/guard/impl/suggest.js +33 -0
- package/dist/commands/hooks/index.d.ts +4 -17
- package/dist/commands/hooks/index.d.ts.map +1 -1
- package/dist/commands/hooks/index.js +4 -415
- package/dist/commands/hooks/install.d.ts +11 -0
- package/dist/commands/hooks/install.d.ts.map +1 -0
- package/dist/commands/hooks/install.js +136 -0
- package/dist/commands/hooks/run.commit-msg.d.ts +3 -0
- package/dist/commands/hooks/run.commit-msg.d.ts.map +1 -0
- package/dist/commands/hooks/run.commit-msg.js +67 -0
- package/dist/commands/hooks/run.d.ts +9 -0
- package/dist/commands/hooks/run.d.ts.map +1 -0
- package/dist/commands/hooks/run.js +45 -0
- package/dist/commands/hooks/run.post-merge.d.ts +3 -0
- package/dist/commands/hooks/run.post-merge.d.ts.map +1 -0
- package/dist/commands/hooks/run.post-merge.js +44 -0
- package/dist/commands/hooks/run.pre-commit.d.ts +3 -0
- package/dist/commands/hooks/run.pre-commit.d.ts.map +1 -0
- package/dist/commands/hooks/run.pre-commit.js +48 -0
- package/dist/commands/hooks/run.pre-push.d.ts +6 -0
- package/dist/commands/hooks/run.pre-push.d.ts.map +1 -0
- package/dist/commands/hooks/run.pre-push.js +88 -0
- package/dist/commands/hooks/shared.d.ts +7 -0
- package/dist/commands/hooks/shared.d.ts.map +1 -0
- package/dist/commands/hooks/shared.js +41 -0
- package/dist/commands/pr/integrate/cmd.js +1 -1
- package/dist/commands/pr/integrate/internal/prepare.js +1 -1
- package/dist/commands/pr/internal/auto-commit.d.ts.map +1 -1
- package/dist/commands/pr/internal/auto-commit.js +2 -5
- package/dist/commands/pr/internal/gh-api.d.ts.map +1 -1
- package/dist/commands/pr/internal/gh-api.js +15 -8
- package/dist/commands/pr/internal/sync-branch.d.ts +0 -1
- package/dist/commands/pr/internal/sync-branch.d.ts.map +1 -1
- package/dist/commands/pr/internal/sync-branch.js +2 -5
- package/dist/commands/pr/internal/sync.d.ts.map +1 -1
- package/dist/commands/pr/internal/sync.js +30 -0
- package/dist/commands/pr/open.d.ts.map +1 -1
- package/dist/commands/pr/open.js +98 -8
- package/dist/commands/recipes/impl/index.d.ts.map +1 -1
- package/dist/commands/recipes/impl/index.js +13 -3
- package/dist/commands/recipes/impl/resolver.js +1 -1
- package/dist/commands/recipes/impl/version.js +1 -1
- package/dist/commands/release/apply.command.js +1 -1
- package/dist/commands/release/apply.mutation.d.ts +1 -0
- package/dist/commands/release/apply.mutation.d.ts.map +1 -1
- package/dist/commands/release/apply.mutation.js +4 -0
- package/dist/commands/release/apply.pipeline/finalize.d.ts +21 -0
- package/dist/commands/release/apply.pipeline/finalize.d.ts.map +1 -0
- package/dist/commands/release/apply.pipeline/finalize.js +80 -0
- package/dist/commands/release/apply.pipeline/mutation.d.ts +18 -0
- package/dist/commands/release/apply.pipeline/mutation.d.ts.map +1 -0
- package/dist/commands/release/apply.pipeline/mutation.js +78 -0
- package/dist/commands/release/apply.pipeline/preflight.d.ts +25 -0
- package/dist/commands/release/apply.pipeline/preflight.d.ts.map +1 -0
- package/dist/commands/release/apply.pipeline/preflight.js +69 -0
- package/dist/commands/release/apply.pipeline/shared.d.ts +2 -0
- package/dist/commands/release/apply.pipeline/shared.d.ts.map +1 -0
- package/dist/commands/release/apply.pipeline/shared.js +5 -0
- package/dist/commands/release/apply.pipeline/state.d.ts +25 -0
- package/dist/commands/release/apply.pipeline/state.d.ts.map +1 -0
- package/dist/commands/release/apply.pipeline/state.js +129 -0
- package/dist/commands/release/apply.pipeline.d.ts +1 -1
- package/dist/commands/release/apply.pipeline.d.ts.map +1 -1
- package/dist/commands/release/apply.pipeline.js +4 -347
- package/dist/commands/release/apply.preflight.d.ts +9 -6
- package/dist/commands/release/apply.preflight.d.ts.map +1 -1
- package/dist/commands/release/apply.preflight.js +71 -51
- package/dist/commands/runtime.command.d.ts +2 -2
- package/dist/commands/runtime.command.d.ts.map +1 -1
- package/dist/commands/runtime.command.js +2 -2
- package/dist/commands/scenario/impl/commands.d.ts.map +1 -1
- package/dist/commands/scenario/impl/commands.js +52 -39
- package/dist/commands/scenario/impl/report.d.ts.map +1 -1
- package/dist/commands/scenario/impl/report.js +4 -7
- package/dist/commands/shared/allow-prefix-policy.d.ts.map +1 -0
- package/dist/{shared → commands/shared}/allow-prefix-policy.js +1 -1
- package/dist/commands/shared/comment-format.d.ts.map +1 -0
- package/dist/commands/shared/diagnostics.d.ts.map +1 -0
- package/dist/commands/shared/git-context.d.ts +1 -27
- package/dist/commands/shared/git-context.d.ts.map +1 -1
- package/dist/commands/shared/git-context.js +1 -156
- package/dist/commands/shared/git-diff.d.ts +1 -10
- package/dist/commands/shared/git-diff.d.ts.map +1 -1
- package/dist/commands/shared/git-diff.js +1 -49
- package/dist/commands/shared/git-ops.d.ts +1 -14
- package/dist/commands/shared/git-ops.d.ts.map +1 -1
- package/dist/commands/shared/git-ops.js +20 -150
- package/dist/commands/shared/git-worktree.d.ts +1 -9
- package/dist/commands/shared/git-worktree.d.ts.map +1 -1
- package/dist/commands/shared/git-worktree.js +1 -68
- package/dist/commands/shared/git.d.ts +1 -3
- package/dist/commands/shared/git.d.ts.map +1 -1
- package/dist/commands/shared/git.js +1 -14
- package/dist/commands/shared/policy-deny.d.ts +1 -1
- package/dist/commands/shared/reconcile-check.js +1 -1
- package/dist/commands/shared/task-backend.d.ts.map +1 -1
- package/dist/commands/shared/task-backend.js +24 -2
- package/dist/commands/shared/task-store/intents.d.ts.map +1 -1
- package/dist/commands/shared/task-store/intents.js +1 -1
- package/dist/commands/start.spec.js +1 -1
- package/dist/commands/task/close-tail-state.d.ts +7 -0
- package/dist/commands/task/close-tail-state.d.ts.map +1 -0
- package/dist/commands/task/close-tail-state.js +18 -0
- package/dist/commands/task/derive.js +1 -1
- package/dist/commands/task/finish-close.d.ts +22 -0
- package/dist/commands/task/finish-close.d.ts.map +1 -0
- package/dist/commands/task/finish-close.js +119 -0
- package/dist/commands/task/finish-command.d.ts +3 -0
- package/dist/commands/task/finish-command.d.ts.map +1 -0
- package/dist/commands/task/finish-command.js +56 -0
- package/dist/commands/task/finish-execute.d.ts +8 -0
- package/dist/commands/task/finish-execute.d.ts.map +1 -0
- package/dist/commands/task/finish-execute.js +272 -0
- package/dist/commands/task/finish-findings.d.ts +20 -0
- package/dist/commands/task/finish-findings.d.ts.map +1 -0
- package/dist/commands/task/finish-findings.js +27 -0
- package/dist/commands/task/finish-plan.d.ts +7 -0
- package/dist/commands/task/finish-plan.d.ts.map +1 -0
- package/dist/commands/task/finish-plan.js +157 -0
- package/dist/commands/task/finish-types.d.ts +69 -0
- package/dist/commands/task/finish-types.d.ts.map +1 -0
- package/dist/commands/task/finish.d.ts +1 -42
- package/dist/commands/task/finish.d.ts.map +1 -1
- package/dist/commands/task/finish.js +1 -527
- package/dist/commands/task/hosted-close-pr.command.d.ts +2 -7
- package/dist/commands/task/hosted-close-pr.command.d.ts.map +1 -1
- package/dist/commands/task/hosted-close-pr.command.js +9 -348
- package/dist/commands/task/hosted-close-pr.execute.d.ts +3 -0
- package/dist/commands/task/hosted-close-pr.execute.d.ts.map +1 -0
- package/dist/commands/task/hosted-close-pr.execute.js +135 -0
- package/dist/commands/task/hosted-close-pr.postcheck.d.ts +3 -0
- package/dist/commands/task/hosted-close-pr.postcheck.d.ts.map +1 -0
- package/dist/commands/task/hosted-close-pr.postcheck.js +13 -0
- package/dist/commands/task/hosted-close-pr.precheck.d.ts +4 -0
- package/dist/commands/task/hosted-close-pr.precheck.d.ts.map +1 -0
- package/dist/commands/task/hosted-close-pr.precheck.js +288 -0
- package/dist/commands/task/hosted-close-pr.report.d.ts +4 -0
- package/dist/commands/task/hosted-close-pr.report.d.ts.map +1 -0
- package/dist/commands/task/hosted-close-pr.report.js +42 -0
- package/dist/commands/task/hosted-close-pr.types.d.ts +75 -0
- package/dist/commands/task/hosted-close-pr.types.d.ts.map +1 -0
- package/dist/commands/task/hosted-merge-sync/builders.d.ts +35 -0
- package/dist/commands/task/hosted-merge-sync/builders.d.ts.map +1 -0
- package/dist/commands/task/hosted-merge-sync/builders.js +148 -0
- package/dist/commands/task/hosted-merge-sync/github.d.ts +10 -0
- package/dist/commands/task/hosted-merge-sync/github.d.ts.map +1 -0
- package/dist/commands/task/hosted-merge-sync/github.js +113 -0
- package/dist/commands/task/hosted-merge-sync/local-branch.d.ts +12 -0
- package/dist/commands/task/hosted-merge-sync/local-branch.d.ts.map +1 -0
- package/dist/commands/task/hosted-merge-sync/local-branch.js +143 -0
- package/dist/commands/task/hosted-merge-sync/model.d.ts +47 -0
- package/dist/commands/task/hosted-merge-sync/model.d.ts.map +1 -0
- package/dist/commands/task/hosted-merge-sync/pr-meta.d.ts +12 -0
- package/dist/commands/task/hosted-merge-sync/pr-meta.d.ts.map +1 -0
- package/dist/commands/task/hosted-merge-sync/pr-meta.js +26 -0
- package/dist/commands/task/hosted-merge-sync.d.ts +5 -63
- package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
- package/dist/commands/task/hosted-merge-sync.js +10 -444
- package/dist/commands/task/new.js +1 -1
- package/dist/commands/task/set-status.command.js +1 -1
- package/dist/commands/task/shared/direct-work-lock.d.ts.map +1 -0
- package/dist/commands/task/shared/git-log.d.ts.map +1 -0
- package/dist/commands/task/shared/transitions.d.ts +1 -1
- package/dist/commands/task/shared/transitions.d.ts.map +1 -1
- package/dist/commands/task/shared/transitions.js +4 -6
- package/dist/commands/upgrade/apply.js +1 -1
- package/dist/commands/upgrade/materialize.d.ts.map +1 -1
- package/dist/commands/upgrade/materialize.js +0 -7
- package/dist/commands/upgrade/source.d.ts +0 -1
- package/dist/commands/upgrade/source.d.ts.map +1 -1
- package/dist/commands/upgrade/source.js +1 -9
- package/dist/commands/workflow-playbook.command.d.ts.map +1 -1
- package/dist/commands/workflow-playbook.command.js +8 -7
- package/dist/harness/hooks-lifecycle.d.ts.map +1 -1
- package/dist/harness/hooks-lifecycle.js +11 -7
- package/dist/meta/release.d.ts.map +1 -1
- package/dist/meta/release.js +8 -4
- package/dist/policy/engine.d.ts +1 -1
- package/dist/policy/evaluate.d.ts +1 -1
- package/dist/policy/{types.d.ts → model.d.ts} +1 -1
- package/dist/policy/{types.d.ts.map → model.d.ts.map} +1 -1
- package/dist/policy/result.d.ts +1 -1
- package/dist/policy/rules/allowlist.d.ts +1 -1
- package/dist/policy/rules/branch-pr-base.d.ts +1 -1
- package/dist/policy/rules/clean-tree.d.ts +1 -1
- package/dist/policy/rules/commit-subject.d.ts +1 -1
- package/dist/policy/rules/protected-paths.d.ts +1 -1
- package/dist/runner/adapters/base.d.ts +42 -0
- package/dist/runner/adapters/base.d.ts.map +1 -0
- package/dist/runner/adapters/base.js +107 -0
- package/dist/runner/adapters/codex-preparation.d.ts +7 -0
- package/dist/runner/adapters/codex-preparation.d.ts.map +1 -0
- package/dist/runner/adapters/codex-preparation.js +86 -0
- package/dist/runner/adapters/codex.d.ts.map +1 -1
- package/dist/runner/adapters/codex.js +30 -175
- package/dist/runner/adapters/custom-preparation.d.ts +9 -0
- package/dist/runner/adapters/custom-preparation.d.ts.map +1 -0
- package/dist/runner/adapters/custom-preparation.js +191 -0
- package/dist/runner/adapters/custom.d.ts.map +1 -1
- package/dist/runner/adapters/custom.js +26 -279
- package/dist/runner/context/base-prompts.d.ts.map +1 -1
- package/dist/runner/context/base-prompts.js +4 -0
- package/dist/runner/context/project-skill-prompt-blocks.d.ts +5 -0
- package/dist/runner/context/project-skill-prompt-blocks.d.ts.map +1 -0
- package/dist/runner/context/project-skill-prompt-blocks.js +57 -0
- package/dist/runner/process-supervision/run.d.ts +30 -0
- package/dist/runner/process-supervision/run.d.ts.map +1 -0
- package/dist/runner/process-supervision/run.js +351 -0
- package/dist/runner/process-supervision/signals.d.ts +16 -0
- package/dist/runner/process-supervision/signals.d.ts.map +1 -0
- package/dist/runner/process-supervision/signals.js +85 -0
- package/dist/runner/process-supervision/state.d.ts +10 -0
- package/dist/runner/process-supervision/state.d.ts.map +1 -0
- package/dist/runner/process-supervision/state.js +42 -0
- package/dist/runner/process-supervision/streams.d.ts +6 -0
- package/dist/runner/process-supervision/streams.d.ts.map +1 -0
- package/dist/runner/process-supervision/streams.js +23 -0
- package/dist/runner/process-supervision.d.ts +5 -47
- package/dist/runner/process-supervision.d.ts.map +1 -1
- package/dist/runner/process-supervision.js +3 -490
- package/dist/runner/usecases/scenario-materialize-task.js +1 -1
- package/dist/runtime/approvals/index.d.ts +1 -1
- package/dist/runtime/approvals/{types.d.ts → model.d.ts} +1 -1
- package/dist/runtime/approvals/{types.d.ts.map → model.d.ts.map} +1 -1
- package/dist/runtime/approvals/runtime.d.ts +1 -1
- package/dist/runtime/behavior/index.d.ts +1 -1
- package/dist/runtime/behavior/{types.d.ts → model.d.ts} +1 -1
- package/dist/runtime/behavior/{types.d.ts.map → model.d.ts.map} +1 -1
- package/dist/runtime/behavior/model.js +1 -0
- package/dist/runtime/behavior/resolve.d.ts +1 -1
- package/dist/runtime/capabilities/backend.d.ts +1 -1
- package/dist/runtime/capabilities/index.d.ts +1 -1
- package/dist/runtime/capabilities/{types.d.ts → model.d.ts} +1 -1
- package/dist/runtime/capabilities/{types.d.ts.map → model.d.ts.map} +1 -1
- package/dist/runtime/capabilities/model.js +1 -0
- package/dist/runtime/capabilities/recipe.d.ts +1 -1
- package/dist/runtime/capabilities/registry.d.ts +1 -1
- package/dist/runtime/capabilities/runner.d.ts +1 -1
- package/dist/runtime/execution-context.d.ts.map +1 -1
- package/dist/runtime/execution-context.js +16 -0
- package/dist/runtime/execution-profile/index.d.ts +1 -1
- package/dist/runtime/execution-profile/{types.d.ts → model.d.ts} +1 -1
- package/dist/runtime/execution-profile/{types.d.ts.map → model.d.ts.map} +1 -1
- package/dist/runtime/execution-profile/model.js +1 -0
- package/dist/runtime/execution-profile/resolve.d.ts +1 -1
- package/dist/runtime/explain/index.d.ts +1 -1
- package/dist/runtime/explain/{types.d.ts → model.d.ts} +1 -1
- package/dist/runtime/explain/{types.d.ts.map → model.d.ts.map} +1 -1
- package/dist/runtime/explain/model.js +1 -0
- package/dist/runtime/explain/resolve.d.ts +1 -1
- package/dist/runtime/protocol/index.d.ts +1 -1
- package/dist/runtime/protocol/index.js +1 -1
- package/dist/runtime/protocol/{types.d.ts → model.d.ts} +1 -1
- package/dist/runtime/protocol/{types.d.ts.map → model.d.ts.map} +1 -1
- package/dist/runtime/protocol/resolve.d.ts +1 -1
- package/dist/runtime/protocol/resolve.js +1 -1
- package/dist/runtime/shared/repo-cli-version.d.ts.map +1 -0
- package/dist/{shared → runtime/shared}/repo-cli-version.js +1 -1
- package/dist/runtime/shared/runtime-artifacts.d.ts.map +1 -0
- package/dist/{shared → runtime/shared}/runtime-source.d.ts +1 -1
- package/dist/runtime/shared/runtime-source.d.ts.map +1 -0
- package/dist/{shared → runtime/shared}/runtime-source.js +1 -1
- package/dist/runtime/shared/version-compare.d.ts.map +1 -0
- package/dist/runtime/task-intake/resolve.js +1 -1
- package/dist/shared/errors.d.ts +56 -3
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/errors.js +72 -4
- package/dist/shared/trace-events.d.ts +13 -0
- package/dist/shared/trace-events.d.ts.map +1 -0
- package/dist/shared/trace-events.js +17 -0
- package/dist/shared/workflow-artifacts.d.ts.map +1 -1
- package/dist/shared/workflow-artifacts.js +1 -8
- package/dist/{shared/task-doc-conflicts.d.ts → task-doc/conflicts.d.ts} +1 -1
- package/dist/task-doc/conflicts.d.ts.map +1 -0
- package/dist/{shared/task-doc-conflicts.js → task-doc/conflicts.js} +1 -1
- package/dist/{shared/task-doc-state.d.ts → task-doc/state.d.ts} +1 -1
- package/dist/task-doc/state.d.ts.map +1 -0
- package/dist/workflow-runtime/file-ops.d.ts.map +1 -1
- package/dist/workflow-runtime/file-ops.js +1 -20
- package/dist/workflow-runtime/paths.d.ts.map +1 -1
- package/dist/workflow-runtime/paths.js +0 -1
- package/dist/workflow-runtime/types.d.ts +0 -1
- package/dist/workflow-runtime/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/cli/run-cli/error-guidance.d.ts +0 -9
- package/dist/cli/run-cli/error-guidance.d.ts.map +0 -1
- package/dist/cli/run-cli/error-guidance.js +0 -210
- package/dist/cli/run-cli.test-helpers.d.ts +0 -2
- package/dist/cli/run-cli.test-helpers.d.ts.map +0 -1
- package/dist/cli/run-cli.test-helpers.js +0 -1
- package/dist/commands/recipes.test-helpers.d.ts +0 -202
- package/dist/commands/recipes.test-helpers.d.ts.map +0 -1
- package/dist/commands/recipes.test-helpers.js +0 -483
- package/dist/commands/release.test-helpers.d.ts +0 -38
- package/dist/commands/release.test-helpers.d.ts.map +0 -1
- package/dist/commands/release.test-helpers.js +0 -55
- package/dist/commands/task.test-helpers.d.ts +0 -13
- package/dist/commands/task.test-helpers.d.ts.map +0 -1
- package/dist/commands/task.test-helpers.js +0 -65
- package/dist/runner/test-helpers.d.ts +0 -30
- package/dist/runner/test-helpers.d.ts.map +0 -1
- package/dist/runner/test-helpers.js +0 -97
- package/dist/shared/agent-emoji.d.ts +0 -5
- package/dist/shared/agent-emoji.d.ts.map +0 -1
- package/dist/shared/agent-emoji.js +0 -51
- package/dist/shared/allow-prefix-policy.d.ts.map +0 -1
- package/dist/shared/comment-format.d.ts.map +0 -1
- package/dist/shared/diagnostics.d.ts.map +0 -1
- package/dist/shared/direct-work-lock.d.ts.map +0 -1
- package/dist/shared/git-log.d.ts.map +0 -1
- package/dist/shared/repo-cli-version.d.ts.map +0 -1
- package/dist/shared/runtime-artifacts.d.ts.map +0 -1
- package/dist/shared/runtime-source.d.ts.map +0 -1
- package/dist/shared/task-doc-conflicts.d.ts.map +0 -1
- package/dist/shared/task-doc-state.d.ts.map +0 -1
- package/dist/shared/version-compare.d.ts.map +0 -1
- package/dist/testing/cli-harness/recipe-archives.d.ts +0 -28
- package/dist/testing/cli-harness/recipe-archives.d.ts.map +0 -1
- package/dist/testing/cli-harness/recipe-archives.js +0 -374
- package/dist/testing/cli-harness/stdio.d.ts +0 -26
- package/dist/testing/cli-harness/stdio.d.ts.map +0 -1
- package/dist/testing/cli-harness/stdio.js +0 -84
- package/dist/testing/cli-harness.d.ts +0 -25
- package/dist/testing/cli-harness.d.ts.map +0 -1
- package/dist/testing/cli-harness.js +0 -313
- package/dist/testing/index.d.ts +0 -2
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js +0 -1
- /package/dist/{policy/types.js → cli/run-cli/commands/init/model.js} +0 -0
- /package/dist/{shared → commands/shared}/allow-prefix-policy.d.ts +0 -0
- /package/dist/{shared → commands/shared}/comment-format.d.ts +0 -0
- /package/dist/{shared → commands/shared}/comment-format.js +0 -0
- /package/dist/{shared → commands/shared}/diagnostics.d.ts +0 -0
- /package/dist/{shared → commands/shared}/diagnostics.js +0 -0
- /package/dist/{runtime/approvals/types.js → commands/task/finish-types.js} +0 -0
- /package/dist/{runtime/behavior/types.js → commands/task/hosted-close-pr.types.js} +0 -0
- /package/dist/{runtime/capabilities/types.js → commands/task/hosted-merge-sync/model.js} +0 -0
- /package/dist/{shared → commands/task/shared}/direct-work-lock.d.ts +0 -0
- /package/dist/{shared → commands/task/shared}/direct-work-lock.js +0 -0
- /package/dist/{shared → commands/task/shared}/git-log.d.ts +0 -0
- /package/dist/{shared → commands/task/shared}/git-log.js +0 -0
- /package/dist/{runtime/execution-profile/types.js → policy/model.js} +0 -0
- /package/dist/runtime/{explain/types.js → approvals/model.js} +0 -0
- /package/dist/runtime/protocol/{types.js → model.js} +0 -0
- /package/dist/{shared → runtime/shared}/repo-cli-version.d.ts +0 -0
- /package/dist/{shared → runtime/shared}/runtime-artifacts.d.ts +0 -0
- /package/dist/{shared → runtime/shared}/runtime-artifacts.js +0 -0
- /package/dist/{shared → runtime/shared}/version-compare.d.ts +0 -0
- /package/dist/{shared → runtime/shared}/version-compare.js +0 -0
- /package/dist/{shared/task-doc-state.js → task-doc/state.js} +0 -0
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
1
|
import { usageError } from "../../cli/spec/errors.js";
|
|
3
|
-
import { createCliEmitter } from "../../cli/output.js";
|
|
4
2
|
import { mapBackendError } from "../../cli/error-map.js";
|
|
5
|
-
import { exitCodeForError } from "../../cli/exit-codes.js";
|
|
6
|
-
import { fileExists } from "../../cli/fs-utils.js";
|
|
7
3
|
import { CliError } from "../../shared/errors.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { parsePrMeta } from "../shared/pr-meta.js";
|
|
13
|
-
import { resolveDefaultGithubRepo, runGhApiJson } from "../pr/internal/gh-api.js";
|
|
14
|
-
import { resolvePrPaths } from "../pr/internal/pr-paths.js";
|
|
15
|
-
import { resolveBaseBranch } from "@agentplaneorg/core";
|
|
4
|
+
import { executeHostedClosePrPlan } from "./hosted-close-pr.execute.js";
|
|
5
|
+
import { postcheckHostedClosePrResult } from "./hosted-close-pr.postcheck.js";
|
|
6
|
+
import { precheckHostedClosePr } from "./hosted-close-pr.precheck.js";
|
|
7
|
+
import { reportHostedClosePrExecutionResult, reportHostedClosePrOutcome, } from "./hosted-close-pr.report.js";
|
|
16
8
|
export const taskHostedClosePrSpec = {
|
|
17
9
|
id: ["task", "hosted-close-pr"],
|
|
18
10
|
group: "Task",
|
|
@@ -80,345 +72,14 @@ export const taskHostedClosePrSpec = {
|
|
|
80
72
|
repo: typeof raw.opts.repo === "string" ? raw.opts.repo : null,
|
|
81
73
|
}),
|
|
82
74
|
};
|
|
83
|
-
async function resolveGithubRepo(opts) {
|
|
84
|
-
const repo = opts.repoOverride?.trim() ?? "";
|
|
85
|
-
if (repo)
|
|
86
|
-
return repo;
|
|
87
|
-
return await resolveDefaultGithubRepo(opts.gitRoot);
|
|
88
|
-
}
|
|
89
|
-
function selectMergedPullRecord(opts) {
|
|
90
|
-
const merged = opts.pulls.filter((record) => {
|
|
91
|
-
if (typeof record.merged_at !== "string" || record.merged_at.trim().length === 0)
|
|
92
|
-
return false;
|
|
93
|
-
const headRef = record.head?.ref?.trim() ?? "";
|
|
94
|
-
if (opts.sourceBranch && headRef && headRef !== opts.sourceBranch)
|
|
95
|
-
return false;
|
|
96
|
-
const baseRef = record.base?.ref?.trim() ?? "";
|
|
97
|
-
if (opts.baseBranch && baseRef && baseRef !== opts.baseBranch)
|
|
98
|
-
return false;
|
|
99
|
-
return true;
|
|
100
|
-
});
|
|
101
|
-
if (merged.length === 0)
|
|
102
|
-
return null;
|
|
103
|
-
if (typeof opts.prNumber === "number" && opts.prNumber > 0) {
|
|
104
|
-
const exact = merged.find((record) => Number(record.number ?? 0) === opts.prNumber);
|
|
105
|
-
if (exact)
|
|
106
|
-
return exact;
|
|
107
|
-
}
|
|
108
|
-
return ([...merged].toSorted((left, right) => {
|
|
109
|
-
const leftAt = Date.parse(left.merged_at ?? "");
|
|
110
|
-
const rightAt = Date.parse(right.merged_at ?? "");
|
|
111
|
-
return Number.isNaN(rightAt) || Number.isNaN(leftAt) ? 0 : rightAt - leftAt;
|
|
112
|
-
})[0] ?? null);
|
|
113
|
-
}
|
|
114
|
-
async function resolveHostedCloseMergeRecord(opts) {
|
|
115
|
-
const owner = opts.repo.split("/")[0]?.trim() ?? "";
|
|
116
|
-
if (!owner)
|
|
117
|
-
return null;
|
|
118
|
-
const query = new URLSearchParams({
|
|
119
|
-
state: "closed",
|
|
120
|
-
head: `${owner}:${opts.sourceBranch}`,
|
|
121
|
-
});
|
|
122
|
-
if (opts.baseBranch)
|
|
123
|
-
query.set("base", opts.baseBranch);
|
|
124
|
-
const records = await runGhApiJson(opts.gitRoot, [
|
|
125
|
-
`repos/${opts.repo}/pulls?${query.toString()}`,
|
|
126
|
-
]);
|
|
127
|
-
return selectMergedPullRecord({
|
|
128
|
-
pulls: Array.isArray(records) ? records : [],
|
|
129
|
-
sourceBranch: opts.sourceBranch,
|
|
130
|
-
baseBranch: opts.baseBranch,
|
|
131
|
-
prNumber: opts.prNumber,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
async function resolveHostedCloseMergeRecordByCommit(opts) {
|
|
135
|
-
const records = await runGhApiJson(opts.gitRoot, [
|
|
136
|
-
`repos/${opts.repo}/commits/${opts.mergeCommit}/pulls`,
|
|
137
|
-
]);
|
|
138
|
-
return selectMergedPullRecord({
|
|
139
|
-
pulls: Array.isArray(records) ? records : [],
|
|
140
|
-
sourceBranch: opts.sourceBranch,
|
|
141
|
-
baseBranch: opts.baseBranch,
|
|
142
|
-
prNumber: opts.prNumber,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
async function readHostedCloseState(opts) {
|
|
146
|
-
const task = await loadTaskFromContext({ ctx: opts.ctx, taskId: opts.taskId });
|
|
147
|
-
const taskBranch = await resolveTaskBranchFromContext({ ctx: opts.ctx, taskId: opts.taskId });
|
|
148
|
-
const { metaPath, config } = await resolvePrPaths({
|
|
149
|
-
ctx: opts.ctx,
|
|
150
|
-
cwd: opts.cwd,
|
|
151
|
-
rootOverride: opts.rootOverride,
|
|
152
|
-
taskId: opts.taskId,
|
|
153
|
-
});
|
|
154
|
-
if (config.workflow_mode !== "branch_pr") {
|
|
155
|
-
throw new CliError({
|
|
156
|
-
exitCode: exitCodeForError("E_USAGE"),
|
|
157
|
-
code: "E_USAGE",
|
|
158
|
-
message: `Invalid workflow_mode: ${config.workflow_mode} (expected branch_pr)`,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
if (!(await fileExists(metaPath))) {
|
|
162
|
-
return { meta: null, task, taskBranch };
|
|
163
|
-
}
|
|
164
|
-
const meta = parsePrMeta(await readFile(metaPath, "utf8"), opts.taskId);
|
|
165
|
-
return { meta, task, taskBranch };
|
|
166
|
-
}
|
|
167
|
-
async function listRemoteTaskCloseBranches(opts) {
|
|
168
|
-
const { stdout } = await execFileAsync("git", ["ls-remote", "--heads", "origin", `task-close/${opts.taskId}/*`], {
|
|
169
|
-
cwd: opts.gitRoot,
|
|
170
|
-
env: gitEnv(),
|
|
171
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
172
|
-
});
|
|
173
|
-
return stdout
|
|
174
|
-
.split("\n")
|
|
175
|
-
.map((line) => line.trim())
|
|
176
|
-
.filter((line) => line.length > 0)
|
|
177
|
-
.map((line) => line.split(/\s+/, 2)[1] ?? "")
|
|
178
|
-
.map((ref) => ref.replace(/^refs\/heads\//, ""))
|
|
179
|
-
.filter((ref) => ref.length > 0);
|
|
180
|
-
}
|
|
181
|
-
function shortSha(value) {
|
|
182
|
-
return value.trim().slice(0, 12);
|
|
183
|
-
}
|
|
184
|
-
function stripBranchRef(branch) {
|
|
185
|
-
return branch.startsWith("refs/heads/") ? branch.slice("refs/heads/".length) : branch;
|
|
186
|
-
}
|
|
187
|
-
async function resolveHostedCloseBranch(opts) {
|
|
188
|
-
const remoteBranches = await listRemoteTaskCloseBranches({
|
|
189
|
-
gitRoot: opts.gitRoot,
|
|
190
|
-
taskId: opts.taskId,
|
|
191
|
-
});
|
|
192
|
-
const explicitBranch = stripBranchRef(opts.explicitBranch?.trim() ?? "");
|
|
193
|
-
if (explicitBranch) {
|
|
194
|
-
const parsedTaskId = parseTaskIdFromCloseBranch(explicitBranch);
|
|
195
|
-
if (parsedTaskId && parsedTaskId !== opts.taskId) {
|
|
196
|
-
throw new CliError({
|
|
197
|
-
exitCode: exitCodeForError("E_VALIDATION"),
|
|
198
|
-
code: "E_VALIDATION",
|
|
199
|
-
message: `Branch ${explicitBranch} does not belong to task ${opts.taskId}.`,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
if (!remoteBranches.includes(explicitBranch)) {
|
|
203
|
-
throw new CliError({
|
|
204
|
-
exitCode: exitCodeForError("E_VALIDATION"),
|
|
205
|
-
code: "E_VALIDATION",
|
|
206
|
-
message: `Remote hosted closure branch not found: ${explicitBranch}.`,
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
return explicitBranch;
|
|
210
|
-
}
|
|
211
|
-
if (opts.mergeCommit) {
|
|
212
|
-
const expected = `task-close/${opts.taskId}/${shortSha(opts.mergeCommit)}`;
|
|
213
|
-
if (remoteBranches.includes(expected))
|
|
214
|
-
return expected;
|
|
215
|
-
if (remoteBranches.length === 1)
|
|
216
|
-
return remoteBranches[0] ?? expected;
|
|
217
|
-
if (remoteBranches.length > 1) {
|
|
218
|
-
throw new CliError({
|
|
219
|
-
exitCode: exitCodeForError("E_VALIDATION"),
|
|
220
|
-
code: "E_VALIDATION",
|
|
221
|
-
message: `Multiple remote hosted closure branches match ${opts.taskId}: ${remoteBranches.join(", ")} (use --branch).`,
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
throw new CliError({
|
|
225
|
-
exitCode: exitCodeForError("E_VALIDATION"),
|
|
226
|
-
code: "E_VALIDATION",
|
|
227
|
-
message: `Remote hosted closure branch not found for ${opts.taskId}: ${expected}.`,
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
if (remoteBranches.length === 1)
|
|
231
|
-
return remoteBranches[0] ?? "";
|
|
232
|
-
if (remoteBranches.length > 1) {
|
|
233
|
-
throw new CliError({
|
|
234
|
-
exitCode: exitCodeForError("E_VALIDATION"),
|
|
235
|
-
code: "E_VALIDATION",
|
|
236
|
-
message: `Multiple remote hosted closure branches match ${opts.taskId}: ${remoteBranches.join(", ")} (use --branch).`,
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
throw new CliError({
|
|
240
|
-
exitCode: exitCodeForError("E_VALIDATION"),
|
|
241
|
-
code: "E_VALIDATION",
|
|
242
|
-
message: `Could not resolve remote hosted closure branch for ${opts.taskId}.`,
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
function buildHostedClosePrTitle(taskId) {
|
|
246
|
-
return `📝 ${taskId} task: close after hosted merge`;
|
|
247
|
-
}
|
|
248
|
-
function buildHostedClosePrBody(opts) {
|
|
249
|
-
const prLine = typeof opts.prNumber === "number" && opts.prNumber > 0
|
|
250
|
-
? `Automated closure for merged task PR #${opts.prNumber}.`
|
|
251
|
-
: "Automated closure for merged task PR.";
|
|
252
|
-
return [
|
|
253
|
-
prLine,
|
|
254
|
-
"",
|
|
255
|
-
`- task_id: \`${opts.taskId}\``,
|
|
256
|
-
`- source_branch: \`${opts.sourceBranch}\``,
|
|
257
|
-
`- merge_sha: \`${opts.mergeSha}\``,
|
|
258
|
-
"",
|
|
259
|
-
"This PR contains only tracked task artifacts produced by the hosted branch_pr closure flow.",
|
|
260
|
-
].join("\n");
|
|
261
|
-
}
|
|
262
|
-
function normalizeGithubPrLink(prNumber, prUrl, verb) {
|
|
263
|
-
return prUrl?.trim()
|
|
264
|
-
? `${verb} GitHub PR #${prNumber}: ${prUrl.trim()}`
|
|
265
|
-
: `${verb} GitHub PR #${prNumber}`;
|
|
266
|
-
}
|
|
267
|
-
async function maybeCleanupMergedTaskBranch(opts) {
|
|
268
|
-
try {
|
|
269
|
-
const cleanup = await cleanupMergedLocalBranch({
|
|
270
|
-
gitRoot: opts.gitRoot,
|
|
271
|
-
branch: opts.branch,
|
|
272
|
-
});
|
|
273
|
-
if (!cleanup.removedBranch && !cleanup.removedWorktree) {
|
|
274
|
-
if (cleanup.skippedReason === "current_worktree") {
|
|
275
|
-
opts.output.info(`local merged branch cleanup skipped: ${opts.branch} is the current checkout`);
|
|
276
|
-
}
|
|
277
|
-
else if (cleanup.skippedReason === "outside_repo") {
|
|
278
|
-
opts.output.info(`local merged branch cleanup skipped: ${opts.branch} is attached to a worktree outside the current checkout root`);
|
|
279
|
-
}
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
const details = [];
|
|
283
|
-
if (cleanup.removedWorktree && cleanup.worktreePath) {
|
|
284
|
-
details.push(`removed worktree ${cleanup.worktreePath}`);
|
|
285
|
-
}
|
|
286
|
-
if (cleanup.removedBranch) {
|
|
287
|
-
details.push(`deleted branch ${opts.branch}`);
|
|
288
|
-
}
|
|
289
|
-
opts.output.info(`local merged branch cleanup: ${details.join("; ")}`);
|
|
290
|
-
}
|
|
291
|
-
catch (error) {
|
|
292
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
293
|
-
opts.output.warn(`local merged branch cleanup failed for ${opts.branch}: ${message}`);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
75
|
async function openHostedClosePr(opts) {
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
cwd: opts.cwd,
|
|
301
|
-
rootOverride: opts.rootOverride,
|
|
302
|
-
taskId: opts.taskId,
|
|
303
|
-
});
|
|
304
|
-
const gitRoot = opts.ctx.resolvedProject.gitRoot;
|
|
305
|
-
const repo = await resolveGithubRepo({ gitRoot, repoOverride: opts.repo ?? null });
|
|
306
|
-
const defaultBaseBranch = await resolveBaseBranch({
|
|
307
|
-
cwd: opts.cwd,
|
|
308
|
-
rootOverride: opts.rootOverride ?? null,
|
|
309
|
-
cliBaseOpt: null,
|
|
310
|
-
mode: opts.ctx.config.workflow_mode,
|
|
311
|
-
});
|
|
312
|
-
let sourceBranch = meta?.branch?.trim() ?? taskBranch?.trim() ?? "";
|
|
313
|
-
let baseBranch = meta?.base?.trim() ?? defaultBaseBranch?.trim() ?? "";
|
|
314
|
-
let mergedRecord = sourceBranch.length > 0 &&
|
|
315
|
-
(meta?.status !== "MERGED" || !(meta?.merge_commit?.trim() ?? task.commit?.hash?.trim() ?? ""))
|
|
316
|
-
? await resolveHostedCloseMergeRecord({
|
|
317
|
-
gitRoot,
|
|
318
|
-
repo,
|
|
319
|
-
sourceBranch,
|
|
320
|
-
baseBranch: baseBranch || null,
|
|
321
|
-
prNumber: typeof meta?.pr_number === "number" ? meta.pr_number : null,
|
|
322
|
-
})
|
|
323
|
-
: null;
|
|
324
|
-
const localMergeCommit = meta?.merge_commit?.trim() ?? task.commit?.hash?.trim() ?? "";
|
|
325
|
-
if (!mergedRecord && localMergeCommit) {
|
|
326
|
-
mergedRecord = await resolveHostedCloseMergeRecordByCommit({
|
|
327
|
-
gitRoot,
|
|
328
|
-
repo,
|
|
329
|
-
mergeCommit: localMergeCommit,
|
|
330
|
-
sourceBranch: sourceBranch || null,
|
|
331
|
-
baseBranch: baseBranch || null,
|
|
332
|
-
prNumber: typeof meta?.pr_number === "number" ? meta.pr_number : null,
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
if (!sourceBranch) {
|
|
336
|
-
sourceBranch = mergedRecord?.head?.ref?.trim() ?? "";
|
|
337
|
-
}
|
|
338
|
-
if (!baseBranch) {
|
|
339
|
-
baseBranch = mergedRecord?.base?.ref?.trim() ?? defaultBaseBranch?.trim() ?? "";
|
|
340
|
-
}
|
|
341
|
-
const mergeCommit = meta?.merge_commit?.trim() ??
|
|
342
|
-
task.commit?.hash?.trim() ??
|
|
343
|
-
mergedRecord?.merge_commit_sha?.trim() ??
|
|
344
|
-
"";
|
|
345
|
-
if (!sourceBranch) {
|
|
346
|
-
throw new CliError({
|
|
347
|
-
exitCode: exitCodeForError("E_VALIDATION"),
|
|
348
|
-
code: "E_VALIDATION",
|
|
349
|
-
message: `Missing hosted close source branch for ${opts.taskId}.`,
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
if (!mergeCommit) {
|
|
353
|
-
throw new CliError({
|
|
354
|
-
exitCode: exitCodeForError("E_VALIDATION"),
|
|
355
|
-
code: "E_VALIDATION",
|
|
356
|
-
message: `Missing hosted close merge commit for ${opts.taskId}.`,
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
if (meta?.status !== "MERGED" && !mergedRecord?.merged_at) {
|
|
360
|
-
throw new CliError({
|
|
361
|
-
exitCode: exitCodeForError("E_USAGE"),
|
|
362
|
-
code: "E_USAGE",
|
|
363
|
-
message: `Task ${opts.taskId} is not in MERGED hosted-close state.`,
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
const branch = await resolveHostedCloseBranch({
|
|
367
|
-
gitRoot,
|
|
368
|
-
taskId: opts.taskId,
|
|
369
|
-
explicitBranch: opts.branch ?? null,
|
|
370
|
-
mergeCommit,
|
|
371
|
-
});
|
|
372
|
-
await maybeCleanupMergedTaskBranch({
|
|
373
|
-
output,
|
|
374
|
-
gitRoot,
|
|
375
|
-
branch: sourceBranch,
|
|
376
|
-
});
|
|
377
|
-
const owner = repo.split("/")[0]?.trim() ?? "";
|
|
378
|
-
const existingQuery = new URLSearchParams({
|
|
379
|
-
state: "open",
|
|
380
|
-
head: `${owner}:${branch}`,
|
|
381
|
-
});
|
|
382
|
-
const existing = await runGhApiJson(gitRoot, [
|
|
383
|
-
`repos/${repo}/pulls?${existingQuery.toString()}`,
|
|
384
|
-
]);
|
|
385
|
-
const existingPr = Array.isArray(existing) ? (existing[0] ?? null) : null;
|
|
386
|
-
const existingNumber = Number(existingPr?.number ?? 0);
|
|
387
|
-
if (Number.isInteger(existingNumber) && existingNumber > 0) {
|
|
388
|
-
output.success("task hosted-close-pr", opts.taskId, normalizeGithubPrLink(existingNumber, existingPr?.html_url ?? null, "linked to"));
|
|
76
|
+
const precheck = await precheckHostedClosePr(opts);
|
|
77
|
+
if (precheck.kind === "skip") {
|
|
78
|
+
reportHostedClosePrOutcome(precheck.outcome);
|
|
389
79
|
return 0;
|
|
390
80
|
}
|
|
391
|
-
const
|
|
392
|
-
|
|
393
|
-
"-X",
|
|
394
|
-
"POST",
|
|
395
|
-
"-f",
|
|
396
|
-
`title=${buildHostedClosePrTitle(opts.taskId)}`,
|
|
397
|
-
"-f",
|
|
398
|
-
`body=${buildHostedClosePrBody({
|
|
399
|
-
taskId: opts.taskId,
|
|
400
|
-
prNumber: typeof meta?.pr_number === "number"
|
|
401
|
-
? meta.pr_number
|
|
402
|
-
: typeof mergedRecord?.number === "number"
|
|
403
|
-
? mergedRecord.number
|
|
404
|
-
: null,
|
|
405
|
-
sourceBranch,
|
|
406
|
-
mergeSha: mergeCommit,
|
|
407
|
-
})}`,
|
|
408
|
-
"-f",
|
|
409
|
-
`head=${branch}`,
|
|
410
|
-
"-f",
|
|
411
|
-
`base=${baseBranch}`,
|
|
412
|
-
]);
|
|
413
|
-
const createdNumber = Number(created.number ?? 0);
|
|
414
|
-
if (!Number.isInteger(createdNumber) || createdNumber <= 0) {
|
|
415
|
-
throw new CliError({
|
|
416
|
-
exitCode: exitCodeForError("E_VALIDATION"),
|
|
417
|
-
code: "E_VALIDATION",
|
|
418
|
-
message: `GitHub did not return a valid PR number for hosted closure branch ${branch}.`,
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
output.success("task hosted-close-pr", opts.taskId, normalizeGithubPrLink(createdNumber, created.html_url ?? null, "created"));
|
|
81
|
+
const result = postcheckHostedClosePrResult(await executeHostedClosePrPlan(precheck.plan));
|
|
82
|
+
reportHostedClosePrExecutionResult(result);
|
|
422
83
|
return 0;
|
|
423
84
|
}
|
|
424
85
|
export function makeRunTaskHostedClosePrHandler(getCtx) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-close-pr.execute.d.ts","sourceRoot":"","sources":["../../../src/commands/task/hosted-close-pr.execute.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,4BAA4B,EAE5B,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AA0EpC,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,4BAA4B,CAAC,CAwEvC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { runGhApiJson } from "../pr/internal/gh-api.js";
|
|
2
|
+
import { cleanupMergedLocalBranch } from "../shared/merged-branch-cleanup.js";
|
|
3
|
+
import { taskCloseAlreadyRecordedOnBase } from "./close-tail-state.js";
|
|
4
|
+
function buildHostedClosePrTitle(taskId) {
|
|
5
|
+
return `📝 ${taskId} task: close after hosted merge`;
|
|
6
|
+
}
|
|
7
|
+
function buildHostedClosePrBody(opts) {
|
|
8
|
+
const prLine = typeof opts.prNumber === "number" && opts.prNumber > 0
|
|
9
|
+
? `Automated closure for merged task PR #${opts.prNumber}.`
|
|
10
|
+
: "Automated closure for merged task PR.";
|
|
11
|
+
return [
|
|
12
|
+
prLine,
|
|
13
|
+
"",
|
|
14
|
+
`- task_id: \`${opts.taskId}\``,
|
|
15
|
+
`- source_branch: \`${opts.sourceBranch}\``,
|
|
16
|
+
`- merge_sha: \`${opts.mergeSha}\``,
|
|
17
|
+
"",
|
|
18
|
+
"This PR contains only tracked task artifacts produced by the hosted branch_pr closure flow.",
|
|
19
|
+
].join("\n");
|
|
20
|
+
}
|
|
21
|
+
async function maybeCleanupMergedTaskBranch(opts) {
|
|
22
|
+
try {
|
|
23
|
+
const cleanup = await cleanupMergedLocalBranch({
|
|
24
|
+
gitRoot: opts.gitRoot,
|
|
25
|
+
branch: opts.branch,
|
|
26
|
+
});
|
|
27
|
+
if (!cleanup.removedBranch && !cleanup.removedWorktree) {
|
|
28
|
+
if (cleanup.skippedReason === "current_worktree") {
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
level: "info",
|
|
32
|
+
message: `local merged branch cleanup skipped: ${opts.branch} is the current checkout`,
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
if (cleanup.skippedReason === "outside_repo") {
|
|
37
|
+
return [
|
|
38
|
+
{
|
|
39
|
+
level: "info",
|
|
40
|
+
message: `local merged branch cleanup skipped: ${opts.branch} is attached to a worktree outside the current checkout root`,
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
const details = [];
|
|
47
|
+
if (cleanup.removedWorktree && cleanup.worktreePath) {
|
|
48
|
+
details.push(`removed worktree ${cleanup.worktreePath}`);
|
|
49
|
+
}
|
|
50
|
+
if (cleanup.removedBranch) {
|
|
51
|
+
details.push(`deleted branch ${opts.branch}`);
|
|
52
|
+
}
|
|
53
|
+
return [{ level: "info", message: `local merged branch cleanup: ${details.join("; ")}` }];
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
57
|
+
return [
|
|
58
|
+
{
|
|
59
|
+
level: "warn",
|
|
60
|
+
message: `local merged branch cleanup failed for ${opts.branch}: ${message}`,
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export async function executeHostedClosePrPlan(plan) {
|
|
66
|
+
const notices = await maybeCleanupMergedTaskBranch({
|
|
67
|
+
gitRoot: plan.gitRoot,
|
|
68
|
+
branch: plan.sourceBranch,
|
|
69
|
+
});
|
|
70
|
+
const alreadyClosedOnBase = await taskCloseAlreadyRecordedOnBase({
|
|
71
|
+
gitRoot: plan.gitRoot,
|
|
72
|
+
workflowDir: plan.workflowDir,
|
|
73
|
+
taskId: plan.taskId,
|
|
74
|
+
baseBranch: plan.baseBranch,
|
|
75
|
+
});
|
|
76
|
+
if (alreadyClosedOnBase) {
|
|
77
|
+
return {
|
|
78
|
+
notices,
|
|
79
|
+
outcome: {
|
|
80
|
+
kind: "base-already-recorded",
|
|
81
|
+
taskId: plan.taskId,
|
|
82
|
+
baseBranch: plan.baseBranch,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const owner = plan.repo.split("/")[0]?.trim() ?? "";
|
|
87
|
+
const existingQuery = new URLSearchParams({
|
|
88
|
+
state: "open",
|
|
89
|
+
head: `${owner}:${plan.closeBranch}`,
|
|
90
|
+
});
|
|
91
|
+
const existing = await runGhApiJson(plan.gitRoot, [
|
|
92
|
+
`repos/${plan.repo}/pulls?${existingQuery.toString()}`,
|
|
93
|
+
]);
|
|
94
|
+
const existingPr = Array.isArray(existing) ? (existing[0] ?? null) : null;
|
|
95
|
+
const existingNumber = Number(existingPr?.number ?? 0);
|
|
96
|
+
if (Number.isInteger(existingNumber) && existingNumber > 0) {
|
|
97
|
+
return {
|
|
98
|
+
notices,
|
|
99
|
+
outcome: {
|
|
100
|
+
kind: "existing-pr",
|
|
101
|
+
taskId: plan.taskId,
|
|
102
|
+
prNumber: existingNumber,
|
|
103
|
+
prUrl: existingPr?.html_url ?? null,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const created = await runGhApiJson(plan.gitRoot, [
|
|
108
|
+
`repos/${plan.repo}/pulls`,
|
|
109
|
+
"-X",
|
|
110
|
+
"POST",
|
|
111
|
+
"-f",
|
|
112
|
+
`title=${buildHostedClosePrTitle(plan.taskId)}`,
|
|
113
|
+
"-f",
|
|
114
|
+
`body=${buildHostedClosePrBody({
|
|
115
|
+
taskId: plan.taskId,
|
|
116
|
+
prNumber: plan.sourcePrNumber,
|
|
117
|
+
sourceBranch: plan.sourceBranch,
|
|
118
|
+
mergeSha: plan.mergeCommit,
|
|
119
|
+
})}`,
|
|
120
|
+
"-f",
|
|
121
|
+
`head=${plan.closeBranch}`,
|
|
122
|
+
"-f",
|
|
123
|
+
`base=${plan.baseBranch}`,
|
|
124
|
+
]);
|
|
125
|
+
return {
|
|
126
|
+
notices,
|
|
127
|
+
outcome: {
|
|
128
|
+
kind: "created-pr",
|
|
129
|
+
taskId: plan.taskId,
|
|
130
|
+
closeBranch: plan.closeBranch,
|
|
131
|
+
prNumber: Number(created.number ?? 0),
|
|
132
|
+
prUrl: created.html_url ?? null,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-close-pr.postcheck.d.ts","sourceRoot":"","sources":["../../../src/commands/task/hosted-close-pr.postcheck.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAE/E,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,4BAA4B,GACnC,4BAA4B,CAY9B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { exitCodeForError } from "../../cli/exit-codes.js";
|
|
2
|
+
import { CliError } from "../../shared/errors.js";
|
|
3
|
+
export function postcheckHostedClosePrResult(result) {
|
|
4
|
+
if (result.outcome.kind === "created-pr" &&
|
|
5
|
+
(!Number.isInteger(result.outcome.prNumber) || result.outcome.prNumber <= 0)) {
|
|
6
|
+
throw new CliError({
|
|
7
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
8
|
+
code: "E_VALIDATION",
|
|
9
|
+
message: `GitHub did not return a valid PR number for hosted closure branch ${result.outcome.closeBranch}.`,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HostedClosePrPrecheckOptions, HostedClosePrPrecheckResult } from "./hosted-close-pr.types.js";
|
|
2
|
+
export declare function shortHostedCloseSha(value: string): string;
|
|
3
|
+
export declare function precheckHostedClosePr(opts: HostedClosePrPrecheckOptions): Promise<HostedClosePrPrecheckResult>;
|
|
4
|
+
//# sourceMappingURL=hosted-close-pr.precheck.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-close-pr.precheck.d.ts","sourceRoot":"","sources":["../../../src/commands/task/hosted-close-pr.precheck.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAEV,4BAA4B,EAC5B,2BAA2B,EAC5B,MAAM,4BAA4B,CAAC;AAiJpC,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD;AAqED,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,4BAA4B,GACjC,OAAO,CAAC,2BAA2B,CAAC,CAoHtC"}
|