codemap-ai 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +181 -0
- package/dist/chunk-5ONPBEWJ.js +350 -0
- package/dist/chunk-5ONPBEWJ.js.map +1 -0
- package/dist/chunk-FLUWKIEM.js +347 -0
- package/dist/chunk-FLUWKIEM.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1302 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +331 -0
- package/dist/index.js +1163 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server.d.ts +2 -0
- package/dist/mcp-server.js +365 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/server-ACGCJ3GE.js +87 -0
- package/dist/server-ACGCJ3GE.js.map +1 -0
- package/dist/server-TBIVIIUJ.js +367 -0
- package/dist/server-TBIVIIUJ.js.map +1 -0
- package/package.json +70 -0
- package/web/index.html +639 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts","../src/graph/builder.ts","../src/parsers/base.ts","../src/parsers/typescript.ts","../src/parsers/python.ts","../src/parsers/index.ts","../src/skills/generator.ts","../src/index.ts"],"sourcesContent":["/**\n * Core types for CodeMap\n */\n\n// ============ Graph Node Types ============\n\nexport type NodeType =\n | \"file\"\n | \"function\"\n | \"class\"\n | \"method\"\n | \"variable\"\n | \"module\"\n | \"import\";\n\nexport interface GraphNode {\n id: string;\n type: NodeType;\n name: string;\n filePath: string;\n startLine: number;\n endLine: number;\n language: string;\n metadata?: Record<string, unknown>;\n}\n\n// ============ Graph Edge Types ============\n\nexport type EdgeType =\n | \"imports\"\n | \"calls\"\n | \"extends\"\n | \"implements\"\n | \"contains\"\n | \"uses\"\n | \"exports\";\n\nexport interface GraphEdge {\n id: string;\n type: EdgeType;\n sourceId: string;\n targetId: string;\n metadata?: Record<string, unknown>;\n}\n\n// ============ Analysis Results ============\n\nexport interface FileAnalysis {\n filePath: string;\n language: string;\n nodes: GraphNode[];\n edges: GraphEdge[];\n imports: ImportInfo[];\n exports: ExportInfo[];\n}\n\nexport interface ImportInfo {\n source: string;\n specifiers: string[];\n isDefault: boolean;\n isNamespace: boolean;\n line: number;\n}\n\nexport interface ExportInfo {\n name: string;\n isDefault: boolean;\n line: number;\n}\n\n// ============ Project Analysis ============\n\nexport interface ProjectAnalysis {\n rootPath: string;\n files: FileAnalysis[];\n totalNodes: number;\n totalEdges: number;\n languages: Record<string, number>;\n analyzedAt: string;\n}\n\n// ============ Query Results ============\n\nexport interface AffectedFile {\n filePath: string;\n reason: string;\n depth: number;\n connections: string[];\n}\n\nexport interface CallChain {\n caller: GraphNode;\n callee: GraphNode;\n filePath: string;\n line: number;\n}\n\n// ============ Skill Generation ============\n\nexport interface GeneratedSkill {\n name: string;\n description: string;\n content: string;\n filePath: string;\n}\n\nexport interface SkillConfig {\n projectName: string;\n outputDir: string;\n includeArchitecture: boolean;\n includePatterns: boolean;\n includeDependencies: boolean;\n}\n\n// ============ Configuration ============\n\nexport interface CodeMapConfig {\n rootPath: string;\n include: string[];\n exclude: string[];\n languages: string[];\n dbPath: string;\n skillsOutputDir: string;\n}\n\nexport const DEFAULT_CONFIG: Partial<CodeMapConfig> = {\n include: [\"**/*.ts\", \"**/*.tsx\", \"**/*.js\", \"**/*.jsx\", \"**/*.py\"],\n exclude: [\n \"**/node_modules/**\",\n \"**/dist/**\",\n \"**/build/**\",\n \"**/.git/**\",\n \"**/venv/**\",\n \"**/__pycache__/**\",\n \"**/.next/**\",\n ],\n languages: [\"typescript\", \"javascript\", \"python\"],\n};\n\n// ============ MCP Types ============\n\nexport interface MCPToolResult {\n content: Array<{\n type: \"text\";\n text: string;\n }>;\n}\n\nexport interface MCPResource {\n uri: string;\n name: string;\n description: string;\n mimeType: string;\n}\n","/**\n * Graph builder - scans codebase and builds the knowledge graph\n */\n\nimport { readFileSync, statSync } from \"fs\";\nimport { glob } from \"glob\";\nimport { join, relative, resolve } from \"path\";\nimport { parserRegistry } from \"../parsers/index.js\";\nimport { GraphStorage } from \"./storage.js\";\nimport type { CodeMapConfig, FileAnalysis, ProjectAnalysis } from \"../types.js\";\n\nexport interface ScanProgress {\n total: number;\n current: number;\n currentFile: string;\n phase: \"discovering\" | \"parsing\" | \"resolving\" | \"complete\";\n}\n\nexport type ProgressCallback = (progress: ScanProgress) => void;\n\nexport class GraphBuilder {\n private storage: GraphStorage;\n private config: CodeMapConfig;\n private onProgress?: ProgressCallback;\n\n constructor(storage: GraphStorage, config: CodeMapConfig) {\n this.storage = storage;\n this.config = config;\n }\n\n setProgressCallback(callback: ProgressCallback): void {\n this.onProgress = callback;\n }\n\n async scan(): Promise<ProjectAnalysis> {\n const rootPath = resolve(this.config.rootPath);\n\n // Phase 1: Discover files\n this.emitProgress({ total: 0, current: 0, currentFile: \"\", phase: \"discovering\" });\n\n const files = await this.discoverFiles(rootPath);\n\n // Phase 2: Parse files\n const fileAnalyses: FileAnalysis[] = [];\n let current = 0;\n\n for (const filePath of files) {\n current++;\n this.emitProgress({\n total: files.length,\n current,\n currentFile: relative(rootPath, filePath),\n phase: \"parsing\",\n });\n\n try {\n const analysis = this.parseFile(filePath);\n if (analysis) {\n fileAnalyses.push(analysis);\n this.storage.insertFileAnalysis(analysis);\n }\n } catch (error) {\n console.error(`Error parsing ${filePath}:`, error);\n }\n }\n\n // Phase 3: Resolve cross-file references\n this.emitProgress({\n total: files.length,\n current: files.length,\n currentFile: \"\",\n phase: \"resolving\",\n });\n this.resolveReferences();\n\n // Store metadata\n const languages: Record<string, number> = {};\n for (const analysis of fileAnalyses) {\n languages[analysis.language] = (languages[analysis.language] || 0) + 1;\n }\n\n const stats = this.storage.getStats();\n\n this.storage.setMeta(\"rootPath\", rootPath);\n this.storage.setMeta(\"analyzedAt\", new Date().toISOString());\n this.storage.setMeta(\"totalFiles\", String(files.length));\n\n this.emitProgress({\n total: files.length,\n current: files.length,\n currentFile: \"\",\n phase: \"complete\",\n });\n\n return {\n rootPath,\n files: fileAnalyses,\n totalNodes: stats.totalNodes,\n totalEdges: stats.totalEdges,\n languages,\n analyzedAt: new Date().toISOString(),\n };\n }\n\n private async discoverFiles(rootPath: string): Promise<string[]> {\n const patterns = this.config.include;\n const ignorePatterns = this.config.exclude;\n\n const allFiles: string[] = [];\n\n for (const pattern of patterns) {\n const matches = await glob(pattern, {\n cwd: rootPath,\n absolute: true,\n ignore: ignorePatterns,\n nodir: true,\n });\n allFiles.push(...matches);\n }\n\n // Deduplicate and filter by supported extensions\n const supportedExts = new Set(parserRegistry.getSupportedExtensions());\n const uniqueFiles = [...new Set(allFiles)].filter((f) => {\n const ext = f.substring(f.lastIndexOf(\".\"));\n return supportedExts.has(ext);\n });\n\n return uniqueFiles.sort();\n }\n\n private parseFile(filePath: string): FileAnalysis | null {\n const parser = parserRegistry.getForFile(filePath);\n if (!parser) {\n return null;\n }\n\n const content = readFileSync(filePath, \"utf-8\");\n return parser.parse(filePath, content);\n }\n\n private resolveReferences(): void {\n // Get all edges with unresolved references\n const allEdges = this.storage.getAllEdges();\n const allNodes = this.storage.getAllNodes();\n\n // Build a map of node names to node IDs\n const nodeNameMap = new Map<string, string[]>();\n for (const node of allNodes) {\n const existing = nodeNameMap.get(node.name) || [];\n existing.push(node.id);\n nodeNameMap.set(node.name, existing);\n }\n\n // Resolve references\n for (const edge of allEdges) {\n if (edge.targetId.startsWith(\"ref:\")) {\n const refName = edge.targetId.substring(4);\n const candidates = nodeNameMap.get(refName);\n\n if (candidates && candidates.length > 0) {\n // For now, take the first match (could be smarter with scope resolution)\n // Update the edge in storage\n // Note: In a more complete implementation, we'd update the edge in the DB\n }\n }\n }\n }\n\n private emitProgress(progress: ScanProgress): void {\n if (this.onProgress) {\n this.onProgress(progress);\n }\n }\n}\n\nexport { GraphStorage };\n","/**\n * Base parser interface and utilities\n */\n\nimport type { FileAnalysis, GraphNode, GraphEdge, ImportInfo, ExportInfo } from \"../types.js\";\n\nexport interface Parser {\n language: string;\n extensions: string[];\n parse(filePath: string, content: string): FileAnalysis;\n}\n\nexport abstract class BaseParser implements Parser {\n abstract language: string;\n abstract extensions: string[];\n\n protected nodeIdCounter = 0;\n protected edgeIdCounter = 0;\n\n abstract parse(filePath: string, content: string): FileAnalysis;\n\n protected generateNodeId(filePath: string, name: string, line: number): string {\n return `${filePath}:${name}:${line}`;\n }\n\n protected generateEdgeId(): string {\n return `edge_${++this.edgeIdCounter}`;\n }\n\n protected createNode(\n type: GraphNode[\"type\"],\n name: string,\n filePath: string,\n startLine: number,\n endLine: number,\n metadata?: Record<string, unknown>\n ): GraphNode {\n return {\n id: this.generateNodeId(filePath, name, startLine),\n type,\n name,\n filePath,\n startLine,\n endLine,\n language: this.language,\n metadata,\n };\n }\n\n protected createEdge(\n type: GraphEdge[\"type\"],\n sourceId: string,\n targetId: string,\n metadata?: Record<string, unknown>\n ): GraphEdge {\n return {\n id: this.generateEdgeId(),\n type,\n sourceId,\n targetId,\n metadata,\n };\n }\n\n protected createEmptyAnalysis(filePath: string): FileAnalysis {\n return {\n filePath,\n language: this.language,\n nodes: [],\n edges: [],\n imports: [],\n exports: [],\n };\n }\n}\n\n/**\n * Registry for all parsers\n */\nexport class ParserRegistry {\n private parsers: Map<string, Parser> = new Map();\n private extensionMap: Map<string, Parser> = new Map();\n\n register(parser: Parser): void {\n this.parsers.set(parser.language, parser);\n for (const ext of parser.extensions) {\n this.extensionMap.set(ext, parser);\n }\n }\n\n getByLanguage(language: string): Parser | undefined {\n return this.parsers.get(language);\n }\n\n getByExtension(extension: string): Parser | undefined {\n // Normalize extension (remove leading dot if present)\n const ext = extension.startsWith(\".\") ? extension : `.${extension}`;\n return this.extensionMap.get(ext);\n }\n\n getForFile(filePath: string): Parser | undefined {\n const ext = filePath.substring(filePath.lastIndexOf(\".\"));\n return this.getByExtension(ext);\n }\n\n getSupportedExtensions(): string[] {\n return Array.from(this.extensionMap.keys());\n }\n\n getSupportedLanguages(): string[] {\n return Array.from(this.parsers.keys());\n }\n}\n\nexport const parserRegistry = new ParserRegistry();\n","/**\n * TypeScript/JavaScript parser using Tree-sitter\n */\n\nimport Parser from \"tree-sitter\";\nimport TypeScript from \"tree-sitter-typescript\";\nimport JavaScript from \"tree-sitter-javascript\";\nimport { BaseParser } from \"./base.js\";\nimport type { FileAnalysis, GraphNode, GraphEdge, ImportInfo, ExportInfo } from \"../types.js\";\n\nexport class TypeScriptParser extends BaseParser {\n language = \"typescript\";\n extensions = [\".ts\", \".tsx\"];\n\n private parser: Parser;\n\n constructor() {\n super();\n this.parser = new Parser();\n this.parser.setLanguage(TypeScript.typescript);\n }\n\n parse(filePath: string, content: string): FileAnalysis {\n const analysis = this.createEmptyAnalysis(filePath);\n\n // Use TSX parser for .tsx files\n if (filePath.endsWith(\".tsx\")) {\n this.parser.setLanguage(TypeScript.tsx);\n } else {\n this.parser.setLanguage(TypeScript.typescript);\n }\n\n const tree = this.parser.parse(content);\n const lines = content.split(\"\\n\");\n\n // Create file node\n const fileNode = this.createNode(\n \"file\",\n filePath.split(\"/\").pop() || filePath,\n filePath,\n 1,\n lines.length\n );\n analysis.nodes.push(fileNode);\n\n // Walk the tree\n this.walkTree(tree.rootNode, filePath, analysis, fileNode.id);\n\n return analysis;\n }\n\n private walkTree(\n node: Parser.SyntaxNode,\n filePath: string,\n analysis: FileAnalysis,\n parentId: string\n ): void {\n switch (node.type) {\n case \"import_statement\":\n this.handleImport(node, analysis);\n break;\n\n case \"export_statement\":\n this.handleExport(node, filePath, analysis, parentId);\n break;\n\n case \"function_declaration\":\n case \"arrow_function\":\n case \"function_expression\":\n this.handleFunction(node, filePath, analysis, parentId);\n break;\n\n case \"class_declaration\":\n this.handleClass(node, filePath, analysis, parentId);\n break;\n\n case \"method_definition\":\n this.handleMethod(node, filePath, analysis, parentId);\n break;\n\n case \"call_expression\":\n this.handleCall(node, filePath, analysis, parentId);\n break;\n\n case \"variable_declaration\":\n this.handleVariable(node, filePath, analysis, parentId);\n break;\n }\n\n // Recurse into children\n for (const child of node.children) {\n this.walkTree(child, filePath, analysis, parentId);\n }\n }\n\n private handleImport(node: Parser.SyntaxNode, analysis: FileAnalysis): void {\n const sourceNode = node.childForFieldName(\"source\");\n if (!sourceNode) return;\n\n const source = sourceNode.text.replace(/['\"]/g, \"\");\n const specifiers: string[] = [];\n let isDefault = false;\n let isNamespace = false;\n\n // Find import clause\n for (const child of node.children) {\n if (child.type === \"import_clause\") {\n for (const clauseChild of child.children) {\n if (clauseChild.type === \"identifier\") {\n specifiers.push(clauseChild.text);\n isDefault = true;\n } else if (clauseChild.type === \"namespace_import\") {\n isNamespace = true;\n const nameNode = clauseChild.childForFieldName(\"name\");\n if (nameNode) specifiers.push(nameNode.text);\n } else if (clauseChild.type === \"named_imports\") {\n for (const importSpec of clauseChild.children) {\n if (importSpec.type === \"import_specifier\") {\n const name = importSpec.childForFieldName(\"name\");\n if (name) specifiers.push(name.text);\n }\n }\n }\n }\n }\n }\n\n analysis.imports.push({\n source,\n specifiers,\n isDefault,\n isNamespace,\n line: node.startPosition.row + 1,\n });\n }\n\n private handleExport(\n node: Parser.SyntaxNode,\n filePath: string,\n analysis: FileAnalysis,\n parentId: string\n ): void {\n const isDefault = node.children.some((c) => c.type === \"default\");\n\n // Find what's being exported\n for (const child of node.children) {\n if (child.type === \"function_declaration\") {\n const nameNode = child.childForFieldName(\"name\");\n if (nameNode) {\n analysis.exports.push({\n name: nameNode.text,\n isDefault,\n line: node.startPosition.row + 1,\n });\n }\n this.handleFunction(child, filePath, analysis, parentId);\n } else if (child.type === \"class_declaration\") {\n const nameNode = child.childForFieldName(\"name\");\n if (nameNode) {\n analysis.exports.push({\n name: nameNode.text,\n isDefault,\n line: node.startPosition.row + 1,\n });\n }\n this.handleClass(child, filePath, analysis, parentId);\n } else if (child.type === \"identifier\") {\n analysis.exports.push({\n name: child.text,\n isDefault,\n line: node.startPosition.row + 1,\n });\n }\n }\n }\n\n private handleFunction(\n node: Parser.SyntaxNode,\n filePath: string,\n analysis: FileAnalysis,\n parentId: string\n ): void {\n let name = \"anonymous\";\n const nameNode = node.childForFieldName(\"name\");\n if (nameNode) {\n name = nameNode.text;\n }\n\n const funcNode = this.createNode(\n \"function\",\n name,\n filePath,\n node.startPosition.row + 1,\n node.endPosition.row + 1,\n {\n async: node.children.some((c) => c.type === \"async\"),\n generator: node.children.some((c) => c.text === \"*\"),\n }\n );\n\n analysis.nodes.push(funcNode);\n\n // Add contains edge from parent\n analysis.edges.push(\n this.createEdge(\"contains\", parentId, funcNode.id)\n );\n }\n\n private handleClass(\n node: Parser.SyntaxNode,\n filePath: string,\n analysis: FileAnalysis,\n parentId: string\n ): void {\n const nameNode = node.childForFieldName(\"name\");\n if (!nameNode) return;\n\n const classNode = this.createNode(\n \"class\",\n nameNode.text,\n filePath,\n node.startPosition.row + 1,\n node.endPosition.row + 1\n );\n\n analysis.nodes.push(classNode);\n\n // Add contains edge\n analysis.edges.push(\n this.createEdge(\"contains\", parentId, classNode.id)\n );\n\n // Check for extends\n for (const child of node.children) {\n if (child.type === \"class_heritage\") {\n const extendsClause = child.children.find((c) => c.type === \"extends_clause\");\n if (extendsClause) {\n const baseClass = extendsClause.children.find((c) => c.type === \"identifier\");\n if (baseClass) {\n // Create a reference edge (will be resolved later)\n analysis.edges.push(\n this.createEdge(\"extends\", classNode.id, `ref:${baseClass.text}`, {\n unresolvedName: baseClass.text,\n })\n );\n }\n }\n }\n }\n\n // Process class body for methods\n const body = node.childForFieldName(\"body\");\n if (body) {\n for (const member of body.children) {\n if (member.type === \"method_definition\") {\n this.handleMethod(member, filePath, analysis, classNode.id);\n }\n }\n }\n }\n\n private handleMethod(\n node: Parser.SyntaxNode,\n filePath: string,\n analysis: FileAnalysis,\n parentId: string\n ): void {\n const nameNode = node.childForFieldName(\"name\");\n if (!nameNode) return;\n\n const methodNode = this.createNode(\n \"method\",\n nameNode.text,\n filePath,\n node.startPosition.row + 1,\n node.endPosition.row + 1,\n {\n static: node.children.some((c) => c.type === \"static\"),\n async: node.children.some((c) => c.type === \"async\"),\n }\n );\n\n analysis.nodes.push(methodNode);\n\n // Add contains edge\n analysis.edges.push(\n this.createEdge(\"contains\", parentId, methodNode.id)\n );\n }\n\n private handleCall(\n node: Parser.SyntaxNode,\n filePath: string,\n analysis: FileAnalysis,\n parentId: string\n ): void {\n const funcNode = node.childForFieldName(\"function\");\n if (!funcNode) return;\n\n let calledName = \"\";\n if (funcNode.type === \"identifier\") {\n calledName = funcNode.text;\n } else if (funcNode.type === \"member_expression\") {\n // Get the full member expression (e.g., \"console.log\")\n calledName = funcNode.text;\n }\n\n if (calledName) {\n analysis.edges.push(\n this.createEdge(\"calls\", parentId, `ref:${calledName}`, {\n unresolvedName: calledName,\n line: node.startPosition.row + 1,\n })\n );\n }\n }\n\n private handleVariable(\n node: Parser.SyntaxNode,\n filePath: string,\n analysis: FileAnalysis,\n parentId: string\n ): void {\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\n if (nameNode && nameNode.type === \"identifier\") {\n // Check if it's a function expression or arrow function\n if (\n valueNode &&\n (valueNode.type === \"arrow_function\" ||\n valueNode.type === \"function_expression\")\n ) {\n const funcNode = this.createNode(\n \"function\",\n nameNode.text,\n filePath,\n node.startPosition.row + 1,\n node.endPosition.row + 1,\n {\n kind: node.children[0]?.text || \"const\",\n }\n );\n analysis.nodes.push(funcNode);\n analysis.edges.push(\n this.createEdge(\"contains\", parentId, funcNode.id)\n );\n }\n }\n }\n }\n }\n}\n\nexport class JavaScriptParser extends TypeScriptParser {\n language = \"javascript\";\n extensions = [\".js\", \".jsx\", \".mjs\", \".cjs\"];\n\n constructor() {\n super();\n // Override to use JavaScript grammar\n (this as any).parser = new Parser();\n (this as any).parser.setLanguage(JavaScript);\n }\n\n parse(filePath: string, content: string): FileAnalysis {\n // Use base implementation but mark as javascript\n const analysis = super.parse(filePath, content);\n analysis.language = \"javascript\";\n for (const node of analysis.nodes) {\n node.language = \"javascript\";\n }\n return analysis;\n }\n}\n","/**\n * Python parser using Tree-sitter\n */\n\nimport Parser from \"tree-sitter\";\nimport Python from \"tree-sitter-python\";\nimport { BaseParser } from \"./base.js\";\nimport type { FileAnalysis, GraphNode, GraphEdge, ImportInfo, ExportInfo } from \"../types.js\";\n\nexport class PythonParser extends BaseParser {\n language = \"python\";\n extensions = [\".py\"];\n\n private parser: Parser;\n\n constructor() {\n super();\n this.parser = new Parser();\n this.parser.setLanguage(Python);\n }\n\n parse(filePath: string, content: string): FileAnalysis {\n const analysis = this.createEmptyAnalysis(filePath);\n const tree = this.parser.parse(content);\n const lines = content.split(\"\\n\");\n\n // Create file node\n const fileNode = this.createNode(\n \"file\",\n filePath.split(\"/\").pop() || filePath,\n filePath,\n 1,\n lines.length\n );\n analysis.nodes.push(fileNode);\n\n // Walk the tree\n this.walkTree(tree.rootNode, filePath, analysis, fileNode.id);\n\n return analysis;\n }\n\n private walkTree(\n node: Parser.SyntaxNode,\n filePath: string,\n analysis: FileAnalysis,\n parentId: string\n ): void {\n switch (node.type) {\n case \"import_statement\":\n this.handleImport(node, analysis);\n break;\n\n case \"import_from_statement\":\n this.handleFromImport(node, analysis);\n break;\n\n case \"function_definition\":\n this.handleFunction(node, filePath, analysis, parentId);\n return; // Don't recurse into function body for top-level analysis\n\n case \"class_definition\":\n this.handleClass(node, filePath, analysis, parentId);\n return; // Don't recurse, class handler will process methods\n\n case \"call\":\n this.handleCall(node, filePath, analysis, parentId);\n break;\n }\n\n // Recurse into children\n for (const child of node.children) {\n this.walkTree(child, filePath, analysis, parentId);\n }\n }\n\n private handleImport(node: Parser.SyntaxNode, analysis: FileAnalysis): void {\n // import foo, bar, baz\n for (const child of node.children) {\n if (child.type === \"dotted_name\") {\n analysis.imports.push({\n source: child.text,\n specifiers: [child.text.split(\".\").pop() || child.text],\n isDefault: false,\n isNamespace: true,\n line: node.startPosition.row + 1,\n });\n } else if (child.type === \"aliased_import\") {\n const nameNode = child.childForFieldName(\"name\");\n const aliasNode = child.childForFieldName(\"alias\");\n if (nameNode) {\n analysis.imports.push({\n source: nameNode.text,\n specifiers: [aliasNode?.text || nameNode.text],\n isDefault: false,\n isNamespace: true,\n line: node.startPosition.row + 1,\n });\n }\n }\n }\n }\n\n private handleFromImport(node: Parser.SyntaxNode, analysis: FileAnalysis): void {\n // from foo import bar, baz\n const moduleNode = node.childForFieldName(\"module_name\");\n if (!moduleNode) return;\n\n const source = moduleNode.text;\n const specifiers: string[] = [];\n\n for (const child of node.children) {\n if (child.type === \"import_prefix\") {\n // Handle relative imports (from . import x, from .. import y)\n continue;\n }\n\n if (child.type === \"dotted_name\" && child !== moduleNode) {\n specifiers.push(child.text);\n } else if (child.type === \"aliased_import\") {\n const nameNode = child.childForFieldName(\"name\");\n if (nameNode) {\n specifiers.push(nameNode.text);\n }\n } else if (child.type === \"wildcard_import\") {\n specifiers.push(\"*\");\n }\n }\n\n if (specifiers.length === 0) {\n // Check for named imports in different structure\n for (const child of node.children) {\n if (child.type === \"import_list\" || child.type === \"import_from_specifier\") {\n for (const spec of child.children) {\n if (spec.type === \"dotted_name\" || spec.type === \"identifier\") {\n specifiers.push(spec.text);\n }\n }\n }\n }\n }\n\n analysis.imports.push({\n source,\n specifiers,\n isDefault: false,\n isNamespace: specifiers.includes(\"*\"),\n line: node.startPosition.row + 1,\n });\n }\n\n private handleFunction(\n node: Parser.SyntaxNode,\n filePath: string,\n analysis: FileAnalysis,\n parentId: string\n ): void {\n const nameNode = node.childForFieldName(\"name\");\n if (!nameNode) return;\n\n const name = nameNode.text;\n\n // Check for decorators\n const decorators: string[] = [];\n let currentNode = node.previousSibling;\n while (currentNode?.type === \"decorator\") {\n const decoratorName = currentNode.children.find(\n (c) => c.type === \"identifier\" || c.type === \"attribute\"\n );\n if (decoratorName) {\n decorators.push(decoratorName.text);\n }\n currentNode = currentNode.previousSibling;\n }\n\n // Check if async\n const isAsync = node.children.some((c) => c.type === \"async\");\n\n const funcNode = this.createNode(\n \"function\",\n name,\n filePath,\n node.startPosition.row + 1,\n node.endPosition.row + 1,\n {\n async: isAsync,\n decorators,\n isPrivate: name.startsWith(\"_\"),\n isDunder: name.startsWith(\"__\") && name.endsWith(\"__\"),\n }\n );\n\n analysis.nodes.push(funcNode);\n analysis.edges.push(this.createEdge(\"contains\", parentId, funcNode.id));\n\n // Parse function body for calls\n const body = node.childForFieldName(\"body\");\n if (body) {\n this.parseBodyForCalls(body, filePath, analysis, funcNode.id);\n }\n\n // If not private, consider it exported\n if (!name.startsWith(\"_\")) {\n analysis.exports.push({\n name,\n isDefault: false,\n line: node.startPosition.row + 1,\n });\n }\n }\n\n private handleClass(\n node: Parser.SyntaxNode,\n filePath: string,\n analysis: FileAnalysis,\n parentId: string\n ): void {\n const nameNode = node.childForFieldName(\"name\");\n if (!nameNode) return;\n\n const name = nameNode.text;\n\n // Check for base classes\n const bases: string[] = [];\n const argumentList = node.children.find((c) => c.type === \"argument_list\");\n if (argumentList) {\n for (const arg of argumentList.children) {\n if (arg.type === \"identifier\" || arg.type === \"attribute\") {\n bases.push(arg.text);\n }\n }\n }\n\n const classNode = this.createNode(\n \"class\",\n name,\n filePath,\n node.startPosition.row + 1,\n node.endPosition.row + 1,\n {\n bases,\n isPrivate: name.startsWith(\"_\"),\n }\n );\n\n analysis.nodes.push(classNode);\n analysis.edges.push(this.createEdge(\"contains\", parentId, classNode.id));\n\n // Add extends edges\n for (const base of bases) {\n analysis.edges.push(\n this.createEdge(\"extends\", classNode.id, `ref:${base}`, {\n unresolvedName: base,\n })\n );\n }\n\n // Parse class body for methods\n const body = node.childForFieldName(\"body\");\n if (body) {\n for (const child of body.children) {\n if (child.type === \"function_definition\") {\n this.handleMethod(child, filePath, analysis, classNode.id);\n }\n }\n }\n\n // Consider non-private classes as exports\n if (!name.startsWith(\"_\")) {\n analysis.exports.push({\n name,\n isDefault: false,\n line: node.startPosition.row + 1,\n });\n }\n }\n\n private handleMethod(\n node: Parser.SyntaxNode,\n filePath: string,\n analysis: FileAnalysis,\n classId: string\n ): void {\n const nameNode = node.childForFieldName(\"name\");\n if (!nameNode) return;\n\n const name = nameNode.text;\n\n // Check for decorators\n const decorators: string[] = [];\n let currentNode = node.previousSibling;\n while (currentNode?.type === \"decorator\") {\n const decoratorName = currentNode.children.find(\n (c) => c.type === \"identifier\" || c.type === \"attribute\"\n );\n if (decoratorName) {\n decorators.push(decoratorName.text);\n }\n currentNode = currentNode.previousSibling;\n }\n\n const isStatic = decorators.includes(\"staticmethod\");\n const isClassMethod = decorators.includes(\"classmethod\");\n const isProperty = decorators.includes(\"property\");\n const isAsync = node.children.some((c) => c.type === \"async\");\n\n const methodNode = this.createNode(\n \"method\",\n name,\n filePath,\n node.startPosition.row + 1,\n node.endPosition.row + 1,\n {\n async: isAsync,\n decorators,\n static: isStatic,\n classmethod: isClassMethod,\n property: isProperty,\n isPrivate: name.startsWith(\"_\"),\n isDunder: name.startsWith(\"__\") && name.endsWith(\"__\"),\n }\n );\n\n analysis.nodes.push(methodNode);\n analysis.edges.push(this.createEdge(\"contains\", classId, methodNode.id));\n\n // Parse method body for calls\n const body = node.childForFieldName(\"body\");\n if (body) {\n this.parseBodyForCalls(body, filePath, analysis, methodNode.id);\n }\n }\n\n private handleCall(\n node: Parser.SyntaxNode,\n filePath: string,\n analysis: FileAnalysis,\n parentId: string\n ): void {\n const funcNode = node.childForFieldName(\"function\");\n if (!funcNode) return;\n\n let calledName = \"\";\n if (funcNode.type === \"identifier\") {\n calledName = funcNode.text;\n } else if (funcNode.type === \"attribute\") {\n // Get the full attribute access (e.g., \"self.method\", \"module.func\")\n calledName = funcNode.text;\n }\n\n if (calledName && !calledName.startsWith(\"self.\")) {\n // Skip self.x calls as they're internal\n analysis.edges.push(\n this.createEdge(\"calls\", parentId, `ref:${calledName}`, {\n unresolvedName: calledName,\n line: node.startPosition.row + 1,\n })\n );\n }\n }\n\n private parseBodyForCalls(\n body: Parser.SyntaxNode,\n filePath: string,\n analysis: FileAnalysis,\n parentId: string\n ): void {\n const walkForCalls = (node: Parser.SyntaxNode): void => {\n if (node.type === \"call\") {\n this.handleCall(node, filePath, analysis, parentId);\n }\n for (const child of node.children) {\n walkForCalls(child);\n }\n };\n walkForCalls(body);\n }\n}\n","/**\n * Parser registry and exports\n */\n\nexport { BaseParser, ParserRegistry, parserRegistry } from \"./base.js\";\nexport { TypeScriptParser, JavaScriptParser } from \"./typescript.js\";\nexport { PythonParser } from \"./python.js\";\n\nimport { parserRegistry } from \"./base.js\";\nimport { TypeScriptParser, JavaScriptParser } from \"./typescript.js\";\nimport { PythonParser } from \"./python.js\";\n\n// Register all parsers\nexport function registerAllParsers(): void {\n parserRegistry.register(new TypeScriptParser());\n parserRegistry.register(new JavaScriptParser());\n parserRegistry.register(new PythonParser());\n}\n\n// Auto-register on import\nregisterAllParsers();\n","/**\n * Skill Generator - Creates Claude Code skills based on codebase analysis\n */\n\nimport { mkdirSync, writeFileSync, existsSync } from \"fs\";\nimport { join, dirname, basename } from \"path\";\nimport { GraphStorage } from \"../graph/storage.js\";\nimport type { GeneratedSkill, SkillConfig } from \"../types.js\";\n\nexport class SkillGenerator {\n private storage: GraphStorage;\n private config: SkillConfig;\n\n constructor(storage: GraphStorage, config: SkillConfig) {\n this.storage = storage;\n this.config = config;\n }\n\n /**\n * Generate all skills and write to .claude/skills/\n */\n generateAll(): GeneratedSkill[] {\n const skills: GeneratedSkill[] = [];\n\n // 1. Architecture overview skill\n if (this.config.includeArchitecture) {\n skills.push(this.generateArchitectureSkill());\n }\n\n // 2. Codebase patterns skill\n if (this.config.includePatterns) {\n skills.push(this.generatePatternsSkill());\n }\n\n // 3. Dependency explorer skill\n if (this.config.includeDependencies) {\n skills.push(this.generateDependencySkill());\n }\n\n // 4. Impact analysis skill (always generate)\n skills.push(this.generateImpactAnalysisSkill());\n\n // 5. Code navigation skill (always generate)\n skills.push(this.generateNavigationSkill());\n\n // Write all skills to disk\n this.writeSkills(skills);\n\n return skills;\n }\n\n private generateArchitectureSkill(): GeneratedSkill {\n const stats = this.storage.getStats();\n const rootPath = this.storage.getMeta(\"rootPath\") || \"\";\n\n // Get file structure by analyzing paths\n const allNodes = this.storage.getNodesByType(\"file\");\n const directories = new Map<string, number>();\n\n for (const node of allNodes) {\n const relativePath = node.filePath.replace(rootPath, \"\").replace(/^\\//, \"\");\n const parts = relativePath.split(\"/\");\n if (parts.length > 1) {\n const topDir = parts[0];\n directories.set(topDir, (directories.get(topDir) || 0) + 1);\n }\n }\n\n // Sort directories by file count\n const sortedDirs = [...directories.entries()]\n .sort((a, b) => b[1] - a[1])\n .slice(0, 10);\n\n const dirList = sortedDirs\n .map(([dir, count]) => `- \\`${dir}/\\` (${count} files)`)\n .join(\"\\n\");\n\n const langList = Object.entries(stats.languages)\n .map(([lang, count]) => `- ${lang}: ${count} files`)\n .join(\"\\n\");\n\n const content = `---\nname: architecture\ndescription: Overview of ${this.config.projectName} architecture and structure\nuser-invocable: true\n---\n\n# ${this.config.projectName} Architecture\n\n## Project Statistics\n- **Total files**: ${stats.totalFiles}\n- **Functions/Methods**: ${stats.nodesByType.function || 0} functions, ${stats.nodesByType.method || 0} methods\n- **Classes**: ${stats.nodesByType.class || 0}\n- **Import relationships**: ${stats.edgesByType.imports || 0}\n- **Call relationships**: ${stats.edgesByType.calls || 0}\n\n## Languages\n${langList}\n\n## Directory Structure\n${dirList}\n\n## Key Patterns\nWhen working with this codebase:\n1. Check the main directories above for feature organization\n2. Use the \\`/impact\\` skill to understand changes\n3. Use the \\`/navigate\\` skill to find specific code\n\n## Getting Started\nTo understand a specific area, ask questions like:\n- \"What does the ${sortedDirs[0]?.[0] || \"src\"} directory contain?\"\n- \"How is authentication handled?\"\n- \"What are the main entry points?\"\n`;\n\n return {\n name: \"architecture\",\n description: `Overview of ${this.config.projectName} architecture`,\n content,\n filePath: join(this.config.outputDir, \"architecture\", \"SKILL.md\"),\n };\n }\n\n private generatePatternsSkill(): GeneratedSkill {\n const stats = this.storage.getStats();\n\n // Analyze common patterns from the graph\n const classes = this.storage.getNodesByType(\"class\");\n const functions = this.storage.getNodesByType(\"function\");\n\n // Find classes with many methods (likely important)\n const classDetails = classes.map((cls) => {\n const methods = this.storage.getEdgesFrom(cls.id).filter((e) => e.type === \"contains\");\n return { ...cls, methodCount: methods.length };\n }).sort((a, b) => b.methodCount - a.methodCount);\n\n const topClasses = classDetails.slice(0, 5);\n const classList = topClasses\n .map((c) => `- \\`${c.name}\\` (${c.methodCount} methods) - [${basename(c.filePath)}](${c.filePath}#L${c.startLine})`)\n .join(\"\\n\");\n\n // Find most-called functions\n const callEdges = this.storage.getEdgesByType(\"calls\");\n const callCounts = new Map<string, number>();\n for (const edge of callEdges) {\n const target = edge.targetId.replace(\"ref:\", \"\");\n callCounts.set(target, (callCounts.get(target) || 0) + 1);\n }\n\n const mostCalled = [...callCounts.entries()]\n .sort((a, b) => b[1] - a[1])\n .slice(0, 10);\n\n const calledList = mostCalled\n .map(([name, count]) => `- \\`${name}\\` (called ${count} times)`)\n .join(\"\\n\");\n\n const content = `---\nname: patterns\ndescription: Common patterns and conventions in ${this.config.projectName}\n---\n\n# Codebase Patterns\n\n## Key Classes\nThese are the most substantial classes in the codebase:\n${classList || \"No classes found\"}\n\n## Most Used Functions\nThese functions are called most frequently:\n${calledList || \"No call data available\"}\n\n## Conventions Detected\n\n### File Organization\n${stats.nodesByType.file ? `- ${stats.totalFiles} files organized across the project` : \"\"}\n${stats.languages.typescript ? \"- TypeScript is used for type safety\" : \"\"}\n${stats.languages.python ? \"- Python follows standard module patterns\" : \"\"}\n\n### Code Structure\n- Functions: ${stats.nodesByType.function || 0}\n- Classes: ${stats.nodesByType.class || 0}\n- Methods: ${stats.nodesByType.method || 0}\n\n## When Making Changes\n1. Follow existing naming conventions\n2. Check similar files for patterns\n3. Use \\`/impact\\` to verify affected areas\n`;\n\n return {\n name: \"patterns\",\n description: `Common patterns in ${this.config.projectName}`,\n content,\n filePath: join(this.config.outputDir, \"patterns\", \"SKILL.md\"),\n };\n }\n\n private generateDependencySkill(): GeneratedSkill {\n const content = `---\nname: dependencies\ndescription: Explore dependencies and imports in ${this.config.projectName}\ncontext: fork\nagent: Explore\n---\n\n# Dependency Explorer\n\nWhen analyzing dependencies for $ARGUMENTS:\n\n## Steps\n1. **Find the target file/module**\n - Search for files matching the query\n - Identify the main module or component\n\n2. **Analyze imports**\n - What does this file import?\n - Are there circular dependencies?\n\n3. **Analyze dependents**\n - What files import this module?\n - How deep is the dependency chain?\n\n4. **Provide summary**\n - List direct dependencies\n - List files that depend on this\n - Highlight any concerns (circular deps, too many dependents)\n\n## Query the CodeMap database\nIf the codemap MCP server is available, use these queries:\n- Get imports: Query the imports table for the file\n- Get dependents: Find files that import this module\n- Get call graph: Find functions that call into this module\n\n## Output Format\n\\`\\`\\`\nDependencies for [target]:\n\nIMPORTS (what this uses):\n- module1 (from ./path)\n- module2 (from package)\n\nIMPORTED BY (what uses this):\n- file1.ts (lines X-Y)\n- file2.ts (lines X-Y)\n\nDEPENDENCY DEPTH: N levels\n\\`\\`\\`\n`;\n\n return {\n name: \"dependencies\",\n description: `Explore dependencies in ${this.config.projectName}`,\n content,\n filePath: join(this.config.outputDir, \"dependencies\", \"SKILL.md\"),\n };\n }\n\n private generateImpactAnalysisSkill(): GeneratedSkill {\n const content = `---\nname: impact\ndescription: Analyze the impact of changes to a file or function\ndisable-model-invocation: true\n---\n\n# Impact Analysis\n\nAnalyze what would be affected by changes to $ARGUMENTS.\n\n## Analysis Steps\n\n1. **Identify the target**\n - Find the file, function, or class being modified\n - Note its current state and purpose\n\n2. **Find direct dependents**\n - What files import this module?\n - What functions call this function?\n - What classes extend this class?\n\n3. **Find indirect dependents**\n - Follow the chain: if A depends on B, and B is our target, A is affected\n - Go up to 3 levels deep\n\n4. **Categorize impact**\n - **Breaking changes**: Signature changes, removed exports\n - **Behavioral changes**: Logic changes that may affect callers\n - **Safe changes**: Internal refactors, added functionality\n\n5. **Generate checklist**\n\n## Output Format\n\n\\`\\`\\`markdown\n# Impact Analysis: [target]\n\n## Direct Impact\n- [ ] file1.ts - uses [specific function/import]\n- [ ] file2.ts - extends [class]\n\n## Indirect Impact\n- [ ] file3.ts - imports file1.ts which uses [target]\n\n## Recommended Actions\n1. Update tests in [test files]\n2. Check [specific callers] for compatibility\n3. Update documentation in [docs]\n\n## Risk Level: [LOW/MEDIUM/HIGH]\n[Explanation of risk assessment]\n\\`\\`\\`\n`;\n\n return {\n name: \"impact\",\n description: \"Analyze impact of code changes\",\n content,\n filePath: join(this.config.outputDir, \"impact\", \"SKILL.md\"),\n };\n }\n\n private generateNavigationSkill(): GeneratedSkill {\n const stats = this.storage.getStats();\n\n const content = `---\nname: navigate\ndescription: Navigate to specific code in ${this.config.projectName}\n---\n\n# Code Navigation\n\nFind and navigate to code matching $ARGUMENTS.\n\n## Available Queries\n\n### By Type\n- \"find class [name]\" - Locate a class definition\n- \"find function [name]\" - Locate a function\n- \"find file [pattern]\" - Find files matching pattern\n- \"find imports of [module]\" - Find all imports of a module\n\n### By Relationship\n- \"callers of [function]\" - Who calls this function?\n- \"callees of [function]\" - What does this function call?\n- \"subclasses of [class]\" - Classes that extend this\n- \"implementers of [interface]\" - Classes implementing interface\n\n### By Location\n- \"in [directory]\" - Filter to specific directory\n- \"in [file]\" - Show contents of file\n\n## Codebase Stats\n- ${stats.totalFiles} files to search\n- ${stats.nodesByType.function || 0} functions\n- ${stats.nodesByType.class || 0} classes\n- ${stats.nodesByType.method || 0} methods\n\n## Output Format\nFor each match, provide:\n- File path with line number link\n- Brief description of what it does\n- Related code (callers/callees if relevant)\n`;\n\n return {\n name: \"navigate\",\n description: `Navigate ${this.config.projectName} codebase`,\n content,\n filePath: join(this.config.outputDir, \"navigate\", \"SKILL.md\"),\n };\n }\n\n private writeSkills(skills: GeneratedSkill[]): void {\n for (const skill of skills) {\n const dir = dirname(skill.filePath);\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n writeFileSync(skill.filePath, skill.content, \"utf-8\");\n }\n }\n}\n","/**\n * CodeMap - AI-powered codebase knowledge graph generator\n *\n * Main entry point for programmatic usage\n */\n\n// Re-export all public APIs\nexport * from \"./types.js\";\nexport * from \"./graph/index.js\";\nexport * from \"./parsers/index.js\";\nexport * from \"./skills/index.js\";\n\n// Convenience function for quick scanning\nimport { resolve, join } from \"path\";\nimport { existsSync, mkdirSync } from \"fs\";\nimport { GraphBuilder, GraphStorage } from \"./graph/index.js\";\nimport { SkillGenerator } from \"./skills/index.js\";\nimport { DEFAULT_CONFIG } from \"./types.js\";\nimport type { CodeMapConfig, ProjectAnalysis, GeneratedSkill } from \"./types.js\";\n\n// Register parsers\nimport \"./parsers/index.js\";\n\nexport interface ScanResult {\n analysis: ProjectAnalysis;\n dbPath: string;\n}\n\nexport interface ScanAndGenerateResult extends ScanResult {\n skills: GeneratedSkill[];\n}\n\n/**\n * Scan a codebase and build the knowledge graph\n */\nexport async function scan(\n projectPath: string,\n options: Partial<CodeMapConfig> = {}\n): Promise<ScanResult> {\n const rootPath = resolve(projectPath);\n const outputDir = resolve(rootPath, \".codemap\");\n\n if (!existsSync(outputDir)) {\n mkdirSync(outputDir, { recursive: true });\n }\n\n const dbPath = join(outputDir, \"graph.db\");\n const storage = new GraphStorage(dbPath);\n\n const config: CodeMapConfig = {\n rootPath,\n include: options.include || DEFAULT_CONFIG.include!,\n exclude: options.exclude || DEFAULT_CONFIG.exclude!,\n languages: options.languages || DEFAULT_CONFIG.languages!,\n dbPath,\n skillsOutputDir: options.skillsOutputDir || join(rootPath, \".claude\", \"skills\", \"codemap\"),\n };\n\n const builder = new GraphBuilder(storage, config);\n const analysis = await builder.scan();\n\n storage.close();\n\n return { analysis, dbPath };\n}\n\n/**\n * Generate Claude Code skills from an existing graph\n */\nexport function generateSkills(\n projectPath: string,\n projectName?: string\n): GeneratedSkill[] {\n const rootPath = resolve(projectPath);\n const dbPath = join(rootPath, \".codemap\", \"graph.db\");\n\n if (!existsSync(dbPath)) {\n throw new Error(\"No graph database found. Run scan() first.\");\n }\n\n const outputDir = join(rootPath, \".claude\", \"skills\", \"codemap\");\n const storage = new GraphStorage(dbPath);\n\n const generator = new SkillGenerator(storage, {\n projectName: projectName || rootPath.split(\"/\").pop() || \"project\",\n outputDir,\n includeArchitecture: true,\n includePatterns: true,\n includeDependencies: true,\n });\n\n const skills = generator.generateAll();\n storage.close();\n\n return skills;\n}\n\n/**\n * Scan a codebase and generate skills in one step\n */\nexport async function scanAndGenerate(\n projectPath: string,\n projectName?: string,\n options: Partial<CodeMapConfig> = {}\n): Promise<ScanAndGenerateResult> {\n const scanResult = await scan(projectPath, options);\n const skills = generateSkills(projectPath, projectName);\n\n return {\n ...scanResult,\n skills,\n };\n}\n"],"mappings":";;;;;AA6HO,IAAM,iBAAyC;AAAA,EACpD,SAAS,CAAC,WAAW,YAAY,WAAW,YAAY,SAAS;AAAA,EACjE,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,WAAW,CAAC,cAAc,cAAc,QAAQ;AAClD;;;ACrIA,SAAS,oBAA8B;AACvC,SAAS,YAAY;AACrB,SAAe,UAAU,eAAe;;;ACMjC,IAAe,aAAf,MAA4C;AAAA,EAIvC,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAIhB,eAAe,UAAkB,MAAc,MAAsB;AAC7E,WAAO,GAAG,QAAQ,IAAI,IAAI,IAAI,IAAI;AAAA,EACpC;AAAA,EAEU,iBAAyB;AACjC,WAAO,QAAQ,EAAE,KAAK,aAAa;AAAA,EACrC;AAAA,EAEU,WACR,MACA,MACA,UACA,WACA,SACA,UACW;AACX,WAAO;AAAA,MACL,IAAI,KAAK,eAAe,UAAU,MAAM,SAAS;AAAA,MACjD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,KAAK;AAAA,MACf;AAAA,IACF;AAAA,EACF;AAAA,EAEU,WACR,MACA,UACA,UACA,UACW;AACX,WAAO;AAAA,MACL,IAAI,KAA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AG;AACvB,UAAM,IAAI,MAAM,4CAA4C;AAAA,EAC9D;AAEA,QAAM,YAAYE,MAAK,UAAU,WAAW,UAAU,SAAS;AAC/D,QAAM,UAAU,IAAI,aAAa,MAAM;AAEvC,QAAM,YAAY,IAAI,eAAe,SAAS;AAAA,IAC5C,aAAa,eAAe,SAAS,MAAM,GAAG,EAAE,IAAI,KAAK;AAAA,IACzD;AAAA,IACA,qBAAqB;AAAA,IACrB,iBAAiB;AAAA,IACjB,qBAAqB;AAAA,EACvB,CAAC;AAED,QAAM,SAAS,UAAU,YAAY;AACrC,UAAQ,MAAM;AAEd,SAAO;AACT;AAKA,eAAsB,gBACpB,aACA,aACA,UAAkC,CAAC,GACH;AAChC,QAAM,aAAa,MAAM,KAAK,aAAa,OAAO;AAClD,QAAM,SAAS,eAAe,aAAa,WAAW;AAEtD,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,EACF;AACF;","names":["Parser","Parser","join","resolve","join","existsSync","mkdirSync","resolve","existsSync","mkdirSync","join"]}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GraphStorage
|
|
3
|
+
} from "./chunk-FLUWKIEM.js";
|
|
4
|
+
|
|
5
|
+
// src/mcp/server.ts
|
|
6
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
7
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8
|
+
import {
|
|
9
|
+
CallToolRequestSchema,
|
|
10
|
+
ListToolsRequestSchema,
|
|
11
|
+
ListResourcesRequestSchema,
|
|
12
|
+
ReadResourceRequestSchema
|
|
13
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
14
|
+
import { resolve } from "path";
|
|
15
|
+
var DB_PATH = process.env.CODEMAP_DB_PATH || ".codemap/graph.db";
|
|
16
|
+
var PROJECT_ROOT = process.env.CODEMAP_PROJECT_ROOT || process.cwd();
|
|
17
|
+
var storage = null;
|
|
18
|
+
function getStorage() {
|
|
19
|
+
if (!storage) {
|
|
20
|
+
const dbPath = resolve(PROJECT_ROOT, DB_PATH);
|
|
21
|
+
storage = new GraphStorage(dbPath);
|
|
22
|
+
}
|
|
23
|
+
return storage;
|
|
24
|
+
}
|
|
25
|
+
var server = new Server(
|
|
26
|
+
{
|
|
27
|
+
name: "codemap",
|
|
28
|
+
version: "0.1.0"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
capabilities: {
|
|
32
|
+
tools: {},
|
|
33
|
+
resources: {}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
38
|
+
return {
|
|
39
|
+
tools: [
|
|
40
|
+
{
|
|
41
|
+
name: "codemap_search",
|
|
42
|
+
description: "Search for functions, classes, or files in the codebase",
|
|
43
|
+
inputSchema: {
|
|
44
|
+
type: "object",
|
|
45
|
+
properties: {
|
|
46
|
+
query: {
|
|
47
|
+
type: "string",
|
|
48
|
+
description: "Search query (function name, class name, or file pattern)"
|
|
49
|
+
},
|
|
50
|
+
type: {
|
|
51
|
+
type: "string",
|
|
52
|
+
enum: ["function", "class", "method", "file", "all"],
|
|
53
|
+
description: "Type of entity to search for",
|
|
54
|
+
default: "all"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
required: ["query"]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "codemap_callers",
|
|
62
|
+
description: "Find all functions/methods that call a specific function",
|
|
63
|
+
inputSchema: {
|
|
64
|
+
type: "object",
|
|
65
|
+
properties: {
|
|
66
|
+
functionName: {
|
|
67
|
+
type: "string",
|
|
68
|
+
description: "Name of the function to find callers for"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
required: ["functionName"]
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "codemap_dependencies",
|
|
76
|
+
description: "Get import/dependency information for a file",
|
|
77
|
+
inputSchema: {
|
|
78
|
+
type: "object",
|
|
79
|
+
properties: {
|
|
80
|
+
filePath: {
|
|
81
|
+
type: "string",
|
|
82
|
+
description: "Path to the file (relative or absolute)"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
required: ["filePath"]
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "codemap_impact",
|
|
90
|
+
description: "Analyze what files would be affected by changes to a file or function",
|
|
91
|
+
inputSchema: {
|
|
92
|
+
type: "object",
|
|
93
|
+
properties: {
|
|
94
|
+
target: {
|
|
95
|
+
type: "string",
|
|
96
|
+
description: "File path or function name to analyze"
|
|
97
|
+
},
|
|
98
|
+
depth: {
|
|
99
|
+
type: "number",
|
|
100
|
+
description: "How many levels of dependencies to follow (default: 2)",
|
|
101
|
+
default: 2
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
required: ["target"]
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "codemap_stats",
|
|
109
|
+
description: "Get statistics about the codebase",
|
|
110
|
+
inputSchema: {
|
|
111
|
+
type: "object",
|
|
112
|
+
properties: {}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "codemap_file_contents",
|
|
117
|
+
description: "Get all functions and classes defined in a file",
|
|
118
|
+
inputSchema: {
|
|
119
|
+
type: "object",
|
|
120
|
+
properties: {
|
|
121
|
+
filePath: {
|
|
122
|
+
type: "string",
|
|
123
|
+
description: "Path to the file"
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
required: ["filePath"]
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
133
|
+
const { name, arguments: args } = request.params;
|
|
134
|
+
const db = getStorage();
|
|
135
|
+
try {
|
|
136
|
+
switch (name) {
|
|
137
|
+
case "codemap_search": {
|
|
138
|
+
const query = args?.query;
|
|
139
|
+
const type = args?.type || "all";
|
|
140
|
+
let nodes = db.searchNodes(query);
|
|
141
|
+
if (type !== "all") {
|
|
142
|
+
nodes = nodes.filter((n) => n.type === type);
|
|
143
|
+
}
|
|
144
|
+
const results = nodes.slice(0, 20).map((n) => ({
|
|
145
|
+
name: n.name,
|
|
146
|
+
type: n.type,
|
|
147
|
+
file: n.filePath,
|
|
148
|
+
line: n.startLine,
|
|
149
|
+
language: n.language
|
|
150
|
+
}));
|
|
151
|
+
return {
|
|
152
|
+
content: [
|
|
153
|
+
{
|
|
154
|
+
type: "text",
|
|
155
|
+
text: JSON.stringify(results, null, 2)
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
case "codemap_callers": {
|
|
161
|
+
const functionName = args?.functionName;
|
|
162
|
+
const callers = db.getCallers(functionName);
|
|
163
|
+
const results = callers.map((n) => ({
|
|
164
|
+
name: n.name,
|
|
165
|
+
type: n.type,
|
|
166
|
+
file: n.filePath,
|
|
167
|
+
line: n.startLine
|
|
168
|
+
}));
|
|
169
|
+
return {
|
|
170
|
+
content: [
|
|
171
|
+
{
|
|
172
|
+
type: "text",
|
|
173
|
+
text: `Found ${results.length} callers of "${functionName}":
|
|
174
|
+
${JSON.stringify(results, null, 2)}`
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
case "codemap_dependencies": {
|
|
180
|
+
const filePath = args?.filePath;
|
|
181
|
+
const deps = db.getFileDependencies(filePath);
|
|
182
|
+
return {
|
|
183
|
+
content: [
|
|
184
|
+
{
|
|
185
|
+
type: "text",
|
|
186
|
+
text: `Dependencies for ${filePath}:
|
|
187
|
+
|
|
188
|
+
Imports:
|
|
189
|
+
${deps.imports.map((i) => ` - ${i}`).join("\n")}
|
|
190
|
+
|
|
191
|
+
Imported by:
|
|
192
|
+
${deps.importedBy.map((i) => ` - ${i}`).join("\n")}`
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
case "codemap_impact": {
|
|
198
|
+
const target = args?.target;
|
|
199
|
+
const depth = args?.depth || 2;
|
|
200
|
+
const nodes = db.searchNodes(target);
|
|
201
|
+
if (nodes.length === 0) {
|
|
202
|
+
return {
|
|
203
|
+
content: [{ type: "text", text: `No matches found for "${target}"` }]
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
const targetNode = nodes[0];
|
|
207
|
+
const affected = /* @__PURE__ */ new Set();
|
|
208
|
+
const queue = [{ id: targetNode.id, depth: 0 }];
|
|
209
|
+
const visited = /* @__PURE__ */ new Set();
|
|
210
|
+
while (queue.length > 0) {
|
|
211
|
+
const current = queue.shift();
|
|
212
|
+
if (visited.has(current.id) || current.depth > depth) continue;
|
|
213
|
+
visited.add(current.id);
|
|
214
|
+
const incomingEdges = db.getEdgesTo(current.id);
|
|
215
|
+
for (const edge of incomingEdges) {
|
|
216
|
+
const sourceNode = db.getNode(edge.sourceId);
|
|
217
|
+
if (sourceNode) {
|
|
218
|
+
affected.add(sourceNode.filePath);
|
|
219
|
+
if (current.depth < depth) {
|
|
220
|
+
queue.push({ id: sourceNode.id, depth: current.depth + 1 });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (targetNode.type === "file" || targetNode.type === "function") {
|
|
225
|
+
const importers = db.getFilesThatImport(targetNode.filePath);
|
|
226
|
+
for (const importer of importers) {
|
|
227
|
+
affected.add(importer);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const affectedList = [...affected].filter((f) => f !== targetNode.filePath);
|
|
232
|
+
return {
|
|
233
|
+
content: [
|
|
234
|
+
{
|
|
235
|
+
type: "text",
|
|
236
|
+
text: `Impact analysis for "${target}":
|
|
237
|
+
|
|
238
|
+
Target: ${targetNode.name} (${targetNode.type}) in ${targetNode.filePath}
|
|
239
|
+
|
|
240
|
+
Affected files (${affectedList.length}):
|
|
241
|
+
${affectedList.map((f) => ` - ${f}`).join("\n") || " (none found)"}`
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
case "codemap_stats": {
|
|
247
|
+
const stats = db.getStats();
|
|
248
|
+
const rootPath = db.getMeta("rootPath") || "unknown";
|
|
249
|
+
const analyzedAt = db.getMeta("analyzedAt") || "unknown";
|
|
250
|
+
return {
|
|
251
|
+
content: [
|
|
252
|
+
{
|
|
253
|
+
type: "text",
|
|
254
|
+
text: `CodeMap Statistics:
|
|
255
|
+
|
|
256
|
+
Project: ${rootPath}
|
|
257
|
+
Last analyzed: ${analyzedAt}
|
|
258
|
+
|
|
259
|
+
Files: ${stats.totalFiles}
|
|
260
|
+
Nodes: ${stats.totalNodes}
|
|
261
|
+
Edges: ${stats.totalEdges}
|
|
262
|
+
|
|
263
|
+
By type:
|
|
264
|
+
${Object.entries(stats.nodesByType).map(([t, c]) => ` - ${t}: ${c}`).join("\n")}
|
|
265
|
+
|
|
266
|
+
By language:
|
|
267
|
+
${Object.entries(stats.languages).map(([l, c]) => ` - ${l}: ${c}`).join("\n")}
|
|
268
|
+
|
|
269
|
+
Relationships:
|
|
270
|
+
${Object.entries(stats.edgesByType).map(([t, c]) => ` - ${t}: ${c}`).join("\n")}`
|
|
271
|
+
}
|
|
272
|
+
]
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
case "codemap_file_contents": {
|
|
276
|
+
const filePath = args?.filePath;
|
|
277
|
+
const nodes = db.getNodesByFile(filePath);
|
|
278
|
+
const contents = nodes.filter((n) => n.type !== "file").map((n) => ({
|
|
279
|
+
name: n.name,
|
|
280
|
+
type: n.type,
|
|
281
|
+
line: `${n.startLine}-${n.endLine}`,
|
|
282
|
+
metadata: n.metadata
|
|
283
|
+
}));
|
|
284
|
+
return {
|
|
285
|
+
content: [
|
|
286
|
+
{
|
|
287
|
+
type: "text",
|
|
288
|
+
text: `Contents of ${filePath}:
|
|
289
|
+
${JSON.stringify(contents, null, 2)}`
|
|
290
|
+
}
|
|
291
|
+
]
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
default:
|
|
295
|
+
return {
|
|
296
|
+
content: [{ type: "text", text: `Unknown tool: ${name}` }],
|
|
297
|
+
isError: true
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
} catch (error) {
|
|
301
|
+
return {
|
|
302
|
+
content: [
|
|
303
|
+
{
|
|
304
|
+
type: "text",
|
|
305
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
306
|
+
}
|
|
307
|
+
],
|
|
308
|
+
isError: true
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
313
|
+
return {
|
|
314
|
+
resources: [
|
|
315
|
+
{
|
|
316
|
+
uri: "codemap://stats",
|
|
317
|
+
name: "Codebase Statistics",
|
|
318
|
+
description: "Overview statistics of the analyzed codebase",
|
|
319
|
+
mimeType: "application/json"
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
uri: "codemap://graph",
|
|
323
|
+
name: "Dependency Graph",
|
|
324
|
+
description: "Full dependency graph for visualization",
|
|
325
|
+
mimeType: "application/json"
|
|
326
|
+
}
|
|
327
|
+
]
|
|
328
|
+
};
|
|
329
|
+
});
|
|
330
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
331
|
+
const { uri } = request.params;
|
|
332
|
+
const db = getStorage();
|
|
333
|
+
if (uri === "codemap://stats") {
|
|
334
|
+
const stats = db.getStats();
|
|
335
|
+
return {
|
|
336
|
+
contents: [
|
|
337
|
+
{
|
|
338
|
+
uri,
|
|
339
|
+
mimeType: "application/json",
|
|
340
|
+
text: JSON.stringify(stats, null, 2)
|
|
341
|
+
}
|
|
342
|
+
]
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
if (uri === "codemap://graph") {
|
|
346
|
+
const graph = db.exportForVisualization();
|
|
347
|
+
return {
|
|
348
|
+
contents: [
|
|
349
|
+
{
|
|
350
|
+
uri,
|
|
351
|
+
mimeType: "application/json",
|
|
352
|
+
text: JSON.stringify(graph, null, 2)
|
|
353
|
+
}
|
|
354
|
+
]
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
throw new Error(`Unknown resource: ${uri}`);
|
|
358
|
+
});
|
|
359
|
+
async function main() {
|
|
360
|
+
const transport = new StdioServerTransport();
|
|
361
|
+
await server.connect(transport);
|
|
362
|
+
console.error("CodeMap MCP server started");
|
|
363
|
+
}
|
|
364
|
+
main().catch(console.error);
|
|
365
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mcp/server.ts"],"sourcesContent":["/**\n * MCP Server for CodeMap - Integrates with Claude Code\n */\n\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n ListResourcesRequestSchema,\n ReadResourceRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { GraphStorage } from \"../graph/storage.js\";\nimport { resolve } from \"path\";\n\n// Get config from environment\nconst DB_PATH = process.env.CODEMAP_DB_PATH || \".codemap/graph.db\";\nconst PROJECT_ROOT = process.env.CODEMAP_PROJECT_ROOT || process.cwd();\n\nlet storage: GraphStorage | null = null;\n\nfunction getStorage(): GraphStorage {\n if (!storage) {\n const dbPath = resolve(PROJECT_ROOT, DB_PATH);\n storage = new GraphStorage(dbPath);\n }\n return storage;\n}\n\nconst server = new Server(\n {\n name: \"codemap\",\n version: \"0.1.0\",\n },\n {\n capabilities: {\n tools: {},\n resources: {},\n },\n }\n);\n\n// ============ Tools ============\n\nserver.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [\n {\n name: \"codemap_search\",\n description: \"Search for functions, classes, or files in the codebase\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description: \"Search query (function name, class name, or file pattern)\",\n },\n type: {\n type: \"string\",\n enum: [\"function\", \"class\", \"method\", \"file\", \"all\"],\n description: \"Type of entity to search for\",\n default: \"all\",\n },\n },\n required: [\"query\"],\n },\n },\n {\n name: \"codemap_callers\",\n description: \"Find all functions/methods that call a specific function\",\n inputSchema: {\n type: \"object\",\n properties: {\n functionName: {\n type: \"string\",\n description: \"Name of the function to find callers for\",\n },\n },\n required: [\"functionName\"],\n },\n },\n {\n name: \"codemap_dependencies\",\n description: \"Get import/dependency information for a file\",\n inputSchema: {\n type: \"object\",\n properties: {\n filePath: {\n type: \"string\",\n description: \"Path to the file (relative or absolute)\",\n },\n },\n required: [\"filePath\"],\n },\n },\n {\n name: \"codemap_impact\",\n description: \"Analyze what files would be affected by changes to a file or function\",\n inputSchema: {\n type: \"object\",\n properties: {\n target: {\n type: \"string\",\n description: \"File path or function name to analyze\",\n },\n depth: {\n type: \"number\",\n description: \"How many levels of dependencies to follow (default: 2)\",\n default: 2,\n },\n },\n required: [\"target\"],\n },\n },\n {\n name: \"codemap_stats\",\n description: \"Get statistics about the codebase\",\n inputSchema: {\n type: \"object\",\n properties: {},\n },\n },\n {\n name: \"codemap_file_contents\",\n description: \"Get all functions and classes defined in a file\",\n inputSchema: {\n type: \"object\",\n properties: {\n filePath: {\n type: \"string\",\n description: \"Path to the file\",\n },\n },\n required: [\"filePath\"],\n },\n },\n ],\n };\n});\n\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n const db = getStorage();\n\n try {\n switch (name) {\n case \"codemap_search\": {\n const query = args?.query as string;\n const type = (args?.type as string) || \"all\";\n\n let nodes = db.searchNodes(query);\n if (type !== \"all\") {\n nodes = nodes.filter((n) => n.type === type);\n }\n\n const results = nodes.slice(0, 20).map((n) => ({\n name: n.name,\n type: n.type,\n file: n.filePath,\n line: n.startLine,\n language: n.language,\n }));\n\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(results, null, 2),\n },\n ],\n };\n }\n\n case \"codemap_callers\": {\n const functionName = args?.functionName as string;\n const callers = db.getCallers(functionName);\n\n const results = callers.map((n) => ({\n name: n.name,\n type: n.type,\n file: n.filePath,\n line: n.startLine,\n }));\n\n return {\n content: [\n {\n type: \"text\",\n text: `Found ${results.length} callers of \"${functionName}\":\\n${JSON.stringify(results, null, 2)}`,\n },\n ],\n };\n }\n\n case \"codemap_dependencies\": {\n const filePath = args?.filePath as string;\n const deps = db.getFileDependencies(filePath);\n\n return {\n content: [\n {\n type: \"text\",\n text: `Dependencies for ${filePath}:\\n\\nImports:\\n${deps.imports.map((i) => ` - ${i}`).join(\"\\n\")}\\n\\nImported by:\\n${deps.importedBy.map((i) => ` - ${i}`).join(\"\\n\")}`,\n },\n ],\n };\n }\n\n case \"codemap_impact\": {\n const target = args?.target as string;\n const depth = (args?.depth as number) || 2;\n\n // Find the target\n const nodes = db.searchNodes(target);\n if (nodes.length === 0) {\n return {\n content: [{ type: \"text\", text: `No matches found for \"${target}\"` }],\n };\n }\n\n const targetNode = nodes[0];\n const affected: Set<string> = new Set();\n\n // BFS to find affected files\n const queue: Array<{ id: string; depth: number }> = [{ id: targetNode.id, depth: 0 }];\n const visited = new Set<string>();\n\n while (queue.length > 0) {\n const current = queue.shift()!;\n if (visited.has(current.id) || current.depth > depth) continue;\n visited.add(current.id);\n\n // Find edges pointing to this node\n const incomingEdges = db.getEdgesTo(current.id);\n for (const edge of incomingEdges) {\n const sourceNode = db.getNode(edge.sourceId);\n if (sourceNode) {\n affected.add(sourceNode.filePath);\n if (current.depth < depth) {\n queue.push({ id: sourceNode.id, depth: current.depth + 1 });\n }\n }\n }\n\n // Also check file-level dependencies\n if (targetNode.type === \"file\" || targetNode.type === \"function\") {\n const importers = db.getFilesThatImport(targetNode.filePath);\n for (const importer of importers) {\n affected.add(importer);\n }\n }\n }\n\n const affectedList = [...affected].filter((f) => f !== targetNode.filePath);\n\n return {\n content: [\n {\n type: \"text\",\n text: `Impact analysis for \"${target}\":\\n\\nTarget: ${targetNode.name} (${targetNode.type}) in ${targetNode.filePath}\\n\\nAffected files (${affectedList.length}):\\n${affectedList.map((f) => ` - ${f}`).join(\"\\n\") || \" (none found)\"}`,\n },\n ],\n };\n }\n\n case \"codemap_stats\": {\n const stats = db.getStats();\n const rootPath = db.getMeta(\"rootPath\") || \"unknown\";\n const analyzedAt = db.getMeta(\"analyzedAt\") || \"unknown\";\n\n return {\n content: [\n {\n type: \"text\",\n text: `CodeMap Statistics:\n\nProject: ${rootPath}\nLast analyzed: ${analyzedAt}\n\nFiles: ${stats.totalFiles}\nNodes: ${stats.totalNodes}\nEdges: ${stats.totalEdges}\n\nBy type:\n${Object.entries(stats.nodesByType).map(([t, c]) => ` - ${t}: ${c}`).join(\"\\n\")}\n\nBy language:\n${Object.entries(stats.languages).map(([l, c]) => ` - ${l}: ${c}`).join(\"\\n\")}\n\nRelationships:\n${Object.entries(stats.edgesByType).map(([t, c]) => ` - ${t}: ${c}`).join(\"\\n\")}`,\n },\n ],\n };\n }\n\n case \"codemap_file_contents\": {\n const filePath = args?.filePath as string;\n const nodes = db.getNodesByFile(filePath);\n\n const contents = nodes\n .filter((n) => n.type !== \"file\")\n .map((n) => ({\n name: n.name,\n type: n.type,\n line: `${n.startLine}-${n.endLine}`,\n metadata: n.metadata,\n }));\n\n return {\n content: [\n {\n type: \"text\",\n text: `Contents of ${filePath}:\\n${JSON.stringify(contents, null, 2)}`,\n },\n ],\n };\n }\n\n default:\n return {\n content: [{ type: \"text\", text: `Unknown tool: ${name}` }],\n isError: true,\n };\n }\n } catch (error) {\n return {\n content: [\n {\n type: \"text\",\n text: `Error: ${error instanceof Error ? error.message : String(error)}`,\n },\n ],\n isError: true,\n };\n }\n});\n\n// ============ Resources ============\n\nserver.setRequestHandler(ListResourcesRequestSchema, async () => {\n return {\n resources: [\n {\n uri: \"codemap://stats\",\n name: \"Codebase Statistics\",\n description: \"Overview statistics of the analyzed codebase\",\n mimeType: \"application/json\",\n },\n {\n uri: \"codemap://graph\",\n name: \"Dependency Graph\",\n description: \"Full dependency graph for visualization\",\n mimeType: \"application/json\",\n },\n ],\n };\n});\n\nserver.setRequestHandler(ReadResourceRequestSchema, async (request) => {\n const { uri } = request.params;\n const db = getStorage();\n\n if (uri === \"codemap://stats\") {\n const stats = db.getStats();\n return {\n contents: [\n {\n uri,\n mimeType: \"application/json\",\n text: JSON.stringify(stats, null, 2),\n },\n ],\n };\n }\n\n if (uri === \"codemap://graph\") {\n const graph = db.exportForVisualization();\n return {\n contents: [\n {\n uri,\n mimeType: \"application/json\",\n text: JSON.stringify(graph, null, 2),\n },\n ],\n };\n }\n\n throw new Error(`Unknown resource: ${uri}`);\n});\n\n// ============ Main ============\n\nasync function main() {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n console.error(\"CodeMap MCP server started\");\n}\n\nmain().catch(console.error);\n"],"mappings":";;;;;AAIA,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,eAAe;AAGxB,IAAM,UAAU,QAAQ,IAAI,mBAAmB;AAC/C,IAAM,eAAe,QAAQ,IAAI,wBAAwB,QAAQ,IAAI;AAErE,IAAI,UAA+B;AAEnC,SAAS,aAA2B;AAClC,MAAI,CAAC,SAAS;AACZ,UAAM,SAAS,QAAQ,cAAc,OAAO;AAC5C,cAAU,IAAI,aAAa,MAAM;AAAA,EACnC;AACA,SAAO;AACT;AAEA,IAAM,SAAS,IAAI;AAAA,EACjB;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,cAAc;AAAA,MACZ,OAAO,CAAC;AAAA,MACR,WAAW,CAAC;AAAA,IACd;AAAA,EACF;AACF;AAIA,OAAO,kBAAkB,wBAAwB,YAAY;AAC3D,SAAO;AAAA,IACL,OAAO;AAAA,MACL;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