beswarm 0.1.75__py3-none-any.whl → 0.1.77__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/plugins/excute_command.py +1 -14
- beswarm/aient/src/aient/plugins/write_file.py +1 -13
- beswarm/aient/src/aient/utils/scripts.py +13 -0
- beswarm/tools/edit_file.py +21 -18
- {beswarm-0.1.75.dist-info → beswarm-0.1.77.dist-info}/METADATA +1 -1
- {beswarm-0.1.75.dist-info → beswarm-0.1.77.dist-info}/RECORD +9 -9
- {beswarm-0.1.75.dist-info → beswarm-0.1.77.dist-info}/WHEEL +0 -0
- {beswarm-0.1.75.dist-info → beswarm-0.1.77.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.27",
|
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",
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import subprocess
|
2
2
|
from .registry import register_tool
|
3
|
-
from ..utils.scripts import sandbox
|
3
|
+
from ..utils.scripts import sandbox, unescape_html
|
4
4
|
|
5
5
|
import re
|
6
6
|
import os
|
7
|
-
import html
|
8
7
|
import select
|
9
8
|
|
10
9
|
# 检查是否在 Unix-like 系统上 (pty 模块主要用于 Unix)
|
@@ -39,18 +38,6 @@ def compare_line(line: str) -> bool:
|
|
39
38
|
# print(f"similarity: {similarity}")
|
40
39
|
return similarity > 0.89
|
41
40
|
|
42
|
-
def unescape_html(input_string: str) -> str:
|
43
|
-
"""
|
44
|
-
将字符串中的 HTML 实体(例如 &)转换回其原始字符(例如 &)。
|
45
|
-
|
46
|
-
Args:
|
47
|
-
input_string: 包含 HTML 实体的输入字符串。
|
48
|
-
|
49
|
-
Returns:
|
50
|
-
转换后的字符串。
|
51
|
-
"""
|
52
|
-
return html.unescape(input_string)
|
53
|
-
|
54
41
|
def get_python_executable(command: str) -> str:
|
55
42
|
"""
|
56
43
|
获取 Python 可执行文件的路径。
|
@@ -1,19 +1,7 @@
|
|
1
1
|
from .registry import register_tool
|
2
|
+
from ..utils.scripts import unescape_html
|
2
3
|
|
3
4
|
import os
|
4
|
-
import html
|
5
|
-
|
6
|
-
def unescape_html(input_string: str) -> str:
|
7
|
-
"""
|
8
|
-
将字符串中的 HTML 实体(例如 &)转换回其原始字符(例如 &)。
|
9
|
-
|
10
|
-
Args:
|
11
|
-
input_string: 包含 HTML 实体的输入字符串。
|
12
|
-
|
13
|
-
Returns:
|
14
|
-
转换后的字符串。
|
15
|
-
"""
|
16
|
-
return html.unescape(input_string)
|
17
5
|
|
18
6
|
@register_tool()
|
19
7
|
def write_to_file(path, content, mode='w'):
|
@@ -202,6 +202,19 @@ def parse_tools_from_cursor_prompt(text):
|
|
202
202
|
print(f"解析 JSON 时出错: {e}")
|
203
203
|
return []
|
204
204
|
|
205
|
+
import html
|
206
|
+
def unescape_html(input_string: str) -> str:
|
207
|
+
"""
|
208
|
+
将字符串中的 HTML 实体(例如 &)转换回其原始字符(例如 &)。
|
209
|
+
|
210
|
+
Args:
|
211
|
+
input_string: 包含 HTML 实体的输入字符串。
|
212
|
+
|
213
|
+
Returns:
|
214
|
+
转换后的字符串。
|
215
|
+
"""
|
216
|
+
return html.unescape(input_string)
|
217
|
+
|
205
218
|
import sys
|
206
219
|
import shlex
|
207
220
|
import builtins
|
beswarm/tools/edit_file.py
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
import os
|
2
2
|
import re
|
3
|
+
import difflib
|
3
4
|
from ..aient.src.aient.plugins import register_tool
|
5
|
+
from ..aient.src.aient.utils.scripts import unescape_html
|
4
6
|
|
5
7
|
@register_tool()
|
6
|
-
def edit_file(file_path, diff_content, match_precision=0.
|
8
|
+
def edit_file(file_path, diff_content, match_precision=0.9):
|
7
9
|
"""
|
8
10
|
使用diff模式编辑代码文件。**重要:此函数每次调用只能对文件进行一处修改。**
|
9
11
|
|
@@ -22,7 +24,7 @@ def edit_file(file_path, diff_content, match_precision=0.8):
|
|
22
24
|
参数:
|
23
25
|
file_path: 要编辑的文件路径。
|
24
26
|
diff_content: 包含单次修改信息的diff字符串,格式必须符合上述要求。
|
25
|
-
match_precision: 匹配精度 (0.0-1.0)
|
27
|
+
match_precision: 匹配精度 (0.0-1.0),值越高要求匹配越精确,默认为0.9。当完全精确匹配失败时,此参数生效。
|
26
28
|
|
27
29
|
返回:
|
28
30
|
编辑结果的状态信息,包括成功或错误信息。
|
@@ -63,6 +65,8 @@ def edit_file(file_path, diff_content, match_precision=0.8):
|
|
63
65
|
# 应用每个diff块
|
64
66
|
new_content = content
|
65
67
|
for search_block, replace_block in diff_blocks:
|
68
|
+
search_block = unescape_html(search_block)
|
69
|
+
replace_block = unescape_html(replace_block)
|
66
70
|
# 检查搜索块是否为空
|
67
71
|
if not search_block.strip():
|
68
72
|
return f"错误: 搜索块不能为空"
|
@@ -93,27 +97,19 @@ def edit_file(file_path, diff_content, match_precision=0.8):
|
|
93
97
|
for i in range(len(content_lines) - len(search_lines) + 1):
|
94
98
|
# 计算当前位置的匹配分数
|
95
99
|
match_score = 0
|
96
|
-
|
100
|
+
lines_compared = 0
|
97
101
|
|
98
102
|
for j in range(len(search_lines)):
|
99
103
|
search_line = search_lines[j]
|
100
104
|
content_line = content_lines[i + j]
|
101
105
|
|
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
|
106
|
+
# 使用 difflib 计算行相似度,该算法对插入和删除更具鲁棒性
|
107
|
+
line_match = difflib.SequenceMatcher(None, search_line, content_line).ratio()
|
108
|
+
match_score += line_match
|
109
|
+
lines_compared += 1
|
111
110
|
|
112
111
|
# 计算整体匹配分数
|
113
|
-
|
114
|
-
match_score = match_score / total_chars
|
115
|
-
else:
|
116
|
-
match_score = 0
|
112
|
+
match_score = match_score / lines_compared
|
117
113
|
|
118
114
|
# 如果使用高精度匹配 (>0.95),我们需要更严格地检查匹配结果
|
119
115
|
if match_precision > 0.95:
|
@@ -146,7 +142,14 @@ def edit_file(file_path, diff_content, match_precision=0.8):
|
|
146
142
|
total_original_lines += original_lines
|
147
143
|
total_new_lines += new_lines
|
148
144
|
else:
|
149
|
-
|
145
|
+
error_message = f"错误: 在文件中未找到足够匹配的代码块,最佳匹配分数为 {best_match_score:.2f},但要求为 {match_precision:.2f}。"
|
146
|
+
if best_match_index != -1:
|
147
|
+
start_index = max(0, best_match_index - len(search_lines))
|
148
|
+
end_index = min(len(content_lines), best_match_index + 2 * len(search_lines))
|
149
|
+
context_lines = content_lines[start_index:end_index]
|
150
|
+
context_block = '\n'.join(context_lines)
|
151
|
+
error_message += f"\n\n文件的最佳匹配范围原文如下 (上下文已扩展):\n<real_file_content>\n{context_block}\n</real_file_content>"
|
152
|
+
return error_message
|
150
153
|
|
151
154
|
# 如果没有进行任何编辑,返回错误
|
152
155
|
if edits_count == 0:
|
@@ -173,7 +176,7 @@ def edit_file(file_path, diff_content, match_precision=0.8):
|
|
173
176
|
if __name__ == "__main__":
|
174
177
|
edit_str = """
|
175
178
|
<<<<<<< SEARCH
|
176
|
-
parser.add_argument('--dataset',
|
179
|
+
parser.add_argument('--dataset',type=str,default='cifar10', choices=['cifar10', 'cifar100', 'imagenet'],help="Dataset to use.")
|
177
180
|
=======
|
178
181
|
parser.add_argument('--dataset', type=str, default='cifar10', choices=['cifar10', 'cifar100', 'imagenet', 'tinyimagenet'], help="Dataset to use.")
|
179
182
|
>>>>>>> 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=TVFBwEKEXhadb_ESCtRQva9W7btAzbXZUV3sj9vyPj4,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
|
@@ -25,7 +25,7 @@ beswarm/aient/src/aient/models/vertex.py,sha256=qVD5l1Q538xXUPulxG4nmDjXE1VoV4yu
|
|
25
25
|
beswarm/aient/src/aient/plugins/__init__.py,sha256=p3KO6Aa3Lupos4i2SjzLQw1hzQTigOAfEHngsldrsyk,986
|
26
26
|
beswarm/aient/src/aient/plugins/arXiv.py,sha256=yHjb6PS3GUWazpOYRMKMzghKJlxnZ5TX8z9F6UtUVow,1461
|
27
27
|
beswarm/aient/src/aient/plugins/config.py,sha256=QGyI9LlNaU36GUpY531o7UbTFBB39u7LfS6rrx_RTWw,7103
|
28
|
-
beswarm/aient/src/aient/plugins/excute_command.py,sha256
|
28
|
+
beswarm/aient/src/aient/plugins/excute_command.py,sha256=ybkgoMlrXxfeRLA8gizxNL1KuVda0s9xSKTSzC8CKyU,10021
|
29
29
|
beswarm/aient/src/aient/plugins/get_time.py,sha256=Ih5XIW5SDAIhrZ9W4Qe5Hs1k4ieKPUc_LAd6ySNyqZk,654
|
30
30
|
beswarm/aient/src/aient/plugins/image.py,sha256=ZElCIaZznE06TN9xW3DrSukS7U3A5_cjk1Jge4NzPxw,2072
|
31
31
|
beswarm/aient/src/aient/plugins/list_directory.py,sha256=JZVuImecMSfEv6jLqii-0uQJ1UCsrpMNmYlwW3PEDg4,1374
|
@@ -35,12 +35,12 @@ beswarm/aient/src/aient/plugins/readonly.py,sha256=qK5-kBM3NDH1b-otFxFHpAjV5BXEY
|
|
35
35
|
beswarm/aient/src/aient/plugins/registry.py,sha256=YknzhieU_8nQ3oKlUSSWDB4X7t2Jx0JnqT2Jd9Xsvfk,3574
|
36
36
|
beswarm/aient/src/aient/plugins/run_python.py,sha256=dgcUwBunMuDkaSKR5bToudVzSdrXVewktDDFUz_iIOQ,4589
|
37
37
|
beswarm/aient/src/aient/plugins/websearch.py,sha256=llxy1U0vJiNMiKvamMr4p7IruLb3nnDR4YErz8TYimc,15215
|
38
|
-
beswarm/aient/src/aient/plugins/write_file.py,sha256=
|
38
|
+
beswarm/aient/src/aient/plugins/write_file.py,sha256=aWOCuKjtpzjl2JiJV9W6YBmPg_WivxyXD509xUHiuCc,3631
|
39
39
|
beswarm/aient/src/aient/prompt/__init__.py,sha256=GBtn6-JDT8KHFCcuPpfSNE_aGddg5p4FEyMCy4BfwGs,20
|
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=JVR6oNxYc9NnfQL0PGsL8QuhG43dwg0-rPS8NR_pyBM,36461
|
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=khKKMaet7FJzTY79SYuRmYdJ5sOzoyX6Rl5ChyjvK1g,8806
|
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.77.dist-info/METADATA,sha256=CjEUw07KUrfTxiusTUIk-XDMkBA5h1qqs6LLrLo_L8M,3553
|
134
|
+
beswarm-0.1.77.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
135
|
+
beswarm-0.1.77.dist-info/top_level.txt,sha256=pJw4O87wvt5882smuSO6DfByJz7FJ8SxxT8h9fHCmpo,8
|
136
|
+
beswarm-0.1.77.dist-info/RECORD,,
|
File without changes
|
File without changes
|