diff --git a/src/shared/paths.test.ts b/src/shared/paths.test.ts index 95780e4..601166a 100644 --- a/src/shared/paths.test.ts +++ b/src/shared/paths.test.ts @@ -11,4 +11,14 @@ describe('encodeProjectPath', () => { expect(encodeProjectPath('C:\\Users\\dev\\Documents\\GitHub')) .toBe('C--Users-dev-Documents-GitHub'); }); + + it('replaces spaces the way Claude does (folder names with spaces)', () => { + expect(encodeProjectPath('C:\\Users\\dev\\Documents\\GitHub\\Youtube Lythem Game')) + .toBe('C--Users-dev-Documents-GitHub-Youtube-Lythem-Game'); + }); + + it('replaces dots and other non-alphanumerics with a dash', () => { + expect(encodeProjectPath('C:\\Users\\dev\\repo\\.claude\\worktrees\\vibe-music')) + .toBe('C--Users-dev-repo--claude-worktrees-vibe-music'); + }); }); diff --git a/src/shared/paths.ts b/src/shared/paths.ts index 7769805..c11247f 100644 --- a/src/shared/paths.ts +++ b/src/shared/paths.ts @@ -1,4 +1,9 @@ -/** Replace every ':' and '\' with '-' to match Claude's ~/.claude/projects dir name. */ +/** + * Encode an absolute path the way Claude names its ~/.claude/projects dir: + * every non-alphanumeric character (drive colon, path separators, spaces, dots, + * …) becomes '-'. Replacing only ':' and '\' missed folders whose names contain + * spaces or dots, so their usage/sessions silently went unmatched. + */ export function encodeProjectPath(absPath: string): string { - return absPath.replace(/[:\\]/g, '-'); + return absPath.replace(/[^a-zA-Z0-9]/g, '-'); }