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