Skip to content

Windows: wizard fails to auto-detect Claude/Codex memory dirs (backslash path regex) #316

@memtomem

Description

@memtomem

Symptom

Windows users running mm init don't get Claude Code / Codex memory directories auto-detected by the wizard's "Provider memory folders" step. Any such path they add manually is classified under the generic user category instead of claude-memory / claude-plans / codex, so the preset namespace rules added in #312 (claude:{ancestor:1}, claude-plans, codex) don't get applied either.

Silent failure: no error, no warning — the wizard just doesn't find the directories it would find on macOS/Linux.

Root cause

categorize_memory_dir at packages/memtomem/src/memtomem/config.py:1040-1064 uses regex patterns that match forward slashes only:

_PROVIDER_CATEGORY_PATTERNS = (
    ("claude-memory", re.compile(r"/\.claude/projects/[^/]+/memory/?$")),
    ("claude-plans",  re.compile(r"/\.claude/plans/?$")),
    ("codex",         re.compile(r"/\.codex/memories/?$")),
)

On Windows, str(Path(...)) returns backslash-separated paths (C:\Users\foo\.claude\projects\bar\memory), so none of the patterns match and the function falls through to return "user" (line 1064). The docstring at lines 1056-1058 already acknowledges this gap:

Uses forward-slash regex, so on Windows a backslash-normalised path will fall through to "user" until a future path-sep-agnostic pass lands.

This issue is that "future pass".

Scope

Testing notes

CI (.github/workflows/ci.yml) runs on ubuntu-latest only — no Windows runner. A fix therefore needs platform-agnostic tests that exercise the backslash code path without a Windows host.

Preferred fixture pattern: hand-constructed backslash strings passed directly to categorize_memory_dir, e.g.

assert categorize_memory_dir(r"C:\Users\foo\.claude\projects\abc\memory") == "claude-memory"

Raw strings (r"...") avoid backslash-escape confusion. This exercises the matching logic directly without touching platform-specific path objects. pathlib.PureWindowsPath also works if a fixture prefers path objects, but the raw-string form is the simpler default.

Acceptance criteria

  • Windows-style paths (C:\Users\…\.claude\projects\<id>\memory, …\.claude\plans, …\.codex\memories) classify into the correct provider category.
  • Existing POSIX-path tests continue to pass — no regression in TestCategorizeMemoryDir / TestDetectProviderDirsRoundtrip.
  • New tests cover at least one Windows-style path per provider category plus the user fallback, using raw-string backslash fixtures (or PureWindowsPath) so they run on Linux CI.
  • Docstring at config.py:1056-1058 updated to reflect that the gap is closed.
  • Edge case consideration: document behaviour for mixed separators (e.g., C:\Users\foo/.claude/plans) and UNC paths (\\server\share\...) — may be out of scope; contributor's call with rationale in the PR body.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions