coderev-cli 1.0.2 → 1.0.4
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 +128 -112
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,140 +1,127 @@
|
|
|
1
|
-
# coderev-cli
|
|
1
|
+
# coderev-cli
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> 多智能体 AI 代码审查工具 — Security / Bug / Quality 三个 Agent 并行审查,带置信度评分。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/coderev-cli)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
---
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
你的代码 (git diff)
|
|
11
|
-
│
|
|
12
|
-
┌──────┼──────┐
|
|
13
|
-
▼ ▼ ▼
|
|
14
|
-
┌──────┐┌──────┐┌──────┐
|
|
15
|
-
│ 🔒 ││ 🐛 ││ 📐 │
|
|
16
|
-
│Security││ Bug ││Quality│
|
|
17
|
-
│Auditor││Detector││Check │
|
|
18
|
-
└──┬───┘└──┬───┘└──┬───┘
|
|
19
|
-
│ │ │
|
|
20
|
-
└───────┼───────┘
|
|
21
|
-
▼
|
|
22
|
-
┌──────────┐
|
|
23
|
-
│ 合并 & │
|
|
24
|
-
│ 置信度评分 │
|
|
25
|
-
│ (0-100) │
|
|
26
|
-
└────┬─────┘
|
|
27
|
-
▼
|
|
28
|
-
结构化审查报告
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
**3 个专业 Agent 并行工作**,从不同角度审查同一份代码:
|
|
9
|
+
## 安装
|
|
32
10
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
| 🐛 Bug Detector | 空指针、竞态条件、异步问题、逻辑错误 |
|
|
37
|
-
| 📐 Code Quality | 代码复杂度、DRY、命名规范、异常处理 |
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g coderev-cli
|
|
13
|
+
```
|
|
38
14
|
|
|
39
|
-
|
|
15
|
+
---
|
|
40
16
|
|
|
41
|
-
##
|
|
17
|
+
## 快速上手
|
|
42
18
|
|
|
43
19
|
```bash
|
|
44
|
-
# 1.
|
|
45
|
-
npm install -g coderev-cli
|
|
46
|
-
|
|
47
|
-
# 2. 初始化项目配置
|
|
20
|
+
# 1. 初始化项目配置
|
|
48
21
|
coderev init
|
|
49
22
|
|
|
50
|
-
#
|
|
51
|
-
export DEEPSEEK_API_KEY="
|
|
52
|
-
export OPENAI_API_KEY="sk-your-key-here" # OpenAI
|
|
23
|
+
# 2. 设置 API Key(支持 DeepSeek / OpenAI)
|
|
24
|
+
export DEEPSEEK_API_KEY="***"
|
|
53
25
|
|
|
54
|
-
#
|
|
26
|
+
# 3. 审查暂存区变更
|
|
55
27
|
coderev review
|
|
56
28
|
|
|
57
|
-
#
|
|
58
|
-
coderev review --repo . --base main --head feature
|
|
59
|
-
|
|
60
|
-
# 6. 或使用管道
|
|
29
|
+
# 4. 或传入 git diff
|
|
61
30
|
git diff main | coderev review
|
|
31
|
+
|
|
32
|
+
# 5. 或审查 PR
|
|
33
|
+
coderev review --pr owner/repo#42
|
|
62
34
|
```
|
|
63
35
|
|
|
64
|
-
|
|
36
|
+
---
|
|
65
37
|
|
|
66
|
-
|
|
38
|
+
## 架构
|
|
67
39
|
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
|
|
40
|
+
```
|
|
41
|
+
你的代码 (git diff)
|
|
42
|
+
│
|
|
43
|
+
┌──────┼──────┐
|
|
44
|
+
▼ ▼ ▼
|
|
45
|
+
┌──────┐┌──────┐┌──────┐
|
|
46
|
+
│ 🔒 ││ 🐛 ││ 📐 │
|
|
47
|
+
│ 安全 ││ 缺陷 ││ 质量 │
|
|
48
|
+
│ 审计 ││ 检测 ││ 检查 │
|
|
49
|
+
└──┬───┘└──┬───┘└──┬───┘
|
|
50
|
+
│ │ │
|
|
51
|
+
└───────┼───────┘
|
|
52
|
+
▼
|
|
53
|
+
┌──────────┐
|
|
54
|
+
│ 合并 & │
|
|
55
|
+
│ 置信度评分 │
|
|
56
|
+
│ (0-100) │
|
|
57
|
+
└────┬─────┘
|
|
58
|
+
▼
|
|
59
|
+
结构化审查报告
|
|
60
|
+
```
|
|
71
61
|
|
|
72
|
-
|
|
73
|
-
|
|
62
|
+
| Agent | 专注领域 |
|
|
63
|
+
|-------|---------|
|
|
64
|
+
| 🔒 安全审计 | SQL注入、XSS、SSRF、硬编码密钥、认证缺陷 |
|
|
65
|
+
| 🐛 缺陷检测 | 空指针、竞态条件、异步问题、逻辑错误 |
|
|
66
|
+
| 📐 质量检查 | 代码复杂度、DRY、命名规范、异常处理 |
|
|
74
67
|
|
|
75
|
-
|
|
76
|
-
coderev review --min-confidence 40
|
|
68
|
+
每个 issue 附带**置信度评分 (0-100)**,低于阈值(默认 60)自动过滤。多 Agent 发现的重复问题自动合并去重。
|
|
77
69
|
|
|
78
|
-
|
|
79
|
-
coderev review --single
|
|
70
|
+
---
|
|
80
71
|
|
|
81
|
-
|
|
82
|
-
coderev review --audit
|
|
72
|
+
## CLI 命令参考
|
|
83
73
|
|
|
84
|
-
|
|
85
|
-
coderev review --no-cache
|
|
74
|
+
### review
|
|
86
75
|
|
|
87
|
-
|
|
88
|
-
coderev review
|
|
76
|
+
```bash
|
|
77
|
+
coderev review # 多 Agent 并行审查(默认)
|
|
78
|
+
coderev review --min-confidence 80 # 提高阈值,减少误报
|
|
79
|
+
coderev review --single # 单 Agent 模式(v0.2 兼容,更省)
|
|
80
|
+
coderev review --audit # 安全审计模式(OWASP 级)
|
|
81
|
+
coderev review --no-cache # 跳过缓存
|
|
82
|
+
coderev review --format json # JSON 输出
|
|
89
83
|
```
|
|
90
84
|
|
|
91
|
-
###
|
|
85
|
+
### fix
|
|
92
86
|
|
|
93
87
|
```bash
|
|
94
|
-
coderev fix --file changes.diff
|
|
95
|
-
coderev fix --file changes.diff --apply
|
|
96
|
-
coderev hook install # 安装 git hook
|
|
97
|
-
coderev hook install pre-commit --min-score 70
|
|
98
|
-
coderev stats # 统计看板
|
|
99
|
-
coderev stats week # 本周统计
|
|
100
|
-
coderev cache status # 缓存状态
|
|
101
|
-
coderev cache clear # 清空缓存
|
|
102
|
-
coderev config show # 查看配置
|
|
88
|
+
coderev fix --file changes.diff # 自动修复建议
|
|
89
|
+
coderev fix --file changes.diff --apply # 生成并应用补丁
|
|
103
90
|
```
|
|
104
91
|
|
|
105
|
-
|
|
92
|
+
### PR 审查
|
|
106
93
|
|
|
107
94
|
```bash
|
|
108
|
-
coderev review --pr owner/repo#42 #
|
|
95
|
+
coderev review --pr owner/repo#42 # 审查外部 PR
|
|
109
96
|
coderev review --pr 42 # 自动检测当前仓库
|
|
110
97
|
coderev review --pr owner/repo#42 --post # 审查 + 贴评论
|
|
111
98
|
coderev review --pr owner/repo#42 --inline # 行内评论
|
|
112
|
-
coderev review --pr owner/repo#42 --format json
|
|
99
|
+
coderev review --pr owner/repo#42 --format json
|
|
113
100
|
```
|
|
114
101
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
## 📝 项目上下文(.coderevhint)
|
|
102
|
+
### Git Hooks
|
|
118
103
|
|
|
119
|
-
|
|
104
|
+
```bash
|
|
105
|
+
coderev hook install # 安装 pre-commit
|
|
106
|
+
coderev hook install pre-commit --min-score 70
|
|
107
|
+
coderev hook install pre-push
|
|
108
|
+
```
|
|
120
109
|
|
|
121
|
-
|
|
110
|
+
### 其他
|
|
122
111
|
|
|
123
|
-
|
|
112
|
+
```bash
|
|
113
|
+
coderev stats # 统计看板
|
|
114
|
+
coderev stats week # 本周统计
|
|
115
|
+
coderev cache status # 缓存状态
|
|
116
|
+
coderev cache clear # 清空缓存
|
|
117
|
+
coderev config show # 查看配置
|
|
118
|
+
```
|
|
124
119
|
|
|
125
|
-
|
|
120
|
+
---
|
|
126
121
|
|
|
127
|
-
|
|
128
|
-
|---|---|
|
|
129
|
-
| JavaScript | async/await 链、== vs ===、内存泄漏、import 循环依赖 |
|
|
130
|
-
| TypeScript | strict 模式、avoid any、泛型、类型断言 |
|
|
131
|
-
| Python | PEP 8、except 类型、mutable 默认参数、async 用法 |
|
|
132
|
-
| Rust | unsafe 审计、unwrap/expect、生命周期、ownership |
|
|
133
|
-
| Go | error handling、goroutine 安全、context 传播、data race |
|
|
134
|
-
| Java | null 处理、checked exception、== vs .equals()、线程安全 |
|
|
135
|
-
| SQL | 注入防护、N+1 查询、索引缺失、大 IN-clause |
|
|
122
|
+
## 配置管理
|
|
136
123
|
|
|
137
|
-
|
|
124
|
+
在项目根目录创建 `.coderevrc.json`:
|
|
138
125
|
|
|
139
126
|
```json
|
|
140
127
|
{
|
|
@@ -157,33 +144,62 @@ coderev 自动检测 diff 中的编程语言,为不同语言添加专项检查
|
|
|
157
144
|
}
|
|
158
145
|
```
|
|
159
146
|
|
|
160
|
-
|
|
147
|
+
内置 8 套预定义规则集,并支持 JS / TS / Python / Rust / Go / Java / SQL 语言专项规则。
|
|
161
148
|
|
|
162
|
-
|
|
149
|
+
### .coderevhint
|
|
163
150
|
|
|
164
|
-
|
|
151
|
+
项目上下文描述文件。AI 审查时自动加载并据此调整分析重点。兼容 `CLAUDE.md`。
|
|
165
152
|
|
|
166
|
-
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 支持的 Git 平台
|
|
156
|
+
|
|
157
|
+
| 平台 | PR 审查 | 评论回贴 |
|
|
158
|
+
|------|---------|---------|
|
|
159
|
+
| GitHub | ✅ | ✅ 行内 / 摘要 |
|
|
160
|
+
| GitLab | ✅ | ✅ |
|
|
161
|
+
| Gitee | ✅ | ✅ |
|
|
162
|
+
| Bitbucket | ✅ | ✅ |
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 缓存
|
|
167
|
+
|
|
168
|
+
- SHA256 摘要哈希
|
|
169
|
+
- 24 小时 TTL
|
|
170
|
+
- `coderev cache status` / `coderev cache clear`
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## CI / GitHub Actions
|
|
175
|
+
|
|
176
|
+
内置工作流文件 `.github/workflows/coderev-review.yml`,PR 自动审查。
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 项目结构
|
|
167
181
|
|
|
168
182
|
```
|
|
169
183
|
coderev/
|
|
170
184
|
├── src/
|
|
171
|
-
│ ├── cli.js
|
|
172
|
-
│ ├── reviewer.js
|
|
173
|
-
│ ├── config.js
|
|
174
|
-
│ ├── github.js
|
|
175
|
-
│ ├── gitlab.js
|
|
176
|
-
│ ├── gitee.js
|
|
177
|
-
│ ├── bitbucket.js
|
|
178
|
-
│ ├── cache.js
|
|
179
|
-
│ ├── rules.js
|
|
180
|
-
│ ├── stats.js
|
|
185
|
+
│ ├── cli.js # CLI 入口
|
|
186
|
+
│ ├── reviewer.js # 多 Agent 审查核心
|
|
187
|
+
│ ├── config.js # 配置加载
|
|
188
|
+
│ ├── github.js # GitHub API
|
|
189
|
+
│ ├── gitlab.js # GitLab API
|
|
190
|
+
│ ├── gitee.js # Gitee API
|
|
191
|
+
│ ├── bitbucket.js # Bitbucket API
|
|
192
|
+
│ ├── cache.js # 缓存系统
|
|
193
|
+
│ ├── rules.js # 规则引擎
|
|
194
|
+
│ ├── stats.js # 统计看板
|
|
181
195
|
│ └── coderev.test.js # 20 个单元测试
|
|
182
|
-
├── .github/workflows/
|
|
183
|
-
├── .coderevrc.json
|
|
184
|
-
├── .coderevignore
|
|
185
|
-
|
|
186
|
-
|
|
196
|
+
├── .github/workflows/
|
|
197
|
+
├── .coderevrc.json
|
|
198
|
+
├── .coderevignore
|
|
199
|
+
└── .coderevhint
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
187
203
|
|
|
188
204
|
## License
|
|
189
205
|
|