Pi 编码代理的 Checkpoint/rewind 扩展。每个回合一个 Checkpoint、/rewind 命令、差异预览、安全恢复、重做堆栈。
Pi 编码代理的 Checkpoint/rewind 扩展。每个回合一个 Checkpoint、/rewind 命令、差异预览、安全恢复、重做堆栈。
Checkpoint/rewind extension for the Pi coding agent. Creates automatic git-based snapshots of your working tree, allowing you to rewind file changes and conversation state when the AI makes mistakes.
Every major coding agent now has rewind/undo: Claude Code (/rewind), Gemini CLI (/rewind), OpenCode (/undo), Cline (Checkpoints). Pi already has community extensions for this — checkpoint-pi and pi-rewind-hook — but neither offers a dedicated /rewind command, diff preview, or a redo stack.
pi-rewind combines the best of both existing extensions with features from the top agents, closing every gap in one package.
/rewind command — checkpoint browser → diff preview → restoreEsc+Esc keyboard shortcut — quick files-only rewindls, find, cat don't create checkpoints)"user prompt" → write → file.ts, edit → other.ts[feature] for same-branch, ⚠️ main for cross-branchnode_modules, .venv, or large files◆ X checkpoints)/fork and /tree navigationctx.compact())# From npm
pi install npm:pi-rewind
# From GitHub
pi install github.com/arpagon/pi-rewind
# For development
git clone [email protected]:arpagon/pi-rewind.git
pi -e ./pi-rewind/src/index.tsTested on repos from 20 files to 182K files (87GB monorepo):
| Repo | createCheckpoint | loadAll (startup) |
|---|---|---|
| Small (20 files) | 62ms | 8ms |
| Medium (500 files) | 62ms | 8ms |
| Large (5,000 files) | 60ms | 8ms |
| Real monorepo (182K files, 87GB) | 142ms | 8ms |
createCheckpoint = ~60-142ms constant → direct latency added per turn (imperceptible)await sequentially, so this is the actual overheadRun the benchmark yourself: npx tsx tests/bench.ts
Two-layer split: core.ts is pure git operations with zero Pi dependency (independently testable), index.ts wires Pi events to core functions.
src/
├── core.ts # 723 LOC — git operations, filtering, safe restore, branch safety, prune
├── index.ts # 280 LOC — Pi event hooks, checkpoint scheduling, auto-prune
├── commands.ts # 344 LOC — /rewind, Esc+Esc, fork/tree handlers
├── state.ts # 74 LOC — shared mutable state
└── ui.ts # 33 LOC — footer status indicator
tests/
├── core.test.ts # 362 LOC — 20 tests passing
└── bench.ts # 252 LOC — performance benchmarks# Run tests
npx tsx tests/core.test.ts
# Run benchmarks
npx tsx tests/bench.ts
# Test with Pi
pi -e ./src/index.tsThis project builds on research and code from:
And draws feature parity targets from:
/rewind — Summarize from here, double-escape trigger/rewind + /restore — Separate restore commands/undo + /redo — Step-level patches, redo stackMIT
暂无开放 Issues,或尚未同步最近议题。