Skip to content
Closed
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
4 changes: 4 additions & 0 deletions hermes_cli/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,10 @@ def register_skill(
f"plugin name '{self.manifest.name}' automatically).")
if not name or not _NAMESPACE_RE.match(name):
raise ValueError(f"Invalid skill name '{name}'. Must match [a-zA-Z0-9_-]+.")
# Plugin register() helpers commonly pass the SKILL.md location as str
# (PluginManifest.path is stored as str); the registry and find_plugin_skill()
# promise a Path downstream.
path = Path(path)
if not path.exists():
raise FileNotFoundError(f"SKILL.md not found at {path}")
namespace = self.manifest.skill_namespace or self.manifest.name
Expand Down
20 changes: 20 additions & 0 deletions tests/test_plugin_skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,26 @@ def test_rejects_missing_file(self, ctx, tmp_path):
with pytest.raises(FileNotFoundError):
ctx.register_skill("foo", tmp_path / "nonexistent.md")

def test_accepts_str_path(self, ctx, tmp_path):
# Plugin register() helpers commonly pass the SKILL.md location as str
# (#104404); this used to abort the whole plugin load with
# "'str' object has no attribute 'exists'" instead of registering.
from pathlib import Path

skill_md = tmp_path / "skills" / "my-skill" / "SKILL.md"
skill_md.parent.mkdir(parents=True)
skill_md.write_text("---\nname: my-skill\n---\nContent.\n")

ctx.register_skill("my-skill", str(skill_md), "A test skill")

found = ctx._manager.find_plugin_skill("testplugin:my-skill")
assert found == skill_md
assert isinstance(found, Path)

def test_missing_str_path_raises_filenotfound(self, ctx, tmp_path):
with pytest.raises(FileNotFoundError):
ctx.register_skill("foo", str(tmp_path / "nonexistent.md"))

def test_duplicate_qualified_name_is_rejected(self, ctx, tmp_path):
ctx.manifest.portable = True
first = tmp_path / "first" / "SKILL.md"
Expand Down
Loading