fix(skills): migrate read_skill path to .agents/skills
This commit is contained in:
parent
cd82c6d658
commit
1812ee7c27
@ -423,7 +423,7 @@ class MainTerminalToolsDefinitionMixin:
|
||||
"type": "function",
|
||||
"function": {
|
||||
"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": {
|
||||
"type": "object",
|
||||
"properties": self._inject_intent({
|
||||
|
||||
@ -545,11 +545,11 @@ class MainTerminalToolsExecutionMixin:
|
||||
normalized = self._normalize_tool_path(result.get("path") or arguments.get("path"))
|
||||
if not normalized:
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
|
||||
def _get_visited_read_files(self) -> Set[str]:
|
||||
@ -698,7 +698,7 @@ class MainTerminalToolsExecutionMixin:
|
||||
)
|
||||
if already_read:
|
||||
return None
|
||||
required_path = f"skills/{skill_id}/SKILL.md"
|
||||
required_path = f".agents/skills/{skill_id}/SKILL.md"
|
||||
return {
|
||||
"success": False,
|
||||
"error": f"调用 {tool_name} 前必须先阅读 {required_path}",
|
||||
|
||||
@ -92,8 +92,8 @@ class MainTerminalToolsReadMixin:
|
||||
if not raw:
|
||||
return ""
|
||||
normalized = raw.replace("\\", "/").strip("/")
|
||||
if normalized.lower().startswith("skills/"):
|
||||
normalized = normalized.split("/", 1)[1] if "/" in normalized else normalized
|
||||
if normalized.lower().startswith(".agents/skills/"):
|
||||
normalized = normalized[len(".agents/skills/"):]
|
||||
if normalized.lower().endswith("/skill.md"):
|
||||
normalized = normalized[: -len("/SKILL.md")]
|
||||
return normalized.strip()
|
||||
@ -147,7 +147,7 @@ class MainTerminalToolsReadMixin:
|
||||
|
||||
skill_id = resolved["skill_id"]
|
||||
read_args = {
|
||||
"path": f"skills/{skill_id}/SKILL.md",
|
||||
"path": f".agents/skills/{skill_id}/SKILL.md",
|
||||
"type": "read",
|
||||
}
|
||||
result = self._handle_read_tool(read_args)
|
||||
|
||||
@ -277,9 +277,9 @@ def build_skills_list(
|
||||
continue
|
||||
description = (meta.get("description") or "").strip()
|
||||
if description:
|
||||
lines.append(f"skills/{skill_id}:{description}")
|
||||
lines.append(f".agents/skills/{skill_id}:{description}")
|
||||
else:
|
||||
lines.append(f"skills/{skill_id}")
|
||||
lines.append(f".agents/skills/{skill_id}")
|
||||
return lines
|
||||
|
||||
|
||||
|
||||
@ -8,19 +8,19 @@ class ToolResultFormatterTest(unittest.TestCase):
|
||||
result = {
|
||||
"success": True,
|
||||
"type": "read",
|
||||
"path": "skills/frontend-design/SKILL.md",
|
||||
"path": ".agents/skills/frontend-design/SKILL.md",
|
||||
"max_chars": 50000,
|
||||
"truncated": False,
|
||||
"content": "# Skill\nFull content",
|
||||
"line_start": 1,
|
||||
"line_end": 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)
|
||||
|
||||
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.assertNotEqual(result["message"], formatted)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user