1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
|
# Makima CLI Reference
Makima is a unified CLI for server, daemon, and task management. It provides commands for running the Makima server, connecting daemon workers, and orchestrating contracts and tasks.
## Table of Contents
- [Installation](#installation)
- [Commands Overview](#commands-overview)
- [Command Reference](#command-reference)
- [makima server](#makima-server)
- [makima daemon](#makima-daemon)
- [makima supervisor](#makima-supervisor)
- [makima contract](#makima-contract)
- [Configuration](#configuration)
- [Configuration File](#configuration-file)
- [Environment Variables](#environment-variables)
- [Usage Examples](#usage-examples)
- [Starting the Server](#starting-the-server)
- [Running a Daemon Worker](#running-a-daemon-worker)
- [Contract Orchestration Workflow](#contract-orchestration-workflow)
- [Task-Contract Interaction](#task-contract-interaction)
---
## Installation
Build and install the Makima CLI from source:
```bash
cd makima
cargo build --release
cargo install --path .
```
Or install directly:
```bash
cargo install --path makima
```
The `makima` binary will be available in your PATH after installation.
---
## Commands Overview
| Command | Description |
|---------|-------------|
| `makima server` | Run the HTTP/WebSocket server |
| `makima daemon` | Connect to server and manage tasks |
| `makima supervisor` | Contract orchestration commands |
| `makima contract` | Task-contract interaction commands |
---
## Command Reference
### makima server
Run the Makima HTTP/WebSocket server that coordinates daemons and manages contracts.
```bash
makima server [OPTIONS]
```
#### Options
| Option | Environment Variable | Default | Description |
|--------|---------------------|---------|-------------|
| `--port <PORT>` | `PORT` | `8080` | Server port |
| `--parakeet-model-dir <PATH>` | `PARAKEET_MODEL_DIR` | `models/parakeet-tdt-0.6b-v3` | Path to Parakeet model directory |
| `--parakeet-eou-dir <PATH>` | `PARAKEET_EOU_DIR` | `models/realtime_eou_120m-v1-onnx` | Path to Parakeet EOU model directory |
| `--sortformer-model-path <PATH>` | `SORTFORMER_MODEL_PATH` | `models/diarization/diar_streaming_sortformer_4spk-v2.1.onnx` | Path to Sortformer model |
| `--database-url <URL>` | `POSTGRES_CONNECTION_URI` | - | PostgreSQL connection URI |
| `-l, --log-level <LEVEL>` | - | `info` | Log level (trace, debug, info, warn, error) |
#### Examples
```bash
# Start server on default port
makima server
# Start server on custom port with database
makima server --port 3000 --database-url "postgresql://user:pass@localhost/makima"
# Start server with custom model paths
makima server --parakeet-model-dir /path/to/models/parakeet
```
---
### makima daemon
Run the daemon worker that connects to the Makima server and executes tasks.
```bash
makima daemon [OPTIONS]
```
#### Options
| Option | Environment Variable | Default | Description |
|--------|---------------------|---------|-------------|
| `-c, --config <PATH>` | - | - | Path to custom config file |
| `--repos-dir <PATH>` | `MAKIMA_DAEMON_REPOS_DIR` | `~/.makima/repos` | Directory where repositories are cloned |
| `--worktrees-dir <PATH>` | `MAKIMA_DAEMON_WORKTREES_DIR` | `~/.makima/worktrees` | Directory where worktrees are created |
| `--server-url <URL>` | `MAKIMA_DAEMON_SERVER_URL` | `wss://api.makima.jp` | WebSocket server URL |
| `--api-key <KEY>` | `MAKIMA_DAEMON_SERVER_APIKEY` | - | API key for server authentication |
| `--max-tasks <N>` | - | `4` | Maximum number of concurrent tasks |
| `-l, --log-level <LEVEL>` | - | `info` | Log level (trace, debug, info, warn, error) |
#### Examples
```bash
# Start daemon with CLI arguments
makima daemon --server-url ws://localhost:8080 --api-key your-api-key
# Start daemon with custom config file
makima daemon --config /path/to/config.toml
# Start daemon with environment variables
export MAKIMA_DAEMON_SERVER_URL=ws://localhost:8080
export MAKIMA_API_KEY=your-api-key
makima daemon
```
---
### makima supervisor
Supervisor commands for contract orchestration. These commands are used by orchestrators to manage tasks, branches, and pull requests.
```bash
makima supervisor <SUBCOMMAND> [OPTIONS]
```
#### Common Options
All supervisor subcommands accept these common options:
| Option | Environment Variable | Default | Description |
|--------|---------------------|---------|-------------|
| `--api-url <URL>` | `MAKIMA_API_URL` | `https://api.makima.jp` | API URL |
| `--api-key <KEY>` | `MAKIMA_API_KEY` | - | API key for authentication |
| `--contract-id <UUID>` | `MAKIMA_CONTRACT_ID` | - | Contract ID |
| `--task-id <UUID>` | `MAKIMA_TASK_ID` | - | Current task ID (optional) |
#### Subcommands
##### tasks
List all tasks in the contract.
```bash
makima supervisor tasks [OPTIONS]
```
##### tree
Get the task tree structure showing parent-child relationships.
```bash
makima supervisor tree [OPTIONS]
```
##### spawn
Create and start a new task.
```bash
makima supervisor spawn <NAME> <PLAN> [OPTIONS]
```
| Argument/Option | Description |
|-----------------|-------------|
| `<NAME>` | Name of the task |
| `<PLAN>` | Plan/description for the task |
| `--parent <UUID>` | Parent task ID to branch from |
| `--checkpoint <SHA>` | Checkpoint SHA to start from |
| `--repo <URL>` | Repository URL (local path or remote) |
##### wait
Wait for a task to complete.
```bash
makima supervisor wait <TASK_ID> [TIMEOUT]
```
| Argument | Default | Description |
|----------|---------|-------------|
| `<TASK_ID>` | - | Task ID to wait for |
| `<TIMEOUT>` | `300` | Timeout in seconds |
##### read-file
Read a file from a task's worktree.
```bash
makima supervisor read-file <TASK_ID> <FILE_PATH>
```
##### branch
Create a git branch.
```bash
makima supervisor branch <NAME> [OPTIONS]
```
| Argument/Option | Description |
|-----------------|-------------|
| `<NAME>` | Branch name to create |
| `--from <REF>` | Reference (task ID or SHA) to branch from |
##### merge
Merge a task's changes to a branch.
```bash
makima supervisor merge <TASK_ID> [OPTIONS]
```
| Option | Description |
|--------|-------------|
| `--to <BRANCH>` | Target branch to merge into |
| `--squash` | Squash commits on merge |
##### pr
Create a pull request from a task's changes.
```bash
makima supervisor pr <TASK_ID> [OPTIONS]
```
| Option | Default | Description |
|--------|---------|-------------|
| `--title <TITLE>` | - | PR title (required) |
| `--body <BODY>` | - | PR body/description |
| `--base <BRANCH>` | `main` | Base branch |
##### diff
View a task's diff.
```bash
makima supervisor diff <TASK_ID>
```
##### checkpoint
Create a checkpoint (save point) for the current task.
```bash
makima supervisor checkpoint <MESSAGE>
```
##### checkpoints
List all checkpoints for the current task.
```bash
makima supervisor checkpoints
```
##### status
Get contract status including current phase.
```bash
makima supervisor status
```
##### advance-phase
Advance the contract to the next phase.
```bash
makima supervisor advance-phase <PHASE>
```
| Argument | Description |
|----------|-------------|
| `<PHASE>` | Phase to advance to (specify, plan, execute, review) |
##### ask
Ask a question and wait for user feedback.
```bash
makima supervisor ask <QUESTION> [OPTIONS]
```
| Option | Default | Description |
|--------|---------|-------------|
| `--choices <CHOICES>` | - | Comma-separated list of choices |
| `--context <CONTEXT>` | - | Context about what this relates to |
| `--timeout <SECONDS>` | `3600` | Timeout in seconds (default: 1 hour) |
---
### makima contract
Contract commands for task-contract interaction. These commands are used by tasks to interact with their parent contract.
```bash
makima contract <SUBCOMMAND> [OPTIONS]
```
#### Common Options
All contract subcommands accept these common options:
| Option | Environment Variable | Default | Description |
|--------|---------------------|---------|-------------|
| `--api-url <URL>` | `MAKIMA_API_URL` | `https://api.makima.jp` | API URL |
| `--api-key <KEY>` | `MAKIMA_API_KEY` | - | API key for authentication |
| `--contract-id <UUID>` | `MAKIMA_CONTRACT_ID` | - | Contract ID |
| `--task-id <UUID>` | `MAKIMA_TASK_ID` | - | Current task ID (optional) |
#### Subcommands
##### status
Get the contract status.
```bash
makima contract status
```
Returns JSON with contract name, description, current phase, and status.
##### checklist
Get the phase checklist with deliverables.
```bash
makima contract checklist
```
Returns JSON with completion percentage, file deliverables, and suggestions.
##### goals
Get the contract goals.
```bash
makima contract goals
```
##### files
List all contract files.
```bash
makima contract files
```
##### file
Get a specific file's content.
```bash
makima contract file <FILE_ID>
```
##### report
Report progress on the contract.
```bash
makima contract report <MESSAGE>
```
##### suggest-action
Get a suggested next action based on contract state.
```bash
makima contract suggest-action
```
##### completion-action
Get a completion recommendation with metrics.
```bash
makima contract completion-action [OPTIONS]
```
| Option | Default | Description |
|--------|---------|-------------|
| `--files <FILES>` | - | Comma-separated list of modified files |
| `--lines-added <N>` | `0` | Number of lines added |
| `--lines-removed <N>` | `0` | Number of lines removed |
| `--code` | - | Flag indicating code changes |
##### update-file
Update an existing contract file (reads content from stdin).
```bash
cat content.md | makima contract update-file <FILE_ID>
```
##### create-file
Create a new contract file (reads content from stdin).
```bash
cat content.md | makima contract create-file <NAME>
```
---
## Configuration
### Configuration File
The daemon loads configuration from multiple sources in order of precedence (highest first):
1. CLI arguments
2. Environment variables
3. Custom config file (if `--config` specified)
4. `./makima-daemon.toml` (current directory)
5. `~/.config/makima-daemon/config.toml` (user config)
6. `/etc/makima-daemon/config.toml` (system config, Linux only)
7. Default values
#### Example Configuration File
Create `makima-daemon.toml`:
```toml
# Server connection settings
[server]
url = "ws://localhost:8080"
api_key = "your-api-key"
heartbeat_interval_secs = 30
reconnect_interval_secs = 5
max_reconnect_attempts = 0 # 0 = infinite
# Worktree settings for task isolation
[worktree]
base_dir = "~/.makima/worktrees"
repos_dir = "~/.makima/repos"
branch_prefix = "makima/task-"
cleanup_on_start = false
# Process settings for Claude Code execution
[process]
claude_command = "claude"
claude_args = []
claude_pre_args = []
enable_permissions = false
disable_verbose = false
max_concurrent_tasks = 4
default_timeout_secs = 0 # 0 = no timeout
# Additional environment variables for Claude Code
[process.env_vars]
ANTHROPIC_API_KEY = "your-anthropic-key"
# Local database settings
[local_db]
path = "~/.makima/daemon.db"
# Logging settings
[logging]
level = "info" # trace, debug, info, warn, error
format = "pretty" # pretty or json
# Repository auto-clone settings
[repos]
home_dir = "~/.makima/home"
# Auto-clone repositories on daemon startup
[[repos.auto_clone]]
url = "https://github.com/user/repo.git"
branch = "main"
shallow = true
# Shorthand format also supported
[[repos.auto_clone]]
url = "github:user/another-repo"
name = "custom-name"
```
### Environment Variables
#### Daemon Environment Variables
| Variable | Description |
|----------|-------------|
| `MAKIMA_API_KEY` | API key for authentication (preferred) |
| `MAKIMA_DAEMON_SERVER_URL` | WebSocket server URL |
| `MAKIMA_DAEMON_SERVER_APIKEY` | API key (alternative) |
| `MAKIMA_DAEMON_REPOS_DIR` | Repository directory |
| `MAKIMA_DAEMON_WORKTREES_DIR` | Worktrees directory |
| `MAKIMA_DAEMON_PROCESS_MAXCONCURRENTTASKS` | Max concurrent tasks |
#### Server Environment Variables
| Variable | Description |
|----------|-------------|
| `PORT` | Server port |
| `POSTGRES_CONNECTION_URI` | PostgreSQL connection URI |
| `PARAKEET_MODEL_DIR` | Parakeet model directory |
| `PARAKEET_EOU_DIR` | Parakeet EOU model directory |
| `SORTFORMER_MODEL_PATH` | Sortformer model path |
#### Supervisor/Contract Environment Variables
| Variable | Description |
|----------|-------------|
| `MAKIMA_API_URL` | API URL for commands |
| `MAKIMA_API_KEY` | API key for authentication |
| `MAKIMA_CONTRACT_ID` | Current contract ID |
| `MAKIMA_TASK_ID` | Current task ID |
---
## Usage Examples
### Starting the Server
```bash
# Start with defaults
makima server
# Start with database
makima server --database-url "postgresql://localhost/makima" --port 8080
# Production setup
makima server \
--port 8080 \
--database-url "$DATABASE_URL" \
--log-level info
```
### Running a Daemon Worker
```bash
# Quick start with CLI args
makima daemon \
--server-url ws://localhost:8080 \
--api-key your-api-key \
--max-tasks 4
# Using environment variables
export MAKIMA_DAEMON_SERVER_URL=ws://localhost:8080
export MAKIMA_API_KEY=your-api-key
makima daemon
# Using a config file
makima daemon --config /etc/makima/daemon.toml
```
### Contract Orchestration Workflow
```bash
# Set up environment
export MAKIMA_API_URL=http://localhost:8080
export MAKIMA_API_KEY=your-api-key
export MAKIMA_CONTRACT_ID=your-contract-uuid
# Check contract status
makima supervisor status
# List existing tasks
makima supervisor tasks
# View task tree
makima supervisor tree
# Spawn a new task
makima supervisor spawn "Implement feature X" "Add the new feature with tests"
# Wait for task completion
makima supervisor wait <task-id> 600
# View task diff
makima supervisor diff <task-id>
# Create a PR
makima supervisor pr <task-id> \
--title "Add feature X" \
--body "Implements feature X with full test coverage" \
--base main
# Or merge directly
makima supervisor merge <task-id> --to main --squash
# Ask user a question
makima supervisor ask "Which approach should we use?" \
--choices "Option A,Option B,Option C" \
--timeout 3600
```
### Task-Contract Interaction
When running inside a task, use contract commands to interact with the parent contract:
```bash
# Get contract context
makima contract status
# Check phase requirements
makima contract checklist
# List contract files
makima contract files
# Read a specific file
makima contract file <file-id>
# Report progress
makima contract report "Completed initial implementation"
# Get suggested next action
makima contract suggest-action
# Create a new documentation file
echo "# Architecture\n\nSystem design..." | makima contract create-file "Architecture"
# Update an existing file
cat updated_doc.md | makima contract update-file <file-id>
# Report completion with metrics
makima contract completion-action \
--files "src/main.rs,src/lib.rs" \
--lines-added 150 \
--lines-removed 30 \
--code
```
---
## Output Format
All commands output JSON to stdout for easy parsing and integration:
```bash
# Parse with jq
makima supervisor tasks | jq '.tasks[].name'
# Get specific fields
makima contract status | jq '{name: .name, phase: .phase}'
# Check completion
makima contract checklist | jq '.completion_percentage'
```
---
## Exit Codes
| Code | Description |
|------|-------------|
| `0` | Success |
| `1` | General error (authentication failed, invalid arguments, etc.) |
---
## See Also
- [Makima README](../README.md) - Project overview
- [Task Branching Plan](./PLAN-task-branching.md) - Task isolation architecture
|