Skip to content

The agent that grows with you

fix(cli): keep plugin skill lookup live and align slash precedence

Hermes Agent9c67c1c4a863
diff --git a/hermes_cli/cli_info_mixin.py b/hermes_cli/cli_info_mixin.py
index cf37dcac7f0..bef1a7ae6df 100644
--- a/hermes_cli/cli_info_mixin.py
+++ b/hermes_cli/cli_info_mixin.py
@@ -1009,15 +1009,10 @@ class CLIInfoMixin:
conversation_history, so message alternation stays intact.
"""
try:
- from agent.skill_commands import reload_skills, get_interactive_skill_commands
+ from agent.skill_commands import reload_skills
if not self._command_running:
print(t("cli.reload_skills.reloading"))
result = reload_skills()
-
- # 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_interactive_skill_commands()
added = result.get("added", []) # [{"name", "description"}, ...]
removed = result.get("removed", [])
total = result.get("total", 0)
diff --git a/hermes_cli/commands_completion.py b/hermes_cli/commands_completion.py
index 66339235811..2edfcdeda24 100644
--- a/hermes_cli/commands_completion.py
+++ b/hermes_cli/commands_completion.py
@@ -327,11 +327,11 @@ class SlashCommandCompleter(Completer):
return # a bare space after the chain may start the instruction
word_key = self._normalize_skill_token(current_word)
for cmd, info in skill_cmds.items():
- if cmd in seen or not cmd.startswith(word_key):
+ if cmd in seen or not self._normalize_skill_token(cmd).startswith(word_key):
continue
# Exact match: trailing space keeps the dropdown open for the next stacked token.
yield _completion(
- f"{cmd} " if cmd == word_key else cmd, current_word, cmd,
+ f"{cmd} " if self._normalize_skill_token(cmd) == word_key else cmd, current_word, cmd,
f"⚡ {info.get('description', 'Skill command')}")
@staticmethod
diff --git a/tests/hermes_cli/test_cli_reload_skills.py b/tests/hermes_cli/test_cli_reload_skills.py
index 315c6547baf..2377cce86e0 100644
--- a/tests/hermes_cli/test_cli_reload_skills.py
+++ b/tests/hermes_cli/test_cli_reload_skills.py
@@ -23,6 +23,35 @@ def _make_cli():
class TestReloadSkillsCLI:
+ def test_reload_keeps_plugin_skill_lookup_live_after_plugin_lifecycle(self, tmp_path, monkeypatch):
+ import cli as cli_mod
+ from hermes_cli import plugins
+
+ home = tmp_path / "home"
+ plugin = home / "plugins" / "live-probe"
+ skill = plugin / "skills" / "guide" / "SKILL.md"
+ skill.parent.mkdir(parents=True)
+ (plugin / "plugin.yaml").write_text("name: live-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: Live guide.\n---\nBody.\n")
+ config = home / "config.yaml"
+ config.write_text("plugins:\n enabled: [live-probe]\n")
+ monkeypatch.setenv("HERMES_HOME", str(home))
+ monkeypatch.setattr(cli_mod, "_skill_commands", None)
+ plugins._reset_plugin_managers_for_tests()
+ try:
+ shell = _make_cli()
+ shell._reload_skills()
+ assert "/live-probe:guide" in cli_mod.get_skill_commands()
+ config.write_text("plugins:\n enabled: [live-probe]\nskills:\n disabled: [guide]\n")
+ assert "/live-probe:guide" not in cli_mod.get_skill_commands()
+ config.write_text("plugins:\n enabled: [live-probe]\n")
+ assert "/live-probe:guide" in cli_mod.get_skill_commands()
+ finally:
+ plugins._reset_plugin_managers_for_tests()
+
def test_reports_added_and_removed_and_queues_note(self, capsys):
cli = _make_cli()
with patch(
diff --git a/tests/hermes_cli/test_skill_stacked_completion.py b/tests/hermes_cli/test_skill_stacked_completion.py
index ccb5819e076..9c8c2e244ad 100644
--- a/tests/hermes_cli/test_skill_stacked_completion.py
+++ b/tests/hermes_cli/test_skill_stacked_completion.py
@@ -11,4 +11,13 @@ def test_stacked_completion_prefers_exact_underscored_plugin_key():
completer = SlashCommandCompleter(skill_commands_provider=lambda: commands)
assert completer._is_skill_command("/plugin:my_skill")
results = list(completer._stacked_skill_completions("/plugin:my_skill /other:"))
- assert [result.display_text for result in results] == ["/other:guide"]
\ No newline at end of file
+ assert [result.display_text for result in results] == ["/other:guide"]
+
+def test_stacked_completion_matches_underscored_current_prefix():
+ commands = {
+ "/other:guide": {"description": "Other"},
+ "/plugin:my_skill": {"description": "Underscored"},
+ }
+ completer = SlashCommandCompleter(skill_commands_provider=lambda: commands)
+ results = list(completer._stacked_skill_completions("/other:guide /plugin:my_"))
+ assert [result.display_text for result in results] == ["/plugin:my_skill"]
\ No newline at end of file
diff --git a/tests/tui_gateway/test_protocol.py b/tests/tui_gateway/test_protocol.py
index 2e705d14d3c..2e7ce6f2418 100644
--- a/tests/tui_gateway/test_protocol.py
+++ b/tests/tui_gateway/test_protocol.py
@@ -1486,6 +1486,7 @@ def test_plugin_skill_catalog_completion_dispatch_and_profile_switch(server, tmp
def test_slash_exec_plugin_command_precedes_colliding_skill(server, tmp_path, monkeypatch):
import agent.skill_commands as sc
+ from agent.skill_bundles import resolve_bundle_command_key
from hermes_cli import plugins
home = tmp_path / "home"
@@ -1496,8 +1497,13 @@ def test_slash_exec_plugin_command_precedes_colliding_skill(server, tmp_path, mo
(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"
- " ctx.register_command('collision:guide', lambda arg: 'plugin:' + arg)\n")
+ " ctx.register_command('collision:guide', lambda arg: 'plugin:' + arg)\n"
+ " ctx.register_command('collision-guide', lambda arg: 'bundle-plugin:' + arg)\n")
md.write_text("---\nname: guide\n---\nSkill body.\n")
+ bundles_dir = home / "skill-bundles"
+ bundles_dir.mkdir()
+ (bundles_dir / "collision-guide.yaml").write_text(
+ "name: collision-guide\nskills: [collision:guide]\n")
(home / "config.yaml").write_text("plugins:\n enabled: [collision]\n")
monkeypatch.setenv("HERMES_HOME", str(home))
plugins._reset_plugin_managers_for_tests()
@@ -1505,9 +1511,21 @@ def test_slash_exec_plugin_command_precedes_colliding_skill(server, tmp_path, mo
sid = "collision-session"
server._sessions[sid] = {"session_key": sid, "profile_home": home, "agent": None}
assert "/collision:guide" in sc.get_interactive_skill_commands()
- result = server.handle_request({"id": "r", "method": "slash.exec", "params": {
- "session_id": sid, "command": "/collision:guide hello"}})
- assert result["result"]["output"] == "plugin:hello"
+ assert resolve_bundle_command_key("collision-guide") == "/collision-guide"
+ for method, params in (
+ ("command.dispatch", {"session_id": sid, "name": "collision:guide", "arg": "hello"}),
+ ("slash.exec", {"session_id": sid, "command": "/collision:guide hello"}),
+ ):
+ result = server.handle_request({"id": "r", "method": method, "params": params})
+ assert result["result"]["output"] == "plugin:hello", (method, result)
+ for method, params in (
+ ("command.dispatch", {"session_id": sid, "name": "collision-guide", "arg": "hello"}),
+ ("slash.exec", {"session_id": sid, "command": "/collision-guide hello"}),
+ ):
+ result = server.handle_request({"id": "r", "method": method, "params": params})
+ expected = ({"output": "bundle-plugin:hello"} if method == "slash.exec" else
+ {"type": "plugin", "output": "bundle-plugin:hello"})
+ assert result["result"] == expected, (method, result)
finally:
plugins._reset_plugin_managers_for_tests()
diff --git a/tui_gateway/methods_tools.py b/tui_gateway/methods_tools.py
index 5e308a040dd..bb0331b4332 100644
--- a/tui_gateway/methods_tools.py
+++ b/tui_gateway/methods_tools.py
@@ -1137,11 +1137,9 @@ def _(rid, params: dict) -> dict:
if base in _WORKER_BLOCKED_COMMANDS and _is_snapshot_restore(arg):
return _err(rid, 4018, "snapshot restore mutates live config/state; use command.dispatch for /snapshot restore")
# Pending-input built-ins route straight to command.dispatch (some clients fail the
- # error-then-retry fallback); bundles go the same way under their resolved key.
- with _session_home_scope(session): # a secondary-only bundle must route too (#110695)
- target = base if base in _PENDING_INPUT_COMMANDS else _bundle_key_for(base)
- if target is not None:
- return _methods["command.dispatch"](rid, {"name": target.lstrip("/"), "arg": arg, "session_id": sid})
+ # error-then-retry fallback).
+ if base in _PENDING_INPUT_COMMANDS:
+ return _methods["command.dispatch"](rid, {"name": base, "arg": arg, "session_id": sid})
# Plugin commands have the same precedence as command.dispatch and the CLI;
# a same-named skill must not intercept them.
if plugin_handler := _plugin_command_handler(base) if base else None:
@@ -1149,6 +1147,10 @@ def _(rid, params: dict) -> dict:
return _ok(rid, {"output": _run_plugin_command(plugin_handler, arg, session) or "(no output)"})
except Exception as e:
return _ok(rid, {"output": f"Plugin command error: {e}"})
+ with _session_home_scope(session): # a secondary-only bundle must route too (#110695)
+ bundle_key = _bundle_key_for(base)
+ if bundle_key is not None:
+ return _methods["command.dispatch"](rid, {"name": bundle_key.lstrip("/"), "arg": arg, "session_id": sid})
# Recognized skills keep the 4018 gate so clients command.dispatch. A scan
# exception must not fail open into the worker: return the dispatch payload
# (or a hard error) here, or the loading banner swallows the prompt.