diff --git a/core/package.json b/core/package.json index 752353da9..e86f1095f 100644 --- a/core/package.json +++ b/core/package.json @@ -31,7 +31,6 @@ "@types/mozilla-readability": "^0.2.1", "@types/mustache": "^4.2.5", "@types/node-fetch": "^2.6.11", - "@types/normalize-path": "^3.0.2", "@types/pg": "^8.11.6", "@types/plist": "^3.0.5", "@types/request": "^2.48.12", @@ -102,7 +101,6 @@ "mac-ca": "^3.1.0", "node-fetch": "^3.3.2", "node-html-markdown": "^1.3.0", - "normalize-path": "^3.0.0", "ollama": "^0.4.6", "onnxruntime-node": "1.14.0", "openai": "^5.13.1", diff --git a/core/util/pathResolver.test.ts b/core/util/pathResolver.test.ts deleted file mode 100644 index 571671798..000000000 --- a/core/util/pathResolver.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -import * as os from "os"; -import * as path from "path"; -import { normalizeDisplayPath } from "./pathResolver"; - -describe("normalizeDisplayPath", () => { - it("should contract home directory to ~", () => { - const homedir = os.homedir(); - - expect( - normalizeDisplayPath(path.join(homedir, "Documents", "file.txt")), - ).toBe("~/Documents/file.txt"); - - expect(normalizeDisplayPath("/usr/local/bin")).toBe("/usr/local/bin"); - }); - - it("should handle root home directory", () => { - const homedir = os.homedir(); - expect(normalizeDisplayPath(homedir)).toBe("~"); - }); - - it("should not contract paths that aren't under home", () => { - expect(normalizeDisplayPath("/var/log/messages")).toBe("/var/log/messages"); - expect(normalizeDisplayPath("/usr/local/bin")).toBe("/usr/local/bin"); - }); -}); diff --git a/core/util/pathResolver.ts b/core/util/pathResolver.ts index b5cfd8a2d..25fe75816 100644 --- a/core/util/pathResolver.ts +++ b/core/util/pathResolver.ts @@ -1,5 +1,4 @@ import { fileURLToPath, pathToFileURL } from "node:url"; -import normalizePath from "normalize-path"; import * as path from "path"; import untildify from "untildify"; import { IDE } from ".."; @@ -15,11 +14,18 @@ export interface ResolvedPath { /** * Checks if a URI is within any of the workspace directories + * Also verifies the file actually exists, matching the behavior of resolveRelativePathInDir */ async function isUriWithinWorkspace(ide: IDE, uri: string): Promise { const workspaceDirs = await ide.getWorkspaceDirs(); const { foundInDir } = findUriInDirs(uri, workspaceDirs); - return foundInDir !== null; + + // Check both: within workspace path AND file exists + if (foundInDir !== null) { + return await ide.fileExists(uri); + } + + return false; } export async function resolveInputPath( @@ -52,9 +58,6 @@ export async function resolveInputPath( /^[a-zA-Z]:/.test(expandedPath); if (isAbsolute) { - // Normalize for cross-platform compatibility (converts \ to /) - const normalizedPath = normalizePath(expandedPath); - // Convert to file:// URI format const uri = pathToFileURL(expandedPath).href; const isWithinWorkspace = await isUriWithinWorkspace(ide, uri);