diff --git a/lib/opencode.sh b/lib/opencode.sh index 230e8e3..685b6f7 100644 --- a/lib/opencode.sh +++ b/lib/opencode.sh @@ -216,6 +216,14 @@ opencode_install_config() { # $3/$4 serve the run-only --model override: it writes a run-scoped config # of that launch's own while carrying user commands from — and never # touching — the live config. +# +# Schema reference: opencode v1.18.21 config.ts + core/src/v1/config/provider.ts +# (opencode.ai/docs/migrate-v1/). A model declares tool support with +# "tool_call": true — a model-level "tools" key is not in the schema and is +# silently dropped. The v1 keys below (provider npm/options, top-level tools, +# autoupdate, share) are normalized by v2; never emit v2-native keys here +# (providers, permissions, agents, commands): v1 would ignore them. +# # Note the "tools" block — it is a latency setting, not a preference. # # Every enabled tool ships its JSON schema in the prompt on EVERY request. @@ -289,7 +297,7 @@ opencode_write_config() { "models": { "${model}": { "name": "$(json_escape "$label")", - "tools": true, + "tool_call": true, "limit": { "context": ${ctx}, "output": ${out_tokens} } } } @@ -561,7 +569,7 @@ opencode_write_remote_config() { "models": { "$(json_escape "$model")": { "name": "$(json_escape "mini · ${model}")", - "tools": true, + "tool_call": true, "limit": { "context": ${ctx}, "output": ${out_tokens} } } } diff --git a/tests/opencode_config_test.sh b/tests/opencode_config_test.sh index cef02d0..00b66e7 100644 --- a/tests/opencode_config_test.sh +++ b/tests/opencode_config_test.sh @@ -451,5 +451,42 @@ assert_eq 'two writes: the temp file sits beside the destination' 'same dir' \ && printf 'same dir' || printf 'elsewhere')" assert_true 'two writes: the live config is still valid JSON' json_ok "$CFG" +# --- 9: schema contract — opencode v1 keys only ----------------------------- + +# opencode v1.18.21 (config.ts + core/src/v1/config/provider.ts) declares model +# tool support as "tool_call"; a model-level "tools" key is not in the schema and +# is silently dropped. The top-level "tools" block and the provider block are +# v1 syntax that v2 normalizes (opencode.ai/docs/migrate-v1/), and v2-native +# keys would be ignored by v1. Asserted on freshly generated output of both +# writers: the local config is regenerated here, the remote one is section 3's. + +run_case case_two_writes_two_temps # leaves a fresh local config in $CFG +assert_eq 'schema: regenerated local config' '0' "$RUN_RC" + +schema_checks() { #