kirograph 0.20.0 → 0.20.1
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/dist/bin/installer/index.js +29 -0
- package/dist/bin/installer/index.js.map +2 -2
- package/dist/bin/kirograph.js +1 -1
- package/dist/extraction/extractor.js +26 -3
- package/dist/extraction/extractor.js.map +2 -2
- package/dist/extraction/grammars.js +1 -0
- package/dist/extraction/grammars.js.map +2 -2
- package/dist/extraction/languages.js +5 -1
- package/dist/extraction/languages.js.map +2 -2
- package/dist/patterns/library/code-eval-elixir.yaml +11 -0
- package/dist/patterns/library/command-injection-c.yaml +11 -0
- package/dist/patterns/library/command-injection-go.yaml +21 -3
- package/dist/patterns/library/command-injection-kotlin.yaml +10 -0
- package/dist/patterns/library/command-injection-php.yaml +11 -0
- package/dist/patterns/library/command-injection-ruby.yaml +11 -0
- package/dist/patterns/library/command-injection-rust.yaml +11 -0
- package/dist/patterns/library/dangerous-eval-bash.yaml +11 -0
- package/dist/patterns/library/dangerous-eval-php.yaml +11 -0
- package/dist/patterns/library/dangerous-eval-ruby.yaml +11 -0
- package/dist/patterns/library/dynamic-load-lua.yaml +10 -0
- package/dist/patterns/library/os-cmd-elixir.yaml +16 -0
- package/dist/patterns/library/os-execute-lua.yaml +10 -0
- package/dist/patterns/library/path-traversal-go.yaml +4 -4
- package/dist/patterns/library/process-launch-swift.yaml +11 -0
- package/dist/patterns/library/process-run-dart.yaml +15 -0
- package/dist/patterns/library/source-injection-bash.yaml +11 -0
- package/dist/patterns/library/sql-injection-dart.yaml +9 -0
- package/dist/patterns/library/sql-injection-kotlin.yaml +11 -0
- package/dist/patterns/library/sql-injection-php.yaml +9 -0
- package/dist/patterns/library/sql-injection-swift.yaml +11 -0
- package/dist/patterns/library/subshell-injection-ruby.yaml +8 -0
- package/dist/patterns/library/unsafe-block-rust.yaml +8 -0
- package/dist/patterns/library/unsafe-string-c.yaml +11 -0
- package/dist/patterns/runner.js +45 -27
- package/dist/patterns/runner.js.map +2 -2
- package/dist/security/integrator.js +8 -8
- package/dist/security/integrator.js.map +2 -2
- package/dist/types.js.map +2 -2
- package/dist/vectors/turboquant-index.js +261 -0
- package/dist/vectors/turboquant-index.js.map +7 -0
- package/package.json +20 -1
|
@@ -230,6 +230,35 @@ async function runInstaller(target = "kiro", opts = {}) {
|
|
|
230
230
|
});
|
|
231
231
|
if (astGrepResult.status === 0) {
|
|
232
232
|
console.log(` \u2713 @ast-grep/napi installed`);
|
|
233
|
+
const langPackages = [
|
|
234
|
+
"@ast-grep/lang-go",
|
|
235
|
+
"@ast-grep/lang-python",
|
|
236
|
+
"@ast-grep/lang-java",
|
|
237
|
+
"@ast-grep/lang-rust",
|
|
238
|
+
"@ast-grep/lang-c",
|
|
239
|
+
"@ast-grep/lang-cpp",
|
|
240
|
+
"@ast-grep/lang-csharp",
|
|
241
|
+
"@ast-grep/lang-kotlin",
|
|
242
|
+
"@ast-grep/lang-swift",
|
|
243
|
+
"@ast-grep/lang-ruby",
|
|
244
|
+
"@ast-grep/lang-php",
|
|
245
|
+
"@ast-grep/lang-bash",
|
|
246
|
+
"@ast-grep/lang-scala",
|
|
247
|
+
"@ast-grep/lang-dart",
|
|
248
|
+
"@ast-grep/lang-lua",
|
|
249
|
+
"@ast-grep/lang-elixir",
|
|
250
|
+
"@ast-grep/lang-haskell"
|
|
251
|
+
];
|
|
252
|
+
const langResult = (0, import_child_process.spawnSync)("npm", ["install", ...langPackages, "--save-optional"], {
|
|
253
|
+
stdio: "inherit",
|
|
254
|
+
shell: true
|
|
255
|
+
});
|
|
256
|
+
if (langResult.status === 0) {
|
|
257
|
+
console.log(` \u2713 @ast-grep language grammars installed`);
|
|
258
|
+
} else {
|
|
259
|
+
console.warn(` \u2717 Language grammar install failed. Pattern matching will be limited to JS/TS/HTML/CSS.`);
|
|
260
|
+
console.warn(` Run manually: npm install ${langPackages.join(" ")}`);
|
|
261
|
+
}
|
|
233
262
|
} else {
|
|
234
263
|
console.warn(` \u2717 @ast-grep/napi install failed. Run manually: npm install @ast-grep/napi`);
|
|
235
264
|
console.warn(` KiroGraph will continue but kirograph pattern and kirograph_live_search will be unavailable.`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/bin/installer/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * KiroGraph Installer\n *\n * The default target wires up Kiro:\n * 1. .kiro/settings/mcp.json \u2014 registers the MCP server (IDE + CLI)\n * 2. .kiro/hooks/*.kiro.hook \u2014 auto-sync hooks for Kiro IDE\n * 3. .kiro/steering/kirograph.md \u2014 teaches Kiro to use the graph tools (IDE + CLI)\n * 4. .kiro/agents/kirograph.json \u2014 custom agent config for Kiro CLI\n */\n\nimport * as readline from 'readline';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { spawnSync } from 'child_process';\nimport { loadConfig, updateConfig } from '../../config';\nimport { printBanner } from '../banner';\nimport { renderIndexProgress } from '../progress';\nimport { dim, reset } from '../ui';\nimport { ask, askToggle } from './prompts';\nimport { promptConfigOptions } from './config-prompt';\nimport { openTypesenseDashboard } from './dashboard';\nimport { ensureQdrantUI, openQdrantDashboard } from './qdrant-dashboard';\nimport type { InstallTarget } from './common';\nimport { getTargetInstaller } from './targets';\nimport type { CavemanMode } from './caveman';\n\nexport async function runInstaller(target: InstallTarget = 'kiro', opts: { yes?: boolean } = {}): Promise<void> {\n printBanner();\n\n const rl = readline.createInterface({ input: process.stdin, output: process.stdout });\n\n try {\n const cwd = process.cwd();\n const installer = getTargetInstaller(target);\n\n console.log(` Workspace: ${cwd}\\n`);\n\n if (!opts.yes) {\n const proceed = await askToggle(rl, `Install KiroGraph for ${installer.label}?`, 'Registers the MCP server and writes integration files for this workspace.');\n if (!proceed) { console.log(' Cancelled.'); rl.close(); return; }\n } else {\n console.log(` Installing KiroGraph for ${installer.label} (--yes)`);\n }\n console.log();\n\n installer.installEarly(cwd);\n\n const alreadyInitialized = fs.existsSync(path.join(cwd, '.kirograph'));\n let cavemanMode: CavemanMode | 'off' = 'off';\n let shellCompressionLevel: 'off' | 'normal' | 'aggressive' | 'ultra' = 'normal';\n let enableMemory = false;\n let enableDocs = false;\n let enableData = false;\n let enableSecurity = false;\n let enablePatterns = false;\n let enableArchitecture = false;\n let enableWatchmen = false;\n let watchmenSynthesisMode: 'local' | 'agent' = 'local';\n let shouldOfferIndex = false;\n let typesenseDashboard = false;\n let qdrantDashboard = false;\n\n try {\n if (alreadyInitialized) {\n const config = await loadConfig(cwd);\n cavemanMode = config.cavemanMode ?? 'off';\n shellCompressionLevel = config.shellCompressionLevel ?? 'normal';\n enableMemory = config.enableMemory ?? false;\n enableDocs = config.enableDocs ?? false;\n enableData = (config as any).enableData ?? false;\n enableSecurity = (config as any).enableSecurity ?? false;\n enableWatchmen = config.enableWatchmen ?? false;\n watchmenSynthesisMode = config.watchmenSynthesisMode ?? 'local';\n enablePatterns = (config as any).enablePatterns ?? false;\n enableArchitecture = config.enableArchitecture ?? false;\n console.log(` \u2713 Reusing existing KiroGraph data in ${cwd}/.kirograph/`);\n console.log(` \u2022 semanticEngine: ${config.semanticEngine}`);\n console.log(` \u2022 enableEmbeddings: ${config.enableEmbeddings}`);\n console.log(` \u2022 enableArchitecture: ${config.enableArchitecture}`);\n console.log(` \u2022 cavemanMode: ${cavemanMode}`);\n console.log(` \u2022 shellCompressionLevel: ${shellCompressionLevel}`);\n console.log(` \u2022 enableMemory: ${enableMemory}`);\n console.log(` \u2022 enableDocs: ${enableDocs}`);\n console.log(` \u2022 enableData: ${enableData}`);\n console.log(` \u2022 enableSecurity: ${enableSecurity}`);\n console.log(` \u2022 enablePatterns: ${enablePatterns}`);\n } else {\n shouldOfferIndex = true;\n const patch = await promptConfigOptions(rl);\n await updateConfig(cwd, patch);\n cavemanMode = patch.cavemanMode ?? 'off';\n shellCompressionLevel = patch.shellCompressionLevel ?? 'normal';\n enableMemory = patch.enableMemory ?? false;\n enableDocs = patch.enableDocs ?? false;\n enableData = patch.enableData ?? false;\n enableSecurity = patch.enableSecurity ?? false;\n enablePatterns = patch.enablePatterns ?? false;\n enableArchitecture = patch.enableArchitecture ?? false;\n enableWatchmen = patch.enableWatchmen ?? false;\n watchmenSynthesisMode = patch.watchmenSynthesisMode ?? 'local';\n typesenseDashboard = patch.typesenseDashboard;\n qdrantDashboard = patch.qdrantDashboard;\n\n console.log(`\\n Configuration saved to ${cwd}/.kirograph/config.json`);\n console.log(` \u2022 enableEmbeddings: ${patch.enableEmbeddings}`);\n if ('embeddingModel' in patch) {\n console.log(` \u2022 embeddingModel: ${patch.embeddingModel} ${dim}(${patch.embeddingDim}-dim)${reset}`);\n }\n if (patch.enableEmbeddings) {\n console.log(` \u2022 semanticEngine: ${patch.semanticEngine}`);\n if (patch.semanticEngine === 'sqlite-vec') {\n console.log(`\\n Installing sqlite-vec dependencies...`);\n const result = spawnSync('npm', ['install', 'better-sqlite3', 'sqlite-vec'], { stdio: 'inherit', shell: true });\n if (result.status === 0) {\n console.log(` \u2713 better-sqlite3 and sqlite-vec installed`);\n } else {\n console.warn(` \u2717 npm install failed (exit ${result.status}). Run manually:`);\n console.warn(` npm install better-sqlite3 sqlite-vec`);\n }\n } else if (patch.semanticEngine === 'orama') {\n console.log(`\\n Installing Orama dependencies...`);\n const result = spawnSync('npm', ['install', '@orama/orama', '@orama/plugin-data-persistence'], { stdio: 'inherit', shell: true });\n if (result.status === 0) {\n console.log(` \u2713 @orama/orama and @orama/plugin-data-persistence installed`);\n } else {\n console.warn(` \u2717 npm install failed (exit ${result.status}). Run manually:`);\n console.warn(` npm install @orama/orama @orama/plugin-data-persistence`);\n }\n } else if (patch.semanticEngine === 'pglite') {\n console.log(`\\n Installing PGlite dependencies...`);\n const result = spawnSync('npm', ['install', '@electric-sql/pglite'], { stdio: 'inherit', shell: true });\n if (result.status === 0) {\n console.log(` \u2713 @electric-sql/pglite installed`);\n } else {\n console.warn(` \u2717 npm install failed (exit ${result.status}). Run manually:`);\n console.warn(` npm install @electric-sql/pglite`);\n }\n } else if (patch.semanticEngine === 'lancedb') {\n console.log(`\\n Installing LanceDB dependencies...`);\n const result = spawnSync('npm', ['install', '@lancedb/lancedb'], { stdio: 'inherit', shell: true });\n if (result.status === 0) {\n console.log(` \u2713 @lancedb/lancedb installed`);\n } else {\n console.warn(` \u2717 npm install failed (exit ${result.status}). Run manually:`);\n console.warn(` npm install @lancedb/lancedb`);\n }\n } else if (patch.semanticEngine === 'qdrant') {\n console.log(`\\n Installing Qdrant dependencies...`);\n const result = spawnSync('npm', ['install', 'qdrant-local'], { stdio: 'inherit', shell: true });\n if (result.status === 0) {\n console.log(` \u2713 qdrant-local installed`);\n } else {\n console.warn(` \u2717 npm install failed (exit ${result.status}). Run manually:`);\n console.warn(` npm install qdrant-local`);\n }\n } else if (patch.semanticEngine === 'typesense') {\n console.log(`\\n Installing Typesense dependencies...`);\n const result = spawnSync('npm', ['install', 'typesense'], { stdio: 'inherit', shell: true });\n if (result.status === 0) {\n console.log(` \u2713 typesense installed`);\n console.log(` \u2139 The Typesense binary (~37MB) will be auto-downloaded on first index run.`);\n } else {\n console.warn(` \u2717 npm install failed (exit ${result.status}). Run manually:`);\n console.warn(` npm install typesense`);\n }\n }\n }\n console.log(` \u2022 extractDocstrings: ${patch.extractDocstrings}`);\n console.log(` \u2022 trackCallSites: ${patch.trackCallSites}`);\n console.log(` \u2022 enableArchitecture: ${patch.enableArchitecture}`);\n console.log(` \u2022 cavemanMode: ${cavemanMode}`);\n console.log(` \u2022 shellCompressionLevel: ${shellCompressionLevel}`);\n console.log(` \u2022 enableMemory: ${enableMemory}`);\n console.log(` \u2022 enableDocs: ${enableDocs}`);\n console.log(` \u2022 enableData: ${enableData}`);\n console.log(` \u2022 enableSecurity: ${enableSecurity}`);\n console.log(` \u2022 enablePatterns: ${enablePatterns}`);\n\n // Install optional data format deps if enableData is on\n if (enableData) {\n if ((patch as any).dataInstallExcel) {\n console.log(`\\n Installing xlsx...`);\n const xlsxResult = spawnSync('npm', ['install', 'xlsx'], { stdio: 'inherit', shell: true });\n if (xlsxResult.status === 0) {\n console.log(` \u2713 xlsx installed`);\n } else {\n console.warn(` \u2717 npm install failed. Run manually: npm install xlsx`);\n }\n }\n if ((patch as any).dataInstallParquet) {\n console.log(`\\n Installing parquetjs-lite...`);\n const pqResult = spawnSync('npm', ['install', 'parquetjs-lite'], { stdio: 'inherit', shell: true });\n if (pqResult.status === 0) {\n console.log(` \u2713 parquetjs-lite installed`);\n } else {\n console.warn(` \u2717 npm install failed. Run manually: npm install parquetjs-lite`);\n }\n }\n }\n\n if (enablePatterns) {\n console.log(`\\n Installing @ast-grep/napi...`);\n const astGrepResult = spawnSync('npm', ['install', '@ast-grep/napi', '--save-optional'], {\n stdio: 'inherit',\n shell: true,\n });\n if (astGrepResult.status === 0) {\n console.log(` \u2713 @ast-grep/napi installed`);\n } else {\n console.warn(` \u2717 @ast-grep/napi install failed. Run manually: npm install @ast-grep/napi`);\n console.warn(` KiroGraph will continue but kirograph pattern and kirograph_live_search will be unavailable.`);\n }\n }\n }\n\n installer.installLate(cwd, cavemanMode, shellCompressionLevel, enableMemory, enableDocs, enableData, enableSecurity, enableArchitecture, enablePatterns, enableWatchmen, watchmenSynthesisMode);\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err);\n console.error(`\\n \u2717 Failed to write configuration: ${reason}`);\n process.exit(1);\n }\n\n // 5. Pre-download Qdrant UI before indexing so Qdrant starts with static content dir\n if (qdrantDashboard) {\n await ensureQdrantUI(cwd);\n }\n\n // 6. Optionally init + index\n const doIndex = shouldOfferIndex && (opts.yes || await askToggle(rl, 'Initialize and index this project now?', 'Creates .kirograph/ and indexes all source files. Takes a few seconds for small projects, longer for large ones.'));\n if (doIndex) {\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n\n const fileBytes = new Map<string, { loaded: number; total: number }>();\n const modelProgress = (file: string, loaded: number, total: number, done: boolean): void => {\n const entry = fileBytes.get(file) ?? { loaded: 0, total: 0 };\n if (total > 0) entry.total = total;\n entry.loaded = done ? entry.total : loaded;\n fileBytes.set(file, entry);\n\n // Only count files where we know the size (content-length was present)\n const knownFiles = Array.from(fileBytes.values()).filter(f => f.total > 0);\n const totalLoaded = knownFiles.reduce((s, f) => s + f.loaded, 0);\n const totalBytes = knownFiles.reduce((s, f) => s + f.total, 0);\n const pct = totalBytes > 0 ? Math.min((totalLoaded / totalBytes) * 100, 100) : 0;\n\n const filled = Math.round(pct / 5);\n const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(20 - filled);\n const mb = (totalLoaded / 1024 / 1024).toFixed(1);\n const totalMb = (totalBytes / 1024 / 1024).toFixed(1);\n process.stdout.write(`\\r [${bar}] ${pct.toFixed(0).padStart(3)}% ${mb} / ${totalMb} MB `);\n };\n\n // Suppress noisy internal warnings from @huggingface/transformers during download\n const originalStderrWrite = process.stderr.write.bind(process.stderr);\n const stderrFilter = (chunk: unknown, ...args: unknown[]): boolean => {\n const str = typeof chunk === 'string' ? chunk : String(chunk);\n if (str.includes('content-length') || str.includes('dtype not specified')) return true;\n return (originalStderrWrite as (...a: unknown[]) => boolean)(chunk, ...args);\n };\n process.stderr.write = stderrFilter as typeof process.stderr.write;\n\n let cg;\n try {\n if (!KiroGraph.isInitialized(cwd)) {\n process.stdout.write(' Downloading embedding model\u2026\\n');\n cg = await KiroGraph.init(cwd, undefined, modelProgress);\n process.stdout.write('\\n');\n console.log(' \u2713 Created .kirograph/');\n } else {\n cg = await KiroGraph.open(cwd, modelProgress);\n if (fileBytes.size > 0) process.stdout.write('\\n');\n }\n } finally {\n process.stderr.write = originalStderrWrite;\n }\n console.log(' Indexing...');\n const result = await cg.indexAll({ onProgress: renderIndexProgress });\n process.stdout.write('\\n');\n console.log(` \u2713 Indexed ${result.filesIndexed} files, ${result.nodesCreated} symbols, ${result.edgesCreated} edges`);\n cg.close();\n\n if (typesenseDashboard) {\n const dashboardServer = await openTypesenseDashboard(cwd);\n console.log(` ${dim}Press Ctrl+C to stop the dashboard server when done.${reset}`);\n await new Promise<void>(resolve => {\n process.on('SIGINT', () => {\n if (dashboardServer) {\n dashboardServer.close(() => resolve());\n } else {\n resolve();\n }\n });\n });\n return; // rl.close() handled in finally\n }\n\n if (qdrantDashboard) {\n await openQdrantDashboard(cwd);\n }\n }\n\n installer.printNextSteps(cwd);\n } finally {\n rl.close();\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,eAA0B;AAC1B,SAAoB;AACpB,WAAsB;AACtB,2BAA0B;AAC1B,oBAAyC;AACzC,oBAA4B;AAC5B,sBAAoC;AACpC,gBAA2B;AAC3B,qBAA+B;AAC/B,2BAAoC;AACpC,uBAAuC;AACvC,8BAAoD;AAEpD,qBAAmC;AAGnC,eAAsB,aAAa,SAAwB,QAAQ,OAA0B,CAAC,GAAkB;AAC9G,iCAAY;AAEZ,QAAM,KAAK,SAAS,gBAAgB,EAAE,OAAO,QAAQ,OAAO,QAAQ,QAAQ,OAAO,CAAC;AAEpF,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,UAAM,gBAAY,mCAAmB,MAAM;AAE3C,YAAQ,IAAI,gBAAgB,GAAG;AAAA,CAAI;AAEnC,QAAI,CAAC,KAAK,KAAK;AACb,YAAM,UAAU,UAAM,0BAAU,IAAI,yBAAyB,UAAU,KAAK,KAAK,2EAA2E;AAC5J,UAAI,CAAC,SAAS;AAAE,gBAAQ,IAAI,cAAc;AAAG,WAAG,MAAM;AAAG;AAAA,MAAQ;AAAA,IACnE,OAAO;AACL,cAAQ,IAAI,8BAA8B,UAAU,KAAK,UAAU;AAAA,IACrE;AACA,YAAQ,IAAI;AAEZ,cAAU,aAAa,GAAG;AAE1B,UAAM,qBAAqB,GAAG,WAAW,KAAK,KAAK,KAAK,YAAY,CAAC;AACrE,QAAI,cAAmC;AACvC,QAAI,wBAAmE;AACvE,QAAI,eAAe;AAC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;AAAA,+BAAkC;AAC9C,gBAAM,oBAAgB,gCAAU,OAAO,CAAC,WAAW,kBAAkB,iBAAiB,GAAG;AAAA,YACvF,OAAO;AAAA,YACP,OAAO;AAAA,UACT,CAAC;AACD,cAAI,cAAc,WAAW,GAAG;AAC9B,oBAAQ,IAAI,mCAA8B;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * KiroGraph Installer\n *\n * The default target wires up Kiro:\n * 1. .kiro/settings/mcp.json \u2014 registers the MCP server (IDE + CLI)\n * 2. .kiro/hooks/*.kiro.hook \u2014 auto-sync hooks for Kiro IDE\n * 3. .kiro/steering/kirograph.md \u2014 teaches Kiro to use the graph tools (IDE + CLI)\n * 4. .kiro/agents/kirograph.json \u2014 custom agent config for Kiro CLI\n */\n\nimport * as readline from 'readline';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { spawnSync } from 'child_process';\nimport { loadConfig, updateConfig } from '../../config';\nimport { printBanner } from '../banner';\nimport { renderIndexProgress } from '../progress';\nimport { dim, reset } from '../ui';\nimport { ask, askToggle } from './prompts';\nimport { promptConfigOptions } from './config-prompt';\nimport { openTypesenseDashboard } from './dashboard';\nimport { ensureQdrantUI, openQdrantDashboard } from './qdrant-dashboard';\nimport type { InstallTarget } from './common';\nimport { getTargetInstaller } from './targets';\nimport type { CavemanMode } from './caveman';\n\nexport async function runInstaller(target: InstallTarget = 'kiro', opts: { yes?: boolean } = {}): Promise<void> {\n printBanner();\n\n const rl = readline.createInterface({ input: process.stdin, output: process.stdout });\n\n try {\n const cwd = process.cwd();\n const installer = getTargetInstaller(target);\n\n console.log(` Workspace: ${cwd}\\n`);\n\n if (!opts.yes) {\n const proceed = await askToggle(rl, `Install KiroGraph for ${installer.label}?`, 'Registers the MCP server and writes integration files for this workspace.');\n if (!proceed) { console.log(' Cancelled.'); rl.close(); return; }\n } else {\n console.log(` Installing KiroGraph for ${installer.label} (--yes)`);\n }\n console.log();\n\n installer.installEarly(cwd);\n\n const alreadyInitialized = fs.existsSync(path.join(cwd, '.kirograph'));\n let cavemanMode: CavemanMode | 'off' = 'off';\n let shellCompressionLevel: 'off' | 'normal' | 'aggressive' | 'ultra' = 'normal';\n let enableMemory = false;\n let enableDocs = false;\n let enableData = false;\n let enableSecurity = false;\n let enablePatterns = false;\n let enableArchitecture = false;\n let enableWatchmen = false;\n let watchmenSynthesisMode: 'local' | 'agent' = 'local';\n let shouldOfferIndex = false;\n let typesenseDashboard = false;\n let qdrantDashboard = false;\n\n try {\n if (alreadyInitialized) {\n const config = await loadConfig(cwd);\n cavemanMode = config.cavemanMode ?? 'off';\n shellCompressionLevel = config.shellCompressionLevel ?? 'normal';\n enableMemory = config.enableMemory ?? false;\n enableDocs = config.enableDocs ?? false;\n enableData = (config as any).enableData ?? false;\n enableSecurity = (config as any).enableSecurity ?? false;\n enableWatchmen = config.enableWatchmen ?? false;\n watchmenSynthesisMode = config.watchmenSynthesisMode ?? 'local';\n enablePatterns = (config as any).enablePatterns ?? false;\n enableArchitecture = config.enableArchitecture ?? false;\n console.log(` \u2713 Reusing existing KiroGraph data in ${cwd}/.kirograph/`);\n console.log(` \u2022 semanticEngine: ${config.semanticEngine}`);\n console.log(` \u2022 enableEmbeddings: ${config.enableEmbeddings}`);\n console.log(` \u2022 enableArchitecture: ${config.enableArchitecture}`);\n console.log(` \u2022 cavemanMode: ${cavemanMode}`);\n console.log(` \u2022 shellCompressionLevel: ${shellCompressionLevel}`);\n console.log(` \u2022 enableMemory: ${enableMemory}`);\n console.log(` \u2022 enableDocs: ${enableDocs}`);\n console.log(` \u2022 enableData: ${enableData}`);\n console.log(` \u2022 enableSecurity: ${enableSecurity}`);\n console.log(` \u2022 enablePatterns: ${enablePatterns}`);\n } else {\n shouldOfferIndex = true;\n const patch = await promptConfigOptions(rl);\n await updateConfig(cwd, patch);\n cavemanMode = patch.cavemanMode ?? 'off';\n shellCompressionLevel = patch.shellCompressionLevel ?? 'normal';\n enableMemory = patch.enableMemory ?? false;\n enableDocs = patch.enableDocs ?? false;\n enableData = patch.enableData ?? false;\n enableSecurity = patch.enableSecurity ?? false;\n enablePatterns = patch.enablePatterns ?? false;\n enableArchitecture = patch.enableArchitecture ?? false;\n enableWatchmen = patch.enableWatchmen ?? false;\n watchmenSynthesisMode = patch.watchmenSynthesisMode ?? 'local';\n typesenseDashboard = patch.typesenseDashboard;\n qdrantDashboard = patch.qdrantDashboard;\n\n console.log(`\\n Configuration saved to ${cwd}/.kirograph/config.json`);\n console.log(` \u2022 enableEmbeddings: ${patch.enableEmbeddings}`);\n if ('embeddingModel' in patch) {\n console.log(` \u2022 embeddingModel: ${patch.embeddingModel} ${dim}(${patch.embeddingDim}-dim)${reset}`);\n }\n if (patch.enableEmbeddings) {\n console.log(` \u2022 semanticEngine: ${patch.semanticEngine}`);\n if (patch.semanticEngine === 'sqlite-vec') {\n console.log(`\\n Installing sqlite-vec dependencies...`);\n const result = spawnSync('npm', ['install', 'better-sqlite3', 'sqlite-vec'], { stdio: 'inherit', shell: true });\n if (result.status === 0) {\n console.log(` \u2713 better-sqlite3 and sqlite-vec installed`);\n } else {\n console.warn(` \u2717 npm install failed (exit ${result.status}). Run manually:`);\n console.warn(` npm install better-sqlite3 sqlite-vec`);\n }\n } else if (patch.semanticEngine === 'orama') {\n console.log(`\\n Installing Orama dependencies...`);\n const result = spawnSync('npm', ['install', '@orama/orama', '@orama/plugin-data-persistence'], { stdio: 'inherit', shell: true });\n if (result.status === 0) {\n console.log(` \u2713 @orama/orama and @orama/plugin-data-persistence installed`);\n } else {\n console.warn(` \u2717 npm install failed (exit ${result.status}). Run manually:`);\n console.warn(` npm install @orama/orama @orama/plugin-data-persistence`);\n }\n } else if (patch.semanticEngine === 'pglite') {\n console.log(`\\n Installing PGlite dependencies...`);\n const result = spawnSync('npm', ['install', '@electric-sql/pglite'], { stdio: 'inherit', shell: true });\n if (result.status === 0) {\n console.log(` \u2713 @electric-sql/pglite installed`);\n } else {\n console.warn(` \u2717 npm install failed (exit ${result.status}). Run manually:`);\n console.warn(` npm install @electric-sql/pglite`);\n }\n } else if (patch.semanticEngine === 'lancedb') {\n console.log(`\\n Installing LanceDB dependencies...`);\n const result = spawnSync('npm', ['install', '@lancedb/lancedb'], { stdio: 'inherit', shell: true });\n if (result.status === 0) {\n console.log(` \u2713 @lancedb/lancedb installed`);\n } else {\n console.warn(` \u2717 npm install failed (exit ${result.status}). Run manually:`);\n console.warn(` npm install @lancedb/lancedb`);\n }\n } else if (patch.semanticEngine === 'qdrant') {\n console.log(`\\n Installing Qdrant dependencies...`);\n const result = spawnSync('npm', ['install', 'qdrant-local'], { stdio: 'inherit', shell: true });\n if (result.status === 0) {\n console.log(` \u2713 qdrant-local installed`);\n } else {\n console.warn(` \u2717 npm install failed (exit ${result.status}). Run manually:`);\n console.warn(` npm install qdrant-local`);\n }\n } else if (patch.semanticEngine === 'typesense') {\n console.log(`\\n Installing Typesense dependencies...`);\n const result = spawnSync('npm', ['install', 'typesense'], { stdio: 'inherit', shell: true });\n if (result.status === 0) {\n console.log(` \u2713 typesense installed`);\n console.log(` \u2139 The Typesense binary (~37MB) will be auto-downloaded on first index run.`);\n } else {\n console.warn(` \u2717 npm install failed (exit ${result.status}). Run manually:`);\n console.warn(` npm install typesense`);\n }\n }\n }\n console.log(` \u2022 extractDocstrings: ${patch.extractDocstrings}`);\n console.log(` \u2022 trackCallSites: ${patch.trackCallSites}`);\n console.log(` \u2022 enableArchitecture: ${patch.enableArchitecture}`);\n console.log(` \u2022 cavemanMode: ${cavemanMode}`);\n console.log(` \u2022 shellCompressionLevel: ${shellCompressionLevel}`);\n console.log(` \u2022 enableMemory: ${enableMemory}`);\n console.log(` \u2022 enableDocs: ${enableDocs}`);\n console.log(` \u2022 enableData: ${enableData}`);\n console.log(` \u2022 enableSecurity: ${enableSecurity}`);\n console.log(` \u2022 enablePatterns: ${enablePatterns}`);\n\n // Install optional data format deps if enableData is on\n if (enableData) {\n if ((patch as any).dataInstallExcel) {\n console.log(`\\n Installing xlsx...`);\n const xlsxResult = spawnSync('npm', ['install', 'xlsx'], { stdio: 'inherit', shell: true });\n if (xlsxResult.status === 0) {\n console.log(` \u2713 xlsx installed`);\n } else {\n console.warn(` \u2717 npm install failed. Run manually: npm install xlsx`);\n }\n }\n if ((patch as any).dataInstallParquet) {\n console.log(`\\n Installing parquetjs-lite...`);\n const pqResult = spawnSync('npm', ['install', 'parquetjs-lite'], { stdio: 'inherit', shell: true });\n if (pqResult.status === 0) {\n console.log(` \u2713 parquetjs-lite installed`);\n } else {\n console.warn(` \u2717 npm install failed. Run manually: npm install parquetjs-lite`);\n }\n }\n }\n\n if (enablePatterns) {\n console.log(`\\n Installing @ast-grep/napi...`);\n const astGrepResult = spawnSync('npm', ['install', '@ast-grep/napi', '--save-optional'], {\n stdio: 'inherit',\n shell: true,\n });\n if (astGrepResult.status === 0) {\n console.log(` \u2713 @ast-grep/napi installed`);\n\n // Install tree-sitter grammar packages for languages beyond the built-in\n // JS/TS/HTML/CSS set. These are optional \u2014 missing packages are silently\n // skipped at runtime, so a failed install here isn't fatal.\n const langPackages = [\n '@ast-grep/lang-go',\n '@ast-grep/lang-python',\n '@ast-grep/lang-java',\n '@ast-grep/lang-rust',\n '@ast-grep/lang-c',\n '@ast-grep/lang-cpp',\n '@ast-grep/lang-csharp',\n '@ast-grep/lang-kotlin',\n '@ast-grep/lang-swift',\n '@ast-grep/lang-ruby',\n '@ast-grep/lang-php',\n '@ast-grep/lang-bash',\n '@ast-grep/lang-scala',\n '@ast-grep/lang-dart',\n '@ast-grep/lang-lua',\n '@ast-grep/lang-elixir',\n '@ast-grep/lang-haskell',\n ];\n const langResult = spawnSync('npm', ['install', ...langPackages, '--save-optional'], {\n stdio: 'inherit',\n shell: true,\n });\n if (langResult.status === 0) {\n console.log(` \u2713 @ast-grep language grammars installed`);\n } else {\n console.warn(` \u2717 Language grammar install failed. Pattern matching will be limited to JS/TS/HTML/CSS.`);\n console.warn(` Run manually: npm install ${langPackages.join(' ')}`);\n }\n } else {\n console.warn(` \u2717 @ast-grep/napi install failed. Run manually: npm install @ast-grep/napi`);\n console.warn(` KiroGraph will continue but kirograph pattern and kirograph_live_search will be unavailable.`);\n }\n }\n }\n\n installer.installLate(cwd, cavemanMode, shellCompressionLevel, enableMemory, enableDocs, enableData, enableSecurity, enableArchitecture, enablePatterns, enableWatchmen, watchmenSynthesisMode);\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err);\n console.error(`\\n \u2717 Failed to write configuration: ${reason}`);\n process.exit(1);\n }\n\n // 5. Pre-download Qdrant UI before indexing so Qdrant starts with static content dir\n if (qdrantDashboard) {\n await ensureQdrantUI(cwd);\n }\n\n // 6. Optionally init + index\n const doIndex = shouldOfferIndex && (opts.yes || await askToggle(rl, 'Initialize and index this project now?', 'Creates .kirograph/ and indexes all source files. Takes a few seconds for small projects, longer for large ones.'));\n if (doIndex) {\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n\n const fileBytes = new Map<string, { loaded: number; total: number }>();\n const modelProgress = (file: string, loaded: number, total: number, done: boolean): void => {\n const entry = fileBytes.get(file) ?? { loaded: 0, total: 0 };\n if (total > 0) entry.total = total;\n entry.loaded = done ? entry.total : loaded;\n fileBytes.set(file, entry);\n\n // Only count files where we know the size (content-length was present)\n const knownFiles = Array.from(fileBytes.values()).filter(f => f.total > 0);\n const totalLoaded = knownFiles.reduce((s, f) => s + f.loaded, 0);\n const totalBytes = knownFiles.reduce((s, f) => s + f.total, 0);\n const pct = totalBytes > 0 ? Math.min((totalLoaded / totalBytes) * 100, 100) : 0;\n\n const filled = Math.round(pct / 5);\n const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(20 - filled);\n const mb = (totalLoaded / 1024 / 1024).toFixed(1);\n const totalMb = (totalBytes / 1024 / 1024).toFixed(1);\n process.stdout.write(`\\r [${bar}] ${pct.toFixed(0).padStart(3)}% ${mb} / ${totalMb} MB `);\n };\n\n // Suppress noisy internal warnings from @huggingface/transformers during download\n const originalStderrWrite = process.stderr.write.bind(process.stderr);\n const stderrFilter = (chunk: unknown, ...args: unknown[]): boolean => {\n const str = typeof chunk === 'string' ? chunk : String(chunk);\n if (str.includes('content-length') || str.includes('dtype not specified')) return true;\n return (originalStderrWrite as (...a: unknown[]) => boolean)(chunk, ...args);\n };\n process.stderr.write = stderrFilter as typeof process.stderr.write;\n\n let cg;\n try {\n if (!KiroGraph.isInitialized(cwd)) {\n process.stdout.write(' Downloading embedding model\u2026\\n');\n cg = await KiroGraph.init(cwd, undefined, modelProgress);\n process.stdout.write('\\n');\n console.log(' \u2713 Created .kirograph/');\n } else {\n cg = await KiroGraph.open(cwd, modelProgress);\n if (fileBytes.size > 0) process.stdout.write('\\n');\n }\n } finally {\n process.stderr.write = originalStderrWrite;\n }\n console.log(' Indexing...');\n const result = await cg.indexAll({ onProgress: renderIndexProgress });\n process.stdout.write('\\n');\n console.log(` \u2713 Indexed ${result.filesIndexed} files, ${result.nodesCreated} symbols, ${result.edgesCreated} edges`);\n cg.close();\n\n if (typesenseDashboard) {\n const dashboardServer = await openTypesenseDashboard(cwd);\n console.log(` ${dim}Press Ctrl+C to stop the dashboard server when done.${reset}`);\n await new Promise<void>(resolve => {\n process.on('SIGINT', () => {\n if (dashboardServer) {\n dashboardServer.close(() => resolve());\n } else {\n resolve();\n }\n });\n });\n return; // rl.close() handled in finally\n }\n\n if (qdrantDashboard) {\n await openQdrantDashboard(cwd);\n }\n }\n\n installer.printNextSteps(cwd);\n } finally {\n rl.close();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,eAA0B;AAC1B,SAAoB;AACpB,WAAsB;AACtB,2BAA0B;AAC1B,oBAAyC;AACzC,oBAA4B;AAC5B,sBAAoC;AACpC,gBAA2B;AAC3B,qBAA+B;AAC/B,2BAAoC;AACpC,uBAAuC;AACvC,8BAAoD;AAEpD,qBAAmC;AAGnC,eAAsB,aAAa,SAAwB,QAAQ,OAA0B,CAAC,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,cAAQ,OAAO,MAAM,IAAI;AACzB,cAAQ,IAAI,oBAAe,OAAO,YAAY,WAAW,OAAO,YAAY,aAAa,OAAO,YAAY,QAAQ;AACpH,SAAG,MAAM;AAET,UAAI,oBAAoB;AACtB,cAAM,kBAAkB,UAAM,yCAAuB,GAAG;AACxD,gBAAQ,IAAI,KAAK,aAAG,uDAAuD,eAAK,EAAE;AAClF,cAAM,IAAI,QAAc,aAAW;AACjC,kBAAQ,GAAG,UAAU,MAAM;AACzB,gBAAI,iBAAiB;AACnB,8BAAgB,MAAM,MAAM,QAAQ,CAAC;AAAA,YACvC,OAAO;AACL,sBAAQ;AAAA,YACV;AAAA,UACF,CAAC;AAAA,QACH,CAAC;AACD;AAAA,MACF;AAEA,UAAI,iBAAiB;AACnB,kBAAM,6CAAoB,GAAG;AAAA,MAC/B;AAAA,IACF;AAEA,cAAU,eAAe,GAAG;AAAA,EAC9B,UAAE;AACA,OAAG,MAAM;AAAA,EACX;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/bin/kirograph.js
CHANGED
|
@@ -85,7 +85,7 @@ process.on("uncaughtException", (err) => {
|
|
|
85
85
|
process.exit(1);
|
|
86
86
|
});
|
|
87
87
|
const program = new import_commander.Command();
|
|
88
|
-
program.name("kirograph").description("Semantic code knowledge graph for Kiro").version("0.20.
|
|
88
|
+
program.name("kirograph").description("Semantic code knowledge graph for Kiro").version("0.20.1").addHelpCommand(true).hook("preAction", (thisCommand) => {
|
|
89
89
|
const name = thisCommand.name();
|
|
90
90
|
if (name === "init") (0, import_banner.printBanner)();
|
|
91
91
|
});
|
|
@@ -210,7 +210,9 @@ const TRANSPARENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
210
210
|
"program",
|
|
211
211
|
"source_file",
|
|
212
212
|
"module",
|
|
213
|
-
"translation_unit"
|
|
213
|
+
"translation_unit",
|
|
214
|
+
"chunk"
|
|
215
|
+
// Lua root node type
|
|
214
216
|
]);
|
|
215
217
|
const KIND_MAP = {
|
|
216
218
|
// Functions
|
|
@@ -268,8 +270,16 @@ const KIND_MAP = {
|
|
|
268
270
|
// Variables / constants (language-specific, see extractVariableKind)
|
|
269
271
|
lexical_declaration: "variable",
|
|
270
272
|
// TS/JS (const/let/var) — refined below
|
|
271
|
-
variable_declaration: "variable"
|
|
273
|
+
variable_declaration: "variable",
|
|
272
274
|
// TS/JS (var)
|
|
275
|
+
// Ruby
|
|
276
|
+
method: "method",
|
|
277
|
+
// Ruby def (top-level and in class body)
|
|
278
|
+
class: "class",
|
|
279
|
+
// Ruby class
|
|
280
|
+
// Lua
|
|
281
|
+
local_function_definition_statement: "function",
|
|
282
|
+
function_definition_statement: "function"
|
|
273
283
|
// Import statements (all handled via extractImport)
|
|
274
284
|
};
|
|
275
285
|
function extractVariableKind(node) {
|
|
@@ -679,9 +689,22 @@ function extractName(node, source, _lang, kind) {
|
|
|
679
689
|
}
|
|
680
690
|
}
|
|
681
691
|
}
|
|
692
|
+
if (node.type === "function_definition_statement") {
|
|
693
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
694
|
+
const child = node.child(i);
|
|
695
|
+
if (child.type === "variable") {
|
|
696
|
+
let lastId = null;
|
|
697
|
+
for (let j = 0; j < child.childCount; j++) {
|
|
698
|
+
const gc = child.child(j);
|
|
699
|
+
if (gc.type === "identifier") lastId = source.slice(gc.startIndex, gc.endIndex);
|
|
700
|
+
}
|
|
701
|
+
if (lastId) return lastId;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
682
705
|
for (let i = 0; i < node.childCount; i++) {
|
|
683
706
|
const child = node.child(i);
|
|
684
|
-
if (child.type === "identifier" || child.type === "property_identifier" || child.type === "type_identifier") {
|
|
707
|
+
if (child.type === "identifier" || child.type === "property_identifier" || child.type === "type_identifier" || child.type === "simple_identifier" || child.type === "word" || child.type === "name" || child.type === "constant") {
|
|
685
708
|
return source.slice(child.startIndex, child.endIndex);
|
|
686
709
|
}
|
|
687
710
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/extraction/extractor.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Symbol extractor using web-tree-sitter\n * Parses source files and extracts nodes + edges into the graph.\n * Handles functions, classes, methods, variables, constants, and imports.\n */\n\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport * as crypto from 'crypto';\nimport type { Node, Edge, NodeKind, Language } from '../types';\nimport { detectLanguage, isSupportedLanguage } from './languages';\nimport { initGrammars, getParser, hasWasmGrammar } from './grammars';\nimport { extractNotebook } from './notebook';\n\nexport interface UnresolvedRef {\n sourceId: string;\n refName: string;\n refKind: 'function' | 'import' | 'extends' | 'implements';\n line: number;\n column: number;\n}\n\nexport interface ExtractedFile {\n filePath: string;\n language: Language;\n contentHash: string;\n fileSize: number;\n nodes: Node[];\n edges: Edge[];\n unresolvedRefs: UnresolvedRef[];\n}\n\nexport function makeNodeId(filePath: string, kind: string, name: string, line: number): string {\n const hash = crypto.createHash('sha256').update(`${filePath}:${kind}:${name}:${line}`).digest('hex').slice(0, 32);\n return `${kind}:${hash}`;\n}\n\n/** Validate that filePath stays within projectRoot to prevent path traversal. */\nfunction validatePath(filePath: string, projectRoot: string): boolean {\n try {\n const real = fs.realpathSync(filePath);\n const realRoot = fs.realpathSync(projectRoot);\n return real.startsWith(realRoot + path.sep) || real === realRoot;\n } catch {\n // If we can't resolve, check with normalize\n const normalized = path.resolve(filePath);\n return normalized.startsWith(path.resolve(projectRoot));\n }\n}\n\n/**\n * Extract symbols from a single file.\n * Optionally accepts pre-read content for batch I/O efficiency.\n */\nexport async function extractFile(filePath: string, projectRoot: string, content?: Buffer | string): Promise<ExtractedFile | null> {\n const language = detectLanguage(filePath);\n if (!isSupportedLanguage(language)) return null;\n\n // Path traversal protection\n if (!validatePath(filePath, projectRoot)) return null;\n\n let source: string;\n try {\n if (content !== undefined) {\n source = typeof content === 'string' ? content : content.toString('utf8');\n } else {\n source = fs.readFileSync(filePath, 'utf8');\n }\n } catch {\n return null;\n }\n\n // Delegate Jupyter notebooks to the dedicated notebook extractor\n if (language === 'jupyter') {\n return extractNotebook(filePath, projectRoot, source);\n }\n\n const contentHash = crypto.createHash('sha256').update(source).digest('hex');\n const fileSize = Buffer.byteLength(source, 'utf8');\n const relPath = path.relative(projectRoot, filePath).replace(/\\\\/g, '/');\n\n await initGrammars();\n const parser = await getParser(language);\n if (!parser) {\n if (!hasWasmGrammar(language)) {\n // Language genuinely has no grammar (e.g. Liquid, unknown) \u2014 track file but no AST extraction\n return {\n filePath: relPath,\n language,\n contentHash,\n fileSize,\n nodes: [],\n edges: [],\n unresolvedRefs: [],\n };\n }\n // Grammar should exist but parser failed (likely WASM crash) \u2014 signal extraction failure\n throw new Error(`Parser unavailable for ${language} (WASM grammar exists but failed to load)`);\n }\n\n const tree = parser.parse(source);\n\n const nodes: Node[] = [];\n const edges: Edge[] = [];\n const unresolvedRefs: UnresolvedRef[] = [];\n const now = Date.now();\n\n walkTree(tree.rootNode, source, relPath, language, nodes, edges, unresolvedRefs, now);\n\n return { filePath: relPath, language, contentHash, fileSize, nodes, edges, unresolvedRefs };\n}\n\n// \u2500\u2500 Elixir helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst ELIXIR_DEF_KINDS: Record<string, NodeKind> = {\n defmodule: 'module',\n def: 'function',\n defp: 'function',\n defmacro: 'function',\n defmacrop: 'function',\n defprotocol: 'interface',\n defimpl: 'class',\n defstruct: 'struct',\n};\n\nconst ELIXIR_IMPORT_TARGETS = new Set(['alias', 'import', 'require', 'use']);\n\nfunction elixirCallTarget(node: any, source: string): string | null {\n const target = node.childForFieldName?.('target') ?? node.child(0);\n if (!target) return null;\n return source.slice(target.startIndex, target.endIndex).trim() || null;\n}\n\nfunction elixirFirstArg(node: any): any | null {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'arguments') {\n return child.namedChild(0) ?? child.child(0) ?? null;\n }\n }\n return null;\n}\n\nfunction extractElixirName(node: any, source: string, kind: NodeKind): string | null {\n const firstArg = elixirFirstArg(node);\n if (!firstArg) return null;\n if (kind === 'module' || kind === 'interface' || kind === 'class') {\n return source.slice(firstArg.startIndex, firstArg.endIndex).trim();\n }\n if (kind === 'function') {\n if (firstArg.type === 'call') {\n const nameNode = firstArg.childForFieldName?.('target') ?? firstArg.child(0);\n if (nameNode) return source.slice(nameNode.startIndex, nameNode.endIndex).trim();\n }\n return source.slice(firstArg.startIndex, firstArg.endIndex).trim();\n }\n return null;\n}\n\nfunction extractElixirImportSource(node: any, source: string): string | null {\n const firstArg = elixirFirstArg(node);\n if (!firstArg) return null;\n return source.slice(firstArg.startIndex, firstArg.endIndex).trim() || null;\n}\n\nfunction walkElixirCall(\n node: any,\n source: string,\n filePath: string,\n language: Language,\n nodes: Node[],\n edges: Edge[],\n unresolvedRefs: UnresolvedRef[],\n now: number,\n parentId?: string\n): void {\n const targetText = elixirCallTarget(node, source);\n if (!targetText) {\n for (let i = 0; i < node.childCount; i++) {\n walkTree(node.child(i), source, filePath, language, nodes, edges, unresolvedRefs, now, parentId);\n }\n return;\n }\n\n if (ELIXIR_IMPORT_TARGETS.has(targetText)) {\n const modPath = extractElixirImportSource(node, source);\n if (modPath) {\n const id = makeNodeId(filePath, 'import', modPath, node.startPosition.row + 1);\n nodes.push({\n id, kind: 'import', name: modPath,\n qualifiedName: `${filePath}::import:${modPath}`,\n filePath, language,\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n startColumn: node.startPosition.column,\n endColumn: node.endPosition.column,\n updatedAt: now,\n });\n unresolvedRefs.push({ sourceId: id, refName: modPath, refKind: 'import', line: node.startPosition.row + 1, column: node.startPosition.column });\n }\n return;\n }\n\n const defKind = ELIXIR_DEF_KINDS[targetText];\n if (defKind) {\n const name = extractElixirName(node, source, defKind);\n if (name) {\n const id = makeNodeId(filePath, defKind, name, node.startPosition.row + 1);\n const isPrivate = targetText === 'defp' || targetText === 'defmacrop';\n nodes.push({\n id, kind: defKind, name,\n qualifiedName: `${filePath}::${name}`,\n filePath, language,\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n startColumn: node.startPosition.column,\n endColumn: node.endPosition.column,\n docstring: extractDocstring(node, source),\n signature: extractSignature(node, source, defKind),\n visibility: isPrivate ? 'private' : 'public',\n isExported: !isPrivate,\n updatedAt: now,\n });\n if (parentId) edges.push({ source: parentId, target: id, kind: 'contains' });\n collectCallRefs(node, source, id, unresolvedRefs);\n for (let i = 0; i < node.childCount; i++) {\n walkTree(node.child(i), source, filePath, language, nodes, edges, unresolvedRefs, now, id);\n }\n return;\n }\n }\n\n for (let i = 0; i < node.childCount; i++) {\n walkTree(node.child(i), source, filePath, language, nodes, edges, unresolvedRefs, now, parentId);\n }\n}\n\n// \u2500\u2500 Node type mappings \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** AST node types that should be descended without creating a symbol node */\nconst TRANSPARENT_TYPES = new Set([\n 'export_statement', 'program', 'source_file', 'module', 'translation_unit',\n]);\n\n/** Mapping from tree-sitter node types to graph NodeKind */\nconst KIND_MAP: Record<string, NodeKind> = {\n // Functions\n function_declaration: 'function',\n function_expression: 'function',\n arrow_function: 'function',\n function_definition: 'function', // Python, Scala\n function_item: 'function', // Rust\n function_declaration_go: 'function',\n // Methods\n method_definition: 'method',\n method_declaration: 'method', // Go, Java, C#\n constructor_declaration: 'method', // Java, C#\n // Classes / structs\n class_declaration: 'class',\n class_expression: 'class',\n class_definition: 'class', // Python, Scala\n impl_item: 'class', // Rust (impl blocks)\n struct_item: 'struct', // Rust\n struct_definition: 'struct', // Zig\n // Interfaces / traits\n interface_declaration: 'interface',\n trait_item: 'trait', // Rust\n trait_definition: 'trait', // Scala\n protocol_declaration: 'interface', // Swift\n // Enums\n enum_declaration: 'enum',\n enum_item: 'enum', // Rust\n // Type aliases\n type_alias_declaration: 'type_alias',\n type_declaration: 'type_alias', // Go\n typealias_declaration: 'type_alias',// Swift\n type_item: 'type_alias', // Rust\n type_alias: 'type_alias', // Kotlin\n // Namespaces / modules\n namespace_declaration: 'namespace',\n module_definition: 'namespace', // OCaml\n // Variables / constants (language-specific, see extractVariableKind)\n lexical_declaration: 'variable', // TS/JS (const/let/var) \u2014 refined below\n variable_declaration: 'variable', // TS/JS (var)\n // Import statements (all handled via extractImport)\n};\n\n/** Refine variable declarations into 'variable' or 'constant' based on modifier */\nfunction extractVariableKind(node: any): NodeKind {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'const') return 'constant';\n }\n return 'variable';\n}\n\n/**\n * Widget superclass names that mark a Dart class as a UI component.\n * `State<Foo>` subclasses are kept as 'class' \u2014 they are state holders, not widgets.\n */\nconst DART_WIDGET_SUPERCLASSES = new Set([\n 'StatelessWidget',\n 'StatefulWidget',\n 'HookWidget',\n 'ConsumerWidget',\n 'ConsumerStatefulWidget',\n]);\n\n/**\n * Inspect a Dart class_definition node's superclass clause to decide if the\n * class is a widget component or a plain class.\n *\n * Dart tree-sitter grammar: class_definition \u2192 superclass \u2192 type_identifier\n * We look for any child/grandchild whose text is one of the known widget base classes.\n */\nfunction refineDartClassKind(node: any, source: string): NodeKind {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'superclass') {\n // Walk all descendants of the superclass clause looking for a type_identifier\n const superText = source.slice(child.startIndex, child.endIndex);\n // Quick string check first for performance\n if (DART_WIDGET_SUPERCLASSES.has(superText.replace(/^extends\\s+/, '').trim())) {\n return 'component';\n }\n // Drill into children to find the exact type_identifier\n for (let j = 0; j < child.childCount; j++) {\n const typeNode = child.child(j);\n if (typeNode.type === 'type_identifier' || typeNode.type === 'identifier') {\n const name = source.slice(typeNode.startIndex, typeNode.endIndex).trim();\n if (DART_WIDGET_SUPERCLASSES.has(name)) return 'component';\n // Also match any name that ends with \"Widget\" (catches custom base widgets)\n if (name.endsWith('Widget') && name !== 'State') return 'component';\n }\n }\n }\n }\n return 'class';\n}\n\n/** Languages/node-types that represent import statements */\nconst IMPORT_NODE_TYPES = new Set([\n 'import_statement', // TS/JS\n 'import_from_statement', // Python\n 'import_declaration', // Go, Java\n 'use_declaration', // Rust\n 'using_directive', // C#\n 'namespace_use_declaration',// PHP\n 'import_header', // Kotlin\n 'import_or_export', // Dart\n 'include_statement', // Pascal\n 'preproc_include', // C/C++\n]);\n\n// \u2500\u2500 Main tree walker \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction walkTree(\n node: any,\n source: string,\n filePath: string,\n language: Language,\n nodes: Node[],\n edges: Edge[],\n unresolvedRefs: UnresolvedRef[],\n now: number,\n parentId?: string\n): void {\n if (TRANSPARENT_TYPES.has(node.type)) {\n for (let i = 0; i < node.childCount; i++) {\n walkTree(node.child(i), source, filePath, language, nodes, edges, unresolvedRefs, now, parentId);\n }\n return;\n }\n\n // Elixir: all definitions and imports are `call` nodes\n if (language === 'elixir' && node.type === 'call') {\n walkElixirCall(node, source, filePath, language, nodes, edges, unresolvedRefs, now, parentId);\n return;\n }\n\n // Handle import statements\n if (IMPORT_NODE_TYPES.has(node.type)) {\n const importNode = extractImport(node, source, filePath, language, unresolvedRefs, now, parentId);\n if (importNode) nodes.push(importNode);\n return; // Don't recurse into import nodes\n }\n\n let kind: NodeKind | null = KIND_MAP[node.type] ?? null;\n\n // Refine lexical_declaration into variable/constant\n if (node.type === 'lexical_declaration' || node.type === 'variable_declaration') {\n kind = extractVariableKind(node);\n }\n\n // Python/Go/Rust/Java/C# variable and constant types\n if (!kind) kind = getLanguageSpecificKind(node.type, language);\n\n // Dart: refine class_definition kind based on superclass (Widget \u2192 component)\n if (language === 'dart' && node.type === 'class_definition' && kind === 'class') {\n kind = refineDartClassKind(node, source);\n }\n\n if (kind) {\n const name = extractName(node, source, language, kind);\n if (name) {\n const id = makeNodeId(filePath, kind, name, node.startPosition.row + 1);\n const visibility = extractVisibility(node, source, language);\n const graphNode: Node = {\n id,\n kind,\n name,\n qualifiedName: `${filePath}::${name}`,\n filePath,\n language,\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n startColumn: node.startPosition.column,\n endColumn: node.endPosition.column,\n docstring: extractDocstring(node, source),\n signature: extractSignature(node, source, kind),\n visibility,\n isExported: isExported(node),\n isAsync: isAsync(node),\n isStatic: isStatic(node),\n updatedAt: now,\n };\n nodes.push(graphNode);\n\n if (parentId) {\n edges.push({ source: parentId, target: id, kind: 'contains' });\n }\n\n // Collect call references within this symbol\n collectCallRefs(node, source, id, unresolvedRefs);\n\n // Extract inheritance edges for C# and Java class/interface nodes\n if ((kind === 'class' || kind === 'interface') && (language === 'csharp' || language === 'java')) {\n extractInheritance(node, source, language, id, unresolvedRefs);\n }\n\n // Recurse with this node as parent\n for (let i = 0; i < node.childCount; i++) {\n walkTree(node.child(i), source, filePath, language, nodes, edges, unresolvedRefs, now, id);\n }\n return;\n }\n }\n\n // No symbol \u2014 recurse without changing parent\n for (let i = 0; i < node.childCount; i++) {\n walkTree(node.child(i), source, filePath, language, nodes, edges, unresolvedRefs, now, parentId);\n }\n}\n\n// \u2500\u2500 Language-specific node kinds \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction getLanguageSpecificKind(type: string, lang: Language): NodeKind | null {\n switch (lang) {\n case 'python':\n if (type === 'assignment') return 'variable';\n break;\n case 'go':\n if (type === 'var_declaration' || type === 'short_var_declaration') return 'variable';\n if (type === 'const_declaration') return 'constant';\n if (type === 'type_spec') return 'type_alias';\n break;\n case 'rust':\n if (type === 'let_declaration') return 'variable';\n if (type === 'const_item') return 'constant';\n if (type === 'static_item') return 'variable';\n break;\n case 'java':\n if (type === 'field_declaration') return 'property';\n if (type === 'local_variable_declaration') return 'variable';\n break;\n case 'csharp':\n if (type === 'field_declaration') return 'property';\n break;\n case 'php':\n if (type === 'property_declaration') return 'property';\n if (type === 'const_declaration') return 'constant';\n break;\n case 'kotlin':\n if (type === 'property_declaration') return 'variable';\n break;\n case 'swift':\n if (type === 'property_declaration') return 'property';\n if (type === 'constant_declaration') return 'constant';\n break;\n case 'dart':\n if (type === 'function_signature') return 'function';\n if (type === 'method_signature') return 'method';\n break;\n case 'ruby':\n if (type === 'singleton_method') return 'method';\n break;\n case 'scala':\n if (type === 'object_definition') return 'class';\n if (type === 'val_definition') return 'variable';\n if (type === 'var_definition') return 'variable';\n if (type === 'type_definition') return 'type_alias';\n break;\n case 'lua':\n if (type === 'local_function') return 'function';\n if (type === 'local_variable_declaration') return 'variable';\n if (type === 'variable_assignment') return 'variable';\n break;\n case 'zig':\n if (type === 'VarDecl') return 'variable';\n if (type === 'ContainerDecl') return 'struct';\n break;\n case 'bash':\n if (type === 'variable_assignment') return 'variable';\n break;\n case 'ocaml':\n if (type === 'let_binding') return 'variable';\n if (type === 'type_binding') return 'type_alias';\n if (type === 'module_binding') return 'namespace';\n break;\n case 'elm':\n if (type === 'function_declaration_left') return 'function';\n if (type === 'type_alias_declaration') return 'type_alias';\n break;\n case 'solidity':\n if (type === 'contract_declaration') return 'class';\n if (type === 'event_definition') return 'function';\n if (type === 'modifier_definition') return 'function';\n if (type === 'state_variable_declaration') return 'variable';\n break;\n case 'objc':\n if (type === 'class_interface') return 'class';\n if (type === 'class_implementation') return 'class';\n if (type === 'protocol_declaration') return 'interface';\n if (type === 'method_declaration') return 'method';\n if (type === 'property_declaration') return 'property';\n break;\n case 'hcl':\n if (type === 'block') return 'namespace';\n if (type === 'attribute') return 'variable';\n break;\n case 'scss':\n if (type === 'mixin_statement') return 'function';\n if (type === 'function_statement') return 'function';\n if (type === 'variable_declaration') return 'variable';\n if (type === 'include_statement') return 'import';\n if (type === 'use_statement') return 'import';\n if (type === 'forward_statement') return 'import';\n if (type === 'placeholder') return 'class';\n break;\n case 'css':\n if (type === 'rule_set') return 'class';\n if (type === 'declaration') return 'variable';\n break;\n case 'rescript':\n if (type === 'let_binding') return 'function';\n if (type === 'type_definition') return 'type_alias';\n if (type === 'module_declaration') return 'module';\n break;\n case 'sql':\n if (type === 'create_function_statement') return 'function';\n if (type === 'create_table_statement') return 'class';\n if (type === 'create_view_statement') return 'function';\n if (type === 'create_procedure_statement') return 'function';\n break;\n case 'r':\n if (type === 'function_definition') return 'function';\n if (type === 'left_assignment') return 'variable';\n break;\n case 'julia':\n if (type === 'function_definition') return 'function';\n if (type === 'struct_definition') return 'struct';\n if (type === 'module_definition') return 'module';\n if (type === 'macro_definition') return 'function';\n break;\n case 'powershell':\n if (type === 'function_statement') return 'function';\n if (type === 'class_statement') return 'class';\n break;\n case 'perl':\n if (type === 'subroutine_declaration_statement') return 'function';\n if (type === 'package_statement') return 'module';\n break;\n case 'gdscript':\n if (type === 'function_definition') return 'function';\n if (type === 'class_definition') return 'class';\n if (type === 'variable_statement') return 'variable';\n break;\n case 'astro':\n if (type === 'function_declaration') return 'function';\n if (type === 'function_definition') return 'function';\n break;\n case 'nix':\n if (type === 'function') return 'function';\n if (type === 'binding') return 'variable';\n break;\n case 'verilog':\n if (type === 'module_declaration') return 'class';\n if (type === 'task_declaration') return 'function';\n if (type === 'function_declaration') return 'function';\n break;\n }\n return null;\n}\n\n// \u2500\u2500 Import extraction \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction extractImport(\n node: any,\n source: string,\n filePath: string,\n language: Language,\n unresolvedRefs: UnresolvedRef[],\n now: number,\n parentId?: string\n): Node | null {\n const modulePath = extractImportSource(node, source, language);\n if (!modulePath) return null;\n\n const id = makeNodeId(filePath, 'import', modulePath, node.startPosition.row + 1);\n const importNode: Node = {\n id,\n kind: 'import',\n name: modulePath,\n qualifiedName: `${filePath}::import:${modulePath}`,\n filePath,\n language,\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n startColumn: node.startPosition.column,\n endColumn: node.endPosition.column,\n updatedAt: now,\n };\n\n // Register as unresolved import for later file-level resolution\n unresolvedRefs.push({\n sourceId: id,\n refName: modulePath,\n refKind: 'import',\n line: node.startPosition.row + 1,\n column: node.startPosition.column,\n });\n\n return importNode;\n}\n\n/** Extract the module path string from an import statement node */\nfunction extractImportSource(node: any, source: string, language: Language): string | null {\n // TS/JS/Svelte: import X from \"module\" \u2192 look for trailing string literal\n if (\n node.type === 'import_statement' ||\n (language === 'svelte' && node.type === 'import_statement')\n ) {\n for (let i = node.childCount - 1; i >= 0; i--) {\n const child = node.child(i);\n if (child.type === 'string') {\n return stripQuotes(source.slice(child.startIndex, child.endIndex));\n }\n }\n }\n\n // Python: from .module import X or import module\n if (node.type === 'import_from_statement') {\n // Look for dotted_name or relative_import after 'from'\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'dotted_name' || child.type === 'relative_import') {\n return source.slice(child.startIndex, child.endIndex);\n }\n }\n }\n if (node.type === 'import_statement' && language === 'python') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'dotted_name') {\n return source.slice(child.startIndex, child.endIndex);\n }\n }\n }\n\n // Go: import \"path\" or import ( \"path\" )\n if (node.type === 'import_declaration') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'string') {\n return stripQuotes(source.slice(child.startIndex, child.endIndex));\n }\n if (child.type === 'import_spec_list') {\n for (let j = 0; j < child.childCount; j++) {\n const spec = child.child(j);\n if (spec.type === 'import_spec') {\n for (let k = 0; k < spec.childCount; k++) {\n const s = spec.child(k);\n if (s.type === 'string') return stripQuotes(source.slice(s.startIndex, s.endIndex));\n }\n }\n }\n }\n }\n }\n\n // Rust: use path::to::module;\n if (node.type === 'use_declaration') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type !== 'use' && child.type !== ';') {\n return source.slice(child.startIndex, child.endIndex);\n }\n }\n }\n\n // C#: using Namespace.Name;\n if (node.type === 'using_directive') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'qualified_name' || child.type === 'identifier') {\n return source.slice(child.startIndex, child.endIndex);\n }\n }\n }\n\n // Java/Kotlin: import a.b.c\n if (node.type === 'import_declaration' || node.type === 'import_header') {\n const text = source.slice(node.startIndex, node.endIndex).trim();\n const m = text.match(/^import\\s+(.+?)[;\\s*]*$/);\n if (m) return m[1].trim();\n }\n\n // PHP: use Foo\\Bar\n if (node.type === 'namespace_use_declaration') {\n const text = source.slice(node.startIndex, node.endIndex).trim();\n const m = text.match(/^use\\s+(.+?)[;\\s]*$/);\n if (m) return m[1].trim();\n }\n\n // Swift/Dart: import SomeModule\n if (node.type === 'import_declaration' || node.type === 'import_or_export') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'identifier' || child.type === 'string') {\n return source.slice(child.startIndex, child.endIndex);\n }\n }\n }\n\n // C/C++: #include \"file.h\" or #include <lib.h>\n if (node.type === 'preproc_include') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'string_literal' || child.type === 'system_lib_string') {\n return source.slice(child.startIndex, child.endIndex).replace(/[<>\"]/g, '');\n }\n }\n }\n\n return null;\n}\n\nfunction stripQuotes(s: string): string {\n return s.replace(/^['\"`]|['\"`]$/g, '');\n}\n\n// \u2500\u2500 Name extraction \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction extractName(node: any, source: string, _lang: Language, kind: NodeKind): string | null {\n // For variable/constant declarations (lexical_declaration, variable_declaration),\n // the identifier is inside a variable_declarator child\n if (kind === 'variable' || kind === 'constant') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'variable_declarator') {\n for (let j = 0; j < child.childCount; j++) {\n const gc = child.child(j);\n if (gc.type === 'identifier') return source.slice(gc.startIndex, gc.endIndex);\n }\n }\n }\n }\n\n // For Go const_declaration / var_declaration \u2192 look inside var_spec / const_spec\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'var_spec' || child.type === 'const_spec') {\n for (let j = 0; j < child.childCount; j++) {\n const gc = child.child(j);\n if (gc.type === 'identifier') return source.slice(gc.startIndex, gc.endIndex);\n }\n }\n }\n\n // Standard: look for first identifier/property_identifier/type_identifier child\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (\n child.type === 'identifier' ||\n child.type === 'property_identifier' ||\n child.type === 'type_identifier'\n ) {\n return source.slice(child.startIndex, child.endIndex);\n }\n }\n\n // Python assignment: the left side is the name\n if (node.type === 'assignment') {\n const left = node.child(0);\n if (left && left.type === 'identifier') {\n return source.slice(left.startIndex, left.endIndex);\n }\n }\n\n return null;\n}\n\n// \u2500\u2500 Signature extraction \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction extractSignature(node: any, source: string, kind: NodeKind): string | undefined {\n // For functions/methods, try to get the meaningful header without the body\n if (kind === 'function' || kind === 'method') {\n // Try to find parameter list \u2014 stop before the body block\n const text = source.slice(node.startIndex, node.endIndex);\n // Find opening brace or colon (Python), take everything before it\n const bodyStart = text.search(/\\s*[\\{:]\\s*\\n|=>|{/);\n const header = bodyStart > 0 ? text.slice(0, bodyStart).trim() : text.split('\\n')[0].trim();\n return header.length > 150 ? header.slice(0, 150) + '\u2026' : header || undefined;\n }\n\n // Default: first line truncated\n const text = source.slice(node.startIndex, node.endIndex);\n const firstLine = text.split('\\n')[0].trim();\n return firstLine.length > 120 ? firstLine.slice(0, 120) + '\u2026' : firstLine || undefined;\n}\n\n// \u2500\u2500 Visibility extraction \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction extractVisibility(node: any, source: string, language: Language): Node['visibility'] {\n // TypeScript / JavaScript: accessibility_modifier child\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'accessibility_modifier') {\n const mod = source.slice(child.startIndex, child.endIndex);\n if (mod === 'public') return 'public';\n if (mod === 'private') return 'private';\n if (mod === 'protected') return 'protected';\n }\n // Direct modifier keywords (Java, C#, PHP, Swift, Kotlin)\n if (child.type === 'public') return 'public';\n if (child.type === 'private') return 'private';\n if (child.type === 'protected') return 'protected';\n if (child.type === 'internal') return 'internal';\n }\n\n // Rust: no `pub` keyword = private, `pub` = public\n if (language === 'rust') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'visibility_modifier') {\n const v = source.slice(child.startIndex, child.endIndex);\n return v.startsWith('pub') ? 'public' : 'private';\n }\n }\n return 'private'; // Rust default\n }\n\n // C# default: private\n if (language === 'csharp') return 'private';\n\n // PHP default: public\n if (language === 'php') return 'public';\n\n // Swift: check for access modifiers\n if (language === 'swift') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n const t = child.type;\n if (t === 'fileprivate') return 'private';\n }\n return 'internal'; // Swift default\n }\n\n // Python: underscore prefix convention\n if (language === 'python') {\n const name = extractName(node, source, language, 'function');\n if (name?.startsWith('_') && !name.startsWith('__')) return 'protected';\n if (name?.startsWith('__')) return 'private';\n return 'public';\n }\n\n return undefined;\n}\n\n// \u2500\u2500 Misc helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction extractDocstring(node: any, source: string): string | undefined {\n const commentTypes = new Set(['comment', 'block_comment', 'line_comment', 'documentation_comment']);\n const commentLines: string[] = [];\n\n let sibling = node.previousNamedSibling;\n while (sibling && commentTypes.has(sibling.type)) {\n commentLines.unshift(source.slice(sibling.startIndex, sibling.endIndex));\n sibling = sibling.previousNamedSibling;\n }\n\n if (commentLines.length === 0) return undefined;\n\n const cleaned = commentLines.join('\\n')\n .replace(/^\\/\\*+\\s*/gm, '')\n .replace(/\\s*\\*+\\/\\s*$/gm, '')\n .replace(/^\\s*\\*\\s?/gm, '')\n .replace(/^\\/\\/\\s?/gm, '')\n .trim();\n\n return cleaned.length > 0 ? cleaned : undefined;\n}\n\nfunction isExported(node: any): boolean {\n // Walk up the parent chain to find an export_statement ancestor\n let current = node.parent;\n while (current) {\n if (current.type === 'export_statement') return true;\n // Stop at scope boundaries\n if (current.type === 'function_body' || current.type === 'class_body' || current.type === 'statement_block') break;\n current = current.parent;\n }\n return false;\n}\n\nfunction isAsync(node: any): boolean {\n for (let i = 0; i < node.childCount; i++) {\n if (node.child(i).type === 'async') return true;\n }\n return false;\n}\n\nfunction isStatic(node: any): boolean {\n for (let i = 0; i < node.childCount; i++) {\n if (node.child(i).type === 'static') return true;\n }\n return false;\n}\n\n// \u2500\u2500 Call reference collection \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Node types that represent a function/method call across all supported languages.\n * Using a combined set avoids threading a language parameter through the recursive walker.\n */\nconst CALL_NODE_TYPES = new Set([\n 'call_expression', // JS/TS/Go/Rust/Swift/Kotlin/Dart/C/C++\n 'invocation_expression', // C#\n 'method_invocation', // Java\n 'call', // Python/Ruby/Elixir (function calls in bodies)\n 'function_call_expression', // PHP\n]);\n\n/**\n * Extract the callee name from a call node.\n * Uses named field lookup first (more precise), then falls back to first-child heuristic.\n */\nfunction extractCallName(node: any, source: string): string | null {\n // Named fields \u2014 Java uses 'name', Python/Ruby use 'function'/'method', Elixir uses 'target'\n for (const field of ['name', 'method', 'function', 'target']) {\n const f = node.childForFieldName?.(field);\n if (f) {\n const t = f.type;\n if (t === 'identifier' || t === 'name' || t === 'property_identifier' || t === 'type_identifier') {\n const text = source.slice(f.startIndex, f.endIndex).trim();\n if (text && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(text)) return text;\n }\n }\n }\n // Fallback: first child, take final segment of dotted access (covers JS/TS, C#, Go, Rust\u2026)\n const funcNode = node.child(0);\n if (funcNode) {\n const rawName = source.slice(funcNode.startIndex, funcNode.endIndex).split('(')[0].trim();\n if (rawName && rawName.length < 100) {\n const calleeName = rawName.split('.').pop()!.trim();\n if (calleeName && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(calleeName)) return calleeName;\n }\n }\n return null;\n}\n\nfunction collectCallRefs(node: any, source: string, sourceId: string, unresolvedRefs: UnresolvedRef[]): void {\n walkForCalls(node, source, sourceId, unresolvedRefs);\n}\n\nfunction walkForCalls(node: any, source: string, sourceId: string, unresolvedRefs: UnresolvedRef[]): void {\n if (CALL_NODE_TYPES.has(node.type)) {\n const calleeName = extractCallName(node, source);\n if (calleeName) {\n unresolvedRefs.push({\n sourceId,\n refName: calleeName,\n refKind: 'function',\n line: node.startPosition.row + 1,\n column: node.startPosition.column,\n });\n }\n }\n for (let i = 0; i < node.childCount; i++) {\n walkForCalls(node.child(i), source, sourceId, unresolvedRefs);\n }\n}\n\n// \u2500\u2500 Inheritance extraction \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Extract the simple type name from an AST node representing a type reference.\n * Strips generic parameters (e.g. \"List<T>\" \u2192 \"List\").\n */\nfunction extractTypeName(node: any, source: string): string | null {\n const t = node.type;\n if (t === 'identifier' || t === 'type_identifier' || t === 'name') {\n return source.slice(node.startIndex, node.endIndex).trim() || null;\n }\n // qualified_name / generic_name: take the rightmost identifier\n if (t === 'qualified_name' || t === 'generic_name' || t === 'scoped_type_identifier') {\n for (let i = node.childCount - 1; i >= 0; i--) {\n const child = node.child(i);\n if (child.type === 'identifier' || child.type === 'type_identifier' || child.type === 'name') {\n return source.slice(child.startIndex, child.endIndex).trim() || null;\n }\n }\n }\n return null;\n}\n\n/**\n * Scan a class/interface AST node for its base types and add them as unresolved\n * extends/implements refs, which the resolver later turns into graph edges.\n *\n * C#: base_list children \u2192 all are either base class or interface (can't distinguish without types)\n * Java: superclass \u2192 extends; super_interfaces / extends_interfaces \u2192 implements / extends\n */\nfunction extractInheritance(\n node: any,\n source: string,\n language: Language,\n classNodeId: string,\n unresolvedRefs: UnresolvedRef[],\n): void {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n\n if (language === 'csharp' && child.type === 'base_list') {\n for (let j = 0; j < child.childCount; j++) {\n const item = child.child(j);\n const name = extractTypeName(item, source);\n if (name) {\n unresolvedRefs.push({\n sourceId: classNodeId,\n refName: name,\n // In C# both classes and interfaces appear in the same base_list;\n // we emit 'extends' for all \u2014 the resolver maps it to the extends edge\n // which covers both parent classes and parent interfaces structurally.\n refKind: 'extends',\n line: item.startPosition.row + 1,\n column: item.startPosition.column,\n });\n }\n }\n }\n\n if (language === 'java') {\n if (child.type === 'superclass') {\n // superclass has a single type_identifier or scoped_type_identifier child\n const typeNode = child.namedChild?.(0);\n if (typeNode) {\n const name = extractTypeName(typeNode, source);\n if (name) unresolvedRefs.push({ sourceId: classNodeId, refName: name, refKind: 'extends', line: child.startPosition.row + 1, column: child.startPosition.column });\n }\n }\n if (child.type === 'super_interfaces' || child.type === 'extends_interfaces') {\n // contains a type_list with one or more types\n const typeList = child.namedChild?.(0);\n if (typeList) {\n const count = typeList.namedChildCount ?? 0;\n for (let j = 0; j < count; j++) {\n const typeNode = typeList.namedChild(j);\n if (typeNode) {\n const name = extractTypeName(typeNode, source);\n if (name) {\n unresolvedRefs.push({\n sourceId: classNodeId,\n refName: name,\n refKind: child.type === 'extends_interfaces' ? 'extends' : 'implements',\n line: typeNode.startPosition.row + 1,\n column: typeNode.startPosition.column,\n });\n }\n }\n }\n }\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,WAAsB;AACtB,SAAoB;AACpB,aAAwB;AAExB,uBAAoD;AACpD,sBAAwD;AACxD,sBAAgC;AAoBzB,SAAS,WAAW,UAAkB,MAAc,MAAc,MAAsB;AAC7F,QAAM,OAAO,OAAO,WAAW,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,EAAE,OAAO,KAAK,EAAE,MAAM,GAAG,EAAE;AAChH,SAAO,GAAG,IAAI,IAAI,IAAI;AACxB;AAGA,SAAS,aAAa,UAAkB,aAA8B;AACpE,MAAI;AACF,UAAM,OAAO,GAAG,aAAa,QAAQ;AACrC,UAAM,WAAW,GAAG,aAAa,WAAW;AAC5C,WAAO,KAAK,WAAW,WAAW,KAAK,GAA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MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["/**\n * Symbol extractor using web-tree-sitter\n * Parses source files and extracts nodes + edges into the graph.\n * Handles functions, classes, methods, variables, constants, and imports.\n */\n\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport * as crypto from 'crypto';\nimport type { Node, Edge, NodeKind, Language } from '../types';\nimport { detectLanguage, isSupportedLanguage } from './languages';\nimport { initGrammars, getParser, hasWasmGrammar } from './grammars';\nimport { extractNotebook } from './notebook';\n\nexport interface UnresolvedRef {\n sourceId: string;\n refName: string;\n refKind: 'function' | 'import' | 'extends' | 'implements';\n line: number;\n column: number;\n}\n\nexport interface ExtractedFile {\n filePath: string;\n language: Language;\n contentHash: string;\n fileSize: number;\n nodes: Node[];\n edges: Edge[];\n unresolvedRefs: UnresolvedRef[];\n}\n\nexport function makeNodeId(filePath: string, kind: string, name: string, line: number): string {\n const hash = crypto.createHash('sha256').update(`${filePath}:${kind}:${name}:${line}`).digest('hex').slice(0, 32);\n return `${kind}:${hash}`;\n}\n\n/** Validate that filePath stays within projectRoot to prevent path traversal. */\nfunction validatePath(filePath: string, projectRoot: string): boolean {\n try {\n const real = fs.realpathSync(filePath);\n const realRoot = fs.realpathSync(projectRoot);\n return real.startsWith(realRoot + path.sep) || real === realRoot;\n } catch {\n // If we can't resolve, check with normalize\n const normalized = path.resolve(filePath);\n return normalized.startsWith(path.resolve(projectRoot));\n }\n}\n\n/**\n * Extract symbols from a single file.\n * Optionally accepts pre-read content for batch I/O efficiency.\n */\nexport async function extractFile(filePath: string, projectRoot: string, content?: Buffer | string): Promise<ExtractedFile | null> {\n const language = detectLanguage(filePath);\n if (!isSupportedLanguage(language)) return null;\n\n // Path traversal protection\n if (!validatePath(filePath, projectRoot)) return null;\n\n let source: string;\n try {\n if (content !== undefined) {\n source = typeof content === 'string' ? content : content.toString('utf8');\n } else {\n source = fs.readFileSync(filePath, 'utf8');\n }\n } catch {\n return null;\n }\n\n // Delegate Jupyter notebooks to the dedicated notebook extractor\n if (language === 'jupyter') {\n return extractNotebook(filePath, projectRoot, source);\n }\n\n const contentHash = crypto.createHash('sha256').update(source).digest('hex');\n const fileSize = Buffer.byteLength(source, 'utf8');\n const relPath = path.relative(projectRoot, filePath).replace(/\\\\/g, '/');\n\n await initGrammars();\n const parser = await getParser(language);\n if (!parser) {\n if (!hasWasmGrammar(language)) {\n // Language genuinely has no grammar (e.g. Liquid, unknown) \u2014 track file but no AST extraction\n return {\n filePath: relPath,\n language,\n contentHash,\n fileSize,\n nodes: [],\n edges: [],\n unresolvedRefs: [],\n };\n }\n // Grammar should exist but parser failed (likely WASM crash) \u2014 signal extraction failure\n throw new Error(`Parser unavailable for ${language} (WASM grammar exists but failed to load)`);\n }\n\n const tree = parser.parse(source);\n\n const nodes: Node[] = [];\n const edges: Edge[] = [];\n const unresolvedRefs: UnresolvedRef[] = [];\n const now = Date.now();\n\n walkTree(tree.rootNode, source, relPath, language, nodes, edges, unresolvedRefs, now);\n\n return { filePath: relPath, language, contentHash, fileSize, nodes, edges, unresolvedRefs };\n}\n\n// \u2500\u2500 Elixir helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst ELIXIR_DEF_KINDS: Record<string, NodeKind> = {\n defmodule: 'module',\n def: 'function',\n defp: 'function',\n defmacro: 'function',\n defmacrop: 'function',\n defprotocol: 'interface',\n defimpl: 'class',\n defstruct: 'struct',\n};\n\nconst ELIXIR_IMPORT_TARGETS = new Set(['alias', 'import', 'require', 'use']);\n\nfunction elixirCallTarget(node: any, source: string): string | null {\n const target = node.childForFieldName?.('target') ?? node.child(0);\n if (!target) return null;\n return source.slice(target.startIndex, target.endIndex).trim() || null;\n}\n\nfunction elixirFirstArg(node: any): any | null {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'arguments') {\n return child.namedChild(0) ?? child.child(0) ?? null;\n }\n }\n return null;\n}\n\nfunction extractElixirName(node: any, source: string, kind: NodeKind): string | null {\n const firstArg = elixirFirstArg(node);\n if (!firstArg) return null;\n if (kind === 'module' || kind === 'interface' || kind === 'class') {\n return source.slice(firstArg.startIndex, firstArg.endIndex).trim();\n }\n if (kind === 'function') {\n if (firstArg.type === 'call') {\n const nameNode = firstArg.childForFieldName?.('target') ?? firstArg.child(0);\n if (nameNode) return source.slice(nameNode.startIndex, nameNode.endIndex).trim();\n }\n return source.slice(firstArg.startIndex, firstArg.endIndex).trim();\n }\n return null;\n}\n\nfunction extractElixirImportSource(node: any, source: string): string | null {\n const firstArg = elixirFirstArg(node);\n if (!firstArg) return null;\n return source.slice(firstArg.startIndex, firstArg.endIndex).trim() || null;\n}\n\nfunction walkElixirCall(\n node: any,\n source: string,\n filePath: string,\n language: Language,\n nodes: Node[],\n edges: Edge[],\n unresolvedRefs: UnresolvedRef[],\n now: number,\n parentId?: string\n): void {\n const targetText = elixirCallTarget(node, source);\n if (!targetText) {\n for (let i = 0; i < node.childCount; i++) {\n walkTree(node.child(i), source, filePath, language, nodes, edges, unresolvedRefs, now, parentId);\n }\n return;\n }\n\n if (ELIXIR_IMPORT_TARGETS.has(targetText)) {\n const modPath = extractElixirImportSource(node, source);\n if (modPath) {\n const id = makeNodeId(filePath, 'import', modPath, node.startPosition.row + 1);\n nodes.push({\n id, kind: 'import', name: modPath,\n qualifiedName: `${filePath}::import:${modPath}`,\n filePath, language,\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n startColumn: node.startPosition.column,\n endColumn: node.endPosition.column,\n updatedAt: now,\n });\n unresolvedRefs.push({ sourceId: id, refName: modPath, refKind: 'import', line: node.startPosition.row + 1, column: node.startPosition.column });\n }\n return;\n }\n\n const defKind = ELIXIR_DEF_KINDS[targetText];\n if (defKind) {\n const name = extractElixirName(node, source, defKind);\n if (name) {\n const id = makeNodeId(filePath, defKind, name, node.startPosition.row + 1);\n const isPrivate = targetText === 'defp' || targetText === 'defmacrop';\n nodes.push({\n id, kind: defKind, name,\n qualifiedName: `${filePath}::${name}`,\n filePath, language,\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n startColumn: node.startPosition.column,\n endColumn: node.endPosition.column,\n docstring: extractDocstring(node, source),\n signature: extractSignature(node, source, defKind),\n visibility: isPrivate ? 'private' : 'public',\n isExported: !isPrivate,\n updatedAt: now,\n });\n if (parentId) edges.push({ source: parentId, target: id, kind: 'contains' });\n collectCallRefs(node, source, id, unresolvedRefs);\n for (let i = 0; i < node.childCount; i++) {\n walkTree(node.child(i), source, filePath, language, nodes, edges, unresolvedRefs, now, id);\n }\n return;\n }\n }\n\n for (let i = 0; i < node.childCount; i++) {\n walkTree(node.child(i), source, filePath, language, nodes, edges, unresolvedRefs, now, parentId);\n }\n}\n\n// \u2500\u2500 Node type mappings \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** AST node types that should be descended without creating a symbol node */\nconst TRANSPARENT_TYPES = new Set([\n 'export_statement', 'program', 'source_file', 'module', 'translation_unit',\n 'chunk', // Lua root node type\n]);\n\n/** Mapping from tree-sitter node types to graph NodeKind */\nconst KIND_MAP: Record<string, NodeKind> = {\n // Functions\n function_declaration: 'function',\n function_expression: 'function',\n arrow_function: 'function',\n function_definition: 'function', // Python, Scala\n function_item: 'function', // Rust\n function_declaration_go: 'function',\n // Methods\n method_definition: 'method',\n method_declaration: 'method', // Go, Java, C#\n constructor_declaration: 'method', // Java, C#\n // Classes / structs\n class_declaration: 'class',\n class_expression: 'class',\n class_definition: 'class', // Python, Scala\n impl_item: 'class', // Rust (impl blocks)\n struct_item: 'struct', // Rust\n struct_definition: 'struct', // Zig\n // Interfaces / traits\n interface_declaration: 'interface',\n trait_item: 'trait', // Rust\n trait_definition: 'trait', // Scala\n protocol_declaration: 'interface', // Swift\n // Enums\n enum_declaration: 'enum',\n enum_item: 'enum', // Rust\n // Type aliases\n type_alias_declaration: 'type_alias',\n type_declaration: 'type_alias', // Go\n typealias_declaration: 'type_alias',// Swift\n type_item: 'type_alias', // Rust\n type_alias: 'type_alias', // Kotlin\n // Namespaces / modules\n namespace_declaration: 'namespace',\n module_definition: 'namespace', // OCaml\n // Variables / constants (language-specific, see extractVariableKind)\n lexical_declaration: 'variable', // TS/JS (const/let/var) \u2014 refined below\n variable_declaration: 'variable', // TS/JS (var)\n // Ruby\n method: 'method', // Ruby def (top-level and in class body)\n class: 'class', // Ruby class\n // Lua\n local_function_definition_statement: 'function',\n function_definition_statement: 'function',\n // Import statements (all handled via extractImport)\n};\n\n/** Refine variable declarations into 'variable' or 'constant' based on modifier */\nfunction extractVariableKind(node: any): NodeKind {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'const') return 'constant';\n }\n return 'variable';\n}\n\n/**\n * Widget superclass names that mark a Dart class as a UI component.\n * `State<Foo>` subclasses are kept as 'class' \u2014 they are state holders, not widgets.\n */\nconst DART_WIDGET_SUPERCLASSES = new Set([\n 'StatelessWidget',\n 'StatefulWidget',\n 'HookWidget',\n 'ConsumerWidget',\n 'ConsumerStatefulWidget',\n]);\n\n/**\n * Inspect a Dart class_definition node's superclass clause to decide if the\n * class is a widget component or a plain class.\n *\n * Dart tree-sitter grammar: class_definition \u2192 superclass \u2192 type_identifier\n * We look for any child/grandchild whose text is one of the known widget base classes.\n */\nfunction refineDartClassKind(node: any, source: string): NodeKind {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'superclass') {\n // Walk all descendants of the superclass clause looking for a type_identifier\n const superText = source.slice(child.startIndex, child.endIndex);\n // Quick string check first for performance\n if (DART_WIDGET_SUPERCLASSES.has(superText.replace(/^extends\\s+/, '').trim())) {\n return 'component';\n }\n // Drill into children to find the exact type_identifier\n for (let j = 0; j < child.childCount; j++) {\n const typeNode = child.child(j);\n if (typeNode.type === 'type_identifier' || typeNode.type === 'identifier') {\n const name = source.slice(typeNode.startIndex, typeNode.endIndex).trim();\n if (DART_WIDGET_SUPERCLASSES.has(name)) return 'component';\n // Also match any name that ends with \"Widget\" (catches custom base widgets)\n if (name.endsWith('Widget') && name !== 'State') return 'component';\n }\n }\n }\n }\n return 'class';\n}\n\n/** Languages/node-types that represent import statements */\nconst IMPORT_NODE_TYPES = new Set([\n 'import_statement', // TS/JS\n 'import_from_statement', // Python\n 'import_declaration', // Go, Java\n 'use_declaration', // Rust\n 'using_directive', // C#\n 'namespace_use_declaration',// PHP\n 'import_header', // Kotlin\n 'import_or_export', // Dart\n 'include_statement', // Pascal\n 'preproc_include', // C/C++\n]);\n\n// \u2500\u2500 Main tree walker \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction walkTree(\n node: any,\n source: string,\n filePath: string,\n language: Language,\n nodes: Node[],\n edges: Edge[],\n unresolvedRefs: UnresolvedRef[],\n now: number,\n parentId?: string\n): void {\n if (TRANSPARENT_TYPES.has(node.type)) {\n for (let i = 0; i < node.childCount; i++) {\n walkTree(node.child(i), source, filePath, language, nodes, edges, unresolvedRefs, now, parentId);\n }\n return;\n }\n\n // Elixir: all definitions and imports are `call` nodes\n if (language === 'elixir' && node.type === 'call') {\n walkElixirCall(node, source, filePath, language, nodes, edges, unresolvedRefs, now, parentId);\n return;\n }\n\n // Handle import statements\n if (IMPORT_NODE_TYPES.has(node.type)) {\n const importNode = extractImport(node, source, filePath, language, unresolvedRefs, now, parentId);\n if (importNode) nodes.push(importNode);\n return; // Don't recurse into import nodes\n }\n\n let kind: NodeKind | null = KIND_MAP[node.type] ?? null;\n\n // Refine lexical_declaration into variable/constant\n if (node.type === 'lexical_declaration' || node.type === 'variable_declaration') {\n kind = extractVariableKind(node);\n }\n\n // Python/Go/Rust/Java/C# variable and constant types\n if (!kind) kind = getLanguageSpecificKind(node.type, language);\n\n // Dart: refine class_definition kind based on superclass (Widget \u2192 component)\n if (language === 'dart' && node.type === 'class_definition' && kind === 'class') {\n kind = refineDartClassKind(node, source);\n }\n\n if (kind) {\n const name = extractName(node, source, language, kind);\n if (name) {\n const id = makeNodeId(filePath, kind, name, node.startPosition.row + 1);\n const visibility = extractVisibility(node, source, language);\n const graphNode: Node = {\n id,\n kind,\n name,\n qualifiedName: `${filePath}::${name}`,\n filePath,\n language,\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n startColumn: node.startPosition.column,\n endColumn: node.endPosition.column,\n docstring: extractDocstring(node, source),\n signature: extractSignature(node, source, kind),\n visibility,\n isExported: isExported(node),\n isAsync: isAsync(node),\n isStatic: isStatic(node),\n updatedAt: now,\n };\n nodes.push(graphNode);\n\n if (parentId) {\n edges.push({ source: parentId, target: id, kind: 'contains' });\n }\n\n // Collect call references within this symbol\n collectCallRefs(node, source, id, unresolvedRefs);\n\n // Extract inheritance edges for C# and Java class/interface nodes\n if ((kind === 'class' || kind === 'interface') && (language === 'csharp' || language === 'java')) {\n extractInheritance(node, source, language, id, unresolvedRefs);\n }\n\n // Recurse with this node as parent\n for (let i = 0; i < node.childCount; i++) {\n walkTree(node.child(i), source, filePath, language, nodes, edges, unresolvedRefs, now, id);\n }\n return;\n }\n }\n\n // No symbol \u2014 recurse without changing parent\n for (let i = 0; i < node.childCount; i++) {\n walkTree(node.child(i), source, filePath, language, nodes, edges, unresolvedRefs, now, parentId);\n }\n}\n\n// \u2500\u2500 Language-specific node kinds \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction getLanguageSpecificKind(type: string, lang: Language): NodeKind | null {\n switch (lang) {\n case 'python':\n if (type === 'assignment') return 'variable';\n break;\n case 'go':\n if (type === 'var_declaration' || type === 'short_var_declaration') return 'variable';\n if (type === 'const_declaration') return 'constant';\n if (type === 'type_spec') return 'type_alias';\n break;\n case 'rust':\n if (type === 'let_declaration') return 'variable';\n if (type === 'const_item') return 'constant';\n if (type === 'static_item') return 'variable';\n break;\n case 'java':\n if (type === 'field_declaration') return 'property';\n if (type === 'local_variable_declaration') return 'variable';\n break;\n case 'csharp':\n if (type === 'field_declaration') return 'property';\n break;\n case 'php':\n if (type === 'property_declaration') return 'property';\n if (type === 'const_declaration') return 'constant';\n break;\n case 'kotlin':\n if (type === 'property_declaration') return 'variable';\n break;\n case 'swift':\n if (type === 'property_declaration') return 'property';\n if (type === 'constant_declaration') return 'constant';\n break;\n case 'dart':\n if (type === 'function_signature') return 'function';\n if (type === 'method_signature') return 'method';\n break;\n case 'ruby':\n if (type === 'singleton_method') return 'method';\n break;\n case 'scala':\n if (type === 'object_definition') return 'class';\n if (type === 'val_definition') return 'variable';\n if (type === 'var_definition') return 'variable';\n if (type === 'type_definition') return 'type_alias';\n break;\n case 'lua':\n if (type === 'local_function') return 'function';\n if (type === 'local_variable_declaration') return 'variable';\n if (type === 'variable_assignment') return 'variable';\n break;\n case 'zig':\n if (type === 'VarDecl') return 'variable';\n if (type === 'ContainerDecl') return 'struct';\n break;\n case 'bash':\n if (type === 'variable_assignment') return 'variable';\n break;\n case 'ocaml':\n if (type === 'let_binding') return 'variable';\n if (type === 'type_binding') return 'type_alias';\n if (type === 'module_binding') return 'namespace';\n break;\n case 'elm':\n if (type === 'function_declaration_left') return 'function';\n if (type === 'type_alias_declaration') return 'type_alias';\n break;\n case 'solidity':\n if (type === 'contract_declaration') return 'class';\n if (type === 'event_definition') return 'function';\n if (type === 'modifier_definition') return 'function';\n if (type === 'state_variable_declaration') return 'variable';\n break;\n case 'objc':\n if (type === 'class_interface') return 'class';\n if (type === 'class_implementation') return 'class';\n if (type === 'protocol_declaration') return 'interface';\n if (type === 'method_declaration') return 'method';\n if (type === 'property_declaration') return 'property';\n break;\n case 'hcl':\n if (type === 'block') return 'namespace';\n if (type === 'attribute') return 'variable';\n break;\n case 'scss':\n if (type === 'mixin_statement') return 'function';\n if (type === 'function_statement') return 'function';\n if (type === 'variable_declaration') return 'variable';\n if (type === 'include_statement') return 'import';\n if (type === 'use_statement') return 'import';\n if (type === 'forward_statement') return 'import';\n if (type === 'placeholder') return 'class';\n break;\n case 'css':\n if (type === 'rule_set') return 'class';\n if (type === 'declaration') return 'variable';\n break;\n case 'rescript':\n if (type === 'let_binding') return 'function';\n if (type === 'type_definition') return 'type_alias';\n if (type === 'module_declaration') return 'module';\n break;\n case 'sql':\n if (type === 'create_function_statement') return 'function';\n if (type === 'create_table_statement') return 'class';\n if (type === 'create_view_statement') return 'function';\n if (type === 'create_procedure_statement') return 'function';\n break;\n case 'r':\n if (type === 'function_definition') return 'function';\n if (type === 'left_assignment') return 'variable';\n break;\n case 'julia':\n if (type === 'function_definition') return 'function';\n if (type === 'struct_definition') return 'struct';\n if (type === 'module_definition') return 'module';\n if (type === 'macro_definition') return 'function';\n break;\n case 'powershell':\n if (type === 'function_statement') return 'function';\n if (type === 'class_statement') return 'class';\n break;\n case 'perl':\n if (type === 'subroutine_declaration_statement') return 'function';\n if (type === 'package_statement') return 'module';\n break;\n case 'gdscript':\n if (type === 'function_definition') return 'function';\n if (type === 'class_definition') return 'class';\n if (type === 'variable_statement') return 'variable';\n break;\n case 'astro':\n if (type === 'function_declaration') return 'function';\n if (type === 'function_definition') return 'function';\n break;\n case 'nix':\n if (type === 'function') return 'function';\n if (type === 'binding') return 'variable';\n break;\n case 'verilog':\n if (type === 'module_declaration') return 'class';\n if (type === 'task_declaration') return 'function';\n if (type === 'function_declaration') return 'function';\n break;\n }\n return null;\n}\n\n// \u2500\u2500 Import extraction \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction extractImport(\n node: any,\n source: string,\n filePath: string,\n language: Language,\n unresolvedRefs: UnresolvedRef[],\n now: number,\n parentId?: string\n): Node | null {\n const modulePath = extractImportSource(node, source, language);\n if (!modulePath) return null;\n\n const id = makeNodeId(filePath, 'import', modulePath, node.startPosition.row + 1);\n const importNode: Node = {\n id,\n kind: 'import',\n name: modulePath,\n qualifiedName: `${filePath}::import:${modulePath}`,\n filePath,\n language,\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n startColumn: node.startPosition.column,\n endColumn: node.endPosition.column,\n updatedAt: now,\n };\n\n // Register as unresolved import for later file-level resolution\n unresolvedRefs.push({\n sourceId: id,\n refName: modulePath,\n refKind: 'import',\n line: node.startPosition.row + 1,\n column: node.startPosition.column,\n });\n\n return importNode;\n}\n\n/** Extract the module path string from an import statement node */\nfunction extractImportSource(node: any, source: string, language: Language): string | null {\n // TS/JS/Svelte: import X from \"module\" \u2192 look for trailing string literal\n if (\n node.type === 'import_statement' ||\n (language === 'svelte' && node.type === 'import_statement')\n ) {\n for (let i = node.childCount - 1; i >= 0; i--) {\n const child = node.child(i);\n if (child.type === 'string') {\n return stripQuotes(source.slice(child.startIndex, child.endIndex));\n }\n }\n }\n\n // Python: from .module import X or import module\n if (node.type === 'import_from_statement') {\n // Look for dotted_name or relative_import after 'from'\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'dotted_name' || child.type === 'relative_import') {\n return source.slice(child.startIndex, child.endIndex);\n }\n }\n }\n if (node.type === 'import_statement' && language === 'python') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'dotted_name') {\n return source.slice(child.startIndex, child.endIndex);\n }\n }\n }\n\n // Go: import \"path\" or import ( \"path\" )\n if (node.type === 'import_declaration') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'string') {\n return stripQuotes(source.slice(child.startIndex, child.endIndex));\n }\n if (child.type === 'import_spec_list') {\n for (let j = 0; j < child.childCount; j++) {\n const spec = child.child(j);\n if (spec.type === 'import_spec') {\n for (let k = 0; k < spec.childCount; k++) {\n const s = spec.child(k);\n if (s.type === 'string') return stripQuotes(source.slice(s.startIndex, s.endIndex));\n }\n }\n }\n }\n }\n }\n\n // Rust: use path::to::module;\n if (node.type === 'use_declaration') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type !== 'use' && child.type !== ';') {\n return source.slice(child.startIndex, child.endIndex);\n }\n }\n }\n\n // C#: using Namespace.Name;\n if (node.type === 'using_directive') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'qualified_name' || child.type === 'identifier') {\n return source.slice(child.startIndex, child.endIndex);\n }\n }\n }\n\n // Java/Kotlin: import a.b.c\n if (node.type === 'import_declaration' || node.type === 'import_header') {\n const text = source.slice(node.startIndex, node.endIndex).trim();\n const m = text.match(/^import\\s+(.+?)[;\\s*]*$/);\n if (m) return m[1].trim();\n }\n\n // PHP: use Foo\\Bar\n if (node.type === 'namespace_use_declaration') {\n const text = source.slice(node.startIndex, node.endIndex).trim();\n const m = text.match(/^use\\s+(.+?)[;\\s]*$/);\n if (m) return m[1].trim();\n }\n\n // Swift/Dart: import SomeModule\n if (node.type === 'import_declaration' || node.type === 'import_or_export') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'identifier' || child.type === 'string') {\n return source.slice(child.startIndex, child.endIndex);\n }\n }\n }\n\n // C/C++: #include \"file.h\" or #include <lib.h>\n if (node.type === 'preproc_include') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'string_literal' || child.type === 'system_lib_string') {\n return source.slice(child.startIndex, child.endIndex).replace(/[<>\"]/g, '');\n }\n }\n }\n\n return null;\n}\n\nfunction stripQuotes(s: string): string {\n return s.replace(/^['\"`]|['\"`]$/g, '');\n}\n\n// \u2500\u2500 Name extraction \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction extractName(node: any, source: string, _lang: Language, kind: NodeKind): string | null {\n // For variable/constant declarations (lexical_declaration, variable_declaration),\n // the identifier is inside a variable_declarator child\n if (kind === 'variable' || kind === 'constant') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'variable_declarator') {\n for (let j = 0; j < child.childCount; j++) {\n const gc = child.child(j);\n if (gc.type === 'identifier') return source.slice(gc.startIndex, gc.endIndex);\n }\n }\n }\n }\n\n // For Go const_declaration / var_declaration \u2192 look inside var_spec / const_spec\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'var_spec' || child.type === 'const_spec') {\n for (let j = 0; j < child.childCount; j++) {\n const gc = child.child(j);\n if (gc.type === 'identifier') return source.slice(gc.startIndex, gc.endIndex);\n }\n }\n }\n\n // Lua function_definition_statement: name lives inside a `variable` child (e.g. M.greet)\n // Extract the last identifier to get the function name (not the module prefix)\n if (node.type === 'function_definition_statement') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'variable') {\n let lastId: string | null = null;\n for (let j = 0; j < child.childCount; j++) {\n const gc = child.child(j);\n if (gc.type === 'identifier') lastId = source.slice(gc.startIndex, gc.endIndex);\n }\n if (lastId) return lastId;\n }\n }\n }\n\n // Standard: look for first named-identifier child\n // Covers: identifier, property_identifier, type_identifier (most languages),\n // simple_identifier (Kotlin, Swift), word (Bash), name (PHP), constant (Ruby class)\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (\n child.type === 'identifier' ||\n child.type === 'property_identifier' ||\n child.type === 'type_identifier' ||\n child.type === 'simple_identifier' ||\n child.type === 'word' ||\n child.type === 'name' ||\n child.type === 'constant'\n ) {\n return source.slice(child.startIndex, child.endIndex);\n }\n }\n\n // Python assignment: the left side is the name\n if (node.type === 'assignment') {\n const left = node.child(0);\n if (left && left.type === 'identifier') {\n return source.slice(left.startIndex, left.endIndex);\n }\n }\n\n return null;\n}\n\n// \u2500\u2500 Signature extraction \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction extractSignature(node: any, source: string, kind: NodeKind): string | undefined {\n // For functions/methods, try to get the meaningful header without the body\n if (kind === 'function' || kind === 'method') {\n // Try to find parameter list \u2014 stop before the body block\n const text = source.slice(node.startIndex, node.endIndex);\n // Find opening brace or colon (Python), take everything before it\n const bodyStart = text.search(/\\s*[\\{:]\\s*\\n|=>|{/);\n const header = bodyStart > 0 ? text.slice(0, bodyStart).trim() : text.split('\\n')[0].trim();\n return header.length > 150 ? header.slice(0, 150) + '\u2026' : header || undefined;\n }\n\n // Default: first line truncated\n const text = source.slice(node.startIndex, node.endIndex);\n const firstLine = text.split('\\n')[0].trim();\n return firstLine.length > 120 ? firstLine.slice(0, 120) + '\u2026' : firstLine || undefined;\n}\n\n// \u2500\u2500 Visibility extraction \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction extractVisibility(node: any, source: string, language: Language): Node['visibility'] {\n // TypeScript / JavaScript: accessibility_modifier child\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'accessibility_modifier') {\n const mod = source.slice(child.startIndex, child.endIndex);\n if (mod === 'public') return 'public';\n if (mod === 'private') return 'private';\n if (mod === 'protected') return 'protected';\n }\n // Direct modifier keywords (Java, C#, PHP, Swift, Kotlin)\n if (child.type === 'public') return 'public';\n if (child.type === 'private') return 'private';\n if (child.type === 'protected') return 'protected';\n if (child.type === 'internal') return 'internal';\n }\n\n // Rust: no `pub` keyword = private, `pub` = public\n if (language === 'rust') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n if (child.type === 'visibility_modifier') {\n const v = source.slice(child.startIndex, child.endIndex);\n return v.startsWith('pub') ? 'public' : 'private';\n }\n }\n return 'private'; // Rust default\n }\n\n // C# default: private\n if (language === 'csharp') return 'private';\n\n // PHP default: public\n if (language === 'php') return 'public';\n\n // Swift: check for access modifiers\n if (language === 'swift') {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n const t = child.type;\n if (t === 'fileprivate') return 'private';\n }\n return 'internal'; // Swift default\n }\n\n // Python: underscore prefix convention\n if (language === 'python') {\n const name = extractName(node, source, language, 'function');\n if (name?.startsWith('_') && !name.startsWith('__')) return 'protected';\n if (name?.startsWith('__')) return 'private';\n return 'public';\n }\n\n return undefined;\n}\n\n// \u2500\u2500 Misc helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction extractDocstring(node: any, source: string): string | undefined {\n const commentTypes = new Set(['comment', 'block_comment', 'line_comment', 'documentation_comment']);\n const commentLines: string[] = [];\n\n let sibling = node.previousNamedSibling;\n while (sibling && commentTypes.has(sibling.type)) {\n commentLines.unshift(source.slice(sibling.startIndex, sibling.endIndex));\n sibling = sibling.previousNamedSibling;\n }\n\n if (commentLines.length === 0) return undefined;\n\n const cleaned = commentLines.join('\\n')\n .replace(/^\\/\\*+\\s*/gm, '')\n .replace(/\\s*\\*+\\/\\s*$/gm, '')\n .replace(/^\\s*\\*\\s?/gm, '')\n .replace(/^\\/\\/\\s?/gm, '')\n .trim();\n\n return cleaned.length > 0 ? cleaned : undefined;\n}\n\nfunction isExported(node: any): boolean {\n // Walk up the parent chain to find an export_statement ancestor\n let current = node.parent;\n while (current) {\n if (current.type === 'export_statement') return true;\n // Stop at scope boundaries\n if (current.type === 'function_body' || current.type === 'class_body' || current.type === 'statement_block') break;\n current = current.parent;\n }\n return false;\n}\n\nfunction isAsync(node: any): boolean {\n for (let i = 0; i < node.childCount; i++) {\n if (node.child(i).type === 'async') return true;\n }\n return false;\n}\n\nfunction isStatic(node: any): boolean {\n for (let i = 0; i < node.childCount; i++) {\n if (node.child(i).type === 'static') return true;\n }\n return false;\n}\n\n// \u2500\u2500 Call reference collection \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Node types that represent a function/method call across all supported languages.\n * Using a combined set avoids threading a language parameter through the recursive walker.\n */\nconst CALL_NODE_TYPES = new Set([\n 'call_expression', // JS/TS/Go/Rust/Swift/Kotlin/Dart/C/C++\n 'invocation_expression', // C#\n 'method_invocation', // Java\n 'call', // Python/Ruby/Elixir (function calls in bodies)\n 'function_call_expression', // PHP\n]);\n\n/**\n * Extract the callee name from a call node.\n * Uses named field lookup first (more precise), then falls back to first-child heuristic.\n */\nfunction extractCallName(node: any, source: string): string | null {\n // Named fields \u2014 Java uses 'name', Python/Ruby use 'function'/'method', Elixir uses 'target'\n for (const field of ['name', 'method', 'function', 'target']) {\n const f = node.childForFieldName?.(field);\n if (f) {\n const t = f.type;\n if (t === 'identifier' || t === 'name' || t === 'property_identifier' || t === 'type_identifier') {\n const text = source.slice(f.startIndex, f.endIndex).trim();\n if (text && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(text)) return text;\n }\n }\n }\n // Fallback: first child, take final segment of dotted access (covers JS/TS, C#, Go, Rust\u2026)\n const funcNode = node.child(0);\n if (funcNode) {\n const rawName = source.slice(funcNode.startIndex, funcNode.endIndex).split('(')[0].trim();\n if (rawName && rawName.length < 100) {\n const calleeName = rawName.split('.').pop()!.trim();\n if (calleeName && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(calleeName)) return calleeName;\n }\n }\n return null;\n}\n\nfunction collectCallRefs(node: any, source: string, sourceId: string, unresolvedRefs: UnresolvedRef[]): void {\n walkForCalls(node, source, sourceId, unresolvedRefs);\n}\n\nfunction walkForCalls(node: any, source: string, sourceId: string, unresolvedRefs: UnresolvedRef[]): void {\n if (CALL_NODE_TYPES.has(node.type)) {\n const calleeName = extractCallName(node, source);\n if (calleeName) {\n unresolvedRefs.push({\n sourceId,\n refName: calleeName,\n refKind: 'function',\n line: node.startPosition.row + 1,\n column: node.startPosition.column,\n });\n }\n }\n for (let i = 0; i < node.childCount; i++) {\n walkForCalls(node.child(i), source, sourceId, unresolvedRefs);\n }\n}\n\n// \u2500\u2500 Inheritance extraction \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Extract the simple type name from an AST node representing a type reference.\n * Strips generic parameters (e.g. \"List<T>\" \u2192 \"List\").\n */\nfunction extractTypeName(node: any, source: string): string | null {\n const t = node.type;\n if (t === 'identifier' || t === 'type_identifier' || t === 'name') {\n return source.slice(node.startIndex, node.endIndex).trim() || null;\n }\n // qualified_name / generic_name: take the rightmost identifier\n if (t === 'qualified_name' || t === 'generic_name' || t === 'scoped_type_identifier') {\n for (let i = node.childCount - 1; i >= 0; i--) {\n const child = node.child(i);\n if (child.type === 'identifier' || child.type === 'type_identifier' || child.type === 'name') {\n return source.slice(child.startIndex, child.endIndex).trim() || null;\n }\n }\n }\n return null;\n}\n\n/**\n * Scan a class/interface AST node for its base types and add them as unresolved\n * extends/implements refs, which the resolver later turns into graph edges.\n *\n * C#: base_list children \u2192 all are either base class or interface (can't distinguish without types)\n * Java: superclass \u2192 extends; super_interfaces / extends_interfaces \u2192 implements / extends\n */\nfunction extractInheritance(\n node: any,\n source: string,\n language: Language,\n classNodeId: string,\n unresolvedRefs: UnresolvedRef[],\n): void {\n for (let i = 0; i < node.childCount; i++) {\n const child = node.child(i);\n\n if (language === 'csharp' && child.type === 'base_list') {\n for (let j = 0; j < child.childCount; j++) {\n const item = child.child(j);\n const name = extractTypeName(item, source);\n if (name) {\n unresolvedRefs.push({\n sourceId: classNodeId,\n refName: name,\n // In C# both classes and interfaces appear in the same base_list;\n // we emit 'extends' for all \u2014 the resolver maps it to the extends edge\n // which covers both parent classes and parent interfaces structurally.\n refKind: 'extends',\n line: item.startPosition.row + 1,\n column: item.startPosition.column,\n });\n }\n }\n }\n\n if (language === 'java') {\n if (child.type === 'superclass') {\n // superclass has a single type_identifier or scoped_type_identifier child\n const typeNode = child.namedChild?.(0);\n if (typeNode) {\n const name = extractTypeName(typeNode, source);\n if (name) unresolvedRefs.push({ sourceId: classNodeId, refName: name, refKind: 'extends', line: child.startPosition.row + 1, column: child.startPosition.column });\n }\n }\n if (child.type === 'super_interfaces' || child.type === 'extends_interfaces') {\n // contains a type_list with one or more types\n const typeList = child.namedChild?.(0);\n if (typeList) {\n const count = typeList.namedChildCount ?? 0;\n for (let j = 0; j < count; j++) {\n const typeNode = typeList.namedChild(j);\n if (typeNode) {\n const name = extractTypeName(typeNode, source);\n if (name) {\n unresolvedRefs.push({\n sourceId: classNodeId,\n refName: name,\n refKind: child.type === 'extends_interfaces' ? 'extends' : 'implements',\n line: typeNode.startPosition.row + 1,\n column: typeNode.startPosition.column,\n });\n }\n }\n }\n }\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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