Files
hermes-agent/tests/hermes_cli/test_banner_skills_width.py
Teknium f6938b37f3 simplify(compat): terminal/file/environments — drop 42 re-exports/aliases, repoint 20 callers + 41 test files
tools/terminal_tool.py: drop 30 pure re-export names (lifecycle/config/backends/
sudo/guards/result/interrupt/utils/_DockerEnvironment/is_managed_tool_gateway_ready)
and the noqa-F401 comments on the 25 names the facade itself uses. Sibling modules
(terminal_tool_backends/_result/_sudo/_lifecycle, environments/base, process_registry)
that read removed names through the facade now import from the defining module.
tools/environments/base.py: drop 11 re-exports (base_output/base_session_env/
path_utils) and the BaseEnvironment.stop() compat alias (no in-tree caller; the
lifecycle hasattr(env, 'stop') fallback stays for third-party envs).
tools/environments/docker.py: drop 1 re-export + the re-export comment.
Callers/tests repointed to tools.terminal_tool_{lifecycle,backends,sudo,config,
guards,result}, tools.interrupt, tools.environments.{base_output,base_session_env,
path_utils}.
2026-09-03 13:29:55 -07:00

68 lines
2.4 KiB
Python

"""Tests for banner skills display — terminal-width-aware truncation."""
import os
from unittest.mock import patch
from rich.console import Console
import hermes_cli.banner as banner
import model_tools
import tools.mcp_tool_discovery
def _build_banner_with_skills(skills_by_category, term_width=160):
"""Helper: build banner with given skills and return captured output."""
with (
patch.object(
model_tools,
"check_tool_availability",
return_value=([], []),
),
patch.object(banner, "get_available_skills", return_value=skills_by_category),
patch.object(banner, "get_update_result", return_value=None),
patch.object(tools.mcp_tool_discovery, "get_mcp_status", return_value=[]),
patch("shutil.get_terminal_size", return_value=os.terminal_size((term_width, 50))),
):
console = Console(
record=True, force_terminal=False, color_system=None, width=term_width
)
banner.build_welcome_banner(
console=console,
model="anthropic/test-model",
cwd="/tmp/project",
tools=[],
)
return console.export_text()
def test_wide_terminal_shows_more_than_8_skills():
"""A wide terminal should display more than 8 skills per category."""
# 15 skills in one category
skills = {"research": [f"skill-{i:02d}" for i in range(15)]}
text = _build_banner_with_skills(skills, term_width=200)
# With a 200-char terminal, more than 8 should be visible.
# The old code always truncated at 8; we should see at least 9 now.
assert "skill-08" in text, f"Expected skill-08 in output for wide terminal: {text}"
def test_small_category_shows_all_skills():
"""Categories with few skills should show all of them regardless of width."""
skills = {"security": ["auth", "vault"]}
text = _build_banner_with_skills(skills, term_width=80)
assert "auth" in text
assert "vault" in text
# No "+N more" indicator for small categories
assert "+2 more" not in text
def test_skills_respect_category_label_width():
"""Skills display should account for the category label prefix width."""
# A category with a long name should have less room for skills
skills = {"very-long-category-name": [f"skill-{i:02d}" for i in range(10)]}
text = _build_banner_with_skills(skills, term_width=120)
# Should still show at least some skills
assert "skill-00" in text