Skip to content

fix(memory): normalize Windows backslash paths in parsePath and parseCcPath#1573

Open
gorevyoneticisi wants to merge 2 commits into
XiaomiMiMo:mainfrom
gorevyoneticisi:fix/windows-path-separator-memory
Open

fix(memory): normalize Windows backslash paths in parsePath and parseCcPath#1573
gorevyoneticisi wants to merge 2 commits into
XiaomiMiMo:mainfrom
gorevyoneticisi:fix/windows-path-separator-memory

Conversation

@gorevyoneticisi

Copy link
Copy Markdown

Summary

The memory FTS index is completely broken on Windows. parsePath() and parseCcPath() use forward-slash regexes against backslash-separated paths produced by path.join(), so .md files under the memory directory never match. This means memory_fts is always empty on Windows and Memory.search returns zero results.

Changes

  • packages/opencode/src/memory/paths.ts: Normalize input paths to forward slashes before regex matching in parsePath() and parseCcPath(). No-op on Unix (paths already use /), fixes the Windows case.
  • packages/opencode/test/memory/paths.test.ts:
    • Added 4 Windows-specific tests covering global, project, session, and task scopes with backslash paths.
    • Fixed 2 pre-existing buildPath test failures by using path.join() in expected values instead of hardcoded forward slashes.

Test Results

All 31 memory paths tests pass on Windows (previously 25 pass, 2 fail on original code).

Evidence

Metric Before After
memory_fts rows (Windows) 0 Indexed correctly
parsePath tests 25/27 pass 31/31 pass

Closes #1571

…CcPath

The memory FTS index is completely broken on Windows because parsePath()
and parseCcPath() use forward-slash regexes against backslash-separated
paths produced by path.join(). This means memory_fts is always empty on
Windows and Memory.search returns zero results.

Normalize the input path to forward slashes before regex matching in both
functions. This is a no-op on Unix (paths already use /) and fixes the
Windows case.

Adds 4 Windows-specific tests covering global, project, session, and task
scopes with backslash paths.

Closes XiaomiMiMo#1571
…tform compat

The buildPath tests hardcoded forward-slash paths in expected values, but
path.join() on Windows returns backslash-separated paths. Use path.join()
in the assertions so tests pass on both Unix and Windows.

All 31 memory paths tests now pass on Windows.
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.

memory_fts empty on Windows: path separator mismatch in MM() function

1 participant