Skip to content
Merged
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
2 changes: 1 addition & 1 deletion cecli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from packaging import version

__version__ = "0.99.6.dev"
__version__ = "0.99.7.dev"
safe_version = __version__

try:
Expand Down
2 changes: 1 addition & 1 deletion cecli/coders/agent_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, *args, **kwargs):
self.read_tools = {
"command",
"commandinteractive",
"exploresymbols",
"explorecode",
"ls",
"grep",
"showcontext",
Expand Down
9 changes: 5 additions & 4 deletions cecli/commands/copy_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from cecli.commands.utils.base_command import BaseCommand
from cecli.commands.utils.helpers import format_command_result
from cecli.helpers.conversation import ConversationService, MessageTag


class CopyContextCommand(BaseCommand):
Expand All @@ -13,13 +14,13 @@ class CopyContextCommand(BaseCommand):
@classmethod
async def execute(cls, io, coder, args, **kwargs):
"""Execute the copy-context command with given parameters."""
chunks = coder.format_chat_chunks()
manager = ConversationService.get_manager(coder)

markdown = ""

# Only include specified chunks in order
for messages in [chunks.repo, chunks.readonly_files, chunks.chat_files]:
for msg in messages:
# Only include specified chunks in order using conversation tags
for tag in [MessageTag.REPO, MessageTag.READONLY_FILES, MessageTag.CHAT_FILES]:
for msg in manager.get_messages_dict(tag=tag):
# Only include user messages
if msg["role"] != "user":
continue
Expand Down
50 changes: 49 additions & 1 deletion cecli/helpers/background_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import subprocess
import threading
from collections import deque
from typing import Dict, Optional, Tuple
from typing import Dict, List, Optional, Tuple

try:
import pty
Expand Down Expand Up @@ -624,3 +624,51 @@ def list_background_commands(cls) -> Dict[str, Dict[str, any]]:
),
}
return result

@staticmethod
def save_paginated_output(
output: str,
command_key: str,
page_size: int,
abs_root_path_func,
local_agent_folder_func,
) -> Optional[Tuple[str, List[str], List[str]]]:
"""
Save long output to paginated files in a folder for later access.

When output exceeds the page_size threshold, it is split into multiple
files named `{page_number}.txt` inside a folder named `{command_key}`
in the agent's local folder.

Args:
output: Full output text to save
command_key: Command key used for both folder naming and as the filename root
page_size: Maximum characters per page (typically large_file_token_threshold)
abs_root_path_func: Callable to convert relative path to absolute (e.g., coder.abs_root_path)
local_agent_folder_func: Callable to generate relative paths (e.g., coder.local_agent_folder)

Returns:
Tuple of (folder path, rel file paths list, alias paths list), or None if output fits in one page.
"""
if not output or len(output) <= page_size:
return None

folder_path = local_agent_folder_func(command_key)
abs_folder = abs_root_path_func(folder_path)
os.makedirs(abs_folder, exist_ok=True)

num_pages = (len(output) + page_size - 1) // page_size

for i in range(num_pages):
page_num = i + 1
filename = f"{page_num}.txt"
abs_path = os.path.join(abs_folder, filename)
page_content = output[i * page_size : (i + 1) * page_size]
with open(abs_path, "w") as f:
f.write(page_content)

file_paths = [f"{folder_path}/{page_num}.txt" for page_num in range(1, num_pages + 1)]
alias_paths = [
f"command_key::{command_key}/{page_num}.txt" for page_num in range(1, num_pages + 1)
]
return (folder_path, file_paths, alias_paths)
12 changes: 0 additions & 12 deletions cecli/helpers/conversation/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,25 +786,13 @@ def add_file_context_messages(self, promote_messages=True) -> None:
tag=MessageTag.FILE_CONTEXTS,
hash_key=("file_context_user", file_path),
force=True,
promotion=(
ConversationService.get_manager(coder).DEFAULT_TAG_PROMOTION_VALUE
if promote_messages
else None
),
mark_for_demotion=1 if promote_messages else None,
)

ConversationService.get_manager(coder).add_message(
message_dict=assistant_msg,
tag=MessageTag.FILE_CONTEXTS,
hash_key=("file_context_assistant", file_path),
force=True,
promotion=(
ConversationService.get_manager(coder).DEFAULT_TAG_PROMOTION_VALUE
if promote_messages
else None
),
mark_for_demotion=1 if promote_messages else None,
)

def reset(self) -> None:
Expand Down
Loading
Loading