@unifan/pi-review-zh 1.0.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.
@@ -0,0 +1,133 @@
1
+ # Claude Code Review — reference
2
+
3
+ > **Source of truth:** `anthropics/claude-plugins-official` → `plugins/code-review/commands/code-review.md`
4
+ > **Secondary (may be stale):** `plugins/code-review/README.md` — describes 4 agents and “2× CLAUDE.md compliance”; the command file is authoritative and lists **5 distinct content agents**.
5
+
6
+ Last verified: 2026-07-19.
7
+
8
+ ## Product intent
9
+
10
+ Automated PR review: multiple independent agents audit the same change from different angles, then **confidence scoring** filters false positives so only high-signal issues are posted.
11
+
12
+ - **Trigger:** `/code-review` (GitHub PR context, uses `gh`)
13
+ - **Output:** PR comment with issues ≥ threshold (default **80/100**), or no comment if none qualify
14
+ - **Not in scope:** auto-fix, harness gating merges, worktree isolation
15
+
16
+ ## Pipeline (ordered phases)
17
+
18
+ Claude is **not** “spawn N reviewers and done”. It is a **sequential pipeline** with one parallel batch in the middle.
19
+
20
+ ```
21
+ ┌─────────────────────────────────────────────────────────────────┐
22
+ │ Phase 1 — Eligibility (Haiku) │
23
+ │ Skip if: closed, draft, trivial/automated, already reviewed │
24
+ │ → STOP if ineligible │
25
+ └────────────────────────────┬────────────────────────────────────┘
26
+
27
+ ┌─────────────────────────────────────────────────────────────────┐
28
+ │ Phase 2 — Prep (Haiku, sequential) │
29
+ │ 2a. List paths to relevant CLAUDE.md files (not full contents) │
30
+ │ 2b. Summarize PR / change │
31
+ └────────────────────────────┬────────────────────────────────────┘
32
+
33
+ ┌─────────────────────────────────────────────────────────────────┐
34
+ │ Phase 3 — Content review (5× Sonnet, PARALLEL) │
35
+ │ Each returns issues + reason flagged (compliance, bug, history…) │
36
+ └────────────────────────────┬────────────────────────────────────┘
37
+
38
+ ┌─────────────────────────────────────────────────────────────────┐
39
+ │ Phase 4 — Confidence scoring (Haiku, PARALLEL per issue) │
40
+ │ One scorer agent per issue from Phase 3 │
41
+ │ Rubric: 0 / 25 / 50 / 75 / 100 (verbatim in command) │
42
+ └────────────────────────────┬────────────────────────────────────┘
43
+
44
+ ┌─────────────────────────────────────────────────────────────────┐
45
+ │ Phase 5 — Filter │
46
+ │ Drop issues with score < 80 (configurable in command) │
47
+ │ → STOP if no issues remain (no comment posted) │
48
+ └────────────────────────────┬────────────────────────────────────┘
49
+
50
+ ┌─────────────────────────────────────────────────────────────────┐
51
+ │ Phase 6 — Re-eligibility (Haiku) │
52
+ │ Repeat Phase 1 checks before posting │
53
+ └────────────────────────────┬────────────────────────────────────┘
54
+
55
+ ┌─────────────────────────────────────────────────────────────────┐
56
+ │ Phase 7 — Output (`gh pr comment`) │
57
+ │ Brief markdown; link file:line with full SHA │
58
+ └─────────────────────────────────────────────────────────────────┘
59
+ ```
60
+
61
+ ## Phase 3 — five content agents (command file)
62
+
63
+ | # | Task | Focus |
64
+ |---|------|--------|
65
+ | 1 | CLAUDE.md compliance | Rules in CLAUDE.md; not every writing-time instruction applies at review time |
66
+ | 2 | Bug detector | Shallow scan of **diff only**; large bugs; ignore nitpicks and likely FPs |
67
+ | 3 | History | `git blame` + history on modified code; bugs in light of historical context |
68
+ | 4 | Previous PRs | PRs that touched same files; comments that may apply to current PR |
69
+ | 5 | Code comments | Inline comments in modified files; change must comply with comment guidance |
70
+
71
+ Agents run **in parallel** after prep. They do **not** score their own issues for final output.
72
+
73
+ ## Phase 4 — confidence rubric (0–100)
74
+
75
+ Given verbatim to each scorer (summarized):
76
+
77
+ | Score | Meaning |
78
+ |-------|---------|
79
+ | **0** | False positive; does not survive scrutiny; or pre-existing |
80
+ | **25** | Might be real; cannot verify; stylistic without explicit CLAUDE.md callout |
81
+ | **50** | Real but minor / nitpick / rare in practice |
82
+ | **75** | Verified likely real and important; or explicitly in CLAUDE.md |
83
+ | **100** | Certain; will happen in practice; direct evidence |
84
+
85
+ **CLAUDE.md issues:** scorer must verify the guideline **explicitly** mentions the issue.
86
+
87
+ **Default threshold:** 80 — issues below are dropped.
88
+
89
+ ## Documented false positives (Phases 3–4)
90
+
91
+ Scorers are instructed to down-rank:
92
+
93
+ - Pre-existing issues not introduced in the PR
94
+ - Things that look like bugs but are not
95
+ - Pedantic nitpicks a senior engineer would skip
96
+ - Linter / typechecker / formatter / import / test failures (CI handles)
97
+ - General quality (tests, docs, generic security) **unless** CLAUDE.md requires it
98
+ - Issues silenced in code (e.g. lint-ignore)
99
+ - Intentional functional changes related to the PR scope
100
+ - Real issues on lines the author did not modify
101
+
102
+ **Explicit non-goals:** do not build or typecheck; do not use web fetch for GitHub (use `gh`).
103
+
104
+ ## README vs command discrepancies
105
+
106
+ | Topic | README | Command (`code-review.md`) |
107
+ |-------|--------|----------------------------|
108
+ | Content agent count | 4 (2× compliance + bug + history) | **5** distinct roles |
109
+ | Agent #2 | Second compliance | **Bug detector** |
110
+ | Agents #4–5 | Not listed | Previous PRs + code comments |
111
+ | Scoring | “Nx confidence scorers” | One Haiku per issue, parallel |
112
+
113
+ **For pi-review alignment, follow the command file.**
114
+
115
+ ## Architecture notes (from README technical section)
116
+
117
+ - Compliance redundancy in README (“2×”) is **not** what the current command specifies.
118
+ - Scoring is **per issue**, not one aggregating judge.
119
+ - GitHub integration: `gh pr view`, `gh pr diff`, blame/history, post comment.
120
+
121
+ ## Implications for pi-review
122
+
123
+ | Claude phase | pi-review adaptation (v0.4) |
124
+ |--------------|-------------------------|
125
+ | 1 Eligibility | PR ref / `--diff` / git repo; optional trivial probe for local-git only |
126
+ | 2 Prep | Rule-file paths + lightweight `gh pr view` / hint metadata (no full diff) |
127
+ | 3 Content (5) | Bundled reviewers **obtain the change themselves** (gh/git/read playbook) |
128
+ | 4 Scoring | Gate + optional per-issue scorers on reviewer evidence (no full diff embed) |
129
+ | 5 Filter | Code-side threshold (map 80/100 → 8/10) |
130
+ | 6 Re-eligibility | Target still present before render |
131
+ | 7 Output | TUI markdown + `appendEntry`; no `gh pr comment` yet |
132
+
133
+ **v0.4 design note:** Claude `/code-review` is an instruction document for the main agent. pi-review keeps parallel spawn + structured_output + gate enforce in the plugin, but must not hard-fail on `gh pr diff` — oversized PRs are handled inside reviewer tool loops.
@@ -0,0 +1,72 @@
1
+ # Cursor Bugbot & Security Review — reference
2
+
3
+ > **Source:** Cursor built-in skills `review-bugbot`, `review-security` (subagent invocation patterns).
4
+
5
+ Last verified: 2026-07-19.
6
+
7
+ ## Product intent (Cursor)
8
+
9
+ **Single-purpose review skills** — user manually invokes `/review-bugbot` or `/review-security`. Each launches **one** specialized subagent. There is **no** multi-phase pipeline, no gate, no per-issue confidence loop.
10
+
11
+ Cursor’s general `/review` skill routes to these specialists; they are **not** a full clone of Claude code-review.
12
+
13
+ ## Invocation contract
14
+
15
+ Both skills use the same prompt shape:
16
+
17
+ ```text
18
+ Full Repository Path: <absolute path>
19
+ Diff: <"branch changes" | "uncommitted changes">
20
+ Base Branch: <optional; only when comparing against a known non-default base>
21
+ Custom Instructions: <optional>
22
+ ```
23
+
24
+ | `Diff` value | Meaning |
25
+ |--------------|---------|
26
+ | `branch changes` (default) | Merge-base vs default branch; includes committed + staged + unstaged |
27
+ | `uncommitted changes` | Working tree only |
28
+
29
+ Subagent computes diff internally — caller should **not** pre-compute diff.
30
+
31
+ **PR / branch special case:** checkout target branch before launch; stash only with user confirmation.
32
+
33
+ ## Subagent types
34
+
35
+ | Skill | `subagent_type` | Purpose |
36
+ |-------|-----------------|---------|
37
+ | `/review-bugbot` | `bugbot` | Correctness / logic bugs in the change |
38
+ | `/review-security` | `security-review` | Security issues in the change |
39
+
40
+ ## Output discipline
41
+
42
+ After subagent completes, parent summarizes:
43
+
44
+ - Empty diff → one-line “no diff”
45
+ - No issues → one-line status
46
+ - Issues → markdown table: **Severity | Location (file:line) | Finding**, sorted by severity
47
+
48
+ **Do not** auto-fix or re-run unless user asks.
49
+
50
+ ## Retry policy
51
+
52
+ - Wrong invocation shape → fix and retry once
53
+ - Other failures → retry once with same prompt
54
+ - Still failing → stop, report error (no infinite retry)
55
+
56
+ ## What to borrow for pi-review
57
+
58
+ | Borrow | Do not borrow |
59
+ |--------|----------------|
60
+ | Bug-focused diff scope (no whole-repo nitpicks) | Single-subagent-only UX (we use parallel reviewers) |
61
+ | Security category checklist mindset | Letting subagent compute diff (we resolve diff in parent) |
62
+ | Compact table-friendly findings | Separate `/review-bugbot` commands (use `/review --reviewer`) |
63
+ | “Only changed lines” discipline | Cursor’s Task/subagent harness |
64
+
65
+ ## Mapping to pi-review agents
66
+
67
+ | Cursor | pi-review agent (planned) | Notes |
68
+ |--------|---------------------------|-------|
69
+ | `bugbot` | `bugbot` (rename from `bug-detector`) | Align prompt with Cursor output discipline |
70
+ | `security-review` | `security-review` (new) | `category: security` in schema already exists |
71
+
72
+ These are **Phase 3 content reviewers** in our pipeline, not replacements for eligibility, prep, or gate.
@@ -0,0 +1,183 @@
1
+ # pi-review — design & version roadmap
2
+
3
+ > **Positioning:** Pure **skills** extension — user manually runs `/review`. No harness, no auto-fix, no GitHub bot in v1.
4
+ > **Pattern:** Claude code-review **pipeline shape** + Cursor **bug/security prompt discipline**.
5
+ > **See also:** [claude-code-review.md](./claude-code-review.md), [cursor-review-skills.md](./cursor-review-skills.md)
6
+
7
+ Last updated: 2026-07-19.
8
+
9
+ ## Design principles
10
+
11
+ 1. **Pipeline, not a bag of agents** — eligibility → prep → parallel content → score/filter → output.
12
+ 2. **High signal** — default threshold aligned with Claude’s 80/100 (our **8/10**).
13
+ 3. **Local-first** — `git diff` / diff file; no `gh` required in v1.
14
+ 4. **Manual invocation only** — no `registerTool`, no CI hooks in v1.
15
+ 5. **Gate = Phase 4+5 compression** — one cheap spawn for dedupe + re-score + verdict; optional per-issue scorers in a later version.
16
+
17
+ ## Phase mapping (Claude → pi-review)
18
+
19
+ | Claude phase | pi-review module (planned) | v1 behavior |
20
+ |--------------|----------------------------|-------------|
21
+ | **0 Eligibility** | `src/eligibility.ts` | Empty diff, non-git, optional trivial skip |
22
+ | **1 Prep** | `src/prep.ts` | Rule paths (`AGENTS.md`, `CLAUDE.md`, `.pi/`) + diff summary injected into reviewer task |
23
+ | **2 Content (×5)** | `src/review.ts` + `agents/*.md` | Parallel subagents; bundled prompts as `--system-prompt` |
24
+ | **3 Score + filter** | `src/gate.ts` + `prompts/gate.md` | Dedupe, apply Claude rubric (adapted to 1–10), threshold, verdict |
25
+ | **4 Re-check** | `index.ts` | Optional: re-verify diff non-empty before render |
26
+ | **5 Output** | `src/report.ts` | `sendMessage` + `appendEntry("pi-review", …)` |
27
+
28
+ ```text
29
+ /review
30
+
31
+ ├─ Phase 0 eligibility() → notify + exit if skip
32
+ ├─ Phase 1 resolveDiff() → git-input / path / @file
33
+ ├─ Phase 1 prepareContext() → rule paths + summary (sync or 1 cheap spawn)
34
+ ├─ Phase 2 runReviewers() → 5 parallel (cap 4 concurrency → 2 waves)
35
+ ├─ Phase 3 runGate() → unless --no-gate
36
+ └─ Phase 4 buildReport + render → TUI markdown
37
+ ```
38
+
39
+ ## Default reviewer roster (v0.2 target)
40
+
41
+ Aligned to Claude’s five content agents, adapted for local use:
42
+
43
+ | ID | Claude agent | Status | Tools (default) |
44
+ |----|--------------|--------|-----------------|
45
+ | `claude-md-compliance` | #1 CLAUDE.md | exists | read, grep, find, ls |
46
+ | `bugbot` | #2 Bug detector | rename `bug-detector` | read, grep, find |
47
+ | `history-context` | #3 History | exists | read, bash |
48
+ | `security-review` | *(pi addition)* | **new** | read, grep, find |
49
+ | `code-comments` | #5 Code comments | **new** | read, grep |
50
+
51
+ **Dropped / deferred**
52
+
53
+ | ID | Reason |
54
+ |----|--------|
55
+ | `pr-context` (Claude #4) | Requires `gh` + PR metadata — **v1 out of scope** |
56
+ | `conventions` | Overlaps compliance + Claude false-positive list; keep as **optional** `enabled: false` |
57
+
58
+ **Concurrency:** hard cap 4 → five reviewers run as batch of 4 + batch of 1 (or user passes `--reviewer` subset).
59
+
60
+ ## Confidence scale
61
+
62
+ | System | Scale | Default keep |
63
+ |--------|-------|--------------|
64
+ | Claude Phase 4 | 0–100 | ≥ 80 |
65
+ | pi-review reviewer + gate | 1–10 | ≥ **8** (change default from 3) |
66
+
67
+ Gate prompt must embed Claude’s rubric (translated to 1–10) for **re-scoring**, not only filtering reviewer self-reported confidence.
68
+
69
+ ## Known gaps (v0.1.0 codebase)
70
+
71
+ | Gap | Blocks |
72
+ |-----|--------|
73
+ | Missing `index.ts` | Extension load |
74
+ | `agents/*.md` not used as system prompt | Reviewer quality |
75
+ | `PI_SUBAGENT_STRUCTURED_OUTPUT_*` not handled by stock `pi` | Subagent spawn |
76
+ | No eligibility / prep phases | Claude alignment |
77
+ | Default threshold 3 | Too noisy vs Claude |
78
+
79
+ ## Version plan
80
+
81
+ ### v0.1.0 — current (incomplete)
82
+
83
+ **Shipped:** core libs, 4 agent templates, gate schema, tests (92).
84
+ **Not shipped:** `index.ts`, npm publish, end-to-end run.
85
+
86
+ No further work on 0.1.0 except tagging reality in CHANGELOG if needed.
87
+
88
+ ---
89
+
90
+ ### v0.2.0 — “skills MVP” (target)
91
+
92
+ **Goal:** User can `pi -e .` or install package and run `/review` on local diff with Claude-shaped pipeline.
93
+
94
+ | Work item | Priority |
95
+ |-----------|----------|
96
+ | `index.ts` — `/review`, `/review-config`, `/review-agents` | P0 |
97
+ | `src/structured-output-capture.ts` — minimal child extension OR document `-e` flag for structured output | P0 |
98
+ | Wire `agents/<id>.md` + `prompts/gate.md` as system prompts | P0 |
99
+ | `src/eligibility.ts` — empty diff, non-git, trivial diff heuristic | P0 |
100
+ | `src/prep.ts` — rule file paths + diff summary in task preamble | P1 |
101
+ | Rename `bug-detector` → `bugbot`; add `security-review.md`, `code-comments.md` | P1 |
102
+ | Default threshold **8**; gate prompt Claude rubric | P1 |
103
+ | `conventions` default `enabled: false` | P2 |
104
+ | Update README + CHANGELOG | P1 |
105
+ | `reference/` in package `files` | P1 |
106
+
107
+ **Out of scope v0.2:** `gh`, per-issue scorers, `registerTool`, worktree, retry loop.
108
+
109
+ **Implementation:** see [v0.2-plan.md](./v0.2-plan.md) for the full task list (54 tasks, 7 tracks).
110
+
111
+ **Exit criteria**
112
+
113
+ - [ ] `pi -e /path/to/pi-review` → `/review` on dirty repo produces report
114
+ - [ ] Gate drops low-confidence issues; empty high-confidence → clear message
115
+ - [ ] `bun test` + `bun run check` pass
116
+ - [ ] npm publish `@georgedong32/pi-review@0.2.0`
117
+
118
+ ---
119
+
120
+ ### v0.3.0 — “quality & optional GH”
121
+
122
+ | Work item | Notes |
123
+ |-----------|-------|
124
+ | Per-issue scorer mode (`--score-per-issue`) | True Claude Phase 4; higher cost |
125
+ | `pr-context` reviewer (optional) | Behind `gh` detection + config flag |
126
+ | Reviewer failure retry (1×) | Only on spawn/timeout errors |
127
+ | `registerMessageRenderer` for collapsible report | TUI polish |
128
+ | Eligibility: “already reviewed” via session `appendEntry` hash | Optional |
129
+
130
+ ---
131
+
132
+ ### v1.0.0 — stable API
133
+
134
+ - Frozen config schema v1
135
+ - Documented reviewer add/replace contract
136
+ - Published pi gallery entry
137
+ - No breaking changes without `schemaVersion` bump
138
+
139
+ ## File layout (target)
140
+
141
+ ```text
142
+ index.ts Extension entry
143
+ src/
144
+ eligibility.ts Phase 0
145
+ prep.ts Phase 1
146
+ git-input.ts Diff resolution (existing)
147
+ review.ts Phase 2 fan-out (existing)
148
+ gate.ts Phase 3 (existing)
149
+ report.ts Phase 5 output (existing)
150
+ structured-output-capture.ts Child pi extension for spawn (new)
151
+ agents/
152
+ claude-md-compliance.md
153
+ bugbot.md (was bug-detector)
154
+ history-context.md
155
+ security-review.md (new)
156
+ code-comments.md (new)
157
+ conventions.md (optional, disabled)
158
+ prompts/
159
+ gate.md
160
+ reference/ This folder
161
+ ```
162
+
163
+ ## Commands (unchanged UX)
164
+
165
+ ```text
166
+ /review [path | @path] [--threshold N] [--reviewer id ...] [--no-gate] [--gate-model id] [--no-spawn]
167
+ /review-config
168
+ /review-agents
169
+ ```
170
+
171
+ ## Decision log
172
+
173
+ | Date | Decision | Rationale |
174
+ |------|----------|-----------|
175
+ | 2026-07-19 | Pure skills, manual `/review` only | User intent; avoid harness scope |
176
+ | 2026-07-19 | Follow Claude **pipeline**, not just parallel agents | User correction; command file is SoT |
177
+ | 2026-07-19 | Keep `history-context` in default roster | Claude agent #3; not merged into bugbot |
178
+ | 2026-07-19 | Add `security-review` (Cursor-inspired) | Orthogonal to bug + compliance |
179
+ | 2026-07-19 | Gate compresses Phase 4+5 for v0.2 | Cost vs fidelity; document in reference |
180
+ | 2026-07-19 | Skip `pr-context` until v0.3+ | Requires `gh`; local-first v1 |
181
+ | 2026-07-19 | Default threshold 8/10 | Maps to Claude 80/100 |
182
+ | 2026-07-26 | CLI collapsed to `--lite` dual-mode; per-issue scorer default off; gate default Haiku | Lighten the CLI surface + align with Claude code-review |
183
+ | 2026-07-26 | Foreground directive mode via `sendUserMessage` (relies on pi-subagents); `--gate-model` restored; spawn path kept as fallback | Review visible in chat; gate model user-configurable |
@@ -0,0 +1,26 @@
1
+ # Structured output capture (child extension)
2
+
3
+ Child `pi` processes spawned by pi-review load `src/structured-output-capture.ts` via:
4
+
5
+ ```text
6
+ pi --no-session --no-extensions --no-skills -e <path/to/structured-output-capture.ts> ...
7
+ ```
8
+
9
+ ## Environment variables
10
+
11
+ | Variable | Purpose |
12
+ |----------|---------|
13
+ | `PI_SUBAGENT_STRUCTURED_OUTPUT_SCHEMA` | Path to JSON Schema file (written by parent; informs model via system prompt) |
14
+ | `PI_SUBAGENT_STRUCTURED_OUTPUT_CAPTURE` | Path where child must write final JSON payload |
15
+
16
+ ## Tool contract
17
+
18
+ The capture extension registers a single tool: `structured_output`.
19
+
20
+ - Parameters: open object (`additionalProperties: true`) — parent validates with TypeBox after spawn.
21
+ - `execute`: writes `JSON.stringify(params)` to capture path; returns `terminate: true`.
22
+ - Parent passes `--tools structured_output` (reviewers also include read/grep/… as configured).
23
+
24
+ ## Parent validation
25
+
26
+ `src/spawn.ts` reads the capture file and validates against `ReviewerOutputSchema` or `GateOutputSchema`.
@@ -0,0 +1,268 @@
1
+ # v0.2.0 implementation plan
2
+
3
+ > **Goal:** Skills MVP — user runs `/review` locally and gets a Claude-shaped pipeline report.
4
+ > **Baseline:** v0.1.0 (core libs + tests; no `index.ts`, no E2E).
5
+ > **Design refs:** [pi-review-roadmap.md](./pi-review-roadmap.md), [claude-code-review.md](./claude-code-review.md)
6
+
7
+ Target release: `@georgedong32/pi-review@0.2.0`
8
+
9
+ ---
10
+
11
+ ## Goals
12
+
13
+ - [x] Extension loads via `pi -e .` and registers `/review`, `/review-config`, `/review-agents`
14
+ - [x] `/review` runs full pipeline: **eligibility → prep → reviewers → gate → report**
15
+ - [x] Five default content reviewers with bundled prompts wired as system prompts
16
+ - [~] Subagent spawn + structured JSON capture works on real `pi` child processes (unit + args tests pass; live spawn E2E pending API key)
17
+ - [x] Default confidence threshold **8/10** (Claude 80/100 equivalent)
18
+ - [ ] Publish to npm
19
+
20
+ ## Non-goals (v0.2)
21
+
22
+ - GitHub / `gh` integration (`pr-context` reviewer)
23
+ - Per-issue Haiku scorers (`--score-per-issue`)
24
+ - `registerTool` / agent auto-invoke
25
+ - Worktree isolation, auto-fix, retry loops
26
+ - Custom TUI message renderer (collapsible sections)
27
+
28
+ ---
29
+
30
+ ## Task list
31
+
32
+ Status key: `[ ]` todo · `[~]` in progress · `[x]` done
33
+
34
+ ### Track A — Extension entry (P0)
35
+
36
+ | ID | Task | Depends | Status |
37
+ |----|------|---------|--------|
38
+ | A1 | Create `index.ts` — default export `ExtensionAPI` factory | — | [x] |
39
+ | A2 | Register `/review` command with arg string passthrough | A1 | [x] |
40
+ | A3 | Register `/review-config` — ensure config dir, open editor, re-validate on save | A1 | [x] |
41
+ | A4 | Register `/review-agents` — list reviewers with resolved model/thinking/tools | A1 | [x] |
42
+ | A5 | Implement `src/cli-args.ts` — parse flags + path/`@file` from `/review` args | A1 | [x] |
43
+ | A6 | Wire orchestration in `index.ts`: load config → eligibility → diff → prep → review → gate → output | A2, A5, B*, C*, D* | [x] |
44
+ | A7 | Output: `renderReport` via `pi.sendMessage` (assistant-visible markdown) | A6 | [x] |
45
+ | A8 | Output: `pi.appendEntry("pi-review", report)` machine-readable payload | A6 | [x] |
46
+ | A9 | Long-run UX: `ctx.ui.setStatus("pi-review", …)` during spawn phases | A6 | [x] |
47
+ | A10 | Add `index.ts` to `package.json` `files`; verify `tsc` includes it | A1 | [x] |
48
+
49
+ **A3 notes:** Prefer `ctx.ui.editor()` with JSON text for in-TUI edit; fall back to `pi.exec($EDITOR, [configPath])` when `ctx.hasUI` and editor env set.
50
+
51
+ **A5 flags to parse:**
52
+
53
+ ```text
54
+ --threshold N
55
+ --reviewer <id> (repeatable)
56
+ --no-gate
57
+ --gate-model <id>
58
+ --no-spawn
59
+ [path | @path]
60
+ ```
61
+
62
+ ---
63
+
64
+ ### Track B — Structured output / spawn (P0)
65
+
66
+ | ID | Task | Depends | Status |
67
+ |----|------|---------|--------|
68
+ | B1 | Add `src/structured-output-capture.ts` — minimal pi extension: register `structured_output` tool; read schema from env; write capture file; `terminate: true` | — | [x] |
69
+ | B2 | Document env contract in `reference/structured-output.md` (or inline in spawn.ts header) | B1 | [x] |
70
+ | B3 | Update `src/args.ts` — append `-e <capture-ext>` to child args (resolve path via `import.meta.url`) | B1 | [x] |
71
+ | B4 | Verify child still uses `--no-session --no-extensions --no-skills` **except** capture extension | B3 | [x] |
72
+ | B5 | Manual E2E: one reviewer spawn writes valid `output.json` | B3, C2 | [ ] |
73
+ | B6 | Integration test with fake spawn (existing pattern) updated for `-e` arg | B3 | [x] |
74
+
75
+ **B1 contract (unchanged env vars):**
76
+
77
+ - `PI_SUBAGENT_STRUCTURED_OUTPUT_SCHEMA` → JSON Schema file path
78
+ - `PI_SUBAGENT_STRUCTURED_OUTPUT_CAPTURE` → output JSON path
79
+
80
+ ---
81
+
82
+ ### Track C — Pipeline phases (P0–P1)
83
+
84
+ | ID | Task | Depends | Status |
85
+ |----|------|---------|--------|
86
+ | C1 | Add `src/eligibility.ts` — `checkEligibility(input): { ok, reason? }` | — | [x] |
87
+ | C2 | Eligibility rules: empty diff → skip; non-git without path → skip; optional trivial diff heuristic | C1 | [x] |
88
+ | C3 | Add `tests/eligibility.test.ts` | C1 | [x] |
89
+ | C4 | Add `src/prep.ts` — `prepareContext(cwd, diff): { rulePaths, summary }` | — | [x] |
90
+ | C5 | Rule discovery: `AGENTS.md`, `CLAUDE.md`, `.pi/rules`, `.pi/conventions.md` (paths only, like Claude step 2) | C4 | [x] |
91
+ | C6 | Diff summary: first N lines / hunk count / files touched (sync, no LLM required for v0.2) | C4 | [x] |
92
+ | C7 | Inject prep block into reviewer task preamble in `review.ts` | C4, D6 | [x] |
93
+ | C8 | Add `tests/prep.test.ts` | C4 | [x] |
94
+ | C9 | Light re-check before render: diff still non-empty (Claude phase 6 lite) | C1, A6 | [x] |
95
+
96
+ **Trivial diff heuristic (v0.2):** only lockfile / only formatting-only / &lt; 3 lines — configurable `skipTrivial: true` in config later; hardcode simple rules OK for v0.2.
97
+
98
+ ---
99
+
100
+ ### Track D — Reviewers & prompts (P1)
101
+
102
+ | ID | Task | Depends | Status |
103
+ |----|------|---------|--------|
104
+ | D1 | Add `src/paths.ts` — `packageRoot()` via `import.meta.url` | — | [x] |
105
+ | D2 | `resolveAgentPrompt(id)` → `agents/<id>.md` (strip YAML frontmatter body for system prompt) | D1 | [x] |
106
+ | D3 | `resolveGatePrompt()` → `prompts/gate.md` | D1 | [x] |
107
+ | D4 | Refactor `review.ts`: use bundled agent md as `--system-prompt`; task = prep + diff | D2, C7 | [x] |
108
+ | D5 | Refactor `gate.ts`: use `prompts/gate.md` as gate system prompt | D3 | [x] |
109
+ | D6 | Rename `agents/bug-detector.md` → `agents/bugbot.md`; update id in config defaults | — | [x] |
110
+ | D7 | Tighten `bugbot.md` prompt per [cursor-review-skills.md](./cursor-review-skills.md) | D6 | [x] |
111
+ | D8 | Add `agents/security-review.md` | — | [x] |
112
+ | D9 | Add `agents/code-comments.md` (Claude agent #5) | — | [x] |
113
+ | D10 | Update `src/config.ts` `DEFAULT_CONFIG.reviewers` roster (5 enabled, conventions disabled) | D6–D9 | [x] |
114
+ | D11 | Update `prompts/gate.md` — embed Claude 0–100 rubric mapped to 1–10; re-score not just filter | D5 | [x] |
115
+ | D12 | Change default `gate.threshold` from 3 → **8** in config + README | D10 | [x] |
116
+ | D13 | Keep `agents/conventions.md`; `enabled: false` in defaults | D10 | [x] |
117
+
118
+ **Default enabled reviewers (v0.2):**
119
+
120
+ 1. `claude-md-compliance`
121
+ 2. `bugbot`
122
+ 3. `history-context`
123
+ 4. `security-review`
124
+ 5. `code-comments`
125
+
126
+ ---
127
+
128
+ ### Track E — Types, schema, report (P1)
129
+
130
+ | ID | Task | Depends | Status |
131
+ |----|------|---------|--------|
132
+ | E1 | Extend `ResolvedInput` / report if needed for prep metadata (`rulePaths`, `summary`) | C4 | [x] |
133
+ | E2 | `buildReport` — handle eligibility skip / no high-confidence issues messaging | A6 | [x] |
134
+ | E3 | `renderReport` — “No high-confidence issues” path (Claude: no comment posted) | E2 | [x] |
135
+ | E4 | Update `tests/report.test.ts` for new messages | E3 | [x] |
136
+ | E5 | Update `tests/config.test.ts` for new defaults + bugbot id | D10 | [x] |
137
+
138
+ ---
139
+
140
+ ### Track F — Tests & docs (P1)
141
+
142
+ | ID | Task | Depends | Status |
143
+ |----|------|---------|--------|
144
+ | F1 | Add `tests/cli-args.test.ts` | A5 | [x] |
145
+ | F2 | Update `tests/args.test.ts` if child argv shape changes (`-e`) | B3 | [x] |
146
+ | F3 | Update `tests/review.test.ts` for bundled prompt resolution (mock fs or inject paths) | D4 | [x] |
147
+ | F4 | Update README — pipeline diagram, 5 reviewers, threshold 8, reference links | * | [x] |
148
+ | F5 | CHANGELOG `[0.2.0]` section | * | [x] |
149
+ | F6 | Bump `package.json` version → `0.2.0` | * | [x] |
150
+ | F7 | `bun test` + `bun run check` green | * | [x] |
151
+
152
+ ---
153
+
154
+ ### Track G — Release (P1)
155
+
156
+ | ID | Task | Depends | Status |
157
+ |----|------|---------|--------|
158
+ | G1 | Manual smoke: `pi -e .` → `/review` on dirty repo | A6, B5 | [ ] |
159
+ | G2 | Manual smoke: `/review --no-gate`, `--reviewer bugbot`, `--no-spawn` | A5, A6 | [ ] |
160
+ | G3 | Manual smoke: `/review-config` round-trip | A3 | [ ] |
161
+ | G4 | `npm publish` (user-triggered) | G1–G3, F7 | [ ] |
162
+
163
+ ---
164
+
165
+ ## Suggested implementation order
166
+
167
+ ```text
168
+ Week 1 — unblock E2E
169
+ D1 → B1 → B3 → D2/D3 → D4/D5 → A1 → A5 → C1/C4 → A6 (no-gate path first)
170
+
171
+ Week 2 — full pipeline
172
+ D6–D13 → C7 → D11/D12 → A7/A8/A9 → A3/A4 → tests (F*) → docs (F4/F5)
173
+
174
+ Week 3 — polish & release
175
+ C2/C9 trivial + re-check → G* smoke → version bump → publish
176
+ ```
177
+
178
+ **Critical path:** `B1 → B3 → D4 → A6 → G1`
179
+
180
+ ---
181
+
182
+ ## Acceptance criteria (release gate)
183
+
184
+ 1. **Load:** `pi -e /path/to/pi-review` lists `/review` in commands.
185
+ 2. **Happy path:** Dirty git repo → `/review` → markdown report with verdict + per-reviewer sections + gate section.
186
+ 3. **Empty:** Clean repo, no commits ahead → eligibility message, no spawn storm.
187
+ 4. **Filter:** Reviewer returns low-confidence issue → gate drops it; report says no high-confidence issues if all dropped.
188
+ 5. **Flags:** `--no-gate` shows raw reviewer JSON sections; `--no-spawn` prints resolved plan; `--reviewer bugbot` runs one agent.
189
+ 6. **Config:** `/review-config` edit + save → `/review-agents` reflects changes.
190
+ 7. **CI:** `bun test` (≥ current count, new tests for eligibility/cli-args/prep) + `tsc --noEmit` pass.
191
+
192
+ ---
193
+
194
+ ## File manifest (expected diff)
195
+
196
+ ### New files
197
+
198
+ ```text
199
+ index.ts
200
+ src/cli-args.ts
201
+ src/eligibility.ts
202
+ src/prep.ts
203
+ src/paths.ts
204
+ src/structured-output-capture.ts
205
+ agents/bugbot.md (from bug-detector)
206
+ agents/security-review.md
207
+ agents/code-comments.md
208
+ tests/cli-args.test.ts
209
+ tests/eligibility.test.ts
210
+ tests/prep.test.ts
211
+ reference/v0.2-plan.md (this file)
212
+ ```
213
+
214
+ ### Modified files
215
+
216
+ ```text
217
+ src/review.ts
218
+ src/gate.ts
219
+ src/args.ts
220
+ src/config.ts
221
+ src/report.ts
222
+ src/types.ts (if prep metadata)
223
+ prompts/gate.md
224
+ README.md
225
+ CHANGELOG.md
226
+ package.json
227
+ reference/README.md
228
+ tests/args.test.ts
229
+ tests/config.test.ts
230
+ tests/report.test.ts
231
+ tests/review.test.ts
232
+ ```
233
+
234
+ ### Removed / renamed
235
+
236
+ ```text
237
+ agents/bug-detector.md → agents/bugbot.md
238
+ ```
239
+
240
+ ---
241
+
242
+ ## Risk register
243
+
244
+ | Risk | Mitigation |
245
+ |------|------------|
246
+ | Stock `pi` rejects `-e` with `--no-extensions` | B4: confirm CLI allows single extension override; else use minimal inline prompt + `--tools` only |
247
+ | Long diff exceeds argv limits | Pass `@file` temp path for task text (already noted in args.ts) |
248
+ | 5 reviewers × spawn cost | Document expected latency; `--reviewer` subset; concurrency cap 4 |
249
+ | Gate re-score drift vs per-issue scorers | Document in reference; v0.3 adds `--score-per-issue` |
250
+
251
+ ---
252
+
253
+ ## Progress summary
254
+
255
+ | Track | Tasks | Done |
256
+ |-------|-------|------|
257
+ | A Extension | 10 | 10 |
258
+ | B Spawn | 6 | 5 |
259
+ | C Pipeline | 9 | 9 |
260
+ | D Reviewers | 13 | 13 |
261
+ | E Types/report | 5 | 5 |
262
+ | F Tests/docs | 7 | 7 |
263
+ | G Release | 4 | 0 |
264
+ | **Total** | **54** | **49** |
265
+
266
+ **Remaining:** B5 live spawn E2E; G1–G3 manual `pi` smoke; G4 `npm publish` (user-triggered).
267
+
268
+ Update the **Progress summary** table as tasks complete.