Skip to content

The agent that grows with you

refactor(doctor): move output primitives + Finding to doctor_report.py leaf

Teknium687884416d7e
diff --git a/hermes_cli/doctor.py b/hermes_cli/doctor.py
index ad7696cd7aa..c4c39f2be51 100644
--- a/hermes_cli/doctor.py
+++ b/hermes_cli/doctor.py
@@ -9,7 +9,6 @@ import sys
import subprocess
import shutil
import importlib.util
-from dataclasses import dataclass, field
from pathlib import Path
from hermes_cli.config import (
@@ -33,6 +32,15 @@ _env_path = get_env_path()
load_hermes_dotenv(hermes_home=_env_path.parent, project_env=PROJECT_ROOT / ".env")
from hermes_cli.colors import Colors, color
+from hermes_cli.doctor_report import ( # noqa: F401 (re-exported for doctor_live and tests)
+ Finding,
+ _fail_and_issue,
+ _section,
+ check_fail,
+ check_info,
+ check_ok,
+ check_warn,
+)
from hermes_cli.doctor_connectivity import ( # noqa: F401 (re-exported; tests import from hermes_cli.doctor)
_build_apikey_providers_list,
_has_healthy_oauth_fallback_for_apikey_provider,
@@ -372,19 +380,6 @@ def _apply_doctor_tool_availability_overrides(available: list[str], unavailable:
return updated_available, updated_unavailable
-def check_ok(text: str, detail: str = ""):
- print(f" {color('✓', Colors.GREEN)} {text}" + (f" {color(detail, Colors.DIM)}" if detail else ""))
-
-def check_warn(text: str, detail: str = ""):
- print(f" {color('⚠', Colors.YELLOW)} {text}" + (f" {color(detail, Colors.DIM)}" if detail else ""))
-
-def check_fail(text: str, detail: str = ""):
- print(f" {color('✗', Colors.RED)} {text}" + (f" {color(detail, Colors.DIM)}" if detail else ""))
-
-def check_info(text: str):
- print(f" {color('→', Colors.CYAN)} {text}")
-
-
def _doctor_memory_config(hermes_home: Path | None = None) -> dict:
"""Return the effective memory section used by doctor diagnostics."""
home = hermes_home if hermes_home is not None else HERMES_HOME
@@ -509,18 +504,6 @@ def _render_state_db_stats(stats: dict, holders=None) -> list:
return lines
-def _section(title: str) -> None:
- """Print a doctor section banner: blank line + bold cyan ◆ title."""
- print()
- print(color(f"◆ {title}", Colors.CYAN, Colors.BOLD))
-
-
-def _fail_and_issue(text: str, detail: str, fix: str, issues: list[str]) -> None:
- """Emit a check_fail and append the corresponding fix instruction."""
- check_fail(text, detail)
- issues.append(fix)
-
-
# Deprecated / legacy config keys still read for back-compat. Doctor surfaces
# them as non-failing warnings with the modern replacement — it does not
# auto-migrate or delete (migrations live in config.py version steps).
@@ -1139,20 +1122,6 @@ def check_macos_full_disk_access() -> None:
)
-@dataclass
-class Finding:
- """What one doctor check contributed: auto-fixable issues, manual-only issues, fixes applied."""
-
- issues: list = field(default_factory=list)
- manual_issues: list = field(default_factory=list)
- fixed: int = 0
-
- def merge(self, other: "Finding") -> None:
- self.issues.extend(other.issues)
- self.manual_issues.extend(other.manual_issues)
- self.fixed += other.fixed
-
-
def _memory_store_flags(hermes_home: Path) -> tuple:
from tools.memory_tool import get_builtin_memory_store_flags
diff --git a/hermes_cli/doctor_report.py b/hermes_cli/doctor_report.py
new file mode 100644
index 00000000000..6c4cdaa41ae
--- /dev/null
+++ b/hermes_cli/doctor_report.py
@@ -0,0 +1,49 @@
+"""Doctor output primitives shared by every ``hermes_cli.doctor_*`` module."""
+
+from __future__ import annotations
+
+from dataclasses import dataclass, field
+
+from hermes_cli.colors import Colors, color
+
+
+def check_ok(text: str, detail: str = ""):
+ print(f" {color('✓', Colors.GREEN)} {text}" + (f" {color(detail, Colors.DIM)}" if detail else ""))
+
+
+def check_warn(text: str, detail: str = ""):
+ print(f" {color('⚠', Colors.YELLOW)} {text}" + (f" {color(detail, Colors.DIM)}" if detail else ""))
+
+
+def check_fail(text: str, detail: str = ""):
+ print(f" {color('✗', Colors.RED)} {text}" + (f" {color(detail, Colors.DIM)}" if detail else ""))
+
+
+def check_info(text: str):
+ print(f" {color('→', Colors.CYAN)} {text}")
+
+
+def _section(title: str) -> None:
+ """Print a doctor section banner: blank line + bold cyan ◆ title."""
+ print()
+ print(color(f"◆ {title}", Colors.CYAN, Colors.BOLD))
+
+
+def _fail_and_issue(text: str, detail: str, fix: str, issues: list[str]) -> None:
+ """Emit a check_fail and append the corresponding fix instruction."""
+ check_fail(text, detail)
+ issues.append(fix)
+
+
+@dataclass
+class Finding:
+ """What one doctor check contributed: auto-fixable issues, manual-only issues, fixes applied."""
+
+ issues: list = field(default_factory=list)
+ manual_issues: list = field(default_factory=list)
+ fixed: int = 0
+
+ def merge(self, other: "Finding") -> None:
+ self.issues.extend(other.issues)
+ self.manual_issues.extend(other.manual_issues)
+ self.fixed += other.fixed