Skip to content

Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.

refactor: return fileId from addNonCodeFile instead of recomputing it

Nikola Chetelyazov6c55ee303aa9
diff --git a/understand-anything-plugin/packages/core/src/analyzer/graph-builder.ts b/understand-anything-plugin/packages/core/src/analyzer/graph-builder.ts
index d43e9e0e..f74cb7e7 100644
--- a/understand-anything-plugin/packages/core/src/analyzer/graph-builder.ts
+++ b/understand-anything-plugin/packages/core/src/analyzer/graph-builder.ts
@@ -136,7 +136,7 @@ export class GraphBuilder {
}
private static basename(filePath: string): string {
- return GraphBuilder.basename(filePath);
+ return filePath.split("/").pop() ?? filePath;
}
addFile(filePath: string, meta: FileMeta): void {
@@ -259,7 +259,7 @@ export class GraphBuilder {
});
}
- addNonCodeFile(filePath: string, meta: NonCodeFileMeta): void {
+ addNonCodeFile(filePath: string, meta: NonCodeFileMeta): string {
const lang = detectLanguage(filePath);
if (lang !== "unknown") this.languages.add(lang);
const name = GraphBuilder.basename(filePath);
@@ -274,11 +274,11 @@ export class GraphBuilder {
tags: meta.tags,
complexity: meta.complexity,
});
+ return id;
}
addNonCodeFileWithAnalysis(filePath: string, meta: NonCodeFileAnalysisMeta): void {
- this.addNonCodeFile(filePath, meta);
- const fileId = `${meta.nodeType ?? "file"}:${filePath}`;
+ const fileId = this.addNonCodeFile(filePath, meta);
// Create child nodes for definitions (tables, schemas, etc.)
for (const def of meta.definitions ?? []) {