gitlab-ai-review 3.5.0 → 3.5.1
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/lib/prompt-tools.js +26 -12
- package/package.json +1 -1
package/lib/prompt-tools.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
293
|
+
const trimmedLine = line.trim();
|
|
294
|
+
// 跳过其他变更的内容
|
|
295
|
+
if (!otherChangesContent.includes(trimmedLine)) {
|
|
282
296
|
prompt += ` ${line}\n`;
|
|
283
297
|
}
|
|
284
298
|
});
|