- Add 14 comprehensive tests for DefaultDispatchManager
- Test queue(), getNextDispatchable(), completeTask(), blockTask()
- Test dispatchNext() with agent dispatch flow
- Test getQueueState() for queue visibility
- Test priority ordering and dependency scenario
- Export DefaultDispatchManager from dispatch module
- Add DefaultDispatchManager class implementing DispatchManager interface
- Implement queue() with task fetching and event emission
- Implement getNextDispatchable() with priority-based ordering
- Implement completeTask() and blockTask() with status updates
- Implement dispatchNext() for agent assignment
- Implement getQueueState() for queue visibility
- Use in-memory Map for queue management
- Create MessageRepository port interface with CRUD and query methods
- Implement DrizzleMessageRepository adapter with nanoid generation
- Add findBySender/findByRecipient for participant-based queries
- Add findPendingForUser for unread user notifications
- Add findRequiringResponse for messages awaiting reply
- Add findReplies for message threading support
- Add 23 tests covering all operations and edge cases
- Update test-helpers with messages table schema
- Re-export from index files following AgentRepository pattern
- TaskQueuedEvent for task queue operations
- TaskDispatchedEvent when task assigned to agent
- TaskCompletedEvent for task completion with success/failure
- TaskBlockedEvent for blocked tasks with reason
- Add TaskRepository to TRPCContext (optional, same pattern as AgentManager)
- Add requireTaskRepository helper function
- Add listTasks procedure (query tasks by planId, ordered by order field)
- Add getTask procedure (get single task by ID, throws NOT_FOUND)
- Add updateTaskStatus procedure (update task status to pending/in_progress/completed/blocked)
- QueuedTask type with priority and dependencies
- DispatchResult type for dispatch operation outcomes
- DispatchManager interface with queue/dispatch/complete/block methods
- Follows hexagonal architecture pattern (same as EventBus, AgentManager)
- Add messages table with sender/recipient pattern for agent-user communication
- Support message types: question, info, error, response
- Add requiresResponse flag and status tracking (pending, read, responded)
- Include parentMessageId for threading responses to original questions
- Add relations for sender/recipient agents and message threading
- Replace placeholder agent command with proper subcommands
- Add agent spawn command with --name, --task, --cwd options
- Add agent stop command to stop running agents
- Add agent list command to show all agents
- Add agent get command for detailed agent info
- Add agent resume command for waiting agents
- Add agent result command to get execution results
- All commands use tRPC client for type-safe communication
- Import AgentManager type into context.ts
- Add optional agentManager field to TRPCContext interface
- Add optional agentManager to CreateContextOptions
- Update TrpcAdapterOptions with optional agentManager
- Pass agentManager through to createContext in adapter
- Test spawn with worktree and agent record creation
- Test duplicate name rejection
- Test AgentSpawned event emission
- Test stop with subprocess kill and status update
- Test list, get, getByName operations
- Test resume with session_id and --resume flag
- Test AgentResumed event emission
- Fix: use agent.id from repository for activeAgents tracking
- Use Claude CLI with --output-format json for agent spawning
- Extract session_id from JSON result for resume capability
- Emit lifecycle events: spawned, stopped, crashed, resumed, waiting
- Handle waiting_for_input status for AskUserQuestion pauses
- Uses WorktreeManager for isolated agent workspaces
- Implement DrizzleAgentRepository with all AgentRepository methods
- Add findByName, findByTaskId, findBySessionId lookups
- Add findByStatus for filtering including waiting_for_input
- Add updateStatus and updateSessionId for state changes
- Add agents table to test-helpers.ts SQL
- Export DrizzleAgentRepository from drizzle/index.ts
- 22 tests covering all operations and edge cases
- AgentSpawnedEvent for new agent creation
- AgentStoppedEvent with reason (user_requested, task_complete, error, waiting_for_input)
- AgentCrashedEvent for unexpected failures
- AgentResumedEvent for session resumption
- AgentWaitingEvent when agent pauses on AskUserQuestion
- Updated DomainEventMap union with all agent events
- Define AgentRepository interface with CRUD operations
- Add findByName, findByTaskId, findBySessionId for lookups
- Add findByStatus for filtering by agent state
- Add updateStatus and updateSessionId for state changes
- Export AgentStatus type
- Export from repositories barrel file
- AgentStatus type for agent lifecycle states
- SpawnAgentOptions for spawn configuration
- AgentInfo for agent state representation
- AgentResult for execution results
- AgentManager interface with spawn, stop, list, get, getByName, resume, getResult
- Define agents table with id, name (unique), taskId, sessionId, worktreeId, status
- Status enum: idle, running, waiting_for_input, stopped, crashed
- Foreign key to tasks with onDelete: 'set null' (agent may outlive task)
- Add agentsRelations linking to tasks
- Export Agent and NewAgent types
- Worktree type for representing git worktrees
- WorktreeDiff type for change preview
- MergeResult type for merge operation results
- WorktreeManager interface (PORT) with CRUD, diff, and merge methods
- Full JSDoc documentation explaining port-adapter relationship
Covers requirements: GIT-01, GIT-02, GIT-03, GIT-04
- WorktreeCreatedEvent for worktree creation tracking
- WorktreeRemovedEvent for worktree cleanup tracking
- WorktreeMergedEvent for successful merge tracking
- WorktreeConflictEvent for merge conflict notification
- All events added to DomainEventMap union type
- src/db/index.ts exports repository interfaces and adapters
- cascade.test.ts tests full hierarchy cascade behavior:
- Delete initiative removes all phases, plans, tasks
- Delete phase removes only its plans and tasks
- Delete plan removes only its tasks
- All 45 repository tests passing
- DrizzleInitiativeRepository: CRUD with nanoid ID generation
- DrizzlePhaseRepository: findByInitiativeId ordered by number
- DrizzlePlanRepository: findByPhaseId ordered by number
- DrizzleTaskRepository: findByPlanId ordered by order field
- All adapters use DI for DrizzleDatabase instance
- Timestamps set automatically on create/update
- Throws on update/delete of non-existent entities
- InitiativeRepository: CRUD for initiative aggregate
- PhaseRepository: CRUD with findByInitiativeId ordered by number
- PlanRepository: CRUD with findByPhaseId ordered by number
- TaskRepository: CRUD with findByPlanId ordered by order field
- Re-export all interfaces from repositories/index.ts
Schema defines 5 tables with proper foreign key relationships:
- initiatives: Top-level projects (active/completed/archived)
- phases: Major milestones within initiatives
- plans: Groups of related tasks within phases
- tasks: Individual work items with type, priority, status, order
- task_dependencies: Dependency relationships between tasks
All tables have cascade deletes and Unix timestamp fields.
Types exported: Initiative, Phase, Plan, Task, TaskDependency + New* variants.
Relations exported for Drizzle relational queries.
- Update status command to use tRPC client for server communication
- Display health status, uptime, and process count
- Handle connection errors gracefully with helpful message
- Add 7 integration tests proving full CLI-server tRPC flow
- Tests cover health procedure, status procedure, and error handling
- Create src/server/trpc-adapter.ts with fetch adapter for node:http
- Create src/cli/trpc-client.ts with typed client factory functions
- Update CoordinationServer to route /trpc/* to tRPC handler
- Move @trpc/client from devDeps to regular deps
- Keep /health and /status HTTP endpoints for backwards compatibility
- Test server lifecycle (start, stop, isRunning)
- Test HTTP endpoints (GET /health, GET /status, 404, 405)
- Test PID file management (create, remove, stale cleanup)
- Verify server throws on double-start or existing PID file
- Define EventBus interface (PORT) with emit, on, off, once methods
- Define base DomainEvent interface with type, timestamp, payload
- Implement EventEmitterBus class (ADAPTER) using Node.js EventEmitter
- Export createEventBus() factory function for easy instantiation
- CoordinationServer class using node:http
- GET /health returns status, uptime, processCount
- GET /status returns full server state and process list
- PID file at ~/.cw/server.pid prevents duplicate servers
- CLI --server flag and --port option for server mode
- CW_PORT env var support for custom port
- ProcessManager class with execa for child process spawning
- spawn() starts detached background processes
- stop() graceful shutdown with SIGTERM then SIGKILL after 5s timeout
- stopAll() terminates all managed processes
- restart() stops and respawns with same config
- isRunning() probes actual process state
- Proper promise handling for killed processes
- ProcessLogWriter class for stdout/stderr capture
- Timestamps each line with [YYYY-MM-DD HH:mm:ss.SSS] format
- Backpressure handling via drain events
- getStdoutStream/getStderrStream for direct piping
- Module index exports types, classes, and createLogger helper
- createLogger convenience function for default config
- LogLevel, LogEntry, LogConfig types in types.ts
- LogManager class with directory management
- Cross-platform paths using node:os and node:path
- ensureLogDir/ensureProcessDir for directory creation
- getLogPath returns ~/.cw/logs/{processId}/{stream}.log
- cleanOldLogs removes directories older than N days
- listLogs enumerates all process log directories
- Add createCli() function with commander configuration
- Register placeholder commands: status, agent, task
- Add graceful error handling for uncaught exceptions
- Read version from package.json via index.ts export