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
70
71
72
73
// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
// SPDX-License-Identifier: MIT OR Apache-2.0
//! AST-based code indexing, semantic retrieval, and repo map generation for Zeph.
//!
//! # Overview
//!
//! `zeph-index` implements the **Code RAG** (Retrieval-Augmented Generation) pipeline
//! that gives the Zeph agent grounded awareness of a local codebase. The pipeline has
//! three stages:
//!
//! 1. **Chunking** — [`chunker`] uses tree-sitter to parse source files into
//! semantically meaningful AST-level chunks (functions, structs, impl blocks, …)
//! rather than fixed-size text windows.
//! 2. **Indexing** — [`indexer`] embeds every chunk via the configured LLM provider
//! and writes the vector + rich metadata into a dual store: Qdrant for vector
//! similarity and `SQLite` for exact hash deduplication.
//! 3. **Retrieval** — [`retriever`] classifies the incoming query as *semantic*,
//! *grep*, or *hybrid*, embeds the query, searches Qdrant, applies a score
//! threshold, and packs results within a token budget.
//!
//! # Additional subsystems
//!
//! | Module | Purpose |
//! |--------|---------|
//! | [`repo_map`] | Compact `<repo_map>` for the system prompt — file paths + symbol signatures |
//! | [`mcp_server`] | In-process MCP server exposing `symbol_definition`, `find_text_references`, `call_graph`, `module_summary` tools |
//! | [`watcher`] | File-system watcher that triggers incremental re-indexing on saves |
//! | [`languages`] | Language detection and tree-sitter grammar registry |
//! | [`store`] | Qdrant + `SQLite` dual-write store |
//! | [`error`] | Unified error type [`IndexError`] |
//!
//! # Quick start
//!
//! ```no_run
//! use std::sync::Arc;
//! use zeph_index::indexer::{CodeIndexer, IndexerConfig};
//! use zeph_index::retriever::{CodeRetriever, RetrievalConfig};
//! use zeph_index::store::CodeStore;
//! # async fn example() -> zeph_index::Result<()> {
//! # let store: CodeStore = panic!("placeholder");
//! # let provider: Arc<zeph_llm::any::AnyProvider> = panic!("placeholder");
//!
//! // Build and run initial project index.
//! let indexer = CodeIndexer::new(store.clone(), Arc::clone(&provider), IndexerConfig::default());
//! let report = indexer.index_project(std::path::Path::new("."), None).await?;
//! println!("{} chunks indexed", report.chunks_created);
//!
//! // Retrieve relevant code for a query.
//! let retriever = CodeRetriever::new(store, Arc::clone(&provider), RetrievalConfig::default());
//! let result = retriever.retrieve("how does authentication work?", 8_000).await?;
//! println!("{} chunks, {} tokens", result.chunks.len(), result.total_tokens);
//! # Ok(())
//! # }
//! ```
pub use sql;
pub use ;
pub use IndexProgress;
pub use IndexMcpServer;