Skip to content

The agent that grows with you

fix(plugins): an installed directory plugin keeps its identity over a same-name pip entry point

teknium19dda4332f80c
diff --git a/hermes_cli/plugins.py b/hermes_cli/plugins.py
index b3b0df18f7f..15fa39d7154 100644
--- a/hermes_cli/plugins.py
+++ b/hermes_cli/plugins.py
@@ -1318,7 +1318,11 @@ class PluginManager(PluginLoaderMixin, PluginDispatchMixin, PluginLedgerMixin):
manifests: List[PluginManifest] = self._collect_directory_manifests()
# Entry points are separate from the directory scan: the startup MCP probe must not import
# or register them.
- ep_manifests = self._scan_entry_points()
+ # An installed directory plugin keeps its identity when its own pip dependency also ships an
+ # entry point under the same name (the pyproject wrapper shape): the directory is what the
+ # user installed, carries catalog provenance and is what update/remove act on.
+ directory_keys = {manifest_key(m) for m in manifests}
+ ep_manifests = [m for m in self._scan_entry_points() if manifest_key(m) not in directory_keys]
logger.debug(" entrypoints: %d manifest(s)", len(ep_manifests))
manifests.extend(ep_manifests)
disabled = _get_disabled_plugins()
diff --git a/hermes_cli/plugins_cmd.py b/hermes_cli/plugins_cmd.py
index 7bbdf3e5085..f06630aca94 100644
--- a/hermes_cli/plugins_cmd.py
+++ b/hermes_cli/plugins_cmd.py
@@ -1376,7 +1376,8 @@ def _scan_level(base: Path, source: str, skip_names: set, prefix: str, depth: in
def _discover_all_plugins() -> list:
"""``(name, version, description, source, dir_path, key)`` for every plugin the loader sees,
- in ``PluginManager.discover_and_load`` order: bundled, user, entry points (later wins)."""
+ in ``PluginManager.discover_and_load`` order: bundled, user, then entry points — which never
+ displace a directory plugin of the same key (see ``PluginManager._discover_and_load_inner``)."""
seen: dict = {}
# memory/, context_engine/ and model-providers/ load through dedicated registries, not the
# PluginManager opt-in surface, so listing them as toggleable plugins would mislead.
@@ -1388,7 +1389,7 @@ def _discover_all_plugins() -> list:
_scan_level(base, source, skip, "", 0, seen)
# Entry-point plugins are installed as Python packages, so they have no plugin directory.
for m in discover_entrypoint_manifests():
- seen[m.name] = (m.name, m.version, m.description, "entrypoint", m.path, m.name)
+ seen.setdefault(m.name, (m.name, m.version, m.description, "entrypoint", m.path, m.name))
return list(seen.values())
diff --git a/tests/hermes_cli/test_plugin_manifest_v2.py b/tests/hermes_cli/test_plugin_manifest_v2.py
index 5a8b0d900ee..d31385dbaf6 100644
--- a/tests/hermes_cli/test_plugin_manifest_v2.py
+++ b/tests/hermes_cli/test_plugin_manifest_v2.py
@@ -432,3 +432,28 @@ class TestRequiresHermes:
for attr in ("_rh_future", "_rh_current"):
if hasattr(sys, attr):
delattr(sys, attr)
+
+
+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 (it
+ carries catalog provenance and is what update/remove act on); the entry point must not displace it."""
+
+ def test_loader_and_listing_prefer_the_installed_directory(self, hermes_home, monkeypatch):
+ from hermes_cli.plugins_manifest import PluginManifest
+ _write_plugin(hermes_home / "plugins", "twin")
+ _enable(hermes_home, ["twin"])
+ twin_ep = PluginManifest(name="twin", version="9.9.9", description="pip twin",
+ source="entrypoint", path="twin_pkg:register", key="twin")
+ monkeypatch.setattr(PluginManager, "_scan_entry_points", lambda self: [twin_ep])
+ monkeypatch.setattr("hermes_cli.plugins_cmd.discover_entrypoint_manifests", lambda: [twin_ep], raising=False)
+ monkeypatch.setattr("hermes_cli.plugins.discover_entrypoint_manifests", lambda: [twin_ep])
+
+ mgr = PluginManager()
+ mgr.discover_and_load()
+ assert mgr._plugins["twin"].manifest.source == "user"
+
+ from hermes_cli.plugins_cmd import _discover_all_plugins
+ rows = [r for r in _discover_all_plugins() if r[0] == "twin"]
+ assert [r[3] for r in rows] == ["user"]
+ assert str(rows[0][4]).endswith("plugins/twin")