Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions tests/test_loop_features15.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,42 @@ def test_doctor_flags_missing_key(monkeypatch):
assert "no key" in report


def test_doctor_accepts_keyless_claude_code_when_cli_exists(monkeypatch):
monkeypatch.delenv("WALLBREAKER_CLAUDE_BIN", raising=False)
checked = []
monkeypatch.setattr(
"wallbreaker.config.shutil.which",
lambda binary: checked.append(binary) or "/fake/claude",
)
ep = Endpoint("claude-code", "claude-code", "", "opus")
cfg = Config(default_profile="claude-code", profiles={"claude-code": ep})

report, ok = doctor_report(cfg)

assert ok
assert checked == ["claude"]
assert "profile 'claude-code' CLI available" in report
assert "no key" not in report


def test_doctor_flags_missing_claude_cli(monkeypatch):
monkeypatch.setenv("WALLBREAKER_CLAUDE_BIN", "/missing/claude")
checked = []
monkeypatch.setattr(
"wallbreaker.config.shutil.which",
lambda binary: checked.append(binary) or None,
)
ep = Endpoint("claude-code", "claude-code", "", "opus")
cfg = Config(default_profile="claude-code", profiles={"claude-code": ep})

report, ok = doctor_report(cfg)

assert not ok
assert checked == ["/missing/claude"]
assert "profile 'claude-code' CLI available" in report
assert "NOT READY" in report


def test_doctor_notes_missing_target_and_judge():
ep = Endpoint("p", "openai", "http://x", "m", api_key="k")
cfg = Config(default_profile="p", profiles={"p": ep})
Expand Down
39 changes: 22 additions & 17 deletions wallbreaker/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import os
import shutil
import tomllib
from dataclasses import dataclass, field
from pathlib import Path
Expand Down Expand Up @@ -182,37 +183,45 @@ def check(label: str, passed: bool, detail: str = "") -> None:
ok = ok and passed
lines.append(f"[{mark}] {label}" + (f" - {detail}" if detail else ""))

def check_endpoint(label: str, ep: Endpoint, detail: str) -> None:
if ep.protocol == "claude-code":
binary = os.environ.get("WALLBREAKER_CLAUDE_BIN") or "claude"
check(
f"{label} CLI available",
shutil.which(binary) is not None,
f"{ep.model} via {binary}",
)
return
has_key = bool(ep.resolved_key())
if not has_key:
detail += f" (no key: set {ep.api_key_env or 'api_key'})"
check(f"{label} key resolves", has_key, detail)

check("profiles defined", bool(config.profiles), f"{len(config.profiles)} found")
check(
f"default_profile '{config.default_profile}' exists",
config.default_profile in config.profiles,
)
for name, ep in config.profiles.items():
has_key = bool(ep.resolved_key())
detail = f"{ep.model} @ {ep.base_url}"
if not has_key:
detail += f" (no key: set {ep.api_key_env or 'api_key'})"
check(f"profile '{name}' key resolves", has_key, detail)
check_endpoint(f"profile '{name}'", ep, f"{ep.model} @ {ep.base_url}")

if config.target is None:
lines.append("[note] no [target] - set one or use /target before attacking")
else:
modality_note = (
" (image-gen target)" if config.target.modality == "image" else ""
)
check(
"target key resolves",
bool(config.target.resolved_key()),
check_endpoint(
"target",
config.target,
f"{config.target.model} @ {config.target.base_url}{modality_note}",
)

if config.judge is None:
lines.append("[note] no [judge] - grading falls back to the default profile")
else:
check(
"judge key resolves",
bool(config.judge.resolved_key()),
f"{config.judge.model} @ {config.judge.base_url}",
check_endpoint(
"judge", config.judge, f"{config.judge.model} @ {config.judge.base_url}"
)

if config.art is None:
Expand All @@ -221,11 +230,7 @@ def check(label: str, passed: bool, detail: str = "") -> None:
"profile (if any) or a local renderer"
)
else:
check(
"art key resolves",
bool(config.art.resolved_key()),
f"{config.art.model} @ {config.art.base_url}",
)
check_endpoint("art", config.art, f"{config.art.model} @ {config.art.base_url}")

lines.append("=" * 40)
lines.append("READY" if ok else "NOT READY - fix the XX lines above")
Expand Down