auto-coder 0.1.362__py3-none-any.whl → 0.1.364__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-0.1.362.dist-info → auto_coder-0.1.364.dist-info}/METADATA +2 -2
- {auto_coder-0.1.362.dist-info → auto_coder-0.1.364.dist-info}/RECORD +65 -22
- autocoder/agent/base_agentic/__init__.py +0 -0
- autocoder/agent/base_agentic/agent_hub.py +169 -0
- autocoder/agent/base_agentic/agentic_lang.py +112 -0
- autocoder/agent/base_agentic/agentic_tool_display.py +180 -0
- autocoder/agent/base_agentic/base_agent.py +1582 -0
- autocoder/agent/base_agentic/default_tools.py +683 -0
- autocoder/agent/base_agentic/test_base_agent.py +82 -0
- autocoder/agent/base_agentic/tool_registry.py +425 -0
- autocoder/agent/base_agentic/tools/__init__.py +12 -0
- autocoder/agent/base_agentic/tools/ask_followup_question_tool_resolver.py +72 -0
- autocoder/agent/base_agentic/tools/attempt_completion_tool_resolver.py +37 -0
- autocoder/agent/base_agentic/tools/base_tool_resolver.py +35 -0
- autocoder/agent/base_agentic/tools/example_tool_resolver.py +46 -0
- autocoder/agent/base_agentic/tools/execute_command_tool_resolver.py +72 -0
- autocoder/agent/base_agentic/tools/list_files_tool_resolver.py +110 -0
- autocoder/agent/base_agentic/tools/plan_mode_respond_tool_resolver.py +35 -0
- autocoder/agent/base_agentic/tools/read_file_tool_resolver.py +54 -0
- autocoder/agent/base_agentic/tools/replace_in_file_tool_resolver.py +156 -0
- autocoder/agent/base_agentic/tools/search_files_tool_resolver.py +134 -0
- autocoder/agent/base_agentic/tools/talk_to_group_tool_resolver.py +96 -0
- autocoder/agent/base_agentic/tools/talk_to_tool_resolver.py +79 -0
- autocoder/agent/base_agentic/tools/use_mcp_tool_resolver.py +44 -0
- autocoder/agent/base_agentic/tools/write_to_file_tool_resolver.py +58 -0
- autocoder/agent/base_agentic/types.py +189 -0
- autocoder/agent/base_agentic/utils.py +100 -0
- autocoder/auto_coder_runner.py +6 -4
- autocoder/chat/conf_command.py +11 -10
- autocoder/common/__init__.py +2 -0
- autocoder/common/file_checkpoint/__init__.py +21 -0
- autocoder/common/file_checkpoint/backup.py +264 -0
- autocoder/common/file_checkpoint/examples.py +217 -0
- autocoder/common/file_checkpoint/manager.py +404 -0
- autocoder/common/file_checkpoint/models.py +156 -0
- autocoder/common/file_checkpoint/store.py +383 -0
- autocoder/common/file_checkpoint/test_backup.py +242 -0
- autocoder/common/file_checkpoint/test_manager.py +570 -0
- autocoder/common/file_checkpoint/test_models.py +360 -0
- autocoder/common/file_checkpoint/test_store.py +327 -0
- autocoder/common/file_checkpoint/test_utils.py +297 -0
- autocoder/common/file_checkpoint/utils.py +119 -0
- autocoder/common/rulefiles/autocoderrules_utils.py +138 -55
- autocoder/common/save_formatted_log.py +76 -5
- autocoder/common/v2/agent/agentic_edit.py +339 -216
- autocoder/common/v2/agent/agentic_edit_tools/read_file_tool_resolver.py +2 -2
- autocoder/common/v2/agent/agentic_edit_tools/replace_in_file_tool_resolver.py +100 -5
- autocoder/common/v2/agent/agentic_edit_tools/test_write_to_file_tool_resolver.py +322 -0
- autocoder/common/v2/agent/agentic_edit_tools/write_to_file_tool_resolver.py +160 -10
- autocoder/common/v2/agent/agentic_edit_types.py +1 -2
- autocoder/common/v2/agent/agentic_tool_display.py +2 -3
- autocoder/compilers/normal_compiler.py +64 -0
- autocoder/events/event_manager_singleton.py +133 -4
- autocoder/linters/normal_linter.py +373 -0
- autocoder/linters/python_linter.py +4 -2
- autocoder/rag/long_context_rag.py +424 -397
- autocoder/rag/test_doc_filter.py +393 -0
- autocoder/rag/test_long_context_rag.py +473 -0
- autocoder/rag/test_token_limiter.py +342 -0
- autocoder/shadows/shadow_manager.py +1 -3
- autocoder/version.py +1 -1
- {auto_coder-0.1.362.dist-info → auto_coder-0.1.364.dist-info}/LICENSE +0 -0
- {auto_coder-0.1.362.dist-info → auto_coder-0.1.364.dist-info}/WHEEL +0 -0
- {auto_coder-0.1.362.dist-info → auto_coder-0.1.364.dist-info}/entry_points.txt +0 -0
- {auto_coder-0.1.362.dist-info → auto_coder-0.1.364.dist-info}/top_level.txt +0 -0
|
@@ -1,21 +1,85 @@
|
|
|
1
|
+
|
|
1
2
|
import os
|
|
2
3
|
import json
|
|
3
4
|
import uuid
|
|
4
5
|
from datetime import datetime
|
|
6
|
+
from loguru import logger # Added import
|
|
7
|
+
|
|
8
|
+
# New helper function for cleaning up logs
|
|
9
|
+
def _cleanup_logs(logs_dir: str, max_files: int = 100):
|
|
10
|
+
"""
|
|
11
|
+
Cleans up old log files in the specified directory, keeping only the most recent ones.
|
|
12
|
+
Log files are expected to follow the naming convention: <YYYYmmdd_HHMMSS>_<uuid>_<suffix>.md
|
|
13
|
+
"""
|
|
14
|
+
logger.debug(f"开始清理日志目录: {logs_dir},最大保留文件数: {max_files}")
|
|
15
|
+
if not os.path.isdir(logs_dir):
|
|
16
|
+
logger.debug(f"日志目录 {logs_dir} 不存在,无需清理。")
|
|
17
|
+
return
|
|
18
|
+
|
|
19
|
+
log_files = []
|
|
20
|
+
for filename in os.listdir(logs_dir):
|
|
21
|
+
if filename.endswith(".md"):
|
|
22
|
+
parts = filename.split('_')
|
|
23
|
+
# Expected format: <YYYYmmdd_HHMMSS>_<uuid>_<suffix>.md
|
|
24
|
+
# parts[0] should be the full timestamp string "YYYYmmdd_HHMMSS"
|
|
25
|
+
if len(parts) >= 2: # At least timestamp and uuid part (suffix might be empty or complex)
|
|
26
|
+
timestamp_str = parts[0]
|
|
27
|
+
try:
|
|
28
|
+
# Validate the timestamp format
|
|
29
|
+
datetime.strptime(timestamp_str, "%Y%m%d_%H%M%S")
|
|
30
|
+
log_files.append((timestamp_str, os.path.join(logs_dir, filename)))
|
|
31
|
+
except ValueError:
|
|
32
|
+
logger.debug(f"文件名 {filename} 的时间戳部分 ({timestamp_str}) 格式不正确,跳过。")
|
|
33
|
+
continue
|
|
34
|
+
else:
|
|
35
|
+
# Log the parts for better debugging if needed
|
|
36
|
+
logger.debug(f"文件名 {filename} (分割后: {parts}) 不符合预期的下划线分割数量 (至少需要 <timestamp>_<uuid>_...),跳过。")
|
|
37
|
+
|
|
38
|
+
# Sort by timestamp (oldest first)
|
|
39
|
+
log_files.sort(key=lambda x: x[0])
|
|
40
|
+
|
|
41
|
+
if len(log_files) > max_files:
|
|
42
|
+
files_to_delete_count = len(log_files) - max_files
|
|
43
|
+
logger.info(f"日志文件数量 ({len(log_files)}) 超过限制 ({max_files}),将删除 {files_to_delete_count} 个最旧的文件。")
|
|
44
|
+
for i in range(files_to_delete_count):
|
|
45
|
+
file_to_delete_timestamp, file_to_delete_path = log_files[i]
|
|
46
|
+
try:
|
|
47
|
+
os.remove(file_to_delete_path)
|
|
48
|
+
logger.info(f"已删除旧日志文件: {file_to_delete_path} (时间戳: {file_to_delete_timestamp})")
|
|
49
|
+
except OSError as e:
|
|
50
|
+
logger.warning(f"删除日志文件 {file_to_delete_path} 失败: {str(e)}")
|
|
51
|
+
logger.exception(e) # Log stack trace
|
|
52
|
+
else:
|
|
53
|
+
logger.debug(f"日志文件数量 ({len(log_files)}) 未超过限制 ({max_files}),无需删除。")
|
|
54
|
+
|
|
5
55
|
|
|
6
56
|
def save_formatted_log(project_root, json_text, suffix):
|
|
7
57
|
"""
|
|
8
|
-
Save a JSON log as a formatted markdown file under project_root/.
|
|
58
|
+
Save a JSON log as a formatted markdown file under project_root/.auto-coder/logs/agentic.
|
|
9
59
|
Filename: <YYYYmmdd_HHMMSS>_<uuid>_<suffix>.md
|
|
60
|
+
Also cleans up old logs in the directory, keeping the latest 100.
|
|
10
61
|
Args:
|
|
11
62
|
project_root (str): The root directory of the project.
|
|
12
63
|
json_text (str): The JSON string to be formatted and saved.
|
|
13
64
|
suffix (str): The suffix for the filename.
|
|
14
65
|
"""
|
|
66
|
+
# Prepare directory (logs_dir is needed for cleanup first)
|
|
67
|
+
logs_dir = os.path.join(project_root, ".auto-coder", "logs", "agentic")
|
|
68
|
+
|
|
69
|
+
# Cleanup old logs BEFORE saving the new one
|
|
70
|
+
try:
|
|
71
|
+
_cleanup_logs(logs_dir) # Default to keep 100 files
|
|
72
|
+
except Exception as e:
|
|
73
|
+
logger.warning(f"日志清理过程中发生错误: {str(e)}")
|
|
74
|
+
logger.exception(e)
|
|
75
|
+
# Log cleanup failure should not prevent the main functionality
|
|
76
|
+
|
|
15
77
|
# Parse JSON
|
|
16
78
|
try:
|
|
17
79
|
data = json.loads(json_text)
|
|
18
80
|
except Exception as e:
|
|
81
|
+
logger.error(f"无效的 JSON 格式: {str(e)}") # Log error before raising
|
|
82
|
+
logger.exception(e) # Log stack trace
|
|
19
83
|
raise ValueError(f"Invalid JSON provided: {e}")
|
|
20
84
|
|
|
21
85
|
# Format as markdown with recursive depth
|
|
@@ -37,8 +101,9 @@ def save_formatted_log(project_root, json_text, suffix):
|
|
|
37
101
|
md_lines.extend(to_markdown(data, 1))
|
|
38
102
|
md_content = "\n".join(md_lines)
|
|
39
103
|
|
|
40
|
-
#
|
|
41
|
-
|
|
104
|
+
# Ensure directory exists
|
|
105
|
+
# _cleanup_logs checks if dir exists but does not create it.
|
|
106
|
+
# os.makedirs needs to be called to ensure the directory for the new log file.
|
|
42
107
|
os.makedirs(logs_dir, exist_ok=True)
|
|
43
108
|
|
|
44
109
|
# Prepare filename
|
|
@@ -48,7 +113,13 @@ def save_formatted_log(project_root, json_text, suffix):
|
|
|
48
113
|
filepath = os.path.join(logs_dir, filename)
|
|
49
114
|
|
|
50
115
|
# Save file
|
|
51
|
-
|
|
52
|
-
|
|
116
|
+
try:
|
|
117
|
+
with open(filepath, "w", encoding="utf-8") as f:
|
|
118
|
+
f.write(md_content)
|
|
119
|
+
logger.info(f"日志已保存至: {filepath}")
|
|
120
|
+
except IOError as e:
|
|
121
|
+
logger.error(f"保存日志文件 {filepath} 失败: {str(e)}")
|
|
122
|
+
logger.exception(e) # Log stack trace
|
|
123
|
+
raise # Re-throw the exception so the caller knows saving failed
|
|
53
124
|
|
|
54
125
|
return filepath
|