vtcode_core/utils/mod.rs
1//! # Utility Functions and Helpers
2//!
3//! This module provides various utility functions and helpers used throughout VT Code,
4//! including configuration management, path utilities, and common operations.
5//!
6//! ## Modules Overview
7//!
8//! ### Configuration Management (`dot_config`)
9//! - **User Preferences**: Theme settings, UI preferences, cache configuration
10//! - **Provider Configuration**: LLM provider settings and API keys
11//! - **Dotfile Management**: `.vtcode` directory and configuration files
12//!
13//! ### ANSI and Colors (`ansi`, `colors`)
14//! - **Terminal Colors**: ANSI color codes and styling
15//! - **Color Management**: Theme support and color schemes
16//! - **Cross-platform**: Works on different terminal types
17//!
18//! ### Git Integration (`vtcodegitignore`)
19//! - **Gitignore Management**: Automatic `.vtcodegitignore` creation
20//! - **Pattern Matching**: File exclusion patterns
21//! - **Workspace Safety**: Prevents accidental file operations
22//!
23//! ### Path Utilities (`path`)
24//! - **Path Normalization**: Resolve `.` and `..` components
25//! - **Shared Utilities**: Common path operations
26//!
27//! ## Basic Usage Examples
28//!
29//! ### Configuration Management
30//! ```rust,ignore
31//! use vtcode_core::utils::dot_config::{load_user_config, save_user_config, UserPreferences};
32//!
33//! #[tokio::main]
34//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
35//! // Load user configuration
36//! let config = load_user_config().await?;
37//!
38//! // Modify preferences
39//! let mut prefs = config.preferences;
40//! prefs.theme = "dark".to_string();
41//!
42//! // Save changes
43//! save_user_config(&prefs).await?;
44//!
45//! Ok(())
46//! }
47//! ```
48//!
49//! ### ANSI Colors
50//! ```rust,ignore
51//! use vtcode_core::utils::ansi::{colorize, Color};
52//!
53//! let message = "Hello, World!";
54//! let colored = colorize(message, Color::Green);
55//! println!("{}", colored); // Prints green text
56//!
57//! // Or use styling functions
58//! let bold_text = vtcode_core::utils::ansi::bold("Important message");
59//! let red_error = colorize("Error occurred", Color::Red);
60//! ```
61//!
62//! ### Git Integration
63//! ```rust,ignore
64//! use vtcode_core::utils::vtcodegitignore::initialize_vtcode_gitignore;
65//!
66//! #[tokio::main]
67//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
68//! let workspace = std::env::current_dir()?;
69//!
70//! // Initialize .vtcodegitignore
71//! initialize_vtcode_gitignore(&workspace).await?;
72//!
73//! println!("Git integration initialized");
74//! Ok(())
75//! }
76//! ```
77
78pub mod ansi_capabilities;
79pub mod ansi_codes;
80pub mod ansi_parser;
81pub mod async_line_writer;
82pub mod async_utils;
83pub mod at_pattern;
84pub mod cached_style_parser;
85pub mod colors;
86pub mod common;
87pub mod diff_styles;
88pub mod dot_config;
89pub mod error_log_collector;
90pub mod error_messages;
91pub mod file_input;
92pub mod file_utils;
93pub mod file_workflow;
94pub mod formatting;
95pub mod gatekeeper;
96pub mod http_client;
97pub mod image_processing;
98pub mod migration;
99pub mod path;
100pub mod serde_helpers;
101pub mod session_archive;
102pub mod session_debug;
103pub mod session_transcript_norm;
104pub mod style_helpers;
105pub mod terminal_color_probe;
106pub mod tokens;
107pub mod tool_name_parsing;
108pub mod trace_writer;
109pub mod tty;
110pub mod unicode_monitor;
111pub mod validation;
112pub mod vtcodegitignore;
113
114pub use cached_style_parser::CachedStyleParser;
115pub use common::{ProjectOverview, build_project_overview, current_timestamp, merge_env_patterns};
116pub use style_helpers::*;