[loop-generated] [refactor] Split timmy/tools/_registry.py — 586 lines, tool management bottleneck #1391

Closed
opened 2026-03-24 11:35:15 +00:00 by Timmy · 1 comment
Owner

Current State:

  • src/timmy/tools/_registry.py is 586 lines with extensive tool registration and management logic
  • Contains tool discovery, registration, validation, execution, and metadata management
  • Critical bottleneck for tool system performance and maintainability

Proposed Split:

src/timmy/tools/registry/
├── __init__.py          # Main registry interface
├── discovery.py         # Tool discovery and scanning
├── registration.py      # Tool registration and validation
├── execution.py         # Tool execution and lifecycle management
├── metadata.py          # Tool metadata and documentation
└── caching.py           # Tool caching and performance optimization

Benefits:

  • Reduced startup time (lazy loading)
  • Better tool isolation and testing
  • Clearer tool lifecycle management
  • Easier to add new tool types

Acceptance Criteria:

  • All tool functionality preserved
  • Tool registration performance maintained or improved
  • Tests pass
  • Each module under 150 lines
  • Backward compatibility maintained
**Current State:** - `src/timmy/tools/_registry.py` is 586 lines with extensive tool registration and management logic - Contains tool discovery, registration, validation, execution, and metadata management - Critical bottleneck for tool system performance and maintainability **Proposed Split:** ``` src/timmy/tools/registry/ ├── __init__.py # Main registry interface ├── discovery.py # Tool discovery and scanning ├── registration.py # Tool registration and validation ├── execution.py # Tool execution and lifecycle management ├── metadata.py # Tool metadata and documentation └── caching.py # Tool caching and performance optimization ``` **Benefits:** - Reduced startup time (lazy loading) - Better tool isolation and testing - Clearer tool lifecycle management - Easier to add new tool types **Acceptance Criteria:** - [ ] All tool functionality preserved - [ ] Tool registration performance maintained or improved - [ ] Tests pass - [ ] Each module under 150 lines - [ ] Backward compatibility maintained
Author
Owner

Implementation Instructions for Kimi:

Step 1: Analyze the current tool registry

wc -l src/timmy/tools/_registry.py
grep -n "class\|def " src/timmy/tools/_registry.py | head -20

Step 2: Create the registry package structure

mkdir -p src/timmy/tools/registry
touch src/timmy/tools/registry/__init__.py

Step 3: Split by responsibility

  • discovery.py: Move tool discovery, scanning, and detection logic
  • registration.py: Move tool registration, validation, and metadata processing
  • execution.py: Move tool execution, lifecycle management, and runtime handling
  • metadata.py: Move tool documentation, schema validation, and introspection
  • caching.py: Move performance optimization, lazy loading, and caching logic
  • init.py: Import and expose the main registry API

Step 4: Preserve backward compatibility

  • Ensure from timmy.tools._registry import ToolRegistry still works
  • Update imports across the codebase
  • Verify tool discovery and registration still functions

Step 5: Run tests

tox -e unit
grep -r "_registry" tests/ | head -10

Critical: The tool registry is a performance bottleneck. Each module should be under 150 lines and implement lazy loading where possible.

Files to verify after split:

  • Check all tool imports still work
  • Verify tool registration performance is maintained
  • Ensure tool execution paths are preserved
**Implementation Instructions for Kimi:** **Step 1: Analyze the current tool registry** ```bash wc -l src/timmy/tools/_registry.py grep -n "class\|def " src/timmy/tools/_registry.py | head -20 ``` **Step 2: Create the registry package structure** ```bash mkdir -p src/timmy/tools/registry touch src/timmy/tools/registry/__init__.py ``` **Step 3: Split by responsibility** - **discovery.py**: Move tool discovery, scanning, and detection logic - **registration.py**: Move tool registration, validation, and metadata processing - **execution.py**: Move tool execution, lifecycle management, and runtime handling - **metadata.py**: Move tool documentation, schema validation, and introspection - **caching.py**: Move performance optimization, lazy loading, and caching logic - **__init__.py**: Import and expose the main registry API **Step 4: Preserve backward compatibility** - Ensure `from timmy.tools._registry import ToolRegistry` still works - Update imports across the codebase - Verify tool discovery and registration still functions **Step 5: Run tests** ```bash tox -e unit grep -r "_registry" tests/ | head -10 ``` **Critical:** The tool registry is a performance bottleneck. Each module should be under 150 lines and implement lazy loading where possible. **Files to verify after split:** - Check all tool imports still work - Verify tool registration performance is maintained - Ensure tool execution paths are preserved
kimi was assigned by Timmy 2026-03-24 11:50:34 +00:00
kimi was unassigned by Timmy 2026-03-24 19:33:27 +00:00
Timmy closed this issue 2026-03-24 21:54:17 +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#1391