auto-coder 0.1.400__py3-none-any.whl → 2.0.0__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.
- auto_coder-2.0.0.dist-info/LICENSE +158 -0
- auto_coder-2.0.0.dist-info/METADATA +558 -0
- auto_coder-2.0.0.dist-info/RECORD +795 -0
- {auto_coder-0.1.400.dist-info → auto_coder-2.0.0.dist-info}/WHEEL +1 -1
- {auto_coder-0.1.400.dist-info → auto_coder-2.0.0.dist-info}/entry_points.txt +3 -3
- autocoder/__init__.py +31 -0
- autocoder/agent/auto_filegroup.py +32 -13
- autocoder/agent/auto_learn_from_commit.py +9 -1
- autocoder/agent/base_agentic/__init__.py +3 -0
- autocoder/agent/base_agentic/agent_hub.py +1 -1
- autocoder/agent/base_agentic/base_agent.py +235 -136
- autocoder/agent/base_agentic/default_tools.py +119 -118
- autocoder/agent/base_agentic/test_base_agent.py +1 -1
- autocoder/agent/base_agentic/tool_registry.py +32 -20
- autocoder/agent/base_agentic/tools/read_file_tool_resolver.py +25 -4
- autocoder/agent/base_agentic/tools/write_to_file_tool_resolver.py +24 -11
- autocoder/agent/base_agentic/types.py +42 -0
- autocoder/agent/entry_command_agent/chat.py +73 -59
- autocoder/auto_coder.py +31 -40
- autocoder/auto_coder_rag.py +11 -1084
- autocoder/auto_coder_runner.py +1029 -2310
- autocoder/auto_coder_terminal.py +26 -0
- autocoder/auto_coder_terminal_v3.py +190 -0
- autocoder/chat/conf_command.py +224 -124
- autocoder/chat/models_command.py +361 -299
- autocoder/chat/rules_command.py +79 -31
- autocoder/chat_auto_coder.py +1021 -372
- autocoder/chat_auto_coder_lang.py +23 -732
- autocoder/commands/auto_command.py +26 -9
- autocoder/commands/auto_web.py +1 -1
- autocoder/commands/tools.py +44 -44
- autocoder/common/__init__.py +150 -128
- autocoder/common/ac_style_command_parser/__init__.py +39 -2
- autocoder/common/ac_style_command_parser/config.py +422 -0
- autocoder/common/ac_style_command_parser/parser.py +292 -78
- autocoder/common/ac_style_command_parser/test_parser.py +241 -16
- autocoder/common/ac_style_command_parser/test_typed_parser.py +342 -0
- autocoder/common/ac_style_command_parser/typed_parser.py +653 -0
- autocoder/common/action_yml_file_manager.py +25 -13
- autocoder/common/agent_events/__init__.py +52 -0
- autocoder/common/agent_events/agent_event_emitter.py +193 -0
- autocoder/common/agent_events/event_factory.py +177 -0
- autocoder/common/agent_events/examples.py +307 -0
- autocoder/common/agent_events/types.py +113 -0
- autocoder/common/agent_events/utils.py +68 -0
- autocoder/common/agent_hooks/__init__.py +44 -0
- autocoder/common/agent_hooks/examples.py +582 -0
- autocoder/common/agent_hooks/hook_executor.py +217 -0
- autocoder/common/agent_hooks/hook_manager.py +288 -0
- autocoder/common/agent_hooks/types.py +133 -0
- autocoder/common/agent_hooks/utils.py +99 -0
- autocoder/common/agent_query_queue/queue_executor.py +324 -0
- autocoder/common/agent_query_queue/queue_manager.py +325 -0
- autocoder/common/agents/__init__.py +11 -0
- autocoder/common/agents/agent_manager.py +323 -0
- autocoder/common/agents/agent_parser.py +189 -0
- autocoder/common/agents/example_usage.py +344 -0
- autocoder/common/agents/integration_example.py +330 -0
- autocoder/common/agents/test_agent_parser.py +545 -0
- autocoder/common/async_utils.py +101 -0
- autocoder/common/auto_coder_lang.py +23 -972
- autocoder/common/autocoderargs_parser/__init__.py +14 -0
- autocoder/common/autocoderargs_parser/parser.py +184 -0
- autocoder/common/autocoderargs_parser/tests/__init__.py +1 -0
- autocoder/common/autocoderargs_parser/tests/test_args_parser.py +235 -0
- autocoder/common/autocoderargs_parser/tests/test_token_parser.py +195 -0
- autocoder/common/autocoderargs_parser/token_parser.py +290 -0
- autocoder/common/buildin_tokenizer.py +2 -4
- autocoder/common/code_auto_generate.py +149 -74
- autocoder/common/code_auto_generate_diff.py +163 -70
- autocoder/common/code_auto_generate_editblock.py +179 -89
- autocoder/common/code_auto_generate_strict_diff.py +167 -72
- autocoder/common/code_auto_merge_editblock.py +13 -6
- autocoder/common/code_modification_ranker.py +1 -1
- autocoder/common/command_completer.py +3 -3
- autocoder/common/command_file_manager/manager.py +183 -47
- autocoder/common/command_file_manager/test_command_file_manager.py +507 -0
- autocoder/common/command_templates.py +1 -1
- autocoder/common/conf_utils.py +2 -4
- autocoder/common/conversations/config.py +11 -3
- autocoder/common/conversations/get_conversation_manager.py +100 -2
- autocoder/common/conversations/llm_stats_models.py +264 -0
- autocoder/common/conversations/manager.py +112 -28
- autocoder/common/conversations/models.py +16 -2
- autocoder/common/conversations/storage/index_manager.py +134 -10
- autocoder/common/core_config/__init__.py +63 -0
- autocoder/common/core_config/agentic_mode_manager.py +109 -0
- autocoder/common/core_config/base_manager.py +123 -0
- autocoder/common/core_config/compatibility.py +151 -0
- autocoder/common/core_config/config_manager.py +156 -0
- autocoder/common/core_config/conversation_manager.py +31 -0
- autocoder/common/core_config/exclude_manager.py +72 -0
- autocoder/common/core_config/file_manager.py +177 -0
- autocoder/common/core_config/human_as_model_manager.py +129 -0
- autocoder/common/core_config/lib_manager.py +54 -0
- autocoder/common/core_config/main_manager.py +81 -0
- autocoder/common/core_config/mode_manager.py +126 -0
- autocoder/common/core_config/models.py +70 -0
- autocoder/common/core_config/test_memory_manager.py +1056 -0
- autocoder/common/env_manager.py +282 -0
- autocoder/common/env_manager_usage_example.py +211 -0
- autocoder/common/file_checkpoint/conversation_checkpoint.py +19 -19
- autocoder/common/file_checkpoint/manager.py +264 -48
- autocoder/common/file_checkpoint/test_backup.py +1 -18
- autocoder/common/file_checkpoint/test_manager.py +270 -1
- autocoder/common/file_checkpoint/test_store.py +1 -17
- autocoder/common/file_handler/__init__.py +23 -0
- autocoder/common/file_handler/active_context_handler.py +159 -0
- autocoder/common/file_handler/add_files_handler.py +409 -0
- autocoder/common/file_handler/chat_handler.py +180 -0
- autocoder/common/file_handler/coding_handler.py +401 -0
- autocoder/common/file_handler/commit_handler.py +200 -0
- autocoder/common/file_handler/lib_handler.py +156 -0
- autocoder/common/file_handler/list_files_handler.py +111 -0
- autocoder/common/file_handler/mcp_handler.py +268 -0
- autocoder/common/file_handler/models_handler.py +493 -0
- autocoder/common/file_handler/remove_files_handler.py +172 -0
- autocoder/common/file_monitor/test_file_monitor.py +307 -0
- autocoder/common/git_utils.py +51 -10
- autocoder/common/global_cancel.py +15 -6
- autocoder/common/ignorefiles/test_ignore_file_utils.py +1 -1
- autocoder/common/international/__init__.py +31 -0
- autocoder/common/international/demo_international.py +92 -0
- autocoder/common/international/message_manager.py +157 -0
- autocoder/common/international/messages/__init__.py +56 -0
- autocoder/common/international/messages/async_command_messages.py +507 -0
- autocoder/common/international/messages/auto_coder_messages.py +2208 -0
- autocoder/common/international/messages/chat_auto_coder_messages.py +1547 -0
- autocoder/common/international/messages/command_help_messages.py +986 -0
- autocoder/common/international/messages/conversation_command_messages.py +191 -0
- autocoder/common/international/messages/git_helper_plugin_messages.py +159 -0
- autocoder/common/international/messages/queue_command_messages.py +751 -0
- autocoder/common/international/messages/rules_command_messages.py +77 -0
- autocoder/common/international/messages/sdk_messages.py +1707 -0
- autocoder/common/international/messages/token_helper_plugin_messages.py +361 -0
- autocoder/common/international/messages/tool_display_messages.py +1212 -0
- autocoder/common/international/messages/workflow_exception_messages.py +473 -0
- autocoder/common/international/test_international.py +612 -0
- autocoder/common/linter_core/__init__.py +28 -0
- autocoder/common/linter_core/base_linter.py +61 -0
- autocoder/common/linter_core/config_loader.py +271 -0
- autocoder/common/linter_core/formatters/__init__.py +0 -0
- autocoder/common/linter_core/formatters/base_formatter.py +38 -0
- autocoder/common/linter_core/formatters/raw_formatter.py +17 -0
- autocoder/common/linter_core/linter.py +166 -0
- autocoder/common/linter_core/linter_factory.py +216 -0
- autocoder/common/linter_core/linter_manager.py +333 -0
- autocoder/common/linter_core/linters/__init__.py +9 -0
- autocoder/common/linter_core/linters/java_linter.py +342 -0
- autocoder/common/linter_core/linters/python_linter.py +115 -0
- autocoder/common/linter_core/linters/typescript_linter.py +119 -0
- autocoder/common/linter_core/models/__init__.py +7 -0
- autocoder/common/linter_core/models/lint_result.py +91 -0
- autocoder/common/linter_core/models.py +33 -0
- autocoder/common/linter_core/tests/__init__.py +3 -0
- autocoder/common/linter_core/tests/test_config_loader.py +323 -0
- autocoder/common/linter_core/tests/test_config_loading.py +308 -0
- autocoder/common/linter_core/tests/test_factory_manager.py +234 -0
- autocoder/common/linter_core/tests/test_formatters.py +147 -0
- autocoder/common/linter_core/tests/test_integration.py +317 -0
- autocoder/common/linter_core/tests/test_java_linter.py +496 -0
- autocoder/common/linter_core/tests/test_linters.py +265 -0
- autocoder/common/linter_core/tests/test_models.py +81 -0
- autocoder/common/linter_core/tests/verify_config_loading.py +296 -0
- autocoder/common/linter_core/tests/verify_fixes.py +183 -0
- autocoder/common/llm_friendly_package/__init__.py +31 -0
- autocoder/common/llm_friendly_package/base_manager.py +102 -0
- autocoder/common/llm_friendly_package/docs_manager.py +121 -0
- autocoder/common/llm_friendly_package/library_manager.py +171 -0
- autocoder/common/{llm_friendly_package.py → llm_friendly_package/main_manager.py} +204 -231
- autocoder/common/llm_friendly_package/models.py +40 -0
- autocoder/common/llm_friendly_package/test_llm_friendly_package.py +536 -0
- autocoder/common/llms/__init__.py +15 -0
- autocoder/common/llms/demo_error_handling.py +85 -0
- autocoder/common/llms/factory.py +142 -0
- autocoder/common/llms/manager.py +264 -0
- autocoder/common/llms/pricing.py +121 -0
- autocoder/common/llms/registry.py +288 -0
- autocoder/common/llms/schema.py +77 -0
- autocoder/common/llms/simple_demo.py +45 -0
- autocoder/common/llms/test_quick_model.py +116 -0
- autocoder/common/llms/test_remove_functionality.py +182 -0
- autocoder/common/llms/tests/__init__.py +1 -0
- autocoder/common/llms/tests/test_manager.py +330 -0
- autocoder/common/llms/tests/test_registry.py +364 -0
- autocoder/common/mcp_tools/__init__.py +62 -0
- autocoder/common/{mcp_tools.py → mcp_tools/executor.py} +49 -40
- autocoder/common/{mcp_hub.py → mcp_tools/hub.py} +42 -68
- autocoder/common/{mcp_server_install.py → mcp_tools/installer.py} +16 -28
- autocoder/common/{mcp_server.py → mcp_tools/server.py} +176 -48
- autocoder/common/mcp_tools/test_keyboard_interrupt.py +93 -0
- autocoder/common/mcp_tools/test_mcp_tools.py +391 -0
- autocoder/common/{mcp_server_types.py → mcp_tools/types.py} +121 -48
- autocoder/common/mcp_tools/verify_functionality.py +202 -0
- autocoder/common/model_speed_tester.py +32 -26
- autocoder/common/priority_directory_finder/__init__.py +142 -0
- autocoder/common/priority_directory_finder/examples.py +230 -0
- autocoder/common/priority_directory_finder/finder.py +283 -0
- autocoder/common/priority_directory_finder/models.py +236 -0
- autocoder/common/priority_directory_finder/test_priority_directory_finder.py +431 -0
- autocoder/common/project_scanner/__init__.py +18 -0
- autocoder/common/project_scanner/compat.py +77 -0
- autocoder/common/project_scanner/scanner.py +436 -0
- autocoder/common/project_tracker/__init__.py +27 -0
- autocoder/common/project_tracker/api.py +228 -0
- autocoder/common/project_tracker/demo.py +272 -0
- autocoder/common/project_tracker/tracker.py +487 -0
- autocoder/common/project_tracker/types.py +53 -0
- autocoder/common/pruner/__init__.py +67 -0
- autocoder/common/pruner/agentic_conversation_pruner.py +746 -0
- autocoder/common/{context_pruner.py → pruner/context_pruner.py} +137 -40
- autocoder/common/pruner/conversation_message_ids_api.py +386 -0
- autocoder/common/pruner/conversation_message_ids_manager.py +347 -0
- autocoder/common/pruner/conversation_message_ids_pruner.py +473 -0
- autocoder/common/pruner/conversation_normalizer.py +347 -0
- autocoder/common/{conversation_pruner.py → pruner/conversation_pruner.py} +26 -6
- autocoder/common/pruner/test_agentic_conversation_pruner.py +784 -0
- autocoder/common/pruner/test_context_pruner.py +546 -0
- autocoder/common/pruner/test_conversation_normalizer.py +502 -0
- autocoder/common/pruner/test_tool_content_detector.py +324 -0
- autocoder/common/pruner/tool_content_detector.py +227 -0
- autocoder/common/pruner/tools/__init__.py +18 -0
- autocoder/common/pruner/tools/query_message_ids.py +264 -0
- autocoder/common/pruner/tools/test_agentic_pruning_logic.py +432 -0
- autocoder/common/pruner/tools/test_message_ids_pruning_only.py +192 -0
- autocoder/common/pull_requests/__init__.py +9 -1
- autocoder/common/pull_requests/utils.py +122 -1
- autocoder/common/rag_manager/rag_manager.py +36 -40
- autocoder/common/rulefiles/__init__.py +53 -1
- autocoder/common/rulefiles/api.py +250 -0
- autocoder/common/rulefiles/core/__init__.py +14 -0
- autocoder/common/rulefiles/core/manager.py +241 -0
- autocoder/common/rulefiles/core/selector.py +805 -0
- autocoder/common/rulefiles/models/__init__.py +20 -0
- autocoder/common/rulefiles/models/index.py +16 -0
- autocoder/common/rulefiles/models/init_rule.py +18 -0
- autocoder/common/rulefiles/models/rule_file.py +18 -0
- autocoder/common/rulefiles/models/rule_relevance.py +14 -0
- autocoder/common/rulefiles/models/summary.py +16 -0
- autocoder/common/rulefiles/test_rulefiles.py +776 -0
- autocoder/common/rulefiles/utils/__init__.py +34 -0
- autocoder/common/rulefiles/utils/monitor.py +86 -0
- autocoder/common/rulefiles/utils/parser.py +230 -0
- autocoder/common/save_formatted_log.py +67 -10
- autocoder/common/search_replace.py +8 -1
- autocoder/common/search_replace_patch/__init__.py +24 -0
- autocoder/common/search_replace_patch/base.py +115 -0
- autocoder/common/search_replace_patch/manager.py +248 -0
- autocoder/common/search_replace_patch/patch_replacer.py +304 -0
- autocoder/common/search_replace_patch/similarity_replacer.py +306 -0
- autocoder/common/search_replace_patch/string_replacer.py +181 -0
- autocoder/common/search_replace_patch/tests/__init__.py +3 -0
- autocoder/common/search_replace_patch/tests/run_tests.py +126 -0
- autocoder/common/search_replace_patch/tests/test_base.py +188 -0
- autocoder/common/search_replace_patch/tests/test_empty_line_insert.py +233 -0
- autocoder/common/search_replace_patch/tests/test_integration.py +389 -0
- autocoder/common/search_replace_patch/tests/test_manager.py +351 -0
- autocoder/common/search_replace_patch/tests/test_patch_replacer.py +316 -0
- autocoder/common/search_replace_patch/tests/test_regex_replacer.py +306 -0
- autocoder/common/search_replace_patch/tests/test_similarity_replacer.py +384 -0
- autocoder/common/shell_commands/__init__.py +197 -0
- autocoder/common/shell_commands/background_process_notifier.py +346 -0
- autocoder/common/shell_commands/command_executor.py +1127 -0
- autocoder/common/shell_commands/error_recovery.py +541 -0
- autocoder/common/shell_commands/exceptions.py +120 -0
- autocoder/common/shell_commands/interactive_executor.py +476 -0
- autocoder/common/shell_commands/interactive_pexpect_process.py +623 -0
- autocoder/common/shell_commands/interactive_process.py +744 -0
- autocoder/common/shell_commands/interactive_session_manager.py +1014 -0
- autocoder/common/shell_commands/monitoring.py +529 -0
- autocoder/common/shell_commands/process_cleanup.py +386 -0
- autocoder/common/shell_commands/process_manager.py +606 -0
- autocoder/common/shell_commands/test_interactive_pexpect_process.py +281 -0
- autocoder/common/shell_commands/tests/__init__.py +6 -0
- autocoder/common/shell_commands/tests/conftest.py +118 -0
- autocoder/common/shell_commands/tests/test_background_process_notifier.py +703 -0
- autocoder/common/shell_commands/tests/test_command_executor.py +448 -0
- autocoder/common/shell_commands/tests/test_error_recovery.py +305 -0
- autocoder/common/shell_commands/tests/test_exceptions.py +299 -0
- autocoder/common/shell_commands/tests/test_execute_batch.py +588 -0
- autocoder/common/shell_commands/tests/test_indented_batch_commands.py +244 -0
- autocoder/common/shell_commands/tests/test_integration.py +664 -0
- autocoder/common/shell_commands/tests/test_monitoring.py +546 -0
- autocoder/common/shell_commands/tests/test_performance.py +632 -0
- autocoder/common/shell_commands/tests/test_process_cleanup.py +397 -0
- autocoder/common/shell_commands/tests/test_process_manager.py +606 -0
- autocoder/common/shell_commands/tests/test_timeout_config.py +343 -0
- autocoder/common/shell_commands/tests/test_timeout_manager.py +520 -0
- autocoder/common/shell_commands/timeout_config.py +315 -0
- autocoder/common/shell_commands/timeout_manager.py +352 -0
- autocoder/common/terminal_paste/__init__.py +14 -0
- autocoder/common/terminal_paste/demo.py +145 -0
- autocoder/common/terminal_paste/demo_paste_functionality.py +95 -0
- autocoder/common/terminal_paste/paste_handler.py +200 -0
- autocoder/common/terminal_paste/paste_manager.py +118 -0
- autocoder/common/terminal_paste/tests/__init__.py +1 -0
- autocoder/common/terminal_paste/tests/test_paste_handler.py +182 -0
- autocoder/common/terminal_paste/tests/test_paste_manager.py +126 -0
- autocoder/common/terminal_paste/utils.py +163 -0
- autocoder/common/test_autocoder_args.py +232 -0
- autocoder/common/test_env_manager.py +173 -0
- autocoder/common/test_env_manager_integration.py +159 -0
- autocoder/common/text_similarity/__init__.py +9 -0
- autocoder/common/text_similarity/demo.py +216 -0
- autocoder/common/text_similarity/examples.py +266 -0
- autocoder/common/text_similarity/test_text_similarity.py +306 -0
- autocoder/common/text_similarity/text_similarity.py +194 -0
- autocoder/common/text_similarity/utils.py +125 -0
- autocoder/common/todos/__init__.py +61 -0
- autocoder/common/todos/cache/__init__.py +16 -0
- autocoder/common/todos/cache/base_cache.py +89 -0
- autocoder/common/todos/cache/cache_manager.py +228 -0
- autocoder/common/todos/cache/memory_cache.py +225 -0
- autocoder/common/todos/config.py +155 -0
- autocoder/common/todos/exceptions.py +35 -0
- autocoder/common/todos/get_todo_manager.py +161 -0
- autocoder/common/todos/manager.py +537 -0
- autocoder/common/todos/models.py +239 -0
- autocoder/common/todos/storage/__init__.py +14 -0
- autocoder/common/todos/storage/base_storage.py +76 -0
- autocoder/common/todos/storage/file_storage.py +278 -0
- autocoder/common/tokens/__init__.py +15 -0
- autocoder/common/tokens/counter.py +44 -2
- autocoder/common/tools_manager/__init__.py +17 -0
- autocoder/common/tools_manager/examples.py +162 -0
- autocoder/common/tools_manager/manager.py +385 -0
- autocoder/common/tools_manager/models.py +39 -0
- autocoder/common/tools_manager/test_tools_manager.py +303 -0
- autocoder/common/tools_manager/utils.py +191 -0
- autocoder/common/v2/agent/agentic_callbacks.py +270 -0
- autocoder/common/v2/agent/agentic_edit.py +2729 -2052
- autocoder/common/v2/agent/agentic_edit_change_manager.py +474 -0
- autocoder/common/v2/agent/agentic_edit_tools/__init__.py +43 -2
- autocoder/common/v2/agent/agentic_edit_tools/ac_mod_list_tool_resolver.py +279 -0
- autocoder/common/v2/agent/agentic_edit_tools/ac_mod_read_tool_resolver.py +40 -0
- autocoder/common/v2/agent/agentic_edit_tools/ac_mod_write_tool_resolver.py +52 -0
- autocoder/common/v2/agent/agentic_edit_tools/ask_followup_question_tool_resolver.py +8 -0
- autocoder/common/v2/agent/agentic_edit_tools/background_task_tool_resolver.py +1167 -0
- autocoder/common/v2/agent/agentic_edit_tools/base_tool_resolver.py +2 -2
- autocoder/common/v2/agent/agentic_edit_tools/conversation_message_ids_read_tool_resolver.py +214 -0
- autocoder/common/v2/agent/agentic_edit_tools/conversation_message_ids_write_tool_resolver.py +299 -0
- autocoder/common/v2/agent/agentic_edit_tools/count_tokens_tool_resolver.py +290 -0
- autocoder/common/v2/agent/agentic_edit_tools/execute_command_tool_resolver.py +565 -30
- autocoder/common/v2/agent/agentic_edit_tools/execute_workflow_tool_resolver.py +485 -0
- autocoder/common/v2/agent/agentic_edit_tools/extract_to_text_tool_resolver.py +225 -0
- autocoder/common/v2/agent/agentic_edit_tools/lint_report.py +79 -0
- autocoder/common/v2/agent/agentic_edit_tools/linter_config_models.py +343 -0
- autocoder/common/v2/agent/agentic_edit_tools/linter_enabled_tool_resolver.py +189 -0
- autocoder/common/v2/agent/agentic_edit_tools/list_files_tool_resolver.py +169 -101
- autocoder/common/v2/agent/agentic_edit_tools/load_extra_document_tool_resolver.py +349 -0
- autocoder/common/v2/agent/agentic_edit_tools/read_file_tool_resolver.py +244 -51
- autocoder/common/v2/agent/agentic_edit_tools/replace_in_file_tool_resolver.py +667 -147
- autocoder/common/v2/agent/agentic_edit_tools/run_named_subagents_tool_resolver.py +691 -0
- autocoder/common/v2/agent/agentic_edit_tools/search_files_tool_resolver.py +409 -140
- autocoder/common/v2/agent/agentic_edit_tools/session_interactive_tool_resolver.py +115 -0
- autocoder/common/v2/agent/agentic_edit_tools/session_start_tool_resolver.py +190 -0
- autocoder/common/v2/agent/agentic_edit_tools/session_stop_tool_resolver.py +76 -0
- autocoder/common/v2/agent/agentic_edit_tools/test_write_to_file_tool_resolver.py +209 -194
- autocoder/common/v2/agent/agentic_edit_tools/todo_read_tool_resolver.py +135 -0
- autocoder/common/v2/agent/agentic_edit_tools/todo_write_tool_resolver.py +328 -0
- autocoder/common/v2/agent/agentic_edit_tools/use_mcp_tool_resolver.py +2 -2
- autocoder/common/v2/agent/agentic_edit_tools/web_crawl_tool_resolver.py +557 -0
- autocoder/common/v2/agent/agentic_edit_tools/web_search_tool_resolver.py +600 -0
- autocoder/common/v2/agent/agentic_edit_tools/write_to_file_tool_resolver.py +56 -121
- autocoder/common/v2/agent/agentic_edit_types.py +386 -10
- autocoder/common/v2/agent/runner/__init__.py +31 -0
- autocoder/common/v2/agent/runner/base_runner.py +92 -0
- autocoder/common/v2/agent/runner/file_based_event_runner.py +217 -0
- autocoder/common/v2/agent/runner/sdk_runner.py +182 -0
- autocoder/common/v2/agent/runner/terminal_runner.py +396 -0
- autocoder/common/v2/agent/runner/tool_display.py +589 -0
- autocoder/common/v2/agent/test_agentic_callbacks.py +265 -0
- autocoder/common/v2/agent/test_agentic_edit.py +194 -0
- autocoder/common/v2/agent/tool_caller/__init__.py +24 -0
- autocoder/common/v2/agent/tool_caller/default_tool_resolver_map.py +135 -0
- autocoder/common/v2/agent/tool_caller/integration_test.py +172 -0
- autocoder/common/v2/agent/tool_caller/plugins/__init__.py +14 -0
- autocoder/common/v2/agent/tool_caller/plugins/base_plugin.py +126 -0
- autocoder/common/v2/agent/tool_caller/plugins/examples/__init__.py +13 -0
- autocoder/common/v2/agent/tool_caller/plugins/examples/logging_plugin.py +164 -0
- autocoder/common/v2/agent/tool_caller/plugins/examples/security_filter_plugin.py +198 -0
- autocoder/common/v2/agent/tool_caller/plugins/plugin_interface.py +141 -0
- autocoder/common/v2/agent/tool_caller/test_tool_caller.py +278 -0
- autocoder/common/v2/agent/tool_caller/tool_call_plugin_manager.py +331 -0
- autocoder/common/v2/agent/tool_caller/tool_caller.py +337 -0
- autocoder/common/v2/agent/tool_caller/usage_example.py +193 -0
- autocoder/common/v2/code_agentic_editblock_manager.py +4 -4
- autocoder/common/v2/code_auto_generate.py +136 -78
- autocoder/common/v2/code_auto_generate_diff.py +135 -79
- autocoder/common/v2/code_auto_generate_editblock.py +174 -99
- autocoder/common/v2/code_auto_generate_strict_diff.py +151 -71
- autocoder/common/v2/code_auto_merge.py +1 -1
- autocoder/common/v2/code_auto_merge_editblock.py +13 -1
- autocoder/common/v2/code_diff_manager.py +3 -3
- autocoder/common/v2/code_editblock_manager.py +4 -14
- autocoder/common/v2/code_manager.py +1 -1
- autocoder/common/v2/code_strict_diff_manager.py +2 -2
- autocoder/common/wrap_llm_hint/__init__.py +10 -0
- autocoder/common/wrap_llm_hint/test_wrap_llm_hint.py +1067 -0
- autocoder/common/wrap_llm_hint/utils.py +432 -0
- autocoder/common/wrap_llm_hint/wrap_llm_hint.py +323 -0
- autocoder/completer/__init__.py +8 -0
- autocoder/completer/command_completer_v2.py +1051 -0
- autocoder/default_project/__init__.py +501 -0
- autocoder/dispacher/__init__.py +4 -12
- autocoder/dispacher/actions/action.py +165 -7
- autocoder/dispacher/actions/plugins/action_regex_project.py +2 -2
- autocoder/index/entry.py +117 -125
- autocoder/{agent → index/filter}/agentic_filter.py +323 -334
- autocoder/index/filter/normal_filter.py +5 -11
- autocoder/index/filter/quick_filter.py +1 -1
- autocoder/index/index.py +36 -9
- autocoder/index/tests/__init__.py +1 -0
- autocoder/index/tests/run_tests.py +195 -0
- autocoder/index/tests/test_entry.py +303 -0
- autocoder/index/tests/test_index_manager.py +314 -0
- autocoder/index/tests/test_module_integration.py +300 -0
- autocoder/index/tests/test_symbols_utils.py +183 -0
- autocoder/inner/__init__.py +4 -0
- autocoder/inner/agentic.py +932 -0
- autocoder/inner/async_command_handler.py +992 -0
- autocoder/inner/conversation_command_handlers.py +623 -0
- autocoder/inner/merge_command_handler.py +213 -0
- autocoder/inner/queue_command_handler.py +684 -0
- autocoder/models.py +95 -266
- autocoder/plugins/git_helper_plugin.py +31 -29
- autocoder/plugins/token_helper_plugin.py +156 -37
- autocoder/pyproject/__init__.py +32 -29
- autocoder/rag/agentic_rag.py +215 -75
- autocoder/rag/cache/simple_cache.py +1 -2
- autocoder/rag/loaders/image_loader.py +1 -1
- autocoder/rag/long_context_rag.py +42 -26
- autocoder/rag/qa_conversation_strategy.py +1 -1
- autocoder/rag/terminal/__init__.py +17 -0
- autocoder/rag/terminal/args.py +581 -0
- autocoder/rag/terminal/bootstrap.py +61 -0
- autocoder/rag/terminal/command_handlers.py +653 -0
- autocoder/rag/terminal/formatters/__init__.py +20 -0
- autocoder/rag/terminal/formatters/base.py +70 -0
- autocoder/rag/terminal/formatters/json_format.py +66 -0
- autocoder/rag/terminal/formatters/stream_json.py +95 -0
- autocoder/rag/terminal/formatters/text.py +28 -0
- autocoder/rag/terminal/init.py +120 -0
- autocoder/rag/terminal/utils.py +106 -0
- autocoder/rag/test_agentic_rag.py +389 -0
- autocoder/rag/test_doc_filter.py +3 -3
- autocoder/rag/test_long_context_rag.py +1 -1
- autocoder/rag/test_token_limiter.py +517 -10
- autocoder/rag/token_counter.py +3 -0
- autocoder/rag/token_limiter.py +19 -15
- autocoder/rag/tools/__init__.py +26 -2
- autocoder/rag/tools/bochaai_example.py +343 -0
- autocoder/rag/tools/bochaai_sdk.py +541 -0
- autocoder/rag/tools/metaso_example.py +268 -0
- autocoder/rag/tools/metaso_sdk.py +417 -0
- autocoder/rag/tools/recall_tool.py +28 -7
- autocoder/rag/tools/run_integration_tests.py +204 -0
- autocoder/rag/tools/test_all_providers.py +318 -0
- autocoder/rag/tools/test_bochaai_integration.py +482 -0
- autocoder/rag/tools/test_final_integration.py +215 -0
- autocoder/rag/tools/test_metaso_integration.py +424 -0
- autocoder/rag/tools/test_metaso_real.py +171 -0
- autocoder/rag/tools/test_web_crawl_tool.py +639 -0
- autocoder/rag/tools/test_web_search_tool.py +509 -0
- autocoder/rag/tools/todo_read_tool.py +202 -0
- autocoder/rag/tools/todo_write_tool.py +412 -0
- autocoder/rag/tools/web_crawl_tool.py +634 -0
- autocoder/rag/tools/web_search_tool.py +558 -0
- autocoder/rag/tools/web_tools_example.py +119 -0
- autocoder/rag/types.py +16 -0
- autocoder/rag/variable_holder.py +4 -2
- autocoder/rags.py +86 -79
- autocoder/regexproject/__init__.py +23 -21
- autocoder/run_context.py +9 -0
- autocoder/sdk/__init__.py +50 -161
- autocoder/sdk/api.py +370 -0
- autocoder/sdk/async_runner/__init__.py +26 -0
- autocoder/sdk/async_runner/async_executor.py +650 -0
- autocoder/sdk/async_runner/async_handler.py +356 -0
- autocoder/sdk/async_runner/markdown_processor.py +595 -0
- autocoder/sdk/async_runner/task_metadata.py +284 -0
- autocoder/sdk/async_runner/worktree_manager.py +438 -0
- autocoder/sdk/cli/__init__.py +2 -5
- autocoder/sdk/cli/formatters.py +28 -204
- autocoder/sdk/cli/handlers.py +77 -44
- autocoder/sdk/cli/main.py +158 -170
- autocoder/sdk/cli/options.py +95 -22
- autocoder/sdk/constants.py +139 -51
- autocoder/sdk/core/auto_coder_core.py +484 -267
- autocoder/sdk/core/bridge.py +298 -118
- autocoder/sdk/exceptions.py +18 -12
- autocoder/sdk/formatters/__init__.py +19 -0
- autocoder/sdk/formatters/input.py +64 -0
- autocoder/sdk/formatters/output.py +247 -0
- autocoder/sdk/formatters/stream.py +54 -0
- autocoder/sdk/models/__init__.py +6 -5
- autocoder/sdk/models/options.py +55 -18
- autocoder/sdk/utils/formatters.py +27 -195
- autocoder/suffixproject/__init__.py +28 -25
- autocoder/terminal/__init__.py +14 -0
- autocoder/terminal/app.py +454 -0
- autocoder/terminal/args.py +32 -0
- autocoder/terminal/bootstrap.py +178 -0
- autocoder/terminal/command_processor.py +521 -0
- autocoder/terminal/command_registry.py +57 -0
- autocoder/terminal/help.py +97 -0
- autocoder/terminal/tasks/__init__.py +5 -0
- autocoder/terminal/tasks/background.py +77 -0
- autocoder/terminal/tasks/task_event.py +70 -0
- autocoder/terminal/ui/__init__.py +13 -0
- autocoder/terminal/ui/completer.py +268 -0
- autocoder/terminal/ui/keybindings.py +75 -0
- autocoder/terminal/ui/session.py +41 -0
- autocoder/terminal/ui/toolbar.py +64 -0
- autocoder/terminal/utils/__init__.py +13 -0
- autocoder/terminal/utils/errors.py +18 -0
- autocoder/terminal/utils/paths.py +19 -0
- autocoder/terminal/utils/shell.py +43 -0
- autocoder/terminal_v3/__init__.py +10 -0
- autocoder/terminal_v3/app.py +201 -0
- autocoder/terminal_v3/handlers/__init__.py +5 -0
- autocoder/terminal_v3/handlers/command_handler.py +131 -0
- autocoder/terminal_v3/models/__init__.py +6 -0
- autocoder/terminal_v3/models/conversation_buffer.py +214 -0
- autocoder/terminal_v3/models/message.py +50 -0
- autocoder/terminal_v3/models/tool_display.py +247 -0
- autocoder/terminal_v3/ui/__init__.py +7 -0
- autocoder/terminal_v3/ui/keybindings.py +56 -0
- autocoder/terminal_v3/ui/layout.py +141 -0
- autocoder/terminal_v3/ui/styles.py +43 -0
- autocoder/tsproject/__init__.py +23 -23
- autocoder/utils/auto_coder_utils/chat_stream_out.py +1 -1
- autocoder/utils/llms.py +88 -80
- autocoder/utils/math_utils.py +101 -0
- autocoder/utils/model_provider_selector.py +16 -4
- autocoder/utils/operate_config_api.py +33 -5
- autocoder/utils/thread_utils.py +2 -2
- autocoder/version.py +4 -2
- autocoder/workflow_agents/__init__.py +84 -0
- autocoder/workflow_agents/agent.py +143 -0
- autocoder/workflow_agents/exceptions.py +573 -0
- autocoder/workflow_agents/executor.py +489 -0
- autocoder/workflow_agents/loader.py +737 -0
- autocoder/workflow_agents/runner.py +267 -0
- autocoder/workflow_agents/types.py +172 -0
- autocoder/workflow_agents/utils.py +434 -0
- autocoder/workflow_agents/workflow_manager.py +211 -0
- auto_coder-0.1.400.dist-info/METADATA +0 -396
- auto_coder-0.1.400.dist-info/RECORD +0 -425
- auto_coder-0.1.400.dist-info/licenses/LICENSE +0 -201
- autocoder/auto_coder_server.py +0 -672
- autocoder/benchmark.py +0 -138
- autocoder/common/ac_style_command_parser/example.py +0 -7
- autocoder/common/cleaner.py +0 -31
- autocoder/common/command_completer_v2.py +0 -615
- autocoder/common/directory_cache/__init__.py +0 -1
- autocoder/common/directory_cache/cache.py +0 -192
- autocoder/common/directory_cache/test_cache.py +0 -190
- autocoder/common/file_checkpoint/examples.py +0 -217
- autocoder/common/llm_friendly_package_example.py +0 -138
- autocoder/common/llm_friendly_package_test.py +0 -63
- autocoder/common/pull_requests/test_module.py +0 -1
- autocoder/common/rulefiles/autocoderrules_utils.py +0 -484
- autocoder/common/text.py +0 -30
- autocoder/common/v2/agent/agentic_edit_tools/list_package_info_tool_resolver.py +0 -42
- autocoder/common/v2/agent/agentic_edit_tools/test_execute_command_tool_resolver.py +0 -70
- autocoder/common/v2/agent/agentic_edit_tools/test_search_files_tool_resolver.py +0 -163
- autocoder/common/v2/agent/agentic_tool_display.py +0 -183
- autocoder/plugins/dynamic_completion_example.py +0 -148
- autocoder/plugins/sample_plugin.py +0 -160
- autocoder/sdk/cli/__main__.py +0 -26
- autocoder/sdk/cli/completion_wrapper.py +0 -38
- autocoder/sdk/cli/install_completion.py +0 -301
- autocoder/sdk/models/messages.py +0 -209
- autocoder/sdk/session/__init__.py +0 -32
- autocoder/sdk/session/session.py +0 -106
- autocoder/sdk/session/session_manager.py +0 -56
- {auto_coder-0.1.400.dist-info → auto_coder-2.0.0.dist-info}/top_level.txt +0 -0
- /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.
|
|
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.
|
|
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.
|
|
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] #
|
|
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.
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
Python
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
126
|
+
Script Type: {{ shell_type }}
|
|
152
127
|
{%- endif %}
|
|
153
128
|
|
|
154
129
|
{%- if env_info.conda_env %}
|
|
155
|
-
Conda
|
|
130
|
+
Conda Environment: {{ env_info.conda_env }}
|
|
156
131
|
{%- endif %}
|
|
157
132
|
{%- if env_info.virtualenv %}
|
|
158
|
-
|
|
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
|
-
|
|
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
|
-
|
|
181
|
-
|
|
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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
255
|
-
2.
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
3.
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
4.
|
|
263
|
-
6.
|
|
264
|
-
|
|
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
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
349
|
+
<description>Execute specified shell scripts. Mainly used for compilation, running, testing, and other tasks.</description>
|
|
360
350
|
<usage>
|
|
361
|
-
|
|
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
|
-
-
|
|
371
|
-
-
|
|
372
|
-
-
|
|
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
|
|
368
|
+
<description>list_files views all files in a specific directory</description>
|
|
416
369
|
<usage>
|
|
417
|
-
|
|
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
|
|
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
|
-
-
|
|
437
|
-
-
|
|
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
|
-
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
-
|
|
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
|
-
|
|
461
|
-
|
|
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
|
-
|
|
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
|
|
423
|
+
<description>Search files based on keywords in filename.</description>
|
|
471
424
|
<usage>
|
|
472
|
-
|
|
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
|
|
439
|
+
<description>Search files based on keywords in file content.</description>
|
|
487
440
|
<usage>
|
|
488
|
-
|
|
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
|
-
-
|
|
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
|
|
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):
|
|
510
|
-
4. after_size (int):
|
|
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
|
-
-
|
|
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
|
|
486
|
+
<description>Output the final required result</description>
|
|
534
487
|
<usage>
|
|
535
|
-
|
|
536
|
-
response:
|
|
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
|
|
510
|
+
<description>Calculate the token count of specified file.</description>
|
|
558
511
|
<usage>
|
|
559
|
-
|
|
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
|
-
-
|
|
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
|
|
525
|
+
<description>Calculate the token count of specified string.</description>
|
|
573
526
|
<usage>
|
|
574
|
-
|
|
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
|
-
-
|
|
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
|
|
540
|
+
<description>Find the file path where the specified symbol is defined.</description>
|
|
588
541
|
<usage>
|
|
589
|
-
|
|
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
|
|
557
|
+
<description>Execute MCP server</description>
|
|
605
558
|
<usage>
|
|
606
|
-
|
|
559
|
+
This function accepts one parameter query, which is the MCP server query string to execute.
|
|
607
560
|
|
|
608
|
-
|
|
609
|
-
|
|
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
|
-
#
|
|
577
|
+
# Get prompt content
|
|
625
578
|
prompt = self._analyze.prompt(request)
|
|
626
579
|
|
|
627
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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(
|
|
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.
|
|
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(
|
|
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(
|
|
659
|
+
llm_utils.get_model_info(
|
|
660
|
+
model_name, self.args.product_mode) or {}
|
|
704
661
|
)
|
|
705
|
-
input_price = model_info.get(
|
|
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
|
-
#
|
|
747
|
-
|
|
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"
|
|
775
|
-
conversations.append(
|
|
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
|
-
#
|
|
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}[
|
|
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(
|
|
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
|
|
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(
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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,24 +828,25 @@ 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
|
-
#
|
|
835
|
+
# Count token numbers
|
|
850
836
|
total_tokens = count_tokens(
|
|
851
837
|
json.dumps(conversations, ensure_ascii=False)
|
|
852
838
|
)
|
|
853
839
|
|
|
854
|
-
#
|
|
855
|
-
|
|
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=
|
|
847
|
+
safe_zone=parsed_safe_zone_tokens,
|
|
861
848
|
)
|
|
862
|
-
from autocoder.common.conversation_pruner import ConversationPruner
|
|
849
|
+
from autocoder.common.pruner.conversation_pruner import ConversationPruner
|
|
863
850
|
|
|
864
851
|
pruner = ConversationPruner(self.args, self.llm)
|
|
865
852
|
conversations = pruner.prune_conversations(conversations)
|
|
@@ -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(
|
|
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:
|