@fyeeme/pi-review 2.0.1 → 2.1.1

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.
package/README.md CHANGED
@@ -8,22 +8,22 @@
8
8
 
9
9
  - **`review_report` structured findings sink** — Chinese Markdown rendered back to the conversation plus machine-readable JSON under `<cwd>/.pi/review/` for CI, `--fix` re-reports, and `--comment`.
10
10
 
11
- - **Effort levels with CC-parity semantics** — `/review [low|medium|high|xhigh|max]`: quad tuples `{correctnessAngles, perAngle, maxFindings, sweep}`, grouped-by-location independent verification, and the xhigh/max gap-hunt.
11
+ - **Effort split (v2.1)** — `/code-review [low|medium|high|xhigh|max]`: low/medium/high review the diff in ONE pass in the main session (no subagents: rubric-ported flag criteria, P0–P3 priorities, in-session self-verify at medium/high); xhigh/max keep the opt-in deep sweep — quad tuples `{correctnessAngles, perAngle, maxFindings, sweep}`, grouped-by-location independent verification, and the gap-hunt.
12
12
 
13
- - **`/simplify` dual-mode** — the dispatcher measures context usage and diff size against the declared strategy, then renders either the PARALLEL template (4 cleaner agents via `subagent`) or the SINGLE-PASS one.
13
+ - **`/code-simplify` dual-mode** — the dispatcher measures context usage and diff size against the declared strategy, then renders either the PARALLEL template (4 cleaner agents via `subagent`) or the SINGLE-PASS one.
14
14
 
15
- - Breaking: commands renamed `/code-review` → `/review`, `/code-simplify` → `/simplify`.
15
+ - Commands: `/code-review` and `/code-simplify` — restored v1 names (2.0.0 briefly renamed them `/review` / `/simplify`).
16
16
 
17
17
  Review & cleanup assets for [pi](https://github.com/earendil-works/pi-mono), in the sandwich shape (skills + prompts + agents on top of a thin plugin entry):
18
18
 
19
19
  ```
20
- skills/ methodology (review, simplify) — registered natively via the `pi` manifest
20
+ skills/ methodology (code-review, code-simplify) — registered natively via the `pi` manifest
21
21
  prompts/ orchestration strategy as data — parallel-when guards in frontmatter,
22
22
  CC-parity phase structure in the body; rendered by the generic dispatcher
23
23
  agents/ the review roles as subagent definitions (finder-*, cleaner-*, verifier,
24
24
  gap-hunter) invoked via the `subagent` tool of @fyeeme/pi-subagents
25
25
  index.ts plugin entry: the review_report structured findings sink + the
26
- /review and /simplify dispatcher commands
26
+ /code-review and /code-simplify dispatcher commands
27
27
  src/ dispatch.ts (variable gathering, guard evaluation, rendering),
28
28
  diff.ts (deterministic diff ladder — unchanged v1 semantics),
29
29
  strategy.ts (guard evaluator), tools/review_report.ts
@@ -39,8 +39,8 @@ composition is idempotent.
39
39
 
40
40
  ## Commands
41
41
 
42
- - `/review [low|medium|high|xhigh|max] [--fix] [--comment] [--share] [<pr#>|<branch>|<path>]` — effort-level code review via the review skill. Effort is sticky: an explicit level is remembered; the next bare `/review` reuses it.
43
- - `/simplify [<target>]` — cleanup of the changed code (reuse/simplification/efficiency/altitude). The dispatcher resolves the diff (upstream merge-base → HEAD worktree → staged → unstaged; submodule-aware), evaluates the strategy declared in `prompts/simplify.parallel.md` frontmatter (context usage < 80%, diff < 400k chars, fan-out available), and renders either the PARALLEL template (Phase 0 visible diff read → `subagent` parallel dispatch of the 4 cleaner agents with `maxTurns: 15` → Phase 2 apply/verify/report) or the SINGLE-PASS template (angles worked inline).
42
+ - `/code-review [low|medium|high|xhigh|max] [--fix] [--loop] [--comment] [--share] [<pr#>|<branch>|<path>]` — effort-level code review via the code-review skill. low/medium/high run as a single pass in this session (fast path, default); xhigh/max fan out finder/verifier/gap-hunt agents through `subagent`. Effort is sticky: an explicit level is remembered; the next bare `/code-review` reuses it. `--loop` (single-pass levels only) drives extension-orchestrated fix→re-review rounds (≤ `maxTurns.loop`, default 3) until no P0/P1 findings remain.
43
+ - `/code-simplify [<target>]` — cleanup of the changed code (reuse/simplification/efficiency/altitude). The dispatcher resolves the diff (upstream merge-base → HEAD worktree → staged → unstaged; submodule-aware), evaluates the strategy declared in `prompts/simplify.parallel.md` frontmatter (context usage < 80%, diff < 400k chars, fan-out available), and renders either the PARALLEL template (Phase 0 visible diff read → `subagent` parallel dispatch of the 4 cleaner agents with `maxTurns: 15` → Phase 2 apply/verify/report) or the SINGLE-PASS template (angles worked inline).
44
44
 
45
45
  Reports land via the `review_report` tool: Chinese Markdown back to the conversation plus machine-readable JSON under `<cwd>/.pi/review/`.
46
46
 
@@ -69,19 +69,20 @@ pattern as pi-subagents' `pi-subagent.json` (project overrides global):
69
69
  // <any layer>/pi-review.json — all keys optional
70
70
  {
71
71
  "maxTurns": {
72
- "subagent": 20, // each /review finder-batch subagent call
73
- "verifier": 15, // each /review Phase 2 verifier call
74
- "gapHunt": 15, // the /review Phase 3 gap-hunter
75
- "simplify": 15 // each /simplify PARALLEL cleaner agent
72
+ "subagent": 20, // each /code-review finder-batch subagent call
73
+ "verifier": 15, // each /code-review Phase 2 verifier call
74
+ "gapHunt": 15, // the /code-review Phase 3 gap-hunter (xhigh/max)
75
+ "simplify": 15, // each /code-simplify PARALLEL cleaner agent
76
+ "loop": 3 // --loop fix→re-review round cap (single-pass levels)
76
77
  }
77
78
  }
78
79
  ```
79
80
 
80
81
  Values must be positive integers; anything else (or an absent file) falls back
81
- to the built-in defaults — `20` / `15` / `15` / `15`, the numbers the bundled
82
+ to the built-in defaults — `20` / `15` / `15` / `15` / `3`, the numbers the bundled
82
83
  prompts and skills were written with — so with no configuration the rendered
83
84
  instructions are byte-identical to the pre-config behavior. Files are read at
84
- command time: an edit takes effect on the next `/review` or `/simplify`
85
+ command time: an edit takes effect on the next `/code-review` or `/code-simplify`
85
86
  without a restart. When a budget is configured, the trigger message states it
86
87
  and the skills defer to it over their built-in defaults.
87
88
 
package/index.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Sandwich architecture (see openspec change subagent-sandwich-refactor):
5
5
  *
6
- * Skills skills/review, skills/simplify — review methodology,
6
+ * Skills skills/code-review, skills/code-simplify — review methodology,
7
7
  * registered natively via the pi manifest (`pi.skills`); they
8
8
  * reference capabilities by stable tool/agent names only.
9
9
  * Prompts prompts/ — the orchestration strategy as data: parallel-when
@@ -20,7 +20,7 @@
20
20
  * manifest path wiring and no separate install step), registers
21
21
  * this package's agents directory as a discovery source, and adds
22
22
  * the `review_report` structured findings sink plus the
23
- * /review and /simplify dispatcher commands.
23
+ * /code-review and /code-simplify dispatcher commands.
24
24
  *
25
25
  * The `subagent` tool registers exactly once per process: if pi-subagents
26
26
  * is ALSO installed standalone (or another consumer composes it), the guard
package/package.json CHANGED
@@ -1,59 +1,60 @@
1
1
  {
2
- "name": "@fyeeme/pi-review",
3
- "version": "2.0.1",
4
- "description": "Review & cleanup assets for pi: /review and /simplify commands dispatching declarative prompt templates (parallel strategy as frontmatter data) plus review methodology skills and finder/verifier agent definitions. Spawning lives in @fyeeme/pi-subagents; this package registers the review_report findings sink and the generic dispatcher.",
5
- "type": "module",
6
- "license": "MIT",
7
- "author": "fyeeme",
8
- "engines": {
9
- "node": ">=18"
10
- },
11
- "keywords": [
12
- "pi",
13
- "pi-package",
14
- "code-review",
15
- "simplify",
16
- "cleanup",
17
- "review"
18
- ],
19
- "files": [
20
- "*.ts",
21
- "src/**/*.ts",
22
- "skills/**/*.md",
23
- "prompts/**/*.md",
24
- "agents/**/*.md",
25
- "README.md",
26
- "LICENSE"
27
- ],
28
- "pi": {
29
- "extensions": [
30
- "./index.ts"
31
- ],
32
- "skills": [
33
- "skills/review",
34
- "skills/simplify"
35
- ]
36
- },
37
- "scripts": {
38
- "test": "vitest --run",
39
- "typecheck": "tsc"
40
- },
41
- "dependencies": {
42
- "@fyeeme/pi-subagents": "2.1.1"
43
- },
44
- "peerDependencies": {
45
- "@earendil-works/pi-ai": ">=0.84.4",
46
- "@earendil-works/pi-coding-agent": ">=0.84.4",
47
- "@earendil-works/pi-tui": ">=0.84.4",
48
- "typebox": ">=1.0.0"
49
- },
50
- "devDependencies": {
51
- "@earendil-works/pi-ai": "0.84.4",
52
- "@earendil-works/pi-coding-agent": "0.84.4",
53
- "@earendil-works/pi-tui": "0.84.4",
54
- "@types/node": "22.19.19",
55
- "jiti": "2.7.0",
56
- "typebox": "1.1.38",
57
- "typescript": "5.9.3"
58
- }
2
+ "name": "@fyeeme/pi-review",
3
+ "version": "2.1.1",
4
+ "description": "Review & cleanup assets for pi: /code-review and /code-simplify commands dispatching declarative prompt templates (parallel strategy as frontmatter data) plus review methodology skills and finder/verifier agent definitions. Spawning lives in @fyeeme/pi-subagents; this package registers the review_report findings sink and the generic dispatcher.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "fyeeme",
8
+ "engines": {
9
+ "node": ">=18"
10
+ },
11
+ "keywords": [
12
+ "pi",
13
+ "pi-package",
14
+ "code-review",
15
+ "simplify",
16
+ "cleanup",
17
+ "review"
18
+ ],
19
+ "files": [
20
+ "*.ts",
21
+ "src/**/*.ts",
22
+ "skills/**/*.md",
23
+ "prompts/**/*.md",
24
+ "agents/**/*.md",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "pi": {
29
+ "extensions": [
30
+ "./index.ts"
31
+ ],
32
+ "skills": [
33
+ "skills/code-review",
34
+ "skills/code-simplify"
35
+ ]
36
+ },
37
+ "scripts": {
38
+ "test": "vitest --run",
39
+ "typecheck": "tsc"
40
+ },
41
+ "dependencies": {
42
+ "@fyeeme/pi-subagents": "2.1.1"
43
+ },
44
+ "peerDependencies": {
45
+ "@earendil-works/pi-ai": ">=0.99.0",
46
+ "@earendil-works/pi-coding-agent": ">=0.99.0",
47
+ "@earendil-works/pi-tui": ">=0.99.0",
48
+ "typebox": ">=1.0.0"
49
+ },
50
+ "devDependencies": {
51
+ "@earendil-works/pi-ai": "0.99.2",
52
+ "@earendil-works/pi-coding-agent": "0.99.2",
53
+ "@earendil-works/pi-agent-core": "0.99.2",
54
+ "@earendil-works/pi-tui": "0.99.2",
55
+ "@types/node": "22.19.19",
56
+ "jiti": "2.7.0",
57
+ "typebox": "1.1.38",
58
+ "typescript": "5.9.3"
59
+ }
59
60
  }
@@ -1,12 +1,12 @@
1
1
  ---
2
- description: "/review trigger — effort-level code review via the review skill"
2
+ description: "/code-review trigger — xhigh/max deep sweep: finder/verifier/gap-hunt fan-out via the code-review skill"
3
3
  vars: [effort, effort-source, extra-args, skill, finder-max-turns, verifier-max-turns, gap-hunt-max-turns, verify]
4
4
  ---
5
5
  Run a code review now. Effective effort: {{effort}} ({{effort-source}}){{extra-args}}.
6
6
 
7
- First load the review skill with the read tool: {{skill}}. Then follow it
8
- exactly — dispatch the finder / verifier / gap-hunter agents it calls for
9
- through the `subagent` tool (bundled agents: finder-diff-scan,
7
+ First load the code-review skill with the read tool: {{skill}}. Then follow its
8
+ XHIGH/MAX FLOW exactly — dispatch the finder / verifier / gap-hunter agents it
9
+ calls for through the `subagent` tool (bundled agents: finder-diff-scan,
10
10
  finder-removed-behavior, finder-cross-file, finder-language-pitfall,
11
11
  finder-wrapper-proxy, cleaner-reuse, cleaner-simplification,
12
12
  cleaner-efficiency, cleaner-altitude, finder-conventions, verifier,
@@ -0,0 +1,16 @@
1
+ ---
2
+ description: "/code-review trigger — single-pass main-session review via the code-review skill (low/medium/high)"
3
+ vars: [effort, effort-source, extra-args, skill, verify, loop-note]
4
+ ---
5
+ Run a code review now. Effective effort: {{effort}} ({{effort-source}}){{extra-args}}.
6
+
7
+ First load the code-review skill with the read tool: {{skill}}. Then follow its
8
+ SINGLE-PASS FLOW for effort {{effort}}: review the diff yourself in this
9
+ session — read it, surface candidates against the skill's rubric, self-verify
10
+ them (medium/high), and report via the `review_report` tool. No subagent
11
+ fan-out at this level: do NOT dispatch finder or verifier agents, even though
12
+ the `subagent` tool may be in your session toolset.
13
+ {{loop-note}}
14
+ Verification guidance (the skill's `--fix` flow consumes it):
15
+
16
+ {{verify}}
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "/simplify trigger — PARALLEL mode (4-agent fan-out via the subagent tool)"
2
+ description: "/code-simplify trigger — PARALLEL mode (4-agent fan-out via the subagent tool)"
3
3
  parallel-when:
4
4
  context-below: 0.8
5
5
  diff-chars-below: 400000
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "/simplify trigger — SINGLE-PASS mode (angles worked inline, no fan-out)"
2
+ description: "/code-simplify trigger — SINGLE-PASS mode (angles worked inline, no fan-out)"
3
3
  vars: [target, reasons, scope-label, too-large, git-command, context-package, skill, verify]
4
4
  ---
5
5
  Clean up the changed code now. Target: {{target}}.
@@ -1,6 +1,6 @@
1
1
  ---
2
- name: review
3
- description: "Review the current diff, or a PR number/branch/path target, for correctness bugs and reuse/simplification/efficiency cleanups at the given effort level (low/medium: fewer, high-confidence findings; high→max: broader coverage, may include uncertain findings). Fresh reverse of CC `/review` (its own name there is `code-review`), re-verified against CLI v2.1.261 (2026-09-05; originally reversed from v2.1.223). Effort semantics: medium = precision, high+ = recall. Pass --fix to apply, --comment to post findings (GitHub inline / GitLab MR note), --share to publish a review page."
2
+ name: code-review
3
+ description: "Review the current diff, or a PR number/branch/path target, for correctness bugs and reuse/simplification/efficiency cleanups at the given effort level (low/medium/high: single-pass in-session review — medium precision, high recall; xhigh/max: subagent fan-out deep sweep). Fresh reverse of CC `/review` (its own name there is `code-review`), re-verified against CLI v2.1.261 (2026-09-05; originally reversed from v2.1.223). Effort semantics: medium = precision, high+ = recall. Pass --fix to apply, --loop to cycle fix→re-review until no P0/P1 findings remain, --comment to post findings (GitHub inline / GitLab MR note), --share to publish a review page."
4
4
  ---
5
5
 
6
6
  <!--
@@ -10,6 +10,19 @@ description: "Review the current diff, or a PR number/branch/path target, for co
10
10
  earlier v2.1.220 reconstruction. Every section below was located in the
11
11
  extracted strings (cc_strings_223.txt) and verified.
12
12
 
13
+ ── v2.1 redesign: effort split (single-pass default) ──
14
+ - low/medium/high → SINGLE-PASS FLOW in the main session (no subagents):
15
+ rubric-ported flag criteria, P0–P3 priorities, in-session self-verify.
16
+ Rationale: the medium+ fan-out pipeline (8–10 finder subprocesses +
17
+ grouped verifiers) cost tens of minutes per run and returned zero
18
+ findings when spawned subprocesses failed to boot — unacceptable ROI
19
+ for the default path.
20
+ - xhigh/max keep the fan-out pipeline unchanged (opt-in deep sweep).
21
+ - NEW --loop: extension-driven fix→re-review rounds (≤ maxTurns.loop,
22
+ default 3) until no P0/P1 findings remain; blocking decisions read
23
+ the structured review_report JSON (never markdown scraping).
24
+ - review_report findings gained an optional `priority` (P0–P3).
25
+
13
26
  ── RE-VERIFIED against CLI v2.1.261 (bin/claude.exe raw bytes, 2026-09-05) ──
14
27
  - The 2.1.217-era background Workflow (phases Scope/Find/Verify/Sweep/
15
28
  Synthesize) is GONE — the phase prompts now live inline in the skill
@@ -61,9 +74,11 @@ description: "Review the current diff, or a PR number/branch/path target, for co
61
74
  - Fixed-later obligation (CC Q8m): later fixes in the session must
62
75
  re-report findings with updated outcome.
63
76
 
64
- Invocation: /review [low|medium|high|xhigh|max] [--fix] [--comment] [--share] [<target>]
77
+ Invocation: /code-review [low|medium|high|xhigh|max] [--fix] [--loop] [--comment] [--share] [<target>]
65
78
  target = Class#method | file path | PR number | branch name
66
- With no level given, the /review HANDLER reuses the last level you
79
+ --loop = extension-driven fix→re-review rounds (single-pass levels only,
80
+ ≤ maxTurns.loop, default 3) until no P0/P1 findings remain
81
+ With no level given, the /code-review HANDLER reuses the last level you
67
82
  typed (CC 2.1.223 codeReviewLastEffort); the skill always receives a
68
83
  concrete level.
69
84
  (CC also supports `ultra` — deep multi-agent review in the cloud.
@@ -82,6 +97,8 @@ description: "Review the current diff, or a PR number/branch/path target, for co
82
97
  Markdown as text.
83
98
  2. Fan-out — CC uses the Agent tool; Pi uses the `subagent` tool
84
99
  (mode: parallel), or runs angles sequentially if unavailable.
100
+ v2.1: fan-out is the XHIGH/MAX path only — low/medium/high
101
+ run as a single pass in the main session (no subagents).
85
102
  3. Verify — CC uses the Agent tool; Pi uses `subagent` for the
86
103
  independent verify agent (fallback: self-check).
87
104
  4. Workflow — CC 2.1.217 routed high/xhigh/max to a background Workflow
@@ -101,8 +118,9 @@ description: "Review the current diff, or a PR number/branch/path target, for co
101
118
  mirrors both fallbacks (see the --comment section).
102
119
 
103
120
  Prerequisite: the `subagent` tool (@fyeeme/pi-subagents; parallel mode) for
104
- medium and above, and for the xhigh/max gap-hunter. lavish-axi
105
- for --share. low runs standalone (no subagents).
121
+ xhigh/max only (finder/verifier/gap-hunt fan-out). lavish-axi
122
+ for --share. low/medium/high run standalone in this session
123
+ (no subagents).
106
124
  -->
107
125
 
108
126
  You are reviewing the current diff for correctness bugs and reuse /
@@ -111,22 +129,30 @@ altitude, and conventions findings when the output cap forces a cut.
111
129
 
112
130
  ## Effort levels
113
131
 
114
- | Level | Intent | Verify | Subagents | 四元组 `{correctnessAngles, perAngle, maxFindings, sweep}` |
132
+ | Level | Path | Intent | Verify | Cap |
115
133
  |-------|--------|--------|-----------|------------|
116
- | low (default) | quick scan | no | no | 上限 `min(files_changed, 4)` |
117
- | medium | **precision** — surface only findings a maintainer would act on | independent verifier (grouped) | 8 finders | `{3, 6, 8, false}` |
118
- | high | **recall** — catch every real bug a careful reviewer would; **err on the side of surfacing** | recall-biased verifier (grouped) | 8 finders | `{3, 6, 10, false}` |
119
- | xhigh | recall + **gap-hunt** | recall-biased verifier (grouped) | 10 finders + 1 gap | `{5, 8, 15, true}` |
120
- | max | 同 xhigh | 同 xhigh | 同 xhigh | 同 xhigh |
134
+ | low (default) | SINGLE-PASS | quick scan | no | `min(files_changed, 4)` |
135
+ | medium | SINGLE-PASS | **precision** — surface only findings a maintainer would act on | self-verify (in-session) | 8 |
136
+ | high | SINGLE-PASS | **recall** — catch every real bug a careful reviewer would; **err on the side of surfacing** | self-verify (in-session) | 10 |
137
+ | xhigh | FAN-OUT (below) | recall + **gap-hunt** | independent verifier agents (grouped) | `{5, 8, 15, true}` |
138
+ | max | FAN-OUT(同 xhigh) | 同 xhigh | 同 xhigh | 同 xhigh |
139
+
140
+ **low/medium/high never dispatch subagents** — one pass in this session:
141
+ read the diff (Turn 1), surface candidates against the rubric (Turn 2),
142
+ self-verify them (Turn 3, medium/high only), report (Turn 4). This is the
143
+ default path: the 8–10 finder + grouped-verifier pipeline cost tens of
144
+ minutes per run and twice produced zero findings when spawned subprocesses
145
+ failed to boot — unacceptable ROI for a daily-driver review.
121
146
 
122
147
  **max 与 xhigh 结构相同**:fan-out / verify / sweep 完全一致,差别仅在模型 reasoning effort(CC v2.1.226 注释实证:`max → same structure as xhigh (the API reasoning effort differs, not the fan-out)`)。若运行时不支持调节 reasoning effort,max 在结构上退化为 xhigh——不要因档名而期待更多 fan-out。
123
148
 
124
- The quad tuple parameterizes the whole pipeline (CC inline semantics, verified 2.1.227):
149
+ The quad tuple parameterizes the XHIGH/MAX fan-out only (CC inline semantics,
150
+ verified 2.1.227):
125
151
 
126
- - `correctnessAngles` — how many correctness angles A–E run, taken **in order** (medium/high: A/B/C; xhigh/max: A–E).
127
- - `perAngle` — candidate cap per finder (6 at medium/high, 8 at xhigh/max).
128
- - `maxFindings` — the report cap after verify (8 / 10 / 15).
129
- - `sweep` — whether Phase 3 gap-hunt runs (xhigh/max only, ≤ 8 new candidates).
152
+ - `correctnessAngles` — 5 at xhigh/max (angles A–E all run).
153
+ - `perAngle` — candidate cap per finder (8).
154
+ - `maxFindings` — the report cap after verify (15).
155
+ - `sweep` — whether Phase 3 gap-hunt runs (≤ 8 new candidates).
130
156
 
131
157
  Each finder surfaces up to `perAngle` candidate findings with `file`, `line`, a
132
158
  one-line `summary`, a ≤60-char `short_summary`, and a concrete
@@ -177,52 +203,123 @@ actions based on it>
177
203
  ```
178
204
 
179
205
  Embed this block verbatim at the top of **every** finder / verifier / gap-hunt
180
- subagent prompt. Subagents do not re-discover the diff or CLAUDE.md; the
181
- target argument travels as a scope constraint only, never as an instruction to
182
- a subagent.
206
+ subagent prompt (XHIGH/MAX FLOW). Subagents do not re-discover the diff or
207
+ CLAUDE.md; the target argument travels as a scope constraint only, never as an
208
+ instruction to a subagent. In the SINGLE-PASS FLOW, keep the assembled block
209
+ as your own working notes — conventions come from it, not from re-discovery.
183
210
 
184
211
  ---
185
212
 
186
- # LOW-EFFORT FLOW (default; runs standalone, no subagents)
213
+ # SINGLE-PASS FLOW (default: low / medium / high — no subagents)
214
+
215
+ You review the diff yourself, in this session. Do NOT dispatch finder or
216
+ verifier agents at these levels, even if the `subagent` tool is available.
187
217
 
188
- `low effort → 1 diff pass → no verify → min(files_changed, 4) findings`
218
+ - `low` — 1 diff pass, no self-verify, cap `min(files_changed, 4)`.
219
+ - `medium` — 1 pass + self-verify, cap 8, **precision**.
220
+ - `high` — 1 pass + self-verify, cap 10, **recall**.
189
221
 
190
222
  ## Turn 1 — read
191
223
 
192
224
  One tool call: read the unified diff (`git diff @{upstream}...HEAD; git diff HEAD`
193
225
  to cover both committed and uncommitted changes, or `git diff main...HEAD` / the
194
- target passed as an argument). Skip test/fixture hunks (`test/`, `spec/`,
195
- `__tests__/`, `*_test.*`, `*.test.*`, `fixtures/`, `testdata/`) — test-file
196
- changes are not reviewed at this level. No subagents, no full-file reads.
197
-
198
- ## Turn 2 — findings
199
-
200
- Flag runtime-correctness bugs visible from the hunk alone: inverted/wrong
201
- condition, off-by-one, null/undefined deref where adjacent lines show the value
202
- can be absent, removed guard, falsy-zero check, missing `await`,
203
- wrong-variable copy-paste, error swallowed in a catch that should propagate.
204
- Also flag — still from the hunk alone — new code that duplicates an existing
205
- helper visible in the diff context, and dead code the diff leaves behind.
206
-
207
- Do **not** flag style, naming, perf, missing tests, or anything outside the hunk.
208
-
209
- Target **min(files_changed, 4) findings**, most-severe first. If you have fewer,
210
- do one more pass focused on the largest changed file and on any **removed** code
211
- blocks. Output exactly `(none)` only if the diff is trivially correct after
212
- that pass.
213
-
214
- Low 档输出契约是**双变体**(与 CC 的 `p$p`/`d$p` 一致):若 `review_report` 工具可用(本扩展已注册),调用它**一次**上报 `{level: "low", fanned_out: false, findings}`,每条 finding 带 `file` / `line` / `summary` / `short_summary`(≤60 字符)/ `failure_scenario`;无发现时传空数组。不要重复打印文本——工具负责渲染。若 `review_report` 不可用,改为纯文本输出:每行 `path/to/file.ext:123 — 问题与失败后果`,无发现输出 `(none)`,不调用任何上报工具。
226
+ target passed as an argument). At low, skip test/fixture hunks (`test/`,
227
+ `spec/`, `__tests__/`, `*_test.*`, `*.test.*`, `fixtures/`, `testdata/`) —
228
+ test-file changes are not reviewed at that level; medium/high include them.
229
+ Then read the enclosing function for each nontrivial hunk; the applicable
230
+ CLAUDE.md conventions are already pinned in the Phase 0.5 scope block.
231
+
232
+ ## Turn 2 — candidates (the rubric)
233
+
234
+ Work the finder angles inline — their definitions live in the XHIGH/MAX FLOW
235
+ below and are shared with the subagent definitions:
236
+
237
+ - **low** — Angle A over the hunks only: runtime-correctness bugs visible
238
+ from the hunk alone (inverted/wrong condition, off-by-one, null/undefined
239
+ deref where adjacent lines show the value can be absent, removed guard,
240
+ falsy-zero check, missing `await`, wrong-variable copy-paste, error
241
+ swallowed in a catch that should propagate), plus new code duplicating an
242
+ existing helper visible in the diff context, plus dead code the diff leaves
243
+ behind. Do **not** flag style, naming, perf, missing tests, or anything
244
+ outside the hunk. If you have fewer than the cap, do one more pass focused
245
+ on the largest changed file and on any **removed** code blocks. Output
246
+ exactly `(none)` only if the diff is trivially correct after that pass.
247
+ - **medium** — Angles A, B, C, then a quick Reuse / Simplification /
248
+ Efficiency pass over the changed code.
249
+ - **high** — the full angle set: A–E, then Reuse / Simplification /
250
+ Efficiency / Altitude / Conventions.
251
+
252
+ Flag issues that (rubric ported from the reference /review implementation):
253
+
254
+ 1. Meaningfully impact the accuracy, performance, security, or
255
+ maintainability of the code.
256
+ 2. Are discrete and actionable (not general issues or multiple combined
257
+ issues).
258
+ 3. Don't demand rigor inconsistent with the rest of the codebase.
259
+ 4. Were introduced in the changes being reviewed (not pre-existing bugs).
260
+ 5. The author would likely fix if made aware of them.
261
+ 6. Don't rely on unstated assumptions about the codebase or the author's
262
+ intent.
263
+
264
+ Every candidate carries `file`, `line`, `category`, a one-line `summary`, a
265
+ ≤60-char `short_summary`, a concrete `failure_scenario`, and a **priority**
266
+ (`--loop` treats P0/P1 as blocking):
267
+
268
+ - **P0** — data loss, security hole, crash on a main path, broken build.
269
+ - **P1** — real bug on a plausible path; broken invariant with visible
270
+ effect.
271
+ - **P2** — worthwhile cleanup (duplication, wasted work, wrong altitude) or
272
+ an uncertain-trigger correctness issue.
273
+ - **P3** — nice-to-have.
274
+
275
+ Correctness outranks cleanup when the cap forces a cut.
276
+
277
+ ## Turn 3 — self-verify (medium / high; low skips)
278
+
279
+ Re-read every candidate against the code once, in this session:
280
+
281
+ - Drop anything whose `failure_scenario` you cannot make concrete.
282
+ - Set the verdict: **`CONFIRMED`** — you can name the inputs/state that
283
+ trigger it and the wrong output or crash (quote the line); **`PLAUSIBLE`**
284
+ — the mechanism is real but the trigger is uncertain (timing, env,
285
+ config); state what would confirm it.
286
+ - **`PLAUSIBLE` by default** — do not drop a candidate for being
287
+ "speculative" or "depends on runtime state" when the state is realistic:
288
+ concurrency races, nil/undefined on a rare-but-reachable path (error
289
+ handler, cold cache, missing optional field), falsy-zero treated as
290
+ missing, off-by-one on a boundary the code does not exclude, retry storms
291
+ / partial failures, regex/allowlist that lost an anchor.
292
+ - At medium (precision), additionally drop what a maintainer would not act
293
+ on. At high (recall), keep every surviving candidate — a missed bug ships.
294
+
295
+ ## Turn 4 — report
296
+
297
+ Report via the `review_report` tool exactly as the Output section below
298
+ specifies, with `fanned_out: false` (honesty: this was a single-pass
299
+ self-review). At low the candidates ARE the findings (unverified — leave
300
+ `verdict` unset so the reader can discount them); if the `review_report` tool
301
+ is unavailable, print the findings as text (one line per finding:
302
+ `path/to/file.ext:123 — 问题与失败后果`), `(none)` when empty.
303
+
304
+ ## Loop fixing (--loop)
305
+
306
+ When the trigger message says loop fixing is armed, the extension takes over
307
+ after your report: it reads the newest `review_report` JSON under
308
+ `.pi/review/`, and while P0/P1 findings remain it sends a fix prompt (apply
309
+ them per the --fix section's rules), waits, then asks you to re-run this
310
+ single-pass flow. Treat each re-review as a fresh pass with a fresh
311
+ `report_id` and an honest fresh findings list — do not rubber-stamp the
312
+ previous run.
215
313
 
216
314
  ---
217
315
 
218
- # MEDIUM-AND-ABOVE FLOW (fan-out + verify)
219
-
220
- ## Phase 1 — Find candidates (single pass or parallel fan-out)
316
+ # XHIGH/MAX FLOW (deep sweep: fan-out + verify)
221
317
 
222
- Work through the angles below. If the `subagent` tool is available, launch
223
- finder agents in a single batch (mode: parallel) so they run concurrently;
224
- otherwise do not fake the fan-out — work the angles yourself in sequence in
225
- this same context, or report that the subagent capability is unavailable.
318
+ Reached only at effort xhigh/max — low/medium/high use the SINGLE-PASS FLOW
319
+ above. Launch finder agents through the `subagent` tool in a single batch
320
+ (mode: parallel) so they run concurrently; if it is unavailable, do not fake
321
+ the fan-out — work the angles yourself in sequence in this same context, or
322
+ report that the subagent capability is unavailable.
226
323
 
227
324
  **Checking `subagent` availability** — wherever this skill says "if the
228
325
  `subagent` tool is available", decide from THIS session's tool list, never by
@@ -255,15 +352,11 @@ every finder batch:
255
352
  before Phase 2 (or fold it into the xhigh/max gap-hunt), and note the
256
353
  re-dispatch in the report.
257
354
 
258
- **Finder allocation** (CC inline, verified 2.1.227): the number of correctness
259
- angles comes from the effort quad tuple, taken **in order A→E** (`slice(0, N)`
260
- — do not hand-pick angles; that makes runs unreproducible):
261
-
262
- - **medium / high** (3 correctness angles): **8 finders** — A, B, C + one
263
- finder each for Reuse, Simplification, Efficiency + one Altitude + one
264
- Conventions.
265
- - **xhigh / max** (5 correctness angles): **10 finders** — A, B, C, D, E + the
266
- same 3 cleanup finders + Altitude + Conventions.
355
+ **Finder allocation** (CC inline, verified 2.1.227): xhigh/max run all five
356
+ correctness angles — **10 finders**: A, B, C, D, E + one finder each for
357
+ Reuse, Simplification, Efficiency + one Altitude + one Conventions. The quad
358
+ tuple's angles are taken **in order A→E** (`slice(0, N)` — do not hand-pick
359
+ angles; that makes runs unreproducible).
267
360
 
268
361
  Each cleanup angle (Reuse / Simplification / Efficiency) gets its own finder;
269
362
  Altitude and Conventions are independent finders. Never silently drop an
@@ -410,12 +503,11 @@ optional field), falsy-zero treated as missing, off-by-one on a boundary the
410
503
  code does not exclude, retry storms / partial failures, regex/allowlist that
411
504
  lost an anchor. These are PLAUSIBLE.
412
505
 
413
- **Recall bias by level** — at high/xhigh/max, a single non-REFUTED verdict
414
- keeps the candidate: do NOT drop it on uncertainty ("speculative", "depends
415
- on runtime state"). That is the recall contract of high+. Medium is the
416
- precision level: there, additionally weigh whether a maintainer would act on
417
- the finding before keeping it. At xhigh/max a missed bug ships — err on the
418
- side of surfacing hardest there.
506
+ **Recall bias** — a single non-REFUTED verdict keeps the candidate: do NOT
507
+ drop it on uncertainty ("speculative", "depends on runtime state"). This
508
+ flow is the recall contract of xhigh/max — a missed bug ships, so err on the
509
+ side of surfacing hardest here. (Medium's precision filter lives in the
510
+ single-pass self-verify; it never reaches this flow.)
419
511
 
420
512
  **REFUTED** only when constructible from the code: factually wrong (quote the
421
513
  actual line); provably impossible (type/constant/invariant — show it); already
@@ -452,8 +544,6 @@ Feed anything it finds back through Phase 2 verify before keeping it. If the
452
544
  `subagent` tool is unavailable, take one self-sweep instead and note the
453
545
  gap-hunt was self-run (lacks the independent fresh-eyes benefit).
454
546
 
455
- At **high and below**, skip Phase 3.
456
-
457
547
  ## Output
458
548
 
459
549
  Report the findings via the `review_report` tool (this extension's counterpart
@@ -471,7 +561,9 @@ or publish an artifact of the review — the tool call is the report");
471
561
  Each finding in the array carries: `file`, `line` (optional), `category`
472
562
  (`correctness` / `reuse` / `simplification` / `efficiency` / `altitude` /
473
563
  `conventions`, or a more specific slug like `test-coverage`), `verdict`
474
- (`CONFIRMED` / `PLAUSIBLE`), `short_summary` (≤60 字符、纯声明——去掉理由与
564
+ (`CONFIRMED` / `PLAUSIBLE`), `priority` (`P0`–`P3`; single-pass levels
565
+ always set it — `--loop` treats P0/P1 as blocking; xhigh/max may omit it),
566
+ `short_summary` (≤60 字符、纯声明——去掉理由与
475
567
  后果,汇总表概述列优先使用它;示例:`"off-by-one in loop bound"`),
476
568
  `summary` (一行中文,含理由与后果,详情块使用), `failure_scenario`
477
569
  (concrete input/state → wrong output/crash; for cleanup findings, the
@@ -498,7 +590,7 @@ the files by id.
498
590
  `outcome` 作为标识符保留英文 token。
499
591
 
500
592
  **`fanned_out` 诚实** — 准确设置:仅当多智能体 fan-out 真的跑起来(subagent
501
- finder + verify agent)才为 `true`;low effort 或任何单遍/自审降级为 `false`。该
593
+ finder + verify agent,xhigh/max)才为 `true`;low/medium/high 单遍或任何自审降级为 `false`。该
502
594
  字段会出现在报告表头,让读者不被误导(替代旧的 Single-pass honesty 小节)。
503
595
 
504
596
  **降级** — 若 `review_report` 工具未注册(这份 SKILL.md 跑在 pi-review 扩展之外),
@@ -508,7 +600,9 @@ finder + verify agent)才为 `true`;low effort 或任何单遍/自审降级
508
600
 
509
601
  ## Applying fixes (--fix)
510
602
 
511
- The `--fix` flag was passed. After producing the findings list, apply the
603
+ The `--fix` flag was passed (the extension-driven `--loop` sends the same
604
+ fix prompts between re-review passes — follow them identically). After
605
+ producing the findings list, apply the
512
606
  findings to the working tree instead of stopping at the report: fix each one
513
607
  directly — correctness bugs and reuse/simplification/efficiency cleanups alike.
514
608
  Skip any finding whose fix would change intended behavior, require changes well