Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions codemcp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion codemcp/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading