Skip to content

The agent that grows with you

fix(skills): expose plugin skills to interactive commands

Carl Taylordc9ee6722a73
diff --git a/agent/skill_commands.py b/agent/skill_commands.py
index e3e4305fe95..7c717124d81 100644
--- a/agent/skill_commands.py
+++ b/agent/skill_commands.py
@@ -528,6 +528,62 @@ def get_skill_commands() -> Dict[str, Dict[str, Any]]:
return scan_skill_commands()
+def get_plugin_skill_commands() -> Dict[str, Dict[str, Any]]:
+ """Project enabled plugin skills into the interactive-only slash namespace."""
+ from agent.skill_utils import get_disabled_skill_names
+ from hermes_cli.plugins import discover_plugins, get_plugin_manager
+ from hermes_cli.plugins_discovery import _get_disabled_plugins
+ from tools.skills_tool import (
+ _parse_frontmatter, skill_matches_apps, skill_matches_environment,
+ skill_matches_platform,
+ )
+
+ discover_plugins()
+ manager = get_plugin_manager()
+ disabled = get_disabled_skill_names()
+ disabled_plugins = _get_disabled_plugins()
+ commands: Dict[str, Dict[str, Any]] = {}
+ for metadata in manager.list_plugin_skill_metadata():
+ qualified = str(metadata.get("name") or "").strip()
+ if not qualified or ":" not in qualified or qualified in disabled or qualified.split(":", 1)[1] in disabled:
+ continue
+ if metadata.get("plugin_key") in disabled_plugins or qualified.split(":", 1)[0] in disabled_plugins:
+ continue
+ skill_md = manager.find_plugin_skill(qualified)
+ if skill_md is None or not skill_md.is_file():
+ continue
+ try:
+ parsed, _ = _parse_frontmatter(skill_md.read_text(encoding="utf-8-sig", errors="replace"))
+ except OSError:
+ continue
+ frontmatter = metadata.get("frontmatter") or parsed
+ if not (skill_matches_platform(frontmatter) and skill_matches_environment(frontmatter)
+ and skill_matches_apps(frontmatter)):
+ continue
+ key = f"/{qualified.lower()}"
+ if skill_command_collision_note(qualified) is not None or key in commands:
+ logger.warning("Plugin skill %r collides with an existing slash command; skipping", qualified)
+ continue
+ commands[key] = {
+ "name": qualified, "description": str(metadata.get("description") or parsed.get("description")
+ or f"Invoke the {qualified} plugin skill").strip(),
+ "skill_identifier": qualified, "skill_md_path": str(skill_md),
+ "skill_dir": str(skill_md.parent), "source": "plugin",
+ }
+ return commands
+
+
+def get_interactive_skill_commands() -> Dict[str, Dict[str, Any]]:
+ """Filesystem skills plus profile-scoped plugin skills; never use for native menus."""
+ commands = dict(get_skill_commands())
+ for key, info in get_plugin_skill_commands().items():
+ if key in commands:
+ logger.warning("Plugin skill %r collides with %r; keeping the first", key, commands[key]["name"])
+ else:
+ commands[key] = info
+ return commands
+
+
def diff_command_snapshots(before: Dict[str, str], after: Dict[str, str]) -> Dict[str, Any]:
"""Diff two {name: description} snapshots into added/removed/unchanged/total.
Removed entries carry the pre-rescan description (the file may be gone)."""
@@ -564,17 +620,19 @@ def reload_skills() -> Dict[str, Any]:
return result
-def resolve_skill_command_key(command: str) -> Optional[str]:
- """Resolve a user-typed /command to its canonical ``/slug`` key, or None.
- ``_`` ≡ ``-``: Telegram disallows hyphens, so ``/claude-code`` arrives as ``/claude_code``."""
- return resolve_slash_key(command, get_skill_commands())
+def resolve_skill_command_key(command: str, *, interactive: bool = False) -> Optional[str]:
+ """Resolve a user-typed /command; native callers retain filesystem-only lookup."""
+ return resolve_slash_key(command, get_interactive_skill_commands() if interactive else get_skill_commands())
def resolve_slash_key(command: str, table: Dict[str, Any]) -> Optional[str]:
"""``command`` -> ``"/slug"`` when present in *table* (``_`` normalized to ``-``), else None."""
if not command:
return None
- cmd_key = f"/{command.replace('_', '-')}"
+ exact_key = f"/{command.lower()}"
+ if exact_key in table:
+ return exact_key
+ cmd_key = f"/{command.replace('_', '-').lower()}"
return cmd_key if cmd_key in table else None
@@ -582,8 +640,8 @@ def build_skill_invocation_message(
cmd_key: str, user_instruction: str = "", task_id: str | None = None, runtime_note: str = "",
) -> Optional[str]:
"""Build the user message for a skill slash command, or None if not found."""
- skill_info = get_skill_commands().get(cmd_key)
- loaded = _load_skill_payload(skill_info["skill_dir"], task_id=task_id) if skill_info else None
+ skill_info = get_interactive_skill_commands().get(cmd_key)
+ loaded = _load_skill_payload(skill_info.get("skill_identifier") or skill_info["skill_dir"], task_id=task_id) if skill_info else None
if not loaded:
return None
note = (f'[IMPORTANT: The user has invoked the "{loaded[2]}" skill, indicating they want '
@@ -608,7 +666,7 @@ def split_stacked_skill_commands(rest: str) -> tuple[list[str], str]:
if not stripped.startswith("/"):
break
token, tail = (stripped.split(None, 1) + [""])[:2]
- cmd_key = resolve_skill_command_key(token.lstrip("/"))
+ cmd_key = resolve_skill_command_key(token.lstrip("/"), interactive=True)
if cmd_key is None or cmd_key in keys:
break
keys.append(cmd_key)
@@ -621,11 +679,11 @@ def build_stacked_skill_invocation_message(
) -> Optional[tuple[str, list[str], list[str]]]:
"""Build the user message for a stacked multi-skill slash invocation:
``(message, loaded_skill_names, missing_skill_names)``, or ``None`` when no skill loaded."""
- commands = get_skill_commands()
+ commands = get_interactive_skill_commands()
keys = [k for k in cmd_keys if k]
loaded_names, missing, _disabled, skill_blocks = _load_skill_blocks(
keys,
- lambda cmd_key: _load_skill_payload(commands[cmd_key]["skill_dir"], task_id=task_id) if cmd_key in commands else None,
+ lambda cmd_key: _load_skill_payload(commands[cmd_key].get("skill_identifier") or commands[cmd_key]["skill_dir"], task_id=task_id) if cmd_key in commands else None,
lambda name: f'[Loaded as part of the stacked skill invocation "{name}".]', # bundle block marker
task_id, missing_label=lambda k: k.lstrip("/"),
)
@@ -670,7 +728,8 @@ def _load_skill_blocks(
missing.append(missing_label(identifier))
continue
skill_name = loaded[2]
- if disabled_names and (skill_name in disabled_names or identifier in disabled_names):
+ if disabled_names and (skill_name in disabled_names or identifier in disabled_names
+ or (":" in skill_name and skill_name.split(":", 1)[1] in disabled_names)):
if disabled_as_missing:
missing.append(identifier)
else:
diff --git a/cli.py b/cli.py
index 095fc99296d..56f9ff9cb2a 100644
--- a/cli.py
+++ b/cli.py
@@ -738,9 +738,9 @@ def _slash_args(cmd: str) -> str:
def _ensure_skill_commands() -> dict:
global _skill_commands
if _skill_commands is None:
- from agent.skill_commands import scan_skill_commands
+ from agent.skill_commands import get_interactive_skill_commands
- _skill_commands = scan_skill_commands()
+ _skill_commands = get_interactive_skill_commands()
return _skill_commands
diff --git a/hermes_cli/cli_info_mixin.py b/hermes_cli/cli_info_mixin.py
index 85d269d4fc3..cf37dcac7f0 100644
--- a/hermes_cli/cli_info_mixin.py
+++ b/hermes_cli/cli_info_mixin.py
@@ -1009,7 +1009,7 @@ class CLIInfoMixin:
conversation_history, so message alternation stays intact.
"""
try:
- from agent.skill_commands import reload_skills, get_skill_commands
+ from agent.skill_commands import reload_skills, get_interactive_skill_commands
if not self._command_running:
print(t("cli.reload_skills.reloading"))
result = reload_skills()
@@ -1017,7 +1017,7 @@ class CLIInfoMixin:
# Sync cli.py's module-level _skill_commands so help / dispatch / Tab-completion see
# the updated dict without a restart.
import cli as _cli
- _cli._skill_commands = get_skill_commands()
+ _cli._skill_commands = get_interactive_skill_commands()
added = result.get("added", []) # [{"name", "description"}, ...]
removed = result.get("removed", [])
total = result.get("total", 0)
diff --git a/hermes_cli/plugins.py b/hermes_cli/plugins.py
index 4fbf7394c85..530074ea5ed 100644
--- a/hermes_cli/plugins.py
+++ b/hermes_cli/plugins.py
@@ -1630,6 +1630,7 @@ class PluginManager(PluginLoaderMixin, PluginDispatchMixin, PluginLedgerMixin):
return [
{
"name": qualified, "description": str(entry.get("description", "")),
+ "plugin_key": str(entry.get("plugin_key", entry.get("plugin", ""))),
"category": "plugin", "frontmatter": dict(entry.get("frontmatter", {})),
} for qualified, entry in sorted(self._plugin_skills.items())
]
diff --git a/tests/tools/test_plugin_skills.py b/tests/tools/test_plugin_skills.py
index 83538831e7a..45d1bc87b0e 100644
--- a/tests/tools/test_plugin_skills.py
+++ b/tests/tools/test_plugin_skills.py
@@ -83,6 +83,43 @@ class TestPluginSkillRegistry:
# Removing non-existent key is a no-op
pm.remove_plugin_skill("p:x")
+class TestInteractivePluginSkill:
+ def test_real_discovery_catalog_completion_dispatch_and_native_separation(self, tmp_path, monkeypatch):
+ from pathlib import Path
+ from hermes_cli import plugins
+ from agent import skill_commands as sc
+ from tools.skills_tool import skill_view
+
+ home = tmp_path / ".hermes"
+ plugin = home / "plugins" / "slash-probe"
+ skill = plugin / "skills" / "guide" / "SKILL.md"
+ skill.parent.mkdir(parents=True)
+ (plugin / "plugin.yaml").write_text("name: slash-probe\nversion: 0.1.0\n")
+ (plugin / "__init__.py").write_text(
+ "from pathlib import Path\ndef register(ctx):\n"
+ " ctx.register_skill('guide', Path(__file__).parent / 'skills' / 'guide' / 'SKILL.md')\n"
+ )
+ skill.write_text("---\nname: guide\ndescription: Plugin guide.\n---\n\nFollow the plugin guide.\n")
+ (home / "config.yaml").write_text("plugins:\n enabled: [slash-probe]\n")
+ monkeypatch.setenv("HERMES_HOME", str(home))
+ plugins._reset_plugin_managers_for_tests()
+ try:
+ assert json.loads(skill_view("slash-probe:guide"))["success"]
+ assert "/slash-probe:guide" not in sc.scan_skill_commands()
+ assert "/slash-probe:guide" in sc.get_interactive_skill_commands()
+ invoked = sc.build_skill_invocation_message("/slash-probe:guide", "apply it")
+ assert "Follow the plugin guide." in invoked
+ assert "apply it" in invoked
+ preload, loaded, missing = sc.build_preloaded_skills_prompt(["slash-probe:guide"])
+ assert loaded == ["slash-probe:guide"] and missing == []
+ assert "Follow the plugin guide." in preload
+ (home / "config.yaml").write_text("plugins:\n enabled: [slash-probe]\nskills:\n disabled: [guide]\n")
+ assert "/slash-probe:guide" not in sc.get_interactive_skill_commands()
+ assert sc.build_preloaded_skills_prompt(["slash-probe:guide"])[2] == ["slash-probe:guide"]
+ finally:
+ plugins._reset_plugin_managers_for_tests()
+
+
class TestPluginContextRegisterSkill:
@pytest.fixture
def ctx(self, tmp_path, monkeypatch):
diff --git a/tests/tui_gateway/test_protocol.py b/tests/tui_gateway/test_protocol.py
index 7ddaa246b09..cd33b8eaddf 100644
--- a/tests/tui_gateway/test_protocol.py
+++ b/tests/tui_gateway/test_protocol.py
@@ -1445,6 +1445,46 @@ def test_command_dispatch_stacked_split_keeps_unknown_tokens_as_instruction(serv
assert "/not-a-skill-command but /model is a registry command" in result["message"]
+def test_plugin_skill_catalog_completion_dispatch_and_profile_switch(server, tmp_path, monkeypatch):
+ """Real plugin registration reaches every interactive RPC but not native skill menus."""
+ from hermes_cli import plugins
+ from agent import skill_commands
+
+ homes = [tmp_path / "profile-a", tmp_path / "profile-b"]
+ for home, suffix in zip(homes, ("alpha", "beta")):
+ plugin = home / "plugins" / f"probe-{suffix}"
+ md = plugin / "skills" / "guide" / "SKILL.md"
+ md.parent.mkdir(parents=True)
+ (plugin / "plugin.yaml").write_text(f"name: probe-{suffix}\nversion: 0.1.0\n")
+ (plugin / "__init__.py").write_text(
+ "from pathlib import Path\ndef register(ctx):\n"
+ " ctx.register_skill('guide', Path(__file__).parent / 'skills' / 'guide' / 'SKILL.md')\n"
+ )
+ md.write_text(f"---\nname: guide\ndescription: {suffix} guide.\n---\n\n{suffix} instructions.\n")
+ (home / "config.yaml").write_text(f"plugins:\n enabled: [probe-{suffix}]\n")
+
+ monkeypatch.setenv("HERMES_HOME", str(homes[0]))
+ plugins._reset_plugin_managers_for_tests()
+ try:
+ for home, suffix in ((homes[0], "alpha"), (homes[1], "beta"), (homes[0], "alpha")):
+ sid = f"skill-{suffix}"
+ server._sessions[sid] = {"session_key": sid, "profile_home": str(home), "agent": None}
+ key = f"/probe-{suffix}:guide"
+ catalog = server.handle_request({"id": "cat", "method": "commands.catalog", "params": {"session_id": sid}})
+ completed = server.handle_request({"id": "complete", "method": "complete.slash", "params": {"session_id": sid, "text": f"/probe-{suffix}:"}})
+ dispatched = server.handle_request({"id": "dispatch", "method": "command.dispatch", "params": {"session_id": sid, "name": key[1:], "arg": "apply"}})
+ assert key in catalog["result"]["skills"], catalog
+ assert any(item["text"] == key[1:] and item["kind"] == "skill" for item in completed["result"]["items"]), completed
+ assert dispatched["result"]["type"] == "skill", dispatched
+ assert f"{suffix} instructions." in dispatched["result"]["message"]
+ assert "apply" in dispatched["result"]["message"]
+ assert key not in skill_commands.get_skill_commands()
+ other = "beta" if suffix == "alpha" else "alpha"
+ assert f"/probe-{other}:guide" not in catalog["result"]["skills"]
+ finally:
+ plugins._reset_plugin_managers_for_tests()
+
+
def test_sessionless_slash_palette_follows_profile_param(server, tmp_path, monkeypatch):
"""A Desktop draft has no session yet: ``commands.catalog`` / ``complete.slash`` must scan the
named ``profile``'s home, not the launch profile's — A→B→A under multiplexing (#124651). The
diff --git a/tools/skills_tool_plugin.py b/tools/skills_tool_plugin.py
index f37f60cffea..d5f8e0f3e51 100644
--- a/tools/skills_tool_plugin.py
+++ b/tools/skills_tool_plugin.py
@@ -157,7 +157,8 @@ def _serve_plugin_skill(
"success": True, "name": qualified_name, "content": banner + rendered_content,
"description": _truncate_description(str(parsed_frontmatter.get("description", ""))),
"linked_files": _plugin_skill_linked_files(skill_md.parent),
- "readiness_status": SkillReadinessStatus.AVAILABLE.value})
+ "readiness_status": SkillReadinessStatus.AVAILABLE.value,
+ "skill_dir": str(skill_md.parent), "_source_path": str(skill_md)})
def _plugin_skill_linked_files(skill_root: Path) -> Dict[str, List[str]] | None:
diff --git a/tui_gateway/methods_complete.py b/tui_gateway/methods_complete.py
index 4ebe4a1c439..91a4f96eeb9 100644
--- a/tui_gateway/methods_complete.py
+++ b/tui_gateway/methods_complete.py
@@ -284,14 +284,14 @@ def _(rid, params: dict) -> dict:
from hermes_cli.commands_completion import SlashCommandCompleter
from prompt_toolkit.document import Document
from prompt_toolkit.formatted_text import to_plain_text
- from agent.skill_commands import get_skill_commands
+ from agent.skill_commands import get_interactive_skill_commands
from agent.skill_bundles import get_skill_bundles
# Skill/bundle lookups are home- and cwd-keyed: bind the calling session's profile and workspace so
# the popup offers the project-local skills ``command.dispatch`` accepts for that session (#114359).
# A new-chat draft has no session yet: it names its rail-selected ``profile`` instead (#124651).
with _session_home_scope(_sessions.get(params.get("session_id", "")), cwd=_completion_cwd(params),
profile=params.get("profile")):
- skill_commands, skill_bundles = dict(get_skill_commands()), dict(get_skill_bundles())
+ skill_commands, skill_bundles = dict(get_interactive_skill_commands()), dict(get_skill_bundles())
completer = SlashCommandCompleter(
skill_commands_provider=lambda: skill_commands, skill_bundles_provider=lambda: skill_bundles)
# `kind` reaches the TUI as data (from the providers, not sniffed from ⚡/▣ glyphs):
diff --git a/tui_gateway/methods_tools.py b/tui_gateway/methods_tools.py
index 039be4b47ef..2df2350374c 100644
--- a/tui_gateway/methods_tools.py
+++ b/tui_gateway/methods_tools.py
@@ -492,8 +492,10 @@ def _catalog_skills(cat: _Catalog, skills: dict[str, dict]) -> str:
``agent.skill_commands`` guard), ``""`` when none."""
usage, origin_of = _skill_usage_lookup()
sc = _tools_mod("agent.skill_commands")
- for k, info in sorted(sc.get_skill_commands().items()):
- cat.pairs.append([k, str(info.get("description", "Skill"))])
+ for k, info in sorted(sc.get_interactive_skill_commands().items()):
+ if k.lower() in cat.canon:
+ continue
+ cat.add(k, str(info.get("description", "Skill")), "Skills")
name = str(info.get("name") or k.lstrip("/"))
skills[k] = {"usage": usage(name), "origin": origin_of(name)}
names = sorted(s["name"] for s in _tools_mod("tools.skills_tool")._find_all_skills())
@@ -645,7 +647,7 @@ def _profile_skill_command(session: dict, base: str) -> bool | None:
"""
try:
with _session_home_scope(session):
- return f"/{base}" in _tools_mod("agent.skill_commands").get_skill_commands()
+ return f"/{base}" in _tools_mod("agent.skill_commands").get_interactive_skill_commands()
except Exception:
return None
@@ -718,7 +720,7 @@ def _dispatch_bundle(rid, params, session, name, arg):
def _dispatch_skill(rid, params, session, name, arg):
with contextlib.suppress(Exception):
sc = _tools_mod("agent.skill_commands")
- cmds, key = sc.get_skill_commands(), f"/{name}"
+ cmds, key = sc.get_interactive_skill_commands(), f"/{name}".lower()
if key in cmds:
# Stacked leading /skill tokens (up to 5, cli.py + gateway parity, #74705): the
# first token matched above; consume any further leading skill tokens from `arg`,