@opentrace/components 0.1.1-rc.47 → 0.1.1-rc.62

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 (111) hide show
  1. package/README.md +306 -0
  2. package/bin/copy-wasm.js +125 -0
  3. package/dist/opentrace-components.cjs +354 -246
  4. package/dist/opentrace-components.cjs.map +1 -1
  5. package/dist/opentrace-components.js +355 -247
  6. package/dist/opentrace-components.js.map +1 -1
  7. package/dist/pipeline-wasm.cjs +58 -0
  8. package/dist/pipeline-wasm.cjs.map +1 -0
  9. package/dist/pipeline-wasm.js +57 -0
  10. package/dist/pipeline-wasm.js.map +1 -0
  11. package/dist/pipeline.cjs +3481 -0
  12. package/dist/pipeline.cjs.map +1 -0
  13. package/dist/pipeline.js +3481 -0
  14. package/dist/pipeline.js.map +1 -0
  15. package/dist/src/GraphCanvas.d.ts +5 -0
  16. package/dist/src/GraphCanvas.d.ts.map +1 -1
  17. package/dist/src/colors/communityColors.d.ts.map +1 -1
  18. package/dist/src/config/graphLayout.d.ts +9 -9
  19. package/dist/src/config/graphLayout.d.ts.map +1 -1
  20. package/dist/src/graph/LayoutPipeline.d.ts +4 -6
  21. package/dist/src/graph/LayoutPipeline.d.ts.map +1 -1
  22. package/dist/src/graph/spacingWorker.d.ts +4 -0
  23. package/dist/src/graph/spacingWorker.d.ts.map +1 -1
  24. package/dist/src/graph/useGraphFilters.d.ts.map +1 -1
  25. package/dist/src/graph/useGraphInstance.d.ts.map +1 -1
  26. package/dist/src/graph/useGraphVisuals.d.ts.map +1 -1
  27. package/dist/src/index.d.ts +1 -1
  28. package/dist/src/index.d.ts.map +1 -1
  29. package/dist/src/pipeline/__tests__/cross-repo.test.d.ts +2 -0
  30. package/dist/src/pipeline/__tests__/cross-repo.test.d.ts.map +1 -0
  31. package/dist/src/pipeline/__tests__/fixture.test.d.ts +2 -0
  32. package/dist/src/pipeline/__tests__/fixture.test.d.ts.map +1 -0
  33. package/dist/src/pipeline/__tests__/github.test.d.ts +2 -0
  34. package/dist/src/pipeline/__tests__/github.test.d.ts.map +1 -0
  35. package/dist/src/pipeline/__tests__/helpers.d.ts +16 -0
  36. package/dist/src/pipeline/__tests__/helpers.d.ts.map +1 -0
  37. package/dist/src/pipeline/__tests__/loading.test.d.ts +2 -0
  38. package/dist/src/pipeline/__tests__/loading.test.d.ts.map +1 -0
  39. package/dist/src/pipeline/__tests__/parsing.test.d.ts +2 -0
  40. package/dist/src/pipeline/__tests__/parsing.test.d.ts.map +1 -0
  41. package/dist/src/pipeline/__tests__/pipeline.test.d.ts +2 -0
  42. package/dist/src/pipeline/__tests__/pipeline.test.d.ts.map +1 -0
  43. package/dist/src/pipeline/index.d.ts +19 -0
  44. package/dist/src/pipeline/index.d.ts.map +1 -0
  45. package/dist/src/pipeline/parser/callResolver.d.ts +52 -0
  46. package/dist/src/pipeline/parser/callResolver.d.ts.map +1 -0
  47. package/dist/src/pipeline/parser/extractors/generic.d.ts +15 -0
  48. package/dist/src/pipeline/parser/extractors/generic.d.ts.map +1 -0
  49. package/dist/src/pipeline/parser/extractors/go.d.ts +8 -0
  50. package/dist/src/pipeline/parser/extractors/go.d.ts.map +1 -0
  51. package/dist/src/pipeline/parser/extractors/python.d.ts +8 -0
  52. package/dist/src/pipeline/parser/extractors/python.d.ts.map +1 -0
  53. package/dist/src/pipeline/parser/extractors/typescript.d.ts +8 -0
  54. package/dist/src/pipeline/parser/extractors/typescript.d.ts.map +1 -0
  55. package/dist/src/pipeline/parser/importAnalyzer.d.ts +25 -0
  56. package/dist/src/pipeline/parser/importAnalyzer.d.ts.map +1 -0
  57. package/dist/src/pipeline/parser/manifestParser.d.ts +42 -0
  58. package/dist/src/pipeline/parser/manifestParser.d.ts.map +1 -0
  59. package/dist/src/pipeline/pipeline.d.ts +10 -0
  60. package/dist/src/pipeline/pipeline.d.ts.map +1 -0
  61. package/dist/src/pipeline/stages/loading.d.ts +6 -0
  62. package/dist/src/pipeline/stages/loading.d.ts.map +1 -0
  63. package/dist/src/pipeline/stages/parsing.d.ts +20 -0
  64. package/dist/src/pipeline/stages/parsing.d.ts.map +1 -0
  65. package/dist/src/pipeline/stages/processing.d.ts +15 -0
  66. package/dist/src/pipeline/stages/processing.d.ts.map +1 -0
  67. package/dist/src/pipeline/stages/resolving.d.ts +11 -0
  68. package/dist/src/pipeline/stages/resolving.d.ts.map +1 -0
  69. package/dist/src/pipeline/stages/saving.d.ts +7 -0
  70. package/dist/src/pipeline/stages/saving.d.ts.map +1 -0
  71. package/dist/src/pipeline/stages/scanning.d.ts +7 -0
  72. package/dist/src/pipeline/stages/scanning.d.ts.map +1 -0
  73. package/dist/src/pipeline/stages/summarizing.d.ts +16 -0
  74. package/dist/src/pipeline/stages/summarizing.d.ts.map +1 -0
  75. package/dist/src/pipeline/store/memory.d.ts +8 -0
  76. package/dist/src/pipeline/store/memory.d.ts.map +1 -0
  77. package/dist/src/pipeline/summarizer/templateSummarizer.d.ts +40 -0
  78. package/dist/src/pipeline/summarizer/templateSummarizer.d.ts.map +1 -0
  79. package/dist/src/pipeline/summarizer/types.d.ts +62 -0
  80. package/dist/src/pipeline/summarizer/types.d.ts.map +1 -0
  81. package/dist/src/pipeline/types.d.ts +119 -0
  82. package/dist/src/pipeline/types.d.ts.map +1 -0
  83. package/dist/src/pipeline/wasm.d.ts +14 -0
  84. package/dist/src/pipeline/wasm.d.ts.map +1 -0
  85. package/dist/src/sigma/useSelectionPulse.d.ts +3 -0
  86. package/dist/src/sigma/useSelectionPulse.d.ts.map +1 -0
  87. package/dist/{useHighlights-DbMfb0-p.js → useHighlights-CmOAWaLE.js} +60 -53
  88. package/dist/{useHighlights-DbMfb0-p.js.map → useHighlights-CmOAWaLE.js.map} +1 -1
  89. package/dist/{useHighlights-fRWg-A_c.cjs → useHighlights-zx7DM4V0.cjs} +60 -53
  90. package/dist/{useHighlights-fRWg-A_c.cjs.map → useHighlights-zx7DM4V0.cjs.map} +1 -1
  91. package/dist/utils.cjs +1 -1
  92. package/dist/utils.js +1 -1
  93. package/package.json +32 -4
  94. package/public/wasm/tree-sitter-bash.wasm +0 -0
  95. package/public/wasm/tree-sitter-c.wasm +0 -0
  96. package/public/wasm/tree-sitter-c_sharp.wasm +0 -0
  97. package/public/wasm/tree-sitter-cpp.wasm +0 -0
  98. package/public/wasm/tree-sitter-go.wasm +0 -0
  99. package/public/wasm/tree-sitter-java.wasm +0 -0
  100. package/public/wasm/tree-sitter-json.wasm +0 -0
  101. package/public/wasm/tree-sitter-kotlin.wasm +0 -0
  102. package/public/wasm/tree-sitter-python.wasm +0 -0
  103. package/public/wasm/tree-sitter-ruby.wasm +0 -0
  104. package/public/wasm/tree-sitter-rust.wasm +0 -0
  105. package/public/wasm/tree-sitter-swift.wasm +0 -0
  106. package/public/wasm/tree-sitter-toml.wasm +0 -0
  107. package/public/wasm/tree-sitter-tsx.wasm +0 -0
  108. package/public/wasm/tree-sitter-typescript.wasm +0 -0
  109. package/public/wasm/web-tree-sitter.wasm +0 -0
  110. package/dist/assets/spacingWorker-hXLGHyRg.js +0 -123
  111. package/dist/assets/spacingWorker-hXLGHyRg.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.cjs","sources":["../src/pipeline/stages/loading.ts","../src/pipeline/parser/manifestParser.ts","../src/pipeline/stages/scanning.ts","../src/pipeline/parser/extractors/python.ts","../src/pipeline/parser/extractors/typescript.ts","../src/pipeline/parser/extractors/go.ts","../src/pipeline/parser/extractors/generic.ts","../src/pipeline/stages/parsing.ts","../src/pipeline/parser/importAnalyzer.ts","../src/pipeline/stages/processing.ts","../src/pipeline/parser/callResolver.ts","../src/pipeline/stages/resolving.ts","../src/pipeline/stages/saving.ts","../src/pipeline/summarizer/templateSummarizer.ts","../src/pipeline/stages/summarizing.ts","../src/pipeline/pipeline.ts","../src/pipeline/store/memory.ts","../src/pipeline/summarizer/types.ts"],"sourcesContent":["/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { GraphNode, GraphRelationship } from '../types';\n\nconst LANGUAGE_MAP: Record<string, string> = {\n '.py': 'python',\n '.ts': 'typescript',\n '.tsx': 'typescript',\n '.js': 'javascript',\n '.jsx': 'javascript',\n '.go': 'go',\n '.rs': 'rust',\n '.java': 'java',\n '.kt': 'kotlin',\n '.rb': 'ruby',\n '.c': 'c',\n '.cpp': 'cpp',\n '.h': 'c',\n '.hpp': 'cpp',\n '.cs': 'csharp',\n '.swift': 'swift',\n};\n\nexport function getExtension(path: string): string {\n const dot = path.lastIndexOf('.');\n if (dot === -1 || dot === path.length - 1) return '';\n return path.slice(dot);\n}\n\nexport function parentDir(path: string): string {\n const slash = path.lastIndexOf('/');\n if (slash <= 0) return '';\n return path.slice(0, slash);\n}\n\nexport function detectLanguage(ext: string): string | null {\n return LANGUAGE_MAP[ext] ?? null;\n}\n\nexport function ensureDirChain(\n repoId: string,\n dirPath: string,\n dirNodes: Map<string, GraphNode>,\n rels: GraphRelationship[],\n): void {\n if (!dirPath || dirNodes.has(dirPath)) return;\n\n const parent = parentDir(dirPath);\n ensureDirChain(repoId, parent, dirNodes, rels);\n\n const dirId = `${repoId}/${dirPath}`;\n const name = dirPath.includes('/')\n ? dirPath.slice(dirPath.lastIndexOf('/') + 1)\n : dirPath;\n\n dirNodes.set(dirPath, {\n id: dirId,\n type: 'Directory',\n name,\n properties: { path: dirPath },\n });\n\n const targetId = parent ? `${repoId}/${parent}` : repoId;\n rels.push({\n id: `${dirId}->DEFINED_IN->${targetId}`,\n type: 'DEFINED_IN',\n source_id: dirId,\n target_id: targetId,\n });\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Parse dependency manifests (package.json, go.mod, requirements.txt, pyproject.toml)\n * into structured dependency records. Pure functions — no tree-sitter needed.\n */\n\nexport interface ParsedDependency {\n name: string; // \"react\", \"github.com/gorilla/mux\", \"requests\"\n version: string; // \"^18.0.0\", \"v1.8.1\", \">=3.0\"\n registry: string; // \"npm\" | \"pypi\" | \"go\" | \"crates\"\n source: string; // manifest file path: \"package.json\"\n dependencyType: string; // \"runtime\" | \"dev\" | \"peer\" | \"optional\" | \"indirect\"\n}\n\nexport interface ManifestParseResult {\n dependencies: ParsedDependency[];\n errors: string[];\n}\n\nconst MANIFEST_BASENAMES = new Set([\n 'package.json',\n 'go.mod',\n 'requirements.txt',\n 'pyproject.toml',\n 'Cargo.toml',\n]);\n\nconst LOCK_BASENAMES = new Set([\n 'package-lock.json',\n 'yarn.lock',\n 'pnpm-lock.yaml',\n 'go.sum',\n 'poetry.lock',\n 'Cargo.lock',\n 'uv.lock',\n]);\n\n/** Returns true if the file path is a supported dependency manifest. */\nexport function isManifestFile(path: string): boolean {\n const basename = path.split('/').pop() ?? '';\n if (LOCK_BASENAMES.has(basename)) return false;\n return MANIFEST_BASENAMES.has(basename);\n}\n\n/** Dispatch to the correct parser based on filename. */\nexport function parseManifest(\n path: string,\n content: string,\n): ManifestParseResult {\n const basename = path.split('/').pop() ?? '';\n switch (basename) {\n case 'package.json':\n return parsePackageJson(content, path);\n case 'go.mod':\n return parseGoMod(content, path);\n case 'requirements.txt':\n return parseRequirementsTxt(content, path);\n case 'pyproject.toml':\n return parsePyprojectToml(content, path);\n case 'Cargo.toml':\n return parseCargoToml(content, path);\n default:\n return {\n dependencies: [],\n errors: [`Unsupported manifest: ${basename}`],\n };\n }\n}\n\n/** Deterministic package ID: pkg:{registry}:{name} */\nexport function packageId(registry: string, name: string): string {\n return `pkg:${registry}:${name}`;\n}\n\n/** Return the canonical web URL for a package on its registry. */\nexport function packageSourceUrl(\n registry: string,\n name: string,\n): string | undefined {\n switch (registry) {\n case 'npm':\n return `https://www.npmjs.com/package/${name}`;\n case 'pypi':\n return `https://pypi.org/project/${name}/`;\n case 'go':\n return `https://pkg.go.dev/${name}`;\n case 'crates':\n return `https://crates.io/crates/${name}`;\n case 'rubygems':\n return `https://rubygems.org/gems/${name}`;\n default:\n return undefined;\n }\n}\n\n// ---------------------------------------------------------------------------\n// package.json\n// ---------------------------------------------------------------------------\n\nexport function parsePackageJson(\n content: string,\n source: string,\n): ManifestParseResult {\n const errors: string[] = [];\n const deps: ParsedDependency[] = [];\n\n let parsed: Record<string, unknown>;\n try {\n parsed = JSON.parse(content);\n } catch (e) {\n return { dependencies: [], errors: [`Failed to parse ${source}: ${e}`] };\n }\n\n const sections: Array<[string, string]> = [\n ['dependencies', 'runtime'],\n ['devDependencies', 'dev'],\n ['peerDependencies', 'peer'],\n ['optionalDependencies', 'optional'],\n ];\n\n for (const [key, depType] of sections) {\n const section = parsed[key];\n if (!section || typeof section !== 'object') continue;\n for (const [name, version] of Object.entries(\n section as Record<string, string>,\n )) {\n deps.push({\n name,\n version: typeof version === 'string' ? version : '',\n registry: 'npm',\n source,\n dependencyType: depType,\n });\n }\n }\n\n return { dependencies: deps, errors };\n}\n\n// ---------------------------------------------------------------------------\n// go.mod\n// ---------------------------------------------------------------------------\n\nexport function parseGoMod(\n content: string,\n source: string,\n): ManifestParseResult {\n const deps: ParsedDependency[] = [];\n const errors: string[] = [];\n\n // Match require blocks: require ( ... )\n const blockRe = /require\\s*\\(([\\s\\S]*?)\\)/g;\n let match: RegExpExecArray | null;\n\n while ((match = blockRe.exec(content)) !== null) {\n const block = match[1];\n for (const line of block.split('\\n')) {\n const dep = parseGoRequireLine(line, source);\n if (dep) deps.push(dep);\n }\n }\n\n // Match single-line requires: require path version\n const singleRe = /^require\\s+(\\S+)\\s+(\\S+)(.*)$/gm;\n while ((match = singleRe.exec(content)) !== null) {\n const depType = match[3]?.includes('// indirect') ? 'indirect' : 'runtime';\n deps.push({\n name: match[1],\n version: match[2],\n registry: 'go',\n source,\n dependencyType: depType,\n });\n }\n\n return { dependencies: deps, errors };\n}\n\nfunction parseGoRequireLine(\n line: string,\n source: string,\n): ParsedDependency | null {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('//')) return null;\n\n // e.g. \"github.com/gorilla/mux v1.8.1 // indirect\"\n const parts = trimmed.split(/\\s+/);\n if (parts.length < 2) return null;\n\n const depType = trimmed.includes('// indirect') ? 'indirect' : 'runtime';\n return {\n name: parts[0],\n version: parts[1],\n registry: 'go',\n source,\n dependencyType: depType,\n };\n}\n\n// ---------------------------------------------------------------------------\n// requirements.txt\n// ---------------------------------------------------------------------------\n\nexport function parseRequirementsTxt(\n content: string,\n source: string,\n): ManifestParseResult {\n const deps: ParsedDependency[] = [];\n const errors: string[] = [];\n\n for (const rawLine of content.split('\\n')) {\n const line = rawLine.trim();\n // Skip blanks, comments, flags (-r, -e, -c, --), and URL references\n if (\n !line ||\n line.startsWith('#') ||\n line.startsWith('-') ||\n line.startsWith('http')\n )\n continue;\n\n // Parse: name[extras]<op>version or bare name\n const match = line.match(\n /^([A-Za-z0-9_.-]+)(?:\\[.*?\\])?\\s*([<>=!~]+\\s*\\S+)?/,\n );\n if (!match) continue;\n\n const rawName = match[1];\n const version = match[2]?.trim() ?? '*';\n\n deps.push({\n name: normalizePyName(rawName),\n version,\n registry: 'pypi',\n source,\n dependencyType: 'runtime',\n });\n }\n\n return { dependencies: deps, errors };\n}\n\n// ---------------------------------------------------------------------------\n// pyproject.toml (limited line-based parser — no TOML library)\n// ---------------------------------------------------------------------------\n\n/**\n * Parses dependencies from pyproject.toml using a simple line-based state machine.\n * Handles `[project] dependencies = [...]` and `[tool.poetry.dependencies]` sections.\n * Falls back gracefully on unusual formatting.\n */\nexport function parsePyprojectToml(\n content: string,\n source: string,\n): ManifestParseResult {\n const deps: ParsedDependency[] = [];\n const errors: string[] = [];\n\n const lines = content.split('\\n');\n let i = 0;\n\n // Track current section header\n let currentSection = '';\n\n while (i < lines.length) {\n const line = lines[i].trim();\n\n // Section headers\n if (line.startsWith('[')) {\n currentSection = line;\n i++;\n continue;\n }\n\n // [project] section: look for dependencies = [...]\n if (currentSection === '[project]' && line.startsWith('dependencies')) {\n const eqIdx = line.indexOf('=');\n if (eqIdx === -1) {\n i++;\n continue;\n }\n\n const afterEq = line.slice(eqIdx + 1).trim();\n if (afterEq.startsWith('[')) {\n // Could be single-line or multi-line array\n const arrayContent = collectTomlArray(lines, i, eqIdx + 1);\n for (const item of parseTomlStringArray(arrayContent)) {\n const dep = parsePep508(item, source);\n if (dep) deps.push(dep);\n }\n }\n i++;\n continue;\n }\n\n // [tool.poetry.dependencies] section\n if (currentSection === '[tool.poetry.dependencies]') {\n // key = \"version\" or key = {version = \"...\", ...}\n const eqIdx = line.indexOf('=');\n if (eqIdx > 0 && !line.startsWith('#') && !line.startsWith('[')) {\n const name = line.slice(0, eqIdx).trim();\n if (name === 'python') {\n i++;\n continue;\n } // skip python version constraint\n const value = line.slice(eqIdx + 1).trim();\n const version = value.replace(/^[\"']|[\"']$/g, '');\n deps.push({\n name: normalizePyName(name),\n version,\n registry: 'pypi',\n source,\n dependencyType: 'runtime',\n });\n }\n }\n\n // [project.optional-dependencies] section\n if (currentSection.startsWith('[project.optional-dependencies')) {\n if (line.includes('=') && !line.startsWith('#')) {\n const eqIdx = line.indexOf('=');\n const afterEq = line.slice(eqIdx + 1).trim();\n if (afterEq.startsWith('[')) {\n const arrayContent = collectTomlArray(lines, i, eqIdx + 1);\n for (const item of parseTomlStringArray(arrayContent)) {\n const dep = parsePep508(item, source, 'optional');\n if (dep) deps.push(dep);\n }\n }\n }\n }\n\n i++;\n }\n\n return { dependencies: deps, errors };\n}\n\n/** Collect a TOML array that may span multiple lines, starting from a [ character. */\nfunction collectTomlArray(\n lines: string[],\n startLine: number,\n charOffset: number,\n): string {\n let result = lines[startLine].slice(charOffset).trim();\n // Check if the array closes on the same line (track bracket depth)\n if (bracketsClosed(result)) return result;\n\n for (let i = startLine + 1; i < lines.length; i++) {\n result += '\\n' + lines[i];\n if (bracketsClosed(result)) break;\n }\n return result;\n}\n\n/** Returns true if all brackets in the string are balanced (outermost [ has its matching ]). */\nfunction bracketsClosed(s: string): boolean {\n let depth = 0;\n for (const ch of s) {\n if (ch === '[') depth++;\n else if (ch === ']') depth--;\n if (depth === 0 && s.indexOf('[') !== -1) return true;\n }\n return false;\n}\n\n/** Parse a TOML string array like `[\"foo>=1.0\", \"bar\"]` into its elements. */\nfunction parseTomlStringArray(raw: string): string[] {\n const items: string[] = [];\n // Match quoted strings inside brackets\n const re = /[\"']([^\"']+)[\"']/g;\n let m: RegExpExecArray | null;\n while ((m = re.exec(raw)) !== null) {\n items.push(m[1]);\n }\n return items;\n}\n\n/** Parse a PEP 508 dependency string like \"requests>=2.0\" or \"Flask[async]~=2.0\". */\nfunction parsePep508(\n spec: string,\n source: string,\n depType = 'runtime',\n): ParsedDependency | null {\n const trimmed = spec.trim();\n if (!trimmed) return null;\n\n // name[extras]<op>version\n const match = trimmed.match(\n /^([A-Za-z0-9_.-]+)(?:\\[.*?\\])?\\s*([<>=!~]+.*)?$/,\n );\n if (!match) return null;\n\n return {\n name: normalizePyName(match[1]),\n version: match[2]?.trim() ?? '*',\n registry: 'pypi',\n source,\n dependencyType: depType,\n };\n}\n\n/** Normalize Python package name: lowercase, underscores to dashes. */\nexport function normalizePyName(name: string): string {\n return name.toLowerCase().replace(/_/g, '-');\n}\n\n// ---------------------------------------------------------------------------\n// Cargo.toml (line-based parser — no TOML library)\n// ---------------------------------------------------------------------------\n\n/**\n * Parses dependencies from Cargo.toml using a line-based state machine.\n * Handles [dependencies], [dev-dependencies], and [build-dependencies] sections.\n */\nexport function parseCargoToml(\n content: string,\n source: string,\n): ManifestParseResult {\n const deps: ParsedDependency[] = [];\n const errors: string[] = [];\n\n const lines = content.split('\\n');\n let currentSection = '';\n\n const depSections: Record<string, string> = {\n '[dependencies]': 'runtime',\n '[dev-dependencies]': 'dev',\n '[build-dependencies]': 'dev',\n };\n\n for (const rawLine of lines) {\n const line = rawLine.trim();\n\n // Section headers\n if (line.startsWith('[')) {\n currentSection = line;\n continue;\n }\n\n if (line.startsWith('#') || !line) continue;\n\n // Check if we're in a dependency section\n const depType = depSections[currentSection];\n if (!depType) continue;\n\n const eqIdx = line.indexOf('=');\n if (eqIdx <= 0) continue;\n\n const name = line.slice(0, eqIdx).trim();\n const value = line.slice(eqIdx + 1).trim();\n\n // value can be: \"1.0\", { version = \"1.0\", ... }, or a bare version\n let version = '*';\n if (value.startsWith('\"') || value.startsWith(\"'\")) {\n version = value.replace(/^[\"']|[\"']$/g, '');\n } else if (value.startsWith('{')) {\n const verMatch = value.match(/version\\s*=\\s*[\"']([^\"']+)[\"']/);\n if (verMatch) version = verMatch[1];\n }\n\n deps.push({\n name,\n version,\n registry: 'crates',\n source,\n dependencyType: depType,\n });\n }\n\n return { dependencies: deps, errors };\n}\n\n/** Extract npm package name from import specifier: @scope/pkg/sub → @scope/pkg, lodash/fp → lodash */\nexport function npmPackageName(specifier: string): string {\n if (specifier.startsWith('@')) {\n // Scoped: @scope/pkg or @scope/pkg/sub\n const parts = specifier.split('/');\n return parts.length >= 2 ? `${parts[0]}/${parts[1]}` : specifier;\n }\n // Unscoped: lodash or lodash/fp\n return specifier.split('/')[0];\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Scanning stage: builds the structural graph (Repo, Dir, File, Package nodes)\n * and pre-computes lookup maps for downstream stages.\n */\n\nimport type {\n GraphNode,\n GraphRelationship,\n LoadingInput,\n ScanResult,\n PipelineContext,\n PipelineEvent,\n RepoFile,\n} from '../types';\nimport {\n getExtension,\n detectLanguage,\n parentDir,\n ensureDirChain,\n} from './loading';\nimport {\n isManifestFile,\n parseManifest,\n packageId,\n packageSourceUrl,\n} from '../parser/manifestParser';\n\nconst PARSEABLE_LANGUAGES = new Set([\n 'python',\n 'typescript',\n 'javascript',\n 'go',\n 'rust',\n 'java',\n 'kotlin',\n 'csharp',\n 'c',\n 'cpp',\n 'ruby',\n 'swift',\n]);\n\nexport function* execute(\n input: LoadingInput,\n ctx: PipelineContext,\n): Generator<PipelineEvent, ScanResult> {\n const { repo } = input;\n const repoId = `${repo.owner}/${repo.repo}`;\n\n yield {\n kind: 'stage_start',\n phase: 'scanning',\n message: `Scanning ${repo.files.length} files`,\n };\n\n const repoProps: Record<string, unknown> = { ref: repo.ref };\n if (repo.url) repoProps.source_uri = repo.url;\n if (repo.provider) repoProps.provider = repo.provider;\n\n const repoNode: GraphNode = {\n id: repoId,\n type: 'Repository',\n name: repoId,\n properties: repoProps,\n };\n\n const dirNodes = new Map<string, GraphNode>();\n const fileNodes: GraphNode[] = [];\n const structureRels: GraphRelationship[] = [];\n const parseableFiles: RepoFile[] = [];\n const packageNodes = new Map<string, GraphNode>();\n const dependencyRels: GraphRelationship[] = [];\n let goModulePath: string | undefined;\n\n // Pre-compute lookup maps for downstream stages\n const knownPaths = new Set<string>();\n const pathToFileId = new Map<string, string>();\n\n const total = repo.files.length;\n\n for (let i = 0; i < repo.files.length; i++) {\n if (ctx.cancelled) break;\n\n const file = repo.files[i];\n const ext = getExtension(file.path);\n const language = detectLanguage(ext);\n\n const fileId = `${repoId}/${file.path}`;\n const fileName = file.path.includes('/')\n ? file.path.slice(file.path.lastIndexOf('/') + 1)\n : file.path;\n\n const fileProps: Record<string, unknown> = {\n path: file.path,\n extension: ext,\n };\n if (language) fileProps.language = language;\n if (repo.url) {\n fileProps.source_uri = `${repo.url}/blob/${repo.ref}/${file.path}`;\n }\n\n fileNodes.push({\n id: fileId,\n type: 'File',\n name: fileName,\n properties: fileProps,\n });\n\n const dir = parentDir(file.path);\n ensureDirChain(repoId, dir, dirNodes, structureRels);\n\n const parentId = dir ? `${repoId}/${dir}` : repoId;\n structureRels.push({\n id: `${fileId}->DEFINED_IN->${parentId}`,\n type: 'DEFINED_IN',\n source_id: fileId,\n target_id: parentId,\n });\n\n if (language && PARSEABLE_LANGUAGES.has(language)) {\n parseableFiles.push(file);\n }\n\n // Populate lookup maps\n knownPaths.add(file.path);\n pathToFileId.set(file.path, fileId);\n\n // Manifest parsing: extract Package nodes + DEPENDS_ON rels\n if (isManifestFile(file.path)) {\n const manifestResult = parseManifest(file.path, file.content);\n\n if (file.path.endsWith('go.mod') || file.path.includes('/go.mod')) {\n const moduleMatch = file.content.match(/^module\\s+(\\S+)/m);\n if (moduleMatch) goModulePath = moduleMatch[1];\n }\n\n for (const dep of manifestResult.dependencies) {\n const pkgId = packageId(dep.registry, dep.name);\n if (!packageNodes.has(pkgId)) {\n const props: Record<string, unknown> = {\n registry: dep.registry,\n version: dep.version,\n };\n const sourceUrl = packageSourceUrl(dep.registry, dep.name);\n if (sourceUrl) props.source_uri = sourceUrl;\n\n packageNodes.set(pkgId, {\n id: pkgId,\n type: 'Package',\n name: dep.name,\n properties: props,\n });\n }\n\n dependencyRels.push({\n id: `${repoId}->DEPENDS_ON->${pkgId}`,\n type: 'DEPENDS_ON',\n source_id: repoId,\n target_id: pkgId,\n properties: {\n version: dep.version,\n dependency_type: dep.dependencyType,\n source: dep.source,\n },\n });\n }\n }\n\n yield {\n kind: 'stage_progress',\n phase: 'scanning',\n message: `Scanning ${file.path}`,\n detail: { current: i + 1, total, fileName: file.path },\n };\n }\n\n const structureNodes: GraphNode[] = [\n repoNode,\n ...dirNodes.values(),\n ...fileNodes,\n ...packageNodes.values(),\n ];\n\n yield {\n kind: 'stage_stop',\n phase: 'scanning',\n message: `Scanned ${fileNodes.length} files, ${dirNodes.size} directories, ${packageNodes.size} packages`,\n nodes: structureNodes,\n relationships: [...structureRels, ...dependencyRels],\n };\n\n return {\n repo,\n repoId,\n repoNode,\n dirNodes,\n fileNodes,\n structureRels,\n parseableFiles,\n packageNodes,\n dependencyRels,\n goModulePath,\n knownPaths,\n pathToFileId,\n };\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Python symbol extractor using web-tree-sitter.\n * Ported from agent/src/opentrace_agent/sources/code/extractors/python_extractor.py\n */\n\nimport type { Node as SyntaxNode } from 'web-tree-sitter';\nimport type { CallRef, CodeSymbol, ExtractionResult } from '../../types';\n\n/** Extract a Python docstring from a function/class body block.\n * Docstrings are the first statement if it's an `expression_statement` whose child is a `string`. */\nfunction extractDocstring(bodyNode: SyntaxNode | null): string | undefined {\n if (!bodyNode) return undefined;\n const first = bodyNode.namedChildren[0];\n if (!first || first.type !== 'expression_statement') return undefined;\n const strNode = first.namedChildren[0];\n if (!strNode || strNode.type !== 'string') return undefined;\n // Strip triple-quote delimiters and clean up\n const raw = strNode.text;\n const stripped = raw\n .replace(/^(\"\"\"|''')\\s?/, '')\n .replace(/\\s?(\"\"\"|''')$/, '');\n return stripped.trim() || undefined;\n}\n\nexport function extractPython(rootNode: SyntaxNode): ExtractionResult {\n const symbols = walkNode(rootNode);\n return { symbols, language: 'python', rootNode };\n}\n\nfunction walkNode(node: SyntaxNode): CodeSymbol[] {\n const symbols: CodeSymbol[] = [];\n for (const child of node.children) {\n if (child.type === 'class_definition') {\n const sym = extractClass(child);\n if (sym) symbols.push(sym);\n } else if (child.type === 'function_definition') {\n const sym = extractFunction(child);\n if (sym) symbols.push(sym);\n } else if (child.type === 'decorated_definition') {\n for (const sub of child.children) {\n if (sub.type === 'class_definition') {\n const sym = extractClass(sub);\n if (sym) symbols.push(sym);\n } else if (sub.type === 'function_definition') {\n const sym = extractFunction(sub);\n if (sym) symbols.push(sym);\n }\n }\n }\n }\n return symbols;\n}\n\nfunction extractClass(node: SyntaxNode): CodeSymbol | null {\n const nameNode = node.childForFieldName('name');\n if (!nameNode) return null;\n const bodyNode = node.childForFieldName('body');\n const children = walkClassBody(node);\n const superclasses = extractBaseClasses(node);\n const docs = extractDocstring(bodyNode);\n return {\n name: nameNode.text,\n kind: 'class',\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n signature: null,\n children,\n calls: [],\n receiverVar: null,\n receiverType: null,\n paramTypes: null,\n superclasses: superclasses.length > 0 ? superclasses : undefined,\n docs,\n };\n}\n\n/** Extract base classes from Python class_definition's argument_list child.\n * e.g., `class Admin(User, Mixin):` → [\"User\", \"Mixin\"] */\nfunction extractBaseClasses(node: SyntaxNode): string[] {\n const bases: string[] = [];\n const argList = node.childForFieldName('superclasses');\n if (!argList) return bases;\n for (const child of argList.children) {\n if (child.type === 'identifier') {\n bases.push(child.text);\n } else if (child.type === 'attribute') {\n // e.g., module.ClassName — use the full dotted text\n bases.push(child.text);\n } else if (child.type === 'keyword_argument') {\n // Skip metaclass=... and other keyword args\n }\n }\n return bases;\n}\n\nfunction walkClassBody(node: SyntaxNode): CodeSymbol[] {\n const body = node.childForFieldName('body');\n if (!body) return [];\n const methods: CodeSymbol[] = [];\n for (const child of body.children) {\n if (child.type === 'function_definition') {\n const sym = extractFunction(child);\n if (sym) methods.push(sym);\n } else if (child.type === 'decorated_definition') {\n for (const sub of child.children) {\n if (sub.type === 'function_definition') {\n const sym = extractFunction(sub);\n if (sym) methods.push(sym);\n }\n }\n }\n }\n return methods;\n}\n\nfunction extractFunction(node: SyntaxNode): CodeSymbol | null {\n const nameNode = node.childForFieldName('name');\n if (!nameNode) return null;\n const paramsNode = node.childForFieldName('parameters');\n const signature = paramsNode ? paramsNode.text : null;\n const paramTypes = paramsNode ? extractParamTypes(paramsNode) : null;\n const bodyNode = node.childForFieldName('body');\n const calls = bodyNode ? collectCalls(bodyNode) : [];\n const docs = extractDocstring(bodyNode);\n return {\n name: nameNode.text,\n kind: 'function',\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n signature,\n children: [],\n calls,\n receiverVar: null,\n receiverType: null,\n paramTypes,\n docs,\n };\n}\n\nfunction extractParamTypes(\n paramsNode: SyntaxNode,\n): Record<string, string> | null {\n const types: Record<string, string> = {};\n for (const child of paramsNode.children) {\n if (\n child.type === 'typed_parameter' ||\n child.type === 'typed_default_parameter'\n ) {\n // Name is the first identifier child (Python grammar has no \"name\" field)\n let nameNode: SyntaxNode | null = null;\n for (const sub of child.children) {\n if (sub.type === 'identifier') {\n nameNode = sub;\n break;\n }\n }\n const typeNode = child.childForFieldName('type');\n if (nameNode && typeNode) {\n const paramName = nameNode.text;\n if (paramName === 'self' || paramName === 'cls') continue;\n // Take the leaf of dotted types (e.g., grpc.Channel → Channel)\n const typeText = typeNode.text;\n const leaf = typeText.includes('.')\n ? typeText.split('.').pop()!\n : typeText;\n types[paramName] = leaf;\n }\n }\n }\n return Object.keys(types).length > 0 ? types : null;\n}\n\nfunction collectCalls(node: SyntaxNode): CallRef[] {\n const calls: CallRef[] = [];\n for (const child of node.children) {\n if (child.type === 'call') {\n const funcNode = child.childForFieldName('function');\n if (funcNode && funcNode.type === 'identifier') {\n calls.push({ name: funcNode.text, receiver: null, kind: 'bare' });\n } else if (funcNode && funcNode.type === 'attribute') {\n const objNode = funcNode.childForFieldName('object');\n const attrNode = funcNode.childForFieldName('attribute');\n if (objNode && attrNode) {\n calls.push({\n name: attrNode.text,\n receiver: objNode.text,\n kind: 'attribute',\n });\n }\n }\n }\n calls.push(...collectCalls(child));\n }\n return calls;\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * TypeScript/TSX symbol extractor using web-tree-sitter.\n * Ported from agent/src/opentrace_agent/sources/code/extractors/typescript_extractor.py\n */\n\nimport type { Node as SyntaxNode } from 'web-tree-sitter';\nimport type { CallRef, CodeSymbol, ExtractionResult } from '../../types';\n\nconst CLASS_TYPES = new Set([\n 'class_declaration',\n 'abstract_class_declaration',\n]);\nconst FUNCTION_TYPES = new Set([\n 'function_declaration',\n 'generator_function_declaration',\n]);\nconst METHOD_TYPES = new Set(['method_definition', 'public_field_definition']);\n\n/** Extract a JSDoc/TSDoc comment from the preceding sibling of an AST node.\n * Checks both the node itself and its parent (for `export_statement` wrapping). */\nfunction extractJSDoc(node: SyntaxNode): string | undefined {\n let prev = node.previousNamedSibling;\n // If no JSDoc on the node itself, check the parent (handles `export function ...`)\n if (\n (!prev || prev.type !== 'comment') &&\n node.parent?.type === 'export_statement'\n ) {\n prev = node.parent.previousNamedSibling;\n }\n if (!prev || prev.type !== 'comment') return undefined;\n const text = prev.text;\n if (!text.startsWith('/**')) return undefined;\n // Strip /** ... */ delimiters and leading ` * ` prefixes\n const cleaned = text\n .replace(/^\\/\\*\\*\\s*/, '')\n .replace(/\\s*\\*\\/$/, '')\n .split('\\n')\n .map((line) => line.replace(/^\\s*\\*\\s?/, ''))\n .join('\\n')\n .trim();\n return cleaned || undefined;\n}\n\nexport function extractTypeScript(\n rootNode: SyntaxNode,\n language = 'typescript',\n): ExtractionResult {\n const symbols = walkNode(rootNode);\n return { symbols, language, rootNode };\n}\n\nfunction walkNode(node: SyntaxNode): CodeSymbol[] {\n const symbols: CodeSymbol[] = [];\n for (const child of node.children) {\n if (CLASS_TYPES.has(child.type)) {\n const sym = extractClass(child);\n if (sym) symbols.push(sym);\n } else if (FUNCTION_TYPES.has(child.type)) {\n const sym = extractFunction(child);\n if (sym) symbols.push(sym);\n } else if (child.type === 'lexical_declaration') {\n symbols.push(...extractLexicalDeclaration(child));\n } else if (child.type === 'export_statement') {\n // Unwrap `export class ...` / `export function ...`\n symbols.push(...walkNode(child));\n }\n }\n return symbols;\n}\n\nfunction extractClass(node: SyntaxNode): CodeSymbol | null {\n const nameNode = node.childForFieldName('name');\n if (!nameNode) return null;\n const children = walkClassBody(node);\n const { superclasses, interfaces } = extractClassHeritage(node);\n const docs = extractJSDoc(node);\n return {\n name: nameNode.text,\n kind: 'class',\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n signature: null,\n children,\n calls: [],\n receiverVar: null,\n receiverType: null,\n paramTypes: null,\n superclasses: superclasses.length > 0 ? superclasses : undefined,\n interfaces: interfaces.length > 0 ? interfaces : undefined,\n docs,\n };\n}\n\n/** Extract extends/implements from a class_heritage child. */\nfunction extractClassHeritage(node: SyntaxNode): {\n superclasses: string[];\n interfaces: string[];\n} {\n const superclasses: string[] = [];\n const interfaces: string[] = [];\n for (const child of node.children) {\n if (child.type === 'class_heritage') {\n for (const clause of child.children) {\n if (clause.type === 'extends_clause') {\n superclasses.push(...collectHeritageNames(clause));\n } else if (clause.type === 'implements_clause') {\n interfaces.push(...collectHeritageNames(clause));\n }\n }\n }\n }\n return { superclasses, interfaces };\n}\n\n/** Collect type names from an extends/implements clause. */\nfunction collectHeritageNames(clause: SyntaxNode): string[] {\n const names: string[] = [];\n for (const child of clause.children) {\n if (child.type === 'identifier' || child.type === 'type_identifier') {\n names.push(child.text);\n } else if (child.type === 'generic_type') {\n // e.g., `Map<string, number>` — extract just the base name\n const nameNode = child.childForFieldName('name');\n if (nameNode) names.push(nameNode.text);\n }\n }\n return names;\n}\n\nfunction walkClassBody(node: SyntaxNode): CodeSymbol[] {\n const body = node.childForFieldName('body');\n if (!body) return [];\n const methods: CodeSymbol[] = [];\n for (const child of body.children) {\n if (METHOD_TYPES.has(child.type)) {\n const sym = extractMethod(child);\n if (sym) methods.push(sym);\n }\n }\n return methods;\n}\n\nfunction extractFunction(node: SyntaxNode): CodeSymbol | null {\n const nameNode = node.childForFieldName('name');\n if (!nameNode) return null;\n const paramsNode = node.childForFieldName('parameters');\n const signature = paramsNode ? paramsNode.text : null;\n const bodyNode = node.childForFieldName('body');\n const calls = bodyNode ? collectCalls(bodyNode) : [];\n const docs = extractJSDoc(node);\n return {\n name: nameNode.text,\n kind: 'function',\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n signature,\n children: [],\n calls,\n receiverVar: null,\n receiverType: null,\n paramTypes: null,\n docs,\n };\n}\n\nfunction extractMethod(node: SyntaxNode): CodeSymbol | null {\n const nameNode = node.childForFieldName('name');\n if (!nameNode) return null;\n const paramsNode = node.childForFieldName('parameters');\n const signature = paramsNode ? paramsNode.text : null;\n const bodyNode = node.childForFieldName('body');\n const calls = bodyNode ? collectCalls(bodyNode) : [];\n const docs = extractJSDoc(node);\n return {\n name: nameNode.text,\n kind: 'function',\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n signature,\n children: [],\n calls,\n receiverVar: null,\n receiverType: null,\n paramTypes: null,\n docs,\n };\n}\n\nfunction extractLexicalDeclaration(node: SyntaxNode): CodeSymbol[] {\n const symbols: CodeSymbol[] = [];\n for (const child of node.children) {\n if (child.type === 'variable_declarator') {\n const nameNode = child.childForFieldName('name');\n const valueNode = child.childForFieldName('value');\n if (!nameNode || !valueNode) continue;\n const name = nameNode.text;\n if (\n valueNode.type === 'arrow_function' ||\n valueNode.type === 'function_expression'\n ) {\n const sym = extractArrowFunction(name, node, valueNode);\n if (sym) symbols.push(sym);\n } else if (valueNode.type === 'class') {\n const sym = extractClassExpression(name, node, valueNode);\n if (sym) symbols.push(sym);\n }\n }\n }\n return symbols;\n}\n\nfunction extractArrowFunction(\n name: string,\n declNode: SyntaxNode,\n valueNode: SyntaxNode,\n): CodeSymbol {\n const paramsNode = valueNode.childForFieldName('parameters');\n const signature = paramsNode ? paramsNode.text : null;\n const bodyNode = valueNode.childForFieldName('body');\n const calls = bodyNode ? collectCalls(bodyNode) : [];\n const docs = extractJSDoc(declNode);\n return {\n name,\n kind: 'function',\n startLine: declNode.startPosition.row + 1,\n endLine: declNode.endPosition.row + 1,\n signature,\n children: [],\n calls,\n receiverVar: null,\n receiverType: null,\n paramTypes: null,\n docs,\n };\n}\n\nfunction extractClassExpression(\n name: string,\n declNode: SyntaxNode,\n valueNode: SyntaxNode,\n): CodeSymbol {\n const children = walkClassBody(valueNode);\n const { superclasses, interfaces } = extractClassHeritage(valueNode);\n const docs = extractJSDoc(declNode);\n return {\n name,\n kind: 'class',\n startLine: declNode.startPosition.row + 1,\n endLine: declNode.endPosition.row + 1,\n signature: null,\n children,\n calls: [],\n receiverVar: null,\n receiverType: null,\n paramTypes: null,\n superclasses: superclasses.length > 0 ? superclasses : undefined,\n interfaces: interfaces.length > 0 ? interfaces : undefined,\n docs,\n };\n}\n\nfunction collectCalls(node: SyntaxNode): CallRef[] {\n const calls: CallRef[] = [];\n\n // Extract call from this node (handles both direct call_expression nodes\n // like concise arrow bodies, and call_expression children found via recursion)\n if (node.type === 'call_expression') {\n const funcNode = node.childForFieldName('function');\n if (funcNode && funcNode.type === 'identifier') {\n calls.push({ name: funcNode.text, receiver: null, kind: 'bare' });\n } else if (funcNode && funcNode.type === 'member_expression') {\n const objNode = funcNode.childForFieldName('object');\n const propNode = funcNode.childForFieldName('property');\n if (objNode && propNode) {\n calls.push({\n name: propNode.text,\n receiver: objNode.text,\n kind: 'attribute',\n });\n }\n }\n }\n\n for (const child of node.children) {\n calls.push(...collectCalls(child));\n }\n return calls;\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Go symbol extractor using web-tree-sitter.\n * Ported from agent/src/opentrace_agent/sources/code/extractors/go_extractor.py\n */\n\nimport type { Node as SyntaxNode } from 'web-tree-sitter';\nimport type { CallRef, CodeSymbol, ExtractionResult } from '../../types';\n\n/** Extract GoDoc comments from consecutive preceding `comment` siblings.\n * Go convention: `// Comment` lines immediately above a declaration. */\nfunction extractGoDoc(node: SyntaxNode): string | undefined {\n const comments: string[] = [];\n let prev = node.previousNamedSibling;\n while (prev && prev.type === 'comment') {\n comments.push(prev.text);\n prev = prev.previousNamedSibling;\n }\n if (comments.length === 0) return undefined;\n // Reverse (we collected bottom-up) and strip `// ` prefix\n const cleaned = comments\n .reverse()\n .map((line) => line.replace(/^\\/\\/\\s?/, ''))\n .join('\\n')\n .trim();\n return cleaned || undefined;\n}\n\nexport function extractGo(rootNode: SyntaxNode): ExtractionResult {\n const symbols = walkNode(rootNode);\n return { symbols, language: 'go', rootNode };\n}\n\nfunction walkNode(node: SyntaxNode): CodeSymbol[] {\n const symbols: CodeSymbol[] = [];\n for (const child of node.children) {\n let sym: CodeSymbol | null = null;\n if (child.type === 'type_declaration') {\n sym = extractTypeDecl(child);\n } else if (child.type === 'function_declaration') {\n sym = extractFunction(child);\n } else if (child.type === 'method_declaration') {\n sym = extractMethod(child);\n }\n if (sym) {\n sym.docs = extractGoDoc(child);\n symbols.push(sym);\n }\n }\n return symbols;\n}\n\nfunction extractTypeDecl(node: SyntaxNode): CodeSymbol | null {\n for (const child of node.children) {\n if (child.type === 'type_spec') {\n const nameNode = child.childForFieldName('name');\n if (!nameNode) continue;\n const typeNode = child.childForFieldName('type');\n if (\n typeNode &&\n (typeNode.type === 'struct_type' || typeNode.type === 'interface_type')\n ) {\n const isInterface = typeNode.type === 'interface_type';\n const methods = isInterface ? extractInterfaceMethods(typeNode) : [];\n const subtype = isInterface ? 'interface' : 'struct';\n const embedded = isInterface\n ? extractEmbeddedInterfaces(typeNode)\n : extractEmbeddedStructs(typeNode);\n return {\n name: nameNode.text,\n kind: 'class',\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n signature: null,\n children: methods,\n calls: [],\n receiverVar: null,\n receiverType: null,\n paramTypes: null,\n subtype,\n interfaces: isInterface && embedded.length > 0 ? embedded : undefined,\n superclasses:\n !isInterface && embedded.length > 0 ? embedded : undefined,\n };\n }\n }\n }\n return null;\n}\n\n/** Extract embedded interface names from interface_type children.\n * e.g., `type ReadWriter interface { Reader; Writer }` → [\"Reader\", \"Writer\"]\n * Embedded interfaces appear as type_elem → type_identifier (not method_elem). */\nfunction extractEmbeddedInterfaces(node: SyntaxNode): string[] {\n const names: string[] = [];\n for (const child of node.children) {\n if (child.type === 'type_elem') {\n for (const sub of child.children) {\n if (sub.type === 'type_identifier') {\n names.push(sub.text);\n } else if (sub.type === 'qualified_type') {\n names.push(sub.text);\n }\n }\n }\n }\n return names;\n}\n\n/** Extract embedded struct field types from struct_type children.\n * e.g., `type Admin struct { User }` → [\"User\"] */\nfunction extractEmbeddedStructs(node: SyntaxNode): string[] {\n const names: string[] = [];\n for (const child of node.children) {\n if (child.type === 'field_declaration_list') {\n for (const field of child.children) {\n if (field.type === 'field_declaration') {\n // Embedded fields have a type but no name\n const nameNode = field.childForFieldName('name');\n const typeNode = field.childForFieldName('type');\n if (!nameNode && typeNode) {\n if (typeNode.type === 'type_identifier') {\n names.push(typeNode.text);\n } else if (typeNode.type === 'pointer_type') {\n for (const sub of typeNode.children) {\n if (sub.type === 'type_identifier') {\n names.push(sub.text);\n break;\n }\n }\n } else if (typeNode.type === 'qualified_type') {\n names.push(typeNode.text);\n }\n }\n }\n }\n }\n }\n return names;\n}\n\nfunction extractInterfaceMethods(node: SyntaxNode): CodeSymbol[] {\n const methods: CodeSymbol[] = [];\n for (const child of node.children) {\n if (child.type === 'method_elem') {\n const nameNode = child.childForFieldName('name');\n if (nameNode) {\n const paramsNode = child.childForFieldName('parameters');\n methods.push({\n name: nameNode.text,\n kind: 'function',\n startLine: child.startPosition.row + 1,\n endLine: child.endPosition.row + 1,\n signature: paramsNode ? paramsNode.text : null,\n children: [],\n calls: [],\n receiverVar: null,\n receiverType: null,\n paramTypes: null,\n });\n }\n }\n }\n return methods;\n}\n\nfunction extractFunction(node: SyntaxNode): CodeSymbol | null {\n const nameNode = node.childForFieldName('name');\n if (!nameNode) return null;\n const paramsNode = node.childForFieldName('parameters');\n const signature = paramsNode ? paramsNode.text : null;\n const bodyNode = node.childForFieldName('body');\n const calls = bodyNode ? collectCalls(bodyNode) : [];\n return {\n name: nameNode.text,\n kind: 'function',\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n signature,\n children: [],\n calls,\n receiverVar: null,\n receiverType: null,\n paramTypes: null,\n };\n}\n\nfunction extractMethod(node: SyntaxNode): CodeSymbol | null {\n const nameNode = node.childForFieldName('name');\n if (!nameNode) return null;\n const paramsNode = node.childForFieldName('parameters');\n const receiverNode = node.childForFieldName('receiver');\n\n const parts: string[] = [];\n let receiverVar: string | null = null;\n let receiverType: string | null = null;\n if (receiverNode) {\n parts.push(receiverNode.text);\n [receiverVar, receiverType] = parseReceiver(receiverNode);\n }\n if (paramsNode) {\n parts.push(paramsNode.text);\n }\n const signature = parts.length > 0 ? parts.join(' ') : null;\n\n const bodyNode = node.childForFieldName('body');\n const calls = bodyNode ? collectCalls(bodyNode) : [];\n return {\n name: nameNode.text,\n kind: 'function',\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n signature,\n children: [],\n calls,\n receiverVar,\n receiverType,\n paramTypes: null,\n };\n}\n\nfunction parseReceiver(\n receiverNode: SyntaxNode,\n): [string | null, string | null] {\n for (const child of receiverNode.children) {\n if (child.type === 'parameter_declaration') {\n let varName: string | null = null;\n let typeName: string | null = null;\n const nameChild = child.childForFieldName('name');\n if (nameChild) varName = nameChild.text;\n const typeChild = child.childForFieldName('type');\n if (typeChild) {\n if (typeChild.type === 'pointer_type') {\n for (const sub of typeChild.children) {\n if (sub.type === 'type_identifier') {\n typeName = sub.text;\n break;\n }\n }\n } else if (typeChild.type === 'type_identifier') {\n typeName = typeChild.text;\n }\n }\n return [varName, typeName];\n }\n }\n return [null, null];\n}\n\nfunction collectCalls(node: SyntaxNode): CallRef[] {\n const calls: CallRef[] = [];\n for (const child of node.children) {\n if (child.type === 'call_expression') {\n const funcNode = child.childForFieldName('function');\n if (funcNode && funcNode.type === 'identifier') {\n calls.push({ name: funcNode.text, receiver: null, kind: 'bare' });\n } else if (funcNode && funcNode.type === 'selector_expression') {\n const operand = funcNode.childForFieldName('operand');\n const field = funcNode.childForFieldName('field');\n if (operand && field) {\n calls.push({\n name: field.text,\n receiver: operand.text,\n kind: 'attribute',\n });\n }\n }\n }\n calls.push(...collectCalls(child));\n }\n return calls;\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Generic table-driven symbol extractor for languages without bespoke extractors.\n *\n * Uses per-language configuration tables to identify class-like and function-like\n * AST node types. Extracts names, line numbers, and parent–child relationships.\n *\n * Limitations (acceptable for v1):\n * - calls array is always empty (no call extraction)\n * - No import analysis (importAnalyzer returns empty for unknown languages)\n * - receiverVar/receiverType always null\n */\n\nimport type { Node as SyntaxNode } from 'web-tree-sitter';\nimport type { CodeSymbol, ExtractionResult } from '../../types';\n\ninterface LanguageConfig {\n /** AST node types treated as class-like (struct, enum, interface, etc.) */\n classTypes: Set<string>;\n /** AST node types treated as function-like */\n functionTypes: Set<string>;\n /** AST node types whose body should be recursed into for child methods */\n containerTypes: Set<string>;\n}\n\n/** Maps AST node types → subtype strings for class-like nodes. */\nconst SUBTYPE_MAP: Record<string, string> = {\n // C/C++\n struct_specifier: 'struct',\n enum_specifier: 'enum',\n // C#\n struct_declaration: 'struct',\n interface_declaration: 'interface',\n enum_declaration: 'enum',\n // Kotlin\n object_declaration: 'object',\n // Ruby\n module: 'module',\n // Rust\n struct_item: 'struct',\n enum_item: 'enum',\n trait_item: 'trait',\n // Swift\n protocol_declaration: 'protocol',\n};\n\nconst LANGUAGE_CONFIGS: Record<string, LanguageConfig> = {\n c: {\n classTypes: new Set(['struct_specifier', 'enum_specifier']),\n functionTypes: new Set(['function_definition']),\n containerTypes: new Set(),\n },\n cpp: {\n classTypes: new Set([\n 'class_specifier',\n 'struct_specifier',\n 'enum_specifier',\n ]),\n functionTypes: new Set(['function_definition']),\n containerTypes: new Set(['class_specifier', 'namespace_definition']),\n },\n csharp: {\n classTypes: new Set([\n 'class_declaration',\n 'interface_declaration',\n 'struct_declaration',\n 'enum_declaration',\n ]),\n functionTypes: new Set(['method_declaration', 'local_function_statement']),\n containerTypes: new Set([\n 'class_declaration',\n 'interface_declaration',\n 'namespace_declaration',\n ]),\n },\n java: {\n classTypes: new Set([\n 'class_declaration',\n 'interface_declaration',\n 'enum_declaration',\n ]),\n functionTypes: new Set(['method_declaration', 'constructor_declaration']),\n containerTypes: new Set(['class_declaration', 'interface_declaration']),\n },\n kotlin: {\n classTypes: new Set(['class_declaration', 'object_declaration']),\n functionTypes: new Set(['function_declaration']),\n containerTypes: new Set(['class_declaration', 'object_declaration']),\n },\n ruby: {\n classTypes: new Set(['class', 'module']),\n functionTypes: new Set(['method', 'singleton_method']),\n containerTypes: new Set(['class', 'module']),\n },\n rust: {\n classTypes: new Set(['struct_item', 'enum_item', 'trait_item']),\n functionTypes: new Set(['function_item', 'function_signature_item']),\n containerTypes: new Set(['impl_item', 'trait_item']),\n },\n swift: {\n classTypes: new Set([\n 'class_declaration',\n 'protocol_declaration',\n 'struct_declaration',\n 'enum_declaration',\n ]),\n functionTypes: new Set(['function_declaration', 'init_declaration']),\n containerTypes: new Set([\n 'class_declaration',\n 'protocol_declaration',\n 'struct_declaration',\n ]),\n },\n};\n\n/** Extract documentation comment from the preceding sibling(s) of an AST node.\n * Handles both block comments (Javadoc-style) and consecutive line comments. */\nfunction extractPrecedingDoc(node: SyntaxNode): string | undefined {\n const prev = node.previousNamedSibling;\n if (!prev) return undefined;\n\n // Block comment (Java/C/C++/Kotlin Javadoc): single `comment` or `block_comment` node starting with `/**`\n if (\n (prev.type === 'comment' || prev.type === 'block_comment') &&\n prev.text.startsWith('/**')\n ) {\n const cleaned = prev.text\n .replace(/^\\/\\*\\*\\s*/, '')\n .replace(/\\s*\\*\\/$/, '')\n .split('\\n')\n .map((line) => line.replace(/^\\s*\\*\\s?/, ''))\n .join('\\n')\n .trim();\n return cleaned || undefined;\n }\n\n // Consecutive line comments (C#, Rust, Swift, etc.): `//` or `///`\n if (prev.type === 'comment' || prev.type === 'line_comment') {\n const comments: string[] = [];\n let cur: SyntaxNode | null = prev;\n while (cur && (cur.type === 'comment' || cur.type === 'line_comment')) {\n comments.push(cur.text);\n cur = cur.previousNamedSibling;\n }\n const cleaned = comments\n .reverse()\n .map((line) => line.replace(/^\\/\\/\\/?\\s?/, ''))\n .join('\\n')\n .trim();\n return cleaned || undefined;\n }\n\n return undefined;\n}\n\nexport function extractGeneric(\n rootNode: SyntaxNode,\n language: string,\n): ExtractionResult {\n const config = LANGUAGE_CONFIGS[language];\n if (!config) {\n return { symbols: [], language, rootNode };\n }\n const symbols = walkTopLevel(rootNode, config);\n return { symbols, language, rootNode };\n}\n\n/** Walk top-level children, extracting classes and functions. */\nfunction walkTopLevel(node: SyntaxNode, config: LanguageConfig): CodeSymbol[] {\n const symbols: CodeSymbol[] = [];\n for (const child of node.children) {\n const sym = extractNode(child, config);\n if (sym) {\n symbols.push(sym);\n } else if (config.containerTypes.has(child.type)) {\n // Container without a name (e.g., Rust `impl Foo {}`) — extract children as top-level\n const body = findBody(child);\n if (body) {\n symbols.push(...walkTopLevel(body, config));\n }\n } else {\n // Recurse into wrapper nodes (e.g., namespace bodies, extern blocks)\n symbols.push(...walkTopLevel(child, config));\n }\n }\n return symbols;\n}\n\nfunction extractNode(\n node: SyntaxNode,\n config: LanguageConfig,\n): CodeSymbol | null {\n let sym: CodeSymbol | null = null;\n if (config.classTypes.has(node.type)) {\n sym = extractClass(node, config);\n } else if (config.functionTypes.has(node.type)) {\n sym = extractFunction(node);\n }\n if (sym) {\n sym.docs = extractPrecedingDoc(node);\n }\n return sym;\n}\n\nfunction extractClass(\n node: SyntaxNode,\n config: LanguageConfig,\n): CodeSymbol | null {\n const name = extractName(node);\n if (!name) return null;\n\n const body = findBody(node);\n const children = body ? extractMethods(body, config) : [];\n const subtype = SUBTYPE_MAP[node.type];\n const { superclasses, interfaces } = extractInheritance(node);\n\n return {\n name,\n kind: 'class',\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n signature: null,\n children,\n calls: [],\n receiverVar: null,\n receiverType: null,\n paramTypes: null,\n subtype,\n superclasses: superclasses.length > 0 ? superclasses : undefined,\n interfaces: interfaces.length > 0 ? interfaces : undefined,\n };\n}\n\nfunction extractFunction(node: SyntaxNode): CodeSymbol | null {\n const name = extractName(node);\n if (!name) return null;\n\n // C/C++ parameters are nested: declarator → function_declarator → parameters\n let paramsNode = node.childForFieldName('parameters');\n if (!paramsNode) {\n const decl = node.childForFieldName('declarator');\n if (decl?.type === 'function_declarator') {\n paramsNode = decl.childForFieldName('parameters');\n }\n }\n const signature = paramsNode ? paramsNode.text : null;\n\n return {\n name,\n kind: 'function',\n startLine: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n signature,\n children: [],\n calls: [],\n receiverVar: null,\n receiverType: null,\n paramTypes: null,\n };\n}\n\n/**\n * Extract superclasses and interfaces from a class-like AST node.\n * Each language grammar represents inheritance differently.\n */\nfunction extractInheritance(node: SyntaxNode): {\n superclasses: string[];\n interfaces: string[];\n} {\n const superclasses: string[] = [];\n const interfaces: string[] = [];\n\n // Java/Ruby: childForFieldName(\"superclass\")\n // Java → \"superclass\" node wrapping type_identifier child\n // Ruby → \"superclass\" node wrapping constant child\n const superclassField = node.childForFieldName('superclass');\n if (superclassField) {\n for (const child of superclassField.children) {\n if (\n child.type === 'type_identifier' ||\n child.type === 'constant' ||\n child.type === 'scope_resolution'\n ) {\n superclasses.push(child.text);\n }\n }\n // If no named identifier child found, try collecting recursively\n if (superclasses.length === 0) {\n const names = collectTypeIdentifiers(superclassField);\n superclasses.push(...names);\n }\n }\n\n // Java: childForFieldName(\"interfaces\") → type_list → type_identifier children\n const interfacesField = node.childForFieldName('interfaces');\n if (interfacesField) {\n interfaces.push(...collectTypeIdentifiers(interfacesField));\n }\n\n // C++: base_class_clause; C#: base_list; Kotlin: delegation_specifiers\n // Swift: type_inheritance_clause — all use a single list node for supertypes\n for (const child of node.children) {\n if (\n child.type === 'base_class_clause' ||\n child.type === 'base_list' ||\n child.type === 'delegation_specifiers' ||\n child.type === 'type_inheritance_clause'\n ) {\n superclasses.push(...collectTypeIdentifiers(child));\n }\n }\n\n return { superclasses, interfaces };\n}\n\n/** Collect type_identifier / identifier / simple_identifier texts from a parent node. */\nfunction collectTypeIdentifiers(node: SyntaxNode): string[] {\n const names: string[] = [];\n for (const child of node.children) {\n if (\n child.type === 'type_identifier' ||\n child.type === 'identifier' ||\n child.type === 'simple_identifier'\n ) {\n names.push(child.text);\n } else if (child.namedChildCount > 0) {\n // Recurse into wrapper nodes (e.g., Java type_list → type_identifier,\n // Kotlin delegation_specifier → user_type → simple_identifier,\n // Swift type_inheritance_clause → inheritance_specifier → type)\n names.push(...collectTypeIdentifiers(child));\n }\n }\n return names;\n}\n\n/** Extract methods from a class/container body. */\nfunction extractMethods(\n body: SyntaxNode,\n config: LanguageConfig,\n): CodeSymbol[] {\n const methods: CodeSymbol[] = [];\n for (const child of body.children) {\n if (config.functionTypes.has(child.type)) {\n const sym = extractFunction(child);\n if (sym) methods.push(sym);\n } else if (config.classTypes.has(child.type)) {\n // Nested class\n const sym = extractClass(child, config);\n if (sym) methods.push(sym);\n }\n }\n return methods;\n}\n\n/**\n * Extract the name from an AST node using a fallback chain:\n * 1. childForFieldName(\"name\")\n * 2. childForFieldName(\"declarator\") — C/C++ pattern\n * 3. First identifier child\n */\nfunction extractName(node: SyntaxNode): string | null {\n // Standard: most languages use a \"name\" field\n const nameNode = node.childForFieldName('name');\n if (nameNode) {\n // For C/C++, the name field of a class_specifier/struct_specifier is the type name\n return nameNode.text;\n }\n\n // C/C++ functions: name is in the \"declarator\" field\n const declarator = node.childForFieldName('declarator');\n if (declarator) {\n // declarator might be a function_declarator wrapping an identifier\n if (declarator.type === 'function_declarator') {\n const inner = declarator.childForFieldName('declarator');\n if (inner) return inner.text;\n }\n if (\n declarator.type === 'identifier' ||\n declarator.type === 'field_identifier'\n ) {\n return declarator.text;\n }\n // Qualified declarator (C++): qualified_identifier → name\n const qName = declarator.childForFieldName('name');\n if (qName) return qName.text;\n return declarator.text;\n }\n\n // Fallback: first identifier child (includes simple_identifier for Kotlin)\n for (const child of node.children) {\n if (\n child.type === 'identifier' ||\n child.type === 'type_identifier' ||\n child.type === 'simple_identifier' ||\n child.type === 'constant'\n ) {\n return child.text;\n }\n }\n\n return null;\n}\n\n/** Find the body/block child of a node. */\nfunction findBody(node: SyntaxNode): SyntaxNode | null {\n // Try common field names\n const body = node.childForFieldName('body');\n if (body) return body;\n\n // Some grammars use \"members\" or \"declaration_list\"\n for (const child of node.children) {\n if (\n child.type === 'field_declaration_list' ||\n child.type === 'declaration_list' ||\n child.type === 'class_body' ||\n child.type === 'enum_body' ||\n child.type === 'interface_body' ||\n child.type === 'block'\n ) {\n return child;\n }\n }\n\n return null;\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Node as SyntaxNode } from 'web-tree-sitter';\nimport type {\n CodeSymbol,\n ExtractionResult,\n GraphNode,\n GraphRelationship,\n ParserMap,\n ParsingFileResult,\n} from '../types';\nimport { detectLanguage, getExtension } from './loading';\nimport { extractPython } from '../parser/extractors/python';\nimport { extractTypeScript } from '../parser/extractors/typescript';\nimport { extractGo } from '../parser/extractors/go';\nimport { extractGeneric } from '../parser/extractors/generic';\nimport type {\n Registries,\n CallInfo,\n SymbolNode,\n} from '../parser/callResolver';\n\n// --- Parser registry (module-level) ---\n\nlet parsers: ParserMap = new Map();\n\n/** Register parsers for use by the parsing stage. Call once during init. */\nexport function initParsers(map: ParserMap): void {\n parsers = map;\n}\n\nexport function getExtractor(\n language: string,\n): ((rootNode: SyntaxNode) => ExtractionResult) | null {\n switch (language) {\n case 'python':\n return extractPython;\n case 'typescript':\n case 'javascript':\n return (rootNode) => extractTypeScript(rootNode, language);\n case 'go':\n return extractGo;\n case 'c':\n case 'cpp':\n case 'csharp':\n case 'java':\n case 'kotlin':\n case 'ruby':\n case 'rust':\n case 'swift':\n return (rootNode) => extractGeneric(rootNode, language);\n default:\n return null;\n }\n}\n\nexport function getParserForLanguage(language: string, ext: string) {\n if (language === 'typescript' && ext === '.tsx') {\n return parsers.get('tsx') ?? parsers.get('typescript');\n }\n if (language === 'javascript' && ext === '.jsx') {\n return parsers.get('jsx') ?? parsers.get('javascript');\n }\n return parsers.get(language);\n}\n\nexport function parseFile(\n filePath: string,\n fileContent: string,\n repoId: string,\n): ParsingFileResult {\n const ext = getExtension(filePath);\n const language = detectLanguage(ext);\n\n if (!language) {\n return {\n nodes: [],\n relationships: [],\n classesExtracted: 0,\n functionsExtracted: 0,\n };\n }\n\n const parser = getParserForLanguage(language, ext);\n if (!parser) {\n return {\n nodes: [],\n relationships: [],\n classesExtracted: 0,\n functionsExtracted: 0,\n };\n }\n\n const extractor = getExtractor(language);\n if (!extractor) {\n return {\n nodes: [],\n relationships: [],\n classesExtracted: 0,\n functionsExtracted: 0,\n };\n }\n\n try {\n const tree = parser.parse(fileContent);\n if (!tree) {\n return {\n nodes: [],\n relationships: [],\n classesExtracted: 0,\n functionsExtracted: 0,\n error: `${filePath}: parse returned null`,\n };\n }\n\n const result = extractor(tree.rootNode);\n const fileId = `${repoId}/${filePath}`;\n const nodes: GraphNode[] = [];\n const rels: GraphRelationship[] = [];\n const stats = { classesExtracted: 0, functionsExtracted: 0 };\n\n for (const sym of result.symbols) {\n convertSymbol(sym, fileId, nodes, rels, stats);\n }\n\n return { nodes, relationships: rels, ...stats };\n } catch (err) {\n return {\n nodes: [],\n relationships: [],\n classesExtracted: 0,\n functionsExtracted: 0,\n error: `${filePath}: ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n}\n\n/**\n * Process a symbol into graph nodes/rels and populate registries for call resolution.\n * Ported from runner's pipeline.ts processSymbol().\n */\nexport function processSymbol(\n symbol: CodeSymbol,\n parentId: string,\n language: string,\n registries: Registries,\n callInfos: CallInfo[],\n nodes: GraphNode[],\n rels: GraphRelationship[],\n emittedNodeIds: Set<string>,\n): SymbolNode | null {\n const fileId = parentId.split('::')[0];\n const namePart = symbol.receiverType\n ? `${symbol.receiverType}.${symbol.name}`\n : symbol.name;\n const nodeId = `${parentId}::${namePart}`;\n\n // Guard against duplicate node IDs (e.g. C++ constructors sharing class name)\n if (emittedNodeIds.has(nodeId)) {\n return null;\n }\n emittedNodeIds.add(nodeId);\n\n if (symbol.kind === 'class') {\n const props: Record<string, unknown> = {\n language,\n start_line: symbol.startLine,\n end_line: symbol.endLine,\n };\n if (symbol.signature) props.signature = symbol.signature;\n if (symbol.superclasses) props.superclasses = symbol.superclasses;\n if (symbol.interfaces) props.interfaces = symbol.interfaces;\n if (symbol.subtype) props.subtype = symbol.subtype;\n if (symbol.docs) props.docs = symbol.docs;\n\n nodes.push({\n id: nodeId,\n type: 'Class',\n name: symbol.name,\n properties: props,\n });\n\n rels.push({\n id: `${nodeId}->DEFINED_IN->${parentId}`,\n type: 'DEFINED_IN',\n source_id: nodeId,\n target_id: parentId,\n });\n\n const symbolNode: SymbolNode = {\n id: nodeId,\n name: symbol.name,\n kind: 'class',\n fileId,\n parentId,\n receiverVar: null,\n receiverType: null,\n paramTypes: null,\n children: [],\n };\n addToRegistry(registries.nameRegistry, symbol.name, symbolNode);\n registries.fileRegistry.get(fileId)?.set(symbol.name, symbolNode);\n addToRegistry(registries.classRegistry, symbol.name, symbolNode);\n\n for (const child of symbol.children) {\n const childSymbolNode = processSymbol(\n child,\n nodeId,\n language,\n registries,\n callInfos,\n nodes,\n rels,\n emittedNodeIds,\n );\n if (childSymbolNode) symbolNode.children.push(childSymbolNode);\n }\n\n return symbolNode;\n } else {\n const props: Record<string, unknown> = {\n language,\n start_line: symbol.startLine,\n end_line: symbol.endLine,\n };\n if (symbol.signature) props.signature = symbol.signature;\n if (symbol.docs) props.docs = symbol.docs;\n\n nodes.push({\n id: nodeId,\n type: 'Function',\n name: symbol.name,\n properties: props,\n });\n\n rels.push({\n id: `${nodeId}->DEFINED_IN->${parentId}`,\n type: 'DEFINED_IN',\n source_id: nodeId,\n target_id: parentId,\n });\n\n const symbolNode: SymbolNode = {\n id: nodeId,\n name: symbol.name,\n kind: 'function',\n fileId,\n parentId,\n receiverVar: symbol.receiverVar,\n receiverType: symbol.receiverType,\n paramTypes: symbol.paramTypes,\n children: [],\n };\n addToRegistry(registries.nameRegistry, symbol.name, symbolNode);\n registries.fileRegistry.get(fileId)?.set(symbol.name, symbolNode);\n\n if (symbol.calls.length > 0) {\n callInfos.push({\n callerNode: symbolNode,\n calls: symbol.calls,\n fileId,\n });\n }\n\n return symbolNode;\n }\n}\n\nexport function addToRegistry(\n registry: Map<string, SymbolNode[]>,\n name: string,\n node: SymbolNode,\n): void {\n const existing = registry.get(name);\n if (existing) {\n existing.push(node);\n } else {\n registry.set(name, [node]);\n }\n}\n\n/** Recursively count classes and functions (including methods inside classes). */\nexport function countSymbols(symbols: CodeSymbol[]): {\n classes: number;\n functions: number;\n} {\n let classes = 0;\n let functions = 0;\n for (const sym of symbols) {\n if (sym.kind === 'class') {\n classes++;\n const childCounts = countSymbols(sym.children);\n classes += childCounts.classes;\n functions += childCounts.functions;\n } else {\n functions++;\n }\n }\n return { classes, functions };\n}\n\nfunction convertSymbol(\n sym: CodeSymbol,\n parentId: string,\n nodes: GraphNode[],\n rels: GraphRelationship[],\n stats: { classesExtracted: number; functionsExtracted: number },\n): void {\n const namePart = sym.receiverType\n ? `${sym.receiverType}.${sym.name}`\n : sym.name;\n const symId = `${parentId}::${namePart}`;\n const nodeType = sym.kind === 'class' ? 'Class' : 'Function';\n\n const props: Record<string, unknown> = {\n start_line: sym.startLine,\n end_line: sym.endLine,\n };\n if (sym.signature) props.signature = sym.signature;\n if (sym.docs) props.docs = sym.docs;\n if (sym.superclasses) props.superclasses = sym.superclasses;\n if (sym.interfaces) props.interfaces = sym.interfaces;\n if (sym.subtype) props.subtype = sym.subtype;\n\n nodes.push({\n id: symId,\n type: nodeType,\n name: sym.name,\n properties: props,\n });\n\n rels.push({\n id: `${symId}->DEFINED_IN->${parentId}`,\n type: 'DEFINED_IN',\n source_id: symId,\n target_id: parentId,\n });\n\n if (sym.kind === 'class') {\n stats.classesExtracted++;\n for (const child of sym.children) {\n // Skip constructors that share the class name to avoid duplicate IDs\n if (child.kind === 'function' && child.name === sym.name) continue;\n convertSymbol(child, symId, nodes, rels, stats);\n }\n } else {\n stats.functionsExtracted++;\n }\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Per-language import analysis using tree-sitter ASTs.\n * Ported from agent/src/opentrace_agent/sources/code/import_analyzer.py\n *\n * Parses import statements from already-parsed source files and maps local\n * aliases to repo-relative file paths (internal) or package IDs (external).\n */\n\nimport type { Node as SyntaxNode } from 'web-tree-sitter';\nimport { npmPackageName, normalizePyName, packageId } from './manifestParser';\n\n/** Result of import analysis for a single file. */\nexport interface ImportAnalysisResult {\n /** Internal imports: alias → repo-relative file path (existing behavior). */\n internal: Record<string, string>;\n /** External imports: package name → deterministic package ID (pkg:registry:name). */\n external: Record<string, string>;\n}\n\n// --- Python imports ---\n\nexport function analyzePythonImports(\n rootNode: SyntaxNode,\n filePath: string,\n knownFiles: Set<string>,\n): ImportAnalysisResult {\n const internal: Record<string, string> = {};\n const external: Record<string, string> = {};\n const fileDir = parentDir(filePath);\n\n for (const child of rootNode.children) {\n if (child.type === 'import_statement') {\n parsePythonImport(child, knownFiles, internal, external);\n } else if (child.type === 'import_from_statement') {\n parsePythonFromImport(child, fileDir, knownFiles, internal, external);\n }\n }\n return { internal, external };\n}\n\nfunction parsePythonImport(\n node: SyntaxNode,\n knownFiles: Set<string>,\n internal: Record<string, string>,\n external: Record<string, string>,\n): void {\n for (const child of node.children) {\n if (child.type === 'dotted_name') {\n const moduleName = child.text;\n const candidates = moduleToPaths(moduleName);\n let found = false;\n for (const candidate of candidates) {\n if (knownFiles.has(candidate)) {\n const parts = moduleName.split('.');\n internal[parts[parts.length - 1]] = candidate;\n found = true;\n break;\n }\n }\n if (!found) {\n const topLevel = moduleName.split('.')[0];\n const name = normalizePyName(topLevel);\n external[name] = packageId('pypi', name);\n }\n } else if (child.type === 'aliased_import') {\n const nameNode = child.childForFieldName('name');\n const aliasNode = child.childForFieldName('alias');\n if (nameNode && aliasNode) {\n const moduleName = nameNode.text;\n const alias = aliasNode.text;\n const candidates = moduleToPaths(moduleName);\n let found = false;\n for (const candidate of candidates) {\n if (knownFiles.has(candidate)) {\n internal[alias] = candidate;\n found = true;\n break;\n }\n }\n if (!found) {\n const topLevel = moduleName.split('.')[0];\n const name = normalizePyName(topLevel);\n external[name] = packageId('pypi', name);\n }\n }\n }\n }\n}\n\nfunction parsePythonFromImport(\n node: SyntaxNode,\n fileDir: string,\n knownFiles: Set<string>,\n internal: Record<string, string>,\n external: Record<string, string>,\n): void {\n const moduleNameNode = node.childForFieldName('module_name');\n if (!moduleNameNode) return;\n\n let moduleText = moduleNameNode.text;\n let isRelative = false;\n let baseDir = fileDir;\n\n for (const child of node.children) {\n if (child.type === 'relative_import') {\n isRelative = true;\n for (const sub of child.children) {\n if (sub.type === 'dotted_name') {\n moduleText = sub.text;\n } else if (sub.type === 'import_prefix') {\n const dots = sub.text;\n baseDir = fileDir;\n for (let i = 0; i < dots.length - 1; i++) {\n baseDir = parentDir(baseDir);\n }\n if (\n moduleText === moduleNameNode.text &&\n moduleText.startsWith('.')\n ) {\n moduleText = '';\n }\n }\n }\n break;\n }\n }\n\n let candidates: string[];\n if (isRelative) {\n const basePath = moduleText\n ? baseDir\n ? `${baseDir}/${moduleText.replace(/\\./g, '/')}`\n : moduleText.replace(/\\./g, '/')\n : baseDir;\n candidates = [`${basePath}.py`, `${basePath}/__init__.py`];\n } else {\n candidates = moduleToPaths(moduleText);\n }\n\n let found = false;\n let resolvedPath: string | null = null;\n for (const candidate of candidates) {\n if (knownFiles.has(candidate)) {\n const alias = moduleText ? moduleText.split('.').pop()! : '';\n if (alias) {\n internal[alias] = candidate;\n }\n resolvedPath = candidate;\n found = true;\n break;\n }\n }\n\n // Store individual imported symbol names from `from X import Y, Z`\n if (resolvedPath) {\n for (const child of node.children) {\n if (\n child.type === 'dotted_name' &&\n child !== node.childForFieldName('module_name')\n ) {\n // Bare imported name: `from X import Y`\n internal[child.text] = resolvedPath;\n } else if (child.type === 'aliased_import') {\n // `from X import Y as Z` — store the alias\n const nameNode = child.childForFieldName('name');\n const aliasNode = child.childForFieldName('alias');\n if (aliasNode) {\n internal[aliasNode.text] = resolvedPath;\n } else if (nameNode) {\n internal[nameNode.text] = resolvedPath;\n }\n }\n }\n }\n\n // Only track external for absolute (non-relative) imports that didn't resolve\n if (!found && !isRelative && moduleText) {\n const topLevel = moduleText.split('.')[0];\n const name = normalizePyName(topLevel);\n external[name] = packageId('pypi', name);\n }\n}\n\n// --- Go imports ---\n\n/**\n * Pre-compute directory → file index for O(1) Go import resolution.\n * Maps full directory paths and their suffixes to a representative file.\n */\nfunction buildDirIndex(knownFiles: Set<string>): Map<string, string> {\n const index = new Map<string, string>();\n // Track all dirs per basename to detect ambiguity\n const baseDirs = new Map<string, Set<string>>();\n for (const filePath of knownFiles) {\n // Only index .go files — non-code files shouldn't create false Go package matches\n if (!filePath.endsWith('.go')) continue;\n const dir = parentDir(filePath);\n if (!dir) continue;\n // Store full dir path\n if (!index.has(dir)) index.set(dir, filePath);\n // Collect dirs per basename for ambiguity check\n const dirBase = dir.split('/').pop()!;\n let dirs = baseDirs.get(dirBase);\n if (!dirs) {\n dirs = new Set();\n baseDirs.set(dirBase, dirs);\n }\n dirs.add(dir);\n }\n // Only store dirBase shortcut when exactly one directory has that name\n for (const [dirBase, dirs] of baseDirs) {\n if (dirs.size === 1) {\n const dir = dirs.values().next().value!;\n index.set(dirBase, index.get(dir)!);\n }\n }\n return index;\n}\n\n// Cache the dir index — knownFiles doesn't change between calls\nlet cachedDirIndex: Map<string, string> | null = null;\nlet cachedDirIndexSource: Set<string> | null = null;\n\nfunction getDirIndex(knownFiles: Set<string>): Map<string, string> {\n if (cachedDirIndex && cachedDirIndexSource === knownFiles) {\n return cachedDirIndex;\n }\n cachedDirIndex = buildDirIndex(knownFiles);\n cachedDirIndexSource = knownFiles;\n return cachedDirIndex;\n}\n\n/** Reset the module-level dir index cache. Call in tests to prevent cross-test pollution. */\nexport function resetDirIndexCache(): void {\n cachedDirIndex = null;\n cachedDirIndexSource = null;\n}\n\nexport function analyzeGoImports(\n rootNode: SyntaxNode,\n knownFiles: Set<string>,\n modulePath?: string,\n): ImportAnalysisResult {\n const internal: Record<string, string> = {};\n const external: Record<string, string> = {};\n const dirIndex = getDirIndex(knownFiles);\n\n for (const child of rootNode.children) {\n if (child.type === 'import_declaration') {\n parseGoImportDecl(child, dirIndex, internal, external, modulePath);\n }\n }\n return { internal, external };\n}\n\nfunction parseGoImportDecl(\n node: SyntaxNode,\n dirIndex: Map<string, string>,\n internal: Record<string, string>,\n external: Record<string, string>,\n modulePath?: string,\n): void {\n for (const child of node.children) {\n if (child.type === 'import_spec') {\n parseGoImportSpec(child, dirIndex, internal, external, modulePath);\n } else if (child.type === 'import_spec_list') {\n for (const spec of child.children) {\n if (spec.type === 'import_spec') {\n parseGoImportSpec(spec, dirIndex, internal, external, modulePath);\n }\n }\n }\n }\n}\n\nfunction parseGoImportSpec(\n node: SyntaxNode,\n dirIndex: Map<string, string>,\n internal: Record<string, string>,\n external: Record<string, string>,\n modulePath?: string,\n): void {\n const pathNode = node.childForFieldName('path');\n const nameNode = node.childForFieldName('name');\n if (!pathNode) return;\n\n const importPath = pathNode.text.replace(/^[\"']|[\"']$/g, '');\n\n // Skip stdlib (no dot in first segment — stdlib packages like \"fmt\", \"net/http\")\n if (!importPath.includes('.')) return;\n\n let alias: string;\n if (nameNode) {\n alias = nameNode.text;\n if (alias === '_' || alias === '.') return;\n } else {\n alias = importPath.split('/').pop()!;\n }\n\n // Try to resolve as internal file via O(1) directory index lookup\n // Priority: full import path → modulePath-stripped repo-relative → bare dirBase shortcut\n const fullMatch = dirIndex.get(importPath);\n if (fullMatch) {\n internal[alias] = fullMatch;\n return;\n }\n\n // Strip modulePath prefix to get repo-relative dir (e.g. \"github.com/org/app/internal/graph\" → \"internal/graph\")\n if (modulePath && importPath.startsWith(modulePath + '/')) {\n const repoRelDir = importPath.slice(modulePath.length + 1);\n const relMatch = dirIndex.get(repoRelDir);\n if (relMatch) {\n internal[alias] = relMatch;\n return;\n }\n }\n\n // Fall back to bare package name (only works when unambiguous)\n const pkgName = importPath.split('/').pop()!;\n const baseMatch = dirIndex.get(pkgName);\n if (baseMatch) {\n internal[alias] = baseMatch;\n return;\n }\n\n // If not internal and doesn't match our module path, it's external\n const isOwnModule = modulePath && importPath.startsWith(modulePath);\n if (!isOwnModule) {\n const goModuleName = goModuleRoot(importPath);\n external[goModuleName] = packageId('go', goModuleName);\n }\n}\n\n/**\n * Extract Go module root from an import path.\n * For well-known hosts (github.com, gitlab.com, etc.), take first 3 segments.\n * For others, take the full path (it might be the module itself).\n */\nfunction goModuleRoot(importPath: string): string {\n const parts = importPath.split('/');\n const host = parts[0];\n\n // Well-known hosting: github.com/owner/repo, gitlab.com/owner/repo, etc.\n if (\n host === 'github.com' ||\n host === 'gitlab.com' ||\n host === 'bitbucket.org' ||\n host === 'golang.org' ||\n host === 'google.golang.org' ||\n host === 'gopkg.in'\n ) {\n return parts.slice(0, 3).join('/');\n }\n\n // For vanity imports and others, take up to 3 segments as a reasonable default\n return parts.length >= 3 ? parts.slice(0, 3).join('/') : importPath;\n}\n\n// --- TypeScript imports ---\n\nexport function analyzeTypeScriptImports(\n rootNode: SyntaxNode,\n filePath: string,\n knownFiles: Set<string>,\n): ImportAnalysisResult {\n const internal: Record<string, string> = {};\n const external: Record<string, string> = {};\n const fileDir = parentDir(filePath);\n\n for (const child of rootNode.children) {\n if (child.type === 'import_statement') {\n parseTsImport(child, fileDir, knownFiles, internal, external);\n } else if (child.type === 'export_statement') {\n parseTsReexport(child, fileDir, knownFiles, internal, external);\n }\n }\n return { internal, external };\n}\n\nfunction parseTsImport(\n node: SyntaxNode,\n fileDir: string,\n knownFiles: Set<string>,\n internal: Record<string, string>,\n external: Record<string, string>,\n): void {\n const sourceNode = node.childForFieldName('source');\n if (!sourceNode) return;\n\n const sourceText = sourceNode.text.replace(/^[\"']|[\"']$/g, '');\n\n // Non-relative import → external package\n if (!sourceText.startsWith('.')) {\n const pkgName = npmPackageName(sourceText);\n external[pkgName] = packageId('npm', pkgName);\n return;\n }\n\n const resolved = resolveRelativePath(fileDir, sourceText);\n const extensions = [\n '',\n '.ts',\n '.tsx',\n '.js',\n '.jsx',\n '/index.ts',\n '/index.tsx',\n '/index.js',\n ];\n for (const ext of extensions) {\n const candidate = resolved + ext;\n if (knownFiles.has(candidate)) {\n const alias = sourceText.split('/').pop()!;\n internal[alias] = candidate;\n break;\n }\n }\n}\n\nfunction parseTsReexport(\n node: SyntaxNode,\n fileDir: string,\n knownFiles: Set<string>,\n internal: Record<string, string>,\n external: Record<string, string>,\n): void {\n const sourceNode = node.childForFieldName('source');\n if (!sourceNode) return; // Bare export (e.g. `export class Foo {}`), not a re-export\n\n const sourceText = sourceNode.text.replace(/^[\"']|[\"']$/g, '');\n\n // Non-relative re-export → external package\n if (!sourceText.startsWith('.')) {\n const pkgName = npmPackageName(sourceText);\n external[pkgName] = packageId('npm', pkgName);\n return;\n }\n\n const resolved = resolveRelativePath(fileDir, sourceText);\n const extensions = [\n '',\n '.ts',\n '.tsx',\n '.js',\n '.jsx',\n '/index.ts',\n '/index.tsx',\n '/index.js',\n ];\n for (const ext of extensions) {\n const candidate = resolved + ext;\n if (knownFiles.has(candidate)) {\n const alias = sourceText.split('/').pop()!;\n internal[alias] = candidate;\n break;\n }\n }\n}\n\n// --- Rust imports ---\n\nexport function analyzeRustImports(\n rootNode: SyntaxNode,\n filePath: string,\n knownFiles: Set<string>,\n): ImportAnalysisResult {\n const internal: Record<string, string> = {};\n const external: Record<string, string> = {};\n const fileDir = parentDir(filePath);\n\n for (const child of rootNode.children) {\n if (child.type === 'mod_item') {\n // `mod foo;` → maps to foo.rs or foo/mod.rs\n const nameNode = child.childForFieldName('name');\n if (!nameNode) continue;\n // Only external mod declarations (with `;`), not inline `mod foo { ... }`\n const hasBody = child.children.some((c) => c.type === 'declaration_list');\n if (hasBody) continue;\n\n const modName = nameNode.text;\n const candidates = [\n fileDir ? `${fileDir}/${modName}.rs` : `${modName}.rs`,\n fileDir ? `${fileDir}/${modName}/mod.rs` : `${modName}/mod.rs`,\n ];\n let found = false;\n for (const candidate of candidates) {\n if (knownFiles.has(candidate)) {\n internal[modName] = candidate;\n found = true;\n break;\n }\n }\n if (!found) {\n // Could be an external crate re-exported via mod\n external[modName] = packageId('crates', modName);\n }\n } else if (child.type === 'use_declaration') {\n parseRustUseDecl(child, fileDir, knownFiles, internal, external);\n }\n }\n return { internal, external };\n}\n\nfunction parseRustUseDecl(\n node: SyntaxNode,\n fileDir: string,\n knownFiles: Set<string>,\n internal: Record<string, string>,\n external: Record<string, string>,\n): void {\n // Extract the root crate/module name from use declarations\n for (const child of node.children) {\n if (child.type === 'scoped_identifier') {\n // `use foo::bar` — root is first identifier\n const parts = child.text.split('::');\n const root = parts[0];\n resolveRustRoot(root, fileDir, knownFiles, internal, external);\n } else if (child.type === 'scoped_use_list') {\n // `use foo::{bar, baz}` — root is the identifier before ::\n for (const sub of child.children) {\n if (sub.type === 'identifier' || sub.type === 'scoped_identifier') {\n const root = sub.text.split('::')[0];\n resolveRustRoot(root, fileDir, knownFiles, internal, external);\n break;\n }\n }\n } else if (child.type === 'identifier') {\n // `use foo;` — bare use\n resolveRustRoot(child.text, fileDir, knownFiles, internal, external);\n }\n }\n}\n\nfunction resolveRustRoot(\n root: string,\n fileDir: string,\n knownFiles: Set<string>,\n internal: Record<string, string>,\n external: Record<string, string>,\n): void {\n // Skip Rust built-ins\n if (\n root === 'std' ||\n root === 'core' ||\n root === 'alloc' ||\n root === 'self' ||\n root === 'super' ||\n root === 'crate'\n ) {\n return;\n }\n\n // Check if this maps to a known file (sibling module)\n if (!internal[root]) {\n const candidates = [\n fileDir ? `${fileDir}/${root}.rs` : `${root}.rs`,\n fileDir ? `${fileDir}/${root}/mod.rs` : `${root}/mod.rs`,\n `src/${root}.rs`,\n `src/${root}/mod.rs`,\n ];\n for (const candidate of candidates) {\n if (knownFiles.has(candidate)) {\n internal[root] = candidate;\n return;\n }\n }\n // External crate\n external[root] = packageId('crates', root);\n }\n}\n\n// --- Ruby imports ---\n\nexport function analyzeRubyImports(\n rootNode: SyntaxNode,\n filePath: string,\n knownFiles: Set<string>,\n): ImportAnalysisResult {\n const internal: Record<string, string> = {};\n const external: Record<string, string> = {};\n const fileDir = parentDir(filePath);\n\n for (const child of rootNode.children) {\n if (child.type === 'call') {\n const funcNode = child.children[0];\n if (!funcNode || funcNode.type !== 'identifier') continue;\n const funcName = funcNode.text;\n\n if (funcName === 'require_relative') {\n const argNode =\n child.childForFieldName('arguments') ??\n child.children.find((c) => c.type === 'argument_list');\n if (!argNode) continue;\n const strNode = argNode.children.find((c) => c.type === 'string');\n if (!strNode) continue;\n const contentNode = strNode.children.find(\n (c) => c.type === 'string_content',\n );\n if (!contentNode) continue;\n\n const requirePath = contentNode.text;\n const resolved = resolveRelativePath(fileDir, requirePath);\n const candidates = [`${resolved}.rb`, resolved, `${resolved}/index.rb`];\n for (const candidate of candidates) {\n if (knownFiles.has(candidate)) {\n const alias = requirePath.split('/').pop()!;\n internal[alias] = candidate;\n break;\n }\n }\n } else if (funcName === 'require') {\n const argNode =\n child.childForFieldName('arguments') ??\n child.children.find((c) => c.type === 'argument_list');\n if (!argNode) continue;\n const strNode = argNode.children.find((c) => c.type === 'string');\n if (!strNode) continue;\n const contentNode = strNode.children.find(\n (c) => c.type === 'string_content',\n );\n if (!contentNode) continue;\n\n const gemName = contentNode.text;\n // Check if it resolves to a local file first\n const candidates = [\n `${gemName}.rb`,\n `lib/${gemName}.rb`,\n `${gemName}/init.rb`,\n ];\n let found = false;\n for (const candidate of candidates) {\n if (knownFiles.has(candidate)) {\n internal[gemName] = candidate;\n found = true;\n break;\n }\n }\n if (!found) {\n const name = gemName.split('/')[0];\n external[name] = packageId('rubygems', name);\n }\n }\n }\n }\n return { internal, external };\n}\n\n// --- Path utilities ---\n\nfunction parentDir(path: string): string {\n const parts = path.split('/');\n return parts.length > 1 ? parts.slice(0, -1).join('/') : '';\n}\n\nfunction moduleToPaths(moduleName: string): string[] {\n const path = moduleName.replace(/\\./g, '/');\n return [`${path}.py`, `${path}/__init__.py`];\n}\n\nfunction resolveRelativePath(baseDir: string, relative: string): string {\n const parts = relative.split('/');\n const baseParts = baseDir ? baseDir.split('/') : [];\n\n for (const part of parts) {\n if (part === '.') continue;\n else if (part === '..') {\n if (baseParts.length > 0) baseParts.pop();\n } else {\n baseParts.push(part);\n }\n }\n return baseParts.join('/');\n}\n\n/** Dispatch to the correct language-specific analyzer. */\nexport function analyzeImports(\n rootNode: SyntaxNode,\n language: string,\n filePath: string,\n knownPaths: Set<string>,\n modulePath?: string,\n): ImportAnalysisResult {\n switch (language) {\n case 'python':\n return analyzePythonImports(rootNode, filePath, knownPaths);\n case 'go':\n return analyzeGoImports(rootNode, knownPaths, modulePath);\n case 'typescript':\n case 'javascript':\n return analyzeTypeScriptImports(rootNode, filePath, knownPaths);\n case 'rust':\n return analyzeRustImports(rootNode, filePath, knownPaths);\n case 'ruby':\n return analyzeRubyImports(rootNode, filePath, knownPaths);\n default:\n return { internal: {}, external: {} };\n }\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Processing stage: per-file parsing + symbol extraction + import analysis.\n *\n * For each parseable file:\n * 1. Parse with tree-sitter\n * 2. Extract symbols → Class/Function nodes + DEFINED_IN rels\n * 3. Populate registries + allCallInfo\n * 4. Analyze imports → IMPORTS rels + Package nodes\n * 5. Yield per-file nodes/rels as stage_progress\n *\n * rootNode is used immediately and discarded (no Map accumulation).\n */\n\nimport type {\n ExtractionResult,\n GraphNode,\n GraphRelationship,\n ScanResult,\n ProcessingOutput,\n PipelineContext,\n PipelineEvent,\n} from '../types';\nimport { detectLanguage, getExtension } from './loading';\nimport {\n getExtractor,\n getParserForLanguage,\n processSymbol,\n countSymbols,\n} from './parsing';\nimport { analyzeImports } from '../parser/importAnalyzer';\nimport type { Registries, CallInfo } from '../parser/callResolver';\n\nexport function* execute(\n input: ScanResult,\n ctx: PipelineContext,\n): Generator<PipelineEvent, ProcessingOutput> {\n const { parseableFiles, repoId, knownPaths, pathToFileId, goModulePath } =\n input;\n const total = parseableFiles.length;\n\n yield {\n kind: 'stage_start',\n phase: 'processing',\n message: `Processing ${total} files`,\n };\n\n // Initialize registries\n const registries: Registries = {\n nameRegistry: new Map(),\n fileRegistry: new Map(),\n classRegistry: new Map(),\n importRegistry: new Map(),\n };\n const allCallInfo: CallInfo[] = [];\n const emittedNodeIds = new Set<string>();\n\n // Copy package nodes from scanning (will accumulate more from imports)\n const packageNodes = new Map(input.packageNodes);\n\n const structureNodes: GraphNode[] = [\n input.repoNode,\n ...input.dirNodes.values(),\n ...input.fileNodes,\n ...input.packageNodes.values(),\n ];\n let totalNodes = structureNodes.length;\n let totalRels = input.structureRels.length + input.dependencyRels.length;\n let filesProcessed = 0;\n let classesExtracted = 0;\n let functionsExtracted = 0;\n const errors: string[] = [];\n\n for (let i = 0; i < parseableFiles.length; i++) {\n if (ctx.cancelled) break;\n\n const file = parseableFiles[i];\n const ext = getExtension(file.path);\n const language = detectLanguage(ext);\n const fileId = `${repoId}/${file.path}`;\n\n if (!language) {\n filesProcessed++;\n continue;\n }\n\n const parser = getParserForLanguage(language, ext);\n const extractor = getExtractor(language);\n\n if (!parser || !extractor) {\n filesProcessed++;\n yield {\n kind: 'stage_progress',\n phase: 'processing',\n message: `Processing ${file.path}`,\n detail: { current: i + 1, total, fileName: file.path },\n };\n continue;\n }\n\n let extraction: ExtractionResult | null = null;\n const nodes: GraphNode[] = [];\n const rels: GraphRelationship[] = [];\n\n try {\n const tree = parser.parse(file.content);\n if (!tree) {\n errors.push(`${file.path}: parse returned null`);\n } else {\n extraction = extractor(tree.rootNode);\n\n // Initialize file registry entry\n registries.fileRegistry.set(fileId, new Map());\n\n // Process symbols → graph nodes + registries\n for (const sym of extraction.symbols) {\n processSymbol(\n sym,\n fileId,\n language,\n registries,\n allCallInfo,\n nodes,\n rels,\n emittedNodeIds,\n );\n }\n const symCounts = countSymbols(extraction.symbols);\n classesExtracted += symCounts.classes;\n functionsExtracted += symCounts.functions;\n\n // Import analysis — uses rootNode immediately, then discards it\n const rootNode = extraction.rootNode;\n if (rootNode) {\n const importResult = analyzeImports(\n rootNode,\n language,\n file.path,\n knownPaths,\n goModulePath,\n );\n\n // Internal imports → populate importRegistry + IMPORTS edges\n const fileImports: Record<string, string> = {};\n const seenTargetFiles = new Set<string>();\n for (const [alias, targetPath] of Object.entries(\n importResult.internal,\n )) {\n const targetFileId = pathToFileId.get(targetPath);\n if (targetFileId) {\n fileImports[alias] = targetFileId;\n if (!seenTargetFiles.has(targetFileId)) {\n seenTargetFiles.add(targetFileId);\n rels.push({\n id: `${fileId}->IMPORTS->${targetFileId}`,\n type: 'IMPORTS',\n source_id: fileId,\n target_id: targetFileId,\n });\n }\n }\n }\n registries.importRegistry.set(fileId, fileImports);\n\n // External imports → IMPORTS rels + new Package nodes\n for (const [pkgName, pkgId] of Object.entries(\n importResult.external,\n )) {\n if (!packageNodes.has(pkgId)) {\n const pkgNode: GraphNode = {\n id: pkgId,\n type: 'Package',\n name: pkgName,\n properties: { registry: pkgId.split(':')[1] },\n };\n packageNodes.set(pkgId, pkgNode);\n nodes.push(pkgNode);\n }\n\n rels.push({\n id: `${fileId}->IMPORTS->${pkgId}`,\n type: 'IMPORTS',\n source_id: fileId,\n target_id: pkgId,\n });\n }\n }\n // rootNode is not stored — used above and now eligible for GC\n }\n } catch (err) {\n errors.push(\n `${file.path}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n\n totalNodes += nodes.length;\n totalRels += rels.length;\n filesProcessed++;\n\n yield {\n kind: 'stage_progress',\n phase: 'processing',\n message: `Processing ${file.path}`,\n detail: { current: i + 1, total, fileName: file.path },\n nodes: nodes.length > 0 ? nodes : undefined,\n relationships: rels.length > 0 ? rels : undefined,\n };\n }\n\n yield {\n kind: 'stage_stop',\n phase: 'processing',\n message: `Processed ${filesProcessed} files`,\n errors: errors.length > 0 ? errors : undefined,\n };\n\n return {\n scanResult: input,\n registries,\n allCallInfo,\n packageNodes,\n stats: {\n nodesCreated: totalNodes,\n relationshipsCreated: totalRels,\n filesProcessed,\n classesExtracted,\n functionsExtracted,\n },\n };\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * 7-strategy call resolution for resolving CallRef → target node.\n * Ported from agent/src/opentrace_agent/sources/code/symbol_attacher.py _resolve_calls/_resolve_single_call\n *\n * Resolution priority:\n * 1. self/this → enclosing class children\n * 2. Go receiver var → methods with matching receiver_type\n * 3. ClassName.method() → class_registry lookup\n * 4. Import-based resolution → alias maps to target file\n * 5. Constructor call → bare name matches class\n * 6. Intra-file bare call\n * 7. Cross-file bare call with unique match\n */\n\nimport type { CallRef, GraphRelationship } from '../types';\n\n/** Internal node representation for resolution (before converting to graph nodes). */\nexport interface SymbolNode {\n id: string;\n name: string;\n kind: 'class' | 'function';\n fileId: string;\n parentId: string;\n receiverVar: string | null;\n receiverType: string | null;\n paramTypes: Record<string, string> | null;\n children: SymbolNode[];\n}\n\n/** Registries populated during Phase 1 (extraction). */\nexport interface Registries {\n /** name → all nodes with that name */\n nameRegistry: Map<string, SymbolNode[]>;\n /** fileId → { symbolName → node } */\n fileRegistry: Map<string, Map<string, SymbolNode>>;\n /** className → class nodes (multiple classes can share a name across files) */\n classRegistry: Map<string, SymbolNode[]>;\n /** fileId → { alias → targetFileId } */\n importRegistry: Map<string, Record<string, string>>;\n}\n\nexport interface CallInfo {\n callerNode: SymbolNode;\n calls: CallRef[];\n fileId: string;\n}\n\nexport interface ResolvedCall {\n sourceId: string;\n targetId: string;\n confidence: number;\n}\n\n/** Resolve all collected calls and return relationships. */\nexport function resolveCalls(\n callInfos: CallInfo[],\n registries: Registries,\n): ResolvedCall[] {\n const results: ResolvedCall[] = [];\n\n for (const { callerNode, calls, fileId } of callInfos) {\n const seen = new Set<string>();\n\n for (const ref of calls) {\n const dedupKey = `${ref.receiver ?? ''}:${ref.name}`;\n if (seen.has(dedupKey)) continue;\n // Skip self-recursive calls\n if (ref.name === callerNode.name && ref.receiver === null) continue;\n\n const resolved = resolveSingleCall(ref, callerNode, fileId, registries);\n if (!resolved) continue;\n\n seen.add(dedupKey);\n results.push({\n sourceId: callerNode.id,\n targetId: resolved.targetId,\n confidence: resolved.confidence,\n });\n }\n }\n\n return results;\n}\n\nfunction resolveSingleCall(\n ref: CallRef,\n callerNode: SymbolNode,\n fileId: string,\n registries: Registries,\n): { targetId: string; confidence: number } | null {\n const { nameRegistry, fileRegistry, classRegistry, importRegistry } =\n registries;\n\n // Strategy 1: self/this resolution\n if (\n ref.kind === 'attribute' &&\n (ref.receiver === 'self' || ref.receiver === 'this')\n ) {\n const classNode = findEnclosingClass(callerNode, classRegistry);\n if (classNode) {\n for (const child of classNode.children) {\n if (child.name === ref.name) {\n return { targetId: child.id, confidence: 1.0 };\n }\n }\n }\n return null;\n }\n\n // Strategy 2: Go receiver variable resolution\n if (ref.kind === 'attribute') {\n if (\n callerNode.receiverVar &&\n ref.receiver === callerNode.receiverVar &&\n callerNode.receiverType\n ) {\n const candidates = nameRegistry.get(ref.name) ?? [];\n for (const candidate of candidates) {\n if (candidate.receiverType === callerNode.receiverType) {\n return { targetId: candidate.id, confidence: 1.0 };\n }\n }\n }\n }\n\n // Strategy 2.5: Parameter type hint resolution (param.method() where param has a known type)\n if (ref.kind === 'attribute' && ref.receiver && callerNode.paramTypes) {\n const typeName = callerNode.paramTypes[ref.receiver];\n if (typeName && classRegistry.has(typeName)) {\n const classCandidates = classRegistry.get(typeName)!;\n for (const cls of classCandidates) {\n for (const child of cls.children) {\n if (child.name === ref.name) {\n return { targetId: child.id, confidence: 0.7 };\n }\n }\n }\n }\n }\n\n // Strategy 3: ClassName.method() resolution\n if (\n ref.kind === 'attribute' &&\n ref.receiver &&\n classRegistry.has(ref.receiver)\n ) {\n const classCandidates = classRegistry.get(ref.receiver)!;\n // Prefer same-file class, then fall back to any\n const sorted = [...classCandidates].sort(\n (a, b) => (a.fileId === fileId ? 0 : 1) - (b.fileId === fileId ? 0 : 1),\n );\n for (const cls of sorted) {\n for (const child of cls.children) {\n if (child.name === ref.name) {\n const targetFileId = child.id.split('::')[0];\n const conf = targetFileId === fileId ? 1.0 : 0.9;\n return { targetId: child.id, confidence: conf };\n }\n }\n }\n // Also check Go-style methods (not class children but have matching receiver_type)\n const candidates = nameRegistry.get(ref.name) ?? [];\n for (const candidate of candidates) {\n if (candidate.receiverType === ref.receiver) {\n const targetFileId = candidate.id.split('::')[0];\n const conf = targetFileId === fileId ? 1.0 : 0.9;\n return { targetId: candidate.id, confidence: conf };\n }\n }\n return null;\n }\n\n // Strategy 4: Import-based resolution\n if (ref.kind === 'attribute' && ref.receiver) {\n const fileImports = importRegistry.get(fileId);\n if (fileImports) {\n const targetFileId = fileImports[ref.receiver];\n if (targetFileId) {\n const targetNames = fileRegistry.get(targetFileId);\n if (targetNames) {\n const target = targetNames.get(ref.name);\n if (target) {\n return { targetId: target.id, confidence: 0.9 };\n }\n }\n }\n }\n }\n\n // Strategy 4.5: Import-based bare call resolution (from X import Y → Y())\n if (ref.kind === 'bare') {\n const fileImports = importRegistry.get(fileId);\n if (fileImports) {\n const targetFileId = fileImports[ref.name];\n if (targetFileId) {\n const targetNames = fileRegistry.get(targetFileId);\n if (targetNames) {\n const target = targetNames.get(ref.name);\n if (target) {\n // If it's a class, prefer its __init__/constructor\n if (target.kind === 'class') {\n for (const child of target.children) {\n if (child.name === '__init__' || child.name === 'constructor') {\n return { targetId: child.id, confidence: 0.9 };\n }\n }\n }\n return { targetId: target.id, confidence: 0.9 };\n }\n }\n }\n }\n }\n\n // Strategy 5: Constructor call — bare name matches a class\n if (ref.kind === 'bare' && classRegistry.has(ref.name)) {\n const classCandidates = classRegistry.get(ref.name)!;\n // Prefer same-file class, then fall back to any\n const sorted = [...classCandidates].sort(\n (a, b) => (a.fileId === fileId ? 0 : 1) - (b.fileId === fileId ? 0 : 1),\n );\n for (const cls of sorted) {\n // Try to find __init__ or constructor child\n for (const child of cls.children) {\n if (child.name === '__init__' || child.name === 'constructor') {\n const targetFileId = child.id.split('::')[0];\n const conf = targetFileId === fileId ? 1.0 : 0.8;\n return { targetId: child.id, confidence: conf };\n }\n }\n }\n // Fall back to the class node itself (prefer same-file)\n const cls = sorted[0];\n const targetFileId = cls.id.split('::')[0];\n const conf = targetFileId === fileId ? 1.0 : 0.8;\n return { targetId: cls.id, confidence: conf };\n }\n\n // Strategy 6: Intra-file bare call\n if (ref.kind === 'bare') {\n const fileNames = fileRegistry.get(fileId);\n if (fileNames) {\n const target = fileNames.get(ref.name);\n if (target) {\n return { targetId: target.id, confidence: 1.0 };\n }\n }\n }\n\n // Strategy 7: Cross-file bare call (unique match only)\n if (ref.kind === 'bare') {\n const candidates = nameRegistry.get(ref.name) ?? [];\n const crossFile = candidates.filter((c) => c.id.split('::')[0] !== fileId);\n if (crossFile.length === 1) {\n return { targetId: crossFile[0].id, confidence: 0.8 };\n }\n }\n\n return null;\n}\n\nfunction findEnclosingClass(\n node: SymbolNode,\n classRegistry: Map<string, SymbolNode[]>,\n): SymbolNode | null {\n // Walk up the ID to find the class — IDs are structured as fileId::ClassName::methodName\n const parts = node.id.split('::');\n // Try progressively shorter prefixes to find a class\n for (let i = parts.length - 1; i >= 1; i--) {\n const potentialClassName = parts[i];\n const candidates = classRegistry.get(potentialClassName);\n if (candidates) {\n for (const cls of candidates) {\n // Verify this class is actually an ancestor (its ID is a prefix of node's ID)\n if (node.id.startsWith(cls.id + '::')) {\n return cls;\n }\n }\n }\n }\n return null;\n}\n\n/** Convert resolved calls into GraphRelationship objects. */\nexport function resolvedCallsToRelationships(\n resolvedCalls: ResolvedCall[],\n): GraphRelationship[] {\n return resolvedCalls.map((call) => ({\n id: `${call.sourceId}->CALLS->${call.targetId}`,\n type: 'CALLS',\n source_id: call.sourceId,\n target_id: call.targetId,\n properties: { confidence: call.confidence },\n }));\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Resolving stage: call resolution.\n *\n * Import analysis has already been performed per-file in the processing stage.\n * This stage only resolves calls using the 7-strategy resolver.\n *\n * Produces CALLS relationships.\n */\n\nimport type { ProcessingOutput, PipelineEvent, PipelineResult } from '../types';\nimport {\n resolveCalls,\n resolvedCallsToRelationships,\n} from '../parser/callResolver';\n\nexport function* execute(\n input: ProcessingOutput,\n): Generator<PipelineEvent, PipelineResult> {\n const { registries, allCallInfo, stats } = input;\n\n yield {\n kind: 'stage_start',\n phase: 'resolving',\n message: `Resolving ${allCallInfo.length} call sites`,\n };\n\n const resolvedCalls = resolveCalls(allCallInfo, registries);\n const callRels = resolvedCallsToRelationships(resolvedCalls);\n\n if (callRels.length > 0) {\n yield {\n kind: 'stage_progress',\n phase: 'resolving',\n message: `Resolved ${callRels.length} calls`,\n relationships: callRels,\n };\n }\n\n yield {\n kind: 'stage_stop',\n phase: 'resolving',\n message: `Resolved ${callRels.length} calls`,\n };\n\n return {\n nodesCreated: stats.nodesCreated,\n relationshipsCreated: stats.relationshipsCreated + callRels.length,\n filesProcessed: stats.filesProcessed,\n classesExtracted: stats.classesExtracted,\n functionsExtracted: stats.functionsExtracted,\n };\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PipelineEvent, Store } from '../types';\n\n/**\n * Wraps an inner event generator, saving graph data to the store\n * as graph_ready events flow through. All events are re-yielded unchanged.\n */\nexport function* execute(\n inner: Generator<PipelineEvent>,\n store: Store,\n): Generator<PipelineEvent> {\n let nodesSaved = 0;\n let relsSaved = 0;\n\n for (const event of inner) {\n if (event.nodes) {\n for (const node of event.nodes) {\n store.saveNode(node);\n }\n nodesSaved += event.nodes.length;\n }\n if (event.relationships) {\n for (const rel of event.relationships) {\n store.saveRelationship(rel);\n }\n relsSaved += event.relationships.length;\n }\n yield event;\n }\n\n yield {\n kind: 'stage_stop',\n phase: 'submitting',\n message: `Saved ${nodesSaved} nodes and ${relsSaved} relationships`,\n };\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Template-based code summarizer — generates semantic summaries from identifier\n * names and structural metadata, with no ML inference.\n *\n * Function/class names are already semantic (`toCamelCase`, `validateEmail`).\n * A name analyzer that splits identifiers and maps verb prefixes to descriptions\n * produces quality summaries instantly — <100ms for 10k nodes.\n */\n\nimport type { Summarizer, NodeKind, SymbolMetadata } from './types';\n\n// ---------------------------------------------------------------------------\n// Verb prefix → description mapping\n// ---------------------------------------------------------------------------\n\nconst VERB_MAP: Record<string, string> = {\n get: 'Retrieves',\n fetch: 'Retrieves',\n load: 'Retrieves',\n find: 'Retrieves',\n query: 'Retrieves',\n read: 'Reads',\n lookup: 'Looks up',\n set: 'Updates',\n update: 'Updates',\n modify: 'Updates',\n patch: 'Updates',\n put: 'Updates',\n validate: 'Validates',\n verify: 'Validates',\n check: 'Validates',\n ensure: 'Ensures',\n create: 'Creates',\n make: 'Creates',\n build: 'Creates',\n generate: 'Creates',\n new: 'Creates',\n add: 'Adds',\n insert: 'Adds',\n append: 'Adds',\n register: 'Registers',\n delete: 'Removes',\n remove: 'Removes',\n destroy: 'Removes',\n drop: 'Removes',\n unset: 'Removes',\n clear: 'Clears',\n parse: 'Parses',\n extract: 'Extracts',\n decode: 'Decodes',\n handle: 'Handles',\n process: 'Processes',\n run: 'Runs',\n execute: 'Executes',\n do: 'Performs',\n perform: 'Performs',\n convert: 'Converts',\n transform: 'Converts',\n to: 'Converts to',\n format: 'Formats',\n encode: 'Encodes',\n serialize: 'Serializes',\n marshal: 'Serializes',\n deserialize: 'Deserializes',\n unmarshal: 'Deserializes',\n is: 'Checks whether',\n has: 'Checks whether',\n can: 'Checks whether',\n should: 'Checks whether',\n init: 'Initializes',\n setup: 'Initializes',\n configure: 'Configures',\n start: 'Starts',\n stop: 'Stops',\n open: 'Opens',\n close: 'Closes',\n connect: 'Connects',\n disconnect: 'Disconnects',\n render: 'Renders',\n display: 'Renders',\n show: 'Renders',\n draw: 'Renders',\n paint: 'Renders',\n hide: 'Hides',\n send: 'Sends',\n emit: 'Emits',\n dispatch: 'Dispatches',\n publish: 'Publishes',\n broadcast: 'Broadcasts',\n notify: 'Notifies',\n receive: 'Receives',\n listen: 'Listens for',\n subscribe: 'Subscribes to',\n on: 'Handles',\n sort: 'Sorts',\n filter: 'Filters',\n map: 'Maps',\n reduce: 'Reduces',\n merge: 'Merges',\n join: 'Joins',\n split: 'Splits',\n group: 'Groups',\n flatten: 'Flattens',\n test: 'Tests',\n assert: 'Tests',\n expect: 'Tests',\n log: 'Logs',\n print: 'Logs',\n warn: 'Logs warning for',\n error: 'Logs error for',\n debug: 'Logs debug info for',\n write: 'Writes',\n save: 'Saves',\n store: 'Stores',\n cache: 'Caches',\n flush: 'Flushes',\n sync: 'Synchronizes',\n reset: 'Resets',\n refresh: 'Refreshes',\n reload: 'Reloads',\n retry: 'Retries',\n wrap: 'Wraps',\n unwrap: 'Unwraps',\n apply: 'Applies',\n resolve: 'Resolves',\n reject: 'Rejects',\n throw: 'Throws',\n raise: 'Raises',\n try: 'Attempts',\n await: 'Awaits',\n wait: 'Waits for',\n schedule: 'Schedules',\n defer: 'Defers',\n cancel: 'Cancels',\n abort: 'Aborts',\n clone: 'Clones',\n copy: 'Copies',\n compare: 'Compares',\n equals: 'Checks equality of',\n match: 'Matches',\n contains: 'Checks whether contains',\n include: 'Includes',\n exclude: 'Excludes',\n enable: 'Enables',\n disable: 'Disables',\n toggle: 'Toggles',\n mount: 'Mounts',\n unmount: 'Unmounts',\n use: 'Uses',\n with: 'Configures with',\n from: 'Creates from',\n of: 'Creates',\n};\n\n// ---------------------------------------------------------------------------\n// Class suffix patterns\n// ---------------------------------------------------------------------------\n\nconst CLASS_SUFFIX_MAP: Record<string, string> = {\n service: 'Service',\n handler: 'Handler',\n controller: 'Controller',\n factory: 'Factory',\n repository: 'Repository',\n repo: 'Repository',\n manager: 'Manager',\n provider: 'Provider',\n adapter: 'Adapter',\n middleware: 'Middleware',\n guard: 'Guard',\n interceptor: 'Interceptor',\n resolver: 'Resolver',\n validator: 'Validator',\n builder: 'Builder',\n parser: 'Parser',\n formatter: 'Formatter',\n converter: 'Converter',\n serializer: 'Serializer',\n client: 'Client',\n server: 'Server',\n router: 'Router',\n store: 'Store',\n cache: 'Cache',\n queue: 'Queue',\n pool: 'Pool',\n registry: 'Registry',\n observer: 'Observer',\n emitter: 'Emitter',\n listener: 'Listener',\n subscriber: 'Subscriber',\n publisher: 'Publisher',\n component: 'Component',\n module: 'Module',\n plugin: 'Plugin',\n helper: 'Helper',\n util: 'Utility',\n utils: 'Utility',\n error: 'Error',\n exception: 'Exception',\n model: 'Model',\n entity: 'Entity',\n dto: 'DTO',\n config: 'Configuration',\n options: 'Options',\n context: 'Context',\n state: 'State',\n hook: 'Hook',\n};\n\n// ---------------------------------------------------------------------------\n// File/directory pattern maps\n// ---------------------------------------------------------------------------\n\nconst FILE_PATTERNS: Array<[RegExp, string]> = [\n [/_test\\.go$/, 'Tests for'],\n [/_test\\.py$/, 'Tests for'],\n [/\\.test\\.[jt]sx?$/, 'Tests for'],\n [/\\.spec\\.[jt]sx?$/, 'Tests for'],\n [/^test_/, 'Tests for'],\n [/^conftest\\.py$/, 'Pytest fixtures and configuration'],\n [/^setup\\.[jt]s$/, 'Setup configuration'],\n [/^index\\.[jt]sx?$/, 'Barrel exports for'],\n [/^main\\.[a-z]+$/, 'Application entry point'],\n [/^mod\\.rs$/, 'Module declarations'],\n [/^__init__\\.py$/, 'Package initialization for'],\n [/^constants?\\.[a-z]+$/, 'Constants and configuration values'],\n [/^types?\\.[a-z]+$/, 'Type definitions'],\n [/^utils?\\.[a-z]+$/, 'Utility functions'],\n [/^helpers?\\.[a-z]+$/, 'Helper functions'],\n [/^middleware\\.[a-z]+$/, 'Middleware definitions'],\n [/^routes?\\.[a-z]+$/, 'Route definitions'],\n [/^models?\\.[a-z]+$/, 'Data model definitions'],\n [/^schema\\.[a-z]+$/, 'Schema definitions'],\n [/^migrations?/, 'Database migration'],\n [/^dockerfile/i, 'Docker container configuration'],\n [/^makefile$/i, 'Build automation rules'],\n [/^readme/i, 'Project documentation'],\n [/^changelog/i, 'Version change history'],\n [/^license/i, 'License information'],\n [/\\.config\\.[a-z]+$/, 'Configuration for'],\n [/rc\\.[a-z]+$/, 'Configuration for'],\n];\n\nconst DIR_PATTERNS: Record<string, string> = {\n api: 'API layer',\n apis: 'API layer',\n handlers: 'Request handlers',\n handler: 'Request handlers',\n controllers: 'Request controllers',\n controller: 'Request controllers',\n routes: 'Route definitions',\n routing: 'Route definitions',\n models: 'Data models',\n model: 'Data models',\n entities: 'Data entities',\n schema: 'Schema definitions',\n schemas: 'Schema definitions',\n services: 'Service layer',\n service: 'Service layer',\n middleware: 'Middleware',\n middlewares: 'Middleware',\n utils: 'Utility functions',\n util: 'Utility functions',\n helpers: 'Helper functions',\n helper: 'Helper functions',\n lib: 'Library modules',\n libs: 'Library modules',\n pkg: 'Package modules',\n internal: 'Internal packages',\n cmd: 'Command entry points',\n config: 'Configuration',\n configs: 'Configuration',\n tests: 'Test suite',\n test: 'Test suite',\n __tests__: 'Test suite',\n spec: 'Test specifications',\n specs: 'Test specifications',\n fixtures: 'Test fixtures',\n mocks: 'Test mocks',\n components: 'UI components',\n component: 'UI components',\n pages: 'Page components',\n views: 'View components',\n layouts: 'Layout components',\n hooks: 'React hooks',\n store: 'State management',\n stores: 'State management',\n state: 'State management',\n reducers: 'State reducers',\n actions: 'State actions',\n selectors: 'State selectors',\n types: 'Type definitions',\n interfaces: 'Interface definitions',\n constants: 'Constants',\n static: 'Static assets',\n assets: 'Static assets',\n public: 'Public assets',\n styles: 'Stylesheets',\n css: 'Stylesheets',\n docs: 'Documentation',\n doc: 'Documentation',\n scripts: 'Build and utility scripts',\n migrations: 'Database migrations',\n seeds: 'Database seed data',\n templates: 'Templates',\n i18n: 'Internationalization',\n locales: 'Locale translations',\n proto: 'Protocol buffer definitions',\n generated: 'Generated code',\n gen: 'Generated code',\n dist: 'Build output',\n build: 'Build output',\n vendor: 'Vendored dependencies',\n node_modules: 'NPM dependencies',\n bin: 'Executable binaries',\n examples: 'Usage examples',\n example: 'Usage examples',\n plugins: 'Plugin modules',\n extensions: 'Extension modules',\n auth: 'Authentication and authorization',\n security: 'Security modules',\n crypto: 'Cryptographic utilities',\n db: 'Database layer',\n database: 'Database layer',\n cache: 'Caching layer',\n queue: 'Message queue handlers',\n workers: 'Background workers',\n jobs: 'Background jobs',\n tasks: 'Task definitions',\n events: 'Event handlers',\n subscribers: 'Event subscribers',\n publishers: 'Event publishers',\n adapters: 'Adapter implementations',\n providers: 'Service providers',\n repositories: 'Data repositories',\n repository: 'Data repositories',\n clients: 'External API clients',\n sdk: 'SDK modules',\n common: 'Shared common modules',\n shared: 'Shared modules',\n core: 'Core modules',\n base: 'Base classes and interfaces',\n errors: 'Error definitions',\n exceptions: 'Exception definitions',\n validators: 'Input validators',\n validation: 'Validation logic',\n serializers: 'Data serializers',\n parsers: 'Data parsers',\n formatters: 'Data formatters',\n converters: 'Data converters',\n transformers: 'Data transformers',\n mappers: 'Data mappers',\n resolvers: 'GraphQL resolvers',\n guards: 'Route guards',\n interceptors: 'Request interceptors',\n decorators: 'Decorators',\n annotations: 'Annotations',\n factories: 'Factory functions',\n builders: 'Builder patterns',\n observers: 'Observer implementations',\n strategies: 'Strategy pattern implementations',\n commands: 'Command implementations',\n queries: 'Query implementations',\n notifications: 'Notification handlers',\n mailers: 'Email sending',\n logging: 'Logging configuration',\n monitoring: 'Monitoring and metrics',\n metrics: 'Application metrics',\n tracing: 'Distributed tracing',\n indexer: 'Indexing pipeline',\n graph: 'Graph data structures',\n summarizer: 'Summarization modules',\n embedder: 'Embedding modules',\n extractors: 'Data extractors',\n};\n\n// ---------------------------------------------------------------------------\n// Keyword extraction patterns\n// ---------------------------------------------------------------------------\n\ninterface KeywordPattern {\n domain: string;\n patterns: RegExp[];\n}\n\nconst KEYWORD_PATTERNS: KeywordPattern[] = [\n {\n domain: 'database',\n patterns: [\n /\\bsql\\b/i,\n /\\bquery\\b/i,\n /\\bSELECT\\b/,\n /\\bINSERT\\b/,\n /\\bUPDATE\\b.*\\bSET\\b/,\n /\\bdb\\./i,\n /\\bcursor\\b/i,\n /\\bconnection\\b/i,\n /\\bprisma\\b/i,\n /\\bknex\\b/i,\n /\\bsequelize\\b/i,\n /\\bmongoose\\b/i,\n /\\bsqlx\\b/i,\n /\\borm\\b/i,\n /\\bmigration\\b/i,\n /\\bschema\\b/i,\n /\\btable\\b/i,\n /\\btransaction\\b/i,\n /\\bcolumn\\b/i,\n ],\n },\n {\n domain: 'auth',\n patterns: [\n /\\bauth\\b/i,\n /\\bjwt\\b/i,\n /\\btoken\\b/i,\n /\\bpassword\\b/i,\n /\\blogin\\b/i,\n /\\bsession\\b/i,\n /\\boauth\\b/i,\n /\\bbcrypt\\b/i,\n /\\bcredential\\b/i,\n /\\bpermission\\b/i,\n /\\brole\\b/i,\n /\\bacl\\b/i,\n /\\bsignin\\b/i,\n /\\bsignup\\b/i,\n ],\n },\n {\n domain: 'http',\n patterns: [\n /\\bhttp\\b/i,\n /\\brequest\\b/i,\n /\\bresponse\\b/i,\n /\\bfetch\\s*\\(/i,\n /\\baxios\\b/i,\n /\\bhandler\\b/i,\n /\\bmiddleware\\b/i,\n /\\bcors\\b/i,\n /\\bendpoint\\b/i,\n /\\broute\\b/i,\n /\\bREST\\b/i,\n /\\bgraphql\\b/i,\n /\\bheader\\b/i,\n ],\n },\n {\n domain: 'filesystem',\n patterns: [\n /\\bfs\\./i,\n /\\breadFile\\b/i,\n /\\bwriteFile\\b/i,\n /\\bpath\\./i,\n /\\bstream\\b/i,\n /\\bbuffer\\b/i,\n /\\bmkdir\\b/i,\n /\\bunlink\\b/i,\n /\\bglob\\b/i,\n ],\n },\n {\n domain: 'crypto',\n patterns: [\n /\\bcrypto\\b/i,\n /\\bencrypt\\b/i,\n /\\bdecrypt\\b/i,\n /\\bhash\\b/i,\n /\\bsign\\b/i,\n /\\bverify\\b/i,\n /\\bcipher\\b/i,\n /\\bhmac\\b/i,\n ],\n },\n {\n domain: 'cache',\n patterns: [\n /\\bcache\\b/i,\n /\\bredis\\b/i,\n /\\bmemcached\\b/i,\n /\\bttl\\b/i,\n /\\binvalidate\\b/i,\n /\\bLRU\\b/i,\n ],\n },\n {\n domain: 'queue',\n patterns: [\n /\\bqueue\\b/i,\n /\\bworker\\b/i,\n /\\bjob\\b/i,\n /\\bpublish\\b/i,\n /\\bsubscribe\\b/i,\n /\\bkafka\\b/i,\n /\\brabbitmq\\b/i,\n /\\bamqp\\b/i,\n ],\n },\n {\n domain: 'config',\n patterns: [\n /\\bconfig\\b/i,\n /\\benv\\b/i,\n /\\bsettings\\b/i,\n /\\byaml\\b/i,\n /\\bdotenv\\b/i,\n /\\.env\\b/i,\n ],\n },\n {\n domain: 'logging',\n patterns: [\n /\\blogger\\b/i,\n /\\bwinston\\b/i,\n /\\bpino\\b/i,\n /\\blogrus\\b/i,\n /\\bslog\\b/i,\n /\\blog\\./i,\n ],\n },\n {\n domain: 'testing',\n patterns: [\n /\\btest\\b/i,\n /\\bassert\\b/i,\n /\\bexpect\\b/i,\n /\\bmock\\b/i,\n /\\bstub\\b/i,\n /\\bspy\\b/i,\n /\\bfixture\\b/i,\n /\\bjest\\b/i,\n /\\bpytest\\b/i,\n ],\n },\n {\n domain: 'async',\n patterns: [\n /\\basync\\b/i,\n /\\bawait\\b/i,\n /\\bPromise\\b/,\n /\\bgoroutine\\b/i,\n /\\bchannel\\b/i,\n /\\bconcurrent\\b/i,\n /\\bparallel\\b/i,\n /\\bmutex\\b/i,\n ],\n },\n {\n domain: 'error',\n patterns: [\n /\\btry\\b/,\n /\\bcatch\\b/,\n /\\bthrow\\b/,\n /\\bError\\b/,\n /\\bpanic\\b/i,\n /\\brecover\\b/i,\n /\\berrno\\b/i,\n ],\n },\n {\n domain: 'validation',\n patterns: [\n /\\bvalidate\\b/i,\n /\\bsanitize\\b/i,\n /\\bzod\\b/i,\n /\\byup\\b/i,\n /\\bjoi\\b/i,\n /\\bregexp\\b/i,\n /\\bregex\\b/i,\n ],\n },\n {\n domain: 'websocket',\n patterns: [\n /\\bwebsocket\\b/i,\n /\\bws\\./i,\n /\\bsocket\\b/i,\n /\\bWebSocket\\b/,\n /\\bemit\\s*\\(/i,\n ],\n },\n {\n domain: 'email',\n patterns: [/\\bemail\\b/i, /\\bsmtp\\b/i, /\\bsendmail\\b/i, /\\bmailer\\b/i],\n },\n];\n\n// ---------------------------------------------------------------------------\n// Identifier splitter\n// ---------------------------------------------------------------------------\n\n/**\n * Split an identifier into words, handling camelCase, PascalCase, snake_case,\n * SCREAMING_SNAKE_CASE, and acronyms (e.g. parseHTTPResponse → [\"parse\", \"HTTP\", \"response\"]).\n */\nexport function splitIdentifier(name: string): string[] {\n // Strip common prefixes/suffixes\n const cleaned = name.replace(/^[_$]+/, '').replace(/[_$]+$/, '');\n\n if (!cleaned) return [name];\n\n // Split on underscores/hyphens first\n const parts = cleaned.split(/[_-]+/).filter(Boolean);\n\n const words: string[] = [];\n for (const part of parts) {\n // Split camelCase/PascalCase with acronym awareness\n const subWords = part\n // Insert boundary between lowercase→uppercase: \"camelCase\" → \"camel Case\"\n .replace(/([a-z])([A-Z])/g, '$1\\0$2')\n // Insert boundary between acronym→word: \"HTTPResponse\" → \"HTTP Response\"\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1\\0$2')\n // Insert boundary between digit→letter and letter→digit\n .replace(/([a-zA-Z])(\\d)/g, '$1\\0$2')\n .replace(/(\\d)([a-zA-Z])/g, '$1\\0$2')\n .split('\\0')\n .filter(Boolean);\n\n words.push(...subWords);\n }\n\n return words.length > 0 ? words : [name];\n}\n\n/**\n * Convert word list to a readable object phrase: [\"user\", \"by\", \"id\"] → \"user by ID\".\n * Short all-caps words (2-4 letters) stay uppercase; everything else lowercased.\n */\nfunction wordsToPhrase(words: string[]): string {\n return words\n .map((w) => {\n if (w.length <= 4 && w === w.toUpperCase() && /^[A-Z]+$/.test(w))\n return w;\n return w.toLowerCase();\n })\n .join(' ');\n}\n\n// ---------------------------------------------------------------------------\n// Keyword extraction\n// ---------------------------------------------------------------------------\n\n/** Scan source code for domain indicators and return deduplicated keywords (max 4). */\nexport function extractKeywords(source: string): string[] {\n if (!source) return [];\n\n const found: string[] = [];\n for (const kp of KEYWORD_PATTERNS) {\n if (found.length >= 4) break;\n for (const pat of kp.patterns) {\n if (pat.test(source)) {\n found.push(kp.domain);\n break; // one match per domain is enough\n }\n }\n }\n\n return found;\n}\n\n/** Format keywords suffix: [\"database\", \"async\"] → \" [database, async]\" */\nfunction formatKeywords(keywords: string[]): string {\n return keywords.length > 0 ? ` [${keywords.join(', ')}]` : '';\n}\n\n// ---------------------------------------------------------------------------\n// Function summarizer\n// ---------------------------------------------------------------------------\n\nconst CONSTRUCTOR_NAMES = new Set([\n '__init__',\n 'constructor',\n 'init',\n 'initialize',\n 'New',\n]);\n\n/** Check if a name is non-descriptive (single letter, too short, or generic). */\nfunction isNonDescriptive(name: string): boolean {\n if (name.length <= 2) return true;\n const lower = name.toLowerCase();\n return [\n 'foo',\n 'bar',\n 'baz',\n 'tmp',\n 'temp',\n 'x',\n 'y',\n 'z',\n 'fn',\n 'cb',\n 'f',\n 'g',\n ].includes(lower);\n}\n\nexport function summarizeFunction(\n name: string,\n _signature?: string,\n _language?: string,\n _lineCount?: number,\n receiverType?: string,\n source?: string,\n): string {\n // Handle constructors\n if (CONSTRUCTOR_NAMES.has(name)) {\n const subject = receiverType || 'instance';\n return `Initializes ${subject}`;\n }\n\n // Handle test functions\n const lowerName = name.toLowerCase();\n if (lowerName.startsWith('test_') || lowerName.startsWith('test')) {\n const words = splitIdentifier(name);\n const testWords =\n words[0].toLowerCase() === 'test' ? words.slice(1) : words;\n if (testWords.length > 0) {\n return `Tests ${wordsToPhrase(testWords)}`;\n }\n return `Tests ${name}`;\n }\n\n // Handle non-descriptive names\n if (isNonDescriptive(name)) {\n return `Function ${name}`;\n }\n\n const words = splitIdentifier(name);\n if (words.length === 0) return `Function ${name}`;\n\n const firstWord = words[0].toLowerCase();\n const restWords = words.slice(1);\n\n // Look up verb prefix\n const verb = VERB_MAP[firstWord];\n if (verb) {\n const object = restWords.length > 0 ? ` ${wordsToPhrase(restWords)}` : '';\n\n let prefix = '';\n if (receiverType) {\n prefix = `${receiverType} method that `;\n // Use lowercase verb for the \"method that <verbs>\" form\n const lowerVerb = verb.toLowerCase();\n const result = `${prefix}${lowerVerb}${object}`;\n const keywords = source ? extractKeywords(source) : [];\n return result + formatKeywords(keywords);\n }\n\n const result = `${verb}${object}`;\n const keywords = source ? extractKeywords(source) : [];\n return result + formatKeywords(keywords);\n }\n\n // No known verb — describe as noun phrase\n const phrase = wordsToPhrase(words);\n let result: string;\n\n if (receiverType) {\n result = `${receiverType} method for ${phrase}`;\n } else {\n // Capitalize first letter\n result = phrase.charAt(0).toUpperCase() + phrase.slice(1);\n }\n\n const keywords = source ? extractKeywords(source) : [];\n return result + formatKeywords(keywords);\n}\n\n// ---------------------------------------------------------------------------\n// Class summarizer\n// ---------------------------------------------------------------------------\n\nconst CRUD_METHODS = new Set([\n 'create',\n 'read',\n 'get',\n 'find',\n 'update',\n 'delete',\n 'remove',\n 'save',\n 'list',\n]);\n\nexport function summarizeClass(\n name: string,\n childNames?: string[],\n source?: string,\n): string {\n const words = splitIdentifier(name);\n const readableName = wordsToPhrase(words);\n const capitalizedName =\n readableName.charAt(0).toUpperCase() + readableName.slice(1);\n\n // Detect class suffix pattern\n const lastWord = words[words.length - 1].toLowerCase();\n const suffixLabel = CLASS_SUFFIX_MAP[lastWord];\n\n // Detect CRUD pattern\n let hasCrud = false;\n if (childNames && childNames.length > 0) {\n const lowerChildren = childNames.map((c) =>\n splitIdentifier(c)[0].toLowerCase(),\n );\n const crudCount = lowerChildren.filter((c) => CRUD_METHODS.has(c)).length;\n hasCrud = crudCount >= 3;\n }\n\n let summary = capitalizedName;\n\n if (hasCrud) {\n summary += ' for CRUD operations';\n } else if (suffixLabel) {\n // Only add if the suffix isn't already the full name\n if (words.length > 1) {\n // The name already describes what it is, just format it nicely\n }\n }\n\n // List key methods (up to 5)\n if (childNames && childNames.length > 0) {\n const methodList = childNames.slice(0, 5).join(', ');\n const extra =\n childNames.length > 5 ? ` and ${childNames.length - 5} more` : '';\n summary += ` with methods: ${methodList}${extra}`;\n }\n\n const keywords = source ? extractKeywords(source) : [];\n return summary + formatKeywords(keywords);\n}\n\n// ---------------------------------------------------------------------------\n// File summarizer\n// ---------------------------------------------------------------------------\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\nexport function summarizeFile(\n fileName: string,\n symbolNames?: string[],\n language?: string,\n _source?: string,\n): string {\n /* eslint-enable @typescript-eslint/no-unused-vars */\n const lowerFile = fileName.toLowerCase();\n\n // Check known file patterns\n for (const [pattern, prefix] of FILE_PATTERNS) {\n if (pattern.test(lowerFile)) {\n // For \"Tests for\" and similar, try to derive subject from filename\n if (prefix.endsWith('for')) {\n const baseName = fileName\n .replace(/_test\\.\\w+$/, '')\n .replace(/\\.test\\.\\w+$/, '')\n .replace(/\\.spec\\.\\w+$/, '')\n .replace(/^test_/, '')\n .replace(/\\.\\w+$/, '');\n const subject = wordsToPhrase(splitIdentifier(baseName));\n return `${prefix} ${subject}`;\n }\n if (prefix.endsWith('for') || prefix === 'Barrel exports for') {\n // Try to derive context from parent dir (not available here — use symbols)\n if (symbolNames && symbolNames.length > 0) {\n const listing = symbolNames.slice(0, 3).join(', ');\n const extra =\n symbolNames.length > 3 ? ` and ${symbolNames.length - 3} more` : '';\n return `${prefix} ${listing}${extra}`;\n }\n }\n return prefix;\n }\n }\n\n // Generic file with symbols\n if (symbolNames && symbolNames.length > 0) {\n const listing = symbolNames.slice(0, 3).join(', ');\n const extra =\n symbolNames.length > 3 ? ` and ${symbolNames.length - 3} more` : '';\n const langNote = language ? ` ${language}` : '';\n return `Defines${langNote} ${listing}${extra}`;\n }\n\n return `Source file ${fileName}`;\n}\n\n// ---------------------------------------------------------------------------\n// Directory summarizer\n// ---------------------------------------------------------------------------\n\nexport function summarizeDirectory(\n dirName: string,\n childNames: string[],\n): string {\n const lowerDir = dirName.toLowerCase();\n const knownPurpose = DIR_PATTERNS[lowerDir];\n\n if (knownPurpose) {\n if (childNames.length > 0) {\n const listing = childNames.slice(0, 5).join(', ');\n const extra =\n childNames.length > 5 ? ` and ${childNames.length - 5} more` : '';\n return `${knownPurpose} containing ${listing}${extra}`;\n }\n return knownPurpose;\n }\n\n // Unknown directory — list contents\n if (childNames.length > 0) {\n const listing = childNames.slice(0, 5).join(', ');\n const extra =\n childNames.length > 5 ? ` and ${childNames.length - 5} more` : '';\n return `Directory containing ${listing}${extra}`;\n }\n\n return `Directory ${dirName}`;\n}\n\n// ---------------------------------------------------------------------------\n// Unified summarizer (from structured metadata)\n// ---------------------------------------------------------------------------\n\n/** Generate a summary from structured symbol metadata — no source code parsing needed.\n * If the symbol has an extracted doc comment (javadoc, pydoc, godoc, etc.), use its\n * first sentence as the summary — the author's own description beats heuristics. */\nexport function summarizeFromMetadata(meta: SymbolMetadata): string {\n if (meta.docs) {\n // Use the first sentence (or first line) of the doc comment\n const firstSentence = meta.docs.split(/\\.\\s|\\n/)[0].trim();\n if (firstSentence) {\n // Ensure it ends cleanly\n return firstSentence.endsWith('.')\n ? firstSentence.slice(0, -1)\n : firstSentence;\n }\n }\n\n switch (meta.kind) {\n case 'function':\n return summarizeFunction(\n meta.name,\n meta.signature,\n meta.language,\n meta.lineCount,\n meta.receiverType,\n meta.source,\n );\n case 'class':\n return summarizeClass(meta.name, meta.childNames, meta.source);\n case 'file':\n return summarizeFile(\n meta.fileName || meta.name,\n meta.childNames,\n meta.language,\n meta.source,\n );\n case 'directory':\n return summarizeDirectory(meta.name, meta.childNames || []);\n default:\n return `${meta.kind} ${meta.name}`;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Summarizer interface implementation (backward compatibility)\n// ---------------------------------------------------------------------------\n\n/**\n * Template-based Summarizer that implements the Summarizer interface.\n *\n * Unlike the ML-based FlanT5Summarizer, this runs synchronously (no model loading)\n * and produces instant summaries from code structure/naming conventions.\n */\nexport class TemplateSummarizer implements Summarizer {\n async init(): Promise<void> {\n // No model to load — templates are instant\n }\n\n async summarize(source: string, kind: NodeKind): Promise<string> {\n // Extract a plausible name from the first line\n const firstLine = source.split('\\n')[0] || '';\n const nameMatch = firstLine.match(\n /(?:function|def|func|class|const|let|var|type|interface)\\s+(\\w+)/,\n );\n const name = nameMatch?.[1] || 'unknown';\n\n return summarizeFromMetadata({ name, kind, source });\n }\n\n async summarizeBatch(\n items: Array<{ source: string; kind: NodeKind }>,\n ): Promise<string[]> {\n return Promise.all(\n items.map((item) => this.summarize(item.source, item.kind)),\n );\n }\n\n async dispose(): Promise<void> {\n // Nothing to dispose\n }\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Summarization stage: wraps an inner event stream and ensures every\n * node that flows through has a `summary` property.\n *\n * Runs after all other stages, intercepting every event. For each node\n * without a summary, calls the template summarizer. Nodes that already\n * have a summary (e.g. from doc comments) are left unchanged.\n */\n\nimport type { PipelineEvent, GraphNode } from '../types';\nimport { summarizeFromMetadata } from '../summarizer/templateSummarizer';\nimport type { NodeKind } from '../summarizer/types';\n\nconst TYPE_TO_KIND: Record<string, NodeKind> = {\n Function: 'function',\n Class: 'class',\n File: 'file',\n Directory: 'directory',\n};\n\n/** Build a SymbolMetadata object from a graph node's properties. */\nfunction summarizeNode(node: GraphNode): string {\n const kind = TYPE_TO_KIND[node.type];\n if (!kind) {\n // Fallback for Repository, Package, etc.\n return `${node.type} ${node.name}`;\n }\n\n const props = node.properties ?? {};\n return summarizeFromMetadata({\n name: node.name,\n kind,\n signature: props.signature as string | undefined,\n language: props.language as string | undefined,\n lineCount:\n typeof props.start_line === 'number' && typeof props.end_line === 'number'\n ? props.end_line - props.start_line + 1\n : undefined,\n receiverType: props.receiver_type as string | undefined,\n fileName:\n kind === 'file' ? ((props.path as string) ?? node.name) : undefined,\n childNames: props.childNames as string[] | undefined,\n docs: props.docs as string | undefined,\n });\n}\n\n/**\n * Wrap an inner event generator, adding summaries to every node that\n * doesn't already have one. Emits its own start/progress/stop events\n * so the UI modal can show summarization activity.\n */\nexport function* wrapWithSummaries(\n inner: Generator<PipelineEvent>,\n): Generator<PipelineEvent> {\n let summarized = 0;\n let total = 0;\n\n yield {\n kind: 'stage_start',\n phase: 'summarizing',\n message: 'Summarizing nodes...',\n };\n\n for (const event of inner) {\n if (event.nodes) {\n for (const node of event.nodes) {\n total++;\n if (!node.properties?.summary) {\n const summary = summarizeNode(node);\n if (summary) {\n node.properties = { ...node.properties, summary };\n summarized++;\n }\n }\n }\n\n yield {\n kind: 'stage_progress',\n phase: 'summarizing',\n message: `Summarized ${summarized} of ${total} nodes`,\n detail: { current: summarized, total },\n };\n }\n yield event;\n }\n\n yield {\n kind: 'stage_stop',\n phase: 'summarizing',\n message: `Summarized ${summarized} nodes`,\n };\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n GraphNode,\n GraphRelationship,\n LoadingInput,\n PipelineContext,\n PipelineEvent,\n Store,\n} from './types';\nimport { execute as scanning } from './stages/scanning';\nimport { execute as processing } from './stages/processing';\nimport { execute as resolving } from './stages/resolving';\nimport { execute as saving } from './stages/saving';\nimport { wrapWithSummaries } from './stages/summarizing';\n\nexport { initParsers } from './stages/parsing';\n\nfunction* corePipeline(\n input: LoadingInput,\n ctx: PipelineContext,\n): Generator<PipelineEvent> {\n const scanResult = yield* scanning(input, ctx);\n\n if (ctx.cancelled) return;\n\n const processingOutput = yield* processing(scanResult, ctx);\n\n if (ctx.cancelled) return;\n\n const finalResult = yield* resolving(processingOutput);\n\n yield {\n kind: 'done',\n phase: 'resolving',\n message: 'Pipeline complete',\n result: finalResult,\n };\n}\n\nexport function* runPipeline(\n input: LoadingInput,\n ctx: PipelineContext,\n store?: Store,\n): Generator<PipelineEvent> {\n const inner = wrapWithSummaries(corePipeline(input, ctx));\n if (store) {\n yield* saving(inner, store);\n } else {\n yield* inner;\n }\n}\n\n/** Collect all events and return aggregated nodes/relationships (convenience for tests). */\nexport function collectPipeline(\n input: LoadingInput,\n ctx: PipelineContext,\n store?: Store,\n): {\n events: PipelineEvent[];\n nodes: GraphNode[];\n relationships: GraphRelationship[];\n} {\n const events: PipelineEvent[] = [];\n const nodes: GraphNode[] = [];\n const relationships: GraphRelationship[] = [];\n\n for (const event of runPipeline(input, ctx, store)) {\n events.push(event);\n if (event.nodes) nodes.push(...event.nodes);\n if (event.relationships) relationships.push(...event.relationships);\n }\n\n return { events, nodes, relationships };\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { GraphNode, GraphRelationship, Store } from '../types';\n\nexport class MemoryStore implements Store {\n readonly nodes = new Map<string, GraphNode>();\n readonly relationships = new Map<string, GraphRelationship>();\n\n saveNode(node: GraphNode): void {\n const existing = this.nodes.get(node.id);\n if (existing) {\n // Merge properties (e.g. summary update into existing node)\n existing.properties = {\n ...existing.properties,\n ...(node.properties ?? {}),\n };\n } else {\n this.nodes.set(node.id, node);\n }\n }\n\n saveRelationship(rel: GraphRelationship): void {\n this.relationships.set(rel.id, rel);\n }\n}\n","/*\n * Copyright 2026 OpenTrace Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Summarizer abstraction layer — shared interface for node summarization.\n *\n * Implementations can use different backends (Transformers.js, ONNX Runtime, etc.)\n * while the pipeline code remains agnostic.\n */\n\nexport type NodeKind = 'function' | 'class' | 'file' | 'directory';\n\nexport type SummarizationStrategyType = 'template' | 'ml' | 'llm' | 'none';\n\n/** Structured metadata for template-based summarization (no source code needed). */\nexport interface SymbolMetadata {\n name: string;\n kind: NodeKind;\n signature?: string; // function params\n language?: string;\n lineCount?: number;\n childNames?: string[]; // method names (classes) or symbol names (files)\n fileName?: string; // file path context\n receiverType?: string; // Go methods\n source?: string; // code snippet for keyword extraction\n docs?: string; // extracted documentation comment (javadoc, pydoc, godoc, etc.)\n}\n\nexport interface SummarizerConfig {\n enabled: boolean;\n /** Which summarization approach to use: template (instant), ml (FlanT5), llm (local), or none. */\n strategy: SummarizationStrategyType;\n model: string;\n /** Maximum input tokens for the model. Source is truncated to ~4× this in chars. */\n maxInputLength: number;\n /** Minimum lines for a function/class to be summarized via ML. Smaller ones get a template. */\n minLines: number;\n /** Base URL for the local LLM server (OpenAI-compatible). Used when strategy === 'llm'. */\n llmUrl?: string;\n /** Model name to use on the local LLM server. Used when strategy === 'llm'. */\n llmModel?: string;\n}\n\nexport const DEFAULT_SUMMARIZER_CONFIG: SummarizerConfig = {\n enabled: true,\n strategy: 'template',\n model: 'Xenova/flan-t5-small',\n maxInputLength: 480,\n minLines: 5,\n};\n\nexport interface Summarizer {\n /** Load the model into memory. Must be called before summarize(). */\n init(): Promise<void>;\n\n /**\n * Generate a one-sentence summary for a code snippet.\n *\n * @param source - The source code to summarize (will be truncated internally).\n * @param kind - What kind of code entity this is (function, class, file).\n * @returns The generated summary string.\n */\n summarize(source: string, kind: NodeKind): Promise<string>;\n\n /**\n * Summarize multiple items in a single batched forward pass.\n * Much faster than calling summarize() in a loop.\n *\n * @param items - Array of {source, kind} pairs to summarize.\n * @returns Array of summary strings (same order as input).\n */\n summarizeBatch(\n items: Array<{ source: string; kind: NodeKind }>,\n ): Promise<string[]>;\n\n /** Release model resources. */\n dispose(): Promise<void>;\n}\n"],"names":["parentDir","execute","walkNode","extractClass","extractFunction","walkClassBody","collectCalls","extractMethod","cls","targetFileId","conf","words","result","keywords","scanning","processing","resolving","saving"],"mappings":";;AAkBA,MAAM,eAAuC;AAAA,EAC3C,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AA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