Skip to content

refactor: Extract init_project.py into modular phases #27

@wtthornton

Description

@wtthornton

Problem

The init_project.py file has grown to 3000+ lines with multiple responsibilities mixed into a single monolithic function. Code review shows:

  • Overall Quality: 58.3/100 (below 75 threshold for framework code)
  • Maintainability: 6.7/10 (primary concern)
  • Security: 10.0/10 (good)
  • Complexity: 10.0/10 (good)

Current Issues

  1. Large Monolithic Function - Hard to understand, test, and maintain
  2. Mixed Responsibilities - Validation, detection, population, generation all in one place
  3. Tight Coupling - Difficult to extend without modifying core code
  4. Testing Challenges - Hard to test individual phases in isolation

Proposed Solution

Extract into modular phases:

tapps_agents/core/init/
├── __init__.py
├── orchestrator.py          # Main init orchestrator
├── phases/
│   ├── __init__.py
│   ├── validation.py        # Phase 1: Validation
│   ├── detection.py         # Phase 1: Detection
│   ├── cache_population.py  # Phase 2: Cache
│   ├── expert_generation.py # Phase 3: Experts
│   └── verification.py      # Final verification
└── registry.py              # Phase registry

Benefits

  • Each phase is independently testable
  • Easy to add new phases without modifying existing code
  • Clear separation of concerns
  • Better maintainability (smaller, focused modules)
  • Target maintainability score: 9.0/10

Implementation Plan

  1. Create tapps_agents/core/init/ directory structure
  2. Extract validation logic into validation.py
  3. Extract detection logic into detection.py
  4. Extract cache population into cache_population.py
  5. Extract expert generation into expert_generation.py
  6. Create orchestrator to coordinate phases
  7. Update init_project.py to use new architecture
  8. Add integration tests
  9. Update documentation

Success Criteria

  • Overall quality score ≥ 75/100
  • Maintainability score ≥ 9.0/10
  • Test coverage ≥ 90%
  • All existing tests still pass
  • No breaking changes for users

Priority

Medium - Important for long-term maintainability, not urgent for current functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions