Skip to content

The agent that grows with you

feat(plugins): hermes plugins update with no name offers every plugin update

Tekniumced2a3935069
diff --git a/hermes_cli/plugins_cmd.py b/hermes_cli/plugins_cmd.py
index 01e11246d36..2dc5bb13c77 100644
--- a/hermes_cli/plugins_cmd.py
+++ b/hermes_cli/plugins_cmd.py
@@ -1063,6 +1063,16 @@ def _catalog():
return plugins_cmd_catalog
+def _action_update(args):
+ if args.name:
+ if getattr(args, "yes", False):
+ _fail(_console(), "[red]Error:[/red] --yes only applies to `hermes plugins update` with no name.")
+ cmd_update(args.name)
+ return
+ from hermes_cli.plugins_cmd_update_all import cmd_update_all
+ cmd_update_all(yes=getattr(args, "yes", False))
+
+
def _action_pack(args):
from hermes_cli.plugin_packs import pack_command
pack_command(args)
@@ -1083,7 +1093,7 @@ _PLUGIN_ACTIONS = {
"browse": lambda args: _catalog().cmd_search(""),
"validate": lambda args: _catalog().cmd_validate(
args.path, as_json=getattr(args, "json", False), install_deps=getattr(args, "install_deps", False)),
- "update": lambda args: cmd_update(args.name),
+ "update": _action_update,
"adopt": lambda args: cmd_adopt(args.name),
"trust-update-url": lambda args: cmd_trust_update_url(args.name),
"check-updates": lambda args: cmd_check_updates(args),
diff --git a/hermes_cli/plugins_cmd_update.py b/hermes_cli/plugins_cmd_update.py
index 8ea12530e2e..a519142490c 100644
--- a/hermes_cli/plugins_cmd_update.py
+++ b/hermes_cli/plugins_cmd_update.py
@@ -269,7 +269,8 @@ def cmd_check_updates(args: Any | None = None) -> None:
console.print()
console.print(table)
console.print()
- console.print("[dim]Check-only. Apply with: hermes plugins update <name>[/dim]")
+ console.print("[dim]Check-only. Apply with: hermes plugins update <name>, or "
+ "hermes plugins update to update them all[/dim]")
def dashboard_update_user_plugin(name: str, *, accept_capabilities: bool = False) -> dict[str, Any]:
diff --git a/hermes_cli/plugins_cmd_update_all.py b/hermes_cli/plugins_cmd_update_all.py
new file mode 100644
index 00000000000..56096889400
--- /dev/null
+++ b/hermes_cli/plugins_cmd_update_all.py
@@ -0,0 +1,172 @@
+"""``hermes plugins update`` with no name: update every installed plugin that has an update.
+
+The list comes from the read-only ``check-updates`` probe (:func:`hermes_cli.plugins_updates.run_checks`);
+each plugin is then updated through the single-plugin :func:`~hermes_cli.plugins_cmd_update.cmd_update`
+path, so catalog consent, the security scan and capability re-consent still apply per plugin.
+
+Sibling of :mod:`hermes_cli.plugins_cmd` (the facade is imported late, never at module level).
+"""
+
+from __future__ import annotations
+
+import logging
+import re
+import sys
+from dataclasses import dataclass, field
+from typing import Any
+
+# Only these classes have an update path `hermes plugins update <name>` can drive: a catalog install
+# re-pins to the reviewed sha, a tracked git install pulls. A pip row is a PyPI distribution that
+# Hermes never upgrades (#132494), so offering it would promise an update nothing applies.
+_UPDATE_KIND = {"catalog": "catalog re-pin", "git": "git pull"}
+_ANSI_RE = re.compile(r"\x1b\[[0-9;?]*[ -/]*[@-~]")
+logger = logging.getLogger(__name__)
+
+
+def _pc():
+ from hermes_cli import plugins_cmd
+ return plugins_cmd
+
+
+@dataclass
+class UpdatePlan:
+ """What ``update`` with no name would do: *movable* rows it updates, *skipped* ``(row, reason)``
+ pairs it cannot move, *current* the count already up to date."""
+
+ movable: list[Any] = field(default_factory=list)
+ skipped: list[tuple[Any, str]] = field(default_factory=list)
+ current: int = 0
+
+
+def plan_update_all(results: list[Any]) -> UpdatePlan:
+ """Split ``run_checks`` rows into the plugins ``update`` can move and the ones it cannot (with why)."""
+ plan = UpdatePlan()
+ for row in results:
+ if row.needs_fixing:
+ plan.skipped.append((row, f"needs fixing: {row.needs_fixing}"))
+ elif row.update_available is True and row.klass in _UPDATE_KIND:
+ plan.movable.append(row)
+ elif row.update_available is True:
+ plan.skipped.append((row, f"{row.klass} distribution; Hermes does not upgrade it"))
+ elif row.update_available is None:
+ plan.skipped.append((row, row.reason or "update status unknown"))
+ elif row.reason: # up to date by construction but worth naming (pinned)
+ plan.skipped.append((row, row.reason))
+ else:
+ plan.current += 1
+ return plan
+
+
+class _Tee:
+ """Pass-through stdout that keeps what was written, so a failed update's own error message can
+ be quoted in the summary. Everything else (isatty, fileno, encoding) is the real stream's."""
+
+ def __init__(self, stream):
+ self._stream = stream
+ self.text: list[str] = []
+
+ def write(self, data):
+ self.text.append(data)
+ return self._stream.write(data)
+
+ def __getattr__(self, name):
+ return getattr(self._stream, name)
+
+ def failure_reason(self) -> str:
+ """The paragraph the single-plugin update printed with its refusal (``Error: ...`` or
+ ``... not applied``), rejoined from Rich's wrapping; else the last line printed."""
+ lines = [ln.strip() for ln in _ANSI_RE.sub("", "".join(self.text)).splitlines()]
+ start = next((i for i, ln in enumerate(lines) if ln.startswith("Error:") or "not applied" in ln), None)
+ if start is None:
+ return next((ln for ln in reversed(lines) if ln), "")
+ para = []
+ for ln in lines[start:]:
+ if not ln:
+ break
+ para.append(ln)
+ reason = " ".join(para)
+ return reason if len(reason) <= 200 else reason[:197] + "..."
+
+
+def _revision(name: str) -> str:
+ return str(_pc()._read_install_metadata().get(name, {}).get("revision") or "")
+
+
+def _update_one(name: str, *, interactive: bool) -> tuple[str, str]:
+ """Run the single-plugin update; return ``(status, detail)`` with status updated/current/failed."""
+ before = _revision(name)
+ tee = _Tee(sys.stdout)
+ sys.stdout = tee
+ try:
+ _pc().cmd_update(name, interactive=interactive)
+ except SystemExit as exc:
+ if exc.code not in (0, None):
+ return "failed", tee.failure_reason() or f"exit {exc.code}"
+ except Exception as exc: # one plugin's crash must not stop the rest
+ logger.warning("update of plugin %s failed", name, exc_info=True)
+ return "failed", f"{type(exc).__name__}: {exc}"
+ finally:
+ sys.stdout = tee._stream
+ after = _revision(name)
+ return ("updated", f"{before[:8]}..{after[:8]}") if after != before else ("current", "")
+
+
+def _print_plan(console, plan: UpdatePlan) -> None:
+ from rich.markup import escape
+ table = _pc()._table([("#", "dim"), ("Plugin", "bold"), ("Current", ""), ("Latest", ""), ("Update", "")],
+ title="Plugin updates available")
+ for i, row in enumerate(plan.movable, 1):
+ table.add_row(str(i), row.name, (row.current or "-")[:12], (row.latest or "-")[:12], _UPDATE_KIND[row.klass])
+ console.print()
+ console.print(table)
+ for row, reason in plan.skipped:
+ console.print(f" [dim]skipped {escape(row.name)} ({row.klass}): {escape(reason)}[/dim]")
+
+
+def cmd_update_all(*, yes: bool = False) -> None:
+ """``hermes plugins update [--yes]``: list the plugins with an update and update them all.
+
+ A terminal asks once (``Update all N? [Y/n]``); without one nothing moves unless ``--yes`` is
+ given. Each plugin then goes through ``cmd_update``, interactive only when a terminal is present,
+ so per-plugin consent prompts still appear there and stay closed (fail closed) under ``--yes``
+ in scripts. One failure does not stop the rest; exit 1 when any update failed.
+ """
+ from rich.markup import escape
+ from hermes_cli.plugins_updates import run_checks
+
+ console = _pc()._console()
+ console.print("[dim]Checking installed plugins for updates...[/dim]")
+ plan = plan_update_all(run_checks(_pc()._plugins_dir()))
+ if not plan.movable:
+ for row, reason in plan.skipped:
+ console.print(f" [dim]skipped {escape(row.name)} ({row.klass}): {escape(reason)}[/dim]")
+ console.print("[green]✓[/green] No plugin updates to apply.")
+ return
+ _print_plan(console, plan)
+ count = len(plan.movable)
+ tty = _pc()._is_tty()
+ if not yes:
+ if not tty:
+ _pc()._fail(console, f"[yellow]Not updating: no terminal to confirm. Re-run with --yes to update "
+ f"these {count} plugin(s).[/yellow]")
+ try:
+ answer = input(f"\nUpdate all {count}? [Y/n]: ").strip().lower()
+ except (EOFError, KeyboardInterrupt):
+ answer = "n"
+ if answer not in ("", "y", "yes"):
+ console.print("Cancelled. Nothing was updated.")
+ return
+
+ outcomes = []
+ for row in plan.movable:
+ console.print(f"\n[bold]── {row.name}[/bold]")
+ outcomes.append((row.name, *_update_one(row.name, interactive=tty)))
+
+ console.print("\n[bold]Summary[/bold]")
+ marks = {"updated": "[green]✓ updated[/green]", "current": "[dim]= already current[/dim]",
+ "failed": "[red]✗ failed[/red]"}
+ for name, status, detail in outcomes:
+ console.print(f" {marks[status]} {escape(name)}" + (f" [dim]{escape(detail)}[/dim]" if detail else ""),
+ highlight=False)
+ if any(status == "failed" for _, status, _ in outcomes):
+ sys.exit(1)
diff --git a/hermes_cli/subcommands/plugins.py b/hermes_cli/subcommands/plugins.py
index fe703ee56ee..1c71fd85bc2 100644
--- a/hermes_cli/subcommands/plugins.py
+++ b/hermes_cli/subcommands/plugins.py
@@ -66,8 +66,12 @@ def build_plugins_parser(subparsers, *, cmd_plugins: Callable) -> None:
add_json_flag(plugins_validate, "Print machine-readable JSON (for CI)")
plugins_update = plugins_subparsers.add_parser(
- "update", help="Pull latest changes for an installed plugin")
- plugins_update.add_argument("name", help="Plugin name to update")
+ "update", help="Update an installed plugin, or with no name every plugin that has an update")
+ plugins_update.add_argument(
+ "name", nargs="?", help="Plugin name to update (default: list every plugin with an update and offer them all)")
+ plugins_update.add_argument(
+ "--yes", "-y", action="store_true",
+ help="With no name: update everything listed without the confirmation question (required without a terminal)")
plugins_adopt = plugins_subparsers.add_parser(
"adopt",
diff --git a/tests/hermes_cli/test_plugins_update_all.py b/tests/hermes_cli/test_plugins_update_all.py
new file mode 100644
index 00000000000..e4c58c6b3da
--- /dev/null
+++ b/tests/hermes_cli/test_plugins_update_all.py
@@ -0,0 +1,72 @@
+"""`hermes plugins update` with no name: offer every plugin that has an update, never move one silently."""
+from __future__ import annotations
+
+import argparse
+
+import pytest
+
+from hermes_cli.plugins_updates import CheckResult
+
+
+def _parse(argv):
+ from hermes_cli.plugins_cmd import plugins_command
+ from hermes_cli.subcommands.plugins import build_plugins_parser
+
+ parser = argparse.ArgumentParser(prog="hermes")
+ build_plugins_parser(parser.add_subparsers(dest="command"), cmd_plugins=plugins_command)
+ return parser.parse_args(["plugins", *argv])
+
+
+def fleet(monkeypatch, tmp_path):
+ """Four installed rows: two the update path can move, a PyPI row it never upgrades (#132494) and a pin."""
+ from hermes_cli import plugins_cmd, plugins_updates
+
+ rows = [
+ CheckResult("cat", "catalog", current="a" * 40, latest="b" * 40, update_available=True),
+ CheckResult("gitty", "git", current="c" * 40, latest="d" * 40, update_available=True),
+ CheckResult("pypkg", "pip", current="1.0", latest="1.1", update_available=True),
+ CheckResult("pinned", "git", current="e" * 40, update_available=False, reason="pinned @ eeee"),
+ ]
+ calls = []
+
+ def fake_update(name, *, interactive=True):
+ calls.append((name, interactive))
+ if name == "cat":
+ plugins_cmd._fail(plugins_cmd._console(), "Error: catalog pin refused")
+
+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))
+ monkeypatch.setattr(plugins_updates, "run_checks", lambda plugins_dir, **kw: rows)
+ monkeypatch.setattr(plugins_cmd, "cmd_update", fake_update)
+ return calls
+
+
+def test_no_terminal_refuses_without_yes_and_updates_only_movable_rows_with_it(fleet, monkeypatch, capsys):
+ from hermes_cli import plugins_cmd
+
+ monkeypatch.setattr(plugins_cmd, "_is_tty", lambda: False)
+ args = _parse(["update"])
+ with pytest.raises(SystemExit) as refused:
+ plugins_cmd.plugins_command(args)
+ assert refused.value.code == 1 and fleet == []
+ assert "--yes" in capsys.readouterr().out
+
+ # --yes: every movable plugin goes through the single-plugin path non-interactively; the failure
+ # of the first does not stop the second, and the pip row / pin are never attempted.
+ with pytest.raises(SystemExit) as done:
+ plugins_cmd.plugins_command(_parse(["update", "--yes"]))
+ assert done.value.code == 1
+ assert fleet == [("cat", False), ("gitty", False)]
+ out = capsys.readouterr().out
+ assert "catalog pin refused" in out.split("Summary", 1)[1]
+ assert "skipped pypkg" in out and "skipped pinned" in out
+
+
+def test_terminal_asks_once_and_cancel_moves_nothing(fleet, monkeypatch, capsys):
+ from hermes_cli import plugins_cmd
+
+ monkeypatch.setattr(plugins_cmd, "_is_tty", lambda: True)
+ prompts = []
+ monkeypatch.setattr("builtins.input", lambda prompt="": prompts.append(prompt) or "n")
+ plugins_cmd.plugins_command(_parse(["update"]))
+ assert prompts == ["\nUpdate all 2? [Y/n]: "] and fleet == []
diff --git a/website/docs/reference/cli-commands.md b/website/docs/reference/cli-commands.md
index 9a6b5635594..65e5414d814 100644
--- a/website/docs/reference/cli-commands.md
+++ b/website/docs/reference/cli-commands.md
@@ -1664,6 +1664,7 @@ Unified plugin management — general plugins, memory providers, and context eng
| `install <identifier> [--force] [--ref COMMIT_SHA] [--allow-removed]` | Install a plugin from the Hermes plugin catalog (bare entry name), a Git URL, or `owner/repo` shorthand. Catalog names resolve to the reviewed 40-hex commit SHA and show declared capabilities. Source, checked-out revision, and a nested catalog-provenance block are recorded in the installer's `plugins/.install-metadata.json`; the `.hermes-catalog.json` copy inside the plugin directory is only for convenience and is never trusted. Raw URLs are flagged as custom (unreviewed) sources. `--ref` selects a full-SHA custom pin and records the SHA actually checked out. `--allow-removed` (DANGEROUS) bypasses the removed-plugin blocklist at install and exempts that install from update, enable, and load-time kill-list checks. |
| `search [term] [--json]` | Search the Hermes plugin catalog (matches entry names, descriptions, and declared tools; omit `term` to list everything). The catalog is curated in-repo (`plugin-catalog/`), refreshed from the live repo with a 6-hour cache, and falls back to the in-tree copy offline. Cataloged ≠ audited — admission reviews the entry, not the code. |
| `update <name>` | Re-pin catalog installs to the reviewed catalog SHA, or update a custom Git install from its recorded source/feed. PM validates active-plugin dependencies before code publication. Explicit custom pins move only with `install --force --ref <new-commit>`. |
+| `update [--yes]` | With no name: list every installed plugin that has an update `update <name>` can apply (catalog re-pin or Git pull) plus the ones it skips and why, then ask `Update all N? [Y/n]` and update each through the single-plugin path (per-plugin consent prompts still apply). One failure does not stop the rest; exits 1 if any failed. Without a terminal nothing is updated unless `--yes` is passed; `--yes` keeps consent fail-closed (new capabilities stay ungranted). |
| `remove <name>` (aliases: `rm`, `uninstall`) | Remove an installed plugin. |
| `enable <name>` | Enable a disabled plugin. |
| `disable <name>` | Disable a plugin without removing it. |
diff --git a/website/docs/user-guide/features/plugins.md b/website/docs/user-guide/features/plugins.md
index 2adc9abb550..a52c64ce22e 100644
--- a/website/docs/user-guide/features/plugins.md
+++ b/website/docs/user-guide/features/plugins.md
@@ -424,6 +424,8 @@ hermes plugins install user/repo # install from Git, then prompt Ena
hermes plugins install user/repo --enable # request enable; dependency consent still applies
hermes plugins install user/repo --no-enable # install but leave disabled (no prompt)
hermes plugins update my-plugin # pull latest (local edits are autostashed and re-applied)
+hermes plugins update # list every plugin with an update, then "Update all N? [Y/n]"
+hermes plugins update --yes # same, without the question (scripts, cron; required without a terminal)
hermes plugins remove my-plugin # uninstall; also drops it from plugins.enabled/disabled/entries
# and resets memory.provider when it was the live provider
hermes plugins enable my-plugin # add to allow-list
@@ -451,7 +453,20 @@ check runs when `plugins.auto_update_check_hours` is due: default 24 hours,
desktop sync-status view. This is not a hard once-per-day limit if you configure
a different interval.
-By default, updates require `hermes plugins update NAME`. Setting
+`hermes plugins update` with no name runs the same check and lists the
+plugins it can move: catalog installs (re-pinned to the reviewed catalog
+commit) and tracked Git installs (pulled). It names every plugin it skips and
+why: pinned, needs fixing, status unknown, or a pip distribution Hermes does
+not upgrade. In a terminal it asks once, then updates each plugin through the
+same path as `hermes plugins update NAME`, so new capabilities, a widened
+catalog pin and scan findings still prompt per plugin. One failure does not
+stop the rest; the summary lists what updated, what was already current and
+what failed with its reason (exit code 1 if any failed). Without a terminal
+it prints the list and updates nothing unless you pass `--yes`; with `--yes`,
+consent prompts fail closed as in any non-interactive update (new
+capabilities stay ungranted, a widened catalog pin is not applied).
+
+By default, plugins only update when you run `hermes plugins update`. Setting
`plugins.auto_apply: true` opts tracked Git plugins into unattended updates.
Both routes use the update security scan. Auto-apply does not manage pinned,
manual, drifted, or pip-distribution rows.