feat(cli): add mempalace export subcommand - #1297
Conversation
Wires the existing mempalace.exporter.export_palace() function to
argparse as a new top-level subcommand:
mempalace export <output_dir>
Dumps the palace as a browsable Markdown tree — top-level index.md
plus one .md per room under each wing directory, with each drawer
rendered as a heading + blockquoted verbatim content + metadata
table. The exporter itself is unchanged; it already streams in
1k-drawer batches so memory stays bounded for large palaces, and
no other commands change behaviour.
Adds three matching tests in tests/test_cli.py covering handler
arg forwarding, ~ expansion, and main() dispatch routing,
mirroring the existing cmd_search test pattern. Updates
CHANGELOG.md under [3.3.4] unreleased and adds a reference entry
in website/reference/cli.md adjacent to mempalace status (both are
read-only palace-inspection commands).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Heads-up -- overlap with #1086 (jphein, opened 2026-04-21) which has the same goal: wire Differences are cosmetic: #1086 takes the dir as Two things worth noting before review:
|
Summary
Wires the existing
mempalace.exporter.export_palace()to argparse as a new top-level subcommand, so users can dump the palace as a browsable Markdown tree without writing Python:The exporter module itself is unchanged — this is pure CLI plumbing.
What changed
mempalace/cli.py— newcmd_exporthandler + subparser registration + dispatch entry, mirroring the existingcmd_searchstyletests/test_cli.py— 3 unit tests (handler arg forwarding,~expansion,main()dispatch routing) following the establishedcmd_*test patternCHANGELOG.md— one bullet under[3.3.4] — unreleasedwebsite/reference/cli.md— reference entry placed adjacent tomempalace status(both are read-only palace-inspection commands)Test plan
python -m pytest tests/test_cli.py -v -k export— 3 new tests passpython -m pytest tests/ -v --ignore=tests/benchmarks— full suite still greenruff check mempalace/cli.py tests/test_cli.py && ruff format --check mempalace/cli.py tests/test_cli.pymempalace init <dir> && mempalace mine <dir> && mempalace export /tmp/out→/tmp/out/index.md+ per-wing dirs createdOut of scope
exporter.pyitself — its existing test coverage intests/test_exporter.pyremains the source of truth for export behaviour.init,mine,search,wake-up);exportbelongs withcompress/repair/migratein the auxiliary tier (CLI reference +--helponly). Happy to add it to the Quickstart if maintainers prefer.