auto-coder 0.1.247__tar.gz → 0.1.249__tar.gz

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 (163) hide show
  1. {auto_coder-0.1.247 → auto_coder-0.1.249}/PKG-INFO +1 -1
  2. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/auto_coder.egg-info/PKG-INFO +1 -1
  3. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/auto_coder.egg-info/SOURCES.txt +1 -0
  4. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/auto_coder.py +1 -9
  5. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/chat_auto_coder.py +7 -63
  6. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/chat_auto_coder_lang.py +2 -0
  7. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/__init__.py +1 -0
  8. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/auto_coder_lang.py +7 -1
  9. auto_coder-0.1.249/src/autocoder/common/command_generator.py +62 -0
  10. auto_coder-0.1.249/src/autocoder/common/shells.py +225 -0
  11. auto_coder-0.1.249/src/autocoder/data/tokenizer.json +263174 -0
  12. auto_coder-0.1.249/src/autocoder/index/filter/quick_filter.py +230 -0
  13. auto_coder-0.1.249/src/autocoder/version.py +1 -0
  14. auto_coder-0.1.247/src/autocoder/common/command_generator.py +0 -45
  15. auto_coder-0.1.247/src/autocoder/data/tokenizer.json +0 -199865
  16. auto_coder-0.1.247/src/autocoder/index/filter/quick_filter.py +0 -135
  17. auto_coder-0.1.247/src/autocoder/version.py +0 -1
  18. {auto_coder-0.1.247 → auto_coder-0.1.249}/LICENSE +0 -0
  19. {auto_coder-0.1.247 → auto_coder-0.1.249}/README.md +0 -0
  20. {auto_coder-0.1.247 → auto_coder-0.1.249}/setup.cfg +0 -0
  21. {auto_coder-0.1.247 → auto_coder-0.1.249}/setup.py +0 -0
  22. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/auto_coder.egg-info/dependency_links.txt +0 -0
  23. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/auto_coder.egg-info/entry_points.txt +0 -0
  24. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/auto_coder.egg-info/requires.txt +0 -0
  25. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/auto_coder.egg-info/top_level.txt +0 -0
  26. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/__init__.py +0 -0
  27. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/agent/__init__.py +0 -0
  28. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/agent/auto_demand_organizer.py +0 -0
  29. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/agent/auto_filegroup.py +0 -0
  30. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/agent/auto_guess_query.py +0 -0
  31. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/agent/auto_review_commit.py +0 -0
  32. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/agent/auto_tool.py +0 -0
  33. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/agent/coder.py +0 -0
  34. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/agent/designer.py +0 -0
  35. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/agent/planner.py +0 -0
  36. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/agent/project_reader.py +0 -0
  37. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/auto_coder_rag.py +0 -0
  38. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/auto_coder_rag_client_mcp.py +0 -0
  39. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/auto_coder_rag_mcp.py +0 -0
  40. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/auto_coder_server.py +0 -0
  41. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/benchmark.py +0 -0
  42. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/chat/__init__.py +0 -0
  43. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/command_args.py +0 -0
  44. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/JupyterClient.py +0 -0
  45. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/ShellClient.py +0 -0
  46. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/anything2images.py +0 -0
  47. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/anything2img.py +0 -0
  48. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/audio.py +0 -0
  49. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/buildin_tokenizer.py +0 -0
  50. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/chunk_validation.py +0 -0
  51. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/cleaner.py +0 -0
  52. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/code_auto_execute.py +0 -0
  53. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/code_auto_generate.py +0 -0
  54. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/code_auto_generate_diff.py +0 -0
  55. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/code_auto_generate_editblock.py +0 -0
  56. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/code_auto_generate_strict_diff.py +0 -0
  57. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/code_auto_merge.py +0 -0
  58. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/code_auto_merge_diff.py +0 -0
  59. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/code_auto_merge_editblock.py +0 -0
  60. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/code_auto_merge_strict_diff.py +0 -0
  61. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/code_modification_ranker.py +0 -0
  62. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/command_completer.py +0 -0
  63. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/command_templates.py +0 -0
  64. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/const.py +0 -0
  65. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/files.py +0 -0
  66. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/git_utils.py +0 -0
  67. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/image_to_page.py +0 -0
  68. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/interpreter.py +0 -0
  69. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/llm_rerank.py +0 -0
  70. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/mcp_hub.py +0 -0
  71. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/mcp_server.py +0 -0
  72. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/mcp_servers/__init__.py +0 -0
  73. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/mcp_servers/mcp_server_perplexity.py +0 -0
  74. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/mcp_tools.py +0 -0
  75. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/memory_manager.py +0 -0
  76. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/printer.py +0 -0
  77. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/recall_validation.py +0 -0
  78. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/screenshots.py +0 -0
  79. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/search.py +0 -0
  80. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/search_replace.py +0 -0
  81. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/sys_prompt.py +0 -0
  82. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/text.py +0 -0
  83. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/types.py +0 -0
  84. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/common/utils_code_auto_generate.py +0 -0
  85. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/db/__init__.py +0 -0
  86. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/db/store.py +0 -0
  87. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/dispacher/__init__.py +0 -0
  88. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/dispacher/actions/__init__.py +0 -0
  89. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/dispacher/actions/action.py +0 -0
  90. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/dispacher/actions/copilot.py +0 -0
  91. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/dispacher/actions/plugins/__init__.py +0 -0
  92. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/dispacher/actions/plugins/action_regex_project.py +0 -0
  93. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/dispacher/actions/plugins/action_translate.py +0 -0
  94. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/index/__init__.py +0 -0
  95. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/index/entry.py +0 -0
  96. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/index/filter/__init__.py +0 -0
  97. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/index/filter/normal_filter.py +0 -0
  98. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/index/for_command.py +0 -0
  99. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/index/index.py +0 -0
  100. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/index/symbols_utils.py +0 -0
  101. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/index/types.py +0 -0
  102. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/lang.py +0 -0
  103. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/models.py +0 -0
  104. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/pyproject/__init__.py +0 -0
  105. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/__init__.py +0 -0
  106. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/api_server.py +0 -0
  107. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/cache/__init__.py +0 -0
  108. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/cache/base_cache.py +0 -0
  109. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/cache/byzer_storage_cache.py +0 -0
  110. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/cache/file_monitor_cache.py +0 -0
  111. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/cache/simple_cache.py +0 -0
  112. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/doc_filter.py +0 -0
  113. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/document_retriever.py +0 -0
  114. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/llm_wrapper.py +0 -0
  115. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/loaders/__init__.py +0 -0
  116. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/loaders/docx_loader.py +0 -0
  117. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/loaders/excel_loader.py +0 -0
  118. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/loaders/pdf_loader.py +0 -0
  119. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/loaders/ppt_loader.py +0 -0
  120. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/long_context_rag.py +0 -0
  121. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/rag_config.py +0 -0
  122. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/rag_entry.py +0 -0
  123. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/raw_rag.py +0 -0
  124. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/relevant_utils.py +0 -0
  125. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/simple_directory_reader.py +0 -0
  126. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/simple_rag.py +0 -0
  127. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/stream_event/__init__.py +0 -0
  128. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/stream_event/event_writer.py +0 -0
  129. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/stream_event/types.py +0 -0
  130. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/token_checker.py +0 -0
  131. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/token_counter.py +0 -0
  132. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/token_limiter.py +0 -0
  133. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/types.py +0 -0
  134. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/utils.py +0 -0
  135. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/rag/variable_holder.py +0 -0
  136. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/regexproject/__init__.py +0 -0
  137. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/suffixproject/__init__.py +0 -0
  138. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/tsproject/__init__.py +0 -0
  139. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/__init__.py +0 -0
  140. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/_markitdown.py +0 -0
  141. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/auto_coder_utils/__init__.py +0 -0
  142. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/auto_coder_utils/chat_stream_out.py +0 -0
  143. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/chat_auto_coder_utils/__init__.py +0 -0
  144. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/conversation_store.py +0 -0
  145. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/llm_client_interceptors.py +0 -0
  146. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/llms.py +0 -0
  147. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/log_capture.py +0 -0
  148. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/multi_turn.py +0 -0
  149. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/operate_config_api.py +0 -0
  150. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/print_table.py +0 -0
  151. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/queue_communicate.py +0 -0
  152. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/request_event_queue.py +0 -0
  153. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/request_queue.py +0 -0
  154. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/rest.py +0 -0
  155. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/tests.py +0 -0
  156. {auto_coder-0.1.247 → auto_coder-0.1.249}/src/autocoder/utils/types.py +0 -0
  157. {auto_coder-0.1.247 → auto_coder-0.1.249}/tests/test_action_regex_project.py +0 -0
  158. {auto_coder-0.1.247 → auto_coder-0.1.249}/tests/test_chat_auto_coder.py +0 -0
  159. {auto_coder-0.1.247 → auto_coder-0.1.249}/tests/test_code_auto_merge_editblock.py +0 -0
  160. {auto_coder-0.1.247 → auto_coder-0.1.249}/tests/test_command_completer.py +0 -0
  161. {auto_coder-0.1.247 → auto_coder-0.1.249}/tests/test_planner.py +0 -0
  162. {auto_coder-0.1.247 → auto_coder-0.1.249}/tests/test_queue_communicate.py +0 -0
  163. {auto_coder-0.1.247 → auto_coder-0.1.249}/tests/test_symbols_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: auto-coder
3
- Version: 0.1.247
3
+ Version: 0.1.249
4
4
  Summary: AutoCoder: AutoCoder
5
5
  Author: allwefantasy
6
6
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: auto-coder
3
- Version: 0.1.247
3
+ Version: 0.1.249
4
4
  Summary: AutoCoder: AutoCoder
5
5
  Author: allwefantasy
6
6
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
@@ -69,6 +69,7 @@ src/autocoder/common/recall_validation.py
69
69
  src/autocoder/common/screenshots.py
70
70
  src/autocoder/common/search.py
71
71
  src/autocoder/common/search_replace.py
72
+ src/autocoder/common/shells.py
72
73
  src/autocoder/common/sys_prompt.py
73
74
  src/autocoder/common/text.py
74
75
  src/autocoder/common/types.py
@@ -1002,15 +1002,7 @@ def main(input_args: Optional[List[str]] = None):
1002
1002
  elif raw_args.agent_command == "generate_command":
1003
1003
  from autocoder.common.command_generator import generate_shell_script
1004
1004
 
1005
- console = Console()
1006
-
1007
- console.print(
1008
- Panel(
1009
- f"Generating shell script from user input {args.query}...",
1010
- title="Command Generator",
1011
- border_style="green",
1012
- )
1013
- )
1005
+ console = Console()
1014
1006
 
1015
1007
  shell_script = generate_shell_script(args.query, llm)
1016
1008
 
@@ -2385,64 +2385,8 @@ def list_files():
2385
2385
 
2386
2386
  @run_in_raw_thread()
2387
2387
  def execute_shell_command(command: str):
2388
- console = Console()
2389
- try:
2390
- # Use shell=True to support shell mode
2391
- process = subprocess.Popen(
2392
- command,
2393
- stdout=subprocess.PIPE,
2394
- stderr=subprocess.PIPE,
2395
- text=True,
2396
- bufsize=1,
2397
- universal_newlines=True,
2398
- shell=True,
2399
- )
2400
-
2401
- output = []
2402
- with Live(console=console, refresh_per_second=4) as live:
2403
- while True:
2404
- output_line = process.stdout.readline()
2405
- error_line = process.stderr.readline()
2406
-
2407
- if output_line:
2408
- output.append(output_line.strip())
2409
- live.update(
2410
- Panel(
2411
- Text("\n".join(output[-20:])),
2412
- title="Shell Output",
2413
- border_style="green",
2414
- )
2415
- )
2416
- if error_line:
2417
- output.append(f"ERROR: {error_line.strip()}")
2418
- live.update(
2419
- Panel(
2420
- Text("\n".join(output[-20:])),
2421
- title="Shell Output",
2422
- border_style="red",
2423
- )
2424
- )
2425
-
2426
- if (
2427
- output_line == ""
2428
- and error_line == ""
2429
- and process.poll() is not None
2430
- ):
2431
- break
2432
-
2433
- if process.returncode != 0:
2434
- console.print(
2435
- f"[bold red]Command failed with return code {process.returncode}[/bold red]"
2436
- )
2437
-
2438
- except FileNotFoundError:
2439
- console.print(
2440
- f"[bold red]Command not found:[/bold red] [yellow]{command}[/yellow]"
2441
- )
2442
- except subprocess.SubprocessError as e:
2443
- console.print(
2444
- f"[bold red]Error executing command:[/bold red] [yellow]{str(e)}[/yellow]"
2445
- )
2388
+ from autocoder.common.shells import execute_shell_command as shell_exec
2389
+ shell_exec(command)
2446
2390
 
2447
2391
 
2448
2392
  def lib_command(args: List[str]):
@@ -2723,13 +2667,13 @@ def main():
2723
2667
  if temp_user_input.startswith('/'):
2724
2668
  user_input = temp_user_input
2725
2669
 
2726
- if (
2727
- memory["mode"] == "auto_detect"
2670
+ if (
2671
+ memory["mode"] == "auto_detect"
2728
2672
  and user_input
2729
2673
  and not user_input.startswith("/")
2730
2674
  ):
2731
2675
  shell_script = generate_shell_command(user_input)
2732
- if confirm("Do you want to execute this script?"):
2676
+ if confirm(get_message("confirm_execute")):
2733
2677
  execute_shell_command(shell_script)
2734
2678
  else:
2735
2679
  continue
@@ -2850,8 +2794,8 @@ def main():
2850
2794
  command = user_input
2851
2795
  if user_input.startswith("/shell"):
2852
2796
  command = user_input[len("/shell"):].strip()
2853
- if not command:
2854
- print("Please enter a shell command to execute.")
2797
+ if not command:
2798
+ print("Please enter a shell command to execute.")
2855
2799
  else:
2856
2800
  execute_shell_command(command)
2857
2801
 
@@ -116,6 +116,7 @@ MESSAGES = {
116
116
  "commit_generating": "{{ model_name }} Generating commit message...",
117
117
  "commit_message": "{{ model_name }} Generated commit message: {{ message }}",
118
118
  "commit_failed": "{{ model_name }} Failed to generate commit message: {{ error }}",
119
+ "confirm_execute": "Do you want to execute this script?",
119
120
  },
120
121
  "zh": {
121
122
  "commit_generating": "{{ model_name }} 正在生成提交信息...",
@@ -231,6 +232,7 @@ MESSAGES = {
231
232
  "remove_files_none": "没有文件被移除。",
232
233
  "files_removed": "移除的文件",
233
234
  "models_api_key_empty": "警告: {{name}} API key 为空。请设置一个有效的 API key。",
235
+ "confirm_execute": "是否执行此脚本?",
234
236
  }
235
237
  }
236
238
 
@@ -260,6 +260,7 @@ class AutoCoderArgs(pydantic.BaseModel):
260
260
 
261
261
  index_model: Optional[str] = ""
262
262
  index_filter_model: Optional[str] = ""
263
+ index_filter_model_max_input_length: Optional[int] = 50*1024
263
264
  index_model_max_length: Optional[int] = 0
264
265
  index_model_max_input_length: Optional[int] = 0
265
266
  index_model_anti_quota_limit: Optional[int] = 0
@@ -4,6 +4,7 @@ from byzerllm.utils import format_str_jinja2
4
4
  MESSAGES = {
5
5
  "en": {
6
6
  "model_not_found": "Model {{model_name}} not found",
7
+ "generating_shell_script": "Generating Shell Script",
7
8
  "new_session_started": "New session started. Previous chat history has been archived.",
8
9
  "memory_save_success": "✅ Saved to your memory",
9
10
  "file_decode_error": "Failed to decode file: {{file_path}}. Tried encodings: {{encodings}}",
@@ -83,10 +84,13 @@ MESSAGES = {
83
84
  "unmerged_replace_block": "Replace Block:",
84
85
  "unmerged_blocks_total": "Total unmerged blocks: {{num_blocks}}",
85
86
  "git_init_required": "⚠️ auto_merge only applies to git repositories.\n\nPlease try using git init in the source directory:\n\n```shell\ncd {{ source_dir }}\ngit init.\n```\n\nThen run auto - coder again.\nError: {{ error }}",
86
- "quick_filter_reason": "Auto get(quick_filter mode)"
87
+ "quick_filter_reason": "Auto get(quick_filter mode)",
88
+ "quick_filter_too_long": "⚠️ index file is too large ({{ tokens_len }}/{{ max_tokens }}). The query will be split into {{ split_size }} chunks.",
89
+ "quick_filter_tokens_len": "📊 Current index size: {{ tokens_len }} tokens"
87
90
  },
88
91
  "zh": {
89
92
  "model_not_found": "未找到模型: {{model_name}}",
93
+ "generating_shell_script": "正在生成 Shell 脚本",
90
94
  "new_session_started": "新会话已开始。之前的聊天历史已存档。",
91
95
  "memory_save_success": "✅ 已保存到您的记忆中",
92
96
  "file_decode_error": "无法解码文件: {{file_path}}。尝试的编码: {{encodings}}",
@@ -152,6 +156,8 @@ MESSAGES = {
152
156
  "unmerged_blocks_total": "未合并代码块数量: {{num_blocks}}",
153
157
  "git_init_required": "⚠️ auto_merge 仅适用于 git 仓库。\n\n请尝试在源目录中使用 git init:\n\n```shell\ncd {{ source_dir }}\ngit init.\n```\n\n然后再次运行 auto-coder。\n错误: {{ error }}",
154
158
  "quick_filter_reason": "自动获取(quick_filter模式)",
159
+ "quick_filter_too_long": "⚠️ 索引文件过大 ({{ tokens_len }}/{{ max_tokens }})。查询将被分成 {{ split_size }} 个部分执行。",
160
+ "quick_filter_tokens_len": "📊 当前索引大小: {{ tokens_len }} tokens",
155
161
  "upsert_file": "✅ 更新文件: {{ file_path }}",
156
162
  "files_merged": "✅ 成功合并了 {{ total }} 个文件到项目中。",
157
163
  "merge_failed": "❌ 合并文件 {{ path }} 失败: {{ error }}",
@@ -0,0 +1,62 @@
1
+ import byzerllm
2
+ from byzerllm.utils.client import code_utils
3
+ from autocoder.utils.auto_coder_utils.chat_stream_out import stream_out
4
+ from autocoder.common import detect_env
5
+ from autocoder.common import shells
6
+ from autocoder.common.printer import Printer
7
+
8
+ @byzerllm.prompt()
9
+ def _generate_shell_script(user_input: str) -> str:
10
+ """
11
+ 环境信息如下:
12
+
13
+ 操作系统: {{ env_info.os_name }} {{ env_info.os_version }}
14
+ Python版本: {{ env_info.python_version }}
15
+ 终端类型: {{ env_info.shell_type }}
16
+ 终端编码: {{ env_info.shell_encoding }}
17
+ {%- if env_info.conda_env %}
18
+ Conda环境: {{ env_info.conda_env }}
19
+ {%- endif %}
20
+ {%- if env_info.virtualenv %}
21
+ 虚拟环境: {{ env_info.virtualenv }}
22
+ {%- endif %}
23
+
24
+ 根据用户的输入以及当前的操作系统和Shell类型生成合适的 shell 脚本,注意只能生成一个shell脚本,不要生成多个。
25
+
26
+ 用户输入: {{ user_input }}
27
+
28
+ 请生成一个适当的 shell 脚本来执行用户的请求。确保脚本是安全的,并且可以在当前Shell环境中运行。
29
+ 脚本应该包含必要的注释来解释每个步骤。
30
+ 脚本内容请用如下方式返回:
31
+
32
+ ```shell
33
+ # 你的 shell 脚本内容
34
+ ```
35
+ """
36
+ env_info = detect_env()
37
+ return {
38
+ "env_info": env_info,
39
+ "shell_type": shells.get_terminal_name(),
40
+ "shell_encoding": shells.get_terminal_encoding()
41
+ }
42
+
43
+
44
+ def generate_shell_script(user_input: str, llm: byzerllm.ByzerLLM) -> str:
45
+ # 获取 prompt 内容
46
+ prompt = _generate_shell_script.prompt(user_input=user_input)
47
+
48
+ # 构造对话上下文
49
+ conversations = [{"role": "user", "content": prompt}]
50
+
51
+ # 使用 stream_out 进行输出
52
+ printer = Printer()
53
+ title = printer.get_message_from_key("generating_shell_script")
54
+ result, _ = stream_out(
55
+ llm.stream_chat_oai(conversations=conversations, delta_mode=True),
56
+ model_name=llm.default_model_name,
57
+ title=title
58
+ )
59
+
60
+ # 提取代码块
61
+ code = code_utils.extract_code(result)[0][1]
62
+ return code
@@ -0,0 +1,225 @@
1
+
2
+ import sys
3
+ import os
4
+ import locale
5
+ import subprocess
6
+ import platform
7
+ from rich.console import Console
8
+ from rich.panel import Panel
9
+ from rich.text import Text
10
+ from rich.live import Live
11
+
12
+ def get_terminal_name() -> str:
13
+ """
14
+ 获取当前终端名称(自动适配 Windows/Linux/Mac)
15
+ 返回终端名称如: cmd.exe, bash, zsh 等
16
+ """
17
+ if sys.platform == 'win32':
18
+ return _get_windows_terminal_name()
19
+ else:
20
+ return _get_unix_terminal_name()
21
+
22
+ def _get_windows_terminal_name() -> str:
23
+ """Windows 系统终端检测"""
24
+ # 检查是否在 PowerShell
25
+ if 'POWERSHELL_DISTRIBUTION_CHANNEL' in os.environ:
26
+ return 'powershell'
27
+
28
+ # 检查是否在 Git Bash
29
+ if 'MINGW' in platform.system():
30
+ return 'git-bash'
31
+
32
+ # 默认返回 cmd.exe
33
+ return 'cmd.exe'
34
+
35
+ def _get_unix_terminal_name() -> str:
36
+ """Linux/Mac 系统终端检测"""
37
+ # 从环境变量获取终端名称
38
+ term = os.environ.get('TERM')
39
+ shell = os.environ.get('SHELL', '')
40
+
41
+ # 检查是否在 VS Code 终端
42
+ if 'VSCODE_GIT_IPC_HANDLE' in os.environ:
43
+ return 'vscode-terminal'
44
+
45
+ # 如果是 Mac 的 Terminal.app
46
+ if sys.platform == 'darwin' and 'Apple_Terminal' in os.environ.get('TERM_PROGRAM', ''):
47
+ return 'terminal.app'
48
+
49
+ # 从 shell 路径获取终端名称
50
+ if shell:
51
+ shell_name = os.path.basename(shell)
52
+ if shell_name in ['bash', 'zsh', 'fish']:
53
+ return shell_name
54
+
55
+ # 从 TERM 环境变量判断
56
+ if term:
57
+ if 'xterm' in term:
58
+ return 'xterm'
59
+ elif 'rxvt' in term:
60
+ return 'rxvt'
61
+ elif 'screen' in term:
62
+ return 'screen'
63
+ elif 'tmux' in term:
64
+ return 'tmux'
65
+
66
+ return 'unknown'
67
+
68
+ def get_terminal_encoding() -> str:
69
+ """
70
+ 获取当前终端编码(自动适配 Windows/Linux/Mac)
71
+ 返回标准编码名称如: utf-8, gbk, cp936 等
72
+ """
73
+ # 第一优先级:尝试标准库locale检测
74
+ try:
75
+ return locale.getencoding() # Python 3.10+ 新增方法
76
+ except AttributeError:
77
+ pass
78
+
79
+ # 第二优先级:各平台专用检测逻辑
80
+ if sys.platform == 'win32':
81
+ return _get_windows_terminal_encoding()
82
+ else:
83
+ return _get_unix_terminal_encoding()
84
+
85
+ def _get_windows_terminal_encoding() -> str:
86
+ """Windows 系统编码检测"""
87
+ try:
88
+ # 通过 chcp 命令获取代码页
89
+ result = subprocess.run(
90
+ ['chcp'],
91
+ capture_output=True,
92
+ text=True,
93
+ shell=True,
94
+ timeout=1
95
+ )
96
+ code_page = result.stdout.split(':')[-1].strip()
97
+ return _win_code_page_to_encoding(code_page)
98
+ except Exception:
99
+ return locale.getpreferredencoding(do_setlocale=False) or 'gbk'
100
+
101
+ def _get_unix_terminal_encoding() -> str:
102
+ """Linux/Mac 系统编码检测"""
103
+ # 尝试读取环境变量
104
+ for var in ['LC_ALL', 'LC_CTYPE', 'LANG']:
105
+ lang = os.environ.get(var)
106
+ if lang and '.' in lang:
107
+ return lang.split('.')[-1]
108
+
109
+ # 通过 locale 命令检测
110
+ try:
111
+ result = subprocess.run(
112
+ ['locale', '-c', 'LC_CTYPE'],
113
+ capture_output=True,
114
+ text=True,
115
+ timeout=1
116
+ )
117
+ return result.stdout.strip().split('.')[-1] or 'utf-8'
118
+ except Exception:
119
+ return locale.getpreferredencoding(do_setlocale=False) or 'utf-8'
120
+
121
+ def _win_code_page_to_encoding(code_page: str) -> str:
122
+ """Windows 代码页转编码名称"""
123
+ cp_map = {
124
+ '65001': 'utf-8',
125
+ '936': 'gbk',
126
+ '950': 'big5',
127
+ '54936': 'gb18030',
128
+ '437': 'cp437',
129
+ '850': 'cp850'
130
+ }
131
+ return cp_map.get(code_page, f'cp{code_page}')
132
+
133
+ def execute_shell_command(command: str):
134
+ """
135
+ Execute a shell command with cross-platform encoding support.
136
+
137
+ Args:
138
+ command (str): The shell command to execute
139
+ encoding (str, optional): Override default encoding. Defaults to None.
140
+ """
141
+ console = Console()
142
+ try:
143
+ # Get terminal encoding
144
+ encoding = get_terminal_encoding()
145
+
146
+ # Start subprocess
147
+ process = subprocess.Popen(
148
+ command,
149
+ stdout=subprocess.PIPE,
150
+ stderr=subprocess.PIPE,
151
+ shell=True
152
+ )
153
+
154
+ # Safe decoding helper
155
+ def safe_decode(byte_stream, encoding):
156
+ try:
157
+ return byte_stream.decode(encoding).strip()
158
+ except UnicodeDecodeError:
159
+ return byte_stream.decode(encoding, errors='replace').strip()
160
+
161
+ output = []
162
+ with Live(console=console, refresh_per_second=4) as live:
163
+ while True:
164
+ # Read output streams
165
+ output_bytes = process.stdout.readline()
166
+ error_bytes = process.stderr.readline()
167
+
168
+ # Handle standard output
169
+ if output_bytes:
170
+ output_line = safe_decode(output_bytes, encoding)
171
+ output.append(output_line)
172
+ live.update(
173
+ Panel(
174
+ Text("\n".join(output[-20:])),
175
+ title="Shell Output",
176
+ border_style="green",
177
+ )
178
+ )
179
+
180
+ # Handle error output
181
+ if error_bytes:
182
+ error_line = safe_decode(error_bytes, encoding)
183
+ output.append(f"ERROR: {error_line}")
184
+ live.update(
185
+ Panel(
186
+ Text("\n".join(output[-20:])),
187
+ title="Shell Output",
188
+ border_style="red",
189
+ )
190
+ )
191
+
192
+ # Check if process has ended
193
+ if process.poll() is not None:
194
+ break
195
+
196
+ # Get remaining output
197
+ remaining_out, remaining_err = process.communicate()
198
+ if remaining_out:
199
+ output.append(safe_decode(remaining_out, encoding))
200
+ if remaining_err:
201
+ output.append(f"ERROR: {safe_decode(remaining_err, encoding)}")
202
+
203
+ # Show final output
204
+ console.print(
205
+ Panel(
206
+ Text("\n".join(output)),
207
+ title="Final Output",
208
+ border_style="blue",
209
+ subtitle=f"Encoding: {encoding} | OS: {sys.platform}"
210
+ )
211
+ )
212
+
213
+ if process.returncode != 0:
214
+ console.print(
215
+ f"[bold red]Command failed with code {process.returncode}[/bold red]"
216
+ )
217
+
218
+ except FileNotFoundError:
219
+ console.print(
220
+ f"[bold red]Command not found:[/bold red] [yellow]{command}[/yellow]"
221
+ )
222
+ except Exception as e:
223
+ console.print(
224
+ f"[bold red]Unexpected error:[/bold red] [yellow]{str(e)}[/yellow]"
225
+ )