- Import max from drizzle-orm for aggregate query
- Query MAX(number) where phase_id matches
- Return max + 1, or 1 if no plans exist
- Pattern follows DrizzlePhaseRepository.getNextNumber
Add architect workflow E2E tests for discuss mode:
- Test spawning architect in discuss mode with context_complete
- Test pause on questions and resume with answers flow
Add convenience methods for architect mode testing:
- setArchitectDiscussComplete for context_complete scenarios
- setArchitectDiscussQuestions for discuss mode questions
- setArchitectBreakdownComplete for breakdown_complete scenarios
- getInitiative, getPhases, createInitiative, createPhasesFromBreakdown
- mockAgentManager alias, advanceTimers, getEmittedEvents helpers
- Wire up initiative/phase repositories and tRPC caller to harness
Also fix pre-existing test issues with dependencies and type casting.
- Test findByNumber with matching/non-matching initiative and number
- Test getNextNumber returns 1 for empty initiative
- Test getNextNumber returns max + 1 with existing phases
- Test getNextNumber handles gaps in numbering
- Test default execute mode on spawn
- Test discuss mode with context_complete scenario
- Test breakdown mode with breakdown_complete scenario
- Verify stopped event reasons for each mode
Add CLI commands for initiative management:
- cw initiative create <name> - create with optional description
- cw initiative list - list all with optional status filter
- cw initiative get <id> - get details by ID
- Add spawnArchitectDiscuss for context-gathering mode
- Add spawnArchitectBreakdown for phase decomposition mode
- Both procedures validate initiative exists before spawning
- Use comprehensive prompts from agent/prompts module
- Add buildDiscussPrompt for context gathering mode
- Add buildBreakdownPrompt for phase decomposition mode
- Add buildExecutePrompt for standard task execution
- Export prompts from agent module index
- Import all mode-specific JSON schemas (discuss, breakdown)
- Add getJsonSchemaForMode() helper to select schema by mode
- Update spawn() to pass mode to repository and use mode-specific schema
- Refactor handleAgentCompletion() to route to mode-specific handlers
- Add handleExecuteOutput() for execute mode (existing behavior)
- Add handleDiscussOutput() for discuss mode (context_complete status)
- Add handleBreakdownOutput() for breakdown mode (breakdown_complete status)
- Update resume() to use mode-specific JSON schema
- Add context_complete scenario for discuss mode
- Add breakdown_complete scenario for breakdown mode
- Import Decision and PhaseBreakdown types from schema
- Handle context_complete status with decisions array
- Handle breakdown_complete status with phases array
- Extend AgentStoppedEvent reason type for new completion reasons
- Export questionItemSchema and add QuestionItem type
- Add Decision type for discuss mode (topic/decision/reason)
- Add PhaseBreakdown type for breakdown mode
- Create discussOutputSchema (questions/context_complete/error)
- Create breakdownOutputSchema (questions/breakdown_complete/error)
- Add discussOutputJsonSchema for Claude CLI --json-schema
- Add breakdownOutputJsonSchema for Claude CLI --json-schema
- Add findByNumber method to lookup phase by initiative and number
- Add getNextNumber method to get next available phase number
- Implement both methods in DrizzlePhaseRepository adapter
- Use drizzle-orm max() and and() for query construction
- Add AgentMode type: 'execute' | 'discuss' | 'breakdown'
- Add mode column to agents table with 'execute' default
- Update SpawnAgentOptions to accept optional mode
- Update AgentInfo interface to include mode field
- Update ClaudeAgentManager.toAgentInfo to map mode
- Fix MockAgentManager to include mode in spawn
- Fix dispatch manager tests to include mode
- Add findByStatus method to InitiativeRepository port interface
- Implement findByStatus in DrizzleInitiativeRepository adapter
- Filter initiatives by status (active/completed/archived)
- Add prompts.ts module with mode-specific agent prompts
- Discuss prompt includes question categories and output format
- Breakdown prompt includes phase design rules
- Execute prompt for standard worker agents
- Tests agent asking two questions at once
- Verifies both questions present in pending questions
- Validates resume with answers for all questions
- Confirms task completes after batched answer resume
- Change resume() signature from (agentId, prompt) to (agentId, answers)
- Accept Record<string, string> mapping question IDs to user answers
- Clear pendingQuestions on resume
- Update mock-manager tests for new signature
- Change resume() signature from (agentId, prompt) to (agentId, answers)
- Accept Record<string, string> mapping question IDs to user answers
- Format answers as structured prompt for Claude CLI
- Update AgentManager interface in types.ts
- Update manager tests for new signature
- Change status from 'question' to 'questions' (plural)
- Add QuestionItem with id field for answer matching
- Update PendingQuestion to PendingQuestions with questions array
- Update AgentWaitingEvent payload to questions array
- Update ClaudeAgentManager and MockAgentManager adapters
- Update TestHarness and all test files