import { Database as Database$1 } from 'sql.js'; interface McpServerOptions { graphPath?: string; } declare function startMcpServer(options?: McpServerOptions): Promise; /** * Shared types for graphify-mcp-tools */ /** A node in the knowledge graph */ interface GraphNode { id: string; label: string; type: string; source_file?: string; repo?: string; community?: string; start_line?: number; end_line?: number; properties?: Record; } /** An edge in the knowledge graph */ interface GraphEdge { source: string; target: string; type: string; confidence?: number; properties?: Record; } /** Community detected by Graphify */ interface GraphCommunity { id: string | number; name: string; members: string[]; size: number; } /** Full graph structure as produced by Graphify */ interface GraphData { nodes: GraphNode[]; edges: GraphEdge[]; communities?: GraphCommunity[]; metadata?: GraphMetadata; } /** Graph metadata */ interface GraphMetadata { graphify_version?: string; built_at?: string; repos?: string[]; node_count?: number; edge_count?: number; } /** Adjacency map for BFS/Dijkstra */ interface AdjacencyMap { /** node_id → list of outgoing edges */ outgoing: Map; /** node_id → list of incoming edges */ incoming: Map; } interface AdjacencyEntry { nodeId: string; edgeType: string; weight: number; } /** Configuration file schema */ interface Config { output: string; repos: RepoConfig[]; build: BuildConfig; outlines: OutlineConfig; server: ServerConfig; } interface RepoConfig { name: string; path: string; } interface BuildConfig { graphify_args: string[]; html: boolean; html_min_degree?: number; html_community_fallback: boolean; exclude: string[]; mode: "monorepo" | "separate"; } interface OutlineConfig { enabled: boolean; language: string; paths: string[]; exclude: string[]; } interface ServerConfig { [key: string]: unknown; } /** Search result */ interface SearchResult { id: string; label: string; type: string; source_file?: string; repo?: string; community?: string; rank: number; properties?: Record; } /** Impact analysis result */ interface ImpactResult { target: GraphNode; upstream: ImpactLayer[]; downstream: ImpactLayer[]; cross_repo_summary: Map; } interface ImpactLayer { depth: number; nodes: ImpactNode[]; } interface ImpactNode { id: string; label: string; source_file?: string; repo?: string; edge_type: string; via?: string; } /** Shortest path result */ interface PathResult { found: boolean; from: string; to: string; hops: number; path: PathStep[]; cross_repo?: string; edge_types_used?: Map; } interface PathStep { node_id: string; label: string; source_file?: string; edge_type?: string; } /** Node detail result */ interface NodeDetail { id: string; label: string; type: string; source_file?: string; repo?: string; community?: string; signature?: string; decorators?: string[]; docstring?: string; start_line?: number; end_line?: number; outgoing_edges: GroupedEdges; incoming_edges: GroupedEdges; centrality: CentralityMetrics; } interface GroupedEdges { [edgeType: string]: EdgeDetail[]; } interface EdgeDetail { node_id: string; label: string; source_file?: string; repo?: string; is_cross_repo?: boolean; is_external?: boolean; } interface CentralityMetrics { in_degree: number; out_degree: number; betweenness: number; } /** Outline structures */ interface FileOutline { file_path: string; line_count: number; imports: ImportEntry[]; functions: FunctionEntry[]; classes: ClassEntry[]; } interface ImportEntry { module: string; names?: string[]; line: number; } interface FunctionEntry { name: string; signature: string; decorators: string[]; docstring?: string; start_line: number; end_line: number; calls: string[]; } interface ClassEntry { name: string; bases: string[]; docstring?: string; start_line: number; end_line: number; methods: FunctionEntry[]; } /** * Load and validate configuration from a YAML file. */ declare function loadConfig(configPath?: string): { config: Config; configDir: string; }; type Database = Database$1; interface DbOptions { readonly?: boolean; } /** * Open or create the SQLite database using sql.js (WASM). */ declare function openDatabase(dbPath: string, _options?: DbOptions): Promise; /** * Save the database to disk. */ declare function saveDatabase(db: Database, dbPath: string): void; /** * Initialize the database schema. */ declare function initializeSchema(db: Database): void; /** * Populate the database from graph data. */ declare function populateDatabase(db: Database, graphData: GraphData): void; /** * Get a metadata value. */ declare function getMeta(db: Database, key: string): string | null; /** * Run a query and return all result rows as objects. */ declare function queryAll(db: Database, sql: string, params?: unknown[]): Record[]; /** * Run a query and return the first result row. */ declare function queryOne(db: Database, sql: string, params?: unknown[]): Record | null; /** * Load graph.json from disk and parse it. * Handles graphify's NetworkX format: * - Nodes: { id, label, file_type, source_file, source_location, community, norm_label } * - Edges: stored as "links" with { source, target, relation, confidence_score, confidence, weight } */ declare function loadGraphData(graphJsonPath: string): GraphData; /** * Build an adjacency map from the graph edges for BFS/Dijkstra traversal. */ declare function buildAdjacencyMap(edges: GraphEdge[], edgeWeights?: Record): AdjacencyMap; /** * Build a node lookup map: id → GraphNode. */ declare function buildNodeMap(nodes: GraphNode[]): Map; interface SearchOptions { top_k?: number; repo?: string; type?: string; } /** * Perform text search on knowledge graph nodes using LIKE matching. * Scores results by number of matching terms (higher = better match). */ declare function searchNodes(db: Database, query: string, options?: SearchOptions): SearchResult[]; /** * Fuzzy match a node by name. Uses OR logic (any term matches) * to handle partial/typo'd names like "get_usr" matching "get_user_by_id". */ declare function fuzzyMatchNode(db: Database, name: string, top_k?: number): SearchResult[]; interface ImpactOptions { direction?: "upstream" | "downstream" | "both"; max_depth?: number; include_tests?: boolean; } /** * Perform blast-radius impact analysis using BFS on the edge graph. */ declare function analyzeImpact(db: Database, symbolId: string, options?: ImpactOptions): ImpactResult | null; /** * Format impact result as markdown. */ declare function formatImpactMarkdown(result: ImpactResult): string; interface ShortestPathOptions { max_depth?: number; edge_types?: string[]; edge_weights?: Record; } /** * Find the shortest path between two nodes using weighted Dijkstra. */ declare function findShortestPath(db: Database, fromName: string, toName: string, options?: ShortestPathOptions): PathResult; /** * Format path result as markdown. */ declare function formatPathMarkdown(result: PathResult): string; /** * Get complete detail for a node. */ declare function getNodeDetail(db: Database, symbol: string): NodeDetail | null; /** * Get suggestions for a not-found node. */ declare function getNodeSuggestions(db: Database, symbol: string): string[]; /** * Format node detail as markdown. */ declare function formatNodeDetailMarkdown(detail: NodeDetail): string; /** * Auto-detect the path to graphify-out directory. * * Resolution order: * 1. Explicit --graph flag * 2. Env var GRAPHIFY_GRAPH_PATH * 3. ./graphify-out/ (current directory) * 4. ../{sibling}/graphify-out/ - sibling probe * 5. null (not found) */ declare function resolveGraphPath(explicitPath?: string): string | null; /** * Resolve the graph.json file path within a graphify-out directory. */ declare function resolveGraphJson(graphDir: string): string | null; /** * Resolve the search database path within a graphify-out directory. */ declare function resolveSearchDb(graphDir: string): string | null; /** * Normalize file paths from absolute to relative with forward slashes. * Used during indexing to ensure consistent paths in the database. */ declare function fixPaths(filePath: string, basePaths: string[]): string; /** * Apply path fixing to all nodes in graph data (mutates in place). */ declare function fixGraphPaths(nodes: Array<{ source_file?: string; }>, basePaths: string[]): void; export { type Config, type Database, type FileOutline, type GraphCommunity, type GraphData, type GraphEdge, type GraphNode, type ImpactResult, type NodeDetail, type PathResult, type SearchResult, analyzeImpact, buildAdjacencyMap, buildNodeMap, findShortestPath, fixGraphPaths, fixPaths, formatImpactMarkdown, formatNodeDetailMarkdown, formatPathMarkdown, fuzzyMatchNode, getMeta, getNodeDetail, getNodeSuggestions, initializeSchema, loadConfig, loadGraphData, openDatabase, populateDatabase, queryAll, queryOne, resolveGraphJson, resolveGraphPath, resolveSearchDb, saveDatabase, searchNodes, startMcpServer };