Skip to main content

Crate cqs

Crate cqs 

Source
Expand description

Local semantic search for code using ML embeddings. Find functions by what they do, not just their names.

§Features

  • Semantic search: Uses nomic-embed-text-v1.5 embeddings (769-dim: 768 model + sentiment)
  • Notes with sentiment: Unified memory system for AI collaborators
  • Multi-language: Rust, Python, TypeScript, JavaScript, Go
  • GPU acceleration: CUDA/TensorRT with CPU fallback
  • MCP integration: Works with Claude Code and other AI assistants

§Quick Start

use cqs::{Embedder, Parser, Store};
use cqs::store::ModelInfo;

// Initialize components
let parser = Parser::new()?;
let mut embedder = Embedder::new()?;
let store = Store::open(std::path::Path::new(".cq/index.db"))?;

// Parse and embed a file
let chunks = parser.parse_file(std::path::Path::new("src/main.rs"))?;
let embeddings = embedder.embed_documents(
    &chunks.iter().map(|c| c.content.as_str()).collect::<Vec<_>>()
)?;

// Search for similar code
let query_embedding = embedder.embed_query("parse configuration file")?;
let results = store.search(&query_embedding, 5, 0.3)?;

§MCP Server

Start the MCP server for AI assistant integration:

// Stdio transport (for Claude Code)
cqs::serve_stdio(".".into(), false)?;  // false = CPU, true = GPU

// HTTP transport with GPU embedding (None = no auth)
cqs::serve_http(".".into(), "127.0.0.1", 3000, true, None)?;

Re-exports§

pub use embedder::Embedder;
pub use hnsw::HnswIndex;
pub use index::IndexResult;
pub use index::VectorIndex;
pub use mcp::serve_http;
pub use mcp::serve_stdio;
pub use parser::Parser;
pub use store::Store;

Modules§

config
Configuration file support for cqs
embedder
Embedding generation with ort + tokenizers
hnsw
HNSW (Hierarchical Navigable Small World) index for fast vector search
index
Vector index trait for nearest neighbor search
language
Language registry for code parsing
mcp
MCP (Model Context Protocol) server implementation
nl
Natural language generation from code chunks.
note
Note parsing and types
parser
Code parsing with tree-sitter
source
Source abstraction for indexable content
store
SQLite storage for chunks and embeddings (sqlx async with sync wrappers)