auto-coder 0.1.260__py3-none-any.whl → 0.1.262__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.260.dist-info → auto_coder-0.1.262.dist-info}/METADATA +2 -2
- {auto_coder-0.1.260.dist-info → auto_coder-0.1.262.dist-info}/RECORD +28 -24
- autocoder/agent/auto_review_commit.py +52 -25
- autocoder/chat_auto_coder.py +56 -6
- autocoder/chat_auto_coder_lang.py +18 -0
- autocoder/commands/auto_command.py +42 -13
- autocoder/common/__init__.py +8 -0
- autocoder/common/auto_coder_lang.py +29 -4
- autocoder/common/code_auto_merge.py +2 -2
- autocoder/common/code_auto_merge_diff.py +2 -2
- autocoder/common/code_auto_merge_editblock.py +2 -2
- autocoder/common/code_auto_merge_strict_diff.py +2 -2
- autocoder/common/command_completer.py +1 -10
- autocoder/common/conf_validator.py +245 -0
- autocoder/common/conversation_pruner.py +131 -0
- autocoder/common/index_import_export.py +101 -0
- autocoder/common/shells.py +22 -6
- autocoder/dispacher/actions/action.py +37 -0
- autocoder/dispacher/actions/plugins/action_regex_project.py +11 -0
- autocoder/index/entry.py +10 -10
- autocoder/index/filter/quick_filter.py +9 -5
- autocoder/index/symbols_utils.py +5 -2
- autocoder/utils/project_structure.py +15 -0
- autocoder/version.py +1 -1
- {auto_coder-0.1.260.dist-info → auto_coder-0.1.262.dist-info}/LICENSE +0 -0
- {auto_coder-0.1.260.dist-info → auto_coder-0.1.262.dist-info}/WHEEL +0 -0
- {auto_coder-0.1.260.dist-info → auto_coder-0.1.262.dist-info}/entry_points.txt +0 -0
- {auto_coder-0.1.260.dist-info → auto_coder-0.1.262.dist-info}/top_level.txt +0 -0
autocoder/common/shells.py
CHANGED
|
@@ -9,6 +9,8 @@ from rich.panel import Panel
|
|
|
9
9
|
from rich.text import Text
|
|
10
10
|
from rich.live import Live
|
|
11
11
|
|
|
12
|
+
from autocoder.common.result_manager import ResultManager
|
|
13
|
+
|
|
12
14
|
def get_terminal_name() -> str:
|
|
13
15
|
"""
|
|
14
16
|
获取当前终端名称(自动适配 Windows/Linux/Mac)
|
|
@@ -139,6 +141,7 @@ def execute_shell_command(command: str):
|
|
|
139
141
|
encoding (str, optional): Override default encoding. Defaults to None.
|
|
140
142
|
"""
|
|
141
143
|
console = Console()
|
|
144
|
+
result_manager = ResultManager()
|
|
142
145
|
try:
|
|
143
146
|
# Get terminal encoding
|
|
144
147
|
encoding = get_terminal_encoding()
|
|
@@ -199,7 +202,13 @@ def execute_shell_command(command: str):
|
|
|
199
202
|
output.append(safe_decode(remaining_out, encoding))
|
|
200
203
|
if remaining_err:
|
|
201
204
|
output.append(f"ERROR: {safe_decode(remaining_err, encoding)}")
|
|
202
|
-
|
|
205
|
+
|
|
206
|
+
result_manager.add_result(content="\n".join(output),meta={
|
|
207
|
+
"action": "execute_shell_command",
|
|
208
|
+
"input": {
|
|
209
|
+
"command": command
|
|
210
|
+
}
|
|
211
|
+
})
|
|
203
212
|
# Show final output
|
|
204
213
|
console.print(
|
|
205
214
|
Panel(
|
|
@@ -210,16 +219,23 @@ def execute_shell_command(command: str):
|
|
|
210
219
|
)
|
|
211
220
|
)
|
|
212
221
|
|
|
213
|
-
if process.returncode != 0:
|
|
214
|
-
console.print(
|
|
215
|
-
f"[bold red]Command failed with code {process.returncode}[/bold red]"
|
|
216
|
-
)
|
|
217
|
-
|
|
218
222
|
except FileNotFoundError:
|
|
223
|
+
result_manager.add_result(content=f"[bold red]Command not found:[/bold red] [yellow]{command}[/yellow]",meta={
|
|
224
|
+
"action": "execute_shell_command",
|
|
225
|
+
"input": {
|
|
226
|
+
"command": command
|
|
227
|
+
}
|
|
228
|
+
})
|
|
219
229
|
console.print(
|
|
220
230
|
f"[bold red]Command not found:[/bold red] [yellow]{command}[/yellow]"
|
|
221
231
|
)
|
|
222
232
|
except Exception as e:
|
|
233
|
+
result_manager.add_result(content=f"[bold red]Unexpected error:[/bold red] [yellow]{str(e)}[/yellow]",meta={
|
|
234
|
+
"action": "execute_shell_command",
|
|
235
|
+
"input": {
|
|
236
|
+
"command": command
|
|
237
|
+
}
|
|
238
|
+
})
|
|
223
239
|
console.print(
|
|
224
240
|
f"[bold red]Unexpected error:[/bold red] [yellow]{str(e)}[/yellow]"
|
|
225
241
|
)
|
|
@@ -29,6 +29,7 @@ from autocoder.common.printer import Printer
|
|
|
29
29
|
from autocoder.utils.llms import get_llm_names
|
|
30
30
|
from autocoder.privacy.model_filter import ModelPathFilter
|
|
31
31
|
from autocoder.common import SourceCodeList
|
|
32
|
+
from autocoder.common.global_cancel import global_cancel
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
class BaseAction:
|
|
@@ -106,6 +107,10 @@ class ActionTSProject(BaseAction):
|
|
|
106
107
|
f"Content(send to model) is {content_length} tokens, which is larger than the maximum input length {self.args.model_max_input_length}"
|
|
107
108
|
)
|
|
108
109
|
|
|
110
|
+
if global_cancel.requested:
|
|
111
|
+
printer = Printer()
|
|
112
|
+
raise Exception(printer.get_message_from_key("generation_cancelled"))
|
|
113
|
+
|
|
109
114
|
if args.execute:
|
|
110
115
|
self.printer.print_in_terminal("code_generation_start")
|
|
111
116
|
start_time = time.time()
|
|
@@ -148,6 +153,11 @@ class ActionTSProject(BaseAction):
|
|
|
148
153
|
model_names=model_names,
|
|
149
154
|
sampling_count=len(generate_result.contents)
|
|
150
155
|
)
|
|
156
|
+
|
|
157
|
+
if global_cancel.requested:
|
|
158
|
+
printer = Printer()
|
|
159
|
+
raise Exception(printer.get_message_from_key("generation_cancelled"))
|
|
160
|
+
|
|
151
161
|
merge_result = None
|
|
152
162
|
if args.execute and args.auto_merge:
|
|
153
163
|
self.printer.print_in_terminal("code_merge_start")
|
|
@@ -207,6 +217,10 @@ class ActionPyScriptProject(BaseAction):
|
|
|
207
217
|
|
|
208
218
|
def process_content(self, source_code_list: SourceCodeList):
|
|
209
219
|
args = self.args
|
|
220
|
+
if global_cancel.requested:
|
|
221
|
+
printer = Printer()
|
|
222
|
+
raise Exception(printer.get_message_from_key("generation_cancelled"))
|
|
223
|
+
|
|
210
224
|
if args.execute:
|
|
211
225
|
self.printer.print_in_terminal("code_generation_start")
|
|
212
226
|
start_time = time.time()
|
|
@@ -249,6 +263,11 @@ class ActionPyScriptProject(BaseAction):
|
|
|
249
263
|
model_names=model_names,
|
|
250
264
|
sampling_count=len(generate_result.contents)
|
|
251
265
|
)
|
|
266
|
+
|
|
267
|
+
if global_cancel.requested:
|
|
268
|
+
printer = Printer()
|
|
269
|
+
raise Exception(printer.get_message_from_key("generation_cancelled"))
|
|
270
|
+
|
|
252
271
|
merge_result = None
|
|
253
272
|
if args.execute and args.auto_merge:
|
|
254
273
|
self.printer.print_in_terminal("code_merge_start")
|
|
@@ -331,6 +350,10 @@ class ActionPyProject(BaseAction):
|
|
|
331
350
|
content_length=content_length,
|
|
332
351
|
max_length=self.args.model_max_input_length
|
|
333
352
|
)
|
|
353
|
+
|
|
354
|
+
if global_cancel.requested:
|
|
355
|
+
printer = Printer()
|
|
356
|
+
raise Exception(printer.get_message_from_key("generation_cancelled"))
|
|
334
357
|
|
|
335
358
|
if args.execute:
|
|
336
359
|
self.printer.print_in_terminal("code_generation_start")
|
|
@@ -375,6 +398,11 @@ class ActionPyProject(BaseAction):
|
|
|
375
398
|
model_names=model_names,
|
|
376
399
|
sampling_count=len(generate_result.contents)
|
|
377
400
|
)
|
|
401
|
+
|
|
402
|
+
if global_cancel.requested:
|
|
403
|
+
printer = Printer()
|
|
404
|
+
raise Exception(printer.get_message_from_key("generation_cancelled"))
|
|
405
|
+
|
|
378
406
|
merge_result = None
|
|
379
407
|
if args.execute and args.auto_merge:
|
|
380
408
|
self.printer.print_in_terminal("code_merge_start")
|
|
@@ -449,6 +477,10 @@ class ActionSuffixProject(BaseAction):
|
|
|
449
477
|
f"Content(send to model) is {content_length} tokens, which is larger than the maximum input length {self.args.model_max_input_length}"
|
|
450
478
|
)
|
|
451
479
|
|
|
480
|
+
if global_cancel.requested:
|
|
481
|
+
printer = Printer()
|
|
482
|
+
raise Exception(printer.get_message_from_key("generation_cancelled"))
|
|
483
|
+
|
|
452
484
|
if args.execute:
|
|
453
485
|
self.printer.print_in_terminal("code_generation_start")
|
|
454
486
|
start_time = time.time()
|
|
@@ -491,6 +523,11 @@ class ActionSuffixProject(BaseAction):
|
|
|
491
523
|
model_names=model_names,
|
|
492
524
|
sampling_count=len(generate_result.contents)
|
|
493
525
|
)
|
|
526
|
+
|
|
527
|
+
if global_cancel.requested:
|
|
528
|
+
printer = Printer()
|
|
529
|
+
raise Exception(printer.get_message_from_key("generation_cancelled") )
|
|
530
|
+
|
|
494
531
|
merge_result = None
|
|
495
532
|
if args.execute and args.auto_merge:
|
|
496
533
|
self.printer.print_in_terminal("code_merge_start")
|
|
@@ -16,6 +16,7 @@ from autocoder.common.printer import Printer
|
|
|
16
16
|
import time
|
|
17
17
|
from autocoder.utils.llms import get_llm_names
|
|
18
18
|
from autocoder.common import SourceCodeList
|
|
19
|
+
from autocoder.common.global_cancel import global_cancel
|
|
19
20
|
from loguru import logger
|
|
20
21
|
class ActionRegexProject:
|
|
21
22
|
def __init__(
|
|
@@ -61,6 +62,11 @@ class ActionRegexProject:
|
|
|
61
62
|
content = content[: self.args.model_max_input_length]
|
|
62
63
|
|
|
63
64
|
start_time = time.time()
|
|
65
|
+
|
|
66
|
+
if global_cancel.requested:
|
|
67
|
+
printer = Printer()
|
|
68
|
+
raise Exception(printer.get_message_from_key("generation_cancelled"))
|
|
69
|
+
|
|
64
70
|
if args.execute:
|
|
65
71
|
self.printer.print_in_terminal("code_generation_start")
|
|
66
72
|
|
|
@@ -103,6 +109,11 @@ class ActionRegexProject:
|
|
|
103
109
|
model_names=model_names,
|
|
104
110
|
sampling_count=len(generate_result.contents)
|
|
105
111
|
)
|
|
112
|
+
|
|
113
|
+
if global_cancel.requested:
|
|
114
|
+
printer = Printer()
|
|
115
|
+
raise Exception(printer.get_message_from_key("generation_cancelled"))
|
|
116
|
+
|
|
106
117
|
merge_result = None
|
|
107
118
|
if args.execute and args.auto_merge:
|
|
108
119
|
self.printer.print_in_terminal("code_merge_start")
|
autocoder/index/entry.py
CHANGED
|
@@ -318,16 +318,16 @@ def build_index_and_filter_files(
|
|
|
318
318
|
• Total time: {total_time:.2f}s
|
|
319
319
|
|
|
320
320
|
"""
|
|
321
|
-
printer.print_panel(
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
)
|
|
321
|
+
# printer.print_panel(
|
|
322
|
+
# summary,
|
|
323
|
+
# text_options={"justify": "left", "style": "bold white"},
|
|
324
|
+
# panel_options={
|
|
325
|
+
# "title": "Indexing and Filtering Summary",
|
|
326
|
+
# "border_style": "bold blue",
|
|
327
|
+
# "padding": (1, 2),
|
|
328
|
+
# "expand": False
|
|
329
|
+
# }
|
|
330
|
+
# )
|
|
331
331
|
|
|
332
332
|
if args.request_id and not args.skip_events:
|
|
333
333
|
queue_communicate.send_event(
|
|
@@ -230,7 +230,8 @@ class QuickFilter():
|
|
|
230
230
|
{{ content }}
|
|
231
231
|
</index>
|
|
232
232
|
|
|
233
|
-
索引文件包含文件序号(##[]括起来的部分),文件路径,文件符号信息等。
|
|
233
|
+
索引文件包含文件序号(##[]括起来的部分),文件路径,文件符号信息等。
|
|
234
|
+
|
|
234
235
|
下面是用户的查询需求:
|
|
235
236
|
|
|
236
237
|
<query>
|
|
@@ -249,16 +250,19 @@ class QuickFilter():
|
|
|
249
250
|
}
|
|
250
251
|
```
|
|
251
252
|
|
|
252
|
-
特别注意
|
|
253
|
-
1. 如果用户的query里 @文件 或者
|
|
253
|
+
特别注意
|
|
254
|
+
1. 如果用户的query里 @文件 或者 @@符号,那么被@的文件或者@@的符号必须要返回,并且尝试通过索引文件诸如导入语句等信息找到这些文件依赖的其他文件,再分析这些文件是否需要提供才能满足后续编码。
|
|
254
255
|
2. 如果 query 里是一段历史对话,那么对话里的内容提及的文件路径必须要返回。
|
|
255
|
-
3.
|
|
256
|
+
3. 想想,如果是你需要修改代码,然后满足这个需求,根据索引文件,你希望查看哪些文件,修改哪些文件,然后返回这些文件。
|
|
257
|
+
4. 如果用户需求为空,则直接返回空列表即可。
|
|
258
|
+
5. 返回的 json格式数据不允许有注释
|
|
256
259
|
'''
|
|
260
|
+
|
|
257
261
|
file_meta_str = "\n".join(
|
|
258
262
|
[f"##[{index}]{item.module_name}\n{item.symbols}" for index, item in enumerate(file_meta_list)])
|
|
259
263
|
context = {
|
|
260
264
|
"content": file_meta_str,
|
|
261
|
-
"query": query
|
|
265
|
+
"query": query
|
|
262
266
|
}
|
|
263
267
|
return context
|
|
264
268
|
|
autocoder/index/symbols_utils.py
CHANGED
|
@@ -27,8 +27,11 @@ def extract_symbols(text: str) -> SymbolsInfo:
|
|
|
27
27
|
"variables": r"变量:(.+)",
|
|
28
28
|
"classes": r"类:(.+)",
|
|
29
29
|
"import_statements": r"导入语句:(.+)",
|
|
30
|
-
}
|
|
31
|
-
|
|
30
|
+
}
|
|
31
|
+
## index.json 中可能会出现 text 为 null 的情况
|
|
32
|
+
if not text or text == "null":
|
|
33
|
+
return SymbolsInfo(usage="",functions=[],variables=[],classes=[],import_statements=[])
|
|
34
|
+
|
|
32
35
|
info = SymbolsInfo()
|
|
33
36
|
for field, pattern in patterns.items():
|
|
34
37
|
match = re.search(pattern, text)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from autocoder.pyproject import PyProject
|
|
2
|
+
from autocoder.tsproject import TSProject
|
|
3
|
+
from autocoder.suffixproject import SuffixProject
|
|
4
|
+
from autocoder.common import AutoCoderArgs
|
|
5
|
+
import byzerllm
|
|
6
|
+
from typing import Union
|
|
7
|
+
|
|
8
|
+
def get_project_structure(args:AutoCoderArgs, llm:Union[byzerllm.ByzerLLM, byzerllm.SimpleByzerLLM]):
|
|
9
|
+
if args.project_type == "ts":
|
|
10
|
+
pp = TSProject(args=args, llm=llm)
|
|
11
|
+
elif args.project_type == "py":
|
|
12
|
+
pp = PyProject(args=args, llm=llm)
|
|
13
|
+
else:
|
|
14
|
+
pp = SuffixProject(args=args, llm=llm, file_filter=None)
|
|
15
|
+
return pp.get_tree_like_directory_structure()
|
autocoder/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.262"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|