@newstarzj/cann-review 3.2.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/INSTALL.md ADDED
@@ -0,0 +1,168 @@
1
+ # CANN Review Skill 安装指南
2
+
3
+ ## 安装步骤
4
+
5
+ ### 1. 安装 Skill
6
+
7
+ ```bash
8
+ # 从本地安装
9
+ cd /Users/zj/.openclaw/workspace/skills/cann-review
10
+ claw install .
11
+
12
+ # 或从 ClawHub 安装(如果已发布)
13
+ claw install cann-review
14
+ ```
15
+
16
+ ### 2. 配置自动审查(可选)
17
+
18
+ 如果你想启用定时自动审查功能,需要配置 cron 任务。
19
+
20
+ #### 方法一:使用 OpenClaw Cron 工具
21
+
22
+ 1. **查看当前 cron 状态**
23
+ ```bash
24
+ claw cron status
25
+ ```
26
+
27
+ 2. **添加定时任务**
28
+
29
+ 编辑 cron.yaml 文件,根据需要调整调度时间:
30
+
31
+ ```yaml
32
+ auto_review:
33
+ schedule: "0 */2 * * *" # 每 2 小时执行一次
34
+ enabled: true
35
+ ```
36
+
37
+ 3. **应用 cron 配置**
38
+
39
+ 使用 OpenClaw 的 cron 工具添加任务:
40
+
41
+ ```bash
42
+ # 添加自动审查任务
43
+ claw cron add \
44
+ --name "cann-auto-review" \
45
+ --schedule "0 */2 * * *" \
46
+ --skill "cann-review" \
47
+ --params '{"auto_mode": true, "max_reviews": 5}'
48
+ ```
49
+
50
+ 或者手动配置(需要管理员权限):
51
+
52
+ ```bash
53
+ # 编辑 crontab
54
+ crontab -e
55
+
56
+ # 添加以下行(每 2 小时执行一次)
57
+ 0 */2 * * * cd /Users/zj/.openclaw && claw run cann-review --auto-mode --max-reviews 5
58
+ ```
59
+
60
+ #### 方法二:使用 OpenClaw Gateway Cron
61
+
62
+ 如果你使用 OpenClaw Gateway,可以通过 API 添加 cron 任务:
63
+
64
+ ```bash
65
+ curl -X POST http://localhost:3000/api/cron/add \
66
+ -H "Content-Type: application/json" \
67
+ -d '{
68
+ "name": "cann-auto-review",
69
+ "schedule": {"kind": "cron", "expr": "0 */2 * * *"},
70
+ "payload": {
71
+ "kind": "agentTurn",
72
+ "message": "使用 cann-review skill 审查未读 MR",
73
+ "params": {
74
+ "auto_mode": true,
75
+ "max_reviews": 5
76
+ }
77
+ },
78
+ "sessionTarget": "isolated",
79
+ "enabled": true
80
+ }'
81
+ ```
82
+
83
+ ### 3. 验证安装
84
+
85
+ ```bash
86
+ # 测试手动审查
87
+ claw run cann-review --pr-url "https://gitcode.com/cann/runtime/pull/472"
88
+
89
+ # 测试自动审查(干运行)
90
+ claw run cann-review --auto-mode --max-reviews 1 --dry-run
91
+ ```
92
+
93
+ ## 配置选项
94
+
95
+ ### Cron 调度表达式
96
+
97
+ 常用调度示例:
98
+
99
+ | 表达式 | 说明 |
100
+ |--------|------|
101
+ | `0 */2 * * *` | 每 2 小时 |
102
+ | `0 9,15 * * *` | 每天 9:00 和 15:00 |
103
+ | `0 9 * * 1-5` | 周一到周五 9:00 |
104
+ | `0 10 * * 0,6` | 周末 10:00 |
105
+ | `*/30 * * * *` | 每 30 分钟 |
106
+
107
+ ### 审查参数
108
+
109
+ | 参数 | 默认值 | 说明 |
110
+ |------|--------|------|
111
+ | `focus_areas` | all | 审查重点(memory/security/readability/all) |
112
+ | `severity_threshold` | medium | LGTM 阈值(low/medium/high) |
113
+ | `max_reviews` | 5 | 单次最大审查数量 |
114
+ | `send_summary` | true | 是否发送汇总通知 |
115
+
116
+ ## 故障排查
117
+
118
+ ### 浏览器无法启动
119
+
120
+ 确保 OpenClaw 内置浏览器可用:
121
+
122
+ ```bash
123
+ claw browser status
124
+ claw browser start
125
+ ```
126
+
127
+ ### Cron 任务未执行
128
+
129
+ 检查 cron 日志:
130
+
131
+ ```bash
132
+ # 查看 OpenClaw cron 日志
133
+ tail -f /Users/zj/.openclaw/logs/cron.log
134
+
135
+ # 或查看系统 cron 日志
136
+ grep CRON /var/log/syslog
137
+ ```
138
+
139
+ ### 无法访问 GitCode
140
+
141
+ 确保已登录 GitCode:
142
+
143
+ ```bash
144
+ # 使用浏览器登录
145
+ claw browser open "https://gitcode.com"
146
+ ```
147
+
148
+ ## 卸载
149
+
150
+ ```bash
151
+ # 移除 skill
152
+ claw uninstall cann-review
153
+
154
+ # 移除 cron 任务
155
+ claw cron remove --name "cann-auto-review"
156
+ ```
157
+
158
+ ## 更新
159
+
160
+ ```bash
161
+ # 更新 skill
162
+ claw update cann-review
163
+
164
+ # 或从源码更新
165
+ cd /Users/zj/.openclaw/workspace/skills/cann-review
166
+ git pull
167
+ claw install .
168
+ ```
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OpenClaw Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,186 @@
1
+ # CANN 代码审查技能
2
+
3
+ 自动审查 GitCode 上的 CANN 项目 PR,检查内存泄漏、安全漏洞和代码可读性。
4
+
5
+ ## ✨ 特性
6
+
7
+ - 🔍 **全面代码审查**:内存泄漏、安全漏洞、代码可读性
8
+ - 🚀 **基于 API**:使用 GitCode API,无需浏览器自动化,稳定可靠
9
+ - 💬 **自动评论**:自动发布结构化审查报告
10
+ - ✅ **LGTM 支持**:低风险 PR 自动发布 `/lgtm`
11
+ - 🤖 **自动模式**:支持定时任务,自动审查新 PR
12
+
13
+ ## 📦 安装
14
+
15
+ ### 1. 安装技能
16
+
17
+ ```bash
18
+ clawhub install cann-review
19
+ ```
20
+
21
+ ### 2. 配置 GitCode API Token
22
+
23
+ **首次使用必须配置 Token:**
24
+
25
+ ```bash
26
+ cd ~/.openclaw/workspace/skills/cann-review
27
+ ./gitcode-api.sh setup
28
+ ```
29
+
30
+ 按提示输入你的 GitCode API Token。
31
+
32
+ <details>
33
+ <summary>📖 如何获取 Token?</summary>
34
+
35
+ 1. 访问 https://gitcode.com/setting/token-classic
36
+ 2. 点击"生成新令牌"
37
+ 3. 选择权限:`api`, `write_repository`
38
+ 4. 复制生成的 Token
39
+
40
+ </details>
41
+
42
+ <details>
43
+ <summary>🔧 其他配置方法</summary>
44
+
45
+ **方法 2:手动配置**
46
+
47
+ ```bash
48
+ cp config/gitcode.conf.example config/gitcode.conf
49
+ nano config/gitcode.conf
50
+ # 设置 GITCODE_API_TOKEN=your_token_here
51
+ ```
52
+
53
+ **方法 3:环境变量**
54
+
55
+ ```bash
56
+ export GITCODE_API_TOKEN=your_token_here
57
+ ```
58
+
59
+ </details>
60
+
61
+ ## 🚀 使用方法
62
+
63
+ ### 手动审查单个 PR
64
+
65
+ 直接提供 PR 链接:
66
+
67
+ ```
68
+ 审查这个 PR: https://gitcode.com/cann/runtime/merge_requests/628
69
+ ```
70
+
71
+ 或使用命令:
72
+
73
+ ```
74
+ cann review PR#628
75
+ ```
76
+
77
+ ### 自动审查模式
78
+
79
+ 配置定时任务,自动审查新 PR:
80
+
81
+ ```yaml
82
+ # 在 OpenClaw 中配置 cron 任务
83
+ schedule: "0 */2 * * *" # 每 2 小时执行一次
84
+ task: "cann-review auto"
85
+ ```
86
+
87
+ ## 🔧 API 辅助脚本
88
+
89
+ 提供了 `gitcode-api.sh` 辅助脚本:
90
+
91
+ ```bash
92
+ # 获取 PR 信息
93
+ ./gitcode-api.sh get-pr cann runtime 628
94
+
95
+ # 获取 PR 文件变更
96
+ ./gitcode-api.sh get-files cann runtime 628
97
+
98
+ # 发布评论
99
+ ./gitcode-api.sh post-comment cann runtime 628 "LGTM!"
100
+
101
+ # 列出开放的 PR
102
+ ./gitcode-api.sh list-prs cann runtime
103
+ ```
104
+
105
+ ## 📊 审查报告格式
106
+
107
+ 审查报告包括:
108
+
109
+ - **审查结论**:严重性评估和建议
110
+ - **修改概述**:变更文件和核心变更
111
+ - **代码质量检查**:
112
+ - 内存安全
113
+ - 安全性
114
+ - 可读性
115
+ - 逻辑正确性
116
+ - **改进建议**:具体优化建议
117
+ - **代码亮点**:做得好的地方
118
+
119
+ ## ⚙️ 配置
120
+
121
+ ### 配置文件
122
+
123
+ 配置文件位于:`~/.openclaw/workspace/skills/cann-review/config/gitcode.conf`
124
+
125
+ ```bash
126
+ # 查看当前配置
127
+ cat ~/.openclaw/workspace/skills/cann-review/config/gitcode.conf
128
+ ```
129
+
130
+ ### 环境变量(可选)
131
+
132
+ 也可以通过环境变量配置:
133
+
134
+ ```bash
135
+ export GITCODE_API_TOKEN=your_token_here
136
+ export GITCODE_API_BASE=https://api.gitcode.com/api/v5 # 可选
137
+ ```
138
+
139
+ ### 重新配置
140
+
141
+ ```bash
142
+ cd ~/.openclaw/workspace/skills/cann-review
143
+ ./gitcode-api.sh setup
144
+ ```
145
+
146
+ ### 审查阈值
147
+
148
+ 可在技能中调整发布 LGTM 的阈值:
149
+
150
+ - `low`: 仅低风险发布 LGTM
151
+ - `medium`: 低和中低风险发布 LGTM(默认)
152
+ - `high`: 低、中、高风险都发布 LGTM(不推荐)
153
+
154
+ ## 🐛 故障排查
155
+
156
+ ### API 返回 401
157
+
158
+ 检查 Token 是否有效:
159
+ ```bash
160
+ curl -H "Authorization: Bearer YOUR_TOKEN" https://api.gitcode.com/api/v5/user
161
+ ```
162
+
163
+ ### 无法评论已合并的 PR
164
+
165
+ 这是正常行为,已合并的 PR 可能禁止新评论。
166
+
167
+ ### API 频率限制
168
+
169
+ GitCode API 限制:50次/分钟,4000次/小时。如需大量审查,添加适当延迟。
170
+
171
+ ## 📝 版本历史
172
+
173
+ ### v3.0.0 (2026-03-04)
174
+ - 🎉 **重大更新**:全面改用 GitCode API
175
+ - 🚀 提高稳定性和可靠性
176
+ - 📝 简化操作流程
177
+
178
+ 详细版本历史见 SKILL.md
179
+
180
+ ## 📄 许可证
181
+
182
+ 内部使用
183
+
184
+ ## 🤝 贡献
185
+
186
+ 如有问题或建议,请联系维护团队。