From 9f83bb09f6e8f973addb78e59b3d37f3eb23c796 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 2 Sep 2026 22:33:08 -0700 Subject: [PATCH] =?UTF-8?q?refactor(hermes=5Fcli):=20setup=20cluster=20?= =?UTF-8?q?=E2=80=94=20=5Fsection=5Frule=20divider=20helper,=20single=20mi?= =?UTF-8?q?ssing-env=20scan,=20BOM=20removeprefix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hermes_cli/send_cmd.py | 7 ++----- hermes_cli/setup.py | 11 ++++++++--- hermes_cli/setup_quick.py | 11 +++++------ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/hermes_cli/send_cmd.py b/hermes_cli/send_cmd.py index b62775a5fd..c785d55160 100644 --- a/hermes_cli/send_cmd.py +++ b/hermes_cli/send_cmd.py @@ -150,13 +150,10 @@ def _load_hermes_env() -> None: # U+FEFF on the first key name and silently drop it from os.environ. load_dotenv(str(env_path), override=True, encoding="utf-8-sig") except UnicodeDecodeError: - try: - # utf-8-sig can't strip a BOM once we fall back to latin-1. + try: # utf-8-sig can't strip a BOM once we fall back to latin-1. import codecs import io - raw = env_path.read_bytes() - if raw.startswith(codecs.BOM_UTF8): - raw = raw[len(codecs.BOM_UTF8) :] + raw = env_path.read_bytes().removeprefix(codecs.BOM_UTF8) load_dotenv(stream=io.StringIO(raw.decode("latin-1")), override=True) except Exception: pass diff --git a/hermes_cli/setup.py b/hermes_cli/setup.py index 80ddfc0a05..96f9fc3341 100644 --- a/hermes_cli/setup.py +++ b/hermes_cli/setup.py @@ -316,15 +316,20 @@ def prompt_checklist(title: str, items: list, pre_selected: list = None) -> list return sorted(curses_checklist(title, items, pre, cancel_returns=pre)) +def _section_rule(title: str) -> None: + """Blank-padded cyan ``─── title ───`` divider used by the key-entry screens.""" + print() + print(color(f" ─── {title} ───", Colors.CYAN)) + print() + + def _prompt_api_key(var: dict): """Display a nicely formatted API key input screen for a single env var.""" tools = var.get("tools", []) tools_str = ", ".join(tools[:3]) if len(tools) > 3: tools_str += f", +{len(tools) - 3} more" - print() - print(color(f" ─── {var.get('description', var['name'])} ───", Colors.CYAN)) - print() + _section_rule(var.get("description", var["name"])) if tools_str: print_info(f" Enables: {tools_str}") if var.get("url"): diff --git a/hermes_cli/setup_quick.py b/hermes_cli/setup_quick.py index 7bcae39fe4..664e5786c4 100644 --- a/hermes_cli/setup_quick.py +++ b/hermes_cli/setup_quick.py @@ -327,14 +327,15 @@ def _run_quick_setup(config: dict, hermes_home): """Quick setup — only configure items that are missing.""" from hermes_cli.setup import ( color, Colors, _info, print_header, print_info, _print_setup_summary, print_success, - _prompt_and_save_env_var, _prompt_api_key, prompt_checklist, save_config, + _prompt_and_save_env_var, _prompt_api_key, _section_rule, prompt_checklist, save_config, ) from hermes_cli.config import (get_missing_env_vars, get_missing_config_fields, check_config_version) print_header("Quick Setup — Missing Items Only", gap=True) # Check what's missing - missing_required = [v for v in get_missing_env_vars(required_only=False) if v.get("is_required")] - missing_optional = [v for v in get_missing_env_vars(required_only=False) if not v.get("is_required")] + missing_env = get_missing_env_vars(required_only=False) + missing_required = [v for v in missing_env if v.get("is_required")] + missing_optional = [v for v in missing_env if not v.get("is_required")] missing_config = get_missing_config_fields() current_ver, latest_ver = check_config_version() if not (missing_required or missing_optional or missing_config or current_ver < latest_ver): @@ -378,9 +379,7 @@ def _run_quick_setup(config: dict, hermes_home): labels = [f"{emojis[p]} {p}" for p in platform_order] for idx in prompt_checklist("Which platforms would you like to set up?", labels): plat = platform_order[idx] - print() - print(color(f" ─── {emojis[plat]} {plat} ───", Colors.CYAN)) - print() + _section_rule(f"{emojis[plat]} {plat}") for var in grouped[plat]: print_info(f" {var.get('description', '')}") if var.get("url"):