↓ Skip to main content

pi-diff

4 mins·
Table of Contents

English 简体中文

Review per-turn, session-wide, and Git changes in a fullscreen TUI inside pi. Browse changed files on the left and inspect diffs on the right, with mouse support, automatic line wrapping, and unified or split views.


Features
#

  • Review at different scopes: inspect the latest task, session total, or Git changes, with file counts and added/removed line totals.
  • Keep your history: recorded task diffs remain available after reloading pi, resuming a session, or switching session branches.
  • Use either language: switch between English and Simplified Chinese with l / L; your choice is remembered.
  • Review safely: viewing diffs does not stage, commit, or revert files. Task and session views also work outside Git repositories.

Unified and split views
#

Read changes in one column or compare old and new content side by side. Press v / V or click the view toggle to switch. Long lines wrap automatically, and colors follow your pi theme. Added/deleted files and narrow windows use unified view.

Unified view with a changed-file tree and highlighted additions and deletions
Unified view

Split view comparing old and new content side by side
Split view

Click either image to view it at full size.

File tree and draggable divider
#

File tree with A/M/D markers and a highlighted draggable divider

Find changed files in collapsible directories. A, M, and D indicate added, modified, and deleted files.

Drag the divider to give more space to the tree or diff; double-click to reset. Drag to the left edge to hide the tree, then press [ or click [Show files] to bring it back.

Inspired by opencode
#

Inspired by opencode, pi-diff brings its terminal diff review experience into pi through /diff.


Installation
#

Project development environment: pi 1.2.0 or later, Node.js ≥ 22.19.0, npm, and Git.

1# Install the extension
2pi install npm:@lyrumu/pi-diff

Alternatively, install from GitHub:

1# Install from GitHub
2pi install git:github.com/lyrumu/pi-diff

Restart pi after installation, or enter /reload in a running session.

To update or uninstall:

1# Update the extension
2pi update npm:@lyrumu/pi-diff
3
4# Uninstall the extension
5pi remove npm:@lyrumu/pi-diff

If you installed from GitHub, use git:github.com/lyrumu/pi-diff as the source in both commands instead.


Usage
#

Start pi in your project directory and enter /diff. Git repositories open Unstaged by default; other projects open Last turn. To browse files, press [, select with j / k, then press ] to read and scroll the diff. The interface starts in English; press l / L for Simplified Chinese.

Press Tab / Shift+Tab to cycle forward or backward through the available scopes:

ScopeChanges shown
Last turnChanges from the most recent task
Session totalCumulative changes recorded on the current session branch
UnstagedChanges that have not been staged
UncommittedStaged and unstaged changes
All branch changesChanges relative to the base branch, including committed and uncommitted work

Git scopes also include untracked files. Outside a Git repository, only the first two scopes are available.

Keyboard and mouse
#

English shortcut bar: l/L language, brackets for focus, Tab/Shift+Tab scope, v/V view, arrows or wheel and j/k for scrolling, Esc/q to close

The shortcut bar follows the current focus: j / k select files when the tree is focused and scroll when the diff is focused.

ActionKeyboard / mouse
Select files and collapse directoriesClick; use ↑↓ in the file tree and Enter / Space to expand or collapse directories
Next / previous filej / k while the file tree is focused
Focus the file tree / diff[ / ], or click the corresponding pane
Resize / hide the file treeDrag the divider; drag to the left edge to hide; double-click to reset the width
Show the hidden file tree[ or click [Show files] at the top
Scroll the diffMouse wheel, ↑↓, j / k, PageUp / PageDown; Home / End jump to the start / end
Switch unified / split viewv / V, or click the view toggle at the top
Switch English / Simplified Chinesel / L
CloseEsc / q

In narrow windows, [ / ] switch between the file tree and diff pages.


Data and limitations
#

  • Task and session history only covers changes recorded after enabling the extension, within the project directory. Git scopes can show existing changes.
  • Outside Git repositories, shell changes may show Previous contents unknown. If a complete session total cannot be restored, the viewer says so.
  • Binary files and diffs exceeding 10 MB show a notice instead of their contents.

License
#

MIT. Parts of the implementation are ported from opencode. See NOTICE.md and third-party licenses for attribution and license terms.

Tweet on Twitter