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
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
import { mkdir, readFile, rm } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { resolveBaseBranch } from "@agentplaneorg/core";
|
|
4
|
+
import { mapBackendError } from "../../../cli/error-map.js";
|
|
5
|
+
import { exitCodeForError } from "../../../cli/exit-codes.js";
|
|
6
|
+
import { fileExists } from "../../../cli/fs-utils.js";
|
|
7
|
+
import { workflowModeMessage } from "../../../cli/output.js";
|
|
8
|
+
import { CliError } from "../../../shared/errors.js";
|
|
9
|
+
import { writeJsonStableIfChanged, writeTextIfChanged } from "../../../shared/write-if-changed.js";
|
|
10
|
+
import { execFileAsync, gitEnv } from "../../shared/git.js";
|
|
11
|
+
import { gitDiffStat } from "../../shared/git-diff.js";
|
|
12
|
+
import { gitCurrentBranch } from "../../shared/git-ops.js";
|
|
13
|
+
import { parseTaskIdFromBranch } from "../../shared/git-worktree.js";
|
|
14
|
+
import { isTransientGhTransportError, normalizeGhTransportError, withGhTransportRetry, } from "../../shared/gh-transport.js";
|
|
15
|
+
import { INCIDENTS_POLICY_PATH } from "../../incidents/shared.js";
|
|
16
|
+
import { buildObservedGithubPrMeta, buildOpenedPrMeta, resolvePrArtifactHeadSha, buildUpdatedPrMeta, parsePrMeta, } from "../../shared/pr-meta.js";
|
|
17
|
+
import { loadBackendTask, loadCommandContext, } from "../../shared/task-backend.js";
|
|
18
|
+
import { isTaskLocalOnlyAdvance } from "../../shared/task-local-freshness.js";
|
|
19
|
+
import { resolvePrPaths } from "./pr-paths.js";
|
|
20
|
+
import { readPrHandoffNotes } from "./note-store.js";
|
|
21
|
+
import { ghEnv } from "./gh-api.js";
|
|
22
|
+
import { buildGithubPrTitle, renderGithubPrBody, renderPrAutoSummary, renderPrReviewDocument, } from "./review-template.js";
|
|
23
|
+
function nowIso() {
|
|
24
|
+
return new Date().toISOString();
|
|
25
|
+
}
|
|
26
|
+
async function readTextIfExists(filePath) {
|
|
27
|
+
try {
|
|
28
|
+
return await readFile(filePath, "utf8");
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
const code = err?.code;
|
|
32
|
+
if (code === "ENOENT")
|
|
33
|
+
return null;
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function restoreIncidentRegistryIfNeeded(opts) {
|
|
38
|
+
const incidentsPath = path.join(opts.gitRoot, INCIDENTS_POLICY_PATH);
|
|
39
|
+
const nextText = await readTextIfExists(incidentsPath);
|
|
40
|
+
if (nextText === opts.previousText)
|
|
41
|
+
return;
|
|
42
|
+
if (opts.previousText === null) {
|
|
43
|
+
await rm(incidentsPath, { force: true });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
await writeTextIfChanged(incidentsPath, opts.previousText);
|
|
47
|
+
}
|
|
48
|
+
function isUnknownRevisionError(err) {
|
|
49
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
50
|
+
return (/unknown revision or path not in the working tree/i.test(message) ||
|
|
51
|
+
/bad revision/i.test(message) ||
|
|
52
|
+
/ambiguous argument/i.test(message));
|
|
53
|
+
}
|
|
54
|
+
function parseGithubRepoFromRemoteUrl(remoteUrl) {
|
|
55
|
+
const trimmed = remoteUrl.trim();
|
|
56
|
+
if (!trimmed)
|
|
57
|
+
return null;
|
|
58
|
+
const httpsMatch = /^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/.exec(trimmed);
|
|
59
|
+
if (httpsMatch)
|
|
60
|
+
return `${httpsMatch[1]}/${httpsMatch[2]}`;
|
|
61
|
+
const sshMatch = /^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/.exec(trimmed);
|
|
62
|
+
if (sshMatch)
|
|
63
|
+
return `${sshMatch[1]}/${sshMatch[2]}`;
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
async function resolveGithubRepoFromOrigin(gitRoot) {
|
|
67
|
+
try {
|
|
68
|
+
const { stdout } = await execFileAsync("git", ["remote", "get-url", "origin"], {
|
|
69
|
+
cwd: gitRoot,
|
|
70
|
+
env: gitEnv(),
|
|
71
|
+
});
|
|
72
|
+
return parseGithubRepoFromRemoteUrl(stdout);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function normalizeObservedGithubPr(record) {
|
|
79
|
+
const number = Number(record.number);
|
|
80
|
+
if (!Number.isInteger(number) || number <= 0)
|
|
81
|
+
return null;
|
|
82
|
+
const state = record.state?.trim().toLowerCase() ?? "";
|
|
83
|
+
const mergedAt = record.merged_at?.trim() ?? null;
|
|
84
|
+
const status = mergedAt && mergedAt.length > 0
|
|
85
|
+
? "MERGED"
|
|
86
|
+
: state === "open"
|
|
87
|
+
? "OPEN"
|
|
88
|
+
: state === "closed"
|
|
89
|
+
? "CLOSED"
|
|
90
|
+
: null;
|
|
91
|
+
if (!status)
|
|
92
|
+
return null;
|
|
93
|
+
const prUrl = record.html_url?.trim() ?? null;
|
|
94
|
+
const mergeCommit = record.merge_commit_sha?.trim() ?? null;
|
|
95
|
+
const base = record.base?.ref?.trim() ?? null;
|
|
96
|
+
const headSha = record.head?.sha?.trim() ?? null;
|
|
97
|
+
return {
|
|
98
|
+
prNumber: number,
|
|
99
|
+
prUrl,
|
|
100
|
+
status,
|
|
101
|
+
mergedAt,
|
|
102
|
+
mergeCommit,
|
|
103
|
+
base,
|
|
104
|
+
headSha,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async function tryLookupExistingGithubPrByBranch(opts) {
|
|
108
|
+
const repo = await resolveGithubRepoFromOrigin(opts.gitRoot);
|
|
109
|
+
if (!repo)
|
|
110
|
+
return null;
|
|
111
|
+
const owner = repo.split("/")[0]?.trim() ?? "";
|
|
112
|
+
if (!owner)
|
|
113
|
+
return null;
|
|
114
|
+
const query = new URLSearchParams({ state: "all", head: `${owner}:${opts.branch}` });
|
|
115
|
+
const baseBranch = opts.baseBranch?.trim() ?? "";
|
|
116
|
+
if (baseBranch)
|
|
117
|
+
query.set("base", baseBranch);
|
|
118
|
+
const endpoint = `repos/${repo}/pulls?${query.toString()}`;
|
|
119
|
+
try {
|
|
120
|
+
const { stdout } = await withGhTransportRetry(() => execFileAsync("gh", ["api", endpoint], {
|
|
121
|
+
cwd: opts.gitRoot,
|
|
122
|
+
env: ghEnv(),
|
|
123
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
124
|
+
}), { label: `running gh api ${endpoint}` });
|
|
125
|
+
const parsed = JSON.parse(stdout);
|
|
126
|
+
if (!Array.isArray(parsed) || parsed.length === 0)
|
|
127
|
+
return null;
|
|
128
|
+
for (const record of parsed) {
|
|
129
|
+
const observed = normalizeObservedGithubPr(record);
|
|
130
|
+
if (observed)
|
|
131
|
+
return observed;
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
const code = err?.code;
|
|
137
|
+
if (code === "ENOENT")
|
|
138
|
+
return null;
|
|
139
|
+
const message = normalizeGhTransportError(err);
|
|
140
|
+
if (message.trim().length > 0)
|
|
141
|
+
return null;
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function formatGithubPrLink(prNumber, prUrl, verb) {
|
|
146
|
+
return prUrl?.trim()
|
|
147
|
+
? `${verb} GitHub PR #${prNumber}: ${prUrl.trim()}`
|
|
148
|
+
: `${verb} GitHub PR #${prNumber}`;
|
|
149
|
+
}
|
|
150
|
+
function formatUnpublishedRemoteHeadReason(branch) {
|
|
151
|
+
return (`task branch ${branch} is not yet published on origin; push it with ` +
|
|
152
|
+
`\`git push -u origin ${branch}\` and rerun \`agentplane pr open\``);
|
|
153
|
+
}
|
|
154
|
+
function isMissingRemoteHeadCreateError(err) {
|
|
155
|
+
const text = normalizeGhTransportError(err);
|
|
156
|
+
if (!/\b422\b/i.test(text))
|
|
157
|
+
return false;
|
|
158
|
+
return (/head sha/i.test(text) ||
|
|
159
|
+
/head ref/i.test(text) ||
|
|
160
|
+
/head.*must be a branch/i.test(text) ||
|
|
161
|
+
/head.*not found/i.test(text) ||
|
|
162
|
+
/field["']?\s*:\s*["']head["']/i.test(text) ||
|
|
163
|
+
/field\s+head\b/i.test(text) ||
|
|
164
|
+
/no commits between/i.test(text));
|
|
165
|
+
}
|
|
166
|
+
function summarizeGithubPrCreateFailure(err) {
|
|
167
|
+
const text = normalizeGhTransportError(err);
|
|
168
|
+
if (err?.code === "ENOENT") {
|
|
169
|
+
return "gh CLI is unavailable";
|
|
170
|
+
}
|
|
171
|
+
if (/authentication required/i.test(text) ||
|
|
172
|
+
/not logged into github/i.test(text) ||
|
|
173
|
+
/bad credentials/i.test(text) ||
|
|
174
|
+
/permission denied/i.test(text) ||
|
|
175
|
+
/\b401\b/i.test(text) ||
|
|
176
|
+
/\b403\b/i.test(text)) {
|
|
177
|
+
return "GitHub auth or permissions unavailable";
|
|
178
|
+
}
|
|
179
|
+
if (isTransientGhTransportError(err)) {
|
|
180
|
+
return "GitHub transport failed; retry `agentplane pr open`";
|
|
181
|
+
}
|
|
182
|
+
return "GitHub PR creation failed";
|
|
183
|
+
}
|
|
184
|
+
async function tryCreateGithubPr(opts) {
|
|
185
|
+
const repo = await resolveGithubRepoFromOrigin(opts.gitRoot);
|
|
186
|
+
if (!repo) {
|
|
187
|
+
return {
|
|
188
|
+
observed: null,
|
|
189
|
+
stagedReason: "GitHub origin repo unavailable",
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
const baseBranch = opts.baseBranch?.trim() ?? "";
|
|
193
|
+
if (!baseBranch) {
|
|
194
|
+
return {
|
|
195
|
+
observed: null,
|
|
196
|
+
stagedReason: "base branch unresolved",
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
const { stdout } = await withGhTransportRetry(() => execFileAsync("gh", [
|
|
201
|
+
"api",
|
|
202
|
+
`repos/${repo}/pulls`,
|
|
203
|
+
"-X",
|
|
204
|
+
"POST",
|
|
205
|
+
"-f",
|
|
206
|
+
`title=${opts.title}`,
|
|
207
|
+
"-f",
|
|
208
|
+
`body=${opts.body}`,
|
|
209
|
+
"-f",
|
|
210
|
+
`head=${opts.branch}`,
|
|
211
|
+
"-f",
|
|
212
|
+
`base=${baseBranch}`,
|
|
213
|
+
], {
|
|
214
|
+
cwd: opts.gitRoot,
|
|
215
|
+
env: ghEnv(),
|
|
216
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
217
|
+
}), { label: `running gh api repos/${repo}/pulls` });
|
|
218
|
+
return {
|
|
219
|
+
observed: normalizeObservedGithubPr(JSON.parse(stdout)),
|
|
220
|
+
stagedReason: null,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
catch (err) {
|
|
224
|
+
if (isMissingRemoteHeadCreateError(err)) {
|
|
225
|
+
return {
|
|
226
|
+
observed: null,
|
|
227
|
+
stagedReason: formatUnpublishedRemoteHeadReason(opts.branch),
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
observed: null,
|
|
232
|
+
stagedReason: summarizeGithubPrCreateFailure(err),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
async function resolveBranchHeadSha(opts) {
|
|
237
|
+
try {
|
|
238
|
+
const { stdout } = await execFileAsync("git", ["rev-parse", opts.branch], {
|
|
239
|
+
cwd: opts.gitRoot,
|
|
240
|
+
env: gitEnv(),
|
|
241
|
+
});
|
|
242
|
+
return stdout.trim() || null;
|
|
243
|
+
}
|
|
244
|
+
catch (err) {
|
|
245
|
+
if (!isUnknownRevisionError(err))
|
|
246
|
+
throw err;
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
async function computePrDiffstat(opts) {
|
|
251
|
+
try {
|
|
252
|
+
return await gitDiffStat(opts.gitRoot, opts.baseBranch, opts.branch, {
|
|
253
|
+
excludePaths: [path.relative(opts.gitRoot, opts.prDir)],
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
catch (err) {
|
|
257
|
+
if (!isUnknownRevisionError(err))
|
|
258
|
+
throw err;
|
|
259
|
+
return "";
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
async function resolvePrSyncBranch(opts) {
|
|
263
|
+
const explicitBranch = opts.branch?.trim() ?? "";
|
|
264
|
+
if (explicitBranch) {
|
|
265
|
+
return { branch: explicitBranch, source: "explicit" };
|
|
266
|
+
}
|
|
267
|
+
if (await fileExists(opts.metaPath)) {
|
|
268
|
+
const metaBranch = parsePrMeta(await readFile(opts.metaPath, "utf8"), opts.taskId).branch?.trim() ?? "";
|
|
269
|
+
if (metaBranch) {
|
|
270
|
+
return { branch: metaBranch, source: "meta" };
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const currentBranchValue = await gitCurrentBranch(opts.resolved.gitRoot);
|
|
274
|
+
const currentBranch = currentBranchValue.trim();
|
|
275
|
+
if (currentBranch) {
|
|
276
|
+
return { branch: currentBranch, source: "current" };
|
|
277
|
+
}
|
|
278
|
+
return { branch: null, source: "none" };
|
|
279
|
+
}
|
|
280
|
+
export async function ensurePrArtifactsSynced(opts) {
|
|
281
|
+
const ctx = opts.ctx ??
|
|
282
|
+
(await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
|
|
283
|
+
const { resolved, config, prDir, metaPath } = await resolvePrPaths({ ...opts, ctx });
|
|
284
|
+
if (config.workflow_mode !== "branch_pr")
|
|
285
|
+
return null;
|
|
286
|
+
const resolvedBranch = await resolvePrSyncBranch({
|
|
287
|
+
resolved,
|
|
288
|
+
metaPath,
|
|
289
|
+
taskId: opts.taskId,
|
|
290
|
+
branch: opts.branch,
|
|
291
|
+
});
|
|
292
|
+
const branch = resolvedBranch.branch?.trim() ?? "";
|
|
293
|
+
if (!branch)
|
|
294
|
+
return null;
|
|
295
|
+
if (resolvedBranch.source === "current" &&
|
|
296
|
+
parseTaskIdFromBranch(config.branch.task_prefix, branch) !== opts.taskId) {
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
const baseBranch = await resolveBaseBranch({
|
|
300
|
+
cwd: opts.cwd,
|
|
301
|
+
rootOverride: opts.rootOverride ?? null,
|
|
302
|
+
cliBaseOpt: null,
|
|
303
|
+
mode: config.workflow_mode,
|
|
304
|
+
});
|
|
305
|
+
if (resolvedBranch.source === "current" && baseBranch && branch === baseBranch) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
const reviewPath = path.join(prDir, "review.md");
|
|
309
|
+
const artifactsExist = (await fileExists(metaPath)) && (await fileExists(reviewPath));
|
|
310
|
+
if (!artifactsExist) {
|
|
311
|
+
await syncPrArtifacts({
|
|
312
|
+
...opts,
|
|
313
|
+
ctx,
|
|
314
|
+
mode: "open",
|
|
315
|
+
author: opts.author,
|
|
316
|
+
branch,
|
|
317
|
+
remoteMode: "sync-only",
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
const result = await syncPrArtifacts({
|
|
321
|
+
...opts,
|
|
322
|
+
ctx,
|
|
323
|
+
mode: "update",
|
|
324
|
+
branch,
|
|
325
|
+
});
|
|
326
|
+
return { ...result, branch };
|
|
327
|
+
}
|
|
328
|
+
export async function syncPrArtifacts(opts) {
|
|
329
|
+
try {
|
|
330
|
+
const ctx = opts.ctx ??
|
|
331
|
+
(await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
|
|
332
|
+
const { task } = await loadBackendTask({
|
|
333
|
+
ctx,
|
|
334
|
+
cwd: opts.cwd,
|
|
335
|
+
rootOverride: opts.rootOverride,
|
|
336
|
+
taskId: opts.taskId,
|
|
337
|
+
});
|
|
338
|
+
const { resolved, config, prDir, metaPath, diffstatPath, notesPath, verifyLogPath, reviewPath, githubTitlePath, githubBodyPath, } = await resolvePrPaths({ ...opts, ctx });
|
|
339
|
+
const incidentsTextBefore = await readTextIfExists(path.join(resolved.gitRoot, INCIDENTS_POLICY_PATH));
|
|
340
|
+
try {
|
|
341
|
+
if (config.workflow_mode !== "branch_pr") {
|
|
342
|
+
throw new CliError({
|
|
343
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
344
|
+
code: "E_USAGE",
|
|
345
|
+
message: workflowModeMessage(config.workflow_mode, "branch_pr"),
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
const resolvedBranch = await resolvePrSyncBranch({
|
|
349
|
+
resolved,
|
|
350
|
+
metaPath,
|
|
351
|
+
taskId: task.id,
|
|
352
|
+
branch: opts.branch,
|
|
353
|
+
});
|
|
354
|
+
const branch = resolvedBranch.branch?.trim() ?? "";
|
|
355
|
+
if (!branch) {
|
|
356
|
+
throw new CliError({
|
|
357
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
358
|
+
code: "E_USAGE",
|
|
359
|
+
message: "Branch could not be resolved (use --branch).",
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
const metaExists = await fileExists(metaPath);
|
|
363
|
+
const reviewExists = await fileExists(reviewPath);
|
|
364
|
+
if (opts.mode === "update" && (!metaExists || !reviewExists)) {
|
|
365
|
+
const missing = [];
|
|
366
|
+
if (!metaExists)
|
|
367
|
+
missing.push(path.relative(resolved.gitRoot, metaPath));
|
|
368
|
+
if (!reviewExists)
|
|
369
|
+
missing.push(path.relative(resolved.gitRoot, reviewPath));
|
|
370
|
+
throw new CliError({
|
|
371
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
372
|
+
code: "E_VALIDATION",
|
|
373
|
+
message: `PR artifacts missing: ${missing.join(", ")} (run \`agentplane pr open\`)`,
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
await mkdir(prDir, { recursive: true });
|
|
377
|
+
const existingMeta = metaExists && (await fileExists(metaPath))
|
|
378
|
+
? parsePrMeta(await readFile(metaPath, "utf8"), task.id)
|
|
379
|
+
: null;
|
|
380
|
+
const handoffNotes = await readPrHandoffNotes(notesPath);
|
|
381
|
+
const now = nowIso();
|
|
382
|
+
const createdAt = existingMeta?.created_at ?? now;
|
|
383
|
+
const baseBranch = await resolveBaseBranch({
|
|
384
|
+
cwd: opts.cwd,
|
|
385
|
+
rootOverride: opts.rootOverride ?? null,
|
|
386
|
+
cliBaseOpt: null,
|
|
387
|
+
mode: config.workflow_mode,
|
|
388
|
+
});
|
|
389
|
+
const headSha = await resolveBranchHeadSha({ gitRoot: resolved.gitRoot, branch });
|
|
390
|
+
const preservePreviousHead = Boolean(existingMeta?.head_sha) &&
|
|
391
|
+
Boolean(headSha) &&
|
|
392
|
+
(await isTaskLocalOnlyAdvance({
|
|
393
|
+
gitRoot: resolved.gitRoot,
|
|
394
|
+
workflowDir: config.paths.workflow_dir,
|
|
395
|
+
taskId: task.id,
|
|
396
|
+
fromRef: existingMeta?.head_sha ?? null,
|
|
397
|
+
toRef: headSha,
|
|
398
|
+
}));
|
|
399
|
+
const renderedHeadSha = resolvePrArtifactHeadSha({
|
|
400
|
+
previousHeadSha: existingMeta?.head_sha ?? null,
|
|
401
|
+
currentHeadSha: headSha,
|
|
402
|
+
preservePrevious: preservePreviousHead,
|
|
403
|
+
});
|
|
404
|
+
const preservedRenderUpdatedAt = existingMeta &&
|
|
405
|
+
(existingMeta.branch ?? null) === branch &&
|
|
406
|
+
(existingMeta.base ?? null) === (baseBranch ?? null) &&
|
|
407
|
+
(existingMeta.head_sha ?? null) === (renderedHeadSha ?? null)
|
|
408
|
+
? existingMeta.updated_at
|
|
409
|
+
: null;
|
|
410
|
+
const renderUpdatedAt = preservedRenderUpdatedAt ?? now;
|
|
411
|
+
if (opts.mode === "open") {
|
|
412
|
+
const remoteMode = opts.remoteMode ?? "auto";
|
|
413
|
+
const diffstat = baseBranch
|
|
414
|
+
? await computePrDiffstat({
|
|
415
|
+
gitRoot: resolved.gitRoot,
|
|
416
|
+
baseBranch,
|
|
417
|
+
branch,
|
|
418
|
+
prDir,
|
|
419
|
+
})
|
|
420
|
+
: "";
|
|
421
|
+
const renderedSummaryHeadSha = renderedHeadSha ?? headSha;
|
|
422
|
+
let nextMeta = buildOpenedPrMeta({
|
|
423
|
+
taskId: task.id,
|
|
424
|
+
branch,
|
|
425
|
+
at: now,
|
|
426
|
+
previousMeta: existingMeta,
|
|
427
|
+
base: baseBranch,
|
|
428
|
+
headSha: renderedHeadSha,
|
|
429
|
+
});
|
|
430
|
+
const linkedExistingOutcome = typeof nextMeta.pr_number === "number" && nextMeta.pr_number > 0
|
|
431
|
+
? {
|
|
432
|
+
action: "linked-existing",
|
|
433
|
+
message: formatGithubPrLink(nextMeta.pr_number, nextMeta.pr_url ?? null, "linked to"),
|
|
434
|
+
}
|
|
435
|
+
: null;
|
|
436
|
+
let openOutcome;
|
|
437
|
+
const githubTitle = buildGithubPrTitle(task);
|
|
438
|
+
const githubBody = renderGithubPrBody({
|
|
439
|
+
task,
|
|
440
|
+
handoffNotes,
|
|
441
|
+
autoSummary: renderPrAutoSummary({
|
|
442
|
+
updatedAt: renderUpdatedAt,
|
|
443
|
+
branch,
|
|
444
|
+
headSha: renderedSummaryHeadSha,
|
|
445
|
+
diffstat,
|
|
446
|
+
}),
|
|
447
|
+
});
|
|
448
|
+
const observedGithubPr = await tryLookupExistingGithubPrByBranch({
|
|
449
|
+
gitRoot: resolved.gitRoot,
|
|
450
|
+
branch,
|
|
451
|
+
baseBranch,
|
|
452
|
+
});
|
|
453
|
+
if (observedGithubPr) {
|
|
454
|
+
nextMeta = buildObservedGithubPrMeta({
|
|
455
|
+
meta: nextMeta,
|
|
456
|
+
observed: observedGithubPr,
|
|
457
|
+
at: now,
|
|
458
|
+
});
|
|
459
|
+
openOutcome = {
|
|
460
|
+
action: "linked-existing",
|
|
461
|
+
message: formatGithubPrLink(observedGithubPr.prNumber, observedGithubPr.prUrl, "linked to"),
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
else if (remoteMode === "sync-only") {
|
|
465
|
+
openOutcome = linkedExistingOutcome ?? {
|
|
466
|
+
action: "sync-only",
|
|
467
|
+
message: "local PR artifacts synced; remote PR creation skipped (--sync-only)",
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
const createdGithubPr = await tryCreateGithubPr({
|
|
472
|
+
gitRoot: resolved.gitRoot,
|
|
473
|
+
branch,
|
|
474
|
+
baseBranch,
|
|
475
|
+
title: githubTitle,
|
|
476
|
+
body: githubBody,
|
|
477
|
+
});
|
|
478
|
+
if (createdGithubPr.observed) {
|
|
479
|
+
nextMeta = buildObservedGithubPrMeta({
|
|
480
|
+
meta: nextMeta,
|
|
481
|
+
observed: createdGithubPr.observed,
|
|
482
|
+
at: now,
|
|
483
|
+
});
|
|
484
|
+
openOutcome = {
|
|
485
|
+
action: "created",
|
|
486
|
+
message: formatGithubPrLink(createdGithubPr.observed.prNumber, createdGithubPr.observed.prUrl, "created"),
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
openOutcome = linkedExistingOutcome ?? {
|
|
491
|
+
action: "staged",
|
|
492
|
+
message: `local PR artifacts synced; remote PR creation staged (${createdGithubPr.stagedReason ?? "remote creation unavailable"})`,
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
const nextAutoSummary = renderPrAutoSummary({
|
|
497
|
+
updatedAt: renderUpdatedAt,
|
|
498
|
+
branch,
|
|
499
|
+
headSha: renderedSummaryHeadSha,
|
|
500
|
+
diffstat,
|
|
501
|
+
});
|
|
502
|
+
const nextReview = renderPrReviewDocument({
|
|
503
|
+
task,
|
|
504
|
+
author: opts.author,
|
|
505
|
+
createdAt,
|
|
506
|
+
branch,
|
|
507
|
+
handoffNotes,
|
|
508
|
+
autoSummary: nextAutoSummary,
|
|
509
|
+
});
|
|
510
|
+
const nextGithubBody = renderGithubPrBody({
|
|
511
|
+
task,
|
|
512
|
+
handoffNotes,
|
|
513
|
+
autoSummary: nextAutoSummary,
|
|
514
|
+
});
|
|
515
|
+
await writeJsonStableIfChanged(metaPath, nextMeta);
|
|
516
|
+
await writeTextIfChanged(diffstatPath, diffstat ? `${diffstat}\n` : "");
|
|
517
|
+
if (!(await fileExists(notesPath))) {
|
|
518
|
+
await writeTextIfChanged(notesPath, "");
|
|
519
|
+
}
|
|
520
|
+
if (!(await fileExists(verifyLogPath))) {
|
|
521
|
+
await writeTextIfChanged(verifyLogPath, "");
|
|
522
|
+
}
|
|
523
|
+
await writeTextIfChanged(reviewPath, nextReview);
|
|
524
|
+
await writeTextIfChanged(githubTitlePath, `${githubTitle}\n`);
|
|
525
|
+
await writeTextIfChanged(githubBodyPath, nextGithubBody);
|
|
526
|
+
return { meta: nextMeta, prDir, resolved, openOutcome };
|
|
527
|
+
}
|
|
528
|
+
if (!baseBranch) {
|
|
529
|
+
throw new CliError({
|
|
530
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
531
|
+
code: "E_USAGE",
|
|
532
|
+
message: "Base branch could not be resolved (use `agentplane branch base set`).",
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
const diffstat = await computePrDiffstat({
|
|
536
|
+
gitRoot: resolved.gitRoot,
|
|
537
|
+
baseBranch,
|
|
538
|
+
branch,
|
|
539
|
+
prDir,
|
|
540
|
+
});
|
|
541
|
+
let nextMeta = buildUpdatedPrMeta({
|
|
542
|
+
meta: existingMeta,
|
|
543
|
+
branch,
|
|
544
|
+
at: now,
|
|
545
|
+
base: baseBranch,
|
|
546
|
+
headSha: renderedHeadSha,
|
|
547
|
+
});
|
|
548
|
+
const observedGithubPr = await tryLookupExistingGithubPrByBranch({
|
|
549
|
+
gitRoot: resolved.gitRoot,
|
|
550
|
+
branch,
|
|
551
|
+
baseBranch,
|
|
552
|
+
});
|
|
553
|
+
if (observedGithubPr) {
|
|
554
|
+
nextMeta = buildObservedGithubPrMeta({
|
|
555
|
+
meta: nextMeta,
|
|
556
|
+
observed: observedGithubPr,
|
|
557
|
+
at: now,
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
const nextAutoSummary = renderPrAutoSummary({
|
|
561
|
+
updatedAt: nextMeta.updated_at,
|
|
562
|
+
branch,
|
|
563
|
+
headSha: nextMeta.head_sha ?? renderedHeadSha ?? headSha,
|
|
564
|
+
diffstat,
|
|
565
|
+
});
|
|
566
|
+
const nextReview = renderPrReviewDocument({
|
|
567
|
+
task,
|
|
568
|
+
createdAt,
|
|
569
|
+
branch,
|
|
570
|
+
handoffNotes,
|
|
571
|
+
autoSummary: nextAutoSummary,
|
|
572
|
+
});
|
|
573
|
+
const githubTitle = buildGithubPrTitle(task);
|
|
574
|
+
const githubBody = renderGithubPrBody({
|
|
575
|
+
task,
|
|
576
|
+
handoffNotes,
|
|
577
|
+
autoSummary: nextAutoSummary,
|
|
578
|
+
});
|
|
579
|
+
await writeTextIfChanged(diffstatPath, diffstat ? `${diffstat}\n` : "");
|
|
580
|
+
await writeTextIfChanged(reviewPath, nextReview);
|
|
581
|
+
await writeTextIfChanged(githubTitlePath, `${githubTitle}\n`);
|
|
582
|
+
await writeTextIfChanged(githubBodyPath, githubBody);
|
|
583
|
+
await writeJsonStableIfChanged(metaPath, nextMeta);
|
|
584
|
+
return { meta: nextMeta, prDir, resolved };
|
|
585
|
+
}
|
|
586
|
+
finally {
|
|
587
|
+
await restoreIncidentRegistryIfNeeded({
|
|
588
|
+
gitRoot: resolved.gitRoot,
|
|
589
|
+
previousText: incidentsTextBefore,
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
catch (err) {
|
|
594
|
+
if (err instanceof CliError)
|
|
595
|
+
throw err;
|
|
596
|
+
throw mapBackendError(err, { command: "pr sync", root: opts.rootOverride ?? null });
|
|
597
|
+
}
|
|
598
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"note.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/note.ts"],"names":[],"mappings":"AAUA,OAAO,
|
|
1
|
+
{"version":3,"file":"note.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/note.ts"],"names":[],"mappings":"AAUA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AAgBnC,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,MAAM,CAAC,CAmFlB"}
|
package/dist/commands/pr/note.js
CHANGED
|
@@ -6,9 +6,11 @@ import { exitCodeForError } from "../../cli/exit-codes.js";
|
|
|
6
6
|
import { fileExists } from "../../cli/fs-utils.js";
|
|
7
7
|
import { createCliEmitter, workflowModeMessage } from "../../cli/output.js";
|
|
8
8
|
import { CliError } from "../../shared/errors.js";
|
|
9
|
-
import { loadCommandContext } from "../shared/task-backend.js";
|
|
9
|
+
import { loadBackendTask, loadCommandContext, } from "../shared/task-backend.js";
|
|
10
10
|
import { resolvePrPaths } from "./internal/pr-paths.js";
|
|
11
|
-
import {
|
|
11
|
+
import { appendPrHandoffNote, buildPrHandoffNote, readPrHandoffNotes, } from "./internal/note-store.js";
|
|
12
|
+
import { buildGithubPrTitle, extractAutoSummaryBlock, renderGithubPrBody, renderPrReviewDocument, } from "./internal/review-template.js";
|
|
13
|
+
import { parsePrMeta } from "../shared/pr-meta.js";
|
|
12
14
|
export async function cmdPrNote(opts) {
|
|
13
15
|
try {
|
|
14
16
|
const output = createCliEmitter();
|
|
@@ -30,7 +32,13 @@ export async function cmdPrNote(opts) {
|
|
|
30
32
|
}
|
|
31
33
|
const ctx = opts.ctx ??
|
|
32
34
|
(await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
|
|
33
|
-
const {
|
|
35
|
+
const { task } = await loadBackendTask({
|
|
36
|
+
ctx,
|
|
37
|
+
cwd: opts.cwd,
|
|
38
|
+
rootOverride: opts.rootOverride,
|
|
39
|
+
taskId: opts.taskId,
|
|
40
|
+
});
|
|
41
|
+
const { config, reviewPath, notesPath, githubTitlePath, githubBodyPath, metaPath, resolved } = await resolvePrPaths({ ...opts, ctx });
|
|
34
42
|
if (config.workflow_mode !== "branch_pr") {
|
|
35
43
|
throw new CliError({
|
|
36
44
|
exitCode: exitCodeForError("E_USAGE"),
|
|
@@ -47,8 +55,33 @@ export async function cmdPrNote(opts) {
|
|
|
47
55
|
});
|
|
48
56
|
}
|
|
49
57
|
const review = await readFile(reviewPath, "utf8");
|
|
50
|
-
const
|
|
58
|
+
const meta = parsePrMeta(await readFile(metaPath, "utf8"), opts.taskId);
|
|
59
|
+
await appendPrHandoffNote({
|
|
60
|
+
notesPath,
|
|
61
|
+
note: buildPrHandoffNote({
|
|
62
|
+
createdAt: new Date().toISOString(),
|
|
63
|
+
author,
|
|
64
|
+
body,
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
const handoffNotes = await readPrHandoffNotes(notesPath);
|
|
68
|
+
const autoSummary = extractAutoSummaryBlock(review) ?? "";
|
|
69
|
+
const updated = renderPrReviewDocument({
|
|
70
|
+
task,
|
|
71
|
+
createdAt: meta.created_at ?? "",
|
|
72
|
+
branch: meta.branch ?? "",
|
|
73
|
+
handoffNotes,
|
|
74
|
+
autoSummary,
|
|
75
|
+
});
|
|
76
|
+
const githubTitle = buildGithubPrTitle(task);
|
|
77
|
+
const githubBody = renderGithubPrBody({
|
|
78
|
+
task,
|
|
79
|
+
handoffNotes,
|
|
80
|
+
autoSummary,
|
|
81
|
+
});
|
|
51
82
|
await atomicWriteFile(reviewPath, updated, "utf8");
|
|
83
|
+
await atomicWriteFile(githubTitlePath, `${githubTitle}\n`, "utf8");
|
|
84
|
+
await atomicWriteFile(githubBodyPath, githubBody, "utf8");
|
|
52
85
|
output.success("pr note", opts.taskId);
|
|
53
86
|
return 0;
|
|
54
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/open.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/open.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAiBhE,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CAiClB"}
|