auto-coder 0.1.326__py3-none-any.whl → 0.1.328__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: auto-coder
3
- Version: 0.1.326
3
+ Version: 0.1.328
4
4
  Summary: AutoCoder: AutoCoder
5
5
  Author: allwefantasy
6
6
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
@@ -14,7 +14,7 @@ autocoder/command_parser.py,sha256=fx1g9E6GaM273lGTcJqaFQ-hoksS_Ik2glBMnVltPCE,1
14
14
  autocoder/lang.py,sha256=U6AjVV8Rs1uLyjFCZ8sT6WWuNUxMBqkXXIOs4S120uk,14511
15
15
  autocoder/models.py,sha256=AyoZ-Pzy0oyYUmWCxOIRiOImsqboSfRET7LO9-UOuxI,11172
16
16
  autocoder/run_context.py,sha256=IUfSO6_gp2Wt1blFWAmOpN0b0nDrTTk4LmtCYUBIoro,1643
17
- autocoder/version.py,sha256=YGdEBe_w43bQfdo8_Mx3DWCOSWhBc0wXQua_nK1cUuo,23
17
+ autocoder/version.py,sha256=HlGvNL3Ly69Nq-jP2hJayZYniYZcRGGmAugjk2TEoas,23
18
18
  autocoder/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  autocoder/agent/auto_demand_organizer.py,sha256=URAq0gSEiHeV_W4zwhOI_83kHz0Ryfj1gcfh5jwCv_w,6501
20
20
  autocoder/agent/auto_filegroup.py,sha256=pBsAkBcpFTff-9L5OwI8xhf2xPKpl-aZwz-skF2B6dc,6296
@@ -33,12 +33,12 @@ autocoder/commands/auto_web.py,sha256=Cc0eb6JN3SvFy3GD_lpSLvIqj7F1eFDTcwg1t-zDcK
33
33
  autocoder/commands/tools.py,sha256=SlMhPICWjDsloi05CfDMawCtJmbffOCjUNj_-ve-w40,31836
34
34
  autocoder/common/JupyterClient.py,sha256=O-wi6pXeAEYhAY24kDa0BINrLYvKS6rKyWe98pDClS0,2816
35
35
  autocoder/common/ShellClient.py,sha256=fM1q8t_XMSbLBl2zkCNC2J9xuyKN3eXzGm6hHhqL2WY,2286
36
- autocoder/common/__init__.py,sha256=uYI9fXA6ypxWopBeN82MjKiOvT9b-xx0U5wI3AztGQc,14170
36
+ autocoder/common/__init__.py,sha256=1Z_dSYnGeeIPUm7RfhKagf2EfoWTI__vihGYoGpk9Vg,14330
37
37
  autocoder/common/action_yml_file_manager.py,sha256=DdF5P1R_B_chCnnqoA2IgogakWLZk_nItiJZUfX0_Wo,17857
38
38
  autocoder/common/anything2images.py,sha256=0ILBbWzY02M-CiWB-vzuomb_J1hVdxRcenAfIrAXq9M,25283
39
39
  autocoder/common/anything2img.py,sha256=iZQmg8srXlD7N5uGl5b_ONKJMBjYoW8kPmokkG6ISF0,10118
40
40
  autocoder/common/audio.py,sha256=Kn9nWKQddWnUrAz0a_ZUgjcu4VUU_IcZBigT7n3N3qc,7439
41
- autocoder/common/auto_coder_lang.py,sha256=4wH_lGZhoj0qA64J14OecsTa3PSRu35BCAlsRssgvYI,37888
41
+ autocoder/common/auto_coder_lang.py,sha256=38dnkZe5Hg2zUKs8eDn7NJUHochG14LSM8KYvFajlyo,38516
42
42
  autocoder/common/auto_configure.py,sha256=D4N-fl9v8bKM5-Ds-uhkC2uGDmHH_ZjLJ759F8KXMKs,13129
43
43
  autocoder/common/buildin_tokenizer.py,sha256=L7d5t39ZFvUd6EoMPXUhYK1toD0FHlRH1jtjKRGokWU,1236
44
44
  autocoder/common/chunk_validation.py,sha256=BrR_ZWavW8IANuueEE7hS8NFAwEvm8TX34WnPx_1hs8,3030
@@ -83,7 +83,7 @@ autocoder/common/search.py,sha256=245iPFgWhMldoUK3CqCP89ltaxZiNPK73evoG6Fp1h8,16
83
83
  autocoder/common/search_replace.py,sha256=GphFkc57Hb673CAwmbiocqTbw8vrV7TrZxtOhD0332g,22147
84
84
  autocoder/common/shells.py,sha256=elminFpNosnV0hsEUcsugDxlGO8NfH96uah-8bkaBvA,19929
85
85
  autocoder/common/stats_panel.py,sha256=wGl9O45pjVVDxhNumLv4_NfLYSlUP_18Tw4hcJSjw50,4596
86
- autocoder/common/stream_out_type.py,sha256=XWONDrdNsWQTSzloVJSwbKD_Tacxe9mX_ozXdl-5VIc,379
86
+ autocoder/common/stream_out_type.py,sha256=W_NUBa0qCo8ufhwGOuKXjekFTYKBKlVHtpFBmbWnoEM,502
87
87
  autocoder/common/sys_prompt.py,sha256=JlexfjZt554faqbgkCmzOJqYUzDHfbnxly5ugFfHfEE,26403
88
88
  autocoder/common/text.py,sha256=KGRQq314GHBmY4MWG8ossRoQi1_DTotvhxchpn78c-k,1003
89
89
  autocoder/common/token_cost_caculate.py,sha256=MSWJtl7YpQSUt-gFQoqUcJMblyPqHXe2ZioiZOFkV80,10085
@@ -102,9 +102,21 @@ autocoder/common/v2/code_auto_merge_diff.py,sha256=xh93G9Gn8zSRhGq6L90tlodFM2u-g
102
102
  autocoder/common/v2/code_auto_merge_editblock.py,sha256=FpXdHAuHhtOLXybrUd2e1rDrxqoge-CpUyWpX0yNEv8,22018
103
103
  autocoder/common/v2/code_auto_merge_strict_diff.py,sha256=jIIedNZGW52dhSmNxb3vB7UdJZp8tg59Z2gg3sCpqoM,10117
104
104
  autocoder/common/v2/code_diff_manager.py,sha256=ciXviNjldX9ce9lgIvmWoG_8JT2GnwRW8U7QCWVdAH0,10512
105
- autocoder/common/v2/code_editblock_manager.py,sha256=vnqXHKSmp6U6Kb1esSO2NRZ7j1Bh5KTaGY6ZxX-6324,11750
105
+ autocoder/common/v2/code_editblock_manager.py,sha256=nFhk7oNznOnTgtIX4A3Perw5pWYaANS-EL7SctP0z5I,15908
106
106
  autocoder/common/v2/code_manager.py,sha256=C403bS-f6urixwitlKHcml-J03hci-UyNwHJOqBiY6Q,9182
107
107
  autocoder/common/v2/code_strict_diff_manager.py,sha256=v-J1kDyLg7tLGg_6_lbO9S4fNkx7M_L8Xr2G7fPptiU,9347
108
+ autocoder/compilers/__init__.py,sha256=C0HOms70QA747XD0uZEMmGtRFcIPenohyqECNStv0Bw,1647
109
+ autocoder/compilers/base_compiler.py,sha256=dsTzMO4H_RoqWfE-SntIk2B52hWuvSlWVLtkdCbHgGs,3244
110
+ autocoder/compilers/compiler_config_api.py,sha256=QRSwWm_EX7jSeZ3dtQqM9HI__x5aZ7U0c3fHIW_2N48,13839
111
+ autocoder/compilers/compiler_config_manager.py,sha256=tNwHEk3t2o2L7ZVpHICDEOOIXRQezkg6oCaa3QDEW-s,10742
112
+ autocoder/compilers/compiler_factory.py,sha256=SLUdvBZdqr_pkY-lfArHCuBVjtiMoIs9uxCGztYj6Ro,10950
113
+ autocoder/compilers/java_compiler.py,sha256=gR-_GB0_A1ZU3cTgRu1H9VPtLPmCWYo2UwBLEZIMvXU,26362
114
+ autocoder/compilers/models.py,sha256=ZqGQhiF5vfsK71xzLlsCUS_q_Oune3mqokJ8S8ZOPSc,9527
115
+ autocoder/compilers/provided_compiler.py,sha256=UoxXAMcNlbaUxi7f2-cr_z1idJF6aZ7jI66CjxRpc0k,12850
116
+ autocoder/compilers/python_compiler.py,sha256=2w2OM_6H0ZWvaquQpDo1x4VciBWczCZkfwmEyJEEpn8,14389
117
+ autocoder/compilers/reactjs_compiler.py,sha256=h1_9OqiA8ca84-u3DIxQifvtH-2FSsKFWmhwALzNhqM,18159
118
+ autocoder/compilers/shadow_compiler.py,sha256=ARx2DBr1U521u7kKnZqg3GbLMi8ggGaX5D7VEckej3U,1699
119
+ autocoder/compilers/vue_compiler.py,sha256=_wOjaDdz8FiameLML_PxHZb_uP24AVenhJVO1lRNP4Q,19745
108
120
  autocoder/data/byzerllm.md,sha256=SGCMpEaUQ0ysPxQsgzyyp5sgvEr8dZsxEGAfVcPBIq0,47741
109
121
  autocoder/data/tokenizer.json,sha256=7Lb5_DaYlDRvBRH0B0ynXO5c1fOwbQLxujX805-OEh0,7847602
110
122
  autocoder/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -117,7 +129,7 @@ autocoder/dispacher/actions/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQ
117
129
  autocoder/dispacher/actions/plugins/action_regex_project.py,sha256=Vp07ANh0LlHoVPLM9ovTiIKv1gsUuCF57Gje4XiFVDA,8000
118
130
  autocoder/dispacher/actions/plugins/action_translate.py,sha256=GEn7dZA22jy5WyzINomjmzzB795p2Olg-CJla97lRF8,7744
119
131
  autocoder/events/__init__.py,sha256=1x_juwr9Ows2RADDa2LyI4QlmPxOVOXZeLO1cht-slM,1443
120
- autocoder/events/event_content.py,sha256=0unVmskGrfvnsniLvNXobco9KG-r6cv_C-gXK3L5zXQ,11557
132
+ autocoder/events/event_content.py,sha256=g55Z55s-ud9IzYp6u7BnLSsHHAAg34w1jrHo-C1w68A,12280
121
133
  autocoder/events/event_manager.py,sha256=WsEog4diXPsidCcN-Ycm18iPbX21PBibkcmjee-aRcQ,11739
122
134
  autocoder/events/event_manager_singleton.py,sha256=8aBp97fgbas0KYrpHbljTg2n4RcWd85SOgQITu47ZWA,8809
123
135
  autocoder/events/event_store.py,sha256=y6tT3P-o3yhDptrKi-UmqI_ZBNg7v21FriI3f7lo_ME,12709
@@ -127,7 +139,7 @@ autocoder/helper/project_creator.py,sha256=RITjVfZ_Y5zytSHTNYiwxfn2Eqfvf2Ywe13e6
127
139
  autocoder/index/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
128
140
  autocoder/index/entry.py,sha256=a8KhkNd6tKuD6W9fh9ohdri2r4UYeZWswi14pVwpr-Q,15740
129
141
  autocoder/index/for_command.py,sha256=BFvljE4t6VaMBGboZAuhUCzVK0EitCy_n5D_7FEnihw,3204
130
- autocoder/index/index.py,sha256=Y72N_w6tdI-Lv3GhgGDeCKxKfSzhxpdVuZpSAdJTsDU,30831
142
+ autocoder/index/index.py,sha256=-_GtT67ERxqdI4ajDyWr2cTsordpG_G9SYSwbTxDAcA,32491
131
143
  autocoder/index/symbols_utils.py,sha256=_EP7E_qWXxluAxq3FGZLlLfdrfwx3FmxCdulI8VGuac,2244
132
144
  autocoder/index/types.py,sha256=a2s_KV5FJlq7jqA2ELSo9E1sjuLwDB-JJYMhSpzBAhU,596
133
145
  autocoder/index/filter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -143,8 +155,8 @@ autocoder/linters/reactjs_linter.py,sha256=HUDm6oNwlJ7V8l22mj_2nfZUx23m5W7-v2tgW
143
155
  autocoder/linters/shadow_linter.py,sha256=LIbv21g9DJ_gK4fAV-zSaCQdVgSoASFGmWaydokNsEg,14810
144
156
  autocoder/linters/vue_linter.py,sha256=ZyvoxT0kSizFh_UkR7UZYO5DV9edbvDQZaibEF9W95I,20905
145
157
  autocoder/memory/__init__.py,sha256=5FeGvsesRViYL4BkFiHw9SdlyHeWlqALpTyqOpfnBRw,179
146
- autocoder/memory/active_context_manager.py,sha256=IhBRHK-muaN3-RCPcEY52erQpv9MtE6HNDD8JBcdBgI,33666
147
- autocoder/memory/active_package.py,sha256=S42zypuVg2hbQ0gaeZML9PmIboJMGuijfOmdKJ1AVgo,25500
158
+ autocoder/memory/active_context_manager.py,sha256=TFyGDKbiHVgaKK4PlDUPE8SuvjVQNf3Paq2mCsbtZJI,33681
159
+ autocoder/memory/active_package.py,sha256=NHLLnncFSfFcOFLWILwJLuEVd4nOoL0mqzFev6QHgzU,25480
148
160
  autocoder/memory/async_processor.py,sha256=htHzLGupw9IHQAEdLe2AEaALZSItPi3AltDt8FMTRHk,4643
149
161
  autocoder/memory/directory_mapper.py,sha256=BXHblOdRpeZb7URDECALp9uN5oi91KmkW9g_UaWFuZY,2513
150
162
  autocoder/plugins/__init__.py,sha256=uc8UNSAVb9uQvr5zUSS-Xu_RhrdbO2i3w2NhkrVtODM,43023
@@ -199,7 +211,7 @@ autocoder/rag/stream_event/types.py,sha256=rtLwOE8rShmi1dJdxyBpAV5ZjLBGG9vptMiSz
199
211
  autocoder/regex_project/__init__.py,sha256=EBZeCL5ORyD_9_5u_UuG4s7XtpXOu0y1sWDmxWFtufE,6781
200
212
  autocoder/regexproject/__init__.py,sha256=OGlfVe2yulGIZstACbVePVbNXajvVLRFyubnIc-9Gw0,9758
201
213
  autocoder/shadows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
202
- autocoder/shadows/shadow_manager.py,sha256=MCJXbGNALwfOZTFGBnPN5KVSgxOULZTlFtxP3IOcpqI,7701
214
+ autocoder/shadows/shadow_manager.py,sha256=pRojC9vW6Thhb1WcUtW_NvShsAh7fRP_HZHaKTKc5Aw,19189
203
215
  autocoder/suffixproject/__init__.py,sha256=EOb8eUqfu3ka8mrggkXUfwX3SWnxqEoiYmDF7Zkf0F8,11143
204
216
  autocoder/tsproject/__init__.py,sha256=LPehIUgzFbZ5DT_Pc0a_xCQQXEDxACPTMwXfFF7rcL0,11836
205
217
  autocoder/utils/__init__.py,sha256=W47ac6IOZhNR1rdbho9fvhHnPI_N1i4oMcZOwxLelbU,1123
@@ -226,9 +238,9 @@ autocoder/utils/types.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
226
238
  autocoder/utils/auto_coder_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
227
239
  autocoder/utils/auto_coder_utils/chat_stream_out.py,sha256=xuBeWD0YOckqRo8JB1WkVIMOYH6c24m7JfV4svBfPDo,15113
228
240
  autocoder/utils/chat_auto_coder_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
229
- auto_coder-0.1.326.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
230
- auto_coder-0.1.326.dist-info/METADATA,sha256=aHhdCGHnZfnbnfXPguIXzw8gTa4xtOPdRMrvr3pjgbs,2747
231
- auto_coder-0.1.326.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
232
- auto_coder-0.1.326.dist-info/entry_points.txt,sha256=0nzHtHH4pNcM7xq4EBA2toS28Qelrvcbrr59GqD_0Ak,350
233
- auto_coder-0.1.326.dist-info/top_level.txt,sha256=Jqc0_uJSw2GwoFQAa9iJxYns-2mWla-9ok_Y3Gcznjk,10
234
- auto_coder-0.1.326.dist-info/RECORD,,
241
+ auto_coder-0.1.328.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
242
+ auto_coder-0.1.328.dist-info/METADATA,sha256=sFysRPR1uSbzXhwUDQPMBbERsQkV-7CKzno3mBFIE-8,2747
243
+ auto_coder-0.1.328.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
244
+ auto_coder-0.1.328.dist-info/entry_points.txt,sha256=0nzHtHH4pNcM7xq4EBA2toS28Qelrvcbrr59GqD_0Ak,350
245
+ auto_coder-0.1.328.dist-info/top_level.txt,sha256=Jqc0_uJSw2GwoFQAa9iJxYns-2mWla-9ok_Y3Gcznjk,10
246
+ auto_coder-0.1.328.dist-info/RECORD,,
@@ -419,7 +419,12 @@ class AutoCoderArgs(pydantic.BaseModel):
419
419
  revert_commit_id: Optional[str] = None
420
420
 
421
421
  enable_auto_fix_lint: Optional[bool] = False
422
+ enable_auto_fix_compile: Optional[bool] = False
423
+
422
424
  auto_fix_lint_max_attempts: Optional[int] = 5
425
+ auto_fix_compile_max_attempts: Optional[int] = 5
426
+
427
+ ignore_clean_shadows: Optional[bool] = False
423
428
 
424
429
  class Config:
425
430
  protected_namespaces = ()
@@ -757,6 +757,22 @@ MESSAGES = {
757
757
  "max_attempts_reached": {
758
758
  "en": "Maximum correction attempts reached",
759
759
  "zh": "已达到最大修复尝试次数"
760
+ },
761
+ "compile_success": {
762
+ "en": "Compile success",
763
+ "zh": "编译成功"
764
+ },
765
+ "compile_failed": {
766
+ "en": "Compile failed",
767
+ "zh": "编译失败"
768
+ },
769
+ "compile_attempt_status": {
770
+ "en": "Compile attempt {{attempt}}/{{max_correction_attempts}}: {{error_count}} errors found. {{ formatted_issues }}",
771
+ "zh": "编译尝试 {{attempt}}/{{max_correction_attempts}}: 发现 {{error_count}} 个错误. {{ formatted_issues }}"
772
+ },
773
+ "max_compile_attempts_reached": {
774
+ "en": "Maximum compilation attempts reached",
775
+ "zh": "已达到最大编译尝试次数"
760
776
  }
761
777
  }
762
778
 
@@ -15,3 +15,9 @@ class CodeRankStreamOutType(Enum):
15
15
 
16
16
  class LintStreamOutType(Enum):
17
17
  LINT = "lint"
18
+
19
+ class CompileStreamOutType(Enum):
20
+ COMPILE = "compile"
21
+
22
+ class IndexStreamOutType(Enum):
23
+ INDEX_BUILD = "index_build"
@@ -10,10 +10,11 @@ from byzerllm.utils.client import code_utils
10
10
  from autocoder.common.types import Mode, CodeGenerateResult, MergeCodeWithoutEffect
11
11
  from autocoder.common import AutoCoderArgs, git_utils, SourceCodeList
12
12
  from autocoder.common import sys_prompt
13
+ from autocoder.compilers.shadow_compiler import ShadowCompiler
13
14
  from autocoder.privacy.model_filter import ModelPathFilter
14
15
  from autocoder.common.utils_code_auto_generate import chat_with_continue, stream_chat_with_continue, ChatWithContinueResult
15
16
  from autocoder.utils.auto_coder_utils.chat_stream_out import stream_out
16
- from autocoder.common.stream_out_type import LintStreamOutType
17
+ from autocoder.common.stream_out_type import LintStreamOutType, CompileStreamOutType
17
18
  from autocoder.common.auto_coder_lang import get_message_with_format
18
19
  from autocoder.common.printer import Printer
19
20
  from autocoder.rag.token_counter import count_tokens
@@ -54,7 +55,8 @@ class CodeEditBlockManager:
54
55
  self.fence_0 = fence_0
55
56
  self.fence_1 = fence_1
56
57
  self.generate_times_same_model = args.generate_times_same_model
57
- self.max_correction_attempts = args.auto_fix_lint_max_attempts
58
+ self.auto_fix_lint_max_attempts = args.auto_fix_lint_max_attempts
59
+ self.auto_fix_compile_max_attempts = args.auto_fix_compile_max_attempts
58
60
  self.printer = Printer()
59
61
 
60
62
  # Initialize sub-components
@@ -63,8 +65,11 @@ class CodeEditBlockManager:
63
65
  self.code_merger = CodeAutoMergeEditBlock(llm, args, fence_0, fence_1)
64
66
 
65
67
  # Create shadow manager for linting
66
- self.shadow_manager = ShadowManager(args.source_dir, args.event_file)
68
+ self.shadow_manager = ShadowManager(
69
+ args.source_dir, args.event_file, args.ignore_clean_shadows)
67
70
  self.shadow_linter = ShadowLinter(self.shadow_manager, verbose=False)
71
+ self.shadow_compiler = ShadowCompiler(
72
+ self.shadow_manager, verbose=False)
68
73
 
69
74
  @byzerllm.prompt()
70
75
  def fix_linter_errors(self, query: str, lint_issues: str) -> str:
@@ -83,6 +88,22 @@ class CodeEditBlockManager:
83
88
  请严格遵守*SEARCH/REPLACE block*的格式。
84
89
  """
85
90
 
91
+ def fix_compile_errors(self, query: str, compile_errors: str) -> str:
92
+ """
93
+ 编译错误:
94
+ <compile_errors>
95
+ {{ compile_errors }}
96
+ </compile_errors>
97
+
98
+ 用户原始需求:
99
+ <user_query_wrapper>
100
+ {{ query }}
101
+ </user_query_wrapper>
102
+
103
+ 修复上述问题,请确保代码质量问题被解决,同时保持代码的原有功能。
104
+ 请严格遵守*SEARCH/REPLACE block*的格式。
105
+ """
106
+
86
107
  def _create_shadow_files_from_edits(self, generation_result: CodeGenerateResult) -> Dict[str, str]:
87
108
  """
88
109
  从编辑块内容中提取代码并创建临时影子文件用于检查。
@@ -169,7 +190,7 @@ class CodeEditBlockManager:
169
190
 
170
191
  def generate_and_fix(self, query: str, source_code_list: SourceCodeList) -> CodeGenerateResult:
171
192
  """
172
- 生成代码,运行linter,修复错误,最多尝试指定次数
193
+ 生成代码,运行linter/compile,修复错误,最多尝试指定次数
173
194
 
174
195
  参数:
175
196
  query (str): 用户查询
@@ -199,7 +220,7 @@ class CodeEditBlockManager:
199
220
  return generation_result
200
221
 
201
222
  # 最多尝试修复5次
202
- for attempt in range(self.max_correction_attempts):
223
+ for attempt in range(self.auto_fix_lint_max_attempts):
203
224
  global_cancel.check_and_raise()
204
225
  # 代码生成结果更新到影子文件里去
205
226
  shadow_files = self._create_shadow_files_from_edits(
@@ -231,13 +252,14 @@ class CodeEditBlockManager:
231
252
  "lint_attempt_status",
232
253
  style="yellow",
233
254
  attempt=(attempt + 1),
234
- max_correction_attempts=self.max_correction_attempts,
255
+ max_correction_attempts=self.auto_fix_lint_max_attempts,
235
256
  error_count=error_count,
236
257
  formatted_issues=formatted_issues
237
258
  )
238
259
 
260
+ # 把lint结果记录到事件系统
239
261
  get_event_manager(self.args.event_file).write_result(EventContentCreator.create_result(
240
- content=EventContentCreator.ResultContent(content=f"Lint attempt {attempt + 1}/{self.max_correction_attempts}: Found {error_count} issues:\n {formatted_issues}",
262
+ content=EventContentCreator.ResultContent(content=f"Lint attempt {attempt + 1}/{self.auto_fix_lint_max_attempts}: Found {error_count} issues:\n {formatted_issues}",
241
263
  metadata={}
242
264
  ).to_dict(),
243
265
  metadata={
@@ -246,7 +268,7 @@ class CodeEditBlockManager:
246
268
  }
247
269
  ))
248
270
 
249
- if attempt == self.max_correction_attempts - 1:
271
+ if attempt == self.auto_fix_lint_max_attempts - 1:
250
272
  self.printer.print_in_terminal(
251
273
  "max_attempts_reached", style="yellow")
252
274
  break
@@ -267,6 +289,8 @@ class CodeEditBlockManager:
267
289
  shadow_files)
268
290
  generation_result = self.code_generator.single_round_run(
269
291
  fix_prompt, source_code_list)
292
+
293
+ # 计算这次修复lint 问题花费的token情况
270
294
  token_cost_calculator.track_token_usage_by_generate(
271
295
  llm=self.llm,
272
296
  generate=generation_result,
@@ -274,6 +298,66 @@ class CodeEditBlockManager:
274
298
  start_time=start_time,
275
299
  end_time=time.time()
276
300
  )
301
+
302
+ # 如果开启了自动修复compile问题,则进行compile修复
303
+ if self.args.enable_auto_fix_compile:
304
+ for attempt in range(self.auto_fix_compile_max_attempts):
305
+ global_cancel.check_and_raise()
306
+ # 先更新增量影子系统的文件
307
+ shadow_files = self._create_shadow_files_from_edits(generation_result)
308
+
309
+ # 在影子系统生成完整的项目,然后编译
310
+ compile_result = self.shadow_compiler.compile_all_shadow_files()
311
+
312
+ # 如果编译成功,则退出,继续往后走
313
+ if compile_result.success or compile_result.total_errors == 0:
314
+ self.printer.print_in_terminal(
315
+ "compile_success", style="green")
316
+ break
317
+
318
+ # 如果有错误,则把compile结果记录到事件系统
319
+ get_event_manager(self.args.event_file).write_result(EventContentCreator.create_result(
320
+ content=EventContentCreator.ResultContent(content=f"Compile attempt {attempt + 1}/{self.auto_fix_compile_max_attempts}: Found {compile_result.total_errors} errors:\n {compile_result.to_str()}",
321
+ metadata={}
322
+ ).to_dict(),
323
+ metadata={
324
+ "stream_out_type": CompileStreamOutType.COMPILE.value,
325
+ "action_file": self.args.file
326
+ }
327
+ ))
328
+
329
+ if attempt == self.auto_fix_compile_max_attempts - 1:
330
+ self.printer.print_in_terminal(
331
+ "max_compile_attempts_reached", style="yellow")
332
+ break
333
+
334
+ # 打印当前compile错误
335
+ self.printer.print_in_terminal("compile_attempt_status",
336
+ style="yellow",
337
+ attempt=(attempt + 1), max_correction_attempts=self.auto_fix_compile_max_attempts,
338
+ error_count=compile_result.total_errors,
339
+ formatted_issues=compile_result.to_str())
340
+
341
+ fix_compile_prompt = self.fix_compile_errors.prompt(
342
+ query=query,
343
+ compile_errors=compile_result.to_str()
344
+ )
345
+
346
+ # 将 shadow_files 转化为 source_code_list
347
+ start_time = time.time()
348
+ source_code_list = self.code_merger.get_source_code_list_from_shadow_files(
349
+ shadow_files)
350
+ generation_result = self.code_generator.single_round_run(
351
+ fix_compile_prompt, source_code_list)
352
+
353
+ # 计算这次修复compile 问题花费的token情况
354
+ token_cost_calculator.track_token_usage_by_generate(
355
+ llm=self.llm,
356
+ generate=generation_result,
357
+ operation_name="code_generation_complete",
358
+ start_time=start_time,
359
+ end_time=time.time()
360
+ )
277
361
 
278
362
  # 清理临时影子文件
279
363
  self.shadow_manager.clean_shadows()
@@ -0,0 +1,51 @@
1
+ """
2
+ Package for compiling code across multiple programming languages.
3
+ This package provides functionality for compiling and checking code in Python, Java, ReactJS, and Vue.js.
4
+ """
5
+
6
+ from autocoder.compilers.compiler_factory import (
7
+ CompilerFactory,
8
+ compile_file,
9
+ compile_project,
10
+ format_compile_result
11
+ )
12
+
13
+ from autocoder.compilers.models import (
14
+ CompilationError,
15
+ CompilationErrorSeverity,
16
+ CompilationErrorPosition,
17
+ FileCompilationResult,
18
+ ProjectCompilationResult
19
+ )
20
+
21
+ from autocoder.compilers.base_compiler import BaseCompiler
22
+ from autocoder.compilers.python_compiler import PythonCompiler
23
+ from autocoder.compilers.java_compiler import JavaCompiler
24
+ from autocoder.compilers.reactjs_compiler import ReactJSCompiler
25
+ from autocoder.compilers.vue_compiler import VueCompiler
26
+ from autocoder.compilers.provided_compiler import ProvidedCompiler, compile_with_provided_config
27
+ from autocoder.compilers.compiler_config_manager import CompilerConfigManager, get_compiler_config_manager
28
+ from autocoder.compilers.compiler_config_api import CompilerConfigAPI, get_compiler_config_api
29
+
30
+ __all__ = [
31
+ 'CompilerFactory',
32
+ 'compile_file',
33
+ 'compile_project',
34
+ 'format_compile_result',
35
+ 'CompilationError',
36
+ 'CompilationErrorSeverity',
37
+ 'CompilationErrorPosition',
38
+ 'FileCompilationResult',
39
+ 'ProjectCompilationResult',
40
+ 'BaseCompiler',
41
+ 'PythonCompiler',
42
+ 'JavaCompiler',
43
+ 'ReactJSCompiler',
44
+ 'VueCompiler',
45
+ 'ProvidedCompiler',
46
+ 'compile_with_provided_config',
47
+ 'CompilerConfigManager',
48
+ 'get_compiler_config_manager',
49
+ 'CompilerConfigAPI',
50
+ 'get_compiler_config_api'
51
+ ]
@@ -0,0 +1,107 @@
1
+ """
2
+ Module for code compilation capabilities across multiple programming languages.
3
+ This module provides a base abstract class for various language-specific compilers.
4
+ """
5
+
6
+ import os
7
+ from abc import ABC, abstractmethod
8
+ from typing import Dict, Any, List, Optional,Union
9
+ from autocoder.compilers.models import ProjectCompilationResult,FileCompilationResult
10
+
11
+ class BaseCompiler(ABC):
12
+ """
13
+ Base abstract class for all language-specific compilers.
14
+ """
15
+
16
+ def __init__(self, verbose: bool = False):
17
+ """
18
+ Initialize the base compiler.
19
+
20
+ Args:
21
+ verbose (bool): Whether to display verbose output.
22
+ """
23
+ self.verbose = verbose
24
+
25
+ @abstractmethod
26
+ def _check_dependencies(self) -> bool:
27
+ """
28
+ Check if required dependencies are installed.
29
+
30
+ Returns:
31
+ bool: True if all dependencies are available, False otherwise.
32
+ """
33
+ pass
34
+
35
+ @abstractmethod
36
+ def compile_file(self, file_path: str,target_compiler_name:Optional[str] = None) -> FileCompilationResult:
37
+ """
38
+ Compile a single file.
39
+
40
+ Args:
41
+ file_path (str): Path to the file to compile.
42
+
43
+ Returns:
44
+ FileCompilationResult: Compilation results.
45
+ """
46
+ pass
47
+
48
+ @abstractmethod
49
+ def compile_project(self, project_path: str,target_compiler_name:Optional[str] = None) -> ProjectCompilationResult:
50
+ """
51
+ Compile an entire project.
52
+
53
+ Args:
54
+ project_path (str): Path to the project directory.
55
+
56
+ Returns:
57
+ ProjectCompilationResult: Compilation results.
58
+ """
59
+ pass
60
+
61
+ @abstractmethod
62
+ def format_compile_result(self, compile_result: Union[ProjectCompilationResult, FileCompilationResult]) -> str:
63
+ """
64
+ Format compilation results into a human-readable string.
65
+
66
+ Args:
67
+ compile_result (Union[ProjectCompilationResult, FileCompilationResult]): The compilation result.
68
+
69
+ Returns:
70
+ str: A formatted string representation of the compilation results.
71
+ """
72
+ pass
73
+
74
+ def get_file_extension(self, file_path: str) -> str:
75
+ """
76
+ Get the file extension from a file path.
77
+
78
+ Args:
79
+ file_path (str): Path to the file.
80
+
81
+ Returns:
82
+ str: The file extension (lowercase, with dot).
83
+ """
84
+ _, ext = os.path.splitext(file_path)
85
+ return ext.lower()
86
+
87
+ def is_supported_file(self, file_path: str) -> bool:
88
+ """
89
+ Check if a file is supported by this compiler.
90
+
91
+ Args:
92
+ file_path (str): Path to the file.
93
+
94
+ Returns:
95
+ bool: True if the file is supported, False otherwise.
96
+ """
97
+ return self.get_file_extension(file_path) in self.get_supported_extensions()
98
+
99
+ @abstractmethod
100
+ def get_supported_extensions(self) -> List[str]:
101
+ """
102
+ Get the list of file extensions supported by this compiler.
103
+
104
+ Returns:
105
+ List[str]: List of supported file extensions (lowercase, with dot).
106
+ """
107
+ pass