ctx_edit: Windows CRLF support
ctx_edit failed on Windows because files use \r\n (CRLF) but agents send old_string with \n (LF). The exact string match failed silently, causing fallback to Write (full-file rewrite) or Bash.
Fixed
- CRLF/LF auto-normalization —
ctx_editdetects the file's line ending style and convertsold_string/new_stringto match. CRLF ↔ LF works transparently in both directions. - Trailing whitespace tolerance — If exact match fails,
ctx_editretries after trimming trailing whitespace per line, matching the original span. - Better error messages — Failed matches on CRLF files now show "(file uses CRLF line endings)".
- 9 unit tests covering CRLF→LF, LF→CRLF, trailing whitespace, and combined scenarios.
Also in v2.16.5 (same session)
ctx_editMCP tool — Search-and-replace without native Read/Edit dependency.- Instructions v7 — Anti-loop guidance: "NEVER loop on Edit failures — use ctx_edit."
- PREFER over NEVER — Native tools allowed as fallback.
Upgrade
cargo install lean-ctx # or
npm i -g lean-ctx-bin # or
brew upgrade lean-ctx # then:
lean-ctx setup # re-install rules (v7)Full Changelog: v2.16.5...v2.16.6