edit_file
Safely replace exact text in remote files with unique-match validation, conflict detection, and base64-preserving writeback; ambiguous or stale edits fail instead of writing blindly.
Instructions
受控编辑远端文件:精确替换(唯一命中校验,all=true 全替换)+ TOCTOU 乐观锁(他人先写则拒绝)+ base64 保真写回(零 Shell 转义——绝不 sed -i)。未命中/多处命中/冲突均报错不盲写。返回 write_mode:atomic-replace=原子替换;inplace-write=保留 inode(bind mount 挂载点 mv 不可用降级)——非原子写入,中断可暴露半截。
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"path": "<path>",
"old": "<old>",
"new": "<new>"
},
"name": "edit_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| all | No | 多处命中全替换(缺省报错) | |
| new | Yes | ||
| old | Yes | 待替换片段(含足够上下文唯一) | |
| path | Yes | ||
| layer | No | 目标层名(缺省=默认层) | |
| write_mode | No | inplace=已知 bind mount 挂载环境显式请求保留 inode 写(跳过 mv 失败尝试) |