From 62acf53fc209b904b7daf04ceed9f004ed4402b3 Mon Sep 17 00:00:00 2001 From: JOJO <1498581755@qq.com> Date: Wed, 27 May 2026 19:17:36 +0800 Subject: [PATCH] fix(skills): migrate read_skill path to .agents/skills --- core/main_terminal_parts/tools_definition.py | 2 +- core/main_terminal_parts/tools_execution.py | 8 ++++---- core/main_terminal_parts/tools_read.py | 6 +++--- modules/skills_manager.py | 4 ++-- test/test_tool_result_formatter.py | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/core/main_terminal_parts/tools_definition.py b/core/main_terminal_parts/tools_definition.py index 5867691..5a4349b 100644 --- a/core/main_terminal_parts/tools_definition.py +++ b/core/main_terminal_parts/tools_definition.py @@ -423,7 +423,7 @@ class MainTerminalToolsDefinitionMixin: "type": "function", "function": { "name": "read_skill", - "description": "按 skill 名称读取 skills//SKILL.md 内容;内部等价于 read_file 的 read 模式,并返回解析后的 path。", + "description": "按 skill 名称读取 .agents/skills//SKILL.md 内容;内部等价于 read_file 的 read 模式,并返回解析后的 path。", "parameters": { "type": "object", "properties": self._inject_intent({ diff --git a/core/main_terminal_parts/tools_execution.py b/core/main_terminal_parts/tools_execution.py index 51b5dd1..a403d5e 100644 --- a/core/main_terminal_parts/tools_execution.py +++ b/core/main_terminal_parts/tools_execution.py @@ -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}", diff --git a/core/main_terminal_parts/tools_read.py b/core/main_terminal_parts/tools_read.py index 8d4d506..57333a4 100644 --- a/core/main_terminal_parts/tools_read.py +++ b/core/main_terminal_parts/tools_read.py @@ -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) diff --git a/modules/skills_manager.py b/modules/skills_manager.py index c975b92..f52279c 100644 --- a/modules/skills_manager.py +++ b/modules/skills_manager.py @@ -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 diff --git a/test/test_tool_result_formatter.py b/test/test_tool_result_formatter.py index adee779..7a71f4a 100644 --- a/test/test_tool_result_formatter.py +++ b/test/test_tool_result_formatter.py @@ -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)