The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(cli): `hermes` / `hermes chat` / `-q` run main's HermesCLI again
Tekniumfb93022be7a2
diff --git a/cli.py b/cli.pyindex bdc31219e6e..375f42661d3 100644--- a/cli.py+++ b/cli.py@@ -1687,7 +1687,7 @@ def main(q: Shorthand for --queryoneshot: With -q: force the legacy answer-and-exit single-query modeeven on a TTY.- image: Not on the gateway path (refused; attach in `hermes --tui` or Desktop)+ image: Optional local image path to attach to a single querytoolsets: Comma-separated list of toolsets to enable (e.g., "web,terminal")skills: Comma-separated or repeated list of skills to preload for the sessionmodel: Model to use (default: anthropic/claude-opus-4-20250514)@@ -1696,30 +1696,25 @@ def main(api_key: API key for authenticationbase_url: Base URL for the APImax_turns: Maximum tool-calling iterations (default: 60)- verbose: Not on the gateway path (refused; `hermes logs --follow`)- compact: Not on the gateway path (refused; `display.compact: true`)- list_tools: List available tools and exit (no session, no gateway)- list_toolsets: List available toolsets and exit (no session, no gateway)- resume: Resume a previous session by id, title, or `latest`- worktree: Not on the gateway path (refused; `hermes --tui -w`). Alias: -w+ verbose: Enable verbose logging+ compact: Use compact display mode+ list_tools: List available tools and exit+ list_toolsets: List available toolsets and exit+ resume: Resume a previous session by its ID (e.g., 20260225_143052_a1b2c3)+ worktree: Run in an isolated git worktree (for parallel agents). Alias: -ww: Shorthand for --worktree-- Every chat launch hands off to the shared gateway (hermes_cli/gateway_chat.py), which- owns the session; the refused options are listed in- website/docs/developer-guide/gateway-classic-cli.md.-+Examples:python cli.py # Start interactive modepython cli.py --toolsets web,terminal # Use specific toolsets+ python cli.py --skills hermes-agent-dev,github-authpython cli.py -q "What is Python?" # Single query mode+ python cli.py -q "Describe this" --image ~/storage/shared/Pictures/cat.pngpython cli.py --list-tools # List tools and exit- python cli.py --resume latest # Resume the most recent CLI session- python cli.py --resume local-<id> # Resume a session by the id it printed+ python cli.py --resume 20260225_143052_a1b2c3 # Resume session+ python cli.py -w # Start in isolated git worktree+ python cli.py -w -q "Fix issue #123" # Single query in worktree"""- if not gateway:- from hermes_cli.gateway_chat import launch_from_kwargs- sys.exit(launch_from_kwargs(locals()))-# UTF-8 stdio on Windows before any print (Rich box-drawing would UnicodeEncodeError on cp1252).with suppress(Exception):from hermes_cli.stdio import configure_windows_stdiodiff --git a/hermes_cli/main.py b/hermes_cli/main.pyindex 84ecfb627af..9f782cb0dc2 100644--- a/hermes_cli/main.py+++ b/hermes_cli/main.py@@ -1707,16 +1707,18 @@ _CHAT_PASSTHROUGH = (def cmd_chat(args):"""Run interactive chat CLI."""from hermes_cli.stream_json import stream_json_requested- # Structured stdout is a non-interactive protocol: it overrides HERMES_TUI/display.interface too,- # so it is decided before the TUI gate and always rides the gateway transport.- if stream_json_requested(args) or _bypass_chat_launch(args) or not _resolve_use_tui(args):+ # Structured stdout (stream-json) and the --safe-mode / --ignore-user-config bypass keep the+ # gateway transport client; the classic CLI (interactive and -q/-Q) is main's HermesCLI, whose+ # agent is a gateway-backed proxy (hermes_cli/gateway_agent.py).+ if stream_json_requested(args) or _bypass_chat_launch(args):from hermes_cli.gateway_chat_startup import launch_gateway_chatsys.exit(launch_gateway_chat(args))- _refuse_unforwarded_tui_flags(args)_apply_safe_mode(args)_apply_user_config_bypass(args)_guard_noninteractive_user_config(args)use_tui = _resolve_use_tui(args)+ if use_tui:+ _refuse_unforwarded_tui_flags(args)_resolve_chat_session_args(args, use_tui)@@ -3239,9 +3241,15 @@ def _try_termux_fast_cli_launch() -> bool:_promote_top_level_resume(args)if args.command in {None, "chat"}:_set_chat_arg_defaults(args)- # The gateway owns agent startup; legacy banner hints must not become- # execution options or leak into a newly ensured owner.- if getattr(args, "query", None) or getattr(args, "image", None):+ interactive_prompt = not getattr(args, "query", None) and not getattr(args, "image", None)+ if interactive_prompt:+ # Reach the prompt first; agent-only discovery on the first turn.+ args.compact = True+ os.environ["HERMES_DEFER_AGENT_STARTUP"] = "1"+ os.environ["HERMES_FAST_STARTUP_BANNER"] = "1"+ if getattr(args, "accept_hooks", False):+ os.environ["HERMES_ACCEPT_HOOKS"] = "1"+ else:_prepare_agent_startup(args)cmd_chat(args)return Truediff --git a/tests/hermes_cli/test_classic_cli_routing.py b/tests/hermes_cli/test_classic_cli_routing.pynew file mode 100644index 00000000000..040b2f23afe--- /dev/null+++ b/tests/hermes_cli/test_classic_cli_routing.py@@ -0,0 +1,61 @@+"""The classic CLI is main's HermesCLI again: `hermes` / `hermes chat` (interactive and -q) reach+``cli.main``; only stream-json and the safe-mode bypass keep the gateway transport client."""+import argparse+import sys+import types++import pytest+++def _args(**kw):+ base = dict(command="chat", query=None, model=None, provider=None, toolsets=None, skills=None,+ verbose=None, quiet=False, image=None, resume=None, worktree=False, checkpoints=False,+ pass_session_id=False, max_turns=None, output_format="text", tui=False, cli=True,+ safe_mode=False, ignore_user_config=False, continue_last=None, yolo=False,+ ignore_rules=False, source=None, query_file=None, oneshot_exit=False, compact=False,+ run_budget=None, reasoning=None, accept_hooks=False)+ base.update(kw)+ return argparse.Namespace(**base)+++def routed(monkeypatch):+ import hermes_cli.main as m+ calls = {}+ fake_cli = types.ModuleType("cli")+ fake_cli.main = lambda **kw: calls.setdefault("cli_main", kw)+ monkeypatch.setitem(sys.modules, "cli", fake_cli)+ import hermes_cli.gateway_chat_startup as startup+ monkeypatch.setattr(startup, "launch_gateway_chat", lambda args: calls.setdefault("gateway", args) and 0)+ for name in ("_resolve_chat_session_args", "_warn_retired_xai_models", "_start_chat_background_prefetch",+ "_pin_kanban_board_env", "_confirm_startup_expensive_model_override",+ "_guard_noninteractive_user_config"):+ monkeypatch.setattr(m, name, lambda *a, **k: None)+ monkeypatch.setattr(m, "_resolve_use_tui", lambda args: False)+ monkeypatch.setattr(m, "_has_any_provider_configured", lambda: True)+ import hermes_cli.free_tier_bootstrap as boot+ monkeypatch.setattr(boot, "run_bootstrap", lambda **k: None)+ import hermes_cli.observability.shared_metrics_consent as consent+ monkeypatch.setattr(consent, "offer_consent_before_chat", lambda args: None)+ import hermes_cli.observability.shared_metrics_process as proc+ monkeypatch.setattr(proc, "begin_process", lambda name: None)+ return m, calls+++def test_interactive_chat_runs_main_hermes_cli(routed):+ m, calls = routed+ m.cmd_chat(_args())+ assert "cli_main" in calls and "gateway" not in calls+++def test_query_runs_main_hermes_cli(routed):+ m, calls = routed+ m.cmd_chat(_args(query="hello"))+ assert calls["cli_main"]["query"] == "hello" and "gateway" not in calls+++def test_cli_main_does_not_hand_off_to_thin_client():+ import inspect++ import cli+ assert "launch_from_kwargs" not in inspect.getsource(cli.main)