The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): check the platform wrapper name in doctor's profile alias probe
liuhao10246d4b211ab453
diff --git a/hermes_cli/doctor_state.py b/hermes_cli/doctor_state.pyindex d2f10cb789b..caaa4303a06 100644--- a/hermes_cli/doctor_state.py+++ b/hermes_cli/doctor_state.py@@ -651,7 +651,7 @@ def _check_profiles(should_fix: bool, f: Finding) -> None:parts = [text for cond, text in ((p.gateway_running, "gateway running"), (p.model, (p.model or "")[:30]),(not (p.path / "config.yaml").exists(), "⚠ missing config"), (not (p.path / ".env").exists(), "no .env"),- (not (wrapper_dir / p.name).exists(), "no alias")) if cond]+ (not _wrapper_path(p.name).exists(), "no alias")) if cond]check_ok(f" {p.name}: {', '.join(parts) if parts else 'configured'}")# Orphan wrappersif wrapper_dir.is_dir():diff --git a/tests/hermes_cli/test_doctor.py b/tests/hermes_cli/test_doctor.pyindex 67155206999..0f5afab8895 100644--- a/tests/hermes_cli/test_doctor.py+++ b/tests/hermes_cli/test_doctor.py@@ -1632,3 +1632,55 @@ def test_cron_store_check_reports_writability_and_low_space(finding = doctor_state._check_cron_store(False)assert expected in capsys.readouterr().outassert len(finding.issues) == len(issues) and all(any(s in i for i in finding.issues) for s in issues)+++class TestCheckProfilesAlias:+ """#131753: doctor must look for the wrapper name the writer actually creates+ (``<alias>.bat`` on Windows), not the bare POSIX name on every platform."""++ @staticmethod+ def _run(monkeypatch, capsys, tmp_path, platform, wrappers):+ import hermes_cli.profiles as profiles_mod+ import hermes_cli.gateway_migrate as gateway_migrate++ wrapper_dir = tmp_path / "bin"+ wrapper_dir.mkdir()+ for name in wrappers:+ target = name[: -len(".bat")] if name.endswith(".bat") else name+ (wrapper_dir / name).write_text(+ f"@echo off\r\nhermes -p {target} %*\r\n", encoding="utf-8")++ home = tmp_path / "home"+ home.mkdir()+ (home / "config.yaml").write_text("model: m\n", encoding="utf-8")+ (home / ".env").write_text("K=v\n", encoding="utf-8")++ profiles = [+ SimpleNamespace(name="dev", path=home, is_default=False,+ gateway_running=True, model="deepseek-v4.1-flash"),+ # ops never gets a wrapper: a genuinely missing alias must stay reportable+ SimpleNamespace(name="ops", path=home, is_default=False,+ gateway_running=True, model="deepseek-v4.1-flash"),+ ]+ monkeypatch.setattr(profiles_mod, "list_profiles", lambda **kw: profiles)+ monkeypatch.setattr(profiles_mod, "_get_wrapper_dir", lambda: wrapper_dir)+ monkeypatch.setattr(profiles_mod, "profile_exists", lambda name: True)+ monkeypatch.setattr(gateway_migrate, "duplicate_credential_findings", lambda: [])+ monkeypatch.setattr(sys, "platform", platform)++ doctor_state._check_profiles(False)+ return capsys.readouterr().out++ def test_windows_bat_wrapper_is_not_reported_missing(self, monkeypatch, capsys, tmp_path):+ out = self._run(monkeypatch, capsys, tmp_path, "win32", ["dev.bat"])+ dev_line = next(ln for ln in out.splitlines() if "dev:" in ln)+ assert "no alias" not in dev_line+ ops_line = next(ln for ln in out.splitlines() if "ops:" in ln)+ assert "no alias" in ops_line++ def test_posix_bare_wrapper_still_matches(self, monkeypatch, capsys, tmp_path):+ out = self._run(monkeypatch, capsys, tmp_path, "darwin", ["dev"])+ dev_line = next(ln for ln in out.splitlines() if "dev:" in ln)+ assert "no alias" not in dev_line+ ops_line = next(ln for ln in out.splitlines() if "ops:" in ln)+ assert "no alias" in ops_line