Skip to content

Commit 11d7499

Browse files
committed
feat: extend autoreview fallback reviewers
1 parent ad55d48 commit 11d7499

2 files changed

Lines changed: 81 additions & 14 deletions

File tree

‎.agents/skills/autoreview/SKILL.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ description: "Autoreview closeout: local dirty changes, PR branch vs main, paral
77

88
Run Codex's built-in code review as a closeout check. This is code review (`codex review`), not Guardian `auto_review` approval routing.
99

10+
Codex native review mode performs best and is recommended. Non-Codex reviewers are fallback/second-opinion paths that receive a generated diff prompt, not the full Codex review-mode runtime.
11+
1012
Use when:
1113
- user asks for Codex review / autoreview / second-model review
1214
- after non-trivial code edits, before final/commit/ship
@@ -21,7 +23,7 @@ Use when:
2123
- Prefer small fixes at the right ownership boundary; no refactor unless it clearly improves the bug class.
2224
- Keep going until the selected review path returns no accepted/actionable findings.
2325
- If a review-triggered fix changes code, rerun focused tests and rerun the review helper.
24-
- Default to Codex review. If Codex is unavailable or exits with an error, the helper may fall back to `claude -p`; `pi -p` and `opencode run` are explicit reviewer/fallback options. The helper runs nested Codex review in yolo/full-access mode by default; use `--no-yolo` only when intentionally testing sandbox behavior.
26+
- Default to Codex review. If Codex is unavailable or exits with an error, the helper may fall back to `claude -p`; `pi -p`, `opencode run`, `droid exec`, and `copilot` are explicit reviewer/fallback options. Prefer Codex for final closeout because it uses native review mode; non-Codex reviewers use a Codex-inspired generated diff prompt. The helper runs nested Codex review in yolo/full-access mode by default; use `--no-yolo` only when intentionally testing sandbox behavior.
2527
- Stop as soon as the review command/helper exits 0 with no accepted/actionable findings. Do not run an extra direct `codex review` just to get a nicer "clean" line, a second opinion, or clearer closeout wording.
2628
- Treat the helper's successful exit plus absence of actionable findings as the clean review result, even if the underlying Codex CLI output is terse.
2729
- If rejecting a finding as intentional/not worth fixing, add a brief inline code comment only when it explains a real invariant or ownership decision that future reviewers should know.
@@ -107,8 +109,8 @@ The helper:
107109
- otherwise uses `origin/main` for non-main branches
108110
- use `--mode commit --commit <ref>` for already-committed work, especially clean `main` after landing
109111
- should be left in `--mode auto` or forced to `--mode branch` for PR/branch work; do not force `--mode local` after committing
110-
- supports `--reviewer codex|claude|pi|opencode|auto`; `auto` runs Codex first
111-
- supports `--fallback-reviewer claude|pi|opencode|none`; default is `claude`
112+
- supports `--reviewer codex|claude|pi|opencode|droid|copilot|auto`; `auto` runs Codex first
113+
- supports `--fallback-reviewer claude|pi|opencode|droid|copilot|none`; default is `claude`
112114
- falls back only when Codex is unavailable or exits nonzero, not when Codex reports findings
113115
- writes only to stdout unless `--output` or `AUTOREVIEW_OUTPUT` is set
114116
- supports `--dry-run`, `--parallel-tests`, and commit refs

‎.agents/skills/autoreview/scripts/autoreview‎

Lines changed: 76 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ Options:
1010
Target selection. Default: auto.
1111
--base REF Base ref for branch review. Default: PR base or origin/main.
1212
--commit REF Commit ref for commit review. Default: HEAD.
13-
--reviewer codex|claude|pi|opencode|auto
13+
--reviewer codex|claude|pi|opencode|droid|copilot|auto
1414
Review engine. Default: auto (Codex, fallback reviewer on error).
15-
--fallback-reviewer claude|pi|opencode|none
15+
--fallback-reviewer claude|pi|opencode|droid|copilot|none
1616
Fallback when Codex is unavailable or exits nonzero. Default: claude.
1717
--codex-bin PATH Codex binary. Default: codex.
1818
--claude-bin PATH Claude binary. Default: claude.
1919
--pi-bin PATH Pi binary. Default: pi.
2020
--opencode-bin PATH OpenCode binary. Default: opencode.
21+
--droid-bin PATH Droid binary. Default: droid.
22+
--copilot-bin PATH GitHub Copilot binary. Default: copilot.
2123
--full-access Keep yolo/full-access mode enabled. Default.
2224
--no-yolo Run nested Codex review with normal sandbox/approval prompts.
2325
--output FILE Also save output to file.
@@ -42,6 +44,8 @@ codex_bin=${CODEX_BIN:-codex}
4244
claude_bin=${CLAUDE_BIN:-claude}
4345
pi_bin=${PI_BIN:-pi}
4446
opencode_bin=${OPENCODE_BIN:-opencode}
47+
droid_bin=${DROID_BIN:-droid}
48+
copilot_bin=${COPILOT_BIN:-copilot}
4549
codex_args=()
4650
yolo=${AUTOREVIEW_YOLO:-${CODEX_REVIEW_YOLO:-1}}
4751
output=${AUTOREVIEW_OUTPUT:-${CODEX_REVIEW_OUTPUT:-}}
@@ -86,6 +90,14 @@ while [[ $# -gt 0 ]]; do
8690
opencode_bin=${2:-}
8791
shift 2
8892
;;
93+
--droid-bin)
94+
droid_bin=${2:-}
95+
shift 2
96+
;;
97+
--copilot-bin)
98+
copilot_bin=${2:-}
99+
shift 2
100+
;;
89101
--full-access)
90102
yolo=1
91103
shift
@@ -131,15 +143,15 @@ case "$mode" in
131143
esac
132144

133145
case "$reviewer" in
134-
auto|codex|claude|pi|opencode) ;;
146+
auto|codex|claude|pi|opencode|droid|copilot) ;;
135147
*)
136148
echo "invalid --reviewer: $reviewer" >&2
137149
exit 2
138150
;;
139151
esac
140152

141153
case "$fallback_reviewer" in
142-
claude|pi|opencode|none) ;;
154+
claude|pi|opencode|droid|copilot|none) ;;
143155
*)
144156
echo "invalid --fallback-reviewer: $fallback_reviewer" >&2
145157
exit 2
@@ -198,6 +210,15 @@ printf 'reviewer: %s\n' "$reviewer"
198210
if [[ "$reviewer" == auto ]]; then
199211
printf 'fallback-reviewer: %s\n' "$fallback_reviewer"
200212
fi
213+
case "$reviewer" in
214+
codex) ;;
215+
auto)
216+
printf 'note: Codex native review mode is the recommended and best-supported review path; fallback reviewers use a generated diff prompt.\n'
217+
;;
218+
*)
219+
printf 'note: Codex native review mode is the recommended and best-supported review path; %s uses a generated diff prompt.\n' "$reviewer"
220+
;;
221+
esac
201222
if [[ "$reviewer" == auto || "$reviewer" == codex ]]; then
202223
printf 'review:'
203224
printf ' %q' "${review_cmd[@]}"
@@ -284,10 +305,14 @@ Base: ${base_ref:-}
284305
Commit: ${commit_ref:-}
285306
286307
Rules:
287-
- Review only the diff below.
308+
- Review the proposed code change as a closeout reviewer.
309+
- Focus on the diff below. If your CLI exposes read-only repository tools, inspect surrounding code and tests to verify findings; never modify files.
288310
- Do not modify files.
289-
- Prioritize correctness bugs, regressions, security issues, and missing tests.
290-
- Ignore speculative edge cases and broad rewrites.
311+
- Report only discrete, actionable issues introduced by this change.
312+
- Prioritize correctness, regressions, security, data loss, performance cliffs, and missing tests that would catch a real bug.
313+
- Do not report pre-existing issues, speculative risks, broad rewrites, style nits, changelog gaps, or findings that depend on unstated assumptions.
314+
- Identify the concrete scenario where the issue appears, and keep the line reference as small as possible.
315+
- A finding should overlap changed code or clearly cite changed code as the cause.
291316
- For each accepted/actionable finding, use exactly this format:
292317
[P<0-3>] Short title
293318
File: path:line
@@ -302,8 +327,15 @@ EOF
302327
} > "$prompt_file" || return
303328
}
304329

330+
reviewer_output_has_clean_marker() {
331+
local path=$1
332+
grep -Eq '^[^[:alnum:]]*autoreview clean: no accepted/actionable findings reported[[:space:]]*$' "$path"
333+
}
334+
305335
run_prompt_reviewer() {
306336
local selected=$1
337+
local copilot_prompt=
338+
local prompt_bytes=0
307339
local reviewer_output
308340
local status=0
309341

@@ -343,13 +375,46 @@ run_prompt_reviewer() {
343375
echo "fallback reviewer unavailable: $opencode_bin" >&2
344376
status=127
345377
elif printf 'fallback: opencode run\n' | tee -a "$review_output"; then
346-
"$opencode_bin" run --pure --dir "$(dirname "$prompt_file")" --file "$prompt_file" \
347-
"Review the attached prompt file. Do not modify files." 2>&1 | tee -a "$review_output" "$reviewer_output"
378+
"$opencode_bin" run --pure --dir "$repo_root" \
379+
"Review the attached prompt file. Do not modify files." \
380+
--file "$prompt_file" 2>&1 | tee -a "$review_output" "$reviewer_output"
348381
status=$?
349382
else
350383
status=$?
351384
fi
352385
;;
386+
droid)
387+
if ! command -v "$droid_bin" >/dev/null 2>&1; then
388+
echo "fallback reviewer unavailable: $droid_bin" >&2
389+
status=127
390+
elif printf 'fallback: droid exec\n' | tee -a "$review_output"; then
391+
"$droid_bin" exec --cwd "$repo_root" -f "$prompt_file" 2>&1 | tee -a "$review_output" "$reviewer_output"
392+
status=$?
393+
else
394+
status=$?
395+
fi
396+
;;
397+
copilot)
398+
if ! command -v "$copilot_bin" >/dev/null 2>&1; then
399+
echo "fallback reviewer unavailable: $copilot_bin" >&2
400+
status=127
401+
elif printf 'fallback: copilot\n' | tee -a "$review_output"; then
402+
prompt_bytes=$(wc -c < "$prompt_file" | tr -d '[:space:]')
403+
if (( prompt_bytes > 120000 )); then
404+
echo "copilot reviewer unavailable: generated prompt is too large for copilot -p; use codex, droid, or another file/stdin-capable reviewer" \
405+
2>&1 | tee -a "$review_output" "$reviewer_output"
406+
status=1
407+
else
408+
copilot_prompt=$(< "$prompt_file")
409+
"$copilot_bin" -C "$repo_root" --available-tools=none --stream off --output-format text --silent \
410+
-p "$copilot_prompt" \
411+
2>&1 | tee -a "$review_output" "$reviewer_output"
412+
status=$?
413+
fi
414+
else
415+
status=$?
416+
fi
417+
;;
353418
*)
354419
echo "unsupported prompt reviewer: $selected" >&2
355420
status=2
@@ -360,7 +425,7 @@ run_prompt_reviewer() {
360425
status=1
361426
elif ! grep -q '[^[:space:]]' "$reviewer_output"; then
362427
status=1
363-
elif ! grep -Fxq 'autoreview clean: no accepted/actionable findings reported' "$reviewer_output"; then
428+
elif ! reviewer_output_has_clean_marker "$reviewer_output"; then
364429
status=1
365430
fi
366431
fi
@@ -380,7 +445,7 @@ run_selected_review() {
380445
fi
381446
run_review
382447
;;
383-
claude|pi|opencode)
448+
claude|pi|opencode|droid|copilot)
384449
run_prompt_reviewer "$selected"
385450
;;
386451
*)

0 commit comments

Comments
 (0)