opencode 2: list opencode's hosted provider and its free models again (decision 1595)

From v1.56.0 the generated OpenCode 2 config denied opencode's own provider
("policies", provider.use on "opencode"), and a fresh install copied that deny
into the user's global config: the Agent tab's picker lost the free models
1.x lists beside the box's lanes, a choice nobody had made. The generated
config denies no provider now; the default and small model stay the box's
lane. An update takes the exact deny of v1.56.0 to v1.59.0 out of the global
config (oc-merge-limits.py --remove-provider-deny, after a backup); a policy
of the user's own stays, and disabled_providers is never touched.

Tests: test_oc_provider_deny.py (the tool, and install.sh's own lines on a
v1.59.0 copy), the generated config on both majors, the uninstall purge on
copies with and without the old deny. Red on the old code, green after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hasan BasbunarandClaude Opus 5.5 committed 2026-11-25 17:55:07 +01:00
1 parent 56e6ce5fc3
commit ade00a01bb
5 files changed
+322 -27

No files matched your search

+24 -18
View File
@@ -89,26 +89,32 @@ class UninstallLeavesOpencodeStartable(unittest.TestCase):
spec = importlib.util.spec_from_file_location("ocm", REPO / "oc-merge-limits.py")
ocm = importlib.util.module_from_spec(spec)
spec.loader.exec_module(ocm)
# the values the purge counts as ours are the ones install.sh writes in the generated v2 config
# the values the purge counts as ours are the ones install.sh writes in the generated v2 config,
# and the deny on opencode's hosted provider that v1.56.0 to v1.59.0 wrote there too: a copy made
# then still holds it (decision 1595, 2026-11-25: no release writes it any more)
install = (REPO / "install.sh").read_text()
for line in ('doc["policies"] = [{"action": "provider.use", "resource": "opencode", "effect": "deny"}]',
'doc["share"] = "disabled"', 'doc["websearch"] = False', 'doc["update"] = "disable"'):
for line in ('doc["share"] = "disabled"', 'doc["websearch"] = False', 'doc["update"] = "disable"'):
self.assertIn(line, install, "install.sh and the purge must agree on the v2 keys")
for websearch, gone in ((False, True), (True, False)):
with self.subTest(gone=gone):
mine = lambda k: json.dumps({
"$schema": "https://opencode.ai/config.json", "provider": {"qwen38": box(k)},
"compaction": {"keep": {"tokens": 135000}, "background": True},
"model": "qwen38/qwen3.8-27b", "small_model": "qwen38/qwen3.8-27b",
"permission": RULES, "permissions": ocm.deny_permissions_v2(),
"policies": [{"action": "provider.use", "resource": "opencode", "effect": "deny"}],
"share": "disabled", "websearch": websearch, "update": "disable"}, indent=2)
out, home, cfg, oc = self.run_it(mine, purge=1)
self.assertEqual(oc.exists(), not gone, out)
if gone:
self.assertIn("held only this box's providers (qwen38): moved to", out)
else:
self.assertIs(json.loads(oc.read_text())["websearch"], True)
self.assertNotIn('doc["policies"]', install)
self.assertEqual(ocm.PROVIDER_DENY_V156,
[{"action": "provider.use", "resource": "opencode", "effect": "deny"}])
for policies in (ocm.PROVIDER_DENY_V156, None):
for websearch, gone in ((False, True), (True, False)):
with self.subTest(policies=policies is not None, gone=gone):
doc = {"$schema": "https://opencode.ai/config.json",
"compaction": {"keep": {"tokens": 135000}, "background": True},
"model": "qwen38/qwen3.8-27b", "small_model": "qwen38/qwen3.8-27b",
"permission": RULES, "permissions": ocm.deny_permissions_v2(),
"share": "disabled", "websearch": websearch, "update": "disable"}
if policies is not None:
doc["policies"] = policies
mine = lambda k: json.dumps({**doc, "provider": {"qwen38": box(k)}}, indent=2)
out, home, cfg, oc = self.run_it(mine, purge=1)
self.assertEqual(oc.exists(), not gone, out)
if gone:
self.assertIn("held only this box's providers (qwen38): moved to", out)
else:
self.assertIs(json.loads(oc.read_text())["websearch"], True)
def test_the_copy_of_a_release_before_v157_goes_with_the_key_too(self):
# up to v1.56.0 the copy held the shell rules alone ("bash*" in 1.x, three shell rules in 2.x): a box