codemap-ai 0.2.0 → 3.0.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/LICENSE +21 -0
- package/README.md +257 -94
- package/dist/chunk-GX7ZMBC2.js +730 -0
- package/dist/chunk-GX7ZMBC2.js.map +1 -0
- package/dist/chunk-XNA2HNUR.js +733 -0
- package/dist/chunk-XNA2HNUR.js.map +1 -0
- package/dist/cli.js +636 -688
- package/dist/cli.js.map +1 -1
- package/dist/flow-server-QO7IWYLE.js +246 -0
- package/dist/flow-server-QO7IWYLE.js.map +1 -0
- package/dist/index.d.ts +167 -190
- package/dist/index.js +597 -485
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.js +144 -265
- package/dist/mcp-server.js.map +1 -1
- package/package.json +13 -17
- package/dist/chunk-5ONPBEWJ.js +0 -350
- package/dist/chunk-5ONPBEWJ.js.map +0 -1
- package/dist/chunk-FLUWKIEM.js +0 -347
- package/dist/chunk-FLUWKIEM.js.map +0 -1
- package/dist/server-3W7ZN3LX.js +0 -103
- package/dist/server-3W7ZN3LX.js.map +0 -1
- package/dist/server-TBIVIIUJ.js +0 -367
- package/dist/server-TBIVIIUJ.js.map +0 -1
- package/web/index.html +0 -639
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import Database from 'better-sqlite3';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Core types for CodeMap
|
|
3
5
|
*/
|
|
@@ -12,7 +14,7 @@ interface GraphNode {
|
|
|
12
14
|
language: string;
|
|
13
15
|
metadata?: Record<string, unknown>;
|
|
14
16
|
}
|
|
15
|
-
type EdgeType = "imports" | "calls" | "extends" | "implements" | "contains" | "uses" | "exports";
|
|
17
|
+
type EdgeType = "imports" | "calls" | "extends" | "implements" | "contains" | "uses" | "exports" | "depends";
|
|
16
18
|
interface GraphEdge {
|
|
17
19
|
id: string;
|
|
18
20
|
type: EdgeType;
|
|
@@ -27,6 +29,21 @@ interface FileAnalysis {
|
|
|
27
29
|
edges: GraphEdge[];
|
|
28
30
|
imports: ImportInfo[];
|
|
29
31
|
exports: ExportInfo[];
|
|
32
|
+
variableTypes?: VariableTypeInfo[];
|
|
33
|
+
databaseOperations?: DatabaseOperationInfo[];
|
|
34
|
+
}
|
|
35
|
+
interface VariableTypeInfo {
|
|
36
|
+
variableName: string;
|
|
37
|
+
typeName: string;
|
|
38
|
+
scopeId: string;
|
|
39
|
+
line: number;
|
|
40
|
+
}
|
|
41
|
+
interface DatabaseOperationInfo {
|
|
42
|
+
nodeId: string;
|
|
43
|
+
operation: string;
|
|
44
|
+
collection: string;
|
|
45
|
+
databaseType: string;
|
|
46
|
+
line: number;
|
|
30
47
|
}
|
|
31
48
|
interface ImportInfo {
|
|
32
49
|
source: string;
|
|
@@ -47,6 +64,7 @@ interface ProjectAnalysis {
|
|
|
47
64
|
totalEdges: number;
|
|
48
65
|
languages: Record<string, number>;
|
|
49
66
|
analyzedAt: string;
|
|
67
|
+
parseErrors?: string[];
|
|
50
68
|
}
|
|
51
69
|
interface AffectedFile {
|
|
52
70
|
filePath: string;
|
|
@@ -96,236 +114,195 @@ interface MCPResource {
|
|
|
96
114
|
}
|
|
97
115
|
|
|
98
116
|
/**
|
|
99
|
-
*
|
|
117
|
+
* Flow-focused storage for call graphs
|
|
118
|
+
* Simplified from graph/storage.ts with enhanced call resolution
|
|
100
119
|
*/
|
|
101
120
|
|
|
102
|
-
|
|
103
|
-
|
|
121
|
+
interface CallPath {
|
|
122
|
+
nodes: Array<{
|
|
123
|
+
id: string;
|
|
124
|
+
name: string;
|
|
125
|
+
file: string;
|
|
126
|
+
line: number;
|
|
127
|
+
}>;
|
|
128
|
+
edges: Array<{
|
|
129
|
+
from: string;
|
|
130
|
+
to: string;
|
|
131
|
+
type: string;
|
|
132
|
+
}>;
|
|
133
|
+
}
|
|
134
|
+
declare class FlowStorage {
|
|
135
|
+
db: Database.Database;
|
|
104
136
|
constructor(dbPath: string);
|
|
105
137
|
private initSchema;
|
|
106
|
-
insertNode(node: GraphNode
|
|
138
|
+
insertNode(node: GraphNode & {
|
|
139
|
+
hash?: string;
|
|
140
|
+
}): void;
|
|
107
141
|
getNode(id: string): GraphNode | null;
|
|
142
|
+
searchNodesByName(name: string): GraphNode[];
|
|
108
143
|
getNodesByFile(filePath: string): GraphNode[];
|
|
109
|
-
getNodesByType(type: string): GraphNode[];
|
|
110
|
-
searchNodes(query: string): GraphNode[];
|
|
111
|
-
getAllNodes(): GraphNode[];
|
|
112
144
|
private rowToNode;
|
|
113
145
|
insertEdge(edge: GraphEdge): void;
|
|
114
|
-
getEdgesFrom(sourceId: string): GraphEdge[];
|
|
115
|
-
getEdgesTo(targetId: string): GraphEdge[];
|
|
116
|
-
getEdgesByType(type: string): GraphEdge[];
|
|
117
|
-
getAllEdges(): GraphEdge[];
|
|
118
|
-
private rowToEdge;
|
|
119
|
-
insertFileAnalysis(analysis: FileAnalysis): void;
|
|
120
|
-
deleteFileData(filePath: string): void;
|
|
121
146
|
/**
|
|
122
|
-
* Get all
|
|
147
|
+
* Get all resolved callees (functions this node calls)
|
|
123
148
|
*/
|
|
124
|
-
|
|
149
|
+
getResolvedCallees(nodeId: string): GraphNode[];
|
|
125
150
|
/**
|
|
126
|
-
* Get all callers
|
|
151
|
+
* Get all resolved callers (functions that call this node)
|
|
127
152
|
*/
|
|
128
|
-
|
|
153
|
+
getResolvedCallers(nodeId: string): GraphNode[];
|
|
129
154
|
/**
|
|
130
|
-
* Get all
|
|
155
|
+
* Get impact: all nodes affected by changes to this node (BFS traversal)
|
|
131
156
|
*/
|
|
132
|
-
|
|
133
|
-
name: string;
|
|
134
|
-
line?: number;
|
|
135
|
-
}[];
|
|
157
|
+
getImpactedNodes(nodeId: string, maxDepth?: number): GraphNode[];
|
|
136
158
|
/**
|
|
137
|
-
*
|
|
159
|
+
* Trace call path from source to target using BFS
|
|
138
160
|
*/
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
161
|
+
traceCallPath(fromId: string, toId: string): CallPath | null;
|
|
162
|
+
registerExport(filePath: string, symbolName: string, nodeId: string): void;
|
|
163
|
+
registerImport(filePath: string, symbol: string, fromModule: string, line: number): void;
|
|
164
|
+
resolveImport(filePath: string, symbol: string): string | null;
|
|
165
|
+
/**
|
|
166
|
+
* Resolve a Python module path to possible file paths
|
|
167
|
+
* Handles: absolute imports, relative imports, __init__.py
|
|
168
|
+
*/
|
|
169
|
+
private resolvePythonModulePath;
|
|
170
|
+
/**
|
|
171
|
+
* Resolve a class method call like ClassName.method_name
|
|
172
|
+
* Handles: static methods, class methods, imported classes
|
|
173
|
+
*/
|
|
174
|
+
resolveClassMethod(className: string, methodName: string, callerFilePath: string): string | null;
|
|
175
|
+
/**
|
|
176
|
+
* Register a variable type (from assignment or parameter)
|
|
177
|
+
*/
|
|
178
|
+
registerVariableType(variableName: string, typeName: string, scopeNodeId: string, filePath: string, line: number, isParameter?: boolean): void;
|
|
179
|
+
/**
|
|
180
|
+
* Resolve variable.method to actual method node
|
|
181
|
+
* Example: user.get_name() where user is of type User
|
|
182
|
+
*/
|
|
183
|
+
resolveVariableMethod(variableName: string, methodName: string, scopeNodeId: string): string | null;
|
|
184
|
+
/**
|
|
185
|
+
* Resolve self.method() calls to methods in the same class
|
|
186
|
+
*/
|
|
187
|
+
private resolveSelfMethod;
|
|
143
188
|
/**
|
|
144
|
-
*
|
|
189
|
+
* Resolve super().method() calls to parent class methods
|
|
145
190
|
*/
|
|
191
|
+
resolveSuperMethod(methodName: string, scopeNodeId: string): string | null;
|
|
192
|
+
upsertFile(filePath: string, language: string, hash: string): void;
|
|
193
|
+
getFileHash(filePath: string): string | null;
|
|
194
|
+
deleteFileData(filePath: string): void;
|
|
146
195
|
getStats(): {
|
|
147
196
|
totalFiles: number;
|
|
148
197
|
totalNodes: number;
|
|
149
198
|
totalEdges: number;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
199
|
+
resolvedCalls: number;
|
|
200
|
+
unresolvedCalls: number;
|
|
201
|
+
httpEndpoints: number;
|
|
202
|
+
frameworkDependencies: number;
|
|
203
|
+
resolvedDependencies: number;
|
|
204
|
+
containers: number;
|
|
153
205
|
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
edges: Array<{
|
|
162
|
-
source: string;
|
|
163
|
-
target: string;
|
|
164
|
-
type: string;
|
|
206
|
+
insertContainer(container: {
|
|
207
|
+
id: string;
|
|
208
|
+
name: string;
|
|
209
|
+
image?: string;
|
|
210
|
+
ports?: Array<{
|
|
211
|
+
host: number;
|
|
212
|
+
container: number;
|
|
165
213
|
}>;
|
|
166
|
-
|
|
214
|
+
environment?: Record<string, string>;
|
|
215
|
+
depends_on?: string[];
|
|
216
|
+
networks?: string[];
|
|
217
|
+
metadata?: Record<string, unknown>;
|
|
218
|
+
}): void;
|
|
219
|
+
getContainer(id: string): any | null;
|
|
220
|
+
getAllContainers(): any[];
|
|
221
|
+
insertHttpEndpoint(endpoint: {
|
|
222
|
+
id: string;
|
|
223
|
+
method: string;
|
|
224
|
+
path: string;
|
|
225
|
+
handler_node_id?: string;
|
|
226
|
+
container_id?: string;
|
|
227
|
+
middleware?: string[];
|
|
228
|
+
metadata?: Record<string, unknown>;
|
|
229
|
+
}): void;
|
|
230
|
+
insertDatabaseOperation(dbOp: {
|
|
231
|
+
id: string;
|
|
232
|
+
node_id: string;
|
|
233
|
+
database_type: string;
|
|
234
|
+
operation: string;
|
|
235
|
+
collection?: string;
|
|
236
|
+
line?: number;
|
|
237
|
+
metadata?: Record<string, unknown>;
|
|
238
|
+
}): void;
|
|
239
|
+
findHttpEndpoint(method: string, path: string): any | null;
|
|
240
|
+
insertFrameworkDependency(dep: {
|
|
241
|
+
id: string;
|
|
242
|
+
source_node_id: string;
|
|
243
|
+
target_node_id?: string;
|
|
244
|
+
framework: string;
|
|
245
|
+
pattern: string;
|
|
246
|
+
parameter_name?: string;
|
|
247
|
+
line?: number;
|
|
248
|
+
unresolved_name?: string;
|
|
249
|
+
metadata?: Record<string, unknown>;
|
|
250
|
+
}): void;
|
|
251
|
+
getFrameworkDependencies(sourceNodeId: string): any[];
|
|
252
|
+
getAllUnresolvedDependencies(): any[];
|
|
253
|
+
updateFrameworkDependencyTarget(id: string, targetNodeId: string): void;
|
|
167
254
|
clear(): void;
|
|
168
255
|
close(): void;
|
|
169
|
-
setMeta(key: string, value: string): void;
|
|
170
|
-
getMeta(key: string): string | null;
|
|
171
256
|
}
|
|
172
257
|
|
|
173
258
|
/**
|
|
174
|
-
*
|
|
259
|
+
* Flow Builder - Builds call graphs with resolved references
|
|
260
|
+
* Core implementation for CodeMap Flow Edition
|
|
175
261
|
*/
|
|
176
262
|
|
|
177
|
-
interface
|
|
263
|
+
interface FlowConfig {
|
|
264
|
+
rootPath: string;
|
|
265
|
+
include: string[];
|
|
266
|
+
exclude: string[];
|
|
267
|
+
forceReindex: boolean;
|
|
268
|
+
}
|
|
269
|
+
interface FlowProgress {
|
|
270
|
+
phase: "discovering" | "parsing" | "resolving" | "complete";
|
|
178
271
|
total: number;
|
|
179
272
|
current: number;
|
|
180
273
|
currentFile: string;
|
|
181
|
-
phase: "discovering" | "parsing" | "resolving" | "complete";
|
|
182
274
|
}
|
|
183
|
-
type ProgressCallback = (progress:
|
|
184
|
-
declare class
|
|
275
|
+
type ProgressCallback = (progress: FlowProgress) => void;
|
|
276
|
+
declare class FlowBuilder {
|
|
185
277
|
private storage;
|
|
186
278
|
private config;
|
|
187
279
|
private onProgress?;
|
|
188
|
-
|
|
280
|
+
private moduleMap;
|
|
281
|
+
private errors;
|
|
282
|
+
constructor(storage: FlowStorage, config: FlowConfig);
|
|
189
283
|
setProgressCallback(callback: ProgressCallback): void;
|
|
190
|
-
|
|
284
|
+
build(): Promise<{
|
|
285
|
+
indexed: number;
|
|
286
|
+
skipped: number;
|
|
287
|
+
resolved: number;
|
|
288
|
+
unresolved: number;
|
|
289
|
+
errors: string[];
|
|
290
|
+
}>;
|
|
191
291
|
private discoverFiles;
|
|
192
|
-
private
|
|
193
|
-
private
|
|
194
|
-
private emitProgress;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Base parser interface and utilities
|
|
199
|
-
*/
|
|
200
|
-
|
|
201
|
-
interface Parser {
|
|
202
|
-
language: string;
|
|
203
|
-
extensions: string[];
|
|
204
|
-
parse(filePath: string, content: string): FileAnalysis;
|
|
205
|
-
}
|
|
206
|
-
declare abstract class BaseParser implements Parser {
|
|
207
|
-
abstract language: string;
|
|
208
|
-
abstract extensions: string[];
|
|
209
|
-
protected nodeIdCounter: number;
|
|
210
|
-
protected edgeIdCounter: number;
|
|
211
|
-
abstract parse(filePath: string, content: string): FileAnalysis;
|
|
212
|
-
protected generateNodeId(filePath: string, name: string, line: number): string;
|
|
213
|
-
protected generateEdgeId(): string;
|
|
214
|
-
protected createNode(type: GraphNode["type"], name: string, filePath: string, startLine: number, endLine: number, metadata?: Record<string, unknown>): GraphNode;
|
|
215
|
-
protected createEdge(type: GraphEdge["type"], sourceId: string, targetId: string, metadata?: Record<string, unknown>): GraphEdge;
|
|
216
|
-
protected createEmptyAnalysis(filePath: string): FileAnalysis;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Registry for all parsers
|
|
220
|
-
*/
|
|
221
|
-
declare class ParserRegistry {
|
|
222
|
-
private parsers;
|
|
223
|
-
private extensionMap;
|
|
224
|
-
register(parser: Parser): void;
|
|
225
|
-
getByLanguage(language: string): Parser | undefined;
|
|
226
|
-
getByExtension(extension: string): Parser | undefined;
|
|
227
|
-
getForFile(filePath: string): Parser | undefined;
|
|
228
|
-
getSupportedExtensions(): string[];
|
|
229
|
-
getSupportedLanguages(): string[];
|
|
230
|
-
}
|
|
231
|
-
declare const parserRegistry: ParserRegistry;
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* TypeScript/JavaScript parser using Tree-sitter
|
|
235
|
-
*/
|
|
236
|
-
|
|
237
|
-
declare class TypeScriptParser extends BaseParser {
|
|
238
|
-
language: string;
|
|
239
|
-
extensions: string[];
|
|
240
|
-
private parser;
|
|
241
|
-
constructor();
|
|
242
|
-
parse(filePath: string, content: string): FileAnalysis;
|
|
243
|
-
private walkTree;
|
|
244
|
-
private handleImport;
|
|
245
|
-
private handleExport;
|
|
246
|
-
private handleFunction;
|
|
247
|
-
private handleClass;
|
|
248
|
-
private handleMethod;
|
|
249
|
-
private handleCall;
|
|
250
|
-
private handleVariable;
|
|
251
|
-
}
|
|
252
|
-
declare class JavaScriptParser extends TypeScriptParser {
|
|
253
|
-
language: string;
|
|
254
|
-
extensions: string[];
|
|
255
|
-
constructor();
|
|
256
|
-
parse(filePath: string, content: string): FileAnalysis;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Python parser using Tree-sitter
|
|
261
|
-
*/
|
|
262
|
-
|
|
263
|
-
declare class PythonParser extends BaseParser {
|
|
264
|
-
language: string;
|
|
265
|
-
extensions: string[];
|
|
266
|
-
private parser;
|
|
267
|
-
constructor();
|
|
268
|
-
parse(filePath: string, content: string): FileAnalysis;
|
|
269
|
-
private walkTree;
|
|
270
|
-
private handleImport;
|
|
271
|
-
private handleFromImport;
|
|
272
|
-
private handleFunction;
|
|
273
|
-
private handleClass;
|
|
274
|
-
private handleMethod;
|
|
275
|
-
private handleCall;
|
|
276
|
-
private parseBodyForCalls;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Parser registry and exports
|
|
281
|
-
*/
|
|
282
|
-
|
|
283
|
-
declare function registerAllParsers(): void;
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Skill Generator - Creates Claude Code skills based on codebase analysis
|
|
287
|
-
*/
|
|
288
|
-
|
|
289
|
-
declare class SkillGenerator {
|
|
290
|
-
private storage;
|
|
291
|
-
private config;
|
|
292
|
-
constructor(storage: GraphStorage, config: SkillConfig);
|
|
292
|
+
private hashContent;
|
|
293
|
+
private parseAndStore;
|
|
293
294
|
/**
|
|
294
|
-
*
|
|
295
|
+
* Process framework-specific patterns (FastAPI routes, Depends, etc.)
|
|
295
296
|
*/
|
|
296
|
-
|
|
297
|
-
private
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
private
|
|
302
|
-
private
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* CodeMap - AI-powered codebase knowledge graph generator
|
|
307
|
-
*
|
|
308
|
-
* Main entry point for programmatic usage
|
|
309
|
-
*/
|
|
310
|
-
|
|
311
|
-
interface ScanResult {
|
|
312
|
-
analysis: ProjectAnalysis;
|
|
313
|
-
dbPath: string;
|
|
314
|
-
}
|
|
315
|
-
interface ScanAndGenerateResult extends ScanResult {
|
|
316
|
-
skills: GeneratedSkill[];
|
|
297
|
+
private processFrameworkPatterns;
|
|
298
|
+
private resolveAllCalls;
|
|
299
|
+
/**
|
|
300
|
+
* Resolve framework dependencies (e.g., FastAPI Depends())
|
|
301
|
+
*/
|
|
302
|
+
private resolveFrameworkDependencies;
|
|
303
|
+
private resolveReference;
|
|
304
|
+
private getLanguage;
|
|
305
|
+
private emitProgress;
|
|
317
306
|
}
|
|
318
|
-
/**
|
|
319
|
-
* Scan a codebase and build the knowledge graph
|
|
320
|
-
*/
|
|
321
|
-
declare function scan(projectPath: string, options?: Partial<CodeMapConfig>): Promise<ScanResult>;
|
|
322
|
-
/**
|
|
323
|
-
* Generate Claude Code skills from an existing graph
|
|
324
|
-
*/
|
|
325
|
-
declare function generateSkills(projectPath: string, projectName?: string): GeneratedSkill[];
|
|
326
|
-
/**
|
|
327
|
-
* Scan a codebase and generate skills in one step
|
|
328
|
-
*/
|
|
329
|
-
declare function scanAndGenerate(projectPath: string, projectName?: string, options?: Partial<CodeMapConfig>): Promise<ScanAndGenerateResult>;
|
|
330
307
|
|
|
331
|
-
export { type AffectedFile,
|
|
308
|
+
export { type AffectedFile, type CallChain, type CallPath, type CodeMapConfig, DEFAULT_CONFIG, type DatabaseOperationInfo, type EdgeType, type ExportInfo, type FileAnalysis, FlowBuilder, type FlowConfig, type FlowProgress, FlowStorage, type GeneratedSkill, type GraphEdge, type GraphNode, type ImportInfo, type MCPResource, type MCPToolResult, type NodeType, type ProgressCallback, type ProjectAnalysis, type SkillConfig, type VariableTypeInfo };
|