vtcode_core/config/
constants.rs1pub mod prompts {
3 pub const DEFAULT_SYSTEM_PROMPT_PATH: &str = "prompts/system.md";
4 pub const CODER_SYSTEM_PROMPT_PATH: &str = "prompts/coder_system.md";
5}
6
7pub mod models {
9 pub mod google {
11 pub const DEFAULT_MODEL: &str = "gemini-2.5-flash-preview-05-20";
12 pub const SUPPORTED_MODELS: &[&str] = &[
13 "gemini-2.5-flash-preview-05-20",
14 "gemini-2.5-pro",
15 "gemini-2.5-flash",
16 "gemini-2.5-flash-lite",
17 ];
18
19 pub const GEMINI_2_5_FLASH_PREVIEW: &str = "gemini-2.5-flash-preview-05-20";
21 pub const GEMINI_2_5_PRO: &str = "gemini-2.5-pro";
22 pub const GEMINI_2_5_FLASH: &str = "gemini-2.5-flash";
23 pub const GEMINI_2_5_FLASH_LITE: &str = "gemini-2.5-flash-lite";
24 }
25
26 pub mod openai {
28 pub const DEFAULT_MODEL: &str = "gpt-5";
29 pub const SUPPORTED_MODELS: &[&str] = &[
30 "gpt-5",
31 "gpt-5-codex",
32 "gpt-5-mini",
33 "gpt-5-nano",
34 "codex-mini-latest",
35 "o4-mini",
36 "o4-mini-deep-research",
37 "o3",
38 "o1",
39 "o1-mini",
40 "o1-preview",
41 "o1-pro",
42 ];
43
44 pub const REASONING_MODELS: &[&str] = &[
46 O4_MINI,
47 O4_MINI_DEEP_RESEARCH,
48 O3,
49 O1,
50 O1_PRO,
51 O1_PREVIEW,
52 O1_MINI,
53 ];
54
55 pub const GPT_5: &str = "gpt-5";
57 pub const GPT_5_CODEX: &str = "gpt-5-codex";
58 pub const GPT_5_MINI: &str = "gpt-5-mini";
59 pub const GPT_5_NANO: &str = "gpt-5-nano";
60 pub const CODEX_MINI_LATEST: &str = "codex-mini-latest";
61 pub const CODEX_MINI: &str = "codex-mini";
62 pub const O4_MINI: &str = "o4-mini";
63 pub const O4_MINI_DEEP_RESEARCH: &str = "o4-mini-deep-research";
64 pub const O3: &str = "o3";
65 pub const O1: &str = "o1";
66 pub const O1_PRO: &str = "o1-pro";
67 pub const O1_PREVIEW: &str = "o1-preview";
68 pub const O1_MINI: &str = "o1-mini";
69 }
70
71 pub mod openrouter {
73 pub const DEFAULT_MODEL: &str = "x-ai/grok-code-fast-1";
74 pub const SUPPORTED_MODELS: &[&str] = &[
75 "x-ai/grok-code-fast-1",
76 "x-ai/grok-4-fast:free",
77 "qwen/qwen3-coder",
78 "deepseek/deepseek-chat-v3.1",
79 "openai/gpt-5",
80 "openai/gpt-5-codex",
81 "anthropic/claude-sonnet-4.5",
82 "anthropic/claude-sonnet-4",
83 ];
84
85 pub const REASONING_MODELS: &[&str] = &[
87 X_AI_GROK_4_FAST_FREE,
88 OPENAI_GPT_5,
89 OPENAI_GPT_5_CODEX,
90 ANTHROPIC_CLAUDE_SONNET_4_5,
91 ANTHROPIC_CLAUDE_SONNET_4,
92 ];
93
94 pub const TOOL_UNAVAILABLE_MODELS: &[&str] = &[OPENAI_GPT_OSS_20B_FREE];
96
97 pub const X_AI_GROK_CODE_FAST_1: &str = "x-ai/grok-code-fast-1";
98 pub const X_AI_GROK_4_FAST_FREE: &str = "x-ai/grok-4-fast:free";
99 pub const QWEN3_CODER: &str = "qwen/qwen3-coder";
100 pub const DEEPSEEK_DEEPSEEK_CHAT_V3_1: &str = "deepseek/deepseek-chat-v3.1";
101 pub const OPENAI_GPT_5: &str = "openai/gpt-5";
102 pub const OPENAI_GPT_5_CODEX: &str = "openai/gpt-5-codex";
103 pub const ANTHROPIC_CLAUDE_SONNET_4_5: &str = "anthropic/claude-sonnet-4.5";
104 pub const ANTHROPIC_CLAUDE_SONNET_4: &str = "anthropic/claude-sonnet-4";
105 pub const OPENAI_GPT_OSS_20B_FREE: &str = "openai/gpt-oss-20b:free";
106 }
107
108 pub mod deepseek {
110 pub const DEFAULT_MODEL: &str = "deepseek-chat";
111 pub const SUPPORTED_MODELS: &[&str] = &["deepseek-chat", "deepseek-reasoner"];
112
113 pub const DEEPSEEK_CHAT: &str = "deepseek-chat";
114 pub const DEEPSEEK_REASONER: &str = "deepseek-reasoner";
115 }
116
117 pub mod anthropic {
119 pub const DEFAULT_MODEL: &str = "claude-sonnet-4-5";
121 pub const SUPPORTED_MODELS: &[&str] = &[
122 "claude-opus-4-1-20250805", "claude-sonnet-4-5", "claude-sonnet-4-20250514", ];
126
127 pub const CLAUDE_OPUS_4_1_20250805: &str = "claude-opus-4-1-20250805";
129 pub const CLAUDE_SONNET_4_5: &str = "claude-sonnet-4-5";
130 pub const CLAUDE_SONNET_4_20250514: &str = "claude-sonnet-4-20250514";
131 }
132
133 pub mod xai {
135 pub const DEFAULT_MODEL: &str = "grok-2-latest";
136 pub const SUPPORTED_MODELS: &[&str] = &[
137 "grok-2-latest",
138 "grok-2",
139 "grok-2-mini",
140 "grok-2-reasoning",
141 "grok-2-vision",
142 ];
143
144 pub const GROK_2_LATEST: &str = "grok-2-latest";
145 pub const GROK_2: &str = "grok-2";
146 pub const GROK_2_MINI: &str = "grok-2-mini";
147 pub const GROK_2_REASONING: &str = "grok-2-reasoning";
148 pub const GROK_2_VISION: &str = "grok-2-vision";
149 }
150
151 pub const GEMINI_2_5_FLASH_PREVIEW: &str = google::GEMINI_2_5_FLASH_PREVIEW;
153 pub const GEMINI_2_5_FLASH: &str = google::GEMINI_2_5_FLASH;
154 pub const GEMINI_2_5_PRO: &str = google::GEMINI_2_5_PRO;
155 pub const GEMINI_2_5_FLASH_LITE: &str = google::GEMINI_2_5_FLASH_LITE;
156 pub const GPT_5: &str = openai::GPT_5;
157 pub const GPT_5_CODEX: &str = openai::GPT_5_CODEX;
158 pub const GPT_5_MINI: &str = openai::GPT_5_MINI;
159 pub const GPT_5_NANO: &str = openai::GPT_5_NANO;
160 pub const CODEX_MINI: &str = openai::CODEX_MINI;
161 pub const CODEX_MINI_LATEST: &str = openai::CODEX_MINI_LATEST;
162 pub const CLAUDE_OPUS_4_1_20250805: &str = anthropic::CLAUDE_OPUS_4_1_20250805;
163 pub const CLAUDE_SONNET_4_5: &str = anthropic::CLAUDE_SONNET_4_5;
164 pub const CLAUDE_SONNET_4_20250514: &str = anthropic::CLAUDE_SONNET_4_20250514;
165 pub const OPENROUTER_X_AI_GROK_CODE_FAST_1: &str = openrouter::X_AI_GROK_CODE_FAST_1;
166 pub const OPENROUTER_X_AI_GROK_4_FAST_FREE: &str = openrouter::X_AI_GROK_4_FAST_FREE;
167 pub const OPENROUTER_QWEN3_CODER: &str = openrouter::QWEN3_CODER;
168 pub const OPENROUTER_DEEPSEEK_CHAT_V3_1: &str = openrouter::DEEPSEEK_DEEPSEEK_CHAT_V3_1;
169 pub const OPENROUTER_OPENAI_GPT_5: &str = openrouter::OPENAI_GPT_5;
170 pub const OPENROUTER_OPENAI_GPT_5_CODEX: &str = openrouter::OPENAI_GPT_5_CODEX;
171 pub const OPENROUTER_ANTHROPIC_CLAUDE_SONNET_4_5: &str =
172 openrouter::ANTHROPIC_CLAUDE_SONNET_4_5;
173 pub const OPENROUTER_ANTHROPIC_CLAUDE_SONNET_4: &str = openrouter::ANTHROPIC_CLAUDE_SONNET_4;
174 pub const XAI_GROK_2_LATEST: &str = xai::GROK_2_LATEST;
175 pub const XAI_GROK_2: &str = xai::GROK_2;
176 pub const XAI_GROK_2_MINI: &str = xai::GROK_2_MINI;
177 pub const XAI_GROK_2_REASONING: &str = xai::GROK_2_REASONING;
178 pub const XAI_GROK_2_VISION: &str = xai::GROK_2_VISION;
179 pub const DEEPSEEK_CHAT: &str = deepseek::DEEPSEEK_CHAT;
180 pub const DEEPSEEK_REASONER: &str = deepseek::DEEPSEEK_REASONER;
181}
182
183pub mod prompt_cache {
185 pub const DEFAULT_ENABLED: bool = true;
186 pub const DEFAULT_CACHE_DIR: &str = ".vtcode/cache/prompts";
187 pub const DEFAULT_MAX_ENTRIES: usize = 1_000;
188 pub const DEFAULT_MAX_AGE_DAYS: u64 = 30;
189 pub const DEFAULT_AUTO_CLEANUP: bool = true;
190 pub const DEFAULT_MIN_QUALITY_THRESHOLD: f64 = 0.7;
191
192 pub const OPENAI_MIN_PREFIX_TOKENS: u32 = 1_024;
193 pub const OPENAI_IDLE_EXPIRATION_SECONDS: u64 = 60 * 60; pub const ANTHROPIC_DEFAULT_TTL_SECONDS: u64 = 5 * 60; pub const ANTHROPIC_EXTENDED_TTL_SECONDS: u64 = 60 * 60; pub const ANTHROPIC_MAX_BREAKPOINTS: u8 = 4;
198
199 pub const GEMINI_MIN_PREFIX_TOKENS: u32 = 1_024;
200 pub const GEMINI_EXPLICIT_DEFAULT_TTL_SECONDS: u64 = 60 * 60; pub const OPENROUTER_CACHE_DISCOUNT_ENABLED: bool = true;
203 pub const XAI_CACHE_ENABLED: bool = true;
204 pub const DEEPSEEK_CACHE_ENABLED: bool = true;
205}
206
207pub mod model_helpers {
209 use super::models;
210
211 pub fn supported_for(provider: &str) -> Option<&'static [&'static str]> {
213 match provider {
214 "google" | "gemini" => Some(models::google::SUPPORTED_MODELS),
215 "openai" => Some(models::openai::SUPPORTED_MODELS),
216 "anthropic" => Some(models::anthropic::SUPPORTED_MODELS),
217 "deepseek" => Some(models::deepseek::SUPPORTED_MODELS),
218 "openrouter" => Some(models::openrouter::SUPPORTED_MODELS),
219 "xai" => Some(models::xai::SUPPORTED_MODELS),
220 _ => None,
221 }
222 }
223
224 pub fn default_for(provider: &str) -> Option<&'static str> {
226 match provider {
227 "google" | "gemini" => Some(models::google::DEFAULT_MODEL),
228 "openai" => Some(models::openai::DEFAULT_MODEL),
229 "anthropic" => Some(models::anthropic::DEFAULT_MODEL),
230 "deepseek" => Some(models::deepseek::DEFAULT_MODEL),
231 "openrouter" => Some(models::openrouter::DEFAULT_MODEL),
232 "xai" => Some(models::xai::DEFAULT_MODEL),
233 _ => None,
234 }
235 }
236
237 pub fn is_valid(provider: &str, model: &str) -> bool {
239 supported_for(provider)
240 .map(|list| list.iter().any(|m| *m == model))
241 .unwrap_or(false)
242 }
243}
244
245pub mod env {
247 pub const UPDATE_CHECK: &str = "VT_UPDATE_CHECK";
249
250 pub mod acp {
252 #[derive(Debug, Clone, Copy)]
253 pub enum AgentClientProtocolEnvKey {
254 Enabled,
255 ZedEnabled,
256 ZedToolsReadFileEnabled,
257 }
258
259 impl AgentClientProtocolEnvKey {
260 pub fn as_str(self) -> &'static str {
261 match self {
262 Self::Enabled => "VT_ACP_ENABLED",
263 Self::ZedEnabled => "VT_ACP_ZED_ENABLED",
264 Self::ZedToolsReadFileEnabled => "VT_ACP_ZED_TOOLS_READ_FILE_ENABLED",
265 }
266 }
267 }
268 }
269}
270
271pub mod defaults {
273 use super::{models, ui};
274
275 pub const DEFAULT_MODEL: &str = models::google::GEMINI_2_5_FLASH_PREVIEW;
276 pub const DEFAULT_CLI_MODEL: &str = models::google::GEMINI_2_5_FLASH_PREVIEW;
277 pub const DEFAULT_PROVIDER: &str = "gemini";
278 pub const DEFAULT_API_KEY_ENV: &str = "GEMINI_API_KEY";
279 pub const DEFAULT_THEME: &str = "ciapre-dark";
280 pub const DEFAULT_MAX_TOOL_LOOPS: usize = 100;
281 pub const ANTHROPIC_DEFAULT_MAX_TOKENS: u32 = 4_096;
282 pub const DEFAULT_PTY_STDOUT_TAIL_LINES: usize = 20;
283 pub const DEFAULT_TOOL_OUTPUT_MODE: &str = ui::TOOL_OUTPUT_MODE_COMPACT;
284}
285
286pub mod ui {
287 pub const TOOL_OUTPUT_MODE_COMPACT: &str = "compact";
288 pub const TOOL_OUTPUT_MODE_FULL: &str = "full";
289 pub const DEFAULT_INLINE_VIEWPORT_ROWS: u16 = 16;
290 pub const INLINE_SHOW_TIMELINE_PANE: bool = false;
291 pub const SLASH_SUGGESTION_LIMIT: usize = 6;
292 pub const INLINE_HEADER_HEIGHT: u16 = 4;
293 pub const INLINE_INPUT_HEIGHT: u16 = 3;
294 pub const INLINE_NAVIGATION_PERCENT: u16 = 32;
295 pub const INLINE_NAVIGATION_MIN_WIDTH: u16 = 24;
296 pub const INLINE_CONTENT_MIN_WIDTH: u16 = 48;
297 pub const INLINE_STACKED_NAVIGATION_PERCENT: u16 = INLINE_NAVIGATION_PERCENT;
298 pub const INLINE_SCROLLBAR_EDGE_PADDING: u16 = 1;
299 pub const INLINE_TRANSCRIPT_BOTTOM_PADDING: u16 = 2;
300 pub const INLINE_PREVIEW_MAX_CHARS: usize = 56;
301 pub const INLINE_PREVIEW_ELLIPSIS: &str = "…";
302 pub const INLINE_AGENT_MESSAGE_LEFT_PADDING: &str = " ";
303 pub const INLINE_AGENT_QUOTE_PREFIX: &str = "";
304 pub const INLINE_USER_MESSAGE_DIVIDER_SYMBOL: &str = "─";
305 pub const HEADER_VERSION_PROMPT: &str = "> ";
306 pub const HEADER_VERSION_PREFIX: &str = "VT Code";
307 pub const HEADER_VERSION_LEFT_DELIMITER: &str = "(";
308 pub const HEADER_VERSION_RIGHT_DELIMITER: &str = ")";
309 pub const HEADER_MODE_INLINE: &str = "Inline session";
310 pub const HEADER_MODE_ALTERNATE: &str = "Alternate session";
311 pub const HEADER_MODE_AUTO: &str = "Auto session";
312 pub const HEADER_MODE_FULL_AUTO_SUFFIX: &str = " (full auto)";
313 pub const HEADER_MODE_PRIMARY_SEPARATOR: &str = " | ";
314 pub const HEADER_MODE_SECONDARY_SEPARATOR: &str = " | ";
315 pub const HEADER_PROVIDER_PREFIX: &str = "Provider: ";
316 pub const HEADER_MODEL_PREFIX: &str = "Model: ";
317 pub const HEADER_REASONING_PREFIX: &str = "Reasoning: ";
318 pub const HEADER_TRUST_PREFIX: &str = "Trust: ";
319 pub const HEADER_TOOLS_PREFIX: &str = "Tools: ";
320 pub const HEADER_LANGUAGES_PREFIX: &str = "Languages: ";
321 pub const HEADER_MCP_PREFIX: &str = "MCP: ";
322 pub const HEADER_UNKNOWN_PLACEHOLDER: &str = "unavailable";
323 pub const HEADER_STATUS_LABEL: &str = "Status";
324 pub const HEADER_STATUS_ACTIVE: &str = "Active";
325 pub const HEADER_STATUS_PAUSED: &str = "Paused";
326 pub const HEADER_MESSAGES_LABEL: &str = "Messages";
327 pub const HEADER_INPUT_LABEL: &str = "Input";
328 pub const HEADER_INPUT_ENABLED: &str = "Enabled";
329 pub const HEADER_INPUT_DISABLED: &str = "Disabled";
330 pub const HEADER_SHORTCUT_HINT: &str =
331 "Shortcuts: Ctrl+Enter to submit • Esc to cancel • Ctrl+C to interrupt";
332 pub const HEADER_META_SEPARATOR: &str = " ";
333 pub const NAVIGATION_BLOCK_TITLE: &str = "Timeline";
334 pub const NAVIGATION_EMPTY_LABEL: &str = "Waiting for activity";
335 pub const NAVIGATION_INDEX_PREFIX: &str = "#";
336 pub const NAVIGATION_LABEL_AGENT: &str = "Agent";
337 pub const NAVIGATION_LABEL_ERROR: &str = "Error";
338 pub const NAVIGATION_LABEL_INFO: &str = "Info";
339 pub const NAVIGATION_LABEL_POLICY: &str = "Policy";
340 pub const NAVIGATION_LABEL_TOOL: &str = "Tool";
341 pub const NAVIGATION_LABEL_USER: &str = "User";
342 pub const NAVIGATION_LABEL_PTY: &str = "PTY";
343 pub const SUGGESTION_BLOCK_TITLE: &str = "Slash Commands";
344}
345
346pub mod reasoning {
348 pub const LOW: &str = "low";
349 pub const MEDIUM: &str = "medium";
350 pub const HIGH: &str = "high";
351 pub const ALLOWED_LEVELS: &[&str] = &[LOW, MEDIUM, HIGH];
352}
353
354pub mod message_roles {
356 pub const SYSTEM: &str = "system";
357 pub const USER: &str = "user";
358 pub const ASSISTANT: &str = "assistant";
359 pub const TOOL: &str = "tool";
360}
361
362pub mod urls {
364 pub const GEMINI_API_BASE: &str = "https://generativelanguage.googleapis.com/v1beta";
365 pub const OPENAI_API_BASE: &str = "https://api.openai.com/v1";
366 pub const ANTHROPIC_API_BASE: &str = "https://api.anthropic.com/v1";
367 pub const ANTHROPIC_API_VERSION: &str = "2023-06-01";
368 pub const OPENROUTER_API_BASE: &str = "https://openrouter.ai/api/v1";
369 pub const XAI_API_BASE: &str = "https://api.x.ai/v1";
370 pub const DEEPSEEK_API_BASE: &str = "https://api.deepseek.com/v1";
371}
372
373pub mod tools {
375 pub const GREP_SEARCH: &str = "grep_search";
376 pub const LIST_FILES: &str = "list_files";
377 pub const RUN_TERMINAL_CMD: &str = "run_terminal_cmd";
378 pub const READ_FILE: &str = "read_file";
379 pub const WRITE_FILE: &str = "write_file";
380 pub const EDIT_FILE: &str = "edit_file";
381 pub const DELETE_FILE: &str = "delete_file";
382 pub const CREATE_FILE: &str = "create_file";
383 pub const AST_GREP_SEARCH: &str = "ast_grep_search";
384 pub const SIMPLE_SEARCH: &str = "simple_search";
385 pub const BASH: &str = "bash";
386 pub const APPLY_PATCH: &str = "apply_patch";
387 pub const SRGN: &str = "srgn";
388 pub const CURL: &str = "curl";
389 pub const UPDATE_PLAN: &str = "update_plan";
390
391 pub const FILE_METADATA: &str = "file_metadata";
393 pub const PROJECT_OVERVIEW: &str = "project_overview";
394 pub const TREE_SITTER_ANALYZE: &str = "tree_sitter_analyze";
395
396 pub const WILDCARD_ALL: &str = "*";
398}
399
400pub mod project_doc {
401 pub const DEFAULT_MAX_BYTES: usize = 16 * 1024;
402}
403
404pub mod context {
406 pub const CHAR_PER_TOKEN_APPROX: usize = 3;
408
409 pub const DEFAULT_MAX_TOKENS: usize = 90_000;
411
412 pub const DEFAULT_TRIM_TO_PERCENT: u8 = 80;
414
415 pub const MIN_TRIM_RATIO_PERCENT: u8 = 60;
417
418 pub const MAX_TRIM_RATIO_PERCENT: u8 = 90;
420
421 pub const DEFAULT_PRESERVE_RECENT_TURNS: usize = 12;
423
424 pub const MIN_PRESERVE_RECENT_TURNS: usize = 6;
426
427 pub const AGGRESSIVE_PRESERVE_RECENT_TURNS: usize = 8;
429
430 pub const CONTEXT_ERROR_RETRY_LIMIT: usize = 2;
432}
433
434pub mod chunking {
436 pub const MAX_LINES_THRESHOLD: usize = 2_000;
438
439 pub const CHUNK_START_LINES: usize = 800;
441
442 pub const CHUNK_END_LINES: usize = 800;
444
445 pub const MAX_TERMINAL_OUTPUT_LINES: usize = 3_000;
447
448 pub const TERMINAL_OUTPUT_START_LINES: usize = 1_000;
450
451 pub const TERMINAL_OUTPUT_END_LINES: usize = 1_000;
453
454 pub const MAX_WRITE_CONTENT_SIZE: usize = 500_000; pub const WRITE_CHUNK_SIZE: usize = 50_000; }