beswarm 0.1.74__py3-none-any.whl → 0.1.76__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.
- beswarm/aient/setup.py +1 -1
- beswarm/aient/src/aient/utils/scripts.py +38 -9
- beswarm/tools/edit_file.py +10 -17
- {beswarm-0.1.74.dist-info → beswarm-0.1.76.dist-info}/METADATA +1 -1
- {beswarm-0.1.74.dist-info → beswarm-0.1.76.dist-info}/RECORD +7 -7
- {beswarm-0.1.74.dist-info → beswarm-0.1.76.dist-info}/WHEEL +0 -0
- {beswarm-0.1.74.dist-info → beswarm-0.1.76.dist-info}/top_level.txt +0 -0
beswarm/aient/setup.py
CHANGED
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
|
|
4
4
|
|
5
5
|
setup(
|
6
6
|
name="aient",
|
7
|
-
version="1.1.
|
7
|
+
version="1.1.26",
|
8
8
|
description="Aient: The Awakening of Agent.",
|
9
9
|
long_description=Path.open(Path("README.md"), encoding="utf-8").read(),
|
10
10
|
long_description_content_type="text/markdown",
|
@@ -241,17 +241,46 @@ def _sandboxed_open(file, mode='r', *args, **kwargs):
|
|
241
241
|
|
242
242
|
builtins.open = _sandboxed_open
|
243
243
|
|
244
|
-
# 2.
|
244
|
+
# 2. 智能判断原始命令是脚本、模块还是代码字符串,并执行
|
245
245
|
original_argv = sys.argv[1:]
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
246
|
+
|
247
|
+
action = None
|
248
|
+
action_arg = None
|
249
|
+
passthrough_args = []
|
250
|
+
i = 0
|
251
|
+
while i < len(original_argv):
|
252
|
+
arg = original_argv[i]
|
253
|
+
if arg == '-m':
|
254
|
+
action = 'module'
|
255
|
+
if i + 1 < len(original_argv):
|
256
|
+
action_arg = original_argv[i+1]
|
257
|
+
passthrough_args = original_argv[i+2:]
|
258
|
+
break
|
259
|
+
elif arg == '-c':
|
260
|
+
action = 'command'
|
261
|
+
if i + 1 < len(original_argv):
|
262
|
+
action_arg = original_argv[i+1]
|
263
|
+
passthrough_args = original_argv[i+2:]
|
264
|
+
break
|
265
|
+
elif arg.startswith('-'):
|
266
|
+
i += 1
|
267
|
+
else:
|
268
|
+
action = 'file'
|
269
|
+
action_arg = arg
|
270
|
+
passthrough_args = original_argv[i+1:]
|
271
|
+
break
|
272
|
+
|
273
|
+
if action == 'module' and action_arg:
|
274
|
+
sys.argv = [action_arg] + passthrough_args
|
275
|
+
runpy.run_module(action_arg, run_name='__main__')
|
276
|
+
elif action == 'command' and action_arg:
|
277
|
+
sys.argv = ['-c'] + passthrough_args
|
278
|
+
exec(action_arg, {'__name__': '__main__'})
|
279
|
+
elif action == 'file' and action_arg:
|
280
|
+
sys.argv = [action_arg] + passthrough_args
|
252
281
|
# 使用原始的 open 来读取要执行的脚本,因为它本身不应受沙箱限制
|
253
|
-
with original_open(
|
254
|
-
code = compile(f.read(),
|
282
|
+
with original_open(action_arg, 'r') as f:
|
283
|
+
code = compile(f.read(), action_arg, 'exec')
|
255
284
|
exec(code, {'__name__': '__main__'})
|
256
285
|
else:
|
257
286
|
pass
|
beswarm/tools/edit_file.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
import os
|
2
2
|
import re
|
3
|
+
import difflib
|
3
4
|
from ..aient.src.aient.plugins import register_tool
|
4
5
|
|
5
6
|
@register_tool()
|
6
|
-
def edit_file(file_path, diff_content, match_precision=0.
|
7
|
+
def edit_file(file_path, diff_content, match_precision=0.9):
|
7
8
|
"""
|
8
9
|
使用diff模式编辑代码文件。**重要:此函数每次调用只能对文件进行一处修改。**
|
9
10
|
|
@@ -22,7 +23,7 @@ def edit_file(file_path, diff_content, match_precision=0.8):
|
|
22
23
|
参数:
|
23
24
|
file_path: 要编辑的文件路径。
|
24
25
|
diff_content: 包含单次修改信息的diff字符串,格式必须符合上述要求。
|
25
|
-
match_precision: 匹配精度 (0.0-1.0)
|
26
|
+
match_precision: 匹配精度 (0.0-1.0),值越高要求匹配越精确,默认为0.9。当完全精确匹配失败时,此参数生效。
|
26
27
|
|
27
28
|
返回:
|
28
29
|
编辑结果的状态信息,包括成功或错误信息。
|
@@ -93,27 +94,19 @@ def edit_file(file_path, diff_content, match_precision=0.8):
|
|
93
94
|
for i in range(len(content_lines) - len(search_lines) + 1):
|
94
95
|
# 计算当前位置的匹配分数
|
95
96
|
match_score = 0
|
96
|
-
|
97
|
+
lines_compared = 0
|
97
98
|
|
98
99
|
for j in range(len(search_lines)):
|
99
100
|
search_line = search_lines[j]
|
100
101
|
content_line = content_lines[i + j]
|
101
102
|
|
102
|
-
#
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
if total_line_chars > 0:
|
108
|
-
line_match = common_chars / total_line_chars
|
109
|
-
match_score += line_match
|
110
|
-
total_chars += 1
|
103
|
+
# 使用 difflib 计算行相似度,该算法对插入和删除更具鲁棒性
|
104
|
+
line_match = difflib.SequenceMatcher(None, search_line, content_line).ratio()
|
105
|
+
match_score += line_match
|
106
|
+
lines_compared += 1
|
111
107
|
|
112
108
|
# 计算整体匹配分数
|
113
|
-
|
114
|
-
match_score = match_score / total_chars
|
115
|
-
else:
|
116
|
-
match_score = 0
|
109
|
+
match_score = match_score / lines_compared
|
117
110
|
|
118
111
|
# 如果使用高精度匹配 (>0.95),我们需要更严格地检查匹配结果
|
119
112
|
if match_precision > 0.95:
|
@@ -173,7 +166,7 @@ def edit_file(file_path, diff_content, match_precision=0.8):
|
|
173
166
|
if __name__ == "__main__":
|
174
167
|
edit_str = """
|
175
168
|
<<<<<<< SEARCH
|
176
|
-
parser.add_argument('--dataset',
|
169
|
+
parser.add_argument('--dataset',type=str,default='cifar10', choices=['cifar10', 'cifar100', 'imagenet'],help="Dataset to use.")
|
177
170
|
=======
|
178
171
|
parser.add_argument('--dataset', type=str, default='cifar10', choices=['cifar10', 'cifar100', 'imagenet', 'tinyimagenet'], help="Dataset to use.")
|
179
172
|
>>>>>>> REPLACE
|
@@ -1,7 +1,7 @@
|
|
1
1
|
beswarm/__init__.py,sha256=HZjUOJtZR5QhMuDbq-wukQQn1VrBusNWai_ysGo-VVI,20
|
2
2
|
beswarm/utils.py,sha256=Z2Kuus2BLp9EHUC2ZNL9iUsb6NWnPj-MTA7SYzGyg24,1755
|
3
3
|
beswarm/aient/main.py,sha256=SiYAIgQlLJqYusnTVEJOx1WNkSJKMImhgn5aWjfroxg,3814
|
4
|
-
beswarm/aient/setup.py,sha256=
|
4
|
+
beswarm/aient/setup.py,sha256=hG7eswVWMMNc-xD67iN6hCTvU9HSIiqwkbkncpEpctA,487
|
5
5
|
beswarm/aient/src/aient/__init__.py,sha256=SRfF7oDVlOOAi6nGKiJIUK6B_arqYLO9iSMp-2IZZps,21
|
6
6
|
beswarm/aient/src/aient/core/__init__.py,sha256=NxjebTlku35S4Dzr16rdSqSTWUvvwEeACe8KvHJnjPg,34
|
7
7
|
beswarm/aient/src/aient/core/log_config.py,sha256=kz2_yJv1p-o3lUQOwA3qh-LSc3wMHv13iCQclw44W9c,274
|
@@ -40,7 +40,7 @@ beswarm/aient/src/aient/prompt/__init__.py,sha256=GBtn6-JDT8KHFCcuPpfSNE_aGddg5p
|
|
40
40
|
beswarm/aient/src/aient/prompt/agent.py,sha256=ebHYebxbgL-WEAKUs1NPNwxlUMucF3GNNoy3eNZrtIo,29737
|
41
41
|
beswarm/aient/src/aient/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
42
42
|
beswarm/aient/src/aient/utils/prompt.py,sha256=UcSzKkFE4-h_1b6NofI6xgk3GoleqALRKY8VBaXLjmI,11311
|
43
|
-
beswarm/aient/src/aient/utils/scripts.py,sha256=
|
43
|
+
beswarm/aient/src/aient/utils/scripts.py,sha256=l8_NrwIRYxvzxPFg-vSJz120swdnxxGfgBcQRogJ4nI,36154
|
44
44
|
beswarm/aient/test/chatgpt.py,sha256=Hvl7FuDt1c74N5TVBmhErOPvJbJJzA7FNp5VoZM4u30,4957
|
45
45
|
beswarm/aient/test/claude.py,sha256=IyB4qI1eJLwlSfDNSnt2FhbQWYyBighHUjJxEXc3osQ,1095
|
46
46
|
beswarm/aient/test/test.py,sha256=rldnoLQdtRR8IKFSIzTti7eIK2MpPMoi9gL5qD8_K44,29
|
@@ -122,7 +122,7 @@ beswarm/queries/tree-sitter-languages/scala-tags.scm,sha256=UxQjz80JIrrJ7Pm56uUn
|
|
122
122
|
beswarm/queries/tree-sitter-languages/typescript-tags.scm,sha256=OMdCeedPiA24ky82DpgTMKXK_l2ySTuF2zrQ2fJAi9E,1253
|
123
123
|
beswarm/tools/__init__.py,sha256=YXP65SJFE1dBNRlffapdd7zsB6M6tHZ6QaQykGq7KDU,1198
|
124
124
|
beswarm/tools/click.py,sha256=TygaekCXTmU3fIu6Uom7ZcyzEgYMlCC_GX-5SmWHuLI,20762
|
125
|
-
beswarm/tools/edit_file.py,sha256=
|
125
|
+
beswarm/tools/edit_file.py,sha256=B1rAKxgd9ZksRpZysF4SOglTIp-_k0hnFK5fZ5BBvGk,8039
|
126
126
|
beswarm/tools/planner.py,sha256=lguBCS6kpwNPoXQvqH-WySabVubT82iyWOkJnjt6dXw,1265
|
127
127
|
beswarm/tools/repomap.py,sha256=N09K0UgwjCN7Zjg_5TYlVsulp3n2fztYlS8twalChU8,45003
|
128
128
|
beswarm/tools/screenshot.py,sha256=u6t8FCgW5YHJ_Oc4coo8e0F3wTusWE_-H8dFh1rBq9Q,1011
|
@@ -130,7 +130,7 @@ beswarm/tools/search_arxiv.py,sha256=9slwBemXjEqrd7-YgVmyMijPXlkhZCybEDRVhWVQ9B0
|
|
130
130
|
beswarm/tools/search_web.py,sha256=B24amOnGHnmdV_6S8bw8O2PdhZRRIDtJjg-wXcfP7dQ,11859
|
131
131
|
beswarm/tools/think.py,sha256=WLw-7jNIsnS6n8MMSYUin_f-BGLENFmnKM2LISEp0co,1760
|
132
132
|
beswarm/tools/worker.py,sha256=DLYzMgKzpf4UYGNKKJix__DHw6LHtX_T9CLVaexDQMg,12909
|
133
|
-
beswarm-0.1.
|
134
|
-
beswarm-0.1.
|
135
|
-
beswarm-0.1.
|
136
|
-
beswarm-0.1.
|
133
|
+
beswarm-0.1.76.dist-info/METADATA,sha256=REGvO25NvgVgRw3qBdQf_172ht7ZgBIDfCBYNWnR6Uk,3553
|
134
|
+
beswarm-0.1.76.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
135
|
+
beswarm-0.1.76.dist-info/top_level.txt,sha256=pJw4O87wvt5882smuSO6DfByJz7FJ8SxxT8h9fHCmpo,8
|
136
|
+
beswarm-0.1.76.dist-info/RECORD,,
|
File without changes
|
File without changes
|