feat: add local agent MCP tools and optional source-grounded AI answers
Core CI / core (ubuntu-latest) (push) Failing after 3m6s
Core CI / core (macos-latest) (push) Canceled after 0s
Core CI / core (windows-latest) (push) Canceled after 0s
Core CI / desktop (ubuntu-latest) (push) Successful in 5m41s
Core CI / desktop (macos-latest) (push) Canceled after 0s
Core CI / desktop (windows-latest) (push) Canceled after 0s
Core CI / core (ubuntu-latest) (push) Failing after 3m6s
Core CI / core (macos-latest) (push) Canceled after 0s
Core CI / core (windows-latest) (push) Canceled after 0s
Core CI / desktop (ubuntu-latest) (push) Successful in 5m41s
Core CI / desktop (macos-latest) (push) Canceled after 0s
Core CI / desktop (windows-latest) (push) Canceled after 0s
This commit is contained in:
1 parent
70746ef428
commit
f5b03c6fb0
27 files changed
+2988
-13
No files matched your search
@@ -0,0 +1,76 @@
|
||||
use searchi_core::{SearchIndex, SourceLocation};
|
||||
use std::fs;
|
||||
|
||||
#[test]
|
||||
fn document_source_is_bounded_current_and_index_scoped() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let files = directory.path().join("files");
|
||||
fs::create_dir(&files).unwrap();
|
||||
let file = files.join("notes.txt");
|
||||
fs::write(&file, "héllo supplier notice").unwrap();
|
||||
let mut index = SearchIndex::open(directory.path().join("index.sqlite")).unwrap();
|
||||
index.index_folder(&files).unwrap();
|
||||
let path = fs::canonicalize(&file)
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.into_owned();
|
||||
let original_version = index.file_signature(&path).unwrap().unwrap();
|
||||
let source = SourceLocation {
|
||||
kind: "line".into(),
|
||||
number: 1,
|
||||
};
|
||||
let passage = index.source_passage(&path, &source, 5).unwrap().unwrap();
|
||||
assert_eq!(passage.text, "héllo");
|
||||
assert!(index.source_passage(&path, &source, 8193).is_err());
|
||||
assert!(index
|
||||
.source_passage(
|
||||
&path,
|
||||
&SourceLocation {
|
||||
kind: "timestamp_ms".into(),
|
||||
number: 0
|
||||
},
|
||||
100
|
||||
)
|
||||
.is_err());
|
||||
assert!(index
|
||||
.source_passage(
|
||||
&path,
|
||||
&SourceLocation {
|
||||
kind: "line".into(),
|
||||
number: 99
|
||||
},
|
||||
100
|
||||
)
|
||||
.unwrap()
|
||||
.is_none());
|
||||
let other = files.join("unindexed.txt");
|
||||
fs::write(&other, "private unrelated content").unwrap();
|
||||
assert!(index
|
||||
.file_signature(&other.to_string_lossy())
|
||||
.unwrap()
|
||||
.is_none());
|
||||
assert!(index
|
||||
.source_passage(&other.to_string_lossy(), &source, 100)
|
||||
.unwrap()
|
||||
.is_none());
|
||||
fs::write(&file, "changed content with different size").unwrap();
|
||||
assert!(index.source_passage(&path, &source, 100).unwrap().is_none());
|
||||
index.index_folder(&files).unwrap();
|
||||
assert_ne!(
|
||||
index.file_signature(&path).unwrap().unwrap(),
|
||||
original_version
|
||||
);
|
||||
assert!(index.source_passage(&path, &source, 100).unwrap().is_some());
|
||||
let old_time = fs::metadata(&file).unwrap().modified().unwrap();
|
||||
let same_size = "x".repeat(fs::metadata(&file).unwrap().len() as usize);
|
||||
fs::write(&file, same_size).unwrap();
|
||||
fs::File::options()
|
||||
.write(true)
|
||||
.open(&file)
|
||||
.unwrap()
|
||||
.set_modified(old_time + std::time::Duration::from_secs(2))
|
||||
.unwrap();
|
||||
assert!(index.source_passage(&path, &source, 100).unwrap().is_none());
|
||||
fs::remove_file(&file).unwrap();
|
||||
assert!(index.source_passage(&path, &source, 100).unwrap().is_none());
|
||||
}
|
||||
Reference in new issue
Block a user