Repository navigation
Description
Context
Three modules have grown past comfortable working size:
-
click_app.py(830 lines): Every CLI command definition, all formatting helpers (format_counts,format_cursors,format_index_status), source resolution logic, theAppEnvdataclass, plain-mode detection, and the summary printer. Adding a new command or modifying output formatting requires navigating the entire file. -
run.py(510 lines): Content hashing (_hash_text,_hash_payload,_hash_file), ID generation (_conversation_id,_message_id,_attachment_content_id), existing-record lookups, ingest preparation, pipeline orchestration, run JSON writing, and the re-run detection logic. The hashing functions are duplicated fromsource_ingest.py. -
source_ingest.py(560 lines): Provider detection heuristics, five different parsing strategies (ChatGPT mapping, Claude chat_messages, Claude Code sessions, Codex prompt/completion, Drive chunkedPrompt), role normalization, attachment extraction, and file iteration. Each provider's logic is interleaved with generic dispatch.
Carrying costs
-
Duplicate code: SHA-256 hashing is implemented identically in both
run.pyandsource_ingest.py. Timestamp formatting exists inclick_app.pywith no shared utility. -
Testing friction: Testing a single provider's parsing requires importing the entire
source_ingestmodule with all its dependencies. Similarly, testing CLI formatting pulls in every command's imports. -
Merge conflicts: Any two branches touching CLI commands will conflict in the same 830-line file. Same for pipeline changes in
run.py. -
Feature resistance: Adding a web server, search filters, or concurrent ingestion to these monoliths means either bloating them further or doing ad-hoc extraction mid-feature.
Scope
In scope:
- Decompose
click_app.pyinto a commands subpackage plus shared helpers - Extract pipeline orchestration from
run.pyinto apipeline/package - Split provider-specific parsing from
source_ingest.pyintoimporters/modules - Consolidate duplicated utilities (hashing, timestamps) into a
core/package - Separate render output path from archive root in config
Out of scope:
- Async pipeline execution (concurrency is fine, async conversion is separate)
- Provider plugin system (importers are still hard-coded dispatch)
- Schema migration tooling
Acceptance criteria
-
click_app.pyis under 50 lines; each command lives in its own module -
run.pycontains only re-exports; actual logic lives inpipeline/ - Each provider has a dedicated module under
importers/withlooks_like()andparse()functions - No duplicate hashing implementations;
core/hashing.pyis the single source -
render_rootis a separate config field with environment variable override - Existing import paths from
run.pystill work (backward-compatible facade)
Activity