[loop-generated] [refactor] Split timmy/cli.py — 693 lines, monolithic CLI interface #1369

Closed
opened 2026-03-24 10:08:39 +00:00 by Timmy · 2 comments
Owner

Priority: High
Impact: Developer experience, CLI maintainability
Size: 693 lines

Problem

src/timmy/cli.py is a monolithic 693-line CLI interface that handles multiple responsibilities:

  • Chat interface
  • Think command
  • Status reporting
  • Session management
  • Tool safety checks

Proposed Split

src/timmy/cli/
├── __init__.py         # Main app entry point
├── chat.py            # Chat command implementation
├── think.py           # Think command implementation
├── status.py          # Status reporting
└── safety.py          # Tool safety checking

Acceptance Criteria

  • Split into 4-5 focused modules
  • Maintain exact same CLI interface
  • All existing tests pass
  • No import cycle issues
  • Clear separation of concerns

Files to Modify

  • src/timmy/cli.pysrc/timmy/cli/__init__.py
  • Create new modules as outlined above
  • Update any imports in other files

Estimated effort: 2-3 hours

**Priority**: High **Impact**: Developer experience, CLI maintainability **Size**: 693 lines ## Problem `src/timmy/cli.py` is a monolithic 693-line CLI interface that handles multiple responsibilities: - Chat interface - Think command - Status reporting - Session management - Tool safety checks ## Proposed Split ``` src/timmy/cli/ ├── __init__.py # Main app entry point ├── chat.py # Chat command implementation ├── think.py # Think command implementation ├── status.py # Status reporting └── safety.py # Tool safety checking ``` ## Acceptance Criteria - [ ] Split into 4-5 focused modules - [ ] Maintain exact same CLI interface - [ ] All existing tests pass - [ ] No import cycle issues - [ ] Clear separation of concerns ## Files to Modify - `src/timmy/cli.py` → `src/timmy/cli/__init__.py` - Create new modules as outlined above - Update any imports in other files Estimated effort: 2-3 hours
Author
Owner

Kimi Task Instructions

Files to work with:

  • src/timmy/cli.py (693 lines - split this)
  • Create new files:
    • src/timmy/cli/__init__.py
    • src/timmy/cli/chat.py (Chat interface, interactive commands)
    • src/timmy/cli/commands.py (Think, status, session management)
    • src/timmy/cli/safety.py (Tool safety checks, validation)
    • src/timmy/cli/interface.py (Main CLI entry point, argument parsing)

Refactor approach:

  1. Create cli/ package directory
  2. Extract chat-related functionality → chat.py
  3. Extract think/status/session commands → commands.py
  4. Extract tool safety logic → safety.py
  5. Keep main entry point and arg parsing in interface.py
  6. Update __init__.py to expose main entry point
  7. Update imports and entry points

Key functionality to preserve:

  • Main CLI entry point: timmy_cli() function
  • Chat interface with streaming responses
  • Think command with session management
  • Tool safety validation
  • Status reporting and diagnostics

Import compatibility:
Ensure these work after refactor:

from timmy.cli import timmy_cli
# Entry point in setup.py should still work

How to verify:

  1. tox -e unit - all tests pass
  2. tox -e lint - no import errors
  3. CLI commands still work: python -m timmy.cli chat
  4. Entry point works if defined

Split guidelines:

  • Each file 150-200 lines max
  • Keep related UI/UX together
  • Separate concerns: interface vs commands vs safety
  • Maintain clean command flow

This improves CLI maintainability and makes it easier to add new commands.

## Kimi Task Instructions **Files to work with:** - `src/timmy/cli.py` (693 lines - split this) - Create new files: - `src/timmy/cli/__init__.py` - `src/timmy/cli/chat.py` (Chat interface, interactive commands) - `src/timmy/cli/commands.py` (Think, status, session management) - `src/timmy/cli/safety.py` (Tool safety checks, validation) - `src/timmy/cli/interface.py` (Main CLI entry point, argument parsing) **Refactor approach:** 1. Create cli/ package directory 2. Extract chat-related functionality → `chat.py` 3. Extract think/status/session commands → `commands.py` 4. Extract tool safety logic → `safety.py` 5. Keep main entry point and arg parsing in `interface.py` 6. Update `__init__.py` to expose main entry point 7. Update imports and entry points **Key functionality to preserve:** - Main CLI entry point: `timmy_cli()` function - Chat interface with streaming responses - Think command with session management - Tool safety validation - Status reporting and diagnostics **Import compatibility:** Ensure these work after refactor: ```python from timmy.cli import timmy_cli # Entry point in setup.py should still work ``` **How to verify:** 1. `tox -e unit` - all tests pass 2. `tox -e lint` - no import errors 3. CLI commands still work: `python -m timmy.cli chat` 4. Entry point works if defined **Split guidelines:** - Each file 150-200 lines max - Keep related UI/UX together - Separate concerns: interface vs commands vs safety - Maintain clean command flow This improves CLI maintainability and makes it easier to add new commands.
kimi was assigned by Timmy 2026-03-24 10:21:46 +00:00
kimi was unassigned by Timmy 2026-03-24 19:18:22 +00:00
Author
Owner

[triage] Duplicate of #1401 (split cli.py). Closing to reduce queue noise.

[triage] Duplicate of #1401 (split cli.py). Closing to reduce queue noise.
Timmy closed this issue 2026-03-24 20:08:53 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1369