@a2f0/agent-tool 0.1.48 → 0.1.49
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/package.json +1 -1
- package/src/cli.ts +2 -3
- package/src/runAgentToolAction.ts +3 -2
- package/src/workflows/pr.ts +19 -2
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -16,7 +16,6 @@ import { bumpVersions, checkVersions, planVersions } from "./version/bumpVersion
|
|
|
16
16
|
import { prepareVersions } from "./version/prepareVersions";
|
|
17
17
|
import { resolveVersionConflicts } from "./version/resolveVersionConflicts";
|
|
18
18
|
import { openPr } from "./pr/openPr";
|
|
19
|
-
import { squashMerge } from "./pr/squashMerge";
|
|
20
19
|
import metadata from "../package.json";
|
|
21
20
|
import { runCommand } from "./commands/run";
|
|
22
21
|
import { inspectLog } from "./commands/output";
|
|
@@ -25,7 +24,7 @@ import { branchCommand } from "./workflows/branch";
|
|
|
25
24
|
import { commitsCommand, binariesCommand, gateCommand } from "./workflows/checks";
|
|
26
25
|
import { hooksCommand } from "./workflows/hooks";
|
|
27
26
|
import { repoCommand, policyCommand, toolchainCommand } from "./workflows/repository";
|
|
28
|
-
import { prWorkflowCommand } from "./workflows/pr";
|
|
27
|
+
import { mergeReviewedHead, prWorkflowCommand } from "./workflows/pr";
|
|
29
28
|
import { releaseCommand } from "./release/commands";
|
|
30
29
|
import { checkoutRoot } from "./workflows/core";
|
|
31
30
|
import { procCommand, teardownCommand } from "./processes/commands";
|
|
@@ -251,7 +250,7 @@ export function main(argv = process.argv.slice(2)): number | Promise<number> {
|
|
|
251
250
|
}
|
|
252
251
|
usage(action === "merge" && args.length === 3, "Usage: agent-tool pr merge <subject-or-empty> <reviewed-head-oid> <base-branch>");
|
|
253
252
|
usage(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i.test(args[1]!), "Merge requires a full reviewed HEAD OID.");
|
|
254
|
-
return
|
|
253
|
+
return mergeReviewedHead(root, args[0], args[1], args[2]);
|
|
255
254
|
}
|
|
256
255
|
if (command === "versions") {
|
|
257
256
|
const action = args.shift();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { openPr } from "./pr/openPr";
|
|
2
|
-
import { squashMerge } from "./pr/squashMerge";
|
|
3
2
|
import { solicitClaudeCodeReview } from "./review/solicitClaudeCodeReview";
|
|
4
3
|
import { solicitCodexReview } from "./review/solicitCodexReview";
|
|
5
4
|
import { solicitOpencodeReview } from "./review/solicitOpencodeReview";
|
|
6
5
|
import { bumpVersions, checkVersions } from "./version/bumpVersions";
|
|
7
6
|
import { resolveVersionConflicts } from "./version/resolveVersionConflicts";
|
|
7
|
+
import { mergeReviewedHead } from "./workflows/pr";
|
|
8
8
|
|
|
9
9
|
const AGENT_TOOL_USAGE =
|
|
10
10
|
"Usage: agent-tool <solicitClaudeCodeReview|solicitCodexReview|solicitOpencodeReview|openPr|squashMerge|bumpVersions|checkVersions|resolveVersionConflicts> [args]\n";
|
|
@@ -36,7 +36,8 @@ const defaultActions: AgentToolActions = {
|
|
|
36
36
|
solicitClaudeCodeReview,
|
|
37
37
|
solicitCodexReview,
|
|
38
38
|
solicitOpencodeReview,
|
|
39
|
-
|
|
39
|
+
// A reviewed HEAD merges only after every preflight gate passes.
|
|
40
|
+
squashMerge: mergeReviewedHead,
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
function assertMaximumPositionals(
|
package/src/workflows/pr.ts
CHANGED
|
@@ -4,11 +4,11 @@ import { closeSync, readFileSync } from "node:fs";
|
|
|
4
4
|
import { createLog } from "../commands/logFile";
|
|
5
5
|
import { DEFAULT_LIMITS, logTail, outputLimit } from "../commands/output";
|
|
6
6
|
import { loadConfig } from "../config";
|
|
7
|
-
import { remoteBranchHead, resolvePr, resolveRepositoryGitUrl } from "../git/prContext";
|
|
7
|
+
import { remoteBranchHead, resolveFreshBaseRef, resolvePr, resolveRepositoryGitUrl } from "../git/prContext";
|
|
8
8
|
import { assertMergeChecks } from "../pr/mergeChecks";
|
|
9
9
|
import { assertStrictBaseFreshness } from "../pr/baseFreshness";
|
|
10
10
|
import { baseFreshness, behindReason, cancelRuns } from "./prFreshness";
|
|
11
|
-
import { resolvePullRequestMergeTarget } from "../pr/squashMerge";
|
|
11
|
+
import { resolvePullRequestMergeTarget, squashMerge } from "../pr/squashMerge";
|
|
12
12
|
import { planVersions } from "../version/bumpVersions";
|
|
13
13
|
import { assert, clean, currentBranch, git, head, json, oid, option, flag, output, poll, timeoutOptions } from "./core";
|
|
14
14
|
|
|
@@ -86,6 +86,23 @@ export function preflight(expectedHead: string, baseBranch: string, baseOid: str
|
|
|
86
86
|
return { ok: true, repo: identity.repo, pr: pr.number, url: pr.url, headOid: expectedHead, baseBranch, baseOid, checks: checks.checks };
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Merge a reviewed HEAD only after every preflight gate passes against the
|
|
91
|
+
* freshly fetched live base: a skipped, failed, or stale preflight run never
|
|
92
|
+
* leads to a merge. Without a reviewed HEAD (legacy manual form) only the
|
|
93
|
+
* merge helper's own checks apply.
|
|
94
|
+
*/
|
|
95
|
+
export function mergeReviewedHead(rootDir: string, subject?: string, expectedHead?: string, baseBranch?: string): number {
|
|
96
|
+
if (!expectedHead) return squashMerge(rootDir, subject, expectedHead, baseBranch);
|
|
97
|
+
const identity = resolvePr();
|
|
98
|
+
const branch = baseBranch ?? resolvePullRequestMergeTarget(identity).baseRefName;
|
|
99
|
+
const baseOid = resolveFreshBaseRef(identity.repo, branch);
|
|
100
|
+
try { preflight(expectedHead, branch, baseOid); }
|
|
101
|
+
catch (error) { throw new Error(`Refusing to merge: preflight failed against live ${branch} ${baseOid}: ${(error as Error).message}`); }
|
|
102
|
+
// Bind the merge to the branch that passed preflight, inferred or given, so a retarget in between is refused.
|
|
103
|
+
return squashMerge(rootDir, subject, expectedHead, branch);
|
|
104
|
+
}
|
|
105
|
+
|
|
89
106
|
interface Comment { id: string; databaseId: number; body: string; url: string; author: { login: string } | null }
|
|
90
107
|
interface Page<T> { nodes: T[]; pageInfo: { hasNextPage: boolean; endCursor: string | null } }
|
|
91
108
|
interface Thread { id: string; isResolved: boolean; isOutdated: boolean; path: string; line: number | null; comments: Page<Comment> }
|