agentplane 0.3.9 → 0.3.11
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 +4 -2
- package/assets/agents/CODER.json +1 -1
- package/assets/policy/dod.core.md +1 -1
- package/assets/policy/governance.md +5 -3
- package/assets/policy/incidents.md +19 -77
- package/assets/policy/workflow.branch_pr.md +2 -0
- package/assets/policy/workflow.direct.md +3 -1
- package/bin/agentplane.js +56 -1
- package/bin/runtime-watch.js +1 -0
- package/bin/stale-dist-policy.d.ts +1 -1
- package/bin/stale-dist-policy.js +13 -0
- package/dist/.build-manifest.json +462 -202
- package/dist/cli/bootstrap-guide.d.ts +1 -0
- package/dist/cli/bootstrap-guide.d.ts.map +1 -1
- package/dist/cli/bootstrap-guide.js +20 -1
- package/dist/cli/command-guide.d.ts.map +1 -1
- package/dist/cli/command-guide.js +2 -1
- package/dist/cli/command-invocations.d.ts.map +1 -1
- package/dist/cli/command-invocations.js +6 -1
- package/dist/cli/command-snippets.d.ts +2 -0
- package/dist/cli/command-snippets.d.ts.map +1 -1
- package/dist/cli/command-snippets.js +2 -0
- package/dist/cli/run-cli/command-catalog/core.d.ts +1 -1
- package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/core.js +10 -0
- 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 +3 -1
- 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 +10 -0
- package/dist/cli/run-cli/command-catalog.d.ts +1 -1
- package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/config.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/config.js +13 -0
- package/dist/cli/run-cli/commands/core/preflight.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/core/preflight.js +44 -1
- package/dist/cli/run-cli.js +2 -2
- package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
- package/dist/cli/run-cli.test-helpers.js +12 -0
- package/dist/commands/backend.d.ts.map +1 -1
- package/dist/commands/backend.js +4 -0
- package/dist/commands/branch/cleanup-merged.d.ts +2 -0
- package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
- package/dist/commands/branch/cleanup-merged.js +132 -28
- package/dist/commands/branch/work-start.d.ts.map +1 -1
- package/dist/commands/branch/work-start.js +60 -1
- package/dist/commands/cleanup/merged.command.d.ts +2 -0
- package/dist/commands/cleanup/merged.command.d.ts.map +1 -1
- package/dist/commands/cleanup/merged.command.js +24 -0
- package/dist/commands/doctor/branch-pr.d.ts +4 -0
- package/dist/commands/doctor/branch-pr.d.ts.map +1 -0
- package/dist/commands/doctor/branch-pr.js +96 -0
- package/dist/commands/doctor/fixes.d.ts +5 -0
- package/dist/commands/doctor/fixes.d.ts.map +1 -1
- package/dist/commands/doctor/fixes.js +70 -0
- package/dist/commands/doctor.run.d.ts.map +1 -1
- package/dist/commands/doctor.run.js +6 -1
- package/dist/commands/finish.run.d.ts.map +1 -1
- package/dist/commands/finish.run.js +11 -0
- package/dist/commands/finish.spec.d.ts +11 -0
- package/dist/commands/finish.spec.d.ts.map +1 -1
- package/dist/commands/finish.spec.js +51 -0
- package/dist/commands/guard/impl/close-message.d.ts.map +1 -1
- package/dist/commands/guard/impl/close-message.js +23 -6
- package/dist/commands/guard/impl/commands.d.ts.map +1 -1
- package/dist/commands/guard/impl/commands.js +24 -2
- package/dist/commands/guard/impl/env.d.ts +1 -0
- package/dist/commands/guard/impl/env.d.ts.map +1 -1
- package/dist/commands/guard/impl/env.js +1 -0
- package/dist/commands/hooks/index.d.ts.map +1 -1
- package/dist/commands/hooks/index.js +98 -1
- package/dist/commands/incidents/advise.command.d.ts +15 -0
- package/dist/commands/incidents/advise.command.d.ts.map +1 -0
- package/dist/commands/incidents/advise.command.js +139 -0
- package/dist/commands/incidents/collect.command.d.ts +11 -0
- package/dist/commands/incidents/collect.command.d.ts.map +1 -0
- package/dist/commands/incidents/collect.command.js +72 -0
- package/dist/commands/incidents/incidents.command.d.ts +5 -0
- package/dist/commands/incidents/incidents.command.d.ts.map +1 -0
- package/dist/commands/incidents/incidents.command.js +21 -0
- package/dist/commands/incidents/shared.d.ts +76 -0
- package/dist/commands/incidents/shared.d.ts.map +1 -0
- package/dist/commands/incidents/shared.js +261 -0
- package/dist/commands/pr/check.d.ts.map +1 -1
- package/dist/commands/pr/check.js +249 -75
- package/dist/commands/pr/close-superseded.d.ts +9 -0
- package/dist/commands/pr/close-superseded.d.ts.map +1 -0
- package/dist/commands/pr/close-superseded.js +129 -0
- package/dist/commands/pr/close.d.ts +11 -0
- package/dist/commands/pr/close.d.ts.map +1 -0
- package/dist/commands/pr/close.js +116 -0
- package/dist/commands/pr/index.d.ts +2 -0
- package/dist/commands/pr/index.d.ts.map +1 -1
- package/dist/commands/pr/index.js +2 -0
- package/dist/commands/pr/integrate/artifacts.d.ts +7 -0
- package/dist/commands/pr/integrate/artifacts.d.ts.map +1 -1
- package/dist/commands/pr/integrate/artifacts.js +66 -1
- package/dist/commands/pr/integrate/cmd.d.ts.map +1 -1
- package/dist/commands/pr/integrate/cmd.js +20 -0
- package/dist/commands/pr/integrate/internal/bootstrap-guidance.d.ts +8 -0
- package/dist/commands/pr/integrate/internal/bootstrap-guidance.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/bootstrap-guidance.js +59 -0
- package/dist/commands/pr/integrate/internal/finalize.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/finalize.js +40 -12
- package/dist/commands/pr/integrate/internal/merge.d.ts +4 -0
- package/dist/commands/pr/integrate/internal/merge.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/merge.js +59 -15
- package/dist/commands/pr/integrate/internal/post-integrate-bootstrap.d.ts +13 -0
- package/dist/commands/pr/integrate/internal/post-integrate-bootstrap.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/post-integrate-bootstrap.js +25 -0
- package/dist/commands/pr/integrate/internal/prepare.d.ts +3 -2
- package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/prepare.js +107 -19
- package/dist/commands/pr/internal/freshness.d.ts +20 -0
- package/dist/commands/pr/internal/freshness.d.ts.map +1 -0
- package/dist/commands/pr/internal/freshness.js +50 -0
- package/dist/commands/pr/internal/gh-api.d.ts +6 -0
- package/dist/commands/pr/internal/gh-api.d.ts.map +1 -0
- package/dist/commands/pr/internal/gh-api.js +80 -0
- package/dist/commands/pr/internal/note-store.d.ts +18 -0
- package/dist/commands/pr/internal/note-store.d.ts.map +1 -0
- package/dist/commands/pr/internal/note-store.js +66 -0
- package/dist/commands/pr/internal/pr-paths.d.ts +13 -0
- package/dist/commands/pr/internal/pr-paths.d.ts.map +1 -1
- package/dist/commands/pr/internal/pr-paths.js +13 -0
- package/dist/commands/pr/internal/review-template.d.ts +24 -4
- package/dist/commands/pr/internal/review-template.d.ts.map +1 -1
- package/dist/commands/pr/internal/review-template.js +221 -33
- package/dist/commands/pr/internal/sync.d.ts +41 -0
- package/dist/commands/pr/internal/sync.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync.js +598 -0
- package/dist/commands/pr/note.d.ts.map +1 -1
- package/dist/commands/pr/note.js +37 -4
- package/dist/commands/pr/open.d.ts +1 -0
- package/dist/commands/pr/open.d.ts.map +1 -1
- package/dist/commands/pr/open.js +18 -54
- package/dist/commands/pr/pr.command.d.ts +15 -0
- package/dist/commands/pr/pr.command.d.ts.map +1 -1
- package/dist/commands/pr/pr.command.js +124 -5
- package/dist/commands/pr/update.d.ts.map +1 -1
- package/dist/commands/pr/update.js +58 -74
- package/dist/commands/recipes/impl/commands/cache-prune.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/cache-prune.js +14 -0
- package/dist/commands/recipes/impl/commands/install.js +1 -1
- package/dist/commands/recipes/impl/commands/list-remote.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/list-remote.js +1 -0
- package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/remove.js +9 -1
- package/dist/commands/release/apply.command.d.ts.map +1 -1
- package/dist/commands/release/apply.command.js +12 -17
- package/dist/commands/release/apply.preflight.d.ts.map +1 -1
- package/dist/commands/release/apply.preflight.js +1 -1
- package/dist/commands/shared/approval-requirements.d.ts +5 -7
- package/dist/commands/shared/approval-requirements.d.ts.map +1 -1
- package/dist/commands/shared/approval-requirements.js +3 -73
- package/dist/commands/shared/gh-transport.d.ts +16 -0
- package/dist/commands/shared/gh-transport.d.ts.map +1 -0
- package/dist/commands/shared/gh-transport.js +71 -0
- package/dist/commands/shared/git-diff.d.ts +3 -1
- package/dist/commands/shared/git-diff.d.ts.map +1 -1
- package/dist/commands/shared/git-diff.js +10 -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 +15 -0
- package/dist/commands/shared/git-worktree.d.ts +2 -0
- package/dist/commands/shared/git-worktree.d.ts.map +1 -1
- package/dist/commands/shared/git-worktree.js +22 -2
- package/dist/commands/shared/network-approval.d.ts +2 -0
- package/dist/commands/shared/network-approval.d.ts.map +1 -1
- package/dist/commands/shared/network-approval.js +1 -1
- package/dist/commands/shared/post-commit-pr-artifacts.d.ts +9 -0
- package/dist/commands/shared/post-commit-pr-artifacts.d.ts.map +1 -0
- package/dist/commands/shared/post-commit-pr-artifacts.js +22 -0
- package/dist/commands/shared/pr-meta.d.ts +29 -0
- package/dist/commands/shared/pr-meta.d.ts.map +1 -1
- package/dist/commands/shared/pr-meta.js +152 -3
- package/dist/commands/shared/task-backend.d.ts +9 -0
- package/dist/commands/shared/task-backend.d.ts.map +1 -1
- package/dist/commands/shared/task-backend.js +34 -22
- package/dist/commands/shared/task-local-freshness.d.ts +13 -0
- package/dist/commands/shared/task-local-freshness.d.ts.map +1 -0
- package/dist/commands/shared/task-local-freshness.js +20 -0
- package/dist/commands/shared/task-mutation.d.ts +2 -0
- package/dist/commands/shared/task-mutation.d.ts.map +1 -1
- package/dist/commands/shared/task-mutation.js +7 -0
- package/dist/commands/task/block.d.ts.map +1 -1
- package/dist/commands/task/block.js +1 -0
- package/dist/commands/task/close-duplicate.d.ts.map +1 -1
- package/dist/commands/task/close-duplicate.js +34 -1
- package/dist/commands/task/close-shared.d.ts.map +1 -1
- package/dist/commands/task/close-shared.js +1 -0
- package/dist/commands/task/derive.js +1 -1
- package/dist/commands/task/doc-template.d.ts.map +1 -1
- package/dist/commands/task/doc-template.js +7 -11
- package/dist/commands/task/findings-add.command.d.ts +20 -0
- package/dist/commands/task/findings-add.command.d.ts.map +1 -0
- package/dist/commands/task/findings-add.command.js +165 -0
- package/dist/commands/task/findings.command.d.ts +7 -0
- package/dist/commands/task/findings.command.d.ts.map +1 -0
- package/dist/commands/task/findings.command.js +20 -0
- package/dist/commands/task/findings.d.ts +63 -0
- package/dist/commands/task/findings.d.ts.map +1 -0
- package/dist/commands/task/findings.js +188 -0
- package/dist/commands/task/finish-shared.d.ts +1 -0
- package/dist/commands/task/finish-shared.d.ts.map +1 -1
- package/dist/commands/task/finish-shared.js +60 -3
- package/dist/commands/task/finish.d.ts +10 -0
- package/dist/commands/task/finish.d.ts.map +1 -1
- package/dist/commands/task/finish.js +143 -0
- package/dist/commands/task/hosted-close-pr.command.d.ts +11 -0
- package/dist/commands/task/hosted-close-pr.command.d.ts.map +1 -0
- package/dist/commands/task/hosted-close-pr.command.js +414 -0
- package/dist/commands/task/hosted-close.command.d.ts.map +1 -1
- package/dist/commands/task/hosted-close.command.js +49 -1
- package/dist/commands/task/hosted-merge-sync.d.ts +38 -0
- package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
- package/dist/commands/task/hosted-merge-sync.js +249 -17
- package/dist/commands/task/index.d.ts +1 -0
- package/dist/commands/task/index.d.ts.map +1 -1
- package/dist/commands/task/index.js +1 -0
- package/dist/commands/task/new.d.ts +1 -0
- package/dist/commands/task/new.d.ts.map +1 -1
- package/dist/commands/task/new.js +140 -30
- package/dist/commands/task/new.spec.d.ts.map +1 -1
- package/dist/commands/task/new.spec.js +7 -0
- package/dist/commands/task/normalize.command.d.ts +2 -0
- package/dist/commands/task/normalize.command.d.ts.map +1 -1
- package/dist/commands/task/normalize.command.js +45 -0
- package/dist/commands/task/normalize.d.ts +2 -0
- package/dist/commands/task/normalize.d.ts.map +1 -1
- package/dist/commands/task/normalize.js +85 -8
- package/dist/commands/task/plan.d.ts.map +1 -1
- package/dist/commands/task/plan.js +7 -10
- package/dist/commands/task/set-status.d.ts.map +1 -1
- package/dist/commands/task/set-status.js +1 -0
- package/dist/commands/task/shared/docs.d.ts +6 -0
- package/dist/commands/task/shared/docs.d.ts.map +1 -1
- package/dist/commands/task/shared/docs.js +14 -0
- package/dist/commands/task/shared/transition-command.d.ts +2 -0
- package/dist/commands/task/shared/transition-command.d.ts.map +1 -1
- package/dist/commands/task/shared/transition-command.js +1 -0
- package/dist/commands/task/shared/transitions.d.ts.map +1 -1
- package/dist/commands/task/shared/transitions.js +11 -1
- package/dist/commands/task/shared.d.ts +1 -1
- package/dist/commands/task/shared.d.ts.map +1 -1
- package/dist/commands/task/shared.js +1 -1
- package/dist/commands/task/start-ready.d.ts.map +1 -1
- package/dist/commands/task/start-ready.js +98 -1
- package/dist/commands/task/start.d.ts.map +1 -1
- package/dist/commands/task/start.js +18 -10
- package/dist/commands/task/task.command.d.ts.map +1 -1
- package/dist/commands/task/task.command.js +4 -0
- package/dist/commands/task/verify-command-shared.d.ts +19 -0
- package/dist/commands/task/verify-command-shared.d.ts.map +1 -1
- package/dist/commands/task/verify-command-shared.js +152 -1
- package/dist/commands/task/verify-ok.command.d.ts.map +1 -1
- package/dist/commands/task/verify-ok.command.js +15 -2
- package/dist/commands/task/verify-record.d.ts +36 -0
- package/dist/commands/task/verify-record.d.ts.map +1 -1
- package/dist/commands/task/verify-record.js +193 -11
- package/dist/commands/task/verify-rework.command.d.ts.map +1 -1
- package/dist/commands/task/verify-rework.command.js +15 -2
- package/dist/commands/task/verify-show.command.d.ts +1 -1
- package/dist/commands/task/verify-show.command.d.ts.map +1 -1
- package/dist/commands/task/verify-show.command.js +28 -1
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +6 -1
- package/dist/commands/verify.run.d.ts.map +1 -1
- package/dist/commands/verify.run.js +12 -0
- package/dist/commands/verify.spec.d.ts +2 -6
- package/dist/commands/verify.spec.d.ts.map +1 -1
- package/dist/commands/verify.spec.js +30 -3
- package/dist/policy/engine.d.ts +3 -1
- package/dist/policy/engine.d.ts.map +1 -1
- package/dist/policy/engine.js +5 -6
- package/dist/policy/taxonomy.d.ts +17 -0
- package/dist/policy/taxonomy.d.ts.map +1 -0
- package/dist/policy/taxonomy.js +302 -0
- package/dist/policy/types.d.ts +2 -1
- package/dist/policy/types.d.ts.map +1 -1
- package/dist/runner/artifacts.d.ts.map +1 -1
- package/dist/runner/artifacts.js +2 -0
- package/dist/runner/context/base-prompts.d.ts +25 -0
- package/dist/runner/context/base-prompts.d.ts.map +1 -1
- package/dist/runner/context/base-prompts.js +182 -54
- package/dist/runner/context/recipe-context.d.ts.map +1 -1
- package/dist/runner/context/recipe-context.js +5 -0
- package/dist/runner/types.d.ts +12 -0
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/usecases/scenario-materialize-task.d.ts.map +1 -1
- package/dist/runner/usecases/scenario-materialize-task.js +81 -11
- package/dist/runner/usecases/task-run-inspect.d.ts.map +1 -1
- package/dist/runner/usecases/task-run-inspect.js +9 -7
- package/dist/runner/usecases/task-run-lifecycle-shared.d.ts.map +1 -1
- package/dist/runner/usecases/task-run-lifecycle-shared.js +8 -6
- package/dist/runner/usecases/task-run.d.ts.map +1 -1
- package/dist/runner/usecases/task-run.js +59 -12
- package/dist/runtime/approvals/index.d.ts +3 -0
- package/dist/runtime/approvals/index.d.ts.map +1 -0
- package/dist/runtime/approvals/index.js +1 -0
- package/dist/runtime/approvals/runtime.d.ts +12 -0
- package/dist/runtime/approvals/runtime.d.ts.map +1 -0
- package/dist/runtime/approvals/runtime.js +154 -0
- package/dist/runtime/approvals/types.d.ts +31 -0
- package/dist/runtime/approvals/types.d.ts.map +1 -0
- package/dist/runtime/approvals/types.js +1 -0
- package/dist/runtime/behavior/index.d.ts +3 -0
- package/dist/runtime/behavior/index.d.ts.map +1 -0
- package/dist/runtime/behavior/index.js +1 -0
- package/dist/runtime/behavior/resolve.d.ts +7 -0
- package/dist/runtime/behavior/resolve.d.ts.map +1 -0
- package/dist/runtime/behavior/resolve.js +66 -0
- package/dist/runtime/behavior/types.d.ts +25 -0
- package/dist/runtime/behavior/types.d.ts.map +1 -0
- package/dist/runtime/behavior/types.js +1 -0
- package/dist/runtime/capabilities/backend.d.ts +7 -0
- package/dist/runtime/capabilities/backend.d.ts.map +1 -0
- package/dist/runtime/capabilities/backend.js +104 -0
- package/dist/runtime/capabilities/index.d.ts +6 -0
- package/dist/runtime/capabilities/index.d.ts.map +1 -0
- package/dist/runtime/capabilities/index.js +4 -0
- package/dist/runtime/capabilities/recipe.d.ts +10 -0
- package/dist/runtime/capabilities/recipe.d.ts.map +1 -0
- package/dist/runtime/capabilities/recipe.js +123 -0
- package/dist/runtime/capabilities/registry.d.ts +6 -0
- package/dist/runtime/capabilities/registry.d.ts.map +1 -0
- package/dist/runtime/capabilities/registry.js +69 -0
- package/dist/runtime/capabilities/runner.d.ts +8 -0
- package/dist/runtime/capabilities/runner.d.ts.map +1 -0
- package/dist/runtime/capabilities/runner.js +73 -0
- package/dist/runtime/capabilities/types.d.ts +28 -0
- package/dist/runtime/capabilities/types.d.ts.map +1 -0
- package/dist/runtime/capabilities/types.js +1 -0
- package/dist/runtime/execution-profile/index.d.ts +3 -0
- package/dist/runtime/execution-profile/index.d.ts.map +1 -0
- package/dist/runtime/execution-profile/index.js +1 -0
- package/dist/runtime/execution-profile/resolve.d.ts +9 -0
- package/dist/runtime/execution-profile/resolve.d.ts.map +1 -0
- package/dist/runtime/execution-profile/resolve.js +80 -0
- package/dist/runtime/execution-profile/types.d.ts +27 -0
- package/dist/runtime/execution-profile/types.d.ts.map +1 -0
- package/dist/runtime/execution-profile/types.js +1 -0
- package/dist/runtime/explain/index.d.ts +3 -0
- package/dist/runtime/explain/index.d.ts.map +1 -0
- package/dist/runtime/explain/index.js +1 -0
- package/dist/runtime/explain/resolve.d.ts +14 -0
- package/dist/runtime/explain/resolve.d.ts.map +1 -0
- package/dist/runtime/explain/resolve.js +50 -0
- package/dist/runtime/explain/types.d.ts +28 -0
- package/dist/runtime/explain/types.d.ts.map +1 -0
- package/dist/runtime/explain/types.js +1 -0
- package/dist/runtime/harness/index.d.ts +4 -0
- package/dist/runtime/harness/index.d.ts.map +1 -0
- package/dist/runtime/harness/index.js +2 -0
- package/dist/runtime/harness/resolve-from-command-context.d.ts +4 -0
- package/dist/runtime/harness/resolve-from-command-context.d.ts.map +1 -0
- package/dist/runtime/harness/resolve-from-command-context.js +11 -0
- package/dist/runtime/harness/resolve.d.ts +13 -0
- package/dist/runtime/harness/resolve.d.ts.map +1 -0
- package/dist/runtime/harness/resolve.js +146 -0
- package/dist/runtime/harness/types.d.ts +65 -0
- package/dist/runtime/harness/types.d.ts.map +1 -0
- package/dist/runtime/harness/types.js +1 -0
- package/dist/runtime/incidents/index.d.ts +3 -0
- package/dist/runtime/incidents/index.d.ts.map +1 -0
- package/dist/runtime/incidents/index.js +1 -0
- package/dist/runtime/incidents/resolve.d.ts +26 -0
- package/dist/runtime/incidents/resolve.d.ts.map +1 -0
- package/dist/runtime/incidents/resolve.js +683 -0
- package/dist/runtime/incidents/types.d.ts +84 -0
- package/dist/runtime/incidents/types.d.ts.map +1 -0
- package/dist/runtime/incidents/types.js +1 -0
- package/dist/runtime/protocol/index.d.ts +3 -0
- package/dist/runtime/protocol/index.d.ts.map +1 -0
- package/dist/runtime/protocol/index.js +2 -0
- package/dist/runtime/protocol/resolve.d.ts +16 -0
- package/dist/runtime/protocol/resolve.d.ts.map +1 -0
- package/dist/runtime/protocol/resolve.js +36 -0
- package/dist/runtime/protocol/types.d.ts +36 -0
- package/dist/runtime/protocol/types.d.ts.map +1 -0
- package/dist/runtime/protocol/types.js +1 -0
- package/dist/runtime/task-intake/index.d.ts +3 -0
- package/dist/runtime/task-intake/index.d.ts.map +1 -0
- package/dist/runtime/task-intake/index.js +1 -0
- package/dist/runtime/task-intake/resolve.d.ts +48 -0
- package/dist/runtime/task-intake/resolve.d.ts.map +1 -0
- package/dist/runtime/task-intake/resolve.js +316 -0
- package/dist/runtime/task-intake/types.d.ts +117 -0
- package/dist/runtime/task-intake/types.d.ts.map +1 -0
- package/dist/runtime/task-intake/types.js +1 -0
- package/dist/shared/env.d.ts +1 -0
- package/dist/shared/env.d.ts.map +1 -1
- package/dist/shared/env.js +22 -1
- package/dist/shared/protected-paths.d.ts +4 -0
- package/dist/shared/protected-paths.d.ts.map +1 -1
- package/dist/shared/protected-paths.js +8 -4
- package/dist/usecases/context/resolve-context.d.ts +55 -6
- package/dist/usecases/context/resolve-context.d.ts.map +1 -1
- package/dist/usecases/context/resolve-context.js +96 -6
- package/dist/usecases/task/task-list-usecase.d.ts.map +1 -1
- package/dist/usecases/task/task-list-usecase.js +8 -2
- package/dist/usecases/task/task-new-usecase.js +4 -4
- package/package.json +2 -2
|
@@ -6,10 +6,16 @@ import { fileExists } from "../../cli/fs-utils.js";
|
|
|
6
6
|
import { createCliEmitter, workflowModeMessage } from "../../cli/output.js";
|
|
7
7
|
import { CliError } from "../../shared/errors.js";
|
|
8
8
|
import { parsePrMeta } from "../shared/pr-meta.js";
|
|
9
|
-
import { gitListTaskBranches, parseTaskIdFromBranch } from "../shared/git-worktree.js";
|
|
9
|
+
import { findWorktreeForBranch, gitListTaskBranches, parseTaskIdFromBranch, } from "../shared/git-worktree.js";
|
|
10
|
+
import { gitRevParse } from "../shared/git-ops.js";
|
|
10
11
|
import { loadBackendTask, loadCommandContext, } from "../shared/task-backend.js";
|
|
11
|
-
import {
|
|
12
|
-
import { validateReviewContents } from "./internal/review-template.js";
|
|
12
|
+
import { readPrArtifactFromBranch, resolvePrPaths } from "./internal/pr-paths.js";
|
|
13
|
+
import { validateGithubPrBodyContents, validateReviewContents, } from "./internal/review-template.js";
|
|
14
|
+
import { assessPrArtifactFreshness } from "./internal/freshness.js";
|
|
15
|
+
function isUnknownRevisionError(err) {
|
|
16
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
17
|
+
return /unknown revision or path not in the working tree/i.test(message);
|
|
18
|
+
}
|
|
13
19
|
async function resolveArtifactBranch(opts) {
|
|
14
20
|
const prefix = opts.ctx.config.branch.task_prefix;
|
|
15
21
|
const branches = await gitListTaskBranches(opts.resolved.gitRoot, prefix);
|
|
@@ -25,26 +31,101 @@ async function resolveArtifactBranch(opts) {
|
|
|
25
31
|
}
|
|
26
32
|
return null;
|
|
27
33
|
}
|
|
28
|
-
async function
|
|
29
|
-
const localPath = path.join(
|
|
30
|
-
if (await fileExists(localPath))
|
|
31
|
-
return
|
|
34
|
+
async function readLocalPrArtifactText(prDir, fileName) {
|
|
35
|
+
const localPath = path.join(prDir, fileName);
|
|
36
|
+
if (!(await fileExists(localPath)))
|
|
37
|
+
return null;
|
|
38
|
+
return await readFile(localPath, "utf8");
|
|
39
|
+
}
|
|
40
|
+
function validateSnapshotContents(opts) {
|
|
41
|
+
const errors = [];
|
|
42
|
+
let meta = null;
|
|
43
|
+
if (opts.texts.metaText) {
|
|
44
|
+
try {
|
|
45
|
+
meta = parsePrMeta(opts.texts.metaText, opts.taskId);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
49
|
+
errors.push(message);
|
|
50
|
+
}
|
|
32
51
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
ctx: opts.ctx,
|
|
36
|
-
resolved: opts.resolved,
|
|
37
|
-
taskId: opts.taskId,
|
|
38
|
-
});
|
|
52
|
+
else {
|
|
53
|
+
errors.push(`Missing PR directory: ${opts.relPrDir}`, `Missing ${opts.relMetaPath}`);
|
|
39
54
|
}
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
if (opts.texts.diffstatText === null)
|
|
56
|
+
errors.push(`Missing ${opts.relDiffstatPath}`);
|
|
57
|
+
if (opts.texts.verifyLogText === null)
|
|
58
|
+
errors.push(`Missing ${opts.relVerifyLogPath}`);
|
|
59
|
+
if (opts.texts.reviewText) {
|
|
60
|
+
validateReviewContents(opts.texts.reviewText, errors);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
errors.push(`Missing ${opts.relReviewPath}`);
|
|
64
|
+
}
|
|
65
|
+
if (!opts.texts.githubTitleText?.trim()) {
|
|
66
|
+
errors.push(`Missing ${opts.relGithubTitlePath}`);
|
|
67
|
+
}
|
|
68
|
+
if (opts.texts.githubBodyText) {
|
|
69
|
+
validateGithubPrBodyContents(opts.texts.githubBodyText, errors);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
errors.push(`Missing ${opts.relGithubBodyPath}`);
|
|
73
|
+
}
|
|
74
|
+
return { meta, errors };
|
|
75
|
+
}
|
|
76
|
+
async function evaluateSnapshotFreshness(opts) {
|
|
77
|
+
if (!opts.snapshot.meta || !opts.branchHeadSha)
|
|
78
|
+
return;
|
|
79
|
+
const freshness = await assessPrArtifactFreshness({
|
|
80
|
+
gitRoot: opts.gitRoot,
|
|
81
|
+
workflowDir: opts.workflowDir,
|
|
82
|
+
taskId: opts.taskId,
|
|
83
|
+
branchHeadSha: opts.branchHeadSha,
|
|
84
|
+
metaHeadSha: opts.snapshot.meta.head_sha ?? null,
|
|
85
|
+
metaLastVerifiedSha: opts.snapshot.meta.last_verified_sha ?? null,
|
|
86
|
+
metaVerifyStatus: opts.snapshot.meta.verify?.status ?? null,
|
|
87
|
+
taskVerificationState: opts.taskVerificationState,
|
|
88
|
+
verifyLogText: opts.snapshot.texts.verifyLogText,
|
|
89
|
+
requiresVerify: opts.requiresVerify,
|
|
47
90
|
});
|
|
91
|
+
opts.snapshot.freshnessEvaluated = true;
|
|
92
|
+
opts.snapshot.freshnessReviewFresh = freshness.reviewFresh;
|
|
93
|
+
opts.snapshot.freshnessVerifySatisfied = freshness.verifySatisfied;
|
|
94
|
+
opts.snapshot.freshnessVerifyFresh = freshness.verifyFresh;
|
|
95
|
+
opts.snapshot.freshnessVerifyLogSha = freshness.verifyLogSha;
|
|
96
|
+
}
|
|
97
|
+
function finalizeSnapshotErrors(opts) {
|
|
98
|
+
const errors = [...opts.snapshot.errors];
|
|
99
|
+
const meta = opts.snapshot.meta;
|
|
100
|
+
if (!meta)
|
|
101
|
+
return errors;
|
|
102
|
+
if (opts.branchHeadSha && opts.snapshot.freshnessEvaluated) {
|
|
103
|
+
if (!opts.snapshot.freshnessReviewFresh) {
|
|
104
|
+
errors.push(`PR artifacts stale: head_sha=${meta.head_sha ?? "<missing>"} current_head=${opts.branchHeadSha}`);
|
|
105
|
+
}
|
|
106
|
+
if (opts.requiresVerify && !opts.snapshot.freshnessVerifySatisfied) {
|
|
107
|
+
if (meta.verify?.status !== "pass") {
|
|
108
|
+
errors.push("Verify requirements not satisfied (meta.verify.status != pass)");
|
|
109
|
+
}
|
|
110
|
+
if ((!meta.last_verified_sha || !meta.last_verified_at) &&
|
|
111
|
+
!opts.snapshot.freshnessVerifyLogSha) {
|
|
112
|
+
errors.push("Verify metadata missing (last_verified_sha/last_verified_at)");
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (opts.requiresVerify && meta.last_verified_sha && !opts.snapshot.freshnessVerifyFresh) {
|
|
116
|
+
errors.push(`Verify state stale: last_verified_sha=${meta.last_verified_sha} current_head=${opts.branchHeadSha}`);
|
|
117
|
+
}
|
|
118
|
+
return errors;
|
|
119
|
+
}
|
|
120
|
+
if (opts.requiresVerify) {
|
|
121
|
+
if (meta.verify?.status !== "pass") {
|
|
122
|
+
errors.push("Verify requirements not satisfied (meta.verify.status != pass)");
|
|
123
|
+
}
|
|
124
|
+
if (!meta.last_verified_sha || !meta.last_verified_at) {
|
|
125
|
+
errors.push("Verify metadata missing (last_verified_sha/last_verified_at)");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return errors;
|
|
48
129
|
}
|
|
49
130
|
export async function cmdPrCheck(opts) {
|
|
50
131
|
try {
|
|
@@ -57,7 +138,7 @@ export async function cmdPrCheck(opts) {
|
|
|
57
138
|
rootOverride: opts.rootOverride,
|
|
58
139
|
taskId: opts.taskId,
|
|
59
140
|
});
|
|
60
|
-
const { resolved, config, prDir, metaPath, diffstatPath, verifyLogPath, reviewPath } = await resolvePrPaths({ ...opts, ctx });
|
|
141
|
+
const { resolved, config, prDir, metaPath, diffstatPath, verifyLogPath, reviewPath, githubTitlePath, githubBodyPath, } = await resolvePrPaths({ ...opts, ctx });
|
|
61
142
|
if (config.workflow_mode !== "branch_pr") {
|
|
62
143
|
throw new CliError({
|
|
63
144
|
exitCode: exitCodeForError("E_USAGE"),
|
|
@@ -71,72 +152,165 @@ export async function cmdPrCheck(opts) {
|
|
|
71
152
|
const relDiffstatPath = path.relative(resolved.gitRoot, diffstatPath);
|
|
72
153
|
const relVerifyLogPath = path.relative(resolved.gitRoot, verifyLogPath);
|
|
73
154
|
const relReviewPath = path.relative(resolved.gitRoot, reviewPath);
|
|
155
|
+
const relGithubTitlePath = path.relative(resolved.gitRoot, githubTitlePath);
|
|
156
|
+
const relGithubBodyPath = path.relative(resolved.gitRoot, githubBodyPath);
|
|
74
157
|
const branchCache = {};
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
prDir,
|
|
80
|
-
|
|
158
|
+
const requiresVerify = Boolean(task.verify && task.verify.length > 0);
|
|
159
|
+
const localTexts = {
|
|
160
|
+
metaText: await readLocalPrArtifactText(prDir, "meta.json"),
|
|
161
|
+
diffstatText: await readLocalPrArtifactText(prDir, "diffstat.txt"),
|
|
162
|
+
verifyLogText: await readLocalPrArtifactText(prDir, "verify.log"),
|
|
163
|
+
reviewText: await readLocalPrArtifactText(prDir, "review.md"),
|
|
164
|
+
githubTitleText: await readLocalPrArtifactText(prDir, "github-title.txt"),
|
|
165
|
+
githubBodyText: await readLocalPrArtifactText(prDir, "github-body.md"),
|
|
166
|
+
};
|
|
167
|
+
const localParsed = validateSnapshotContents({
|
|
168
|
+
texts: localTexts,
|
|
169
|
+
relPrDir,
|
|
170
|
+
relMetaPath,
|
|
171
|
+
relDiffstatPath,
|
|
172
|
+
relVerifyLogPath,
|
|
173
|
+
relReviewPath,
|
|
174
|
+
relGithubTitlePath,
|
|
175
|
+
relGithubBodyPath,
|
|
81
176
|
taskId: task.id,
|
|
82
|
-
branchCache,
|
|
83
177
|
});
|
|
84
|
-
|
|
178
|
+
const localSnapshot = {
|
|
179
|
+
source: "local",
|
|
180
|
+
texts: localTexts,
|
|
181
|
+
meta: localParsed.meta,
|
|
182
|
+
errors: localParsed.errors,
|
|
183
|
+
freshnessEvaluated: false,
|
|
184
|
+
freshnessReviewFresh: false,
|
|
185
|
+
freshnessVerifySatisfied: false,
|
|
186
|
+
freshnessVerifyFresh: false,
|
|
187
|
+
freshnessVerifyLogSha: null,
|
|
188
|
+
};
|
|
189
|
+
const localBranch = localSnapshot.meta?.branch?.trim() ?? "";
|
|
190
|
+
if (localBranch) {
|
|
191
|
+
branchCache.value = localBranch;
|
|
192
|
+
}
|
|
193
|
+
else if (branchCache.value === undefined) {
|
|
194
|
+
branchCache.value = await resolveArtifactBranch({
|
|
195
|
+
ctx,
|
|
196
|
+
resolved,
|
|
197
|
+
taskId: task.id,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
const branchForFreshness = branchCache.value ?? null;
|
|
201
|
+
let branchHeadSha = null;
|
|
202
|
+
if (branchForFreshness) {
|
|
85
203
|
try {
|
|
86
|
-
|
|
204
|
+
branchHeadSha = await gitRevParse(resolved.gitRoot, [branchForFreshness]);
|
|
87
205
|
}
|
|
88
206
|
catch (err) {
|
|
89
|
-
|
|
90
|
-
|
|
207
|
+
if (!isUnknownRevisionError(err))
|
|
208
|
+
throw err;
|
|
91
209
|
}
|
|
92
210
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
ctx,
|
|
98
|
-
resolved,
|
|
99
|
-
prDir,
|
|
100
|
-
fileName: "diffstat.txt",
|
|
101
|
-
taskId: task.id,
|
|
102
|
-
branchCache,
|
|
103
|
-
});
|
|
104
|
-
if (diffstatText === null) {
|
|
105
|
-
errors.push(`Missing ${relDiffstatPath}`);
|
|
106
|
-
}
|
|
107
|
-
const verifyLogText = await readPrArtifactWithOptionalBranch({
|
|
108
|
-
ctx,
|
|
109
|
-
resolved,
|
|
110
|
-
prDir,
|
|
111
|
-
fileName: "verify.log",
|
|
211
|
+
await evaluateSnapshotFreshness({
|
|
212
|
+
snapshot: localSnapshot,
|
|
213
|
+
gitRoot: resolved.gitRoot,
|
|
214
|
+
workflowDir: config.paths.workflow_dir,
|
|
112
215
|
taskId: task.id,
|
|
113
|
-
|
|
216
|
+
branchHeadSha,
|
|
217
|
+
taskVerificationState: task.verification?.state ?? null,
|
|
218
|
+
requiresVerify,
|
|
114
219
|
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
220
|
+
let selectedSnapshot = localSnapshot;
|
|
221
|
+
if (branchForFreshness &&
|
|
222
|
+
branchHeadSha &&
|
|
223
|
+
(!localSnapshot.meta ||
|
|
224
|
+
!localSnapshot.freshnessReviewFresh ||
|
|
225
|
+
(requiresVerify && !localSnapshot.freshnessVerifySatisfied))) {
|
|
226
|
+
const worktreePath = await findWorktreeForBranch(resolved.gitRoot, branchForFreshness);
|
|
227
|
+
const branchTexts = {
|
|
228
|
+
metaText: await readPrArtifactFromBranch({
|
|
229
|
+
resolved,
|
|
230
|
+
prDir,
|
|
231
|
+
fileName: "meta.json",
|
|
232
|
+
branch: branchForFreshness,
|
|
233
|
+
worktreePath,
|
|
234
|
+
}),
|
|
235
|
+
diffstatText: await readPrArtifactFromBranch({
|
|
236
|
+
resolved,
|
|
237
|
+
prDir,
|
|
238
|
+
fileName: "diffstat.txt",
|
|
239
|
+
branch: branchForFreshness,
|
|
240
|
+
worktreePath,
|
|
241
|
+
}),
|
|
242
|
+
verifyLogText: await readPrArtifactFromBranch({
|
|
243
|
+
resolved,
|
|
244
|
+
prDir,
|
|
245
|
+
fileName: "verify.log",
|
|
246
|
+
branch: branchForFreshness,
|
|
247
|
+
worktreePath,
|
|
248
|
+
}),
|
|
249
|
+
reviewText: await readPrArtifactFromBranch({
|
|
250
|
+
resolved,
|
|
251
|
+
prDir,
|
|
252
|
+
fileName: "review.md",
|
|
253
|
+
branch: branchForFreshness,
|
|
254
|
+
worktreePath,
|
|
255
|
+
}),
|
|
256
|
+
githubTitleText: await readPrArtifactFromBranch({
|
|
257
|
+
resolved,
|
|
258
|
+
prDir,
|
|
259
|
+
fileName: "github-title.txt",
|
|
260
|
+
branch: branchForFreshness,
|
|
261
|
+
worktreePath,
|
|
262
|
+
}),
|
|
263
|
+
githubBodyText: await readPrArtifactFromBranch({
|
|
264
|
+
resolved,
|
|
265
|
+
prDir,
|
|
266
|
+
fileName: "github-body.md",
|
|
267
|
+
branch: branchForFreshness,
|
|
268
|
+
worktreePath,
|
|
269
|
+
}),
|
|
270
|
+
};
|
|
271
|
+
const branchParsed = validateSnapshotContents({
|
|
272
|
+
texts: branchTexts,
|
|
273
|
+
relPrDir,
|
|
274
|
+
relMetaPath,
|
|
275
|
+
relDiffstatPath,
|
|
276
|
+
relVerifyLogPath,
|
|
277
|
+
relReviewPath,
|
|
278
|
+
relGithubTitlePath,
|
|
279
|
+
relGithubBodyPath,
|
|
280
|
+
taskId: task.id,
|
|
281
|
+
});
|
|
282
|
+
const branchSnapshot = {
|
|
283
|
+
source: "branch",
|
|
284
|
+
texts: branchTexts,
|
|
285
|
+
meta: branchParsed.meta,
|
|
286
|
+
errors: branchParsed.errors,
|
|
287
|
+
freshnessEvaluated: false,
|
|
288
|
+
freshnessReviewFresh: false,
|
|
289
|
+
freshnessVerifySatisfied: false,
|
|
290
|
+
freshnessVerifyFresh: false,
|
|
291
|
+
freshnessVerifyLogSha: null,
|
|
292
|
+
};
|
|
293
|
+
await evaluateSnapshotFreshness({
|
|
294
|
+
snapshot: branchSnapshot,
|
|
295
|
+
gitRoot: resolved.gitRoot,
|
|
296
|
+
workflowDir: config.paths.workflow_dir,
|
|
297
|
+
taskId: task.id,
|
|
298
|
+
branchHeadSha,
|
|
299
|
+
taskVerificationState: task.verification?.state ?? null,
|
|
300
|
+
requiresVerify,
|
|
301
|
+
});
|
|
302
|
+
if (branchSnapshot.errors.length === 0 &&
|
|
303
|
+
branchSnapshot.meta &&
|
|
304
|
+
branchSnapshot.freshnessReviewFresh &&
|
|
305
|
+
(!requiresVerify || branchSnapshot.freshnessVerifySatisfied)) {
|
|
306
|
+
selectedSnapshot = branchSnapshot;
|
|
138
307
|
}
|
|
139
308
|
}
|
|
309
|
+
errors.push(...finalizeSnapshotErrors({
|
|
310
|
+
snapshot: selectedSnapshot,
|
|
311
|
+
branchHeadSha,
|
|
312
|
+
requiresVerify,
|
|
313
|
+
}));
|
|
140
314
|
if (errors.length > 0) {
|
|
141
315
|
throw new CliError({
|
|
142
316
|
exitCode: exitCodeForError("E_VALIDATION"),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type CommandContext } from "../shared/task-backend.js";
|
|
2
|
+
export declare function cmdPrCloseSuperseded(opts: {
|
|
3
|
+
ctx?: CommandContext;
|
|
4
|
+
cwd: string;
|
|
5
|
+
rootOverride?: string;
|
|
6
|
+
taskId: string;
|
|
7
|
+
deleteRemoteBranch: boolean;
|
|
8
|
+
}): Promise<number>;
|
|
9
|
+
//# sourceMappingURL=close-superseded.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"close-superseded.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/close-superseded.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AAiCnC,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,OAAO,CAAC;CAC7B,GAAG,OAAO,CAAC,MAAM,CAAC,CAsHlB"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { mapCoreError } from "../../cli/error-map.js";
|
|
3
|
+
import { exitCodeForError } from "../../cli/exit-codes.js";
|
|
4
|
+
import { createCliEmitter, infoMessage, workflowModeMessage } from "../../cli/output.js";
|
|
5
|
+
import { fileExists } from "../../cli/fs-utils.js";
|
|
6
|
+
import { CliError } from "../../shared/errors.js";
|
|
7
|
+
import { loadBackendTask, loadCommandContext, } from "../shared/task-backend.js";
|
|
8
|
+
import { parsePrMetaForwardCompatible } from "../shared/pr-meta.js";
|
|
9
|
+
import { cmdPrClose } from "./close.js";
|
|
10
|
+
import { isGhNotFound, resolveDefaultGithubRepo, runGhApiJson, runGhApiNoOutput, } from "./internal/gh-api.js";
|
|
11
|
+
import { resolvePrPaths } from "./internal/pr-paths.js";
|
|
12
|
+
async function deleteRemoteBranch(opts) {
|
|
13
|
+
const endpoint = `repos/${opts.repo}/git/refs/heads/${encodeURIComponent(opts.branch)}`;
|
|
14
|
+
try {
|
|
15
|
+
await runGhApiNoOutput(opts.cwd, [endpoint, "-X", "DELETE"]);
|
|
16
|
+
return "deleted";
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
if (isGhNotFound(err))
|
|
20
|
+
return "already-absent";
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export async function cmdPrCloseSuperseded(opts) {
|
|
25
|
+
try {
|
|
26
|
+
const output = createCliEmitter();
|
|
27
|
+
const ctx = opts.ctx ??
|
|
28
|
+
(await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
|
|
29
|
+
const { task } = await loadBackendTask({
|
|
30
|
+
ctx,
|
|
31
|
+
cwd: opts.cwd,
|
|
32
|
+
rootOverride: opts.rootOverride,
|
|
33
|
+
taskId: opts.taskId,
|
|
34
|
+
});
|
|
35
|
+
if (String(task.status ?? "")
|
|
36
|
+
.trim()
|
|
37
|
+
.toUpperCase() !== "DONE") {
|
|
38
|
+
throw new CliError({
|
|
39
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
40
|
+
code: "E_VALIDATION",
|
|
41
|
+
message: `Task ${opts.taskId} must be DONE before closing superseded PRs.`,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const { config, metaPath, resolved } = await resolvePrPaths({ ...opts, ctx });
|
|
45
|
+
if (config.workflow_mode !== "branch_pr") {
|
|
46
|
+
throw new CliError({
|
|
47
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
48
|
+
code: "E_USAGE",
|
|
49
|
+
message: workflowModeMessage(config.workflow_mode, "branch_pr"),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (!(await fileExists(metaPath))) {
|
|
53
|
+
throw new CliError({
|
|
54
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
55
|
+
code: "E_VALIDATION",
|
|
56
|
+
message: `Missing PR metadata: ${metaPath}`,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const meta = parsePrMetaForwardCompatible(await readFile(metaPath, "utf8"), opts.taskId);
|
|
60
|
+
const branch = meta.branch?.trim() ?? "";
|
|
61
|
+
if (!branch) {
|
|
62
|
+
throw new CliError({
|
|
63
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
64
|
+
code: "E_VALIDATION",
|
|
65
|
+
message: `Missing PR branch for ${opts.taskId}`,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const repo = await resolveDefaultGithubRepo(resolved.gitRoot);
|
|
69
|
+
const owner = repo.split("/", 1)[0]?.trim() ?? "";
|
|
70
|
+
if (!owner) {
|
|
71
|
+
throw new CliError({
|
|
72
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
73
|
+
code: "E_VALIDATION",
|
|
74
|
+
message: "Could not derive GitHub owner from remote origin.",
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const openPrs = await runGhApiJson(resolved.gitRoot, [
|
|
78
|
+
`repos/${repo}/pulls?head=${encodeURIComponent(`${owner}:${branch}`)}&state=open&per_page=100`,
|
|
79
|
+
]);
|
|
80
|
+
if (openPrs.length === 0) {
|
|
81
|
+
const remoteBranchAction = opts.deleteRemoteBranch
|
|
82
|
+
? await deleteRemoteBranch({ cwd: resolved.gitRoot, repo, branch })
|
|
83
|
+
: "skipped";
|
|
84
|
+
output.report([
|
|
85
|
+
{ label: "task", value: opts.taskId },
|
|
86
|
+
{ label: "branch", value: branch },
|
|
87
|
+
{ label: "state", value: "skipped" },
|
|
88
|
+
{ label: "reason", value: "no open task PR found" },
|
|
89
|
+
{ label: "remote_branch_action", value: remoteBranchAction },
|
|
90
|
+
], { header: infoMessage(`pr close-superseded ${opts.taskId}`) });
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
if (openPrs.length > 1) {
|
|
94
|
+
throw new CliError({
|
|
95
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
96
|
+
code: "E_VALIDATION",
|
|
97
|
+
message: `Multiple open PRs match task ${opts.taskId} branch ${branch}: ${openPrs
|
|
98
|
+
.map((pr) => pr.number)
|
|
99
|
+
.filter((value) => typeof value === "number" && Number.isInteger(value) && value > 0)
|
|
100
|
+
.map((value) => `#${value}`)
|
|
101
|
+
.join(", ")}`,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const prNumber = Number(openPrs[0]?.number ?? 0);
|
|
105
|
+
if (!Number.isInteger(prNumber) || prNumber <= 0) {
|
|
106
|
+
throw new CliError({
|
|
107
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
108
|
+
code: "E_VALIDATION",
|
|
109
|
+
message: `Could not determine open PR number for task ${opts.taskId}.`,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return await cmdPrClose({
|
|
113
|
+
ctx,
|
|
114
|
+
cwd: opts.cwd,
|
|
115
|
+
rootOverride: opts.rootOverride,
|
|
116
|
+
prNumber,
|
|
117
|
+
comment: `Superseded by protected-main closure of task ${opts.taskId}.`,
|
|
118
|
+
deleteRemoteBranch: opts.deleteRemoteBranch,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
if (err instanceof CliError)
|
|
123
|
+
throw err;
|
|
124
|
+
throw mapCoreError(err, {
|
|
125
|
+
command: "pr close-superseded",
|
|
126
|
+
root: opts.rootOverride ?? null,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type CommandContext } from "../shared/task-backend.js";
|
|
2
|
+
export declare function cmdPrClose(opts: {
|
|
3
|
+
ctx?: CommandContext;
|
|
4
|
+
cwd: string;
|
|
5
|
+
rootOverride?: string;
|
|
6
|
+
prNumber: number;
|
|
7
|
+
repo?: string;
|
|
8
|
+
comment?: string;
|
|
9
|
+
deleteRemoteBranch: boolean;
|
|
10
|
+
}): Promise<number>;
|
|
11
|
+
//# sourceMappingURL=close.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"close.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/close.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AA+CpF,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,OAAO,CAAC;CAC7B,GAAG,OAAO,CAAC,MAAM,CAAC,CAuGlB"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { mapCoreError } from "../../cli/error-map.js";
|
|
2
|
+
import { exitCodeForError } from "../../cli/exit-codes.js";
|
|
3
|
+
import { createCliEmitter, successMessage } from "../../cli/output.js";
|
|
4
|
+
import { CliError } from "../../shared/errors.js";
|
|
5
|
+
import { loadCommandContext } from "../shared/task-backend.js";
|
|
6
|
+
import { isGhNotFound, resolveDefaultGithubRepo, runGhApiJson, runGhApiNoOutput, } from "./internal/gh-api.js";
|
|
7
|
+
function ensureNonEmptyFlag(name, value) {
|
|
8
|
+
const trimmed = value.trim();
|
|
9
|
+
if (!trimmed) {
|
|
10
|
+
throw new CliError({
|
|
11
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
12
|
+
code: "E_USAGE",
|
|
13
|
+
message: `Invalid value for --${name}.`,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return trimmed;
|
|
17
|
+
}
|
|
18
|
+
export async function cmdPrClose(opts) {
|
|
19
|
+
try {
|
|
20
|
+
if (!Number.isInteger(opts.prNumber) || opts.prNumber <= 0) {
|
|
21
|
+
throw new CliError({
|
|
22
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
23
|
+
code: "E_USAGE",
|
|
24
|
+
message: "Invalid PR number.",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const output = createCliEmitter();
|
|
28
|
+
const ctx = opts.ctx ??
|
|
29
|
+
(await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
|
|
30
|
+
const commandCwd = ctx.resolvedProject.gitRoot;
|
|
31
|
+
const repo = opts.repo
|
|
32
|
+
? ensureNonEmptyFlag("repo", opts.repo)
|
|
33
|
+
: await resolveDefaultGithubRepo(commandCwd);
|
|
34
|
+
const comment = opts.comment?.trim() ? ensureNonEmptyFlag("comment", opts.comment) : null;
|
|
35
|
+
const pr = await runGhApiJson(commandCwd, [
|
|
36
|
+
`repos/${repo}/pulls/${opts.prNumber}`,
|
|
37
|
+
]);
|
|
38
|
+
if (!pr.number) {
|
|
39
|
+
throw new CliError({
|
|
40
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
41
|
+
code: "E_VALIDATION",
|
|
42
|
+
message: `GitHub pull request #${opts.prNumber} was not found in ${repo}.`,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (comment) {
|
|
46
|
+
await runGhApiNoOutput(commandCwd, [
|
|
47
|
+
`repos/${repo}/issues/${opts.prNumber}/comments`,
|
|
48
|
+
"-X",
|
|
49
|
+
"POST",
|
|
50
|
+
"-f",
|
|
51
|
+
`body=${comment}`,
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
const closed = await runGhApiJson(commandCwd, [
|
|
55
|
+
`repos/${repo}/pulls/${opts.prNumber}`,
|
|
56
|
+
"-X",
|
|
57
|
+
"PATCH",
|
|
58
|
+
"-f",
|
|
59
|
+
"state=closed",
|
|
60
|
+
]);
|
|
61
|
+
const headRepo = closed.head?.repo?.full_name?.trim() ?? pr.head?.repo?.full_name?.trim() ?? null;
|
|
62
|
+
const headRef = closed.head?.ref?.trim() ?? pr.head?.ref?.trim() ?? null;
|
|
63
|
+
let remoteBranchAction = "skipped";
|
|
64
|
+
if (opts.deleteRemoteBranch) {
|
|
65
|
+
if (!headRef) {
|
|
66
|
+
remoteBranchAction = "skipped-missing-head";
|
|
67
|
+
}
|
|
68
|
+
else if (headRepo && headRepo !== repo) {
|
|
69
|
+
remoteBranchAction = "skipped-fork";
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
try {
|
|
73
|
+
await runGhApiNoOutput(commandCwd, [
|
|
74
|
+
`repos/${repo}/git/refs/heads/${encodeURIComponent(headRef)}`,
|
|
75
|
+
"-X",
|
|
76
|
+
"DELETE",
|
|
77
|
+
]);
|
|
78
|
+
remoteBranchAction = "deleted";
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
if (isGhNotFound(err)) {
|
|
82
|
+
remoteBranchAction = "already-absent";
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const result = {
|
|
91
|
+
repo,
|
|
92
|
+
prNumber: opts.prNumber,
|
|
93
|
+
url: closed.html_url?.trim() ?? pr.html_url?.trim() ?? null,
|
|
94
|
+
state: closed.state?.trim() ?? pr.state?.trim() ?? "closed",
|
|
95
|
+
comment: comment ? "added" : "skipped",
|
|
96
|
+
remoteBranch: headRef,
|
|
97
|
+
remoteBranchAction,
|
|
98
|
+
};
|
|
99
|
+
output.report([
|
|
100
|
+
{ label: "repo", value: result.repo },
|
|
101
|
+
{ label: "state", value: result.state },
|
|
102
|
+
{ label: "url", value: result.url ?? "unknown" },
|
|
103
|
+
{ label: "comment", value: result.comment },
|
|
104
|
+
{ label: "remote_branch", value: result.remoteBranch ?? "unknown" },
|
|
105
|
+
{ label: "remote_branch_action", value: result.remoteBranchAction },
|
|
106
|
+
], {
|
|
107
|
+
header: successMessage("pr close", `#${result.prNumber}`),
|
|
108
|
+
});
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
if (err instanceof CliError)
|
|
113
|
+
throw err;
|
|
114
|
+
throw mapCoreError(err, { command: "pr close", root: opts.rootOverride ?? null });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -2,5 +2,7 @@ export { cmdPrOpen } from "./open.js";
|
|
|
2
2
|
export { cmdPrUpdate } from "./update.js";
|
|
3
3
|
export { cmdPrCheck } from "./check.js";
|
|
4
4
|
export { cmdPrNote } from "./note.js";
|
|
5
|
+
export { cmdPrClose } from "./close.js";
|
|
6
|
+
export { cmdPrCloseSuperseded } from "./close-superseded.js";
|
|
5
7
|
export { cmdIntegrate } from "./integrate.js";
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -2,4 +2,6 @@ export { cmdPrOpen } from "./open.js";
|
|
|
2
2
|
export { cmdPrUpdate } from "./update.js";
|
|
3
3
|
export { cmdPrCheck } from "./check.js";
|
|
4
4
|
export { cmdPrNote } from "./note.js";
|
|
5
|
+
export { cmdPrClose } from "./close.js";
|
|
6
|
+
export { cmdPrCloseSuperseded } from "./close-superseded.js";
|
|
5
7
|
export { cmdIntegrate } from "./integrate.js";
|