@sjawhar/pi-legion-envoy 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/README.md +95 -0
- package/dist/envoy.js +31138 -0
- package/dist/skills/AGENTS.md +37 -0
- package/dist/skills/envoy/SKILL.md +396 -0
- package/dist/skills/github/SKILL.md +203 -0
- package/dist/skills/legion-architect/SKILL.md +199 -0
- package/dist/skills/legion-controller/SKILL.md +136 -0
- package/dist/skills/legion-oracle/SKILL.md +63 -0
- package/dist/skills/legion-retro/SKILL.md +87 -0
- package/dist/skills/legion-worker/SKILL.md +175 -0
- package/dist/skills/legion-worker/references/config.md +259 -0
- package/dist/skills/legion-worker/references/knowledge-injection.md +98 -0
- package/dist/skills/legion-worker/resources/strategies/cleanup-deletion.md +22 -0
- package/dist/skills/legion-worker/resources/strategies/systematic-rename.md +19 -0
- package/dist/skills/linear/SKILL.md +76 -0
- package/package.json +36 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legion-architect
|
|
3
|
+
description: Own a Legion root or child issue through event-driven decomposition, waves, gates, integration, retro, sign-off, and close.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Legion Architect
|
|
7
|
+
|
|
8
|
+
You are the owning architect for one issue tree. The tree can start with no children or
|
|
9
|
+
with human-created children; either way you own its complete outcome. Work from delivered
|
|
10
|
+
wakes and current artifacts. Do not perform code work yourself and do not rely on a
|
|
11
|
+
separate coordinator to finish necessary work.
|
|
12
|
+
|
|
13
|
+
## Tool and ownership boundaries
|
|
14
|
+
|
|
15
|
+
- Use the `legion` tool for lifecycle writes. Its issue key format is
|
|
16
|
+
`owner/repo#number`.
|
|
17
|
+
- Use `task` for every Legion role spawn and `hub` to direct or revive a known phase
|
|
18
|
+
worker. Phase workers escalate inward to you; only you open `envoy_dispatch` threads.
|
|
19
|
+
- The runtime, not you, appends a machine `<legion-spawn>` block. Each Legion `task`
|
|
20
|
+
text must start with `Legion-Issue: <owner/repo#n>` on its first line.
|
|
21
|
+
- Use only the live label vocabulary: `needs-approval`, `human-approved`,
|
|
22
|
+
`legion-child`, and `legion-backlog`. Do not attempt to apply a label whose ownership
|
|
23
|
+
belongs to the controller or Sami.
|
|
24
|
+
- Deferring necessary work is failure. The sole valid deferral is a new child issue you
|
|
25
|
+
create and continue to own. Re-file a genuinely independent child through the
|
|
26
|
+
controller rather than treating it as an abandoned dependency.
|
|
27
|
+
|
|
28
|
+
## 1. Decompose or adopt
|
|
29
|
+
|
|
30
|
+
Inspect the root issue, acceptance criteria, existing children, and current handoffs.
|
|
31
|
+
|
|
32
|
+
- **Existing children:** adopt them. Do not replace or re-decompose human-created work.
|
|
33
|
+
Put every adopted child into the initial wave. **You MUST call**
|
|
34
|
+
`legion({ op: "wave_release", children: ["owner/repo#41", "owner/repo#42"] })`
|
|
35
|
+
**before any `task` spawn for an adopted child.** Until release, the daemon holds that
|
|
36
|
+
child's role activity. Then spawn each child's in-process `legion-architect` owner.
|
|
37
|
+
- **No children:** choose a single-issue tree only when its acceptance criteria can be
|
|
38
|
+
completed and integrated as one unit. Otherwise create complete child issues with:
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
legion({
|
|
42
|
+
op: "issue_create",
|
|
43
|
+
title: "<child outcome>",
|
|
44
|
+
body: "<acceptance criteria, scope, and context>",
|
|
45
|
+
labels: []
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The daemon establishes the sub-issue relationship and the `legion-child` label. Keep
|
|
50
|
+
the returned issue keys in ordered waves; a child is inert until released.
|
|
51
|
+
|
|
52
|
+
Write one root specification containing the accepted scope, adoption/decomposition,
|
|
53
|
+
waves, acceptance criteria, and integration test. When the config-armed root design gate
|
|
54
|
+
applies, run this exact sequence **before any Legion-role spawn**, including a
|
|
55
|
+
sub-architect:
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
legion({ op: "post_spec", issue: "<root issue>", body: "<root specification>" })
|
|
59
|
+
legion({ op: "label_add", issue: "<root issue>", label: "needs-approval" })
|
|
60
|
+
envoy_dispatch({
|
|
61
|
+
parent: "<root issue>",
|
|
62
|
+
subject: "Legion design approval requested",
|
|
63
|
+
body: "<summary, specification, and requested decision>"
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Then park. Do not release a wave or spawn a Legion role until a later delivered wake
|
|
68
|
+
shows `human-approved` on the root. You never add that label yourself. Approval covers
|
|
69
|
+
the entire tree: later waves, re-scopes, and integration-failure children do not repeat
|
|
70
|
+
this sequence.
|
|
71
|
+
|
|
72
|
+
## 2. Children in flight
|
|
73
|
+
|
|
74
|
+
Release only the next useful wave, then give its owners their work. A release is an
|
|
75
|
+
explicit lifecycle write:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
legion({ op: "wave_release", children: ["owner/repo#41", "owner/repo#42"] })
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
After release, spawn each relevant owner with an issue-prefixed task; for example:
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
task({
|
|
85
|
+
agent: "legion-architect",
|
|
86
|
+
task: "Legion-Issue: owner/repo#41\nOwn this child through its lifecycle and report its evidence."
|
|
87
|
+
})
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Do not add a `<legion-spawn>` block. Keep the child agent IDs and session identifiers
|
|
91
|
+
returned by `task`, because retro and adjustment use those live sessions. Park while
|
|
92
|
+
children are in flight. On each child closure, re-scope open work, close obsolete work
|
|
93
|
+
with a reason, and release the next wave only when it now makes sense. There is no
|
|
94
|
+
inter-child dependency mechanism to encode.
|
|
95
|
+
|
|
96
|
+
## 3. Children complete
|
|
97
|
+
|
|
98
|
+
Treat `children-complete` as the edge into the end-game, not as a reason to close the
|
|
99
|
+
parent. Launch one **fresh** `legion-tester` for the parent, scoped to the parent's own
|
|
100
|
+
acceptance criteria and current `main` integration surface:
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
task({
|
|
104
|
+
agent: "legion-tester",
|
|
105
|
+
task: "Legion-Issue: owner/repo#40\nFreshly verify this parent issue against its acceptance criteria on current main; return reproducible integration evidence."
|
|
106
|
+
})
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
If that tester finds a failure, create and release a new corrective child wave, then
|
|
110
|
+
return to children-in-flight. Do not downgrade the parent criterion or silently carry the
|
|
111
|
+
failure forward.
|
|
112
|
+
|
|
113
|
+
## 4. Integration verification
|
|
114
|
+
|
|
115
|
+
Read the fresh tester's evidence, not merely a child PR's check status. The parent test
|
|
116
|
+
is successful only when every parent acceptance criterion has evidence against current
|
|
117
|
+
main. Route a failed criterion into a corrective child wave; route a passing result to
|
|
118
|
+
review and the merge-gate sequence.
|
|
119
|
+
|
|
120
|
+
## 5. Retro
|
|
121
|
+
|
|
122
|
+
Retro is mandatory for every issue that passed review, before merge. Revive the parked
|
|
123
|
+
implementer that owns the reviewed work through `hub`, naming the skill in the message:
|
|
124
|
+
|
|
125
|
+
```text
|
|
126
|
+
hub({
|
|
127
|
+
op: "send",
|
|
128
|
+
to: "<implementer agent identifier>",
|
|
129
|
+
message: "Run the legion-retro skill now. Capture durable learnings and post the issue comment; do not create a .legion handoff file."
|
|
130
|
+
})
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Wait for the revived implementer to report its durable retro result. Retro output is
|
|
134
|
+
`docs/solutions/` plus an issue comment; it must not create a `.legion` file or change
|
|
135
|
+
the reviewer-approved head after cleanup.
|
|
136
|
+
|
|
137
|
+
## 6. Architect sign-off and final merge gate
|
|
138
|
+
|
|
139
|
+
Sign off only when scope is fully met, integration evidence is current, corrective work
|
|
140
|
+
is complete, review is clean, retro completed, and no necessary work was silently
|
|
141
|
+
deferred. Make the sign-off comment explicit about that evidence.
|
|
142
|
+
|
|
143
|
+
When the config-armed final merge gate applies, preserve this order exactly:
|
|
144
|
+
|
|
145
|
+
1. tester green and review cycles complete;
|
|
146
|
+
2. reviewer pushes the `.legion/` deletion as its final commit and approves that head;
|
|
147
|
+
3. retro completes without dirtying the branch;
|
|
148
|
+
4. enter the Sami-approval step by calling
|
|
149
|
+
`legion({ op: "merge_gate", pr: <pull request number> })`. The daemon performs one
|
|
150
|
+
current GitHub review read against the pinned head. If it returns `approved: true`, the
|
|
151
|
+
approval already satisfies the gate and you immediately continue to the merger; do not
|
|
152
|
+
wait for a new wake. If it returns `approved: false`, request or retain Sami approval
|
|
153
|
+
and park for a later `pr-ready` wake. Do not poll or retry this check;
|
|
154
|
+
5. `legion-merger` verifies the approved head and squash-merges without pushing.
|
|
155
|
+
|
|
156
|
+
If anything changes the approved head, return to review; do not ask the merger to merge
|
|
157
|
+
an obsolete approval.
|
|
158
|
+
|
|
159
|
+
## 7. Close
|
|
160
|
+
|
|
161
|
+
After the merge result and sign-off are recorded, close this issue through the Legion
|
|
162
|
+
write surface and include the sign-off comment:
|
|
163
|
+
|
|
164
|
+
```text
|
|
165
|
+
legion({
|
|
166
|
+
op: "issue_close",
|
|
167
|
+
issue: "owner/repo#40",
|
|
168
|
+
comment: "<sign-off: scope, integration evidence, review, retro, Sami approval, and merge>"
|
|
169
|
+
})
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Closing a child supplies the closure event to its parent. Do not close a parent until the
|
|
173
|
+
entire end-game sequence has completed.
|
|
174
|
+
|
|
175
|
+
## Wake routing
|
|
176
|
+
|
|
177
|
+
Handle one delivered wake by verifying the relevant live artifact and then performing the
|
|
178
|
+
corresponding lifecycle procedure.
|
|
179
|
+
|
|
180
|
+
| Wake | Procedure |
|
|
181
|
+
| --- | --- |
|
|
182
|
+
| `child-closed` | Read the child completion and remaining open children. Re-scope or close obsolete open work; release an appropriate next wave, or await `children-complete`. |
|
|
183
|
+
| `children-complete` | Execute steps 3–4: fresh parent integration verification; failures become a new child wave, success advances to review and retro. |
|
|
184
|
+
| `child-reopened` | Treat the completion edge as reset. Reassess the reopened child and return the tree to children-in-flight; do not continue an already-started end-game. |
|
|
185
|
+
| `pr-ready` | Verify the live PR head, green status, and review state. Continue the review/retro/Sami/merger order only for that current head. |
|
|
186
|
+
| `pr-blocked` | Read the failed CI evidence and recovery attempts. Assign a focused implementer or corrective child, then return it through testing and review; do not treat the blocked PR as final. |
|
|
187
|
+
| `pr-closed-unmerged` | Decide from current scope whether to reopen the work, send a fresh implementer, or cancel it with a reason. Delegate the repository action to the responsible phase worker and keep ownership. |
|
|
188
|
+
| `issue-comment` | Interpret the comment in the issue's design context. Answer it, adjust the plan, or relay it through `hub` to the responsible worker; scope and product decisions remain with you. |
|
|
189
|
+
| `dispatch-reply` | Resolve the question that opened the thread, record the resulting decision in the tree's work, and direct the affected worker through `hub`. |
|
|
190
|
+
| `catchup-overseer` | Verify its gates, child counts, and PR verdicts against current artifacts, then resume the applicable numbered lifecycle step. It is a current-state snapshot, not a raw-event replay. |
|
|
191
|
+
| `revive-worker` | The extension has revived the backed worker. Do not create a duplicate; direct the restored worker through `hub` if action is needed and rely on its committed handoff over recollection. |
|
|
192
|
+
| `reopened` | Reopen the root lifecycle: inspect the reason and current artifacts, reassess scope and children, and resume at the first applicable numbered step. |
|
|
193
|
+
|
|
194
|
+
## Escalation judgment
|
|
195
|
+
|
|
196
|
+
Controller-actionable matters are exactly re-filing a genuinely independent child,
|
|
197
|
+
capacity, and cross-tree conflict. Use the Legion escalation operation for those. Handle
|
|
198
|
+
everything else in the tree or, for a human question, use `envoy_dispatch`; workers never
|
|
199
|
+
open dispatch threads. Do not create a wait loop for any wake source.
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legion-controller
|
|
3
|
+
description: Use when handling Legion controller wakes for root-issue triage, backlog admission, architect escalation, resync healing, human interaction, or gate approval.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Legion Controller
|
|
7
|
+
|
|
8
|
+
The controller is the one persistent, wake-driven session for a Legion project. It makes
|
|
9
|
+
triage, escalation, and human-interaction judgments; it never does phase-worker work or
|
|
10
|
+
routes raw events into an architect.
|
|
11
|
+
|
|
12
|
+
## Start and claim the controller role
|
|
13
|
+
|
|
14
|
+
The Legion extension claims `legion-<project>-controller` and registers controller readiness
|
|
15
|
+
with the daemon during session startup. Do not handle a wake unless that startup succeeded.
|
|
16
|
+
|
|
17
|
+
For an interactive takeover, start OMP with `LEGION_CONTROLLER_SECRET` and
|
|
18
|
+
`LEGION_DAEMON_URL` in its environment, then run:
|
|
19
|
+
|
|
20
|
+
```text
|
|
21
|
+
/legion-claim-controller
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The command resolves the project from daemon state, claims the Envoy role for the current
|
|
25
|
+
session, and posts readiness before controller commands can act. It retains the environment
|
|
26
|
+
capability for `legion admit`, `legion approve`, and `legion backlog`. Never pass a secret as a
|
|
27
|
+
command argument or copy it into a transcript.
|
|
28
|
+
|
|
29
|
+
This handshake lets the daemon redeliver held controller work. It does not turn the controller
|
|
30
|
+
into a state holder: daemon state and GitHub artifacts remain authoritative.
|
|
31
|
+
|
|
32
|
+
## Turn discipline
|
|
33
|
+
|
|
34
|
+
- **Direct user message always first.** If this turn includes a direct user message, answer
|
|
35
|
+
it before handling every other wake.
|
|
36
|
+
- **One wake = one turn.** Handle exactly the wake's implication, then end the turn. Never
|
|
37
|
+
poll, idle-loop, or wait for another event.
|
|
38
|
+
- **Wakes are advisory.** Before any side effect, verify the current daemon state and the
|
|
39
|
+
relevant GitHub artifact. A stale or duplicate wake may cost a read, never a wrong action.
|
|
40
|
+
- **Controller state is disposable.** Do not reconstruct or preserve local controller
|
|
41
|
+
bookkeeping between turns.
|
|
42
|
+
|
|
43
|
+
## Wake routing table
|
|
44
|
+
|
|
45
|
+
| Wake | Content | Controller action |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| New issue added to the project board (webhook: issue opened / project item added; resync heals misses) | issue ref + triage context (incl. pre-existing children) | Triage: spawn root process via daemon admission, or park in the daemon-state backlog |
|
|
48
|
+
| Backlog eligibility | slot freed / priority change | Reconsider parked items; deliberately-backlogged issues carry a marker so resync doesn't re-flag them |
|
|
49
|
+
| Architect escalation (controller-actionable only: re-file a child as a root issue, capacity, cross-tree conflicts) | request + context | Judge and act; human Q&A never routes here — architects open dispatch threads |
|
|
50
|
+
| Resync report | artifact-driven anomaly list (zero-owner trees, erroring issues) | Verify against fresh state, then dispatch/heal |
|
|
51
|
+
| Mention | Slack/GitHub @mention text | Answer, or route to the owning issue's architect role |
|
|
52
|
+
| Approval interpretation | ambiguous human comment on a gated issue | Decide whether it's an approval; if so, apply `human-approved` via the daemon |
|
|
53
|
+
| Direct user message | — | Always first |
|
|
54
|
+
|
|
55
|
+
## New issue triage
|
|
56
|
+
|
|
57
|
+
1. Read `legion state --json`, then inspect the reported GitHub issue with `gh issue view`.
|
|
58
|
+
Verify the issue is on this project board, is eligible for a root process, and whether it
|
|
59
|
+
has pre-existing children. GitHub and daemon state, not the wake text, decide triage.
|
|
60
|
+
2. If it should run now, admit the root issue:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
legion admit <issue>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
3. If it should deliberately wait, record a durable reason instead of leaving it unowned:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
legion backlog <issue> --marker <reason>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The marker is required: it distinguishes intentional backlog from a missed wake during
|
|
73
|
+
resync. Do not triage a system-created child as a root issue.
|
|
74
|
+
|
|
75
|
+
## Backlog eligibility
|
|
76
|
+
|
|
77
|
+
When a slot frees or priority changes, use `legion state --json` and the current issue
|
|
78
|
+
artifact to reconsider marked backlog entries. Admit the selected root with `legion admit
|
|
79
|
+
<issue>`. Keep an item backlogged only with a current, explicit marker; changing the marker
|
|
80
|
+
is a deliberate controller decision, not a no-op.
|
|
81
|
+
|
|
82
|
+
## Architect escalation
|
|
83
|
+
|
|
84
|
+
Only decide controller-actionable escalations: re-filing independent work, capacity, and
|
|
85
|
+
cross-tree conflicts. Architects handle ordinary human Q&A through their own dispatch
|
|
86
|
+
threads.
|
|
87
|
+
|
|
88
|
+
For an independence judgment, verify the child and its parent against GitHub and current
|
|
89
|
+
daemon state. If the work belongs in an independent root:
|
|
90
|
+
|
|
91
|
+
1. File a **fresh root issue** with `gh`, carrying the necessary context.
|
|
92
|
+
2. Close the child and leave a pointer to the new root issue.
|
|
93
|
+
3. Admit or deliberately backlog the new root through the normal triage procedure.
|
|
94
|
+
|
|
95
|
+
Never promote a child in place. Resolve capacity and cross-tree conflicts from verified
|
|
96
|
+
state, routing design decisions back to the owning architect when they are not controller
|
|
97
|
+
judgments.
|
|
98
|
+
|
|
99
|
+
## Resync report
|
|
100
|
+
|
|
101
|
+
Treat a resync report as an anomaly list, not an instruction. For every zero-owner tree or
|
|
102
|
+
erroring issue it names, verify `legion state --json` and the current GitHub artifact first.
|
|
103
|
+
Then heal the verified condition: admit an eligible root, restore a deliberately backlogged
|
|
104
|
+
marker, or use the applicable daemon control path. Do not act on erroring or stale entries
|
|
105
|
+
until their source artifact explains the anomaly.
|
|
106
|
+
|
|
107
|
+
## Mentions
|
|
108
|
+
|
|
109
|
+
Read the mention and its artifact. Answer it when it asks the controller for triage or
|
|
110
|
+
human-facing information. Otherwise resolve the authoritative owning architect role and
|
|
111
|
+
route the verified context with `envoy_publish`. Do not route raw event traffic or invent a
|
|
112
|
+
role token from a partial issue reference.
|
|
113
|
+
|
|
114
|
+
## Approval interpretation
|
|
115
|
+
|
|
116
|
+
For an ambiguous human comment on a gated issue, verify the current issue, gate state, and
|
|
117
|
+
comment's meaning. If it is Sami's approval, apply the daemon transition:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
legion approve <issue>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
This applies `human-approved` and clears `needs-approval` atomically. It is not a generic
|
|
124
|
+
label-edit operation. The design gate remains skill-enforced by the architect, and the
|
|
125
|
+
merge gate remains config-armed until Sami approves the final reviewed head.
|
|
126
|
+
|
|
127
|
+
## Label vocabulary
|
|
128
|
+
|
|
129
|
+
Use only the project labels below, with their stated ownership:
|
|
130
|
+
|
|
131
|
+
| Label | Applied by | Removed by | Meaning |
|
|
132
|
+
|---|---|---|---|
|
|
133
|
+
| `needs-approval` | architect | controller/Sami when applying `human-approved` | design gate armed, awaiting Sami |
|
|
134
|
+
| `human-approved` | Sami or controller | Sami | design gate open |
|
|
135
|
+
| `legion-child` | daemon | never | system-created child |
|
|
136
|
+
| `legion-backlog` | controller | controller | deliberately unowned root |
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legion-oracle
|
|
3
|
+
description: Research institutional knowledge before escalating questions to users. Check docs/solutions/ and codebase patterns before asking humans.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Legion Oracle
|
|
7
|
+
|
|
8
|
+
Research institutional knowledge before escalating questions to users.
|
|
9
|
+
|
|
10
|
+
## Core Principle
|
|
11
|
+
|
|
12
|
+
**Check docs/solutions/ first.** This codebase captures learnings from past work.
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
|
|
16
|
+
```dot
|
|
17
|
+
digraph oracle_decision {
|
|
18
|
+
"About to ask user a question?" [shape=diamond];
|
|
19
|
+
"Is it a preference/requirement?" [shape=diamond];
|
|
20
|
+
"Might be documented?" [shape=diamond];
|
|
21
|
+
"Ask user directly" [shape=box];
|
|
22
|
+
"Use oracle" [shape=box];
|
|
23
|
+
|
|
24
|
+
"About to ask user a question?" -> "Is it a preference/requirement?" [label="yes"];
|
|
25
|
+
"About to ask user a question?" -> "Ask user directly" [label="no - not asking"];
|
|
26
|
+
"Is it a preference/requirement?" -> "Ask user directly" [label="yes"];
|
|
27
|
+
"Is it a preference/requirement?" -> "Might be documented?" [label="no"];
|
|
28
|
+
"Might be documented?" -> "Use oracle" [label="yes"];
|
|
29
|
+
"Might be documented?" -> "Ask user directly" [label="no"];
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Use oracle for:** patterns, conventions, solved problems, technical approaches
|
|
34
|
+
|
|
35
|
+
**Ask directly for:** preferences, requirements, scope decisions, human judgment
|
|
36
|
+
|
|
37
|
+
## Research Strategy
|
|
38
|
+
|
|
39
|
+
Run steps 1-2 first (parallel OK), then 3-4 if needed:
|
|
40
|
+
|
|
41
|
+
| Step | Tool | Query |
|
|
42
|
+
|------|------|-------|
|
|
43
|
+
| 1. Institutional learnings | `Task learnings-researcher` | Search docs/solutions/ for [question] |
|
|
44
|
+
| 2. Codebase patterns | `Task Explore` | Find how src/ handles [topic] |
|
|
45
|
+
| 3. Framework docs | Context7 MCP | resolve-library-id → query-docs |
|
|
46
|
+
| 4. External practices | `Task best-practices-researcher` or `WebSearch` | Current best practices for [topic] |
|
|
47
|
+
|
|
48
|
+
## Output
|
|
49
|
+
|
|
50
|
+
**Found:** Answer with source (file:line or URL)
|
|
51
|
+
|
|
52
|
+
**Not found:** "Checked docs/solutions/ and codebase - no relevant learnings found" → search externally OR escalate to user
|
|
53
|
+
|
|
54
|
+
## Example
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
/legion-oracle How should I handle GraphQL pagination?
|
|
58
|
+
|
|
59
|
+
[learnings-researcher] → No matches
|
|
60
|
+
[Explore] → Found src/legion/state/fetch.py uses cursor-based pagination
|
|
61
|
+
|
|
62
|
+
Answer: Use cursor-based pagination per src/legion/state/fetch.py:42
|
|
63
|
+
```
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legion-retro
|
|
3
|
+
description: Use when an issue has passed review and its parked implementer is revived for the mandatory pre-merge Legion retrospective.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Legion Retro
|
|
7
|
+
|
|
8
|
+
Retro is mandatory for every issue that passed review. The architect revives the parked
|
|
9
|
+
implementer so the person with implementation context performs the retrospective, and the
|
|
10
|
+
skill obtains a separate fresh-eyes perspective. Retro runs before merge.
|
|
11
|
+
|
|
12
|
+
## Merge-gate ordering
|
|
13
|
+
|
|
14
|
+
Follow this ordering exactly. It keeps the reviewed branch clean while preserving the
|
|
15
|
+
retrospective's durable output.
|
|
16
|
+
|
|
17
|
+
1. Tester green and all code-review cycles finish.
|
|
18
|
+
2. The reviewer removes `.legion/`, pushes that deletion as its final commit, then approves.
|
|
19
|
+
3. Run this retro: commit durable learnings to `docs/solutions/` and post the issue comment.
|
|
20
|
+
Retro writes **no `.legion` file**, so it never re-dirties the cleaned handoff tree.
|
|
21
|
+
4. Sami approves the final reviewed head.
|
|
22
|
+
5. The merger squash-merges and pushes nothing.
|
|
23
|
+
|
|
24
|
+
Do not start retro before step 2, skip it because the change seems mechanical, or merge before
|
|
25
|
+
steps 3 and 4. The design gate is not a substitute for this final merge gate.
|
|
26
|
+
|
|
27
|
+
## Two perspectives
|
|
28
|
+
|
|
29
|
+
1. Re-read the issue, its acceptance criteria, the PR, test evidence, and review evidence.
|
|
30
|
+
Do not rebase or create a new branch; work on the existing issue branch.
|
|
31
|
+
2. Spawn one fresh-eyes subagent. Give it the issue and PR, ask it to inspect the diff and
|
|
32
|
+
return concrete reusable learnings, and require it to return analysis rather than edit files.
|
|
33
|
+
3. Independently record the implementer's perspective: surprising constraints, difficult
|
|
34
|
+
decisions, failed approaches, and reusable patterns.
|
|
35
|
+
4. Integrate the two perspectives. The implementer owns the final judgment: reject generic or
|
|
36
|
+
context-free suggestions and preserve only learning that will help a future worker.
|
|
37
|
+
|
|
38
|
+
## Durable outputs
|
|
39
|
+
|
|
40
|
+
Write the integrated learning as one or more discoverable documents under `docs/solutions/`.
|
|
41
|
+
Organize by reusable topic rather than by pull request. Each document uses this front matter:
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
---
|
|
45
|
+
title: "Descriptive title matching the H1"
|
|
46
|
+
category: subdirectory-name
|
|
47
|
+
tags:
|
|
48
|
+
- searchable-topic
|
|
49
|
+
date: YYYY-MM-DD
|
|
50
|
+
status: active
|
|
51
|
+
module: affected-module
|
|
52
|
+
related_issues:
|
|
53
|
+
- "owner/repo#123"
|
|
54
|
+
---
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Commit the documentation on the existing issue branch, advance its existing bookmark, and push
|
|
58
|
+
that branch. Do not create a replacement branch or bookmark. Then post an issue comment naming
|
|
59
|
+
the documents and the one-to-three most useful takeaways. The comment must carry this revived
|
|
60
|
+
implementer's structured attribution footer with `phase` set to `retro`:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
legion gh -- issue comment <issue-number> \
|
|
64
|
+
--body $'## Retro Complete
|
|
65
|
+
|
|
66
|
+
**Learnings documented in:**
|
|
67
|
+
- docs/solutions/<path>.md
|
|
68
|
+
|
|
69
|
+
**Key takeaways:**
|
|
70
|
+
- <reusable lesson>
|
|
71
|
+
|
|
72
|
+
<!-- legion: {"session":"<session-id>","phase":"retro"} -->' \
|
|
73
|
+
--repo <owner>/<repo>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The issue comment and `docs/solutions/` commit are the only retro outputs. Never write a
|
|
77
|
+
handoff, phase artifact, local feedback log, or completion label.
|
|
78
|
+
|
|
79
|
+
## Completion check
|
|
80
|
+
|
|
81
|
+
Before returning, verify all of the following:
|
|
82
|
+
|
|
83
|
+
- The reviewer cleanup commit remains below the retro documentation commit.
|
|
84
|
+
- The learning documents and issue comment both exist.
|
|
85
|
+
- No `.legion` file was created or modified by retro.
|
|
86
|
+
- The fresh-eyes analysis was considered alongside the implementer's context.
|
|
87
|
+
- Sami's approval and the merger remain subsequent steps, not work performed by retro.
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legion-worker
|
|
3
|
+
description: Use when dispatched as an architect, plan, implement, test, or review phase worker in a Legion issue workspace.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Legion Phase Worker
|
|
7
|
+
|
|
8
|
+
You are one phase in a shared issue workspace, not a dispatcher or pipeline coordinator. The
|
|
9
|
+
architect owns the tree; phases use the same jj workspace sequentially. Complete the phase
|
|
10
|
+
assigned in the prompt, return its structured output to the architect, and leave the durable
|
|
11
|
+
copy that the next phase can trust.
|
|
12
|
+
|
|
13
|
+
## Identity, scope, and role
|
|
14
|
+
|
|
15
|
+
The dispatch supplies the issue, phase, daemon-minted role token, workspace, and task
|
|
16
|
+
`outputSchema`. At startup, claim that role with `envoy_role_set`; never construct a role
|
|
17
|
+
token from an issue name. A claim survives parking, and a revived or re-created worker claims
|
|
18
|
+
its own role again.
|
|
19
|
+
|
|
20
|
+
Read the current issue and its acceptance criteria before changing the workspace. Work only
|
|
21
|
+
on this phase's artifact. You may use ordinary scouts, reviewers, and oracle subagents for
|
|
22
|
+
phase work; never spawn legion-role workers or open human dispatch threads. Escalate a product,
|
|
23
|
+
scope, cross-phase, or human decision to the owning architect through hub, with the verified
|
|
24
|
+
facts and the decision needed.
|
|
25
|
+
|
|
26
|
+
## Workspace and handoff precedence
|
|
27
|
+
|
|
28
|
+
The `workspace` attribute in your `<legion-spawn>` block is the authoritative issue
|
|
29
|
+
workspace. Before reading repository files or handoffs, you **MUST** bind to that exact
|
|
30
|
+
path with:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
cd -- "<workspace>" && jj -R "<workspace>" status
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Never rely on the inherited cwd. Every later repository shell command **MUST** begin
|
|
37
|
+
`cd -- "<workspace>" &&`; every jj command **MUST** use `-R "<workspace>"`; and native
|
|
38
|
+
filesystem tool paths **MUST** be absolute under that workspace. Do not create an isolated
|
|
39
|
+
worktree, change the workspace topology, or mix another issue's work into it. Concurrent
|
|
40
|
+
issues have disjoint workspaces; phases for this issue are sequential.
|
|
41
|
+
|
|
42
|
+
On every start, and especially after revival or re-creation, read the issue and then the
|
|
43
|
+
committed predecessor handoffs in lifecycle order from `<workspace>/.legion/`:
|
|
44
|
+
|
|
45
|
+
1. `architect.json`
|
|
46
|
+
2. `plan.json`
|
|
47
|
+
3. `implement.json`
|
|
48
|
+
4. `test.json`
|
|
49
|
+
5. `review.json`
|
|
50
|
+
|
|
51
|
+
Read only files that precede the assigned phase. The live path returns JSON matching the task
|
|
52
|
+
`outputSchema` directly to the architect. The durable path uses the **same schema** in
|
|
53
|
+
`<workspace>/.legion/<phase>.json`. If a committed handoff conflicts with memory or a prior
|
|
54
|
+
transcript, the committed file wins: it is the copy that survived.
|
|
55
|
+
|
|
56
|
+
## jj Safety Rules
|
|
57
|
+
|
|
58
|
+
- **Always `jj -R "<workspace>" new` to create isolated commits.** Never
|
|
59
|
+
`jj -R "<workspace>" edit @-` to go back to a parent — this changes what `@` points to
|
|
60
|
+
and makes `jj abandon` dangerous.
|
|
61
|
+
- **Never `jj -R "<workspace>" abandon`.** If a mistake would require abandoning work,
|
|
62
|
+
stop and send the owning architect the `jj -R "<workspace>" log` evidence.
|
|
63
|
+
- **Before pushing, check ancestry:** `jj -R "<workspace>" log -r 'ancestors(@, 5)'` —
|
|
64
|
+
verify only your issue's commits are in the chain, not unrelated work.
|
|
65
|
+
|
|
66
|
+
**Shared operation safety:** Never run `jj op restore` in a Legion workspace. It rewrites the
|
|
67
|
+
shared operation log. If a mistake reaches that point, stop and send the owning architect the
|
|
68
|
+
`jj -R "<workspace>" log` evidence; recover only through the approved, path-scoped workflow.
|
|
69
|
+
|
|
70
|
+
## Phase work
|
|
71
|
+
|
|
72
|
+
Follow the repository's normal engineering workflow and the assigned issue's acceptance criteria.
|
|
73
|
+
The dispatch output schema defines the phase artifact and completion evidence. Do not replace
|
|
74
|
+
architect-owned decomposition, gate discipline, scheduling, or human communication with labels
|
|
75
|
+
or a local status model.
|
|
76
|
+
|
|
77
|
+
Commit attribution is automatic: the Legion extension exports a `JJ_CONFIG` overlay at root
|
|
78
|
+
bootstrap, so every jj commit made in the session family carries an `Omp-Session: <root-session-id>`
|
|
79
|
+
trailer with no action from you. Do not add attribution trailers by hand.
|
|
80
|
+
|
|
81
|
+
The jj configuration already supplies the phase worker's plus-addressed author and committer
|
|
82
|
+
identity. Do not override Git identity configuration. The worker session receives the
|
|
83
|
+
credential capability it needs; invoke GitHub through the credential helper:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
legion gh -- <gh args…>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## GitHub comment attribution
|
|
90
|
+
|
|
91
|
+
Append this exact structured footer to **every** GitHub issue comment, pull-request comment,
|
|
92
|
+
and review that this phase posts. It preserves session provenance on the artifact itself so
|
|
93
|
+
work stays attributable to the session that produced it:
|
|
94
|
+
|
|
95
|
+
```html
|
|
96
|
+
<!-- legion: {"session":"<session-id>","phase":"<phase>"} -->
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
For example:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
legion gh -- issue comment <issue-number> \
|
|
103
|
+
--body $'Verification complete.\n\n<!-- legion: {"session":"<session-id>","phase":"<phase>"} -->' \
|
|
104
|
+
--repo <owner>/<repo>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Implementer push and pull request
|
|
108
|
+
|
|
109
|
+
Only the implementer creates the issue bookmark, pushes it, and opens the pull request. After
|
|
110
|
+
its implementation commit and verification, it uses this exact branch name and push procedure:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
cd -- "<workspace>" && \
|
|
114
|
+
jj -R "<workspace>" bookmark set legion/issue-<n> && \
|
|
115
|
+
jj -R "<workspace>" git push --bookmark legion/issue-<n> --allow-new
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The provisioned issue workspace configures `credential.helper` with the daemon's absolute
|
|
119
|
+
credential command, so `jj -R "<workspace>" git push` authenticates transparently through the
|
|
120
|
+
same session capability. Never handle a token.
|
|
121
|
+
|
|
122
|
+
Then create the pull request with the `github` tool's `pr_create` operation. The credential
|
|
123
|
+
helper and `legion gh` provide the GitHub identity; never export, fetch, or replace a token.
|
|
124
|
+
Other phases advance the existing branch rather than creating a replacement bookmark or PR.
|
|
125
|
+
|
|
126
|
+
## Completion gate: handoff write, verification, and persistence
|
|
127
|
+
|
|
128
|
+
The durable handoff uses the phase-specific fields from the task's `outputSchema` only.
|
|
129
|
+
`--data` must not include `schemaVersion`, `phase`, or `completed`: the CLI generates that
|
|
130
|
+
envelope. Return the **full** schema through the task's structured output, including the
|
|
131
|
+
generated envelope fields.
|
|
132
|
+
|
|
133
|
+
Write the phase-specific handoff:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
cd -- "<workspace>" && \
|
|
137
|
+
legion handoff write --phase <p> --data '<JSON object of phase-specific fields only>'
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Then verify the durable artifact exists:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
test -f "<workspace>/.legion/<phase>.json"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Then commit that exact handoff file onto the issue branch:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
cd -- "<workspace>" && \
|
|
150
|
+
jj -R "<workspace>" split -m "<phase>: record handoff" .legion/<phase>.json
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
If the issue bookmark exists locally, advance it and push it with the provisioned credential
|
|
154
|
+
helper. `--allow-new` also publishes the locally provisioned bookmark on its first push:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
cd -- "<workspace>" && \
|
|
158
|
+
jj -R "<workspace>" bookmark set legion/issue-<n> && \
|
|
159
|
+
jj -R "<workspace>" git push --bookmark legion/issue-<n> --allow-new
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Do not report phase completion until the write, existence check, and handoff commit succeed;
|
|
163
|
+
when an issue branch exists, its push is also required. This is the committed copy the next
|
|
164
|
+
phase reads after revival. The reviewer later removes `.legion/` as its final commit; phase
|
|
165
|
+
workers do not remove it.
|
|
166
|
+
|
|
167
|
+
## Completion and escalation
|
|
168
|
+
|
|
169
|
+
Return the same schema as the durable handoff through the task's structured output. Do not add
|
|
170
|
+
pipeline labels, run a controller loop, or notify a controller with an invented completion
|
|
171
|
+
protocol. A direct worker delivery belongs to its role; overseers receive only derived
|
|
172
|
+
verdicts.
|
|
173
|
+
|
|
174
|
+
When blocked, send the owning architect a concise hub message: issue, phase, verified
|
|
175
|
+
observation, what you tried, and the decision required. Do not dispatch a human thread yourself.
|