ccswarm 0.4.5

AI-powered multi-agent orchestration system with proactive intelligence, security monitoring, and session management
Documentation
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

/// Search agent for code and documentation
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchAgent {
    pub search_history: Vec<SearchQuery>,
    pub results_cache: HashMap<String, SearchResult>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchQuery {
    pub query: String,
    pub scope: SearchScope,
    pub timestamp: chrono::DateTime<chrono::Utc>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SearchScope {
    Code,
    Documentation,
    Comments,
    All,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchResult {
    pub matches: Vec<Match>,
    pub total_count: usize,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Match {
    pub file_path: String,
    pub line_number: usize,
    pub content: String,
    pub score: f32,
    pub title: String,
    pub snippet: String,
    pub relevance_score: f32,
}

impl SearchAgent {
    pub fn new() -> Self {
        Self {
            search_history: Vec::new(),
            results_cache: HashMap::new(),
        }
    }

    pub async fn search(&mut self, query: &str, scope: SearchScope) -> SearchResult {
        let search_query = SearchQuery {
            query: query.to_string(),
            scope: scope.clone(),
            timestamp: chrono::Utc::now(),
        };

        self.search_history.push(search_query);

        // Placeholder implementation
        SearchResult {
            matches: Vec::new(),
            total_count: 0,
        }
    }
}

impl Default for SearchAgent {
    fn default() -> Self {
        Self::new()
    }
}

/// Search request
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchRequest {
    pub query: String,
    pub scope: SearchScope,
    pub max_results: Option<usize>,
    pub requesting_agent: String,
    pub filters: Option<SearchFilters>,
    pub context: Option<String>,
}

/// Search filters
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchFilters {
    pub file_types: Option<Vec<String>>,
    pub directories: Option<Vec<String>>,
    pub exclude_patterns: Option<Vec<String>>,
}

/// Search context for better results
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchContext {
    pub current_task: Option<String>,
    pub related_files: Option<Vec<String>>,
    pub keywords: Option<Vec<String>>,
}

/// Search response
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchResponse {
    pub results: Vec<Match>,
    pub total_count: usize,
    pub query: String,
    pub query_used: String,
}