Skip to content

The agent that grows with you

fix(memory): a missing catalog memory provider names its install command

teknium1d450c3659ecb
diff --git a/hermes_cli/_parser.py b/hermes_cli/_parser.py
index 4d29b39788c..77ca79105b5 100644
--- a/hermes_cli/_parser.py
+++ b/hermes_cli/_parser.py
@@ -319,6 +319,21 @@ def _build_chat_parser(subparsers) -> argparse.ArgumentParser:
return chat_parser
+def _plugin_command_install_hint(prog: str, value: str):
+ """Install command when *value* names a catalog memory plugin that resolves nowhere: its
+ ``hermes <name>`` command exists only once the plugin is installed. Top level only; never raises."""
+ if prog != "hermes" or not re.fullmatch(r"[a-z0-9_-]{1,64}", value):
+ return None
+ try:
+ from plugins.memory import find_provider_dir
+ if find_provider_dir(value) is not None:
+ return None
+ from hermes_cli.memory_provider_migration import catalog_install_hint
+ return catalog_install_hint(value, category="memory")
+ except Exception:
+ return None
+
+
class HermesArgumentParser(argparse.ArgumentParser):
"""argparse parser whose unknown-subcommand error is three short lines, not a 70-name dump.
@@ -334,7 +349,11 @@ class HermesArgumentParser(argparse.ArgumentParser):
# (argparse hands add_parser() the parent's class), so the copy stays correct for both.
lines = [f"{self.prog}: '{value}' is not a `{self.prog}` command."]
close = difflib.get_close_matches(str(value), list(action.choices), n=3, cutoff=0.6)
- if close:
+ install = _plugin_command_install_hint(self.prog, str(value))
+ if install:
+ # A provider that left core (``hermes honcho``) registers its command only once installed.
+ lines.append(f"The '{value}' memory plugin is not installed. Install it with: {install}")
+ elif close:
lines.append(f"Did you mean: {', '.join(close)}?")
lines.append(f"Run `{self.prog} --help` to see all commands.")
self.exit(2, "\n".join(lines) + "\n")
diff --git a/hermes_cli/doctor_state.py b/hermes_cli/doctor_state.py
index f6dea92a198..cb4db53ee1c 100644
--- a/hermes_cli/doctor_state.py
+++ b/hermes_cli/doctor_state.py
@@ -606,7 +606,10 @@ def _memory_provider_generic(name: str) -> None:
elif _provider:
check_warn(f"{name} configured but not available", "run: hermes memory status")
else:
- check_warn(f"{name} plugin not found", "run: hermes memory setup")
+ from plugins.memory import find_provider_dir
+ from hermes_cli.memory_provider_migration import catalog_install_hint
+ hint = catalog_install_hint(name, category="memory") if find_provider_dir(name) is None else None
+ check_warn(f"{name} plugin not found", f"run: {hint or 'hermes memory setup'}")
@doctor_check()
diff --git a/hermes_cli/memory_provider_migration.py b/hermes_cli/memory_provider_migration.py
index 4a8809d45fd..cf291306a10 100644
--- a/hermes_cli/memory_provider_migration.py
+++ b/hermes_cli/memory_provider_migration.py
@@ -59,6 +59,25 @@ def catalog_source(name: str) -> Optional[str]:
return entry.name if entry is not None else None
+def catalog_install_hint(name: str, *, category: Optional[str] = None) -> Optional[str]:
+ """``hermes [-p <profile>] plugins install <name>`` when this checkout's catalog ships plugin
+ *name* (of *category*, when given), else None.
+
+ Recovery copy for a provider that left core and is not installed (offline, lazy installs off, a
+ failed migration): doctor, ``memory status``, ``memory setup <name>`` and the CLI's unknown-command
+ error point at the one command that fixes it. In-tree catalog only, never the network — these run
+ offline and on error paths."""
+ try:
+ from hermes_cli.plugin_catalog import get_catalog_entry
+ entry = get_catalog_entry(name) if name else None
+ except Exception:
+ return None
+ if entry is None or (category is not None and entry.category != category):
+ return None
+ from hermes_constants import get_hermes_home
+ return _install_command(name, get_hermes_home())
+
+
def _pending_provider(home: Path, *, say: Callable[[str], None]) -> Optional[str]:
"""The provider *home* needs from the catalog, or None (nothing to do, or a catalog miss already
reported through *say*). Read-only."""
diff --git a/hermes_cli/memory_setup.py b/hermes_cli/memory_setup.py
index f4859289e8b..702fd22c5a3 100644
--- a/hermes_cli/memory_setup.py
+++ b/hermes_cli/memory_setup.py
@@ -154,6 +154,15 @@ def _find_provider(providers: list, provider_name: str):
return next((p for p in providers if p[0] == provider_name), None)
+def _catalog_install_hint(provider_name: str):
+ """The install command for a catalog memory provider that resolves nowhere, else None."""
+ from plugins.memory import find_provider_dir
+ from hermes_cli.memory_provider_migration import catalog_install_hint
+ if not provider_name or find_provider_dir(provider_name) is not None:
+ return None
+ return catalog_install_hint(provider_name, category="memory")
+
+
def _post_setup_hook(provider, config: dict) -> bool:
"""Normalize the ``memory`` block; True when the provider's ``post_setup`` took over (it owns
config, connection test and activation), so the caller must stop."""
@@ -172,7 +181,11 @@ def cmd_setup_provider(provider_name: str) -> None:
match = _find_provider(_get_available_providers(), provider_name)
if not match:
print(f"\n Memory provider '{provider_name}' not found.")
- print(" Run 'hermes memory setup' to see available providers.\n")
+ install = _catalog_install_hint(provider_name)
+ if install:
+ print(f" It is a catalog plugin that is not installed. Install it with: {install}\n")
+ else:
+ print(" Run 'hermes memory setup' to see available providers.\n")
return
name, _, provider = match
@@ -412,7 +425,11 @@ def cmd_status(args) -> None:
print(" set any variables above in the service environment.")
else:
print("\n Plugin: NOT installed ✗")
- print(f" Install the '{provider_name}' memory plugin to ~/.hermes/plugins/")
+ install = _catalog_install_hint(provider_name)
+ if install:
+ print(f" Install it with: {install}")
+ else:
+ print(f" Install the '{provider_name}' memory plugin to ~/.hermes/plugins/")
if providers:
print("\n Installed plugins:")
diff --git a/tests/hermes_cli/test_memory_provider_migration.py b/tests/hermes_cli/test_memory_provider_migration.py
index 9d9b7fc48a4..f9dd5814121 100644
--- a/tests/hermes_cli/test_memory_provider_migration.py
+++ b/tests/hermes_cli/test_memory_provider_migration.py
@@ -226,3 +226,38 @@ def test_startup_hint_installs_into_the_profile_that_printed_it(tmp_path, monkey
said: list[str] = []
assert mig.recover_at_startup("twin", say=said.append) is False
assert f"`{command}`" in said[0]
+
+
+def test_missing_catalog_provider_recovery_names_the_profile_install_command(tmp_path, monkeypatch, capsys):
+ """Offline, lazy installs off, or a failed migration: every surface a user turns to (doctor,
+ ``memory status``, ``memory setup honcho``, ``hermes honcho``) names the one command that installs
+ the catalog plugin into THIS profile. Real in-tree catalog, nothing installed."""
+ from types import SimpleNamespace
+ from hermes_cli import doctor_state, memory_setup
+ from hermes_cli._parser import build_top_level_parser
+
+ home = tmp_path / "profiles" / "work"
+ home.mkdir(parents=True)
+ (home / "config.yaml").write_text("memory:\n provider: honcho\n", encoding="utf-8")
+ monkeypatch.setenv("HERMES_HOME", str(home))
+ want = "hermes -p work plugins install honcho"
+
+ doctor_state._memory_provider_generic("honcho")
+ memory_setup.cmd_status(SimpleNamespace())
+ memory_setup.cmd_setup_provider("honcho")
+ assert capsys.readouterr().out.count(want) == 3
+ parser, _subparsers, _chat = build_top_level_parser()
+ with pytest.raises(SystemExit):
+ parser.parse_args(["honcho", "status"])
+ assert want in capsys.readouterr().err
+
+
+def test_recovery_copy_without_a_catalog_memory_entry_keeps_the_generic_hint(tmp_path, monkeypatch, capsys):
+ from hermes_cli import doctor_state
+
+ monkeypatch.setenv("HERMES_HOME", str(tmp_path)) # not a profile home: no -p to add
+ assert mig.catalog_install_hint("honcho", category="memory") == "hermes plugins install honcho"
+ assert mig.catalog_install_hint("honcho", category="tools") is None
+ assert mig.catalog_install_hint("no-such-provider") is None
+ doctor_state._memory_provider_generic("no-such-provider")
+ assert "run: hermes memory setup" in capsys.readouterr().out