job51-gitlab-cr-node-jt-1 2.3.8 → 2.4.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/.claude/rules/code-review-rules.md +9 -0
- package/package.json +1 -1
- package/patch.js +0 -81
|
@@ -241,6 +241,11 @@
|
|
|
241
241
|
|
|
242
242
|
18. **输出格式**:严格参照 SKILL.md 模板,无某类问题时省略对应部分;
|
|
243
243
|
> - **必须输出 `<LINE_INFO>` 标签**:包含所有问题的行号信息
|
|
244
|
+
> - **LINE_INFO 输出约束**(关键规则):
|
|
245
|
+
> - **仅有存在严重问题时,才允许在 LINE_INFO 中输出行号数据**
|
|
246
|
+
> - **无严重问题时,LINE_INFO 必须输出空数组 `[]`**
|
|
247
|
+
> - **禁止在无严重问题时输出行号数据**
|
|
248
|
+
> - 示例:无问题时输出 `<LINE_INFO>[]</LINE_INFO>`,不得输出具体行号
|
|
244
249
|
> - **LINE_INFO 格式**(与 targetLine 结构一致):
|
|
245
250
|
```json
|
|
246
251
|
[{"new_path":"文件路径","new_line":行号,"old_path":"文件路径","old_line":行号}]
|
|
@@ -277,3 +282,7 @@
|
|
|
277
282
|
> - **禁止编造 diff 中没有的代码**,如报告中不得出现 diff 中完全不存在的条件判断、方法调用等
|
|
278
283
|
> - **验证方法**:将错误代码示例与 diff 内容逐行对比,确认每行代码都能对应上
|
|
279
284
|
> - [ ] **最终自检**:如果这段代码是安全的/正确的,我为什么要报告它?如无法回答,省略该问题
|
|
285
|
+
> - [ ] **LINE_INFO 输出验证**(关键规则):
|
|
286
|
+
> - **仅在有严重问题时,才允许在 LINE_INFO 中输出行号数据**
|
|
287
|
+
> - **无严重问题时,LINE_INFO 必须输出 `[]`**
|
|
288
|
+
> - **输出前检查**:是否有"🔴 严重问题"标题?如无,则 LINE_INFO 必须为空数组
|
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
|
-
}
|