@iceinvein/agent-skills 0.25.0 → 0.27.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.
Files changed (44) hide show
  1. package/README.md +14 -5
  2. package/dist/cli/index.js +913 -239
  3. package/package.json +2 -1
  4. package/skills/index.json +4 -4
  5. package/skills/magpie/README.md +24 -6
  6. package/skills/magpie/SKILL.md +35 -18
  7. package/skills/magpie/bin/magpie.ts +28 -0
  8. package/skills/magpie/package.json +1 -1
  9. package/skills/magpie/references/critic.md +2 -2
  10. package/skills/magpie/references/peer-review.md +7 -7
  11. package/skills/magpie/references/proof.md +2 -2
  12. package/skills/magpie/scripts/__tests__/peer-run.test.ts +231 -0
  13. package/skills/magpie/scripts/__tests__/preflight.test.ts +22 -1
  14. package/skills/magpie/scripts/__tests__/setup-cmd.test.ts +14 -0
  15. package/skills/magpie/scripts/__tests__/skill-lint.test.ts +45 -4
  16. package/skills/magpie/scripts/peer-run.ts +146 -0
  17. package/skills/magpie/scripts/preflight.ts +20 -20
  18. package/skills/magpie/scripts/setup-cmd.ts +7 -1
  19. package/skills/magpie/skill.json +21 -3
  20. package/skills/sluice/SKILL.md +24 -7
  21. package/skills/sluice/evals/README.md +4 -3
  22. package/skills/sluice/evals/deep-run-mirrors-the-task-list/case.yaml +4 -0
  23. package/skills/sluice/evals/deep-run-mirrors-the-task-list/fixture.sh +304 -0
  24. package/skills/sluice/evals/deep-run-mirrors-the-task-list/graders/every-task-done.md +7 -0
  25. package/skills/sluice/evals/deep-run-mirrors-the-task-list/graders/sluice-fired.md +5 -0
  26. package/skills/sluice/evals/deep-run-mirrors-the-task-list/graders/task-list-completed.md +7 -0
  27. package/skills/sluice/evals/deep-run-mirrors-the-task-list/graders/task-list-created.md +8 -0
  28. package/skills/sluice/evals/deep-run-mirrors-the-task-list/prompt.md +13 -0
  29. package/skills/sluice/evals/rules.json +9 -0
  30. package/skills/sluice/references/deep-channel.md +52 -25
  31. package/skills/sluice/references/finish.md +2 -2
  32. package/skills/sluice/references/intent.md +1 -1
  33. package/skills/sluice/references/status.md +18 -7
  34. package/skills/sluice/references/test-first.md +12 -0
  35. package/skills/sluice/scripts/board-index.sh +59 -37
  36. package/skills/sluice/scripts/board.sh +72 -40
  37. package/skills/sluice/scripts/host.sh +60 -0
  38. package/skills/sluice/scripts/postinstall.sh +3 -3
  39. package/skills/sluice/scripts/run-stats.sh +41 -3
  40. package/skills/sluice/scripts/session-start.sh +75 -17
  41. package/skills/sluice/scripts/status.sh +9 -5
  42. package/skills/sluice/scripts/stop-guard.sh +101 -37
  43. package/skills/sluice/scripts/transcript.sh +221 -0
  44. package/skills/sluice/skill.json +28 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iceinvein/agent-skills",
3
- "version": "0.25.0",
3
+ "version": "0.27.0",
4
4
  "description": "Install agent skills into AI coding tools",
5
5
  "author": "iceinvein",
6
6
  "license": "MIT",
@@ -26,6 +26,7 @@
26
26
  "skill:audit": "bun run scripts/audit-skills.ts",
27
27
  "eval:fresh": "bun run scripts/eval-freshness.ts",
28
28
  "eval:plugins": "bun run scripts/eval-plugins.ts",
29
+ "eval:host": "bun run scripts/eval-host.ts",
29
30
  "release": "bash scripts/release.sh"
30
31
  },
31
32
  "keywords": [
package/skills/index.json CHANGED
@@ -225,9 +225,9 @@
225
225
  },
226
226
  {
227
227
  "name": "magpie",
228
- "description": "Interactive PR review pipeline. Runs five parallel specialist subagents (security, bugs, performance, code-smells, architecture) plus a once-per-PR checks pass that finds tests and controls able to pass without proving their purpose, drops findings whose quoted evidence is not in the code, dedupes, runs critic subagents that re-check each finding against the worktree and set its risk label, peer-reviews via codex exec (falling back to a Claude second opinion when codex is unavailable), and serves an interactive HTML report for selecting or dismissing findings to post via gh, recording the outcome per finding as labels. Bundles a Bun CLI put on PATH by the skill's postinstall step under a bunx install, or by the plugin's bin/ under a Claude Code plugin install. Use when the user asks to review a GitHub pull request. Local mode (setup --local) runs the same pipeline on the current branch's diff from its merge base, uncommitted and untracked work included, against the caller's live tree, with no server or posting, and hands the ranked findings back in the terminal for an implementing or orchestrating agent to address. Splits oversized diffs into budgeted shards and rebuilds the diff from the local clone when gh pr diff refuses it.",
228
+ "description": "Interactive PR review pipeline. Runs five parallel specialist subagents (security, bugs, performance, code-smells, architecture) plus a once-per-PR checks pass that finds tests and controls able to pass without proving their purpose, drops findings whose quoted evidence is not in the code, dedupes, runs critic subagents that re-check each finding against the worktree and set its risk label, peer-reviews through a configured provider (codex, claude or agy) with a subagent fallback when the provider is unavailable, and serves an interactive HTML report for selecting or dismissing findings to post via gh, recording the outcome per finding as labels. Bundles a Bun CLI put on PATH by the skill's postinstall step under a bunx install, or by the plugin's bin/ under a Claude Code plugin install. Use when the user asks to review a GitHub pull request. Local mode (setup --local) runs the same pipeline on the current branch's diff from its merge base, uncommitted and untracked work included, against the caller's live tree, with no server or posting, and hands the ranked findings back in the terminal for an implementing or orchestrating agent to address. Splits oversized diffs into budgeted shards and rebuilds the diff from the local clone when gh pr diff refuses it.",
229
229
  "type": "prompt",
230
- "version": "0.17.0"
230
+ "version": "0.19.0"
231
231
  },
232
232
  {
233
233
  "name": "migrate",
@@ -293,9 +293,9 @@
293
293
  },
294
294
  {
295
295
  "name": "sluice",
296
- "description": "Routes work by change shape into four channels (bypass, fast, main, deep) and applies only the rules each channel needs, so a one-line fix does not pay the cost of a multi-subsystem build. Carries nine rules as one-liners in the router and the full treatment in references read only on friction. Deep runs read the repo before designing, map the spec's intent to its decisions, and check spec against intent and plan against spec with a fresh reader, with plan.sh validate enforcing that every decision is covered. Checks the finished plan with plan.sh validate rather than trusting it to memory, seeds the run state from it, keeps a deep run's task breakdown in .sluice/run.json so a statusline segment, one status command and a SessionStart hook can answer where the run is (the hook prints a live run at every session start, compaction included), lists every live deep run and routed fast or main session on the machine in one board.sh view (drawn once, watched, or as JSON), and closes each run with a ledger read out of the session transcript: elapsed, tools, tokens, and what each dispatched agent cost where the transcript recorded it. Two Stop hooks hold a handback: one refuses a tree that moved since its last recorded check, the other refuses a changed existing test not proven to fail on the session's starting code (or recorded with a reason). Claude Code only; stands down where the superpowers pipeline governs the repo.",
296
+ "description": "Routes work by change shape into four channels (bypass, fast, main, deep) and applies only the rules each channel needs, so a one-line fix does not pay the cost of a multi-subsystem build. Carries nine rules as one-liners in the router and the full treatment in references read only on friction. Deep runs read the repo before designing, map the spec's intent to its decisions, and check spec against intent and plan against spec with a fresh reader, with plan.sh validate enforcing that every decision is covered. Checks the finished plan with plan.sh validate rather than trusting it to memory, seeds the run state from it, keeps a deep run's task breakdown in .sluice/run.json so an opt-in statusline segment, the harness task list where the session has one, one status command and a SessionStart hook can answer where the run is (the hook prints a live run at every session start, compaction included), lists every live deep run and routed fast or main session on the machine in one board.sh view (drawn once, watched, or as JSON), and closes each run with a ledger read out of the session transcript: elapsed, tools, tokens, and what each dispatched agent cost where the transcript recorded it. Two Stop hooks hold a handback: one refuses a tree that moved since its last recorded check, the other refuses a changed existing test not proven to fail on the session's starting code (or recorded with a reason). Runs on Claude Code, Codex and Antigravity; stands down where the superpowers pipeline governs the repo.",
297
297
  "type": "prompt",
298
- "version": "0.29.0"
298
+ "version": "0.32.0"
299
299
  },
300
300
  {
301
301
  "name": "temporal-coupling-detector",
@@ -1,31 +1,35 @@
1
1
  # magpie
2
2
 
3
- Interactive Claude Code skill that runs a multi-stage PR review pipeline inside the user's Claude Code conversation.
3
+ Skill that runs a multi-stage PR review pipeline inside the user's agent conversation. It runs under Claude Code, Codex and Antigravity.
4
4
 
5
5
  ## What it does
6
6
 
7
- Given a GitHub PR number, dispatches five specialist subagents in parallel (security, bugs, performance, code-smells, architecture), each quoting an evidence snippet for every anchored finding, plus one checks pass per PR that reviews the tests, harnesses and controls for ways they can pass without proving what they exist for. Dedupe drops findings whose snippet is not in the file and groups nearby findings from different domains as merge candidates. Critic subagents then re-check each surviving finding against the worktree, keep, drop or merge it, and set its risk label, from which the severity is derived. Peer review runs via `codex exec` (falling back to a Claude second-opinion subagent when codex is unavailable). The interactive HTML report puts the top recommended findings first, lets the user dismiss findings with a reason, and posts the ones they select via `gh`; cleanup records what was posted, dismissed or ignored in `labels.json`.
7
+ Given a GitHub PR number, dispatches five specialist subagents in parallel (security, bugs, performance, code-smells, architecture), each quoting an evidence snippet for every anchored finding, plus one checks pass per PR that reviews the tests, harnesses and controls for ways they can pass without proving what they exist for. Dedupe drops findings whose snippet is not in the file and groups nearby findings from different domains as merge candidates. Critic subagents then re-check each surviving finding against the worktree, keep, drop or merge it, and set its risk label, from which the severity is derived. Peer review runs through the configured peer provider (`codex`, `claude` or `agy`), falling back to a second-opinion subagent when that provider is unavailable. The interactive HTML report puts the top recommended findings first, lets the user dismiss findings with a reason, and posts the ones they select via `gh`; cleanup records what was posted, dismissed or ignored in `labels.json`.
8
8
 
9
9
  ## Requirements
10
10
 
11
11
  - `bun` on PATH (https://bun.sh)
12
12
  - `gh` on PATH, authenticated (`gh auth status`)
13
13
  - `git` on PATH
14
- - `codex` on PATH, authenticated (optional; if absent the peer-review stage falls back to a Claude second-opinion subagent)
14
+ - the peer provider's binary on PATH, authenticated (optional; if absent the peer-review stage falls back to a second-opinion subagent). See [Peer review settings](#peer-review-settings) for which binary each preset needs.
15
15
 
16
16
  ## Install
17
17
 
18
18
  ```
19
- bunx @iceinvein/agent-skills install magpie -g
19
+ bunx @iceinvein/agent-skills install magpie -g # Claude Code: ~/.claude/skills/magpie/
20
+ bunx @iceinvein/agent-skills install magpie --tool codex -g # Codex: ~/.agents/skills/magpie/
21
+ bunx @iceinvein/agent-skills install magpie --tool antigravity -g # Antigravity: ~/.gemini/config/skills/magpie/
20
22
  ```
21
23
 
24
+ Without `-g`, the skill lands in the current project instead: `.claude/skills/magpie/` for Claude Code, and `.agents/skills/magpie/` for both Codex and Antigravity.
25
+
22
26
  As a Claude Code plugin, after `/plugin marketplace add iceinvein/agent-skills`:
23
27
 
24
28
  ```
25
29
  /plugin install magpie@iceinvein-skills
26
30
  ```
27
31
 
28
- This skill ships in two parts: the prompt (SKILL.md) and a companion Bun CLI (bin + scripts). The agent-skills installer writes both into `~/.claude/skills/magpie/` and then runs the bundled `install.sh` as a postinstall step, which symlinks `bin/magpie` onto your PATH (preferring `/usr/local/bin`, falling back to `~/.local/bin`). Set `MAGPIE_BIN_DIR` to link into that directory instead; it is created if missing, and install.sh fails rather than falling back when it cannot link there. Removing the skill with `agent-skills remove magpie -g` runs `uninstall.sh` first to undo the PATH symlink.
32
+ This skill ships in two parts: the prompt (SKILL.md) and a companion Bun CLI (bin + scripts). The agent-skills installer writes both into the host's skill directory (above) and then runs the bundled `install.sh` as a postinstall step, which symlinks `bin/magpie` onto your PATH (preferring `/usr/local/bin`, falling back to `~/.local/bin`). Set `MAGPIE_BIN_DIR` to link into that directory instead; it is created if missing, and install.sh fails rather than falling back when it cannot link there. Removing the skill with `agent-skills remove magpie -g` runs `uninstall.sh` first to undo the PATH symlink.
29
33
 
30
34
  Under a Claude Code plugin install, the plugin's `bin/` puts `magpie` on your PATH, and `bin/magpie` installs its runtime dependencies on first run (Bun required). `install.sh` and `MAGPIE_BIN_DIR` apply only to the bunx install.
31
35
 
@@ -33,10 +37,24 @@ If you cloned this repo and want to run from source, you can also invoke `./inst
33
37
 
34
38
  ## Use
35
39
 
36
- Inside Claude Code, ask: "Review PR 1234" (or paste a PR URL). The agent reads SKILL.md and walks the pipeline; the CLI runs as `magpie setup`, `magpie serve`, etc.
40
+ Inside Claude Code, Codex or Antigravity, ask: "Review PR 1234" (or paste a PR URL). The agent reads SKILL.md and walks the pipeline; the CLI runs as `magpie setup`, `magpie serve`, etc.
37
41
 
38
42
  An implementing or orchestrating agent can also ask for a review of its own branch before a PR exists: local mode (`magpie setup <run-dir> --local [--base <ref>]`) reviews the merge base to working tree diff in place and hands the ranked findings back as terminal text via `magpie handoff`, with no server, report or posting. `/magpie` with no arguments runs local mode; pass a PR number or URL to review a PR.
39
43
 
44
+ ### Peer review settings
45
+
46
+ Stage 7 sends the review to a second model through `magpie peer-run`. These environment variables pick it:
47
+
48
+ - `MAGPIE_PEER`: the provider preset, `codex` (default), `claude` or `agy`. `codex` runs `codex exec` and needs the `codex` binary; `claude` runs `claude -p` and needs the `claude` binary (Claude Code); `agy` runs `agy -p` and needs the `agy` binary (Antigravity). `MAGPIE_CODEX_BIN`, `MAGPIE_CLAUDE_BIN` and `MAGPIE_AGY_BIN` point a preset at a binary elsewhere than PATH.
49
+ - `MAGPIE_PEER_MODEL`: the model passed to the provider (`-m` for codex, `--model` for claude and agy). Unset, the provider's own default applies.
50
+ - `MAGPIE_PEER_TIMEOUT`: the provider's time limit in seconds (default 600).
51
+
52
+ An unknown `MAGPIE_PEER` or a non-positive `MAGPIE_PEER_TIMEOUT` fails setup. A missing provider binary only moves peer review to a subagent.
53
+
54
+ ### Host sandbox
55
+
56
+ Whichever host runs it, its sandbox must allow network access for `gh` (and for the peer provider, which calls its own API), writes to `~/.magpie` (the run directories) and to the repository's `.git` (PR mode adds a worktree), and running the peer provider's binary. A Codex or Antigravity sandbox that blocks these makes setup or posting fail rather than degrade.
57
+
40
58
  ### Review panel
41
59
 
42
60
  The [magpie-panel](../../mods/magpie-panel) mod shows a PR run's findings in a pane beside the chat, alongside the HTML report. With it installed, stage 8 opens the pane; without it nothing changes.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: magpie
3
- description: Use when the user asks to review a GitHub pull request (a PR number, PR URL, or "review this PR"), or to self-review the current branch diff before a PR exists, typically requested by an implementing or orchestrating agent, with findings handed back in the terminal. Interactive PR review pipeline; five parallel specialist subagents, dedupe, critic, codex/Claude peer review, and an interactive HTML report for posting selected findings via gh. Follow the stage walkthrough in this skill; the description is not the procedure.
3
+ description: Use when the user asks to review a GitHub pull request (a PR number, PR URL, or "review this PR"), or to self-review the current branch diff before a PR exists, typically requested by an implementing or orchestrating agent, with findings handed back in the terminal. Interactive PR review pipeline; five parallel specialist subagents, dedupe, critic, peer review by a configured second model, and an interactive HTML report for posting selected findings via gh. Follow the stage walkthrough in this skill; the description is not the procedure.
4
4
  argument-hint: "[<pr#>|<pr-url>|local (default)] [--base <ref>] [--intent-file <path>]"
5
5
  ---
6
6
 
@@ -8,11 +8,19 @@ argument-hint: "[<pr#>|<pr-url>|local (default)] [--base <ref>] [--intent-file <
8
8
 
9
9
  ## Prerequisites
10
10
 
11
- The skill pre-flights `bun`, `gh`, `git` (required) and `codex` (optional). A missing required binary aborts the run with a single install hint line. Without `codex` the run continues and peer review falls back to a Claude second-opinion subagent (setup prints a one-line notice and logs `{stage: preflight, status: done, missingOptional: ["codex"]}`).
11
+ The skill pre-flights `bun`, `gh`, `git` (required) and the peer provider (optional): `MAGPIE_PEER` is `codex` (default), `claude` or `agy`, `MAGPIE_PEER_MODEL` its model, `MAGPIE_PEER_TIMEOUT` its limit in seconds (default 600). A missing required binary or bad peer setting fails setup: show setup's stderr verbatim. A missing peer only moves peer review to a subagent (setup logs `{stage: preflight, status: done, missingOptional: ["<provider>"]}`). The host's sandbox must allow network for `gh` and writes to `~/.magpie` and the repo's `.git`.
12
+
13
+ ## Hosts
14
+
15
+ "Dispatch a subagent" means, per host:
16
+
17
+ - Claude Code: the Agent tool, `general-purpose` type. Host family `claude`.
18
+ - Codex: spawn a subagent. Host family `codex`.
19
+ - Antigravity: `invoke_subagent`. Host family `antigravity`.
12
20
 
13
21
  ## Stage walkthrough
14
22
 
15
- Stop reading and follow these steps in order. Do not skip stages. Use the exact Bash invocations below.
23
+ Stop reading and follow these steps in order. Do not skip stages. Use the exact shell invocations below.
16
24
 
17
25
  ### 0. Identify the PR
18
26
 
@@ -63,12 +71,14 @@ Setup also runs a deterministic test-coverage check: when the diff contains zero
63
71
 
64
72
  ### 2. Serve
65
73
 
66
- Start the HTML server in the background using the Bash tool with `run_in_background: true`:
74
+ Start the HTML server as a background process (on Claude Code, the Bash tool with `run_in_background: true`):
67
75
 
68
76
  ```
69
77
  magpie serve "$RUN_DIR"
70
78
  ```
71
79
 
80
+ A host without background processes tells the user to run `magpie serve "$RUN_DIR"` and carries on.
81
+
72
82
  Read `$RUN_DIR/state/server-info` for the URL (written within ~1s; re-read if missing). Print to the user: "Open <url> in your browser to follow along."
73
83
 
74
84
  The server stops after 30 idle minutes (an open report tab keeps it up); nothing depends on it, so re-run `magpie serve "$RUN_DIR"` to bring the report back.
@@ -85,7 +95,7 @@ Append `{stage: context, status: running}` to `$RUN_DIR/log.jsonl` and re-render
85
95
 
86
96
  Set `WORKTREE=$(magpie target "$RUN_DIR")`, the directory findings are anchored against (the run's own `worktree/` checkout on a PR run), and `TARGET` to `PR #$PR_NUMBER`. Every prompt from here on takes both.
87
97
 
88
- Read `references/scout.md` and `references/checks.md`, then dispatch two subagents (Agent tool, `general-purpose`) in one message: the scout, carrying the `magpie-scout` block with `<<RUN_DIR>>`, `<<WORKTREE>>` and `<<TARGET>>` substituted, which writes `$RUN_DIR/brief.json`; and the checks pass, built as `references/checks.md` says, which writes `$RUN_DIR/findings/checks.json` once for the run.
98
+ Read `references/scout.md` and `references/checks.md`, then, in one message, dispatch a subagent for each of two jobs: the scout, carrying the `magpie-scout` block with `<<RUN_DIR>>`, `<<WORKTREE>>` and `<<TARGET>>` substituted, which writes `$RUN_DIR/brief.json`; and the checks pass, built as `references/checks.md` says, which writes `$RUN_DIR/findings/checks.json` once for the run.
89
99
 
90
100
  Append `{stage: context, status: done}` and re-render progress. If the scout wrote no `brief.json`, append `{stage: context, status: skipped}` instead and continue: the brief is optional everywhere it is read. If the checks pass wrote no `checks.json`, append `{stage: checks, status: skipped}`; nothing downstream needs it.
91
101
 
@@ -101,9 +111,8 @@ Run `magpie history "$RUN_DIR"` once; any output is part 6 of every specialist p
101
111
 
102
112
  **One shard, zero shards, or no manifest** (a diff filtered down to nothing, e.g. a
103
113
  lockfile-only PR, yields `shards: []` in an otherwise normal manifest; a run predating
104
- this feature has no manifest at all): dispatch the five specialists in a single message,
105
- five parallel Agent calls, one per focus in (security, bugs, performance, code-smells,
106
- architecture), each carrying the prompt `references/specialists.md` describes with the
114
+ this feature has no manifest at all): dispatch a subagent per focus (security, bugs, performance, code-smells,
115
+ architecture), all five in one message, each carrying the prompt `references/specialists.md` describes with the
107
116
  unsharded run header. The shard gate and the wave dispatch below do not apply; the
108
117
  logging and the file check at the end of this stage still do.
109
118
 
@@ -163,7 +172,7 @@ The critic runs as subagents that read `$WORKTREE`. The CLI fills its prompt fro
163
172
  magpie critic-prompt "$RUN_DIR"
164
173
  ```
165
174
 
166
- It prints `<prompt path>\t<output path>` per batch of about 30 candidates (a merge group always stays in one batch). Dispatch one subagent (Agent tool, `general-purpose`) per line, all in one message, each one's entire task the verbatim contents of its prompt file. Each writes its output path and returns one summary line. No lines printed means no candidates: go straight to `critic-apply`.
175
+ It prints `<prompt path>\t<output path>` per batch of about 30 candidates (a merge group always stays in one batch). Then dispatch a subagent per line, all in one message, each one's entire task the verbatim contents of its prompt file. Each writes its output path and returns one summary line. No lines printed means no candidates: go straight to `critic-apply`.
167
176
 
168
177
  Confirm every output path exists; re-dispatch any batch whose file is missing. On a resume, dispatch only the batches whose output file is missing. Apply the verdicts:
169
178
 
@@ -175,9 +184,15 @@ It writes `findings.kept.json` and `critic-dropped.json` and logs the critic `do
175
184
 
176
185
  ### 7. Peer review
177
186
 
178
- Append `{stage: peer-review, status: running}` to `$RUN_DIR/log.jsonl` and re-render progress. This stage always runs. `codex` is preferred because it is a different model from the Claude agents that produced the findings; without it, a Claude second-opinion subagent stands in.
187
+ Append `{stage: peer-review, status: running}` to `$RUN_DIR/log.jsonl` and re-render progress. This stage always runs. Read the preset first:
179
188
 
180
- Build the peer-review prompt first: read `references/peer-review.md`, take the `magpie-peer-review` block from it, and substitute the placeholders listed in that file's `## Substitute before use` preamble.
189
+ ```
190
+ echo "${MAGPIE_PEER:-codex}"
191
+ ```
192
+
193
+ `<<PRIMARY_PROVIDER>>` is the host family (Hosts). When the preset is the host's own family (`agy` is `antigravity`), say so once in the terminal.
194
+
195
+ Build the peer-review prompt: read `references/peer-review.md`, take the `magpie-peer-review` block from it, and substitute the placeholders listed in that file's `## Substitute before use` preamble.
181
196
 
182
197
  One batch carries up to 40 findings; above that, split them 30 at a time.
183
198
  Write each batch's prompt, its `<<KEPT_FINDINGS_COMPACT>>` narrowed to that batch, to
@@ -187,23 +202,25 @@ Write each batch's prompt, its `<<KEPT_FINDINGS_COMPACT>>` narrowed to that batc
187
202
  finding in `findings.final.json` must have a unique one or the report and post stages
188
203
  crash.
189
204
 
190
- **Codex path (preferred).** If `codex` is available (setup did not log `missingOptional: ["codex"]` and `command -v codex` succeeds), set `<<PEER_PROVIDER>>` to `codex` and run codex once per batch, that batch's prompt piped on stdin:
205
+ **Peer path.** When preflight's `missingOptional` omits the preset, set `<<PEER_PROVIDER>>` to the preset and run each batch (omit `--batch` for a single batch):
191
206
 
192
207
  ```
193
- codex exec < "$RUN_DIR/peer-prompt-<k>.md" > "$RUN_DIR/peer-<k>.out"
208
+ magpie peer-run "$RUN_DIR" [--batch <k>]
194
209
  ```
195
210
 
196
- Each `peer-<k>.out` is codex's full transcript; extract the fenced JSON block tagged `review-peer-review` from each. Write the concatenated verdict arrays to `$RUN_DIR/peer.json` once, after the last batch: writing `peer.json` per batch keeps only the last batch's verdicts and silently discards the rest. Then append `{stage: peer-review, status: done, provider: codex}` and apply the verdicts as described below.
211
+ Extract the fenced `review-peer-review` JSON block from each `peer-<k>.out`. Write the concatenated verdict arrays to `$RUN_DIR/peer.json` once, after the last batch: per batch keeps only the last batch's verdicts.
212
+
213
+ On a non-zero exit, log `{stage: peer-review, provider: <preset>, status: fallback, batch: <k>, error: "<first stderr line>"}` and take the fallback for that batch. Never log `status: error` for a peer failure: `magpie status` would report the run poisoned.
197
214
 
198
- If codex returns non-zero on a batch, do not abort: record `{stage: peer-review, provider: codex, status: fallback, batch: <k>, error: "<first line of stderr>"}` and take the Claude path for that batch. (Never log `status: error` for a recoverable codex failure: `magpie status` stops at the first `error` entry and would report the run as poisoned even after the Claude fallback succeeds.)
215
+ **Fallback.** When the preset is missing or failed, prepend the `magpie-peer-review-same-family-preamble` block from `references/peer-review.md` to that batch's `peer-prompt[-<k>].md`, set `<<PEER_PROVIDER>>` to the host family, and dispatch a subagent per batch whose entire task is that file, returning only the fenced `review-peer-review` JSON block. Write its reply to `peer-<k>.out` and merge as above. A preset in `missingOptional` first logs that `status: fallback` line per batch, `error: "<preset> not on PATH"`.
199
216
 
200
- **Claude path (fallback).** When `codex` is unavailable or failed, get the second opinion from a Claude subagent instead, one per batch. Set `<<PEER_PROVIDER>>` to `claude`, then prepend the `magpie-peer-review-claude-preamble` block from `references/peer-review.md` to each batch's substituted prompt (the preamble forces genuine independence, since the reviewer shares a model family with the primary reviewers). Dispatch one subagent (Agent tool, `general-purpose`) per batch whose entire task is that combined prompt, and instruct it to return only the fenced `review-peer-review` JSON block. Write each output to `$RUN_DIR/peer-<k>.out`, extract each `review-peer-review` block, merge into `$RUN_DIR/peer.json` after the last batch as above, and append `{stage: peer-review, status: done, provider: claude}` (`provider: mixed` if codex handled some batches).
217
+ Then append `{stage: peer-review, status: done, provider: <p>}`: the preset, the host family if only the fallback ran, or `mixed`.
201
218
 
202
219
  **Apply the verdicts (both paths).** Parse the merged verdicts and apply the `update` / `add` entries (an empty array means no change). A peer `fields.severity` (or `finding.severity` on an `add`) is ignored: severity is derived from `risk.impact`. Mint each `add`'s `id` as above before merging, since the peer contract does not carry ids. Then write `findings.final.json`. Re-render progress.
203
220
 
204
221
  ### 7b. Proof
205
222
 
206
- Append `{stage: proof, status: running}` and re-render progress. `magpie proof-prompt "$RUN_DIR"` fills `references/proof.md` for up to 8 must-fix or should-fix findings, printing `<prompt path>\t<output path>` each. On a PR run with any printed, first install `$WORKTREE`'s dependencies once with the repo's frozen-lockfile command (`npm ci`, `uv sync --frozen`, ...); on failure log `{stage: proof-deps, status: skipped, error}` and go on. Dispatch the prompts as stage 6 does its batches, then `magpie proof-apply "$RUN_DIR"`: it drops disproved findings to `proof-dropped.json`, marks the rest and logs `done`. On a non-zero exit, delete only the `proof-<id>.json` files or leftovers stderr names, then re-dispatch or re-apply.
223
+ Append `{stage: proof, status: running}` and re-render progress. `magpie proof-prompt "$RUN_DIR"` fills `references/proof.md` for up to 8 must-fix or should-fix findings, printing `<prompt path>\t<output path>` each. On a PR run with any printed, first install `$WORKTREE`'s dependencies once with the repo's frozen-lockfile command (`npm ci`, `uv sync --frozen`, ...); on failure log `{stage: proof-deps, status: skipped, error}` and go on. Then dispatch a subagent per prompt as stage 6 does its batches, then `magpie proof-apply "$RUN_DIR"`: it drops disproved findings to `proof-dropped.json`, marks the rest and logs `done`. On a non-zero exit, delete only the `proof-<id>.json` files or leftovers stderr names, then re-dispatch or re-apply.
207
224
 
208
225
  ### 8. Report
209
226
 
@@ -278,7 +295,7 @@ On a non-zero exit, show stderr verbatim to the caller and stop. The diff runs f
278
295
  - Stage 8: `magpie handoff "$RUN_DIR"`. On exit 4 (`findings.final.json` or `local.json` missing) or 2 (not a local run), show stderr to the caller and stop.
279
296
  - Then `magpie cleanup "$RUN_DIR" --repo "$REPO"` at once. Reply to the caller with the handoff stdout verbatim, then one line `Run archived at <path>`, `<path>` from cleanup's `archived to <path>`. End the turn.
280
297
 
281
- Do not edit the tree mid-run: anchors and evidence are read from it live. Without the Agent tool, stop and say so rather than reviewing single-handed. The local ladder ends at handoff, then cleanup; there is no server to restart.
298
+ Do not edit the tree mid-run: anchors and evidence are read from it live. A host that cannot dispatch subagents stops and says so rather than reviewing single-handed. The local ladder ends at handoff, then cleanup; there is no server to restart.
282
299
 
283
300
  ## Resuming a crashed run
284
301
 
@@ -25,6 +25,9 @@ Subcommands:
25
25
  dedupe <run-dir> Merge specialist findings into deduped set
26
26
  critic-prompt <run-dir> [--batch-size N]
27
27
  Write one critic prompt per batch, print prompt and output paths
28
+ peer-run <run-dir> [--batch K]
29
+ Run the peer reviewer ($MAGPIE_PEER: codex, claude or agy) on
30
+ peer-prompt[-K].md, write its stdout to peer[-K].out
28
31
  critic-apply <run-dir> [--design-cap N]
29
32
  Apply critic verdicts, write findings.kept.json (no cap on
30
33
  code-smells + architecture keeps unless --design-cap is given)
@@ -252,6 +255,31 @@ const HANDLERS: Record<string, Handler> = {
252
255
  const { runDedupe } = await import('../scripts/dedupe-cmd.ts')
253
256
  return runDedupe(runDir, threshold !== undefined ? { threshold } : {})
254
257
  },
258
+ 'peer-run': async (args) => {
259
+ const runDir = args[0]
260
+ if (!runDir || runDir.startsWith('-')) {
261
+ process.stderr.write('peer-run: missing <run-dir> [--batch <k>]\n')
262
+ return 2
263
+ }
264
+ const flag = args.indexOf('--batch')
265
+ const raw = flag !== -1 ? args[flag + 1] : undefined
266
+ let batch: number | null = null
267
+ if (flag !== -1) {
268
+ const n = Number(raw)
269
+ if (!Number.isInteger(n) || n <= 0) {
270
+ process.stderr.write(`peer-run: invalid --batch ${raw} (want a positive integer)\n`)
271
+ return 2
272
+ }
273
+ batch = n
274
+ }
275
+ const { runPeer } = await import('../scripts/peer-run.ts')
276
+ const result = await runPeer(runDir, batch, process.env)
277
+ if (!result.ok) {
278
+ process.stderr.write(`peer-run: ${result.error}\n`)
279
+ return 1
280
+ }
281
+ return 0
282
+ },
255
283
  'critic-prompt': async (args) => {
256
284
  const runDir = args[0]
257
285
  if (!runDir) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magpie",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -17,7 +17,7 @@ from the run directory, and writes one prompt file per batch of candidates:
17
17
  - `<<WORKTREE>>`, `<<DIFF_PATH>>`: the run's worktree and `diff.patch`.
18
18
  - `<<OUTPUT_PATH>>`: where this batch's verdicts go, `critic.json` or `critic-<k>.json`.
19
19
 
20
- Each prompt file is the entire task of one `general-purpose` subagent. `magpie
20
+ Each prompt file is the entire task of one subagent. `magpie
21
21
  critic-apply "$RUN_DIR"` then reads every output file, rejects the set if any verdict
22
22
  is malformed, and writes `findings.kept.json` and `critic-dropped.json`. The output
23
23
  contract in the block is exactly what critic-apply accepts; change one only with the
@@ -163,7 +163,7 @@ followed by no reason from that list means "should-fix".
163
163
 
164
164
  ## Output contract
165
165
 
166
- Write a JSON array to <<OUTPUT_PATH>> with the Write tool, one entry per candidate
166
+ Write a JSON array to <<OUTPUT_PATH>> (write the file), one entry per candidate
167
167
  below, every candidate exactly once. Copy each `id` verbatim and invent none. Each
168
168
  entry is:
169
169
 
@@ -1,6 +1,6 @@
1
1
  # Peer-review prompt
2
2
 
3
- The agent substitutes the placeholders below and writes the result to `<run-dir>/peer-prompt.md`. Stage 7 then feeds that prompt to the peer reviewer: `codex exec < <run-dir>/peer-prompt.md > <run-dir>/peer.out` when codex is available, or a Claude `general-purpose` subagent (with the `magpie-peer-review-claude-preamble` prepended) writing to `<run-dir>/peer.out` when it is not.
3
+ The agent substitutes the placeholders below and writes the result to `<run-dir>/peer-prompt.md`. Stage 7 then feeds that prompt to the peer reviewer: `magpie peer-run <run-dir>` runs the configured peer (`MAGPIE_PEER`, default `codex`) on it and writes `<run-dir>/peer.out`, or, when that peer is missing or fails, a subagent (with the `magpie-peer-review-same-family-preamble` prepended) writes `<run-dir>/peer.out`.
4
4
 
5
5
  Either way, extract the fenced `review-peer-review` block from `peer.out` and save it to `<run-dir>/peer.json`.
6
6
 
@@ -13,14 +13,14 @@ last batch. Everything below is per batch and otherwise unchanged.
13
13
 
14
14
  Replace each `<<NAME>>` placeholder in the block below:
15
15
 
16
- - `<<PRIMARY_PROVIDER>>` — the agent that produced the findings (e.g. `claude`).
17
- - `<<PEER_PROVIDER>>` — the agent auditing the review (e.g. `codex`).
16
+ - `<<PRIMARY_PROVIDER>>` — the host family that produced the findings: `claude`, `codex` or `antigravity`.
17
+ - `<<PEER_PROVIDER>>` — the agent auditing the review: the `MAGPIE_PEER` preset (e.g. `codex`), or the host family when the subagent fallback runs.
18
18
  - `<<PR_TITLE>>` — `jq -r .title < $RUN_DIR/pr.json`
19
19
  - `<<PR_AUTHOR>>` — `jq -r .author.login < $RUN_DIR/pr.json`
20
20
  - `<<PR_HEAD_BRANCH>>` — `jq -r .headRefName < $RUN_DIR/pr.json`
21
21
  - `<<PR_BASE_BRANCH>>` — `jq -r .baseRefName < $RUN_DIR/pr.json`
22
22
  - `<<PR_FILES_CHANGED>>` — `grep -c '^diff --git' $RUN_DIR/diff.patch`
23
- - `<<KEPT_FINDINGS_COMPACT>>` — pretty-printed JSON array of kept findings with the fields codex needs:
23
+ - `<<KEPT_FINDINGS_COMPACT>>` — pretty-printed JSON array of kept findings with the fields the peer needs:
24
24
  ```
25
25
  jq '[.[] | {id, file, line, risk, domain, title, description}]' "$RUN_DIR/findings.kept.json"
26
26
  ```
@@ -83,11 +83,11 @@ Rules:
83
83
  ```
84
84
  ````
85
85
 
86
- ## Claude peer-review preamble
86
+ ## Same-family peer-review preamble
87
87
 
88
- Used only by the Claude fallback path in stage 7. Prepend this block verbatim (no substitutions) to the substituted `magpie-peer-review` prompt before dispatching the subagent. Its job is to buy back the independence you lose by using the same model family that produced the findings: the reviewer must re-derive each verdict from the diff rather than trusting the finding text, and must actively resist rubber-stamping.
88
+ Used only by the subagent fallback in stage 7. Prepend this block verbatim (no substitutions) to the substituted `magpie-peer-review` prompt before dispatching the subagent. Its job is to buy back the independence you lose by using the same model family that produced the findings: the reviewer must re-derive each verdict from the diff rather than trusting the finding text, and must actively resist rubber-stamping.
89
89
 
90
- ````magpie-peer-review-claude-preamble
90
+ ````magpie-peer-review-same-family-preamble
91
91
  You are a fresh, independent second-opinion reviewer. You have no memory of, and no stake in, how the findings below were produced. They were generated by other agents that share your model family, so they may carry the same blind spots you would: do not defer to them, and do not assume they are correct because they sound confident.
92
92
 
93
93
  Ground every verdict in the diff hunks provided, not in the prose of the finding. For each finding, independently re-derive whether the described problem is actually present on the cited line before you accept it. If a finding's reasoning does not hold against the hunk, or the anchor is wrong, or the risk is off, say so with "update"; if you can see a clearly actionable adjacent issue in the same hunks that was missed, add it. When the existing finding survives your own check unchanged, leave it alone.
@@ -12,7 +12,7 @@ one prompt file per finding:
12
12
  the worktree is the caller's own repo.
13
13
  - `<<OUTPUT_PATH>>`: where this finding's result goes, `proof-<id>.json`.
14
14
 
15
- Each prompt file is the entire task of one `general-purpose` subagent. `magpie
15
+ Each prompt file is the entire task of one subagent. `magpie
16
16
  proof-apply "$RUN_DIR"` then reads every result, rejects the set if any is missing or
17
17
  malformed, drops the disproved findings to `proof-dropped.json`, and marks the rest in
18
18
  `findings.final.json`. The output contract in the block is exactly what proof-apply
@@ -82,7 +82,7 @@ Diff: <<DIFF_PATH>>
82
82
 
83
83
  ## Output contract
84
84
 
85
- Write one JSON object to <<OUTPUT_PATH>> with the Write tool:
85
+ Write one JSON object to <<OUTPUT_PATH>> (write the file):
86
86
 
87
87
  ```
88
88
  {