Files
hermes-agent/tests/tui_gateway/test_plugins_manage_install_ref.py
Teknium 6d89c1afde feat(plugins): pin a plugin to a commit from Desktop, and show pins in every list
Only the CLI could install a plugin at an exact commit (`--ref <sha>`); the
Desktop "Install from Git" dialog, the TUI gateway `plugins.manage install`
method and the dashboard `/agent-plugins/install` endpoint all called
`_install_plugin_core` without a ref, so a team that wanted everyone on the
same private-plugin commit had to leave the app for a terminal.

- `dashboard_install_plugin(ref=)` threads the pin to `_install_plugin_core`;
  the 40-hex validation and HEAD verification are unchanged. The gateway
  method and dashboard body accept `ref`.
- Desktop dialog gains an optional "Pin to commit" field (custom sources only,
  client-side 40-hex check disables Install on anything shorter).
- `plugins.manage list` rows carry `pinned_sha`; the Desktop plugins tab shows
  a `pinned @ <sha8>` badge and `hermes plugins list` prints `git pinned@<sha8>`
  in Source, so a team can eyeball that everyone runs the same commit.
2026-09-10 05:09:15 -07:00

25 lines
1.3 KiB
Python

"""Desktop/TUI ``plugins.manage`` honours a ``ref`` pin exactly like ``hermes plugins install --ref``."""
from unittest.mock import patch
from tui_gateway import methods_tools, server
def test_plugins_manage_install_threads_ref_to_headless_install():
sha = "a" * 40
with patch("hermes_cli.plugins_cmd.dashboard_install_plugin", return_value={"ok": True}) as install:
server.handle_request({"id": "1", "method": "plugins.manage",
"params": {"action": "install", "identifier": "org/private-plugin", "ref": sha}})
assert install.call_args.kwargs["ref"] == sha
def test_plugins_manage_list_reports_ref_pin(monkeypatch, tmp_path):
sha = "b" * 40
pc = methods_tools._tools_mod("hermes_cli.plugins_cmd")
monkeypatch.setattr(pc, "_discover_all_plugins", lambda: [("team-plugin", "1.0", "", "git", tmp_path, "team-plugin")])
monkeypatch.setattr(pc, "_read_install_metadata", lambda: {"team-plugin": {"pinned": True, "revision": sha, "source": "x"}})
monkeypatch.setattr(pc, "_get_enabled_set", set)
monkeypatch.setattr(pc, "_get_disabled_set", set)
monkeypatch.setattr(methods_tools._tools_mod("hermes_cli.plugins_cmd_catalog"), "catalog_pins", dict)
(row,) = methods_tools._plugin_rows()
assert row["pinned_sha"] == sha