mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-06 05:17:15 +00:00
The ratchet (scripts/check --only health, new on main) freezes every file over 2,000 lines at its main size and blocks blind excepts. - Facades back at or below their main size: the backend seam's local imports become module-level ones (config_exists via hermes_cli.config where that is already imported), and unrelated pure helpers move to topical siblings: _job_doc_header -> cron/scheduler_prompt.py, _csv_or_list_to_set -> gateway/run_common.py, the dotted config-path pair -> hermes_cli/backup_restore.py, voice/timezone/web checks -> hermes_cli/config_value_checks.py, a new profile's config document (seed, migrate, backend read) -> hermes_cli/profiles_config.py, pet spritesheet helpers -> tui_gateway/pet_sheet.py. Callers import from the defining module (no re-export). - BLE001: _load_config_dict catches YAMLError/OSError/UnicodeError; run_migrations inlines the step loop again (the moved blind except keeps main's identity); the two intentional fail-opens carry '# health: allow' with their reason.
30 lines
1.3 KiB
Python
30 lines
1.3 KiB
Python
"""Migrate a new profile's copied config document (``hermes_cli.profiles`` creation helper)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import contextlib
|
|
from pathlib import Path
|
|
from hermes_cli.config_backend import config_exists, supports_file_tooling
|
|
|
|
|
|
def _migrate_profile_config_if_outdated(profile_dir: Path) -> None:
|
|
"""Migrate a copied config.yaml to the current schema (non-interactive, scoped to the new
|
|
profile); otherwise the first desktop/doctor view shows a scary ``v0 -> latest`` warning."""
|
|
if not supports_file_tooling():
|
|
return # no local config.yaml to migrate: a remote backend migrates in memory on read (D12)
|
|
if not config_exists(profile_dir / "config.yaml"):
|
|
return
|
|
# Creation must not fail over an unmigratable old config; `hermes doctor --fix` surfaces
|
|
# the detailed error in the target profile.
|
|
with contextlib.suppress(Exception):
|
|
from hermes_constants import reset_hermes_home_override, set_hermes_home_override
|
|
from hermes_cli.config import check_config_version, migrate_config
|
|
token = set_hermes_home_override(str(profile_dir))
|
|
try:
|
|
current_ver, latest_ver = check_config_version()
|
|
if current_ver < latest_ver:
|
|
migrate_config(interactive=False, quiet=True)
|
|
finally:
|
|
reset_hermes_home_override(token)
|
|
|