agentplane 0.2.2 → 0.2.4
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 +58 -32
- package/assets/framework.manifest.json +89 -0
- package/dist/adapters/clock/system-clock-adapter.d.ts +5 -0
- package/dist/adapters/clock/system-clock-adapter.d.ts.map +1 -0
- package/dist/adapters/clock/system-clock-adapter.js +5 -0
- package/dist/adapters/fs/node-fs-adapter.d.ts +15 -0
- package/dist/adapters/fs/node-fs-adapter.d.ts.map +1 -0
- package/dist/adapters/fs/node-fs-adapter.js +47 -0
- package/dist/adapters/git/git-context-adapter.d.ts +21 -0
- package/dist/adapters/git/git-context-adapter.d.ts.map +1 -0
- package/dist/adapters/git/git-context-adapter.js +27 -0
- package/dist/adapters/index.d.ts +13 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +12 -0
- package/dist/adapters/task-backend/task-backend-adapter.d.ts +12 -0
- package/dist/adapters/task-backend/task-backend-adapter.d.ts.map +1 -0
- package/dist/adapters/task-backend/task-backend-adapter.js +22 -0
- package/dist/backends/task-backend/local-backend.d.ts.map +1 -1
- package/dist/backends/task-backend/local-backend.js +39 -34
- package/dist/backends/task-index.d.ts +9 -3
- package/dist/backends/task-index.d.ts.map +1 -1
- package/dist/backends/task-index.js +64 -14
- package/dist/cli/cli-error.d.ts +9 -0
- package/dist/cli/cli-error.d.ts.map +1 -0
- package/dist/cli/cli-error.js +13 -0
- package/dist/cli/http.d.ts.map +1 -1
- package/dist/cli/http.js +18 -6
- package/dist/cli/parse/lifecycle.d.ts.map +1 -1
- package/dist/cli/parse/lifecycle.js +6 -1
- 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/command-catalog.js +8 -0
- package/dist/cli/run-cli/commands/init/conflicts.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/conflicts.js +2 -1
- package/dist/cli/run-cli/commands/init/write-agents.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/write-agents.js +27 -4
- package/dist/cli/run-cli/commands/init/write-config.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/write-config.js +0 -4
- package/dist/cli/run-cli.d.ts.map +1 -1
- package/dist/cli/run-cli.js +14 -5
- package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
- package/dist/cli/run-cli.test-helpers.js +35 -1
- package/dist/commands/branch/internal/work-validate.d.ts.map +1 -1
- package/dist/commands/branch/internal/work-validate.js +13 -4
- package/dist/commands/branch/status.d.ts.map +1 -1
- package/dist/commands/branch/status.js +9 -4
- package/dist/commands/doctor.command.d.ts +8 -0
- package/dist/commands/doctor.command.d.ts.map +1 -0
- package/dist/commands/doctor.command.js +137 -0
- package/dist/commands/guard/impl/allow.d.ts.map +1 -1
- package/dist/commands/guard/impl/allow.js +7 -2
- package/dist/commands/guard/impl/close-message.d.ts.map +1 -1
- package/dist/commands/guard/impl/close-message.js +7 -2
- package/dist/commands/pr/check.d.ts.map +1 -1
- package/dist/commands/pr/check.js +7 -2
- package/dist/commands/pr/integrate/artifacts.d.ts.map +1 -1
- package/dist/commands/pr/integrate/artifacts.js +6 -1
- package/dist/commands/pr/integrate/internal/merge.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/merge.js +7 -6
- package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -1
- package/dist/commands/pr/integrate/internal/prepare.js +9 -4
- package/dist/commands/pr/integrate/verify.d.ts.map +1 -1
- package/dist/commands/pr/integrate/verify.js +3 -1
- package/dist/commands/pr/note.d.ts.map +1 -1
- package/dist/commands/pr/note.js +13 -4
- package/dist/commands/pr/open.d.ts.map +1 -1
- package/dist/commands/pr/open.js +8 -3
- package/dist/commands/recipes/impl/apply.d.ts.map +1 -1
- package/dist/commands/recipes/impl/apply.js +2 -1
- package/dist/commands/recipes/impl/commands/explain.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/explain.js +2 -1
- package/dist/commands/recipes/impl/commands/info.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/info.js +2 -1
- package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/install.js +5 -4
- package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/remove.js +2 -1
- package/dist/commands/scenario/impl/commands.d.ts.map +1 -1
- package/dist/commands/scenario/impl/commands.js +8 -7
- package/dist/commands/shared/git-ops.d.ts.map +1 -1
- package/dist/commands/shared/git-ops.js +4 -3
- package/dist/commands/shared/task-store.d.ts.map +1 -1
- package/dist/commands/shared/task-store.js +7 -2
- package/dist/commands/task/list.command.d.ts.map +1 -1
- package/dist/commands/task/list.command.js +4 -5
- package/dist/commands/task/migrate-doc.d.ts.map +1 -1
- package/dist/commands/task/migrate-doc.js +2 -1
- package/dist/commands/task/new.command.d.ts.map +1 -1
- package/dist/commands/task/new.command.js +2 -8
- package/dist/commands/task/rebuild-index.command.d.ts +6 -0
- package/dist/commands/task/rebuild-index.command.d.ts.map +1 -0
- package/dist/commands/task/rebuild-index.command.js +18 -0
- package/dist/commands/task/shared.d.ts.map +1 -1
- package/dist/commands/task/shared.js +15 -6
- package/dist/commands/upgrade.command.d.ts.map +1 -1
- package/dist/commands/upgrade.command.js +52 -4
- package/dist/commands/upgrade.d.ts +10 -0
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +337 -95
- package/dist/policy/engine.d.ts +21 -0
- package/dist/policy/engine.d.ts.map +1 -0
- package/dist/policy/engine.js +32 -0
- package/dist/ports/clock-port.d.ts +4 -0
- package/dist/ports/clock-port.d.ts.map +1 -0
- package/dist/ports/clock-port.js +1 -0
- package/dist/ports/fs-port.d.ts +18 -0
- package/dist/ports/fs-port.d.ts.map +1 -0
- package/dist/ports/fs-port.js +1 -0
- package/dist/ports/git-port.d.ts +18 -0
- package/dist/ports/git-port.d.ts.map +1 -0
- package/dist/ports/git-port.js +1 -0
- package/dist/ports/task-backend-port.d.ts +8 -0
- package/dist/ports/task-backend-port.d.ts.map +1 -0
- package/dist/ports/task-backend-port.js +1 -0
- package/dist/usecases/context/resolve-context.d.ts +14 -0
- package/dist/usecases/context/resolve-context.d.ts.map +1 -0
- package/dist/usecases/context/resolve-context.js +13 -0
- package/dist/usecases/task/task-list-usecase.d.ts +9 -0
- package/dist/usecases/task/task-list-usecase.d.ts.map +1 -0
- package/dist/usecases/task/task-list-usecase.js +17 -0
- package/dist/usecases/task/task-new-usecase.d.ts +9 -0
- package/dist/usecases/task/task-new-usecase.d.ts.map +1 -0
- package/dist/usecases/task/task-new-usecase.js +17 -0
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { loadConfig, resolveBaseBranch, resolveProject } from "@agentplaneorg/core";
|
|
2
2
|
import { mapCoreError } from "../../cli/error-map.js";
|
|
3
|
+
import { exitCodeForError } from "../../cli/exit-codes.js";
|
|
3
4
|
import { unknownEntityMessage } from "../../cli/output.js";
|
|
4
5
|
import { CliError } from "../../shared/errors.js";
|
|
5
6
|
import { gitAheadBehind } from "../shared/git-diff.js";
|
|
@@ -20,25 +21,29 @@ export async function cmdBranchStatus(opts) {
|
|
|
20
21
|
mode: loaded.config.workflow_mode,
|
|
21
22
|
});
|
|
22
23
|
if (!branch) {
|
|
23
|
-
throw new CliError({
|
|
24
|
+
throw new CliError({
|
|
25
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
26
|
+
code: "E_USAGE",
|
|
27
|
+
message: "Invalid value for --branch.",
|
|
28
|
+
});
|
|
24
29
|
}
|
|
25
30
|
if (!base) {
|
|
26
31
|
throw new CliError({
|
|
27
|
-
exitCode:
|
|
32
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
28
33
|
code: "E_USAGE",
|
|
29
34
|
message: "Base branch could not be resolved (use `agentplane branch base set` or --base).",
|
|
30
35
|
});
|
|
31
36
|
}
|
|
32
37
|
if (!(await gitBranchExists(resolved.gitRoot, branch))) {
|
|
33
38
|
throw new CliError({
|
|
34
|
-
exitCode:
|
|
39
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
35
40
|
code: "E_USAGE",
|
|
36
41
|
message: unknownEntityMessage("branch", branch),
|
|
37
42
|
});
|
|
38
43
|
}
|
|
39
44
|
if (!(await gitBranchExists(resolved.gitRoot, base))) {
|
|
40
45
|
throw new CliError({
|
|
41
|
-
exitCode:
|
|
46
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
42
47
|
code: "E_USAGE",
|
|
43
48
|
message: unknownEntityMessage("base branch", base),
|
|
44
49
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CommandHandler, CommandSpec } from "../cli/spec/spec.js";
|
|
2
|
+
type DoctorParsed = {
|
|
3
|
+
fix: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const doctorSpec: CommandSpec<DoctorParsed>;
|
|
6
|
+
export declare const runDoctor: CommandHandler<DoctorParsed>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=doctor.command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.command.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvE,KAAK,YAAY,GAAG;IAClB,GAAG,EAAE,OAAO,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,YAAY,CAWhD,CAAC;AAkHF,eAAO,MAAM,SAAS,EAAE,cAAc,CAAC,YAAY,CAoBlD,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { resolveProject } from "@agentplaneorg/core";
|
|
4
|
+
import { warnMessage, successMessage } from "../cli/output.js";
|
|
5
|
+
import { loadCommandContext } from "./shared/task-backend.js";
|
|
6
|
+
export const doctorSpec = {
|
|
7
|
+
id: ["doctor"],
|
|
8
|
+
group: "Quality",
|
|
9
|
+
summary: "Check structural invariants of an agentplane workspace (and optionally apply safe fixes).",
|
|
10
|
+
options: [{ kind: "boolean", name: "fix", default: false, description: "Apply safe fixes." }],
|
|
11
|
+
examples: [
|
|
12
|
+
{ cmd: "agentplane doctor", why: "Check layering and workspace invariants." },
|
|
13
|
+
{ cmd: "agentplane doctor --fix", why: "Apply safe-only fixes (idempotent)." },
|
|
14
|
+
],
|
|
15
|
+
parse: (raw) => ({ fix: raw.opts.fix === true }),
|
|
16
|
+
};
|
|
17
|
+
async function listTsFiles(rootDir) {
|
|
18
|
+
const out = [];
|
|
19
|
+
async function walk(absDir) {
|
|
20
|
+
const entries = await fs.readdir(absDir, { withFileTypes: true });
|
|
21
|
+
for (const ent of entries) {
|
|
22
|
+
if (ent.name.startsWith("."))
|
|
23
|
+
continue;
|
|
24
|
+
if (ent.name === "__snapshots__")
|
|
25
|
+
continue;
|
|
26
|
+
if (ent.name === "node_modules")
|
|
27
|
+
continue;
|
|
28
|
+
const abs = path.join(absDir, ent.name);
|
|
29
|
+
if (ent.isDirectory()) {
|
|
30
|
+
await walk(abs);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (ent.isFile() && ent.name.endsWith(".ts")) {
|
|
34
|
+
out.push({ absPath: abs, relPath: path.relative(rootDir, abs) });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
await walk(rootDir);
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
function extractImports(source) {
|
|
42
|
+
const imports = [];
|
|
43
|
+
const re = /^\s*import\s+(?:type\s+)?(?:[^"']*?\s+from\s+)?["']([^"']+)["']\s*;?/gm;
|
|
44
|
+
for (const match of source.matchAll(re)) {
|
|
45
|
+
imports.push(match[1] ?? "");
|
|
46
|
+
}
|
|
47
|
+
return imports.filter(Boolean);
|
|
48
|
+
}
|
|
49
|
+
async function checkLayering(repoRoot) {
|
|
50
|
+
const problems = [];
|
|
51
|
+
const agentplaneSrcRoot = path.join(repoRoot, "packages", "agentplane", "src");
|
|
52
|
+
const cliRoot = path.join(agentplaneSrcRoot, "cli");
|
|
53
|
+
const cliFiles = await listTsFiles(cliRoot);
|
|
54
|
+
for (const f of cliFiles) {
|
|
55
|
+
const src = await fs.readFile(f.absPath, "utf8");
|
|
56
|
+
const imports = extractImports(src);
|
|
57
|
+
const hits = imports.filter((s) => s.includes("/adapters/") ||
|
|
58
|
+
s.includes("../adapters") ||
|
|
59
|
+
s.includes("../../adapters") ||
|
|
60
|
+
s.includes("../../../adapters"));
|
|
61
|
+
if (hits.length > 0) {
|
|
62
|
+
problems.push(`${f.relPath} imports adapters directly: ${hits.join(", ")}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const roots = [path.join(agentplaneSrcRoot, "usecases"), path.join(agentplaneSrcRoot, "ports")];
|
|
66
|
+
const banned = [
|
|
67
|
+
"node:fs",
|
|
68
|
+
"node:fs/promises",
|
|
69
|
+
"fs",
|
|
70
|
+
"fs/promises",
|
|
71
|
+
"node:path",
|
|
72
|
+
"path",
|
|
73
|
+
"simple-git",
|
|
74
|
+
"isomorphic-git",
|
|
75
|
+
];
|
|
76
|
+
for (const root of roots) {
|
|
77
|
+
const files = await listTsFiles(root);
|
|
78
|
+
for (const f of files) {
|
|
79
|
+
const src = await fs.readFile(f.absPath, "utf8");
|
|
80
|
+
const imports = extractImports(src);
|
|
81
|
+
const hits = imports.filter((s) => banned.some((b) => s === b || s.startsWith(`${b}/`)));
|
|
82
|
+
if (hits.length > 0) {
|
|
83
|
+
problems.push(`${f.relPath} imports banned modules: ${hits.join(", ")}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return problems;
|
|
88
|
+
}
|
|
89
|
+
async function safeFixGitignore(repoRoot) {
|
|
90
|
+
const gitignorePath = path.join(repoRoot, ".gitignore");
|
|
91
|
+
let existing = "";
|
|
92
|
+
try {
|
|
93
|
+
existing = await fs.readFile(gitignorePath, "utf8");
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
// If .gitignore doesn't exist, do not create it implicitly (keep doctor safe).
|
|
97
|
+
return { changed: false, note: "Skip: .gitignore not found." };
|
|
98
|
+
}
|
|
99
|
+
const lines = existing.split(/\r?\n/);
|
|
100
|
+
const entry = ".agentplane/.upgrade/";
|
|
101
|
+
if (lines.some((l) => l.trim() === entry)) {
|
|
102
|
+
return { changed: false, note: "OK: .gitignore already ignores .agentplane/.upgrade/." };
|
|
103
|
+
}
|
|
104
|
+
const next = `${existing.trimEnd()}\n${entry}\n`;
|
|
105
|
+
await fs.writeFile(gitignorePath, next, "utf8");
|
|
106
|
+
return { changed: true, note: "Fixed: added .agentplane/.upgrade/ to .gitignore." };
|
|
107
|
+
}
|
|
108
|
+
async function safeFixTaskIndex(repoRoot) {
|
|
109
|
+
try {
|
|
110
|
+
// Best-effort: rebuilding the index is a side-effect of listing tasks for the local backend.
|
|
111
|
+
const ctx = await loadCommandContext({ cwd: repoRoot, rootOverride: null });
|
|
112
|
+
await ctx.taskBackend.listTasks();
|
|
113
|
+
return { changed: true, note: "OK: rebuilt tasks index cache (best-effort)." };
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return { changed: false, note: "Skip: could not rebuild tasks index cache." };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export const runDoctor = async (ctx, p) => {
|
|
120
|
+
const resolved = await resolveProject({ cwd: ctx.cwd, rootOverride: ctx.rootOverride ?? null });
|
|
121
|
+
const repoRoot = resolved.gitRoot;
|
|
122
|
+
const problems = await checkLayering(repoRoot);
|
|
123
|
+
if (problems.length > 0) {
|
|
124
|
+
console.error(warnMessage(`doctor found ${problems.length} problem(s):`));
|
|
125
|
+
for (const prob of problems)
|
|
126
|
+
console.error(`- ${prob}`);
|
|
127
|
+
return 1;
|
|
128
|
+
}
|
|
129
|
+
if (p.fix) {
|
|
130
|
+
const fix = await safeFixGitignore(repoRoot);
|
|
131
|
+
console.log(successMessage("doctor fix", undefined, fix.note));
|
|
132
|
+
const idx = await safeFixTaskIndex(repoRoot);
|
|
133
|
+
console.log(successMessage("doctor fix", undefined, idx.note));
|
|
134
|
+
}
|
|
135
|
+
console.log(successMessage("doctor", undefined, "OK"));
|
|
136
|
+
return 0;
|
|
137
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allow.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/allow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"allow.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/allow.ts"],"names":[],"mappings":"AAMA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEvF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAS9D;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAOpB;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBhB;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,GAAG,EAAE,cAAc,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAoCpB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolveProject } from "@agentplaneorg/core";
|
|
2
|
+
import { exitCodeForError } from "../../../cli/exit-codes.js";
|
|
2
3
|
import { gitPathIsUnderPrefix, normalizeGitPathPrefix } from "../../../shared/git-path.js";
|
|
3
4
|
import { CliError } from "../../../shared/errors.js";
|
|
4
5
|
import { GitContext } from "../../shared/git-context.js";
|
|
@@ -29,13 +30,17 @@ export async function ensureGitClean(opts) {
|
|
|
29
30
|
(await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
|
|
30
31
|
const staged = await ctx.git.statusStagedPaths();
|
|
31
32
|
if (staged.length > 0) {
|
|
32
|
-
throw new CliError({
|
|
33
|
+
throw new CliError({
|
|
34
|
+
exitCode: exitCodeForError("E_GIT"),
|
|
35
|
+
code: "E_GIT",
|
|
36
|
+
message: "Working tree has staged changes",
|
|
37
|
+
});
|
|
33
38
|
}
|
|
34
39
|
// Policy-defined "clean" ignores untracked files.
|
|
35
40
|
const unstaged = await ctx.git.statusUnstagedTrackedPaths();
|
|
36
41
|
if (unstaged.length > 0) {
|
|
37
42
|
throw new CliError({
|
|
38
|
-
exitCode:
|
|
43
|
+
exitCode: exitCodeForError("E_GIT"),
|
|
39
44
|
code: "E_GIT",
|
|
40
45
|
message: "Working tree has unstaged changes",
|
|
41
46
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close-message.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/close-message.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"close-message.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/close-message.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAsHlE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,uBAAuB,CAAC,IAAI,EAAE;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,QAAQ,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAsD9B;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,MAAM,CAET"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { extractTaskSuffix } from "@agentplaneorg/core";
|
|
3
|
+
import { exitCodeForError } from "../../../cli/exit-codes.js";
|
|
3
4
|
import { CliError } from "../../../shared/errors.js";
|
|
4
5
|
import { execFileAsync, gitEnv } from "../../shared/git.js";
|
|
5
6
|
function uniqSorted(values) {
|
|
@@ -114,12 +115,16 @@ export async function buildCloseCommitMessage(opts) {
|
|
|
114
115
|
: [];
|
|
115
116
|
const isSpike = tags.includes("spike");
|
|
116
117
|
if (String(task.status || "").toUpperCase() !== "DONE") {
|
|
117
|
-
throw new CliError({
|
|
118
|
+
throw new CliError({
|
|
119
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
120
|
+
code: "E_USAGE",
|
|
121
|
+
message: `Task is not DONE: ${task.id}`,
|
|
122
|
+
});
|
|
118
123
|
}
|
|
119
124
|
const implCommit = task.commit?.hash?.trim() ?? "";
|
|
120
125
|
if (!implCommit) {
|
|
121
126
|
throw new CliError({
|
|
122
|
-
exitCode:
|
|
127
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
123
128
|
code: "E_USAGE",
|
|
124
129
|
message: `Task is missing recorded commit metadata: ${task.id} (finish with --commit or set commit on the task).`,
|
|
125
130
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/check.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/check.ts"],"names":[],"mappings":"AASA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AAKnC,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAwElB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { mapBackendError } from "../../cli/error-map.js";
|
|
4
|
+
import { exitCodeForError } from "../../cli/exit-codes.js";
|
|
4
5
|
import { fileExists } from "../../cli/fs-utils.js";
|
|
5
6
|
import { successMessage, workflowModeMessage } from "../../cli/output.js";
|
|
6
7
|
import { CliError } from "../../shared/errors.js";
|
|
@@ -21,7 +22,7 @@ export async function cmdPrCheck(opts) {
|
|
|
21
22
|
const { resolved, config, prDir, metaPath, diffstatPath, verifyLogPath, reviewPath } = await resolvePrPaths({ ...opts, ctx });
|
|
22
23
|
if (config.workflow_mode !== "branch_pr") {
|
|
23
24
|
throw new CliError({
|
|
24
|
-
exitCode:
|
|
25
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
25
26
|
code: "E_USAGE",
|
|
26
27
|
message: workflowModeMessage(config.workflow_mode, "branch_pr"),
|
|
27
28
|
});
|
|
@@ -65,7 +66,11 @@ export async function cmdPrCheck(opts) {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
if (errors.length > 0) {
|
|
68
|
-
throw new CliError({
|
|
69
|
+
throw new CliError({
|
|
70
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
71
|
+
code: "E_VALIDATION",
|
|
72
|
+
message: errors.join("\n"),
|
|
73
|
+
});
|
|
69
74
|
}
|
|
70
75
|
process.stdout.write(`${successMessage("pr check", path.relative(resolved.gitRoot, prDir))}\n`);
|
|
71
76
|
return 0;
|
|
@@ -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":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAWnE,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,CA8CD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { exitCodeForError } from "../../../cli/exit-codes.js";
|
|
2
3
|
import { CliError } from "../../../shared/errors.js";
|
|
3
4
|
import { readPrArtifact } from "../internal/pr-paths.js";
|
|
4
5
|
import { validateReviewContents } from "../internal/review-template.js";
|
|
@@ -39,7 +40,11 @@ export async function readAndValidatePrArtifacts(opts) {
|
|
|
39
40
|
if (reviewText)
|
|
40
41
|
validateReviewContents(reviewText, errors);
|
|
41
42
|
if (errors.length > 0) {
|
|
42
|
-
throw new CliError({
|
|
43
|
+
throw new CliError({
|
|
44
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
45
|
+
code: "E_VALIDATION",
|
|
46
|
+
message: errors.join("\n"),
|
|
47
|
+
});
|
|
43
48
|
}
|
|
44
49
|
return { verifyLogText };
|
|
45
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../../../src/commands/pr/integrate/internal/merge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../../../src/commands/pr/integrate/internal/merge.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAIzD,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,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,GAAG,OAAO,CAAC,MAAM,CAAC,CAuElB;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBlB;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;CAChB,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,CAsDD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { extractTaskSuffix, validateCommitSubject } from "@agentplaneorg/core";
|
|
2
|
+
import { exitCodeForError } from "../../../../cli/exit-codes.js";
|
|
2
3
|
import { CliError } from "../../../../shared/errors.js";
|
|
3
4
|
import { execFileAsync, gitEnv } from "../../../shared/git.js";
|
|
4
5
|
import { gitRevParse } from "../../../shared/git-ops.js";
|
|
@@ -16,7 +17,7 @@ export async function runSquashMerge(opts) {
|
|
|
16
17
|
env: gitEnv(),
|
|
17
18
|
});
|
|
18
19
|
const message = err instanceof Error ? err.message : "git merge --squash failed";
|
|
19
|
-
throw new CliError({ exitCode:
|
|
20
|
+
throw new CliError({ exitCode: exitCodeForError("E_GIT"), code: "E_GIT", message });
|
|
20
21
|
}
|
|
21
22
|
const { stdout: staged } = await execFileAsync("git", ["diff", "--cached", "--name-only"], {
|
|
22
23
|
cwd: opts.gitRoot,
|
|
@@ -28,7 +29,7 @@ export async function runSquashMerge(opts) {
|
|
|
28
29
|
env: gitEnv(),
|
|
29
30
|
});
|
|
30
31
|
throw new CliError({
|
|
31
|
-
exitCode:
|
|
32
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
32
33
|
code: "E_USAGE",
|
|
33
34
|
message: `Nothing to integrate: ${opts.branch} is already merged into ${opts.base}`,
|
|
34
35
|
});
|
|
@@ -65,7 +66,7 @@ export async function runSquashMerge(opts) {
|
|
|
65
66
|
env: gitEnv(),
|
|
66
67
|
});
|
|
67
68
|
const message = err instanceof Error ? err.message : "git commit failed";
|
|
68
|
-
throw new CliError({ exitCode:
|
|
69
|
+
throw new CliError({ exitCode: exitCodeForError("E_GIT"), code: "E_GIT", message });
|
|
69
70
|
}
|
|
70
71
|
return await gitRevParse(opts.gitRoot, ["HEAD"]);
|
|
71
72
|
}
|
|
@@ -83,7 +84,7 @@ export async function runMergeCommit(opts) {
|
|
|
83
84
|
catch (err) {
|
|
84
85
|
await execFileAsync("git", ["merge", "--abort"], { cwd: opts.gitRoot, env: gitEnv() });
|
|
85
86
|
const message = err instanceof Error ? err.message : "git merge failed";
|
|
86
|
-
throw new CliError({ exitCode:
|
|
87
|
+
throw new CliError({ exitCode: exitCodeForError("E_GIT"), code: "E_GIT", message });
|
|
87
88
|
}
|
|
88
89
|
return await gitRevParse(opts.gitRoot, ["HEAD"]);
|
|
89
90
|
}
|
|
@@ -94,7 +95,7 @@ export async function runRebaseFastForward(opts) {
|
|
|
94
95
|
catch (err) {
|
|
95
96
|
await execFileAsync("git", ["rebase", "--abort"], { cwd: opts.worktreePath, env: gitEnv() });
|
|
96
97
|
const message = err instanceof Error ? err.message : "git rebase failed";
|
|
97
|
-
throw new CliError({ exitCode:
|
|
98
|
+
throw new CliError({ exitCode: exitCodeForError("E_GIT"), code: "E_GIT", message });
|
|
98
99
|
}
|
|
99
100
|
let branchHeadSha = await gitRevParse(opts.gitRoot, [opts.branch]);
|
|
100
101
|
let alreadyVerifiedSha = opts.alreadyVerifiedSha;
|
|
@@ -130,7 +131,7 @@ export async function runRebaseFastForward(opts) {
|
|
|
130
131
|
env: gitEnv(),
|
|
131
132
|
}).catch(() => null);
|
|
132
133
|
const message = err instanceof Error ? err.message : "git merge --ff-only failed";
|
|
133
|
-
throw new CliError({ exitCode:
|
|
134
|
+
throw new CliError({ exitCode: exitCodeForError("E_GIT"), code: "E_GIT", message });
|
|
134
135
|
}
|
|
135
136
|
const mergeHash = await gitRevParse(opts.gitRoot, ["HEAD"]);
|
|
136
137
|
branchHeadSha = await gitRevParse(opts.gitRoot, [opts.branch]);
|
|
@@ -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":"AAYA,OAAO,EACL,eAAe,EAEf,KAAK,cAAc,EACpB,MAAM,iCAAiC,CAAC;AAUzC,OAAO,EAAe,KAAK,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEtE,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,OAAO,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAE1D,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,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,CAwJ7B"}
|
|
@@ -2,6 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { resolveBaseBranch } from "@agentplaneorg/core";
|
|
4
4
|
import { fileExists } from "../../../../cli/fs-utils.js";
|
|
5
|
+
import { exitCodeForError } from "../../../../cli/exit-codes.js";
|
|
5
6
|
import { unknownEntityMessage, workflowModeMessage } from "../../../../cli/output.js";
|
|
6
7
|
import { CliError } from "../../../../shared/errors.js";
|
|
7
8
|
import { ensureGitClean } from "../../../guard/index.js";
|
|
@@ -26,7 +27,7 @@ export async function prepareIntegrate(opts) {
|
|
|
26
27
|
const loadedConfig = ctx.config;
|
|
27
28
|
if (loadedConfig.workflow_mode !== "branch_pr") {
|
|
28
29
|
throw new CliError({
|
|
29
|
-
exitCode:
|
|
30
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
30
31
|
code: "E_USAGE",
|
|
31
32
|
message: workflowModeMessage(loadedConfig.workflow_mode, "branch_pr"),
|
|
32
33
|
});
|
|
@@ -35,7 +36,11 @@ export async function prepareIntegrate(opts) {
|
|
|
35
36
|
ensureVerificationSatisfiedIfRequired(task, loadedConfig);
|
|
36
37
|
await ensureGitClean({ cwd: opts.cwd, rootOverride: opts.rootOverride });
|
|
37
38
|
if (opts.base?.trim().length === 0) {
|
|
38
|
-
throw new CliError({
|
|
39
|
+
throw new CliError({
|
|
40
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
41
|
+
code: "E_USAGE",
|
|
42
|
+
message: "Invalid value for --base.",
|
|
43
|
+
});
|
|
39
44
|
}
|
|
40
45
|
const baseBranch = await resolveBaseBranch({
|
|
41
46
|
cwd: opts.cwd,
|
|
@@ -45,7 +50,7 @@ export async function prepareIntegrate(opts) {
|
|
|
45
50
|
});
|
|
46
51
|
if (!baseBranch) {
|
|
47
52
|
throw new CliError({
|
|
48
|
-
exitCode:
|
|
53
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
49
54
|
code: "E_USAGE",
|
|
50
55
|
message: "Base branch could not be resolved (use `agentplane branch base set` or --base).",
|
|
51
56
|
});
|
|
@@ -53,7 +58,7 @@ export async function prepareIntegrate(opts) {
|
|
|
53
58
|
const currentBranch = await gitCurrentBranch(resolved.gitRoot);
|
|
54
59
|
if (currentBranch !== baseBranch) {
|
|
55
60
|
throw new CliError({
|
|
56
|
-
exitCode:
|
|
61
|
+
exitCode: exitCodeForError("E_GIT"),
|
|
57
62
|
code: "E_GIT",
|
|
58
63
|
message: `integrate must run on base branch ${baseBranch} (current: ${currentBranch})`,
|
|
59
64
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/integrate/verify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/integrate/verify.ts"],"names":[],"mappings":"AAcA,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;CACpB,GAAG;IACF,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,eAAe,EAAE,OAAO,CAAC;CAC1B,CAgBA;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAgCjD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { extractLastVerifiedSha, runShellCommand } from "../../shared/pr-meta.js";
|
|
2
2
|
import { successMessage } from "../../../cli/output.js";
|
|
3
|
+
import { exitCodeForError } from "../../../cli/exit-codes.js";
|
|
3
4
|
import { CliError } from "../../../shared/errors.js";
|
|
4
5
|
function normalizeVerifyCommands(rawVerify) {
|
|
5
6
|
return Array.isArray(rawVerify)
|
|
@@ -41,9 +42,10 @@ export async function runVerifyCommands(opts) {
|
|
|
41
42
|
});
|
|
42
43
|
if (result.code !== 0) {
|
|
43
44
|
throw new CliError({
|
|
44
|
-
exitCode:
|
|
45
|
+
exitCode: exitCodeForError("E_IO"),
|
|
45
46
|
code: "E_IO",
|
|
46
47
|
message: `Verify command failed: ${command}`,
|
|
48
|
+
context: { commandExitCode: result.code || 1 },
|
|
47
49
|
});
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"note.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/note.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"note.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/note.ts"],"names":[],"mappings":"AAUA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAKpF,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,MAAM,CAAC,CAkDlB"}
|
package/dist/commands/pr/note.js
CHANGED
|
@@ -2,6 +2,7 @@ import { readFile } from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { atomicWriteFile } from "@agentplaneorg/core";
|
|
4
4
|
import { mapCoreError } from "../../cli/error-map.js";
|
|
5
|
+
import { exitCodeForError } from "../../cli/exit-codes.js";
|
|
5
6
|
import { fileExists } from "../../cli/fs-utils.js";
|
|
6
7
|
import { successMessage, workflowModeMessage } from "../../cli/output.js";
|
|
7
8
|
import { CliError } from "../../shared/errors.js";
|
|
@@ -13,17 +14,25 @@ export async function cmdPrNote(opts) {
|
|
|
13
14
|
const author = opts.author.trim();
|
|
14
15
|
const body = opts.body.trim();
|
|
15
16
|
if (!author) {
|
|
16
|
-
throw new CliError({
|
|
17
|
+
throw new CliError({
|
|
18
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
19
|
+
code: "E_USAGE",
|
|
20
|
+
message: "Invalid value for --author.",
|
|
21
|
+
});
|
|
17
22
|
}
|
|
18
23
|
if (!body) {
|
|
19
|
-
throw new CliError({
|
|
24
|
+
throw new CliError({
|
|
25
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
26
|
+
code: "E_USAGE",
|
|
27
|
+
message: "Invalid value for --body.",
|
|
28
|
+
});
|
|
20
29
|
}
|
|
21
30
|
const ctx = opts.ctx ??
|
|
22
31
|
(await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
|
|
23
32
|
const { config, reviewPath, resolved } = await resolvePrPaths({ ...opts, ctx });
|
|
24
33
|
if (config.workflow_mode !== "branch_pr") {
|
|
25
34
|
throw new CliError({
|
|
26
|
-
exitCode:
|
|
35
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
27
36
|
code: "E_USAGE",
|
|
28
37
|
message: workflowModeMessage(config.workflow_mode, "branch_pr"),
|
|
29
38
|
});
|
|
@@ -31,7 +40,7 @@ export async function cmdPrNote(opts) {
|
|
|
31
40
|
if (!(await fileExists(reviewPath))) {
|
|
32
41
|
const relReviewPath = path.relative(resolved.gitRoot, reviewPath);
|
|
33
42
|
throw new CliError({
|
|
34
|
-
exitCode:
|
|
43
|
+
exitCode: exitCodeForError("E_VALIDATION"),
|
|
35
44
|
code: "E_VALIDATION",
|
|
36
45
|
message: `Missing ${relReviewPath} (run \`agentplane pr open\`)`,
|
|
37
46
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/open.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../../src/commands/pr/open.ts"],"names":[],"mappings":"AAaA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AASnC,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,MAAM,CAAC,CA0ElB"}
|
package/dist/commands/pr/open.js
CHANGED
|
@@ -2,6 +2,7 @@ import { mkdir, readFile } from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { atomicWriteFile } from "@agentplaneorg/core";
|
|
4
4
|
import { mapBackendError } from "../../cli/error-map.js";
|
|
5
|
+
import { exitCodeForError } from "../../cli/exit-codes.js";
|
|
5
6
|
import { fileExists } from "../../cli/fs-utils.js";
|
|
6
7
|
import { successMessage, workflowModeMessage } from "../../cli/output.js";
|
|
7
8
|
import { CliError } from "../../shared/errors.js";
|
|
@@ -18,7 +19,11 @@ export async function cmdPrOpen(opts) {
|
|
|
18
19
|
try {
|
|
19
20
|
const author = opts.author.trim();
|
|
20
21
|
if (!author) {
|
|
21
|
-
throw new CliError({
|
|
22
|
+
throw new CliError({
|
|
23
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
24
|
+
code: "E_USAGE",
|
|
25
|
+
message: "Invalid value for --author.",
|
|
26
|
+
});
|
|
22
27
|
}
|
|
23
28
|
const ctx = opts.ctx ??
|
|
24
29
|
(await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
|
|
@@ -31,7 +36,7 @@ export async function cmdPrOpen(opts) {
|
|
|
31
36
|
const { resolved, config, prDir, metaPath, diffstatPath, verifyLogPath, reviewPath } = await resolvePrPaths({ ...opts, ctx });
|
|
32
37
|
if (config.workflow_mode !== "branch_pr") {
|
|
33
38
|
throw new CliError({
|
|
34
|
-
exitCode:
|
|
39
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
35
40
|
code: "E_USAGE",
|
|
36
41
|
message: workflowModeMessage(config.workflow_mode, "branch_pr"),
|
|
37
42
|
});
|
|
@@ -39,7 +44,7 @@ export async function cmdPrOpen(opts) {
|
|
|
39
44
|
const branch = (opts.branch ?? (await gitCurrentBranch(resolved.gitRoot))).trim();
|
|
40
45
|
if (!branch) {
|
|
41
46
|
throw new CliError({
|
|
42
|
-
exitCode:
|
|
47
|
+
exitCode: exitCodeForError("E_USAGE"),
|
|
43
48
|
code: "E_USAGE",
|
|
44
49
|
message: "Branch could not be resolved (use --branch).",
|
|
45
50
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../../src/commands/recipes/impl/apply.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../../src/commands/recipes/impl/apply.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAErE,wBAAsB,aAAa,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAarF;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,kBAAkB,CAAC;CAChC,GAAG,OAAO,CAAC,IAAI,CAAC,CAgDhB;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BhB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cp, mkdir, readFile, readdir, rename, rm } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { exitCodeForError } from "../../../cli/exit-codes.js";
|
|
3
4
|
import { fileExists, getPathKind } from "../../../cli/fs-utils.js";
|
|
4
5
|
import { invalidFieldMessage, missingFileMessage } from "../../../cli/output.js";
|
|
5
6
|
import { CliError } from "../../../shared/errors.js";
|
|
@@ -50,7 +51,7 @@ export async function applyRecipeAgents(opts) {
|
|
|
50
51
|
if (await getPathKind(targetPath)) {
|
|
51
52
|
if (opts.onConflict === "fail") {
|
|
52
53
|
throw new CliError({
|
|
53
|
-
exitCode:
|
|
54
|
+
exitCode: exitCodeForError("E_IO"),
|
|
54
55
|
code: "E_IO",
|
|
55
56
|
message: `Agent already exists: ${targetId}`,
|
|
56
57
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/explain.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/explain.ts"],"names":[],"mappings":"AASA,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,MAAM,CAAC,CAmFlB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mapCoreError } from "../../../../cli/error-map.js";
|
|
2
|
+
import { exitCodeForError } from "../../../../cli/exit-codes.js";
|
|
2
3
|
import { CliError } from "../../../../shared/errors.js";
|
|
3
4
|
import { collectRecipeScenarioDetails } from "../scenario.js";
|
|
4
5
|
import { formatJsonBlock } from "../format.js";
|
|
@@ -10,7 +11,7 @@ export async function cmdRecipeExplainParsed(opts) {
|
|
|
10
11
|
const entry = installed.recipes.find((recipe) => recipe.id === opts.id);
|
|
11
12
|
if (!entry) {
|
|
12
13
|
throw new CliError({
|
|
13
|
-
exitCode:
|
|
14
|
+
exitCode: exitCodeForError("E_IO"),
|
|
14
15
|
code: "E_IO",
|
|
15
16
|
message: `Recipe not installed: ${opts.id}`,
|
|
16
17
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/info.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../../../../src/commands/recipes/impl/commands/info.ts"],"names":[],"mappings":"AAOA,wBAAsB,mBAAmB,CAAC,IAAI,EAAE;IAC9C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,MAAM,CAAC,CAsDlB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mapCoreError } from "../../../../cli/error-map.js";
|
|
2
|
+
import { exitCodeForError } from "../../../../cli/exit-codes.js";
|
|
2
3
|
import { CliError } from "../../../../shared/errors.js";
|
|
3
4
|
import { readInstalledRecipesFile } from "../installed-recipes.js";
|
|
4
5
|
import { resolveInstalledRecipesPath } from "../paths.js";
|
|
@@ -8,7 +9,7 @@ export async function cmdRecipeInfoParsed(opts) {
|
|
|
8
9
|
const entry = installed.recipes.find((recipe) => recipe.id === opts.id);
|
|
9
10
|
if (!entry) {
|
|
10
11
|
throw new CliError({
|
|
11
|
-
exitCode:
|
|
12
|
+
exitCode: exitCodeForError("E_IO"),
|
|
12
13
|
code: "E_IO",
|
|
13
14
|
message: `Recipe not installed: ${opts.id}`,
|
|
14
15
|
});
|