ai_agent/utils/
query_context.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct QueryContext {
8 pub query: String,
9 pub search_path: Option<String>,
10 pub file_pattern: Option<String>,
11 pub case_sensitive: bool,
12 pub regex: bool,
13}
14
15impl QueryContext {
16 pub fn new(query: &str) -> Self {
17 Self {
18 query: query.to_string(),
19 search_path: None,
20 file_pattern: None,
21 case_sensitive: false,
22 regex: false,
23 }
24 }
25
26 pub fn with_path(mut self, path: &str) -> Self {
27 self.search_path = Some(path.to_string());
28 self
29 }
30
31 pub fn with_pattern(mut self, pattern: &str) -> Self {
32 self.file_pattern = Some(pattern.to_string());
33 self
34 }
35
36 pub fn case_sensitive(mut self) -> Self {
37 self.case_sensitive = true;
38 self
39 }
40
41 pub fn is_regex(mut self) -> Self {
42 self.regex = true;
43 self
44 }
45}
46
47#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct QueryResult {
50 pub matches: Vec<QueryMatch>,
51 pub total_count: usize,
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56pub struct QueryMatch {
57 pub file_path: String,
58 pub line_number: usize,
59 pub line_content: String,
60 pub match_start: usize,
61 pub match_end: usize,
62}