Repository navigation
Description
Context
polylogue/cli.py is approaching 1900 lines. It contains the argument parser, every command handler, every interactive prompt, the import summary builder, the settings menu, and the watcher loop. Adding a new subcommand means touching a file where a merge conflict is almost guaranteed, and the import graph is becoming circular as domain modules reach back into CLI helpers.
All output paths are rooted at /realm/data/chatlog/, a host-specific NixOS mount. Running on any other machine requires overriding every default via flags or environment variables. The _attachments/ directory naming also collides with static-site generators that treat underscore-prefixed paths as special.
The per-conversation output is a flat pair: slug.md alongside slug_attachments/. There's no natural place for branch transcripts, overlay files, or per-conversation HTML explorers — everything would need to be crammed into the attachment directory or scattered at the same level as the Markdown.
Motivation
Two features are ready to land — branch graph exploration and FTS5 transcript search — but both need new CLI surfaces (argument groups, interactive pickers, HTML output) that would push the monolith past 2500 lines. The branch explorer specifically needs a per-conversation directory to write branches/<id>/<id>.md alongside the canonical transcript.
The Nix package also ships without its CLI dependencies (gum, skim, delta) on PATH, which means the interactive UI silently falls back to plain mode after a nix build unless the user has those tools installed globally.
Scope
In scope:
- Decompose
cli.pyinto acli/package grouped by command surface - Replace all hardcoded paths with XDG base directory derivations
- Migrate output layout from
slug.md+slug_attachments/toslug/conversation.md+slug/attachments/ - Unify
sync-codex,sync-claude-code, andsync(Drive) undersync <provider> - Add
inspect branches,inspect search,inspect statscommand group - Add
prunecommand for cleaning up legacy flat-file outputs - Change
--htmlfrom boolean to tri-state (on|off|auto) - Wrap the Nix package binary with CLI tool paths
- Add tiktoken and qdrant-client to the dependency set
Out of scope:
- Async migration (separate concern)
- Click migration (separate concern)
- Provider-specific parser changes beyond the layout migration
Acceptance criteria
-
polylogue sync codex --html on --jsonproduces JSON withslugfields matching the new directory names -
polylogue inspect branches --provider chatgptrenders a tree and optionally writes an HTML explorer -
polylogue inspect search "error" --with-attachments --jsonreturns filtered FTS5 hits -
polylogue prune --dry-runlists legacy*.mdand*_attachments/paths without deleting - All XDG paths respect their environment variables and fall back to
~/.config,~/.local/share,~/.local/state -
nix build .#polylogue && result/bin/polylogue doctorworks without gum/skim on the system PATH - Existing tests pass with the tiktoken stub; new tests cover branch exploration, search, CLI dispatch, zip traversal
Activity
devloop: preserve schema bootstrap ownership (#6387)