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