fix(install): distinguish protocol targets in status

This commit is contained in:
oxura
2026-10-08 19:25:36 +06:00
parent 3c418f6f0b
commit 39e7d46fa7
3 changed files with 9 additions and 64 deletions
@@ -90,6 +90,8 @@ headroom install remove
`apply` creates or updates a named deployment profile, stores its manifest under `~/.headroom/deploy/<profile>/manifest.json`, applies reversible configuration changes, and starts the selected runtime.
`status` distinguishes the default backend from the Anthropic and OpenAI protocol targets. Each target is shown as `configured` or `default`; target URLs and credentials are not printed. An OpenAI-compatible deployment can therefore have `Default backend: anthropic` and `OpenAI target: configured` at the same time.
## Presets and runtime kinds
### Presets
+7 -1
View File
@@ -1180,7 +1180,13 @@ def install_status(profile: str) -> None:
config = payload.get("config")
if not isinstance(config, dict):
config = {}
click.echo(f"Backend: {config.get('backend', manifest.backend)}")
click.echo(f"Default backend: {config.get('backend', manifest.backend)}")
click.echo(
f"Anthropic target: {'configured' if config.get('anthropic_api_url') else 'default'}"
)
click.echo(
f"OpenAI target: {'configured' if config.get('openai_api_url') else 'default'}"
)
@install.command("start")
-63
View File
@@ -449,69 +449,6 @@ def test_install_apply_explicit_env_overrides_captured(monkeypatch) -> None:
assert captured["extra_env"]["ANTHROPIC_TARGET_API_URL"] == "https://explicit.internal/v1"
def test_install_status_includes_backend_from_health_probe(monkeypatch) -> None:
runner = CliRunner()
class Manifest:
targets = ["claude"]
tool_envs = {}
profile = "default"
preset = "persistent-service"
runtime_kind = "python"
supervisor_kind = "service"
scope = "user"
port = 8787
backend = "anthropic"
health_url = "http://127.0.0.1:8787/readyz"
monkeypatch.setattr("headroom.cli.install.load_manifest", lambda profile: Manifest())
monkeypatch.setattr(
"headroom.cli.install.runtime_status",
lambda manifest: "running",
)
monkeypatch.setattr("headroom.cli.install.probe_ready", lambda url: True)
monkeypatch.setattr(
"headroom.cli.install.probe_json",
lambda url: {"config": {"backend": "anthropic"}},
)
result = runner.invoke(main, ["install", "status"])
assert result.exit_code == 0, result.output
assert "Status: running" in result.output
assert "Healthy: yes" in result.output
assert "Backend: anthropic" in result.output
def test_install_status_survives_non_dict_config(monkeypatch) -> None:
"""A health payload whose `config` is a non-dict (e.g. a different service
answering on the port returns config: null) must not crash the command."""
runner = CliRunner()
class Manifest:
targets = ["claude"]
tool_envs = {}
profile = "default"
preset = "persistent-service"
runtime_kind = "python"
supervisor_kind = "service"
scope = "user"
port = 8787
backend = "anthropic"
health_url = "http://127.0.0.1:8787/readyz"
monkeypatch.setattr("headroom.cli.install.load_manifest", lambda profile: Manifest())
monkeypatch.setattr("headroom.cli.install.runtime_status", lambda manifest: "running")
monkeypatch.setattr("headroom.cli.install.probe_ready", lambda url: True)
monkeypatch.setattr("headroom.cli.install.probe_json", lambda url: {"config": None})
result = runner.invoke(main, ["install", "status"])
# No AttributeError; Backend falls back to the manifest value.
assert result.exit_code == 0, result.output
assert "Backend: anthropic" in result.output
def test_install_restart_uses_internal_helpers(monkeypatch) -> None:
runner = CliRunner()
calls: list[str] = []