pi-semantic-edit
Edits[] edit tool for Pi — 10-pass fuzzy matcher chain (OpenDev + Unicode), replaceAll escape hatch, uniqueness guard, stale-read detection, zero runtime deps. Replaces the built-in edit.
Package details
Install pi-semantic-edit from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-semantic-edit- Package
pi-semantic-edit- Version
0.3.1- Published
- Aug 3, 2026
- Downloads
- 924/mo · 924/wk
- Author
- k3_2o
- License
- MIT
- Types
- extension
- Size
- 79.5 KB
- Dependencies
- 0 dependencies · 4 peers
Pi manifest JSON
{
"extensions": [
"./index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-semantic-edit
Drop-in replacement for Pi's built-in edit. Same edits[] contract, so the model keeps writing the calls it already writes. What changes is what happens after the call: the matcher absorbs the drift models actually produce, and failures say what to fix instead of bouncing the model into a blind retry.
{ "path": "src/foo.ts", "edits": [{ "oldText": "let x = 1;", "newText": "let x = 2;" }] }
Why you'd install it
The built-in edit is strict. oldText has to match the file byte for byte, and when it doesn't the model retries in the dark. This one runs the text through a 10-pass fuzzy chain (line trim, indentation, escaped sequences, Unicode quotes and dashes) before giving up. Every pass re-verifies its match against the actual file, so tolerance never turns into an edit at the wrong location.
Two behaviors the built-in lacks:
replaceAll: trueon an edit replaces every occurrence. That's what renames actually need; without it a multi-match fails with the line positions and you add context.- Stale-read rejection. If the file changed since the model last read it, the edit is refused with a re-read message instead of silently landing on stale content.
On no-match the error quotes the closest real text plus a similarity percentage, so the retry targets what's actually in the file, not what the model remembers.
Install
pi install npm:pi-semantic-edit
That's it. edit now resolves to this tool.
Legacy input
Aider-format patch blocks still work for sessions that started on older versions, but they're deprecated. New sessions should use edits[].
Docs
- Reference: input format, matcher passes, safety behaviors, errors
- Explanation: why the matcher is built this way
License
MIT, see LICENSE.