Skip to content

feat: add Aider chat history markdown normalizer - #172

Open
mvanhorn wants to merge 3 commits into
MemPalace:developfrom
mvanhorn:feat/59-aider-normalizer
Open

feat: add Aider chat history markdown normalizer#172
mvanhorn wants to merge 3 commits into
MemPalace:developfrom
mvanhorn:feat/59-aider-normalizer

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a _try_aider_md() parser to normalize.py that extracts user/assistant conversations from Aider's .aider.chat.history.md files. Aider uses #### headings for user messages with assistant responses as plain text between them.

Wired into the auto-detect chain ahead of JSON parsing, in both normalize() and normalize_conversations(). Detection is a filename fingerprint — the file must be named exactly .aider.chat.history.md — so regular markdown that happens to use #### headings (CONTRIBUTING.md, CHANGELOG.md, API docs) is never claimed by the parser.

Partially addresses #59 (Aider was called out as "lowest-hanging fruit" in the issue).

How to test

pytest tests/test_normalize.py -k aider -v

Or with a real Aider history file:

from mempalace.normalize import normalize
result = normalize(".aider.chat.history.md")
print(result[:500])

Checklist

  • Tests pass (uv run pytest tests/ -v --ignore=tests/benchmarks) — 4303 passed, 31 skipped
  • No hardcoded paths
  • Linter passes (ruff check ., ruff format --check .)

This contribution was developed with AI assistance (Codex).

@adv3nt3

adv3nt3 commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Nice work — Aider was called out as lowest-hanging fruit in #59 and this is a clean implementation.

A few concerns:

  1. False positive risk on regular markdown files. Any .md file with 2+ #### headings will trigger the parser — CONTRIBUTING.md, CHANGELOG.md, API docs, etc. Aider's history file has a very specific name (.aider.chat.history.md). Checking the filename would be a much safer fingerprint:
if ext == ".md" and Path(filepath).name == ".aider.chat.history.md":
  1. User messages can span multiple lines. In real Aider sessions, users sometimes paste multi-line code or context after the #### heading. The current parser treats everything after #### as assistant text until the next ####, which would split a multi-line user prompt and misattribute part of it as an assistant response.

  2. No structural fingerprint. The other JSONL/JSON parsers (Codex, Gemini, Pi) check for a session header or unique keys to confirm the format. Relying on #### count alone in .md files is fragile — combining the filename check from point 1 would solve this.

@mvanhorn

mvanhorn commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

Great catches. Fixed all three in 3277254:

  1. Fingerprint now checks Path(filepath).name == ".aider.chat.history.md" instead of matching any .md with #### headings. CONTRIBUTING.md, CHANGELOG.md, etc. are no longer false positives.

  2. Re: multi-line user messages - in Aider's actual format, the full user prompt lives on the #### line (even long ones). Lines after are always assistant output. But if we see real-world exceptions to this pattern, happy to revisit.

  3. The filename check serves as the structural fingerprint (solves points 1 and 3 together).

Added test_aider_rejects_generic_md to verify regular markdown files are not parsed.

@web3guru888 web3guru888 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of #172feat: add Aider chat history markdown normalizer

Scope: +80/−1 · 2 file(s)

  • mempalace/normalize.py (modified: +40/−1)
  • tests/test_normalize.py (modified: +40/−0)

Strengths

  • ✅ Includes test coverage

🟢 Approved — clean, well-structured PR. Good work @mvanhorn!


🏛️ Reviewed by MemPalace-AGI · Autonomous research system with perfect memory · Showcase: Truth Palace of Atlantis

@bensig
bensig changed the base branch from main to develop April 11, 2026 22:23
@igorls igorls added area/mining File and conversation mining enhancement New feature or request labels Apr 14, 2026
@igorls

igorls commented May 8, 2026

Copy link
Copy Markdown
Member

Hi, thanks for the contribution.

This PR has merge conflicts with develop, and the branch has not been updated in over 7 days, which puts it before our most recent release. The conflicts are likely against work that landed in that release.

Could you rebase onto develop so we can take another look?

If this change is no longer relevant, feel free to close the PR.

(This message is part of a periodic backlog pass, sent to all open PRs that match this state.)

@mvanhorn

mvanhorn commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current develop and resolved the conflicts (develop's tmp_path test rewrite and the JSON normalization comments). The aider test now uses the exact .aider.chat.history.md filename fingerprint. Full test suite passes locally: 153 tests in test_normalize.py, 3219 overall.

@mvanhorn
mvanhorn force-pushed the feat/59-aider-normalizer branch from 3bc6ede to 1ef7080 Compare July 23, 2026 00:55
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Brought this one up to date with develop as well (1ef7080), clean rebase, 3402 tests passing locally.

@igorls

igorls commented Aug 15, 2026

Copy link
Copy Markdown
Member

Thanks for this contribution, and apologies for the slow turnaround.

develop has moved a fair way since this was opened and the branch no longer merges cleanly. If you're still interested in landing it, could you rebase onto current develop? Once it merges cleanly and CI is green I'll get it reviewed for the 3.8.0 cycle.

If you'd rather not pick it back up, no problem at all — just say so and I'll close it out, and thanks either way for taking the time to send it.

@cursor
cursor Bot force-pushed the feat/59-aider-normalizer branch from 1ef7080 to e7e1cae Compare August 16, 2026 22:25
@mvanhorn

Copy link
Copy Markdown
Contributor Author

@igorls rebased onto current develop. Mergeable now.

develop had split ingest onto normalize_conversations(), so a clean rebase would have left the Aider parser only on the unused normalize() path. I wired the same filename-fingerprint branch into normalize_conversations() so a real .aider.chat.history.md actually gets parsed during ingest.

There's still an old CLOSET_DISTANCE_CAP deletion on this branch, same leftover as #601. I'm dropping it so this PR stays the Aider normalizer only.

@cursor
cursor Bot force-pushed the feat/59-aider-normalizer branch from e7e1cae to a0287de Compare August 16, 2026 22:35
mvanhorn and others added 3 commits August 19, 2026 14:37
Add _try_aider_md() parser to normalize.py for .aider.chat.history.md
files. Detects #### headings as user messages with assistant responses
in between. Wired into the normalize() auto-detect chain before JSON
parsing.

Partially addresses MemPalace#59.
…arkdown

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.
develop split the parser chain into normalize_conversations(), which is
the only entry point convo_miner uses. The Aider branch existed solely in
normalize(), so a real .aider.chat.history.md was ingested as raw markdown.

Co-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>
@mvanhorn
mvanhorn force-pushed the feat/59-aider-normalizer branch from a0287de to 38c76d3 Compare August 19, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/mining File and conversation mining enhancement New feature or request needs-rebase PR has merge conflicts with develop and needs rebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants