Files
gatekeep/README.zh-CN.md
layue13 c6c2d071fb
Gatekeep evals / eval-floor (push) Successful in 3s
Gatekeep evals / eval-floor (pull_request) Successful in 15s
Gatekeep / gatekeep (pull_request) Failing after 1m46s
fix: harden partial 429 success, fallbacks, zh errors
Retry HTTP 429 with backoff; keep models beyond first 3 as
fallbacks; degrade agreement when some models fail; force-high
risk only if zero usable responses. Clearer zh-CN errors/docs for
dogfood uses: ./ rebase + workflow_dispatch re-run.
2026-10-27 08:35:52 +00:00

101 lines
4.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Gatekeep
AI 辅助的 PR 审查 Action:多模型并行投票、按严重级别输出可扫读的结论,适合自己的仓库。
## 它做什么
- 对每个 PR 并行调用 **2–3 个模型**(**可来自不同供应商**),**仅当多个模型达成一致**时发 inline 评论。
- 每条结论明确写出:**严重级别**、**代码位置**、**为什么重要**。
- 汇总评论给出 PR **风险档**(low / medium / high);安全相关可阻断合并。
- 不提供 CodeRabbit 式聊天 / `@命令`。
## 远程引用(推荐)
工作流文件必须放在 **`.github/workflows/`**(Gitea / GitHub 都认这个路径)。
```yaml
- uses: actions/checkout@v4
- uses: https://git.potatolab.uk/layue13/gatekeep@main
# 占位:uses: https://git.example.com/OWNER/gatekeep@v1
env:
# 必须与 providers.yaml 里的 key 同名(自由命名,无强制 gatekeep_ 前缀)
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
```
### 自审(本仓库 dogfood)
`layue13/gatekeep` 用 [`.github/workflows/gatekeep-pr.yml`](.github/workflows/gatekeep-pr.yml) 对本仓库 PR 跑 Gatekeep:`uses: ./` + `secrets.OPENROUTER_API_KEY`。向 `main` 开 PR 即可触发(需有可用的 Gitea Actions runner)。
**注意:** `uses: ./` 用的是 **PR 分支上的 Action**。main 上的修复要进 PR,需要 rebase/merge main,否则看起来像“修了还挂”。重跑:再推一次提交,或 Actions → Gatekeep → **Run workflow**。免费模型 429 会退避重试;`models` 列表第 4 个及以后作备用;**只有全部模型失败**才强制抬高风险档为 high。
github.com runner 若不允许非 github.com Action 源,见 `docs/remote-uses.md`。
## 多供应商(providers.yaml)
```yaml
language: zh-CN # 报告语言:zh-CN | en | …(提示词 + 汇总/inline 评论)
providers:
openrouter:
key: OPENROUTER_API_KEY # 自由命名 — 任意 secret/环境变量名
protocol: openai # openai | openai-completions | openai-responses | anthropic
models:
- cohere/north-mini-code:free
- nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free
- google/gemma-4-31b-it:free
```
- **`language`:报告语言**(本仓库默认 `zh-CN`)。也可用 Action 输入 `language:` 覆盖。别名 `report_language`。
- **`key`:自由命名**,**不要**要求必须 `gatekeep_` 前缀(你也可以叫 `gatekeep_openrouter`,只是举例)。
- 每个供应商只需:`key` + `protocol`(`base_url` / `models` 按需;已知 id 有默认 base_url)。
- **不内置死模型清单**;启动时拉取供应商模型列表并校验名字。
- 可混用多个供应商;只写你真正配置了的条目。
### 如何设置语言
| 方式 | 示例 |
| --- | --- |
| `providers.yaml` | `language: zh-CN` 或 `language: en` |
| Action 输入(优先) | `with: { language: en }` |
| 缺省 | 无 YAML / 无输入时回落 `en`;本仓库 defaults 已写 `zh-CN` |
JSON 键名与枚举值(如 `Critical`)保持英文;摘要、结论正文、inline 评论跟人读的文案跟 `language`。
## 输入面
| 项 | 含义 |
| --- | --- |
| `language` | 报告语言(`zh-CN` / `en` …);覆盖 YAML |
| `key` | Secret / 环境变量名(自由) |
| `protocol` | `openai` / `openai-completions` / `openai-responses` / `anthropic` |
| `models` | 参与并行审查的模型名 |
| step `env` | 把 `key` 同名的 secret 注入环境 |
| `github-token` | 发评论 / checks |
## 混用示例
```yaml
- uses: https://git.potatolab.uk/layue13/gatekeep@main
env:
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config-dir: .github/gatekeep # 内含 providers.yaml,见 config/providers.yaml
```
## 风险档
| 档 | 人工 |
| --- | --- |
| low | 0(审查与安全绿后;kill switch 可自动合并) |
| medium | 1 人(Bot 不能顶替) |
| high | 2 人 |
## 更多
- 英文:`README.md`
- 远程限制:`docs/remote-uses.md`