Files
hermes-agent/tests/tools/test_skill_usage_plugin_rows.py
Teknium c060f4ef85 fix(curator): list plugin skills in hermes curator usage
A plugin's skill is loaded and counted under its qualified name
("meshy:meshy-3d"), but usage_report() only walked the skills directory, so
the report had no row for it. An audit that joined on that report read four
plugin skills as never used when they had 3 to 9 loads each.

Add the enabled plugins' skills as rows with provenance "plugin", and accept
`--provenance plugin`. curated_report() is untouched, so a plugin skill still
never becomes a curator candidate.
2026-11-10 01:13:52 -08:00

41 lines
1.7 KiB
Python

"""`usage_report()` covers plugin-provided skills, which live outside the skills directory."""
from pathlib import Path
import pytest
@pytest.fixture
def usage_mod(tmp_path, monkeypatch):
home = tmp_path / ".hermes"
(home / "skills" / "local-skill").mkdir(parents=True)
(home / "skills" / "local-skill" / "SKILL.md").write_text("---\nname: local-skill\ndescription: d\n---\nbody\n")
monkeypatch.setattr(Path, "home", lambda: tmp_path)
monkeypatch.setenv("HERMES_HOME", str(home))
import importlib
import tools.skill_usage as mod
importlib.reload(mod)
return mod
def test_usage_report_lists_plugin_skills_with_their_counts(usage_mod, tmp_path, monkeypatch):
from hermes_cli import plugins
md = tmp_path / "plug" / "skills" / "model-3d" / "SKILL.md"
md.parent.mkdir(parents=True)
md.write_text("---\nname: model-3d\ndescription: d\n---\nbody\n")
manager = plugins.PluginManager()
manager._plugin_skills["meshlike:model-3d"] = {
"path": md, "plugin": "meshlike", "bare_name": "model-3d", "description": "d"}
monkeypatch.setattr(plugins, "discover_plugins", lambda force=False: None)
monkeypatch.setattr(plugins, "get_plugin_manager", lambda: manager)
usage_mod.bump_use("meshlike:model-3d")
usage_mod.bump_use("meshlike:model-3d")
rows = {r["name"]: r for r in usage_mod.usage_report()}
assert rows["meshlike:model-3d"]["use_count"] == 2
assert rows["meshlike:model-3d"]["provenance"] == "plugin"
assert rows["local-skill"]["provenance"] == "agent"
# A plugin skill is never handed to the curator: listing it must not make it a managed row.
assert "meshlike:model-3d" not in {r["name"] for r in usage_mod.curated_report()}