@agentskit/code-review 0.1.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/.doc-bridge/capabilities.json +34 -0
  2. package/.doc-bridge/index.json +94 -0
  3. package/.pre-commit-hooks.yaml +9 -0
  4. package/AGENTS.md +20 -0
  5. package/CHANGELOG.md +85 -0
  6. package/CONTRIBUTING.md +45 -0
  7. package/README.md +238 -33
  8. package/ROADMAP.md +20 -0
  9. package/SECURITY.md +16 -0
  10. package/action.yml +120 -0
  11. package/dist/agents/code-review/agent.js +453 -76
  12. package/dist/agents/code-review/agent.js.map +1 -1
  13. package/dist/agents/code-review/lenses.js +17 -1
  14. package/dist/agents/code-review/lenses.js.map +1 -1
  15. package/dist/agents/code-review/reporters.js +83 -7
  16. package/dist/agents/code-review/reporters.js.map +1 -1
  17. package/dist/agents/code-review/sources.js +324 -73
  18. package/dist/agents/code-review/sources.js.map +1 -1
  19. package/dist/src/acp-cli-adapter.js +127 -0
  20. package/dist/src/acp-cli-adapter.js.map +1 -0
  21. package/dist/src/batch-coverage.js +111 -0
  22. package/dist/src/batch-coverage.js.map +1 -0
  23. package/dist/src/claude-code-adapter.js +44 -60
  24. package/dist/src/claude-code-adapter.js.map +1 -1
  25. package/dist/src/cli.js +347 -50
  26. package/dist/src/cli.js.map +1 -1
  27. package/dist/src/codex-adapter.js +114 -69
  28. package/dist/src/codex-adapter.js.map +1 -1
  29. package/dist/src/github-review-state.js +134 -0
  30. package/dist/src/github-review-state.js.map +1 -0
  31. package/dist/src/grok-cli-adapter.js +27 -0
  32. package/dist/src/grok-cli-adapter.js.map +1 -0
  33. package/dist/src/headless-cli-adapter.js +78 -0
  34. package/dist/src/headless-cli-adapter.js.map +1 -0
  35. package/dist/src/local-cli-process.js +328 -0
  36. package/dist/src/local-cli-process.js.map +1 -0
  37. package/dist/src/local-cli-timeout.js +14 -0
  38. package/dist/src/local-cli-timeout.js.map +1 -0
  39. package/dist/src/ollama-adapter.js +155 -0
  40. package/dist/src/ollama-adapter.js.map +1 -0
  41. package/dist/src/opencode-cli-adapter.js +57 -0
  42. package/dist/src/opencode-cli-adapter.js.map +1 -0
  43. package/dist/src/provider-circuit-breaker.js +52 -0
  44. package/dist/src/provider-circuit-breaker.js.map +1 -0
  45. package/dist/src/provider-registry.js +168 -0
  46. package/dist/src/provider-registry.js.map +1 -0
  47. package/dist/src/review-config.js +145 -0
  48. package/dist/src/review-config.js.map +1 -0
  49. package/doc-bridge.config.json +116 -0
  50. package/docs/OPERATIONS.md +358 -0
  51. package/docs/assets/agentskit-mark.svg +10 -0
  52. package/docs/assets/code-review-terminal.png +0 -0
  53. package/docs/continuous-improvement.md +35 -0
  54. package/docs/for-agents/code-review-cli.md +70 -0
  55. package/docs/for-agents/index.md +5 -0
  56. package/docs/plans/ecosystem-doc-quality-code-review.md +61 -0
  57. package/docs/provider-compatibility.json +35 -0
  58. package/ecosystem-claims.json +187 -0
  59. package/ecosystem.json +277 -0
  60. package/examples/pull-request.yml +29 -0
  61. package/llms-full.txt +1049 -0
  62. package/llms.txt +24 -0
  63. package/package.json +53 -7
  64. package/scripts/generate-llms-full.mjs +68 -0
  65. package/scripts/run-cycle-benchmark.mjs +64 -0
  66. package/test/cli-smoke.test.mjs +507 -0
  67. package/test/continuous-improvement.test.mjs +20 -0
  68. package/test/documentation.test.mjs +238 -0
  69. package/test/release-workflow.test.mjs +31 -0
  70. package/dist/agents/code-review/agent.d.ts +0 -115
  71. package/dist/agents/code-review/lenses.d.ts +0 -10
  72. package/dist/agents/code-review/reporters.d.ts +0 -31
  73. package/dist/agents/code-review/sources.d.ts +0 -27
  74. package/dist/src/claude-code-adapter.d.ts +0 -4
  75. package/dist/src/cli.d.ts +0 -2
  76. package/dist/src/codex-adapter.d.ts +0 -4
@@ -0,0 +1,358 @@
1
+ # Code Review operations guide
2
+
3
+ This guide is the repository-native reference for running AgentsKit Code Review locally and in CI. The CLI is the source of truth for flags; run `agentskit-review --help` against the version or commit you use.
4
+
5
+ ## Provider and credential choices
6
+
7
+ | Provider class | Examples | Secret or login | Network boundary |
8
+ |---|---|---|---|
9
+ | Logged-in local CLI | `codex-cli`, `claude-cli`, `grok-cli`, `opencode-cli` | Existing local login | Provider CLI policy |
10
+ | Hosted API | `openai`, `anthropic`, `gemini`, `mistral`, `groq` | Repository/org secret | Selected code reaches provider |
11
+ | Local model | `ollama` | Usually none | Host or runner network only |
12
+ | Gateway | `openrouter`, custom `--base-url` | Gateway secret | Gateway policy and routing |
13
+
14
+ Credential precedence is `--api-key`, `LLM_API_KEY`, then `<PROVIDER>_API_KEY`. Prefer environment variables and GitHub secrets: process arguments may be visible to other processes or captured by diagnostics. The composite Action forwards its secret through `LLM_API_KEY` and never adds it to CLI arguments.
15
+
16
+ Do not run hosted review on code whose policy forbids external processing. A local model reduces external disclosure but does not remove the need to secure the runner, logs, cache, and generated SARIF.
17
+
18
+ ## Provider registry and doctor
19
+
20
+ Provider IDs are versioned registry entries. `grok` is the xAI API adapter, while `grok-cli` and `opencode-cli` are stable local CLI providers. `--list-providers` prints registry metadata and dynamically discovered API factories, including each support level (`stable`, `experimental`, or `unsupported`), transport, and model requirement.
21
+
22
+ Use the offline doctor before execution:
23
+
24
+ ```sh
25
+ npx --yes github:AgentsKit-io/code-review doctor --provider codex-cli
26
+ npx --yes github:AgentsKit-io/code-review doctor --provider openai --model gpt-4o --json
27
+ ```
28
+
29
+ It checks the named executable and version, transport, model requirement, configuration mode, and credential presence without making a model request. API keys are represented only as `configured` or `missing`; they are never printed. Local CLI credentials are represented as login-managed because login storage is provider-specific. `doctor --live` is the explicit provider smoke-test path; normal Codex reviews run the same bounded smoke check before fan-out. Unknown local CLI versions warn during local runs and fail in CI. Doctor exits `0` when checks pass, `1` when a provider check fails, and `2` for invalid usage.
30
+
31
+ ## First local setup
32
+
33
+ ```sh
34
+ git clone https://github.com/AgentsKit-io/code-review.git
35
+ cd code-review
36
+ npm install
37
+ npm run check
38
+ npx --yes github:AgentsKit-io/code-review --provider opencode-cli --transport acp --model openai/gpt-4o --no-fail
39
+ ```
40
+
41
+ The last command requires an installed and authenticated OpenCode CLI. For a
42
+ credential-free verification, `npm run check` uses only the committed offline
43
+ fixtures. Precedence is explicit CLI flags, then the repository's
44
+ `.agentskit-review.json` policy, then safe defaults; the project file never
45
+ selects a trusted execution mode or carries credentials.
46
+
47
+ ## Grok Build CLI via ACP
48
+
49
+ `grok-cli` is stable and uses `--transport acp` by default. It
50
+ starts `grok agent stdio --no-auto-update`, performs the ACP initialize,
51
+ authentication (when advertised), session, prompt, update, shutdown, and exit
52
+ sequence, then emits one `submit_findings` tool call. The worker accepts only a
53
+ `schemaVersion: 1` envelope with valid findings; malformed output gets one
54
+ bounded retry.
55
+
56
+ In the default `isolated` mode, provide `XAI_API_KEY` through the environment
57
+ or `--api-key`; the selected key is copied only into the temporary worker
58
+ environment. Existing `grok login` state is available only with explicit
59
+ local-only `--mode trusted-local`. Filesystem writes, terminal, MCP, plugin,
60
+ and subagent requests are denied, and the worker never uses the checkout as
61
+ its working directory. `doctor --provider grok-cli` checks executable/version
62
+ availability without making a model request. Headless mode is documented below
63
+ and must be selected explicitly.
64
+
65
+ ## OpenCode CLI via ACP
66
+
67
+ `opencode-cli` is stable and uses `--transport acp` by default.
68
+ It starts `opencode acp`, performs the ACP initialize, session, prompt, update,
69
+ shutdown, and exit sequence, then emits one validated `submit_findings` tool
70
+ call. When `--model` is provided it is passed as OpenCode's `--model` option.
71
+ The worker allows no filesystem writes, terminal, MCP, plugin, or subagent
72
+ requests and retries malformed output once.
73
+
74
+ In the default `isolated` mode, provide `OPENCODE_API_KEY` through the
75
+ environment or `--api-key`; the selected key is copied only into the temporary
76
+ worker environment. Existing OpenCode login/configuration state is available
77
+ only with explicit local-only `--mode trusted-local`. The CLI does not install
78
+ OpenCode automatically.
79
+ `doctor --provider opencode-cli` checks executable/version availability without
80
+ making a model request. Headless mode is documented below and must be selected
81
+ explicitly.
82
+
83
+ ## Grok and OpenCode headless transport
84
+
85
+ Headless mode is explicit with `--transport headless`. Grok uses
86
+ `grok --no-auto-update -p <prompt> --output-format json`; OpenCode uses
87
+ `opencode run --format json [--model provider/model] <prompt>`. Their output
88
+ framings are parsed separately and normalized to the same strict
89
+ `schemaVersion: 1` envelope. Surrounding logs are bounded and tolerated only
90
+ when the validated envelope can still be recovered.
91
+
92
+ `--transport auto` is a local convenience for these two providers:
93
+ it tries ACP first, reports the reason on stderr, then tries the provider's
94
+ headless command. It is rejected in CI so a pipeline cannot silently change
95
+ transport. Both paths use the same isolated worker timeout, output cap,
96
+ cancellation, temporary working directory, selected-credential injection, and
97
+ redacted diagnostics. Neither path installs a provider CLI automatically.
98
+
99
+ The executable compatibility source of truth is
100
+ [`provider-compatibility.json`](./provider-compatibility.json). It lists the
101
+ stable providers, every supported transport, required lenses, minimum version,
102
+ and the offline fixture that proves each cell. A provider remains experimental
103
+ until its registry entry, matrix, fixtures, and doctor checks are all green.
104
+
105
+ ## pre-commit integration
106
+
107
+ The root `.pre-commit-hooks.yaml` exposes `agentskit-review` as a Node hook. It uses `pass_filenames: false` because the CLI reviews a Git diff, explicit paths, a pull request, or stdin rather than interpreting positional filenames. It is confined to the `manual` stage by default so cloning the hook does not silently add model calls to every commit.
108
+
109
+ Consumer configuration must select a provider through `args`. Keep credentials in the provider login or environment; never place API keys in `.pre-commit-config.yaml`. Before overriding the hook to `stages: [pre-push]`, decide whether findings are advisory, set a file budget, and confirm that provider latency and data handling are appropriate for every contributor.
110
+
111
+ The default diff base remains `origin/main`. A pre-commit invocation does not mean the input is limited to the Git staging area. Set `--base` explicitly when the repository uses another integration branch.
112
+
113
+ ## Versioned review configuration
114
+
115
+ Use a strict `.agentskit-review.json` at the repository root for review policy.
116
+ It requires `configVersion: 1` and supports a `full` or `fast` profile. The
117
+ fast profile reviews correctness, security, and tests in one bounded batch with
118
+ one vote and no retry. The config also supports lens policy (`enabled` and
119
+ `required` per built-in lens), votes, retries, thresholds, file/byte/call,
120
+ concurrency and global-deadline budgets, conventions, and context selection. All built-in lenses
121
+ are enabled by default; correctness, security, and tests are required.
122
+ The shared local worker also accepts bounded `timeoutMs` and `maxOutputBytes`
123
+ settings; absolute ceilings are always enforced.
124
+
125
+ Flags override file values. The file cannot contain credentials or executable
126
+ plugins. Provider, model, transport, trust mode, redaction, permissions, and
127
+ other execution inputs are rejected when supplied by the project config in CI.
128
+ An intentionally incomplete profile must say `incompleteProfile: true` and be
129
+ run locally with `--allow-incomplete`; it is rejected in CI and cannot become an
130
+ approval. Malformed, unknown, or unsafe configuration exits `2` before a model
131
+ request and diagnostics do not print config values.
132
+
133
+ Keep policy-only configuration in the file. Use trusted workflow flags or the
134
+ runner environment for provider selection, credentials, and execution mode.
135
+
136
+ `prompt` is the default context mode. To review an explicit repository snapshot,
137
+ set `context.mode` to `isolated-snapshot` and provide repository-relative
138
+ patterns such as `src/**` or `!src/generated/**`. Sensitive directories/files,
139
+ symlink escapes, binaries, and over-limit inputs are excluded and shown as
140
+ `UNREVIEWED`. The default snapshot ceiling is 100 files/5 MiB; the absolute
141
+ ceiling is 500 files/25 MiB. Prompt files default to 256 KiB with a 1 MiB
142
+ absolute per-file ceiling.
143
+
144
+ Remote and unknown provider boundaries receive high-confidence credential
145
+ redaction while preserving file and line context. `--allow-unredacted` is a
146
+ local-only escape hatch and is rejected in CI; never use it for untrusted code.
147
+
148
+ ## Local Ollama review
149
+
150
+ Ollama serves its local API at `http://localhost:11434` by default. Verify the service without sending repository content:
151
+
152
+ ```sh
153
+ curl --fail --silent http://localhost:11434/api/tags >/dev/null
154
+ ```
155
+
156
+ Choose a tool-capable model that fits the host; tool calling is required because every lens submits a structured result. `qwen2.5-coder:7b` is a practical starting point for machines that cannot run the larger `qwen3-coder:30b`; model quality, context capacity, latency, and memory requirements vary. Pulling a model downloads several gigabytes and does not start a review:
157
+
158
+ ```sh
159
+ ollama pull qwen2.5-coder:7b
160
+ ```
161
+
162
+ Start with a bounded, advisory branch review:
163
+
164
+ ```sh
165
+ npx --yes github:AgentsKit-io/code-review \
166
+ --provider ollama \
167
+ --model qwen2.5-coder:7b \
168
+ --base main \
169
+ --base-url http://localhost:11434 \
170
+ --max-files 10 \
171
+ --concurrency 1 \
172
+ --no-fail
173
+ ```
174
+
175
+ The default source is the committed Git diff from `--base` to `HEAD`. It does not mean “only staged files,” even when invoked by a Git hook. Use `--paths` when complete files are the intended source. Avoid piping a unified Git patch through `--stdin`: stdin is treated as one source file rather than parsed into per-file changed ranges.
176
+
177
+ Seven primary lenses plus adversarial votes can be expensive for a local model, and each structured result can require more than one model turn. Begin with `--max-files 10`, `--concurrency 1`, and the default three votes. Reduce the file set before reducing verification depth. `--no-fail` makes surviving findings advisory; it does not hide an unavailable model, malformed response, unreadable source, or failed lens coverage.
178
+
179
+ For a self-hosted runner, bind Ollama only to the network interfaces required by the job, isolate the runner per repository trust boundary, and protect job logs and artifacts. Do not set a hosted gateway as `--base-url` and describe the run as local. Any optional telemetry or observability exporter creates a separate network boundary that must be approved explicitly.
180
+
181
+ Troubleshooting:
182
+
183
+ - **Connection refused:** start Ollama and repeat the `/api/tags` health check.
184
+ - **Model not found:** run `ollama pull <exact-model-id>` and pass the same id to `--model`.
185
+ - **Slow or out-of-memory:** choose a smaller model, reduce `--max-files`, and keep `--concurrency 1`.
186
+ - **Context overflow:** review narrower paths or a smaller branch diff; unreviewed files must remain visibly outside the result.
187
+ - **No findings with exit 0:** inspect the summary and successful/failed lens counts; advisory output is not proof that every file was reviewed.
188
+
189
+ ## GitHub Action permissions
190
+
191
+ The copy-ready workflow in [`examples/pull-request.yml`](../examples/pull-request.yml) requires:
192
+
193
+ ```yaml
194
+ permissions:
195
+ contents: read
196
+ pull-requests: write
197
+ ```
198
+
199
+ `contents: read` loads the PR source. `pull-requests: write` posts the batched review. Do not grant repository administration, package write, or workflow write. Fork PRs do not receive normal repository secrets; do not switch to `pull_request_target` merely to expose a model key, because that can execute or process untrusted contributions with privileged context.
200
+
201
+ The composite Action defaults to 17 files, 7 findings per file, 1,000 provider calls, and a 10-minute global deadline. `codex-cli` is accepted only with `mode: trusted-local` on a pre-authenticated self-hosted runner; use an API provider with a secret on GitHub-hosted runners.
202
+
203
+ Use environment protection or organization secrets for sensitive providers. Rotate a secret after suspected exposure and review provider usage plus GitHub audit logs.
204
+
205
+ When `--post` is used with `--pr`, the reviewer stores a hidden SHA and policy
206
+ fingerprint marker in the summary comment. Re-running the same head SHA with
207
+ the same policy skips provider calls and updates no comments. A new SHA uses
208
+ GitHub compare scope only when the previous marked SHA is an ancestor; a
209
+ missing marker, force-push, or changed fingerprint falls back to the full PR
210
+ file list. Fork PRs are reported as `SKIPPED` with exit `2` on this workflow
211
+ boundary; do not switch to `pull_request_target` to expose secrets. Summary
212
+ comments are reconciled by marker, while POST/PATCH failures remain visible for
213
+ manual retry.
214
+
215
+ ## Advisory and blocking behavior
216
+
217
+ The Action is advisory by default: `fail-on-block: 'false'` adds `--no-fail`. Findings still post, but surviving blocker/high findings do not fail the job. `--no-fail` never suppresses provider, source, reporter, or review-execution errors. For enforcement:
218
+
219
+ ```yaml
220
+ with:
221
+ block: high
222
+ fail-on-block: 'true'
223
+ ```
224
+
225
+ Then require the workflow check in branch protection. CLI exit codes are:
226
+
227
+ | Exit | Meaning | Operator action |
228
+ |---:|---|---|
229
+ | `0` | Review completed; no blocking finding, or advisory mode | Inspect posted/report output |
230
+ | `1` | A finding at or above `--block` survived | Fix, dismiss with evidence, or change policy intentionally |
231
+ | `2` | Configuration, provider, source, or reporter failure | Inspect stderr; do not interpret as a clean review |
232
+
233
+ A model response that is malformed may drop one lens while other lenses continue; progress output and the final summary report successful and failed primary-lens counts. If any reviewable file cannot be ingested or has zero successful primary lenses, the pipeline stops before reporters run and exits `2`, including in advisory mode. Treat missing output or exit `2` as unavailable review, not approval.
234
+
235
+ Use `--plan --json` (or `--dry-run`) to run the source and budget preflight without a model request. The plan reports profile, batching, files, bytes, enabled and required lenses, votes, retries, concurrency, deadline, estimated provider calls, every `UNREVIEWED` path with its reason, and concrete reductions when a limit would be exceeded. Estimates are `bounded` when `thresholds.maxPerFile` is set and `best-effort` otherwise, because model output volume is variable. The preflight refuses before the provider starts; `maxCalls` is capped at 1000 and unlimited mode is not supported. A required-lens failure is `INCOMPLETE` and exits `2`, including with `--no-fail`.
236
+
237
+ For a PR that exceeds one review budget, use deterministic coverage batches instead of accepting an incomplete review. Run `--plan --json --batch-size <n> --batch-manifest <private-file>` to create a private manifest keyed by repository, PR, head SHA, and policy fingerprint. Each `--batch-index <n> --result <private-file>` run is deliberately incomplete by itself and rejects `--post`; its result artifact carries the same identity plus its exact file manifest. `--consolidate-manifest <manifest> --artifacts <comma-list> --result <private-file>` rejects a missing, duplicate, stale, mismatched, failed, deadline-exceeded, or required-lens-incomplete artifact. Only that consolidated artifact is accepted by `--publish-result <file> --pr owner/repo#N --post`, which rechecks current SHA and policy before creating the one GitHub review. Delete or replace the private state when the PR SHA or policy changes; never upload it as a CI artifact or commit it.
238
+
239
+ ## Cost and latency controls
240
+
241
+ Seven lenses fan out over selected files; candidate findings then receive adversarial votes. The primary controls are:
242
+
243
+ - `--max-files`: positive hard file budget;
244
+ - `--max-calls`: bounded provider-call budget (absolute ceiling 1000);
245
+ - `--max-findings-per-file`: positive verified-finding budget per file;
246
+ - `--votes`: verification depth and cost;
247
+ - `--concurrency`: simultaneous model/subprocess calls (default 1 for CLI providers, 4 for API providers);
248
+ - `--profile fast`: one bounded correctness/security/tests batch per file, one vote, and no retry;
249
+ - `--deadline-ms`: hard global deadline; active local workers receive the abort signal and queued calls do not start;
250
+ - `--health-check`: bounded provider smoke check before fan-out (`auto` or `off`);
251
+ - `--paths` or workflow path filters: narrow scope;
252
+ - `--min-severity` and `--min-confidence`: output noise, not input-token cost.
253
+
254
+ Start advisory with a small file budget, measure provider usage, and raise depth only where it improves signal. Never present an unmeasured cost estimate as a guaranteed price.
255
+
256
+ Every completed report includes provider-call evidence: calls started, failed,
257
+ skipped by the circuit/budget, elapsed time, deadline status, and circuit state.
258
+ The circuit opens immediately for authentication, timeout, or cancellation
259
+ failures and after repeated transient provider failures. Incomplete evidence is
260
+ never an approval.
261
+
262
+ ## SARIF
263
+
264
+ `--sarif out.sarif` writes SARIF 2.1.0 alongside Markdown. Each surviving finding includes a `code-review/<category>` rule, severity level, message, file, and line. Uploading SARIF to GitHub code scanning requires the separate `security-events: write` permission and `github/codeql-action/upload-sarif`; the bundled Action does not request that permission or upload automatically.
265
+
266
+ SARIF can contain source paths and model-generated explanations. Apply the same retention and access policy as CI logs.
267
+
268
+ ### Route findings through reviewdog
269
+
270
+ [reviewdog](https://github.com/reviewdog/reviewdog) accepts SARIF directly, so no AgentsKit-specific reporter or converter is required. This complete pull-request job installs reviewdog, fetches the base history, generates the report in advisory mode, and lets reviewdog own diff filtering, annotations, and the final CI threshold:
271
+
272
+ ```yaml
273
+ name: AgentsKit reviewdog
274
+ on: pull_request
275
+
276
+ permissions:
277
+ contents: read
278
+ pull-requests: write
279
+
280
+ jobs:
281
+ review:
282
+ runs-on: ubuntu-latest
283
+ steps:
284
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
285
+ with:
286
+ fetch-depth: 0
287
+ - uses: reviewdog/action-setup@d8edfce3dd5e1ec6978745e801f9c50b5ef80252 # v1.4.0
288
+ with:
289
+ reviewdog_version: v0.21.0
290
+ - name: Review changed code
291
+ env:
292
+ BASE_REF: ${{ github.base_ref }}
293
+ LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
294
+ REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
295
+ run: |
296
+ REPORT_FILE="$(mktemp)"
297
+ trap 'rm -f "${REPORT_FILE}"' EXIT
298
+ npx --yes github:AgentsKit-io/code-review#3dfd7427640148281454d52846d369e5ddf85b11 \
299
+ --provider openai --model gpt-4o --base "origin/${BASE_REF}" \
300
+ --sarif "${REPORT_FILE}" --no-fail &&
301
+ reviewdog -f=sarif -name=agentskit-review \
302
+ -reporter=github-pr-review -filter-mode=added -fail-level=error \
303
+ < "${REPORT_FILE}"
304
+ ```
305
+
306
+ The hosted-runner example uses an API provider because local CLI providers require their executable and an existing authenticated session. Replace the provider and model with your approved adapter. The base comes from the pull-request event rather than assuming `main`, and `fetch-depth: 0` makes its remote-tracking ref available to `git diff`. Pass the provider secret through `LLM_API_KEY`, pass the workflow token through `REVIEWDOG_GITHUB_API_TOKEN`, and grant only `contents: read` plus `pull-requests: write`.
307
+
308
+ The temporary report and `&&` prevent reviewdog from reading stale output when the producer fails. Keep `--no-fail` on the producer so reviewdog receives the complete report when review succeeds; `-fail-level=error` then makes SARIF `error` findings fail the reviewdog step. AgentsKit maps blocker and high findings to SARIF `error`, medium to `warning`, and nit to `note`.
309
+
310
+ The default `added` filter limits inline feedback to changed lines. Choose a broader reviewdog filter deliberately; broader modes can move findings outside the PR diff into checks, annotations, or console output depending on the reporter. Pin both Code Review and reviewdog to reviewed immutable versions in enforcement workflows.
311
+
312
+ ## Failure scenarios
313
+
314
+ - **Unknown provider or missing model:** validate with `--list-providers`; API/local-server adapters require `--model`.
315
+ - **Authentication failure:** verify only the provider-specific secret/login and avoid printing its value. A terminal authentication failure stops remaining lenses immediately and the review exits incomplete rather than spending one failed call per lens.
316
+ - **Rate limit or timeout:** Codex calls stop after 300 seconds by default; other local CLI calls use 120 seconds. Set `AGENTSKIT_REVIEW_SUBPROCESS_TIMEOUT_MS` to a positive millisecond value when needed, reduce concurrency/file budget, or use an approved gateway; retry only when provider policy makes the operation safe.
317
+ - **No PR comments:** confirm `pull-requests: write`, token availability, and fork restrictions. The Markdown report still appears in logs.
318
+ - **Inline comment rejected:** the reporter falls back to a non-approving comment for GitHub 422 restrictions.
319
+ - **Large diff:** GitHub PR reviews cap metadata at 500 files, select only the configured file budget before downloading contents, and stop content downloads at the byte budget. Set `--max-files`/`--max-calls` or split review by paths; truncated or unreviewed files must not be described as reviewed.
320
+ - **Ollama timeout:** Requests stop after 30 seconds by default. Use a smaller scope or a responsive local model when the request is aborted; a stalled model must not hold the review indefinitely.
321
+ - **Provider unavailable:** fail or mark the check unavailable according to team policy; never silently convert it to approval.
322
+
323
+ ## Releases and maturity
324
+
325
+ The current package is `0.4.0` and the project is pre-v1:
326
+
327
+ - GitHub-source CLI commands can pin a commit SHA after `github:AgentsKit-io/code-review#<sha>`;
328
+ - Actions should pin `@v0.4.0` or a full commit SHA;
329
+ - a moving `@main` reference is suitable only when that mutability is accepted;
330
+ - the future `@v1` Action tag remains a separate stability milestone.
331
+
332
+ Release work updates [`CHANGELOG.md`](../CHANGELOG.md), [`ROADMAP.md`](../ROADMAP.md), package version, immutable tag guidance, and signed/provenance evidence when available. Run `npm run check` and `npm pack --dry-run` before publishing.
333
+
334
+ ### Automated npm publishing
335
+
336
+ Changesets is the release source of truth. A product-affecting pull request adds a small Markdown file in `.changeset/` that names `@agentskit/code-review`, selects `patch`, `minor`, or `major`, and explains the user-visible change. Documentation-only, test-only, and CI-only pull requests add `npx changeset --empty` when they intentionally require no release.
337
+
338
+ Every merge to `main` runs `.github/workflows/release.yml`. When pending non-empty changesets exist, it creates or updates the `chore: version packages` pull request on the trusted `changeset-release/main` branch. That pull request contains the version bump, generated `CHANGELOG.md` entry, and consumed changesets. Merging this version pull request is the only automatic publish trigger. This extra review boundary is intentional: ordinary feature merges collect safely, while the versioned release has a concrete, reviewable diff. A maintainer-authored release PR may use the explicitly allowlisted `codex/release-0.4.1` recovery branch when repository rules prevent the bot PR from receiving required checks.
339
+
340
+ `.github/workflows/publish.yml` runs only after that trusted version pull request is merged. It checks out that exact merge commit, verifies the package version and a clean release payload with `npm run check` and `npm pack --dry-run`, publishes `@agentskit/code-review` using [npm Trusted Publishing](https://docs.npmjs.com/trusted-publishers/) (OIDC), then creates the immutable `v<version>` GitHub Release. If npm already has the exact version, it skips only the publish step and still creates a missing GitHub release; normal PR-triggered runs cannot publish a duplicate. No long-lived `NPM_TOKEN`, npm access token, or personal GitHub token is stored in this repository. GitHub's built-in workflow token is used only to create the version PR and GitHub release.
341
+
342
+ Before the first release, configure the npm package's Trusted Publisher for GitHub Actions with:
343
+
344
+ - Organization: `AgentsKit-io`
345
+ - Repository: `code-review`
346
+ - Workflow filename: `publish.yml`
347
+
348
+ Enable GitHub Actions permission to create pull requests only when the repository setting requires it for Changesets. Keep branch protection configured to require human review: the workflow never approves or merges its own version PR. This repository-wide setting can also permit workflow approvals, so restrict `pull-requests: write` to the version workflow and do not count workflow approvals toward the required human review. The npm configuration is a one-time external prerequisite; the GitHub workflow cannot create it. Do not run `npm publish` locally.
349
+
350
+ The publish workflow has no manual dispatch path: only a merged, title-matched Changesets version pull request from an explicitly allowlisted release branch can publish. If a release is interrupted, repair it through a new reviewed version PR rather than granting an arbitrary ref publishing authority.
351
+
352
+ ## Contribution and security
353
+
354
+ Start with [`CONTRIBUTING.md`](../CONTRIBUTING.md). Provider integrations must preserve the AgentsKit adapter contract and keep secrets out of arguments/logs. Review lenses need reproducible evidence and false-positive fixtures. Report vulnerabilities privately through [`SECURITY.md`](../SECURITY.md).
355
+
356
+ For adjacent work, use [AgentsKit](https://www.agentskit.io/docs) for runtime and adapters, [Registry](https://registry.agentskit.io/docs) for the vendored agent, [AgentsKit Chat](https://chat.agentskit.io/docs) when review belongs inside a conversational application, [Playbook](https://playbook.agentskit.io/docs) for engineering patterns, [Doc Bridge](https://agentskit-io.github.io/doc-bridge/) for documentation ownership handoffs, and [AKOS](https://akos.agentskit.io/docs) for enterprise orchestration and production governance.
357
+
358
+ Machine readers should start with [`llms.txt`](../llms.txt), escalate to [`llms-full.txt`](../llms-full.txt) only when the complete corpus is required, and use [`docs/for-agents`](./for-agents/index.md) before changing an owned module.
@@ -0,0 +1,10 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 72 64" fill="none">
2
+ <g stroke="#0f766e" stroke-width="2" stroke-linecap="round">
3
+ <line x1="12" y1="52" x2="36" y2="12"/>
4
+ <line x1="36" y1="12" x2="60" y2="52"/>
5
+ <line x1="12" y1="52" x2="60" y2="52"/>
6
+ </g>
7
+ <circle cx="36" cy="12" r="6" fill="#0f766e"/>
8
+ <circle cx="12" cy="52" r="6" fill="#0f766e"/>
9
+ <circle cx="60" cy="52" r="6" fill="#0f766e"/>
10
+ </svg>
@@ -0,0 +1,35 @@
1
+ # Continuous improvement cycles
2
+
3
+ Each cycle improves one measurable review-process hypothesis. A cycle is not a request to remove every model suggestion from the repository.
4
+
5
+ ## Cycle contract
6
+
7
+ Before changing behavior, record one hypothesis, its acceptance criteria, a fixed benchmark set, and the decision rule. A confirmed high-severity finding in the cycle scope, incomplete coverage, or a failed gate blocks publication. Medium and low findings outside the hypothesis enter the backlog.
8
+
9
+ ## Baseline benchmark
10
+
11
+ Run these deterministic, credential-free cases before and after every process change:
12
+
13
+ | Case | Fixture | Expected evidence |
14
+ | --- | --- | --- |
15
+ | Clean review | `test/fixtures/review/good.ts` | Complete `APPROVE`, all enabled lenses succeed. |
16
+ | Lens failure | `CODEX_FIXTURE_FAIL_CATEGORY=security` | Incomplete, fail-closed result with missing required-lens evidence. |
17
+ | Deadline | `CODEX_FIXTURE_HANG=1` | Incomplete, blocking result artifact; no candidate finding is accepted without skeptical verification. |
18
+
19
+ The benchmark records elapsed time, provider calls, failed/skipped calls, execution coverage, verdict, incomplete state, and deadline state. It is run with the fixture provider; representative live runs are a separate acceptance check, never a replacement for this baseline.
20
+
21
+ Run it with `npm run benchmark:cycle`. It emits a versioned JSON report and exits non-zero when any of the three cases stops preserving its stated fail-closed behavior.
22
+
23
+ ## Closed cycle
24
+
25
+ 1. Run and store the baseline benchmark.
26
+ 2. Diagnose one root cause and define the smallest change set.
27
+ 3. Implement the change with a regression test.
28
+ 4. Re-run the same benchmark and compare the listed evidence.
29
+ 5. Run `npm run check`, `npm pack --dry-run`, and `ak-verify run --config .codex/verification.json --json`; record its run ID and require its current state to be `COMPLETE`.
30
+ 6. Review only the cycle diff. Confirmed highs in scope block; unrelated medium/low findings enter backlog.
31
+ 7. Add a Changeset for public behavior, open/merge the version PR, then let trusted publishing create the npm package and GitHub release.
32
+
33
+ ## Release boundary
34
+
35
+ A cycle can be locally validated without publishing. Publishing requires the repository workflow to be pushed, GitHub Actions to be allowed to create the Changesets version PR, npm Trusted Publishing to be configured, and the version PR to merge. These are external prerequisites; they are reported separately from benchmark evidence.
@@ -0,0 +1,70 @@
1
+ ---
2
+ type: package
3
+ package: code-review-cli
4
+ editRoot: .
5
+ checks: [npm run check, npm pack --dry-run]
6
+ ---
7
+
8
+ # Code Review CLI handoff
9
+
10
+ ## Purpose
11
+
12
+ Provider-neutral, low-noise AI code review for local Git diffs, files/stdin, and GitHub pull requests. Seven focused lenses propose findings; adversarial votes remove weak findings; reporters emit Markdown, GitHub reviews, and SARIF.
13
+
14
+ ## Ownership map
15
+
16
+ - `src/cli.ts`: public flags, source selection, provider selection, exit policy.
17
+ - `src/<provider>-adapter.ts`: logged-in local CLI adapters.
18
+ - `agents/code-review/`: review pipeline, lenses, input normalization, reporters.
19
+ - `action.yml`: composite GitHub Action contract.
20
+ - `.github/workflows/release.yml`: Changesets version-pull-request workflow.
21
+ - `.github/workflows/publish.yml`: version-PR-gated npm Trusted Publishing and GitHub Release workflow.
22
+ - `examples/`: copy-ready Action workflows.
23
+ - `README.md` and `docs/OPERATIONS.md`: public adoption and operations guidance.
24
+ - `ecosystem.json`, `llms.txt`, and `llms-full.txt`: canonical product graph and machine-readable discovery/full-corpus surfaces.
25
+ - `test/`: credential-free CLI, Action, and documentation contract proofs.
26
+
27
+ ## Boundaries
28
+
29
+ - Depend on AgentsKit adapter/runtime/tool contracts; do not create a second model abstraction.
30
+ - Preserve provider neutrality and advisory-by-default Action behavior.
31
+ - Never expose provider keys in arguments, docs fixtures, logs, or PR output.
32
+ - This product intentionally has no Fumadocs site and no embedded AgentsChat.
33
+ - The vendored review agent tracks the AgentsKit Registry source; keep divergences explicit.
34
+
35
+ ## Change routes
36
+
37
+ - CLI flag/provider behavior: start at `src/cli.ts`, then update README, operations docs, and tests.
38
+ - Local CLI subprocess behavior: start at the matching `src/<provider>-adapter.ts` and add an offline fixture.
39
+ - Review logic or noise reduction: start at `agents/code-review/agent.ts` and the relevant lens; prove both survival and rejection behavior.
40
+ - GitHub comments/SARIF: start at `agents/code-review/reporters.ts` and verify permissions/failure docs.
41
+ - Action input: update `action.yml`, `examples/pull-request.yml`, README, and contract tests together.
42
+ - Release automation: update `.github/workflows/release.yml`, `.github/workflows/publish.yml`, Changesets configuration, and the automated publishing section in `docs/OPERATIONS.md` together.
43
+
44
+ ## Verification
45
+
46
+ ```bash
47
+ npm ci
48
+ npm run check
49
+ npm pack --dry-run
50
+ ```
51
+
52
+ `npm run check` includes typecheck, build, an end-to-end offline stdin review, Action/documentation tests, Doc Bridge gates, and CLI help.
53
+
54
+ ## Ecosystem routes
55
+
56
+ - AgentsKit — runtime, adapters, and custom review agents: https://www.agentskit.io/docs
57
+ - Registry — ready-made agent source: https://registry.agentskit.io/docs
58
+ - AgentsKit Chat — conversational delivery; do not embed a chat runtime here: https://chat.agentskit.io/docs
59
+ - Playbook — engineering discipline before verification: https://playbook.agentskit.io/docs
60
+ - Doc Bridge — documentation ownership, freshness, and handoff generation: https://agentskit-io.github.io/doc-bridge/
61
+ - AKOS — enterprise orchestration and production governance: https://akos.agentskit.io/docs
62
+
63
+ Use `llms.txt` for discovery and `llms-full.txt` only when the complete public, operational, and agent-handoff context is required.
64
+
65
+ ## Human guide
66
+
67
+ - README: https://raw.githubusercontent.com/AgentsKit-io/code-review/main/README.md
68
+ - Operations guide: https://raw.githubusercontent.com/AgentsKit-io/code-review/main/docs/OPERATIONS.md
69
+ - Contributing: https://raw.githubusercontent.com/AgentsKit-io/code-review/main/CONTRIBUTING.md
70
+ - Security: https://raw.githubusercontent.com/AgentsKit-io/code-review/main/SECURITY.md
@@ -0,0 +1,5 @@
1
+ # Code Review agent docs
2
+
3
+ - Code Review CLI handoff — ownership, change routes, security boundaries, and verification: https://raw.githubusercontent.com/AgentsKit-io/code-review/main/docs/for-agents/code-review-cli.md
4
+ - Concise machine map — discovery, raw sources, and all seven ecosystem products: https://raw.githubusercontent.com/AgentsKit-io/code-review/main/llms.txt
5
+ - Full machine corpus — public, operational, governance, maturity, and agent handoffs: https://raw.githubusercontent.com/AgentsKit-io/code-review/main/llms-full.txt
@@ -0,0 +1,61 @@
1
+ # Ecosystem documentation — Code Review tracer
2
+
3
+ ## Objective
4
+
5
+ Make Code Review a complete, repository-native member of the seven-product AgentsKit ecosystem without adding Fumadocs or an embedded chat surface.
6
+
7
+ ## Acceptance criteria
8
+
9
+ - The canonical ecosystem manifest lists AgentsKit, Registry, Chat, Playbook, Doc Bridge, Code Review, and AKOS with stable public URLs.
10
+ - The README remains concise, keeps its verified examples and maturity contract, and presents all six sibling products as contextual next steps.
11
+ - Documentation-related guidance points to Doc Bridge, conversational UI guidance points to AgentsKit Chat, and enterprise operation guidance points to AKOS.
12
+ - `llms.txt` is a compact discovery map with human, agent, raw-source, and ecosystem routes.
13
+ - `llms-full.txt` exposes the complete repository documentation corpus without bloating `llms.txt`.
14
+ - `docs/for-agents/` identifies ownership, change routes, ecosystem hooks, and required checks.
15
+ - Doc Bridge remains exactly 100/100 with fresh committed artifacts.
16
+
17
+ ## Test plan
18
+
19
+ ### Unit and contract tests
20
+
21
+ - Verify the canonical manifest contains seven unique products in the expected order.
22
+ - Verify Code Review resolves exactly six siblings and that every public URL is HTTPS.
23
+ - Verify `llms.txt` stays concise and links `llms-full.txt`, raw sources, for-agents, and all six siblings.
24
+ - Verify `llms-full.txt` contains the README, operations guide, and agent handoffs.
25
+ - Verify the README contains the six-peer continuation table and the three strategic hooks.
26
+
27
+ ### Integration and regression
28
+
29
+ - Run TypeScript typecheck, build, offline CLI review, Action/documentation contract tests, and README Standard v1.
30
+ - Run Doc Bridge index, gate, and doctor; require 100/100 and fresh artifacts.
31
+ - Run `npm pack --dry-run` and confirm the two LLM surfaces, ecosystem manifest, and agent handoffs ship.
32
+ - Preserve provider neutrality, advisory-by-default behavior, and the repository-native no-Fumadocs/no-AgentsChat-runtime boundary.
33
+
34
+ ### Edge cases
35
+
36
+ - Reject duplicate or missing ecosystem product identifiers.
37
+ - Keep secrets and provider keys out of generated machine-readable docs.
38
+ - Avoid claims of stable npm or `v1` Action distribution while the project remains pre-v1.
39
+ - Ensure GitHub raw-source links are pinned to the public `main` path and do not expose local filesystem paths.
40
+
41
+ ## Documentation impact
42
+
43
+ - `README.md`
44
+ - `llms.txt` and `llms-full.txt`
45
+ - `docs/for-agents/`
46
+ - `docs/OPERATIONS.md`
47
+ - `ecosystem.json`
48
+ - Doc Bridge generated artifacts and README freshness hash
49
+
50
+ ## Definition of Done
51
+
52
+ - All acceptance criteria are implemented.
53
+ - `npm run check` passes.
54
+ - `npm pack --dry-run` passes with the required documentation payload.
55
+ - Doc Bridge reports 100/100 A with all gates passing.
56
+ - No commit, push, release, or PR is created without explicit user authorization.
57
+
58
+ ## Upstream adoption record
59
+
60
+ - Reuse the approved seven-product ecosystem manifest and documentation-quality language from the central AgentsKit documentation contract.
61
+ - Keep review primitives on AgentsKit adapters/runtime and the Registry-sourced review agent; no local model or agent abstraction is introduced.
@@ -0,0 +1,35 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "envelope": "schemaVersion: 1",
4
+ "requiredLenses": ["correctness", "security", "tests"],
5
+ "providers": [
6
+ {
7
+ "id": "grok-cli",
8
+ "support": "stable",
9
+ "executable": "grok",
10
+ "minimumVersion": "0.1.0",
11
+ "trustModes": ["isolated", "trusted-local"],
12
+ "transports": {
13
+ "acp": { "status": "supported", "fixture": "test/grok-cli-adapter.test.mjs" },
14
+ "headless": { "status": "supported", "fixture": "test/headless-cli-adapter.test.mjs" },
15
+ "auto": { "status": "local-only", "fixture": "test/headless-cli-adapter.test.mjs" }
16
+ },
17
+ "auth": "isolated: XAI_API_KEY or --api-key; trusted-local: provider login",
18
+ "failureSemantics": ["strict-envelope", "one-invalid-output-retry", "bounded-timeout", "cancel", "redacted-diagnostics"]
19
+ },
20
+ {
21
+ "id": "opencode-cli",
22
+ "support": "stable",
23
+ "executable": "opencode",
24
+ "minimumVersion": "0.1.0",
25
+ "trustModes": ["isolated", "trusted-local"],
26
+ "transports": {
27
+ "acp": { "status": "supported", "fixture": "test/opencode-cli-adapter.test.mjs" },
28
+ "headless": { "status": "supported", "fixture": "test/headless-cli-adapter.test.mjs" },
29
+ "auto": { "status": "local-only", "fixture": "test/headless-cli-adapter.test.mjs" }
30
+ },
31
+ "auth": "isolated: OPENCODE_API_KEY or --api-key; trusted-local: provider login/configuration",
32
+ "failureSemantics": ["strict-envelope", "one-invalid-output-retry", "bounded-timeout", "cancel", "redacted-diagnostics"]
33
+ }
34
+ ]
35
+ }