@fyeeme/pi-review 1.1.1 → 2.0.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 +77 -146
- package/agents/cleaner-altitude.md +18 -0
- package/agents/cleaner-efficiency.md +19 -0
- package/agents/cleaner-reuse.md +16 -0
- package/agents/cleaner-simplification.md +16 -0
- package/agents/finder-conventions.md +23 -0
- package/agents/finder-cross-file.md +21 -0
- package/agents/finder-diff-scan.md +23 -0
- package/agents/finder-language-pitfall.md +21 -0
- package/agents/finder-removed-behavior.md +21 -0
- package/agents/finder-wrapper-proxy.md +23 -0
- package/agents/gap-hunter.md +24 -0
- package/agents/verifier.md +33 -0
- package/index.ts +34 -39
- package/package.json +18 -17
- package/prompts/review.md +23 -0
- package/prompts/simplify.parallel.md +45 -0
- package/prompts/simplify.single.md +23 -0
- package/skills/{code-review → review}/SKILL.md +113 -33
- package/skills/simplify/SKILL.md +56 -44
- package/src/config.ts +103 -0
- package/src/diff.ts +306 -0
- package/src/dispatch.ts +238 -0
- package/src/strategy.ts +76 -0
- package/src/tools/review_report.ts +17 -15
- package/src/commands/code-review.ts +0 -100
- package/src/commands/code-simplify.ts +0 -807
- package/src/concurrency.ts +0 -23
- package/src/tools/subagent.ts +0 -372
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fyeeme/pi-review",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Review & cleanup
|
|
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
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "fyeeme",
|
|
@@ -9,26 +9,29 @@
|
|
|
9
9
|
"node": ">=18"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [
|
|
12
|
-
"pi-package",
|
|
13
12
|
"pi",
|
|
13
|
+
"pi-package",
|
|
14
14
|
"code-review",
|
|
15
15
|
"simplify",
|
|
16
16
|
"cleanup",
|
|
17
|
-
"subagent",
|
|
18
|
-
"fan-out",
|
|
19
17
|
"review"
|
|
20
18
|
],
|
|
21
19
|
"files": [
|
|
22
20
|
"*.ts",
|
|
23
21
|
"src/**/*.ts",
|
|
24
22
|
"skills/**/*.md",
|
|
23
|
+
"prompts/**/*.md",
|
|
24
|
+
"agents/**/*.md",
|
|
25
25
|
"README.md",
|
|
26
26
|
"LICENSE"
|
|
27
27
|
],
|
|
28
28
|
"pi": {
|
|
29
29
|
"extensions": [
|
|
30
|
-
"./index.ts"
|
|
31
|
-
|
|
30
|
+
"./index.ts"
|
|
31
|
+
],
|
|
32
|
+
"skills": [
|
|
33
|
+
"skills/review",
|
|
34
|
+
"skills/simplify"
|
|
32
35
|
]
|
|
33
36
|
},
|
|
34
37
|
"scripts": {
|
|
@@ -36,20 +39,18 @@
|
|
|
36
39
|
"typecheck": "tsc"
|
|
37
40
|
},
|
|
38
41
|
"dependencies": {
|
|
39
|
-
"@fyeeme/pi-
|
|
42
|
+
"@fyeeme/pi-subagents": "2.1.1"
|
|
40
43
|
},
|
|
41
44
|
"peerDependencies": {
|
|
42
|
-
"@earendil-works/pi-ai": ">=0.84.
|
|
43
|
-
"@earendil-works/pi-coding-agent": ">=0.84.
|
|
44
|
-
"@earendil-works/pi-tui": ">=0.84.
|
|
45
|
-
"
|
|
46
|
-
"typebox": ">=1.0.0",
|
|
47
|
-
"typescript": ">=5.0.0"
|
|
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"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
|
-
"@earendil-works/pi-ai": "0.84.
|
|
51
|
-
"@earendil-works/pi-coding-agent": "0.84.
|
|
52
|
-
"@earendil-works/pi-tui": "0.84.
|
|
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",
|
|
53
54
|
"@types/node": "22.19.19",
|
|
54
55
|
"jiti": "2.7.0",
|
|
55
56
|
"typebox": "1.1.38",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "/review trigger — effort-level code review via the review skill"
|
|
3
|
+
vars: [effort, effort-source, extra-args, skill, finder-max-turns, verifier-max-turns, gap-hunt-max-turns, verify]
|
|
4
|
+
---
|
|
5
|
+
Run a code review now. Effective effort: {{effort}} ({{effort-source}}){{extra-args}}.
|
|
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,
|
|
10
|
+
finder-removed-behavior, finder-cross-file, finder-language-pitfall,
|
|
11
|
+
finder-wrapper-proxy, cleaner-reuse, cleaner-simplification,
|
|
12
|
+
cleaner-efficiency, cleaner-altitude, finder-conventions, verifier,
|
|
13
|
+
gap-hunter), with `maxTurns: {{finder-max-turns}}` per finder batch,
|
|
14
|
+
`maxTurns: {{verifier-max-turns}}` per verifier and `maxTurns: {{gap-hunt-max-turns}}`
|
|
15
|
+
for the gap-hunt as the skill instructs.
|
|
16
|
+
|
|
17
|
+
The `subagent` tool is a pi extension tool in your session toolset — judge
|
|
18
|
+
its availability from that list, never via `mcp` tool search (which only
|
|
19
|
+
indexes MCP-server tools and cannot see extension tools).
|
|
20
|
+
|
|
21
|
+
Verification guidance (the skill's `--fix` flow consumes it):
|
|
22
|
+
|
|
23
|
+
{{verify}}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "/simplify trigger — PARALLEL mode (4-agent fan-out via the subagent tool)"
|
|
3
|
+
parallel-when:
|
|
4
|
+
context-below: 0.8
|
|
5
|
+
diff-chars-below: 400000
|
|
6
|
+
vars: [target, scope-label, pct, git-command, context-package, skill, verify, simplify-max-turns]
|
|
7
|
+
---
|
|
8
|
+
Clean up the changed code now. Target: {{target}}.
|
|
9
|
+
|
|
10
|
+
Dispatcher decided PARALLEL mode (context {{pct}} full; scope {{scope-label}}).
|
|
11
|
+
Follow the phases IN ORDER — do not launch anything before Phase 0 is done.
|
|
12
|
+
|
|
13
|
+
## Phase 0 — read the diff (visible, before any agent launches)
|
|
14
|
+
|
|
15
|
+
{{context-package}}
|
|
16
|
+
|
|
17
|
+
Run exactly this command (the dispatcher already resolved the scope — do not
|
|
18
|
+
re-derive a different range):
|
|
19
|
+
|
|
20
|
+
{{git-command}}
|
|
21
|
+
|
|
22
|
+
Read the full diff, then write a 2–4 line change-intent summary BEFORE
|
|
23
|
+
launching anything — that summary and your first-hand reading are what you
|
|
24
|
+
will use to merge, dedup, and judge the agents' findings in Phase 2.
|
|
25
|
+
|
|
26
|
+
## Phase 1 — launch the 4 cleanup agents
|
|
27
|
+
|
|
28
|
+
Call the `subagent` tool in parallel mode with 4 tasks, one per agent —
|
|
29
|
+
cleaner-reuse, cleaner-simplification, cleaner-efficiency, cleaner-altitude —
|
|
30
|
+
each task being: "Review the changed code of {{target}} for <angle> findings.
|
|
31
|
+
Run this first to see the diff: {{git-command}}. Report file:line — one-line
|
|
32
|
+
summary — the concrete cost." Set `maxTurns: {{simplify-max-turns}}` on the call (the slowest
|
|
33
|
+
agent pins the wave's wall time; a capped agent still owes partial output).
|
|
34
|
+
The agents' angle guidance rides their own definitions — do not write the
|
|
35
|
+
agent prompts yourself or inline the diff anywhere. The tool's result carries
|
|
36
|
+
the four findings reports.
|
|
37
|
+
|
|
38
|
+
## Phase 2 — apply, verify, report
|
|
39
|
+
|
|
40
|
+
When the tool result arrives, merge/dedup the findings against your Phase 0
|
|
41
|
+
reading, then load {{skill}} via the read tool and follow its Phase 2
|
|
42
|
+
(snapshot → apply → verify → auto-revert on failure → report via
|
|
43
|
+
review_report with `fanned_out: true` — the 4-agent fan-out actually ran).
|
|
44
|
+
Never apply changes the findings don't justify.
|
|
45
|
+
{{verify}}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "/simplify trigger — SINGLE-PASS mode (angles worked inline, no fan-out)"
|
|
3
|
+
vars: [target, reasons, scope-label, too-large, git-command, context-package, skill, verify]
|
|
4
|
+
---
|
|
5
|
+
Clean up the changed code now. Target: {{target}}.
|
|
6
|
+
|
|
7
|
+
Dispatcher decided SINGLE-PASS mode ({{reasons}}). Scope: {{scope-label}}.
|
|
8
|
+
|
|
9
|
+
## Phase 0 — read the diff first
|
|
10
|
+
|
|
11
|
+
{{context-package}}
|
|
12
|
+
|
|
13
|
+
Run exactly this command (the dispatcher already resolved the scope — do not
|
|
14
|
+
re-derive a different range):
|
|
15
|
+
|
|
16
|
+
{{git-command}}
|
|
17
|
+
|
|
18
|
+
Read the full diff, then write a 2–4 line change-intent summary before
|
|
19
|
+
reviewing.{{too-large}}
|
|
20
|
+
|
|
21
|
+
Then load {{skill}} via the read tool and follow its single-pass body. Work
|
|
22
|
+
the four angles inline — do not fake fan-out.
|
|
23
|
+
{{verify}}
|
|
@@ -1,16 +1,45 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
description: "Review the current diff for correctness bugs and reuse/simplification/efficiency cleanups at the given effort level. Fresh reverse of CC `/code-review`
|
|
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."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<!--
|
|
7
|
-
Origin: Claude Code built-in skill `/
|
|
7
|
+
Origin: Claude Code built-in skill `/review` (CLI v2.1.223), freshly
|
|
8
8
|
reverse-engineered 2026-08-06 from bin/claude.exe strings. This file is
|
|
9
9
|
sourced DIRECTLY from the 2.1.223 binary — NOT carried forward from the
|
|
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
|
-
|
|
13
|
+
── RE-VERIFIED against CLI v2.1.261 (bin/claude.exe raw bytes, 2026-09-05) ──
|
|
14
|
+
- The 2.1.217-era background Workflow (phases Scope/Find/Verify/Sweep/
|
|
15
|
+
Synthesize) is GONE — the phase prompts now live inline in the skill
|
|
16
|
+
and dispatch via the Agent tool; per the bundled changelog, high/
|
|
17
|
+
xhigh/max now run inside a background agent (a CC host capability Pi
|
|
18
|
+
has no counterpart for — Pi runs inline in the session).
|
|
19
|
+
- 2.1.261 ships flag-gated effort variants (e.g. an inline, dedup-only
|
|
20
|
+
xhigh WITHOUT verify, alongside the fan-out + 1-vote-verify shape).
|
|
21
|
+
This skill keeps the uniform linearization: medium+ = fan-out +
|
|
22
|
+
grouped verify; sweep at xhigh/max.
|
|
23
|
+
- Angle bodies A–E and Reuse/Simplification/Efficiency/Conventions are
|
|
24
|
+
byte-identical to what we carried; **Altitude** gained CC's
|
|
25
|
+
root-cause phrasing + "name that change" (synced below).
|
|
26
|
+
- NEW sweep focus list ("what the first pass tends to miss") — synced
|
|
27
|
+
into Phase 3 and agents/gap-hunter.md.
|
|
28
|
+
- --comment gained GitLab: ONE general MR note via `glab mr note`
|
|
29
|
+
(glab has no single verb for line-anchored comments); GitHub inline
|
|
30
|
+
falls back to `gh api repos/{owner}/{repo}/pulls/{pr}/comments`,
|
|
31
|
+
suggestion block only when it fully fixes the issue — synced below.
|
|
32
|
+
- Output contract unchanged: {level, findings} with file/line/summary/
|
|
33
|
+
short_summary(≤60)/failure_scenario/category/verdict; outcome 三档
|
|
34
|
+
fixed / skipped / no_change_needed on re-report — all still match.
|
|
35
|
+
NEW: CC forbids creating/publishing an artifact of the review ("the
|
|
36
|
+
tool call is the report"); Pi keeps --share as the explicit opt-in
|
|
37
|
+
and forbids UNSOLICITED artifacts instead.
|
|
38
|
+
- `ultra` (deep multi-agent cloud review) still exists upstream; still
|
|
39
|
+
omitted here (requires claude.ai cloud access, which Pi lacks).
|
|
40
|
+
Sticky last-effort (codeReviewLastEffort) unchanged.
|
|
41
|
+
|
|
42
|
+
What CC 2.1.227 contained (historical basis, verified 2026-08-11):
|
|
14
43
|
- Effort quad tuple {correctnessAngles, perAngle, maxFindings, sweep}:
|
|
15
44
|
medium {3,6,8,false} / high {3,6,10,false} / xhigh {5,8,15,true} / max
|
|
16
45
|
same structure as xhigh. medium = precision; high+ = recall
|
|
@@ -32,9 +61,9 @@ description: "Review the current diff for correctness bugs and reuse/simplificat
|
|
|
32
61
|
- Fixed-later obligation (CC Q8m): later fixes in the session must
|
|
33
62
|
re-report findings with updated outcome.
|
|
34
63
|
|
|
35
|
-
Invocation: /
|
|
64
|
+
Invocation: /review [low|medium|high|xhigh|max] [--fix] [--comment] [--share] [<target>]
|
|
36
65
|
target = Class#method | file path | PR number | branch name
|
|
37
|
-
With no level given, the /
|
|
66
|
+
With no level given, the /review HANDLER reuses the last level you
|
|
38
67
|
typed (CC 2.1.223 codeReviewLastEffort); the skill always receives a
|
|
39
68
|
concrete level.
|
|
40
69
|
(CC also supports `ultra` — deep multi-agent review in the cloud.
|
|
@@ -55,16 +84,23 @@ description: "Review the current diff for correctness bugs and reuse/simplificat
|
|
|
55
84
|
(mode: parallel), or runs angles sequentially if unavailable.
|
|
56
85
|
3. Verify — CC uses the Agent tool; Pi uses `subagent` for the
|
|
57
86
|
independent verify agent (fallback: self-check).
|
|
58
|
-
4. Workflow — CC
|
|
59
|
-
Scope/Find/Verify/Sweep/Synthesize)
|
|
60
|
-
|
|
61
|
-
|
|
87
|
+
4. Workflow — CC 2.1.217 routed high/xhigh/max to a background Workflow
|
|
88
|
+
(phases Scope/Find/Verify/Sweep/Synthesize); 2.1.261 removed
|
|
89
|
+
it and runs the phases inline via its Agent tool, with high+
|
|
90
|
+
inside a background agent. Pi has neither host capability, so
|
|
91
|
+
this skill runs INLINE and linearizes those phases into the
|
|
92
|
+
flow below; the Phase 0.5 scope block is our absorption of
|
|
93
|
+
the old workflow's Scope phase (kept: it still turns N
|
|
94
|
+
repeated subagent discoveries into one).
|
|
62
95
|
5. ultra — dropped (cloud-only).
|
|
63
|
-
6. --share — CC uses the Artifact tool; Pi uses lavish-axi.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
96
|
+
6. --share — CC uses the Artifact tool; Pi uses lavish-axi. CC 2.1.261
|
|
97
|
+
forbids UNSOLICITED review artifacts; --share stays the
|
|
98
|
+
explicit opt-in.
|
|
99
|
+
7. --comment— CC uses mcp__github_inline_comment (fallback `gh api`) and
|
|
100
|
+
posts GitLab MRs as one general note via `glab mr note`; Pi
|
|
101
|
+
mirrors both fallbacks (see the --comment section).
|
|
102
|
+
|
|
103
|
+
Prerequisite: the `subagent` tool (@fyeeme/pi-subagents; parallel mode) for
|
|
68
104
|
medium and above, and for the xhigh/max gap-hunter. lavish-axi
|
|
69
105
|
for --share. low runs standalone (no subagents).
|
|
70
106
|
-->
|
|
@@ -188,6 +224,14 @@ finder agents in a single batch (mode: parallel) so they run concurrently;
|
|
|
188
224
|
otherwise do not fake the fan-out — work the angles yourself in sequence in
|
|
189
225
|
this same context, or report that the subagent capability is unavailable.
|
|
190
226
|
|
|
227
|
+
**Checking `subagent` availability** — wherever this skill says "if the
|
|
228
|
+
`subagent` tool is available", decide from THIS session's tool list, never by
|
|
229
|
+
probing: `subagent` is a pi extension tool registered alongside
|
|
230
|
+
read/bash/edit, not an MCP server tool, so the `mcp` gateway's tool search
|
|
231
|
+
answers "No tools matching subagent" even when the tool is registered and
|
|
232
|
+
callable. If it is in your toolset, use it without further verification; if it
|
|
233
|
+
is genuinely absent, take the sequential fallback above.
|
|
234
|
+
|
|
191
235
|
**Finder turn budget(Pi adaptation — the same runaway-exploration guard the
|
|
192
236
|
Phase 3 gap-hunt already carries)** — a finder that exhausts its turn cap
|
|
193
237
|
mid-read returns NOTHING and silently loses its whole angle (observed on a
|
|
@@ -198,6 +242,8 @@ every finder batch:
|
|
|
198
242
|
1. **Set `maxTurns: 20` on the `subagent` call** — the slowest finder pins
|
|
199
243
|
the wave's wall time; 20 turns covers the highest-risk hunks of any
|
|
200
244
|
single angle, and a capped finder still owes partial output (next item).
|
|
245
|
+
(20 is the built-in default — if the trigger message states a different
|
|
246
|
+
finder budget, use that instead.)
|
|
201
247
|
2. **Declare the budget inside each finder prompt** — e.g. "You have ~15
|
|
202
248
|
tool calls. Spend them on the highest-risk hunks first; when half are
|
|
203
249
|
spent, stop opening new files."
|
|
@@ -293,10 +339,11 @@ alternative.
|
|
|
293
339
|
|
|
294
340
|
### Altitude
|
|
295
341
|
|
|
296
|
-
Check that each change
|
|
297
|
-
bandaid. Special cases layered on shared
|
|
298
|
-
isn't deep enough — prefer
|
|
299
|
-
special cases
|
|
342
|
+
Check that each change fixes the root cause at the right depth rather than
|
|
343
|
+
patching a symptom with a fragile bandaid. Special cases layered on shared
|
|
344
|
+
infrastructure are a sign the fix isn't deep enough — prefer the simpler,
|
|
345
|
+
more general change to the underlying mechanism over adding special cases,
|
|
346
|
+
and name that change.
|
|
300
347
|
### Conventions (CLAUDE.md)
|
|
301
348
|
Find the CLAUDE.md files that govern the changed code: the user-level
|
|
302
349
|
~/.claude/CLAUDE.md, the repo-root CLAUDE.md, plus any CLAUDE.md or
|
|
@@ -324,7 +371,9 @@ Then verify each candidate **grouped by location**. If the `subagent` tool is
|
|
|
324
371
|
available: group the deduplicated candidates by `(file, line)`; dispatch ONE
|
|
325
372
|
independent verify agent per group (mode: parallel, one prompt per group),
|
|
326
373
|
giving it the scope block, the diff, the relevant file(s), and the full
|
|
327
|
-
candidate list for that location with each candidate's index.
|
|
374
|
+
candidate list for that location with each candidate's index. Set
|
|
375
|
+
`maxTurns: 15` on each verifier call (15 is the built-in default — a
|
|
376
|
+
different verifier budget stated in the trigger message wins). The verifier
|
|
328
377
|
returns a verdict per candidate:
|
|
329
378
|
|
|
330
379
|
```
|
|
@@ -365,7 +414,8 @@ lost an anchor. These are PLAUSIBLE.
|
|
|
365
414
|
keeps the candidate: do NOT drop it on uncertainty ("speculative", "depends
|
|
366
415
|
on runtime state"). That is the recall contract of high+. Medium is the
|
|
367
416
|
precision level: there, additionally weigh whether a maintainer would act on
|
|
368
|
-
the finding before keeping it.
|
|
417
|
+
the finding before keeping it. At xhigh/max a missed bug ships — err on the
|
|
418
|
+
side of surfacing hardest there.
|
|
369
419
|
|
|
370
420
|
**REFUTED** only when constructible from the code: factually wrong (quote the
|
|
371
421
|
actual line); provably impossible (type/constant/invariant — show it); already
|
|
@@ -375,8 +425,13 @@ handled in this diff (cite the guard); or pure style with no observable effect.
|
|
|
375
425
|
|
|
376
426
|
At **xhigh and max**, after Phase 2 dedup, dispatch ONE fresh finder agent (the
|
|
377
427
|
`subagent` tool) that has never seen the candidates and hunts only for gaps not
|
|
378
|
-
already listed — **at most 8 new candidates**.
|
|
379
|
-
|
|
428
|
+
already listed — **at most 8 new candidates**. Focus the hunt on what the first
|
|
429
|
+
pass tends to miss (CC 2.1.261 sweep list): moved/extracted code that dropped a
|
|
430
|
+
guard or anchor; second-tier footguns (dataclass default evaluated once,
|
|
431
|
+
`hash()` non-determinism, lock-scope shrink, predicate methods with side
|
|
432
|
+
effects); setup/teardown asymmetry in tests; config defaults flipped. If
|
|
433
|
+
nothing new turns up, return an empty sweep — do not pad. Feed anything it
|
|
434
|
+
finds back through Phase 2 verify before keeping it.
|
|
380
435
|
|
|
381
436
|
Constrain it so exploration can't run away (Pi adaptation — CC's workflow bounds
|
|
382
437
|
this differently):
|
|
@@ -386,7 +441,9 @@ this differently):
|
|
|
386
441
|
results: the diff, the enclosing functions, the deduplicated finding list,
|
|
387
442
|
and any search results. The gap-hunt agent **analyzes**, it does not
|
|
388
443
|
**discover**.
|
|
389
|
-
2. **Set `maxTurns: 15`** on the `subagent` call — caps it at 15 assistant turns
|
|
444
|
+
2. **Set `maxTurns: 15`** on the `subagent` call — caps it at 15 assistant turns
|
|
445
|
+
(built-in default — a different gap-hunt budget stated in the trigger
|
|
446
|
+
message wins).
|
|
390
447
|
3. **Declare a tool-call budget in the prompt** — e.g. "You have ONLY 3 tool
|
|
391
448
|
calls to read files. Read them now, then analyze from this message's
|
|
392
449
|
context."
|
|
@@ -405,7 +462,11 @@ to CC's `ReportFindings`) — call it **once** with
|
|
|
405
462
|
ranked most-severe first (empty array if nothing survived verification). The
|
|
406
463
|
tool renders the Chinese Markdown report (table + details) back to the
|
|
407
464
|
conversation AND writes a machine-readable JSON to `<cwd>/.pi/review/` for CI /
|
|
408
|
-
`--fix` / `--comment`. Do **not** also hand-write the Markdown table.
|
|
465
|
+
`--fix` / `--comment`. Do **not** also hand-write the Markdown table. Also do
|
|
466
|
+
**not** spontaneously produce a review page/artifact when `--share` was not
|
|
467
|
+
passed — the `review_report` call IS the report (CC 2.1.261: "do not create
|
|
468
|
+
or publish an artifact of the review — the tool call is the report");
|
|
469
|
+
`--share` is the only explicit exception.
|
|
409
470
|
|
|
410
471
|
Each finding in the array carries: `file`, `line` (optional), `category`
|
|
411
472
|
(`correctness` / `reuse` / `simplification` / `efficiency` / `altitude` /
|
|
@@ -452,31 +513,50 @@ findings to the working tree instead of stopping at the report: fix each one
|
|
|
452
513
|
directly — correctness bugs and reuse/simplification/efficiency cleanups alike.
|
|
453
514
|
Skip any finding whose fix would change intended behavior, require changes well
|
|
454
515
|
outside the reviewed diff, or that you judge to be a false positive — note the
|
|
455
|
-
skip rather than arguing with it.
|
|
516
|
+
skip rather than arguing with it. If a verification command was detected (see
|
|
517
|
+
the trigger message's verification line), run it BEFORE re-reporting: a finding
|
|
518
|
+
whose fix breaks verification is reverted and re-reported as `skipped`
|
|
519
|
+
(verification is opportunistic — with no detected command, re-report directly
|
|
520
|
+
and say verification was not run). Then call `review_report` once more to
|
|
456
521
|
re-report (same `report_id`), setting `outcome` on each finding (`fixed` =
|
|
457
522
|
applied and verified / `skipped` = real but not applied, incl. reverted /
|
|
458
523
|
`no_change_needed` = not applicable or already handled). This structured
|
|
459
524
|
re-report replaces the hand-written summary and makes the fix result
|
|
460
|
-
machine-consumable.
|
|
525
|
+
machine-consumable. Make that call immediately after the fixes land, before
|
|
526
|
+
any prose summary (CC 2.1.261: the host UI's per-finding status updates only
|
|
527
|
+
from it).
|
|
461
528
|
If `review_report` is unavailable, fall back to a brief text summary of what was
|
|
462
529
|
fixed and what was skipped.
|
|
463
530
|
|
|
464
531
|
## Posting comments (--comment)
|
|
465
532
|
|
|
466
|
-
The `--comment` flag was passed.
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
533
|
+
The `--comment` flag was passed. After producing the findings list:
|
|
534
|
+
|
|
535
|
+
- **GitHub PR target** — post each finding as an inline PR comment on the
|
|
536
|
+
corresponding `file`/`line`, one call per finding; include a suggestion
|
|
537
|
+
block only when it fully fixes the issue (CC 2.1.261 rule). If no
|
|
538
|
+
inline-comment tool is available on Pi, fall back to `gh api
|
|
539
|
+
repos/{owner}/{repo}/pulls/{pr}/comments`; if `gh` is unavailable too,
|
|
540
|
+
print the findings as text and note that inline posting was unavailable.
|
|
541
|
+
- **GitLab MR target** — post the findings as ONE general MR note via
|
|
542
|
+
`glab mr note -m "<body>"` from inside the project's checkout — every
|
|
543
|
+
finding with its file:line, the issue, and the suggested fix (CC 2.1.261;
|
|
544
|
+
glab has no single verb for line-anchored comments, so post the general
|
|
545
|
+
note unless the user explicitly asks for inline threads — those need
|
|
546
|
+
`glab api projects/:id/merge_requests/:iid/discussions`). If `glab` is
|
|
547
|
+
unavailable, print the findings instead.
|
|
548
|
+
- **Not a PR/MR target** — print the findings to the terminal and note that
|
|
549
|
+
`--comment` was ignored.
|
|
470
550
|
|
|
471
551
|
## Publishing a shareable review (--share)
|
|
472
552
|
|
|
473
553
|
The `--share` flag was passed. After producing the findings list, also publish
|
|
474
554
|
them as an artifact so they can be shared and iterated on outside the terminal.
|
|
475
555
|
|
|
476
|
-
1. Write a self-contained HTML review page to `.lavish/
|
|
556
|
+
1. Write a self-contained HTML review page to `.lavish/review-<n>.html`
|
|
477
557
|
(create `.lavish/` in the repo root if missing). The page must render with no
|
|
478
558
|
server and carry every finding plus its context.
|
|
479
|
-
2. Open it with `lavish-axi .lavish/
|
|
559
|
+
2. Open it with `lavish-axi .lavish/review-<n>.html` so the reader can
|
|
480
560
|
review, annotate, and send feedback back through the poll.
|
|
481
561
|
|
|
482
562
|
Page structure (follow lavish design guidance — clear visual hierarchy, no
|
package/skills/simplify/SKILL.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: simplify
|
|
3
|
-
description: "Review the changed code for reuse, simplification, efficiency, and altitude cleanups, then apply the fixes. Quality only — it does not hunt for bugs; use /
|
|
3
|
+
description: "Review the changed code for reuse, simplification, efficiency, and altitude cleanups, then apply the fixes. Quality only — it does not hunt for bugs; use /review for that. v3 (from Claude Code CLI v2.1.227, symbol-level verified; re-verified against v2.1.261 on 2026-09-05 — bodies unchanged except Altitude) — 4 cleanup agents fan out in parallel when context allows, else a single-pass inline cleanup; either way the fixes are applied, verified against the project's check command, and auto-reverted on failure, then reported as structured outcomes via review_report."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<!--
|
|
7
7
|
Origin: Claude Code built-in skill `/simplify` (CLI v2.1.227), reverse-
|
|
8
|
-
engineered from bin/claude.exe raw bytes. Pi registers it as /
|
|
8
|
+
engineered from bin/claude.exe raw bytes. Pi registers it as /simplify.
|
|
9
9
|
|
|
10
10
|
Lineage:
|
|
11
11
|
v2.1.220 → the first reconstruction (v1)
|
|
@@ -18,6 +18,16 @@ description: "Review the changed code for reuse, simplification, efficiency, and
|
|
|
18
18
|
VBv/KBv (with interpolated c$e / m7t / u$e / d$e / p$e) are
|
|
19
19
|
unchanged; the mode guard is Dii (see below); fan-out defaults
|
|
20
20
|
nJu=20 / lKs=50 are now mirrored in the subagent tool.
|
|
21
|
+
v2.1.261 → re-verified 2026-09-05 from raw bytes: the two mode bodies,
|
|
22
|
+
the 4-angle set, and the Phase 2 apply rules are unchanged;
|
|
23
|
+
the Altitude angle gained CC's root-cause phrasing + "name
|
|
24
|
+
that change" (synced here and in the review skill). The command
|
|
25
|
+
description ("Clean up the changed code without changing
|
|
26
|
+
behavior"; "Quality only — it does not hunt for bugs; use
|
|
27
|
+
/code-review for that") and the Agent-tool fan-out ("all in a
|
|
28
|
+
single message so they run concurrently") are unchanged.
|
|
29
|
+
The /code-review↔/simplify division of labor is now stated
|
|
30
|
+
explicitly in both skills upstream — same as here.
|
|
21
31
|
|
|
22
32
|
CC 2.1.227 empirical evidence (symbol-level, extracted from bin/claude.exe):
|
|
23
33
|
- $u({name: "simplify", ..., getPromptForCommand(args, ctx)}) registers the
|
|
@@ -31,14 +41,14 @@ description: "Review the changed code for reuse, simplification, efficiency, and
|
|
|
31
41
|
default 3, feature flag tengu_hazel_trellis) OR the Agent tool is not in
|
|
32
42
|
the options.tools allowlist (Pa matches by name/aliases).
|
|
33
43
|
- VBv / KBv — the two mode-body templates; interpolated variables shared
|
|
34
|
-
with
|
|
44
|
+
with the review skill: c$e (Phase 0), m7t/u$e/d$e/p$e (the 4 cleanup angles).
|
|
35
45
|
- nJu() = CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS ?? 20; lKs =
|
|
36
46
|
FORKED_AGENT_DEFAULT_MAX_TURNS = 50 — mirrored as the subagent tool's
|
|
37
47
|
defaults (PI_MAX_CONCURRENT_SUBAGENTS env still overrides the ceiling).
|
|
38
48
|
|
|
39
49
|
Bundled: ships inside the pi-review extension (skills/simplify/SKILL.md).
|
|
40
50
|
|
|
41
|
-
Invocation: /
|
|
51
|
+
Invocation: /simplify [<target>]
|
|
42
52
|
target = file path | PR number | branch name
|
|
43
53
|
|
|
44
54
|
════════════════════════════════════════════════════════════════════════
|
|
@@ -59,34 +69,34 @@ description: "Review the changed code for reuse, simplification, efficiency, and
|
|
|
59
69
|
Dii. The cleanup agents' tool whitelist (read/grep/find/ls/bash) never
|
|
60
70
|
includes a fan-out tool, so recursion stays physically bounded
|
|
61
71
|
regardless of tool registration. The decision is made
|
|
62
|
-
DETERMINISTICALLY by the /
|
|
72
|
+
DETERMINISTICALLY by the /simplify handler — it can
|
|
63
73
|
read ctx.getContextUsage(), which a pure-prompt skill cannot — and announced
|
|
64
74
|
in the trigger message; this skill just provides the two mode bodies.
|
|
65
|
-
3. Command — CC: /simplify; Pi: /
|
|
75
|
+
3. Command — CC: /simplify; Pi: /simplify.
|
|
66
76
|
4. Dispatch — CC's lead model writes the 4 Agent prompts itself after its
|
|
67
77
|
visible Phase 0. Pi keeps the same TIMELINE but moves the packaging into
|
|
68
78
|
code: the trigger message carries the handler-resolved scope, the
|
|
69
79
|
changed-file index, and the exact `git -C … diff …` command; the model
|
|
70
80
|
runs it, reads the diff, writes a change-intent summary, and THEN calls
|
|
71
|
-
the `
|
|
72
|
-
|
|
73
|
-
text — CC's own transcripts show its model skipping the diff inlining),
|
|
74
|
-
embeds it in each task, and spawns the agents; its result carries the
|
|
81
|
+
the `subagent` tool in parallel mode (the counterpart of CC's Agent
|
|
82
|
+
call) with the 4 bundled cleaner agents; the tool result carries the
|
|
75
83
|
findings back into the same turn for Phase 2.
|
|
76
84
|
|
|
77
85
|
Prerequisite: the `review_report` tool (provided by the pi-review extension)
|
|
78
86
|
for the Phase 2 structured outcome report. PARALLEL MODE
|
|
79
|
-
additionally needs the `
|
|
87
|
+
additionally needs the `subagent` tool (@fyeeme/pi-subagents;
|
|
80
88
|
registered whenever fan-out is allowed for this process — the
|
|
81
|
-
recursion guard; the
|
|
89
|
+
recursion guard; the dispatcher only picks PARALLEL when it
|
|
90
|
+
is) plus the bundled agents cleaner-reuse /
|
|
91
|
+
cleaner-simplification / cleaner-efficiency / cleaner-altitude.
|
|
82
92
|
SINGLE-PASS MODE runs standalone apart from `review_report`.
|
|
83
93
|
-->
|
|
84
94
|
|
|
85
95
|
You are improving the quality of the changed code, not hunting for bugs. Review
|
|
86
96
|
it for reuse, simplification, efficiency, and altitude issues, then fix what you
|
|
87
|
-
find. Do not look for correctness bugs — that is what `/
|
|
97
|
+
find. Do not look for correctness bugs — that is what `/review` is for.
|
|
88
98
|
|
|
89
|
-
The `/
|
|
99
|
+
The `/simplify` handler has already chosen the mode (PARALLEL or
|
|
90
100
|
SINGLE-PASS) from real context usage and announced it in the trigger message.
|
|
91
101
|
Follow the body that matches; do not fake the mode you weren't asked to run.
|
|
92
102
|
Both modes open the same way: the trigger message carries the handler-resolved
|
|
@@ -96,7 +106,7 @@ VISIBLE, model-run step before anything launches.
|
|
|
96
106
|
## Phase 0 — Gather the diff
|
|
97
107
|
|
|
98
108
|
When the trigger message carries a handler-resolved scope (it always does for
|
|
99
|
-
/
|
|
109
|
+
/simplify), use THAT: run the exact `git -C … diff …` command the trigger
|
|
100
110
|
provides — the handler already ran the cascade (merge-base → HEAD → staged →
|
|
101
111
|
unstaged) to pick it — read the full diff, and write a 2–4 line change-intent
|
|
102
112
|
summary before anything else. Do not re-derive a different range. That summary
|
|
@@ -115,27 +125,27 @@ review that target instead. Treat this diff as the review scope.)
|
|
|
115
125
|
|
|
116
126
|
# PARALLEL MODE (context not near-full AND diff under the fan-out threshold AND fan-out available)
|
|
117
127
|
|
|
118
|
-
`/
|
|
128
|
+
`/simplify → visible Phase 0 (read the diff, summarize) → subagent tool (parallel, 4 cleaner agents) → apply the fixes`
|
|
119
129
|
|
|
120
130
|
## Phase 1 — Review (4 cleanup agents in parallel)
|
|
121
131
|
|
|
122
|
-
After your Phase 0 summary, call the `
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
each
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
with `file`, `line`, a one-line `summary`, and the
|
|
129
|
-
duplicated, wasted, or harder to maintain). The agent
|
|
130
|
-
agent widget / FleetView and respect the
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
132
|
+
After your Phase 0 summary, call the `subagent` tool exactly as the trigger
|
|
133
|
+
message instructs: parallel mode, 4 tasks, one per bundled agent —
|
|
134
|
+
cleaner-reuse, cleaner-simplification, cleaner-efficiency, cleaner-altitude —
|
|
135
|
+
each with `maxTurns: 15` (set it on the call; 15 is the built-in default — a
|
|
136
|
+
different budget stated in the trigger message wins). The agents' angle guidance
|
|
137
|
+
rides their own definitions (read-only tool whitelist read/grep/find/ls/bash);
|
|
138
|
+
each returns its findings with `file`, `line`, a one-line `summary`, and the
|
|
139
|
+
concrete cost (what is duplicated, wasted, or harder to maintain). The agent
|
|
140
|
+
rows appear live in the agent widget / FleetView and respect the
|
|
141
|
+
`maxConcurrency` setting.
|
|
142
|
+
|
|
143
|
+
Do NOT write the four agent prompts yourself or inline the diff into any
|
|
144
|
+
prompt. If the fan-out conditions no longer hold (context grew while you read
|
|
145
|
+
the diff), fall back to the SINGLE-PASS body below and report `fanned_out:
|
|
146
|
+
false`. When the tool result arrives, merge and deduplicate the findings
|
|
147
|
+
against your first-hand Phase 0 reading. The four angles below are what the
|
|
148
|
+
agents were asked to find.
|
|
139
149
|
|
|
140
150
|
### Reuse
|
|
141
151
|
|
|
@@ -161,10 +171,11 @@ alternative.
|
|
|
161
171
|
|
|
162
172
|
### Altitude
|
|
163
173
|
|
|
164
|
-
Check that each change
|
|
165
|
-
bandaid. Special cases layered on shared
|
|
166
|
-
isn't deep enough — prefer
|
|
167
|
-
special cases
|
|
174
|
+
Check that each change fixes the root cause at the right depth rather than
|
|
175
|
+
patching a symptom with a fragile bandaid. Special cases layered on shared
|
|
176
|
+
infrastructure are a sign the fix isn't deep enough — prefer the simpler,
|
|
177
|
+
more general change to the underlying mechanism over adding special cases,
|
|
178
|
+
and name that change.
|
|
168
179
|
## Phase 2 — Apply, verify, and report
|
|
169
180
|
|
|
170
181
|
Follow the shared **Phase 2** procedure at the end of this skill (snapshot → apply → verify → auto-revert on failure → report via `review_report`). The parallel fan-out only changes how findings are gathered (Phase 1 — done by the handler); applying, verifying, and reporting are identical across modes. Set `fanned_out: true` in the report since the 4-agent fan-out actually ran.
|
|
@@ -173,7 +184,7 @@ Follow the shared **Phase 2** procedure at the end of this skill (snapshot → a
|
|
|
173
184
|
|
|
174
185
|
# SINGLE-PASS MODE (context near-full OR diff too large OR fan-out unavailable)
|
|
175
186
|
|
|
176
|
-
`/
|
|
187
|
+
`/simplify → handler decided single-pass (reasons in the trigger message) → inline cleanup → apply the fixes`
|
|
177
188
|
|
|
178
189
|
The handler decided against the 4-agent fan-out (context near-full, diff too
|
|
179
190
|
large, fan-out unavailable, or usage unmeasurable — the exact reasons are in
|
|
@@ -212,10 +223,11 @@ alternative.
|
|
|
212
223
|
|
|
213
224
|
### Altitude
|
|
214
225
|
|
|
215
|
-
Check that each change
|
|
216
|
-
bandaid. Special cases layered on shared
|
|
217
|
-
isn't deep enough — prefer
|
|
218
|
-
special cases
|
|
226
|
+
Check that each change fixes the root cause at the right depth rather than
|
|
227
|
+
patching a symptom with a fragile bandaid. Special cases layered on shared
|
|
228
|
+
infrastructure are a sign the fix isn't deep enough — prefer the simpler,
|
|
229
|
+
more general change to the underlying mechanism over adding special cases,
|
|
230
|
+
and name that change.
|
|
219
231
|
## Phase 2 — Apply, verify, and report
|
|
220
232
|
|
|
221
233
|
Follow the shared **Phase 2** procedure at the end of this skill (snapshot → apply → verify → auto-revert on failure → report via `review_report`). Single-pass vs parallel only changes how findings are gathered (Phase 1); applying, verifying, and reporting are identical across modes. Set `fanned_out: false` in the report so a reader is not misled into thinking the 4-agent fan-out ran.
|
|
@@ -225,7 +237,7 @@ Follow the shared **Phase 2** procedure at the end of this skill (snapshot → a
|
|
|
225
237
|
# Phase 2 — Apply, verify, and report (shared by both modes)
|
|
226
238
|
|
|
227
239
|
Dedup findings that point at the same line or mechanism first. Then apply,
|
|
228
|
-
verify, and report. This safety net is what distinguishes `/
|
|
240
|
+
verify, and report. This safety net is what distinguishes `/simplify` from
|
|
229
241
|
a blind cleanup: a finding is only "done" once it is applied AND the project
|
|
230
242
|
still verifies — otherwise it is reverted.
|
|
231
243
|
|
|
@@ -246,7 +258,7 @@ for any file in a subdirectory. If a fix CREATES a new file, record its path so
|
|
|
246
258
|
Step 3a can remove it on rollback (it has no baseline entry).
|
|
247
259
|
|
|
248
260
|
This baseline captures the working-tree state **including** the user's
|
|
249
|
-
uncommitted changes — reverting to it undoes only `/
|
|
261
|
+
uncommitted changes — reverting to it undoes only `/simplify`'s fixes,
|
|
250
262
|
never the user's diff. Do **not** use `git checkout` / `git restore` to revert:
|
|
251
263
|
that would discard the user's intended changes too.
|
|
252
264
|
|