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

@ -4487,6 +4487,31 @@ command = "idea-mcp"
);
}
#[test]
fn opencode_provider_config_json_zai_is_cache_independent() {
let custom = domain::profile::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", domain::ports::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
@ -4515,8 +4540,7 @@ command = "idea-mcp"
.unwrap();
use domain::permission::Posture;
let allowed =
opencode_config_json(&config, "/project", None, Some(&eff(Posture::Allow)));
let allowed = opencode_config_json(&config, "/project", None, Some(&eff(Posture::Allow)));
assert_eq!(allowed["permission"]["bash"], "allow");
assert_eq!(allowed["permission"]["edit"], "allow");