Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/hermes_github_app_plugin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

from __future__ import annotations

import importlib
import json
import os
from collections.abc import Mapping
from dataclasses import dataclass
from pathlib import Path
from typing import Any
from typing import Any, cast

import yaml

Expand Down Expand Up @@ -39,8 +40,19 @@ def installation_id_for_repo(self, repo: str | None = None) -> str:


def hermes_home() -> Path:
"""Return the configured Hermes home directory."""
return Path(os.environ.get("HERMES_HOME", str(Path.home() / ".hermes"))).expanduser()
"""Return the configured Hermes home directory.

Prefer ``hermes_constants.get_hermes_home()`` so the profile-scoped home
(the contextvar override installed by a multiplex gateway) is honored when
this code runs inside a Hermes process. Falls back to the ``HERMES_HOME``
env var / platform default when the module is unavailable (e.g. the
standalone CLI, launched outside the Hermes source tree).
"""
try:
module = importlib.import_module("hermes_constants")
return cast(Path, cast(Any, module).get_hermes_home())
except (ImportError, AttributeError):
return Path(os.environ.get("HERMES_HOME", str(Path.home() / ".hermes"))).expanduser()


def config_path() -> Path:
Expand Down