agentplane 0.3.13 → 0.3.15
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/framework.manifest.json +7 -0
- package/assets/policy/incidents.md +5 -3
- package/assets/policy/workflow.branch_pr.md +10 -5
- package/dist/.build-manifest.json +280 -180
- 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/run-cli/command-catalog/core.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/core.js +29 -87
- 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 +16 -38
- 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/init/recipes.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/recipes.js +1 -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 -769
- 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/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/internal/auto-commit.d.ts.map +1 -1
- package/dist/commands/pr/internal/auto-commit.js +2 -1
- 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 -529
- package/dist/commands/pr/open.d.ts.map +1 -1
- package/dist/commands/pr/open.js +25 -8
- package/dist/commands/pr/pr.command.d.ts.map +1 -1
- package/dist/commands/pr/pr.command.js +7 -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 +1 -2
- package/dist/commands/recipes/impl/commands/active.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/active.js +6 -5
- package/dist/commands/recipes/impl/commands/add.d.ts +1 -0
- package/dist/commands/recipes/impl/commands/add.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/add.js +32 -27
- package/dist/commands/recipes/impl/commands/detach.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/detach.js +35 -21
- package/dist/commands/recipes/impl/commands/disable.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/disable.js +5 -3
- package/dist/commands/recipes/impl/commands/enable.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/enable.js +5 -3
- package/dist/commands/recipes/impl/commands/explain.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/explain.js +57 -47
- package/dist/commands/recipes/impl/commands/info.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/info.js +25 -21
- 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 +3 -13
- 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 +7 -6
- package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/remove.js +12 -7
- package/dist/commands/recipes/impl/commands/update.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/update.js +38 -24
- 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 +19 -3
- package/dist/commands/recipes/impl/overlay-project.d.ts.map +1 -1
- package/dist/commands/recipes/impl/overlay-project.js +76 -38
- package/dist/commands/recipes/impl/paths.d.ts +0 -3
- package/dist/commands/recipes/impl/paths.d.ts.map +1 -1
- package/dist/commands/recipes/impl/paths.js +0 -3
- package/dist/commands/recipes/impl/project-installed-recipes.d.ts +4 -1
- package/dist/commands/recipes/impl/project-installed-recipes.d.ts.map +1 -1
- package/dist/commands/recipes/impl/project-installed-recipes.js +6 -4
- package/dist/commands/recipes/impl/project-recipe-state.d.ts +1 -1
- package/dist/commands/recipes/impl/project-recipe-state.d.ts.map +1 -1
- package/dist/commands/recipes/impl/project-registry.d.ts +5 -1
- package/dist/commands/recipes/impl/project-registry.d.ts.map +1 -1
- package/dist/commands/recipes/impl/project-registry.js +34 -14
- 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 +1 -1
- package/dist/commands/recipes/impl/types.d.ts +1 -1
- 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.d.ts +5 -4
- package/dist/commands/recipes.d.ts.map +1 -1
- package/dist/commands/recipes.js +3 -3
- 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/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-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/hosted-close.command.d.ts.map +1 -1
- package/dist/commands/task/hosted-close.command.js +23 -2
- 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 +3 -22
- package/dist/runner/context/base-prompts.d.ts.map +1 -1
- package/dist/runner/context/base-prompts.js +6 -450
- 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 +2 -1
- 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/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 +4 -2
- package/dist/runtime/capabilities/recipe.d.ts +1 -1
- package/dist/runtime/capabilities/recipe.d.ts.map +1 -1
- 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/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 -4
- 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 -7
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanup-merged.d.ts","sourceRoot":"","sources":["../../../src/commands/branch/cleanup-merged.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cleanup-merged.d.ts","sourceRoot":"","sources":["../../../src/commands/branch/cleanup-merged.ts"],"names":[],"mappings":"AAsBA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AAgInC,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,GAAG,OAAO,CAAC,MAAM,CAAC,CAyJlB"}
|
|
@@ -8,6 +8,7 @@ import { ensureGitClean } from "../guard/index.js";
|
|
|
8
8
|
import { execFileAsync, gitEnv } from "../shared/git.js";
|
|
9
9
|
import { gitDiffNames } from "../shared/git-diff.js";
|
|
10
10
|
import { gitBranchExists, gitCurrentBranch, gitIsAncestor } from "../shared/git-ops.js";
|
|
11
|
+
import { cleanupMergedLocalBranch } from "../shared/merged-branch-cleanup.js";
|
|
11
12
|
import { findWorktreeForBranch, gitListBranchesByPrefixes, parseTaskIdFromCloseBranch, parseTaskIdFromBranch, } from "../shared/git-worktree.js";
|
|
12
13
|
import { isPathWithin, resolvePathFallback } from "../shared/path.js";
|
|
13
14
|
import { parsePrMeta } from "../shared/pr-meta.js";
|
|
@@ -216,15 +217,10 @@ export async function cmdCleanupMerged(opts) {
|
|
|
216
217
|
const taskDir = path.join(resolved.gitRoot, config.paths.workflow_dir, item.taskId);
|
|
217
218
|
await archivePrArtifacts(taskDir);
|
|
218
219
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
await execFileAsync("git", ["branch", "-D", item.branch], {
|
|
226
|
-
cwd: resolved.gitRoot,
|
|
227
|
-
env: gitEnv(),
|
|
220
|
+
await cleanupMergedLocalBranch({
|
|
221
|
+
gitRoot: resolved.gitRoot,
|
|
222
|
+
branch: item.branch,
|
|
223
|
+
worktreePathHint: worktreePath,
|
|
228
224
|
});
|
|
229
225
|
if (opts.deleteRemoteBranches) {
|
|
230
226
|
deletedRemoteBranches += (await deleteRemoteBranchIfPresent(resolved.gitRoot, item.branch))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-start.command.d.ts","sourceRoot":"","sources":["../../../src/commands/branch/work-start.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAc,MAAM,wBAAwB,CAAC;AAGtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"work-start.command.d.ts","sourceRoot":"","sources":["../../../src/commands/branch/work-start.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAc,MAAM,wBAAwB,CAAC;AAGtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,eAAe,CAmDtD,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,CAAC,sBAAsB,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,GAClE,cAAc,CAAC,eAAe,CAAC,CA4BjC"}
|
|
@@ -42,6 +42,7 @@ export const workStartSpec = {
|
|
|
42
42
|
notes: [
|
|
43
43
|
"When workflow_mode=direct, agentplane does not create task branches; it records a single active task for the workspace.",
|
|
44
44
|
"When workflow_mode=branch_pr, --worktree is required and the command must be run on the base branch.",
|
|
45
|
+
"After branch_pr work starts, run owner-scoped task commands from the created worktree so task README/PR artifacts stay attached to one checkout.",
|
|
45
46
|
],
|
|
46
47
|
parse: (raw) => ({
|
|
47
48
|
taskId: raw.args["task-id"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit.spec.d.ts","sourceRoot":"","sources":["../../src/commands/commit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOvD,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"commit.spec.d.ts","sourceRoot":"","sources":["../../src/commands/commit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOvD,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,YAAY,CA0LhD,CAAC"}
|
|
@@ -104,6 +104,8 @@ export const commitSpec = {
|
|
|
104
104
|
},
|
|
105
105
|
],
|
|
106
106
|
notes: [
|
|
107
|
+
"Repository-managed task commits use the canonical subject format `<emoji> <suffix> <scope>: <summary>`; non-task commits use `<emoji> <scope>: <summary>`.",
|
|
108
|
+
"Repository-managed commit paths resolve author/committer identity from global git `user.name` and `user.email` before falling back to ambient git env.",
|
|
107
109
|
"Protected path-scoped overrides can stand alone without a duplicate explicit prefix: `--allow-tasks`, `--allow-policy`, `--allow-config`, `--allow-hooks`, and `--allow-ci` each admit their own path family.",
|
|
108
110
|
"Top-level `agentplane commit` can auto-stage those protected path scopes when the git index starts empty.",
|
|
109
111
|
"`--allow-base` is different: it only overrides base-branch protection and never selects file paths by itself.",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type CommandContext } from "../shared/task-backend.js";
|
|
2
2
|
export declare function checkBranchPrShippedTaskDrift(ctx?: CommandContext): Promise<string[]>;
|
|
3
3
|
export declare function checkBranchPrDoneTaskOpenPrDrift(ctx?: CommandContext): Promise<string[]>;
|
|
4
4
|
//# sourceMappingURL=branch-pr.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch-pr.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/branch-pr.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"branch-pr.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/branch-pr.ts"],"names":[],"mappings":"AAKA,OAAO,EAA6B,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAM3F,wBAAsB,6BAA6B,CAAC,GAAG,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAyC3F;AAED,wBAAsB,gCAAgC,CAAC,GAAG,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAoC9F"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { renderDiagnosticFinding } from "../../shared/diagnostics.js";
|
|
4
|
+
import { backendUsesLocalTaskStore } from "../shared/task-backend.js";
|
|
4
5
|
import { findDoneBranchPrTasksWithOpenPrArtifacts, findLocallyShippedBranchPrTasks, } from "../task/hosted-merge-sync.js";
|
|
5
6
|
export async function checkBranchPrShippedTaskDrift(ctx) {
|
|
6
|
-
if (ctx
|
|
7
|
+
if (!ctx || !backendUsesLocalTaskStore(ctx) || ctx.config.workflow_mode !== "branch_pr") {
|
|
7
8
|
return [];
|
|
9
|
+
}
|
|
8
10
|
let tasks = [];
|
|
9
11
|
try {
|
|
10
12
|
tasks = await ctx.taskBackend.listTasks();
|
|
@@ -38,8 +40,9 @@ export async function checkBranchPrShippedTaskDrift(ctx) {
|
|
|
38
40
|
];
|
|
39
41
|
}
|
|
40
42
|
export async function checkBranchPrDoneTaskOpenPrDrift(ctx) {
|
|
41
|
-
if (ctx
|
|
43
|
+
if (!ctx || !backendUsesLocalTaskStore(ctx) || ctx.config.workflow_mode !== "branch_pr") {
|
|
42
44
|
return [];
|
|
45
|
+
}
|
|
43
46
|
const tasks = await readDoneTaskSnapshot(ctx);
|
|
44
47
|
if (tasks.length === 0)
|
|
45
48
|
return [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/commands.ts"],"names":[],"mappings":"AAaA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAQvF,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/commands.ts"],"names":[],"mappings":"AAaA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAQvF,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA+SxE,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBlB;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBlB;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAa9E;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,GAAG,OAAO,CAAC,MAAM,CAAC,CAwPlB"}
|
|
@@ -15,7 +15,7 @@ import { execFileAsync, gitEnv } from "../../shared/git.js";
|
|
|
15
15
|
import { ensureReconciledBeforeMutation } from "../../shared/reconcile-check.js";
|
|
16
16
|
import { stageAllowlist, suggestAllowPrefixes } from "./allow.js";
|
|
17
17
|
import { buildCloseCommitMessage, taskReadmePathForTask } from "./close-message.js";
|
|
18
|
-
import { buildGitCommitEnv } from "./env.js";
|
|
18
|
+
import { buildGitCommitEnv, resolveCanonicalGitIdentity } from "./env.js";
|
|
19
19
|
import { guardCommitCheck } from "./policy.js";
|
|
20
20
|
const COMMIT_FAILURE_SIGNAL_PATTERNS = [
|
|
21
21
|
/Code style issues found/i,
|
|
@@ -167,6 +167,7 @@ async function commitRefreshedTaskArtifacts(opts) {
|
|
|
167
167
|
allowConfig: false,
|
|
168
168
|
allowHooks: false,
|
|
169
169
|
allowCI: false,
|
|
170
|
+
gitIdentity: await resolveCanonicalGitIdentity(),
|
|
170
171
|
});
|
|
171
172
|
await opts.ctx.git.commit({ message, env });
|
|
172
173
|
return true;
|
|
@@ -442,6 +443,7 @@ export async function cmdCommit(opts) {
|
|
|
442
443
|
allowHooks: false,
|
|
443
444
|
allowCI: false,
|
|
444
445
|
allowStaleDist: true,
|
|
446
|
+
gitIdentity: await resolveCanonicalGitIdentity(),
|
|
445
447
|
});
|
|
446
448
|
await ctx.git.commit({ message: msg.subject, body: msg.body, env });
|
|
447
449
|
if (!opts.quiet) {
|
|
@@ -512,6 +514,7 @@ export async function cmdCommit(opts) {
|
|
|
512
514
|
allowConfig: opts.allowConfig,
|
|
513
515
|
allowHooks: opts.allowHooks,
|
|
514
516
|
allowCI: opts.allowCI,
|
|
517
|
+
gitIdentity: await resolveCanonicalGitIdentity(),
|
|
515
518
|
});
|
|
516
519
|
await ctx.git.commit({ message: opts.message, env });
|
|
517
520
|
await refreshBranchPrArtifactsAfterTaskCommit({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment-commit.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/comment-commit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAQ/E,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAiEvF,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,gBAAgB,CAAC;CAC1B,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"comment-commit.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/comment-commit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAQ/E,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAiEvF,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,gBAAgB,CAAC;CAC1B,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA4F/D"}
|
|
@@ -3,7 +3,7 @@ import { invalidValueMessage, successMessage } from "../../../cli/output.js";
|
|
|
3
3
|
import { CliError } from "../../../shared/errors.js";
|
|
4
4
|
import { formatCommentBodyForCommit, normalizeCommentBodyForCommit, } from "../../../shared/comment-format.js";
|
|
5
5
|
import { loadCommandContext } from "../../shared/task-backend.js";
|
|
6
|
-
import { buildGitCommitEnv } from "./env.js";
|
|
6
|
+
import { buildGitCommitEnv, resolveCanonicalGitIdentity } from "./env.js";
|
|
7
7
|
import { stageAllowlist } from "./allow.js";
|
|
8
8
|
import { guardCommitCheck } from "./policy.js";
|
|
9
9
|
function deriveCommitMessageFromComment(opts) {
|
|
@@ -116,6 +116,7 @@ export async function commitFromComment(opts) {
|
|
|
116
116
|
allowConfig: false,
|
|
117
117
|
allowHooks: false,
|
|
118
118
|
allowCI: false,
|
|
119
|
+
gitIdentity: await resolveCanonicalGitIdentity(),
|
|
119
120
|
});
|
|
120
121
|
await ctx.git.commit({ message, body, env });
|
|
121
122
|
const { hash, subject } = await ctx.git.headHashSubject();
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export type CanonicalGitIdentity = {
|
|
2
|
+
name: string;
|
|
3
|
+
email: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function resolveCanonicalGitIdentity(): Promise<CanonicalGitIdentity | null>;
|
|
1
6
|
export declare function buildGitCommitEnv(opts: {
|
|
2
7
|
taskId: string;
|
|
3
8
|
agentId?: string;
|
|
@@ -9,5 +14,6 @@ export declare function buildGitCommitEnv(opts: {
|
|
|
9
14
|
allowHooks: boolean;
|
|
10
15
|
allowCI: boolean;
|
|
11
16
|
allowStaleDist?: boolean;
|
|
17
|
+
gitIdentity?: CanonicalGitIdentity | null;
|
|
12
18
|
}): NodeJS.ProcessEnv;
|
|
13
19
|
//# sourceMappingURL=env.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/env.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAiBF,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAkBxF;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CAC3C,GAAG,MAAM,CAAC,UAAU,CAsBpB"}
|
|
@@ -1,6 +1,47 @@
|
|
|
1
|
+
import { execFileAsync } from "../../shared/git.js";
|
|
2
|
+
let canonicalGitIdentityPromise = null;
|
|
3
|
+
async function readGitConfigValue(key) {
|
|
4
|
+
try {
|
|
5
|
+
const { stdout } = await execFileAsync("git", ["config", "--global", "--get", key], {
|
|
6
|
+
cwd: process.cwd(),
|
|
7
|
+
env: process.env,
|
|
8
|
+
});
|
|
9
|
+
const trimmed = stdout.trim();
|
|
10
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export async function resolveCanonicalGitIdentity() {
|
|
17
|
+
canonicalGitIdentityPromise ??= (async () => {
|
|
18
|
+
const globalName = await readGitConfigValue("user.name");
|
|
19
|
+
const globalEmail = await readGitConfigValue("user.email");
|
|
20
|
+
const name = globalName ??
|
|
21
|
+
process.env.GIT_AUTHOR_NAME?.trim() ??
|
|
22
|
+
process.env.GIT_COMMITTER_NAME?.trim() ??
|
|
23
|
+
null;
|
|
24
|
+
const email = globalEmail ??
|
|
25
|
+
process.env.GIT_AUTHOR_EMAIL?.trim() ??
|
|
26
|
+
process.env.GIT_COMMITTER_EMAIL?.trim() ??
|
|
27
|
+
null;
|
|
28
|
+
if (!name || !email)
|
|
29
|
+
return null;
|
|
30
|
+
return { name, email };
|
|
31
|
+
})();
|
|
32
|
+
return await canonicalGitIdentityPromise;
|
|
33
|
+
}
|
|
1
34
|
export function buildGitCommitEnv(opts) {
|
|
2
35
|
return {
|
|
3
36
|
...process.env,
|
|
37
|
+
...(opts.gitIdentity
|
|
38
|
+
? {
|
|
39
|
+
GIT_AUTHOR_NAME: opts.gitIdentity.name,
|
|
40
|
+
GIT_AUTHOR_EMAIL: opts.gitIdentity.email,
|
|
41
|
+
GIT_COMMITTER_NAME: opts.gitIdentity.name,
|
|
42
|
+
GIT_COMMITTER_EMAIL: opts.gitIdentity.email,
|
|
43
|
+
}
|
|
44
|
+
: null),
|
|
4
45
|
AGENTPLANE_TASK_ID: opts.taskId,
|
|
5
46
|
...(opts.agentId ? { AGENTPLANE_AGENT_ID: opts.agentId } : null),
|
|
6
47
|
...(opts.statusTo ? { AGENTPLANE_STATUS_TO: opts.statusTo } : null),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-commit.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/auto-commit.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAiCnE,wBAAsB,8BAA8B,CAAC,IAAI,EAAE;IACzD,GAAG,EAAE,cAAc,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"auto-commit.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/auto-commit.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAiCnE,wBAAsB,8BAA8B,CAAC,IAAI,EAAE;IACzD,GAAG,EAAE,cAAc,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,OAAO,CAAC,CA+CnB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { extractTaskSuffix } from "@agentplaneorg/core";
|
|
3
|
-
import { buildGitCommitEnv } from "../../guard/impl/env.js";
|
|
3
|
+
import { buildGitCommitEnv, resolveCanonicalGitIdentity } from "../../guard/impl/env.js";
|
|
4
4
|
import { toGitPath } from "../../shared/git-diff.js";
|
|
5
5
|
import { execFileAsync, gitEnv } from "../../shared/git.js";
|
|
6
6
|
import { gitCurrentBranch } from "../../shared/git-ops.js";
|
|
@@ -62,6 +62,7 @@ export async function maybeAutoCommitTaskPrArtifacts(opts) {
|
|
|
62
62
|
allowConfig: false,
|
|
63
63
|
allowHooks: false,
|
|
64
64
|
allowCI: false,
|
|
65
|
+
gitIdentity: await resolveCanonicalGitIdentity(),
|
|
65
66
|
}),
|
|
66
67
|
});
|
|
67
68
|
opts.ctx.git.invalidateStatus();
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type ResolvedPrSyncBranch = {
|
|
2
|
+
branch: string | null;
|
|
3
|
+
source: "explicit" | "meta" | "current" | "none";
|
|
4
|
+
};
|
|
5
|
+
export declare function isUnknownRevisionError(err: unknown): boolean;
|
|
6
|
+
export declare function taskPrArtifactRefreshMessage(taskId: string): string;
|
|
7
|
+
export declare function resolveBranchHeadSha(opts: {
|
|
8
|
+
gitRoot: string;
|
|
9
|
+
branch: string;
|
|
10
|
+
}): Promise<string | null>;
|
|
11
|
+
export declare function resolveRenderableBranchHead(opts: {
|
|
12
|
+
gitRoot: string;
|
|
13
|
+
taskId: string;
|
|
14
|
+
branch: string;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
headSha: string | null;
|
|
17
|
+
artifactRefresh: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
export declare function resolvePrDiffBaseRef(opts: {
|
|
20
|
+
gitRoot: string;
|
|
21
|
+
baseBranch: string;
|
|
22
|
+
}): Promise<string>;
|
|
23
|
+
export declare function computePrDiffstat(opts: {
|
|
24
|
+
gitRoot: string;
|
|
25
|
+
baseBranch: string;
|
|
26
|
+
branch: string;
|
|
27
|
+
prDir: string;
|
|
28
|
+
}): Promise<string>;
|
|
29
|
+
export declare function resolvePrSyncBranch(opts: {
|
|
30
|
+
gitRoot: string;
|
|
31
|
+
metaPath: string;
|
|
32
|
+
taskId: string;
|
|
33
|
+
branch?: string;
|
|
34
|
+
}): Promise<ResolvedPrSyncBranch>;
|
|
35
|
+
export declare function currentBranchMatchesTask(taskPrefix: string, branch: string, taskId: string): boolean;
|
|
36
|
+
//# sourceMappingURL=sync-branch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-branch.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/sync-branch.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;CAClD,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAO5D;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWzB;AAED,wBAAsB,2BAA2B,CAAC,IAAI,EAAE;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,CAAC,CAwBhE;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CAclB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBlB;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAqBhC;AAED,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,OAAO,CAET"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { extractTaskSuffix } from "@agentplaneorg/core";
|
|
4
|
+
import { fileExists } from "../../../cli/fs-utils.js";
|
|
5
|
+
import { execFileAsync, gitEnv } from "../../shared/git.js";
|
|
6
|
+
import { gitBranchUpstream, gitCurrentBranch } from "../../shared/git-ops.js";
|
|
7
|
+
import { parseTaskIdFromBranch } from "../../shared/git-worktree.js";
|
|
8
|
+
import { gitDiffStat } from "../../shared/git-diff.js";
|
|
9
|
+
import { parsePrMeta } from "../../shared/pr-meta.js";
|
|
10
|
+
export function isUnknownRevisionError(err) {
|
|
11
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
12
|
+
return (/unknown revision or path not in the working tree/i.test(message) ||
|
|
13
|
+
/bad revision/i.test(message) ||
|
|
14
|
+
/ambiguous argument/i.test(message));
|
|
15
|
+
}
|
|
16
|
+
export function taskPrArtifactRefreshMessage(taskId) {
|
|
17
|
+
return `📝 ${extractTaskSuffix(taskId)} task: refresh PR artifacts`;
|
|
18
|
+
}
|
|
19
|
+
export async function resolveBranchHeadSha(opts) {
|
|
20
|
+
try {
|
|
21
|
+
const { stdout } = await execFileAsync("git", ["rev-parse", opts.branch], {
|
|
22
|
+
cwd: opts.gitRoot,
|
|
23
|
+
env: gitEnv(),
|
|
24
|
+
});
|
|
25
|
+
return stdout.trim() || null;
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
if (!isUnknownRevisionError(err))
|
|
29
|
+
throw err;
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export async function resolveRenderableBranchHead(opts) {
|
|
34
|
+
const branchHeadSha = await resolveBranchHeadSha({
|
|
35
|
+
gitRoot: opts.gitRoot,
|
|
36
|
+
branch: opts.branch,
|
|
37
|
+
});
|
|
38
|
+
if (!branchHeadSha)
|
|
39
|
+
return { headSha: null, artifactRefresh: false };
|
|
40
|
+
try {
|
|
41
|
+
const { stdout: subjectStdout } = await execFileAsync("git", ["log", "-1", "--pretty=%s", branchHeadSha], {
|
|
42
|
+
cwd: opts.gitRoot,
|
|
43
|
+
env: gitEnv(),
|
|
44
|
+
});
|
|
45
|
+
const subject = subjectStdout.trim();
|
|
46
|
+
return {
|
|
47
|
+
headSha: branchHeadSha,
|
|
48
|
+
artifactRefresh: subject === taskPrArtifactRefreshMessage(opts.taskId),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return { headSha: branchHeadSha, artifactRefresh: false };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export async function resolvePrDiffBaseRef(opts) {
|
|
56
|
+
const upstreamRef = await gitBranchUpstream(opts.gitRoot, opts.baseBranch);
|
|
57
|
+
const candidate = upstreamRef?.trim() ?? "";
|
|
58
|
+
if (!candidate)
|
|
59
|
+
return opts.baseBranch;
|
|
60
|
+
try {
|
|
61
|
+
const { stdout } = await execFileAsync("git", ["rev-parse", "--verify", candidate], {
|
|
62
|
+
cwd: opts.gitRoot,
|
|
63
|
+
env: gitEnv(),
|
|
64
|
+
});
|
|
65
|
+
return stdout.trim() ? candidate : opts.baseBranch;
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
if (!isUnknownRevisionError(err))
|
|
69
|
+
throw err;
|
|
70
|
+
return opts.baseBranch;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export async function computePrDiffstat(opts) {
|
|
74
|
+
const diffBaseRef = await resolvePrDiffBaseRef({
|
|
75
|
+
gitRoot: opts.gitRoot,
|
|
76
|
+
baseBranch: opts.baseBranch,
|
|
77
|
+
});
|
|
78
|
+
const taskDir = path.dirname(opts.prDir);
|
|
79
|
+
try {
|
|
80
|
+
return await gitDiffStat(opts.gitRoot, diffBaseRef, opts.branch, {
|
|
81
|
+
excludePaths: [
|
|
82
|
+
path.relative(opts.gitRoot, opts.prDir),
|
|
83
|
+
path.relative(opts.gitRoot, path.join(taskDir, "README.md")),
|
|
84
|
+
],
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
if (!isUnknownRevisionError(err))
|
|
89
|
+
throw err;
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export async function resolvePrSyncBranch(opts) {
|
|
94
|
+
const explicitBranch = opts.branch?.trim() ?? "";
|
|
95
|
+
if (explicitBranch) {
|
|
96
|
+
return { branch: explicitBranch, source: "explicit" };
|
|
97
|
+
}
|
|
98
|
+
if (await fileExists(opts.metaPath)) {
|
|
99
|
+
const metaBranch = parsePrMeta(await readFile(opts.metaPath, "utf8"), opts.taskId).branch?.trim() ?? "";
|
|
100
|
+
if (metaBranch) {
|
|
101
|
+
return { branch: metaBranch, source: "meta" };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const currentBranchValue = await gitCurrentBranch(opts.gitRoot);
|
|
105
|
+
const currentBranch = currentBranchValue.trim();
|
|
106
|
+
if (currentBranch) {
|
|
107
|
+
return { branch: currentBranch, source: "current" };
|
|
108
|
+
}
|
|
109
|
+
return { branch: null, source: "none" };
|
|
110
|
+
}
|
|
111
|
+
export function currentBranchMatchesTask(taskPrefix, branch, taskId) {
|
|
112
|
+
return parseTaskIdFromBranch(taskPrefix, branch) === taskId;
|
|
113
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type ObservedGithubPr = {
|
|
2
|
+
prNumber: number;
|
|
3
|
+
prUrl: string | null;
|
|
4
|
+
status: "OPEN" | "CLOSED" | "MERGED";
|
|
5
|
+
mergedAt: string | null;
|
|
6
|
+
mergeCommit: string | null;
|
|
7
|
+
base: string | null;
|
|
8
|
+
headSha: string | null;
|
|
9
|
+
};
|
|
10
|
+
export declare function tryLookupExistingGithubPrByBranch(opts: {
|
|
11
|
+
gitRoot: string;
|
|
12
|
+
branch: string;
|
|
13
|
+
baseBranch?: string | null;
|
|
14
|
+
}): Promise<ObservedGithubPr | null>;
|
|
15
|
+
export declare function formatGithubPrLink(prNumber: number, prUrl: string | null, verb: "linked to" | "created"): string;
|
|
16
|
+
export declare function shouldPersistObservedGithubPrMeta(observed: ObservedGithubPr | null): boolean;
|
|
17
|
+
export declare function formatUnpublishedRemoteHeadReason(branch: string): string;
|
|
18
|
+
export declare function tryCreateGithubPr(opts: {
|
|
19
|
+
gitRoot: string;
|
|
20
|
+
branch: string;
|
|
21
|
+
baseBranch: string | null;
|
|
22
|
+
title: string;
|
|
23
|
+
body: string;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
observed: ObservedGithubPr | null;
|
|
26
|
+
stagedReason: string | null;
|
|
27
|
+
}>;
|
|
28
|
+
//# sourceMappingURL=sync-github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-github.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/sync-github.ts"],"names":[],"mappings":"AAsBA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACrC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AAqDF,wBAAsB,iCAAiC,CAAC,IAAI,EAAE;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAmCnC;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,IAAI,EAAE,WAAW,GAAG,SAAS,GAC5B,MAAM,CAIR;AAED,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,GAAG,OAAO,CAG5F;AAED,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKxE;AAqCD,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC;IACV,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAClC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAAC,CA8CD"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { execFileAsync } from "../../shared/git.js";
|
|
2
|
+
import { isTransientGhTransportError, normalizeGhTransportError, withGhTransportRetry, } from "../../shared/gh-transport.js";
|
|
3
|
+
import { ghEnv } from "./gh-api.js";
|
|
4
|
+
function parseGithubRepoFromRemoteUrl(remoteUrl) {
|
|
5
|
+
const trimmed = remoteUrl.trim();
|
|
6
|
+
if (!trimmed)
|
|
7
|
+
return null;
|
|
8
|
+
const httpsMatch = /^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/.exec(trimmed);
|
|
9
|
+
if (httpsMatch)
|
|
10
|
+
return `${httpsMatch[1]}/${httpsMatch[2]}`;
|
|
11
|
+
const sshMatch = /^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/.exec(trimmed);
|
|
12
|
+
if (sshMatch)
|
|
13
|
+
return `${sshMatch[1]}/${sshMatch[2]}`;
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
async function resolveGithubRepoFromOrigin(gitRoot) {
|
|
17
|
+
try {
|
|
18
|
+
const { stdout } = await execFileAsync("git", ["remote", "get-url", "origin"], {
|
|
19
|
+
cwd: gitRoot,
|
|
20
|
+
env: process.env,
|
|
21
|
+
});
|
|
22
|
+
return parseGithubRepoFromRemoteUrl(stdout);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function normalizeObservedGithubPr(record) {
|
|
29
|
+
const number = Number(record.number);
|
|
30
|
+
if (!Number.isInteger(number) || number <= 0)
|
|
31
|
+
return null;
|
|
32
|
+
const state = record.state?.trim().toLowerCase() ?? "";
|
|
33
|
+
const mergedAt = record.merged_at?.trim() ?? null;
|
|
34
|
+
const status = mergedAt && mergedAt.length > 0
|
|
35
|
+
? "MERGED"
|
|
36
|
+
: state === "open"
|
|
37
|
+
? "OPEN"
|
|
38
|
+
: state === "closed"
|
|
39
|
+
? "CLOSED"
|
|
40
|
+
: null;
|
|
41
|
+
if (!status)
|
|
42
|
+
return null;
|
|
43
|
+
const prUrl = record.html_url?.trim() ?? null;
|
|
44
|
+
const mergeCommit = record.merge_commit_sha?.trim() ?? null;
|
|
45
|
+
const base = record.base?.ref?.trim() ?? null;
|
|
46
|
+
const headSha = record.head?.sha?.trim() ?? null;
|
|
47
|
+
return {
|
|
48
|
+
prNumber: number,
|
|
49
|
+
prUrl,
|
|
50
|
+
status,
|
|
51
|
+
mergedAt,
|
|
52
|
+
mergeCommit,
|
|
53
|
+
base,
|
|
54
|
+
headSha,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export async function tryLookupExistingGithubPrByBranch(opts) {
|
|
58
|
+
const repo = await resolveGithubRepoFromOrigin(opts.gitRoot);
|
|
59
|
+
if (!repo)
|
|
60
|
+
return null;
|
|
61
|
+
const owner = repo.split("/")[0]?.trim() ?? "";
|
|
62
|
+
if (!owner)
|
|
63
|
+
return null;
|
|
64
|
+
const query = new URLSearchParams({ state: "all", head: `${owner}:${opts.branch}` });
|
|
65
|
+
const baseBranch = opts.baseBranch?.trim() ?? "";
|
|
66
|
+
if (baseBranch)
|
|
67
|
+
query.set("base", baseBranch);
|
|
68
|
+
const endpoint = `repos/${repo}/pulls?${query.toString()}`;
|
|
69
|
+
try {
|
|
70
|
+
const { stdout } = await withGhTransportRetry(() => execFileAsync("gh", ["api", endpoint], {
|
|
71
|
+
cwd: opts.gitRoot,
|
|
72
|
+
env: ghEnv(),
|
|
73
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
74
|
+
}), { label: `running gh api ${endpoint}` });
|
|
75
|
+
const parsed = JSON.parse(stdout);
|
|
76
|
+
if (!Array.isArray(parsed) || parsed.length === 0)
|
|
77
|
+
return null;
|
|
78
|
+
for (const record of parsed) {
|
|
79
|
+
const observed = normalizeObservedGithubPr(record);
|
|
80
|
+
if (observed)
|
|
81
|
+
return observed;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
const code = err?.code;
|
|
87
|
+
if (code === "ENOENT")
|
|
88
|
+
return null;
|
|
89
|
+
const message = normalizeGhTransportError(err);
|
|
90
|
+
if (message.trim().length > 0)
|
|
91
|
+
return null;
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export function formatGithubPrLink(prNumber, prUrl, verb) {
|
|
96
|
+
return prUrl?.trim()
|
|
97
|
+
? `${verb} GitHub PR #${prNumber}: ${prUrl.trim()}`
|
|
98
|
+
: `${verb} GitHub PR #${prNumber}`;
|
|
99
|
+
}
|
|
100
|
+
export function shouldPersistObservedGithubPrMeta(observed) {
|
|
101
|
+
if (!observed)
|
|
102
|
+
return false;
|
|
103
|
+
return observed.status === "MERGED";
|
|
104
|
+
}
|
|
105
|
+
export function formatUnpublishedRemoteHeadReason(branch) {
|
|
106
|
+
return (`task branch ${branch} is not yet published on origin; push it with ` +
|
|
107
|
+
`\`git push -u origin ${branch}\` and rerun \`agentplane pr open\``);
|
|
108
|
+
}
|
|
109
|
+
function isMissingRemoteHeadCreateError(err) {
|
|
110
|
+
const text = normalizeGhTransportError(err);
|
|
111
|
+
if (!/\b422\b/i.test(text))
|
|
112
|
+
return false;
|
|
113
|
+
return (/head sha/i.test(text) ||
|
|
114
|
+
/head ref/i.test(text) ||
|
|
115
|
+
/head.*must be a branch/i.test(text) ||
|
|
116
|
+
/head.*not found/i.test(text) ||
|
|
117
|
+
/field["']?\s*:\s*["']head["']/i.test(text) ||
|
|
118
|
+
/field\s+head\b/i.test(text) ||
|
|
119
|
+
/no commits between/i.test(text));
|
|
120
|
+
}
|
|
121
|
+
function summarizeGithubPrCreateFailure(err) {
|
|
122
|
+
const text = normalizeGhTransportError(err);
|
|
123
|
+
if (err?.code === "ENOENT") {
|
|
124
|
+
return "gh CLI is unavailable";
|
|
125
|
+
}
|
|
126
|
+
if (/authentication required/i.test(text) ||
|
|
127
|
+
/not logged into github/i.test(text) ||
|
|
128
|
+
/bad credentials/i.test(text) ||
|
|
129
|
+
/permission denied/i.test(text) ||
|
|
130
|
+
/\b401\b/i.test(text) ||
|
|
131
|
+
/\b403\b/i.test(text)) {
|
|
132
|
+
return "GitHub auth or permissions unavailable";
|
|
133
|
+
}
|
|
134
|
+
if (isTransientGhTransportError(err)) {
|
|
135
|
+
return "GitHub transport failed; retry `agentplane pr open`";
|
|
136
|
+
}
|
|
137
|
+
return "GitHub PR creation failed";
|
|
138
|
+
}
|
|
139
|
+
export async function tryCreateGithubPr(opts) {
|
|
140
|
+
const repo = await resolveGithubRepoFromOrigin(opts.gitRoot);
|
|
141
|
+
if (!repo) {
|
|
142
|
+
return { observed: null, stagedReason: "GitHub origin repo unavailable" };
|
|
143
|
+
}
|
|
144
|
+
const baseBranch = opts.baseBranch?.trim() ?? "";
|
|
145
|
+
if (!baseBranch) {
|
|
146
|
+
return { observed: null, stagedReason: "base branch unresolved" };
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
const { stdout } = await withGhTransportRetry(() => execFileAsync("gh", [
|
|
150
|
+
"api",
|
|
151
|
+
`repos/${repo}/pulls`,
|
|
152
|
+
"-X",
|
|
153
|
+
"POST",
|
|
154
|
+
"-f",
|
|
155
|
+
`title=${opts.title}`,
|
|
156
|
+
"-f",
|
|
157
|
+
`body=${opts.body}`,
|
|
158
|
+
"-f",
|
|
159
|
+
`head=${opts.branch}`,
|
|
160
|
+
"-f",
|
|
161
|
+
`base=${baseBranch}`,
|
|
162
|
+
], {
|
|
163
|
+
cwd: opts.gitRoot,
|
|
164
|
+
env: ghEnv(),
|
|
165
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
166
|
+
}), { label: `running gh api repos/${repo}/pulls` });
|
|
167
|
+
return {
|
|
168
|
+
observed: normalizeObservedGithubPr(JSON.parse(stdout)),
|
|
169
|
+
stagedReason: null,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
if (isMissingRemoteHeadCreateError(err)) {
|
|
174
|
+
return { observed: null, stagedReason: formatUnpublishedRemoteHeadReason(opts.branch) };
|
|
175
|
+
}
|
|
176
|
+
return { observed: null, stagedReason: summarizeGithubPrCreateFailure(err) };
|
|
177
|
+
}
|
|
178
|
+
}
|