Skip to content

The agent that grows with you

fix(plugins): accept str skill paths in register_skill

liuhao102489f0ae80d43b
diff --git a/hermes_cli/plugins.py b/hermes_cli/plugins.py
index 8d8bfddf5c1..23dff081afd 100644
--- a/hermes_cli/plugins.py
+++ b/hermes_cli/plugins.py
@@ -1007,6 +1007,10 @@ class PluginContext:
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
diff --git a/tests/tools/test_plugin_skills.py b/tests/tools/test_plugin_skills.py
index b2f49061fa3..5a58b3ad6c3 100644
--- a/tests/tools/test_plugin_skills.py
+++ b/tests/tools/test_plugin_skills.py
@@ -139,6 +139,26 @@ class TestPluginContextRegisterSkill:
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"