Open-source, local-first AI agent for real work.
TypeScript agent-toolsai-agentbyokcoding-agentcross-platformdesktop-appdeveloper-toolselectronharnessknowledge-basellmwikilocal-firstmcpplugin-systemprivacy-firstskillstypescriptvettaworkflow-automation
export const EDIT_TOOL_DESCRIPTION = [
"Edit a file surgically. Two modes — block mode (preferred) and exact-text mode.",
"",
"BLOCK MODE (preferred): pass `edits`, an array of { oldText, oldEndText?, newText }.",
"- `oldText` is copied from the file: the block's first line, or any unique fragment of it. Indentation and internal spacing are ignored when matching, so do not worry about re-creating them exactly — but the words must be the file's words, not your paraphrase.",
"- The block runs from the start of the line containing `oldText` to the end of that line. Add `oldEndText` (another line copied from the file) to reach further: everything up to and including that line is replaced. This is how you replace a 60-line region without retyping its middle.",
"- `newText` replaces those whole lines. Empty newText deletes them. Send file content only — never the `42:` line numbers from read output.",
"- If `oldText` matches more than one place the edit is rejected and the error lists the candidates. Fix it by making `oldText` more specific (add a neighbouring line); never by retrying the same value. If every match should get the same change, use exact-text mode with `replaceAll: true`.",
"- The batch is atomic: if any block cannot be located, nothing is written and the error names the failing entry.",
"- After a success the result shows the current lines around each change. Line numbers shift with every edit, so re-read those numbers from the latest result instead of remembering older ones.",
"",
"EXACT-TEXT MODE: pass `oldText`/`newText` for one character-precise replacement. `oldText` must match exactly (including whitespace) and appear once in the file. This is the only mode that can change part of a line in place.",
"- Add `replaceAll: true` to change every occurrence of `oldText` in this file at once (renaming a selector, string or identifier within one file). The result reports how many places changed.",
"",
"SIZE GUIDANCE — this tool is for surgical changes, not rewrites:",
"- A hand-written block above ~30 lines is where structure mistakes come from; it fails about three times as often as a small one. It still usually succeeds, so this tool will not refuse it — but for a block that size, `write` or a short python3 script is the safer call.",
"- Many small blocks in one batch are fine.",
"",
"WHEN NOT TO USE THIS TOOL:",
"- Whole-file rewrites: use `write`.",
"- The same change across many files, renaming a symbol across the codebase, reformatting, restructuring from a list of pairs, or generating a large block: use `bash` with a short `python3` script that reads, transforms, writes and prints a diff. One deterministic call you can verify beats dozens you cannot.",
"- A single mechanical regex substitution where you cannot read the exact text: `bash` + `sed -i` is fine for a one-off; prefer python3 when the pattern contains `/`, quotes, or must report a count.",
"",
"SAFETY RAILS — these reject the edit before anything is written:",
"- A replacement that would leave the file's brackets or JSX tags more unbalanced than they already were.",
"- A replacement identical to the text it replaces.",
"",
"Read or grep the file first: you must quote its current text. A block edit needs no other preparation — there is no snapshot token to carry between turns, so nothing you read earlier can go stale as long as the text itself is still there.",
].join("\n");