# Gantt Board CLI Tools

Complete command-line interface for the Gantt Board. All web UI operations available via CLI.

## Quick Start

```bash
# List all tasks
./scripts/gantt.sh task list

# Create a task
./scripts/gantt.sh task create "Fix login bug" open high

# Create task with natural language
./scripts/gantt.sh task natural "Research TTS options by Friday, high priority"

# Update task
./scripts/gantt.sh task update <task-id> status done

# Add comment
./scripts/gantt.sh task comment <task-id> "Working on this now"

# Attach file
./scripts/gantt.sh task attach <task-id> ./notes.md
```

## Main CLI: `gantt.sh`

A unified CLI that covers all API operations.

### Task Commands

```bash
# List tasks (optionally filter by status)
./scripts/gantt.sh task list
./scripts/gantt.sh task list open
./scripts/gantt.sh task list in-progress

# Get specific task
./scripts/gantt.sh task get <task-id>

# Create task
./scripts/gantt.sh task create <title> [status] [priority] [project-id]
./scripts/gantt.sh task create "Fix bug" open high 1

# Create from natural language
./scripts/gantt.sh task natural "Fix login bug by Friday, assign to Matt, high priority"

# Update any field
./scripts/gantt.sh task update <task-id> <field> <value>
./scripts/gantt.sh task update abc-123 status done
./scripts/gantt.sh task update abc-123 priority urgent
./scripts/gantt.sh task update abc-123 title "New title"
./scripts/gantt.sh task update abc-123 assigneeId <user-id>

# Delete task
./scripts/gantt.sh task delete <task-id>

# Add comment
./scripts/gantt.sh task comment <task-id> "Your comment here"

# Attach file
./scripts/gantt.sh task attach <task-id> <file-path>
./scripts/gantt.sh task attach abc-123 ./research.pdf
```

### Project Commands

```bash
# List all projects
./scripts/gantt.sh project list

# Create project
./scripts/gantt.sh project create "Project Name" "Description" "#color"

# Update project field
./scripts/gantt.sh project update <project-id> <field> <value>
./scripts/gantt.sh project update abc-123 name "New Name"
./scripts/gantt.sh project update abc-123 description "New desc"
./scripts/gantt.sh project update abc-123 color "#ff0000"

# Delete project
./scripts/gantt.sh project delete <project-id>
```

### Sprint Commands

```bash
# List all sprints
./scripts/gantt.sh sprint list

# Create sprint
./scripts/gantt.sh sprint create "Sprint 2" <project-id> "2026-02-23" "2026-03-01" "Sprint goal"

# Update sprint field
./scripts/gantt.sh sprint update <sprint-id> <field> <value>
./scripts/gantt.sh sprint update abc-123 name "New Sprint Name"
./scripts/gantt.sh sprint update abc-123 status active
./scripts/gantt.sh sprint update abc-123 startDate "2026-02-25"

# Delete sprint
./scripts/gantt.sh sprint delete <sprint-id>
```

### Auth Commands

```bash
# Check current session
./scripts/gantt.sh auth session

# Log in
./scripts/gantt.sh auth login <email> <password>

# Log out
./scripts/gantt.sh auth logout

# Register new account
./scripts/gantt.sh auth register <email> <password> [name]

# Request password reset
./scripts/gantt.sh auth forgot-password <email>

# Reset password with token
./scripts/gantt.sh auth reset-password <token> <new-password>

# Update account
./scripts/gantt.sh auth account <field> <value>

# List all users
./scripts/gantt.sh auth users
```

### User Admin Commands

```bash
# List all users
./scripts/gantt.sh user list

# Get specific user
./scripts/gantt.sh user get <user-id>

# Update user field
./scripts/gantt.sh user update <user-id> <field> <value>
./scripts/gantt.sh user update abc-123 name "New Name"
./scripts/gantt.sh user update abc-123 email "new@example.com"

# Delete user
./scripts/gantt.sh user delete <user-id>
```

### Meta Commands

```bash
# List all meta entries
./scripts/gantt.sh meta list

# Get specific meta value
./scripts/gantt.sh meta get <key>

# Set meta key-value
./scripts/gantt.sh meta set <key> <value>
./scripts/gantt.sh meta set lastBackup "2026-02-22"

# Delete meta entry
./scripts/gantt.sh meta delete <key>
```

### Debug

```bash
# Call debug endpoint
./scripts/gantt.sh debug
```

## Legacy Scripts (Supabase Direct)

These scripts use Supabase directly (not the API) and work without the web server running:

### `gantt-task-crud.sh` - Direct Supabase Task Operations

Uses Supabase REST API directly with service role key.

```bash
./scripts/gantt-task-crud.sh list              # List all tasks
./scripts/gantt-task-crud.sh list open         # List open tasks
./scripts/gantt-task-crud.sh get <task-id>     # Get specific task
./scripts/gantt-task-crud.sh create "Title"    # Create task
./scripts/gantt-task-crud.sh update <id> field value  # Update field
./scripts/gantt-task-crud.sh delete <task-id>  # Delete task
```

### `attach-file.sh` - Direct Supabase File Attachments

```bash
./scripts/attach-file.sh <task-id> <file-path>
```

Supports: md, txt, json, pdf, png, jpg, gif

### `view-attachment.sh` - View Attached Files

```bash
./scripts/view-attachment.sh <task-id> [index]
```

Displays text files in terminal, saves binary files to `/tmp/`.

## API Coverage Matrix

| Feature | Web UI | gantt.sh (API) | Legacy Scripts (Supabase) |
|---------|--------|----------------|---------------------------|
| List tasks | ✅ | ✅ | ✅ |
| Get task | ✅ | ✅ | ✅ |
| Create task | ✅ | ✅ | ✅ |
| Natural language create | ✅ | ✅ | ❌ |
| Update task | ✅ | ✅ | ✅ |
| Delete task | ✅ | ✅ | ✅ |
| Add comment | ✅ | ✅ | ❌ |
| Attach file | ✅ | ✅ | ✅ |
| List projects | ✅ | ✅ | ❌ |
| Create project | ✅ | ✅ | ❌ |
| Update project | ✅ | ✅ | ❌ |
| Delete project | ✅ | ✅ | ❌ |
| List sprints | ✅ | ✅ | ❌ |
| Create sprint | ✅ | ✅ | ❌ |
| Update sprint | ✅ | ✅ | ❌ |
| Delete sprint | ✅ | ✅ | ❌ |
| Auth login | ✅ | ✅ | ❌ |
| Auth logout | ✅ | ✅ | ❌ |
| Auth register | ✅ | ✅ | ❌ |
| Auth forgot-password | ✅ | ✅ | ❌ |
| Auth reset-password | ✅ | ✅ | ❌ |
| Auth account update | ✅ | ✅ | ❌ |
| Auth list users | ✅ | ✅ | ❌ |
| **User Admin** ||||
| Get user | ✅ | ✅ | ❌ |
| Update user | ✅ | ✅ | ❌ |
| Delete user | ✅ | ✅ | ❌ |
| **Meta** ||||
| List meta | ✅ | ✅ | ❌ |
| Get meta | ✅ | ✅ | ❌ |
| Set meta | ✅ | ✅ | ❌ |
| Delete meta | ✅ | ✅ | ❌ |
| **Other** ||||
| View attachments | ✅ | ❌ | ✅ |

### Auditing Coverage

Use the audit script to verify CLI stays in sync with API:

```bash
./scripts/audit-cli-coverage.sh
```

This scans all API routes and checks that each has a matching CLI command. Run this before committing any API changes to ensure Rule 2.5 compliance.

## Requirements

- `curl` - HTTP requests (built into macOS)
- `jq` - JSON parsing: `brew install jq`

## Environment Variables

```bash
# Override API URL
export API_URL=http://localhost:3001/api
./scripts/gantt.sh task list
```

## Common Workflows

### Create Task with Natural Language

```bash
./scripts/gantt.sh task natural "Fix the login bug by Friday, high priority, assign to Matt"
```

### Complete Task with Documentation

```bash
# Add completion comment
./scripts/gantt.sh task comment abc-123 "Completed. See attached notes."

# Attach notes
./scripts/gantt.sh task attach abc-123 ./completion-notes.md

# Mark done
./scripts/gantt.sh task update abc-123 status done
```

### Find Tasks

```bash
# All open tasks
./scripts/gantt.sh task list open

# Filter with jq
./scripts/gantt.sh task list | jq '.[] | select(.priority == "urgent") | {id, title}'
```

## Which Script to Use?

**Use `gantt.sh` (API) when:**
- Web server is running
- You want natural language task creation
- You need to add comments
- You want to use the same API as the web UI

**Use legacy scripts (Supabase) when:**
- Web server is not running
- You need to view attachment content
- You want direct database access

## Troubleshooting

### "jq: command not found"
```bash
brew install jq
```

### "API call failed (HTTP 401)"
- Check that you're logged in: `./scripts/gantt.sh auth session`
- Log in: `./scripts/gantt.sh auth login <email> <password>`

### "API call failed (HTTP 500)"
- Check that the dev server is running: `npm run dev`
- Check server logs for errors

### Task ID format
Task IDs are UUIDs like `33ebc71e-7d40-456c-8f98-bb3578d2bb2b`. Find them:
- In the URL when viewing a task
- From `task list` output
- From `task create` output

## Tips

1. **Tab completion:** Add `source <(./scripts/gantt.sh completion bash)` to your `.bashrc`
2. **jq filtering:** Pipe output to `jq` for precise data extraction
3. **Task URLs:** `https://gantt-board.vercel.app/tasks/<task-id>`
4. **Always verify:** After attach/update, run `task get` to confirm
