fix(opencode): make models.dev providers cache-independent

This commit is contained in:
2026-07-25 14:26:15 +02:00
parent 69e5878679
commit ad491e765f
5 changed files with 246 additions and 31 deletions

View File

@ -611,18 +611,14 @@ fn parent_dir(base: &ProjectPath, rel: &str) -> String {
#[cfg(test)]
mod opencode_provider_config_json_tests {
use domain::profile::CustomProviderConfig;
use domain::ports::SecretRef;
use domain::profile::CustomProviderConfig;
use super::*;
fn known_provider_config() -> OpenCodeProviderConfig {
OpenCodeProviderConfig::new(
"anthropic",
"claude-sonnet-5",
SecretRef::new("secret-ref"),
)
.unwrap()
OpenCodeProviderConfig::new("anthropic", "claude-sonnet-5", SecretRef::new("secret-ref"))
.unwrap()
}
fn custom_provider_config() -> OpenCodeProviderConfig {
@ -674,6 +670,30 @@ mod opencode_provider_config_json_tests {
);
}
#[test]
fn zai_provider_is_rendered_as_a_cache_independent_provider() {
let custom = CustomProviderConfig::new(
"@ai-sdk/openai-compatible",
"https://api.z.ai/api/paas/v4",
Some("GLM-5.1".to_owned()),
)
.unwrap();
let config = OpenCodeProviderConfig::new("zai", "glm-5.1", SecretRef::new("ref"))
.unwrap()
.with_custom(custom);
let body = opencode_provider_config_json(&config, "secret", "/project", None, None);
assert_eq!(body["model"], "zai/glm-5.1");
assert_eq!(body["provider"]["zai"]["npm"], "@ai-sdk/openai-compatible");
assert_eq!(
body["provider"]["zai"]["options"]["baseURL"],
"https://api.z.ai/api/paas/v4"
);
assert_eq!(
body["provider"]["zai"]["models"]["glm-5.1"]["name"],
"GLM-5.1"
);
}
// ---- permission projection wiring (ticket #94) -----------------------
/// Builds an [`EffectivePermissions`] with the given fallback posture (only