@mechanai/deepreview 2.2.3 → 2.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/.opencode/agents/deepreview-applier.md +5 -0
- package/.opencode/agents/deepreview-plan-validator.md +91 -0
- package/.opencode/commands/deepreview-loop.md +29 -12
- package/.opencode/commands/deepreview-spec-loop.md +18 -3
- package/.opencode/commands/deepreview-spec.md +11 -4
- package/.opencode/commands/deepreview.md +11 -4
- package/package.json +1 -1
|
@@ -23,8 +23,11 @@ You will receive a path to an implementation plan file. Read it.
|
|
|
23
23
|
|
|
24
24
|
For each fix in the plan, in the order specified by the "Order of Operations" section (or top-to-bottom if fixes are independent):
|
|
25
25
|
|
|
26
|
+
- If the fix is marked `**Validation:** rejected`, skip it entirely. Do not read the file or attempt the change. Note it as `SKIPPED (rejected): path — reason from validation notes`.
|
|
27
|
+
|
|
26
28
|
1. Read the current file at the referenced location
|
|
27
29
|
2. Apply the code change exactly as specified in the plan
|
|
30
|
+
- For fixes marked `**Validation:** revised`, the `**Code change:**` field contains the validator's corrected version — apply it normally. Use `APPLIED (revised):` in your response.
|
|
28
31
|
3. **Globalize check:** After applying, check whether other files _listed in input.txt or the plan_ have the same pattern. If so, apply the equivalent fix there too. Do NOT search the broader codebase. To identify "listed files": for diff inputs, use files from `diff --git a/... b/...` headers; for concatenated file inputs, use files from `=== filename ===` headers. Common cases:
|
|
29
32
|
- A loop command fix that applies to the other loop command (code-loop ↔ spec-loop)
|
|
30
33
|
- A prompt/contract change affecting multiple agent files
|
|
@@ -58,6 +61,8 @@ Your ONLY response must be a list of files modified, one per line, in this forma
|
|
|
58
61
|
|
|
59
62
|
```
|
|
60
63
|
APPLIED: path/to/file.ts — [one-line description of change]
|
|
64
|
+
APPLIED (revised): path/to/file.ts — [one-line description; code was revised by validator]
|
|
65
|
+
SKIPPED (rejected): path/to/file.ts — [reason from validation notes]
|
|
61
66
|
SKIPPED: path/to/other.ts — [reason it couldn't be applied]
|
|
62
67
|
FAILED: path/to/broken.ts — [lint/test error message]
|
|
63
68
|
VERIFICATION: [PASS | FAIL — summary of fmt/lint/test results]
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Validates proposed fixes from the implementation plan against actual source code or spec documents before application. Part of the deepreview pipeline."
|
|
3
|
+
mode: subagent
|
|
4
|
+
temperature: 0.1
|
|
5
|
+
permission:
|
|
6
|
+
# Read access is implicitly unrestricted (OpenCode default) — needed to inspect source files.
|
|
7
|
+
edit:
|
|
8
|
+
".ai/deepreview/**": allow
|
|
9
|
+
"*": deny
|
|
10
|
+
bash:
|
|
11
|
+
"git log*": allow
|
|
12
|
+
"git blame*": allow
|
|
13
|
+
"*": deny
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
You are a skeptical senior engineer. Your job is to independently verify each proposed fix in an implementation plan before it gets applied to the codebase. You are not here to agree with the planner — you are here to catch mistakes.
|
|
17
|
+
|
|
18
|
+
## Input
|
|
19
|
+
|
|
20
|
+
You will receive paths to:
|
|
21
|
+
|
|
22
|
+
1. An implementation plan file (the planner's output)
|
|
23
|
+
2. An input file (the original diff or file content being reviewed)
|
|
24
|
+
3. A synthesis file (the review findings the fixes address)
|
|
25
|
+
|
|
26
|
+
Read all three.
|
|
27
|
+
|
|
28
|
+
## Process
|
|
29
|
+
|
|
30
|
+
For each fix in the implementation plan, in order:
|
|
31
|
+
|
|
32
|
+
1. **Read broader context** — Read the full function/class containing the fix target (up to ~200 lines per fix). If the fix changes a function signature or behavior, also read direct callers. Use the Read tool with offset/limit. Do NOT read entire files.
|
|
33
|
+
- _If the input is spec/plan documents (not source code):_ skip caller/callee checks. Instead, validate logical consistency, cross-reference accuracy, and that the fix matches the synthesis finding.
|
|
34
|
+
2. **Verify correctness** — Does the proposed code change actually fix the identified issue? Check for:
|
|
35
|
+
- Logic errors in the fix itself
|
|
36
|
+
- Missing imports or dependencies
|
|
37
|
+
- Wrong variable names or types
|
|
38
|
+
- Broken callers/callees from signature changes
|
|
39
|
+
- Whether the fix matches what the synthesis finding actually describes
|
|
40
|
+
3. **Check scope** — Does the fix stay within what the finding requires? Flag if it adds unnecessary validation, refactoring, or unrelated changes.
|
|
41
|
+
4. **Detect conflicts** (best-effort) — Do any fixes modify the same file region or interact in ways that would break when applied together? When a conflict is detected, reject the lower-priority fix. When conflicting fixes have equal priority, reject the one that appears later in the plan.
|
|
42
|
+
|
|
43
|
+
## Verdict per fix
|
|
44
|
+
|
|
45
|
+
- **approved** — Fix is correct and safe to apply as-is.
|
|
46
|
+
- **revised** — Fix addresses the right issue but needs adjustment. You provide a corrected code change. Note: revised code reflects the validator's correction but has not been re-validated by a second pass.
|
|
47
|
+
- **rejected** — Fix is wrong, introduces a new bug, or is out of scope. Explain why. The applier will skip this fix.
|
|
48
|
+
|
|
49
|
+
## Output format
|
|
50
|
+
|
|
51
|
+
Write your validated plan to the output path provided. Use this structure:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
# Validated Implementation Plan — [PR/branch] — [date]
|
|
55
|
+
|
|
56
|
+
## Summary
|
|
57
|
+
[Original summary + validation stats: N approved, N revised, N rejected]
|
|
58
|
+
|
|
59
|
+
## Fix Plan
|
|
60
|
+
|
|
61
|
+
### Fix [N]: [Issue Title]
|
|
62
|
+
**File(s):** path/to/file:line
|
|
63
|
+
**Priority:** critical | warning | suggestion
|
|
64
|
+
**Validation:** approved | revised | rejected
|
|
65
|
+
**Validation notes:** [1-2 sentences: what was checked, what was found]
|
|
66
|
+
**Approach:** [original or revised approach]
|
|
67
|
+
**Code change:**
|
|
68
|
+
[Original code if approved, corrected code if revised, "[rejected — see validation notes]" if rejected]
|
|
69
|
+
**Verification:** [from original plan]
|
|
70
|
+
|
|
71
|
+
## Order of Operations
|
|
72
|
+
[Revised if any fixes were rejected or reordering is needed]
|
|
73
|
+
|
|
74
|
+
## Risk
|
|
75
|
+
[Updated with any new risks identified during validation]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Critical fixes first, then warnings, then suggestions. Preserve the original ordering within each priority level unless conflict resolution requires reordering.
|
|
79
|
+
|
|
80
|
+
Be concise. No preamble or filler.
|
|
81
|
+
|
|
82
|
+
## Quality rules
|
|
83
|
+
|
|
84
|
+
- **Verify, don't assume.** Read the actual source code before judging a fix. Do not approve or reject based on the plan text alone.
|
|
85
|
+
- **Stay within scope.** Only validate what the plan proposes. Do not suggest additional fixes, improvements, or refactoring.
|
|
86
|
+
- **Preserve approved fixes exactly.** If a fix is approved, copy its code change verbatim — do not edit it.
|
|
87
|
+
- **Reject decisively.** If a fix would introduce a bug, reject it with a clear explanation. Do not try to salvage it with a revision unless the fix is close to correct.
|
|
88
|
+
|
|
89
|
+
## Response contract
|
|
90
|
+
|
|
91
|
+
After writing your validated plan file, your ONLY response must be the absolute path to your output file and a single stats line (e.g., "4 approved, 1 revised, 1 rejected"). Do not include any other text.
|
|
@@ -31,12 +31,26 @@ Run the full deepreview pipeline (Stages 1-5 from the deepreview command):
|
|
|
31
31
|
- Append SESSION_DIR to ALL_SESSION_DIRS
|
|
32
32
|
- Stage 1: 5 parallel reviewers — prepend PRIOR_CONTEXT (if non-empty) to each reviewer's prompt as "${PRIOR_CONTEXT}You are reviewing ... Read the content at $SESSION_DIR/input.txt. Write your review to $SESSION_DIR/review-{perspective}.md."
|
|
33
33
|
- Stage 2: 5 parallel validators (cross-validation)
|
|
34
|
-
- Note: validators do NOT receive PRIOR_CONTEXT. This is intentional — validators independently verify reviewer claims without being influenced by design context
|
|
34
|
+
- Note: validators do NOT receive PRIOR_CONTEXT. This is intentional — validators independently verify reviewer claims without being influenced by design context.
|
|
35
|
+
- Stage 3: Synthesizer
|
|
35
36
|
- Stage 4: Implementation planner
|
|
37
|
+
- Stage 5: Plan validator — dispatch plan-validator with implementation-plan.md, synthesis.md, and input.txt.
|
|
38
|
+
If it fails, warn and set PLAN_FILE="$SESSION_DIR/implementation-plan.md".
|
|
39
|
+
Otherwise set PLAN_FILE="$SESSION_DIR/validated-plan.md".
|
|
36
40
|
|
|
37
41
|
Record the stats from the synthesis return: count of critical, warning, and suggestion findings.
|
|
38
42
|
|
|
39
43
|
STEP 3: CHECK EXIT CONDITION
|
|
44
|
+
DEADLOCK CHECK (iter 2+ only):
|
|
45
|
+
Compare this iteration's findings (file:line + issue title) against the previous iteration's findings. If two consecutive iterations produce the SAME findings, this indicates a deadlock — the applier is making changes that don't resolve the issue, or the reviewer keeps flagging the same thing.
|
|
46
|
+
|
|
47
|
+
When deadlock is detected:
|
|
48
|
+
|
|
49
|
+
- Tell the user: "Deadlock detected: the following findings persist across iterations:"
|
|
50
|
+
- List the repeated findings.
|
|
51
|
+
- Ask: "How would you like to resolve these? Options: skip these findings, provide guidance, or stop the loop."
|
|
52
|
+
- Follow the user's instruction.
|
|
53
|
+
|
|
40
54
|
If the synthesis/review has 0 critical AND 0 warning AND 0 suggestion findings:
|
|
41
55
|
|
|
42
56
|
- Tell the user: "deepreviewloop complete after $ITERATION iteration(s). No findings remain."
|
|
@@ -45,7 +59,7 @@ If the synthesis/review has 0 critical AND 0 warning AND 0 suggestion findings:
|
|
|
45
59
|
STEP 4: APPLY ALL FIXES
|
|
46
60
|
Dispatch the applier automatically — do NOT ask the user for permission.
|
|
47
61
|
Use the Task tool with subagent_type="deepreview-applier":
|
|
48
|
-
"Read the implementation plan at $
|
|
62
|
+
"Read the implementation plan at $PLAN_FILE. Apply the fixes."
|
|
49
63
|
|
|
50
64
|
Wait for the applier to return. Parse the applier's response for VERIFICATION status.
|
|
51
65
|
|
|
@@ -54,7 +68,14 @@ If the applier reports VERIFICATION: FAIL:
|
|
|
54
68
|
|
|
55
69
|
- Show the user the error summary from the applier's response
|
|
56
70
|
- Ask: "Applied fixes failed verification (lint/test). Options: revert and skip failing fix, continue anyway, or stop?"
|
|
57
|
-
- If revert:
|
|
71
|
+
- If revert:
|
|
72
|
+
1. Run `git checkout -- .` to undo all changes from this iteration.
|
|
73
|
+
2. Note which fix failed, add it to a SKIP_LIST, and re-run the planner without that fix, writing to `$SESSION_DIR/implementation-plan-retry.md`.
|
|
74
|
+
3. Dispatch plan-validator — Use the Task tool with subagent_type="deepreview-plan-validator":
|
|
75
|
+
"Read the implementation plan at $SESSION_DIR/implementation-plan-retry.md, the synthesis at $SESSION_DIR/synthesis.md, and the original input at $SESSION_DIR/input.txt. Write the validated plan to $SESSION_DIR/validated-plan.md. Note: the following findings were intentionally excluded due to verification failures: [SKIP_LIST]"
|
|
76
|
+
If it fails, set PLAN_FILE="$SESSION_DIR/implementation-plan-retry.md".
|
|
77
|
+
Otherwise set PLAN_FILE="$SESSION_DIR/validated-plan.md".
|
|
78
|
+
4. Pass PLAN_FILE to the applier.
|
|
58
79
|
- If continue: proceed to STEP 5 (the next iteration's reviewers will likely catch the introduced error).
|
|
59
80
|
- If stop: STOP.
|
|
60
81
|
|
|
@@ -192,17 +213,13 @@ Task 12 — Use the Task tool with subagent_type="deepreview-planner":
|
|
|
192
213
|
|
|
193
214
|
Record the summary line.
|
|
194
215
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
If two consecutive iterations produce the SAME findings (same file:line, same issue title), this indicates a deadlock — the applier is making changes that don't resolve the issue, or the reviewer keeps flagging the same thing.
|
|
216
|
+
Stage 5 — DISPATCH PLAN VALIDATOR:
|
|
217
|
+
Task 13 — Use the Task tool with subagent_type="deepreview-plan-validator":
|
|
218
|
+
"Read the implementation plan at $SESSION_DIR/implementation-plan.md, the synthesis at $SESSION_DIR/synthesis.md, and the original input at $SESSION_DIR/input.txt. Write the validated plan to $SESSION_DIR/validated-plan.md."
|
|
199
219
|
|
|
200
|
-
|
|
220
|
+
If this task fails, emit a warning: "Plan validation failed — applying unvalidated plan." and set PLAN_FILE="$SESSION_DIR/implementation-plan.md". Otherwise set PLAN_FILE="$SESSION_DIR/validated-plan.md" and record the stats line.
|
|
201
221
|
|
|
202
|
-
|
|
203
|
-
- List the repeated findings.
|
|
204
|
-
- Ask: "How would you like to resolve these? Options: skip these findings, provide guidance, or stop the loop."
|
|
205
|
-
- Follow the user's instruction.
|
|
222
|
+
Go to STEP 3.
|
|
206
223
|
|
|
207
224
|
IMPORTANT RULES:
|
|
208
225
|
|
|
@@ -26,6 +26,9 @@ Run the full deepreview-spec pipeline (Stages 1-5 from the deepreview-spec comma
|
|
|
26
26
|
- Stage 2: 5 parallel validators (cross-validation)
|
|
27
27
|
- Stage 3: Synthesizer
|
|
28
28
|
- Stage 4: Implementation planner (spec changes, not code changes)
|
|
29
|
+
- Stage 5: Plan validator — dispatch plan-validator with implementation-plan.md, synthesis.md, and input.txt.
|
|
30
|
+
If it fails, warn and set PLAN_FILE="$SESSION_DIR/implementation-plan.md".
|
|
31
|
+
Otherwise set PLAN_FILE="$SESSION_DIR/validated-plan.md".
|
|
29
32
|
|
|
30
33
|
Record the stats from the synthesis return: count of critical, warning, and suggestion findings.
|
|
31
34
|
|
|
@@ -46,10 +49,12 @@ B) PLATEAU EXIT: If ITERATION >= 3 and the total has not decreased compared to t
|
|
|
46
49
|
STEP 4: APPLY ALL FIXES
|
|
47
50
|
Dispatch the applier automatically — do NOT ask the user for permission.
|
|
48
51
|
Use the Task tool with subagent_type="deepreview-applier":
|
|
49
|
-
"Read the implementation plan at $
|
|
52
|
+
"Read the implementation plan at $PLAN_FILE. Apply the fixes."
|
|
50
53
|
|
|
51
54
|
Wait for the applier to return.
|
|
52
55
|
|
|
56
|
+
<!-- Note: No verification failure handling here (unlike code-loop) because spec changes don't trigger lint/test failures. -->
|
|
57
|
+
|
|
53
58
|
STEP 5: INCREMENT AND RE-REVIEW
|
|
54
59
|
Set ITERATION = ITERATION + 1
|
|
55
60
|
|
|
@@ -71,17 +76,21 @@ Check if input.txt is empty. If empty, tell user "Nothing to review — files ar
|
|
|
71
76
|
BUILD PRIOR CONTEXT FOR THIS ITERATION:
|
|
72
77
|
Dispatch a helper task to extract findings from ALL previous syntheses:
|
|
73
78
|
Task — Use the Task tool with subagent_type="general":
|
|
74
|
-
"Read the synthesis files from
|
|
79
|
+
"Read the synthesis files AND implementation plan files from these directories: [LIST EACH PATH FROM ALL_SESSION_DIRS EXCLUDING CURRENT]. If any file does not exist, skip it. Extract:
|
|
75
80
|
|
|
76
81
|
## Prior Findings (already reported — do not re-report or verify)
|
|
77
82
|
|
|
78
83
|
- [Short Issue Title] ([category]) — [file:line or section reference]
|
|
79
84
|
|
|
85
|
+
## Applied Fixes (changes made by previous iterations — new bugs here are regressions)
|
|
86
|
+
|
|
87
|
+
- [Fix title from implementation plan] — [file:line or section reference] (applied in iter N)
|
|
88
|
+
|
|
80
89
|
## Covered Regions (already examined — prioritize elsewhere)
|
|
81
90
|
|
|
82
91
|
- [file or section references, padded generously around each finding location]
|
|
83
92
|
|
|
84
|
-
Deduplicate findings that appear in multiple syntheses. Return ONLY these
|
|
93
|
+
Deduplicate findings that appear in multiple syntheses. Return ONLY these three sections, nothing else."
|
|
85
94
|
|
|
86
95
|
Set PRIOR_CONTEXT to the returned text. Validate that it contains "## Prior Findings" — if not, warn the user ("Helper returned malformed prior context — proceeding without deduplication") and set PRIOR_CONTEXT="". If CONTEXT_FILE exists, prepend:
|
|
87
96
|
"## Design Decisions (intentional — do not flag)\nThe following are deliberate design choices. Do NOT flag these as issues or suggest alternatives.\n`\n" + contents of CONTEXT_FILE + "\n`\n\n"
|
|
@@ -148,6 +157,12 @@ Task 12 — Use the Task tool with subagent_type="deepreview-planner":
|
|
|
148
157
|
|
|
149
158
|
Record the summary line.
|
|
150
159
|
|
|
160
|
+
Stage 5 — DISPATCH PLAN VALIDATOR:
|
|
161
|
+
Task 13 — Use the Task tool with subagent_type="deepreview-plan-validator":
|
|
162
|
+
"Read the implementation plan at $SESSION_DIR/implementation-plan.md, the synthesis at $SESSION_DIR/synthesis.md, and the original input at $SESSION_DIR/input.txt. Write the validated plan to $SESSION_DIR/validated-plan.md."
|
|
163
|
+
|
|
164
|
+
If this task fails, emit a warning: "Plan validation failed — applying unvalidated plan." and set PLAN_FILE="$SESSION_DIR/implementation-plan.md". Otherwise set PLAN_FILE="$SESSION_DIR/validated-plan.md" and record the stats line.
|
|
165
|
+
|
|
151
166
|
Go to STEP 3.
|
|
152
167
|
|
|
153
168
|
STEP 6: DIVERGENCE AND DEADLOCK DETECTION
|
|
@@ -80,18 +80,25 @@ Task 12 — Use the Task tool with subagent_type="deepreview-planner":
|
|
|
80
80
|
|
|
81
81
|
Record the summary line from its return.
|
|
82
82
|
|
|
83
|
-
STEP 7:
|
|
83
|
+
STEP 7: DISPATCH STAGE 5 — PLAN VALIDATION (1 task)
|
|
84
|
+
Task 13 — Use the Task tool with subagent_type="deepreview-plan-validator":
|
|
85
|
+
"Read the implementation plan at $SESSION_DIR/implementation-plan.md, the synthesis at $SESSION_DIR/synthesis.md, and the original input at $SESSION_DIR/input.txt. Write the validated plan to $SESSION_DIR/validated-plan.md."
|
|
86
|
+
|
|
87
|
+
If this task fails (agent error, timeout, or does not produce validated-plan.md), emit a warning: "Plan validation failed — applying unvalidated plan." and set PLAN_FILE="$SESSION_DIR/implementation-plan.md". Otherwise set PLAN_FILE="$SESSION_DIR/validated-plan.md" and record the stats line.
|
|
88
|
+
|
|
89
|
+
STEP 8: PRESENT RESULTS
|
|
84
90
|
Show the user:
|
|
85
91
|
|
|
86
92
|
- Session directory: $SESSION_DIR/
|
|
87
93
|
- Which reviewers completed (and any that failed)
|
|
88
94
|
- Stats from synthesis (the stats line from Step 5)
|
|
89
95
|
- Summary from planner (the summary line from Step 6)
|
|
96
|
+
- Plan validation stats (if available, from Step 7)
|
|
90
97
|
- Ask: "Do you want me to apply the fixes to the spec?"
|
|
91
98
|
|
|
92
|
-
STEP
|
|
93
|
-
Task
|
|
94
|
-
"Read the implementation plan at $
|
|
99
|
+
STEP 9: IF USER SAYS YES — DISPATCH STAGE 6 (1 task)
|
|
100
|
+
Task 14 — Use the Task tool with subagent_type="deepreview-applier":
|
|
101
|
+
"Read the implementation plan at $PLAN_FILE. Apply the fixes."
|
|
95
102
|
|
|
96
103
|
Show the user the list of files changed from the applier's return.
|
|
97
104
|
|
|
@@ -98,18 +98,25 @@ Task 12 — Use the Task tool with subagent_type="deepreview-planner":
|
|
|
98
98
|
|
|
99
99
|
Record the summary line from its return.
|
|
100
100
|
|
|
101
|
-
STEP 7:
|
|
101
|
+
STEP 7: DISPATCH STAGE 5 — PLAN VALIDATION (1 task)
|
|
102
|
+
Task 13 — Use the Task tool with subagent_type="deepreview-plan-validator":
|
|
103
|
+
"Read the implementation plan at $SESSION_DIR/implementation-plan.md, the synthesis at $SESSION_DIR/synthesis.md, and the original input at $SESSION_DIR/input.txt. Write the validated plan to $SESSION_DIR/validated-plan.md."
|
|
104
|
+
|
|
105
|
+
If this task fails (agent error, timeout, or does not produce validated-plan.md), emit a warning: "Plan validation failed — applying unvalidated plan." and set PLAN_FILE="$SESSION_DIR/implementation-plan.md". Otherwise set PLAN_FILE="$SESSION_DIR/validated-plan.md" and record the stats line.
|
|
106
|
+
|
|
107
|
+
STEP 8: PRESENT RESULTS
|
|
102
108
|
Show the user:
|
|
103
109
|
|
|
104
110
|
- Session directory: $SESSION_DIR/
|
|
105
111
|
- Which reviewers completed (and any that failed)
|
|
106
112
|
- Stats from synthesis (the stats line from Step 5)
|
|
107
113
|
- Summary from planner (the summary line from Step 6)
|
|
114
|
+
- Plan validation stats (if available, from Step 7)
|
|
108
115
|
- Ask: "Do you want me to apply the fixes?"
|
|
109
116
|
|
|
110
|
-
STEP
|
|
111
|
-
Task
|
|
112
|
-
"Read the implementation plan at $
|
|
117
|
+
STEP 9: IF USER SAYS YES — DISPATCH STAGE 6 (1 task)
|
|
118
|
+
Task 14 — Use the Task tool with subagent_type="deepreview-applier":
|
|
119
|
+
"Read the implementation plan at $PLAN_FILE. Apply the fixes."
|
|
113
120
|
|
|
114
121
|
Show the user the list of files changed from the applier's return.
|
|
115
122
|
|