legion-cc 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/LICENSE +21 -0
- package/README.md +269 -0
- package/VERSION +1 -0
- package/agents/legion-orchestrator.md +95 -0
- package/bin/install.js +898 -0
- package/bin/legion-tools.cjs +421 -0
- package/bin/lib/config.cjs +141 -0
- package/bin/lib/core.cjs +216 -0
- package/bin/lib/domain.cjs +107 -0
- package/bin/lib/init.cjs +184 -0
- package/bin/lib/session.cjs +140 -0
- package/bin/lib/state.cjs +280 -0
- package/commands/legion/devops/architect.md +44 -0
- package/commands/legion/devops/build.md +52 -0
- package/commands/legion/devops/cycle.md +52 -0
- package/commands/legion/devops/execute.md +52 -0
- package/commands/legion/devops/plan.md +51 -0
- package/commands/legion/devops/quick.md +45 -0
- package/commands/legion/devops/review.md +52 -0
- package/commands/legion/resume.md +52 -0
- package/commands/legion/status.md +53 -0
- package/hooks/legion-context-monitor.js +180 -0
- package/hooks/legion-statusline.js +191 -0
- package/package.json +48 -0
- package/references/agent-routing.md +64 -0
- package/references/devops/agent-map.md +61 -0
- package/references/devops/pipeline-patterns.md +87 -0
- package/references/domain-registry.md +63 -0
- package/references/ui-brand.md +102 -0
- package/templates/config.json +25 -0
- package/templates/devops/architect-output.md +28 -0
- package/templates/devops/execution-report.md +23 -0
- package/templates/devops/plan-output.md +33 -0
- package/templates/devops/review-checklist.md +35 -0
- package/templates/session.md +17 -0
- package/templates/state.md +17 -0
- package/templates/task-record.md +19 -0
- package/workflows/core/completion.md +70 -0
- package/workflows/core/context-load.md +57 -0
- package/workflows/core/init.md +52 -0
- package/workflows/devops/architect.md +91 -0
- package/workflows/devops/build.md +92 -0
- package/workflows/devops/cycle.md +237 -0
- package/workflows/devops/execute.md +118 -0
- package/workflows/devops/plan.md +108 -0
- package/workflows/devops/quick.md +107 -0
- package/workflows/devops/review.md +112 -0
- package/workflows/resume.md +88 -0
- package/workflows/status.md +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vladyslav Blackmoore
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# Legion
|
|
2
|
+
|
|
3
|
+
Multi-agent orchestration framework for Claude Code. Legion organizes specialized agents into domain-specific pipelines — architect, plan, execute, review — with state tracking, context monitoring, and session continuity across conversations.
|
|
4
|
+
|
|
5
|
+
The first domain ships with Legion: **devops** — infrastructure design, planning, execution, and review.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
**Domain-based agent pipelines**
|
|
12
|
+
Each domain defines a sequential pipeline of specialized agents. The devops domain runs: `architect → plan → execute → review`. Every stage produces a numbered artifact that feeds the next.
|
|
13
|
+
|
|
14
|
+
**Fast context-aware execution**
|
|
15
|
+
`/legion:devops:quick` reads `.codebase/` and `.planning/codebase/` before dispatching to classify and route the task to the correct agent automatically.
|
|
16
|
+
|
|
17
|
+
**State tracking across sessions**
|
|
18
|
+
All pipeline state is written to `.planning/legion/STATE.md` — current domain, stage, task history, and artifact chain. State persists between Claude Code sessions.
|
|
19
|
+
|
|
20
|
+
**Context window monitoring**
|
|
21
|
+
A `PostToolUse` hook reads context metrics after each tool call. When remaining context drops below 35%, the agent receives an in-context warning to wrap up. At 25%, it receives a critical stop directive. Warnings are debounced across tool calls and coexist safely with GSD.
|
|
22
|
+
|
|
23
|
+
**Approval checkpoints in the pipeline**
|
|
24
|
+
`/legion:devops:cycle` pauses after the architect and plan stages to show the output and ask for approval before continuing. The user can approve, request a revision, or stop and save state for later.
|
|
25
|
+
|
|
26
|
+
**Sequential artifact management**
|
|
27
|
+
Each pipeline stage writes a numbered artifact to `.planning/legion/devops/`:
|
|
28
|
+
```
|
|
29
|
+
001-architect-eks-migration.md
|
|
30
|
+
002-plan-eks-migration.md
|
|
31
|
+
003-execution-eks-migration.md
|
|
32
|
+
004-review-eks-migration.md
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Session continuity**
|
|
36
|
+
`/legion:resume` reads `STATE.md` and the latest session record, restores context, identifies where the pipeline stopped, and routes to the correct next command.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
git clone git@github.com:vladyslavblackmoore/legion.git
|
|
44
|
+
cd legion
|
|
45
|
+
chmod +x install.sh
|
|
46
|
+
./install.sh
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The installer copies commands, workflows, templates, references, and hooks into `~/.claude/`, registers the `PostToolUse` context monitor in Claude Code settings, and writes a file manifest for clean uninstalls.
|
|
50
|
+
|
|
51
|
+
**Options**
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
./install.sh --dry-run # preview what would be installed
|
|
55
|
+
./install.sh --force # overwrite existing agent files
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Uninstall**
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
./uninstall.sh
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Commands
|
|
67
|
+
|
|
68
|
+
### DevOps domain
|
|
69
|
+
|
|
70
|
+
| Command | Description |
|
|
71
|
+
|---------|-------------|
|
|
72
|
+
| `/legion:devops:quick <task>` | Classify the task and dispatch to the right agent. Reads `.codebase/` first. |
|
|
73
|
+
| `/legion:devops:architect <task>` | Design infrastructure architecture with the `devops-architect` agent (opus). |
|
|
74
|
+
| `/legion:devops:plan [path]` | Decompose architecture into an implementation plan with `delivery-planner` (sonnet). Uses latest architect artifact if no path given. |
|
|
75
|
+
| `/legion:devops:execute [path]` | Implement the plan with `infra-executor` (opus). Supports `--task T1` to run a single task. |
|
|
76
|
+
| `/legion:devops:build [path]` | Scaffold project structure and create `.codebase/` documentation with `codebase-builder` (opus). |
|
|
77
|
+
| `/legion:devops:review [path]` | Review changes against architectural intent with `devops-architect` in review mode (sonnet). |
|
|
78
|
+
| `/legion:devops:cycle <task>` | Run the full pipeline (architect → plan → execute → review) with checkpoints after architect and plan. |
|
|
79
|
+
|
|
80
|
+
### Session management
|
|
81
|
+
|
|
82
|
+
| Command | Description |
|
|
83
|
+
|---------|-------------|
|
|
84
|
+
| `/legion:status` | Show active domain, pipeline stage, task history, and last session info. |
|
|
85
|
+
| `/legion:resume` | Restore context from the previous session and route to the next pipeline stage. |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Architecture
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
legion/
|
|
93
|
+
├── agents/ # Agent definitions installed to ~/.claude/agents/
|
|
94
|
+
├── bin/ # Node.js CLI (legion-tools.cjs) — init, state, session management
|
|
95
|
+
│ └── lib/ # Modules: config, core, domain, init, session, state
|
|
96
|
+
├── commands/ # Claude Code slash commands (.md frontmatter + execution prompt)
|
|
97
|
+
│ └── legion/
|
|
98
|
+
│ ├── devops/ # /legion:devops:* commands
|
|
99
|
+
│ ├── resume.md
|
|
100
|
+
│ └── status.md
|
|
101
|
+
├── hooks/ # Claude Code hooks (Node.js)
|
|
102
|
+
│ ├── legion-context-monitor.js # PostToolUse: injects context warnings
|
|
103
|
+
│ └── legion-statusline.js # StatusLine: shows domain:stage + context bar
|
|
104
|
+
├── references/ # Reference documents read during workflow execution
|
|
105
|
+
│ ├── agent-routing.md
|
|
106
|
+
│ ├── domain-registry.md
|
|
107
|
+
│ ├── ui-brand.md
|
|
108
|
+
│ └── devops/
|
|
109
|
+
│ ├── agent-map.md
|
|
110
|
+
│ └── pipeline-patterns.md
|
|
111
|
+
├── templates/ # State, session, artifact, and config templates
|
|
112
|
+
│ └── devops/ # Artifact templates (architect, plan, execution, review)
|
|
113
|
+
├── workflows/ # Step-by-step execution logic referenced by commands
|
|
114
|
+
│ ├── core/ # init, context-load, completion (shared across domains)
|
|
115
|
+
│ └── devops/ # One workflow per command
|
|
116
|
+
├── install.sh
|
|
117
|
+
├── uninstall.sh
|
|
118
|
+
├── package.json
|
|
119
|
+
└── VERSION
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## DevOps Agents
|
|
125
|
+
|
|
126
|
+
| Agent | Role | Model | Used By |
|
|
127
|
+
|-------|------|-------|---------|
|
|
128
|
+
| `devops-architect` | Senior/Lead DevOps Architect — infrastructure design, security assessment, migration planning, HA/DR | opus (architect) / sonnet (review) | `architect`, `review`, `cycle` |
|
|
129
|
+
| `delivery-planner` | Senior Delivery Planner — work decomposition, phased planning, dependency mapping, risk assessment | sonnet | `plan`, `cycle` |
|
|
130
|
+
| `infra-executor` | Elite Infrastructure Execution Specialist — Terraform, CI/CD, Kubernetes, AWS resource management | opus | `execute`, `cycle` |
|
|
131
|
+
| `codebase-builder` | Elite Codebase Builder — project scaffolding, `.codebase/` documentation creation, existing project analysis | opus | `build` |
|
|
132
|
+
|
|
133
|
+
The `devops-architect` agent doubles as reviewer: the same agent definition is invoked with a review prompt at sonnet model for the review stage.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Pipeline
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
/legion:devops:cycle "Add ElastiCache Redis for session management"
|
|
141
|
+
|
|
142
|
+
[devops-architect] opus
|
|
143
|
+
|
|
|
144
|
+
| 001-architect-*.md
|
|
145
|
+
v
|
|
146
|
+
[checkpoint] -- revise? ------> re-run architect
|
|
147
|
+
|
|
|
148
|
+
| approve
|
|
149
|
+
v
|
|
150
|
+
[delivery-planner] sonnet
|
|
151
|
+
|
|
|
152
|
+
| 002-plan-*.md
|
|
153
|
+
v
|
|
154
|
+
[checkpoint] -- revise? ------> re-run planner
|
|
155
|
+
|
|
|
156
|
+
| approve
|
|
157
|
+
v
|
|
158
|
+
[infra-executor] opus
|
|
159
|
+
|
|
|
160
|
+
| 003-execution-*.md
|
|
161
|
+
v
|
|
162
|
+
[devops-architect (review)] sonnet
|
|
163
|
+
|
|
|
164
|
+
| 004-review-*.md
|
|
165
|
+
v
|
|
166
|
+
done
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Checkpoints default to ON after architect and plan, OFF after execute and review. This is configurable per project in `.planning/legion/config.json`.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Pipeline Patterns
|
|
174
|
+
|
|
175
|
+
**Full cycle** — new, complex infrastructure work:
|
|
176
|
+
```
|
|
177
|
+
/legion:devops:cycle "Add ElastiCache Redis for session management"
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Enter at any stage** — architecture exists, start from plan:
|
|
181
|
+
```
|
|
182
|
+
/legion:devops:plan
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Quick fix** — small, well-understood change:
|
|
186
|
+
```
|
|
187
|
+
/legion:devops:quick "Add ingress rule for port 8443 to eks-node SG"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Documentation first** — existing project without `.codebase/` docs:
|
|
191
|
+
```
|
|
192
|
+
/legion:devops:build
|
|
193
|
+
/legion:devops:architect "migration plan"
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Review only** — audit a path:
|
|
197
|
+
```
|
|
198
|
+
/legion:devops:review ./aws/modules/rds/
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Adding Domains
|
|
204
|
+
|
|
205
|
+
Legion is designed to host multiple domains. To add a new domain (e.g., `backend`):
|
|
206
|
+
|
|
207
|
+
1. Create commands at `commands/legion/{domain}/` — one `.md` file per pipeline stage
|
|
208
|
+
2. Create workflows at `workflows/{domain}/` — one `.md` file per command
|
|
209
|
+
3. Create templates at `templates/{domain}/` — artifact output templates
|
|
210
|
+
4. Create references at `references/{domain}/` — `agent-map.md` and `pipeline-patterns.md`
|
|
211
|
+
5. Define agents in `agents/` and register them in `references/{domain}/agent-map.md`
|
|
212
|
+
6. Add the domain entry to `references/domain-registry.md`
|
|
213
|
+
7. Run `./install.sh` to deploy
|
|
214
|
+
|
|
215
|
+
Each domain must define: pipeline stages (ordered), agent mapping (stage to agent), model assignment, and classification rules for its `/quick` command.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Project Structure (installed)
|
|
220
|
+
|
|
221
|
+
After installation, Legion lives inside `~/.claude/`:
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
~/.claude/
|
|
225
|
+
├── commands/legion/ # Slash commands
|
|
226
|
+
│ ├── resume.md
|
|
227
|
+
│ ├── status.md
|
|
228
|
+
│ └── devops/
|
|
229
|
+
├── hooks/
|
|
230
|
+
│ ├── legion-context-monitor.js
|
|
231
|
+
│ └── legion-statusline.js
|
|
232
|
+
├── agents/
|
|
233
|
+
│ ├── devops-architect.md
|
|
234
|
+
│ ├── delivery-planner.md
|
|
235
|
+
│ ├── infra-executor.md
|
|
236
|
+
│ ├── codebase-builder.md
|
|
237
|
+
│ └── legion-orchestrator.md
|
|
238
|
+
└── legion/
|
|
239
|
+
├── bin/
|
|
240
|
+
├── workflows/
|
|
241
|
+
├── templates/
|
|
242
|
+
├── references/
|
|
243
|
+
└── VERSION
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Per-project state is written alongside your code:
|
|
247
|
+
|
|
248
|
+
```
|
|
249
|
+
{project}/
|
|
250
|
+
└── .planning/
|
|
251
|
+
└── legion/
|
|
252
|
+
├── STATE.md
|
|
253
|
+
├── config.json
|
|
254
|
+
├── sessions/
|
|
255
|
+
└── devops/ # Numbered artifacts
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Requirements
|
|
261
|
+
|
|
262
|
+
- [Claude Code](https://claude.ai/download) installed and configured (`~/.claude/` must exist)
|
|
263
|
+
- Node.js >= 18
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## License
|
|
268
|
+
|
|
269
|
+
MIT
|
package/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.0
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legion-orchestrator
|
|
3
|
+
description: "Legion meta-agent for task classification and agent routing. Used by /legion:devops:quick to analyze tasks and dispatch to the right specialized agent."
|
|
4
|
+
model: sonnet
|
|
5
|
+
color: blue
|
|
6
|
+
memory: user
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Legion Orchestrator
|
|
10
|
+
|
|
11
|
+
You are the Legion Orchestrator — a lightweight routing agent that analyzes incoming tasks and determines which specialized agent should handle them.
|
|
12
|
+
|
|
13
|
+
## Core Role
|
|
14
|
+
|
|
15
|
+
You do NOT execute tasks yourself. You:
|
|
16
|
+
1. Analyze the task description
|
|
17
|
+
2. Load project context (.codebase/, .planning/)
|
|
18
|
+
3. Classify the task type
|
|
19
|
+
4. Recommend the appropriate agent and provide context for spawning
|
|
20
|
+
|
|
21
|
+
## Classification Rules
|
|
22
|
+
|
|
23
|
+
Analyze the task and classify into one of these categories:
|
|
24
|
+
|
|
25
|
+
### architecture
|
|
26
|
+
**Agent**: devops-architect (opus)
|
|
27
|
+
**Triggers**: Design decisions, technology evaluation, migration strategy, HA/DR planning, security architecture, infrastructure design, capacity planning, comparing options
|
|
28
|
+
**Keywords**: design, architect, propose, evaluate, strategy, migration, HA, DR, compare options, should we use, how to design
|
|
29
|
+
|
|
30
|
+
### planning
|
|
31
|
+
**Agent**: delivery-planner (sonnet)
|
|
32
|
+
**Triggers**: Breaking down work, creating implementation plans, task decomposition, phased rollout planning, dependency analysis
|
|
33
|
+
**Keywords**: plan, decompose, break down, create tasks, implementation plan, phases, rollout, what steps, how to implement
|
|
34
|
+
|
|
35
|
+
### execution
|
|
36
|
+
**Agent**: infra-executor (opus)
|
|
37
|
+
**Triggers**: Writing Terraform code, modifying infrastructure, fixing configs, updating pipelines, creating AWS resources, changing security groups
|
|
38
|
+
**Keywords**: implement, create, add, write, fix, update, change, terraform, pipeline, module, resource, deploy, configure
|
|
39
|
+
|
|
40
|
+
### build
|
|
41
|
+
**Agent**: codebase-builder (opus)
|
|
42
|
+
**Triggers**: New project setup, scaffolding, creating .codebase/ documentation, initializing project structure
|
|
43
|
+
**Keywords**: scaffold, init, setup, create project, new project, .codebase/, document structure, bootstrap
|
|
44
|
+
|
|
45
|
+
### review
|
|
46
|
+
**Agent**: devops-architect (sonnet, review mode)
|
|
47
|
+
**Triggers**: Code review, security audit, architecture validation, compliance check, best practices review
|
|
48
|
+
**Keywords**: review, audit, check, validate, security review, compliance, best practices
|
|
49
|
+
|
|
50
|
+
## Classification Process
|
|
51
|
+
|
|
52
|
+
1. Read the task description carefully
|
|
53
|
+
2. Identify primary intent (what does the user want to ACHIEVE?)
|
|
54
|
+
3. Match against classification rules above
|
|
55
|
+
4. If ambiguous between two categories:
|
|
56
|
+
- Prefer the more specific one
|
|
57
|
+
- If still unclear, state both options and ask the user
|
|
58
|
+
5. NEVER guess — if truly unclear, ask
|
|
59
|
+
|
|
60
|
+
## Output Format
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"classification": "execution",
|
|
65
|
+
"confidence": "high",
|
|
66
|
+
"agent": "infra-executor",
|
|
67
|
+
"model": "opus",
|
|
68
|
+
"reasoning": "Task asks to add a security group rule — this is a direct infrastructure change",
|
|
69
|
+
"context_needed": ["current security group config", "VPC CIDR ranges"],
|
|
70
|
+
"task_summary": "Add ingress rule for port 8443 to eks-node security group"
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Rules
|
|
75
|
+
|
|
76
|
+
- You are a ROUTER, not an executor
|
|
77
|
+
- Classify quickly — don't over-analyze
|
|
78
|
+
- If the task is simple and clear, route immediately
|
|
79
|
+
- If the task is complex, it might need the full cycle (/legion:devops:cycle)
|
|
80
|
+
- Always consider project context when classifying
|
|
81
|
+
- MCP tools are mandatory for context gathering
|
|
82
|
+
- If unsure, say "я не знаю" and ask the user
|
|
83
|
+
|
|
84
|
+
## Agent Memory
|
|
85
|
+
|
|
86
|
+
You have persistent memory at `/Users/explorer/.claude/agent-memory/legion-orchestrator/`.
|
|
87
|
+
|
|
88
|
+
### What to Remember
|
|
89
|
+
- Common task patterns and their correct classifications
|
|
90
|
+
- Project-specific routing preferences
|
|
91
|
+
- Classification mistakes and corrections
|
|
92
|
+
|
|
93
|
+
### What NOT to Remember
|
|
94
|
+
- Individual task details
|
|
95
|
+
- Session-specific context
|