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.
TypeScript antigravity-skillsbusiness-knowledgeclaude-codeclaude-skillscodebase-analysiscodexcodex-skillsdeveloper-tools-ai-agentgemini-cli-skillskarpathy-llm-wikiknowledge-baseknowledge-graphmemoryopencode-skillspi-agentunderstandcodevibe-coding
fix(import-map): respect host path semantics
Lum1104500d5d73c5c3
diff --git a/tests/skill/understand/test_extract_import_map.test.mjs b/tests/skill/understand/test_extract_import_map.test.mjsindex 4d8c95b8..91312b18 100644--- a/tests/skill/understand/test_extract_import_map.test.mjs+++ b/tests/skill/understand/test_extract_import_map.test.mjs@@ -180,6 +180,57 @@ describe('extract-import-map.mjs — TypeScript / JavaScript resolver', () => {},);+ it.skipIf(process.platform === 'win32')(+ 'accepts Windows-looking paths as project-relative POSIX filenames',+ () => {+ projectRoot = setupTree({+ 'C:/drive-slash.js': 'module.exports = 1;\n',+ 'C:\\drive-backslash.js': 'module.exports = 2;\n',+ '\\root-backslash.js': 'module.exports = 3;\n',+ });++ const paths = [+ 'C:/drive-slash.js',+ 'C:\\drive-backslash.js',+ '\\root-backslash.js',+ ];+ const result = runScript(projectRoot, {+ projectRoot,+ files: paths.map(path => ({+ path,+ language: 'javascript',+ fileCategory: 'code',+ })),+ analysisPaths: paths,+ });++ expect(result.status, result.stderr).toBe(0);+ expect(result.output.importMap).toEqual(Object.fromEntries(+ paths.map(path => [path, []]),+ ));+ },+ );++ it('rejects host-absolute analysis paths', () => {+ projectRoot = setupTree({+ 'src/index.ts': 'export const value = 1;\n',+ });+ const absolutePath = process.platform === 'win32'+ ? 'C:\\outside\\index.ts'+ : '/outside/index.ts';++ const result = runScript(projectRoot, {+ projectRoot,+ files: [+ { path: 'src/index.ts', language: 'typescript', fileCategory: 'code' },+ ],+ analysisPaths: [absolutePath],+ });++ expect(result.status).not.toBe(0);+ expect(result.stderr).toContain('analysisPaths entry must be project-relative');+ });+it('orders Unicode import targets by locale-independent UTF-16 code units', () => {projectRoot = setupTree({'src/index.ts': `import './ä';\nimport './Z';\nimport './a';\n`,diff --git a/understand-anything-plugin/skills/understand/extract-import-map.mjs b/understand-anything-plugin/skills/understand/extract-import-map.mjsindex 1af9698b..84b3a6d7 100644--- a/understand-anything-plugin/skills/understand/extract-import-map.mjs+++ b/understand-anything-plugin/skills/understand/extract-import-map.mjs@@ -40,7 +40,7 @@*/import { createRequire } from 'node:module';-import { dirname, resolve, join, posix } from 'node:path';+import { dirname, resolve, join, posix, isAbsolute } from 'node:path';import { fileURLToPath, pathToFileURL } from 'node:url';import { existsSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';import { readFile } from 'node:fs/promises';@@ -128,7 +128,10 @@ function selectAnalysisFiles(files, analysisPaths) {if (typeof rawPath !== 'string' || rawPath.length === 0) {throw new Error('Invalid input: every analysisPaths entry must be a non-empty string');}- if (/^(?:[A-Za-z]:[\\/]|[\\/])/.test(rawPath)) {+ // Use the host's path semantics here. On POSIX, backslashes and drive-like+ // prefixes are ordinary project-relative filename characters; on Windows,+ // path.isAbsolute also rejects drive-rooted and root-relative paths.+ if (isAbsolute(rawPath)) {throw new Error(`Invalid input: analysisPaths entry must be project-relative: ${rawPath}`);}const path = toPosix(rawPath);