claude_code_switcher/templates/
deepseek.rs1use crate::{
4 settings::{ClaudeSettings, Permissions},
5 snapshots::SnapshotScope,
6 templates::Template,
7};
8use std::collections::HashMap;
9
10#[derive(Debug, Clone)]
12pub struct DeepSeekTemplate;
13
14impl Template for DeepSeekTemplate {
15 fn template_type(&self) -> crate::templates::TemplateType {
16 crate::templates::TemplateType::DeepSeek
17 }
18
19 fn env_var_name(&self) -> &'static str {
20 "DEEPSEEK_API_KEY"
21 }
22
23 fn display_name(&self) -> &'static str {
24 "DeepSeek"
25 }
26
27 fn description(&self) -> &'static str {
28 "DeepSeek Chat API - High-performance conversational AI"
29 }
30
31 fn api_key_url(&self) -> Option<&'static str> {
32 Some("https://platform.deepseek.com/api_keys")
33 }
34
35 fn create_settings(&self, api_key: &str, scope: &SnapshotScope) -> ClaudeSettings {
36 let mut settings = ClaudeSettings::new();
37
38 if matches!(scope, SnapshotScope::Common | SnapshotScope::All) {
39 settings.model = Some("deepseek-chat".to_string());
40
41 settings.permissions = Some(Permissions {
42 allow: Some(vec![
43 "Bash".to_string(),
44 "Read".to_string(),
45 "Write".to_string(),
46 "Edit".to_string(),
47 "MultiEdit".to_string(),
48 "Glob".to_string(),
49 "Grep".to_string(),
50 "WebFetch".to_string(),
51 ]),
52 ask: None,
53 deny: Some(vec!["WebSearch".to_string()]),
54 additional_directories: None,
55 default_mode: None,
56 disable_bypass_permissions_mode: None,
57 });
58 }
59
60 if matches!(scope, SnapshotScope::Env | SnapshotScope::All) {
61 let mut env = HashMap::new();
62 env.insert(
63 "ANTHROPIC_BASE_URL".to_string(),
64 "https://api.deepseek.com/anthropic".to_string(),
65 );
66 env.insert("ANTHROPIC_AUTH_TOKEN".to_string(), api_key.to_string());
67 env.insert("API_TIMEOUT_MS".to_string(), "600000".to_string());
68 env.insert("ANTHROPIC_MODEL".to_string(), "deepseek-chat".to_string());
69 env.insert(
70 "ANTHROPIC_SMALL_FAST_MODEL".to_string(),
71 "deepseek-chat".to_string(),
72 );
73 env.insert(
74 "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC".to_string(),
75 "1".to_string(),
76 );
77 settings.env = Some(env);
78 }
79
80 settings
81 }
82}
83
84pub fn create_deepseek_template(api_key: &str, scope: &SnapshotScope) -> ClaudeSettings {
86 let template = DeepSeekTemplate;
87 template.create_settings(api_key, scope)
88}