hermes-agent/tests/hermes_cli/test_skin_cmd.py
Brooklyn Nicholson 4f4f938aef feat(themes): hermes skin set — deterministic one-color tweak, bg untouched
Changing a single color kept wrecking the rest because the agent hand-authored a
new skin (often from `default`, which has no `background`, resetting the terminal
to black). Add `hermes skin set <key> <hex>`: edits the ACTIVE skin's one key in
place (a built-in is forked into an editable copy carrying its full palette), so
everything else — background included — is preserved. Plus `skin use` / `skin
list`. The skill now points tweaks at this command instead of hand-authoring.
2026-07-21 21:00:43 -05:00

57 lines
2 KiB
Python

"""`hermes skin set` — deterministic single-color tweak of the active skin.
The whole point is that changing one token never disturbs the rest of the look
(background especially), which hand-authoring kept getting wrong.
"""
import yaml
from hermes_cli import skin_cmd
from hermes_constants import get_hermes_home
def _skins():
d = get_hermes_home() / "skins"
d.mkdir(parents=True, exist_ok=True)
return d
def _activate(name: str) -> None:
(get_hermes_home() / "config.yaml").write_text(f"display:\n skin: {name}\n", encoding="utf-8")
def test_set_edits_active_user_skin_in_place_preserving_everything_else():
(_skins() / "oasis.yaml").write_text(
'name: oasis\ncolors:\n background: "#08201f"\n banner_title: "#f2dfb3"\n', encoding="utf-8"
)
_activate("oasis")
assert skin_cmd._skin_set("ui_tool", "#00FFFF", None) == 0
data = yaml.safe_load((_skins() / "oasis.yaml").read_text())
assert data["colors"]["ui_tool"] == "#00FFFF"
assert data["colors"]["background"] == "#08201f" # untouched — the whole point
assert data["colors"]["banner_title"] == "#f2dfb3"
assert data["name"] == "oasis" # no rename, no fork
assert not (_skins() / "oasis-custom.yaml").exists()
def test_set_forks_a_builtin_without_inventing_a_background():
_activate("default") # a built-in — no file
assert skin_cmd._skin_set("ui_tool", "#00FFFF", None) == 0
fork = _skins() / "default-custom.yaml"
assert fork.exists()
data = yaml.safe_load(fork.read_text())
assert data["colors"]["ui_tool"] == "#00FFFF"
# default has no background, so the fork must not invent one (terminal stays put).
assert "background" not in data["colors"]
# full palette carried over, and it became active.
assert data["colors"].get("banner_title")
assert (get_hermes_home() / "config.yaml").read_text().find("default-custom") != -1
def test_set_rejects_non_hex():
_activate("default")
assert skin_cmd._skin_set("ui_tool", "teal", None) == 1