@sld0ant/pi-diff
v1.0.1
Published
High-performance diff for pi-agent with Patience algorithm and WASM acceleration
Downloads
162
Maintainers
Readme
@sld0ant/pi-diff
High-performance diff patch for pi-agent with Patience algorithm and WASM acceleration.
Quick Install
bunx @sld0ant/pi-diff installUninstall
bunx @sld0ant/pi-diff uninstallCheck Status
bunx @sld0ant/pi-diff statusFeatures
- 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
How It Works
Auto Algorithm Selection
| 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 |
Example Difference
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)
Performance
| 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 |
Build from Source
Prerequisites
- Rust + cargo
- wasm-pack (
cargo install wasm-pack) - Bun
Build
bun install
bun run buildLocal Install
bun run install-patchAfter Updating pi-agent
When pi-agent is updated, the patch will be overwritten. Reinstall:
bunx @sld0ant/pi-diff installLicense
MIT
