Skip to content

CLI has outgrown its flat command structure and static shell completions #23

Closed

Description

@Sinity

Context

The CLI currently exposes seventeen top-level commands: render, sync, watch, import, search, inspect, status, dashboards, settings, env, runs, prune, doctor, index, completions, help, and _complete. Running polylogue --help produces a wall of text where the operational commands (sync, import) sit alongside maintenance utilities (prune, doctor) and introspection tools (status, env, runs) with no grouping.

Shell completions are generated statically—bash gets a hardcoded word list for the first positional argument and nothing beyond that. Subcommand flags, provider names, conversation slugs, and branch IDs all require manual typing. Fish completions are similarly static. Only zsh uses the dynamic _complete endpoint, but the engine behind it only handles a subset of the command tree.

Additional concerns

Vendor shims: _vendor/frontmatter.py, _vendor/pyperclip.py, and _vendor/watchfiles.py pre-date the current pyproject.toml dependency declarations. They're dead code in normal operation but still get imported as fallbacks, creating a testing surface that diverges from production.

Memory-bound JSON parsing: The ChatGPT and Claude importers call json.loads() on entire conversations.json files. For archives with thousands of conversations this pulls the full parse tree into memory before iteration begins.

N+1 branch queries: branch_explorer._load_branch_overview issues a separate _fetch_divergence_message query per branch. Conversations with many branches generate noticeable latency.

Prune destructiveness: The prune path calls shutil.rmtree directly on output directories. An interrupted prune can leave partially deleted conversation trees that confuse subsequent syncs.

NixOS deployment: There's no NixOS module—deploying on a NixOS host requires hand-written systemd units that duplicate CLI flag knowledge and don't track target configuration declaratively.

Scope

  • Regroup commands into sync, import, browse, maintain, config hierarchies
  • Fold watch into sync --watch; remove dashboards (redundant with browse status)
  • Replace static completion scripts with dynamic completers for all subcommands
  • Add a NixOS module generating systemd timers from a declarative target manifest
  • Switch importers to streaming JSON parsing
  • Batch branch explorer divergence queries
  • Safe-prune via rename-to-trash before rmtree
  • Remove vendor shims

Acceptance criteria

  • polylogue --help shows ≤8 top-level commands with brief descriptions
  • polylogue sync codex --watch replaces polylogue watch codex
  • Tab-completing polylogue browse in bash/fish/zsh offers branches, stats, status, runs
  • Tab-completing --provider arguments offers live provider names from the state DB
  • NixOS module produces working systemd timers when services.polylogue.targets.codex.enable = true
  • ChatGPT/Claude imports stream without loading full JSON into memory
  • Prune interrupted mid-operation leaves data recoverable in .trash/

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:storagefaux-pull-requesttype:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions