The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(plugins): share the loader's SUPPORTED_MANIFEST_VERSION with the installer (#85879)
webdevtodayjason118984d7a02f
diff --git a/hermes_cli/plugins_cmd.py b/hermes_cli/plugins_cmd.pyindex a16a7af3d66..a234264c446 100644--- a/hermes_cli/plugins_cmd.py+++ b/hermes_cli/plugins_cmd.py@@ -165,10 +165,6 @@ def _scan_plugin_tree(plugin_dir: Path, identifier: str, *, force: bool, scan_dereturn result-# Highest ``manifest_version`` this installer understands; breaking schema changes bump it.-_SUPPORTED_MANIFEST_VERSION = 1--def _plugins_dir() -> Path:"""Return the user plugins directory, creating it if needed."""plugins = get_hermes_home() / "plugins"@@ -595,11 +591,14 @@ def _check_manifest_version(manifest: dict, plugin_name: str) -> None:raise PluginOperationError(f"Plugin '{plugin_name}' has invalid manifest_version '{mv}' (expected an integer).",) from None- if mv_int > _SUPPORTED_MANIFEST_VERSION:+ # Shared with the runtime loader so the installer can never drift behind what the loader+ # accepts (#85879): a private cap here refused v2 manifests the runtime happily loads.+ from hermes_cli.plugins_manifest import SUPPORTED_MANIFEST_VERSION+ if mv_int > SUPPORTED_MANIFEST_VERSION:from hermes_cli.config import recommended_update_commandraise PluginOperationError(f"Plugin '{plugin_name}' requires manifest_version {mv}, "- f"but this installer only supports up to {_SUPPORTED_MANIFEST_VERSION}. "+ f"but this Hermes supports up to {SUPPORTED_MANIFEST_VERSION}. "f"Run {recommended_update_command()} to update Hermes.",) from Nonediff --git a/tests/hermes_cli/test_plugin_install_manifest_version.py b/tests/hermes_cli/test_plugin_install_manifest_version.pynew file mode 100644index 00000000000..938762f406c--- /dev/null+++ b/tests/hermes_cli/test_plugin_install_manifest_version.py@@ -0,0 +1,84 @@+"""Installer accepts every manifest_version the runtime loader supports (#85879).++The installer used to carry its own private manifest-version cap, which+drifted behind the loader's ``SUPPORTED_MANIFEST_VERSION`` and refused v2+plugins the runtime happily loads. These tests install through the real+clone path so the two can never split again on the next bump.+"""++from __future__ import annotations++import subprocess+from pathlib import Path++import pytest+import yaml++from hermes_cli.plugins import SUPPORTED_MANIFEST_VERSION+++def _git(repo: Path, *args: str) -> str:+ result = subprocess.run(+ ["git", *args], cwd=repo, check=True, capture_output=True, text=True+ )+ return result.stdout.strip()+++def _plugin_repo(root: Path, manifest: dict) -> Path:+ repo = root / "repo"+ repo.mkdir()+ _git(repo, "init", "-q")+ _git(repo, "config", "user.email", "[email protected]")+ _git(repo, "config", "user.name", "Fixture")+ (repo / "plugin.yaml").write_text(yaml.safe_dump(manifest), encoding="utf-8")+ _git(repo, "add", ".")+ _git(repo, "commit", "-qm", "init")+ return repo+++ "manifest_version", list(range(1, SUPPORTED_MANIFEST_VERSION + 1))+)+def test_install_accepts_every_loader_supported_manifest_version(+ monkeypatch, tmp_path, manifest_version+):+ from hermes_cli.plugins_cmd import _install_plugin_core++ repo = _plugin_repo(+ tmp_path,+ {"name": "demo", "version": "1.0.0", "manifest_version": manifest_version},+ )+ home = tmp_path / "home"+ monkeypatch.setenv("HERMES_HOME", str(home))++ target, manifest, name = _install_plugin_core(repo.as_uri(), force=False)++ assert name == "demo"+ assert target.exists()+ assert int(manifest["manifest_version"]) == manifest_version+++def test_manifest_version_above_shared_support_is_refused_cleanly(+ monkeypatch, tmp_path+):+ from hermes_cli.plugins_cmd import PluginOperationError, _install_plugin_core++ repo = _plugin_repo(+ tmp_path,+ {+ "name": "demo",+ "version": "1.0.0",+ "manifest_version": SUPPORTED_MANIFEST_VERSION + 1,+ },+ )+ home = tmp_path / "home"+ monkeypatch.setenv("HERMES_HOME", str(home))++ with pytest.raises(+ PluginOperationError,+ match=rf"supports up to {SUPPORTED_MANIFEST_VERSION}\b",+ ):+ _install_plugin_core(repo.as_uri(), force=False)++ assert not (home / "plugins" / "demo").exists()+ assert not (home / "plugins" / ".install-metadata.json").exists()