c76362af953b9294712b641220adc94a307cef04
The LLM was treating the diff as complete file context and flagging "missing imports" for symbols that exist in unchanged portions of the file. Added explicit instructions to the system prompt: - Clarify that the diff is partial; unchanged code already exists - Explicitly instruct: do not flag missing imports/types unless the diff introduces a new usage without a corresponding addition - Add rule: never flag undefined symbols that could exist in the unchanged portions
review-bot
Automated code review bot for Gitea. Fetches a pull request diff, sends it to an LLM for analysis, and posts a structured review back to the PR.
Features
- Fetches PR metadata, diff, and CI status from Gitea API
- Sends context-rich prompts to any OpenAI-compatible LLM
- Parses structured JSON review responses
- Posts formatted reviews (APPROVE / REQUEST_CHANGES) back to Gitea
- Supports custom coding conventions via repo files
- Zero external dependencies — Go stdlib only
Usage
review-bot \
--gitea-url https://gitea.example.com \
--repo owner/name \
--pr 42 \
--reviewer-token "$GITEA_TOKEN" \
--llm-base-url https://api.openai.com/v1 \
--llm-api-key "$OPENAI_API_KEY" \
--llm-model gpt-4 \
--reviewer-name "Sonnet" \
--conventions-file CONVENTIONS.md \
--dry-run
Environment Variables
All flags can be set via environment variables:
| Flag | Env Var | Required | Description |
|---|---|---|---|
--gitea-url |
GITEA_URL |
Yes | Gitea instance base URL |
--repo |
GITEA_REPO |
Yes | Repository in owner/name format |
--pr |
PR_NUMBER |
Yes | Pull request number |
--reviewer-token |
REVIEWER_TOKEN |
Yes | Gitea API token for posting reviews |
--llm-base-url |
LLM_BASE_URL |
Yes | OpenAI-compatible API base URL |
--llm-api-key |
LLM_API_KEY |
Yes | LLM API key |
--llm-model |
LLM_MODEL |
Yes | Model identifier |
--reviewer-name |
REVIEWER_NAME |
No | Display name in review footer |
--conventions-file |
CONVENTIONS_FILE |
No | Path to conventions file in repo |
--dry-run |
— | No | Print review to stdout instead of posting |
Adding to a Gitea Repository
-
Build the binary or use the CI workflow approach (build in CI).
-
Add secrets to your Gitea repo (Settings → Actions → Secrets):
SONNET_REVIEW_TOKEN— Gitea token for the Sonnet reviewer accountGPT_REVIEW_TOKEN— Gitea token for the GPT reviewer accountLLM_BASE_URL— Your LLM API endpointLLM_API_KEY— Your LLM API key
-
Copy
.gitea/workflows/ci.ymlto your repo (or adapt it). -
On every PR, the bot will:
- Run tests and vet
- Build review-bot
- Post reviews from each configured LLM reviewer
Development
# Run tests
go test ./...
# Run vet
go vet ./...
# Build
go build -o review-bot ./cmd/review-bot
# Integration tests (requires env vars)
go test -tags=integration ./...
Architecture
cmd/review-bot/ CLI entrypoint
gitea/ Gitea API client
llm/ OpenAI-compatible LLM client
review/ Prompt building, response parsing, formatting
License
MIT
Description