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.

fix(import-map): refresh supplemental imports for changed files

Lum110433068e548dc3
diff --git a/tests/skill/understand/test_prepare_incremental.test.mjs b/tests/skill/understand/test_prepare_incremental.test.mjs
index ec4f1679..1724f331 100644
--- a/tests/skill/understand/test_prepare_incremental.test.mjs
+++ b/tests/skill/understand/test_prepare_incremental.test.mjs
@@ -342,6 +342,27 @@ describe('prepare-incremental.mjs', { timeout: 30_000 }, () => {
expect(scan.importMap['src/index.ts']).toEqual(['alternate/foo.ts']);
});
+ it('refreshes supplemental require imports even when fingerprints classify the edit as cosmetic', () => {
+ const { root, baseCommit } = setupRepository({
+ 'src/index.js': "const value = require('./a');\nmodule.exports = value;\n",
+ 'src/a.js': 'module.exports = 1;\n',
+ 'src/b.js': 'module.exports = 2;\n',
+ 'src/c.js': 'module.exports = 3;\n',
+ });
+ writeProjectFile(
+ root,
+ 'src/index.js',
+ "const value = require('./b');\nmodule.exports = value;\n",
+ );
+ commit(root, 'change supplemental require');
+
+ const { plan, scan } = prepare(root, baseCommit);
+ expect(plan.action).toBe('SKIP');
+ expect(plan.cosmeticFiles).toEqual(['src/index.js']);
+ expect(plan.filesToReanalyze).toEqual([]);
+ expect(scan.importMap['src/index.js']).toEqual(['src/b.js']);
+ });
+
it('treats LF-to-CRLF conversion as cosmetic and schedules no analyzer', () => {
const { root, baseCommit } = setupRepository({
'src/a.ts': 'export function value() {\n return 1;\n}\n',
diff --git a/understand-anything-plugin/skills/understand/prepare-incremental.mjs b/understand-anything-plugin/skills/understand/prepare-incremental.mjs
index fcc25d62..61ee9aa8 100644
--- a/understand-anything-plugin/skills/understand/prepare-incremental.mjs
+++ b/understand-anything-plugin/skills/understand/prepare-incremental.mjs
@@ -503,7 +503,7 @@ async function main() {
|| currentChangedPaths.some(isImportResolverConfig);
const importAnalysisPaths = importResolutionContextChanged
? currentInventory
- : sorted([...filesToReanalyze, ...missingImportEntries]);
+ : sorted([...currentChangedPaths, ...missingImportEntries]);
const importMap = refreshImportMap({
projectRoot,
intermediateDir,