The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(hermes_cli): dedupe decision-message printing, width-probe loop, plugin dedupe via dict
Teknium48ef059a6c57
diff --git a/hermes_cli/cli_agent_setup_mixin.py b/hermes_cli/cli_agent_setup_mixin.pyindex afda620ee50..d36056e15f6 100644--- a/hermes_cli/cli_agent_setup_mixin.py+++ b/hermes_cli/cli_agent_setup_mixin.py@@ -417,12 +417,13 @@ class CLIAgentSetupMixin:else:ChatConsole().print(rich)if not session_meta:+ hint = "Use a session ID from a previous CLI run (hermes sessions list)."if _quiet_mode:print(f"Session not found: {self.session_id}", file=sys.stderr)- print("Use a session ID from a previous CLI run (hermes sessions list).", file=sys.stderr)+ print(hint, file=sys.stderr)else:_cprint(f"\033[1;31mSession not found: {self.session_id}{_RST}")- _cprint(f"{_DIM}Use a session ID from a previous CLI run (hermes sessions list).{_RST}")+ _cprint(f"{_DIM}{hint}{_RST}")return Falsesession_meta = self._follow_compression_chain(session_meta,diff --git a/hermes_cli/cli_loops_mixin.py b/hermes_cli/cli_loops_mixin.pyindex 10aec28cc5d..2952479ebfe 100644--- a/hermes_cli/cli_loops_mixin.py+++ b/hermes_cli/cli_loops_mixin.py@@ -21,6 +21,15 @@ def _preview(payload: str) -> str:return f"{payload[:80]}{'...' if len(payload) > 80 else ''}"+def _print_decision_message(decision: dict) -> bool:+ """Print a manager decision's ``message`` (if any) via _cprint; True when one was printed."""+ from cli import _cprint+ msg = decision.get("message") or ""+ if msg:+ _cprint(f" {msg}")+ return bool(msg)++class CLILoopsMixin:"""Simple slash-command wrappers plus goal/heartbeat/loop manager hooks for the interactive CLI"""@@ -246,10 +255,10 @@ class CLILoopsMixin:print(f"User plugins ({len(user_entries)}):")for name, version, _desc, source, _dir, key in sorted(user_entries):state = _plugin_status(name, enabled, disabled, key=key)- glyph = {"enabled": "✓", "disabled": "✗"}.get(state, "○")- ver = f" v{version}" if version else ""info = loaded.get(name) or {}bits = [f"{info[k]} {k}" for k in ("tools", "hooks", "commands") if info.get(k)]+ glyph = {"enabled": "✓", "disabled": "✗"}.get(state, "○")+ ver = f" v{version}" if version else ""detail = f" ({', '.join(bits)})" if bits else ""label = "" if state == "enabled" else f" [{state}]"error = f" — {info['error']}" if info.get("error") else ""@@ -432,10 +441,7 @@ class CLILoopsMixin:# judge; complete them immediately (caps and scheduling still apply).if wakeup.lstrip().startswith("/"):try:- decision = mgr.complete_tick("")- msg = decision.get("message") or ""- if msg:- _cprint(f" {msg}")+ _print_decision_message(mgr.complete_tick(""))except Exception:pass@@ -483,10 +489,8 @@ class CLILoopsMixin:f"Use /loop resume to continue, or /loop stop to end it.{_RST}")returndecision = mgr.complete_tick(self._last_assistant_response_text())- msg = decision.get("message") or ""- if msg:- _cprint(f" {msg}")- elif decision.get("status") == "active" and mgr.state is not None:+ if (not _print_decision_message(decision) and decision.get("status") == "active"+ and mgr.state is not None):_cprint(f" {_DIM}↻ Loop: {mgr.state.remaining_label()}.{_RST}")def _maybe_continue_goal_after_turn(self) -> None:@@ -508,15 +512,10 @@ class CLILoopsMixin:try:pending = getattr(self, "_pending_input", None)if pending is not None and not pending.empty():- has_real_message = Falsetry:- for entry in list(pending.queue):- if isinstance(entry, tuple) and entry:- entry = entry[0]- if isinstance(entry, str) and _looks_like_slash_command(entry):- continue- has_real_message = True- break+ entries = [e[0] if isinstance(e, tuple) and e else e for e in list(pending.queue)]+ has_real_message = any(+ not (isinstance(e, str) and _looks_like_slash_command(e)) for e in entries)except Exception:has_real_message = True # can't introspect — defer to be safeif has_real_message:@@ -545,9 +544,7 @@ class CLILoopsMixin:_bg_procs = Nonedecision = mgr.evaluate_after_turn(last_response, user_initiated=True, background_processes=_bg_procs)- msg = decision.get("message") or ""- if msg:- _cprint(f" {msg}")+ _print_decision_message(decision)if decision.get("should_continue"):prompt = decision.get("continuation_prompt")if prompt:diff --git a/hermes_cli/cli_terminal_mixin.py b/hermes_cli/cli_terminal_mixin.pyindex 5209de1d0a4..76bb8738314 100644--- a/hermes_cli/cli_terminal_mixin.py+++ b/hermes_cli/cli_terminal_mixin.py@@ -310,21 +310,18 @@ class CLITerminalMixin:reports a hardcoded 80 columns, which would make the first real signal look like awidth change. ``app.output`` is what the running resize handler measures."""- try:- width = app.output.get_size().columns- except Exception:- width = None- if not width or width <= 0:+ width = None+ for probe in (lambda: app.output.get_size().columns,+ lambda: shutil.get_terminal_size((80, 24)).columns):try:- width = shutil.get_terminal_size((80, 24)).columns+ width = probe()except Exception:width = None+ if width and width > 0:+ breakself._last_resize_width = widthoriginal_on_resize = app._on_resize-- def _resize_clear_ghosts():- self._schedule_resize_recovery(app, original_on_resize)- app._on_resize = _resize_clear_ghosts+ app._on_resize = lambda: self._schedule_resize_recovery(app, original_on_resize)def _try_attach_clipboard_image(self) -> bool:"""Save a clipboard image to ~/.hermes/images/ and attach it; True if attached."""diff --git a/hermes_cli/codex_runtime_plugin_migration.py b/hermes_cli/codex_runtime_plugin_migration.pyindex dbef3dcea1c..ab49d9d5291 100644--- a/hermes_cli/codex_runtime_plugin_migration.py+++ b/hermes_cli/codex_runtime_plugin_migration.py@@ -298,8 +298,7 @@ def _query_codex_plugins(marketplaces = resp.get("marketplaces") or []if not isinstance(marketplaces, list):return [], "plugin/list response missing 'marketplaces'"- out: list[dict] = []- seen: set[tuple[str, str]] = set()+ out: dict[tuple[str, str], dict] = {} # (name, marketplace) -> entry; first winsfor marketplace in marketplaces:if not isinstance(marketplace, dict):continue@@ -314,12 +313,11 @@ def _query_codex_plugins(availability)continuename = str(plugin.get("name") or "")- if not name or (name, market_name) in seen:- continue- seen.add((name, market_name))- out.append({"name": name, "marketplace": market_name,- "enabled": bool(plugin.get("enabled", True))})- return out, None+ if name:+ out.setdefault((name, market_name), {+ "name": name, "marketplace": market_name,+ "enabled": bool(plugin.get("enabled", True))})+ return list(out.values()), None# pytest tempdir shapes: ``pytest-of-<user>/pytest-<n>/``, macOS ``/private/var/folders/…/T``.