@cappa/cli 0.14.0 → 0.15.0
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/dist/index.cjs +15 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +15 -7
- package/dist/index.mjs.map +1 -1
- package/integrations/claude/agents/cappa-judge.md +54 -0
- package/integrations/opencode/agents/cappa-judge.md +5 -2
- package/integrations/opencode/commands/cappa-approve.md +2 -0
- package/integrations/opencode/commands/cappa-review.md +7 -4
- package/integrations/skills/cappa/JUDGING.md +15 -2
- package/integrations/skills/cappa/SKILL.md +33 -8
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { ProtocolMismatchError, createClient } from "@cappa/client";
|
|
|
12
12
|
import { createServer, isLoopbackHost } from "@cappa/server";
|
|
13
13
|
import { randomBytes } from "node:crypto";
|
|
14
14
|
//#region package.json
|
|
15
|
-
var version = "0.
|
|
15
|
+
var version = "0.15.0";
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region ../../node_modules/.pnpm/tsdown@0.23.0_@arethetypeswrong+core@0.18.5_oxc-resolver@11.24.2_tsx@4.23.1_typescript@7.0.2/node_modules/tsdown/esm-shims.js
|
|
18
18
|
const getFilename = () => fileURLToPath(import.meta.url);
|
|
@@ -24,7 +24,8 @@ const __dirname = /* @__PURE__ */ getDirname();
|
|
|
24
24
|
* Agent integrations `cappa agent init` can install, and the files each one
|
|
25
25
|
* gets.
|
|
26
26
|
*
|
|
27
|
-
* - `claude` — Claude Code: the skill in `.claude/skills/cappa
|
|
27
|
+
* - `claude` — Claude Code: the skill in `.claude/skills/cappa` plus a
|
|
28
|
+
* `cappa-judge` subagent that judges screenshots in its own context.
|
|
28
29
|
* - `agents` — the vendor-neutral Agent Skills directory `.agents/skills`,
|
|
29
30
|
* read by Codex, OpenCode and other agents that adopted it.
|
|
30
31
|
* - `opencode` — OpenCode: the `.agents` skill plus slash commands that run
|
|
@@ -44,7 +45,10 @@ const skillInto = (dir) => SKILL.map((source) => ({
|
|
|
44
45
|
target: path.join(dir, path.basename(source))
|
|
45
46
|
}));
|
|
46
47
|
const STACK_FILES = {
|
|
47
|
-
claude: skillInto(".claude/skills/cappa"),
|
|
48
|
+
claude: [...skillInto(".claude/skills/cappa"), {
|
|
49
|
+
source: "claude/agents/cappa-judge.md",
|
|
50
|
+
target: path.join(".claude", "agents", "cappa-judge.md")
|
|
51
|
+
}],
|
|
48
52
|
agents: skillInto(".agents/skills/cappa"),
|
|
49
53
|
opencode: [...skillInto(".agents/skills/cappa"), ...[
|
|
50
54
|
"commands/cappa-review.md",
|
|
@@ -250,20 +254,24 @@ const agentApprove = (names, options) => run$1(options, async () => {
|
|
|
250
254
|
return !screenshot || screenshot.category === "passed";
|
|
251
255
|
});
|
|
252
256
|
if (unknown.length > 0) throw new Error(`Nothing to approve for: ${unknown.join(", ")} — names must match exactly (see \`cappa agent check --json\`).`);
|
|
253
|
-
|
|
257
|
+
const verdicts = /* @__PURE__ */ new Map();
|
|
258
|
+
if (!!options.label?.length || names.some((name) => byName.get(name)?.category === "changed")) {
|
|
254
259
|
const previous = await readAgentReport(config.outputDir);
|
|
255
260
|
const report = await runAgentCheck({
|
|
256
261
|
outputDir: config.outputDir,
|
|
257
262
|
diff: config.diff,
|
|
258
263
|
judge: previous?.judge ?? "ambiguous"
|
|
259
264
|
});
|
|
260
|
-
const
|
|
261
|
-
for (const entry of report.entries) if (entry.category === "changed" && entry.verdict && labels.has(entry.verdict.label)) wanted.add(entry.name);
|
|
265
|
+
for (const entry of report.entries) if (entry.category === "changed" && entry.verdict) verdicts.set(entry.name, entry.verdict.label);
|
|
262
266
|
}
|
|
267
|
+
const labels = new Set(options.label);
|
|
268
|
+
for (const [name, label] of verdicts) if (labels.has(label)) wanted.add(name);
|
|
263
269
|
const toApprove = [...wanted].flatMap((name) => {
|
|
264
270
|
const screenshot = byName.get(name);
|
|
265
271
|
return screenshot && screenshot.category !== "passed" ? [screenshot] : [];
|
|
266
272
|
});
|
|
273
|
+
const regressions = toApprove.filter((s) => verdicts.get(s.name) === "regression-likely").map((s) => s.name);
|
|
274
|
+
if (regressions.length > 0 && !options.allowRegression) throw new Error(`Refusing to approve regression-likely: ${regressions.join(", ")} — if the change is intended, judge it (\`cappa agent check --judge all\`, then \`cappa agent judge <name> --label intentional-likely\`), or pass --allow-regression.`);
|
|
267
275
|
await new ScreenshotFileSystem(config.outputDir).approveScreenshots(toApprove, config.diff);
|
|
268
276
|
await Promise.all(toApprove.map((screenshot) => clearJudgment(config.outputDir, screenshot.name)));
|
|
269
277
|
const approved = toApprove.map((s) => ({
|
|
@@ -328,7 +336,7 @@ const registerAgentCommand = (program) => {
|
|
|
328
336
|
const agent = program.command("agent").description("Visual review for coding agents: label changes, hand ambiguous ones to an agent, approve");
|
|
329
337
|
agent.command("check").description("Label every changed screenshot and write judgment requests for an agent (does not capture)").option("--judge <mode>", `which changes get a judgment request: ${JUDGE_MODES.join(", ")}`, parseChoice(JUDGE_MODES, "--judge"), "ambiguous").option("--max-tile-regions <count>", "regions rendered into each regions.png", parsePositiveInt).option("--json", "print a JSON summary to stdout").action(agentCheck);
|
|
330
338
|
agent.command("judge").description("Record a verdict for screenshots with a judgment request").argument("<names...>", "screenshot names, exactly as reported").requiredOption("--label <label>", JUDGED_LABELS.join(" | "), parseLabel).requiredOption("--headline <text>", "one line describing the change").option("--rationale <text...>", "reasons for the verdict").option("--confidence <number>", "0 to 1", parseConfidence).option("--json", "print a JSON summary to stdout").action(agentJudge);
|
|
331
|
-
agent.command("approve").description("Approve screenshots by exact name or by verdict label (refused in CI)").argument("[names...]", "screenshot names, exactly as reported").option("--label <label>", "also approve every changed screenshot with this verdict label (repeatable)", collectLabel).option("--json", "print a JSON summary to stdout").action(agentApprove);
|
|
339
|
+
agent.command("approve").description("Approve screenshots by exact name or by verdict label (refused in CI)").argument("[names...]", "screenshot names, exactly as reported").option("--label <label>", "also approve every changed screenshot with this verdict label (repeatable)", collectLabel).option("--allow-regression", "approve screenshots whose current verdict is regression-likely").option("--json", "print a JSON summary to stdout").action(agentApprove);
|
|
332
340
|
agent.command("init").description("Install the cappa skill for coding agents in this project").option("--stack <stack>", `${SKILL_STACK_NAMES.join(", ")} or all (default: detected)`, parseChoice([...SKILL_STACK_NAMES, "all"], "--stack")).option("--force", "overwrite skill files that were modified").option("--runner <command>", "how the project runs cappa, e.g. `pnpm exec cappa` (default: from the lockfile)").option("--json", "print a JSON summary to stdout").action(agentInit);
|
|
333
341
|
};
|
|
334
342
|
//#endregion
|