The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): take the gateway's skill list again when a dropped plugin command is dispatched again
unsupportedpastels6df7e00d41b9
diff --git a/cli.py b/cli.pyindex 03bfb891792..6852a35046e 100644--- a/cli.py+++ b/cli.py@@ -1215,6 +1215,7 @@ class HermesCLI(CLIInitMixin, CLITuiRuntimeMixin, CLIProcessNotificationsMixin,gone = self._run_plugin_slash_command(base_cmd, user_args) is gateway_plugin_commands.GONEif not gone:return True+ skill_commands = _session_skill_commands(self) # the reload may have changed the skillsif base_cmd in skill_bundles: # also a name a gateway plugin reload just dropped (GONE)self._run_skill_bundle_command(base_cmd, skill_bundles[base_cmd], user_args)elif base_cmd in skill_commands:diff --git a/tests/gateway/test_cli_plugin_command_in_gateway.py b/tests/gateway/test_cli_plugin_command_in_gateway.pyindex ed619289935..86939dec5aa 100644--- a/tests/gateway/test_cli_plugin_command_in_gateway.py+++ b/tests/gateway/test_cli_plugin_command_in_gateway.py@@ -315,12 +315,14 @@ def test_a_command_a_plugin_reload_removed_is_dispatched_again(tmp_path, monkeypfrom gateway.control_socket import reload_gateway_plugins_no_local_plugins(monkeypatch)ran_skill = []- monkeypatch.setattr(cli_mod, '_ensure_skill_commands', lambda: {'/pptwin': {'name': 'pptwin'}})+ monkeypatch.setattr(cli_mod, '_ensure_skill_commands', dict) # the skill is the gateway's, belowmonkeypatch.setattr(cli_mod, 'get_skill_bundles', dict)monkeypatch.setattr(HermesCLI, '_run_skill_slash_command', lambda self, *a: ran_skill.append(a[0]))work = tmp_path / 'work'work.mkdir()with _plugin_home(tmp_path, _RELOADED.replace('TWIN', _TWIN)) as (root, home, env):+ (home / 'skills' / 'pptwin').mkdir(parents=True)+ (home / 'skills' / 'pptwin' / 'SKILL.md').write_text('---\nname: pptwin\ndescription: Twin skill\n---\nSay SKILL_TWIN.\n')with daemon(root, home, env, barrier=True, fixture='plugin_mcp_daemon.py') as (proc, desc):wire = _Wire(home, desc)try:diff --git a/tests/hermes_cli/test_gateway_plugin_commands.py b/tests/hermes_cli/test_gateway_plugin_commands.pyindex f1a98eb331e..46877990f5b 100644--- a/tests/hermes_cli/test_gateway_plugin_commands.py+++ b/tests/hermes_cli/test_gateway_plugin_commands.py@@ -356,11 +356,13 @@ def test_completion_lists_the_gateways_plugin_commands(local_plugin_reads):assert local_plugin_reads == []-def _unloaded_since_the_cached_read(monkeypatch, name):- """The CLI ran ``/name`` and cached the catalog; then a gateway plugin reload dropped it (same- session, same gateway life), so ``slash.exec`` refuses it as the gateway does."""+def _unloaded_since_the_cached_read(monkeypatch, name, skills=()):+ """The CLI ran ``/name`` and cached the catalog (``skills``: the session's skill commands the+ gateway lists); then a gateway plugin reload dropped it (same session, same gateway life), so+ ``slash.exec`` refuses it as the gateway does."""from hermes_cli.gateway_client import GatewayRPCErrorconn = _Conn({name: "Before the reload"})+ conn.extra = {"skills": {"/" + skill: {} for skill in skills}}c = _cli(monkeypatch, conn)c._process_unregistered_slash(f"/{name}", f"/{name}")conn._plugins, conn._reply = {}, GatewayRPCError("unsupported_command")@@ -381,9 +383,8 @@ def test_a_command_a_reload_unloaded_is_named_not_the_raw_refusal(monkeypatch, cdef test_a_same_named_skill_runs_once_a_reload_unloaded_the_plugin_command(monkeypatch, capsys):- conn, c = _unloaded_since_the_cached_read(monkeypatch, "pptwin")+ conn, c = _unloaded_since_the_cached_read(monkeypatch, "pptwin", skills=["pptwin"])ran = []- monkeypatch.setattr(cli_mod, "_ensure_skill_commands", lambda: {"/pptwin": {"name": "pptwin"}})monkeypatch.setattr(HermesCLI, "_run_skill_slash_command", lambda self, *a: ran.append(a[0]))capsys.readouterr()for _ in range(2):@@ -392,13 +393,26 @@ def test_a_same_named_skill_runs_once_a_reload_unloaded_the_plugin_command(monkeassert _execs(conn) == ["pptwin"] * 2 # the first run and the one refusal; the skill follows+def test_a_skill_the_same_reload_brought_runs_on_the_first_try(monkeypatch, capsys):+ """One reload dropped the plugin command and the gateway now lists a same-named skill the cached+ catalog lacked: the re-read after the refusal is what dispatch uses, so the skill runs at once."""+ conn, c = _unloaded_since_the_cached_read(monkeypatch, "pptwin")+ conn.extra = {"skills": {"/pptwin": {}}}+ ran = []+ monkeypatch.setattr(HermesCLI, "_run_skill_slash_command", lambda self, *a: ran.append(a[0]))+ capsys.readouterr()+ assert c._process_unregistered_slash("/pptwin", "/pptwin") is True+ out = capsys.readouterr().out+ assert ran == ["/pptwin"] and "nothing was run" not in out, out+ assert _execs(conn) == ["pptwin"] * 2 and _catalog_reads(conn) == 2 # the refusal's one re-read++def test_a_skill_reply_for_an_unloaded_plugin_command_runs_the_skill_here(monkeypatch, capsys):"""The gateway answers the dropped name for its own same-named skill (``type: skill``): there-read shows no plugin command, so the CLI's skill dispatch runs it, as for a refusal."""- conn, c = _unloaded_since_the_cached_read(monkeypatch, "pptwin")+ conn, c = _unloaded_since_the_cached_read(monkeypatch, "pptwin", skills=["pptwin"])conn._reply = {"type": "skill", "name": "pptwin", "message": "skill body"}ran = []- monkeypatch.setattr(cli_mod, "_ensure_skill_commands", lambda: {"/pptwin": {"name": "pptwin"}})monkeypatch.setattr(HermesCLI, "_run_skill_slash_command", lambda self, *a: ran.append(a[0]))assert c._process_unregistered_slash("/pptwin", "/pptwin") is Trueassert ran == ["/pptwin"] and "nothing was run" not in capsys.readouterr().out