diff --git a/README.md b/README.md index 6fc9f5b..cc847d4 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,35 @@ codereview ask https://github.com/org/repo/pull/123 "Is the retry loop safe unde Nothing is written to a PR unless you pass `--post`. +Prebuilt binaries for Linux, macOS and Windows are on the [Releases](https://github.com/divmora/code-review-bot/releases) page. There's also a Docker image whose entrypoint is the `codereview` binary: + + +```bash +docker run --rm -e CODEREVIEW_MODEL -e ANTHROPIC_API_KEY -e GITHUB_TOKEN \ + ghcr.io/divmora/code-review-bot:0.4.0 review https://github.com/org/repo/pull/123 + +# local changes: mount the repository at /workspace +docker run --rm -v "$PWD:/workspace" -e CODEREVIEW_MODEL -e ANTHROPIC_API_KEY \ + ghcr.io/divmora/code-review-bot:0.4.0 review --local +``` + + +## How it works + +``` + PR diff + description + .codereview.yaml (from the target branch) + │ + ├─ 1. pick up where the last run stopped (state is kept in the bot's own PR comment) + ├─ 2. skip lockfiles, generated, vendored and binary files; scan added lines for secrets + ├─ 3. build token-budgeted batches: small files whole, large ones as excerpts around changes + ├─ 4. review the batches in parallel (structured output, retries, fallback models) + ├─ 5. drop every comment that isn't on a line the PR changed + ├─ 6. verification pass: remove false positives, turn uncertain findings into questions + └─ 7. with --post: inline comments, walkthrough summary, scores, labels, commit status +``` + +The model only proposes findings; the deterministic checks in steps 2 and 5 decide what can be posted. + ## Switching providers Choose the model in order of precedence: `--model` flag, `CODEREVIEW_MODEL` env var, then `model:` in `codereview.yaml`. The value is a **profile name** from the config or a direct **`provider:model`** spec. Only the first colon separates the two, so `bedrock:anthropic.x-v1:0` and `ollama:qwen2.5-coder:14b` work. @@ -110,6 +139,18 @@ Every response is also parsed leniently (fenced or prose-wrapped JSON), so weake `--auto` applies the repo's `auto_review` rules (drafts, title keywords, base branches). `--fail-on ` exits with code 3 so you can gate merges. `--format sarif` produces output for code-scanning dashboards. +Tips for CI: +- **Keep it advisory.** The GitLab example sets `allow_failure: true` so a provider outage never blocks a pipeline. Add `--fail-on critical` only when you want the review to gate merges. +- **Drafts are skipped** with `--auto` unless `auto_review.drafts: true`. So are closed PRs and commits that were already reviewed. +- **Self-managed GitLab** is detected from `CI_SERVER_URL` (or `GITLAB_URL`). If it uses a private CA, add the CA to the image or point `SSL_CERT_FILE` at it. As a last resort, set `skip_tls_verify` for that instance in `codereview.yaml`: + + ```yaml + gitlab: + - base_url: https://gitlab.internal.example.com + token: ${GITLAB_TOKEN} + skip_tls_verify: true # only for self-signed certificates you can't install + ``` + ## Use from another program The CLI is designed to be driven by schedulers such as Divmora Code Review Console. Its flags, environment variables, JSON output and exit codes are the interface; the Go packages are not, apart from `pkg/vcs` and `pkg/diff`: @@ -231,6 +272,16 @@ auto_review: ignore_title_keywords: ["WIP", "[skip review]"] ``` +### Review profiles + +| Profile | Reports | +|---|---| +| `chill` | Likely bugs, security problems, data loss and serious performance issues only. No style or naming points. | +| `balanced` (default) | Bugs, security and performance, plus maintainability problems that will clearly cause trouble. Skips pure style preferences. | +| `assertive` | Everything above, plus readability, naming, missing tests and documentation gaps. Small polish items are marked as nitpicks. | + +Set it in `.codereview.yaml` or with `--profile`. The profile also sets the default minimum severity and confidence for posted comments. + ## CLI reference | Command | Purpose | @@ -255,6 +306,12 @@ make lint Architecture and contributor notes are in [AGENTS.md](AGENTS.md); planned work is in [ROADMAP.md](ROADMAP.md). +## Contributing + +- **Contributions:** see [CONTRIBUTING.md](CONTRIBUTING.md) for pull requests and issues. +- **Code of Conduct:** [Divmora Code of Conduct](https://github.com/divmora/.github/blob/main/CODE_OF_CONDUCT.md), inherited from the organisation. +- **Security:** report vulnerabilities privately as described in [SECURITY.md](SECURITY.md). + ## License Licensed under the **Apache License, Version 2.0**. It is free to use, modify and run in any environment, including commercial and production use, with no commercial license required. See [LICENSE](LICENSE). diff --git a/ROADMAP.md b/ROADMAP.md index d5fb205..ba89b3a 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -16,8 +16,6 @@ Active, assigned work belongs in GitHub Issues instead. with tree-sitter or LSP and include them in the prompt. - [ ] **Linter and SAST integration**: run configured tools (golangci-lint, eslint, semgrep, gitleaks) and let the model triage and explain their findings. -- [ ] **Two-pass verification**: an optional second model call that challenges each finding before - posting, to cut false positives further. - [ ] **Docstring and unit-test generation** commands. - [ ] **Prompt caching** for providers that support it (Anthropic, Bedrock, Gemini, OpenAI) to cut the cost of shared system prompts across batches. diff --git a/docs/index.html b/docs/index.html index 32b7530..f98bbe0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -159,6 +159,16 @@ .console { display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, var(--panel)), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; } .console p { color: var(--muted); margin: 6px 0 0; max-width: 640px; } +/* how it works */ +ol.flow { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; counter-reset: step; } +@media (max-width: 920px) { ol.flow { grid-template-columns: repeat(2, minmax(0, 1fr)); } } +@media (max-width: 520px) { ol.flow { grid-template-columns: minmax(0, 1fr); } } +ol.flow li { counter-increment: step; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 16px; } +ol.flow li::before { content: counter(step); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; margin-bottom: 10px; font-weight: 700; font-size: 14px; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); } +ol.flow li p { margin: 0; color: var(--muted); font-size: 14px; } +.card .lvl { display: inline-block; font-size: 12px; font-weight: 600; color: var(--accent-2); margin-left: 6px; } +.note { margin-top: 18px; } +.note li { font-size: 14.5px; } footer { padding: 36px 0 48px; color: var(--faint); font-size: 14px; border-top: 1px solid var(--line); } footer .wrap { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; } footer a { color: var(--muted); } @@ -186,6 +196,7 @@ Code Review Bot