redhat-et / redhat-et/docsclaw
Add edit_file tool for surgical code edits
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2
- Forks
- 1
- Avg merge
- 6h 9m
- Merged PRs (30d)
- 1
Description
Summary
Add an edit_file tool that performs surgical edits on files — string replacement or line-range modifications — without overwriting the entire file.
Motivation
The existing write_file tool overwrites entire files, which is destructive for code changes. A coding agent needs to make targeted edits: replace a function signature, fix a specific line, insert a block at a given location. This is a prerequisite for using DocsClaw as a coding/code-analysis agent in CI/CD pipelines.
Proposed interface
{
"name": "edit_file",
"parameters": {
"path": "string — file path (workspace-scoped)",
"old_string": "string — exact text to find and replace",
"new_string": "string — replacement text"
}
}
Alternative mode (line-range):
{
"parameters": {
"path": "string",
"start_line": "integer",
"end_line": "integer",
"content": "string — replacement content for the line range"
}
}
Implementation notes
- Reuse workspace scoping and path traversal protection from
write_file - Read existing file, apply edit, write back
- Return diff preview in tool output (so the LLM can verify)
- Fail if
old_stringis not found or not unique (require enough context) - Follow existing tool pattern: implement
Toolinterface, register inserve.go
Security considerations
- Same workspace boundary enforcement as
read_file/write_file - Symlink resolution before edit
- No binary file editing
Related
- Part of the coding agent capabilities gap analysis
- Pairs with grep (#27) and glob (#28) tools for code navigation + editing workflow
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing read_file and write_file implementations, the Tool interface, and registration in serve.go. Reuse the documented workspace and symlink protections, then verify that edits reject missing or non-unique text, avoid binary files, and return a diff preview. Done means the edit_file tool supports the agreed edit mode and is registered for use.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100