@abhinav2203/codeflow-core 1.0.0 → 1.0.1
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 } from "./repo-multi.js";
|
|
4
|
+
export type { AnalyzeRepoOptions, RepoAnalysisResult, SourceSpanEntry } from "./repo-multi.js";
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
type RepoGraphPart = Omit<import("../schema/index.js").BlueprintGraph, "projectName" | "mode" | "generatedAt">;
|
|
2
|
+
export interface SourceSpanEntry {
|
|
3
|
+
nodeId: string;
|
|
4
|
+
filePath: string;
|
|
5
|
+
startLine: number;
|
|
6
|
+
endLine: number;
|
|
7
|
+
symbol?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface RepoAnalysisResult extends RepoGraphPart {
|
|
10
|
+
sourceSpans: Record<string, SourceSpanEntry>;
|
|
11
|
+
}
|
|
2
12
|
export interface AnalyzeRepoOptions {
|
|
3
13
|
excludePatterns?: string[];
|
|
4
14
|
}
|
|
5
|
-
export declare const analyzeRepo: (repoPath: string, options?: AnalyzeRepoOptions) => Promise<
|
|
15
|
+
export declare const analyzeRepo: (repoPath: string, options?: AnalyzeRepoOptions) => Promise<RepoAnalysisResult>;
|
|
6
16
|
export {};
|
|
@@ -70,6 +70,16 @@ export const analyzeRepo = async (repoPath, options) => {
|
|
|
70
70
|
allImportEdges.push(...result.importEdges);
|
|
71
71
|
allInheritEdges.push(...result.inheritEdges);
|
|
72
72
|
}
|
|
73
|
+
const sourceSpans = {};
|
|
74
|
+
for (const n of allNodes) {
|
|
75
|
+
sourceSpans[n.nodeId] = {
|
|
76
|
+
nodeId: n.nodeId,
|
|
77
|
+
filePath: n.path,
|
|
78
|
+
startLine: n.startLine,
|
|
79
|
+
endLine: n.endLine,
|
|
80
|
+
symbol: n.sourceRefs.find(r => r.symbol)?.symbol
|
|
81
|
+
};
|
|
82
|
+
}
|
|
73
83
|
const nodeMap = new Map();
|
|
74
84
|
for (const n of allNodes) {
|
|
75
85
|
nodeMap.set(n.nodeId, createNode({
|
|
@@ -241,6 +251,7 @@ export const analyzeRepo = async (repoPath, options) => {
|
|
|
241
251
|
nodes: [...nodeMap.values()],
|
|
242
252
|
edges: dedupeEdges(edges),
|
|
243
253
|
workflows: [],
|
|
244
|
-
warnings
|
|
254
|
+
warnings,
|
|
255
|
+
sourceSpans
|
|
245
256
|
};
|
|
246
257
|
};
|
|
@@ -147,6 +147,7 @@ export const extractNodesFromFile = async (filePath, relativePath) => {
|
|
|
147
147
|
const importEdges = [];
|
|
148
148
|
const inheritEdges = [];
|
|
149
149
|
const moduleId = createNodeId("module", relativePath, relativePath);
|
|
150
|
+
const moduleEndLine = root.endPosition.row + 1;
|
|
150
151
|
nodes.push({
|
|
151
152
|
nodeId: moduleId,
|
|
152
153
|
kind: "module",
|
|
@@ -154,7 +155,9 @@ export const extractNodesFromFile = async (filePath, relativePath) => {
|
|
|
154
155
|
summary: `Source module ${relativePath}.`,
|
|
155
156
|
path: relativePath,
|
|
156
157
|
signature: "",
|
|
157
|
-
sourceRefs: [{ kind: "repo", path: relativePath }]
|
|
158
|
+
sourceRefs: [{ kind: "repo", path: relativePath }],
|
|
159
|
+
startLine: 1,
|
|
160
|
+
endLine: moduleEndLine
|
|
158
161
|
});
|
|
159
162
|
const recordFunc = (funcName, funcNode, paramsNode, returnTypeNode, bodyNode, ownerName, ownerId) => {
|
|
160
163
|
if (!funcName)
|
|
@@ -175,7 +178,9 @@ export const extractNodesFromFile = async (filePath, relativePath) => {
|
|
|
175
178
|
path: relativePath,
|
|
176
179
|
signature,
|
|
177
180
|
sourceRefs: [{ kind: "repo", path: relativePath, symbol: displayName }],
|
|
178
|
-
ownerId: isMethod ? ownerId : (kind === "function" ? moduleId : undefined)
|
|
181
|
+
ownerId: isMethod ? ownerId : (kind === "function" ? moduleId : undefined),
|
|
182
|
+
startLine: funcNode.startPosition.row + 1,
|
|
183
|
+
endLine: funcNode.endPosition.row + 1
|
|
179
184
|
});
|
|
180
185
|
// Only store fully-qualified keys for methods to avoid collisions
|
|
181
186
|
symbolIndex.set(`${relativePath}::${displayName}`, nodeId);
|
|
@@ -441,7 +446,9 @@ export const extractNodesFromFile = async (filePath, relativePath) => {
|
|
|
441
446
|
path: relativePath,
|
|
442
447
|
signature: `class ${className}`,
|
|
443
448
|
sourceRefs: [{ kind: "repo", path: relativePath, symbol: className }],
|
|
444
|
-
ownerId: moduleId
|
|
449
|
+
ownerId: moduleId,
|
|
450
|
+
startLine: child.startPosition.row + 1,
|
|
451
|
+
endLine: child.endPosition.row + 1
|
|
445
452
|
});
|
|
446
453
|
symbolIndex.set(`${relativePath}::${className}`, classId);
|
|
447
454
|
if (parentClass)
|
|
@@ -473,7 +480,9 @@ export const extractNodesFromFile = async (filePath, relativePath) => {
|
|
|
473
480
|
path: relativePath,
|
|
474
481
|
signature: `class ${className}`,
|
|
475
482
|
sourceRefs: [{ kind: "repo", path: relativePath, symbol: className }],
|
|
476
|
-
ownerId: moduleId
|
|
483
|
+
ownerId: moduleId,
|
|
484
|
+
startLine: child.startPosition.row + 1,
|
|
485
|
+
endLine: child.endPosition.row + 1
|
|
477
486
|
});
|
|
478
487
|
symbolIndex.set(`${relativePath}::${className}`, classId);
|
|
479
488
|
if (parentClass)
|
|
@@ -496,7 +505,9 @@ export const extractNodesFromFile = async (filePath, relativePath) => {
|
|
|
496
505
|
summary: buildSummary(className, child, null, [], ""),
|
|
497
506
|
path: relativePath,
|
|
498
507
|
signature: `type ${className} struct`,
|
|
499
|
-
sourceRefs: [{ kind: "repo", path: relativePath, symbol: className }]
|
|
508
|
+
sourceRefs: [{ kind: "repo", path: relativePath, symbol: className }],
|
|
509
|
+
startLine: structType.startPosition.row + 1,
|
|
510
|
+
endLine: structType.endPosition.row + 1
|
|
500
511
|
});
|
|
501
512
|
symbolIndex.set(`${relativePath}::${className}`, classId);
|
|
502
513
|
walkFunctions(child, className, classId);
|
|
@@ -519,7 +530,9 @@ export const extractNodesFromFile = async (filePath, relativePath) => {
|
|
|
519
530
|
summary: buildSummary(className, child, null, [], ""),
|
|
520
531
|
path: relativePath,
|
|
521
532
|
signature: `struct ${className}`,
|
|
522
|
-
sourceRefs: [{ kind: "repo", path: relativePath, symbol: className }]
|
|
533
|
+
sourceRefs: [{ kind: "repo", path: relativePath, symbol: className }],
|
|
534
|
+
startLine: child.startPosition.row + 1,
|
|
535
|
+
endLine: child.endPosition.row + 1
|
|
523
536
|
});
|
|
524
537
|
symbolIndex.set(`${relativePath}::${className}`, classId);
|
|
525
538
|
walkFunctions(child, className, classId);
|
|
@@ -547,7 +560,9 @@ export const extractNodesFromFile = async (filePath, relativePath) => {
|
|
|
547
560
|
summary: buildSummary(className, child, null, [], ""),
|
|
548
561
|
path: relativePath,
|
|
549
562
|
signature: `impl ${className}`,
|
|
550
|
-
sourceRefs: [{ kind: "repo", path: relativePath, symbol: className }]
|
|
563
|
+
sourceRefs: [{ kind: "repo", path: relativePath, symbol: className }],
|
|
564
|
+
startLine: child.startPosition.row + 1,
|
|
565
|
+
endLine: child.endPosition.row + 1
|
|
551
566
|
});
|
|
552
567
|
symbolIndex.set(`${relativePath}::${className}`, classId);
|
|
553
568
|
walkFunctions(child, className, classId);
|
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.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|