$ show dropbox/witchcraft
Witchcraft is a high-performance, local-first semantic search engine built in Rust. It indexes documents using a quantized T5 encoder (Google DeepMind's XTR model) and stores dense and sparse embeddings in SQLite, enabling hybrid retrieval with no external API dependencies or vector database. The project provides multiple interfaces: a CLI (`warp`), a Python package (`witchcraft`), a Node.js native module (`warp`), and an MCP server for AI agent integration. The flagship use case is "pickbrain" — a TUI application that ingests conversation transcripts from Pi, Claude Code, Codex, and Slack, then allows the user to search and resume sessions directly from the terminal. The architecture is modular: the core library (`src/lib.rs`) handles embedding, indexing, and search; `src/embedder.rs` wraps tokenization and T5 inference with sliding-window support; `src/db.rs` manages a SQLite database with WAL, FTS5, and batch operations. Performance-critical operations use custom CPU kernels in `src/fast_ops.rs` and the separate `fbgemm-rs` crate, which provides hand-tuned AVX2/NEON bf16 matrix multiplication and int8 quantized GEMM. Embedding compression via Haar wavelets and rANS entropy coding is provided by `src/packops.rs` and `src/rans64.rs`. The project also includes benchmark tools, a quantization tool, and safety netting for platform-specific quirks (OpenVINO memory leaks, macOS thread priorities). Overall, it is a well-crafted application demonstrating deep systems engineering, though its complexity and tight coupling of some components limit broad reuse.
The LLM identified 6 files worth highlighting for reuse:
Hand-written ARM NEON bf16 GEMM micro-kernels with 6 tiling variants (1x2 to 6x2). Demonstrates advanced SIMD optimization: register blocking, prefetching, and inline assembly. Extractable as a reusable bf16 GEMM primitive for other Rust ML projects.
A self-contained crate that dumps Chrome/Electron IndexedDB databases (LevelDB + blob files) to structured JSON. Used to ingest Slack messages. Reusable for any tool needing local browser storage extraction.
Implements timestamp-based watermark tracking for incremental ingestion. Stores last-indexed timestamps per source, supports staleness detection, and avoids re-ingesting unchanged data. Portable pattern for any data ingestion pipeline.
P95 latency histogram with configurable buckets and reporting. Thread-safe, lightweight, and dependency-free. Easily extractable for benchmarking any Rust application.
Forward and inverse Haar wavelet transform implementation with mirror-edge extension. Used for embedding packing. Clean, self-contained, and adaptable to any signal processing or compression task.
Unified progress reporting abstraction that dispatches to indicatif (CLI), N-API callbacks, or a silent no-op based on feature flags. Demonstrates a pattern for conditionally pluggable UI components in library crates.