@ranger1/dx 0.1.77 → 0.1.79
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 +102 -33
- package/bin/dx.js +3 -3
- package/lib/cli/commands/core.js +24 -1
- package/lib/cli/commands/db.js +6 -4
- package/lib/cli/commands/stack.js +198 -237
- package/lib/cli/commands/start.js +0 -6
- package/lib/cli/dx-cli.js +84 -1
- package/lib/cli/help.js +42 -9
- package/lib/{opencode-initial.js → codex-initial.js} +3 -82
- package/package.json +1 -2
- package/@opencode/agents/__pycache__/gh_review_harvest.cpython-314.pyc +0 -0
- package/@opencode/agents/__pycache__/pr_context.cpython-314.pyc +0 -0
- package/@opencode/agents/__pycache__/pr_precheck.cpython-314.pyc +0 -0
- package/@opencode/agents/__pycache__/pr_review_aggregate.cpython-314.pyc +0 -0
- package/@opencode/agents/__pycache__/test_pr_review_aggregate.cpython-314-pytest-9.0.2.pyc +0 -0
- package/@opencode/agents/__pycache__/test_pr_review_aggregate.cpython-314.pyc +0 -0
- package/@opencode/agents/claude-reviewer.md +0 -82
- package/@opencode/agents/codex-reviewer.md +0 -83
- package/@opencode/agents/gemini-reviewer.md +0 -82
- package/@opencode/agents/gh-thread-reviewer.md +0 -122
- package/@opencode/agents/gh_review_harvest.py +0 -292
- package/@opencode/agents/pr-context.md +0 -82
- package/@opencode/agents/pr-fix.md +0 -243
- package/@opencode/agents/pr-precheck.md +0 -89
- package/@opencode/agents/pr-review-aggregate.md +0 -151
- package/@opencode/agents/pr_context.py +0 -351
- package/@opencode/agents/pr_precheck.py +0 -505
- package/@opencode/agents/pr_review_aggregate.py +0 -868
- package/@opencode/agents/test_pr_review_aggregate.py +0 -701
- package/@opencode/commands/doctor.md +0 -271
- package/@opencode/commands/git-commit-and-pr.md +0 -282
- package/@opencode/commands/git-release.md +0 -642
- package/@opencode/commands/oh_attach.json +0 -92
- package/@opencode/commands/opencode_attach.json +0 -29
- package/@opencode/commands/opencode_attach.py +0 -142
- package/@opencode/commands/pr-review-loop.md +0 -211
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: PR fix review
|
|
3
|
-
mode: subagent
|
|
4
|
-
model: openai/gpt-5.3-codex
|
|
5
|
-
temperature: 0.1
|
|
6
|
-
tools:
|
|
7
|
-
write: true
|
|
8
|
-
edit: true
|
|
9
|
-
bash: true
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# Fix Specialist
|
|
13
|
-
|
|
14
|
-
执行 PR 修复(基于 fixFile),并生成可直接发布到 GitHub 评论的修复报告(Markdown 文件)。
|
|
15
|
-
|
|
16
|
-
## Agent 角色定义
|
|
17
|
-
|
|
18
|
-
| 属性 | 描述 |
|
|
19
|
-
| -------------- | ------------------------------------------------------------------------ |
|
|
20
|
-
| **角色** | 代码修复 Specialist(执行层) |
|
|
21
|
-
| **上下文隔离** | 仅处理问题列表;不重新获取评审意见(默认不调用 `gh` 拉取 PR 上下文) |
|
|
22
|
-
| **输入** | PR 编号 + `fixFile`(Markdown 文件名,Structured Handoff) |
|
|
23
|
-
| **输出** | fixReportFile(Markdown 文件名) |
|
|
24
|
-
| **边界** | ✅ 可修改代码、提交并推送;⛔ 不发布 GitHub 评论(由 Orchestrator 负责) |
|
|
25
|
-
|
|
26
|
-
## 前置条件
|
|
27
|
-
|
|
28
|
-
### Cache 约定(强制)
|
|
29
|
-
|
|
30
|
-
- 缓存目录固定为 `./.cache/`;交接一律传 `./.cache/<file>`(repo 相对路径),禁止 basename-only(如 `foo.md`)。
|
|
31
|
-
|
|
32
|
-
### 必需输入
|
|
33
|
-
|
|
34
|
-
- **PR 编号**:调用者必须在 prompt 中明确提供(如:`请修复 PR #123`)
|
|
35
|
-
- **runId**:调用者必须在 prompt 中提供(必须透传,格式 `<PR>-<ROUND>-<HEAD_SHORT>`,禁止自行生成)
|
|
36
|
-
- **fixFile**:调用者必须在 prompt 中提供问题清单文件路径(repo 相对路径,例:`./.cache/fix-...md`)(Structured Handoff)
|
|
37
|
-
|
|
38
|
-
### 失败快速退出
|
|
39
|
-
|
|
40
|
-
如未满足以下任一条件,立即返回错误 JSON 并退出:
|
|
41
|
-
|
|
42
|
-
- ❌ prompt 未包含 PR 编号 → `{"error":"MISSING_PR_NUMBER"}`
|
|
43
|
-
- ❌ prompt 未包含 fixFile → `{"error":"MISSING_FIX_FILE"}`
|
|
44
|
-
- ❌ fixFile 不存在/不可读 → `{"error":"FIX_FILE_NOT_READABLE"}`
|
|
45
|
-
- ❌ fixFile 无法解析出 issuesToFix → `{"error":"INVALID_FIX_FILE"}`
|
|
46
|
-
|
|
47
|
-
## 输入格式(Structured Handoff:fixFile,Markdown)
|
|
48
|
-
|
|
49
|
-
说明:fixFile 由编排器根据 reviewer 的 findings 聚合生成;不要求严格 JSON,但必须包含可解析的字段。
|
|
50
|
-
|
|
51
|
-
推荐最小格式(稳定、易解析):
|
|
52
|
-
|
|
53
|
-
```md
|
|
54
|
-
# Fix File
|
|
55
|
-
|
|
56
|
-
PR: 123
|
|
57
|
-
Round: 2
|
|
58
|
-
|
|
59
|
-
## IssuesToFix
|
|
60
|
-
|
|
61
|
-
- id: CDX-001
|
|
62
|
-
priority: P1
|
|
63
|
-
category: quality
|
|
64
|
-
file: apps/backend/src/foo.ts
|
|
65
|
-
line: 42
|
|
66
|
-
title: 未处理的异常
|
|
67
|
-
description: JSON.parse 可能抛出异常但未被捕获
|
|
68
|
-
suggestion: 添加 try/catch 并返回一致错误码
|
|
69
|
-
|
|
70
|
-
## OptionalIssues
|
|
71
|
-
|
|
72
|
-
- id: GMN-004
|
|
73
|
-
priority: P3
|
|
74
|
-
category: suggestion
|
|
75
|
-
file: apps/front/src/bar.tsx
|
|
76
|
-
line: null
|
|
77
|
-
title: 可读性优化
|
|
78
|
-
description: ...
|
|
79
|
-
suggestion: ...
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
解析规则(强制):
|
|
83
|
-
|
|
84
|
-
- 仅处理 `## IssuesToFix` 段落里的条目;`## OptionalIssues` 可忽略或按需处理(建议:根据 PR 目标/风险/时间预算自行裁决)
|
|
85
|
-
- 每条必须至少包含:`id`、`priority`、`file`、`title`、`suggestion`
|
|
86
|
-
- `line` 允许为 `null`
|
|
87
|
-
|
|
88
|
-
## 工作流程
|
|
89
|
-
|
|
90
|
-
### 1. 读取 fixFile 并标准化
|
|
91
|
-
|
|
92
|
-
要求:只依赖 prompt 中的 `fixFile`;不要重新拉取/生成评审意见。
|
|
93
|
-
|
|
94
|
-
- 用 bash 读取 `fixFile`(例如 `cat "$fixFile"`)
|
|
95
|
-
- 解析失败则返回 `INVALID_FIX_FILE`
|
|
96
|
-
|
|
97
|
-
### 2. 逐项修复(No Scope Creep)
|
|
98
|
-
|
|
99
|
-
- 仅修复 fixFile 中列出的问题:`IssuesToFix`(必要)与 `OptionalIssues`(可选)
|
|
100
|
-
- 每个修复必须能明确对应到原问题的 `id`
|
|
101
|
-
- 无法修复时必须记录原因(例如:缺少上下文、超出本 PR 范围、需要产品决策、需要数据库迁移等)
|
|
102
|
-
|
|
103
|
-
### 3. 提交策略
|
|
104
|
-
|
|
105
|
-
- 强制:每个 findingId 单独一个提交(一个 findingId 对应一个 commit)
|
|
106
|
-
- 每个提交后立即推送到远端(禁止 force push)
|
|
107
|
-
- 约定:如无 upstream,首次用 `git push -u origin HEAD`,后续用 `git push`
|
|
108
|
-
- 所有问题处理完毕后,再执行一次 `git push` 作为兜底
|
|
109
|
-
|
|
110
|
-
提交信息建议(强制包含 findingId):
|
|
111
|
-
|
|
112
|
-
- `fix(pr #<PR_NUMBER>): <FINDING_ID> <title>`
|
|
113
|
-
|
|
114
|
-
## 修复原则(强制)
|
|
115
|
-
|
|
116
|
-
- 只修复 `issuesToFix`/`optionalIssues`;禁止顺手重构/格式化/改无关代码
|
|
117
|
-
- 不确定的问题降级为拒绝修复,并写清 `reason`(不要“猜”)
|
|
118
|
-
- 修改尽量小:最小 diff、保持既有风格与约定
|
|
119
|
-
- 修改项目里的json/jsonc文件的时候,使用python脚本进行修改,禁止手动拼接字符串,防止格式错误
|
|
120
|
-
- 修复完成之后,调用 dx lint 和 dx build all 确保编译通过
|
|
121
|
-
|
|
122
|
-
## 重要约束(强制)
|
|
123
|
-
|
|
124
|
-
- ⛔ 不要发布评论到 GitHub(不调用 `gh pr comment/review`)
|
|
125
|
-
- ✅ 必须 push(禁止 force push;禁止 rebase)
|
|
126
|
-
- ✅ 必须生成 fixReportFile(Markdown),内容可直接发到 GitHub 评论
|
|
127
|
-
|
|
128
|
-
## 输出(强制)
|
|
129
|
-
|
|
130
|
-
写入:`./.cache/fix-report-pr<PR_NUMBER>-r<ROUND>-<RUN_ID>.md`
|
|
131
|
-
|
|
132
|
-
最终只输出一行:
|
|
133
|
-
|
|
134
|
-
`fixReportFile: ./.cache/<file>.md`
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
## Decision Log 输出(强制)
|
|
138
|
-
|
|
139
|
-
修复完成后,必须生成/追加 Decision Log 文件,用于跨轮次的决策持久化存储。
|
|
140
|
-
|
|
141
|
-
### 文件路径
|
|
142
|
-
|
|
143
|
-
`./.cache/decision-log-pr<PR_NUMBER>.md`
|
|
144
|
-
|
|
145
|
-
### 格式规范
|
|
146
|
-
|
|
147
|
-
```markdown
|
|
148
|
-
# Decision Log
|
|
149
|
-
|
|
150
|
-
PR: <PR_NUMBER>
|
|
151
|
-
|
|
152
|
-
## Round <ROUND>
|
|
153
|
-
|
|
154
|
-
### Fixed
|
|
155
|
-
|
|
156
|
-
- id: <FINDING_ID>
|
|
157
|
-
file: <FILE_PATH>
|
|
158
|
-
commit: <SHA>
|
|
159
|
-
essence: <问题本质的一句话描述>
|
|
160
|
-
|
|
161
|
-
### Rejected
|
|
162
|
-
|
|
163
|
-
- id: <FINDING_ID>
|
|
164
|
-
file: <FILE_PATH>
|
|
165
|
-
priority: <P0|P1|P2|P3>
|
|
166
|
-
reason: <拒绝原因>
|
|
167
|
-
essence: <问题本质的一句话描述>
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### 追加规则(强制)
|
|
171
|
-
|
|
172
|
-
- 如果文件不存在:创建新文件,包含 `# Decision Log` 头、`PR: <PR_NUMBER>` 字段,以及第一个 `## Round <ROUND>` 段落
|
|
173
|
-
- 如果文件存在:追加新的 `## Round <ROUND>` 段落到文件末尾
|
|
174
|
-
- **禁止删除或覆盖历史轮次的记录**
|
|
175
|
-
- **file 字段**:必须记录问题所在的文件路径(repo 相对路径)。
|
|
176
|
-
- 对于 `pr-precheck` 产生的修复,`file` 字段可填 `__precheck__`。
|
|
177
|
-
|
|
178
|
-
### essence 字段要求
|
|
179
|
-
|
|
180
|
-
essence 是问题本质的一句话描述,用于后续轮次的智能匹配和重复检测。要求:
|
|
181
|
-
|
|
182
|
-
- 简洁性:≤ 50 字
|
|
183
|
-
- 问题导向:描述问题核心(而非具体代码位置、文件行号)
|
|
184
|
-
- 可匹配性:后续轮次的 reviewer 能通过关键词匹配识别该问题
|
|
185
|
-
- **文件强绑定**:必须假设问题与当前文件强绑定(若文件重命名,视为不同问题)
|
|
186
|
-
|
|
187
|
-
**示例对比:**
|
|
188
|
-
|
|
189
|
-
| ✅ 好的 essence | ❌ 不好的 essence |
|
|
190
|
-
|---|---|
|
|
191
|
-
| "JSON.parse 未捕获异常" | "apps/backend/src/foo.ts 第 42 行缺少 try/catch" |
|
|
192
|
-
| "缺少输入验证" | "在 UserController 中没有验证 username 参数" |
|
|
193
|
-
| "密码明文存储" | "第 156 行 password 字段未加密" |
|
|
194
|
-
|
|
195
|
-
### Decision Log 的用途
|
|
196
|
-
|
|
197
|
-
Decision Log 供后续工作流参考:
|
|
198
|
-
|
|
199
|
-
- **pr-review-loop**:检查 decision-log 是否存在,避免重复提出已拒绝的问题
|
|
200
|
-
- **pr-review-aggregate**:使用 LLM 智能匹配 essence 字段,识别本轮与历史轮的重复问题
|
|
201
|
-
- **交接文档**:跨团队成员阅读,理解历史决策
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
## fixReportFile 内容格式(强制)
|
|
205
|
-
|
|
206
|
-
fixReportFile 内容必须是可直接粘贴到 GitHub 评论的 Markdown,且不得包含本地缓存文件路径。
|
|
207
|
-
|
|
208
|
-
```md
|
|
209
|
-
# Fix Report
|
|
210
|
-
|
|
211
|
-
PR: <PR_NUMBER>
|
|
212
|
-
Round: <ROUND>
|
|
213
|
-
|
|
214
|
-
## Summary
|
|
215
|
-
|
|
216
|
-
Fixed: <n>
|
|
217
|
-
Rejected: <n>
|
|
218
|
-
|
|
219
|
-
## Fixed
|
|
220
|
-
|
|
221
|
-
- id: <FINDING_ID>
|
|
222
|
-
commit: <SHA>
|
|
223
|
-
note: <what changed>
|
|
224
|
-
|
|
225
|
-
## Rejected
|
|
226
|
-
|
|
227
|
-
- id: <FINDING_ID>
|
|
228
|
-
reason: <why>
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
## Multi-Agent 约束(Contract)
|
|
232
|
-
|
|
233
|
-
| 约束 | 说明 |
|
|
234
|
-
| -------------------- | --------------------------------------------------------------------------- |
|
|
235
|
-
| **Structured Input** | 仅处理 `fixFile` 中的问题;不重新获取评审意见(默认不调用 `gh` 拉取上下文) |
|
|
236
|
-
| **Output** | 必须生成 fixReportFile(Markdown) |
|
|
237
|
-
| **ID Correlation** | 每条提交必须能关联到某个 findingId |
|
|
238
|
-
| **No Scope Creep** | ⛔ 不修复 fixFile 之外的问题,不引入无关变更 |
|
|
239
|
-
|
|
240
|
-
## 输出有效性保证
|
|
241
|
-
|
|
242
|
-
- fixReportFile 必须成功写入
|
|
243
|
-
- stdout 只能输出一行 `fixReportFile: ./.cache/<file>.md`
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: PR precheck (checkout + lint + build)
|
|
3
|
-
mode: subagent
|
|
4
|
-
model: openai/gpt-5.3-codex
|
|
5
|
-
temperature: 0.1
|
|
6
|
-
tools:
|
|
7
|
-
bash: true
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# PR Precheck
|
|
11
|
-
|
|
12
|
-
## Cache 约定(强制)
|
|
13
|
-
|
|
14
|
-
- 缓存目录固定为 `./.cache/`;交接一律传 `./.cache/<file>`(repo 相对路径),禁止 basename-only(如 `foo.md`)。
|
|
15
|
-
|
|
16
|
-
## 输入(prompt 必须包含)
|
|
17
|
-
|
|
18
|
-
- `PR #<number>`
|
|
19
|
-
- `round: <number>`(默认 1)
|
|
20
|
-
|
|
21
|
-
## 一键脚本
|
|
22
|
-
|
|
23
|
-
脚本位置:`~/.opencode/agents/pr_precheck.py`
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
python3 ~/.opencode/agents/pr_precheck.py --pr <PR_NUMBER> --round <ROUND>
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## 脚本输出处理(强制)
|
|
30
|
-
|
|
31
|
-
- 脚本 stdout 只会输出**单一一行 JSON**(可 `JSON.parse()`)。
|
|
32
|
-
- **成功时**:你的最终输出必须是**脚本 stdout 的那一行 JSON 原样内容**。
|
|
33
|
-
- 典型返回:`{"ok":true}` 或 `{"ok":false,"fixFile":"..."}`
|
|
34
|
-
- **重要**:如果返回 `fixFile`,请使用基于 `headOid` 的标准 runId(`<PR>-<ROUND>-<HEAD_SHORT>`)来命名文件。
|
|
35
|
-
- 禁止:解释/分析/补充文字
|
|
36
|
-
- 禁止:代码块(```)
|
|
37
|
-
- 禁止:前后空行
|
|
38
|
-
- **失败/异常时**:
|
|
39
|
-
- 若脚本 stdout 已输出合法 JSON(包含 `error` 或其他字段)→ 仍然**原样返回该 JSON**。
|
|
40
|
-
- 若脚本未输出合法 JSON / 退出异常 → 仅输出一行 JSON:`{"error":"PR_PRECHECK_AGENT_FAILED"}`(必要时可加 `detail` 字段)。
|
|
41
|
-
|
|
42
|
-
## GitHub 认证校验(重要)
|
|
43
|
-
|
|
44
|
-
脚本会在执行 `gh pr view/checkout` 之前校验 GitHub CLI 已认证。
|
|
45
|
-
|
|
46
|
-
- 为了避免 `gh auth status` 在“其他 host(例如 enterprise)认证异常”时误判,脚本会优先从 `git remote origin` 推断 host,并使用:
|
|
47
|
-
- `gh auth status --hostname <host>`
|
|
48
|
-
- 推断失败时默认使用 `github.com`。
|
|
49
|
-
|
|
50
|
-
可能出现的错误:
|
|
51
|
-
|
|
52
|
-
- `{"error":"GH_CLI_NOT_FOUND"}`:找不到 `gh` 命令(PATH 内未安装/不可执行)
|
|
53
|
-
- 处理:安装 GitHub CLI:https://cli.github.com/
|
|
54
|
-
- `{"error":"GH_NOT_AUTHENTICATED"}`:当前 repo 的 host 未认证
|
|
55
|
-
- 处理:`gh auth login --hostname <host>`
|
|
56
|
-
|
|
57
|
-
本地排查命令(在同一个 shell 环境运行):
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
git remote get-url origin
|
|
61
|
-
gh auth status
|
|
62
|
-
gh auth status --hostname github.com
|
|
63
|
-
env | grep '^GH_'
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## 仅当出现 merge 冲突时怎么处理
|
|
67
|
-
|
|
68
|
-
当脚本输出 `{"error":"PR_MERGE_CONFLICTS_UNRESOLVED"}` 时:
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
# 1) 获取 base 分支名
|
|
72
|
-
gh pr view <PR_NUMBER> --json baseRefName --jq .baseRefName
|
|
73
|
-
|
|
74
|
-
# 2) 拉取 base 并合并到当前 PR 分支(不 rebase、不 force push)
|
|
75
|
-
git fetch origin <baseRefName>
|
|
76
|
-
git merge --no-ff --no-commit origin/<baseRefName>
|
|
77
|
-
|
|
78
|
-
# 3) 解决冲突后确认无未解决文件
|
|
79
|
-
git diff --name-only --diff-filter=U
|
|
80
|
-
git grep -n '<<<<<<< ' -- .
|
|
81
|
-
|
|
82
|
-
# 4) 提交并推送
|
|
83
|
-
git add -A
|
|
84
|
-
git commit -m "chore(pr #<PR_NUMBER>): resolve merge conflicts"
|
|
85
|
-
git push
|
|
86
|
-
|
|
87
|
-
# 5) 重新运行预检脚本
|
|
88
|
-
python3 ~/.opencode/agents/pr_precheck.py --pr <PR_NUMBER> --round <ROUND>
|
|
89
|
-
```
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: aggregate PR reviews + create fix file
|
|
3
|
-
mode: subagent
|
|
4
|
-
model: openai/gpt-5.3-codex
|
|
5
|
-
temperature: 0.1
|
|
6
|
-
tools:
|
|
7
|
-
bash: true
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# PR Review Aggregator
|
|
11
|
-
|
|
12
|
-
## Cache 约定(强制)
|
|
13
|
-
|
|
14
|
-
- 缓存目录固定为 `./.cache/`;交接一律传 `./.cache/<file>`(repo 相对路径),禁止 basename-only(如 `foo.md`)。
|
|
15
|
-
|
|
16
|
-
## 输入(两种模式)
|
|
17
|
-
|
|
18
|
-
### 模式 A:评审聚合 + 生成 fixFile + 发布评审评论
|
|
19
|
-
|
|
20
|
-
- `PR #<number>`
|
|
21
|
-
- `round: <number>`
|
|
22
|
-
- `runId: <string>`(必须透传,格式 `<PR>-<ROUND>-<HEAD_SHORT>`,禁止自行生成)
|
|
23
|
-
- `contextFile: <path>`(例如:`./.cache/pr-context-...md`)
|
|
24
|
-
- `reviewFile: <path>`(多行,1+ 条;例如:`./.cache/review-...md`)
|
|
25
|
-
|
|
26
|
-
### 模式 B:发布修复评论(基于 fixReportFile)
|
|
27
|
-
|
|
28
|
-
- `PR #<number>`
|
|
29
|
-
- `round: <number>`
|
|
30
|
-
- `runId: <string>`(必须透传,格式 `<PR>-<ROUND>-<HEAD_SHORT>`,禁止自行生成)
|
|
31
|
-
- `fixReportFile: <path>`(例如:`./.cache/fix-report-...md`)
|
|
32
|
-
|
|
33
|
-
示例:
|
|
34
|
-
|
|
35
|
-
```text
|
|
36
|
-
PR #123
|
|
37
|
-
round: 1
|
|
38
|
-
runId: 123-1-a1b2c3d
|
|
39
|
-
contextFile: ./.cache/pr-context-pr123-r1-123-1-a1b2c3d.md
|
|
40
|
-
reviewFile: ./.cache/review-CDX-pr123-r1-123-1-a1b2c3d.md
|
|
41
|
-
reviewFile: ./.cache/review-CLD-pr123-r1-123-1-a1b2c3d.md
|
|
42
|
-
reviewFile: ./.cache/review-GMN-pr123-r1-123-1-a1b2c3d.md
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## 执行方式(强制)
|
|
46
|
-
|
|
47
|
-
所有确定性工作(解析/聚合/发评论/生成 fixFile/输出 JSON)都由 `~/.opencode/agents/pr_review_aggregate.py` 完成。
|
|
48
|
-
|
|
49
|
-
你只做两件事:
|
|
50
|
-
|
|
51
|
-
1) 在模式 A 里用大模型判断哪些 finding 是重复的,并把重复分组作为参数传给脚本(不落盘)。
|
|
52
|
-
2) 调用脚本后,把脚本 stdout 的 JSON **原样返回**给调用者(不做解释/分析)。
|
|
53
|
-
|
|
54
|
-
## 重复分组(仅作为脚本入参)
|
|
55
|
-
|
|
56
|
-
你需要基于所有 `reviewFile` 内容判断重复 finding 分组,生成**一行 JSON**(不要代码块、不要解释文字、不要换行)。
|
|
57
|
-
|
|
58
|
-
注意:这行 JSON **不是你的最终输出**,它只用于生成 `--duplicate-groups-b64` 传给脚本。
|
|
59
|
-
|
|
60
|
-
```json
|
|
61
|
-
{"duplicateGroups":[["CDX-001","CLD-003"],["GMN-002","CLD-005","CDX-004"]]}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## 智能匹配(仅在模式 A + decision-log 存在时)
|
|
65
|
-
|
|
66
|
-
如果 decision-log(`./.cache/decision-log-pr<PR_NUMBER>.md`)存在,你需要基于 LLM 判断每个新 finding 与已决策问题的本质是否相同,从而生成 **escalation_groups** 参数。
|
|
67
|
-
|
|
68
|
-
**匹配原则**:
|
|
69
|
-
- **Essence 匹配**:对比 `essence` 字段与新 finding 的问题本质。
|
|
70
|
-
- **文件强绑定**:仅当 decision-log 条目的 `file` 与新 finding 的 `file` **完全一致**时才进行匹配。
|
|
71
|
-
- 若文件被重命名/删除/拆分,视为不同问题(为了稳定性,不处理复杂的 rename 映射)。
|
|
72
|
-
- 若 decision-log 条目缺少 `file` 字段(旧数据),则跳过匹配(视为不相关)。
|
|
73
|
-
|
|
74
|
-
**流程**:
|
|
75
|
-
|
|
76
|
-
1. 读取 decision-log,提取已 rejected 问题的 `essence` 和 `file` 字段
|
|
77
|
-
2. 逐个新 finding,**先检查 file 是否匹配**
|
|
78
|
-
- 若 file 不匹配 → 视为 New Issue
|
|
79
|
-
- 若 file 匹配 → 继续对比 essence
|
|
80
|
-
3. 若 essence 也匹配("问题本质相同"):
|
|
81
|
-
4. 收集可升级的问题(重新质疑阈值):
|
|
82
|
-
- **升级阈值**:优先级差距 ≥ 2 级
|
|
83
|
-
- 例如:已 rejected P3 but finding 为 P1 → 可升级质疑
|
|
84
|
-
- 例如:已 rejected P2 but finding 为 P0 → 可升级质疑
|
|
85
|
-
- 例如:已 rejected P2 but finding 为 P1 → 不升级(仅差 1 级)
|
|
86
|
-
5. 生成**一行 JSON**(不要代码块、不要解释文字、不要换行),结构如下:
|
|
87
|
-
|
|
88
|
-
```json
|
|
89
|
-
{"escalationGroups":[["CDX-001"],["GMN-002","CLD-005"]]}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
其中每个组表示「可以作为已 rejected 问题的升级质疑」的 finding ID 集合。若无可升级问题,输出空数组:
|
|
93
|
-
|
|
94
|
-
```json
|
|
95
|
-
{"escalationGroups":[]}
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
注意:escalation_groups JSON **不是你的最终输出**,它只用于生成 `--escalation-groups-b64` 传给脚本。
|
|
99
|
-
|
|
100
|
-
## 调用脚本(强制)
|
|
101
|
-
|
|
102
|
-
模式 A(带 reviewFile + 重复分组 + 智能匹配):
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
python3 ~/.opencode/agents/pr_review_aggregate.py \
|
|
106
|
-
--pr <PR_NUMBER> \
|
|
107
|
-
--round <ROUND> \
|
|
108
|
-
--run-id <RUN_ID> \
|
|
109
|
-
--context-file <CONTEXT_FILE> \
|
|
110
|
-
--review-file <REVIEW_FILE_1> \
|
|
111
|
-
--review-file <REVIEW_FILE_2> \
|
|
112
|
-
--review-file <REVIEW_FILE_3> \
|
|
113
|
-
--duplicate-groups-b64 <BASE64_JSON> \
|
|
114
|
-
--decision-log-file ./.cache/decision-log-pr<PR_NUMBER>.md \
|
|
115
|
-
--escalation-groups-b64 <BASE64_JSON>
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
**参数说明**:
|
|
119
|
-
|
|
120
|
-
- `--duplicate-groups-b64`:base64 编码的 JSON,格式同上,例如 `eyJkdXBsaWNhdGVHcm91cHMiOltbIkNEWC0wMDEiLCJDTEQtMDAzIl1dfQ==`
|
|
121
|
-
- `--decision-log-file`:decision-log 文件路径(可选;若不存在则跳过智能匹配逻辑)
|
|
122
|
-
- `--escalation-groups-b64`:base64 编码的 escalation groups JSON,格式如上,例如 `eyJlc2NhbGF0aW9uR3JvdXBzIjpbWyJDRFgtMDAxIl1dfQ==`
|
|
123
|
-
|
|
124
|
-
模式 B(带 fixReportFile):
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
python3 ~/.opencode/agents/pr_review_aggregate.py \
|
|
128
|
-
--pr <PR_NUMBER> \
|
|
129
|
-
--round <ROUND> \
|
|
130
|
-
--run-id <RUN_ID> \
|
|
131
|
-
--fix-report-file <FIX_REPORT_FILE>
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## 脚本输出处理(强制)
|
|
135
|
-
|
|
136
|
-
- 脚本 stdout 只会输出**单一一行 JSON**(可 `JSON.parse()`)。
|
|
137
|
-
- **成功时**:你的最终输出必须是**脚本 stdout 的那一行 JSON 原样内容**。
|
|
138
|
-
- 典型返回:`{"stop":true}` 或 `{"stop":false,"fixFile":"..."}` 或 `{"ok":true}`
|
|
139
|
-
- 禁止:解释/分析/补充文字
|
|
140
|
-
- 禁止:代码块(```)
|
|
141
|
-
- 禁止:前后空行
|
|
142
|
-
- **失败/异常时**:
|
|
143
|
-
- 若脚本 stdout 已输出合法 JSON(包含 `error` 或其他字段)→ 仍然**原样返回该 JSON**。
|
|
144
|
-
- 若脚本未输出合法 JSON / 退出异常 → 仅返回一行 JSON:`{"error":"PR_REVIEW_AGGREGATE_AGENT_FAILED"}`(必要时可加 `detail` 字段)。
|
|
145
|
-
|
|
146
|
-
## fixFile 结构(补充说明)
|
|
147
|
-
|
|
148
|
-
脚本在模式 A 下生成的 fixFile 分为两段:
|
|
149
|
-
|
|
150
|
-
- `## IssuesToFix`:只包含 P0/P1(必须修)
|
|
151
|
-
- `## OptionalIssues`:包含 P2/P3(由 pr-fix 自主决定是否修复/或拒绝并说明原因)
|