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.

Files changed (87) hide show
  1. tunacode/cli/commands/base.py +2 -2
  2. tunacode/cli/commands/implementations/__init__.py +7 -1
  3. tunacode/cli/commands/implementations/conversation.py +1 -1
  4. tunacode/cli/commands/implementations/debug.py +1 -1
  5. tunacode/cli/commands/implementations/development.py +4 -1
  6. tunacode/cli/commands/implementations/template.py +132 -0
  7. tunacode/cli/commands/registry.py +28 -1
  8. tunacode/cli/commands/template_shortcut.py +93 -0
  9. tunacode/cli/main.py +6 -0
  10. tunacode/cli/repl.py +29 -174
  11. tunacode/cli/repl_components/__init__.py +10 -0
  12. tunacode/cli/repl_components/command_parser.py +34 -0
  13. tunacode/cli/repl_components/error_recovery.py +88 -0
  14. tunacode/cli/repl_components/output_display.py +33 -0
  15. tunacode/cli/repl_components/tool_executor.py +84 -0
  16. tunacode/configuration/defaults.py +2 -2
  17. tunacode/configuration/settings.py +11 -14
  18. tunacode/constants.py +57 -23
  19. tunacode/context.py +0 -14
  20. tunacode/core/agents/agent_components/__init__.py +27 -0
  21. tunacode/core/agents/agent_components/agent_config.py +109 -0
  22. tunacode/core/agents/agent_components/json_tool_parser.py +109 -0
  23. tunacode/core/agents/agent_components/message_handler.py +100 -0
  24. tunacode/core/agents/agent_components/node_processor.py +480 -0
  25. tunacode/core/agents/agent_components/response_state.py +13 -0
  26. tunacode/core/agents/agent_components/result_wrapper.py +50 -0
  27. tunacode/core/agents/agent_components/task_completion.py +28 -0
  28. tunacode/core/agents/agent_components/tool_buffer.py +24 -0
  29. tunacode/core/agents/agent_components/tool_executor.py +49 -0
  30. tunacode/core/agents/main.py +421 -778
  31. tunacode/core/agents/utils.py +42 -2
  32. tunacode/core/background/manager.py +3 -3
  33. tunacode/core/logging/__init__.py +4 -3
  34. tunacode/core/logging/config.py +1 -1
  35. tunacode/core/logging/formatters.py +1 -1
  36. tunacode/core/logging/handlers.py +41 -7
  37. tunacode/core/setup/__init__.py +2 -0
  38. tunacode/core/setup/agent_setup.py +2 -2
  39. tunacode/core/setup/base.py +2 -2
  40. tunacode/core/setup/config_setup.py +10 -6
  41. tunacode/core/setup/git_safety_setup.py +13 -2
  42. tunacode/core/setup/template_setup.py +75 -0
  43. tunacode/core/state.py +13 -2
  44. tunacode/core/token_usage/api_response_parser.py +6 -2
  45. tunacode/core/token_usage/usage_tracker.py +37 -7
  46. tunacode/core/tool_handler.py +24 -1
  47. tunacode/prompts/system.md +289 -4
  48. tunacode/setup.py +2 -0
  49. tunacode/templates/__init__.py +9 -0
  50. tunacode/templates/loader.py +210 -0
  51. tunacode/tools/glob.py +3 -3
  52. tunacode/tools/grep.py +26 -276
  53. tunacode/tools/grep_components/__init__.py +9 -0
  54. tunacode/tools/grep_components/file_filter.py +93 -0
  55. tunacode/tools/grep_components/pattern_matcher.py +152 -0
  56. tunacode/tools/grep_components/result_formatter.py +45 -0
  57. tunacode/tools/grep_components/search_result.py +35 -0
  58. tunacode/tools/todo.py +27 -21
  59. tunacode/types.py +19 -4
  60. tunacode/ui/completers.py +6 -1
  61. tunacode/ui/decorators.py +2 -2
  62. tunacode/ui/keybindings.py +1 -1
  63. tunacode/ui/panels.py +13 -5
  64. tunacode/ui/prompt_manager.py +1 -1
  65. tunacode/ui/tool_ui.py +8 -2
  66. tunacode/utils/bm25.py +4 -4
  67. tunacode/utils/file_utils.py +2 -2
  68. tunacode/utils/message_utils.py +3 -1
  69. tunacode/utils/system.py +0 -4
  70. tunacode/utils/text_utils.py +1 -1
  71. tunacode/utils/token_counter.py +2 -2
  72. {tunacode_cli-0.0.51.dist-info → tunacode_cli-0.0.53.dist-info}/METADATA +146 -1
  73. tunacode_cli-0.0.53.dist-info/RECORD +123 -0
  74. {tunacode_cli-0.0.51.dist-info → tunacode_cli-0.0.53.dist-info}/top_level.txt +0 -1
  75. api/auth.py +0 -13
  76. api/users.py +0 -8
  77. tunacode/core/recursive/__init__.py +0 -18
  78. tunacode/core/recursive/aggregator.py +0 -467
  79. tunacode/core/recursive/budget.py +0 -414
  80. tunacode/core/recursive/decomposer.py +0 -398
  81. tunacode/core/recursive/executor.py +0 -470
  82. tunacode/core/recursive/hierarchy.py +0 -488
  83. tunacode/ui/recursive_progress.py +0 -380
  84. tunacode_cli-0.0.51.dist-info/RECORD +0 -107
  85. {tunacode_cli-0.0.51.dist-info → tunacode_cli-0.0.53.dist-info}/WHEEL +0 -0
  86. {tunacode_cli-0.0.51.dist-info → tunacode_cli-0.0.53.dist-info}/entry_points.txt +0 -0
  87. {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)