# T3-2.2: Task Dependency Commands

## Priority
Medium

## Status
Completed

## Description
Implement task dependency management commands for the CLI, allowing users to add, remove, and view dependencies between tasks.

## Objectives
- Add `anyt task dep add` command to create dependencies
- Add `anyt task dep rm` command to remove dependencies
- Add `anyt task dep list` command to view dependencies
- Show both dependencies (tasks this depends on) and dependents (tasks blocked by this)
- Validate against circular dependencies
- Display clear error messages for dependency violations

## Commands

### anyt task dep add
```bash
# Add single dependency
$ anyt task dep add DEV-43 --on DEV-42
✓ DEV-43 now depends on DEV-42

# Add multiple dependencies
$ anyt task dep add DEV-45 --on DEV-42,DEV-43
✓ DEV-45 now depends on DEV-42, DEV-43

# Error handling
$ anyt task dep add DEV-42 --on DEV-42
✗ Error: Task cannot depend on itself

$ anyt task dep add DEV-43 --on DEV-45
✗ Error: Adding this dependency would create a circular dependency
```

### anyt task dep rm
```bash
# Remove dependency
$ anyt task dep rm DEV-43 --on DEV-42
✓ Removed dependency: DEV-43 → DEV-42

# Remove multiple
$ anyt task dep rm DEV-45 --on DEV-42,DEV-43
✓ Removed 2 dependencies from DEV-45
```

### anyt task dep list
```bash
# List dependencies for a task
$ anyt task dep list DEV-43

DEV-43: Add tests
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Dependencies (tasks this depends on):
  → DEV-42  Implement OAuth callback  ✓ done

Blocks (tasks that depend on this):
  ← DEV-45  Integration tests         ⬜ backlog
  ← DEV-46  Deploy to staging         ⬜ backlog

# Shorthand when using picked task
$ anyt task pick DEV-43
$ anyt dep list
[Shows dependencies for DEV-43]
```

### anyt task dep show
```bash
# Show dependency graph (ASCII art)
$ anyt task dep show DEV-45

DEV-45: Integration tests
  ↓ depends on
  DEV-43: Add tests
    ↓ depends on
    DEV-42: Implement OAuth callback [done]
```

## Acceptance Criteria
- [x] `anyt task dep add` creates dependencies with validation
- [x] `anyt task dep rm` removes dependencies
- [x] `anyt task dep list` shows both dependencies and dependents
- [x] Circular dependency detection with clear error messages
- [x] Support for multiple dependencies in single command
- [x] Commands work with task identifiers (DEV-42) and IDs
- [x] Rich formatted output with colors and symbols
- [x] Commands respect workspace context from .anyt/
- [x] Error messages are clear and actionable
- [ ] Optional: `anyt task dep show` displays dependency graph (deferred - not in scope)

## Dependencies
- T3-2.1: CLI Task Commands - Core (core commands must exist first)
- T2-2: Task Dependencies API (completed)

## Estimated Effort
3-4 hours

## Technical Notes
- Reuse API client methods: `add_task_dependency()`, `remove_task_dependency()`, `get_task_dependencies()`, `get_task_dependents()`
- Use rich for formatted output
- Validate input locally before API calls
- Handle API errors gracefully (404, 409, 400)
- Consider showing dependency status symbols (✓ done, ⬜ backlog, etc.)

## Out of Scope
- Visual graph rendering (ASCII art is sufficient)
- Bulk dependency operations
- Dependency templates or presets

## Events

### 2025-10-15 - Started work
- Moved task from backlog to active
- Created new branch: T3-2.2-task-dependency-commands
- Task T3-2.1 (core task commands) completed - dependency satisfied
- Beginning implementation of dependency management commands

### 2025-10-15 - Completed implementation
- Implemented `anyt task dep add` command with validation
  - Supports single and multiple dependencies (comma-separated)
  - Validates against self-dependencies
  - Handles circular dependency errors from API
  - Rich formatted output with success and error messages
- Implemented `anyt task dep rm` command
  - Supports removing single or multiple dependencies
  - Clear error messages for missing dependencies
  - Shows count of removed dependencies
- Implemented `anyt task dep list` command
  - Displays both dependencies (→) and dependents (←)
  - Shows task status with colored symbols (✓ done, ⬤ in progress, ⬜ backlog)
  - Rich formatted output with task details
- All commands respect workspace context from .anyt/
- Error handling for 404, 409, and circular dependency errors
- All linting, formatting, and type checking passed
- Task completed successfully
- Created PR #22: https://github.com/supercarl87/AnyTaskBackend/pull/22
- Branch: T3-2.2-task-dependency-commands
