# Implementation Plan: Context Composition Decoupling ## Phase 1: Core Data Model Changes Focus: Add view_mode field to FileItem, understand current coupling - [ ] Task 1.1: Audit FileItem model in models.py - add view_mode and custom_slices fields - [ ] Task 1.2: Audit _render_context_composition_panel() to understand current coupling - [ ] Task 1.3: Audit _render_files_panel() to understand how Files & Media populates context - [ ] Task 1.4: Write tests for FileItem with view_mode and custom_slices ## Phase 2: Decouple Context Composition from Files & Media Focus: Remove auto-population inheritance, make Context Composition independent - [ ] Task 2.1: Remove auto-population of context from Files & Media in context composition - [ ] Task 2.2: Add manual "Add Files" button to Context Composition (file picker from project whitelist) - [ ] Task 2.3: Implement "Add All" batch operation - [ ] Task 2.4: Write tests for decoupled context composition state ## Phase 3: Directory Grouping + File Stats Focus: Compact file listing with stats - [ ] Task 3.1: Implement directory grouping helper to group files by relative path prefix - [ ] Task 3.2: Add file stats computation (line count, AST element count) - async - [ ] Task 3.3: Render file list with collapsible directory headers - [ ] Task 3.4: Display aggregate stats (total files, lines, AST elements) - [ ] Task 3.5: Write tests for directory grouping and stats ## Phase 4: View Mode Selection UI Focus: Per-file view mode dropdown (full/sig/def/custom) - [ ] Task 4.1: Add view_mode dropdown to each file entry in Context Composition - [ ] Task 4.2: Implement custom view mode indicator (enabled when custom slices exist) - [ ] Task 4.3: Batch view mode change operations - [ ] Task 4.4: Write tests for view mode selection ## Phase 5: Context Presets Infrastructure Focus: Data structures for save/load (without UI) - [ ] Task 5.1: Create ContextPreset and FileViewPreset data models - [ ] Task 5.2: Implement serialization for context presets (TOML) - [ ] Task 5.3: Write tests for context preset models ## Phase 6: Integration + Bug Fixes Focus: Ensure aggregate respects new view modes, fix any issues - [ ] Task 6.1: Verify aggregate.py respects view_mode when composing context - [ ] Task 6.2: Test with gencpp project files - [ ] Task 6.3: Conductor - User Manual Verification