@alibaba-group/open-code-review 1.7.14 → 1.7.16
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/README.ja-JP.md +26 -803
- package/README.ko-KR.md +26 -761
- package/README.md +26 -811
- package/README.ru-RU.md +26 -807
- package/README.zh-CN.md +26 -790
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -6,8 +6,11 @@
|
|
|
6
6
|
</div>
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
|
+
<a href="https://trendshift.io/repositories/41087?utm_source=repository-badge&utm_medium=badge&utm_campaign=badge-repository-41087" target="_blank" rel="noopener noreferrer">
|
|
10
|
+
<img src="https://trendshift.io/api/badge/repositories/41087" alt="alibaba%2Fopen-code-review | Trendshift" style="width: 280px; height: 60px;" width="280" height="60" />
|
|
11
|
+
</a>
|
|
9
12
|
<a href="https://trendshift.io/repositories/41087" target="_blank">
|
|
10
|
-
<img src="https://trendshift.io/api/badge/trendshift/repositories/41087/weekly?language=Go" alt="alibaba%2Fopen-code-review | Trendshift" style="width:
|
|
13
|
+
<img src="https://trendshift.io/api/badge/trendshift/repositories/41087/weekly?language=Go" alt="alibaba%2Fopen-code-review | Trendshift" style="width: 280px; height: 60px;" width="280" height="60" />
|
|
11
14
|
</a>
|
|
12
15
|
</p>
|
|
13
16
|
<p align="center">
|
|
@@ -99,116 +102,19 @@ The agent's strengths are concentrated where they matter most — dynamic decisi
|
|
|
99
102
|
|
|
100
103
|
#### Install
|
|
101
104
|
|
|
102
|
-
**Via NPM (Recommended)**
|
|
103
|
-
|
|
104
105
|
```bash
|
|
105
106
|
npm install -g @alibaba-group/open-code-review
|
|
106
107
|
```
|
|
107
108
|
|
|
108
109
|
After installation, the `ocr` command is available globally.
|
|
109
110
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
If you installed via NPM, update manually to the latest version:
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
npm install -g @alibaba-group/open-code-review@latest
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
NPM installations also check for newer versions in the background by default and upgrade automatically. To disable auto-updates, set `OCR_NO_UPDATE=1`.
|
|
119
|
-
|
|
120
|
-
If you installed with the install script or a manually downloaded binary, rerun the same install/download command to replace the local binary with the latest release. Use `OCR_VERSION` when you need to pin a specific release tag.
|
|
121
|
-
|
|
122
|
-
**From GitHub Release**
|
|
123
|
-
|
|
124
|
-
Install the latest binary for your OS/architecture with one command (macOS / Linux):
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
curl -fsSL https://raw.githubusercontent.com/alibaba/open-code-review/main/install.sh | sh
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
The script picks the right release binary, verifies its SHA-256 checksum, and installs it as `ocr` in `/usr/local/bin`. Override the target with `OCR_INSTALL_DIR` or pin a release with `OCR_VERSION`:
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
OCR_INSTALL_DIR="$HOME/.local/bin" OCR_VERSION=v1.3.13 \
|
|
134
|
-
sh -c "$(curl -fsSL https://raw.githubusercontent.com/alibaba/open-code-review/main/install.sh)"
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
On Windows (PowerShell 5.1+):
|
|
138
|
-
|
|
139
|
-
```powershell
|
|
140
|
-
irm https://raw.githubusercontent.com/alibaba/open-code-review/main/install.ps1 | iex
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
The script picks the right Windows release binary, verifies its SHA-256 checksum, and installs it as `ocr.exe` in `%LOCALAPPDATA%\Programs\ocr`. Override the target with `OCR_INSTALL_DIR` or pin a release with `OCR_VERSION`:
|
|
144
|
-
|
|
145
|
-
```powershell
|
|
146
|
-
$env:OCR_INSTALL_DIR = "$env:USERPROFILE\bin"
|
|
147
|
-
$env:OCR_VERSION = "v1.3.13"
|
|
148
|
-
irm https://raw.githubusercontent.com/alibaba/open-code-review/main/install.ps1 | iex
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
Piping a remote script into a shell executes code from the internet. Prefer downloading and inspecting first:
|
|
152
|
-
|
|
153
|
-
```bash
|
|
154
|
-
curl -fsSL https://raw.githubusercontent.com/alibaba/open-code-review/main/install.sh -o install.sh
|
|
155
|
-
less install.sh && sh install.sh
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
```powershell
|
|
159
|
-
irm https://raw.githubusercontent.com/alibaba/open-code-review/main/install.ps1 -OutFile install.ps1
|
|
160
|
-
notepad install.ps1 # review, then: .\install.ps1
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
<details>
|
|
164
|
-
<summary>Manual download (all platforms, including Windows)</summary>
|
|
165
|
-
|
|
166
|
-
Download the binary for your platform from [GitHub Releases](https://github.com/alibaba/open-code-review/releases):
|
|
167
|
-
|
|
168
|
-
```bash
|
|
169
|
-
# macOS (Apple Silicon)
|
|
170
|
-
curl -Lo ocr https://github.com/alibaba/open-code-review/releases/latest/download/opencodereview-darwin-arm64
|
|
171
|
-
chmod +x ocr && sudo mv ocr /usr/local/bin/ocr
|
|
172
|
-
|
|
173
|
-
# macOS (Intel)
|
|
174
|
-
curl -Lo ocr https://github.com/alibaba/open-code-review/releases/latest/download/opencodereview-darwin-amd64
|
|
175
|
-
chmod +x ocr && sudo mv ocr /usr/local/bin/ocr
|
|
176
|
-
|
|
177
|
-
# Linux (x86_64)
|
|
178
|
-
curl -Lo ocr https://github.com/alibaba/open-code-review/releases/latest/download/opencodereview-linux-amd64
|
|
179
|
-
chmod +x ocr && sudo mv ocr /usr/local/bin/ocr
|
|
180
|
-
|
|
181
|
-
# Linux (ARM64)
|
|
182
|
-
curl -Lo ocr https://github.com/alibaba/open-code-review/releases/latest/download/opencodereview-linux-arm64
|
|
183
|
-
chmod +x ocr && sudo mv ocr /usr/local/bin/ocr
|
|
184
|
-
|
|
185
|
-
# Windows (x86_64) — move ocr.exe to a directory in your PATH
|
|
186
|
-
curl -Lo ocr.exe https://github.com/alibaba/open-code-review/releases/latest/download/opencodereview-windows-amd64.exe
|
|
187
|
-
|
|
188
|
-
# Windows (ARM64) — move ocr.exe to a directory in your PATH
|
|
189
|
-
curl -Lo ocr.exe https://github.com/alibaba/open-code-review/releases/latest/download/opencodereview-windows-arm64.exe
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
</details>
|
|
193
|
-
|
|
194
|
-
**From Source**
|
|
195
|
-
|
|
196
|
-
```bash
|
|
197
|
-
git clone https://github.com/alibaba/open-code-review.git
|
|
198
|
-
cd open-code-review
|
|
199
|
-
make build
|
|
200
|
-
sudo cp dist/opencodereview /usr/local/bin/ocr
|
|
201
|
-
```
|
|
111
|
+
For other installation methods (install script, GitHub Release binary, from source), see [Installation](https://open-codereview.ai/docs/installation).
|
|
202
112
|
|
|
203
113
|
#### Quick Start
|
|
204
114
|
|
|
205
115
|
**1. Configure LLM**
|
|
206
116
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
OCR manages LLM configuration through a unified **Provider** system. It ships with many popular built-in providers and also supports adding custom providers to connect to private deployments or other compatible endpoints. Config is stored in `~/.opencodereview/config.json`.
|
|
210
|
-
|
|
211
|
-
**Option A: Interactive setup (Recommended)**
|
|
117
|
+
You must configure an LLM before reviewing code, unless you use [Delegation Mode](https://open-codereview.ai/docs/delegate).
|
|
212
118
|
|
|
213
119
|
```bash
|
|
214
120
|
ocr config provider # Select a built-in provider or add a custom one
|
|
@@ -219,91 +125,9 @@ ocr config model # Pick a model for the active provider
|
|
|
219
125
|
|
|
220
126
|
The interactive UI guides you through provider selection, API key entry, and model configuration, then automatically tests connectivity.
|
|
221
127
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
**Custom providers** can also be added through the interactive UI — you'll need to provide a name, API URL, protocol type (`anthropic` or `openai`), and API key.
|
|
225
|
-
|
|
226
|
-
**Option B: CLI setup (for CI/CD and non-interactive environments)**
|
|
227
|
-
|
|
228
|
-
Use `ocr config set` to write provider configuration directly, suitable for scripts and automation.
|
|
229
|
-
|
|
230
|
-
Using a built-in provider:
|
|
231
|
-
|
|
232
|
-
```bash
|
|
233
|
-
ocr config set provider anthropic
|
|
234
|
-
ocr config set providers.anthropic.api_key your-api-key-here
|
|
235
|
-
ocr config set providers.anthropic.model claude-sonnet-4-6
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
Using a custom provider (private gateway or other compatible endpoint):
|
|
239
|
-
|
|
240
|
-
```bash
|
|
241
|
-
ocr config set provider my-gateway
|
|
242
|
-
ocr config set custom_providers.my-gateway.url https://my-llm-gateway.internal/v1
|
|
243
|
-
ocr config set custom_providers.my-gateway.protocol openai
|
|
244
|
-
ocr config set custom_providers.my-gateway.api_key your-api-key-here
|
|
245
|
-
ocr config set custom_providers.my-gateway.model gpt-4o
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
> `url` and `protocol` are required for custom providers. Supported protocols: `anthropic`, `openai`, `openai-responses`.
|
|
249
|
-
|
|
250
|
-
Optional settings:
|
|
251
|
-
|
|
252
|
-
| Key | Description |
|
|
253
|
-
|-----|-------------|
|
|
254
|
-
| `providers.<name>.auth_header` | Auth header: `x-api-key` or `authorization` (default: `authorization`) |
|
|
255
|
-
| `providers.<name>.extra_body` | Custom JSON fields merged into the request body |
|
|
256
|
-
| `providers.<name>.extra_headers` | Comma-separated `key=value` pairs of custom HTTP headers added to every request |
|
|
257
|
-
| `providers.<name>.models` | Model list for interactive selection |
|
|
258
|
-
|
|
259
|
-
**`extra_headers` (optional):** Adds custom HTTP headers to every LLM API request. Useful for proxies, gateways, or enterprise endpoints that require additional headers (e.g. organization IDs, tracing IDs). Format is comma-separated `key=value` pairs. Double-quote values that contain commas:
|
|
260
|
-
|
|
261
|
-
```bash
|
|
262
|
-
ocr config set llm.extra_headers "X-Org-ID=org-123,X-Forwarded-For=\"1.2.3.4,5.6.7.8\""
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
You can also set extra headers per-provider:
|
|
266
|
-
|
|
267
|
-
```bash
|
|
268
|
-
ocr config set providers.anthropic.extra_headers "X-Org-ID=org-123"
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
**Environment variables (highest priority)**
|
|
272
|
-
|
|
273
|
-
Environment variables override config file settings, useful in CI/CD where writing config files is inconvenient:
|
|
128
|
+
For CLI setup, environment variables, custom providers, and other advanced configuration, see [Configuration](https://open-codereview.ai/docs/configuration).
|
|
274
129
|
|
|
275
|
-
|
|
276
|
-
export OCR_LLM_URL=https://api.anthropic.com/v1/messages
|
|
277
|
-
export OCR_LLM_TOKEN=your-api-key-here
|
|
278
|
-
export OCR_LLM_MODEL=claude-opus-4-6
|
|
279
|
-
export OCR_USE_ANTHROPIC=true
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
To use the OpenAI Responses API (GPT-5.x / o-series), set `OCR_LLM_PROTOCOL` instead of `OCR_USE_ANTHROPIC`:
|
|
283
|
-
|
|
284
|
-
```bash
|
|
285
|
-
export OCR_LLM_URL=https://api.openai.com/v1
|
|
286
|
-
export OCR_LLM_TOKEN=your-openai-key
|
|
287
|
-
export OCR_LLM_MODEL=gpt-5.4
|
|
288
|
-
export OCR_LLM_PROTOCOL=openai-responses
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
`OCR_LLM_PROTOCOL` accepts `anthropic`, `openai`, `openai-responses`, and takes priority over `OCR_USE_ANTHROPIC` when both are set.
|
|
292
|
-
|
|
293
|
-
Also compatible with Claude Code environment variables (`ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_MODEL`) and parses `~/.zshrc` / `~/.bashrc` for those exports.
|
|
294
|
-
|
|
295
|
-
> **Note for CC-Switch Users**: If you are using [CC-Switch](https://github.com/farion1231/cc-switch) with [routing service](https://www.ccswitch.io/en/docs?section=proxy&item=service) enabled, you can point the provider's `url` to the CC-Switch proxy address without additional configuration:
|
|
296
|
-
> - For **Claude** provider: set `providers.anthropic.url` to `http://127.0.0.1:15721`
|
|
297
|
-
> - For **Codex** provider: set the corresponding provider's `url` to `http://127.0.0.1:15721/v1`
|
|
298
|
-
> - `api_key` can be any value; `extra_body` settings still apply
|
|
299
|
-
|
|
300
|
-
**2. Test Connectivity**
|
|
301
|
-
|
|
302
|
-
```bash
|
|
303
|
-
ocr llm test
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
**3. Review**
|
|
130
|
+
**2. Review**
|
|
307
131
|
|
|
308
132
|
```bash
|
|
309
133
|
cd your-project
|
|
@@ -331,633 +155,24 @@ ocr delegate preview
|
|
|
331
155
|
ocr delegate rule src/main.go src/handler.go
|
|
332
156
|
```
|
|
333
157
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
See [skills/open-code-review-delegate/SKILL.md](skills/open-code-review-delegate/SKILL.md) for details.
|
|
355
|
-
|
|
356
|
-
#### Option 2: Install as a Claude Code Plugin
|
|
357
|
-
|
|
358
|
-
For [Claude Code](https://docs.anthropic.com/en/docs/claude-code), install the command plugin through the following command in Claude Code:
|
|
359
|
-
|
|
360
|
-
```bash
|
|
361
|
-
/plugin marketplace add alibaba/open-code-review
|
|
362
|
-
/plugin install open-code-review@open-code-review
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
This registers the `/open-code-review:review` slash command, which runs OCR and automatically filters and fixes issues. It also provides `/open-code-review:delegate-review` for delegation mode (the agent reviews using its own capabilities while OCR handles file selection and rules).
|
|
366
|
-
|
|
367
|
-
#### Option 3: Install as a Codex Plugin
|
|
368
|
-
|
|
369
|
-
For local Codex, install the Open Code Review plugin from this repository:
|
|
370
|
-
|
|
371
|
-
```bash
|
|
372
|
-
codex plugin marketplace add alibaba/open-code-review
|
|
373
|
-
codex
|
|
374
|
-
/plugins
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
For a local checkout or fork:
|
|
378
|
-
|
|
379
|
-
```bash
|
|
380
|
-
codex plugin marketplace add .
|
|
381
|
-
codex
|
|
382
|
-
/plugins
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
Install and enable `Open Code Review`, then start a new Codex thread and invoke it explicitly:
|
|
386
|
-
|
|
387
|
-
```text
|
|
388
|
-
@Open Code Review review my current changes
|
|
389
|
-
@Open Code Review review this branch against main
|
|
390
|
-
@Open Code Review review and fix high-confidence issues
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
This registers a Codex skill that runs the local OCR CLI:
|
|
394
|
-
|
|
395
|
-
```bash
|
|
396
|
-
ocr review --audience agent
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
This integration does not change OCR's internal LLM backend and does not require configuring an OpenAI Responses API endpoint for Codex. OCR itself still requires the `ocr` CLI to be installed and configured as described in the CLI setup section.
|
|
400
|
-
|
|
401
|
-
Korean guide: [`plugins/open-code-review/CODEX.ko-KR.md`](plugins/open-code-review/CODEX.ko-KR.md)
|
|
402
|
-
|
|
403
|
-
#### Option 4: Install as a Cursor Plugin
|
|
404
|
-
|
|
405
|
-
For [Cursor](https://www.cursor.com/), install the Open Code Review plugin from this repository:
|
|
406
|
-
|
|
407
|
-
```
|
|
408
|
-
cursor-plugin marketplace add alibaba/open-code-review
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
Or add the marketplace manually. In Cursor, open `/plugins`, search for `Open Code Review`, and install it.
|
|
412
|
-
|
|
413
|
-
For a local checkout or fork:
|
|
414
|
-
|
|
415
|
-
```
|
|
416
|
-
cursor-plugin marketplace add .
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
After installation, invoke it in Cursor:
|
|
420
|
-
|
|
421
|
-
```text
|
|
422
|
-
@Open Code Review review my current changes
|
|
423
|
-
@Open Code Review review this branch against main
|
|
424
|
-
@Open Code Review review and fix high-confidence issues
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
This registers a Cursor skill that runs the local OCR CLI:
|
|
428
|
-
|
|
429
|
-
```bash
|
|
430
|
-
ocr review --audience agent
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
This integration does not change OCR's internal LLM backend. OCR itself still requires the `ocr` CLI to be installed and configured as described in the CLI setup section.
|
|
434
|
-
|
|
435
|
-
#### Option 5: Copy the Command File Directly
|
|
436
|
-
|
|
437
|
-
For a quick setup without any package manager, simply copy the command file to use the `/open-code-review` slash command in Claude Code.
|
|
438
|
-
|
|
439
|
-
**Project-level** (shared with team via git):
|
|
440
|
-
|
|
441
|
-
```bash
|
|
442
|
-
mkdir -p .claude/commands
|
|
443
|
-
curl -o .claude/commands/open-code-review.md \
|
|
444
|
-
https://raw.githubusercontent.com/alibaba/open-code-review/main/plugins/open-code-review/claude-code/commands/review.md
|
|
445
|
-
```
|
|
446
|
-
|
|
447
|
-
**User-level** (personal global use across all projects):
|
|
448
|
-
|
|
449
|
-
```bash
|
|
450
|
-
mkdir -p ~/.claude/commands
|
|
451
|
-
curl -o ~/.claude/commands/open-code-review.md \
|
|
452
|
-
https://raw.githubusercontent.com/alibaba/open-code-review/main/plugins/open-code-review/claude-code/commands/review.md
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
For delegation mode (no LLM configuration needed on OCR side):
|
|
456
|
-
|
|
457
|
-
```bash
|
|
458
|
-
# Project-level
|
|
459
|
-
mkdir -p .claude/commands
|
|
460
|
-
curl -o .claude/commands/open-code-review-delegate.md \
|
|
461
|
-
https://raw.githubusercontent.com/alibaba/open-code-review/main/plugins/open-code-review/claude-code/commands/delegate-review.md
|
|
462
|
-
|
|
463
|
-
# User-level
|
|
464
|
-
mkdir -p ~/.claude/commands
|
|
465
|
-
curl -o ~/.claude/commands/open-code-review-delegate.md \
|
|
466
|
-
https://raw.githubusercontent.com/alibaba/open-code-review/main/plugins/open-code-review/claude-code/commands/delegate-review.md
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
> **Prerequisite**: All integration methods require the `ocr` CLI to be installed. Standard mode additionally requires an LLM configured — see [Install](#install) and [Configure LLM](#1-configure-llm) above. Delegation mode does **not** require LLM configuration on the OCR side.
|
|
470
|
-
|
|
471
|
-
### CI/CD Integration
|
|
472
|
-
|
|
473
|
-
OCR can be integrated into CI/CD pipelines to automate code review on Merge Requests / Pull Requests.
|
|
474
|
-
|
|
475
|
-
The core command for CI integration:
|
|
476
|
-
|
|
477
|
-
```bash
|
|
478
|
-
ocr review \
|
|
479
|
-
--from "origin/main" \
|
|
480
|
-
--to "<commit_sha>" \
|
|
481
|
-
--format json
|
|
482
|
-
```
|
|
483
|
-
|
|
484
|
-
The `--from` flag accepts a branch ref (e.g., `origin/main`) or commit SHA as the base, while `--to` accepts a commit SHA or branch ref as the head. In CI environments, using commit SHA for `--to` is recommended to correctly handle fork PRs/MRs where the source branch doesn't exist on the origin remote.
|
|
485
|
-
|
|
486
|
-
The `--format json` flag outputs machine-readable results suitable for parsing in CI scripts.
|
|
487
|
-
|
|
488
|
-
Each finding carries two structured fields so CI integrations can sort, group, filter, or gate builds without re-parsing comment text:
|
|
489
|
-
|
|
490
|
-
| Field | Allowed values | Notes |
|
|
491
|
-
|-------|----------------|-------|
|
|
492
|
-
| `category` | `bug`, `security`, `performance`, `maintainability`, `test`, `style`, `documentation`, `other` | The category the issue belongs to. |
|
|
493
|
-
| `severity` | `critical`, `high`, `medium`, `low` | The importance of the issue. |
|
|
494
|
-
|
|
495
|
-
In JSON output the two fields appear as siblings alongside `content`, `start_line`, etc. In the terminal, they render as an inline `[category · severity]` badge before the comment, colored by severity.
|
|
496
|
-
|
|
497
|
-
See the [`examples/`](./examples/) directory for integration examples:
|
|
498
|
-
|
|
499
|
-
- [`github_actions/`](./examples/github_actions/) — GitHub Actions integration example
|
|
500
|
-
- [`gitlab_ci/`](./examples/gitlab_ci/) — GitLab CI integration example
|
|
501
|
-
- [`gitflic_ci/`](./examples/gitflic_ci/) — GitFlic CI integration example
|
|
502
|
-
- [`gerrit_ci/`](./examples/gerrit_ci/) — Gerrit (Jenkins / Gerrit Trigger) integration example
|
|
503
|
-
|
|
504
|
-
#### GitHub Action
|
|
505
|
-
|
|
506
|
-
For GitHub, this repository also ships a ready-to-use composite Action at the repo root ([`action.yml`](./action.yml)). Instead of scripting `ocr review` yourself, reference it directly and it handles the full pipeline — checkout, OCR install, running the review, posting inline and summary comments, uploading artifacts, and retry/idempotency:
|
|
507
|
-
|
|
508
|
-
```yaml
|
|
509
|
-
- uses: alibaba/open-code-review@main
|
|
510
|
-
with:
|
|
511
|
-
llm_url: ${{ secrets.OCR_LLM_URL }}
|
|
512
|
-
llm_auth_token: ${{ secrets.OCR_LLM_AUTH_TOKEN }}
|
|
513
|
-
llm_model: ${{ vars.OCR_LLM_MODEL }}
|
|
514
|
-
llm_use_anthropic: ${{ vars.OCR_LLM_USE_ANTHROPIC }}
|
|
515
|
-
```
|
|
516
|
-
|
|
517
|
-
Pin to a version tag or commit SHA for reproducibility. See the [`examples/github_actions/`](./examples/github_actions/) directory for a complete workflow demo and the full list of inputs, outputs, and comment-posting modes (sticky summary, incremental non-destructive posting).
|
|
518
|
-
|
|
519
|
-
## Commands
|
|
520
|
-
|
|
521
|
-
| Command | Alias | Description |
|
|
522
|
-
|---------|-------|-------------|
|
|
523
|
-
| `ocr review` | `ocr r` | Start a diff-based code review |
|
|
524
|
-
| `ocr scan` | `ocr s` | Review whole files (no diff required) |
|
|
525
|
-
| `ocr delegate preview` | `ocr d preview` | Preview reviewable files with mode/ref metadata (no LLM required) |
|
|
526
|
-
| `ocr delegate rule <path...>` | `ocr d rule` | Output resolved review rules grouped by content (no LLM required) |
|
|
527
|
-
| `ocr rules check <file>` | — | Preview which review rule applies to a file path |
|
|
528
|
-
| `ocr config provider` | — | Interactive provider setup (built-in, custom, or manual) |
|
|
529
|
-
| `ocr config model` | — | Interactive model selection for the active provider |
|
|
530
|
-
| `ocr config set <key> <value>` | — | Set configuration values |
|
|
531
|
-
| `ocr config unset custom_providers.<name>` | — | Delete a custom provider |
|
|
532
|
-
| `ocr llm test` | — | Test LLM connectivity |
|
|
533
|
-
| `ocr llm providers` | — | List built-in LLM providers |
|
|
534
|
-
| `ocr session list` | `ocr sessions list`, `ocr session ls` | List saved review sessions |
|
|
535
|
-
| `ocr session show <id>` | `ocr sessions show <id>` | Inspect one session and its per-file checkpoints |
|
|
536
|
-
| `ocr viewer` | `ocr v` | Launch WebUI session viewer on `localhost:5483` |
|
|
537
|
-
| `ocr version` | — | Show version info |
|
|
538
|
-
|
|
539
|
-
### `ocr review` Flags
|
|
540
|
-
|
|
541
|
-
| Flag | Shorthand | Default | Description |
|
|
542
|
-
|------|-----------|---------|-------------|
|
|
543
|
-
| `--repo` | — | current dir | Git repository root |
|
|
544
|
-
| `--from` | — | — | Source ref (e.g., `main`) |
|
|
545
|
-
| `--to` | — | — | Target ref (e.g., `feature-branch`) |
|
|
546
|
-
| `--commit` | `-c` | — | Single commit to review |
|
|
547
|
-
| `--exclude` | — | — | Comma-separated gitignore-style patterns to skip; merged with rule.json excludes |
|
|
548
|
-
| `--preview` | `-p` | `false` | Preview which files will be reviewed without running the LLM |
|
|
549
|
-
| `--resume` | — | — | Resume from a previous compatible range or commit review session |
|
|
550
|
-
| `--format` | `-f` | `text` | Output format: `text` or `json` |
|
|
551
|
-
| `--concurrency` | — | `8` | Max concurrent file reviews |
|
|
552
|
-
| `--timeout` | — | `10` | Concurrent task timeout in minutes |
|
|
553
|
-
| `--audience` | — | `human` | `human` (show progress) or `agent` (summary only) |
|
|
554
|
-
| `--background` | `-b` | — | Optional requirement/business context for the review; auto-filled from commit message when using `--commit` |
|
|
555
|
-
| `--background-file` | `-B` | — | Optional requirement/business context from a Markdown file; Combined with `--background` the inline value is given first |
|
|
556
|
-
| `--model` | — | — | Select or override the LLM model for this review |
|
|
557
|
-
| `--rule` | — | — | Path to custom JSON review rules |
|
|
558
|
-
| `--max-tools` | — | built-in | Max tool call rounds per file; only takes effect when greater than template default |
|
|
559
|
-
| `--max-git-procs` | — | `16` | Max concurrent git subprocesses |
|
|
560
|
-
| `--tools` | — | built-in | Path to custom JSON tools config |
|
|
561
|
-
|
|
562
|
-
#### Resumable Reviews and Sessions
|
|
563
|
-
|
|
564
|
-
Every `ocr review` run persists a local session log under
|
|
565
|
-
`~/.opencodereview/sessions/`. Successful text output stays focused on review
|
|
566
|
-
results and does not print the session ID; use `ocr session list/show` to find
|
|
567
|
-
saved sessions, or `--format json` to include `session_id` in machine-readable
|
|
568
|
-
output. If a range or commit review is interrupted, list the saved sessions and
|
|
569
|
-
resume from the one that matches the same review target:
|
|
570
|
-
|
|
571
|
-
```bash
|
|
572
|
-
ocr session list
|
|
573
|
-
ocr session show <session-id>
|
|
574
|
-
ocr review --from main --to feature-branch --resume <session-id>
|
|
575
|
-
ocr review --commit abc123 --resume <session-id>
|
|
576
|
-
```
|
|
577
|
-
|
|
578
|
-
Resume is intentionally strict: it only supports branch-range and single-commit
|
|
579
|
-
reviews, not workspace reviews, and the current `--from/--to` or `--commit`
|
|
580
|
-
must match the saved session. `--preview` cannot be combined with `--resume`.
|
|
581
|
-
|
|
582
|
-
When `--format json` is used, resumed runs include:
|
|
583
|
-
|
|
584
|
-
- `session_id` — the current run's session ID
|
|
585
|
-
- `resume.resumed_from` — the source session ID
|
|
586
|
-
- `resume.reused_files` — files reused from saved checkpoints
|
|
587
|
-
- `resume.rerun_files` — files reviewed again in the current run
|
|
588
|
-
|
|
589
|
-
### `ocr session` Flags
|
|
590
|
-
|
|
591
|
-
| Command | Flag | Default | Description |
|
|
592
|
-
|---------|------|---------|-------------|
|
|
593
|
-
| `ocr session list` | `--repo` | current dir | Repository whose sessions should be listed |
|
|
594
|
-
| `ocr session list` | `--json` | `false` | Emit session summaries as JSON |
|
|
595
|
-
| `ocr session list` | `--limit` | `20` | Cap listed sessions; use `0` for unlimited |
|
|
596
|
-
| `ocr session show <id>` | `--repo` | current dir | Repository whose session should be inspected |
|
|
597
|
-
| `ocr session show <id>` | `--json` | `false` | Emit session metadata and per-file items as JSON |
|
|
598
|
-
|
|
599
|
-
### `ocr scan` Flags
|
|
600
|
-
|
|
601
|
-
`ocr scan` reviews entire files rather than a diff — useful for auditing an unfamiliar
|
|
602
|
-
codebase, a pre-migration sweep, or any directory with no meaningful diff. It works in
|
|
603
|
-
non-git directories too (it falls back to a filesystem walk that honors `.gitignore`).
|
|
604
|
-
|
|
605
|
-
| Flag | Shorthand | Default | Description |
|
|
606
|
-
|------|-----------|---------|-------------|
|
|
607
|
-
| `--path` | — | whole repo | Comma-separated dirs/files to scan |
|
|
608
|
-
| `--exclude` | — | — | Comma-separated gitignore-style patterns to skip; merged with rule.json excludes |
|
|
609
|
-
| `--preview` | `-p` | `false` | List which files would be scanned without running the LLM |
|
|
610
|
-
| `--max-tokens-budget` | — | `0` (unlimited) | Cap total token usage; dispatch stops once exceeded |
|
|
611
|
-
| `--no-plan` | — | `false` | Skip the per-file planning pre-pass |
|
|
612
|
-
| `--no-dedup` | — | `false` | Skip per-batch de-duplication of similar comments |
|
|
613
|
-
| `--no-summary` | — | `false` | Skip the project-level summary |
|
|
614
|
-
| `--batch` | — | `by-language` | Batching strategy: `none`, `by-language`, or `by-directory` |
|
|
615
|
-
| `--format` | `-f` | `text` | Output format: `text` or `json` (JSON includes a `project_summary` field) |
|
|
616
|
-
| `--concurrency` | — | `8` | Max concurrent file scans |
|
|
617
|
-
| `--rule` | — | — | Path to custom JSON review rules |
|
|
618
|
-
| `--repo` | — | current dir | Repository or directory root to scan |
|
|
619
|
-
|
|
620
|
-
Before each run, `ocr scan` prints a rough token-cost estimate. Use `--preview` to see the
|
|
621
|
-
file list first, and `--max-tokens-budget` to cap spend on large repositories.
|
|
622
|
-
|
|
623
|
-
### `ocr delegate` Flags
|
|
624
|
-
|
|
625
|
-
`ocr delegate` is the delegation mode for AI coding agents. It provides deterministic
|
|
626
|
-
file selection and rule resolution without calling any LLM — the host agent performs
|
|
627
|
-
the actual review using its own capabilities.
|
|
628
|
-
|
|
629
|
-
| Sub-command | Description |
|
|
630
|
-
|-------------|-------------|
|
|
631
|
-
| `ocr delegate preview` | Output reviewable file list with mode/ref metadata |
|
|
632
|
-
| `ocr delegate rule <path...>` | Output resolved review rules grouped by content |
|
|
633
|
-
|
|
634
|
-
Both sub-commands share these flags:
|
|
635
|
-
|
|
636
|
-
| Flag | Shorthand | Default | Description |
|
|
637
|
-
|------|-----------|---------|-------------|
|
|
638
|
-
| `--repo` | — | current dir | Git repository root |
|
|
639
|
-
| `--from` | — | — | Source ref (e.g., `main`) |
|
|
640
|
-
| `--to` | — | — | Target ref (e.g., `feature-branch`) |
|
|
641
|
-
| `--commit` | `-c` | — | Single commit to review |
|
|
642
|
-
| `--exclude` | — | — | Comma-separated gitignore-style patterns to skip |
|
|
643
|
-
| `--rule` | — | — | Path to custom JSON review rules |
|
|
644
|
-
| `--background` | `-b` | — | Optional requirement/business context |
|
|
645
|
-
| `--background-file` | `-B` | — | Business context from a Markdown file |
|
|
646
|
-
| `--max-git-procs` | — | `16` | Max concurrent git subprocesses |
|
|
647
|
-
|
|
648
|
-
## Examples
|
|
649
|
-
|
|
650
|
-
```bash
|
|
651
|
-
# Interactive provider and model setup
|
|
652
|
-
ocr config provider
|
|
653
|
-
ocr config model
|
|
654
|
-
ocr llm providers
|
|
655
|
-
|
|
656
|
-
# Delete a custom provider
|
|
657
|
-
ocr config unset custom_providers.my-gateway
|
|
658
|
-
|
|
659
|
-
# Preview which files will be reviewed (no LLM calls)
|
|
660
|
-
ocr review --preview
|
|
661
|
-
ocr review -c abc123 -p
|
|
662
|
-
|
|
663
|
-
# Review workspace changes with default settings
|
|
664
|
-
ocr review
|
|
665
|
-
|
|
666
|
-
# Review branch diff with higher concurrency
|
|
667
|
-
ocr review --from main --to my-feature --concurrency 4
|
|
668
|
-
|
|
669
|
-
# Review a specific commit with verbose JSON output
|
|
670
|
-
ocr review --commit abc123 --format json --audience agent
|
|
671
|
-
|
|
672
|
-
# Resume an interrupted range or commit review
|
|
673
|
-
ocr session list
|
|
674
|
-
ocr session show <session-id>
|
|
675
|
-
ocr review --from main --to my-feature --resume <session-id>
|
|
676
|
-
ocr review --commit abc123 --resume <session-id>
|
|
677
|
-
|
|
678
|
-
# Select or override model for this review
|
|
679
|
-
ocr review --model claude-opus-4-6
|
|
680
|
-
ocr review --commit abc123 --model claude-sonnet-4-6
|
|
681
|
-
|
|
682
|
-
# Provide requirement context for more targeted review
|
|
683
|
-
ocr review --background "Adding rate limiting to the login API"
|
|
684
|
-
|
|
685
|
-
# Provide requirement context from a Markdown file
|
|
686
|
-
ocr review --background-file ./docs/my_business_context.md
|
|
687
|
-
|
|
688
|
-
# Combine inline context with a local context file (both are used)
|
|
689
|
-
ocr review --background "Focus on auth" --background-file ./docs/my_business_context.md
|
|
690
|
-
|
|
691
|
-
# Use custom review rules
|
|
692
|
-
ocr review --rule /path/to/my-rules.json
|
|
693
|
-
|
|
694
|
-
# Preview which rule applies to a file
|
|
695
|
-
ocr rules check src/main/java/com/example/Foo.java
|
|
696
|
-
ocr rules check --rule custom.json src/main/resources/mapper/UserMapper.xml
|
|
697
|
-
|
|
698
|
-
# Full-file scan: preview the file list first (no LLM calls)
|
|
699
|
-
ocr scan --preview
|
|
700
|
-
|
|
701
|
-
# Scan the whole repo, cap spend at ~500k tokens
|
|
702
|
-
ocr scan --max-tokens-budget 500000
|
|
703
|
-
|
|
704
|
-
# Scan a subdirectory, skipping generated/test files
|
|
705
|
-
ocr scan --path internal --exclude '**/*_test.go,**/generated/**'
|
|
706
|
-
|
|
707
|
-
# Scan a non-git directory with JSON output (includes project_summary)
|
|
708
|
-
ocr scan --repo /path/to/plain/dir --format json
|
|
709
|
-
|
|
710
|
-
# Fastest scan: skip planning, dedup, and the project summary
|
|
711
|
-
ocr scan --no-plan --no-dedup --no-summary
|
|
712
|
-
|
|
713
|
-
# Delegation mode — let your AI agent drive the review (no LLM config needed)
|
|
714
|
-
ocr delegate preview
|
|
715
|
-
ocr delegate preview --from main --to feature-branch
|
|
716
|
-
ocr delegate preview --commit abc123
|
|
717
|
-
ocr delegate rule internal/handler.go internal/service.go cmd/main.go
|
|
718
|
-
|
|
719
|
-
# View review session history in browser
|
|
720
|
-
ocr viewer
|
|
721
|
-
ocr viewer --addr :3000
|
|
722
|
-
```
|
|
723
|
-
|
|
724
|
-
### Viewer security
|
|
725
|
-
|
|
726
|
-
The viewer serves session JSONL contents (LLM request messages and responses) over HTTP. It enforces a Host-header allowlist on every request: loopback names (`localhost`, `127.0.0.0/8`, `::1`) and the concrete bind host are always allowed. Wildcard binds (`--addr :3000`, `--addr 0.0.0.0:3000`) and other non-loopback Hostnames must be added via the `OCR_VIEWER_ALLOWED_HOSTS` environment variable (comma-separated):
|
|
727
|
-
|
|
728
|
-
```bash
|
|
729
|
-
OCR_VIEWER_ALLOWED_HOSTS=review.internal,ocr.lan ocr viewer --addr :3000
|
|
730
|
-
```
|
|
731
|
-
|
|
732
|
-
This blocks DNS-rebinding attacks against the local viewer.
|
|
733
|
-
|
|
734
|
-
## Review Rules
|
|
735
|
-
|
|
736
|
-
OCR resolves review rules using a four-layer priority chain. Each layer uses first-match-wins: if a file path matches a pattern, that rule is used; otherwise it falls through to the next layer.
|
|
737
|
-
|
|
738
|
-
| Priority | Source | Path | Description |
|
|
739
|
-
|----------|--------|------|-------------|
|
|
740
|
-
| 1 (highest) | `--rule` flag | User-specified path | CLI explicit override |
|
|
741
|
-
| 2 | Project config | `<repoDir>/.opencodereview/rule.json` | Per-project rules, can be committed to git |
|
|
742
|
-
| 3 | Global config | `~/.opencodereview/rule.json` | User-wide personal preferences |
|
|
743
|
-
| 4 (lowest) | System default | Embedded `system_rules.json` | Built-in rules covering common languages and file types |
|
|
744
|
-
|
|
745
|
-
### Rule File Format
|
|
746
|
-
|
|
747
|
-
Layers 1–3 share the same JSON format:
|
|
748
|
-
|
|
749
|
-
```json
|
|
750
|
-
{
|
|
751
|
-
"rules": [
|
|
752
|
-
{
|
|
753
|
-
"path": "force-api/**/*.java",
|
|
754
|
-
"rule": "All new methods must validate required parameters for null values",
|
|
755
|
-
"merge_system_rule": true
|
|
756
|
-
},
|
|
757
|
-
{
|
|
758
|
-
"path": "**/*mapper*.xml",
|
|
759
|
-
"rule": "Check SQL for injection risks, parameter errors, and missing closing tags"
|
|
760
|
-
}
|
|
761
|
-
]
|
|
762
|
-
}
|
|
763
|
-
```
|
|
764
|
-
|
|
765
|
-
- `path` supports `**` recursive matching and `{java,kt}` brace expansion.
|
|
766
|
-
- `merge_system_rule` is optional. When `true`, the matched built-in system rule is merged with this user rule; otherwise the user rule replaces the system rule.
|
|
767
|
-
- Within each layer, rules are evaluated in declaration order — the first match wins.
|
|
768
|
-
- If a rule file does not exist, it is silently skipped.
|
|
769
|
-
|
|
770
|
-
**The `rule` field supports both inline content and file paths.** The system auto-detects which one you mean:
|
|
771
|
-
|
|
772
|
-
1. If the value contains newlines → **inline content** (multi-line rules are never file paths).
|
|
773
|
-
2. If the value is a single line, contains no spaces, and ends with `.md` / `.txt` / `.markdown` → **file path**.
|
|
774
|
-
- Absolute paths (starting with `/`) are used directly.
|
|
775
|
-
- Relative paths are resolved against the project root. Path traversal (e.g. `../../etc/passwd.md`) is blocked. If not found, a `[WARN]` is emitted and the rule is cleared (no fallback to inline).
|
|
776
|
-
- The file must pass validation: whitelisted extension, ≤ 512 KB, and resolved symlink target must also be a whitelisted extension. If validation fails, the rule is cleared.
|
|
777
|
-
3. Otherwise → **inline content**.
|
|
778
|
-
|
|
779
|
-
```json
|
|
780
|
-
{
|
|
781
|
-
"rules": [
|
|
782
|
-
{
|
|
783
|
-
"path": "**/*mapper*.xml",
|
|
784
|
-
"rule": "docs/sql-rules.md"
|
|
785
|
-
},
|
|
786
|
-
{
|
|
787
|
-
"path": "**/*.java",
|
|
788
|
-
"rule": "Always check for null safety and resource leaks"
|
|
789
|
-
},
|
|
790
|
-
{
|
|
791
|
-
"path": "**/*.go",
|
|
792
|
-
"rule": "shared/go-concurrency.md"
|
|
793
|
-
},
|
|
794
|
-
{
|
|
795
|
-
"path": "**/*.py",
|
|
796
|
-
"rule": "/Users/me/team-rules/python.md"
|
|
797
|
-
}
|
|
798
|
-
]
|
|
799
|
-
}
|
|
800
|
-
```
|
|
801
|
-
|
|
802
|
-
- `docs/sql-rules.md` — relative path, resolved from `<project>/docs/sql-rules.md`.
|
|
803
|
-
- `Always check for null safety…` — inline string, used directly.
|
|
804
|
-
- `shared/go-concurrency.md` — relative path, same resolution.
|
|
805
|
-
- `/Users/me/team-rules/python.md` — absolute path, used directly.
|
|
806
|
-
|
|
807
|
-
> Absolute paths can access files outside the project directory — this is intentional. `rule.json` is authored by project maintainers, i.e. trusted input. Teams can store shared rules at a common path (e.g. `/opt/company-rules/`) instead of copying them into every project.
|
|
808
|
-
|
|
809
|
-
### Path Filtering
|
|
810
|
-
|
|
811
|
-
Rule files also support `include` and `exclude` fields to control which files enter the review scope:
|
|
812
|
-
|
|
813
|
-
```json
|
|
814
|
-
{
|
|
815
|
-
"rules": [
|
|
816
|
-
{"path": "**/*.java", "rule": "Check for null safety"}
|
|
817
|
-
],
|
|
818
|
-
"include": ["src/main/**/*.java", "lib/**/*.kt"],
|
|
819
|
-
"exclude": ["**/generated/**", "vendor/**"]
|
|
820
|
-
}
|
|
821
|
-
```
|
|
822
|
-
|
|
823
|
-
**Filter decision priority (highest to lowest):**
|
|
824
|
-
|
|
825
|
-
| Step | Condition | Result |
|
|
826
|
-
|------|-----------|--------|
|
|
827
|
-
| 1 | File is binary | Excluded |
|
|
828
|
-
| 2 | Path matches user `exclude` pattern | Excluded |
|
|
829
|
-
| 3 | File extension not in supported list | Excluded |
|
|
830
|
-
| 4 | `include` is configured and path matches | **Reviewed** (skips step 5) |
|
|
831
|
-
| 5 | Path matches built-in default exclude pattern (test files, etc.) | Excluded |
|
|
832
|
-
| 6 | None of the above | Reviewed |
|
|
833
|
-
|
|
834
|
-
**How it works:**
|
|
835
|
-
|
|
836
|
-
- `include` and `exclude` follow the same priority chain as review rules (`--rule` > project config > global config). The **highest-priority layer that has include/exclude configured** takes effect as a whole — patterns are not merged across layers.
|
|
837
|
-
- `exclude` always wins over `include` — a file matching both is excluded.
|
|
838
|
-
- `include` acts as a **bypass for built-in default exclude patterns** (e.g., test files), not as an exclusive allowlist — files not matching any `include` pattern still proceed through the default filter checks normally.
|
|
839
|
-
- Pattern syntax: supports `**` recursive matching, `*` single-segment matching, and `{a,b}` brace expansion. Matching is case-insensitive.
|
|
840
|
-
|
|
841
|
-
**Built-in default exclude patterns** (filters test files, etc. — can be overridden with `include`):
|
|
842
|
-
|
|
843
|
-
```
|
|
844
|
-
**/*_test.go, **/*Test.java, **/*Tests.java, **/*_test.rs,
|
|
845
|
-
**/*.test.{js,jsx,ts,tsx}, **/*.spec.{js,jsx,ts,tsx}, **/__tests__/**,
|
|
846
|
-
**/src/test/java/**/*.java, **/src/test/**/*.kt,
|
|
847
|
-
**/test/**/*_test.py, **/tests/**/*_test.py, **/*_test.py,
|
|
848
|
-
**/*_spec.rb, **/spec/**/*_spec.rb, **/oh_modules/**
|
|
849
|
-
```
|
|
850
|
-
|
|
851
|
-
## Configuration Reference
|
|
852
|
-
|
|
853
|
-
Config file: `~/.opencodereview/config.json`
|
|
854
|
-
|
|
855
|
-
| Key | Type | Example |
|
|
856
|
-
|-----|------|---------|
|
|
857
|
-
| `provider` | string | `anthropic` \| `openai` \| `dashscope` \| `deepseek` \| `z-ai` |
|
|
858
|
-
| `providers.<name>.api_key` | string | Provider-specific API key |
|
|
859
|
-
| `providers.<name>.url` | string | Provider base URL override |
|
|
860
|
-
| `providers.<name>.protocol` | string | `anthropic` \| `openai` \| `openai-responses` |
|
|
861
|
-
| `providers.<name>.model` | string | Model name for the provider |
|
|
862
|
-
| `providers.<name>.models` | array | Optional provider model list for interactive selection |
|
|
863
|
-
| `providers.<name>.auth_header` | string | `x-api-key` \| `authorization` |
|
|
864
|
-
| `providers.<name>.extra_body` | object | JSON object merged into every request body |
|
|
865
|
-
| `providers.<name>.timeout_sec` | integer | Per-request HTTP timeout in seconds (default: `300`) |
|
|
866
|
-
| `providers.<name>.extra_headers` | string | Comma-separated `key=value` HTTP headers |
|
|
867
|
-
| `custom_providers.<name>.*` | — | Same fields as `providers.<name>.*`, including optional `models` |
|
|
868
|
-
| `llm.url` | string | `https://api.openai.com/v1/chat/completions` |
|
|
869
|
-
| `llm.auth_token` | string | `sk-xxxxxxx` |
|
|
870
|
-
| `llm.auth_header` | string | Anthropic only: `x-api-key` \| `authorization` |
|
|
871
|
-
| `llm.extra_body` | object | JSON object merged into every request body |
|
|
872
|
-
| `llm.timeout_sec` | integer | Per-request HTTP timeout in seconds (default: `300`) |
|
|
873
|
-
| `llm.extra_headers` | string | Comma-separated `key=value` HTTP headers |
|
|
874
|
-
| `llm.model` | string | `claude-opus-4-6` |
|
|
875
|
-
| `llm.protocol` | string | `anthropic` \| `openai` \| `openai-responses`; takes priority over `llm.use_anthropic` |
|
|
876
|
-
| `llm.use_anthropic` | boolean | `true` \| `false` (legacy; prefer `llm.protocol`) |
|
|
877
|
-
| `mcp_servers.<name>.command` | string | Command to start the MCP server |
|
|
878
|
-
| `mcp_servers.<name>.args` | array | Command-line arguments for the MCP server |
|
|
879
|
-
| `mcp_servers.<name>.env` | array | Environment variables in `KEY=VALUE` format |
|
|
880
|
-
| `mcp_servers.<name>.tools` | array | Allowed tool names (empty = all tools) |
|
|
881
|
-
| `mcp_servers.<name>.setup` | string | Setup command to run before starting the server |
|
|
882
|
-
| `language` | string | Any language name, e.g. `English`, `Chinese` (default: `English`) |
|
|
883
|
-
| `telemetry.enabled` | boolean | `true` \| `false` |
|
|
884
|
-
| `telemetry.exporter` | string | `console` \| `otlp` |
|
|
885
|
-
| `telemetry.otlp_endpoint` | string | OTLP collector address |
|
|
886
|
-
| `telemetry.content_logging` | boolean | Include prompts in telemetry |
|
|
887
|
-
|
|
888
|
-
Environment variables take precedence over the config file.
|
|
889
|
-
|
|
890
|
-
### MCP Server
|
|
891
|
-
|
|
892
|
-
Open Code Review supports [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) servers, allowing the review agent to use external tools during code review via the stdio transport.
|
|
893
|
-
|
|
894
|
-
Configure MCP servers via the CLI:
|
|
895
|
-
|
|
896
|
-
```bash
|
|
897
|
-
# Add an MCP server
|
|
898
|
-
ocr config set mcp_servers.<name>.command <command>
|
|
899
|
-
ocr config set mcp_servers.<name>.args '["arg1","arg2"]'
|
|
900
|
-
ocr config set mcp_servers.<name>.env '["KEY=VALUE"]'
|
|
901
|
-
ocr config set mcp_servers.<name>.tools '["tool_name"]'
|
|
902
|
-
ocr config set mcp_servers.<name>.setup '<setup command>'
|
|
903
|
-
|
|
904
|
-
# Delete an MCP server
|
|
905
|
-
ocr config unset mcp_servers.<name>
|
|
906
|
-
```
|
|
907
|
-
|
|
908
|
-
| Field | Required | Description |
|
|
909
|
-
|-------|----------|-------------|
|
|
910
|
-
| `command` | Yes | The executable command to start the MCP server |
|
|
911
|
-
| `args` | No | Command-line arguments passed to the server |
|
|
912
|
-
| `env` | No | Environment variables in `KEY=VALUE` format |
|
|
913
|
-
| `tools` | No | Allowed tool names; if empty, all tools from the server are available |
|
|
914
|
-
| `setup` | No | A shell command to run before starting the server (e.g. build an index) |
|
|
915
|
-
|
|
916
|
-
> **Note:** If an MCP tool's name conflicts with a built-in tool, it will be skipped with a warning. The `setup` command has a 5-minute timeout.
|
|
917
|
-
|
|
918
|
-
**Example: Add [CodeGraph](https://github.com/nicholasgasior/codegraph) for code structure analysis**
|
|
919
|
-
|
|
920
|
-
```bash
|
|
921
|
-
ocr config set mcp_servers.codegraph.command codegraph
|
|
922
|
-
ocr config set mcp_servers.codegraph.args '["serve","--mcp"]'
|
|
923
|
-
ocr config set mcp_servers.codegraph.tools '["codegraph_explore"]'
|
|
924
|
-
ocr config set mcp_servers.codegraph.setup 'codegraph init && codegraph index'
|
|
925
|
-
```
|
|
926
|
-
|
|
927
|
-
### Environment Variables
|
|
928
|
-
|
|
929
|
-
| Variable | Purpose |
|
|
930
|
-
|----------|---------|
|
|
931
|
-
| `OCR_LLM_URL` | LLM API endpoint URL |
|
|
932
|
-
| `OCR_LLM_TOKEN` | API key / auth token |
|
|
933
|
-
| `OCR_LLM_AUTH_HEADER` | Anthropic auth header (`x-api-key` or `authorization`) |
|
|
934
|
-
| `OCR_LLM_EXTRA_HEADERS` | Comma-separated `key=value` HTTP headers |
|
|
935
|
-
| `OCR_LLM_MODEL` | Model name |
|
|
936
|
-
| `OCR_LLM_PROTOCOL` | Protocol: `anthropic` \| `openai` \| `openai-responses`; takes priority over `OCR_USE_ANTHROPIC` |
|
|
937
|
-
| `OCR_LLM_TIMEOUT` | Per-request HTTP timeout in seconds (overrides config file `timeout_sec`) |
|
|
938
|
-
| `OCR_USE_ANTHROPIC` | `true` = Anthropic, `false` = OpenAI Chat Completions (legacy; prefer `OCR_LLM_PROTOCOL`) |
|
|
939
|
-
|
|
940
|
-
## Telemetry
|
|
941
|
-
|
|
942
|
-
OpenTelemetry integration for observability (spans, metrics). Disabled by default.
|
|
943
|
-
|
|
944
|
-
```bash
|
|
945
|
-
ocr config set telemetry.enabled true
|
|
946
|
-
ocr config set telemetry.exporter otlp
|
|
947
|
-
ocr config set telemetry.otlp_endpoint localhost:4317
|
|
948
|
-
```
|
|
949
|
-
|
|
950
|
-
Set `telemetry.content_logging` to include LLM prompts and responses in exported data.
|
|
951
|
-
|
|
952
|
-
**Protocol selection:** Set the environment variable `OTEL_EXPORTER_OTLP_PROTOCOL` to choose the export protocol:
|
|
953
|
-
|
|
954
|
-
| Value | Transport | Notes |
|
|
955
|
-
|---|---|---|
|
|
956
|
-
| `grpc` (default) | gRPC | Default port 4317 |
|
|
957
|
-
| `http/protobuf` | HTTP | Default port 4318 |
|
|
958
|
-
|
|
959
|
-
**Endpoint format:** `telemetry.otlp_endpoint` expects a base URL in `host:port` or `http://host:port` format, without a path component. The SDK appends the signal path (e.g. `/v1/traces`) automatically per the [OTLP specification](https://opentelemetry.io/docs/specs/otlp/#otlphttp-request).
|
|
960
|
-
|
|
158
|
+
## Documentation
|
|
159
|
+
|
|
160
|
+
Full documentation lives at **[open-codereview.ai/docs](https://open-codereview.ai/docs)**:
|
|
161
|
+
|
|
162
|
+
- [Quickstart](https://open-codereview.ai/docs/quickstart) — install and run your first review
|
|
163
|
+
- [Installation](https://open-codereview.ai/docs/installation) — all platforms and package managers
|
|
164
|
+
- [CLI Reference](https://open-codereview.ai/docs/cli-reference) — every command and flag
|
|
165
|
+
- [Review Rules](https://open-codereview.ai/docs/review-rules) — customize review rules with path filtering and targeting
|
|
166
|
+
- [Configuration](https://open-codereview.ai/docs/configuration) — config keys and environment variables
|
|
167
|
+
- [MCP Server](https://open-codereview.ai/docs/mcp) — extend the review agent with external tools
|
|
168
|
+
- Coding Agent Integrations — integrate OCR into Claude Code, Codex, Cursor, etc.
|
|
169
|
+
- [Skill](https://open-codereview.ai/docs/agent-skill) — install as a reusable agent skill
|
|
170
|
+
- [Plugin](https://open-codereview.ai/docs/claude-code) — install as a Claude Code / Codex / Cursor plugin
|
|
171
|
+
- [Delegation Mode](https://open-codereview.ai/docs/delegate) — let your agent review using its own LLM
|
|
172
|
+
- [CI/CD Integration](https://open-codereview.ai/docs/cicd) — GitHub Actions, GitLab CI, GitFlic CI, and Gerrit integration
|
|
173
|
+
- [Session Viewer](https://open-codereview.ai/docs/viewer) — browse and replay review sessions in browser
|
|
174
|
+
- [Telemetry](https://open-codereview.ai/docs/telemetry) — OpenTelemetry integration for observability
|
|
175
|
+
- [FAQ](https://open-codereview.ai/docs/faq) — common questions and troubleshooting
|
|
961
176
|
|
|
962
177
|
## Contributing
|
|
963
178
|
|