---
phase: 12-phase-task-decomposition
plan: 03
type: execute
wave: 2
depends_on: ["12-01"]
files_modified:
  - src/agent/manager.ts
  - src/agent/mock-manager.ts
autonomous: true
---

<objective>
Update ClaudeAgentManager and MockAgentManager to support decompose mode.

Purpose: Enable spawning agents in decompose mode with the correct JSON schema. Agents in this mode break phases into tasks.

Output: Mode-aware agent spawning handles 'decompose' mode with decomposeOutputJsonSchema.
</objective>

<execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md

# Depends on Plan 01 for decompose schema
@.planning/phases/12-phase-task-decomposition/12-01-SUMMARY.md

# Pattern reference from Phase 11 (mode handling)
@.planning/phases/11-architect-agent/11-03-SUMMARY.md

# Source files to modify
@src/agent/manager.ts
@src/agent/schema.ts
</context>

<tasks>

<task type="auto">
  <name>Task 1: Update ClaudeAgentManager for decompose mode</name>
  <files>src/agent/manager.ts</files>
  <action>
1. Import decomposeOutputSchema and decomposeOutputJsonSchema from schema.ts

2. Update getJsonSchemaForMode() to handle 'decompose':
   ```typescript
   case 'decompose':
     return decomposeOutputJsonSchema;
   ```

3. Add handleDecomposeOutput() method following pattern of handleBreakdownOutput():
   - Parse output with decomposeOutputSchema
   - Handle 'decompose_complete' status → emit agent:stopped with reason: 'decompose_complete'
   - Handle 'questions' status → emit agent:stopped with reason: 'questions'
   - Handle 'unrecoverable_error' → emit agent:stopped with reason: 'error'

4. Update handleAgentCompletion() switch to call handleDecomposeOutput for mode: 'decompose'
  </action>
  <verify>npm run build passes</verify>
  <done>ClaudeAgentManager handles decompose mode with correct schema and completion handling</done>
</task>

<task type="auto">
  <name>Task 2: Update MockAgentManager for decompose mode</name>
  <files>src/agent/mock-manager.ts</files>
  <action>
1. Add 'decompose_complete' to MockAgentScenario status type (alongside 'context_complete' and 'breakdown_complete')

2. Add tasks field to scenario result type for decompose_complete:
   ```typescript
   tasks?: Array<{ number: number; name: string; description: string; type: string; dependencies: number[] }>;
   ```

3. Update handleAgentCompletion() to handle decompose scenarios:
   - If status is 'decompose_complete', emit agent:stopped with reason: 'decompose_complete'
   - Include tasks in the output event if present

4. Update resume() to handle decompose mode similarly to breakdown mode
  </action>
  <verify>npm run build passes, npm test passes</verify>
  <done>MockAgentManager handles decompose mode scenarios for E2E testing</done>
</task>

<task type="auto">
  <name>Task 3: Extend AgentStoppedEvent reason type</name>
  <files>src/events/types.ts</files>
  <action>
Update AgentStoppedEvent reason type to include 'decompose_complete':

```typescript
reason: 'completed' | 'stopped' | 'error' | 'questions' | 'context_complete' | 'breakdown_complete' | 'decompose_complete';
```

This follows the pattern established in Phase 11 for context_complete and breakdown_complete.
  </action>
  <verify>npm run build passes</verify>
  <done>AgentStoppedEvent reason includes 'decompose_complete'</done>
</task>

</tasks>

<verification>
Before declaring plan complete:
- [ ] npm run build succeeds
- [ ] npm test passes all tests
- [ ] ClaudeAgentManager.getJsonSchemaForMode returns decomposeOutputJsonSchema for 'decompose'
- [ ] ClaudeAgentManager.handleDecomposeOutput exists and handles all statuses
- [ ] MockAgentManager handles decompose_complete scenarios
- [ ] AgentStoppedEvent.reason includes 'decompose_complete'
</verification>

<success_criteria>
- All tasks completed
- All verification checks pass
- No errors or warnings introduced
- Decompose mode fully supported in both managers
</success_criteria>

<output>
After completion, create `.planning/phases/12-phase-task-decomposition/12-03-SUMMARY.md`
</output>
