auto-coder 0.1.227__py3-none-any.whl → 0.1.228__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.227
3
+ Version: 0.1.228
4
4
  Summary: AutoCoder: AutoCoder
5
5
  Author: allwefantasy
6
6
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
@@ -26,7 +26,7 @@ Requires-Dist: tabulate
26
26
  Requires-Dist: jupyter-client
27
27
  Requires-Dist: prompt-toolkit
28
28
  Requires-Dist: tokenizers
29
- Requires-Dist: byzerllm[saas] >=0.1.148
29
+ Requires-Dist: byzerllm[saas] >=0.1.149
30
30
  Requires-Dist: patch
31
31
  Requires-Dist: diff-match-patch
32
32
  Requires-Dist: GitPython
@@ -10,8 +10,8 @@ autocoder/chat_auto_coder.py,sha256=ZKj_VdoEAFPsdInf_dQeBK6lQtz8Mzz7L4nLO6l8pEY,
10
10
  autocoder/chat_auto_coder_lang.py,sha256=YJsFi8an0Kjbo9X7xKZfpdbHS3rbhrvChZNjWqEQ5Sw,11032
11
11
  autocoder/command_args.py,sha256=9aYJ-AmPxP1sQh6ciw04FWHjSn31f2W9afXFwo8wgx4,30441
12
12
  autocoder/lang.py,sha256=U6AjVV8Rs1uLyjFCZ8sT6WWuNUxMBqkXXIOs4S120uk,14511
13
- autocoder/models.py,sha256=shzX2EMArWZ7X8cS0yK4CwCJT5UPGzMaLgJwETrHdMA,5053
14
- autocoder/version.py,sha256=8GcCJXjjBKc6SzhEitvO8ub2W7HOhWSkKFq9aFDXd98,24
13
+ autocoder/models.py,sha256=DX30r_VjQK9cvYHPLYyEXuifkoJat8sRCvbOytrXwtY,5054
14
+ autocoder/version.py,sha256=Wi8xJHc_sggKQwapQNkMrXbzUQskh-gmUlZ7t1VxJmc,24
15
15
  autocoder/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  autocoder/agent/auto_demand_organizer.py,sha256=NWSAEsEk94vT3lGjfo25kKLMwYdPcpy9e-i21txPasQ,6942
17
17
  autocoder/agent/auto_filegroup.py,sha256=CW7bqp0FW1GIEMnl-blyAc2UGT7O9Mom0q66ITz1ckM,6635
@@ -36,15 +36,16 @@ autocoder/common/code_auto_generate.py,sha256=5lEW9iudGYQIcd_QjrGyGaEmrWuyZ625PN
36
36
  autocoder/common/code_auto_generate_diff.py,sha256=o5yeqpc3WXSRWlcLzhlwJNosKo7dcj0CeIsFh6Aibus,16248
37
37
  autocoder/common/code_auto_generate_editblock.py,sha256=QdUHUkGaervvQNCY8T2vQ_tfnQX_2kxxu4qq_QW_Nn8,17828
38
38
  autocoder/common/code_auto_generate_strict_diff.py,sha256=uteWDEHfIbrnVgwKgqC7qwrIeW0enJCXcHzZGa48yY8,14774
39
- autocoder/common/code_auto_merge.py,sha256=1tiKrram8GCCuPYrNvHFbr-Tic-f84Y8H13fDTdcg6c,7142
40
- autocoder/common/code_auto_merge_diff.py,sha256=5SI6ggklJ0QDHvsS0cpNXFuIkFRQxp1i08k6iwWbPJc,15242
41
- autocoder/common/code_auto_merge_editblock.py,sha256=l6yEiZqXyIlUNIIPXvkHOnLCIInXR78TzSjF-jtJkkg,17035
39
+ autocoder/common/code_auto_merge.py,sha256=CH0-6AKVLGjhWvKCFqnfSbt62rxL7ZBobFAX5FUzY5A,7164
40
+ autocoder/common/code_auto_merge_diff.py,sha256=zyA5BxNiAROyzOEJnozelarAaFK8BKgezXAbm4aq7DA,15239
41
+ autocoder/common/code_auto_merge_editblock.py,sha256=dp8PFs1inKy3u70jnt8hWLdUhL5Biz1zsjay4SXpGko,16942
42
42
  autocoder/common/code_auto_merge_strict_diff.py,sha256=ABYOTDUQYA4Bn4BwT1Rw812y49cHW3UH_JSpM9uJ6ig,9399
43
43
  autocoder/common/code_modification_ranker.py,sha256=DFlbwgdg8GK47zVcvfZSzkyniEKmTVLTOWejjcVIgaw,5121
44
44
  autocoder/common/command_completer.py,sha256=SSeb8MDH0JPvfdyW-S2uaHnui4VBDfSQvQPLbv3ORPA,9314
45
45
  autocoder/common/command_generator.py,sha256=v4LmU7sO-P7jEZIXCWHUC6P-vT7AvBi_x_PTwCqBAE8,1323
46
46
  autocoder/common/command_templates.py,sha256=mnB3n8i0yjH1mqzyClEg8Wpr9VbZV44kxky66Zu6OJY,8557
47
47
  autocoder/common/const.py,sha256=eTjhjh4Aj4CUzviJ81jaf3Y5cwqsLATySn2wJxaS6RQ,2911
48
+ autocoder/common/files.py,sha256=uGpfKASYwIncK_Vt_e_FOjFlO5VyAQOnRJe2SFdSWrg,877
48
49
  autocoder/common/git_utils.py,sha256=btK45sxvfm4tX3fBRNUPRZoGQuZuOEQrWSAwLy1yoLw,23095
49
50
  autocoder/common/image_to_page.py,sha256=O0cNO_vHHUP-fP4GXiVojShmNqkPnZXeIyiY1MRLpKg,13936
50
51
  autocoder/common/interpreter.py,sha256=62-dIakOunYB4yjmX8SHC0Gdy2h8NtxdgbpdqRZJ5vk,2833
@@ -78,7 +79,7 @@ autocoder/index/for_command.py,sha256=LGnz-OWogT8rd24m4Zcan7doLaijxqorAuiMk7WuRq
78
79
  autocoder/index/index.py,sha256=1HLwK-ylpibYjHgPommdaL1bRwGP1QGWONaNYExzqRc,34828
79
80
  autocoder/index/symbols_utils.py,sha256=CjcjUVajmJZB75Ty3a7kMv1BZphrm-tIBAdOJv6uo-0,2037
80
81
  autocoder/index/types.py,sha256=tYoFicbS6k1Dx4EoMpuNq71-4pF6hhEbtej0VYCVlSo,524
81
- autocoder/pyproject/__init__.py,sha256=7ZuIxD2QBYIwhjmpva8eL2knorKo03yNqUhSyecpt7c,14448
82
+ autocoder/pyproject/__init__.py,sha256=dQ2_7YZ7guybT9BhfxSGn43eLQJGQN2zgeKa6--JlaQ,14403
82
83
  autocoder/rag/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
83
84
  autocoder/rag/api_server.py,sha256=dRbhAZVRAOlZ64Cnxf4_rKb4iJwHnrWS9Zr67IVORw0,7288
84
85
  autocoder/rag/doc_filter.py,sha256=B99Qcy3tcNLuSz2kWbpgfBj2_Igme91zWKOJ2Niq2UY,6652
@@ -111,9 +112,9 @@ autocoder/rag/stream_event/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
111
112
  autocoder/rag/stream_event/event_writer.py,sha256=l7kq_LnDDE8E5dZ-73C7J2MgzSL7WrozdXk0eV-k55Q,409
112
113
  autocoder/rag/stream_event/types.py,sha256=rtLwOE8rShmi1dJdxyBpAV5ZjLBGG9vptMiSzMxGuIA,318
113
114
  autocoder/regex_project/__init__.py,sha256=EBZeCL5ORyD_9_5u_UuG4s7XtpXOu0y1sWDmxWFtufE,6781
114
- autocoder/regexproject/__init__.py,sha256=lHTpHfYkguCMtczXoH4bMr-IMNZQtXIjmtSvjtfX0Ro,9674
115
- autocoder/suffixproject/__init__.py,sha256=2dBat5ZuYIPVCuDwYC58yuzHP5R79JLzGXnZHisLLGo,11061
116
- autocoder/tsproject/__init__.py,sha256=77hu4rBcicnXHBwKtBo8RQnd61R--gQbo9s00w-ICvg,11719
115
+ autocoder/regexproject/__init__.py,sha256=cEr-ZOaQjLD5sx7T7F2DhD5ips03HcJ02rded9EpSXc,9693
116
+ autocoder/suffixproject/__init__.py,sha256=cmP54Y01ditZ83tiJqw5wle0I-uJBC0aZbZ7lYNSVO8,11080
117
+ autocoder/tsproject/__init__.py,sha256=yloVzkGLnbTd4Hcj9fMO-rcjNTTx4wI3Ga41LWOSYrY,11747
117
118
  autocoder/utils/__init__.py,sha256=KtcGElFNBgZPF7dEL8zF9JpXkCAjoyDrzaREJBhJrcs,994
118
119
  autocoder/utils/_markitdown.py,sha256=RU88qn4eZfYIy0GDrPxlI8oYXIypbi63VRJjdlnE0VU,47431
119
120
  autocoder/utils/coder.py,sha256=rK8e0svQBe0NOP26dIGToUXgha_hUDgxlWoC_p_r7oc,5698
@@ -126,11 +127,11 @@ autocoder/utils/print_table.py,sha256=ZMRhCA9DD0FUfKyJBWd5bDdj1RrtPtgOMWSJwtvZcL
126
127
  autocoder/utils/queue_communicate.py,sha256=buyEzdvab1QA4i2QKbq35rG5v_9x9PWVLWWMTznWcYM,6832
127
128
  autocoder/utils/request_event_queue.py,sha256=r3lo5qGsB1dIjzVQ05dnr0z_9Z3zOkBdP1vmRciKdi4,2095
128
129
  autocoder/utils/request_queue.py,sha256=nwp6PMtgTCiuwJI24p8OLNZjUiprC-TsefQrhMI-yPE,3889
129
- autocoder/utils/rest.py,sha256=HawagAap3wMIDROGhY1730zSZrJR_EycODAA5qOj83c,8807
130
+ autocoder/utils/rest.py,sha256=opE_kBEdNQdxh350M5lUTMk5TViRfpuKP_qWc0B1lks,8861
130
131
  autocoder/utils/tests.py,sha256=BqphrwyycGAvs-5mhH8pKtMZdObwhFtJ5MC_ZAOiLq8,1340
131
- auto_coder-0.1.227.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
132
- auto_coder-0.1.227.dist-info/METADATA,sha256=wL1FIzxZxtMImRZSGTZyK4KemZ3cfHQZq0iI3Lbg9OI,2615
133
- auto_coder-0.1.227.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
134
- auto_coder-0.1.227.dist-info/entry_points.txt,sha256=0nzHtHH4pNcM7xq4EBA2toS28Qelrvcbrr59GqD_0Ak,350
135
- auto_coder-0.1.227.dist-info/top_level.txt,sha256=Jqc0_uJSw2GwoFQAa9iJxYns-2mWla-9ok_Y3Gcznjk,10
136
- auto_coder-0.1.227.dist-info/RECORD,,
132
+ auto_coder-0.1.228.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
133
+ auto_coder-0.1.228.dist-info/METADATA,sha256=EUX3bowx5PPKjP_eJj8nV1PnpRQhhjpPOWjujzpnWM8,2615
134
+ auto_coder-0.1.228.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
135
+ auto_coder-0.1.228.dist-info/entry_points.txt,sha256=0nzHtHH4pNcM7xq4EBA2toS28Qelrvcbrr59GqD_0Ak,350
136
+ auto_coder-0.1.228.dist-info/top_level.txt,sha256=Jqc0_uJSw2GwoFQAa9iJxYns-2mWla-9ok_Y3Gcznjk,10
137
+ auto_coder-0.1.228.dist-info/RECORD,,
@@ -9,6 +9,7 @@ from loguru import logger
9
9
  from autocoder.common.types import CodeGenerateResult, MergeCodeWithoutEffect
10
10
  from autocoder.common.code_modification_ranker import CodeModificationRanker
11
11
  import hashlib
12
+ from autocoder.common import files as FileUtils
12
13
 
13
14
  class PathAndCode(pydantic.BaseModel):
14
15
  path: str
@@ -135,8 +136,7 @@ class CodeAutoMerge:
135
136
  file_content_mapping[file_path] = block.content
136
137
  else:
137
138
  if file_path not in file_content_mapping:
138
- with open(file_path, "r") as f:
139
- file_content_mapping[file_path] = f.read()
139
+ file_content_mapping[file_path] = FileUtils.read_file(file_path)
140
140
  if file_content_mapping[file_path] != block.content:
141
141
  file_content_mapping[file_path] = block.content
142
142
  else:
@@ -150,7 +150,7 @@ class CodeAutoMerge:
150
150
  def _merge_code(self, content: str,force_skip_git:bool=False):
151
151
  total = 0
152
152
 
153
- file_content = open(self.args.file).read()
153
+ file_content = FileUtils.read_file(self.args.file)
154
154
  md5 = hashlib.md5(file_content.encode('utf-8')).hexdigest()
155
155
  # get the file name
156
156
  file_name = os.path.basename(self.args.file)
@@ -17,6 +17,7 @@ from autocoder.common.search_replace import (
17
17
  )
18
18
  from autocoder.common.types import CodeGenerateResult, MergeCodeWithoutEffect
19
19
  from autocoder.common.code_modification_ranker import CodeModificationRanker
20
+ from autocoder.common import files as FileUtils
20
21
 
21
22
  class PathAndCode(pydantic.BaseModel):
22
23
  path: str
@@ -438,8 +439,7 @@ class CodeAutoMergeDiff:
438
439
  errors = []
439
440
  for path, hunk in uniq:
440
441
  full_path = self.abs_root_path(path)
441
- with open(full_path) as f:
442
- content = f.read()
442
+ content = FileUtils.read_file(full_path)
443
443
 
444
444
  original, _ = hunk_to_before_after(hunk)
445
445
 
@@ -488,8 +488,7 @@ class CodeAutoMergeDiff:
488
488
  continue
489
489
 
490
490
  if full_path not in file_content_mapping:
491
- with open(full_path, "r") as f:
492
- file_content_mapping[full_path] = f.read()
491
+ file_content_mapping[full_path] = FileUtils.read_file(full_path)
493
492
 
494
493
  content = file_content_mapping[full_path]
495
494
  new_content = do_replace(full_path, content, hunk)
@@ -20,7 +20,7 @@ import json
20
20
  from typing import Union, List, Tuple
21
21
  from autocoder.common.types import CodeGenerateResult, MergeCodeWithoutEffect
22
22
  from autocoder.common.code_modification_ranker import CodeModificationRanker
23
-
23
+ from autocoder.common import files as FileUtils
24
24
 
25
25
  class PathAndCode(pydantic.BaseModel):
26
26
  path: str
@@ -235,9 +235,7 @@ class CodeAutoMergeEditBlock:
235
235
  file_content_mapping[file_path] = update
236
236
  else:
237
237
  if file_path not in file_content_mapping:
238
- with open(file_path, "r") as f:
239
- temp = f.read()
240
- file_content_mapping[file_path] = temp
238
+ file_content_mapping[file_path] = FileUtils.read_file(file_path)
241
239
  existing_content = file_content_mapping[file_path]
242
240
 
243
241
  # First try exact match
@@ -290,9 +288,7 @@ class CodeAutoMergeEditBlock:
290
288
  changes_made = True
291
289
  else:
292
290
  if file_path not in file_content_mapping:
293
- with open(file_path, "r") as f:
294
- temp = f.read()
295
- file_content_mapping[file_path] = temp
291
+ file_content_mapping[file_path] = FileUtils.read_file(file_path)
296
292
  existing_content = file_content_mapping[file_path]
297
293
  new_content = (
298
294
  existing_content.replace(head, update, 1)
@@ -0,0 +1,26 @@
1
+ def read_file(file_path):
2
+ """Read a file with automatic encoding detection.
3
+
4
+ Tries common encodings in sequence (UTF-8 > GBK > UTF-16 > Latin-1) to handle
5
+ cross-platform encoding issues between Windows and Linux systems.
6
+
7
+ Args:
8
+ file_path (str): Path to the file to read
9
+
10
+ Returns:
11
+ str: The file contents as a string
12
+
13
+ Raises:
14
+ ValueError: If the file cannot be decoded with any of the tried encodings
15
+ """
16
+ encodings = ['utf-8', 'gbk', 'utf-16', 'latin-1']
17
+
18
+ for encoding in encodings:
19
+ try:
20
+ with open(file_path, 'r', encoding=encoding) as f:
21
+ content = f.read()
22
+ return content
23
+ except UnicodeDecodeError:
24
+ continue
25
+
26
+ raise ValueError(f"无法解码文件: {file_path}。尝试的编码: {', '.join(encodings)}")
autocoder/models.py CHANGED
@@ -16,7 +16,7 @@ default_models_list = [
16
16
  "api_key_path": "api.deepseek.com"
17
17
  },
18
18
  {
19
- "name": "deepsee_chat",
19
+ "name": "deepseek_chat",
20
20
  "description": "DeepSeek Chat is for coding",
21
21
  "model_name": "deepseek-chat",
22
22
  "model_type": "saas/openai",
@@ -17,7 +17,7 @@ from pydantic import BaseModel, Field
17
17
  from rich.console import Console
18
18
  import json
19
19
  from autocoder.utils.queue_communicate import queue_communicate, CommunicateEvent, CommunicateEventType
20
-
20
+ from autocoder.common import files as FileUtils
21
21
 
22
22
  class RegPattern(BaseModel):
23
23
  pattern: str = Field(
@@ -35,9 +35,8 @@ class Level1PyProject:
35
35
 
36
36
  def get_imports_from_script(self, file_path):
37
37
  script = ""
38
- with open(file_path, "r") as file:
39
- script = file.read()
40
- tree = ast.parse(script, filename=file_path)
38
+ script = FileUtils.read_file(file_path)
39
+ tree = ast.parse(script, filename=file_path)
41
40
 
42
41
  imports = [
43
42
  node
@@ -61,8 +60,7 @@ class Level1PyProject:
61
60
  def fetch_source_code(self, import_name):
62
61
  spec = importlib.util.find_spec(import_name)
63
62
  if spec and spec.origin:
64
- with open(spec.origin, "r") as file:
65
- return file.read()
63
+ return FileUtils.read_file(spec.origin)
66
64
  return None
67
65
 
68
66
  @byzerllm.prompt(render="jinja")
@@ -188,8 +186,7 @@ class PyProject:
188
186
  result.append(f"{line_number}:{line}")
189
187
  return "\n".join(result)
190
188
 
191
- with open(file_path, "r") as file:
192
- return file.read()
189
+ return FileUtils.read_file(file_path)
193
190
 
194
191
  def convert_to_source_code(self, file_path):
195
192
  module_name = file_path
@@ -12,7 +12,7 @@ from pydantic import BaseModel, Field
12
12
  from rich.console import Console
13
13
  import json
14
14
  from autocoder.utils.queue_communicate import queue_communicate, CommunicateEvent, CommunicateEventType
15
-
15
+ from autocoder.common import files as FileUtils
16
16
 
17
17
  class RegPattern(BaseModel):
18
18
  pattern: str = Field(
@@ -84,8 +84,7 @@ class RegexProject:
84
84
  return re.search(self.regex_pattern, file_path) is not None
85
85
 
86
86
  def read_file_content(self, file_path):
87
- with open(file_path, "r") as file:
88
- return file.read()
87
+ return FileUtils.read_file(file_path)
89
88
 
90
89
  def convert_to_source_code(self, file_path):
91
90
  module_name = file_path
@@ -12,7 +12,7 @@ from pydantic import BaseModel, Field
12
12
  from rich.console import Console
13
13
  import json
14
14
  from autocoder.utils.queue_communicate import queue_communicate, CommunicateEvent, CommunicateEventType
15
-
15
+ from autocoder.common import files as FileUtils
16
16
 
17
17
  class RegPattern(BaseModel):
18
18
  pattern: str = Field(
@@ -120,8 +120,7 @@ class SuffixProject:
120
120
  return any([file_path.endswith(suffix) for suffix in self.suffixs])
121
121
 
122
122
  def read_file_content(self, file_path):
123
- with open(file_path, "r") as file:
124
- return file.read()
123
+ return FileUtils.read_file(file_path)
125
124
 
126
125
  def convert_to_source_code(self, file_path):
127
126
  module_name = file_path
@@ -14,6 +14,7 @@ from pydantic import BaseModel, Field
14
14
  from rich.console import Console
15
15
  import json
16
16
  from autocoder.utils.queue_communicate import queue_communicate, CommunicateEvent, CommunicateEventType
17
+ from autocoder.common import files as FileUtils
17
18
 
18
19
 
19
20
  class RegPattern(BaseModel):
@@ -107,8 +108,7 @@ class TSProject:
107
108
  return open(self.target_file, "r").read()
108
109
 
109
110
  def read_file_content(self, file_path):
110
- with open(file_path, "r") as file:
111
- return file.read()
111
+ return FileUtils.read_file(file_path)
112
112
 
113
113
  def is_likely_useful_file(self, file_path):
114
114
  # Ignore common build output, dependency and configuration directories
autocoder/utils/rest.py CHANGED
@@ -7,6 +7,7 @@ from bs4 import BeautifulSoup
7
7
  from loguru import logger
8
8
  import os
9
9
  from pathlib import Path
10
+ from autocoder.common import files as FileUtils
10
11
 
11
12
  class HttpDoc:
12
13
  def __init__(self, args, llm: byzerllm.ByzerLLM,urls:Optional[List[str]]=None):
@@ -112,7 +113,7 @@ class HttpDoc:
112
113
  return temp_documents
113
114
 
114
115
  if ext not in exts.keys():
115
- main_content = open(file_path, "r").read()
116
+ main_content = FileUtils.read_file(file_path)
116
117
  source_code = SourceCode(module_name=file_path, source_code=main_content)
117
118
  source_codes.append(source_code)
118
119
  else:
@@ -135,7 +136,7 @@ class HttpDoc:
135
136
 
136
137
  except ImportError as e:
137
138
  logger.warning(f"Failed to import llama_index. Please install it using 'pip install llama_index' {e}")
138
- main_content = open(url, "r").read()
139
+ main_content = FileUtils.read_file(url)
139
140
  source_code = SourceCode(module_name=url, source_code=main_content)
140
141
  source_codes.append(source_code)
141
142
  else:
autocoder/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.227"
1
+ __version__ = "0.1.228"