# Interactive Configuration Utility

You are an interactive configuration assistant helping users create and modify infinite loop configurations.

## Command Usage

```
/project:configure [action] [profile] [output_path]
```

**Actions:**
- `create` - Create new custom configuration interactively
- `edit` - Edit existing configuration
- `compare` - Compare two configurations
- `optimize` - Optimize configuration for specific use case
- `merge` - Merge multiple configurations

**Examples:**
```bash
# Create new custom configuration
/project:configure create

# Create configuration based on production profile
/project:configure create production my_config.json

# Edit existing configuration
/project:configure edit examples/custom_config.json

# Compare development vs production
/project:configure compare development production

# Optimize for speed
/project:configure optimize speed

# Optimize for quality
/project:configure optimize quality

# Merge development + custom overrides
/project:configure merge development examples/custom_config.json output.json
```

## Action: CREATE

Interactive configuration creation workflow using chain prompting.

### STAGE 1: Determine Base Profile

Ask user:
```
Choose a base profile to start from:
1. development - Optimized for testing and iteration (smaller batches, verbose logging)
2. production - Optimized for scale and efficiency (larger batches, minimal logging)
3. research - Optimized for quality and exploration (maximum quality checks, extensive logging)
4. defaults - Start from system defaults

Enter selection (1-4):
```

Load selected profile as base.

### STAGE 2: Configure Orchestration

Ask user for orchestration settings:
```
=== ORCHESTRATION SETTINGS ===

How many parallel agents should run simultaneously? (1-10)
Current: {current_value}
Recommendation: 3-5 for balanced performance
Enter value or press Enter to keep current:

What batch size should be used? (1-50)
Current: {current_value}
Recommendation: 5-10 for development, 10-20 for production
Enter value or press Enter to keep current:

For infinite mode, how many iterations per wave? (1-20)
Current: {current_value}
Recommendation: Equal to or multiple of max_parallel_agents
Enter value or press Enter to keep current:

Enable progressive sophistication in infinite mode? (yes/no)
Current: {current_value}
Increases complexity with each wave
Enter yes/no or press Enter to keep current:
```

Update configuration with responses.

### STAGE 3: Configure Generation

Ask user for generation settings:
```
=== GENERATION SETTINGS ===

Output directory name?
Current: {current_value}
Enter directory name or press Enter to keep current:

File naming pattern?
Current: {current_value}
Available placeholders: {theme}, {iteration}, {variant}, {timestamp}
Examples:
  - {theme}_{iteration:03d}.html
  - output_{iteration:04d}_{variant}.html
  - {theme}_{timestamp}_{iteration}.html
Enter pattern or press Enter to keep current:

Include metadata in generated files? (yes/no)
Current: {current_value}
Enter yes/no or press Enter to keep current:
```

### STAGE 4: Configure Quality

Ask user for quality settings:
```
=== QUALITY SETTINGS ===

Minimum uniqueness threshold (0.0 - 1.0)?
Current: {current_value}
0.7 = fairly unique, 0.85 = very unique, 0.95 = extremely unique
Enter value or press Enter to keep current:

Enable validation of generated outputs? (yes/no)
Current: {current_value}
Enter yes/no or press Enter to keep current:

Enable review stage in chain prompting? (yes/no)
Current: {current_value}
Adds review step but increases execution time by 30-50%
Enter yes/no or press Enter to keep current:

Maximum retry attempts for failed generations (0-5)?
Current: {current_value}
Enter value or press Enter to keep current:
```

### STAGE 5: Configure Web Enhancement

Ask user for web enhancement settings:
```
=== WEB ENHANCEMENT SETTINGS ===

Enable web-enhanced generation? (yes/no)
Current: {current_value}
Fetches web resources to inform generation
Enter yes/no or press Enter to keep current:

[If yes:]

How many URLs to fetch during initial priming (0-10)?
Current: {current_value}
Recommendation: 2-3 for quick start, 5-8 for comprehensive priming
Enter value or press Enter to keep current:

How many URLs to fetch per iteration (0-5)?
Current: {current_value}
Recommendation: 1 for focused learning, 2-3 for diverse learning
Enter value or press Enter to keep current:

Use progressive difficulty for URL selection? (yes/no)
Current: {current_value}
Starts with basic tutorials, progresses to advanced documentation
Enter yes/no or press Enter to keep current:

Enable web search fallback when URLs exhausted? (yes/no)
Current: {current_value}
Enter yes/no or press Enter to keep current:
```

### STAGE 6: Configure Logging

Ask user for logging settings:
```
=== LOGGING SETTINGS ===

Logging level?
1. debug - Detailed information for debugging
2. info - General informational messages
3. warn - Warning messages only
4. error - Error messages only
Current: {current_value}
Enter selection (1-4) or press Enter to keep current:

Log agent outputs? (yes/no)
Current: {current_value}
Logs what each sub-agent generates
Enter yes/no or press Enter to keep current:

Log web fetches? (yes/no)
Current: {current_value}
Logs URLs fetched and content retrieved
Enter yes/no or press Enter to keep current:

Verbose mode? (yes/no)
Current: {current_value}
Maximum detail in all logs (use for debugging only)
Enter yes/no or press Enter to keep current:
```

### STAGE 7: Configure Limits

Ask user for limits:
```
=== LIMITS ===

Maximum iterations before automatic stop?
Current: {current_value}
Recommendation: 10-50 for testing, 100-1000 for production
Enter value or press Enter to keep current:

Maximum file size in KB?
Current: {current_value}
Recommendation: 300-500 KB for HTML files
Enter value or press Enter to keep current:

Maximum total output size in MB?
Current: {current_value}
Recommendation: 10 MB for testing, 50-100 MB for production
Enter value or press Enter to keep current:

Warn at iteration number?
Current: {current_value}
Shows warning to user at this iteration
Enter value or press Enter to keep current:
```

### STAGE 8: Review and Save

Display complete configuration:
```
=== CONFIGURATION SUMMARY ===

Profile: {profile}

Orchestration:
  - Parallel agents: {max_parallel_agents}
  - Batch size: {batch_size}
  - Infinite wave size: {infinite_mode_wave_size}
  - Progressive sophistication: {enable_progressive_sophistication}

Generation:
  - Output directory: {output_directory}
  - Naming pattern: {naming_pattern}
  - Include metadata: {include_metadata}

Quality:
  - Uniqueness threshold: {min_uniqueness_threshold}
  - Validation: {enable_validation}
  - Review stage: {enable_review_stage}
  - Max retries: {max_retry_attempts}

Web Enhancement:
  - Enabled: {enabled}
  - Initial priming URLs: {initial_priming_urls}
  - URLs per iteration: {urls_per_iteration}
  - Progressive difficulty: {progressive_difficulty}

Logging:
  - Level: {level}
  - Verbose: {verbose}

Limits:
  - Max iterations: {max_iterations}
  - Max file size: {max_file_size_kb} KB
  - Max total output: {max_total_output_mb} MB

Is this configuration correct? (yes/no/edit):
```

If user confirms:
- Validate configuration using validation stages
- Save to specified path or default location
- Confirm save

If user wants to edit:
- Ask which section to modify
- Return to that stage

If user cancels:
- Discard and exit

## Action: EDIT

Edit existing configuration file.

### Process
1. Read existing configuration using Read tool
2. Display current settings
3. Ask user which section to modify:
   - orchestration
   - generation
   - quality
   - web_enhancement
   - logging
   - limits
   - all
4. For selected section, show current values and prompt for changes
5. Validate changes
6. Save updated configuration

## Action: COMPARE

Compare two configurations side-by-side.

### Process
1. Load first configuration
2. Load second configuration
3. Display comparison table:

```
========================================
CONFIGURATION COMPARISON
========================================

Configuration A: {path_a}
Configuration B: {path_b}

ORCHESTRATION:
                              A          B        Diff
  max_parallel_agents        3          5        +2
  batch_size                 5          10       +5
  infinite_mode_wave_size    3          10       +7
  progressive_sophistication true       true     =

GENERATION:
                              A              B            Diff
  output_directory           output_dev     output_prod  different
  naming_pattern             {theme}...     {theme}...   different
  include_metadata           true           false        different

QUALITY:
                              A          B        Diff
  min_uniqueness_threshold   0.7        0.9      +0.2
  enable_validation          true       true     =
  enable_review_stage        true       false    different
  max_retry_attempts         3          2        -1

WEB ENHANCEMENT:
                              A          B        Diff
  enabled                    true       true     =
  initial_priming_urls       2          5        +3
  urls_per_iteration         1          2        +1
  progressive_difficulty     false      true     different

LOGGING:
                              A          B        Diff
  level                      debug      warn     different
  verbose                    true       false    different

LIMITS:
                              A          B        Diff
  max_iterations             10         1000     +990
  max_file_size_kb           300        500      +200
  max_total_output_mb        10         100      +90

SUMMARY:
  Configuration A: Optimized for development/testing
  Configuration B: Optimized for production scale

  Key differences:
    - B uses 66% more parallel agents
    - B has 100x higher iteration limit
    - B uses minimal logging vs verbose debugging
    - B has stricter quality thresholds
    - A enables review stage (slower but higher quality)
========================================
```

## Action: OPTIMIZE

Optimize configuration for specific use case.

### Use Cases
1. **speed** - Optimize for fastest execution
2. **quality** - Optimize for highest quality output
3. **scale** - Optimize for large batch processing
4. **development** - Optimize for iterative development
5. **research** - Optimize for experimentation

### Optimization Profiles

**Speed Optimization:**
- max_parallel_agents: 10 (maximum parallelism)
- batch_size: 20-50 (large batches)
- enable_validation: false (skip validation)
- enable_review_stage: false (skip review)
- logging.level: warn (minimal logging)
- web_enhancement.enabled: false (skip web fetches)

**Quality Optimization:**
- max_parallel_agents: 2-3 (more careful generation)
- min_uniqueness_threshold: 0.95 (very high uniqueness)
- enable_validation: true
- enable_review_stage: true
- max_retry_attempts: 5
- web_enhancement.initial_priming_urls: 8 (extensive priming)
- logging.level: debug (detailed logging)

**Scale Optimization:**
- max_parallel_agents: 5
- batch_size: 10
- infinite_mode_wave_size: 10
- max_iterations: 1000
- enable_validation: true
- enable_review_stage: false (too slow at scale)
- logging.level: info

**Development Optimization:**
- max_parallel_agents: 2
- batch_size: 3
- max_iterations: 10
- enable_validation: true
- enable_review_stage: true
- logging.level: debug
- verbose: true

**Research Optimization:**
- max_parallel_agents: 3
- min_uniqueness_threshold: 0.95
- enable_validation: true
- enable_review_stage: true
- max_retry_attempts: 5
- web_enhancement: full configuration
- enable_cross_iteration_learning: true
- logging: comprehensive

### Process
1. Ask user to confirm use case
2. Load appropriate base profile
3. Apply optimizations
4. Show before/after comparison
5. Validate optimized configuration
6. Save if user confirms

## Action: MERGE

Merge multiple configurations with conflict resolution.

### Process
1. Load base configuration
2. Load override configuration(s)
3. Perform deep merge (later configs override earlier)
4. Display merge summary showing:
   - Which values came from which source
   - Any conflicts and how resolved
   - Final merged configuration
5. Validate merged configuration
6. Save to output path

### Merge Example
```
========================================
CONFIGURATION MERGE
========================================

Base: .claude/config/profiles/development.json
Override: examples/custom_config.json
Output: merged_config.json

MERGE SUMMARY:

orchestration.max_parallel_agents
  Base: 2
  Override: 5
  Final: 5 (from override)

orchestration.batch_size
  Base: 3
  Override: (not set)
  Final: 3 (from base)

web_enhancement.enabled
  Base: true
  Override: true
  Final: true (same in both)

logging.level
  Base: debug
  Override: info
  Final: info (from override)

Total fields: 45
From base only: 30
From override only: 5
Overridden: 10
Conflicts resolved: 10

Merged configuration validated: PASSED
Saved to: merged_config.json
========================================
```

## Configuration Templates

Provide quick-start templates:

### Template: High-Speed Batch Processing
```json
{
  "profile": "speed_optimized",
  "orchestration": {
    "max_parallel_agents": 10,
    "batch_size": 50
  },
  "quality": {
    "enable_validation": false,
    "enable_review_stage": false
  },
  "logging": {
    "level": "warn",
    "verbose": false
  },
  "web_enhancement": {
    "enabled": false
  }
}
```

### Template: Maximum Quality
```json
{
  "profile": "quality_focused",
  "orchestration": {
    "max_parallel_agents": 2
  },
  "quality": {
    "min_uniqueness_threshold": 0.95,
    "enable_validation": true,
    "enable_review_stage": true,
    "max_retry_attempts": 5
  },
  "web_enhancement": {
    "enabled": true,
    "initial_priming_urls": 8,
    "urls_per_iteration": 3
  }
}
```

### Template: Balanced Production
```json
{
  "profile": "balanced_production",
  "orchestration": {
    "max_parallel_agents": 5,
    "batch_size": 10
  },
  "quality": {
    "min_uniqueness_threshold": 0.85,
    "enable_validation": true,
    "enable_review_stage": false
  },
  "web_enhancement": {
    "enabled": true,
    "initial_priming_urls": 3,
    "urls_per_iteration": 1
  },
  "logging": {
    "level": "info"
  }
}
```

## Notes

- All configurations validated before saving
- Interactive prompts support defaults (press Enter to keep current)
- Configurations can be chained: create → optimize → validate
- Use validation command to check any configuration
- Merge supports unlimited number of override configs
- Templates can be customized after creation
