Skip to content

Monolithic CLI and hardcoded paths block new inspection features #15

Closed

Description

@Sinity

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.py into a cli/ package grouped by command surface
  • Replace all hardcoded paths with XDG base directory derivations
  • Migrate output layout from slug.md + slug_attachments/ to slug/conversation.md + slug/attachments/
  • Unify sync-codex, sync-claude-code, and sync (Drive) under sync <provider>
  • Add inspect branches, inspect search, inspect stats command group
  • Add prune command for cleaning up legacy flat-file outputs
  • Change --html from 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 --json produces JSON with slug fields matching the new directory names
  • polylogue inspect branches --provider chatgpt renders a tree and optionally writes an HTML explorer
  • polylogue inspect search "error" --with-attachments --json returns filtered FTS5 hits
  • polylogue prune --dry-run lists legacy *.md and *_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 doctor works 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

  1. added
    type:refactor
    faux-pull-request
    on Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliarea:pipelinearea:schemaarea:storagefaux-pull-requesttype:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions