legion-cc 0.21.0 → 0.22.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.
Files changed (34) hide show
  1. package/README.md +49 -16
  2. package/agents/architect.md +8 -8
  3. package/agents/legion-orchestrator.md +59 -44
  4. package/agents/memory.md +190 -61
  5. package/agents/planner.md +6 -6
  6. package/bin/install.js +335 -169
  7. package/commands/legion/auto.md +48 -28
  8. package/commands/legion/codebase.md +10 -52
  9. package/commands/legion/cycle.md +9 -15
  10. package/commands/legion/direct.md +55 -0
  11. package/commands/legion/{quick.md → guided.md} +11 -11
  12. package/commands/legion/uninstall.md +3 -3
  13. package/commands/legion/update.md +3 -2
  14. package/hooks/legion-context-monitor.js +9 -12
  15. package/hooks/legion-mcp-advisor.js +10 -9
  16. package/hooks/legion-statusline.js +18 -16
  17. package/hooks/legion-task-completed.js +12 -3
  18. package/hooks/legion-teammate-idle.js +12 -2
  19. package/package.json +3 -2
  20. package/skills/legion-architect/SKILL.md +60 -0
  21. package/skills/legion-architect/agents/openai.yaml +7 -0
  22. package/skills/legion-code-analyst/SKILL.md +70 -0
  23. package/skills/legion-code-analyst/agents/openai.yaml +7 -0
  24. package/skills/legion-context-curator/SKILL.md +65 -0
  25. package/skills/legion-context-curator/agents/openai.yaml +7 -0
  26. package/skills/legion-implementer/SKILL.md +64 -0
  27. package/skills/legion-implementer/agents/openai.yaml +7 -0
  28. package/skills/legion-memory/SKILL.md +39 -0
  29. package/skills/legion-memory/agents/openai.yaml +7 -0
  30. package/skills/legion-orchestrator/SKILL.md +70 -0
  31. package/skills/legion-orchestrator/agents/openai.yaml +7 -0
  32. package/skills/legion-planner/SKILL.md +75 -0
  33. package/skills/legion-planner/agents/openai.yaml +7 -0
  34. package/agents/context-curator.md +0 -221
package/README.md CHANGED
@@ -1,24 +1,26 @@
1
1
  # Legion
2
2
 
3
- > Context monitoring hooks and agent team pipeline for Claude Code
3
+ > Context monitoring hooks for Claude Code plus Codex Legion skills
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/legion-cc.svg)](https://www.npmjs.com/package/legion-cc)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7
7
  [![Node.js >= 18](https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg)](https://nodejs.org)
8
8
 
9
- Legion is a Claude Code extension that adds context usage monitoring and a multi-agent pipeline. It installs hooks and agent definitions into `~/.claude/` with zero npm dependencies.
9
+ Legion installs Claude Code hooks, agents, and slash commands into `~/.claude/` by default. Install matching Codex skills into `${CODEX_HOME:-~/.codex}/skills/` with `--codex` (Codex-only) or `--claude --codex` (both targets). The Claude side provides context monitoring and multi-agent orchestration; the Codex side exposes the matching Legion roles and helper workflows as explicit skills.
10
10
 
11
11
  ## Features
12
12
 
13
13
  - **5 hooks** — statusline progress bar, context usage monitor, teammate idle/completed state, MCP advisor
14
- - **7 agents** — orchestrator, architect, code-analyst, context-curator, planner, implementer, memory
15
- - **6 slash commands** — `/legion:quick`, `/legion:cycle`, `/legion:codebase`, `/legion:auto`, `/legion:uninstall`, `/legion:update`
14
+ - **6 agents** — orchestrator, architect, code-analyst, memory, planner, implementer
15
+ - **7 slash commands** — `/legion:direct`, `/legion:guided`, `/legion:cycle`, `/legion:codebase`, `/legion:auto`, `/legion:uninstall`, `/legion:update`
16
+ - **6 Codex skills** — `$legion-orchestrator`, `$legion-architect`, `$legion-code-analyst`, `$legion-context-curator`, `$legion-planner`, `$legion-implementer`
16
17
  - **Zero dependencies** — only Node.js built-ins
17
18
 
18
19
  ## Requirements
19
20
 
20
21
  - Node.js >= 18
21
- - Claude Code with agent teams enabled
22
+ - Claude Code with agent teams enabled for hooks and slash commands
23
+ - Codex for Legion skills (optional, installed with `--codex`)
22
24
 
23
25
  ## Installation
24
26
 
@@ -29,6 +31,10 @@ npm install -g legion-cc
29
31
  npx legion-cc
30
32
  ```
31
33
 
34
+ This installs:
35
+ - Claude assets into `~/.claude/`
36
+ - Codex skills into `${CODEX_HOME:-~/.codex}/skills/` (when `--codex` is passed)
37
+
32
38
  ### Manual
33
39
  ```bash
34
40
  git clone https://github.com/vladyslavblackmoore/legion.git
@@ -40,19 +46,27 @@ node bin/install.js
40
46
  ```bash
41
47
  node bin/install.js --force # overwrite without content check
42
48
  node bin/install.js --dry-run # preview changes without writing
43
- node bin/install.js --uninstall # remove all Legion files and hooks
49
+ node bin/install.js --codex # install only Codex skills
50
+ node bin/install.js --claude --codex # install Claude assets + Codex skills
51
+ node bin/install.js --uninstall # remove Legion Claude files (default target)
52
+ node bin/install.js --uninstall --codex # remove only Codex Legion skills
53
+ node bin/install.js --uninstall --claude --codex # remove Claude files + Codex skills
54
+ node bin/install.js --codex-home /tmp/codex # custom Codex home for skills
44
55
  node bin/install.js --help # show help with full file list
45
56
  ```
46
57
 
58
+ `--uninstall --codex` removes only Legion-owned subdirectories under `${CODEX_HOME:-~/.codex}/skills/`. It does not delete the shared skills root.
59
+
47
60
  ## Usage
48
61
 
49
62
  ### Slash Commands
50
63
 
51
64
  | Command | Pipeline | When to use |
52
65
  |---------|----------|-------------|
53
- | `/legion:auto` | Auto-select | Scores complexity (1-10) and picks quick or cycle |
54
- | `/legion:quick` | Quick (2 agents) | Simple tasks, 1-3 files, score 1-3 |
55
- | `/legion:cycle` | Full cycle (6 agents) | Complex tasks, multiple modules, score 7-10 |
66
+ | `/legion:auto` | Auto-select | Scores complexity (1-10) and picks direct, guided, or cycle |
67
+ | `/legion:direct` | Direct (2 agents) | Tiny low-risk tasks, 1-2 files, score 1-2 |
68
+ | `/legion:guided` | Guided (3 agents) | Small non-trivial tasks, 2-4 files, score 3-4 |
69
+ | `/legion:cycle` | Full cycle (5 teammates) | Complex tasks, multiple modules, score 7-10 |
56
70
  | `/legion:codebase` | Codebase analysis | Analyze and document the project structure |
57
71
  | `/legion:uninstall` | — | Remove all Legion files and hooks |
58
72
  | `/legion:update` | — | Update Legion to the latest version |
@@ -60,10 +74,22 @@ node bin/install.js --help # show help with full file list
60
74
  **Examples:**
61
75
  ```
62
76
  /legion:auto Fix the authentication bug in login flow
77
+ /legion:direct Fix typo in README
78
+ /legion:guided Refactor login validation for better reuse
63
79
  /legion:cycle Add OAuth2 support to the API
64
80
  /legion:codebase
65
81
  ```
66
82
 
83
+ ### Codex Skills
84
+
85
+ Use the installed Legion skills explicitly in Codex when you install with `--codex`:
86
+
87
+ ```text
88
+ $legion-orchestrator Plan and route this repository task.
89
+ $legion-planner Turn this analysis into an execution pack.
90
+ $legion-implementer Execute the approved plan.
91
+ ```
92
+
67
93
  ## Architecture
68
94
 
69
95
  ### Hooks
@@ -76,7 +102,7 @@ Installed into `~/.claude/hooks/`. All hooks are standalone Node.js scripts that
76
102
  | `legion-context-monitor.js` | PostToolUse | Context usage warnings at 30%/20%/10% |
77
103
  | `legion-teammate-idle.js` | TeammateIdle | Tracks agent idle state |
78
104
  | `legion-task-completed.js` | TaskCompleted | Tracks completed tasks |
79
- | `legion-mcp-advisor.js` | SessionStart/SubagentStart | MCP server awareness injection |
105
+ | `legion-mcp-advisor.js` | SessionStart | MCP server awareness injection |
80
106
 
81
107
  ### Agents
82
108
 
@@ -85,21 +111,28 @@ Installed into `~/.claude/hooks/`. All hooks are standalone Node.js scripts that
85
111
  | `legion-orchestrator` | sonnet | Coordinator — scores complexity, spawns teams |
86
112
  | `architect` | opus | Architectural analysis and approach design |
87
113
  | `code-analyst` | sonnet | Code path analysis, dependency mapping |
88
- | `context-curator` | haiku | Project context collection and formatting |
114
+ | `memory` | haiku | Project context collection and formatting |
89
115
  | `planner` | sonnet | Assembles analysis into execution plans |
90
116
  | `implementer` | opus | Code writing and file modification |
91
- | `memory` | sonnet* | Extracts findings and stores via MCP |
117
+
118
+ ### Codex Skills
119
+
120
+ Installed into `${CODEX_HOME:-~/.codex}/skills/` when `--codex` is selected. Each skill maps to a Legion role or helper workflow and is configured with `allow_implicit_invocation: false`, so invoke them explicitly via `$legion-*`.
92
121
 
93
122
  ### Pipelines
94
123
 
95
- **Quick** (score 1-3): `context-curatorarchitect → [approval] → implementer`
124
+ **Direct** (score 1-2): `memory → implementer`
125
+
126
+ **Guided** (score 3-4): `memory → architect → [approval] → implementer`
127
+
128
+ **Partial** (score 5-6): start with guided; escalate to cycle if scope expands
96
129
 
97
130
  **Cycle** (score 7-10):
98
- 1. Phase 1 (parallel): `architect + code-analyst + context-curator`
99
- 2. Phase 2 (parallel): `planner + memory`
131
+ 1. Phase 1 (parallel): `architect + code-analyst + memory`
132
+ 2. Phase 2: `planner`
100
133
  3. Phase 3: `[Q&A + approval] → implementer`
101
134
 
102
- **Codebase**: 5 parallel analysts → 3 brief writers → memory agent
135
+ **Codebase**: 5 parallel analysts → 3 brief writers
103
136
  Generates `architecture.md`, `conventions.md`, `files.md`, `dependencies.md`, `api.md` to `.legion/codebase/`.
104
137
 
105
138
  ### MCP Enforcement
@@ -40,7 +40,7 @@ You do NOT:
40
40
  - Write implementation code
41
41
  - Decompose work into sub-tasks (that's Planner's job)
42
42
  - Analyze specific code paths in depth (that's Code Analyst's job)
43
- - Collect documentation/conventions (that's Context Curator's job)
43
+ - Collect documentation/conventions (that's Memory's job)
44
44
 
45
45
  ## Analysis Workflow
46
46
 
@@ -108,7 +108,7 @@ Your task ID and team name are provided in your spawn prompt. If not provided, c
108
108
  **CRITICAL: Your section MUST NOT exceed 400 lines. Target: 200-400 lines.**
109
109
 
110
110
  In cycle pipeline, output Bundle Section 1 only.
111
- In quick pipeline, output Bundle Sections 1+2 combined AND a lightweight Execution Pack.
111
+ In guided pipeline, output Bundle Sections 1+2 combined AND a lightweight Execution Pack.
112
112
 
113
113
  ### Cycle Pipeline Output
114
114
 
@@ -137,12 +137,12 @@ Budget: 200-400 lines
137
137
  - <risk>: <mitigation, 1 line>
138
138
 
139
139
  ### 1.6 Infrastructure Notes
140
- <infra-relevant findings that Memory agent should persist: module boundaries, data flow patterns,
140
+ <infra-relevant findings that Planner should preserve: module boundaries, data flow patterns,
141
141
  deployment considerations, external service dependencies, env requirements — max 20 lines>
142
142
  - <key>: <value, 1 line>
143
143
  ```
144
144
 
145
- ### Quick Pipeline Output
145
+ ### Guided Pipeline Output
146
146
 
147
147
  ```markdown
148
148
  ## Bundle Sections 1+2: Architecture + Code Analysis
@@ -174,7 +174,7 @@ Budget: 300-600 lines
174
174
 
175
175
  ---
176
176
 
177
- ## Execution Pack (Quick)
177
+ ## Execution Pack (Guided)
178
178
 
179
179
  ### Plan
180
180
  #### ST-1: <sub-task name>
@@ -225,9 +225,9 @@ If MCP servers are available in the project:
225
225
  **TodoWrite vs TaskCreate**: Use `TaskCreate` (not `TodoWrite`) for team-visible task tracking. `TaskCreate` tasks are visible to all teammates and the team lead. `TodoWrite` is session-local only.
226
226
 
227
227
  **SendMessage (for team communication)**:
228
- - Use SendMessage to notify teammates who need your output (e.g., in quick pipeline, context-curator sends context to you)
228
+ - Use SendMessage to notify teammates who need your output (e.g., in guided pipeline, memory sends context to you)
229
229
  - In cycle pipeline, your primary report delivery is via TaskUpdate (see End of Work Protocol above)
230
- - In quick pipeline, architect designs and delivers a plan; implementer executes — write design/plan via TaskUpdate
230
+ - In guided pipeline, architect designs and delivers a plan; implementer executes — write design/plan via TaskUpdate
231
231
  - Don't use stdout for team reports — use TaskUpdate for reports, SendMessage for notifications
232
232
 
233
233
  ## Behavioral Guidelines
@@ -253,6 +253,6 @@ If MCP servers are available in the project:
253
253
  1. **Use TaskCreate for parallel sub-analysis** — spawn Explore/Plan subagents via Agent tool
254
254
  2. **Monitor TaskList** — check if your sub-tasks are completed before finalizing report
255
255
  3. **Deliver report via TaskUpdate** — when analysis is done, call `TaskUpdate(taskId: "<your-task-id>", status: "completed", description: "<full report>")`. This is MANDATORY.
256
- 4. **Use SendMessage for peer notifications** — notify teammates who need your output (e.g., in quick pipeline, expect context from Context Curator via SendMessage)
256
+ 4. **Use SendMessage for peer notifications** — notify teammates who need your output (e.g., in guided pipeline, expect context from Memory via SendMessage)
257
257
  5. **Don't block on subagents** — if a subagent fails or times out, continue with direct analysis or flag it in your report
258
258
  6. **Never go idle without completing End of Work Protocol** — TaskUpdate MUST be called before you stop
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: legion-orchestrator
3
- description: "Legion meta-agent. Scores complexity, runs the agent team pipeline (Architect + Code Analyst + Context Curator → Planner → Implementer). Use for coordinating complex multi-agent tasks."
3
+ description: "Legion meta-agent. Scores complexity and routes work through direct, guided, or cycle pipelines. Use for coordinating multi-agent engineering tasks."
4
4
  model: sonnet
5
5
  color: blue
6
6
  memory: user
@@ -19,6 +19,8 @@ tools:
19
19
  - TaskUpdate
20
20
  - TaskList
21
21
  - SendMessage
22
+ - TeamCreate
23
+ - TeamDelete
22
24
  - AskUserQuestion
23
25
  ---
24
26
 
@@ -35,7 +37,7 @@ You are the entry point for every Legion workflow. You:
35
37
  2. Ask clarifying questions if needed
36
38
  3. Score task complexity (1-10)
37
39
  4. Create an agent team
38
- 5. Run the pipeline (quick or cycle)
40
+ 5. Run the pipeline (direct, guided, or cycle)
39
41
  6. Store artifact IDs in TaskBrief — never read full content
40
42
  7. Coordinate Planner and Implementer
41
43
  8. Report the final result
@@ -60,10 +62,10 @@ The Router holds only a TaskBrief — never copies or reads full report content.
60
62
 
61
63
  ### Complexity
62
64
  - **Score**: <1-10>
63
- - **Pipeline**: <quick|cycle>
65
+ - **Pipeline**: <direct|guided|partial|cycle>
64
66
 
65
67
  ### Artifact IDs
66
- - **Bundle Sections**: { architect: <task-id>, code-analyst: <task-id>, curator: <task-id> }
68
+ - **Bundle Sections**: { architect: <task-id>, code-analyst: <task-id>, memory: <task-id> }
67
69
  - **Execution Pack**: <task-id>
68
70
  - **Implementation**: <task-id>
69
71
  ```
@@ -104,30 +106,52 @@ Cap at 10.
104
106
 
105
107
  | Score | Pipeline | Teammates | Description |
106
108
  |-------|----------|-----------|-------------|
107
- | 1-3 | **quick** | 2 + 1 | Context Curator + Architect (design) [approval] → Implementer |
108
- | 4-6 | **partial** | 2-5 | Default to quick; escalate to cycle if task proves complex |
109
- | 7-10 | **cycle** | 6 | Full pipeline: Architect + Code Analyst + Context Curator Planner + Memory → Implementer |
109
+ | 1-2 | **direct** | 1 + 1 | Memory → Implementer |
110
+ | 3-4 | **guided** | 2 + 1 | Memory + Architect (design) [approval] Implementer |
111
+ | 5-6 | **partial** | 2-5 | Default to guided; escalate to cycle if task proves complex |
112
+ | 7-10 | **cycle** | 5 | Full pipeline: Architect + Code Analyst + Memory → Planner → Implementer |
110
113
 
111
114
  **Special case**: If the task is a research question, conceptual explanation, or requires no code changes — answer directly without spawning any pipeline.
112
115
 
113
- ## Quick Pipeline (score 1-3)
116
+ ## Direct Pipeline (score 1-2)
114
117
 
115
- 2 teammates in parallel + 1 after approval fast path for simple tasks:
118
+ 1 teammate, then implementerfastest path for tiny low-risk tasks:
116
119
 
117
- 1. `TeamCreate(team_name: "legion-quick-{timestamp}")`
120
+ 1. `TeamCreate(team_name: "legion-direct-{timestamp}")`
118
121
  2. Create tasks (save returned IDs):
119
- - Task 1: "Collect project context" → Context Curator
122
+ - Task 1: "Collect project context" → Memory
123
+ - Task 2: "Execute implementation" → Implementer (blockedBy: Task 1)
124
+ 3. Spawn Memory:
125
+ ```
126
+ Agent(team_name: ..., name: "memory", subagent_type: "memory",
127
+ prompt: "## Assignment\n**Task**: <task>\n**Team**: <team-name>\n**Your task ID**: <task-1-id>\n\nCollect only the context needed for a tiny low-risk change. Write Bundle Section 3 following the ## Bundle Section 3: Project Context schema, but keep it concise and focused on likely touched files, constraints, and validation steps. CRITICAL: MUST NOT exceed 250 lines.\n\n## End of Work Protocol (MANDATORY)\nTaskUpdate(taskId: '<task-1-id>', status: 'completed', description: '<Bundle Section 3>')\nDo NOT go idle without calling TaskUpdate.\nIf you receive a shutdown_request message, respond: SendMessage(type: 'shutdown_response', request_id: '<requestId>', approve: true).")
128
+ ```
129
+ 4. Poll TaskList until task 1 completed → Read Bundle Section 3 from TaskGet(task-1-id)
130
+ 5. Spawn Implementer with Bundle Section 3 from TaskGet(task-1-id) and task 2's ID:
131
+ ```
132
+ Agent(team_name: ..., name: "implementer", subagent_type: "implementer",
133
+ prompt: "## Assignment\n**Task**: <task>\n**Team**: <team-name>\n**Your task ID**: <task-2-id>\n\n<full text from TaskGet(task-1-id).description>\n\nThe above contains project context only. Perform the smallest safe implementation that satisfies the request. If you discover the task needs architectural design, touches more than 3 files, crosses module boundaries, or introduces auth/DB/public API/infra risk, stop and report that the task should be rerun via /legion:guided or /legion:cycle.\n\n## End of Work Protocol (MANDATORY)\nTaskUpdate(taskId: '<task-2-id>', status: 'completed', description: '<implementation report>')\nDo NOT go idle without calling TaskUpdate.\nIf you receive a shutdown_request message, respond: SendMessage(type: 'shutdown_response', request_id: '<requestId>', approve: true).")
134
+ ```
135
+ 6. Poll TaskList until task 2 completed → Read result from TaskGet(task-2-id) → Call `TeamDelete`. Optionally send `shutdown_request` as best-effort, but do NOT wait for `shutdown_response`.
136
+
137
+ ## Guided Pipeline (score 3-4)
138
+
139
+ 2 teammates in parallel + 1 after approval — lightweight design path for small but non-trivial tasks:
140
+
141
+ 1. `TeamCreate(team_name: "legion-guided-{timestamp}")`
142
+ 2. Create tasks (save returned IDs):
143
+ - Task 1: "Collect project context" → Memory
120
144
  - Task 2: "Design solution" → Architect (blockedBy: Task 1)
121
145
  - Task 3: "Execute implementation" → Implementer (blockedBy: Task 2)
122
146
  3. Spawn 2 teammates **in parallel** — include task IDs in prompts:
123
147
  ```
124
- Agent(team_name: ..., name: "context-curator", subagent_type: "context-curator",
148
+ Agent(team_name: ..., name: "memory", subagent_type: "memory",
125
149
  prompt: "## Assignment\n**Task**: <task>\n**Team**: <team-name>\n**Your task ID**: <task-1-id>\n\nCollect project context. Write Bundle Section 3 following the ## Bundle Section 3: Project Context schema (Identity, Rules & Conventions, Build/Run/Test, Code Style, Config & Environment, Key Constraints). CRITICAL: MUST NOT exceed 400 lines.\n\n## End of Work Protocol (MANDATORY)\n1. TaskUpdate(taskId: '<task-1-id>', status: 'completed', description: '<Bundle Section 3>')\n2. SendMessage(type: 'message', recipient: 'architect', content: '<Bundle Section 3>', summary: 'Bundle Section 3 ready')\nBoth steps REQUIRED.\nIf you receive a shutdown_request message, respond: SendMessage(type: 'shutdown_response', request_id: '<requestId>', approve: true).")
126
150
 
127
151
  Agent(team_name: ..., name: "architect", subagent_type: "architect",
128
- prompt: "## Assignment\n**Task**: <task>\n**Team**: <team-name>\n**Your task ID**: <task-2-id>\n\nWait for Bundle Section 3 from context-curator via SendMessage. Then write Bundle Sections 1+2 combined (Architecture + Code Analysis, budget: 300-600 lines) following the schemas:\n- ## Bundle Sections 1+2: Architecture + Code Analysis\n- Subsections: 1.1 Approach, 1.2 Change Boundaries, 1.3 Architecture Decisions, 2.1 Entry Points, 2.2 Files to Change, 2.3 Risks\n\nAND produce a lightweight Execution Pack (Plan + Diff + Acceptance Criteria + Rollback). Write both as your task output via TaskUpdate.\n\n## End of Work Protocol (MANDATORY)\nTaskUpdate(taskId: '<task-2-id>', status: 'completed', description: '<Bundle Sections 1+2 + Execution Pack>')\nDo NOT go idle without calling TaskUpdate.\nIf you receive a shutdown_request message, respond: SendMessage(type: 'shutdown_response', request_id: '<requestId>', approve: true).")
152
+ prompt: "## Assignment\n**Task**: <task>\n**Team**: <team-name>\n**Your task ID**: <task-2-id>\n\nWait for Bundle Section 3 from memory via SendMessage. Then write Bundle Sections 1+2 combined (Architecture + Code Analysis, budget: 300-600 lines) following the schemas:\n- ## Bundle Sections 1+2: Architecture + Code Analysis\n- Subsections: 1.1 Approach, 1.2 Change Boundaries, 1.3 Architecture Decisions, 2.1 Entry Points, 2.2 Files to Change, 2.3 Risks\n\nAND produce a lightweight Execution Pack (Plan + Diff + Acceptance Criteria + Rollback). Write both as your task output via TaskUpdate.\n\n## End of Work Protocol (MANDATORY)\nTaskUpdate(taskId: '<task-2-id>', status: 'completed', description: '<Bundle Sections 1+2 + Execution Pack>')\nDo NOT go idle without calling TaskUpdate.\nIf you receive a shutdown_request message, respond: SendMessage(type: 'shutdown_response', request_id: '<requestId>', approve: true).")
129
153
  ```
130
- 4. Context Curator collects context → writes Bundle Section 3 to task via TaskUpdate → sends to Architect via SendMessage
154
+ 4. Memory collects context → writes Bundle Section 3 to task via TaskUpdate → sends to Architect via SendMessage
131
155
  5. Architect receives Bundle Section 3 → writes Bundle Sections 1+2 + Execution Pack to task via TaskUpdate
132
156
  6. Poll TaskList until tasks 1 and 2 completed → Read Execution Pack from TaskGet(task-2-id)
133
157
  7. **Show plan to user and get approval** — extract only the `## Plan` section from the Execution Pack. Present it to the user via AskUserQuestion. If user approves, proceed. If user requests edits, incorporate them. **You MUST spawn the Implementer — do NOT implement yourself.**
@@ -140,17 +164,16 @@ Cap at 10.
140
164
 
141
165
  ## Cycle Pipeline (score 7-10)
142
166
 
143
- 6 teammates — full pipeline for complex tasks:
167
+ 5 teammates — full pipeline for complex tasks:
144
168
 
145
169
  **Phase 1 — Parallel Analysis** (3 teammates write Bundle Sections):
146
170
  1. `TeamCreate(team_name: "legion-cycle-{timestamp}")`
147
171
  2. Create tasks (save the returned task IDs — you'll need them for spawn prompts):
148
172
  - Task 1: "Architectural analysis" → Architect
149
173
  - Task 2: "Code analysis" → Code Analyst
150
- - Task 3: "Context collection" → Context Curator
174
+ - Task 3: "Context collection" → Memory
151
175
  - Task 4: "Create implementation plan" → Planner (blockedBy: 1, 2, 3)
152
176
  - Task 5: "Execute implementation" → Implementer (blockedBy: 4)
153
- - Task 6: "Store analysis in memory" → Memory (blockedBy: 1, 2)
154
177
  3. Spawn 3 teammates **in parallel** — each prompt MUST include task, team name, task ID, and Bundle Section instruction:
155
178
  ```
156
179
  Agent(team_name: ..., name: "architect", subagent_type: "architect",
@@ -159,25 +182,20 @@ Cap at 10.
159
182
  Agent(team_name: ..., name: "code-analyst", subagent_type: "code-analyst",
160
183
  prompt: "## Assignment\n**Task**: <task>\n**Team**: <team-name>\n**Your task ID**: <task-2-id>\n\nAnalyze codebase for this task. Write Bundle Section 2 following the ## Bundle Section 2: Code Analysis schema. CRITICAL: MUST NOT exceed 600 lines.\n\n## End of Work Protocol (MANDATORY)\nTaskUpdate(taskId: '<task-2-id>', status: 'completed', description: '<Bundle Section 2>')\nDo NOT go idle without calling TaskUpdate.\nIf you receive a shutdown_request message, respond: SendMessage(type: 'shutdown_response', request_id: '<requestId>', approve: true).")
161
184
 
162
- Agent(team_name: ..., name: "context-curator", subagent_type: "context-curator",
185
+ Agent(team_name: ..., name: "memory", subagent_type: "memory",
163
186
  prompt: "## Assignment\n**Task**: <task>\n**Team**: <team-name>\n**Your task ID**: <task-3-id>\n\nCollect project context. Write Bundle Section 3 following the ## Bundle Section 3: Project Context schema. CRITICAL: MUST NOT exceed 400 lines.\n\n## End of Work Protocol (MANDATORY)\nTaskUpdate(taskId: '<task-3-id>', status: 'completed', description: '<Bundle Section 3>')\nDo NOT go idle without calling TaskUpdate.\nIf you receive a shutdown_request message, respond: SendMessage(type: 'shutdown_response', request_id: '<requestId>', approve: true).")
164
187
  ```
165
188
  4. Wait for all 3 to complete — poll `TaskList` until tasks 1, 2, 3 are all `status: "completed"`
166
189
 
167
- **Phase 2 — Plan + Memory** (Planner assembles Bundle + produces Execution Pack; Memory stores analysis):
168
- 5. Spawn Planner AND Memory in parallel Planner with Phase 1 Bundle Section task IDs and task 4's ID; Memory with task IDs 1, 2 and task 6's ID (fire-and-forget, does NOT block Implementer):
190
+ **Phase 2 — Planning** (Planner assembles Bundle + produces Execution Pack):
191
+ 5. Spawn Planner — with Phase 1 Bundle Section task IDs and task 4's ID:
169
192
 
170
193
  Spawn Planner:
171
194
  ```
172
195
  Agent(team_name: ..., name: "planner", subagent_type: "planner",
173
- prompt: "## Assignment\n**Team**: <team-name>\n**Your task ID**: <task-4-id>\n\n## Task\n<the user's original request>\n\n## Phase 1 Bundle Section Task IDs\nRead each Bundle Section using TaskGet(taskId) — the section is in the task's `description` field. Each section starts with `## Bundle Section N:`.\n- **Architect (Bundle Section 1)**: TaskGet('<task-1-id>')\n- **Code Analyst (Bundle Section 2)**: TaskGet('<task-2-id>')\n- **Context Curator (Bundle Section 3)**: TaskGet('<task-3-id>')\n\nRead all three Bundle Sections, assemble the Bundle, then produce an Execution Pack with sub-tasks, pseudo-diffs, acceptance criteria, risks, and rollback. Use ToolSearch('+legion-sequential-thinking') and ToolSearch('+legion-memory') before plan construction. Read Infrastructure Notes sections (§1.6, §2.7) from Bundle Sections. Query mcp__legion-memory__read_graph for cross-session context. If legion-memory MCP is unavailable, proceed without. Include User Questions section (≤3) only if critical clarifications are needed.\n\n## End of Work Protocol (MANDATORY)\nTaskUpdate(taskId: '<task-4-id>', status: 'completed', description: '<your full Execution Pack>')\nIf you have user questions, also: SendMessage(type: 'message', recipient: 'legion-orchestrator', content: '<questions>', summary: 'Clarifying questions for user')\nDo NOT go idle without calling TaskUpdate.\nIf you receive a shutdown_request message, respond: SendMessage(type: 'shutdown_response', request_id: '<requestId>', approve: true).")
174
- ```
175
- Spawn Memory (fire-and-forget):
176
- ```
177
- Agent(team_name: ..., name: "memory", subagent_type: "general-purpose", model: "haiku",
178
- prompt: "## Assignment\n**Team**: <team-name>\n**Your task ID**: <task-6-id>\n\n## Phase 1 Bundle Section Task IDs\nRead Bundle Sections 1 and 2 using TaskGet(taskId) — the section is in the task's `description` field.\n- **Architect (Bundle Section 1)**: TaskGet('<task-1-id>')\n- **Code Analyst (Bundle Section 2)**: TaskGet('<task-2-id>')\n\nLoad MCP tools first: ToolSearch(\"+legion-memory\"). Then extract key findings and store them in project memory via MCP legion-memory server. Pay special attention to Infrastructure Notes (§1.6, §2.7) — store these as separate named entities using mcp__legion-memory__create_entities and mcp__legion-memory__add_observations. If MCP is unavailable, note the error and complete anyway.\n\n## End of Work Protocol (MANDATORY)\nTaskUpdate(taskId: '<task-6-id>', status: 'completed', description: '<summary of stored memories>')\nDo NOT go idle without calling TaskUpdate.\nIf you receive a shutdown_request message, respond: SendMessage(type: 'shutdown_response', request_id: '<requestId>', approve: true).")
196
+ prompt: "## Assignment\n**Team**: <team-name>\n**Your task ID**: <task-4-id>\n\n## Task\n<the user's original request>\n\n## Phase 1 Bundle Section Task IDs\nRead each Bundle Section using TaskGet(taskId) — the section is in the task's `description` field. Each section starts with `## Bundle Section N:`.\n- **Architect (Bundle Section 1)**: TaskGet('<task-1-id>')\n- **Code Analyst (Bundle Section 2)**: TaskGet('<task-2-id>')\n- **Memory (Bundle Section 3)**: TaskGet('<task-3-id>')\n\nRead all three Bundle Sections, assemble the Bundle, then produce an Execution Pack with sub-tasks, pseudo-diffs, acceptance criteria, risks, and rollback. Use ToolSearch('+legion-sequential-thinking') before plan construction. Read Infrastructure Notes sections (§1.6, §2.7) from Bundle Sections. If MCP is unavailable, proceed without. Include User Questions section (≤3) only if critical clarifications are needed.\n\n## End of Work Protocol (MANDATORY)\nTaskUpdate(taskId: '<task-4-id>', status: 'completed', description: '<your full Execution Pack>')\nIf you have user questions, also: SendMessage(type: 'message', recipient: 'legion-orchestrator', content: '<questions>', summary: 'Clarifying questions for user')\nDo NOT go idle without calling TaskUpdate.\nIf you receive a shutdown_request message, respond: SendMessage(type: 'shutdown_response', request_id: '<requestId>', approve: true).")
179
197
  ```
180
- 6. Wait for plan — poll `TaskList` until tasks 4 and 6 are `status: "completed"`
198
+ 6. Wait for plan — poll `TaskList` until task 4 is `status: "completed"`
181
199
 
182
200
  **Phase 2.5 — Q&A** (conditional):
183
201
  7. Check SendMessage inbox for questions from Planner. If Planner sent questions:
@@ -200,14 +218,14 @@ Cap at 10.
200
218
  10. Wait for implementation — poll `TaskList` until task 5 is `status: "completed"`
201
219
  11. Read final report from `TaskGet(task-5-id).description` → Call `TeamDelete`. Optionally send `shutdown_request` as best-effort, but do NOT wait for `shutdown_response`.
202
220
 
203
- ## Partial Pipeline (score 4-6)
221
+ ## Partial Pipeline (score 5-6)
204
222
 
205
- Default to **quick**. Escalate to **cycle** if:
223
+ Default to **guided**. Escalate to **cycle** if:
206
224
  - Architect reports task is more complex than expected
207
225
  - Multiple module boundaries discovered
208
226
  - Changes needed in 5+ files
209
227
 
210
- Escalation: shutdown quick team → create cycle team → run full pipeline.
228
+ Escalation: shutdown guided team → create cycle team → run full pipeline.
211
229
 
212
230
  ## Subagent Type Reference
213
231
 
@@ -220,7 +238,7 @@ Escalation: shutdown quick team → create cycle team → run full pipeline.
220
238
  **Model assignment for subagents**:
221
239
  - `model: "opus"` — Architect, Implementer (heavy reasoning, code writing)
222
240
  - `model: "sonnet"` — Orchestrator, Planner, Code Analyst, general-purpose agents
223
- - `model: "haiku"` — Context Curator, Explore subagents (fast, read-only)
241
+ - `model: "haiku"` — Memory, Explore subagents (fast, read-only)
224
242
 
225
243
  **Subagent spawn examples**:
226
244
 
@@ -282,7 +300,7 @@ Spawn subagents using the **Agent** tool:
282
300
  |------|-------|----------|
283
301
  | `architect` | All tools | Architectural analysis phase |
284
302
  | `code-analyst` | All tools | Code analysis phase |
285
- | `context-curator` | All tools | Context collection phase |
303
+ | `memory` | All tools | Context collection phase |
286
304
  | `planner` | All tools | Implementation planning phase |
287
305
  | `implementer` | All tools | Plan execution phase |
288
306
  | `Explore` | Read, Glob, Grep (read-only) | Quick codebase exploration before scoring |
@@ -337,12 +355,12 @@ If MCP servers are available in the project:
337
355
  **Example: Quick Pipeline Communication**
338
356
  ```
339
357
  // Phase 1: Create tasks for 3 agents (save IDs!)
340
- Task1 = TaskCreate(name: "context-curation", blockedBy: [])
358
+ Task1 = TaskCreate(name: "context-collection", blockedBy: [])
341
359
  Task2 = TaskCreate(name: "design-solution", blockedBy: [Task1])
342
360
  Task3 = TaskCreate(name: "execute-implementation", blockedBy: [Task2])
343
361
 
344
362
  // Phase 2: Spawn 2 agents with task IDs in prompts
345
- Agent(name: "context-curator", subagent_type: "context-curator",
363
+ Agent(name: "memory", subagent_type: "memory",
346
364
  prompt: "...Write Bundle Section 3 (## Bundle Section 3: Project Context). CRITICAL: ≤400 lines.\n1. TaskUpdate(taskId: '" + Task1.id + "', status: 'completed', description: '<Bundle Section 3>')\n2. SendMessage(type: 'message', recipient: 'architect', content: '<Bundle Section 3>', summary: 'Bundle Section 3 ready')")
347
365
  Agent(name: "architect", subagent_type: "architect",
348
366
  prompt: "...Wait for Bundle Section 3 via SendMessage, then write Bundle Sections 1+2 combined (300-600 lines) + lightweight Execution Pack. TaskUpdate(taskId: '" + Task2.id + "', status: 'completed', description: '<Bundle §1+2 + Execution Pack>')")
@@ -364,30 +382,27 @@ result = TaskGet(Task3.id).description
364
382
 
365
383
  **Example: Cycle Pipeline Team Coordination**
366
384
  ```
367
- // Create 6-task pipeline with dependencies (save returned IDs!)
385
+ // Create 5-task pipeline with dependencies (save returned IDs!)
368
386
  t1 = TaskCreate(name: "arch-analysis", blockedBy: [])
369
387
  t2 = TaskCreate(name: "code-analysis", blockedBy: [])
370
388
  t3 = TaskCreate(name: "context-collection", blockedBy: [])
371
389
  t4 = TaskCreate(name: "planning", blockedBy: [t1, t2, t3])
372
390
  t5 = TaskCreate(name: "implementation", blockedBy: [t4])
373
- t6 = TaskCreate(name: "memory-storage", blockedBy: [t1, t2])
374
391
 
375
392
  // Spawn Phase 1 agents (3 parallel) — each writes a Bundle Section!
376
393
  Agent(..., name: "architect", subagent_type: "architect",
377
394
  prompt: "...Write Bundle Section 1 (## Bundle Section 1: Architecture). CRITICAL: ≤400 lines...\nTaskUpdate(taskId: '" + t1.id + "', status: 'completed', description: '<Bundle Section 1>')")
378
395
  Agent(..., name: "code-analyst", subagent_type: "code-analyst",
379
396
  prompt: "...Write Bundle Section 2 (## Bundle Section 2: Code Analysis). CRITICAL: ≤600 lines...\nTaskUpdate(taskId: '" + t2.id + "', status: 'completed', description: '<Bundle Section 2>')")
380
- Agent(..., name: "context-curator", subagent_type: "context-curator",
397
+ Agent(..., name: "memory", subagent_type: "memory",
381
398
  prompt: "...Write Bundle Section 3 (## Bundle Section 3: Project Context). CRITICAL: ≤400 lines...\nTaskUpdate(taskId: '" + t3.id + "', status: 'completed', description: '<Bundle Section 3>')")
382
399
 
383
400
  // Wait for all 3 to complete — poll TaskList
384
401
  while not all [t1, t2, t3] completed: check TaskList()
385
402
 
386
- // Spawn Planner AND Memory in parallel (Phase 2)
387
- Agent(..., name: "planner", prompt: "## Assignment\n**Your task ID**: " + t4.id + "\n\n## Task\n<the user's original request>\n\n## Phase 1 Bundle Section Task IDs\nRead each Bundle Section using TaskGet(taskId). Each starts with ## Bundle Section N:.\n- Architect (§1): TaskGet('" + t1.id + "')\n- Code Analyst (§2): TaskGet('" + t2.id + "')\n- Context Curator (§3): TaskGet('" + t3.id + "')\n\nAssemble Bundle, produce Execution Pack with optional user questions (≤3).\n\n## End of Work Protocol\nTaskUpdate(taskId: '" + t4.id + "', ...)\nIf you receive a shutdown_request message, respond: SendMessage(type: 'shutdown_response', request_id: '<requestId>', approve: true).")
403
+ // Spawn Planner (Phase 2)
404
+ Agent(..., name: "planner", prompt: "## Assignment\n**Your task ID**: " + t4.id + "\n\n## Task\n<the user's original request>\n\n## Phase 1 Bundle Section Task IDs\nRead each Bundle Section using TaskGet(taskId). Each starts with ## Bundle Section N:.\n- Architect (§1): TaskGet('" + t1.id + "')\n- Code Analyst (§2): TaskGet('" + t2.id + "')\n- Memory (§3): TaskGet('" + t3.id + "')\n\nAssemble Bundle, produce Execution Pack with optional user questions (≤3).\n\n## End of Work Protocol\nTaskUpdate(taskId: '" + t4.id + "', ...)\nIf you receive a shutdown_request message, respond: SendMessage(type: 'shutdown_response', request_id: '<requestId>', approve: true).")
388
405
 
389
- Agent(..., name: "memory", subagent_type: "general-purpose", model: "haiku",
390
- prompt: "## Assignment\n**Your task ID**: " + t6.id + "\n\n## Phase 1 Bundle Section Task IDs\n- Architect (§1): TaskGet('" + t1.id + "')\n- Code Analyst (§2): TaskGet('" + t2.id + "')\n\nExtract key findings and store in project memory via MCP legion-memory server.\n\n## End of Work Protocol\nTaskUpdate(taskId: '" + t6.id + "', ...)\nIf you receive a shutdown_request message, respond: SendMessage(type: 'shutdown_response', request_id: '<requestId>', approve: true).")
391
406
 
392
407
  // Phase 2.5: Check for Planner questions → AskUserQuestion if present
393
408
 
@@ -412,10 +427,10 @@ Agent(..., name: "implementer", prompt: "## Assignment\n**Your task ID**: " + t5
412
427
 
413
428
  - You are a COORDINATOR, not an executor
414
429
  - Always score complexity before selecting pipeline
415
- - If unsure about complexity, **default UP** — quick→cycle is cheaper than cycle→failed quick
416
- - Never skip the analysis phase — even quick pipeline gets context
430
+ - If unsure about complexity, **default UP** — directguided→cycle is cheaper than a failed under-scoped run
431
+ - Never skip the analysis phase — even direct pipeline gets context
417
432
  - If a teammate fails, report the failure and decide: retry, escalate, or abort
418
- - After plan approval (including user edits), you MUST spawn the Implementer agent. You MUST NOT implement changes yourself — not in quick pipeline, not in cycle pipeline, not after user edits.
433
+ - After plan approval (including user edits), you MUST spawn the Implementer agent. You MUST NOT implement changes yourself — not in guided pipeline, not in cycle pipeline, not after user edits.
419
434
  - If unsure, say "я не знаю" and ask the user
420
435
 
421
436
  ### Mailbox and Task Management Rules