gitlab-ai-review 3.4.1 → 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 +34 -8
- package/package.json +1 -1
package/lib/prompt-tools.js
CHANGED
|
@@ -47,20 +47,33 @@ 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
|
-
|
|
58
|
+
const trimmedLine = line.trim();
|
|
59
|
+
// 跳过其他变更的内容
|
|
60
|
+
if (!otherChangesContent.includes(trimmedLine)) {
|
|
61
|
+
prompt += ` ${line}\n`;
|
|
62
|
+
}
|
|
54
63
|
});
|
|
55
64
|
}
|
|
56
65
|
|
|
57
66
|
// 变更行
|
|
58
67
|
prompt += `${change.type === 'addition' ? '+' : '-'} ${change.content}\n`;
|
|
59
68
|
|
|
60
|
-
//
|
|
69
|
+
// 下文(只显示不变的行,过滤掉其他变更的内容)
|
|
61
70
|
if (change.context?.after?.length > 0) {
|
|
62
71
|
change.context.after.forEach(line => {
|
|
63
|
-
|
|
72
|
+
const trimmedLine = line.trim();
|
|
73
|
+
// 跳过其他变更的内容
|
|
74
|
+
if (!otherChangesContent.includes(trimmedLine)) {
|
|
75
|
+
prompt += ` ${line}\n`;
|
|
76
|
+
}
|
|
64
77
|
});
|
|
65
78
|
}
|
|
66
79
|
|
|
@@ -255,20 +268,33 @@ export function buildFileReviewWithImpactPrompt(fileName, meaningfulChanges, imp
|
|
|
255
268
|
prompt += `**类型**: ${change.type === 'addition' ? '新增' : '删除'}\n`;
|
|
256
269
|
prompt += `**内容**:\n\`\`\`\n`;
|
|
257
270
|
|
|
258
|
-
//
|
|
271
|
+
// 收集所有其他变更的内容(用于过滤)
|
|
272
|
+
const otherChangesContent = meaningfulChanges
|
|
273
|
+
.filter((_, i) => i !== index)
|
|
274
|
+
.map(c => c.content.trim());
|
|
275
|
+
|
|
276
|
+
// 上下文(只显示不变的行,过滤掉其他变更的内容)
|
|
259
277
|
if (change.context?.before?.length > 0) {
|
|
260
278
|
change.context.before.forEach(line => {
|
|
261
|
-
|
|
279
|
+
const trimmedLine = line.trim();
|
|
280
|
+
// 跳过其他变更的内容
|
|
281
|
+
if (!otherChangesContent.includes(trimmedLine)) {
|
|
282
|
+
prompt += ` ${line}\n`;
|
|
283
|
+
}
|
|
262
284
|
});
|
|
263
285
|
}
|
|
264
286
|
|
|
265
287
|
// 变更行
|
|
266
288
|
prompt += `${change.type === 'addition' ? '+' : '-'} ${change.content}\n`;
|
|
267
289
|
|
|
268
|
-
//
|
|
290
|
+
// 下文(只显示不变的行,过滤掉其他变更的内容)
|
|
269
291
|
if (change.context?.after?.length > 0) {
|
|
270
292
|
change.context.after.forEach(line => {
|
|
271
|
-
|
|
293
|
+
const trimmedLine = line.trim();
|
|
294
|
+
// 跳过其他变更的内容
|
|
295
|
+
if (!otherChangesContent.includes(trimmedLine)) {
|
|
296
|
+
prompt += ` ${line}\n`;
|
|
297
|
+
}
|
|
272
298
|
});
|
|
273
299
|
}
|
|
274
300
|
|