Skip to content

Commit c7c42b3

Browse files
authored
Integrate E23-T3 pr-review command and doctor workflow
Integrate E23-T3 pr-review command and doctor workflow
2 parents e4ab573 + 1bc79bf commit c7c42b3

File tree

8 files changed

+366
-7
lines changed

8 files changed

+366
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ All notable changes to this project are documented in this file.
7575
- Added `/autoflow`, `/autoflow-status`, `/autoflow-report`, `/autoflow-dry-run`, and `/autoflow-stop` aliases in `opencode.json`.
7676
- Added `instructions/pr_review_rubric.md` defining Epic 23 Task 23.1 deterministic risk categories, severity/confidence scoring, blocker evidence thresholds, and low-noise recommendation mapping for `/pr-review`.
7777
- Added `scripts/pr_review_analyzer.py` implementing Epic 23 Task 23.2 diff parsing, changed-area classification, missing evidence detection, and deterministic rubric-aligned findings/recommendation output for PR risk triage.
78+
- Added `scripts/pr_review_command.py` implementing Epic 23 Task 23.3 `/pr-review` command integration with concise/JSON review output, pre-merge checklist generation, and subsystem doctor diagnostics.
79+
- Added `/pr-review`, `/pr-review-json`, `/pr-review-checklist`, and `/pr-review-doctor` aliases in `opencode.json`.
7880

7981
### Changes
8082
- Documented extension evaluation outcomes and when each tool is the better fit.
@@ -148,6 +150,7 @@ All notable changes to this project are documented in this file.
148150
- Marked Epic 23 as in progress and completed Task 23.1 rubric-definition notes in the roadmap.
149151
- Moved `plan_execution` runtime persistence out of `opencode.json` into `~/.config/opencode/my_opencode/runtime/plan_execution.json` to prevent OpenCode startup failures caused by unrecognized top-level config keys.
150152
- Added selftest coverage for `/pr-review` analyzer missing-evidence and blocker-evidence decision paths, and marked Task 23.2 complete in the roadmap.
153+
- Integrated `pr-review` checks into unified `/doctor`, updated installer self-check/hints for PR review workflows, and marked Task 23.3 complete in the roadmap.
151154

152155
## v0.2.0 - 2026-02-12
153156

IMPLEMENTATION_ROADMAP.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Use this map to avoid overlapping implementations.
5959
| E20 | Execution Budget Guardrails | done | High | E2, E11 | bd-63f | Bound time/tool/token usage for autonomous runs |
6060
| E21 | Bounded Loop Mode Presets | merged | Medium | E22, E28 | TBD | Merged into E22/E28 loop controls |
6161
| E22 | Autoflow Unified Orchestration Command | done | High | E14, E15, E17, E19, E20 | TBD | One command for plan-run-resume-report lifecycle |
62-
| E23 | PR Review Copilot | in_progress | High | E3 | bd-2zt | Pre-PR quality, output, and risk review automation |
62+
| E23 | PR Review Copilot | in_progress | High | E3 | bd-1hc | Pre-PR quality, output, and risk review automation |
6363
| E24 | Release Train Assistant | planned | High | E14, E23 | TBD | Validate, draft, and gate releases reliably |
6464
| E25 | Incident Hotfix Mode | planned | Medium | E20, E22 | TBD | Constrained emergency workflow with strict safety |
6565
| E26 | Repo Health Score and Drift Monitor | planned | Medium | E9, E12, E20 | TBD | Operational visibility and continuous diagnostics |
@@ -824,10 +824,11 @@ Every command-oriented epic must ship all of the following:
824824
- [x] Subtask 23.2.2: Detect missing tests/docs/changelog implications
825825
- [x] Subtask 23.2.3: Produce actionable findings with file-level references
826826
- [x] Notes: Added `scripts/pr_review_analyzer.py` with deterministic unified-diff parsing, changed-area classification, rubric-aligned finding generation, missing evidence detection (`tests`, `README`, `CHANGELOG`), and recommendation mapping (`approve|needs_review|changes_requested|block`) with file-level references and blocker evidence gates.
827-
- [ ] Task 23.3: Command surface and workflow integration
828-
- [ ] Subtask 23.3.1: Add `/pr-review` with concise and JSON modes
829-
- [ ] Subtask 23.3.2: Integrate with pre-merge checklist and doctor output
830-
- [ ] Subtask 23.3.3: Document triage flow for warnings vs blockers
827+
- [x] Task 23.3: Command surface and workflow integration
828+
- [x] Subtask 23.3.1: Add `/pr-review` with concise and JSON modes
829+
- [x] Subtask 23.3.2: Integrate with pre-merge checklist and doctor output
830+
- [x] Subtask 23.3.3: Document triage flow for warnings vs blockers
831+
- [x] Notes: Added `scripts/pr_review_command.py` command surface with concise/JSON output and `checklist`/`doctor` subcommands, wired aliases in `opencode.json`, integrated `pr-review` into unified doctor checks, and documented blocker-vs-warning triage guidance in README.
831832
- [ ] Task 23.4: Verification
832833
- [ ] Subtask 23.4.1: Add tests for risk detection and false positive control
833834
- [ ] Subtask 23.4.2: Add tests for missing-evidence behavior

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,27 @@ python3 ~/.config/opencode/my_opencode/scripts/pr_review_analyzer.py analyze --b
234234
python3 ~/.config/opencode/my_opencode/scripts/pr_review_analyzer.py analyze --diff-file /tmp/pr.diff --json
235235
```
236236

237+
Task 23.3 command integration:
238+
239+
- command module: `scripts/pr_review_command.py`
240+
- command surface: `/pr-review`, `/pr-review-json`, `/pr-review-checklist`, `/pr-review-doctor`
241+
- doctor integration: unified `/doctor run --json` includes `pr-review` subsystem readiness
242+
243+
Warning vs blocker triage flow:
244+
245+
- `block`: at least one `S3` finding with `C2+` confidence and hard evidence; do not merge until fixed.
246+
- `changes_requested`: repeated `S2` findings with concrete remediation and missing evidence.
247+
- `needs_review`: medium-risk findings or uncertain evidence requiring reviewer attention.
248+
- `approve`: no meaningful risk findings beyond informational noise.
249+
250+
Examples:
251+
252+
```text
253+
/pr-review --base main --head HEAD --json
254+
/pr-review checklist --base main --head HEAD --json
255+
/pr-review doctor --json
256+
```
257+
237258
## Installed plugin stack 🔌
238259

239260
- `@mohak34/opencode-notifier@latest` - desktop and sound alerts for completion, errors, and permission prompts.

install.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ fi
9090
if [ -f "$INSTALL_DIR/scripts/autoflow_command.py" ]; then
9191
chmod +x "$INSTALL_DIR/scripts/autoflow_command.py"
9292
fi
93+
if [ -f "$INSTALL_DIR/scripts/pr_review_analyzer.py" ]; then
94+
chmod +x "$INSTALL_DIR/scripts/pr_review_analyzer.py"
95+
fi
96+
if [ -f "$INSTALL_DIR/scripts/pr_review_command.py" ]; then
97+
chmod +x "$INSTALL_DIR/scripts/pr_review_command.py"
98+
fi
9399
ln -sfn "$INSTALL_DIR/opencode.json" "$CONFIG_PATH"
94100

95101
if [ "$RUN_WIZARD" = true ]; then
@@ -141,12 +147,13 @@ if [ "$SKIP_SELF_CHECK" = false ]; then
141147
fi
142148
if [ -f "$INSTALL_DIR/scripts/resume_command.py" ]; then
143149
python3 "$INSTALL_DIR/scripts/resume_command.py" status --json || true
144-
python3 -c "import json,pathlib; p=pathlib.Path('$CONFIG_PATH'); data=json.loads(p.read_text(encoding='utf-8')); pe=data.get('plan_execution', {}); steps=pe.get('steps', []); pe['status']='failed'; pe['resume']={'enabled': True, 'attempt_count': 0, 'max_attempts': 3, 'trail': []};
150+
RUNTIME_PATH="$HOME/.config/opencode/my_opencode/runtime/plan_execution.json"
151+
python3 -c "import json,pathlib; p=pathlib.Path('$RUNTIME_PATH'); data=json.loads(p.read_text(encoding='utf-8')) if p.exists() else {}; steps=data.get('steps', []); data['status']='failed'; data['resume']={'enabled': True, 'attempt_count': 0, 'max_attempts': 3, 'trail': []};
145152
if isinstance(steps, list) and len(steps) >= 2:
146153
steps[0]['state']='done';
147154
steps[1]['state']='pending';
148155
steps[1]['idempotent']=False;
149-
data['plan_execution']=pe; p.write_text(json.dumps(data, indent=2)+'\n', encoding='utf-8')"
156+
p.parent.mkdir(parents=True, exist_ok=True); p.write_text(json.dumps(data, indent=2)+'\n', encoding='utf-8')"
150157
python3 "$INSTALL_DIR/scripts/resume_command.py" now --interruption-class tool_failure --json || true
151158
python3 "$INSTALL_DIR/scripts/resume_command.py" now --interruption-class tool_failure --approve-step 2 --json
152159
fi
@@ -174,6 +181,13 @@ data['plan_execution']=pe; p.write_text(json.dumps(data, indent=2)+'\n', encodin
174181
python3 "$INSTALL_DIR/scripts/autoflow_command.py" stop --reason install-self-check --json
175182
python3 "$INSTALL_DIR/scripts/start_work_command.py" "$SELF_CHECK_PLAN" --deviation "install self-check" --json
176183
fi
184+
if [ -f "$INSTALL_DIR/scripts/pr_review_command.py" ]; then
185+
SELF_CHECK_DIFF="$HOME/.config/opencode/my_opencode/.install-selfcheck-pr.diff"
186+
python3 -c "from pathlib import Path; Path('$SELF_CHECK_DIFF').write_text('diff --git a/scripts/install_selfcheck.py b/scripts/install_selfcheck.py\nindex 0000000..1111111 100644\n--- a/scripts/install_selfcheck.py\n+++ b/scripts/install_selfcheck.py\n@@ -0,0 +1,1 @@\n+print(\"install\")\n', encoding='utf-8')"
187+
python3 "$INSTALL_DIR/scripts/pr_review_command.py" --diff-file "$SELF_CHECK_DIFF" --json
188+
python3 "$INSTALL_DIR/scripts/pr_review_command.py" checklist --diff-file "$SELF_CHECK_DIFF" --json
189+
python3 "$INSTALL_DIR/scripts/pr_review_command.py" doctor --json
190+
fi
177191
python3 "$INSTALL_DIR/scripts/nvim_integration_command.py" status
178192
python3 "$INSTALL_DIR/scripts/devtools_command.py" status
179193
python3 "$INSTALL_DIR/scripts/doctor_command.py" run || true
@@ -245,6 +259,9 @@ printf " /autoflow dry-run ~/.config/opencode/my_opencode/plan.md --json\n"
245259
printf " /autoflow status --json\n"
246260
printf " /autoflow report --json\n"
247261
printf " /autoflow stop --reason manual --json\n"
262+
printf " /pr-review --base main --head HEAD --json\n"
263+
printf " /pr-review-checklist --base main --head HEAD\n"
264+
printf " /pr-review-doctor\n"
248265
printf " /todo status --json\n"
249266
printf " /todo enforce --json\n"
250267
printf " /resume status --json\n"

opencode.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,22 @@
310310
"description": "Trigger /autoflow kill-switch stop in JSON",
311311
"template": "!`python3 \"$HOME/.config/opencode/my_opencode/scripts/autoflow_command.py\" stop $ARGUMENTS --json`\nShow only the command output."
312312
},
313+
"pr-review": {
314+
"description": "Run PR review copilot analysis with checklist output",
315+
"template": "!`python3 \"$HOME/.config/opencode/my_opencode/scripts/pr_review_command.py\" $ARGUMENTS`\nShow only the command output."
316+
},
317+
"pr-review-json": {
318+
"description": "Run PR review analysis in JSON mode",
319+
"template": "!`python3 \"$HOME/.config/opencode/my_opencode/scripts/pr_review_command.py\" $ARGUMENTS --json`\nShow only the command output."
320+
},
321+
"pr-review-checklist": {
322+
"description": "Show pre-merge checklist for current review range",
323+
"template": "!`python3 \"$HOME/.config/opencode/my_opencode/scripts/pr_review_command.py\" checklist $ARGUMENTS --json`\nShow only the command output."
324+
},
325+
"pr-review-doctor": {
326+
"description": "Run PR review subsystem diagnostics in JSON",
327+
"template": "!`python3 \"$HOME/.config/opencode/my_opencode/scripts/pr_review_command.py\" doctor --json`\nShow only the command output."
328+
},
313329
"budget": {
314330
"description": "Manage execution budget controls (status|profile|override|doctor)",
315331
"template": "!`python3 \"$HOME/.config/opencode/my_opencode/scripts/budget_command.py\" $ARGUMENTS`\nShow only the command output."

scripts/doctor_command.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,18 @@ def script_path(name: str) -> Path:
204204
"--json",
205205
],
206206
},
207+
{
208+
"name": "pr-review",
209+
"kind": "doctor-json",
210+
"optional": True,
211+
"required_path": str(script_path("pr_review_command.py")),
212+
"command": [
213+
sys.executable,
214+
str(script_path("pr_review_command.py")),
215+
"doctor",
216+
"--json",
217+
],
218+
},
207219
{
208220
"name": "budget",
209221
"kind": "doctor-json",

0 commit comments

Comments
 (0)