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 E5-base-v2 embeddings (769-dim: 768 model + sentiment)
  • Notes with sentiment: Unified memory system for AI collaborators
  • Multi-language: Rust, Python, TypeScript, JavaScript, Go, C, Java, SQL, Markdown
  • GPU acceleration: CUDA/TensorRT with CPU fallback
  • CLI tools: Call graph, impact analysis, test mapping, dead code detection

§Quick Start

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

// Initialize components
let parser = Parser::new()?;
let embedder = Embedder::new()?;
let store = Store::open(std::path::Path::new(".cqs/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)?;

Re-exports§

pub use audit::parse_duration;
pub use embedder::Embedder;
pub use embedder::Embedding;
pub use hnsw::HnswIndex;
pub use index::IndexResult;
pub use index::VectorIndex;
pub use note::parse_notes;
pub use note::path_matches_mention;
pub use note::rewrite_notes_file;
pub use note::NoteEntry;
pub use note::NoteError;
pub use note::NoteFile;
pub use note::NOTES_HEADER;
pub use parser::Chunk;
pub use parser::Parser;
pub use store::ModelInfo;
pub use store::SearchFilter;
pub use store::Store;

Modules§

audit
Audit mode for excluding notes from search/read
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
note
Note parsing and types
parser
Code parsing with tree-sitter
reference
Reference index support for multi-index search
store
SQLite storage for chunks and embeddings (sqlx async with sync wrappers)

Structs§

DiffResult
Result of a semantic diff
GatherOptions
Options for gather operation
ImpactResult
Complete impact analysis result
ProjectRegistry
Global registry of indexed cqs projects

Enums§

GatherDirection
Direction of call graph expansion
NlTemplate
Template variants for NL description generation.
Pattern
Known structural patterns

Constants§

EMBEDDING_DIM
Embedding dimension: 768 from E5-base-v2 model + 1 sentiment dimension. Single source of truth — all modules import this constant.
INDEX_DIR
Name of the per-project index directory (created by cqs init).

Functions§

analyze_impact
Run impact analysis: find callers, affected tests, and transitive callers.
enumerate_files
Enumerate files to index in a project directory.
extract_type_names
Extract non-standard type names from a function signature.
gather
Gather relevant code chunks for a query
generate_nl_description
Generate natural language description from chunk metadata.
generate_nl_with_template
Generate NL description using a specific template variant.
impact_to_json
Serialize impact result to JSON, relativizing paths against the project root
impact_to_mermaid
Generate a mermaid diagram from impact result
index_notes
Index notes into the database (embed and store)
normalize_for_fts
Normalize code text for FTS5 indexing.
parse_target
Parse a target string into (optional_file_filter, function_name).
resolve_index_dir
Resolve the index directory for a project, migrating from .cq/ to .cqs/ if needed.
resolve_target
Resolve a target string to a ChunkSummary.
search_across_projects
Search across all registered projects
semantic_diff
Run a semantic diff between two stores
strip_unc_prefix
No-op on non-Windows platforms