11# DiffMind - AI Code Review Memory
22
3- ** DiffMind** learns from your team's bug history and warns when similar patterns appear in new code changes.
3+ > [ 한국어 문서] ( README_KO.md )
4+
5+ ** DiffMind** learns from your team's bug history and warns when similar patterns appear in new code changes. Powered by semantic embeddings + LLM analysis.
46
57## How It Works
68
79```
8- git diff → embed changed code
10+ git diff → embed changed code (sentence-transformers)
911 ↓
1012search past bugfix history (TurboQuant compressed)
1113 ↓
1214"This pattern was a bug 3 months ago in PR #142" warning
1315 ↓
14- auto-run via git hook or GitHub Action
16+ LLM analyzes + suggests fix code (Claude / GPT / Ollama)
17+ ↓
18+ auto-run via VS Code / git hook / GitHub Action
1519```
1620
1721## Installation
1822
1923``` bash
20- # From source
24+ # Core CLI
2125git clone https://github.com/wjddusrb03/diffmind.git
2226cd diffmind
2327pip install -e .
28+
29+ # With LLM integration (Claude + OpenAI)
30+ pip install -e " .[llm]"
31+
32+ # With all integrations (GitHub, Slack, Discord)
33+ pip install -e " .[connect]"
34+ ```
35+
36+ ### VS Code Extension
37+
38+ ``` bash
39+ # Option 1: Install from .vsix file
40+ cd vscode-extension
41+ npm install && npm run compile
42+ npx @vscode/vsce package --allow-missing-repository
43+ code --install-extension diffmind-0.1.0.vsix
44+
45+ # Option 2: Open in VS Code and press F5 to debug
2446```
2547
2648## Quick Start
2749
50+ ### CLI
51+
2852``` bash
2953# 1. Learn from repository history (one-time)
3054diffmind learn . --since 2024-01-01
3155
32- # 2. Install pre-commit hook (one-time)
33- diffmind install --pre-commit
34-
35- # 3. Now every commit is auto-reviewed!
36- git commit -m " update login"
37- # DiffMind: reviewing staged changes...
38- # [!!!] HIGH RISK: src/auth/login.py (93% similar to bugfix a1b2c3d)
39-
40- # 4. Manual review
56+ # 2. Review current changes
4157diffmind review --staged
4258
43- # 5. Search past changes
59+ # 3. AI-powered review with fix suggestions
60+ diffmind connect ai-review --staged --provider claude
61+
62+ # 4. Search past changes
4463diffmind search " null check missing" --lang python
4564
46- # 6 . View statistics
65+ # 5 . View statistics
4766diffmind stats
4867
49- # 7. Incremental update
50- diffmind learn --update
68+ # 6. Install pre-commit hook (auto-review on every commit)
69+ diffmind install --pre-commit
70+ ```
71+
72+ ### VS Code
73+
74+ ```
75+ Ctrl+Shift+P → "DiffMind: Learn" ← one-time setup
76+ Ctrl+Shift+D ← review changes
77+ Ctrl+Shift+A ← AI review with LLM
78+ Ctrl+Shift+F6 ← search bug history
79+ Right-click → DiffMind menu ← context menu
5180```
5281
5382## Commands
5483
84+ ### Core CLI
85+
5586| Command | Description |
5687| ---| ---|
5788| ` diffmind learn [PATH] ` | Learn from git history |
5889| ` diffmind review ` | Review current changes against past bugs |
5990| ` diffmind search QUERY ` | Semantic search over diff history |
6091| ` diffmind stats ` | Show index statistics |
61- | ` diffmind install ` | Install automation hooks |
92+ | ` diffmind install ` | Install git hooks / GitHub Action |
93+
94+ ### Connect (Integrations)
95+
96+ | Command | Description |
97+ | ---| ---|
98+ | ` diffmind connect ai-review ` | LLM-powered review with fix suggestions |
99+ | ` diffmind connect github --pr N ` | Auto-post AI review on GitHub PR |
100+ | ` diffmind connect slack --test ` | Send alerts to Slack |
101+ | ` diffmind connect discord --test ` | Send alerts to Discord |
102+ | ` diffmind connect init ` | Generate config file |
103+
104+ ### VS Code Extension
105+
106+ | Command | Shortcut | Description |
107+ | ---| ---| ---|
108+ | DiffMind: Learn | - | Learn repository history |
109+ | DiffMind: Review | ` Ctrl+Shift+D ` | Review changes → Problems panel |
110+ | DiffMind: Review Staged | - | Review only staged changes |
111+ | DiffMind: AI Review | ` Ctrl+Shift+A ` | LLM analysis → WebView panel |
112+ | DiffMind: Search | ` Ctrl+Shift+F6 ` | Search bug history |
113+ | DiffMind: Stats | - | Show index statistics |
114+ | DiffMind: Toggle Auto-Review | - | Auto-review on file save |
62115
63116## Key Features
64117
65118- ** Team Bug Memory** : Learns your team's specific bug patterns, not generic rules
119+ - ** LLM Analysis** : Claude/GPT/Ollama analyzes warnings and suggests fix code
120+ - ** VS Code Integration** : Inline warnings, WebView panels, status bar, auto-review on save
66121- ** Semantic Search** : Search by meaning, not keywords ("authentication error" finds auth bugs)
67122- ** TurboQuant Compression** : ~ 2x memory savings for large repositories
68- - ** Asymmetric Scoring** : Search without decompressing vectors
123+ - ** GitHub PR Bot** : Auto-post AI review comments on pull requests
124+ - ** Slack / Discord Alerts** : Real-time notifications for risky patterns
69125- ** Git Hook / GitHub Action** : Auto-review on every commit or PR
70126- ** Incremental Learning** : Only process new commits with ` --update `
71- - ** Multi-language** : Supports Python, JavaScript, TypeScript, Java, Go, Rust, C/C++, and more
127+ - ** Bilingual** : English and Korean support for AI reviews
128+ - ** Multi-language** : Supports Python, JavaScript, TypeScript, Java, Go, Rust, C/C++, and 30+ languages
129+
130+ ## AI Review (Connect)
131+
132+ DiffMind Connect combines pattern detection with LLM analysis:
133+
134+ ``` bash
135+ # Review with Claude (default)
136+ diffmind connect ai-review --staged
137+
138+ # Review with OpenAI
139+ diffmind connect ai-review --staged --provider openai
140+
141+ # Review with local Ollama (free, offline)
142+ diffmind connect ai-review --staged --provider ollama
143+
144+ # Korean output
145+ diffmind connect ai-review --staged --lang ko
146+
147+ # JSON for CI pipelines
148+ diffmind connect ai-review --staged --json --fail-on high
149+ ```
150+
151+ ** Output example:**
152+ ```
153+ ============================================================
154+ DiffMind AI Review Report
155+ Provider: claude (claude-sonnet-4-20250514)
156+ Overall risk: HIGH
157+ ============================================================
158+
159+ [!!!] HIGH: src/auth/login.py
160+ Confidence: 95%
161+
162+ Summary: Null check removed - NoneType error likely
163+
164+ Explanation:
165+ The same pattern caused a NoneType error in PR #142.
166+ The user object null check was removed.
167+
168+ Suggested fix:
169+ if user is None:
170+ raise ValueError("User not found")
171+ ```
172+
173+ ### GitHub PR Bot
174+
175+ ``` bash
176+ # Post AI review as PR comment
177+ diffmind connect github --pr 42
178+
179+ # Set up in GitHub Action
180+ ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY } }
181+ diffmind connect ai-review --staged --json --fail-on high
182+ ```
183+
184+ ### Notifications
185+
186+ ``` bash
187+ # Slack
188+ diffmind connect slack --test --webhook https://hooks.slack.com/services/...
189+
190+ # Discord
191+ diffmind connect discord --test --webhook https://discord.com/api/webhooks/...
192+ ```
193+
194+ ### Configuration
195+
196+ ``` bash
197+ # Generate config file
198+ diffmind connect init
199+ # → .diffmind/config.yml
200+ ```
201+
202+ ``` yaml
203+ llm :
204+ provider : claude # claude, openai, ollama
205+ language : ko # en or ko
206+ github :
207+ token : " " # or GITHUB_TOKEN env
208+ repo : owner/repo
209+ slack :
210+ webhook_url : " "
211+ min_risk : MEDIUM
212+ discord :
213+ webhook_url : " "
214+ min_risk : HIGH
215+ ` ` `
216+
217+ ## VS Code Extension Details
218+
219+ ### What You See
220+
221+ - **Status Bar** (bottom-left): ` 🛡 DiffMind` → click to review
222+ - **Problems Panel**: HIGH = red error, MEDIUM = yellow warning
223+ - **WebView Panel**: Beautiful AI review report with fix suggestions
224+ - **Context Menu**: Right-click → DiffMind review/search
225+
226+ # ## Settings
227+
228+ Open `Ctrl+,` → search "diffmind" :
229+
230+ | Setting | Default | Description |
231+ |---|---|---|
232+ | `diffmind.pythonPath` | `python` | Python interpreter path |
233+ | `diffmind.autoReviewOnSave` | `false` | Auto-review when saving |
234+ | `diffmind.threshold` | `0.75` | Similarity threshold (0-1) |
235+ | `diffmind.aiProvider` | `claude` | LLM provider |
236+ | `diffmind.aiLanguage` | `en` | AI output language (en/ko) |
237+ | `diffmind.maxWarningsPerHunk` | `3` | Max warnings per hunk |
238+ | `diffmind.showStatusBar` | `true` | Show status bar item |
72239
73240# # How It Detects Bugs
74241
@@ -79,43 +246,106 @@ DiffMind identifies bugfix commits by:
792464. Keywords (`fix`, `bug`, `resolve`, `수정`, `버그`)
802475. Revert commits
81248
82- ## Options
249+ # # Risk Classification
250+
251+ | Risk | Condition | Meaning |
252+ |---|---|---|
253+ | **HIGH** | ≥90% similar + bugfix commit | Very likely same bug |
254+ | **MEDIUM** | ≥80% similar + bugfix commit | Needs attention |
255+ | **LOW** | ≥75% similar | Reference only |
256+
257+ # # CLI Options
83258
84259# ## `diffmind learn`
85- - ` --since DATE ` - Learn from commits after date
86- - ` --bugfix-only ` - Only learn bugfix commits
260+ - ` --since DATE` / `--until DATE` - Date range
261+ - ` --branch NAME` - Specific branch
262+ - ` --bugfix-only` - Only bugfix commits
87263- `--model NAME` - Embedding model (default : all-MiniLM-L6-v2)
88264- `--bits N` - Compression bits : 2, 3, or 4 (default: 3)
89- - ` --update ` - Incremental learn (only new commits)
265+ - ` --update` - Incremental learn
90266
91267# ## `diffmind review`
92- - ` --staged ` - Only review staged changes
268+ - ` --staged` - Only staged changes
93269- `--threshold N` - Similarity threshold (default : 0.75)
94- - ` --fail-on LEVEL ` - Exit code 1 if risk >= level (high/medium/low)
95- - ` --json ` - JSON output for CI integration
270+ - ` --fail-on LEVEL` - Exit 1 if risk >= level
271+ - ` --json` - JSON output
96272
97273# ## `diffmind search`
98- - ` --file PATH ` - Filter by file path
274+ - ` --file PATH` - Filter by file
99275- ` --author NAME` - Filter by author
100276- ` --lang LANG` - Filter by language
101277- ` --bugfix-only` - Only bugfix commits
102278
279+ # ## `diffmind connect ai-review`
280+ - ` --provider [claude|openai|ollama]` - LLM provider
281+ - ` --model NAME` - Model override
282+ - ` --lang [en|ko]` - Output language
283+ - ` --json` - JSON output
284+ - ` --fail-on LEVEL` - CI exit code
285+
103286# # vs Other Tools
104287
105288| Tool | What It Does | What DiffMind Does |
106289|---|---|---|
107- | ESLint/Pylint | General rule violations | Team-specific patterns |
290+ | ESLint/Pylint | General rule violations | Team-specific bug patterns |
108291| GitHub Copilot | Code generation | Bug pattern memory |
109- | CodeRabbit | Generic AI review | Project-specific learning |
110- | SonarQube | Static analysis | Semantic similarity search |
292+ | CodeRabbit | Generic AI review | Project-specific + LLM analysis |
293+ | SonarQube | Static analysis | Semantic similarity + fix suggestions |
111294| `git log --grep` | Keyword search | Meaning-based search |
112295
296+ # # Architecture
297+
298+ ```
299+ src/diffmind/
300+ ├── cli.py # Click CLI (learn, review, search, stats, install, connect)
301+ ├── models.py # DiffHunk, ReviewWarning, ReviewComment, ReviewReport
302+ ├── parser.py # Git log/diff parser, bugfix detection
303+ ├── indexer.py # Embedding + TurboQuant compression
304+ ├── reviewer.py # Similarity-based review engine
305+ ├── searcher.py # Semantic search
306+ ├── storage.py # Pickle-based index persistence
307+ ├── display.py # Terminal + JSON formatting
308+ ├── hooks.py # Git hooks + GitHub Action generation
309+ └── connect/
310+ ├── llm.py # LLM reviewer (Claude/OpenAI/Ollama)
311+ ├── github_bot.py # GitHub PR comments
312+ ├── slack.py # Slack webhook alerts
313+ ├── discord.py # Discord webhook alerts
314+ ├── config.py # YAML config + env vars
315+ └── prompts.py # Bilingual prompt templates
316+
317+ vscode-extension/
318+ ├── src/extension.ts # VS Code extension
319+ └── package.json # Extension manifest
320+
321+ tests/ # 440 tests
322+ ```
323+
113324## Dependencies
114325
326+ **Core:**
115327- [langchain-turboquant](https://pypi.org/project/langchain-turboquant/) - Vector compression
116328- [sentence-transformers](https://www.sbert.net/) - Embedding models
117329- [Click](https://click.palletsprojects.com/) - CLI framework
118330
331+ **Optional (Connect):**
332+ - [anthropic](https://github.com/anthropics/anthropic-sdk-python) - Claude API
333+ - [openai](https://github.com/openai/openai-python) - OpenAI API
334+ - [PyGithub](https://github.com/PyGithub/PyGithub) - GitHub API
335+
336+ ## Tests
337+
338+ ```bash
339+ # Run all 440 tests
340+ pytest tests/ -v
341+
342+ # Test categories:
343+ # - Unit tests: models, parser, reviewer, display, storage, hooks
344+ # - Integration: real git repos, real sentence-transformers
345+ # - E2E: full CLI workflows, stress tests
346+ # - Connect: LLM, GitHub, Slack, Discord, config, prompts
347+ ```
348+
119349## License
120350
121351MIT
0 commit comments