fix: resolve .env and config paths from HERMES_HOME, not PROJECT_ROOT
The `hermes` CLI entry point (hermes_cli/main.py) and the agent runner (run_agent.py) only loaded .env from the project installation directory. After the standard installer, code lives at ~/.hermes/hermes-agent/ but config lives at ~/.hermes/ — so the .env was never found. Aligns these entry points with the pattern already used by gateway/run.py and rl_cli.py: load ~/.hermes/.env first, fall back to project root .env for dev-mode compatibility. Also fixes: - status.py checking .env existence and API keys at PROJECT_ROOT - doctor.py KeyError on tool availability (missing_vars vs env_vars) - doctor.py checking logs/ and Skills Hub at PROJECT_ROOT instead of HERMES_HOME - doctor.py redundant logs/ check (already covered by subdirectory loop) - mini-swe-agent loading config from platformdirs default instead of ~/.hermes/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -23,9 +23,13 @@ if _env_path.exists():
|
||||
load_dotenv(_env_path, encoding="utf-8")
|
||||
except UnicodeDecodeError:
|
||||
load_dotenv(_env_path, encoding="latin-1")
|
||||
# Also try project .env as fallback
|
||||
# Also try project .env as dev fallback
|
||||
load_dotenv(PROJECT_ROOT / ".env", override=False, encoding="utf-8")
|
||||
|
||||
# Point mini-swe-agent at ~/.hermes/ so it shares our config
|
||||
os.environ.setdefault("MSWEA_GLOBAL_CONFIG_DIR", str(HERMES_HOME))
|
||||
os.environ.setdefault("MSWEA_SILENT_STARTUP", "1")
|
||||
|
||||
from hermes_cli.colors import Colors, color
|
||||
from hermes_constants import OPENROUTER_MODELS_URL
|
||||
|
||||
@@ -225,17 +229,6 @@ def run_doctor(args):
|
||||
check_ok("Created ~/.hermes/SOUL.md with basic template")
|
||||
fixed_count += 1
|
||||
|
||||
logs_dir = PROJECT_ROOT / "logs"
|
||||
if logs_dir.exists():
|
||||
check_ok("logs/ directory exists (project root)")
|
||||
else:
|
||||
if should_fix:
|
||||
logs_dir.mkdir(parents=True, exist_ok=True)
|
||||
check_ok("Created logs/ directory")
|
||||
fixed_count += 1
|
||||
else:
|
||||
check_warn("logs/ not found", "(will be created on first use)")
|
||||
|
||||
# Check memory directory
|
||||
memories_dir = hermes_home / "memories"
|
||||
if memories_dir.exists():
|
||||
@@ -447,14 +440,15 @@ def run_doctor(args):
|
||||
check_ok(info.get("name", tid))
|
||||
|
||||
for item in unavailable:
|
||||
if item["missing_vars"]:
|
||||
vars_str = ", ".join(item["missing_vars"])
|
||||
env_vars = item.get("missing_vars") or item.get("env_vars") or []
|
||||
if env_vars:
|
||||
vars_str = ", ".join(env_vars)
|
||||
check_warn(item["name"], f"(missing {vars_str})")
|
||||
else:
|
||||
check_warn(item["name"], "(system dependency not met)")
|
||||
|
||||
|
||||
# Count disabled tools with API key requirements
|
||||
api_disabled = [u for u in unavailable if u["missing_vars"]]
|
||||
api_disabled = [u for u in unavailable if (u.get("missing_vars") or u.get("env_vars"))]
|
||||
if api_disabled:
|
||||
issues.append("Run 'hermes setup' to configure missing API keys for full tool access")
|
||||
except Exception as e:
|
||||
@@ -466,7 +460,7 @@ def run_doctor(args):
|
||||
print()
|
||||
print(color("◆ Skills Hub", Colors.CYAN, Colors.BOLD))
|
||||
|
||||
hub_dir = PROJECT_ROOT / "skills" / ".hub"
|
||||
hub_dir = HERMES_HOME / "skills" / ".hub"
|
||||
if hub_dir.exists():
|
||||
check_ok("Skills Hub directory exists")
|
||||
lock_file = hub_dir / "lock.json"
|
||||
@@ -485,7 +479,8 @@ def run_doctor(args):
|
||||
else:
|
||||
check_warn("Skills Hub directory not initialized", "(run: hermes skills list)")
|
||||
|
||||
github_token = os.environ.get("GITHUB_TOKEN") or os.environ.get("GH_TOKEN")
|
||||
from hermes_cli.config import get_env_value
|
||||
github_token = get_env_value("GITHUB_TOKEN") or get_env_value("GH_TOKEN")
|
||||
if github_token:
|
||||
check_ok("GitHub token configured (authenticated API access)")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user