use serde::{Deserialize, Serialize};
use std::time::Instant;
#[derive(Debug, Clone)]
pub struct EnhancedCacheEntry<T> {
pub data: T,
pub timestamp: Instant,
pub access_count: usize,
pub size_bytes: usize,
pub last_accessed: Instant,
pub priority: u8, }
impl<T> EnhancedCacheEntry<T> {
pub fn new(data: T, size_bytes: usize) -> Self {
let now = Instant::now();
Self {
data,
timestamp: now,
access_count: 1,
size_bytes,
last_accessed: now,
priority: 1,
}
}
pub fn access(&mut self) {
self.access_count += 1;
self.last_accessed = Instant::now();
}
}
#[derive(Debug, Clone, Default)]
pub struct EnhancedCacheStats {
pub hits: usize,
pub misses: usize,
pub entries: usize,
pub total_size_bytes: usize,
pub evictions: usize,
pub memory_evictions: usize,
pub expired_evictions: usize,
pub total_memory_saved: usize,
}
#[derive(Debug, Clone, Default)]
pub struct OperationStats {
pub total_calls: usize,
pub total_duration_ms: u64,
pub avg_duration_ms: f64,
pub success_count: usize,
pub error_count: usize,
pub last_called: Option<Instant>,
}
#[derive(Debug, Deserialize)]
pub struct Input {
pub path: String,
#[serde(default)]
pub max_bytes: Option<usize>,
#[serde(default)]
pub encoding: Option<String>,
#[serde(default)]
pub ast_grep_pattern: Option<String>,
#[serde(default)]
pub chunk_lines: Option<usize>,
#[serde(default)]
pub max_lines: Option<usize>,
}
#[derive(Debug, Deserialize)]
pub struct WriteInput {
pub path: String,
pub content: String,
#[serde(default)]
pub encoding: Option<String>,
#[serde(default = "default_write_mode")]
pub mode: String,
#[serde(default)]
pub ast_grep_lint: bool,
#[serde(default)]
pub ast_grep_refactor: bool,
}
#[derive(Debug, Deserialize)]
pub struct EditInput {
pub path: String,
pub old_str: String,
pub new_str: String,
#[serde(default)]
pub encoding: Option<String>,
#[serde(default)]
pub ast_grep_pattern: Option<String>,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct ListInput {
pub path: String,
#[serde(default = "default_max_items")]
pub max_items: usize,
#[serde(default)]
pub page: Option<usize>,
#[serde(default)]
pub per_page: Option<usize>,
#[serde(default)]
pub response_format: Option<String>,
#[serde(default)]
pub include_hidden: bool,
#[serde(default)]
pub ast_grep_pattern: Option<String>,
#[serde(default)]
pub mode: Option<String>, #[serde(default)]
pub name_pattern: Option<String>, #[serde(default)]
pub content_pattern: Option<String>, #[serde(default)]
pub file_extensions: Option<Vec<String>>, #[serde(default)]
pub case_sensitive: Option<bool>, }
#[derive(Debug, Deserialize, Serialize)]
pub struct EnhancedTerminalInput {
pub command: Vec<String>,
#[serde(default)]
pub working_dir: Option<String>,
#[serde(default)]
pub timeout_secs: Option<u64>,
#[serde(default)]
pub mode: Option<String>, #[serde(default)]
pub response_format: Option<String>,
}
#[derive(Debug, Clone)]
pub struct VTCodePtySession {
pub id: String,
pub command: String,
pub args: Vec<String>,
pub working_dir: Option<String>,
pub rows: u16,
pub cols: u16,
}
fn default_max_items() -> usize {
1000
}
fn default_write_mode() -> String {
"overwrite".to_string()
}
pub fn default_search_path() -> String {
".".to_string()
}