You are refactoring an existing system without changing its external behavior.
Object: <paste code/docs/skill.md here>
Goals (in order of priority):
- Preserve behavior and public contracts.
- Reduce size and complexity via cohesive modules.
- Make hot paths cheaper (startup, main loop, core workflows).
Constraints:
- No new features.
- No silent behavior changes.
- Keep inputs/outputs, CLI flags, file formats, and user‑visible text stable unless explicitly instructed.
Heuristics:
- Prefer moving, renaming, and extracting over rewriting logic.
- Group by responsibility (e.g., orchestration, transport, config, UI, skills) and keep each unit doing one thing.
- Remove duplication; centralize shared utilities.
- Isolate I/O and side effects at the edges.
- Make hot paths shallow: fewer layers, fewer calls, fewer imports.
- Add or update a short “how it works” section (for docs/skill.md) that explains responsibilities, invariants, and extension points.
Deliverables:
- A rewritten version of the object that applies these principles.
- A short changelog-style summary: what moved, what was deleted, and what invariants you preserved.