Scrub real machine hostname from README and test fixtures

This commit is contained in:
neil 2026-11-05 01:29:45 -08:00
parent c8f04f49b7
commit d07a92e5b5
2 changed files with 34 additions and 34 deletions

View file

@ -79,7 +79,7 @@ the file up as `opencode.json.before-llmhost`.
A config with comments (`.jsonc`) is never rewritten, since that would drop them; setup prints the block to paste instead. A config with comments (`.jsonc`) is never rewritten, since that would drop them; setup prints the block to paste instead.
**On another machine**, run `llmhost opencode-config` on the server. It prints a provider block and a one-liner **On another machine**, run `llmhost opencode-config` on the server. It prints a provider block and a one-liner
that copies the API key over. That block is named **LLMHost (<the server's hostname>)** — e.g. `LLMHost (popos.local)` that copies the API key over. That block is named **LLMHost (<the server's hostname>)** — e.g. `LLMHost (mybox.local)`
— under the provider id `llmhost-<shorthost>`. — under the provider id `llmhost-<shorthost>`.
### One opencode, several servers ### One opencode, several servers
@ -114,8 +114,8 @@ never overwritten (setup takes `llmhost-local` instead and says so), and `uninst
provider — remote ones, and providers llm-host didn't create, are left in place. If a provider's default model provider — remote ones, and providers llm-host didn't create, are left in place. If a provider's default model
goes away with it, `model` is repointed at a surviving llm-host provider, and dropped only if there is none. goes away with it, `model` is repointed at a surviving llm-host provider, and dropped only if there is none.
Retiring a server is the one thing the servers can't do for each other: uninstalling on `popos` can't reach the Retiring a server is the one thing the servers can't do for each other: uninstalling on `mybox` can't reach the
clients pointing at it. On each client, run `llmhost opencode-remove --host popos.local` (or delete the block by clients pointing at it. On each client, run `llmhost opencode-remove --host mybox.local` (or delete the block by
hand if llm-host isn't installed there). hand if llm-host isn't installed there).
### If opencode keeps asking for the API key ### If opencode keeps asking for the API key

View file

@ -47,21 +47,21 @@ check("limits come from the loaded model",
check("reasoning flag from the loaded model", mods["default"].get("reasoning") is True, mods["default"]) check("reasoning flag from the loaded model", mods["default"].get("reasoning") is True, mods["default"])
print("\n2. local + remote side by side") print("\n2. local + remote side by side")
rp, rb = remote("popos.local") rp, rb = remote("mybox.local")
reset({"provider": {rp: rb}, "model": f"{rp}/qwen3.8-27b"}) reset({"provider": {rp: rb}, "model": f"{rp}/qwen3.8-27b"})
st, path, prov, authcl = opencode.configure(CFG) st, path, prov, authcl = opencode.configure(CFG)
d = load() d = load()
check("remote id is llmhost-popos", rp == "llmhost-popos", rp) check("remote id is llmhost-mybox", rp == "llmhost-mybox", rp)
check('remote name is "LLMHost (popos.local)"', rb["name"] == "LLMHost (popos.local)", rb["name"]) check('remote name is "LLMHost (mybox.local)"', rb["name"] == "LLMHost (mybox.local)", rb["name"])
check("remote has one entry too", list(rb["models"]) == ["default"], list(rb["models"])) check("remote has one entry too", list(rb["models"]) == ["default"], list(rb["models"]))
check("remote label names no model (it would go stale)", check("remote label names no model (it would go stale)",
rb["models"]["default"]["name"] == "Default model (popos.local)", rb["models"]["default"]["name"]) rb["models"]["default"]["name"] == "Default model (mybox.local)", rb["models"]["default"]["name"])
check("local added alongside", sorted(d["provider"]) == ["llmhost", "llmhost-popos"], sorted(d["provider"])) check("local added alongside", sorted(d["provider"]) == ["llmhost", "llmhost-mybox"], sorted(d["provider"]))
check("remote untouched", d["provider"][rp] == rb) check("remote untouched", d["provider"][rp] == rb)
check("existing model kept", d["model"] == f"{rp}/qwen3.8-27b", d["model"]) check("existing model kept", d["model"] == f"{rp}/qwen3.8-27b", d["model"])
print("\n3. a REMOTE block squatting on the `llmhost` id (gap 1)") print("\n3. a REMOTE block squatting on the `llmhost` id (gap 1)")
_, rb2 = remote("popos.local", prov="llmhost") _, rb2 = remote("mybox.local", prov="llmhost")
reset({"provider": {"llmhost": rb2}}) reset({"provider": {"llmhost": rb2}})
st, path, prov, authcl = opencode.configure(CFG) st, path, prov, authcl = opencode.configure(CFG)
d = load() d = load()
@ -83,7 +83,7 @@ check("a stale default makes it an update", st == "updated", st)
check("and it is migrated", load()["model"] == "mymac/default", load().get("model")) check("and it is migrated", load()["model"] == "mymac/default", load().get("model"))
print("\n5. uninstall: remove local, keep remote, repoint model") print("\n5. uninstall: remove local, keep remote, repoint model")
rp, rb = remote("popos.local") rp, rb = remote("mybox.local")
reset({"provider": {"llmhost": opencode.local_block(CFG), rp: rb}, "model": "llmhost/default"}) reset({"provider": {"llmhost": opencode.local_block(CFG), rp: rb}, "model": "llmhost/default"})
st, path, removed, new_model = opencode.remove(local=True) st, path, removed, new_model = opencode.remove(local=True)
d = load() d = load()
@ -108,13 +108,13 @@ check("remote still there", list(load()["provider"]) == [rp])
print("\n7. retiring a remote server (gap 3)") print("\n7. retiring a remote server (gap 3)")
reset({"provider": {"llmhost": opencode.local_block(CFG), rp: rb}, "model": f"{rp}/qwen3.8-27b"}) reset({"provider": {"llmhost": opencode.local_block(CFG), rp: rb}, "model": f"{rp}/qwen3.8-27b"})
st, path, removed, new_model = opencode.remove(local=False, host="popos.local") st, path, removed, new_model = opencode.remove(local=False, host="mybox.local")
d = load() d = load()
check("removed the remote", removed == [rp], removed) check("removed the remote", removed == [rp], removed)
check("local survives", list(d["provider"]) == ["llmhost"], list(d["provider"])) check("local survives", list(d["provider"]) == ["llmhost"], list(d["provider"]))
check("model repointed to local", d["model"].startswith("llmhost/"), d.get("model")) check("model repointed to local", d["model"].startswith("llmhost/"), d.get("model"))
reset({"provider": {"llmhost": opencode.local_block(CFG), rp: rb}}) reset({"provider": {"llmhost": opencode.local_block(CFG), rp: rb}})
st, path, removed, _ = opencode.remove(local=False, host="popos") st, path, removed, _ = opencode.remove(local=False, host="mybox")
check("short hostname also matches", removed == [rp], removed) check("short hostname also matches", removed == [rp], removed)
print("\n8. --all drops the model key when nothing is left") print("\n8. --all drops the model key when nothing is left")
@ -126,15 +126,15 @@ check("model key dropped", "model" not in d and new_model is None, d)
check("provider key dropped", "provider" not in d, d) check("provider key dropped", "provider" not in d, d)
print("\n9. foreign providers are never touched") print("\n9. foreign providers are never touched")
foreign = {"npm": "@ai-sdk/openai-compatible", "name": "vLLM (popos)", foreign = {"npm": "@ai-sdk/openai-compatible", "name": "vLLM (mybox)",
"options": {"baseURL": "http://popos.local:1134/v1", "apiKey": "{file:~/.config/opencode/popos-vllm.key}"}, "options": {"baseURL": "http://mybox.local:1134/v1", "apiKey": "{file:~/.config/opencode/mybox-vllm.key}"},
"models": {"x": {"name": "x"}}} "models": {"x": {"name": "x"}}}
reset({"provider": {"popos-vllm": foreign, "llmhost": opencode.local_block(CFG)}, "model": "popos-vllm/x"}) reset({"provider": {"mybox-vllm": foreign, "llmhost": opencode.local_block(CFG)}, "model": "mybox-vllm/x"})
st, path, removed, new_model = opencode.remove(local=True) st, path, removed, new_model = opencode.remove(local=True)
d = load() d = load()
check("only ours removed", removed == ["llmhost"], removed) check("only ours removed", removed == ["llmhost"], removed)
check("foreign intact", d["provider"]["popos-vllm"] == foreign) check("foreign intact", d["provider"]["mybox-vllm"] == foreign)
check("foreign model untouched", d["model"] == "popos-vllm/x", d.get("model")) check("foreign model untouched", d["model"] == "mybox-vllm/x", d.get("model"))
st, path, removed, _ = opencode.remove(local=False, every=True) st, path, removed, _ = opencode.remove(local=False, every=True)
check("--all skips foreign", removed == [], removed) check("--all skips foreign", removed == [], removed)
@ -165,15 +165,15 @@ st, path, prov, authcl = opencode.configure(CFG)
check("still installs", prov == "llmhost" and st == "added", (prov, st)) check("still installs", prov == "llmhost" and st == "added", (prov, st))
print("\n13. --host must not take a foreign provider on the same host (regression)") print("\n13. --host must not take a foreign provider on the same host (regression)")
rp, rb = remote("popos.local") rp, rb = remote("mybox.local")
reset({"provider": {rp: rb, "popos-vllm": foreign, "llmhost": opencode.local_block(CFG)}, reset({"provider": {rp: rb, "mybox-vllm": foreign, "llmhost": opencode.local_block(CFG)},
"model": "popos-vllm/x"}) "model": "mybox-vllm/x"})
st, path, removed, new_model = opencode.remove(local=False, host="popos.local") st, path, removed, new_model = opencode.remove(local=False, host="mybox.local")
d = load() d = load()
check("removed only ours", removed == [rp], removed) check("removed only ours", removed == [rp], removed)
check("foreign on same host survives", "popos-vllm" in d["provider"]) check("foreign on same host survives", "mybox-vllm" in d["provider"])
check("local survives", "llmhost" in d["provider"]) check("local survives", "llmhost" in d["provider"])
check("foreign model untouched", d["model"] == "popos-vllm/x", d.get("model")) check("foreign model untouched", d["model"] == "mybox-vllm/x", d.get("model"))
print("\n14. a stale cached key is cleared on configure") print("\n14. a stale cached key is cleared on configure")
def put_auth(d, mode=0o600): def put_auth(d, mode=0o600):
@ -212,12 +212,12 @@ check("left verbatim", f.read_text() == "{ not json")
check("reported nothing cleared", authcl is False, authcl) check("reported nothing cleared", authcl is False, authcl)
print("\n17. remove() takes the cached key with the provider") print("\n17. remove() takes the cached key with the provider")
reset({"provider": {"llmhost": opencode.local_block(CFG), "llmhost-popos": remote("popos.local")[1]}}) reset({"provider": {"llmhost": opencode.local_block(CFG), "llmhost-mybox": remote("mybox.local")[1]}})
put_auth({"llmhost": {"type": "api", "key": "sk-A"}, "llmhost-popos": {"type": "api", "key": "sk-B"}}) put_auth({"llmhost": {"type": "api", "key": "sk-A"}, "llmhost-mybox": {"type": "api", "key": "sk-B"}})
st, path, removed, _ = opencode.remove(local=True) st, path, removed, _ = opencode.remove(local=True)
a = get_auth() a = get_auth()
check("local cred cleared", "llmhost" not in a, a) check("local cred cleared", "llmhost" not in a, a)
check("remote cred kept", a.get("llmhost-popos") == {"type": "api", "key": "sk-B"}, a) check("remote cred kept", a.get("llmhost-mybox") == {"type": "api", "key": "sk-B"}, a)
print("\n18. purge --keep-key keeps the API key through a purge") print("\n18. purge --keep-key keeps the API key through a purge")
from llmhost import cli from llmhost import cli
@ -276,9 +276,9 @@ print("\n21. sync() never wires opencode up on its own")
reset() reset()
check("no config file -> no-op", opencode.sync(CFG) is None) check("no config file -> no-op", opencode.sync(CFG) is None)
check("still no config file", not opencode.config_file().exists()) check("still no config file", not opencode.config_file().exists())
reset({"provider": {"popos-vllm": foreign}, "model": "popos-vllm/x"}) reset({"provider": {"mybox-vllm": foreign}, "model": "mybox-vllm/x"})
check("no local block -> no-op", opencode.sync(CFG) is None) check("no local block -> no-op", opencode.sync(CFG) is None)
check("foreign provider untouched", load()["provider"] == {"popos-vllm": foreign}) check("foreign provider untouched", load()["provider"] == {"mybox-vllm": foreign})
reset({"provider": {"mymac": opencode.local_block(CFG)}}) reset({"provider": {"mymac": opencode.local_block(CFG)}})
check("finds a renamed local block", opencode.sync(dict(CFG, active="qwen3-coder")) == "mymac") check("finds a renamed local block", opencode.sync(dict(CFG, active="qwen3-coder")) == "mymac")
@ -286,8 +286,8 @@ check.section("22. a default naming a specific model is migrated to the alias")
for old_model, expect in (("llmhost/qwen3.8-27b", "llmhost/default"), for old_model, expect in (("llmhost/qwen3.8-27b", "llmhost/default"),
("llmhost/ornith-1.5-9b", "llmhost/default"), ("llmhost/ornith-1.5-9b", "llmhost/default"),
("llmhost/default", "llmhost/default"), ("llmhost/default", "llmhost/default"),
("popos-vllm/qwen3.8-27b", "popos-vllm/qwen3.8-27b"), ("mybox-vllm/qwen3.8-27b", "mybox-vllm/qwen3.8-27b"),
("llmhost-popos/qwen3.8-27b", "llmhost-popos/qwen3.8-27b")): ("llmhost-mybox/qwen3.8-27b", "llmhost-mybox/qwen3.8-27b")):
reset({"provider": {"llmhost": opencode.local_block(CFG)}, "model": old_model}) reset({"provider": {"llmhost": opencode.local_block(CFG)}, "model": old_model})
opencode.configure(CFG) opencode.configure(CFG)
got = load().get("model") got = load().get("model")
@ -301,10 +301,10 @@ import argparse, io, contextlib
cli._service_check = lambda: CFG cli._service_check = lambda: CFG
buf = io.StringIO() buf = io.StringIO()
with contextlib.redirect_stdout(buf): with contextlib.redirect_stdout(buf):
cli.cmd_opencode(argparse.Namespace(host="popos.local", provider=None, json=True)) cli.cmd_opencode(argparse.Namespace(host="mybox.local", provider=None, json=True))
snip = json.loads(buf.getvalue()) snip = json.loads(buf.getvalue())
prov_id, block = next(iter(snip["provider"].items())) prov_id, block = next(iter(snip["provider"].items()))
check("provider named after the host", prov_id == "llmhost-popos", prov_id) check("provider named after the host", prov_id == "llmhost-mybox", prov_id)
check("model is <provider>/<an entry in the block>", check("model is <provider>/<an entry in the block>",
snip["model"].partition("/")[0] == prov_id and snip["model"].partition("/")[2] in block["models"], snip["model"].partition("/")[0] == prov_id and snip["model"].partition("/")[2] in block["models"],
(snip["model"], list(block["models"]))) (snip["model"], list(block["models"])))
@ -313,7 +313,7 @@ check.section("24. the block never offers a reasoning chooser of its own")
check("opencode's whole menu is switched off", check("opencode's whole menu is switched off",
opencode.effort_variants() == {l: {"disabled": True} for l in ("low", "medium", "high")}, opencode.effort_variants() == {l: {"disabled": True} for l in ("low", "medium", "high")},
opencode.effort_variants()) opencode.effort_variants())
q = opencode.provider_block(dict(CFG, active="qwen3.8-27b"), "popos.local", "k", "popos.local") q = opencode.provider_block(dict(CFG, active="qwen3.8-27b"), "mybox.local", "k", "mybox.local")
ent = q["models"]["default"] ent = q["models"]["default"]
check("a reasoning model is marked as one (so thinking blocks render)", ent.get("reasoning") is True, ent) check("a reasoning model is marked as one (so thinking blocks render)", ent.get("reasoning") is True, ent)
check("but every effort level is disabled", check("but every effort level is disabled",
@ -322,7 +322,7 @@ check("no variant carries a reasoningEffort to send",
not any("reasoningEffort" in v for v in ent["variants"].values()), ent["variants"]) not any("reasoningEffort" in v for v in ent["variants"].values()), ent["variants"])
check("the model levels from the catalog are not offered either", check("the model levels from the catalog are not offered either",
not ({"xhigh"} & set(ent["variants"])), ent["variants"]) not ({"xhigh"} & set(ent["variants"])), ent["variants"])
nr = opencode.provider_block(dict(CFG, active="qwen3-coder"), "popos.local", "k", "popos.local") nr = opencode.provider_block(dict(CFG, active="qwen3-coder"), "mybox.local", "k", "mybox.local")
check("a non-reasoning model gets no variants", "variants" not in nr["models"]["default"], nr["models"]["default"]) check("a non-reasoning model gets no variants", "variants" not in nr["models"]["default"], nr["models"]["default"])
check("one entry only, named for the alias, so the client can't pick a model either", check("one entry only, named for the alias, so the client can't pick a model either",
list(q["models"]) == [plan.SERVED_ALIAS], list(q["models"])) list(q["models"]) == [plan.SERVED_ALIAS], list(q["models"]))