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
//! **RAG pipeline for code: index, search, and inject codebase context into
//! LLM prompts - fully on-device, no daemon, no API key.**
//!
//! `semtree-rag` is the composable core behind the [`semtree`] CLI. It wires a
//! pluggable [`Embedder`](semtree_embed::Embedder) and
//! [`VectorStore`](semtree_store::VectorStore) into a full pipeline -
//! parse → chunk → embed → index → search - that you can drop into your own
//! tool, an MCP server, or an LLM context provider.
//!
//! # Pipeline at a glance
//!
//! | Stage | Building blocks |
//! |-------|-----------------|
//! | Index a directory | [`Indexer`] + [`ChunkRegistry`] |
//! | Search (vector / BM25 / fused) | [`HybridSearcher`] over [`SearchEngine`] + [`LexicalIndex`] |
//! | Build an LLM prompt | [`ContextBuilder`] → [`ContextWindow`] |
//! | Incremental re-index | [`FileManifest`] |
//!
//! # Example
//!
//! ```no_run
//! use std::sync::Arc;
//! use semtree_embed::fastembed::FastEmbedder;
//! use semtree_store::usearch::UsearchStore;
//! use semtree_rag::{ChunkRegistry, HybridSearcher, Indexer, LexicalIndex, SearchEngine, SearchMode};
//!
//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
//! // Backends are traits - swap FastEmbedder for OpenAI, UsearchStore for Qdrant.
//! let embedder = Arc::new(FastEmbedder::new()?);
//! let store = Arc::new(UsearchStore::new(384)?);
//!
//! // Index: parse -> chunk -> embed -> store. The registry keeps chunk metadata.
//! let mut registry = ChunkRegistry::default();
//! Indexer::new(embedder.clone(), store.clone())
//! .index_dir(std::path::Path::new("./src"), &mut registry, None, |_, _| {})
//! .await?;
//!
//! // Search: fuse vector similarity with BM25 keyword matching.
//! let engine = SearchEngine::new(embedder, store);
//! let lexical = LexicalIndex::from_chunks(registry.iter());
//! let hits = HybridSearcher::new(engine, lexical)
//! .search("how is authentication handled", 5, SearchMode::Hybrid)
//! .await?;
//! # Ok(())
//! # }
//! ```
//!
//! A complete, runnable version lives in [`examples/build_your_own.rs`].
//!
//! [`semtree`]: https://crates.io/crates/semtree
//! [`examples/build_your_own.rs`]: https://github.com/rustkit-ai/semtree/blob/main/crates/semtree-rag/examples/build_your_own.rs
pub use ;
pub use RagError;
pub use ;
pub use ;
pub use LexicalIndex;
pub use FileManifest;
pub use ChunkRegistry;
pub use SearchEngine;