oc-pilot 0.111.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +9 -5
  3. package/README.ru.md +8 -4
  4. package/dist/cli.js +9 -1
  5. package/dist/cli.js.map +1 -1
  6. package/dist/cli.test.js +24 -0
  7. package/dist/cli.test.js.map +1 -1
  8. package/dist/commands/cuckoo.js +1 -1
  9. package/dist/commands/mirage.js +138 -0
  10. package/dist/commands/mirage.js.map +1 -0
  11. package/dist/commands/warden.js +116 -0
  12. package/dist/commands/warden.js.map +1 -0
  13. package/dist/core/cuckoo.js +1 -1
  14. package/dist/core/cuckoo.js.map +1 -1
  15. package/dist/core/cuckoo.test.js +8 -8
  16. package/dist/core/cuckoo.test.js.map +1 -1
  17. package/dist/core/mirage.js +193 -0
  18. package/dist/core/mirage.js.map +1 -0
  19. package/dist/core/mirage.test.js +120 -0
  20. package/dist/core/mirage.test.js.map +1 -0
  21. package/dist/core/warden.js +274 -0
  22. package/dist/core/warden.js.map +1 -0
  23. package/dist/core/warden.test.js +121 -0
  24. package/dist/core/warden.test.js.map +1 -0
  25. package/dist/mcp-prompts.test.js +2 -0
  26. package/dist/mcp-prompts.test.js.map +1 -1
  27. package/dist/mcp.js +118 -0
  28. package/dist/mcp.js.map +1 -1
  29. package/dist/mcp.test.js +10 -0
  30. package/dist/mcp.test.js.map +1 -1
  31. package/dist/skills.test.js +3 -0
  32. package/dist/skills.test.js.map +1 -1
  33. package/dist/version.js +1 -1
  34. package/docs/integrations.md +5 -5
  35. package/package.json +1 -1
  36. package/skills/agent-self-review/SKILL.md +1 -1
  37. package/skills/commit-discipline/SKILL.md +1 -1
  38. package/skills/oc-pilot/SKILL.md +6 -0
  39. package/skills/secure-diff-gate/SKILL.md +1 -1
  40. package/skills/stack-review-packs/SKILL.md +1 -1
  41. package/skills/test-failure-triage/SKILL.md +1 -1
package/dist/mcp.js CHANGED
@@ -1521,6 +1521,44 @@ const TOOLS = [
1521
1521
  },
1522
1522
  },
1523
1523
  },
1524
+ {
1525
+ name: "mirage",
1526
+ description: "Record fetch responses and Date.now into a cassette, then replay them without the network; replay fails with [MIRAGE MISS] on an unrecorded URL. Actions: record, replay, list, show, clear. record/clear write and need --allow-write; replay executes the command.",
1527
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
1528
+ inputSchema: {
1529
+ type: "object",
1530
+ additionalProperties: false,
1531
+ required: ["action"],
1532
+ properties: {
1533
+ action: { type: "string", enum: ["record", "replay", "list", "show", "clear"] },
1534
+ command: { type: "string", description: "Command to run under the preload" },
1535
+ cassette: { type: "string", description: "Repository-relative cassette JSON" },
1536
+ timeout_ms: { type: "integer", minimum: 1000, maximum: 900000 },
1537
+ force: { type: "boolean", description: "Confirm clear" },
1538
+ ...RESULT_PROPERTIES,
1539
+ },
1540
+ },
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
+ },
1524
1562
  {
1525
1563
  name: "apoptosis",
1526
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.",
@@ -1829,6 +1867,22 @@ const PROMPTS = [
1829
1867
  { name: "context", description: "Why the test is flaky", required: false },
1830
1868
  ],
1831
1869
  },
1870
+ {
1871
+ name: "freeze-the-network",
1872
+ title: "Freeze the network and clock",
1873
+ description: "Record real fetch responses and Date.now into a cassette, then replay them offline and fail on any unrecorded request.",
1874
+ arguments: [
1875
+ { name: "context", description: "What the test is exercising", required: false },
1876
+ ],
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
+ },
1832
1886
  {
1833
1887
  name: "prune-senescent-code",
1834
1888
  title: "Prune senescent AI code",
@@ -4171,6 +4225,47 @@ async function callQuarantine(input, cwd) {
4171
4225
  args.push("--force");
4172
4226
  return toToolResult(await runCli(args, cwd));
4173
4227
  }
4228
+ async function callMirage(input, cwd) {
4229
+ const action = stringArg(input, "action", true);
4230
+ const args = ["mirage", action, "--json"];
4231
+ const command = stringArg(input, "command");
4232
+ if (command)
4233
+ args.push("--command", command);
4234
+ const cassette = stringArg(input, "cassette");
4235
+ if (cassette)
4236
+ args.push("--cassette", cassette);
4237
+ const timeout = integerArg(input, "timeout_ms");
4238
+ if (timeout !== undefined)
4239
+ args.push("--timeout", String(Math.max(1, Math.round(timeout / 1000))) + "s");
4240
+ if (booleanArg(input, "force"))
4241
+ args.push("--force");
4242
+ return toToolResult(await runCli(args, cwd));
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
+ }
4174
4269
  async function callApoptosis(input, cwd) {
4175
4270
  const action = stringArg(input, "action") ?? "scan";
4176
4271
  const args = ["apoptosis", action, "--json"];
@@ -4407,6 +4502,12 @@ async function dispatchTool(name, input, cwd, readOnly) {
4407
4502
  if (name === "quarantine" && ["add", "remove", "clear"].includes(stringArg(input, "action") ?? "")) {
4408
4503
  throw new ToolInputError("quarantine add/remove/clear write .oc-pilot/quarantine.json and are disabled in read-only mode; start the MCP server with --allow-write");
4409
4504
  }
4505
+ if (name === "mirage" && ["record", "clear"].includes(stringArg(input, "action") ?? "")) {
4506
+ throw new ToolInputError("mirage record/clear write cassettes and are disabled in read-only mode; start the MCP server with --allow-write");
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
+ }
4410
4511
  if (name === "honeypot" && (stringArg(input, "action") === "deploy" || stringArg(input, "action") === "remove")) {
4411
4512
  throw new ToolInputError("honeypot deploy/remove writes files and is disabled in read-only mode; start the MCP server with --allow-write");
4412
4513
  }
@@ -4548,6 +4649,10 @@ async function dispatchTool(name, input, cwd, readOnly) {
4548
4649
  return callBeacon(input, cwd);
4549
4650
  case "quarantine":
4550
4651
  return callQuarantine(input, cwd);
4652
+ case "mirage":
4653
+ return callMirage(input, cwd);
4654
+ case "warden":
4655
+ return callWarden(input, cwd);
4551
4656
  case "apoptosis":
4552
4657
  return callApoptosis(input, cwd);
4553
4658
  case "scan_injection":
@@ -4627,6 +4732,15 @@ function summarizeResult(value) {
4627
4732
  if (typeof value.status === "string" && Array.isArray(value.removed) && typeof value.summary === "string") {
4628
4733
  return `oc-pilot: apoptosis ${value.status}, ${String(value.removed.length)} removed`;
4629
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
+ }
4741
+ if (typeof value.mode === "string" && typeof value.cassette === "string" && typeof value.status === "string" && typeof value.entries === "number") {
4742
+ return `oc-pilot: mirage ${value.mode} ${value.status}, ${String(value.entries)} fetch`;
4743
+ }
4630
4744
  if (typeof value.status === "string" && Array.isArray(value.expired) && typeof value.summary === "string") {
4631
4745
  return `oc-pilot: quarantine ${value.status}, ${String(value.expired.length)} expired`;
4632
4746
  }
@@ -4986,6 +5100,10 @@ function promptBody(name, args) {
4986
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}`;
4987
5101
  case "stamp-the-passport":
4988
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}`;
5105
+ case "freeze-the-network":
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}`;
4989
5107
  case "quarantine-the-flake":
4990
5108
  return `Call the oc-pilot "quarantine" tool with action=add and a real test name, owner, reason and a short expiry (14 days or less). Read the expiry and tell the user who owns the fix and when the gate will fail. Use action=check in CI; if it returns [QUARANTINE EXPIRED], fix or delete the test instead of extending the deadline silently. Never quarantine a test without an owner and never make the expiry permanent. add/remove/clear need --allow-write.${suffix}`;
4991
5109
  case "stamp-the-beacon":