@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.cjs
CHANGED
|
@@ -38,14 +38,15 @@ let _cappa_client = require("@cappa/client");
|
|
|
38
38
|
let _cappa_server = require("@cappa/server");
|
|
39
39
|
let node_crypto = require("node:crypto");
|
|
40
40
|
//#region package.json
|
|
41
|
-
var version = "0.
|
|
41
|
+
var version = "0.15.0";
|
|
42
42
|
//#endregion
|
|
43
43
|
//#region src/utils/agentSkills.ts
|
|
44
44
|
/**
|
|
45
45
|
* Agent integrations `cappa agent init` can install, and the files each one
|
|
46
46
|
* gets.
|
|
47
47
|
*
|
|
48
|
-
* - `claude` — Claude Code: the skill in `.claude/skills/cappa
|
|
48
|
+
* - `claude` — Claude Code: the skill in `.claude/skills/cappa` plus a
|
|
49
|
+
* `cappa-judge` subagent that judges screenshots in its own context.
|
|
49
50
|
* - `agents` — the vendor-neutral Agent Skills directory `.agents/skills`,
|
|
50
51
|
* read by Codex, OpenCode and other agents that adopted it.
|
|
51
52
|
* - `opencode` — OpenCode: the `.agents` skill plus slash commands that run
|
|
@@ -65,7 +66,10 @@ const skillInto = (dir) => SKILL.map((source) => ({
|
|
|
65
66
|
target: node_path.default.join(dir, node_path.default.basename(source))
|
|
66
67
|
}));
|
|
67
68
|
const STACK_FILES = {
|
|
68
|
-
claude: skillInto(".claude/skills/cappa"),
|
|
69
|
+
claude: [...skillInto(".claude/skills/cappa"), {
|
|
70
|
+
source: "claude/agents/cappa-judge.md",
|
|
71
|
+
target: node_path.default.join(".claude", "agents", "cappa-judge.md")
|
|
72
|
+
}],
|
|
69
73
|
agents: skillInto(".agents/skills/cappa"),
|
|
70
74
|
opencode: [...skillInto(".agents/skills/cappa"), ...[
|
|
71
75
|
"commands/cappa-review.md",
|
|
@@ -271,20 +275,24 @@ const agentApprove = (names, options) => run$1(options, async () => {
|
|
|
271
275
|
return !screenshot || screenshot.category === "passed";
|
|
272
276
|
});
|
|
273
277
|
if (unknown.length > 0) throw new Error(`Nothing to approve for: ${unknown.join(", ")} — names must match exactly (see \`cappa agent check --json\`).`);
|
|
274
|
-
|
|
278
|
+
const verdicts = /* @__PURE__ */ new Map();
|
|
279
|
+
if (!!options.label?.length || names.some((name) => byName.get(name)?.category === "changed")) {
|
|
275
280
|
const previous = await (0, _cappa_core.readAgentReport)(config.outputDir);
|
|
276
281
|
const report = await (0, _cappa_core.runAgentCheck)({
|
|
277
282
|
outputDir: config.outputDir,
|
|
278
283
|
diff: config.diff,
|
|
279
284
|
judge: previous?.judge ?? "ambiguous"
|
|
280
285
|
});
|
|
281
|
-
const
|
|
282
|
-
for (const entry of report.entries) if (entry.category === "changed" && entry.verdict && labels.has(entry.verdict.label)) wanted.add(entry.name);
|
|
286
|
+
for (const entry of report.entries) if (entry.category === "changed" && entry.verdict) verdicts.set(entry.name, entry.verdict.label);
|
|
283
287
|
}
|
|
288
|
+
const labels = new Set(options.label);
|
|
289
|
+
for (const [name, label] of verdicts) if (labels.has(label)) wanted.add(name);
|
|
284
290
|
const toApprove = [...wanted].flatMap((name) => {
|
|
285
291
|
const screenshot = byName.get(name);
|
|
286
292
|
return screenshot && screenshot.category !== "passed" ? [screenshot] : [];
|
|
287
293
|
});
|
|
294
|
+
const regressions = toApprove.filter((s) => verdicts.get(s.name) === "regression-likely").map((s) => s.name);
|
|
295
|
+
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.`);
|
|
288
296
|
await new _cappa_core.ScreenshotFileSystem(config.outputDir).approveScreenshots(toApprove, config.diff);
|
|
289
297
|
await Promise.all(toApprove.map((screenshot) => (0, _cappa_core.clearJudgment)(config.outputDir, screenshot.name)));
|
|
290
298
|
const approved = toApprove.map((s) => ({
|
|
@@ -349,7 +357,7 @@ const registerAgentCommand = (program) => {
|
|
|
349
357
|
const agent = program.command("agent").description("Visual review for coding agents: label changes, hand ambiguous ones to an agent, approve");
|
|
350
358
|
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: ${_cappa_core.JUDGE_MODES.join(", ")}`, parseChoice(_cappa_core.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);
|
|
351
359
|
agent.command("judge").description("Record a verdict for screenshots with a judgment request").argument("<names...>", "screenshot names, exactly as reported").requiredOption("--label <label>", _cappa_core.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);
|
|
352
|
-
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);
|
|
360
|
+
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);
|
|
353
361
|
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);
|
|
354
362
|
};
|
|
355
363
|
//#endregion
|