fix(skills): migrate read_skill path to .agents/skills
This commit is contained in:
parent
cd82c6d658
commit
62acf53fc2
@ -423,7 +423,7 @@ class MainTerminalToolsDefinitionMixin:
|
|||||||
"type": "function",
|
"type": "function",
|
||||||
"function": {
|
"function": {
|
||||||
"name": "read_skill",
|
"name": "read_skill",
|
||||||
"description": "按 skill 名称读取 skills/<name>/SKILL.md 内容;内部等价于 read_file 的 read 模式,并返回解析后的 path。",
|
"description": "按 skill 名称读取 .agents/skills/<name>/SKILL.md 内容;内部等价于 read_file 的 read 模式,并返回解析后的 path。",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": self._inject_intent({
|
"properties": self._inject_intent({
|
||||||
|
|||||||
@ -545,11 +545,11 @@ class MainTerminalToolsExecutionMixin:
|
|||||||
normalized = self._normalize_tool_path(result.get("path") or arguments.get("path"))
|
normalized = self._normalize_tool_path(result.get("path") or arguments.get("path"))
|
||||||
if not normalized:
|
if not normalized:
|
||||||
return
|
return
|
||||||
if normalized.endswith("skills/terminal-guide/skill.md"):
|
if normalized.endswith(".agents/skills/terminal-guide/skill.md"):
|
||||||
self.context_manager._set_meta_flag(self._skill_meta_key("terminal-guide"), True)
|
self.context_manager._set_meta_flag(self._skill_meta_key("terminal-guide"), True)
|
||||||
if normalized.endswith("skills/sub-agent-guide/skill.md"):
|
if normalized.endswith(".agents/skills/sub-agent-guide/skill.md"):
|
||||||
self.context_manager._set_meta_flag(self._skill_meta_key("sub-agent-guide"), True)
|
self.context_manager._set_meta_flag(self._skill_meta_key("sub-agent-guide"), True)
|
||||||
if normalized.endswith("skills/run-command-guide/skill.md"):
|
if normalized.endswith(".agents/skills/run-command-guide/skill.md"):
|
||||||
self.context_manager._set_meta_flag(self._skill_meta_key("run-command-guide"), True)
|
self.context_manager._set_meta_flag(self._skill_meta_key("run-command-guide"), True)
|
||||||
|
|
||||||
def _get_visited_read_files(self) -> Set[str]:
|
def _get_visited_read_files(self) -> Set[str]:
|
||||||
@ -698,7 +698,7 @@ class MainTerminalToolsExecutionMixin:
|
|||||||
)
|
)
|
||||||
if already_read:
|
if already_read:
|
||||||
return None
|
return None
|
||||||
required_path = f"skills/{skill_id}/SKILL.md"
|
required_path = f".agents/skills/{skill_id}/SKILL.md"
|
||||||
return {
|
return {
|
||||||
"success": False,
|
"success": False,
|
||||||
"error": f"调用 {tool_name} 前必须先阅读 {required_path}",
|
"error": f"调用 {tool_name} 前必须先阅读 {required_path}",
|
||||||
|
|||||||
@ -92,8 +92,8 @@ class MainTerminalToolsReadMixin:
|
|||||||
if not raw:
|
if not raw:
|
||||||
return ""
|
return ""
|
||||||
normalized = raw.replace("\\", "/").strip("/")
|
normalized = raw.replace("\\", "/").strip("/")
|
||||||
if normalized.lower().startswith("skills/"):
|
if normalized.lower().startswith(".agents/skills/"):
|
||||||
normalized = normalized.split("/", 1)[1] if "/" in normalized else normalized
|
normalized = normalized[len(".agents/skills/"):]
|
||||||
if normalized.lower().endswith("/skill.md"):
|
if normalized.lower().endswith("/skill.md"):
|
||||||
normalized = normalized[: -len("/SKILL.md")]
|
normalized = normalized[: -len("/SKILL.md")]
|
||||||
return normalized.strip()
|
return normalized.strip()
|
||||||
@ -147,7 +147,7 @@ class MainTerminalToolsReadMixin:
|
|||||||
|
|
||||||
skill_id = resolved["skill_id"]
|
skill_id = resolved["skill_id"]
|
||||||
read_args = {
|
read_args = {
|
||||||
"path": f"skills/{skill_id}/SKILL.md",
|
"path": f".agents/skills/{skill_id}/SKILL.md",
|
||||||
"type": "read",
|
"type": "read",
|
||||||
}
|
}
|
||||||
result = self._handle_read_tool(read_args)
|
result = self._handle_read_tool(read_args)
|
||||||
|
|||||||
@ -277,9 +277,9 @@ def build_skills_list(
|
|||||||
continue
|
continue
|
||||||
description = (meta.get("description") or "").strip()
|
description = (meta.get("description") or "").strip()
|
||||||
if description:
|
if description:
|
||||||
lines.append(f"skills/{skill_id}:{description}")
|
lines.append(f".agents/skills/{skill_id}:{description}")
|
||||||
else:
|
else:
|
||||||
lines.append(f"skills/{skill_id}")
|
lines.append(f".agents/skills/{skill_id}")
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -8,19 +8,19 @@ class ToolResultFormatterTest(unittest.TestCase):
|
|||||||
result = {
|
result = {
|
||||||
"success": True,
|
"success": True,
|
||||||
"type": "read",
|
"type": "read",
|
||||||
"path": "skills/frontend-design/SKILL.md",
|
"path": ".agents/skills/frontend-design/SKILL.md",
|
||||||
"max_chars": 50000,
|
"max_chars": 50000,
|
||||||
"truncated": False,
|
"truncated": False,
|
||||||
"content": "# Skill\nFull content",
|
"content": "# Skill\nFull content",
|
||||||
"line_start": 1,
|
"line_start": 1,
|
||||||
"line_end": 2,
|
"line_end": 2,
|
||||||
"total_lines": 2,
|
"total_lines": 2,
|
||||||
"message": "已读取 skills/frontend-design/SKILL.md 的内容(行 1~2)",
|
"message": "已读取 .agents/skills/frontend-design/SKILL.md 的内容(行 1~2)",
|
||||||
}
|
}
|
||||||
|
|
||||||
formatted = format_tool_result_for_context("read_skill", result)
|
formatted = format_tool_result_for_context("read_skill", result)
|
||||||
|
|
||||||
self.assertIn("读取 skills/frontend-design/SKILL.md 行 1~2", formatted)
|
self.assertIn("读取 .agents/skills/frontend-design/SKILL.md 行 1~2", formatted)
|
||||||
self.assertIn("```\n# Skill\nFull content\n```", formatted)
|
self.assertIn("```\n# Skill\nFull content\n```", formatted)
|
||||||
self.assertNotEqual(result["message"], formatted)
|
self.assertNotEqual(result["message"], formatted)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user