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.
- package/lib/prompt-tools.js +20 -8
- package/package.json +1 -1
package/lib/prompt-tools.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
280
|
+
// 跳过变更行(以 + 或 - 开头)
|
|
281
|
+
if (!line.trim().startsWith('+') && !line.trim().startsWith('-')) {
|
|
282
|
+
prompt += ` ${line}\n`;
|
|
283
|
+
}
|
|
272
284
|
});
|
|
273
285
|
}
|
|
274
286
|
|