# Infinite Loop Orchestrator with Utility Ecosystem

You are the orchestrator for the Infinite Agentic Loop pattern with integrated utility commands.

## Chain-of-Thought Reasoning Process

Let's think through this orchestration step by step:

**Step 1: Understand the Request**
- Parse command arguments: [spec_file] [output_dir] [count]
- Validate inputs using `/validate-spec` utility
- Check if this is a fresh start or continuation

**Step 2: Specification Analysis**
Read the specification file completely. Ask yourself:
1. What type of content are we generating?
2. What are the required file structures?
3. What uniqueness constraints apply?
4. What quality standards must be met?

**Step 3: Directory Reconnaissance**
If output directory exists:
1. List all existing files
2. Use `/analyze` utility to understand patterns
3. Identify what themes/variations have been used
4. Determine next iteration numbers

**Step 4: Planning Agent Deployment**
Calculate parallel agent strategy:
- If count <= 5: Deploy all agents in single wave
- If count <= 20: Deploy in waves of 5
- If count == "infinite": Deploy continuous waves until context limits

For each agent, assign:
1. Unique iteration number
2. Distinct creative direction
3. Constraints to avoid duplication
4. Quality requirements from spec

**Step 5: Execute Generation Wave**
For each agent in the wave:
1. Create sub-agent task with complete context
2. Include: spec, existing iterations summary, unique assignment
3. Execute in parallel using Task tool
4. Monitor progress with `/status` utility

**Step 6: Quality Validation**
After each wave:
1. Use `/test-output` to validate against spec
2. Use `/debug` if any issues detected
3. Generate `/report` for wave completion
4. Determine if next wave needed

**Step 7: Next Wave Decision**
If infinite mode or more iterations needed:
1. Increase sophistication level
2. Update creative direction assignments
3. Launch next wave
4. Repeat steps 5-7

## Command Format

```
/project:infinite [spec_file] [output_dir] [count]
```

**Arguments:**
- `spec_file`: Path to specification markdown file
- `output_dir`: Directory for generated outputs
- `count`: Number of iterations (1-20 or "infinite")

## Example Executions

```bash
# Single generation with validation
/project:infinite specs/example_spec.md outputs 1

# Small batch with analysis
/project:infinite specs/example_spec.md outputs 5

# Continuous generation with monitoring
/project:infinite specs/example_spec.md outputs infinite
```

## Utility Integration Points

Throughout execution, leverage these utilities:

**Pre-Execution:**
- `/init` - First-time setup (if needed)
- `/validate-spec` - Ensure spec is valid

**During Execution:**
- `/status` - Monitor progress
- `/debug` - Troubleshoot issues
- `/analyze` - Understand patterns

**Post-Execution:**
- `/test-output` - Validate results
- `/report` - Generate summary

## Execution Protocol

Now, let me execute the orchestration:

1. **Read the specification file provided**
   - Parse all requirements
   - Understand output structure
   - Note quality criteria

2. **Analyze existing iterations** (if any)
   - Count current files
   - Identify patterns used
   - Determine uniqueness constraints

3. **Calculate agent deployment strategy**
   - Batch size based on count
   - Creative direction assignments
   - Parallel vs sequential waves

4. **Deploy sub-agents with complete context**
   - Spec requirements
   - Existing iteration summary
   - Unique creative assignment
   - Quality standards

5. **Monitor and validate**
   - Track progress
   - Validate outputs
   - Report completion

6. **Continue or conclude**
   - If infinite: launch next wave
   - If batch: complete and report
   - If single: validate and finish

## Chain-of-Thought Benefits

This orchestrator uses explicit step-by-step reasoning to:
- **Decompose complex orchestration** into manageable phases
- **Make decision points transparent** for debugging
- **Enable mid-execution adjustment** through status monitoring
- **Provide clear rationale** for agent assignments
- **Support troubleshooting** through visible reasoning chain

Begin orchestration with the provided arguments.
