auto-coder 0.1.268__py3-none-any.whl → 0.1.270__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.268.dist-info → auto_coder-0.1.270.dist-info}/METADATA +2 -2
- {auto_coder-0.1.268.dist-info → auto_coder-0.1.270.dist-info}/RECORD +23 -20
- autocoder/agent/auto_learn_from_commit.py +209 -0
- autocoder/auto_coder.py +4 -0
- autocoder/auto_coder_runner.py +2647 -0
- autocoder/chat_auto_coder.py +54 -2630
- autocoder/commands/auto_command.py +23 -33
- autocoder/common/__init__.py +6 -2
- autocoder/common/auto_coder_lang.py +21 -4
- autocoder/common/auto_configure.py +41 -30
- autocoder/common/code_modification_ranker.py +55 -11
- autocoder/common/command_templates.py +2 -3
- autocoder/common/context_pruner.py +214 -14
- autocoder/common/conversation_pruner.py +11 -10
- autocoder/index/entry.py +44 -22
- autocoder/index/index.py +1 -1
- autocoder/utils/auto_project_type.py +120 -0
- autocoder/utils/model_provider_selector.py +23 -23
- autocoder/version.py +1 -1
- {auto_coder-0.1.268.dist-info → auto_coder-0.1.270.dist-info}/LICENSE +0 -0
- {auto_coder-0.1.268.dist-info → auto_coder-0.1.270.dist-info}/WHEEL +0 -0
- {auto_coder-0.1.268.dist-info → auto_coder-0.1.270.dist-info}/entry_points.txt +0 -0
- {auto_coder-0.1.268.dist-info → auto_coder-0.1.270.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: auto-coder
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.270
|
|
4
4
|
Summary: AutoCoder: AutoCoder
|
|
5
5
|
Author: allwefantasy
|
|
6
6
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
@@ -58,7 +58,7 @@ Requires-Dist: pydub
|
|
|
58
58
|
Requires-Dist: youtube-transcript-api
|
|
59
59
|
Requires-Dist: SpeechRecognition
|
|
60
60
|
Requires-Dist: pathvalidate
|
|
61
|
-
Requires-Dist: mcp
|
|
61
|
+
Requires-Dist: mcp ; python_version >= "3.10"
|
|
62
62
|
|
|
63
63
|
<p align="center">
|
|
64
64
|
<picture>
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
autocoder/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
autocoder/auto_coder.py,sha256=
|
|
2
|
+
autocoder/auto_coder.py,sha256=SgAAoSpUaPZiiNnEWRYIULEsKBJaKuQK_b7pEl_mKY8,65516
|
|
3
3
|
autocoder/auto_coder_lang.py,sha256=Rtupq6N3_HT7JRhDKdgCBcwRaiAnyCOR_Gsp4jUomrI,3229
|
|
4
4
|
autocoder/auto_coder_rag.py,sha256=nwgsXO2-scssWStjX3S910tDp-OZXZRddSYrpyC4Nq0,29021
|
|
5
5
|
autocoder/auto_coder_rag_client_mcp.py,sha256=QRxUbjc6A8UmDMQ8lXgZkjgqtq3lgKYeatJbDY6rSo0,6270
|
|
6
6
|
autocoder/auto_coder_rag_mcp.py,sha256=-RrjNwFaS2e5v8XDIrKR-zlUNUE8UBaeOtojffBrvJo,8521
|
|
7
|
+
autocoder/auto_coder_runner.py,sha256=JGyLT231zu2cZgnf98Y-W5wDQ0xORZJef1GfL7SZQto,100725
|
|
7
8
|
autocoder/auto_coder_server.py,sha256=6YQweNEKUrGAZ3yPvw8_qlNZJYLVSVUXGrn1K6udLts,20413
|
|
8
9
|
autocoder/benchmark.py,sha256=Ypomkdzd1T3GE6dRICY3Hj547dZ6_inqJbBJIp5QMco,4423
|
|
9
|
-
autocoder/chat_auto_coder.py,sha256=
|
|
10
|
+
autocoder/chat_auto_coder.py,sha256=skujpqYqf4EvBLQARJELxj7Xwq9KQj2FGefUAiutF7c,16711
|
|
10
11
|
autocoder/chat_auto_coder_lang.py,sha256=ShOQVOnMA-WlT-fB9OrOer-xQkbcWxJGl-WMPuZcUkM,19572
|
|
11
12
|
autocoder/command_args.py,sha256=9aYJ-AmPxP1sQh6ciw04FWHjSn31f2W9afXFwo8wgx4,30441
|
|
12
13
|
autocoder/lang.py,sha256=U6AjVV8Rs1uLyjFCZ8sT6WWuNUxMBqkXXIOs4S120uk,14511
|
|
13
14
|
autocoder/models.py,sha256=PlG1tKHSHwB57cKLOl5gTl5yTzFUDzCgeHPJU3N9F6Q,9106
|
|
14
|
-
autocoder/version.py,sha256=
|
|
15
|
+
autocoder/version.py,sha256=Ymv8qf0pYidfKqf8MPKhpZSW_mioPG_ryznbSNFF01w,23
|
|
15
16
|
autocoder/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
17
|
autocoder/agent/auto_demand_organizer.py,sha256=NWSAEsEk94vT3lGjfo25kKLMwYdPcpy9e-i21txPasQ,6942
|
|
17
18
|
autocoder/agent/auto_filegroup.py,sha256=CW7bqp0FW1GIEMnl-blyAc2UGT7O9Mom0q66ITz1ckM,6635
|
|
18
19
|
autocoder/agent/auto_guess_query.py,sha256=rDSdhpPHcOGE5MuDXvIrhCXAPR4ARS1LqpyoLsx2Jhw,11374
|
|
20
|
+
autocoder/agent/auto_learn_from_commit.py,sha256=H_7i-73DZIOOKC9rfh1Uwb8SbWJ9XOJLwem3mhWSBEk,8240
|
|
19
21
|
autocoder/agent/auto_review_commit.py,sha256=Ks5oCDp-82YXiRfcDCgYabKq0pcMJkMrP4CaWIgw_JE,9143
|
|
20
22
|
autocoder/agent/auto_tool.py,sha256=DBzip-P_T6ZtT2eHexPcusmKYD0h7ufzp7TLwXAY10E,11554
|
|
21
23
|
autocoder/agent/coder.py,sha256=x6bdJwDuETGg9ebQnYlUWCxCtQcDGg73LtI6McpWslQ,72034
|
|
@@ -24,16 +26,16 @@ autocoder/agent/planner.py,sha256=SZTSZHxHzDmuWZo3K5fs79RwvJLWurg-nbJRRNbX65o,91
|
|
|
24
26
|
autocoder/agent/project_reader.py,sha256=tWLaPoLw1gI6kO_NzivQj28KbobU2ceOLuppHMbfGl8,18234
|
|
25
27
|
autocoder/chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
28
|
autocoder/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
-
autocoder/commands/auto_command.py,sha256=
|
|
29
|
+
autocoder/commands/auto_command.py,sha256=BbQoSmkzAv6EtVbJDYCgWqMrN8w3A6BdhlMTtEp1dXQ,51384
|
|
28
30
|
autocoder/commands/tools.py,sha256=xDhGD1jRN67fGfeck33pM74TxXlAMeo49S3Q9K-VKco,20107
|
|
29
31
|
autocoder/common/JupyterClient.py,sha256=O-wi6pXeAEYhAY24kDa0BINrLYvKS6rKyWe98pDClS0,2816
|
|
30
32
|
autocoder/common/ShellClient.py,sha256=fM1q8t_XMSbLBl2zkCNC2J9xuyKN3eXzGm6hHhqL2WY,2286
|
|
31
|
-
autocoder/common/__init__.py,sha256=
|
|
33
|
+
autocoder/common/__init__.py,sha256=d1AmAAYhm4b17dVhAJFwV3Vv2r1lUhMejpjr32Poyg8,12948
|
|
32
34
|
autocoder/common/anything2images.py,sha256=0ILBbWzY02M-CiWB-vzuomb_J1hVdxRcenAfIrAXq9M,25283
|
|
33
35
|
autocoder/common/anything2img.py,sha256=4TREa-sOA-iargieUy7MpyCYVUE-9Mmq0wJtwomPqnE,7662
|
|
34
36
|
autocoder/common/audio.py,sha256=Kn9nWKQddWnUrAz0a_ZUgjcu4VUU_IcZBigT7n3N3qc,7439
|
|
35
|
-
autocoder/common/auto_coder_lang.py,sha256=
|
|
36
|
-
autocoder/common/auto_configure.py,sha256=
|
|
37
|
+
autocoder/common/auto_coder_lang.py,sha256=L1K8Q_gyXXxRgCByasSxWae6Udb3Z4B0Y130J7qJeaw,31514
|
|
38
|
+
autocoder/common/auto_configure.py,sha256=L0wjvR-6wFNpP3c9ZxwDOunTtGrzwzjUwsS6BUnJ3W8,12470
|
|
37
39
|
autocoder/common/buildin_tokenizer.py,sha256=L7d5t39ZFvUd6EoMPXUhYK1toD0FHlRH1jtjKRGokWU,1236
|
|
38
40
|
autocoder/common/chunk_validation.py,sha256=BrR_ZWavW8IANuueEE7hS8NFAwEvm8TX34WnPx_1hs8,3030
|
|
39
41
|
autocoder/common/cleaner.py,sha256=NU72i8C6o9m0vXExab7nao5bstBUsfJFcj11cXa9l4U,1089
|
|
@@ -46,15 +48,15 @@ autocoder/common/code_auto_merge.py,sha256=cMEX44QT59iMPEo5B8OQKU9fAzn4iIahEPk2n
|
|
|
46
48
|
autocoder/common/code_auto_merge_diff.py,sha256=jl6rYvioAuN5CWaYRPY4uBFKsDB0_yW6g6KeVlIxPJA,17948
|
|
47
49
|
autocoder/common/code_auto_merge_editblock.py,sha256=D8petP0X74lScsVktFXEQ4_9u5UDVBRDFF16nkjWGZg,20310
|
|
48
50
|
autocoder/common/code_auto_merge_strict_diff.py,sha256=VxasaD8IcxOEEilXmxT0WeLLA16JDlvvI7cV5GyyHAI,12086
|
|
49
|
-
autocoder/common/code_modification_ranker.py,sha256=
|
|
51
|
+
autocoder/common/code_modification_ranker.py,sha256=e1i8oNPN_PfG4O8HQnQWxh9tyOd-ur6jFTXfkHPVXYo,13152
|
|
50
52
|
autocoder/common/command_completer.py,sha256=Nw_EFXLDuVXbOKGlmzTODNRJUV9mSUEWV73GUmO_WLw,35166
|
|
51
53
|
autocoder/common/command_generator.py,sha256=Je7OKJvyzeb4krdEspUJx2tyM2tjk-PkNpkc6bZ7PbA,2563
|
|
52
|
-
autocoder/common/command_templates.py,sha256=
|
|
54
|
+
autocoder/common/command_templates.py,sha256=WAixVjue5QmCFAD13K4ElfcOEjdeGr8tFb0atDAbEoo,8658
|
|
53
55
|
autocoder/common/conf_import_export.py,sha256=w__WsIobe6nmsGns2pV-laU7R5ZvtQNuIbXebxhbY7A,3967
|
|
54
56
|
autocoder/common/conf_validator.py,sha256=EzSmadpZ22D9e8iWmfeWodUeYJt0IgMoaAOmCleXliI,8795
|
|
55
57
|
autocoder/common/const.py,sha256=eTjhjh4Aj4CUzviJ81jaf3Y5cwqsLATySn2wJxaS6RQ,2911
|
|
56
|
-
autocoder/common/context_pruner.py,sha256=
|
|
57
|
-
autocoder/common/conversation_pruner.py,sha256=
|
|
58
|
+
autocoder/common/context_pruner.py,sha256=_JUpN8naoGNF2JupirM-5xn8Bl9uQgIVmZP3dXH4F1g,21725
|
|
59
|
+
autocoder/common/conversation_pruner.py,sha256=pzmrQEa7pFzA66eYSS_h7VqP6ZwUABeooDQzm0PGu0A,5770
|
|
58
60
|
autocoder/common/files.py,sha256=2-9CJwOZtyWkk2TQM4gPSkpJ3_cwb-l_3sdsCd1H5GQ,3380
|
|
59
61
|
autocoder/common/git_utils.py,sha256=qeuF_IB3G3M72asHxWokROU3hINCuFA1nar-UtF9wIU,26022
|
|
60
62
|
autocoder/common/global_cancel.py,sha256=hT7J7J5ChThIhk2x11_v4v9ASIn4HtwyPD26t2s-fwc,418
|
|
@@ -93,9 +95,9 @@ autocoder/dispacher/actions/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQ
|
|
|
93
95
|
autocoder/dispacher/actions/plugins/action_regex_project.py,sha256=AqGIkjbqV1eOS3vBoZUTSOpyOlkv1p5h35mI2Kcvekw,6906
|
|
94
96
|
autocoder/dispacher/actions/plugins/action_translate.py,sha256=GEn7dZA22jy5WyzINomjmzzB795p2Olg-CJla97lRF8,7744
|
|
95
97
|
autocoder/index/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
96
|
-
autocoder/index/entry.py,sha256=
|
|
98
|
+
autocoder/index/entry.py,sha256=l-RVlKSLDZkWaWi3jDzMbyWpZ97ZHIEZufsF5gae4Lo,14430
|
|
97
99
|
autocoder/index/for_command.py,sha256=BFvljE4t6VaMBGboZAuhUCzVK0EitCy_n5D_7FEnihw,3204
|
|
98
|
-
autocoder/index/index.py,sha256=
|
|
100
|
+
autocoder/index/index.py,sha256=1wUYfK9s0IHmisQL0bzd42PKdFg6WhYgglyMFEcrx6Y,27362
|
|
99
101
|
autocoder/index/symbols_utils.py,sha256=_EP7E_qWXxluAxq3FGZLlLfdrfwx3FmxCdulI8VGuac,2244
|
|
100
102
|
autocoder/index/types.py,sha256=a2s_KV5FJlq7jqA2ELSo9E1sjuLwDB-JJYMhSpzBAhU,596
|
|
101
103
|
autocoder/index/filter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -141,12 +143,13 @@ autocoder/suffixproject/__init__.py,sha256=EOb8eUqfu3ka8mrggkXUfwX3SWnxqEoiYmDF7
|
|
|
141
143
|
autocoder/tsproject/__init__.py,sha256=LPehIUgzFbZ5DT_Pc0a_xCQQXEDxACPTMwXfFF7rcL0,11836
|
|
142
144
|
autocoder/utils/__init__.py,sha256=KtcGElFNBgZPF7dEL8zF9JpXkCAjoyDrzaREJBhJrcs,994
|
|
143
145
|
autocoder/utils/_markitdown.py,sha256=RU88qn4eZfYIy0GDrPxlI8oYXIypbi63VRJjdlnE0VU,47431
|
|
146
|
+
autocoder/utils/auto_project_type.py,sha256=9_-wE9aavjbPiNSUVKxttJAdu5i5fu-zHyPYHr5XtWk,4422
|
|
144
147
|
autocoder/utils/coder.py,sha256=rK8e0svQBe0NOP26dIGToUXgha_hUDgxlWoC_p_r7oc,5698
|
|
145
148
|
autocoder/utils/conversation_store.py,sha256=esd9zLarKYe0ZsYqjjwHc_ksmVQDDEhVt-Ejul2oyys,1178
|
|
146
149
|
autocoder/utils/llm_client_interceptors.py,sha256=FEHNXoFZlCjAHQcjPRyX8FOMjo6rPXpO2AJ2zn2KTTo,901
|
|
147
150
|
autocoder/utils/llms.py,sha256=HM5K_v4AcuWo65lgcp66DEqaU9-fjoT7mcI1iv2Fopg,3839
|
|
148
151
|
autocoder/utils/log_capture.py,sha256=I-bsJFLWoGUiX-GKoZsH9kWJCKSV7ZlUnRt7jh-fOL0,1548
|
|
149
|
-
autocoder/utils/model_provider_selector.py,sha256=
|
|
152
|
+
autocoder/utils/model_provider_selector.py,sha256=h1eVf4F7qfSOdJbtdwv7_xfIRcNBk3fVet5w1AuvK-g,7680
|
|
150
153
|
autocoder/utils/multi_turn.py,sha256=unK9OpqVRbK6uIcTKXgggX2wNmyj7s5eyEAQ2xUwHoM,88
|
|
151
154
|
autocoder/utils/operate_config_api.py,sha256=K1lQxXNHiAYTgRDS2EGpWmjdJTrQaeP16RUWS0DIorw,5841
|
|
152
155
|
autocoder/utils/print_table.py,sha256=ZMRhCA9DD0FUfKyJBWd5bDdj1RrtPtgOMWSJwtvZcLs,403
|
|
@@ -161,9 +164,9 @@ autocoder/utils/types.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
161
164
|
autocoder/utils/auto_coder_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
162
165
|
autocoder/utils/auto_coder_utils/chat_stream_out.py,sha256=lkJ_A-sYU36JMzjFWkk3pR6uos8oZHYt9GPsPe_CPAo,11766
|
|
163
166
|
autocoder/utils/chat_auto_coder_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
164
|
-
auto_coder-0.1.
|
|
165
|
-
auto_coder-0.1.
|
|
166
|
-
auto_coder-0.1.
|
|
167
|
-
auto_coder-0.1.
|
|
168
|
-
auto_coder-0.1.
|
|
169
|
-
auto_coder-0.1.
|
|
167
|
+
auto_coder-0.1.270.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
|
168
|
+
auto_coder-0.1.270.dist-info/METADATA,sha256=WYXgsk9HU_b-oD40iNZ4r11ze3YNvWq-v2FUL0Ai5bQ,2643
|
|
169
|
+
auto_coder-0.1.270.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
170
|
+
auto_coder-0.1.270.dist-info/entry_points.txt,sha256=0nzHtHH4pNcM7xq4EBA2toS28Qelrvcbrr59GqD_0Ak,350
|
|
171
|
+
auto_coder-0.1.270.dist-info/top_level.txt,sha256=Jqc0_uJSw2GwoFQAa9iJxYns-2mWla-9ok_Y3Gcznjk,10
|
|
172
|
+
auto_coder-0.1.270.dist-info/RECORD,,
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
from typing import Generator, List, Dict, Union, Tuple, Optional
|
|
2
|
+
import os
|
|
3
|
+
import yaml
|
|
4
|
+
import byzerllm
|
|
5
|
+
import pydantic
|
|
6
|
+
import git
|
|
7
|
+
from rich.console import Console
|
|
8
|
+
from autocoder.common.printer import Printer
|
|
9
|
+
from autocoder.common import AutoCoderArgs
|
|
10
|
+
from autocoder.common.utils_code_auto_generate import stream_chat_with_continue
|
|
11
|
+
import hashlib
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def load_yaml_config(yaml_file: str) -> Dict:
|
|
15
|
+
"""加载YAML配置文件"""
|
|
16
|
+
try:
|
|
17
|
+
with open(yaml_file, 'r', encoding='utf-8') as f:
|
|
18
|
+
return yaml.safe_load(f)
|
|
19
|
+
except Exception as e:
|
|
20
|
+
printer = Printer()
|
|
21
|
+
printer.print_in_terminal("yaml_load_error", style="red", yaml_file=yaml_file, error=str(e))
|
|
22
|
+
return {}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class AutoLearnFromCommit:
|
|
26
|
+
def __init__(self, llm: Union[byzerllm.ByzerLLM,byzerllm.SimpleByzerLLM],
|
|
27
|
+
args:AutoCoderArgs,
|
|
28
|
+
skip_diff: bool = False,
|
|
29
|
+
console: Optional[Console] = None):
|
|
30
|
+
"""
|
|
31
|
+
初始化 AutoLearnFromCommit
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
llm: ByzerLLM 实例,用于代码学习
|
|
35
|
+
project_dir: 项目根目录
|
|
36
|
+
skip_diff: 是否跳过获取 diff 信息
|
|
37
|
+
"""
|
|
38
|
+
self.project_dir = args.source_dir
|
|
39
|
+
self.actions_dir = os.path.join(args.source_dir, "actions")
|
|
40
|
+
self.llm = llm
|
|
41
|
+
self.skip_diff = skip_diff
|
|
42
|
+
self.console = console or Console()
|
|
43
|
+
|
|
44
|
+
@byzerllm.prompt()
|
|
45
|
+
def learn(self, querie_with_urls_and_changes: List[Tuple[str, List[str], Dict[str, Tuple[str, str]]]], query: str) -> Generator[str,None,None]:
|
|
46
|
+
"""
|
|
47
|
+
请根据下面的代码变更,总结出通用的代码调整模式,以帮助实现类似的需求。
|
|
48
|
+
|
|
49
|
+
下面用户对本次的目标以及你需要总结的要求:
|
|
50
|
+
<goal>
|
|
51
|
+
{{ query }}
|
|
52
|
+
</goal>
|
|
53
|
+
|
|
54
|
+
下面是本次提交的代码变更:
|
|
55
|
+
<changes>
|
|
56
|
+
{% for query,urls,changes in querie_with_urls_and_changes %}
|
|
57
|
+
## 原始的任务需求
|
|
58
|
+
{{ query }}
|
|
59
|
+
|
|
60
|
+
修改的文件:
|
|
61
|
+
{% for url in urls %}
|
|
62
|
+
- {{ url }}
|
|
63
|
+
{% endfor %}
|
|
64
|
+
|
|
65
|
+
代码变更:
|
|
66
|
+
{% for file_path, (before, after) in changes.items() %}
|
|
67
|
+
##File: {{ file_path }}
|
|
68
|
+
##修改前:
|
|
69
|
+
|
|
70
|
+
{{ before or "New file" }}
|
|
71
|
+
|
|
72
|
+
##File: {{ file_path }}
|
|
73
|
+
##修改后:
|
|
74
|
+
|
|
75
|
+
{{ after or "File deleted" }}
|
|
76
|
+
|
|
77
|
+
{% endfor %}
|
|
78
|
+
{% endfor %}
|
|
79
|
+
</changes>
|
|
80
|
+
|
|
81
|
+
请总结以下内容:
|
|
82
|
+
1. 代码调整模式:描述为了实现这个目标,通常需要对代码做出哪些通用调整
|
|
83
|
+
2. 关键修改点:指出本次提交中最关键或最具代表性的修改点
|
|
84
|
+
3. 潜在扩展:基于这些修改,未来类似需求可能需要进行哪些扩展
|
|
85
|
+
4. 注意事项:在实现类似功能时需要注意哪些问题
|
|
86
|
+
|
|
87
|
+
总结要求:
|
|
88
|
+
1. 总结应该抽象化,不要局限于具体实现细节
|
|
89
|
+
2. 对于每个模式都应该提供明确的适用场景
|
|
90
|
+
3. 应该考虑代码的可维护性和可扩展性
|
|
91
|
+
4. 应该指出在不同技术栈或框架下的通用性
|
|
92
|
+
"""
|
|
93
|
+
pass
|
|
94
|
+
|
|
95
|
+
def parse_history_tasks(self) -> List[Dict]:
|
|
96
|
+
"""
|
|
97
|
+
解析历史任务信息
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
List[Dict]: 每个字典包含一个历史任务的信息
|
|
101
|
+
"""
|
|
102
|
+
# 获取所有YAML文件
|
|
103
|
+
action_files = [
|
|
104
|
+
f for f in os.listdir(self.actions_dir)
|
|
105
|
+
if f[:3].isdigit() and "_" in f and f.endswith('.yml')
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
# 按序号排序
|
|
109
|
+
def get_seq(name):
|
|
110
|
+
return int(name.split("_")[0])
|
|
111
|
+
|
|
112
|
+
# 获取最新的action文件列表
|
|
113
|
+
action_files = sorted(action_files, key=get_seq)
|
|
114
|
+
action_files.reverse()
|
|
115
|
+
|
|
116
|
+
action_file = action_files[0]
|
|
117
|
+
|
|
118
|
+
querie_with_urls_and_changes = []
|
|
119
|
+
repo = git.Repo(self.project_dir)
|
|
120
|
+
|
|
121
|
+
# 收集所有query、urls和对应的文件变化
|
|
122
|
+
for yaml_file in [action_file]:
|
|
123
|
+
yaml_path = os.path.join(self.actions_dir, yaml_file)
|
|
124
|
+
config = load_yaml_config(yaml_path)
|
|
125
|
+
|
|
126
|
+
if not config:
|
|
127
|
+
continue
|
|
128
|
+
|
|
129
|
+
query = config.get('query', '')
|
|
130
|
+
urls = config.get('urls', [])
|
|
131
|
+
|
|
132
|
+
if query:
|
|
133
|
+
changes = {}
|
|
134
|
+
if not self.skip_diff:
|
|
135
|
+
# 计算文件的MD5用于匹配commit
|
|
136
|
+
with open(yaml_path, 'r', encoding='utf-8') as f:
|
|
137
|
+
yaml_content = f.read()
|
|
138
|
+
file_md5 = hashlib.md5(yaml_content.encode("utf-8")).hexdigest()
|
|
139
|
+
response_id = f"auto_coder_{yaml_file}_{file_md5}"
|
|
140
|
+
# 查找对应的commit
|
|
141
|
+
try:
|
|
142
|
+
for commit in repo.iter_commits():
|
|
143
|
+
if response_id in commit.message:
|
|
144
|
+
if commit.parents:
|
|
145
|
+
parent = commit.parents[0]
|
|
146
|
+
# 获取所有文件的前后内容
|
|
147
|
+
for diff_item in parent.diff(commit):
|
|
148
|
+
file_path = diff_item.a_path if diff_item.a_path else diff_item.b_path
|
|
149
|
+
|
|
150
|
+
# 获取变更前内容
|
|
151
|
+
before_content = None
|
|
152
|
+
try:
|
|
153
|
+
if diff_item.a_blob:
|
|
154
|
+
before_content = repo.git.show(f"{parent.hexsha}:{file_path}")
|
|
155
|
+
except git.exc.GitCommandError:
|
|
156
|
+
pass # 文件可能是新增的
|
|
157
|
+
|
|
158
|
+
# 获取变更后内容
|
|
159
|
+
after_content = None
|
|
160
|
+
try:
|
|
161
|
+
if diff_item.b_blob:
|
|
162
|
+
after_content = repo.git.show(f"{commit.hexsha}:{file_path}")
|
|
163
|
+
except git.exc.GitCommandError:
|
|
164
|
+
pass # 文件可能被删除
|
|
165
|
+
|
|
166
|
+
changes[file_path] = (before_content, after_content)
|
|
167
|
+
break
|
|
168
|
+
except git.exc.GitCommandError as e:
|
|
169
|
+
printer = Printer()
|
|
170
|
+
printer.print_in_terminal("git_command_error", style="red", error=str(e))
|
|
171
|
+
except Exception as e:
|
|
172
|
+
printer = Printer()
|
|
173
|
+
printer.print_in_terminal("get_commit_changes_error", style="red", error=str(e))
|
|
174
|
+
|
|
175
|
+
querie_with_urls_and_changes.append((query, urls, changes))
|
|
176
|
+
|
|
177
|
+
return querie_with_urls_and_changes
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def learn_from_commit(self,query: str, conversations: List[Dict]) -> Generator[str,None,None]:
|
|
181
|
+
"""
|
|
182
|
+
从最新的代码提交中学习通用模式
|
|
183
|
+
|
|
184
|
+
Returns:
|
|
185
|
+
Optional[Generator]: 学习结果生成器,如果出错则返回None
|
|
186
|
+
"""
|
|
187
|
+
printer = Printer()
|
|
188
|
+
# 获取最新的提交信息
|
|
189
|
+
changes = self.parse_history_tasks()
|
|
190
|
+
if not changes:
|
|
191
|
+
printer.print_in_terminal("no_latest_commit", style="red")
|
|
192
|
+
return None
|
|
193
|
+
|
|
194
|
+
# 调用LLM进行代码学习
|
|
195
|
+
try:
|
|
196
|
+
# 获取 prompt 内容
|
|
197
|
+
query = self.learn.prompt(changes, query)
|
|
198
|
+
new_conversations = conversations.copy()[0:-1]
|
|
199
|
+
new_conversations.append({"role": "user", "content": query})
|
|
200
|
+
# 构造对话消息
|
|
201
|
+
v = stream_chat_with_continue(
|
|
202
|
+
llm=self.llm,
|
|
203
|
+
conversations=new_conversations,
|
|
204
|
+
llm_config={}
|
|
205
|
+
)
|
|
206
|
+
return v
|
|
207
|
+
except Exception as e:
|
|
208
|
+
printer.print_in_terminal("code_learn_error", style="red", error=str(e))
|
|
209
|
+
return None
|
autocoder/auto_coder.py
CHANGED
|
@@ -1339,6 +1339,10 @@ def main(input_args: Optional[List[str]] = None):
|
|
|
1339
1339
|
from autocoder.agent.auto_review_commit import AutoReviewCommit
|
|
1340
1340
|
reviewer = AutoReviewCommit(llm=chat_llm, args=args)
|
|
1341
1341
|
v = reviewer.review_commit(query=args.query,conversations=loaded_conversations)
|
|
1342
|
+
elif "learn_from_commit" in args.action:
|
|
1343
|
+
from autocoder.agent.auto_learn_from_commit import AutoLearnFromCommit
|
|
1344
|
+
learner = AutoLearnFromCommit(llm=chat_llm, args=args)
|
|
1345
|
+
v = learner.learn_from_commit(query=args.query,conversations=loaded_conversations)
|
|
1342
1346
|
else:
|
|
1343
1347
|
# 预估token数量
|
|
1344
1348
|
estimated_input_tokens = count_tokens(json.dumps(loaded_conversations, ensure_ascii=False))
|