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.

feat(core): make resolveImports optional on AnalyzerPlugin

Lum11049eb220c4924c
diff --git a/understand-anything-plugin/packages/core/src/__tests__/plugin-registry.test.ts b/understand-anything-plugin/packages/core/src/__tests__/plugin-registry.test.ts
index 8000924f..5e5976c8 100644
--- a/understand-anything-plugin/packages/core/src/__tests__/plugin-registry.test.ts
+++ b/understand-anything-plugin/packages/core/src/__tests__/plugin-registry.test.ts
@@ -178,4 +178,17 @@ describe("PluginRegistry", () => {
const result = registry.resolveImports("main.py", "import os");
expect(result).toBeNull();
});
+
+ it("handles plugins with optional resolveImports (non-code plugins)", () => {
+ const markdownPlugin: AnalyzerPlugin = {
+ name: "markdown",
+ languages: ["markdown"],
+ analyzeFile: () => ({ functions: [], classes: [], imports: [], exports: [] }),
+ // No resolveImports — optional for non-code plugins
+ };
+ const registry = new PluginRegistry();
+ registry.register(markdownPlugin);
+ const result = registry.resolveImports("README.md", "# Hello");
+ expect(result).toBeNull();
+ });
});
diff --git a/understand-anything-plugin/packages/core/src/plugins/registry.ts b/understand-anything-plugin/packages/core/src/plugins/registry.ts
index 71233fe3..67261f53 100644
--- a/understand-anything-plugin/packages/core/src/plugins/registry.ts
+++ b/understand-anything-plugin/packages/core/src/plugins/registry.ts
@@ -61,7 +61,7 @@ export class PluginRegistry {
resolveImports(filePath: string, content: string): ImportResolution[] | null {
const plugin = this.getPluginForFile(filePath);
- if (!plugin) return null;
+ if (!plugin || !plugin.resolveImports) return null;
return plugin.resolveImports(filePath, content);
}