pi-lean-edit
Safer, cheaper edits by verifying prior reads in the harness instead of the prompt. Lets the harness verify the model already read the latest text it wants to edit, avoiding old-text replay and hash-decorated reads.
Package details
Install pi-lean-edit from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-lean-edit- Package
pi-lean-edit- Version
0.2.0- Published
- May 29, 2026
- Downloads
- not available
- Author
- sergiobonf
- License
- unknown
- Types
- extension
- Size
- 66.7 KB
- Dependencies
- 1 dependency · 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-lean-edit
Safer, cheaper edits by verifying prior reads in the harness instead of the prompt.
Formerly
pi-smart-edit.
pi-lean-edit lets the harness verify the model already read the latest text it wants to edit, reducing stale-edit failures without resending old text in edit requests and without the per-read overhead of hash-decorated output.
Install or test
Install permanently:
pi install npm:pi-lean-edit
Test without installing permanently:
pi --no-extensions -e npm:pi-lean-edit
To load it alongside your normal setup:
pi -e npm:pi-lean-edit
Tools
read
{ path: string; offset?: number; limit?: number; columnOffset?: number; columnLimit?: number }
Shows numbered text lines and stores shown ranges as in-memory snapshots for that file. Adjacent line reads merge into wider covered ranges. Huge single-line reads can continue with columnOffset/columnLimit; columnOffset is single-line only, so omit limit or set limit=1. Adjacent/overlapping huge-line column windows compose into wider column coverage.
edit
{ path: string; startLine: number; endLine?: number; startColumn?: number; endColumn?: number; newText: string }
// or
{ path: string; edits: Array<{ startLine: number; endLine?: number; startColumn?: number; endColumn?: number; newText: string }> }
edit applies one or more non-overlapping inclusive ranges after read has shown those ranges for the same canonical file. If the file changed, it fails with file stale, read again. Normal-line column edits require a whole-line snapshot; huge-line column edits can use matching column snapshots. After a successful edit, edited ranges are invalidated. Same-line-count edits preserve unaffected later snapshots; line-count-changing edits invalidate later snapshots.
Metrics
Successful edits record saved characters versus exact-text edit payloads. Failed edits increment failure rate. Global metrics persist at ~/.pi/agent/pi-lean-edit/metrics.json by default, or PI_LEAN_EDIT_METRICS_PATH if set.
Show stats:
/lean-edit-stats
Test
npm test
Notes
read output is capped by line and byte limits. Defaults: PI_LEAN_EDIT_MAX_READ_LINES=2000, PI_LEAN_EDIT_MAX_READ_BYTES=50000.