review — First-Class Code Review for Agents
TL;DR
/review turns "paste a diff for AI to look at" into a repeatable capability: clear scope, noise-controlled, one shared engine for human and model.
Overview
"Have AI look at this code" stumbles on: where the diff comes from, too much noise, unstable prompts, split human/model entry points. @piex-dev/review consolidates it: humans use /review, the model uses the review tool, the core is one git-diff collection + noise filter + structured prompt. A lightweight omp review: keeps the diff engine and modes, drops multi-agent parallel review and TUI overlay.
How it works
Review = pick scope + clean noise + feed structured context. Core insight: review quality depends on whether the diff fed to the model is clean — half the tokens being package-lock.json is waste. 5 modes map to real dev actions: uncommitted / staged / vs base branch (with fetch) / commit / custom.
pick mode → git diff/show → parse unified diff
→ drop noise (lock/min/build/vendor) → build Markdown prompt
→ hand to current session model for findings
Human and model share the engine: /review uses a UI menu, the review tool uses params; both end up in parseDiff + buildReviewPrompt.
Usage
Install
pi install npm:@piex-dev/review
Source: extensions/review
Prerequisites
The current directory is a git repo; git is on the machine.
Usage
Human: /review lists the mode menu. Model: call the review tool with action (diff/staged/commit/branch). After selection a prompt is generated and sent back via pi.sendUserMessage(..., { deliverAs: "followUp" }) for the current model to act as reviewer.
Verify
pi -e ./extensions/review/src/review.ts -p "what is 1+1" --no-session
Implementation
~350 lines, single file. Noise filter (EXCLUDED_PATTERNS) auto-excludes lock/build/vendor/generated/media-binary; excluded files still appear in an "Excluded" section (path + reason + line count) so the model knows things were filtered without ingesting them. Diff parsing chunks by diff --git counting +/-. Prompt generation: skips embedding full diff when too large (>50k chars or >20 files, suggests read); unified instructions grade findings critical/warning/info with file+line.
| omp | piex review |
|---|---|
| multi-agent parallel review | current agent reviews directly |
| TUI overlay | text output |
| Diff + noise filter | ✅ |
| Multiple modes | ✅ (light set) |
| Structured prompt | ✅ streamlined |
Design notes
| Project | Mechanism | piex choice |
|---|---|---|
| oh-my-pi review | command + tool; multi-agent parallel + TUI overlay; diff engine + noise filter + structured prompt | Adopted: diff engine, noise filter, multi-mode, shared prompt. Not adopted: multi-agent parallel (needs subagent), TUI overlay |
| OpenCode /review | built-in command, review uncommitted or specified commit/branch | Borrowed: interactive menu, unified prompt template, multi-source review |
Core trade-off: keep the diff engine and noise filter intact (feed the model clean context), drop parallelism and visual overlay.
Changelog
Roadmap
| Direction | Plan |
|---|---|
| Single model, single thread | near-term optional multi-pass (critical then style); long-term migrate to omp multi-agent when subagent is ready |
| Weak findings↔code binding | output findings JSON; link diagnostics, route runtime suspects to dap |
| Naive base-branch & noise rules | project-level .reviewignore/pathspec; configurable remote & default branch |
| Result is chat text | attach a machine-readable block beyond Markdown; serve local workflow first, then gating |
| Extreme diffs | parser covers real PR edge cases (rename/binary/submodule) |
Version history
| Version | Date | Changes |
|---|---|---|
| 0.1.1 | 2026-07-19 | Initial release: diff engine (parseDiff) + noise filter (EXCLUDED_PATTERNS); 5 modes; buildReviewPrompt structured prompt (oversized diff not inlined); shared engine for human/model; omp lightweight (no multi-agent parallel or TUI overlay) |
Source Markdown: docs/packages/review.md