From 977ddbeba23b9c0f6a4c586e98a9e614cb78f681 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Tue, 25 Mar 2025 19:07:36 +0800 Subject: [PATCH] Update [ghstack-poisoned] --- codemcp/common.py | 8 ++++++-- codemcp/file_utils.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) 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",