kirograph 0.27.1 → 0.28.0

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.
Files changed (222) hide show
  1. package/README.md +35 -2
  2. package/dist/bin/commands/annotations.js +56 -0
  3. package/dist/bin/commands/annotations.js.map +7 -0
  4. package/dist/bin/commands/ast-rewrite.js +55 -0
  5. package/dist/bin/commands/ast-rewrite.js.map +7 -0
  6. package/dist/bin/commands/bench.js +103 -0
  7. package/dist/bin/commands/bench.js.map +7 -0
  8. package/dist/bin/commands/branch.js +133 -0
  9. package/dist/bin/commands/branch.js.map +7 -0
  10. package/dist/bin/commands/callees.js +76 -0
  11. package/dist/bin/commands/callees.js.map +7 -0
  12. package/dist/bin/commands/callers.js +76 -0
  13. package/dist/bin/commands/callers.js.map +7 -0
  14. package/dist/bin/commands/changelog.js +55 -0
  15. package/dist/bin/commands/changelog.js.map +7 -0
  16. package/dist/bin/commands/circular-deps.js +68 -0
  17. package/dist/bin/commands/circular-deps.js.map +7 -0
  18. package/dist/bin/commands/commit-context.js +55 -0
  19. package/dist/bin/commands/commit-context.js.map +7 -0
  20. package/dist/bin/commands/complexity.js +60 -0
  21. package/dist/bin/commands/complexity.js.map +7 -0
  22. package/dist/bin/commands/cost.js +146 -0
  23. package/dist/bin/commands/cost.js.map +7 -0
  24. package/dist/bin/commands/dependency-depth.js +55 -0
  25. package/dist/bin/commands/dependency-depth.js.map +7 -0
  26. package/dist/bin/commands/diff-context.js +55 -0
  27. package/dist/bin/commands/diff-context.js.map +7 -0
  28. package/dist/bin/commands/distribution.js +56 -0
  29. package/dist/bin/commands/distribution.js.map +7 -0
  30. package/dist/bin/commands/doc-coverage.js +56 -0
  31. package/dist/bin/commands/doc-coverage.js.map +7 -0
  32. package/dist/bin/commands/doctor.js +202 -0
  33. package/dist/bin/commands/doctor.js.map +7 -0
  34. package/dist/bin/commands/dsm.js +56 -0
  35. package/dist/bin/commands/dsm.js.map +7 -0
  36. package/dist/bin/commands/gini.js +55 -0
  37. package/dist/bin/commands/gini.js.map +7 -0
  38. package/dist/bin/commands/god-class.js +56 -0
  39. package/dist/bin/commands/god-class.js.map +7 -0
  40. package/dist/bin/commands/health.js +55 -0
  41. package/dist/bin/commands/health.js.map +7 -0
  42. package/dist/bin/commands/help.js +224 -45
  43. package/dist/bin/commands/help.js.map +2 -2
  44. package/dist/bin/commands/impact.js +76 -0
  45. package/dist/bin/commands/impact.js.map +7 -0
  46. package/dist/bin/commands/inheritance-depth.js +56 -0
  47. package/dist/bin/commands/inheritance-depth.js.map +7 -0
  48. package/dist/bin/commands/insert-at.js +55 -0
  49. package/dist/bin/commands/insert-at.js.map +7 -0
  50. package/dist/bin/commands/largest.js +56 -0
  51. package/dist/bin/commands/largest.js.map +7 -0
  52. package/dist/bin/commands/manifest.js +158 -0
  53. package/dist/bin/commands/manifest.js.map +7 -0
  54. package/dist/bin/commands/module-api.js +57 -0
  55. package/dist/bin/commands/module-api.js.map +7 -0
  56. package/dist/bin/commands/monitor.js +91 -0
  57. package/dist/bin/commands/monitor.js.map +7 -0
  58. package/dist/bin/commands/multi-replace.js +66 -0
  59. package/dist/bin/commands/multi-replace.js.map +7 -0
  60. package/dist/bin/commands/pr-context.js +55 -0
  61. package/dist/bin/commands/pr-context.js.map +7 -0
  62. package/dist/bin/commands/query.js +19 -1
  63. package/dist/bin/commands/query.js.map +3 -3
  64. package/dist/bin/commands/rank.js +56 -0
  65. package/dist/bin/commands/rank.js.map +7 -0
  66. package/dist/bin/commands/read.js +1 -1
  67. package/dist/bin/commands/read.js.map +2 -2
  68. package/dist/bin/commands/recursion.js +56 -0
  69. package/dist/bin/commands/recursion.js.map +7 -0
  70. package/dist/bin/commands/rename-preview.js +56 -0
  71. package/dist/bin/commands/rename-preview.js.map +7 -0
  72. package/dist/bin/commands/session.js +60 -0
  73. package/dist/bin/commands/session.js.map +7 -0
  74. package/dist/bin/commands/simplify-scan.js +56 -0
  75. package/dist/bin/commands/simplify-scan.js.map +7 -0
  76. package/dist/bin/commands/str-replace.js +55 -0
  77. package/dist/bin/commands/str-replace.js.map +7 -0
  78. package/dist/bin/commands/test-coverage.js +59 -0
  79. package/dist/bin/commands/test-coverage.js.map +7 -0
  80. package/dist/bin/commands/test-map.js +56 -0
  81. package/dist/bin/commands/test-map.js.map +7 -0
  82. package/dist/bin/commands/test-risk.js +59 -0
  83. package/dist/bin/commands/test-risk.js.map +7 -0
  84. package/dist/bin/commands/type-hierarchy.js +76 -0
  85. package/dist/bin/commands/type-hierarchy.js.map +7 -0
  86. package/dist/bin/commands/unused-imports.js +55 -0
  87. package/dist/bin/commands/unused-imports.js.map +7 -0
  88. package/dist/bin/commands/upgrade.js +78 -0
  89. package/dist/bin/commands/upgrade.js.map +7 -0
  90. package/dist/bin/installer/common.js +19 -9
  91. package/dist/bin/installer/common.js.map +2 -2
  92. package/dist/bin/installer/config-prompt.js +147 -12
  93. package/dist/bin/installer/config-prompt.js.map +3 -3
  94. package/dist/bin/installer/index.js +62 -6
  95. package/dist/bin/installer/index.js.map +2 -2
  96. package/dist/bin/installer/instructions.js +14 -25
  97. package/dist/bin/installer/instructions.js.map +2 -2
  98. package/dist/bin/installer/mcp.js.map +2 -2
  99. package/dist/bin/installer/steering.js +569 -100
  100. package/dist/bin/installer/steering.js.map +2 -2
  101. package/dist/bin/installer/targets/aider.js +3 -3
  102. package/dist/bin/installer/targets/aider.js.map +2 -2
  103. package/dist/bin/installer/targets/amp.js +3 -3
  104. package/dist/bin/installer/targets/amp.js.map +2 -2
  105. package/dist/bin/installer/targets/antigravity.js +4 -4
  106. package/dist/bin/installer/targets/antigravity.js.map +2 -2
  107. package/dist/bin/installer/targets/augment.js +3 -3
  108. package/dist/bin/installer/targets/augment.js.map +2 -2
  109. package/dist/bin/installer/targets/claude.js +3 -3
  110. package/dist/bin/installer/targets/claude.js.map +2 -2
  111. package/dist/bin/installer/targets/cline.js +4 -4
  112. package/dist/bin/installer/targets/cline.js.map +2 -2
  113. package/dist/bin/installer/targets/codex.js +4 -4
  114. package/dist/bin/installer/targets/codex.js.map +2 -2
  115. package/dist/bin/installer/targets/continue.js +4 -4
  116. package/dist/bin/installer/targets/continue.js.map +2 -2
  117. package/dist/bin/installer/targets/copilot-cli.js +4 -4
  118. package/dist/bin/installer/targets/copilot-cli.js.map +2 -2
  119. package/dist/bin/installer/targets/copilot.js +4 -4
  120. package/dist/bin/installer/targets/copilot.js.map +2 -2
  121. package/dist/bin/installer/targets/cursor.js +5 -5
  122. package/dist/bin/installer/targets/cursor.js.map +2 -2
  123. package/dist/bin/installer/targets/devin.js +4 -4
  124. package/dist/bin/installer/targets/devin.js.map +2 -2
  125. package/dist/bin/installer/targets/gemini-cli.js +4 -4
  126. package/dist/bin/installer/targets/gemini-cli.js.map +2 -2
  127. package/dist/bin/installer/targets/generic.js +2 -2
  128. package/dist/bin/installer/targets/generic.js.map +2 -2
  129. package/dist/bin/installer/targets/goose.js +3 -4
  130. package/dist/bin/installer/targets/goose.js.map +3 -3
  131. package/dist/bin/installer/targets/index.js.map +1 -1
  132. package/dist/bin/installer/targets/junie.js +4 -4
  133. package/dist/bin/installer/targets/junie.js.map +2 -2
  134. package/dist/bin/installer/targets/kilo.js +4 -4
  135. package/dist/bin/installer/targets/kilo.js.map +2 -2
  136. package/dist/bin/installer/targets/kiro.js +27 -3
  137. package/dist/bin/installer/targets/kiro.js.map +2 -2
  138. package/dist/bin/installer/targets/opencode.js +3 -3
  139. package/dist/bin/installer/targets/opencode.js.map +2 -2
  140. package/dist/bin/installer/targets/openhands.js +3 -3
  141. package/dist/bin/installer/targets/openhands.js.map +2 -2
  142. package/dist/bin/installer/targets/qoder.js +2 -2
  143. package/dist/bin/installer/targets/qoder.js.map +2 -2
  144. package/dist/bin/installer/targets/qwen.js +2 -2
  145. package/dist/bin/installer/targets/qwen.js.map +2 -2
  146. package/dist/bin/installer/targets/replit.js +3 -3
  147. package/dist/bin/installer/targets/replit.js.map +2 -2
  148. package/dist/bin/installer/targets/roo.js +4 -4
  149. package/dist/bin/installer/targets/roo.js.map +2 -2
  150. package/dist/bin/installer/targets/tabnine.js +3 -3
  151. package/dist/bin/installer/targets/tabnine.js.map +2 -2
  152. package/dist/bin/installer/targets/trae.js +3 -3
  153. package/dist/bin/installer/targets/trae.js.map +2 -2
  154. package/dist/bin/installer/targets/warp.js +4 -4
  155. package/dist/bin/installer/targets/warp.js.map +2 -2
  156. package/dist/bin/installer/targets/windsurf.js +4 -4
  157. package/dist/bin/installer/targets/windsurf.js.map +2 -2
  158. package/dist/bin/kirograph.js +83 -1
  159. package/dist/bin/kirograph.js.map +3 -3
  160. package/dist/config.js +30 -8
  161. package/dist/config.js.map +2 -2
  162. package/dist/core/branch-manager.js +111 -0
  163. package/dist/core/branch-manager.js.map +7 -0
  164. package/dist/core/pipeline.js +3 -3
  165. package/dist/core/pipeline.js.map +2 -2
  166. package/dist/data/pixelrag-bridge.js +93 -0
  167. package/dist/data/pixelrag-bridge.js.map +7 -0
  168. package/dist/data/pixelrag-manager.js +416 -0
  169. package/dist/data/pixelrag-manager.js.map +7 -0
  170. package/dist/db/database.js +34 -7
  171. package/dist/db/database.js.map +2 -2
  172. package/dist/db/schema.sql +7 -1
  173. package/dist/extraction/complexity.js +116 -0
  174. package/dist/extraction/complexity.js.map +7 -0
  175. package/dist/extraction/extractor.js +52 -1
  176. package/dist/extraction/extractor.js.map +2 -2
  177. package/dist/graph/git-context.js +229 -0
  178. package/dist/graph/git-context.js.map +7 -0
  179. package/dist/index.js +4 -2
  180. package/dist/index.js.map +2 -2
  181. package/dist/mcp/cache.js +1 -1
  182. package/dist/mcp/cache.js.map +2 -2
  183. package/dist/mcp/handler.js +446 -0
  184. package/dist/mcp/handler.js.map +7 -0
  185. package/dist/mcp/handlers/architecture.js +297 -0
  186. package/dist/mcp/handlers/architecture.js.map +7 -0
  187. package/dist/mcp/handlers/branch.js +175 -0
  188. package/dist/mcp/handlers/branch.js.map +7 -0
  189. package/dist/mcp/handlers/code-health.js +563 -0
  190. package/dist/mcp/handlers/code-health.js.map +7 -0
  191. package/dist/mcp/handlers/complexity.js +267 -0
  192. package/dist/mcp/handlers/complexity.js.map +7 -0
  193. package/dist/mcp/handlers/core.js +611 -0
  194. package/dist/mcp/handlers/core.js.map +7 -0
  195. package/dist/mcp/handlers/data.js +337 -0
  196. package/dist/mcp/handlers/data.js.map +7 -0
  197. package/dist/mcp/handlers/docs.js +159 -0
  198. package/dist/mcp/handlers/docs.js.map +7 -0
  199. package/dist/mcp/handlers/edit-primitives.js +200 -0
  200. package/dist/mcp/handlers/edit-primitives.js.map +7 -0
  201. package/dist/mcp/handlers/git-context.js +286 -0
  202. package/dist/mcp/handlers/git-context.js.map +7 -0
  203. package/dist/mcp/handlers/memory.js +363 -0
  204. package/dist/mcp/handlers/memory.js.map +7 -0
  205. package/dist/mcp/handlers/patterns.js +310 -0
  206. package/dist/mcp/handlers/patterns.js.map +7 -0
  207. package/dist/mcp/handlers/security.js +699 -0
  208. package/dist/mcp/handlers/security.js.map +7 -0
  209. package/dist/mcp/handlers/utils.js +97 -0
  210. package/dist/mcp/handlers/utils.js.map +7 -0
  211. package/dist/mcp/handlers/watchmen.js +104 -0
  212. package/dist/mcp/handlers/watchmen.js.map +7 -0
  213. package/dist/mcp/handlers/wiki.js +242 -0
  214. package/dist/mcp/handlers/wiki.js.map +7 -0
  215. package/dist/mcp/server.js +72 -3
  216. package/dist/mcp/server.js.map +2 -2
  217. package/dist/mcp/tool-names.js +136 -10
  218. package/dist/mcp/tool-names.js.map +2 -2
  219. package/dist/mcp/tools.js +846 -3019
  220. package/dist/mcp/tools.js.map +3 -3
  221. package/dist/types.js.map +2 -2
  222. package/package.json +36 -10
@@ -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 '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;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,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AC7B,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAEA,QAAI,aAAa,QAAQ;AACvB,UAAI,MAAM,SAAS,cAAc;AAE/B,cAAM,WAAW,MAAM,aAAa,CAAC;AACrC,YAAI,UAAU;AACZ,gBAAM,OAAO,gBAAgB,UAAU,MAAM;AAC7C,cAAI,KAAM,gBAAe,KAAK,EAAE,UAAU,aAAa,SAAS,MAAM,SAAS,WAAW,MAAM,MAAM,cAAc,MAAM,GAAG,QAAQ,MAAM,cAAc,OAAO,CAAC;AAAA,QACnK;AAAA,MACF;AACA,UAAI,MAAM,SAAS,sBAAsB,MAAM,SAAS,sBAAsB;AAE5E,cAAM,WAAW,MAAM,aAAa,CAAC;AACrC,YAAI,UAAU;AACZ,gBAAM,QAAQ,SAAS,mBAAmB;AAC1C,mBAAS,IAAI,GAAG,IAAI,OAAO,KAAK;AAC9B,kBAAM,WAAW,SAAS,WAAW,CAAC;AACtC,gBAAI,UAAU;AACZ,oBAAM,OAAO,gBAAgB,UAAU,MAAM;AAC7C,kBAAI,MAAM;AACR,+BAAe,KAAK;AAAA,kBAClB,UAAU;AAAA,kBACV,SAAS;AAAA,kBACT,SAAS,MAAM,SAAS,uBAAuB,YAAY;AAAA,kBAC3D,MAAM,SAAS,cAAc,MAAM;AAAA,kBACnC,QAAQ,SAAS,cAAc;AAAA,gBACjC,CAAC;AAAA,cACH;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,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, opts?: { enableComplexity?: boolean }): 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 // Complexity post-processing: compute metrics for function/method nodes when enabled.\n if (opts?.enableComplexity) {\n const sourceLines = source.split('\\n');\n for (const n of nodes) {\n if (n.kind !== 'function' && n.kind !== 'method') continue;\n const fnSource = sourceLines.slice(n.startLine - 1, n.endLine).join('\\n');\n const cc = computeTextCyclomaticComplexity(fnSource);\n const depth = computeTextNestingDepth(fnSource);\n const loc = n.endLine - n.startLine + 1;\n const tokens = fnSource.match(/\\b\\w+\\b|[+\\-*/=<>!&|^~%]+|[(){}[\\],;.]/g) ?? [];\n const volume = tokens.length > 0 && tokens.length > 1\n ? tokens.length * Math.log2(new Set(tokens).size || 1)\n : 0;\n const mi = Math.max(0, Math.min(100,\n 171 - 5.2 * Math.log(Math.max(1, volume)) - 0.23 * cc - 16.2 * Math.log(Math.max(1, loc))\n ));\n n.complexityCyclomatic = cc;\n n.nestingDepth = depth;\n n.maintainabilityIndex = Math.round(mi * 10) / 10;\n }\n }\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\n// \u2500\u2500 Text-based complexity 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\n// Used when enableComplexity=true in extractFile(). Text heuristics are less\n// accurate than full AST walking but require no per-language grammar handling.\n\nconst CC_PATTERNS = [\n /\\bif\\b/g, /\\belse\\s+if\\b/g, /\\belif\\b/g,\n /\\bfor\\b/g, /\\bwhile\\b/g, /\\bdo\\b/g,\n /\\bcase\\b/g, /\\bcatch\\b/g, /\\bexcept\\b/g,\n /&&/g, /\\|\\|/g, /\\?\\?/g,\n // ternary ? that is not ?. or ?: or optional chaining\n /(?<![?!])\\?(?![.?:])/g,\n];\n\nfunction computeTextCyclomaticComplexity(src: string): number {\n // Strip string literals and comments to avoid counting keywords inside them\n const stripped = src\n .replace(/`[^`]*`/g, '``')\n .replace(/\"(?:[^\"\\\\]|\\\\.)*\"/g, '\"\"')\n .replace(/'(?:[^'\\\\]|\\\\.)*'/g, \"''\")\n .replace(/\\/\\/[^\\n]*/g, '')\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '');\n let count = 0;\n for (const pat of CC_PATTERNS) count += (stripped.match(pat) ?? []).length;\n return 1 + count;\n}\n\nfunction computeTextNestingDepth(src: string): number {\n let depth = 0, max = 0;\n for (const ch of src) {\n if (ch === '{') { depth++; if (depth > max) max = depth; }\n else if (ch === '}') depth = Math.max(0, depth - 1);\n }\n return max;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;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AS,wBAAwB,KAAqB;AACpD,MAAI,QAAQ,GAAG,MAAM;AACrB,aAAW,MAAM,KAAK;AACpB,QAAI,OAAO,KAAK;AAAE;AAAS,UAAI,QAAQ,IAAK,OAAM;AAAA,IAAO,WAChD,OAAO,IAAK,SAAQ,KAAK,IAAI,GAAG,QAAQ,CAAC;AAAA,EACpD;AACA,SAAO;AACT;",
6
6
  "names": ["text"]
7
7
  }
@@ -0,0 +1,229 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var git_context_exports = {};
20
+ __export(git_context_exports, {
21
+ findTestFiles: () => findTestFiles,
22
+ findUncoveredSymbols: () => findUncoveredSymbols,
23
+ getChangedSymbols: () => getChangedSymbols,
24
+ getCommitContext: () => getCommitContext,
25
+ getCommitLog: () => getCommitLog,
26
+ getPRContext: () => getPRContext,
27
+ parseDiff: () => parseDiff
28
+ });
29
+ module.exports = __toCommonJS(git_context_exports);
30
+ var import_child_process = require("child_process");
31
+ function git(projectRoot, args) {
32
+ try {
33
+ return (0, import_child_process.execSync)(`git ${args}`, {
34
+ cwd: projectRoot,
35
+ encoding: "utf8",
36
+ stdio: ["pipe", "pipe", "pipe"]
37
+ }).trim();
38
+ } catch (err) {
39
+ throw new Error(`git ${args.split(" ")[0]} failed: ${err.message ?? String(err)}`);
40
+ }
41
+ }
42
+ function parseDiff(diffOutput) {
43
+ const hunks = [];
44
+ let current = null;
45
+ for (const line of diffOutput.split("\n")) {
46
+ if (line.startsWith("diff --git")) {
47
+ current = null;
48
+ continue;
49
+ }
50
+ if (line.startsWith("--- ") || line.startsWith("+++ ")) {
51
+ const filePath = line.slice(4).replace(/^[ab]\//, "").replace(/^\t/, "");
52
+ if (line.startsWith("+++ ") && filePath !== "/dev/null") {
53
+ if (!current) {
54
+ current = { filePath, addedLines: [], deletedLines: [], isNewFile: false, isDeletedFile: false };
55
+ hunks.push(current);
56
+ } else {
57
+ current.filePath = filePath;
58
+ }
59
+ } else if (line.startsWith("--- ") && filePath === "/dev/null") {
60
+ if (current) current.isNewFile = true;
61
+ } else if (line.startsWith("+++ ") && filePath === "/dev/null") {
62
+ if (current) current.isDeletedFile = true;
63
+ }
64
+ continue;
65
+ }
66
+ if (line.startsWith("@@") && current) {
67
+ const m = line.match(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
68
+ if (m) {
69
+ const newStart = parseInt(m[3], 10);
70
+ const newLen = parseInt(m[4] ?? "1", 10);
71
+ if (newLen > 0) current.addedLines.push([newStart, newStart + newLen - 1]);
72
+ const oldStart = parseInt(m[1], 10);
73
+ const oldLen = parseInt(m[2] ?? "1", 10);
74
+ if (oldLen > 0) current.deletedLines.push([oldStart, oldStart + oldLen - 1]);
75
+ }
76
+ continue;
77
+ }
78
+ if (line.startsWith("new file") && current) {
79
+ current.isNewFile = true;
80
+ continue;
81
+ }
82
+ if (line.startsWith("deleted file") && current) {
83
+ current.isDeletedFile = true;
84
+ continue;
85
+ }
86
+ }
87
+ return hunks;
88
+ }
89
+ function hunkToNodes(db, hunk) {
90
+ const rawDb = db.getRawDb();
91
+ const found = /* @__PURE__ */ new Map();
92
+ const queryRange = (lines, changeType) => {
93
+ for (const [s, e] of lines) {
94
+ const rows = rawDb.all(
95
+ `SELECT id, name, kind, file_path, start_line, end_line, qualified_name
96
+ FROM nodes WHERE file_path = ? AND start_line <= ? AND end_line >= ?
97
+ AND kind NOT IN ('contains','declared_in')`,
98
+ [hunk.filePath, e, s]
99
+ );
100
+ for (const r of rows) {
101
+ if (!found.has(r.id)) found.set(r.id, { ...r, changeType });
102
+ }
103
+ }
104
+ };
105
+ if (hunk.isNewFile) {
106
+ queryRange(hunk.addedLines, "added");
107
+ } else if (hunk.isDeletedFile) {
108
+ } else {
109
+ queryRange(hunk.addedLines, "modified");
110
+ }
111
+ return [...found.values()].map((r) => ({
112
+ id: r.id,
113
+ name: r.name,
114
+ kind: r.kind,
115
+ filePath: r.file_path,
116
+ startLine: r.start_line,
117
+ endLine: r.end_line,
118
+ qualifiedName: r.qualified_name,
119
+ changeType: r.changeType
120
+ }));
121
+ }
122
+ function enrichWithEdges(db, nodes) {
123
+ const rawDb = db.getRawDb();
124
+ return nodes.map((n) => {
125
+ const callers = rawDb.all(
126
+ `SELECT s.name, s.kind, s.file_path, s.start_line FROM edges e
127
+ JOIN nodes s ON s.id = e.source WHERE e.target = ? AND e.kind IN ('calls','imports') LIMIT 5`,
128
+ [n.id]
129
+ ).map((r) => ({ name: r.name, kind: r.kind, filePath: r.file_path, startLine: r.start_line }));
130
+ const callees = rawDb.all(
131
+ `SELECT t.name, t.kind, t.file_path, t.start_line FROM edges e
132
+ JOIN nodes t ON t.id = e.target WHERE e.source = ? AND e.kind IN ('calls','imports') LIMIT 5`,
133
+ [n.id]
134
+ ).map((r) => ({ name: r.name, kind: r.kind, filePath: r.file_path, startLine: r.start_line }));
135
+ return { ...n, callers, callees };
136
+ });
137
+ }
138
+ function getChangedSymbols(projectRoot, db, opts = {}) {
139
+ let diffArgs = "diff --unified=0";
140
+ if (opts.ref) diffArgs = `diff --unified=0 ${opts.ref}..HEAD`;
141
+ else if (opts.staged) diffArgs = "diff --cached --unified=0";
142
+ const diffOutput = git(projectRoot, diffArgs);
143
+ if (!diffOutput) return { changedSymbols: [], hunks: [] };
144
+ const hunks = parseDiff(diffOutput);
145
+ const allNodes = [];
146
+ for (const h of hunks) {
147
+ allNodes.push(...hunkToNodes(db, h));
148
+ }
149
+ const seen = /* @__PURE__ */ new Set();
150
+ const unique = allNodes.filter((n) => {
151
+ if (seen.has(n.id)) return false;
152
+ seen.add(n.id);
153
+ return true;
154
+ });
155
+ return { changedSymbols: enrichWithEdges(db, unique), hunks };
156
+ }
157
+ function getCommitContext(projectRoot, db) {
158
+ const stagedFiles = git(projectRoot, "diff --cached --name-only").split("\n").filter(Boolean);
159
+ const diffStat = git(projectRoot, "diff --cached --stat");
160
+ const { changedSymbols } = getChangedSymbols(projectRoot, db, { staged: true });
161
+ return { stagedFiles, changedSymbols, diffStat };
162
+ }
163
+ function getPRContext(projectRoot, db, base, head = "HEAD") {
164
+ const ref = `${base}..${head}`;
165
+ let diffOutput;
166
+ try {
167
+ diffOutput = git(projectRoot, `diff --unified=0 ${ref}`);
168
+ } catch {
169
+ throw new Error(`Could not diff ${ref}. Ensure both refs exist in this repository.`);
170
+ }
171
+ if (!diffOutput) return { changedSymbols: [], hunks: [], ref };
172
+ const hunks = parseDiff(diffOutput);
173
+ const allNodes = [];
174
+ for (const h of hunks) allNodes.push(...hunkToNodes(db, h));
175
+ const seen = /* @__PURE__ */ new Set();
176
+ const unique = allNodes.filter((n) => {
177
+ if (seen.has(n.id)) return false;
178
+ seen.add(n.id);
179
+ return true;
180
+ });
181
+ return { changedSymbols: enrichWithEdges(db, unique), hunks, ref };
182
+ }
183
+ function getCommitLog(projectRoot, ref1, ref2) {
184
+ const log = git(projectRoot, `log --pretty=format:%H|||%h|||%an|||%ad|||%s --date=short ${ref1}..${ref2}`);
185
+ if (!log) return [];
186
+ return log.split("\n").filter(Boolean).map((line) => {
187
+ const [hash, shortHash, author, date, ...subjectParts] = line.split("|||");
188
+ return { hash, shortHash, author, date, subject: subjectParts.join("|||") };
189
+ });
190
+ }
191
+ function findTestFiles(db, symbolId) {
192
+ const rawDb = db.getRawDb();
193
+ const testFiles = rawDb.all(
194
+ `SELECT DISTINCT n.file_path FROM edges e
195
+ JOIN nodes n ON n.id = e.source
196
+ WHERE e.target = ? AND (
197
+ n.file_path LIKE '%test%' OR n.file_path LIKE '%spec%' OR
198
+ n.file_path LIKE '%.test.%' OR n.file_path LIKE '%.spec.%'
199
+ )`,
200
+ [symbolId]
201
+ );
202
+ return testFiles.map((r) => r.file_path);
203
+ }
204
+ function findUncoveredSymbols(db, limit = 30) {
205
+ const rawDb = db.getRawDb();
206
+ return rawDb.all(
207
+ `SELECT n.name, n.kind, n.file_path, n.start_line FROM nodes n
208
+ WHERE n.is_exported = 1 AND n.kind IN ('function','method','class')
209
+ AND NOT EXISTS (
210
+ SELECT 1 FROM edges e JOIN nodes caller ON caller.id = e.source
211
+ WHERE e.target = n.id AND (
212
+ caller.file_path LIKE '%test%' OR caller.file_path LIKE '%spec%'
213
+ )
214
+ )
215
+ ORDER BY n.file_path, n.start_line LIMIT ?`,
216
+ [limit]
217
+ ).map((r) => ({ name: r.name, kind: r.kind, filePath: r.file_path, startLine: r.start_line }));
218
+ }
219
+ // Annotate the CommonJS export names for ESM import in node:
220
+ 0 && (module.exports = {
221
+ findTestFiles,
222
+ findUncoveredSymbols,
223
+ getChangedSymbols,
224
+ getCommitContext,
225
+ getCommitLog,
226
+ getPRContext,
227
+ parseDiff
228
+ });
229
+ //# sourceMappingURL=git-context.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/graph/git-context.ts"],
4
+ "sourcesContent": ["/**\n * Git Context \u2014 shared module for all enableGitContext tools.\n *\n * Runs git diff / git log, maps changed line ranges to graph nodes,\n * and enriches with callers/callees. All tools in handlers/git-context.ts\n * import from here.\n */\n\nimport { execSync } from 'child_process';\nimport type { GraphDatabase } from '../db/database';\n\nexport interface ChangedSymbol {\n name: string;\n kind: string;\n filePath: string;\n startLine: number;\n endLine: number;\n qualifiedName: string;\n changeType: 'added' | 'modified' | 'deleted' | 'unknown';\n callers: Array<{ name: string; kind: string; filePath: string; startLine: number }>;\n callees: Array<{ name: string; kind: string; filePath: string; startLine: number }>;\n}\n\nexport interface DiffHunk {\n filePath: string;\n addedLines: Array<[number, number]>; // [start, end] inclusive\n deletedLines: Array<[number, number]>;\n isNewFile: boolean;\n isDeletedFile: boolean;\n}\n\n/** Run a git command in projectRoot. Throws if git not found or not a git repo. */\nfunction git(projectRoot: string, args: string): string {\n try {\n return execSync(`git ${args}`, {\n cwd: projectRoot,\n encoding: 'utf8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n } catch (err: any) {\n throw new Error(`git ${args.split(' ')[0]} failed: ${err.message ?? String(err)}`);\n }\n}\n\n/** Parse unified diff output into a list of DiffHunk objects. */\nexport function parseDiff(diffOutput: string): DiffHunk[] {\n const hunks: DiffHunk[] = [];\n let current: DiffHunk | null = null;\n\n for (const line of diffOutput.split('\\n')) {\n if (line.startsWith('diff --git')) {\n current = null;\n continue;\n }\n if (line.startsWith('--- ') || line.startsWith('+++ ')) {\n const filePath = line.slice(4).replace(/^[ab]\\//, '').replace(/^\\t/, '');\n if (line.startsWith('+++ ') && filePath !== '/dev/null') {\n if (!current) {\n current = { filePath, addedLines: [], deletedLines: [], isNewFile: false, isDeletedFile: false };\n hunks.push(current);\n } else {\n current.filePath = filePath;\n }\n } else if (line.startsWith('--- ') && filePath === '/dev/null') {\n if (current) current.isNewFile = true;\n } else if (line.startsWith('+++ ') && filePath === '/dev/null') {\n if (current) current.isDeletedFile = true;\n }\n continue;\n }\n if (line.startsWith('@@') && current) {\n // @@ -oldStart,oldLen +newStart,newLen @@\n const m = line.match(/@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@/);\n if (m) {\n const newStart = parseInt(m[3], 10);\n const newLen = parseInt(m[4] ?? '1', 10);\n if (newLen > 0) current.addedLines.push([newStart, newStart + newLen - 1]);\n const oldStart = parseInt(m[1], 10);\n const oldLen = parseInt(m[2] ?? '1', 10);\n if (oldLen > 0) current.deletedLines.push([oldStart, oldStart + oldLen - 1]);\n }\n continue;\n }\n if (line.startsWith('new file') && current) { current.isNewFile = true; continue; }\n if (line.startsWith('deleted file') && current) { current.isDeletedFile = true; continue; }\n }\n\n return hunks;\n}\n\n/** Map a DiffHunk to graph nodes that overlap the changed line ranges. */\nfunction hunkToNodes(db: GraphDatabase, hunk: DiffHunk): Array<{ id: string; name: string; kind: string; filePath: string; startLine: number; endLine: number; qualifiedName: string; changeType: 'added' | 'modified' | 'deleted' | 'unknown' }> {\n const rawDb = db.getRawDb();\n const found = new Map<string, any>();\n\n const queryRange = (lines: Array<[number, number]>, changeType: 'added' | 'modified' | 'deleted') => {\n for (const [s, e] of lines) {\n const rows = rawDb.all(\n `SELECT id, name, kind, file_path, start_line, end_line, qualified_name\n FROM nodes WHERE file_path = ? AND start_line <= ? AND end_line >= ?\n AND kind NOT IN ('contains','declared_in')`,\n [hunk.filePath, e, s]\n );\n for (const r of rows) {\n if (!found.has(r.id)) found.set(r.id, { ...r, changeType });\n }\n }\n };\n\n if (hunk.isNewFile) {\n queryRange(hunk.addedLines, 'added');\n } else if (hunk.isDeletedFile) {\n // Can't look up nodes by line \u2014 they're gone. Return what we have.\n } else {\n queryRange(hunk.addedLines, 'modified');\n }\n\n return [...found.values()].map(r => ({\n id: r.id,\n name: r.name,\n kind: r.kind,\n filePath: r.file_path,\n startLine: r.start_line,\n endLine: r.end_line,\n qualifiedName: r.qualified_name,\n changeType: r.changeType,\n }));\n}\n\n/** Enrich a list of nodes with their immediate callers and callees (max 5 each). */\nfunction enrichWithEdges(db: GraphDatabase, nodes: Array<{ id: string; name: string; kind: string; filePath: string; startLine: number; endLine: number; qualifiedName: string; changeType: 'added' | 'modified' | 'deleted' | 'unknown' }>): ChangedSymbol[] {\n const rawDb = db.getRawDb();\n return nodes.map(n => {\n const callers = rawDb.all(\n `SELECT s.name, s.kind, s.file_path, s.start_line FROM edges e\n JOIN nodes s ON s.id = e.source WHERE e.target = ? AND e.kind IN ('calls','imports') LIMIT 5`,\n [n.id]\n ).map((r: any) => ({ name: r.name, kind: r.kind, filePath: r.file_path, startLine: r.start_line }));\n const callees = rawDb.all(\n `SELECT t.name, t.kind, t.file_path, t.start_line FROM edges e\n JOIN nodes t ON t.id = e.target WHERE e.source = ? AND e.kind IN ('calls','imports') LIMIT 5`,\n [n.id]\n ).map((r: any) => ({ name: r.name, kind: r.kind, filePath: r.file_path, startLine: r.start_line }));\n return { ...n, callers, callees };\n });\n}\n\nexport interface GitDiffResult {\n changedSymbols: ChangedSymbol[];\n hunks: DiffHunk[];\n ref?: string;\n}\n\n/**\n * Get changed symbols for unstaged, staged, or a ref diff.\n * - staged=false \u2192 git diff (working tree vs index)\n * - staged=true \u2192 git diff --cached (index vs HEAD)\n * - ref \u2192 git diff <ref>..HEAD\n */\nexport function getChangedSymbols(projectRoot: string, db: GraphDatabase, opts: { staged?: boolean; ref?: string } = {}): GitDiffResult {\n let diffArgs = 'diff --unified=0';\n if (opts.ref) diffArgs = `diff --unified=0 ${opts.ref}..HEAD`;\n else if (opts.staged) diffArgs = 'diff --cached --unified=0';\n\n const diffOutput = git(projectRoot, diffArgs);\n if (!diffOutput) return { changedSymbols: [], hunks: [] };\n\n const hunks = parseDiff(diffOutput);\n const allNodes: Array<{ id: string; name: string; kind: string; filePath: string; startLine: number; endLine: number; qualifiedName: string; changeType: 'added' | 'modified' | 'deleted' | 'unknown' }> = [];\n for (const h of hunks) {\n allNodes.push(...hunkToNodes(db, h));\n }\n\n // Deduplicate by id\n const seen = new Set<string>();\n const unique = allNodes.filter(n => { if (seen.has(n.id)) return false; seen.add(n.id); return true; });\n\n return { changedSymbols: enrichWithEdges(db, unique), hunks };\n}\n\n/** Get structured commit info for staged changes (for commit message generation). */\nexport interface CommitContext {\n stagedFiles: string[];\n changedSymbols: ChangedSymbol[];\n diffStat: string;\n}\n\nexport function getCommitContext(projectRoot: string, db: GraphDatabase): CommitContext {\n const stagedFiles = git(projectRoot, 'diff --cached --name-only').split('\\n').filter(Boolean);\n const diffStat = git(projectRoot, 'diff --cached --stat');\n const { changedSymbols } = getChangedSymbols(projectRoot, db, { staged: true });\n return { stagedFiles, changedSymbols, diffStat };\n}\n\n/** Get semantic diff between two git refs. */\nexport function getPRContext(projectRoot: string, db: GraphDatabase, base: string, head = 'HEAD'): GitDiffResult {\n const ref = `${base}..${head}`;\n let diffOutput: string;\n try {\n diffOutput = git(projectRoot, `diff --unified=0 ${ref}`);\n } catch {\n throw new Error(`Could not diff ${ref}. Ensure both refs exist in this repository.`);\n }\n if (!diffOutput) return { changedSymbols: [], hunks: [], ref };\n\n const hunks = parseDiff(diffOutput);\n const allNodes: Array<{ id: string; name: string; kind: string; filePath: string; startLine: number; endLine: number; qualifiedName: string; changeType: 'added' | 'modified' | 'deleted' | 'unknown' }> = [];\n for (const h of hunks) allNodes.push(...hunkToNodes(db, h));\n\n const seen = new Set<string>();\n const unique = allNodes.filter(n => { if (seen.has(n.id)) return false; seen.add(n.id); return true; });\n\n return { changedSymbols: enrichWithEdges(db, unique), hunks, ref };\n}\n\n/** Get commit log between two refs as structured entries. */\nexport interface CommitEntry {\n hash: string;\n shortHash: string;\n author: string;\n date: string;\n subject: string;\n}\n\nexport function getCommitLog(projectRoot: string, ref1: string, ref2: string): CommitEntry[] {\n const log = git(projectRoot, `log --pretty=format:%H|||%h|||%an|||%ad|||%s --date=short ${ref1}..${ref2}`);\n if (!log) return [];\n return log.split('\\n').filter(Boolean).map(line => {\n const [hash, shortHash, author, date, ...subjectParts] = line.split('|||');\n return { hash, shortHash, author, date, subject: subjectParts.join('|||') };\n });\n}\n\n/** Find test files that reference a given symbol. */\nexport function findTestFiles(db: GraphDatabase, symbolId: string): string[] {\n const rawDb = db.getRawDb();\n const testFiles = rawDb.all(\n `SELECT DISTINCT n.file_path FROM edges e\n JOIN nodes n ON n.id = e.source\n WHERE e.target = ? AND (\n n.file_path LIKE '%test%' OR n.file_path LIKE '%spec%' OR\n n.file_path LIKE '%.test.%' OR n.file_path LIKE '%.spec.%'\n )`,\n [symbolId]\n );\n return testFiles.map((r: any) => r.file_path);\n}\n\n/** Find symbols that have no test coverage (exported, no caller from a test file). */\nexport function findUncoveredSymbols(db: GraphDatabase, limit = 30): Array<{ name: string; kind: string; filePath: string; startLine: number }> {\n const rawDb = db.getRawDb();\n return rawDb.all(\n `SELECT n.name, n.kind, n.file_path, n.start_line FROM nodes n\n WHERE n.is_exported = 1 AND n.kind IN ('function','method','class')\n AND NOT EXISTS (\n SELECT 1 FROM edges e JOIN nodes caller ON caller.id = e.source\n WHERE e.target = n.id AND (\n caller.file_path LIKE '%test%' OR caller.file_path LIKE '%spec%'\n )\n )\n ORDER BY n.file_path, n.start_line LIMIT ?`,\n [limit]\n ).map((r: any) => ({ name: r.name, kind: r.kind, filePath: r.file_path, startLine: r.start_line }));\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,2BAAyB;AAwBzB,SAAS,IAAI,aAAqB,MAAsB;AACtD,MAAI;AACF,eAAO,+BAAS,OAAO,IAAI,IAAI;AAAA,MAC7B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,OAAO,CAAC,QAAQ,QAAQ,MAAM;AAAA,IAChC,CAAC,EAAE,KAAK;AAAA,EACV,SAAS,KAAU;AACjB,UAAM,IAAI,MAAM,OAAO,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,YAAY,IAAI,WAAW,OAAO,GAAG,CAAC,EAAE;AAAA,EACnF;AACF;AAGO,SAAS,UAAU,YAAgC;AACxD,QAAM,QAAoB,CAAC;AAC3B,MAAI,UAA2B;AAE/B,aAAW,QAAQ,WAAW,MAAM,IAAI,GAAG;AACzC,QAAI,KAAK,WAAW,YAAY,GAAG;AACjC,gBAAU;AACV;AAAA,IACF;AACA,QAAI,KAAK,WAAW,MAAM,KAAK,KAAK,WAAW,MAAM,GAAG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