git-diff-ai-reviewer 1.1.0 → 1.1.4

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/README.md CHANGED
@@ -32,14 +32,16 @@ npm install --save-dev @anthropic-ai/sdk @google/genai
32
32
 
33
33
  ## Setup
34
34
 
35
- Set the API key for your chosen provider:
35
+ Set the API key for your chosen provider. You can set these as environment variables, or simply create a `.env` file in the root of your project:
36
36
 
37
37
  ```bash
38
+ # .env file
39
+
38
40
  # For Claude (Anthropic)
39
- export ANTHROPIC_API_KEY=your-key-here
41
+ ANTHROPIC_API_KEY=your-key-here
40
42
 
41
43
  # For Gemini (Google)
42
- export GEMINI_API_KEY=your-key-here
44
+ GEMINI_API_KEY=your-key-here
43
45
  ```
44
46
 
45
47
  ## Usage
@@ -129,12 +131,15 @@ Create `.ai-review.config.json` in your project root:
129
131
 
130
132
  ```json
131
133
  {
132
- "provider": "claude",
134
+ "provider": "gemini",
133
135
  "baseBranch": "main",
134
- "model": "",
136
+ "model": "gemini-2.0-flash",
135
137
  "maxTokens": 4096,
136
138
  "outputDir": "./reviews",
137
- "reviewRules": "standard"
139
+ "reviewRules": {
140
+ "preset": "standard",
141
+ "extend": []
142
+ }
138
143
  }
139
144
  ```
140
145
 
@@ -151,18 +156,33 @@ Create `.ai-review.config.json` in your project root:
151
156
 
152
157
  ### Custom Rules Example
153
158
 
159
+ You can completely replace the rules by providing an array:
160
+
154
161
  ```json
155
162
  {
156
163
  "provider": "gemini",
157
164
  "reviewRules": [
158
165
  "Use camelCase for variable names",
159
- "All functions must have JSDoc comments",
160
- "No inline styles in React components",
161
- "Database queries must use parameterized statements"
166
+ "All functions must have JSDoc comments"
162
167
  ]
163
168
  }
164
169
  ```
165
170
 
171
+ Or **extend** an existing preset with your own project-specific rules:
172
+
173
+ ```json
174
+ {
175
+ "provider": "gemini",
176
+ "reviewRules": {
177
+ "preset": "standard",
178
+ "extend": [
179
+ "No inline styles in React components",
180
+ "Database queries must use parameterized statements"
181
+ ]
182
+ }
183
+ }
184
+ ```
185
+
166
186
  ## Programmatic API
167
187
 
168
188
  ```javascript
@@ -181,7 +201,10 @@ const review = await reviewCode(diff, {
181
201
  provider,
182
202
  changedFiles: files,
183
203
  branchName: 'feature/xyz',
184
- reviewRules: STANDARD_RULES,
204
+ reviewRules: {
205
+ preset: 'standard',
206
+ extend: ['Check that all functions are properly documented']
207
+ },
185
208
  });
186
209
  ```
187
210
 
package/bin/review.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ require('dotenv').config();
3
4
  const path = require('path');
4
5
  const fs = require('fs');
5
6
  const { getDiff, getChangedFiles, getBranchName, isGitRepo } = require('../src/git');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-diff-ai-reviewer",
3
- "version": "1.1.0",
3
+ "version": "1.1.4",
4
4
  "description": "AI-powered code review using Claude or Gemini API. Reviews git branch diffs and generates actionable fix prompts.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -39,5 +39,8 @@
39
39
  "@google/genai": {
40
40
  "optional": true
41
41
  }
42
+ },
43
+ "dependencies": {
44
+ "dotenv": "^17.3.1"
42
45
  }
43
- }
46
+ }
package/src/rules.js CHANGED
@@ -85,6 +85,12 @@ function resolveRules(rulesConfig) {
85
85
  return rulesConfig;
86
86
  }
87
87
 
88
+ if (typeof rulesConfig === 'object' && !Array.isArray(rulesConfig)) {
89
+ const base = resolveRules(rulesConfig.preset || 'standard');
90
+ const custom = Array.isArray(rulesConfig.extend) ? rulesConfig.extend : [];
91
+ return [...base, ...custom];
92
+ }
93
+
88
94
  return STANDARD_RULES;
89
95
  }
90
96