700f186023
- CLI binary with flag/env var configuration - Gitea API client (PR metadata, diff, CI status, post review) - OpenAI-compatible LLM client - Structured review prompt with conventions support - JSON response parser with validation - Markdown review formatter for Gitea - CI failure auto-detection (REQUEST_CHANGES) - Dry-run mode for testing
59 lines
1.6 KiB
Markdown
59 lines
1.6 KiB
Markdown
# review-bot
|
|
|
|
AI-powered code review bot for Gitea pull requests.
|
|
|
|
## Overview
|
|
|
|
`review-bot` fetches a PR's diff, title, description, and CI status from Gitea, sends it to an LLM via an OpenAI-compatible API, and posts a structured code review back to Gitea.
|
|
|
|
## Usage
|
|
|
|
```bash
|
|
review-bot \
|
|
--gitea-url https://gitea.weiker.me \
|
|
--repo owner/name \
|
|
--pr 123 \
|
|
--reviewer-name "sonnet-review-bot" \
|
|
--reviewer-token "$(cat /path/to/token)" \
|
|
--llm-base-url "https://proxy.example.com/v1" \
|
|
--llm-api-key "key" \
|
|
--llm-model "anthropic--claude-4.6-sonnet" \
|
|
--conventions-file "CLAUDE.md"
|
|
```
|
|
|
|
All flags can also be set via environment variables:
|
|
|
|
| Flag | Env Var |
|
|
|------|---------|
|
|
| `--gitea-url` | `GITEA_URL` |
|
|
| `--repo` | `GITEA_REPO` |
|
|
| `--pr` | `PR_NUMBER` |
|
|
| `--reviewer-name` | `REVIEWER_NAME` |
|
|
| `--reviewer-token` | `REVIEWER_TOKEN` |
|
|
| `--llm-base-url` | `LLM_BASE_URL` |
|
|
| `--llm-api-key` | `LLM_API_KEY` |
|
|
| `--llm-model` | `LLM_MODEL` |
|
|
| `--conventions-file` | `CONVENTIONS_FILE` |
|
|
|
|
Use `--dry-run` to print the review to stdout without posting.
|
|
|
|
## Build
|
|
|
|
```bash
|
|
go build -o review-bot ./cmd/review-bot
|
|
```
|
|
|
|
## Architecture
|
|
|
|
- `cmd/review-bot/main.go` — CLI entry point
|
|
- `gitea/client.go` — Gitea API interactions (fetch PR, diff, CI status, post review)
|
|
- `llm/client.go` — OpenAI-compatible chat completion client
|
|
- `review/prompt.go` — System/user prompt construction
|
|
- `review/parser.go` — Parse LLM JSON response
|
|
- `review/formatter.go` — Format markdown review body
|
|
|
|
## Constraints
|
|
|
|
- Pure Go stdlib, no external dependencies
|
|
- No CGO
|