auto-coder 0.1.354__py3-none-any.whl → 0.1.356__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 (40) hide show
  1. {auto_coder-0.1.354.dist-info → auto_coder-0.1.356.dist-info}/METADATA +1 -1
  2. {auto_coder-0.1.354.dist-info → auto_coder-0.1.356.dist-info}/RECORD +40 -35
  3. autocoder/agent/agentic_filter.py +1 -1
  4. autocoder/agent/auto_learn.py +631 -0
  5. autocoder/auto_coder.py +8 -0
  6. autocoder/auto_coder_runner.py +59 -87
  7. autocoder/chat/conf_command.py +270 -0
  8. autocoder/chat/models_command.py +485 -0
  9. autocoder/chat/rules_command.py +458 -0
  10. autocoder/chat_auto_coder.py +34 -24
  11. autocoder/chat_auto_coder_lang.py +156 -2
  12. autocoder/commands/auto_command.py +1 -1
  13. autocoder/commands/auto_web.py +1 -1
  14. autocoder/common/__init__.py +2 -0
  15. autocoder/common/auto_coder_lang.py +9 -1
  16. autocoder/common/command_completer.py +58 -12
  17. autocoder/common/command_completer_v2.py +615 -0
  18. autocoder/common/global_cancel.py +53 -16
  19. autocoder/common/rulefiles/autocoderrules_utils.py +83 -0
  20. autocoder/common/v2/agent/agentic_edit.py +4 -4
  21. autocoder/common/v2/code_agentic_editblock_manager.py +9 -9
  22. autocoder/common/v2/code_diff_manager.py +2 -2
  23. autocoder/common/v2/code_editblock_manager.py +11 -10
  24. autocoder/common/v2/code_strict_diff_manager.py +3 -2
  25. autocoder/dispacher/actions/action.py +6 -6
  26. autocoder/dispacher/actions/plugins/action_regex_project.py +2 -2
  27. autocoder/events/event_manager_singleton.py +1 -1
  28. autocoder/index/index.py +2 -2
  29. autocoder/rag/cache/local_byzer_storage_cache.py +1 -1
  30. autocoder/rag/cache/local_duckdb_storage_cache.py +8 -0
  31. autocoder/rag/loaders/image_loader.py +25 -13
  32. autocoder/rag/long_context_rag.py +2 -2
  33. autocoder/utils/auto_coder_utils/chat_stream_out.py +3 -4
  34. autocoder/utils/model_provider_selector.py +14 -2
  35. autocoder/utils/thread_utils.py +9 -27
  36. autocoder/version.py +1 -1
  37. {auto_coder-0.1.354.dist-info → auto_coder-0.1.356.dist-info}/LICENSE +0 -0
  38. {auto_coder-0.1.354.dist-info → auto_coder-0.1.356.dist-info}/WHEEL +0 -0
  39. {auto_coder-0.1.354.dist-info → auto_coder-0.1.356.dist-info}/entry_points.txt +0 -0
  40. {auto_coder-0.1.354.dist-info → auto_coder-0.1.356.dist-info}/top_level.txt +0 -0
@@ -375,8 +375,28 @@ MESSAGES = {
375
375
  "zh": "管理模型配置,仅在lite模式下可用"
376
376
  },
377
377
  "models_usage": {
378
- "en": "Usage: /models <command>\nAvailable subcommands:\n /list - List all models\n /add <name> <api_key> - Add a built-in model\n /add_model - Add a custom model\n /remove <name> - Remove a model\n /input_price <name> <value> - Set model input price\n /output_price <name> <value> - Set model output price\n /speed <name> <value> - Set model speed\n /speed-test - Test models speed\n /speed-test-long - Test models speed with long context",
379
- "zh": "用法: /models <命令>\n可用的子命令:\n /list - 列出所有模型\n /add <名称> <API密钥> - 添加内置模型\n /add_model - 添加自定义模型\n /remove <名称> - 移除模型\n /input_price <名称> <价格> - 设置模型输入价格\n /output_price <名称> <价格> - 设置模型输出价格\n /speed <名称> <速度> - 设置模型速度\n /speed-test - 测试模型速度\n /speed-test-long - 使用长文本上下文测试模型速度"
378
+ "en": '''Usage: /models <command>
379
+ Available subcommands:
380
+ /list - List all configured models (built-in + custom).
381
+ /add <name> <api_key> - Add or activate a built-in model and set its API key.
382
+ /add_model - Add a custom model. Provide parameters in 'key=value' format, e.g., name=my_model model_name=gpt-4 base_url=... api_key=...
383
+ /remove <name> - Remove a configured model by its name.
384
+ /input_price <name> <value> - Set the input price for a model (unit: Million tokens).
385
+ /output_price <name> <value> - Set the output price for a model (unit: Million tokens).
386
+ /speed <name> <value> - Set the average speed for a model (unit: seconds per request).
387
+ /speed-test [<rounds>] - Test the speed of configured models. Optionally specify the number of rounds.
388
+ /speed-test /long_context [<rounds>] - Test model speed using a long context. Optionally specify the number of rounds.''',
389
+ "zh": '''用法: /models <命令>
390
+ 可用的子命令:
391
+ /list - 列出所有已配置的模型 (包括内置和自定义)。
392
+ /add <名称> <API密钥> - 添加或激活一个内置模型,并设置其 API 密钥。
393
+ /add_model - 添加一个自定义模型。参数使用 'key=value' 格式提供,例如:name=my_model model_name=gpt-4 base_url=... api_key=...
394
+ /remove <名称> - 根据名称移除一个已配置的模型。
395
+ /input_price <名称> <价格> - 设置指定模型的输入价格 (单位: 百万 Token)。
396
+ /output_price <名称> <价格> - 设置指定模型的输出价格 (单位: 百万 Token)。
397
+ /speed <名称> <速度> - 设置指定模型的平均速度 (单位: 秒/请求)。
398
+ /speed-test [<轮数>] - 测试已配置模型的速度。可以指定测试轮数 (可选)。
399
+ /speed-test /long_context [<轮数>] - 使用长文本上下文测试模型速度。可以指定测试轮数 (可选)。'''
380
400
  },
381
401
  "models_added": {
382
402
  "en": "Added/Updated model '{{name}}' successfully.",
@@ -458,6 +478,10 @@ MESSAGES = {
458
478
  "en": "No models found.",
459
479
  "zh": "未找到任何模型。"
460
480
  },
481
+ "models_no_models_matching_pattern": {
482
+ "en": "No models found matching pattern: {{pattern}}",
483
+ "zh": "未找到匹配模式的模型: {{pattern}}"
484
+ },
461
485
  "models_lite_only": {
462
486
  "en": "The /models command is only available in lite mode",
463
487
  "zh": "/models 命令仅在 lite 模式下可用"
@@ -569,6 +593,136 @@ MESSAGES = {
569
593
  "marketplace_add_error": {
570
594
  "en": "Error adding marketplace item: {{name}} - {{error}}",
571
595
  "zh": "添加市场项目时出错:{{name}} - {{error}}"
596
+ },
597
+ "rules_desc": {
598
+ "en": "Analyze current files with rules and create code learning notes",
599
+ "zh": "使用规则分析当前文件并创建代码学习笔记"
600
+ },
601
+ "rules_file_list_title": {
602
+ "en": "Rules Files List (Pattern: {{pattern}})",
603
+ "zh": "规则文件列表 (匹配: {{pattern}})"
604
+ },
605
+ "rules_file_path": {
606
+ "en": "File Path",
607
+ "zh": "文件路径"
608
+ },
609
+ "rules_content_length": {
610
+ "en": "Content Length",
611
+ "zh": "内容长度"
612
+ },
613
+ "rules_help_subtitle": {
614
+ "en": "Use '/rules help' for more information",
615
+ "zh": "使用 '/rules help' 获取更多帮助"
616
+ },
617
+ "rules_no_files_found": {
618
+ "en": "No rules files found. Use '/rules /help' to learn how to add rules.",
619
+ "zh": "未找到任何规则文件。请使用 '/rules /help' 了解如何添加规则。"
620
+ },
621
+ "rules_no_matching_files": {
622
+ "en": "No rules files found matching pattern '{{pattern}}'.",
623
+ "zh": "没有找到匹配模式 '{{pattern}}' 的规则文件。"
624
+ },
625
+ "rules_remove_param_required": {
626
+ "en": "Error: 'remove' command requires a parameter (file pattern). Usage: /rules /remove <pattern>",
627
+ "zh": "错误: 'remove' 命令需要一个参数(文件匹配模式)。用法: /rules /remove <匹配模式>"
628
+ },
629
+ "rules_no_files_to_remove": {
630
+ "en": "No rules files found matching pattern '{{pattern}}'.",
631
+ "zh": "没有找到匹配模式 '{{pattern}}' 的规则文件。"
632
+ },
633
+ "rules_delete_error": {
634
+ "en": "Error deleting file '{{file_path}}': {{error}}",
635
+ "zh": "删除文件 '{{file_path}}' 时出错: {{error}}"
636
+ },
637
+ "rules_delete_success": {
638
+ "en": "Successfully deleted {{count}} rules files.",
639
+ "zh": "成功删除了 {{count}} 个规则文件。"
640
+ },
641
+ "rules_no_active_files": {
642
+ "en": "Error: No files selected for analysis. Please use 'add_files' command to add files first.",
643
+ "zh": "错误: 没有选择任何文件进行分析。请先使用 'add_files' 命令添加文件。"
644
+ },
645
+ "rules_file_read_error": {
646
+ "en": "Error reading file '{{file_path}}': {{error}}",
647
+ "zh": "读取文件 '{{file_path}}' 时出错: {{error}}"
648
+ },
649
+ "rules_analysis_error": {
650
+ "en": "Error analyzing code: {{error}}",
651
+ "zh": "分析代码时出错: {{error}}"
652
+ },
653
+ "rules_help_text": {
654
+ "en": """
655
+ /rules command usage:
656
+ /rules [query] - Analyze current added files, optionally provide specific query content.
657
+ /rules /list [pattern] - List all rules files. Optionally provide wildcard pattern (e.g. *.md).
658
+ /rules /remove <pattern> - Delete rules files matching the specified pattern.
659
+ /rules /get <pattern> - Display the content of rules files matching the specified pattern.
660
+ /rules /help or /rules help - Show this help message.
661
+
662
+ Rules file usage:
663
+ Rules files are stored in the project's .autocoderrules/ directory, in Markdown format.
664
+ The system automatically monitors changes to this directory and updates rules.
665
+ """,
666
+ "zh": """
667
+ /rules 命令用法:
668
+ /rules [查询内容] - 分析当前已添加的文件,可选提供具体查询内容。
669
+ /rules /list [匹配模式] - 列出所有规则文件。可选提供通配符匹配模式 (例如: *.md).
670
+ /rules /remove <匹配模式> - 删除匹配指定模式的规则文件。
671
+ /rules /get <匹配模式> - 显示匹配指定模式的规则文件内容。
672
+ /rules /help 或 /rules help - 显示此帮助信息。
673
+
674
+ 规则文件用法:
675
+ 规则文件存储在项目的 .autocoderrules/ 目录下,为 Markdown 格式。
676
+ 系统会自动监控该目录的变化并更新规则。
677
+ """
678
+ },
679
+ "rules_unknown_command": {
680
+ "en": "Unknown subcommand '/rules {{subcommand}}'. Use '/rules /help' for help.",
681
+ "zh": "未知的子命令 '/rules {{subcommand}}'。请使用 '/rules /help' 获取帮助。"
682
+ },
683
+ "rules_command_error": {
684
+ "en": "Error executing '/rules {{subcommand}}': {{error}}",
685
+ "zh": "执行 '/rules {{subcommand}}' 时发生错误: {{error}}"
686
+ },
687
+ "rules_get_param_required": {
688
+ "en": "Error: 'get' command requires a parameter (file pattern). Usage: /rules /get <pattern>",
689
+ "zh": "错误: 'get' 命令需要一个参数(文件匹配模式)。用法: /rules /get <匹配模式>"
690
+ },
691
+ "rules_get_no_matching_files": {
692
+ "en": "No rules files found matching pattern '{{pattern}}'.",
693
+ "zh": "没有找到匹配模式 '{{pattern}}' 的规则文件。"
694
+ },
695
+ "rules_get_file_title": {
696
+ "en": "Rule File: {{file_path}}",
697
+ "zh": "规则文件: {{file_path}}"
698
+ },
699
+ "rules_get_read_error": {
700
+ "en": "Error reading file '{{file_path}}': {{error}}",
701
+ "zh": "读取文件 '{{file_path}}' 时出错: {{error}}"
702
+ },
703
+ "rules_commit_param_required": {
704
+ "en": "Error: 'commit' command requires parameters. Usage: /rules /commit <commit_id> /query <query>",
705
+ "zh": "错误: 'commit' 命令需要参数。用法: /rules /commit <commit_id> /query <查询内容>"
706
+ },
707
+ "rules_commit_format_error": {
708
+ "en": "Error: Command format must be '/rules /commit <commit_id> /query <query>'",
709
+ "zh": "错误:命令格式必须为 '/rules /commit <commit_id> /query <你的需求>'"
710
+ },
711
+ "rules_commit_id_required": {
712
+ "en": "Error: Commit ID must be provided",
713
+ "zh": "错误:必须提供 commit ID"
714
+ },
715
+ "rules_query_required": {
716
+ "en": "Error: Query content must be provided",
717
+ "zh": "错误:必须提供查询内容"
718
+ },
719
+ "rules_commit_success": {
720
+ "en": "Successfully analyzed commit {{commit_id}}, query: {{query}}",
721
+ "zh": "成功分析 commit {{commit_id}},查询:{{query}}"
722
+ },
723
+ "rules_commit_error": {
724
+ "en": "Error analyzing commit {{commit_id}}: {{error}}",
725
+ "zh": "分析 commit {{commit_id}} 时出错:{{error}}"
572
726
  }
573
727
  }
574
728
 
@@ -440,7 +440,7 @@ class CommandAutoTuner:
440
440
  result_manager = ResultManager()
441
441
 
442
442
  while True:
443
- global_cancel.check_and_raise()
443
+ global_cancel.check_and_raise(token=self.args.event_file)
444
444
  # 执行命令
445
445
  command = response.suggestions[0].command
446
446
  parameters = response.suggestions[0].parameters
@@ -794,7 +794,7 @@ class AutoWebTuner:
794
794
  logger.info(f"开始执行迭代 {iterations}/{max_iterations}")
795
795
 
796
796
  # 检查是否需要取消操作
797
- global_cancel.check_and_raise()
797
+ global_cancel.check_and_raise(token=self.args.event_file)
798
798
 
799
799
  # 如果没有更多操作,认为任务完成
800
800
  if not plan.actions:
@@ -304,6 +304,8 @@ class AutoCoderArgs(pydantic.BaseModel):
304
304
  rag_duckdb_query_similarity: Optional[float] = 0.1 # DuckDB 向量化检索 相似度 阈值
305
305
  rag_duckdb_query_top_k: Optional[int] = 10000 # DuckDB 向量化检索 返回 TopK个结果(且大于相似度)
306
306
  rag_index_build_workers: Optional[int] = 10
307
+ rag_emb_dim: Optional[int] = 1024
308
+ rag_emb_text_size: Optional[int] = 1024
307
309
  # rag 本地图床地址
308
310
  local_image_host: Optional[str] = ""
309
311
  rag_recall_max_queries: Optional[int] = 5
@@ -106,6 +106,10 @@ MESSAGES = {
106
106
  "en": "DeepSeek Official",
107
107
  "zh": "DeepSeek官方"
108
108
  },
109
+ "model_provider_openrouter": {
110
+ "en": "OpenRouter",
111
+ "zh": "OpenRouter"
112
+ },
109
113
  "model_provider_api_key_title": {
110
114
  "en": "API Key",
111
115
  "zh": "API密钥"
@@ -114,6 +118,10 @@ MESSAGES = {
114
118
  "en": "Please enter your Volcano Engine API key:",
115
119
  "zh": "请输入您的火山方舟API密钥:"
116
120
  },
121
+ "model_provider_openrouter_api_key_text": {
122
+ "en": "Please enter your OpenRouter API key:",
123
+ "zh": "请输入您的OpenRouter API密钥:"
124
+ },
117
125
  "model_provider_volcano_r1_text": {
118
126
  "en": "Please enter your Volcano Engine R1 endpoint (format: ep-20250204215011-vzbsg):",
119
127
  "zh": "请输入您的火山方舟 R1 推理点(格式如: ep-20250204215011-vzbsg):"
@@ -129,7 +137,7 @@ MESSAGES = {
129
137
  "model_provider_deepseek_api_key_text": {
130
138
  "en": "Please enter your DeepSeek API key:",
131
139
  "zh": "请输入您的DeepSeek API密钥:"
132
- },
140
+ },
133
141
  "model_provider_selected": {
134
142
  "en": "Provider configuration completed successfully! You can use /models command to view, add and modify all models later.",
135
143
  "zh": "供应商配置已成功完成!后续你可以使用 /models 命令,查看,新增和修改所有模型"
@@ -1,10 +1,12 @@
1
+ import os
2
+ import pydantic
3
+ from typing import Callable,Dict,Any # Added import
4
+ from pydantic import BaseModel,SkipValidation # Added import
1
5
  from prompt_toolkit.completion import Completer, Completion, CompleteEvent
2
6
  from prompt_toolkit.document import Document
3
- import pydantic
4
- from typing import Callable,Dict,Any
5
- from pydantic import BaseModel,SkipValidation
6
- from autocoder.common import AutoCoderArgs
7
- import os
7
+
8
+ from autocoder import models as models_module # Import models module
9
+ from autocoder.common import AutoCoderArgs # Ensure AutoCoderArgs is imported
8
10
 
9
11
  COMMANDS = {
10
12
  "/add_files": {
@@ -78,7 +80,7 @@ class MemoryConfig(BaseModel):
78
80
  """
79
81
  A model to encapsulate memory configuration and operations.
80
82
  """
81
- memory: Dict[str, Any]
83
+ get_memory_func: SkipValidation[Callable]
82
84
  save_memory_func: SkipValidation[Callable]
83
85
 
84
86
  class Config:
@@ -366,10 +368,13 @@ class CommandCompleter(Completer):
366
368
  self.file_system_model = file_system_model
367
369
  self.memory_model = memory_model
368
370
  self.all_file_names = file_system_model.get_all_file_names_in_project()
369
- self.all_files = file_system_model.get_all_file_in_project()
370
- self.all_dir_names = file_system_model.get_all_dir_names_in_project()
371
- self.all_files_with_dot = file_system_model.get_all_file_in_project_with_dot()
372
- self.symbol_list = file_system_model.get_symbol_list()
371
+ self.all_files = self.file_system_model.get_all_file_in_project()
372
+ self.all_dir_names = self.file_system_model.get_all_dir_names_in_project()
373
+ self.all_files_with_dot = self.file_system_model.get_all_file_in_project_with_dot()
374
+ self.symbol_list = self.file_system_model.get_symbol_list()
375
+ # Refresh model names if they can change dynamically (optional)
376
+ self.all_model_names = [m['name'] for m in models_module.load_models()]
377
+ self.all_model_names = [m['name'] for m in models_module.load_models()] # Load model names
373
378
  self.current_file_names = []
374
379
 
375
380
  def get_completions(self, document, complete_event):
@@ -544,9 +549,49 @@ class CommandCompleter(Completer):
544
549
  for field_name in AutoCoderArgs.model_fields.keys()
545
550
  if field_name.startswith(current_word)
546
551
  ]
547
-
552
+ # /conf key:[cursor] or /conf key:v[cursor]
553
+ elif ":" in text: # Check if colon exists anywhere after /conf
554
+ parts = text[len("/conf"):].strip().split(":", 1)
555
+ if len(parts) == 2:
556
+ key = parts[0].strip()
557
+ value_part = parts[1] # This is the part after the colon
558
+
559
+ # Determine the word being completed (part after colon)
560
+ # Find the start of the current word after the colon
561
+ space_pos = value_part.rfind(" ")
562
+ if space_pos != -1:
563
+ current_value_word = value_part[space_pos + 1:]
564
+ else:
565
+ current_value_word = value_part
566
+
567
+ # Model name completion
568
+ if "model" in key:
569
+ for model_name in self.all_model_names:
570
+ if model_name.startswith(current_value_word):
571
+ yield Completion(model_name, start_position=-len(current_value_word))
572
+ # Prioritize model completion if key matches
573
+ return # Exit after providing model completions
574
+
575
+ # Boolean completion
576
+ bool_keys = {name for name, field in AutoCoderArgs.model_fields.items() if field.annotation == bool}
577
+ if key in bool_keys:
578
+ if "true".startswith(current_value_word):
579
+ yield Completion("true", start_position=-len(current_value_word))
580
+ if "false".startswith(current_value_word):
581
+ yield Completion("false", start_position=-len(current_value_word))
582
+ # Prioritize boolean completion if key matches
583
+ return # Exit after providing boolean completions
584
+
585
+ # Add other value completions based on key if needed here
586
+
587
+ # No specific value completions matched, so no yield from here
588
+ return # Exit if we were trying value completion
589
+
590
+ # Default completion for keys or /drop if no value completion logic was triggered above
548
591
  for completion in completions:
549
- yield Completion(completion, start_position=-len(current_word))
592
+ # Adjust start_position based on whether we are completing key or /drop
593
+ yield Completion(completion, start_position=-len(current_word))
594
+
550
595
  elif words[0] in ["/chat", "/coding","/auto"]:
551
596
  image_extensions = (
552
597
  ".png",
@@ -895,6 +940,7 @@ class CommandCompleter(Completer):
895
940
  def update_current_files(self, files):
896
941
  self.current_file_names = [f for f in files]
897
942
 
943
+
898
944
  def refresh_files(self):
899
945
  self.all_file_names = self.file_system_model.get_all_file_names_in_project()
900
946
  self.all_files = self.file_system_model.get_all_file_in_project()