ai-pr-review-cli 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -0
- package/README.md +381 -123
- package/batch-review.js +415 -0
- package/bin/cli.js +38 -0
- package/package.json +10 -4
- package/src/ai.js +26 -13
- package/src/git.js +47 -5
- package/src/reviewer.js +106 -50
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to AI PR Review CLI will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [1.2.0] - 2026-03-22
|
|
6
|
+
|
|
7
|
+
### 🚀 Revolutionary File Processing
|
|
8
|
+
- **Unlimited File Support**: No more 10-file limits - review unlimited files
|
|
9
|
+
- **Intelligent Auto-Batching**: Built-in batching system processes files in groups of 5
|
|
10
|
+
- **Smart Rate Limiting**: 3-second delays between batches prevent API rate limit errors
|
|
11
|
+
- **Progress Tracking**: Real-time batch progress with detailed status updates
|
|
12
|
+
- **Error Recovery**: If one batch fails, others continue processing
|
|
13
|
+
|
|
14
|
+
### 🔧 Enhanced User Experience
|
|
15
|
+
- **Verbose Mode**: `--verbose` flag shows detailed processing information
|
|
16
|
+
- **File Content Debugging**: See exactly what files are being processed
|
|
17
|
+
- **Batch Status Updates**: Track progress through multiple batches
|
|
18
|
+
- **Consolidated Results**: All batch results combined into final comprehensive report
|
|
19
|
+
- **No Data Loss**: Every file gets reviewed, no truncation or skipping
|
|
20
|
+
|
|
21
|
+
### 🛠️ Technical Improvements
|
|
22
|
+
- **Improved Error Handling**: Better error messages and graceful failure recovery
|
|
23
|
+
- **Memory Efficient**: Processes files in manageable chunks
|
|
24
|
+
- **Scope Bug Fixes**: Fixed variable scope issues in batch processing
|
|
25
|
+
- **Performance Optimization**: Reduced memory usage and improved processing speed
|
|
26
|
+
|
|
27
|
+
### 📊 Better Output Format
|
|
28
|
+
- **Batch-by-Batch Results**: See results from each batch as it completes
|
|
29
|
+
- **Combined Final Results**: All findings consolidated into comprehensive summary
|
|
30
|
+
- **Processing Statistics**: Shows total batches and processing time
|
|
31
|
+
- **Enhanced Debugging**: Verbose mode shows file content previews and prompt sizes
|
|
32
|
+
|
|
33
|
+
## [1.1.0] - 2026-03-22
|
|
34
|
+
|
|
35
|
+
### 🚀 Major Features Added
|
|
36
|
+
- **Batch Processing**: Added intelligent batch review for large repositories
|
|
37
|
+
- **Universal Project Support**: Enhanced support for all project types (backend, frontend, mobile, DevOps)
|
|
38
|
+
- **Smart File Filtering**: Automatically skips generated files, node_modules, build artifacts
|
|
39
|
+
- **Rate Limit Handling**: Graceful handling of OpenAI API rate limits with retry logic
|
|
40
|
+
- **Frontend Optimization**: Special batching mode for React, Vue, Angular projects
|
|
41
|
+
|
|
42
|
+
### ✨ New Commands
|
|
43
|
+
- `ai-pr-review batch` - Intelligent batch processing for large repos
|
|
44
|
+
- `ai-pr-review batch --frontend` - Frontend-optimized batching
|
|
45
|
+
- `ai-pr-review batch --dry-run` - Preview batching without API calls
|
|
46
|
+
- `ai-pr-review config` - Global configuration management
|
|
47
|
+
|
|
48
|
+
### 🔧 Improvements
|
|
49
|
+
- **Better Error Handling**: Clear error messages for common issues (API key, rate limits, git errors)
|
|
50
|
+
- **Auto Branch Detection**: Automatically detects common base branches (main, master, develop)
|
|
51
|
+
- **Enhanced Prompt**: More effective prompts for finding bugs, security issues, and improvements
|
|
52
|
+
- **File Content Limits**: Smart truncation to prevent huge requests
|
|
53
|
+
- **Priority-Based Batching**: Reviews critical files first (API, services, components)
|
|
54
|
+
|
|
55
|
+
### 🛠️ Technical Enhancements
|
|
56
|
+
- **Universal File Grouping**: Intelligent grouping for any project type
|
|
57
|
+
- **Dynamic Batch Sizes**: Adjusts batch size based on file type and complexity
|
|
58
|
+
- **Package Lock Handling**: Special handling for large dependency files
|
|
59
|
+
- **JSON Extraction**: Robust parsing of AI responses even with formatting issues
|
|
60
|
+
|
|
61
|
+
### 📚 Documentation
|
|
62
|
+
- **Comprehensive README**: Complete rewrite with practical examples
|
|
63
|
+
- **Usage Examples**: Real-world workflows for different project types
|
|
64
|
+
- **Troubleshooting Guide**: Solutions for common problems
|
|
65
|
+
- **Platform Support**: Clear documentation for Windows, Mac, Linux
|
|
66
|
+
|
|
67
|
+
## [1.0.1] - 2026-03-21
|
|
68
|
+
|
|
69
|
+
### 🔧 Bug Fixes
|
|
70
|
+
- Fixed ES module compatibility issues with `ora` and `chalk`
|
|
71
|
+
- Improved Git operations error handling
|
|
72
|
+
- Updated GitHub repository links
|
|
73
|
+
|
|
74
|
+
## [1.0.0] - 2026-03-21
|
|
75
|
+
|
|
76
|
+
### 🎉 Initial Release
|
|
77
|
+
- **Basic PR Review**: Single-file and small repository review
|
|
78
|
+
- **OpenAI Integration**: GPT-powered code analysis
|
|
79
|
+
- **Git Integration**: Automatic diff detection and file analysis
|
|
80
|
+
- **Configurable**: Support for different AI models and base branches
|
|
81
|
+
- **Beautiful CLI**: Colorful output with clear categorization
|
|
82
|
+
|
|
83
|
+
### 📦 Core Features
|
|
84
|
+
- Issues detection (bugs, security, performance)
|
|
85
|
+
- Typo detection (spelling, grammar)
|
|
86
|
+
- Improvement suggestions (best practices, refactoring)
|
|
87
|
+
- Multiple configuration methods (CLI, file, environment)
|
|
88
|
+
- Cross-platform support (Windows, Mac, Linux)
|
package/README.md
CHANGED
|
@@ -1,212 +1,470 @@
|
|
|
1
1
|
# 🤖 AI PR Review CLI
|
|
2
2
|
|
|
3
|
-
An intelligent command-line tool that uses AI to review your code changes and provide instant feedback on
|
|
3
|
+
An intelligent command-line tool that uses AI to review your code changes and provide instant feedback on issues, typos, and improvements. Perfect for any programming language and project type.
|
|
4
4
|
|
|
5
|
-
## ✨ Features
|
|
5
|
+
## ✨ Key Features
|
|
6
6
|
|
|
7
|
-
- 🔍 **
|
|
8
|
-
- 🎯 **
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
7
|
+
- 🔍 **Smart Code Analysis** - Uses GPT to find bugs, security issues, and improvements
|
|
8
|
+
- 🎯 **Auto Branch Detection** - Automatically detects your base branch (main/master/develop)
|
|
9
|
+
- 🔄 **Intelligent Batching** - Processes ALL files in manageable batches (5 files per batch)
|
|
10
|
+
- 📊 **No File Limits** - Reviews unlimited files without losing any data
|
|
11
|
+
- ⚡ **Rate Limit Protection** - Smart delays between batches prevent API errors
|
|
12
|
+
- 🎨 **Beautiful Output** - Clean, colorful results with progress tracking
|
|
13
|
+
- 🌍 **Universal Support** - Works with any language, framework, or project type
|
|
14
|
+
- ⚙️ **Flexible Config** - Multiple ways to customize behavior
|
|
15
|
+
- 🛡️ **Error Recovery** - Continues processing even if one batch fails
|
|
13
16
|
|
|
14
17
|
## 🚀 Quick Start
|
|
15
18
|
|
|
16
|
-
###
|
|
17
|
-
|
|
19
|
+
### 1. Install
|
|
18
20
|
```bash
|
|
19
|
-
# Install globally
|
|
20
|
-
npm install -g ai-pr-review-cli
|
|
21
|
+
# Install globally
|
|
22
|
+
npm install -g @blockdeepanshu/ai-pr-review-cli
|
|
21
23
|
|
|
22
|
-
# Or use
|
|
23
|
-
npx ai-pr-review-cli review
|
|
24
|
+
# Or use without installing
|
|
25
|
+
npx @blockdeepanshu/ai-pr-review-cli review
|
|
24
26
|
```
|
|
25
27
|
|
|
26
|
-
###
|
|
28
|
+
### 2. Get OpenAI API Key
|
|
29
|
+
Get your API key from [OpenAI](https://platform.openai.com/api-keys)
|
|
30
|
+
|
|
31
|
+
### 3. Set API Key
|
|
27
32
|
|
|
28
|
-
|
|
33
|
+
**Windows:**
|
|
34
|
+
```powershell
|
|
35
|
+
# PowerShell - current session
|
|
36
|
+
$env:OPENAI_API_KEY="your-api-key-here"
|
|
37
|
+
|
|
38
|
+
# Permanent (via System Properties > Environment Variables)
|
|
39
|
+
# Variable name: OPENAI_API_KEY
|
|
40
|
+
# Variable value: your-api-key-here
|
|
41
|
+
```
|
|
29
42
|
|
|
30
|
-
|
|
43
|
+
**Mac/Linux:**
|
|
31
44
|
```bash
|
|
32
|
-
#
|
|
45
|
+
# Current session
|
|
33
46
|
export OPENAI_API_KEY="your-api-key-here"
|
|
34
47
|
|
|
35
|
-
#
|
|
36
|
-
echo
|
|
48
|
+
# Permanent (add to ~/.bashrc or ~/.zshrc)
|
|
49
|
+
echo 'export OPENAI_API_KEY="your-api-key-here"' >> ~/.bashrc
|
|
37
50
|
```
|
|
38
51
|
|
|
39
|
-
|
|
52
|
+
### 4. Use in Any Git Repository
|
|
40
53
|
```bash
|
|
41
|
-
#
|
|
54
|
+
# Navigate to your project
|
|
55
|
+
cd my-project
|
|
56
|
+
|
|
57
|
+
# Review your changes
|
|
42
58
|
ai-pr-review review
|
|
43
59
|
|
|
44
|
-
#
|
|
60
|
+
# Short alias also works
|
|
45
61
|
aipr review
|
|
46
62
|
```
|
|
47
63
|
|
|
48
|
-
##
|
|
49
|
-
|
|
50
|
-
### Basic Usage
|
|
64
|
+
## 💻 Usage Examples
|
|
51
65
|
|
|
66
|
+
### Small Projects
|
|
52
67
|
```bash
|
|
53
|
-
#
|
|
68
|
+
# Simple review - auto-detects base branch
|
|
54
69
|
ai-pr-review review
|
|
55
70
|
|
|
56
71
|
# Review against specific branch
|
|
57
|
-
ai-pr-review review --base
|
|
72
|
+
ai-pr-review review --base main
|
|
58
73
|
|
|
59
|
-
# Use
|
|
74
|
+
# Use GPT-4 for higher quality
|
|
60
75
|
ai-pr-review review --model gpt-4o
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Large Projects (Multiple Approaches)
|
|
79
|
+
|
|
80
|
+
**Method 1: Automatic Batching (Built-in)**
|
|
81
|
+
```bash
|
|
82
|
+
# The standard review now automatically batches files
|
|
83
|
+
ai-pr-review review # Processes ALL files in batches of 5
|
|
61
84
|
|
|
62
|
-
#
|
|
85
|
+
# With verbose output to see batching progress
|
|
63
86
|
ai-pr-review review --verbose
|
|
64
87
|
```
|
|
65
88
|
|
|
66
|
-
|
|
89
|
+
**Method 2: Advanced Batch Mode**
|
|
90
|
+
```bash
|
|
91
|
+
# Smart batching by file type (React, Vue, Angular, etc.)
|
|
92
|
+
ai-pr-review batch --frontend
|
|
67
93
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
| `--base <branch>` | `-b` | Base branch to compare against | `-b origin/main` |
|
|
71
|
-
| `--model <model>` | `-m` | AI model to use | `-m gpt-4o` |
|
|
72
|
-
| `--provider <provider>` | | AI provider (currently only openai) | `--provider openai` |
|
|
73
|
-
| `--verbose` | `-v` | Show detailed output | `-v` |
|
|
94
|
+
# Custom batch size for different project needs
|
|
95
|
+
ai-pr-review batch --batch-size 6
|
|
74
96
|
|
|
75
|
-
|
|
97
|
+
# Preview what would be reviewed (no API calls)
|
|
98
|
+
ai-pr-review batch --dry-run
|
|
99
|
+
```
|
|
76
100
|
|
|
101
|
+
**Method 3: Selective Review**
|
|
77
102
|
```bash
|
|
78
|
-
# Review
|
|
79
|
-
git
|
|
80
|
-
ai-pr-review review
|
|
103
|
+
# Review only specific files
|
|
104
|
+
git add src/important-file.js src/critical-component.js
|
|
105
|
+
ai-pr-review review # Only reviews staged files
|
|
106
|
+
```
|
|
81
107
|
|
|
82
|
-
|
|
83
|
-
ai-pr-review review --model gpt-4o --verbose
|
|
108
|
+
## 📋 Common Workflows
|
|
84
109
|
|
|
85
|
-
|
|
86
|
-
|
|
110
|
+
### Feature Development
|
|
111
|
+
```bash
|
|
112
|
+
# Create feature branch
|
|
113
|
+
git checkout -b feature/new-feature
|
|
114
|
+
|
|
115
|
+
# Make changes, then review before committing
|
|
87
116
|
ai-pr-review review
|
|
88
117
|
|
|
89
|
-
#
|
|
90
|
-
|
|
118
|
+
# Address feedback, then commit
|
|
119
|
+
git add .
|
|
120
|
+
git commit -m "Implement new feature"
|
|
91
121
|
```
|
|
92
122
|
|
|
93
|
-
|
|
123
|
+
### Large Codebase Updates
|
|
124
|
+
```bash
|
|
125
|
+
# Stage all changes
|
|
126
|
+
git add .
|
|
127
|
+
|
|
128
|
+
# Smart automatic batching handles everything
|
|
129
|
+
ai-pr-review review --verbose
|
|
130
|
+
|
|
131
|
+
# Example output for 23 files:
|
|
132
|
+
# 🔄 Processing 5 batches of files (5 files per batch)...
|
|
133
|
+
# --- Batch 1/5 ---
|
|
134
|
+
# Files: auth.js, login.js, middleware.js, routes.js, config.js
|
|
135
|
+
# ✅ Batch 1 completed: 3 issues, 1 typo, 4 improvements
|
|
136
|
+
# ⏳ Waiting 3 seconds before next batch...
|
|
137
|
+
# [continues for all batches...]
|
|
138
|
+
|
|
139
|
+
# Final consolidated results:
|
|
140
|
+
# 🚨 Issues: bugs, security, performance
|
|
141
|
+
# ✏️ Typos: spelling, grammar
|
|
142
|
+
# 💡 Improvements: best practices, refactoring
|
|
143
|
+
```
|
|
94
144
|
|
|
95
|
-
###
|
|
145
|
+
### Different Project Types
|
|
96
146
|
```bash
|
|
97
|
-
|
|
147
|
+
# Works automatically for any project:
|
|
148
|
+
cd react-frontend && ai-pr-review batch --frontend
|
|
149
|
+
cd node-api && ai-pr-review batch
|
|
150
|
+
cd python-ml && ai-pr-review batch
|
|
151
|
+
cd java-enterprise && ai-pr-review batch
|
|
152
|
+
cd devops-terraform && ai-pr-review batch
|
|
98
153
|
```
|
|
99
154
|
|
|
100
|
-
|
|
101
|
-
Create `.aiprconfig.json` in your project root:
|
|
155
|
+
## ⚙️ Configuration Options
|
|
102
156
|
|
|
157
|
+
### Global Config (One-time Setup)
|
|
158
|
+
```bash
|
|
159
|
+
# Set default preferences
|
|
160
|
+
ai-pr-review config --model gpt-4o-mini --base main
|
|
161
|
+
|
|
162
|
+
# Creates ~/.aiprconfig.json with your defaults
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Project Config (.aiprconfig.json)
|
|
103
166
|
```json
|
|
104
167
|
{
|
|
105
168
|
"provider": "openai",
|
|
106
|
-
"model": "gpt-4o-mini",
|
|
107
|
-
"baseBranch": "
|
|
169
|
+
"model": "gpt-4o-mini",
|
|
170
|
+
"baseBranch": "develop"
|
|
108
171
|
}
|
|
109
172
|
```
|
|
110
173
|
|
|
111
|
-
###
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
174
|
+
### Command Line Options
|
|
175
|
+
| Option | Description | Example |
|
|
176
|
+
|--------|-------------|---------|
|
|
177
|
+
| `--base <branch>` | Compare against specific branch | `--base origin/develop` |
|
|
178
|
+
| `--model <model>` | Use specific AI model | `--model gpt-4o` |
|
|
179
|
+
| `--verbose` | Show detailed analysis info | `--verbose` |
|
|
180
|
+
| `--batch-size <n>` | Files per batch (default: 8) | `--batch-size 4` |
|
|
181
|
+
| `--frontend` | Optimize for frontend projects | `--frontend` |
|
|
182
|
+
| `--dry-run` | Preview without API calls | `--dry-run` |
|
|
183
|
+
|
|
184
|
+
## 🎯 What Gets Analyzed
|
|
185
|
+
|
|
186
|
+
### Code Changes
|
|
187
|
+
- ✅ **Committed changes** (between branches)
|
|
188
|
+
- ✅ **Staged changes** (`git add`)
|
|
189
|
+
- ✅ **Working directory changes** (uncommitted)
|
|
190
|
+
|
|
191
|
+
### File Types Supported
|
|
192
|
+
- **Web**: JavaScript, TypeScript, HTML, CSS, SCSS
|
|
193
|
+
- **Backend**: Python, Java, Go, Ruby, PHP, C#
|
|
194
|
+
- **Mobile**: React Native, Flutter, Swift, Kotlin
|
|
195
|
+
- **DevOps**: Terraform, Docker, Kubernetes, YAML
|
|
196
|
+
- **Data**: SQL, R, Jupyter notebooks
|
|
197
|
+
- **Config**: JSON, YAML, TOML, XML
|
|
198
|
+
- **Documentation**: Markdown, reStructuredText
|
|
199
|
+
|
|
200
|
+
## 🔄 How Batching Works
|
|
201
|
+
|
|
202
|
+
### Automatic Batching (Default)
|
|
203
|
+
The tool automatically processes files in batches to handle any number of files efficiently:
|
|
120
204
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
The tool analyzes:
|
|
124
|
-
- ✅ **Committed changes** between branches
|
|
125
|
-
- ✅ **Staged changes** (files added with `git add`)
|
|
126
|
-
- ✅ **Working directory changes** (uncommitted modifications)
|
|
127
|
-
- ✅ **File contents** for context
|
|
205
|
+
```bash
|
|
206
|
+
ai-pr-review review # Automatically batches files
|
|
128
207
|
|
|
129
|
-
|
|
208
|
+
# Example with 23 files:
|
|
209
|
+
📁 Found 23 changed files: auth.js, login.js, config.js...
|
|
130
210
|
|
|
131
|
-
|
|
132
|
-
- Critical bugs and logic errors
|
|
133
|
-
- Security vulnerabilities
|
|
134
|
-
- Performance problems
|
|
135
|
-
- Breaking changes
|
|
211
|
+
🔄 Processing 5 batches of files (5 files per batch)...
|
|
136
212
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
213
|
+
--- Batch 1/5 ---
|
|
214
|
+
Files: auth.js, login.js, middleware.js, routes.js, config.js
|
|
215
|
+
✅ Batch 1 completed: 3 issues, 1 typo, 4 improvements
|
|
216
|
+
⏳ Waiting 3 seconds before next batch...
|
|
141
217
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
- Refactoring opportunities
|
|
218
|
+
--- Batch 2/5 ---
|
|
219
|
+
Files: utils.js, helpers.js, constants.js, api.js, db.js
|
|
220
|
+
✅ Batch 2 completed: 2 issues, 0 typos, 3 improvements
|
|
221
|
+
⏳ Waiting 3 seconds before next batch...
|
|
147
222
|
|
|
148
|
-
|
|
223
|
+
[... continues for all files ...]
|
|
149
224
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
| `gpt-4o-mini` | ⚡⚡⚡ | ⭐⭐⭐ | 💰 |
|
|
153
|
-
| `gpt-4o` | ⚡⚡ | ⭐⭐⭐⭐⭐ | 💰💰💰 |
|
|
154
|
-
| `gpt-3.5-turbo` | ⚡⚡⚡ | ⭐⭐ | 💰 |
|
|
225
|
+
📋 Final Summary: 12 issues, 4 typos, 18 improvements
|
|
226
|
+
```
|
|
155
227
|
|
|
156
|
-
|
|
228
|
+
### Benefits
|
|
229
|
+
- ✅ **No File Limits** - Reviews unlimited files
|
|
230
|
+
- ✅ **Rate Limit Safe** - 3-second delays prevent API errors
|
|
231
|
+
- ✅ **Progress Tracking** - See which batch is processing
|
|
232
|
+
- ✅ **Error Recovery** - If one batch fails, others continue
|
|
233
|
+
- ✅ **Memory Efficient** - Processes files in manageable chunks
|
|
157
234
|
|
|
158
|
-
|
|
159
|
-
- Make sure you're on a feature branch (not main/master)
|
|
160
|
-
- Check if you have uncommitted changes: `git status`
|
|
161
|
-
- Try specifying a different base branch: `--base main`
|
|
162
|
-
- Update remote branches: `git fetch origin`
|
|
235
|
+
## 🔧 Troubleshooting
|
|
163
236
|
|
|
164
|
-
###
|
|
237
|
+
### Rate Limit Errors (429)
|
|
165
238
|
```bash
|
|
166
|
-
#
|
|
167
|
-
|
|
239
|
+
# The tool now automatically handles rate limits with batching
|
|
240
|
+
ai-pr-review review # Built-in 3-second delays between batches
|
|
168
241
|
|
|
169
|
-
#
|
|
170
|
-
|
|
242
|
+
# For very large projects, use advanced batch mode
|
|
243
|
+
ai-pr-review batch --batch-size 3 # Smaller batches
|
|
244
|
+
|
|
245
|
+
# Or wait 1-2 minutes and retry
|
|
246
|
+
ai-pr-review review
|
|
247
|
+
|
|
248
|
+
# Consider upgrading OpenAI plan for higher limits
|
|
171
249
|
```
|
|
172
250
|
|
|
173
|
-
###
|
|
251
|
+
### No Changes Found
|
|
174
252
|
```bash
|
|
175
|
-
#
|
|
176
|
-
git
|
|
253
|
+
# Check git status
|
|
254
|
+
git status
|
|
177
255
|
|
|
178
|
-
#
|
|
256
|
+
# Make sure you're not on the main branch
|
|
257
|
+
git checkout -b feature/my-changes
|
|
258
|
+
|
|
259
|
+
# Or specify different base branch
|
|
179
260
|
ai-pr-review review --base origin/master
|
|
180
261
|
```
|
|
181
262
|
|
|
263
|
+
### API Key Issues
|
|
264
|
+
```bash
|
|
265
|
+
# Verify key is set
|
|
266
|
+
echo $OPENAI_API_KEY # Mac/Linux
|
|
267
|
+
echo $env:OPENAI_API_KEY # Windows PowerShell
|
|
268
|
+
|
|
269
|
+
# Test with simple review
|
|
270
|
+
ai-pr-review review --verbose
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## 💡 Pro Tips
|
|
274
|
+
|
|
275
|
+
### Efficient Workflows
|
|
276
|
+
```bash
|
|
277
|
+
# Review before committing
|
|
278
|
+
git add changed-files/
|
|
279
|
+
ai-pr-review review
|
|
280
|
+
# Fix issues, then commit
|
|
281
|
+
|
|
282
|
+
# Review large changes in batches
|
|
283
|
+
ai-pr-review batch --dry-run # Preview
|
|
284
|
+
ai-pr-review batch # Execute
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Cost Optimization
|
|
288
|
+
```bash
|
|
289
|
+
# Use mini model for regular reviews (cheaper)
|
|
290
|
+
ai-pr-review review --model gpt-4o-mini
|
|
291
|
+
|
|
292
|
+
# Use GPT-4 for critical reviews (more thorough)
|
|
293
|
+
ai-pr-review review --model gpt-4o
|
|
294
|
+
|
|
295
|
+
# Set as default
|
|
296
|
+
ai-pr-review config --model gpt-4o-mini
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Shell Aliases
|
|
300
|
+
```bash
|
|
301
|
+
# Add to ~/.bashrc or ~/.zshrc
|
|
302
|
+
alias review="ai-pr-review review"
|
|
303
|
+
alias batch-review="ai-pr-review batch"
|
|
304
|
+
alias quick-review="ai-pr-review review --model gpt-4o-mini"
|
|
305
|
+
|
|
306
|
+
# Usage
|
|
307
|
+
review --base develop
|
|
308
|
+
batch-review --frontend
|
|
309
|
+
quick-review
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## 🌍 Platform Support
|
|
313
|
+
|
|
314
|
+
| Platform | Status | Notes |
|
|
315
|
+
|----------|--------|-------|
|
|
316
|
+
| **GitHub** | ✅ | Full support |
|
|
317
|
+
| **GitLab** | ✅ | Full support |
|
|
318
|
+
| **Bitbucket** | ✅ | Full support |
|
|
319
|
+
| **Azure DevOps** | ✅ | Full support |
|
|
320
|
+
| **Local Git** | ✅ | Works without remote |
|
|
321
|
+
|
|
322
|
+
## 📊 Sample Output
|
|
323
|
+
|
|
324
|
+
### Single File Review
|
|
325
|
+
```bash
|
|
326
|
+
git add problematic-file.js
|
|
327
|
+
ai-pr-review review
|
|
328
|
+
|
|
329
|
+
🤖 AI PR Review
|
|
330
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
331
|
+
|
|
332
|
+
📊 Analyzing changes on branch: feature/auth-fixes
|
|
333
|
+
📁 Found 1 changed file: problematic-file.js
|
|
334
|
+
|
|
335
|
+
🔄 Processing 1 batch of files (5 files per batch)...
|
|
336
|
+
|
|
337
|
+
--- Batch 1/1 ---
|
|
338
|
+
Files: problematic-file.js
|
|
339
|
+
✅ Batch 1 completed: 3 issues, 1 typo, 2 improvements
|
|
340
|
+
✔ Review completed!
|
|
341
|
+
|
|
342
|
+
🚨 Issues
|
|
343
|
+
1. Invalid JavaScript syntax: unexpected semicolon and commas
|
|
344
|
+
2. Missing input validation for user input
|
|
345
|
+
3. Use const instead of var for better scoping
|
|
346
|
+
|
|
347
|
+
✏️ Typos
|
|
348
|
+
1. "recieve" should be "receive" in comment
|
|
349
|
+
|
|
350
|
+
💡 Improvements
|
|
351
|
+
1. Add proper error handling
|
|
352
|
+
2. Remove unused variables
|
|
353
|
+
|
|
354
|
+
📋 Review Summary: 3 issues, 1 typo, 2 improvements
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### Large Project Review
|
|
358
|
+
```bash
|
|
359
|
+
git add . # 23 files
|
|
360
|
+
ai-pr-review review --verbose
|
|
361
|
+
|
|
362
|
+
🤖 AI PR Review
|
|
363
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
364
|
+
|
|
365
|
+
📊 Analyzing changes on branch: feature/auth-system
|
|
366
|
+
📁 Found 23 changed files: auth.js, login.js, middleware.js, routes.js...
|
|
367
|
+
|
|
368
|
+
🔄 Processing 5 batches of files (5 files per batch)...
|
|
369
|
+
|
|
370
|
+
--- Batch 1/5 ---
|
|
371
|
+
Files: auth.js, login.js, middleware.js, routes.js, config.js
|
|
372
|
+
🔍 Debug - Files with content:
|
|
373
|
+
1. auth.js (1,240 chars): "const jwt = require('jsonwebtoken'); const bcrypt..."
|
|
374
|
+
2. login.js (856 chars): "// Login component with validation..."
|
|
375
|
+
✅ Batch 1 completed: 4 issues, 1 typo, 3 improvements
|
|
376
|
+
⏳ Waiting 3 seconds before next batch...
|
|
377
|
+
|
|
378
|
+
--- Batch 2/5 ---
|
|
379
|
+
Files: utils.js, helpers.js, constants.js, api.js, db.js
|
|
380
|
+
✅ Batch 2 completed: 2 issues, 0 typos, 4 improvements
|
|
381
|
+
⏳ Waiting 3 seconds before next batch...
|
|
382
|
+
|
|
383
|
+
[... continues for all 5 batches ...]
|
|
384
|
+
|
|
385
|
+
✔ Review completed!
|
|
386
|
+
|
|
387
|
+
🚨 Issues
|
|
388
|
+
1. Missing input validation in auth.js:15
|
|
389
|
+
2. Potential SQL injection in routes.js:42
|
|
390
|
+
3. Password stored in plain text - use bcrypt
|
|
391
|
+
[... 9 more issues ...]
|
|
392
|
+
|
|
393
|
+
✏️ Typos
|
|
394
|
+
1. "recieve" should be "receive" in comment (auth.js:8)
|
|
395
|
+
[... 2 more typos ...]
|
|
396
|
+
|
|
397
|
+
💡 Improvements
|
|
398
|
+
1. Add rate limiting to login endpoint
|
|
399
|
+
2. Use environment variables for JWT secret
|
|
400
|
+
[... 16 more improvements ...]
|
|
401
|
+
|
|
402
|
+
📋 Review Summary: 12 issues, 3 typos, 19 improvements
|
|
403
|
+
```
|
|
404
|
+
|
|
182
405
|
## 🔐 Security & Privacy
|
|
183
406
|
|
|
184
|
-
-
|
|
185
|
-
-
|
|
186
|
-
-
|
|
187
|
-
- Consider using this on non-sensitive codebases
|
|
407
|
+
- Code is sent to OpenAI's API for analysis
|
|
408
|
+
- No permanent storage of your code
|
|
409
|
+
- Use `.gitignore` to exclude sensitive files
|
|
188
410
|
- Review OpenAI's [data usage policies](https://openai.com/policies/api-data-usage-policies)
|
|
411
|
+
- Consider using on non-production codebases first
|
|
189
412
|
|
|
190
|
-
##
|
|
413
|
+
## 📊 Performance for Any Repository Size
|
|
191
414
|
|
|
192
|
-
|
|
415
|
+
### Smart Handling of Large Codebases
|
|
416
|
+
| Repository Size | Processing Method | Time | Success Rate |
|
|
417
|
+
|----------------|------------------|------|--------------|
|
|
418
|
+
| **1-5 files** | Single batch | ~10 seconds | ✅ 100% |
|
|
419
|
+
| **6-25 files** | 2-5 batches | ~30-60 seconds | ✅ 100% |
|
|
420
|
+
| **26-100 files** | 5-20 batches | 2-5 minutes | ✅ 100% |
|
|
421
|
+
| **100+ files** | Smart batching | 5-15 minutes | ✅ 100% |
|
|
422
|
+
|
|
423
|
+
### Before vs After
|
|
424
|
+
- **Old Approach**: Limited to 10 files = Many files ignored ❌
|
|
425
|
+
- **New Approach**: Unlimited files in smart batches = All files reviewed ✅
|
|
426
|
+
|
|
427
|
+
### Real-World Examples
|
|
428
|
+
```bash
|
|
429
|
+
# Small project (5 files)
|
|
430
|
+
📁 Found 5 files → 🔄 1 batch → ✅ ~15 seconds
|
|
431
|
+
|
|
432
|
+
# Medium project (23 files)
|
|
433
|
+
📁 Found 23 files → 🔄 5 batches → ✅ ~90 seconds
|
|
434
|
+
|
|
435
|
+
# Large project (87 files)
|
|
436
|
+
📁 Found 87 files → 🔄 18 batches → ✅ ~8 minutes
|
|
437
|
+
|
|
438
|
+
# Enterprise project (200+ files)
|
|
439
|
+
📁 Found 234 files → 🔄 47 batches → ✅ ~15 minutes
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### Efficiency Features
|
|
443
|
+
- ✅ **No File Limits** - Review unlimited files
|
|
444
|
+
- ✅ **Smart Rate Limiting** (3-second delays between batches)
|
|
445
|
+
- ✅ **Progress Tracking** for long reviews
|
|
446
|
+
- ✅ **Error Recovery** - continues even if one batch fails
|
|
447
|
+
- ✅ **Memory Efficient** - processes in manageable chunks
|
|
193
448
|
|
|
194
449
|
## 📄 License
|
|
195
450
|
|
|
196
451
|
MIT License - see [LICENSE](LICENSE) file for details.
|
|
197
452
|
|
|
198
|
-
##
|
|
453
|
+
## 🤝 Contributing
|
|
454
|
+
|
|
455
|
+
Contributions welcome! Feel free to:
|
|
456
|
+
- Report bugs or request features
|
|
457
|
+
- Submit pull requests
|
|
458
|
+
- Improve documentation
|
|
459
|
+
- Share usage examples
|
|
460
|
+
|
|
461
|
+
## 📞 Support
|
|
199
462
|
|
|
200
|
-
- **
|
|
201
|
-
- **
|
|
202
|
-
- **Use `--verbose`** to see what's being analyzed
|
|
203
|
-
- **Try different models** for varying levels of detail
|
|
204
|
-
- **Set up aliases** in your shell for quick access:
|
|
205
|
-
```bash
|
|
206
|
-
alias review="ai-pr-review review"
|
|
207
|
-
alias aipr="ai-pr-review review"
|
|
208
|
-
```
|
|
463
|
+
- **Issues**: [GitHub Issues](https://github.com/blockDeepanshu/ai-pr-review/issues)
|
|
464
|
+
- **Discussions**: [GitHub Discussions](https://github.com/blockDeepanshu/ai-pr-review/discussions)
|
|
209
465
|
|
|
210
466
|
---
|
|
211
467
|
|
|
212
|
-
Made with ❤️ for developers who want
|
|
468
|
+
**Made with ❤️ for developers who want smarter code reviews**
|
|
469
|
+
|
|
470
|
+
*Save time, catch bugs, and improve code quality with AI-powered reviews* 🚀
|