coderev-cli 1.0.26 → 1.3.0
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 +776 -0
- package/package.json +1 -1
- package/src/cli.js +162 -1
- package/src/issue-validator.js +499 -0
- package/src/issue-validator.test.js +404 -0
- package/src/models.js +59 -0
- package/src/models.test.js +139 -2
- package/src/rag-indexer.js +700 -0
- package/src/rag-indexer.test.js +385 -0
- package/src/reviewer.js +36 -6
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
- [快速上手](#快速上手)
|
|
21
21
|
- [命令详解](#命令详解)
|
|
22
22
|
- [coderev review(核心审查)](#coderev-review核心审查)
|
|
23
|
+
- [coderev index(代码库索引)🆕](#coderev-index代码库索引)
|
|
23
24
|
- [coderev fix(自动修复)](#coderev-fix自动修复)
|
|
24
25
|
- [coderev hook(Git Hooks)](#coderev-hookgit-hooks)
|
|
25
26
|
- [coderev stats(统计看板)](#coderev-stats统计看板)
|
|
@@ -32,9 +33,29 @@
|
|
|
32
33
|
- [coderev rules(规则市场)🆕](#coderev-rules规则市场)
|
|
33
34
|
- [coderev doctor(环境诊断)🆕](#coderev-doctor环境诊断)
|
|
34
35
|
- [配置详解](#配置详解)
|
|
36
|
+
- [Token 生成和使用说明](#token-生成和使用说明)
|
|
37
|
+
- [GitHub Personal Access Token](#1-github-personal-access-token)
|
|
38
|
+
- [GitLab Personal Access Token](#2-gitlab-personal-access-token)
|
|
39
|
+
- [Gitee Personal Access Token](#3-gitee-personal-access-token)
|
|
40
|
+
- [GitCode Personal Access Token](#4-gitcode-personal-access-token)
|
|
41
|
+
- [Bitbucket App Password](#5-bitbucket-app-password)
|
|
42
|
+
- [GitHub App JWT Token(coderev serve)](#6-github-app-jwt-tokencoderev-serve)
|
|
43
|
+
- [Token 使用方式总结](#token-使用方式总结)
|
|
35
44
|
- [平台集成](#平台集成)
|
|
36
45
|
- [CI/CD 集成](#cicd-集成)
|
|
37
46
|
- [VS Code 扩展 🆕](#vs-code-扩展)
|
|
47
|
+
- [完整接口使用说明](#完整接口使用说明)
|
|
48
|
+
- [命令一览](#命令一览)
|
|
49
|
+
- [API Key(AI 模型)配置接口](#api-keyai-模型配置接口)
|
|
50
|
+
- [审查相关接口](#审查相关接口)
|
|
51
|
+
- [PR/MR 平台接口](#prmr-平台接口)
|
|
52
|
+
- [修复相关接口](#修复相关接口)
|
|
53
|
+
- [Hook 接口](#hook-接口)
|
|
54
|
+
- [统计与缓存接口](#统计与缓存接口)
|
|
55
|
+
- [配置与诊断接口](#配置与诊断接口)
|
|
56
|
+
- [GitHub App 服务接口](#github-app-服务接口)
|
|
57
|
+
- [规则市场接口](#规则市场接口)
|
|
58
|
+
- [VS Code 扩展接口](#vs-code-扩展接口)
|
|
38
59
|
- [FAQ / 常见问题](#faq--常见问题)
|
|
39
60
|
|
|
40
61
|
---
|
|
@@ -886,6 +907,244 @@ build/
|
|
|
886
907
|
|
|
887
908
|
---
|
|
888
909
|
|
|
910
|
+
## Token 生成和使用说明
|
|
911
|
+
|
|
912
|
+
coderev 在访问各 Git 平台的 PR/MR 时需要 **Personal Access Token** 进行身份认证。以下逐个说明各平台的 Token 生成方法和使用方式。
|
|
913
|
+
|
|
914
|
+
### 1. GitHub Personal Access Token
|
|
915
|
+
|
|
916
|
+
#### 生成步骤
|
|
917
|
+
|
|
918
|
+
1. 登录 GitHub → 右上角头像 → **Settings**
|
|
919
|
+
2. 左侧菜单 → **Developer settings** → **Personal access tokens** → **Tokens (classic)**
|
|
920
|
+
3. 点击 **Generate new token → Generate new token (classic)**
|
|
921
|
+
4. 填写 Note(如 `coderev`),设置过期时间
|
|
922
|
+
5. 勾选以下权限:
|
|
923
|
+
|
|
924
|
+
| Scope | 用途 |
|
|
925
|
+
|-------|------|
|
|
926
|
+
| `repo`(全部) | 读取私有仓库代码、PR diff |
|
|
927
|
+
| `read:org` | 读取组织信息(可选) |
|
|
928
|
+
|
|
929
|
+
6. 点击 **Generate token** → **复制 Token**(只显示一次!)
|
|
930
|
+
|
|
931
|
+
> 💡 也可使用 **Fine-grained token**:选择仓库 → Repository permissions → Pull requests: Read and write
|
|
932
|
+
|
|
933
|
+
#### 使用方式
|
|
934
|
+
|
|
935
|
+
```bash
|
|
936
|
+
# 方式一:命令行参数
|
|
937
|
+
coderev review --pr 42 --github-token ghp_xxxx
|
|
938
|
+
|
|
939
|
+
# 方式二:环境变量(推荐)
|
|
940
|
+
# Windows PowerShell:
|
|
941
|
+
$env:GITHUB_TOKEN="ghp_xxxx"
|
|
942
|
+
# Linux / macOS:
|
|
943
|
+
export GITHUB_TOKEN="ghp_xxxx"
|
|
944
|
+
|
|
945
|
+
# 方式三:写入配置文件
|
|
946
|
+
# .coderevrc.json 中:
|
|
947
|
+
"github": { "token": "ghp_xxxx" }
|
|
948
|
+
```
|
|
949
|
+
|
|
950
|
+
---
|
|
951
|
+
|
|
952
|
+
### 2. GitLab Personal Access Token
|
|
953
|
+
|
|
954
|
+
#### 生成步骤
|
|
955
|
+
|
|
956
|
+
1. 登录 GitLab → 右上角头像 → **Preferences**
|
|
957
|
+
2. 左侧菜单 → **Access Tokens**
|
|
958
|
+
3. 填写 Token name(如 `coderev`),设置过期时间
|
|
959
|
+
4. 勾选以下权限:
|
|
960
|
+
|
|
961
|
+
| Scope | 用途 |
|
|
962
|
+
|-------|------|
|
|
963
|
+
| `read_api` | 读取 MR、diff 信息 |
|
|
964
|
+
| `read_repository` | 读取仓库代码 |
|
|
965
|
+
| `api`(可选) | 发布 MR 评论(需要时选此代替上面两个) |
|
|
966
|
+
|
|
967
|
+
5. 点击 **Create personal access token** → **复制 Token**
|
|
968
|
+
|
|
969
|
+
#### 使用方式
|
|
970
|
+
|
|
971
|
+
```bash
|
|
972
|
+
# 方式一:命令行参数
|
|
973
|
+
coderev review --gl 42 --gitlab-token glpat-xxxx
|
|
974
|
+
|
|
975
|
+
# 方式二:环境变量(推荐)
|
|
976
|
+
export GITLAB_TOKEN="glpat-xxxx"
|
|
977
|
+
|
|
978
|
+
# 方式三:配置文件
|
|
979
|
+
# .coderevrc.json 中:
|
|
980
|
+
"gitlab": { "token": "glpat-xxxx" }
|
|
981
|
+
```
|
|
982
|
+
|
|
983
|
+
> **GitLab MR URL 格式**:`owner/repo!42` → 用 `--gl owner/repo!42`
|
|
984
|
+
|
|
985
|
+
---
|
|
986
|
+
|
|
987
|
+
### 3. Gitee Personal Access Token
|
|
988
|
+
|
|
989
|
+
#### 生成步骤
|
|
990
|
+
|
|
991
|
+
1. 登录 Gitee → 右上角头像 → **设置**
|
|
992
|
+
2. 左侧菜单 → **私人令牌**
|
|
993
|
+
3. 点击 **生成新令牌**
|
|
994
|
+
4. 填写描述,勾选权限:
|
|
995
|
+
|
|
996
|
+
| 权限 | 用途 |
|
|
997
|
+
|------|------|
|
|
998
|
+
| `pull_requests` | 读取 PR 信息 |
|
|
999
|
+
| `projects` | 读取仓库信息 |
|
|
1000
|
+
|
|
1001
|
+
5. 点击 **提交** → **复制 Token**
|
|
1002
|
+
|
|
1003
|
+
#### 使用方式
|
|
1004
|
+
|
|
1005
|
+
```bash
|
|
1006
|
+
# 方式一:命令行参数
|
|
1007
|
+
coderev review --gee owner/repo!42 --gee-token gitee_xxxx
|
|
1008
|
+
|
|
1009
|
+
# 方式二:环境变量(推荐)
|
|
1010
|
+
export GITEE_TOKEN="gitee_xxxx"
|
|
1011
|
+
|
|
1012
|
+
# 方式三:配置文件
|
|
1013
|
+
"gitee": { "token": "gitee_xxxx" }
|
|
1014
|
+
```
|
|
1015
|
+
|
|
1016
|
+
> **注意**:Gitee 不支持行内评论,PR 审查仅支持摘要评论模式。
|
|
1017
|
+
|
|
1018
|
+
---
|
|
1019
|
+
|
|
1020
|
+
### 4. GitCode Personal Access Token
|
|
1021
|
+
|
|
1022
|
+
#### 生成步骤
|
|
1023
|
+
|
|
1024
|
+
1. 登录 GitCode → 右上角头像 → **设置**
|
|
1025
|
+
2. 左侧菜单 → **访问令牌**
|
|
1026
|
+
3. 点击 **创建访问令牌**
|
|
1027
|
+
4. 填写名称,勾选权限:
|
|
1028
|
+
|
|
1029
|
+
| 权限 | 用途 |
|
|
1030
|
+
|------|------|
|
|
1031
|
+
| `api` | 读取 MR 和仓库信息 |
|
|
1032
|
+
| `read_repository` | 读取代码 |
|
|
1033
|
+
|
|
1034
|
+
5. 点击 **创建** → **复制 Token**
|
|
1035
|
+
|
|
1036
|
+
#### 使用方式
|
|
1037
|
+
|
|
1038
|
+
```bash
|
|
1039
|
+
# 方式一:命令行参数
|
|
1040
|
+
coderev review --gc owner/repo!42 --gc-token gitcode_xxxx
|
|
1041
|
+
|
|
1042
|
+
# 方式二:环境变量(推荐)
|
|
1043
|
+
export GITCODE_TOKEN="gitcode_xxxx"
|
|
1044
|
+
```
|
|
1045
|
+
|
|
1046
|
+
---
|
|
1047
|
+
|
|
1048
|
+
### 5. Bitbucket App Password
|
|
1049
|
+
|
|
1050
|
+
#### 生成步骤
|
|
1051
|
+
|
|
1052
|
+
1. 登录 Bitbucket → 左下角头像 → **Personal settings**
|
|
1053
|
+
2. 左侧菜单 → **App passwords**
|
|
1054
|
+
3. 点击 **Create app password**
|
|
1055
|
+
4. 填写 Label(如 `coderev`),勾选权限:
|
|
1056
|
+
|
|
1057
|
+
| 权限 | 用途 |
|
|
1058
|
+
|------|------|
|
|
1059
|
+
| `Repositories: Read` | 读取仓库和 PR |
|
|
1060
|
+
| `Pull requests: Read` | 读取 PR diff |
|
|
1061
|
+
| `Pull requests: Write`(可选) | 发布 PR 评论 |
|
|
1062
|
+
|
|
1063
|
+
5. 点击 **Create** → **复制密码**
|
|
1064
|
+
|
|
1065
|
+
> ⚠️ Bitbucket App Password 格式为 `username:password`,**用户名是 Bitbucket 用户名,不是邮箱**。
|
|
1066
|
+
|
|
1067
|
+
#### 使用方式
|
|
1068
|
+
|
|
1069
|
+
```bash
|
|
1070
|
+
# 方式一:命令行参数
|
|
1071
|
+
coderev review --bb owner/repo#42 --bb-token your_username:app_password
|
|
1072
|
+
|
|
1073
|
+
# 方式二:环境变量(推荐)
|
|
1074
|
+
export BITBUCKET_APP_PASSWORD="your_username:app_password"
|
|
1075
|
+
|
|
1076
|
+
# 方式三:配置文件
|
|
1077
|
+
"bitbucket": { "username": "your_username", "appPassword": "xxx" }
|
|
1078
|
+
```
|
|
1079
|
+
|
|
1080
|
+
---
|
|
1081
|
+
|
|
1082
|
+
### 6. GitHub App JWT Token(coderev serve)
|
|
1083
|
+
|
|
1084
|
+
`coderev serve` 使用 GitHub App 身份认证而非 Personal Access Token。
|
|
1085
|
+
|
|
1086
|
+
#### 生成/获取步骤
|
|
1087
|
+
|
|
1088
|
+
1. 创建 GitHub App(详见 [docs/github-app.md](docs/github-app.md))
|
|
1089
|
+
2. 获取以下凭证:
|
|
1090
|
+
|
|
1091
|
+
| 凭证 | 说明 | 获取位置 |
|
|
1092
|
+
|------|------|---------|
|
|
1093
|
+
| **App ID** | GitHub App 的标识数字 | GitHub App 设置页顶部 |
|
|
1094
|
+
| **Private Key (.pem)** | RSA 私钥,用于生成 JWT | App 设置页 → Generate private key |
|
|
1095
|
+
| **Webhook Secret** | 验证 webhook 请求签名 | App 设置页 → Webhook secret |
|
|
1096
|
+
|
|
1097
|
+
#### JWT 生成原理
|
|
1098
|
+
|
|
1099
|
+
coderev 内部自动处理 JWT 生成(无需手动操作),其流程为:
|
|
1100
|
+
|
|
1101
|
+
```
|
|
1102
|
+
App ID + Private Key → 签名 JWT → 交换 Installation Token → 访问仓库
|
|
1103
|
+
```
|
|
1104
|
+
|
|
1105
|
+
- JWT 有效期:10 分钟(GitHub App 最大限制)
|
|
1106
|
+
- Installation Token 有效期:1 小时,由 coderev 自动获取和管理
|
|
1107
|
+
|
|
1108
|
+
#### 使用方式
|
|
1109
|
+
|
|
1110
|
+
```bash
|
|
1111
|
+
# 方式一:命令行参数
|
|
1112
|
+
coderev serve \
|
|
1113
|
+
--app-id 123456 \
|
|
1114
|
+
--private-key "$(cat /path/to/key.pem)" \
|
|
1115
|
+
--webhook-secret "your-secret"
|
|
1116
|
+
|
|
1117
|
+
# 方式二:环境变量(推荐)
|
|
1118
|
+
export GITHUB_APP_ID=123456
|
|
1119
|
+
export GITHUB_APP_PRIVATE_KEY="$(cat /path/to/key.pem)"
|
|
1120
|
+
export GITHUB_APP_WEBHOOK_SECRET="your-secret"
|
|
1121
|
+
coderev serve
|
|
1122
|
+
|
|
1123
|
+
# 方式三:.coderevrc.json 配置
|
|
1124
|
+
"githubApp": {
|
|
1125
|
+
"appId": 123456,
|
|
1126
|
+
"privateKey": "-----BEGIN RSA PRIVATE KEY-----\n...",
|
|
1127
|
+
"webhookSecret": "your-secret"
|
|
1128
|
+
}
|
|
1129
|
+
```
|
|
1130
|
+
|
|
1131
|
+
---
|
|
1132
|
+
|
|
1133
|
+
### Token 使用方式总结
|
|
1134
|
+
|
|
1135
|
+
| 平台 | Token 类型 | CLI 参数 | 环境变量 | 配置文件字段 |
|
|
1136
|
+
|------|-----------|---------|---------|------------|
|
|
1137
|
+
| GitHub | Personal Access Token | `--github-token` | `GITHUB_TOKEN` | `github.token` |
|
|
1138
|
+
| GitLab | Personal Access Token | `--gitlab-token` | `GITLAB_TOKEN` | `gitlab.token` |
|
|
1139
|
+
| Gitee | Private Token | `--gee-token` | `GITEE_TOKEN` | `gitee.token` |
|
|
1140
|
+
| GitCode | Access Token | `--gc-token` | `GITCODE_TOKEN` | `gitcode.token` |
|
|
1141
|
+
| Bitbucket | App Password | `--bb-token` | `BITBUCKET_APP_PASSWORD` | `bitbucket.appPassword` |
|
|
1142
|
+
| GitHub App | JWT + Installation | `--app-id` + `--private-key` | `GITHUB_APP_ID` + `GITHUB_APP_PRIVATE_KEY` | `githubApp.appId` + `githubApp.privateKey` |
|
|
1143
|
+
|
|
1144
|
+
**优先级**(从高到低):命令行参数 > 环境变量 > 配置文件
|
|
1145
|
+
|
|
1146
|
+
---
|
|
1147
|
+
|
|
889
1148
|
## 平台集成
|
|
890
1149
|
|
|
891
1150
|
### 支持的 Git 平台
|
|
@@ -1056,6 +1315,502 @@ cd vscode && npm install && npm run package
|
|
|
1056
1315
|
|
|
1057
1316
|
---
|
|
1058
1317
|
|
|
1318
|
+
## 完整接口使用说明
|
|
1319
|
+
|
|
1320
|
+
> 本章汇总 coderev 所有命令、参数、环境变量和配置项,作为完整 API / 接口参考。
|
|
1321
|
+
|
|
1322
|
+
### 命令一览
|
|
1323
|
+
|
|
1324
|
+
| 命令 | 用途 | 版本 |
|
|
1325
|
+
|------|------|------|
|
|
1326
|
+
| `coderev review` | 审查代码 diff / PR / MR | v0.1.0 |
|
|
1327
|
+
| `coderev fix` | AI 自动修复问题 | v0.1.0 |
|
|
1328
|
+
| `coderev hook` | Git Hook 安装/卸载 | v0.1.0 |
|
|
1329
|
+
| `coderev stats` | 审查统计看板 | v0.2.0 |
|
|
1330
|
+
| `coderev cache` | 缓存管理 | v0.1.0 |
|
|
1331
|
+
| `coderev config` | 配置管理 | v0.1.0 |
|
|
1332
|
+
| `coderev init` | 项目初始化 | v0.1.0 |
|
|
1333
|
+
| `coderev serve` | GitHub App Webhook 服务 | v1.0.18 |
|
|
1334
|
+
| `coderev models` | 模型模板列表 | v1.0.24 |
|
|
1335
|
+
| `coderev setup` | 模型配置 | v1.0.24 |
|
|
1336
|
+
| `coderev rules` | 规则市场 | v1.0.23 |
|
|
1337
|
+
| `coderev doctor` | 环境诊断 | v1.0.26 |
|
|
1338
|
+
|
|
1339
|
+
---
|
|
1340
|
+
|
|
1341
|
+
### API Key(AI 模型)配置接口
|
|
1342
|
+
|
|
1343
|
+
coderev 通过 **OpenAI 兼容 API** 调用各 AI 服务商。配置 AI 接口有三种方式:
|
|
1344
|
+
|
|
1345
|
+
#### 方式一:`coderev setup` 交互式配置
|
|
1346
|
+
|
|
1347
|
+
```bash
|
|
1348
|
+
# 选择模板(最简方式)
|
|
1349
|
+
coderev setup --model deepseek
|
|
1350
|
+
|
|
1351
|
+
# 主模型 + 备用模型
|
|
1352
|
+
coderev setup --model deepseek --fallback qwen
|
|
1353
|
+
|
|
1354
|
+
# 不同 Agent 使用不同模型
|
|
1355
|
+
coderev setup --agent-security deepseek-r1 --agent-quality qwen
|
|
1356
|
+
|
|
1357
|
+
# 查看当前配置
|
|
1358
|
+
coderev setup
|
|
1359
|
+
```
|
|
1360
|
+
|
|
1361
|
+
**支持的 `--model` 模板名**:`deepseek` / `openai` / `qwen` / `claude` / `gemini` / `zhipu` / `moonshot` / `codestral` / `deepseek-r1` / `openai-o3` / `qwen-coder`
|
|
1362
|
+
|
|
1363
|
+
#### 方式二:手动配置 `.coderevrc.json`
|
|
1364
|
+
|
|
1365
|
+
```json
|
|
1366
|
+
{
|
|
1367
|
+
"ai": {
|
|
1368
|
+
"provider": "deepseek",
|
|
1369
|
+
"baseURL": "https://api.deepseek.com",
|
|
1370
|
+
"model": "deepseek-chat",
|
|
1371
|
+
"apiKeyEnv": "DEEPSEEK_API_KEY",
|
|
1372
|
+
"temperature": 0.3,
|
|
1373
|
+
"maxTokens": 4096,
|
|
1374
|
+
"fallback": {
|
|
1375
|
+
"enabled": true,
|
|
1376
|
+
"provider": "openai",
|
|
1377
|
+
"baseURL": "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
1378
|
+
"model": "qwen-plus",
|
|
1379
|
+
"temperature": 0.3
|
|
1380
|
+
},
|
|
1381
|
+
"agents": {
|
|
1382
|
+
"security": {
|
|
1383
|
+
"provider": "deepseek",
|
|
1384
|
+
"baseURL": "https://api.deepseek.com",
|
|
1385
|
+
"model": "deepseek-reasoner"
|
|
1386
|
+
},
|
|
1387
|
+
"quality": {
|
|
1388
|
+
"provider": "openai",
|
|
1389
|
+
"baseURL": "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
1390
|
+
"model": "qwen-plus"
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
```
|
|
1396
|
+
|
|
1397
|
+
| 字段 | 类型 | 必填 | 说明 |
|
|
1398
|
+
|------|------|------|------|
|
|
1399
|
+
| `ai.provider` | string | ✅ | AI 提供商标识,目前固定为 `"openai"` 或 `"deepseek"` |
|
|
1400
|
+
| `ai.baseURL` | string | ❌ | API 地址,支持任何 OpenAI 兼容接口 |
|
|
1401
|
+
| `ai.model` | string | ✅ | 模型名称 |
|
|
1402
|
+
| `ai.apiKey` | string | ❌ | 直接写入 API Key(不推荐,不够安全) |
|
|
1403
|
+
| `ai.apiKeyEnv` | string | ✅ | 从环境变量读取 API Key 的变量名 |
|
|
1404
|
+
| `ai.temperature` | number | ❌ | 0-1,默认 0.3(越低越确定) |
|
|
1405
|
+
| `ai.maxTokens` | number | ❌ | 最大输出 token,默认 4096 |
|
|
1406
|
+
| `ai.fallback` | object | ❌ | 备用模型配置(主模型失败时自动切换) |
|
|
1407
|
+
| `ai.agents` | object | ❌ | 按 Agent 角色指定不同模型 |
|
|
1408
|
+
| `ai.agents.security` | object | ❌ | 安全审计 Agent 的模型覆盖 |
|
|
1409
|
+
| `ai.agents.bugs` | object | ❌ | 缺陷检测 Agent 的模型覆盖 |
|
|
1410
|
+
| `ai.agents.quality` | object | ❌ | 质量检查 Agent 的模型覆盖 |
|
|
1411
|
+
|
|
1412
|
+
#### 方式三:环境变量
|
|
1413
|
+
|
|
1414
|
+
| 环境变量 | 提供商 | 对应模板 |
|
|
1415
|
+
|---------|--------|---------|
|
|
1416
|
+
| `DEEPSEEK_API_KEY` | DeepSeek | `deepseek` / `deepseek-r1` |
|
|
1417
|
+
| `OPENAI_API_KEY` | OpenAI | `openai` / `openai-o3` |
|
|
1418
|
+
| `DASHSCOPE_API_KEY` | 阿里云百炼 | `qwen` / `qwen-coder` |
|
|
1419
|
+
| `ANTHROPIC_API_KEY` | Anthropic | `claude` |
|
|
1420
|
+
| `GEMINI_API_KEY` | Google | `gemini` |
|
|
1421
|
+
| `ZHIPU_API_KEY` | 智谱 AI | `zhipu` |
|
|
1422
|
+
| `MOONSHOT_API_KEY` | 月之暗面 | `moonshot` |
|
|
1423
|
+
| `MISTRAL_API_KEY` | Mistral | `codestral` |
|
|
1424
|
+
|
|
1425
|
+
#### API Key 获取链接
|
|
1426
|
+
|
|
1427
|
+
| 提供商 | 获取地址 |
|
|
1428
|
+
|--------|---------|
|
|
1429
|
+
| DeepSeek | https://platform.deepseek.com/api_keys |
|
|
1430
|
+
| OpenAI | https://platform.openai.com/api-keys |
|
|
1431
|
+
| 阿里云百炼 | https://bailian.console.aliyun.com/ |
|
|
1432
|
+
| Anthropic | https://console.anthropic.com/keys |
|
|
1433
|
+
| Google AI | https://aistudio.google.com/apikey |
|
|
1434
|
+
| 智谱 AI | https://open.bigmodel.cn/usercenter/apikeys |
|
|
1435
|
+
| 月之暗面 | https://platform.moonshot.cn/ |
|
|
1436
|
+
| Mistral | https://console.mistral.ai/api-keys/ |
|
|
1437
|
+
|
|
1438
|
+
---
|
|
1439
|
+
|
|
1440
|
+
### 审查相关接口
|
|
1441
|
+
|
|
1442
|
+
#### `coderev review` — 核心审查
|
|
1443
|
+
|
|
1444
|
+
```
|
|
1445
|
+
coderev review [选项]
|
|
1446
|
+
```
|
|
1447
|
+
|
|
1448
|
+
**输入来源**(优先级从高到低):
|
|
1449
|
+
|
|
1450
|
+
| 来源 | 参数 | 说明 |
|
|
1451
|
+
|------|------|------|
|
|
1452
|
+
| 管道 stdin | (无参数) | `git diff main \| coderev review` |
|
|
1453
|
+
| Git 仓库 | `--repo <path>` + `--base` / `--head` | 在指定仓库中生成 diff |
|
|
1454
|
+
| Diff 文件 | `--file <path>` | 从文件读取 diff |
|
|
1455
|
+
| GitHub PR | `--pr <ref>` | 拉取 GitHub PR diff |
|
|
1456
|
+
| GitLab MR | `--gl <ref>` | 拉取 GitLab MR diff |
|
|
1457
|
+
| Gitee PR | `--gee <ref>` | 拉取 Gitee PR diff |
|
|
1458
|
+
| GitCode MR | `--gc <ref>` | 拉取 GitCode MR diff |
|
|
1459
|
+
| Bitbucket PR | `--bb <ref>` | 拉取 Bitbucket PR diff |
|
|
1460
|
+
|
|
1461
|
+
**审查参数**:
|
|
1462
|
+
|
|
1463
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
1464
|
+
|------|------|--------|------|
|
|
1465
|
+
| `--config, -c <path>` | string | — | 指定配置文件路径 |
|
|
1466
|
+
| `--output, -o <format>` | enum | `terminal` | 输出格式:`terminal` / `json` / `markdown` / `html` |
|
|
1467
|
+
| `--min-confidence <n>` | number | `60` | 置信度阈值(0-100),低于此值的结果被过滤 |
|
|
1468
|
+
| `--ci` | flag | — | CI 模式,发现 issue 以非零退出码终止 |
|
|
1469
|
+
| `--no-cache` | flag | — | 跳过缓存,强制重新审查 |
|
|
1470
|
+
| `--incremental` | flag | — | 增量模式,只关注新增/修改的行 |
|
|
1471
|
+
| `--interactive` | flag | — | 交互模式,逐条选择是否修复 |
|
|
1472
|
+
| `--audit` | flag | — | 安全审计模式(OWASP 级别检查) |
|
|
1473
|
+
| `--single` | flag | — | 单 Agent 模式(兼容旧版,省 token) |
|
|
1474
|
+
| `--agents <list>` | string | — | 逗号分隔的 Agent 列表,如 `security,bugs,quality` |
|
|
1475
|
+
| `--blame` | flag | — | 启用 git blame,区分新增 vs 已有问题 |
|
|
1476
|
+
|
|
1477
|
+
**PR/MR 回贴参数**:
|
|
1478
|
+
|
|
1479
|
+
| 参数 | 说明 |
|
|
1480
|
+
|------|------|
|
|
1481
|
+
| `--post` | 审查完成后自动回贴评论到 PR/MR(配合 `--pr`/`--gl` 等使用) |
|
|
1482
|
+
| `--inline` | 以行内方式回贴评论(仅 GitHub/GitLab 支持,配合 `--pr`/`--gl`) |
|
|
1483
|
+
| `--all` | 审查仓库所有开启的 PR(配合 `--pr owner/repo` 使用) |
|
|
1484
|
+
|
|
1485
|
+
**平台 Token 参数**:
|
|
1486
|
+
|
|
1487
|
+
| 参数 | 说明 |
|
|
1488
|
+
|------|------|
|
|
1489
|
+
| `--github-token <token>` | GitHub Personal Access Token |
|
|
1490
|
+
| `--gitlab-token <token>` | GitLab Personal Access Token |
|
|
1491
|
+
| `--gee-token <token>` | Gitee Personal Access Token |
|
|
1492
|
+
| `--gc-token <token>` | GitCode Access Token |
|
|
1493
|
+
| `--bb-token <token>` | Bitbucket App Password(`username:password`) |
|
|
1494
|
+
|
|
1495
|
+
**返回结构**(JSON 模式):
|
|
1496
|
+
|
|
1497
|
+
```json
|
|
1498
|
+
{
|
|
1499
|
+
"summary": "审查摘要",
|
|
1500
|
+
"score": 85,
|
|
1501
|
+
"issues": [
|
|
1502
|
+
{
|
|
1503
|
+
"type": "error|warning|info",
|
|
1504
|
+
"severity": "high|medium|low",
|
|
1505
|
+
"confidence": 85,
|
|
1506
|
+
"file": "src/file.js",
|
|
1507
|
+
"line": 42,
|
|
1508
|
+
"message": "问题描述",
|
|
1509
|
+
"suggestion": "修复建议",
|
|
1510
|
+
"detectedBy": "security|bugs|quality|legacy"
|
|
1511
|
+
}
|
|
1512
|
+
],
|
|
1513
|
+
"suggestions": ["改进建议"],
|
|
1514
|
+
"praise": ["好的实践"],
|
|
1515
|
+
"_agents": { "total": 3, "summary": "...", "errors": 0 },
|
|
1516
|
+
"_blameContext": { "newIssues": 2, "preExistingIssues": 1 }
|
|
1517
|
+
}
|
|
1518
|
+
```
|
|
1519
|
+
|
|
1520
|
+
---
|
|
1521
|
+
|
|
1522
|
+
### PR/MR 平台接口
|
|
1523
|
+
|
|
1524
|
+
每个平台有独立的参数前缀和 ref 格式:
|
|
1525
|
+
|
|
1526
|
+
| 平台 | 参数 | Ref 格式 | 示例 |
|
|
1527
|
+
|------|------|---------|------|
|
|
1528
|
+
| GitHub | `--pr` | `owner/repo#N` 或 `N` | `--pr 42` 或 `--pr owner/repo#42` |
|
|
1529
|
+
| GitLab | `--gl` | `owner/repo!N` | `--gl 42` 或 `--gl owner/repo!42` |
|
|
1530
|
+
| Gitee | `--gee` | `owner/repo!N` | `--gee owner/repo!42` |
|
|
1531
|
+
| GitCode | `--gc` | `owner/repo!N` | `--gc owner/repo!42` |
|
|
1532
|
+
| Bitbucket | `--bb` | `owner/repo#N` | `--bb owner/repo#42` |
|
|
1533
|
+
|
|
1534
|
+
**自动检测**:GitHub 和 GitLab 支持只传数字(`--pr 42`),coderev 会从 `git remote` 自动检测仓库名。
|
|
1535
|
+
|
|
1536
|
+
**支持的 URL 格式**(直接粘贴浏览器的 PR URL 也可以):
|
|
1537
|
+
|
|
1538
|
+
```bash
|
|
1539
|
+
coderev review --pr https://github.com/user/repo/pull/42
|
|
1540
|
+
coderev review --gl https://gitlab.com/user/repo/-/merge_requests/42
|
|
1541
|
+
coderev review --gee https://gitee.com/user/repo/pulls/42
|
|
1542
|
+
```
|
|
1543
|
+
|
|
1544
|
+
**回贴评论的完整流程**:
|
|
1545
|
+
|
|
1546
|
+
```bash
|
|
1547
|
+
# 1. 审查 PR + 回贴摘要评论
|
|
1548
|
+
coderev review --pr 42 --post --github-token ghp_xxx
|
|
1549
|
+
|
|
1550
|
+
# 2. 审查 PR + 行内评论(更精细)
|
|
1551
|
+
coderev review --pr 42 --inline --github-token ghp_xxx
|
|
1552
|
+
|
|
1553
|
+
# 3. 批量审查所有开放 PR
|
|
1554
|
+
coderev review --pr owner/repo --all --github-token ghp_xxx --post
|
|
1555
|
+
|
|
1556
|
+
# 4. GitLab MR 审查 + 回贴
|
|
1557
|
+
coderev review --gl 42 --post --gitlab-token glpat_xxx
|
|
1558
|
+
```
|
|
1559
|
+
|
|
1560
|
+
---
|
|
1561
|
+
|
|
1562
|
+
### 修复相关接口
|
|
1563
|
+
|
|
1564
|
+
#### `coderev fix` — 自动修复
|
|
1565
|
+
|
|
1566
|
+
```
|
|
1567
|
+
coderev fix [选项]
|
|
1568
|
+
```
|
|
1569
|
+
|
|
1570
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
1571
|
+
|------|------|------|------|
|
|
1572
|
+
| `--file, -f <path>` | string | 二选一 | 指定 diff 文件路径 |
|
|
1573
|
+
| `--pr <ref>` | string | 二选一 | 指定 PR 编号 |
|
|
1574
|
+
| `--apply` | flag | ❌ | 直接应用补丁到文件中 |
|
|
1575
|
+
| `--github-token <token>` | string | ❌ | GitHub Token(配合 --pr 使用) |
|
|
1576
|
+
|
|
1577
|
+
**输入来源**:
|
|
1578
|
+
1. `--file` 指定 diff 文件
|
|
1579
|
+
2. `--pr` 拉取 PR diff
|
|
1580
|
+
3. 管道 stdin(默认)
|
|
1581
|
+
|
|
1582
|
+
**修复流程**:
|
|
1583
|
+
1. 读取 diff → 运行审查 → 识别问题
|
|
1584
|
+
2. 调用 AI 生成统一补丁(unified patch)
|
|
1585
|
+
3. 输出补丁内容到终端
|
|
1586
|
+
4. 如果带 `--apply`,自动执行 `git apply`
|
|
1587
|
+
|
|
1588
|
+
```bash
|
|
1589
|
+
# 生成 diff → 修复 → 输出补丁
|
|
1590
|
+
coderev fix --file changes.diff
|
|
1591
|
+
|
|
1592
|
+
# 直接从 PR 修复并应用
|
|
1593
|
+
coderev fix --pr 42 --apply --github-token ghp_xxx
|
|
1594
|
+
|
|
1595
|
+
# 管道模式
|
|
1596
|
+
git diff main | coderev fix --apply
|
|
1597
|
+
```
|
|
1598
|
+
|
|
1599
|
+
#### 交互式修复(coderev review --interactive)
|
|
1600
|
+
|
|
1601
|
+
```bash
|
|
1602
|
+
coderev review --interactive
|
|
1603
|
+
```
|
|
1604
|
+
|
|
1605
|
+
逐条展示 issue,可选操作:
|
|
1606
|
+
|
|
1607
|
+
| 按键 | 操作 | 说明 |
|
|
1608
|
+
|------|------|------|
|
|
1609
|
+
| `a` | Apply fix | AI 生成补丁并输出 |
|
|
1610
|
+
| `s` | Skip | 跳过当前 issue |
|
|
1611
|
+
| `q` | Quit | 退出,已修复的保存为 `coderev-fixes.patch` |
|
|
1612
|
+
|
|
1613
|
+
---
|
|
1614
|
+
|
|
1615
|
+
### Hook 接口
|
|
1616
|
+
|
|
1617
|
+
#### `coderev hook` — Git Hooks 管理
|
|
1618
|
+
|
|
1619
|
+
```
|
|
1620
|
+
coderev hook <action> [hook-type] [选项]
|
|
1621
|
+
```
|
|
1622
|
+
|
|
1623
|
+
| 参数 | 值 | 说明 |
|
|
1624
|
+
|------|-----|------|
|
|
1625
|
+
| `<action>` | `install` / `remove` | 安装或卸载 hook |
|
|
1626
|
+
| `[hook-type]` | `pre-commit` / `pre-push` | Hook 类型(默认 `pre-commit`) |
|
|
1627
|
+
| `--min-score <n>` | number | 最低评分阈值(默认 50),低于此值阻止提交/推送 |
|
|
1628
|
+
|
|
1629
|
+
**Hook 行为**:
|
|
1630
|
+
- `pre-commit`:`git commit` 前自动运行审查,评分低于阈值阻止提交
|
|
1631
|
+
- `pre-push`:`git push` 前自动运行审查,评分低于阈值阻止推送
|
|
1632
|
+
|
|
1633
|
+
```bash
|
|
1634
|
+
coderev hook install # 安装 pre-commit
|
|
1635
|
+
coderev hook install pre-commit --min-score 70
|
|
1636
|
+
coderev hook install pre-push
|
|
1637
|
+
coderev hook remove # 移除全部
|
|
1638
|
+
coderev hook remove pre-commit # 移除指定
|
|
1639
|
+
```
|
|
1640
|
+
|
|
1641
|
+
---
|
|
1642
|
+
|
|
1643
|
+
### 统计与缓存接口
|
|
1644
|
+
|
|
1645
|
+
#### `coderev stats` — 审查统计
|
|
1646
|
+
|
|
1647
|
+
```
|
|
1648
|
+
coderev stats [period] [选项]
|
|
1649
|
+
```
|
|
1650
|
+
|
|
1651
|
+
| 参数 | 值 | 说明 |
|
|
1652
|
+
|------|-----|------|
|
|
1653
|
+
| `[period]` | `day` / `week` / `month` / `all` | 统计周期(默认 `all`) |
|
|
1654
|
+
| `--clear` | flag | 清除全部审查历史 |
|
|
1655
|
+
|
|
1656
|
+
**输出内容**:总审查次数、平均分、最高/最低分、问题数、类型分布、严重程度分布、趋势图
|
|
1657
|
+
|
|
1658
|
+
#### `coderev cache` — 缓存管理
|
|
1659
|
+
|
|
1660
|
+
```
|
|
1661
|
+
coderev cache [action]
|
|
1662
|
+
```
|
|
1663
|
+
|
|
1664
|
+
| 参数 | 值 | 说明 |
|
|
1665
|
+
|------|-----|------|
|
|
1666
|
+
| `[action]` | `status` / `clear` | 查看缓存状态或清空缓存 |
|
|
1667
|
+
|
|
1668
|
+
**缓存机制**:
|
|
1669
|
+
- 基于 diff SHA256 哈希
|
|
1670
|
+
- 有效期 24 小时
|
|
1671
|
+
- 缓存目录:`~/.coderev/cache/`
|
|
1672
|
+
- 可跳过缓存:`coderev review --no-cache`
|
|
1673
|
+
|
|
1674
|
+
---
|
|
1675
|
+
|
|
1676
|
+
### 配置与诊断接口
|
|
1677
|
+
|
|
1678
|
+
#### `coderev config` — 配置管理
|
|
1679
|
+
|
|
1680
|
+
```
|
|
1681
|
+
coderev config [action]
|
|
1682
|
+
```
|
|
1683
|
+
|
|
1684
|
+
| 参数 | 值 | 说明 |
|
|
1685
|
+
|------|-----|------|
|
|
1686
|
+
| `[action]` | `show` / `validate` / `path` | 显示配置 / 验证配置 / 显示配置文件路径 |
|
|
1687
|
+
|
|
1688
|
+
```bash
|
|
1689
|
+
coderev config # 显示当前配置(API Key 已脱敏)
|
|
1690
|
+
coderev config validate # 验证配置完整性
|
|
1691
|
+
coderev config path # 输出配置文件路径
|
|
1692
|
+
```
|
|
1693
|
+
|
|
1694
|
+
#### `coderev init` — 项目初始化
|
|
1695
|
+
|
|
1696
|
+
```
|
|
1697
|
+
coderev init [选项]
|
|
1698
|
+
```
|
|
1699
|
+
|
|
1700
|
+
| 参数 | 说明 |
|
|
1701
|
+
|------|------|
|
|
1702
|
+
| `--github-action` | 同时生成 `.github/workflows/coderev.yml` |
|
|
1703
|
+
| `--gitlab-ci` | 同时生成 `.gitlab-ci.yml` |
|
|
1704
|
+
|
|
1705
|
+
**生成文件**:
|
|
1706
|
+
1. `.coderevrc.json` — 审查配置
|
|
1707
|
+
2. `.coderevignore` — 忽略文件列表(glob)
|
|
1708
|
+
3. `.coderevhint` — AI 项目上下文提示
|
|
1709
|
+
|
|
1710
|
+
#### `coderev doctor` — 环境诊断
|
|
1711
|
+
|
|
1712
|
+
```
|
|
1713
|
+
coderev doctor [选项]
|
|
1714
|
+
```
|
|
1715
|
+
|
|
1716
|
+
| 参数 | 说明 |
|
|
1717
|
+
|------|------|
|
|
1718
|
+
| `-c, --config <path>` | 指定配置文件路径 |
|
|
1719
|
+
| `--json` | JSON 格式输出 |
|
|
1720
|
+
|
|
1721
|
+
**诊断项目**:Node.js 版本 → Git 环境 → 配置文件 → API Key → AI 服务商连通性
|
|
1722
|
+
|
|
1723
|
+
---
|
|
1724
|
+
|
|
1725
|
+
### GitHub App 服务接口
|
|
1726
|
+
|
|
1727
|
+
#### `coderev serve` — Webhook 服务器
|
|
1728
|
+
|
|
1729
|
+
```
|
|
1730
|
+
coderev serve [选项]
|
|
1731
|
+
```
|
|
1732
|
+
|
|
1733
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
1734
|
+
|------|------|--------|------|
|
|
1735
|
+
| `-p, --port <n>` | number | `3000` | HTTP 端口 |
|
|
1736
|
+
| `--app-id <id>` | string | — | GitHub App ID |
|
|
1737
|
+
| `--private-key <key>` | string | — | RSA 私钥 PEM |
|
|
1738
|
+
| `--webhook-secret <secret>` | string | — | Webhook 签名密钥 |
|
|
1739
|
+
| `--review-mode <mode>` | enum | `comment` | 审查模式:`comment` / `inline` / `check` |
|
|
1740
|
+
| `--auto-approve` | flag | — | 无问题 PR 自动 approve |
|
|
1741
|
+
| `--min-confidence <n>` | number | `60` | 置信度阈值 |
|
|
1742
|
+
|
|
1743
|
+
**HTTP 端点**:
|
|
1744
|
+
|
|
1745
|
+
| 路径 | 方法 | 说明 |
|
|
1746
|
+
|------|------|------|
|
|
1747
|
+
| `/webhook` | POST | GitHub App webhook 入口 |
|
|
1748
|
+
| `/health` | GET | 健康检查 |
|
|
1749
|
+
|
|
1750
|
+
**健康检查返回**:
|
|
1751
|
+
```json
|
|
1752
|
+
{
|
|
1753
|
+
"status": "ok",
|
|
1754
|
+
"version": "1.0.0",
|
|
1755
|
+
"uptime": 3600
|
|
1756
|
+
}
|
|
1757
|
+
```
|
|
1758
|
+
|
|
1759
|
+
---
|
|
1760
|
+
|
|
1761
|
+
### 规则市场接口
|
|
1762
|
+
|
|
1763
|
+
#### `coderev rules` — 规则包管理
|
|
1764
|
+
|
|
1765
|
+
```
|
|
1766
|
+
coderev rules <action> [选项]
|
|
1767
|
+
```
|
|
1768
|
+
|
|
1769
|
+
| 动作 | 说明 | 示例 |
|
|
1770
|
+
|------|------|------|
|
|
1771
|
+
| `search [query]` | 搜索规则市场 | `coderev rules search react` |
|
|
1772
|
+
| `install <name>` | 安装规则包 | `coderev rules install react-security` |
|
|
1773
|
+
| `publish` | 发布本地规则 | `coderev rules publish --name my-rules` |
|
|
1774
|
+
| `list` | 查看已安装 | `coderev rules list` |
|
|
1775
|
+
| `uninstall <name>` | 卸载规则包 | `coderev rules uninstall react-security` |
|
|
1776
|
+
| `info <name>` | 规则包详情 | `coderev rules info react-security` |
|
|
1777
|
+
|
|
1778
|
+
**参数**:
|
|
1779
|
+
|
|
1780
|
+
| 参数 | 说明 |
|
|
1781
|
+
|------|------|
|
|
1782
|
+
| `-q, --query <text>` | 搜索关键词 |
|
|
1783
|
+
| `-n, --name <name>` | 规则包名称 |
|
|
1784
|
+
| `--version <ver>` | 发布版本号 |
|
|
1785
|
+
| `--desc <text>` | 发布描述 |
|
|
1786
|
+
| `--api-url <url>` | 自定义市场 API 地址(默认 `https://rules.coderev.dev/api`) |
|
|
1787
|
+
|
|
1788
|
+
**安装目录**:`.coderev-marketplace/installed.json`(清单) + `.coderevrc.json` 中 `rules.custom` 数组(规则,带 `_source` 标记)
|
|
1789
|
+
|
|
1790
|
+
---
|
|
1791
|
+
|
|
1792
|
+
### VS Code 扩展接口
|
|
1793
|
+
|
|
1794
|
+
#### 扩展命令
|
|
1795
|
+
|
|
1796
|
+
| 命令 ID | 说明 |
|
|
1797
|
+
|---------|------|
|
|
1798
|
+
| `coderev.reviewWorkspace` | 审查整个工作区 |
|
|
1799
|
+
| `coderev.reviewFile` | 审查当前打开的文件 |
|
|
1800
|
+
| `coderev.fixFile` | 修复当前文件的问题 |
|
|
1801
|
+
|
|
1802
|
+
#### 扩展配置项
|
|
1803
|
+
|
|
1804
|
+
| 配置键 | 类型 | 默认值 | 说明 |
|
|
1805
|
+
|--------|------|--------|------|
|
|
1806
|
+
| `coderev.enabled` | boolean | `true` | 是否启用扩展 |
|
|
1807
|
+
| `coderev.lintOnSave` | boolean | `false` | 保存文件时自动审查 |
|
|
1808
|
+
| `coderev.minConfidence` | number | `60` | 最低置信度阈值 |
|
|
1809
|
+
| `coderev.apiKey` | string | `""` | AI 提供商的 API Key |
|
|
1810
|
+
| `coderev.model` | string | `"deepseek-chat"` | 使用的模型 |
|
|
1811
|
+
|
|
1812
|
+
---
|
|
1813
|
+
|
|
1059
1814
|
## FAQ / 常见问题
|
|
1060
1815
|
|
|
1061
1816
|
### Q:为什么审查结果为空?
|
|
@@ -1076,6 +1831,27 @@ A:可以,审查时加 `--no-cache` 参数即可跳过缓存。
|
|
|
1076
1831
|
### Q:怎么给 coderev 加自己的规则?
|
|
1077
1832
|
A:在 `.coderevrc.json` 的 `rules.custom` 数组中添加。详见上方「自定义规则」章节。
|
|
1078
1833
|
|
|
1834
|
+
### Q:GitHub / GitLab Token 权限不够怎么办?
|
|
1835
|
+
A:确保 Token 至少有以下权限:
|
|
1836
|
+
- **GitHub**:`repo`(全部)
|
|
1837
|
+
- **GitLab**:`read_api` + `read_repository`(如要发布评论再加 `api`)
|
|
1838
|
+
- **Gitee**:`pull_requests` + `projects`
|
|
1839
|
+
- **GitCode**:`api` + `read_repository`
|
|
1840
|
+
- **Bitbucket**:`Repositories: Read` + `Pull requests: Read`
|
|
1841
|
+
|
|
1842
|
+
### Q:Token 泄漏了怎么办?
|
|
1843
|
+
A:立即到对应平台撤销旧 Token,重新生成。建议始终用环境变量存储 Token,不要直接写到 `.coderevrc.json` 中,并确保 `.coderevrc.json` 在 `.gitignore` 中。
|
|
1844
|
+
|
|
1845
|
+
### Q:如何获取各 AI 提供商 API Key?
|
|
1846
|
+
A:详见上方「API Key(AI 模型)配置接口」→ [API Key 获取链接](#api-key-获取链接)。每个提供商都有免费额度或试用额度。
|
|
1847
|
+
|
|
1848
|
+
### Q:`coderev serve` 报 "Missing GITHUB_APP_ID or GITHUB_APP_PRIVATE_KEY"
|
|
1849
|
+
A:GitHub App 需要三个凭据,确认都已设置:
|
|
1850
|
+
- `GITHUB_APP_ID`(数字,如 `123456`)
|
|
1851
|
+
- `GITHUB_APP_PRIVATE_KEY`(PEM 格式私钥全文)
|
|
1852
|
+
- `GITHUB_APP_WEBHOOK_SECRET`(推荐,与 App 设置页一致)
|
|
1853
|
+
详见上方「Token 生成和使用说明」→ [GitHub App JWT Token](#6-github-app-jwt-tokencoderev-serve)
|
|
1854
|
+
|
|
1079
1855
|
---
|
|
1080
1856
|
## Contributing
|
|
1081
1857
|
|