pi-semantic-edit

Aider-format SEARCH/REPLACE edit tool for Pi — OpenDev 9-pass fuzzy matcher chain, uniqueness guard, stale-read detection, zero runtime deps. Replaces the built-in edit.

Packages

Package details

extension

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.2.5
Published
Aug 1, 2026
Downloads
152/mo · 152/wk
Author
k3_2o
License
MIT
Types
extension
Size
67.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

A drop-in replacement for Pi's built-in edit tool that accepts aider-format SEARCH/REPLACE blocks and applies them through a fuzzy matcher that tolerates the drift models actually produce.

Features

  • Aider-format input — the model writes SEARCH/REPLACE blocks exactly as it does everywhere else; nothing new to learn.
  • 10-pass fuzzy matcher — exact match first, then progressively tolerant passes for whitespace, indentation, escapes, and Unicode drift (smart quotes, dashes, non-breaking spaces).
  • Never guesses — ambiguous matches fail with the exact line positions; no silent wrong-location edits.
  • Stale-read protection — rejects edits to files that changed since the model last read them.
  • Zero runtime dependencies — Node/Bun built-ins only.

Quick Start

# Install
pi install npm:pi-semantic-edit

# Or try it without installing
pi -e npm:pi-semantic-edit

Pi packages run with full system access — review the source before using.

Once loaded, the tool replaces Pi's built-in edit. The model calls edit with a single patch field:

src/foo.ts
<<<<<<< SEARCH
old code as it appears in the file
=======
new code
>>>>>>> REPLACE

Usage

Edit a file by describing the change as a search/replace block:

edit: src/foo.ts
<<<<<<< SEARCH
let x = 1;
=======
let x = 2;
>>>>>>> REPLACE

The matcher tolerates minor drift between your SEARCH text and the file — trailing whitespace, indentation, line endings, escaped sequences, and typographic quotes all normalize during matching.

Multiple blocks in one patch, each with its own path:

src/a.ts
<<<<<<< SEARCH
alpha
=======
ALPHA
>>>>>>> REPLACE
src/b.ts
<<<<<<< SEARCH
beta
=======
BETA
>>>>>>> REPLACE

If the SEARCH text matches more than one location, the edit fails with the line positions and asks for more context — the file is left untouched. If nothing matches, the error shows the closest text actually in the file so the correction can target reality.

Documentation

  • Reference — input format, matcher passes, error behavior
  • Explanation — why the format and the matcher are designed this way

License

MIT — see LICENSE.