_hermes_home.py 817 B

1234567891011121314151617181920212223
  1. """Resolve HERMES_HOME for standalone skill scripts.
  2. Skill scripts may run outside the Hermes process (system Python, nix env,
  3. CI) where ``hermes_constants`` is not importable. This module provides the
  4. same ``get_hermes_home()`` contract without requiring it on ``sys.path``.
  5. When ``hermes_constants`` IS available it is used directly so profile
  6. resolution and any future enhancements are picked up automatically.
  7. """
  8. from __future__ import annotations
  9. import os
  10. from pathlib import Path
  11. try:
  12. from hermes_constants import get_hermes_home
  13. except (ModuleNotFoundError, ImportError):
  14. def get_hermes_home() -> Path:
  15. """Return the Hermes home directory (default: ``~/.hermes``)."""
  16. val = os.environ.get("HERMES_HOME", "").strip()
  17. return Path(val) if val else Path.home() / ".hermes"