v2.16.5 — ctx_edit: MCP-native file editing
ctx_edit — MCP-native file editing
In Windsurf + Claude Code extension (and similar environments), the native Edit tool requires a prior Read call — but Read doesn't exist as a tool. Agents entered infinite loops trying to make Edit work, burning through 10%+ of user quota.
Added
ctx_editMCP tool — Search-and-replace that reads, modifies, and writes files in one call. No native Read/Edit dependency.ctx_edit(path, old_string, new_string)— replace unique matchctx_edit(path, old_string, new_string, replace_all=true)— replace all occurrencesctx_edit(path, new_string="...", create=true)— create new file- Error on ambiguous matches (old_string found multiple times without replace_all)
- Auto-approved in
lean-ctx setupfor all IDEs
Changed
- Instructions v7 — All injected rules now include
ctx_editin the tool mapping and explicit anti-loop guidance: "NEVER loop on Edit failures — switch to ctx_edit immediately." - PREFER over NEVER — Native tools allowed as fallback (continued from v2.16.4)
Fixed
- Agents no longer loop when Edit requires unavailable Read
- 10%+ quota burn from Edit/Read loops eliminated
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.4...v2.16.5