1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//! # Probe
//!
//! Probe is an AI-friendly, fully local, semantic code search tool for large codebases.
//!
//! This crate provides both a command-line interface and a library that can be used
//! programmatically in other Rust applications.
//!
//! ## Features
//!
//! - Semantic code search with intelligent ranking
//! - Code block extraction with language-aware parsing
//! - AST-based pattern matching for precise code structure search
//!
//! ## Examples
//!
//! ### Searching for code
//!
//! ```no_run
//! use probe_code::search::{perform_probe, SearchOptions};
//! use std::path::Path;
//!
//! // Create search options
//! let options = SearchOptions {
//! path: Path::new("."),
//! queries: &vec!["function search".to_string()],
//! files_only: false,
//! custom_ignores: &[],
//! exclude_filenames: false,
//! reranker: "bm25",
//! frequency_search: true,
//! exact: false,
//! language: None,
//! max_results: Some(10),
//! max_bytes: None,
//! max_tokens: Some(10000),
//! allow_tests: false,
//! no_merge: false,
//! merge_threshold: None,
//! dry_run: false,
//! session: None,
//! timeout: 30,
//! };
//!
//! let results = perform_probe(&options).unwrap();
//! println!("Found {} results", results.results.len());
//! ```
//!
//! ### Extracting code blocks
//!
//! ```no_run
//! use probe_code::extract::{handle_extract, ExtractOptions};
//!
//! let options = ExtractOptions {
//! files: vec!["src/main.rs".to_string()],
//! custom_ignores: vec![],
//! context_lines: 0,
//! format: "text".to_string(),
//! from_clipboard: false,
//! input_file: None,
//! to_clipboard: false,
//! dry_run: false,
//! diff: false,
//! allow_tests: false,
//! keep_input: false,
//! prompt: None,
//! instructions: None,
//! };
//!
//! handle_extract(options).unwrap();
//! ```
//!
//! ### AST pattern matching
//!
//! ```no_run
//! use probe_code::query::{perform_query, QueryOptions};
//! use std::path::Path;
//!
//! // Using the lower-level perform_query function
//! let options = QueryOptions {
//! path: Path::new("."),
//! pattern: "fn $NAME($$$PARAMS) { $$$BODY }",
//! language: Some("rust".to_string()),
//! ignore: &[],
//! allow_tests: false,
//! max_results: None,
//! format: "text".to_string(),
//! };
//!
//! let matches = perform_query(&options).unwrap();
//! println!("Found {} matches", matches.len());
//! ```
// Allow internal modules to reference the crate by its library name
extern crate self as probe_code;
// Re-export commonly used types for convenience
pub use ;
pub use ;
pub use resolve_path;
pub use ;
pub use ;
// Tests are defined in their respective modules with #[cfg(test)]