auto-coder 0.1.353__py3-none-any.whl → 0.1.355__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.353.dist-info → auto_coder-0.1.355.dist-info}/METADATA +1 -1
- {auto_coder-0.1.353.dist-info → auto_coder-0.1.355.dist-info}/RECORD +60 -45
- autocoder/agent/agentic_filter.py +1 -1
- autocoder/auto_coder.py +8 -0
- autocoder/auto_coder_rag.py +37 -1
- autocoder/auto_coder_runner.py +58 -77
- autocoder/chat/conf_command.py +270 -0
- autocoder/chat/models_command.py +485 -0
- autocoder/chat_auto_coder.py +29 -24
- autocoder/chat_auto_coder_lang.py +26 -2
- autocoder/commands/auto_command.py +60 -132
- autocoder/commands/auto_web.py +1 -1
- autocoder/commands/tools.py +1 -1
- autocoder/common/__init__.py +3 -1
- autocoder/common/command_completer.py +58 -12
- autocoder/common/command_completer_v2.py +576 -0
- autocoder/common/conversations/__init__.py +52 -0
- autocoder/common/conversations/compatibility.py +303 -0
- autocoder/common/conversations/conversation_manager.py +502 -0
- autocoder/common/conversations/example.py +152 -0
- autocoder/common/file_monitor/__init__.py +5 -0
- autocoder/common/file_monitor/monitor.py +383 -0
- autocoder/common/global_cancel.py +53 -16
- autocoder/common/ignorefiles/__init__.py +4 -0
- autocoder/common/ignorefiles/ignore_file_utils.py +103 -0
- autocoder/common/ignorefiles/test_ignore_file_utils.py +91 -0
- autocoder/common/rulefiles/__init__.py +15 -0
- autocoder/common/rulefiles/autocoderrules_utils.py +173 -0
- autocoder/common/save_formatted_log.py +54 -0
- autocoder/common/v2/agent/agentic_edit.py +10 -39
- autocoder/common/v2/agent/agentic_edit_tools/list_files_tool_resolver.py +1 -1
- autocoder/common/v2/agent/agentic_edit_tools/search_files_tool_resolver.py +73 -43
- autocoder/common/v2/code_agentic_editblock_manager.py +9 -9
- autocoder/common/v2/code_diff_manager.py +2 -2
- autocoder/common/v2/code_editblock_manager.py +31 -18
- autocoder/common/v2/code_strict_diff_manager.py +3 -2
- autocoder/dispacher/actions/action.py +6 -6
- autocoder/dispacher/actions/plugins/action_regex_project.py +2 -2
- autocoder/events/event_manager_singleton.py +1 -1
- autocoder/index/index.py +3 -3
- autocoder/models.py +22 -9
- autocoder/rag/api_server.py +14 -2
- autocoder/rag/cache/local_byzer_storage_cache.py +1 -1
- autocoder/rag/cache/local_duckdb_storage_cache.py +8 -0
- autocoder/rag/cache/simple_cache.py +63 -33
- autocoder/rag/loaders/docx_loader.py +1 -1
- autocoder/rag/loaders/filter_utils.py +133 -76
- autocoder/rag/loaders/image_loader.py +15 -3
- autocoder/rag/loaders/pdf_loader.py +2 -2
- autocoder/rag/long_context_rag.py +11 -0
- autocoder/rag/qa_conversation_strategy.py +5 -31
- autocoder/rag/utils.py +21 -2
- autocoder/utils/_markitdown.py +66 -25
- autocoder/utils/auto_coder_utils/chat_stream_out.py +4 -4
- autocoder/utils/thread_utils.py +9 -27
- autocoder/version.py +1 -1
- {auto_coder-0.1.353.dist-info → auto_coder-0.1.355.dist-info}/LICENSE +0 -0
- {auto_coder-0.1.353.dist-info → auto_coder-0.1.355.dist-info}/WHEEL +0 -0
- {auto_coder-0.1.353.dist-info → auto_coder-0.1.355.dist-info}/entry_points.txt +0 -0
- {auto_coder-0.1.353.dist-info → auto_coder-0.1.355.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Compatibility layer for existing conversation implementations.
|
|
3
|
+
|
|
4
|
+
This module provides adapter functions and classes to help
|
|
5
|
+
transition from the existing conversation implementations to
|
|
6
|
+
the new unified conversation manager.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import Dict, List, Any, Optional, Callable, Union
|
|
10
|
+
import time
|
|
11
|
+
from pydantic import BaseModel
|
|
12
|
+
|
|
13
|
+
from autocoder.common import AutoCoderArgs
|
|
14
|
+
from autocoder.common.conversations.conversation_manager import (
|
|
15
|
+
ConversationManager,
|
|
16
|
+
ConversationType,
|
|
17
|
+
get_conversation_manager,
|
|
18
|
+
Message
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# ======= CommandMessage (auto_command.py) Compatibility =======
|
|
23
|
+
|
|
24
|
+
class CommandMessage(BaseModel):
|
|
25
|
+
"""Compatible with auto_command.py CommandMessage."""
|
|
26
|
+
role: str
|
|
27
|
+
content: str
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ExtendedCommandMessage(BaseModel):
|
|
31
|
+
"""Compatible with auto_command.py ExtendedCommandMessage."""
|
|
32
|
+
message: CommandMessage
|
|
33
|
+
timestamp: str
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class CommandConversation(BaseModel):
|
|
37
|
+
"""Compatible with auto_command.py CommandConversation."""
|
|
38
|
+
history: Dict[str, ExtendedCommandMessage]
|
|
39
|
+
current_conversation: List[ExtendedCommandMessage]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def command_message_to_message(cmd_msg: Union[CommandMessage, ExtendedCommandMessage]) -> Message:
|
|
43
|
+
"""Convert a CommandMessage or ExtendedCommandMessage to a Message."""
|
|
44
|
+
if isinstance(cmd_msg, ExtendedCommandMessage):
|
|
45
|
+
return Message(
|
|
46
|
+
role=cmd_msg.message.role,
|
|
47
|
+
content=cmd_msg.message.content,
|
|
48
|
+
timestamp=int(cmd_msg.timestamp)
|
|
49
|
+
)
|
|
50
|
+
else:
|
|
51
|
+
return Message(
|
|
52
|
+
role=cmd_msg.role,
|
|
53
|
+
content=cmd_msg.content
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def message_to_command_message(msg: Message) -> ExtendedCommandMessage:
|
|
58
|
+
"""Convert a Message to an ExtendedCommandMessage."""
|
|
59
|
+
return ExtendedCommandMessage(
|
|
60
|
+
message=CommandMessage(
|
|
61
|
+
role=msg.role,
|
|
62
|
+
content=msg.content or ""
|
|
63
|
+
),
|
|
64
|
+
timestamp=str(msg.timestamp or int(time.time()))
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def load_command_conversation(args: AutoCoderArgs, conv_id: str = "command") -> CommandConversation:
|
|
69
|
+
"""
|
|
70
|
+
Load a command conversation in the old format.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
args: AutoCoderArgs object
|
|
74
|
+
conv_id: Conversation ID (defaults to "command")
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
A CommandConversation object compatible with auto_command.py
|
|
78
|
+
"""
|
|
79
|
+
manager = get_conversation_manager(args)
|
|
80
|
+
conversation = manager.get_conversation(
|
|
81
|
+
conv_id=conv_id,
|
|
82
|
+
conv_type=ConversationType.COMMAND,
|
|
83
|
+
create_if_not_exists=True
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
# Convert to old format
|
|
87
|
+
current_conversation = [
|
|
88
|
+
message_to_command_message(msg)
|
|
89
|
+
for msg in conversation.messages
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
# Convert archived conversations
|
|
93
|
+
history = {}
|
|
94
|
+
if conversation.archived_conversations:
|
|
95
|
+
for timestamp, messages in conversation.archived_conversations.items():
|
|
96
|
+
history[timestamp] = [
|
|
97
|
+
message_to_command_message(msg)
|
|
98
|
+
for msg in messages
|
|
99
|
+
]
|
|
100
|
+
|
|
101
|
+
return CommandConversation(
|
|
102
|
+
history=history,
|
|
103
|
+
current_conversation=current_conversation
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def save_command_conversation(
|
|
108
|
+
args: AutoCoderArgs,
|
|
109
|
+
conv: CommandConversation,
|
|
110
|
+
conv_id: str = "command"
|
|
111
|
+
) -> None:
|
|
112
|
+
"""
|
|
113
|
+
Save a command conversation from the old format.
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
args: AutoCoderArgs object
|
|
117
|
+
conv: CommandConversation object
|
|
118
|
+
conv_id: Conversation ID (defaults to "command")
|
|
119
|
+
"""
|
|
120
|
+
manager = get_conversation_manager(args)
|
|
121
|
+
conversation = manager.get_conversation(
|
|
122
|
+
conv_id=conv_id,
|
|
123
|
+
conv_type=ConversationType.COMMAND,
|
|
124
|
+
create_if_not_exists=True
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
# Convert messages
|
|
128
|
+
conversation.messages = [
|
|
129
|
+
command_message_to_message(msg)
|
|
130
|
+
for msg in conv.current_conversation
|
|
131
|
+
]
|
|
132
|
+
|
|
133
|
+
# Convert archived conversations
|
|
134
|
+
conversation.archived_conversations = {}
|
|
135
|
+
for timestamp, messages in conv.history.items():
|
|
136
|
+
conversation.archived_conversations[timestamp] = [
|
|
137
|
+
command_message_to_message(msg)
|
|
138
|
+
for msg in messages
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
# Save
|
|
142
|
+
manager._save_conversation(conversation)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def save_to_command_memory_file(
|
|
146
|
+
args: AutoCoderArgs,
|
|
147
|
+
query: str,
|
|
148
|
+
response: str,
|
|
149
|
+
conv_id: str = "command"
|
|
150
|
+
) -> None:
|
|
151
|
+
"""
|
|
152
|
+
Save a command conversation message pair.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
args: AutoCoderArgs object
|
|
156
|
+
query: User query
|
|
157
|
+
response: Assistant response
|
|
158
|
+
conv_id: Conversation ID
|
|
159
|
+
"""
|
|
160
|
+
manager = get_conversation_manager(args)
|
|
161
|
+
conversation = manager.get_conversation(
|
|
162
|
+
conv_id=conv_id,
|
|
163
|
+
conv_type=ConversationType.COMMAND,
|
|
164
|
+
create_if_not_exists=True
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
# Add the messages
|
|
168
|
+
manager.add_user_message(conv_id, query)
|
|
169
|
+
manager.add_assistant_message(conv_id, response)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
# ======= AgenticConversation (agentic_edit_conversation.py) Compatibility =======
|
|
173
|
+
|
|
174
|
+
def get_agentic_conversation(
|
|
175
|
+
args: AutoCoderArgs,
|
|
176
|
+
conversation_name: Optional[str] = None,
|
|
177
|
+
event_id: Optional[str] = None
|
|
178
|
+
) -> 'AgenticConversationWrapper':
|
|
179
|
+
"""
|
|
180
|
+
Get an AgenticConversation wrapper that mimics the original class.
|
|
181
|
+
|
|
182
|
+
Args:
|
|
183
|
+
args: AutoCoderArgs object
|
|
184
|
+
conversation_name: Optional conversation name
|
|
185
|
+
event_id: Optional event ID
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
An AgenticConversationWrapper object compatible with agentic_edit_conversation.py
|
|
189
|
+
"""
|
|
190
|
+
return AgenticConversationWrapper(args, conversation_name, event_id)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class AgenticConversationWrapper:
|
|
194
|
+
"""Wrapper that mimics the AgenticConversation class from agentic_edit_conversation.py."""
|
|
195
|
+
|
|
196
|
+
def __init__(
|
|
197
|
+
self,
|
|
198
|
+
args: AutoCoderArgs,
|
|
199
|
+
conversation_name: Optional[str] = None,
|
|
200
|
+
event_id: Optional[str] = None,
|
|
201
|
+
initial_history: Optional[List[Dict[str, Any]]] = None
|
|
202
|
+
):
|
|
203
|
+
"""
|
|
204
|
+
Initialize the AgenticConversation wrapper.
|
|
205
|
+
|
|
206
|
+
Args:
|
|
207
|
+
args: AutoCoderArgs object
|
|
208
|
+
conversation_name: Optional conversation name, used as conv_id
|
|
209
|
+
event_id: Optional event ID to associate with this conversation
|
|
210
|
+
initial_history: Optional initial conversation history
|
|
211
|
+
"""
|
|
212
|
+
self.args = args
|
|
213
|
+
self.project_path = args.source_dir
|
|
214
|
+
self.conversation_name = conversation_name or "agentic_edit"
|
|
215
|
+
self.event_id = event_id
|
|
216
|
+
|
|
217
|
+
# Get the conversation manager
|
|
218
|
+
self.manager = get_conversation_manager(args)
|
|
219
|
+
|
|
220
|
+
# Get or create the conversation
|
|
221
|
+
self.conversation = self.manager.get_conversation(
|
|
222
|
+
conv_id=self.conversation_name,
|
|
223
|
+
event_id=self.event_id,
|
|
224
|
+
conv_type=ConversationType.AGENTIC_EDIT,
|
|
225
|
+
create_if_not_exists=True
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
# Add initial history if provided
|
|
229
|
+
if initial_history:
|
|
230
|
+
self._add_initial_history(initial_history)
|
|
231
|
+
|
|
232
|
+
def _add_initial_history(self, history: List[Dict[str, Any]]) -> None:
|
|
233
|
+
"""Add initial history to the conversation."""
|
|
234
|
+
for msg in history:
|
|
235
|
+
role = msg.get("role", "")
|
|
236
|
+
content = msg.get("content", "")
|
|
237
|
+
tool_calls = msg.get("tool_calls", None)
|
|
238
|
+
tool_call_id = msg.get("tool_call_id", None)
|
|
239
|
+
|
|
240
|
+
self.manager.add_message(
|
|
241
|
+
self.conversation.id,
|
|
242
|
+
role,
|
|
243
|
+
content,
|
|
244
|
+
tool_calls=tool_calls,
|
|
245
|
+
tool_call_id=tool_call_id
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
def add_message(self, role: str, content: Any, **kwargs) -> None:
|
|
249
|
+
"""Add a message to the conversation."""
|
|
250
|
+
self.manager.add_message(
|
|
251
|
+
self.conversation.id,
|
|
252
|
+
role,
|
|
253
|
+
content,
|
|
254
|
+
**kwargs
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
def add_user_message(self, content: str) -> None:
|
|
258
|
+
"""Add a user message to the conversation."""
|
|
259
|
+
self.manager.add_user_message(self.conversation.id, content)
|
|
260
|
+
|
|
261
|
+
def add_assistant_message(self, content: str) -> None:
|
|
262
|
+
"""Add an assistant message to the conversation."""
|
|
263
|
+
self.manager.add_assistant_message(self.conversation.id, content)
|
|
264
|
+
|
|
265
|
+
def append_to_last_message(self, content: str, role: str = "assistant") -> None:
|
|
266
|
+
"""Append content to the last message."""
|
|
267
|
+
self.manager.append_to_last_message(
|
|
268
|
+
self.conversation.id,
|
|
269
|
+
content,
|
|
270
|
+
role
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
def add_assistant_tool_call_message(self, tool_calls: List[Dict[str, Any]], content: Optional[str] = None) -> None:
|
|
274
|
+
"""Add a tool call message from the assistant."""
|
|
275
|
+
self.manager.add_tool_call_message(
|
|
276
|
+
self.conversation.id,
|
|
277
|
+
tool_calls,
|
|
278
|
+
content
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
def add_tool_result_message(self, tool_call_id: str, content: Any) -> None:
|
|
282
|
+
"""Add a tool result message."""
|
|
283
|
+
self.manager.add_tool_result_message(
|
|
284
|
+
self.conversation.id,
|
|
285
|
+
tool_call_id,
|
|
286
|
+
content
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
def get_history(self) -> List[Dict[str, Any]]:
|
|
290
|
+
"""Get the conversation history in the format expected by agentic_edit."""
|
|
291
|
+
return self.manager.get_history_as_dict_list(self.conversation.id)
|
|
292
|
+
|
|
293
|
+
def clear_history(self) -> None:
|
|
294
|
+
"""Clear the conversation history."""
|
|
295
|
+
self.manager.clear_conversation(self.conversation.id)
|
|
296
|
+
|
|
297
|
+
def __len__(self) -> int:
|
|
298
|
+
"""Return the number of messages in the conversation."""
|
|
299
|
+
return len(self.conversation.messages)
|
|
300
|
+
|
|
301
|
+
def __str__(self) -> str:
|
|
302
|
+
"""Return a string representation of the conversation."""
|
|
303
|
+
return str(self.get_history())
|