gitlab-ai-review 3.4.1 → 3.5.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.
@@ -47,20 +47,26 @@ export function buildFileReviewPrompt(fileName, meaningfulChanges) {
47
47
  prompt += `**类型**: ${change.type === 'addition' ? '新增' : '删除'}\n`;
48
48
  prompt += `**内容**:\n\`\`\`\n`;
49
49
 
50
- // 上下文
50
+ // 上下文(只显示不变的行,过滤掉 + 和 - 开头的变更行)
51
51
  if (change.context?.before?.length > 0) {
52
52
  change.context.before.forEach(line => {
53
- prompt += ` ${line}\n`;
53
+ // 跳过变更行(以 + 或 - 开头)
54
+ if (!line.trim().startsWith('+') && !line.trim().startsWith('-')) {
55
+ prompt += ` ${line}\n`;
56
+ }
54
57
  });
55
58
  }
56
59
 
57
60
  // 变更行
58
61
  prompt += `${change.type === 'addition' ? '+' : '-'} ${change.content}\n`;
59
62
 
60
- // 下文
63
+ // 下文(只显示不变的行)
61
64
  if (change.context?.after?.length > 0) {
62
65
  change.context.after.forEach(line => {
63
- prompt += ` ${line}\n`;
66
+ // 跳过变更行(以 + 或 - 开头)
67
+ if (!line.trim().startsWith('+') && !line.trim().startsWith('-')) {
68
+ prompt += ` ${line}\n`;
69
+ }
64
70
  });
65
71
  }
66
72
 
@@ -255,20 +261,26 @@ export function buildFileReviewWithImpactPrompt(fileName, meaningfulChanges, imp
255
261
  prompt += `**类型**: ${change.type === 'addition' ? '新增' : '删除'}\n`;
256
262
  prompt += `**内容**:\n\`\`\`\n`;
257
263
 
258
- // 上下文
264
+ // 上下文(只显示不变的行,过滤掉 + 和 - 开头的变更行)
259
265
  if (change.context?.before?.length > 0) {
260
266
  change.context.before.forEach(line => {
261
- prompt += ` ${line}\n`;
267
+ // 跳过变更行(以 + 或 - 开头)
268
+ if (!line.trim().startsWith('+') && !line.trim().startsWith('-')) {
269
+ prompt += ` ${line}\n`;
270
+ }
262
271
  });
263
272
  }
264
273
 
265
274
  // 变更行
266
275
  prompt += `${change.type === 'addition' ? '+' : '-'} ${change.content}\n`;
267
276
 
268
- // 下文
277
+ // 下文(只显示不变的行)
269
278
  if (change.context?.after?.length > 0) {
270
279
  change.context.after.forEach(line => {
271
- prompt += ` ${line}\n`;
280
+ // 跳过变更行(以 + 或 - 开头)
281
+ if (!line.trim().startsWith('+') && !line.trim().startsWith('-')) {
282
+ prompt += ` ${line}\n`;
283
+ }
272
284
  });
273
285
  }
274
286
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitlab-ai-review",
3
- "version": "3.4.1",
3
+ "version": "3.5.0",
4
4
  "description": "GitLab AI Review SDK with Impact Analysis - 支持影响分析、删除符号检测、注释代码识别、文件内部冲突检查、智能文件过滤的智能代码审查工具",
5
5
  "main": "index.js",
6
6
  "type": "module",