Context
The current file mutation tools are `write_file` (full overwrite) and `replace` (exact string match replacement). The upstream Node.js CLI also provides an `edit` tool that supports line-range-based editing — inserting, deleting, or replacing specific line ranges.
This is a meaningful gap because:
- `replace` requires the model to reproduce the exact target string, which is fragile for large blocks
- `write_file` requires rewriting the entire file for a small change
- Line-oriented editing is a more natural fit for how models think about code modifications
Proposed change
Implement an `edit` tool in `internal/tools/` that accepts:
- `file_path`: target file
- `start_line` / `end_line`: line range to operate on
- `new_content`: replacement content for that range (empty = delete)
- `insert_before` or `insert_after`: insert mode (alternative to replace)
The tool should:
- Register in `internal/tools/registry.go`
- Use the same approval flow as `write_file` and `replace`
- Validate line numbers against actual file length
- Handle edge cases (empty file, single-line file, append at end)
Relevant files
- `internal/tools/registry.go` — tool registration
- `internal/tools/replace.go` — existing string-replace tool (pattern to follow)
- `internal/tools/executor.go` — approval flow
Context
The current file mutation tools are `write_file` (full overwrite) and `replace` (exact string match replacement). The upstream Node.js CLI also provides an `edit` tool that supports line-range-based editing — inserting, deleting, or replacing specific line ranges.
This is a meaningful gap because:
Proposed change
Implement an `edit` tool in `internal/tools/` that accepts:
The tool should:
Relevant files