--- phase: 12-phase-task-decomposition plan: 02 type: execute wave: 1 depends_on: [] files_modified: - src/db/repositories/plan-repository.ts - src/db/repositories/drizzle/drizzle-plan-repository.ts - src/db/repositories/index.ts autonomous: true --- Extend PlanRepository with methods needed for task decomposition workflow. Purpose: Enable creating plans from architect output and querying plans by phase. The decompose agent needs to know what plans exist in a phase to break them into tasks. Output: PlanRepository with findByPhaseId, getNextNumber, bulk creation methods. @~/.claude/get-shit-done/workflows/execute-plan.md @~/.claude/get-shit-done/templates/summary.md @.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md # Pattern reference from Phase 11 (repository extensions) @.planning/phases/11-architect-agent/11-02-SUMMARY.md # Source files to modify @src/db/repositories/plan-repository.ts @src/db/repositories/drizzle/drizzle-plan-repository.ts @src/db/repositories/phase-repository.ts Task 1: Extend PlanRepository port interface src/db/repositories/plan-repository.ts Add the following methods to PlanRepository interface (following pattern from PhaseRepository): 1. `findByPhaseId(phaseId: string): Promise` - Get all plans for a phase, ordered by number 2. `getNextNumber(phaseId: string): Promise` - Get next available plan number (MAX+1 or 1 if none) npm run build passes (no implementation yet) PlanRepository interface extended with new methods Task 2: Implement methods in DrizzlePlanRepository src/db/repositories/drizzle/drizzle-plan-repository.ts Implement the new methods in DrizzlePlanRepository adapter: 1. `findByPhaseId(phaseId)`: - Query plans table where phase_id = phaseId - Order by number ascending - Return array (empty if none) 2. `getNextNumber(phaseId)`: - Query MAX(number) where phase_id = phaseId - Return max + 1, or 1 if no plans exist Follow the pattern from DrizzlePhaseRepository.getNextNumber. npm run build passes, npm test passes DrizzlePlanRepository implements findByPhaseId and getNextNumber Task 3: Export types from repositories index src/db/repositories/index.ts Verify PlanRepository and its types are properly exported. If not already exported: - Export PlanRepository interface - Export CreatePlanData type - Export UpdatePlanData type Check existing exports and add if missing. npm run build passes, types importable from src/db/repositories All PlanRepository types properly exported Before declaring plan complete: - [ ] npm run build succeeds - [ ] npm test passes all tests - [ ] PlanRepository.findByPhaseId exists and works - [ ] PlanRepository.getNextNumber exists and works - [ ] Types exported from index - All tasks completed - All verification checks pass - No errors or warnings introduced - PlanRepository ready for tRPC procedures After completion, create `.planning/phases/12-phase-task-decomposition/12-02-SUMMARY.md`