gitlab-ai-review 2.1.0 → 2.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/index.js CHANGED
@@ -15,7 +15,7 @@ import * as DiffParser from './lib/diff-parser.js';
15
15
  export class GitLabAIReview {
16
16
  constructor(options = {}) {
17
17
  this.name = 'GitLab AI Review SDK';
18
- this.version = '2.1.0';
18
+ this.version = '2.2.0';
19
19
 
20
20
  // 如果传入了配置,使用手动配置;否则使用自动检测
21
21
  if (options.token || options.gitlab) {
@@ -181,17 +181,18 @@ export class GitLabAIReview {
181
181
  /**
182
182
  * AI 审查 MR 的所有有意义的变更并自动添加行级评论(按文件批量处理)
183
183
  * @param {Object} options - 选项
184
- * @param {number} options.maxFiles - 最大审查文件数量(默认 5)
184
+ * @param {number} options.maxFiles - 最大审查文件数量(默认不限制)
185
185
  * @returns {Promise<Array>} 评论结果数组
186
186
  */
187
187
  async reviewAndCommentOnLines(options = {}) {
188
- const { maxFiles = 5 } = options;
188
+ const { maxFiles = Infinity } = options;
189
189
  const changes = await this.getMergeRequestChanges();
190
190
  const results = [];
191
191
 
192
- console.log(`共 ${changes.length} 个文件需要审查(最多审查 ${maxFiles} 个)`);
192
+ const filesToReview = maxFiles === Infinity ? changes.length : Math.min(maxFiles, changes.length);
193
+ console.log(`共 ${changes.length} 个文件需要审查${maxFiles === Infinity ? '(不限制数量)' : `(最多审查 ${maxFiles} 个)`}`);
193
194
 
194
- for (const change of changes.slice(0, maxFiles)) {
195
+ for (const change of changes.slice(0, filesToReview)) {
195
196
  const fileName = change.new_path || change.old_path;
196
197
 
197
198
  try {
@@ -136,7 +136,8 @@ export function buildFileReviewPrompt(fileName, meaningfulChanges) {
136
136
 
137
137
  1. 仔细审查每一行变更,判断是否存在问题
138
138
  2. **只对有问题的行提出审查意见**,没有问题的行不需要评论
139
- 3. 返回 JSON 格式的结果,格式如下:
139
+ 3. **必须使用中文**返回审查意见
140
+ 4. 返回 JSON 格式的结果,格式如下:
140
141
 
141
142
  \`\`\`json
142
143
  {
@@ -144,7 +145,7 @@ export function buildFileReviewPrompt(fileName, meaningfulChanges) {
144
145
  {
145
146
  "lineNumber": 15,
146
147
  "hasIssue": true,
147
- "comment": "具体的问题描述和改进建议"
148
+ "comment": "这里用中文描述具体的问题和改进建议"
148
149
  },
149
150
  {
150
151
  "lineNumber": 20,
@@ -154,8 +155,9 @@ export function buildFileReviewPrompt(fileName, meaningfulChanges) {
154
155
  }
155
156
  \`\`\`
156
157
 
157
- 4. 如果所有代码都没有问题,返回空的 reviews 数组:\`{"reviews": []}\`
158
- 5. 只返回 JSON,不要包含其他文字说明`;
158
+ 5. 如果所有代码都没有问题,返回空的 reviews 数组:\`{"reviews": []}\`
159
+ 6. 只返回 JSON,不要包含其他文字说明
160
+ 7. comment 字段必须使用中文,要简洁明了`;
159
161
 
160
162
  return prompt;
161
163
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitlab-ai-review",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "GitLab AI Review SDK - 按文件批量审查,只评论有问题的代码",
5
5
  "main": "index.js",
6
6
  "type": "module",