Skip to content

The agent that grows with you

fix(skills): print CLI errors unwrapped so the Desktop toast keeps the subject

Teknium23a68610a5b2
diff --git a/hermes_cli/skills_hub.py b/hermes_cli/skills_hub.py
index fdabce982ef..bfa5cae8abe 100644
--- a/hermes_cli/skills_hub.py
+++ b/hermes_cli/skills_hub.py
@@ -132,7 +132,9 @@ def _finish_change(c: Console, invalidate_cache: bool, what: str = "Change will
def _print_error(c: Console, message: str) -> None:
- c.print(f"[bold red]Error:[/] {message}\n")
+ # One unwrapped line: the Desktop Hub toasts a failed action's last 3 log lines, and an 80-column
+ # wrap left only the tail of the message there (the subject was cut off).
+ c.print(f"[bold red]Error:[/] {message}\n", soft_wrap=True)
def _print_listed(c: Console, label: str, items) -> None:
diff --git a/tests/hermes_cli/test_skills_failure_exit_code.py b/tests/hermes_cli/test_skills_failure_exit_code.py
index a9b724ca13d..fcc7c4b2025 100644
--- a/tests/hermes_cli/test_skills_failure_exit_code.py
+++ b/tests/hermes_cli/test_skills_failure_exit_code.py
@@ -8,19 +8,11 @@ the action log. The scan gate is the common case: a blocked install used to prin
"""
import sys
-from io import StringIO
-
import pytest
-from rich.console import Console
import hermes_cli.skills_hub as cli_hub
-def _console():
- sink = StringIO()
- return Console(file=sink, force_terminal=False, color_system=None, width=200), sink
-
-
def _scan_gate_env(monkeypatch, tmp_path, *, verdict="dangerous", installed=None):
"""Wire ``do_install`` down to the real scan-policy decision for a community skill."""
import tools.skills_guard as guard
@@ -63,17 +55,6 @@ def _scan_gate_env(monkeypatch, tmp_path, *, verdict="dangerous", installed=None
return installs, audit
[email protected]("verdict", ["dangerous", "caution"])
-def test_scan_blocked_install_reports_failure(monkeypatch, tmp_path, verdict):
- installs, audit = _scan_gate_env(monkeypatch, tmp_path, verdict=verdict)
- console, sink = _console()
-
- assert cli_hub.do_install("org/repo/risky-skill", console=console, skip_confirm=True) is False
- assert installs == []
- assert "Not installed:" in sink.getvalue()
- assert audit and audit[0][0] == "BLOCKED"
-
-
# --- the process exit code, through the real `hermes` entry point ---
@@ -87,15 +68,30 @@ def test_scan_blocked_install_reports_failure(monkeypatch, tmp_path, verdict):
(["skills", "uninstall", "x", "--yes"], "do_uninstall", True, 0),
(["skills", "snapshot", "import", "snap.json"], "do_snapshot_import", False, 1),
(["skills", "snapshot", "import", "snap.json"], "do_snapshot_import", None, 0),
+ # The real scan gate, not a stubbed outcome: a refused community skill installs nothing and exits 1.
+ (["skills", "install", "org/repo/risky-skill", "--yes"], "scan_gate", "dangerous", 1),
+ (["skills", "install", "org/repo/risky-skill", "--yes"], "scan_gate", "caution", 1),
])
-def test_cli_exit_code_follows_the_action_outcome(monkeypatch, argv, target, outcome, code):
+def test_cli_exit_code_follows_the_action_outcome(monkeypatch, tmp_path, capsys, argv, target, outcome, code):
from hermes_cli.main import main
- monkeypatch.setattr(cli_hub, target, lambda *a, **k: outcome)
- monkeypatch.setattr(sys, "argv", ["hermes", *argv])
- try:
- main()
- exit_code = 0
- except SystemExit as exc:
- exit_code = exc.code or 0
+ if target == "scan_gate":
+ installs, audit = _scan_gate_env(monkeypatch, tmp_path, verdict=outcome)
+ else:
+ monkeypatch.setattr(cli_hub, target, lambda *a, **k: outcome)
+ if argv[1] == "update":
+ # Never run hermes_cli.main with `update` in argv (it can turn into a real self-update): drive
+ # the same router `hermes skills` returns its exit code from.
+ from argparse import Namespace
+ exit_code = cli_hub.skills_command(Namespace(skills_action="update", name=None, force=False)) or 0
+ else:
+ monkeypatch.setattr(sys, "argv", ["hermes", *argv])
+ try:
+ main()
+ exit_code = 0
+ except SystemExit as exc:
+ exit_code = exc.code or 0
assert exit_code == code
+ if target == "scan_gate":
+ assert installs == [] and "Not installed:" in capsys.readouterr().out
+ assert audit and audit[0][0] == "BLOCKED"
diff --git a/tests/hermes_cli/test_skills_hub.py b/tests/hermes_cli/test_skills_hub.py
index 41aec0d020f..265613d5815 100644
--- a/tests/hermes_cli/test_skills_hub.py
+++ b/tests/hermes_cli/test_skills_hub.py
@@ -676,29 +676,23 @@ def _stub_search(monkeypatch, results):
monkeypatch.setattr(search, "unified_search", lambda *args, **kwargs: list(results))
-def test_resolve_short_name_matches_identifier_slug(monkeypatch):
- """A catalog row whose title is prettified ("Blender Bpy Enhanced") still resolves when the
- user installs the slug the Hub lists — before this, `hermes skills install <slug>` answered
- "No exact match" while printing that very slug as the suggestion."""
- from hermes_cli.skills_hub import _resolve_short_name
-
- _stub_search(monkeypatch, [_meta("Blender Bpy Enhanced", "@emergencescience/blender-bpy-enhanced")])
- console, sink = _sink_console()
-
- resolved = _resolve_short_name("blender-bpy-enhanced", [], console)
-
- assert resolved == "@emergencescience/blender-bpy-enhanced"
- assert "No exact match" not in sink.getvalue()
-
-
@pytest.mark.parametrize("identifier", [
"computer-use", "NousResearch/hermes-agent/skills/productivity/pdf",
- "skills-sh/nousresearch/hermes-agent/google-workspace"])
-def test_install_of_a_bundled_name_restores_it_and_never_touches_the_hub(monkeypatch, tmp_path, identifier):
+ "skills-sh/nousresearch/hermes-agent/google-workspace", "blender-bpy-enhanced"])
+def test_install_by_name_resolves_to_the_skill_it_names(monkeypatch, tmp_path, identifier):
"""`hermes skills install <bundled skill>` failed every time: the name resolved to a stranger's
same-named hub skill or an ambiguity table, and this repo's own copy was rescanned as community
- content and refused. It now makes the shipped skill active and fetches nothing."""
+ content and refused. It now makes the shipped skill active and fetches nothing. A hub slug behind
+ a prettified catalog title ("Blender Bpy Enhanced") resolves too, where it answered "No exact match"
+ while printing that very slug as the suggestion."""
import hermes_cli.skills_hub as cli_hub
+
+ if identifier == "blender-bpy-enhanced":
+ _stub_search(monkeypatch, [_meta("Blender Bpy Enhanced", "@emergencescience/blender-bpy-enhanced")])
+ console, sink = _sink_console()
+ assert cli_hub._resolve_short_name(identifier, [], console) == "@emergencescience/blender-bpy-enhanced"
+ assert "No exact match" not in sink.getvalue()
+ return
from tools import skills_sync
import tools.skills_hub as hub
@@ -742,6 +736,8 @@ def test_install_of_a_bundled_name_restores_it_and_never_touches_the_hub(monkeyp
install_path=f"hub-installs/{name}", files=["SKILL.md"])
console, sink = _sink_console()
assert cli_hub.do_install(identifier, console=console, skip_confirm=True) is False
- out = " ".join(sink.getvalue().split())
- assert "already available" not in out and f"hermes skills uninstall {name}" in out
+ # One line, subject and remedy together: the Desktop toast shows only a failed action's last 3 lines.
+ error = next(line for line in sink.getvalue().splitlines() if line.startswith("Error:"))
+ assert f"'{name}' is a built-in skill" in error and f"`hermes skills uninstall {name}`" in error
+ assert "already available" not in sink.getvalue()
assert (stranger / "SKILL.md").read_text().endswith("stranger\n")