| tags |
|
||||
|---|---|---|---|---|---|
| aliases |
|
This page documents all public TypeScript types exported from the @code-rag/core package. These types are used across the MCP server, REST API, CLI, and viewer.
Note: > All types are defined with TypeScript strict mode. The project uses the
Result<T, E>pattern fromneverthrowfor error handling instead of thrown exceptions.
Chunks are the fundamental unit of indexed code in CodeRAG. Each chunk represents a semantically meaningful piece of code (a function, class, interface, etc.) extracted via Tree-sitter AST parsing.
Source: packages/core/src/types/chunk.ts
interface Chunk {
/** Unique identifier for the chunk (hash-based). */
id: string;
/** Raw source code content. */
content: string;
/** Natural language summary generated by LLM before embedding. */
nlSummary: string;
/** Relative file path from project root. */
filePath: string;
/** Start line number (1-based). */
startLine: number;
/** End line number (1-based, inclusive). */
endLine: number;
/** Programming language of the chunk. */
language: string;
/** Structured metadata about the chunk. */
metadata: ChunkMetadata;
/** Embedding vector (populated after embedding phase). */
embedding?: number[];
}/** A Chunk that is guaranteed to have an embedding vector. */
interface ChunkWithEmbedding extends Chunk {
embedding: number[];
}interface ChunkMetadata {
/** Type of code construct this chunk represents. */
chunkType: ChunkType;
/** Name of the symbol (function name, class name, etc.). */
name: string;
/** Parent symbol name (e.g., class name for a method). */
parentName?: string;
/** Symbols declared in this chunk. */
declarations: string[];
/** Imported symbols/modules. */
imports: string[];
/** Exported symbols. */
exports: string[];
/** Repository name (for multi-repo setups). */
repoName?: string;
/** Wikilinks extracted from documentation chunks ([[link]] syntax). */
links?: string[];
/** Tags extracted from documentation chunks (#tag syntax + frontmatter). */
tags?: string[];
/** Aliases from Obsidian frontmatter. */
aliases?: string[];
/** Document title from frontmatter. */
docTitle?: string;
}type ChunkType =
| 'function' // Standalone function
| 'method' // Method inside a class
| 'class' // Class definition
| 'module' // Module-level code
| 'interface' // Interface definition
| 'type_alias' // Type alias (type Foo = ...)
| 'config_block' // Configuration block
| 'import_block' // Import statements
| 'doc'; // Documentation chunk (Markdown, Confluence)Types used by the hybrid search engine and retrieval pipeline.
Source: packages/core/src/types/search.ts
interface SearchResult {
/** ID of the matched chunk. */
chunkId: string;
/** Full Chunk object (may be undefined in sparse results). */
chunk?: Chunk;
/** Raw content of the matched chunk. */
content: string;
/** Natural language summary. */
nlSummary: string;
/** Relevance score (0--1, higher is better). */
score: number;
/** Which search method produced this result. */
method: SearchMethod;
/** Chunk metadata. */
metadata: ChunkMetadata;
}type SearchMethod = 'vector' | 'bm25' | 'hybrid';interface SearchQuery {
/** The search text. */
text: string;
/** Optional filters to narrow results. */
filters?: SearchFilters;
/** Optional search behavior options. */
options?: SearchOptions;
}interface SearchFilters {
/** Filter to specific programming languages. */
languages?: string[];
/** Filter to specific file paths. */
filePaths?: string[];
/** Filter to specific chunk types. */
chunkTypes?: ChunkType[];
}interface SearchOptions {
/** Number of results to return. Default: 10 */
topK?: number;
/** Weight for vector (semantic) search. Default from config. */
vectorWeight?: number;
/** Weight for BM25 (keyword) search. Default from config. */
bm25Weight?: number;
/** Whether to expand results via dependency graph. */
expandGraph?: boolean;
}Types for the query analysis pipeline that classifies user intent and extracts entities.
Source: packages/core/src/retrieval/query-analyzer.ts
interface AnalyzedQuery {
/** The original user query string. */
originalQuery: string;
/** Classified intent of the query. */
intent: QueryIntent;
/** Extracted entities (symbols, files, concepts). */
entities: QueryEntity[];
/** Automatically suggested filters based on query analysis. */
suggestedFilters: SearchFilters;
/** Expanded search terms for broader matching. */
expandedTerms: string[];
}type QueryIntent =
| 'find_definition' // Looking for where something is defined
| 'find_usage' // Looking for where something is used
| 'understand_module' // Trying to understand how a module works
| 'find_similar' // Looking for similar code patterns
| 'general'; // General information queryinterface QueryEntity {
/** Type of entity detected in the query. */
type: 'function' | 'class' | 'module' | 'file' | 'concept';
/** The extracted entity value. */
value: string;
}Types for the graph-based context expansion pipeline.
Source: packages/core/src/retrieval/context-expander.ts
interface ExpandedContext {
/** Primary search results. */
primaryResults: SearchResult[];
/** Related chunks found via dependency graph traversal. */
relatedChunks: RelatedChunk[];
/** Excerpt of the dependency graph relevant to these results. */
graphExcerpt: GraphExcerpt;
}interface RelatedChunk {
/** The search result for the related chunk. */
chunk: SearchResult;
/** How this chunk is related to the primary results. */
relationship: RelationshipType;
/** Graph distance from the nearest primary result. */
distance: number;
}type RelationshipType =
| 'imports' // This chunk imports from a primary chunk
| 'imported_by' // This chunk is imported by a primary chunk
| 'test_for' // This chunk is a test for a primary chunk
| 'interface_of' // This chunk is an interface implemented by a primary chunk
| 'sibling'; // This chunk is in the same file as a primary chunkinterface GraphExcerpt {
/** Node IDs included in the excerpt. */
nodes: string[];
/** Edges between included nodes. */
edges: Array<{ from: string; to: string; type: string }>;
}The output of the TokenBudgetOptimizer.
Source: packages/core/src/retrieval/token-budget.ts
interface AssembledContext {
/** Final assembled context string with formatted sections. */
content: string;
/** Primary results that fit within the budget. */
primaryChunks: SearchResult[];
/** Related chunks that fit within the budget. */
relatedChunks: RelatedChunk[];
/** Estimated total token count of the assembled content. */
tokenCount: number;
/** Whether results were truncated to fit the budget. */
truncated: boolean;
}Types for the dependency graph that models relationships between code modules.
Source: packages/core/src/graph/dependency-graph.ts
interface GraphNode {
/** Unique node ID (typically the file path). */
id: string;
/** Relative file path. */
filePath: string;
/** Symbols declared in this module. */
symbols: string[];
/** Type of node. */
type: 'module' | 'class' | 'function';
}interface GraphEdge {
/** ID of the source node. */
source: string;
/** ID of the target node. */
target: string;
/** Type of relationship. */
type: 'imports' | 'extends' | 'implements' | 'calls';
}Types for the project backlog integration.
Source: packages/core/src/backlog/types.ts
interface BacklogItem {
/** Internal ID. */
id: string;
/** Provider-specific ID (e.g., "AB#123", "PROJ-456"). */
externalId: string;
/** Item title. */
title: string;
/** Full description text. */
description: string;
/** Item type. */
type: BacklogItemType;
/** Current state (e.g., "New", "Active", "Resolved", "Closed"). */
state: string;
/** Assigned user. */
assignedTo?: string;
/** Associated tags. */
tags: string[];
/** File paths linked to this item. */
linkedCodePaths: string[];
/** Web URL to view the item in the provider UI. */
url?: string;
/** Provider-specific metadata. */
metadata: Record<string, unknown>;
}type BacklogItemType = 'epic' | 'story' | 'task' | 'bug' | 'feature';interface BacklogQuery {
/** Text search filter. */
text?: string;
/** Filter by item types. */
types?: BacklogItemType[];
/** Filter by states. */
states?: string[];
/** Filter by assignee. */
assignedTo?: string;
/** Filter by tags. */
tags?: string[];
/** Maximum items to return. */
limit?: number;
}Types for the .coderag.yaml configuration file.
Source: packages/core/src/types/config.ts
The root configuration object parsed from .coderag.yaml.
interface CodeRAGConfig {
/** Config file version. */
version: string;
/** Project metadata. */
project: ProjectConfig;
/** Ingestion pipeline settings. */
ingestion: IngestionConfig;
/** Embedding provider settings. */
embedding: EmbeddingConfig;
/** LLM provider settings (for NL enrichment). */
llm: LLMConfig;
/** Search behavior settings. */
search: SearchConfig;
/** Storage backend settings. */
storage: StorageConfig;
/** Optional re-ranker configuration. */
reranker?: ReRankerConfig;
/** Optional multi-repo configuration. */
repos?: RepoConfig[];
/** Optional backlog provider configuration. */
backlog?: BacklogConfig;
}interface ProjectConfig {
/** Project name. */
name: string;
/** Supported languages ("auto" for detection). */
languages: string[] | 'auto';
}interface IngestionConfig {
/** Maximum tokens per chunk. */
maxTokensPerChunk: number;
/** Glob patterns to exclude from indexing. */
exclude: string[];
}interface EmbeddingConfig {
/** Provider name (e.g., "ollama", "voyage", "openai"). */
provider: string;
/** Model name (e.g., "nomic-embed-text", "voyage-code-3"). */
model: string;
/** Embedding vector dimensions. */
dimensions: number;
}interface LLMConfig {
/** Provider name (e.g., "ollama"). */
provider: string;
/** Model name (e.g., "qwen2.5-coder", "llama3.2"). */
model: string;
}interface SearchConfig {
/** Default number of results. */
topK: number;
/** Default weight for vector search (0--1). */
vectorWeight: number;
/** Default weight for BM25 search (0--1). */
bm25Weight: number;
}interface StorageConfig {
/** Relative path to storage directory from project root. */
path: string;
/** Vector store provider. Default: "lancedb". */
provider?: 'lancedb' | 'qdrant';
/** Qdrant-specific settings (when provider is "qdrant"). */
qdrant?: QdrantStorageConfig;
}interface QdrantStorageConfig {
/** Qdrant server URL. */
url?: string;
/** Collection name. */
collectionName?: string;
}interface ReRankerConfig {
/** Whether re-ranking is enabled. */
enabled: boolean;
/** Cross-encoder model name. */
model: string;
/** Number of top results to re-rank. */
topN: number;
}interface RepoConfig {
/** Absolute or relative path to the repository. */
path: string;
/** Optional display name. */
name?: string;
/** Override languages for this repo. */
languages?: string[];
/** Override exclude patterns for this repo. */
exclude?: string[];
}interface BacklogConfig {
/** Provider name ("azure-devops", "jira", "clickup"). */
provider: string;
/** Provider-specific configuration. */
config?: Record<string, unknown>;
}Types produced by the code parser during ingestion.
Source: packages/core/src/types/provider.ts
interface ParsedFile {
/** Relative file path from project root. */
filePath: string;
/** Detected programming language. */
language: string;
/** Full file content. */
content: string;
/** Top-level declarations found in the file. */
declarations: string[];
}CodeRAG uses typed error classes with the Result<T, E> pattern from neverthrow. Each module has its own error class for precise error handling.
Source: packages/core/src/types/provider.ts, packages/core/src/backlog/backlog-provider.ts, packages/core/src/auth/types.ts, packages/core/src/storage/types.ts
class ParseError extends Error {
readonly name = 'ParseError';
}
class ChunkError extends Error {
readonly name = 'ChunkError';
}
class EmbedError extends Error {
readonly name = 'EmbedError';
}
class StoreError extends Error {
readonly name = 'StoreError';
}
class LLMError extends Error {
readonly name = 'LLMError';
}
class ReRankerError extends Error {
readonly name = 'ReRankerError';
}
class BacklogError extends Error {
readonly name = 'BacklogError';
}
class AuthError extends Error {
readonly name = 'AuthError';
}
class StorageError extends Error {
readonly name = 'StorageError';
}Tip: > All error types extend
Errorand set a descriptivenameproperty. They are used as theEtype inResult<T, E>return types throughout the codebase, ensuring errors are always handled explicitly.
Types for the authentication and authorization system.
Source: packages/core/src/auth/types.ts
/** CodeRAG role hierarchy: Admin > Developer > Viewer */
type Role = 'admin' | 'developer' | 'viewer';
/** Ordered role hierarchy (index = privilege level). */
const ROLE_HIERARCHY: readonly Role[] = ['viewer', 'developer', 'admin'];/** Actions that can be gated by RBAC. */
type Action =
| 'search'
| 'context'
| 'status'
| 'explain'
| 'docs'
| 'index'
| 'configure';interface User {
readonly id: string;
readonly email: string;
readonly name: string;
readonly roles: readonly Role[];
readonly allowedRepos: readonly string[];
}interface AuthToken {
readonly userId: string;
readonly email: string;
readonly roles: readonly Role[];
readonly exp: number; // Expiration (Unix timestamp)
readonly iat: number; // Issued at (Unix timestamp)
}interface AuditEntry {
readonly timestamp: Date;
readonly userId: string;
readonly action: string;
readonly resource: string;
readonly details: string;
readonly ip: string;
}- Interfaces -- Provider interfaces that use these types
- Core -- Core package documentation
- MCP Tools -- MCP tools that return these types
- REST API -- REST API that returns these types