diff --git a/codemcp/common.py b/codemcp/common.py index ce64c377..e5e5a98e 100644 --- a/codemcp/common.py +++ b/codemcp/common.py @@ -87,7 +87,9 @@ def get_edit_snippet( return "\n".join(result) -def truncate_output_content(content: Union[str, bytes], prefer_end: bool = True) -> str: +def truncate_output_content( + content: Union[str, bytes, None], prefer_end: bool = True +) -> str: """Truncate command output content to a reasonable size. When prefer_end is True, this function prioritizes keeping content from the end @@ -101,8 +103,10 @@ def truncate_output_content(content: Union[str, bytes], prefer_end: bool = True) Returns: The truncated content with appropriate indicators """ + if content is None: + return "" if not content: - return "" if content is None else str(content) + return str(content) # Convert bytes to str if needed if isinstance(content, bytes): diff --git a/codemcp/file_utils.py b/codemcp/file_utils.py index 5d94bc06..b191ff60 100644 --- a/codemcp/file_utils.py +++ b/codemcp/file_utils.py @@ -7,9 +7,9 @@ import anyio from .access import check_edit_permission +from .async_file_utils import OpenTextMode from .git import commit_changes from .line_endings import apply_line_endings, normalize_to_lf -from .async_file_utils import OpenTextMode __all__ = [ "check_file_path_and_permissions",