From f22ed78a3e5102bbd5866abd4bcb46dd4f97a70a Mon Sep 17 00:00:00 2001 From: stablegenius49 <16443023+stablegenius49@users.noreply.github.com> Date: Tue, 10 Mar 2026 23:46:14 -0700 Subject: [PATCH] fix: mark doctor as interactive for tool checks --- hermes_cli/doctor.py | 4 ++++ tests/hermes_cli/test_doctor.py | 39 ++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/hermes_cli/doctor.py b/hermes_cli/doctor.py index de55bdff933e0..d6ea93f5884a4 100644 --- a/hermes_cli/doctor.py +++ b/hermes_cli/doctor.py @@ -69,6 +69,10 @@ def check_info(text: str): def run_doctor(args): """Run diagnostic checks.""" should_fix = getattr(args, 'fix', False) + + # Doctor runs from the interactive CLI, so CLI-gated tool availability + # checks (like cronjob management) should see the same context as `hermes`. + os.environ.setdefault("HERMES_INTERACTIVE", "1") issues = [] manual_issues = [] # issues that can't be auto-fixed diff --git a/tests/hermes_cli/test_doctor.py b/tests/hermes_cli/test_doctor.py index 6594de4fad1f6..43e357e95ce99 100644 --- a/tests/hermes_cli/test_doctor.py +++ b/tests/hermes_cli/test_doctor.py @@ -1,5 +1,13 @@ -"""Tests for hermes doctor helpers.""" +"""Tests for hermes_cli.doctor.""" +import os +import sys +import types +from argparse import Namespace + +import pytest + +from hermes_cli import doctor as doctor_mod from hermes_cli.doctor import _has_provider_env_config @@ -15,3 +23,32 @@ def test_detects_custom_endpoint_without_openrouter_key(self): def test_returns_false_when_no_provider_settings(self): content = "TERMINAL_ENV=local\n" assert not _has_provider_env_config(content) + + +def test_run_doctor_sets_interactive_env_for_tool_checks(monkeypatch, tmp_path): + """Doctor should present CLI-gated tools as available in CLI context.""" + project_root = tmp_path / "project" + hermes_home = tmp_path / ".hermes" + project_root.mkdir() + hermes_home.mkdir() + + monkeypatch.setattr(doctor_mod, "PROJECT_ROOT", project_root) + monkeypatch.setattr(doctor_mod, "HERMES_HOME", hermes_home) + monkeypatch.delenv("HERMES_INTERACTIVE", raising=False) + + seen = {} + + def fake_check_tool_availability(*args, **kwargs): + seen["interactive"] = os.getenv("HERMES_INTERACTIVE") + raise SystemExit(0) + + fake_model_tools = types.SimpleNamespace( + check_tool_availability=fake_check_tool_availability, + TOOLSET_REQUIREMENTS={}, + ) + monkeypatch.setitem(sys.modules, "model_tools", fake_model_tools) + + with pytest.raises(SystemExit): + doctor_mod.run_doctor(Namespace(fix=False)) + + assert seen["interactive"] == "1"