Skip to content

fix: correct Windows path encoding/resolution in cvfs#41

Open
hen-corix wants to merge 1 commit into
dlond:mainfrom
hen-corix:fix/windows-path-encoding
Open

fix: correct Windows path encoding/resolution in cvfs#41
hen-corix wants to merge 1 commit into
dlond:mainfrom
hen-corix:fix/windows-path-encoding

Conversation

@hen-corix
Copy link
Copy Markdown

Summary

  • get_home(): prefer USERPROFILE over HOME on Win32 — Git Bash sets HOME to an MSYS2 virtual path (e.g. /c/Users/foo) that native Win32 file APIs can't resolve
  • msys2_to_win(): convert Git Bash MSYS2 drive-mount paths (/d/workspace/foo) to proper Windows paths (D:/workspace/foo) before processing
  • resolve_path(): handle Windows absolute paths (C:/...) correctly; normalize Unix.realpath output which may return backslashes on Win32
  • project_path(): match Claude Code's actual encoding — replace any character outside [a-zA-Z0-9-] with - (previously only /, \, : were replaced, missing underscores, spaces, and other chars)
  • get_cwd_from_jsonl() / get_project_path_from_dir(): read the real cwd from JSONL conversation files instead of trying to reverse-decode the encoded directory name (which is lossy — hyphens in folder names are indistinguishable from encoded path separators)
  • Replace all Sys.getenv "HOME" with get_home() throughout

Context

These fixes address three bugs on Windows:

  1. claude-mv always reported "Error: No conversation found"
  2. claude-ls reported "No conversations found in ."
  3. claude-ls / claude-clean failed for project paths containing hyphens, uppercase letters, underscores, or spaces

Test plan

  • claude-ls in a Windows project directory returns conversations
  • claude-ls in a path with underscores (e.g. D:\workspace\My_Project) finds the correct Claude project directory
  • claude-ls with a Git Bash MSYS2 path argument (e.g. /d/workspace/foo) resolves correctly
  • claude-clean shows correct project paths (not mangled by lossy hyphen substitution)
  • claude-mv successfully finds and moves conversations on Windows
  • All existing behaviour unchanged on Linux/macOS

🤖 Generated with Claude Code

On Windows, path handling had several issues that caused claude-mv,
claude-ls, and claude-clean to fail or misidentify project directories.

- normalize_sep: convert backslashes to forward slashes uniformly
- get_home: prefer USERPROFILE over HOME on Win32 (Git Bash sets HOME
  to an MSYS2 virtual path like /c/Users/foo that Win32 APIs can't resolve)
- msys2_to_win: convert Git Bash MSYS2 drive-mount paths (/d/foo) to
  proper Windows paths (D:/foo) before encoding
- resolve_path: handle Windows absolute paths (C:/...) correctly and
  normalize Unix.realpath output which may return backslashes on Win32
- project_path: match Claude Code's encoding — replace any char outside
  [a-zA-Z0-9-] with '-' (previously only /, \, : were replaced, missing
  underscores, spaces, and other ASCII special chars)
- get_cwd_from_jsonl / get_project_path_from_dir: read the actual cwd
  from JSONL conversation files instead of trying to reverse the lossy
  encoded directory name (hyphens in dir names are indistinguishable
  from encoded path separators)
- Replace all Sys.getenv "HOME" with get_home () throughout

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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