- 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
Key changes:
- Add agent names (human-readable like 'gastown') instead of UUID-only
- Use Claude CLI with --output-format json instead of SDK streaming
- Session ID extracted from CLI JSON output, not SDK init message
- Add waiting_for_input status for AskUserQuestion scenarios
- Resume flow is for answering agent questions, not general resumption
- CLI commands use names as primary identifier
- 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