auto-coder 0.1.362__py3-none-any.whl → 0.1.364__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 auto-coder might be problematic. Click here for more details.

Files changed (65) hide show
  1. {auto_coder-0.1.362.dist-info → auto_coder-0.1.364.dist-info}/METADATA +2 -2
  2. {auto_coder-0.1.362.dist-info → auto_coder-0.1.364.dist-info}/RECORD +65 -22
  3. autocoder/agent/base_agentic/__init__.py +0 -0
  4. autocoder/agent/base_agentic/agent_hub.py +169 -0
  5. autocoder/agent/base_agentic/agentic_lang.py +112 -0
  6. autocoder/agent/base_agentic/agentic_tool_display.py +180 -0
  7. autocoder/agent/base_agentic/base_agent.py +1582 -0
  8. autocoder/agent/base_agentic/default_tools.py +683 -0
  9. autocoder/agent/base_agentic/test_base_agent.py +82 -0
  10. autocoder/agent/base_agentic/tool_registry.py +425 -0
  11. autocoder/agent/base_agentic/tools/__init__.py +12 -0
  12. autocoder/agent/base_agentic/tools/ask_followup_question_tool_resolver.py +72 -0
  13. autocoder/agent/base_agentic/tools/attempt_completion_tool_resolver.py +37 -0
  14. autocoder/agent/base_agentic/tools/base_tool_resolver.py +35 -0
  15. autocoder/agent/base_agentic/tools/example_tool_resolver.py +46 -0
  16. autocoder/agent/base_agentic/tools/execute_command_tool_resolver.py +72 -0
  17. autocoder/agent/base_agentic/tools/list_files_tool_resolver.py +110 -0
  18. autocoder/agent/base_agentic/tools/plan_mode_respond_tool_resolver.py +35 -0
  19. autocoder/agent/base_agentic/tools/read_file_tool_resolver.py +54 -0
  20. autocoder/agent/base_agentic/tools/replace_in_file_tool_resolver.py +156 -0
  21. autocoder/agent/base_agentic/tools/search_files_tool_resolver.py +134 -0
  22. autocoder/agent/base_agentic/tools/talk_to_group_tool_resolver.py +96 -0
  23. autocoder/agent/base_agentic/tools/talk_to_tool_resolver.py +79 -0
  24. autocoder/agent/base_agentic/tools/use_mcp_tool_resolver.py +44 -0
  25. autocoder/agent/base_agentic/tools/write_to_file_tool_resolver.py +58 -0
  26. autocoder/agent/base_agentic/types.py +189 -0
  27. autocoder/agent/base_agentic/utils.py +100 -0
  28. autocoder/auto_coder_runner.py +6 -4
  29. autocoder/chat/conf_command.py +11 -10
  30. autocoder/common/__init__.py +2 -0
  31. autocoder/common/file_checkpoint/__init__.py +21 -0
  32. autocoder/common/file_checkpoint/backup.py +264 -0
  33. autocoder/common/file_checkpoint/examples.py +217 -0
  34. autocoder/common/file_checkpoint/manager.py +404 -0
  35. autocoder/common/file_checkpoint/models.py +156 -0
  36. autocoder/common/file_checkpoint/store.py +383 -0
  37. autocoder/common/file_checkpoint/test_backup.py +242 -0
  38. autocoder/common/file_checkpoint/test_manager.py +570 -0
  39. autocoder/common/file_checkpoint/test_models.py +360 -0
  40. autocoder/common/file_checkpoint/test_store.py +327 -0
  41. autocoder/common/file_checkpoint/test_utils.py +297 -0
  42. autocoder/common/file_checkpoint/utils.py +119 -0
  43. autocoder/common/rulefiles/autocoderrules_utils.py +138 -55
  44. autocoder/common/save_formatted_log.py +76 -5
  45. autocoder/common/v2/agent/agentic_edit.py +339 -216
  46. autocoder/common/v2/agent/agentic_edit_tools/read_file_tool_resolver.py +2 -2
  47. autocoder/common/v2/agent/agentic_edit_tools/replace_in_file_tool_resolver.py +100 -5
  48. autocoder/common/v2/agent/agentic_edit_tools/test_write_to_file_tool_resolver.py +322 -0
  49. autocoder/common/v2/agent/agentic_edit_tools/write_to_file_tool_resolver.py +160 -10
  50. autocoder/common/v2/agent/agentic_edit_types.py +1 -2
  51. autocoder/common/v2/agent/agentic_tool_display.py +2 -3
  52. autocoder/compilers/normal_compiler.py +64 -0
  53. autocoder/events/event_manager_singleton.py +133 -4
  54. autocoder/linters/normal_linter.py +373 -0
  55. autocoder/linters/python_linter.py +4 -2
  56. autocoder/rag/long_context_rag.py +424 -397
  57. autocoder/rag/test_doc_filter.py +393 -0
  58. autocoder/rag/test_long_context_rag.py +473 -0
  59. autocoder/rag/test_token_limiter.py +342 -0
  60. autocoder/shadows/shadow_manager.py +1 -3
  61. autocoder/version.py +1 -1
  62. {auto_coder-0.1.362.dist-info → auto_coder-0.1.364.dist-info}/LICENSE +0 -0
  63. {auto_coder-0.1.362.dist-info → auto_coder-0.1.364.dist-info}/WHEEL +0 -0
  64. {auto_coder-0.1.362.dist-info → auto_coder-0.1.364.dist-info}/entry_points.txt +0 -0
  65. {auto_coder-0.1.362.dist-info → auto_coder-0.1.364.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,180 @@
1
+ import json
2
+ from typing import Dict, Callable, Type
3
+ from autocoder.common.auto_coder_lang import get_system_language, format_str_jinja2
4
+ from autocoder.agent.base_agentic.types import (
5
+ BaseTool,
6
+ ReadFileTool, WriteToFileTool, ReplaceInFileTool, ExecuteCommandTool,
7
+ ListFilesTool, SearchFilesTool,
8
+ AskFollowupQuestionTool, UseMcpTool, AttemptCompletionTool
9
+ )
10
+
11
+ # Define message templates for each tool in English and Chinese
12
+ TOOL_DISPLAY_MESSAGES: Dict[Type[BaseTool], Dict[str, str]] = {
13
+ ReadFileTool: {
14
+ "en": "AutoCoder wants to read this file:\n[bold cyan]{{ path }}[/]",
15
+ "zh": "AutoCoder 想要读取此文件:\n[bold cyan]{{ path }}[/]"
16
+ },
17
+ WriteToFileTool: {
18
+ "en": (
19
+ "AutoCoder wants to write to this file:\n[bold cyan]{{ path }}[/]\n\n"
20
+ "[dim]Content Snippet:[/dim]\n{{ content_snippet }}{{ ellipsis }}"
21
+ ),
22
+ "zh": (
23
+ "AutoCoder 想要写入此文件:\n[bold cyan]{{ path }}[/]\n\n"
24
+ "[dim]内容片段:[/dim]\n{{ content_snippet }}{{ ellipsis }}"
25
+ )
26
+ },
27
+ ReplaceInFileTool: {
28
+ "en": (
29
+ "AutoCoder wants to replace content in this file:\n[bold cyan]{{ path }}[/]\n\n"
30
+ "[dim]Diff Snippet:[/dim]\n{{ diff_snippet }}{{ ellipsis }}"
31
+ ),
32
+ "zh": (
33
+ "AutoCoder 想要替换此文件中的内容:\n[bold cyan]{{ path }}[/]\n\n"
34
+ "[dim]差异片段:[/dim]\n{{ diff_snippet }}{{ ellipsis }}"
35
+ )
36
+ },
37
+ ExecuteCommandTool: {
38
+ "en": (
39
+ "AutoCoder wants to execute this command:\n[bold yellow]{{ command }}[/]\n"
40
+ "[dim](Requires Approval: {{ requires_approval }})[/]"
41
+ ),
42
+ "zh": (
43
+ "AutoCoder 想要执行此命令:\n[bold yellow]{{ command }}[/]\n"
44
+ "[dim](需要批准:{{ requires_approval }})[/]"
45
+ )
46
+ },
47
+ ListFilesTool: {
48
+ "en": (
49
+ "AutoCoder wants to list files in:\n[bold green]{{ path }}[/] "
50
+ "{{ recursive_text }}"
51
+ ),
52
+ "zh": (
53
+ "AutoCoder 想要列出此目录中的文件:\n[bold green]{{ path }}[/] "
54
+ "{{ recursive_text }}"
55
+ )
56
+ },
57
+ SearchFilesTool: {
58
+ "en": (
59
+ "AutoCoder wants to search files in:\n[bold green]{{ path }}[/]\n"
60
+ "[dim]File Pattern:[/dim] [yellow]{{ file_pattern }}[/]\n"
61
+ "[dim]Regex:[/dim] [yellow]{{ regex }}[/]"
62
+ ),
63
+ "zh": (
64
+ "AutoCoder 想要在此目录中搜索文件:\n[bold green]{{ path }}[/]\n"
65
+ "[dim]文件模式:[/dim] [yellow]{{ file_pattern }}[/]\n"
66
+ "[dim]正则表达式:[/dim] [yellow]{{ regex }}[/]"
67
+ )
68
+ },
69
+
70
+ AskFollowupQuestionTool: {
71
+ "en": (
72
+ "AutoCoder is asking a question:\n[bold magenta]{{ question }}[/]\n"
73
+ "{{ options_text }}"
74
+ ),
75
+ "zh": (
76
+ "AutoCoder 正在提问:\n[bold magenta]{{ question }}[/]\n"
77
+ "{{ options_text }}"
78
+ )
79
+ },
80
+ UseMcpTool: {
81
+ "en": (
82
+ "AutoCoder wants to use an MCP tool:\n"
83
+ "[dim]Server:[/dim] [blue]{{ server_name }}[/]\n"
84
+ "[dim]Tool:[/dim] [blue]{{ tool_name }}[/]\n"
85
+ "[dim]Args:[/dim] {{ arguments_snippet }}{{ ellipsis }}"
86
+ ),
87
+ "zh": (
88
+ "AutoCoder 想要使用 MCP 工具:\n"
89
+ "[dim]服务器:[/dim] [blue]{{ server_name }}[/]\n"
90
+ "[dim]工具:[/dim] [blue]{{ tool_name }}[/]\n"
91
+ "[dim]参数:[/dim] {{ arguments_snippet }}{{ ellipsis }}"
92
+ )
93
+ }
94
+ }
95
+
96
+ def get_tool_display_message(tool: BaseTool) -> str:
97
+ """
98
+ Generates a user-friendly, internationalized string representation for a tool call.
99
+
100
+ Args:
101
+ tool: The tool instance (Pydantic model).
102
+
103
+ Returns:
104
+ A formatted string for display in the terminal.
105
+ """
106
+ lang = get_system_language()
107
+ tool_type = type(tool)
108
+
109
+ if tool_type not in TOOL_DISPLAY_MESSAGES:
110
+ # Fallback for unknown tools
111
+ return f"Unknown tool type: {tool_type.__name__}\nData: {tool.model_dump_json(indent=2)}"
112
+
113
+ templates = TOOL_DISPLAY_MESSAGES[tool_type]
114
+ template = templates.get(lang, templates.get("en", "Tool display template not found")) # Fallback to English
115
+
116
+ # Prepare context specific to each tool type
117
+ context = {}
118
+ if isinstance(tool, ReadFileTool):
119
+ context = {"path": tool.path}
120
+ elif isinstance(tool, WriteToFileTool):
121
+ snippet = tool.content[:150]
122
+ context = {
123
+ "path": tool.path,
124
+ "content_snippet": snippet,
125
+ "ellipsis": '...' if len(tool.content) > 150 else ''
126
+ }
127
+ elif isinstance(tool, ReplaceInFileTool):
128
+ snippet = tool.diff
129
+ context = {
130
+ "path": tool.path,
131
+ "diff_snippet": snippet,
132
+ "ellipsis": ''
133
+ }
134
+ elif isinstance(tool, ExecuteCommandTool):
135
+ context = {"command": tool.command, "requires_approval": tool.requires_approval}
136
+ elif isinstance(tool, ListFilesTool):
137
+ rec_text_en = '(Recursively)' if tool.recursive else '(Top Level)'
138
+ rec_text_zh = '(递归)' if tool.recursive else '(顶层)'
139
+ context = {
140
+ "path": tool.path,
141
+ "recursive_text": rec_text_zh if lang == 'zh' else rec_text_en
142
+ }
143
+ elif isinstance(tool, SearchFilesTool):
144
+ context = {
145
+ "path": tool.path,
146
+ "file_pattern": tool.file_pattern or '*',
147
+ "regex": tool.regex
148
+ }
149
+ elif isinstance(tool, ListCodeDefinitionNamesTool):
150
+ context = {"path": tool.path}
151
+ elif isinstance(tool, AskFollowupQuestionTool):
152
+ options_text_en = ""
153
+ options_text_zh = ""
154
+ if tool.options:
155
+ options_list_en = "\n".join([f"- {opt}" for opt in tool.options])
156
+ options_list_zh = "\n".join([f"- {opt}" for opt in tool.options]) # Assuming options are simple enough not to need translation
157
+ options_text_en = f"[dim]Options:[/dim]\n{options_list_en}"
158
+ options_text_zh = f"[dim]选项:[/dim]\n{options_list_zh}"
159
+ context = {
160
+ "question": tool.question,
161
+ "options_text": options_text_zh if lang == 'zh' else options_text_en
162
+ }
163
+ elif isinstance(tool, UseMcpTool):
164
+ args_str = tool.query
165
+ snippet = args_str[:100]
166
+ context = {
167
+ "server_name": tool.server_name,
168
+ "tool_name": tool.tool_name,
169
+ "arguments_snippet": snippet,
170
+ "ellipsis": '...' if len(args_str) > 100 else ''
171
+ }
172
+ else:
173
+ # Generic context for tools not specifically handled above
174
+ context = tool.model_dump()
175
+
176
+ try:
177
+ return format_str_jinja2(template, **context)
178
+ except Exception as e:
179
+ # Fallback in case of formatting errors
180
+ return f"Error formatting display for {tool_type.__name__}: {e}\nTemplate: {template}\nContext: {context}"