best-review 0.5.8 → 0.5.11
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 +52 -14
- package/dist/best-review.cjs +239 -238
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
这个项目的重点不是替代人工 Review,而是把可重复的风险检查前置到本地、CI 和 GitLab Merge Request 流程里:
|
|
6
6
|
|
|
7
7
|
- 本地审查未提交变更、提交范围、指定文件或完整文件内容。
|
|
8
|
-
- GitLab MR
|
|
8
|
+
- GitLab MR 远程审查,可按配置把问题回评到 MR 行内 discussion。
|
|
9
9
|
- 内置 `general`、`bug-hunter`、`security-scan`、`performance-check`、`consistency-check`、`validation` Agent。
|
|
10
10
|
- 支持用户级规则、共享 `extends` 规则包和项目级 `skills/` 审查增强。
|
|
11
11
|
- 默认执行置信度过滤、去重、validation 复核,减少泛泛建议和误报。
|
|
12
12
|
- 支持显式自动修复严重风险,先生成 unified diff,并通过 `git apply --check` 后才写入。
|
|
13
|
-
- 生成本地 JSON
|
|
13
|
+
- 生成本地 JSON 报告;GitLab 写操作默认关闭,需要通过配置开关显式开启。
|
|
14
14
|
|
|
15
15
|
## 快速开始
|
|
16
16
|
|
|
@@ -41,7 +41,7 @@ best-review init --provider openai
|
|
|
41
41
|
best-review review
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
`best-review init` 会以选项式流程写入用户级 `~/.best-review/config.json
|
|
44
|
+
`best-review init` 会以选项式流程写入用户级 `~/.best-review/config.json`,并提示是否把 `GITLAB_TOKEN` 写入同一个用户级配置文件;直接回车可跳过。
|
|
45
45
|
|
|
46
46
|
## 常用命令
|
|
47
47
|
|
|
@@ -97,8 +97,11 @@ best-review review --fix-critical
|
|
|
97
97
|
best-review review --fix-severity critical,high --fix-dry-run
|
|
98
98
|
best-review review --fix-critical --fix-max-issues 3 --fix-patch-file ~/.best-review/fix.patch
|
|
99
99
|
|
|
100
|
-
# GitLab MR
|
|
101
|
-
|
|
100
|
+
# GitLab MR 远程审查(默认只读)
|
|
101
|
+
best-review review-mr https://gitlab.example.com/group/project/-/merge_requests/123
|
|
102
|
+
|
|
103
|
+
# 如需回评 MR discussion,先配置发布 token 并打开 gitlab.uploadEnabled
|
|
104
|
+
br init GITLAB_TOKEN
|
|
102
105
|
|
|
103
106
|
# 查看内置资产和执行器
|
|
104
107
|
best-review agents
|
|
@@ -159,6 +162,10 @@ POST <llm.baseUrl>/chat/completions
|
|
|
159
162
|
"apiKey": "<your-api-key>",
|
|
160
163
|
"model": "deepseek-v4-flash"
|
|
161
164
|
},
|
|
165
|
+
"gitlab": {
|
|
166
|
+
"token": "<your-gitlab-token>",
|
|
167
|
+
"uploadEnabled": false
|
|
168
|
+
},
|
|
162
169
|
"executors": {
|
|
163
170
|
"openai-compatible-api": {
|
|
164
171
|
"review": { "concurrency": 2 },
|
|
@@ -192,6 +199,10 @@ POST <llm.baseUrl>/chat/completions
|
|
|
192
199
|
"apiKey": "<your-api-key>",
|
|
193
200
|
"model": "deepseek-v4-flash"
|
|
194
201
|
},
|
|
202
|
+
"gitlab": {
|
|
203
|
+
"token": "<your-gitlab-token>",
|
|
204
|
+
"uploadEnabled": false
|
|
205
|
+
},
|
|
195
206
|
"executors": {
|
|
196
207
|
"deepseek-api": {
|
|
197
208
|
"review": { "concurrency": 2 },
|
|
@@ -258,12 +269,13 @@ POST <llm.baseUrl>/chat/completions
|
|
|
258
269
|
```bash
|
|
259
270
|
best-review config
|
|
260
271
|
best-review init
|
|
272
|
+
br init GITLAB_TOKEN
|
|
261
273
|
best-review config show
|
|
262
274
|
best-review config edit
|
|
263
275
|
best-review doctor
|
|
264
276
|
```
|
|
265
277
|
|
|
266
|
-
`best-review init` 用来初始化或更新 `~/.best-review/config.json`;`best-review config` 会用当前用户级配置做一次简化诊断;`best-review doctor` 输出同一套诊断结果,适合在本地或 CI 中确认当前机器是否可以直接执行 review。
|
|
278
|
+
`best-review init` 用来初始化或更新 `~/.best-review/config.json`;`br init GITLAB_TOKEN` 只配置用户级 `gitlab.token`,不会要求重新填写模型服务。`best-review config` 会用当前用户级配置做一次简化诊断;`best-review doctor` 输出同一套诊断结果,适合在本地或 CI 中确认当前机器是否可以直接执行 review。
|
|
267
279
|
|
|
268
280
|
## 审查流程
|
|
269
281
|
|
|
@@ -359,23 +371,40 @@ best-review extends remove https://github.com/org/best-review-rules.git
|
|
|
359
371
|
|
|
360
372
|
## GitLab Merge Request
|
|
361
373
|
|
|
362
|
-
`review-mr` 会直接读取 GitLab MR diff 和远程文件内容,运行同一套 pipeline
|
|
374
|
+
`review-mr` 会直接读取 GitLab MR diff 和远程文件内容,运行同一套 pipeline。GitLab discussion 回评属于写操作,默认关闭,需要显式开启。
|
|
363
375
|
|
|
364
376
|
```bash
|
|
365
|
-
export GITLAB_TOKEN=<token>
|
|
366
|
-
|
|
367
377
|
best-review review-mr https://gitlab.example.com/group/project/-/merge_requests/123
|
|
368
378
|
best-review review-mr <mr-url> --agent security-scan --log-steps
|
|
369
379
|
best-review review-mr <mr-url> --executor deepseek-api --model deepseek-v4-flash
|
|
380
|
+
|
|
381
|
+
# 如需回评 MR discussion,再初始化发布 token
|
|
382
|
+
br init GITLAB_TOKEN
|
|
370
383
|
```
|
|
371
384
|
|
|
385
|
+
如需把审查结果回评到 MR,先在用户级配置打开上传开关,并提供发布 discussion 的 `GITLAB_TOKEN`:
|
|
386
|
+
|
|
387
|
+
```json
|
|
388
|
+
{
|
|
389
|
+
"gitlab": {
|
|
390
|
+
"uploadEnabled": true,
|
|
391
|
+
"token": "<your-gitlab-token>"
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
也可以在 CI 中临时设置 `BEST_REVIEW_GITLAB_ENABLED=true`。只有上传开关开启时,`review-mr` 才会要求 `GITLAB_TOKEN`;否则它只读取 MR 并输出本地结果。
|
|
397
|
+
|
|
398
|
+
`review-mr` 会使用内置的 `BEST_REVIEW_HISTORY_USER_TOKEN` 读取 MR。`BEST_REVIEW_HISTORY_REMOTE`、`BEST_REVIEW_HISTORY_BRANCH`、`GITLAB_HOST` 已内置默认值,无需再写入项目 `.env`。
|
|
399
|
+
|
|
372
400
|
可选变量:
|
|
373
401
|
|
|
374
402
|
| 变量 | 说明 |
|
|
375
403
|
| --- | --- |
|
|
376
|
-
| `
|
|
377
|
-
| `
|
|
378
|
-
| `
|
|
404
|
+
| `BEST_REVIEW_HISTORY_USER_TOKEN` | 已内置的 review 记录 token;如需临时替换,可通过环境变量覆盖 |
|
|
405
|
+
| `GITLAB_TOKEN` | 发布 MR discussion 的 token;仅在上传开关开启时需要 |
|
|
406
|
+
| `GITLAB_HOST` | GitLab API host 覆盖值;默认 `https://git.bestfulfill.tech`,可传完整 `/api/v4` |
|
|
407
|
+
| `BEST_REVIEW_GITLAB_ENABLED` | GitLab discussion 上传开关;设置为 `true`/`false` 可覆盖 `gitlab.uploadEnabled` |
|
|
379
408
|
| `GITLAB_PROJECT_ID` / `CI_PROJECT_ID` | 非 `review-mr` 模式下用于定位项目 |
|
|
380
409
|
| `GITLAB_MR_IID` / `CI_MERGE_REQUEST_IID` | 非 `review-mr` 模式下用于定位 MR |
|
|
381
410
|
|
|
@@ -472,14 +501,21 @@ best-review review --base origin/main --json
|
|
|
472
501
|
|
|
473
502
|
报告包含仓库信息、模型、风险结论、质量评分、最终问题和 diff 摘要。默认不保存完整 diff。
|
|
474
503
|
|
|
475
|
-
|
|
504
|
+
默认只保留本地报告,不再因为配置了历史仓库地址而自动上传远端。如果确需把本地 review 结果归档到 Git 仓库,需要显式开启:
|
|
476
505
|
|
|
477
506
|
```bash
|
|
478
507
|
BEST_REVIEW_HISTORY=true
|
|
479
|
-
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
历史归档默认使用源码内置地址和分支:
|
|
511
|
+
|
|
512
|
+
```text
|
|
513
|
+
BEST_REVIEW_HISTORY_REMOTE=https://git.bestfulfill.tech/jericho/review-history.git
|
|
480
514
|
BEST_REVIEW_HISTORY_BRANCH=review-log
|
|
481
515
|
```
|
|
482
516
|
|
|
517
|
+
也可以通过环境变量覆盖为自己的仓库地址和分支。
|
|
518
|
+
|
|
483
519
|
上传后的文件会按项目和 GitLab 用户分组:
|
|
484
520
|
|
|
485
521
|
```text
|
|
@@ -502,6 +538,8 @@ projects/<group>/<project>/<gitlab-user>/<timestamp>-<run-id>.json
|
|
|
502
538
|
}
|
|
503
539
|
```
|
|
504
540
|
|
|
541
|
+
`historyEnabled` 需要显式设置为 `true` 才会开启历史归档;仅配置 `historyRemote` 不会自动上传。
|
|
542
|
+
|
|
505
543
|
如果还需要把报告 POST 到内部效能系统,再配置 Reporting URL:
|
|
506
544
|
|
|
507
545
|
```bash
|