fix: unified Windows path normalization for consistent cross-client hashing#266
Open
troshab wants to merge 1 commit intozilliztech:masterfrom
Open
fix: unified Windows path normalization for consistent cross-client hashing#266troshab wants to merge 1 commit intozilliztech:masterfrom
troshab wants to merge 1 commit intozilliztech:masterfrom
Conversation
…ashing On Windows, clients (Claude Code, VS Code, Chrome extension) can pass codebase paths in different formats: native (C:\...), forward slashes (C:/...), MSYS/Git Bash (/c/...), or mixed. Node.js path.resolve() incorrectly handles MSYS paths on Windows, producing C:\c\Users\... instead of C:\Users\... This causes different collection name hashes for the same codebase depending on which client indexed/searched it. - Add normalizeCodebasePath() for FS operations (MSYS conversion, slash normalization, preserves case) - Add canonicalCodebasePath() for hashing (adds lowercase on Windows for case-insensitive FS consistency) - Add normalizeRelativePath() for DB storage (backslash to forward slash) - Apply canonicalCodebasePath in getCollectionName, getSnapshotPath, deleteSnapshot (hash-based lookups) - Apply normalizeRelativePath in processChunkBatch and deleteFileChunks (consistent relative paths in vector DB) - Rewrite ensureAbsolutePath in MCP to delegate to normalizeCodebasePath
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On Windows, different MCP clients pass codebase paths in different formats:
C:\Users\tro\test(Windows native)C:/Users/tro/test(forward slashes)/c/Users/tro/test(Git Bash / MSYS)C:\Users\tro/test)path.resolve('/c/Users/tro/test')on Windows producesC:\c\Users\tro\test(wrong), and even valid formats could differ in case. This causes different collection name hashes for the same codebase, so indexing from one client and searching from another fails with "collection not found".Changes
packages/core/src/utils/path.tswith three functions:normalizeCodebasePath()- for FS operations (MSYS conversion, resolve, slash normalization, preserves case)canonicalCodebasePath()- for hashing (adds lowercase on Windows for case-insensitive FS)normalizeRelativePath()- for DB storage (backslash to forward slash)getCollectionName,getSnapshotPath,deleteSnapshotnow usecanonicalCodebasePath(consistent hashing)processChunkBatch,deleteFileChunksnow usenormalizeRelativePath(consistent relative paths in vector DB)ensureAbsolutePathin MCP package delegates tonormalizeCodebasePathCross-platform safety
process.platform === 'win32'path.resolve()unchanged (case-sensitive FS)Test plan
pnpm buildcompiles without errorscanonicalCodebasePathoutput on WindowsnormalizeCodebasePathpreserves original case (usable for FS operations and display)