@katyella/legio 0.1.0
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 +422 -0
- package/LICENSE +21 -0
- package/README.md +555 -0
- package/agents/builder.md +141 -0
- package/agents/coordinator.md +351 -0
- package/agents/cto.md +196 -0
- package/agents/gateway.md +276 -0
- package/agents/lead.md +281 -0
- package/agents/merger.md +156 -0
- package/agents/monitor.md +212 -0
- package/agents/reviewer.md +142 -0
- package/agents/scout.md +131 -0
- package/agents/supervisor.md +416 -0
- package/bin/legio.mjs +38 -0
- package/package.json +77 -0
- package/src/agents/checkpoint.test.ts +88 -0
- package/src/agents/checkpoint.ts +102 -0
- package/src/agents/hooks-deployer.test.ts +1820 -0
- package/src/agents/hooks-deployer.ts +574 -0
- package/src/agents/identity.test.ts +614 -0
- package/src/agents/identity.ts +385 -0
- package/src/agents/lifecycle.test.ts +202 -0
- package/src/agents/lifecycle.ts +184 -0
- package/src/agents/manifest.test.ts +558 -0
- package/src/agents/manifest.ts +297 -0
- package/src/agents/overlay.test.ts +592 -0
- package/src/agents/overlay.ts +316 -0
- package/src/beads/client.test.ts +210 -0
- package/src/beads/client.ts +227 -0
- package/src/beads/molecules.test.ts +320 -0
- package/src/beads/molecules.ts +209 -0
- package/src/commands/agents.test.ts +325 -0
- package/src/commands/agents.ts +286 -0
- package/src/commands/clean.test.ts +730 -0
- package/src/commands/clean.ts +653 -0
- package/src/commands/completions.test.ts +346 -0
- package/src/commands/completions.ts +950 -0
- package/src/commands/coordinator.test.ts +1524 -0
- package/src/commands/coordinator.ts +880 -0
- package/src/commands/costs.test.ts +1015 -0
- package/src/commands/costs.ts +473 -0
- package/src/commands/dashboard.test.ts +94 -0
- package/src/commands/dashboard.ts +607 -0
- package/src/commands/doctor.test.ts +295 -0
- package/src/commands/doctor.ts +213 -0
- package/src/commands/down.test.ts +308 -0
- package/src/commands/down.ts +124 -0
- package/src/commands/errors.test.ts +648 -0
- package/src/commands/errors.ts +255 -0
- package/src/commands/feed.test.ts +579 -0
- package/src/commands/feed.ts +368 -0
- package/src/commands/gateway.test.ts +698 -0
- package/src/commands/gateway.ts +419 -0
- package/src/commands/group.test.ts +262 -0
- package/src/commands/group.ts +539 -0
- package/src/commands/hooks.test.ts +292 -0
- package/src/commands/hooks.ts +210 -0
- package/src/commands/init.test.ts +211 -0
- package/src/commands/init.ts +622 -0
- package/src/commands/inspect.test.ts +670 -0
- package/src/commands/inspect.ts +455 -0
- package/src/commands/log.test.ts +1556 -0
- package/src/commands/log.ts +752 -0
- package/src/commands/logs.test.ts +379 -0
- package/src/commands/logs.ts +544 -0
- package/src/commands/mail.test.ts +1726 -0
- package/src/commands/mail.ts +926 -0
- package/src/commands/merge.test.ts +676 -0
- package/src/commands/merge.ts +374 -0
- package/src/commands/metrics.test.ts +444 -0
- package/src/commands/metrics.ts +150 -0
- package/src/commands/monitor.test.ts +151 -0
- package/src/commands/monitor.ts +394 -0
- package/src/commands/nudge.test.ts +230 -0
- package/src/commands/nudge.ts +373 -0
- package/src/commands/prime.test.ts +467 -0
- package/src/commands/prime.ts +386 -0
- package/src/commands/replay.test.ts +742 -0
- package/src/commands/replay.ts +367 -0
- package/src/commands/run.test.ts +443 -0
- package/src/commands/run.ts +365 -0
- package/src/commands/server.test.ts +626 -0
- package/src/commands/server.ts +298 -0
- package/src/commands/sling.test.ts +810 -0
- package/src/commands/sling.ts +700 -0
- package/src/commands/spec.test.ts +206 -0
- package/src/commands/spec.ts +171 -0
- package/src/commands/status.test.ts +276 -0
- package/src/commands/status.ts +339 -0
- package/src/commands/stop.test.ts +357 -0
- package/src/commands/stop.ts +119 -0
- package/src/commands/supervisor.test.ts +186 -0
- package/src/commands/supervisor.ts +544 -0
- package/src/commands/trace.test.ts +746 -0
- package/src/commands/trace.ts +332 -0
- package/src/commands/up.test.ts +597 -0
- package/src/commands/up.ts +275 -0
- package/src/commands/watch.test.ts +152 -0
- package/src/commands/watch.ts +238 -0
- package/src/commands/worktree.test.ts +648 -0
- package/src/commands/worktree.ts +266 -0
- package/src/config.test.ts +496 -0
- package/src/config.ts +616 -0
- package/src/doctor/agents.test.ts +448 -0
- package/src/doctor/agents.ts +396 -0
- package/src/doctor/config-check.test.ts +184 -0
- package/src/doctor/config-check.ts +185 -0
- package/src/doctor/consistency.test.ts +645 -0
- package/src/doctor/consistency.ts +294 -0
- package/src/doctor/databases.test.ts +284 -0
- package/src/doctor/databases.ts +211 -0
- package/src/doctor/dependencies.test.ts +150 -0
- package/src/doctor/dependencies.ts +179 -0
- package/src/doctor/logs.test.ts +244 -0
- package/src/doctor/logs.ts +295 -0
- package/src/doctor/merge-queue.test.ts +210 -0
- package/src/doctor/merge-queue.ts +144 -0
- package/src/doctor/structure.test.ts +285 -0
- package/src/doctor/structure.ts +195 -0
- package/src/doctor/types.ts +37 -0
- package/src/doctor/version.test.ts +130 -0
- package/src/doctor/version.ts +131 -0
- package/src/e2e/chat-flow.test.ts +346 -0
- package/src/e2e/init-sling-lifecycle.test.ts +288 -0
- package/src/errors.test.ts +21 -0
- package/src/errors.ts +246 -0
- package/src/events/store.test.ts +660 -0
- package/src/events/store.ts +344 -0
- package/src/events/tool-filter.test.ts +330 -0
- package/src/events/tool-filter.ts +126 -0
- package/src/global-setup.ts +14 -0
- package/src/index.ts +339 -0
- package/src/insights/analyzer.test.ts +466 -0
- package/src/insights/analyzer.ts +203 -0
- package/src/logging/color.test.ts +118 -0
- package/src/logging/color.ts +71 -0
- package/src/logging/logger.test.ts +812 -0
- package/src/logging/logger.ts +266 -0
- package/src/logging/reporter.test.ts +258 -0
- package/src/logging/reporter.ts +109 -0
- package/src/logging/sanitizer.test.ts +190 -0
- package/src/logging/sanitizer.ts +57 -0
- package/src/mail/broadcast.test.ts +203 -0
- package/src/mail/broadcast.ts +92 -0
- package/src/mail/client.test.ts +873 -0
- package/src/mail/client.ts +236 -0
- package/src/mail/store.test.ts +815 -0
- package/src/mail/store.ts +402 -0
- package/src/merge/queue.test.ts +449 -0
- package/src/merge/queue.ts +262 -0
- package/src/merge/resolver.test.ts +1453 -0
- package/src/merge/resolver.ts +759 -0
- package/src/metrics/store.test.ts +1167 -0
- package/src/metrics/store.ts +511 -0
- package/src/metrics/summary.test.ts +397 -0
- package/src/metrics/summary.ts +178 -0
- package/src/metrics/transcript.test.ts +643 -0
- package/src/metrics/transcript.ts +351 -0
- package/src/mulch/client.test.ts +547 -0
- package/src/mulch/client.ts +416 -0
- package/src/server/audit-store.test.ts +384 -0
- package/src/server/audit-store.ts +257 -0
- package/src/server/headless.test.ts +180 -0
- package/src/server/headless.ts +151 -0
- package/src/server/index.test.ts +241 -0
- package/src/server/index.ts +317 -0
- package/src/server/public/app.js +187 -0
- package/src/server/public/apple-touch-icon.png +0 -0
- package/src/server/public/components/agent-badge.js +37 -0
- package/src/server/public/components/data-table.js +114 -0
- package/src/server/public/components/gateway-chat.js +256 -0
- package/src/server/public/components/issue-card.js +96 -0
- package/src/server/public/components/layout.js +88 -0
- package/src/server/public/components/message-bubble.js +120 -0
- package/src/server/public/components/stat-card.js +26 -0
- package/src/server/public/components/terminal-panel.js +140 -0
- package/src/server/public/favicon-16.png +0 -0
- package/src/server/public/favicon-32.png +0 -0
- package/src/server/public/favicon.ico +0 -0
- package/src/server/public/favicon.png +0 -0
- package/src/server/public/index.html +64 -0
- package/src/server/public/lib/api.js +35 -0
- package/src/server/public/lib/markdown.js +8 -0
- package/src/server/public/lib/preact-setup.js +8 -0
- package/src/server/public/lib/state.js +99 -0
- package/src/server/public/lib/utils.js +309 -0
- package/src/server/public/lib/ws.js +79 -0
- package/src/server/public/views/chat.js +983 -0
- package/src/server/public/views/costs.js +692 -0
- package/src/server/public/views/dashboard.js +781 -0
- package/src/server/public/views/gateway-chat.js +622 -0
- package/src/server/public/views/inspect.js +399 -0
- package/src/server/public/views/issues.js +470 -0
- package/src/server/public/views/setup.js +94 -0
- package/src/server/public/views/task-detail.js +422 -0
- package/src/server/routes.test.ts +3816 -0
- package/src/server/routes.ts +1964 -0
- package/src/server/websocket.test.ts +288 -0
- package/src/server/websocket.ts +196 -0
- package/src/sessions/compat.test.ts +109 -0
- package/src/sessions/compat.ts +17 -0
- package/src/sessions/store.test.ts +969 -0
- package/src/sessions/store.ts +480 -0
- package/src/test-helpers.test.ts +97 -0
- package/src/test-helpers.ts +143 -0
- package/src/types.ts +708 -0
- package/src/watchdog/daemon.test.ts +1233 -0
- package/src/watchdog/daemon.ts +533 -0
- package/src/watchdog/health.test.ts +371 -0
- package/src/watchdog/health.ts +248 -0
- package/src/watchdog/triage.test.ts +162 -0
- package/src/watchdog/triage.ts +193 -0
- package/src/worktree/manager.test.ts +444 -0
- package/src/worktree/manager.ts +224 -0
- package/src/worktree/tmux.test.ts +1238 -0
- package/src/worktree/tmux.ts +644 -0
- package/templates/CLAUDE.md.tmpl +89 -0
- package/templates/hooks.json.tmpl +132 -0
- package/templates/overlay.md.tmpl +79 -0
package/README.md
ADDED
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
# Legio
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="assets/legio-mascot.png" alt="Legio mascot" width="400">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
[](https://github.com/katyella/legio/actions/workflows/ci.yml)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
[](https://nodejs.org)
|
|
10
|
+
[](https://github.com/katyella/legio/releases)
|
|
11
|
+
|
|
12
|
+
Built on [Overstory](https://github.com/jayminwest/overstory).
|
|
13
|
+
|
|
14
|
+
**Turn one Claude Code session into a multi-agent fleet.**
|
|
15
|
+
|
|
16
|
+
Claude Code is powerful — but it works one task at a time, sequentially. One agent, one context window, one thread of execution.
|
|
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?
|
|
23
|
+
|
|
24
|
+
**The problem:** Claude Code runs a single agent in a single session. Ten files across three subsystems means sequential work — one change at a time, in one context window, with no parallelism.
|
|
25
|
+
|
|
26
|
+
**The solution:** A fleet of specialized agents, each with its own worktree, file scope, and tmux session. A coordinator decomposes the objective. Leads break it into tasks. Builders implement. Reviewers validate. Mergers integrate. All in parallel.
|
|
27
|
+
|
|
28
|
+
**The payoff:**
|
|
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
|
|
36
|
+
|
|
37
|
+
## See It in Action
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<img src="assets/dashboard.png" alt="Legio Dashboard — real-time agent monitoring" width="800">
|
|
41
|
+
<br>
|
|
42
|
+
<em>Dashboard: live view of agent status, mail feed, merge queue, and system metrics</em>
|
|
43
|
+
</p>
|
|
44
|
+
|
|
45
|
+
<p align="center">
|
|
46
|
+
<img src="assets/gateway-chat.png" alt="Gateway Chat — conversational planning interface" width="800">
|
|
47
|
+
<br>
|
|
48
|
+
<em>Gateway Chat: natural language interface for planning and task decomposition</em>
|
|
49
|
+
</p>
|
|
50
|
+
|
|
51
|
+
<p align="center">
|
|
52
|
+
<img src="assets/inspect.png" alt="Inspect — deep per-agent inspection" width="800">
|
|
53
|
+
<br>
|
|
54
|
+
<em>Inspect: deep dive into any agent's activity, tool calls, and terminal output</em>
|
|
55
|
+
</p>
|
|
56
|
+
|
|
57
|
+
## Quick Start
|
|
58
|
+
|
|
59
|
+
The fastest way to get started:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
cd your-project
|
|
63
|
+
|
|
64
|
+
# Bootstrap everything — init, start server, open browser
|
|
65
|
+
legio up
|
|
66
|
+
|
|
67
|
+
# Verify setup is healthy
|
|
68
|
+
legio doctor
|
|
69
|
+
|
|
70
|
+
# When you're done, shut it all down
|
|
71
|
+
legio down
|
|
72
|
+
```
|
|
73
|
+
|
|
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
|
+
## How It Works
|
|
107
|
+
|
|
108
|
+
CLAUDE.md + hooks + the `legio` CLI turn your Claude Code session into a multi-agent orchestrator. A persistent coordinator agent manages task decomposition and dispatch, while a mechanical watchdog daemon monitors agent health.
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
Coordinator (persistent orchestrator at project root)
|
|
112
|
+
--> Lead (team lead, decomposes tasks, depth 1)
|
|
113
|
+
--> Workers: Scout, Builder, Reviewer, Merger (depth 2)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Agent Types
|
|
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.
|
|
162
|
+
|
|
163
|
+
## Requirements
|
|
164
|
+
|
|
165
|
+
- [Node.js](https://nodejs.org) (v22+)
|
|
166
|
+
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code)
|
|
167
|
+
- git
|
|
168
|
+
- tmux
|
|
169
|
+
- [bd (beads)](https://github.com/jayminwest/beads) — issue tracking CLI
|
|
170
|
+
- [mulch](https://github.com/jayminwest/mulch) — structured expertise management CLI
|
|
171
|
+
|
|
172
|
+
## Installation
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
npm install -g legio
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### From Source
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
git clone https://github.com/katyella/legio.git
|
|
182
|
+
cd legio
|
|
183
|
+
npm install
|
|
184
|
+
npm link
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## CLI Reference
|
|
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
|
|
375
|
+
|
|
376
|
+
legio log <event> Log a hook event (called by hooks)
|
|
377
|
+
|
|
378
|
+
Global Flags:
|
|
379
|
+
--quiet, -q Suppress non-error output
|
|
380
|
+
--completions <shell> Generate shell completions (bash, zsh, fish)
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
## REST API
|
|
384
|
+
|
|
385
|
+
When the server is running, a full REST API is available at `http://localhost:4173/api/`:
|
|
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
|
|
439
|
+
|
|
440
|
+
## Development
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
# Run core tests
|
|
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
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
## License
|
|
550
|
+
|
|
551
|
+
MIT
|
|
552
|
+
|
|
553
|
+
---
|
|
554
|
+
|
|
555
|
+
Inspired by: https://github.com/steveyegge/gastown/
|