Skip to content

The agent that grows with you

refactor(hermes_cli): setup cluster — _section_rule divider helper, single missing-env scan, BOM removeprefix

Teknium9f83bb09f6e8
diff --git a/hermes_cli/send_cmd.py b/hermes_cli/send_cmd.py
index b62775a5fdf..c785d55160c 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 80ddfc0a050..96f9fc3341a 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 7bcae39fe40..664e5786c4c 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"):