# Track Specification: Context Composition Presets

## Overview
Implement Context Preset save/load with validation, and Context Preview before sending to agent. This is Phase 3 of the Context Composition Redesign per spec at `docs/superpowers/specs/2026-05-10-context-composition-redesign-design.md`.

## Current State Audit (as of 2026-05-10)
### Already Implemented
- Preset system exists for system prompts, tool presets, personas
- ProjectManager handles TOML save/load
- Context Composition stores FileItem entries with flags

### Gaps to Fill (This Track's Scope)
- No Context Preset model for saving file+view+slices compositions
- No save/load UI for Context Presets in Context Composition panel
- No validation when loading preset (missing files warn user)
- No Context Preview showing what will be sent to agent

## Goals
1. Context Preset model with name, description, files list
2. Save Context Preset to project config
3. Load Context Preset populates Context Composition
4. Missing file validation on load with user choice
5. Context Preview before send showing exact context text

## Functional Requirements
### Context Preset Model
- Contains: name, description, list of ContextFileEntry
- ContextFileEntry: relative_path, view_mode, custom_slices
- All paths stored as relative to project root
- Serializes to TOML in project config

### Save Preset UI
- [Save] button in Context Composition
- Dialog: enter preset name + optional description
- Validation before save:
  - Check all files exist in project
  - If files missing: warn user, offer to save without or cancel

### Load Preset UI
- Dropdown selector for preset selection
- On load: clear Context Composition, populate from preset
- If file missing from preset: highlight in red, warn user
- User can proceed with missing files or re-path

### Context Preview
- "Preview" button/tab showing what will be sent
- Per file: view mode, line ranges, tags, comments
- Collapsed view: just file list + view modes
- Expanded view: actual text/slices that will be sent
- Token estimate for total context

### Stale Preset Handling
- If project changes and preset references moved/renamed files:
  - On load: detect and warn
  - User can save preset without invalid files
  - Or ignore warning and proceed

## Architecture Reference
- `src/project_manager.py` - existing preset save/load patterns
- `src/presets.py` - existing preset manager patterns to follow
- `docs/superpowers/specs/2026-05-10-context-composition-redesign-design.md`

## Out of Scope
- Slice visualization (Phase 2)
- Files & Media changes (Phase 1)
- RAG configuration changes
