@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.
- package/README.md +111 -0
- package/extensions/review/CHANGELOG.md +540 -0
- package/extensions/review/LICENSE +15 -0
- package/extensions/review/README.md +55 -0
- package/extensions/review/agents/bugbot.md +46 -0
- package/extensions/review/agents/claude-md-compliance.md +46 -0
- package/extensions/review/agents/code-comments.md +43 -0
- package/extensions/review/agents/conventions.md +41 -0
- package/extensions/review/agents/gate.md +70 -0
- package/extensions/review/agents/history-context.md +45 -0
- package/extensions/review/agents/lite-review.md +51 -0
- package/extensions/review/agents/security-review.md +45 -0
- package/extensions/review/index.ts +205 -0
- package/extensions/review/package.json +38 -0
- package/extensions/review/reference/README.md +20 -0
- package/extensions/review/reference/claude-code-review.md +133 -0
- package/extensions/review/reference/cursor-review-skills.md +72 -0
- package/extensions/review/reference/pi-review-roadmap.md +183 -0
- package/extensions/review/reference/structured-output.md +26 -0
- package/extensions/review/reference/v0.2-plan.md +268 -0
- package/extensions/review/src/cli-args.ts +105 -0
- package/extensions/review/src/config.ts +340 -0
- package/extensions/review/src/directive.ts +481 -0
- package/extensions/review/src/gate-enforce.ts +151 -0
- package/extensions/review/src/lean-agents.ts +105 -0
- package/extensions/review/src/pr-ref.ts +39 -0
- package/extensions/review/src/report-tool.ts +394 -0
- package/extensions/review/src/report.ts +399 -0
- package/extensions/review/src/review-report.ts +279 -0
- package/extensions/review/src/review-run.ts +568 -0
- package/extensions/review/src/target-workspace.ts +239 -0
- package/extensions/review/src/tool-wrapper.ts +75 -0
- package/extensions/review/src/tui-renderer.ts +92 -0
- package/extensions/review/src/types.ts +207 -0
- package/extensions/review/src/workflow-schemas.ts +172 -0
- package/extensions/sessions/README.md +41 -0
- package/extensions/sessions/index.ts +862 -0
- package/extensions/sessions/package.json +21 -0
- package/extensions/sessions/sessions.ts +264 -0
- package/package.json +36 -0
- package/skills/README.md +29 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@unifan/pi-review-zh",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Pi AI 并发代码审查扩展(多专家子代理并发 + 门禁裁判系统,中文增强版)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "821869798",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/821869798/pi-unifan-zh.git"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"pi-package",
|
|
14
|
+
"pi-extension",
|
|
15
|
+
"pi-coding-agent",
|
|
16
|
+
"code-review",
|
|
17
|
+
"reviewer",
|
|
18
|
+
"chinese"
|
|
19
|
+
],
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@earendil-works/pi-ai": ">=0.74.0 <1.0.0",
|
|
22
|
+
"@earendil-works/pi-coding-agent": ">=0.74.0 <1.0.0",
|
|
23
|
+
"pi-subagents": ">=0.41.0 <1.0.0"
|
|
24
|
+
},
|
|
25
|
+
"pi": {
|
|
26
|
+
"extensions": [
|
|
27
|
+
"./index.ts"
|
|
28
|
+
],
|
|
29
|
+
"subagents": {
|
|
30
|
+
"agents": [
|
|
31
|
+
"./agents"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@sinclair/typebox": "^0.34.0"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# pi-review reference
|
|
2
|
+
|
|
3
|
+
Design references and version planning. Read these before changing pipeline shape, reviewer roster, or gate behavior so we do not drift from agreed intent.
|
|
4
|
+
|
|
5
|
+
| Document | Contents |
|
|
6
|
+
|----------|----------|
|
|
7
|
+
| [claude-code-review.md](./claude-code-review.md) | Official Claude `/code-review` pipeline (source of truth: `commands/code-review.md`) |
|
|
8
|
+
| [cursor-review-skills.md](./cursor-review-skills.md) | Cursor Bugbot / Security Review skills (what to borrow, what not to) |
|
|
9
|
+
| [pi-review-roadmap.md](./pi-review-roadmap.md) | pi-review adaptation, phase mapping, version plan |
|
|
10
|
+
| [v0.2-plan.md](./v0.2-plan.md) | **v0.2.0 task list**, acceptance criteria, implementation order |
|
|
11
|
+
| [structured-output.md](./structured-output.md) | Child capture extension env contract |
|
|
12
|
+
|
|
13
|
+
**Primary upstream (Claude):**
|
|
14
|
+
https://github.com/anthropics/claude-plugins-official/blob/main/plugins/code-review/commands/code-review.md
|
|
15
|
+
|
|
16
|
+
**When to update this folder**
|
|
17
|
+
|
|
18
|
+
- Upstream Claude command changes
|
|
19
|
+
- Reviewer roster or pipeline phase changes in pi-review
|
|
20
|
+
- Default threshold / gate semantics change
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Claude Code Review — reference
|
|
2
|
+
|
|
3
|
+
> **Source of truth:** `anthropics/claude-plugins-official` → `plugins/code-review/commands/code-review.md`
|
|
4
|
+
> **Secondary (may be stale):** `plugins/code-review/README.md` — describes 4 agents and “2× CLAUDE.md compliance”; the command file is authoritative and lists **5 distinct content agents**.
|
|
5
|
+
|
|
6
|
+
Last verified: 2026-07-19.
|
|
7
|
+
|
|
8
|
+
## Product intent
|
|
9
|
+
|
|
10
|
+
Automated PR review: multiple independent agents audit the same change from different angles, then **confidence scoring** filters false positives so only high-signal issues are posted.
|
|
11
|
+
|
|
12
|
+
- **Trigger:** `/code-review` (GitHub PR context, uses `gh`)
|
|
13
|
+
- **Output:** PR comment with issues ≥ threshold (default **80/100**), or no comment if none qualify
|
|
14
|
+
- **Not in scope:** auto-fix, harness gating merges, worktree isolation
|
|
15
|
+
|
|
16
|
+
## Pipeline (ordered phases)
|
|
17
|
+
|
|
18
|
+
Claude is **not** “spawn N reviewers and done”. It is a **sequential pipeline** with one parallel batch in the middle.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
22
|
+
│ Phase 1 — Eligibility (Haiku) │
|
|
23
|
+
│ Skip if: closed, draft, trivial/automated, already reviewed │
|
|
24
|
+
│ → STOP if ineligible │
|
|
25
|
+
└────────────────────────────┬────────────────────────────────────┘
|
|
26
|
+
▼
|
|
27
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
28
|
+
│ Phase 2 — Prep (Haiku, sequential) │
|
|
29
|
+
│ 2a. List paths to relevant CLAUDE.md files (not full contents) │
|
|
30
|
+
│ 2b. Summarize PR / change │
|
|
31
|
+
└────────────────────────────┬────────────────────────────────────┘
|
|
32
|
+
▼
|
|
33
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
34
|
+
│ Phase 3 — Content review (5× Sonnet, PARALLEL) │
|
|
35
|
+
│ Each returns issues + reason flagged (compliance, bug, history…) │
|
|
36
|
+
└────────────────────────────┬────────────────────────────────────┘
|
|
37
|
+
▼
|
|
38
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
39
|
+
│ Phase 4 — Confidence scoring (Haiku, PARALLEL per issue) │
|
|
40
|
+
│ One scorer agent per issue from Phase 3 │
|
|
41
|
+
│ Rubric: 0 / 25 / 50 / 75 / 100 (verbatim in command) │
|
|
42
|
+
└────────────────────────────┬────────────────────────────────────┘
|
|
43
|
+
▼
|
|
44
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
45
|
+
│ Phase 5 — Filter │
|
|
46
|
+
│ Drop issues with score < 80 (configurable in command) │
|
|
47
|
+
│ → STOP if no issues remain (no comment posted) │
|
|
48
|
+
└────────────────────────────┬────────────────────────────────────┘
|
|
49
|
+
▼
|
|
50
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
51
|
+
│ Phase 6 — Re-eligibility (Haiku) │
|
|
52
|
+
│ Repeat Phase 1 checks before posting │
|
|
53
|
+
└────────────────────────────┬────────────────────────────────────┘
|
|
54
|
+
▼
|
|
55
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
56
|
+
│ Phase 7 — Output (`gh pr comment`) │
|
|
57
|
+
│ Brief markdown; link file:line with full SHA │
|
|
58
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Phase 3 — five content agents (command file)
|
|
62
|
+
|
|
63
|
+
| # | Task | Focus |
|
|
64
|
+
|---|------|--------|
|
|
65
|
+
| 1 | CLAUDE.md compliance | Rules in CLAUDE.md; not every writing-time instruction applies at review time |
|
|
66
|
+
| 2 | Bug detector | Shallow scan of **diff only**; large bugs; ignore nitpicks and likely FPs |
|
|
67
|
+
| 3 | History | `git blame` + history on modified code; bugs in light of historical context |
|
|
68
|
+
| 4 | Previous PRs | PRs that touched same files; comments that may apply to current PR |
|
|
69
|
+
| 5 | Code comments | Inline comments in modified files; change must comply with comment guidance |
|
|
70
|
+
|
|
71
|
+
Agents run **in parallel** after prep. They do **not** score their own issues for final output.
|
|
72
|
+
|
|
73
|
+
## Phase 4 — confidence rubric (0–100)
|
|
74
|
+
|
|
75
|
+
Given verbatim to each scorer (summarized):
|
|
76
|
+
|
|
77
|
+
| Score | Meaning |
|
|
78
|
+
|-------|---------|
|
|
79
|
+
| **0** | False positive; does not survive scrutiny; or pre-existing |
|
|
80
|
+
| **25** | Might be real; cannot verify; stylistic without explicit CLAUDE.md callout |
|
|
81
|
+
| **50** | Real but minor / nitpick / rare in practice |
|
|
82
|
+
| **75** | Verified likely real and important; or explicitly in CLAUDE.md |
|
|
83
|
+
| **100** | Certain; will happen in practice; direct evidence |
|
|
84
|
+
|
|
85
|
+
**CLAUDE.md issues:** scorer must verify the guideline **explicitly** mentions the issue.
|
|
86
|
+
|
|
87
|
+
**Default threshold:** 80 — issues below are dropped.
|
|
88
|
+
|
|
89
|
+
## Documented false positives (Phases 3–4)
|
|
90
|
+
|
|
91
|
+
Scorers are instructed to down-rank:
|
|
92
|
+
|
|
93
|
+
- Pre-existing issues not introduced in the PR
|
|
94
|
+
- Things that look like bugs but are not
|
|
95
|
+
- Pedantic nitpicks a senior engineer would skip
|
|
96
|
+
- Linter / typechecker / formatter / import / test failures (CI handles)
|
|
97
|
+
- General quality (tests, docs, generic security) **unless** CLAUDE.md requires it
|
|
98
|
+
- Issues silenced in code (e.g. lint-ignore)
|
|
99
|
+
- Intentional functional changes related to the PR scope
|
|
100
|
+
- Real issues on lines the author did not modify
|
|
101
|
+
|
|
102
|
+
**Explicit non-goals:** do not build or typecheck; do not use web fetch for GitHub (use `gh`).
|
|
103
|
+
|
|
104
|
+
## README vs command discrepancies
|
|
105
|
+
|
|
106
|
+
| Topic | README | Command (`code-review.md`) |
|
|
107
|
+
|-------|--------|----------------------------|
|
|
108
|
+
| Content agent count | 4 (2× compliance + bug + history) | **5** distinct roles |
|
|
109
|
+
| Agent #2 | Second compliance | **Bug detector** |
|
|
110
|
+
| Agents #4–5 | Not listed | Previous PRs + code comments |
|
|
111
|
+
| Scoring | “Nx confidence scorers” | One Haiku per issue, parallel |
|
|
112
|
+
|
|
113
|
+
**For pi-review alignment, follow the command file.**
|
|
114
|
+
|
|
115
|
+
## Architecture notes (from README technical section)
|
|
116
|
+
|
|
117
|
+
- Compliance redundancy in README (“2×”) is **not** what the current command specifies.
|
|
118
|
+
- Scoring is **per issue**, not one aggregating judge.
|
|
119
|
+
- GitHub integration: `gh pr view`, `gh pr diff`, blame/history, post comment.
|
|
120
|
+
|
|
121
|
+
## Implications for pi-review
|
|
122
|
+
|
|
123
|
+
| Claude phase | pi-review adaptation (v0.4) |
|
|
124
|
+
|--------------|-------------------------|
|
|
125
|
+
| 1 Eligibility | PR ref / `--diff` / git repo; optional trivial probe for local-git only |
|
|
126
|
+
| 2 Prep | Rule-file paths + lightweight `gh pr view` / hint metadata (no full diff) |
|
|
127
|
+
| 3 Content (5) | Bundled reviewers **obtain the change themselves** (gh/git/read playbook) |
|
|
128
|
+
| 4 Scoring | Gate + optional per-issue scorers on reviewer evidence (no full diff embed) |
|
|
129
|
+
| 5 Filter | Code-side threshold (map 80/100 → 8/10) |
|
|
130
|
+
| 6 Re-eligibility | Target still present before render |
|
|
131
|
+
| 7 Output | TUI markdown + `appendEntry`; no `gh pr comment` yet |
|
|
132
|
+
|
|
133
|
+
**v0.4 design note:** Claude `/code-review` is an instruction document for the main agent. pi-review keeps parallel spawn + structured_output + gate enforce in the plugin, but must not hard-fail on `gh pr diff` — oversized PRs are handled inside reviewer tool loops.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Cursor Bugbot & Security Review — reference
|
|
2
|
+
|
|
3
|
+
> **Source:** Cursor built-in skills `review-bugbot`, `review-security` (subagent invocation patterns).
|
|
4
|
+
|
|
5
|
+
Last verified: 2026-07-19.
|
|
6
|
+
|
|
7
|
+
## Product intent (Cursor)
|
|
8
|
+
|
|
9
|
+
**Single-purpose review skills** — user manually invokes `/review-bugbot` or `/review-security`. Each launches **one** specialized subagent. There is **no** multi-phase pipeline, no gate, no per-issue confidence loop.
|
|
10
|
+
|
|
11
|
+
Cursor’s general `/review` skill routes to these specialists; they are **not** a full clone of Claude code-review.
|
|
12
|
+
|
|
13
|
+
## Invocation contract
|
|
14
|
+
|
|
15
|
+
Both skills use the same prompt shape:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
Full Repository Path: <absolute path>
|
|
19
|
+
Diff: <"branch changes" | "uncommitted changes">
|
|
20
|
+
Base Branch: <optional; only when comparing against a known non-default base>
|
|
21
|
+
Custom Instructions: <optional>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
| `Diff` value | Meaning |
|
|
25
|
+
|--------------|---------|
|
|
26
|
+
| `branch changes` (default) | Merge-base vs default branch; includes committed + staged + unstaged |
|
|
27
|
+
| `uncommitted changes` | Working tree only |
|
|
28
|
+
|
|
29
|
+
Subagent computes diff internally — caller should **not** pre-compute diff.
|
|
30
|
+
|
|
31
|
+
**PR / branch special case:** checkout target branch before launch; stash only with user confirmation.
|
|
32
|
+
|
|
33
|
+
## Subagent types
|
|
34
|
+
|
|
35
|
+
| Skill | `subagent_type` | Purpose |
|
|
36
|
+
|-------|-----------------|---------|
|
|
37
|
+
| `/review-bugbot` | `bugbot` | Correctness / logic bugs in the change |
|
|
38
|
+
| `/review-security` | `security-review` | Security issues in the change |
|
|
39
|
+
|
|
40
|
+
## Output discipline
|
|
41
|
+
|
|
42
|
+
After subagent completes, parent summarizes:
|
|
43
|
+
|
|
44
|
+
- Empty diff → one-line “no diff”
|
|
45
|
+
- No issues → one-line status
|
|
46
|
+
- Issues → markdown table: **Severity | Location (file:line) | Finding**, sorted by severity
|
|
47
|
+
|
|
48
|
+
**Do not** auto-fix or re-run unless user asks.
|
|
49
|
+
|
|
50
|
+
## Retry policy
|
|
51
|
+
|
|
52
|
+
- Wrong invocation shape → fix and retry once
|
|
53
|
+
- Other failures → retry once with same prompt
|
|
54
|
+
- Still failing → stop, report error (no infinite retry)
|
|
55
|
+
|
|
56
|
+
## What to borrow for pi-review
|
|
57
|
+
|
|
58
|
+
| Borrow | Do not borrow |
|
|
59
|
+
|--------|----------------|
|
|
60
|
+
| Bug-focused diff scope (no whole-repo nitpicks) | Single-subagent-only UX (we use parallel reviewers) |
|
|
61
|
+
| Security category checklist mindset | Letting subagent compute diff (we resolve diff in parent) |
|
|
62
|
+
| Compact table-friendly findings | Separate `/review-bugbot` commands (use `/review --reviewer`) |
|
|
63
|
+
| “Only changed lines” discipline | Cursor’s Task/subagent harness |
|
|
64
|
+
|
|
65
|
+
## Mapping to pi-review agents
|
|
66
|
+
|
|
67
|
+
| Cursor | pi-review agent (planned) | Notes |
|
|
68
|
+
|--------|---------------------------|-------|
|
|
69
|
+
| `bugbot` | `bugbot` (rename from `bug-detector`) | Align prompt with Cursor output discipline |
|
|
70
|
+
| `security-review` | `security-review` (new) | `category: security` in schema already exists |
|
|
71
|
+
|
|
72
|
+
These are **Phase 3 content reviewers** in our pipeline, not replacements for eligibility, prep, or gate.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# pi-review — design & version roadmap
|
|
2
|
+
|
|
3
|
+
> **Positioning:** Pure **skills** extension — user manually runs `/review`. No harness, no auto-fix, no GitHub bot in v1.
|
|
4
|
+
> **Pattern:** Claude code-review **pipeline shape** + Cursor **bug/security prompt discipline**.
|
|
5
|
+
> **See also:** [claude-code-review.md](./claude-code-review.md), [cursor-review-skills.md](./cursor-review-skills.md)
|
|
6
|
+
|
|
7
|
+
Last updated: 2026-07-19.
|
|
8
|
+
|
|
9
|
+
## Design principles
|
|
10
|
+
|
|
11
|
+
1. **Pipeline, not a bag of agents** — eligibility → prep → parallel content → score/filter → output.
|
|
12
|
+
2. **High signal** — default threshold aligned with Claude’s 80/100 (our **8/10**).
|
|
13
|
+
3. **Local-first** — `git diff` / diff file; no `gh` required in v1.
|
|
14
|
+
4. **Manual invocation only** — no `registerTool`, no CI hooks in v1.
|
|
15
|
+
5. **Gate = Phase 4+5 compression** — one cheap spawn for dedupe + re-score + verdict; optional per-issue scorers in a later version.
|
|
16
|
+
|
|
17
|
+
## Phase mapping (Claude → pi-review)
|
|
18
|
+
|
|
19
|
+
| Claude phase | pi-review module (planned) | v1 behavior |
|
|
20
|
+
|--------------|----------------------------|-------------|
|
|
21
|
+
| **0 Eligibility** | `src/eligibility.ts` | Empty diff, non-git, optional trivial skip |
|
|
22
|
+
| **1 Prep** | `src/prep.ts` | Rule paths (`AGENTS.md`, `CLAUDE.md`, `.pi/`) + diff summary injected into reviewer task |
|
|
23
|
+
| **2 Content (×5)** | `src/review.ts` + `agents/*.md` | Parallel subagents; bundled prompts as `--system-prompt` |
|
|
24
|
+
| **3 Score + filter** | `src/gate.ts` + `prompts/gate.md` | Dedupe, apply Claude rubric (adapted to 1–10), threshold, verdict |
|
|
25
|
+
| **4 Re-check** | `index.ts` | Optional: re-verify diff non-empty before render |
|
|
26
|
+
| **5 Output** | `src/report.ts` | `sendMessage` + `appendEntry("pi-review", …)` |
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
/review
|
|
30
|
+
│
|
|
31
|
+
├─ Phase 0 eligibility() → notify + exit if skip
|
|
32
|
+
├─ Phase 1 resolveDiff() → git-input / path / @file
|
|
33
|
+
├─ Phase 1 prepareContext() → rule paths + summary (sync or 1 cheap spawn)
|
|
34
|
+
├─ Phase 2 runReviewers() → 5 parallel (cap 4 concurrency → 2 waves)
|
|
35
|
+
├─ Phase 3 runGate() → unless --no-gate
|
|
36
|
+
└─ Phase 4 buildReport + render → TUI markdown
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Default reviewer roster (v0.2 target)
|
|
40
|
+
|
|
41
|
+
Aligned to Claude’s five content agents, adapted for local use:
|
|
42
|
+
|
|
43
|
+
| ID | Claude agent | Status | Tools (default) |
|
|
44
|
+
|----|--------------|--------|-----------------|
|
|
45
|
+
| `claude-md-compliance` | #1 CLAUDE.md | exists | read, grep, find, ls |
|
|
46
|
+
| `bugbot` | #2 Bug detector | rename `bug-detector` | read, grep, find |
|
|
47
|
+
| `history-context` | #3 History | exists | read, bash |
|
|
48
|
+
| `security-review` | *(pi addition)* | **new** | read, grep, find |
|
|
49
|
+
| `code-comments` | #5 Code comments | **new** | read, grep |
|
|
50
|
+
|
|
51
|
+
**Dropped / deferred**
|
|
52
|
+
|
|
53
|
+
| ID | Reason |
|
|
54
|
+
|----|--------|
|
|
55
|
+
| `pr-context` (Claude #4) | Requires `gh` + PR metadata — **v1 out of scope** |
|
|
56
|
+
| `conventions` | Overlaps compliance + Claude false-positive list; keep as **optional** `enabled: false` |
|
|
57
|
+
|
|
58
|
+
**Concurrency:** hard cap 4 → five reviewers run as batch of 4 + batch of 1 (or user passes `--reviewer` subset).
|
|
59
|
+
|
|
60
|
+
## Confidence scale
|
|
61
|
+
|
|
62
|
+
| System | Scale | Default keep |
|
|
63
|
+
|--------|-------|--------------|
|
|
64
|
+
| Claude Phase 4 | 0–100 | ≥ 80 |
|
|
65
|
+
| pi-review reviewer + gate | 1–10 | ≥ **8** (change default from 3) |
|
|
66
|
+
|
|
67
|
+
Gate prompt must embed Claude’s rubric (translated to 1–10) for **re-scoring**, not only filtering reviewer self-reported confidence.
|
|
68
|
+
|
|
69
|
+
## Known gaps (v0.1.0 codebase)
|
|
70
|
+
|
|
71
|
+
| Gap | Blocks |
|
|
72
|
+
|-----|--------|
|
|
73
|
+
| Missing `index.ts` | Extension load |
|
|
74
|
+
| `agents/*.md` not used as system prompt | Reviewer quality |
|
|
75
|
+
| `PI_SUBAGENT_STRUCTURED_OUTPUT_*` not handled by stock `pi` | Subagent spawn |
|
|
76
|
+
| No eligibility / prep phases | Claude alignment |
|
|
77
|
+
| Default threshold 3 | Too noisy vs Claude |
|
|
78
|
+
|
|
79
|
+
## Version plan
|
|
80
|
+
|
|
81
|
+
### v0.1.0 — current (incomplete)
|
|
82
|
+
|
|
83
|
+
**Shipped:** core libs, 4 agent templates, gate schema, tests (92).
|
|
84
|
+
**Not shipped:** `index.ts`, npm publish, end-to-end run.
|
|
85
|
+
|
|
86
|
+
No further work on 0.1.0 except tagging reality in CHANGELOG if needed.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
### v0.2.0 — “skills MVP” (target)
|
|
91
|
+
|
|
92
|
+
**Goal:** User can `pi -e .` or install package and run `/review` on local diff with Claude-shaped pipeline.
|
|
93
|
+
|
|
94
|
+
| Work item | Priority |
|
|
95
|
+
|-----------|----------|
|
|
96
|
+
| `index.ts` — `/review`, `/review-config`, `/review-agents` | P0 |
|
|
97
|
+
| `src/structured-output-capture.ts` — minimal child extension OR document `-e` flag for structured output | P0 |
|
|
98
|
+
| Wire `agents/<id>.md` + `prompts/gate.md` as system prompts | P0 |
|
|
99
|
+
| `src/eligibility.ts` — empty diff, non-git, trivial diff heuristic | P0 |
|
|
100
|
+
| `src/prep.ts` — rule file paths + diff summary in task preamble | P1 |
|
|
101
|
+
| Rename `bug-detector` → `bugbot`; add `security-review.md`, `code-comments.md` | P1 |
|
|
102
|
+
| Default threshold **8**; gate prompt Claude rubric | P1 |
|
|
103
|
+
| `conventions` default `enabled: false` | P2 |
|
|
104
|
+
| Update README + CHANGELOG | P1 |
|
|
105
|
+
| `reference/` in package `files` | P1 |
|
|
106
|
+
|
|
107
|
+
**Out of scope v0.2:** `gh`, per-issue scorers, `registerTool`, worktree, retry loop.
|
|
108
|
+
|
|
109
|
+
**Implementation:** see [v0.2-plan.md](./v0.2-plan.md) for the full task list (54 tasks, 7 tracks).
|
|
110
|
+
|
|
111
|
+
**Exit criteria**
|
|
112
|
+
|
|
113
|
+
- [ ] `pi -e /path/to/pi-review` → `/review` on dirty repo produces report
|
|
114
|
+
- [ ] Gate drops low-confidence issues; empty high-confidence → clear message
|
|
115
|
+
- [ ] `bun test` + `bun run check` pass
|
|
116
|
+
- [ ] npm publish `@georgedong32/pi-review@0.2.0`
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
### v0.3.0 — “quality & optional GH”
|
|
121
|
+
|
|
122
|
+
| Work item | Notes |
|
|
123
|
+
|-----------|-------|
|
|
124
|
+
| Per-issue scorer mode (`--score-per-issue`) | True Claude Phase 4; higher cost |
|
|
125
|
+
| `pr-context` reviewer (optional) | Behind `gh` detection + config flag |
|
|
126
|
+
| Reviewer failure retry (1×) | Only on spawn/timeout errors |
|
|
127
|
+
| `registerMessageRenderer` for collapsible report | TUI polish |
|
|
128
|
+
| Eligibility: “already reviewed” via session `appendEntry` hash | Optional |
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
### v1.0.0 — stable API
|
|
133
|
+
|
|
134
|
+
- Frozen config schema v1
|
|
135
|
+
- Documented reviewer add/replace contract
|
|
136
|
+
- Published pi gallery entry
|
|
137
|
+
- No breaking changes without `schemaVersion` bump
|
|
138
|
+
|
|
139
|
+
## File layout (target)
|
|
140
|
+
|
|
141
|
+
```text
|
|
142
|
+
index.ts Extension entry
|
|
143
|
+
src/
|
|
144
|
+
eligibility.ts Phase 0
|
|
145
|
+
prep.ts Phase 1
|
|
146
|
+
git-input.ts Diff resolution (existing)
|
|
147
|
+
review.ts Phase 2 fan-out (existing)
|
|
148
|
+
gate.ts Phase 3 (existing)
|
|
149
|
+
report.ts Phase 5 output (existing)
|
|
150
|
+
structured-output-capture.ts Child pi extension for spawn (new)
|
|
151
|
+
agents/
|
|
152
|
+
claude-md-compliance.md
|
|
153
|
+
bugbot.md (was bug-detector)
|
|
154
|
+
history-context.md
|
|
155
|
+
security-review.md (new)
|
|
156
|
+
code-comments.md (new)
|
|
157
|
+
conventions.md (optional, disabled)
|
|
158
|
+
prompts/
|
|
159
|
+
gate.md
|
|
160
|
+
reference/ This folder
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Commands (unchanged UX)
|
|
164
|
+
|
|
165
|
+
```text
|
|
166
|
+
/review [path | @path] [--threshold N] [--reviewer id ...] [--no-gate] [--gate-model id] [--no-spawn]
|
|
167
|
+
/review-config
|
|
168
|
+
/review-agents
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Decision log
|
|
172
|
+
|
|
173
|
+
| Date | Decision | Rationale |
|
|
174
|
+
|------|----------|-----------|
|
|
175
|
+
| 2026-07-19 | Pure skills, manual `/review` only | User intent; avoid harness scope |
|
|
176
|
+
| 2026-07-19 | Follow Claude **pipeline**, not just parallel agents | User correction; command file is SoT |
|
|
177
|
+
| 2026-07-19 | Keep `history-context` in default roster | Claude agent #3; not merged into bugbot |
|
|
178
|
+
| 2026-07-19 | Add `security-review` (Cursor-inspired) | Orthogonal to bug + compliance |
|
|
179
|
+
| 2026-07-19 | Gate compresses Phase 4+5 for v0.2 | Cost vs fidelity; document in reference |
|
|
180
|
+
| 2026-07-19 | Skip `pr-context` until v0.3+ | Requires `gh`; local-first v1 |
|
|
181
|
+
| 2026-07-19 | Default threshold 8/10 | Maps to Claude 80/100 |
|
|
182
|
+
| 2026-07-26 | CLI collapsed to `--lite` dual-mode; per-issue scorer default off; gate default Haiku | Lighten the CLI surface + align with Claude code-review |
|
|
183
|
+
| 2026-07-26 | Foreground directive mode via `sendUserMessage` (relies on pi-subagents); `--gate-model` restored; spawn path kept as fallback | Review visible in chat; gate model user-configurable |
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Structured output capture (child extension)
|
|
2
|
+
|
|
3
|
+
Child `pi` processes spawned by pi-review load `src/structured-output-capture.ts` via:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
pi --no-session --no-extensions --no-skills -e <path/to/structured-output-capture.ts> ...
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Environment variables
|
|
10
|
+
|
|
11
|
+
| Variable | Purpose |
|
|
12
|
+
|----------|---------|
|
|
13
|
+
| `PI_SUBAGENT_STRUCTURED_OUTPUT_SCHEMA` | Path to JSON Schema file (written by parent; informs model via system prompt) |
|
|
14
|
+
| `PI_SUBAGENT_STRUCTURED_OUTPUT_CAPTURE` | Path where child must write final JSON payload |
|
|
15
|
+
|
|
16
|
+
## Tool contract
|
|
17
|
+
|
|
18
|
+
The capture extension registers a single tool: `structured_output`.
|
|
19
|
+
|
|
20
|
+
- Parameters: open object (`additionalProperties: true`) — parent validates with TypeBox after spawn.
|
|
21
|
+
- `execute`: writes `JSON.stringify(params)` to capture path; returns `terminate: true`.
|
|
22
|
+
- Parent passes `--tools structured_output` (reviewers also include read/grep/… as configured).
|
|
23
|
+
|
|
24
|
+
## Parent validation
|
|
25
|
+
|
|
26
|
+
`src/spawn.ts` reads the capture file and validates against `ReviewerOutputSchema` or `GateOutputSchema`.
|