refactor: consolidate get_hermes_home() and parse_reasoning_effort() (#3062)

Centralizes two widely-duplicated patterns into hermes_constants.py:

1. get_hermes_home() — Path resolution for ~/.hermes (HERMES_HOME env var)
   - Was copy-pasted inline across 30+ files as:
     Path(os.getenv("HERMES_HOME", Path.home() / ".hermes"))
   - Now defined once in hermes_constants.py (zero-dependency module)
   - hermes_cli/config.py re-exports it for backward compatibility
   - Removed local wrapper functions in honcho_integration/client.py,
     tools/website_policy.py, tools/tirith_security.py, hermes_cli/uninstall.py

2. parse_reasoning_effort() — Reasoning effort string validation
   - Was copy-pasted in cli.py, gateway/run.py, cron/scheduler.py
   - Same validation logic: check against (xhigh, high, medium, low, minimal, none)
   - Now defined once in hermes_constants.py, called from all 3 locations
   - Warning log for unknown values kept at call sites (context-specific)

31 files changed, net +31 lines (125 insertions, 94 deletions)
Full test suite: 6179 passed, 0 failed
This commit is contained in:
Teknium
2026-03-25 15:54:28 -07:00
committed by GitHub
parent e0cfc089da
commit 77bcaba2d7
31 changed files with 125 additions and 94 deletions

View File

@@ -18,6 +18,8 @@ import os
import logging
from dataclasses import dataclass, field
from pathlib import Path
from hermes_constants import get_hermes_home
from typing import Any, TYPE_CHECKING
if TYPE_CHECKING:
@@ -29,11 +31,6 @@ GLOBAL_CONFIG_PATH = Path.home() / ".honcho" / "config.json"
HOST = "hermes"
def _get_hermes_home() -> Path:
"""Get HERMES_HOME without importing hermes_cli (avoids circular deps)."""
return Path(os.getenv("HERMES_HOME", Path.home() / ".hermes"))
def resolve_config_path() -> Path:
"""Return the active Honcho config path.
@@ -41,7 +38,7 @@ def resolve_config_path() -> Path:
to ~/.honcho/config.json (global). Returns the global path if neither
exists (for first-time setup writes).
"""
local_path = _get_hermes_home() / "honcho.json"
local_path = get_hermes_home() / "honcho.json"
if local_path.exists():
return local_path
return GLOBAL_CONFIG_PATH