Repository navigation
pi-snap-edit v5.0.0
pi-snap-edit v5.0.0
Breaking release. target_edit now cascades through match tiers automatically instead of requiring matchMode: "trim", and reports the tier whenever a match is not exact. Also removes substitute_edit entirely.
Changes
- Automatic match cascade for
target_edit: matching now falls through exact substring → unescaped target → whole-line trim. The trim tier only runs when both earlier tiers miss, so a unique exact hit is never diluted into an ambiguous reject. Indentation or trailing-whitespace drift succeeds without a retry, saving a read/edit round-trip. - Match tier reporting: when a match is not exact, the tool output states how it matched (
matched via trim (indentation or trailing whitespace differed)ormatched via unescape (escape sequences in target were normalized)), prefixed withop[N]in multi-op batches. Exact matches stay silent. Relaxed matching is deliberately visible so a wrong-but-plausible match can be caught rather than applied quietly. - Trim semantics gated on occurrence kind: trim behavior now keys off the resolved occurrence being a trim match rather than the caller's
matchMode. Onreplace, edge trimming keeps the file's original indentation; previously the auto path would double it. Auto-cascade and explicitmatchMode: "trim"produce byte-identical output for the same input, unless the target also matches exactly — then auto-cascade correctly resolves to the exact hit whilematchMode: "trim"ignores it by design. deleteon a trim match removes the whole line: previously it blanked the content and left an indentation-only line behind. Multi-line trim blocks remove all matched lines, and deleting the last line of a file without a trailing newline removes the preceding line terminator instead of leaving one dangling.deleteon an exact or unescaped match keeps literal substring semantics.matchModeunchanged in meaning: still accepted, still forces trim-only matching and ignores exact substring hits — useful when the target text also appears inside an indented line.- Removed
substitute_edit: unregistered as a callable tool since v3.0.0; its engine, schema, and exports are now gone. Thesubstitute_editfilter in active-tool preference is kept so saved state from older sessions is still cleaned up. - Docs: README,
target_editpromptGuidelines, and thematchModeschema description updated to describe the cascade instead of instructing callers to opt into trim.
Breaking
applySubstituteEditsand theSubstitutiontype are no longer exported.target_editsucceeds on some inputs that previously failed withtarget not found. Callers relying on strict exact-only matching should passmatchMode: "exact"-equivalent unique targets, or aline/rangeselector.target_editdeleteon a trim match now removes the whole line instead of blanking it. Callers that relied on the leftover indentation-only line must adjust.
Install
pi install npm:pi-snap-editVerification
npm run typecheckpassed.npm testpassed (106 tests).git diff --checkpassed.npm pack --dry-runpassed.- A/B verified against the previous release: exact-path behavior is unchanged across exact substring
delete,deletewith alineselector, unescapedelete, exact multi-line blockdelete, trimreplace, and triminsert_after; auto-cascade output matches explicitmatchMode: "trim"on single-line, no-indent replacement, multi-line block, and CRLF/no-trailing-newline cases; ambiguous trim matches still reject; a failing later operation still rolls back a valid earlier trim edit. - Live-tested through the registered Pi
read,quick_edit, andtarget_edittools ontmp/fixtures, verifying exact bytes for tab indentation, CRLF, no-trailing-newline, and UTF-8 content.