The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(plugins): LAZY_DEPS mirror plugin.yaml ranges; manifest parser names list-typed files and reads hooks:
teknium195481bb54d00
diff --git a/hermes_cli/plugins_manifest.py b/hermes_cli/plugins_manifest.pyindex 1fd45dc0375..e81fe50822b 100644--- a/hermes_cli/plugins_manifest.py+++ b/hermes_cli/plugins_manifest.py@@ -477,6 +477,10 @@ def parse_manifest_file(logger.warning("PyYAML not installed – cannot load %s", manifest_file)return Nonedata = fast_safe_load(manifest_file.read_text(encoding="utf-8")) or {}+ if not isinstance(data, Mapping):+ logger.warning("Failed to parse %s: top level must be a mapping, got %s (#14066)",+ manifest_file, type(data).__name__)+ return Nonename = data.get("name", plugin_dir.name)key = f"{prefix}/{plugin_dir.name}" if prefix else namekind = _manifest_kind(data, key, plugin_dir)@@ -487,7 +491,9 @@ def parse_manifest_file(description=data.get("description", ""), author=_display_author(data.get("author", "")),requires_env=data.get("requires_env", []),provides_tools=data.get("provides_tools", []),- provides_hooks=data.get("provides_hooks", []), source=source, path=str(plugin_dir),+ # ``hooks:`` is the spelling the bundled manifests carried for months; external copies of it+ # must keep declaring the same thing (#108371).+ provides_hooks=data.get("provides_hooks", data.get("hooks", [])), source=source, path=str(plugin_dir),kind=kind, key=key, requires_hermes=str(data.get("requires_hermes") or "").strip(),capabilities=_parse_declared_capabilities(data.get("capabilities"), name),**_parse_manifest_v2_fields(data, key), emits=data.get("emits") or [],diff --git a/pyproject.toml b/pyproject.tomlindex e366b8459da..e38e5a8349e 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -258,10 +258,12 @@ wake = []honcho = ["honcho-ai==2.2.0"]# Cloud memory providers — opt-in, lazy-installed via tools/lazy_deps.py-# (memory.supermemory / memory.mem0) at first use. Exact pins MUST match the-# LAZY_DEPS pins (enforced by tests/test_project_metadata.py). Deliberately-# excluded from [all] like honcho/hindsight so a quarantined upstream release-# can't break fresh installs.+# (memory.supermemory / memory.mem0) at first use. Where BOTH pin exactly the+# versions MUST match (enforced by tests/test_project_metadata.py); LAZY_DEPS+# entries that mirror a plugin.yaml range (mem0ai, hindsight-client) keep the+# extra as the floor install and never downgrade a newer compatible release.+# Deliberately excluded from [all] like honcho/hindsight so a quarantined+# upstream release can't break fresh installs.supermemory = ["supermemory==3.50.0"]mem0 = ["mem0ai==2.0.10"]# Image resize recovery for the vision tools. Pillow is now a CORE dependencydiff --git a/tests/hermes_cli/test_plugin_manifest_v2.py b/tests/hermes_cli/test_plugin_manifest_v2.pyindex d31385dbaf6..73a64f7a9ef 100644--- a/tests/hermes_cli/test_plugin_manifest_v2.py+++ b/tests/hermes_cli/test_plugin_manifest_v2.py@@ -412,6 +412,27 @@ class TestCtxHasPlugin:class TestRequiresHermes:+ def test_gate_reads_the_running_code_version_not_dist_metadata(self, monkeypatch):+ """An editable install's dist metadata is frozen at install time (0.21.0 here) while the checkout runs+ 0.21.4; the gate must compare against the code that is running."""+ import importlib.metadata+ from hermes_cli import plugins_manifest+ monkeypatch.setattr(importlib.metadata, "version", lambda name: "0.21.0")+ monkeypatch.setattr("hermes_cli.__version__", "0.21.4")+ assert plugins_manifest.running_hermes_version() == "0.21.4"+ assert plugins_manifest.version_satisfies(">=0.21.4", plugins_manifest.running_hermes_version())++ @pytest.mark.parametrize("spec, current, expected", [+ (">=99.0.0rc1", "0.21.4", False), # rc target used to parse as None -> clause silently dropped+ (">=0.23.0", "0.22.0rc1", False), # rc running version used to disable every gate+ (">=0.21.0", "0.22.0rc1", True),+ (">=1.2.3.post1", "1.2.3", True),+ ("banana", "0.21.4", True), # documented: unparseable target stays permissive+ ])+ def test_prerelease_spellings_gate(self, spec, current, expected):+ from hermes_cli.plugins_manifest import version_satisfies+ assert version_satisfies(spec, current) is expected+def test_unsatisfied_requires_hermes_skips_without_importing(self, hermes_home, monkeypatch):"""A too-new ``requires_hermes`` records an error and never runs register(); a satisfied one loads."""import sys@@ -434,6 +455,84 @@ class TestRequiresHermes:delattr(sys, attr)+class TestLoadIsolation:+ def test_sys_exit_in_plugin_is_isolated_and_named(self, hermes_home, caplog):+ """A plugin calling ``sys.exit()`` at import used to propagate SystemExit out of discovery: the whole+ registry emptied, ``_discovered`` reset and ``hermes chat`` exited 3 with no output. It must be+ recorded as that plugin's error while later plugins still load."""+ _write_plugin(hermes_home / "plugins", "b_exit")+ (hermes_home / "plugins" / "b_exit" / "__init__.py").write_text("import sys\nsys.exit(0)\n")+ _write_plugin(hermes_home / "plugins", "c_after")+ _enable(hermes_home, ["b_exit", "c_after"])+ mgr = PluginManager()+ with caplog.at_level(logging.WARNING, logger="hermes_cli.plugins"):+ mgr.discover_and_load() # must not raise+ assert mgr._discovered is True+ assert mgr._plugins["c_after"].enabled+ assert not mgr._plugins["b_exit"].enabled+ assert "SystemExit(0)" in (mgr._plugins["b_exit"].error or "")++ def test_keyboard_interrupt_still_propagates(self, hermes_home):+ _write_plugin(hermes_home / "plugins", "ctrlc")+ (hermes_home / "plugins" / "ctrlc" / "__init__.py").write_text("raise KeyboardInterrupt\n")+ _enable(hermes_home, ["ctrlc"])+ with pytest.raises(KeyboardInterrupt):+ PluginManager().discover_and_load()+++class TestBundledKeyShadowing:+ def test_impostor_dir_cannot_claim_a_bundled_key(self, tmp_path, monkeypatch, caplog):+ """``~/.hermes/plugins/impostor_dir/plugin.yaml`` with ``name: <bundled key>`` used to displace the+ bundled plugin silently, so ``hermes plugins enable <key>`` enabled unrelated code. The bundled+ manifest wins and the impostor is warned about; a same-named user copy still overrides (documented)."""+ home = tmp_path / "home"+ (home / "plugins").mkdir(parents=True)+ bundled = tmp_path / "bundled"+ monkeypatch.setenv("HERMES_HOME", str(home))+ monkeypatch.setenv("HERMES_ENABLE_PROJECT_PLUGINS", "0")+ monkeypatch.setenv("HERMES_BUNDLED_PLUGINS", str(bundled))+ _write_plugin(bundled, "genuine", register_body="import sys; sys._shadow_probe = 'bundled'")+ _write_plugin(bundled, "overridable", register_body="import sys; sys._override_probe = 'bundled'")+ _write_plugin(home / "plugins", "impostor_dir", manifest_extra={"name": "genuine"},+ register_body="import sys; sys._shadow_probe = 'impostor'")+ (home / "plugins" / "impostor_dir" / "plugin.yaml").write_text(+ yaml.dump({"name": "genuine", "version": "0.1.0", "description": "impostor"}))+ _write_plugin(home / "plugins", "overridable", register_body="import sys; sys._override_probe = 'user'")+ _enable(home, ["genuine", "overridable"])+ import sys+ try:+ with caplog.at_level(logging.INFO, logger="hermes_cli.plugins"):+ mgr = PluginManager()+ mgr.discover_and_load()+ assert mgr._plugins["genuine"].manifest.source == "bundled"+ assert sys._shadow_probe == "bundled"+ assert "impostor_dir" in caplog.text and "rename the directory" in caplog.text+ assert mgr._plugins["overridable"].manifest.source == "user"+ assert sys._override_probe == "user"+ assert "shadows the bundled copy" in caplog.text+ finally:+ for attr in ("_shadow_probe", "_override_probe"):+ if hasattr(sys, attr):+ delattr(sys, attr)+++class TestManifestParsingRobustness:+ def test_list_manifest_is_rejected_with_a_clear_reason_and_hooks_alias(self, hermes_home, caplog):+ """A list-typed plugin.yaml (#14066) names the actual problem instead of an AttributeError; the+ long-standing ``hooks:`` spelling still populates ``provides_hooks`` (#108371)."""+ from hermes_cli.plugins_discovery import scan_directory+ bad = hermes_home / "plugins" / "listy"+ bad.mkdir()+ (bad / "plugin.yaml").write_text("- name: listy\n")+ good = _write_plugin(hermes_home / "plugins", "hooky", manifest_extra={"hooks": ["pre_tool_call"]})+ with caplog.at_level(logging.WARNING, logger="hermes_cli.plugins"):+ manifests = {m.name: m for m in scan_directory(hermes_home / "plugins", "user")}+ assert "listy" not in manifests+ assert "top level must be a mapping" in caplog.text+ assert manifests["hooky"].provides_hooks == ["pre_tool_call"]+ assert manifests["hooky"].path == str(good)++class TestDirectoryPluginKeepsIdentityOverEntryPoint:"""A pyproject-wrapper plugin depends on a pip package that ships a ``hermes_agent.plugins``entry point under the SAME name. The installed directory must stay the plugin's identity (itdiff --git a/tests/tools/test_lazy_deps.py b/tests/tools/test_lazy_deps.pyindex 5adf2ba8c39..32a082636cd 100644--- a/tests/tools/test_lazy_deps.py+++ b/tests/tools/test_lazy_deps.py@@ -223,6 +223,13 @@ class TestIsSatisfiedVersionAware:self._fake_version(monkeypatch, {"mautrix": "0.20.0"})assert ld._is_satisfied("mautrix[encryption]==0.21.0") is False+ def test_plugin_owned_sdk_newer_compatible_release_is_satisfied(self, monkeypatch):+ """A newer release inside the plugin.yaml range must not be re-pinned downward on refresh+ (#86992 hindsight-client 0.9.x -> 0.6.1, #98407 mem0ai 2.0.19 -> 2.0.10)."""+ self._fake_version(monkeypatch, {"hindsight-client": "0.9.2", "mem0ai": "2.0.19"})+ assert ld.feature_missing("memory.hindsight") == ()+ assert ld.feature_missing("memory.mem0") == ()+def test_trace_upload_hub_at_core_locked_version_is_current(self, monkeypatch):"""#60783 regression: refresh must not churn the shared hub install.@@ -426,6 +433,34 @@ class TestRefreshActiveFeatures:class TestInstallSpecs:+ def test_uv_tier_runs_from_the_checkout_so_exclude_newer_applies(self, monkeypatch, tmp_path):+ """uv reads ``[tool.uv] exclude-newer`` from the cwd project only; a plugin-dep install launched from+ $HOME or a gateway service must still run under the checkout's quarantine, so the uv invocation+ carries the checkout root as cwd (#L1-3 of the 2026-09 plugin audit)."""+ import subprocess+ from pathlib import Path++ calls = []++ def fake_run(cmd, **kw):+ calls.append((cmd, kw))+ return subprocess.CompletedProcess(cmd, 0, stdout="", stderr="")++ monkeypatch.setattr(ld, "_run_installer", fake_run)+ monkeypatch.setattr(ld, "_uv_binary", lambda: "/fake/uv")+ monkeypatch.setattr(ld, "_lazy_install_target", lambda: None)+ monkeypatch.setattr(ld, "_after_successful_install", lambda *a, **kw: None)+ monkeypatch.chdir(tmp_path)+ project_root = Path(ld.__file__).resolve().parent.parent+ assert (project_root / "pyproject.toml").is_file()++ result = ld._venv_pip_install(("requests==2.32.0",))++ assert result.success+ (cmd, kw), = calls+ assert cmd[:3] == ["/fake/uv", "pip", "install"]+ assert kw.get("cwd") == str(project_root)+def test_empty_specs_is_trivially_ok(self, monkeypatch):monkeypatch.setattr(ld, "_venv_pip_install",diff --git a/tools/lazy_deps.py b/tools/lazy_deps.pyindex c9b4e16c02e..7e33d431aca 100644--- a/tools/lazy_deps.py+++ b/tools/lazy_deps.py@@ -107,11 +107,15 @@ LAZY_DEPS: dict[str, tuple[str, ...]] = {# ─── Memory providers ──────────────────────────────────────────────────"memory.honcho": ("honcho-ai==2.2.0",),- "memory.hindsight": ("hindsight-client==0.6.1",),+ # Plugin-owned SDKs mirror the range their plugin.yaml declares instead of an exact pin: an exact pin+ # made _is_satisfied() reject every newer compatible release, so `hermes update` (and the hindsight+ # plugin's own >=_MIN_CLIENT_VERSION auto-upgrade) kept downgrading a working 0.9.x client to 0.6.1+ # and broke embedded daemons whose DB a newer client had migrated (#86992, #39424, #98407).+ "memory.hindsight": ("hindsight-client>=0.6.1,<1",),# Cloud memory SDKs MUST be allowlisted + ensure()'d at the import site, or they never# install on the sealed Docker image (durable-target only)."memory.supermemory": ("supermemory==3.50.0",),- "memory.mem0": ("mem0ai==2.0.10",),+ "memory.mem0": ("mem0ai>=2.0.10,<3",),# ─── Messaging platforms (lazy-installable on demand) ──────────────────"platform.telegram": ("python-telegram-bot[webhooks]==22.8",),