job51-gitlab-cr-node-jt-1 2.3.9 → 2.4.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/index.js +1 -1
- package/package.json +1 -1
- package/patch.js +0 -81
package/index.js
CHANGED
|
@@ -262,7 +262,7 @@ ${diffObject.diff}`;
|
|
|
262
262
|
//若结果为空,则记录日志
|
|
263
263
|
if (!claudeResult) {
|
|
264
264
|
debugLog(`本地AI命令审核结果为空`);
|
|
265
|
-
return { reportContent:
|
|
265
|
+
return { reportContent: '<REPORT>\n## 🤖 AI 代码审查结果\n\n</REPORT>', lineInfo: '[]' };
|
|
266
266
|
}
|
|
267
267
|
debugLog(`本地 AI 命令审核完成,审核结果长度:${claudeResult?.length || 0}`);
|
|
268
268
|
|
package/package.json
CHANGED
package/patch.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
|
|
4
|
-
const content = fs.readFileSync('index.js', 'utf-8');
|
|
5
|
-
|
|
6
|
-
const oldCode = `debugLog(\`本地 AI 命令审核完成,AI 审核结果:\${claudeResult}\`);
|
|
7
|
-
|
|
8
|
-
// 检查结果是否包含"🤖 AI 代码审查结果",如果包含则返回结果
|
|
9
|
-
if (claudeResult && claudeResult.includes('🤖 AI 代码审查结果')) {
|
|
10
|
-
debugLog(\`AI 审核成功,包含"🤖 AI 代码审查结果" (尝试 \${attempts})\`);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// 提取 REPORT 标签内容并返回
|
|
14
|
-
// 提取 REPORT 标签和 LINE_INFO 标签内容并返回对象
|
|
15
|
-
return extractReportContent(claudeResult);
|
|
16
|
-
} else {
|
|
17
|
-
debugLog(\`AI 审核结果不包含"🤖 AI 代码审查结果" (尝试 \${attempts}),将重试...\`);
|
|
18
|
-
if (attempts >= maxAttempts) {
|
|
19
|
-
debugLog(\`已达到最大重试次数 \${maxAttempts},返回最后一次结果\`);
|
|
20
|
-
|
|
21
|
-
// 验证报告有效性:检查 LINE_INFO 是否为空且报告内容是否过短
|
|
22
|
-
const lineInfoEmpty = claudeResult.includes('<LINE_INFO>[]</LINE_INFO>');
|
|
23
|
-
const reportTooShort = claudeResult.length < 100;
|
|
24
|
-
|
|
25
|
-
// 如果 LINE_INFO 为空且报告内容很短,说明无实质问题
|
|
26
|
-
if (lineInfoEmpty && reportTooShort) {
|
|
27
|
-
debugLog(\`报告无实质问题,修正为标准无问题格式\`);
|
|
28
|
-
claudeResult = '<REPORT>\\n## 🤖 AI 代码审查结果\\n\\n</REPORT>\\n\\n<LINE_INFO>\\n[]\\n</LINE_INFO>';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return extractReportContent(claudeResult);
|
|
32
|
-
}
|
|
33
|
-
}`;
|
|
34
|
-
|
|
35
|
-
const newCode = `debugLog(\`本地 AI 命令审核完成,AI 审核结果长度:\${claudeResult?.length || 0}\`);
|
|
36
|
-
|
|
37
|
-
// 提取关键标记
|
|
38
|
-
const hasLineInfoTag = claudeResult && claudeResult.includes('<LINE_INFO>') && claudeResult.includes('</LINE_INFO>');
|
|
39
|
-
const hasNonEmptyLineInfo = hasLineInfoTag && !claudeResult.includes('<LINE_INFO>[]</LINE_INFO>');
|
|
40
|
-
const hasEmptyLineInfo = hasLineInfoTag && claudeResult.includes('<LINE_INFO>[]</LINE_INFO>');
|
|
41
|
-
const hasReportTag = claudeResult && claudeResult.includes('<REPORT>') && claudeResult.includes('</REPORT>');
|
|
42
|
-
|
|
43
|
-
// 情况 1:LINE_INFO 有行号信息 → 说明 AI 发现了问题,直接接受
|
|
44
|
-
if (hasNonEmptyLineInfo) {
|
|
45
|
-
debugLog(\`LINE_INFO 包含行号信息,AI 发现了问题,直接接受结果 (尝试 \${attempts})\`);
|
|
46
|
-
return extractReportContent(claudeResult);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// 情况 2:LINE_INFO 为空数组且有 REPORT 标签 → 无问题,直接接受(不重试)
|
|
50
|
-
if (hasEmptyLineInfo && hasReportTag) {
|
|
51
|
-
debugLog(\`LINE_INFO 为空数组,AI 报告无问题,直接接受结果 (尝试 \${attempts})\`);
|
|
52
|
-
return extractReportContent(claudeResult);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// 情况 3:只有 REPORT 标签,无 LINE_INFO → 标准化后接受
|
|
56
|
-
if (hasReportTag && !hasLineInfoTag) {
|
|
57
|
-
debugLog(\`报告包含基本标签结构但缺少 LINE_INFO,补充后接受 (尝试 \${attempts})\`);
|
|
58
|
-
claudeResult = claudeResult + '\\n\\n<LINE_INFO>[]</LINE_INFO>';
|
|
59
|
-
return extractReportContent(claudeResult);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// 情况 4:没有任何有效结构 → 重试
|
|
63
|
-
debugLog(\`AI 审核结果无有效报告结构 (尝试 \${attempts}),将重试...\`);
|
|
64
|
-
if (attempts >= maxAttempts) {
|
|
65
|
-
debugLog(\`已达到最大重试次数 \${maxAttempts},返回标准无问题格式\`);
|
|
66
|
-
claudeResult = '<REPORT>\\n## 🤖 AI 代码审查结果\\n\\n</REPORT>\\n\\n<LINE_INFO>[]</LINE_INFO>';
|
|
67
|
-
return extractReportContent(claudeResult);
|
|
68
|
-
}`;
|
|
69
|
-
|
|
70
|
-
if (content.includes(oldCode)) {
|
|
71
|
-
const newContent = content.replace(oldCode, newCode);
|
|
72
|
-
fs.writeFileSync('index.js', newContent, 'utf-8');
|
|
73
|
-
console.log('✅ index.js 更新成功');
|
|
74
|
-
} else {
|
|
75
|
-
console.log('❌ 未找到目标代码');
|
|
76
|
-
console.log('当前文件内容片段:');
|
|
77
|
-
const idx = content.indexOf('AI 审核结果');
|
|
78
|
-
if (idx !== -1) {
|
|
79
|
-
console.log(content.substring(idx, idx + 200));
|
|
80
|
-
}
|
|
81
|
-
}
|