@sjawhar/claude-envoy 5.23.4 → 5.23.6
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/.claude-plugin/plugin.json +1 -1
- package/.omp-plugin/plugin.json +1 -1
- package/dist/codex-hook.js +46 -18
- package/dist/dispatch.js +46 -18
- package/dist/envoy-channel.js +48 -20
- package/dist/session-hook.js +46 -18
- package/legion/skills/legion-architect/references/wake-routing.md +1 -1
- package/legion/skills/legion-controller/references/admission.md +1 -1
- package/legion/skills/legion-retro/SKILL.md +2 -2
- package/legion/skills/legion-worker/SKILL.md +1 -1
- package/legion/skills/legion-worker/references/conflicts-and-rewrites.md +1 -1
- package/legion/skills/legion-worker/references/findings.md +1 -1
- package/package.json +1 -1
- package/skills/dispatch/SKILL.md +1 -1
- package/src/codex/codex-server.ts +1 -1
package/.omp-plugin/plugin.json
CHANGED
package/dist/codex-hook.js
CHANGED
|
@@ -13931,7 +13931,8 @@ var versionFields = {
|
|
|
13931
13931
|
created_at: string2(),
|
|
13932
13932
|
size: number2().int().optional(),
|
|
13933
13933
|
mime: string2().optional(),
|
|
13934
|
-
sha256: string2().optional()
|
|
13934
|
+
sha256: string2().optional(),
|
|
13935
|
+
token: string2().optional()
|
|
13935
13936
|
};
|
|
13936
13937
|
var VersionSchema = strictObject(versionFields).readonly();
|
|
13937
13938
|
var DocumentRoleSchema = _enum2(["verification", "plan", "decisions"]);
|
|
@@ -14095,6 +14096,20 @@ var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text
|
|
|
14095
14096
|
var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
|
|
14096
14097
|
var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so a document's name ends in .md or .markdown or has no extension, under content and under neither flag alike; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
|
|
14097
14098
|
var ARTIFACT_NAME_EXISTS_RULE = `An upload under the name of a document the owner already holds is refused: it writes that document's next version, over the text it holds. Change a document with dispatch doc-edit. To write the next version, send the upload again with force (--force) and the token of the version it replaces (--precondition-json '{"document":"sha256:\u2026"}', the token dispatch doc-read prints).`;
|
|
14099
|
+
function artifactKindWord(kind) {
|
|
14100
|
+
return { doc: "document", file: "file", image: "picture" }[kind] ?? kind;
|
|
14101
|
+
}
|
|
14102
|
+
function fileNameExistsRule(kind, statesToken) {
|
|
14103
|
+
const what = artifactKindWord(kind);
|
|
14104
|
+
const head = `An upload under the name of a ${what} the owner already holds is refused: it writes that ${what}'s next version, over the bytes it holds.`;
|
|
14105
|
+
if (!statesToken) {
|
|
14106
|
+
return `${head} The version standing under the name states no token, so an upload naming one is refused: to write the next version, read the ${what} again with dispatch doc-read, then send the upload again with force (--force) alone.`;
|
|
14107
|
+
}
|
|
14108
|
+
return `${head} To write the next version, send the upload again with force (--force) and the token of the version you read: --precondition-json '{"document":"<the Document token your own dispatch doc-read of the ${what} printed>"}'. A version written since that read refuses it 409 PRECONDITION_FAILED: read the ${what} again before you replace it.`;
|
|
14109
|
+
}
|
|
14110
|
+
function artifactKindConflictRule(held, upload) {
|
|
14111
|
+
return `This upload is a ${artifactKindWord(upload)}, and the name holds a ${artifactKindWord(held)}: Dispatch keeps one kind under one name, so this upload cannot be its next version, with force or without. Give the upload another name.`;
|
|
14112
|
+
}
|
|
14098
14113
|
var ARTIFACT_STORED_TEXT_RULE = `content and content-file hold text Dispatch stores as Markdown, and a text the store would write under another spelling is refused. A typed block whose attributes differ from Dispatch's only in their order is not refused: the command uploads it with them in Dispatch's order and names each such block. A refusal names the first difference: a changed line by the attribute or the word that differs, a word of more than 200 characters by a window from its first character that differs, and a line the store adds or drops by a quote cut at 200 characters, each cut named. The refusal prints the text Dispatch stores: send that text. A name that does not end in .md or .markdown has a second way out, which keeps the text as it was written: send it as a file with ${PATH_KEEPS_BYTES}.`;
|
|
14099
14114
|
var NAME_EXTENSION = /\.([^\s.]+)$/u;
|
|
14100
14115
|
var MARKDOWN_EXTENSION = /^(md|markdown)$/i;
|
|
@@ -14109,8 +14124,8 @@ function preconditionArgument(z) {
|
|
|
14109
14124
|
}
|
|
14110
14125
|
function uploadPreconditionArgument(z) {
|
|
14111
14126
|
return z.object({
|
|
14112
|
-
document: z.string({ min: 1 }).describe("Token
|
|
14113
|
-
}).describe("The token of the version this upload replaces, which an upload over a document the owner already holds
|
|
14127
|
+
document: z.string({ min: 1 }).describe("Token of the version this upload replaces, as dispatch doc-read prints it for a document, a file or a picture.")
|
|
14128
|
+
}).describe("The token of the version this upload replaces, which an upload over a document, a file or a picture the owner already holds names; a first upload under a name replaces nothing and names none.").optional();
|
|
14114
14129
|
}
|
|
14115
14130
|
function pathKeepsBytesOf(name) {
|
|
14116
14131
|
const extension = NAME_EXTENSION.exec(name.trim())?.[1];
|
|
@@ -14735,7 +14750,7 @@ var dispatchToolSpecs = [
|
|
|
14735
14750
|
{
|
|
14736
14751
|
name: "dispatch_doc_read",
|
|
14737
14752
|
example: { issue: "DSP-1" },
|
|
14738
|
-
description: "Read a live document or a named document version, or the text of an uploaded file at its latest or named 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. With blocks it lists the live document's blocks instead of its markdown, in document order: each block's id, type, token, anchored comments and asks, and opening words, a typed block's serves and needs under it, and under a table each row by the index delete_row takes and each cell by its row and the column delete_column takes; block ids, block tokens and those indexes are what dispatch doc-edit takes. " + "After the markdown it prints every open thread anchored on the document in full: an open ask with its id and question and each reply's author, time and text, and a comment thread with its root's id, author, time, quote and text and each reply's author, time and text, in order; a resolved thread, and an ask that is answered or resolved, is not printed. " + "A picture (an uploaded PNG, JPEG, GIF or WebP of at most 3,750,000 bytes, 5 MB once base64-encoded) comes back as an image you see, with its name, type, size and version, every time you ask, including one a read already showed this session; " + "any other file that is not UTF-8 text is described, with the route that serves its bytes. " + OWNER_REFERENCE,
|
|
14753
|
+
description: "Read a live document or a named document version, or the text of an uploaded file at its latest or named 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. With blocks it lists the live document's blocks instead of its markdown, in document order: each block's id, type, token, anchored comments and asks, and opening words, a typed block's serves and needs under it, and under a table each row by the index delete_row takes and each cell by its row and the column delete_column takes; block ids, block tokens and those indexes are what dispatch doc-edit takes. " + "After the markdown it prints every open thread anchored on the document in full: an open ask with its id and question and each reply's author, time and text, and a comment thread with its root's id, author, time, quote and text and each reply's author, time and text, in order; a resolved thread, and an ask that is answered or resolved, is not printed. " + "A picture (an uploaded PNG, JPEG, GIF or WebP of at most 3,750,000 bytes, 5 MB once base64-encoded) comes back as an image you see, with its name, type, size and version, every time you ask, including one a read already showed this session; " + "any other file that is not UTF-8 text is described, with the route that serves its bytes. " + "A read of an uploaded file or picture prints, in its header before the file's text, the latest version's token as a `Document token: sha256:\u2026` line, which dispatch artifact's precondition takes for the next version, or a named version's hash as a `Content: sha256:\u2026` line; the text after the header is the stored file unchanged, except that the dispatch command adds a line feed after a file that ends without one and, under Claude Code or Codex, cuts an output past 25,000 characters and writes the whole of it to a file it names. " + OWNER_REFERENCE,
|
|
14739
14754
|
arguments: (z) => ({
|
|
14740
14755
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
14741
14756
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -14830,7 +14845,7 @@ var dispatchToolSpecs = [
|
|
|
14830
14845
|
name: "dispatch_artifact",
|
|
14831
14846
|
example: { issue: "DSP-1", name: "design.md", content: `# Design
|
|
14832
14847
|
` },
|
|
14833
|
-
description: "Attach a local file or inline text as an issue artifact or project document, or make an empty document from its name alone. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. " + `${ARTIFACT_SOURCE_RULE} ` + `${ARTIFACT_NAME_EXISTS_RULE} A call that stores nothing - no path, and content absent or blank - is refused under a held name even with force and a token, so a title typed twice never empties the document that holds it; that refusal names no token, since no token makes such a call one Dispatch takes. ` + "A markdown document is at most 1 MiB and any other file at most 25 MiB. " + "An upload that replaces a document the owner already holds under that name says which version it replaces: precondition.document takes the document token dispatch doc-read prints as `Document token: sha256:\u2026`, and Dispatch checks it under the write's own lock. An upload that names none is taken for now without a check, since older dispatch commands cannot name one; name the token wherever the command can, because a later release refuses an upload naming none with 400 PRECONDITION_REQUIRED. A token behind the live document is refused with 409 PRECONDITION_FAILED. The refusal tells you to read the document again with dispatch doc-read, which prints the token the document carries now, and to upload again naming that token.
|
|
14848
|
+
description: "Attach a local file or inline text as an issue artifact or project document, or make an empty document from its name alone. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. " + `${ARTIFACT_SOURCE_RULE} ` + `${ARTIFACT_NAME_EXISTS_RULE} A call that stores nothing - no path, and content absent or blank - is refused under a held name even with force and a token, so a title typed twice never empties the document that holds it; that refusal names no token, since no token makes such a call one Dispatch takes. ` + "A markdown document is at most 1 MiB and any other file at most 25 MiB. " + "An upload that replaces a document the owner already holds under that name says which version it replaces: precondition.document takes the document token dispatch doc-read prints as `Document token: sha256:\u2026`, and Dispatch checks it under the write's own lock. An upload that names none is taken for now without a check, since older dispatch commands cannot name one; name the token wherever the command can, because a later release refuses an upload naming none with 400 PRECONDITION_REQUIRED. A token behind the live document is refused with 409 PRECONDITION_FAILED. The refusal tells you to read the document again with dispatch doc-read, which prints the token the document carries now, and to upload again naming that token. An upload that replaces a file or a picture names the token of the version it replaces the same way, the `Document token:` line dispatch doc-read prints for its latest version, and any other token is refused with 409 PRECONDITION_FAILED; one naming none is taken unchecked. The command's refusal of a name the owner holds prints no token: for a file or a picture it names --force with the token your own dispatch doc-read printed, or --force alone where Dispatch states no token for the file, since such a Dispatch refuses a token on a file's upload; for an upload of another kind than the name holds (a declared Markdown upload is a document, PNG, JPEG, GIF or WebP bytes a picture, anything else a file) it names another name, since Dispatch refuses it under that name with 400 ARTIFACT_KIND_MISMATCH. A first upload under a name replaces no version, so it names none. " + `${ARTIFACT_CONTENT_NAME_RULE} ${ARTIFACT_STORED_TEXT_RULE} ` + "Markdown is also refused with 413 CAP_EXCEEDED when it makes more than 65,536 elements (a block weighs 3, and an empty list item, quote, footnote definition or typed block 3 more for the empty paragraph it holds; a table cell 4, a hard line break 3, an image 3, a piece of inline HTML 2, an autolink 2, a footnote reference 2; inline syntax, marks, lines of text and backslash escapes or character references 1 each), or when a new version would leave the document's stored markdown (what its text reads back as) longer than 1 MiB or making more than 65,536 elements, and longer or heavier than before; shorten it or split it across documents. " + "In a table row, write every | in a cell as \\|, in code too: a | after two backslashes ends the cell, and a row with more cells than its table is refused. " + "Markdown holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK; a new version of a document is held to it only for the asks it writes or changes. " + `${CI_CHECK_RULE} ` + `${OWNER_REFERENCE}`,
|
|
14834
14849
|
arguments: (z) => ({
|
|
14835
14850
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
14836
14851
|
project: z.string().describe("Project key for an unlinked document.").optional(),
|
|
@@ -22363,7 +22378,7 @@ function oversizePictureText(name, bytes) {
|
|
|
22363
22378
|
}
|
|
22364
22379
|
var PICTURES_SHOWN_MAX = 8;
|
|
22365
22380
|
var PICTURES_SHOWN_MAX_BYTES = 10 * 1024 * 1024;
|
|
22366
|
-
var PICTURE_SNIFF_BYTES =
|
|
22381
|
+
var PICTURE_SNIFF_BYTES = 14;
|
|
22367
22382
|
function bytesAt(bytes, offset, expected) {
|
|
22368
22383
|
return expected.every((byte, index) => bytes[offset + index] === byte);
|
|
22369
22384
|
}
|
|
@@ -22375,11 +22390,14 @@ function sniffPictureType(bytes) {
|
|
|
22375
22390
|
if (bytesAt(bytes, 0, [71, 73, 70, 56]) && (bytes[4] === 55 || bytes[4] === 57) && bytes[5] === 97) {
|
|
22376
22391
|
return "image/gif";
|
|
22377
22392
|
}
|
|
22378
|
-
if (bytesAt(bytes, 0, [82, 73, 70, 70]) && bytesAt(bytes, 8, [87, 69, 66, 80])) {
|
|
22393
|
+
if (bytesAt(bytes, 0, [82, 73, 70, 70]) && bytesAt(bytes, 8, [87, 69, 66, 80, 86, 80])) {
|
|
22379
22394
|
return "image/webp";
|
|
22380
22395
|
}
|
|
22381
22396
|
return;
|
|
22382
22397
|
}
|
|
22398
|
+
async function readPictureHead(path) {
|
|
22399
|
+
return new Uint8Array(await Bun.file(path).slice(0, PICTURE_SNIFF_BYTES).arrayBuffer());
|
|
22400
|
+
}
|
|
22383
22401
|
function toolImage(bytes) {
|
|
22384
22402
|
const mimeType = sniffPictureType(bytes);
|
|
22385
22403
|
if (mimeType === undefined || bytes.length > PICTURE_SHOWN_MAX_BYTES)
|
|
@@ -23353,7 +23371,7 @@ async function localPicture(path, cwd) {
|
|
|
23353
23371
|
if (!stats.isFile())
|
|
23354
23372
|
return `images: ${path} is not a file`;
|
|
23355
23373
|
size = stats.size;
|
|
23356
|
-
head =
|
|
23374
|
+
head = await readPictureHead(absolute);
|
|
23357
23375
|
} catch (error) {
|
|
23358
23376
|
return `images: ${path} cannot be read: ${messageFor(error)}`;
|
|
23359
23377
|
}
|
|
@@ -27566,15 +27584,21 @@ function artifactUnderName(artifacts, name) {
|
|
|
27566
27584
|
const written = name.trim();
|
|
27567
27585
|
return artifacts.find((held) => held.slug === written) ?? artifacts.find((held) => held.name === written);
|
|
27568
27586
|
}
|
|
27569
|
-
function
|
|
27587
|
+
async function uploadKindOf(path, head) {
|
|
27588
|
+
if (path === undefined || !pathKeepsBytesOf(path))
|
|
27589
|
+
return "doc";
|
|
27590
|
+
return sniffPictureType(await head(path)) === undefined ? "file" : "image";
|
|
27591
|
+
}
|
|
27592
|
+
function artifactNameExistsProblem(held, owner, upload) {
|
|
27570
27593
|
const versions = held.versions ?? [];
|
|
27571
27594
|
const newest = versions[versions.length - 1];
|
|
27595
|
+
const rule = upload !== held.kind ? artifactKindConflictRule(held.kind, upload) : held.kind === "doc" ? ARTIFACT_NAME_EXISTS_RULE : fileNameExistsRule(held.kind, newest?.token !== undefined);
|
|
27572
27596
|
if (newest === undefined) {
|
|
27573
|
-
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}), which has no version yet and which ${actorText(held.created_by)} created. ${
|
|
27597
|
+
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}), which has no version yet and which ${actorText(held.created_by)} created. ${rule}`;
|
|
27574
27598
|
}
|
|
27575
27599
|
const authors = (newest.authors ?? []).map(actorText);
|
|
27576
27600
|
const wroteIt = authors.length === 0 ? actorText(held.created_by) : authors.join(" and ");
|
|
27577
|
-
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${
|
|
27601
|
+
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${rule}`;
|
|
27578
27602
|
}
|
|
27579
27603
|
function storedTextCheckFailed(error, name) {
|
|
27580
27604
|
if (error instanceof DispatchAnswerNotKeptError) {
|
|
@@ -27602,11 +27626,14 @@ async function readUploadedFile(client, artifact, details, requested, owner, sho
|
|
|
27602
27626
|
const number = requested ?? latest;
|
|
27603
27627
|
const of = number === latest ? "" : ` of ${latest}`;
|
|
27604
27628
|
const bytesRoute = `GET /api/v1/artifacts/${artifact.id}/versions/${number} serves its bytes.`;
|
|
27629
|
+
const stated = versions.find((version) => version.number === number);
|
|
27630
|
+
const hashLine = requested === undefined ? stated?.token === undefined ? "" : `
|
|
27631
|
+
Document token: ${stated.token}` : stated?.sha256 === undefined ? "" : `
|
|
27632
|
+
Content: sha256:${stated.sha256}`;
|
|
27605
27633
|
const tooLarge = (mime, bytes) => ({
|
|
27606
|
-
text: `${oversizePictureText(artifact.name, bytes)}, so dispatch doc-read cannot show this ` + `uploaded ${mime} picture (version ${number}${of}). ${bytesRoute}`,
|
|
27634
|
+
text: `${oversizePictureText(artifact.name, bytes)}, so dispatch doc-read cannot show this ` + `uploaded ${mime} picture (version ${number}${of}). ${bytesRoute}${hashLine}`,
|
|
27607
27635
|
details
|
|
27608
27636
|
});
|
|
27609
|
-
const stated = versions.find((version) => version.number === number);
|
|
27610
27637
|
if (artifact.kind === "image" && stated?.size !== undefined && stated.size > PICTURE_SHOWN_MAX_BYTES) {
|
|
27611
27638
|
return tooLarge(stated.mime ?? "image", stated.size);
|
|
27612
27639
|
}
|
|
@@ -27618,7 +27645,7 @@ async function readUploadedFile(client, artifact, details, requested, owner, sho
|
|
|
27618
27645
|
const address = `dispatch://${owner}/artifact/${artifact.slug}@v${number}`;
|
|
27619
27646
|
shown?.add(address);
|
|
27620
27647
|
return {
|
|
27621
|
-
text: `Picture ${artifact.name}: ${image.mimeType}, version ${number}${of}, ${size}
|
|
27648
|
+
text: `Picture ${artifact.name}: ${image.mimeType}, version ${number}${of}, ${size}.${hashLine}
|
|
27622
27649
|
` + shownPictureLine(1, address, artifact.name, image.mimeType, file.bytes.length),
|
|
27623
27650
|
details,
|
|
27624
27651
|
images: [image]
|
|
@@ -27629,15 +27656,15 @@ async function readUploadedFile(client, artifact, details, requested, owner, sho
|
|
|
27629
27656
|
}
|
|
27630
27657
|
let text;
|
|
27631
27658
|
try {
|
|
27632
|
-
text = new TextDecoder("utf-8", { fatal: true }).decode(file.bytes);
|
|
27659
|
+
text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(file.bytes);
|
|
27633
27660
|
} catch {
|
|
27634
27661
|
return {
|
|
27635
|
-
text: `${artifact.name} is an uploaded ${file.mime} file (version ${number}${of}, ${size}) that is not ` + `UTF-8 text, so dispatch doc-read cannot show it. ${bytesRoute}`,
|
|
27662
|
+
text: `${artifact.name} is an uploaded ${file.mime} file (version ${number}${of}, ${size}) that is not ` + `UTF-8 text, so dispatch doc-read cannot show it. ${bytesRoute}${hashLine}`,
|
|
27636
27663
|
details
|
|
27637
27664
|
};
|
|
27638
27665
|
}
|
|
27639
27666
|
return {
|
|
27640
|
-
text: `File ${artifact.name}: ${file.mime}, version ${number}${of}, ${size}
|
|
27667
|
+
text: `File ${artifact.name}: ${file.mime}, version ${number}${of}, ${size}.${hashLine}
|
|
27641
27668
|
|
|
27642
27669
|
${text}`,
|
|
27643
27670
|
details
|
|
@@ -27968,8 +27995,9 @@ async function artifactCommand(context) {
|
|
|
27968
27995
|
if ((path !== undefined || !blank) && optionalBoolean(args, "force") !== true) {
|
|
27969
27996
|
const held = artifactUnderName(artifactOwner.kind === "project" ? await client.listProjectArtifacts(artifactOwner.project, true) : await client.listIssueArtifacts(issue()), name);
|
|
27970
27997
|
if (held !== undefined) {
|
|
27998
|
+
const kind = await uploadKindOf(path, (named) => input.uploadBytes === undefined ? readPictureHead(resolvePath2(input.cwd, named)) : Promise.resolve(input.uploadBytes.subarray(0, PICTURE_SNIFF_BYTES)));
|
|
27971
27999
|
throw new ToolInputError(input.tool, [
|
|
27972
|
-
artifactNameExistsProblem(held, artifactOwner.kind === "project" ? `project ${artifactOwner.project}` : `issue ${issue()}
|
|
28000
|
+
artifactNameExistsProblem(held, artifactOwner.kind === "project" ? `project ${artifactOwner.project}` : `issue ${issue()}`, kind)
|
|
27973
28001
|
]);
|
|
27974
28002
|
}
|
|
27975
28003
|
}
|
package/dist/dispatch.js
CHANGED
|
@@ -14535,7 +14535,8 @@ var versionFields = {
|
|
|
14535
14535
|
created_at: string2(),
|
|
14536
14536
|
size: number2().int().optional(),
|
|
14537
14537
|
mime: string2().optional(),
|
|
14538
|
-
sha256: string2().optional()
|
|
14538
|
+
sha256: string2().optional(),
|
|
14539
|
+
token: string2().optional()
|
|
14539
14540
|
};
|
|
14540
14541
|
var VersionSchema = strictObject(versionFields).readonly();
|
|
14541
14542
|
var DocumentRoleSchema = _enum2(["verification", "plan", "decisions"]);
|
|
@@ -14699,6 +14700,20 @@ var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text
|
|
|
14699
14700
|
var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
|
|
14700
14701
|
var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so a document's name ends in .md or .markdown or has no extension, under content and under neither flag alike; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
|
|
14701
14702
|
var ARTIFACT_NAME_EXISTS_RULE = `An upload under the name of a document the owner already holds is refused: it writes that document's next version, over the text it holds. Change a document with dispatch doc-edit. To write the next version, send the upload again with force (--force) and the token of the version it replaces (--precondition-json '{"document":"sha256:\u2026"}', the token dispatch doc-read prints).`;
|
|
14703
|
+
function artifactKindWord(kind) {
|
|
14704
|
+
return { doc: "document", file: "file", image: "picture" }[kind] ?? kind;
|
|
14705
|
+
}
|
|
14706
|
+
function fileNameExistsRule(kind, statesToken) {
|
|
14707
|
+
const what = artifactKindWord(kind);
|
|
14708
|
+
const head = `An upload under the name of a ${what} the owner already holds is refused: it writes that ${what}'s next version, over the bytes it holds.`;
|
|
14709
|
+
if (!statesToken) {
|
|
14710
|
+
return `${head} The version standing under the name states no token, so an upload naming one is refused: to write the next version, read the ${what} again with dispatch doc-read, then send the upload again with force (--force) alone.`;
|
|
14711
|
+
}
|
|
14712
|
+
return `${head} To write the next version, send the upload again with force (--force) and the token of the version you read: --precondition-json '{"document":"<the Document token your own dispatch doc-read of the ${what} printed>"}'. A version written since that read refuses it 409 PRECONDITION_FAILED: read the ${what} again before you replace it.`;
|
|
14713
|
+
}
|
|
14714
|
+
function artifactKindConflictRule(held, upload) {
|
|
14715
|
+
return `This upload is a ${artifactKindWord(upload)}, and the name holds a ${artifactKindWord(held)}: Dispatch keeps one kind under one name, so this upload cannot be its next version, with force or without. Give the upload another name.`;
|
|
14716
|
+
}
|
|
14702
14717
|
var ARTIFACT_STORED_TEXT_RULE = `content and content-file hold text Dispatch stores as Markdown, and a text the store would write under another spelling is refused. A typed block whose attributes differ from Dispatch's only in their order is not refused: the command uploads it with them in Dispatch's order and names each such block. A refusal names the first difference: a changed line by the attribute or the word that differs, a word of more than 200 characters by a window from its first character that differs, and a line the store adds or drops by a quote cut at 200 characters, each cut named. The refusal prints the text Dispatch stores: send that text. A name that does not end in .md or .markdown has a second way out, which keeps the text as it was written: send it as a file with ${PATH_KEEPS_BYTES}.`;
|
|
14703
14718
|
var NAME_EXTENSION = /\.([^\s.]+)$/u;
|
|
14704
14719
|
var MARKDOWN_EXTENSION = /^(md|markdown)$/i;
|
|
@@ -14713,8 +14728,8 @@ function preconditionArgument(z) {
|
|
|
14713
14728
|
}
|
|
14714
14729
|
function uploadPreconditionArgument(z) {
|
|
14715
14730
|
return z.object({
|
|
14716
|
-
document: z.string({ min: 1 }).describe("Token
|
|
14717
|
-
}).describe("The token of the version this upload replaces, which an upload over a document the owner already holds
|
|
14731
|
+
document: z.string({ min: 1 }).describe("Token of the version this upload replaces, as dispatch doc-read prints it for a document, a file or a picture.")
|
|
14732
|
+
}).describe("The token of the version this upload replaces, which an upload over a document, a file or a picture the owner already holds names; a first upload under a name replaces nothing and names none.").optional();
|
|
14718
14733
|
}
|
|
14719
14734
|
function pathKeepsBytesOf(name) {
|
|
14720
14735
|
const extension = NAME_EXTENSION.exec(name.trim())?.[1];
|
|
@@ -15339,7 +15354,7 @@ var dispatchToolSpecs = [
|
|
|
15339
15354
|
{
|
|
15340
15355
|
name: "dispatch_doc_read",
|
|
15341
15356
|
example: { issue: "DSP-1" },
|
|
15342
|
-
description: "Read a live document or a named document version, or the text of an uploaded file at its latest or named 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. With blocks it lists the live document's blocks instead of its markdown, in document order: each block's id, type, token, anchored comments and asks, and opening words, a typed block's serves and needs under it, and under a table each row by the index delete_row takes and each cell by its row and the column delete_column takes; block ids, block tokens and those indexes are what dispatch doc-edit takes. " + "After the markdown it prints every open thread anchored on the document in full: an open ask with its id and question and each reply's author, time and text, and a comment thread with its root's id, author, time, quote and text and each reply's author, time and text, in order; a resolved thread, and an ask that is answered or resolved, is not printed. " + "A picture (an uploaded PNG, JPEG, GIF or WebP of at most 3,750,000 bytes, 5 MB once base64-encoded) comes back as an image you see, with its name, type, size and version, every time you ask, including one a read already showed this session; " + "any other file that is not UTF-8 text is described, with the route that serves its bytes. " + OWNER_REFERENCE,
|
|
15357
|
+
description: "Read a live document or a named document version, or the text of an uploaded file at its latest or named 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. With blocks it lists the live document's blocks instead of its markdown, in document order: each block's id, type, token, anchored comments and asks, and opening words, a typed block's serves and needs under it, and under a table each row by the index delete_row takes and each cell by its row and the column delete_column takes; block ids, block tokens and those indexes are what dispatch doc-edit takes. " + "After the markdown it prints every open thread anchored on the document in full: an open ask with its id and question and each reply's author, time and text, and a comment thread with its root's id, author, time, quote and text and each reply's author, time and text, in order; a resolved thread, and an ask that is answered or resolved, is not printed. " + "A picture (an uploaded PNG, JPEG, GIF or WebP of at most 3,750,000 bytes, 5 MB once base64-encoded) comes back as an image you see, with its name, type, size and version, every time you ask, including one a read already showed this session; " + "any other file that is not UTF-8 text is described, with the route that serves its bytes. " + "A read of an uploaded file or picture prints, in its header before the file's text, the latest version's token as a `Document token: sha256:\u2026` line, which dispatch artifact's precondition takes for the next version, or a named version's hash as a `Content: sha256:\u2026` line; the text after the header is the stored file unchanged, except that the dispatch command adds a line feed after a file that ends without one and, under Claude Code or Codex, cuts an output past 25,000 characters and writes the whole of it to a file it names. " + OWNER_REFERENCE,
|
|
15343
15358
|
arguments: (z) => ({
|
|
15344
15359
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
15345
15360
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -15434,7 +15449,7 @@ var dispatchToolSpecs = [
|
|
|
15434
15449
|
name: "dispatch_artifact",
|
|
15435
15450
|
example: { issue: "DSP-1", name: "design.md", content: `# Design
|
|
15436
15451
|
` },
|
|
15437
|
-
description: "Attach a local file or inline text as an issue artifact or project document, or make an empty document from its name alone. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. " + `${ARTIFACT_SOURCE_RULE} ` + `${ARTIFACT_NAME_EXISTS_RULE} A call that stores nothing - no path, and content absent or blank - is refused under a held name even with force and a token, so a title typed twice never empties the document that holds it; that refusal names no token, since no token makes such a call one Dispatch takes. ` + "A markdown document is at most 1 MiB and any other file at most 25 MiB. " + "An upload that replaces a document the owner already holds under that name says which version it replaces: precondition.document takes the document token dispatch doc-read prints as `Document token: sha256:\u2026`, and Dispatch checks it under the write's own lock. An upload that names none is taken for now without a check, since older dispatch commands cannot name one; name the token wherever the command can, because a later release refuses an upload naming none with 400 PRECONDITION_REQUIRED. A token behind the live document is refused with 409 PRECONDITION_FAILED. The refusal tells you to read the document again with dispatch doc-read, which prints the token the document carries now, and to upload again naming that token.
|
|
15452
|
+
description: "Attach a local file or inline text as an issue artifact or project document, or make an empty document from its name alone. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. " + `${ARTIFACT_SOURCE_RULE} ` + `${ARTIFACT_NAME_EXISTS_RULE} A call that stores nothing - no path, and content absent or blank - is refused under a held name even with force and a token, so a title typed twice never empties the document that holds it; that refusal names no token, since no token makes such a call one Dispatch takes. ` + "A markdown document is at most 1 MiB and any other file at most 25 MiB. " + "An upload that replaces a document the owner already holds under that name says which version it replaces: precondition.document takes the document token dispatch doc-read prints as `Document token: sha256:\u2026`, and Dispatch checks it under the write's own lock. An upload that names none is taken for now without a check, since older dispatch commands cannot name one; name the token wherever the command can, because a later release refuses an upload naming none with 400 PRECONDITION_REQUIRED. A token behind the live document is refused with 409 PRECONDITION_FAILED. The refusal tells you to read the document again with dispatch doc-read, which prints the token the document carries now, and to upload again naming that token. An upload that replaces a file or a picture names the token of the version it replaces the same way, the `Document token:` line dispatch doc-read prints for its latest version, and any other token is refused with 409 PRECONDITION_FAILED; one naming none is taken unchecked. The command's refusal of a name the owner holds prints no token: for a file or a picture it names --force with the token your own dispatch doc-read printed, or --force alone where Dispatch states no token for the file, since such a Dispatch refuses a token on a file's upload; for an upload of another kind than the name holds (a declared Markdown upload is a document, PNG, JPEG, GIF or WebP bytes a picture, anything else a file) it names another name, since Dispatch refuses it under that name with 400 ARTIFACT_KIND_MISMATCH. A first upload under a name replaces no version, so it names none. " + `${ARTIFACT_CONTENT_NAME_RULE} ${ARTIFACT_STORED_TEXT_RULE} ` + "Markdown is also refused with 413 CAP_EXCEEDED when it makes more than 65,536 elements (a block weighs 3, and an empty list item, quote, footnote definition or typed block 3 more for the empty paragraph it holds; a table cell 4, a hard line break 3, an image 3, a piece of inline HTML 2, an autolink 2, a footnote reference 2; inline syntax, marks, lines of text and backslash escapes or character references 1 each), or when a new version would leave the document's stored markdown (what its text reads back as) longer than 1 MiB or making more than 65,536 elements, and longer or heavier than before; shorten it or split it across documents. " + "In a table row, write every | in a cell as \\|, in code too: a | after two backslashes ends the cell, and a row with more cells than its table is refused. " + "Markdown holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK; a new version of a document is held to it only for the asks it writes or changes. " + `${CI_CHECK_RULE} ` + `${OWNER_REFERENCE}`,
|
|
15438
15453
|
arguments: (z) => ({
|
|
15439
15454
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
15440
15455
|
project: z.string().describe("Project key for an unlinked document.").optional(),
|
|
@@ -27656,7 +27671,7 @@ function oversizePictureText(name, bytes) {
|
|
|
27656
27671
|
}
|
|
27657
27672
|
var PICTURES_SHOWN_MAX = 8;
|
|
27658
27673
|
var PICTURES_SHOWN_MAX_BYTES = 10 * 1024 * 1024;
|
|
27659
|
-
var PICTURE_SNIFF_BYTES =
|
|
27674
|
+
var PICTURE_SNIFF_BYTES = 14;
|
|
27660
27675
|
function bytesAt(bytes, offset, expected) {
|
|
27661
27676
|
return expected.every((byte, index) => bytes[offset + index] === byte);
|
|
27662
27677
|
}
|
|
@@ -27668,11 +27683,14 @@ function sniffPictureType(bytes) {
|
|
|
27668
27683
|
if (bytesAt(bytes, 0, [71, 73, 70, 56]) && (bytes[4] === 55 || bytes[4] === 57) && bytes[5] === 97) {
|
|
27669
27684
|
return "image/gif";
|
|
27670
27685
|
}
|
|
27671
|
-
if (bytesAt(bytes, 0, [82, 73, 70, 70]) && bytesAt(bytes, 8, [87, 69, 66, 80])) {
|
|
27686
|
+
if (bytesAt(bytes, 0, [82, 73, 70, 70]) && bytesAt(bytes, 8, [87, 69, 66, 80, 86, 80])) {
|
|
27672
27687
|
return "image/webp";
|
|
27673
27688
|
}
|
|
27674
27689
|
return;
|
|
27675
27690
|
}
|
|
27691
|
+
async function readPictureHead(path) {
|
|
27692
|
+
return new Uint8Array(await Bun.file(path).slice(0, PICTURE_SNIFF_BYTES).arrayBuffer());
|
|
27693
|
+
}
|
|
27676
27694
|
function toolImage(bytes) {
|
|
27677
27695
|
const mimeType = sniffPictureType(bytes);
|
|
27678
27696
|
if (mimeType === undefined || bytes.length > PICTURE_SHOWN_MAX_BYTES)
|
|
@@ -28646,7 +28664,7 @@ async function localPicture(path, cwd) {
|
|
|
28646
28664
|
if (!stats.isFile())
|
|
28647
28665
|
return `images: ${path} is not a file`;
|
|
28648
28666
|
size = stats.size;
|
|
28649
|
-
head =
|
|
28667
|
+
head = await readPictureHead(absolute);
|
|
28650
28668
|
} catch (error) {
|
|
28651
28669
|
return `images: ${path} cannot be read: ${messageFor(error)}`;
|
|
28652
28670
|
}
|
|
@@ -32511,15 +32529,21 @@ function artifactUnderName(artifacts, name) {
|
|
|
32511
32529
|
const written = name.trim();
|
|
32512
32530
|
return artifacts.find((held) => held.slug === written) ?? artifacts.find((held) => held.name === written);
|
|
32513
32531
|
}
|
|
32514
|
-
function
|
|
32532
|
+
async function uploadKindOf(path, head) {
|
|
32533
|
+
if (path === undefined || !pathKeepsBytesOf(path))
|
|
32534
|
+
return "doc";
|
|
32535
|
+
return sniffPictureType(await head(path)) === undefined ? "file" : "image";
|
|
32536
|
+
}
|
|
32537
|
+
function artifactNameExistsProblem(held, owner, upload) {
|
|
32515
32538
|
const versions = held.versions ?? [];
|
|
32516
32539
|
const newest = versions[versions.length - 1];
|
|
32540
|
+
const rule = upload !== held.kind ? artifactKindConflictRule(held.kind, upload) : held.kind === "doc" ? ARTIFACT_NAME_EXISTS_RULE : fileNameExistsRule(held.kind, newest?.token !== undefined);
|
|
32517
32541
|
if (newest === undefined) {
|
|
32518
|
-
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}), which has no version yet and which ${actorText(held.created_by)} created. ${
|
|
32542
|
+
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}), which has no version yet and which ${actorText(held.created_by)} created. ${rule}`;
|
|
32519
32543
|
}
|
|
32520
32544
|
const authors = (newest.authors ?? []).map(actorText);
|
|
32521
32545
|
const wroteIt = authors.length === 0 ? actorText(held.created_by) : authors.join(" and ");
|
|
32522
|
-
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${
|
|
32546
|
+
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${rule}`;
|
|
32523
32547
|
}
|
|
32524
32548
|
function storedTextCheckFailed(error, name) {
|
|
32525
32549
|
if (error instanceof DispatchAnswerNotKeptError) {
|
|
@@ -32547,11 +32571,14 @@ async function readUploadedFile(client, artifact, details, requested, owner, sho
|
|
|
32547
32571
|
const number = requested ?? latest;
|
|
32548
32572
|
const of = number === latest ? "" : ` of ${latest}`;
|
|
32549
32573
|
const bytesRoute = `GET /api/v1/artifacts/${artifact.id}/versions/${number} serves its bytes.`;
|
|
32574
|
+
const stated = versions.find((version) => version.number === number);
|
|
32575
|
+
const hashLine = requested === undefined ? stated?.token === undefined ? "" : `
|
|
32576
|
+
Document token: ${stated.token}` : stated?.sha256 === undefined ? "" : `
|
|
32577
|
+
Content: sha256:${stated.sha256}`;
|
|
32550
32578
|
const tooLarge = (mime, bytes) => ({
|
|
32551
|
-
text: `${oversizePictureText(artifact.name, bytes)}, so dispatch doc-read cannot show this ` + `uploaded ${mime} picture (version ${number}${of}). ${bytesRoute}`,
|
|
32579
|
+
text: `${oversizePictureText(artifact.name, bytes)}, so dispatch doc-read cannot show this ` + `uploaded ${mime} picture (version ${number}${of}). ${bytesRoute}${hashLine}`,
|
|
32552
32580
|
details
|
|
32553
32581
|
});
|
|
32554
|
-
const stated = versions.find((version) => version.number === number);
|
|
32555
32582
|
if (artifact.kind === "image" && stated?.size !== undefined && stated.size > PICTURE_SHOWN_MAX_BYTES) {
|
|
32556
32583
|
return tooLarge(stated.mime ?? "image", stated.size);
|
|
32557
32584
|
}
|
|
@@ -32563,7 +32590,7 @@ async function readUploadedFile(client, artifact, details, requested, owner, sho
|
|
|
32563
32590
|
const address = `dispatch://${owner}/artifact/${artifact.slug}@v${number}`;
|
|
32564
32591
|
shown?.add(address);
|
|
32565
32592
|
return {
|
|
32566
|
-
text: `Picture ${artifact.name}: ${image.mimeType}, version ${number}${of}, ${size}
|
|
32593
|
+
text: `Picture ${artifact.name}: ${image.mimeType}, version ${number}${of}, ${size}.${hashLine}
|
|
32567
32594
|
` + shownPictureLine(1, address, artifact.name, image.mimeType, file.bytes.length),
|
|
32568
32595
|
details,
|
|
32569
32596
|
images: [image]
|
|
@@ -32574,15 +32601,15 @@ async function readUploadedFile(client, artifact, details, requested, owner, sho
|
|
|
32574
32601
|
}
|
|
32575
32602
|
let text;
|
|
32576
32603
|
try {
|
|
32577
|
-
text = new TextDecoder("utf-8", { fatal: true }).decode(file.bytes);
|
|
32604
|
+
text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(file.bytes);
|
|
32578
32605
|
} catch {
|
|
32579
32606
|
return {
|
|
32580
|
-
text: `${artifact.name} is an uploaded ${file.mime} file (version ${number}${of}, ${size}) that is not ` + `UTF-8 text, so dispatch doc-read cannot show it. ${bytesRoute}`,
|
|
32607
|
+
text: `${artifact.name} is an uploaded ${file.mime} file (version ${number}${of}, ${size}) that is not ` + `UTF-8 text, so dispatch doc-read cannot show it. ${bytesRoute}${hashLine}`,
|
|
32581
32608
|
details
|
|
32582
32609
|
};
|
|
32583
32610
|
}
|
|
32584
32611
|
return {
|
|
32585
|
-
text: `File ${artifact.name}: ${file.mime}, version ${number}${of}, ${size}
|
|
32612
|
+
text: `File ${artifact.name}: ${file.mime}, version ${number}${of}, ${size}.${hashLine}
|
|
32586
32613
|
|
|
32587
32614
|
${text}`,
|
|
32588
32615
|
details
|
|
@@ -32913,8 +32940,9 @@ async function artifactCommand(context) {
|
|
|
32913
32940
|
if ((path !== undefined || !blank) && optionalBoolean(args, "force") !== true) {
|
|
32914
32941
|
const held = artifactUnderName(artifactOwner.kind === "project" ? await client.listProjectArtifacts(artifactOwner.project, true) : await client.listIssueArtifacts(issue()), name);
|
|
32915
32942
|
if (held !== undefined) {
|
|
32943
|
+
const kind = await uploadKindOf(path, (named) => input.uploadBytes === undefined ? readPictureHead(resolvePath2(input.cwd, named)) : Promise.resolve(input.uploadBytes.subarray(0, PICTURE_SNIFF_BYTES)));
|
|
32916
32944
|
throw new ToolInputError(input.tool, [
|
|
32917
|
-
artifactNameExistsProblem(held, artifactOwner.kind === "project" ? `project ${artifactOwner.project}` : `issue ${issue()}
|
|
32945
|
+
artifactNameExistsProblem(held, artifactOwner.kind === "project" ? `project ${artifactOwner.project}` : `issue ${issue()}`, kind)
|
|
32918
32946
|
]);
|
|
32919
32947
|
}
|
|
32920
32948
|
}
|
package/dist/envoy-channel.js
CHANGED
|
@@ -36731,7 +36731,8 @@ var versionFields = {
|
|
|
36731
36731
|
created_at: string2(),
|
|
36732
36732
|
size: number2().int().optional(),
|
|
36733
36733
|
mime: string2().optional(),
|
|
36734
|
-
sha256: string2().optional()
|
|
36734
|
+
sha256: string2().optional(),
|
|
36735
|
+
token: string2().optional()
|
|
36735
36736
|
};
|
|
36736
36737
|
var VersionSchema = strictObject(versionFields).readonly();
|
|
36737
36738
|
var DocumentRoleSchema = _enum2(["verification", "plan", "decisions"]);
|
|
@@ -36895,6 +36896,20 @@ var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text
|
|
|
36895
36896
|
var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
|
|
36896
36897
|
var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so a document's name ends in .md or .markdown or has no extension, under content and under neither flag alike; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
|
|
36897
36898
|
var ARTIFACT_NAME_EXISTS_RULE = `An upload under the name of a document the owner already holds is refused: it writes that document's next version, over the text it holds. Change a document with dispatch doc-edit. To write the next version, send the upload again with force (--force) and the token of the version it replaces (--precondition-json '{"document":"sha256:\u2026"}', the token dispatch doc-read prints).`;
|
|
36899
|
+
function artifactKindWord(kind) {
|
|
36900
|
+
return { doc: "document", file: "file", image: "picture" }[kind] ?? kind;
|
|
36901
|
+
}
|
|
36902
|
+
function fileNameExistsRule(kind, statesToken) {
|
|
36903
|
+
const what = artifactKindWord(kind);
|
|
36904
|
+
const head = `An upload under the name of a ${what} the owner already holds is refused: it writes that ${what}'s next version, over the bytes it holds.`;
|
|
36905
|
+
if (!statesToken) {
|
|
36906
|
+
return `${head} The version standing under the name states no token, so an upload naming one is refused: to write the next version, read the ${what} again with dispatch doc-read, then send the upload again with force (--force) alone.`;
|
|
36907
|
+
}
|
|
36908
|
+
return `${head} To write the next version, send the upload again with force (--force) and the token of the version you read: --precondition-json '{"document":"<the Document token your own dispatch doc-read of the ${what} printed>"}'. A version written since that read refuses it 409 PRECONDITION_FAILED: read the ${what} again before you replace it.`;
|
|
36909
|
+
}
|
|
36910
|
+
function artifactKindConflictRule(held, upload) {
|
|
36911
|
+
return `This upload is a ${artifactKindWord(upload)}, and the name holds a ${artifactKindWord(held)}: Dispatch keeps one kind under one name, so this upload cannot be its next version, with force or without. Give the upload another name.`;
|
|
36912
|
+
}
|
|
36898
36913
|
var ARTIFACT_STORED_TEXT_RULE = `content and content-file hold text Dispatch stores as Markdown, and a text the store would write under another spelling is refused. A typed block whose attributes differ from Dispatch's only in their order is not refused: the command uploads it with them in Dispatch's order and names each such block. A refusal names the first difference: a changed line by the attribute or the word that differs, a word of more than 200 characters by a window from its first character that differs, and a line the store adds or drops by a quote cut at 200 characters, each cut named. The refusal prints the text Dispatch stores: send that text. A name that does not end in .md or .markdown has a second way out, which keeps the text as it was written: send it as a file with ${PATH_KEEPS_BYTES}.`;
|
|
36899
36914
|
var NAME_EXTENSION = /\.([^\s.]+)$/u;
|
|
36900
36915
|
var MARKDOWN_EXTENSION = /^(md|markdown)$/i;
|
|
@@ -36909,8 +36924,8 @@ function preconditionArgument(z) {
|
|
|
36909
36924
|
}
|
|
36910
36925
|
function uploadPreconditionArgument(z) {
|
|
36911
36926
|
return z.object({
|
|
36912
|
-
document: z.string({ min: 1 }).describe("Token
|
|
36913
|
-
}).describe("The token of the version this upload replaces, which an upload over a document the owner already holds
|
|
36927
|
+
document: z.string({ min: 1 }).describe("Token of the version this upload replaces, as dispatch doc-read prints it for a document, a file or a picture.")
|
|
36928
|
+
}).describe("The token of the version this upload replaces, which an upload over a document, a file or a picture the owner already holds names; a first upload under a name replaces nothing and names none.").optional();
|
|
36914
36929
|
}
|
|
36915
36930
|
function pathKeepsBytesOf(name) {
|
|
36916
36931
|
const extension = NAME_EXTENSION.exec(name.trim())?.[1];
|
|
@@ -37535,7 +37550,7 @@ var dispatchToolSpecs = [
|
|
|
37535
37550
|
{
|
|
37536
37551
|
name: "dispatch_doc_read",
|
|
37537
37552
|
example: { issue: "DSP-1" },
|
|
37538
|
-
description: "Read a live document or a named document version, or the text of an uploaded file at its latest or named 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. With blocks it lists the live document's blocks instead of its markdown, in document order: each block's id, type, token, anchored comments and asks, and opening words, a typed block's serves and needs under it, and under a table each row by the index delete_row takes and each cell by its row and the column delete_column takes; block ids, block tokens and those indexes are what dispatch doc-edit takes. " + "After the markdown it prints every open thread anchored on the document in full: an open ask with its id and question and each reply's author, time and text, and a comment thread with its root's id, author, time, quote and text and each reply's author, time and text, in order; a resolved thread, and an ask that is answered or resolved, is not printed. " + "A picture (an uploaded PNG, JPEG, GIF or WebP of at most 3,750,000 bytes, 5 MB once base64-encoded) comes back as an image you see, with its name, type, size and version, every time you ask, including one a read already showed this session; " + "any other file that is not UTF-8 text is described, with the route that serves its bytes. " + OWNER_REFERENCE,
|
|
37553
|
+
description: "Read a live document or a named document version, or the text of an uploaded file at its latest or named 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. With blocks it lists the live document's blocks instead of its markdown, in document order: each block's id, type, token, anchored comments and asks, and opening words, a typed block's serves and needs under it, and under a table each row by the index delete_row takes and each cell by its row and the column delete_column takes; block ids, block tokens and those indexes are what dispatch doc-edit takes. " + "After the markdown it prints every open thread anchored on the document in full: an open ask with its id and question and each reply's author, time and text, and a comment thread with its root's id, author, time, quote and text and each reply's author, time and text, in order; a resolved thread, and an ask that is answered or resolved, is not printed. " + "A picture (an uploaded PNG, JPEG, GIF or WebP of at most 3,750,000 bytes, 5 MB once base64-encoded) comes back as an image you see, with its name, type, size and version, every time you ask, including one a read already showed this session; " + "any other file that is not UTF-8 text is described, with the route that serves its bytes. " + "A read of an uploaded file or picture prints, in its header before the file's text, the latest version's token as a `Document token: sha256:\u2026` line, which dispatch artifact's precondition takes for the next version, or a named version's hash as a `Content: sha256:\u2026` line; the text after the header is the stored file unchanged, except that the dispatch command adds a line feed after a file that ends without one and, under Claude Code or Codex, cuts an output past 25,000 characters and writes the whole of it to a file it names. " + OWNER_REFERENCE,
|
|
37539
37554
|
arguments: (z) => ({
|
|
37540
37555
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
37541
37556
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -37630,7 +37645,7 @@ var dispatchToolSpecs = [
|
|
|
37630
37645
|
name: "dispatch_artifact",
|
|
37631
37646
|
example: { issue: "DSP-1", name: "design.md", content: `# Design
|
|
37632
37647
|
` },
|
|
37633
|
-
description: "Attach a local file or inline text as an issue artifact or project document, or make an empty document from its name alone. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. " + `${ARTIFACT_SOURCE_RULE} ` + `${ARTIFACT_NAME_EXISTS_RULE} A call that stores nothing - no path, and content absent or blank - is refused under a held name even with force and a token, so a title typed twice never empties the document that holds it; that refusal names no token, since no token makes such a call one Dispatch takes. ` + "A markdown document is at most 1 MiB and any other file at most 25 MiB. " + "An upload that replaces a document the owner already holds under that name says which version it replaces: precondition.document takes the document token dispatch doc-read prints as `Document token: sha256:\u2026`, and Dispatch checks it under the write's own lock. An upload that names none is taken for now without a check, since older dispatch commands cannot name one; name the token wherever the command can, because a later release refuses an upload naming none with 400 PRECONDITION_REQUIRED. A token behind the live document is refused with 409 PRECONDITION_FAILED. The refusal tells you to read the document again with dispatch doc-read, which prints the token the document carries now, and to upload again naming that token.
|
|
37648
|
+
description: "Attach a local file or inline text as an issue artifact or project document, or make an empty document from its name alone. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. " + `${ARTIFACT_SOURCE_RULE} ` + `${ARTIFACT_NAME_EXISTS_RULE} A call that stores nothing - no path, and content absent or blank - is refused under a held name even with force and a token, so a title typed twice never empties the document that holds it; that refusal names no token, since no token makes such a call one Dispatch takes. ` + "A markdown document is at most 1 MiB and any other file at most 25 MiB. " + "An upload that replaces a document the owner already holds under that name says which version it replaces: precondition.document takes the document token dispatch doc-read prints as `Document token: sha256:\u2026`, and Dispatch checks it under the write's own lock. An upload that names none is taken for now without a check, since older dispatch commands cannot name one; name the token wherever the command can, because a later release refuses an upload naming none with 400 PRECONDITION_REQUIRED. A token behind the live document is refused with 409 PRECONDITION_FAILED. The refusal tells you to read the document again with dispatch doc-read, which prints the token the document carries now, and to upload again naming that token. An upload that replaces a file or a picture names the token of the version it replaces the same way, the `Document token:` line dispatch doc-read prints for its latest version, and any other token is refused with 409 PRECONDITION_FAILED; one naming none is taken unchecked. The command's refusal of a name the owner holds prints no token: for a file or a picture it names --force with the token your own dispatch doc-read printed, or --force alone where Dispatch states no token for the file, since such a Dispatch refuses a token on a file's upload; for an upload of another kind than the name holds (a declared Markdown upload is a document, PNG, JPEG, GIF or WebP bytes a picture, anything else a file) it names another name, since Dispatch refuses it under that name with 400 ARTIFACT_KIND_MISMATCH. A first upload under a name replaces no version, so it names none. " + `${ARTIFACT_CONTENT_NAME_RULE} ${ARTIFACT_STORED_TEXT_RULE} ` + "Markdown is also refused with 413 CAP_EXCEEDED when it makes more than 65,536 elements (a block weighs 3, and an empty list item, quote, footnote definition or typed block 3 more for the empty paragraph it holds; a table cell 4, a hard line break 3, an image 3, a piece of inline HTML 2, an autolink 2, a footnote reference 2; inline syntax, marks, lines of text and backslash escapes or character references 1 each), or when a new version would leave the document's stored markdown (what its text reads back as) longer than 1 MiB or making more than 65,536 elements, and longer or heavier than before; shorten it or split it across documents. " + "In a table row, write every | in a cell as \\|, in code too: a | after two backslashes ends the cell, and a row with more cells than its table is refused. " + "Markdown holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK; a new version of a document is held to it only for the asks it writes or changes. " + `${CI_CHECK_RULE} ` + `${OWNER_REFERENCE}`,
|
|
37634
37649
|
arguments: (z) => ({
|
|
37635
37650
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
37636
37651
|
project: z.string().describe("Project key for an unlinked document.").optional(),
|
|
@@ -49621,7 +49636,7 @@ function oversizePictureText(name, bytes) {
|
|
|
49621
49636
|
}
|
|
49622
49637
|
var PICTURES_SHOWN_MAX = 8;
|
|
49623
49638
|
var PICTURES_SHOWN_MAX_BYTES = 10 * 1024 * 1024;
|
|
49624
|
-
var PICTURE_SNIFF_BYTES =
|
|
49639
|
+
var PICTURE_SNIFF_BYTES = 14;
|
|
49625
49640
|
function bytesAt(bytes, offset, expected) {
|
|
49626
49641
|
return expected.every((byte, index) => bytes[offset + index] === byte);
|
|
49627
49642
|
}
|
|
@@ -49633,11 +49648,14 @@ function sniffPictureType(bytes) {
|
|
|
49633
49648
|
if (bytesAt(bytes, 0, [71, 73, 70, 56]) && (bytes[4] === 55 || bytes[4] === 57) && bytes[5] === 97) {
|
|
49634
49649
|
return "image/gif";
|
|
49635
49650
|
}
|
|
49636
|
-
if (bytesAt(bytes, 0, [82, 73, 70, 70]) && bytesAt(bytes, 8, [87, 69, 66, 80])) {
|
|
49651
|
+
if (bytesAt(bytes, 0, [82, 73, 70, 70]) && bytesAt(bytes, 8, [87, 69, 66, 80, 86, 80])) {
|
|
49637
49652
|
return "image/webp";
|
|
49638
49653
|
}
|
|
49639
49654
|
return;
|
|
49640
49655
|
}
|
|
49656
|
+
async function readPictureHead(path) {
|
|
49657
|
+
return new Uint8Array(await Bun.file(path).slice(0, PICTURE_SNIFF_BYTES).arrayBuffer());
|
|
49658
|
+
}
|
|
49641
49659
|
function toolImage(bytes) {
|
|
49642
49660
|
const mimeType = sniffPictureType(bytes);
|
|
49643
49661
|
if (mimeType === undefined || bytes.length > PICTURE_SHOWN_MAX_BYTES)
|
|
@@ -50611,7 +50629,7 @@ async function localPicture(path, cwd) {
|
|
|
50611
50629
|
if (!stats.isFile())
|
|
50612
50630
|
return `images: ${path} is not a file`;
|
|
50613
50631
|
size = stats.size;
|
|
50614
|
-
head =
|
|
50632
|
+
head = await readPictureHead(absolute);
|
|
50615
50633
|
} catch (error) {
|
|
50616
50634
|
return `images: ${path} cannot be read: ${messageFor(error)}`;
|
|
50617
50635
|
}
|
|
@@ -54824,15 +54842,21 @@ function artifactUnderName(artifacts, name) {
|
|
|
54824
54842
|
const written = name.trim();
|
|
54825
54843
|
return artifacts.find((held) => held.slug === written) ?? artifacts.find((held) => held.name === written);
|
|
54826
54844
|
}
|
|
54827
|
-
function
|
|
54845
|
+
async function uploadKindOf(path, head) {
|
|
54846
|
+
if (path === undefined || !pathKeepsBytesOf(path))
|
|
54847
|
+
return "doc";
|
|
54848
|
+
return sniffPictureType(await head(path)) === undefined ? "file" : "image";
|
|
54849
|
+
}
|
|
54850
|
+
function artifactNameExistsProblem(held, owner, upload) {
|
|
54828
54851
|
const versions = held.versions ?? [];
|
|
54829
54852
|
const newest = versions[versions.length - 1];
|
|
54853
|
+
const rule = upload !== held.kind ? artifactKindConflictRule(held.kind, upload) : held.kind === "doc" ? ARTIFACT_NAME_EXISTS_RULE : fileNameExistsRule(held.kind, newest?.token !== undefined);
|
|
54830
54854
|
if (newest === undefined) {
|
|
54831
|
-
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}), which has no version yet and which ${actorText(held.created_by)} created. ${
|
|
54855
|
+
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}), which has no version yet and which ${actorText(held.created_by)} created. ${rule}`;
|
|
54832
54856
|
}
|
|
54833
54857
|
const authors = (newest.authors ?? []).map(actorText);
|
|
54834
54858
|
const wroteIt = authors.length === 0 ? actorText(held.created_by) : authors.join(" and ");
|
|
54835
|
-
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${
|
|
54859
|
+
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${rule}`;
|
|
54836
54860
|
}
|
|
54837
54861
|
function storedTextCheckFailed(error, name) {
|
|
54838
54862
|
if (error instanceof DispatchAnswerNotKeptError) {
|
|
@@ -54860,11 +54884,14 @@ async function readUploadedFile(client, artifact, details, requested, owner, sho
|
|
|
54860
54884
|
const number = requested ?? latest;
|
|
54861
54885
|
const of = number === latest ? "" : ` of ${latest}`;
|
|
54862
54886
|
const bytesRoute = `GET /api/v1/artifacts/${artifact.id}/versions/${number} serves its bytes.`;
|
|
54887
|
+
const stated = versions.find((version) => version.number === number);
|
|
54888
|
+
const hashLine = requested === undefined ? stated?.token === undefined ? "" : `
|
|
54889
|
+
Document token: ${stated.token}` : stated?.sha256 === undefined ? "" : `
|
|
54890
|
+
Content: sha256:${stated.sha256}`;
|
|
54863
54891
|
const tooLarge = (mime, bytes) => ({
|
|
54864
|
-
text: `${oversizePictureText(artifact.name, bytes)}, so dispatch doc-read cannot show this ` + `uploaded ${mime} picture (version ${number}${of}). ${bytesRoute}`,
|
|
54892
|
+
text: `${oversizePictureText(artifact.name, bytes)}, so dispatch doc-read cannot show this ` + `uploaded ${mime} picture (version ${number}${of}). ${bytesRoute}${hashLine}`,
|
|
54865
54893
|
details
|
|
54866
54894
|
});
|
|
54867
|
-
const stated = versions.find((version) => version.number === number);
|
|
54868
54895
|
if (artifact.kind === "image" && stated?.size !== undefined && stated.size > PICTURE_SHOWN_MAX_BYTES) {
|
|
54869
54896
|
return tooLarge(stated.mime ?? "image", stated.size);
|
|
54870
54897
|
}
|
|
@@ -54876,7 +54903,7 @@ async function readUploadedFile(client, artifact, details, requested, owner, sho
|
|
|
54876
54903
|
const address = `dispatch://${owner}/artifact/${artifact.slug}@v${number}`;
|
|
54877
54904
|
shown?.add(address);
|
|
54878
54905
|
return {
|
|
54879
|
-
text: `Picture ${artifact.name}: ${image.mimeType}, version ${number}${of}, ${size}
|
|
54906
|
+
text: `Picture ${artifact.name}: ${image.mimeType}, version ${number}${of}, ${size}.${hashLine}
|
|
54880
54907
|
` + shownPictureLine(1, address, artifact.name, image.mimeType, file.bytes.length),
|
|
54881
54908
|
details,
|
|
54882
54909
|
images: [image]
|
|
@@ -54887,15 +54914,15 @@ async function readUploadedFile(client, artifact, details, requested, owner, sho
|
|
|
54887
54914
|
}
|
|
54888
54915
|
let text;
|
|
54889
54916
|
try {
|
|
54890
|
-
text = new TextDecoder("utf-8", { fatal: true }).decode(file.bytes);
|
|
54917
|
+
text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(file.bytes);
|
|
54891
54918
|
} catch {
|
|
54892
54919
|
return {
|
|
54893
|
-
text: `${artifact.name} is an uploaded ${file.mime} file (version ${number}${of}, ${size}) that is not ` + `UTF-8 text, so dispatch doc-read cannot show it. ${bytesRoute}`,
|
|
54920
|
+
text: `${artifact.name} is an uploaded ${file.mime} file (version ${number}${of}, ${size}) that is not ` + `UTF-8 text, so dispatch doc-read cannot show it. ${bytesRoute}${hashLine}`,
|
|
54894
54921
|
details
|
|
54895
54922
|
};
|
|
54896
54923
|
}
|
|
54897
54924
|
return {
|
|
54898
|
-
text: `File ${artifact.name}: ${file.mime}, version ${number}${of}, ${size}
|
|
54925
|
+
text: `File ${artifact.name}: ${file.mime}, version ${number}${of}, ${size}.${hashLine}
|
|
54899
54926
|
|
|
54900
54927
|
${text}`,
|
|
54901
54928
|
details
|
|
@@ -55226,8 +55253,9 @@ async function artifactCommand(context) {
|
|
|
55226
55253
|
if ((path !== undefined || !blank) && optionalBoolean(args, "force") !== true) {
|
|
55227
55254
|
const held = artifactUnderName(artifactOwner.kind === "project" ? await client.listProjectArtifacts(artifactOwner.project, true) : await client.listIssueArtifacts(issue()), name);
|
|
55228
55255
|
if (held !== undefined) {
|
|
55256
|
+
const kind = await uploadKindOf(path, (named) => input.uploadBytes === undefined ? readPictureHead(resolvePath2(input.cwd, named)) : Promise.resolve(input.uploadBytes.subarray(0, PICTURE_SNIFF_BYTES)));
|
|
55229
55257
|
throw new ToolInputError(input.tool, [
|
|
55230
|
-
artifactNameExistsProblem(held, artifactOwner.kind === "project" ? `project ${artifactOwner.project}` : `issue ${issue()}
|
|
55258
|
+
artifactNameExistsProblem(held, artifactOwner.kind === "project" ? `project ${artifactOwner.project}` : `issue ${issue()}`, kind)
|
|
55231
55259
|
]);
|
|
55232
55260
|
}
|
|
55233
55261
|
}
|
|
@@ -62801,7 +62829,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
|
|
|
62801
62829
|
|
|
62802
62830
|
// package.json
|
|
62803
62831
|
var name2 = "@sjawhar/claude-envoy";
|
|
62804
|
-
var version2 = "5.23.
|
|
62832
|
+
var version2 = "5.23.6";
|
|
62805
62833
|
var legion = {
|
|
62806
62834
|
daemonApiVersion: 250
|
|
62807
62835
|
};
|
|
@@ -71217,7 +71245,7 @@ function callingThread(meta) {
|
|
|
71217
71245
|
}
|
|
71218
71246
|
function dispatchToolDefinition() {
|
|
71219
71247
|
return {
|
|
71220
|
-
description: 'Runs the `dispatch` command as this session, outside Codex\'s sandbox. Pass the words after `dispatch` as `args` (for example ["read", "--issue", "LEGION-3"]) and what the command would read on standard input as `stdin` (the text of a here-document given as `--body-file -`). `["--help"]` lists the commands. Answers with what the command printed and its exit code: 0 written or read, 1
|
|
71248
|
+
description: 'Runs the `dispatch` command as this session, outside Codex\'s sandbox. Pass the words after `dispatch` as `args` (for example ["read", "--issue", "LEGION-3"]) and what the command would read on standard input as `stdin` (the text of a here-document given as `--body-file -`). `["--help"]` lists the commands. Answers with what the command printed and its exit code: 0 written or read, 2 a usage error, 1 any other failure: Dispatch\'s refusal, a Dispatch the command cannot reach, or `ANSWER_NOT_KEPT` for a call that wrote nothing, which you run again.',
|
|
71221
71249
|
inputSchema: {
|
|
71222
71250
|
properties: {
|
|
71223
71251
|
args: {
|
package/dist/session-hook.js
CHANGED
|
@@ -17381,7 +17381,8 @@ var versionFields = {
|
|
|
17381
17381
|
created_at: string2(),
|
|
17382
17382
|
size: number2().int().optional(),
|
|
17383
17383
|
mime: string2().optional(),
|
|
17384
|
-
sha256: string2().optional()
|
|
17384
|
+
sha256: string2().optional(),
|
|
17385
|
+
token: string2().optional()
|
|
17385
17386
|
};
|
|
17386
17387
|
var VersionSchema = strictObject(versionFields).readonly();
|
|
17387
17388
|
var DocumentRoleSchema = _enum2(["verification", "plan", "decisions"]);
|
|
@@ -17545,6 +17546,20 @@ var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text
|
|
|
17545
17546
|
var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
|
|
17546
17547
|
var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so a document's name ends in .md or .markdown or has no extension, under content and under neither flag alike; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
|
|
17547
17548
|
var ARTIFACT_NAME_EXISTS_RULE = `An upload under the name of a document the owner already holds is refused: it writes that document's next version, over the text it holds. Change a document with dispatch doc-edit. To write the next version, send the upload again with force (--force) and the token of the version it replaces (--precondition-json '{"document":"sha256:\u2026"}', the token dispatch doc-read prints).`;
|
|
17549
|
+
function artifactKindWord(kind) {
|
|
17550
|
+
return { doc: "document", file: "file", image: "picture" }[kind] ?? kind;
|
|
17551
|
+
}
|
|
17552
|
+
function fileNameExistsRule(kind, statesToken) {
|
|
17553
|
+
const what = artifactKindWord(kind);
|
|
17554
|
+
const head = `An upload under the name of a ${what} the owner already holds is refused: it writes that ${what}'s next version, over the bytes it holds.`;
|
|
17555
|
+
if (!statesToken) {
|
|
17556
|
+
return `${head} The version standing under the name states no token, so an upload naming one is refused: to write the next version, read the ${what} again with dispatch doc-read, then send the upload again with force (--force) alone.`;
|
|
17557
|
+
}
|
|
17558
|
+
return `${head} To write the next version, send the upload again with force (--force) and the token of the version you read: --precondition-json '{"document":"<the Document token your own dispatch doc-read of the ${what} printed>"}'. A version written since that read refuses it 409 PRECONDITION_FAILED: read the ${what} again before you replace it.`;
|
|
17559
|
+
}
|
|
17560
|
+
function artifactKindConflictRule(held, upload) {
|
|
17561
|
+
return `This upload is a ${artifactKindWord(upload)}, and the name holds a ${artifactKindWord(held)}: Dispatch keeps one kind under one name, so this upload cannot be its next version, with force or without. Give the upload another name.`;
|
|
17562
|
+
}
|
|
17548
17563
|
var ARTIFACT_STORED_TEXT_RULE = `content and content-file hold text Dispatch stores as Markdown, and a text the store would write under another spelling is refused. A typed block whose attributes differ from Dispatch's only in their order is not refused: the command uploads it with them in Dispatch's order and names each such block. A refusal names the first difference: a changed line by the attribute or the word that differs, a word of more than 200 characters by a window from its first character that differs, and a line the store adds or drops by a quote cut at 200 characters, each cut named. The refusal prints the text Dispatch stores: send that text. A name that does not end in .md or .markdown has a second way out, which keeps the text as it was written: send it as a file with ${PATH_KEEPS_BYTES}.`;
|
|
17549
17564
|
var NAME_EXTENSION = /\.([^\s.]+)$/u;
|
|
17550
17565
|
var MARKDOWN_EXTENSION = /^(md|markdown)$/i;
|
|
@@ -17559,8 +17574,8 @@ function preconditionArgument(z) {
|
|
|
17559
17574
|
}
|
|
17560
17575
|
function uploadPreconditionArgument(z) {
|
|
17561
17576
|
return z.object({
|
|
17562
|
-
document: z.string({ min: 1 }).describe("Token
|
|
17563
|
-
}).describe("The token of the version this upload replaces, which an upload over a document the owner already holds
|
|
17577
|
+
document: z.string({ min: 1 }).describe("Token of the version this upload replaces, as dispatch doc-read prints it for a document, a file or a picture.")
|
|
17578
|
+
}).describe("The token of the version this upload replaces, which an upload over a document, a file or a picture the owner already holds names; a first upload under a name replaces nothing and names none.").optional();
|
|
17564
17579
|
}
|
|
17565
17580
|
function pathKeepsBytesOf(name) {
|
|
17566
17581
|
const extension = NAME_EXTENSION.exec(name.trim())?.[1];
|
|
@@ -18185,7 +18200,7 @@ var dispatchToolSpecs = [
|
|
|
18185
18200
|
{
|
|
18186
18201
|
name: "dispatch_doc_read",
|
|
18187
18202
|
example: { issue: "DSP-1" },
|
|
18188
|
-
description: "Read a live document or a named document version, or the text of an uploaded file at its latest or named 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. With blocks it lists the live document's blocks instead of its markdown, in document order: each block's id, type, token, anchored comments and asks, and opening words, a typed block's serves and needs under it, and under a table each row by the index delete_row takes and each cell by its row and the column delete_column takes; block ids, block tokens and those indexes are what dispatch doc-edit takes. " + "After the markdown it prints every open thread anchored on the document in full: an open ask with its id and question and each reply's author, time and text, and a comment thread with its root's id, author, time, quote and text and each reply's author, time and text, in order; a resolved thread, and an ask that is answered or resolved, is not printed. " + "A picture (an uploaded PNG, JPEG, GIF or WebP of at most 3,750,000 bytes, 5 MB once base64-encoded) comes back as an image you see, with its name, type, size and version, every time you ask, including one a read already showed this session; " + "any other file that is not UTF-8 text is described, with the route that serves its bytes. " + OWNER_REFERENCE,
|
|
18203
|
+
description: "Read a live document or a named document version, or the text of an uploaded file at its latest or named 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. With blocks it lists the live document's blocks instead of its markdown, in document order: each block's id, type, token, anchored comments and asks, and opening words, a typed block's serves and needs under it, and under a table each row by the index delete_row takes and each cell by its row and the column delete_column takes; block ids, block tokens and those indexes are what dispatch doc-edit takes. " + "After the markdown it prints every open thread anchored on the document in full: an open ask with its id and question and each reply's author, time and text, and a comment thread with its root's id, author, time, quote and text and each reply's author, time and text, in order; a resolved thread, and an ask that is answered or resolved, is not printed. " + "A picture (an uploaded PNG, JPEG, GIF or WebP of at most 3,750,000 bytes, 5 MB once base64-encoded) comes back as an image you see, with its name, type, size and version, every time you ask, including one a read already showed this session; " + "any other file that is not UTF-8 text is described, with the route that serves its bytes. " + "A read of an uploaded file or picture prints, in its header before the file's text, the latest version's token as a `Document token: sha256:\u2026` line, which dispatch artifact's precondition takes for the next version, or a named version's hash as a `Content: sha256:\u2026` line; the text after the header is the stored file unchanged, except that the dispatch command adds a line feed after a file that ends without one and, under Claude Code or Codex, cuts an output past 25,000 characters and writes the whole of it to a file it names. " + OWNER_REFERENCE,
|
|
18189
18204
|
arguments: (z) => ({
|
|
18190
18205
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
18191
18206
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -18280,7 +18295,7 @@ var dispatchToolSpecs = [
|
|
|
18280
18295
|
name: "dispatch_artifact",
|
|
18281
18296
|
example: { issue: "DSP-1", name: "design.md", content: `# Design
|
|
18282
18297
|
` },
|
|
18283
|
-
description: "Attach a local file or inline text as an issue artifact or project document, or make an empty document from its name alone. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. " + `${ARTIFACT_SOURCE_RULE} ` + `${ARTIFACT_NAME_EXISTS_RULE} A call that stores nothing - no path, and content absent or blank - is refused under a held name even with force and a token, so a title typed twice never empties the document that holds it; that refusal names no token, since no token makes such a call one Dispatch takes. ` + "A markdown document is at most 1 MiB and any other file at most 25 MiB. " + "An upload that replaces a document the owner already holds under that name says which version it replaces: precondition.document takes the document token dispatch doc-read prints as `Document token: sha256:\u2026`, and Dispatch checks it under the write's own lock. An upload that names none is taken for now without a check, since older dispatch commands cannot name one; name the token wherever the command can, because a later release refuses an upload naming none with 400 PRECONDITION_REQUIRED. A token behind the live document is refused with 409 PRECONDITION_FAILED. The refusal tells you to read the document again with dispatch doc-read, which prints the token the document carries now, and to upload again naming that token.
|
|
18298
|
+
description: "Attach a local file or inline text as an issue artifact or project document, or make an empty document from its name alone. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. " + `${ARTIFACT_SOURCE_RULE} ` + `${ARTIFACT_NAME_EXISTS_RULE} A call that stores nothing - no path, and content absent or blank - is refused under a held name even with force and a token, so a title typed twice never empties the document that holds it; that refusal names no token, since no token makes such a call one Dispatch takes. ` + "A markdown document is at most 1 MiB and any other file at most 25 MiB. " + "An upload that replaces a document the owner already holds under that name says which version it replaces: precondition.document takes the document token dispatch doc-read prints as `Document token: sha256:\u2026`, and Dispatch checks it under the write's own lock. An upload that names none is taken for now without a check, since older dispatch commands cannot name one; name the token wherever the command can, because a later release refuses an upload naming none with 400 PRECONDITION_REQUIRED. A token behind the live document is refused with 409 PRECONDITION_FAILED. The refusal tells you to read the document again with dispatch doc-read, which prints the token the document carries now, and to upload again naming that token. An upload that replaces a file or a picture names the token of the version it replaces the same way, the `Document token:` line dispatch doc-read prints for its latest version, and any other token is refused with 409 PRECONDITION_FAILED; one naming none is taken unchecked. The command's refusal of a name the owner holds prints no token: for a file or a picture it names --force with the token your own dispatch doc-read printed, or --force alone where Dispatch states no token for the file, since such a Dispatch refuses a token on a file's upload; for an upload of another kind than the name holds (a declared Markdown upload is a document, PNG, JPEG, GIF or WebP bytes a picture, anything else a file) it names another name, since Dispatch refuses it under that name with 400 ARTIFACT_KIND_MISMATCH. A first upload under a name replaces no version, so it names none. " + `${ARTIFACT_CONTENT_NAME_RULE} ${ARTIFACT_STORED_TEXT_RULE} ` + "Markdown is also refused with 413 CAP_EXCEEDED when it makes more than 65,536 elements (a block weighs 3, and an empty list item, quote, footnote definition or typed block 3 more for the empty paragraph it holds; a table cell 4, a hard line break 3, an image 3, a piece of inline HTML 2, an autolink 2, a footnote reference 2; inline syntax, marks, lines of text and backslash escapes or character references 1 each), or when a new version would leave the document's stored markdown (what its text reads back as) longer than 1 MiB or making more than 65,536 elements, and longer or heavier than before; shorten it or split it across documents. " + "In a table row, write every | in a cell as \\|, in code too: a | after two backslashes ends the cell, and a row with more cells than its table is refused. " + "Markdown holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK; a new version of a document is held to it only for the asks it writes or changes. " + `${CI_CHECK_RULE} ` + `${OWNER_REFERENCE}`,
|
|
18284
18299
|
arguments: (z) => ({
|
|
18285
18300
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
18286
18301
|
project: z.string().describe("Project key for an unlinked document.").optional(),
|
|
@@ -25163,7 +25178,7 @@ function oversizePictureText(name, bytes) {
|
|
|
25163
25178
|
}
|
|
25164
25179
|
var PICTURES_SHOWN_MAX = 8;
|
|
25165
25180
|
var PICTURES_SHOWN_MAX_BYTES = 10 * 1024 * 1024;
|
|
25166
|
-
var PICTURE_SNIFF_BYTES =
|
|
25181
|
+
var PICTURE_SNIFF_BYTES = 14;
|
|
25167
25182
|
function bytesAt(bytes, offset, expected) {
|
|
25168
25183
|
return expected.every((byte, index) => bytes[offset + index] === byte);
|
|
25169
25184
|
}
|
|
@@ -25175,11 +25190,14 @@ function sniffPictureType(bytes) {
|
|
|
25175
25190
|
if (bytesAt(bytes, 0, [71, 73, 70, 56]) && (bytes[4] === 55 || bytes[4] === 57) && bytes[5] === 97) {
|
|
25176
25191
|
return "image/gif";
|
|
25177
25192
|
}
|
|
25178
|
-
if (bytesAt(bytes, 0, [82, 73, 70, 70]) && bytesAt(bytes, 8, [87, 69, 66, 80])) {
|
|
25193
|
+
if (bytesAt(bytes, 0, [82, 73, 70, 70]) && bytesAt(bytes, 8, [87, 69, 66, 80, 86, 80])) {
|
|
25179
25194
|
return "image/webp";
|
|
25180
25195
|
}
|
|
25181
25196
|
return;
|
|
25182
25197
|
}
|
|
25198
|
+
async function readPictureHead(path) {
|
|
25199
|
+
return new Uint8Array(await Bun.file(path).slice(0, PICTURE_SNIFF_BYTES).arrayBuffer());
|
|
25200
|
+
}
|
|
25183
25201
|
function toolImage(bytes) {
|
|
25184
25202
|
const mimeType = sniffPictureType(bytes);
|
|
25185
25203
|
if (mimeType === undefined || bytes.length > PICTURE_SHOWN_MAX_BYTES)
|
|
@@ -26153,7 +26171,7 @@ async function localPicture(path, cwd) {
|
|
|
26153
26171
|
if (!stats.isFile())
|
|
26154
26172
|
return `images: ${path} is not a file`;
|
|
26155
26173
|
size = stats.size;
|
|
26156
|
-
head =
|
|
26174
|
+
head = await readPictureHead(absolute);
|
|
26157
26175
|
} catch (error) {
|
|
26158
26176
|
return `images: ${path} cannot be read: ${messageFor(error)}`;
|
|
26159
26177
|
}
|
|
@@ -30366,15 +30384,21 @@ function artifactUnderName(artifacts, name) {
|
|
|
30366
30384
|
const written = name.trim();
|
|
30367
30385
|
return artifacts.find((held) => held.slug === written) ?? artifacts.find((held) => held.name === written);
|
|
30368
30386
|
}
|
|
30369
|
-
function
|
|
30387
|
+
async function uploadKindOf(path, head) {
|
|
30388
|
+
if (path === undefined || !pathKeepsBytesOf(path))
|
|
30389
|
+
return "doc";
|
|
30390
|
+
return sniffPictureType(await head(path)) === undefined ? "file" : "image";
|
|
30391
|
+
}
|
|
30392
|
+
function artifactNameExistsProblem(held, owner, upload) {
|
|
30370
30393
|
const versions = held.versions ?? [];
|
|
30371
30394
|
const newest = versions[versions.length - 1];
|
|
30395
|
+
const rule = upload !== held.kind ? artifactKindConflictRule(held.kind, upload) : held.kind === "doc" ? ARTIFACT_NAME_EXISTS_RULE : fileNameExistsRule(held.kind, newest?.token !== undefined);
|
|
30372
30396
|
if (newest === undefined) {
|
|
30373
|
-
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}), which has no version yet and which ${actorText(held.created_by)} created. ${
|
|
30397
|
+
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}), which has no version yet and which ${actorText(held.created_by)} created. ${rule}`;
|
|
30374
30398
|
}
|
|
30375
30399
|
const authors = (newest.authors ?? []).map(actorText);
|
|
30376
30400
|
const wroteIt = authors.length === 0 ? actorText(held.created_by) : authors.join(" and ");
|
|
30377
|
-
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${
|
|
30401
|
+
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${rule}`;
|
|
30378
30402
|
}
|
|
30379
30403
|
function storedTextCheckFailed(error, name) {
|
|
30380
30404
|
if (error instanceof DispatchAnswerNotKeptError) {
|
|
@@ -30402,11 +30426,14 @@ async function readUploadedFile(client, artifact, details, requested, owner, sho
|
|
|
30402
30426
|
const number = requested ?? latest;
|
|
30403
30427
|
const of = number === latest ? "" : ` of ${latest}`;
|
|
30404
30428
|
const bytesRoute = `GET /api/v1/artifacts/${artifact.id}/versions/${number} serves its bytes.`;
|
|
30429
|
+
const stated = versions.find((version) => version.number === number);
|
|
30430
|
+
const hashLine = requested === undefined ? stated?.token === undefined ? "" : `
|
|
30431
|
+
Document token: ${stated.token}` : stated?.sha256 === undefined ? "" : `
|
|
30432
|
+
Content: sha256:${stated.sha256}`;
|
|
30405
30433
|
const tooLarge = (mime, bytes) => ({
|
|
30406
|
-
text: `${oversizePictureText(artifact.name, bytes)}, so dispatch doc-read cannot show this ` + `uploaded ${mime} picture (version ${number}${of}). ${bytesRoute}`,
|
|
30434
|
+
text: `${oversizePictureText(artifact.name, bytes)}, so dispatch doc-read cannot show this ` + `uploaded ${mime} picture (version ${number}${of}). ${bytesRoute}${hashLine}`,
|
|
30407
30435
|
details
|
|
30408
30436
|
});
|
|
30409
|
-
const stated = versions.find((version) => version.number === number);
|
|
30410
30437
|
if (artifact.kind === "image" && stated?.size !== undefined && stated.size > PICTURE_SHOWN_MAX_BYTES) {
|
|
30411
30438
|
return tooLarge(stated.mime ?? "image", stated.size);
|
|
30412
30439
|
}
|
|
@@ -30418,7 +30445,7 @@ async function readUploadedFile(client, artifact, details, requested, owner, sho
|
|
|
30418
30445
|
const address = `dispatch://${owner}/artifact/${artifact.slug}@v${number}`;
|
|
30419
30446
|
shown?.add(address);
|
|
30420
30447
|
return {
|
|
30421
|
-
text: `Picture ${artifact.name}: ${image.mimeType}, version ${number}${of}, ${size}
|
|
30448
|
+
text: `Picture ${artifact.name}: ${image.mimeType}, version ${number}${of}, ${size}.${hashLine}
|
|
30422
30449
|
` + shownPictureLine(1, address, artifact.name, image.mimeType, file.bytes.length),
|
|
30423
30450
|
details,
|
|
30424
30451
|
images: [image]
|
|
@@ -30429,15 +30456,15 @@ async function readUploadedFile(client, artifact, details, requested, owner, sho
|
|
|
30429
30456
|
}
|
|
30430
30457
|
let text;
|
|
30431
30458
|
try {
|
|
30432
|
-
text = new TextDecoder("utf-8", { fatal: true }).decode(file.bytes);
|
|
30459
|
+
text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(file.bytes);
|
|
30433
30460
|
} catch {
|
|
30434
30461
|
return {
|
|
30435
|
-
text: `${artifact.name} is an uploaded ${file.mime} file (version ${number}${of}, ${size}) that is not ` + `UTF-8 text, so dispatch doc-read cannot show it. ${bytesRoute}`,
|
|
30462
|
+
text: `${artifact.name} is an uploaded ${file.mime} file (version ${number}${of}, ${size}) that is not ` + `UTF-8 text, so dispatch doc-read cannot show it. ${bytesRoute}${hashLine}`,
|
|
30436
30463
|
details
|
|
30437
30464
|
};
|
|
30438
30465
|
}
|
|
30439
30466
|
return {
|
|
30440
|
-
text: `File ${artifact.name}: ${file.mime}, version ${number}${of}, ${size}
|
|
30467
|
+
text: `File ${artifact.name}: ${file.mime}, version ${number}${of}, ${size}.${hashLine}
|
|
30441
30468
|
|
|
30442
30469
|
${text}`,
|
|
30443
30470
|
details
|
|
@@ -30768,8 +30795,9 @@ async function artifactCommand(context) {
|
|
|
30768
30795
|
if ((path !== undefined || !blank) && optionalBoolean(args, "force") !== true) {
|
|
30769
30796
|
const held = artifactUnderName(artifactOwner.kind === "project" ? await client.listProjectArtifacts(artifactOwner.project, true) : await client.listIssueArtifacts(issue()), name);
|
|
30770
30797
|
if (held !== undefined) {
|
|
30798
|
+
const kind = await uploadKindOf(path, (named) => input.uploadBytes === undefined ? readPictureHead(resolvePath2(input.cwd, named)) : Promise.resolve(input.uploadBytes.subarray(0, PICTURE_SNIFF_BYTES)));
|
|
30771
30799
|
throw new ToolInputError(input.tool, [
|
|
30772
|
-
artifactNameExistsProblem(held, artifactOwner.kind === "project" ? `project ${artifactOwner.project}` : `issue ${issue()}
|
|
30800
|
+
artifactNameExistsProblem(held, artifactOwner.kind === "project" ? `project ${artifactOwner.project}` : `issue ${issue()}`, kind)
|
|
30773
30801
|
]);
|
|
30774
30802
|
}
|
|
30775
30803
|
}
|
|
@@ -13,7 +13,7 @@ Where a row says to ask a person, a child's own architect sends the question to
|
|
|
13
13
|
| `design-approved` | One gated step opened; `gatedSteps` in `read_record` says which. Once every step is `approved`, release the children (section 2). A task saying "this resume is your design-approved wake" is this wake. On a `handed_over` root, or a version a person's answer to a decision block wrote, start nothing. |
|
|
14
14
|
| `design-changes-requested` | Revise the document of the step whose `status` is `changes_requested` as the reason asks, then request approval again ("The armed gate" in `skill://legion-architect/references/design-gate.md`) and end your turn. One for an older version came late: answer its reason if the latest version does not. |
|
|
15
15
|
| `carried-gate-opened` | Start nothing and release nothing for it. |
|
|
16
|
-
| `phase-finished` | The next phase started, or `retro-held` came too. Read
|
|
16
|
+
| `phase-finished` | The next phase started, or `retro-held` came too. Read `dispatch results`, the pull request and its review, and tell the working role of any gap. A departure in `plan.md` under `## Departures from the spec`: keep the plan while the Summary, requirements, checks, scope and settled decisions hold, else change the spec ("After approval" in design-gate.md). When the step before `acceptance:owner` finishes, section 6 applies. A worker reporting that no surface reaches the changed path: build the surface in this tree, then tell it to continue. |
|
|
17
17
|
| `retro-held`, `task-stopped`, `plan-not-taken` | Act as "The notices" in `skill://legion-architect/references/plan-changes.md` says. |
|
|
18
18
|
| `pr-blocked` | The review round cap is reached: decide in this turn, as "A capped pull request" below says. |
|
|
19
19
|
| `checks-red` | The daemon asked the implementer, or in `merging` the merger, to merge the base forward; the issue stays in the phase the notice names. Start nothing ("A conflicting head" in `skill://legion-architect/references/acceptance.md`). |
|
|
@@ -44,7 +44,7 @@ Name them in the day's report and take nothing for them.
|
|
|
44
44
|
|
|
45
45
|
| Word | Meaning | What ends it |
|
|
46
46
|
|---|---|---|
|
|
47
|
-
| `tree_closed` | Its tree's root is `done`, or still lingering after it left the workflow | An architect's `release_children` of the live tree its Dispatch parent reaches, where that release is accepted, the end of the root's linger,
|
|
47
|
+
| `tree_closed` | Its tree's root is `done`, or still lingering after it left the workflow, or waiting in the line, its design gate open, for the promotion that opens its tree again | An architect's `release_children` of the live tree its Dispatch parent reaches, where that release is accepted, the end of the root's linger, a `todo` on the root, or the root's promotion from the waiting line |
|
|
48
48
|
| `tree_parked` | Its tree was parked and the linger ran out | A `todo` on the root; your own hold, the parked-root walk decides |
|
|
49
49
|
| `label_off` | A root whose `legion` label is off | A person's label |
|
|
50
50
|
| `ancestry` | Its Dispatch chain reaches another live root: that tree's unreleased work | That tree's architect releasing it or its parent, or the chain leaving that tree |
|
|
@@ -28,9 +28,9 @@ End each turn of that hold with a WAITING line naming the defect and the answer
|
|
|
28
28
|
|
|
29
29
|
## Steps
|
|
30
30
|
|
|
31
|
-
1. **Read the evidence**: the issue, `dispatch results --issue <issue>`, the pull request, and the
|
|
31
|
+
1. **Read the evidence**: the issue, `dispatch results --issue <issue>`, the pull request, and the thread of each plan task in `plan.md`.
|
|
32
32
|
Also read the tester's handoff (`dispatch handoff-read --issue <issue> --phase test`) where it has a tester step.
|
|
33
|
-
Read the review
|
|
33
|
+
Read the GitHub review of the last worker step's head where it has a reviewer step.
|
|
34
34
|
A pass must stand at the last worker step's head for every `before_merge` check, and the body's `Checks` block carries each.
|
|
35
35
|
|
|
36
36
|
- A check carrying `ci_check` is CI's: its derived result is the pass it needs (`skill://legion-worker/references/ci-checks.md`).
|
|
@@ -10,7 +10,7 @@ Your role prompt gives the workspace, the push, the handoff, `handoff_complete`,
|
|
|
10
10
|
## Every phase
|
|
11
11
|
|
|
12
12
|
1. Read the issue, then your task, then each earlier phase's handoff (`dispatch handoff-read --issue <issue> --phase <plan|implement|test|review>`).
|
|
13
|
-
Your architect's decisions for you come in your task and
|
|
13
|
+
Your architect's decisions for you come in your task, and in a reply in the thread of the plan task they concern, which its message links.
|
|
14
14
|
A record beats your memory.
|
|
15
15
|
|
|
16
16
|
2. Commit only your phase's paths: `jj -R "$LEGION_WORKSPACE" split -m "<message>" <paths…>`.
|
|
@@ -41,7 +41,7 @@ A head that conflicts with its base keeps the issue in its phase. The daemon rea
|
|
|
41
41
|
|
|
42
42
|
- Before `merging` the implementer gets a merge-forward message on its role topic, and in `merging` the merger does. Merge the base forward in `$LEGION_WORKSPACE`, the one workspace every role of the issue shares, as *Reintegrating the base* says, and push the issue branch, with no handoff and no completion for the merge. In `implementing` the phase is the implementer's, and its assignment and its completion stand.
|
|
43
43
|
- In `testing` and `reviewing`, the phase's worker is told to stop writing the workspace: stop at once, complete nothing at the old head, and keep your turn and its jobs. When the push lands you are told the new head: read the merge as above and go on at that head.
|
|
44
|
-
- `HANDOFF_HEAD_MERGED_FORWARD`: a merge forward the daemon asked for has landed above the head your completion names, or your completion names no head; nothing
|
|
44
|
+
- `HANDOFF_HEAD_MERGED_FORWARD`: a merge forward the daemon asked for has landed above the head your completion names, or your completion names no head; it moved nothing, and the daemon keeps the refusal, so the same call again is answered `HANDOFF_ALREADY_RECORDED`.
|
|
45
45
|
Read the merge (*Reading a merge of the base*, above), then complete again at the new head with a handoff that names it.
|
|
46
46
|
|
|
47
47
|
## A wrong pushed commit
|
|
@@ -6,7 +6,7 @@ Read it when you find a problem your issue does not cover (a defect in another c
|
|
|
6
6
|
|
|
7
7
|
A finding outside your issue never becomes a `dispatch issue` you file. Take the first step that fits:
|
|
8
8
|
|
|
9
|
-
1. **Fix it here.** A defect with a clear fix, in code your tree touches or depends on, goes into your tree's own pull request; say so in
|
|
9
|
+
1. **Fix it here.** A defect with a clear fix, in code your tree touches or depends on, goes into your tree's own pull request; say so in the PR body.
|
|
10
10
|
2. **Hand it over.** Any other clear defect goes to the controller with its evidence (*Send a finding to the controller*). It gives the work to the tree that owns the code, or files a Legion root when none does.
|
|
11
11
|
3. **Ask.** A finding that needs a person's authority, taste or risk appetite (whether it is wanted, which design, who owns it, a change of scope, cost or risk) is a `dispatch ask` with one recommendation (*What the ask says*).
|
|
12
12
|
|
package/package.json
CHANGED
package/skills/dispatch/SKILL.md
CHANGED
|
@@ -9,7 +9,7 @@ Dispatch is a record for the people who decide, never a log of your work.
|
|
|
9
9
|
|
|
10
10
|
- Use the `dispatch` command; the HTTP API only for what no command does. `dispatch <command> --help` gives its rules and an example.
|
|
11
11
|
- Put long text on stdin, one flag per call: `--<field>-file -` with `<<'EOF'`; objects and lists take JSON.
|
|
12
|
-
- Exit
|
|
12
|
+
- Exit 2 is a usage error: fix every problem it names before you call again. Exit 1 is any other failure: Dispatch's refusal, a Dispatch the command cannot reach, or `ANSWER_NOT_KEPT` for a call that wrote nothing, which you run again. `dispatch login` exits 1 when the broker cannot be reached or refuses, the person denies the login, or its code expires; its usage error names only the first bad argument.
|
|
13
13
|
- Never work around a hard-to-use command, or one storing or losing something wrongly: open an issue in the owning project and tell its controller. A Legion role tells its architect (`skill://legion-worker/references/findings.md`).
|
|
14
14
|
|
|
15
15
|
## Asks and ask blocks
|
|
@@ -140,7 +140,7 @@ export function callingThread(meta: unknown): string | undefined {
|
|
|
140
140
|
export function dispatchToolDefinition() {
|
|
141
141
|
return {
|
|
142
142
|
description:
|
|
143
|
-
'Runs the `dispatch` command as this session, outside Codex\'s sandbox. Pass the words after `dispatch` as `args` (for example ["read", "--issue", "LEGION-3"]) and what the command would read on standard input as `stdin` (the text of a here-document given as `--body-file -`). `["--help"]` lists the commands. Answers with what the command printed and its exit code: 0 written or read, 1
|
|
143
|
+
'Runs the `dispatch` command as this session, outside Codex\'s sandbox. Pass the words after `dispatch` as `args` (for example ["read", "--issue", "LEGION-3"]) and what the command would read on standard input as `stdin` (the text of a here-document given as `--body-file -`). `["--help"]` lists the commands. Answers with what the command printed and its exit code: 0 written or read, 2 a usage error, 1 any other failure: Dispatch\'s refusal, a Dispatch the command cannot reach, or `ANSWER_NOT_KEPT` for a call that wrote nothing, which you run again.',
|
|
144
144
|
inputSchema: {
|
|
145
145
|
properties: {
|
|
146
146
|
args: {
|