job51-gitlab-cr-node-jt-1 2.4.3 → 2.4.5
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/skills/simple-code-review/SKILL.md +22 -11
- package/index.js +23 -19
- package/log.txt +704 -745
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
---
|
|
1
|
+
---
|
|
2
2
|
name: simple-code-review
|
|
3
3
|
description: 代码审查技能,审查变更代码并输出 REPORT 和 LINE_INFO
|
|
4
4
|
---
|
|
@@ -9,17 +9,18 @@ description: 代码审查技能,审查变更代码并输出 REPORT 和 LINE_IN
|
|
|
9
9
|
|
|
10
10
|
2. **解析文件信息**:从 `=== File Information ===` 部分提取
|
|
11
11
|
- `Block Index`: 当前块索引号
|
|
12
|
-
- `
|
|
12
|
+
- `New Start`: 当前 diff 块在变更后文件中的起始行号(**关键:用于计算绝对行号**)
|
|
13
|
+
- `New Count`: 当前 diff 块的行数
|
|
13
14
|
- `New Path` / `Old Path`: 文件路径(去掉 `a/` 或 `b/` 前缀)
|
|
14
15
|
|
|
15
|
-
3.
|
|
16
|
+
3. **解析行号**:使用 `New Start` 作为基准,遍历 diff 内容计算每行的绝对行号
|
|
16
17
|
- 行号计算规则:
|
|
17
|
-
-
|
|
18
|
+
- **基准行号** = `New Start`(从 File Information 中获取)
|
|
18
19
|
- 遍历 diff 内容,只计数 `+` 开头(新增)和空格开头(上下文)的行
|
|
19
|
-
- 第 1 行 `+` 或空格:行号 = `
|
|
20
|
-
- 第 2 行 `+` 或空格:行号 = `
|
|
20
|
+
- 第 1 行 `+` 或空格:行号 = `New Start`
|
|
21
|
+
- 第 2 行 `+` 或空格:行号 = `New Start + 1`
|
|
21
22
|
- 以此类推,`-` 开头的删除行不计入行号
|
|
22
|
-
-
|
|
23
|
+
- **重要**:行号是变更后文件中的绝对行号,必须使用 `New Start` 作为基准计算
|
|
23
24
|
|
|
24
25
|
4. **读取上下文**:基于 New Path 读取变更后文件,涉及方法调用时追踪读取实现代码
|
|
25
26
|
|
|
@@ -29,6 +30,7 @@ description: 代码审查技能,审查变更代码并输出 REPORT 和 LINE_IN
|
|
|
29
30
|
- 审查结果放入 `<REPORT>` 标签
|
|
30
31
|
- 行号信息放入 `<LINE_INFO>` 标签(必须输出)
|
|
31
32
|
- LINE_INFO 格式参考 @.claude/rules/code-review-rules.md 第 19 条
|
|
33
|
+
- **问题和行号对应**:`<LINE_INFO>` 中的第 N 个元素对应第 N 个问题的行号
|
|
32
34
|
|
|
33
35
|
## 输出模板
|
|
34
36
|
|
|
@@ -37,9 +39,16 @@ description: 代码审查技能,审查变更代码并输出 REPORT 和 LINE_IN
|
|
|
37
39
|
|
|
38
40
|
### 🔴 严重问题
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
---
|
|
43
|
+
**问题 1**:[问题描述]<br/>
|
|
44
|
+
**文件及行号**:[文件路径:行号]<br/>
|
|
45
|
+
**修改建议**:[正确示例代码或说明]
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
**问题 2**:[问题描述]<br/>
|
|
49
|
+
**文件及行号**:[文件路径:行号]<br/>
|
|
50
|
+
**修改建议**:[正确示例代码或说明]
|
|
51
|
+
---
|
|
43
52
|
|
|
44
53
|
</REPORT>
|
|
45
54
|
|
|
@@ -49,4 +58,6 @@ description: 代码审查技能,审查变更代码并输出 REPORT 和 LINE_IN
|
|
|
49
58
|
|
|
50
59
|
**说明**:
|
|
51
60
|
- 无问题时省略对应标题,但 `<LINE_INFO>` 必须输出(空数组:`[]`)
|
|
52
|
-
-
|
|
61
|
+
- 每个问题用 `---` 分割线分隔,方便切分
|
|
62
|
+
- **`<LINE_INFO>` 数组中的元素顺序必须与问题顺序一致**:第 1 个元素对应问题 1 的行号,第 2 个元素对应问题 2 的行号,以此类推
|
|
63
|
+
- 行号计算:使用 `New Start` 作为基准,第 1 行 `+` 或空格的行号 = `New Start`,第 2 行 = `New Start + 1`,依此类推
|
package/index.js
CHANGED
|
@@ -160,6 +160,8 @@ class GitLabCodeReviewer {
|
|
|
160
160
|
New Path: ${diffObject.new_path || 'N/A'}
|
|
161
161
|
Old Path: ${diffObject.old_path || 'N/A'}
|
|
162
162
|
Block Index: ${blockIndex}
|
|
163
|
+
New Start: ${diffObject.line_info?.new_start || 1}
|
|
164
|
+
New Count: ${diffObject.line_info?.new_count || 1}
|
|
163
165
|
=== Diff Content ===
|
|
164
166
|
${diffObject.diff}`;
|
|
165
167
|
|
|
@@ -512,30 +514,32 @@ ${diffObject.diff}`;
|
|
|
512
514
|
*/
|
|
513
515
|
extractSingleProblemReport(fullReport, problemIndex) {
|
|
514
516
|
const lines = fullReport.split('\n');
|
|
515
|
-
//
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
let
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
if (nextProblemRegex.test(lines[j])) {
|
|
528
|
-
endIndex = j;
|
|
529
|
-
break;
|
|
517
|
+
// 使用 --- 分割线来切分问题
|
|
518
|
+
const problemBlocks = [];
|
|
519
|
+
let currentBlock = [];
|
|
520
|
+
let inBlock = false;
|
|
521
|
+
|
|
522
|
+
for (const line of lines) {
|
|
523
|
+
if (line.trim() === '---') {
|
|
524
|
+
if (inBlock) {
|
|
525
|
+
// 块结束
|
|
526
|
+
if (currentBlock.length > 0) {
|
|
527
|
+
problemBlocks.push(currentBlock.join('\n'));
|
|
528
|
+
currentBlock = [];
|
|
530
529
|
}
|
|
530
|
+
inBlock = false;
|
|
531
|
+
} else {
|
|
532
|
+
// 块开始
|
|
533
|
+
inBlock = true;
|
|
531
534
|
}
|
|
532
|
-
|
|
535
|
+
} else if (inBlock) {
|
|
536
|
+
currentBlock.push(line);
|
|
533
537
|
}
|
|
534
538
|
}
|
|
535
539
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
return
|
|
540
|
+
// 返回第 problemIndex 个问题(索引从 1 开始)
|
|
541
|
+
if (problemIndex >= 1 && problemIndex <= problemBlocks.length) {
|
|
542
|
+
return problemBlocks[problemIndex - 1];
|
|
539
543
|
}
|
|
540
544
|
|
|
541
545
|
// 如果无法提取,返回完整报告(降级处理)
|