probe_code/
models.rs

1// Structure to hold both limited search results and skipped files
2#[derive(Debug)]
3pub struct LimitedSearchResults {
4    pub results: Vec<SearchResult>,
5    pub skipped_files: Vec<SearchResult>,
6    pub limits_applied: Option<SearchLimits>,
7    pub cached_blocks_skipped: Option<usize>,
8}
9
10// Structure to track which limits were applied
11#[derive(Debug)]
12pub struct SearchLimits {
13    pub max_results: Option<usize>,
14    pub max_bytes: Option<usize>,
15    pub max_tokens: Option<usize>,
16
17    #[allow(dead_code)]
18    pub total_bytes: usize,
19    #[allow(dead_code)]
20    pub total_tokens: usize,
21}
22
23// Structure to hold search results
24#[derive(Debug, Clone)]
25pub struct SearchResult {
26    pub file: String,
27    pub lines: (usize, usize),
28    pub node_type: String,
29    pub code: String,
30    // Indicates if this result was found by filename matching
31    pub matched_by_filename: Option<bool>,
32    // Ranking information
33    pub rank: Option<usize>,
34    // Combined score from the ranking algorithm
35    pub score: Option<f64>,
36    // Individual TF-IDF score
37    pub tfidf_score: Option<f64>,
38    // Individual BM25 score
39    pub bm25_score: Option<f64>,
40    // TF-IDF rank (1 is most relevant)
41    pub tfidf_rank: Option<usize>,
42    // BM25 rank (1 is most relevant)
43    pub bm25_rank: Option<usize>,
44    // New score incorporating file and block metrics
45    pub new_score: Option<f64>,
46    // Hybrid2 rank (1 is most relevant)
47    pub hybrid2_rank: Option<usize>,
48    // Separate rank for combined score (useful when using different rerankers)
49    pub combined_score_rank: Option<usize>,
50    // Number of distinct search terms matched in the file
51    pub file_unique_terms: Option<usize>,
52    // Total count of matches across the file (content + filename matches)
53    pub file_total_matches: Option<usize>,
54    // Rank of the file based on total matches
55    pub file_match_rank: Option<usize>,
56    // Number of unique search terms matched in the block
57    pub block_unique_terms: Option<usize>,
58    // Total frequency of term matches in the block
59    pub block_total_matches: Option<usize>,
60    // Identifier for the parent file (used for block merging)
61    pub parent_file_id: Option<String>,
62    // Identifier for the individual block within a file (used for block merging)
63    #[allow(dead_code)]
64    pub block_id: Option<usize>,
65    // The actual keywords that matched in this result
66    pub matched_keywords: Option<Vec<String>>,
67    /// Tokenized version of the code block with filename prepended
68    #[allow(dead_code)]
69    pub tokenized_content: Option<Vec<String>>,
70}
71
72// Structure to hold node information for merging
73#[derive(Debug, PartialEq, Eq, Clone)]
74pub struct CodeBlock {
75    pub start_row: usize,
76    pub end_row: usize,
77    #[allow(dead_code)]
78    pub start_byte: usize,
79    #[allow(dead_code)]
80    pub end_byte: usize,
81    pub node_type: String,
82    // Parent node information
83    pub parent_node_type: Option<String>,
84    pub parent_start_row: Option<usize>,
85    pub parent_end_row: Option<usize>,
86}