Skip to content

Commit 142ca97

Browse files
committed
chore: build DIFF as argv array so scoped pathspecs survive (unix-friendly paths)
Addresses Codex PR review (P2): storing the diff in a scalar and running `$DIFF` unquoted let the shell word-split/glob $SCOPE, so a pathspec with spaces or glob chars ('docs/notes with spaces') broke or reviewed the wrong files. DIFF is now an argv array (`DIFF=(git diff "$BASE...HEAD")`, append `-- "$SCOPE"` when set). Run via `"${DIFF[@]}"`; embed in subprocess prompts via a shell-quoted `DIFF_STR=$(printf '%q ' "${DIFF[@]}")`. Verified the pathspec stays a single intact argument in both bash and zsh. Signed-off-by: phernandez <paul@basicmachines.co>
1 parent cf451b5 commit 142ca97

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

  • .agents/skills/adversarial-review

.agents/skills/adversarial-review/SKILL.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,20 @@ Two independent, optional inputs:
3939
- `SCOPE` — a pathspec to narrow the review (e.g. `src/basic_memory`). Default: none (whole diff).
4040

4141
These are separate: a ref and a pathspec are not interchangeable. Build the **canonical diff
42-
command** once in preflight and reuse it everywhere below as `$DIFF` — never re-spell the diff
43-
inline (the scattered, inconsistent spelling is what broke earlier):
42+
command** once in preflight and reuse it everywhere below — never re-spell the diff inline
43+
(the scattered, inconsistent spelling is what broke earlier). Build it as an **argv array**,
44+
not a string, so a `$SCOPE` containing spaces or glob characters survives intact:
4445

4546
```bash
4647
BASE="${BASE:-main}"
47-
DIFF="git diff $BASE...HEAD"
48-
[ -n "$SCOPE" ] && DIFF="$DIFF -- $SCOPE"
48+
DIFF=(git diff "$BASE...HEAD") # argv array — never a scalar string
49+
[ -n "$SCOPE" ] && DIFF+=(-- "$SCOPE") # pathspec stays one argument even with spaces
50+
DIFF_STR=$(printf '%q ' "${DIFF[@]}") # shell-quoted rendering, for embedding in a prompt
4951
```
5052

53+
To **run** it, use `"${DIFF[@]}"` (quoted, no word-splitting). To **embed** it as text inside
54+
a subprocess prompt, use `$DIFF_STR`.
55+
5156
## Preflight
5257

5358
0. Set `SKILL_DIR` to the directory this SKILL.md lives in. Canonical location is
@@ -57,8 +62,8 @@ DIFF="git diff $BASE...HEAD"
5762
1. Confirm the *other* model's CLI is on PATH (`codex` if you're Claude, `claude` if you're
5863
Codex). If it's missing, tell the user the panel falls back to single-model (which loses
5964
the cross-vendor benefit) and ask whether to proceed or stop.
60-
2. Run `$DIFF`. If it prints nothing, report "nothing to review against $BASE" (mention
61-
`$SCOPE` if set) and stop.
65+
2. Run `"${DIFF[@]}"`. If it prints nothing, report "nothing to review against $BASE"
66+
(mention `$SCOPE` if set) and stop.
6267
3. `RUN=$(mktemp -d)` — scratch dir for the other model's output. Transient, never committed.
6368
No persisted artifacts, no state file.
6469

@@ -75,7 +80,7 @@ model findings):
7580
## Phase 1 — Independent review (you + the other model, concurrently)
7681

7782
Both reviewers get the same brief: `prompts/review.md` + the repo's `CLAUDE.md` house rules,
78-
reviewing `$DIFF`. Both emit findings matching `schemas/findings.schema.json`.
83+
reviewing the diff from `"${DIFF[@]}"`. Both emit findings matching `schemas/findings.schema.json`.
7984

8085
**Your native pass:** review as yourself, following `prompts/review.md`. Hold your findings
8186
as that JSON shape.
@@ -92,13 +97,13 @@ codex exec -s read-only \
9297
-o "$RUN/other_findings.json" \
9398
"$(cat "$SKILL_DIR/prompts/review.md")
9499
95-
Review the diff: $DIFF" </dev/null
100+
Review the diff: $DIFF_STR" </dev/null
96101

97102
# You are Codex → run Claude (read-only via plan mode; parse the JSON block it returns):
98103
claude -p --permission-mode plan --output-format json \
99104
"$(cat "$SKILL_DIR/prompts/review.md")
100105
101-
Review the diff: $DIFF
106+
Review the diff: $DIFF_STR
102107
Return ONLY a JSON object matching this schema:
103108
$(cat "$SKILL_DIR/schemas/findings.schema.json")" </dev/null > "$RUN/other_raw.json"
104109
# claude --output-format json output shape varies by CLI version: it may be a JSON ARRAY
@@ -122,8 +127,8 @@ Each model tries to refute the *other's* findings, per `prompts/refute.md`
122127

123128
- **You** refute the other model's findings natively.
124129
- **The other model** refutes *your* findings — invoke it again the same way (swap
125-
`prompts/review.md` for `prompts/refute.md`, append your findings JSON **and the `$DIFF`
126-
command** so it judges against the right base and scope, and for Codex use
130+
`prompts/review.md` for `prompts/refute.md`, append your findings JSON **and `$DIFF_STR`**
131+
so it judges against the right base and scope, and for Codex use
127132
`--output-schema schemas/verdicts.schema.json`).
128133

129134
Match verdicts to findings by `id`.

0 commit comments

Comments
 (0)