@katyella/legio 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +113 -389
- package/README.md +45 -466
- package/agents/builder.md +5 -15
- package/agents/cto.md +2 -2
- package/agents/gateway.md +23 -0
- package/agents/lead.md +6 -7
- package/agents/merger.md +5 -14
- package/agents/reviewer.md +6 -14
- package/agents/scout.md +3 -3
- package/package.json +1 -1
- package/src/agents/overlay.test.ts +9 -10
- package/src/agents/overlay.ts +35 -17
- package/src/commands/gateway.test.ts +60 -0
- package/src/commands/gateway.ts +6 -2
- package/src/commands/init.test.ts +157 -1
- package/src/commands/init.ts +86 -1
- package/src/commands/sling.ts +92 -38
- package/src/commands/worktree.ts +8 -3
- package/src/config.test.ts +3 -3
- package/src/config.ts +0 -1
- package/src/doctor/config-check.test.ts +68 -1
- package/src/doctor/config-check.ts +54 -0
- package/src/doctor/dependencies.ts +17 -4
- package/src/index.ts +1 -1
- package/src/server/routes.ts +1 -1
- package/templates/CLAUDE.md.tmpl +0 -89
package/README.md
CHANGED
|
@@ -4,35 +4,26 @@
|
|
|
4
4
|
<img src="assets/legio-mascot.png" alt="Legio mascot" width="400">
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
+
[](https://www.npmjs.com/package/@katyella/legio)
|
|
7
8
|
[](https://github.com/katyella/legio/actions/workflows/ci.yml)
|
|
8
9
|
[](https://opensource.org/licenses/MIT)
|
|
9
10
|
[](https://nodejs.org)
|
|
10
11
|
[](https://github.com/katyella/legio/releases)
|
|
11
12
|
|
|
12
|
-
Built on [Overstory](https://github.com/jayminwest/overstory).
|
|
13
|
-
|
|
14
13
|
**Turn one Claude Code session into a multi-agent fleet.**
|
|
15
14
|
|
|
16
|
-
Claude Code is powerful — but it works one task at a time
|
|
17
|
-
|
|
18
|
-
Legio changes that. It spawns specialized agents in isolated git worktrees, coordinates them through a typed SQLite messaging system, and merges their work back automatically with tiered conflict resolution. Your session becomes the orchestrator. The agents do the work in parallel.
|
|
19
|
-
|
|
20
|
-
> **Warning: Agent swarms are not a universal solution.** Do not deploy Legio without understanding the risks of multi-agent orchestration — compounding error rates, cost amplification, debugging complexity, and merge conflicts are the normal case, not edge cases. Read [STEELMAN.md](STEELMAN.md) for a full risk analysis and the [Agentic Engineering Book](https://github.com/jayminwest/agentic-engineering-book) ([web version](https://jayminwest.com/agentic-engineering-book)) before using this tool in production.
|
|
21
|
-
|
|
22
|
-
## Why Legio?
|
|
15
|
+
Claude Code is powerful — but it works one task at a time. One agent, one context window, one thread of execution.
|
|
23
16
|
|
|
24
|
-
|
|
17
|
+
Legio changes that. It spawns specialized agents in isolated git worktrees, coordinates them through a typed SQLite messaging system, and merges their work back automatically. Your session becomes the orchestrator. The agents do the work in parallel.
|
|
25
18
|
|
|
26
|
-
**
|
|
19
|
+
- **Parallel execution** — 5-10 agents working simultaneously, each in its own tmux session
|
|
20
|
+
- **Conflict-free isolation** — every agent in its own git worktree with exclusive file ownership
|
|
21
|
+
- **Structured coordination** — typed SQLite mail system with protocol-level message types, not ad-hoc prompts
|
|
22
|
+
- **Automatic merge pipeline** — FIFO queue with 4-tier conflict resolution
|
|
23
|
+
- **Real-time visibility** — browser dashboard shows every agent's status, cost, and output live
|
|
24
|
+
- **Tiered health monitoring** — mechanical watchdog catches stalls and crashes before you do
|
|
27
25
|
|
|
28
|
-
**
|
|
29
|
-
|
|
30
|
-
- Parallel execution — 5-10 agents working simultaneously
|
|
31
|
-
- Conflict-free isolation — every agent in its own git worktree with exclusive file ownership
|
|
32
|
-
- Structured coordination — typed SQLite mail system, not ad-hoc prompts
|
|
33
|
-
- Automatic merge pipeline — FIFO queue with 4-tier conflict resolution
|
|
34
|
-
- Real-time visibility — browser dashboard shows every agent status, cost, and output live
|
|
35
|
-
- Tiered health monitoring — mechanical watchdog catches stalls and crashes
|
|
26
|
+
> **Heads up:** Multi-agent swarms burn through tokens fast — a single session can push the limits of a 20x Max Claude subscription.
|
|
36
27
|
|
|
37
28
|
## See It in Action
|
|
38
29
|
|
|
@@ -43,20 +34,24 @@ Legio changes that. It spawns specialized agents in isolated git worktrees, coor
|
|
|
43
34
|
</p>
|
|
44
35
|
|
|
45
36
|
<p align="center">
|
|
46
|
-
<img src="assets/
|
|
37
|
+
<img src="assets/inspect.png" alt="Inspect — deep per-agent inspection" width="800">
|
|
47
38
|
<br>
|
|
48
|
-
<em>
|
|
39
|
+
<em>Inspect: deep dive into any agent's activity, tool calls, and terminal output</em>
|
|
49
40
|
</p>
|
|
50
41
|
|
|
51
42
|
<p align="center">
|
|
52
|
-
<img src="assets/
|
|
43
|
+
<img src="assets/costs.png" alt="Costs — token usage and cost breakdown" width="800">
|
|
53
44
|
<br>
|
|
54
|
-
<em>
|
|
45
|
+
<em>Costs: token usage by model, per-agent breakdown, and daily cost trends</em>
|
|
55
46
|
</p>
|
|
56
47
|
|
|
57
|
-
|
|
48
|
+
<p align="center">
|
|
49
|
+
<img src="assets/tasks.png" alt="Tasks — issue tracking kanban board" width="800">
|
|
50
|
+
<br>
|
|
51
|
+
<em>Tasks: kanban board with issue tracking, priority filters, and dispatch controls</em>
|
|
52
|
+
</p>
|
|
58
53
|
|
|
59
|
-
|
|
54
|
+
## Quick Start
|
|
60
55
|
|
|
61
56
|
```bash
|
|
62
57
|
cd your-project
|
|
@@ -71,41 +66,9 @@ legio doctor
|
|
|
71
66
|
legio down
|
|
72
67
|
```
|
|
73
68
|
|
|
74
|
-
Or step by step:
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
# Initialize legio in your project
|
|
78
|
-
legio init
|
|
79
|
-
|
|
80
|
-
# Install hooks into .claude/settings.local.json
|
|
81
|
-
legio hooks install
|
|
82
|
-
|
|
83
|
-
# Start the web UI server (daemon mode)
|
|
84
|
-
legio server start --daemon
|
|
85
|
-
|
|
86
|
-
# Start a coordinator (persistent orchestrator)
|
|
87
|
-
legio coordinator start
|
|
88
|
-
|
|
89
|
-
# Or spawn individual worker agents
|
|
90
|
-
# Task IDs come from beads: run `bd ready` to find available work, or `bd create` to create new tasks
|
|
91
|
-
legio sling <task-id> --capability builder --name my-builder
|
|
92
|
-
|
|
93
|
-
# Check agent status
|
|
94
|
-
legio status
|
|
95
|
-
|
|
96
|
-
# Live TUI dashboard for monitoring the fleet
|
|
97
|
-
legio dashboard
|
|
98
|
-
|
|
99
|
-
# Nudge a stalled agent
|
|
100
|
-
legio nudge <agent-name>
|
|
101
|
-
|
|
102
|
-
# Check mail from agents
|
|
103
|
-
legio mail check --inject
|
|
104
|
-
```
|
|
105
|
-
|
|
106
69
|
## How It Works
|
|
107
70
|
|
|
108
|
-
CLAUDE.md + hooks + the `legio` CLI turn your Claude Code session into a multi-agent orchestrator. A persistent coordinator
|
|
71
|
+
CLAUDE.md + hooks + the `legio` CLI turn your Claude Code session into a multi-agent orchestrator. A persistent coordinator manages task decomposition and dispatch, while a mechanical watchdog daemon monitors agent health.
|
|
109
72
|
|
|
110
73
|
```
|
|
111
74
|
Coordinator (persistent orchestrator at project root)
|
|
@@ -113,66 +76,22 @@ Coordinator (persistent orchestrator at project root)
|
|
|
113
76
|
--> Workers: Scout, Builder, Reviewer, Merger (depth 2)
|
|
114
77
|
```
|
|
115
78
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
| Agent | Role | Access |
|
|
119
|
-
|-------|------|--------|
|
|
120
|
-
| **Coordinator** | Persistent orchestrator — decomposes objectives, dispatches agents, tracks task groups | Read-only |
|
|
121
|
-
| **Lead** | Team coordination, can spawn sub-workers | Read-write |
|
|
122
|
-
| **Gateway** | Planning companion — analyzes codebase, decomposes objectives into issues, bridges human intent and agent work | Read-only |
|
|
123
|
-
| **Scout** | Read-only exploration and research | Read-only |
|
|
124
|
-
| **Builder** | Implementation and code changes | Read-write |
|
|
125
|
-
| **Reviewer** | Validation and code review | Read-only |
|
|
126
|
-
| **Merger** | Branch merge specialist | Read-write |
|
|
127
|
-
| **Supervisor** | Per-project team lead — manages worker lifecycle, handles nudge/escalation | Read-only |
|
|
128
|
-
| **CTO** | Strategic technical leadership | Read-only |
|
|
129
|
-
| **Monitor** | Tier 2 continuous fleet patrol — ongoing health monitoring | Read-only |
|
|
130
|
-
|
|
131
|
-
### Key Architecture
|
|
132
|
-
|
|
133
|
-
- **Agent Definitions**: Two-layer system — base `.md` files define the HOW (workflow), per-task overlays define the WHAT (task scope). Base definition content is injected into spawned agent overlays automatically.
|
|
134
|
-
- **Messaging**: Custom SQLite mail system with typed protocol — 8 message types (`worker_done`, `merge_ready`, `dispatch`, `escalation`, etc.) for structured agent coordination, plus broadcast messaging with group addresses (`@all`, `@builders`, etc.)
|
|
135
|
-
- **Worktrees**: Each agent gets an isolated git worktree — no file conflicts between agents
|
|
136
|
-
- **Merge**: FIFO merge queue (SQLite-backed) with 4-tier conflict resolution
|
|
137
|
-
- **Watchdog**: Tiered health monitoring — Tier 0 mechanical daemon (tmux/pid liveness), Tier 1 AI-assisted failure triage, Tier 2 monitor agent for continuous fleet patrol
|
|
138
|
-
- **Web UI**: Browser-based dashboard with real-time WebSocket updates — agent monitoring, mail, terminal access, cost tracking, and setup wizard
|
|
139
|
-
- **Tool Enforcement**: PreToolUse hooks mechanically block file modifications for non-implementation agents and dangerous git operations for all agents
|
|
140
|
-
- **Task Groups**: Batch coordination with auto-close when all member issues complete
|
|
141
|
-
- **Session Lifecycle**: Checkpoint save/restore for compaction survivability, handoff orchestration for crash recovery
|
|
142
|
-
- **Token Instrumentation**: Session metrics extracted from Claude Code transcript JSONL files
|
|
143
|
-
|
|
144
|
-
## Web UI
|
|
145
|
-
|
|
146
|
-
Legio includes a browser-based dashboard for real-time fleet monitoring. Start it with `legio server start` or `legio up`.
|
|
147
|
-
|
|
148
|
-
**Views:**
|
|
149
|
-
|
|
150
|
-
| View | Description |
|
|
151
|
-
|------|-------------|
|
|
152
|
-
| **Dashboard** | Agent status, mail feed, merge queue, system metrics |
|
|
153
|
-
| **Costs** | Token usage and cost breakdown |
|
|
154
|
-
| **Tasks** | Beads issue tracking and status |
|
|
155
|
-
| **Chat** | Task-based conversations grouped by issue |
|
|
156
|
-
| **Setup** | Initialization wizard and configuration |
|
|
157
|
-
| **Gateway Chat** | Gateway agent conversation interface |
|
|
158
|
-
| **Inspect** | Deep per-agent inspection |
|
|
159
|
-
| **Task Detail** | Task overview with agents and communication tabs |
|
|
160
|
-
|
|
161
|
-
**Tech:** Preact + HTM + Tailwind CSS, WebSocket for real-time updates, zero build step.
|
|
79
|
+
**Agent types:** Coordinator, Lead, Gateway, Supervisor, Scout, Builder, Reviewer, Merger, Monitor, CTO — each with defined access levels (read-only vs read-write) and hierarchy constraints. See [docs/architecture.md](docs/architecture.md) for details.
|
|
162
80
|
|
|
163
|
-
##
|
|
81
|
+
## Key Features
|
|
164
82
|
|
|
165
|
-
-
|
|
166
|
-
-
|
|
167
|
-
-
|
|
168
|
-
- tmux
|
|
169
|
-
-
|
|
170
|
-
-
|
|
83
|
+
- **Messaging system** — SQLite-backed typed mail with protocol messages (`worker_done`, `merge_ready`, `dispatch`, `escalation`), broadcast groups (`@all`, `@builders`), and auto-nudge on high priority
|
|
84
|
+
- **Merge pipeline** — FIFO queue with 4-tier conflict resolution, from fast-forward through AI-assisted merge
|
|
85
|
+
- **Web dashboard** — Real-time agent monitoring, mail feed, cost tracking, terminal access, and setup wizard via browser UI (Preact + HTM, zero build step)
|
|
86
|
+
- **Health monitoring** — Tier 0 mechanical daemon (tmux/pid liveness), Tier 1 AI-assisted failure triage, Tier 2 continuous monitor agent
|
|
87
|
+
- **Tool enforcement** — PreToolUse hooks mechanically block dangerous operations per agent role
|
|
88
|
+
- **Task groups** — Batch coordination with auto-close when all member issues complete
|
|
89
|
+
- **Session lifecycle** — Checkpoint save/restore for compaction survivability, crash recovery handoffs
|
|
171
90
|
|
|
172
91
|
## Installation
|
|
173
92
|
|
|
174
93
|
```bash
|
|
175
|
-
npm install -g legio
|
|
94
|
+
npm install -g @katyella/legio
|
|
176
95
|
```
|
|
177
96
|
|
|
178
97
|
### From Source
|
|
@@ -184,366 +103,25 @@ npm install
|
|
|
184
103
|
npm link
|
|
185
104
|
```
|
|
186
105
|
|
|
187
|
-
##
|
|
188
|
-
|
|
189
|
-
### Bootstrap
|
|
190
|
-
|
|
191
|
-
```
|
|
192
|
-
legio up Start everything (init + server + coordinator)
|
|
193
|
-
--port <n> Server port (default: 4173)
|
|
194
|
-
--host <addr> Server host (default: 127.0.0.1)
|
|
195
|
-
--no-open Skip opening browser
|
|
196
|
-
--force Reinitialize even if .legio/ exists
|
|
197
|
-
--json JSON output
|
|
198
|
-
|
|
199
|
-
legio down Stop everything (coordinator + server)
|
|
200
|
-
--json JSON output
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
### Core Workflow
|
|
204
|
-
|
|
205
|
-
```
|
|
206
|
-
legio init Initialize .legio/ in current project
|
|
207
|
-
(deploys agent definitions automatically)
|
|
208
|
-
|
|
209
|
-
legio sling <task-id> Spawn a worker agent
|
|
210
|
-
--capability <type> builder | scout | reviewer | lead | merger
|
|
211
|
-
| coordinator | supervisor | monitor
|
|
212
|
-
--name <name> Unique agent name
|
|
213
|
-
--spec <path> Path to task spec file
|
|
214
|
-
--files <f1,f2,...> Exclusive file scope
|
|
215
|
-
--parent <agent-name> Parent (for hierarchy tracking)
|
|
216
|
-
--depth <n> Current hierarchy depth
|
|
217
|
-
--json JSON output
|
|
218
|
-
|
|
219
|
-
legio prime Load context for orchestrator/agent
|
|
220
|
-
--agent <name> Per-agent priming
|
|
221
|
-
--compact Restore from checkpoint (compaction)
|
|
222
|
-
|
|
223
|
-
legio spec write <bead-id> Write a task specification
|
|
224
|
-
--body <content> Spec content (or pipe via stdin)
|
|
225
|
-
|
|
226
|
-
legio agents discover Discover agents by capability/state/parent
|
|
227
|
-
--capability <type> Filter by capability type
|
|
228
|
-
--state <state> Filter by agent state
|
|
229
|
-
--parent <name> Filter by parent agent
|
|
230
|
-
--json JSON output
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
### Server
|
|
234
|
-
|
|
235
|
-
```
|
|
236
|
-
legio server start Start the web UI server
|
|
237
|
-
--port <n> Server port (default: 4173)
|
|
238
|
-
--host <addr> Server host (default: 127.0.0.1)
|
|
239
|
-
--open Open browser on start
|
|
240
|
-
--daemon Run as background process
|
|
241
|
-
legio server stop Stop the server daemon
|
|
242
|
-
legio server status Show server state
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
### Coordination Agents
|
|
246
|
-
|
|
247
|
-
```
|
|
248
|
-
legio coordinator start Start persistent coordinator agent
|
|
249
|
-
--attach / --no-attach TTY-aware tmux attach (default: auto)
|
|
250
|
-
--watchdog Auto-start watchdog daemon with coordinator
|
|
251
|
-
--monitor Auto-start Tier 2 monitor agent
|
|
252
|
-
legio coordinator stop Stop coordinator
|
|
253
|
-
legio coordinator status Show coordinator state
|
|
254
|
-
|
|
255
|
-
legio supervisor start Start per-project supervisor agent
|
|
256
|
-
--task <bead-id> Bead task ID (required)
|
|
257
|
-
--name <name> Unique name (required)
|
|
258
|
-
--parent <agent> Parent agent (default: coordinator)
|
|
259
|
-
--depth <n> Hierarchy depth (default: 1)
|
|
260
|
-
--attach / --no-attach TTY-aware tmux attach (default: auto)
|
|
261
|
-
legio supervisor stop Stop supervisor
|
|
262
|
-
legio supervisor status Show supervisor state
|
|
263
|
-
|
|
264
|
-
legio monitor start Start Tier 2 monitor agent
|
|
265
|
-
legio monitor stop Stop monitor agent
|
|
266
|
-
legio monitor status Show monitor state
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### Messaging
|
|
270
|
-
|
|
271
|
-
```
|
|
272
|
-
legio mail send Send a message
|
|
273
|
-
--to <agent> --subject <text> --body <text>
|
|
274
|
-
--to @all | @builders | @scouts ... Broadcast to group addresses
|
|
275
|
-
--type <status|question|result|error>
|
|
276
|
-
--priority <low|normal|high|urgent> (urgent/high auto-nudges recipient)
|
|
277
|
-
|
|
278
|
-
legio mail check Check inbox (unread messages)
|
|
279
|
-
--agent <name> --inject --json
|
|
280
|
-
--debounce <ms> Skip if checked within window
|
|
281
|
-
|
|
282
|
-
legio mail list List messages with filters
|
|
283
|
-
--from <name> --to <name> --unread
|
|
284
|
-
|
|
285
|
-
legio mail read <id> Mark message as read
|
|
286
|
-
legio mail reply <id> --body <text> Reply in same thread
|
|
287
|
-
|
|
288
|
-
legio nudge <agent> [message] Send a text nudge to an agent
|
|
289
|
-
--from <name> Sender name (default: orchestrator)
|
|
290
|
-
--force Skip debounce check
|
|
291
|
-
--json JSON output
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
### Merge & Groups
|
|
295
|
-
|
|
296
|
-
```
|
|
297
|
-
legio merge Merge agent branches into canonical
|
|
298
|
-
--branch <name> Specific branch
|
|
299
|
-
--all All completed branches
|
|
300
|
-
--into <branch> Target branch (default: session-branch.txt > canonicalBranch)
|
|
301
|
-
--dry-run Check for conflicts only
|
|
302
|
-
|
|
303
|
-
legio group create <name> Create a task group for batch tracking
|
|
304
|
-
legio group status <name> Show group progress
|
|
305
|
-
legio group add <name> <issue-id> Add issue to group
|
|
306
|
-
legio group list List all groups
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
### Monitoring & Observability
|
|
310
|
-
|
|
311
|
-
```
|
|
312
|
-
legio status Show all active agents, worktrees, beads state
|
|
313
|
-
--json --verbose
|
|
314
|
-
|
|
315
|
-
legio dashboard Live TUI dashboard for agent monitoring
|
|
316
|
-
--interval <ms> Refresh interval (default: 2000)
|
|
317
|
-
|
|
318
|
-
legio inspect <agent> Deep per-agent inspection
|
|
319
|
-
--json --follow --interval <ms> --no-tmux --limit <n>
|
|
320
|
-
|
|
321
|
-
legio trace View agent/bead timeline
|
|
322
|
-
--agent <name> --run <id>
|
|
323
|
-
--since <ts> --until <ts> --limit <n> --json
|
|
324
|
-
|
|
325
|
-
legio feed [options] Unified real-time event stream across agents
|
|
326
|
-
--follow, -f --interval <ms>
|
|
327
|
-
--agent <name> --run <id> --json
|
|
328
|
-
|
|
329
|
-
legio errors Aggregated error view across agents
|
|
330
|
-
--agent <name> --run <id>
|
|
331
|
-
--since <ts> --until <ts> --limit <n> --json
|
|
332
|
-
|
|
333
|
-
legio replay Interleaved chronological replay
|
|
334
|
-
--run <id> --agent <name>
|
|
335
|
-
--since <ts> --until <ts> --limit <n> --json
|
|
336
|
-
|
|
337
|
-
legio logs [options] Query NDJSON logs across agents
|
|
338
|
-
--agent <name> --level <level>
|
|
339
|
-
--since <ts> --until <ts> --follow --json
|
|
340
|
-
|
|
341
|
-
legio costs Token/cost analysis and breakdown
|
|
342
|
-
--live --agent <name> --run <id>
|
|
343
|
-
--by-capability --last <n> --json
|
|
344
|
-
|
|
345
|
-
legio metrics Show session metrics
|
|
346
|
-
--last <n> --json
|
|
347
|
-
|
|
348
|
-
legio run list List orchestration runs
|
|
349
|
-
legio run show <id> Show run details
|
|
350
|
-
legio run complete Mark current run complete
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
### Infrastructure
|
|
354
|
-
|
|
355
|
-
```
|
|
356
|
-
legio hooks install Install orchestrator hooks to .claude/settings.local.json
|
|
357
|
-
--force Overwrite existing hooks
|
|
358
|
-
legio hooks uninstall Remove orchestrator hooks
|
|
359
|
-
legio hooks status Check if hooks are installed
|
|
360
|
-
|
|
361
|
-
legio worktree list List worktrees with status
|
|
362
|
-
legio worktree clean Remove completed worktrees
|
|
363
|
-
--completed --all
|
|
364
|
-
|
|
365
|
-
legio watch Start watchdog daemon (Tier 0)
|
|
366
|
-
--interval <ms> --background
|
|
367
|
-
|
|
368
|
-
legio doctor Run health checks on legio setup
|
|
369
|
-
--json --category <name>
|
|
370
|
-
|
|
371
|
-
legio clean Clean up worktrees, sessions, artifacts
|
|
372
|
-
--all --mail --sessions --metrics
|
|
373
|
-
--logs --worktrees --branches
|
|
374
|
-
--agents --specs --json
|
|
106
|
+
## Requirements
|
|
375
107
|
|
|
376
|
-
|
|
108
|
+
- [Node.js](https://nodejs.org) (v22+)
|
|
109
|
+
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code)
|
|
110
|
+
- git
|
|
111
|
+
- tmux
|
|
112
|
+
- [bd (beads)](https://github.com/steveyegge/beads) — issue tracking CLI
|
|
113
|
+
- [mulch](https://github.com/jayminwest/mulch) — structured expertise management CLI (`npm install -g @os-eco/mulch-cli`)
|
|
377
114
|
|
|
378
|
-
|
|
379
|
-
--quiet, -q Suppress non-error output
|
|
380
|
-
--completions <shell> Generate shell completions (bash, zsh, fish)
|
|
381
|
-
```
|
|
115
|
+
## Documentation
|
|
382
116
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
| Endpoint | Description |
|
|
388
|
-
|----------|-------------|
|
|
389
|
-
| `GET /api/status` | Overall project status |
|
|
390
|
-
| `GET /api/health` | Server health check |
|
|
391
|
-
| `GET /api/agents` | List all agents |
|
|
392
|
-
| `GET /api/agents/active` | Active agents only |
|
|
393
|
-
| `GET /api/agents/:name` | Agent details |
|
|
394
|
-
| `GET /api/agents/:name/inspect` | Deep inspection data |
|
|
395
|
-
| `GET /api/agents/:name/events` | Agent events |
|
|
396
|
-
| `POST /api/agents/:name/chat` | Send chat message to agent |
|
|
397
|
-
| `GET /api/agents/:name/chat/history` | Agent chat history |
|
|
398
|
-
| `POST /api/agents/spawn` | Spawn agent from UI |
|
|
399
|
-
| `POST /api/coordinator/chat` | Send chat message to coordinator |
|
|
400
|
-
| `GET /api/coordinator/chat/history` | Coordinator chat history |
|
|
401
|
-
| `POST /api/gateway/chat` | Send chat message to gateway |
|
|
402
|
-
| `GET /api/gateway/chat/history` | Gateway chat history |
|
|
403
|
-
| `GET /api/chat/unified/history` | Unified chat timeline |
|
|
404
|
-
| `POST /api/chat/transcript-sync` | Sync transcript data |
|
|
405
|
-
| `GET /api/ideas` | Ideas list |
|
|
406
|
-
| `POST /api/ideas` | Create idea |
|
|
407
|
-
| `PUT /api/ideas/:id` | Update idea |
|
|
408
|
-
| `DELETE /api/ideas/:id` | Delete idea |
|
|
409
|
-
| `POST /api/ideas/:id/dispatch` | Dispatch idea to agents |
|
|
410
|
-
| `POST /api/ideas/:id/backlog` | Move idea to backlog |
|
|
411
|
-
| `GET /api/mail` | All messages |
|
|
412
|
-
| `GET /api/mail/unread` | Unread messages |
|
|
413
|
-
| `GET /api/mail/conversations` | Thread grouping |
|
|
414
|
-
| `POST /api/mail/send` | Send a message |
|
|
415
|
-
| `GET /api/events` | Tool events |
|
|
416
|
-
| `GET /api/events/errors` | Error events |
|
|
417
|
-
| `GET /api/metrics` | Session metrics |
|
|
418
|
-
| `GET /api/runs` | All runs |
|
|
419
|
-
| `GET /api/runs/active` | Active run |
|
|
420
|
-
| `GET /api/issues` | Beads issues |
|
|
421
|
-
| `GET /api/merge-queue` | Merge queue status |
|
|
422
|
-
| `POST /api/terminal/send` | Send keys to tmux pane |
|
|
423
|
-
| `GET /api/terminal/capture` | Capture pane output |
|
|
424
|
-
| `POST /api/setup/init` | Initialize legio from UI |
|
|
425
|
-
| `GET /api/setup/status` | Setup status |
|
|
426
|
-
| `GET /api/audit` | Query audit trail |
|
|
427
|
-
| `WS /ws` | WebSocket for real-time updates |
|
|
428
|
-
|
|
429
|
-
## Tech Stack
|
|
430
|
-
|
|
431
|
-
- **Runtime**: Node/tsx (TypeScript directly, no build step)
|
|
432
|
-
- **Node.js**: v22+ (required for `better-sqlite3`)
|
|
433
|
-
- **Dependencies**: `better-sqlite3` (SQLite), `tsx` (TypeScript execution), `ws` (WebSocket server)
|
|
434
|
-
- **Database**: SQLite via `better-sqlite3` (WAL mode for concurrent access)
|
|
435
|
-
- **Web UI**: Preact + HTM + Tailwind CSS (zero build step, served from `src/server/public/`)
|
|
436
|
-
- **Linting**: Biome (formatter + linter)
|
|
437
|
-
- **Testing**: `vitest` (stores, server) + `playwright` (e2e)
|
|
438
|
-
- **External CLIs**: `bd` (beads), `mulch`, `git`, `tmux` — invoked as subprocesses
|
|
117
|
+
- [CLI Reference](docs/cli.md) — full command reference with all flags
|
|
118
|
+
- [REST API](docs/api.md) — server endpoints and WebSocket
|
|
119
|
+
- [Architecture](docs/architecture.md) — tech stack, agent types, project structure
|
|
439
120
|
|
|
440
121
|
## Development
|
|
441
122
|
|
|
442
123
|
```bash
|
|
443
|
-
|
|
444
|
-
npm test
|
|
445
|
-
|
|
446
|
-
# Run store/server tests (vitest)
|
|
447
|
-
npm run test:server
|
|
448
|
-
|
|
449
|
-
# Run e2e tests (playwright)
|
|
450
|
-
npm run test:e2e
|
|
451
|
-
|
|
452
|
-
# Run a single test file
|
|
453
|
-
npx vitest run src/config.test.ts
|
|
454
|
-
|
|
455
|
-
# Lint + format check
|
|
456
|
-
npx biome check .
|
|
457
|
-
|
|
458
|
-
# Type check
|
|
459
|
-
tsc --noEmit
|
|
460
|
-
|
|
461
|
-
# All quality gates
|
|
462
|
-
npm test && npx biome check . && tsc --noEmit
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
### Versioning
|
|
466
|
-
|
|
467
|
-
Version is maintained in two places that must stay in sync:
|
|
468
|
-
|
|
469
|
-
1. `package.json` — `"version"` field
|
|
470
|
-
2. `src/index.ts` — `VERSION` constant
|
|
471
|
-
|
|
472
|
-
Version bumps are handled by the GitHub Actions `workflow_dispatch` workflow. Do not bump versions manually.
|
|
473
|
-
|
|
474
|
-
## Project Structure
|
|
475
|
-
|
|
476
|
-
```
|
|
477
|
-
legio/
|
|
478
|
-
src/
|
|
479
|
-
index.ts CLI entry point (command router)
|
|
480
|
-
types.ts Shared types and interfaces
|
|
481
|
-
config.ts Config loader + validation
|
|
482
|
-
errors.ts Custom error types
|
|
483
|
-
commands/ One file per CLI subcommand (34 commands)
|
|
484
|
-
up.ts Bootstrap full stack
|
|
485
|
-
down.ts Shutdown full stack
|
|
486
|
-
server.ts Web UI server lifecycle
|
|
487
|
-
agents.ts Agent discovery and querying
|
|
488
|
-
coordinator.ts Persistent orchestrator lifecycle
|
|
489
|
-
gateway.ts Gateway agent lifecycle
|
|
490
|
-
supervisor.ts Team lead management
|
|
491
|
-
dashboard.ts Live TUI dashboard (ANSI, zero deps)
|
|
492
|
-
hooks.ts Orchestrator hooks management
|
|
493
|
-
sling.ts Agent spawning
|
|
494
|
-
group.ts Task group batch tracking
|
|
495
|
-
nudge.ts Agent nudging
|
|
496
|
-
mail.ts Inter-agent messaging
|
|
497
|
-
monitor.ts Tier 2 monitor management
|
|
498
|
-
merge.ts Branch merging
|
|
499
|
-
status.ts Fleet status overview
|
|
500
|
-
prime.ts Context priming
|
|
501
|
-
init.ts Project initialization
|
|
502
|
-
worktree.ts Worktree management
|
|
503
|
-
watch.ts Watchdog daemon
|
|
504
|
-
log.ts Hook event logging
|
|
505
|
-
logs.ts NDJSON log query
|
|
506
|
-
feed.ts Unified real-time event stream
|
|
507
|
-
run.ts Orchestration run lifecycle
|
|
508
|
-
trace.ts Agent/bead timeline viewing
|
|
509
|
-
clean.ts Worktree/session cleanup
|
|
510
|
-
doctor.ts Health check runner (9 check modules)
|
|
511
|
-
inspect.ts Deep per-agent inspection
|
|
512
|
-
spec.ts Task spec management
|
|
513
|
-
errors.ts Aggregated error view
|
|
514
|
-
replay.ts Interleaved event replay
|
|
515
|
-
costs.ts Token/cost analysis
|
|
516
|
-
metrics.ts Session metrics
|
|
517
|
-
completions.ts Shell completion generation (bash/zsh/fish)
|
|
518
|
-
server/ Web UI server
|
|
519
|
-
routes.ts REST API routes
|
|
520
|
-
websocket.ts WebSocket real-time updates
|
|
521
|
-
audit-store.ts SQLite audit trail
|
|
522
|
-
public/ Frontend (Preact + HTM + Tailwind)
|
|
523
|
-
views/ UI views (command, chat, dashboard, etc.)
|
|
524
|
-
components/ Reusable UI components
|
|
525
|
-
lib/ Client-side state, API, WebSocket
|
|
526
|
-
agents/ Agent lifecycle management
|
|
527
|
-
manifest.ts Agent registry (load + query)
|
|
528
|
-
overlay.ts Dynamic CLAUDE.md overlay generator
|
|
529
|
-
identity.ts Persistent agent identity (CVs)
|
|
530
|
-
checkpoint.ts Session checkpoint save/restore
|
|
531
|
-
lifecycle.ts Handoff orchestration
|
|
532
|
-
hooks-deployer.ts Deploy hooks + tool enforcement
|
|
533
|
-
worktree/ Git worktree + tmux management
|
|
534
|
-
mail/ SQLite mail system (typed protocol, broadcast)
|
|
535
|
-
merge/ FIFO queue + conflict resolution
|
|
536
|
-
watchdog/ Tiered health monitoring (daemon, triage, health)
|
|
537
|
-
logging/ Multi-format logger + sanitizer + reporter + color control
|
|
538
|
-
metrics/ SQLite metrics + transcript parsing
|
|
539
|
-
doctor/ Health check modules (9 checks)
|
|
540
|
-
insights/ Session insight analyzer for auto-expertise
|
|
541
|
-
beads/ bd CLI wrapper + molecules
|
|
542
|
-
mulch/ mulch CLI wrapper
|
|
543
|
-
e2e/ End-to-end lifecycle tests
|
|
544
|
-
agents/ Base agent definitions (.md, 10 roles)
|
|
545
|
-
|
|
546
|
-
templates/ Templates for overlays and hooks
|
|
124
|
+
npm test && npm run lint && npm run typecheck
|
|
547
125
|
```
|
|
548
126
|
|
|
549
127
|
## License
|
|
@@ -552,4 +130,5 @@ MIT
|
|
|
552
130
|
|
|
553
131
|
---
|
|
554
132
|
|
|
555
|
-
|
|
133
|
+
Adopted from [Overstory](https://github.com/jayminwest/overstory).
|
|
134
|
+
|
package/agents/builder.md
CHANGED
|
@@ -16,10 +16,7 @@ You are an implementation specialist. Given a spec and a set of files you own, y
|
|
|
16
16
|
- **Grep** -- search file contents with regex
|
|
17
17
|
- **Bash:**
|
|
18
18
|
- `git add`, `git commit`, `git diff`, `git log`, `git status`
|
|
19
|
-
-
|
|
20
|
-
- `npm run lint` (lint and format check via biome)
|
|
21
|
-
- `npx biome check --write` (auto-fix lint/format issues)
|
|
22
|
-
- `npm run typecheck` (type checking via tsc)
|
|
19
|
+
- Project test, lint, and typecheck commands (see Quality Gates in your overlay)
|
|
23
20
|
- `bd show`, `bd close` (beads task management)
|
|
24
21
|
- `mulch prime`, `mulch record`, `mulch query` (expertise)
|
|
25
22
|
- `legio mail send`, `legio mail check` (communication)
|
|
@@ -49,12 +46,7 @@ You receive mail automatically. Do not call `legio mail check` in loops or on a
|
|
|
49
46
|
- You may read any file for context, but only write to scoped files.
|
|
50
47
|
- Follow project conventions (check existing code for patterns).
|
|
51
48
|
- Write tests alongside implementation.
|
|
52
|
-
5. **Run quality gates
|
|
53
|
-
```bash
|
|
54
|
-
npm run test:unit # Unit tests must pass
|
|
55
|
-
npm run lint # Lint and format must be clean
|
|
56
|
-
npm run typecheck # No TypeScript errors
|
|
57
|
-
```
|
|
49
|
+
5. **Run quality gates** as specified in your overlay's Quality Gates section (tests, lint, and any other configured gates).
|
|
58
50
|
6. **Commit your work** to your worktree branch:
|
|
59
51
|
```bash
|
|
60
52
|
git add <your-scoped-files>
|
|
@@ -77,7 +69,7 @@ You receive mail automatically. Do not call `legio mail check` in loops or on a
|
|
|
77
69
|
- **Never push to the canonical branch** (main/develop). You commit to your worktree branch only. Merging is handled by the orchestrator or a merger agent.
|
|
78
70
|
- **Never run `git push`** -- your branch lives in the local worktree. The merge process handles integration.
|
|
79
71
|
- **Never spawn sub-workers.** You are a leaf node. If you need something decomposed, ask your parent via mail.
|
|
80
|
-
- **Run quality gates before closing.** Do not report completion unless
|
|
72
|
+
- **Run quality gates before closing.** Do not report completion unless tests, lint, and typecheck pass (commands are in your overlay).
|
|
81
73
|
- If tests fail, fix them. If you cannot fix them, report the failure via mail with `--type error`.
|
|
82
74
|
|
|
83
75
|
## Communication Protocol
|
|
@@ -107,7 +99,7 @@ These are named failures. If you catch yourself doing any of these, stop and cor
|
|
|
107
99
|
- **FILE_SCOPE_VIOLATION** -- Editing or writing to a file not listed in your FILE_SCOPE. Read any file for context, but only modify scoped files.
|
|
108
100
|
- **CANONICAL_BRANCH_WRITE** -- Committing to or pushing to main/develop/canonical branch. You commit to your worktree branch only.
|
|
109
101
|
- **SILENT_FAILURE** -- Encountering an error (test failure, lint failure, blocked dependency) and not reporting it via mail. Every error must be communicated to your parent with `--type error`.
|
|
110
|
-
- **INCOMPLETE_CLOSE** -- Running `bd close` without first passing quality gates (
|
|
102
|
+
- **INCOMPLETE_CLOSE** -- Running `bd close` without first passing quality gates (tests, lint, and any other configured gates) and sending a result mail to your parent.
|
|
111
103
|
- **MISSING_WORKER_DONE** -- Closing a bead issue without first sending `worker_done` mail to parent. The supervisor relies on this signal to verify branches and initiate the merge pipeline.
|
|
112
104
|
- **MISSING_MULCH_RECORD** -- Closing without recording mulch learnings. Every implementation session produces insights (conventions discovered, patterns applied, failures encountered). Skipping `mulch record` loses knowledge for future agents.
|
|
113
105
|
|
|
@@ -117,9 +109,7 @@ Every mail message and every tool call costs tokens. Be concise in mail bodies -
|
|
|
117
109
|
|
|
118
110
|
## Completion Protocol
|
|
119
111
|
|
|
120
|
-
1. Run
|
|
121
|
-
2. Run `npm run lint` -- lint and formatting must be clean.
|
|
122
|
-
3. Run `npm run typecheck` -- no TypeScript errors.
|
|
112
|
+
1. Run the project's quality gate commands (tests, lint, and any other configured gates) as specified in your overlay.
|
|
123
113
|
4. Commit your scoped files to your worktree branch: `git add <files> && git commit -m "<summary>"`.
|
|
124
114
|
5. **Record mulch learnings** -- review your work for insights worth preserving (conventions discovered, patterns applied, failures encountered, decisions made) and record them:
|
|
125
115
|
```bash
|
package/agents/cto.md
CHANGED
|
@@ -48,8 +48,8 @@ Before forming opinions, gather raw facts from the system.
|
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
3. **Read architectural files:**
|
|
51
|
-
- `CLAUDE.md`, `README.md`,
|
|
52
|
-
- Key source
|
|
51
|
+
- `CLAUDE.md`, `README.md`, and the project's package/build configuration files
|
|
52
|
+
- Key source entry points and type definitions
|
|
53
53
|
- Any files flagged by mulch as hot (edited 3+ times recently)
|
|
54
54
|
|
|
55
55
|
4. **Analyze git history for patterns:**
|