Files
hermes-agent/pm/paths.py
ethernet f6a30447de refactor(pm): one install_root() in pm.paths replaces six HERMES_INSTALL_ROOT ladders
post_update._install_root, boot_bootstrap.default_project_root,
update_channel._default_root, version_info._CODE_ROOT + _resolve_stamp_file,
_launchers.publish_launchers and pm.runtime each re-derived "HERMES_INSTALL_ROOT
or the code root". pm.paths.install_root() is the one place now; pm.store reuses
the downloader's User-Agent instead of carrying a second one.
2026-09-18 20:08:16 -04:00

62 lines
1.8 KiB
Python

"""Where the store, lockfile, and installed-state file live."""
from __future__ import annotations
import os
from pathlib import Path
def repo_root() -> Path:
return Path(__file__).resolve().parent.parent
def install_root() -> Path:
"""The tree this process runs from. ``HERMES_INSTALL_ROOT`` when a steward
wrapper sets it (Nix points it at the sealed tree whose install stamp lives
outside the package dir), else the executing checkout."""
env = os.environ.get("HERMES_INSTALL_ROOT")
return Path(env) if env else repo_root()
def lockfile_path() -> Path:
return Path(__file__).resolve().parent / "lock.json"
def store_root() -> Path:
from pm.environments import store_root as resolve
return resolve(repo_root())
def partials_root() -> Path:
"""The downloader's managed partials area: machine-scoped and shared
(keyed by sha256(url), so two callers or two profiles reuse one
partial), but anchored to the DEFAULT hermes root — NOT the byte
store. The store can live inside a read-only sealed payload
(WindowsApps/agent-payload), and partials are mutable state the
downloader writes continuously, so they must land somewhere writable
on every install kind: ``%LOCALAPPDATA%\\hermes\\cache\\partials`` on
Windows, ``~/.hermes/cache/partials`` on POSIX.
"""
from hermes_constants import get_default_hermes_root
return get_default_hermes_root() / "cache" / "partials"
def facts_path() -> Path:
return store_root() / "facts.json"
def writable_store_root() -> Path:
if not (store_root().parent / "manifest.json").is_file():
return store_root()
from hermes_constants import get_default_hermes_root
return get_default_hermes_root() / "tools"
def runtime_facts_path() -> Path:
from pm.environments import runtime_facts_path as resolve
return resolve(repo_root())