AgentManager was never instantiated or passed to the CoordinationServer,
causing all agent-related tRPC procedures to throw "Agent manager not
available". Creates DrizzleAgentRepository, SimpleGitWorktreeManager,
and ClaudeAgentManager in startServer() and passes agentManager into
the server context deps.
listWaitingAgents, listAgents, and getAgentQuestions now return empty
results instead of throwing when agentManager is not wired into the
tRPC context. Mutation procedures (spawn, stop, resume) still throw.
- getAgentQuestions returns structured PendingQuestions from AgentManager
- listWaitingAgents filters agents to waiting_for_input status
- Updated JSDoc procedure list with both new procedures
The server never created a database or instantiated repositories, so all
tRPC procedures requiring initiativeRepository (and other repos) threw
"Initiative repository not available" on every request.
- Create ensureSchema() for shared database table initialization
- Extend TrpcAdapterOptions to accept all repository/manager dependencies
- Add ServerContextDeps to CoordinationServer for dependency injection
- Wire database, schema, and repositories in CLI startServer()
- Refactor test-helpers to use shared ensureSchema()
startServer() was creating CoordinationServer without an EventBus,
causing all tRPC requests to fail with "Server not initialized or
missing eventBus". Create and pass EventBus through to both
ProcessManager and CoordinationServer.
Create tRPC client with httpBatchLink targeting /trpc (Vite proxy).
Wrap app in trpc.Provider and QueryClientProvider with sensible
defaults. Add health check query to App.tsx for connection
verification. Add vite-env.d.ts for CSS module types. Remove
unused Plan import from backend router.
- Test independent phases dispatch in parallel
- Test dependent phase waits for prerequisite
- Test diamond dependency pattern (A -> B,C -> D)
- Test blocked phase prevents dispatch
- Test blocked phase propagates down dependency chain
- Import PhaseDispatchManager type and DefaultPhaseDispatchManager
- Add phaseDispatchManager property to TestHarness interface
- Wire DefaultPhaseDispatchManager with phaseRepository and eventBus
Add phase command group with dependency management and dispatch operations:
- cw phase add-dependency: Create dependency between phases
- cw phase dependencies: List dependencies for a phase
- cw phase queue: Queue phase for execution
- cw phase dispatch: Dispatch next available phase
- cw phase queue-status: Show queued, ready, and blocked phases
- Import PhaseDispatchManager type from dispatch module
- Add requirePhaseDispatchManager helper function
- Add createPhaseDependency: creates dependency between two phases
- Add getPhaseDependencies: returns phase IDs that a phase depends on
- Add queuePhase: queues phase for dispatch
- Add dispatchNextPhase: dispatches next available phase
- Add getPhaseQueueState: returns phase queue state
All procedures follow existing naming conventions and error handling patterns.
- Import PhaseDispatchManager type from dispatch module
- Add optional phaseDispatchManager to TRPCContext interface
- Add phaseDispatchManager to CreateContextOptions
- Wire phaseDispatchManager through createContext function
Includes blocking fix: added 'blocked' status to phases schema enum
- Add createDependency(phaseId, dependsOnPhaseId) to interface and adapter
- Add getDependencies(phaseId) returning IDs of phases this phase depends on
- Add getDependents(phaseId) returning IDs of phases that depend on this phase
- Import phaseDependencies table in DrizzlePhaseRepository
- Follow exact pattern from DrizzleTaskRepository.createDependency
- PhaseQueuedEvent for tracking phases awaiting execution
- PhaseStartedEvent for phase execution start
- PhaseCompletedEvent for phase completion with success flag
- PhaseBlockedEvent for blocked phases with reason
- Add phase_dependencies table mirroring task_dependencies pattern
- Add phaseId and dependsOnPhaseId FK columns with cascade delete
- Add phasesRelations with dependsOn and dependents many relations
- Add phaseDependenciesRelations with phase and dependsOnPhase one relations
- Export PhaseDependency and NewPhaseDependency types
- Add proper test timeouts (120s for real API calls)
- Document key finding: result field is empty, structured_output has data
- Add validation cost estimates (~$0.025 per simple call)
- Confirm MockAgentManager accurately simulates real CLI behavior
- Add structured_output field to ClaudeCliResult interface
- Read from structured_output when present (--json-schema response)
- Fall back to parsing result for backwards compatibility
- Add test file for validating JSON schemas with real Claude CLI
- Tests are skipped by default (REAL_CLAUDE_TESTS=1 to enable)
- Covers execute, discuss, breakdown, and decompose modes
- Helper function callClaudeCli() handles CLI invocation
- Add tests for spawn decompose agent with completion
- Add tests for Q&A flow with questions and resume
- Add tests for multiple questions handling
- Add tests for task persistence from decomposition
- Add tests for all task types (auto, checkpoint variants)
- Add tests for task dependencies
- Add full workflow test: initiative -> phase -> plan -> decompose -> tasks
- Add setArchitectDecomposeComplete and setArchitectDecomposeQuestions helpers
- Add planRepository to harness for plan operations
- Add createPlan and getTasksForPlan convenience methods
- Import TaskBreakdown and Plan types
Add tests for getNextNumber method:
- Returns 1 for phase with no plans
- Returns max + 1 for phase with existing plans
- Not affected by plans in other phases
Add tests for decompose mode scenarios:
- Spawn agent in decompose mode
- Complete with tasks on decompose_complete
- Pause on questions in decompose mode
- Emit stopped event with decompose_complete reason
- Set result message with task count
Add CLI commands for plan management:
- cw plan list --phase <id>: List plans in a phase
- cw plan create --phase <id> --name <name>: Create a plan
- cw plan get <id>: Get plan details
- cw plan tasks <id>: List tasks in a plan
Add architect decompose command:
- cw architect decompose <planId>: Spawn agent to decompose plan into tasks
- Import buildDecomposePrompt from agent prompts
- Add spawnArchitectDecompose procedure for decompose mode
- Validates plan and phase exist before spawning
- Spawns agent with decompose mode and comprehensive prompt
- Add buildDecomposePrompt for decompose mode agent operations
- Import Phase and Plan types from schema
- Comprehensive prompt explaining task breakdown rules, types, and output format
- Add createDependency method to TaskRepository interface
- Implement createDependency in DrizzleTaskRepository
- Add createTasksFromDecomposition procedure for bulk task creation
- Procedure verifies plan exists before creating tasks
- Creates tasks in order, building number-to-ID map
- Creates task dependencies after all tasks exist
- Dependencies mapped from task numbers to IDs
- Import PlanRepository type from repositories
- Add planRepository?: PlanRepository to TRPCContext type
- Add planRepository to CreateContextOptions
- Update createContext to include planRepository
- Import TaskBreakdown from schema.ts
- Add decompose_complete status to MockAgentScenario type
- Update completeAgent() to handle decompose_complete scenarios
- Emit agent:stopped with reason 'decompose_complete' for E2E testing
- Add TaskBreakdown type with number, name, description, type, dependencies
- Create decomposeOutputSchema discriminated union (questions/decompose_complete/error)
- Create decomposeOutputJsonSchema for Claude CLI --json-schema flag
- Update module docstring to include decompose mode
- 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