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!(
61 scope,
62 SnapshotScope::Env | SnapshotScope::Common | SnapshotScope::All
63 ) {
64 let mut env = HashMap::new();
65 env.insert(
66 "ANTHROPIC_BASE_URL".to_string(),
67 "https://api.deepseek.com/anthropic".to_string(),
68 );
69 env.insert("ANTHROPIC_AUTH_TOKEN".to_string(), api_key.to_string());
70 env.insert("API_TIMEOUT_MS".to_string(), "600000".to_string());
71 env.insert("ANTHROPIC_MODEL".to_string(), "deepseek-chat".to_string());
72 env.insert(
73 "ANTHROPIC_SMALL_FAST_MODEL".to_string(),
74 "deepseek-chat".to_string(),
75 );
76 env.insert(
77 "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC".to_string(),
78 "1".to_string(),
79 );
80 settings.env = Some(env);
81 }
82
83 settings
84 }
85}
86
87pub fn create_deepseek_template(api_key: &str, scope: &SnapshotScope) -> ClaudeSettings {
89 let template = DeepSeekTemplate;
90 template.create_settings(api_key, scope)
91}