Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyfpa/memory/retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def build_memory_index(workspace: str | Path) -> MemoryIndex:
):
continue
text = path.read_text()
relative = str(path.relative_to(workspace))
relative = path.relative_to(workspace).as_posix()
entries.append(MemoryEntry(
path=relative,
category=_category(path, workspace),
Expand Down
19 changes: 19 additions & 0 deletions tests/test_memory_retrieval.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pathlib import Path, PureWindowsPath

from pyfpa.memory.retrieval import (
build_context_pack,
build_memory_index,
Expand Down Expand Up @@ -52,6 +54,23 @@ def test_memory_index_round_trip_and_context_pack(tmp_path):
assert "`business-profile.md`" in pack


def test_memory_index_paths_are_posix_when_os_uses_backslashes(tmp_path, monkeypatch):
(tmp_path / "corrections").mkdir()
(tmp_path / "corrections" / "cash.md").write_text("Cash collections lag.\n")

real_relative_to = Path.relative_to

def relative_to_windows(self, *other):
return PureWindowsPath(*real_relative_to(self, *other).parts)

monkeypatch.setattr(Path, "relative_to", relative_to_windows)

index = build_memory_index(tmp_path)

assert [entry.path for entry in index.entries] == ["corrections/cash.md"]
assert all("\\" not in entry.path for entry in index.entries)


def test_generated_index_does_not_index_itself(tmp_path):
(tmp_path / "MEMORY.md").write_text("# Memory\n")
save_memory_index(build_memory_index(tmp_path), tmp_path / "index.yaml")
Expand Down