auto-coder 1.0.0__py3-none-any.whl → 2.0.1__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 (574) hide show
  1. auto_coder-2.0.1.dist-info/LICENSE +158 -0
  2. auto_coder-2.0.1.dist-info/METADATA +558 -0
  3. auto_coder-2.0.1.dist-info/RECORD +795 -0
  4. {auto_coder-1.0.0.dist-info → auto_coder-2.0.1.dist-info}/WHEEL +1 -1
  5. {auto_coder-1.0.0.dist-info → auto_coder-2.0.1.dist-info}/entry_points.txt +3 -3
  6. autocoder/__init__.py +31 -0
  7. autocoder/agent/auto_filegroup.py +32 -13
  8. autocoder/agent/auto_learn_from_commit.py +9 -1
  9. autocoder/agent/base_agentic/__init__.py +3 -0
  10. autocoder/agent/base_agentic/agent_hub.py +1 -1
  11. autocoder/agent/base_agentic/base_agent.py +235 -136
  12. autocoder/agent/base_agentic/default_tools.py +119 -118
  13. autocoder/agent/base_agentic/test_base_agent.py +1 -1
  14. autocoder/agent/base_agentic/tool_registry.py +32 -20
  15. autocoder/agent/base_agentic/tools/read_file_tool_resolver.py +24 -3
  16. autocoder/agent/base_agentic/tools/write_to_file_tool_resolver.py +24 -11
  17. autocoder/agent/base_agentic/types.py +42 -0
  18. autocoder/agent/entry_command_agent/chat.py +77 -73
  19. autocoder/auto_coder.py +31 -40
  20. autocoder/auto_coder_rag.py +11 -1084
  21. autocoder/auto_coder_runner.py +962 -2345
  22. autocoder/auto_coder_terminal.py +26 -0
  23. autocoder/auto_coder_terminal_v3.py +190 -0
  24. autocoder/chat/conf_command.py +224 -124
  25. autocoder/chat/models_command.py +361 -299
  26. autocoder/chat/rules_command.py +79 -31
  27. autocoder/chat_auto_coder.py +988 -398
  28. autocoder/chat_auto_coder_lang.py +23 -732
  29. autocoder/commands/auto_command.py +25 -8
  30. autocoder/commands/auto_web.py +1 -1
  31. autocoder/commands/tools.py +44 -44
  32. autocoder/common/__init__.py +150 -128
  33. autocoder/common/ac_style_command_parser/__init__.py +39 -2
  34. autocoder/common/ac_style_command_parser/config.py +422 -0
  35. autocoder/common/ac_style_command_parser/parser.py +292 -78
  36. autocoder/common/ac_style_command_parser/test_parser.py +241 -16
  37. autocoder/common/ac_style_command_parser/test_typed_parser.py +342 -0
  38. autocoder/common/ac_style_command_parser/typed_parser.py +653 -0
  39. autocoder/common/action_yml_file_manager.py +25 -13
  40. autocoder/common/agent_events/__init__.py +52 -0
  41. autocoder/common/agent_events/agent_event_emitter.py +193 -0
  42. autocoder/common/agent_events/event_factory.py +177 -0
  43. autocoder/common/agent_events/examples.py +307 -0
  44. autocoder/common/agent_events/types.py +113 -0
  45. autocoder/common/agent_events/utils.py +68 -0
  46. autocoder/common/agent_hooks/__init__.py +44 -0
  47. autocoder/common/agent_hooks/examples.py +582 -0
  48. autocoder/common/agent_hooks/hook_executor.py +217 -0
  49. autocoder/common/agent_hooks/hook_manager.py +288 -0
  50. autocoder/common/agent_hooks/types.py +133 -0
  51. autocoder/common/agent_hooks/utils.py +99 -0
  52. autocoder/common/agent_query_queue/queue_executor.py +324 -0
  53. autocoder/common/agent_query_queue/queue_manager.py +325 -0
  54. autocoder/common/agents/__init__.py +11 -0
  55. autocoder/common/agents/agent_manager.py +323 -0
  56. autocoder/common/agents/agent_parser.py +189 -0
  57. autocoder/common/agents/example_usage.py +344 -0
  58. autocoder/common/agents/integration_example.py +330 -0
  59. autocoder/common/agents/test_agent_parser.py +545 -0
  60. autocoder/common/async_utils.py +101 -0
  61. autocoder/common/auto_coder_lang.py +23 -972
  62. autocoder/common/autocoderargs_parser/__init__.py +14 -0
  63. autocoder/common/autocoderargs_parser/parser.py +184 -0
  64. autocoder/common/autocoderargs_parser/tests/__init__.py +1 -0
  65. autocoder/common/autocoderargs_parser/tests/test_args_parser.py +235 -0
  66. autocoder/common/autocoderargs_parser/tests/test_token_parser.py +195 -0
  67. autocoder/common/autocoderargs_parser/token_parser.py +290 -0
  68. autocoder/common/buildin_tokenizer.py +2 -4
  69. autocoder/common/code_auto_generate.py +149 -74
  70. autocoder/common/code_auto_generate_diff.py +163 -70
  71. autocoder/common/code_auto_generate_editblock.py +179 -89
  72. autocoder/common/code_auto_generate_strict_diff.py +167 -72
  73. autocoder/common/code_auto_merge_editblock.py +13 -6
  74. autocoder/common/code_modification_ranker.py +1 -1
  75. autocoder/common/command_completer.py +3 -3
  76. autocoder/common/command_file_manager/manager.py +183 -47
  77. autocoder/common/command_file_manager/test_command_file_manager.py +507 -0
  78. autocoder/common/command_templates.py +1 -1
  79. autocoder/common/conf_utils.py +2 -4
  80. autocoder/common/conversations/config.py +11 -3
  81. autocoder/common/conversations/get_conversation_manager.py +100 -2
  82. autocoder/common/conversations/llm_stats_models.py +264 -0
  83. autocoder/common/conversations/manager.py +112 -28
  84. autocoder/common/conversations/models.py +16 -2
  85. autocoder/common/conversations/storage/index_manager.py +134 -10
  86. autocoder/common/core_config/__init__.py +63 -0
  87. autocoder/common/core_config/agentic_mode_manager.py +109 -0
  88. autocoder/common/core_config/base_manager.py +123 -0
  89. autocoder/common/core_config/compatibility.py +151 -0
  90. autocoder/common/core_config/config_manager.py +156 -0
  91. autocoder/common/core_config/conversation_manager.py +31 -0
  92. autocoder/common/core_config/exclude_manager.py +72 -0
  93. autocoder/common/core_config/file_manager.py +177 -0
  94. autocoder/common/core_config/human_as_model_manager.py +129 -0
  95. autocoder/common/core_config/lib_manager.py +54 -0
  96. autocoder/common/core_config/main_manager.py +81 -0
  97. autocoder/common/core_config/mode_manager.py +126 -0
  98. autocoder/common/core_config/models.py +70 -0
  99. autocoder/common/core_config/test_memory_manager.py +1056 -0
  100. autocoder/common/env_manager.py +282 -0
  101. autocoder/common/env_manager_usage_example.py +211 -0
  102. autocoder/common/file_checkpoint/conversation_checkpoint.py +19 -19
  103. autocoder/common/file_checkpoint/manager.py +264 -48
  104. autocoder/common/file_checkpoint/test_backup.py +1 -18
  105. autocoder/common/file_checkpoint/test_manager.py +270 -1
  106. autocoder/common/file_checkpoint/test_store.py +1 -17
  107. autocoder/common/file_handler/__init__.py +23 -0
  108. autocoder/common/file_handler/active_context_handler.py +159 -0
  109. autocoder/common/file_handler/add_files_handler.py +409 -0
  110. autocoder/common/file_handler/chat_handler.py +180 -0
  111. autocoder/common/file_handler/coding_handler.py +409 -0
  112. autocoder/common/file_handler/commit_handler.py +200 -0
  113. autocoder/common/file_handler/lib_handler.py +156 -0
  114. autocoder/common/file_handler/list_files_handler.py +111 -0
  115. autocoder/common/file_handler/mcp_handler.py +268 -0
  116. autocoder/common/file_handler/models_handler.py +493 -0
  117. autocoder/common/file_handler/remove_files_handler.py +172 -0
  118. autocoder/common/git_utils.py +44 -8
  119. autocoder/common/global_cancel.py +15 -6
  120. autocoder/common/ignorefiles/test_ignore_file_utils.py +1 -1
  121. autocoder/common/international/__init__.py +31 -0
  122. autocoder/common/international/demo_international.py +92 -0
  123. autocoder/common/international/message_manager.py +157 -0
  124. autocoder/common/international/messages/__init__.py +56 -0
  125. autocoder/common/international/messages/async_command_messages.py +507 -0
  126. autocoder/common/international/messages/auto_coder_messages.py +2208 -0
  127. autocoder/common/international/messages/chat_auto_coder_messages.py +1547 -0
  128. autocoder/common/international/messages/command_help_messages.py +986 -0
  129. autocoder/common/international/messages/conversation_command_messages.py +191 -0
  130. autocoder/common/international/messages/git_helper_plugin_messages.py +159 -0
  131. autocoder/common/international/messages/queue_command_messages.py +751 -0
  132. autocoder/common/international/messages/rules_command_messages.py +77 -0
  133. autocoder/common/international/messages/sdk_messages.py +1707 -0
  134. autocoder/common/international/messages/token_helper_plugin_messages.py +361 -0
  135. autocoder/common/international/messages/tool_display_messages.py +1212 -0
  136. autocoder/common/international/messages/workflow_exception_messages.py +473 -0
  137. autocoder/common/international/test_international.py +612 -0
  138. autocoder/common/linter_core/__init__.py +28 -0
  139. autocoder/common/linter_core/base_linter.py +61 -0
  140. autocoder/common/linter_core/config_loader.py +271 -0
  141. autocoder/common/linter_core/formatters/__init__.py +0 -0
  142. autocoder/common/linter_core/formatters/base_formatter.py +38 -0
  143. autocoder/common/linter_core/formatters/raw_formatter.py +17 -0
  144. autocoder/common/linter_core/linter.py +166 -0
  145. autocoder/common/linter_core/linter_factory.py +216 -0
  146. autocoder/common/linter_core/linter_manager.py +333 -0
  147. autocoder/common/linter_core/linters/__init__.py +9 -0
  148. autocoder/common/linter_core/linters/java_linter.py +342 -0
  149. autocoder/common/linter_core/linters/python_linter.py +115 -0
  150. autocoder/common/linter_core/linters/typescript_linter.py +119 -0
  151. autocoder/common/linter_core/models/__init__.py +7 -0
  152. autocoder/common/linter_core/models/lint_result.py +91 -0
  153. autocoder/common/linter_core/models.py +33 -0
  154. autocoder/common/linter_core/tests/__init__.py +3 -0
  155. autocoder/common/linter_core/tests/test_config_loader.py +323 -0
  156. autocoder/common/linter_core/tests/test_config_loading.py +308 -0
  157. autocoder/common/linter_core/tests/test_factory_manager.py +234 -0
  158. autocoder/common/linter_core/tests/test_formatters.py +147 -0
  159. autocoder/common/linter_core/tests/test_integration.py +317 -0
  160. autocoder/common/linter_core/tests/test_java_linter.py +496 -0
  161. autocoder/common/linter_core/tests/test_linters.py +265 -0
  162. autocoder/common/linter_core/tests/test_models.py +81 -0
  163. autocoder/common/linter_core/tests/verify_config_loading.py +296 -0
  164. autocoder/common/linter_core/tests/verify_fixes.py +183 -0
  165. autocoder/common/llm_friendly_package/__init__.py +31 -0
  166. autocoder/common/llm_friendly_package/base_manager.py +102 -0
  167. autocoder/common/llm_friendly_package/docs_manager.py +121 -0
  168. autocoder/common/llm_friendly_package/library_manager.py +171 -0
  169. autocoder/common/{llm_friendly_package.py → llm_friendly_package/main_manager.py} +204 -231
  170. autocoder/common/llm_friendly_package/models.py +40 -0
  171. autocoder/common/llm_friendly_package/test_llm_friendly_package.py +536 -0
  172. autocoder/common/llms/__init__.py +15 -0
  173. autocoder/common/llms/demo_error_handling.py +85 -0
  174. autocoder/common/llms/factory.py +142 -0
  175. autocoder/common/llms/manager.py +264 -0
  176. autocoder/common/llms/pricing.py +121 -0
  177. autocoder/common/llms/registry.py +316 -0
  178. autocoder/common/llms/schema.py +77 -0
  179. autocoder/common/llms/simple_demo.py +45 -0
  180. autocoder/common/llms/test_quick_model.py +116 -0
  181. autocoder/common/llms/test_remove_functionality.py +182 -0
  182. autocoder/common/llms/tests/__init__.py +1 -0
  183. autocoder/common/llms/tests/test_manager.py +330 -0
  184. autocoder/common/llms/tests/test_registry.py +364 -0
  185. autocoder/common/mcp_tools/__init__.py +62 -0
  186. autocoder/common/{mcp_tools.py → mcp_tools/executor.py} +49 -40
  187. autocoder/common/{mcp_hub.py → mcp_tools/hub.py} +42 -68
  188. autocoder/common/{mcp_server_install.py → mcp_tools/installer.py} +16 -28
  189. autocoder/common/{mcp_server.py → mcp_tools/server.py} +176 -48
  190. autocoder/common/mcp_tools/test_keyboard_interrupt.py +93 -0
  191. autocoder/common/mcp_tools/test_mcp_tools.py +391 -0
  192. autocoder/common/{mcp_server_types.py → mcp_tools/types.py} +121 -48
  193. autocoder/common/mcp_tools/verify_functionality.py +202 -0
  194. autocoder/common/model_speed_tester.py +32 -26
  195. autocoder/common/priority_directory_finder/__init__.py +142 -0
  196. autocoder/common/priority_directory_finder/examples.py +230 -0
  197. autocoder/common/priority_directory_finder/finder.py +283 -0
  198. autocoder/common/priority_directory_finder/models.py +236 -0
  199. autocoder/common/priority_directory_finder/test_priority_directory_finder.py +431 -0
  200. autocoder/common/project_scanner/__init__.py +18 -0
  201. autocoder/common/project_scanner/compat.py +77 -0
  202. autocoder/common/project_scanner/scanner.py +436 -0
  203. autocoder/common/project_tracker/__init__.py +27 -0
  204. autocoder/common/project_tracker/api.py +228 -0
  205. autocoder/common/project_tracker/demo.py +272 -0
  206. autocoder/common/project_tracker/tracker.py +487 -0
  207. autocoder/common/project_tracker/types.py +53 -0
  208. autocoder/common/pruner/__init__.py +67 -0
  209. autocoder/common/pruner/agentic_conversation_pruner.py +651 -102
  210. autocoder/common/pruner/conversation_message_ids_api.py +386 -0
  211. autocoder/common/pruner/conversation_message_ids_manager.py +347 -0
  212. autocoder/common/pruner/conversation_message_ids_pruner.py +473 -0
  213. autocoder/common/pruner/conversation_normalizer.py +347 -0
  214. autocoder/common/pruner/conversation_pruner.py +26 -6
  215. autocoder/common/pruner/test_agentic_conversation_pruner.py +554 -112
  216. autocoder/common/pruner/test_conversation_normalizer.py +502 -0
  217. autocoder/common/pruner/test_tool_content_detector.py +324 -0
  218. autocoder/common/pruner/tool_content_detector.py +227 -0
  219. autocoder/common/pruner/tools/__init__.py +18 -0
  220. autocoder/common/pruner/tools/query_message_ids.py +264 -0
  221. autocoder/common/pruner/tools/test_agentic_pruning_logic.py +432 -0
  222. autocoder/common/pruner/tools/test_message_ids_pruning_only.py +192 -0
  223. autocoder/common/pull_requests/__init__.py +9 -1
  224. autocoder/common/pull_requests/utils.py +122 -1
  225. autocoder/common/rag_manager/rag_manager.py +36 -40
  226. autocoder/common/rulefiles/__init__.py +53 -1
  227. autocoder/common/rulefiles/api.py +250 -0
  228. autocoder/common/rulefiles/core/__init__.py +14 -0
  229. autocoder/common/rulefiles/core/manager.py +241 -0
  230. autocoder/common/rulefiles/core/selector.py +805 -0
  231. autocoder/common/rulefiles/models/__init__.py +20 -0
  232. autocoder/common/rulefiles/models/index.py +16 -0
  233. autocoder/common/rulefiles/models/init_rule.py +18 -0
  234. autocoder/common/rulefiles/models/rule_file.py +18 -0
  235. autocoder/common/rulefiles/models/rule_relevance.py +14 -0
  236. autocoder/common/rulefiles/models/summary.py +16 -0
  237. autocoder/common/rulefiles/test_rulefiles.py +776 -0
  238. autocoder/common/rulefiles/utils/__init__.py +34 -0
  239. autocoder/common/rulefiles/utils/monitor.py +86 -0
  240. autocoder/common/rulefiles/utils/parser.py +230 -0
  241. autocoder/common/save_formatted_log.py +67 -10
  242. autocoder/common/search_replace.py +8 -1
  243. autocoder/common/search_replace_patch/__init__.py +24 -0
  244. autocoder/common/search_replace_patch/base.py +115 -0
  245. autocoder/common/search_replace_patch/manager.py +248 -0
  246. autocoder/common/search_replace_patch/patch_replacer.py +304 -0
  247. autocoder/common/search_replace_patch/similarity_replacer.py +306 -0
  248. autocoder/common/search_replace_patch/string_replacer.py +181 -0
  249. autocoder/common/search_replace_patch/tests/__init__.py +3 -0
  250. autocoder/common/search_replace_patch/tests/run_tests.py +126 -0
  251. autocoder/common/search_replace_patch/tests/test_base.py +188 -0
  252. autocoder/common/search_replace_patch/tests/test_empty_line_insert.py +233 -0
  253. autocoder/common/search_replace_patch/tests/test_integration.py +389 -0
  254. autocoder/common/search_replace_patch/tests/test_manager.py +351 -0
  255. autocoder/common/search_replace_patch/tests/test_patch_replacer.py +316 -0
  256. autocoder/common/search_replace_patch/tests/test_regex_replacer.py +306 -0
  257. autocoder/common/search_replace_patch/tests/test_similarity_replacer.py +384 -0
  258. autocoder/common/shell_commands/__init__.py +197 -0
  259. autocoder/common/shell_commands/background_process_notifier.py +346 -0
  260. autocoder/common/shell_commands/command_executor.py +1127 -0
  261. autocoder/common/shell_commands/error_recovery.py +541 -0
  262. autocoder/common/shell_commands/exceptions.py +120 -0
  263. autocoder/common/shell_commands/interactive_executor.py +476 -0
  264. autocoder/common/shell_commands/interactive_pexpect_process.py +623 -0
  265. autocoder/common/shell_commands/interactive_process.py +744 -0
  266. autocoder/common/shell_commands/interactive_session_manager.py +1014 -0
  267. autocoder/common/shell_commands/monitoring.py +529 -0
  268. autocoder/common/shell_commands/process_cleanup.py +386 -0
  269. autocoder/common/shell_commands/process_manager.py +606 -0
  270. autocoder/common/shell_commands/test_interactive_pexpect_process.py +281 -0
  271. autocoder/common/shell_commands/tests/__init__.py +6 -0
  272. autocoder/common/shell_commands/tests/conftest.py +118 -0
  273. autocoder/common/shell_commands/tests/test_background_process_notifier.py +703 -0
  274. autocoder/common/shell_commands/tests/test_command_executor.py +448 -0
  275. autocoder/common/shell_commands/tests/test_error_recovery.py +305 -0
  276. autocoder/common/shell_commands/tests/test_exceptions.py +299 -0
  277. autocoder/common/shell_commands/tests/test_execute_batch.py +588 -0
  278. autocoder/common/shell_commands/tests/test_indented_batch_commands.py +244 -0
  279. autocoder/common/shell_commands/tests/test_integration.py +664 -0
  280. autocoder/common/shell_commands/tests/test_monitoring.py +546 -0
  281. autocoder/common/shell_commands/tests/test_performance.py +632 -0
  282. autocoder/common/shell_commands/tests/test_process_cleanup.py +397 -0
  283. autocoder/common/shell_commands/tests/test_process_manager.py +606 -0
  284. autocoder/common/shell_commands/tests/test_timeout_config.py +343 -0
  285. autocoder/common/shell_commands/tests/test_timeout_manager.py +520 -0
  286. autocoder/common/shell_commands/timeout_config.py +315 -0
  287. autocoder/common/shell_commands/timeout_manager.py +352 -0
  288. autocoder/common/terminal_paste/__init__.py +14 -0
  289. autocoder/common/terminal_paste/demo.py +145 -0
  290. autocoder/common/terminal_paste/demo_paste_functionality.py +95 -0
  291. autocoder/common/terminal_paste/paste_handler.py +200 -0
  292. autocoder/common/terminal_paste/paste_manager.py +118 -0
  293. autocoder/common/terminal_paste/tests/__init__.py +1 -0
  294. autocoder/common/terminal_paste/tests/test_paste_handler.py +182 -0
  295. autocoder/common/terminal_paste/tests/test_paste_manager.py +126 -0
  296. autocoder/common/terminal_paste/utils.py +163 -0
  297. autocoder/common/test_autocoder_args.py +232 -0
  298. autocoder/common/test_env_manager.py +173 -0
  299. autocoder/common/test_env_manager_integration.py +159 -0
  300. autocoder/common/text_similarity/__init__.py +9 -0
  301. autocoder/common/text_similarity/demo.py +216 -0
  302. autocoder/common/text_similarity/examples.py +266 -0
  303. autocoder/common/text_similarity/test_text_similarity.py +306 -0
  304. autocoder/common/text_similarity/text_similarity.py +194 -0
  305. autocoder/common/text_similarity/utils.py +125 -0
  306. autocoder/common/todos/__init__.py +61 -0
  307. autocoder/common/todos/cache/__init__.py +16 -0
  308. autocoder/common/todos/cache/base_cache.py +89 -0
  309. autocoder/common/todos/cache/cache_manager.py +228 -0
  310. autocoder/common/todos/cache/memory_cache.py +225 -0
  311. autocoder/common/todos/config.py +155 -0
  312. autocoder/common/todos/exceptions.py +35 -0
  313. autocoder/common/todos/get_todo_manager.py +161 -0
  314. autocoder/common/todos/manager.py +537 -0
  315. autocoder/common/todos/models.py +239 -0
  316. autocoder/common/todos/storage/__init__.py +14 -0
  317. autocoder/common/todos/storage/base_storage.py +76 -0
  318. autocoder/common/todos/storage/file_storage.py +278 -0
  319. autocoder/common/tokens/counter.py +24 -2
  320. autocoder/common/tools_manager/__init__.py +17 -0
  321. autocoder/common/tools_manager/examples.py +162 -0
  322. autocoder/common/tools_manager/manager.py +385 -0
  323. autocoder/common/tools_manager/models.py +39 -0
  324. autocoder/common/tools_manager/test_tools_manager.py +303 -0
  325. autocoder/common/tools_manager/utils.py +191 -0
  326. autocoder/common/v2/agent/agentic_callbacks.py +270 -0
  327. autocoder/common/v2/agent/agentic_edit.py +2699 -1856
  328. autocoder/common/v2/agent/agentic_edit_change_manager.py +474 -0
  329. autocoder/common/v2/agent/agentic_edit_tools/__init__.py +35 -1
  330. autocoder/common/v2/agent/agentic_edit_tools/ac_mod_list_tool_resolver.py +279 -0
  331. autocoder/common/v2/agent/agentic_edit_tools/ac_mod_write_tool_resolver.py +10 -1
  332. autocoder/common/v2/agent/agentic_edit_tools/background_task_tool_resolver.py +1167 -0
  333. autocoder/common/v2/agent/agentic_edit_tools/base_tool_resolver.py +2 -2
  334. autocoder/common/v2/agent/agentic_edit_tools/conversation_message_ids_read_tool_resolver.py +214 -0
  335. autocoder/common/v2/agent/agentic_edit_tools/conversation_message_ids_write_tool_resolver.py +299 -0
  336. autocoder/common/v2/agent/agentic_edit_tools/count_tokens_tool_resolver.py +290 -0
  337. autocoder/common/v2/agent/agentic_edit_tools/execute_command_tool_resolver.py +564 -29
  338. autocoder/common/v2/agent/agentic_edit_tools/execute_workflow_tool_resolver.py +485 -0
  339. autocoder/common/v2/agent/agentic_edit_tools/extract_to_text_tool_resolver.py +225 -0
  340. autocoder/common/v2/agent/agentic_edit_tools/lint_report.py +79 -0
  341. autocoder/common/v2/agent/agentic_edit_tools/linter_config_models.py +343 -0
  342. autocoder/common/v2/agent/agentic_edit_tools/linter_enabled_tool_resolver.py +189 -0
  343. autocoder/common/v2/agent/agentic_edit_tools/list_files_tool_resolver.py +169 -101
  344. autocoder/common/v2/agent/agentic_edit_tools/load_extra_document_tool_resolver.py +356 -0
  345. autocoder/common/v2/agent/agentic_edit_tools/read_file_tool_resolver.py +243 -50
  346. autocoder/common/v2/agent/agentic_edit_tools/replace_in_file_tool_resolver.py +667 -147
  347. autocoder/common/v2/agent/agentic_edit_tools/run_named_subagents_tool_resolver.py +691 -0
  348. autocoder/common/v2/agent/agentic_edit_tools/search_files_tool_resolver.py +410 -86
  349. autocoder/common/v2/agent/agentic_edit_tools/session_interactive_tool_resolver.py +115 -0
  350. autocoder/common/v2/agent/agentic_edit_tools/session_start_tool_resolver.py +190 -0
  351. autocoder/common/v2/agent/agentic_edit_tools/session_stop_tool_resolver.py +76 -0
  352. autocoder/common/v2/agent/agentic_edit_tools/test_write_to_file_tool_resolver.py +207 -192
  353. autocoder/common/v2/agent/agentic_edit_tools/todo_read_tool_resolver.py +80 -63
  354. autocoder/common/v2/agent/agentic_edit_tools/todo_write_tool_resolver.py +237 -233
  355. autocoder/common/v2/agent/agentic_edit_tools/use_mcp_tool_resolver.py +2 -2
  356. autocoder/common/v2/agent/agentic_edit_tools/web_crawl_tool_resolver.py +557 -0
  357. autocoder/common/v2/agent/agentic_edit_tools/web_search_tool_resolver.py +600 -0
  358. autocoder/common/v2/agent/agentic_edit_tools/write_to_file_tool_resolver.py +56 -121
  359. autocoder/common/v2/agent/agentic_edit_types.py +343 -9
  360. autocoder/common/v2/agent/runner/__init__.py +3 -3
  361. autocoder/common/v2/agent/runner/base_runner.py +12 -26
  362. autocoder/common/v2/agent/runner/{event_runner.py → file_based_event_runner.py} +3 -2
  363. autocoder/common/v2/agent/runner/sdk_runner.py +150 -8
  364. autocoder/common/v2/agent/runner/terminal_runner.py +170 -57
  365. autocoder/common/v2/agent/runner/tool_display.py +557 -159
  366. autocoder/common/v2/agent/test_agentic_callbacks.py +265 -0
  367. autocoder/common/v2/agent/test_agentic_edit.py +194 -0
  368. autocoder/common/v2/agent/tool_caller/__init__.py +24 -0
  369. autocoder/common/v2/agent/tool_caller/default_tool_resolver_map.py +135 -0
  370. autocoder/common/v2/agent/tool_caller/integration_test.py +172 -0
  371. autocoder/common/v2/agent/tool_caller/plugins/__init__.py +14 -0
  372. autocoder/common/v2/agent/tool_caller/plugins/base_plugin.py +126 -0
  373. autocoder/common/v2/agent/tool_caller/plugins/examples/__init__.py +13 -0
  374. autocoder/common/v2/agent/tool_caller/plugins/examples/logging_plugin.py +164 -0
  375. autocoder/common/v2/agent/tool_caller/plugins/examples/security_filter_plugin.py +198 -0
  376. autocoder/common/v2/agent/tool_caller/plugins/plugin_interface.py +141 -0
  377. autocoder/common/v2/agent/tool_caller/test_tool_caller.py +278 -0
  378. autocoder/common/v2/agent/tool_caller/tool_call_plugin_manager.py +331 -0
  379. autocoder/common/v2/agent/tool_caller/tool_caller.py +337 -0
  380. autocoder/common/v2/agent/tool_caller/usage_example.py +193 -0
  381. autocoder/common/v2/code_agentic_editblock_manager.py +4 -4
  382. autocoder/common/v2/code_auto_generate.py +136 -78
  383. autocoder/common/v2/code_auto_generate_diff.py +135 -79
  384. autocoder/common/v2/code_auto_generate_editblock.py +174 -99
  385. autocoder/common/v2/code_auto_generate_strict_diff.py +151 -71
  386. autocoder/common/v2/code_auto_merge.py +1 -1
  387. autocoder/common/v2/code_auto_merge_editblock.py +13 -1
  388. autocoder/common/v2/code_diff_manager.py +3 -3
  389. autocoder/common/v2/code_editblock_manager.py +4 -14
  390. autocoder/common/v2/code_manager.py +1 -1
  391. autocoder/common/v2/code_strict_diff_manager.py +2 -2
  392. autocoder/common/wrap_llm_hint/__init__.py +10 -0
  393. autocoder/common/wrap_llm_hint/test_wrap_llm_hint.py +1067 -0
  394. autocoder/common/wrap_llm_hint/utils.py +432 -0
  395. autocoder/common/wrap_llm_hint/wrap_llm_hint.py +323 -0
  396. autocoder/completer/__init__.py +8 -0
  397. autocoder/completer/command_completer_v2.py +1094 -0
  398. autocoder/default_project/__init__.py +501 -0
  399. autocoder/dispacher/__init__.py +4 -12
  400. autocoder/dispacher/actions/action.py +400 -129
  401. autocoder/dispacher/actions/plugins/action_regex_project.py +2 -2
  402. autocoder/index/entry.py +117 -125
  403. autocoder/{agent → index/filter}/agentic_filter.py +322 -333
  404. autocoder/index/filter/normal_filter.py +5 -11
  405. autocoder/index/filter/quick_filter.py +1 -1
  406. autocoder/index/index.py +36 -9
  407. autocoder/index/tests/__init__.py +1 -0
  408. autocoder/index/tests/run_tests.py +195 -0
  409. autocoder/index/tests/test_entry.py +303 -0
  410. autocoder/index/tests/test_index_manager.py +314 -0
  411. autocoder/index/tests/test_module_integration.py +300 -0
  412. autocoder/index/tests/test_symbols_utils.py +183 -0
  413. autocoder/inner/__init__.py +4 -0
  414. autocoder/inner/agentic.py +923 -0
  415. autocoder/inner/async_command_handler.py +992 -0
  416. autocoder/inner/conversation_command_handlers.py +623 -0
  417. autocoder/inner/merge_command_handler.py +213 -0
  418. autocoder/inner/queue_command_handler.py +684 -0
  419. autocoder/models.py +95 -266
  420. autocoder/plugins/git_helper_plugin.py +31 -29
  421. autocoder/plugins/token_helper_plugin.py +65 -46
  422. autocoder/pyproject/__init__.py +32 -29
  423. autocoder/rag/agentic_rag.py +215 -75
  424. autocoder/rag/cache/simple_cache.py +1 -2
  425. autocoder/rag/loaders/image_loader.py +1 -1
  426. autocoder/rag/long_context_rag.py +42 -26
  427. autocoder/rag/qa_conversation_strategy.py +1 -1
  428. autocoder/rag/terminal/__init__.py +17 -0
  429. autocoder/rag/terminal/args.py +581 -0
  430. autocoder/rag/terminal/bootstrap.py +61 -0
  431. autocoder/rag/terminal/command_handlers.py +653 -0
  432. autocoder/rag/terminal/formatters/__init__.py +20 -0
  433. autocoder/rag/terminal/formatters/base.py +70 -0
  434. autocoder/rag/terminal/formatters/json_format.py +66 -0
  435. autocoder/rag/terminal/formatters/stream_json.py +95 -0
  436. autocoder/rag/terminal/formatters/text.py +28 -0
  437. autocoder/rag/terminal/init.py +120 -0
  438. autocoder/rag/terminal/utils.py +106 -0
  439. autocoder/rag/test_agentic_rag.py +389 -0
  440. autocoder/rag/test_doc_filter.py +3 -3
  441. autocoder/rag/test_long_context_rag.py +1 -1
  442. autocoder/rag/test_token_limiter.py +517 -10
  443. autocoder/rag/token_counter.py +3 -0
  444. autocoder/rag/token_limiter.py +19 -15
  445. autocoder/rag/tools/__init__.py +26 -2
  446. autocoder/rag/tools/bochaai_example.py +343 -0
  447. autocoder/rag/tools/bochaai_sdk.py +541 -0
  448. autocoder/rag/tools/metaso_example.py +268 -0
  449. autocoder/rag/tools/metaso_sdk.py +417 -0
  450. autocoder/rag/tools/recall_tool.py +28 -7
  451. autocoder/rag/tools/run_integration_tests.py +204 -0
  452. autocoder/rag/tools/test_all_providers.py +318 -0
  453. autocoder/rag/tools/test_bochaai_integration.py +482 -0
  454. autocoder/rag/tools/test_final_integration.py +215 -0
  455. autocoder/rag/tools/test_metaso_integration.py +424 -0
  456. autocoder/rag/tools/test_metaso_real.py +171 -0
  457. autocoder/rag/tools/test_web_crawl_tool.py +639 -0
  458. autocoder/rag/tools/test_web_search_tool.py +509 -0
  459. autocoder/rag/tools/todo_read_tool.py +202 -0
  460. autocoder/rag/tools/todo_write_tool.py +412 -0
  461. autocoder/rag/tools/web_crawl_tool.py +634 -0
  462. autocoder/rag/tools/web_search_tool.py +558 -0
  463. autocoder/rag/tools/web_tools_example.py +119 -0
  464. autocoder/rag/types.py +16 -0
  465. autocoder/rag/variable_holder.py +4 -2
  466. autocoder/rags.py +86 -79
  467. autocoder/regexproject/__init__.py +23 -21
  468. autocoder/sdk/__init__.py +46 -190
  469. autocoder/sdk/api.py +370 -0
  470. autocoder/sdk/async_runner/__init__.py +26 -0
  471. autocoder/sdk/async_runner/async_executor.py +650 -0
  472. autocoder/sdk/async_runner/async_handler.py +356 -0
  473. autocoder/sdk/async_runner/markdown_processor.py +595 -0
  474. autocoder/sdk/async_runner/task_metadata.py +284 -0
  475. autocoder/sdk/async_runner/worktree_manager.py +438 -0
  476. autocoder/sdk/cli/__init__.py +2 -5
  477. autocoder/sdk/cli/formatters.py +28 -204
  478. autocoder/sdk/cli/handlers.py +77 -44
  479. autocoder/sdk/cli/main.py +154 -171
  480. autocoder/sdk/cli/options.py +95 -22
  481. autocoder/sdk/constants.py +139 -51
  482. autocoder/sdk/core/auto_coder_core.py +484 -109
  483. autocoder/sdk/core/bridge.py +297 -115
  484. autocoder/sdk/exceptions.py +18 -12
  485. autocoder/sdk/formatters/__init__.py +19 -0
  486. autocoder/sdk/formatters/input.py +64 -0
  487. autocoder/sdk/formatters/output.py +247 -0
  488. autocoder/sdk/formatters/stream.py +54 -0
  489. autocoder/sdk/models/__init__.py +6 -5
  490. autocoder/sdk/models/options.py +55 -18
  491. autocoder/sdk/utils/formatters.py +27 -195
  492. autocoder/suffixproject/__init__.py +28 -25
  493. autocoder/terminal/__init__.py +14 -0
  494. autocoder/terminal/app.py +454 -0
  495. autocoder/terminal/args.py +32 -0
  496. autocoder/terminal/bootstrap.py +178 -0
  497. autocoder/terminal/command_processor.py +521 -0
  498. autocoder/terminal/command_registry.py +57 -0
  499. autocoder/terminal/help.py +97 -0
  500. autocoder/terminal/tasks/__init__.py +5 -0
  501. autocoder/terminal/tasks/background.py +77 -0
  502. autocoder/terminal/tasks/task_event.py +70 -0
  503. autocoder/terminal/ui/__init__.py +13 -0
  504. autocoder/terminal/ui/completer.py +268 -0
  505. autocoder/terminal/ui/keybindings.py +75 -0
  506. autocoder/terminal/ui/session.py +41 -0
  507. autocoder/terminal/ui/toolbar.py +64 -0
  508. autocoder/terminal/utils/__init__.py +13 -0
  509. autocoder/terminal/utils/errors.py +18 -0
  510. autocoder/terminal/utils/paths.py +19 -0
  511. autocoder/terminal/utils/shell.py +43 -0
  512. autocoder/terminal_v3/__init__.py +10 -0
  513. autocoder/terminal_v3/app.py +201 -0
  514. autocoder/terminal_v3/handlers/__init__.py +5 -0
  515. autocoder/terminal_v3/handlers/command_handler.py +131 -0
  516. autocoder/terminal_v3/models/__init__.py +6 -0
  517. autocoder/terminal_v3/models/conversation_buffer.py +214 -0
  518. autocoder/terminal_v3/models/message.py +50 -0
  519. autocoder/terminal_v3/models/tool_display.py +247 -0
  520. autocoder/terminal_v3/ui/__init__.py +7 -0
  521. autocoder/terminal_v3/ui/keybindings.py +56 -0
  522. autocoder/terminal_v3/ui/layout.py +141 -0
  523. autocoder/terminal_v3/ui/styles.py +43 -0
  524. autocoder/tsproject/__init__.py +23 -23
  525. autocoder/utils/auto_coder_utils/chat_stream_out.py +1 -1
  526. autocoder/utils/llms.py +88 -80
  527. autocoder/utils/math_utils.py +101 -0
  528. autocoder/utils/model_provider_selector.py +16 -4
  529. autocoder/utils/operate_config_api.py +33 -5
  530. autocoder/utils/thread_utils.py +2 -2
  531. autocoder/version.py +4 -2
  532. autocoder/workflow_agents/__init__.py +84 -0
  533. autocoder/workflow_agents/agent.py +143 -0
  534. autocoder/workflow_agents/exceptions.py +573 -0
  535. autocoder/workflow_agents/executor.py +665 -0
  536. autocoder/workflow_agents/loader.py +749 -0
  537. autocoder/workflow_agents/runner.py +267 -0
  538. autocoder/workflow_agents/types.py +173 -0
  539. autocoder/workflow_agents/utils.py +434 -0
  540. autocoder/workflow_agents/workflow_manager.py +211 -0
  541. auto_coder-1.0.0.dist-info/METADATA +0 -396
  542. auto_coder-1.0.0.dist-info/RECORD +0 -442
  543. auto_coder-1.0.0.dist-info/licenses/LICENSE +0 -201
  544. autocoder/auto_coder_server.py +0 -672
  545. autocoder/benchmark.py +0 -138
  546. autocoder/common/ac_style_command_parser/example.py +0 -7
  547. autocoder/common/cleaner.py +0 -31
  548. autocoder/common/command_completer_v2.py +0 -615
  549. autocoder/common/context_pruner.py +0 -477
  550. autocoder/common/conversation_pruner.py +0 -132
  551. autocoder/common/directory_cache/__init__.py +0 -1
  552. autocoder/common/directory_cache/cache.py +0 -192
  553. autocoder/common/directory_cache/test_cache.py +0 -190
  554. autocoder/common/file_checkpoint/examples.py +0 -217
  555. autocoder/common/llm_friendly_package_example.py +0 -138
  556. autocoder/common/llm_friendly_package_test.py +0 -63
  557. autocoder/common/pull_requests/test_module.py +0 -1
  558. autocoder/common/rulefiles/autocoderrules_utils.py +0 -484
  559. autocoder/common/text.py +0 -30
  560. autocoder/common/v2/agent/agentic_edit_tools/list_package_info_tool_resolver.py +0 -42
  561. autocoder/common/v2/agent/agentic_edit_tools/test_execute_command_tool_resolver.py +0 -70
  562. autocoder/common/v2/agent/agentic_edit_tools/test_search_files_tool_resolver.py +0 -163
  563. autocoder/common/v2/agent/agentic_tool_display.py +0 -183
  564. autocoder/plugins/dynamic_completion_example.py +0 -148
  565. autocoder/plugins/sample_plugin.py +0 -160
  566. autocoder/sdk/cli/__main__.py +0 -26
  567. autocoder/sdk/cli/completion_wrapper.py +0 -38
  568. autocoder/sdk/cli/install_completion.py +0 -301
  569. autocoder/sdk/models/messages.py +0 -209
  570. autocoder/sdk/session/__init__.py +0 -32
  571. autocoder/sdk/session/session.py +0 -106
  572. autocoder/sdk/session/session_manager.py +0 -56
  573. {auto_coder-1.0.0.dist-info → auto_coder-2.0.1.dist-info}/top_level.txt +0 -0
  574. /autocoder/{sdk/example.py → common/agent_query_queue/__init__.py} +0 -0
@@ -8,29 +8,30 @@ from typing import List, Dict, Any, Union, Callable, Optional
8
8
  from autocoder.common.printer import Printer
9
9
  from rich.console import Console
10
10
  from rich.panel import Panel
11
- from pydantic import SkipValidation
12
11
 
13
12
  from autocoder.common.result_manager import ResultManager
14
13
  from autocoder.utils.auto_coder_utils.chat_stream_out import stream_out
15
14
  from byzerllm.utils.str2model import to_model
16
15
  from autocoder.common import git_utils
17
16
  from autocoder.commands.tools import AutoCommandTools
18
- from autocoder.auto_coder import AutoCoderArgs
17
+ from autocoder.common import AutoCoderArgs
18
+ from autocoder.common.autocoderargs_parser import AutoCoderArgsParser
19
19
  from autocoder.common import detect_env
20
20
  from autocoder.common import shells
21
21
  from loguru import logger
22
22
  from autocoder.utils import llms as llms_utils
23
- from autocoder.rag.token_counter import count_tokens
23
+ from autocoder.common.tokens import count_string_tokens as count_tokens
24
24
  from autocoder.common.global_cancel import global_cancel
25
25
  from autocoder.common.auto_configure import config_readme
26
26
  from autocoder.utils.auto_project_type import ProjectTypeAnalyzer
27
27
  from rich.text import Text
28
- from autocoder.common.mcp_server import get_mcp_server, McpServerInfoRequest
28
+ from autocoder.common.mcp_tools.server import get_mcp_server, McpServerInfoRequest
29
29
  from autocoder.common.action_yml_file_manager import ActionYmlFileManager
30
30
  from autocoder.events.event_manager_singleton import get_event_manager
31
31
  from autocoder.events import event_content as EventContentCreator
32
32
  from autocoder.run_context import get_run_context
33
33
  from autocoder.common.stream_out_type import AgenticFilterStreamOutType
34
+ from autocoder.common.core_config import get_memory_manager
34
35
 
35
36
 
36
37
  class AgenticFilterRequest(BaseModel):
@@ -43,8 +44,8 @@ class FileOperation(BaseModel):
43
44
 
44
45
 
45
46
  class AgenticFilterResponse(BaseModel):
46
- files: List[FileOperation] # 文件列表,包含pathoperation字段
47
- reasoning: str # 决策过程说明
47
+ files: List[FileOperation] # File list containing path and operation fields
48
+ reasoning: str # Decision process explanation
48
49
 
49
50
 
50
51
  class CommandSuggestion(BaseModel):
@@ -63,53 +64,12 @@ class AutoCommandRequest(BaseModel):
63
64
  user_input: str
64
65
 
65
66
 
66
- class MemoryConfig(BaseModel):
67
- """
68
- A model to encapsulate memory configuration and operations.
69
- """
70
-
71
- memory: Dict[str, Any]
72
- save_memory_func: SkipValidation[Callable]
73
-
74
- class Config:
75
- arbitrary_types_allowed = True
76
-
77
-
78
- class CommandConfig(BaseModel):
79
- coding: SkipValidation[Callable]
80
- chat: SkipValidation[Callable]
81
- add_files: SkipValidation[Callable]
82
- remove_files: SkipValidation[Callable]
83
- index_build: SkipValidation[Callable]
84
- index_query: SkipValidation[Callable]
85
- list_files: SkipValidation[Callable]
86
- ask: SkipValidation[Callable]
87
- revert: SkipValidation[Callable]
88
- commit: SkipValidation[Callable]
89
- help: SkipValidation[Callable]
90
- exclude_dirs: SkipValidation[Callable]
91
- summon: SkipValidation[Callable]
92
- design: SkipValidation[Callable]
93
- mcp: SkipValidation[Callable]
94
- models: SkipValidation[Callable]
95
- lib: SkipValidation[Callable]
96
- execute_shell_command: SkipValidation[Callable]
97
- generate_shell_command: SkipValidation[Callable]
98
- conf_export: SkipValidation[Callable]
99
- conf_import: SkipValidation[Callable]
100
- index_export: SkipValidation[Callable]
101
- index_import: SkipValidation[Callable]
102
- exclude_files: SkipValidation[Callable]
103
-
104
-
105
67
  class AgenticFilter:
106
68
  def __init__(
107
69
  self,
108
70
  llm: Union[byzerllm.ByzerLLM, byzerllm.SimpleByzerLLM],
109
71
  conversation_history: List[Dict[str, Any]],
110
72
  args: AutoCoderArgs,
111
- memory_config: MemoryConfig,
112
- command_config: Optional[CommandConfig] = None,
113
73
  ):
114
74
  self.llm = llm
115
75
  self.args = args
@@ -119,9 +79,11 @@ class AgenticFilter:
119
79
  # Use existing args for max iterations
120
80
  self.max_iterations = args.auto_command_max_iterations
121
81
  self.conversation_history = conversation_history
122
- self.memory_config = memory_config
123
- self.command_config = command_config
124
- self.project_type_analyzer = ProjectTypeAnalyzer(args=args, llm=self.llm)
82
+ self.project_type_analyzer = ProjectTypeAnalyzer(
83
+ args=args, llm=self.llm)
84
+
85
+ # Initialize AutoCoderArgs parser for flexible parameter parsing
86
+ self.args_parser = AutoCoderArgsParser()
125
87
  try:
126
88
  self.mcp_server = get_mcp_server()
127
89
  mcp_server_info_response = self.mcp_server.send_request(
@@ -134,94 +96,156 @@ class AgenticFilter:
134
96
  except Exception as e:
135
97
  logger.error(f"Error getting MCP server info: {str(e)}")
136
98
  self.mcp_server_info = ""
99
+ self.memory_config = get_memory_manager()
100
+
101
+ def _get_parsed_safe_zone_tokens(self) -> int:
102
+ """
103
+ Parse conversation_prune_safe_zone_tokens parameter, supports multiple formats
104
+
105
+ Returns:
106
+ Parsed token count
107
+ """
108
+ return self.args_parser.parse_conversation_prune_safe_zone_tokens(
109
+ self.args.conversation_prune_safe_zone_tokens,
110
+ self.args.code_model
111
+ )
137
112
 
138
113
  @byzerllm.prompt()
139
114
  def _analyze(self, request: AgenticFilterRequest) -> str:
140
115
  """
141
- ## 当前用户环境信息如下:
116
+ ## Current User Environment Information:
142
117
  <os_info>
143
- 操作系统: {{ env_info.os_name }} {{ env_info.os_version }}
144
- 操作系统发行版: {{ os_distribution }}
145
- Python版本: {{ env_info.python_version }}
146
- 终端类型: {{ env_info.shell_type }}
147
- 终端编码: {{ env_info.shell_encoding }}
148
- 当前用户: {{ current_user }}
118
+ Operating System: {{ env_info.os_name }} {{ env_info.os_version }}
119
+ OS Distribution: {{ os_distribution }}
120
+ Python Version: {{ env_info.python_version }}
121
+ Terminal Type: {{ env_info.shell_type }}
122
+ Terminal Encoding: {{ env_info.shell_encoding }}
123
+ Current User: {{ current_user }}
149
124
 
150
125
  {%- if shell_type %}
151
- 脚本类型:{{ shell_type }}
126
+ Script Type: {{ shell_type }}
152
127
  {%- endif %}
153
128
 
154
129
  {%- if env_info.conda_env %}
155
- Conda环境: {{ env_info.conda_env }}
130
+ Conda Environment: {{ env_info.conda_env }}
156
131
  {%- endif %}
157
132
  {%- if env_info.virtualenv %}
158
- 虚拟环境: {{ env_info.virtualenv }}
133
+ Virtual Environment: {{ env_info.virtualenv }}
159
134
  {%- endif %}
160
135
  </os_info>
161
136
 
162
- 当前项目根目录:
137
+ Current Project Root Directory:
163
138
  {{ current_project }}
164
139
 
165
140
  {% if current_files %}
166
- ## 当前用户手动添加关注的文件列表:
141
+ ## Current User Manually Added File List:
167
142
  <current_files>
168
143
  {% for file in current_files %}
169
144
  - {{ file }}
170
145
  {% endfor %}
171
146
  </current_files>
172
147
  {% endif %}
148
+
149
+ ## Available Function List:
150
+ {{ available_commands }}
151
+
152
+ ====
153
+
154
+ AC MOD FILES
155
+
156
+ # AC Modules (.ac.mod.md)
157
+
158
+ ## What is an AC Module?
159
+
160
+ Any directory containing a `.ac.mod.md` file is considered an AC Module - a language-agnostic module that provides complete functionality and can be used as an API.
161
+ These modules are self-contained units with well-defined interfaces and comprehensive documentation. AC Modules basically should not large than 60K tokens,
162
+ you can use count_tokens tool to get the tokens number of the module.
163
+
164
+ ## AC Module Structure
165
+ - .ac.mod.md contains detailed information about:
166
+ - Module overview and purpose: One-sentence description of core functionality
167
+ - Directory structure: Complete file tree with functionality descriptions
168
+ - Quick start guide: Basic usage examples and code snippets
169
+ - Core components: Main classes, methods, and their responsibilities (make it simple)
170
+ - Sequence diagrams: Visual flow showing component interactions and calling relationships
171
+ - Dependency graphs: Internal dependencies and relationships between components
172
+ - External dependencies: References to other AC modules it depends on
173
+ - Configuration management: Setup examples and configuration files
174
+ - Testing instructions: Executable commands and test examples
175
+
176
+ ## When to Use AC Modules
177
+
178
+ 1. **Avoid duplicate implementation**: Check if functionality already exists in project AC modules before implementing new features
179
+ 2. **Project understanding**: Review multiple AC modules to gain comprehensive knowledge of the entire project architecture
180
+ 3. **File modification context**: When modifying files in a directory, check if it's an AC module or contains AC modules to understand the full impact
173
181
 
174
- ## 可用函数列表:
175
- {{ available_commands }}
182
+ ## execute_shell_command
176
183
 
177
- ## 当前大模型窗口安全值
178
- {{ conversation_safe_zone_tokens }}
184
+ When to use:
185
+ - When you want to list all AC modules in the project
186
+ - When you want to list all AC modules in a specific directory
179
187
 
180
- ## Token 安全区
181
- 对话和文件内容的总Token数不应超过 {{ conversation_safe_zone_tokens }}。请谨慎读取大文件。
188
+ Example:
189
+
190
+ execute_shell_command(command="find . -name '*.ac.mod.md' -type f | sed 's|/[^/]*$||' | sort | uniq")
191
+
192
+
193
+ ## read_files
194
+
195
+ When to use:
196
+ - Use the this tool to retrieve comprehensive information about an AC module
197
+ - The tool reads the `.ac.mod.md` file and provides structured information about the module
198
+
199
+ Example:
200
+
201
+ read_files(paths="src/autocoder/agent/.ac.mod.md")
202
+
203
+ ====
182
204
 
183
- ## 对话历史
205
+ {% if conversation_history %}
206
+ ## Conversation History
184
207
  <conversation_history>
185
208
  {% for msg in conversation_history %}
186
209
  **{{ msg.role }}**: {{ msg.content }}
187
210
  {% endfor %}
188
211
  </conversation_history>
212
+ {% endif %}
189
213
 
190
- ## 完成任务的一些实践指导
214
+ ## Practical Guidance for Task Completion
191
215
  {{ command_combination_readme }}
192
-
193
- ## 你的任务以及要求
194
- 你是一个代码分析专家,需要根据用户的需求分析项目中相关的文件。你的工作是确定:
195
216
 
196
- 1. **需要修改的文件**(标记为"MODIFY"):直接需要更改的文件
197
- 2. **需要参考的文件**(标记为"REFERENCE"):理解需求或实现修改所需参考的文件
198
- 3. **需要新增的文件**(标记为"ADD"):实现需求可能需要创建的新文件
199
- 4. **需要删除的文件**(标记为"REMOVE"):实现需求可能需要删除的文件
217
+ ## Your Task and Requirements
218
+ You are a code analysis expert who needs to analyze project-related files based on user requirements. Your job is to determine:
219
+
220
+ 1. **Files to Modify** (marked as "MODIFY"): Files that need direct changes
221
+ 2. **Files to Reference** (marked as "REFERENCE"): Files needed for understanding requirements or implementing modifications
222
+ 3. **Files to Add** (marked as "ADD"): New files that may need to be created to fulfill requirements
223
+ 4. **Files to Remove** (marked as "REMOVE"): Files that may need to be deleted to fulfill requirements
200
224
 
201
- 请通过以下步骤进行分析:
202
- 1. 理解用户需求的核心目标
203
- 2. 使用提供的工具函数探索项目结构
204
- 3. 分析相关文件的内容和依赖关系
205
- 4. 确定需要修改、参考、新增或删除的文件列表
225
+ Please analyze through the following steps:
226
+ 1. Understand the core objectives of user requirements
227
+ 2. Use the provided tool functions to explore project structure
228
+ 3. Analyze the content and dependencies of relevant files
229
+ 4. Determine the list of files to modify, reference, add, or remove
206
230
 
207
- ## 返回格式要求
208
- 返回格式必须是严格的JSON格式:
231
+ ## Return Format Requirements
232
+ The return format must be strict JSON format:
209
233
 
210
234
  ```json
211
235
  {
212
236
  "suggestions": [
213
237
  {
214
- "command": "函数名称",
238
+ "command": "function_name",
215
239
  "parameters": {},
216
240
  "confidence": 0.9,
217
- "reasoning": "推荐理由"
241
+ "reasoning": "recommendation_reason"
218
242
  }
219
243
  ],
220
- "reasoning": "整体推理说明"
244
+ "reasoning": "overall_reasoning_explanation"
221
245
  }
222
246
  ```
223
247
 
224
- 请返回第一个建议的函数调用。我会将每个函数的执行结果提供给你,然后你可以根据这些结果确定下一步要执行的函数,直到完成分析。
248
+ Please return the first suggested function call. I will provide you with the execution results of each function, and then you can determine the next function to execute based on these results until the analysis is complete.
225
249
  """
226
250
  env_info = detect_env()
227
251
  shell_type = "bash"
@@ -231,37 +255,37 @@ class AgenticFilter:
231
255
  shell_type = "powershell"
232
256
  return {
233
257
  "user_input": request.user_input,
234
- "current_files": self.memory_config.memory["current_files"]["files"],
258
+ "current_files": self.memory_config.get_current_files(),
235
259
  "conversation_history": self.conversation_history,
236
260
  "available_commands": self._command_readme.prompt(),
237
- "current_conf": json.dumps(self.memory_config.memory["conf"], indent=2),
261
+ "current_conf": json.dumps(self.memory_config.get_all_config(), indent=2),
238
262
  "env_info": env_info,
239
263
  "shell_type": shell_type,
240
264
  "shell_encoding": shells.get_terminal_encoding(),
241
- "conversation_safe_zone_tokens": self.args.conversation_prune_safe_zone_tokens,
265
+ "conversation_safe_zone_tokens": self._get_parsed_safe_zone_tokens(),
242
266
  "os_distribution": shells.get_os_distribution(),
243
267
  "current_user": shells.get_current_username(),
244
268
  "command_combination_readme": self._command_combination_readme.prompt(
245
269
  user_input=request.user_input
246
270
  ),
247
- "current_project": os.path.abspath(self.args.source_dir),
248
- }
271
+ "current_project": os.path.abspath(self.args.source_dir or "."),
272
+ } # type: ignore
249
273
 
250
274
  @byzerllm.prompt()
251
275
  def _command_combination_readme(self, user_input: str) -> str:
252
276
  """
253
- ## 操作流程建议
254
- 1. **理解需求**: 分析用户输入 `{{ user_input }}`。
255
- 2. **探索项目**:
256
- * 使用 `list_files` 层层递进了解项目结构,用来确定需要关注的文件。
257
- * 如果用户提及文件名等,则可以使用 `find_files_by_name` 或,如果用户提到关键字则可以使用 `find_files_by_content` 定位可能相关的文件。
258
- * 如果用户提到了具体的符号(函数,类名等)则可以使用 `get_project_map` 获取候选文件的详细信息(如符号)。
259
- 3. **深入分析**:
260
- * 使用 `read_files` 读取关键文件的内容进行确认。如果文件过大,使用 `line_ranges` 参数分段读取。
261
- * 如有必要,使用 `run_python` `execute_shell_command` 执行代码或命令进行更复杂的分析。
262
- 4. **迭代决策**: 根据工具的返回结果,你可能需要多次调用不同的工具来逐步缩小范围或获取更多信息。
263
- 6. **最终响应**: 当你确定了所有需要参考和修改的文件后,**必须**调用 `output_result` 工具,并提供符合其要求格式的JSON字符串作为其 `response` 参数。
264
- 该json格式要求为:
277
+ ## Recommended Operation Flow
278
+ 1. **Understand Requirements**: Analyze user input `{{ user_input }}`.
279
+ 2. **Explore Project**:
280
+ * List all current AC modules using `execute_shell_command` to enumerate them, then read `.ac.mod.md` files to understand the purpose of each AC module.
281
+ * Use `list_files` to progressively understand project structure and determine files that need attention.
282
+ * If user mentions file names, use `find_files_by_name`; if user mentions keywords, use `find_files_by_content` to locate potentially relevant files.
283
+ 3. **In-depth Analysis**:
284
+ * Use `read_files` to read key file contents for confirmation. If files are too large, use `line_ranges` parameter for segmented reading.
285
+ * If necessary, use `execute_shell_command` to execute code or commands for more complex analysis.
286
+ 4. **Iterative Decision Making**: Based on tool return results, you may need to call different tools multiple times to gradually narrow down scope or obtain more information.
287
+ 6. **Final Response**: When you have determined all files that need to be referenced and modified, you **must** call the `output_result` tool and provide a JSON string that meets its format requirements as the `response` parameter.
288
+ The required JSON format is:
265
289
  ```json
266
290
  {
267
291
  "files": [
@@ -270,36 +294,33 @@ class AgenticFilter:
270
294
  {"path": "/path/to/new_file.txt", "operation": "ADD"},
271
295
  {"path": "/path/to/old_file.log", "operation": "REMOVE"}
272
296
  ],
273
- "reasoning": "详细说明你是如何通过分析和使用工具得出这个文件列表的。"
297
+ "reasoning": "Detailed explanation of how you analyzed and used tools to arrive at this file list."
274
298
  }
275
299
  ```
276
-
277
- {% if enable_active_context %}
278
- ** 非常非常重要的提示 **
279
- 每一个目录都有一个描述信息,比如 {{ project_path }}/src/abc/bbc 的目录描述信息会放在 {{ project_path }}/.auto-coder/active-context/src/abc/bbc/active.md 文件中。
280
- 你可以使用 read_files 函数读取,从而帮助你更好的挑选要详细阅读哪个文件。值得注意的是,active.md 并不会包含该目录下所有的文件信息,只保存最近发生变更的文件的信息。
281
- {% endif %}
282
- """
300
+
301
+ ** Very Important Note **
302
+ You should try to read the .ac.mod.md file for every directory to better understand the directory content. For example, directory description information for {{ project_path }}/src/abc/bbc would be located in {{ project_path }}/src/abc/bbc/.ac.mod.md file.
303
+ You can use the read_files function to read these files, helping you better choose which files to read in detail.
304
+ """
283
305
  return {
284
- "project_path": os.path.abspath(self.args.source_dir),
285
- "enable_active_context": self.args.enable_active_context,
286
- }
306
+ "project_path": os.path.abspath(self.args.source_dir or ".")
307
+ } # type: ignore
287
308
 
288
309
  @byzerllm.prompt()
289
310
  def _execute_command_result(self, result: str) -> str:
290
311
  """
291
- 根据函数执行结果,返回下一个函数。
312
+ Based on function execution results, return the next function.
292
313
 
293
- 下面是我们上一个函数执行结果:
314
+ Below is our previous function execution result:
294
315
 
295
316
  <function_result>
296
317
  {{ result }}
297
318
  </function_result>
298
319
 
299
- 请根据命令执行结果以及前面的对话,返回下一个函数。
320
+ Please return the next function based on the command execution results and previous conversation.
300
321
 
301
- *** 非常非常重要的提示 ***
302
- 1. 如果你认为已经收集到足够信息来确定最终的文件列表,请务必调用 `output_result` 并以如下格式要求的JSON字符串作为 `response` 参数。最多允许 {{ max_iterations }} 次工具调用。
322
+ *** Very Important Notes ***
323
+ 1. If you think you have collected enough information to determine the final file list, you must call `output_result` with a JSON string in the required format as the `response` parameter. Maximum {{ max_iterations }} tool calls allowed.
303
324
  ```json
304
325
  {
305
326
  "files": [
@@ -308,114 +329,46 @@ class AgenticFilter:
308
329
  {"path": "/path/to/new_file.txt", "operation": "ADD"},
309
330
  {"path": "/path/to/old_file.log", "operation": "REMOVE"}
310
331
  ],
311
- "reasoning": "详细说明你是如何通过分析和使用工具得出这个文件列表的。"
332
+ "reasoning": "Detailed explanation of how you analyzed and used tools to arrive at this file list."
312
333
  }
313
334
  ```
314
- 2. 你最多尝试 {{ auto_command_max_iterations }} 次,如果 {{ auto_command_max_iterations }} 次都没有满足要求,则不要返回任何函数,确保 suggestions 为空。
335
+ 2. You can try at most {{ auto_command_max_iterations }} times. If {{ auto_command_max_iterations }} attempts do not meet requirements, do not return any function and ensure suggestions is empty.
315
336
  """
316
337
  return {
317
338
  "auto_command_max_iterations": self.args.auto_command_max_iterations,
318
- "conversation_safe_zone_tokens": self.args.conversation_prune_safe_zone_tokens,
319
- }
339
+ "conversation_safe_zone_tokens": self._get_parsed_safe_zone_tokens(),
340
+ } # type: ignore
320
341
 
321
342
  @byzerllm.prompt()
322
343
  def _command_readme(self) -> str:
323
344
  """
324
- 你有如下函数可供使用:
325
- <commands>
326
- <name>ask_user</name>
327
- <description>
328
- 如果你对用户的问题有什么疑问,或者你想从用户收集一些额外信息,可以调用此方法。
329
- 输入参数 question 是你对用户的提问。
330
- 返回值是 用户对你问题的回答。
331
- ** 如果你的问题比较多,建议一次就问一个,然后根据用户回答再问下一个。 **
332
- </description>
333
- <usage>
334
- 该命令接受一个参数 question,为需要向用户询问的问题字符串。
335
-
336
- 使用例子:
337
- ask_user(question="请输入火山引擎的 R1 模型推理点")
338
- </command>
339
-
340
- <command>
341
- <name>run_python</name>
342
- <description>运行指定的Python代码。主要用于执行一些Python脚本或测试代码。</description>
343
- <usage>
344
- 该命令接受一个参数 code,为要执行的Python代码字符串。
345
-
346
- 使用例子:
347
-
348
- run_python(code="print('Hello World')")
349
-
350
- 注意:
351
- - 代码将在项目根目录下执行
352
- - 可以访问项目中的所有文件
353
- - 输出结果会返回给用户
354
- </usage>
355
- </command>
356
-
345
+ You have the following functions available:
346
+ <commands>
357
347
  <command>
358
348
  <name>execute_shell_command</name>
359
- <description>运行指定的Shell脚本。主要用于编译、运行、测试等任务。</description>
349
+ <description>Execute specified shell scripts. Mainly used for compilation, running, testing, and other tasks.</description>
360
350
  <usage>
361
- 该命令接受一个参数 command,为要执行的Shell脚本字符串。
351
+ This command accepts one parameter 'command', which is the shell script string to execute.
362
352
 
363
353
 
364
- 使用例子:
354
+ Usage example:
365
355
 
366
356
  execute_shell_command(command="ls -l")
367
357
 
368
- 注意:
369
- - 脚本将在项目根目录下执行
370
- - 禁止执行包含 rm 命令的脚本
371
- - 输出结果会返回给用户
372
- - 执行该命令的时候,需要通过 ask_user 询问用户是否同意执行,如果用户拒绝,则不再执行当前想执行的脚本呢。
373
- </usage>
374
- </command>
375
-
376
- <command>
377
- <name>generate_shell_command</name>
378
- <description>
379
- 根据用户需求描述,生成shell脚本。
380
- </description>
381
- <usage>
382
- 支持的参数名为 input_text, 字符串类型,用户的需求,使用该函数,会打印生成结果,用户可以更加清晰
383
- 的看到生成的脚本。然后配合 ask_user, execute_shell_command 两个函数,最终完成
384
- 脚本执行。
385
- </usage>
386
- </command>
387
-
388
- <command>
389
- <name>get_project_map</name>
390
- <description>返回项目中指定文件包括文件用途、导入的包、定义的类、函数、变量等。</description>
391
- <usage>
392
- 该命令接受一个参数 file_paths,路径list,或者是以逗号分割的多个文件路径。
393
- 路径支持相对路径和绝对路径。
394
-
395
- 使用例子:
396
-
397
- get_project_map(file_paths=["full/path/to/main.py","partial/path/to/utils.py"]),
398
-
399
- 或者:
400
-
401
- get_project_map(file_paths="full/path/to/main.py,partial/path/to/utils.py")
402
-
403
- 该函数特别适合你想要了解某个文件的用途,以及该文件的导入的包,定义的类,函数,变量等信息。
404
- 同时,你还能看到文件的大小(tokens数),以及索引的大小(tokens数),以及构建索引花费费用等信息。
405
- 如果你觉得该文件确实是你关注的,你可以通过 read_files 函数来读取文件完整内容,从而帮你做更好的决策。
406
-
407
- 注意:
408
- - 返回值为JSON格式文本
409
- - 只能返回已被索引的文件
358
+ Notes:
359
+ - Scripts will be executed in the project root directory
360
+ - Scripts containing rm commands are prohibited
361
+ - Output results will be returned to the user
362
+ - When executing this command, you need to ask the user through ask_user whether they agree to execute it. If the user refuses, do not execute the script.
410
363
  </usage>
411
- </command>
364
+ </command>
412
365
 
413
366
  <command>
414
367
  <name>list_files</name>
415
- <description>list_files 查看某个目录下的所有文件</description>
368
+ <description>list_files views all files in a specific directory</description>
416
369
  <usage>
417
- 该命令接受一个参数 path, 为要查看的目录路径。
418
- 使用例子:
370
+ This command accepts one parameter 'path', which is the directory path to view.
371
+ Usage example:
419
372
  list_files(path="path/to/dir")
420
373
 
421
374
  </usage>
@@ -423,117 +376,117 @@ class AgenticFilter:
423
376
 
424
377
  <command>
425
378
  <name>read_files</name>
426
- <description>读取指定文件的内容(支持指定行范围),支持文件名或绝对路径。</description>
379
+ <description>Read specified file content (supports line range specification), supports filename or absolute path.</description>
427
380
  <usage>
428
- 该函数用于读取指定文件的内容。
381
+ This function is used to read specified file content.
429
382
 
430
- 参数说明:
383
+ Parameter description:
431
384
  1. paths (str):
432
- - 以逗号分隔的文件路径列表
433
- - 支持两种格式:
434
- a) 文件名: 如果多个文件匹配该名称,将选择第一个匹配项
435
- b) 绝对路径: 直接指定文件的完整路径
436
- - 示例: "main.py,utils.py" "/path/to/main.py,/path/to/utils.py"
437
- - 建议: 每次调用推荐一个文件,最多不要超过3个文件。
385
+ - Comma-separated list of file paths
386
+ - Supports two formats:
387
+ a) Filename: If multiple files match this name, the first match will be selected
388
+ b) Absolute path: Directly specify the complete file path
389
+ - Example: "main.py,utils.py" or "/path/to/main.py,/path/to/utils.py"
390
+ - Recommendation: Each call should read one file, maximum of 3 files.
438
391
 
439
392
  2. line_ranges (Optional[str]):
440
- - 可选参数,用于指定每个文件要读取的具体行范围
441
- - 格式说明:
442
- * 使用逗号分隔不同文件的行范围
443
- * 每个文件可以指定多个行范围,用/分隔
444
- * 每个行范围使用-连接起始行和结束行
445
- - 示例:
446
- * "1-100,2-50" (为两个文件分别指定一个行范围)
447
- * "1-100/200-300,50-100" (第一个文件指定两个行范围,第二个文件指定一个行范围)
448
- - 注意: line_ranges中的文件数量必须与paths中的文件数量一致,否则会抛出错误
449
-
450
- 返回值:
451
- - 返回str类型,包含所有请求文件的内容
452
- - 每个文件内容前会标注文件路径和行范围信息(如果指定了行范围)
453
-
454
- 使用例子:
393
+ - Optional parameter to specify the specific line ranges to read for each file
394
+ - Format description:
395
+ * Use commas to separate line ranges for different files
396
+ * Each file can specify multiple line ranges, separated by /
397
+ * Each line range uses - to connect start and end lines
398
+ - Examples:
399
+ * "1-100,2-50" (specify one line range for each of two files)
400
+ * "1-100/200-300,50-100" (first file has two line ranges, second file has one line range)
401
+ - Note: The number of files in line_ranges must match the number of files in paths, otherwise an error will be thrown
402
+
403
+ Return value:
404
+ - Returns str type, containing content of all requested files
405
+ - Each file content will be annotated with file path and line range information (if line ranges are specified)
406
+
407
+ Usage examples:
455
408
 
456
409
  read_files(paths="main.py,utils.py", line_ranges="1-100/200-300,50-100")
457
410
 
458
411
  read_files(paths="main.py,utils.py")
459
412
 
460
- 你可以使用 get_project_structure 函数获取项目结构后,然后再通过 get_project_map 函数获取某个文件的用途,符号列表,以及
461
- 文件大小(tokens数),最后再通过 read_files 函数来读取文件内容,从而帮你做更好的决策。如果需要读取的文件过大,
413
+ You can use get_project_structure function to get project structure, then use get_project_map function to get a file's purpose, symbol list, and
414
+ file size (token count), and finally use read_files function to read file content, helping you make better decisions. If the file to be read is too large,
462
415
 
463
- 特别注意:使用 read_files 时,一次性读取文件数量不要超过1个,每次只读取200行。如果发现读取的内容不够,则继续读取下面200行。
416
+ Special note: When using read_files, do not read more than 1 file at a time, only read 200 lines each time. If you find the read content is insufficient, continue reading the next 200 lines.
464
417
 
465
418
  </usage>
466
419
  </command>
467
420
 
468
421
  <command>
469
422
  <name>find_files_by_name</name>
470
- <description>根据文件名中的关键字搜索文件。</description>
423
+ <description>Search files based on keywords in filename.</description>
471
424
  <usage>
472
- 该命令接受一个参数 keyword,为要搜索的关键字字符串。
425
+ This command accepts one parameter 'keyword', which is the keyword string to search for.
473
426
 
474
- 使用例子:
427
+ Usage example:
475
428
 
476
429
  find_files_by_name(keyword="test")
477
430
 
478
- 注意:
479
- - 搜索不区分大小写
480
- - 返回所有匹配的文件路径,逗号分隔
431
+ Notes:
432
+ - Search is case-insensitive
433
+ - Returns all matching file paths, comma-separated
481
434
  </usage>
482
435
  </command>
483
436
 
484
437
  <command>
485
438
  <name>find_files_by_content</name>
486
- <description>根据文件内容中的关键字搜索文件。</description>
439
+ <description>Search files based on keywords in file content.</description>
487
440
  <usage>
488
- 该命令接受一个参数 keyword,为要搜索的关键字字符串。
441
+ This command accepts one parameter 'keyword', which is the keyword string to search for.
489
442
 
490
- 使用例子:
443
+ Usage example:
491
444
 
492
445
  find_files_by_content(keyword="TODO")
493
446
 
494
- 注意:
495
- - 搜索不区分大小写
496
- - 如果结果过多,只返回前10个匹配项
447
+ Notes:
448
+ - Search is case-insensitive
449
+ - If too many results, only returns the first 10 matches
497
450
  </usage>
498
451
  </command>
499
452
 
500
453
  <command>
501
454
  <name>read_file_with_keyword_ranges</name>
502
- <description>读取包含指定关键字的行及其前后指定范围的行。</description>
455
+ <description>Read lines containing specified keywords and their surrounding lines within specified range.</description>
503
456
  <usage>
504
- 该函数用于读取包含关键字的行及其前后指定范围的行。
457
+ This function is used to read lines containing keywords and their surrounding lines within specified range.
505
458
 
506
- 参数说明:
507
- 1. file_path (str): 文件路径,可以是相对路径或绝对路径
508
- 2. keyword (str): 要搜索的关键字
509
- 3. before_size (int): 关键字行之前要读取的行数,默认100
510
- 4. after_size (int): 关键字行之后要读取的行数,默认100
459
+ Parameter description:
460
+ 1. file_path (str): File path, can be relative or absolute path
461
+ 2. keyword (str): Keyword to search for
462
+ 3. before_size (int): Number of lines to read before keyword line, default 100
463
+ 4. after_size (int): Number of lines to read after keyword line, default 100
511
464
 
512
- 返回值:
513
- - 返回str类型,包含关键字的行及其前后指定范围的行
514
- - 格式如下:
465
+ Return value:
466
+ - Returns str type, containing keyword lines and their surrounding lines within specified range
467
+ - Format as follows:
515
468
  ```
516
469
  ##File: /path/to/file.py
517
470
  ##Line: 10-20
518
471
 
519
- 内容
472
+ Content
520
473
  ```
521
474
 
522
- 使用例子:
475
+ Usage example:
523
476
  read_file_with_keyword_ranges(file_path="main.py", keyword="TODO", before_size=5, after_size=5)
524
477
 
525
- 注意:
526
- - 如果文件中有多个匹配的关键字,会返回多个内容块
527
- - 搜索不区分大小写
478
+ Notes:
479
+ - If there are multiple matching keywords in the file, multiple content blocks will be returned
480
+ - Search is case-insensitive
528
481
  </usage>
529
482
  </command>
530
483
 
531
484
  <command>
532
485
  <name>output_result</name>
533
- <description>输出最后需要的结果</description>
486
+ <description>Output the final required result</description>
534
487
  <usage>
535
- 只有一个参数:
536
- response: 字符串类型,需要返回给用户的内容。 response 必须满足如下Json格式:
488
+ Only one parameter:
489
+ response: String type, content to return to user. response must satisfy the following Json format:
537
490
 
538
491
  ```json
539
492
  {
@@ -543,70 +496,70 @@ class AgenticFilter:
543
496
  {"path": "/path/to/new_file.txt", "operation": "ADD"},
544
497
  {"path": "/path/to/old_file.log", "operation": "REMOVE"}
545
498
  ],
546
- "reasoning": "详细说明你是如何通过分析和使用工具得出这个文件列表的。"
499
+ "reasoning": "Detailed explanation of how you analyzed and used tools to arrive at this file list."
547
500
  }
548
501
  ```
549
502
 
550
- 使用例子:
551
- output_result(response='{"files": [{"path": "/path/to/file1.py", "operation": "MODIFY"}, {"path": "/path/to/file2.md", "operation": "REFERENCE"}, {"path": "/path/to/new_file.txt", "operation": "ADD"}, {"path": "/path/to/old_file.log", "operation": "REMOVE"}], "reasoning": "详细说明你是如何通过分析和使用工具得出这个文件列表的。"}')
503
+ Usage example:
504
+ output_result(response='{"files": [{"path": "/path/to/file1.py", "operation": "MODIFY"}, {"path": "/path/to/file2.md", "operation": "REFERENCE"}, {"path": "/path/to/new_file.txt", "operation": "ADD"}, {"path": "/path/to/old_file.log", "operation": "REMOVE"}], "reasoning": "Detailed explanation of how you analyzed and used tools to arrive at this file list."}')
552
505
  </usage>
553
506
  </command>
554
507
 
555
508
  <command>
556
509
  <name>count_file_tokens</name>
557
- <description>计算指定文件的token数量。</description>
510
+ <description>Calculate the token count of specified file.</description>
558
511
  <usage>
559
- 该函数接受一个参数 file_path, 为要计算的文件路径。
512
+ This function accepts one parameter file_path, which is the file path to calculate.
560
513
 
561
- 使用例子:
514
+ Usage example:
562
515
  count_file_tokens(file_path="full")
563
516
 
564
- 注意:
565
- - 返回值为int类型,表示文件的token数量。
517
+ Notes:
518
+ - Return value is int type, representing the token count of the file.
566
519
 
567
520
  </usage>
568
521
  </command>
569
522
 
570
523
  <command>
571
524
  <name>count_string_tokens</name>
572
- <description>计算指定字符串的token数量。</description>
525
+ <description>Calculate the token count of specified string.</description>
573
526
  <usage>
574
- 该函数接受一个参数 text, 为要计算的文本。
527
+ This function accepts one parameter text, which is the text to calculate.
575
528
 
576
- 使用例子:
577
- count_string_tokens(text="你好,世界")
529
+ Usage example:
530
+ count_string_tokens(text="Hello, World")
578
531
 
579
- 注意:
580
- - 返回值为int类型,表示文本的token数量。
532
+ Notes:
533
+ - Return value is int type, representing the token count of the text.
581
534
 
582
535
  </usage>
583
536
  </command>
584
537
 
585
538
  <command>
586
539
  <n>find_symbol_definition</n>
587
- <description>查找指定符号的定义所在的文件路径。</description>
540
+ <description>Find the file path where the specified symbol is defined.</description>
588
541
  <usage>
589
- 该函数接受一个参数 symbol, 为要查找的符号名称。
542
+ This function accepts one parameter symbol, which is the symbol name to search for.
590
543
 
591
- 使用例子:
544
+ Usage examples:
592
545
  find_symbol_definition(symbol="MyClass")
593
546
  find_symbol_definition(symbol="process_data")
594
547
 
595
- 注意:
596
- - 返回值为字符串,包含符号定义所在的文件路径列表,以逗号分隔
597
- - 支持精确匹配和模糊匹配(不区分大小写)
598
- - 如果未找到匹配项,会返回提示信息
548
+ Notes:
549
+ - Return value is string, containing file path list where symbols are defined, comma-separated
550
+ - Supports exact matching and fuzzy matching (case-insensitive)
551
+ - If no matches found, returns prompt information
599
552
 
600
553
  </usage>
601
554
  </command>
602
555
  <command>
603
556
  <n>execute_mcp_server</n>
604
- <description>执行MCP服务器</description>
557
+ <description>Execute MCP server</description>
605
558
  <usage>
606
- 该函数接受一个参数 query, 为要执行的MCP服务器查询字符串。
559
+ This function accepts one parameter query, which is the MCP server query string to execute.
607
560
 
608
- 你可以根据下面已经连接的 mcp server 信息,来决定个是否调用该函数,注意该函数会更具你的 query
609
- 自动选择合适的 mcp server 来执行。如果你想某个特定的 server 来执行,你可以在 query 中说明你想哪个 server 执行。
561
+ You can decide whether to call this function based on the connected mcp server information below. Note that this function will automatically
562
+ select the appropriate mcp server to execute based on your query. If you want a specific server to execute, you can specify which server you want in the query.
610
563
 
611
564
  <mcp_server_info>
612
565
  {{ mcp_server_info }}
@@ -621,10 +574,10 @@ class AgenticFilter:
621
574
  }
622
575
 
623
576
  def analyze(self, request: AgenticFilterRequest) -> Optional[AgenticFilterResponse]:
624
- # 获取 prompt 内容
577
+ # Get prompt content
625
578
  prompt = self._analyze.prompt(request)
626
579
 
627
- # 获取对当前项目变更的最近8条历史人物
580
+ # Get the recent 8 history records of current project changes
628
581
  action_yml_file_manager = ActionYmlFileManager(self.args.source_dir)
629
582
  history_tasks = action_yml_file_manager.to_tasks_prompt(limit=8)
630
583
  new_messages = []
@@ -633,20 +586,20 @@ class AgenticFilter:
633
586
  new_messages.append(
634
587
  {
635
588
  "role": "assistant",
636
- "content": "好的,我知道最近的任务对项目的变更了,我会参考这些来更好的理解你的需求。",
589
+ "content": "Okay, I understand the recent project changes from tasks, and I will refer to these to better understand your requirements.",
637
590
  }
638
591
  )
639
592
 
640
- # 构造对话上下文
593
+ # Construct conversation context
641
594
  conversations = new_messages + [{"role": "user", "content": prompt}]
642
595
 
643
- # 使用 stream_out 进行输出
596
+ # Use stream_out for output
644
597
  printer = Printer()
645
598
  title = printer.get_message_from_key("auto_command_analyzing")
646
599
  final_title = printer.get_message_from_key("auto_command_analyzed")
647
600
 
648
601
  def extract_command_response(content: str) -> str:
649
- # 提取 JSON 并转换为 AutoCommandResponse
602
+ # Extract JSON and convert to AutoCommandResponse
650
603
  try:
651
604
  response = to_model(content, AutoCommandResponse)
652
605
  if response.suggestions:
@@ -669,26 +622,29 @@ class AgenticFilter:
669
622
  success_flag = False
670
623
 
671
624
  get_event_manager(self.args.event_file).write_result(
672
- EventContentCreator.create_result(content=printer.get_message_from_key("agenticFilterContext")),
625
+ EventContentCreator.create_result(
626
+ content=printer.get_message_from_key("agenticFilterContext")),
673
627
  metadata={
674
- "stream_out_type": AgenticFilterStreamOutType.AGENTIC_FILTER.value
628
+ "stream_out_type": AgenticFilterStreamOutType.AGENTIC_FILTER.value
675
629
  }
676
630
  )
677
631
 
678
632
  while True:
679
- global_cancel.check_and_raise(token=self.args.event_file)
633
+ global_cancel.check_and_raise(token=self.args.cancel_token)
680
634
  # print(json.dumps(conversations, ensure_ascii=False, indent=4))
681
635
  model_name = ",".join(llms_utils.get_llm_names(self.llm))
682
636
  start_time = time.monotonic()
683
637
  result, last_meta = stream_out(
684
- self.llm.stream_chat_oai(conversations=conversations, delta_mode=True),
638
+ self.llm.stream_chat_oai(
639
+ conversations=conversations, delta_mode=True),
685
640
  model_name=model_name,
686
641
  title=title,
687
642
  final_title=final_title,
688
643
  display_func=extract_command_response,
689
644
  args=self.args,
645
+ cancel_token=self.args.cancel_token,
690
646
  extra_meta={
691
- "stream_out_type": AgenticFilterStreamOutType.AGENTIC_FILTER.value
647
+ "stream_out_type": AgenticFilterStreamOutType.AGENTIC_FILTER.value
692
648
  },
693
649
  )
694
650
 
@@ -700,9 +656,11 @@ class AgenticFilter:
700
656
  from autocoder.utils import llms as llm_utils
701
657
 
702
658
  model_info = (
703
- llm_utils.get_model_info(model_name, self.args.product_mode) or {}
659
+ llm_utils.get_model_info(
660
+ model_name, self.args.product_mode) or {}
704
661
  )
705
- input_price = model_info.get("input_price", 0.0) if model_info else 0.0
662
+ input_price = model_info.get(
663
+ "input_price", 0.0) if model_info else 0.0
706
664
  output_price = (
707
665
  model_info.get("output_price", 0.0) if model_info else 0.0
708
666
  )
@@ -743,17 +701,42 @@ class AgenticFilter:
743
701
  )
744
702
 
745
703
  conversations.append({"role": "assistant", "content": result})
746
- # 提取 JSON 并转换为 AutoCommandResponse
747
- response = to_model(result, AutoCommandResponse)
704
+ # Extract JSON and convert to AutoCommandResponse
705
+ try:
706
+ response = to_model(result, AutoCommandResponse)
707
+ except Exception as e:
708
+ error_content = printer.get_message_from_key_with_format(
709
+ "invalid_output_format_error",
710
+ error=str(e)
711
+ )
712
+ # If this key doesn't exist, use default error message
713
+ if not error_content or error_content.startswith("Message key"):
714
+ error_content = f'''Invalid output format, error message: {str(e)}
715
+ Please output in the required JSON format:
716
+ ```json
717
+ {{{{
718
+ "files": [
719
+ {{"path": "/path/to/file1.py", "operation": "MODIFY"}},
720
+ {{"path": "/path/to/file2.md", "operation": "REFERENCE"}},
721
+ {{"path": "/path/to/new_file.txt", "operation": "ADD"}},
722
+ {{"path": "/path/to/old_file.log", "operation": "REMOVE"}}
723
+ ],
724
+ "reasoning": "Detailed explanation of how you analyzed and used tools to arrive at this file list."
725
+ }}}}
726
+ ```
727
+ '''
728
+ conversations.append(
729
+ {"role": "user", "content": error_content})
730
+ continue
748
731
 
749
732
  if not response or not response.suggestions:
750
733
  break
751
734
 
752
- # 执行命令
735
+ # Execute command
753
736
  command = response.suggestions[0].command
754
737
  parameters = response.suggestions[0].parameters
755
738
 
756
- # 打印正在执行的命令
739
+ # Print the command being executed
757
740
  temp_content = printer.get_message_from_key_with_format(
758
741
  "auto_command_executing", command=command
759
742
  )
@@ -764,15 +747,16 @@ class AgenticFilter:
764
747
  content=EventContentCreator.ResultCommandPrepareStatContent(
765
748
  command=command, parameters=parameters
766
749
  ).to_dict()
767
- ),metadata={
768
- "stream_out_type": AgenticFilterStreamOutType.AGENTIC_FILTER.value
750
+ ), metadata={
751
+ "stream_out_type": AgenticFilterStreamOutType.AGENTIC_FILTER.value
769
752
  }
770
753
  )
771
754
  try:
772
755
  self.execute_auto_command(command, parameters)
773
756
  except Exception as e:
774
- error_content = f"执行命令失败,错误信息:{e}"
775
- conversations.append({"role": "user", "content": error_content})
757
+ error_content = f"Command execution failed, error message: {e}"
758
+ conversations.append(
759
+ {"role": "user", "content": error_content})
776
760
  continue
777
761
 
778
762
  content = ""
@@ -780,30 +764,32 @@ class AgenticFilter:
780
764
  if last_result:
781
765
  action = last_result.meta["action"]
782
766
  if action == "coding":
783
- # 如果上一步是 coding,则需要把上一步的更改前和更改后的内容作为上下文
767
+ # If the previous step was coding, need to include before and after changes as context
784
768
  changes = git_utils.get_changes_by_commit_message(
785
769
  "", last_result.meta["commit_message"]
786
770
  )
787
771
  if changes.success:
788
772
  for file_path, change in changes.changes.items():
789
773
  if change:
790
- content += f"## File: {file_path}[更改前]\n{change.before or 'New File'}\n\nFile: {file_path}\n\n[更改后]\n{change.after or 'Deleted File'}\n\n"
774
+ content += f"## File: {file_path}[Before Changes]\n{change.before or 'New File'}\n\nFile: {file_path}\n\n[After Changes]\n{change.after or 'Deleted File'}\n\n"
791
775
  else:
792
- content = printer.get_message_from_key("no_changes_made")
776
+ content = printer.get_message_from_key(
777
+ "no_changes_made")
793
778
  else:
794
- # 其他的直接获取执行结果
779
+ # For others, directly get execution results
795
780
  content = last_result.content
796
781
 
797
782
  if action != command:
798
- # command action 不一致,则认为命令执行失败,退出
783
+ # If command and action don't match, consider command execution failed and exit
799
784
  temp_content = printer.get_message_from_key_with_format(
800
785
  "auto_command_action_break", command=command, action=action
801
786
  )
802
787
  printer.print_str_in_terminal(temp_content, style="yellow")
803
788
  get_event_manager(self.args.event_file).write_result(
804
- EventContentCreator.create_result(content=temp_content),
789
+ EventContentCreator.create_result(
790
+ content=temp_content),
805
791
  metadata={
806
- "stream_out_type": AgenticFilterStreamOutType.AGENTIC_FILTER.value
792
+ "stream_out_type": AgenticFilterStreamOutType.AGENTIC_FILTER.value
807
793
  }
808
794
  )
809
795
  break
@@ -818,14 +804,14 @@ class AgenticFilter:
818
804
  command=command, content=content
819
805
  ).to_dict(),
820
806
  metadata={
821
- "stream_out_type": AgenticFilterStreamOutType.AGENTIC_FILTER.value
807
+ "stream_out_type": AgenticFilterStreamOutType.AGENTIC_FILTER.value
822
808
  }
823
809
  )
824
810
  )
825
811
 
826
- # 打印执行结果
812
+ # Print execution results
827
813
  console = Console()
828
- # 截取content前后200字符
814
+ # Truncate content to 200 characters before and after
829
815
  truncated_content = (
830
816
  content[:200] + "\n...\n" + content[-200:]
831
817
  if len(content) > 400
@@ -834,7 +820,7 @@ class AgenticFilter:
834
820
  title = printer.get_message_from_key_with_format(
835
821
  "command_execution_result", action=action
836
822
  )
837
- # 转义内容,避免Rich将内容中的[]解释为markup语法
823
+ # Escape content to prevent Rich from interpreting [] in content as markup syntax
838
824
  text_content = Text(truncated_content)
839
825
  console.print(
840
826
  Panel(
@@ -842,22 +828,23 @@ class AgenticFilter:
842
828
  )
843
829
  )
844
830
 
845
- # 添加新的对话内容
831
+ # Add new conversation content
846
832
  new_content = self._execute_command_result.prompt(content)
847
833
  conversations.append({"role": "user", "content": new_content})
848
834
 
849
- # 统计 token 数量
835
+ # Count token numbers
850
836
  total_tokens = count_tokens(
851
837
  json.dumps(conversations, ensure_ascii=False)
852
838
  )
853
839
 
854
- # 如果对话过长,使用默认策略进行修剪
855
- if total_tokens > self.args.conversation_prune_safe_zone_tokens:
840
+ # If conversation is too long, use default strategy for pruning
841
+ parsed_safe_zone_tokens = self._get_parsed_safe_zone_tokens()
842
+ if total_tokens > parsed_safe_zone_tokens:
856
843
  self.printer.print_in_terminal(
857
844
  "conversation_pruning_start",
858
845
  style="yellow",
859
846
  total_tokens=total_tokens,
860
- safe_zone=self.args.conversation_prune_safe_zone_tokens,
847
+ safe_zone=parsed_safe_zone_tokens,
861
848
  )
862
849
  from autocoder.common.pruner.conversation_pruner import ConversationPruner
863
850
 
@@ -872,27 +859,28 @@ class AgenticFilter:
872
859
  get_event_manager(self.args.event_file).write_result(
873
860
  EventContentCreator.create_result(content=temp_content),
874
861
  metadata={
875
- "stream_out_type": AgenticFilterStreamOutType.AGENTIC_FILTER.value
862
+ "stream_out_type": AgenticFilterStreamOutType.AGENTIC_FILTER.value
876
863
  }
877
864
  )
878
865
  break
879
866
 
880
867
  get_event_manager(self.args.event_file).write_result(
881
- EventContentCreator.create_result(content=printer.get_message_from_key("agenticFilterCommandResult")),
868
+ EventContentCreator.create_result(
869
+ content=printer.get_message_from_key("agenticFilterCommandResult")),
882
870
  metadata={
883
- "stream_out_type": AgenticFilterStreamOutType.AGENTIC_FILTER.value
871
+ "stream_out_type": AgenticFilterStreamOutType.AGENTIC_FILTER.value
884
872
  }
885
- )
873
+ )
886
874
 
887
875
  if success_flag:
888
- to_model(content, AgenticFilterResponse)
876
+ return to_model(content, AgenticFilterResponse)
889
877
  # return AgenticFilterResponse(**json.loads(content))
890
878
  else:
891
879
  return None
892
880
 
893
881
  def execute_auto_command(self, command: str, parameters: Dict[str, Any]) -> None:
894
882
  """
895
- 执行自动生成的命令
883
+ Execute automatically generated commands
896
884
  """
897
885
  command_map = {
898
886
  "run_python": self.tools.run_python_code,
@@ -912,6 +900,7 @@ class AgenticFilter:
912
900
  "count_file_tokens": self.tools.count_file_tokens,
913
901
  "count_string_tokens": self.tools.count_string_tokens,
914
902
  "find_symbol_definition": self.tools.find_symbol_definition,
903
+ "execute_shell_command": shells.execute_shell_command,
915
904
  }
916
905
 
917
906
  if command not in command_map:
@@ -922,7 +911,7 @@ class AgenticFilter:
922
911
  return
923
912
 
924
913
  try:
925
- # 将参数字典转换为命令所需的格式
914
+ # Convert parameter dictionary to the format required by commands
926
915
  if parameters:
927
916
  command_map[command](**parameters)
928
917
  else: