mission-control/scripts/README.md

241 lines
7.6 KiB
Markdown

# Mission Control CLI
A Next.js API-based CLI for managing Mission Control. Follows the same architecture principles as the Gantt Board CLI.
## Architecture
The Mission Control CLI follows a **clean API passthrough architecture**:
1. **API is the source of truth** - All business logic lives in the Mission Control API endpoints
2. **CLI is thin** - CLI scripts parse arguments and call API endpoints, no direct database access
3. **Shared code via delegation** - Task/project/sprint operations delegate to Gantt Board CLI
4. **Mission Control specific features** call Mission Control API directly
## Quick Start
```bash
# Authenticate
./scripts/mc.sh auth login user@example.com password
# Search across tasks, projects, documents
./scripts/mc.sh search "api design"
# List tasks with due dates
./scripts/mc.sh due-dates
# Task operations (delegates to gantt-board)
./scripts/mc.sh task list --status open
./scripts/mc.sh task create --title "New task" --project "Mission Control"
# Project operations (delegates to gantt-board)
./scripts/mc.sh project list
# Sprint operations (delegates to gantt-board)
./scripts/mc.sh sprint list --active
```
## Scripts
### Main CLI
- **`mc.sh`** - Main entry point for all Mission Control CLI operations
### Wrapper Scripts (Delegate to Gantt Board)
- **`task.sh`** - Task operations (delegates to gantt-board/scripts/task.sh)
- **`project.sh`** - Project operations (delegates to gantt-board/scripts/project.sh)
- **`sprint.sh`** - Sprint operations (delegates to gantt-board/scripts/sprint.sh)
### Library
- **`lib/api_client.sh`** - Shared HTTP client for Mission Control API calls
### Utilities
- **`update-task-status.js`** - Update task status (delegates to gantt-board)
## Configuration
Environment variables:
```bash
# Mission Control API URL
export MC_API_URL="http://localhost:3001/api"
# Path to gantt-board (auto-detected if not set)
export GANTT_BOARD_DIR="/path/to/gantt-board"
# Cookie file for authentication
export MC_COOKIE_FILE="$HOME/.config/mission-control/cookies.txt"
```
## Command Reference
### Authentication
```bash
./mc.sh auth login <email> <password>
./mc.sh auth logout
./mc.sh auth session
```
### Search
```bash
./mc.sh search "query string"
```
Searches across:
- Tasks (title, description)
- Projects (name, description)
- Sprints (name, goal)
- Documents (title, content)
### Tasks with Due Dates
```bash
./mc.sh due-dates
```
Returns tasks with due dates, ordered by due date.
### Documents
```bash
./mc.sh documents list
./mc.sh documents get <id>
```
### Task Operations (via Gantt Board)
```bash
./mc.sh task list [--status <status>] [--priority <priority>]
./mc.sh task get <task-id>
./mc.sh task create --title "..." [--description "..."] [--project <name>]
./mc.sh task update <task-id> [--status <status>] [--priority <priority>]
./mc.sh task delete <task-id>
```
See Gantt Board CLI documentation for full task command reference.
### Project Operations (via Gantt Board)
```bash
./mc.sh project list
./mc.sh project get <project-id-or-name>
./mc.sh project create --name "..." [--description "..."]
./mc.sh project update <project-id> [--name "..."] [--description "..."]
```
### Sprint Operations (via Gantt Board)
```bash
./mc.sh sprint list [--active]
./mc.sh sprint get <sprint-id-or-name>
./mc.sh sprint create --name "..." [--goal "..."]
./mc.sh sprint close <sprint-id-or-name>
```
## Architecture Diagram
```
┌─────────────────────────────────────────────────────────────┐
│ Mission Control CLI │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ mc.sh │ │ task.sh │ │ project.sh │ │
│ │ (main) │ │ (wrapper) │ │ (wrapper) │ │
│ └──────┬──────┘ └──────┬──────┘ └──────────┬──────────┘ │
│ │ │ │ │
│ │ └──────────┬──────────┘ │
│ │ │ │
│ │ ┌──────────────▼──────────────┐ │
│ │ │ Gantt Board CLI │ │
│ │ │ (task.sh, project.sh) │ │
│ │ └──────────────┬──────────────┘ │
│ │ │ │
│ │ ▼ │
│ │ ┌─────────────────────┐ │
│ │ │ Gantt Board API │ │
│ │ └─────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────┐ │
│ │ Mission Control API │ │
│ │ /api/search, /api/tasks/with-due-dates, etc │ │
│ └──────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
```
## Testing
Run the CLI contract test:
```bash
npm run test:cli-contract
```
This verifies:
1. Mission Control CLI wrappers delegate to gantt-board CLI
2. No direct database references in scripts/
3. update-task-status.js delegates to gantt-board task.sh
## Design Principles
1. **No Direct Database Access** - CLI scripts never call the database directly
2. **API Passthrough** - All operations go through API endpoints
3. **Shared Functionality** - Common operations (tasks, projects, sprints) use Gantt Board
4. **Clean Separation** - Mission Control specific features use Mission Control API
## Adding New Commands
To add a new Mission Control specific command:
1. Create the API endpoint in `app/api/<feature>/route.ts`
2. Add the command handler in `scripts/mc.sh`
3. Use `lib/api_client.sh` functions for HTTP calls
4. Document the command in this README
Example:
```bash
# In mc.sh
handle_feature() {
mc_get "/feature" | jq .
}
```
## Troubleshooting
### "GANTT_BOARD_DIR not set"
Set the environment variable:
```bash
export GANTT_BOARD_DIR=/path/to/gantt-board
```
Or use the auto-detection by placing gantt-board in a standard location:
- `../../../gantt-board` (relative to mission-control)
- `$HOME/Documents/Projects/OpenClaw/Web/gantt-board`
### "Not authenticated"
Login first:
```bash
./scripts/mc.sh auth login user@example.com password
```
### API Connection Errors
Verify Mission Control is running:
```bash
curl http://localhost:3001/api/auth/session
```
## Related Documentation
- [Gantt Board CLI](../../gantt-board/scripts/README.md)
- [Mission Control API](../app/api/)