[package]
name = "brainwires-rag"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
homepage.workspace = true
description = "RAG-based codebase indexing and semantic search library for the Brainwires Agent Framework"
documentation = "https://docs.rs/brainwires-rag"
readme = "README.md"
keywords = ["mcp", "rag", "embeddings", "semantic-search", "code-analysis"]
categories = ["command-line-utilities", "development-tools"]
exclude = [
    ".github/",
    ".cache/",
    "docs/adr/",
    "CLAUDE.md",
    "CONTRIBUTING.md",
    "TESTING.md",
]

[dependencies]
# Always available
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
anyhow = "1.0"
thiserror = "2.0"
regex = "1.10"
chrono = "0.4"
tracing = "0.1"

# Async runtime (minimal for WASM, full for native)
tokio = { version = "1.43", features = ["sync", "time"] }

# Internal crates (optional, for document processing)
brainwires-core = { workspace = true, optional = true }

# Native-only dependencies
rmcp = { version = "0.8", features = ["server", "transport-io", "macros"], optional = true }
schemars = { version = "1.0", optional = true }
lancedb = { version = "0.23", optional = true }
arrow-array = { version = "56.2", optional = true }
arrow-schema = { version = "56.2", optional = true }
futures = { version = "0.3", optional = true }
qdrant-client = { version = "1.15", optional = true }
fastembed = { version = "5.1", optional = true }
tantivy = { version = "0.22", optional = true }
git2 = { version = "0.19", optional = true }
async-trait = { version = "0.1", optional = true }
walkdir = { version = "2.5", optional = true }
dirs = { version = "6", optional = true }
sha2 = { version = "0.10", optional = true }
ignore = { version = "0.4", optional = true }
globset = { version = "0.4", optional = true }
tracing-subscriber = { version = "0.3", optional = true }
tree-sitter = { version = "0.25", optional = true }
tree-sitter-rust = { version = "0.23", optional = true }
tree-sitter-python = { version = "0.23", optional = true }
tree-sitter-javascript = { version = "0.23", optional = true }
tree-sitter-typescript = { version = "0.23", optional = true }
tree-sitter-go = { version = "0.23", optional = true }
tree-sitter-java = { version = "0.23", optional = true }
tree-sitter-swift = { version = "0.7", optional = true }
tree-sitter-c = { version = "0.24", optional = true }
tree-sitter-cpp = { version = "0.23", optional = true }
tree-sitter-c-sharp = { version = "0.23", optional = true }
tree-sitter-ruby = { version = "0.23", optional = true }
tree-sitter-php = { version = "0.24", optional = true }
clap = { version = "4", features = ["derive", "env"], optional = true }
toml = { version = "0.8", optional = true }
pdf-extract = { version = "0.7", optional = true }
rayon = { version = "1.10", optional = true }
tokio-util = { version = "0.7", optional = true }
fs2 = { version = "0.4", optional = true }

# Document processing (optional, for document feature)
zip = { version = "8", optional = true }
uuid = { workspace = true, optional = true }

[dev-dependencies]
tempfile = "3.0"
criterion = { version = "0.5", features = ["async_tokio"] }
filetime = "0.2"

[features]
# Default: native with LanceDB backend and all tree-sitter language parsers
default = ["native", "lancedb-backend", "tree-sitter-languages"]

# Native feature gates all heavy dependencies (except tree-sitter language parsers)
native = [
    "dep:rmcp", "dep:schemars", "dep:lancedb", "dep:arrow-array", "dep:arrow-schema",
    "dep:futures", "dep:fastembed", "dep:tantivy", "dep:git2", "dep:async-trait",
    "dep:walkdir", "dep:dirs", "dep:sha2", "dep:ignore", "dep:globset",
    "dep:tree-sitter", "dep:tracing-subscriber",
    "dep:toml", "pdf-extract", "dep:rayon", "dep:tokio-util", "dep:fs2",
    "tokio/full",
    "documents",
]

# All tree-sitter language parsers for AST-aware chunking and symbol extraction.
# Without this feature, RAG still works using line-based chunking.
tree-sitter-languages = [
    "dep:tree-sitter",
    "dep:tree-sitter-rust", "dep:tree-sitter-python", "dep:tree-sitter-javascript",
    "dep:tree-sitter-typescript", "dep:tree-sitter-go", "dep:tree-sitter-java",
    "dep:tree-sitter-swift", "dep:tree-sitter-c", "dep:tree-sitter-cpp",
    "dep:tree-sitter-c-sharp", "dep:tree-sitter-ruby", "dep:tree-sitter-php",
]

# Document processing (PDF, DOCX, chunking, hybrid search)
documents = [
    "dep:brainwires-core",
    "dep:zip", "dep:uuid",
]

# WASM mode: only types and error modules
wasm = []

# PDF extraction support
pdf-extract = ["dep:pdf-extract"]

# Vector database backend selection
lancedb-backend = []
qdrant-backend = ["qdrant-client"]

# Alternative folder name for data storage (for consuming crates that want different folder)
alt-folder-name = []

# High-precision code navigation for Python, TypeScript, Java, Ruby
# This feature is prepared but not yet fully implemented
# When enabled, uses stack-graphs for ~95% accuracy name resolution
stack-graphs = []

[lib]
name = "brainwires_rag"
path = "src/lib.rs"

[[bench]]
name = "indexing_benchmark"
harness = false

[[example]]
name = "basic_indexing"
required-features = ["native"]

[[example]]
name = "advanced_search"
required-features = ["native"]

[[example]]
name = "git_search"
required-features = ["native"]
