gitlab-ai-review 3.5.0 → 3.6.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.
Files changed (2) hide show
  1. package/lib/prompt-tools.js +26 -12
  2. package/package.json +1 -1
@@ -47,11 +47,17 @@ export function buildFileReviewPrompt(fileName, meaningfulChanges) {
47
47
  prompt += `**类型**: ${change.type === 'addition' ? '新增' : '删除'}\n`;
48
48
  prompt += `**内容**:\n\`\`\`\n`;
49
49
 
50
- // 上下文(只显示不变的行,过滤掉 + 和 - 开头的变更行)
50
+ // 收集所有其他变更的内容(用于过滤)
51
+ const otherChangesContent = meaningfulChanges
52
+ .filter((_, i) => i !== index)
53
+ .map(c => c.content.trim());
54
+
55
+ // 上下文(只显示不变的行,过滤掉其他变更的内容)
51
56
  if (change.context?.before?.length > 0) {
52
57
  change.context.before.forEach(line => {
53
- // 跳过变更行(以 + 或 - 开头)
54
- if (!line.trim().startsWith('+') && !line.trim().startsWith('-')) {
58
+ const trimmedLine = line.trim();
59
+ // 跳过其他变更的内容
60
+ if (!otherChangesContent.includes(trimmedLine)) {
55
61
  prompt += ` ${line}\n`;
56
62
  }
57
63
  });
@@ -60,11 +66,12 @@ export function buildFileReviewPrompt(fileName, meaningfulChanges) {
60
66
  // 变更行
61
67
  prompt += `${change.type === 'addition' ? '+' : '-'} ${change.content}\n`;
62
68
 
63
- // 下文(只显示不变的行)
69
+ // 下文(只显示不变的行,过滤掉其他变更的内容)
64
70
  if (change.context?.after?.length > 0) {
65
71
  change.context.after.forEach(line => {
66
- // 跳过变更行(以 + 或 - 开头)
67
- if (!line.trim().startsWith('+') && !line.trim().startsWith('-')) {
72
+ const trimmedLine = line.trim();
73
+ // 跳过其他变更的内容
74
+ if (!otherChangesContent.includes(trimmedLine)) {
68
75
  prompt += ` ${line}\n`;
69
76
  }
70
77
  });
@@ -261,11 +268,17 @@ export function buildFileReviewWithImpactPrompt(fileName, meaningfulChanges, imp
261
268
  prompt += `**类型**: ${change.type === 'addition' ? '新增' : '删除'}\n`;
262
269
  prompt += `**内容**:\n\`\`\`\n`;
263
270
 
264
- // 上下文(只显示不变的行,过滤掉 + 和 - 开头的变更行)
271
+ // 收集所有其他变更的内容(用于过滤)
272
+ const otherChangesContent = meaningfulChanges
273
+ .filter((_, i) => i !== index)
274
+ .map(c => c.content.trim());
275
+
276
+ // 上下文(只显示不变的行,过滤掉其他变更的内容)
265
277
  if (change.context?.before?.length > 0) {
266
278
  change.context.before.forEach(line => {
267
- // 跳过变更行(以 + 或 - 开头)
268
- if (!line.trim().startsWith('+') && !line.trim().startsWith('-')) {
279
+ const trimmedLine = line.trim();
280
+ // 跳过其他变更的内容
281
+ if (!otherChangesContent.includes(trimmedLine)) {
269
282
  prompt += ` ${line}\n`;
270
283
  }
271
284
  });
@@ -274,11 +287,12 @@ export function buildFileReviewWithImpactPrompt(fileName, meaningfulChanges, imp
274
287
  // 变更行
275
288
  prompt += `${change.type === 'addition' ? '+' : '-'} ${change.content}\n`;
276
289
 
277
- // 下文(只显示不变的行)
290
+ // 下文(只显示不变的行,过滤掉其他变更的内容)
278
291
  if (change.context?.after?.length > 0) {
279
292
  change.context.after.forEach(line => {
280
- // 跳过变更行(以 + 或 - 开头)
281
- if (!line.trim().startsWith('+') && !line.trim().startsWith('-')) {
293
+ const trimmedLine = line.trim();
294
+ // 跳过其他变更的内容
295
+ if (!otherChangesContent.includes(trimmedLine)) {
282
296
  prompt += ` ${line}\n`;
283
297
  }
284
298
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitlab-ai-review",
3
- "version": "3.5.0",
3
+ "version": "3.6.0",
4
4
  "description": "GitLab AI Review SDK with Impact Analysis - 支持影响分析、删除符号检测、注释代码识别、文件内部冲突检查、智能文件过滤的智能代码审查工具",
5
5
  "main": "index.js",
6
6
  "type": "module",