best-review 0.5.8 → 0.5.9

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
@@ -10,7 +10,7 @@
10
10
  - 支持用户级规则、共享 `extends` 规则包和项目级 `skills/` 审查增强。
11
11
  - 默认执行置信度过滤、去重、validation 复核,减少泛泛建议和误报。
12
12
  - 支持显式自动修复严重风险,先生成 unified diff,并通过 `git apply --check` 后才写入。
13
- - 生成本地 JSON 报告;本地 `review` 可显式开启历史归档,`review-mr` 只回评 MR。
13
+ - 生成本地 JSON 报告;本地 `review` 配置历史仓库后会自动归档,`review-mr` 只回评 MR。
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`。`.best-review.json` 已弃用,CLI 不再生成或默认读取它。
44
+ `best-review init` 会以选项式流程写入用户级 `~/.best-review/config.json`,并提示是否把 `GITLAB_TOKEN` 写入同一个用户级配置文件;直接回车可跳过。
45
45
 
46
46
  ## 常用命令
47
47
 
@@ -98,7 +98,8 @@ 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
100
  # GitLab MR 远程审查
101
- GITLAB_TOKEN=<token> best-review review-mr https://gitlab.example.com/group/project/-/merge_requests/123
101
+ br init GITLAB_TOKEN
102
+ best-review review-mr https://gitlab.example.com/group/project/-/merge_requests/123
102
103
 
103
104
  # 查看内置资产和执行器
104
105
  best-review agents
@@ -159,6 +160,9 @@ POST <llm.baseUrl>/chat/completions
159
160
  "apiKey": "<your-api-key>",
160
161
  "model": "deepseek-v4-flash"
161
162
  },
163
+ "gitlab": {
164
+ "token": "<your-gitlab-token>"
165
+ },
162
166
  "executors": {
163
167
  "openai-compatible-api": {
164
168
  "review": { "concurrency": 2 },
@@ -192,6 +196,9 @@ POST <llm.baseUrl>/chat/completions
192
196
  "apiKey": "<your-api-key>",
193
197
  "model": "deepseek-v4-flash"
194
198
  },
199
+ "gitlab": {
200
+ "token": "<your-gitlab-token>"
201
+ },
195
202
  "executors": {
196
203
  "deepseek-api": {
197
204
  "review": { "concurrency": 2 },
@@ -258,12 +265,13 @@ POST <llm.baseUrl>/chat/completions
258
265
  ```bash
259
266
  best-review config
260
267
  best-review init
268
+ br init GITLAB_TOKEN
261
269
  best-review config show
262
270
  best-review config edit
263
271
  best-review doctor
264
272
  ```
265
273
 
266
- `best-review init` 用来初始化或更新 `~/.best-review/config.json`;`best-review config` 会用当前用户级配置做一次简化诊断;`best-review doctor` 输出同一套诊断结果,适合在本地或 CI 中确认当前机器是否可以直接执行 review。
274
+ `best-review init` 用来初始化或更新 `~/.best-review/config.json`;`br init GITLAB_TOKEN` 只配置用户级 `gitlab.token`,不会要求重新填写模型服务。`best-review config` 会用当前用户级配置做一次简化诊断;`best-review doctor` 输出同一套诊断结果,适合在本地或 CI 中确认当前机器是否可以直接执行 review。
267
275
 
268
276
  ## 审查流程
269
277
 
@@ -362,18 +370,23 @@ best-review extends remove https://github.com/org/best-review-rules.git
362
370
  `review-mr` 会直接读取 GitLab MR diff 和远程文件内容,运行同一套 pipeline,并默认启用 GitLab Reporting。
363
371
 
364
372
  ```bash
365
- export GITLAB_TOKEN=<token>
373
+ br init GITLAB_TOKEN
366
374
 
367
375
  best-review review-mr https://gitlab.example.com/group/project/-/merge_requests/123
368
376
  best-review review-mr <mr-url> --agent security-scan --log-steps
369
377
  best-review review-mr <mr-url> --executor deepseek-api --model deepseek-v4-flash
370
378
  ```
371
379
 
380
+ 如果运行 `review-mr` 时当前环境和用户级配置都没有 `GITLAB_TOKEN`,CLI 会在交互式终端中提示填写并写入 `~/.best-review/config.json`;直接回车会取消本次 MR 审查。CI 中仍可通过 `export GITLAB_TOKEN=<token>` 或平台变量注入。
381
+
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。
383
+
372
384
  可选变量:
373
385
 
374
386
  | 变量 | 说明 |
375
387
  | --- | --- |
376
- | `GITLAB_TOKEN` | 读取 MR 和发布 discussion token |
388
+ | `BEST_REVIEW_HISTORY_USER_TOKEN` | 读取 MR 和解析 GitLab 用户的内置 token |
389
+ | `GITLAB_TOKEN` | 发布 MR discussion 的 token,需要用户自行配置 |
377
390
  | `GITLAB_HOST` | GitLab API host 覆盖值;可传 `https://gitlab.example.com` 或完整 `/api/v4` |
378
391
  | `BEST_REVIEW_GITLAB_ENABLED` | 本地 `review` 模式下设置为 `true` 时启用 GitLab Reporting |
379
392
  | `GITLAB_PROJECT_ID` / `CI_PROJECT_ID` | 非 `review-mr` 模式下用于定位项目 |
@@ -472,14 +485,19 @@ best-review review --base origin/main --json
472
485
 
473
486
  报告包含仓库信息、模型、风险结论、质量评分、最终问题和 diff 摘要。默认不保存完整 diff。
474
487
 
475
- 如果想把本地 review 结果归档到 Git 仓库,开启历史归档并配置自己的仓库地址:
488
+ 如果想把本地 review 结果归档到 Git 仓库,配置自己的仓库地址即可启用历史归档:
476
489
 
477
490
  ```bash
478
- BEST_REVIEW_HISTORY=true
479
491
  BEST_REVIEW_HISTORY_REMOTE=git@git.example.com:team/review-history.git
480
492
  BEST_REVIEW_HISTORY_BRANCH=review-log
481
493
  ```
482
494
 
495
+ 如需临时关闭历史归档,可以设置:
496
+
497
+ ```bash
498
+ BEST_REVIEW_HISTORY=false
499
+ ```
500
+
483
501
  上传后的文件会按项目和 GitLab 用户分组:
484
502
 
485
503
  ```text
@@ -495,13 +513,14 @@ projects/<group>/<project>/<gitlab-user>/<timestamp>-<run-id>.json
495
513
  ```json
496
514
  {
497
515
  "reporting": {
498
- "historyEnabled": true,
499
516
  "historyRemote": "git@git.example.com:team/review-history.git",
500
517
  "historyBranch": "review-log"
501
518
  }
502
519
  }
503
520
  ```
504
521
 
522
+ `historyEnabled` 仍可显式设置为 `true`;配置了 `historyRemote` 时不再需要额外开启。
523
+
505
524
  如果还需要把报告 POST 到内部效能系统,再配置 Reporting URL:
506
525
 
507
526
  ```bash