diff --git a/app/tool/file_operators.py b/app/tool/file_operators.py index 61f8b16..5720172 100644 --- a/app/tool/file_operators.py +++ b/app/tool/file_operators.py @@ -42,17 +42,20 @@ class FileOperator(Protocol): class LocalFileOperator(FileOperator): """File operations implementation for local filesystem.""" + def __init__(self, encoding: str = "utf-8"): + self.encoding = encoding + async def read_file(self, path: PathLike) -> str: """Read content from a local file.""" try: - return Path(path).read_text() + return Path(path).read_text(encoding=self.encoding) except Exception as e: raise ToolError(f"Failed to read {path}: {str(e)}") from None async def write_file(self, path: PathLike, content: str) -> None: """Write content to a local file.""" try: - Path(path).write_text(content) + Path(path).write_text(content, encoding=self.encoding) except Exception as e: raise ToolError(f"Failed to write to {path}: {str(e)}") from None