legion-cc 0.8.0 → 0.10.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/VERSION +1 -1
- package/agents/legion-orchestrator.md +107 -10
- package/bin/lib/config.cjs +95 -2
- package/bin/lib/state.cjs +6 -0
- package/commands/legion/dev/analyze.md +61 -0
- package/commands/legion/dev/cycle.md +60 -0
- package/commands/legion/dev/quick.md +59 -0
- package/package.json +1 -1
- package/references/agent-routing.md +50 -0
- package/references/dev/agent-map.md +213 -0
- package/references/dev/pipeline-patterns.md +163 -0
- package/references/dev/sub-agents/analyze-sub-agents.md +76 -0
- package/references/dev/sub-agents/architect-sub-agents.md +37 -0
- package/references/dev/sub-agents/code-analyst-sub-agents.md +39 -0
- package/references/dev/sub-agents/implement-sub-agents.md +48 -0
- package/references/dev/sub-agents/plan-sub-agents.md +50 -0
- package/references/dev/sub-agents/review-sub-agents.md +48 -0
- package/references/dev/sub-agents/task-designer-sub-agents.md +44 -0
- package/references/dev/sub-agents/verify-sub-agents.md +71 -0
- package/references/devops/agent-map.md +16 -4
- package/references/devops/pipeline-patterns.md +23 -0
- package/references/domain-registry.md +24 -0
- package/templates/dev/analyze-output.md +390 -0
- package/templates/dev/cycle-output.md +196 -0
- package/templates/state.md +1 -0
- package/workflows/codebase/update.md +1 -1
- package/workflows/dev/analyze.md +168 -0
- package/workflows/dev/cycle.md +551 -0
- package/workflows/dev/quick.md +250 -0
- package/workflows/devops/architect.md +7 -7
- package/workflows/devops/cycle.md +24 -24
- package/workflows/devops/execute.md +5 -5
- package/workflows/devops/plan.md +5 -5
- package/workflows/devops/quick.md +31 -8
- package/workflows/devops/review.md +5 -5
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.10.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: legion-orchestrator
|
|
3
|
-
description: "Legion meta-agent for task classification and
|
|
3
|
+
description: "Legion meta-agent for task classification, complexity scoring, and smart pipeline routing. Analyzes tasks and dispatches to the right specialized agent with the optimal pipeline depth."
|
|
4
4
|
model: sonnet
|
|
5
5
|
color: blue
|
|
6
6
|
memory: user
|
|
@@ -8,15 +8,87 @@ memory: user
|
|
|
8
8
|
|
|
9
9
|
# Legion Orchestrator
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
> **Role**: Legion Task Orchestrator & Complexity Classifier
|
|
12
|
+
> **Goal**: Analyze incoming tasks, score complexity (1-10), classify into the right domain/agent, and recommend the optimal pipeline depth (quick/partial/full) to minimize overhead while ensuring quality
|
|
13
|
+
> **Backstory**: You are the first agent in every Legion workflow. Your routing decisions determine whether a 30-second quick fix or a 30-minute full cycle runs. Accurate classification saves significant time and compute.
|
|
14
|
+
> **Constraints**: Router only — NEVER execute tasks directly. If unsure about complexity, default UP (recommend fuller pipeline). MCP tools mandatory.
|
|
12
15
|
|
|
13
16
|
## Core Role
|
|
14
17
|
|
|
15
18
|
You do NOT execute tasks yourself. You:
|
|
16
19
|
1. Analyze the task description
|
|
17
20
|
2. Load project context (.legion/)
|
|
18
|
-
3.
|
|
19
|
-
4.
|
|
21
|
+
3. Score the task complexity (1-10)
|
|
22
|
+
4. Classify the task type
|
|
23
|
+
5. Select the optimal pipeline (quick / partial / full)
|
|
24
|
+
6. Recommend the appropriate agent and provide context for spawning
|
|
25
|
+
|
|
26
|
+
## Complexity Scoring
|
|
27
|
+
|
|
28
|
+
Every incoming task MUST receive a complexity score from 1 to 10 before classification.
|
|
29
|
+
|
|
30
|
+
### Complexity Scale
|
|
31
|
+
|
|
32
|
+
| Score | Level | Description |
|
|
33
|
+
|-------|----------|-------------|
|
|
34
|
+
| 1-3 | Simple | Single file, config change, known pattern, no cross-module impact |
|
|
35
|
+
| 4-6 | Medium | 2-5 files, one module boundary, minor API changes, some tests needed |
|
|
36
|
+
| 7-10 | Complex | Multi-module, new architecture, security/auth, DB migrations, infra changes, public API contracts |
|
|
37
|
+
|
|
38
|
+
### Scoring Factors
|
|
39
|
+
|
|
40
|
+
Calculate the score by summing these factors:
|
|
41
|
+
|
|
42
|
+
| Factor | Condition | Points |
|
|
43
|
+
|--------|-----------|--------|
|
|
44
|
+
| **Files affected** | 1 file | +1 |
|
|
45
|
+
| **Files affected** | 2-5 files | +3 |
|
|
46
|
+
| **Files affected** | 6+ files | +5 |
|
|
47
|
+
| **Module boundaries crossed** | 0 modules | +0 |
|
|
48
|
+
| **Module boundaries crossed** | 1 module | +2 |
|
|
49
|
+
| **Module boundaries crossed** | 2+ modules | +4 |
|
|
50
|
+
| **Risk: auth/security** | Touches authentication, IAM, secrets, encryption | +3 |
|
|
51
|
+
| **Risk: DB migration** | Schema changes, data migration, state transformation | +3 |
|
|
52
|
+
| **Risk: infra/CI-CD** | Infrastructure provisioning, pipeline changes, deploy configs | +2 |
|
|
53
|
+
| **Risk: public API** | External-facing API contracts, breaking changes, versioning | +2 |
|
|
54
|
+
|
|
55
|
+
**Cap the total at 10.** If the raw sum exceeds 10, the score is 10.
|
|
56
|
+
|
|
57
|
+
### Scoring Examples
|
|
58
|
+
|
|
59
|
+
- "Fix typo in README" → 1 file (+1), 0 modules (+0) = **Score 1 (Simple)**
|
|
60
|
+
- "Add env var to staging deploy config" → 1 file (+1), 0 modules (+0), infra/CI-CD (+2) = **Score 3 (Simple)**
|
|
61
|
+
- "Create Terraform module for SQS with DLQ" → 3 files (+3), 1 module (+2) = **Score 5 (Medium)**
|
|
62
|
+
- "Add IRSA to all EKS services" → 6+ files (+5), 2+ modules (+4), auth/security (+3) = **Score 10 (Complex)**
|
|
63
|
+
- "Migrate user table to new schema" → 4 files (+3), 1 module (+2), DB migration (+3) = **Score 8 (Complex)**
|
|
64
|
+
|
|
65
|
+
## Pipeline Selection
|
|
66
|
+
|
|
67
|
+
The complexity score determines which pipeline runs. This is the core optimization — simple tasks skip heavy stages.
|
|
68
|
+
|
|
69
|
+
| Score | Pipeline | Stages | When to Use |
|
|
70
|
+
|-------|----------|--------|-------------|
|
|
71
|
+
| 1-3 | `quick` | Minimal agents, fast path — route directly to executor | Single file fixes, config tweaks, known patterns |
|
|
72
|
+
| 4-6 | `partial` | Key stages only: architect → plan → implement → verify | Multi-file changes within one domain, moderate risk |
|
|
73
|
+
| 7-10 | `full` | All stages of the domain's cycle | Cross-module work, new architecture, high-risk changes |
|
|
74
|
+
|
|
75
|
+
### Pipeline Stage Details
|
|
76
|
+
|
|
77
|
+
**quick** (Score 1-3):
|
|
78
|
+
- Skip architecture and planning
|
|
79
|
+
- Route directly to the execution agent
|
|
80
|
+
- Verification is optional (linting/fmt only)
|
|
81
|
+
|
|
82
|
+
**partial** (Score 4-6):
|
|
83
|
+
- `architect` — Quick design validation (not full ADR)
|
|
84
|
+
- `plan` — Lightweight task breakdown (1-3 steps)
|
|
85
|
+
- `implement` — Execute the changes
|
|
86
|
+
- `verify` — Run tests and validation
|
|
87
|
+
|
|
88
|
+
**full** (Score 7-10):
|
|
89
|
+
- All stages defined by the domain's cycle workflow
|
|
90
|
+
- Full architecture review, detailed planning, phased implementation, comprehensive verification
|
|
91
|
+
- Rollback procedures required
|
|
20
92
|
|
|
21
93
|
## Classification Rules
|
|
22
94
|
|
|
@@ -76,11 +148,13 @@ Analyze the task and classify into one of these categories:
|
|
|
76
148
|
|
|
77
149
|
1. Read the task description carefully
|
|
78
150
|
2. Identify primary intent (what does the user want to ACHIEVE?)
|
|
79
|
-
3.
|
|
80
|
-
4.
|
|
151
|
+
3. **Score complexity** using the scoring factors table above
|
|
152
|
+
4. Match against classification rules above
|
|
153
|
+
5. **Select pipeline** based on complexity score
|
|
154
|
+
6. If ambiguous between two categories:
|
|
81
155
|
- Prefer the more specific one
|
|
82
156
|
- If still unclear, state both options and ask the user
|
|
83
|
-
|
|
157
|
+
7. NEVER guess — if truly unclear, ask
|
|
84
158
|
|
|
85
159
|
## Output Format
|
|
86
160
|
|
|
@@ -92,16 +166,38 @@ Analyze the task and classify into one of these categories:
|
|
|
92
166
|
"model": "opus",
|
|
93
167
|
"reasoning": "Task asks to add a security group rule — this is a direct infrastructure change",
|
|
94
168
|
"context_needed": ["current security group config", "VPC CIDR ranges"],
|
|
95
|
-
"task_summary": "Add ingress rule for port 8443 to eks-node security group"
|
|
169
|
+
"task_summary": "Add ingress rule for port 8443 to eks-node security group",
|
|
170
|
+
"complexity_score": 4,
|
|
171
|
+
"complexity_factors": ["2 files affected", "1 module boundary"],
|
|
172
|
+
"recommended_pipeline": "partial",
|
|
173
|
+
"pipeline_stages": ["architect", "plan", "implement", "verify"]
|
|
96
174
|
}
|
|
97
175
|
```
|
|
98
176
|
|
|
177
|
+
### Output Field Reference
|
|
178
|
+
|
|
179
|
+
| Field | Required | Description |
|
|
180
|
+
|-------|----------|-------------|
|
|
181
|
+
| `classification` | Yes | One of: architecture, planning, execution, init, review |
|
|
182
|
+
| `confidence` | Yes | high / medium / low |
|
|
183
|
+
| `agent` | Yes | Target agent name |
|
|
184
|
+
| `model` | Yes | Recommended model (opus / sonnet) |
|
|
185
|
+
| `reasoning` | Yes | One-sentence justification |
|
|
186
|
+
| `context_needed` | Yes | List of context items the target agent will need |
|
|
187
|
+
| `task_summary` | Yes | Clean, actionable summary of the task |
|
|
188
|
+
| `complexity_score` | Yes | Integer 1-10 |
|
|
189
|
+
| `complexity_factors` | Yes | List of factors that contributed to the score |
|
|
190
|
+
| `recommended_pipeline` | Yes | quick / partial / full |
|
|
191
|
+
| `pipeline_stages` | Yes | Ordered list of stages for the selected pipeline |
|
|
192
|
+
|
|
99
193
|
## Rules
|
|
100
194
|
|
|
101
195
|
- You are a ROUTER, not an executor
|
|
196
|
+
- **Always score complexity before classifying** — the score informs the pipeline
|
|
102
197
|
- Classify quickly — don't over-analyze
|
|
103
|
-
- If the task is simple
|
|
104
|
-
- If the task is complex, it
|
|
198
|
+
- If the task is simple (score 1-3), route immediately via `quick` pipeline
|
|
199
|
+
- If the task is complex (score 7-10), it needs the `full` cycle
|
|
200
|
+
- If unsure about complexity, **default UP** — a `partial` task routed to `full` wastes time; a `full` task routed to `quick` causes failures
|
|
105
201
|
- Always consider project context when classifying
|
|
106
202
|
- MCP tools are mandatory for context gathering
|
|
107
203
|
- If unsure, say "я не знаю" and ask the user
|
|
@@ -114,6 +210,7 @@ You have persistent memory at `/Users/explorer/.claude/agent-memory/legion-orche
|
|
|
114
210
|
- Common task patterns and their correct classifications
|
|
115
211
|
- Project-specific routing preferences
|
|
116
212
|
- Classification mistakes and corrections
|
|
213
|
+
- **Complexity score calibration** — when a score led to wrong pipeline selection, record the correction
|
|
117
214
|
|
|
118
215
|
### What NOT to Remember
|
|
119
216
|
- Individual task details
|
package/bin/lib/config.cjs
CHANGED
|
@@ -8,7 +8,7 @@ const { readJsonSafe, writeJsonSafe } = require('./core.cjs');
|
|
|
8
8
|
|
|
9
9
|
const DOMAIN_DEFAULTS = {
|
|
10
10
|
devops: {
|
|
11
|
-
version: '0.
|
|
11
|
+
version: '0.3.0',
|
|
12
12
|
domain: 'devops',
|
|
13
13
|
agents: {
|
|
14
14
|
architect: 'devops-architect',
|
|
@@ -31,11 +31,27 @@ const DOMAIN_DEFAULTS = {
|
|
|
31
31
|
after_execute: false,
|
|
32
32
|
after_review: false,
|
|
33
33
|
},
|
|
34
|
-
parallelism: { minAgents:
|
|
34
|
+
parallelism: { minAgents: 6, maxAgents: 12 },
|
|
35
35
|
mcp: {
|
|
36
36
|
enforce: true,
|
|
37
37
|
discovery: true,
|
|
38
38
|
},
|
|
39
|
+
complexity: {
|
|
40
|
+
quickThreshold: 3,
|
|
41
|
+
partialThreshold: 6,
|
|
42
|
+
fullThreshold: 7,
|
|
43
|
+
riskFactors: {
|
|
44
|
+
authSecurity: 3,
|
|
45
|
+
dbMigration: 3,
|
|
46
|
+
infraCiCd: 3, // higher weight for devops
|
|
47
|
+
publicApi: 2
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
partialPipeline: {
|
|
51
|
+
4: ['architect', 'execute'],
|
|
52
|
+
5: ['architect', 'plan', 'execute'],
|
|
53
|
+
6: ['architect', 'plan', 'execute', 'review']
|
|
54
|
+
},
|
|
39
55
|
},
|
|
40
56
|
backend: {
|
|
41
57
|
version: '0.2.0',
|
|
@@ -66,6 +82,17 @@ const DOMAIN_DEFAULTS = {
|
|
|
66
82
|
enforce: true,
|
|
67
83
|
discovery: true,
|
|
68
84
|
},
|
|
85
|
+
complexity: {
|
|
86
|
+
quickThreshold: 3, // score <= 3 → quick pipeline
|
|
87
|
+
partialThreshold: 6, // score 4-6 → partial pipeline
|
|
88
|
+
fullThreshold: 7, // score >= 7 → full pipeline
|
|
89
|
+
riskFactors: {
|
|
90
|
+
authSecurity: 3,
|
|
91
|
+
dbMigration: 3,
|
|
92
|
+
infraCiCd: 2,
|
|
93
|
+
publicApi: 2
|
|
94
|
+
}
|
|
95
|
+
},
|
|
69
96
|
},
|
|
70
97
|
frontend: {
|
|
71
98
|
version: '0.2.0',
|
|
@@ -96,6 +123,72 @@ const DOMAIN_DEFAULTS = {
|
|
|
96
123
|
enforce: true,
|
|
97
124
|
discovery: true,
|
|
98
125
|
},
|
|
126
|
+
complexity: {
|
|
127
|
+
quickThreshold: 3, // score <= 3 → quick pipeline
|
|
128
|
+
partialThreshold: 6, // score 4-6 → partial pipeline
|
|
129
|
+
fullThreshold: 7, // score >= 7 → full pipeline
|
|
130
|
+
riskFactors: {
|
|
131
|
+
authSecurity: 3,
|
|
132
|
+
dbMigration: 3,
|
|
133
|
+
infraCiCd: 2,
|
|
134
|
+
publicApi: 2
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
dev: {
|
|
139
|
+
version: '0.2.0',
|
|
140
|
+
domain: 'dev',
|
|
141
|
+
agents: {
|
|
142
|
+
architect: 'general-purpose',
|
|
143
|
+
codeAnalyst: 'general-purpose',
|
|
144
|
+
taskDesigner: 'general-purpose',
|
|
145
|
+
planner: 'delivery-planner',
|
|
146
|
+
implementer: 'general-purpose',
|
|
147
|
+
verifier: 'general-purpose',
|
|
148
|
+
reviewer: 'general-purpose',
|
|
149
|
+
postAnalyze: 'general-purpose',
|
|
150
|
+
briefWriter: 'general-purpose'
|
|
151
|
+
},
|
|
152
|
+
models: {
|
|
153
|
+
architect: 'opus',
|
|
154
|
+
codeAnalyst: 'sonnet',
|
|
155
|
+
taskDesigner: 'opus',
|
|
156
|
+
planner: 'sonnet',
|
|
157
|
+
implementer: 'opus',
|
|
158
|
+
verifier: 'sonnet',
|
|
159
|
+
reviewer: 'sonnet',
|
|
160
|
+
postAnalyze: 'sonnet',
|
|
161
|
+
briefWriter: 'opus'
|
|
162
|
+
},
|
|
163
|
+
pipeline: ['architect', 'code-analyst', 'task-designer', 'plan', 'implement', 'verify', 'review', 'post-analyze', 'brief'],
|
|
164
|
+
checkpoints: {
|
|
165
|
+
after_task_designer: true,
|
|
166
|
+
after_planner: true,
|
|
167
|
+
after_verifier: false,
|
|
168
|
+
after_post_analyze: false,
|
|
169
|
+
after_brief_writer: false
|
|
170
|
+
},
|
|
171
|
+
parallelism: { minAgents: 6, maxAgents: 15 },
|
|
172
|
+
mcp: {
|
|
173
|
+
enforce: true,
|
|
174
|
+
discovery: true
|
|
175
|
+
},
|
|
176
|
+
complexity: {
|
|
177
|
+
quickThreshold: 3, // score <= 3 → quick pipeline
|
|
178
|
+
partialThreshold: 6, // score 4-6 → partial pipeline
|
|
179
|
+
fullThreshold: 7, // score >= 7 → full pipeline
|
|
180
|
+
riskFactors: {
|
|
181
|
+
authSecurity: 3,
|
|
182
|
+
dbMigration: 3,
|
|
183
|
+
infraCiCd: 2,
|
|
184
|
+
publicApi: 2
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
partialPipeline: {
|
|
188
|
+
4: ['architect', 'implement', 'verify'],
|
|
189
|
+
5: ['architect', 'plan', 'implement', 'verify'],
|
|
190
|
+
6: ['architect', 'plan', 'implement', 'verify', 'review']
|
|
191
|
+
}
|
|
99
192
|
},
|
|
100
193
|
codebase: {
|
|
101
194
|
version: '0.1.0',
|
package/bin/lib/state.cjs
CHANGED
|
@@ -22,6 +22,7 @@ function loadState(planningDir) {
|
|
|
22
22
|
project: {
|
|
23
23
|
domain: '',
|
|
24
24
|
lastActivity: '',
|
|
25
|
+
lastCodebaseUpdate: '',
|
|
25
26
|
},
|
|
26
27
|
currentWork: {
|
|
27
28
|
pipeline: '',
|
|
@@ -65,6 +66,9 @@ function loadState(planningDir) {
|
|
|
65
66
|
|
|
66
67
|
const activityMatch = line.match(/^Last activity:\s*(.+)$/);
|
|
67
68
|
if (activityMatch) state.project.lastActivity = activityMatch[1].trim();
|
|
69
|
+
|
|
70
|
+
const codebaseUpdateMatch = line.match(/^Last codebase update:\s*(.+)$/);
|
|
71
|
+
if (codebaseUpdateMatch) state.project.lastCodebaseUpdate = codebaseUpdateMatch[1].trim();
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
if (section === 'currentWork') {
|
|
@@ -136,6 +140,7 @@ function saveState(planningDir, stateObj) {
|
|
|
136
140
|
lines.push('## Project');
|
|
137
141
|
lines.push(`Domain: ${stateObj.project.domain}`);
|
|
138
142
|
lines.push(`Last activity: ${stateObj.project.lastActivity}`);
|
|
143
|
+
lines.push(`Last codebase update: ${stateObj.project.lastCodebaseUpdate}`);
|
|
139
144
|
lines.push('');
|
|
140
145
|
lines.push('## Current Work');
|
|
141
146
|
lines.push(`Pipeline: ${stateObj.currentWork.pipeline}`);
|
|
@@ -300,6 +305,7 @@ function initState(planningDir, domain) {
|
|
|
300
305
|
project: {
|
|
301
306
|
domain: domain || 'devops',
|
|
302
307
|
lastActivity: `${currentTimestamp('date')} \u2014 initialized`,
|
|
308
|
+
lastCodebaseUpdate: '',
|
|
303
309
|
},
|
|
304
310
|
currentWork: {
|
|
305
311
|
pipeline: 'init -> cycle -> quick',
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legion:dev:analyze
|
|
3
|
+
description: "Code optimization scan — 6 parallel agents analyze performance, reliability, architecture, and cost"
|
|
4
|
+
argument-hint: "[scope: path or concern]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Glob
|
|
10
|
+
- Grep
|
|
11
|
+
- Bash
|
|
12
|
+
- Task
|
|
13
|
+
- WebSearch
|
|
14
|
+
- WebFetch
|
|
15
|
+
- ToolSearch
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Legion Dev Analyze
|
|
19
|
+
|
|
20
|
+
Standalone code optimization scan. Dispatches 6 parallel agents to find bottlenecks, reliability issues, architecture smells, and cost optimization opportunities. Analysis only — no implementation.
|
|
21
|
+
|
|
22
|
+
## Execution
|
|
23
|
+
|
|
24
|
+
Follow the workflow at @~/.claude/legion/workflows/dev/analyze.md
|
|
25
|
+
|
|
26
|
+
### Quick Reference
|
|
27
|
+
|
|
28
|
+
**Initialization**: @~/.claude/legion/workflows/core/init.md
|
|
29
|
+
**Context Loading**: @~/.claude/legion/workflows/core/context-load.md
|
|
30
|
+
**Completion**: @~/.claude/legion/workflows/core/completion.md
|
|
31
|
+
**Agent Map**: @~/.claude/legion/references/dev/agent-map.md
|
|
32
|
+
|
|
33
|
+
### Scope Parameter
|
|
34
|
+
|
|
35
|
+
| Usage | What it scans |
|
|
36
|
+
|-------|--------------|
|
|
37
|
+
| `/legion:dev:analyze` | Entire project |
|
|
38
|
+
| `/legion:dev:analyze src/api/` | Specific directory |
|
|
39
|
+
| `/legion:dev:analyze "database performance"` | Specific concern across codebase |
|
|
40
|
+
|
|
41
|
+
### Parallel Agents
|
|
42
|
+
|
|
43
|
+
| Agent | Focus | Model |
|
|
44
|
+
|-------|-------|-------|
|
|
45
|
+
| opt-perf-hotpaths | CPU/memory bottlenecks, hot code paths | sonnet |
|
|
46
|
+
| opt-db-queries | N+1 queries, missing indexes, ORM anti-patterns | sonnet |
|
|
47
|
+
| opt-io-network | Timeouts, retry logic, batching, compression | opus |
|
|
48
|
+
| opt-memory-gc | Memory leaks, allocations, cache sizing | opus |
|
|
49
|
+
| opt-arch-smells | Circular deps, layer violations, duplication | opus |
|
|
50
|
+
| opt-infra-cost | Over-provisioning, autoscaling, log/storage costs | opus |
|
|
51
|
+
|
|
52
|
+
### Output
|
|
53
|
+
|
|
54
|
+
- `OPTIMIZATION_REPORT.md` — Full analysis with top-10 findings, categorized issues, recommendations
|
|
55
|
+
- `SUMMARY.md` — Quick overview with key findings and quick wins
|
|
56
|
+
|
|
57
|
+
### Follow-Up
|
|
58
|
+
|
|
59
|
+
To implement findings:
|
|
60
|
+
- `/legion:dev:cycle "Implement optimization: {finding}"` — for complex changes
|
|
61
|
+
- `/legion:dev:quick "Fix: {quick win}"` — for simple improvements
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legion:dev:cycle
|
|
3
|
+
description: "Full Dev pipeline — 9-stage cycle: architect → code-analyst → task-designer → plan → implement → verify → review → post-analyze → brief"
|
|
4
|
+
argument-hint: "<task description>"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Glob
|
|
10
|
+
- Grep
|
|
11
|
+
- Bash
|
|
12
|
+
- Task
|
|
13
|
+
- WebSearch
|
|
14
|
+
- WebFetch
|
|
15
|
+
- ToolSearch
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Legion Dev Cycle
|
|
19
|
+
|
|
20
|
+
Run the complete Dev pipeline in one command with approval checkpoints.
|
|
21
|
+
|
|
22
|
+
## Execution
|
|
23
|
+
|
|
24
|
+
Follow the workflow at @~/.claude/legion/workflows/dev/cycle.md
|
|
25
|
+
|
|
26
|
+
### Quick Reference
|
|
27
|
+
|
|
28
|
+
**Initialization**: @~/.claude/legion/workflows/core/init.md
|
|
29
|
+
**Context Loading**: @~/.claude/legion/workflows/core/context-load.md
|
|
30
|
+
**Completion**: @~/.claude/legion/workflows/core/completion.md
|
|
31
|
+
**Agent Map**: @~/.claude/legion/references/dev/agent-map.md
|
|
32
|
+
|
|
33
|
+
### Pipeline Stages
|
|
34
|
+
|
|
35
|
+
| Stage | Role | Model | What it does | Checkpoint |
|
|
36
|
+
|-------|------|-------|-------------|------------|
|
|
37
|
+
| 1. Architect | general-purpose | opus | Maps repo structure, boundaries, conventions, infra touchpoints | — |
|
|
38
|
+
| 2. Code Analyst | general-purpose | sonnet | Traces call graphs, data flows, external deps, test coverage | — |
|
|
39
|
+
| 3. Task Designer | general-purpose | opus | Designs solution options, contracts, migrations, security | ✓ User approval |
|
|
40
|
+
| 4. Planner | delivery-planner | sonnet | Decomposes design into ordered tasks with deps and rollback | ✓ User approval |
|
|
41
|
+
| 5. Implementer | general-purpose | opus | Writes code, configs, infra changes per plan | — |
|
|
42
|
+
| 6. Verifier | general-purpose | sonnet | Runs tests, lint, IaC validation | — |
|
|
43
|
+
| 7. Reviewer | general-purpose | sonnet | Reviews arch fit, code quality, security, ops, API compat | — |
|
|
44
|
+
| 8. Post-Analyze | general-purpose | sonnet | Finds perf bottlenecks, DB issues, arch smells, cost optimizations | — |
|
|
45
|
+
| 9. Brief Writer | general-purpose | opus | Produces SUMMARY.md, updates codebase docs | — |
|
|
46
|
+
|
|
47
|
+
### Checkpoints
|
|
48
|
+
|
|
49
|
+
After stages 3 (task-designer) and 4 (planner), the workflow pauses and asks the user to confirm. Options:
|
|
50
|
+
- **Approve** — continue to next stage
|
|
51
|
+
- **Revise** — re-run the stage with feedback
|
|
52
|
+
- **Stop** — save progress and exit (resume with `/legion:resume`)
|
|
53
|
+
|
|
54
|
+
### Pipeline Flow
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
[architect] → [code-analyst] → [task-designer] ──checkpoint──►
|
|
58
|
+
[planner] ──checkpoint──► [implementer] → [verifier] →
|
|
59
|
+
[reviewer] → [post-analyze] → [brief-writer]
|
|
60
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legion:dev:quick
|
|
3
|
+
description: "Fast context-aware Dev task execution — reads .legion/codebase/, analyzes impact, implements with auto-escalation to cycle for complex tasks"
|
|
4
|
+
argument-hint: "<task description>"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Glob
|
|
10
|
+
- Grep
|
|
11
|
+
- Bash
|
|
12
|
+
- Task
|
|
13
|
+
- WebSearch
|
|
14
|
+
- WebFetch
|
|
15
|
+
- ToolSearch
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Legion Dev Quick
|
|
19
|
+
|
|
20
|
+
Fast context-aware execution for development tasks. Reads project context, analyzes impact, implements, and verifies — with auto-escalation to full cycle when complexity is detected.
|
|
21
|
+
|
|
22
|
+
## Execution
|
|
23
|
+
|
|
24
|
+
Follow the workflow at @~/.claude/legion/workflows/dev/quick.md
|
|
25
|
+
|
|
26
|
+
### Quick Reference
|
|
27
|
+
|
|
28
|
+
**Initialization**: @~/.claude/legion/workflows/core/init.md
|
|
29
|
+
**Context Loading**: @~/.claude/legion/workflows/core/context-load.md
|
|
30
|
+
**Completion**: @~/.claude/legion/workflows/core/completion.md
|
|
31
|
+
**Agent Map**: @~/.claude/legion/references/dev/agent-map.md
|
|
32
|
+
|
|
33
|
+
### Pipeline (Shortened)
|
|
34
|
+
|
|
35
|
+
| Step | Agent | Model | What it does |
|
|
36
|
+
|------|-------|-------|-------------|
|
|
37
|
+
| 1. Quick Analysis | 4 parallel agents | opus/sonnet | Context, locations, impact, verify plan |
|
|
38
|
+
| 2. Escalation Check | orchestrator | — | Detects complex scope, asks user |
|
|
39
|
+
| 3. Planner-Lite | delivery-planner | sonnet | 3-7 step compact plan |
|
|
40
|
+
| 4. Implement | general-purpose | opus | Execute plan step by step |
|
|
41
|
+
| 5. Verify-Lite | general-purpose | sonnet | Run tests + lint on changed files |
|
|
42
|
+
| 6. Brief | general-purpose | opus | SUMMARY.md + codebase update |
|
|
43
|
+
|
|
44
|
+
### Auto-Escalation Triggers
|
|
45
|
+
|
|
46
|
+
If the impact analysis detects any of these, the workflow suggests switching to `/legion:dev:cycle`:
|
|
47
|
+
- Auth/security/permissions changes
|
|
48
|
+
- Database migrations
|
|
49
|
+
- Infrastructure/CI/CD changes
|
|
50
|
+
- Public API contract changes
|
|
51
|
+
- Wide cascading impact (>5 files across >2 modules)
|
|
52
|
+
|
|
53
|
+
The user always decides — no automatic escalation.
|
|
54
|
+
|
|
55
|
+
### Key Rules
|
|
56
|
+
- ALWAYS read .legion/codebase/ before starting
|
|
57
|
+
- If task is unclear, ASK the user
|
|
58
|
+
- Pass full context summary to spawned agents
|
|
59
|
+
- Update STATE.md after completion
|
package/package.json
CHANGED
|
@@ -10,6 +10,54 @@ Legion commands invoke specialized agents via the Task tool. Each domain defines
|
|
|
10
10
|
2. **Pipeline**: Previous stage determines next agent (architect → planner → executor)
|
|
11
11
|
3. **Auto-classify**: `/legion:devops:quick` analyzes the task and routes automatically
|
|
12
12
|
|
|
13
|
+
## Complexity-Based Routing
|
|
14
|
+
|
|
15
|
+
The orchestrator scores each task's complexity (1-10) and selects the optimal pipeline depth:
|
|
16
|
+
|
|
17
|
+
### Complexity Score → Pipeline Mapping
|
|
18
|
+
|
|
19
|
+
| Score | Pipeline | Description | Typical Agent Count |
|
|
20
|
+
|-------|----------|-------------|-------------------|
|
|
21
|
+
| 1-3 | `quick` | Fast path — single-round parallel agents, no checkpoints | 4-6 agents |
|
|
22
|
+
| 4-6 | `partial` | Key stages only — architect → plan → implement → verify | 8-12 agents |
|
|
23
|
+
| 7-10 | `full` | All pipeline stages with checkpoints | 15-25+ agents |
|
|
24
|
+
|
|
25
|
+
### Scoring Algorithm
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
score = 0
|
|
29
|
+
score += files_affected_score // 1 file=1, 2-5 files=3, 6+ files=5
|
|
30
|
+
score += module_boundary_score // 0 boundaries=0, 1=2, 2+=4
|
|
31
|
+
score += risk_factor_score // auth/security=+3, DB migration=+3, infra/CI-CD=+2, public API=+2
|
|
32
|
+
score = min(score, 10) // cap at 10
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Auto-Escalation Rules
|
|
36
|
+
|
|
37
|
+
When `quick` workflow detects complexity above threshold during execution:
|
|
38
|
+
- Trigger detection in analysis round → suggest escalation to user
|
|
39
|
+
- User chooses: continue quick (accept risk) / escalate to partial / escalate to full
|
|
40
|
+
- NEVER auto-escalate without user confirmation
|
|
41
|
+
|
|
42
|
+
### Pipeline Stage Selection (Partial)
|
|
43
|
+
|
|
44
|
+
For `partial` pipeline (score 4-6), select stages based on task classification:
|
|
45
|
+
|
|
46
|
+
**DevOps domain:**
|
|
47
|
+
| Classification | Stages |
|
|
48
|
+
|---------------|--------|
|
|
49
|
+
| architecture | architect → (checkpoint) |
|
|
50
|
+
| planning | architect → plan → (checkpoint) |
|
|
51
|
+
| execution | architect → execute → validate |
|
|
52
|
+
| review | architect → review |
|
|
53
|
+
|
|
54
|
+
**Dev domain:**
|
|
55
|
+
| Score | Stages |
|
|
56
|
+
|-------|--------|
|
|
57
|
+
| 4 | architect → implement → verify |
|
|
58
|
+
| 5 | architect → plan → implement → verify |
|
|
59
|
+
| 6 | architect → plan → implement → verify → review |
|
|
60
|
+
|
|
13
61
|
## DevOps Domain Agent Map
|
|
14
62
|
|
|
15
63
|
| Pipeline Stage | Agent Name | subagent_type | Model | File |
|
|
@@ -71,6 +119,8 @@ When a workflow stage supports sub-agent decomposition:
|
|
|
71
119
|
|
|
72
120
|
### Collapse Strategies
|
|
73
121
|
|
|
122
|
+
> **Note:** Collapse strategies apply WITHIN each pipeline stage. Complexity-based routing (see `## Complexity-Based Routing`) determines WHICH stages run; collapse strategies determine HOW agents are allocated inside a given stage.
|
|
123
|
+
|
|
74
124
|
| Budget | Strategy | Description |
|
|
75
125
|
|--------|----------|-------------|
|
|
76
126
|
| 1 | monolith | Single agent, blueprint as checklist |
|