Skip to content

fix: unified Windows path normalization for consistent cross-client hashing#266

Open
troshab wants to merge 1 commit intozilliztech:masterfrom
troshab:fix/unified-windows-path-normalization
Open

fix: unified Windows path normalization for consistent cross-client hashing#266
troshab wants to merge 1 commit intozilliztech:masterfrom
troshab:fix/unified-windows-path-normalization

Conversation

@troshab
Copy link

@troshab troshab commented Feb 12, 2026

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)
  • Mixed (C:\Users\tro/test)

path.resolve('/c/Users/tro/test') on Windows produces C:\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

  • New packages/core/src/utils/path.ts with 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, deleteSnapshot now use canonicalCodebasePath (consistent hashing)
  • processChunkBatch, deleteFileChunks now use normalizeRelativePath (consistent relative paths in vector DB)
  • ensureAbsolutePath in MCP package delegates to normalizeCodebasePath

Cross-platform safety

  • MSYS conversion and lowercase only apply on process.platform === 'win32'
  • On Linux/macOS, paths pass through path.resolve() unchanged (case-sensitive FS)

Test plan

  • pnpm build compiles without errors
  • All three path formats produce identical canonicalCodebasePath output on Windows
  • normalizeCodebasePath preserves original case (usable for FS operations and display)
  • Re-index codebase from Claude Code, search from VS Code extension - should find results

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant