claude_code_switcher/templates/
seed_code.rs

1//! Seed Code (Volcengine) AI provider template implementation
2
3use crate::{
4    settings::{ClaudeSettings, Permissions},
5    snapshots::SnapshotScope,
6    templates::Template,
7};
8use std::collections::HashMap;
9
10/// Seed Code AI provider template
11#[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!(
61            scope,
62            SnapshotScope::Env | SnapshotScope::Common | SnapshotScope::All
63        ) {
64            let mut env = HashMap::new();
65            env.insert("ANTHROPIC_API_KEY".to_string(), api_key.to_string());
66            env.insert("ANTHROPIC_AUTH_TOKEN".to_string(), api_key.to_string());
67            env.insert(
68                "ANTHROPIC_BASE_URL".to_string(),
69                "https://ark.cn-beijing.volces.com/api/coding".to_string(),
70            );
71            env.insert(
72                "ANTHROPIC_MODEL".to_string(),
73                "doubao-seed-code-preview-latest".to_string(),
74            );
75            env.insert(
76                "ANTHROPIC_SMALL_FAST_MODEL".to_string(),
77                "doubao-seed-code-preview-latest".to_string(),
78            );
79            env.insert("API_TIMEOUT_MS".to_string(), "3000000".to_string());
80            env.insert(
81                "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC".to_string(),
82                "1".to_string(),
83            );
84            settings.env = Some(env);
85        }
86
87        settings
88    }
89}
90
91/// Create Seed Code template settings (legacy compatibility function)
92pub fn create_seed_code_template(api_key: &str, scope: &SnapshotScope) -> ClaudeSettings {
93    let template = SeedCodeTemplate;
94    template.create_settings(api_key, scope)
95}