High-performance diff patch for pi-agent with Patience algorithm and WASM acceleration.
bunx @sld0ant/pi-diff installbunx @sld0ant/pi-diff uninstallbunx @sld0ant/pi-diff status- Patience algorithm for code — better structure preservation (functions, classes)
- Myers algorithm for data — faster for JSON, YAML, Markdown
- WASM acceleration — 5-8x faster on large files (>1000 lines)
- 80 KB — compact universal WASM bundle
| File Type | Algorithm | Reason |
|---|---|---|
.ts, .js, .py, .rs, .go |
Patience | Preserves code structure |
.json, .yaml, .md, .txt |
Myers | Faster for data |
| >10000 lines | Myers | Performance |
Refactoring: moving a function
Myers shows:
-function hello() { ... }
+function world() { ... }(thinks hello was replaced with world)
Patience shows:
+function world() { ... }
function hello() { ... }(understands world was added, hello stayed)
| File Size | JS (diff) | WASM (@sld0ant/pi-diff) | Speedup |
|---|---|---|---|
| 1000 lines | 4ms | 2.5ms | 1.6x |
| 5000 lines | 119ms | 21ms | 5.6x |
| 10000 lines | 520ms | 64ms | 8.1x |
- Rust + cargo
- wasm-pack (
cargo install wasm-pack) - Bun
bun install
bun run buildbun run install-patchWhen pi-agent is updated, the patch will be overwritten. Reinstall:
bunx @sld0ant/pi-diff installMIT