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