@iceinvein/agent-skills 0.24.0 → 0.26.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 (55) hide show
  1. package/README.md +4 -3
  2. package/dist/cli/index.js +775 -236
  3. package/package.json +2 -1
  4. package/skills/index.json +2 -2
  5. package/skills/magpie/README.md +14 -0
  6. package/skills/magpie/SKILL.md +42 -23
  7. package/skills/magpie/bin/magpie.ts +91 -3
  8. package/skills/magpie/evals/README.md +1 -1
  9. package/skills/magpie/evals/post-folds-selection-events/fixture.sh +35 -0
  10. package/skills/magpie/evals/post-folds-selection-events/graders/selection-read-from-magpie-view.md +6 -0
  11. package/skills/magpie/evals/post-folds-selection-events/prompt.md +2 -2
  12. package/skills/magpie/evals/rules.json +2 -2
  13. package/skills/magpie/package.json +1 -1
  14. package/skills/magpie/references/critic.md +2 -2
  15. package/skills/magpie/references/peer-review.md +7 -7
  16. package/skills/magpie/references/proof.md +2 -2
  17. package/skills/magpie/scripts/__tests__/helper.test.ts +300 -0
  18. package/skills/magpie/scripts/__tests__/labels.test.ts +46 -1
  19. package/skills/magpie/scripts/__tests__/mark-cmd.test.ts +129 -0
  20. package/skills/magpie/scripts/__tests__/peer-run.test.ts +231 -0
  21. package/skills/magpie/scripts/__tests__/post-cmd.test.ts +298 -1
  22. package/skills/magpie/scripts/__tests__/preflight.test.ts +22 -1
  23. package/skills/magpie/scripts/__tests__/render-cmd.test.ts +15 -1
  24. package/skills/magpie/scripts/__tests__/render-findings.test.ts +13 -0
  25. package/skills/magpie/scripts/__tests__/server.test.ts +96 -1
  26. package/skills/magpie/scripts/__tests__/setup-cmd.test.ts +14 -0
  27. package/skills/magpie/scripts/__tests__/skill-lint.test.ts +68 -4
  28. package/skills/magpie/scripts/__tests__/view-cmd.test.ts +219 -0
  29. package/skills/magpie/scripts/helper.js +44 -4
  30. package/skills/magpie/scripts/labels.ts +11 -0
  31. package/skills/magpie/scripts/mark-cmd.ts +56 -0
  32. package/skills/magpie/scripts/peer-run.ts +146 -0
  33. package/skills/magpie/scripts/post-cmd.ts +75 -5
  34. package/skills/magpie/scripts/preflight.ts +20 -20
  35. package/skills/magpie/scripts/render-cmd.ts +3 -1
  36. package/skills/magpie/scripts/render-findings.ts +3 -1
  37. package/skills/magpie/scripts/server.ts +31 -2
  38. package/skills/magpie/scripts/setup-cmd.ts +7 -1
  39. package/skills/magpie/scripts/view-cmd.ts +143 -0
  40. package/skills/magpie/skill.json +1 -1
  41. package/skills/sluice/SKILL.md +21 -6
  42. package/skills/sluice/references/deep-channel.md +35 -25
  43. package/skills/sluice/references/finish.md +2 -2
  44. package/skills/sluice/references/intent.md +1 -1
  45. package/skills/sluice/references/status.md +10 -4
  46. package/skills/sluice/references/test-first.md +12 -0
  47. package/skills/sluice/scripts/board-index.sh +59 -37
  48. package/skills/sluice/scripts/board.sh +72 -40
  49. package/skills/sluice/scripts/host.sh +60 -0
  50. package/skills/sluice/scripts/run-stats.sh +41 -3
  51. package/skills/sluice/scripts/session-start.sh +75 -17
  52. package/skills/sluice/scripts/status.sh +9 -5
  53. package/skills/sluice/scripts/stop-guard.sh +101 -37
  54. package/skills/sluice/scripts/transcript.sh +221 -0
  55. package/skills/sluice/skill.json +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iceinvein/agent-skills",
3
- "version": "0.24.0",
3
+ "version": "0.26.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
@@ -227,7 +227,7 @@
227
227
  "name": "magpie",
228
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.",
229
229
  "type": "prompt",
230
- "version": "0.16.1"
230
+ "version": "0.18.0"
231
231
  },
232
232
  {
233
233
  "name": "migrate",
@@ -295,7 +295,7 @@
295
295
  "name": "sluice",
296
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.",
297
297
  "type": "prompt",
298
- "version": "0.29.0"
298
+ "version": "0.30.0"
299
299
  },
300
300
  {
301
301
  "name": "temporal-coupling-detector",
@@ -37,6 +37,20 @@ Inside Claude Code, ask: "Review PR 1234" (or paste a PR URL). The agent reads S
37
37
 
38
38
  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
39
 
40
+ ### Review panel
41
+
42
+ 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.
43
+
44
+ ```
45
+ /plugin install magpie-panel@iceinvein-skills
46
+ ```
47
+
48
+ The pane and the report share their ticks through the run's `state/events`, and the pane reaches the run only through these commands, which also work on their own:
49
+
50
+ - `magpie view <run-dir> [--top N]` prints a PR run's findings as one JSON object, each with its diff hunk, post status, dismissal and whether it is selected or recommended. Stage 9 reads the selection from it when you reply `post`.
51
+ - `magpie mark <run-dir> <id> select|deselect|undismiss` and `magpie mark <run-dir> <id> dismiss <reason>` record a selection or dismissal event, as the report's checkboxes and Dismiss button do.
52
+ - `magpie post <run-dir> --ids a,b --review [--via recommended|selected|one|cli]` posts the findings as one GitHub review, as the report's Post buttons do, skipping ids already posted; `--via` records which button the post came from in `labels.json`. Without `--review`, `post` keeps posting separate inline comments plus a summary comment.
53
+
40
54
  ## Development
41
55
 
42
56
  ```
@@ -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:
188
+
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.
179
194
 
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.
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.
197
212
 
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.)
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.
199
214
 
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).
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"`.
216
+
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
 
@@ -215,15 +232,17 @@ The report shows the top 10 recommended (`must-fix`/`should-fix`, highest score
215
232
 
216
233
  Append `{stage: report, status: done}` to `$RUN_DIR/log.jsonl` and re-render progress (the render CLI does not log this itself, and `magpie status` needs the `done` entry to resume past `report`).
217
234
 
218
- Print to the terminal: "Findings ready at <url>. Tick the ones you want and click **Post Selected**, or reply `post` here and I'll post whatever you've ticked."
235
+ If `mcp__magpie-panel__show_findings` is available, resolve `$RUN_DIR`, `command -v magpie` and `$PATH` in Bash, then call it with them as `runDir`, `magpieBin` and `path` to open the findings panel.
236
+
237
+ Print to the terminal: "Findings ready at <url> and in the magpie panel. Tick the ones you want and click **Post Selected**, or reply `post` here and I'll post whatever you've ticked." Drop "and in the magpie panel" unless the call succeeded.
219
238
 
220
239
  End the turn.
221
240
 
222
241
  ### 9. Post
223
242
 
224
- Most users tick the checkboxes in the served report and click **Post Selected** (or **Post Recommended**, which takes only the top N above the fold; **Select recommended** ticks the same set); the server posts that batch as one GitHub review with inline threads. **Dismiss** on a finding records a reason (`wrong`, `not-worth-it`, `duplicate`, `style`) and drops it from the recommended set. The agent posts only when the user types `post` (optionally `post 1,3,7` for indices), which takes the CLI path below: separate inline comments plus a top-level summary comment. Either path records posted ids in `post-status.json`, so the two cannot double-post the same finding.
243
+ Most users tick findings in the report or panel and click **Post Selected** (or **Post Recommended**, which takes only the top N above the fold; **Select recommended** ticks the same set); the server posts that batch as one GitHub review with inline threads. **Dismiss** on a finding records a reason (`wrong`, `not-worth-it`, `duplicate`, `style`) and drops it from the recommended set. The agent posts only when the user types `post` (optionally `post 1,3,7` for indices), which takes the CLI path below. Either path records posted ids in `post-status.json`, so the two cannot double-post the same finding.
225
244
 
226
- When the user types `post`, read `$RUN_DIR/state/events` and fold them in order, keeping the LAST event per finding id; ids whose last event is `select` are selected (a later `dismiss` therefore unselects). (Not union-minus: the UI emits one event per toggle, so select, deselect, select again resolves to selected.) Merge any explicit indices the user named (1-based, against `findings.final.json` in file order). If nothing is selected, say so and ask rather than posting an empty batch. Then post via the CLI:
245
+ When the user types `post`, run `magpie view "$RUN_DIR"` and take the ids whose `selected` is true (report and panel ticks, already folded). Merge any explicit indices the user named (1-based, against `findings.final.json` in file order). If nothing is selected, say so and ask rather than posting an empty batch. Then post via the CLI:
227
246
 
228
247
  ```
229
248
  magpie post "$RUN_DIR" --ids id1,id2,id3
@@ -231,8 +250,8 @@ magpie post "$RUN_DIR" --ids id1,id2,id3
231
250
 
232
251
  That delegates to `runPost`, which:
233
252
 
234
- - For a finding with a `line`, picks `formatInlineBody` (severity heading, `<sub>` risk metaline, parsed `Observation`/`Why it matters`/`Suggested direction`/`Needs verification` sections, optional `` ```suggestion `` block, hidden `magpie:finding` marker) and opens an inline review thread via `gh api repos/<owner>/<repo>/pulls/<n>/comments`.
235
- - Falls back to `formatConversationBody` (same shape plus a `Location · <file>:<line>` metaline) via `gh pr comment <n>` when there is no anchor, or GitHub rejects the inline anchor with 422.
253
+ - For a finding with a `line`, picks `formatInlineBody` (severity heading, risk metaline, parsed sections, optional `` ```suggestion `` block, hidden `magpie:finding` marker) and opens an inline review thread via `gh api repos/<owner>/<repo>/pulls/<n>/comments`.
254
+ - Falls back to `formatConversationBody` (same shape plus a location line) via `gh pr comment <n>` when there is no anchor, or GitHub rejects the inline anchor with 422.
236
255
  - When at least one new finding is in the batch (default `auto` mode), prepends one top-level summary comment (verdict line, "Needs Attention" top three, `<details>` risk breakdown) and persists the `__summary__` sentinel in `post-status.json` so re-runs don't duplicate it. Override with `--include-summary always|never`.
237
256
  - Appends `{stage: post, ...}` events to `log.jsonl` and updates `$RUN_DIR/post-status.json` per finding id.
238
257
 
@@ -276,7 +295,7 @@ On a non-zero exit, show stderr verbatim to the caller and stop. The diff runs f
276
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.
277
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.
278
297
 
279
- 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.
280
299
 
281
300
  ## Resuming a crashed run
282
301
 
@@ -13,12 +13,21 @@ Subcommands:
13
13
  (default origin/HEAD), committed and uncommitted
14
14
  target <run-dir> Print the directory findings are anchored against
15
15
  handoff <run-dir> Print local review findings as a ranked list
16
+ view <run-dir> [--top N] Print a PR run's findings with diff hunks, post status and
17
+ selection as JSON (recommends the top N, default 10)
18
+ mark <run-dir> <id> select|deselect|undismiss
19
+ mark <run-dir> <id> dismiss <reason>
20
+ Record a selection or dismissal in state/events, as the
21
+ HTML report does (reason: wrong|not-worth-it|duplicate|style)
16
22
  history <run-dir> Print what is already on the PR (open threads, comments,
17
23
  dismissals, failing checks) for the specialist prompts
18
24
  serve <run-dir-or-id> Start the HTML server (accepts active or archived run id)
19
25
  dedupe <run-dir> Merge specialist findings into deduped set
20
26
  critic-prompt <run-dir> [--batch-size N]
21
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
22
31
  critic-apply <run-dir> [--design-cap N]
23
32
  Apply critic verdicts, write findings.kept.json (no cap on
24
33
  code-smells + architecture keeps unless --design-cap is given)
@@ -38,7 +47,10 @@ Subcommands:
38
47
  delete saved refs of closed PRs
39
48
  status <run-dir> Print highest completed stage
40
49
  open [id] Open findings.html in your browser (defaults to latest run)
41
- post <run-dir> --ids a,b Post the given finding ids via gh (rich body + optional summary)
50
+ post <run-dir> --ids a,b [--review] [--via recommended|selected|one|cli] [--dry-run]
51
+ Post the given finding ids via gh (rich body + optional
52
+ summary); --review posts them as one GitHub review, as the
53
+ HTML report does, and prints its id and per-id results
42
54
  preview [opts] Render the UI from a bundled fixture (no PR needed). See --help-preview.
43
55
  --list-runs List archived runs
44
56
  --cleanup-run <id> Delete an archived run
@@ -150,6 +162,38 @@ const HANDLERS: Record<string, Handler> = {
150
162
  const { runHandoff } = await import('../scripts/handoff-cmd.ts')
151
163
  return runHandoff(runDir, { gitBin: process.env.MAGPIE_GIT_BIN || 'git' })
152
164
  },
165
+ view: async (args) => {
166
+ const runDir = args[0]
167
+ if (!runDir || runDir.startsWith('-')) {
168
+ process.stderr.write('view: missing <run-dir> [--top <n>]\n')
169
+ return 2
170
+ }
171
+ const flag = args.indexOf('--top')
172
+ const raw = flag !== -1 ? args[flag + 1] : undefined
173
+ const { DEFAULT_TOP_N } = await import('../scripts/render-issues-list.ts')
174
+ let topN = DEFAULT_TOP_N
175
+ if (flag !== -1) {
176
+ const n = Number(raw)
177
+ if (!Number.isInteger(n) || n <= 0) {
178
+ process.stderr.write(`view: invalid --top ${raw} (want a positive integer)\n`)
179
+ return 2
180
+ }
181
+ topN = n
182
+ }
183
+ const { runView } = await import('../scripts/view-cmd.ts')
184
+ return runView(runDir, topN)
185
+ },
186
+ mark: async (args) => {
187
+ const [runDir, id, verb, reason] = args
188
+ if (!runDir || runDir.startsWith('-') || !id || !verb) {
189
+ process.stderr.write(
190
+ 'mark: missing <run-dir> <id> (select|deselect|undismiss | dismiss <reason>)\n',
191
+ )
192
+ return 2
193
+ }
194
+ const { runMark } = await import('../scripts/mark-cmd.ts')
195
+ return runMark({ runDir, id, verb, ...(reason !== undefined ? { reason } : {}) })
196
+ },
153
197
  serve: async (args) => {
154
198
  const idOrPath = args[0]
155
199
  if (!idOrPath) {
@@ -211,6 +255,31 @@ const HANDLERS: Record<string, Handler> = {
211
255
  const { runDedupe } = await import('../scripts/dedupe-cmd.ts')
212
256
  return runDedupe(runDir, threshold !== undefined ? { threshold } : {})
213
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
+ },
214
283
  'critic-prompt': async (args) => {
215
284
  const runDir = args[0]
216
285
  if (!runDir) {
@@ -428,7 +497,7 @@ const HANDLERS: Record<string, Handler> = {
428
497
  const runDir = args[0]
429
498
  if (!runDir) {
430
499
  process.stderr.write(
431
- 'post: missing <run-dir> --ids <a,b,c> [--include-summary auto|always|never] [--dry-run]\n',
500
+ 'post: missing <run-dir> --ids <a,b,c> [--review] [--via recommended|selected|one|cli] [--include-summary auto|always|never] [--dry-run]\n',
432
501
  )
433
502
  return 2
434
503
  }
@@ -456,13 +525,32 @@ const HANDLERS: Record<string, Handler> = {
456
525
  process.stderr.write(`post: invalid --include-summary ${summaryRaw}\n`)
457
526
  return 2
458
527
  }
528
+ const viaFlag = args.indexOf('--via')
529
+ const viaRaw = viaFlag !== -1 ? args[viaFlag + 1] : undefined
530
+ const { POST_VIAS, parseVia } = await import('../scripts/labels.ts')
531
+ const via = viaFlag !== -1 ? parseVia(viaRaw) : 'cli'
532
+ if (!via) {
533
+ process.stderr.write(`post: invalid --via ${viaRaw} (want ${POST_VIAS.join('|')})\n`)
534
+ return 2
535
+ }
459
536
  const dryRun = args.includes('--dry-run')
537
+ if (args.includes('--review')) {
538
+ const { runPostReview } = await import('../scripts/post-cmd.ts')
539
+ const review = await runPostReview({ runDir, findingIds, via, dryRun })
540
+ if (review.error) {
541
+ process.stderr.write(`post: ${review.error}\n`)
542
+ return 2
543
+ }
544
+ const { ok, reviewId, results } = review
545
+ process.stdout.write(`${JSON.stringify({ ok, reviewId, results })}\n`)
546
+ return ok ? 0 : 1
547
+ }
460
548
  const { runPost } = await import('../scripts/post-cmd.ts')
461
549
  const outcome = await runPost({
462
550
  runDir,
463
551
  findingIds,
464
552
  dryRun,
465
- via: 'cli',
553
+ via,
466
554
  ...(includeSummary ? { includeSummary } : {}),
467
555
  })
468
556
  process.stdout.write(`${JSON.stringify(outcome)}\n`)
@@ -12,7 +12,7 @@ must not touch.
12
12
  | `shard-gate-stops-and-asks` | A resume at stage 4 with seven shards | Stops before dispatching, names 7 shards and 35 subagents, offers all three options |
13
13
  | `codex-missing-falls-back` | No codex on the machine at stage 7 | Claude path with the independence preamble, `provider: claude`, never `status: error` |
14
14
  | `report-ends-the-turn` | Stage 8 reached | Renders, logs the stage done, hands back for selection, posts nothing |
15
- | `post-folds-selection-events` | The user typed `post` after re-ticking | Folds `state/events` last-event-wins, posts `bugs-1,perf-1` only |
15
+ | `post-folds-selection-events` | The user typed `post` after re-ticking | Reads the selection from `magpie view`, posts `bugs-1,perf-1` only |
16
16
  | `resume-finds-active-run` | A fresh review ask on a PR with a live run | Checks `--list-runs` first, never calls `setup`, surfaces the interrupted run |
17
17
  | `local-mode-hands-back` | A local run resumed after peer review | Runs `handoff` then `cleanup`, replies with both finding titles, never serves, renders, posts or calls `gh` |
18
18
  | `bare-invocation-goes-local` | A bare `/magpie` on a branch with an open PR | Runs `setup --local`, never `--pr`, never calls `gh` |
@@ -90,6 +90,41 @@ buttons = '<button>Post Selected</button><button>Post Recommended</button>' if r
90
90
  RENDER
91
91
  echo "rendered ${3:-progress} -> $RUN_DIR/screen/${3:-progress}.html"
92
92
  ;;
93
+ view)
94
+ # Folds state/events last-event-wins as the real view does, so the
95
+ # selection follows the events the case writes rather than a canned list.
96
+ python3 - "${2:-$RUN_DIR}" <<'VIEW'
97
+ import json, pathlib, sys
98
+
99
+ run = pathlib.Path(sys.argv[1])
100
+ selected = set()
101
+ events = run / 'state' / 'events'
102
+ for line in (events.read_text().splitlines() if events.exists() else []):
103
+ if not line.strip():
104
+ continue
105
+ event = json.loads(line)
106
+ if event['type'] == 'select':
107
+ selected.add(event['findingId'])
108
+ elif event['type'] in ('deselect', 'dismiss'):
109
+ selected.discard(event['findingId'])
110
+ status_path = run / 'post-status.json'
111
+ status = json.loads(status_path.read_text()) if status_path.exists() else {}
112
+ pr = json.loads((run / 'pr.json').read_text())
113
+ findings = []
114
+ for f in json.loads((run / 'findings.final.json').read_text()):
115
+ raw = status.get(f['id'])
116
+ state = raw if isinstance(raw, str) or raw is None else raw.get('status')
117
+ findings.append({
118
+ 'id': f['id'], 'file': f['file'], 'line': f['line'], 'severity': f['severity'],
119
+ 'action': f['risk']['action'], 'title': f['title'], 'description': f['description'],
120
+ 'suggestion': None, 'proof': None, 'hunk': None, 'fileDiff': None,
121
+ 'postStatus': state, 'postMessage': None if isinstance(raw, str) or raw is None else raw.get('message'),
122
+ 'dismissed': None, 'selected': f['id'] in selected,
123
+ 'recommended': f['risk']['action'] in ('must-fix', 'should-fix') and state != 'posted',
124
+ })
125
+ print(json.dumps({'pr': {'number': pr['number'], 'title': pr['title'], 'url': pr['url']}, 'findings': findings}))
126
+ VIEW
127
+ ;;
93
128
  post)
94
129
  ids=""
95
130
  while [ $# -gt 0 ]; do
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: regex
3
+ pattern: 'magpie view \S+[\s\S]*magpie post [^\n]*--ids'
4
+ target: { source: file, path: .magpie-calls.log }
5
+ weight: 2
6
+ ---
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: post-folds-selection-events
3
- description: Typing `post` posts what state/events leaves selected, folded last-event-wins per finding id.
3
+ description: Typing `post` posts the findings `magpie view` reports as selected.
4
4
  tags: [magpie, post, selection, scaffold]
5
5
  max_turns: 25
6
6
  timeout_seconds: 900
7
7
  allowed_tools: [Read, Glob, Grep, Skill, Write, Edit, Bash]
8
- expected_outcome: Posts exactly bugs-1 and perf-1 via magpie post --ids, leaves the deselected security-1 alone, logs the post stage done and re-renders the report.
8
+ expected_outcome: Reads the selection from magpie view, posts exactly bugs-1 and perf-1 via magpie post --ids, leaves the deselected security-1 alone, logs the post stage done and re-renders the report.
9
9
  ---
10
10
 
11
11
  I've been ticking through the magpie report for PR 1337. post
@@ -112,9 +112,9 @@
112
112
  ]
113
113
  },
114
114
  {
115
- "id": "post-folds-events-last-event-wins",
115
+ "id": "post-reads-selection-from-magpie-view",
116
116
  "states": "SKILL.md: 9. Post",
117
- "origin": "commit:1762265",
117
+ "origin": "docs/specs/2026-11-20-magpie-panel.md",
118
118
  "cases": [
119
119
  "post-folds-selection-events"
120
120
  ]
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magpie",
3
- "version": "0.11.0",
3
+ "version": "0.18.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
  {