agentplane 0.3.12 → 0.3.14
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/RUNNER.md +1 -1
- package/assets/agents/ORCHESTRATOR.json +1 -1
- package/assets/agents/SKILL_EXTRACTOR.json +31 -0
- package/assets/codex-plugin/assets/header.png +0 -0
- package/assets/codex-plugin/assets/icon.svg +1 -0
- package/assets/codex-plugin/assets/logo.svg +1 -0
- package/assets/codex-plugin/skills/agentplane/SKILL.md +35 -0
- package/assets/framework.manifest.json +7 -0
- package/assets/policy/governance.md +4 -2
- package/assets/policy/incidents.md +4 -19
- package/assets/policy/workflow.branch_pr.md +10 -5
- package/assets/policy/workflow.release.md +5 -2
- package/dist/.build-manifest.json +409 -219
- package/dist/cli/exit-codes.d.ts.map +1 -1
- package/dist/cli/exit-codes.js +1 -0
- package/dist/cli/output.d.ts +29 -0
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +33 -0
- package/dist/cli/reason-codes.d.ts +1 -1
- package/dist/cli/reason-codes.d.ts.map +1 -1
- package/dist/cli/reason-codes.js +12 -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 +36 -78
- package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/lifecycle.js +4 -12
- 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 +27 -31
- package/dist/cli/run-cli/command-catalog/shared.d.ts +9 -6
- package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/shared.js +23 -6
- package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/task.js +6 -18
- 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/codex.d.ts +14 -0
- package/dist/cli/run-cli/commands/codex.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/codex.js +100 -0
- package/dist/cli/run-cli/commands/core.d.ts +1 -0
- package/dist/cli/run-cli/commands/core.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/core.js +1 -0
- package/dist/cli/run-cli/commands/init/recipes.d.ts +9 -1
- package/dist/cli/run-cli/commands/init/recipes.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/recipes.js +33 -22
- package/dist/cli/run-cli/commands/init.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init.js +26 -21
- package/dist/cli/run-cli/error-guidance.js +20 -0
- package/dist/cli/run-cli.js +1 -1
- package/dist/cli/run-cli.test-helpers.d.ts +1 -74
- package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
- package/dist/cli/run-cli.test-helpers.js +1 -766
- package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
- package/dist/commands/branch/cleanup-merged.js +5 -9
- package/dist/commands/branch/work-start.command.d.ts.map +1 -1
- package/dist/commands/branch/work-start.command.js +1 -0
- package/dist/commands/codex/plugin-install.d.ts +26 -0
- package/dist/commands/codex/plugin-install.d.ts.map +1 -0
- package/dist/commands/codex/plugin-install.js +209 -0
- package/dist/commands/commit.spec.d.ts.map +1 -1
- package/dist/commands/commit.spec.js +2 -0
- package/dist/commands/doctor/branch-pr.d.ts +1 -1
- package/dist/commands/doctor/branch-pr.d.ts.map +1 -1
- package/dist/commands/doctor/branch-pr.js +5 -2
- package/dist/commands/guard/impl/commands.d.ts.map +1 -1
- package/dist/commands/guard/impl/commands.js +4 -1
- package/dist/commands/guard/impl/comment-commit.d.ts.map +1 -1
- package/dist/commands/guard/impl/comment-commit.js +2 -1
- package/dist/commands/guard/impl/env.d.ts +6 -0
- package/dist/commands/guard/impl/env.d.ts.map +1 -1
- package/dist/commands/guard/impl/env.js +41 -0
- package/dist/commands/pr/integrate/cmd.d.ts.map +1 -1
- package/dist/commands/pr/integrate/cmd.js +81 -5
- package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/prepare.js +38 -7
- package/dist/commands/pr/internal/auto-commit.d.ts.map +1 -1
- package/dist/commands/pr/internal/auto-commit.js +13 -7
- package/dist/commands/pr/internal/sync-branch.d.ts +36 -0
- package/dist/commands/pr/internal/sync-branch.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-branch.js +113 -0
- package/dist/commands/pr/internal/sync-github.d.ts +28 -0
- package/dist/commands/pr/internal/sync-github.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-github.js +178 -0
- package/dist/commands/pr/internal/sync-model.d.ts +36 -0
- package/dist/commands/pr/internal/sync-model.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-model.js +1 -0
- package/dist/commands/pr/internal/sync-open-step.d.ts +10 -0
- package/dist/commands/pr/internal/sync-open-step.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-open-step.js +128 -0
- package/dist/commands/pr/internal/sync-support.d.ts +7 -0
- package/dist/commands/pr/internal/sync-support.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-support.js +29 -0
- package/dist/commands/pr/internal/sync-update-step.d.ts +6 -0
- package/dist/commands/pr/internal/sync-update-step.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-update-step.js +68 -0
- package/dist/commands/pr/internal/sync.d.ts +2 -6
- package/dist/commands/pr/internal/sync.d.ts.map +1 -1
- package/dist/commands/pr/internal/sync.js +83 -525
- package/dist/commands/pr/open.d.ts.map +1 -1
- package/dist/commands/pr/open.js +62 -7
- package/dist/commands/pr/pr.command.d.ts.map +1 -1
- package/dist/commands/pr/pr.command.js +7 -2
- package/dist/commands/recipes/active.command.d.ts +7 -0
- package/dist/commands/recipes/active.command.d.ts.map +1 -0
- package/dist/commands/recipes/active.command.js +12 -0
- package/dist/commands/recipes/add.command.d.ts +8 -0
- package/dist/commands/recipes/add.command.d.ts.map +1 -0
- package/dist/commands/recipes/add.command.js +33 -0
- package/dist/commands/recipes/detach.command.d.ts +7 -0
- package/dist/commands/recipes/detach.command.d.ts.map +1 -0
- package/dist/commands/recipes/detach.command.js +19 -0
- package/dist/commands/recipes/disable.command.d.ts +7 -0
- package/dist/commands/recipes/disable.command.d.ts.map +1 -0
- package/dist/commands/recipes/disable.command.js +10 -0
- package/dist/commands/recipes/enable.command.d.ts +7 -0
- package/dist/commands/recipes/enable.command.d.ts.map +1 -0
- package/dist/commands/recipes/enable.command.js +10 -0
- package/dist/commands/recipes/explain-active.command.d.ts +5 -0
- package/dist/commands/recipes/explain-active.command.d.ts.map +1 -0
- package/dist/commands/recipes/explain-active.command.js +11 -0
- package/dist/commands/recipes/explain.command.d.ts.map +1 -1
- package/dist/commands/recipes/explain.command.js +4 -2
- package/dist/commands/recipes/impl/apply.d.ts +1 -1
- package/dist/commands/recipes/impl/apply.d.ts.map +1 -1
- package/dist/commands/recipes/impl/apply.js +34 -16
- package/dist/commands/recipes/impl/commands/active.d.ts +6 -0
- package/dist/commands/recipes/impl/commands/active.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/active.js +47 -0
- package/dist/commands/recipes/impl/commands/add.d.ts +8 -0
- package/dist/commands/recipes/impl/commands/add.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/add.js +105 -0
- package/dist/commands/recipes/impl/commands/detach.d.ts +6 -0
- package/dist/commands/recipes/impl/commands/detach.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/detach.js +99 -0
- package/dist/commands/recipes/impl/commands/disable.d.ts +6 -0
- package/dist/commands/recipes/impl/commands/disable.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/disable.js +23 -0
- package/dist/commands/recipes/impl/commands/enable.d.ts +6 -0
- package/dist/commands/recipes/impl/commands/enable.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/enable.js +41 -0
- package/dist/commands/recipes/impl/commands/explain-active.d.ts +5 -0
- package/dist/commands/recipes/impl/commands/explain-active.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/explain-active.js +20 -0
- package/dist/commands/recipes/impl/commands/explain.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/explain.js +83 -36
- package/dist/commands/recipes/impl/commands/info.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/info.js +39 -22
- package/dist/commands/recipes/impl/commands/install.d.ts +1 -1
- package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/install.js +35 -42
- package/dist/commands/recipes/impl/commands/list-remote.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/list-remote.js +2 -3
- package/dist/commands/recipes/impl/commands/list.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/list.js +13 -12
- package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/remove.js +12 -2
- package/dist/commands/recipes/impl/commands/update.d.ts +7 -0
- package/dist/commands/recipes/impl/commands/update.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/update.js +107 -0
- package/dist/commands/recipes/impl/commands.d.ts +7 -0
- package/dist/commands/recipes/impl/commands.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands.js +7 -0
- package/dist/commands/recipes/impl/constants.d.ts +1 -14
- package/dist/commands/recipes/impl/constants.d.ts.map +1 -1
- package/dist/commands/recipes/impl/constants.js +1 -18
- package/dist/commands/recipes/impl/index.d.ts +1 -1
- package/dist/commands/recipes/impl/index.d.ts.map +1 -1
- package/dist/commands/recipes/impl/installed-recipes.d.ts +1 -1
- package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -1
- package/dist/commands/recipes/impl/installed-recipes.js +1 -2
- package/dist/commands/recipes/impl/mutation-transaction.d.ts +7 -0
- package/dist/commands/recipes/impl/mutation-transaction.d.ts.map +1 -0
- package/dist/commands/recipes/impl/mutation-transaction.js +47 -0
- package/dist/commands/recipes/impl/overlay-project.d.ts +48 -0
- package/dist/commands/recipes/impl/overlay-project.d.ts.map +1 -0
- package/dist/commands/recipes/impl/overlay-project.js +320 -0
- package/dist/commands/recipes/impl/paths.d.ts +17 -2
- package/dist/commands/recipes/impl/paths.d.ts.map +1 -1
- package/dist/commands/recipes/impl/paths.js +20 -5
- package/dist/commands/recipes/impl/project-installed-recipes.d.ts +5 -4
- package/dist/commands/recipes/impl/project-installed-recipes.d.ts.map +1 -1
- package/dist/commands/recipes/impl/project-installed-recipes.js +34 -76
- package/dist/commands/recipes/impl/project-recipe-state.d.ts +18 -0
- package/dist/commands/recipes/impl/project-recipe-state.d.ts.map +1 -0
- package/dist/commands/recipes/impl/project-recipe-state.js +94 -0
- package/dist/commands/recipes/impl/project-registry.d.ts +24 -0
- package/dist/commands/recipes/impl/project-registry.d.ts.map +1 -0
- package/dist/commands/recipes/impl/project-registry.js +124 -0
- package/dist/commands/recipes/impl/resolver.d.ts +1 -1
- package/dist/commands/recipes/impl/resolver.d.ts.map +1 -1
- package/dist/commands/recipes/impl/resolver.js +6 -4
- package/dist/commands/recipes/impl/types.d.ts +1 -240
- package/dist/commands/recipes/impl/types.d.ts.map +1 -1
- package/dist/commands/recipes/impl/version.d.ts +5 -0
- package/dist/commands/recipes/impl/version.d.ts.map +1 -0
- package/dist/commands/recipes/impl/version.js +9 -0
- package/dist/commands/recipes/info.command.js +2 -2
- package/dist/commands/recipes/install.spec.js +4 -4
- package/dist/commands/recipes/list.command.js +4 -4
- package/dist/commands/recipes/remove.command.js +2 -2
- package/dist/commands/recipes/update.command.d.ts +8 -0
- package/dist/commands/recipes/update.command.d.ts.map +1 -0
- package/dist/commands/recipes/update.command.js +35 -0
- package/dist/commands/recipes.d.ts +10 -6
- package/dist/commands/recipes.d.ts.map +1 -1
- package/dist/commands/recipes.js +8 -5
- package/dist/commands/recipes.test-helpers.d.ts +3 -3
- package/dist/commands/recipes.test-helpers.d.ts.map +1 -1
- package/dist/commands/recipes.test-helpers.js +105 -15
- package/dist/commands/release/apply.command.d.ts +1 -1
- package/dist/commands/release/apply.command.d.ts.map +1 -1
- package/dist/commands/release/apply.command.js +15 -379
- package/dist/commands/release/apply.mutation.d.ts +1 -0
- package/dist/commands/release/apply.mutation.d.ts.map +1 -1
- package/dist/commands/release/apply.mutation.js +24 -1
- package/dist/commands/release/apply.pipeline.d.ts +22 -0
- package/dist/commands/release/apply.pipeline.d.ts.map +1 -0
- package/dist/commands/release/apply.pipeline.js +371 -0
- package/dist/commands/release/apply.preflight.d.ts +2 -0
- package/dist/commands/release/apply.preflight.d.ts.map +1 -1
- package/dist/commands/release/apply.preflight.js +13 -4
- package/dist/commands/release/apply.types.d.ts +27 -0
- package/dist/commands/release/apply.types.d.ts.map +1 -1
- package/dist/commands/release.test-helpers.d.ts +4 -0
- package/dist/commands/release.test-helpers.d.ts.map +1 -1
- package/dist/commands/release.test-helpers.js +7 -0
- package/dist/commands/scenario/execute.command.js +4 -4
- package/dist/commands/scenario/impl/commands.js +4 -4
- package/dist/commands/scenario/info.command.js +4 -4
- package/dist/commands/scenario/list.command.js +3 -3
- package/dist/commands/scenario/run.command.js +5 -5
- package/dist/commands/scenario/scenario.command.js +7 -7
- package/dist/commands/shared/reconcile-check.d.ts.map +1 -1
- package/dist/commands/shared/reconcile-check.js +2 -2
- package/dist/commands/shared/task-backend.d.ts +6 -1
- package/dist/commands/shared/task-backend.d.ts.map +1 -1
- package/dist/commands/shared/task-backend.js +34 -2
- package/dist/commands/shared/task-handoff.d.ts +2 -1
- package/dist/commands/shared/task-handoff.d.ts.map +1 -1
- package/dist/commands/shared/task-handoff.js +15 -0
- package/dist/commands/shared/task-mutation.d.ts.map +1 -1
- package/dist/commands/shared/task-mutation.js +4 -4
- package/dist/commands/shared/task-store/intents.d.ts +34 -0
- package/dist/commands/shared/task-store/intents.d.ts.map +1 -0
- package/dist/commands/shared/task-store/intents.js +265 -0
- package/dist/commands/shared/task-store/readme.d.ts +28 -0
- package/dist/commands/shared/task-store/readme.d.ts.map +1 -0
- package/dist/commands/shared/task-store/readme.js +125 -0
- package/dist/commands/shared/task-store/store.d.ts +26 -0
- package/dist/commands/shared/task-store/store.d.ts.map +1 -0
- package/dist/commands/shared/task-store/store.js +105 -0
- package/dist/commands/shared/task-store/types.d.ts +94 -0
- package/dist/commands/shared/task-store/types.d.ts.map +1 -0
- package/dist/commands/shared/task-store/types.js +1 -0
- package/dist/commands/shared/task-store.d.ts +3 -109
- package/dist/commands/shared/task-store.d.ts.map +1 -1
- package/dist/commands/shared/task-store.js +2 -493
- package/dist/commands/task/block.d.ts.map +1 -1
- package/dist/commands/task/block.js +7 -2
- package/dist/commands/task/comment.d.ts.map +1 -1
- package/dist/commands/task/comment.js +7 -2
- package/dist/commands/task/finish-shared.d.ts.map +1 -1
- package/dist/commands/task/finish-shared.js +3 -3
- package/dist/commands/task/finish.d.ts.map +1 -1
- package/dist/commands/task/finish.js +102 -15
- package/dist/commands/task/handoff-show.command.d.ts.map +1 -1
- package/dist/commands/task/handoff-show.command.js +24 -0
- package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
- package/dist/commands/task/hosted-merge-sync.js +9 -4
- package/dist/commands/task/list.run.d.ts.map +1 -1
- package/dist/commands/task/list.run.js +14 -4
- package/dist/commands/task/new.command.d.ts.map +1 -1
- package/dist/commands/task/new.command.js +16 -2
- package/dist/commands/task/new.js +2 -2
- package/dist/commands/task/show.d.ts.map +1 -1
- package/dist/commands/task/show.js +3 -3
- package/dist/commands/task/update.d.ts.map +1 -1
- package/dist/commands/task/update.js +11 -3
- package/dist/runner/adapters/codex.d.ts.map +1 -1
- package/dist/runner/adapters/codex.js +3 -33
- package/dist/runner/adapters/custom.d.ts.map +1 -1
- package/dist/runner/adapters/custom.js +3 -30
- package/dist/runner/adapters/runtime-shared.d.ts +14 -0
- package/dist/runner/adapters/runtime-shared.d.ts.map +1 -0
- package/dist/runner/adapters/runtime-shared.js +36 -0
- package/dist/runner/context/base-prompt-sources.d.ts +30 -0
- package/dist/runner/context/base-prompt-sources.d.ts.map +1 -0
- package/dist/runner/context/base-prompt-sources.js +144 -0
- package/dist/runner/context/base-prompts.d.ts +5 -23
- package/dist/runner/context/base-prompts.d.ts.map +1 -1
- package/dist/runner/context/base-prompts.js +10 -358
- package/dist/runner/context/overlay-prompt-blocks.d.ts +7 -0
- package/dist/runner/context/overlay-prompt-blocks.d.ts.map +1 -0
- package/dist/runner/context/overlay-prompt-blocks.js +72 -0
- package/dist/runner/context/prompt-block-shared.d.ts +54 -0
- package/dist/runner/context/prompt-block-shared.d.ts.map +1 -0
- package/dist/runner/context/prompt-block-shared.js +106 -0
- package/dist/runner/context/recipe-context.d.ts +2 -1
- package/dist/runner/context/recipe-context.d.ts.map +1 -1
- package/dist/runner/context/recipe-context.js +41 -8
- package/dist/runner/context/recipe-prompt-blocks.d.ts +6 -0
- package/dist/runner/context/recipe-prompt-blocks.d.ts.map +1 -0
- package/dist/runner/context/recipe-prompt-blocks.js +143 -0
- package/dist/runner/types.d.ts +4 -0
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/usecases/scenario-materialize-task.js +2 -2
- package/dist/runner/usecases/task-run-inspect.js +2 -2
- package/dist/runner/usecases/task-run-lifecycle-shared.js +2 -2
- package/dist/runner/usecases/task-run.d.ts.map +1 -1
- package/dist/runner/usecases/task-run.js +6 -3
- package/dist/runtime/behavior/resolve.d.ts +2 -1
- package/dist/runtime/behavior/resolve.d.ts.map +1 -1
- package/dist/runtime/behavior/resolve.js +25 -5
- package/dist/runtime/behavior/types.d.ts +1 -0
- package/dist/runtime/behavior/types.d.ts.map +1 -1
- package/dist/runtime/capabilities/recipe.d.ts +2 -1
- package/dist/runtime/capabilities/recipe.d.ts.map +1 -1
- package/dist/runtime/capabilities/recipe.js +88 -28
- package/dist/runtime/execution-context.d.ts +63 -0
- package/dist/runtime/execution-context.d.ts.map +1 -0
- package/dist/{usecases/context/resolve-context.js → runtime/execution-context.js} +23 -26
- package/dist/runtime/incidents/advice-strategy.d.ts +15 -0
- package/dist/runtime/incidents/advice-strategy.d.ts.map +1 -0
- package/dist/runtime/incidents/advice-strategy.js +54 -0
- package/dist/runtime/incidents/plan-strategy.d.ts +9 -0
- package/dist/runtime/incidents/plan-strategy.d.ts.map +1 -0
- package/dist/runtime/incidents/plan-strategy.js +205 -0
- package/dist/runtime/incidents/registry-strategy.d.ts +6 -0
- package/dist/runtime/incidents/registry-strategy.d.ts.map +1 -0
- package/dist/runtime/incidents/registry-strategy.js +280 -0
- package/dist/runtime/incidents/resolve.d.ts +3 -25
- package/dist/runtime/incidents/resolve.d.ts.map +1 -1
- package/dist/runtime/incidents/resolve.js +3 -683
- package/dist/runtime/incidents/shared.d.ts +34 -0
- package/dist/runtime/incidents/shared.d.ts.map +1 -0
- package/dist/runtime/incidents/shared.js +171 -0
- package/dist/shared/errors.d.ts +1 -1
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/runtime-source.d.ts.map +1 -1
- package/dist/shared/runtime-source.js +8 -3
- package/dist/testing/cli-harness/recipe-archives.d.ts +28 -0
- package/dist/testing/cli-harness/recipe-archives.d.ts.map +1 -0
- package/dist/testing/cli-harness/recipe-archives.js +374 -0
- package/dist/testing/cli-harness/stdio.d.ts +26 -0
- package/dist/testing/cli-harness/stdio.d.ts.map +1 -0
- package/dist/testing/cli-harness/stdio.js +84 -0
- package/dist/testing/cli-harness.d.ts +25 -0
- package/dist/testing/cli-harness.d.ts.map +1 -0
- package/dist/testing/cli-harness.js +313 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +1 -0
- package/package.json +7 -3
- package/dist/cli/recipes-bundled.d.ts +0 -10
- package/dist/cli/recipes-bundled.d.ts.map +0 -1
- package/dist/cli/recipes-bundled.js +0 -36
- package/dist/commands/recipes/impl/manifest.d.ts +0 -4
- package/dist/commands/recipes/impl/manifest.d.ts.map +0 -1
- package/dist/commands/recipes/impl/manifest.js +0 -229
- package/dist/commands/recipes/impl/normalize.d.ts +0 -8
- package/dist/commands/recipes/impl/normalize.d.ts.map +0 -1
- package/dist/commands/recipes/impl/normalize.js +0 -54
- package/dist/commands/recipes/impl/scenario.d.ts +0 -16
- package/dist/commands/recipes/impl/scenario.d.ts.map +0 -1
- package/dist/commands/recipes/impl/scenario.js +0 -262
- package/dist/recipes/bundled-recipes.d.ts +0 -17
- package/dist/recipes/bundled-recipes.d.ts.map +0 -1
- package/dist/recipes/bundled-recipes.js +0 -15
- package/dist/usecases/context/resolve-context.d.ts +0 -68
- package/dist/usecases/context/resolve-context.d.ts.map +0 -1
- package/dist/usecases/task/task-list-usecase.d.ts +0 -9
- package/dist/usecases/task/task-list-usecase.d.ts.map +0 -1
- package/dist/usecases/task/task-list-usecase.js +0 -17
- package/dist/usecases/task/task-new-usecase.d.ts +0 -9
- package/dist/usecases/task/task-new-usecase.d.ts.map +0 -1
- package/dist/usecases/task/task-new-usecase.js +0 -17
|
@@ -1,333 +1,78 @@
|
|
|
1
|
-
import { mkdir, readFile
|
|
1
|
+
import { mkdir, readFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { resolveBaseBranch } from "@agentplaneorg/core";
|
|
4
4
|
import { mapBackendError } from "../../../cli/error-map.js";
|
|
5
5
|
import { exitCodeForError } from "../../../cli/exit-codes.js";
|
|
6
6
|
import { fileExists } from "../../../cli/fs-utils.js";
|
|
7
7
|
import { workflowModeMessage } from "../../../cli/output.js";
|
|
8
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 { gitBranchUpstream, 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
9
|
import { INCIDENTS_POLICY_PATH } from "../../incidents/shared.js";
|
|
16
|
-
import {
|
|
10
|
+
import { resolvePrArtifactHeadSha, parsePrMeta } from "../../shared/pr-meta.js";
|
|
17
11
|
import { isTaskLocalOnlyAdvance } from "../../shared/task-local-freshness.js";
|
|
18
12
|
import { loadBackendTask, loadCommandContext, } from "../../shared/task-backend.js";
|
|
19
13
|
import { resolvePrPaths } from "./pr-paths.js";
|
|
20
14
|
import { readPrHandoffNotes } from "./note-store.js";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
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 shouldPersistObservedGithubPrMeta(observed) {
|
|
151
|
-
if (!observed)
|
|
152
|
-
return false;
|
|
153
|
-
return observed.status === "MERGED";
|
|
154
|
-
}
|
|
155
|
-
function taskPrArtifactRefreshMessage(taskId) {
|
|
156
|
-
return `📝 ${extractTaskSuffix(taskId)} task: refresh PR artifacts`;
|
|
157
|
-
}
|
|
158
|
-
async function resolveRenderableBranchHead(opts) {
|
|
159
|
-
const branchHeadSha = await resolveBranchHeadSha({
|
|
160
|
-
gitRoot: opts.gitRoot,
|
|
15
|
+
import { currentBranchMatchesTask, resolvePrSyncBranch, resolveRenderableBranchHead, } from "./sync-branch.js";
|
|
16
|
+
import { runPrOpenSync } from "./sync-open-step.js";
|
|
17
|
+
import { nowIso, readTextIfExists, restoreIncidentRegistryIfNeeded } from "./sync-support.js";
|
|
18
|
+
import { runPrUpdateSync } from "./sync-update-step.js";
|
|
19
|
+
async function buildPrSyncCommonState(opts) {
|
|
20
|
+
const handoffNotes = await readPrHandoffNotes(opts.notesPath);
|
|
21
|
+
const now = nowIso();
|
|
22
|
+
const createdAt = opts.existingMeta?.created_at ?? now;
|
|
23
|
+
const { headSha, artifactRefresh } = await resolveRenderableBranchHead({
|
|
24
|
+
gitRoot: opts.resolved.gitRoot,
|
|
25
|
+
taskId: opts.task.id,
|
|
161
26
|
branch: opts.branch,
|
|
162
27
|
});
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
function formatUnpublishedRemoteHeadReason(branch) {
|
|
181
|
-
return (`task branch ${branch} is not yet published on origin; push it with ` +
|
|
182
|
-
`\`git push -u origin ${branch}\` and rerun \`agentplane pr open\``);
|
|
183
|
-
}
|
|
184
|
-
function isMissingRemoteHeadCreateError(err) {
|
|
185
|
-
const text = normalizeGhTransportError(err);
|
|
186
|
-
if (!/\b422\b/i.test(text))
|
|
187
|
-
return false;
|
|
188
|
-
return (/head sha/i.test(text) ||
|
|
189
|
-
/head ref/i.test(text) ||
|
|
190
|
-
/head.*must be a branch/i.test(text) ||
|
|
191
|
-
/head.*not found/i.test(text) ||
|
|
192
|
-
/field["']?\s*:\s*["']head["']/i.test(text) ||
|
|
193
|
-
/field\s+head\b/i.test(text) ||
|
|
194
|
-
/no commits between/i.test(text));
|
|
195
|
-
}
|
|
196
|
-
function summarizeGithubPrCreateFailure(err) {
|
|
197
|
-
const text = normalizeGhTransportError(err);
|
|
198
|
-
if (err?.code === "ENOENT") {
|
|
199
|
-
return "gh CLI is unavailable";
|
|
200
|
-
}
|
|
201
|
-
if (/authentication required/i.test(text) ||
|
|
202
|
-
/not logged into github/i.test(text) ||
|
|
203
|
-
/bad credentials/i.test(text) ||
|
|
204
|
-
/permission denied/i.test(text) ||
|
|
205
|
-
/\b401\b/i.test(text) ||
|
|
206
|
-
/\b403\b/i.test(text)) {
|
|
207
|
-
return "GitHub auth or permissions unavailable";
|
|
208
|
-
}
|
|
209
|
-
if (isTransientGhTransportError(err)) {
|
|
210
|
-
return "GitHub transport failed; retry `agentplane pr open`";
|
|
211
|
-
}
|
|
212
|
-
return "GitHub PR creation failed";
|
|
213
|
-
}
|
|
214
|
-
async function tryCreateGithubPr(opts) {
|
|
215
|
-
const repo = await resolveGithubRepoFromOrigin(opts.gitRoot);
|
|
216
|
-
if (!repo) {
|
|
217
|
-
return {
|
|
218
|
-
observed: null,
|
|
219
|
-
stagedReason: "GitHub origin repo unavailable",
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
const baseBranch = opts.baseBranch?.trim() ?? "";
|
|
223
|
-
if (!baseBranch) {
|
|
224
|
-
return {
|
|
225
|
-
observed: null,
|
|
226
|
-
stagedReason: "base branch unresolved",
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
try {
|
|
230
|
-
const { stdout } = await withGhTransportRetry(() => execFileAsync("gh", [
|
|
231
|
-
"api",
|
|
232
|
-
`repos/${repo}/pulls`,
|
|
233
|
-
"-X",
|
|
234
|
-
"POST",
|
|
235
|
-
"-f",
|
|
236
|
-
`title=${opts.title}`,
|
|
237
|
-
"-f",
|
|
238
|
-
`body=${opts.body}`,
|
|
239
|
-
"-f",
|
|
240
|
-
`head=${opts.branch}`,
|
|
241
|
-
"-f",
|
|
242
|
-
`base=${baseBranch}`,
|
|
243
|
-
], {
|
|
244
|
-
cwd: opts.gitRoot,
|
|
245
|
-
env: ghEnv(),
|
|
246
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
247
|
-
}), { label: `running gh api repos/${repo}/pulls` });
|
|
248
|
-
return {
|
|
249
|
-
observed: normalizeObservedGithubPr(JSON.parse(stdout)),
|
|
250
|
-
stagedReason: null,
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
catch (err) {
|
|
254
|
-
if (isMissingRemoteHeadCreateError(err)) {
|
|
255
|
-
return {
|
|
256
|
-
observed: null,
|
|
257
|
-
stagedReason: formatUnpublishedRemoteHeadReason(opts.branch),
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
return {
|
|
261
|
-
observed: null,
|
|
262
|
-
stagedReason: summarizeGithubPrCreateFailure(err),
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
async function resolveBranchHeadSha(opts) {
|
|
267
|
-
try {
|
|
268
|
-
const { stdout } = await execFileAsync("git", ["rev-parse", opts.branch], {
|
|
269
|
-
cwd: opts.gitRoot,
|
|
270
|
-
env: gitEnv(),
|
|
28
|
+
const preservePreviousHead = Boolean(opts.existingMeta?.head_sha) &&
|
|
29
|
+
Boolean(headSha) &&
|
|
30
|
+
(await isTaskLocalOnlyAdvance({
|
|
31
|
+
gitRoot: opts.resolved.gitRoot,
|
|
32
|
+
workflowDir: opts.workflowDir,
|
|
33
|
+
tasksPath: opts.tasksPath,
|
|
34
|
+
taskId: opts.task.id,
|
|
35
|
+
fromRef: opts.existingMeta?.head_sha ?? null,
|
|
36
|
+
toRef: headSha,
|
|
37
|
+
}));
|
|
38
|
+
const renderedHeadSha = artifactRefresh
|
|
39
|
+
? (opts.existingMeta?.head_sha ?? undefined)
|
|
40
|
+
: resolvePrArtifactHeadSha({
|
|
41
|
+
previousHeadSha: opts.existingMeta?.head_sha ?? null,
|
|
42
|
+
currentHeadSha: headSha,
|
|
43
|
+
preservePrevious: preservePreviousHead,
|
|
271
44
|
});
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
45
|
+
const preservedRenderUpdatedAt = opts.existingMeta &&
|
|
46
|
+
(opts.existingMeta.branch ?? null) === opts.branch &&
|
|
47
|
+
(opts.existingMeta.base ?? null) === (opts.baseBranch ?? null) &&
|
|
48
|
+
(opts.existingMeta.head_sha ?? null) === (renderedHeadSha ?? null)
|
|
49
|
+
? opts.existingMeta.updated_at
|
|
50
|
+
: null;
|
|
51
|
+
const renderUpdatedAt = preservedRenderUpdatedAt ?? now;
|
|
52
|
+
return {
|
|
53
|
+
task: opts.task,
|
|
54
|
+
resolved: opts.resolved,
|
|
55
|
+
workflowDir: opts.workflowDir,
|
|
56
|
+
tasksPath: opts.tasksPath,
|
|
57
|
+
prDir: opts.prDir,
|
|
58
|
+
metaPath: opts.metaPath,
|
|
59
|
+
diffstatPath: opts.diffstatPath,
|
|
60
|
+
notesPath: opts.notesPath,
|
|
61
|
+
verifyLogPath: opts.verifyLogPath,
|
|
62
|
+
reviewPath: opts.reviewPath,
|
|
63
|
+
githubTitlePath: opts.githubTitlePath,
|
|
64
|
+
githubBodyPath: opts.githubBodyPath,
|
|
65
|
+
existingMeta: opts.existingMeta,
|
|
66
|
+
handoffNotes,
|
|
67
|
+
now,
|
|
68
|
+
createdAt,
|
|
69
|
+
branch: opts.branch,
|
|
283
70
|
baseBranch: opts.baseBranch,
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
catch (err) {
|
|
291
|
-
if (!isUnknownRevisionError(err))
|
|
292
|
-
throw err;
|
|
293
|
-
return "";
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
async function resolvePrDiffBaseRef(opts) {
|
|
297
|
-
const upstreamRef = await gitBranchUpstream(opts.gitRoot, opts.baseBranch);
|
|
298
|
-
const candidate = upstreamRef?.trim() ?? "";
|
|
299
|
-
if (!candidate)
|
|
300
|
-
return opts.baseBranch;
|
|
301
|
-
try {
|
|
302
|
-
const { stdout } = await execFileAsync("git", ["rev-parse", "--verify", candidate], {
|
|
303
|
-
cwd: opts.gitRoot,
|
|
304
|
-
env: gitEnv(),
|
|
305
|
-
});
|
|
306
|
-
return stdout.trim() ? candidate : opts.baseBranch;
|
|
307
|
-
}
|
|
308
|
-
catch (err) {
|
|
309
|
-
if (!isUnknownRevisionError(err))
|
|
310
|
-
throw err;
|
|
311
|
-
return opts.baseBranch;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
async function resolvePrSyncBranch(opts) {
|
|
315
|
-
const explicitBranch = opts.branch?.trim() ?? "";
|
|
316
|
-
if (explicitBranch) {
|
|
317
|
-
return { branch: explicitBranch, source: "explicit" };
|
|
318
|
-
}
|
|
319
|
-
if (await fileExists(opts.metaPath)) {
|
|
320
|
-
const metaBranch = parsePrMeta(await readFile(opts.metaPath, "utf8"), opts.taskId).branch?.trim() ?? "";
|
|
321
|
-
if (metaBranch) {
|
|
322
|
-
return { branch: metaBranch, source: "meta" };
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
const currentBranchValue = await gitCurrentBranch(opts.resolved.gitRoot);
|
|
326
|
-
const currentBranch = currentBranchValue.trim();
|
|
327
|
-
if (currentBranch) {
|
|
328
|
-
return { branch: currentBranch, source: "current" };
|
|
329
|
-
}
|
|
330
|
-
return { branch: null, source: "none" };
|
|
71
|
+
headSha,
|
|
72
|
+
artifactRefresh,
|
|
73
|
+
renderedHeadSha,
|
|
74
|
+
renderUpdatedAt,
|
|
75
|
+
};
|
|
331
76
|
}
|
|
332
77
|
export async function ensurePrArtifactsSynced(opts) {
|
|
333
78
|
const ctx = opts.ctx ??
|
|
@@ -336,7 +81,7 @@ export async function ensurePrArtifactsSynced(opts) {
|
|
|
336
81
|
if (config.workflow_mode !== "branch_pr")
|
|
337
82
|
return null;
|
|
338
83
|
const resolvedBranch = await resolvePrSyncBranch({
|
|
339
|
-
resolved,
|
|
84
|
+
gitRoot: resolved.gitRoot,
|
|
340
85
|
metaPath,
|
|
341
86
|
taskId: opts.taskId,
|
|
342
87
|
branch: opts.branch,
|
|
@@ -345,7 +90,7 @@ export async function ensurePrArtifactsSynced(opts) {
|
|
|
345
90
|
if (!branch)
|
|
346
91
|
return null;
|
|
347
92
|
if (resolvedBranch.source === "current" &&
|
|
348
|
-
|
|
93
|
+
!currentBranchMatchesTask(config.branch.task_prefix, branch, opts.taskId)) {
|
|
349
94
|
return null;
|
|
350
95
|
}
|
|
351
96
|
const baseBranch = await resolveBaseBranch({
|
|
@@ -398,7 +143,7 @@ export async function syncPrArtifacts(opts) {
|
|
|
398
143
|
});
|
|
399
144
|
}
|
|
400
145
|
const resolvedBranch = await resolvePrSyncBranch({
|
|
401
|
-
resolved,
|
|
146
|
+
gitRoot: resolved.gitRoot,
|
|
402
147
|
metaPath,
|
|
403
148
|
taskId: task.id,
|
|
404
149
|
branch: opts.branch,
|
|
@@ -429,226 +174,39 @@ export async function syncPrArtifacts(opts) {
|
|
|
429
174
|
const existingMeta = metaExists && (await fileExists(metaPath))
|
|
430
175
|
? parsePrMeta(await readFile(metaPath, "utf8"), task.id)
|
|
431
176
|
: null;
|
|
432
|
-
const handoffNotes = await readPrHandoffNotes(notesPath);
|
|
433
|
-
const now = nowIso();
|
|
434
|
-
const createdAt = existingMeta?.created_at ?? now;
|
|
435
177
|
const baseBranch = await resolveBaseBranch({
|
|
436
178
|
cwd: opts.cwd,
|
|
437
179
|
rootOverride: opts.rootOverride ?? null,
|
|
438
180
|
cliBaseOpt: null,
|
|
439
181
|
mode: config.workflow_mode,
|
|
440
182
|
});
|
|
441
|
-
const
|
|
442
|
-
|
|
443
|
-
|
|
183
|
+
const common = await buildPrSyncCommonState({
|
|
184
|
+
task,
|
|
185
|
+
resolved,
|
|
186
|
+
workflowDir: config.paths.workflow_dir,
|
|
187
|
+
tasksPath: config.paths.tasks_path,
|
|
188
|
+
prDir,
|
|
189
|
+
metaPath,
|
|
190
|
+
diffstatPath,
|
|
191
|
+
notesPath,
|
|
192
|
+
verifyLogPath,
|
|
193
|
+
reviewPath,
|
|
194
|
+
githubTitlePath,
|
|
195
|
+
githubBodyPath,
|
|
196
|
+
existingMeta,
|
|
444
197
|
branch,
|
|
198
|
+
baseBranch,
|
|
445
199
|
});
|
|
446
|
-
const preservePreviousHead = Boolean(existingMeta?.head_sha) &&
|
|
447
|
-
Boolean(headSha) &&
|
|
448
|
-
(await isTaskLocalOnlyAdvance({
|
|
449
|
-
gitRoot: resolved.gitRoot,
|
|
450
|
-
workflowDir: config.paths.workflow_dir,
|
|
451
|
-
tasksPath: config.paths.tasks_path,
|
|
452
|
-
taskId: task.id,
|
|
453
|
-
fromRef: existingMeta?.head_sha ?? null,
|
|
454
|
-
toRef: headSha,
|
|
455
|
-
}));
|
|
456
|
-
const renderedHeadSha = artifactRefresh
|
|
457
|
-
? (existingMeta?.head_sha ?? undefined)
|
|
458
|
-
: resolvePrArtifactHeadSha({
|
|
459
|
-
previousHeadSha: existingMeta?.head_sha ?? null,
|
|
460
|
-
currentHeadSha: headSha,
|
|
461
|
-
preservePrevious: preservePreviousHead,
|
|
462
|
-
});
|
|
463
|
-
const preservedRenderUpdatedAt = existingMeta &&
|
|
464
|
-
(existingMeta.branch ?? null) === branch &&
|
|
465
|
-
(existingMeta.base ?? null) === (baseBranch ?? null) &&
|
|
466
|
-
(existingMeta.head_sha ?? null) === (renderedHeadSha ?? null)
|
|
467
|
-
? existingMeta.updated_at
|
|
468
|
-
: null;
|
|
469
|
-
const renderUpdatedAt = preservedRenderUpdatedAt ?? now;
|
|
470
200
|
if (opts.mode === "open") {
|
|
471
201
|
const remoteMode = opts.remoteMode ?? "auto";
|
|
472
|
-
const
|
|
473
|
-
? await computePrDiffstat({
|
|
474
|
-
gitRoot: resolved.gitRoot,
|
|
475
|
-
baseBranch,
|
|
476
|
-
branch,
|
|
477
|
-
prDir,
|
|
478
|
-
})
|
|
479
|
-
: "";
|
|
480
|
-
const renderedSummaryHeadSha = artifactRefresh
|
|
481
|
-
? renderedHeadSha
|
|
482
|
-
: (renderedHeadSha ?? headSha);
|
|
483
|
-
let nextMeta = buildOpenedPrMeta({
|
|
484
|
-
taskId: task.id,
|
|
485
|
-
branch,
|
|
486
|
-
at: now,
|
|
487
|
-
previousMeta: existingMeta,
|
|
488
|
-
base: baseBranch,
|
|
489
|
-
headSha: renderedHeadSha,
|
|
490
|
-
});
|
|
491
|
-
const linkedExistingOutcome = typeof nextMeta.pr_number === "number" && nextMeta.pr_number > 0
|
|
492
|
-
? {
|
|
493
|
-
action: "linked-existing",
|
|
494
|
-
message: formatGithubPrLink(nextMeta.pr_number, nextMeta.pr_url ?? null, "linked to"),
|
|
495
|
-
}
|
|
496
|
-
: null;
|
|
497
|
-
let openOutcome;
|
|
498
|
-
const githubTitle = buildGithubPrTitle(task);
|
|
499
|
-
const githubBody = renderGithubPrBody({
|
|
500
|
-
task,
|
|
501
|
-
handoffNotes,
|
|
502
|
-
autoSummary: renderPrAutoSummary({
|
|
503
|
-
updatedAt: renderUpdatedAt,
|
|
504
|
-
branch,
|
|
505
|
-
headSha: renderedSummaryHeadSha ?? null,
|
|
506
|
-
diffstat,
|
|
507
|
-
}),
|
|
508
|
-
});
|
|
509
|
-
const observedGithubPr = await tryLookupExistingGithubPrByBranch({
|
|
510
|
-
gitRoot: resolved.gitRoot,
|
|
511
|
-
branch,
|
|
512
|
-
baseBranch,
|
|
513
|
-
});
|
|
514
|
-
if (observedGithubPr) {
|
|
515
|
-
if (shouldPersistObservedGithubPrMeta(observedGithubPr)) {
|
|
516
|
-
nextMeta = buildObservedGithubPrMeta({
|
|
517
|
-
meta: nextMeta,
|
|
518
|
-
observed: observedGithubPr,
|
|
519
|
-
at: now,
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
openOutcome = {
|
|
523
|
-
action: "linked-existing",
|
|
524
|
-
message: formatGithubPrLink(observedGithubPr.prNumber, observedGithubPr.prUrl, "linked to"),
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
else if (remoteMode === "sync-only") {
|
|
528
|
-
openOutcome = linkedExistingOutcome ?? {
|
|
529
|
-
action: "sync-only",
|
|
530
|
-
message: "local PR artifacts synced; remote PR creation skipped (--sync-only)",
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
else {
|
|
534
|
-
const createdGithubPr = await tryCreateGithubPr({
|
|
535
|
-
gitRoot: resolved.gitRoot,
|
|
536
|
-
branch,
|
|
537
|
-
baseBranch,
|
|
538
|
-
title: githubTitle,
|
|
539
|
-
body: githubBody,
|
|
540
|
-
});
|
|
541
|
-
if (createdGithubPr.observed) {
|
|
542
|
-
if (shouldPersistObservedGithubPrMeta(createdGithubPr.observed)) {
|
|
543
|
-
nextMeta = buildObservedGithubPrMeta({
|
|
544
|
-
meta: nextMeta,
|
|
545
|
-
observed: createdGithubPr.observed,
|
|
546
|
-
at: now,
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
openOutcome = {
|
|
550
|
-
action: "created",
|
|
551
|
-
message: formatGithubPrLink(createdGithubPr.observed.prNumber, createdGithubPr.observed.prUrl, "created"),
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
|
-
else {
|
|
555
|
-
openOutcome = linkedExistingOutcome ?? {
|
|
556
|
-
action: "staged",
|
|
557
|
-
message: `local PR artifacts synced; remote PR creation staged (${createdGithubPr.stagedReason ?? "remote creation unavailable"})`,
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
const nextAutoSummary = renderPrAutoSummary({
|
|
562
|
-
updatedAt: renderUpdatedAt,
|
|
563
|
-
branch,
|
|
564
|
-
headSha: renderedSummaryHeadSha ?? null,
|
|
565
|
-
diffstat,
|
|
566
|
-
});
|
|
567
|
-
const nextReview = renderPrReviewDocument({
|
|
568
|
-
task,
|
|
202
|
+
const { meta, openOutcome } = await runPrOpenSync(common, {
|
|
569
203
|
author: opts.author,
|
|
570
|
-
|
|
571
|
-
branch,
|
|
572
|
-
handoffNotes,
|
|
573
|
-
autoSummary: nextAutoSummary,
|
|
574
|
-
});
|
|
575
|
-
const nextGithubBody = renderGithubPrBody({
|
|
576
|
-
task,
|
|
577
|
-
handoffNotes,
|
|
578
|
-
autoSummary: nextAutoSummary,
|
|
579
|
-
});
|
|
580
|
-
await writeJsonStableIfChanged(metaPath, nextMeta);
|
|
581
|
-
await writeTextIfChanged(diffstatPath, diffstat ? `${diffstat}\n` : "");
|
|
582
|
-
if (!(await fileExists(notesPath))) {
|
|
583
|
-
await writeTextIfChanged(notesPath, "");
|
|
584
|
-
}
|
|
585
|
-
if (!(await fileExists(verifyLogPath))) {
|
|
586
|
-
await writeTextIfChanged(verifyLogPath, "");
|
|
587
|
-
}
|
|
588
|
-
await writeTextIfChanged(reviewPath, nextReview);
|
|
589
|
-
await writeTextIfChanged(githubTitlePath, `${githubTitle}\n`);
|
|
590
|
-
await writeTextIfChanged(githubBodyPath, nextGithubBody);
|
|
591
|
-
return { meta: nextMeta, prDir, resolved, openOutcome };
|
|
592
|
-
}
|
|
593
|
-
if (!baseBranch) {
|
|
594
|
-
throw new CliError({
|
|
595
|
-
exitCode: exitCodeForError("E_USAGE"),
|
|
596
|
-
code: "E_USAGE",
|
|
597
|
-
message: "Base branch could not be resolved (use `agentplane branch base set`).",
|
|
204
|
+
remoteMode,
|
|
598
205
|
});
|
|
206
|
+
return { meta, prDir, resolved, openOutcome };
|
|
599
207
|
}
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
baseBranch,
|
|
603
|
-
branch,
|
|
604
|
-
prDir,
|
|
605
|
-
});
|
|
606
|
-
let nextMeta = buildUpdatedPrMeta({
|
|
607
|
-
meta: existingMeta,
|
|
608
|
-
branch,
|
|
609
|
-
at: now,
|
|
610
|
-
base: baseBranch,
|
|
611
|
-
headSha: renderedHeadSha,
|
|
612
|
-
});
|
|
613
|
-
const observedGithubPr = await tryLookupExistingGithubPrByBranch({
|
|
614
|
-
gitRoot: resolved.gitRoot,
|
|
615
|
-
branch,
|
|
616
|
-
baseBranch,
|
|
617
|
-
});
|
|
618
|
-
if (shouldPersistObservedGithubPrMeta(observedGithubPr)) {
|
|
619
|
-
nextMeta = buildObservedGithubPrMeta({
|
|
620
|
-
meta: nextMeta,
|
|
621
|
-
observed: observedGithubPr,
|
|
622
|
-
at: now,
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
const nextAutoSummary = renderPrAutoSummary({
|
|
626
|
-
updatedAt: nextMeta.updated_at,
|
|
627
|
-
branch,
|
|
628
|
-
headSha: artifactRefresh
|
|
629
|
-
? (nextMeta.head_sha ?? renderedHeadSha ?? null)
|
|
630
|
-
: (nextMeta.head_sha ?? renderedHeadSha ?? headSha ?? null),
|
|
631
|
-
diffstat,
|
|
632
|
-
});
|
|
633
|
-
const nextReview = renderPrReviewDocument({
|
|
634
|
-
task,
|
|
635
|
-
createdAt,
|
|
636
|
-
branch,
|
|
637
|
-
handoffNotes,
|
|
638
|
-
autoSummary: nextAutoSummary,
|
|
639
|
-
});
|
|
640
|
-
const githubTitle = buildGithubPrTitle(task);
|
|
641
|
-
const githubBody = renderGithubPrBody({
|
|
642
|
-
task,
|
|
643
|
-
handoffNotes,
|
|
644
|
-
autoSummary: nextAutoSummary,
|
|
645
|
-
});
|
|
646
|
-
await writeTextIfChanged(diffstatPath, diffstat ? `${diffstat}\n` : "");
|
|
647
|
-
await writeTextIfChanged(reviewPath, nextReview);
|
|
648
|
-
await writeTextIfChanged(githubTitlePath, `${githubTitle}\n`);
|
|
649
|
-
await writeTextIfChanged(githubBodyPath, githubBody);
|
|
650
|
-
await writeJsonStableIfChanged(metaPath, nextMeta);
|
|
651
|
-
return { meta: nextMeta, prDir, resolved };
|
|
208
|
+
const { meta } = await runPrUpdateSync(common);
|
|
209
|
+
return { meta, prDir, resolved };
|
|
652
210
|
}
|
|
653
211
|
finally {
|
|
654
212
|
await restoreIncidentRegistryIfNeeded({
|
|
@@ -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":"AAQA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAuDpF,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,CAgElB"}
|