@sjawhar/opencode-legion-envoy 1.4.0 → 1.4.2
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/dist/src/server.js
CHANGED
|
@@ -13552,6 +13552,9 @@ function date4(params) {
|
|
|
13552
13552
|
// ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/external.js
|
|
13553
13553
|
config(en_default());
|
|
13554
13554
|
// ../contracts/src/dispatch-api.ts
|
|
13555
|
+
function searchOwnerOf(result) {
|
|
13556
|
+
return result.owner ?? { kind: "issue", key: result.issue.key };
|
|
13557
|
+
}
|
|
13555
13558
|
var DispatchEventSchema = object({
|
|
13556
13559
|
issue_key: string2().nullable(),
|
|
13557
13560
|
artifact_id: string2().nullish(),
|
|
@@ -13713,7 +13716,9 @@ function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false)
|
|
|
13713
13716
|
};
|
|
13714
13717
|
}
|
|
13715
13718
|
var SPEC_SECTIONS = [
|
|
13719
|
+
"Summary",
|
|
13716
13720
|
"Decisions needed",
|
|
13721
|
+
"New since we talked",
|
|
13717
13722
|
"Acceptance",
|
|
13718
13723
|
"Requirements",
|
|
13719
13724
|
"Design",
|
|
@@ -13721,7 +13726,7 @@ var SPEC_SECTIONS = [
|
|
|
13721
13726
|
"Testing",
|
|
13722
13727
|
"Rejected"
|
|
13723
13728
|
];
|
|
13724
|
-
var SPEC_WRITING_GUIDANCE = `When writing a spec, use these sections in order: ${SPEC_SECTIONS.join(", ")}. ` + "
|
|
13729
|
+
var SPEC_WRITING_GUIDANCE = `When writing a spec, use these sections in order: ${SPEC_SECTIONS.join(", ")}. ` + "Write for a reader who has not seen the code: plain sentences, every identifier expanded on " + "first use, no coined shorthand; see skills/dispatch Writing for the human and Writing a spec.";
|
|
13725
13730
|
var ASK_URGENCIES = ["low", "med", "high", "blocking"];
|
|
13726
13731
|
var DOC_EDIT_OPS = ["replace", "delete", "insert"];
|
|
13727
13732
|
var dispatchToolSpecs = [
|
|
@@ -14896,9 +14901,14 @@ function duplicateCandidates(error) {
|
|
|
14896
14901
|
return error.candidates;
|
|
14897
14902
|
}
|
|
14898
14903
|
function searchResultLine(result, baseUrl) {
|
|
14904
|
+
const href = new URL(result.href, baseUrl).toString();
|
|
14905
|
+
const owner = searchOwnerOf(result);
|
|
14906
|
+
if (owner.kind === "document") {
|
|
14907
|
+
const reference = `dispatch://${owner.project}/artifact/${owner.slug}`;
|
|
14908
|
+
return `${reference} [document] ${owner.name} - ${result.kind}: ${snippetText(result.snippet)} -> ${href}`;
|
|
14909
|
+
}
|
|
14899
14910
|
const artifactName = result.artifact ? ` ${result.artifact.name}` : "";
|
|
14900
14911
|
const label = `${result.issue.key} [${result.issue.status}] ${result.issue.title} - ${result.kind}${artifactName}`;
|
|
14901
|
-
const href = new URL(result.href, baseUrl).toString();
|
|
14902
14912
|
return `${label}: ${snippetText(result.snippet)} -> ${href}`;
|
|
14903
14913
|
}
|
|
14904
14914
|
function askUrgency(args) {
|
|
@@ -15812,12 +15822,20 @@ class EnvoyApiError extends Error {
|
|
|
15812
15822
|
function createEnvoyClient(config) {
|
|
15813
15823
|
const baseUrl = normalizeEnvoyUrl(config.baseUrl);
|
|
15814
15824
|
const timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
15825
|
+
const apiToken = process.env["ENVOY_TOKEN"];
|
|
15815
15826
|
const request = async (path, init) => {
|
|
15816
15827
|
const url = `${baseUrl}${path}`;
|
|
15817
15828
|
for (let attempt = 0;attempt < 2; attempt += 1) {
|
|
15818
15829
|
let response;
|
|
15819
15830
|
try {
|
|
15820
|
-
|
|
15831
|
+
const headers = new Headers(init.headers);
|
|
15832
|
+
if (apiToken)
|
|
15833
|
+
headers.set("Authorization", `Bearer ${apiToken}`);
|
|
15834
|
+
response = await config.fetch(url, {
|
|
15835
|
+
...init,
|
|
15836
|
+
headers,
|
|
15837
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
15838
|
+
});
|
|
15821
15839
|
} catch (error) {
|
|
15822
15840
|
if (attempt === 0) {
|
|
15823
15841
|
await waitForRetry();
|
package/package.json
CHANGED
package/skills/dispatch/SKILL.md
CHANGED
|
@@ -13,31 +13,49 @@ The server enforces high signal: an ask question is at most 800 characters with
|
|
|
13
13
|
most 2,000 characters; an artifact is at most 25 MiB. It refuses over-limit input; it never truncates it. GitHub threads and markers no
|
|
14
14
|
longer exist.
|
|
15
15
|
|
|
16
|
+
## Writing for the human
|
|
17
|
+
|
|
18
|
+
Sami, 2026-09-12, on what Legion had been producing: "It's completely incomprehensible. It's just
|
|
19
|
+
compressed jargon nonsense. I have no idea what the fuck it's saying." Every spec, ask, comment,
|
|
20
|
+
message, and PR body is read by a person who has not read the code, does not share this session's
|
|
21
|
+
vocabulary, and is often on a phone. Write for that person.
|
|
22
|
+
|
|
23
|
+
- Plain English, full sentences, one idea per sentence. Never repo shorthand or nouns you coined:
|
|
24
|
+
not "fix 8c", "READY-target", "PR B", "spec@v3", "the pair", "the packet" — say what the thing is.
|
|
25
|
+
- Expand every identifier the first time it appears: an issue key gets its title, a PR number its
|
|
26
|
+
title, a file what it is for, a session id who it is. Link a URL rather than pasting a bare id.
|
|
27
|
+
- Frame a request as current state → desired state → proposed change, with at least two options,
|
|
28
|
+
what each costs, and your recommendation with its reason.
|
|
29
|
+
- Before posting, test it: could Sami, reading only this text on his phone, know what he is being
|
|
30
|
+
told or asked? If not, rewrite it. Length is not the problem; density is.
|
|
31
|
+
|
|
16
32
|
## Writing a spec
|
|
17
33
|
|
|
18
|
-
A spec
|
|
19
|
-
these
|
|
34
|
+
A spec has two readers: the human who decides reads the top; the implementer who builds reads the
|
|
35
|
+
rest. Use these headings in this order.
|
|
20
36
|
|
|
21
37
|
| Section | Required content | Form |
|
|
22
38
|
| --- | --- | --- |
|
|
23
|
-
| **
|
|
24
|
-
| **
|
|
25
|
-
| **
|
|
26
|
-
| **
|
|
27
|
-
| **
|
|
28
|
-
| **
|
|
29
|
-
| **
|
|
39
|
+
| **Summary** | The problem, what changes for whom, and how we will know it worked — in plain words. | Three sentences at most. |
|
|
40
|
+
| **Decisions needed** | Only decisions that need human authority, taste, or risk appetite. Each is one plain question, two or three options with what each costs, and your recommendation with its reason — understandable without opening anything else. Every item is an anchored `dispatch_ask`; an answered item moves into Requirements with its provenance. If there is nothing to decide, write `None: this records what was agreed.` and do not ask for a review. | One decision per line. |
|
|
41
|
+
| **New since we talked** | Every design point the human did not settle in conversation, marked `inferred:` with the reasoning. Empty is fine. | One plain sentence per point. |
|
|
42
|
+
| **Acceptance** | Each outcome names what a user will observe and the check that proves it (browser scenario, API call, or command). An outcome without a check is not acceptance. | Numbered lines. |
|
|
43
|
+
| **Requirements** | What must hold, and where each came from: a quoted human sentence, or `inferred:` plus the reasoning. Readers treat inferred requirements as hypotheses. | `requirement \| where it comes from` table, or prose if the reader follows it more easily. |
|
|
44
|
+
| **Design** | The files, components, routes, and data flow that change. | Prose or tables; a diagram only for real structure. |
|
|
45
|
+
| **Errors** | The behaviour for every error condition. Never a silent fallback. | `condition \| behaviour` table. |
|
|
46
|
+
| **Testing** | Which proof exercises each acceptance line. | One line per acceptance item. |
|
|
47
|
+
| **Rejected** | Each alternative considered and why it was rejected, so it is not proposed again. | One alternative per line. |
|
|
30
48
|
|
|
31
49
|
### Rules
|
|
32
50
|
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
- Do not use TBD, TODO, or placeholders; an open item is a Decision needed.
|
|
51
|
+
- The spec is the issue's one primary document. Extend it in place — a new version that keeps the
|
|
52
|
+
human's own text — never a second "spec" artifact beside it.
|
|
53
|
+
- No hedging ("might", "could consider"). No TBD, TODO, or placeholders: an open item is a
|
|
54
|
+
Decision needed.
|
|
38
55
|
- Keep each section to one screen; work that exceeds one screen per section is two specs.
|
|
39
|
-
- Update the spec
|
|
40
|
-
- Before sending it: no sections conflict,
|
|
56
|
+
- Update the spec as decisions land: the spec is the record, comments are the discussion.
|
|
57
|
+
- Before sending it: no sections conflict, every requirement has exactly one reading, and the
|
|
58
|
+
Summary and Decisions pass the phone test above.
|
|
41
59
|
|
|
42
60
|
## Your owner
|
|
43
61
|
|
|
@@ -60,9 +78,11 @@ Before you create an issue or start a design document, search:
|
|
|
60
78
|
```ts
|
|
61
79
|
dispatch_search({ query, project?, limit? })
|
|
62
80
|
```
|
|
63
|
-
It returns every issue, document, comment, ask, and message that contains the words
|
|
64
|
-
|
|
65
|
-
|
|
81
|
+
It returns every issue, document, comment, ask, and message that contains the words. Issue-owned hit lines
|
|
82
|
+
start with the issue key; standalone project-document hit lines start with
|
|
83
|
+
`dispatch://PROJECT/artifact/<slug>`, followed by the absolute link. Cite the hit you build on
|
|
84
|
+
(`dispatch://KEY` or the document reference), or state "no prior issue" in the spec. Websearch syntax applies:
|
|
85
|
+
`"merge queue"`, `-daemon`, `OR`.
|
|
66
86
|
|
|
67
87
|
`dispatch_issue` refuses a title that near-duplicates an issue in the same project and returns the candidates (`POSSIBLE_DUPLICATE`).
|
|
68
88
|
Read them; reference the existing issue, or repeat the call with `force: true` when it is genuinely new work.
|
|
@@ -83,9 +103,16 @@ dispatch_ask({
|
|
|
83
103
|
})
|
|
84
104
|
```
|
|
85
105
|
It returns `details` `{ issue, topic, ask }` for an issue or `{ project, artifact, document, topic, ask }` for a project document.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
106
|
+
|
|
107
|
+
An ask is read on a phone by someone who has not read the code. Open with one or two plain
|
|
108
|
+
sentences: what needs deciding and why it matters now. Each option is a button with a label and
|
|
109
|
+
one sentence saying what happens if it is chosen; never enumerate choices in prose. Put the
|
|
110
|
+
recommendation and its reason last, in `question`. Never put file paths, line numbers, sequence
|
|
111
|
+
numbers, document versions, or role tokens in the question; if the human needs that detail, anchor
|
|
112
|
+
the ask to the document passage instead. Apply the phone test from "Writing for the human" before
|
|
113
|
+
posting. Anchor a document question with `anchor: { artifact, quote, occurrence? }`; `occurrence`
|
|
114
|
+
is zero-based and selects a repeated quote, and an anchor whose quote later disappears becomes
|
|
115
|
+
orphaned but stays readable against its original document version.
|
|
89
116
|
|
|
90
117
|
An ask must be answerable from its own text and its anchor alone. Anchor a question about a document passage with `anchor`; thread one
|
|
91
118
|
about a comment with `reply_to`; thread a follow-up on your own ask with `reply_to_ask`; cite anything else with a `dispatch://`
|
|
@@ -223,13 +250,14 @@ dispatch_artifact({ issue?, project?, name, path, summary? })
|
|
|
223
250
|
Or, when the text is already in the call, post a Markdown document directly:
|
|
224
251
|
|
|
225
252
|
```ts
|
|
226
|
-
dispatch_artifact({ issue?, project?, name: "
|
|
253
|
+
dispatch_artifact({ issue?, project?, name: "load-test-results.md", content: "# Load test\n..." })
|
|
227
254
|
```
|
|
228
255
|
|
|
229
256
|
Exactly one of `issue` and `project` is required. A project upload creates an unlinked project document; it must not include `artifact`.
|
|
230
257
|
Exactly one of `path` and `content` is required. It returns issue or project-document owner details plus `artifact`, `version`, and its
|
|
231
|
-
write `topic`. Uploading the same `name` creates its next version
|
|
232
|
-
|
|
258
|
+
write `topic`. Uploading the same `name` creates its next version — so uploading `spec.md` **replaces the issue's own specification**
|
|
259
|
+
with your text. Never do that: the spec is edited in place with `dispatch_doc_edit` (see [The Spec](#the-spec)). Address an existing
|
|
260
|
+
artifact by the slug shown in the upload result or by its filename; the slug also arrives on `artifact.created` events.
|
|
233
261
|
|
|
234
262
|
## Messages
|
|
235
263
|
|
|
@@ -75,24 +75,39 @@ Wave releases, child closures, and your own status are visible from the issue tr
|
|
|
75
75
|
handoffs; do not narrate them into the spec or a `dispatch_message`. A blocker only Sami can
|
|
76
76
|
clear is a `dispatch_ask`.
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
The issue's primary document **is** the root specification. Extend it in place — a new version
|
|
79
|
+
that keeps the human's own text and adds Summary, Decisions needed, New since we talked, the
|
|
80
|
+
adoption/decomposition and waves, acceptance criteria, and the integration test — never a second
|
|
81
|
+
"spec" artifact beside it (`dispatch_artifact` with the primary document's name replaces the
|
|
82
|
+
human's document; do not do that). Both readers described in
|
|
83
|
+
[Writing for the human](../dispatch/SKILL.md#writing-for-the-human) must be able to follow it.
|
|
84
|
+
When the config-armed root design gate applies, run this exact sequence **before any
|
|
85
|
+
Legion-role spawn**, including a sub-architect:
|
|
82
86
|
|
|
83
87
|
```text
|
|
84
|
-
|
|
88
|
+
dispatch_doc_edit({ issue: "<root issue>", ... }) // extend the primary document in place
|
|
85
89
|
askId = dispatch_ask({
|
|
86
90
|
issue: "<root issue>",
|
|
87
|
-
question: "<
|
|
88
|
-
options: [
|
|
91
|
+
question: "<what is true today, in one sentence> <what will be true when this lands, in one sentence> <how: one issue or N child issues, and what the first step is> I recommend Approve because <one reason>.",
|
|
92
|
+
options: [
|
|
93
|
+
{ label: "Approve", description: "Work starts as described; the first worker is spawned now." },
|
|
94
|
+
{ label: "Hold", description: "Nothing starts; reply on the issue with what should change first." },
|
|
95
|
+
]
|
|
89
96
|
})
|
|
90
97
|
legion({ op: "register_gate", issue: "<root issue>", askId })
|
|
91
98
|
```
|
|
92
99
|
|
|
100
|
+
Both options are required: a question with only `Approve` is not a decision. The whole ask is
|
|
101
|
+
read on a phone by someone who has not read the code: no file paths, line numbers, document
|
|
102
|
+
versions, or role tokens in it. Sami, 2026-09-12, on a gate ask that broke this rule: "I have no
|
|
103
|
+
idea what the fuck you're talking about."
|
|
104
|
+
|
|
93
105
|
Then park. Do not release a wave or spawn a Legion role until a later delivered wake
|
|
94
|
-
shows `design-approved` on the root.
|
|
95
|
-
|
|
106
|
+
shows `design-approved` on the root. On a deployment whose design gate is off
|
|
107
|
+
(`gates.design: off` in its `legion.yaml`), the daemon satisfies the gate as you register it
|
|
108
|
+
and `design-approved` arrives immediately — proceed; the ask remains open on Dispatch as the
|
|
109
|
+
record and needs no answer. Approval covers the entire tree: later waves, re-scopes, and
|
|
110
|
+
integration-failure children do not repeat this sequence.
|
|
96
111
|
|
|
97
112
|
## 2. Children in flight
|
|
98
113
|
|
|
@@ -44,6 +44,10 @@ into a state holder: daemon state and the Dispatch project remain authoritative.
|
|
|
44
44
|
relevant Dispatch issue. A stale or duplicate wake may cost a read, never a wrong action.
|
|
45
45
|
- **Controller state is disposable.** Do not reconstruct or preserve local controller
|
|
46
46
|
bookkeeping between turns.
|
|
47
|
+
- **Write for a human.** Every `dispatch_comment`, `dispatch_message`, and `dispatch_ask` you
|
|
48
|
+
post follows the dispatch skill's "Writing for the human" rules: plain sentences, every
|
|
49
|
+
identifier expanded on first use, no coined shorthand. A triage note that reads like a log
|
|
50
|
+
line is not a triage note.
|
|
47
51
|
|
|
48
52
|
## Wake routing table
|
|
49
53
|
|