Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/tools/test_skill_manager_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ def _two_roots(local_dir: Path, external_dir: Path):
"""Patch the skill manager so local SKILLS_DIR = local_dir and
get_all_skills_dirs() returns [local_dir, external_dir] in order."""
with patch("tools.skill_manager_tool.SKILLS_DIR", local_dir), \
patch("agent.skill_utils.get_external_skills_dirs", return_value=[external_dir]), \
patch("agent.skill_utils.get_all_skills_dirs",
return_value=[local_dir, external_dir]):
yield
Expand Down Expand Up @@ -820,9 +821,8 @@ def test_delete_external_skill_cleans_empty_category(self, tmp_path):
assert not cat_dir.exists() # empty category cleaned up
assert external.exists() # but never the external root

def test_create_still_writes_to_local_root(self, tmp_path):
"""Creating a new skill always lands in local SKILLS_DIR, never
external_dirs — create is unchanged by this PR."""
def test_create_defaults_to_first_external_root(self, tmp_path):
"""Creating a new skill should honor the first configured external root."""
local = tmp_path / "local"
external = tmp_path / "vault"
local.mkdir(); external.mkdir()
Expand All @@ -832,8 +832,8 @@ def test_create_still_writes_to_local_root(self, tmp_path):
"name: test-skill", "name: fresh-skill"))

assert result["success"] is True, result
assert (local / "fresh-skill" / "SKILL.md").exists()
assert not (external / "fresh-skill").exists()
assert (external / "fresh-skill" / "SKILL.md").exists()
assert not (local / "fresh-skill").exists()



Expand Down
14 changes: 11 additions & 3 deletions tools/skill_manager_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,17 @@ def _validate_content_size(content: str, label: str = "SKILL.md") -> Optional[st

def _resolve_skill_dir(name: str, category: str = None) -> Path:
"""Build the directory path for a new skill, optionally under a category."""
try:
from agent.skill_utils import get_external_skills_dirs

external_dirs = get_external_skills_dirs()
except Exception:
external_dirs = []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On current main, do not fall back to module-level SKILLS_DIR: commit c6a3d412d462 introduced _skills_dir() so long-lived profile-scoped runtimes resolve the active profile at call time. Preserve _skills_dir() here when no external root is selected.

target_root = external_dirs[0] if external_dirs else SKILLS_DIR
if category:
return SKILLS_DIR / category / name
return SKILLS_DIR / name
return target_root / category / name
return target_root / name


def _find_skill(name: str) -> Optional[Dict[str, Any]]:
Expand Down Expand Up @@ -415,7 +423,7 @@ def _create_skill(name: str, content: str, category: str = None) -> Dict[str, An
result = {
"success": True,
"message": f"Skill '{name}' created.",
"path": str(skill_dir.relative_to(SKILLS_DIR)),
"path": str(skill_dir.relative_to(_containing_skills_root(skill_dir))),
"skill_md": str(skill_md),
}
if category:
Expand Down
Loading