Skip to content

Commit 177f94c

Browse files
committed
refactor: reorder imports and improve code formatting across modules
Reorder import statements alphabetically for better consistency across multiple files. Format long function calls and conditional expressions with proper line breaks to maintain 100 character limit per line. BREAKING CHANGE: None fix: adjust code style in engine and indexer modules Apply consistent formatting to multi-line expressions and function calls. Simplify nested method chains and improve readability of conditional statements. feat: update workspace persistence logic Streamline document card extraction logic in workspace module by removing unnecessary indentation and improving code flow. refactor: format stopwords array in keywords module Convert stopwords array to multi-line format with one entry per line for better readability and maintainability.
1 parent 5ec2d22 commit 177f94c

6 files changed

Lines changed: 150 additions & 57 deletions

File tree

crates/vectorless-document/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub use structure::{DocumentStructure, StructureNode};
4545
pub use toc::{TocConfig, TocEntry, TocNode, TocView};
4646
pub use tree::{DocumentTree, RetrievalIndex};
4747
pub use understanding::{
48-
Concept, Document, DocumentInfo, DocumentMeta, IngestInput, CURRENT_SCHEMA_VERSION,
48+
CURRENT_SCHEMA_VERSION, Concept, Document, DocumentInfo, DocumentMeta, IngestInput,
4949
};
5050

5151
// Re-export agent acceleration types

crates/vectorless-engine/src/engine.rs

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -347,21 +347,21 @@ impl Engine {
347347
/// Build a [`CompileArtifact`] from a [`Document`].
348348
fn build_index_item(doc: &Document) -> CompileArtifact {
349349
use vectorless_document::DocumentFormat;
350-
let format = DocumentFormat::from_extension(&doc.format)
351-
.unwrap_or(DocumentFormat::Markdown);
350+
let format =
351+
DocumentFormat::from_extension(&doc.format).unwrap_or(DocumentFormat::Markdown);
352352

353353
CompileArtifact::new(
354354
doc.doc_id.clone(),
355355
doc.name.clone(),
356356
format,
357-
if doc.summary.is_empty() { None } else { Some(doc.summary.clone()) },
357+
if doc.summary.is_empty() {
358+
None
359+
} else {
360+
Some(doc.summary.clone())
361+
},
358362
doc.page_count,
359363
)
360-
.with_source_path(
361-
doc.source_path
362-
.clone()
363-
.unwrap_or_default(),
364-
)
364+
.with_source_path(doc.source_path.clone().unwrap_or_default())
365365
}
366366

367367
// ============================================================
@@ -441,10 +441,7 @@ impl Engine {
441441
}
442442

443443
/// Load a full Document by ID (for navigation via primitives).
444-
pub async fn load_document(
445-
&self,
446-
doc_id: &str,
447-
) -> Result<Option<Document>> {
444+
pub async fn load_document(&self, doc_id: &str) -> Result<Option<Document>> {
448445
self.workspace.load(doc_id).await
449446
}
450447

@@ -595,9 +592,8 @@ impl Engine {
595592
None => return Ok(IndexAction::FullIndex { existing_id: None }),
596593
};
597594

598-
let format =
599-
vectorless_compiler::parse::DocumentFormat::from_extension(&stored_doc.format)
600-
.unwrap_or(vectorless_compiler::parse::DocumentFormat::Markdown);
595+
let format = vectorless_compiler::parse::DocumentFormat::from_extension(&stored_doc.format)
596+
.unwrap_or(vectorless_compiler::parse::DocumentFormat::Markdown);
601597
let pipeline_options = self.build_pipeline_options(options, source);
602598

603599
// If logic fingerprint changed, remove old doc before full reprocess
@@ -667,13 +663,7 @@ impl Engine {
667663
for doc in &loaded_docs {
668664
let keywords = Self::extract_keywords_from_doc(doc);
669665
let node_count = doc.meta.as_ref().map(|m| m.node_count).unwrap_or(0);
670-
builder.add_document(
671-
&doc.doc_id,
672-
&doc.name,
673-
&doc.format,
674-
node_count,
675-
keywords,
676-
);
666+
builder.add_document(&doc.doc_id, &doc.name, &doc.format, node_count, keywords);
677667
}
678668

679669
let graph = builder.build();
@@ -782,9 +772,6 @@ mod tests {
782772
let item = Engine::build_index_item(&doc);
783773

784774
assert_eq!(item.source_path, Some(String::new())); // unwrap_or_default
785-
assert_eq!(
786-
item.format,
787-
vectorless_compiler::parse::DocumentFormat::Pdf
788-
);
775+
assert_eq!(item.format, vectorless_compiler::parse::DocumentFormat::Pdf);
789776
}
790777
}

crates/vectorless-engine/src/indexer.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ use tracing::info;
2727
use uuid::Uuid;
2828

2929
use vectorless_compiler::{CompilerInput, PipelineExecutor, PipelineOptions, SourceFormat};
30-
use vectorless_document::{
31-
Document, DocumentFormat, DocumentMeta, CURRENT_SCHEMA_VERSION,
32-
};
30+
use vectorless_document::{CURRENT_SCHEMA_VERSION, Document, DocumentFormat, DocumentMeta};
3331
use vectorless_error::{Error, Result};
3432
use vectorless_llm::LlmClient;
3533
use vectorless_utils::fingerprint::Fingerprint;
3634

3735
use super::compile_input::CompileSource;
38-
use vectorless_events::{EventEmitter, CompileEvent};
36+
use vectorless_events::{CompileEvent, EventEmitter};
3937

4038
/// Document compile client.
4139
///
@@ -257,7 +255,8 @@ impl IndexerClient {
257255
.ok_or_else(|| Error::Parse("Document tree not generated".to_string()))?;
258256

259257
let node_count = tree.node_count();
260-
self.events.emit_compile(CompileEvent::TreeBuilt { node_count });
258+
self.events
259+
.emit_compile(CompileEvent::TreeBuilt { node_count });
261260

262261
let doc_name = name
263262
.map(str::to_string)
@@ -276,8 +275,10 @@ impl IndexerClient {
276275
meta = meta.with_logic_fingerprint(logic_fp.to_string());
277276

278277
// Extract stats from metrics
279-
let (summary_tokens, duration_ms) =
280-
(result.metrics.total_tokens_generated, result.metrics.total_time_ms());
278+
let (summary_tokens, duration_ms) = (
279+
result.metrics.total_tokens_generated,
280+
result.metrics.total_time_ms(),
281+
);
281282
meta.update_processing_stats(node_count, summary_tokens, duration_ms);
282283

283284
// Compute content fingerprint from source file if available
@@ -308,7 +309,9 @@ impl IndexerClient {
308309
};
309310

310311
info!("Compiling complete: {} ({} nodes)", doc.doc_id, node_count);
311-
self.events.emit_compile(CompileEvent::Complete { doc_id: doc.doc_id.clone() });
312+
self.events.emit_compile(CompileEvent::Complete {
313+
doc_id: doc.doc_id.clone(),
314+
});
312315

313316
Ok(doc)
314317
}

crates/vectorless-storage/src/persistence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use serde::{Deserialize, Serialize};
1313
use sha2::{Digest, Sha256};
1414

15-
use vectorless_document::{Document, CURRENT_SCHEMA_VERSION};
15+
use vectorless_document::{CURRENT_SCHEMA_VERSION, Document};
1616
use vectorless_error::Error;
1717
use vectorless_error::Result;
1818

crates/vectorless-storage/src/workspace.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,7 @@ impl Workspace {
259259
Self::save_meta_index(&inner)?;
260260

261261
// Update catalog with DocCard
262-
if let Some(card) = doc
263-
.nav_index
264-
.doc_card()
265-
.cloned()
266-
{
262+
if let Some(card) = doc.nav_index.doc_card().cloned() {
267263
inner.catalog.insert(doc_id.clone(), card);
268264
Self::save_catalog_index(&inner)?;
269265
}
@@ -571,11 +567,7 @@ impl Workspace {
571567
for key in doc_keys {
572568
if let Some(bytes) = inner.backend.get(key)? {
573569
if let Ok(doc) = load_document_from_bytes(&bytes) {
574-
if let Some(card) = doc
575-
.nav_index
576-
.doc_card()
577-
.cloned()
578-
{
570+
if let Some(card) = doc.nav_index.doc_card().cloned() {
579571
inner.catalog.insert(doc.doc_id.clone(), card);
580572
}
581573
}

crates/vectorless-utils/src/keywords.rs

Lines changed: 122 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,128 @@
55
66
/// Common English stop words for keyword filtering.
77
pub const STOPWORDS: &[&str] = &[
8-
"a", "an", "the", "is", "are", "was", "were", "be", "been", "being", "have", "has", "had",
9-
"do", "does", "did", "will", "would", "could", "should", "may", "might", "must", "shall",
10-
"can", "need", "dare", "ought", "used", "to", "of", "in", "for", "on", "with", "at", "by",
11-
"from", "as", "into", "through", "during", "before", "after", "above", "below", "between",
12-
"under", "again", "further", "then", "once", "here", "there", "when", "where", "why", "how",
13-
"all", "each", "few", "more", "most", "other", "some", "such", "no", "nor", "not", "only",
14-
"own", "same", "so", "than", "too", "very", "just", "and", "but", "if", "or", "because",
15-
"until", "while", "about", "what", "which", "who", "whom", "this", "that", "these", "those",
16-
"i", "me", "my", "myself", "we", "our", "ours", "ourselves", "you", "your", "yours",
17-
"yourself", "yourselves", "he", "him", "his", "himself", "she", "her", "hers", "herself",
18-
"it", "its", "itself", "they", "them", "their", "theirs", "themselves",
8+
"a",
9+
"an",
10+
"the",
11+
"is",
12+
"are",
13+
"was",
14+
"were",
15+
"be",
16+
"been",
17+
"being",
18+
"have",
19+
"has",
20+
"had",
21+
"do",
22+
"does",
23+
"did",
24+
"will",
25+
"would",
26+
"could",
27+
"should",
28+
"may",
29+
"might",
30+
"must",
31+
"shall",
32+
"can",
33+
"need",
34+
"dare",
35+
"ought",
36+
"used",
37+
"to",
38+
"of",
39+
"in",
40+
"for",
41+
"on",
42+
"with",
43+
"at",
44+
"by",
45+
"from",
46+
"as",
47+
"into",
48+
"through",
49+
"during",
50+
"before",
51+
"after",
52+
"above",
53+
"below",
54+
"between",
55+
"under",
56+
"again",
57+
"further",
58+
"then",
59+
"once",
60+
"here",
61+
"there",
62+
"when",
63+
"where",
64+
"why",
65+
"how",
66+
"all",
67+
"each",
68+
"few",
69+
"more",
70+
"most",
71+
"other",
72+
"some",
73+
"such",
74+
"no",
75+
"nor",
76+
"not",
77+
"only",
78+
"own",
79+
"same",
80+
"so",
81+
"than",
82+
"too",
83+
"very",
84+
"just",
85+
"and",
86+
"but",
87+
"if",
88+
"or",
89+
"because",
90+
"until",
91+
"while",
92+
"about",
93+
"what",
94+
"which",
95+
"who",
96+
"whom",
97+
"this",
98+
"that",
99+
"these",
100+
"those",
101+
"i",
102+
"me",
103+
"my",
104+
"myself",
105+
"we",
106+
"our",
107+
"ours",
108+
"ourselves",
109+
"you",
110+
"your",
111+
"yours",
112+
"yourself",
113+
"yourselves",
114+
"he",
115+
"him",
116+
"his",
117+
"himself",
118+
"she",
119+
"her",
120+
"hers",
121+
"herself",
122+
"it",
123+
"its",
124+
"itself",
125+
"they",
126+
"them",
127+
"their",
128+
"theirs",
129+
"themselves",
19130
];
20131

21132
/// Extract keywords from a query string, filtering stop words.

0 commit comments

Comments
 (0)