pi-diff-widget0.2.1
Interactive diff viewer for pi: uncommitted changes and per-turn diffs
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-diff-widget
Interactive diff viewer and live edits widget for pi.

Install
pi install npm:pi-diff-widget
# straight from the repo, no npm required
pi install git:github.com/omgzsa/pi-diff-widget
# or from a local checkout
pi install /absolute/path/to/pi-diff-widget
Usage
/diff
Opens a scrollable overlay with two sources:
- Uncommitted: tracked modifications, staged changes, deletions, and
untracked files from
git diff HEAD. - Turns: the files the agent edited, grouped by the prompt that caused them. Read straight from the session, so it needs no git and works anywhere.
Diffs render with pi's own renderer, so colors and intra-line highlighting match the inline edit diffs.
Keys:
Tab: switch between uncommitted and turns[/]: previous / next turn (turns view)up/down: scroll one linepageUp/pageDown: scroll one pagen/p: next / previous file or sectiong/G: jump to top / bottomq/Esc: close
See Commands for /diff accept, /diff reject, and the
/diff-widget visibility toggle.
Live edits widget
Above the editor, pi-diff shows the net effect of the agent's edits this session, refreshed at each turn boundary:
edits · 3 files · +3 -0
src/git.ts +1 -0
src/index.ts +1 -0
src/ui.ts +1 -0
For each file the agent touches, pi-diff records the content before the first touch and diffs it against the current content. Reverted files drop out and the counts are net, so it shows what the agent has actually changed, not cumulative churn. Committing a file drops it from the panel automatically, so what remains is the agent's work that is not yet committed. Paths are shown relative to the working directory. Baselines live in the session, capped at 256 KB per file. A baseline whose parent directory no longer exists is dropped, so a checkout you move or delete stops counting as a whole-file deletion.
It hides itself when nothing differs.
Commands
Keeping or undoing the agent's edits acts on the tracked files, not on everything
the uncommitted view lists: /diff accept and /diff reject work from the
session baselines, so files the agent never touched are left alone. If you hand
edit a tracked file after the agent first touched it, /diff reject discards
that edit too.
| Command | Effect |
|---|---|
/diff accept |
Keep the agent's edits: the current content becomes the baseline and the panel clears. Alias: keep |
/diff reject |
Undo the agent's edits: restore every tracked file to its pre-agent content, delete the files the agent created, and recreate the ones it deleted |
/diff-widget |
Toggle the panel. With no argument it shows a hidden panel and hides a visible one |
/diff-widget on |
Show it |
/diff-widget off |
Hide it |
accept is Zed's Keep All. reject asks for confirmation first, naming up to
five affected paths, and cannot be undone. Whole files only: there is no
hunk-level accept or reject. With nothing to reject it reports Nothing to reject. Any unrecognized argument warns instead of acting, so a typo never hides
the panel or reverts a file. Both commands complete their arguments on Tab.
/diff accept
/diff reject
/diff-widget off
Status
- Uncommitted changes (
git diff HEADplus untracked files) - Per-turn diffs grouped by prompt, reconstructed from session edit results
-
write-tool before/after snapshots, persisted per turn - Live net edits widget above the editor, with
/diff-widget on|off|accept|reject
See ROADMAP.md for planned work and known gaps.
How it works
- Uncommitted diffs shell out to git, then feed old and new content into pi's
generateDiffStringandrenderDiff. No third-party diff library. - Per-turn diffs read pi's session data. The
edittool persistsdetails.diffper call, so reconstruction needs no git and works outside a repo. Thewritetool stores no diff, so atool_callhandler snapshots the old content, synthesizes one ontool_result, and appends it to the session atturn_end. Write diffs therefore survive reload, same as edit diffs.
Development
npm install
npm run typecheck
npm test
pi -e ./src/index.ts # then run /diff
Tests use the built-in node:test runner with no extra dependencies. Git tests
build throwaway repos under the system temp directory.