@sjawhar/opencode-legion-envoy 1.43.0 → 1.44.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/dist/src/server.js +44 -6
- package/package.json +1 -1
- package/skills/AGENTS.md +14 -41
- package/skills/dispatch/SKILL.md +16 -3
package/dist/src/server.js
CHANGED
|
@@ -13816,6 +13816,20 @@ function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false)
|
|
|
13816
13816
|
message: alwaysRequireArtifact ? "Exactly one of issue and project is required; artifact or ref must name the document." : "Exactly one of issue and project is required; with project, artifact names the document."
|
|
13817
13817
|
};
|
|
13818
13818
|
}
|
|
13819
|
+
var documentEditValidation = {
|
|
13820
|
+
check: (value) => {
|
|
13821
|
+
if (!documentOwnerValidation(true, true).check(value))
|
|
13822
|
+
return false;
|
|
13823
|
+
const input = value;
|
|
13824
|
+
if (input.precondition === undefined)
|
|
13825
|
+
return true;
|
|
13826
|
+
if (typeof input.precondition !== "object" || input.precondition === null)
|
|
13827
|
+
return false;
|
|
13828
|
+
const precondition = input.precondition;
|
|
13829
|
+
return typeof precondition.document === "string" !== Array.isArray(precondition.blocks);
|
|
13830
|
+
},
|
|
13831
|
+
message: "Exactly one of issue and project is required; artifact or ref must name the document. A precondition selects exactly one of document or blocks."
|
|
13832
|
+
};
|
|
13819
13833
|
var commentOwner = documentOwnerValidation(true);
|
|
13820
13834
|
var commentValidation = {
|
|
13821
13835
|
check: (value) => {
|
|
@@ -14043,9 +14057,10 @@ var dispatchToolSpecs = [
|
|
|
14043
14057
|
example: {
|
|
14044
14058
|
issue: "DSP-1",
|
|
14045
14059
|
artifact: "spec",
|
|
14046
|
-
ops: [{ op: "delete_column", block: "table-123", index: 1 }]
|
|
14060
|
+
ops: [{ op: "delete_column", block: "table-123", index: 1 }],
|
|
14061
|
+
precondition: { blocks: [{ id: "table-123", token: "sha256:current-table-token" }] }
|
|
14047
14062
|
},
|
|
14048
|
-
description: "Apply deterministic document edits: replace or delete quoted text, insert markdown at an anchor, retype an identified paragraph or typed block into a schema-declared typed block, delete or move a whole block by its id, or delete a table row or column in place. " + "Do not use it for review feedback or for reading; use dispatch_comment, dispatch_suggest, or dispatch_doc_read instead. " + "For replace, delete, and quote anchors, find text as rendered: inline Markdown (**bold**, `code`) is tolerated; a leading '# ' matches a heading. replace is inline: with is the new text of the matched span, so a leading list or heading marker stays literal text. " + "A delete whose find is a block's entire text removes the block (a list emptied of its items goes too); delete with block removes any block by id, and move with block relocates one. delete_row and delete_column take a table block and a zero-based index, preserving the table block id and refusing to remove cells with open asks or unresolved comments. " + 'Insert and move anchors also accept "start", "end", "heading:<exact heading text>", and "block:<id>"; block ids
|
|
14063
|
+
description: "Apply deterministic document edits: replace or delete quoted text, insert markdown at an anchor, retype an identified paragraph or typed block into a schema-declared typed block, delete or move a whole block by its id, or delete a table row or column in place. " + "Do not use it for review feedback or for reading; use dispatch_comment, dispatch_suggest, or dispatch_doc_read instead. " + "For replace, delete, and quote anchors, find text as rendered: inline Markdown (**bold**, `code`) is tolerated; a leading '# ' matches a heading. replace is inline: with is the new text of the matched span, so a leading list or heading marker stays literal text. " + "A delete whose find is a block's entire text removes the block (a list emptied of its items goes too); delete with block removes any block by id, and move with block relocates one. delete_row and delete_column take a table block and a zero-based index, preserving the table block id and refusing to remove cells with open asks or unresolved comments. " + 'Insert and move anchors also accept "start", "end", "heading:<exact heading text>", and "block:<id>"; block ids and their tokens come from GET /api/v1/artifacts/{artifact UUID}/blocks (the route takes the artifact UUID, not its slug). ' + "Optionally require the state just read: precondition selects exactly one of a document token from dispatch_doc_read, or block {id, token} values from /blocks. A block guard must include every block the batch changes; Dispatch resolves quote targets and rejects an uncovered batch rather than applying it. Use a document token for insert or move, which depend on document order. Prefer block tokens when the covered content blocks are independent sections. Tokens include inline marks, so a fresh human comment also makes a stale edit fail. PRECONDITION_FAILED means re-read; EDIT_QUEUE_FULL means back off before retrying. " + `The spec (or any document) holds requirements, design, and decisions - never progress, status, or timestamps. ${OWNER_REFERENCE} ${SPEC_WRITING_GUIDANCE}`,
|
|
14049
14064
|
arguments: (z) => ({
|
|
14050
14065
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
14051
14066
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -14064,14 +14079,21 @@ var dispatchToolSpecs = [
|
|
|
14064
14079
|
type: z.string().describe("Typed block name for retype.").optional(),
|
|
14065
14080
|
attributes: z.unknown().describe("Typed block attributes for retype.").optional()
|
|
14066
14081
|
})).describe("Flat tagged edits; the server validates fields required for each operation."),
|
|
14082
|
+
precondition: z.object({
|
|
14083
|
+
document: z.string({ min: 1 }).describe("Token for the exact canonical document returned by dispatch_doc_read.").optional(),
|
|
14084
|
+
blocks: z.array(z.object({
|
|
14085
|
+
id: z.string({ min: 1 }).describe("Stable block id from GET /api/v1/artifacts/{id}/blocks."),
|
|
14086
|
+
token: z.string({ min: 1 }).describe("That block's full-state token, including inline marks.")
|
|
14087
|
+
}), { min: 1 }).describe("Every content block this batch changes, each with the token returned by /blocks.").optional()
|
|
14088
|
+
}).describe("Optional optimistic-concurrency guard; select exactly one of document or blocks.").optional(),
|
|
14067
14089
|
summary: z.string().describe("Optional named-version summary.").optional()
|
|
14068
14090
|
}),
|
|
14069
|
-
validation:
|
|
14091
|
+
validation: documentEditValidation
|
|
14070
14092
|
},
|
|
14071
14093
|
{
|
|
14072
14094
|
name: "dispatch_doc_read",
|
|
14073
14095
|
example: { issue: "DSP-1" },
|
|
14074
|
-
description: "Read a live document or a named document version. Do not use it for issue status, asks, or events; " + "use dispatch_read instead. Supply ref, issue, or project plus artifact; issue plus an omitted artifact reads the primary document. " + OWNER_REFERENCE,
|
|
14096
|
+
description: "Read a live document or a named document version. Do not use it for issue status, asks, or events; " + "use dispatch_read instead. Supply ref, issue, or project plus artifact; issue plus an omitted artifact reads the primary document. " + "A live read returns its document token for an optional dispatch_doc_edit precondition; use /blocks for per-block tokens. " + OWNER_REFERENCE,
|
|
14075
14097
|
arguments: (z) => ({
|
|
14076
14098
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
14077
14099
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -14296,6 +14318,14 @@ var reviewSchema = baseHandoffSchema.extend({
|
|
|
14296
14318
|
verdict: _enum2(["approved", "changes_requested"]).optional(),
|
|
14297
14319
|
keyFindings: array(object({ severity: string2(), file: string2(), description: string2() }).passthrough()).optional()
|
|
14298
14320
|
});
|
|
14321
|
+
var nonEmptySkillList = array(string2().trim().min(1)).min(1);
|
|
14322
|
+
var planWriteSchema = planSchema.extend({
|
|
14323
|
+
requiredSkills: object({
|
|
14324
|
+
implement: nonEmptySkillList,
|
|
14325
|
+
test: nonEmptySkillList,
|
|
14326
|
+
review: nonEmptySkillList
|
|
14327
|
+
}).passthrough()
|
|
14328
|
+
});
|
|
14299
14329
|
var phaseHandoffSchema = discriminatedUnion("phase", [
|
|
14300
14330
|
architectSchema,
|
|
14301
14331
|
planSchema,
|
|
@@ -14919,12 +14949,16 @@ class DispatchServiceError extends Error {
|
|
|
14919
14949
|
code;
|
|
14920
14950
|
status;
|
|
14921
14951
|
candidates;
|
|
14952
|
+
current;
|
|
14953
|
+
mismatches;
|
|
14922
14954
|
name = "DispatchServiceError";
|
|
14923
|
-
constructor(code, status, message, candidates) {
|
|
14955
|
+
constructor(code, status, message, candidates, current, mismatches) {
|
|
14924
14956
|
super(message);
|
|
14925
14957
|
this.code = code;
|
|
14926
14958
|
this.status = status;
|
|
14927
14959
|
this.candidates = candidates;
|
|
14960
|
+
this.current = current;
|
|
14961
|
+
this.mismatches = mismatches;
|
|
14928
14962
|
}
|
|
14929
14963
|
}
|
|
14930
14964
|
function asErrorShape(value) {
|
|
@@ -15236,7 +15270,7 @@ class DispatchClient {
|
|
|
15236
15270
|
}
|
|
15237
15271
|
if (!response.ok) {
|
|
15238
15272
|
const error = asErrorShape(payload);
|
|
15239
|
-
throw new DispatchServiceError(error.code ?? `HTTP_${response.status}`, response.status, error.error ?? (typeof payload === "string" && payload ? payload : response.statusText), error.candidates);
|
|
15273
|
+
throw new DispatchServiceError(error.code ?? `HTTP_${response.status}`, response.status, error.error ?? (typeof payload === "string" && payload ? payload : response.statusText), error.candidates, error.current, error.mismatches);
|
|
15240
15274
|
}
|
|
15241
15275
|
return payload;
|
|
15242
15276
|
}
|
|
@@ -16586,9 +16620,12 @@ ${followsAsk(askOwner)}`,
|
|
|
16586
16620
|
const resolved = await resolveArtifact(client, documentOwner(), stringArg(args, "artifact"));
|
|
16587
16621
|
const ops = args.ops;
|
|
16588
16622
|
const summary = optionalString(args, "summary");
|
|
16623
|
+
const { precondition: rawPrecondition } = args;
|
|
16624
|
+
const precondition = rawPrecondition;
|
|
16589
16625
|
const edited = await client.docEdit(resolved.artifact.id, {
|
|
16590
16626
|
ops,
|
|
16591
16627
|
...summary === undefined ? {} : { summary },
|
|
16628
|
+
...precondition === undefined ? {} : { precondition },
|
|
16592
16629
|
actor
|
|
16593
16630
|
});
|
|
16594
16631
|
const retyped = ops.filter((operation) => operation.op === "retype").length;
|
|
@@ -16616,6 +16653,7 @@ ${followsAsk(askOwner)}`,
|
|
|
16616
16653
|
const marks = marksResult.value;
|
|
16617
16654
|
const approval = approvalLine(resolved.artifact);
|
|
16618
16655
|
const trailer = [
|
|
16656
|
+
..."token" in document && document.token !== undefined ? [`Document token: ${document.token}`] : [],
|
|
16619
16657
|
...marks.length === 0 ? [] : [`Open anchored asks/comments: ${marks.join(", ")}`],
|
|
16620
16658
|
...approval === undefined ? [] : [approval]
|
|
16621
16659
|
];
|
package/package.json
CHANGED
package/skills/AGENTS.md
CHANGED
|
@@ -4,44 +4,17 @@ Legion skills guide the architect and its sequential phase workers in a shared i
|
|
|
4
4
|
They are Markdown instructions loaded by Oh My Pi sessions; the daemon and OMP extension own
|
|
5
5
|
event intake, process lifecycle, credentials, and role delivery.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
The extension supplies a phase worker with its issue, workspace, role token, and structured
|
|
23
|
-
output schema. The worker claims its supplied role, works only on its phase artifact, and
|
|
24
|
-
returns that schema to the architect. It writes the same phase-specific payload to
|
|
25
|
-
`.legion/<phase>.json`, verifies it exists, and commits the handoff before reporting completion.
|
|
26
|
-
The committed predecessor handoff wins after revival or re-creation.
|
|
27
|
-
|
|
28
|
-
Workers do not run a controller loop or mutate lifecycle labels. Workers coordinate
|
|
29
|
-
lifecycle, scope, and cross-phase decisions with the owning architect by `envoy_publish` to its
|
|
30
|
-
role topic, sending the verified observation and decision needed (`hub` reaches only subagents
|
|
31
|
-
inside the worker's own process). A worker may call the native `dispatch_*` tools directly for a
|
|
32
|
-
durable human question; replies come back to the worker's own session.
|
|
33
|
-
|
|
34
|
-
## Durable artifacts
|
|
35
|
-
|
|
36
|
-
Phase handoffs are committed in lifecycle order: architect, plan, implement, test, and review.
|
|
37
|
-
Only the implementer pushes them: it and the merger act as the code-writing GitHub App, while
|
|
38
|
-
the planner, tester, reviewer, and architects act as the review App (`appRoleForLegionRole`,
|
|
39
|
-
`packages/daemon/src/daemon/github-apps.ts`), which holds no `contents` permission — their
|
|
40
|
-
handoff commits stay on the shared workspace's issue branch and ride the implementer's next push.
|
|
41
|
-
A clean review ends with the `.legion/` deletion pushed by the implementer at the reviewer's
|
|
42
|
-
direction, which the reviewer then approves; retro records its learning in
|
|
43
|
-
`docs/solutions/` and writes no handoff. GitHub comments and reviews carry the required Legion
|
|
44
|
-
footer so the daemon can attribute artifacts to their worker session.
|
|
45
|
-
The implement handoff carries the implementer's own production-like proof and the test handoff the
|
|
46
|
-
tester's verdict on it plus the tester's own; `legion handoff write` refuses a payload the phase's
|
|
47
|
-
schema rejects and names the field. Retro's message goes to the Dispatch issue (`dispatch_message`), never a GitHub issue.
|
|
7
|
+
| Skill | Who reads it | What it owns |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `dispatch/` | every role, and any session writing to Dispatch | specs, asks, comments, artifacts, and messages on native Dispatch |
|
|
10
|
+
| `envoy/` | every role | subscriptions, agent-to-agent messages, and topic formats |
|
|
11
|
+
| `legion-architect/` | root and sub-architects | tree ownership, decomposition, waves, gates, integration, sign-off |
|
|
12
|
+
| `legion-controller/` | the controller root process | wake routing, backlog admission, escalation |
|
|
13
|
+
| `legion-oracle/` | any role doing research | repository-grounded research |
|
|
14
|
+
| `legion-retro/` | the implementer, at retro | the pre-merge retrospective and its Dispatch message |
|
|
15
|
+
| `legion-worker/` | planner, implementer, tester, reviewer, merger | the phase contracts: handoffs, GitHub identity, PR body and READY discipline, the merge-gate order |
|
|
16
|
+
|
|
17
|
+
The owning skill above is where each contract is defined; a role prompt that needs a contract from its own seat points there or restates only its own step. This file lists and does not restate.
|
|
18
|
+
The text a worker boots with (its role prompt) lives in `packages/pi-envoy/roles/` and is
|
|
19
|
+
composed per role in `packages/daemon/src/daemon/processes.ts`; `packages/pi-envoy/roles/roles.test.ts`
|
|
20
|
+
holds the structural rules for those parts.
|
package/skills/dispatch/SKILL.md
CHANGED
|
@@ -381,11 +381,12 @@ Read the current document before changing it:
|
|
|
381
381
|
```ts
|
|
382
382
|
dispatch_doc_read({ issue?, project?, artifact?, version?, ref? })
|
|
383
383
|
```
|
|
384
|
-
It returns live or versioned markdown with open marks.
|
|
385
|
-
`artifact
|
|
384
|
+
It returns live or versioned markdown with open marks. A live read ends with a document token; `issue` with an
|
|
385
|
+
omitted `artifact` reads the issue specification; a project needs `artifact`; and a
|
|
386
|
+
`dispatch://PROJECT/artifact/<document-ref>` ref supplies both, where `document-ref` is the id, slug, or filename.
|
|
386
387
|
|
|
387
388
|
```ts
|
|
388
|
-
dispatch_doc_edit({ issue?, project?, artifact, ops, summary? })
|
|
389
|
+
dispatch_doc_edit({ issue?, project?, artifact, ops, precondition?, summary? })
|
|
389
390
|
```
|
|
390
391
|
It returns issue or project-document owner details plus `applied` and optional `version`. `ops` is an array of this
|
|
391
392
|
exact `EditOp` shape:
|
|
@@ -445,6 +446,18 @@ an earlier `delete {block}` fails as `INVALID_OP` naming the earlier operation a
|
|
|
445
446
|
whose anchor lies inside the moved block, or a delete that would leave a typed block without the body its content rule requires, is
|
|
446
447
|
`INVALID_OP` naming the field and the rule.
|
|
447
448
|
|
|
449
|
+
`GET /api/v1/artifacts/<artifact UUID>/blocks` includes a full-state `token` on every block, including
|
|
450
|
+
inline marks. To reject a stale edit, pass `precondition` with exactly one of
|
|
451
|
+
`{ document: "<token from dispatch_doc_read>" }` or
|
|
452
|
+
`{ blocks: [{ id: "<block id>", token: "<block token>" }] }`. The server resolves the whole batch before
|
|
453
|
+
mutation: a block guard must cover every content block it changes, or Dispatch returns
|
|
454
|
+
`400 INVALID_PRECONDITION` without applying anything. Use a document token for insert and move because they
|
|
455
|
+
depend on document order. A block token lets other sections change concurrently; a new anchored ask or comment
|
|
456
|
+
changes the relevant token. A stale guard returns `409 PRECONDITION_FAILED` with each mismatch and current
|
|
457
|
+
token; Dispatch applies no part of that batch. It is the hashline `#TAG` property applied to stable block ids,
|
|
458
|
+
not line numbers: canonical Markdown lines shift under concurrent edits and rendering changes, while block ids
|
|
459
|
+
survive moves and retyping.
|
|
460
|
+
|
|
448
461
|
`retype` turns the paragraph or typed block with `block` into the named typed `type` in place. It keeps the
|
|
449
462
|
block id, keeps a typed block's body, and uses `attributes` for client-owned typed attributes. Use it when
|
|
450
463
|
an existing paragraph is the question that should become a decision.
|