Skip to content

feat(cli): add mempalace export subcommand - #1297

Open
chrischen1104 wants to merge 1 commit into
MemPalace:developfrom
chrischen1104:exporter-cli
Open

feat(cli): add mempalace export subcommand#1297
chrischen1104 wants to merge 1 commit into
MemPalace:developfrom
chrischen1104:exporter-cli

Conversation

@chrischen1104

Copy link
Copy Markdown

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:

mempalace export <output_dir>

The exporter module itself is unchanged — this is pure CLI plumbing.

What changed

  • mempalace/cli.py — new cmd_export handler + subparser registration + dispatch entry, mirroring the existing cmd_search style
  • tests/test_cli.py — 3 unit tests (handler arg forwarding, ~ expansion, main() dispatch routing) following the established cmd_* test pattern
  • CHANGELOG.md — one bullet under [3.3.4] — unreleased
  • website/reference/cli.md — reference entry placed adjacent to mempalace status (both are read-only palace-inspection commands)

Test plan

  • python -m pytest tests/test_cli.py -v -k export — 3 new tests pass
  • python -m pytest tests/ -v --ignore=tests/benchmarks — full suite still green
  • ruff check mempalace/cli.py tests/test_cli.py && ruff format --check mempalace/cli.py tests/test_cli.py
  • Manual end-to-end: mempalace init <dir> && mempalace mine <dir> && mempalace export /tmp/out/tmp/out/index.md + per-wing dirs created

Out of scope

  • No changes to exporter.py itself — its existing test coverage in tests/test_exporter.py remains the source of truth for export behaviour.
  • No README change — README's Quickstart deliberately lists only the 4 daily-driver commands (init, mine, search, wake-up); export belongs with compress/repair/migrate in the auxiliary tier (CLI reference + --help only). Happy to add it to the Quickstart if maintainers prefer.
  • No new MCP tool — CLI-only for now; can be added in a follow-up if there's demand.

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>
@mvalentsev

mvalentsev commented May 1, 2026

Copy link
Copy Markdown
Contributor

Heads-up -- overlap with #1086 (jphein, opened 2026-04-21) which has the same goal: wire mempalace.exporter.export_palace() to argparse as mempalace export. Same shape (CLI plumbing only, exporter.py untouched), same touched files (mempalace/cli.py + tests/test_cli.py), same from .exporter import export_palace + same export_palace(palace_path=..., output_dir=...) call. #1086 shows mergeStateStatus: CLEAN against develop.

Differences are cosmetic: #1086 takes the dir as -o <dir> flag, this PR takes it as a positional. This PR also adds a website/reference/cli.md entry, which #1086 doesn't.

Two things worth noting before review:

  1. Base branch: this PR targets main, but the active branch is develop -- main is the release-tag branch and only moves on prep merges. mergeStateStatus: BEHIND reflects that. Compare with feat(cli): wire export_palace() to CLI as mempalace export #1086 -> develop.

  2. Related (broader, separate scope): Feat/add export snapshot #775 (111r1ck) is also in this area but modifies exporter.py itself (adds snapshot functionality) -- a superset, currently UNSTABLE.

@igorls igorls added area/cli CLI commands enhancement New feature or request storage labels May 2, 2026
@igorls
igorls changed the base branch from main to develop May 17, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli CLI commands enhancement New feature or request storage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants