@unifan/pi-unifan-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.
Files changed (42) hide show
  1. package/README.md +111 -0
  2. package/extensions/review/CHANGELOG.md +540 -0
  3. package/extensions/review/LICENSE +15 -0
  4. package/extensions/review/README.md +55 -0
  5. package/extensions/review/agents/bugbot.md +46 -0
  6. package/extensions/review/agents/claude-md-compliance.md +46 -0
  7. package/extensions/review/agents/code-comments.md +43 -0
  8. package/extensions/review/agents/conventions.md +41 -0
  9. package/extensions/review/agents/gate.md +70 -0
  10. package/extensions/review/agents/history-context.md +45 -0
  11. package/extensions/review/agents/lite-review.md +51 -0
  12. package/extensions/review/agents/security-review.md +45 -0
  13. package/extensions/review/index.ts +205 -0
  14. package/extensions/review/package.json +38 -0
  15. package/extensions/review/reference/README.md +20 -0
  16. package/extensions/review/reference/claude-code-review.md +133 -0
  17. package/extensions/review/reference/cursor-review-skills.md +72 -0
  18. package/extensions/review/reference/pi-review-roadmap.md +183 -0
  19. package/extensions/review/reference/structured-output.md +26 -0
  20. package/extensions/review/reference/v0.2-plan.md +268 -0
  21. package/extensions/review/src/cli-args.ts +105 -0
  22. package/extensions/review/src/config.ts +340 -0
  23. package/extensions/review/src/directive.ts +481 -0
  24. package/extensions/review/src/gate-enforce.ts +151 -0
  25. package/extensions/review/src/lean-agents.ts +105 -0
  26. package/extensions/review/src/pr-ref.ts +39 -0
  27. package/extensions/review/src/report-tool.ts +394 -0
  28. package/extensions/review/src/report.ts +399 -0
  29. package/extensions/review/src/review-report.ts +279 -0
  30. package/extensions/review/src/review-run.ts +568 -0
  31. package/extensions/review/src/target-workspace.ts +239 -0
  32. package/extensions/review/src/tool-wrapper.ts +75 -0
  33. package/extensions/review/src/tui-renderer.ts +92 -0
  34. package/extensions/review/src/types.ts +207 -0
  35. package/extensions/review/src/workflow-schemas.ts +172 -0
  36. package/extensions/sessions/README.md +41 -0
  37. package/extensions/sessions/index.ts +862 -0
  38. package/extensions/sessions/package.json +21 -0
  39. package/extensions/sessions/sessions.ts +264 -0
  40. package/package.json +36 -0
  41. package/skills/README.md +29 -0
  42. package/tsconfig.json +14 -0
package/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # 🌟 pi-unifan-zh (Pi 中文扩展与工具库)
2
+
3
+ 专为 **Pi Coding Agent** 设计的高质量中文扩展合集与独立插件库。
4
+
5
+ 支持 **“全家桶一键整包安装”** 与 **“按需单个插件独立安装”** 双模式架构。
6
+
7
+ ---
8
+
9
+ ## 📁 项目目录结构
10
+
11
+ ```text
12
+ pi-unifan-zh/
13
+ ├── package.json # 根包配置(支持整包一键安装所有扩展与技能)
14
+ ├── tsconfig.json # TypeScript 编译配置
15
+ ├── .gitignore # Git 忽略规则
16
+ ├── README.md # 仓库主说明文档
17
+ ├── extensions/ # 📦 独立插件集目录
18
+ │ ├── sessions/ # 📜 历史会话管理器(双栏实时预览与恢复·中文增强版)
19
+ │ │ ├── package.json # 独立包配置
20
+ │ │ ├── index.ts # TUI 交互与命令逻辑
21
+ │ │ ├── sessions.ts # 会话数据提取与格式化
22
+ │ │ └── README.md # 插件说明
23
+ │ └── review/ # 🔍 AI 并发代码审查(5 专家并发 + 门禁裁判·中文增强版)
24
+ │ ├── package.json # 独立包配置
25
+ │ ├── index.ts # 命令入口与工作流注册
26
+ │ ├── agents/ # 6 大专家与门禁 Prompt 定义
27
+ │ ├── src/ # 核心审查逻辑与中文报告渲染器
28
+ │ └── README.md # 插件说明
29
+ └── skills/ # 🎯 自定义技能目录(存放自定义 SKILL.md)
30
+ └── README.md
31
+ ```
32
+
33
+ ---
34
+
35
+ ## 🚀 安装指南
36
+
37
+ ### 模式 A:一键安装整包(包含库内所有插件与技能)
38
+
39
+ #### 1. 远程一键安装(推荐):
40
+ ```bash
41
+ pi install git:github.com/821869798/pi-unifan-zh
42
+ ```
43
+
44
+ #### 2. 本地安装测试:
45
+ ```bash
46
+ pi install D:/program/my/pi-unifan-zh
47
+ ```
48
+
49
+ ---
50
+
51
+ ### 模式 B:按需单独安装单个插件
52
+
53
+ 每个插件都位于 `extensions/<插件名>/` 下,自带独立的 `package.json`:
54
+
55
+ #### 1. 仅安装 `sessions`(历史会话管理器·中文版):
56
+ ```bash
57
+ pi install D:/program/my/pi-unifan-zh/extensions/sessions
58
+ ```
59
+
60
+ #### 2. 仅安装 `review`(AI 并发代码审查·中文版):
61
+ ```bash
62
+ pi install D:/program/my/pi-unifan-zh/extensions/review
63
+ ```
64
+
65
+ ---
66
+
67
+ ## 📦 已包含的扩展清单
68
+
69
+ ### 1. 📜 `sessions`(历史会话管理器·中文版)
70
+ - **命令**:`/sessions`
71
+ - **特性**:
72
+ - 双栏全屏 TUI 视图(左侧选会话与 Git 变更统计,右侧毫秒级实时滚屏预览完整对话)。
73
+ - 支持 `◆ 用户`、`● 助手`、`◌ 思考过程`、`▸ 工具调用` 与折叠。
74
+ - 界面与时间提示(刚刚/X分钟前/昨天)全面中文化。
75
+ - 独立运行,零多余 Token 消耗,不引发卡顿。
76
+
77
+ ### 2. 🔍 `review`(AI 并发代码审查·中文版)
78
+ - **命令**:
79
+ - `/review`:全量 5 专家深度并发审查 + 门禁裁判。
80
+ - `/review --lite`:极速单专家快速体检(超省 Token)。
81
+ - `/review 重点看并发安全`:带侧重点定制审查。
82
+ - `/review-show`:重新显示最近一次审查报告。
83
+ - `/review-agents`:查看各专家代理状态与模型分配。
84
+ - **特性**:
85
+ - 5 个专业 AI 审查专家(Bug、安全、规范、历史回归、注释)并发排查。
86
+ - 1 个门禁总裁判(Gate AI)智能去重并过滤误报,给出最终裁决。
87
+ - 报告全中文结构化展示(致命阻断 / 严重 / 次要 / 细节优化)。
88
+
89
+ ---
90
+
91
+ ## 🛠️ 后续如何开发新插件?
92
+
93
+ 1. 在 `extensions/` 目录下新建一个插件文件夹(例如 `extensions/my-tool/`)。
94
+ 2. 在该文件夹内创建 `package.json` 和 `index.ts`。
95
+ 3. 在根目录的 `package.json` 中的 `"pi"."extensions"` 数组添加新入口:
96
+ ```json
97
+ "pi": {
98
+ "extensions": [
99
+ "./extensions/sessions/index.ts",
100
+ "./extensions/review/index.ts",
101
+ "./extensions/my-tool/index.ts"
102
+ ]
103
+ }
104
+ ```
105
+ 4. 运行 `pi reload` 即可自动生效!
106
+
107
+ ---
108
+
109
+ ## 📄 开源协议
110
+
111
+ MIT License
@@ -0,0 +1,540 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [0.8.3] - 2026-08-27
8
+
9
+ ### Changed — report card UX (user decisions)
10
+ - **The `[pi-review]` echo is sent immediately** when `/review` runs, before
11
+ the (potentially minutes-long) diff/clone preparation — no more long
12
+ silent gap after submitting the command.
13
+ - **The report card always renders the FULL report.** The collapsed/expanded
14
+ split (one preview line unless the host's global expansion toggle was on)
15
+ made the card look like the report "didn't show up". The card now renders
16
+ a `pi-review result:` summary line at the TOP with the full report body
17
+ below it, regardless of the expansion state.
18
+ - **Summary line format:** `pi-review result: Approve · 0 blocker · 0 major
19
+ · 0 minor · 0 nit` (title-case verdict; counts kept — user approved this
20
+ line, just wanted the new prefix).
21
+ - The `pi_review_report` tool result line uses the same
22
+ `pi-review result: ...` format (was `pi-review verdict: ... —`), and now
23
+ points at the rendered card instead of duplicating it.
24
+
25
+ [0.8.3]: https://github.com/GeorgeDong32/pi-review/compare/v0.8.2...v0.8.3
26
+
27
+ ## [0.8.2] - 2026-08-27
28
+
29
+ ### Fixed
30
+ - **The gate-fallback branch now keeps the configured thinking level** via
31
+ the child `thinking` parameter (consumed as an override upstream). When a
32
+ proxy provider's model verification rejects the configured model and the
33
+ gate retries with an inherited model, `gate.thinking` (e.g. `"high"`) is
34
+ no longer silently dropped.
35
+ - Ops note: the model-verification strictness itself is addressed by a
36
+ local patch to the installed pi-subagents (`~/.pi/agent/local-patches/`):
37
+ containment of the observed id within the registered id passes as a
38
+ warning-level match. That patch is lost on pi-subagents upgrades — re-apply
39
+ from the archived patch file; the in-script fallback here remains the
40
+ safety net either way.
41
+
42
+ [0.8.2]: https://github.com/GeorgeDong32/pi-review/compare/v0.8.1...v0.8.2
43
+
44
+ ## [0.8.1] - 2026-08-27
45
+
46
+ ### Fixed
47
+ - **Gate no longer dies on proxy providers' model verification.** First
48
+ v0.8.0 field run: reviewers all completed, then the gate was rejected with
49
+ `model_verification_failed: child reported a different model than the
50
+ launch candidate. Expected 'CPA/Minimax/MiniMax-M2.7:high' but observed
51
+ 'MiniMax-M2.7'` — proxy providers report the bare upstream model id,
52
+ which never matches the registered `provider/id` form. The gate launch is
53
+ now wrapped in try/catch with a one-shot retry under the `gate-fallback`
54
+ key that inherits the parent session model (the same path the reviewers
55
+ use, which is why they never hit this). A second failure rejects as
56
+ before; the configured model is still preferred when it works.
57
+ (Different key because the runtime rejects same-key launches with
58
+ different params.)
59
+
60
+ [0.8.1]: https://github.com/GeorgeDong32/pi-review/compare/v0.8.0...v0.8.1
61
+
62
+ ## [0.8.0] - 2026-08-27
63
+
64
+ ### Changed — Markdown-first output contract (user decision)
65
+ **Structured output is gone from the fan-out.** The `outputSchema` /
66
+ `structured_output`-tool finish contract kept failing in the field (v0.7.5:
67
+ "Missing structured_output call" after tool-budget wrap-ups; models chose
68
+ plain-text finishes). v0.8 removes the contract instead of patching it:
69
+
70
+ - **Reviewers (all 6 lanes) return Markdown reports** — Summary / Findings /
71
+ Coverage sections, findings as `- [SEVERITY|category|confidence]
72
+ \`file:line\` — evidence` bullets, `SKIPPED: <reason>` for non-applicable
73
+ lanes. Nothing to un-escape, nothing to fail.
74
+ - **The gate (and the lite-reviewer) end their Markdown with exactly one
75
+ fenced ```json verdict block** ({ status, verdict, issues[],
76
+ dispositions[], reason }). That block is the only machine-read point;
77
+ `pi_review_report` extracts it (fenced-first, brace-lift fallback, last
78
+ well-shaped block wins) and re-applies the deterministic verdict rules on
79
+ its issues.
80
+ - **The gate's inputs are the reviewers' Markdown reports** (inlined into
81
+ its task, FAILED reviewers annotated) — the gate reads them the way an
82
+ LLM reads best, re-scores, verifies blocker/majors against the diff +
83
+ workspace, and emits the verdict block.
84
+ - The workflowScript shrinks again (~17 KB → ~9 KB full mode, 1.3 KB lite):
85
+ no schema constants, no per-child `outputSchema`. Verified against the
86
+ real installed pi-subagents 0.55.0 validator (PASS), the read-only task
87
+ classifier (all 6 tasks read-only with Markdown payloads), and an
88
+ end-to-end stub run including gate-Markdown → verdict-block extraction.
89
+ - Report rendering: reviewer Markdown is rendered verbatim under the status
90
+ header; gate synthesis + surviving issues + dispositions follow. All
91
+ reviewers skipped can no longer produce a clean APPROVE (downgraded to
92
+ comment); a gate that ran but produced no parseable verdict block reports
93
+ `no-gate`.
94
+
95
+ [0.8.0]: https://github.com/GeorgeDong32/pi-review/compare/v0.7.5...v0.8.0
96
+
97
+ ## [0.7.5] - 2026-08-27
98
+
99
+ Hotfix for the first v0.7.4 field run: the workflowScript finally executed —
100
+ reviewers really ran (bugbot: 3m56s, 20 tool uses) — but steps ended with
101
+ `Error: Missing structured_output call; this step has outputSchema and must
102
+ finish by calling structured_output`, and bugbot's output file contained
103
+ only "I have enough context to finalize the review. Let me compile
104
+ findings." — the JSON never made it out.
105
+
106
+ ### Fixed
107
+ - **Mandatory finish rule in every bundled agent prompt.** The old wording
108
+ ("Return this JSON as your final reply. If the `structured_output` tool
109
+ is available, call it once instead") let models choose a plain-text
110
+ finish — fatal once the soft tool budget nudged a wrap-up. All 8 agents
111
+ now carry a FINISH RULE block: the final action MUST be a single
112
+ `structured_output` call (the only accepted finish; a plain-text reply
113
+ FAILS the step), keep one tool call in reserve, and when the budget
114
+ nudges, stop exploring and call it immediately.
115
+ - **Salvage path for prose finishes:** when a step fails with "Missing
116
+ structured_output call" but its output text contains the JSON object
117
+ (often wrapped in prose or a fence), `pi_review_report` now lifts the
118
+ outermost `{…}` block and reports the reviewer as `limited` with its
119
+ findings intact, instead of `failed` with everything dropped. Truly
120
+ empty outputs still report `failed`, and a run whose reviewers are all
121
+ salvaged can no longer be misreported as `error` (all-limited →
122
+ `partial`).
123
+
124
+ [0.7.5]: https://github.com/GeorgeDong32/pi-review/compare/v0.7.4...v0.7.5
125
+
126
+ ## [0.7.4] - 2026-08-27
127
+
128
+ Hotfix for the 2026-08-26 16:14 session: with v0.7.3's short-line script the
129
+ main agent's copy finally survived intact — and the workflow was then
130
+ rejected by pi-subagents' **AST validation**: "workflowScript does not
131
+ support nested async functions". The gate had been launched as
132
+ `gate: await (async () => { ... })()` since v0.7.0: an async IIFE, which the
133
+ upstream walker (scripted-workflow.ts) rejects outright. Every earlier
134
+ failure that got past the syntax stage had died at this same check — it was
135
+ simply invisible while copies were corrupting the script first.
136
+
137
+ ### Fixed
138
+ - **The gate launch is now plain top-level statements** — `const
139
+ reviewerInputs = reviewers.map(...)` (sync arrows are allowed), `const
140
+ gateRun = await runs.run('gate', {...})`, `const gate = {...}`, then
141
+ `return { reviewers, gate, reviewersShaped }`. No async IIFE anywhere.
142
+ - **Verified against the real installed pi-subagents 0.55.0
143
+ `validateWorkflowScript`** (exported from the package): full and lite
144
+ scripts both pass, and the script still executes end-to-end with stub
145
+ runs.
146
+ - Contract test pins the constraint: the generated script must contain no
147
+ `async` keyword at all (the runtime wraps the body itself), and the gate
148
+ launch must be a top-level `const gateRun = await runs.run('gate', {`.
149
+
150
+ [0.7.4]: https://github.com/GeorgeDong32/pi-review/compare/v0.7.3...v0.7.4
151
+
152
+ ## [0.7.3] - 2026-08-26
153
+
154
+ Hotfix for the PR 19291 incident (first run of v0.7.2): the main agent
155
+ followed the new workflow.js copy procedure exactly — read the file, copied
156
+ it verbatim, retried once per the hard rules, then stopped and notified as
157
+ instructed — and the review STILL died twice with "workflowScript must be
158
+ valid JavaScript". Byte-diffing the sent script against workflow.js showed
159
+ the copy had slipped a single character inside a 1400-char single-line
160
+ schema (`"maxLength":80,"description"` → `"maxLength":80",`).
161
+
162
+ ### Fixed
163
+ - **The generated workflowScript no longer contains any long single lines —
164
+ the actual root cause of every copy failure so far.** LLMs cannot
165
+ byte-reliably copy a 21 KB blob, and the fragile spots were the huge
166
+ lines, so the script now:
167
+ - declares `REVIEWER_SCHEMA` / `GATE_SCHEMA` **once** as shared consts
168
+ (was: the full schema inlined per child — 6 copies, ~10 KB of the
169
+ script, in 1400-char lines); children reference `outputSchema:
170
+ REVIEWER_SCHEMA`;
171
+ - emits reviewer and gate **task text as short quoted arrays joined at
172
+ runtime** (`task: ["…", "…"].join(" ")`) instead of one 900-char
173
+ JSON.stringify line;
174
+ - serializes schemas multi-line.
175
+ Net effect: script 21.4 KB → 17.3 KB, **longest line 1469 → 342 chars**.
176
+ Verified end-to-end: directive == workflow.js, parses, executes, and all
177
+ six task texts still classify read-only under the real installed
178
+ pi-subagents classifier.
179
+ - **`/review` command echo no longer collapsed into "pi-review · COMMENT".**
180
+ The echo message shares the report's `pi-review` custom type, so the
181
+ report renderer folded the user's own command away (the header extractor
182
+ falls back to "comment" when no verdict is present). Echoes starting with
183
+ `/review` now render verbatim as `[pi-review] /review …`.
184
+
185
+ [0.7.3]: https://github.com/GeorgeDong32/pi-review/compare/v0.7.2...v0.7.3
186
+
187
+ ## [0.7.2] - 2026-08-25
188
+
189
+ Hotfix for the PR 19395 incident (2026-08-25, first run of v0.7.1): the
190
+ review stalled for 40+ minutes with "Workflow failed: workflowScript must
191
+ be valid JavaScript" three times in a row, then the main agent drifted into
192
+ hand-debugging the generated script.
193
+
194
+ ### Fixed
195
+ - **The generated workflowScript is now presented to the main agent as an
196
+ unescaped template literal (backticks), not a double-escaped JSON string.**
197
+ The script body contains no backticks and no `${` (enforced by a plugin
198
+ guard + contract test), so a straight copy is a valid script — there is
199
+ nothing left for the main agent to unescape, which is exactly what failed:
200
+ `subagent({ workflowScript: "...\\\"...\\n..." })` required the model to
201
+ reverse the escaping while copying a 19 KB body, and any slip produced a
202
+ syntax error (`summary"`typos,"`\"` lost, etc.).
203
+ - **The raw script is persisted to `.pi/pi-review/runs/<runId>/workflow.js`
204
+ as an additional retry source.** If the copy is rejected with a parse
205
+ error, the hard rule now says: `Read` `workflow.js` and repeat the call
206
+ with exactly that content — once; on a second failure stop and notify the
207
+ user. Hand-editing, re-quoting, or "fixing" the script is explicitly
208
+ forbidden (the old rule allowed one fix and the model silently looped far
209
+ beyond that).
210
+ - Plugin-side guard: if a future script template ever introduces a backtick
211
+ or `${`, `buildReviewDirective` refuses to build the directive with a
212
+ clear "plugin bug" error instead of feeding a corrupted copy to the model.
213
+
214
+ [0.7.2]: https://github.com/GeorgeDong32/pi-review/compare/v0.7.1...v0.7.2
215
+
216
+ ## [0.7.1] - 2026-08-25
217
+
218
+ Post-mortem of the 2026-08 field reports (false positives, wrong diffs, gate
219
+ rejections after pi-subagents upgrades). Root causes verified against
220
+ CherryPR artifacts (17 PRs), 36 pi sessions, and the installed
221
+ pi-subagents 0.55.0 source.
222
+
223
+ ### Fixed — upstream compatibility (pi-subagents 0.42→0.55)
224
+ - **Gate no longer rejected at launch:** pi-subagents ≥0.55 classifies task
225
+ text for mutation intent and refuses read-only agents given
226
+ "implementation" tasks. The gate task contained the bare verb "modify"
227
+ ("lines the author did not modify") and got rejected with `Agent
228
+ 'pi-review.gate' was given an implementation task…` (observed 2026-08-24,
229
+ which silently disabled gating). Every reviewer + gate task now carries a
230
+ blanket read-only declaration ("READ-ONLY task — review only. Do not write
231
+ any files. … Return findings only."), and `agents/gate.md` declares
232
+ `acceptanceRole: read-only`. Verified against the real installed
233
+ classifier: all tasks → `read-only`, `taskMayMutate=false`.
234
+ - **Acceptance-contract compliance:** the runtime appends an Acceptance
235
+ Contract expecting a closing ```` ```acceptance-report ```` fence; our
236
+ agents ended with "return JSON and stop", so every run's acceptance meta
237
+ read `rejected`. All bundled agents now instruct compliance.
238
+ - **Contract tests pin the upstream heuristics** (read-only classification
239
+ mirror, `chatProgress` enum, acceptance mention) so the next pi-subagents
240
+ release fails our tests first, not every `/review` in the field.
241
+
242
+ ### Changed — single diff authority + lifecycle (user decisions 2026-08-25)
243
+ - **`gh pr diff` is the single PR diff authority.** It is byte-for-byte what
244
+ the GitHub web UI renders (same merge-base semantics), so a locally
245
+ computed `git diff origin/main...FETCH_HEAD` substitute — no matter how
246
+ carefully verified — can still diverge from what the user sees on the
247
+ web. The git fallback path was removed entirely: `gh pr diff` failure now
248
+ aborts the run with a clear "fix gh and re-run" error instead of
249
+ computing its own diff. (`git-pr-fallback` stays in the manifest mode
250
+ union only so pre-0.7.1 manifests keep parsing.)
251
+ - **Gate budgets tuned up again (user feedback):** 12→16 turns, 10→14 soft
252
+ tools; wall clock 15→17 min. The verification duty (read the hunk + the
253
+ touched file per blocker/major) needs the headroom.
254
+ - **End-of-run workspace reclamation:** a successful `pi_review_report`
255
+ immediately removes the run's plugin-owned tmpdir clone (the report is
256
+ already rendered + persisted). Concurrency-safe by construction — each
257
+ run allocates a unique `pi-review-ws-<ts>-<rand>` root and the manifest
258
+ records `workspaceCloned`, so reclamation never touches another run's
259
+ clone or the user's cwd. Runs that die before reaching the report tool
260
+ are still caught by the 24h TTL pruner on the next `prepareRun`.
261
+
262
+ ### Fixed — diff correctness / stability
263
+ - **No more stale-ref fallback:** the git fallback previously fetched
264
+ `pull/N/head` into a named branch and — when that fetch failed — silently
265
+ reused whatever branch was already there (2026-08-12: an 8583-line diff
266
+ for a 3-file PR, two phantom blockers, `request_changes` on a clean PR).
267
+ As of the 2026-08-25 decision the fallback is gone altogether: the run
268
+ aborts instead of ever substituting a locally computed diff.
269
+ - **Workspace/diff SHA reconciliation:** the target workspace checks out the
270
+ PR head via `FETCH_HEAD` (detached) and its landed HEAD is compared with
271
+ the diff's head SHA; a force-push race retries the clone once, then stops.
272
+ `manifest.json` records `workspaceHeadSha` and the report shows whether it
273
+ matches the diff head.
274
+ - **PR clone uses `gh repo clone` first** (private repos ride the gh
275
+ credential) with plain-https fallback; a failed PR clone is now a hard
276
+ error — the old silent fallback to the user's (possibly 247-commits
277
+ stale) cwd produced the "diff@new, files@old" evidence split that drove
278
+ false positives.
279
+ - **Cleanup:** scratch workspace clones older than 24h are pruned from the
280
+ tmpdir on every run; legacy v0.5/0.6 flat artifacts
281
+ (`.pi/pi-review/{change.diff,changed-files.txt,change-kind.txt,diff-meta.txt}`)
282
+ are removed once per run (they were repeatedly misread as current-run
283
+ inputs). Cleanup helpers no longer use ESM-`require()` (silently dead
284
+ under some loaders).
285
+ - `git ls-remote --heads origin pull/N/head` (which can never match
286
+ `refs/pull/*`) removed along with the code path it served.
287
+
288
+ ### Fixed — gate accuracy
289
+ - **Gate can finally verify:** it receives the diff path + target workspace
290
+ cwd, its budgets rose from 6 turns / 5 soft tools to 16 turns / 14 soft
291
+ tools (user-tuned), and the wall clock from 10 to 17 minutes.
292
+ - **No silent drops of unverifiable majors:** the gate must keep
293
+ blocker/major candidates it cannot verify at the reviewer's original
294
+ confidence with an `unverified:` reason (field: two real majors killed
295
+ 2026-08-20; a confidence-7 real issue killed 2026-08-21). The report tool
296
+ enforces this code-side: `unverified:` blocker/major dispositions are
297
+ floored at the threshold (they survive into issues + verdict, evidence
298
+ flagged `(unverified)`).
299
+ - **No confidence amplification without evidence:** never score above 8
300
+ without the gate's own tool-verified evidence (field: an unverifiable
301
+ "hand-edited generated file" claim became a confidence-10 blocker).
302
+ - **Missing confidence no longer means dropped:** issues arriving without a
303
+ usable confidence default to a neutral 5 at ingestion (previously
304
+ `undefined >= threshold` filtered out every such issue).
305
+ - Reviewer default turn budget 20→26 (field runs kept wrapping up partial
306
+ at the soft limit).
307
+
308
+ ### Fixed — adversarial round 2 (wiring, coverage semantics, contamination guards)
309
+ - **`gate.enabled` and `budgets.turnBudget` actually take effect:** both
310
+ config keys were documented but never consumed by the execution path.
311
+ `gate.enabled: false` now skips the gate while keeping the full reviewer
312
+ roster; config turn budgets flow into the workflowScript (and the stale
313
+ hard-coded default that would have regressed 26→20 was removed).
314
+ - **Mixed dirty trees review untracked files too:** a working tree with both
315
+ modified and new files previously diffed only the tracked changes — new
316
+ files (the ones most needing review) silently missed. Both parts are now
317
+ combined into the run diff.
318
+ - **Stale-artifact contamination guard:** the directive's hard rules forbid
319
+ reading `.pi-subagents/` (the 2026-08-24 incident had a failed workflow
320
+ followed by old-artifact findings presented as the current PR's), and
321
+ `pi_review_report` drops + surfaces findings whose reviewer key is not in
322
+ the run's roster (manifest.reviewerIds).
323
+ - **All-limited coverage never yields a clean APPROVE:** when every reviewer
324
+ returned `status: limited`, the report verdict is now `partial` instead of
325
+ `approve` (the mirror of the no-gate incident: degraded coverage must not
326
+ read as a pass).
327
+ - **Local stale-base warning:** a failed `git fetch origin <base>` with an
328
+ existing remote-tracking ref now records a visible diff note instead of
329
+ silently diffing against a stale base.
330
+ - **Diff-vs-workspace arbitration made explicit:** reviewer tasks state the
331
+ diff is the authoritative change record; workspace files are context only.
332
+ - Trivial-change guard cleans up its orphan run dir; dry-run is fully
333
+ side-effect free; README/config-comment drift fixed.
334
+
335
+ ### Migration
336
+ - None. Config schema unchanged; behavior differences are all in-plugin.
337
+
338
+ [0.7.1]: https://github.com/GeorgeDong32/pi-review/compare/v0.7.0...v0.7.1
339
+
340
+ ## [0.7.0] - 2026-08-16
341
+
342
+ ### Added
343
+ - **Deterministic target workspace prep:** `/review` now clones/checks out the target repo (PR) or uses the user's cwd (local) and writes `.pi/pi-review/runs/<runId>/manifest.json` + `change.diff` before handing the directive to the main agent. Cross-repo PRs (e.g. reviewing `CherryHQ/cherry-studio` from the plugin's cwd) now point `history-context` / `code-comments` at the **target** workspace instead of the plugin repo.
344
+ - **`pi_review_report` tool:** renders the final report deterministically (dedupe → threshold → code-side verdict) from the workflow return value, persists a session entry, and is the only authoritative report source.
345
+ - **`/review-show`:** re-renders the most recent `pi-review` session entry.
346
+ - **Collapsible TUI renderer**: `registerMessageRenderer("pi-review")` collapses long reports into a verdict + count preview line.
347
+ - **Dispositions:** the gate now records per-candidate keep/drop/merge audits (`src/types.ts GateDisposition` + `agents/gate.md`).
348
+
349
+ ### Changed
350
+ - **`chatProgress` fixed:** the directive emits `chatProgress: "auto"` (was an invalid `"milestones"` value rejected by pi-subagents).
351
+ - **Structured output hard requirement:** every reviewer and gate child carries `outputSchema`; the workflowScript consumes `result.structuredOutput`, never free-text `result.output`. Reviewers return `status` (`ok | limited | skipped`) and `coverage`.
352
+ - **Model inheritance preserved:** `model: "inherit"` reviewers no longer get a concrete per-child `model` clause injected (fixes silent inheritance loss).
353
+ - **Strict verdict default:** `enforceGateOutput` uses `strict` policy — any surviving blocker/major → `request_changes` (was `≥3 majors`). Legacy policy available via `verdictPolicy: "legacy"`.
354
+ - **Gate prompt:** re-scores every candidate, emits `dispositions`, and no longer consumes Markdown fenced JSON.
355
+ - **Diff acquisition moved into the plugin:** `src/review-run.ts` fetches `gh pr view` / `gh pr diff` / git fallback, records base/head SHAs, diff SHA-256, changed files (derived from the diff only), rule paths, docs-only flag.
356
+
357
+ ### Removed
358
+ - `/review` no longer auto-writes `.pi/projects/<id>/permissions.local.json`; diff/clone/fetch happens via the extension's own subprocesses.
359
+ - **Legacy spawn pipeline deleted:** `src/spawn.ts`, `src/gate.ts`, `src/review.ts`, `src/issue-score.ts`, `src/args.ts`, `src/obtain-diff.ts`, `src/prep.ts`, `src/git-input.ts`, `src/eligibility.ts`, `src/paths.ts`, `src/structured-output-capture.ts`, `src/parallel.ts`, `src/schema.ts`, `src/run.ts`, `scripts/smoke-acceptance.ts`, `prompts/gate.md`, and their tests. The foreground workflowScript path is the only supported execution path.
360
+ - **Config knobs that could not be honored removed:** `concurrency`, `inheritance`, `gate.scorePerIssue`, `reviewers.<id>.tools`, `reviewers.<id>.timeoutMs`. Legacy keys still parse (with one migration warning) but no longer affect behavior.
361
+
362
+ ### Added
363
+ - `routing.mode` (`adaptive` | `all`): drops clearly-inapplicable reviewer lanes up front (no rule files / docs-only / no git history). Skipped lanes appear in the report.
364
+ - `gate.verdictPolicy` (`strict` | `legacy`): code-side verdict rule selection.
365
+
366
+ ### Migration
367
+ - Config `schemaVersion` stays 1; old configs continue to load.
368
+
369
+ [0.7.0]: https://github.com/GeorgeDong32/pi-review/compare/v0.6.2...v0.7.0
370
+
371
+ ## [0.6.1] - 2026-08-08
372
+
373
+ ### Fixed
374
+ - **Agent permission blocks removed:** pi-subagents ≥0.42 rejects the legacy nested `permission:` frontmatter (`bash:` sub-maps, `"*": ask` wildcard) with `permissions must be an object mapping tool names to allow, ask, or deny`. The new model gates bash via pi-guard and only accepts flat `tool → allow|ask|deny` (no `*` wildcard, no `bash` key). All 8 bundled agents now rely on their `tools:` allowlist (the primary constraint) and omit `permission:` entirely.
375
+
376
+ [0.6.1]: https://github.com/GeorgeDong32/pi-review/compare/v0.6.0...v0.6.1
377
+
378
+ ## [0.6.0] - 2026-08-07
379
+
380
+ ### Breaking
381
+ - **workflowScript migration:** fan-out now runs through one `subagent({ workflowScript, async:false })` instead of the removed top-level `subagent({ tasks:[...] })` (pi-subagents ≥0.41 dropped legacy `tasks`/`chain`/`concurrency`). Step 2 and the gate merge into a single tool call: the script fans out reviewers via `runs.all([...])`, then feeds their inlined JSON findings to `runs.run("gate", ...)`.
382
+ - **Peer deps:** `@mariozechner/*` → `@earendil-works/*`; added `pi-subagents >=0.41.0` (provides the `workflowScript` API). Source imports (`index.ts`, `src/run.ts`, `src/structured-output-capture.ts`) and devDependencies migrated to `@earendil-works/pi-coding-agent` as well; peer floor raised to `>=0.74.0` (lowest version published under the new scope).
383
+ - **Removed directive params:** `reads: false`, `acceptance: false`, top-level `outputMode: "file-only"`, and `concurrency` — `reads` is not a valid top-level `subagent` field and would fail schema validation. Reviewers now return JSON as their final reply; the script captures `result.output`.
384
+
385
+ ### Changed
386
+ - **Inline gate:** the gate task receives reviewer JSON inlined as text (no file-only indirection). Per-child `toolBudget`/`turnBudget` are injected onto each `runs.all` / `runs.run` item.
387
+ - **Reviewer prompts:** all `agents/*.md` now say "return JSON as your final reply" (the `structured_output` fallback is kept for the legacy spawn path).
388
+ - **Tests:** `tests/directive.test.ts` rewritten for the workflowScript shape (legacy-input `doesNotMatch` guards added).
389
+
390
+ [0.6.0]: https://github.com/GeorgeDong32/pi-review/compare/v0.5.3...v0.6.0
391
+
392
+ ## [0.5.3] - 2026-07-31
393
+
394
+ ### Fixed
395
+ - **Stale base diffs:** Step 1 now `git fetch`es the remote default branch and compares against `origin/<base>` (not a stale local `main`/`master`). PR path still prefers `gh pr diff`, with a fetch `pull/<n>/head` + three-dot fallback. Writes `.pi/pi-review/diff-meta.txt` (mode / base / SHAs / merge-base) for audit.
396
+ - Allowlist adds `git fetch` / `git merge-base` / `git ls-files` for the obtain-diff path.
397
+
398
+ ## [0.5.2] - 2026-07-30
399
+
400
+ ### Changed
401
+ - **Single-wave hard rules:** at most 2 `subagent` calls (1 fan-out + 1 gate); no per-reviewer serial calls; no retries on timeout/partial.
402
+ - **turnBudget** default **20** (config `budgets.turnBudget`, up to 24/48); toolBudget soft/hard raised slightly.
403
+ - **Reviewer thinking inherits** the parent session (no forced medium/low on lean agents). Gate uses `config.gate.model` + `config.gate.thinking` as `model:thinking`.
404
+ - **Diff companion files:** write `.pi/pi-review/changed-files.txt` + `change-kind.txt` (`docs`|`code`); docs-only → bugbot/security empty early-exit.
405
+ - **Shallow prompts:** diff-first; history one multi-path `git log`; bugbot/security may use allowlisted `git show|log|blame` when needed.
406
+
407
+ ### Added
408
+ - **CC-aligned permission allowlist** (`src/review-permissions.ts`): Claude `/code-review` 7× `Bash(gh …:*)` plus history/obtain git + `Read`/`Grep`. `/review` merges them into `.pi/projects/<id>/permissions.local.json` (permission-modes) so headless children are not blocked.
409
+
410
+ [0.5.3]: https://github.com/GeorgeDong32/pi-review/compare/v0.5.2...v0.5.3
411
+ [0.5.2]: https://github.com/GeorgeDong32/pi-review/compare/v0.5.1...v0.5.2
412
+
413
+ ## [0.5.1] - 2026-07-28
414
+
415
+ ### Changed
416
+ - **Token-lean subagent fan-out:** the directive now pins every reviewer to a lean `pi-review.*` package agent (not the builtin fat `reviewer`), with explicit `turnBudget` / `toolBudget`, `reads: false`, `outputMode: "file-only"`, and `acceptance: false`.
417
+ - **Shared diff under cwd:** write to `.pi/pi-review/change.diff` (not `/tmp/...`) so children can read it without outside-cwd blocks. Main agent must **write-only** — no read/summarize of the full diff; report from file-only outputs only.
418
+ - **Lean agent prompts:** short CC-style briefs; `inheritProjectContext: false`; no obtain-change playbook; history capped at ≤5 files / `git log -n 5`.
419
+ - Package agents registered via `pi.subagents.agents: ["./agents"]` (runtime names like `pi-review.bugbot`, `pi-review.gate`).
420
+ - Default `inheritance.inheritProjectContext` is now `false`; reviewer tool lists narrowed.
421
+
422
+ ### Fixed
423
+ - Directive path previously ignored pi-review config `tools` / `thinking` / inherit flags because the main agent fell through to builtin `reviewer` (`thinking: high`, edit/write/intercom, project context on).
424
+
425
+ [0.5.1]: https://github.com/GeorgeDong32/pi-review/compare/v0.5.0...v0.5.1
426
+
427
+ ## [0.5.0] - 2026-07-27
428
+
429
+ ### Changed
430
+ - **Foreground review**: `/review` now delegates to the main agent via a hidden directive (`sendMessage` with `display:false` + `triggerTurn:true`); the main agent fans out reviewers + gate with the pi-subagents `subagent` tool. The whole review streams in chat — no more silent background spawn. **Requires the pi-subagents extension.**
431
+ - **Main agent owns the diff**: the directive has the main agent obtain the diff once into `/tmp/pi-review-change.diff`; reviewers read that file instead of each fetching separately.
432
+ - **Hidden directive, visible echo**: only a short `/review <prompt>` line shows in chat; the full directive is hidden.
433
+ - **Top-level config**: moved to `~/.pi/agent/pi-review.json` (mirrors pi-permission-modes); added `setConfigPath` for tests.
434
+ - **Gate model** defaults to a cheap tier (`anthropic/claude-haiku-4-5`); override via config or the restored `--gate-model` flag.
435
+ - **per-issue scorer** default `off` (was `blocker-major`).
436
+ - **CLI slimmed**: `/review` surface reduced to `--lite` + freeform prompt; removed flags are accepted-but-ignored (their capabilities moved to config).
437
+
438
+ ### Added
439
+ - **`--lite` mode**: single-agent fast review (`agents/lite-review.md`), no fan-out/gate.
440
+ - **Workflow checklist**: the directive has the main agent post a markdown checklist of the steps first, then work through it (pi has no native todo tool).
441
+ - `getArgumentCompletions` for `--lite` / `--gate-model`.
442
+
443
+ ### Removed
444
+ - Code-enforced verdict — now instructed to the main agent (LLM follows the rule, but no longer a hard guarantee). The background spawn path is kept as a fallback.
445
+
446
+ [0.5.0]: https://github.com/GeorgeDong32/pi-review/compare/v0.4.1...v0.5.0
447
+
448
+ ## [0.4.1] - 2026-07-26
449
+
450
+ ### Fixed
451
+ - **UI feedback during `/review`:** immediate notify + footer status; per-reviewer progress; errors surface via notify + message.
452
+ - Stop calling `gh pr diff` during target resolve (was blocking the TUI with no output while the backend worked). Oversized hint comes from `gh pr view` metadata instead.
453
+
454
+ [0.4.1]: https://github.com/GeorgeDong32/pi-review/compare/v0.4.0...v0.4.1
455
+
456
+ ## [0.4.0] - 2026-07-26
457
+
458
+ ### Changed
459
+ - **Agent-driven change acquisition (CC-aligned):** the plugin no longer pre-fetches or embeds a full diff. Reviewers obtain the change via `gh` / `git` / `read` using an obtain-change playbook in the task prompt.
460
+ - Oversized PRs (`gh pr diff` HTTP 406 / too_large) no longer abort the pipeline; agents fall back to git / path-scoped reads.
461
+ - Gate and per-issue scorers receive metadata + reviewer JSON only (no full `<diff>` embed).
462
+ - All content reviewers include `bash` so they can run `gh`/`git`.
463
+
464
+ ### Added
465
+ - `ReviewTarget` + `resolveReviewTarget` (`pr` | `diff-file` | `local-git`).
466
+ - Optional `gh pr view` metadata prep and `probeNote` for dry-run.
467
+
468
+ [0.4.0]: https://github.com/GeorgeDong32/pi-review/compare/v0.3.1...v0.4.0
469
+
470
+ ## [0.3.1] - 2026-07-26
471
+
472
+ ### Changed
473
+ - **CC-aligned `/review` args:** positional text is **user context** (PR URL/number, instructions), not a filesystem path. Fixes `ENOENT` when passing GitHub PR links.
474
+ - PR URLs/numbers resolve via `gh pr diff`; explicit diff files use `--diff @file.diff`.
475
+
476
+ ### Added
477
+ - `src/pr-ref.ts` — extract PR refs from freeform input (handles CJK punctuation like `,review`).
478
+
479
+ [0.3.1]: https://github.com/GeorgeDong32/pi-review/compare/v0.3.0...v0.3.1
480
+
481
+ ## [0.3.0] - 2026-07-26
482
+
483
+ ### Added
484
+ - **Code-side gate enforce** (`src/gate-enforce.ts`): deterministic dedupe + threshold filter + verdict rules after the gate LLM (Claude Phase 5 equivalent).
485
+ - **Full diff to gate**: gate task includes the complete review body inside `<diff>` (no 2KB slice).
486
+ - **Optional per-issue scorers** (`gate.scorePerIssue`, default `blocker-major`): Claude Phase 4–style parallel confidence scoring for high-severity findings (`prompts/issue-score.md`).
487
+ - CLI: `--score-per-issue off|blocker-major|all`; `--threshold` is clamped to 0–10.
488
+
489
+ ### Fixed
490
+ - Spawn: drain stdout to avoid pipe deadlock; reject non-zero child exit even when `output.json` exists.
491
+ - Report: list final gate issues in markdown; mark unfiltered totals when gate is missing/failed.
492
+ - ESM: replace `require()` in `paths.ts` / `prep.ts` / `git-input.ts` so `tsx --test` works under pure ESM.
493
+
494
+ [0.3.0]: https://github.com/GeorgeDong32/pi-review/compare/v0.2.0...v0.3.0
495
+
496
+ ## [0.2.0] - 2026-07-19
497
+
498
+ ### Added
499
+ - `index.ts` — registers `/review`, `/review-config`, `/review-agents`.
500
+ - Claude-shaped pipeline: **eligibility → prep → reviewers → gate → report** (`src/eligibility.ts`, `src/prep.ts`, `src/run.ts`).
501
+ - `src/structured-output-capture.ts` — child extension for `structured_output` tool; loaded via `-e` on subagent spawns.
502
+ - `src/cli-args.ts` — flag parsing for `/review`.
503
+ - New reviewers: `bugbot` (replaces `bug-detector`), `security-review`, `code-comments`.
504
+ - `reference/` docs (Claude flow, Cursor skills, roadmap, v0.2 plan).
505
+ - Tests: eligibility, prep, cli-args (+104 total).
506
+
507
+ ### Changed
508
+ - Default gate threshold **3 → 8** (maps to Claude 80/100).
509
+ - Bundled `agents/*.md` and `prompts/gate.md` wired as subagent system prompts.
510
+ - Gate prompt embeds Claude confidence rubric (1–10 re-score).
511
+ - `conventions` reviewer default **disabled**.
512
+ - `@sinclair/typebox` moved to `dependencies` (capture extension runtime).
513
+
514
+ ### Removed
515
+ - `agents/bug-detector.md` (renamed to `bugbot.md`).
516
+
517
+ ## [0.1.0] - 2026-07-02
518
+
519
+ ### Added
520
+ - `/review [path]` slash command — fans the diff out to four parallel reviewer subagents (`claude-md-compliance`, `bug-detector`, `conventions`, `history-context`) and aggregates their structured output through a single cheap-model gate.
521
+ - `/review-config` — opens `~/.pi/agent/extensions/pi-review/config.json` in `$EDITOR` and re-validates on close.
522
+ - `/review-agents` — lists the bundled reviewers with their resolved model, thinking, and tool lists.
523
+ - Smart default diff source: dirty working tree → `git diff HEAD`; clean tree → `git diff <default-branch>...HEAD`. Probes `origin/HEAD` → `main` → `master` → current branch.
524
+ - Per-reviewer model / thinking / tool overrides via `~/.pi/agent/extensions/pi-review/config.json`. `"inherit"` resolves to the parent session's model at run time.
525
+ - Flags: `--threshold N`, `--reviewer id...` (repeatable), `--no-gate`, `--gate-model id`, `--no-spawn` (dry run).
526
+ - TUI output: full report rendered as an `assistant` text block. Machine-readable copy written via `pi.appendEntry("pi-review", ...)` for future collapse-aware consumers.
527
+ - Structured output via TypeBox schemas. Subagents receive the JSON Schema via `PI_SUBAGENT_STRUCTURED_OUTPUT_SCHEMA` and write the validated payload to `PI_SUBAGENT_STRUCTURED_OUTPUT_CAPTURE`. Parent re-validates with `validateValue`.
528
+
529
+ ### Changed
530
+ - Each reviewer / gate runs as a fresh, isolated `pi` subprocess (`--no-session --no-extensions --no-skills`) — mirrors the pattern from `pi-subagents`.
531
+ - Hard cap of 4 concurrent reviewers, regardless of `concurrency` in config.
532
+ - The gate is spawned with no tools — pure reasoning on the aggregated prompt.
533
+
534
+ ### Out of scope (deferred)
535
+ - Retry loop for failed reviewers.
536
+ - Worktree-per-reviewer isolation.
537
+ - GitHub / `gh` integration (PR comment posting).
538
+ - Inline fix suggestions / auto-apply.
539
+ - Multi-PR batch mode.
540
+ - Web UI for configuration.