Skip to content

Commit 4efc9e4

Browse files
devwhodevsclaude
andcommitted
style: cargo fmt
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c946acd commit 4efc9e4

11 files changed

Lines changed: 324 additions & 103 deletions

File tree

src/context.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,9 @@ mod tests {
667667
store
668668
.insert_file("note.md", "h1", 100, &["rust".into()], &d1, None)
669669
.unwrap();
670-
store.insert_file("other.md", "h2", 100, &[], &d2, None).unwrap();
670+
store
671+
.insert_file("other.md", "h2", 100, &[], &d2, None)
672+
.unwrap();
671673

672674
let f1 = store.get_file("note.md").unwrap().unwrap().id;
673675
let f2 = store.get_file("other.md").unwrap().unwrap().id;
@@ -804,7 +806,14 @@ mod tests {
804806

805807
let store = Store::open_memory().unwrap();
806808
let f1 = store
807-
.insert_file("People/John.md", "h1", 100, &["person".into()], "aaa111", None)
809+
.insert_file(
810+
"People/John.md",
811+
"h1",
812+
100,
813+
&["person".into()],
814+
"aaa111",
815+
None,
816+
)
808817
.unwrap();
809818
let f2 = store
810819
.insert_file("daily.md", "h2", 100, &[], "bbb222", None)

src/fts.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,34 @@ mod tests {
7272
let store = setup_store();
7373

7474
let file_id1 = store
75-
.insert_file("notes/a.md", "h1", 100, &[], &generate_docid("notes/a.md"), None)
75+
.insert_file(
76+
"notes/a.md",
77+
"h1",
78+
100,
79+
&[],
80+
&generate_docid("notes/a.md"),
81+
None,
82+
)
7683
.unwrap();
7784
let file_id2 = store
78-
.insert_file("notes/b.md", "h2", 100, &[], &generate_docid("notes/b.md"), None)
85+
.insert_file(
86+
"notes/b.md",
87+
"h2",
88+
100,
89+
&[],
90+
&generate_docid("notes/b.md"),
91+
None,
92+
)
7993
.unwrap();
8094
let file_id3 = store
81-
.insert_file("notes/c.md", "h3", 100, &[], &generate_docid("notes/c.md"), None)
95+
.insert_file(
96+
"notes/c.md",
97+
"h3",
98+
100,
99+
&[],
100+
&generate_docid("notes/c.md"),
101+
None,
102+
)
82103
.unwrap();
83104

84105
// Chunk with "delivery" appearing multiple times should rank higher.

src/graph.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,14 @@ mod tests {
311311
.insert_file("b.md", "h2", 100, &[], &generate_docid("b.md"), None)
312312
.unwrap();
313313
let f3 = store
314-
.insert_file("shared.md", "h3", 100, &[], &generate_docid("shared.md"), None)
314+
.insert_file(
315+
"shared.md",
316+
"h3",
317+
100,
318+
&[],
319+
&generate_docid("shared.md"),
320+
None,
321+
)
315322
.unwrap();
316323

317324
store.insert_edge(f1, f3, "wikilink").unwrap();
@@ -352,7 +359,9 @@ mod tests {
352359
#[test]
353360
fn test_graph_expand_empty_graph() {
354361
let store = Store::open_memory().unwrap();
355-
let f1 = store.insert_file("a.md", "h1", 100, &[], "aaa111", None).unwrap();
362+
let f1 = store
363+
.insert_file("a.md", "h1", 100, &[], "aaa111", None)
364+
.unwrap();
356365

357366
let seeds = vec![RankedResult {
358367
file_path: "a.md".into(),

src/indexer.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::HashMap;
22
use std::path::{Path, PathBuf};
33
use std::time::{Duration, Instant};
44

5-
use anyhow::{anyhow, Context, Result};
5+
use anyhow::{Context, Result, anyhow};
66
use ignore::WalkBuilder;
77
use sha2::{Digest, Sha256};
88
use tracing::info;
@@ -305,7 +305,10 @@ pub fn index_file(
305305
});
306306

307307
// 2. Embed all chunks
308-
let token_counts: Vec<usize> = chunks.iter().map(|c| embedder.token_count(&c.text)).collect();
308+
let token_counts: Vec<usize> = chunks
309+
.iter()
310+
.map(|c| embedder.token_count(&c.text))
311+
.collect();
309312
let texts: Vec<&str> = chunks.iter().map(|c| c.text.as_str()).collect();
310313
let mut all_vectors = Vec::with_capacity(texts.len());
311314
for batch in texts.chunks(config.batch_size) {
@@ -592,11 +595,7 @@ fn run_index_inner(
592595
info!("computing folder centroids");
593596
let mut folder_vecs: HashMap<String, Vec<Vec<f32>>> = HashMap::new();
594597
for rel_path in &indexed_rel_paths {
595-
let folder = rel_path
596-
.split('/')
597-
.next()
598-
.unwrap_or("(root)")
599-
.to_string();
598+
let folder = rel_path.split('/').next().unwrap_or("(root)").to_string();
600599
if let Some(file_record) = store.get_file(rel_path)? {
601600
let chunk_vectors = store.get_chunk_vectors_for_file(file_record.id)?;
602601
for vector in chunk_vectors {
@@ -827,9 +826,15 @@ mod tests {
827826
write_file(root, "c.md", "# C\nNo links here.");
828827

829828
let store = Store::open_memory().unwrap();
830-
let f_a = store.insert_file("a.md", "h1", 100, &[], "aaa111", None).unwrap();
831-
let f_b = store.insert_file("b.md", "h2", 100, &[], "bbb222", None).unwrap();
832-
let _f_c = store.insert_file("c.md", "h3", 100, &[], "ccc333", None).unwrap();
829+
let f_a = store
830+
.insert_file("a.md", "h1", 100, &[], "aaa111", None)
831+
.unwrap();
832+
let f_b = store
833+
.insert_file("b.md", "h2", 100, &[], "bbb222", None)
834+
.unwrap();
835+
let _f_c = store
836+
.insert_file("c.md", "h3", 100, &[], "ccc333", None)
837+
.unwrap();
833838

834839
let content_a = std::fs::read_to_string(root.join("a.md")).unwrap();
835840
let content_b = std::fs::read_to_string(root.join("b.md")).unwrap();

src/links.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,7 @@ mod tests {
771771
assert_eq!(matches.len(), 1);
772772
assert!(matches!(
773773
matches[0].match_type,
774-
LinkMatchType::FirstName {
775-
confidence_bp: 650
776-
}
774+
LinkMatchType::FirstName { confidence_bp: 650 }
777775
));
778776
assert_eq!(matches[0].display, Some("Steve".to_string()));
779777
}
@@ -807,8 +805,7 @@ mod tests {
807805
match_type: LinkMatchType::ExactName,
808806
}];
809807
// "Steve" is at position 12..17
810-
let matches =
811-
find_first_name_matches("I talked to Steve about it.", &people, &[(12, 17)]);
808+
let matches = find_first_name_matches("I talked to Steve about it.", &people, &[(12, 17)]);
812809
assert_eq!(matches.len(), 0);
813810
}
814811

src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,13 @@ async fn main() -> Result<()> {
583583
created_by,
584584
limit,
585585
} => {
586-
let items =
587-
engraph::context::context_list(&params, folder.as_deref(), &tags, created_by.as_deref(), limit)?;
586+
let items = engraph::context::context_list(
587+
&params,
588+
folder.as_deref(),
589+
&tags,
590+
created_by.as_deref(),
591+
limit,
592+
)?;
588593
if cli.json {
589594
println!("{}", serde_json::to_string_pretty(&items)?);
590595
} else {

src/placement.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,7 @@ mod tests {
620620

621621
#[test]
622622
fn test_no_correction_when_confirmed() {
623-
let content =
624-
"---\nsuggested_folder: 01-Projects/\ncreated_by: cli\n---\n\n# Note\n";
623+
let content = "---\nsuggested_folder: 01-Projects/\ncreated_by: cli\n---\n\n# Note\n";
625624
assert!(detect_correction_from_frontmatter(content, "01-Projects/").is_none());
626625
}
627626

@@ -633,7 +632,8 @@ mod tests {
633632

634633
#[test]
635634
fn test_no_correction_external_tool() {
636-
let content = "---\nsuggested_folder: 00-Inbox/\ncreated_by: some-other-tool\n---\n\n# Note\n";
635+
let content =
636+
"---\nsuggested_folder: 00-Inbox/\ncreated_by: some-other-tool\n---\n\n# Note\n";
637637
assert!(detect_correction_from_frontmatter(content, "01-Projects/").is_none());
638638
}
639639

src/serve.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,14 @@ impl EngraphServer {
195195
};
196196
let tags = params.0.tags.unwrap_or_default();
197197
let limit = params.0.limit.unwrap_or(20);
198-
let items = context::context_list(&ctx, params.0.folder.as_deref(), &tags, params.0.created_by.as_deref(), limit)
199-
.map_err(|e| mcp_err(&e))?;
198+
let items = context::context_list(
199+
&ctx,
200+
params.0.folder.as_deref(),
201+
&tags,
202+
params.0.created_by.as_deref(),
203+
limit,
204+
)
205+
.map_err(|e| mcp_err(&e))?;
200206
to_json_result(&items)
201207
}
202208

0 commit comments

Comments
 (0)