---
phase: 05-task-dispatch
plan: 05
type: execute
wave: 3
depends_on: ["05-02", "05-04"]
files_modified: [src/trpc/router.ts, src/trpc/context.ts, src/cli/index.ts]
autonomous: true
---
Add message and dispatch tRPC procedures and CLI commands.
Purpose: Complete AGENT-06 (message visibility) and TASK-04/TASK-05 (dispatch control) with user-facing interfaces. Users can view pending agent questions and control task dispatch.
Output: tRPC message and dispatch procedures, CLI commands for messages and dispatch.
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/templates/summary.md
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/05-task-dispatch/05-01-SUMMARY.md
@.planning/phases/05-task-dispatch/05-02-SUMMARY.md
@.planning/phases/05-task-dispatch/05-04-SUMMARY.md
@src/trpc/router.ts
@src/trpc/context.ts
@src/cli/index.ts
@src/db/repositories/message-repository.ts
@src/dispatch/types.ts
Task 1: Add message and dispatch tRPC procedures
src/trpc/router.ts, src/trpc/context.ts
1. Add to TRPCContext:
- messageRepository?: MessageRepository
- dispatchManager?: DispatchManager
- Add requireMessageRepository and requireDispatchManager helpers
2. Add message procedures to appRouter:
listMessages: publicProcedure
.input(z.object({ agentId: z.string().optional(), status: z.enum(['pending', 'read', 'responded']).optional() }))
.query(...)
- If agentId, filter by agent
- If status, filter by status
- Return array of Message objects
getMessage: publicProcedure
.input(z.object({ id: z.string() }))
.query(...)
- Return single message or throw NOT_FOUND
respondToMessage: publicProcedure
.input(z.object({ id: z.string(), response: z.string() }))
.mutation(...)
- Update message with response and status='responded'
- Return updated message
3. Add dispatch procedures:
queueTask: publicProcedure
.input(z.object({ taskId: z.string() }))
.mutation(...)
- Call dispatchManager.queue(taskId)
- Return { success: true }
dispatchNext: publicProcedure
.mutation(...)
- Call dispatchManager.dispatchNext()
- Return DispatchResult
getQueueState: publicProcedure
.query(...)
- Call dispatchManager.getQueueState()
- Return queue state object
completeTask: publicProcedure
.input(z.object({ taskId: z.string() }))
.mutation(...)
- Call dispatchManager.completeTask(taskId)
- Return { success: true }
npm run build passes
Message and dispatch tRPC procedures added
Task 2: Add message and dispatch CLI commands
src/cli/index.ts
1. Add message command group:
const messageCommand = program
.command('message')
.description('View agent messages and questions');
cw message list [--agent ] [--status ]
- Call listMessages tRPC
- Display as table: id (short), agent, type, content (truncated), status, createdAt
- Show "(pending)" count prominently
cw message read
- Call getMessage tRPC
- Display full message content
- If pending, show prompt to respond
cw message respond
- Call respondToMessage tRPC
- Confirm response recorded
- Suggest resuming agent if appropriate
2. Add dispatch command group:
const dispatchCommand = program
.command('dispatch')
.description('Control task dispatch queue');
cw dispatch queue
- Call queueTask tRPC
- Confirm task queued
cw dispatch next
- Call dispatchNext tRPC
- Show result: which task dispatched to which agent, or why it failed
cw dispatch status
- Call getQueueState tRPC
- Show: queued count, ready count, blocked count
- List ready tasks with their priority
cw dispatch complete
- Call completeTask tRPC
- Confirm task completed
Follow existing CLI patterns for error handling and output formatting.
cw message --help and cw dispatch --help show commands
Message and dispatch CLI commands functional
Before declaring plan complete:
- [ ] npm run build succeeds
- [ ] npm test passes
- [ ] cw message --help shows list, read, respond
- [ ] cw dispatch --help shows queue, next, status, complete
- [ ] All tRPC procedures added
- Message tRPC procedures: listMessages, getMessage, respondToMessage
- Dispatch tRPC procedures: queueTask, dispatchNext, getQueueState, completeTask
- CLI message commands: list, read, respond
- CLI dispatch commands: queue, next, status, complete
- All requirements (AGENT-06, TASK-01, TASK-04, TASK-05) have user-facing interfaces