summaryrefslogtreecommitdiff
path: root/tests/hermes
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hermes')
-rw-r--r--tests/hermes/conftest.py4
-rw-r--r--tests/hermes/test_plugin.py36
2 files changed, 39 insertions, 1 deletions
diff --git a/tests/hermes/conftest.py b/tests/hermes/conftest.py
index 561cd8c..ec22bed 100644
--- a/tests/hermes/conftest.py
+++ b/tests/hermes/conftest.py
@@ -9,11 +9,12 @@ def mock_ctx():
ctx = MagicMock()
ctx._hooks = {}
ctx._skills = {}
+ ctx._descriptions = {}
def register_hook(event, fn):
ctx._hooks[event] = fn
- def register_skill(name, path):
+ def register_skill(name, path, description="", frontmatter=None):
# Mimic hermes' real register_skill, which calls path.exists() and
# therefore breaks on a str (the bug that silently disabled the whole
# plugin, found 2026-07-23). Keeping that fidelity here means a
@@ -24,6 +25,7 @@ def mock_ctx():
f"register_skill requires a pathlib.Path, got {type(path).__name__}"
)
ctx._skills[name] = path
+ ctx._descriptions[name] = description
ctx.register_hook.side_effect = register_hook
ctx.register_skill.side_effect = register_skill
diff --git a/tests/hermes/test_plugin.py b/tests/hermes/test_plugin.py
index 9c6c4f0..57d619e 100644
--- a/tests/hermes/test_plugin.py
+++ b/tests/hermes/test_plugin.py
@@ -1,6 +1,7 @@
import importlib
import importlib.util
import os
+import re
import shutil
import sys
from pathlib import Path
@@ -140,3 +141,38 @@ class TestLayoutResolution:
mod = self._load_from(plugdir)
with pytest.raises(RuntimeError, match="cannot find the skills"):
mod.register(mock_ctx)
+
+
+class TestSkillDescriptions:
+ """Hermes builds its skill catalogue from register_skill(description=...),
+ which defaults to "". Registering the path alone left every stock skill
+ blank in that catalogue, so the model had nothing to select on."""
+
+ def test_every_stock_skill_registers_a_description(self, mock_ctx):
+ plugin = _load_plugin()
+ plugin.register(mock_ctx)
+ assert set(mock_ctx._descriptions) == set(mock_ctx._skills)
+ blank = sorted(n for n, d in mock_ctx._descriptions.items() if not d.strip())
+ assert blank == [], f"registered without a description: {blank}"
+
+ def test_descriptions_match_the_skill_frontmatter(self, mock_ctx):
+ plugin = _load_plugin()
+ plugin.register(mock_ctx)
+ skills_dir = Path(plugin._skills_dir())
+ for name, description in mock_ctx._descriptions.items():
+ text = (skills_dir / name / "SKILL.md").read_text(encoding="utf-8")
+ declared = re.search(r"^description:\s*(.+)$", text, re.M).group(1)
+ assert description == declared.strip().strip('"').strip("'")
+
+ @pytest.mark.parametrize(
+ "block, expected",
+ [
+ ('---\nname: demo\ndescription: "Quoted value."\n---\nbody', "Quoted value."),
+ ("---\nname: demo\ndescription: Bare value\n---\nbody", "Bare value"),
+ ("---\nname: demo\n---\nbody", ""),
+ ("no frontmatter at all", ""),
+ ],
+ )
+ def test_frontmatter_value_parsing(self, block, expected):
+ plugin = _load_plugin()
+ assert plugin._frontmatter_value(block, "description") == expected