Expand description
§cqs - Semantic Code Search
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
- diff_
parse - Unified diff parser for
cqs impact-diff - 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§
- Changed
Function - A function identified as changed by a diff
- Diff
Impact Result - Aggregated impact result from a diff
- Diff
Result - Result of a semantic diff
- File
Group - A file group in the scout result
- File
Suggestion - Suggestion for where to place new code
- Function
Hints - Lightweight caller + test coverage hints for a function.
- Gather
Options - Options for gather operation
- Impact
Result - Complete impact analysis result
- Local
Patterns - Local patterns observed in a file
- Placement
Result - Result from placement analysis
- Project
Registry - Global registry of indexed cqs projects
- Related
Function - A function related to the target with overlap count.
- Related
Result - Result of co-occurrence analysis for a target function.
- Scout
Chunk - A chunk in the scout result with hints
- Scout
Result - Complete scout result
- Scout
Summary - Summary counts
- Test
Suggestion - A suggested test for an untested caller
Enums§
- Chunk
Role - Role classification for chunks in scout results
- Gather
Direction - 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_
diff_ impact - Run impact analysis across all changed functions from a diff.
- analyze_
impact - Run impact analysis: find callers, affected tests, and transitive callers.
- compute_
hints - Compute caller count and test count for a single function.
- compute_
hints_ with_ graph - Core implementation — accepts pre-loaded graph and test chunks.
- diff_
impact_ to_ json - Serialize diff impact result to JSON
- enumerate_
files - Enumerate files to index in a project directory.
- extract_
type_ names - Extract non-standard type names from a function signature.
- find_
related - Find functions related to
target_nameby co-occurrence. - 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)
- map_
hunks_ to_ functions - Map diff hunks to function names using the index.
- 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.
- scout
- Run scout analysis for a task description.
- scout_
to_ json - Serialize scout result to JSON
- 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
- suggest_
placement - Suggest where to place new code matching a description.
- suggest_
tests - Suggest tests for untested callers in an impact result.