codeorbit 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.js +3054 -13
- package/dist/cli.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/server.js.map +1 -1
- package/package.json +90 -85
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/infrastructure/SqliteGraphRepository.ts","../src/infrastructure/TreeSitterParser.ts","../src/usecases/buildGraph.ts","../src/infrastructure/FileSystemHelper.ts","../src/infrastructure/GitRunner.ts"],"sourcesContent":["/**\n * SQLite-backed knowledge graph storage — infrastructure implementation.\n *\n * Implements IGraphRepository. Pure CRUD + adjacency — no business logic.\n * BFS impact-radius computation was extracted to usecases/getImpactRadius.ts.\n *\n * Direct port of code_review_graph/graph.py.\n */\n\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport Database from 'better-sqlite3';\nimport type {\n NodeInfo,\n EdgeInfo,\n GraphNode,\n GraphEdge,\n GraphStats,\n NodeRow,\n EdgeRow,\n CountRow,\n KindCountRow,\n LanguageRow,\n FilePathRow,\n MetadataRow,\n EdgeKind,\n} from '../domain/types.js';\nimport type { IGraphRepository } from '../domain/ports/IGraphRepository.js';\n\n// ---------------------------------------------------------------------------\n// Schema DDL — must match Python's _SCHEMA_SQL exactly (schema_version = 1)\n// ---------------------------------------------------------------------------\n\nconst SCHEMA_SQL = `\nCREATE TABLE IF NOT EXISTS nodes (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n kind TEXT NOT NULL,\n name TEXT NOT NULL,\n qualified_name TEXT NOT NULL UNIQUE,\n file_path TEXT NOT NULL,\n line_start INTEGER,\n line_end INTEGER,\n language TEXT,\n parent_name TEXT,\n params TEXT,\n return_type TEXT,\n modifiers TEXT,\n is_test INTEGER DEFAULT 0,\n file_hash TEXT,\n extra TEXT DEFAULT '{}',\n updated_at REAL NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS edges (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n kind TEXT NOT NULL,\n source_qualified TEXT NOT NULL,\n target_qualified TEXT NOT NULL,\n file_path TEXT NOT NULL,\n line INTEGER DEFAULT 0,\n extra TEXT DEFAULT '{}',\n updated_at REAL NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS metadata (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS idx_nodes_file ON nodes(file_path);\nCREATE INDEX IF NOT EXISTS idx_nodes_kind ON nodes(kind);\nCREATE INDEX IF NOT EXISTS idx_nodes_qualified ON nodes(qualified_name);\nCREATE INDEX IF NOT EXISTS idx_edges_source ON edges(source_qualified);\nCREATE INDEX IF NOT EXISTS idx_edges_target ON edges(target_qualified);\nCREATE INDEX IF NOT EXISTS idx_edges_kind ON edges(kind);\nCREATE INDEX IF NOT EXISTS idx_edges_file ON edges(file_path);\n`;\n\n// ---------------------------------------------------------------------------\n// In-memory adjacency cache (replaces networkx.DiGraph)\n// ---------------------------------------------------------------------------\n\ninterface AdjacencyCache {\n out: Map<string, Set<string>>;\n in: Map<string, Set<string>>;\n}\n\n// ---------------------------------------------------------------------------\n// SqliteGraphRepository\n// ---------------------------------------------------------------------------\n\nexport class SqliteGraphRepository implements IGraphRepository {\n private db: Database.Database;\n private adjCache: AdjacencyCache | null = null;\n readonly dbPath: string;\n\n constructor(dbPath: string) {\n this.dbPath = dbPath;\n const dir = path.dirname(dbPath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n this.db = new Database(dbPath);\n this.db.pragma('journal_mode = WAL');\n this.db.pragma('busy_timeout = 5000');\n\n try {\n this.db.pragma('wal_checkpoint(TRUNCATE)');\n } catch {\n // ignore — safe to skip if another writer holds it\n }\n\n this._initSchema();\n }\n\n close(): void {\n try {\n this.db.pragma('wal_checkpoint(TRUNCATE)');\n } catch {\n // ignore\n }\n this.db.close();\n for (const suffix of ['-wal', '-shm']) {\n const side = this.dbPath + suffix;\n try {\n if (fs.existsSync(side)) { fs.unlinkSync(side); }\n } catch {\n // locked by another process — leave it alone\n }\n }\n }\n\n // ---------------------------------------------------------------------------\n // Write operations\n // ---------------------------------------------------------------------------\n\n upsertNode(node: NodeInfo, fileHash = ''): number {\n const now = Date.now() / 1000;\n const qualified = this._makeQualified(node);\n const extra = node.extra ? JSON.stringify(node.extra) : '{}';\n\n this.db.prepare(`\n INSERT INTO nodes\n (kind, name, qualified_name, file_path, line_start, line_end,\n language, parent_name, params, return_type, modifiers, is_test,\n file_hash, extra, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(qualified_name) DO UPDATE SET\n kind=excluded.kind, name=excluded.name,\n file_path=excluded.file_path, line_start=excluded.line_start,\n line_end=excluded.line_end, language=excluded.language,\n parent_name=excluded.parent_name, params=excluded.params,\n return_type=excluded.return_type, modifiers=excluded.modifiers,\n is_test=excluded.is_test, file_hash=excluded.file_hash,\n extra=excluded.extra, updated_at=excluded.updated_at\n `).run(\n node.kind, node.name, qualified, node.filePath,\n node.lineStart, node.lineEnd, node.language ?? null,\n node.parentName ?? null, node.params ?? null, node.returnType ?? null,\n node.modifiers ?? null, node.isTest ? 1 : 0, fileHash,\n extra, now,\n );\n\n const row = this.db.prepare(\n 'SELECT id FROM nodes WHERE qualified_name = ?'\n ).get(qualified) as { id: number };\n return row.id;\n }\n\n upsertEdge(edge: EdgeInfo): number {\n const now = Date.now() / 1000;\n const extra = edge.extra ? JSON.stringify(edge.extra) : '{}';\n const line = edge.line ?? 0;\n\n const existing = this.db.prepare(`\n SELECT id FROM edges\n WHERE kind=? AND source_qualified=? AND target_qualified=?\n AND file_path=? AND line=?\n `).get(edge.kind, edge.source, edge.target, edge.filePath, line) as\n { id: number } | undefined;\n\n if (existing) {\n this.db.prepare(\n 'UPDATE edges SET line=?, extra=?, updated_at=? WHERE id=?'\n ).run(line, extra, now, existing.id);\n return existing.id;\n }\n\n const result = this.db.prepare(`\n INSERT INTO edges\n (kind, source_qualified, target_qualified, file_path, line, extra, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?)\n `).run(edge.kind, edge.source, edge.target, edge.filePath, line, extra, now);\n return Number(result.lastInsertRowid);\n }\n\n removeFileData(filePath: string): void {\n this.db.prepare('DELETE FROM nodes WHERE file_path = ?').run(filePath);\n this.db.prepare('DELETE FROM edges WHERE file_path = ?').run(filePath);\n this._invalidateCache();\n }\n\n storeFileNodesEdges(\n filePath: string,\n nodes: NodeInfo[],\n edges: EdgeInfo[],\n fileHash = '',\n ): void {\n const txn = this.db.transaction(() => {\n this.removeFileData(filePath);\n for (const node of nodes) { this.upsertNode(node, fileHash); }\n for (const edge of edges) { this.upsertEdge(edge); }\n });\n txn();\n this._invalidateCache();\n }\n\n setMetadata(key: string, value: string): void {\n this.db.prepare(\n 'INSERT OR REPLACE INTO metadata (key, value) VALUES (?, ?)'\n ).run(key, value);\n }\n\n getMetadata(key: string): string | undefined {\n const row = this.db.prepare(\n 'SELECT value FROM metadata WHERE key = ?'\n ).get(key) as MetadataRow | undefined;\n return row?.value;\n }\n\n // ---------------------------------------------------------------------------\n // Read operations\n // ---------------------------------------------------------------------------\n\n getNode(qualifiedName: string): GraphNode | undefined {\n const row = this.db.prepare(\n 'SELECT * FROM nodes WHERE qualified_name = ?'\n ).get(qualifiedName) as NodeRow | undefined;\n return row ? this._rowToNode(row) : undefined;\n }\n\n getNodesByFile(filePath: string): GraphNode[] {\n const rows = this.db.prepare(\n 'SELECT * FROM nodes WHERE file_path = ? ORDER BY line_start'\n ).all(filePath) as NodeRow[];\n return rows.map((r) => this._rowToNode(r));\n }\n\n getEdgesBySource(qualifiedName: string): GraphEdge[] {\n const rows = this.db.prepare(\n 'SELECT * FROM edges WHERE source_qualified = ?'\n ).all(qualifiedName) as EdgeRow[];\n return rows.map((r) => this._rowToEdge(r));\n }\n\n getEdgesByTarget(qualifiedName: string): GraphEdge[] {\n const rows = this.db.prepare(\n 'SELECT * FROM edges WHERE target_qualified = ?'\n ).all(qualifiedName) as EdgeRow[];\n return rows.map((r) => this._rowToEdge(r));\n }\n\n searchEdgesByTargetName(name: string, kind: EdgeKind = 'CALLS'): GraphEdge[] {\n const rows = this.db.prepare(\n 'SELECT * FROM edges WHERE target_qualified = ? AND kind = ?'\n ).all(name, kind) as EdgeRow[];\n return rows.map((r) => this._rowToEdge(r));\n }\n\n getAllFiles(): string[] {\n const rows = this.db.prepare(\n \"SELECT DISTINCT file_path FROM nodes WHERE kind = 'File' ORDER BY file_path\"\n ).all() as FilePathRow[];\n return rows.map((r) => r.file_path);\n }\n\n searchNodes(query: string, limit = 20): GraphNode[] {\n const words = query.toLowerCase().split(/\\s+/).filter(Boolean);\n if (words.length === 0) { return []; }\n\n const conditions = words.map(\n () => '(LOWER(name) LIKE ? OR LOWER(qualified_name) LIKE ?)'\n );\n const params: Array<string | number> = [];\n for (const word of words) {\n params.push(`%${word}%`, `%${word}%`);\n }\n params.push(limit);\n\n const where = conditions.join(' AND ');\n // nosec: all values are parameterised\n const rows = this.db.prepare(\n `SELECT * FROM nodes WHERE ${where} LIMIT ?`\n ).all(...params) as NodeRow[];\n return rows.map((r) => this._rowToNode(r));\n }\n\n getSubgraph(qualifiedNames: string[]): { nodes: GraphNode[]; edges: GraphEdge[] } {\n const nodes: GraphNode[] = [];\n for (const qn of qualifiedNames) {\n const n = this.getNode(qn);\n if (n) { nodes.push(n); }\n }\n const qnSet = new Set(qualifiedNames);\n const edges: GraphEdge[] = [];\n for (const qn of qualifiedNames) {\n for (const e of this.getEdgesBySource(qn)) {\n if (qnSet.has(e.targetQualified)) { edges.push(e); }\n }\n }\n return { nodes, edges };\n }\n\n getStats(): GraphStats {\n const totalNodes = (\n this.db.prepare('SELECT COUNT(*) AS cnt FROM nodes').get() as CountRow\n ).cnt;\n const totalEdges = (\n this.db.prepare('SELECT COUNT(*) AS cnt FROM edges').get() as CountRow\n ).cnt;\n\n const nodesByKind: Record<string, number> = {};\n for (const r of this.db.prepare(\n 'SELECT kind, COUNT(*) AS cnt FROM nodes GROUP BY kind'\n ).all() as KindCountRow[]) {\n nodesByKind[r.kind] = r.cnt;\n }\n\n const edgesByKind: Record<string, number> = {};\n for (const r of this.db.prepare(\n 'SELECT kind, COUNT(*) AS cnt FROM edges GROUP BY kind'\n ).all() as KindCountRow[]) {\n edgesByKind[r.kind] = r.cnt;\n }\n\n const languages = (this.db.prepare(\n \"SELECT DISTINCT language FROM nodes WHERE language IS NOT NULL AND language != ''\"\n ).all() as LanguageRow[]).map((r) => r.language);\n\n const filesCount = (this.db.prepare(\n \"SELECT COUNT(*) AS cnt FROM nodes WHERE kind = 'File'\"\n ).get() as CountRow).cnt;\n\n const lastUpdated = this.getMetadata('last_updated') ?? null;\n\n let embeddingsCount = 0;\n try {\n embeddingsCount = (\n this.db.prepare('SELECT COUNT(*) AS cnt FROM embeddings').get() as CountRow\n ).cnt;\n } catch {\n // embeddings table may not exist — that is fine\n }\n\n return {\n totalNodes, totalEdges, nodesByKind, edgesByKind,\n languages, filesCount, lastUpdated, embeddingsCount,\n };\n }\n\n getNodesBySize(\n minLines = 50,\n maxLines?: number,\n kind?: string,\n filePathPattern?: string,\n limit = 50,\n ): Array<GraphNode & { lineCount: number }> {\n const conditions = [\n 'line_start IS NOT NULL',\n 'line_end IS NOT NULL',\n '(line_end - line_start + 1) >= ?',\n ];\n const params: Array<string | number> = [minLines];\n\n if (maxLines !== undefined) {\n conditions.push('(line_end - line_start + 1) <= ?');\n params.push(maxLines);\n }\n if (kind) { conditions.push('kind = ?'); params.push(kind); }\n if (filePathPattern) {\n conditions.push('file_path LIKE ?');\n params.push(`%${filePathPattern}%`);\n }\n params.push(limit);\n const where = conditions.join(' AND ');\n // nosec: all values are parameterised\n const rows = this.db.prepare(\n `SELECT * FROM nodes WHERE ${where} ORDER BY (line_end - line_start + 1) DESC LIMIT ?`\n ).all(...params) as NodeRow[];\n return rows.map((r) => ({\n ...this._rowToNode(r),\n lineCount:\n r.line_start != null && r.line_end != null\n ? r.line_end - r.line_start + 1\n : 0,\n }));\n }\n\n getAllEdges(): GraphEdge[] {\n const rows = this.db.prepare('SELECT * FROM edges').all() as EdgeRow[];\n return rows.map((r) => this._rowToEdge(r));\n }\n\n getEdgesAmong(qualifiedNames: Set<string>): GraphEdge[] {\n if (qualifiedNames.size === 0) { return []; }\n const qns = [...qualifiedNames];\n const results: GraphEdge[] = [];\n const batchSize = 450;\n\n for (let i = 0; i < qns.length; i += batchSize) {\n const batch = qns.slice(i, i + batchSize);\n const placeholders = batch.map(() => '?').join(',');\n // nosec: placeholders are parameterised\n const rows = this.db.prepare(\n `SELECT * FROM edges WHERE source_qualified IN (${placeholders})`\n ).all(...batch) as EdgeRow[];\n for (const r of rows) {\n const edge = this._rowToEdge(r);\n if (qualifiedNames.has(edge.targetQualified)) { results.push(edge); }\n }\n }\n return results;\n }\n\n // ---------------------------------------------------------------------------\n // Adjacency (BFS support for use cases)\n // ---------------------------------------------------------------------------\n\n getAdjacency(): { outgoing: Map<string, Set<string>>; incoming: Map<string, Set<string>> } {\n const cache = this._buildAdjacency();\n return { outgoing: cache.out, incoming: cache.in };\n }\n\n // ---------------------------------------------------------------------------\n // Private helpers\n // ---------------------------------------------------------------------------\n\n private _initSchema(): void {\n this.db.exec(SCHEMA_SQL);\n this.setMetadata('schema_version', '1');\n }\n\n private _invalidateCache(): void {\n this.adjCache = null;\n }\n\n private _buildAdjacency(): AdjacencyCache {\n if (this.adjCache) { return this.adjCache; }\n const out = new Map<string, Set<string>>();\n const inMap = new Map<string, Set<string>>();\n\n const rows = this.db.prepare('SELECT source_qualified, target_qualified FROM edges').all() as\n Array<{ source_qualified: string; target_qualified: string }>;\n\n for (const r of rows) {\n if (!out.has(r.source_qualified)) { out.set(r.source_qualified, new Set()); }\n out.get(r.source_qualified)!.add(r.target_qualified);\n\n if (!inMap.has(r.target_qualified)) { inMap.set(r.target_qualified, new Set()); }\n inMap.get(r.target_qualified)!.add(r.source_qualified);\n }\n\n this.adjCache = { out, in: inMap };\n return this.adjCache;\n }\n\n private _makeQualified(node: NodeInfo): string {\n if (node.kind === 'File') { return node.filePath; }\n if (node.parentName) {\n return `${node.filePath}::${node.parentName}.${node.name}`;\n }\n return `${node.filePath}::${node.name}`;\n }\n\n private _rowToNode(row: NodeRow): GraphNode {\n return {\n id: row.id,\n kind: row.kind as GraphNode['kind'],\n name: row.name,\n qualifiedName: row.qualified_name,\n filePath: row.file_path,\n lineStart: row.line_start,\n lineEnd: row.line_end,\n language: row.language ?? null,\n parentName: row.parent_name ?? null,\n params: row.params ?? null,\n returnType: row.return_type ?? null,\n modifiers: row.modifiers ?? null,\n isTest: row.is_test === 1,\n fileHash: row.file_hash ?? null,\n };\n }\n\n private _rowToEdge(row: EdgeRow): GraphEdge {\n return {\n id: row.id,\n kind: row.kind as GraphEdge['kind'],\n sourceQualified: row.source_qualified,\n targetQualified: row.target_qualified,\n filePath: row.file_path,\n line: row.line ?? 0,\n };\n }\n}\n\n// ---------------------------------------------------------------------------\n// Utility exports (mirrors Python module-level helpers)\n// ---------------------------------------------------------------------------\n\nexport function sanitizeName(s: string, maxLen = 256): string {\n let cleaned = '';\n for (const ch of s) {\n const code = ch.codePointAt(0) ?? 0;\n if (ch === '\\t' || ch === '\\n' || code >= 0x20) { cleaned += ch; }\n }\n return cleaned.slice(0, maxLen);\n}\n\nexport function nodeToDict(n: GraphNode): Record<string, unknown> {\n return {\n id: n.id,\n kind: n.kind,\n name: sanitizeName(n.name),\n qualified_name: sanitizeName(n.qualifiedName),\n file_path: n.filePath,\n line_start: n.lineStart,\n line_end: n.lineEnd,\n language: n.language,\n parent_name: n.parentName ? sanitizeName(n.parentName) : n.parentName,\n is_test: n.isTest,\n };\n}\n\nexport function edgeToDict(e: GraphEdge): Record<string, unknown> {\n return {\n id: e.id,\n kind: e.kind,\n source: sanitizeName(e.sourceQualified),\n target: sanitizeName(e.targetQualified),\n file_path: e.filePath,\n line: e.line,\n };\n}\n\n// Backward-compat alias (used by tests + public index.ts)\nexport { SqliteGraphRepository as GraphStore };\n","/**\r\n * Tree-sitter based multi-language code parser.\r\n *\r\n * Extracts structural nodes (classes, functions, imports, types) and edges\r\n * (calls, inheritance, contains) from source files.\r\n *\r\n * Direct port of code_review_graph/parser.py.\r\n * Supports 14 languages: Python, JS/TS/TSX, Go, Rust, Java, C, C++, C#,\r\n * Ruby, Kotlin, Swift, PHP, Solidity, Vue SFC.\r\n */\r\n\r\nimport crypto from 'node:crypto';\r\nimport fs from 'node:fs';\r\nimport { createRequire } from 'node:module';\r\nimport path from 'node:path';\r\nimport Parser from 'tree-sitter';\r\n\r\nconst _require = createRequire(import.meta.url);\r\nimport type { NodeInfo, EdgeInfo } from '../domain/types.js';\r\nimport type { IParser } from '../domain/ports/IParser.js';\r\n\r\n// ---------------------------------------------------------------------------\r\n// Language loading — individual npm grammar packages\r\n// ---------------------------------------------------------------------------\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\ntype Language = any;\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\ntype SyntaxNode = any;\r\n\r\nfunction loadLanguage(pkg: string): Language | null {\r\n try {\r\n // eslint-disable-next-line @typescript-eslint/no-require-imports\r\n const mod = _require(pkg);\r\n return mod.default ?? mod;\r\n } catch {\r\n return null;\r\n }\r\n}\r\n\r\n// Lazy-loaded grammar map. Languages are loaded on first use.\r\nconst _languageCache = new Map<string, Language | null>();\r\n\r\nfunction getLanguage(name: string): Language | null {\r\n if (_languageCache.has(name)) { return _languageCache.get(name) ?? null; }\r\n\r\n const pkgMap: Record<string, string> = {\r\n python: 'tree-sitter-python',\r\n javascript: 'tree-sitter-javascript',\r\n typescript: 'tree-sitter-typescript/bindings/node/typescript',\r\n tsx: 'tree-sitter-typescript/bindings/node/tsx',\r\n go: 'tree-sitter-go',\r\n rust: 'tree-sitter-rust',\r\n java: 'tree-sitter-java',\r\n c: 'tree-sitter-c',\r\n cpp: 'tree-sitter-cpp',\r\n csharp: 'tree-sitter-c-sharp',\r\n ruby: 'tree-sitter-ruby',\r\n kotlin: 'tree-sitter-kotlin',\r\n swift: 'tree-sitter-swift',\r\n php: 'tree-sitter-php/php',\r\n solidity: 'tree-sitter-solidity',\r\n vue: 'tree-sitter-vue',\r\n };\r\n\r\n const pkg = pkgMap[name];\r\n const lang = pkg ? loadLanguage(pkg) : null;\r\n _languageCache.set(name, lang);\r\n return lang;\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Extension → language mapping\r\n// ---------------------------------------------------------------------------\r\n\r\nexport const EXTENSION_TO_LANGUAGE: Record<string, string> = {\r\n '.py': 'python',\r\n '.js': 'javascript',\r\n '.jsx': 'javascript',\r\n '.ts': 'typescript',\r\n '.tsx': 'tsx',\r\n '.go': 'go',\r\n '.rs': 'rust',\r\n '.java': 'java',\r\n '.cs': 'csharp',\r\n '.rb': 'ruby',\r\n '.cpp': 'cpp',\r\n '.cc': 'cpp',\r\n '.cxx': 'cpp',\r\n '.c': 'c',\r\n '.h': 'c',\r\n '.hpp': 'cpp',\r\n '.kt': 'kotlin',\r\n '.swift': 'swift',\r\n '.php': 'php',\r\n '.sol': 'solidity',\r\n '.vue': 'vue',\r\n};\r\n\r\n// ---------------------------------------------------------------------------\r\n// AST node type sets per language\r\n// ---------------------------------------------------------------------------\r\n\r\nconst CLASS_TYPES: Record<string, string[]> = {\r\n python: ['class_definition'],\r\n javascript: ['class_declaration', 'class'],\r\n typescript: ['class_declaration', 'class'],\r\n tsx: ['class_declaration', 'class'],\r\n go: ['type_declaration'],\r\n rust: ['struct_item', 'enum_item', 'impl_item'],\r\n java: ['class_declaration', 'interface_declaration', 'enum_declaration'],\r\n c: ['struct_specifier', 'type_definition'],\r\n cpp: ['class_specifier', 'struct_specifier'],\r\n csharp: ['class_declaration', 'interface_declaration', 'enum_declaration', 'struct_declaration'],\r\n ruby: ['class', 'module'],\r\n kotlin: ['class_declaration', 'object_declaration'],\r\n swift: ['class_declaration', 'struct_declaration', 'protocol_declaration'],\r\n php: ['class_declaration', 'interface_declaration'],\r\n solidity: [\r\n 'contract_declaration', 'interface_declaration', 'library_declaration',\r\n 'struct_declaration', 'enum_declaration', 'error_declaration',\r\n 'user_defined_type_definition',\r\n ],\r\n};\r\n\r\nconst FUNCTION_TYPES: Record<string, string[]> = {\r\n python: ['function_definition'],\r\n javascript: ['function_declaration', 'method_definition', 'arrow_function'],\r\n typescript: ['function_declaration', 'method_definition', 'arrow_function'],\r\n tsx: ['function_declaration', 'method_definition', 'arrow_function'],\r\n go: ['function_declaration', 'method_declaration'],\r\n rust: ['function_item'],\r\n java: ['method_declaration', 'constructor_declaration'],\r\n c: ['function_definition'],\r\n cpp: ['function_definition'],\r\n csharp: ['method_declaration', 'constructor_declaration'],\r\n ruby: ['method', 'singleton_method'],\r\n kotlin: ['function_declaration'],\r\n swift: ['function_declaration'],\r\n php: ['function_definition', 'method_declaration'],\r\n solidity: [\r\n 'function_definition', 'constructor_definition', 'modifier_definition',\r\n 'event_definition', 'fallback_receive_definition',\r\n ],\r\n};\r\n\r\nconst IMPORT_TYPES: Record<string, string[]> = {\r\n python: ['import_statement', 'import_from_statement'],\r\n javascript: ['import_statement'],\r\n typescript: ['import_statement'],\r\n tsx: ['import_statement'],\r\n go: ['import_declaration'],\r\n rust: ['use_declaration'],\r\n java: ['import_declaration'],\r\n c: ['preproc_include'],\r\n cpp: ['preproc_include'],\r\n csharp: ['using_directive'],\r\n ruby: ['call'], // require / require_relative\r\n kotlin: ['import_header'],\r\n swift: ['import_declaration'],\r\n php: ['namespace_use_declaration'],\r\n solidity: ['import_directive'],\r\n};\r\n\r\nconst CALL_TYPES: Record<string, string[]> = {\r\n python: ['call'],\r\n javascript: ['call_expression', 'new_expression'],\r\n typescript: ['call_expression', 'new_expression'],\r\n tsx: ['call_expression', 'new_expression'],\r\n go: ['call_expression'],\r\n rust: ['call_expression', 'macro_invocation'],\r\n java: ['method_invocation', 'object_creation_expression'],\r\n c: ['call_expression'],\r\n cpp: ['call_expression'],\r\n csharp: ['invocation_expression', 'object_creation_expression'],\r\n ruby: ['call', 'method_call'],\r\n kotlin: ['call_expression'],\r\n swift: ['call_expression'],\r\n php: ['function_call_expression', 'member_call_expression'],\r\n solidity: ['call_expression'],\r\n};\r\n\r\n// ---------------------------------------------------------------------------\r\n// Test detection patterns\r\n// ---------------------------------------------------------------------------\r\n\r\nconst TEST_PATTERNS = [\r\n /^test_/,\r\n /^Test/,\r\n /_test$/,\r\n /\\.test\\./,\r\n /\\.spec\\./,\r\n /_spec$/,\r\n];\r\n\r\nconst TEST_FILE_PATTERNS = [\r\n /test_.*\\.py$/,\r\n /.*_test\\.py$/,\r\n /.*\\.test\\.[jt]sx?$/,\r\n /.*\\.spec\\.[jt]sx?$/,\r\n /.*_test\\.go$/,\r\n /tests?\\//,\r\n];\r\n\r\nfunction isTestFile(filePath: string): boolean {\r\n return TEST_FILE_PATTERNS.some((p) => p.test(filePath));\r\n}\r\n\r\n// Test-runner framework names that indicate a function IS a test even\r\n// if its name doesn't start with \"test\".\r\nconst TEST_RUNNER_NAMES = new Set([\r\n 'describe', 'it', 'test', 'beforeEach', 'afterEach', 'beforeAll', 'afterAll',\r\n]);\r\n\r\nfunction isTestFunction(name: string, filePath: string): boolean {\r\n // Name-pattern match always wins\r\n if (TEST_PATTERNS.some((p) => p.test(name))) { return true; }\r\n // In a test file, only test-runner functions count (not every helper)\r\n if (isTestFile(filePath) && TEST_RUNNER_NAMES.has(name)) { return true; }\r\n return false;\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Public utility\r\n// ---------------------------------------------------------------------------\r\n\r\nexport function fileHash(filePath: string): string {\r\n const buf = fs.readFileSync(filePath);\r\n return crypto.createHash('sha256').update(buf).digest('hex');\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// CodeParser\r\n// ---------------------------------------------------------------------------\r\n\r\nconst MAX_AST_DEPTH = 180;\r\nconst MODULE_CACHE_MAX = 15_000;\r\n\r\nexport class CodeParser implements IParser {\r\n private parsers = new Map<string, Parser>();\r\n private moduleFileCache = new Map<string, string | null>();\r\n\r\n private getParser(language: string): Parser | null {\r\n if (this.parsers.has(language)) { return this.parsers.get(language) ?? null; }\r\n try {\r\n const lang = getLanguage(language);\r\n if (!lang) { return null; }\r\n const p = new Parser();\r\n p.setLanguage(lang);\r\n this.parsers.set(language, p);\r\n return p;\r\n } catch {\r\n return null;\r\n }\r\n }\r\n\r\n detectLanguage(filePath: string): string | null {\r\n const ext = path.extname(filePath).toLowerCase();\r\n return EXTENSION_TO_LANGUAGE[ext] ?? null;\r\n }\r\n\r\n parseFile(filePath: string): [NodeInfo[], EdgeInfo[]] {\r\n let source: Buffer;\r\n try {\r\n source = fs.readFileSync(filePath);\r\n } catch {\r\n return [[], []];\r\n }\r\n return this.parseBytes(filePath, source);\r\n }\r\n\r\n parseBytes(filePath: string, source: Buffer): [NodeInfo[], EdgeInfo[]] {\r\n const language = this.detectLanguage(filePath);\r\n if (!language) { return [[], []]; }\r\n\r\n if (language === 'vue') {\r\n return this._parseVue(filePath, source);\r\n }\r\n\r\n const parser = this.getParser(language);\r\n if (!parser) { return [[], []]; }\r\n\r\n const tree = parser.parse(source.toString('utf-8'));\r\n const nodes: NodeInfo[] = [];\r\n const edges: EdgeInfo[] = [];\r\n const testFile = isTestFile(filePath);\r\n\r\n // File node\r\n const lineCount = source.toString('utf-8').split('\\n').length;\r\n nodes.push({\r\n kind: 'File',\r\n name: filePath,\r\n filePath,\r\n lineStart: 1,\r\n lineEnd: lineCount,\r\n language,\r\n isTest: testFile,\r\n });\r\n\r\n const [importMap, definedNames] = this._collectFileScope(\r\n tree.rootNode, language, source,\r\n );\r\n\r\n this._extractFromTree(\r\n tree.rootNode, source, language, filePath, nodes, edges,\r\n undefined, undefined, importMap, definedNames,\r\n );\r\n\r\n const resolvedEdges = this._resolveCallTargets(nodes, edges, filePath);\r\n\r\n // Generate TESTED_BY edges\r\n if (testFile) {\r\n const testQNames = new Set<string>();\r\n for (const n of nodes) {\r\n if (n.isTest) {\r\n testQNames.add(this._qualify(n.name, filePath, n.parentName ?? null));\r\n }\r\n }\r\n const testedBy: EdgeInfo[] = [];\r\n for (const edge of resolvedEdges) {\r\n if (edge.kind === 'CALLS' && testQNames.has(edge.source)) {\r\n testedBy.push({\r\n kind: 'TESTED_BY',\r\n source: edge.target,\r\n target: edge.source,\r\n filePath: edge.filePath,\r\n line: edge.line,\r\n });\r\n }\r\n }\r\n resolvedEdges.push(...testedBy);\r\n }\r\n\r\n return [nodes, resolvedEdges];\r\n }\r\n\r\n private _parseVue(filePath: string, source: Buffer): [NodeInfo[], EdgeInfo[]] {\r\n const vueParser = this.getParser('vue');\r\n if (!vueParser) { return [[], []]; }\r\n\r\n const tree = vueParser.parse(source.toString('utf-8'));\r\n const testFile = isTestFile(filePath);\r\n const lineCount = source.toString('utf-8').split('\\n').length;\r\n\r\n const allNodes: NodeInfo[] = [{\r\n kind: 'File',\r\n name: filePath,\r\n filePath,\r\n lineStart: 1,\r\n lineEnd: lineCount,\r\n language: 'vue',\r\n isTest: testFile,\r\n }];\r\n const allEdges: EdgeInfo[] = [];\r\n\r\n for (const child of tree.rootNode.children) {\r\n if (child.type !== 'script_element') { continue; }\r\n\r\n let scriptLang = 'javascript';\r\n let startTag: SyntaxNode | null = null;\r\n let rawTextNode: SyntaxNode | null = null;\r\n\r\n for (const sub of child.children) {\r\n if (sub.type === 'start_tag') { startTag = sub; }\r\n else if (sub.type === 'raw_text') { rawTextNode = sub; }\r\n }\r\n\r\n if (startTag) {\r\n for (const attr of startTag.children) {\r\n if (attr.type === 'attribute') {\r\n let attrName: string | null = null;\r\n let attrValue: string | null = null;\r\n for (const a of attr.children) {\r\n if (a.type === 'attribute_name') { attrName = a.text; }\r\n else if (a.type === 'quoted_attribute_value') {\r\n for (const v of a.children) {\r\n if (v.type === 'attribute_value') { attrValue = v.text; }\r\n }\r\n }\r\n }\r\n if (attrName === 'lang' && (attrValue === 'ts' || attrValue === 'typescript')) {\r\n scriptLang = 'typescript';\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (!rawTextNode) { continue; }\r\n\r\n const scriptSource = Buffer.from(rawTextNode.text, 'utf-8');\r\n const lineOffset: number = rawTextNode.startPosition.row;\r\n\r\n const scriptParser = this.getParser(scriptLang);\r\n if (!scriptParser) { continue; }\r\n\r\n const scriptTree = scriptParser.parse(scriptSource.toString('utf-8'));\r\n const [importMap, definedNames] = this._collectFileScope(\r\n scriptTree.rootNode, scriptLang, scriptSource,\r\n );\r\n\r\n const nodes: NodeInfo[] = [];\r\n const edges: EdgeInfo[] = [];\r\n this._extractFromTree(\r\n scriptTree.rootNode, scriptSource, scriptLang, filePath,\r\n nodes, edges, undefined, undefined, importMap, definedNames,\r\n );\r\n\r\n // Adjust line numbers and language for position within .vue file\r\n for (const n of nodes) {\r\n n.lineStart += lineOffset;\r\n n.lineEnd += lineOffset;\r\n n.language = 'vue';\r\n }\r\n for (const e of edges) {\r\n e.line = (e.line ?? 0) + lineOffset;\r\n }\r\n\r\n allNodes.push(...nodes);\r\n allEdges.push(...edges);\r\n }\r\n\r\n // Generate TESTED_BY edges\r\n if (testFile) {\r\n const testQNames = new Set<string>();\r\n for (const n of allNodes) {\r\n if (n.isTest) {\r\n testQNames.add(this._qualify(n.name, filePath, n.parentName ?? null));\r\n }\r\n }\r\n const testedBy: EdgeInfo[] = [];\r\n for (const edge of allEdges) {\r\n if (edge.kind === 'CALLS' && testQNames.has(edge.source)) {\r\n testedBy.push({\r\n kind: 'TESTED_BY',\r\n source: edge.target,\r\n target: edge.source,\r\n filePath: edge.filePath,\r\n line: edge.line,\r\n });\r\n }\r\n }\r\n allEdges.push(...testedBy);\r\n }\r\n\r\n return [allNodes, allEdges];\r\n }\r\n\r\n private _resolveCallTargets(\r\n nodes: NodeInfo[],\r\n edges: EdgeInfo[],\r\n filePath: string,\r\n ): EdgeInfo[] {\r\n const symbols = new Map<string, string>();\r\n for (const node of nodes) {\r\n if (['Function', 'Class', 'Type', 'Test'].includes(node.kind)) {\r\n const bare = node.name;\r\n if (!symbols.has(bare)) {\r\n symbols.set(bare, this._qualify(bare, filePath, node.parentName ?? null));\r\n }\r\n }\r\n }\r\n\r\n return edges.map((edge) => {\r\n if (edge.kind === 'CALLS' && !edge.target.includes('::')) {\r\n const qualified = symbols.get(edge.target);\r\n if (qualified) {\r\n return { ...edge, target: qualified };\r\n }\r\n }\r\n return edge;\r\n });\r\n }\r\n\r\n private _extractFromTree(\r\n root: SyntaxNode,\r\n source: Buffer,\r\n language: string,\r\n filePath: string,\r\n nodes: NodeInfo[],\r\n edges: EdgeInfo[],\r\n enclosingClass?: string | null,\r\n enclosingFunc?: string | null,\r\n importMap?: Map<string, string>,\r\n definedNames?: Set<string>,\r\n depth = 0,\r\n ): void {\r\n if (depth > MAX_AST_DEPTH) { return; }\r\n\r\n const classTypes = new Set(CLASS_TYPES[language] ?? []);\r\n const funcTypes = new Set(FUNCTION_TYPES[language] ?? []);\r\n const importTypes = new Set(IMPORT_TYPES[language] ?? []);\r\n const callTypes = new Set(CALL_TYPES[language] ?? []);\r\n\r\n for (const child of root.children) {\r\n const nodeType: string = child.type;\r\n\r\n // --- Classes ---\r\n if (classTypes.has(nodeType)) {\r\n const name = this._getName(child, language, 'class');\r\n if (name) {\r\n nodes.push({\r\n kind: 'Class',\r\n name,\r\n filePath,\r\n lineStart: child.startPosition.row + 1,\r\n lineEnd: child.endPosition.row + 1,\r\n language,\r\n parentName: enclosingClass ?? null,\r\n });\r\n\r\n edges.push({\r\n kind: 'CONTAINS',\r\n source: filePath,\r\n target: this._qualify(name, filePath, enclosingClass ?? null),\r\n filePath,\r\n line: child.startPosition.row + 1,\r\n });\r\n\r\n const bases = this._getBases(child, language);\r\n for (const base of bases) {\r\n edges.push({\r\n kind: 'INHERITS',\r\n source: this._qualify(name, filePath, enclosingClass ?? null),\r\n target: base,\r\n filePath,\r\n line: child.startPosition.row + 1,\r\n });\r\n }\r\n\r\n this._extractFromTree(\r\n child, source, language, filePath, nodes, edges,\r\n name, null, importMap, definedNames, depth + 1,\r\n );\r\n continue;\r\n }\r\n }\r\n\r\n // --- Functions ---\r\n if (funcTypes.has(nodeType)) {\r\n const name = this._getName(child, language, 'function');\r\n if (name) {\r\n const isTest = isTestFunction(name, filePath);\r\n const kind = isTest ? 'Test' : 'Function';\r\n const qualified = this._qualify(name, filePath, enclosingClass ?? null);\r\n const params = this._getParams(child, language);\r\n const retType = this._getReturnType(child, language);\r\n\r\n nodes.push({\r\n kind,\r\n name,\r\n filePath,\r\n lineStart: child.startPosition.row + 1,\r\n lineEnd: child.endPosition.row + 1,\r\n language,\r\n parentName: enclosingClass ?? null,\r\n params,\r\n returnType: retType,\r\n isTest,\r\n });\r\n\r\n const container = enclosingClass\r\n ? this._qualify(enclosingClass, filePath, null)\r\n : filePath;\r\n edges.push({\r\n kind: 'CONTAINS',\r\n source: container,\r\n target: qualified,\r\n filePath,\r\n line: child.startPosition.row + 1,\r\n });\r\n\r\n // Solidity: modifier invocations → CALLS edges\r\n if (language === 'solidity') {\r\n for (const sub of child.children) {\r\n if (sub.type === 'modifier_invocation') {\r\n for (const ident of sub.children) {\r\n if (ident.type === 'identifier') {\r\n edges.push({\r\n kind: 'CALLS',\r\n source: qualified,\r\n target: ident.text,\r\n filePath,\r\n line: sub.startPosition.row + 1,\r\n });\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._extractFromTree(\r\n child, source, language, filePath, nodes, edges,\r\n enclosingClass, name, importMap, definedNames, depth + 1,\r\n );\r\n continue;\r\n }\r\n }\r\n\r\n // --- Imports ---\r\n if (importTypes.has(nodeType)) {\r\n const imports = this._extractImport(child, language);\r\n for (const impTarget of imports) {\r\n edges.push({\r\n kind: 'IMPORTS_FROM',\r\n source: filePath,\r\n target: impTarget,\r\n filePath,\r\n line: child.startPosition.row + 1,\r\n });\r\n }\r\n continue;\r\n }\r\n\r\n // --- Calls ---\r\n if (callTypes.has(nodeType)) {\r\n const callName = this._getCallName(child, language);\r\n if (callName && enclosingFunc) {\r\n const caller = this._qualify(enclosingFunc, filePath, enclosingClass ?? null);\r\n const target = this._resolveCallTarget(\r\n callName, filePath, language,\r\n importMap ?? new Map(), definedNames ?? new Set(),\r\n );\r\n edges.push({\r\n kind: 'CALLS',\r\n source: caller,\r\n target,\r\n filePath,\r\n line: child.startPosition.row + 1,\r\n });\r\n }\r\n }\r\n\r\n // --- Solidity-specific constructs ---\r\n if (language === 'solidity') {\r\n // emit statements → CALLS edges\r\n if (nodeType === 'emit_statement' && enclosingFunc) {\r\n for (const sub of child.children) {\r\n if (sub.type === 'expression') {\r\n for (const ident of sub.children) {\r\n if (ident.type === 'identifier') {\r\n const caller = this._qualify(\r\n enclosingFunc, filePath, enclosingClass ?? null,\r\n );\r\n edges.push({\r\n kind: 'CALLS',\r\n source: caller,\r\n target: ident.text,\r\n filePath,\r\n line: child.startPosition.row + 1,\r\n });\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // State variable declarations → Function nodes\r\n if (nodeType === 'state_variable_declaration' && enclosingClass) {\r\n let varName: string | null = null;\r\n let varVisibility: string | null = null;\r\n let varType: string | null = null;\r\n let varMutability: string | null = null;\r\n\r\n for (const sub of child.children) {\r\n if (sub.type === 'identifier') { varName = sub.text; }\r\n else if (sub.type === 'visibility') { varVisibility = sub.text; }\r\n else if (sub.type === 'type_name') { varType = sub.text; }\r\n else if (sub.type === 'constant' || sub.type === 'immutable') {\r\n varMutability = sub.type;\r\n }\r\n }\r\n if (varName) {\r\n const qualified = this._qualify(varName, filePath, enclosingClass);\r\n nodes.push({\r\n kind: 'Function',\r\n name: varName,\r\n filePath,\r\n lineStart: child.startPosition.row + 1,\r\n lineEnd: child.endPosition.row + 1,\r\n language,\r\n parentName: enclosingClass,\r\n returnType: varType,\r\n modifiers: varVisibility,\r\n extra: { solidity_kind: 'state_variable', mutability: varMutability },\r\n });\r\n edges.push({\r\n kind: 'CONTAINS',\r\n source: this._qualify(enclosingClass, filePath, null),\r\n target: qualified,\r\n filePath,\r\n line: child.startPosition.row + 1,\r\n });\r\n continue;\r\n }\r\n }\r\n\r\n // Constant variable declarations\r\n if (nodeType === 'constant_variable_declaration') {\r\n let varName: string | null = null;\r\n let varType: string | null = null;\r\n for (const sub of child.children) {\r\n if (sub.type === 'identifier') { varName = sub.text; }\r\n else if (sub.type === 'type_name') { varType = sub.text; }\r\n }\r\n if (varName) {\r\n const qualified = this._qualify(varName, filePath, enclosingClass ?? null);\r\n nodes.push({\r\n kind: 'Function',\r\n name: varName,\r\n filePath,\r\n lineStart: child.startPosition.row + 1,\r\n lineEnd: child.endPosition.row + 1,\r\n language,\r\n parentName: enclosingClass ?? null,\r\n returnType: varType,\r\n extra: { solidity_kind: 'constant' },\r\n });\r\n const container = enclosingClass\r\n ? this._qualify(enclosingClass, filePath, null)\r\n : filePath;\r\n edges.push({\r\n kind: 'CONTAINS',\r\n source: container,\r\n target: qualified,\r\n filePath,\r\n line: child.startPosition.row + 1,\r\n });\r\n continue;\r\n }\r\n }\r\n\r\n // Using directives → DEPENDS_ON edge\r\n if (nodeType === 'using_directive') {\r\n let libName: string | null = null;\r\n for (const sub of child.children) {\r\n if (sub.type === 'type_alias') {\r\n for (const ident of sub.children) {\r\n if (ident.type === 'identifier') { libName = ident.text; break; }\r\n }\r\n }\r\n }\r\n if (libName) {\r\n const sourceName = enclosingClass\r\n ? this._qualify(enclosingClass, filePath, null)\r\n : filePath;\r\n edges.push({\r\n kind: 'DEPENDS_ON',\r\n source: sourceName,\r\n target: libName,\r\n filePath,\r\n line: child.startPosition.row + 1,\r\n });\r\n }\r\n continue;\r\n }\r\n }\r\n\r\n // Recurse for other node types\r\n this._extractFromTree(\r\n child, source, language, filePath, nodes, edges,\r\n enclosingClass, enclosingFunc, importMap, definedNames, depth + 1,\r\n );\r\n }\r\n }\r\n\r\n private _collectFileScope(\r\n root: SyntaxNode,\r\n language: string,\r\n source: Buffer,\r\n ): [Map<string, string>, Set<string>] {\r\n const importMap = new Map<string, string>();\r\n const definedNames = new Set<string>();\r\n\r\n const classTypes = new Set(CLASS_TYPES[language] ?? []);\r\n const funcTypes = new Set(FUNCTION_TYPES[language] ?? []);\r\n const importTypes = new Set(IMPORT_TYPES[language] ?? []);\r\n const decoratorWrappers = new Set(['decorated_definition', 'decorator']);\r\n\r\n for (const child of root.children) {\r\n const nodeType: string = child.type;\r\n\r\n // Unwrap decorator wrappers\r\n let target = child;\r\n if (decoratorWrappers.has(nodeType)) {\r\n for (const inner of child.children) {\r\n if (funcTypes.has(inner.type) || classTypes.has(inner.type)) {\r\n target = inner;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n const targetType: string = target.type;\r\n\r\n if (funcTypes.has(targetType) || classTypes.has(targetType)) {\r\n const name = this._getName(\r\n target, language, classTypes.has(targetType) ? 'class' : 'function',\r\n );\r\n if (name) { definedNames.add(name); }\r\n }\r\n\r\n if (importTypes.has(nodeType)) {\r\n this._collectImportNames(child, language, source, importMap);\r\n }\r\n }\r\n\r\n return [importMap, definedNames];\r\n }\r\n\r\n private _collectImportNames(\r\n node: SyntaxNode,\r\n language: string,\r\n _source: Buffer,\r\n importMap: Map<string, string>,\r\n ): void {\r\n if (language === 'python') {\r\n if (node.type === 'import_from_statement') {\r\n let module: string | null = null;\r\n let seenImport = false;\r\n for (const child of node.children) {\r\n if (child.type === 'dotted_name' && !seenImport) {\r\n module = child.text;\r\n } else if (child.type === 'import') {\r\n seenImport = true;\r\n } else if (seenImport && module) {\r\n if (child.type === 'identifier' || child.type === 'dotted_name') {\r\n importMap.set(child.text, module);\r\n } else if (child.type === 'aliased_import') {\r\n const names = child.children\r\n .filter((c: SyntaxNode) =>\r\n c.type === 'identifier' || c.type === 'dotted_name'\r\n )\r\n .map((c: SyntaxNode) => c.text as string);\r\n if (names.length > 0) { importMap.set(names[names.length - 1]!, module); }\r\n }\r\n }\r\n }\r\n }\r\n } else if (language === 'javascript' || language === 'typescript' || language === 'tsx') {\r\n let module: string | null = null;\r\n for (const child of node.children) {\r\n if (child.type === 'string') {\r\n module = (child.text as string).replace(/^['\"]|['\"]$/g, '');\r\n }\r\n }\r\n if (module) {\r\n for (const child of node.children) {\r\n if (child.type === 'import_clause') {\r\n this._collectJsImportNames(child, module, importMap);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _collectJsImportNames(\r\n clauseNode: SyntaxNode,\r\n module: string,\r\n importMap: Map<string, string>,\r\n ): void {\r\n for (const child of clauseNode.children) {\r\n if (child.type === 'identifier') {\r\n importMap.set(child.text, module);\r\n } else if (child.type === 'named_imports') {\r\n for (const spec of child.children) {\r\n if (spec.type === 'import_specifier') {\r\n const names = spec.children\r\n .filter((s: SyntaxNode) =>\r\n s.type === 'identifier' || s.type === 'property_identifier'\r\n )\r\n .map((s: SyntaxNode) => s.text as string);\r\n if (names.length > 0) { importMap.set(names[names.length - 1]!, module); }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _resolveModuleToFile(\r\n module: string,\r\n filePath: string,\r\n language: string,\r\n ): string | null {\r\n const callerDir = path.dirname(filePath);\r\n const cacheKey = `${language}:${callerDir}:${module}`;\r\n if (this.moduleFileCache.has(cacheKey)) {\r\n return this.moduleFileCache.get(cacheKey) ?? null;\r\n }\r\n\r\n const resolved = this._doResolveModule(module, filePath, language);\r\n if (this.moduleFileCache.size >= MODULE_CACHE_MAX) {\r\n this.moduleFileCache.clear();\r\n }\r\n this.moduleFileCache.set(cacheKey, resolved);\r\n return resolved;\r\n }\r\n\r\n private _doResolveModule(\r\n module: string,\r\n filePath: string,\r\n language: string,\r\n ): string | null {\r\n const callerDir = path.dirname(filePath);\r\n\r\n if (language === 'python') {\r\n const relPath = module.replace(/\\./g, '/');\r\n const candidates = [`${relPath}.py`, `${relPath}/__init__.py`];\r\n let current = callerDir;\r\n // eslint-disable-next-line no-constant-condition\r\n while (true) {\r\n for (const candidate of candidates) {\r\n const target = path.join(current, candidate);\r\n if (fs.existsSync(target)) { return path.resolve(target); }\r\n }\r\n const parent = path.dirname(current);\r\n if (parent === current) { break; }\r\n current = parent;\r\n }\r\n } else if (\r\n language === 'javascript' || language === 'typescript' ||\r\n language === 'tsx' || language === 'vue'\r\n ) {\r\n if (module.startsWith('.')) {\r\n const base = path.join(callerDir, module);\r\n const extensions = ['.ts', '.tsx', '.js', '.jsx', '.vue'];\r\n if (fs.existsSync(base) && fs.statSync(base).isFile()) {\r\n return path.resolve(base);\r\n }\r\n for (const ext of extensions) {\r\n const target = base + ext;\r\n if (fs.existsSync(target)) { return path.resolve(target); }\r\n }\r\n // Try index file in directory\r\n if (fs.existsSync(base) && fs.statSync(base).isDirectory()) {\r\n for (const ext of extensions) {\r\n const target = path.join(base, `index${ext}`);\r\n if (fs.existsSync(target)) { return path.resolve(target); }\r\n }\r\n }\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n private _resolveCallTarget(\r\n callName: string,\r\n filePath: string,\r\n language: string,\r\n importMap: Map<string, string>,\r\n definedNames: Set<string>,\r\n ): string {\r\n if (definedNames.has(callName)) {\r\n return this._qualify(callName, filePath, null);\r\n }\r\n const importedFrom = importMap.get(callName);\r\n if (importedFrom) {\r\n const resolved = this._resolveModuleToFile(importedFrom, filePath, language);\r\n if (resolved) { return this._qualify(callName, resolved, null); }\r\n }\r\n return callName;\r\n }\r\n\r\n private _qualify(name: string, filePath: string, enclosingClass: string | null): string {\r\n if (enclosingClass) { return `${filePath}::${enclosingClass}.${name}`; }\r\n return `${filePath}::${name}`;\r\n }\r\n\r\n private _getName(node: SyntaxNode, language: string, kind: string): string | null {\r\n // Solidity: constructor and receive/fallback have no identifier child\r\n if (language === 'solidity') {\r\n if (node.type === 'constructor_definition') { return 'constructor'; }\r\n if (node.type === 'fallback_receive_definition') {\r\n for (const child of node.children) {\r\n if (child.type === 'receive' || child.type === 'fallback') {\r\n return child.text;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // C/C++: function names are inside function_declarator/pointer_declarator\r\n if ((language === 'c' || language === 'cpp') && kind === 'function') {\r\n for (const child of node.children) {\r\n if (child.type === 'function_declarator' || child.type === 'pointer_declarator') {\r\n const result = this._getName(child, language, kind);\r\n if (result) { return result; }\r\n }\r\n }\r\n }\r\n\r\n // Most languages: look for identifier child\r\n for (const child of node.children) {\r\n if ([\r\n 'identifier', 'name', 'type_identifier', 'property_identifier',\r\n 'simple_identifier', 'constant',\r\n ].includes(child.type)) {\r\n return child.text;\r\n }\r\n }\r\n\r\n // Go type declarations: look for type_spec\r\n if (language === 'go' && node.type === 'type_declaration') {\r\n for (const child of node.children) {\r\n if (child.type === 'type_spec') {\r\n return this._getName(child, language, kind);\r\n }\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n private _getParams(node: SyntaxNode, language: string): string | null {\r\n for (const child of node.children) {\r\n if (['parameters', 'formal_parameters', 'parameter_list'].includes(child.type)) {\r\n return child.text;\r\n }\r\n }\r\n if (language === 'solidity') {\r\n const params = node.children\r\n .filter((c: SyntaxNode) => c.type === 'parameter')\r\n .map((c: SyntaxNode) => c.text as string);\r\n if (params.length > 0) { return `(${params.join(', ')})`; }\r\n }\r\n return null;\r\n }\r\n\r\n private _getReturnType(node: SyntaxNode, language: string): string | null {\r\n for (const child of node.children) {\r\n if ([\r\n 'type', 'return_type', 'type_annotation', 'return_type_definition',\r\n ].includes(child.type)) {\r\n return child.text;\r\n }\r\n }\r\n if (language === 'python') {\r\n for (let i = 0; i < node.children.length - 1; i++) {\r\n if (node.children[i].type === '->') {\r\n return node.children[i + 1].text;\r\n }\r\n }\r\n }\r\n return null;\r\n }\r\n\r\n private _getBases(node: SyntaxNode, language: string): string[] {\r\n const bases: string[] = [];\r\n\r\n if (language === 'python') {\r\n for (const child of node.children) {\r\n if (child.type === 'argument_list') {\r\n for (const arg of child.children) {\r\n if (arg.type === 'identifier' || arg.type === 'attribute') {\r\n bases.push(arg.text);\r\n }\r\n }\r\n }\r\n }\r\n } else if (\r\n language === 'java' || language === 'csharp' || language === 'kotlin'\r\n ) {\r\n for (const child of node.children) {\r\n if ([\r\n 'superclass', 'super_interfaces', 'extends_type', 'implements_type',\r\n 'type_identifier', 'supertype', 'delegation_specifier',\r\n ].includes(child.type)) {\r\n bases.push(child.text);\r\n }\r\n }\r\n } else if (language === 'cpp') {\r\n for (const child of node.children) {\r\n if (child.type === 'base_class_clause') {\r\n for (const sub of child.children) {\r\n if (sub.type === 'type_identifier') { bases.push(sub.text); }\r\n }\r\n }\r\n }\r\n } else if (\r\n language === 'typescript' || language === 'javascript' || language === 'tsx'\r\n ) {\r\n for (const child of node.children) {\r\n if (child.type === 'extends_clause' || child.type === 'implements_clause') {\r\n for (const sub of child.children) {\r\n if ([\r\n 'identifier', 'type_identifier', 'nested_identifier',\r\n ].includes(sub.type)) {\r\n bases.push(sub.text);\r\n }\r\n }\r\n }\r\n }\r\n } else if (language === 'solidity') {\r\n for (const child of node.children) {\r\n if (child.type === 'inheritance_specifier') {\r\n for (const sub of child.children) {\r\n if (sub.type === 'user_defined_type') {\r\n for (const ident of sub.children) {\r\n if (ident.type === 'identifier') { bases.push(ident.text); }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n } else if (language === 'go') {\r\n for (const child of node.children) {\r\n if (child.type === 'type_spec') {\r\n for (const sub of child.children) {\r\n if (sub.type === 'struct_type' || sub.type === 'interface_type') {\r\n for (const fieldNode of sub.children) {\r\n if (fieldNode.type === 'field_declaration_list') {\r\n for (const f of fieldNode.children) {\r\n if (f.type === 'type_identifier') { bases.push(f.text); }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n return bases;\r\n }\r\n\r\n private _extractImport(node: SyntaxNode, language: string): string[] {\r\n const imports: string[] = [];\r\n const text: string = node.text.trim();\r\n\r\n if (language === 'python') {\r\n if (node.type === 'import_from_statement') {\r\n for (const child of node.children) {\r\n if (child.type === 'dotted_name') {\r\n imports.push(child.text);\r\n break;\r\n }\r\n }\r\n } else {\r\n for (const child of node.children) {\r\n if (child.type === 'dotted_name') { imports.push(child.text); }\r\n }\r\n }\r\n } else if (\r\n language === 'javascript' || language === 'typescript' || language === 'tsx'\r\n ) {\r\n for (const child of node.children) {\r\n if (child.type === 'string') {\r\n imports.push((child.text as string).replace(/^['\"]|['\"]$/g, ''));\r\n }\r\n }\r\n } else if (language === 'go') {\r\n for (const child of node.children) {\r\n if (child.type === 'import_spec_list') {\r\n for (const spec of child.children) {\r\n if (spec.type === 'import_spec') {\r\n for (const s of spec.children) {\r\n if (s.type === 'interpreted_string_literal') {\r\n imports.push((s.text as string).replace(/^\"|\"$/g, ''));\r\n }\r\n }\r\n }\r\n }\r\n } else if (child.type === 'import_spec') {\r\n for (const s of child.children) {\r\n if (s.type === 'interpreted_string_literal') {\r\n imports.push((s.text as string).replace(/^\"|\"$/g, ''));\r\n }\r\n }\r\n }\r\n }\r\n } else if (language === 'rust') {\r\n imports.push(text.replace(/^use\\s+/, '').replace(/;$/, '').trim());\r\n } else if (language === 'c' || language === 'cpp') {\r\n for (const child of node.children) {\r\n if (child.type === 'system_lib_string' || child.type === 'string_literal') {\r\n imports.push((child.text as string).replace(/^[<\"\"]|[>\"\"]$/g, ''));\r\n }\r\n }\r\n } else if (language === 'java' || language === 'csharp') {\r\n const parts = text.split(/\\s+/);\r\n if (parts.length >= 2) {\r\n imports.push(parts[parts.length - 1]!.replace(/;$/, ''));\r\n }\r\n } else if (language === 'solidity') {\r\n for (const child of node.children) {\r\n if (child.type === 'string') {\r\n const val = (child.text as string).replace(/^\"|\"$/g, '');\r\n if (val) { imports.push(val); }\r\n }\r\n }\r\n } else if (language === 'ruby') {\r\n if (text.includes('require')) {\r\n const match = /['\"]([^'\"]+)['\"]/u.exec(text);\r\n if (match) { imports.push(match[1]!); }\r\n }\r\n } else {\r\n imports.push(text);\r\n }\r\n\r\n return imports;\r\n }\r\n\r\n private _getCallName(node: SyntaxNode, language: string): string | null {\r\n if (!node.children || node.children.length === 0) { return null; }\r\n\r\n let first: SyntaxNode = node.children[0];\r\n\r\n // Solidity wraps call targets in 'expression' — unwrap\r\n if (\r\n language === 'solidity' &&\r\n first.type === 'expression' &&\r\n first.children.length > 0\r\n ) {\r\n first = first.children[0];\r\n }\r\n\r\n if (first.type === 'identifier') { return first.text; }\r\n\r\n const memberTypes = [\r\n 'attribute', 'member_expression', 'field_expression', 'selector_expression',\r\n ];\r\n if (memberTypes.includes(first.type)) {\r\n for (let i = first.children.length - 1; i >= 0; i--) {\r\n const child: SyntaxNode = first.children[i];\r\n if ([\r\n 'identifier', 'property_identifier', 'field_identifier', 'field_name',\r\n ].includes(child.type)) {\r\n return child.text;\r\n }\r\n }\r\n return first.text;\r\n }\r\n\r\n if (first.type === 'scoped_identifier' || first.type === 'qualified_name') {\r\n return first.text;\r\n }\r\n\r\n return null;\r\n }\r\n}\r\n\r\n// Canonical export alias matching the file name\r\nexport { CodeParser as TreeSitterParser }\r\n","/**\n * Use cases: full build and incremental update of the knowledge graph.\n *\n * Extracted from incremental.ts (fullBuild, incrementalUpdate, findDependents)\n * + tools.ts (buildOrUpdateGraph).\n *\n * Accepts IParser and IGraphRepository as parameters for testability.\n * Imports file-system and git utilities from infrastructure.\n */\n\nimport crypto from 'node:crypto'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport type { BuildResult } from '../domain/types.js'\nimport type { IParser } from '../domain/ports/IParser.js'\nimport type { IGraphRepository } from '../domain/ports/IGraphRepository.js'\nimport {\n collectAllFiles,\n loadIgnorePatterns,\n shouldIgnore,\n} from '../infrastructure/FileSystemHelper.js'\nimport { getChangedFiles } from '../infrastructure/GitRunner.js'\n\n// ---------------------------------------------------------------------------\n// Full build\n// ---------------------------------------------------------------------------\n\nexport function fullBuild(\n repoRoot: string,\n repo: IGraphRepository,\n parser: IParser,\n): BuildResult {\n const files = collectAllFiles(repoRoot)\n\n // Purge stale data\n const existingFiles = new Set(repo.getAllFiles())\n const currentAbs = new Set(files.map((f) => path.join(repoRoot, f)))\n for (const stale of existingFiles) {\n if (!currentAbs.has(stale)) {\n repo.removeFileData(stale)\n }\n }\n\n let totalNodes = 0\n let totalEdges = 0\n const errors: string[] = []\n\n for (let i = 0; i < files.length; i++) {\n const relPath = files[i]!\n const fullPath = path.join(repoRoot, relPath)\n try {\n const source = fs.readFileSync(fullPath)\n const fhash = crypto.createHash('sha256').update(source).digest('hex')\n const [nodes, edges] = parser.parseBytes(fullPath, source)\n repo.storeFileNodesEdges(fullPath, nodes, edges, fhash)\n totalNodes += nodes.length\n totalEdges += edges.length\n } catch (err) {\n errors.push(`${relPath}: ${String(err)}`)\n }\n if ((i + 1) % 50 === 0 || i + 1 === files.length) {\n process.stderr.write(`Progress: ${i + 1}/${files.length} files parsed\\n`)\n }\n }\n\n repo.setMetadata('last_updated', new Date().toISOString().replace(/\\..+$/, ''))\n repo.setMetadata('last_build_type', 'full')\n\n return {\n buildType: 'full',\n filesUpdated: files.length,\n totalNodes,\n totalEdges,\n changedFiles: files,\n dependentFiles: [],\n errors,\n }\n}\n\n// ---------------------------------------------------------------------------\n// Incremental update\n// ---------------------------------------------------------------------------\n\nexport function incrementalUpdate(\n repoRoot: string,\n repo: IGraphRepository,\n parser: IParser,\n base = 'HEAD~1',\n changedFiles?: string[],\n): BuildResult {\n const ignorePatterns = loadIgnorePatterns(repoRoot)\n const changed = changedFiles ?? getChangedFiles(repoRoot, base)\n\n if (changed.length === 0) {\n return {\n buildType: 'incremental',\n filesUpdated: 0,\n totalNodes: 0,\n totalEdges: 0,\n changedFiles: [],\n dependentFiles: [],\n errors: [],\n }\n }\n\n const dependentFiles = new Set<string>()\n for (const relPath of changed) {\n const fullPath = path.join(repoRoot, relPath)\n const deps = findDependents(repo, fullPath)\n for (const d of deps) {\n try {\n dependentFiles.add(path.relative(repoRoot, d))\n } catch {\n dependentFiles.add(d)\n }\n }\n }\n\n const allFiles = new Set([...changed, ...dependentFiles])\n let totalNodes = 0\n let totalEdges = 0\n const errors: string[] = []\n\n for (const relPath of allFiles) {\n if (shouldIgnore(relPath, ignorePatterns)) { continue }\n const absPath = path.join(repoRoot, relPath)\n\n if (!fs.existsSync(absPath)) {\n repo.removeFileData(absPath)\n continue\n }\n if (!parser.detectLanguage(absPath)) { continue }\n\n try {\n const source = fs.readFileSync(absPath)\n const fhash = crypto.createHash('sha256').update(source).digest('hex')\n const existingNodes = repo.getNodesByFile(absPath)\n if (existingNodes.length > 0 && existingNodes[0]!.fileHash === fhash) {\n continue\n }\n const [nodes, edges] = parser.parseBytes(absPath, source)\n repo.storeFileNodesEdges(absPath, nodes, edges, fhash)\n totalNodes += nodes.length\n totalEdges += edges.length\n } catch (err) {\n errors.push(`${relPath}: ${String(err)}`)\n }\n }\n\n repo.setMetadata('last_updated', new Date().toISOString().replace(/\\..+$/, ''))\n repo.setMetadata('last_build_type', 'incremental')\n\n return {\n buildType: 'incremental',\n filesUpdated: allFiles.size,\n totalNodes,\n totalEdges,\n changedFiles: changed,\n dependentFiles: [...dependentFiles],\n errors,\n }\n}\n\n// ---------------------------------------------------------------------------\n// Private helper\n// ---------------------------------------------------------------------------\n\nfunction findDependents(repo: IGraphRepository, filePath: string): string[] {\n const dependents = new Set<string>()\n\n for (const e of repo.getEdgesByTarget(filePath)) {\n if (e.kind === 'IMPORTS_FROM') {\n dependents.add(e.filePath)\n }\n }\n\n for (const node of repo.getNodesByFile(filePath)) {\n for (const e of repo.getEdgesByTarget(node.qualifiedName)) {\n if (['CALLS', 'IMPORTS_FROM', 'INHERITS', 'IMPLEMENTS'].includes(e.kind)) {\n dependents.add(e.filePath)\n }\n }\n }\n\n dependents.delete(filePath)\n return [...dependents]\n}\n","/**\n * File-system infrastructure helpers.\n *\n * Extracted from incremental.ts: findRepoRoot, findProjectRoot, getDbPath,\n * loadIgnorePatterns, shouldIgnore, isBinary, walkDir, collectAllFiles.\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport micromatch from 'micromatch'\nimport { CodeParser } from './TreeSitterParser.js'\nimport { getAllTrackedFiles } from './GitRunner.js'\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nexport const DEFAULT_IGNORE_PATTERNS = [\n '.codeorbit/**',\n 'node_modules/**',\n '.git/**',\n '__pycache__/**',\n '*.pyc',\n '.venv/**',\n 'venv/**',\n 'dist/**',\n 'build/**',\n '.next/**',\n 'target/**',\n '*.min.js',\n '*.min.css',\n '*.map',\n '*.lock',\n 'package-lock.json',\n 'yarn.lock',\n '*.db',\n '*.sqlite',\n '*.db-journal',\n '*.db-wal',\n]\n\nexport const PRUNE_DIRS = new Set([\n 'node_modules', '.git', '__pycache__', '.next', '.nuxt', '.svelte-kit',\n 'dist', 'build', '.venv', 'venv', 'env', 'target', '.mypy_cache',\n '.pytest_cache', 'coverage', '.tox', '.cache', '.tmp', 'tmp', 'temp',\n 'vendor', 'Pods', 'DerivedData', '.gradle', '.idea', '.vs',\n])\n\nexport const DEBOUNCE_MS = 300\n\n// ---------------------------------------------------------------------------\n// Repo / DB path discovery\n// ---------------------------------------------------------------------------\n\nexport function findRepoRoot(start?: string): string | undefined {\n let current = start ?? process.cwd()\n while (true) {\n if (fs.existsSync(path.join(current, '.git'))) {\n return current\n }\n const parent = path.dirname(current)\n if (parent === current) { break }\n current = parent\n }\n return undefined\n}\n\nexport function findProjectRoot(start?: string): string {\n return findRepoRoot(start) ?? start ?? process.cwd()\n}\n\nexport function getDbPath(repoRoot: string): string {\n const crgDir = path.join(repoRoot, '.codeorbit')\n const newDb = path.join(crgDir, 'graph.db')\n\n if (!fs.existsSync(crgDir)) {\n fs.mkdirSync(crgDir, { recursive: true })\n }\n\n const innerGitignore = path.join(crgDir, '.gitignore')\n if (!fs.existsSync(innerGitignore)) {\n fs.writeFileSync(\n innerGitignore,\n '# Auto-generated by codeorbit — do not commit database files.\\n' +\n '# The graph.db contains absolute paths and code structure metadata.\\n' +\n '*\\n',\n )\n }\n\n const legacyDb = path.join(repoRoot, '.codeorbit.db')\n if (fs.existsSync(legacyDb) && !fs.existsSync(newDb)) {\n fs.renameSync(legacyDb, newDb)\n }\n for (const suffix of ['-wal', '-shm', '-journal']) {\n const side = legacyDb + suffix\n if (fs.existsSync(side)) {\n try { fs.unlinkSync(side) } catch { /* ignore */ }\n }\n }\n\n return newDb\n}\n\n// ---------------------------------------------------------------------------\n// Ignore patterns\n// ---------------------------------------------------------------------------\n\nexport function loadIgnorePatterns(repoRoot: string): string[] {\n const patterns = [...DEFAULT_IGNORE_PATTERNS]\n const ignoreFile = path.join(repoRoot, '.codeorbitignore')\n if (fs.existsSync(ignoreFile)) {\n for (const line of fs.readFileSync(ignoreFile, 'utf-8').split('\\n')) {\n const trimmed = line.trim()\n if (trimmed && !trimmed.startsWith('#')) {\n patterns.push(trimmed)\n }\n }\n }\n return patterns\n}\n\nexport function shouldIgnore(filePath: string, patterns: string[]): boolean {\n return micromatch.isMatch(filePath, patterns)\n}\n\nexport function isBinary(filePath: string): boolean {\n try {\n const chunk = Buffer.alloc(8192)\n const fd = fs.openSync(filePath, 'r')\n const bytesRead = fs.readSync(fd, chunk, 0, 8192, 0)\n fs.closeSync(fd)\n return chunk.slice(0, bytesRead).includes(0)\n } catch {\n return true\n }\n}\n\n// ---------------------------------------------------------------------------\n// File collection\n// ---------------------------------------------------------------------------\n\nfunction walkDir(dir: string, repoRoot: string): string[] {\n const files: string[] = []\n const entries = fs.readdirSync(dir, { withFileTypes: true })\n for (const entry of entries) {\n if (entry.isDirectory()) {\n if (PRUNE_DIRS.has(entry.name)) { continue }\n files.push(...walkDir(path.join(dir, entry.name), repoRoot))\n } else if (entry.isFile()) {\n const rel = path.relative(repoRoot, path.join(dir, entry.name))\n files.push(rel)\n }\n }\n return files\n}\n\nexport function collectAllFiles(repoRoot: string): string[] {\n const ignorePatterns = loadIgnorePatterns(repoRoot)\n const parser = new CodeParser()\n const files: string[] = []\n\n const tracked = getAllTrackedFiles(repoRoot)\n const candidates = tracked.length > 0 ? tracked : walkDir(repoRoot, repoRoot)\n\n for (const relPath of candidates) {\n if (shouldIgnore(relPath, ignorePatterns)) { continue }\n const fullPath = path.join(repoRoot, relPath)\n\n let stat: fs.Stats\n try {\n stat = fs.lstatSync(fullPath)\n } catch {\n continue\n }\n\n if (!stat.isFile() || stat.isSymbolicLink()) { continue }\n if (!parser.detectLanguage(fullPath)) { continue }\n if (isBinary(fullPath)) { continue }\n files.push(relPath)\n }\n\n return files\n}\n","/**\n * Git operations infrastructure.\n *\n * Extracted from incremental.ts: gitRun, getChangedFiles, getStagedAndUnstaged,\n * getAllTrackedFiles.\n */\n\nimport { spawnSync } from 'node:child_process'\n\nexport const GIT_TIMEOUT_MS = Number(process.env['CRG_GIT_TIMEOUT'] ?? 30) * 1000\n\nfunction gitRun(args: string[], cwd: string): string {\n const result = spawnSync('git', args, {\n cwd,\n encoding: 'utf-8',\n timeout: GIT_TIMEOUT_MS,\n stdio: ['ignore', 'pipe', 'ignore'],\n })\n if (result.error || result.status !== 0) {\n return ''\n }\n return result.stdout ?? ''\n}\n\nexport function getChangedFiles(repoRoot: string, base = 'HEAD~1'): string[] {\n let output = gitRun(['diff', '--name-only', base], repoRoot)\n if (!output.trim()) {\n output = gitRun(['diff', '--name-only', '--cached'], repoRoot)\n }\n return output\n .split('\\n')\n .map((f) => f.trim())\n .filter(Boolean)\n}\n\nexport function getStagedAndUnstaged(repoRoot: string): string[] {\n const output = gitRun(['status', '--porcelain'], repoRoot)\n const files: string[] = []\n for (const line of output.split('\\n')) {\n if (line.length > 3) {\n let entry = line.slice(3).trim()\n if (entry.includes(' -> ')) {\n entry = entry.split(' -> ')[1]!\n }\n files.push(entry)\n }\n }\n return files\n}\n\nexport function getAllTrackedFiles(repoRoot: string): string[] {\n const output = gitRun(['ls-files'], repoRoot)\n return output\n .split('\\n')\n .map((f) => f.trim())\n .filter(Boolean)\n}\n"],"mappings":";AASA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,cAAc;AAsBrB,IAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AAO,QAAQ;AAC1B,SAAO,CAAC,GAAG,UAAU;AACvB;","names":["fileHash","fs","path","crypto","fs","path","fs","path","fs","path","path","fs","path","fs","crypto"]}
|
|
1
|
+
{"version":3,"sources":["../src/infrastructure/SqliteGraphRepository.ts","../src/infrastructure/TreeSitterParser.ts","../src/usecases/buildGraph.ts","../src/infrastructure/FileSystemHelper.ts","../src/infrastructure/GitRunner.ts"],"sourcesContent":["/**\n * SQLite-backed knowledge graph storage — infrastructure implementation.\n *\n * Implements IGraphRepository. Pure CRUD + adjacency — no business logic.\n * BFS impact-radius computation was extracted to usecases/getImpactRadius.ts.\n *\n * Direct port of code_review_graph/graph.py.\n */\n\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport Database from 'better-sqlite3';\nimport type {\n NodeInfo,\n EdgeInfo,\n GraphNode,\n GraphEdge,\n GraphStats,\n NodeRow,\n EdgeRow,\n CountRow,\n KindCountRow,\n LanguageRow,\n FilePathRow,\n MetadataRow,\n EdgeKind,\n} from '../domain/types.js';\nimport type { IGraphRepository } from '../domain/ports/IGraphRepository.js';\n\n// ---------------------------------------------------------------------------\n// Schema DDL — must match Python's _SCHEMA_SQL exactly (schema_version = 1)\n// ---------------------------------------------------------------------------\n\nconst SCHEMA_SQL = `\nCREATE TABLE IF NOT EXISTS nodes (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n kind TEXT NOT NULL,\n name TEXT NOT NULL,\n qualified_name TEXT NOT NULL UNIQUE,\n file_path TEXT NOT NULL,\n line_start INTEGER,\n line_end INTEGER,\n language TEXT,\n parent_name TEXT,\n params TEXT,\n return_type TEXT,\n modifiers TEXT,\n is_test INTEGER DEFAULT 0,\n file_hash TEXT,\n extra TEXT DEFAULT '{}',\n updated_at REAL NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS edges (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n kind TEXT NOT NULL,\n source_qualified TEXT NOT NULL,\n target_qualified TEXT NOT NULL,\n file_path TEXT NOT NULL,\n line INTEGER DEFAULT 0,\n extra TEXT DEFAULT '{}',\n updated_at REAL NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS metadata (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS idx_nodes_file ON nodes(file_path);\nCREATE INDEX IF NOT EXISTS idx_nodes_kind ON nodes(kind);\nCREATE INDEX IF NOT EXISTS idx_nodes_qualified ON nodes(qualified_name);\nCREATE INDEX IF NOT EXISTS idx_edges_source ON edges(source_qualified);\nCREATE INDEX IF NOT EXISTS idx_edges_target ON edges(target_qualified);\nCREATE INDEX IF NOT EXISTS idx_edges_kind ON edges(kind);\nCREATE INDEX IF NOT EXISTS idx_edges_file ON edges(file_path);\n`;\n\n// ---------------------------------------------------------------------------\n// In-memory adjacency cache (replaces networkx.DiGraph)\n// ---------------------------------------------------------------------------\n\ninterface AdjacencyCache {\n out: Map<string, Set<string>>;\n in: Map<string, Set<string>>;\n}\n\n// ---------------------------------------------------------------------------\n// SqliteGraphRepository\n// ---------------------------------------------------------------------------\n\nexport class SqliteGraphRepository implements IGraphRepository {\n private db: Database.Database;\n private adjCache: AdjacencyCache | null = null;\n readonly dbPath: string;\n\n constructor(dbPath: string) {\n this.dbPath = dbPath;\n const dir = path.dirname(dbPath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n this.db = new Database(dbPath);\n this.db.pragma('journal_mode = WAL');\n this.db.pragma('busy_timeout = 5000');\n\n try {\n this.db.pragma('wal_checkpoint(TRUNCATE)');\n } catch {\n // ignore — safe to skip if another writer holds it\n }\n\n this._initSchema();\n }\n\n close(): void {\n try {\n this.db.pragma('wal_checkpoint(TRUNCATE)');\n } catch {\n // ignore\n }\n this.db.close();\n for (const suffix of ['-wal', '-shm']) {\n const side = this.dbPath + suffix;\n try {\n if (fs.existsSync(side)) { fs.unlinkSync(side); }\n } catch {\n // locked by another process — leave it alone\n }\n }\n }\n\n // ---------------------------------------------------------------------------\n // Write operations\n // ---------------------------------------------------------------------------\n\n upsertNode(node: NodeInfo, fileHash = ''): number {\n const now = Date.now() / 1000;\n const qualified = this._makeQualified(node);\n const extra = node.extra ? JSON.stringify(node.extra) : '{}';\n\n this.db.prepare(`\n INSERT INTO nodes\n (kind, name, qualified_name, file_path, line_start, line_end,\n language, parent_name, params, return_type, modifiers, is_test,\n file_hash, extra, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(qualified_name) DO UPDATE SET\n kind=excluded.kind, name=excluded.name,\n file_path=excluded.file_path, line_start=excluded.line_start,\n line_end=excluded.line_end, language=excluded.language,\n parent_name=excluded.parent_name, params=excluded.params,\n return_type=excluded.return_type, modifiers=excluded.modifiers,\n is_test=excluded.is_test, file_hash=excluded.file_hash,\n extra=excluded.extra, updated_at=excluded.updated_at\n `).run(\n node.kind, node.name, qualified, node.filePath,\n node.lineStart, node.lineEnd, node.language ?? null,\n node.parentName ?? null, node.params ?? null, node.returnType ?? null,\n node.modifiers ?? null, node.isTest ? 1 : 0, fileHash,\n extra, now,\n );\n\n const row = this.db.prepare(\n 'SELECT id FROM nodes WHERE qualified_name = ?'\n ).get(qualified) as { id: number };\n return row.id;\n }\n\n upsertEdge(edge: EdgeInfo): number {\n const now = Date.now() / 1000;\n const extra = edge.extra ? JSON.stringify(edge.extra) : '{}';\n const line = edge.line ?? 0;\n\n const existing = this.db.prepare(`\n SELECT id FROM edges\n WHERE kind=? AND source_qualified=? AND target_qualified=?\n AND file_path=? AND line=?\n `).get(edge.kind, edge.source, edge.target, edge.filePath, line) as\n { id: number } | undefined;\n\n if (existing) {\n this.db.prepare(\n 'UPDATE edges SET line=?, extra=?, updated_at=? WHERE id=?'\n ).run(line, extra, now, existing.id);\n return existing.id;\n }\n\n const result = this.db.prepare(`\n INSERT INTO edges\n (kind, source_qualified, target_qualified, file_path, line, extra, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?)\n `).run(edge.kind, edge.source, edge.target, edge.filePath, line, extra, now);\n return Number(result.lastInsertRowid);\n }\n\n removeFileData(filePath: string): void {\n this.db.prepare('DELETE FROM nodes WHERE file_path = ?').run(filePath);\n this.db.prepare('DELETE FROM edges WHERE file_path = ?').run(filePath);\n this._invalidateCache();\n }\n\n storeFileNodesEdges(\n filePath: string,\n nodes: NodeInfo[],\n edges: EdgeInfo[],\n fileHash = '',\n ): void {\n const txn = this.db.transaction(() => {\n this.removeFileData(filePath);\n for (const node of nodes) { this.upsertNode(node, fileHash); }\n for (const edge of edges) { this.upsertEdge(edge); }\n });\n txn();\n this._invalidateCache();\n }\n\n setMetadata(key: string, value: string): void {\n this.db.prepare(\n 'INSERT OR REPLACE INTO metadata (key, value) VALUES (?, ?)'\n ).run(key, value);\n }\n\n getMetadata(key: string): string | undefined {\n const row = this.db.prepare(\n 'SELECT value FROM metadata WHERE key = ?'\n ).get(key) as MetadataRow | undefined;\n return row?.value;\n }\n\n // ---------------------------------------------------------------------------\n // Read operations\n // ---------------------------------------------------------------------------\n\n getNode(qualifiedName: string): GraphNode | undefined {\n const row = this.db.prepare(\n 'SELECT * FROM nodes WHERE qualified_name = ?'\n ).get(qualifiedName) as NodeRow | undefined;\n return row ? this._rowToNode(row) : undefined;\n }\n\n getNodesByFile(filePath: string): GraphNode[] {\n const rows = this.db.prepare(\n 'SELECT * FROM nodes WHERE file_path = ? ORDER BY line_start'\n ).all(filePath) as NodeRow[];\n return rows.map((r) => this._rowToNode(r));\n }\n\n getEdgesBySource(qualifiedName: string): GraphEdge[] {\n const rows = this.db.prepare(\n 'SELECT * FROM edges WHERE source_qualified = ?'\n ).all(qualifiedName) as EdgeRow[];\n return rows.map((r) => this._rowToEdge(r));\n }\n\n getEdgesByTarget(qualifiedName: string): GraphEdge[] {\n const rows = this.db.prepare(\n 'SELECT * FROM edges WHERE target_qualified = ?'\n ).all(qualifiedName) as EdgeRow[];\n return rows.map((r) => this._rowToEdge(r));\n }\n\n searchEdgesByTargetName(name: string, kind: EdgeKind = 'CALLS'): GraphEdge[] {\n const rows = this.db.prepare(\n 'SELECT * FROM edges WHERE target_qualified = ? AND kind = ?'\n ).all(name, kind) as EdgeRow[];\n return rows.map((r) => this._rowToEdge(r));\n }\n\n getAllFiles(): string[] {\n const rows = this.db.prepare(\n \"SELECT DISTINCT file_path FROM nodes WHERE kind = 'File' ORDER BY file_path\"\n ).all() as FilePathRow[];\n return rows.map((r) => r.file_path);\n }\n\n searchNodes(query: string, limit = 20): GraphNode[] {\n const words = query.toLowerCase().split(/\\s+/).filter(Boolean);\n if (words.length === 0) { return []; }\n\n const conditions = words.map(\n () => '(LOWER(name) LIKE ? OR LOWER(qualified_name) LIKE ?)'\n );\n const params: Array<string | number> = [];\n for (const word of words) {\n params.push(`%${word}%`, `%${word}%`);\n }\n params.push(limit);\n\n const where = conditions.join(' AND ');\n // nosec: all values are parameterised\n const rows = this.db.prepare(\n `SELECT * FROM nodes WHERE ${where} LIMIT ?`\n ).all(...params) as NodeRow[];\n return rows.map((r) => this._rowToNode(r));\n }\n\n getSubgraph(qualifiedNames: string[]): { nodes: GraphNode[]; edges: GraphEdge[] } {\n const nodes: GraphNode[] = [];\n for (const qn of qualifiedNames) {\n const n = this.getNode(qn);\n if (n) { nodes.push(n); }\n }\n const qnSet = new Set(qualifiedNames);\n const edges: GraphEdge[] = [];\n for (const qn of qualifiedNames) {\n for (const e of this.getEdgesBySource(qn)) {\n if (qnSet.has(e.targetQualified)) { edges.push(e); }\n }\n }\n return { nodes, edges };\n }\n\n getStats(): GraphStats {\n const totalNodes = (\n this.db.prepare('SELECT COUNT(*) AS cnt FROM nodes').get() as CountRow\n ).cnt;\n const totalEdges = (\n this.db.prepare('SELECT COUNT(*) AS cnt FROM edges').get() as CountRow\n ).cnt;\n\n const nodesByKind: Record<string, number> = {};\n for (const r of this.db.prepare(\n 'SELECT kind, COUNT(*) AS cnt FROM nodes GROUP BY kind'\n ).all() as KindCountRow[]) {\n nodesByKind[r.kind] = r.cnt;\n }\n\n const edgesByKind: Record<string, number> = {};\n for (const r of this.db.prepare(\n 'SELECT kind, COUNT(*) AS cnt FROM edges GROUP BY kind'\n ).all() as KindCountRow[]) {\n edgesByKind[r.kind] = r.cnt;\n }\n\n const languages = (this.db.prepare(\n \"SELECT DISTINCT language FROM nodes WHERE language IS NOT NULL AND language != ''\"\n ).all() as LanguageRow[]).map((r) => r.language);\n\n const filesCount = (this.db.prepare(\n \"SELECT COUNT(*) AS cnt FROM nodes WHERE kind = 'File'\"\n ).get() as CountRow).cnt;\n\n const lastUpdated = this.getMetadata('last_updated') ?? null;\n\n let embeddingsCount = 0;\n try {\n embeddingsCount = (\n this.db.prepare('SELECT COUNT(*) AS cnt FROM embeddings').get() as CountRow\n ).cnt;\n } catch {\n // embeddings table may not exist — that is fine\n }\n\n return {\n totalNodes, totalEdges, nodesByKind, edgesByKind,\n languages, filesCount, lastUpdated, embeddingsCount,\n };\n }\n\n getNodesBySize(\n minLines = 50,\n maxLines?: number,\n kind?: string,\n filePathPattern?: string,\n limit = 50,\n ): Array<GraphNode & { lineCount: number }> {\n const conditions = [\n 'line_start IS NOT NULL',\n 'line_end IS NOT NULL',\n '(line_end - line_start + 1) >= ?',\n ];\n const params: Array<string | number> = [minLines];\n\n if (maxLines !== undefined) {\n conditions.push('(line_end - line_start + 1) <= ?');\n params.push(maxLines);\n }\n if (kind) { conditions.push('kind = ?'); params.push(kind); }\n if (filePathPattern) {\n conditions.push('file_path LIKE ?');\n params.push(`%${filePathPattern}%`);\n }\n params.push(limit);\n const where = conditions.join(' AND ');\n // nosec: all values are parameterised\n const rows = this.db.prepare(\n `SELECT * FROM nodes WHERE ${where} ORDER BY (line_end - line_start + 1) DESC LIMIT ?`\n ).all(...params) as NodeRow[];\n return rows.map((r) => ({\n ...this._rowToNode(r),\n lineCount:\n r.line_start != null && r.line_end != null\n ? r.line_end - r.line_start + 1\n : 0,\n }));\n }\n\n getAllEdges(): GraphEdge[] {\n const rows = this.db.prepare('SELECT * FROM edges').all() as EdgeRow[];\n return rows.map((r) => this._rowToEdge(r));\n }\n\n getEdgesAmong(qualifiedNames: Set<string>): GraphEdge[] {\n if (qualifiedNames.size === 0) { return []; }\n const qns = [...qualifiedNames];\n const results: GraphEdge[] = [];\n const batchSize = 450;\n\n for (let i = 0; i < qns.length; i += batchSize) {\n const batch = qns.slice(i, i + batchSize);\n const placeholders = batch.map(() => '?').join(',');\n // nosec: placeholders are parameterised\n const rows = this.db.prepare(\n `SELECT * FROM edges WHERE source_qualified IN (${placeholders})`\n ).all(...batch) as EdgeRow[];\n for (const r of rows) {\n const edge = this._rowToEdge(r);\n if (qualifiedNames.has(edge.targetQualified)) { results.push(edge); }\n }\n }\n return results;\n }\n\n // ---------------------------------------------------------------------------\n // Adjacency (BFS support for use cases)\n // ---------------------------------------------------------------------------\n\n getAdjacency(): { outgoing: Map<string, Set<string>>; incoming: Map<string, Set<string>> } {\n const cache = this._buildAdjacency();\n return { outgoing: cache.out, incoming: cache.in };\n }\n\n // ---------------------------------------------------------------------------\n // Private helpers\n // ---------------------------------------------------------------------------\n\n private _initSchema(): void {\n this.db.exec(SCHEMA_SQL);\n this.setMetadata('schema_version', '1');\n }\n\n private _invalidateCache(): void {\n this.adjCache = null;\n }\n\n private _buildAdjacency(): AdjacencyCache {\n if (this.adjCache) { return this.adjCache; }\n const out = new Map<string, Set<string>>();\n const inMap = new Map<string, Set<string>>();\n\n const rows = this.db.prepare('SELECT source_qualified, target_qualified FROM edges').all() as\n Array<{ source_qualified: string; target_qualified: string }>;\n\n for (const r of rows) {\n if (!out.has(r.source_qualified)) { out.set(r.source_qualified, new Set()); }\n out.get(r.source_qualified)!.add(r.target_qualified);\n\n if (!inMap.has(r.target_qualified)) { inMap.set(r.target_qualified, new Set()); }\n inMap.get(r.target_qualified)!.add(r.source_qualified);\n }\n\n this.adjCache = { out, in: inMap };\n return this.adjCache;\n }\n\n private _makeQualified(node: NodeInfo): string {\n if (node.kind === 'File') { return node.filePath; }\n if (node.parentName) {\n return `${node.filePath}::${node.parentName}.${node.name}`;\n }\n return `${node.filePath}::${node.name}`;\n }\n\n private _rowToNode(row: NodeRow): GraphNode {\n return {\n id: row.id,\n kind: row.kind as GraphNode['kind'],\n name: row.name,\n qualifiedName: row.qualified_name,\n filePath: row.file_path,\n lineStart: row.line_start,\n lineEnd: row.line_end,\n language: row.language ?? null,\n parentName: row.parent_name ?? null,\n params: row.params ?? null,\n returnType: row.return_type ?? null,\n modifiers: row.modifiers ?? null,\n isTest: row.is_test === 1,\n fileHash: row.file_hash ?? null,\n };\n }\n\n private _rowToEdge(row: EdgeRow): GraphEdge {\n return {\n id: row.id,\n kind: row.kind as GraphEdge['kind'],\n sourceQualified: row.source_qualified,\n targetQualified: row.target_qualified,\n filePath: row.file_path,\n line: row.line ?? 0,\n };\n }\n}\n\n// ---------------------------------------------------------------------------\n// Utility exports (mirrors Python module-level helpers)\n// ---------------------------------------------------------------------------\n\nexport function sanitizeName(s: string, maxLen = 256): string {\n let cleaned = '';\n for (const ch of s) {\n const code = ch.codePointAt(0) ?? 0;\n if (ch === '\\t' || ch === '\\n' || code >= 0x20) { cleaned += ch; }\n }\n return cleaned.slice(0, maxLen);\n}\n\nexport function nodeToDict(n: GraphNode): Record<string, unknown> {\n return {\n id: n.id,\n kind: n.kind,\n name: sanitizeName(n.name),\n qualified_name: sanitizeName(n.qualifiedName),\n file_path: n.filePath,\n line_start: n.lineStart,\n line_end: n.lineEnd,\n language: n.language,\n parent_name: n.parentName ? sanitizeName(n.parentName) : n.parentName,\n is_test: n.isTest,\n };\n}\n\nexport function edgeToDict(e: GraphEdge): Record<string, unknown> {\n return {\n id: e.id,\n kind: e.kind,\n source: sanitizeName(e.sourceQualified),\n target: sanitizeName(e.targetQualified),\n file_path: e.filePath,\n line: e.line,\n };\n}\n\n// Backward-compat alias (used by tests + public index.ts)\nexport { SqliteGraphRepository as GraphStore };\n","/**\n * Tree-sitter based multi-language code parser.\n *\n * Extracts structural nodes (classes, functions, imports, types) and edges\n * (calls, inheritance, contains) from source files.\n *\n * Direct port of code_review_graph/parser.py.\n * Supports 14 languages: Python, JS/TS/TSX, Go, Rust, Java, C, C++, C#,\n * Ruby, Kotlin, Swift, PHP, Solidity, Vue SFC.\n */\n\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport Parser from 'tree-sitter';\n\nconst _require = createRequire(import.meta.url);\nimport type { NodeInfo, EdgeInfo } from '../domain/types.js';\nimport type { IParser } from '../domain/ports/IParser.js';\n\n// ---------------------------------------------------------------------------\n// Language loading — individual npm grammar packages\n// ---------------------------------------------------------------------------\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Language = any;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype SyntaxNode = any;\n\nfunction loadLanguage(pkg: string): Language | null {\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const mod = _require(pkg);\n return mod.default ?? mod;\n } catch {\n return null;\n }\n}\n\n// Lazy-loaded grammar map. Languages are loaded on first use.\nconst _languageCache = new Map<string, Language | null>();\n\nfunction getLanguage(name: string): Language | null {\n if (_languageCache.has(name)) { return _languageCache.get(name) ?? null; }\n\n const pkgMap: Record<string, string> = {\n python: 'tree-sitter-python',\n javascript: 'tree-sitter-javascript',\n typescript: 'tree-sitter-typescript/bindings/node/typescript',\n tsx: 'tree-sitter-typescript/bindings/node/tsx',\n go: 'tree-sitter-go',\n rust: 'tree-sitter-rust',\n java: 'tree-sitter-java',\n c: 'tree-sitter-c',\n cpp: 'tree-sitter-cpp',\n csharp: 'tree-sitter-c-sharp',\n ruby: 'tree-sitter-ruby',\n kotlin: 'tree-sitter-kotlin',\n swift: 'tree-sitter-swift',\n php: 'tree-sitter-php/php',\n solidity: 'tree-sitter-solidity',\n vue: 'tree-sitter-vue',\n };\n\n const pkg = pkgMap[name];\n const lang = pkg ? loadLanguage(pkg) : null;\n _languageCache.set(name, lang);\n return lang;\n}\n\n// ---------------------------------------------------------------------------\n// Extension → language mapping\n// ---------------------------------------------------------------------------\n\nexport const EXTENSION_TO_LANGUAGE: Record<string, string> = {\n '.py': 'python',\n '.js': 'javascript',\n '.jsx': 'javascript',\n '.ts': 'typescript',\n '.tsx': 'tsx',\n '.go': 'go',\n '.rs': 'rust',\n '.java': 'java',\n '.cs': 'csharp',\n '.rb': 'ruby',\n '.cpp': 'cpp',\n '.cc': 'cpp',\n '.cxx': 'cpp',\n '.c': 'c',\n '.h': 'c',\n '.hpp': 'cpp',\n '.kt': 'kotlin',\n '.swift': 'swift',\n '.php': 'php',\n '.sol': 'solidity',\n '.vue': 'vue',\n};\n\n// ---------------------------------------------------------------------------\n// AST node type sets per language\n// ---------------------------------------------------------------------------\n\nconst CLASS_TYPES: Record<string, string[]> = {\n python: ['class_definition'],\n javascript: ['class_declaration', 'class'],\n typescript: ['class_declaration', 'class'],\n tsx: ['class_declaration', 'class'],\n go: ['type_declaration'],\n rust: ['struct_item', 'enum_item', 'impl_item'],\n java: ['class_declaration', 'interface_declaration', 'enum_declaration'],\n c: ['struct_specifier', 'type_definition'],\n cpp: ['class_specifier', 'struct_specifier'],\n csharp: ['class_declaration', 'interface_declaration', 'enum_declaration', 'struct_declaration'],\n ruby: ['class', 'module'],\n kotlin: ['class_declaration', 'object_declaration'],\n swift: ['class_declaration', 'struct_declaration', 'protocol_declaration'],\n php: ['class_declaration', 'interface_declaration'],\n solidity: [\n 'contract_declaration', 'interface_declaration', 'library_declaration',\n 'struct_declaration', 'enum_declaration', 'error_declaration',\n 'user_defined_type_definition',\n ],\n};\n\nconst FUNCTION_TYPES: Record<string, string[]> = {\n python: ['function_definition'],\n javascript: ['function_declaration', 'method_definition', 'arrow_function'],\n typescript: ['function_declaration', 'method_definition', 'arrow_function'],\n tsx: ['function_declaration', 'method_definition', 'arrow_function'],\n go: ['function_declaration', 'method_declaration'],\n rust: ['function_item'],\n java: ['method_declaration', 'constructor_declaration'],\n c: ['function_definition'],\n cpp: ['function_definition'],\n csharp: ['method_declaration', 'constructor_declaration'],\n ruby: ['method', 'singleton_method'],\n kotlin: ['function_declaration'],\n swift: ['function_declaration'],\n php: ['function_definition', 'method_declaration'],\n solidity: [\n 'function_definition', 'constructor_definition', 'modifier_definition',\n 'event_definition', 'fallback_receive_definition',\n ],\n};\n\nconst IMPORT_TYPES: Record<string, string[]> = {\n python: ['import_statement', 'import_from_statement'],\n javascript: ['import_statement'],\n typescript: ['import_statement'],\n tsx: ['import_statement'],\n go: ['import_declaration'],\n rust: ['use_declaration'],\n java: ['import_declaration'],\n c: ['preproc_include'],\n cpp: ['preproc_include'],\n csharp: ['using_directive'],\n ruby: ['call'], // require / require_relative\n kotlin: ['import_header'],\n swift: ['import_declaration'],\n php: ['namespace_use_declaration'],\n solidity: ['import_directive'],\n};\n\nconst CALL_TYPES: Record<string, string[]> = {\n python: ['call'],\n javascript: ['call_expression', 'new_expression'],\n typescript: ['call_expression', 'new_expression'],\n tsx: ['call_expression', 'new_expression'],\n go: ['call_expression'],\n rust: ['call_expression', 'macro_invocation'],\n java: ['method_invocation', 'object_creation_expression'],\n c: ['call_expression'],\n cpp: ['call_expression'],\n csharp: ['invocation_expression', 'object_creation_expression'],\n ruby: ['call', 'method_call'],\n kotlin: ['call_expression'],\n swift: ['call_expression'],\n php: ['function_call_expression', 'member_call_expression'],\n solidity: ['call_expression'],\n};\n\n// ---------------------------------------------------------------------------\n// Test detection patterns\n// ---------------------------------------------------------------------------\n\nconst TEST_PATTERNS = [\n /^test_/,\n /^Test/,\n /_test$/,\n /\\.test\\./,\n /\\.spec\\./,\n /_spec$/,\n];\n\nconst TEST_FILE_PATTERNS = [\n /test_.*\\.py$/,\n /.*_test\\.py$/,\n /.*\\.test\\.[jt]sx?$/,\n /.*\\.spec\\.[jt]sx?$/,\n /.*_test\\.go$/,\n /tests?\\//,\n];\n\nfunction isTestFile(filePath: string): boolean {\n return TEST_FILE_PATTERNS.some((p) => p.test(filePath));\n}\n\n// Test-runner framework names that indicate a function IS a test even\n// if its name doesn't start with \"test\".\nconst TEST_RUNNER_NAMES = new Set([\n 'describe', 'it', 'test', 'beforeEach', 'afterEach', 'beforeAll', 'afterAll',\n]);\n\nfunction isTestFunction(name: string, filePath: string): boolean {\n // Name-pattern match always wins\n if (TEST_PATTERNS.some((p) => p.test(name))) { return true; }\n // In a test file, only test-runner functions count (not every helper)\n if (isTestFile(filePath) && TEST_RUNNER_NAMES.has(name)) { return true; }\n return false;\n}\n\n// ---------------------------------------------------------------------------\n// Public utility\n// ---------------------------------------------------------------------------\n\nexport function fileHash(filePath: string): string {\n const buf = fs.readFileSync(filePath);\n return crypto.createHash('sha256').update(buf).digest('hex');\n}\n\n// ---------------------------------------------------------------------------\n// CodeParser\n// ---------------------------------------------------------------------------\n\nconst MAX_AST_DEPTH = 180;\nconst MODULE_CACHE_MAX = 15_000;\n\nexport class CodeParser implements IParser {\n private parsers = new Map<string, Parser>();\n private moduleFileCache = new Map<string, string | null>();\n\n private getParser(language: string): Parser | null {\n if (this.parsers.has(language)) { return this.parsers.get(language) ?? null; }\n try {\n const lang = getLanguage(language);\n if (!lang) { return null; }\n const p = new Parser();\n p.setLanguage(lang);\n this.parsers.set(language, p);\n return p;\n } catch {\n return null;\n }\n }\n\n detectLanguage(filePath: string): string | null {\n const ext = path.extname(filePath).toLowerCase();\n return EXTENSION_TO_LANGUAGE[ext] ?? null;\n }\n\n parseFile(filePath: string): [NodeInfo[], EdgeInfo[]] {\n let source: Buffer;\n try {\n source = fs.readFileSync(filePath);\n } catch {\n return [[], []];\n }\n return this.parseBytes(filePath, source);\n }\n\n parseBytes(filePath: string, source: Buffer): [NodeInfo[], EdgeInfo[]] {\n const language = this.detectLanguage(filePath);\n if (!language) { return [[], []]; }\n\n if (language === 'vue') {\n return this._parseVue(filePath, source);\n }\n\n const parser = this.getParser(language);\n if (!parser) { return [[], []]; }\n\n const tree = parser.parse(source.toString('utf-8'));\n const nodes: NodeInfo[] = [];\n const edges: EdgeInfo[] = [];\n const testFile = isTestFile(filePath);\n\n // File node\n const lineCount = source.toString('utf-8').split('\\n').length;\n nodes.push({\n kind: 'File',\n name: filePath,\n filePath,\n lineStart: 1,\n lineEnd: lineCount,\n language,\n isTest: testFile,\n });\n\n const [importMap, definedNames] = this._collectFileScope(\n tree.rootNode, language, source,\n );\n\n this._extractFromTree(\n tree.rootNode, source, language, filePath, nodes, edges,\n undefined, undefined, importMap, definedNames,\n );\n\n const resolvedEdges = this._resolveCallTargets(nodes, edges, filePath);\n\n // Generate TESTED_BY edges\n if (testFile) {\n const testQNames = new Set<string>();\n for (const n of nodes) {\n if (n.isTest) {\n testQNames.add(this._qualify(n.name, filePath, n.parentName ?? null));\n }\n }\n const testedBy: EdgeInfo[] = [];\n for (const edge of resolvedEdges) {\n if (edge.kind === 'CALLS' && testQNames.has(edge.source)) {\n testedBy.push({\n kind: 'TESTED_BY',\n source: edge.target,\n target: edge.source,\n filePath: edge.filePath,\n line: edge.line,\n });\n }\n }\n resolvedEdges.push(...testedBy);\n }\n\n return [nodes, resolvedEdges];\n }\n\n private _parseVue(filePath: string, source: Buffer): [NodeInfo[], EdgeInfo[]] {\n const vueParser = this.getParser('vue');\n if (!vueParser) { return [[], []]; }\n\n const tree = vueParser.parse(source.toString('utf-8'));\n const testFile = isTestFile(filePath);\n const lineCount = source.toString('utf-8').split('\\n').length;\n\n const allNodes: NodeInfo[] = [{\n kind: 'File',\n name: filePath,\n filePath,\n lineStart: 1,\n lineEnd: lineCount,\n language: 'vue',\n isTest: testFile,\n }];\n const allEdges: EdgeInfo[] = [];\n\n for (const child of tree.rootNode.children) {\n if (child.type !== 'script_element') { continue; }\n\n let scriptLang = 'javascript';\n let startTag: SyntaxNode | null = null;\n let rawTextNode: SyntaxNode | null = null;\n\n for (const sub of child.children) {\n if (sub.type === 'start_tag') { startTag = sub; }\n else if (sub.type === 'raw_text') { rawTextNode = sub; }\n }\n\n if (startTag) {\n for (const attr of startTag.children) {\n if (attr.type === 'attribute') {\n let attrName: string | null = null;\n let attrValue: string | null = null;\n for (const a of attr.children) {\n if (a.type === 'attribute_name') { attrName = a.text; }\n else if (a.type === 'quoted_attribute_value') {\n for (const v of a.children) {\n if (v.type === 'attribute_value') { attrValue = v.text; }\n }\n }\n }\n if (attrName === 'lang' && (attrValue === 'ts' || attrValue === 'typescript')) {\n scriptLang = 'typescript';\n }\n }\n }\n }\n\n if (!rawTextNode) { continue; }\n\n const scriptSource = Buffer.from(rawTextNode.text, 'utf-8');\n const lineOffset: number = rawTextNode.startPosition.row;\n\n const scriptParser = this.getParser(scriptLang);\n if (!scriptParser) { continue; }\n\n const scriptTree = scriptParser.parse(scriptSource.toString('utf-8'));\n const [importMap, definedNames] = this._collectFileScope(\n scriptTree.rootNode, scriptLang, scriptSource,\n );\n\n const nodes: NodeInfo[] = [];\n const edges: EdgeInfo[] = [];\n this._extractFromTree(\n scriptTree.rootNode, scriptSource, scriptLang, filePath,\n nodes, edges, undefined, undefined, importMap, definedNames,\n );\n\n // Adjust line numbers and language for position within .vue file\n for (const n of nodes) {\n n.lineStart += lineOffset;\n n.lineEnd += lineOffset;\n n.language = 'vue';\n }\n for (const e of edges) {\n e.line = (e.line ?? 0) + lineOffset;\n }\n\n allNodes.push(...nodes);\n allEdges.push(...edges);\n }\n\n // Generate TESTED_BY edges\n if (testFile) {\n const testQNames = new Set<string>();\n for (const n of allNodes) {\n if (n.isTest) {\n testQNames.add(this._qualify(n.name, filePath, n.parentName ?? null));\n }\n }\n const testedBy: EdgeInfo[] = [];\n for (const edge of allEdges) {\n if (edge.kind === 'CALLS' && testQNames.has(edge.source)) {\n testedBy.push({\n kind: 'TESTED_BY',\n source: edge.target,\n target: edge.source,\n filePath: edge.filePath,\n line: edge.line,\n });\n }\n }\n allEdges.push(...testedBy);\n }\n\n return [allNodes, allEdges];\n }\n\n private _resolveCallTargets(\n nodes: NodeInfo[],\n edges: EdgeInfo[],\n filePath: string,\n ): EdgeInfo[] {\n const symbols = new Map<string, string>();\n for (const node of nodes) {\n if (['Function', 'Class', 'Type', 'Test'].includes(node.kind)) {\n const bare = node.name;\n if (!symbols.has(bare)) {\n symbols.set(bare, this._qualify(bare, filePath, node.parentName ?? null));\n }\n }\n }\n\n return edges.map((edge) => {\n if (edge.kind === 'CALLS' && !edge.target.includes('::')) {\n const qualified = symbols.get(edge.target);\n if (qualified) {\n return { ...edge, target: qualified };\n }\n }\n return edge;\n });\n }\n\n private _extractFromTree(\n root: SyntaxNode,\n source: Buffer,\n language: string,\n filePath: string,\n nodes: NodeInfo[],\n edges: EdgeInfo[],\n enclosingClass?: string | null,\n enclosingFunc?: string | null,\n importMap?: Map<string, string>,\n definedNames?: Set<string>,\n depth = 0,\n ): void {\n if (depth > MAX_AST_DEPTH) { return; }\n\n const classTypes = new Set(CLASS_TYPES[language] ?? []);\n const funcTypes = new Set(FUNCTION_TYPES[language] ?? []);\n const importTypes = new Set(IMPORT_TYPES[language] ?? []);\n const callTypes = new Set(CALL_TYPES[language] ?? []);\n\n for (const child of root.children) {\n const nodeType: string = child.type;\n\n // --- Classes ---\n if (classTypes.has(nodeType)) {\n const name = this._getName(child, language, 'class');\n if (name) {\n nodes.push({\n kind: 'Class',\n name,\n filePath,\n lineStart: child.startPosition.row + 1,\n lineEnd: child.endPosition.row + 1,\n language,\n parentName: enclosingClass ?? null,\n });\n\n edges.push({\n kind: 'CONTAINS',\n source: filePath,\n target: this._qualify(name, filePath, enclosingClass ?? null),\n filePath,\n line: child.startPosition.row + 1,\n });\n\n const bases = this._getBases(child, language);\n for (const base of bases) {\n edges.push({\n kind: 'INHERITS',\n source: this._qualify(name, filePath, enclosingClass ?? null),\n target: base,\n filePath,\n line: child.startPosition.row + 1,\n });\n }\n\n this._extractFromTree(\n child, source, language, filePath, nodes, edges,\n name, null, importMap, definedNames, depth + 1,\n );\n continue;\n }\n }\n\n // --- Functions ---\n if (funcTypes.has(nodeType)) {\n const name = this._getName(child, language, 'function');\n if (name) {\n const isTest = isTestFunction(name, filePath);\n const kind = isTest ? 'Test' : 'Function';\n const qualified = this._qualify(name, filePath, enclosingClass ?? null);\n const params = this._getParams(child, language);\n const retType = this._getReturnType(child, language);\n\n nodes.push({\n kind,\n name,\n filePath,\n lineStart: child.startPosition.row + 1,\n lineEnd: child.endPosition.row + 1,\n language,\n parentName: enclosingClass ?? null,\n params,\n returnType: retType,\n isTest,\n });\n\n const container = enclosingClass\n ? this._qualify(enclosingClass, filePath, null)\n : filePath;\n edges.push({\n kind: 'CONTAINS',\n source: container,\n target: qualified,\n filePath,\n line: child.startPosition.row + 1,\n });\n\n // Solidity: modifier invocations → CALLS edges\n if (language === 'solidity') {\n for (const sub of child.children) {\n if (sub.type === 'modifier_invocation') {\n for (const ident of sub.children) {\n if (ident.type === 'identifier') {\n edges.push({\n kind: 'CALLS',\n source: qualified,\n target: ident.text,\n filePath,\n line: sub.startPosition.row + 1,\n });\n break;\n }\n }\n }\n }\n }\n\n this._extractFromTree(\n child, source, language, filePath, nodes, edges,\n enclosingClass, name, importMap, definedNames, depth + 1,\n );\n continue;\n }\n }\n\n // --- Imports ---\n if (importTypes.has(nodeType)) {\n const imports = this._extractImport(child, language);\n for (const impTarget of imports) {\n edges.push({\n kind: 'IMPORTS_FROM',\n source: filePath,\n target: impTarget,\n filePath,\n line: child.startPosition.row + 1,\n });\n }\n continue;\n }\n\n // --- Calls ---\n if (callTypes.has(nodeType)) {\n const callName = this._getCallName(child, language);\n if (callName && enclosingFunc) {\n const caller = this._qualify(enclosingFunc, filePath, enclosingClass ?? null);\n const target = this._resolveCallTarget(\n callName, filePath, language,\n importMap ?? new Map(), definedNames ?? new Set(),\n );\n edges.push({\n kind: 'CALLS',\n source: caller,\n target,\n filePath,\n line: child.startPosition.row + 1,\n });\n }\n }\n\n // --- Solidity-specific constructs ---\n if (language === 'solidity') {\n // emit statements → CALLS edges\n if (nodeType === 'emit_statement' && enclosingFunc) {\n for (const sub of child.children) {\n if (sub.type === 'expression') {\n for (const ident of sub.children) {\n if (ident.type === 'identifier') {\n const caller = this._qualify(\n enclosingFunc, filePath, enclosingClass ?? null,\n );\n edges.push({\n kind: 'CALLS',\n source: caller,\n target: ident.text,\n filePath,\n line: child.startPosition.row + 1,\n });\n }\n }\n }\n }\n }\n\n // State variable declarations → Function nodes\n if (nodeType === 'state_variable_declaration' && enclosingClass) {\n let varName: string | null = null;\n let varVisibility: string | null = null;\n let varType: string | null = null;\n let varMutability: string | null = null;\n\n for (const sub of child.children) {\n if (sub.type === 'identifier') { varName = sub.text; }\n else if (sub.type === 'visibility') { varVisibility = sub.text; }\n else if (sub.type === 'type_name') { varType = sub.text; }\n else if (sub.type === 'constant' || sub.type === 'immutable') {\n varMutability = sub.type;\n }\n }\n if (varName) {\n const qualified = this._qualify(varName, filePath, enclosingClass);\n nodes.push({\n kind: 'Function',\n name: varName,\n filePath,\n lineStart: child.startPosition.row + 1,\n lineEnd: child.endPosition.row + 1,\n language,\n parentName: enclosingClass,\n returnType: varType,\n modifiers: varVisibility,\n extra: { solidity_kind: 'state_variable', mutability: varMutability },\n });\n edges.push({\n kind: 'CONTAINS',\n source: this._qualify(enclosingClass, filePath, null),\n target: qualified,\n filePath,\n line: child.startPosition.row + 1,\n });\n continue;\n }\n }\n\n // Constant variable declarations\n if (nodeType === 'constant_variable_declaration') {\n let varName: string | null = null;\n let varType: string | null = null;\n for (const sub of child.children) {\n if (sub.type === 'identifier') { varName = sub.text; }\n else if (sub.type === 'type_name') { varType = sub.text; }\n }\n if (varName) {\n const qualified = this._qualify(varName, filePath, enclosingClass ?? null);\n nodes.push({\n kind: 'Function',\n name: varName,\n filePath,\n lineStart: child.startPosition.row + 1,\n lineEnd: child.endPosition.row + 1,\n language,\n parentName: enclosingClass ?? null,\n returnType: varType,\n extra: { solidity_kind: 'constant' },\n });\n const container = enclosingClass\n ? this._qualify(enclosingClass, filePath, null)\n : filePath;\n edges.push({\n kind: 'CONTAINS',\n source: container,\n target: qualified,\n filePath,\n line: child.startPosition.row + 1,\n });\n continue;\n }\n }\n\n // Using directives → DEPENDS_ON edge\n if (nodeType === 'using_directive') {\n let libName: string | null = null;\n for (const sub of child.children) {\n if (sub.type === 'type_alias') {\n for (const ident of sub.children) {\n if (ident.type === 'identifier') { libName = ident.text; break; }\n }\n }\n }\n if (libName) {\n const sourceName = enclosingClass\n ? this._qualify(enclosingClass, filePath, null)\n : filePath;\n edges.push({\n kind: 'DEPENDS_ON',\n source: sourceName,\n target: libName,\n filePath,\n line: child.startPosition.row + 1,\n });\n }\n continue;\n }\n }\n\n // Recurse for other node types\n this._extractFromTree(\n child, source, language, filePath, nodes, edges,\n enclosingClass, enclosingFunc, importMap, definedNames, depth + 1,\n );\n }\n }\n\n private _collectFileScope(\n root: SyntaxNode,\n language: string,\n source: Buffer,\n ): [Map<string, string>, Set<string>] {\n const importMap = new Map<string, string>();\n const definedNames = new Set<string>();\n\n const classTypes = new Set(CLASS_TYPES[language] ?? []);\n const funcTypes = new Set(FUNCTION_TYPES[language] ?? []);\n const importTypes = new Set(IMPORT_TYPES[language] ?? []);\n const decoratorWrappers = new Set(['decorated_definition', 'decorator']);\n\n for (const child of root.children) {\n const nodeType: string = child.type;\n\n // Unwrap decorator wrappers\n let target = child;\n if (decoratorWrappers.has(nodeType)) {\n for (const inner of child.children) {\n if (funcTypes.has(inner.type) || classTypes.has(inner.type)) {\n target = inner;\n break;\n }\n }\n }\n\n const targetType: string = target.type;\n\n if (funcTypes.has(targetType) || classTypes.has(targetType)) {\n const name = this._getName(\n target, language, classTypes.has(targetType) ? 'class' : 'function',\n );\n if (name) { definedNames.add(name); }\n }\n\n if (importTypes.has(nodeType)) {\n this._collectImportNames(child, language, source, importMap);\n }\n }\n\n return [importMap, definedNames];\n }\n\n private _collectImportNames(\n node: SyntaxNode,\n language: string,\n _source: Buffer,\n importMap: Map<string, string>,\n ): void {\n if (language === 'python') {\n if (node.type === 'import_from_statement') {\n let module: string | null = null;\n let seenImport = false;\n for (const child of node.children) {\n if (child.type === 'dotted_name' && !seenImport) {\n module = child.text;\n } else if (child.type === 'import') {\n seenImport = true;\n } else if (seenImport && module) {\n if (child.type === 'identifier' || child.type === 'dotted_name') {\n importMap.set(child.text, module);\n } else if (child.type === 'aliased_import') {\n const names = child.children\n .filter((c: SyntaxNode) =>\n c.type === 'identifier' || c.type === 'dotted_name'\n )\n .map((c: SyntaxNode) => c.text as string);\n if (names.length > 0) { importMap.set(names[names.length - 1]!, module); }\n }\n }\n }\n }\n } else if (language === 'javascript' || language === 'typescript' || language === 'tsx') {\n let module: string | null = null;\n for (const child of node.children) {\n if (child.type === 'string') {\n module = (child.text as string).replace(/^['\"]|['\"]$/g, '');\n }\n }\n if (module) {\n for (const child of node.children) {\n if (child.type === 'import_clause') {\n this._collectJsImportNames(child, module, importMap);\n }\n }\n }\n }\n }\n\n private _collectJsImportNames(\n clauseNode: SyntaxNode,\n module: string,\n importMap: Map<string, string>,\n ): void {\n for (const child of clauseNode.children) {\n if (child.type === 'identifier') {\n importMap.set(child.text, module);\n } else if (child.type === 'named_imports') {\n for (const spec of child.children) {\n if (spec.type === 'import_specifier') {\n const names = spec.children\n .filter((s: SyntaxNode) =>\n s.type === 'identifier' || s.type === 'property_identifier'\n )\n .map((s: SyntaxNode) => s.text as string);\n if (names.length > 0) { importMap.set(names[names.length - 1]!, module); }\n }\n }\n }\n }\n }\n\n private _resolveModuleToFile(\n module: string,\n filePath: string,\n language: string,\n ): string | null {\n const callerDir = path.dirname(filePath);\n const cacheKey = `${language}:${callerDir}:${module}`;\n if (this.moduleFileCache.has(cacheKey)) {\n return this.moduleFileCache.get(cacheKey) ?? null;\n }\n\n const resolved = this._doResolveModule(module, filePath, language);\n if (this.moduleFileCache.size >= MODULE_CACHE_MAX) {\n this.moduleFileCache.clear();\n }\n this.moduleFileCache.set(cacheKey, resolved);\n return resolved;\n }\n\n private _doResolveModule(\n module: string,\n filePath: string,\n language: string,\n ): string | null {\n const callerDir = path.dirname(filePath);\n\n if (language === 'python') {\n const relPath = module.replace(/\\./g, '/');\n const candidates = [`${relPath}.py`, `${relPath}/__init__.py`];\n let current = callerDir;\n // eslint-disable-next-line no-constant-condition\n while (true) {\n for (const candidate of candidates) {\n const target = path.join(current, candidate);\n if (fs.existsSync(target)) { return path.resolve(target); }\n }\n const parent = path.dirname(current);\n if (parent === current) { break; }\n current = parent;\n }\n } else if (\n language === 'javascript' || language === 'typescript' ||\n language === 'tsx' || language === 'vue'\n ) {\n if (module.startsWith('.')) {\n const base = path.join(callerDir, module);\n const extensions = ['.ts', '.tsx', '.js', '.jsx', '.vue'];\n if (fs.existsSync(base) && fs.statSync(base).isFile()) {\n return path.resolve(base);\n }\n for (const ext of extensions) {\n const target = base + ext;\n if (fs.existsSync(target)) { return path.resolve(target); }\n }\n // Try index file in directory\n if (fs.existsSync(base) && fs.statSync(base).isDirectory()) {\n for (const ext of extensions) {\n const target = path.join(base, `index${ext}`);\n if (fs.existsSync(target)) { return path.resolve(target); }\n }\n }\n }\n }\n\n return null;\n }\n\n private _resolveCallTarget(\n callName: string,\n filePath: string,\n language: string,\n importMap: Map<string, string>,\n definedNames: Set<string>,\n ): string {\n if (definedNames.has(callName)) {\n return this._qualify(callName, filePath, null);\n }\n const importedFrom = importMap.get(callName);\n if (importedFrom) {\n const resolved = this._resolveModuleToFile(importedFrom, filePath, language);\n if (resolved) { return this._qualify(callName, resolved, null); }\n }\n return callName;\n }\n\n private _qualify(name: string, filePath: string, enclosingClass: string | null): string {\n if (enclosingClass) { return `${filePath}::${enclosingClass}.${name}`; }\n return `${filePath}::${name}`;\n }\n\n private _getName(node: SyntaxNode, language: string, kind: string): string | null {\n // Solidity: constructor and receive/fallback have no identifier child\n if (language === 'solidity') {\n if (node.type === 'constructor_definition') { return 'constructor'; }\n if (node.type === 'fallback_receive_definition') {\n for (const child of node.children) {\n if (child.type === 'receive' || child.type === 'fallback') {\n return child.text;\n }\n }\n }\n }\n\n // C/C++: function names are inside function_declarator/pointer_declarator\n if ((language === 'c' || language === 'cpp') && kind === 'function') {\n for (const child of node.children) {\n if (child.type === 'function_declarator' || child.type === 'pointer_declarator') {\n const result = this._getName(child, language, kind);\n if (result) { return result; }\n }\n }\n }\n\n // Most languages: look for identifier child\n for (const child of node.children) {\n if ([\n 'identifier', 'name', 'type_identifier', 'property_identifier',\n 'simple_identifier', 'constant',\n ].includes(child.type)) {\n return child.text;\n }\n }\n\n // Go type declarations: look for type_spec\n if (language === 'go' && node.type === 'type_declaration') {\n for (const child of node.children) {\n if (child.type === 'type_spec') {\n return this._getName(child, language, kind);\n }\n }\n }\n\n return null;\n }\n\n private _getParams(node: SyntaxNode, language: string): string | null {\n for (const child of node.children) {\n if (['parameters', 'formal_parameters', 'parameter_list'].includes(child.type)) {\n return child.text;\n }\n }\n if (language === 'solidity') {\n const params = node.children\n .filter((c: SyntaxNode) => c.type === 'parameter')\n .map((c: SyntaxNode) => c.text as string);\n if (params.length > 0) { return `(${params.join(', ')})`; }\n }\n return null;\n }\n\n private _getReturnType(node: SyntaxNode, language: string): string | null {\n for (const child of node.children) {\n if ([\n 'type', 'return_type', 'type_annotation', 'return_type_definition',\n ].includes(child.type)) {\n return child.text;\n }\n }\n if (language === 'python') {\n for (let i = 0; i < node.children.length - 1; i++) {\n if (node.children[i].type === '->') {\n return node.children[i + 1].text;\n }\n }\n }\n return null;\n }\n\n private _getBases(node: SyntaxNode, language: string): string[] {\n const bases: string[] = [];\n\n if (language === 'python') {\n for (const child of node.children) {\n if (child.type === 'argument_list') {\n for (const arg of child.children) {\n if (arg.type === 'identifier' || arg.type === 'attribute') {\n bases.push(arg.text);\n }\n }\n }\n }\n } else if (\n language === 'java' || language === 'csharp' || language === 'kotlin'\n ) {\n for (const child of node.children) {\n if ([\n 'superclass', 'super_interfaces', 'extends_type', 'implements_type',\n 'type_identifier', 'supertype', 'delegation_specifier',\n ].includes(child.type)) {\n bases.push(child.text);\n }\n }\n } else if (language === 'cpp') {\n for (const child of node.children) {\n if (child.type === 'base_class_clause') {\n for (const sub of child.children) {\n if (sub.type === 'type_identifier') { bases.push(sub.text); }\n }\n }\n }\n } else if (\n language === 'typescript' || language === 'javascript' || language === 'tsx'\n ) {\n for (const child of node.children) {\n if (child.type === 'extends_clause' || child.type === 'implements_clause') {\n for (const sub of child.children) {\n if ([\n 'identifier', 'type_identifier', 'nested_identifier',\n ].includes(sub.type)) {\n bases.push(sub.text);\n }\n }\n }\n }\n } else if (language === 'solidity') {\n for (const child of node.children) {\n if (child.type === 'inheritance_specifier') {\n for (const sub of child.children) {\n if (sub.type === 'user_defined_type') {\n for (const ident of sub.children) {\n if (ident.type === 'identifier') { bases.push(ident.text); }\n }\n }\n }\n }\n }\n } else if (language === 'go') {\n for (const child of node.children) {\n if (child.type === 'type_spec') {\n for (const sub of child.children) {\n if (sub.type === 'struct_type' || sub.type === 'interface_type') {\n for (const fieldNode of sub.children) {\n if (fieldNode.type === 'field_declaration_list') {\n for (const f of fieldNode.children) {\n if (f.type === 'type_identifier') { bases.push(f.text); }\n }\n }\n }\n }\n }\n }\n }\n }\n\n return bases;\n }\n\n private _extractImport(node: SyntaxNode, language: string): string[] {\n const imports: string[] = [];\n const text: string = node.text.trim();\n\n if (language === 'python') {\n if (node.type === 'import_from_statement') {\n for (const child of node.children) {\n if (child.type === 'dotted_name') {\n imports.push(child.text);\n break;\n }\n }\n } else {\n for (const child of node.children) {\n if (child.type === 'dotted_name') { imports.push(child.text); }\n }\n }\n } else if (\n language === 'javascript' || language === 'typescript' || language === 'tsx'\n ) {\n for (const child of node.children) {\n if (child.type === 'string') {\n imports.push((child.text as string).replace(/^['\"]|['\"]$/g, ''));\n }\n }\n } else if (language === 'go') {\n for (const child of node.children) {\n if (child.type === 'import_spec_list') {\n for (const spec of child.children) {\n if (spec.type === 'import_spec') {\n for (const s of spec.children) {\n if (s.type === 'interpreted_string_literal') {\n imports.push((s.text as string).replace(/^\"|\"$/g, ''));\n }\n }\n }\n }\n } else if (child.type === 'import_spec') {\n for (const s of child.children) {\n if (s.type === 'interpreted_string_literal') {\n imports.push((s.text as string).replace(/^\"|\"$/g, ''));\n }\n }\n }\n }\n } else if (language === 'rust') {\n imports.push(text.replace(/^use\\s+/, '').replace(/;$/, '').trim());\n } else if (language === 'c' || language === 'cpp') {\n for (const child of node.children) {\n if (child.type === 'system_lib_string' || child.type === 'string_literal') {\n imports.push((child.text as string).replace(/^[<\"\"]|[>\"\"]$/g, ''));\n }\n }\n } else if (language === 'java' || language === 'csharp') {\n const parts = text.split(/\\s+/);\n if (parts.length >= 2) {\n imports.push(parts[parts.length - 1]!.replace(/;$/, ''));\n }\n } else if (language === 'solidity') {\n for (const child of node.children) {\n if (child.type === 'string') {\n const val = (child.text as string).replace(/^\"|\"$/g, '');\n if (val) { imports.push(val); }\n }\n }\n } else if (language === 'ruby') {\n if (text.includes('require')) {\n const match = /['\"]([^'\"]+)['\"]/u.exec(text);\n if (match) { imports.push(match[1]!); }\n }\n } else {\n imports.push(text);\n }\n\n return imports;\n }\n\n private _getCallName(node: SyntaxNode, language: string): string | null {\n if (!node.children || node.children.length === 0) { return null; }\n\n let first: SyntaxNode = node.children[0];\n\n // Solidity wraps call targets in 'expression' — unwrap\n if (\n language === 'solidity' &&\n first.type === 'expression' &&\n first.children.length > 0\n ) {\n first = first.children[0];\n }\n\n if (first.type === 'identifier') { return first.text; }\n\n const memberTypes = [\n 'attribute', 'member_expression', 'field_expression', 'selector_expression',\n ];\n if (memberTypes.includes(first.type)) {\n for (let i = first.children.length - 1; i >= 0; i--) {\n const child: SyntaxNode = first.children[i];\n if ([\n 'identifier', 'property_identifier', 'field_identifier', 'field_name',\n ].includes(child.type)) {\n return child.text;\n }\n }\n return first.text;\n }\n\n if (first.type === 'scoped_identifier' || first.type === 'qualified_name') {\n return first.text;\n }\n\n return null;\n }\n}\n\n// Canonical export alias matching the file name\nexport { CodeParser as TreeSitterParser }\n","/**\n * Use cases: full build and incremental update of the knowledge graph.\n *\n * Extracted from incremental.ts (fullBuild, incrementalUpdate, findDependents)\n * + tools.ts (buildOrUpdateGraph).\n *\n * Accepts IParser and IGraphRepository as parameters for testability.\n * Imports file-system and git utilities from infrastructure.\n */\n\nimport crypto from 'node:crypto'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport type { BuildResult } from '../domain/types.js'\nimport type { IParser } from '../domain/ports/IParser.js'\nimport type { IGraphRepository } from '../domain/ports/IGraphRepository.js'\nimport {\n collectAllFiles,\n loadIgnorePatterns,\n shouldIgnore,\n} from '../infrastructure/FileSystemHelper.js'\nimport { getChangedFiles } from '../infrastructure/GitRunner.js'\n\n// ---------------------------------------------------------------------------\n// Full build\n// ---------------------------------------------------------------------------\n\nexport function fullBuild(\n repoRoot: string,\n repo: IGraphRepository,\n parser: IParser,\n): BuildResult {\n const files = collectAllFiles(repoRoot)\n\n // Purge stale data\n const existingFiles = new Set(repo.getAllFiles())\n const currentAbs = new Set(files.map((f) => path.join(repoRoot, f)))\n for (const stale of existingFiles) {\n if (!currentAbs.has(stale)) {\n repo.removeFileData(stale)\n }\n }\n\n let totalNodes = 0\n let totalEdges = 0\n const errors: string[] = []\n\n for (let i = 0; i < files.length; i++) {\n const relPath = files[i]!\n const fullPath = path.join(repoRoot, relPath)\n try {\n const source = fs.readFileSync(fullPath)\n const fhash = crypto.createHash('sha256').update(source).digest('hex')\n const [nodes, edges] = parser.parseBytes(fullPath, source)\n repo.storeFileNodesEdges(fullPath, nodes, edges, fhash)\n totalNodes += nodes.length\n totalEdges += edges.length\n } catch (err) {\n errors.push(`${relPath}: ${String(err)}`)\n }\n if ((i + 1) % 50 === 0 || i + 1 === files.length) {\n process.stderr.write(`Progress: ${i + 1}/${files.length} files parsed\\n`)\n }\n }\n\n repo.setMetadata('last_updated', new Date().toISOString().replace(/\\..+$/, ''))\n repo.setMetadata('last_build_type', 'full')\n\n return {\n buildType: 'full',\n filesUpdated: files.length,\n totalNodes,\n totalEdges,\n changedFiles: files,\n dependentFiles: [],\n errors,\n }\n}\n\n// ---------------------------------------------------------------------------\n// Incremental update\n// ---------------------------------------------------------------------------\n\nexport function incrementalUpdate(\n repoRoot: string,\n repo: IGraphRepository,\n parser: IParser,\n base = 'HEAD~1',\n changedFiles?: string[],\n): BuildResult {\n const ignorePatterns = loadIgnorePatterns(repoRoot)\n const changed = changedFiles ?? getChangedFiles(repoRoot, base)\n\n if (changed.length === 0) {\n return {\n buildType: 'incremental',\n filesUpdated: 0,\n totalNodes: 0,\n totalEdges: 0,\n changedFiles: [],\n dependentFiles: [],\n errors: [],\n }\n }\n\n const dependentFiles = new Set<string>()\n for (const relPath of changed) {\n const fullPath = path.join(repoRoot, relPath)\n const deps = findDependents(repo, fullPath)\n for (const d of deps) {\n try {\n dependentFiles.add(path.relative(repoRoot, d))\n } catch {\n dependentFiles.add(d)\n }\n }\n }\n\n const allFiles = new Set([...changed, ...dependentFiles])\n let totalNodes = 0\n let totalEdges = 0\n const errors: string[] = []\n\n for (const relPath of allFiles) {\n if (shouldIgnore(relPath, ignorePatterns)) { continue }\n const absPath = path.join(repoRoot, relPath)\n\n if (!fs.existsSync(absPath)) {\n repo.removeFileData(absPath)\n continue\n }\n if (!parser.detectLanguage(absPath)) { continue }\n\n try {\n const source = fs.readFileSync(absPath)\n const fhash = crypto.createHash('sha256').update(source).digest('hex')\n const existingNodes = repo.getNodesByFile(absPath)\n if (existingNodes.length > 0 && existingNodes[0]!.fileHash === fhash) {\n continue\n }\n const [nodes, edges] = parser.parseBytes(absPath, source)\n repo.storeFileNodesEdges(absPath, nodes, edges, fhash)\n totalNodes += nodes.length\n totalEdges += edges.length\n } catch (err) {\n errors.push(`${relPath}: ${String(err)}`)\n }\n }\n\n repo.setMetadata('last_updated', new Date().toISOString().replace(/\\..+$/, ''))\n repo.setMetadata('last_build_type', 'incremental')\n\n return {\n buildType: 'incremental',\n filesUpdated: allFiles.size,\n totalNodes,\n totalEdges,\n changedFiles: changed,\n dependentFiles: [...dependentFiles],\n errors,\n }\n}\n\n// ---------------------------------------------------------------------------\n// Private helper\n// ---------------------------------------------------------------------------\n\nfunction findDependents(repo: IGraphRepository, filePath: string): string[] {\n const dependents = new Set<string>()\n\n for (const e of repo.getEdgesByTarget(filePath)) {\n if (e.kind === 'IMPORTS_FROM') {\n dependents.add(e.filePath)\n }\n }\n\n for (const node of repo.getNodesByFile(filePath)) {\n for (const e of repo.getEdgesByTarget(node.qualifiedName)) {\n if (['CALLS', 'IMPORTS_FROM', 'INHERITS', 'IMPLEMENTS'].includes(e.kind)) {\n dependents.add(e.filePath)\n }\n }\n }\n\n dependents.delete(filePath)\n return [...dependents]\n}\n","/**\n * File-system infrastructure helpers.\n *\n * Extracted from incremental.ts: findRepoRoot, findProjectRoot, getDbPath,\n * loadIgnorePatterns, shouldIgnore, isBinary, walkDir, collectAllFiles.\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport micromatch from 'micromatch'\nimport { CodeParser } from './TreeSitterParser.js'\nimport { getAllTrackedFiles } from './GitRunner.js'\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nexport const DEFAULT_IGNORE_PATTERNS = [\n '.codeorbit/**',\n 'node_modules/**',\n '.git/**',\n '__pycache__/**',\n '*.pyc',\n '.venv/**',\n 'venv/**',\n 'dist/**',\n 'build/**',\n '.next/**',\n 'target/**',\n '*.min.js',\n '*.min.css',\n '*.map',\n '*.lock',\n 'package-lock.json',\n 'yarn.lock',\n '*.db',\n '*.sqlite',\n '*.db-journal',\n '*.db-wal',\n]\n\nexport const PRUNE_DIRS = new Set([\n 'node_modules', '.git', '__pycache__', '.next', '.nuxt', '.svelte-kit',\n 'dist', 'build', '.venv', 'venv', 'env', 'target', '.mypy_cache',\n '.pytest_cache', 'coverage', '.tox', '.cache', '.tmp', 'tmp', 'temp',\n 'vendor', 'Pods', 'DerivedData', '.gradle', '.idea', '.vs',\n])\n\nexport const DEBOUNCE_MS = 300\n\n// ---------------------------------------------------------------------------\n// Repo / DB path discovery\n// ---------------------------------------------------------------------------\n\nexport function findRepoRoot(start?: string): string | undefined {\n let current = start ?? process.cwd()\n while (true) {\n if (fs.existsSync(path.join(current, '.git'))) {\n return current\n }\n const parent = path.dirname(current)\n if (parent === current) { break }\n current = parent\n }\n return undefined\n}\n\nexport function findProjectRoot(start?: string): string {\n return findRepoRoot(start) ?? start ?? process.cwd()\n}\n\nexport function getDbPath(repoRoot: string): string {\n const crgDir = path.join(repoRoot, '.codeorbit')\n const newDb = path.join(crgDir, 'graph.db')\n\n if (!fs.existsSync(crgDir)) {\n fs.mkdirSync(crgDir, { recursive: true })\n }\n\n const innerGitignore = path.join(crgDir, '.gitignore')\n if (!fs.existsSync(innerGitignore)) {\n fs.writeFileSync(\n innerGitignore,\n '# Auto-generated by codeorbit — do not commit database files.\\n' +\n '# The graph.db contains absolute paths and code structure metadata.\\n' +\n '*\\n',\n )\n }\n\n const legacyDb = path.join(repoRoot, '.codeorbit.db')\n if (fs.existsSync(legacyDb) && !fs.existsSync(newDb)) {\n fs.renameSync(legacyDb, newDb)\n }\n for (const suffix of ['-wal', '-shm', '-journal']) {\n const side = legacyDb + suffix\n if (fs.existsSync(side)) {\n try { fs.unlinkSync(side) } catch { /* ignore */ }\n }\n }\n\n return newDb\n}\n\n// ---------------------------------------------------------------------------\n// Ignore patterns\n// ---------------------------------------------------------------------------\n\nexport function loadIgnorePatterns(repoRoot: string): string[] {\n const patterns = [...DEFAULT_IGNORE_PATTERNS]\n const ignoreFile = path.join(repoRoot, '.codeorbitignore')\n if (fs.existsSync(ignoreFile)) {\n for (const line of fs.readFileSync(ignoreFile, 'utf-8').split('\\n')) {\n const trimmed = line.trim()\n if (trimmed && !trimmed.startsWith('#')) {\n patterns.push(trimmed)\n }\n }\n }\n return patterns\n}\n\nexport function shouldIgnore(filePath: string, patterns: string[]): boolean {\n return micromatch.isMatch(filePath, patterns)\n}\n\nexport function isBinary(filePath: string): boolean {\n try {\n const chunk = Buffer.alloc(8192)\n const fd = fs.openSync(filePath, 'r')\n const bytesRead = fs.readSync(fd, chunk, 0, 8192, 0)\n fs.closeSync(fd)\n return chunk.slice(0, bytesRead).includes(0)\n } catch {\n return true\n }\n}\n\n// ---------------------------------------------------------------------------\n// File collection\n// ---------------------------------------------------------------------------\n\nfunction walkDir(dir: string, repoRoot: string): string[] {\n const files: string[] = []\n const entries = fs.readdirSync(dir, { withFileTypes: true })\n for (const entry of entries) {\n if (entry.isDirectory()) {\n if (PRUNE_DIRS.has(entry.name)) { continue }\n files.push(...walkDir(path.join(dir, entry.name), repoRoot))\n } else if (entry.isFile()) {\n const rel = path.relative(repoRoot, path.join(dir, entry.name))\n files.push(rel)\n }\n }\n return files\n}\n\nexport function collectAllFiles(repoRoot: string): string[] {\n const ignorePatterns = loadIgnorePatterns(repoRoot)\n const parser = new CodeParser()\n const files: string[] = []\n\n const tracked = getAllTrackedFiles(repoRoot)\n const candidates = tracked.length > 0 ? tracked : walkDir(repoRoot, repoRoot)\n\n for (const relPath of candidates) {\n if (shouldIgnore(relPath, ignorePatterns)) { continue }\n const fullPath = path.join(repoRoot, relPath)\n\n let stat: fs.Stats\n try {\n stat = fs.lstatSync(fullPath)\n } catch {\n continue\n }\n\n if (!stat.isFile() || stat.isSymbolicLink()) { continue }\n if (!parser.detectLanguage(fullPath)) { continue }\n if (isBinary(fullPath)) { continue }\n files.push(relPath)\n }\n\n return files\n}\n","/**\n * Git operations infrastructure.\n *\n * Extracted from incremental.ts: gitRun, getChangedFiles, getStagedAndUnstaged,\n * getAllTrackedFiles.\n */\n\nimport { spawnSync } from 'node:child_process'\n\nexport const GIT_TIMEOUT_MS = Number(process.env['CRG_GIT_TIMEOUT'] ?? 30) * 1000\n\nfunction gitRun(args: string[], cwd: string): string {\n const result = spawnSync('git', args, {\n cwd,\n encoding: 'utf-8',\n timeout: GIT_TIMEOUT_MS,\n stdio: ['ignore', 'pipe', 'ignore'],\n })\n if (result.error || result.status !== 0) {\n return ''\n }\n return result.stdout ?? ''\n}\n\nexport function getChangedFiles(repoRoot: string, base = 'HEAD~1'): string[] {\n let output = gitRun(['diff', '--name-only', base], repoRoot)\n if (!output.trim()) {\n output = gitRun(['diff', '--name-only', '--cached'], repoRoot)\n }\n return output\n .split('\\n')\n .map((f) => f.trim())\n .filter(Boolean)\n}\n\nexport function getStagedAndUnstaged(repoRoot: string): string[] {\n const output = gitRun(['status', '--porcelain'], repoRoot)\n const files: string[] = []\n for (const line of output.split('\\n')) {\n if (line.length > 3) {\n let entry = line.slice(3).trim()\n if (entry.includes(' -> ')) {\n entry = entry.split(' -> ')[1]!\n }\n files.push(entry)\n }\n }\n return files\n}\n\nexport function getAllTrackedFiles(repoRoot: string): string[] {\n const output = gitRun(['ls-files'], repoRoot)\n return output\n .split('\\n')\n .map((f) => f.trim())\n .filter(Boolean)\n}\n"],"mappings":";AASA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,cAAc;AAsBrB,IAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0DZ,IAAM,wBAAN,MAAwD;AAAA,EACrD;AAAA,EACA,WAAkC;AAAA,EACjC;AAAA,EAET,YAAY,QAAgB;AAC1B,SAAK,SAAS;AACd,UAAM,MAAM,KAAK,QAAQ,MAAM;AAC/B,QAAI,CAAC,GAAG,WAAW,GAAG,GAAG;AACvB,SAAG,UAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA,IACvC;AAEA,SAAK,KAAK,IAAI,SAAS,MAAM;AAC7B,SAAK,GAAG,OAAO,oBAAoB;AACnC,SAAK,GAAG,OAAO,qBAAqB;AAEpC,QAAI;AACF,WAAK,GAAG,OAAO,0BAA0B;AAAA,IAC3C,QAAQ;AAAA,IAER;AAEA,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,QAAc;AACZ,QAAI;A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