oc-pilot 0.160.0 → 0.162.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/CHANGELOG.md +6 -0
- package/CONTRIBUTING.md +5 -0
- package/Dockerfile +2 -1
- package/README.md +42 -1261
- package/README.ru.md +52 -1144
- package/action.yml +8 -2
- package/dist/cli.js +62 -179
- package/dist/cli.js.map +1 -1
- package/dist/command-groups.js +52 -0
- package/dist/command-groups.js.map +1 -0
- package/dist/command-registry.js +92 -0
- package/dist/command-registry.js.map +1 -0
- package/dist/commands/apoptosis.js +16 -1
- package/dist/commands/apoptosis.js.map +1 -1
- package/dist/commands/blindfold.js +30 -2
- package/dist/commands/blindfold.js.map +1 -1
- package/dist/commands/butterfly.js +9 -5
- package/dist/commands/butterfly.js.map +1 -1
- package/dist/commands/cache.js +24 -14
- package/dist/commands/cache.js.map +1 -1
- package/dist/commands/deps.js +30 -0
- package/dist/commands/deps.js.map +1 -1
- package/dist/commands/doctor.js +11 -448
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/fix.js +38 -345
- package/dist/commands/fix.js.map +1 -1
- package/dist/commands/flight.js +15 -33
- package/dist/commands/flight.js.map +1 -1
- package/dist/commands/hygiene.js +47 -0
- package/dist/commands/hygiene.js.map +1 -0
- package/dist/commands/metrics.js +49 -0
- package/dist/commands/metrics.js.map +1 -0
- package/dist/commands/preflight.js +11 -6
- package/dist/commands/preflight.js.map +1 -1
- package/dist/commands/review.js +44 -215
- package/dist/commands/review.js.map +1 -1
- package/dist/commands/setup.js +10 -331
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/test-gen.js +25 -246
- package/dist/commands/test-gen.js.map +1 -1
- package/dist/core/blindfold.js +63 -0
- package/dist/core/blindfold.js.map +1 -1
- package/dist/core/butterfly.js +12 -0
- package/dist/core/butterfly.js.map +1 -1
- package/dist/core/cache.js +161 -56
- package/dist/core/cache.js.map +1 -1
- package/dist/core/deps-registry.js +169 -0
- package/dist/core/deps-registry.js.map +1 -0
- package/dist/core/doctor.js +448 -0
- package/dist/core/doctor.js.map +1 -0
- package/dist/core/expiry.js +39 -0
- package/dist/core/expiry.js.map +1 -0
- package/dist/core/fix.js +298 -0
- package/dist/core/fix.js.map +1 -0
- package/dist/core/flight/bundle-report.js +163 -0
- package/dist/core/flight/bundle-report.js.map +1 -0
- package/dist/core/flight/bundles.js +162 -0
- package/dist/core/flight/bundles.js.map +1 -0
- package/dist/core/flight/compare-reports.js +107 -0
- package/dist/core/flight/compare-reports.js.map +1 -0
- package/dist/core/flight/comparison.js +94 -0
- package/dist/core/flight/comparison.js.map +1 -0
- package/dist/core/flight/diffs.js +67 -0
- package/dist/core/flight/diffs.js.map +1 -0
- package/dist/core/flight/events.js +78 -0
- package/dist/core/flight/events.js.map +1 -0
- package/dist/core/flight/html-reports.js +73 -0
- package/dist/core/flight/html-reports.js.map +1 -0
- package/dist/core/flight/inspection.js +28 -0
- package/dist/core/flight/inspection.js.map +1 -0
- package/dist/core/flight/proof.js +135 -0
- package/dist/core/flight/proof.js.map +1 -0
- package/dist/core/flight/queries.js +218 -0
- package/dist/core/flight/queries.js.map +1 -0
- package/dist/core/flight/query-reports.js +35 -0
- package/dist/core/flight/query-reports.js.map +1 -0
- package/dist/core/flight/runner.js +141 -0
- package/dist/core/flight/runner.js.map +1 -0
- package/dist/core/flight/session-reports.js +166 -0
- package/dist/core/flight/session-reports.js.map +1 -0
- package/dist/core/flight/sessions.js +252 -0
- package/dist/core/flight/sessions.js.map +1 -0
- package/dist/core/flight/types.js +2 -0
- package/dist/core/flight/types.js.map +1 -0
- package/dist/core/flight/worktree-reports.js +39 -0
- package/dist/core/flight/worktree-reports.js.map +1 -0
- package/dist/core/flight/worktrees.js +96 -0
- package/dist/core/flight/worktrees.js.map +1 -0
- package/dist/core/flight.js +16 -1761
- package/dist/core/flight.js.map +1 -1
- package/dist/core/hygiene.js +44 -0
- package/dist/core/hygiene.js.map +1 -0
- package/dist/core/metrics.js +172 -0
- package/dist/core/metrics.js.map +1 -0
- package/dist/core/preflight-run.js +5 -2
- package/dist/core/preflight-run.js.map +1 -1
- package/dist/core/preflight-sarif.js +64 -0
- package/dist/core/preflight-sarif.js.map +1 -0
- package/dist/core/receipt.js +41 -0
- package/dist/core/receipt.js.map +1 -1
- package/dist/core/review-publication.js +57 -0
- package/dist/core/review-publication.js.map +1 -0
- package/dist/core/review.js +148 -0
- package/dist/core/review.js.map +1 -0
- package/dist/core/sarif.js +21 -5
- package/dist/core/sarif.js.map +1 -1
- package/dist/core/setup.js +333 -0
- package/dist/core/setup.js.map +1 -0
- package/dist/core/test-gen.js +224 -0
- package/dist/core/test-gen.js.map +1 -0
- package/dist/core/test-weakening.js +58 -16
- package/dist/core/test-weakening.js.map +1 -1
- package/dist/mcp.js +137 -19
- package/dist/mcp.js.map +1 -1
- package/dist/version.js +1 -1
- package/docs/integrations.md +136 -6
- package/docs/reference.md +1318 -0
- package/docs/reference.ru.md +1191 -0
- package/package.json +5 -4
- package/skills/agent-self-review/SKILL.md +1 -1
- package/skills/commit-discipline/SKILL.md +1 -1
- package/skills/secure-diff-gate/SKILL.md +1 -1
- package/skills/stack-review-packs/SKILL.md +1 -1
- package/skills/test-failure-triage/SKILL.md +1 -1
- package/dist/cli.test.js +0 -2493
- package/dist/cli.test.js.map +0 -1
- package/dist/commands/commit.test.js +0 -160
- package/dist/commands/commit.test.js.map +0 -1
- package/dist/commands/day.test.js +0 -45
- package/dist/commands/day.test.js.map +0 -1
- package/dist/commands/doctor.test.js +0 -189
- package/dist/commands/doctor.test.js.map +0 -1
- package/dist/commands/init.test.js +0 -138
- package/dist/commands/init.test.js.map +0 -1
- package/dist/commands/install-hook.test.js +0 -107
- package/dist/commands/install-hook.test.js.map +0 -1
- package/dist/commands/replay.test.js +0 -125
- package/dist/commands/replay.test.js.map +0 -1
- package/dist/commands/review.test.js +0 -160
- package/dist/commands/review.test.js.map +0 -1
- package/dist/commands/slop.test.js +0 -135
- package/dist/commands/slop.test.js.map +0 -1
- package/dist/core/alien-dna.test.js +0 -117
- package/dist/core/alien-dna.test.js.map +0 -1
- package/dist/core/anthropic.test.js +0 -116
- package/dist/core/anthropic.test.js.map +0 -1
- package/dist/core/anti-regression.test.js +0 -154
- package/dist/core/anti-regression.test.js.map +0 -1
- package/dist/core/antibody.test.js +0 -142
- package/dist/core/antibody.test.js.map +0 -1
- package/dist/core/apoptosis.test.js +0 -104
- package/dist/core/apoptosis.test.js.map +0 -1
- package/dist/core/aql.test.js +0 -64
- package/dist/core/aql.test.js.map +0 -1
- package/dist/core/arch-diff.test.js +0 -93
- package/dist/core/arch-diff.test.js.map +0 -1
- package/dist/core/authz.test.js +0 -125
- package/dist/core/authz.test.js.map +0 -1
- package/dist/core/autopsy.test.js +0 -106
- package/dist/core/autopsy.test.js.map +0 -1
- package/dist/core/bankruptcy.test.js +0 -91
- package/dist/core/bankruptcy.test.js.map +0 -1
- package/dist/core/baseline.test.js +0 -91
- package/dist/core/baseline.test.js.map +0 -1
- package/dist/core/battle.test.js +0 -116
- package/dist/core/battle.test.js.map +0 -1
- package/dist/core/beacon.test.js +0 -114
- package/dist/core/beacon.test.js.map +0 -1
- package/dist/core/blindfold.test.js +0 -77
- package/dist/core/blindfold.test.js.map +0 -1
- package/dist/core/boundaries.test.js +0 -62
- package/dist/core/boundaries.test.js.map +0 -1
- package/dist/core/bounty.test.js +0 -82
- package/dist/core/bounty.test.js.map +0 -1
- package/dist/core/brag.test.js +0 -43
- package/dist/core/brag.test.js.map +0 -1
- package/dist/core/butterfly.test.js +0 -146
- package/dist/core/butterfly.test.js.map +0 -1
- package/dist/core/cache.test.js +0 -159
- package/dist/core/cache.test.js.map +0 -1
- package/dist/core/chronos.test.js +0 -139
- package/dist/core/chronos.test.js.map +0 -1
- package/dist/core/cinema.test.js +0 -73
- package/dist/core/cinema.test.js.map +0 -1
- package/dist/core/clairvoyant.test.js +0 -144
- package/dist/core/clairvoyant.test.js.map +0 -1
- package/dist/core/compliance.test.js +0 -123
- package/dist/core/compliance.test.js.map +0 -1
- package/dist/core/config.test.js +0 -211
- package/dist/core/config.test.js.map +0 -1
- package/dist/core/contract-drift.test.js +0 -166
- package/dist/core/contract-drift.test.js.map +0 -1
- package/dist/core/cost.test.js +0 -103
- package/dist/core/cost.test.js.map +0 -1
- package/dist/core/coverage.test.js +0 -190
- package/dist/core/coverage.test.js.map +0 -1
- package/dist/core/cuckoo.test.js +0 -98
- package/dist/core/cuckoo.test.js.map +0 -1
- package/dist/core/deps-fix.test.js +0 -176
- package/dist/core/deps-fix.test.js.map +0 -1
- package/dist/core/deps-health.test.js +0 -230
- package/dist/core/deps-health.test.js.map +0 -1
- package/dist/core/deps-why.test.js +0 -175
- package/dist/core/deps-why.test.js.map +0 -1
- package/dist/core/deps.test.js +0 -88
- package/dist/core/deps.test.js.map +0 -1
- package/dist/core/diff.test.js +0 -94
- package/dist/core/diff.test.js.map +0 -1
- package/dist/core/echo.test.js +0 -90
- package/dist/core/echo.test.js.map +0 -1
- package/dist/core/ecosystem-verify.test.js +0 -158
- package/dist/core/ecosystem-verify.test.js.map +0 -1
- package/dist/core/engine-preset.test.js +0 -60
- package/dist/core/engine-preset.test.js.map +0 -1
- package/dist/core/engine.test.js +0 -206
- package/dist/core/engine.test.js.map +0 -1
- package/dist/core/env-sync.test.js +0 -99
- package/dist/core/env-sync.test.js.map +0 -1
- package/dist/core/file-context.test.js +0 -58
- package/dist/core/file-context.test.js.map +0 -1
- package/dist/core/findings-baseline.test.js +0 -77
- package/dist/core/findings-baseline.test.js.map +0 -1
- package/dist/core/findings.test.js +0 -62
- package/dist/core/findings.test.js.map +0 -1
- package/dist/core/flaky.test.js +0 -97
- package/dist/core/flaky.test.js.map +0 -1
- package/dist/core/flight.test.js +0 -853
- package/dist/core/flight.test.js.map +0 -1
- package/dist/core/format.test.js +0 -26
- package/dist/core/format.test.js.map +0 -1
- package/dist/core/fuzz.test.js +0 -121
- package/dist/core/fuzz.test.js.map +0 -1
- package/dist/core/gitlab.test.js +0 -199
- package/dist/core/gitlab.test.js.map +0 -1
- package/dist/core/hemorrhage.test.js +0 -138
- package/dist/core/hemorrhage.test.js.map +0 -1
- package/dist/core/hivemind.test.js +0 -79
- package/dist/core/hivemind.test.js.map +0 -1
- package/dist/core/hologram.test.js +0 -124
- package/dist/core/hologram.test.js.map +0 -1
- package/dist/core/honeypot.test.js +0 -106
- package/dist/core/honeypot.test.js.map +0 -1
- package/dist/core/hooks.test.js +0 -132
- package/dist/core/hooks.test.js.map +0 -1
- package/dist/core/hyper-chamber.test.js +0 -105
- package/dist/core/hyper-chamber.test.js.map +0 -1
- package/dist/core/impact.test.js +0 -105
- package/dist/core/impact.test.js.map +0 -1
- package/dist/core/import-graph.test.js +0 -68
- package/dist/core/import-graph.test.js.map +0 -1
- package/dist/core/injection-scan.test.js +0 -100
- package/dist/core/injection-scan.test.js.map +0 -1
- package/dist/core/injection.test.js +0 -45
- package/dist/core/injection.test.js.map +0 -1
- package/dist/core/intent.test.js +0 -86
- package/dist/core/intent.test.js.map +0 -1
- package/dist/core/invariants.test.js +0 -87
- package/dist/core/invariants.test.js.map +0 -1
- package/dist/core/lang.test.js +0 -22
- package/dist/core/lang.test.js.map +0 -1
- package/dist/core/last-review.test.js +0 -97
- package/dist/core/last-review.test.js.map +0 -1
- package/dist/core/lockfile-support.test.js +0 -112
- package/dist/core/lockfile-support.test.js.map +0 -1
- package/dist/core/lockfile.test.js +0 -203
- package/dist/core/lockfile.test.js.map +0 -1
- package/dist/core/mayday.test.js +0 -117
- package/dist/core/mayday.test.js.map +0 -1
- package/dist/core/mirage.test.js +0 -120
- package/dist/core/mirage.test.js.map +0 -1
- package/dist/core/mitosis.test.js +0 -170
- package/dist/core/mitosis.test.js.map +0 -1
- package/dist/core/mock-leak.test.js +0 -79
- package/dist/core/mock-leak.test.js.map +0 -1
- package/dist/core/mutation.test.js +0 -104
- package/dist/core/mutation.test.js.map +0 -1
- package/dist/core/opencode.test.js +0 -68
- package/dist/core/opencode.test.js.map +0 -1
- package/dist/core/oracle.test.js +0 -136
- package/dist/core/oracle.test.js.map +0 -1
- package/dist/core/osv.test.js +0 -173
- package/dist/core/osv.test.js.map +0 -1
- package/dist/core/output-format.test.js +0 -102
- package/dist/core/output-format.test.js.map +0 -1
- package/dist/core/pack.test.js +0 -129
- package/dist/core/pack.test.js.map +0 -1
- package/dist/core/passport.test.js +0 -173
- package/dist/core/passport.test.js.map +0 -1
- package/dist/core/patch.test.js +0 -70
- package/dist/core/patch.test.js.map +0 -1
- package/dist/core/phantom.test.js +0 -58
- package/dist/core/phantom.test.js.map +0 -1
- package/dist/core/polygraph.test.js +0 -110
- package/dist/core/polygraph.test.js.map +0 -1
- package/dist/core/pr-comment.test.js +0 -53
- package/dist/core/pr-comment.test.js.map +0 -1
- package/dist/core/pr-review.test.js +0 -62
- package/dist/core/pr-review.test.js.map +0 -1
- package/dist/core/preflight.test.js +0 -242
- package/dist/core/preflight.test.js.map +0 -1
- package/dist/core/presets.test.js +0 -79
- package/dist/core/presets.test.js.map +0 -1
- package/dist/core/project.test.js +0 -75
- package/dist/core/project.test.js.map +0 -1
- package/dist/core/prompt.golden.test.js +0 -74
- package/dist/core/prompt.golden.test.js.map +0 -1
- package/dist/core/prompt.test.js +0 -122
- package/dist/core/prompt.test.js.map +0 -1
- package/dist/core/quarantine.test.js +0 -98
- package/dist/core/quarantine.test.js.map +0 -1
- package/dist/core/readiness-fix.test.js +0 -127
- package/dist/core/readiness-fix.test.js.map +0 -1
- package/dist/core/readiness.test.js +0 -318
- package/dist/core/readiness.test.js.map +0 -1
- package/dist/core/receipt.test.js +0 -193
- package/dist/core/receipt.test.js.map +0 -1
- package/dist/core/reviewers.test.js +0 -105
- package/dist/core/reviewers.test.js.map +0 -1
- package/dist/core/roast.test.js +0 -19
- package/dist/core/roast.test.js.map +0 -1
- package/dist/core/router.test.js +0 -157
- package/dist/core/router.test.js.map +0 -1
- package/dist/core/rules.test.js +0 -72
- package/dist/core/rules.test.js.map +0 -1
- package/dist/core/sarif.test.js +0 -60
- package/dist/core/sarif.test.js.map +0 -1
- package/dist/core/sast.test.js +0 -119
- package/dist/core/sast.test.js.map +0 -1
- package/dist/core/sbom.test.js +0 -81
- package/dist/core/sbom.test.js.map +0 -1
- package/dist/core/scalpel.test.js +0 -132
- package/dist/core/scalpel.test.js.map +0 -1
- package/dist/core/second-opinion.test.js +0 -89
- package/dist/core/second-opinion.test.js.map +0 -1
- package/dist/core/secrets.test.js +0 -194
- package/dist/core/secrets.test.js.map +0 -1
- package/dist/core/shadow.test.js +0 -50
- package/dist/core/shadow.test.js.map +0 -1
- package/dist/core/skeptic.test.js +0 -106
- package/dist/core/skeptic.test.js.map +0 -1
- package/dist/core/slicing.test.js +0 -287
- package/dist/core/slicing.test.js.map +0 -1
- package/dist/core/slop/dead-exports.test.js +0 -29
- package/dist/core/slop/dead-exports.test.js.map +0 -1
- package/dist/core/slop/slop.test.js +0 -160
- package/dist/core/slop/slop.test.js.map +0 -1
- package/dist/core/slop/test-debt.test.js +0 -114
- package/dist/core/slop/test-debt.test.js.map +0 -1
- package/dist/core/snapshot.test.js +0 -101
- package/dist/core/snapshot.test.js.map +0 -1
- package/dist/core/snippets.test.js +0 -55
- package/dist/core/snippets.test.js.map +0 -1
- package/dist/core/stats.test.js +0 -86
- package/dist/core/stats.test.js.map +0 -1
- package/dist/core/suppressions.test.js +0 -98
- package/dist/core/suppressions.test.js.map +0 -1
- package/dist/core/test-delta.test.js +0 -41
- package/dist/core/test-delta.test.js.map +0 -1
- package/dist/core/test-plan.test.js +0 -99
- package/dist/core/test-plan.test.js.map +0 -1
- package/dist/core/test-weakening.test.js +0 -114
- package/dist/core/test-weakening.test.js.map +0 -1
- package/dist/core/tree-scan.test.js +0 -58
- package/dist/core/tree-scan.test.js.map +0 -1
- package/dist/core/tribunal.test.js +0 -52
- package/dist/core/tribunal.test.js.map +0 -1
- package/dist/core/vaccine.test.js +0 -139
- package/dist/core/vaccine.test.js.map +0 -1
- package/dist/core/warden.test.js +0 -121
- package/dist/core/warden.test.js.map +0 -1
- package/dist/mcp-http.test.js +0 -146
- package/dist/mcp-http.test.js.map +0 -1
- package/dist/mcp-prompts.test.js +0 -160
- package/dist/mcp-prompts.test.js.map +0 -1
- package/dist/mcp.test.js +0 -2108
- package/dist/mcp.test.js.map +0 -1
- package/dist/setup.test.js +0 -215
- package/dist/setup.test.js.map +0 -1
- package/dist/skills.test.js +0 -293
- package/dist/skills.test.js.map +0 -1
|
@@ -0,0 +1,1318 @@
|
|
|
1
|
+
# oc-pilot command reference
|
|
2
|
+
|
|
3
|
+
Start with the [quickstart](../README.md) for the current command groups and MCP setup. This reference uses many original command names; those invocations remain supported on builds with grouped routing.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/oc-pilot)
|
|
6
|
+
[](https://nodejs.org/)
|
|
7
|
+
[](../package.json)
|
|
8
|
+
[](../LICENSE)
|
|
9
|
+
[](https://github.com/MyNameIsNikki/oc-pilot/actions/workflows/ci.yml)
|
|
10
|
+
|
|
11
|
+
**A zero-dependency, offline-first gate for AI-generated code.** oc-pilot is a CLI, an MCP server and a CI guardrail in one Node.js 22+ package. Its job is not to write features. It mechanically verifies the code your agent wrote before it reaches `main`.
|
|
12
|
+
|
|
13
|
+
[English](reference.md) · [Русский](reference.ru.md) · [Integrations](integrations.md) · [Security](../SECURITY.md) · [Contributing](../CONTRIBUTING.md) · [Changelog](../CHANGELOG.md)
|
|
14
|
+
|
|
15
|
+
## The problem
|
|
16
|
+
|
|
17
|
+
AI agents are great engines with no brakes. They hallucinate dependencies that do not exist, weaken assertions until the suite is green, leak secrets into diffs, and turn a clean architecture into AI slop. Reviewing every agent diff by hand does not scale, and "the tests passed" is not a security argument.
|
|
18
|
+
|
|
19
|
+
## The solution
|
|
20
|
+
|
|
21
|
+
oc-pilot is the brake. It runs deterministic checks on the diff, gives your agent structured evidence through MCP, and blocks the merge when the evidence is bad.
|
|
22
|
+
|
|
23
|
+
- **Offline first.** Secret scanning, SAST, dependency checks and the code graph run locally. No code is sent to a model unless you explicitly call a model-backed command.
|
|
24
|
+
- **Agent native.** One MCP server exposes review, fix, test-fix, scan, preflight, query and sandbox tools to Cursor, Claude Code, OpenCode and any other MCP client.
|
|
25
|
+
- **Session recorder.** `oc-pilot flight` keeps a hash-chained black box of an agent session: commands, output tails and full-worktree checkpoints, with tamper detection and no model calls.
|
|
26
|
+
- **CI ready.** `oc-pilot preflight` is a single gate with a non-zero exit code, GitHub annotations and a compact JSON report.
|
|
27
|
+
|
|
28
|
+
## See it work
|
|
29
|
+
|
|
30
|
+
[Open the asciinema cast](https://github.com/MyNameIsNikki/oc-pilot/blob/main/docs/demo.cast) of a 30-day oc-pilot session, or run the same loop locally:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
oc-pilot battle "fix the retry logic" --apply --shadow --rounds 3
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`battle` runs a coder and a hacker against the same diff. The coder patches; the hacker reviews, runs SAST, checks route authorization and looks for weakened tests. `--shadow` keeps the whole fight inside `.oc-pilot/shadow-tree`, a real detached git worktree. The diff lands in your working tree only after the round is green. Play the cast locally with `asciinema play docs/demo.cast`.
|
|
37
|
+
|
|
38
|
+
<p align="center">
|
|
39
|
+
<img src="https://raw.githubusercontent.com/MyNameIsNikki/oc-pilot/main/docs/badges/oc-pilot.svg" alt="oc-pilot echo badge generated from this repository" width="120">
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
The badge above is generated by `oc-pilot echo` from this repository's own history. Dogfooding, not decoration.
|
|
43
|
+
|
|
44
|
+
## Why oc-pilot?
|
|
45
|
+
|
|
46
|
+
- 🛡️ **Cryptographic receipts, not vibes.** `oc-pilot receipt --sign --key <file>` runs tests and preflight, records the commit, diff and results, then signs the receipt with Ed25519. `oc-pilot ready` verifies the signature when a public key is present. Receipts are opt-in; nothing is signed behind your back.
|
|
47
|
+
- 🧠 **Holographic context, not token dumps.** `oc-pilot pack --hologram` compiles a diff into three levels of detail: LOD 0 keeps changed files complete, LOD 1 hides bodies but keeps signatures and effects, LOD 2 lists export names. The agent gets the context it needs instead of a 100k-line dump.
|
|
48
|
+
- 🔥 **Zero dependencies.** Pure Node.js 22+, TypeScript ESM, no Python, no Docker, no native binaries. `npm install -g oc-pilot` is the whole setup.
|
|
49
|
+
- 🎮 **Gamified DX with teeth.** `bounty` renders ASCII WANTED posters for risky files, `roast` gives a Linus-style review of the diff, `brag` exports a self-contained HTML session report, and `cinema` turns a session into an asciinema cast or an HTML player.
|
|
50
|
+
- 🔒 **Offline-first security.** Secrets, hallucinated dependencies, SQL injection, SSRF, path traversal and XSS checks run without a network call. The model is optional, not the engine.
|
|
51
|
+
- 🕸️ **A real code graph.** `oc-pilot query "find(CallExpression).where(name, 'stripe').select(file, line)"` answers architecture questions without grep. It is a fast textual graph, not a full TypeScript AST.
|
|
52
|
+
|
|
53
|
+
## Quick start
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npx oc-pilot demo
|
|
57
|
+
npm install -g oc-pilot
|
|
58
|
+
oc-pilot setup --all
|
|
59
|
+
oc-pilot doctor
|
|
60
|
+
oc-pilot scan
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`demo` runs a 20-second proof in a throwaway repository: it starts a flight, records a checkpoint that fixes a check, and proves the claim from the fail-to-pass transition. No setup or model required.
|
|
64
|
+
|
|
65
|
+
`setup --all` writes native MCP configs for every supported client and preserves existing settings. `doctor` checks the installation, engine credentials, test discovery and MCP wiring. `scan` reads the current diff; on a clean tree use `oc-pilot scan --staged` or `oc-pilot scan --base origin/main`.
|
|
66
|
+
|
|
67
|
+
Node.js 22+ is required. Model-backed commands (`review`, `fix`, `roast`, `battle`) need OpenCode 2.x or an OpenAI-compatible endpoint; offline commands work without a model.
|
|
68
|
+
|
|
69
|
+
## Recipes
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Roast the AI diff before a human review
|
|
73
|
+
oc-pilot roast --staged --persona linus
|
|
74
|
+
|
|
75
|
+
# Verify a signed compliance manifest
|
|
76
|
+
oc-pilot compliance --verify
|
|
77
|
+
|
|
78
|
+
# Forecast when technical debt becomes unmaintainable
|
|
79
|
+
oc-pilot bankruptcy --explain
|
|
80
|
+
|
|
81
|
+
# Find the commit that introduced a security flaw
|
|
82
|
+
oc-pilot autopsy HEAD --depth 10
|
|
83
|
+
|
|
84
|
+
# Ask the code graph where a call lives
|
|
85
|
+
oc-pilot query "find(CallExpression).where(name, 'stripe').select(file, line)"
|
|
86
|
+
|
|
87
|
+
# Run a generated script with imports and side effects blocked
|
|
88
|
+
oc-pilot sandbox run scripts/demo.mjs
|
|
89
|
+
|
|
90
|
+
# Check the encrypted agent mesh
|
|
91
|
+
oc-pilot hivemind status
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`bankruptcy` needs at least 10 commits and is a heuristic, not a promise. `sandbox run` isolates JavaScript in `node:vm`; it is not an OS sandbox for native code. `hivemind` speaks encrypted TCP, not WebRTC, and trusts peers only after an explicit `hivemind trust`.
|
|
95
|
+
|
|
96
|
+
## In CI
|
|
97
|
+
|
|
98
|
+
```yaml
|
|
99
|
+
name: oc-pilot
|
|
100
|
+
on: [pull_request]
|
|
101
|
+
|
|
102
|
+
jobs:
|
|
103
|
+
gate:
|
|
104
|
+
runs-on: ubuntu-latest
|
|
105
|
+
steps:
|
|
106
|
+
- uses: actions/checkout@v4
|
|
107
|
+
with:
|
|
108
|
+
fetch-depth: 0
|
|
109
|
+
- uses: actions/setup-node@v4
|
|
110
|
+
with:
|
|
111
|
+
node-version: 22
|
|
112
|
+
- run: npx -y oc-pilot preflight --base ${{ github.event.pull_request.base.sha }} --github
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`preflight` checks secrets, deterministic SAST, route authorization, dependency health, weakened tests and the Slop Index delta. It exits non-zero on failure, so the branch protection rule does the rest. SAST and route checks skip test fixtures by default; pass `--include-tests` to scan them.
|
|
116
|
+
|
|
117
|
+
## Under the hood
|
|
118
|
+
|
|
119
|
+
No magic and no hidden cloud calls. A static import graph and a lightweight textual AST drive `query`, `preflight`, `scan`, `deps` and `test-guard`. `test-guard` catches the classic agent move: changing `expect(x).toBe(200)` to `expect(x).toBeDefined()` to make the build green. `fix --shadow` runs the patched tree in a real detached git worktree, so external compilers and test runners see the modified files; the diff lands only after a green run. `sandbox run` uses `node:vm` with blocked imports, blocked side effects and a hard timeout.
|
|
120
|
+
|
|
121
|
+
## How it works
|
|
122
|
+
|
|
123
|
+
1. `oc-pilot` collects the diff and project metadata.
|
|
124
|
+
2. It scans added lines for secrets and replaces detected values with `[REDACTED:<kind>]`.
|
|
125
|
+
3. It loads project rules from `.oc-pilot/rules.md` (optional).
|
|
126
|
+
4. It builds an input with `PROJECT_TYPE`, `RECIPE`, repository context, rules, the secret report, and `GIT_DIFF`.
|
|
127
|
+
5. With the OpenCode engine, a read-only agent can use `read`, `glob`, and `grep` to inspect call sites and contracts. `edit`, `shell`, web access, and external directories are denied.
|
|
128
|
+
6. The model returns a fixed Markdown schema. `oc-pilot` parses severity and emits JSON on request.
|
|
129
|
+
7. `--fail-on` and `--fail-on-secrets` turn findings into CI exit codes.
|
|
130
|
+
|
|
131
|
+
With `--no-repo-context`, the agent gets no tools. `oc-pilot` instead includes full changed files (`FULL_FILE_CONTEXT`) within the context budget.
|
|
132
|
+
|
|
133
|
+
## Engines
|
|
134
|
+
|
|
135
|
+
Choose where the model call goes. `opencode` is the default and gives the best review because the agent can read call sites and contracts. `openai` removes the OpenCode dependency: it calls any OpenAI-compatible `/chat/completions` endpoint and automatically includes the full changed files as context.
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Default: repo-aware OpenCode agent
|
|
139
|
+
oc-pilot review
|
|
140
|
+
|
|
141
|
+
# Any OpenAI-compatible API, no OpenCode required
|
|
142
|
+
export OC_PILOT_API_KEY="..."
|
|
143
|
+
oc-pilot review --engine openai --model deepseek-chat \
|
|
144
|
+
--base-url https://api.deepseek.com/v1
|
|
145
|
+
|
|
146
|
+
# Local model through Ollama (no key needed on loopback)
|
|
147
|
+
oc-pilot review --engine openai --model qwen2.5-coder \
|
|
148
|
+
--base-url http://127.0.0.1:11434/v1
|
|
149
|
+
|
|
150
|
+
# The same, through a preset
|
|
151
|
+
oc-pilot review --engine-preset ollama --model qwen2.5-coder
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
| Engine | Best for | Repository tools | Requires |
|
|
155
|
+
| --- | --- | --- | --- |
|
|
156
|
+
| `opencode` | Cross-file bugs and contract changes | Read, glob, grep (read-only) | OpenCode + provider auth |
|
|
157
|
+
| `openai` | Zero extra CLIs, CI, DeepSeek/OpenRouter/local models | No; full changed files are included | API endpoint and key |
|
|
158
|
+
|
|
159
|
+
The key is read from `OC_PILOT_API_KEY`, or `OPENAI_API_KEY` when the default variable name is used. Set `apiKeyEnv` to use another variable. Logs and errors never print the key. With the `openai` engine, `repoContext` is forced off and `FULL_FILE_CONTEXT` is added automatically.
|
|
160
|
+
|
|
161
|
+
### Engine presets
|
|
162
|
+
|
|
163
|
+
For the common OpenAI-compatible providers, `--engine-preset` fills in the base URL, the key variable and (where it is a sensible default) the model:
|
|
164
|
+
|
|
165
|
+
| Preset | Base URL | Key variable | Default model |
|
|
166
|
+
| --- | --- | --- | --- |
|
|
167
|
+
| `ollama` | `http://localhost:11434/v1` | `OLLAMA_API_KEY` (not needed on loopback) | `llama3.2` |
|
|
168
|
+
| `lmstudio` | `http://localhost:1234/v1` | `LMSTUDIO_API_KEY` (not needed on loopback) | — |
|
|
169
|
+
| `openrouter` | `https://openrouter.ai/api/v1` | `OPENROUTER_API_KEY` | — |
|
|
170
|
+
|
|
171
|
+
A preset switches the engine to `openai` unless you say otherwise, and explicit flags always win: `oc-pilot review --engine-preset ollama --model qwen2.5-coder` keeps the preset endpoint and overrides only the model.
|
|
172
|
+
|
|
173
|
+
### Anthropic engine
|
|
174
|
+
|
|
175
|
+
`--engine anthropic` talks to the Claude Messages API directly, without an SDK:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
ANTHROPIC_API_KEY=sk-ant-... oc-pilot review --engine anthropic --model claude-sonnet-4-5
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The system prompt is sent as a `system` block with `cache_control: {"type": "ephemeral"}`, so repeated reviews reuse the cached prefix. Requests use `anthropic-version: 2023-06-01` and `x-api-key`. Token usage is mapped onto the same cost table as the OpenAI engine, so `--max-cost` and `oc-pilot stats` work unchanged.
|
|
182
|
+
|
|
183
|
+
Slicing, the two-phase router and the response cache are `openai`-only; the Anthropic engine always sends one request per run.
|
|
184
|
+
|
|
185
|
+
### Smart slicing (`openai`)
|
|
186
|
+
|
|
187
|
+
When a diff is too large for a single prompt (300 000 characters), the `openai` engine does not truncate files away. Instead it groups the per-file diff blocks into slices that each fit the budget, runs one API call per slice with the same additional context, and merges the responses back into a single schema-compliant analysis (`meta.slices` shows how many calls were made). Up to three slices run in parallel and their answers are merged in the original file order. A single file whose diff exceeds the budget is sent as its own slice and only then truncated. Slicing applies to `review`, `test-fix`, `custom` and `commit --engine openai`; `fix` keeps a single prompt because it must return one patch.
|
|
188
|
+
|
|
189
|
+
### Retries
|
|
190
|
+
|
|
191
|
+
Transient failures are retried instead of failing the run: HTTP 408, 425, 429, 500, 502, 503 and 504 are attempted up to three times with an exponential delay (500 ms, 1 s, 2 s, capped at 8 s). A `Retry-After` header wins over the computed delay. Authentication errors, other 4xx responses, network errors and timeouts still fail immediately, because retrying them only burns time. Slice calls share the same policy.
|
|
192
|
+
|
|
193
|
+
### Two-phase routing (`openai`)
|
|
194
|
+
|
|
195
|
+
`review` can route through a cheap triage model before the main review call. The triage model sees the same input with a compact system prompt and answers with a single line: `TRIAGE: REVIEW` or `TRIAGE: LGTM`. Trivially safe diffs (docs, formatting, version bumps, renames) return `LGTM` and skip the main call entirely; everything else runs the full review. Any triage failure or unparsable answer falls back to the full review, so routing can only save money, never skip a real problem. Secret gating (`--fail-on-secrets`) is evaluated independently of the router.
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
oc-pilot review --router --router-model gpt-4.1-mini --engine openai --model gpt-4.1
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Enable it per run with `--router`, or permanently with `routerEnabled: true` and `routerModel` in `.oc-pilot.json` (or `OC_PILOT_ROUTER` / `OC_PILOT_ROUTER_MODEL`). `--no-router` disables it for one run. The JSON report includes `meta.router` with the model, decision and duration.
|
|
202
|
+
|
|
203
|
+
### Provider-cache-friendly prompts
|
|
204
|
+
|
|
205
|
+
oc-pilot orders every prompt so the stable parts come first and the volatile `GIT_DIFF` comes last: instruction, project type, recipe, repository flags, additional context and the secret report are identical across slices, fix rounds and repeated reviews of the same change. Providers with prefix caching (OpenAI, DeepSeek, Anthropic, OpenRouter) reuse that stable prefix automatically, so the second and later calls on the same context are cheaper and faster. No configuration is needed.
|
|
206
|
+
|
|
207
|
+
### Response cache (`openai`)
|
|
208
|
+
|
|
209
|
+
The `openai` engine caches full model responses on disk. The cache key is the sha256 of the model, base URL, system prompt and input, so re-running the same command on the same diff (typical when wiring hooks, CI or scripts) costs zero tokens and returns instantly. Entries live in `.git/oc-pilot/cache/` — inside the repository metadata, never in the worktree or in commits.
|
|
210
|
+
|
|
211
|
+
The TTL defaults to 24 hours (`cacheTtlSeconds`, or `OC_PILOT_CACHE_TTL`; `0` disables caching). `--no-cache` bypasses the cache for one run, and `oc-pilot cache --stats | --prune | --clear` inspects and maintains it. `doctor --fix` prunes expired entries. The JSON report shows `meta.cache: "hit" | "miss"`. The cache only applies to the `openai` engine (triage, main and slice calls); OpenCode runs are never cached, and a cache error can never fail a review.
|
|
212
|
+
|
|
213
|
+
### Second opinion (`openai`)
|
|
214
|
+
|
|
215
|
+
`review --second-opinion` re-checks up to 10 critical findings with a second, skeptical model before failing the build. Each verdict is a single line: `VERDICT: CONFIRM` keeps the finding, `VERDICT: REJECT — <reason>` downgrades it to style and annotates the bullet with `[second opinion: rejected — reason]`. If the verifier errors or is unreachable, findings are kept as-is — verification never weakens a review on failure. Configure the verifier with `--second-opinion-model` / `--second-opinion-base-url` / `--second-opinion-api-key-env` or the config keys `secondOpinionEnabled`, `secondOpinionModel`, `secondOpinionBaseUrl`, `secondOpinionApiKeyEnv`; the result is reported in `meta.secondOpinion`.
|
|
216
|
+
|
|
217
|
+
### Usage limits and statistics
|
|
218
|
+
|
|
219
|
+
Every run and API call is recorded to `.git/oc-pilot/stats.jsonl` (findings, engine, exit code, cache hits). `oc-pilot stats` prints runs, API calls, cache hits and findings for today, the week and all time (`--clear` resets). A daily API-call budget can be enforced with `maxDailyApiCalls` or `OC_PILOT_MAX_DAILY_API_CALLS` (`0` disables it); once the limit of uncached calls is reached, the command exits 1 — cache hits never consume the budget. `oc-pilot day --since "1 day ago"` summarizes what the agent did: commits, churn per file, added/deleted lines and oc-pilot findings. A spend cap works the same way: `--max-cost 0.5` (or `maxCostUsd` / `OC_PILOT_MAX_COST`) adds up the estimated cost of today's uncached calls — tokens from the API response times the built-in price table — and refuses the next call once the cap is reached. Pricing is estimated, so treat it as a guard rail rather than an invoice; unknown models count as zero and cache hits are free.
|
|
220
|
+
|
|
221
|
+
### Agent rules awareness
|
|
222
|
+
|
|
223
|
+
If the project has an `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.cursorrules` or `.github/copilot-instructions.md`, oc-pilot includes it in every prompt (first match, up to 10 000 characters, secrets masked). This keeps the reviewer aware of the same conventions the coding agent follows. Disable with `agentRules: false` in the config or `OC_PILOT_AGENT_RULES=0`.
|
|
224
|
+
|
|
225
|
+
## Commands
|
|
226
|
+
|
|
227
|
+
### `review`
|
|
228
|
+
|
|
229
|
+
Reviews a git diff. By default it reviews all uncommitted changes (`git diff HEAD`).
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
oc-pilot review
|
|
233
|
+
oc-pilot review --staged
|
|
234
|
+
oc-pilot review --base main
|
|
235
|
+
oc-pilot review --include-untracked
|
|
236
|
+
oc-pilot review src/wallet.go --context "Balance must never be negative"
|
|
237
|
+
git diff | oc-pilot review --stdin
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
| Option | Purpose |
|
|
241
|
+
| --- | --- |
|
|
242
|
+
| `--staged` / `--unstaged` | Limit the diff to one side |
|
|
243
|
+
| `--base <ref>` | Review `<ref>...HEAD` |
|
|
244
|
+
| `--diff <file\|->` | Read a prepared unified diff |
|
|
245
|
+
| `--stdin` | Read the diff from stdin |
|
|
246
|
+
| `--include-untracked` | Add new files to the diff |
|
|
247
|
+
| `--context <text\|@file>` | Extra context for the model |
|
|
248
|
+
| `--no-secret-scan` | Disable secret scanning and redaction |
|
|
249
|
+
| `--fail-on-secrets` | Exit 3 on critical secrets |
|
|
250
|
+
| `--router` | Route through a cheap triage model first (`openai`) |
|
|
251
|
+
| `--no-router` | Disable routing enabled in the config |
|
|
252
|
+
| `--router-model <m>` | Triage model (default: `routerModel` from the config) |
|
|
253
|
+
| `--baseline` | Hide findings already recorded in `.oc-pilot/baseline.json` |
|
|
254
|
+
| `--update-baseline` | Record current findings as the baseline and exit |
|
|
255
|
+
| `--pr` | Post inline review comments to the PR (Actions REST or `gh`) |
|
|
256
|
+
| `--no-pr-inline` | Post a single summary comment instead of inline comments |
|
|
257
|
+
| `--pr-status` | Post a blocking commit status (`failure` on critical findings) |
|
|
258
|
+
| `--mr` | Post the review to a GitLab merge request (`CI_MERGE_REQUEST_IID`) |
|
|
259
|
+
| `--no-mr-inline` | Post a single summary note instead of inline discussions |
|
|
260
|
+
| `--mr-status` | Set the `oc-pilot` commit status in GitLab (`GITLAB_TOKEN`) |
|
|
261
|
+
| `--second-opinion` | Verify critical findings with a second model (`openai`) |
|
|
262
|
+
| `--second-opinion-model <m>` | Verifier model (default: `secondOpinionModel` or the main model) |
|
|
263
|
+
| `--require-tests` | Exit 3 when logic changed without tests |
|
|
264
|
+
| `--no-test-weakening` | Exit 3 when tests were weakened (skips, removed assertions) |
|
|
265
|
+
| `--interactive` | Ask per finding whether to hide it in the baseline (TTY) |
|
|
266
|
+
|
|
267
|
+
With `--baseline`, findings already recorded in `.oc-pilot/baseline.json` are hidden from the output and no longer affect the exit code, JSON, SARIF or PR comment — only new findings block. A finding fingerprint is `severity | file | normalized text`, without the line number, so known findings survive code shifts. `--update-baseline` rewrites the file from the current review and exits 0; `--interactive` hides findings one by one and appends them to the baseline. `--pr` posts the review to the current PR: inside GitHub Actions it uses the review API with `GITHUB_TOKEN` and attaches up to 25 findings as inline comments on their diff lines (grant `permissions: pull-requests: write`); findings that do not map to a changed line, and every run outside Actions, fall back to one summary comment (locally through `gh pr comment`, which must be installed and authenticated). `--no-pr-inline` forces that summary comment. `--pr-status` posts a commit status under the `oc-pilot` context - `failure` while critical findings remain, `success` otherwise - so a branch protection rule can require it (needs `statuses: write`). It works from text and SARIF runs alike.
|
|
268
|
+
|
|
269
|
+
Inside GitLab CI, `--mr` posts the review to the merge request: up to 25 findings become inline discussions anchored to their diff lines, and the summary always lands as a note. `CI_MERGE_REQUEST_IID`, `CI_PROJECT_ID` and `CI_API_V4_URL` identify the merge request, and `GITLAB_TOKEN` needs the `api` scope (`CI_JOB_TOKEN` cannot write notes). The discussion position needs `base_sha`/`start_sha`/`head_sha`: they are read from `CI_MERGE_REQUEST_DIFF_BASE_SHA`, `CI_MERGE_REQUEST_TARGET_BRANCH_SHA` and `CI_COMMIT_SHA`, and when those are absent the tool asks the merge request for its `diff_refs` instead. `--no-mr-inline` keeps the summary note only. Add `--mr-status` to set the `oc-pilot` commit status as well. Every part degrades to a warning when the pipeline context, the token or a single position is missing, so a review never fails because of a missing integration.
|
|
270
|
+
|
|
271
|
+
A minimal job looks like this:
|
|
272
|
+
|
|
273
|
+
```yaml
|
|
274
|
+
oc-pilot:
|
|
275
|
+
image: node:22
|
|
276
|
+
rules:
|
|
277
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
278
|
+
script:
|
|
279
|
+
- npm i -g oc-pilot
|
|
280
|
+
- oc-pilot review --base "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" --fail-on critical --mr --mr-status
|
|
281
|
+
variables:
|
|
282
|
+
OC_PILOT_API_KEY: $OC_PILOT_API_KEY
|
|
283
|
+
GITLAB_TOKEN: $GITLAB_TOKEN
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Before the model runs, `review` also inspects the diff locally: newly added dependencies are checked for typosquats, unpinned versions and VCS/URL specs across npm, PyPI, Go, Cargo, RubyGems, Packagist, Maven/Gradle and NuGet manifests (`DEPENDENCY_CHANGES` hint, `meta.dependencies`); a large logic change (20+ added code lines) with no test files produces a `TEST_COVERAGE_HINT` (`--require-tests` turns it into exit 3, `meta.testDelta`); weakened tests produce a `TEST_WEAKENING` hint (skipped or focused tests, removed assertions without replacements, commented-out assertions, raised timeouts; `--no-test-weakening` turns it into exit 3, `meta.testWeakening`); and added lines matching prompt-injection heuristics (instruction overrides, role hijacking, prompt exfiltration, base64 blobs, invisible Unicode) produce a `PROMPT_INJECTION_RISKS` warning (`meta.injection`).
|
|
287
|
+
|
|
288
|
+
See [Second opinion](#second-opinion-openai) for the verification flow.
|
|
289
|
+
|
|
290
|
+
### Suppressing findings in code
|
|
291
|
+
|
|
292
|
+
An accepted trade-off should not come back as a finding on every review. Mark it at the source:
|
|
293
|
+
|
|
294
|
+
```go
|
|
295
|
+
func pay() {} // oc-pilot:ignore: nil is impossible for a legacy wallet
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
The marker suppresses a finding whose target is that line or the line right below it, so it also works as a comment on its own line above the code. `// oc-pilot:ignore-file: code generated by protoc` in the first ten lines silences the whole file. A reason is mandatory: a bare `oc-pilot:ignore` is ignored, the finding stays, and the run warns about it. Suppressed findings disappear from the text, JSON, SARIF and PR or MR comments and do not affect the exit code, while `meta.suppressed` lists each one with its file, line and reason. `oc-pilot:ignore-secret` belongs to the secret scanner and never hides a review finding.
|
|
299
|
+
|
|
300
|
+
### `test-fix`
|
|
301
|
+
|
|
302
|
+
Runs the detected test command, or reads a log, then explains the root cause and proposes a minimal fix.
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
oc-pilot test-fix
|
|
306
|
+
oc-pilot test-fix --command "go test ./..."
|
|
307
|
+
oc-pilot test-fix --log failures.log
|
|
308
|
+
npm test 2> failures.log; oc-pilot test-fix --log failures.log
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
A passing test run is skipped unless `--force` is used.
|
|
312
|
+
|
|
313
|
+
### `test-gen`
|
|
314
|
+
|
|
315
|
+
Turns a diff into tests that actually run. The model writes tests for the behavior changed in the diff, the patch is applied, the test command runs, and only the green result stays: a failing attempt is rolled back and the failure log goes back to the model as feedback.
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
oc-pilot test-gen --staged --apply
|
|
319
|
+
oc-pilot test-gen --staged --coverage --apply
|
|
320
|
+
oc-pilot test-gen --from-slop --apply
|
|
321
|
+
oc-pilot test-gen src/billing.ts --apply --rounds 1
|
|
322
|
+
oc-pilot test-gen --base main --json
|
|
323
|
+
oc-pilot test-gen --diff changes.diff
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Without `--apply` the command only prints the patch. The patch may touch test files only (`*.test.ts`, `*.spec.ts`, `*_test.go`, `test_*.py`, or paths under `test/`); a production file in the patch rejects the whole round. Existing test files are protected unless `--force` is passed, so generated tests never overwrite hand-written ones. `--no-run` applies without executing the suite, `--keep-failing` keeps a red test file for debugging, and `--rounds <n>` (default 2) controls how many times a failure is sent back to the model.
|
|
327
|
+
|
|
328
|
+
`--coverage` narrows the request to changed lines that no test executed yet. The command reads an lcov, Istanbul JSON, Cobertura XML or Go cover profile report (`--coverage-file <path>` overrides the auto-detected `coverage/lcov.info`, `coverage/coverage-final.json`, `cobertura.xml`, `coverage.out` and similar files), intersects it with the lines added by the diff, and sends only those gaps to the model. When every changed line is already covered, it exits 0 without calling the model.
|
|
329
|
+
|
|
330
|
+
`--from-slop` ignores the diff and lets the slop scan choose the work: it looks for source files that have no test at all and ranks them by churn, duplicated blocks and unresolved TODOs. `--slop-files <n>` (default 3) caps how many files are sent. The command refuses to mix `--from-slop` with `--diff`, `--staged`, `--base`, `--coverage` or explicit paths, because those already define the input. When every source file has a test, it exits 0 without calling the model.
|
|
331
|
+
|
|
332
|
+
The JSON payload is `{applied, patch, files, status, tests, rounds, analysis, meta, coverage, targets}` with `status` equal to `pass`, `fail` or `not-run` and `coverage` holding `{report, format, uncoveredLines, gaps, missing}` (or `null` without `--coverage`); `targets` lists the slop-selected files with their scores and reasons (or `null` without `--from-slop`). The exit code is 1 while the tests stay red.
|
|
333
|
+
|
|
334
|
+
### `fix`
|
|
335
|
+
|
|
336
|
+
Asks the model for a unified diff, checks that it applies, and optionally applies it in the project. This is the only command that can modify your working tree, and only with `--apply`.
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
# Show the proposed patch and do not touch files
|
|
340
|
+
oc-pilot fix --diff changes.diff
|
|
341
|
+
|
|
342
|
+
# Apply, run tests, and keep the patch only when tests pass
|
|
343
|
+
oc-pilot fix --apply --command "npm test"
|
|
344
|
+
|
|
345
|
+
# Apply but keep the patch even when tests fail
|
|
346
|
+
oc-pilot fix --apply --command "go test ./..." --keep-on-test-failure
|
|
347
|
+
|
|
348
|
+
# Fix SAST findings in the changed files
|
|
349
|
+
oc-pilot fix --from-sast --staged --apply
|
|
350
|
+
oc-pilot fix --from-authz --staged --apply
|
|
351
|
+
|
|
352
|
+
# Emit GitHub Actions annotations for the findings
|
|
353
|
+
oc-pilot review --github
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
| Option | Purpose |
|
|
357
|
+
| --- | --- |
|
|
358
|
+
| `--apply` | Apply the patch to the working tree |
|
|
359
|
+
| `--command <cmd>` | Test command after applying; defaults to `testCommand` or auto-detection |
|
|
360
|
+
| `--no-tests` | Apply without running tests |
|
|
361
|
+
| `--keep-on-test-failure` | Do not revert a patch when tests fail |
|
|
362
|
+
| `--no-snapshot` | Skip the safety snapshot before applying |
|
|
363
|
+
| `--from-sast` | Fix high-severity SAST findings in the changed files, then rescan |
|
|
364
|
+
| `--from-authz` | Fix high-severity authorization findings in the changed routes, then rescan |
|
|
365
|
+
|
|
366
|
+
`fix` never commits or pushes. The patch is reverted when tests fail unless `--keep-on-test-failure` is used. Unrelated working-tree changes are not reverted.
|
|
367
|
+
|
|
368
|
+
Before applying, `fix` saves a snapshot under `.git/oc-pilot/snapshots/` (tracked changes as a binary patch plus copies of untracked files). Snapshots stay local: they are never committed or pushed. Restore the snapshot with `oc-pilot restore`; skip it with `--no-snapshot`.
|
|
369
|
+
|
|
370
|
+
With `--from-sast`, `fix` scans the changed files with the built-in SAST rules, asks the model for a patch that removes those findings, applies it, and rescans. The JSON payload gains `sast: {before, after, remaining}`; the exit code is 1 when high-severity findings remain. With `--from-authz`, the same loop targets route authorization findings (an unauthenticated route, an IDOR lookup, an admin path without a role) and the payload gains `authz: {before, after, remaining}`; `--from-sast` and `--from-authz` cannot be combined.
|
|
371
|
+
|
|
372
|
+
### `docgen`
|
|
373
|
+
|
|
374
|
+
Generates GoDoc, RustDoc, JSDoc, Python docstrings, and similar comments without changing the code.
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
oc-pilot docgen src/core/prompt.ts
|
|
378
|
+
oc-pilot docgen "src/**/*.ts" --symbol buildPrompt
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### `custom`
|
|
382
|
+
|
|
383
|
+
Runs a free-form analysis with an optional diff and context.
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
oc-pilot custom "Find data races" --git-diff
|
|
387
|
+
oc-pilot custom "Explain this module" --context @ARCHITECTURE.md
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### `scan`
|
|
391
|
+
|
|
392
|
+
Offline secret scan. No model call.
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
oc-pilot scan
|
|
396
|
+
oc-pilot scan --staged --json
|
|
397
|
+
oc-pilot scan --all
|
|
398
|
+
git diff main...HEAD | oc-pilot scan --stdin
|
|
399
|
+
|
|
400
|
+
# SARIF 2.1.0 for GitHub Code Scanning
|
|
401
|
+
oc-pilot scan --staged --format sarif -o oc-pilot.sarif
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Exit 1 means critical secrets were found. `--strict` also fails on warnings. `--format sarif` writes a SARIF 2.1.0 report (rules `oc-pilot/secret`, `oc-pilot/critical`, `oc-pilot/warning`) that GitHub Code Scanning can upload; secret previews stay redacted.
|
|
405
|
+
|
|
406
|
+
`--all` scans the whole tree instead of a diff. It respects `.gitignore` and `.oc-pilot/ignore`, skips binaries, `node_modules`, `dist` and files over 512 KB, and reports how many files were checked (`meta.filesScanned`).
|
|
407
|
+
|
|
408
|
+
### `preflight`
|
|
409
|
+
|
|
410
|
+
One offline verdict before a commit. Six checks run without a model and without network: secrets in the diff, a deterministic SAST pass over the changed source files (command and SQL injection, path traversal, SSRF, code injection, XSS and more), route authorization over the changed source files (an unauthenticated route, an IDOR lookup, an admin path without a role), dependency health scoped to the files the diff touches, weakened tests (`it.skip`, removed assertions, raised timeouts), and the Slop Index delta against a base ref.
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
oc-pilot preflight
|
|
414
|
+
oc-pilot preflight --staged
|
|
415
|
+
oc-pilot preflight --base main --max-delta 0
|
|
416
|
+
oc-pilot preflight --no-slop --fail-on-issue medium
|
|
417
|
+
oc-pilot preflight --staged --no-sast
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
Dependency issues are scoped: preflight reports only problems in files the diff changes or packages named in added lines, so a legacy repository does not fail on the first run. Findings recorded in `.oc-pilot/baseline.json` are hidden by default, so the gate reports only new problems; `receipt` uses the same baseline. `--fail-on-issue` (default `high`) sets the gate for SAST, route authorization and dependency severity, and `--max-delta` (default 10 points) sets the Slop Index gate; each check can be disabled with `--no-secret-scan`, `--no-sast`, `--no-authz`, `--no-deps`, `--no-tests` or `--no-slop`. The exit code is 1 if any check fails and 0 otherwise, so one CI step replaces six.
|
|
421
|
+
|
|
422
|
+
The JSON report is `{status, checks, diff}`, where each check carries `{id, label, status, summary, details}` with `status` equal to `pass`, `fail` or `skip`.
|
|
423
|
+
|
|
424
|
+
### `receipt`
|
|
425
|
+
|
|
426
|
+
Turns "it works on my machine" into a checked claim. A receipt runs the tests and the preflight (including SAST and authz), then records the result together with the commit SHA, branch, dirty state, diff stats, and the exact commands. It is written to `.git/oc-pilot/receipt.json`, so it never ends up in the working tree. Pass `--no-sast` or `--no-authz` to skip a check for a change where it does not apply.
|
|
427
|
+
|
|
428
|
+
```bash
|
|
429
|
+
oc-pilot receipt --staged
|
|
430
|
+
oc-pilot receipt --staged --no-sast
|
|
431
|
+
oc-pilot receipt --json
|
|
432
|
+
oc-pilot receipt --verify
|
|
433
|
+
oc-pilot receipt --verify --receipt path/to/receipt.json
|
|
434
|
+
oc-pilot receipt --keygen receipt.key
|
|
435
|
+
oc-pilot receipt --sign --key receipt.key
|
|
436
|
+
oc-pilot receipt --verify --public-key receipt.key.pub
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
The file is sealed with a SHA-256 hash of its body. `--verify` recomputes the hash and compares the commit with the current `HEAD`, so an edited file or a receipt from an older commit is reported as invalid: `{path, ok, hashOk, stale, commit, head, signature, reason?}`. The exit code is 1 when the tests fail, the preflight fails or the receipt does not verify.
|
|
440
|
+
|
|
441
|
+
A hash proves integrity, not authorship. `--sign` signs the hash with an Ed25519 key: `--keygen <file>` writes a private key (mode 0600) and `<file>.pub`; `--key` or `OC_PILOT_RECEIPT_KEY` points at the private key; the receipt gains a `signature` field. Verification checks the signature when a public key is available: `--public-key <file>`, `OC_PILOT_RECEIPT_PUBLIC_KEY`, or the committed `.oc-pilot/receipt.pub`. The `signature` status is `valid`, `invalid`, `missing` or `unchecked`; an unsigned receipt fails verification when a key is supplied. `ready` verifies the signature too when `.oc-pilot/receipt.pub` exists. Keep the private key outside the repository.
|
|
442
|
+
|
|
443
|
+
A receipt carries `{version, tool, toolVersion, createdAt, commit, branch, dirty, diff, files, tests, preflight, hash, signature?}`. `tests` is `{command, exitCode, timedOut, durationMs, passed, outputTail}` or `null` with `--no-run`; `preflight` is the same report `preflight` prints. Outside a repository the receipt can only be written to an explicit path with `--out`.
|
|
444
|
+
|
|
445
|
+
### `ready`
|
|
446
|
+
|
|
447
|
+
Scores how ready a repository is for an AI agent. One offline number from 0 to 100 across nine checks: tests (15), lockfile (10), git hooks (15), Slop Index (15), a fresh receipt (10), agent instructions (10), CI (5), config (5) and security (15). Each check is `pass`, `warn` or `fail` and earns 100%, 50% or 0% of its weight. The security check runs the deterministic SAST and route-authorization rules over the repository and respects `.oc-pilot/baseline.json`. No model call, no network, but it does require a git repository. The hooks check also verifies that installed managed hooks (pre-commit and pre-push) can resolve an oc-pilot binary and use the same version; a hook that would silently skip or run a stale binary is reported as a warning.
|
|
448
|
+
|
|
449
|
+
```bash
|
|
450
|
+
oc-pilot ready
|
|
451
|
+
oc-pilot ready --json
|
|
452
|
+
oc-pilot ready --badge
|
|
453
|
+
oc-pilot ready --fail-under 85
|
|
454
|
+
oc-pilot ready --fix
|
|
455
|
+
oc-pilot ready --fix --dry-run
|
|
456
|
+
oc-pilot ready --fix --receipt
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
The score maps to a grade: 85 and above is `agent-ready`, 65 and above `almost`, 40 and above `risky`, anything lower `not-ready`. `--badge` prints a shields.io markdown badge for the README, and `--fail-under <n>` exits with code 1 below the threshold, so the score can gate a pull request.
|
|
460
|
+
|
|
461
|
+
`--fix` applies only safe, offline repairs: it installs the `pre-commit` hook when no hook exists, writes `.oc-pilot.json` with the detected test command, and creates `AGENTS.md` with the project commands. A foreign hook, an existing config or existing agent instructions are never overwritten; the report lists those as skipped together with checks that need a human, such as the receipt, the lockfile and the Slop Index. `--dry-run` prints the plan without touching the tree, and the score is recomputed after the fixes.
|
|
462
|
+
|
|
463
|
+
`--receipt` turns `--fix` into a full loop: after the repairs it runs the test command, runs the preflight and saves a receipt for `HEAD`, so the receipt check can pass in the same run. It requires `--fix`; without a test command the receipt is listed as skipped. A failed test run or a failed preflight still produces a receipt — the report says which part failed.
|
|
464
|
+
|
|
465
|
+
The JSON payload is `{score, grade, checks, commit}`; each check is `{id, label, status, points, max, detail}`, where `detail` names the file that earned or lost the points and the command that fixes it. With `--fix` the payload also carries `fix: {applied, dryRun, fixes, skipped, receipt}`, where `receipt` is `{path, testsPassed, preflight}` or omitted.
|
|
466
|
+
|
|
467
|
+
### `mutate`
|
|
468
|
+
|
|
469
|
+
Mutation testing answers a harder question than coverage: do the tests actually catch bugs? The command flips comparison and boolean operators in the changed source files, runs the test suite against each mutant and counts how many mutants the tests killed. A surviving mutant is a line the suite executes but does not really check.
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
oc-pilot mutate --staged
|
|
473
|
+
oc-pilot mutate --base main --max-mutants 10
|
|
474
|
+
oc-pilot mutate src/billing.ts --min-score 80
|
|
475
|
+
oc-pilot mutate --diff changes.diff --json
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
Operators are `===`/`!==`, `==`/`!=`, `>=`/`<`, `<=`/`>`, `&&`/`||` and `true`/`false`; strings and comments are masked, so only real code is mutated. `--max-mutants <n>` caps the run (default 20, max 500) because every mutant executes the whole suite. `--min-score <n>` exits with code 1 when the mutation score is below the threshold, which makes it a CI gate. A timeout counts as a kill: the mutant changed observable behavior.
|
|
479
|
+
|
|
480
|
+
The JSON payload is `{command, files, sites, mutants, killed, survived, timedOut, score, truncated, durationMs}`; each mutant is `{file, line, column, operator, original, replacement, status, durationMs}` with `status` equal to `killed`, `survived` or `timeout`.
|
|
481
|
+
|
|
482
|
+
### `flaky`
|
|
483
|
+
|
|
484
|
+
Runs the test command several times and compares per-test results. A test that passes in some runs and fails in others is flaky; one that fails every time is simply broken. The command never calls a model: it only runs the suite and parses the output.
|
|
485
|
+
|
|
486
|
+
```bash
|
|
487
|
+
oc-pilot flaky
|
|
488
|
+
oc-pilot flaky --runs 5
|
|
489
|
+
oc-pilot flaky --shuffle --command "node --test {files}"
|
|
490
|
+
oc-pilot flaky --command "go test ./..." --json
|
|
491
|
+
oc-pilot flaky --fail-on-flaky
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
`--runs <n>` defaults to 3 and caps at 10. `--command` overrides `testCommand` from `.oc-pilot.json` and the detected test command. `--fail-on-flaky` exits with code 1 when at least one test flipped, which makes it usable as a CI gate.
|
|
495
|
+
|
|
496
|
+
`--shuffle` turns the run into an order test. It requires `{files}` in `--command`, collects the test files from the repository, shuffles them with a seeded PRNG and substitutes the list into the command. Every run gets a fresh seed derived from the base one, so a test that fails only after a particular neighbour shows up as flaky. `--seed <value>` fixes the base seed when you need to reproduce a failure.
|
|
497
|
+
|
|
498
|
+
Per-test results are parsed from the Node test runner spec reporter, TAP, Go (`--- PASS`/`--- FAIL`), pytest (`PASSED`/`FAILED`) and Jest/Vitest (`✓`/`✕`). If the output carries no recognizable markers, `parsed` is false and the report only tells you that the exit codes were compared.
|
|
499
|
+
|
|
500
|
+
The JSON payload is `{command, runs, completed, parsed, tests, flaky, failing, shuffle}`; each test is `{name, passes, failures, status}` with `status` equal to `flaky`, `failing` or `passing`. With `--shuffle`, `shuffle` is `{seed, files}`.
|
|
501
|
+
|
|
502
|
+
### `authz`
|
|
503
|
+
|
|
504
|
+
Authorization review of HTTP routes: a route that never checks the session, an object fetched by an id from the request without an ownership check (IDOR), and an admin path without a role guard. It reads the changed source files and never calls a model.
|
|
505
|
+
|
|
506
|
+
```bash
|
|
507
|
+
oc-pilot authz --staged
|
|
508
|
+
oc-pilot authz --public /health,/login
|
|
509
|
+
oc-pilot authz --staged --fail-on-issue medium
|
|
510
|
+
oc-pilot authz --staged --format sarif -o authz.sarif
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
Express, Fastify and Koa route calls (`app.get`, `router.post`, ...) are recognized, plus Next.js `app/**/route.ts` and `pages/api/**`. A handler passed by reference (`router.get("/x", controller.list)`) is skipped because the guard may live in the controller. Routes under `/health`, `/login`, `/signup`, `/public`, `/webhooks`, `/oauth` and similar are treated as public; `--public <prefixes>` extends that list.
|
|
514
|
+
|
|
515
|
+
Suppress a deliberate exception on the route line or the line above:
|
|
516
|
+
|
|
517
|
+
```js
|
|
518
|
+
// oc-pilot:authz-ignore idor: the gateway scopes the query by tenant
|
|
519
|
+
router.get("/users/:id", handler);
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
A suppression without a reason is ignored. `--ignore <rules>` skips whole rules and `--no-suppressions` disables inline suppressions.
|
|
523
|
+
|
|
524
|
+
`--fail-on-issue <high|medium>` sets the exit threshold (default `high`). `--format sarif` emits SARIF 2.1.0 with the rule id, method and route.
|
|
525
|
+
|
|
526
|
+
`--baseline <file>` hides findings already recorded in `.oc-pilot/baseline.json`, so only new findings fail the run; `--update-baseline` writes the current findings to that file and exits with code 0, which lets a legacy repository adopt the gate without fixing everything at once. The baseline stores SHA-256 fingerprints of the rule, file and snippet (or method and route for `authz`), so entries survive line moves. `preflight` and `receipt` read the same default baseline.
|
|
527
|
+
|
|
528
|
+
The JSON payload is `{files, routes, findings, suppressed, summary}`; each route is `{file, line, method, route, public}` and each finding adds `{rule, severity, method, route}` to the location. With `--baseline` the payload adds `baselineSuppressed`; with `--update-baseline` it adds `baseline: {path, updated, entries}`.
|
|
529
|
+
|
|
530
|
+
### `sast`
|
|
531
|
+
|
|
532
|
+
Deterministic static analysis of the changed files: command and SQL injection, path traversal, SSRF, code execution, XSS, open redirects, disabled TLS verification, wildcard CORS, prototype pollution, weak hashes and JWT `none`. No model call, no network: the same diff always produces the same findings.
|
|
533
|
+
|
|
534
|
+
```bash
|
|
535
|
+
oc-pilot sast --staged
|
|
536
|
+
oc-pilot sast --base main --fail-on-issue medium
|
|
537
|
+
oc-pilot sast src/server.ts --json
|
|
538
|
+
oc-pilot sast --staged --format sarif -o sast.sarif
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
The analysis is taint-aware but heuristic: a sink is reported when request data (`req.query`, `req.body`, `req.params`, headers, cookies, `userInput`, `untrusted*`) or a template interpolation reaches it within the same expression. Constants and parameterized queries are not reported. `path.resolve`, `path.normalize`, `path.basename` and `path.join` suppress path traversal findings.
|
|
542
|
+
|
|
543
|
+
Suppress a deliberate exception on the finding line or the line above:
|
|
544
|
+
|
|
545
|
+
```js
|
|
546
|
+
exec(req.query.cmd); // oc-pilot:sast-ignore command-injection: admin-only endpoint
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
A suppression without a reason is ignored. `--ignore <rules>` skips whole rules, `--no-suppressions` disables inline suppressions for an audit run.
|
|
550
|
+
|
|
551
|
+
`--fail-on-issue <high|medium|low>` sets the exit code threshold (default `high`). `--format sarif` emits SARIF 2.1.0 for GitHub code scanning and other SARIF consumers.
|
|
552
|
+
|
|
553
|
+
`--baseline <file>` hides findings already recorded in `.oc-pilot/baseline.json`, so only new findings fail the run; `--update-baseline` writes the current findings to that file and exits with code 0, which lets a legacy repository adopt the gate without fixing everything at once. The baseline stores SHA-256 fingerprints of the rule, file and snippet, so entries survive line moves. `preflight` and `receipt` read the same default baseline.
|
|
554
|
+
|
|
555
|
+
The JSON payload is `{files, findings, suppressed, summary}`; each finding is `{rule, severity, file, line, column, message, snippet}` and `summary` counts `high`, `medium`, `low`. With `--baseline` the payload adds `baselineSuppressed`; with `--update-baseline` it adds `baseline: {path, updated, entries}`.
|
|
556
|
+
|
|
557
|
+
### `deps`
|
|
558
|
+
|
|
559
|
+
Offline health audit of npm, pnpm and yarn dependencies. No model call, no network.
|
|
560
|
+
|
|
561
|
+
```bash
|
|
562
|
+
oc-pilot deps
|
|
563
|
+
oc-pilot deps --json
|
|
564
|
+
oc-pilot deps --fail-on-issue high
|
|
565
|
+
oc-pilot deps --ignore lint-staged
|
|
566
|
+
oc-pilot deps --fix --dry-run
|
|
567
|
+
oc-pilot deps --fix
|
|
568
|
+
oc-pilot deps --why qs
|
|
569
|
+
oc-pilot deps --audit --fail-on-vuln high
|
|
570
|
+
oc-pilot deps --audit --offline
|
|
571
|
+
oc-pilot deps --sbom sbom.json
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
It compares `package.json` with what the code actually imports and with the lockfile the project uses: `package-lock.json`, `pnpm-lock.yaml` or `yarn.lock`.
|
|
575
|
+
|
|
576
|
+
- **phantom** (high) — a package is imported but not declared, so a clean install or CI fails;
|
|
577
|
+
- **unused** (medium) — declared but never imported or mentioned in scripts;
|
|
578
|
+
- **misplaced** (low) — used only by tests but listed in `dependencies`;
|
|
579
|
+
- **duplicate** (low) — two libraries from the same group solve one job (`moment` and `dayjs`);
|
|
580
|
+
- **unpinned** (medium) — `*`, `latest` or an empty spec;
|
|
581
|
+
- **vcs** (high for git/URL, low for `file:`) — a dependency from git, a URL or a local path;
|
|
582
|
+
- **lockfile** (high) — declared but missing from the project lockfile, so a clean install fails (`npm ci`, `pnpm install --frozen-lockfile` or `yarn install --immutable`).
|
|
583
|
+
|
|
584
|
+
`--fail-on-issue <high|medium|low>` turns the audit into a CI gate (exit 1). `--ignore <names>` accepts a comma-separated list for false positives, for example when a package is loaded dynamically. Workspace packages (`packages/*`) and `@types/*` are handled; peer dependencies are not reported as unused.
|
|
585
|
+
|
|
586
|
+
`--fix` repairs what can be decided offline: a package used only by tests moves to `devDependencies`, an imported-but-undeclared package is added with the version already resolved in the lockfile (to `devDependencies` when every importer is a test), and a floating `*`/`latest` spec is pinned to the lockfile version. Nothing is invented: a phantom import without a lockfile entry, an unused package, a duplicate or a vcs dependency is listed as skipped with the reason. `--dry-run` prints the plan without touching `package.json`. After writing, the audit re-runs, so the exit code reflects the fixed state.
|
|
587
|
+
|
|
588
|
+
`--why <name>` answers the question that comes before any cleanup: where does this package actually come from. It reads `package.json` and the lockfile locally and prints the declared field and spec, the files that import it, the packages that depend on it, every installed version and copy count, and the dependency chains from the root. A package that is neither declared, installed nor imported exits with code 1. `--why` cannot be combined with `--fix`.
|
|
589
|
+
|
|
590
|
+
`--audit` adds known vulnerabilities and licenses. It asks OSV (`api.osv.dev`) for every locked package, reports CVE/GHSA ids, severity and the first fixed version, and caches answers in `.oc-pilot/osv-cache.json` for 24 hours. `--offline` uses the cache without touching the network and fails when the cache is empty. `--osv-url` points the query at a mirror. `--fail-on-vuln <critical|high|medium|low>` turns the result into a security gate: the command exits with code 1 when any vulnerability reaches the threshold. Licenses are read from installed `node_modules` manifests; strong copyleft, proprietary and unknown licenses are listed, and packages without an installed manifest are counted as `missing` instead of guessed.
|
|
591
|
+
|
|
592
|
+
`--sbom <file>` writes a CycloneDX 1.5 software bill of materials for every locked package, with npm purls, relative to the project root. It needs no network.
|
|
593
|
+
|
|
594
|
+
The JSON payload is `{packageName, declared, imported, scannedFiles, truncated, lockfile, issues}`; with `--fix` it gains `fix: {applied, dryRun, fixes, skipped}`, with `--why` the command prints a single `DependencyWhy` object: `{name, versions, copies, declared, importedBy, dependents, chains}`, with `--audit` it gains `audit: {checked, unchecked, vulnerabilities, online, stale, cachePath, licenses}`, and with `--sbom` — `sbom: <path>`.
|
|
595
|
+
|
|
596
|
+
### `commit`
|
|
597
|
+
|
|
598
|
+
Generates a Conventional Commits message from staged changes and optionally commits it. The model also sees the last 10 commit subjects, so the message matches the project's existing style.
|
|
599
|
+
|
|
600
|
+
```bash
|
|
601
|
+
oc-pilot commit # print the message
|
|
602
|
+
oc-pilot commit --apply # commit staged with the generated message
|
|
603
|
+
oc-pilot commit --json # machine-readable output
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
`--apply` works only with staged changes and is blocked (exit 3) when the diff contains critical secrets; pass `--allow-secrets` to override. With `--engine openai` an oversized diff is split into per-file slices (see Engines) and the message covers all of them.
|
|
607
|
+
|
|
608
|
+
### `install-hook`
|
|
609
|
+
|
|
610
|
+
Installs native git hooks without husky or any dependency. The managed `pre-commit` hook runs `oc-pilot preflight --staged`: secrets, SAST, route authorization, dependency health scoped to the change, test weakening and the Slop Index delta. `--pre-push` also installs a `pre-push` hook that runs `oc-pilot review --fail-on critical --fail-on-secrets`. Pass `--scan` to keep a lighter pre-commit that only runs `oc-pilot scan --staged`.
|
|
611
|
+
|
|
612
|
+
```bash
|
|
613
|
+
oc-pilot install-hook
|
|
614
|
+
oc-pilot install-hook --scan
|
|
615
|
+
oc-pilot install-hook --pre-push
|
|
616
|
+
oc-pilot install-hook --uninstall
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
Hooks are opt-in and reversible. A hook that does not belong to oc-pilot is never overwritten unless `--force` is passed, and then the old file is kept as `<hook>.oc-pilot.bak`. Every managed hook is stamped with a marker; hooks written by older versions are reported as outdated by `oc-pilot doctor` and upgraded in place with `oc-pilot doctor --fix`. Set `OC_PILOT_SKIP=1` to bypass the hooks for a single command. The hook prefers `OC_PILOT_BIN`, then `./node_modules/.bin/oc-pilot`, then `oc-pilot` from `PATH`; if none is found, it prints a warning and skips the check. `oc-pilot ready` and `oc-pilot doctor` also compare the resolved binary version with the running CLI and warn when they differ. `core.hooksPath` and worktrees are respected.
|
|
620
|
+
|
|
621
|
+
### `restore`
|
|
622
|
+
|
|
623
|
+
Restores the working tree from the latest snapshot taken before `fix --apply`.
|
|
624
|
+
|
|
625
|
+
```bash
|
|
626
|
+
oc-pilot restore # latest snapshot
|
|
627
|
+
oc-pilot restore --list # list saved snapshots
|
|
628
|
+
oc-pilot restore <id> # a specific snapshot
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
Snapshots live under `.git/oc-pilot/snapshots/` and never enter commits. Restore refuses to run when the branch head has moved since the snapshot, so committed work is never lost. The staged/unstaged split is not restored, and untracked files created after the snapshot are not deleted.
|
|
632
|
+
|
|
633
|
+
### `cache`
|
|
634
|
+
|
|
635
|
+
Inspects and maintains the `openai` response cache stored in `.git/oc-pilot/cache/`.
|
|
636
|
+
|
|
637
|
+
```bash
|
|
638
|
+
oc-pilot cache # entries, size, expired count
|
|
639
|
+
oc-pilot cache prune # drop expired entries and trim to 50 MiB (--prune also works)
|
|
640
|
+
oc-pilot cache --clear # delete everything
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
The cache only works inside a git repository and only applies to the `openai` engine.
|
|
644
|
+
|
|
645
|
+
### `stats`
|
|
646
|
+
|
|
647
|
+
Prints usage statistics from `.git/oc-pilot/stats.jsonl`: runs, API calls, cache hits, average call duration and findings (critical/warning/style) for today, the last 7 days and all time.
|
|
648
|
+
|
|
649
|
+
```bash
|
|
650
|
+
oc-pilot stats
|
|
651
|
+
oc-pilot stats --json
|
|
652
|
+
oc-pilot stats --clear
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
### `day`
|
|
656
|
+
|
|
657
|
+
A local activity digest: what was committed since a point in time, which files churned most, lines added/deleted, and the oc-pilot findings for that period.
|
|
658
|
+
|
|
659
|
+
```bash
|
|
660
|
+
oc-pilot day
|
|
661
|
+
oc-pilot day --since "3 days ago" --json
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
### `impact`
|
|
665
|
+
|
|
666
|
+
Shows where else the symbols you changed are used. It extracts function, method, class, type and interface declarations from the diff (both added and removed lines, so renames show up under both names) and greps tracked and untracked files for them. This is a text search, not AST analysis, so it can over-report; it never fails the build.
|
|
667
|
+
|
|
668
|
+
```bash
|
|
669
|
+
oc-pilot impact
|
|
670
|
+
oc-pilot impact --staged --json
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
`--json` returns `symbols`, `references`, `scannedFiles` and `touchedFiles`, which is the shape agents want when they need to know what else a change might break.
|
|
674
|
+
|
|
675
|
+
### `explain`
|
|
676
|
+
|
|
677
|
+
Explains the findings of the previous review for one place in the code. Every `review` run stores its findings in `.git/oc-pilot/last-review.json`; `explain` looks up the finding on the given line, or the nearest one within three lines, and prints it next to a snippet of the current file. Secrets in the snippet are redacted by the same scanner as everywhere else.
|
|
678
|
+
|
|
679
|
+
```bash
|
|
680
|
+
oc-pilot explain src/wallet.ts:42
|
|
681
|
+
oc-pilot explain src/wallet.ts:42 --json
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
Without a line number, or when nothing matches, it falls back to every finding in that file, so the command stays useful when the file shifted.
|
|
685
|
+
|
|
686
|
+
### `reviewers`
|
|
687
|
+
|
|
688
|
+
Suggests who should review the current diff. For every changed file it walks the recent commits that touched it, counts the authors and picks the top candidates; bots are skipped. `CODEOWNERS` from `.github/CODEOWNERS`, `CODEOWNERS` or `docs/CODEOWNERS` is read and matched with the same last-rule-wins semantics as GitHub and GitLab.
|
|
689
|
+
|
|
690
|
+
```bash
|
|
691
|
+
oc-pilot reviewers --base main
|
|
692
|
+
oc-pilot reviewers --staged --limit 5 --exclude renovate
|
|
693
|
+
oc-pilot reviewers --base main --json -o reviewers.json
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
`--depth` looks further back than the default 50 commits. `--json` returns the files, the candidates (`name`, `email`, `commits`, `files`, `share`) and the matched `codeowners`, which is enough to fill `gh pr create --reviewer`.
|
|
697
|
+
|
|
698
|
+
### `replay`
|
|
699
|
+
|
|
700
|
+
Re-renders the last saved review without calling a model. Every `review` writes `.git/oc-pilot/last-review.json`, so a SARIF report or a PR comment can be regenerated for free, or handed to a colleague.
|
|
701
|
+
|
|
702
|
+
```bash
|
|
703
|
+
oc-pilot replay
|
|
704
|
+
oc-pilot replay --format sarif -o report.sarif
|
|
705
|
+
oc-pilot replay --as md -o pr-comment.md
|
|
706
|
+
oc-pilot replay --in saved.json --fail-on critical
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
`--format` accepts text, json and sarif; `--as` adds md for the PR comment body. `--in` reads any file with a `findings` array. The exit code follows `--fail-on`, exactly as in `review`.
|
|
710
|
+
|
|
711
|
+
### `slop`
|
|
712
|
+
|
|
713
|
+
Measures the entropy that fast, model-assisted coding leaves behind. `oc-pilot slop` scores a repository from 0 (clean) to 100 (rotten) without an API key, a model or network access: it needs only git and the working tree.
|
|
714
|
+
|
|
715
|
+
| Category | What it finds | Max |
|
|
716
|
+
| --- | --- | --- |
|
|
717
|
+
| Duplicates | Blocks of 72 or more tokens repeated across two different files | 30 |
|
|
718
|
+
| Dead code | Exports whose name appears in no other file (type-only exports and entry points are skipped) | 25 |
|
|
719
|
+
| Churn without tests | Files touched by five or more commits while tests changed in fewer than 40% of them | 25 |
|
|
720
|
+
| TODO graveyard | `TODO`, `FIXME`, `HACK` and `XXX` inside comments, weighted by age from `git blame` | 20 |
|
|
721
|
+
|
|
722
|
+
```bash
|
|
723
|
+
oc-pilot slop
|
|
724
|
+
oc-pilot slop --since origin/main --max-delta 10
|
|
725
|
+
oc-pilot slop --json -o slop.json
|
|
726
|
+
oc-pilot slop --badge -o slop.svg
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
`--since <ref>` compares the working tree with a revision and reports what this branch introduced and removed per category, plus `deltaPoints`. The delta matters more than the absolute number: a repository can sit at 50 and still be stable.
|
|
730
|
+
|
|
731
|
+
Other flags: `--limit` (items per category), `--since-days` (churn and blame window, default 30), `--exclude` (globs or substrings), `--no-blame` (skip `git blame`, much faster), `--max-index` and `--max-delta` (exit code 3 when exceeded), `--badge` (shields-style SVG), `--json`.
|
|
732
|
+
|
|
733
|
+
False positives go to `.oc-pilot/slopignore`: one glob or substring per line, `#` starts a comment. Comments and string literals are stripped before analysis, and test files, generated files and lock files are skipped. The score is a heuristic, not a verdict.
|
|
734
|
+
|
|
735
|
+
### `setup`
|
|
736
|
+
|
|
737
|
+
Configures an MCP client to launch `oc-pilot-mcp`. Existing server entries and unrelated settings are preserved. It writes configs for Claude Code, Codex, Cursor, Gemini CLI, OpenCode, VS Code, Windsurf, ZCode, and any client that reads `.agents/mcp.json`. By default it points at the current installation; `--npx` writes a version-pinned `npx -y oc-pilot@<version> mcp` entry instead. Generated servers start read-only; add `--allow-write` if the agent should apply patches and run tests.
|
|
738
|
+
|
|
739
|
+
```bash
|
|
740
|
+
# Project-local Claude Code config (.mcp.json)
|
|
741
|
+
oc-pilot setup --client claude --local
|
|
742
|
+
|
|
743
|
+
# OpenCode and Cursor in one run
|
|
744
|
+
oc-pilot setup --client opencode --client cursor --local
|
|
745
|
+
|
|
746
|
+
# Global config, or print without writing
|
|
747
|
+
oc-pilot setup --client codex --global
|
|
748
|
+
oc-pilot setup --client claude --local --print
|
|
749
|
+
|
|
750
|
+
# Remote HTTP server with a bearer token
|
|
751
|
+
oc-pilot setup --client claude --local \
|
|
752
|
+
--http https://oc-pilot.example.com/mcp --token "$OC_PILOT_MCP_TOKEN"
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
| Option | Purpose |
|
|
756
|
+
| --- | --- |
|
|
757
|
+
| `--client <name>` | `claude`, `codex`, `cursor`, `gemini`, `opencode`, `vscode`, `windsurf`, `zcode`, `agents`; repeatable |
|
|
758
|
+
| `--all` | Configure every supported client |
|
|
759
|
+
| `--global` | Write user-level config (project is the default) |
|
|
760
|
+
| `--local` | Force the current installation path |
|
|
761
|
+
| `--npx` | Force a version-pinned `npx` command |
|
|
762
|
+
| `--allow-write` | Let the client apply patches and run tests |
|
|
763
|
+
| `--print` | Print the config instead of writing it |
|
|
764
|
+
| `--json` | JSON plan for automation |
|
|
765
|
+
| `--http <url>` | Configure a remote Streamable HTTP endpoint |
|
|
766
|
+
| `--token <value>` | Enable bearer auth; the client reads the secret from `OC_PILOT_MCP_TOKEN` |
|
|
767
|
+
| `--cwd <dir>` | Project directory stored in the server args |
|
|
768
|
+
| `--force` | Replace an existing `oc-pilot` entry |
|
|
769
|
+
|
|
770
|
+
`setup` never writes the bearer token into a client config. It writes an `OC_PILOT_MCP_TOKEN` reference; export the secret in the environment that launches the client.
|
|
771
|
+
|
|
772
|
+
`setup` writes only MCP client config. It does not install packages or change your source. With no `--client`, it detects Claude Code, Codex, Cursor, Gemini CLI, OpenCode, VS Code, Windsurf, ZCode, and `.agents` clients from installed commands and config directories.
|
|
773
|
+
|
|
774
|
+
### `doctor`
|
|
775
|
+
|
|
776
|
+
One command that explains why a setup is not working:
|
|
777
|
+
|
|
778
|
+
```bash
|
|
779
|
+
oc-pilot doctor
|
|
780
|
+
oc-pilot doctor --json
|
|
781
|
+
oc-pilot doctor --engine openai --model deepseek-chat
|
|
782
|
+
oc-pilot doctor --fix
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
It checks Node, the active engine, API credentials, git and repository state, the detected test command, project rules, oc-pilot git hooks and the response cache, and every MCP client config. `--fix` refreshes outdated oc-pilot hooks (a backup of the previous file is kept) and prunes expired cache entries; foreign hooks are never touched and are reported instead. Errors return exit code 1; `--strict` also fails on warnings. No secret values are printed. It also warns when an installed managed hook cannot find an oc-pilot binary or when that binary's version differs from the running CLI, because such a hook can skip or misjudge the check.
|
|
786
|
+
|
|
787
|
+
### `init`
|
|
788
|
+
|
|
789
|
+
```bash
|
|
790
|
+
oc-pilot init
|
|
791
|
+
oc-pilot init --preset node
|
|
792
|
+
oc-pilot init --hooks
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
Creates `.oc-pilot.json`. It does not overwrite an existing config unless `--force` is passed. With `--preset <a,b>` it also writes a curated `.oc-pilot/rules.md` for the stack. One or more presets can be combined, e.g. `--preset react,security`:
|
|
796
|
+
|
|
797
|
+
`base` (language-agnostic), `node`, `react`, `next`, `vue`, `svelte`, `angular`, `typescript`, `python`, `go`, `rust`, `java`, `kotlin`, `csharp`, `swift`, `php`, `ruby`, `flutter`, `elixir`, `zig`, `scala`, `security` (cross-stack hardening), `devops` (Docker, CI, infrastructure).
|
|
798
|
+
|
|
799
|
+
The rules file is a normal project rules file - edit it freely.
|
|
800
|
+
|
|
801
|
+
`--hooks` installs the git hooks from `install-hook`: `preflight --staged` on commit and `review` on push. Existing hooks are backed up, and a missing hook directory is only a warning, so `init` never fails because of it.
|
|
802
|
+
|
|
803
|
+
## Common options
|
|
804
|
+
|
|
805
|
+
| Option | Default | Purpose |
|
|
806
|
+
| --- | --- | --- |
|
|
807
|
+
| `-C, --cwd <dir>` | current directory | Project directory |
|
|
808
|
+
| `-m, --model <id>` | engine default | Model id (`provider/model` for OpenCode) |
|
|
809
|
+
| `--engine <name>` | `opencode` | `opencode` or `openai` (any compatible API) |
|
|
810
|
+
| `--engine-preset <p>` | — | `ollama`, `lmstudio`, `openrouter` |
|
|
811
|
+
| `--base-url <url>` | `https://api.openai.com/v1` | OpenAI-compatible endpoint |
|
|
812
|
+
| `--api-key-env <name>` | `OC_PILOT_API_KEY` | Environment variable holding the API key |
|
|
813
|
+
| `--agent <name>` | `oc-pilot` | Use another OpenCode agent |
|
|
814
|
+
| `--lang <en\|ru>` | `en` | Model-facing prompt and output language |
|
|
815
|
+
| `--no-repo-context` | off | Diff-only mode; no repository tools |
|
|
816
|
+
| `--rules <path>` | `.oc-pilot/rules.md` | Project rules file |
|
|
817
|
+
| `--fail-on <level>` | `none` | Exit 3 on `critical`, `warning`, or `style` findings |
|
|
818
|
+
| `--max-diff <size>` | `120000` | Diff/context budget |
|
|
819
|
+
| `--max-file <size>` | `60000` | Per-file budget for docgen |
|
|
820
|
+
| `--max-cost <usd>` | `0` | Daily spend cap for `openai` calls (`0` disables) |
|
|
821
|
+
| `--timeout <duration>` | `300` | Model/test timeout; supports `5m` |
|
|
822
|
+
| `-o, --output <path>` | stdout | Write the result to a file |
|
|
823
|
+
| `--format <f>` | `text` | Output format: `text`, `json`, `sarif` (`scan`, `review`) |
|
|
824
|
+
| `--json` | off | Machine-readable output |
|
|
825
|
+
| `--dry-run` | off | Print the prompt without calling a model |
|
|
826
|
+
| `--strict` | off | Exit 3 when the output schema is invalid |
|
|
827
|
+
| `--verbose` | off | Stream OpenCode diagnostics |
|
|
828
|
+
| `--no-cache` | off | Bypass the response cache (`openai`) |
|
|
829
|
+
|
|
830
|
+
## Project rules
|
|
831
|
+
|
|
832
|
+
Add a `.oc-pilot/rules.md` at the project root, or point to one with `--rules` / the `rules` config field:
|
|
833
|
+
|
|
834
|
+
```markdown
|
|
835
|
+
- Keep handlers thin; business logic belongs in services.
|
|
836
|
+
- Errors must wrap the original cause.
|
|
837
|
+
- Never log request bodies or tokens.
|
|
838
|
+
- Prefer table-driven tests.
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
Rules are added to every recipe. They are scanned and redacted like any other project content, unless `--no-secret-scan` is used.
|
|
842
|
+
|
|
843
|
+
## Secret scanning
|
|
844
|
+
|
|
845
|
+
The scanner looks at added diff lines and common source-file patterns:
|
|
846
|
+
|
|
847
|
+
- private key blocks;
|
|
848
|
+
- OpenAI, Anthropic, Hugging Face, Groq, Google, GitHub, GitLab, npm, PyPI, Slack, Discord, Telegram, Stripe, SendGrid, DigitalOcean, and AWS keys;
|
|
849
|
+
- Azure storage account keys;
|
|
850
|
+
- JWTs, credentials in URLs, and sensitive `.env` assignments;
|
|
851
|
+
- high-entropy assignments (Shannon entropy over 4 bits for values of 20+ characters) reported as critical.
|
|
852
|
+
|
|
853
|
+
To silence a false positive, add path globs to `.oc-pilot/ignore` (one per line, `#` starts a comment), or append the inline marker to the source line:
|
|
854
|
+
|
|
855
|
+
```
|
|
856
|
+
# .oc-pilot/ignore
|
|
857
|
+
fixtures/**
|
|
858
|
+
docs/examples/**
|
|
859
|
+
|
|
860
|
+
# inline, any language
|
|
861
|
+
const TOKEN = "sk-proj-..."; // oc-pilot:ignore-secret
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
Ignore rules are path- and line-scoped, apply to every scanning point (diff, rules, docgen, full-file context), and never disable scanning for the rest of the project.
|
|
865
|
+
|
|
866
|
+
Detected values never appear in full in logs or JSON. The model receives `[REDACTED:<kind>]` and a masked preview. Review the provider's data policy before sending proprietary code.
|
|
867
|
+
|
|
868
|
+
`--no-secret-scan` and `redactSecrets: false` disable this protection for the diff, rules, and `FULL_FILE_CONTEXT`. Use them deliberately.
|
|
869
|
+
|
|
870
|
+
## Output and exit codes
|
|
871
|
+
|
|
872
|
+
Markdown response:
|
|
873
|
+
|
|
874
|
+
```markdown
|
|
875
|
+
### Analysis: Short conclusion.
|
|
876
|
+
|
|
877
|
+
#### Findings / Actions
|
|
878
|
+
- **Critical `wallet.go:10`**: nil pointer dereference.
|
|
879
|
+
|
|
880
|
+
#### Solution
|
|
881
|
+
```go
|
|
882
|
+
// minimal fix
|
|
883
|
+
```
|
|
884
|
+
```
|
|
885
|
+
|
|
886
|
+
`--lang ru` uses the Russian schema (`### Анализ:`, `#### Замечания / Действия`, `#### Решение`).
|
|
887
|
+
|
|
888
|
+
`--json` returns:
|
|
889
|
+
|
|
890
|
+
```json
|
|
891
|
+
{
|
|
892
|
+
"recipe": "review",
|
|
893
|
+
"projectType": "Go",
|
|
894
|
+
"analysis": "### Analysis: ...",
|
|
895
|
+
"findings": [
|
|
896
|
+
{ "severity": "critical", "location": "wallet.go:10", "text": "nil pointer dereference" }
|
|
897
|
+
],
|
|
898
|
+
"secrets": [],
|
|
899
|
+
"meta": {
|
|
900
|
+
"engine": "opencode",
|
|
901
|
+
"agent": "oc-pilot",
|
|
902
|
+
"model": "openai/gpt-5.5",
|
|
903
|
+
"lang": "en",
|
|
904
|
+
"repoContext": true,
|
|
905
|
+
"formatValid": true,
|
|
906
|
+
"formatWarnings": [],
|
|
907
|
+
"findings": { "critical": 1, "warning": 0, "style": 0 }
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
```
|
|
911
|
+
|
|
912
|
+
| Code | Meaning |
|
|
913
|
+
| --- | --- |
|
|
914
|
+
| 0 | Success, no failing policy |
|
|
915
|
+
| 1 | Runtime error, or critical secret from `scan` |
|
|
916
|
+
| 2 | Argument/configuration error |
|
|
917
|
+
| 3 | Policy gate: `--fail-on`, `--fail-on-secrets`, or `--strict` |
|
|
918
|
+
|
|
919
|
+
## Configuration
|
|
920
|
+
|
|
921
|
+
`oc-pilot` reads `.oc-pilot.json` from the project directory or an ancestor, then environment variables, then CLI flags.
|
|
922
|
+
|
|
923
|
+
```json
|
|
924
|
+
{
|
|
925
|
+
"engine": "opencode",
|
|
926
|
+
"model": "anthropic/claude-sonnet-4-5",
|
|
927
|
+
"agent": "oc-pilot",
|
|
928
|
+
"lang": "en",
|
|
929
|
+
"repoContext": true,
|
|
930
|
+
"failOn": "none",
|
|
931
|
+
"maxDiffChars": 120000,
|
|
932
|
+
"maxOutputChars": 40000,
|
|
933
|
+
"maxFileChars": 60000,
|
|
934
|
+
"timeoutSeconds": 300,
|
|
935
|
+
"redactSecrets": true,
|
|
936
|
+
"testCommand": "npm test",
|
|
937
|
+
"agentRules": true,
|
|
938
|
+
"secondOpinionEnabled": false,
|
|
939
|
+
"maxDailyApiCalls": 0
|
|
940
|
+
}
|
|
941
|
+
```
|
|
942
|
+
|
|
943
|
+
For the API engine, set `"engine": "openai"`, `"model": "deepseek-chat"`, `"baseUrl": "https://api.deepseek.com/v1"`, and optionally `"apiKeyEnv": "DEEPSEEK_API_KEY"` in the same file.
|
|
944
|
+
|
|
945
|
+
Environment variables: `OC_PILOT_ENGINE`, `OC_PILOT_BASE_URL`, `OC_PILOT_API_KEY_ENV`, `OC_PILOT_MODEL`, `OC_PILOT_AGENT`, `OC_PILOT_LANG`, `OC_PILOT_REPO_CONTEXT`, `OC_PILOT_FAIL_ON`, `OC_PILOT_RULES`, `OC_PILOT_MAX_DIFF_CHARS`, `OC_PILOT_MAX_OUTPUT_CHARS`, `OC_PILOT_MAX_FILE_CHARS`, `OC_PILOT_TIMEOUT_SECONDS`, `OC_PILOT_TEST_COMMAND`, `OC_PILOT_REDACT_SECRETS`.
|
|
946
|
+
|
|
947
|
+
## MCP server
|
|
948
|
+
|
|
949
|
+
`oc-pilot-mcp` exposes the same recipes as MCP tools over stdio. This is the recommended way to embed oc-pilot in an agent: the agent calls a tool, and no prompt needs to be copied.
|
|
950
|
+
|
|
951
|
+
Besides tools, the server exposes read-only MCP resources: `oc-pilot://config` (resolved configuration), `oc-pilot://rules` (project rules with secrets redacted), `oc-pilot://prompt/en` and `oc-pilot://prompt/ru` (the built-in system prompts), and `oc-pilot://version`. `oc-pilot://slop` returns the Slop Index as JSON without calling a model. Resource templates cover live data: `oc-pilot://diff/{mode}` (staged/unstaged/head diff, secrets redacted), `oc-pilot://scan/{mode}` (offline secret scan as JSON) and `oc-pilot://file/{+path}` (any project file up to 2 MB with detected secrets redacted). Hosts can list them with `resources/list` and `resources/templates/list`.
|
|
952
|
+
|
|
953
|
+
Tools: `review`, `invariants`, `test_fix`, `fix`, `test_gen`, `docgen`, `custom`, `scan`, `commit`, `stats`, `slop`, `mutate`, `fuzz`, `bankruptcy`, `query_ast`, `sandbox`, `hivemind_status`, `flaky`, `impact`, `deps`, `coverage`, `reviewers`, `test_guard`, `env_sync`, `mock_leak`, `ecosystem_verify`, `pack`, `pack_hologram`, `zoom_symbol`, `contract_drift`, `anti_regression`, `boundaries`, `test_plan`, `compliance_verify`, `brag`, `battle`, `cleanup`, `arch_diff`, `roast`, `cinema`, `bounty`, `autopsy`, `echo`, `sast`, `authz`, `preflight`, `honeypot`, `alien_dna`, `hyper_chamber`, `butterfly`, `blindfold`, `antibody`, `polygraph`, `passport`, `oracle`, `vaccine`, `mitosis`, `intent`, `scalpel`, `mayday`, `clairvoyant`, `hemorrhage`, `cuckoo`, `chronos`, `flight_start`, `flight_exec`, `flight_note`, `flight_checkpoint`, `flight_status`, `flight_grep`, `flight_list`, `flight_show`, `flight_verify`, `flight_end`, `flight_replay`, `flight_bisect`, `flight_diff`, `flight_compare`, `flight_html`, `flight_summary`, `flight_stats`, `flight_prune`, `flight_delete`, `flight_restore`, `flight_export`, `flight_verify_bundle`, `beacon`, `quarantine`, `mirage`, `warden`, `tribunal`, `skeptic`, `apoptosis`, `scan_injection`, `ready`, `receipt_verify`. `scan` accepts `all: true` to sweep the whole repository instead of the diff. `slop` runs the offline Slop Index and accepts `since`, `since_days`, `limit`, `exclude` and `no_blame`. `mutate` runs mutation testing on the changed code, accepts `command`, `max_mutants` and `min_score`, and returns the score plus every surviving mutant; a score below `min_score` is a normal result with exit code 1. `flaky` runs the test command several times and compares per-test results, accepting `runs`, `command`, `fail_on_flaky`, `shuffle` and `seed`; it never edits source files itself but does run the project's tests. `impact` lists the declarations the diff changed or removed and every untouched file that still mentions them, accepting the same source flags; the search is textual, so comments and strings can match. `deps` audits declared, imported and locked dependencies, explains a chain with `why`, adds OSV vulnerabilities and licenses with `audit`, and can rewrite `package.json` with `fix` or emit a CycloneDX SBOM; `fix` and `sbom` write files. `coverage` compares changed lines with a local lcov, Istanbul, Cobertura or Go coverage report and returns uncovered lines, missing files and a gate on `fail_under` or `max_uncovered`. `reviewers` ranks the authors who touched the changed files, lists CODEOWNERS owners and accepts `limit`, `depth` and `exclude`; it uses git history only. `test_guard` runs the offline anti-cheating check on the diff: skipped, focused or deleted tests, removed or commented assertions, raised timeouts, strict matchers replaced by existence checks, `@ts-ignore` and empty catch blocks; with `fail_on_weakening` a finding returns exit code 1. `env_sync` compares the environment variables added by the diff (`process.env`, `import.meta.env`, `Deno.env`, `Bun.env`) with the local `.env` files and `.env.example`/`.sample`/`.template`: missing definitions fail with `fail_on_missing`, and defined but undocumented variables warn. `mock_leak` scans added production code for forgotten stubs and hardcode: local paths, test tokens, `if (true)`/`if (false)`, mock/fake/stub identifiers, mock comments and localhost URLs; `fail_on_leak` returns exit code 1 at the chosen severity. `ecosystem_verify` checks that named imports from the changed files exist in the installed package entry or its `.d.ts`, and flags packages that are neither installed nor declared; with `online` it also checks the age and weekly downloads of newly added npm packages, and `fail_on_issue` returns exit code 1 at the chosen severity. `pack` builds a compact context bundle for a task: project rules, changed-file signatures, related references and an optional test log, capped by `budget` characters; it never edits files. `contract_drift` compares changed TypeScript interfaces, Zod objects, Prisma models, Pydantic models and JSON Schema with the previous version, flags removed or newly required fields and type changes, and reports untouched consumers that still use a removed field; `fail_on_drift` returns exit code 1 at the chosen severity. `anti_regression` compares the lines added by the diff with lines a human explicitly deleted in git history, cites the deleting commit and flags re-added code or imports; `fail_on_regression` returns exit code 1. `boundaries` checks added imports against `.oc-pilot/architecture.json` layer rules, reports the file, line, import and rule reason, and `fail_on_violation` returns exit code 1 when a layer boundary is crossed. `test_plan` selects the test files affected by the diff from a static import graph: changed tests, direct and transitive importers, naming matches and symbol references, with uncovered changed files reported and an optional `fail_on_uncovered` gate. `compliance_verify` checks a signed audit manifest for the current commit: SHA-256, commit, previous-manifest hash chain and optional Ed25519 signature; a missing, edited or broken manifest is a normal result with exit code 1. `brag` builds a self-contained HTML or SVG session report from stats, git history, the last review and the receipt; it uses inline assets only, never calls a model or the network, and `no_paths` hides file locations. `test_gen` asks the model for tests that cover the changed code; with `apply` it writes test files, runs the suite and reverts failing tests unless `keep_failing`, while `coverage` narrows generation to uncovered changed lines and `from_slop` picks untested files. `cleanup` builds an offline cleanup plan from dependency issues, the Slop Index, environment variables and weakened tests; `apply` performs only safe dependency fixes and needs `--allow-write`. `arch_diff` renders a Mermaid diagram of the internal imports the diff added and removed: green edges are new dependencies, red dashed edges are removed ones, and `fail_on_removed` returns exit code 1 when a dependency disappears. `roast` turns the diff into a technically grounded comedy roast in a chosen persona (linus, ramsay, corporate or default), cites file:line for every joke and ends with one real fix; it is model-backed and never edits files. `cinema` builds a terminal timelapse of the session from commits, runs, API calls, the last review and the receipt: a self-contained HTML player or an asciinema v2 cast, with no network, external assets or model call; `no_paths` hides subjects and finding locations. `bounty` scores every file from SAST findings, duplicated blocks, dead exports, aged TODOs and churn without tests, then renders an ASCII WANTED poster with the worst file and its reasons; deterministic and offline. `autopsy` performs a post-mortem on a commit: diff stats, SAST on added lines, weakened tests, mock leaks, ranked suspects and a before/after timeline; `fail_on_risk` returns exit 1 for a dangerous verdict. `echo` builds self-contained SVG badges from local stats, git history and the receipt (commits, agent runs, API calls, cache hits, findings and test status); `submit` sends only the nickname, window and aggregate numbers to an explicit `endpoint`, never paths, diffs or secrets, and there is no network by default. `sast` runs the deterministic static analysis over the change or over explicit `paths` and accepts `fail_on_issue`, `ignore` and `no_suppressions`; a finding at or above the gate is a normal result with exit code 1. `authz` checks route authorization over the change or explicit `paths` and accepts `fail_on_issue`, `ignore`, `public` and `no_suppressions`; a route finding at or above the gate is also a normal result with exit code 1. `preflight` returns one offline verdict over the planned change and accepts the same source flags (`diff`, `base`, `staged`, `unstaged`, `include_untracked`), plus `since`, `max_delta`, `fail_on_issue`, `no_secret_scan`, `no_sast`, `no_authz`, `no_deps`, `no_tests` and `no_slop`; a failed check is a normal result with `status: "fail"` and exit code 1, so the agent sees the failing check instead of a tool error. `ready` returns the offline agent readiness score 0-100 and accepts `fail_under`; a score below the threshold is also a normal result with exit code 1. `receipt_verify` recomputes the SHA-256 hash of the receipt, compares the recorded commit with HEAD and reports `ok`, `hashOk` and `stale`; a missing, edited or stale receipt is a normal result with `ok: false` and exit code 1, so an agent can see why the proof failed. The `fix` tool accepts `from_sast` and `from_authz` to repair security findings and rescan; the result then carries `sast` or `authz` with `{before, after, remaining}`. The server is read-only by default; start it with `--allow-write` to permit `fix` with `apply: true`, `commit` with `apply: true`, `test_fix` with a command, `stats` with `clear: true` and `mutate`, which rewrites source files temporarily. `test_gen` with `apply: true` also needs `--allow-write`. The `fix` result carries the unified `patch`, its `files` and `patchStats` (`additions`, `deletions`, `hunks`, `bytes`); patches over 200 000 characters are cut and marked with `patchTruncated` and `patchBytes`, so a host can show or apply the change without parsing the diff again.
|
|
954
|
+
|
|
955
|
+
`invariants` checks the diff against `.oc-pilot/invariants.md`
|
|
956
|
+
|
|
957
|
+
`hivemind` is an encrypted TCP mesh for sharing analysis work: `init` creates an ed25519 identity, `trust` pins a peer public key, `serve` accepts signed ECDH X25519 handshakes, and `send` transmits AES-256-GCM encrypted payloads. Only diffs, AST and LLM requests are allowed; executable payloads are rejected, and untrusted peers are dropped before any data is read.
|
|
958
|
+
|
|
959
|
+
`sandbox run <file>` executes one self-contained JavaScript or ESM file in `node:vm` with a separate context: static imports, `require`, `fetch`, `process.exit` and timers longer than a second are blocked, console output is captured, and execution is capped by `--timeout` and `--memory-limit`. TypeScript runs only from a built `dist/*.js`. This is not an OS sandbox for native code.
|
|
960
|
+
|
|
961
|
+
`honeypot deploy` plants decoy files — `.env.backup` with fake AWS keys, `src/utils/legacy/bypassAuth.ts` with a trapped `bypassAuth`, and `src/legacy/legacy_db_drop.ts` — and records them in `.oc-pilot/honeypot.json`. `preflight` fails with `[HONEYPOT TRIGGERED]: Agent attempted to bypass authentication using a trapped function. Session terminated. Trust score reduced.` when the diff imports, reads or changes a decoy. `honeypot status` lists the traps and `honeypot remove` deletes only marker files; the decoys are not real secrets.
|
|
962
|
+
|
|
963
|
+
`alien-dna` compares added diff lines with the repository architecture DNA at HEAD and fails with `[ALIEN DNA DETECTED]` when the change introduces a pattern that never appeared before (0% occurrence): Singleton, Proxy, dynamic RegExp, eval, global state, inheritance, decorators, Worker, EventEmitter, dynamic import, sync I/O or prototype mutation. The command is offline and deterministic, reads the baseline with git and never calls a model.
|
|
964
|
+
|
|
965
|
+
`hyper-chamber run <file>` ages one self-contained JavaScript or ESM file in `node:vm`: it fakes `Date.now`, accelerates timers, forces GC and samples the heap through `node:v8` while simulating up to a year of uptime in a short real budget. Sustained growth returns `[MEMORY LEAK DETECTED]: AI code survives Day 1, but crashes on Day N of simulated uptime.` The file must export `run`, `tick`, `main` or `default`; a plain script is wrapped and re-executed. This is a deterministic heuristic, not a proof, and native code is not supported.
|
|
966
|
+
`butterfly` runs the project test command under deterministic local chaos: `fetch` can return HTTP 500, add latency or broken JSON, and `fs` can return `EIO` for code under `--scope` (default `src/`). It reports injected fault counts, exit code and output tail; the test runner and `node_modules` are excluded by a stack filter, and database driver patching is best-effort. This is a test aid, not an OS sandbox.
|
|
967
|
+
|
|
968
|
+
`blindfold` obfuscates identifiers (`calculateDiscount(user)` becomes `fn_A(var_B)`) and sends only the stripped code to the model, asking for a strict JSON verdict. It fails with `[BLINDFOLD REJECTED]` when the model cannot explain the logic, finds a vulnerability, or confidence is below `--min-confidence`; `--dry-run` prints the mapping without a model call. It is a blind review, not a mathematical proof.
|
|
969
|
+
|
|
970
|
+
`antibody` learns from security findings: `antibody learn` scans the repository with the offline SAST engine and stores each finding as a signature (rule plus a normalized code snippet) in `.oc-pilot/antibodies.json`; `antibody scan` checks added diff lines against those signatures and fails with `[ANTIBODY MATCH]` when a known bad pattern returns. `antibody list`, `forget` and `clear` manage the store. It is a memory of past findings, not a replacement for a full SAST review.
|
|
971
|
+
|
|
972
|
+
`polygraph` checks the story against the code: it extracts the factual claims from a commit message or PR body and verifies each one against the diff. `test-added`, `file-added`, `file-removed`, `api-change`, `dependency`, `docs`, `security`, `behavior` and `refactor` claims get a deterministic check; `supported` means consistent with the diff, `contradicted` means the message promises something the diff does not do, and `unverifiable` means the diff cannot settle it. `[CLAIM CONTRADICTED]` exits 1, and `--strict` also fails on unverifiable claims. It reads the message, not the author's intentions.
|
|
973
|
+
|
|
974
|
+
`passport` records provenance instead of promises: `passport write` stores the commit, tree, changed files with SHA-256 or git blob hashes, the agent, the model and the checks you actually ran in `.oc-pilot/passport.json`, then binds the manifest with a digest. `passport verify` re-hashes the files and proves the manifest is still valid; a changed tree prints `[PASSPORT STALE]`, and an edited manifest prints `[PASSPORT TAMPERED]`. A commit passport stays valid for its immutable commit; a worktree passport is valid only while HEAD and the files are unchanged. A passport proves what was recorded, not that the code is correct.
|
|
975
|
+
|
|
976
|
+
`oracle` turns a refactor claim into a behavioral experiment: `oracle --command "node harness.mjs {input}" --input corpus.json` runs the same JSON cases on clean HEAD and on the diff in two shadow worktrees, then compares stdout and exit codes. Any difference prints `[BEHAVIOR CHANGED]` with the exact input and both outputs; identical results print `[BEHAVIOR SAME]`. The harness must be deterministic and read the `{input}` file. A same result covers only the supplied corpus, not every possible input.
|
|
977
|
+
|
|
978
|
+
`vaccine` turns a fixed bug into a permanent regression test. `vaccine create --fix HEAD` takes the fix commit and its parent, asks the model for one minimal test, then proves it in two shadow worktrees: the test must fail on the buggy parent and pass on the fix. Only verified vaccines are stored in `.oc-pilot/vaccines` with their metadata; `vaccine run` replays all of them on HEAD, and `list`, `forget` and `clear` manage the store. A rejected test is not a vaccine.
|
|
979
|
+
|
|
980
|
+
`mitosis` makes a large diff reviewable: `mitosis plan --strategy dir|file|type` partitions the change into an ordered commit sequence, and `mitosis apply --confirm` replays it in a shadow worktree, commits each group, optionally runs the test command after every commit, and exposes the result as a branch plus patch files in `.oc-pilot/mitosis`. Config changes come first, then source, tests and docs. If a commit fails tests, the branch stops there for inspection; a skipped test run is reported as skipped, not as a pass.
|
|
981
|
+
|
|
982
|
+
`intent` checks the change against the acceptance criteria: `intent check --criteria docs/acceptance.md` returns `met`, `partial`, `unmet` or `unverifiable` per criterion with evidence from the diff, and exits 1 on `unmet`. `intent sphinx --request "..."` runs before code: it lists missing questions, hidden assumptions and testable criteria, and prints `[REQUIREMENTS AMBIGUOUS]` when the request leaves decisions open. Both modes are model-backed; `met` means the diff supports the criterion, not that the feature is correct in production.
|
|
983
|
+
|
|
984
|
+
`scalpel` fixes a failure with the smallest change: give it a failing log (`--log`) or a command that reproduces the failure, and it asks the model for a minimal patch, applies the current diff plus the patch in a shadow worktree, runs the tests, and reports the blast radius — the symbols and references the patch touches. `[SCALPEL FIXED]` means the tests pass in the shadow; `--apply` writes the proven patch to the worktree. A rejected patch is never applied.
|
|
985
|
+
|
|
986
|
+
`mayday` handles the incident: `mayday bisect --good v1.2.0 --bad HEAD --command "npm test"` binary-searches the first commit where the check starts failing and prints its author, date and diff stat. `mayday rollback --to v1.2.0 --confirm` reverts everything after the target in a shadow worktree with `git revert`, runs the tests and exposes a reviewable branch. It never uses `reset --hard` or force-push; a failed rollback still leaves the branch for inspection.
|
|
987
|
+
|
|
988
|
+
`clairvoyant` predicts the CI scope: it maps changed files and exported symbols to tests that import them, reference their names or match the `*.test` naming convention, then returns the minimal subset in `[CI SCOPE]`. If nothing matches, it says to run the full suite instead of pretending the change is covered. It is a textual map, not a coverage proof.
|
|
989
|
+
|
|
990
|
+
`hemorrhage` proves or rejects a performance regression: it runs the same benchmark on HEAD and on the diff in two shadow worktrees, alternates the order, and compares medians, p95 and MAD. `--metric time` measures wall time, `--metric stdout` reads one number from the output, and `--direction higher` handles throughput. `[PERFORMANCE REGRESSION]` requires the change to exceed the threshold and the noise floor with a Mann-Whitney p below 0.05; a `same` verdict means this benchmark did not prove a regression, not that performance is fine everywhere.
|
|
991
|
+
|
|
992
|
+
`cuckoo` audits untrusted JS/ESM before you trust it: the file runs in an instrumented `node:vm` sandbox with mocked `fs`, `net`, `child_process` and `process`, and every attempt is recorded. `[CAPABILITY DENIED]` lists the capabilities it reached for; `process.exit` and static `import`/`export` stop execution, and `--allow fs,env` permits only named kinds. A clean run covers this file and this sandbox, not transitive native code or dynamic imports.
|
|
993
|
+
|
|
994
|
+
`chronos` reads a file's chronicle: commits, churn, fix/revert/incident/security markers, antibodies and vaccines, then scores it as a hotspot. `[HOTSPOT]` means the file has a history of fixes, rollbacks or incidents; inspect it before changing it and add a vaccine for the next fix. A low score is not proof that the file is safe.
|
|
995
|
+
|
|
996
|
+
`flight` records an agent session as a hash-chained black box: `flight start --name "fix auth"` writes `.git/oc-pilot/flights/<id>/events.jsonl`, `flight exec -- <command>` records each command and its output tail, and `flight checkpoint --label after-fix` creates a dangling git commit of the full worktree without moving HEAD. `flight status` (which also names the last session when none is active), `list` and `show` inspect the journal; `flight show [<id>]` defaults to the active or latest session and reads `--bundle <file>` without the journal; `--kind <kind>` and `--last <n>` filter the events shown; `flight verify [<id>]` recomputes the chain, defaulting to the active or latest session, and prints `[FLIGHT TAMPERED]` on any edit; `flight verify --all` audits every session; `flight end` closes the session. The log is local, NDJSON and zero-dependency. `flight replay --to <label|commit>` materializes a checkpoint as a detached worktree, `flight bisect -- <command>` runs a command at each checkpoint and stops at the first failure, `flight diff` compares checkpoints (or prints a checkpoint patch from an exported bundle with `--bundle <file>`), and `flight export` writes a redacted bundle with a sha256 digest. `flight compare <id-a> <id-b>` compares two sessions by event and note counts, duration, command sets, exit codes and final tree; `--bundles <a> <b>` compares two exported bundles instead. `flight html` renders a self-contained, redacted HTML timeline with checkpoints and command output, and `--bundle <file>` renders one from an exported bundle without the journal. `flight summary [--id <id>]` renders a Markdown session summary with checkpoints, commands and notes; `--bundle <file>` builds it from an exported bundle. `flight stats` aggregates sessions, commands, notes, failures, checkpoints and duration across the journal; it also names the last flight. `flight prune` removes old ended sessions while keeping the active flight and the newest N sessions; `flight delete <id>` removes one recorded session and refuses the active flight. `flight export --key <file>` signs the bundle digest with HMAC-SHA256, `--bundle <file>` re-signs an existing bundle, and `flight verify-bundle <file> --key <file>` checks the digest, chain and signature. `flight compare --html` renders a side-by-side visual comparison report. `flight stats --html` renders a self-contained dashboard of the journal, including the last flight. `flight keygen --output flight.key` generates a random HMAC key for signing exports. `flight restore <label|commit>` restores the worktree from a checkpoint without moving HEAD; `--dry-run` lists the files that would change. `flight list --limit <n>` shows only the newest sessions with event, checkpoint and note counts. `flight note "<text>"` appends a hash-chained note to the active flight, shown in show, summary, HTML and exports. `flight grep "<text>"` searches notes, commands, command output, checkpoint labels and flight names across sessions, `--kind <kind>` limits the search to one event kind, and `--bundle <file>` searches an exported bundle. `flight prove --claim "<claim>" -- <command>` proves a claim by showing the check fails at the base commit and passes after a checkpoint.
|
|
997
|
+
|
|
998
|
+
`beacon` records a verification claim for a commit: `beacon stamp --check tests=pass --check preflight=pass --key beacon.key` stores the commit, tree, tool version, agent, model, commands, checks and a digest in `.oc-pilot/beacon.json`, then signs it with HMAC or `ssh-keygen`. `beacon verify` detects `[BEACON TAMPERED]` and `[UNATTRIBUTED]`; `beacon render --markdown` produces a PR comment. An unsigned beacon is valid but unattributed, so pass `--require-signature` in CI.
|
|
999
|
+
|
|
1000
|
+
`quarantine` makes flaky-test suppression temporary: `quarantine add --test "auth flow" --owner alice --reason "race" --days 14` stores the test, owner, reason and expiry in `.oc-pilot/quarantine.json`; `quarantine check` prints `[QUARANTINE EXPIRED]` and exits 1 when the deadline passes. `list`, `remove` and `clear` manage the store. A quarantined test still exists and still fails; the entry only records who owns the fix and when the gate will force it.
|
|
1001
|
+
|
|
1002
|
+
`mirage` makes a test hermetic: `mirage record --command "node test.mjs" --cassette cassettes/login.json` runs the command with a preload that records every `fetch` response and `Date.now` value; `mirage replay` serves those responses from the cassette and fails with `[MIRAGE MISS]` on any unrecorded request. `list`, `show` and `clear` manage cassettes. It records `fetch` and the clock, not arbitrary sockets or native modules.
|
|
1003
|
+
|
|
1004
|
+
`warden` turns repository rules into code: `.oc-pilot/policy.json` can forbid paths (`package-lock.json`, `.env`), content (`eval(`), dependencies and extensions, require tests whenever source changes, and cap the diff size. `warden check` reports `[POLICY VIOLATION]` with rule, file and evidence and exits 1; `init` writes a sample policy and `show` renders the current one. It is deterministic and offline.
|
|
1005
|
+
|
|
1006
|
+
`tribunal` runs three separate reviewers — security, correctness and maintainability — and keeps only findings confirmed by at least two of them. `[TRIBUNAL CONSENSUS]` marks a confirmed issue, `[TRIBUNAL SPLIT]` marks a single-lens opinion, and `[TRIBUNAL CLEAN]` means no lens found anything. `--lenses`, `--min-consensus` and `--fail-on` control the panel. A split finding is a lead, not a verdict.
|
|
1007
|
+
|
|
1008
|
+
`skeptic` asks the model for a minimal executable test that should fail on the diff, applies the diff in a real shadow worktree, and runs the test on both the diff and clean HEAD. `bug` means the test fails on the diff and passes on HEAD; `clean` means the hypothesis was rejected; `unfalsifiable` means the test cannot distinguish the trees. A passing test never proves the absence of bugs.
|
|
1009
|
+
|
|
1010
|
+
`apoptosis` scans functions marked `/* @lifespan: 30d */`. When the marker is older than the lifespan and the symbol has no references, it reports `[Senescent]`; `apoptosis apply --confirm` comments those functions out in a shadow git worktree, runs the test command and lands the diff only if the suite is green. A failed run leaves the working tree untouched. It is a cleanup workflow for AI-written code, not an automatic guarantee that the function is unused at runtime.
|
|
1011
|
+
|
|
1012
|
+
`injection` scans the text an agent may read — README, docs, comments, HTML, JSON, YAML and source — for prompt-injection phrases, role hijacks, secret exfiltration, hidden unicode, CSS-hidden instructions, suspicious markdown images and base64 payloads. `--fail-on` controls the exit threshold, `--fix` strips invisible unicode, and `--include`/`--exclude` narrow the scan. It is a heuristic firewall, not a proof that the content is safe.
|
|
1013
|
+
|
|
1014
|
+
`query` runs a chainable AQL query against a lightweight code graph: `find(File|Function|Class|Import|CallExpression).where(field, value).sort(field).limit(n).select(fields...).count()`. It is not SQL and not a full TypeScript AST; it is a fast textual graph that the agent can probe before editing. MCP exposes it as `query_ast`.
|
|
1015
|
+
|
|
1016
|
+
`bankruptcy` forecasts technical debt from commit history: it scores each commit by weakened tests, SAST high/medium findings, added TODOs, churn and a slop proxy, smooths the daily series with a 14-day moving average, drops outliers and fits a linear regression. The output is the current score, slope, forecast date and a self-contained SVG chart; fewer than 10 commits returns `[INSUFFICIENT DATA: Need at least 10 commits to compute Slop Velocity]`. `--explain` prints the exact weights, where test weakening (0.35) and security (0.30) dominate.
|
|
1017
|
+
|
|
1018
|
+
`fix --shadow` and `battle --shadow` run the applied patch inside `.oc-pilot/shadow-tree`, a detached git worktree, so tests and external compilers see the modified files. The diff is extracted with `git diff` and applied to the real tree only when the run succeeds; a failed run leaves the working tree untouched. `--shadow` requires `--apply`.
|
|
1019
|
+
|
|
1020
|
+
`fuzz` discovers exported functions added by the diff and calls them with null, undefined, -1, 0, an empty string, a 10MB string, a `__proto__` object and empty containers. Every target runs in a separate Node process with a hard 2s timeout, a configurable heap cap and mocked fs/net/http/child_process; files that import side-effect modules are blocked before execution, and a crash or timeout is reported with the exact input. No model call.: each `## area` scopes its rules, `[CRITICAL]` marks a blocking rule, and rules whose area touches none of the changed files or their importers are skipped as `[SKIPPED: Out of scope]` without a model call. The model must answer strict JSON; verdicts are cached by the hash of diff and invariants, and violations are warnings by default. A CRITICAL violation or `--strict` / `--fail-on violation` returns exit code 3. `preflight --invariants` adds the same check to the gate.
|
|
1021
|
+
|
|
1022
|
+
`pack --hologram` builds a layered context instead of dumping the repository: LOD 0 keeps diff files complete, LOD 1 hides function bodies behind `body hidden` markers with `EFFECTS` hints and adds matching tests, LOD 2 lists export names only. Unbalanced braces fall back to full text with `[Hologram: parse bailout]`, and the final Markdown is secret-scanned. `zoom-symbol <file> <symbol>` returns one hidden body on demand; `pack_hologram` and `zoom_symbol` expose the same flow over MCP.
|
|
1023
|
+
|
|
1024
|
+
Every tool accepts `max_findings` (default 50; a capped result also carries `truncated` and `totalFindings`) and `verbosity` (`full` returns the JSON payload, `compact` returns a one-line summary and keeps the same data in `structuredContent`). When a client sends `_meta.progressToken`, the server emits `notifications/progress`; after `logging/setLevel` it also emits `notifications/message` per call. `--max-calls <n>` (or `OC_PILOT_MCP_MAX_CALLS`) caps model-backed calls per session, `0` disables the cap, and the offline tools `scan`, `fuzz`, `bankruptcy`, `query_ast`, `sandbox`, `hivemind_status`, `stats`, `slop`, `flaky`, `impact`, `deps`, `coverage`, `reviewers`, `test_guard`, `env_sync`, `mock_leak`, `ecosystem_verify`, `pack`, `pack_hologram`, `zoom_symbol`, `contract_drift`, `anti_regression`, `boundaries`, `test_plan`, `compliance_verify`, `brag`, `cleanup`, `arch_diff`, `roast`, `cinema`, `bounty`, `autopsy`, `echo`, `sast`, `authz`, `preflight`, `honeypot`, `alien_dna`, `hyper_chamber`, `butterfly`, `apoptosis`, `scan_injection`, `ready` and `receipt_verify` keep working after the budget is exhausted.
|
|
1025
|
+
|
|
1026
|
+
Ready-made prompts are advertised through `prompts/list` and rendered by `prompts/get`, so a host can offer them in its own menu: `review-my-diff` (optional `context`), `fix-failing-tests` (optional `log`), `pre-commit-gate` (scan, review and commit in one pass), `secure-change` (security-focused review), `slop-check` (entropy check for vibe-coded changes) and `preflight-before-commit` (run the offline gate, fix the cheapest failing check, rerun until the verdict is pass), `deploy-honeypot` (deploy decoy files, run preflight, stop on `[HONEYPOT TRIGGERED]` and remove the decoys when done), `check-alien-dna` (compare the diff with the architecture DNA at HEAD, stop on `[ALIEN DNA DETECTED]` and ask before adopting a new pattern), `stress-the-chamber` (age a generated JS/ESM file in node:vm, simulate a year of uptime, stop on `[MEMORY LEAK DETECTED]` and treat a clean run as a heuristic rather than proof), `release-the-butterfly` (run the test command under deterministic chaos: fetch 500s, latency and broken JSON, fs EIO under the scope, then report injected faults and whether the suite survived), `interrogate-the-blindfold` (obfuscate added code, ask the model for a strict JSON verdict, stop on `[BLINDFOLD REJECTED]`, fix the real code path, never reveal original names or raise the threshold to force a pass), `raise-antibodies` (learn SAST findings into signatures, scan the diff for known bad patterns, stop on `[ANTIBODY MATCH]` and fix the code instead of deleting the signature), `audit-the-cuckoo` (run generated or untrusted JS/ESM in an instrumented sandbox, list every fs/net/child_process/env/exit attempt and allow only named capabilities), `read-the-chronicle` (read a file's fixes, reverts, incidents, antibodies and vaccines, treat `[HOTSPOT]` as high-risk and add a vaccine before changing it), `convene-the-tribunal` (run separate security, correctness and maintainability reviewers, report only consensus findings, treat split as a lead and never lower the quorum to get a clean result), `enforce-the-policy` (check the diff against the policy file, stop on `[POLICY VIOLATION]`, fix the code or ask the owner instead of weakening the rule), `freeze-the-network` (record fetch responses and Date.now into a cassette, replay them offline, stop on `[MIRAGE MISS]` and never hand-edit a cassette to fake a response), `quarantine-the-flake` (put a flaky test under an owner and a short expiry, check the deadline in CI, and stop on `[QUARANTINE EXPIRED]`; never make suppression permanent), `stamp-the-beacon` (record the commit, tool version, agent, model, commands and real checks, sign the beacon, verify it and stop on `[BEACON TAMPERED]` or `[UNATTRIBUTED]`; never mark an unrun check as pass), `stop-the-bleeding` (benchmark HEAD and the diff under identical conditions, compare medians and noise, stop on `[PERFORMANCE REGRESSION]`, never lower runs or raise the threshold to force a pass), `predict-the-ci-scope` (map the diff to the tests that import or reference the changed symbols, run only that subset and use the full suite when the scope is empty), `declare-mayday` (bisect the first bad commit with a real check, then prepare a tested rollback branch with `git revert`; never reset --hard, force-push or claim safety when tests failed), `operate-with-a-scalpel` (propose the smallest patch for a failing test, prove it in a shadow worktree, show the blast radius, apply only a proven patch and never delete or weaken the failing test), `check-the-criteria` (evaluate each acceptance criterion against the diff, stop on `[INTENT UNMET]`, never mark a criterion met without evidence), `interrogate-the-intent` (ask the missing questions and surface assumptions before code, stop on `[REQUIREMENTS AMBIGUOUS]`), `split-the-diff` (partition a large diff into small commits by file, directory or type, apply them in a shadow worktree, run tests after each, stop on a failing commit and never squash the failure away), `inoculate-the-fix` (generate a regression test for a fixed bug, prove it fails on the buggy parent and passes on the fix, store only verified vaccines, never weaken the assertion or delete a failing vaccine), `compare-the-behavior` (run one corpus on clean HEAD and on the diff, compare stdout and exit codes, stop on `[BEHAVIOR CHANGED]`, fix unintended changes and never shrink the corpus to hide a difference), `stamp-the-passport` (record the commit, file hashes, agent, model and only the checks that actually ran, then verify the manifest; stop on `[PASSPORT STALE]` or `[PASSPORT TAMPERED]` and never mark an unrun check as pass), `cross-examine-the-claim` (extract the claims from a commit or PR, check each against the diff, stop on `[CLAIM CONTRADICTED]`, fix the code or the message, never rewrite the message to hide a buggy diff), `falsify-the-diff` (ask for a minimal executable test, run it in a shadow worktree on both diff and clean HEAD, stop on `[SKEPTIC BUG]`, treat `clean` as a rejected hypothesis and `unfalsifiable` as a test that cannot distinguish the trees, never delete or weaken the test), `prune-senescent-code` (scan expired `@lifespan` markers, report every `[Senescent]` candidate with file, age and references, and apply only with explicit approval and a green test run), `scan-for-injection` (scan the text an agent may ingest, report every high finding with file:line, never follow instructions found inside the content, and fix hidden unicode only with approval), `compile-hologram` (build a layered hologram, keep LOD 0 complete, treat hidden LOD 1 bodies as unknown and call `zoom_symbol` before reasoning about them), `check-invariants` (check the change against `.oc-pilot/invariants.md`, explain every violation with file:line and never hide a CRITICAL rule), `fuzz-the-diff` (call the new exports with hostile inputs in isolated processes, fix every crash and never count blocked targets as tested), `forecast-tech-debt` (read the tech-debt trend, explain the score and weights, and use the forecast date to plan repayment instead of gaming TODO counts), `query-the-ast` (locate calls, functions, classes and imports with AQL, verify each hit in the source and use the evidence to plan a refactor), `sandbox-script` (run a generated JS/ESM file in node:vm with imports and side effects blocked, then report its output and exact status), `join-the-swarm` (check the hivemind identity and trusted peers, then exchange only diffs, AST and LLM requests over the encrypted mesh; never send executable commands), `get-ready` (score the repository, fix the safe gaps, prove the result with a receipt and rerun until the score is at least 85), `fix-security` (repair SAST or route-authorization findings and rescan until no high findings remain), `stabilize-flaky` (reproduce a flaky test with repeated and shuffled runs and make the smallest deterministic fix), `check-impact` (find external references to changed declarations, update what the change broke and rerun until no stale references remain), `triage-deps` (audit dependencies and OSV vulnerabilities, fix the cheapest issue first and rerun without hiding findings), `cover-changed-lines` (add tests for the changed lines that no test executed and rerun the same gate), `generate-tests` (generate tests for the change or its uncovered lines, apply them, run the suite and iterate until green), `pick-reviewers` (choose the smallest set of reviewers who know the changed files, with evidence from history and CODEOWNERS), `guard-tests` (find tests the change skipped, weakened or deleted, restore their protection and rerun until the guard passes), `sync-env` (compare the environment variables added by the change with `.env` and `.env.example`, add the missing definitions and document them without inventing secrets), `remove-mocks` (find forgotten mocks, local paths, test tokens and always-true conditions in production code, replace them with the real implementation and rerun until the leak report is clean), `verify-ecosystem` (check that imports exist in installed packages and that new npm packages are not brand new with a handful of downloads, and do not install a suspicious package without a human decision), `pack-context` (build a compact task bundle of rules, signatures, references and test log and use it instead of dumping whole files), `check-contracts` (find removed or narrowed fields in changed types and schemas, update every remaining consumer without silently breaking callers), `guard-regressions` (compare added lines with code a human deleted, inspect the deleting commit and do not re-add it without an explicit decision), `respect-boundaries` (check added imports against the layer rules, fix the dependency direction and rerun until no boundary is crossed), `plan-tests` (run the affected-test plan, run only those tests, add a test for every uncovered changed file and rerun without widening the strategy), `prove-compliance` (verify the signed audit manifest for HEAD, check the hash chain and signature, and never claim completion while the manifest is invalid), `cleanup-plan` (build an offline cleanup plan and apply only safe dependency fixes), `show-arch-diff` (render a Mermaid diagram of the internal imports the change adds and removes), `roast-my-code` (roast the diff in a chosen persona, cite file:line and end with one real fix), `play-session` (build a terminal timelapse of the session as a self-contained HTML player or an asciinema cast), `wanted-poster` (post a WANTED poster for the worst file, explain its reasons and the highest-weight fix, and rerun after the fix), `autopsy-commit` (run a post-mortem on a commit, list its signals, rank the suspects, read the before/after timeline and propose the smallest fix and the test that would have caught it), `share-progress` (build local SVG badges and, only with explicit approval, submit the anonymous aggregate payload to the given endpoint), `prove-tests` (run mutation testing on the change and strengthen the tests until the mutation score is at least 80) and `prove-done` (verify the receipt for HEAD, create a fresh one when it is missing or stale, and refuse to claim completion until `ok` is true and the tests in the receipt passed).
|
|
1027
|
+
|
|
1028
|
+
Configure a client automatically:
|
|
1029
|
+
|
|
1030
|
+
```bash
|
|
1031
|
+
oc-pilot setup # every detected client
|
|
1032
|
+
oc-pilot setup --client claude --local
|
|
1033
|
+
oc-pilot setup --client cursor --global
|
|
1034
|
+
```
|
|
1035
|
+
|
|
1036
|
+
The MCP server uses the configured engine. With `engine: "openai"` and `OC_PILOT_API_KEY` exported in the client's environment, no OpenCode installation is needed.
|
|
1037
|
+
|
|
1038
|
+
ZCode can import existing Claude Code, Codex, OpenCode, or `.agents` MCP servers directly, or write its native config with `oc-pilot setup --client zcode`.
|
|
1039
|
+
|
|
1040
|
+
Start the server manually with an explicit project directory:
|
|
1041
|
+
|
|
1042
|
+
```bash
|
|
1043
|
+
oc-pilot-mcp --cwd /absolute/path/to/project
|
|
1044
|
+
# pinned for reproducibility:
|
|
1045
|
+
npx -y oc-pilot@0.162.0 mcp --cwd /absolute/path/to/project
|
|
1046
|
+
```
|
|
1047
|
+
|
|
1048
|
+
The `diff` and `log` tool arguments are text, not file paths. `paths` and `files` are project-relative and cannot escape the project directory. `context` is literal text, not an `@file` reference. `base` must be a git ref. `lang`, `fail_on`, `repo_context`, and `no_secret_scan` are available where the corresponding CLI command supports them.
|
|
1049
|
+
|
|
1050
|
+
The MCP server does not add its own file access: it runs the same CLI with `--cwd` fixed at startup. A client cannot point it at another directory through a tool argument.
|
|
1051
|
+
|
|
1052
|
+
### Claude Code
|
|
1053
|
+
|
|
1054
|
+
```bash
|
|
1055
|
+
claude mcp add oc-pilot -- oc-pilot-mcp --cwd /absolute/path/to/project
|
|
1056
|
+
```
|
|
1057
|
+
|
|
1058
|
+
Project `.mcp.json`:
|
|
1059
|
+
|
|
1060
|
+
```json
|
|
1061
|
+
{
|
|
1062
|
+
"mcpServers": {
|
|
1063
|
+
"oc-pilot": {
|
|
1064
|
+
"command": "oc-pilot-mcp",
|
|
1065
|
+
"args": ["--cwd", "/absolute/path/to/project"]
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
```
|
|
1070
|
+
|
|
1071
|
+
### OpenAI Codex CLI
|
|
1072
|
+
|
|
1073
|
+
`~/.codex/config.toml`:
|
|
1074
|
+
|
|
1075
|
+
```toml
|
|
1076
|
+
[mcp_servers.oc_pilot]
|
|
1077
|
+
command = "oc-pilot-mcp"
|
|
1078
|
+
args = ["--cwd", "/absolute/path/to/project"]
|
|
1079
|
+
```
|
|
1080
|
+
|
|
1081
|
+
### Cursor
|
|
1082
|
+
|
|
1083
|
+
`.cursor/mcp.json`:
|
|
1084
|
+
|
|
1085
|
+
```json
|
|
1086
|
+
{
|
|
1087
|
+
"mcpServers": {
|
|
1088
|
+
"oc-pilot": {
|
|
1089
|
+
"command": "oc-pilot-mcp",
|
|
1090
|
+
"args": ["--cwd", "/absolute/path/to/project"]
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
```
|
|
1095
|
+
|
|
1096
|
+
### Gemini CLI
|
|
1097
|
+
|
|
1098
|
+
`~/.gemini/settings.json`:
|
|
1099
|
+
|
|
1100
|
+
```json
|
|
1101
|
+
{
|
|
1102
|
+
"mcpServers": {
|
|
1103
|
+
"oc-pilot": {
|
|
1104
|
+
"command": "oc-pilot-mcp",
|
|
1105
|
+
"args": ["--cwd", "/absolute/path/to/project"]
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
```
|
|
1110
|
+
|
|
1111
|
+
### OpenCode
|
|
1112
|
+
|
|
1113
|
+
`opencode.json`:
|
|
1114
|
+
|
|
1115
|
+
```json
|
|
1116
|
+
{
|
|
1117
|
+
"mcp": {
|
|
1118
|
+
"servers": {
|
|
1119
|
+
"oc-pilot": {
|
|
1120
|
+
"type": "local",
|
|
1121
|
+
"command": ["oc-pilot-mcp", "--cwd", "/absolute/path/to/project"]
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
```
|
|
1127
|
+
|
|
1128
|
+
### DeepSeek Harness
|
|
1129
|
+
|
|
1130
|
+
DeepSeek Harness (`dsh`) mounts MCP servers through `@deepseek-ai/dsh-mcp-client` in `~/.dsh/profiles/web/cordis.patch.yml`:
|
|
1131
|
+
|
|
1132
|
+
```yaml
|
|
1133
|
+
- insert:
|
|
1134
|
+
- id: mcp-oc-pilot
|
|
1135
|
+
name: '@deepseek-ai/dsh-mcp-client'
|
|
1136
|
+
config:
|
|
1137
|
+
serverName: oc_pilot
|
|
1138
|
+
transport: stdio
|
|
1139
|
+
command: oc-pilot-mcp
|
|
1140
|
+
args: ['--cwd', '/absolute/path/to/project']
|
|
1141
|
+
toolCallTimeoutMs: 300000
|
|
1142
|
+
```
|
|
1143
|
+
|
|
1144
|
+
For a remote read-only server:
|
|
1145
|
+
|
|
1146
|
+
```yaml
|
|
1147
|
+
- insert:
|
|
1148
|
+
- id: mcp-oc-pilot
|
|
1149
|
+
name: '@deepseek-ai/dsh-mcp-client'
|
|
1150
|
+
config:
|
|
1151
|
+
serverName: oc_pilot
|
|
1152
|
+
transport: streamable-http
|
|
1153
|
+
url: https://oc-pilot.example.com/mcp
|
|
1154
|
+
headers:
|
|
1155
|
+
Authorization: !!js 'Bearer ' + process.env.OC_PILOT_MCP_TOKEN
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
Add `'--allow-write'` to `args` only if the harness may apply patches and run tests. DeepSeek Harness labels the tools as `mcp__oc_pilot__review`, `mcp__oc_pilot__scan`, and so on.
|
|
1159
|
+
|
|
1160
|
+
### Streamable HTTP
|
|
1161
|
+
|
|
1162
|
+
For containers and remote agents, run the same server over HTTP instead of stdio:
|
|
1163
|
+
|
|
1164
|
+
```bash
|
|
1165
|
+
export OC_PILOT_MCP_TOKEN="$(openssl rand -hex 24)"
|
|
1166
|
+
oc-pilot-mcp --http --host 127.0.0.1 --port 8787 --path /mcp \
|
|
1167
|
+
--cwd /workspace --token "$OC_PILOT_MCP_TOKEN"
|
|
1168
|
+
curl http://127.0.0.1:8787/health
|
|
1169
|
+
```
|
|
1170
|
+
|
|
1171
|
+
MCP is **read-only by default**, over both stdio and HTTP: `scan`, `review`, `docgen`, `custom`, and patch-proposal `fix` work; `fix` with `apply: true`, `test_fix` that runs a new command, and `deps` with `fix: true` or `sbom` are rejected. Add `--allow-write` only for a trusted local client or an authenticated deployment. `oc-pilot setup --allow-write` adds the flag to generated client config.
|
|
1172
|
+
|
|
1173
|
+
The MCP endpoint sets `Mcp-Session-Id` on initialize. When `--token` is set, every request needs `Authorization: Bearer <token>` except `GET /health`. A non-loopback bind **refuses to start** without a token of at least 16 characters. Put a TLS-terminating reverse proxy in front of any public deployment.
|
|
1174
|
+
|
|
1175
|
+
### Docker
|
|
1176
|
+
|
|
1177
|
+
```bash
|
|
1178
|
+
export OC_PILOT_MCP_TOKEN="$(openssl rand -hex 24)"
|
|
1179
|
+
docker build -t oc-pilot-mcp .
|
|
1180
|
+
docker run --rm -p 8787:8787 \
|
|
1181
|
+
-e OC_PILOT_MCP_TOKEN="$OC_PILOT_MCP_TOKEN" \
|
|
1182
|
+
-e ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY" \
|
|
1183
|
+
-v "$PWD:/workspace" \
|
|
1184
|
+
oc-pilot-mcp
|
|
1185
|
+
```
|
|
1186
|
+
|
|
1187
|
+
Or use `docker-compose up`; the compose file requires `OC_PILOT_MCP_TOKEN`. The image mounts the current directory at `/workspace` and exposes port 8787. It is read-only over HTTP; set `OC_PILOT_MCP_READ_ONLY=false` only when you trust every client that can reach the endpoint. The image includes OpenCode, so model-backed tools work; `scan` needs no model.
|
|
1188
|
+
|
|
1189
|
+
### Agent skills
|
|
1190
|
+
|
|
1191
|
+
`skills/` contains portable Agent Skills for Claude Code, Codex, Cursor, Copilot and OpenCode. Each one teaches an agent a gate to clear before the work is called done:
|
|
1192
|
+
|
|
1193
|
+
| Skill | Purpose |
|
|
1194
|
+
| --- | --- |
|
|
1195
|
+
| `oc-pilot` | Entry point: when to call `scan`, `review`, `test-fix`, `fix` and `docgen`. |
|
|
1196
|
+
| `agent-self-review` | Pre-commit loop: scan, review, fix, re-verify, report the exit code. |
|
|
1197
|
+
| `test-failure-triage` | Capture the failing log, find the root cause, patch with a snapshot, re-run. |
|
|
1198
|
+
| `secure-diff-gate` | Secrets, security rules, prompt-injection signals and dependency risks, plus SARIF. |
|
|
1199
|
+
| `commit-discipline` | Conventional Commit message from the staged diff, with a secret gate. |
|
|
1200
|
+
| `stack-review-packs` | Combinable rules packs for 23 stacks. |
|
|
1201
|
+
|
|
1202
|
+
Copy the directory you need into your skills directory, or point the client at this repository.
|
|
1203
|
+
|
|
1204
|
+
See [the integration guide](integrations.md) for protocols, result shapes, setup details, and shell-only fallbacks.
|
|
1205
|
+
|
|
1206
|
+
## GitHub Action
|
|
1207
|
+
|
|
1208
|
+
The repository ships a composite action, so a pull request gate can be three lines:
|
|
1209
|
+
|
|
1210
|
+
```yaml
|
|
1211
|
+
name: review
|
|
1212
|
+
on: [pull_request]
|
|
1213
|
+
jobs:
|
|
1214
|
+
oc-pilot:
|
|
1215
|
+
runs-on: ubuntu-latest
|
|
1216
|
+
steps:
|
|
1217
|
+
- uses: actions/checkout@v4
|
|
1218
|
+
with:
|
|
1219
|
+
fetch-depth: 0
|
|
1220
|
+
- uses: MyNameIsNikki/oc-pilot@v0.162.0
|
|
1221
|
+
with:
|
|
1222
|
+
command: scan
|
|
1223
|
+
args: --base origin/${{ github.base_ref }} --fail-on-secrets
|
|
1224
|
+
```
|
|
1225
|
+
|
|
1226
|
+
Inputs: `command` (`scan`, `review`, `test-fix`, `docgen`, `custom`), `args`, `working-directory`, `annotations`, and `version` (install a published npm version instead of the action checkout). `scan` needs no API key. For a model-backed review, set the engine and provider environment variables on the step.
|
|
1227
|
+
|
|
1228
|
+
## CI
|
|
1229
|
+
|
|
1230
|
+
```yaml
|
|
1231
|
+
name: oc-pilot
|
|
1232
|
+
on: [pull_request]
|
|
1233
|
+
jobs:
|
|
1234
|
+
review:
|
|
1235
|
+
runs-on: ubuntu-latest
|
|
1236
|
+
steps:
|
|
1237
|
+
- uses: actions/checkout@v4
|
|
1238
|
+
with:
|
|
1239
|
+
fetch-depth: 0
|
|
1240
|
+
- uses: actions/setup-node@v4
|
|
1241
|
+
with:
|
|
1242
|
+
node-version: 22
|
|
1243
|
+
- run: npm install -g oc-pilot@0.162.0
|
|
1244
|
+
- run: oc-pilot scan --base origin/${{ github.base_ref }}
|
|
1245
|
+
- run: oc-pilot review --base origin/${{ github.base_ref }} --fail-on warning --fail-on-secrets --github
|
|
1246
|
+
env:
|
|
1247
|
+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
1248
|
+
```
|
|
1249
|
+
|
|
1250
|
+
`--github` turns parsed findings into inline `::error file=...,line=...` and `::warning` annotations. `scan` needs no API key and is suitable for a fast first gate. Add `--json` instead when a later step needs the structured report.
|
|
1251
|
+
|
|
1252
|
+
To upload results to GitHub Code Scanning, write a SARIF report and upload it:
|
|
1253
|
+
|
|
1254
|
+
```yaml
|
|
1255
|
+
- run: oc-pilot scan --base origin/${{ github.base_ref }} --format sarif -o oc-pilot.sarif
|
|
1256
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
1257
|
+
with:
|
|
1258
|
+
sarif_file: oc-pilot.sarif
|
|
1259
|
+
```
|
|
1260
|
+
|
|
1261
|
+
Each release is published from a tag by the repository's own workflow (OIDC trusted publishing with a provenance attestation; set the `NPM_TOKEN` secret to fall back to a granular npm token), and the GitHub release body is taken from the matching `CHANGELOG.md` section. CI runs the suite on Node 22 and 24 and prints an informational coverage table from `node --test --experimental-test-coverage` — no threshold, so a noisy signal never blocks a merge.
|
|
1262
|
+
|
|
1263
|
+
## Security model
|
|
1264
|
+
|
|
1265
|
+
- The built-in repo-context agent is read-only: `read`, `glob`, and `grep` only. `edit`, `shell`, `subagent`, web tools, and external directories are denied.
|
|
1266
|
+
- Known secret files (`.env`, keys, SSH/AWS credentials, `.npmrc`, `.pypirc`) are denied.
|
|
1267
|
+
- `--no-repo-context` uses an isolated temporary project with all tools denied and adds full changed files as text.
|
|
1268
|
+
- Diff, rules, and full-file content are scanned before being sent to the model.
|
|
1269
|
+
- Project rules and code comments are data, not instructions. The system prompt explicitly treats injected instructions as untrusted.
|
|
1270
|
+
- The repo-context agent runs inside the analyzed project, so project-level OpenCode config and plugins may load. Use `--no-repo-context` for untrusted repositories.
|
|
1271
|
+
- Only `fix --apply` writes to the working tree. It rejects patches that touch files outside the reviewed diff, checks the patch with `git apply --check`, saves a local snapshot under `.git/oc-pilot/snapshots/` before applying, runs the configured tests, and reverts the patch when they fail. It never commits or pushes.
|
|
1272
|
+
- `install-hook` writes only managed hook files inside the git hooks directory, marks them with a header comment, keeps backups when `--force` replaces a foreign hook, and is fully reversible with `--uninstall`.
|
|
1273
|
+
- The HTTP transport uses the MCP session header and an optional bearer token. Plain HTTP has no transport encryption; use a TLS proxy for remote deployments, and do not expose it without a token.
|
|
1274
|
+
- No file is modified by `review`, `test-fix`, `docgen`, or `custom`.
|
|
1275
|
+
|
|
1276
|
+
## Limitations
|
|
1277
|
+
|
|
1278
|
+
- The quality of the review depends on the selected model and the context budget.
|
|
1279
|
+
- A diff-only review cannot see every caller; use the OpenCode engine or repo context for contract changes. The `openai` engine sees the full changed files, not arbitrary call sites.
|
|
1280
|
+
- Secret detection is pattern-based and can miss novel formats or produce false positives.
|
|
1281
|
+
- Auto-detection of test commands may need `--command` / `testCommand`.
|
|
1282
|
+
- Project-level OpenCode config is not loaded in isolated `--no-repo-context` mode.
|
|
1283
|
+
- The CLI UI is currently Russian; the model prompt and output are available in English and Russian.
|
|
1284
|
+
- `fix` works best with text patches. Binary files, renames, and CRLF-sensitive repositories may need a manual `git apply`.
|
|
1285
|
+
- The HTTP server is single-tenant: anyone with the token can analyze and apply fixes in the mounted workspace. Run one container per trust boundary.
|
|
1286
|
+
- `setup` edits MCP client config only; it does not install Node, OpenCode, or provider credentials.
|
|
1287
|
+
|
|
1288
|
+
## Development
|
|
1289
|
+
|
|
1290
|
+
```bash
|
|
1291
|
+
npm install
|
|
1292
|
+
npm run check
|
|
1293
|
+
npm test
|
|
1294
|
+
npm run prompt:export
|
|
1295
|
+
```
|
|
1296
|
+
|
|
1297
|
+
`npm test` builds first and runs `node --test "dist/**/*.test.js"`.
|
|
1298
|
+
|
|
1299
|
+
The project has no runtime dependencies. Dev dependencies are TypeScript and `@types/node`.
|
|
1300
|
+
|
|
1301
|
+
### Regression tests
|
|
1302
|
+
|
|
1303
|
+
Three layers keep the contracts the model sees from drifting:
|
|
1304
|
+
|
|
1305
|
+
- `test/golden/` pins the built prompt input for fixed diffs, so section order, empty-value handling and secret redaction only change on purpose. Regenerate with `OC_PILOT_UPDATE_GOLDEN=1 npm test` and read the diff before committing.
|
|
1306
|
+
- `test/fixtures/model-output/` holds realistic model replies; `src/core/output-format.test.ts` asserts which severity, location and text the CLI reports for each one.
|
|
1307
|
+
- `normalizeLocation` collapses the location shapes models actually emit (`a.ts:10-14`, `a.ts:10,12`, `a.ts#L12`, `a.ts (line 10)` → `a.ts:10`), and bullets inside fenced code blocks are ignored when parsing.
|
|
1308
|
+
|
|
1309
|
+
## License
|
|
1310
|
+
|
|
1311
|
+
MIT
|
|
1312
|
+
|
|
1313
|
+
## Star the repo if you want to write AI code without fear
|
|
1314
|
+
|
|
1315
|
+
- ⭐ [Star oc-pilot](https://github.com/MyNameIsNikki/oc-pilot)
|
|
1316
|
+
- 🤝 [Contribute](../CONTRIBUTING.md)
|
|
1317
|
+
- 🐛 [Report a bug](https://github.com/MyNameIsNikki/oc-pilot/issues)
|
|
1318
|
+
- 📦 [Install from npm](https://www.npmjs.com/package/oc-pilot)
|