Main orchestrator for CodeGraph. Provides the service layer that ties together parsing, search, embedding, and graph operations into a unified API.
The core package is the central hub of CodeGraph. It re-exports key interfaces from @codegraph/graph, @codegraph/types, and @codegraph/plugin-typescript, and provides the high-level services that the MCP server and API consume.
codeGraphService— Main service facade for search, graph traversal, entity access, project managementsearch()— Vector retrieval + cross-encoder reranking (enrichedSearchV2)getGraphStats(),getFullGraph(),getFileSubgraph(),getDependencyTree()buildFileTree(),getIndexSummary(),getProjects(),deleteProject()executeReadQuery(),getEntityWithConnections(),getNodesPaginated(),getNeighbors()
knowledgeService— Knowledge graph facade for entity/relationship/fact operationsstoreEntity(),storeRelationship(),storeFact(),recall()getMemoryStats(),decayRelevance(),pruneStaleEntities()
enrichedSearchV2— Vector retrieval + cross-encoder reranking (the only active search strategy)- Pipeline: query → embed (Voyage code-3) → vector search → reranker (Jina reranker-v3) → graph enrichment
indexProject— Full project indexing with incremental support, parallel processing, embeddingsindexSingleFile— Index a single fileisProjectIndexed— Check project indexing status
embedParsedEntities— Embed newly parsed code entities during indexingembedAllParsedEntities— Batch embed multiple parsed resultsembedAllNodes— Retroactive bulk embedding for existing graph nodes
initParser/parseCode/parseFile/disposeParser— Tree-sitter parser lifecyclegetLanguageForExtension— Resolve language plugin by file extensionregisterPlugins/registerTier2Languages— Register language pluginsextractEntitiesForFile/buildParsedFileEntities— Entity extraction pipeline
loadConfig/saveConfig— Read/write~/.codegraph/mcp-context.jsongetActiveProjectPaths— Manage which projects are indexedneedsSetup/isStale— Setup and staleness detection
syncGitHistory— Import git commit history linked to code entitiesgetRepoInfo— Repository metadata
WatchService— File system watcher for live incremental updatesreadSourceFile— Read file content with line slicing and path traversal protection
import { codeGraphService, knowledgeService, indexProject } from '@codegraph/core';
// Index a project
await indexProject('/path/to/project', client);
// Search (returns { hits, meta })
const results = await codeGraphService.search('authentication');
// Knowledge operations
await knowledgeService.storeFact('The auth service uses OAuth2');
const recall = await knowledgeService.recall('auth service');3 test files:
config.test.ts— Config load/save, setup detection, staleness, atomic writesservice.test.ts— Service layer tests (needs update to match current API)complexity.test.ts— Complexity metrics (needs import path fix)
cd packages/core
pnpm exec vitest run