agentplane 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/policy/governance.md +3 -4
- package/assets/policy/incidents.md +19 -88
- package/assets/policy/workflow.branch_pr.md +1 -1
- package/assets/policy/workflow.direct.md +2 -2
- package/bin/agentplane.js +56 -1
- package/bin/runtime-watch.js +1 -0
- package/bin/stale-dist-policy.d.ts +1 -1
- package/bin/stale-dist-policy.js +13 -0
- package/dist/.build-manifest.json +219 -154
- 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/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.map +1 -1
- package/dist/cli/run-cli.test-helpers.js +12 -0
- package/dist/commands/branch/cleanup-merged.d.ts +2 -0
- package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
- package/dist/commands/branch/cleanup-merged.js +132 -28
- package/dist/commands/branch/work-start.d.ts.map +1 -1
- package/dist/commands/branch/work-start.js +60 -1
- package/dist/commands/cleanup/merged.command.d.ts +2 -0
- package/dist/commands/cleanup/merged.command.d.ts.map +1 -1
- package/dist/commands/cleanup/merged.command.js +24 -0
- package/dist/commands/doctor/branch-pr.d.ts +4 -0
- package/dist/commands/doctor/branch-pr.d.ts.map +1 -0
- package/dist/commands/doctor/branch-pr.js +96 -0
- package/dist/commands/doctor/fixes.d.ts +5 -0
- package/dist/commands/doctor/fixes.d.ts.map +1 -1
- package/dist/commands/doctor/fixes.js +70 -0
- package/dist/commands/doctor.run.d.ts.map +1 -1
- package/dist/commands/doctor.run.js +6 -1
- package/dist/commands/finish.run.d.ts.map +1 -1
- package/dist/commands/finish.run.js +11 -0
- package/dist/commands/finish.spec.d.ts +11 -0
- package/dist/commands/finish.spec.d.ts.map +1 -1
- package/dist/commands/finish.spec.js +51 -0
- package/dist/commands/guard/impl/close-message.d.ts.map +1 -1
- package/dist/commands/guard/impl/close-message.js +23 -6
- package/dist/commands/guard/impl/commands.d.ts.map +1 -1
- package/dist/commands/guard/impl/commands.js +24 -2
- package/dist/commands/guard/impl/env.d.ts +1 -0
- package/dist/commands/guard/impl/env.d.ts.map +1 -1
- package/dist/commands/guard/impl/env.js +1 -0
- package/dist/commands/hooks/index.d.ts.map +1 -1
- package/dist/commands/hooks/index.js +98 -1
- package/dist/commands/incidents/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 +238 -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 +16 -0
- package/dist/commands/pr/integrate/internal/bootstrap-guidance.d.ts +8 -0
- package/dist/commands/pr/integrate/internal/bootstrap-guidance.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/bootstrap-guidance.js +59 -0
- package/dist/commands/pr/integrate/internal/finalize.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/finalize.js +40 -12
- package/dist/commands/pr/integrate/internal/merge.d.ts.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/prepare.d.ts +3 -2
- package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/prepare.js +101 -38
- package/dist/commands/pr/internal/freshness.d.ts +20 -0
- package/dist/commands/pr/internal/freshness.d.ts.map +1 -0
- package/dist/commands/pr/internal/freshness.js +50 -0
- package/dist/commands/pr/internal/gh-api.d.ts +6 -0
- package/dist/commands/pr/internal/gh-api.d.ts.map +1 -0
- package/dist/commands/pr/internal/gh-api.js +80 -0
- package/dist/commands/pr/internal/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 +462 -122
- 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 +13 -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 +59 -1
- package/dist/commands/release/apply.command.d.ts.map +1 -1
- package/dist/commands/release/apply.command.js +3 -17
- package/dist/commands/release/apply.preflight.d.ts.map +1 -1
- package/dist/commands/release/apply.preflight.js +1 -1
- package/dist/commands/shared/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/post-commit-pr-artifacts.d.ts +9 -0
- package/dist/commands/shared/post-commit-pr-artifacts.d.ts.map +1 -0
- package/dist/commands/shared/post-commit-pr-artifacts.js +22 -0
- package/dist/commands/shared/pr-meta.d.ts +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 +34 -22
- 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 +1 -0
- package/dist/commands/task/finish-shared.d.ts.map +1 -1
- package/dist/commands/task/finish-shared.js +55 -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 +414 -0
- package/dist/commands/task/hosted-close.command.d.ts.map +1 -1
- package/dist/commands/task/hosted-close.command.js +49 -1
- package/dist/commands/task/hosted-merge-sync.d.ts +38 -0
- package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
- package/dist/commands/task/hosted-merge-sync.js +249 -17
- package/dist/commands/task/index.d.ts +1 -0
- package/dist/commands/task/index.d.ts.map +1 -1
- package/dist/commands/task/index.js +1 -0
- package/dist/commands/task/new.d.ts +1 -0
- package/dist/commands/task/new.d.ts.map +1 -1
- package/dist/commands/task/new.js +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-ready.d.ts.map +1 -1
- package/dist/commands/task/start-ready.js +86 -0
- 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
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { mapCoreError } from "../../cli/error-map.js";
|
|
2
|
+
import { exitCodeForError } from "../../cli/exit-codes.js";
|
|
3
|
+
import { createCliEmitter, successMessage } from "../../cli/output.js";
|
|
4
|
+
import { CliError } from "../../shared/errors.js";
|
|
5
|
+
import { loadCommandContext } from "../shared/task-backend.js";
|
|
6
|
+
import { isGhNotFound, resolveDefaultGithubRepo, runGhApiJson, runGhApiNoOutput, } from "./internal/gh-api.js";
|
|
7
|
+
function ensureNonEmptyFlag(name, value) {
|
|
8
|
+
const trimmed = value.trim();
|
|
9
|
+
if (!trimmed) {
|
|
10
|
+
throw new CliError({
|
|
11
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
12
|
+
code: "E_USAGE",
|
|
13
|
+
message: `Invalid value for --${name}.`,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return trimmed;
|
|
17
|
+
}
|
|
18
|
+
export async function cmdPrClose(opts) {
|
|
19
|
+
try {
|
|
20
|
+
if (!Number.isInteger(opts.prNumber) || opts.prNumber <= 0) {
|
|
21
|
+
throw new CliError({
|
|
22
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
23
|
+
code: "E_USAGE",
|
|
24
|
+
message: "Invalid PR number.",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const output = createCliEmitter();
|
|
28
|
+
const ctx = opts.ctx ??
|
|
29
|
+
(await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
|
|
30
|
+
const commandCwd = ctx.resolvedProject.gitRoot;
|
|
31
|
+
const repo = opts.repo
|
|
32
|
+
? ensureNonEmptyFlag("repo", opts.repo)
|
|
33
|
+
: await resolveDefaultGithubRepo(commandCwd);
|
|
34
|
+
const comment = opts.comment?.trim() ? ensureNonEmptyFlag("comment", opts.comment) : null;
|
|
35
|
+
const pr = await runGhApiJson(commandCwd, [
|
|
36
|
+
`repos/${repo}/pulls/${opts.prNumber}`,
|
|
37
|
+
]);
|
|
38
|
+
if (!pr.number) {
|
|
39
|
+
throw new CliError({
|
|
40
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
41
|
+
code: "E_VALIDATION",
|
|
42
|
+
message: `GitHub pull request #${opts.prNumber} was not found in ${repo}.`,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (comment) {
|
|
46
|
+
await runGhApiNoOutput(commandCwd, [
|
|
47
|
+
`repos/${repo}/issues/${opts.prNumber}/comments`,
|
|
48
|
+
"-X",
|
|
49
|
+
"POST",
|
|
50
|
+
"-f",
|
|
51
|
+
`body=${comment}`,
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
const closed = await runGhApiJson(commandCwd, [
|
|
55
|
+
`repos/${repo}/pulls/${opts.prNumber}`,
|
|
56
|
+
"-X",
|
|
57
|
+
"PATCH",
|
|
58
|
+
"-f",
|
|
59
|
+
"state=closed",
|
|
60
|
+
]);
|
|
61
|
+
const headRepo = closed.head?.repo?.full_name?.trim() ?? pr.head?.repo?.full_name?.trim() ?? null;
|
|
62
|
+
const headRef = closed.head?.ref?.trim() ?? pr.head?.ref?.trim() ?? null;
|
|
63
|
+
let remoteBranchAction = "skipped";
|
|
64
|
+
if (opts.deleteRemoteBranch) {
|
|
65
|
+
if (!headRef) {
|
|
66
|
+
remoteBranchAction = "skipped-missing-head";
|
|
67
|
+
}
|
|
68
|
+
else if (headRepo && headRepo !== repo) {
|
|
69
|
+
remoteBranchAction = "skipped-fork";
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
try {
|
|
73
|
+
await runGhApiNoOutput(commandCwd, [
|
|
74
|
+
`repos/${repo}/git/refs/heads/${encodeURIComponent(headRef)}`,
|
|
75
|
+
"-X",
|
|
76
|
+
"DELETE",
|
|
77
|
+
]);
|
|
78
|
+
remoteBranchAction = "deleted";
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
if (isGhNotFound(err)) {
|
|
82
|
+
remoteBranchAction = "already-absent";
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const result = {
|
|
91
|
+
repo,
|
|
92
|
+
prNumber: opts.prNumber,
|
|
93
|
+
url: closed.html_url?.trim() ?? pr.html_url?.trim() ?? null,
|
|
94
|
+
state: closed.state?.trim() ?? pr.state?.trim() ?? "closed",
|
|
95
|
+
comment: comment ? "added" : "skipped",
|
|
96
|
+
remoteBranch: headRef,
|
|
97
|
+
remoteBranchAction,
|
|
98
|
+
};
|
|
99
|
+
output.report([
|
|
100
|
+
{ label: "repo", value: result.repo },
|
|
101
|
+
{ label: "state", value: result.state },
|
|
102
|
+
{ label: "url", value: result.url ?? "unknown" },
|
|
103
|
+
{ label: "comment", value: result.comment },
|
|
104
|
+
{ label: "remote_branch", value: result.remoteBranch ?? "unknown" },
|
|
105
|
+
{ label: "remote_branch_action", value: result.remoteBranchAction },
|
|
106
|
+
], {
|
|
107
|
+
header: successMessage("pr close", `#${result.prNumber}`),
|
|
108
|
+
});
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
if (err instanceof CliError)
|
|
113
|
+
throw err;
|
|
114
|
+
throw mapCoreError(err, { command: "pr close", root: opts.rootOverride ?? null });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -2,5 +2,7 @@ export { cmdPrOpen } from "./open.js";
|
|
|
2
2
|
export { cmdPrUpdate } from "./update.js";
|
|
3
3
|
export { cmdPrCheck } from "./check.js";
|
|
4
4
|
export { cmdPrNote } from "./note.js";
|
|
5
|
+
export { cmdPrClose } from "./close.js";
|
|
6
|
+
export { cmdPrCloseSuperseded } from "./close-superseded.js";
|
|
5
7
|
export { cmdIntegrate } from "./integrate.js";
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -2,4 +2,6 @@ export { cmdPrOpen } from "./open.js";
|
|
|
2
2
|
export { cmdPrUpdate } from "./update.js";
|
|
3
3
|
export { cmdPrCheck } from "./check.js";
|
|
4
4
|
export { cmdPrNote } from "./note.js";
|
|
5
|
+
export { cmdPrClose } from "./close.js";
|
|
6
|
+
export { cmdPrCloseSuperseded } from "./close-superseded.js";
|
|
5
7
|
export { cmdIntegrate } from "./integrate.js";
|
|
@@ -11,4 +11,11 @@ export declare function readAndValidatePrArtifacts(opts: {
|
|
|
11
11
|
}): Promise<{
|
|
12
12
|
verifyLogText: string | null;
|
|
13
13
|
}>;
|
|
14
|
+
export declare function ensureCommittedPrArtifactsOnBranch(opts: {
|
|
15
|
+
resolved: {
|
|
16
|
+
gitRoot: string;
|
|
17
|
+
};
|
|
18
|
+
prDir: string;
|
|
19
|
+
branch: string;
|
|
20
|
+
}): Promise<void>;
|
|
14
21
|
//# sourceMappingURL=artifacts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/integrate/artifacts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/integrate/artifacts.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAYnE,wBAAsB,0BAA0B,CAAC,IAAI,EAAE;IACrD,GAAG,EAAE,cAAc,CAAC;IACpB,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC;IACV,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC,CAkDD;AAED,wBAAsB,kCAAkC,CAAC,IAAI,EAAE;IAC7D,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkEhB"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { exitCodeForError } from "../../../cli/exit-codes.js";
|
|
3
3
|
import { CliError } from "../../../shared/errors.js";
|
|
4
|
-
import { readPrArtifact } from "../internal/pr-paths.js";
|
|
4
|
+
import { readPrArtifact, readPrArtifactFromBranch } from "../internal/pr-paths.js";
|
|
5
|
+
import { findWorktreeForBranch } from "../../shared/git-worktree.js";
|
|
5
6
|
import { validateReviewContents } from "../internal/review-template.js";
|
|
6
7
|
export async function readAndValidatePrArtifacts(opts) {
|
|
7
8
|
const readPrArtifactTyped = readPrArtifact;
|
|
@@ -9,6 +10,7 @@ export async function readAndValidatePrArtifacts(opts) {
|
|
|
9
10
|
const diffstatPath = path.join(prDir, "diffstat.txt");
|
|
10
11
|
const verifyLogPath = path.join(prDir, "verify.log");
|
|
11
12
|
const reviewPath = path.join(prDir, "review.md");
|
|
13
|
+
const worktreePath = await findWorktreeForBranch(opts.resolved.gitRoot, opts.branch);
|
|
12
14
|
const errors = [];
|
|
13
15
|
const relDiffstat = path.relative(opts.resolved.gitRoot, diffstatPath);
|
|
14
16
|
const relVerifyLog = path.relative(opts.resolved.gitRoot, verifyLogPath);
|
|
@@ -18,6 +20,7 @@ export async function readAndValidatePrArtifacts(opts) {
|
|
|
18
20
|
prDir,
|
|
19
21
|
fileName: "diffstat.txt",
|
|
20
22
|
branch: opts.branch,
|
|
23
|
+
worktreePath,
|
|
21
24
|
});
|
|
22
25
|
if (diffstatText === null)
|
|
23
26
|
errors.push(`Missing ${relDiffstat}`);
|
|
@@ -26,6 +29,7 @@ export async function readAndValidatePrArtifacts(opts) {
|
|
|
26
29
|
prDir,
|
|
27
30
|
fileName: "verify.log",
|
|
28
31
|
branch: opts.branch,
|
|
32
|
+
worktreePath,
|
|
29
33
|
});
|
|
30
34
|
if (verifyLogText === null)
|
|
31
35
|
errors.push(`Missing ${relVerifyLog}`);
|
|
@@ -34,6 +38,7 @@ export async function readAndValidatePrArtifacts(opts) {
|
|
|
34
38
|
prDir,
|
|
35
39
|
fileName: "review.md",
|
|
36
40
|
branch: opts.branch,
|
|
41
|
+
worktreePath,
|
|
37
42
|
});
|
|
38
43
|
if (reviewText === null)
|
|
39
44
|
errors.push(`Missing ${relReview}`);
|
|
@@ -48,3 +53,63 @@ export async function readAndValidatePrArtifacts(opts) {
|
|
|
48
53
|
}
|
|
49
54
|
return { verifyLogText };
|
|
50
55
|
}
|
|
56
|
+
export async function ensureCommittedPrArtifactsOnBranch(opts) {
|
|
57
|
+
const readCommittedPrArtifact = readPrArtifactFromBranch;
|
|
58
|
+
const { prDir } = opts;
|
|
59
|
+
const diffstatPath = path.join(prDir, "diffstat.txt");
|
|
60
|
+
const verifyLogPath = path.join(prDir, "verify.log");
|
|
61
|
+
const reviewPath = path.join(prDir, "review.md");
|
|
62
|
+
const metaPath = path.join(prDir, "meta.json");
|
|
63
|
+
const errors = [];
|
|
64
|
+
const relMeta = path.relative(opts.resolved.gitRoot, metaPath);
|
|
65
|
+
const relDiffstat = path.relative(opts.resolved.gitRoot, diffstatPath);
|
|
66
|
+
const relVerifyLog = path.relative(opts.resolved.gitRoot, verifyLogPath);
|
|
67
|
+
const relReview = path.relative(opts.resolved.gitRoot, reviewPath);
|
|
68
|
+
const metaText = await readCommittedPrArtifact({
|
|
69
|
+
resolved: opts.resolved,
|
|
70
|
+
prDir,
|
|
71
|
+
fileName: "meta.json",
|
|
72
|
+
branch: opts.branch,
|
|
73
|
+
});
|
|
74
|
+
if (metaText === null)
|
|
75
|
+
errors.push(`Missing committed ${relMeta} on branch ${opts.branch}`);
|
|
76
|
+
const diffstatText = await readCommittedPrArtifact({
|
|
77
|
+
resolved: opts.resolved,
|
|
78
|
+
prDir,
|
|
79
|
+
fileName: "diffstat.txt",
|
|
80
|
+
branch: opts.branch,
|
|
81
|
+
});
|
|
82
|
+
if (diffstatText === null) {
|
|
83
|
+
errors.push(`Missing committed ${relDiffstat} on branch ${opts.branch}`);
|
|
84
|
+
}
|
|
85
|
+
const verifyLogText = await readCommittedPrArtifact({
|
|
86
|
+
resolved: opts.resolved,
|
|
87
|
+
prDir,
|
|
88
|
+
fileName: "verify.log",
|
|
89
|
+
branch: opts.branch,
|
|
90
|
+
});
|
|
91
|
+
if (verifyLogText === null) {
|
|
92
|
+
errors.push(`Missing committed ${relVerifyLog} on branch ${opts.branch}`);
|
|
93
|
+
}
|
|
94
|
+
const reviewText = await readCommittedPrArtifact({
|
|
95
|
+
resolved: opts.resolved,
|
|
96
|
+
prDir,
|
|
97
|
+
fileName: "review.md",
|
|
98
|
+
branch: opts.branch,
|
|
99
|
+
});
|
|
100
|
+
if (reviewText === null) {
|
|
101
|
+
errors.push(`Missing committed ${relReview} on branch ${opts.branch}`);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
validateReviewContents(reviewText, errors);
|
|
105
|
+
}
|
|
106
|
+
if (errors.length > 0) {
|
|
107
|
+
throw new CliError({
|
|
108
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
109
|
+
code: "E_VALIDATION",
|
|
110
|
+
message: `Task branch ${opts.branch} is missing committed PR artifacts required for integrate.\n` +
|
|
111
|
+
`${errors.join("\n")}\n` +
|
|
112
|
+
"Commit the task README/PR artifacts on the task branch (for example via `agentplane pr open` + git add/commit) before rerunning integrate.",
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmd.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/integrate/cmd.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cmd.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/integrate/cmd.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AASnE,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC7C,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAkNlB"}
|
|
@@ -3,10 +3,12 @@ import { mapBackendError } from "../../../cli/error-map.js";
|
|
|
3
3
|
import { createCliEmitter } from "../../../cli/output.js";
|
|
4
4
|
import { CliError } from "../../../shared/errors.js";
|
|
5
5
|
import { cleanupIntegratedBranch } from "./internal/cleanup.js";
|
|
6
|
+
import { renderPostIntegrateBootstrapFailureGuidance, renderPostIntegrateBootstrapGuidance, shouldRecommendPostIntegrateBootstrap, } from "./internal/bootstrap-guidance.js";
|
|
6
7
|
import { execFileAsync, gitEnv } from "../../shared/git.js";
|
|
7
8
|
import { gitRevParse } from "../../shared/git-ops.js";
|
|
8
9
|
import { finalizeIntegrate } from "./internal/finalize.js";
|
|
9
10
|
import { runMergeCommit, runRebaseFastForward, runSquashMerge } from "./internal/merge.js";
|
|
11
|
+
import { maybeRunPostIntegrateBootstrap } from "./internal/post-integrate-bootstrap.js";
|
|
10
12
|
import { prepareIntegrate } from "./internal/prepare.js";
|
|
11
13
|
import { resolveWorktreeForIntegrate } from "./internal/worktree.js";
|
|
12
14
|
import { runVerifyCommands } from "./verify.js";
|
|
@@ -159,6 +161,20 @@ export async function cmdIntegrate(opts) {
|
|
|
159
161
|
tempWorktreePath = null;
|
|
160
162
|
createdTempWorktree = false;
|
|
161
163
|
}
|
|
164
|
+
if (shouldRecommendPostIntegrateBootstrap(changedPaths)) {
|
|
165
|
+
const bootstrapResult = await maybeRunPostIntegrateBootstrap({
|
|
166
|
+
gitRoot: resolved.gitRoot,
|
|
167
|
+
changedPaths,
|
|
168
|
+
});
|
|
169
|
+
if (!opts.quiet) {
|
|
170
|
+
if (bootstrapResult.status === "skipped") {
|
|
171
|
+
output.warn(renderPostIntegrateBootstrapGuidance());
|
|
172
|
+
}
|
|
173
|
+
else if (bootstrapResult.status === "failed") {
|
|
174
|
+
output.warn(renderPostIntegrateBootstrapFailureGuidance(bootstrapResult.error));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
162
178
|
return 0;
|
|
163
179
|
}
|
|
164
180
|
catch (err) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function shouldRecommendPostIntegrateBootstrap(changedPaths: string[]): boolean;
|
|
2
|
+
export declare function shouldAutoBootstrapAfterIntegrate(opts: {
|
|
3
|
+
changedPaths: string[];
|
|
4
|
+
gitRoot: string;
|
|
5
|
+
}): boolean;
|
|
6
|
+
export declare function renderPostIntegrateBootstrapGuidance(): string;
|
|
7
|
+
export declare function renderPostIntegrateBootstrapFailureGuidance(reason: string): string;
|
|
8
|
+
//# sourceMappingURL=bootstrap-guidance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap-guidance.d.ts","sourceRoot":"","sources":["../../../../../src/commands/pr/integrate/internal/bootstrap-guidance.ts"],"names":[],"mappings":"AA4CA,wBAAgB,qCAAqC,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAErF;AAED,wBAAgB,iCAAiC,CAAC,IAAI,EAAE;IACtD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CASV;AAED,wBAAgB,oCAAoC,IAAI,MAAM,CAK7D;AAED,wBAAgB,2CAA2C,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKlF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { isRuntimeRelevantWatchedFile } from "../../../../../bin/runtime-watch.js";
|
|
4
|
+
const WATCHED_RUNTIME_PACKAGES = [
|
|
5
|
+
{
|
|
6
|
+
packageRoot: "packages/agentplane",
|
|
7
|
+
watchedPaths: [
|
|
8
|
+
"src",
|
|
9
|
+
"bin/agentplane.js",
|
|
10
|
+
"bin/dist-guard.js",
|
|
11
|
+
"bin/runtime-context.js",
|
|
12
|
+
"bin/stale-dist-policy.js",
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
packageRoot: "packages/core",
|
|
17
|
+
watchedPaths: ["src"],
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
function normalizeRepoPath(filePath) {
|
|
21
|
+
return filePath.replaceAll("\\", "/");
|
|
22
|
+
}
|
|
23
|
+
function isWatchedRuntimeSourcePath(filePath) {
|
|
24
|
+
const normalized = normalizeRepoPath(filePath);
|
|
25
|
+
for (const watchedPackage of WATCHED_RUNTIME_PACKAGES) {
|
|
26
|
+
for (const watchedPath of watchedPackage.watchedPaths) {
|
|
27
|
+
if (watchedPath === "src") {
|
|
28
|
+
const sourcePrefix = `${watchedPackage.packageRoot}/src/`;
|
|
29
|
+
if (!normalized.startsWith(sourcePrefix))
|
|
30
|
+
continue;
|
|
31
|
+
const packageRelativePath = normalized.slice(watchedPackage.packageRoot.length + 1);
|
|
32
|
+
return isRuntimeRelevantWatchedFile(packageRelativePath);
|
|
33
|
+
}
|
|
34
|
+
if (normalized === `${watchedPackage.packageRoot}/${watchedPath}`) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
export function shouldRecommendPostIntegrateBootstrap(changedPaths) {
|
|
42
|
+
return changedPaths.some((changedPath) => isWatchedRuntimeSourcePath(changedPath));
|
|
43
|
+
}
|
|
44
|
+
export function shouldAutoBootstrapAfterIntegrate(opts) {
|
|
45
|
+
if (!shouldRecommendPostIntegrateBootstrap(opts.changedPaths)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return (existsSync(path.join(opts.gitRoot, "package.json")) &&
|
|
49
|
+
existsSync(path.join(opts.gitRoot, "packages", "agentplane", "package.json")) &&
|
|
50
|
+
existsSync(path.join(opts.gitRoot, "scripts", "bootstrap-framework-dev.mjs")));
|
|
51
|
+
}
|
|
52
|
+
export function renderPostIntegrateBootstrapGuidance() {
|
|
53
|
+
return ("This merge changed watched runtime sources. Run `bun run framework:dev:bootstrap` " +
|
|
54
|
+
"before the next command so the repo-local build stays current.");
|
|
55
|
+
}
|
|
56
|
+
export function renderPostIntegrateBootstrapFailureGuidance(reason) {
|
|
57
|
+
return ("This merge changed watched runtime sources and the automatic repo-local runtime refresh " +
|
|
58
|
+
`failed (${reason}). Run \`bun run framework:dev:bootstrap\` manually before the next command.`);
|
|
59
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finalize.d.ts","sourceRoot":"","sources":["../../../../../src/commands/pr/integrate/internal/finalize.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAiBrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"finalize.d.ts","sourceRoot":"","sources":["../../../../../src/commands/pr/integrate/internal/finalize.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAiBrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAUtE,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,GAAG,EAAE,cAAc,CAAC;IACpB,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IAEf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAE3B,aAAa,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,eAAe,EAAE,OAAO,CAAC;IAEzB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwGhB"}
|
|
@@ -8,11 +8,13 @@ import { gitDiffStat } from "../../../shared/git-diff.js";
|
|
|
8
8
|
import { appendVerifyLog, buildIntegratedPrMeta, parsePrMeta, } from "../../../shared/pr-meta.js";
|
|
9
9
|
import { readCommitInfo } from "../../../task/shared.js";
|
|
10
10
|
import { createTaskCloseCommit, writeFinishedTasks } from "../../../task/finish-shared.js";
|
|
11
|
+
import { collectTaskIncidents, renderIncidentCollectionPlanOutcome, } from "../../../incidents/shared.js";
|
|
11
12
|
function nowIso() {
|
|
12
13
|
return new Date().toISOString();
|
|
13
14
|
}
|
|
14
15
|
export async function finalizeIntegrate(opts) {
|
|
15
16
|
const output = createCliEmitter();
|
|
17
|
+
const taskAlreadyDone = String(opts.task.status || "TODO").toUpperCase() === "DONE";
|
|
16
18
|
if (!(await fileExists(opts.prDir))) {
|
|
17
19
|
throw new CliError({
|
|
18
20
|
exitCode: 3,
|
|
@@ -52,20 +54,45 @@ export async function finalizeIntegrate(opts) {
|
|
|
52
54
|
: "skipped";
|
|
53
55
|
const finishBody = `Verified: Integrated via ${opts.mergeStrategy}; verify=${verifyDesc}; pr=${path.relative(opts.gitRoot, opts.prDir)}.`;
|
|
54
56
|
const resultSummary = `integrate: ${opts.mergeStrategy} ${opts.branch}`;
|
|
55
|
-
|
|
56
|
-
await writeFinishedTasks({
|
|
57
|
+
await collectTaskIncidents({
|
|
57
58
|
ctx: opts.ctx,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
body: finishBody,
|
|
62
|
-
force: false,
|
|
63
|
-
resultProvided: true,
|
|
64
|
-
resultSummary,
|
|
65
|
-
riskLevel: undefined,
|
|
66
|
-
breaking: false,
|
|
67
|
-
taskCommitInfo,
|
|
59
|
+
taskId: opts.taskId,
|
|
60
|
+
task: opts.task,
|
|
61
|
+
write: false,
|
|
68
62
|
});
|
|
63
|
+
if (!taskAlreadyDone) {
|
|
64
|
+
const taskCommitInfo = await readCommitInfo(opts.gitRoot, opts.mergeHash);
|
|
65
|
+
await writeFinishedTasks({
|
|
66
|
+
ctx: opts.ctx,
|
|
67
|
+
loadedTasks: [{ taskId: opts.taskId, task: opts.task }],
|
|
68
|
+
metaTaskId: opts.taskId,
|
|
69
|
+
author: "INTEGRATOR",
|
|
70
|
+
body: finishBody,
|
|
71
|
+
force: false,
|
|
72
|
+
resultProvided: true,
|
|
73
|
+
resultSummary,
|
|
74
|
+
riskLevel: undefined,
|
|
75
|
+
breaking: false,
|
|
76
|
+
taskCommitInfo,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const collectedIncidents = await collectTaskIncidents({
|
|
80
|
+
ctx: opts.ctx,
|
|
81
|
+
taskId: opts.taskId,
|
|
82
|
+
task: opts.task,
|
|
83
|
+
write: true,
|
|
84
|
+
});
|
|
85
|
+
if (!opts.quiet) {
|
|
86
|
+
output.info(renderIncidentCollectionPlanOutcome(collectedIncidents.plan, {
|
|
87
|
+
wrote: collectedIncidents.wrote,
|
|
88
|
+
context: "finish",
|
|
89
|
+
promotedIds: collectedIncidents.plan.promotable.map((item) => item.entry.id),
|
|
90
|
+
registryPaths: collectedIncidents.registryPaths,
|
|
91
|
+
}));
|
|
92
|
+
if (taskAlreadyDone) {
|
|
93
|
+
output.info("task already DONE; integrating only missing PR metadata and close artifacts");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
69
96
|
await createTaskCloseCommit({
|
|
70
97
|
ctx: opts.ctx,
|
|
71
98
|
cwd: opts.cwd,
|
|
@@ -73,6 +100,7 @@ export async function finalizeIntegrate(opts) {
|
|
|
73
100
|
taskId: opts.taskId,
|
|
74
101
|
baseBranchOverride: opts.base,
|
|
75
102
|
quiet: opts.quiet,
|
|
103
|
+
allowPolicy: collectedIncidents.wrote,
|
|
76
104
|
});
|
|
77
105
|
if (!opts.quiet) {
|
|
78
106
|
output.success("integrate", opts.taskId, `merge=${opts.mergeHash.slice(0, 12)}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../../../src/commands/pr/integrate/internal/merge.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../../../src/commands/pr/integrate/internal/merge.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AA+JzD,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqFlB;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,GAAG,OAAO,CAAC,MAAM,CAAC,CA6BlB;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,eAAe,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,GAAG,OAAO,CAAC;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrD,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC,CA8DD"}
|
|
@@ -8,6 +8,20 @@ import { gitRevParse } from "../../../shared/git-ops.js";
|
|
|
8
8
|
import { buildGithubPrTitle } from "../../internal/review-template.js";
|
|
9
9
|
import { computeVerifyState, runVerifyCommands } from "../verify.js";
|
|
10
10
|
const noopPromise = () => Promise.resolve();
|
|
11
|
+
function integrateCommitEnv(taskId) {
|
|
12
|
+
return {
|
|
13
|
+
...gitEnv(),
|
|
14
|
+
AGENTPLANE_TASK_ID: taskId,
|
|
15
|
+
AGENTPLANE_ALLOW_BASE: "1",
|
|
16
|
+
AGENTPLANE_ALLOW_TASKS: "1",
|
|
17
|
+
AGENTPLANE_ALLOW_CONFIG: "1",
|
|
18
|
+
AGENTPLANE_DEV_ALLOW_STALE_DIST: "1",
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function isTaskArtifactPath(filePath) {
|
|
22
|
+
const normalized = filePath.replaceAll("\\", "/");
|
|
23
|
+
return normalized.startsWith(".agentplane/tasks/") || normalized.startsWith("tasks/");
|
|
24
|
+
}
|
|
11
25
|
function fallbackIntegrateSummary(opts) {
|
|
12
26
|
const suffix = extractTaskSuffix(opts.taskId);
|
|
13
27
|
return buildGithubPrTitle({
|
|
@@ -34,6 +48,16 @@ async function listUntrackedTaskArtifacts(opts) {
|
|
|
34
48
|
.map((line) => line.slice(3).trim())
|
|
35
49
|
.filter(Boolean);
|
|
36
50
|
}
|
|
51
|
+
async function listCommitChangedPaths(opts) {
|
|
52
|
+
const { stdout } = await execFileAsync("git", ["show", "--name-only", "--format=", opts.revision], {
|
|
53
|
+
cwd: opts.gitRoot,
|
|
54
|
+
env: gitEnv(),
|
|
55
|
+
});
|
|
56
|
+
return stdout
|
|
57
|
+
.split("\n")
|
|
58
|
+
.map((line) => line.trim())
|
|
59
|
+
.filter(Boolean);
|
|
60
|
+
}
|
|
37
61
|
async function moveCollidingTaskArtifacts(opts) {
|
|
38
62
|
const taskPrefix = `${opts.workflowDir.replaceAll("\\", "/")}/${opts.taskId}`;
|
|
39
63
|
const candidatePaths = opts.changedPaths.filter((changedPath) => changedPath === taskPrefix || changedPath.startsWith(`${taskPrefix}/`));
|
|
@@ -133,16 +157,20 @@ export async function runSquashMerge(opts) {
|
|
|
133
157
|
taskId: opts.taskId,
|
|
134
158
|
genericTokens: opts.genericTokens,
|
|
135
159
|
});
|
|
136
|
-
|
|
160
|
+
let shouldFallback = !subjectPolicy.ok;
|
|
161
|
+
if (!shouldFallback) {
|
|
162
|
+
const headPaths = await listCommitChangedPaths({
|
|
163
|
+
gitRoot: opts.gitRoot,
|
|
164
|
+
revision: opts.branch,
|
|
165
|
+
});
|
|
166
|
+
shouldFallback =
|
|
167
|
+
headPaths.length > 0 && headPaths.every((filePath) => isTaskArtifactPath(filePath));
|
|
168
|
+
}
|
|
169
|
+
if (shouldFallback) {
|
|
137
170
|
const suffix = extractTaskSuffix(opts.taskId);
|
|
138
171
|
subject = `🧩 ${suffix} integrate: ${fallbackIntegrateSummary(opts)}`;
|
|
139
172
|
}
|
|
140
|
-
const env =
|
|
141
|
-
...process.env,
|
|
142
|
-
AGENTPLANE_TASK_ID: opts.taskId,
|
|
143
|
-
AGENTPLANE_ALLOW_BASE: "1",
|
|
144
|
-
AGENTPLANE_ALLOW_TASKS: "0",
|
|
145
|
-
};
|
|
173
|
+
const env = integrateCommitEnv(opts.taskId);
|
|
146
174
|
try {
|
|
147
175
|
await execFileAsync("git", ["commit", "-m", subject], {
|
|
148
176
|
cwd: opts.gitRoot,
|
|
@@ -169,12 +197,7 @@ export async function runMergeCommit(opts) {
|
|
|
169
197
|
taskId: opts.taskId,
|
|
170
198
|
changedPaths: opts.changedPaths,
|
|
171
199
|
});
|
|
172
|
-
const env =
|
|
173
|
-
...process.env,
|
|
174
|
-
AGENTPLANE_TASK_ID: opts.taskId,
|
|
175
|
-
AGENTPLANE_ALLOW_BASE: "1",
|
|
176
|
-
AGENTPLANE_ALLOW_TASKS: "0",
|
|
177
|
-
};
|
|
200
|
+
const env = integrateCommitEnv(opts.taskId);
|
|
178
201
|
try {
|
|
179
202
|
await execFileAsync("git", [
|
|
180
203
|
"merge",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type PostIntegrateBootstrapResult = {
|
|
2
|
+
status: "skipped";
|
|
3
|
+
} | {
|
|
4
|
+
status: "ran";
|
|
5
|
+
} | {
|
|
6
|
+
status: "failed";
|
|
7
|
+
error: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function maybeRunPostIntegrateBootstrap(opts: {
|
|
10
|
+
gitRoot: string;
|
|
11
|
+
changedPaths: string[];
|
|
12
|
+
}): Promise<PostIntegrateBootstrapResult>;
|
|
13
|
+
//# sourceMappingURL=post-integrate-bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-integrate-bootstrap.d.ts","sourceRoot":"","sources":["../../../../../src/commands/pr/integrate/internal/post-integrate-bootstrap.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,4BAA4B,GACpC;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,KAAK,CAAA;CAAE,GACjB;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAUxC,wBAAsB,8BAA8B,CAAC,IAAI,EAAE;IACzD,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAcxC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { execFileAsync } from "../../../shared/git.js";
|
|
2
|
+
import { shouldAutoBootstrapAfterIntegrate } from "./bootstrap-guidance.js";
|
|
3
|
+
function compactError(err) {
|
|
4
|
+
if (err instanceof Error) {
|
|
5
|
+
const text = err.message.trim();
|
|
6
|
+
return text.length > 0 ? text : err.name;
|
|
7
|
+
}
|
|
8
|
+
return String(err);
|
|
9
|
+
}
|
|
10
|
+
export async function maybeRunPostIntegrateBootstrap(opts) {
|
|
11
|
+
if (!shouldAutoBootstrapAfterIntegrate(opts)) {
|
|
12
|
+
return { status: "skipped" };
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
await execFileAsync("bun", ["run", "framework:dev:bootstrap"], {
|
|
16
|
+
cwd: opts.gitRoot,
|
|
17
|
+
env: { ...process.env },
|
|
18
|
+
maxBuffer: 50 * 1024 * 1024,
|
|
19
|
+
});
|
|
20
|
+
return { status: "ran" };
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
return { status: "failed", error: compactError(err) };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TaskData } from "../../../../backends/task-backend.js";
|
|
2
|
+
import { type CommandContext } from "../../../shared/task-backend.js";
|
|
2
3
|
import { type PrMeta } from "../../../shared/pr-meta.js";
|
|
3
4
|
export type PreparedIntegrate = {
|
|
4
5
|
ctx: CommandContext;
|
|
5
6
|
resolved: CommandContext["resolvedProject"];
|
|
6
7
|
loadedConfig: CommandContext["config"];
|
|
7
|
-
task:
|
|
8
|
+
task: TaskData;
|
|
8
9
|
baseBranch: string;
|
|
9
10
|
currentBranch: string;
|
|
10
11
|
prDir: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../../../../src/commands/pr/integrate/internal/prepare.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../../../../src/commands/pr/integrate/internal/prepare.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAUrE,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,iCAAiC,CAAC;AAWzC,OAAO,EAAgC,KAAK,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGvF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,cAAc,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAC;IAC5C,YAAY,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,EAAE,QAAQ,CAAC;IAEf,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IAEtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IAEtB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IAEb,aAAa,EAAE,MAAM,CAAC;IAEtB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;CACpB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAyO7B"}
|