The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(plugins): a memory-provider install activates through memory.provider
Konstantin Khlopkov7f43fb2611bf
diff --git a/hermes_cli/plugins_cmd_install.py b/hermes_cli/plugins_cmd_install.pyindex 3befb589784..acc33eb0ddf 100644--- a/hermes_cli/plugins_cmd_install.py+++ b/hermes_cli/plugins_cmd_install.py@@ -562,8 +562,13 @@ def cmd_install(should_enable = False if no_deps else enableif no_deps:console.print("[dim]--no-deps: skipping dependency consent; the plugin stays disabled.[/dim]")+ # A memory provider activates through memory.provider alone; the loader never reads plugins.enabled.+ from plugins.memory import _is_memory_provider_dir+ is_memory_provider = (entry.category == "memory") if entry is not None else _is_memory_provider_dir(target)if should_enable is None and not already_active:- should_enable = _pc()._is_tty() and _pc()._ask_yes(f" Enable '{installed_name}' now? [y/N]: ")+ should_enable = _pc()._is_tty() and _pc()._ask_yes(+ f" Use '{installed_name}' as the memory provider now? [y/N]: " if is_memory_provider+ else f" Enable '{installed_name}' now? [y/N]: ")deps_ok, deps_reason = (True, None)if should_enable and not already_active:deps_ok, deps_reason = _install_plugin_python_deps(installed_manifest, target, console,@@ -590,6 +595,8 @@ def cmd_install(if already_active:console.print("[dim]Replacement installed; plugin selection was not changed.[/dim]")+ elif is_memory_provider:+ _select_memory_provider(target.name, console, select=should_enable)elif should_enable:from hermes_cli.plugins_admission import AdmissionRefused@@ -613,13 +620,34 @@ def cmd_install(declared_caps = _pc()._declared_capabilities_from_manifest(installed_manifest, installed_name)if declared_caps:_pc()._run_capability_consent(console, installed_name, declared_caps, context="install")- if enable:+ if enable and not is_memory_provider:# Loads it into the running gateway now (handlers live) or says what needs a restart (#87770).from hermes_cli.plugins_activation import activate_plugin_now, activation_hintconsole.print(f"[dim]{activation_hint(activate_plugin_now(installed_name, in_process=False))}[/dim]")console.print()+def _select_memory_provider(name: str, console, *, select: bool) -> None:+ """Make *name* the live memory provider (deps prepared through PM first, as ``hermes memory setup``+ does), or say how to; ``plugins enable`` cannot activate one (#119909)."""+ if not select:+ console.print(+ f"[dim]Memory provider installed but not active. Run `hermes memory setup` "+ f"(or set memory.provider: {name}) to use it.[/dim]")+ return+ from hermes_cli.memory_setup import prepare_memory_provider_dependencies+ try:+ prepare_memory_provider_dependencies(name)+ except Exception as exc: # resolver conflict, network, PM refusal: report, leave the selection alone+ console.print(f"[red]✗[/red] Could not prepare {name}'s dependencies: {exc}")+ console.print("[dim]memory.provider is unchanged; run `hermes memory setup` after resolving it.[/dim]")+ return+ _pc()._save_memory_provider(name)+ console.print(+ f"[green]✓[/green] [bold]{name}[/bold] set as memory.provider. "+ f"Run `hermes memory setup {name}` to configure it; new sessions use it.")++def dashboard_install_plugin(identifier: str, *, force: bool, enable: bool, catalog_name: Optional[str] = None,ref: Optional[str] = None, assume_deps_consent: bool = False,diff --git a/tests/hermes_cli/test_plugins_cmd_catalog.py b/tests/hermes_cli/test_plugins_cmd_catalog.pyindex f97d931bc45..c00bea3e7e6 100644--- a/tests/hermes_cli/test_plugins_cmd_catalog.py+++ b/tests/hermes_cli/test_plugins_cmd_catalog.py@@ -332,6 +332,59 @@ def test_kill_list_covers_update_enable_and_load_of_an_installed_plugin(world, tassert gate_manifest(manifest, set(), {"killed"}).action == "load"[email protected]("enable", [True, False])+def test_memory_category_install_activates_via_memory_provider_not_plugins_enable(world, monkeypatch, enable):+ """A category:memory install activates through memory.provider alone — the loader never consults+ plugins.enabled — so "Enable now?" must select the provider, and a decline must point at+ `hermes memory setup`, never at the dead-end `plugins enable` hint."""+ repo = world["repo"]+ (repo / "__init__.py").write_text("def register_memory_provider(ctx):\n pass\n")+ world["state"]["pin"] = _commit(repo, "memory provider contract")++ def _memory_entries():+ return [pc_cat.PluginCatalogEntry(name="cat-plugin", repo=repo.as_uri(), sha=world["state"]["pin"],+ description="d", maintainer="t", category="memory")]++ monkeypatch.setattr(pc_cat, "load_catalog", lambda catalog_dir=None: _memory_entries())+ printed: list[str] = []++ def _capture(*args, **_kwargs):+ printed.extend(str(a) for a in args)++ monkeypatch.setattr(pc, "_console",+ lambda: type("C", (), {"print": staticmethod(_capture)})())++ pc.cmd_install("cat-plugin", enable=enable)+ assert pc._get_current_memory_provider() == ("cat-plugin" if enable else "")+ assert pc._get_enabled_set() == set()+ assert any("hermes memory setup" in line for line in printed)+ assert not any("plugins enable cat-plugin" in line for line in printed)+++def test_url_install_of_a_memory_provider_dir_gets_the_provider_hint(world, tmp_path, monkeypatch):+ """A URL (non-catalog) install whose tree satisfies the memory-provider contract gets the same+ provider activation path — the catalog category is a shortcut, not the only trigger."""+ repo = tmp_path / "mem-repo"+ repo.mkdir()+ (repo / "plugin.yaml").write_text("name: mem-plugin\nversion: 1.0.0\ndescription: d\n")+ (repo / "__init__.py").write_text("from plugins.memory import MemoryProvider\n")+ sp.run(["git", "init", "-q"], cwd=repo, check=True, env=_GIT_ENV)+ _commit(repo, "v1")++ printed: list[str] = []++ def _capture(*args, **_kwargs):+ printed.extend(str(a) for a in args)++ monkeypatch.setattr(pc, "_console",+ lambda: type("C", (), {"print": staticmethod(_capture)})())++ pc.cmd_install(repo.as_uri(), enable=True)+ assert pc._get_current_memory_provider() == "mem-plugin"+ assert pc._get_enabled_set() == set()+ assert any("memory.provider" in line for line in printed)++def test_annotated_tag_pin_keeps_reviewed_trust_and_reads_as_at_pin(world, monkeypatch):"""A pin recorded as `git rev-parse <tag>` names the TAG object; HEAD can only ever be the commit itpoints at. Trust (scan skips the caution prompt) and the at-pin check must both use the peeled commit,