---
phase: 05-task-dispatch
plan: 02
type: execute
wave: 1
depends_on: []
files_modified: [src/trpc/router.ts, src/trpc/context.ts, src/cli/index.ts]
autonomous: true
---

<objective>
Add task visibility via tRPC and CLI.

Purpose: TASK-01 requires users to see status of all tasks at a glance. Expose existing TaskRepository through tRPC endpoints and CLI commands for task listing and status viewing.
Output: tRPC task procedures, CLI `cw task list` and `cw task get` commands.
</objective>

<execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md

@src/trpc/router.ts
@src/trpc/context.ts
@src/cli/index.ts
@src/db/repositories/task-repository.ts
@src/db/schema.ts
</context>

<tasks>

<task type="auto">
  <name>Task 1: Add task tRPC procedures</name>
  <files>src/trpc/router.ts, src/trpc/context.ts</files>
  <action>
1. Add TaskRepository to TRPCContext (optional, same pattern as agentManager):
   - Add taskRepository?: TaskRepository to context type
   - Add requireTaskRepository helper function

2. Add task procedures to appRouter:

   listTasks: publicProcedure
     .input(z.object({ planId: z.string().optional() }))
     .query(...)
   - If planId provided, return tasks for that plan (ordered by order field)
   - If no planId, return all tasks (need to add findAll to TaskRepository first - OR use a simple "list all" query)
   - Actually, for simplicity: require planId. Users query by plan.
   - Return array of Task objects

   getTask: publicProcedure
     .input(z.object({ id: z.string() }))
     .query(...)
   - Return single task or throw NOT_FOUND

   updateTaskStatus: publicProcedure
     .input(z.object({
       id: z.string(),
       status: z.enum(['pending', 'in_progress', 'completed', 'blocked'])
     }))
     .mutation(...)
   - Update task status
   - Return updated task

Follow existing patterns from agent procedures. Use Zod schemas for input validation.
  </action>
  <verify>npm run build passes, npm test -- src/trpc/router.test.ts passes</verify>
  <done>Task tRPC procedures available: listTasks, getTask, updateTaskStatus</done>
</task>

<task type="auto">
  <name>Task 2: Add task CLI commands</name>
  <files>src/cli/index.ts</files>
  <action>
Add task subcommands to the existing 'task' command group:

1. cw task list --plan <planId>
   - Call listTasks tRPC procedure
   - Display tasks as table: name, status, type, priority
   - Show count of pending/in_progress/completed

2. cw task get <taskId>
   - Call getTask tRPC procedure
   - Display full task details: id, name, description, type, priority, status, order, timestamps

3. cw task status <taskId> <status>
   - Call updateTaskStatus tRPC procedure
   - Validate status is one of: pending, in_progress, completed, blocked
   - Confirm status update

Replace the placeholder "not implemented" action with real commands.
Follow existing CLI patterns (error handling, client creation, output formatting).
  </action>
  <verify>cw task list --plan test-id shows error (expected - no server), cw task --help shows commands</verify>
  <done>CLI task commands functional: list, get, status</done>
</task>

</tasks>

<verification>
Before declaring plan complete:
- [ ] npm run build succeeds
- [ ] npm test passes
- [ ] cw task --help shows list, get, status commands
- [ ] Task procedures added to router
</verification>

<success_criteria>

- tRPC task procedures (listTasks, getTask, updateTaskStatus) added
- TaskRepository optional in context (same pattern as AgentManager)
- CLI task commands: list, get, status
- All existing tests still pass
  </success_criteria>

<output>
After completion, create `.planning/phases/05-task-dispatch/05-02-SUMMARY.md`
</output>
