Expand description
ctx - Code intelligence library for AI-assisted development.
This library provides tools for understanding codebases and generating context for Large Language Models (LLMs). It includes:
- Code Indexing: Parse and index source code with symbol extraction
- Semantic Search: Find relevant code using embeddings
- Call Graph Analysis: Understand code relationships and impact
- Smart Context Selection: Intelligently select files for LLM context
- Diff-Aware Context: Generate context focused on code changes
- Token Management: Count and budget tokens for LLM context windows
§Quick Start
ⓘ
use ctx::{index::Indexer, db::Database, smart::{smart_context, SmartConfig}};
use ctx::embeddings::LocalProvider;
// Index a codebase
let mut indexer = Indexer::new("./my-project", false)?;
indexer.index()?;
// Open the database
let db = index::open_database("./my-project")?;
// Generate smart context for a task
let provider = LocalProvider::new()?;
let config = SmartConfig::default();
let context = smart_context(&db, &analytics, &provider, "add caching", config)?;§Feature Flags
mcp- Enable Model Context Protocol server support
Re-exports§
Modules§
- analytics
- Analytics module using DuckDB for complex graph queries.
- audit
- Code quality audit module.
- db
- Database module for code intelligence storage.
- diff
- Diff-aware context generation for code review and change understanding.
- embeddings
- Semantic search via embeddings.
- error
- Unified error type for ctx operations.
- formatter
- index
- Code indexing module.
- output
- parser
- Code parsing module using tree-sitter.
- prelude
- Prelude module for convenient imports.
- smart
- Smart context selection for LLM workflows.
- tokens
- Token counting for LLM context management.
- tree
- utils
- Shared utility functions for ctx.
- walker