claude_code_switcher/templates/
seed_code.rs1use crate::{
4 settings::{ClaudeSettings, Permissions},
5 snapshots::SnapshotScope,
6 templates::Template,
7};
8use std::collections::HashMap;
9
10#[derive(Debug, Clone)]
12pub struct SeedCodeTemplate;
13
14impl Template for SeedCodeTemplate {
15 fn template_type(&self) -> crate::templates::TemplateType {
16 crate::templates::TemplateType::SeedCode
17 }
18
19 fn env_var_name(&self) -> &'static str {
20 "ARK_API_KEY"
21 }
22
23 fn display_name(&self) -> &'static str {
24 "Seed Code"
25 }
26
27 fn description(&self) -> &'static str {
28 "Volcengine Seed Code - AI coding assistant"
29 }
30
31 fn api_key_url(&self) -> Option<&'static str> {
32 Some("https://console.volcengine.com/ark/region:ark+cn-beijing/apikey")
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("doubao-seed-code-preview-latest".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("ANTHROPIC_API_KEY".to_string(), api_key.to_string());
63 env.insert("ANTHROPIC_AUTH_TOKEN".to_string(), api_key.to_string());
64 env.insert(
65 "ANTHROPIC_BASE_URL".to_string(),
66 "https://ark.cn-beijing.volces.com/api/coding".to_string(),
67 );
68 env.insert(
69 "ANTHROPIC_MODEL".to_string(),
70 "doubao-seed-code-preview-latest".to_string(),
71 );
72 env.insert(
73 "ANTHROPIC_SMALL_FAST_MODEL".to_string(),
74 "doubao-seed-code-preview-latest".to_string(),
75 );
76 env.insert("API_TIMEOUT_MS".to_string(), "3000000".to_string());
77 env.insert(
78 "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC".to_string(),
79 "1".to_string(),
80 );
81 settings.env = Some(env);
82 }
83
84 settings
85 }
86}
87
88pub fn create_seed_code_template(api_key: &str, scope: &SnapshotScope) -> ClaudeSettings {
90 let template = SeedCodeTemplate;
91 template.create_settings(api_key, scope)
92}