best-review 0.5.6 → 0.5.8

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
@@ -7,10 +7,10 @@
7
7
  - 本地审查未提交变更、提交范围、指定文件或完整文件内容。
8
8
  - GitLab MR 远程审查,并把问题回评到 MR 行内 discussion。
9
9
  - 内置 `general`、`bug-hunter`、`security-scan`、`performance-check`、`consistency-check`、`validation` Agent。
10
- - 支持项目规则、全局规则、共享 `extends` 规则包和项目级 `skills/` 审查增强。
10
+ - 支持用户级规则、共享 `extends` 规则包和项目级 `skills/` 审查增强。
11
11
  - 默认执行置信度过滤、去重、validation 复核,减少泛泛建议和误报。
12
12
  - 支持显式自动修复严重风险,先生成 unified diff,并通过 `git apply --check` 后才写入。
13
- - 生成本地 JSON 报告,可选上报到内部效能统计系统。
13
+ - 生成本地 JSON 报告;本地 `review` 可显式开启历史归档,`review-mr` 只回评 MR。
14
14
 
15
15
  ## 快速开始
16
16
 
@@ -56,6 +56,11 @@ best-review review --base main
56
56
  best-review review --branch .
57
57
  best-review review --branch feature/login --base main
58
58
 
59
+ # 审查单个 commit 或连续多个 commit
60
+ best-review review --commit HEAD
61
+ best-review review --commit abc1234
62
+ best-review review --commit-range HEAD~3..HEAD
63
+
59
64
  # 只审查指定文件的 Git 变更
60
65
  best-review review --files src/auth.ts
61
66
  best-review review --files src/auth.ts,src/user.ts --base main
@@ -90,7 +95,7 @@ best-review review --log-steps
90
95
  # 显式自动修复严重风险
91
96
  best-review review --fix-critical
92
97
  best-review review --fix-severity critical,high --fix-dry-run
93
- best-review review --fix-critical --fix-max-issues 3 --fix-patch-file .best-review/fix.patch
98
+ best-review review --fix-critical --fix-max-issues 3 --fix-patch-file ~/.best-review/fix.patch
94
99
 
95
100
  # GitLab MR 远程审查
96
101
  GITLAB_TOKEN=<token> best-review review-mr https://gitlab.example.com/group/project/-/merge_requests/123
@@ -207,7 +212,6 @@ POST <llm.baseUrl>/chat/completions
207
212
  "domain-review": { "enabled": true }
208
213
  },
209
214
  "reporting": {
210
- "localDir": ".best-review/reports",
211
215
  "enabled": false,
212
216
  "includeDiffs": false,
213
217
  "failOnError": false
@@ -283,6 +287,8 @@ flowchart LR
283
287
  关键行为:
284
288
 
285
289
  - `filterReviewableDiffs()` 默认跳过二进制、生成物、文档和命中排除规则的文件。
290
+ - 本地 review 支持未提交变更、`--base/--head`、`--branch`、`--commit`、`--commit-range`、`--files` 和 `--full`;互斥或不完整的参数组合会在进入 pipeline 前直接拒绝。
291
+ - `--commit <ref>` 等价于比较 `<ref>^` 和 `<ref>`;`--commit-range <oldest>..<newest>` 会包含两端 commit,要求 `<oldest>` 是 `<newest>` 的祖先。
286
292
  - 本地 review 会补充变更文件全文和一层相对依赖上下文,避免模型只看 diff。
287
293
  - diff 输入默认压缩,只保留 hunk 行号、变更行和少量上下文。
288
294
  - 默认是多 Agent 独立审查;设置 `BEST_REVIEW_MULTI_AGENT=false` 可把多个专业 Agent 合并成一次快速审查。
@@ -309,7 +315,6 @@ flowchart LR
309
315
  自定义规则可以放在:
310
316
 
311
317
  ```text
312
- .best-review/rules/*.md
313
318
  ~/.best-review/rules/*.md
314
319
  ```
315
320
 
@@ -332,14 +337,13 @@ agent: security-scan
332
337
  自定义 Agent 可以放在:
333
338
 
334
339
  ```text
335
- .best-review/agents/*.md
336
340
  ~/.best-review/agents/*.md
337
341
  ```
338
342
 
339
343
  规则和 Agent 加载优先级:
340
344
 
341
345
  ```text
342
- defaults < extends < user < project
346
+ defaults < extends < user
343
347
  ```
344
348
 
345
349
  共享规则包:
@@ -389,7 +393,7 @@ best-review review --fix-critical
389
393
  best-review review --fix-severity critical,high --fix-dry-run
390
394
 
391
395
  # 限制修复数量,并保存补丁
392
- best-review review --fix-critical --fix-max-issues 3 --fix-patch-file .best-review/fix.patch
396
+ best-review review --fix-critical --fix-max-issues 3 --fix-patch-file ~/.best-review/fix.patch
393
397
  ```
394
398
 
395
399
  安全约束:
@@ -460,40 +464,52 @@ best-review review --base origin/main --json
460
464
 
461
465
  ## Reporting
462
466
 
463
- 每次 review 都会尽量生成本地报告,默认目录:
467
+ 每次 `best-review review` 都会保存一份本地 JSON 报告,默认目录:
464
468
 
465
469
  ```text
466
- .best-review/reports/
470
+ ~/.best-review/reports/
467
471
  ```
468
472
 
469
- 报告包含仓库信息、base/head、模型、Agent 结果、阶段结果、风险结论、质量评分、issue audit trail、最终问题和 diff 摘要。默认不保存完整 diff。
473
+ 报告包含仓库信息、模型、风险结论、质量评分、最终问题和 diff 摘要。默认不保存完整 diff。
474
+
475
+ 如果想把本地 review 结果归档到 Git 仓库,开启历史归档并配置自己的仓库地址:
470
476
 
471
- 配置上报:
477
+ ```bash
478
+ BEST_REVIEW_HISTORY=true
479
+ BEST_REVIEW_HISTORY_REMOTE=git@git.example.com:team/review-history.git
480
+ BEST_REVIEW_HISTORY_BRANCH=review-log
481
+ ```
482
+
483
+ 上传后的文件会按项目和 GitLab 用户分组:
484
+
485
+ ```text
486
+ projects/<group>/<project>/<gitlab-user>/<timestamp>-<run-id>.json
487
+ ```
488
+
489
+ 历史归档只上传 `best-review review` 的本地结果;`best-review review-mr` 不会上传到历史仓库。
490
+
491
+ 上传成功后,本地 JSON 会被删除,避免长期占用磁盘;上传失败时会保留本地文件,方便排查。
492
+
493
+ 也可以通过用户级 `~/.best-review/config.json` 配置:
472
494
 
473
495
  ```json
474
496
  {
475
497
  "reporting": {
476
- "localDir": ".best-review/reports",
477
- "enabled": true,
478
- "url": "https://efficiency.example.com/api/ai-review/usages",
479
- "token": "replace-with-token",
480
- "includeDiffs": false,
481
- "failOnError": false
498
+ "historyEnabled": true,
499
+ "historyRemote": "git@git.example.com:team/review-history.git",
500
+ "historyBranch": "review-log"
482
501
  }
483
502
  }
484
503
  ```
485
504
 
486
- 环境变量覆盖:
505
+ 如果还需要把报告 POST 到内部效能系统,再配置 Reporting URL:
487
506
 
488
507
  ```bash
489
- BEST_REVIEW_REPORT_DIR=.best-review/reports
490
508
  BEST_REVIEW_REPORT_URL=https://efficiency.example.com/api/ai-review/usages
491
509
  BEST_REVIEW_REPORT_TOKEN=replace-with-token
492
- BEST_REVIEW_REPORT_INCLUDE_DIFFS=false
493
- BEST_REVIEW_REPORT_FAIL_ON_ERROR=false
494
510
  ```
495
511
 
496
- 上报失败默认不阻断 review;如果 CI 要求上报失败即失败,设置 `failOnError: true` 或 `BEST_REVIEW_REPORT_FAIL_ON_ERROR=true`。
512
+ 默认上报失败不会阻断 reviewCI 里想让上报失败直接失败,可以设置 `BEST_REVIEW_REPORT_FAIL_ON_ERROR=true`。
497
513
 
498
514
  ## 审查质量评测
499
515
 
@@ -556,8 +572,8 @@ BEST_REVIEW_DISABLE_SMART_ROUTING=true best-review review
556
572
  默认缓存目录:
557
573
 
558
574
  ```text
559
- .best-review/cache/review
560
- .best-review/cache/validation
575
+ ~/.best-review/cache/review
576
+ ~/.best-review/cache/validation
561
577
  ```
562
578
 
563
579
  缓存 key 包含模型、base URL、temperature、prompt、规则和 diff 输入。相同输入会复用成功结果,并在终端/JSON 中统计缓存命中和节省 token。