Description
Context
The CLI has reached the point where gmd.py is carrying argument parsing, interactive prompts, Drive coordination, Markdown assembly, and output formatting in one place.
The renderer has a similar problem. It effectively returns a string, which means any new output surface has to reverse-engineer metadata, attachments, and derived stats from code that was only written to emit Markdown. That is especially limiting if we want HTML previews or richer summaries, because the current structure encourages copy/paste rather than reuse.
Motivation
We need a command boundary before the next round of features lands. Without one, every CLI enhancement deepens the coupling between argparse parsing, Drive access, attachment collection, and text generation. That makes even small additions costly to review and increases the chance that render and sync drift apart behaviorally.
HTML preview support is the clearest near-term example. If we add HTML directly to the current implementation, we will either duplicate all of the metadata and attachment logic or build another layer that parses already-rendered Markdown back into structured data. Neither is attractive. The better move is to promote a structured document model and let both Markdown and HTML writers consume it.
There is also a UX concern. Interactive use is valuable for browsing files and chats, but it should not be entangled with CI or shell scripting paths. The repo needs a plain-mode story and a small UI abstraction so the code can ask for a choice or a summary without hard-coding one terminal tool everywhere.
Scope
In scope:
- split
gmd.pyinto a thin CLI adapter plus a reusable command layer - introduce typed option/result objects for render, sync, list, and status paths
- centralize attachment collection and Markdown building so render and sync share one implementation
- introduce a structured document object that can back both Markdown and HTML outputs
- add an optional HTML preview writer
- add a plain-aware interaction layer that can wrap picker and presentation tools cleanly
- update the dev shell to include the interactive/HTML stack the tool actually expects
Out of scope:
- provider expansion beyond Gemini in this pass
- deep visual theming or a full terminal UI framework
- a large CLI rename or config migration
Acceptance criteria
- Render and sync both delegate to shared command functions that accept typed option objects and return typed results.
- The renderer produces a structured document representation that preserves metadata, attachments, and stats for both Markdown and HTML writers.
- HTML previews can be generated from the same render pipeline with explicit flags and theme selection.
- Interactive behavior can be disabled cleanly for CI/scripts, and bare CLI invocation can enter a menu without changing scripted subcommand behavior.
- Attachment handling, pruning logic, and Drive orchestration are no longer duplicated between render and sync code paths.
Activity
refactor: drop runtime text classifier fallback from message model (#839
fix(live): eliminate read storm by trusting cursor on mtime drift (#1003
feat(maintenance): wire SOURCE_REPLAY dispatch with per-artifact curs…
docs(retro): record post-#1498 cascade umbrella + hot-file review (#1605
feat(export): add fail-closed sanitized shareable export (#2381) (#2433)
fix(storage): permit same-raw revision CAS supersede (#3194)
feat(insights): declare readiness/cost/degraded contracts for default…
feat(insights): declare readiness/cost/degraded contracts for default…
feat(insights): implement GitHub PR effect adapter via gh CLI (#3327)
feat(devtools): add cold-model MCP pagination+cancellation replay pro…
feat(insights): materialize incident work-evidence graphs from archiv…
feat(insights): add source-to-graph incident evidence materialization (…
fix(mcp): generalize response-budget paging to dict-rooted payloads (#…
fix(daemon): make health verdict consult alerts and stop going blind (#…
fix(storage): quarantine session-link cycles at write time (#3643)
fix(sources): classify Hermes candidates before session admission (#4365
fix(sources): classify Hermes candidates before session admission (#4365
fix(sources): classify Hermes candidates before session admission (#4365
sinex: primary mode and the rebuild proof; the loop builds the index …
Saved relations bind their own defaults; query hash prefixes resolve;…
Match physical work before folding logical sessions (#6998)