agentplane 0.3.10 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/AGENTS.md +2 -2
- package/assets/agents/CODER.json +4 -0
- package/assets/agents/CREATOR.json +1 -0
- package/assets/agents/DOCS.json +2 -1
- package/assets/agents/INTEGRATOR.json +2 -1
- package/assets/agents/ORCHESTRATOR.json +2 -0
- package/assets/agents/PLANNER.json +3 -1
- package/assets/agents/REVIEWER.json +1 -0
- package/assets/agents/TESTER.json +2 -2
- package/assets/agents/UPDATER.json +1 -0
- package/assets/agents/UPGRADER.json +1 -1
- package/assets/policy/governance.md +3 -4
- package/assets/policy/incidents.md +20 -88
- package/assets/policy/workflow.branch_pr.md +1 -1
- package/assets/policy/workflow.direct.md +2 -2
- package/bin/agentplane.js +114 -4
- package/bin/runtime-watch.js +1 -0
- package/bin/stale-dist-policy.d.ts +1 -1
- package/bin/stale-dist-policy.js +19 -1
- package/dist/.build-manifest.json +251 -166
- package/dist/cli/bootstrap-guide.d.ts.map +1 -1
- package/dist/cli/bootstrap-guide.js +3 -2
- package/dist/cli/command-guide.d.ts.map +1 -1
- package/dist/cli/command-guide.js +2 -1
- package/dist/cli/command-invocations.d.ts.map +1 -1
- package/dist/cli/command-invocations.js +4 -1
- 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 +6 -1
- package/dist/cli/run-cli/command-catalog/project.d.ts +1 -1
- package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/project.js +3 -1
- package/dist/cli/run-cli/command-catalog/task.d.ts +1 -1
- package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/task.js +10 -0
- package/dist/cli/run-cli/command-catalog.d.ts +1 -1
- package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/core/preflight.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/core/preflight.js +44 -1
- package/dist/cli/run-cli.test-helpers.d.ts +1 -0
- package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
- package/dist/cli/run-cli.test-helpers.js +26 -0
- package/dist/commands/branch/cleanup-merged.d.ts +3 -0
- package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
- package/dist/commands/branch/cleanup-merged.js +149 -36
- package/dist/commands/branch/work-start.d.ts.map +1 -1
- package/dist/commands/branch/work-start.js +137 -1
- package/dist/commands/cleanup/merged.command.d.ts +2 -0
- package/dist/commands/cleanup/merged.command.d.ts.map +1 -1
- package/dist/commands/cleanup/merged.command.js +24 -0
- package/dist/commands/doctor/branch-pr.d.ts +4 -0
- package/dist/commands/doctor/branch-pr.d.ts.map +1 -0
- package/dist/commands/doctor/branch-pr.js +96 -0
- package/dist/commands/doctor/fixes.d.ts +5 -0
- package/dist/commands/doctor/fixes.d.ts.map +1 -1
- package/dist/commands/doctor/fixes.js +70 -0
- package/dist/commands/doctor.run.d.ts.map +1 -1
- package/dist/commands/doctor.run.js +6 -1
- package/dist/commands/finish.run.d.ts.map +1 -1
- package/dist/commands/finish.run.js +11 -0
- package/dist/commands/finish.spec.d.ts +11 -0
- package/dist/commands/finish.spec.d.ts.map +1 -1
- package/dist/commands/finish.spec.js +51 -0
- package/dist/commands/guard/impl/close-message.d.ts.map +1 -1
- package/dist/commands/guard/impl/close-message.js +23 -6
- package/dist/commands/guard/impl/commands.d.ts +1 -0
- package/dist/commands/guard/impl/commands.d.ts.map +1 -1
- package/dist/commands/guard/impl/commands.js +94 -2
- package/dist/commands/guard/impl/env.d.ts +1 -0
- package/dist/commands/guard/impl/env.d.ts.map +1 -1
- package/dist/commands/guard/impl/env.js +1 -0
- package/dist/commands/hooks/index.d.ts +1 -1
- package/dist/commands/hooks/index.d.ts.map +1 -1
- package/dist/commands/hooks/index.js +139 -6
- package/dist/commands/incidents/collect.command.d.ts.map +1 -1
- package/dist/commands/incidents/collect.command.js +12 -7
- package/dist/commands/incidents/incidents.command.js +1 -1
- package/dist/commands/incidents/shared.d.ts +34 -0
- package/dist/commands/incidents/shared.d.ts.map +1 -1
- package/dist/commands/incidents/shared.js +166 -12
- package/dist/commands/pr/check.d.ts.map +1 -1
- package/dist/commands/pr/check.js +241 -135
- package/dist/commands/pr/close-superseded.d.ts +9 -0
- package/dist/commands/pr/close-superseded.d.ts.map +1 -0
- package/dist/commands/pr/close-superseded.js +129 -0
- package/dist/commands/pr/close.d.ts +11 -0
- package/dist/commands/pr/close.d.ts.map +1 -0
- package/dist/commands/pr/close.js +116 -0
- package/dist/commands/pr/index.d.ts +2 -0
- package/dist/commands/pr/index.d.ts.map +1 -1
- package/dist/commands/pr/index.js +2 -0
- package/dist/commands/pr/integrate/artifacts.d.ts +7 -0
- package/dist/commands/pr/integrate/artifacts.d.ts.map +1 -1
- package/dist/commands/pr/integrate/artifacts.js +66 -1
- package/dist/commands/pr/integrate/cmd.d.ts.map +1 -1
- package/dist/commands/pr/integrate/cmd.js +43 -2
- package/dist/commands/pr/integrate/internal/bootstrap-guidance.d.ts +8 -0
- package/dist/commands/pr/integrate/internal/bootstrap-guidance.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/bootstrap-guidance.js +59 -0
- package/dist/commands/pr/integrate/internal/cleanup.d.ts +1 -11
- package/dist/commands/pr/integrate/internal/cleanup.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/cleanup.js +1 -46
- package/dist/commands/pr/integrate/internal/finalize.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/finalize.js +43 -12
- package/dist/commands/pr/integrate/internal/github-protection.d.ts +5 -0
- package/dist/commands/pr/integrate/internal/github-protection.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/github-protection.js +13 -0
- package/dist/commands/pr/integrate/internal/merge.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/merge.js +36 -13
- package/dist/commands/pr/integrate/internal/post-integrate-bootstrap.d.ts +13 -0
- package/dist/commands/pr/integrate/internal/post-integrate-bootstrap.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/post-integrate-bootstrap.js +25 -0
- package/dist/commands/pr/integrate/internal/pre-integrate-bootstrap.d.ts +15 -0
- package/dist/commands/pr/integrate/internal/pre-integrate-bootstrap.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/pre-integrate-bootstrap.js +35 -0
- package/dist/commands/pr/integrate/internal/prepare.d.ts +4 -2
- package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/prepare.js +109 -38
- package/dist/commands/pr/internal/auto-commit.d.ts +7 -0
- package/dist/commands/pr/internal/auto-commit.d.ts.map +1 -0
- package/dist/commands/pr/internal/auto-commit.js +64 -0
- package/dist/commands/pr/internal/freshness.d.ts +21 -0
- package/dist/commands/pr/internal/freshness.d.ts.map +1 -0
- package/dist/commands/pr/internal/freshness.js +52 -0
- package/dist/commands/pr/internal/gh-api.d.ts +6 -0
- package/dist/commands/pr/internal/gh-api.d.ts.map +1 -0
- package/dist/commands/pr/internal/gh-api.js +80 -0
- package/dist/commands/pr/internal/pr-paths.d.ts +10 -0
- package/dist/commands/pr/internal/pr-paths.d.ts.map +1 -1
- package/dist/commands/pr/internal/pr-paths.js +10 -0
- package/dist/commands/pr/internal/review-template.d.ts.map +1 -1
- package/dist/commands/pr/internal/review-template.js +37 -4
- package/dist/commands/pr/internal/sync.d.ts +9 -0
- package/dist/commands/pr/internal/sync.d.ts.map +1 -1
- package/dist/commands/pr/internal/sync.js +531 -124
- package/dist/commands/pr/open.d.ts +1 -0
- package/dist/commands/pr/open.d.ts.map +1 -1
- package/dist/commands/pr/open.js +24 -2
- package/dist/commands/pr/pr.command.d.ts +15 -0
- package/dist/commands/pr/pr.command.d.ts.map +1 -1
- package/dist/commands/pr/pr.command.js +118 -2
- package/dist/commands/pr/update.d.ts.map +1 -1
- package/dist/commands/pr/update.js +71 -2
- package/dist/commands/release/apply.command.d.ts +3 -1
- package/dist/commands/release/apply.command.d.ts.map +1 -1
- package/dist/commands/release/apply.command.js +356 -34
- package/dist/commands/release/apply.mutation.d.ts.map +1 -1
- package/dist/commands/release/apply.mutation.js +1 -0
- package/dist/commands/release/apply.preflight.d.ts.map +1 -1
- package/dist/commands/release/apply.preflight.js +1 -1
- package/dist/commands/release/apply.reporting.d.ts +1 -0
- package/dist/commands/release/apply.reporting.d.ts.map +1 -1
- package/dist/commands/release/apply.reporting.js +12 -8
- package/dist/commands/release/apply.types.d.ts +13 -0
- package/dist/commands/release/apply.types.d.ts.map +1 -1
- package/dist/commands/release/plan.command.d.ts.map +1 -1
- package/dist/commands/release/plan.command.js +48 -0
- package/dist/commands/shared/gh-transport.d.ts +16 -0
- package/dist/commands/shared/gh-transport.d.ts.map +1 -0
- package/dist/commands/shared/gh-transport.js +71 -0
- package/dist/commands/shared/git-diff.d.ts +3 -1
- package/dist/commands/shared/git-diff.d.ts.map +1 -1
- package/dist/commands/shared/git-diff.js +10 -2
- package/dist/commands/shared/git-ops.d.ts +1 -0
- package/dist/commands/shared/git-ops.d.ts.map +1 -1
- package/dist/commands/shared/git-ops.js +15 -0
- package/dist/commands/shared/git-worktree.d.ts +2 -0
- package/dist/commands/shared/git-worktree.d.ts.map +1 -1
- package/dist/commands/shared/git-worktree.js +22 -2
- package/dist/commands/shared/merged-branch-cleanup.d.ts +12 -0
- package/dist/commands/shared/merged-branch-cleanup.d.ts.map +1 -0
- package/dist/commands/shared/merged-branch-cleanup.js +46 -0
- package/dist/commands/shared/post-commit-pr-artifacts.d.ts +9 -0
- package/dist/commands/shared/post-commit-pr-artifacts.d.ts.map +1 -0
- package/dist/commands/shared/post-commit-pr-artifacts.js +57 -0
- package/dist/commands/shared/pr-meta.d.ts +20 -0
- package/dist/commands/shared/pr-meta.d.ts.map +1 -1
- package/dist/commands/shared/pr-meta.js +125 -0
- package/dist/commands/shared/task-backend.d.ts +7 -0
- package/dist/commands/shared/task-backend.d.ts.map +1 -1
- package/dist/commands/shared/task-backend.js +71 -27
- package/dist/commands/shared/task-local-freshness.d.ts +2 -0
- package/dist/commands/shared/task-local-freshness.d.ts.map +1 -1
- package/dist/commands/shared/task-local-freshness.js +7 -1
- package/dist/commands/task/close-duplicate.d.ts.map +1 -1
- package/dist/commands/task/close-duplicate.js +34 -1
- package/dist/commands/task/derive.js +1 -1
- package/dist/commands/task/doc-template.d.ts.map +1 -1
- package/dist/commands/task/doc-template.js +7 -11
- package/dist/commands/task/findings-add.command.d.ts +20 -0
- package/dist/commands/task/findings-add.command.d.ts.map +1 -0
- package/dist/commands/task/findings-add.command.js +165 -0
- package/dist/commands/task/findings.command.d.ts +7 -0
- package/dist/commands/task/findings.command.d.ts.map +1 -0
- package/dist/commands/task/findings.command.js +20 -0
- package/dist/commands/task/findings.d.ts +63 -0
- package/dist/commands/task/findings.d.ts.map +1 -0
- package/dist/commands/task/findings.js +188 -0
- package/dist/commands/task/finish-shared.d.ts +2 -0
- package/dist/commands/task/finish-shared.d.ts.map +1 -1
- package/dist/commands/task/finish-shared.js +56 -1
- package/dist/commands/task/finish.d.ts +10 -0
- package/dist/commands/task/finish.d.ts.map +1 -1
- package/dist/commands/task/finish.js +125 -6
- package/dist/commands/task/hosted-close-pr.command.d.ts +11 -0
- package/dist/commands/task/hosted-close-pr.command.d.ts.map +1 -0
- package/dist/commands/task/hosted-close-pr.command.js +449 -0
- package/dist/commands/task/hosted-close.command.d.ts.map +1 -1
- package/dist/commands/task/hosted-close.command.js +234 -19
- package/dist/commands/task/hosted-merge-sync.d.ts +41 -0
- package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
- package/dist/commands/task/hosted-merge-sync.js +291 -17
- package/dist/commands/task/index.d.ts +1 -0
- package/dist/commands/task/index.d.ts.map +1 -1
- package/dist/commands/task/index.js +1 -0
- package/dist/commands/task/new.d.ts +1 -0
- package/dist/commands/task/new.d.ts.map +1 -1
- package/dist/commands/task/new.js +71 -1
- package/dist/commands/task/new.spec.d.ts.map +1 -1
- package/dist/commands/task/new.spec.js +7 -0
- package/dist/commands/task/normalize.command.d.ts +2 -0
- package/dist/commands/task/normalize.command.d.ts.map +1 -1
- package/dist/commands/task/normalize.command.js +45 -0
- package/dist/commands/task/normalize.d.ts +2 -0
- package/dist/commands/task/normalize.d.ts.map +1 -1
- package/dist/commands/task/normalize.js +85 -8
- package/dist/commands/task/plan.d.ts.map +1 -1
- package/dist/commands/task/plan.js +7 -10
- package/dist/commands/task/shared/docs.d.ts +6 -0
- package/dist/commands/task/shared/docs.d.ts.map +1 -1
- package/dist/commands/task/shared/docs.js +14 -0
- package/dist/commands/task/shared/transitions.d.ts.map +1 -1
- package/dist/commands/task/shared/transitions.js +11 -1
- package/dist/commands/task/shared.d.ts +1 -1
- package/dist/commands/task/shared.d.ts.map +1 -1
- package/dist/commands/task/shared.js +1 -1
- package/dist/commands/task/start.d.ts.map +1 -1
- package/dist/commands/task/start.js +7 -10
- package/dist/commands/task/task.command.d.ts.map +1 -1
- package/dist/commands/task/task.command.js +4 -0
- package/dist/commands/task/verify-command-shared.d.ts +19 -0
- package/dist/commands/task/verify-command-shared.d.ts.map +1 -1
- package/dist/commands/task/verify-command-shared.js +152 -1
- package/dist/commands/task/verify-ok.command.d.ts.map +1 -1
- package/dist/commands/task/verify-ok.command.js +15 -2
- package/dist/commands/task/verify-record.d.ts +36 -0
- package/dist/commands/task/verify-record.d.ts.map +1 -1
- package/dist/commands/task/verify-record.js +166 -11
- package/dist/commands/task/verify-rework.command.d.ts.map +1 -1
- package/dist/commands/task/verify-rework.command.js +15 -2
- package/dist/commands/task/verify-show.command.d.ts +1 -1
- package/dist/commands/task/verify-show.command.d.ts.map +1 -1
- package/dist/commands/task/verify-show.command.js +28 -1
- package/dist/commands/verify.run.d.ts.map +1 -1
- package/dist/commands/verify.run.js +12 -0
- package/dist/commands/verify.spec.d.ts +2 -6
- package/dist/commands/verify.spec.d.ts.map +1 -1
- package/dist/commands/verify.spec.js +30 -3
- package/dist/runtime/incidents/index.d.ts +1 -1
- package/dist/runtime/incidents/index.d.ts.map +1 -1
- package/dist/runtime/incidents/resolve.d.ts.map +1 -1
- package/dist/runtime/incidents/resolve.js +319 -73
- package/dist/runtime/incidents/types.d.ts +14 -2
- package/dist/runtime/incidents/types.d.ts.map +1 -1
- package/dist/shared/env.d.ts +1 -0
- package/dist/shared/env.d.ts.map +1 -1
- package/dist/shared/env.js +22 -1
- package/dist/shared/protected-paths.d.ts +1 -1
- package/dist/shared/protected-paths.d.ts.map +1 -1
- package/dist/shared/protected-paths.js +4 -0
- package/package.json +2 -2
|
@@ -18,6 +18,43 @@ function parseSemver(version) {
|
|
|
18
18
|
return null;
|
|
19
19
|
return { major, minor, patch };
|
|
20
20
|
}
|
|
21
|
+
function compareSemver(left, right) {
|
|
22
|
+
const leftParsed = parseSemver(left);
|
|
23
|
+
const rightParsed = parseSemver(right);
|
|
24
|
+
if (!leftParsed || !rightParsed) {
|
|
25
|
+
throw new CliError({
|
|
26
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
27
|
+
code: "E_VALIDATION",
|
|
28
|
+
message: `Invalid semver comparison: ${left} vs ${right}`,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (leftParsed.major !== rightParsed.major)
|
|
32
|
+
return leftParsed.major - rightParsed.major;
|
|
33
|
+
if (leftParsed.minor !== rightParsed.minor)
|
|
34
|
+
return leftParsed.minor - rightParsed.minor;
|
|
35
|
+
return leftParsed.patch - rightParsed.patch;
|
|
36
|
+
}
|
|
37
|
+
function normalizeTagVersion(tag) {
|
|
38
|
+
if (!tag)
|
|
39
|
+
return null;
|
|
40
|
+
return tag.startsWith("v") ? tag.slice(1) : tag;
|
|
41
|
+
}
|
|
42
|
+
function listMissingPatchTags(fromVersion, toVersion) {
|
|
43
|
+
const fromParsed = parseSemver(fromVersion);
|
|
44
|
+
const toParsed = parseSemver(toVersion);
|
|
45
|
+
if (!fromParsed || !toParsed)
|
|
46
|
+
return [];
|
|
47
|
+
if (fromParsed.major !== toParsed.major ||
|
|
48
|
+
fromParsed.minor !== toParsed.minor ||
|
|
49
|
+
toParsed.patch <= fromParsed.patch) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
const out = [];
|
|
53
|
+
for (let patch = fromParsed.patch + 1; patch <= toParsed.patch; patch += 1) {
|
|
54
|
+
out.push(`v${fromParsed.major}.${fromParsed.minor}.${patch}`);
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
21
58
|
function bumpVersion(version, bump) {
|
|
22
59
|
const parsed = parseSemver(version);
|
|
23
60
|
if (!parsed) {
|
|
@@ -220,6 +257,17 @@ export const runReleasePlan = async (ctx, flags) => {
|
|
|
220
257
|
});
|
|
221
258
|
}
|
|
222
259
|
const prevTag = flags.since ?? (await getLatestSemverTag(gitRoot));
|
|
260
|
+
const latestPublishedVersion = normalizeTagVersion(prevTag);
|
|
261
|
+
if (latestPublishedVersion && compareSemver(coreVersion, latestPublishedVersion) > 0) {
|
|
262
|
+
const missingTags = listMissingPatchTags(latestPublishedVersion, coreVersion);
|
|
263
|
+
const missingText = missingTags.length > 0 ? missingTags.join(", ") : coreVersion;
|
|
264
|
+
throw new CliError({
|
|
265
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
266
|
+
code: "E_VALIDATION",
|
|
267
|
+
message: `Release planning blocked: workspace version is already ${coreVersion} while the latest published/tagged release is ${prevTag}. ` +
|
|
268
|
+
`Publish or recover the missing release sequence first: ${missingText}.`,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
223
271
|
const nextVersion = bumpVersion(coreVersion, flags.bump);
|
|
224
272
|
const nextTag = `v${nextVersion}`;
|
|
225
273
|
const changes = await listChanges(gitRoot, prevTag);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const GH_LOOKUP_MAX_ATTEMPTS = 3;
|
|
2
|
+
export declare const GH_LOOKUP_BASE_DELAY_MS = 250;
|
|
3
|
+
export declare function normalizeGhTransportError(err: unknown): string;
|
|
4
|
+
export declare function isTransientGhTransportError(err: unknown): boolean;
|
|
5
|
+
export declare function withGhTransportRetry<T>(operation: () => Promise<T>, opts: {
|
|
6
|
+
label: string;
|
|
7
|
+
maxAttempts?: number;
|
|
8
|
+
baseDelayMs?: number;
|
|
9
|
+
onRetry?: (ctx: {
|
|
10
|
+
attempt: number;
|
|
11
|
+
maxAttempts: number;
|
|
12
|
+
error: unknown;
|
|
13
|
+
label: string;
|
|
14
|
+
}) => void;
|
|
15
|
+
}): Promise<T>;
|
|
16
|
+
//# sourceMappingURL=gh-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gh-transport.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/gh-transport.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AA8B3C,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAU9D;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAIjE;AAOD,wBAAsB,oBAAoB,CAAC,CAAC,EAC1C,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,IAAI,EAAE;IACJ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,EAAE,OAAO,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACf,KAAK,IAAI,CAAC;CACZ,GACA,OAAO,CAAC,CAAC,CAAC,CAiBZ"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export const GH_LOOKUP_MAX_ATTEMPTS = 3;
|
|
2
|
+
export const GH_LOOKUP_BASE_DELAY_MS = 250;
|
|
3
|
+
const GH_TRANSIENT_ERROR_PATTERNS = [
|
|
4
|
+
/eof\b/i,
|
|
5
|
+
/tls handshake timeout/i,
|
|
6
|
+
/ssl_error_syscall/i,
|
|
7
|
+
/connection reset by peer/i,
|
|
8
|
+
/\beconnreset\b/i,
|
|
9
|
+
/\betimedout\b/i,
|
|
10
|
+
/socket hang up/i,
|
|
11
|
+
/temporary failure in name resolution/i,
|
|
12
|
+
/network is unreachable/i,
|
|
13
|
+
/server closed the connection/i,
|
|
14
|
+
];
|
|
15
|
+
const GH_PERMANENT_ERROR_PATTERNS = [
|
|
16
|
+
/authentication required/i,
|
|
17
|
+
/not logged into github/i,
|
|
18
|
+
/could not resolve to a pull request/i,
|
|
19
|
+
/graphql: field/i,
|
|
20
|
+
/bad credentials/i,
|
|
21
|
+
/permission denied/i,
|
|
22
|
+
/\b404\b/i,
|
|
23
|
+
/\b422\b/i,
|
|
24
|
+
/\b403\b/i,
|
|
25
|
+
/\b401\b/i,
|
|
26
|
+
/unknown command/i,
|
|
27
|
+
/usage:/i,
|
|
28
|
+
];
|
|
29
|
+
export function normalizeGhTransportError(err) {
|
|
30
|
+
if (err instanceof Error) {
|
|
31
|
+
const parts = [err.name, err.message];
|
|
32
|
+
const stderr = err.stderr;
|
|
33
|
+
const stdout = err.stdout;
|
|
34
|
+
if (typeof stderr === "string" && stderr.trim())
|
|
35
|
+
parts.push(stderr);
|
|
36
|
+
if (typeof stdout === "string" && stdout.trim())
|
|
37
|
+
parts.push(stdout);
|
|
38
|
+
return parts.filter((part) => part.trim().length > 0).join("\n");
|
|
39
|
+
}
|
|
40
|
+
return String(err);
|
|
41
|
+
}
|
|
42
|
+
export function isTransientGhTransportError(err) {
|
|
43
|
+
const text = normalizeGhTransportError(err);
|
|
44
|
+
if (GH_PERMANENT_ERROR_PATTERNS.some((pattern) => pattern.test(text)))
|
|
45
|
+
return false;
|
|
46
|
+
return GH_TRANSIENT_ERROR_PATTERNS.some((pattern) => pattern.test(text));
|
|
47
|
+
}
|
|
48
|
+
async function sleep(ms) {
|
|
49
|
+
if (ms <= 0)
|
|
50
|
+
return;
|
|
51
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
52
|
+
}
|
|
53
|
+
export async function withGhTransportRetry(operation, opts) {
|
|
54
|
+
const maxAttempts = opts.maxAttempts ?? GH_LOOKUP_MAX_ATTEMPTS;
|
|
55
|
+
const baseDelayMs = opts.baseDelayMs ?? GH_LOOKUP_BASE_DELAY_MS;
|
|
56
|
+
let lastError = null;
|
|
57
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
58
|
+
try {
|
|
59
|
+
return await operation();
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
lastError = error;
|
|
63
|
+
if (!isTransientGhTransportError(error) || attempt === maxAttempts) {
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
opts.onRetry?.({ attempt, maxAttempts, error, label: opts.label });
|
|
67
|
+
await sleep(baseDelayMs * attempt);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
71
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export declare function toGitPath(filePath: string): string;
|
|
2
2
|
export declare function gitShowFile(cwd: string, ref: string, relPath: string): Promise<string>;
|
|
3
3
|
export declare function gitDiffNames(cwd: string, base: string, branch: string): Promise<string[]>;
|
|
4
|
-
export declare function gitDiffStat(cwd: string, base: string, branch: string
|
|
4
|
+
export declare function gitDiffStat(cwd: string, base: string, branch: string, opts?: {
|
|
5
|
+
excludePaths?: string[];
|
|
6
|
+
}): Promise<string>;
|
|
5
7
|
export declare function gitAheadBehind(cwd: string, base: string, branch: string): Promise<{
|
|
6
8
|
ahead: number;
|
|
7
9
|
behind: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-diff.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/git-diff.ts"],"names":[],"mappings":"AAIA,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAM5F;AAED,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAS/F;AAED,wBAAsB,WAAW,
|
|
1
|
+
{"version":3,"file":"git-diff.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/git-diff.ts"],"names":[],"mappings":"AAIA,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAM5F;AAED,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAS/F;AAED,wBAAsB,WAAW,CAC/B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GACjC,OAAO,CAAC,MAAM,CAAC,CAcjB;AAED,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAa5C"}
|
|
@@ -20,8 +20,16 @@ export async function gitDiffNames(cwd, base, branch) {
|
|
|
20
20
|
.map((line) => line.trim())
|
|
21
21
|
.filter((line) => line.length > 0);
|
|
22
22
|
}
|
|
23
|
-
export async function gitDiffStat(cwd, base, branch) {
|
|
24
|
-
const
|
|
23
|
+
export async function gitDiffStat(cwd, base, branch, opts) {
|
|
24
|
+
const args = ["diff", "--stat", `${base}...${branch}`];
|
|
25
|
+
const excludePaths = (opts?.excludePaths ?? [])
|
|
26
|
+
.map((relPath) => relPath.trim())
|
|
27
|
+
.filter((relPath) => relPath.length > 0)
|
|
28
|
+
.map((relPath) => `:(exclude)${toGitPath(relPath)}`);
|
|
29
|
+
if (excludePaths.length > 0) {
|
|
30
|
+
args.push("--", ".", ...excludePaths);
|
|
31
|
+
}
|
|
32
|
+
const { stdout } = await execFileAsync("git", args, {
|
|
25
33
|
cwd,
|
|
26
34
|
env: gitEnv(),
|
|
27
35
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare function gitRevParse(cwd: string, args: string[]): Promise<string>;
|
|
2
2
|
export declare function gitCurrentBranch(cwd: string): Promise<string>;
|
|
3
3
|
export declare function gitBranchExists(cwd: string, branch: string): Promise<boolean>;
|
|
4
|
+
export declare function gitIsAncestor(cwd: string, maybeAncestor: string, descendant: string): Promise<boolean>;
|
|
4
5
|
export declare function gitBranchUpstream(cwd: string, branch: string): Promise<string | null>;
|
|
5
6
|
export declare function gitListBranches(cwd: string): Promise<string[]>;
|
|
6
7
|
export declare function gitStagedPaths(cwd: string): Promise<string[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-ops.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/git-ops.ts"],"names":[],"mappings":"AAMA,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAK9E;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAA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I,CAAC,CAKf;AAED,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB5E;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAe9F;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,MAAM,CAAC,CAiDlB;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACpB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBhB"}
|
|
@@ -52,6 +52,21 @@ export async function gitBranchExists(cwd, branch) {
|
|
|
52
52
|
throw err;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
export async function gitIsAncestor(cwd, maybeAncestor, descendant) {
|
|
56
|
+
try {
|
|
57
|
+
await execFileAsync("git", ["merge-base", "--is-ancestor", maybeAncestor, descendant], {
|
|
58
|
+
cwd,
|
|
59
|
+
env: gitEnv(),
|
|
60
|
+
});
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
const code = err?.code;
|
|
65
|
+
if (code === 1)
|
|
66
|
+
return false;
|
|
67
|
+
throw err;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
55
70
|
export async function gitBranchUpstream(cwd, branch) {
|
|
56
71
|
try {
|
|
57
72
|
const { stdout } = await execFileAsync("git", ["for-each-ref", "--format=%(upstream:short)", `refs/heads/${branch}`], {
|
|
@@ -4,5 +4,7 @@ export declare function listWorktrees(cwd: string): Promise<{
|
|
|
4
4
|
}[]>;
|
|
5
5
|
export declare function findWorktreeForBranch(cwd: string, branch: string): Promise<string | null>;
|
|
6
6
|
export declare function parseTaskIdFromBranch(prefix: string, branch: string): string | null;
|
|
7
|
+
export declare function parseTaskIdFromCloseBranch(branch: string): string | null;
|
|
8
|
+
export declare function gitListBranchesByPrefixes(cwd: string, prefixes: string[]): Promise<string[]>;
|
|
7
9
|
export declare function gitListTaskBranches(cwd: string, prefix: string): Promise<string[]>;
|
|
8
10
|
//# sourceMappingURL=git-worktree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-worktree.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/git-worktree.ts"],"names":[],"mappings":"AAEA,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,CAAC,CAoBpD;AAED,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQ/F;AAMD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMnF;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"git-worktree.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/git-worktree.ts"],"names":[],"mappings":"AAEA,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,CAAC,CAoBpD;AAED,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQ/F;AAMD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMnF;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMxE;AAED,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CAkBnB;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAExF"}
|
|
@@ -39,10 +39,30 @@ export function parseTaskIdFromBranch(prefix, branch) {
|
|
|
39
39
|
const taskId = rest.split("/", 1)[0];
|
|
40
40
|
return taskId ? taskId.trim() : null;
|
|
41
41
|
}
|
|
42
|
-
export
|
|
43
|
-
const
|
|
42
|
+
export function parseTaskIdFromCloseBranch(branch) {
|
|
43
|
+
const normalized = stripBranchRef(branch);
|
|
44
|
+
if (!normalized.startsWith("task-close/"))
|
|
45
|
+
return null;
|
|
46
|
+
const rest = normalized.slice("task-close/".length);
|
|
47
|
+
const taskId = rest.split("/", 1)[0];
|
|
48
|
+
return taskId ? taskId.trim() : null;
|
|
49
|
+
}
|
|
50
|
+
export async function gitListBranchesByPrefixes(cwd, prefixes) {
|
|
51
|
+
const patterns = prefixes
|
|
52
|
+
.map((prefix) => prefix.trim())
|
|
53
|
+
.filter((prefix) => prefix.length > 0)
|
|
54
|
+
.map((prefix) => `refs/heads/${prefix}`);
|
|
55
|
+
if (patterns.length === 0)
|
|
56
|
+
return [];
|
|
57
|
+
const { stdout } = await execFileAsync("git", ["for-each-ref", "--format=%(refname:short)", ...patterns], {
|
|
58
|
+
cwd,
|
|
59
|
+
env: gitEnv(),
|
|
60
|
+
});
|
|
44
61
|
return stdout
|
|
45
62
|
.split("\n")
|
|
46
63
|
.map((line) => line.trim())
|
|
47
64
|
.filter((line) => line.length > 0);
|
|
48
65
|
}
|
|
66
|
+
export async function gitListTaskBranches(cwd, prefix) {
|
|
67
|
+
return await gitListBranchesByPrefixes(cwd, [prefix]);
|
|
68
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type MergedBranchCleanupResult = {
|
|
2
|
+
removedBranch: boolean;
|
|
3
|
+
removedWorktree: boolean;
|
|
4
|
+
worktreePath: string | null;
|
|
5
|
+
skippedReason: "outside_repo" | "current_worktree" | null;
|
|
6
|
+
};
|
|
7
|
+
export declare function cleanupMergedLocalBranch(opts: {
|
|
8
|
+
gitRoot: string;
|
|
9
|
+
branch: string;
|
|
10
|
+
worktreePathHint?: string | null;
|
|
11
|
+
}): Promise<MergedBranchCleanupResult>;
|
|
12
|
+
//# sourceMappingURL=merged-branch-cleanup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merged-branch-cleanup.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/merged-branch-cleanup.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,yBAAyB,GAAG;IACtC,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,EAAE,cAAc,GAAG,kBAAkB,GAAG,IAAI,CAAC;CAC3D,CAAC;AAEF,wBAAsB,wBAAwB,CAAC,IAAI,EAAE;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,GAAG,OAAO,CAAC,yBAAyB,CAAC,CA4CrC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { execFileAsync, gitEnv } from "./git.js";
|
|
2
|
+
import { gitBranchExists } from "./git-ops.js";
|
|
3
|
+
import { findWorktreeForBranch } from "./git-worktree.js";
|
|
4
|
+
import { isPathWithin, resolvePathFallback } from "./path.js";
|
|
5
|
+
export async function cleanupMergedLocalBranch(opts) {
|
|
6
|
+
const repoRoot = await resolvePathFallback(opts.gitRoot);
|
|
7
|
+
const discoveredWorktree = await findWorktreeForBranch(opts.gitRoot, opts.branch);
|
|
8
|
+
const rawWorktreePath = discoveredWorktree ?? opts.worktreePathHint ?? null;
|
|
9
|
+
const worktreePath = rawWorktreePath ? await resolvePathFallback(rawWorktreePath) : null;
|
|
10
|
+
if (worktreePath) {
|
|
11
|
+
if (!isPathWithin(repoRoot, worktreePath)) {
|
|
12
|
+
return {
|
|
13
|
+
removedBranch: false,
|
|
14
|
+
removedWorktree: false,
|
|
15
|
+
worktreePath,
|
|
16
|
+
skippedReason: "outside_repo",
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (worktreePath === repoRoot) {
|
|
20
|
+
return {
|
|
21
|
+
removedBranch: false,
|
|
22
|
+
removedWorktree: false,
|
|
23
|
+
worktreePath,
|
|
24
|
+
skippedReason: "current_worktree",
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
await execFileAsync("git", ["worktree", "remove", "--force", worktreePath], {
|
|
28
|
+
cwd: opts.gitRoot,
|
|
29
|
+
env: gitEnv(),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
let removedBranch = false;
|
|
33
|
+
if (await gitBranchExists(opts.gitRoot, opts.branch)) {
|
|
34
|
+
await execFileAsync("git", ["branch", "-D", opts.branch], {
|
|
35
|
+
cwd: opts.gitRoot,
|
|
36
|
+
env: gitEnv(),
|
|
37
|
+
});
|
|
38
|
+
removedBranch = true;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
removedBranch,
|
|
42
|
+
removedWorktree: Boolean(worktreePath),
|
|
43
|
+
worktreePath,
|
|
44
|
+
skippedReason: null,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommandContext } from "../shared/task-backend.js";
|
|
2
|
+
export declare function refreshBranchPrArtifactsAfterTaskCommit(opts: {
|
|
3
|
+
ctx: CommandContext;
|
|
4
|
+
cwd: string;
|
|
5
|
+
rootOverride?: string;
|
|
6
|
+
taskId: string;
|
|
7
|
+
quiet: boolean;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=post-commit-pr-artifacts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-commit-pr-artifacts.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/post-commit-pr-artifacts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AA2BhE,wBAAsB,uCAAuC,CAAC,IAAI,EAAE;IAClE,GAAG,EAAE,cAAc,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmChB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { warnMessage } from "../../cli/output.js";
|
|
2
|
+
import { normalizeGhTransportError } from "../shared/gh-transport.js";
|
|
3
|
+
import { execFileAsync, gitEnv } from "../shared/git.js";
|
|
4
|
+
import { ensurePrArtifactsSynced } from "../pr/internal/sync.js";
|
|
5
|
+
import { isTaskLocalOnlyAdvance } from "./task-local-freshness.js";
|
|
6
|
+
function isUnknownRevisionError(err) {
|
|
7
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
8
|
+
return (/unknown revision or path not in the working tree/i.test(message) ||
|
|
9
|
+
/bad revision/i.test(message) ||
|
|
10
|
+
/ambiguous argument/i.test(message));
|
|
11
|
+
}
|
|
12
|
+
async function resolveHeadParent(gitRoot) {
|
|
13
|
+
try {
|
|
14
|
+
const { stdout } = await execFileAsync("git", ["rev-parse", "HEAD^"], {
|
|
15
|
+
cwd: gitRoot,
|
|
16
|
+
env: gitEnv(),
|
|
17
|
+
});
|
|
18
|
+
const parent = stdout.trim();
|
|
19
|
+
return parent.length > 0 ? parent : null;
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
if (!isUnknownRevisionError(err))
|
|
23
|
+
throw err;
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export async function refreshBranchPrArtifactsAfterTaskCommit(opts) {
|
|
28
|
+
if (opts.ctx.config.workflow_mode !== "branch_pr")
|
|
29
|
+
return;
|
|
30
|
+
try {
|
|
31
|
+
const gitRoot = opts.ctx.resolvedProject.gitRoot;
|
|
32
|
+
const headParent = await resolveHeadParent(gitRoot);
|
|
33
|
+
if (await isTaskLocalOnlyAdvance({
|
|
34
|
+
gitRoot,
|
|
35
|
+
workflowDir: opts.ctx.config.paths.workflow_dir,
|
|
36
|
+
tasksPath: opts.ctx.config.paths.tasks_path,
|
|
37
|
+
taskId: opts.taskId,
|
|
38
|
+
fromRef: headParent,
|
|
39
|
+
toRef: "HEAD",
|
|
40
|
+
})) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
await ensurePrArtifactsSynced({
|
|
44
|
+
ctx: opts.ctx,
|
|
45
|
+
cwd: opts.cwd,
|
|
46
|
+
rootOverride: opts.rootOverride,
|
|
47
|
+
taskId: opts.taskId,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
if (opts.quiet)
|
|
52
|
+
return;
|
|
53
|
+
const detail = normalizeGhTransportError(err).trim();
|
|
54
|
+
const suffix = detail ? ` (${detail})` : "";
|
|
55
|
+
process.stderr.write(`${warnMessage(`task commit succeeded but PR artifacts refresh failed for ${opts.taskId}; run \`agentplane pr update ${opts.taskId}\`${suffix}`)}\n`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { type TaskPrMeta } from "@agentplaneorg/core";
|
|
2
2
|
export type PrMeta = TaskPrMeta;
|
|
3
|
+
export type ObservedGithubPrState = {
|
|
4
|
+
prNumber: number;
|
|
5
|
+
prUrl: string | null;
|
|
6
|
+
status: "OPEN" | "CLOSED" | "MERGED";
|
|
7
|
+
mergedAt?: string | null;
|
|
8
|
+
mergeCommit?: string | null;
|
|
9
|
+
base?: string | null;
|
|
10
|
+
headSha?: string | null;
|
|
11
|
+
};
|
|
3
12
|
export type PrArtifactTextState = {
|
|
4
13
|
diffstatText: string | null;
|
|
5
14
|
verifyLogText: string | null;
|
|
@@ -23,6 +32,16 @@ export declare function buildUpdatedPrMeta(opts: {
|
|
|
23
32
|
base?: string | null;
|
|
24
33
|
headSha?: string | null;
|
|
25
34
|
}): PrMeta;
|
|
35
|
+
export declare function resolvePrArtifactHeadSha(opts: {
|
|
36
|
+
previousHeadSha?: string | null;
|
|
37
|
+
currentHeadSha?: string | null;
|
|
38
|
+
preservePrevious: boolean;
|
|
39
|
+
}): string | undefined;
|
|
40
|
+
export declare function buildObservedGithubPrMeta(opts: {
|
|
41
|
+
meta: PrMeta;
|
|
42
|
+
observed: ObservedGithubPrState;
|
|
43
|
+
at: string;
|
|
44
|
+
}): PrMeta;
|
|
26
45
|
export declare function buildVerifiedPrMeta(opts: {
|
|
27
46
|
meta: PrMeta;
|
|
28
47
|
at: string;
|
|
@@ -46,6 +65,7 @@ export type ShellInvocation = {
|
|
|
46
65
|
};
|
|
47
66
|
export declare function resolveShellInvocation(command: string): ShellInvocation;
|
|
48
67
|
export declare function parsePrMeta(raw: string, taskId: string): PrMeta;
|
|
68
|
+
export declare function parsePrMetaForwardCompatible(raw: string, taskId: string): PrMeta;
|
|
49
69
|
export declare function extractLastVerifiedSha(logText: string): string | null;
|
|
50
70
|
export declare function appendVerifyLog(logPath: string, header: string, content: string): Promise<void>;
|
|
51
71
|
export declare function runShellCommand(command: string, cwd: string): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pr-meta.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/pr-meta.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAI1E,MAAM,MAAM,MAAM,GAAG,UAAU,CAAC;AAChC,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG;IAClD,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAOF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"pr-meta.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/pr-meta.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAI1E,MAAM,MAAM,MAAM,GAAG,UAAU,CAAC;AAChC,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAA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OAAO,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAqBD"}
|
|
@@ -18,8 +18,14 @@ export function buildOpenedPrMeta(opts) {
|
|
|
18
18
|
schema_version: 1,
|
|
19
19
|
task_id: opts.taskId,
|
|
20
20
|
branch: opts.branch,
|
|
21
|
+
pr_number: opts.previousMeta?.pr_number,
|
|
22
|
+
pr_url: opts.previousMeta?.pr_url,
|
|
21
23
|
created_at: opts.previousMeta?.created_at ?? opts.at,
|
|
22
24
|
updated_at: changed ? opts.at : (opts.previousMeta?.updated_at ?? opts.at),
|
|
25
|
+
status: opts.previousMeta?.status,
|
|
26
|
+
merge_strategy: opts.previousMeta?.merge_strategy,
|
|
27
|
+
merged_at: opts.previousMeta?.merged_at,
|
|
28
|
+
merge_commit: opts.previousMeta?.merge_commit,
|
|
23
29
|
last_verified_sha: opts.previousMeta?.last_verified_sha ?? null,
|
|
24
30
|
last_verified_at: opts.previousMeta?.last_verified_at ?? null,
|
|
25
31
|
verify: opts.previousMeta?.verify ?? { status: "skipped" },
|
|
@@ -43,6 +49,46 @@ export function buildUpdatedPrMeta(opts) {
|
|
|
43
49
|
last_verified_at: opts.meta.last_verified_at ?? null,
|
|
44
50
|
};
|
|
45
51
|
}
|
|
52
|
+
export function resolvePrArtifactHeadSha(opts) {
|
|
53
|
+
const previousHeadSha = asNonEmptyString(opts.previousHeadSha);
|
|
54
|
+
const currentHeadSha = asNonEmptyString(opts.currentHeadSha);
|
|
55
|
+
if (opts.preservePrevious && previousHeadSha)
|
|
56
|
+
return previousHeadSha;
|
|
57
|
+
return currentHeadSha ?? previousHeadSha;
|
|
58
|
+
}
|
|
59
|
+
export function buildObservedGithubPrMeta(opts) {
|
|
60
|
+
const nextStatus = opts.observed.status;
|
|
61
|
+
const nextHeadSha = opts.meta.head_sha ?? opts.observed.headSha ?? undefined;
|
|
62
|
+
const nextMeta = {
|
|
63
|
+
...opts.meta,
|
|
64
|
+
pr_number: opts.observed.prNumber,
|
|
65
|
+
pr_url: opts.observed.prUrl ?? opts.meta.pr_url,
|
|
66
|
+
status: nextStatus,
|
|
67
|
+
base: opts.observed.base ?? opts.meta.base,
|
|
68
|
+
head_sha: nextHeadSha,
|
|
69
|
+
updated_at: opts.meta.updated_at,
|
|
70
|
+
};
|
|
71
|
+
if (nextStatus === "MERGED") {
|
|
72
|
+
nextMeta.merged_at = opts.observed.mergedAt ?? opts.meta.merged_at;
|
|
73
|
+
nextMeta.merge_commit = opts.observed.mergeCommit ?? opts.meta.merge_commit;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
delete nextMeta.merged_at;
|
|
77
|
+
delete nextMeta.merge_commit;
|
|
78
|
+
delete nextMeta.merge_strategy;
|
|
79
|
+
}
|
|
80
|
+
const changed = nextMeta.pr_number !== opts.meta.pr_number ||
|
|
81
|
+
(nextMeta.pr_url ?? null) !== (opts.meta.pr_url ?? null) ||
|
|
82
|
+
nextMeta.status !== opts.meta.status ||
|
|
83
|
+
(nextMeta.base ?? null) !== (opts.meta.base ?? null) ||
|
|
84
|
+
(nextMeta.head_sha ?? null) !== (opts.meta.head_sha ?? null) ||
|
|
85
|
+
(nextMeta.merged_at ?? null) !== (opts.meta.merged_at ?? null) ||
|
|
86
|
+
(nextMeta.merge_commit ?? null) !== (opts.meta.merge_commit ?? null);
|
|
87
|
+
if (changed) {
|
|
88
|
+
nextMeta.updated_at = opts.at;
|
|
89
|
+
}
|
|
90
|
+
return nextMeta;
|
|
91
|
+
}
|
|
46
92
|
export function buildVerifiedPrMeta(opts) {
|
|
47
93
|
const verifiedSha = opts.meta.head_sha ?? null;
|
|
48
94
|
return {
|
|
@@ -96,6 +142,85 @@ export function parsePrMeta(raw, taskId) {
|
|
|
96
142
|
throw new Error("pr/meta.json task_id mismatch");
|
|
97
143
|
return meta;
|
|
98
144
|
}
|
|
145
|
+
function asNonEmptyString(value) {
|
|
146
|
+
if (typeof value !== "string")
|
|
147
|
+
return undefined;
|
|
148
|
+
const trimmed = value.trim();
|
|
149
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
150
|
+
}
|
|
151
|
+
function asOptionalInteger(value) {
|
|
152
|
+
return Number.isInteger(value) && Number(value) > 0 ? Number(value) : undefined;
|
|
153
|
+
}
|
|
154
|
+
function asVerifyStatus(value) {
|
|
155
|
+
if (!value || typeof value !== "object")
|
|
156
|
+
return undefined;
|
|
157
|
+
const status = asNonEmptyString(value.status);
|
|
158
|
+
if (status !== "pass" && status !== "fail" && status !== "skipped")
|
|
159
|
+
return undefined;
|
|
160
|
+
const command = asNonEmptyString(value.command);
|
|
161
|
+
return command ? { status, command } : { status };
|
|
162
|
+
}
|
|
163
|
+
function asMergeStrategy(value) {
|
|
164
|
+
const strategy = asNonEmptyString(value);
|
|
165
|
+
return strategy === "squash" || strategy === "merge" || strategy === "rebase"
|
|
166
|
+
? strategy
|
|
167
|
+
: undefined;
|
|
168
|
+
}
|
|
169
|
+
function buildForwardCompatiblePrMeta(parsed, taskId) {
|
|
170
|
+
if (parsed.schema_version !== 1)
|
|
171
|
+
return null;
|
|
172
|
+
if (asNonEmptyString(parsed.task_id) !== taskId)
|
|
173
|
+
return null;
|
|
174
|
+
const branch = asNonEmptyString(parsed.branch);
|
|
175
|
+
const createdAt = asNonEmptyString(parsed.created_at);
|
|
176
|
+
const updatedAt = asNonEmptyString(parsed.updated_at);
|
|
177
|
+
if (!branch || !createdAt || !updatedAt)
|
|
178
|
+
return null;
|
|
179
|
+
const statusCandidate = asNonEmptyString(parsed.status);
|
|
180
|
+
const status = statusCandidate === "OPEN" || statusCandidate === "CLOSED" || statusCandidate === "MERGED"
|
|
181
|
+
? statusCandidate
|
|
182
|
+
: undefined;
|
|
183
|
+
return {
|
|
184
|
+
schema_version: 1,
|
|
185
|
+
task_id: taskId,
|
|
186
|
+
branch,
|
|
187
|
+
pr_number: asOptionalInteger(parsed.pr_number),
|
|
188
|
+
pr_url: asNonEmptyString(parsed.pr_url),
|
|
189
|
+
created_at: createdAt,
|
|
190
|
+
updated_at: updatedAt,
|
|
191
|
+
status,
|
|
192
|
+
merge_strategy: asMergeStrategy(parsed.merge_strategy),
|
|
193
|
+
merged_at: asNonEmptyString(parsed.merged_at),
|
|
194
|
+
merge_commit: asNonEmptyString(parsed.merge_commit),
|
|
195
|
+
last_verified_sha: asNonEmptyString(parsed.last_verified_sha),
|
|
196
|
+
last_verified_at: asNonEmptyString(parsed.last_verified_at),
|
|
197
|
+
verify: asVerifyStatus(parsed.verify) ?? { status: "skipped" },
|
|
198
|
+
base: asNonEmptyString(parsed.base),
|
|
199
|
+
head_sha: asNonEmptyString(parsed.head_sha),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
export function parsePrMetaForwardCompatible(raw, taskId) {
|
|
203
|
+
let parsed;
|
|
204
|
+
try {
|
|
205
|
+
parsed = JSON.parse(raw);
|
|
206
|
+
}
|
|
207
|
+
catch (err) {
|
|
208
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
209
|
+
throw new Error(`JSON Parse error: ${message}`);
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
const meta = validateTaskPrMeta(parsed);
|
|
213
|
+
if (meta.task_id !== taskId)
|
|
214
|
+
throw new Error("pr/meta.json task_id mismatch");
|
|
215
|
+
return meta;
|
|
216
|
+
}
|
|
217
|
+
catch (err) {
|
|
218
|
+
const compat = buildForwardCompatiblePrMeta(parsed, taskId);
|
|
219
|
+
if (compat)
|
|
220
|
+
return compat;
|
|
221
|
+
throw err;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
99
224
|
export function extractLastVerifiedSha(logText) {
|
|
100
225
|
const regex = /verified_sha=([0-9a-f]{7,40})/gi;
|
|
101
226
|
let match = null;
|
|
@@ -29,11 +29,18 @@ export declare function loadCommandContext(opts: {
|
|
|
29
29
|
export declare function loadTaskFromContext(opts: {
|
|
30
30
|
ctx: CommandContext;
|
|
31
31
|
taskId: string;
|
|
32
|
+
preferBranchSnapshot?: boolean;
|
|
33
|
+
branchSnapshotBranch?: string | null;
|
|
32
34
|
}): Promise<TaskData>;
|
|
35
|
+
export declare function resolveTaskBranchFromContext(opts: {
|
|
36
|
+
ctx: CommandContext;
|
|
37
|
+
taskId: string;
|
|
38
|
+
}): Promise<string | null>;
|
|
33
39
|
export declare function loadTaskFromBranchSnapshot(opts: {
|
|
34
40
|
ctx: CommandContext;
|
|
35
41
|
taskId: string;
|
|
36
42
|
readmePath: string;
|
|
43
|
+
branch?: string | null;
|
|
37
44
|
}): Promise<TaskData | null>;
|
|
38
45
|
export declare function loadBackendTask(opts: {
|
|
39
46
|
ctx?: CommandContext;
|