The folds Teknium approved are on main (/verbose focus, /statusbar battery|indicator, /status's egress block, /model --runtime, /pet hatch, /goal add, /help <page>, /billing topup|upgrade, TUI /verbose details|density), but the old names still ran. They are now retired with RETIRED_COMMANDS: typing /focus, /battery, /indicator, /egress, /codex-runtime, /hatch, /generate-pet, /subgoal, /commands, /topup, /subscription or /upgrade (either _ or - spelling) runs nothing on the CLI, gateway, TUI and Desktop and answers "`/old` is now `/new`.". The TUI answers its own /details, /detail and /density the same way (slash.retired), since they never existed elsewhere. The old names leave help, menus, completion, the Telegram menu priority, the Slack /hermes-only set, the Desktop registry and description keys, and the docs tables (the Renamed commands table lists each). Handlers only the old names reached are removed; the umbrella commands still call the shared handlers. Slash access: the folded forms check their own user_allowed_commands keys (goal-add, model-runtime, status-egress, help-pages) instead of the retired names, and an operator list that still names subgoal, codex-runtime, egress, commands or topup grants what replaced it, so no existing config loses or gains access.
104 lines
3.2 KiB
Python
104 lines
3.2 KiB
Python
"""Tests for CLI /status command behavior."""
|
|
from datetime import datetime
|
|
from pathlib import Path
|
|
from types import SimpleNamespace
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from cli import HermesCLI
|
|
from agent.i18n import t
|
|
|
|
|
|
def _make_cli():
|
|
cli_obj = HermesCLI.__new__(HermesCLI)
|
|
cli_obj.config = {}
|
|
cli_obj.console = MagicMock()
|
|
cli_obj.agent = None
|
|
cli_obj.conversation_history = []
|
|
cli_obj.session_id = "session-123"
|
|
cli_obj._pending_input = MagicMock()
|
|
cli_obj._status_bar_visible = True
|
|
cli_obj.model = "openai/gpt-5.4"
|
|
cli_obj.provider = "openai"
|
|
cli_obj.session_start = datetime(2026, 4, 9, 19, 24)
|
|
cli_obj._agent_running = False
|
|
cli_obj._session_db = MagicMock()
|
|
cli_obj._session_db.get_session.return_value = None
|
|
return cli_obj
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_process_command_status_prints_proxy_status_when_egress_is_enabled(monkeypatch):
|
|
cli_obj = _make_cli()
|
|
monkeypatch.setattr("hermes_cli.proxy_cli.load_config", lambda: {"proxy": {"enabled": True}})
|
|
monkeypatch.setattr(
|
|
"hermes_cli.proxy_cli.format_status_text",
|
|
lambda: "Egress proxy status\nEnabled: no",
|
|
)
|
|
|
|
assert cli_obj.process_command("/status") is True
|
|
|
|
cli_obj.console.print.assert_called()
|
|
printed = "\n".join(str(call.args[0]) for call in cli_obj.console.print.call_args_list)
|
|
assert "Egress proxy status" in printed
|
|
|
|
|
|
|
|
|
|
def test_status_prefix_prefers_status_command_over_statusbar_toggle():
|
|
cli_obj = _make_cli()
|
|
|
|
with patch.object(cli_obj, "_show_session_status") as mock_status:
|
|
assert cli_obj.process_command("/sta") is True
|
|
|
|
mock_status.assert_called_once_with()
|
|
assert cli_obj._status_bar_visible is True
|
|
|
|
|
|
def test_show_session_status_prints_gateway_style_summary():
|
|
cli_obj = _make_cli()
|
|
cli_obj.agent = SimpleNamespace(
|
|
session_total_tokens=321,
|
|
session_api_calls=4,
|
|
)
|
|
cli_obj._session_db.get_session.return_value = {
|
|
"title": "My titled session",
|
|
"started_at": 1775791440,
|
|
}
|
|
|
|
with patch("hermes_constants.display_hermes_home", return_value="~/.hermes"):
|
|
cli_obj._show_session_status()
|
|
|
|
printed = "\n".join(str(call.args[0]) for call in cli_obj.console.print.call_args_list)
|
|
assert t("cli.session.status_title") in printed
|
|
assert "Session ID: session-123" in printed
|
|
assert "Path: ~/.hermes" in printed
|
|
assert "Title: My titled session" in printed
|
|
assert "Model: openai/gpt-5.4 (openai)" in printed
|
|
assert "Tokens: 321" in printed
|
|
assert "Agent Running: No" in printed
|
|
_, kwargs = cli_obj.console.print.call_args
|
|
assert kwargs.get("highlight") is False
|
|
assert kwargs.get("markup") is False
|
|
|
|
|
|
|
|
|
|
def test_profile_command_reports_custom_root_profile(monkeypatch, tmp_path, capsys):
|
|
"""Profile detection works for custom-root deployments (not under ~/.hermes)."""
|
|
cli_obj = _make_cli()
|
|
profile_home = tmp_path / "profiles" / "coder"
|
|
|
|
monkeypatch.setenv("HERMES_HOME", str(profile_home))
|
|
monkeypatch.setattr(Path, "home", lambda: tmp_path / "unrelated-home")
|
|
|
|
cli_obj._handle_profile_command()
|
|
|
|
out = capsys.readouterr().out
|
|
assert "Profile: coder" in out
|
|
assert f"Home: {profile_home}" in out
|