@abhinav2203/codeflow-core 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/analyzer/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { buildBlueprintGraph } from "./build.js";
|
|
2
2
|
export { analyzeTypeScriptRepo } from "./repo.js";
|
|
3
3
|
export { analyzeRepo } from "./repo-multi.js";
|
|
4
|
-
export type { AnalyzeRepoOptions, RepoAnalysisResult, SourceSpanEntry } from "./repo-multi.js";
|
|
4
|
+
export type { AnalyzeRepoOptions, RepoAnalysisResult, SourceSpanEntry, CallSiteEntry } from "./repo-multi.js";
|
|
@@ -6,8 +6,17 @@ export interface SourceSpanEntry {
|
|
|
6
6
|
endLine: number;
|
|
7
7
|
symbol?: string;
|
|
8
8
|
}
|
|
9
|
+
export interface CallSiteEntry {
|
|
10
|
+
edgeKey: string;
|
|
11
|
+
fromNodeId: string;
|
|
12
|
+
toNodeId: string;
|
|
13
|
+
filePath: string;
|
|
14
|
+
lineNumbers: number[];
|
|
15
|
+
expressions: string[];
|
|
16
|
+
}
|
|
9
17
|
export interface RepoAnalysisResult extends RepoGraphPart {
|
|
10
18
|
sourceSpans: Record<string, SourceSpanEntry>;
|
|
19
|
+
callSites: Record<string, CallSiteEntry>;
|
|
11
20
|
}
|
|
12
21
|
export interface AnalyzeRepoOptions {
|
|
13
22
|
excludePatterns?: string[];
|
|
@@ -247,11 +247,42 @@ export const analyzeRepo = async (repoPath, options) => {
|
|
|
247
247
|
}
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
|
+
// Build callSites from resolved call edges
|
|
251
|
+
const callSites = {};
|
|
252
|
+
const callSiteGroups = new Map();
|
|
253
|
+
for (const call of allCallEdges) {
|
|
254
|
+
const targetId = [...allSymbolIndex.entries()].find(([key]) => key.endsWith(`::${call.toName}`))?.[1];
|
|
255
|
+
if (!targetId || targetId === call.fromId)
|
|
256
|
+
continue;
|
|
257
|
+
const edgeKey = `calls:${call.fromId}:${targetId}`;
|
|
258
|
+
const callerNode = nodeMap.get(call.fromId);
|
|
259
|
+
const filePath = callerNode?.path ?? "";
|
|
260
|
+
if (!filePath)
|
|
261
|
+
continue;
|
|
262
|
+
let group = callSiteGroups.get(edgeKey);
|
|
263
|
+
if (!group) {
|
|
264
|
+
group = { fromId: call.fromId, toId: targetId, lines: [], texts: [] };
|
|
265
|
+
callSiteGroups.set(edgeKey, group);
|
|
266
|
+
}
|
|
267
|
+
group.lines.push(call.callLine);
|
|
268
|
+
group.texts.push(call.callText);
|
|
269
|
+
}
|
|
270
|
+
for (const [edgeKey, group] of callSiteGroups) {
|
|
271
|
+
callSites[edgeKey] = {
|
|
272
|
+
edgeKey,
|
|
273
|
+
fromNodeId: group.fromId,
|
|
274
|
+
toNodeId: group.toId,
|
|
275
|
+
filePath: nodeMap.get(group.fromId)?.path ?? "",
|
|
276
|
+
lineNumbers: [...new Set(group.lines)].sort((a, b) => a - b),
|
|
277
|
+
expressions: [...new Set(group.texts)]
|
|
278
|
+
};
|
|
279
|
+
}
|
|
250
280
|
return {
|
|
251
281
|
nodes: [...nodeMap.values()],
|
|
252
282
|
edges: dedupeEdges(edges),
|
|
253
283
|
workflows: [],
|
|
254
284
|
warnings,
|
|
255
|
-
sourceSpans
|
|
285
|
+
sourceSpans,
|
|
286
|
+
callSites
|
|
256
287
|
};
|
|
257
288
|
};
|
|
@@ -211,7 +211,12 @@ export const extractNodesFromFile = async (filePath, relativePath) => {
|
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
if (calleeName) {
|
|
214
|
-
callEdges.push({
|
|
214
|
+
callEdges.push({
|
|
215
|
+
fromId: callerId,
|
|
216
|
+
toName: calleeName,
|
|
217
|
+
callText: child.text,
|
|
218
|
+
callLine: child.startPosition.row + 1
|
|
219
|
+
});
|
|
215
220
|
}
|
|
216
221
|
collectCalls(child, callerId);
|
|
217
222
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abhinav2203/codeflow-core",
|
|
3
3
|
"description": "Framework-agnostic CodeFlow analysis core for blueprint generation, repository analysis, exports, and conflict detection.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|