feat: add Google code retrieval across desktop CLI and MCP
Core CI / core (macos-latest) (push) Canceled after 0s
Core CI / core (windows-latest) (push) Canceled after 0s
Core CI / desktop (macos-latest) (push) Canceled after 0s
Core CI / desktop (ubuntu-latest) (push) Canceled after 0s
Core CI / desktop (windows-latest) (push) Canceled after 0s
Core CI / core (ubuntu-latest) (push) Canceled after 2m23s

This commit is contained in:
karl committed 2026-10-12 21:22:11 +02:00
1 parent 8b9b079469
commit 81846b3e98
32 files changed
+1303 -59

No files matched your search

+50
View File
@@ -119,6 +119,8 @@ fn set_cpu_threads(threads: usize, state: State<'_, AppState>) -> Result<Setting
#[derive(Default, Deserialize)]
struct Filters {
#[serde(default)]
code_only: bool,
folder: Option<PathBuf>,
extension: Option<String>,
min_size: Option<u64>,
@@ -132,6 +134,7 @@ struct Filters {
impl From<Filters> for SearchOptions {
fn from(value: Filters) -> Self {
Self {
code_only: value.code_only,
folder: value.folder,
extension: value.extension,
min_size: value.min_size,
@@ -500,6 +503,53 @@ fn main() {
mod tests {
use super::*;
#[test]
fn code_scope_defaults_off_and_combines_with_other_filters() {
let legacy: Filters = serde_json::from_str(r#"{"extension":"rs"}"#).unwrap();
let legacy: SearchOptions = legacy.into();
assert!(!legacy.code_only);
let scoped: Filters =
serde_json::from_str(r#"{"code_only":true,"extension":"rs","min_size":10}"#).unwrap();
let scoped: SearchOptions = scoped.into();
assert!(scoped.code_only);
assert_eq!(scoped.extension.as_deref(), Some("rs"));
assert_eq!(scoped.min_size, Some(10));
assert!(serde_json::from_str::<Filters>(r#"{"code_only":"true"}"#).is_err());
}
#[test]
fn code_scope_reaches_real_keyword_search_without_model_readiness() {
let root = tempfile::tempdir().unwrap();
std::fs::write(
root.path().join("parse.rs"),
"fn parse_configuration() { /* validate config */ }",
)
.unwrap();
std::fs::write(
root.path().join("notes.md"),
"parse_configuration validate config",
)
.unwrap();
let mut index = SearchIndex::open(":memory:").unwrap();
index.index_folder(root.path()).unwrap();
let all: SearchOptions = Filters::default().into();
assert_eq!(
index
.search_with_options("parse_configuration", 10, &all)
.unwrap()
.len(),
2
);
let scoped: SearchOptions = serde_json::from_str::<Filters>(r#"{"code_only":true}"#)
.unwrap()
.into();
let hits = index
.search_with_options("parse_configuration", 10, &scoped)
.unwrap();
assert_eq!(hits.len(), 1);
assert_eq!(hits[0].filename, "parse.rs");
}
#[test]
fn measured_failure_retains_closed_trace_without_inventing_results() {
let mut trace = TraceCollector::new(MetricsMode::Debug);