@roodriigoooo/pi-hunk
Review-first Shiki terminal diffs and spatial Hunk review notes for pi.
Package details
Install @roodriigoooo/pi-hunk from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@roodriigoooo/pi-hunk- Package
@roodriigoooo/pi-hunk- Version
0.4.0- Published
- Jun 25, 2026
- Downloads
- not available
- Author
- roodriigoooo
- License
- MIT
- Types
- extension
- Size
- 100 KB
- Dependencies
- 2 dependencies · 5 peers
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-hunk
A pi extension that replaces pi's default write and edit tool output with Shiki-highlighted, word-emphasised terminal diffs, and adds a read-only bridge so a human can review those changes in a live Hunk session and attach their inline review state to the agent.
Two halves
- Diff renderer. Every
writeandeditresult renders through pi-hunk with Shiki syntax tokenisation, word-level highlights viadiffWordsWithSpace, compact folding of unchanged regions, line numbers, hunk captions, changed-line gutter bars, and a bordered file header. - Read-only Hunk bridge. While the agent works, you run
hunk diff --watchin a second terminal on the same repo and add comments withc. pi-hunk reads only the comments you authored (type=user) and attaches them to the agent as review state. pi-hunk never creates, edits, applies, removes, or clears Hunk comments, and it writes no patch or sidecar files.
Install
pi install npm:@roodriigoooo/pi-hunk
Then restart pi (or run /reload). To install a pinned git ref instead:
pi install git:github.com/roodriigoooo/pi-hunk@v0.3.0
You need the hunk CLI on your PATH only if you use the review bridge. The diff renderer works on its own.
Commands
/hunk statusprobeshunk session get --repo <cwd>and reports whether a live Hunk session is attached./hunk sendreadshunk session comment list --repo <cwd> --type user --json, shapes the open review state by file and line, and attaches it to the agent as a follow-up when idle or as steering when streaming./hunk auto on|offopts in to automatic pickup before each agent turn. Pickup is scoped to notes that overlap a recent edit by file and line, and unchanged duplicate review states are not re-attached./hunk reviewopens a read-only view that pairs each open user note with whether a recent edit touched its line (✓ touched) or not (○ open). It never sends anything to the agent./hunk configureopens the configuration TUI.
LLM-callable tool
hunk_review_notesgives the model read-only, live-session-gated access to the sametype=usernotes. It returns semantic notes, not raw CLI access. The tool's prompt guidelines tell the model to address notes comment-by-comment and to never create, apply, edit, remove, or clear comments.
Checks
npm run check
Runs two scripts:
scripts/units.mjstests the exposed seams directly:parseUnifiedPatchfor structure, line numbers, word-emphasis ranges, side-aware strike highlighting, tint persistence across Shiki token resets, and no phantom trailing line;normalizeHunkCommentsfor shape tolerance, dedup, and thetype=userfilter.scripts/smoke.mjsloads the extension through pi's Jiti runtime, drives syntheticwriteandeditcalls, verifies ANSI rendering, verifies no sidecars are written, tests auto review pickup, exercises the/hunk configurelive-preview UI, and dry-runs the Hunk comment parser against a fake live session.
The check scripts locate pi by PI_CODING_AGENT_ROOT or a few common install paths (global npm, node_modules, ~/.pi/agent/npm). Set PI_CODING_AGENT_ROOT if pi lives somewhere else.
Project layout
src/config.tsconfig types, defaults, value menus, legacy migration, palette resolution, and shiki theme selection.src/paths.tspath resolution and display helpers.src/render-records.tsin-memory store of recent rendered edits.src/diff-view.tsthe DiffView module: unified-patch parser, word-emphasis model, and renderer.src/hunk-bridge.tsthe ReviewBridge module: Hunk CLI exec, comment normalization, note shaping, pickup and dedup policy, note-to-edit correlation, and the read-only review pairing.src/configure.tsthe/hunk configureTUI.src/index.tsextension entry: wires modules and registers tools, commands, and events.
License
MIT