auto-coder 0.1.305__py3-none-any.whl → 0.1.307__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of auto-coder might be problematic. Click here for more details.

Files changed (43) hide show
  1. {auto_coder-0.1.305.dist-info → auto_coder-0.1.307.dist-info}/METADATA +1 -1
  2. {auto_coder-0.1.305.dist-info → auto_coder-0.1.307.dist-info}/RECORD +43 -38
  3. autocoder/agent/auto_demand_organizer.py +13 -20
  4. autocoder/agent/auto_filegroup.py +10 -16
  5. autocoder/agent/auto_learn_from_commit.py +25 -33
  6. autocoder/agent/auto_review_commit.py +15 -64
  7. autocoder/auto_coder.py +6 -8
  8. autocoder/auto_coder_runner.py +153 -8
  9. autocoder/chat_auto_coder.py +9 -1
  10. autocoder/chat_auto_coder_lang.py +552 -278
  11. autocoder/commands/auto_command.py +31 -7
  12. autocoder/common/__init__.py +6 -0
  13. autocoder/common/action_yml_file_manager.py +75 -37
  14. autocoder/common/auto_coder_lang.py +737 -401
  15. autocoder/common/code_auto_generate.py +104 -16
  16. autocoder/common/code_auto_generate_diff.py +101 -10
  17. autocoder/common/code_auto_generate_editblock.py +103 -9
  18. autocoder/common/code_auto_generate_strict_diff.py +99 -9
  19. autocoder/common/code_auto_merge.py +8 -0
  20. autocoder/common/code_auto_merge_diff.py +8 -0
  21. autocoder/common/code_auto_merge_editblock.py +7 -0
  22. autocoder/common/code_auto_merge_strict_diff.py +5 -0
  23. autocoder/common/code_modification_ranker.py +9 -3
  24. autocoder/common/command_completer.py +12 -0
  25. autocoder/common/command_generator.py +5 -4
  26. autocoder/common/git_utils.py +86 -63
  27. autocoder/common/stream_out_type.py +8 -1
  28. autocoder/common/utils_code_auto_generate.py +29 -3
  29. autocoder/dispacher/__init__.py +18 -19
  30. autocoder/dispacher/actions/action.py +0 -132
  31. autocoder/index/filter/quick_filter.py +6 -3
  32. autocoder/memory/__init__.py +7 -0
  33. autocoder/memory/active_context_manager.py +649 -0
  34. autocoder/memory/active_package.py +469 -0
  35. autocoder/memory/async_processor.py +161 -0
  36. autocoder/memory/directory_mapper.py +67 -0
  37. autocoder/utils/auto_coder_utils/chat_stream_out.py +5 -0
  38. autocoder/utils/project_structure.py +35 -1
  39. autocoder/version.py +1 -1
  40. {auto_coder-0.1.305.dist-info → auto_coder-0.1.307.dist-info}/LICENSE +0 -0
  41. {auto_coder-0.1.305.dist-info → auto_coder-0.1.307.dist-info}/WHEEL +0 -0
  42. {auto_coder-0.1.305.dist-info → auto_coder-0.1.307.dist-info}/entry_points.txt +0 -0
  43. {auto_coder-0.1.305.dist-info → auto_coder-0.1.307.dist-info}/top_level.txt +0 -0
@@ -17,6 +17,7 @@ from contextlib import contextmanager
17
17
  from typing import List, Dict, Any, Optional
18
18
  from autocoder.common import AutoCoderArgs
19
19
  from pydantic import BaseModel
20
+ from autocoder.common.action_yml_file_manager import ActionYmlFileManager
20
21
  from autocoder.common.result_manager import ResultManager
21
22
  from autocoder.version import __version__
22
23
  from autocoder.auto_coder import main as auto_coder_main
@@ -49,10 +50,12 @@ from autocoder.utils.llms import get_single_llm
49
50
  import pkg_resources
50
51
  from autocoder.common.printer import Printer
51
52
  from autocoder.utils.thread_utils import run_in_raw_thread
53
+ from autocoder.memory.active_context_manager import ActiveContextManager
52
54
  from autocoder.common.command_completer import CommandCompleter,FileSystemModel as CCFileSystemModel,MemoryConfig as CCMemoryModel
53
55
  from autocoder.common.conf_validator import ConfigValidator
54
56
  from autocoder import command_parser as CommandParser
55
57
  from loguru import logger
58
+ from autocoder.utils.project_structure import EnhancedFileAnalyzer
56
59
 
57
60
  class SymbolItem(BaseModel):
58
61
  symbol_name: str
@@ -168,9 +171,10 @@ def configure_project_type():
168
171
  print_info(get_message("examples"))
169
172
 
170
173
  print_warning(f"{get_message('default_type')}\n")
171
-
174
+
175
+ extensions = get_all_extensions(project_root) or "py"
172
176
  project_type = prompt(
173
- get_message("enter_project_type"), default="py", style=style
177
+ get_message("enter_project_type"), default=extensions, style=style
174
178
  ).strip()
175
179
 
176
180
  if project_type:
@@ -186,6 +190,32 @@ def configure_project_type():
186
190
  return project_type
187
191
 
188
192
 
193
+ def get_all_extensions(directory: str = ".") -> str:
194
+ """获取指定目录下所有文件的后缀名,多个按逗号分隔,并且带."""
195
+ args = AutoCoderArgs(
196
+ source_dir=directory,
197
+ # 其他必要参数设置为默认值
198
+ target_file="",
199
+ git_url="",
200
+ project_type="",
201
+ conversation_prune_safe_zone_tokens=0
202
+ )
203
+
204
+ analyzer = EnhancedFileAnalyzer(
205
+ args=args,
206
+ llm=None, # 如果只是获取后缀名,可以不需要LLM
207
+ config=None # 使用默认配置
208
+ )
209
+
210
+ # 获取分析结果
211
+ analysis_result = analyzer.analyze_extensions()
212
+
213
+ # 合并 code 和 config 的后缀名
214
+ all_extensions = set(analysis_result["code"] + analysis_result["config"])
215
+
216
+ # 转换为逗号分隔的字符串
217
+ return ",".join(sorted(all_extensions))
218
+
189
219
  def initialize_system(args:InitializeSystemRequest):
190
220
  from autocoder.utils.model_provider_selector import ModelProviderSelector
191
221
  from autocoder import models as models_module
@@ -666,9 +696,7 @@ def revert():
666
696
 
667
697
  if "Successfully reverted changes" in s:
668
698
  result_manager.append(content=s, meta={"action": "revert","success":False, "input":{
669
- }})
670
-
671
- os.remove(file_path)
699
+ }})
672
700
  else:
673
701
  result_manager.append(content=s, meta={"action": "revert","success":False, "input":{
674
702
  }})
@@ -1399,12 +1427,33 @@ def commit(query: str):
1399
1427
  with open(os.path.join(execute_file), "w",encoding="utf-8") as f:
1400
1428
  f.write(yaml_content)
1401
1429
 
1402
- file_content = open(execute_file).read()
1403
- md5 = hashlib.md5(file_content.encode("utf-8")).hexdigest()
1430
+ args.file = execute_file
1431
+
1404
1432
  file_name = os.path.basename(execute_file)
1405
1433
  commit_result = git_utils.commit_changes(
1406
1434
  ".", f"{commit_message}\nauto_coder_{file_name}"
1407
1435
  )
1436
+
1437
+ printer = Printer()
1438
+
1439
+ action_yml_file_manager = ActionYmlFileManager(args.source_dir)
1440
+ action_file_name = os.path.basename(args.file)
1441
+ add_updated_urls = []
1442
+ commit_result.changed_files
1443
+ for file in commit_result.changed_files:
1444
+ add_updated_urls.append(os.path.join(args.source_dir, file))
1445
+
1446
+ args.add_updated_urls = add_updated_urls
1447
+ update_yaml_success = action_yml_file_manager.update_yaml_field(action_file_name, "add_updated_urls", add_updated_urls)
1448
+ if not update_yaml_success:
1449
+ printer.print_in_terminal("yaml_save_error", style="red", yaml_file=action_file_name)
1450
+
1451
+ if args.enable_active_context:
1452
+ active_context_manager = ActiveContextManager(llm, args.source_dir)
1453
+ task_id = active_context_manager.process_changes(args)
1454
+ printer.print_in_terminal("active_context_background_task",
1455
+ style="blue",
1456
+ task_id=task_id)
1408
1457
  git_utils.print_commit_info(commit_result=commit_result)
1409
1458
  if commit_message:
1410
1459
  printer.print_in_terminal("commit_message", style="green", model_name=target_model, message=commit_message)
@@ -1417,7 +1466,7 @@ def commit(query: str):
1417
1466
 
1418
1467
 
1419
1468
  @run_in_raw_thread()
1420
- def coding(query: str):
1469
+ def coding(query: str):
1421
1470
  console = Console()
1422
1471
  is_apply = query.strip().startswith("/apply")
1423
1472
  if is_apply:
@@ -1756,6 +1805,102 @@ def design(query: str):
1756
1805
  os.remove(execute_file)
1757
1806
 
1758
1807
 
1808
+ @run_in_raw_thread()
1809
+ def active_context(query: str):
1810
+ """
1811
+ 管理活动上下文任务,支持列表、查询等操作
1812
+
1813
+ Args:
1814
+ query: 命令参数,例如 "list" 列出所有任务
1815
+ """
1816
+ # 解析命令
1817
+ commands_infos = CommandParser.parse_query(query)
1818
+ command = "list" # 默认命令是列出所有任务
1819
+
1820
+ if len(commands_infos) > 0:
1821
+ if "list" in commands_infos:
1822
+ command = "list"
1823
+ if "run" in commands_infos:
1824
+ command = "run"
1825
+
1826
+ args = get_final_config()
1827
+ printer = Printer()
1828
+ # 获取LLM实例
1829
+ llm = get_single_llm(args.model,product_mode=args.product_mode)
1830
+ action_file_manager = ActionYmlFileManager(args.source_dir)
1831
+
1832
+ # 获取配置和参数
1833
+
1834
+
1835
+ active_context_manager = ActiveContextManager(llm, args.source_dir)
1836
+ if command == "run":
1837
+ file_name = commands_infos["run"]["args"][-1]
1838
+ args.file = action_file_manager.get_full_path_by_file_name(file_name)
1839
+ ## 因为更新了args.file
1840
+ active_context_manager = ActiveContextManager(llm, args.source_dir)
1841
+ task_id = active_context_manager.process_changes(args)
1842
+ printer.print_in_terminal("active_context_background_task",
1843
+ style="blue",
1844
+ task_id=task_id)
1845
+
1846
+ # 处理不同的命令
1847
+ if command == "list":
1848
+ # 获取所有任务
1849
+ all_tasks = active_context_manager.get_all_tasks()
1850
+
1851
+ if not all_tasks:
1852
+ console = Console()
1853
+ console.print("[yellow]没有找到任何活动上下文任务[/yellow]")
1854
+ return
1855
+
1856
+ # 创建表格
1857
+ table = Table(title="活动上下文任务列表")
1858
+ table.add_column("任务ID", style="cyan")
1859
+ table.add_column("状态", style="green")
1860
+ table.add_column("开始时间", style="yellow")
1861
+ table.add_column("完成时间", style="yellow")
1862
+ table.add_column("文件", style="blue")
1863
+
1864
+ # 添加任务数据
1865
+ for task in all_tasks:
1866
+ status = task.get("status", "未知")
1867
+ status_display = status
1868
+
1869
+ # 根据状态设置不同的显示样式
1870
+ if status == "completed":
1871
+ status_display = "[green]已完成[/green]"
1872
+ elif status == "running":
1873
+ status_display = "[blue]运行中[/blue]"
1874
+ elif status == "queued":
1875
+ position = task.get("queue_position", 0)
1876
+ status_display = f"[yellow]排队中 (位置: {position})[/yellow]"
1877
+ elif status == "failed":
1878
+ status_display = "[red]失败[/red]"
1879
+
1880
+ # 格式化时间
1881
+ start_time = task.get("start_time", "")
1882
+ start_time_str = start_time.strftime("%Y-%m-%d %H:%M:%S") if start_time else "未知"
1883
+
1884
+ completion_time = task.get("completion_time", "")
1885
+ completion_time_str = completion_time.strftime("%Y-%m-%d %H:%M:%S") if completion_time else "-"
1886
+
1887
+ # 获取文件名
1888
+ file_name = task.get("file_name", "未知")
1889
+
1890
+ # 添加到表格
1891
+ table.add_row(
1892
+ task.get("task_id", "未知"),
1893
+ status_display,
1894
+ start_time_str,
1895
+ completion_time_str,
1896
+ file_name
1897
+ )
1898
+
1899
+ # 显示表格
1900
+ console = Console()
1901
+ console.print(table)
1902
+
1903
+
1759
1904
  def voice_input():
1760
1905
  conf = memory.get("conf", {})
1761
1906
  yaml_config = {
@@ -49,6 +49,7 @@ from autocoder.auto_coder_runner import (
49
49
  completer,
50
50
  summon,
51
51
  get_memory,
52
+ active_context,
52
53
  )
53
54
 
54
55
  # Create a global plugin manager
@@ -63,6 +64,7 @@ original_functions = {
63
64
  "voice_input": voice_input,
64
65
  "auto_command": auto_command,
65
66
  "execute_shell_command": execute_shell_command,
67
+ "active_context": active_context,
66
68
  }
67
69
 
68
70
 
@@ -149,6 +151,7 @@ def show_help():
149
151
  print(f" \033[94m/lib\033[0m - \033[92m{get_message('lib_desc')}\033[0m")
150
152
  print(f" \033[94m/models\033[0m - \033[92m{get_message('models_desc')}\033[0m")
151
153
  print(f" \033[94m/plugins\033[0m - \033[92m{get_message('plugins_desc')}\033[0m")
154
+ print(f" \033[94m/active_context\033[0m - \033[92m{get_message('active_context_desc')}\033[0m")
152
155
  print(f" \033[94m/exit\033[0m - \033[92m{get_message('exit_desc')}\033[0m")
153
156
  print()
154
157
 
@@ -423,13 +426,14 @@ def main():
423
426
  )
424
427
 
425
428
  # Replace original functions with wrapped versions
426
- global ask, coding, chat, design, voice_input, auto_command, execute_shell_command
429
+ global ask, coding, chat, design, voice_input, auto_command, execute_shell_command, active_context
427
430
  ask = wrapped_functions.get("ask", ask)
428
431
  coding = wrapped_functions.get("coding", coding)
429
432
  chat = wrapped_functions.get("chat", chat)
430
433
  design = wrapped_functions.get("design", design)
431
434
  voice_input = wrapped_functions.get("voice_input", voice_input)
432
435
  auto_command = wrapped_functions.get("auto_command", auto_command)
436
+ active_context = wrapped_functions.get("active_context", active_context)
433
437
  execute_shell_command = wrapped_functions.get(
434
438
  "execute_shell_command", execute_shell_command
435
439
  )
@@ -620,6 +624,10 @@ def main():
620
624
  print("Please enter your query.")
621
625
  else:
622
626
  mcp(query)
627
+
628
+ elif user_input.startswith("/active_context"):
629
+ query = user_input[len("/active_context") :].strip()
630
+ active_context(query)
623
631
 
624
632
  elif user_input.startswith("/auto"):
625
633
  query = user_input[len("/auto") :].strip()