tunacode-cli 0.0.51__py3-none-any.whl → 0.0.53__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of tunacode-cli might be problematic. Click here for more details.
- tunacode/cli/commands/base.py +2 -2
- tunacode/cli/commands/implementations/__init__.py +7 -1
- tunacode/cli/commands/implementations/conversation.py +1 -1
- tunacode/cli/commands/implementations/debug.py +1 -1
- tunacode/cli/commands/implementations/development.py +4 -1
- tunacode/cli/commands/implementations/template.py +132 -0
- tunacode/cli/commands/registry.py +28 -1
- tunacode/cli/commands/template_shortcut.py +93 -0
- tunacode/cli/main.py +6 -0
- tunacode/cli/repl.py +29 -174
- tunacode/cli/repl_components/__init__.py +10 -0
- tunacode/cli/repl_components/command_parser.py +34 -0
- tunacode/cli/repl_components/error_recovery.py +88 -0
- tunacode/cli/repl_components/output_display.py +33 -0
- tunacode/cli/repl_components/tool_executor.py +84 -0
- tunacode/configuration/defaults.py +2 -2
- tunacode/configuration/settings.py +11 -14
- tunacode/constants.py +57 -23
- tunacode/context.py +0 -14
- tunacode/core/agents/agent_components/__init__.py +27 -0
- tunacode/core/agents/agent_components/agent_config.py +109 -0
- tunacode/core/agents/agent_components/json_tool_parser.py +109 -0
- tunacode/core/agents/agent_components/message_handler.py +100 -0
- tunacode/core/agents/agent_components/node_processor.py +480 -0
- tunacode/core/agents/agent_components/response_state.py +13 -0
- tunacode/core/agents/agent_components/result_wrapper.py +50 -0
- tunacode/core/agents/agent_components/task_completion.py +28 -0
- tunacode/core/agents/agent_components/tool_buffer.py +24 -0
- tunacode/core/agents/agent_components/tool_executor.py +49 -0
- tunacode/core/agents/main.py +421 -778
- tunacode/core/agents/utils.py +42 -2
- tunacode/core/background/manager.py +3 -3
- tunacode/core/logging/__init__.py +4 -3
- tunacode/core/logging/config.py +1 -1
- tunacode/core/logging/formatters.py +1 -1
- tunacode/core/logging/handlers.py +41 -7
- tunacode/core/setup/__init__.py +2 -0
- tunacode/core/setup/agent_setup.py +2 -2
- tunacode/core/setup/base.py +2 -2
- tunacode/core/setup/config_setup.py +10 -6
- tunacode/core/setup/git_safety_setup.py +13 -2
- tunacode/core/setup/template_setup.py +75 -0
- tunacode/core/state.py +13 -2
- tunacode/core/token_usage/api_response_parser.py +6 -2
- tunacode/core/token_usage/usage_tracker.py +37 -7
- tunacode/core/tool_handler.py +24 -1
- tunacode/prompts/system.md +289 -4
- tunacode/setup.py +2 -0
- tunacode/templates/__init__.py +9 -0
- tunacode/templates/loader.py +210 -0
- tunacode/tools/glob.py +3 -3
- tunacode/tools/grep.py +26 -276
- tunacode/tools/grep_components/__init__.py +9 -0
- tunacode/tools/grep_components/file_filter.py +93 -0
- tunacode/tools/grep_components/pattern_matcher.py +152 -0
- tunacode/tools/grep_components/result_formatter.py +45 -0
- tunacode/tools/grep_components/search_result.py +35 -0
- tunacode/tools/todo.py +27 -21
- tunacode/types.py +19 -4
- tunacode/ui/completers.py +6 -1
- tunacode/ui/decorators.py +2 -2
- tunacode/ui/keybindings.py +1 -1
- tunacode/ui/panels.py +13 -5
- tunacode/ui/prompt_manager.py +1 -1
- tunacode/ui/tool_ui.py +8 -2
- tunacode/utils/bm25.py +4 -4
- tunacode/utils/file_utils.py +2 -2
- tunacode/utils/message_utils.py +3 -1
- tunacode/utils/system.py +0 -4
- tunacode/utils/text_utils.py +1 -1
- tunacode/utils/token_counter.py +2 -2
- {tunacode_cli-0.0.51.dist-info → tunacode_cli-0.0.53.dist-info}/METADATA +146 -1
- tunacode_cli-0.0.53.dist-info/RECORD +123 -0
- {tunacode_cli-0.0.51.dist-info → tunacode_cli-0.0.53.dist-info}/top_level.txt +0 -1
- api/auth.py +0 -13
- api/users.py +0 -8
- tunacode/core/recursive/__init__.py +0 -18
- tunacode/core/recursive/aggregator.py +0 -467
- tunacode/core/recursive/budget.py +0 -414
- tunacode/core/recursive/decomposer.py +0 -398
- tunacode/core/recursive/executor.py +0 -470
- tunacode/core/recursive/hierarchy.py +0 -488
- tunacode/ui/recursive_progress.py +0 -380
- tunacode_cli-0.0.51.dist-info/RECORD +0 -107
- {tunacode_cli-0.0.51.dist-info → tunacode_cli-0.0.53.dist-info}/WHEEL +0 -0
- {tunacode_cli-0.0.51.dist-info → tunacode_cli-0.0.53.dist-info}/entry_points.txt +0 -0
- {tunacode_cli-0.0.51.dist-info → tunacode_cli-0.0.53.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Tool buffer for managing parallel execution of read-only tools."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, List, Tuple
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ToolBuffer:
|
|
7
|
+
"""Buffer for collecting read-only tool calls to execute in parallel."""
|
|
8
|
+
|
|
9
|
+
def __init__(self):
|
|
10
|
+
self.read_only_tasks: List[Tuple[Any, Any]] = []
|
|
11
|
+
|
|
12
|
+
def add(self, part: Any, node: Any) -> None:
|
|
13
|
+
"""Add a read-only tool call to the buffer."""
|
|
14
|
+
self.read_only_tasks.append((part, node))
|
|
15
|
+
|
|
16
|
+
def flush(self) -> List[Tuple[Any, Any]]:
|
|
17
|
+
"""Return buffered tasks and clear the buffer."""
|
|
18
|
+
tasks = self.read_only_tasks
|
|
19
|
+
self.read_only_tasks = []
|
|
20
|
+
return tasks
|
|
21
|
+
|
|
22
|
+
def has_tasks(self) -> bool:
|
|
23
|
+
"""Check if there are buffered tasks."""
|
|
24
|
+
return len(self.read_only_tasks) > 0
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Tool execution and parallelization functionality."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import os
|
|
5
|
+
from typing import Any, Awaitable, Callable, List, Tuple
|
|
6
|
+
|
|
7
|
+
from tunacode.core.logging.logger import get_logger
|
|
8
|
+
|
|
9
|
+
logger = get_logger(__name__)
|
|
10
|
+
|
|
11
|
+
ToolCallback = Callable[[Any, Any], Awaitable[Any]]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
async def execute_tools_parallel(
|
|
15
|
+
tool_calls: List[Tuple[Any, Any]], callback: ToolCallback, return_exceptions: bool = True
|
|
16
|
+
) -> List[Any]:
|
|
17
|
+
"""
|
|
18
|
+
Execute multiple tool calls in parallel using asyncio.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
tool_calls: List of (part, node) tuples
|
|
22
|
+
callback: The tool callback function to execute
|
|
23
|
+
return_exceptions: Whether to return exceptions or raise them
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
List of results in the same order as input, with exceptions for failed calls
|
|
27
|
+
"""
|
|
28
|
+
# Get max parallel from environment or default to CPU count
|
|
29
|
+
max_parallel = int(os.environ.get("TUNACODE_MAX_PARALLEL", os.cpu_count() or 4))
|
|
30
|
+
|
|
31
|
+
async def execute_with_error_handling(part, node):
|
|
32
|
+
try:
|
|
33
|
+
return await callback(part, node)
|
|
34
|
+
except Exception as e:
|
|
35
|
+
logger.error(f"Error executing parallel tool: {e}", exc_info=True)
|
|
36
|
+
return e
|
|
37
|
+
|
|
38
|
+
# If we have more tools than max_parallel, execute in batches
|
|
39
|
+
if len(tool_calls) > max_parallel:
|
|
40
|
+
results = []
|
|
41
|
+
for i in range(0, len(tool_calls), max_parallel):
|
|
42
|
+
batch = tool_calls[i : i + max_parallel]
|
|
43
|
+
batch_tasks = [execute_with_error_handling(part, node) for part, node in batch]
|
|
44
|
+
batch_results = await asyncio.gather(*batch_tasks, return_exceptions=return_exceptions)
|
|
45
|
+
results.extend(batch_results)
|
|
46
|
+
return results
|
|
47
|
+
else:
|
|
48
|
+
tasks = [execute_with_error_handling(part, node) for part, node in tool_calls]
|
|
49
|
+
return await asyncio.gather(*tasks, return_exceptions=return_exceptions)
|