The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(plugins): post-pull union re-sync for member-manifest plugins
ethernet130eeca51e08
diff --git a/hermes_cli/plugins_cmd.py b/hermes_cli/plugins_cmd.pyindex 2aab4e8592d..8efec2aa6ea 100644--- a/hermes_cli/plugins_cmd.py+++ b/hermes_cli/plugins_cmd.py@@ -1266,6 +1266,28 @@ def cmd_update(name: str) -> None:# __pycache__ compiled from the previous revision._clear_plugin_bytecode(target)+ # Member-manifest plugins: the pull may have changed its pyproject+ # pins — re-sync the union so new deps land (Task 5, plugin+ # auto-update plan). The venv stamp now includes member pyproject+ # CONTENT (Task 4), so a pins change forces the re-lock; a+ # content-identical pull is a no-op stamp match. Failures surface+ # the resolver's message (conflict = loud refusal, bisect ++ # write-back ride the shipped sync path) but never fail the update+ # itself — the plugin code is already updated.+ if (target / "pyproject.toml").is_file():+ try:+ import pm+ pm.sync_venv(explicit=True)+ except Exception as exc:+ console.print(+ f"[yellow]⚠[/yellow] Dependency re-sync failed for "+ f"{name}: {exc}"+ )+ console.print(+ "[dim]The plugin code updated; run `hermes pm install` "+ "to retry the dependency sync.[/dim]"+ )+# Copy any new .example files_copy_example_files(target, console)diff --git a/tests/hermes_cli/test_plugins_update_sync.py b/tests/hermes_cli/test_plugins_update_sync.pynew file mode 100644index 00000000000..29584eea8c4--- /dev/null+++ b/tests/hermes_cli/test_plugins_update_sync.py@@ -0,0 +1,88 @@+"""Tests: cmd_update post-pull union re-sync for member-manifest plugins.++Task 5 of the plugin auto-update plan: a plugin update whose pull changed+its pyproject pins must re-sync the venv union (new deps land); a sync+failure surfaces the resolver reason but never fails the update — the+plugin code is already updated.+"""++from __future__ import annotations++import json+from pathlib import Path+from unittest.mock import patch++import pytest++import hermes_cli.plugins_cmd as pc+++def plugin_env(tmp_path, monkeypatch):+ """An installed, provenanced, enabled plugin + injectable seams."""+ home = tmp_path / "home"+ plugins = home / "plugins"+ plug = plugins / "plug"+ (plug / ".git").mkdir(parents=True)+ (plug / "plugin.yaml").write_text("name: plug\n", encoding="utf-8")+ (home / "config.yaml").write_text("plugins:\n enabled: [plug]\n", encoding="utf-8")+ plugins.mkdir(parents=True, exist_ok=True)+ (plugins / ".install-metadata.json").write_text(+ json.dumps({"plug": {"pinned": False, "revision": "a" * 40,+ "source": "https://example/o/r"}}),+ encoding="utf-8",+ )+ monkeypatch.setenv("HERMES_HOME", str(home))+ import hermes_constants++ monkeypatch.setattr(hermes_constants, "get_hermes_home", lambda: home)+ monkeypatch.setattr(pc, "_plugins_dir", lambda: plugins)+ monkeypatch.setattr(+ pc, "_scan_on_install_enabled", lambda: False+ )+ monkeypatch.setattr(+ pc, "_git_pull_plugin_dir",+ lambda target: (True, "ok"),+ )+ monkeypatch.setattr(pc, "_resolve_git_executable", lambda: None)+ monkeypatch.setattr(pc, "_read_install_metadata", lambda: {+ "plug": {"pinned": False, "revision": "a" * 40,+ "source": "https://example/o/r"}+ })+ monkeypatch.setattr(pc, "_write_install_metadata", lambda m: None)+ monkeypatch.setattr(pc, "_get_enabled_set", lambda: {"plug"})+ monkeypatch.setattr(pc, "_get_disabled_set", lambda: set())+ monkeypatch.setattr(pc, "_copy_example_files", lambda t, c: None)+ return plug+++def test_member_plugin_triggers_post_pull_sync(plugin_env, monkeypatch):+ (plugin_env / "pyproject.toml").write_text("[project]\n", encoding="utf-8")+ synced = []+ import pm++ monkeypatch.setattr(pm, "sync_venv", lambda extras=None, **k: synced.append(extras))+ pc.cmd_update("plug")+ assert synced == [None] # explicit sync with recorded extras+++def test_plain_plugin_skips_sync(plugin_env, monkeypatch):+ # no pyproject.toml — nothing to union+ import pm++ synced = []+ monkeypatch.setattr(pm, "sync_venv", lambda extras=None, **k: synced.append(extras))+ pc.cmd_update("plug")+ assert synced == []+++def test_sync_failure_surfaces_but_update_succeeds(plugin_env, monkeypatch, capsys):+ (plugin_env / "pyproject.toml").write_text("[project]\n", encoding="utf-8")+ import pm++ def boom(extras=None, **k):+ raise pm.InstallError("venv", "uv lock exited 1: unsatisfiable")++ monkeypatch.setattr(pm, "sync_venv", boom)+ # must NOT raise — the plugin code is already updated+ pc.cmd_update("plug")\ No newline at end of file