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
1.6 KiB
1.6 KiB
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
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
go build -o review-bot ./cmd/review-bot
Architecture
cmd/review-bot/main.go— CLI entry pointgitea/client.go— Gitea API interactions (fetch PR, diff, CI status, post review)llm/client.go— OpenAI-compatible chat completion clientreview/prompt.go— System/user prompt constructionreview/parser.go— Parse LLM JSON responsereview/formatter.go— Format markdown review body
Constraints
- Pure Go stdlib, no external dependencies
- No CGO