---
phase: 05-task-dispatch
plan: 02
subsystem: api
tags: [trpc, cli, tasks, crud]

# Dependency graph
requires:
  - phase: 02-persistence
    provides: TaskRepository interface and Drizzle implementation
  - phase: 04-agent-lifecycle
    provides: tRPC router patterns and context structure
provides:
  - listTasks tRPC procedure (query tasks by plan)
  - getTask tRPC procedure (get task by ID)
  - updateTaskStatus tRPC procedure (update status)
  - CLI task commands (list, get, status)
affects: [05-task-dispatch, future-task-assignment]

# Tech tracking
tech-stack:
  added: []
  patterns:
    - TaskRepository optional in tRPC context (same as AgentManager)
    - requireTaskRepository helper for context validation

key-files:
  created: []
  modified:
    - src/trpc/context.ts
    - src/trpc/router.ts
    - src/cli/index.ts

key-decisions:
  - "Require planId for listTasks (no global task listing)"
  - "Status update limited to 4 states: pending, in_progress, completed, blocked"

patterns-established:
  - "Task CLI commands follow agent command patterns"

# Metrics
duration: 3min
completed: 2026-01-30
---

# Phase 5 Plan 2: Task Visibility Summary

**tRPC task procedures (listTasks, getTask, updateTaskStatus) and CLI commands (list, get, status) for task visibility**

## Performance

- **Duration:** 3 min
- **Started:** 2026-01-30T14:32:03Z
- **Completed:** 2026-01-30T14:35:32Z
- **Tasks:** 2
- **Files modified:** 3

## Accomplishments

- TaskRepository added to tRPC context (optional, same pattern as AgentManager)
- listTasks procedure queries tasks by planId, ordered by order field
- getTask procedure retrieves single task by ID (throws NOT_FOUND if missing)
- updateTaskStatus mutation updates task status with validation
- CLI `cw task list --plan <planId>` shows tasks with status summary
- CLI `cw task get <taskId>` displays full task details
- CLI `cw task status <taskId> <status>` updates task status

## Task Commits

Each task was committed atomically:

1. **Task 1: Add task tRPC procedures** - `9f24c1f` (feat)
2. **Task 2: Add task CLI commands** - `586f7ca` (feat)

## Files Created/Modified

- `src/trpc/context.ts` - Added TaskRepository to TRPCContext and CreateContextOptions
- `src/trpc/router.ts` - Added listTasks, getTask, updateTaskStatus procedures and requireTaskRepository helper
- `src/cli/index.ts` - Replaced placeholder task command with list, get, status subcommands

## Decisions Made

- **Require planId for listTasks**: Users query tasks by plan rather than global listing. Simplifies queries and matches typical workflow.
- **Status enum limited to 4 values**: pending, in_progress, completed, blocked - matching common task lifecycle states.

## Deviations from Plan

None - plan executed exactly as written.

## Issues Encountered

None.

## User Setup Required

None - no external service configuration required.

## Next Phase Readiness

- Task visibility complete via tRPC and CLI
- Ready for 05-03 (message passing) or dependent plans
- Note: pre-existing message.test.ts failures unrelated to this plan (message table not yet migrated)

---
*Phase: 05-task-dispatch*
*Completed: 2026-01-30*
