@newstarzj/cann-review 3.2.0 → 3.3.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/README.md +156 -107
- package/SKILL.md +121 -511
- package/index.js +67 -6
- package/package.json +12 -13
- package/skill.yaml +35 -90
- package/INSTALL.md +0 -168
- package/auto-review-final.sh +0 -170
- package/auto-review-post-comment.sh +0 -197
- package/auto-review-single-simple.sh +0 -123
- package/auto-review-single-v2.sh +0 -183
- package/auto-review-single.sh +0 -172
- package/auto-review.sh +0 -170
- package/check-mentions.py +0 -145
- package/check-mentions.sh +0 -128
- package/cron.yaml +0 -89
- package/post-install.sh +0 -41
- package/prompt.md +0 -212
- package/simple-review.sh +0 -56
- package/test-api.sh +0 -86
- package/test-auto-review.sh +0 -26
package/README.md
CHANGED
|
@@ -1,186 +1,235 @@
|
|
|
1
|
-
# CANN
|
|
1
|
+
# CANN Code Review Skill 🔍
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://badge.fury.io/js/@newstarzj/cann-review)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
🤖 **自动化代码审查技能 - 专为 CANN 项目设计**
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
8
|
+
自动分析 GitCode PR 代码变更,检查内存泄漏、安全漏洞和可读性,生成结构化报告并发布评论。
|
|
9
|
+
|
|
10
|
+
## ✨ 核心功能
|
|
11
|
+
|
|
12
|
+
- 🚀 **自动分析代码变更** - 使用 GitCode API 获取 PR 信息
|
|
13
|
+
- 🔍 **全面质量检查** - 内存泄漏、安全漏洞、代码可读性
|
|
14
|
+
- 📊 **结构化报告** - 清晰展示问题和改进建议
|
|
15
|
+
- 💬 **自动发布评论** - 直接发布到 GitCode PR
|
|
16
|
+
- ✅ **智能 LGTM** - 中低风险自动打上 `/lgtm` 标记
|
|
12
17
|
|
|
13
18
|
## 📦 安装
|
|
14
19
|
|
|
15
|
-
### 1
|
|
20
|
+
### 方式 1: npx 直接使用(推荐)
|
|
21
|
+
|
|
22
|
+
无需安装,直接运行:
|
|
16
23
|
|
|
17
24
|
```bash
|
|
18
|
-
|
|
25
|
+
npx @newstarzj/cann-review
|
|
19
26
|
```
|
|
20
27
|
|
|
21
|
-
### 2
|
|
22
|
-
|
|
23
|
-
**首次使用必须配置 Token:**
|
|
28
|
+
### 方式 2: 全局安装
|
|
24
29
|
|
|
25
30
|
```bash
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
npm install -g @newstarzj/cann-review
|
|
32
|
+
cann-review
|
|
28
33
|
```
|
|
29
34
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<details>
|
|
33
|
-
<summary>📖 如何获取 Token?</summary>
|
|
35
|
+
### 方式 3: 在 OpenCode 中使用
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
2. 点击"生成新令牌"
|
|
37
|
-
3. 选择权限:`api`, `write_repository`
|
|
38
|
-
4. 复制生成的 Token
|
|
37
|
+
将此技能复制到 OpenCode 的 skills 目录:
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
```bash
|
|
40
|
+
# OpenCode 默认路径
|
|
41
|
+
cp -r ./ ~/.opencode/skills/cann-review/
|
|
42
|
+
```
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
<summary>🔧 其他配置方法</summary>
|
|
44
|
+
## 🚀 快速开始
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
### 1. 配置 GitCode API Token
|
|
46
47
|
|
|
47
48
|
```bash
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
# 获取 Token: https://gitcode.com/setting/token-classic
|
|
50
|
+
export GITCODE_API_TOKEN=your_token_here
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. 使用技能
|
|
54
|
+
|
|
55
|
+
在 OpenCode 中:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
审查这个 PR: https://gitcode.com/cann/runtime/merge_requests/628
|
|
51
59
|
```
|
|
52
60
|
|
|
53
|
-
|
|
61
|
+
或通过命令行:
|
|
54
62
|
|
|
55
63
|
```bash
|
|
56
|
-
|
|
64
|
+
npx @newstarzj/cann-review "https://gitcode.com/cann/runtime/merge_requests/628"
|
|
57
65
|
```
|
|
58
66
|
|
|
59
|
-
|
|
67
|
+
## 📖 使用示例
|
|
60
68
|
|
|
61
|
-
|
|
69
|
+
### 基本用法
|
|
62
70
|
|
|
63
|
-
|
|
71
|
+
```
|
|
72
|
+
审查这个 PR: https://gitcode.com/cann/runtime/merge_requests/628
|
|
73
|
+
```
|
|
64
74
|
|
|
65
|
-
|
|
75
|
+
### 仅检查安全问题
|
|
66
76
|
|
|
67
77
|
```
|
|
68
78
|
审查这个 PR: https://gitcode.com/cann/runtime/merge_requests/628
|
|
79
|
+
只检查安全漏洞
|
|
69
80
|
```
|
|
70
81
|
|
|
71
|
-
|
|
82
|
+
### 禁用自动 LGTM
|
|
72
83
|
|
|
73
84
|
```
|
|
74
|
-
|
|
85
|
+
审查这个 PR: https://gitcode.com/cann/runtime/merge_requests/628
|
|
86
|
+
不要自动打 lgtm
|
|
75
87
|
```
|
|
76
88
|
|
|
77
|
-
|
|
89
|
+
## 🎯 审查报告示例
|
|
78
90
|
|
|
79
|
-
|
|
91
|
+
```markdown
|
|
92
|
+
## 🤖 CANN 代码审查报告
|
|
80
93
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
task: "cann-review auto"
|
|
85
|
-
```
|
|
94
|
+
**PR**: #628 - Fix memory leak in buffer allocation
|
|
95
|
+
**严重性**: ✅ Low
|
|
96
|
+
**审查时间**: 2026-03-12 21:30
|
|
86
97
|
|
|
87
|
-
|
|
98
|
+
---
|
|
88
99
|
|
|
89
|
-
|
|
100
|
+
### 📊 审查结论
|
|
90
101
|
|
|
91
|
-
|
|
92
|
-
# 获取 PR 信息
|
|
93
|
-
./gitcode-api.sh get-pr cann runtime 628
|
|
102
|
+
**✅ 建议合入**
|
|
94
103
|
|
|
95
|
-
|
|
96
|
-
|
|
104
|
+
- **严重性**: Low
|
|
105
|
+
- **代码质量**: 良好
|
|
106
|
+
- **内存安全**: ✅ 无风险
|
|
107
|
+
- **安全性**: ✅ 无漏洞
|
|
97
108
|
|
|
98
|
-
|
|
99
|
-
./gitcode-api.sh post-comment cann runtime 628 "LGTM!"
|
|
109
|
+
代码质量良好,修复了内存泄漏问题,建议合入。
|
|
100
110
|
|
|
101
|
-
|
|
102
|
-
./gitcode-api.sh list-prs cann runtime
|
|
103
|
-
```
|
|
111
|
+
---
|
|
104
112
|
|
|
105
|
-
|
|
113
|
+
### 🔍 详细检查
|
|
106
114
|
|
|
107
|
-
|
|
115
|
+
#### 1. 内存安全 ✅
|
|
116
|
+
- **内存泄漏**: 已修复
|
|
117
|
+
- **指针操作**: 安全
|
|
118
|
+
- **资源管理**: RAII 模式
|
|
108
119
|
|
|
109
|
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
|
|
113
|
-
- 安全性
|
|
114
|
-
- 可读性
|
|
115
|
-
- 逻辑正确性
|
|
116
|
-
- **改进建议**:具体优化建议
|
|
117
|
-
- **代码亮点**:做得好的地方
|
|
120
|
+
#### 2. 安全性 ✅
|
|
121
|
+
- **边界检查**: 完整
|
|
122
|
+
- **输入验证**: 完整
|
|
123
|
+
- **潜在漏洞**: 无
|
|
118
124
|
|
|
119
|
-
|
|
125
|
+
#### 3. 可读性 ✅
|
|
126
|
+
- **代码清晰度**: 良好
|
|
127
|
+
- **命名规范**: 符合
|
|
128
|
+
- **注释完整性**: 部分
|
|
120
129
|
|
|
121
|
-
|
|
130
|
+
---
|
|
122
131
|
|
|
123
|
-
|
|
132
|
+
### 💡 改进建议
|
|
124
133
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
cat ~/.openclaw/workspace/skills/cann-review/config/gitcode.conf
|
|
128
|
-
```
|
|
134
|
+
1. **文档**: 为新增的内存管理类添加详细注释
|
|
135
|
+
2. **测试**: 增加边界条件的单元测试
|
|
129
136
|
|
|
130
|
-
|
|
137
|
+
---
|
|
131
138
|
|
|
132
|
-
|
|
139
|
+
### ✅ 代码亮点
|
|
133
140
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
141
|
+
- 使用 RAII 管理资源,避免内存泄漏
|
|
142
|
+
- 错误处理完整,异常路径安全
|
|
143
|
+
- 代码结构清晰,易于维护
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
**总体评价**: 高质量的内存管理修复,建议合入。
|
|
137
148
|
```
|
|
138
149
|
|
|
139
|
-
|
|
150
|
+
## ⚙️ 配置选项
|
|
151
|
+
|
|
152
|
+
| 选项 | 说明 | 默认值 |
|
|
153
|
+
|------|------|--------|
|
|
154
|
+
| `pr_url` | PR 页面链接(必需) | - |
|
|
155
|
+
| `focus_areas` | 审查重点 (memory/security/readability/all) | all |
|
|
156
|
+
| `auto_lgtm` | 中低风险自动 LGTM | true |
|
|
157
|
+
|
|
158
|
+
## 🔧 高级配置
|
|
159
|
+
|
|
160
|
+
创建配置文件 `~/.cann-review/config`:
|
|
140
161
|
|
|
141
162
|
```bash
|
|
142
|
-
|
|
143
|
-
|
|
163
|
+
# GitCode API Token
|
|
164
|
+
GITCODE_API_TOKEN=your_token_here
|
|
165
|
+
|
|
166
|
+
# 审查超时时间(秒)
|
|
167
|
+
REVIEW_TIMEOUT=300
|
|
168
|
+
|
|
169
|
+
# 最大文件数
|
|
170
|
+
MAX_FILES=100
|
|
144
171
|
```
|
|
145
172
|
|
|
146
|
-
|
|
173
|
+
## 📋 审查标准
|
|
174
|
+
|
|
175
|
+
### 严重程度判定
|
|
176
|
+
|
|
177
|
+
| 等级 | 条件 | 是否合入 | LGTM |
|
|
178
|
+
|------|------|---------|------|
|
|
179
|
+
| ✅ Low | 仅有建议性改进 | 可以 | 自动 |
|
|
180
|
+
| ⚠️ Medium | 有一般性问题 | 建议修改后 | 自动 |
|
|
181
|
+
| ❌ High | 有严重问题 | 需要修改 | 不发布 |
|
|
182
|
+
| 🔴 Critical | 有安全漏洞或严重内存问题 | 需要修改 | 不发布 |
|
|
147
183
|
|
|
148
|
-
|
|
184
|
+
### 检查项
|
|
149
185
|
|
|
150
|
-
|
|
151
|
-
-
|
|
152
|
-
-
|
|
186
|
+
#### 内存安全
|
|
187
|
+
- 动态内存分配/释放配对
|
|
188
|
+
- 异常路径资源释放
|
|
189
|
+
- RAII 模式使用
|
|
190
|
+
- 容器内存管理
|
|
153
191
|
|
|
154
|
-
|
|
192
|
+
#### 安全性
|
|
193
|
+
- 空指针检查
|
|
194
|
+
- 数组边界检查
|
|
195
|
+
- 安全函数使用
|
|
196
|
+
- 整数溢出检查
|
|
155
197
|
|
|
156
|
-
|
|
198
|
+
#### 可读性
|
|
199
|
+
- 命名清晰度
|
|
200
|
+
- 注释完整性
|
|
201
|
+
- 代码结构
|
|
202
|
+
- 风格一致性
|
|
203
|
+
|
|
204
|
+
## 🛠️ 开发
|
|
157
205
|
|
|
158
|
-
检查 Token 是否有效:
|
|
159
206
|
```bash
|
|
160
|
-
|
|
161
|
-
|
|
207
|
+
# 克隆仓库
|
|
208
|
+
git clone https://gitcode.com/your-repo/cann-review.git
|
|
162
209
|
|
|
163
|
-
|
|
210
|
+
# 安装依赖
|
|
211
|
+
npm install
|
|
164
212
|
|
|
165
|
-
|
|
213
|
+
# 测试
|
|
214
|
+
npm test
|
|
166
215
|
|
|
167
|
-
|
|
216
|
+
# 发布
|
|
217
|
+
npm publish
|
|
218
|
+
```
|
|
168
219
|
|
|
169
|
-
|
|
220
|
+
## 📄 License
|
|
170
221
|
|
|
171
|
-
|
|
222
|
+
MIT License - 详见 [LICENSE](LICENSE) 文件
|
|
172
223
|
|
|
173
|
-
|
|
174
|
-
- 🎉 **重大更新**:全面改用 GitCode API
|
|
175
|
-
- 🚀 提高稳定性和可靠性
|
|
176
|
-
- 📝 简化操作流程
|
|
224
|
+
## 🤝 贡献
|
|
177
225
|
|
|
178
|
-
|
|
226
|
+
欢迎提交 Issue 和 Pull Request!
|
|
179
227
|
|
|
180
|
-
##
|
|
228
|
+
## 📮 联系方式
|
|
181
229
|
|
|
182
|
-
|
|
230
|
+
- GitCode: https://gitcode.com/your-repo/cann-review
|
|
231
|
+
- Email: openclaw@gitcode.com
|
|
183
232
|
|
|
184
|
-
|
|
233
|
+
---
|
|
185
234
|
|
|
186
|
-
|
|
235
|
+
**Made with ❤️ by OpenClaw Team**
|