Skip to content

Commit fa50eb9

Browse files
authored
Merge pull request #329 from pedramamini/cli-improvements
CLI enhancements
2 parents 50a8183 + 8999e6b commit fa50eb9

File tree

12 files changed

+1887
-44
lines changed

12 files changed

+1887
-44
lines changed

docs/cli.md

Lines changed: 129 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
title: Command Line Interface
3-
description: Run playbooks from the command line, cron jobs, or CI/CD pipelines with maestro-cli.
3+
description: Send messages to agents, list sessions, run playbooks, and manage Maestro from the command line.
44
icon: square-terminal
55
---
66

7-
Maestro includes a CLI tool (`maestro-cli`) for managing agents and running playbooks from the command line, cron jobs, or CI/CD pipelines. The CLI requires Node.js (which you already have if you're using Claude Code).
7+
Maestro includes a CLI tool (`maestro-cli`) for sending messages to agents, browsing sessions, running playbooks, and managing resources from the command line, cron jobs, or CI/CD pipelines. The CLI requires Node.js (which you already have if you're using Claude Code).
88

99
## Installation
1010

@@ -32,6 +32,114 @@ node "/Applications/Maestro.app/Contents/Resources/maestro-cli.js" list groups
3232

3333
## Usage
3434

35+
### Sending Messages to Agents
36+
37+
Send a message to an agent and receive a structured JSON response. Supports creating new sessions or resuming existing ones for multi-turn conversations.
38+
39+
```bash
40+
# Send a message to an agent (creates a new session)
41+
maestro-cli send <agent-id> "describe the authentication flow"
42+
43+
# Resume an existing session for follow-up
44+
maestro-cli send <agent-id> "now add rate limiting" -s <session-id>
45+
```
46+
47+
The response is always JSON:
48+
49+
```json
50+
{
51+
"agentId": "a1b2c3d4-...",
52+
"agentName": "My Agent",
53+
"sessionId": "abc123def456",
54+
"response": "The authentication flow works by...",
55+
"success": true,
56+
"usage": {
57+
"inputTokens": 1000,
58+
"outputTokens": 500,
59+
"cacheReadInputTokens": 200,
60+
"cacheCreationInputTokens": 100,
61+
"totalCostUsd": 0.05,
62+
"contextWindow": 200000,
63+
"contextUsagePercent": 1
64+
}
65+
}
66+
```
67+
68+
On failure, `success` is `false` and an `error` field is included:
69+
70+
```json
71+
{
72+
"success": false,
73+
"error": "Agent not found: bad-id",
74+
"code": "AGENT_NOT_FOUND"
75+
}
76+
```
77+
78+
Error codes: `AGENT_NOT_FOUND`, `AGENT_UNSUPPORTED`, `CLAUDE_NOT_FOUND`, `CODEX_NOT_FOUND`.
79+
80+
Supported agent types: `claude-code`, `codex`.
81+
82+
### Listing Sessions
83+
84+
Browse an agent's session history, sorted most recent to oldest. Supports pagination with limit/skip and keyword search.
85+
86+
```bash
87+
# List the 25 most recent sessions
88+
maestro-cli list sessions <agent-id>
89+
90+
# Limit to 10 results
91+
maestro-cli list sessions <agent-id> -l 10
92+
93+
# Paginate: skip the first 25, show next 25
94+
maestro-cli list sessions <agent-id> -k 25
95+
96+
# Page 3 of 10-item pages
97+
maestro-cli list sessions <agent-id> -l 10 -k 20
98+
99+
# Search for sessions by keyword (matches session name and first message)
100+
maestro-cli list sessions <agent-id> -s "authentication"
101+
102+
# Combine limit, skip, and search with JSON output
103+
maestro-cli list sessions <agent-id> -l 50 -k 0 -s "refactor" --json
104+
```
105+
106+
| Flag | Description | Default |
107+
|------|-------------|---------|
108+
| `-l, --limit <count>` | Maximum number of sessions to return | 25 |
109+
| `-k, --skip <count>` | Number of sessions to skip (for pagination) | 0 |
110+
| `-s, --search <keyword>` | Filter by keyword in session name or first message ||
111+
| `--json` | Output as JSON ||
112+
113+
JSON output includes full session metadata:
114+
115+
```json
116+
{
117+
"success": true,
118+
"agentId": "a1b2c3d4-...",
119+
"agentName": "My Agent",
120+
"totalCount": 42,
121+
"filteredCount": 3,
122+
"sessions": [
123+
{
124+
"sessionId": "abc123",
125+
"sessionName": "Auth refactor",
126+
"modifiedAt": "2026-02-08T10:00:00.000Z",
127+
"firstMessage": "Help me refactor the auth module...",
128+
"messageCount": 12,
129+
"costUsd": 0.05,
130+
"inputTokens": 5000,
131+
"outputTokens": 2000,
132+
"durationSeconds": 300,
133+
"starred": true
134+
}
135+
]
136+
}
137+
```
138+
139+
Currently supported for `claude-code` agents.
140+
141+
### Listing Resources
142+
35143
```bash
36144
# List all groups
37145
maestro-cli list groups
@@ -51,7 +159,11 @@ maestro-cli list playbooks --agent <agent-id>
51159

52160
# Show playbook details
53161
maestro-cli show playbook <playbook-id>
162+
```
54163

164+
### Running Playbooks
165+
166+
```bash
55167
# Run a playbook
56168
maestro-cli playbook <playbook-id>
57169

@@ -72,9 +184,21 @@ maestro-cli clean playbooks
72184
maestro-cli clean playbooks --dry-run
73185
```
74186

187+
## Partial IDs
188+
189+
All commands that accept an agent ID or group ID support partial matching. You only need to type enough characters to uniquely identify the resource:
190+
191+
```bash
192+
# These are equivalent if "a1b2" uniquely matches one agent
193+
maestro-cli send a1b2c3d4-e5f6-7890-abcd-ef1234567890 "hello"
194+
maestro-cli send a1b2 "hello"
195+
```
196+
197+
If the partial ID is ambiguous, the CLI will show all matches.
198+
75199
## JSON Output
76200

77-
By default, commands output human-readable formatted text. Use `--json` for machine-parseable JSONL output:
201+
By default, commands output human-readable formatted text. Use `--json` for machine-parseable output:
78202

79203
```bash
80204
# Human-readable output (default)
@@ -106,6 +230,8 @@ maestro-cli playbook <playbook-id> --json
106230
{"type":"complete","timestamp":...,"success":true,"totalTasksCompleted":5,"totalElapsedMs":60000,"totalCost":0.05}
107231
```
108232

233+
The `send` command always outputs JSON (no `--json` flag needed).
234+
109235
## Scheduling with Cron
110236

111237
```bash

0 commit comments

Comments
 (0)