best-review 0.5.9 → 0.5.13

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 CHANGED
@@ -5,12 +5,12 @@
5
5
  这个项目的重点不是替代人工 Review,而是把可重复的风险检查前置到本地、CI 和 GitLab Merge Request 流程里:
6
6
 
7
7
  - 本地审查未提交变更、提交范围、指定文件或完整文件内容。
8
- - GitLab MR 远程审查,并把问题回评到 MR 行内 discussion。
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 报告;本地 `review` 配置历史仓库后会自动归档,`review-mr` 只回评 MR。
13
+ - 生成本地 JSON 报告;GitLab 写操作默认关闭,需要通过配置开关显式开启。
14
14
 
15
15
  ## 快速开始
16
16
 
@@ -97,10 +97,12 @@ 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
- br init GITLAB_TOKEN
100
+ # GitLab MR 远程审查(默认只读)
102
101
  best-review review-mr https://gitlab.example.com/group/project/-/merge_requests/123
103
102
 
103
+ # 如需回评 MR discussion,先配置发布 token 并打开 gitlab.uploadEnabled
104
+ br init GITLAB_TOKEN
105
+
104
106
  # 查看内置资产和执行器
105
107
  best-review agents
106
108
  best-review rules
@@ -161,7 +163,8 @@ POST <llm.baseUrl>/chat/completions
161
163
  "model": "deepseek-v4-flash"
162
164
  },
163
165
  "gitlab": {
164
- "token": "<your-gitlab-token>"
166
+ "token": "<your-gitlab-token>",
167
+ "uploadEnabled": false
165
168
  },
166
169
  "executors": {
167
170
  "openai-compatible-api": {
@@ -197,7 +200,8 @@ POST <llm.baseUrl>/chat/completions
197
200
  "model": "deepseek-v4-flash"
198
201
  },
199
202
  "gitlab": {
200
- "token": "<your-gitlab-token>"
203
+ "token": "<your-gitlab-token>",
204
+ "uploadEnabled": true
201
205
  },
202
206
  "executors": {
203
207
  "deepseek-api": {
@@ -367,28 +371,40 @@ best-review extends remove https://github.com/org/best-review-rules.git
367
371
 
368
372
  ## GitLab Merge Request
369
373
 
370
- `review-mr` 会直接读取 GitLab MR diff 和远程文件内容,运行同一套 pipeline,并默认启用 GitLab Reporting。
374
+ `review-mr` 会直接读取 GitLab MR diff 和远程文件内容,运行同一套 pipelineGitLab discussion 回评属于写操作,默认关闭,需要显式开启。
371
375
 
372
376
  ```bash
373
- br init GITLAB_TOKEN
374
-
375
377
  best-review review-mr https://gitlab.example.com/group/project/-/merge_requests/123
376
378
  best-review review-mr <mr-url> --agent security-scan --log-steps
377
379
  best-review review-mr <mr-url> --executor deepseek-api --model deepseek-v4-flash
380
+
381
+ # 如需回评 MR discussion,再初始化发布 token
382
+ br init GITLAB_TOKEN
378
383
  ```
379
384
 
380
- 如果运行 `review-mr` 时当前环境和用户级配置都没有 `GITLAB_TOKEN`,CLI 会在交互式终端中提示填写并写入 `~/.best-review/config.json`;直接回车会取消本次 MR 审查。CI 中仍可通过 `export GITLAB_TOKEN=<token>` 或平台变量注入。
385
+ 如需把审查结果回评到 MR,先在用户级配置打开上传开关,并提供发布 discussion `GITLAB_TOKEN`:
381
386
 
382
- `review-mr` 启动前会先校验内置 GitLab 配置是否存在:`BEST_REVIEW_HISTORY_REMOTE`、`BEST_REVIEW_HISTORY_BRANCH`、`GITLAB_HOST`、`BEST_REVIEW_HISTORY_USER_TOKEN`。其中 `BEST_REVIEW_HISTORY_USER_TOKEN` 只用于读取 MR 和解析 GitLab 用户;`GITLAB_TOKEN` 只用于向 MR 发布 discussion。
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`。
383
399
 
384
400
  可选变量:
385
401
 
386
402
  | 变量 | 说明 |
387
403
  | --- | --- |
388
- | `BEST_REVIEW_HISTORY_USER_TOKEN` | 读取 MR 和解析 GitLab 用户的内置 token |
389
- | `GITLAB_TOKEN` | 发布 MR discussion 的 token,需要用户自行配置 |
390
- | `GITLAB_HOST` | GitLab API host 覆盖值;可传 `https://gitlab.example.com` 或完整 `/api/v4` |
391
- | `BEST_REVIEW_GITLAB_ENABLED` | 本地 `review` 模式下设置为 `true` 时启用 GitLab Reporting |
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` |
392
408
  | `GITLAB_PROJECT_ID` / `CI_PROJECT_ID` | 非 `review-mr` 模式下用于定位项目 |
393
409
  | `GITLAB_MR_IID` / `CI_MERGE_REQUEST_IID` | 非 `review-mr` 模式下用于定位 MR |
394
410
 
@@ -485,19 +501,21 @@ best-review review --base origin/main --json
485
501
 
486
502
  报告包含仓库信息、模型、风险结论、质量评分、最终问题和 diff 摘要。默认不保存完整 diff。
487
503
 
488
- 如果想把本地 review 结果归档到 Git 仓库,配置自己的仓库地址即可启用历史归档:
504
+ 默认只保留本地报告,不再因为配置了历史仓库地址而自动上传远端。如果确需把本地 review 结果归档到 Git 仓库,需要显式开启:
489
505
 
490
506
  ```bash
491
- BEST_REVIEW_HISTORY_REMOTE=git@git.example.com:team/review-history.git
492
- BEST_REVIEW_HISTORY_BRANCH=review-log
507
+ BEST_REVIEW_HISTORY=true
493
508
  ```
494
509
 
495
- 如需临时关闭历史归档,可以设置:
510
+ 历史归档默认使用源码内置地址和分支:
496
511
 
497
- ```bash
498
- BEST_REVIEW_HISTORY=false
512
+ ```text
513
+ BEST_REVIEW_HISTORY_REMOTE=https://git.bestfulfill.tech/jericho/review-history.git
514
+ BEST_REVIEW_HISTORY_BRANCH=review-log
499
515
  ```
500
516
 
517
+ 也可以通过环境变量覆盖为自己的仓库地址和分支。
518
+
501
519
  上传后的文件会按项目和 GitLab 用户分组:
502
520
 
503
521
  ```text
@@ -513,13 +531,14 @@ projects/<group>/<project>/<gitlab-user>/<timestamp>-<run-id>.json
513
531
  ```json
514
532
  {
515
533
  "reporting": {
534
+ "historyEnabled": true,
516
535
  "historyRemote": "git@git.example.com:team/review-history.git",
517
536
  "historyBranch": "review-log"
518
537
  }
519
538
  }
520
539
  ```
521
540
 
522
- `historyEnabled` 仍可显式设置为 `true`;配置了 `historyRemote` 时不再需要额外开启。
541
+ `historyEnabled` 需要显式设置为 `true` 才会开启历史归档;仅配置 `historyRemote` 不会自动上传。
523
542
 
524
543
  如果还需要把报告 POST 到内部效能系统,再配置 Reporting URL:
525
544