|
1 | | -# sight |
| 1 | +<p align="center"> |
| 2 | + <h1 align="center">Sight</h1> |
| 3 | + <p align="center"> |
| 4 | + <strong>AI-powered code review for diffs</strong> |
| 5 | + </p> |
| 6 | + <p align="center"> |
| 7 | + <a href="https://golang.org/"><img src="https://img.shields.io/badge/Go-1.23+-00ADD8?style=flat-square&logo=go&logoColor=white" alt="Go"></a> |
| 8 | + <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="License"></a> |
| 9 | + <a href="https://github.com/GrayCodeAI/sight/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/GrayCodeAI/sight/ci.yml?style=flat-square&label=tests" alt="CI"></a> |
| 10 | + </p> |
| 11 | +</p> |
2 | 12 |
|
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. |
| 13 | +--- |
4 | 14 |
|
5 | | -## Design |
| 15 | +Sight provides intelligent code review capabilities by analyzing diffs with AI. It understands context, identifies issues, and suggests improvements. |
6 | 16 |
|
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) |
| 17 | +## Features |
10 | 18 |
|
11 | | -## Install |
| 19 | +- **Diff-aware analysis** - Reviews only changed code with full context |
| 20 | +- **Severity classification** - Categorizes findings by impact |
| 21 | +- **Provider agnostic** - Works with any LLM provider through the `Provider` interface |
| 22 | +- **Extensible rules** - Add custom review rules for your codebase |
| 23 | + |
| 24 | +## Quick Start |
12 | 25 |
|
13 | 26 | ```bash |
14 | | -go get github.com/GrayCodeAI/sight@latest |
| 27 | +go get github.com/GrayCodeAI/sight |
15 | 28 | ``` |
16 | 29 |
|
17 | | -## Usage |
18 | | - |
19 | | -### One-shot review |
20 | | - |
21 | 30 | ```go |
22 | | -result, err := sight.Review(ctx, diffText, |
23 | | - sight.WithProvider(myProvider), |
| 31 | +import "github.com/GrayCodeAI/sight" |
| 32 | + |
| 33 | +reviewer := sight.NewReviewer( |
| 34 | + sight.WithProvider(myLLMProvider), |
24 | 35 | sight.Thorough, |
25 | 36 | ) |
| 37 | + |
| 38 | +result, err := reviewer.Review(ctx, diff) |
26 | 39 | for _, f := range result.Findings { |
27 | 40 | fmt.Printf("[%s] %s:%d - %s\n", f.Severity, f.File, f.Line, f.Message) |
28 | 41 | } |
29 | 42 | ``` |
30 | 43 |
|
31 | | -### Reusable reviewer |
| 44 | +## Examples |
32 | 45 |
|
33 | | -```go |
34 | | -r := sight.NewReviewer(sight.WithProvider(p), sight.Thorough) |
35 | | -result1, _ := r.Review(ctx, diff1) |
36 | | -result2, _ := r.Review(ctx, diff2) |
37 | | -``` |
| 46 | +See the [examples/](examples/) directory for runnable code samples. |
38 | 47 |
|
39 | | -### Provider interface |
| 48 | +## Provider Interface |
40 | 49 |
|
41 | | -Implement this with any LLM client: |
| 50 | +Implement the `Provider` interface to use any LLM: |
42 | 51 |
|
43 | 52 | ```go |
44 | 53 | type Provider interface { |
45 | | - Complete(ctx context.Context, messages []Message) (string, error) |
| 54 | + Chat(ctx context.Context, messages []Message, opts ChatOpts) (*Response, error) |
46 | 55 | } |
47 | 56 | ``` |
48 | 57 |
|
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 | | -- Human-readable terminal output |
73 | | - |
74 | | -## Configuration |
75 | | - |
76 | | -File-based config via `.sight.toml`: |
77 | | - |
78 | | -```toml |
79 | | -fail-on = "high" |
80 | | -exclude = ["vendor/", "generated/"] |
81 | | -concerns = ["security", "performance", "correctness"] |
82 | | -``` |
83 | | - |
84 | | -## Testing |
85 | | - |
86 | | -```bash |
87 | | -make test # Unit tests |
88 | | -make test-race # With race detector |
89 | | -make bench # Benchmarks |
90 | | -make cover # Coverage report |
91 | | -``` |
92 | | - |
93 | 58 | ## License |
94 | 59 |
|
95 | | -MIT |
96 | | - |
97 | | -## New Features (Wave 1-4) |
98 | | - |
99 | | -### Confidence Scoring |
100 | | - |
101 | | -Every finding includes a numeric confidence score (0.0-1.0) indicating how certain the system is that it's a true positive. Higher scores = more reliable findings. |
102 | | - |
103 | | -### SAST-LLM Fusion |
104 | | - |
105 | | -Sight can ingest findings from static analysis tools (SAST) and feed them into the LLM review prompt for validation. This combines the breadth of automated scanning with the depth of LLM reasoning. |
106 | | - |
107 | | -### Fix Suggestion Pipeline |
108 | | - |
109 | | -Sight includes a built-in fix suggestion pipeline that generates remediation code for common vulnerability patterns: |
110 | | -- SQL injection → parameterized queries |
111 | | -- XSS → HTML escaping / template engines |
112 | | -- Hardcoded secrets → environment variables |
113 | | -- Missing input validation → validation middleware |
114 | | -- Weak crypto → modern algorithm replacement |
115 | | -- Path traversal → filepath.Clean + base path checks |
116 | | -- SSRF → URL allowlist validation |
117 | | - |
118 | | -Custom rules can be registered via AddRule(). |
119 | | - |
120 | | -### Memory Bridge (Coming Soon) |
121 | | - |
122 | | -Integration with yaad memory for context-aware reviews. Sight can recall similar past findings and store review results for future reference. |
123 | | - |
124 | | -## Ecosystem |
125 | | - |
126 | | -Sight is part of the hawk-eco platform: |
127 | | -- **hawk** — CLI/REPL that orchestrates all tools |
128 | | -- **eyrie** — LLM provider layer (sight calls LLMs through eyrie) |
129 | | -- **yaad** — memory/recall engine |
130 | | -- **inspect** — security/accessibility auditing |
131 | | -- **tok** — token counting and cost estimation |
132 | | -- **trace** — session capture and replay |
| 60 | +MIT - see [LICENSE](LICENSE) for details. |
0 commit comments