The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): review findings on the glyph layout
Tekniumc5a4a20bcda5
diff --git a/agent/display.py b/agent/display.pyindex c116f282198..f8161010098 100644--- a/agent/display.py+++ b/agent/display.py@@ -1101,23 +1101,30 @@ def _cute_row(emoji: str, verb: str, detail: str = "") -> str:return _CuteRow(f"┊ {emoji} {label:9} {detail}", label, detail)-def get_tool_row_parts(tool_name: str, args: dict | None, result: str | None = None):- """``([(verb, detail), ...], is_failure, failure_suffix)`` for one completed call: the same- labels the ``┊`` completion line uses, without its emoji and column padding."""+def get_tool_row_parts(tool_name: str, args: dict | None, result: str | None = None, *, is_error: bool = False):+ """``[(verb, detail, failure), ...]`` for one completed call: the labels the ``┊`` line uses,+ without its emoji and padding. ``failure`` is None for a row that succeeded, else that row's+ suffix (``" [exit 1]"``, possibly ``""``); batch calls mark the entry that failed."""try:args = redact_tool_args_for_display(tool_name, args) or args or {}is_failure, suffix = _detect_tool_failure(tool_name, result)+ call_failure = suffix if is_failure else ("" if is_error else None)labels = bridge_tool_labels(tool_name, args)if labels:- return [(_cute_trunc(lb.text), _cute_trunc(lb.preview) if lb.preview else "") for lb in labels], is_failure, suffix+ suffixes = _bridge_row_suffixes(len(labels), result, suffix if is_failure else "")+ marks = [s or None for s in suffixes]+ if call_failure is not None and not any(suffixes):+ marks[-1] = call_failure # the call failed without naming an entry+ return [(_cute_trunc(lb.text), _cute_trunc(lb.preview) if lb.preview else "", mark)+ for lb, mark in zip(labels, marks)]render = _CUTE_LINES.get(tool_name)row = render(args, result) if render else Noneif isinstance(row, _CuteRow):- return [(row.verb, row.detail)], is_failure, suffix- return [(tool_name, _cute_trunc(build_tool_preview(tool_name, args) or ""))], is_failure, suffix+ return [(row.verb, row.detail, call_failure)]+ return [(tool_name, _cute_trunc(build_tool_preview(tool_name, args) or ""), call_failure)]except Exception:logger.debug("Tool row parts failed for %s", tool_name, exc_info=True)- return [(str(tool_name), "")], False, ""+ return [(str(tool_name), "", None)]def _cute_web_extract(a: dict, _r) -> str:diff --git a/hermes_cli/cli_chat_turn_mixin.py b/hermes_cli/cli_chat_turn_mixin.pyindex 7ca1f7bed98..1e7148455fe 100644--- a/hermes_cli/cli_chat_turn_mixin.py+++ b/hermes_cli/cli_chat_turn_mixin.py@@ -692,7 +692,7 @@ class CLIChatTurnMixin:from hermes_cli.cli_modern_layout import answer_label_cprint(answer_label())ChatConsole().print(_render_final_assistant_content(response, mode=self.final_response_markdown),- style=_resp_text, width=self._scrollback_box_width())+ style=_resp_text, soft_wrap=True) # terminal wraps; resize re-flowselse:ChatConsole().print(Panel(_render_final_assistant_content(response, mode=self.final_response_markdown),diff --git a/hermes_cli/cli_init_mixin.py b/hermes_cli/cli_init_mixin.pyindex d4b070ab0a8..f130a79512e 100644--- a/hermes_cli/cli_init_mixin.py+++ b/hermes_cli/cli_init_mixin.py@@ -121,12 +121,11 @@ class CLIInitMixin:enabled=display.get("persistent_output", True),max_lines=display.get("persistent_output_max_lines", 200),)- from hermes_cli.cli_modern_layout import layout_from_config, set_active+ from hermes_cli.cli_modern_layout import busy_input_mode_from_config, layout_from_config, set_activeself._modern_layout = layout_from_config(display) # display.cli_layout: modern | classicset_active(self._modern_layout)# busy_input_mode: "interrupt" (redirect the run) | "queue" (next turn) | "steer" (inject mid-run).- # Unset: the glyph layout steers (Tab queues), the classic layout interrupts.- _bim = str(display.get("busy_input_mode") or ("steer" if self._modern_layout else "interrupt")).strip().lower()+ _bim = busy_input_mode_from_config(display)self.busy_input_mode = _bim if _bim in ("queue", "steer") else "interrupt"# verbose ONLY controls global DEBUG logging; tool_progress="verbose" is independentdiff --git a/hermes_cli/cli_modern_layout.py b/hermes_cli/cli_modern_layout.pyindex de74ee6e2e8..5b3a803adda 100644--- a/hermes_cli/cli_modern_layout.py+++ b/hermes_cli/cli_modern_layout.py@@ -34,6 +34,12 @@ def layout_from_config(display: dict) -> bool:return str((display or {}).get("cli_layout", "modern") or "modern").strip().lower() != "classic"+def busy_input_mode_from_config(display: dict) -> str:+ """``display.busy_input_mode`` when set; unset steers in this layout and interrupts in classic."""+ mode = (display or {}).get("busy_input_mode") or ("steer" if layout_from_config(display) else "interrupt")+ return str(mode).strip().lower()++def _skin_hex(key: str, fallback: str) -> str:from hermes_cli.skin_engine import get_active_skinreturn get_active_skin().get_color(key, fallback) or fallback@@ -109,19 +115,17 @@ def completed_tool_line(cli, function_name: str, args: dict | None, duration: fldef tool_row(function_name: str, args: dict | None, duration: float, result=None, is_error: bool = False) -> str:"""``● Read calc.py 0.2s`` / ``✗ Ran $ pytest -q 0.4s [exit 1]`` — one row per completed call."""from agent.display import get_tool_row_parts- rows, failed, suffix = get_tool_row_parts(function_name, args or {}, result)- failed = failed or bool(is_error)- glyph = f"{_RED}✗{_RST}" if failed else "●"+ rows = get_tool_row_parts(function_name, args or {}, result, is_error=bool(is_error))out = []- for index, (verb, detail) in enumerate(rows):+ for index, (verb, detail, suffix) in enumerate(rows):verb = (verb or function_name).strip()- line = f"{glyph} {_BOLD}{verb[:1].upper()}{verb[1:]}{_RST}"+ line = f"{f'{_RED}✗{_RST}' if suffix is not None else '●'} {_BOLD}{verb[:1].upper()}{verb[1:]}{_RST}"if detail:line += f" {detail}"if index == len(rows) - 1 and duration >= 0.1:line += f" {_DIM}{duration:.1f}s{_RST}"- if failed and suffix:- line += f"{_RED}{suffix}{_RST}"+ if suffix:+ line += f"{_RED}{suffix}{_RST}"out.append(line)return "\n".join(out)@@ -320,7 +324,7 @@ def _render_safely(render, cli) -> list:# Live-state badges the classic bar shows, minus its throughput/clock fields: what changes per turn._DEFAULT_FIELDS = frozenset({"model", "context_pct", "compressions", "bg_tasks", "bg_processes", "bg_subagents",- "goal", "focus", "yolo", "stash"})+ "goal", "focus", "yolo", "stash", "battery"})def _status_line_fragments(cli) -> list:@@ -337,6 +341,13 @@ def _status_line_fragments(cli) -> list:stash = cli._prompt_stash.indicator() if "stash" in fields and hasattr(cli, "_prompt_stash") else ""if stash: # a parked draft is never silently forgottenleft += [(dim, " · "), (strong, stash)]+ battery = snapshot.get("battery_label") or "" # only set while /battery is on+ if battery and "battery" in fields:+ left[0:0] = [("", " "), (cli._battery_status_style(snapshot.get("battery_category", "dim")), battery),+ (dim, " ·")]+ vim = cli._vim_mode_label()+ if vim:+ left += [(dim, " · "), (strong, vim)]right: list = []for key, text in hint_pairs(cli) if width >= 76 else []:if right:@@ -377,10 +388,13 @@ def modern_input_rules(cli, kb):@kb.add("tab", filter=Condition(_can_queue), eager=True)def _queue_while_busy(event):- cli._busy_mode_override = "queue"- try:- cli._tui_handle_enter(event)- finally:- cli._busy_mode_override = None+ # Not _tui_handle_enter: its paste/continuation rules would turn this key into a newline.+ buf = event.app.current_buffer+ text, images = buf.text.strip(), list(cli._attached_images)+ cli._attached_images.clear()+ cli._tui_enter_while_busy(text, images, (text, images) if images else text, mode="queue")+ cli._inline_pastes(buf)+ buf.reset(append_to_history=True)+ event.app.invalidate()return top, bottomdiff --git a/hermes_cli/cli_panel.py b/hermes_cli/cli_panel.pynew file mode 100644index 00000000000..1d177945a5d--- /dev/null+++ b/hermes_cli/cli_panel.py@@ -0,0 +1,28 @@+"""Bordered overlay panels (approval, clarify, sudo, pickers) for the classic CLI's live region."""++from hermes_cli.cli_render import _append_blank_panel_line, _append_panel_line+++class _Panel:+ """Fragment accumulator for one bordered overlay panel (``(style, text)`` tuples)."""++ def __init__(self, border: str, box_width: int, title: str = "", title_style: str = ""):+ self.lines, self.border, self.width = [], border, box_width+ self._row, self._blank = _append_panel_line, _append_blank_panel_line+ if title:+ # Title inlined into the top rule: ``╭─ Title ───╮``.+ self.lines.append((border, "╭─ "))+ self.lines.append((title_style, title))+ self.lines.append((border, " " + ("─" * max(0, box_width - len(title) - 3)) + "╮\n"))+ else:+ self.lines.append((border, "╭" + ("─" * box_width) + "╮\n"))++ def row(self, style: str, text: str) -> None:+ self._row(self.lines, self.border, style, text, self.width)++ def blank(self) -> None:+ self._blank(self.lines, self.border, self.width)++ def close(self) -> list:+ self.lines.append((self.border, "╰" + ("─" * self.width) + "╯\n"))+ return self.linesdiff --git a/hermes_cli/cli_render.py b/hermes_cli/cli_render.pyindex 8f03e9830e7..f52ab7c2949 100644--- a/hermes_cli/cli_render.py+++ b/hermes_cli/cli_render.py@@ -975,28 +975,3 @@ def _append_panel_line(lines, border_style: str, content_style: str, text: str,def _append_blank_panel_line(lines, border_style: str, box_width: int) -> None:lines.append((border_style, "│" + (" " * box_width) + "│\n"))---class _Panel:- """Fragment accumulator for one bordered overlay panel (``(style, text)`` tuples)."""-- def __init__(self, border: str, box_width: int, title: str = "", title_style: str = ""):- self.lines, self.border, self.width = [], border, box_width- self._row, self._blank = _append_panel_line, _append_blank_panel_line- if title:- # Title inlined into the top rule: ``╭─ Title ───╮``.- self.lines.append((border, "╭─ "))- self.lines.append((title_style, title))- self.lines.append((border, " " + ("─" * max(0, box_width - len(title) - 3)) + "╮\n"))- else:- self.lines.append((border, "╭" + ("─" * box_width) + "╮\n"))-- def row(self, style: str, text: str) -> None:- self._row(self.lines, self.border, style, text, self.width)-- def blank(self) -> None:- self._blank(self.lines, self.border, self.width)-- def close(self) -> list:- self.lines.append((self.border, "╰" + ("─" * self.width) + "╯\n"))- return self.linesdiff --git a/hermes_cli/cli_tui_mixin.py b/hermes_cli/cli_tui_mixin.pyindex 245788da1fd..33bf90805a4 100644--- a/hermes_cli/cli_tui_mixin.py+++ b/hermes_cli/cli_tui_mixin.py@@ -39,7 +39,7 @@ from prompt_toolkit.widgets import TextAreafrom typing import Optionalfrom hermes_cli.cli_footer_split import FooterSplit-from hermes_cli.cli_render import _Panel+from hermes_cli.cli_panel import _Panel# Rows below an overlay panel taken by spinner/tool-progress, status bar, input, separators and# prompt symbol (measured ~6 during live PTY approval prompts) — shared by every panel budget.@@ -1480,7 +1480,7 @@ class CLITuiMixin:event.app.invalidate()return True- def _tui_enter_while_busy(self, text: str, images: list, payload) -> None:+ def _tui_enter_while_busy(self, text: str, images: list, payload, mode: str | None = None) -> None:"""Route a submission typed while the agent runs, per ``busy_input_mode``.steer → agent.steer(text) mid-run (images can't ride along and a missing/rejecting@@ -1489,7 +1489,7 @@ class CLITuiMixin:multimodal follow-ups, or a turn that finished in the race). queue → next turn."""from cli import CLI_CONFIG, _ACCENT, _DIM, _RST, _cprint, _hermes_home- _effective_mode = getattr(self, "_busy_mode_override", None) or self.busy_input_mode+ _effective_mode = mode or self.busy_input_moderedirected = Falseif _effective_mode == "steer":if images or not text:diff --git a/tests/hermes_cli/test_cli_modern_layout.py b/tests/hermes_cli/test_cli_modern_layout.pyindex 4d77e1c953f..bf9ff26f812 100644--- a/tests/hermes_cli/test_cli_modern_layout.py+++ b/tests/hermes_cli/test_cli_modern_layout.py@@ -65,3 +65,24 @@ def test_panel_rows_never_carry_a_newline():rows = _wrap_panel_text_keep_ws("python3 - <<'PY'\nprint(sum(range(10)))\nPY", 30)assert rows == ["python3 - <<'PY'", "print(sum(range(10)))", "PY"]++[email protected]("display, modern, busy", [+ ({}, True, "steer"),+ ({"cli_layout": "classic"}, False, "interrupt"),+ ({"busy_input_mode": "queue"}, True, "queue"),+ ({"cli_layout": "classic", "busy_input_mode": "steer"}, False, "steer"),+])+def test_layout_and_busy_default_through_the_config_loader(tmp_path, monkeypatch, display, modern, busy):+ import hermes_yaml as yaml+ import cli+ from hermes_cli.cli_modern_layout import busy_input_mode_from_config, layout_from_config++ home = tmp_path / ".hermes"+ home.mkdir()+ monkeypatch.setenv("HERMES_HOME", str(home))+ monkeypatch.setattr(cli, "_hermes_home", home)+ (home / "config.yaml").write_text(yaml.safe_dump({"display": display} if display else {"model": {}}))+ loaded = cli.load_cli_config()["display"]+ assert layout_from_config(loaded) is modern+ assert busy_input_mode_from_config(loaded) == busy