job51-gitlab-cr-node-jt-1 2.3.3 → 2.3.4

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/index.js +28 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -61,6 +61,7 @@ class GitLabCodeReviewer {
61
61
  // 最多重试3次,直到结果包含"🤖 AI 代码审查结果"或达到最大重试次数
62
62
  let attempts = 0;
63
63
  const maxAttempts = 5;
64
+ let claudeResult = null;
64
65
 
65
66
  while (attempts < maxAttempts) {
66
67
  attempts++;
@@ -68,7 +69,7 @@ class GitLabCodeReviewer {
68
69
  debugLog(`调用本地AI命令审核文件 (尝试 ${attempts}/${maxAttempts})`);
69
70
 
70
71
  // 直接将prompt内容传递给Claude命令
71
- const claudeResult = await runClaudeCommand(prompt);
72
+ claudeResult = await runClaudeCommand(prompt);
72
73
 
73
74
  debugLog(`本地AI命令审核完成,AI审核结果: ${claudeResult}`);
74
75
 
@@ -83,11 +84,19 @@ class GitLabCodeReviewer {
83
84
  } else {
84
85
  debugLog(`AI审核结果不包含"🤖 AI 代码审查结果" (尝试 ${attempts}),将重试...`);
85
86
  if (attempts >= maxAttempts) {
86
- debugLog(`已达到最大重试次数 ${maxAttempts},返回最后一次结果,${claudeResult}`);
87
+ debugLog(`已达到最大重试次数 ${maxAttempts},返回最后一次结果`);
87
88
 
88
- // 提取REPORT标签内容并返回
89
- // 提取 REPORT 标签和 LINE_INFO 标签内容并返回对象
90
- return extractReportContent(claudeResult);
89
+ // 验证报告有效性:检查 LINE_INFO 是否为空且报告内容是否过短
90
+ const lineInfoEmpty = claudeResult.includes('<LINE_INFO>[]</LINE_INFO>');
91
+ const reportTooShort = claudeResult.length < 100;
92
+
93
+ // 如果 LINE_INFO 为空且报告内容很短,说明无实质问题
94
+ if (lineInfoEmpty && reportTooShort) {
95
+ debugLog(`报告无实质问题,修正为标准无问题格式`);
96
+ claudeResult = '<REPORT>\n## 🤖 AI 代码审查结果\n\n</REPORT>\n\n<LINE_INFO>\n[]\n</LINE_INFO>';
97
+ }
98
+
99
+ return extractReportContent(claudeResult);
91
100
  }
92
101
  }
93
102
  } catch (error) {
@@ -219,6 +228,7 @@ ${diffObject.diff}`;
219
228
  // 最多重试5次,直到结果包含"🤖 AI 代码审查结果"或达到最大重试次数
220
229
  let attempts = 0;
221
230
  const maxAttempts = 5;
231
+ let claudeResult = null;
222
232
 
223
233
  while (attempts < maxAttempts) {
224
234
  attempts++;
@@ -226,7 +236,7 @@ ${diffObject.diff}`;
226
236
  debugLog(`调用本地AI命令审核文件 (尝试 ${attempts}/${maxAttempts})`);
227
237
 
228
238
  // 直接将prompt内容(包含文件路径)传递给Claude命令
229
- const claudeResult = await runClaudeCommand(prompt);
239
+ claudeResult = await runClaudeCommand(prompt);
230
240
  //若结果为空,则记录日志
231
241
  if (!claudeResult) {
232
242
  debugLog(`本地AI命令审核结果为空`);
@@ -242,11 +252,19 @@ ${diffObject.diff}`;
242
252
  } else {
243
253
  debugLog(`AI审核结果不包含"🤖 AI 代码审查结果" (尝试 ${attempts}),将重试...`);
244
254
  if (attempts >= maxAttempts) {
245
- debugLog(`已达到最大重试次数 ${maxAttempts},返回最后一次结果,${claudeResult}`);
255
+ debugLog(`已达到最大重试次数 ${maxAttempts},返回最后一次结果`);
246
256
 
247
- // 提取REPORT标签内容并返回
248
- // 提取 REPORT 标签和 LINE_INFO 标签内容并返回对象
249
- return extractReportContent(claudeResult);
257
+ // 验证报告有效性:检查 LINE_INFO 是否为空且报告内容是否过短
258
+ const lineInfoEmpty = claudeResult.includes('<LINE_INFO>[]</LINE_INFO>');
259
+ const reportTooShort = claudeResult.length < 100;
260
+
261
+ // 如果 LINE_INFO 为空且报告内容很短,说明无实质问题
262
+ if (lineInfoEmpty && reportTooShort) {
263
+ debugLog(`报告无实质问题,修正为标准无问题格式`);
264
+ claudeResult = '<REPORT>\n## 🤖 AI 代码审查结果\n\n</REPORT>\n\n<LINE_INFO>\n[]\n</LINE_INFO>';
265
+ }
266
+
267
+ return extractReportContent(claudeResult);
250
268
  }
251
269
  }
252
270
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "job51-gitlab-cr-node-jt-1",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "description": "GitLab merge request code review tool with AI-powered analysis and project context support",
5
5
  "main": "index.js",
6
6
  "bin": {