pi-semantic-edit
v0.4.0
Published
Edits[] edit tool for Pi — 10-pass fuzzy matcher chain (OpenDev + Unicode), replaceAll escape hatch, uniqueness guard, zero runtime deps. Replaces the built-in edit.
Maintainers
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.
A behavior 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.
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-editThat'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.
