git-diff-ai-reviewer 1.1.3 → 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 +26 -5
- package/package.json +1 -1
- package/src/rules.js +6 -0
package/README.md
CHANGED
|
@@ -136,7 +136,10 @@ Create `.ai-review.config.json` in your project root:
|
|
|
136
136
|
"model": "gemini-2.0-flash",
|
|
137
137
|
"maxTokens": 4096,
|
|
138
138
|
"outputDir": "./reviews",
|
|
139
|
-
"reviewRules":
|
|
139
|
+
"reviewRules": {
|
|
140
|
+
"preset": "standard",
|
|
141
|
+
"extend": []
|
|
142
|
+
}
|
|
140
143
|
}
|
|
141
144
|
```
|
|
142
145
|
|
|
@@ -153,18 +156,33 @@ Create `.ai-review.config.json` in your project root:
|
|
|
153
156
|
|
|
154
157
|
### Custom Rules Example
|
|
155
158
|
|
|
159
|
+
You can completely replace the rules by providing an array:
|
|
160
|
+
|
|
156
161
|
```json
|
|
157
162
|
{
|
|
158
163
|
"provider": "gemini",
|
|
159
164
|
"reviewRules": [
|
|
160
165
|
"Use camelCase for variable names",
|
|
161
|
-
"All functions must have JSDoc comments"
|
|
162
|
-
"No inline styles in React components",
|
|
163
|
-
"Database queries must use parameterized statements"
|
|
166
|
+
"All functions must have JSDoc comments"
|
|
164
167
|
]
|
|
165
168
|
}
|
|
166
169
|
```
|
|
167
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
|
+
|
|
168
186
|
## Programmatic API
|
|
169
187
|
|
|
170
188
|
```javascript
|
|
@@ -183,7 +201,10 @@ const review = await reviewCode(diff, {
|
|
|
183
201
|
provider,
|
|
184
202
|
changedFiles: files,
|
|
185
203
|
branchName: 'feature/xyz',
|
|
186
|
-
reviewRules:
|
|
204
|
+
reviewRules: {
|
|
205
|
+
preset: 'standard',
|
|
206
|
+
extend: ['Check that all functions are properly documented']
|
|
207
|
+
},
|
|
187
208
|
});
|
|
188
209
|
```
|
|
189
210
|
|
package/package.json
CHANGED
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
|
|