Repository navigation
Description
Context
Polylogue is carrying two command-layer implementations at the same time. The user-facing entrypoint is Click-based, but polylogue/cli/click_app.py still reconstructs argparse.Namespace objects and forwards into the older argparse stack in polylogue/cli/app.py, polylogue/cli/registry.py, and the setup_parser() / dispatch() modules under polylogue/cli/commands/. That means the real behavior of a single command is split across decorators, parser builders, registry wiring, and dispatch wrappers.
The duplication is already visible in a few places:
- option definitions live in both Click decorators and argparse helper functions
- help/completion behavior has to reason about parser internals instead of just the active Click tree
- command-specific helpers are trapped inside the large
app.pyentrypoint instead of living in focused modules
The same area is also where two operational problems now sit unresolved. First, rendered Markdown/HTML can contain email addresses, access tokens, and other secrets copied verbatim from transcripts, and there is no first-class CLI switch for writing sanitized output. Second, local session and export-bundle sync still rely heavily on mtime freshness checks, so harmless file touches can trigger full re-import work even when the underlying bytes did not change.
Motivation
The duplicated CLI stack is not just untidy; it is raising the cost of every new change that touches command options. Any feature that needs end-to-end plumbing has to be implemented twice before it can reach process_conversation() or persist_document(). That is the wrong place to spend complexity budget.
This is becoming urgent for two reasons.
The first is security and operational hygiene. Operators need a supported way to emit redacted Markdown/HTML when sharing archives or snapshots outside the trusted environment. Right now the only choices are “write the raw content” or “post-process the file outside Polylogue,” neither of which fits the existing persistence and hashing model.
The second is repeated sync cost. Local session sync has enough state to do better than mtime-only freshness checks, but the current option and pipeline wiring make small improvements feel expensive because every flag and codepath crosses the Click/argparse split.
Scope
In scope:
- remove the argparse compatibility layer and make Click the only command dispatch path
- extract command-specific helpers from
polylogue/cli/app.pyinto focused modules - add a first-class sanitizing output flag that reaches the persistence boundary
- use raw content hashes to skip unchanged local sessions and unchanged export bundles
- move CLI tests toward direct Click invocation instead of parser-object assertions
Out of scope:
- redesigning the user-visible command taxonomy
- changing raw import retention semantics
- introducing a new typed options layer for every command helper
Acceptance criteria
polylogue/cli/app.py,polylogue/cli/registry.py, and the argparse dispatch wrappers are no longer required for command execution- Click callbacks dispatch directly to the real
run_*_clihelpers without reconstructing argparse parser state - sync/import/render accept a sanitizing flag that causes persisted Markdown/HTML to be redacted and marked as redacted in metadata
- unchanged local session files and unchanged export bundles skip reprocessing based on content hashes, with mtime checks remaining only as fallback behavior
- CLI tests exercise the Click group directly and cover both redaction metadata and hash-based skip behavior
Activity