|
| 1 | +# sight |
| 2 | + |
| 3 | +AI-powered code review on diffs. Parses unified diffs, enriches with surrounding code context and git history, then runs parallel multi-concern reviews through an LLM provider. |
| 4 | + |
| 5 | +## Design |
| 6 | + |
| 7 | +- **Library only** — no CLI, no binary |
| 8 | +- **No LLM SDK dependency** — defines a Provider interface; consumers implement it |
| 9 | +- **No opinions** — consumers inject their own LLM client (e.g., via eyrie) |
| 10 | + |
| 11 | +## Install |
| 12 | + |
| 13 | +```bash |
| 14 | +go get github.com/GrayCodeAI/sight@latest |
| 15 | +``` |
| 16 | + |
| 17 | +## Usage |
| 18 | + |
| 19 | +### One-shot review |
| 20 | + |
| 21 | +```go |
| 22 | +result, err := sight.Review(ctx, diffText, |
| 23 | + sight.WithProvider(myProvider), |
| 24 | + sight.Thorough, |
| 25 | +) |
| 26 | +for _, f := range result.Findings { |
| 27 | + fmt.Printf("[%s] %s:%d - %s\n", f.Severity, f.File, f.Line, f.Message) |
| 28 | +} |
| 29 | +``` |
| 30 | + |
| 31 | +### Reusable reviewer |
| 32 | + |
| 33 | +```go |
| 34 | +r := sight.NewReviewer(sight.WithProvider(p), sight.Thorough) |
| 35 | +result1, _ := r.Review(ctx, diff1) |
| 36 | +result2, _ := r.Review(ctx, diff2) |
| 37 | +``` |
| 38 | + |
| 39 | +### Provider interface |
| 40 | + |
| 41 | +Implement this with any LLM client: |
| 42 | + |
| 43 | +```go |
| 44 | +type Provider interface { |
| 45 | + Complete(ctx context.Context, messages []Message) (string, error) |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +## Presets |
| 50 | + |
| 51 | +| Preset | Concerns | Use case | |
| 52 | +|--------|----------|----------| |
| 53 | +| Quick | security, correctness | Fast PR checks | |
| 54 | +| Standard | all (default) | Balanced review | |
| 55 | +| Thorough | all + deeper analysis | Critical code | |
| 56 | +| SecurityFocus | security only | Security audit | |
| 57 | +| CI | all + fail-on threshold | CI/CD gates | |
| 58 | + |
| 59 | +## Findings |
| 60 | + |
| 61 | +Each finding includes: |
| 62 | +- **Concern**: security, performance, correctness, maintainability, testing |
| 63 | +- **Severity**: critical, high, medium, low, info |
| 64 | +- **File** and **Line**: exact location in diff |
| 65 | +- **Message**: human-readable description |
| 66 | +- **Fix**: suggested code fix |
| 67 | +- **CWE**: reference (e.g., CWE-79) |
| 68 | + |
| 69 | +## Output Formats |
| 70 | + |
| 71 | +- Inline comments (GitHub/GitLab PR comments) |
| 72 | +- SARIF (static analysis interchange) |
| 73 | +- Human-readable terminal output |
| 74 | + |
| 75 | +## Configuration |
| 76 | + |
| 77 | +File-based config via `.sight.toml`: |
| 78 | + |
| 79 | +```toml |
| 80 | +fail-on = "high" |
| 81 | +exclude = ["vendor/", "generated/"] |
| 82 | +concerns = ["security", "performance", "correctness"] |
| 83 | +``` |
| 84 | + |
| 85 | +## Testing |
| 86 | + |
| 87 | +```bash |
| 88 | +make test # Unit tests |
| 89 | +make test-race # With race detector |
| 90 | +make bench # Benchmarks |
| 91 | +make cover # Coverage report |
| 92 | +``` |
| 93 | + |
| 94 | +## License |
| 95 | + |
| 96 | +MIT |
0 commit comments