Skip to content

Commit 91b890c

Browse files
committed
fix: use filename fingerprint to prevent false positives on regular markdown
Check for .aider.chat.history.md specifically instead of matching any .md file with #### headings. Addresses review feedback: CONTRIBUTING.md, CHANGELOG.md, and API docs would have falsely triggered the Aider parser. Add test_aider_rejects_generic_md to verify regular markdown files are not parsed as Aider chat history.
1 parent 28f09c8 commit 91b890c

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

mempalace/normalize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ def normalize(filepath: str) -> str:
152152

153153
ext = Path(filepath).suffix.lower()
154154

155-
# Try Aider markdown normalization
156-
if ext == ".md" and sum(1 for line in lines if line.startswith("#### ")) >= 2:
155+
# Try Aider markdown normalization (filename fingerprint to avoid false positives)
156+
if ext == ".md" and Path(filepath).name == ".aider.chat.history.md":
157157
normalized = _try_aider_md(content)
158158
if normalized:
159159
return normalized

tests/test_normalize.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def test_aider_md(tmp_path):
8383
"#### Can you also add tests for it?\n\n"
8484
"Sure, here's a test file.\n"
8585
)
86-
f = tmp_path / "session.aider.chat.history.md"
86+
# Must use Aider's exact filename to trigger the parser
87+
f = tmp_path / ".aider.chat.history.md"
8788
f.write_text(content)
8889
result = normalize(str(f))
8990
assert "How do I add a new route?" in result

0 commit comments

Comments
 (0)