oc-pilot 0.112.0 → 0.113.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/mcp.js CHANGED
@@ -1539,6 +1539,26 @@ const TOOLS = [
1539
1539
  },
1540
1540
  },
1541
1541
  },
1542
+ {
1543
+ name: "warden",
1544
+ description: "Check the diff against .oc-pilot/policy.json: forbidden paths, content, dependencies and extensions, required tests and max files. Deterministic, offline and read-only for check/show; init writes the policy and needs --allow-write.",
1545
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
1546
+ inputSchema: {
1547
+ type: "object",
1548
+ additionalProperties: false,
1549
+ required: ["action"],
1550
+ properties: {
1551
+ action: { type: "string", enum: ["check", "init", "show"] },
1552
+ force: { type: "boolean", description: "Overwrite an existing policy on init" },
1553
+ diff: { type: "string", description: "Unified diff text; omit to use the project's git diff" },
1554
+ base: { type: "string" },
1555
+ staged: { type: "boolean" },
1556
+ unstaged: { type: "boolean" },
1557
+ include_untracked: { type: "boolean" },
1558
+ ...RESULT_PROPERTIES,
1559
+ },
1560
+ },
1561
+ },
1542
1562
  {
1543
1563
  name: "apoptosis",
1544
1564
  description: "Scan functions marked /* @lifespan: 30d */ and report [Senescent] when the marker is older than the lifespan and the symbol has no references. With action=apply and confirm=true, comment the senescent functions out in a shadow git worktree, run tests and land the diff only if the suite is green. Apply writes files and needs --allow-write.",
@@ -1855,6 +1875,14 @@ const PROMPTS = [
1855
1875
  { name: "context", description: "What the test is exercising", required: false },
1856
1876
  ],
1857
1877
  },
1878
+ {
1879
+ name: "enforce-the-policy",
1880
+ title: "Enforce the repository policy",
1881
+ description: "Check the diff against the policy file, stop on [POLICY VIOLATION] and fix the code instead of weakening the rule.",
1882
+ arguments: [
1883
+ { name: "context", description: "Why the change is needed", required: false },
1884
+ ],
1885
+ },
1858
1886
  {
1859
1887
  name: "prune-senescent-code",
1860
1888
  title: "Prune senescent AI code",
@@ -4213,6 +4241,31 @@ async function callMirage(input, cwd) {
4213
4241
  args.push("--force");
4214
4242
  return toToolResult(await runCli(args, cwd));
4215
4243
  }
4244
+ async function callWarden(input, cwd) {
4245
+ const temp = new TempFiles();
4246
+ try {
4247
+ const action = stringArg(input, "action", true);
4248
+ const args = ["warden", action, "--json"];
4249
+ if (booleanArg(input, "force"))
4250
+ args.push("--force");
4251
+ const diff = stringArg(input, "diff");
4252
+ if (diff)
4253
+ args.push("--diff", temp.write("warden.diff", diff));
4254
+ const base = baseArg(input);
4255
+ if (base)
4256
+ args.push("--base", base);
4257
+ if (booleanArg(input, "staged"))
4258
+ args.push("--staged");
4259
+ if (booleanArg(input, "unstaged"))
4260
+ args.push("--unstaged");
4261
+ if (booleanArg(input, "include_untracked"))
4262
+ args.push("--include-untracked");
4263
+ return toToolResult(await runCli(args, cwd));
4264
+ }
4265
+ finally {
4266
+ temp.cleanup();
4267
+ }
4268
+ }
4216
4269
  async function callApoptosis(input, cwd) {
4217
4270
  const action = stringArg(input, "action") ?? "scan";
4218
4271
  const args = ["apoptosis", action, "--json"];
@@ -4452,6 +4505,9 @@ async function dispatchTool(name, input, cwd, readOnly) {
4452
4505
  if (name === "mirage" && ["record", "clear"].includes(stringArg(input, "action") ?? "")) {
4453
4506
  throw new ToolInputError("mirage record/clear write cassettes and are disabled in read-only mode; start the MCP server with --allow-write");
4454
4507
  }
4508
+ if (name === "warden" && stringArg(input, "action") === "init") {
4509
+ throw new ToolInputError("warden init writes .oc-pilot/policy.json and is disabled in read-only mode; start the MCP server with --allow-write");
4510
+ }
4455
4511
  if (name === "honeypot" && (stringArg(input, "action") === "deploy" || stringArg(input, "action") === "remove")) {
4456
4512
  throw new ToolInputError("honeypot deploy/remove writes files and is disabled in read-only mode; start the MCP server with --allow-write");
4457
4513
  }
@@ -4595,6 +4651,8 @@ async function dispatchTool(name, input, cwd, readOnly) {
4595
4651
  return callQuarantine(input, cwd);
4596
4652
  case "mirage":
4597
4653
  return callMirage(input, cwd);
4654
+ case "warden":
4655
+ return callWarden(input, cwd);
4598
4656
  case "apoptosis":
4599
4657
  return callApoptosis(input, cwd);
4600
4658
  case "scan_injection":
@@ -4674,6 +4732,12 @@ function summarizeResult(value) {
4674
4732
  if (typeof value.status === "string" && Array.isArray(value.removed) && typeof value.summary === "string") {
4675
4733
  return `oc-pilot: apoptosis ${value.status}, ${String(value.removed.length)} removed`;
4676
4734
  }
4735
+ if (typeof value.status === "string" && Array.isArray(value.violations) && typeof value.files === "number") {
4736
+ return `oc-pilot: warden ${value.status}, ${String(value.violations.length)} violation(s)`;
4737
+ }
4738
+ if (Array.isArray(value.rules) && typeof value.version === "number") {
4739
+ return `oc-pilot: warden ${String(value.rules.length)} rule(s)`;
4740
+ }
4677
4741
  if (typeof value.mode === "string" && typeof value.cassette === "string" && typeof value.status === "string" && typeof value.entries === "number") {
4678
4742
  return `oc-pilot: mirage ${value.mode} ${value.status}, ${String(value.entries)} fetch`;
4679
4743
  }
@@ -5036,6 +5100,8 @@ function promptBody(name, args) {
5036
5100
  return `Call the oc-pilot "skeptic" tool on the proposed diff. Read the hypothesis reason and the exact status. If it returns bug, stop and quote the failing test output: the generated test fails on the diff and passes on HEAD, so the change is falsified. Fix the code or the test expectation, then rerun; do not delete the test, do not weaken the assertion and do not claim a bug from a test that also fails on HEAD. If it returns clean, say that the hypothesis was rejected, not that the code is proven correct. If it returns unfalsifiable, explain that the test did not distinguish the diff from HEAD. If it returns error, report the infrastructure failure instead of guessing.${suffix}`;
5037
5101
  case "stamp-the-passport":
5038
5102
  return `Call the oc-pilot "passport" tool with action=write after the checks you actually ran, then action=verify. Record only real checks as name=pass|warn|fail|skip, the real agent/model and the commit. If verify returns [PASSPORT STALE] or [PASSPORT TAMPERED], stop: the manifest no longer matches the tree; rewrite it from the current state or investigate the change. Never mark a check as pass without running it, never edit the manifest by hand to hide a mismatch, and never claim that a passport proves correctness: it proves what was recorded and that the files still match. write/clear need --allow-write.${suffix}`;
5103
+ case "enforce-the-policy":
5104
+ return `Call the oc-pilot "warden" tool with action=check on the proposed diff. Read every violation with its rule, file and evidence. If it returns [POLICY VIOLATION], stop: the change breaks a repository rule. Fix the code or ask the owner to change the policy; never delete a rule, weaken a pattern or add an exception just to pass. init writes the sample policy and needs --allow-write. Deterministic and offline.${suffix}`;
5039
5105
  case "freeze-the-network":
5040
5106
  return `Call the oc-pilot "mirage" tool with action=record, the test command and a cassette path. Then stop the network or run in an environment without it and call action=replay with the same command. Read the recorded entries and clock values. If replay returns [MIRAGE MISS], stop: the test depends on an unrecorded request; record it explicitly instead of widening the matcher or deleting the assertion. Do not hand-edit the cassette to fake a response. record/clear need --allow-write.${suffix}`;
5041
5107
  case "quarantine-the-flake":