Skip to main content

vtcode_config/core/agent/
vibe_coding.rs

1//! Vibe-coding (lazy/vague request) configuration.
2
3use serde::{Deserialize, Serialize};
4
5/// Vibe coding configuration for lazy/vague request support
6///
7/// Enables intelligent context gathering and entity resolution to support
8/// casual, imprecise requests like "make it blue" or "decrease by half".
9#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
10#[derive(Debug, Clone, Deserialize, Serialize)]
11pub struct AgentVibeCodingConfig {
12    /// Enable vibe coding support
13    #[serde(default = "default_vibe_coding_enabled")]
14    pub enabled: bool,
15
16    /// Minimum prompt length for refinement (default: 5 chars)
17    #[serde(default = "default_vibe_min_prompt_length")]
18    pub min_prompt_length: usize,
19
20    /// Minimum prompt words for refinement (default: 2 words)
21    #[serde(default = "default_vibe_min_prompt_words")]
22    pub min_prompt_words: usize,
23
24    /// Enable fuzzy entity resolution
25    #[serde(default = "default_vibe_entity_resolution")]
26    pub enable_entity_resolution: bool,
27
28    /// Entity index cache file path (relative to workspace)
29    #[serde(default = "default_vibe_entity_cache")]
30    pub entity_index_cache: String,
31
32    /// Maximum entity matches to return (default: 5)
33    #[serde(default = "default_vibe_max_entity_matches")]
34    max_entity_matches: usize,
35
36    /// Track workspace state (file activity, value changes)
37    #[serde(default = "default_vibe_track_workspace")]
38    pub track_workspace_state: bool,
39
40    /// Maximum recent files to track (default: 20)
41    #[serde(default = "default_vibe_max_recent_files")]
42    max_recent_files: usize,
43
44    /// Track value history for inference
45    #[serde(default = "default_vibe_track_values")]
46    track_value_history: bool,
47
48    /// Enable conversation memory for pronoun resolution
49    #[serde(default = "default_vibe_conversation_memory")]
50    pub enable_conversation_memory: bool,
51
52    /// Maximum conversation turns to remember (default: 50)
53    #[serde(default = "default_vibe_max_memory_turns")]
54    max_memory_turns: usize,
55
56    /// Enable pronoun resolution (it, that, this)
57    #[serde(default = "default_vibe_pronoun_resolution")]
58    enable_pronoun_resolution: bool,
59
60    /// Enable proactive context gathering
61    #[serde(default = "default_vibe_proactive_context")]
62    enable_proactive_context: bool,
63
64    /// Maximum files to gather for context (default: 3)
65    #[serde(default = "default_vibe_max_context_files")]
66    max_context_files: usize,
67
68    /// Maximum code snippets per file (default: 20 lines)
69    #[serde(default = "default_vibe_max_snippets_per_file")]
70    max_context_snippets_per_file: usize,
71
72    /// Maximum search results to include (default: 5)
73    #[serde(default = "default_vibe_max_search_results")]
74    max_search_results: usize,
75
76    /// Enable relative value inference (by half, double, etc.)
77    #[serde(default = "default_vibe_value_inference")]
78    pub enable_relative_value_inference: bool,
79}
80
81impl Default for AgentVibeCodingConfig {
82    fn default() -> Self {
83        Self {
84            enabled: default_vibe_coding_enabled(),
85            min_prompt_length: default_vibe_min_prompt_length(),
86            min_prompt_words: default_vibe_min_prompt_words(),
87            enable_entity_resolution: default_vibe_entity_resolution(),
88            entity_index_cache: default_vibe_entity_cache(),
89            max_entity_matches: default_vibe_max_entity_matches(),
90            track_workspace_state: default_vibe_track_workspace(),
91            max_recent_files: default_vibe_max_recent_files(),
92            track_value_history: default_vibe_track_values(),
93            enable_conversation_memory: default_vibe_conversation_memory(),
94            max_memory_turns: default_vibe_max_memory_turns(),
95            enable_pronoun_resolution: default_vibe_pronoun_resolution(),
96            enable_proactive_context: default_vibe_proactive_context(),
97            max_context_files: default_vibe_max_context_files(),
98            max_context_snippets_per_file: default_vibe_max_snippets_per_file(),
99            max_search_results: default_vibe_max_search_results(),
100            enable_relative_value_inference: default_vibe_value_inference(),
101        }
102    }
103}
104
105// Vibe coding default functions
106#[inline]
107const fn default_vibe_coding_enabled() -> bool {
108    false // Conservative default, opt-in
109}
110
111#[inline]
112const fn default_vibe_min_prompt_length() -> usize {
113    5
114}
115
116#[inline]
117const fn default_vibe_min_prompt_words() -> usize {
118    2
119}
120
121#[inline]
122const fn default_vibe_entity_resolution() -> bool {
123    true
124}
125
126#[inline]
127fn default_vibe_entity_cache() -> String {
128    ".vtcode/entity_index.json".into()
129}
130
131#[inline]
132const fn default_vibe_max_entity_matches() -> usize {
133    5
134}
135
136#[inline]
137const fn default_vibe_track_workspace() -> bool {
138    true
139}
140
141#[inline]
142const fn default_vibe_max_recent_files() -> usize {
143    20
144}
145
146#[inline]
147const fn default_vibe_track_values() -> bool {
148    true
149}
150
151#[inline]
152const fn default_vibe_conversation_memory() -> bool {
153    true
154}
155
156#[inline]
157const fn default_vibe_max_memory_turns() -> usize {
158    50
159}
160
161#[inline]
162const fn default_vibe_pronoun_resolution() -> bool {
163    true
164}
165
166#[inline]
167const fn default_vibe_proactive_context() -> bool {
168    true
169}
170
171#[inline]
172const fn default_vibe_max_context_files() -> usize {
173    3
174}
175
176#[inline]
177const fn default_vibe_max_snippets_per_file() -> usize {
178    20
179}
180
181#[inline]
182const fn default_vibe_max_search_results() -> usize {
183    5
184}
185
186#[inline]
187const fn default_vibe_value_inference() -> bool {
188    true
189}