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
|
@@ -3,6 +3,15 @@ import { extractTaskSuffix } from "@agentplaneorg/core";
|
|
|
3
3
|
import { exitCodeForError } from "../../../cli/exit-codes.js";
|
|
4
4
|
import { CliError } from "../../../shared/errors.js";
|
|
5
5
|
import { execFileAsync, gitEnv } from "../../shared/git.js";
|
|
6
|
+
function isMissingCommitObjectError(err) {
|
|
7
|
+
const stderr = err.stderr;
|
|
8
|
+
const text = err instanceof Error
|
|
9
|
+
? [err.message, typeof stderr === "string" ? stderr : ""]
|
|
10
|
+
.filter((part) => part.trim().length > 0)
|
|
11
|
+
.join("\n")
|
|
12
|
+
: String(err);
|
|
13
|
+
return (/bad object/i.test(text) || /unknown revision/i.test(text) || /ambiguous argument/i.test(text));
|
|
14
|
+
}
|
|
6
15
|
function uniqSorted(values) {
|
|
7
16
|
return [...new Set(values)].toSorted((a, b) => a.localeCompare(b));
|
|
8
17
|
}
|
|
@@ -29,12 +38,20 @@ function clampList(items, max) {
|
|
|
29
38
|
return items.slice(0, Math.max(0, Math.floor(max)));
|
|
30
39
|
}
|
|
31
40
|
async function gitNumstatForCommit(gitRoot, commit) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
let stdout;
|
|
42
|
+
try {
|
|
43
|
+
({ stdout } = await execFileAsync("git", ["show", "--numstat", "--format=", commit], {
|
|
44
|
+
cwd: gitRoot,
|
|
45
|
+
env: gitEnv(),
|
|
46
|
+
encoding: "buffer",
|
|
47
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
if (isMissingCommitObjectError(err))
|
|
52
|
+
return [];
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
38
55
|
const text = Buffer.isBuffer(stdout) ? stdout.toString("utf8") : String(stdout);
|
|
39
56
|
const entries = [];
|
|
40
57
|
for (const line of text.split("\n")) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/commands.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/commands.ts"],"names":[],"mappings":"AAaA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAQvF,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA8SxE,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBlB;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBlB;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAa9E;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,GAAG,OAAO,CAAC,MAAM,CAAC,CAsPlB"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { extractTaskSuffix } from "@agentplaneorg/core";
|
|
3
4
|
import { resolveTaskIndexPath } from "../../../backends/task-index.js";
|
|
4
5
|
import { mapCoreError } from "../../../cli/error-map.js";
|
|
5
6
|
import { infoMessage, successMessage } from "../../../cli/output.js";
|
|
6
7
|
import { stripAnsi } from "../../../cli/shared/ansi.js";
|
|
7
8
|
import { withDiagnosticContext } from "../../../shared/diagnostics.js";
|
|
8
9
|
import { CliError } from "../../../shared/errors.js";
|
|
10
|
+
import { refreshBranchPrArtifactsAfterTaskCommit } from "../../shared/post-commit-pr-artifacts.js";
|
|
11
|
+
import { isTaskLocalAdvancePath } from "../../shared/task-local-freshness.js";
|
|
9
12
|
import { loadCommandContext } from "../../shared/task-backend.js";
|
|
10
13
|
import { loadTaskFromContext } from "../../shared/task-backend.js";
|
|
11
14
|
import { execFileAsync, gitEnv } from "../../shared/git.js";
|
|
@@ -110,6 +113,64 @@ function detectCommitFailureSignal(output) {
|
|
|
110
113
|
}
|
|
111
114
|
return null;
|
|
112
115
|
}
|
|
116
|
+
function taskArtifactRefreshCommitMessage(taskId) {
|
|
117
|
+
return `📝 ${extractTaskSuffix(taskId)} task: refresh PR artifacts`;
|
|
118
|
+
}
|
|
119
|
+
async function commitRefreshedTaskArtifacts(opts) {
|
|
120
|
+
const changedPaths = await opts.ctx.git.statusChangedPaths();
|
|
121
|
+
const taskArtifactPaths = changedPaths.filter((relPath) => isTaskLocalAdvancePath({
|
|
122
|
+
workflowDir: opts.ctx.config.paths.workflow_dir,
|
|
123
|
+
taskId: opts.taskId,
|
|
124
|
+
tasksPath: opts.ctx.config.paths.tasks_path,
|
|
125
|
+
relPath,
|
|
126
|
+
}));
|
|
127
|
+
if (taskArtifactPaths.length === 0)
|
|
128
|
+
return false;
|
|
129
|
+
await stageAllowlist({
|
|
130
|
+
ctx: opts.ctx,
|
|
131
|
+
allow: [],
|
|
132
|
+
allowTasks: true,
|
|
133
|
+
allowPolicy: false,
|
|
134
|
+
allowConfig: false,
|
|
135
|
+
allowHooks: false,
|
|
136
|
+
allowCI: false,
|
|
137
|
+
tasksPath: opts.ctx.config.paths.tasks_path,
|
|
138
|
+
workflowDir: opts.ctx.config.paths.workflow_dir,
|
|
139
|
+
taskId: opts.taskId,
|
|
140
|
+
allowTaskOnly: true,
|
|
141
|
+
emptyAllowMessage: "PR artifact refresh produced no task-local files to stage for the follow-up commit.",
|
|
142
|
+
noMatchMessage: "PR artifact refresh produced changes outside the active task artifact scope; inspect the working tree before retrying the commit flow.",
|
|
143
|
+
});
|
|
144
|
+
const message = taskArtifactRefreshCommitMessage(opts.taskId);
|
|
145
|
+
await guardCommitCheck({
|
|
146
|
+
ctx: opts.ctx,
|
|
147
|
+
cwd: opts.cwd,
|
|
148
|
+
rootOverride: opts.rootOverride,
|
|
149
|
+
baseBranchOverride: null,
|
|
150
|
+
taskId: opts.taskId,
|
|
151
|
+
message,
|
|
152
|
+
allow: [],
|
|
153
|
+
allowBase: false,
|
|
154
|
+
allowTasks: true,
|
|
155
|
+
allowPolicy: false,
|
|
156
|
+
allowConfig: false,
|
|
157
|
+
allowHooks: false,
|
|
158
|
+
allowCI: false,
|
|
159
|
+
requireClean: true,
|
|
160
|
+
quiet: opts.quiet,
|
|
161
|
+
});
|
|
162
|
+
const env = buildGitCommitEnv({
|
|
163
|
+
taskId: opts.taskId,
|
|
164
|
+
allowTasks: true,
|
|
165
|
+
allowBase: false,
|
|
166
|
+
allowPolicy: false,
|
|
167
|
+
allowConfig: false,
|
|
168
|
+
allowHooks: false,
|
|
169
|
+
allowCI: false,
|
|
170
|
+
});
|
|
171
|
+
await opts.ctx.git.commit({ message, env });
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
113
174
|
function commitFailureDiagnostic(phase, output) {
|
|
114
175
|
const signal = detectCommitFailureSignal(output);
|
|
115
176
|
if (signal === "formatter") {
|
|
@@ -325,11 +386,26 @@ export async function cmdCommit(opts) {
|
|
|
325
386
|
}
|
|
326
387
|
return 0;
|
|
327
388
|
}
|
|
389
|
+
if (opts.closeStageTaskArtifacts === true) {
|
|
390
|
+
if (opts.closeRefreshTaskArtifacts !== false) {
|
|
391
|
+
await refreshBranchPrArtifactsAfterTaskCommit({
|
|
392
|
+
ctx,
|
|
393
|
+
cwd: opts.cwd,
|
|
394
|
+
rootOverride: opts.rootOverride,
|
|
395
|
+
taskId: opts.taskId,
|
|
396
|
+
quiet: opts.quiet,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
// Artifact refresh writes tracked task files on disk; invalidate the memoized
|
|
400
|
+
// porcelain snapshot so staging/cleanliness checks see the current task artifact state.
|
|
401
|
+
ctx.git.invalidateStatus();
|
|
402
|
+
}
|
|
328
403
|
await (opts.closeStageTaskArtifacts === true
|
|
329
404
|
? stageAllowlist({
|
|
330
405
|
ctx,
|
|
331
406
|
allow: [],
|
|
332
407
|
allowTasks: true,
|
|
408
|
+
allowPolicy: opts.allowPolicy,
|
|
333
409
|
tasksPath: ctx.config.paths.tasks_path,
|
|
334
410
|
workflowDir: ctx.config.paths.workflow_dir,
|
|
335
411
|
taskId: opts.taskId,
|
|
@@ -350,7 +426,7 @@ export async function cmdCommit(opts) {
|
|
|
350
426
|
allow: [],
|
|
351
427
|
allowBase: opts.allowBase,
|
|
352
428
|
allowTasks: true,
|
|
353
|
-
allowPolicy:
|
|
429
|
+
allowPolicy: opts.allowPolicy,
|
|
354
430
|
allowConfig: false,
|
|
355
431
|
allowHooks: false,
|
|
356
432
|
allowCI: false,
|
|
@@ -361,10 +437,11 @@ export async function cmdCommit(opts) {
|
|
|
361
437
|
taskId: opts.taskId,
|
|
362
438
|
allowTasks: true,
|
|
363
439
|
allowBase: opts.allowBase,
|
|
364
|
-
allowPolicy:
|
|
440
|
+
allowPolicy: opts.allowPolicy,
|
|
365
441
|
allowConfig: false,
|
|
366
442
|
allowHooks: false,
|
|
367
443
|
allowCI: false,
|
|
444
|
+
allowStaleDist: true,
|
|
368
445
|
});
|
|
369
446
|
await ctx.git.commit({ message: msg.subject, body: msg.body, env });
|
|
370
447
|
if (!opts.quiet) {
|
|
@@ -437,6 +514,21 @@ export async function cmdCommit(opts) {
|
|
|
437
514
|
allowCI: opts.allowCI,
|
|
438
515
|
});
|
|
439
516
|
await ctx.git.commit({ message: opts.message, env });
|
|
517
|
+
await refreshBranchPrArtifactsAfterTaskCommit({
|
|
518
|
+
ctx,
|
|
519
|
+
cwd: opts.cwd,
|
|
520
|
+
rootOverride: opts.rootOverride,
|
|
521
|
+
taskId: opts.taskId,
|
|
522
|
+
quiet: opts.quiet,
|
|
523
|
+
});
|
|
524
|
+
ctx.git.invalidateStatus();
|
|
525
|
+
await commitRefreshedTaskArtifacts({
|
|
526
|
+
ctx,
|
|
527
|
+
cwd: opts.cwd,
|
|
528
|
+
rootOverride: opts.rootOverride,
|
|
529
|
+
taskId: opts.taskId,
|
|
530
|
+
quiet: opts.quiet,
|
|
531
|
+
});
|
|
440
532
|
if (!opts.quiet) {
|
|
441
533
|
const { hash, subject } = await ctx.git.headHashSubject();
|
|
442
534
|
process.stdout.write(`${successMessage("committed", `${hash?.slice(0, 12) ?? ""} ${subject ?? ""}`.trim(), autoStaged.length > 0 ? `staged=${autoStaged.join(", ")}` : undefined)}\n`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/env.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/env.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,MAAM,CAAC,UAAU,CAcpB"}
|
|
@@ -10,5 +10,6 @@ export function buildGitCommitEnv(opts) {
|
|
|
10
10
|
AGENTPLANE_ALLOW_CONFIG: opts.allowConfig ? "1" : "0",
|
|
11
11
|
AGENTPLANE_ALLOW_HOOKS: opts.allowHooks ? "1" : "0",
|
|
12
12
|
AGENTPLANE_ALLOW_CI: opts.allowCI ? "1" : "0",
|
|
13
|
+
...(opts.allowStaleDist ? { AGENTPLANE_DEV_ALLOW_STALE_DIST: "1" } : null),
|
|
13
14
|
};
|
|
14
15
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const HOOK_NAMES: readonly ["commit-msg", "pre-commit", "pre-push"];
|
|
1
|
+
export declare const HOOK_NAMES: readonly ["commit-msg", "pre-commit", "pre-push", "post-merge"];
|
|
2
2
|
export declare function cmdHooksInstall(opts: {
|
|
3
3
|
cwd: string;
|
|
4
4
|
rootOverride?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/hooks/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/hooks/index.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,UAAU,iEAAkE,CAAC;AA8K1F,wBAAsB,eAAe,CAAC,IAAI,EAAE;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmClB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CA4BlB;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoLlB"}
|
|
@@ -1,18 +1,32 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
1
2
|
import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
2
3
|
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
3
5
|
import { loadConfig, resolveBaseBranch, resolveProject } from "@agentplaneorg/core";
|
|
4
6
|
import { evaluatePolicy } from "../../policy/evaluate.js";
|
|
5
7
|
import { mapBackendError, mapCoreError } from "../../cli/error-map.js";
|
|
6
8
|
import { fileExists } from "../../cli/fs-utils.js";
|
|
7
9
|
import { infoMessage, successMessage } from "../../cli/output.js";
|
|
8
10
|
import { CliError } from "../../shared/errors.js";
|
|
11
|
+
import { cmdCleanupMerged } from "../branch/index.js";
|
|
9
12
|
import { GitContext } from "../shared/git-context.js";
|
|
10
13
|
import { throwIfPolicyDenied } from "../shared/policy-deny.js";
|
|
11
14
|
import { gitCurrentBranch, gitRevParse } from "../shared/git-ops.js";
|
|
15
|
+
import { parseTaskIdFromBranch, parseTaskIdFromCloseBranch } from "../shared/git-worktree.js";
|
|
12
16
|
import { isPathWithin } from "../shared/path.js";
|
|
17
|
+
import { loadCommandContext } from "../shared/task-backend.js";
|
|
13
18
|
const HOOK_MARKER = "agentplane-hook";
|
|
14
19
|
const SHIM_MARKER = "agentplane-hook-shim";
|
|
15
|
-
export const HOOK_NAMES = ["commit-msg", "pre-commit", "pre-push"];
|
|
20
|
+
export const HOOK_NAMES = ["commit-msg", "pre-commit", "pre-push", "post-merge"];
|
|
21
|
+
async function inferTaskIdFromBranchContext(opts) {
|
|
22
|
+
try {
|
|
23
|
+
const branch = await gitCurrentBranch(opts.gitRoot);
|
|
24
|
+
return (parseTaskIdFromBranch(opts.taskPrefix, branch) ?? parseTaskIdFromCloseBranch(branch) ?? "");
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return "";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
16
30
|
async function resolveGitHooksDir(cwd) {
|
|
17
31
|
const repoRoot = await gitRevParse(cwd, ["--show-toplevel"]);
|
|
18
32
|
const commonDirRaw = await gitRevParse(cwd, ["--git-common-dir"]);
|
|
@@ -71,14 +85,14 @@ function shimScriptText() {
|
|
|
71
85
|
"set -e",
|
|
72
86
|
'SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"',
|
|
73
87
|
'REPO_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")"',
|
|
74
|
-
'ENV_BIN="${AGENTPLANE_HOOK_RUNNER:-}"',
|
|
75
|
-
'if [ -n "$ENV_BIN" ] && command -v node >/dev/null 2>&1 && [ -f "$ENV_BIN" ]; then',
|
|
76
|
-
' exec node "$ENV_BIN" "$@"',
|
|
77
|
-
"fi",
|
|
78
88
|
'LOCAL_BIN="$REPO_ROOT/packages/agentplane/bin/agentplane.js"',
|
|
79
89
|
'if command -v node >/dev/null 2>&1 && [ -f "$LOCAL_BIN" ]; then',
|
|
80
90
|
' exec node "$LOCAL_BIN" "$@"',
|
|
81
91
|
"fi",
|
|
92
|
+
'ENV_BIN="${AGENTPLANE_HOOK_RUNNER:-}"',
|
|
93
|
+
'if [ -n "$ENV_BIN" ] && command -v node >/dev/null 2>&1 && [ -f "$ENV_BIN" ]; then',
|
|
94
|
+
' exec node "$ENV_BIN" "$@"',
|
|
95
|
+
"fi",
|
|
82
96
|
"if command -v agentplane >/dev/null 2>&1; then",
|
|
83
97
|
' exec agentplane "$@"',
|
|
84
98
|
"fi",
|
|
@@ -116,6 +130,47 @@ function readCommitSubject(message) {
|
|
|
116
130
|
}
|
|
117
131
|
return "";
|
|
118
132
|
}
|
|
133
|
+
function resolveBundledPrePushHookScriptPath() {
|
|
134
|
+
return fileURLToPath(new URL("../../../../../scripts/run-pre-push-hook.mjs", import.meta.url));
|
|
135
|
+
}
|
|
136
|
+
async function readHookStdinUtf8(timeoutMs = 25) {
|
|
137
|
+
if (process.stdin.isTTY)
|
|
138
|
+
return "";
|
|
139
|
+
const chunks = [];
|
|
140
|
+
const consume = () => {
|
|
141
|
+
let chunk = process.stdin.read();
|
|
142
|
+
while (chunk !== null) {
|
|
143
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
|
|
144
|
+
chunk = process.stdin.read();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
consume();
|
|
148
|
+
if (chunks.length > 0 || process.stdin.readableEnded) {
|
|
149
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
150
|
+
}
|
|
151
|
+
await new Promise((resolve) => {
|
|
152
|
+
const finish = () => {
|
|
153
|
+
clearTimeout(timer);
|
|
154
|
+
process.stdin.off("readable", onReadable);
|
|
155
|
+
process.stdin.off("end", onEnd);
|
|
156
|
+
resolve();
|
|
157
|
+
};
|
|
158
|
+
const onReadable = () => {
|
|
159
|
+
consume();
|
|
160
|
+
finish();
|
|
161
|
+
};
|
|
162
|
+
const onEnd = () => {
|
|
163
|
+
consume();
|
|
164
|
+
finish();
|
|
165
|
+
};
|
|
166
|
+
const timer = setTimeout(finish, timeoutMs);
|
|
167
|
+
process.stdin.on("readable", onReadable);
|
|
168
|
+
process.stdin.on("end", onEnd);
|
|
169
|
+
process.stdin.resume();
|
|
170
|
+
});
|
|
171
|
+
consume();
|
|
172
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
173
|
+
}
|
|
119
174
|
export async function cmdHooksInstall(opts) {
|
|
120
175
|
try {
|
|
121
176
|
const resolved = await resolveProject({
|
|
@@ -201,7 +256,11 @@ export async function cmdHooksRun(opts) {
|
|
|
201
256
|
rootOverride: opts.rootOverride ?? null,
|
|
202
257
|
});
|
|
203
258
|
const loaded = await loadConfig(resolved.agentplaneDir);
|
|
204
|
-
const taskId = (process.env.AGENTPLANE_TASK_ID ?? "").trim()
|
|
259
|
+
const taskId = (process.env.AGENTPLANE_TASK_ID ?? "").trim() ||
|
|
260
|
+
(await inferTaskIdFromBranchContext({
|
|
261
|
+
gitRoot: resolved.gitRoot,
|
|
262
|
+
taskPrefix: loaded.config.branch.task_prefix,
|
|
263
|
+
}));
|
|
205
264
|
const statusTo = (process.env.AGENTPLANE_STATUS_TO ?? "").trim().toUpperCase();
|
|
206
265
|
const emoji = subject.split(/\s+/).find(Boolean) ?? "";
|
|
207
266
|
if (taskId && statusTo === "DONE" && emoji !== "✅") {
|
|
@@ -269,9 +328,83 @@ export async function cmdHooksRun(opts) {
|
|
|
269
328
|
throwIfPolicyDenied(res);
|
|
270
329
|
return 0;
|
|
271
330
|
}
|
|
331
|
+
if (opts.hook === "pre-push") {
|
|
332
|
+
const resolved = await resolveProject({
|
|
333
|
+
cwd: opts.cwd,
|
|
334
|
+
rootOverride: opts.rootOverride ?? null,
|
|
335
|
+
});
|
|
336
|
+
const scriptPath = resolveBundledPrePushHookScriptPath();
|
|
337
|
+
if (!(await fileExists(scriptPath))) {
|
|
338
|
+
throw new CliError({
|
|
339
|
+
exitCode: 2,
|
|
340
|
+
code: "E_USAGE",
|
|
341
|
+
message: `Missing pre-push hook script: ${scriptPath}`,
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
const result = spawnSync("node", [scriptPath], {
|
|
345
|
+
cwd: resolved.gitRoot,
|
|
346
|
+
env: process.env,
|
|
347
|
+
encoding: "utf8",
|
|
348
|
+
input: await readHookStdinUtf8(),
|
|
349
|
+
stdio: ["pipe", "inherit", "inherit"],
|
|
350
|
+
});
|
|
351
|
+
if (result.error)
|
|
352
|
+
throw result.error;
|
|
353
|
+
return result.status ?? (result.signal ? 1 : 0);
|
|
354
|
+
}
|
|
355
|
+
if (opts.hook === "post-merge") {
|
|
356
|
+
try {
|
|
357
|
+
const ctx = await loadCommandContext({
|
|
358
|
+
cwd: opts.cwd,
|
|
359
|
+
rootOverride: opts.rootOverride ?? null,
|
|
360
|
+
});
|
|
361
|
+
if (ctx.config.workflow_mode !== "branch_pr")
|
|
362
|
+
return 0;
|
|
363
|
+
const baseBranch = await resolveBaseBranch({
|
|
364
|
+
cwd: opts.cwd,
|
|
365
|
+
rootOverride: opts.rootOverride ?? null,
|
|
366
|
+
cliBaseOpt: null,
|
|
367
|
+
mode: ctx.config.workflow_mode,
|
|
368
|
+
});
|
|
369
|
+
if (!baseBranch)
|
|
370
|
+
return 0;
|
|
371
|
+
const currentBranch = await gitCurrentBranch(ctx.resolvedProject.gitRoot);
|
|
372
|
+
if (currentBranch !== baseBranch)
|
|
373
|
+
return 0;
|
|
374
|
+
return await cmdCleanupMerged({
|
|
375
|
+
ctx,
|
|
376
|
+
cwd: opts.cwd,
|
|
377
|
+
rootOverride: opts.rootOverride,
|
|
378
|
+
base: baseBranch,
|
|
379
|
+
yes: true,
|
|
380
|
+
archive: false,
|
|
381
|
+
deleteRemoteBranches: false,
|
|
382
|
+
fetch: false,
|
|
383
|
+
quiet: true,
|
|
384
|
+
skipUnsafeWorktrees: true,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
const message = error instanceof Error && error.message.trim().length > 0
|
|
389
|
+
? error.message.trim()
|
|
390
|
+
: String(error);
|
|
391
|
+
process.stderr.write(`warning: post-merge cleanup skipped: ${message}\n`);
|
|
392
|
+
return 0;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
272
395
|
return 0;
|
|
273
396
|
}
|
|
274
397
|
catch (err) {
|
|
398
|
+
const status = err?.status;
|
|
399
|
+
const stdout = err?.stdout;
|
|
400
|
+
const stderr = err?.stderr;
|
|
401
|
+
if (typeof stdout === "string" && stdout.length > 0)
|
|
402
|
+
process.stdout.write(stdout);
|
|
403
|
+
if (typeof stderr === "string" && stderr.length > 0)
|
|
404
|
+
process.stderr.write(stderr);
|
|
405
|
+
if (typeof status === "number" && Number.isInteger(status) && status >= 0) {
|
|
406
|
+
return status;
|
|
407
|
+
}
|
|
275
408
|
if (err instanceof CliError)
|
|
276
409
|
throw err;
|
|
277
410
|
throw mapBackendError(err, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collect.command.d.ts","sourceRoot":"","sources":["../../../src/commands/incidents/collect.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGpF,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"collect.command.d.ts","sourceRoot":"","sources":["../../../src/commands/incidents/collect.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGpF,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,sBAAsB,CAmCpE,CAAC;AAEF,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IAC/E,KAAK,UAAU,EAAE,GAAG,sBAAsB,KAAG,OAAO,CAAC,MAAM,CAAC,CAsC3E"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createCliEmitter } from "../../cli/output.js";
|
|
2
2
|
import { loadCommandContext } from "../shared/task-backend.js";
|
|
3
|
-
import { collectTaskIncidents } from "./shared.js";
|
|
3
|
+
import { collectTaskIncidents, renderIncidentCollectionPlanOutcome } from "./shared.js";
|
|
4
4
|
const output = createCliEmitter();
|
|
5
5
|
export const incidentsCollectSpec = {
|
|
6
6
|
id: ["incidents", "collect"],
|
|
7
7
|
group: "Policy",
|
|
8
|
-
summary: "Promote
|
|
8
|
+
summary: "Promote reusable resolved external findings from a task into the incident registry.",
|
|
9
9
|
args: [{ name: "task-id", required: true, valueHint: "<task-id>" }],
|
|
10
10
|
options: [
|
|
11
11
|
{
|
|
@@ -28,7 +28,7 @@ export const incidentsCollectSpec = {
|
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
cmd: "agentplane incidents collect 202604031416-HEJWTM --check --json",
|
|
31
|
-
why: "Validate that
|
|
31
|
+
why: "Validate that reusable resolved external findings are complete before finish.",
|
|
32
32
|
},
|
|
33
33
|
],
|
|
34
34
|
parse: (raw) => ({
|
|
@@ -51,17 +51,22 @@ export function makeRunIncidentsCollectHandler(getCtx) {
|
|
|
51
51
|
task_id: p.taskId,
|
|
52
52
|
checked_only: p.check,
|
|
53
53
|
candidates: result.plan.candidates.length,
|
|
54
|
+
skipped: result.plan.skipped,
|
|
54
55
|
promotable: result.plan.promotable.map((item) => item.entry),
|
|
55
56
|
duplicates: result.plan.duplicates.map((item) => item.entry.id),
|
|
56
57
|
wrote: result.wrote,
|
|
57
58
|
registry_path: result.registryPath,
|
|
59
|
+
registry_paths: result.registryPaths,
|
|
58
60
|
});
|
|
59
61
|
return 0;
|
|
60
62
|
}
|
|
61
|
-
output.success(p.check ? "checked" : "collected", p.taskId, `candidates=${result.plan.candidates.length} promoted=${result.plan.promotable.length} duplicates=${result.plan.duplicates.length}`);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
output.success(p.check ? "checked" : "collected", p.taskId, `candidates=${result.plan.candidates.length} skipped=${result.plan.skipped.length} promoted=${result.plan.promotable.length} duplicates=${result.plan.duplicates.length}`);
|
|
64
|
+
output.info(renderIncidentCollectionPlanOutcome(result.plan, {
|
|
65
|
+
wrote: result.wrote,
|
|
66
|
+
context: "collect",
|
|
67
|
+
promotedIds: result.plan.promotable.map((item) => item.entry.id),
|
|
68
|
+
registryPaths: result.registryPaths,
|
|
69
|
+
}));
|
|
65
70
|
return 0;
|
|
66
71
|
};
|
|
67
72
|
}
|
|
@@ -6,7 +6,7 @@ export const incidentsSpec = {
|
|
|
6
6
|
synopsis: ["agentplane incidents <collect|advise> [args] [options]"],
|
|
7
7
|
args: [{ name: "cmd", required: false, variadic: true, valueHint: "<command>" }],
|
|
8
8
|
notes: [
|
|
9
|
-
"Use `incidents collect` to promote
|
|
9
|
+
"Use `incidents collect` to promote resolved reusable external findings into `.agentplane/policy/incidents.md`.",
|
|
10
10
|
"Use `incidents advise` to query registry advice by task id or lightweight scope/tags.",
|
|
11
11
|
],
|
|
12
12
|
parse: (raw) => parseGroupCommand(raw),
|
|
@@ -2,6 +2,7 @@ import type { TaskData } from "../../backends/task-backend.js";
|
|
|
2
2
|
import { type IncidentAdviceMatch, type IncidentAdviceQuery, type IncidentCollectionPlan, type IncidentRegistry } from "../../runtime/incidents/index.js";
|
|
3
3
|
import type { CommandContext } from "../shared/task-backend.js";
|
|
4
4
|
export declare const INCIDENTS_POLICY_PATH = ".agentplane/policy/incidents.md";
|
|
5
|
+
export declare const INCIDENTS_POLICY_ASSET_PATH = "packages/agentplane/assets/policy/incidents.md";
|
|
5
6
|
export type LoadedTaskIncidents = {
|
|
6
7
|
task: TaskData;
|
|
7
8
|
findings: string;
|
|
@@ -9,6 +10,7 @@ export type LoadedTaskIncidents = {
|
|
|
9
10
|
query: IncidentAdviceQuery;
|
|
10
11
|
};
|
|
11
12
|
export declare function incidentRegistryPath(ctx: CommandContext): string;
|
|
13
|
+
export declare function incidentRegistryAssetPath(ctx: CommandContext): string;
|
|
12
14
|
export declare function loadIncidentRegistry(ctx: CommandContext): Promise<{
|
|
13
15
|
registryPath: string;
|
|
14
16
|
registryText: string;
|
|
@@ -25,11 +27,43 @@ export declare function collectTaskIncidents(opts: {
|
|
|
25
27
|
}): Promise<{
|
|
26
28
|
loaded: LoadedTaskIncidents;
|
|
27
29
|
registryPath: string;
|
|
30
|
+
registryPaths: string[];
|
|
28
31
|
registryText: string;
|
|
29
32
|
registry: IncidentRegistry;
|
|
30
33
|
plan: IncidentCollectionPlan;
|
|
31
34
|
wrote: boolean;
|
|
32
35
|
}>;
|
|
36
|
+
export declare function inspectTaskIncidents(opts: {
|
|
37
|
+
ctx: CommandContext;
|
|
38
|
+
taskId: string;
|
|
39
|
+
task?: TaskData | null;
|
|
40
|
+
now?: Date;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
loaded: LoadedTaskIncidents;
|
|
43
|
+
registryPath: string;
|
|
44
|
+
registryPaths: string[];
|
|
45
|
+
registryText: string;
|
|
46
|
+
registry: IncidentRegistry;
|
|
47
|
+
plan: IncidentCollectionPlan;
|
|
48
|
+
}>;
|
|
49
|
+
export declare function renderIncidentCollectionOutcome(promotedCount: number): string;
|
|
50
|
+
export declare function renderIncidentCollectionPlanOutcome(plan: {
|
|
51
|
+
candidates?: readonly unknown[];
|
|
52
|
+
skipped?: readonly unknown[];
|
|
53
|
+
promotable?: readonly unknown[];
|
|
54
|
+
duplicates?: readonly unknown[];
|
|
55
|
+
issues?: readonly {
|
|
56
|
+
missingFields?: readonly string[];
|
|
57
|
+
}[];
|
|
58
|
+
findingsTextPresent?: boolean;
|
|
59
|
+
structuredFindingCount?: number;
|
|
60
|
+
}, opts?: {
|
|
61
|
+
wrote?: boolean;
|
|
62
|
+
context?: "collect" | "verify" | "finish" | "generic";
|
|
63
|
+
promotedIds?: readonly string[];
|
|
64
|
+
registryPaths?: readonly string[];
|
|
65
|
+
taskId?: string | null;
|
|
66
|
+
}): string;
|
|
33
67
|
export declare function adviseTaskIncidents(opts: {
|
|
34
68
|
ctx: CommandContext;
|
|
35
69
|
taskId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/commands/incidents/shared.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAG/D,OAAO,EAOL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACtB,MAAM,kCAAkC,CAAC;AAM1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,eAAO,MAAM,qBAAqB,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/commands/incidents/shared.ts"],"names":[],"mappings":"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"}
|