Update skills_tool.py
frdel committed
Feb 5, 2026 at 17:01 UTC
5a074f125c12a5c9bae9db8f875de03a86804109
1 file changed
+39
-37
python/tools/skills_tool.py
+39
-37
@@ -40,17 +40,17 @@ class SkillsTool(Tool):
40
if method == "load":
41
skill_name = str(kwargs.get("skill_name") or "").strip()
42
return Response(message=self._load(skill_name), break_loop=False)
43
- if method == "read_file":
44
- skill_name = str(kwargs.get("skill_name") or "").strip()
45
- file_path = str(kwargs.get("file_path") or "").strip()
46
- return Response(
47
- message=self._read_file(skill_name, file_path), break_loop=False
48
- )
43
+ # if method == "read_file":
44
+ # skill_name = str(kwargs.get("skill_name") or "").strip()
45
+ # file_path = str(kwargs.get("file_path") or "").strip()
46
+ # return Response(
47
+ # message=self._read_file(skill_name, file_path), break_loop=False
48
+ # )
49
50
return Response(
51
message=(
52
"Error: missing/invalid 'method'. Supported methods: "
53
- "list, search, load, read_file."
53
+ "list, load."
54
),
55
break_loop=False,
56
)
@@ -118,7 +118,7 @@ class SkillsTool(Tool):
118
if not skill_name:
119
return "Error: 'skill_name' is required for method=load."
120
121
- self.agent.data[DATA_NAME_LOADED_SKILL] = [skill_name]
121
+ self.agent.data[DATA_NAME_LOADED_SKILLS] = [skill_name]
122
123
# skill = skills_helper.find_skill(
124
# skill_name,
@@ -190,35 +190,6 @@ class SkillsTool(Tool):
190
191
return "\n".join(lines)
192
193
- def _read_file(self, skill_name: str, file_path: str) -> str:
194
- if not skill_name:
195
- return "Error: 'skill_name' is required for method=read_file."
196
- if not file_path:
197
- return "Error: 'file_path' is required for method=read_file."
198
-
199
- skill = skills_helper.find_skill(
200
- skill_name,
201
- include_content=False,
202
- agent=self.agent,
203
- )
204
- if not skill:
205
- return f"Error: skill not found: {skill_name!r}."
206
-
207
- try:
208
- target = skills_helper.safe_path_within_dir(skill.path, file_path)
209
- except Exception as e:
210
- return f"Error: invalid file_path: {e}"
211
-
212
- if not target.exists() or not target.is_file():
213
- return f"Error: file not found: {file_path!r} (within skill {skill.name})"
214
-
215
- # Basic binary guard: if null byte present, do not dump
216
- content = target.read_bytes()
217
- if b"\x00" in content[:4096]:
218
- return f"Error: file appears to be binary; refusing to print raw bytes ({file_path})."
219
-
220
- text = content.decode("utf-8", errors="replace")
221
- return f"File: {file_path}\n\n{text}"
193
194
def _list_skill_files(self, skill_dir: Path, *, max_files: int = 80) -> str:
195
if not skill_dir.exists():
@@ -241,3 +212,34 @@ class SkillsTool(Tool):
212
tree = tree.replace(str(skill_dir), runtime_path)
213
214
return str(tree)
215
+
216
+
217
+ # def _read_file(self, skill_name: str, file_path: str) -> str:
218
+ # if not skill_name:
219
+ # return "Error: 'skill_name' is required for method=read_file."
220
+ # if not file_path:
221
+ # return "Error: 'file_path' is required for method=read_file."
222
+
223
+ # skill = skills_helper.find_skill(
224
+ # skill_name,
225
+ # include_content=False,
226
+ # agent=self.agent,
227
+ # )
228
+ # if not skill:
229
+ # return f"Error: skill not found: {skill_name!r}."
230
+
231
+ # try:
232
+ # target = skills_helper.safe_path_within_dir(skill.path, file_path)
233
+ # except Exception as e:
234
+ # return f"Error: invalid file_path: {e}"
235
+
236
+ # if not target.exists() or not target.is_file():
237
+ # return f"Error: file not found: {file_path!r} (within skill {skill.name})"
238
+
239
+ # # Basic binary guard: if null byte present, do not dump
240
+ # content = target.read_bytes()
241
+ # if b"\x00" in content[:4096]:
242
+ # return f"Error: file appears to be binary; refusing to print raw bytes ({file_path})."
243
+
244
+ # text = content.decode("utf-8", errors="replace")
245
+ # return f"File: {file_path}\n\n{text}"
\ No newline at end of file