@cappa/cli 0.17.1 → 0.18.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 CHANGED
@@ -38,7 +38,7 @@ 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.17.1";
41
+ var version = "0.18.0";
42
42
  //#endregion
43
43
  //#region src/utils/agentSkills.ts
44
44
  /**
@@ -413,8 +413,7 @@ const run$1 = async (options, action) => {
413
413
  const LABEL_COLORS = {
414
414
  "regression-likely": chalk.default.red,
415
415
  "intentional-likely": chalk.default.green,
416
- "noise-likely": chalk.default.gray,
417
- ambiguous: chalk.default.yellow
416
+ "noise-likely": chalk.default.gray
418
417
  };
419
418
  /** Human-readable lines for a report — what `--json` prints, for people. */
420
419
  const describeAgentReport = (report) => {
@@ -422,13 +421,14 @@ const describeAgentReport = (report) => {
422
421
  const lines = [`${totals.passed}/${totals.total} passed · ${totals.changed} changed · ${totals.new} new · ${totals.deleted} deleted`];
423
422
  if (totals.pendingJudgments > 0) lines.push(chalk.default.yellow(`${totals.pendingJudgments} awaiting judgment in ${report.outputDir}/.cappa-agent/judgments`));
424
423
  for (const entry of report.entries) {
425
- if (entry.category !== "changed" || !entry.verdict) {
424
+ if (entry.category !== "changed") {
426
425
  lines.push(`${chalk.default.bold(entry.name)} ${chalk.default.dim(entry.category)}`);
427
426
  continue;
428
427
  }
429
- const { label, headline, source } = entry.verdict;
430
- const tags = [source === "agent" ? "judged" : void 0, entry.pending ? "pending" : void 0].filter(Boolean);
431
- lines.push(`${chalk.default.bold(entry.name)} ${LABEL_COLORS[label](label)} — ${headline}${tags.length > 0 ? chalk.default.dim(` (${tags.join(", ")})`) : ""}`);
428
+ if (entry.verdict) {
429
+ const { label, headline } = entry.verdict;
430
+ lines.push(`${chalk.default.bold(entry.name)} ${LABEL_COLORS[label](label)} — ${headline}`);
431
+ } else lines.push(`${chalk.default.bold(entry.name)} ${chalk.default.yellow("awaiting judgment")} — ${entry.change ?? "changed"}`);
432
432
  if (entry.verdictError) lines.push(chalk.default.red(` verdict.json ignored: ${entry.verdictError}`));
433
433
  }
434
434
  return lines;
@@ -438,7 +438,6 @@ const agentCheck = (options) => run$1(options, async () => {
438
438
  const report = await (0, _cappa_core.runAgentCheck)({
439
439
  outputDir: config.outputDir,
440
440
  diff: config.diff,
441
- judge: options.judge,
442
441
  maxTileRegions: options.maxTileRegions
443
442
  });
444
443
  if (options.json) printJson((0, _cappa_core.toSlimAgentReport)(report));
@@ -480,11 +479,9 @@ const agentApprove = (names, options) => run$1(options, async () => {
480
479
  if (unknown.length > 0) throw new Error(`Nothing to approve for: ${unknown.join(", ")} — names must match exactly (see \`cappa agent check --json\`).`);
481
480
  const verdicts = /* @__PURE__ */ new Map();
482
481
  if (!!options.label?.length || names.some((name) => byName.get(name)?.category === "changed")) {
483
- const previous = await (0, _cappa_core.readAgentReport)(config.outputDir);
484
482
  const report = await (0, _cappa_core.runAgentCheck)({
485
483
  outputDir: config.outputDir,
486
- diff: config.diff,
487
- judge: previous?.judge ?? "ambiguous"
484
+ diff: config.diff
488
485
  });
489
486
  for (const entry of report.entries) if (entry.category === "changed" && entry.verdict) verdicts.set(entry.name, entry.verdict.label);
490
487
  }
@@ -495,7 +492,7 @@ const agentApprove = (names, options) => run$1(options, async () => {
495
492
  return screenshot && screenshot.category !== "passed" ? [screenshot] : [];
496
493
  });
497
494
  const regressions = toApprove.filter((s) => verdicts.get(s.name) === "regression-likely").map((s) => s.name);
498
- 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.`);
495
+ if (regressions.length > 0 && !options.allowRegression) throw new Error(`Refusing to approve regression-likely: ${regressions.join(", ")} — if the change is intended, judge it again (\`cappa agent judge <name> --label intentional-likely\`), or pass --allow-regression.`);
499
496
  await new _cappa_core.ScreenshotFileSystem(config.outputDir).approveScreenshots(toApprove, config.diff);
500
497
  await Promise.all(toApprove.map((screenshot) => (0, _cappa_core.clearJudgment)(config.outputDir, screenshot.name)));
501
498
  const approved = toApprove.map((s) => ({
@@ -601,7 +598,7 @@ const parseChoice = (choices, what) => (value) => {
601
598
  return value;
602
599
  };
603
600
  const parseLabel = (value) => {
604
- if (!(0, _cappa_core.isJudgedLabel)(value)) throw new commander.InvalidArgumentError(`label must be one of: ${_cappa_core.JUDGED_LABELS.join(", ")}`);
601
+ if (!(0, _cappa_core.isVerdictLabel)(value)) throw new commander.InvalidArgumentError(`label must be one of: ${_cappa_core.VERDICT_LABELS.join(", ")}`);
605
602
  return value;
606
603
  };
607
604
  const collectLabel = (value, previous = []) => [...previous, parseLabel(value)];
@@ -616,9 +613,9 @@ const parsePositiveInt = (value) => {
616
613
  return parsed;
617
614
  };
618
615
  const registerAgentCommand = (program) => {
619
- const agent = program.command("agent").description("Visual review for coding agents: label changes, hand ambiguous ones to an agent, approve");
620
- 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);
621
- 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);
616
+ const agent = program.command("agent").description("Visual review for coding agents: hand every change to a judge, record verdicts, approve");
617
+ agent.command("check").description("Write a judgment request for every changed screenshot and apply verdicts already recorded (does not capture)").option("--max-tile-regions <count>", "regions rendered into each regions.png", parsePositiveInt).option("--json", "print a JSON summary to stdout").action(agentCheck);
618
+ 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.VERDICT_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);
622
619
  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);
623
620
  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("--judge-model <model>", "pin the cappa-judge subagent to a model that can read images: provider/model for OpenCode, an alias or model id for Claude Code (default: the calling model)").option("--json", "print a JSON summary to stdout").action(agentInit);
624
621
  agent.command("guard", { hidden: true }).description("Allow or block a cappa-judge Bash call (Claude Code hook)").requiredOption("--runner <command>", "how the project runs cappa").action(agentGuard);