Patch file content (replace old_str with new_str). Args: path: Path to file old_str: String to find and replace new_str: Replacement string Returns: Diff of changes or error message
(path: str, old_str: str, new_str: str)
| 154 | |
| 155 | |
| 156 | def tool_patch_file(path: str, old_str: str, new_str: str) -> str: |
| 157 | """ |
| 158 | Patch file content (replace old_str with new_str). |
| 159 | |
| 160 | Args: |
| 161 | path: Path to file |
| 162 | old_str: String to find and replace |
| 163 | new_str: Replacement string |
| 164 | |
| 165 | Returns: |
| 166 | Diff of changes or error message |
| 167 | """ |
| 168 | try: |
| 169 | return _get_fs().patch(path, old_str, new_str) |
| 170 | except FilesystemAccessError as e: |
| 171 | return f"[ERROR] {e}" |
| 172 | |
| 173 | |
| 174 | def tool_append_file(path: str, content: str) -> str: |