fix(opencode): the auth check is the binary, and create takes the adapter's verdict (Issue #60, Linux item 3)

opencode 2.x needs no login: a fresh HOME runs a free default model and a
local provider has no key, while 2.x keeps no auth.json. auth_ok is now
"opencode on PATH or under <HOME>/.opencode/bin". `python -m lib_py.agents
auth-ok <agent>` exits with an adapter's verdict, and create's opencode
branch uses it (same 7 lines) instead of its own auth.json/key test and
`opencode --version`, which wrote a line to the real opencode log.
test_a4's opencode block now pins the binary rule (decision D1, required
by the brief's item 3 and by both reviewers). Other agents are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GodopuandClaude Opus 5.5 committed 2026-10-18 13:38:58 +00:00
1 parent 7803d47026
commit d17cd80bd9
5 files changed
+100 -17

No files matched your search

+11 -3
View File
@@ -311,16 +311,24 @@ def test_adapter_auth_ok(tmp_path, monkeypatch):
# Hermes always True
assert get_adapter('hermes').auth_ok() is True
# OpenCode auth check (provider env var or auth.json file)
# OpenCode auth check: the binary alone (2.x needs no login, Issue #60);
# keys and auth.json do not count
opencode = get_adapter('opencode')
path = os.environ["PATH"]
monkeypatch.setenv("PATH", str(tmp_path / "empty-bin"))
assert opencode.auth_ok() is False
monkeypatch.setenv("ANTHROPIC_API_KEY", "test-key")
assert opencode.auth_ok() is True
monkeypatch.delenv("ANTHROPIC_API_KEY", raising=False)
opencode_auth = tmp_path / ".local" / "share" / "opencode" / "auth.json"
opencode_auth.parent.mkdir(parents=True, exist_ok=True)
opencode_auth.write_text("{}")
assert opencode.auth_ok() is False
monkeypatch.delenv("ANTHROPIC_API_KEY", raising=False)
opencode_bin = tmp_path / ".opencode" / "bin" / "opencode"
opencode_bin.parent.mkdir(parents=True)
opencode_bin.write_text("#!/bin/sh\n")
opencode_bin.chmod(0o755)
assert opencode.auth_ok() is True
monkeypatch.setenv("PATH", path)
# Codex auth check (env var, auth.json file, or CLI)
codex = get_adapter('codex')