Skip to content

Commit f08a048

Browse files
committed
update README.md
1 parent 925d454 commit f08a048

4 files changed

Lines changed: 371 additions & 281 deletions

File tree

.goreleaser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ archives:
3434
files:
3535
- LICENSE
3636
- README.md
37-
- README-zh-CN.md
37+
- README-en.md
3838

3939
checksum:
4040
name_template: checksums.txt

README-en.md

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
# Zadig Review Agent
2+
3+
[![CI](https://github.com/koderover/zadig-review-agent/actions/workflows/ci.yml/badge.svg)](https://github.com/koderover/zadig-review-agent/actions/workflows/ci.yml)
4+
[![CodeQL](https://github.com/koderover/zadig-review-agent/actions/workflows/codeql.yml/badge.svg)](https://github.com/koderover/zadig-review-agent/actions/workflows/codeql.yml)
5+
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
6+
7+
Read-only, LLM-powered code review for local development and CI workflows.
8+
9+
English | [简体中文](README.md)
10+
11+
## What it does
12+
13+
Zadig Review Agent reviews Git changes, asks a configured language model to identify concrete defects, validates every finding against the actual diff, and produces console, JSON, and Markdown reports. It focuses on correctness, security, concurrency, resource management, performance, compatibility, and missing critical tests.
14+
15+
Key properties:
16+
17+
- reviews a workspace, one commit, or a ref range;
18+
- supports OpenAI, Gemini, and Anthropic protocols through their official Go SDKs;
19+
- applies built-in or repository-specific review rules;
20+
- exposes only read-only repository tools to the model;
21+
- returns deterministic exit codes suitable for CI quality gates;
22+
- never writes comments back to a forge or modifies the reviewed repository.
23+
24+
This project is a review assistant, not a substitute for tests, security analysis, or human review. Model output can be incomplete or incorrect.
25+
26+
## Requirements
27+
28+
- Go 1.24 or later when building from source
29+
- Git and a Git repository to review
30+
- credentials for one supported model provider (not needed for `--preview`)
31+
32+
## Installation
33+
34+
### Go install
35+
36+
After the first tagged release is available:
37+
38+
```bash
39+
go install github.com/koderover/zadig-review-agent@latest
40+
```
41+
42+
`go install` honors the standard `GOPROXY` setting. To use a trusted organization or regional proxy for one installation:
43+
44+
```bash
45+
GOPROXY=https://your-go-proxy.example,direct \
46+
go install github.com/koderover/zadig-review-agent@latest
47+
```
48+
49+
Use an explicit version such as `@v0.1.0` when reproducible installation is more important than tracking the latest release.
50+
51+
### Release archive
52+
53+
Download the archive for Linux, macOS, or Windows from [GitHub Releases](https://github.com/koderover/zadig-review-agent/releases), then verify it with `checksums.txt`.
54+
55+
### Build from source
56+
57+
```bash
58+
git clone https://github.com/koderover/zadig-review-agent.git
59+
cd zadig-review-agent
60+
make build
61+
./bin/zadig-review-agent version
62+
```
63+
64+
## Quick start
65+
66+
Preview which files and rules would be used without contacting a model:
67+
68+
```bash
69+
zadig-review-agent review --preview
70+
```
71+
72+
Configure a provider. Keeping the API key in an environment variable avoids writing it to disk or shell history:
73+
74+
```bash
75+
zadig-review-agent config set model.protocol openai
76+
zadig-review-agent config set model.name gpt-4o
77+
zadig-review-agent config set model.endpoint https://api.openai.com/v1
78+
export ZADIG_REVIEW_MODEL_API_KEY='your-api-key'
79+
```
80+
81+
Review the current workspace:
82+
83+
```bash
84+
zadig-review-agent review
85+
```
86+
87+
Review a commit or a range:
88+
89+
```bash
90+
zadig-review-agent review --commit <sha>
91+
zadig-review-agent review --from origin/main --to HEAD
92+
```
93+
94+
Use `zadig-review-agent help` and `zadig-review-agent review --help` for the complete command-line reference.
95+
96+
## Configuration
97+
98+
The default configuration file is `~/.zadig-review-agent/config.yaml`. Start from [.zadig-review-agent.example.yaml](.zadig-review-agent.example.yaml), or use `config set`:
99+
100+
```bash
101+
zadig-review-agent config path
102+
zadig-review-agent config show
103+
zadig-review-agent config get model.name
104+
zadig-review-agent config set output.language en-US
105+
```
106+
107+
Configuration precedence is:
108+
109+
```text
110+
built-in defaults < configuration file < ZADIG_REVIEW_MODEL_* < review flags
111+
```
112+
113+
Supported model environment variables are:
114+
115+
```text
116+
ZADIG_REVIEW_MODEL_PROTOCOL
117+
ZADIG_REVIEW_MODEL_NAME
118+
ZADIG_REVIEW_MODEL_ENDPOINT
119+
ZADIG_REVIEW_MODEL_TIMEOUT
120+
ZADIG_REVIEW_MODEL_API_KEY
121+
```
122+
123+
`config show` redacts the API key. `config get model.api_key` intentionally returns the real value, so avoid printing it in logs.
124+
125+
## Review rules
126+
127+
Rules are declarative JSON data and cannot execute code. They are loaded in this order:
128+
129+
1. `--rule <path>`
130+
2. `<repository>/.zadig-review/rules.json`
131+
3. `~/.zadig-review/rules.json`
132+
4. embedded system rules
133+
134+
See [.zadig-review/rules.example.json](.zadig-review/rules.example.json) and [.zadig-review/docs/go-review.md](.zadig-review/docs/go-review.md). Check the resolved rule for a path with:
135+
136+
```bash
137+
zadig-review-agent rules check internal/reviewer/reviewer.go
138+
```
139+
140+
## CI usage
141+
142+
The `--ci` flag selects concise console output. Explicit report paths are convenient for CI artifacts:
143+
144+
```bash
145+
zadig-review-agent review \
146+
--from origin/main \
147+
--to HEAD \
148+
--ci \
149+
--output-json "$PWD/review-report.json" \
150+
--output-md "$PWD/review-report.md"
151+
```
152+
153+
Exit codes are stable:
154+
155+
| Code | Meaning |
156+
| --- | --- |
157+
| `0` | Review completed and no finding matched `fail_on`. |
158+
| `1` | Review completed and at least one finding matched `fail_on`. |
159+
| `2` | Configuration, Git, provider, filtering, or review processing was incomplete. |
160+
| `130` | The process was canceled. |
161+
162+
The default quality gate fails on `critical` and `high` findings. Configure it with `review.fail_on` or `--fail-on`.
163+
164+
## Privacy and security
165+
166+
- Diffs, rule text, and repository content requested through read-only tools are sent to the model endpoint you configure. Review the provider's data policy before using sensitive code.
167+
- JSON reports retain detailed tool output and raw model responses for diagnostics and can contain source code. Reports and configuration files are created with restricted permissions, but you must protect, retain, and delete them according to your own policy.
168+
- The agent does not provide the model with shell, network, or write-file tools and does not execute repository-provided commands or configuration.
169+
- API keys are not inserted into prompts or reports. Prefer environment variables or a secret manager in CI.
170+
- The project has no telemetry service.
171+
172+
Please report vulnerabilities according to [SECURITY.md](SECURITY.md), not through a public issue.
173+
174+
## Troubleshooting
175+
176+
### Model is not configured
177+
178+
Set `model.name` and the provider settings, or export the corresponding `ZADIG_REVIEW_MODEL_*` variables. `--preview` works without model credentials.
179+
180+
### A range review cannot resolve its base
181+
182+
Both refs must exist locally. Fetch the target branch before running the review, for example `git fetch origin main`.
183+
184+
### A file is unexpectedly excluded
185+
186+
Run the same review with `--preview`, then inspect the exclusion reason and resolved rule. Use `rules check` for a single path.
187+
188+
### The review exits with code 2
189+
190+
Inspect warnings and errors in the console or JSON report. An incomplete model tool loop, token limit, relocation, or filtering phase intentionally cannot pass the quality gate.
191+
192+
## Development
193+
194+
```bash
195+
make help
196+
make check
197+
```
198+
199+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the contribution workflow and [DESIGN.md](DESIGN.md) for implementation details.
200+
201+
## Releasing
202+
203+
Release configuration lives in [.goreleaser.yaml](.goreleaser.yaml) and requires GoReleaser v2. On macOS, install it with Homebrew:
204+
205+
```bash
206+
brew install goreleaser
207+
```
208+
209+
Alternatively, install it with Go:
210+
211+
```bash
212+
go install github.com/goreleaser/goreleaser/v2@latest
213+
```
214+
215+
Before a release, run all checks and a local snapshot. Snapshot artifacts are written to `dist/` and are not uploaded to GitHub:
216+
217+
```bash
218+
make check
219+
goreleaser check
220+
goreleaser release --snapshot --clean
221+
```
222+
223+
### Automated tag release (recommended)
224+
225+
Create and push a semantic `vX.Y.Z` tag:
226+
227+
```bash
228+
git tag -a v0.1.0 -m "Release v0.1.0"
229+
git push origin v0.1.0
230+
```
231+
232+
The [Release workflow](.github/workflows/release.yml) then runs the tests, builds amd64/arm64 archives for Linux, macOS, and Windows, generates SHA-256 checksums, and creates the GitHub Release.
233+
234+
### Manual local release
235+
236+
A manual release requires a GitHub token with repository Contents read/write access. Because pushing a tag triggers the automated release, temporarily disable the Release workflow and re-enable it afterward:
237+
238+
```bash
239+
git tag -a v0.1.0 -m "Release v0.1.0"
240+
gh workflow disable release.yml
241+
git push origin v0.1.0
242+
243+
GITHUB_TOKEN="$(gh auth token)" goreleaser release --clean
244+
245+
gh workflow enable release.yml
246+
```
247+
248+
Ensure that `release.yml` is re-enabled whether the manual release succeeds or fails. Never run automated and manual releases for the same tag, because their artifacts will conflict.
249+
250+
## License
251+
252+
Licensed under the [Apache License 2.0](LICENSE).

0 commit comments

Comments
 (0)