@sjawhar/claude-envoy 5.5.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/.omp-plugin/plugin.json +1 -1
- package/dist/codex-hook.js +366 -32
- package/dist/dispatch.js +2019 -1781
- package/dist/envoy-channel.js +368 -34
- package/dist/session-hook.js +366 -32
- package/legion/agents/plan-reviewer.md +1 -1
- package/package.json +1 -1
package/dist/envoy-channel.js
CHANGED
|
@@ -36868,7 +36868,7 @@ var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text
|
|
|
36868
36868
|
var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
|
|
36869
36869
|
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}.`;
|
|
36870
36870
|
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).`;
|
|
36871
|
-
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. 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}.`;
|
|
36871
|
+
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}.`;
|
|
36872
36872
|
var NAME_EXTENSION = /\.([^\s.]+)$/u;
|
|
36873
36873
|
var MARKDOWN_EXTENSION = /^(md|markdown)$/i;
|
|
36874
36874
|
function preconditionArgument(z) {
|
|
@@ -37170,7 +37170,7 @@ var dispatchToolSpecs = [
|
|
|
37170
37170
|
{
|
|
37171
37171
|
name: "dispatch_issue",
|
|
37172
37172
|
example: { project: "DSP", title: "Native workspace" },
|
|
37173
|
-
description: "Create a native Dispatch issue for newly tracked work. Search first with dispatch search; if potentially duplicate issues exist, this returns 409 POSSIBLE_DUPLICATE unless --force is set after reading them, or, when the refusal cannot be recorded, creates the issue and names the near copy to read in the result. " + "
|
|
37173
|
+
description: "Create a native Dispatch issue for newly tracked work. Search first with dispatch search; if potentially duplicate issues exist, this returns 409 POSSIBLE_DUPLICATE unless --force is set after reading them, or, when the refusal cannot be recorded, creates the issue and names the near copy to read in the result. " + "Where the spec is large, or changed in a way you cannot check alone, a fresh read-only reader can find its gaps and check its factual claims; a Legion architect can use `plan-gap-analyst` and `plan-reviewer`. " + "A spec 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. " + `${CI_CHECK_RULE} ` + "Create a project only when a person asks for one; work that spans projects goes in the project that owns most of it. " + `${RELATED_CHECK_RESULT} With --force, the result also names each issue whose title you forced past. ` + `Do not use it when an existing issue already covers the work; read or update that issue instead. ${ISSUE_REFERENCE}`,
|
|
37174
37174
|
arguments: (z) => ({
|
|
37175
37175
|
project: z.string().describe("Project key for the new issue."),
|
|
37176
37176
|
title: z.string({ max: ISSUE_TITLE_MAX }).describe("Concise issue title, at most 1,000 characters."),
|
|
@@ -37455,12 +37455,12 @@ var dispatchToolSpecs = [
|
|
|
37455
37455
|
{
|
|
37456
37456
|
name: "dispatch_request_approval",
|
|
37457
37457
|
example: { issue: "DSP-1", summary: "A live sync replaces the nightly export." },
|
|
37458
|
-
description: "Ask a human to approve a document at its current version.
|
|
37458
|
+
description: "Ask a human to approve a document at its current version. Where the spec is large, or changed in a way you cannot check alone, a fresh read-only reader can find its gaps and check its factual claims; a Legion architect can use `plan-gap-analyst` and `plan-reviewer`. Opens an approval ask (Approve / " + "Request changes) in the human's Inbox whose question names the document and version, " + "followed by the summary; the answer pins a review to that version and arrives as " + "artifact.approved or artifact.changes_requested. " + "The request reaches the person it was handed to, else the issue's assignee, else the " + "project's default assignee, so it always reaches a person, and this tool's answer names " + "that person. " + "An open request follows the document: a " + "later version moves it to that version and leaves it waiting on you, as a human's reply in " + "its thread does. Only the first move since the request was opened or handed back sends an " + "event, and never to the session whose version made it; dispatch doc-read shows whom it " + "waits on. Once the revision is complete and " + HUMAN_AGREED_TO_DOCUMENT + ", call this again to hand that same Inbox row back. The request carries nothing new. A " + "call while it already waits on the human hands nothing back: the same summary changes " + "nothing, and a different one is refused, since it would rewrite the card the human is " + "reading. Approve and Request changes each close the request, so the next call opens a new " + "one. Call it once per revision, when the revision is complete, never after each edit. An " + "approval goes stale when the document changes outside its decision blocks after it, until " + "a later version's text is exactly the approved version's again, as when an accidental " + "edit is undone exactly, and no decision block in it was decided since: that version " + "carries the approval and the document reads approved at it, so nothing is requested for " + "it. When the document does not read approved, request approval again once that revision " + "is complete and " + HUMAN_AGREED_TO_DOCUMENT + ", with a one-sentence summary naming what changed since the earlier approval: the card " + "names that approval (version, date, reviewer) and its Show diff control carries the detail. " + "A human's own answer to a decision block carries the approval to the version it writes when " + "that answer is the whole change since the approved version, so nothing is requested for " + "it. A new version of a Legion root spec closes its armed design gate until a human " + "approves it; a carried approval reopens it too. " + "Refused, with nothing sent, while the document holds an open decision block, even when a " + "human asked for approval: the refusal names each block; ask the human to answer or waive " + "it first. " + "Refused 409 PLAN_APPROVED_BY_REVIEW on an issue's plan, which its plan review approves " + "(dispatch plan-approve), never a person. " + "On an issue's spec the answer ends with a `Coverage of <name>:` line naming each requirement " + "the spec marks that no check serves, in any document of the issue or of its descendants, or saying " + "the spec marks no requirements; a spec every requirement of which has a check gets no such line. It never " + "names a missing plan task, and a gap refuses nothing. " + OWNER_REFERENCE,
|
|
37459
37459
|
arguments: (z) => ({
|
|
37460
37460
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
37461
37461
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
37462
37462
|
artifact: z.string().describe("Project document artifact id, slug, or filename; primary document by default for an issue.").optional(),
|
|
37463
|
-
summary: z.string({ min: 1 }).describe(`What the human is approving, in one to three sentences, and nothing else: no commentary on itself or the conversation, and no question; after an earlier approval, one sentence naming what changed since it, since the card shows that approval and a diff.
|
|
37463
|
+
summary: z.string({ min: 1 }).describe(`What the human is approving, in one to three sentences, and nothing else: no commentary on itself or the conversation, and no question; after an earlier approval, one sentence naming what changed since it, since the card shows that approval and a diff. Request approval only once ${HUMAN_AGREED_TO_DOCUMENT}.`),
|
|
37464
37464
|
include_verification: z.boolean().describe("Ask for the issue's Verification document in the same request, beside this one: one Inbox card names both at their current versions, and the answer records the human's review on each. 409 NO_VERIFICATION_DOCUMENT when the issue has no verification.md. Without it the request names this document alone and records nothing on the Verification document.").optional()
|
|
37465
37465
|
}),
|
|
37466
37466
|
validation: documentOwnerValidation(true)
|
|
@@ -37542,7 +37542,7 @@ var dispatchToolSpecs = [
|
|
|
37542
37542
|
project: z.string().describe("Project key for an unlinked document.").optional(),
|
|
37543
37543
|
name: z.string().describe("Artifact filename shown in Dispatch."),
|
|
37544
37544
|
path: z.string().describe("Local path to the file to upload.").optional(),
|
|
37545
|
-
content: z.string().describe("Inline text to store as a Markdown document, under a name ending in .md or .markdown or with no extension. The command refuses a text the store would write under another spelling, a CR LF or a lone carriage return among them, which Dispatch stores as a line feed. A missing line feed at the end is not such a text: Dispatch adds one, and the upload goes on. The refusal prints the text Dispatch stores, which is the text to send.").optional(),
|
|
37545
|
+
content: z.string().describe("Inline text to store as a Markdown document, under a name ending in .md or .markdown or with no extension. The command refuses a text the store would write under another spelling, a CR LF or a lone carriage return among them, which Dispatch stores as a line feed. A missing line feed at the end is not such a text: Dispatch adds one, and the upload goes on. Nor is a typed block whose attributes differ only in their order: the upload puts them in Dispatch's order. The 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. It prints the text Dispatch stores, which is the text to send.").optional(),
|
|
37546
37546
|
force: z.boolean().describe("Write the next version of a document the owner already holds under this name; without it the upload of a name that exists is refused.").optional(),
|
|
37547
37547
|
precondition: uploadPreconditionArgument(z),
|
|
37548
37548
|
summary: z.string().describe("Optional version summary.").optional()
|
|
@@ -52690,27 +52690,327 @@ import { resolve as resolvePath2 } from "path";
|
|
|
52690
52690
|
// ../contracts/src/go-blank.ts
|
|
52691
52691
|
var goBlankPattern = /^[\t\n\v\f\r \u0085\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]*$/u;
|
|
52692
52692
|
|
|
52693
|
-
// ../envoy-client/src/
|
|
52694
|
-
function
|
|
52695
|
-
|
|
52696
|
-
|
|
52693
|
+
// ../envoy-client/src/typed-block-opener.ts
|
|
52694
|
+
function runOf(text, index, char) {
|
|
52695
|
+
let end = index;
|
|
52696
|
+
while (text.charAt(end) === char)
|
|
52697
|
+
end++;
|
|
52698
|
+
return end - index;
|
|
52699
|
+
}
|
|
52700
|
+
function directiveNameChar(char) {
|
|
52701
|
+
return /^[A-Za-z0-9_-]$/.test(char);
|
|
52702
|
+
}
|
|
52703
|
+
function typedFenceBrace(text, at) {
|
|
52704
|
+
const nameStart = at + runOf(text, at, ":");
|
|
52705
|
+
if (nameStart - at < 3)
|
|
52706
|
+
return -1;
|
|
52707
|
+
let brace = nameStart;
|
|
52708
|
+
while (directiveNameChar(text.charAt(brace)))
|
|
52709
|
+
brace++;
|
|
52710
|
+
return brace > nameStart && text.charAt(brace) === "{" ? brace : -1;
|
|
52711
|
+
}
|
|
52712
|
+
function typedOpenerAt(text, at) {
|
|
52713
|
+
const brace = typedFenceBrace(text, at);
|
|
52714
|
+
if (brace === -1 || !text.endsWith("}"))
|
|
52715
|
+
return;
|
|
52716
|
+
const attributes = directiveAttributes(text.slice(brace + 1, -1));
|
|
52717
|
+
if (attributes === undefined)
|
|
52718
|
+
return;
|
|
52719
|
+
const colons = runOf(text, at, ":");
|
|
52720
|
+
return { ...attributes, name: text.slice(at + colons, brace), colons };
|
|
52721
|
+
}
|
|
52722
|
+
function refusedDirective(text) {
|
|
52723
|
+
if (text.startsWith(":::"))
|
|
52724
|
+
return text !== ":::" && typedOpenerAt(text, 0) === undefined;
|
|
52725
|
+
if (text.startsWith("::"))
|
|
52726
|
+
return text.length > 2 && directiveNameChar(text.charAt(2));
|
|
52727
|
+
return text.length > 1 && directiveNameChar(text.charAt(1)) && text.includes("{");
|
|
52728
|
+
}
|
|
52729
|
+
function attributeSpace(char) {
|
|
52730
|
+
return char === " " || char >= "\t" && char <= "\r";
|
|
52731
|
+
}
|
|
52732
|
+
var BLOCK_ID_ATTRIBUTE = "blockId";
|
|
52733
|
+
function directiveAttributes(value) {
|
|
52734
|
+
const attributes = [];
|
|
52735
|
+
const gaps = [];
|
|
52736
|
+
const named = new Set;
|
|
52737
|
+
let hasId = false;
|
|
52738
|
+
let id;
|
|
52739
|
+
let offset = 0;
|
|
52740
|
+
for (;; ) {
|
|
52741
|
+
const gap = offset;
|
|
52742
|
+
while (offset < value.length && attributeSpace(value.charAt(offset)))
|
|
52743
|
+
offset++;
|
|
52744
|
+
gaps.push(value.slice(gap, offset));
|
|
52745
|
+
if (offset === value.length)
|
|
52746
|
+
break;
|
|
52747
|
+
const start = offset;
|
|
52748
|
+
const sigil = value.charAt(start);
|
|
52749
|
+
let name;
|
|
52750
|
+
if (sigil === "#") {
|
|
52751
|
+
offset = start + 1;
|
|
52752
|
+
while (offset < value.length && !TYPED_BLOCK_ID_SHORTCUT_EXCLUDED.includes(value.charAt(offset)))
|
|
52753
|
+
offset++;
|
|
52754
|
+
if (offset === start + 1 || hasId)
|
|
52755
|
+
return;
|
|
52756
|
+
hasId = true;
|
|
52757
|
+
id = value.slice(start + 1, offset);
|
|
52758
|
+
name = "id";
|
|
52759
|
+
} else if (sigil === ".") {
|
|
52760
|
+
offset = start + 1;
|
|
52761
|
+
while (offset < value.length && directiveNameChar(value.charAt(offset)))
|
|
52762
|
+
offset++;
|
|
52763
|
+
if (offset === start + 1)
|
|
52764
|
+
return;
|
|
52765
|
+
named.add("class");
|
|
52766
|
+
name = "class";
|
|
52767
|
+
} else {
|
|
52768
|
+
while (offset < value.length && directiveNameChar(value.charAt(offset)))
|
|
52769
|
+
offset++;
|
|
52770
|
+
name = value.slice(start, offset);
|
|
52771
|
+
if (name === "")
|
|
52772
|
+
return;
|
|
52773
|
+
if (name === "id") {
|
|
52774
|
+
const close = value.startsWith('="', offset) ? value.indexOf('"', offset + 2) : -1;
|
|
52775
|
+
if (close === -1 || close === offset + 2 || hasId)
|
|
52776
|
+
return;
|
|
52777
|
+
hasId = true;
|
|
52778
|
+
id = decodedId(value.slice(offset + 2, close));
|
|
52779
|
+
offset = close + 1;
|
|
52780
|
+
} else {
|
|
52781
|
+
if (name === BLOCK_ID_ATTRIBUTE || named.has(name))
|
|
52782
|
+
return;
|
|
52783
|
+
named.add(name);
|
|
52784
|
+
if (offset < value.length && value.charAt(offset) !== " ") {
|
|
52785
|
+
const close = value.startsWith('="', offset) ? value.indexOf('"', offset + 2) : -1;
|
|
52786
|
+
if (close === -1)
|
|
52787
|
+
return;
|
|
52788
|
+
offset = close + 1;
|
|
52789
|
+
}
|
|
52790
|
+
}
|
|
52791
|
+
}
|
|
52792
|
+
if (offset < value.length && !attributeSpace(value.charAt(offset)))
|
|
52793
|
+
return;
|
|
52794
|
+
attributes.push({ name, text: value.slice(start, offset) });
|
|
52795
|
+
}
|
|
52796
|
+
return { attributes, gaps, id };
|
|
52797
|
+
}
|
|
52798
|
+
var NAMED_REFERENCES = new Map([
|
|
52799
|
+
["amp;", "&"],
|
|
52800
|
+
["amp", "&"],
|
|
52801
|
+
["lt;", "<"],
|
|
52802
|
+
["lt", "<"],
|
|
52803
|
+
["gt;", ">"],
|
|
52804
|
+
["gt", ">"],
|
|
52805
|
+
["quot;", '"'],
|
|
52806
|
+
["quot", '"'],
|
|
52807
|
+
["apos;", "'"],
|
|
52808
|
+
["nbsp;", "\xA0"],
|
|
52809
|
+
["nbsp", "\xA0"]
|
|
52810
|
+
]);
|
|
52811
|
+
var WINDOWS_1252 = "\u20AC\x81\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0160\u2039\u0152\x8D\u017D\x8F" + "\x90\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\u0161\u203A\u0153\x9D\u017E\u0178";
|
|
52812
|
+
function decodedId(raw) {
|
|
52813
|
+
let id = "";
|
|
52814
|
+
let at = 0;
|
|
52815
|
+
for (let amp = raw.indexOf("&");amp !== -1; amp = raw.indexOf("&", at)) {
|
|
52816
|
+
id += raw.slice(at, amp);
|
|
52817
|
+
const s = raw.slice(amp);
|
|
52818
|
+
let i = 1;
|
|
52819
|
+
if (s.charAt(1) === "#") {
|
|
52820
|
+
const hex = s.charAt(2) === "x" || s.charAt(2) === "X";
|
|
52821
|
+
let x = 0;
|
|
52822
|
+
i = hex ? 3 : 2;
|
|
52823
|
+
while (s.length > 3 && i < s.length) {
|
|
52824
|
+
const c = s.charAt(i++);
|
|
52825
|
+
const digit = (hex ? /^[0-9A-Fa-f]$/ : /^[0-9]$/).test(c) ? Number.parseInt(c, 16) : -1;
|
|
52826
|
+
if (digit >= 0) {
|
|
52827
|
+
x = Math.imul(x, hex ? 16 : 10) + digit | 0;
|
|
52828
|
+
continue;
|
|
52829
|
+
}
|
|
52830
|
+
if (c !== ";")
|
|
52831
|
+
i--;
|
|
52832
|
+
break;
|
|
52833
|
+
}
|
|
52834
|
+
if (s.length <= 3 || i <= 3) {
|
|
52835
|
+
id += "&";
|
|
52836
|
+
i = 1;
|
|
52837
|
+
} else if (x >= 128 && x <= 159) {
|
|
52838
|
+
id += WINDOWS_1252.charAt(x - 128);
|
|
52839
|
+
} else if (x <= 0 || x >= 55296 && x <= 57343 || x > 1114111) {
|
|
52840
|
+
id += "\uFFFD";
|
|
52841
|
+
} else {
|
|
52842
|
+
id += String.fromCodePoint(x);
|
|
52843
|
+
}
|
|
52844
|
+
} else {
|
|
52845
|
+
while (i < s.length && /^[A-Za-z0-9]$/.test(s.charAt(i)))
|
|
52846
|
+
i++;
|
|
52847
|
+
if (s.charAt(i) === ";")
|
|
52848
|
+
i++;
|
|
52849
|
+
const name = s.slice(1, i);
|
|
52850
|
+
const decoded = NAMED_REFERENCES.get(name);
|
|
52851
|
+
if (decoded !== undefined)
|
|
52852
|
+
id += decoded;
|
|
52853
|
+
else if (name.replace(/;$/, "").length > 1 && /^[A-Za-z]/.test(name))
|
|
52854
|
+
return;
|
|
52855
|
+
else
|
|
52856
|
+
id += s.slice(0, i);
|
|
52857
|
+
}
|
|
52858
|
+
at = amp + i;
|
|
52859
|
+
}
|
|
52860
|
+
return id + raw.slice(at);
|
|
52697
52861
|
}
|
|
52698
|
-
|
|
52699
|
-
|
|
52700
|
-
|
|
52701
|
-
|
|
52702
|
-
|
|
52862
|
+
|
|
52863
|
+
// ../envoy-client/src/dispatch-commands/stored-spelling.ts
|
|
52864
|
+
function headedOpener(line) {
|
|
52865
|
+
for (let at = 0;at < line.length; at += Math.max(1, runOf(line, at, ":"))) {
|
|
52866
|
+
const brace = typedFenceBrace(line, at);
|
|
52867
|
+
if (brace === -1)
|
|
52868
|
+
continue;
|
|
52869
|
+
const opener = typedOpenerAt(line, at);
|
|
52870
|
+
return opener === undefined ? undefined : { ...opener, head: line.slice(0, brace + 1) };
|
|
52703
52871
|
}
|
|
52704
|
-
|
|
52705
|
-
|
|
52706
|
-
|
|
52872
|
+
return;
|
|
52873
|
+
}
|
|
52874
|
+
function attributesByName(attributes) {
|
|
52875
|
+
const byName = new Map(attributes.map((attribute) => [attribute.name, attribute.text]));
|
|
52876
|
+
return byName.size === attributes.length ? byName : undefined;
|
|
52877
|
+
}
|
|
52878
|
+
function inStoredOrder(given, stored) {
|
|
52879
|
+
const written = attributesByName(given.attributes);
|
|
52880
|
+
if (written === undefined || attributesByName(stored.attributes) === undefined || stored.attributes.length !== given.attributes.length) {
|
|
52881
|
+
return;
|
|
52882
|
+
}
|
|
52883
|
+
let line = `${given.head}${given.gaps[0] ?? ""}`;
|
|
52884
|
+
for (const [index, attribute] of stored.attributes.entries()) {
|
|
52885
|
+
const text = written.get(attribute.name);
|
|
52886
|
+
if (text === undefined)
|
|
52887
|
+
return;
|
|
52888
|
+
line += `${text}${given.gaps[index + 1] ?? ""}`;
|
|
52889
|
+
}
|
|
52890
|
+
return `${line}}`;
|
|
52891
|
+
}
|
|
52892
|
+
function onlyReordered(given, held, stored) {
|
|
52893
|
+
return given !== undefined && stored !== undefined && inStoredOrder(given, stored) === held;
|
|
52894
|
+
}
|
|
52895
|
+
function reorderedBlockLine(line, opener) {
|
|
52896
|
+
const named = `${opener.name} block${opener.id === undefined ? "" : ` ${opener.id}`}`;
|
|
52897
|
+
const order = opener.attributes.map((attribute) => attribute.name).join(", ");
|
|
52898
|
+
return `This upload put the attributes of ${named} (line ${line}) in the order Dispatch stores: ${order}.`;
|
|
52899
|
+
}
|
|
52900
|
+
function attributesReordered(given, stored) {
|
|
52901
|
+
const written = withoutFinalLineFeed(given).split(`
|
|
52902
|
+
`);
|
|
52903
|
+
const holds = withoutFinalLineFeed(stored).split(`
|
|
52904
|
+
`);
|
|
52905
|
+
if (written.length !== holds.length)
|
|
52906
|
+
return;
|
|
52907
|
+
const lines = [];
|
|
52908
|
+
for (const [index, held] of holds.entries()) {
|
|
52909
|
+
const wrote = written[index];
|
|
52910
|
+
if (wrote === held)
|
|
52911
|
+
continue;
|
|
52912
|
+
const opener = headedOpener(held);
|
|
52913
|
+
if (wrote === undefined || opener === undefined || !onlyReordered(headedOpener(wrote), held, opener)) {
|
|
52914
|
+
return;
|
|
52915
|
+
}
|
|
52916
|
+
lines.push(reorderedBlockLine(index + 1, opener));
|
|
52917
|
+
}
|
|
52918
|
+
return lines;
|
|
52707
52919
|
}
|
|
52708
52920
|
var STORED_LINE_QUOTED = 200;
|
|
52709
|
-
function quotedStoredLine(
|
|
52710
|
-
|
|
52711
|
-
|
|
52712
|
-
const
|
|
52713
|
-
|
|
52921
|
+
function quotedStoredLine(characters, from) {
|
|
52922
|
+
const shown = characters.slice(from, from + STORED_LINE_QUOTED);
|
|
52923
|
+
const quote = JSON.stringify(shown.join(""));
|
|
52924
|
+
const cutAfter = from + shown.length < characters.length;
|
|
52925
|
+
if (from === 0 && !cutAfter)
|
|
52926
|
+
return quote;
|
|
52927
|
+
const cut = from === 0 ? "after" : cutAfter ? "before and after" : "before the last";
|
|
52928
|
+
return `${quote} (cut ${cut} ${shown.length} of its ${characters.length} characters)`;
|
|
52929
|
+
}
|
|
52930
|
+
function lineWords(line, opener) {
|
|
52931
|
+
const plain = (text) => (text.match(/\s+|\S+/g) ?? []).map((word) => ({ text: word, attribute: false }));
|
|
52932
|
+
if (opener === undefined)
|
|
52933
|
+
return plain(line);
|
|
52934
|
+
const words = plain(opener.head);
|
|
52935
|
+
for (const [index, gap] of opener.gaps.entries()) {
|
|
52936
|
+
if (gap !== "")
|
|
52937
|
+
words.push({ text: gap, attribute: false });
|
|
52938
|
+
const attribute = opener.attributes[index];
|
|
52939
|
+
if (attribute !== undefined)
|
|
52940
|
+
words.push({ text: attribute.text, attribute: true });
|
|
52941
|
+
}
|
|
52942
|
+
words.push({ text: "}", attribute: false });
|
|
52943
|
+
return words;
|
|
52944
|
+
}
|
|
52945
|
+
function wordText(word, from = 0, characters = Array.from(word.text)) {
|
|
52946
|
+
if (word.attribute)
|
|
52947
|
+
return `the attribute ${word.text}`;
|
|
52948
|
+
return `${/\S/.test(word.text) ? "the word" : "the space"} ${quotedStoredLine(characters, from)}`;
|
|
52949
|
+
}
|
|
52950
|
+
function wordDifference(written, holds) {
|
|
52951
|
+
let before = 0;
|
|
52952
|
+
for (let index = 0;index < Math.max(written.length, holds.length); index += 1) {
|
|
52953
|
+
const given = written[index];
|
|
52954
|
+
const stored = holds[index];
|
|
52955
|
+
if (given !== undefined && stored !== undefined && given.text === stored.text) {
|
|
52956
|
+
before += Array.from(given.text).length;
|
|
52957
|
+
continue;
|
|
52958
|
+
}
|
|
52959
|
+
if (given === undefined && stored !== undefined) {
|
|
52960
|
+
return `ends after character ${before}, where Dispatch goes on with ${wordText(stored)}`;
|
|
52961
|
+
}
|
|
52962
|
+
if (given !== undefined && stored === undefined) {
|
|
52963
|
+
return `reads ${wordText(given)} at character ${before + 1}, where Dispatch ends the line`;
|
|
52964
|
+
}
|
|
52965
|
+
if (given !== undefined && stored !== undefined) {
|
|
52966
|
+
const wrote = Array.from(given.text);
|
|
52967
|
+
const held = Array.from(stored.text);
|
|
52968
|
+
let from = 0;
|
|
52969
|
+
if (!given.attribute && !stored.attribute && Math.max(wrote.length, held.length) > STORED_LINE_QUOTED) {
|
|
52970
|
+
while (from < wrote.length && wrote[from] === held[from])
|
|
52971
|
+
from += 1;
|
|
52972
|
+
const tail = Math.max(0, from - STORED_LINE_QUOTED);
|
|
52973
|
+
if (from === wrote.length) {
|
|
52974
|
+
return `ends ${wordText(given, tail, wrote)} after character ${before + from}, where Dispatch goes on with ${wordText(stored, from, held)}`;
|
|
52975
|
+
}
|
|
52976
|
+
if (from === held.length) {
|
|
52977
|
+
return `reads ${wordText(given, from, wrote)} at character ${before + from + 1}, where Dispatch ends ${wordText(stored, tail, held)}`;
|
|
52978
|
+
}
|
|
52979
|
+
}
|
|
52980
|
+
return `reads ${wordText(given, from, wrote)} at character ${before + from + 1}, where Dispatch stores ${wordText(stored, from, held)}`;
|
|
52981
|
+
}
|
|
52982
|
+
}
|
|
52983
|
+
return "differs from the line Dispatch stores";
|
|
52984
|
+
}
|
|
52985
|
+
function attributeDifference(line, given, stored) {
|
|
52986
|
+
const written = attributesByName(given.attributes);
|
|
52987
|
+
if (written === undefined)
|
|
52988
|
+
return;
|
|
52989
|
+
for (const attribute of stored.attributes) {
|
|
52990
|
+
const text = written.get(attribute.name);
|
|
52991
|
+
if (text === undefined)
|
|
52992
|
+
return `Dispatch adds the attribute ${attribute.text} to line ${line}`;
|
|
52993
|
+
if (text !== attribute.text) {
|
|
52994
|
+
return `line ${line} holds the attribute ${text}, which Dispatch stores as ${attribute.text}`;
|
|
52995
|
+
}
|
|
52996
|
+
}
|
|
52997
|
+
const held = new Set(stored.attributes.map((attribute) => attribute.name));
|
|
52998
|
+
const dropped = given.attributes.find((attribute) => !held.has(attribute.name));
|
|
52999
|
+
return dropped === undefined ? undefined : `line ${line} holds the attribute ${dropped.text}, which Dispatch drops`;
|
|
53000
|
+
}
|
|
53001
|
+
function lineDifference(line, wrote, given, held, stored) {
|
|
53002
|
+
if (given === undefined || stored === undefined) {
|
|
53003
|
+
return `line ${line} ${wordDifference(lineWords(wrote, undefined), lineWords(held, undefined))}`;
|
|
53004
|
+
}
|
|
53005
|
+
const attribute = attributeDifference(line, given, stored);
|
|
53006
|
+
if (attribute !== undefined)
|
|
53007
|
+
return attribute;
|
|
53008
|
+
const reordered = inStoredOrder(given, stored);
|
|
53009
|
+
if (reordered !== undefined && reordered !== wrote) {
|
|
53010
|
+
const words = lineWords(reordered, headedOpener(reordered));
|
|
53011
|
+
return `line ${line}, with its attributes put in the order Dispatch stores, ${wordDifference(words, lineWords(held, stored))}`;
|
|
53012
|
+
}
|
|
53013
|
+
return `line ${line} ${wordDifference(lineWords(wrote, given), lineWords(held, stored))}`;
|
|
52714
53014
|
}
|
|
52715
53015
|
function firstStoredDifference(given, stored) {
|
|
52716
53016
|
const written = given.split(`
|
|
@@ -52723,13 +53023,17 @@ function firstStoredDifference(given, stored) {
|
|
|
52723
53023
|
if (wrote === held)
|
|
52724
53024
|
continue;
|
|
52725
53025
|
if (wrote === undefined && held !== undefined) {
|
|
52726
|
-
return `the store writes a line ${line + 1}, ${quotedStoredLine(held)}`;
|
|
53026
|
+
return `the store writes a line ${line + 1}, ${quotedStoredLine(Array.from(held), 0)}`;
|
|
52727
53027
|
}
|
|
52728
53028
|
if (held === undefined && wrote !== undefined) {
|
|
52729
|
-
return `the store drops line ${line + 1}, ${quotedStoredLine(wrote)}`;
|
|
53029
|
+
return `the store drops line ${line + 1}, ${quotedStoredLine(Array.from(wrote), 0)}`;
|
|
52730
53030
|
}
|
|
52731
53031
|
if (wrote !== undefined && held !== undefined) {
|
|
52732
|
-
|
|
53032
|
+
const givenOpener = headedOpener(wrote);
|
|
53033
|
+
const storedOpener = headedOpener(held);
|
|
53034
|
+
if (onlyReordered(givenOpener, held, storedOpener))
|
|
53035
|
+
continue;
|
|
53036
|
+
return lineDifference(line + 1, wrote, givenOpener, held, storedOpener);
|
|
52733
53037
|
}
|
|
52734
53038
|
}
|
|
52735
53039
|
return "the stored text differs from the text given";
|
|
@@ -52759,6 +53063,33 @@ ${printed.text}`,
|
|
|
52759
53063
|
"--- end of the text Dispatch stores ---"
|
|
52760
53064
|
].join("");
|
|
52761
53065
|
}
|
|
53066
|
+
function withoutFinalLineFeed(text) {
|
|
53067
|
+
return text.endsWith(`
|
|
53068
|
+
`) ? text.slice(0, -1) : text;
|
|
53069
|
+
}
|
|
53070
|
+
function storedUpload(given, stored, name) {
|
|
53071
|
+
if (withoutFinalLineFeed(stored) === withoutFinalLineFeed(given)) {
|
|
53072
|
+
return { sent: given, reordered: [] };
|
|
53073
|
+
}
|
|
53074
|
+
const reordered = attributesReordered(given, stored);
|
|
53075
|
+
return reordered === undefined ? { refusal: storedTextProblem(given, stored, name) } : { sent: stored, reordered };
|
|
53076
|
+
}
|
|
53077
|
+
|
|
53078
|
+
// ../envoy-client/src/dispatch-commands/upload-checks.ts
|
|
53079
|
+
function artifactUnderName(artifacts, name) {
|
|
53080
|
+
const written = name.trim();
|
|
53081
|
+
return artifacts.find((held) => held.slug === written) ?? artifacts.find((held) => held.name === written);
|
|
53082
|
+
}
|
|
53083
|
+
function artifactNameExistsProblem(held, owner) {
|
|
53084
|
+
const versions = held.versions ?? [];
|
|
53085
|
+
const newest = versions[versions.length - 1];
|
|
53086
|
+
if (newest === undefined) {
|
|
53087
|
+
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}), which has no version yet and which ${actorText(held.created_by)} created. ${ARTIFACT_NAME_EXISTS_RULE}`;
|
|
53088
|
+
}
|
|
53089
|
+
const authors = (newest.authors ?? []).map(actorText);
|
|
53090
|
+
const wroteIt = authors.length === 0 ? actorText(held.created_by) : authors.join(" and ");
|
|
53091
|
+
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${ARTIFACT_NAME_EXISTS_RULE}`;
|
|
53092
|
+
}
|
|
52762
53093
|
function storedTextCheckFailed(error, name) {
|
|
52763
53094
|
const failure = `Dispatch could not say how it would store this text, so nothing was uploaded: POST /api/v1/markdown/round-trip failed with ${messageFor(error)}.`;
|
|
52764
53095
|
if (!dispatchAnswered(error, 413)) {
|
|
@@ -52770,10 +53101,6 @@ function storedTextCheckFailed(error, name) {
|
|
|
52770
53101
|
function roundTripRouteAbsent(error) {
|
|
52771
53102
|
return dispatchAnswered(error, 404) || dispatchAnswered(error, 405);
|
|
52772
53103
|
}
|
|
52773
|
-
function withoutFinalLineFeed(text) {
|
|
52774
|
-
return text.endsWith(`
|
|
52775
|
-
`) ? text.slice(0, -1) : text;
|
|
52776
|
-
}
|
|
52777
53104
|
|
|
52778
53105
|
// ../envoy-client/src/dispatch-commands/documents.ts
|
|
52779
53106
|
async function blockAsks(client, resolved, state) {
|
|
@@ -53157,6 +53484,8 @@ async function artifactCommand(context) {
|
|
|
53157
53484
|
]);
|
|
53158
53485
|
}
|
|
53159
53486
|
}
|
|
53487
|
+
let sent = content;
|
|
53488
|
+
let reordered = [];
|
|
53160
53489
|
if (!blank) {
|
|
53161
53490
|
let stored;
|
|
53162
53491
|
try {
|
|
@@ -53166,8 +53495,12 @@ async function artifactCommand(context) {
|
|
|
53166
53495
|
throw new Error(storedTextCheckFailed(error, name), { cause: error });
|
|
53167
53496
|
}
|
|
53168
53497
|
}
|
|
53169
|
-
if (stored !== undefined
|
|
53170
|
-
|
|
53498
|
+
if (stored !== undefined) {
|
|
53499
|
+
const upload = storedUpload(content, stored, name);
|
|
53500
|
+
if ("refusal" in upload)
|
|
53501
|
+
throw new ToolInputError(input.tool, [upload.refusal]);
|
|
53502
|
+
sent = upload.sent;
|
|
53503
|
+
reordered = upload.reordered;
|
|
53171
53504
|
}
|
|
53172
53505
|
}
|
|
53173
53506
|
const artifactInput = path !== undefined ? {
|
|
@@ -53175,7 +53508,7 @@ async function artifactCommand(context) {
|
|
|
53175
53508
|
file: input.uploadBytes === undefined ? Bun.file(resolvePath2(input.cwd, path)) : new Blob([new Uint8Array(input.uploadBytes)], {
|
|
53176
53509
|
type: Bun.file(resolvePath2(input.cwd, path)).type
|
|
53177
53510
|
})
|
|
53178
|
-
} :
|
|
53511
|
+
} : sent !== undefined ? { ...options, content: sent } : options;
|
|
53179
53512
|
const result = artifactOwner.kind === "project" ? await client.projectArtifact(artifactOwner.project, artifactInput) : await client.artifact(issue(), artifactInput);
|
|
53180
53513
|
const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
|
|
53181
53514
|
const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
|
|
@@ -53186,6 +53519,7 @@ async function artifactCommand(context) {
|
|
|
53186
53519
|
return {
|
|
53187
53520
|
text: [
|
|
53188
53521
|
path === undefined && content === undefined ? `Made ${result.artifact.name} as an empty document (artifact slug ${result.artifact.slug}; ${artifactRef}). Write in it with dispatch doc-edit.${await notSubscribed(uploadOwner, input.subscriptions)}` : `Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef})${await notSubscribed(uploadOwner, input.subscriptions)}`,
|
|
53522
|
+
...reordered,
|
|
53189
53523
|
...adviceLines
|
|
53190
53524
|
].join(`
|
|
53191
53525
|
`),
|
|
@@ -60555,7 +60889,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
|
|
|
60555
60889
|
|
|
60556
60890
|
// package.json
|
|
60557
60891
|
var name2 = "@sjawhar/claude-envoy";
|
|
60558
|
-
var version2 = "5.
|
|
60892
|
+
var version2 = "5.6.0";
|
|
60559
60893
|
var legion = {
|
|
60560
60894
|
daemonApiVersion: 213
|
|
60561
60895
|
};
|
|
@@ -64214,7 +64548,7 @@ function phaseOpParameters(zod) {
|
|
|
64214
64548
|
var PHASE_OP_SENTENCES = {
|
|
64215
64549
|
readRecord: "read_record returns the record of `issue` from the daemon's record route for that issue, your own issue when you leave `issue` out. " + "A held issue names in `heldFrom` the phase the hold took it out of. A failed claim carries `failure`: the " + "`cause` word for what failed it, the `detail` sentence beside that word, `at`, when it failed, and " + "`attempts`, the four counts it failed with. A todo written on a held root releases the hold and starts " + "that phase again, as the architect's retry_or_escalate with retry does. ",
|
|
64216
64550
|
readReleaseRecords: "read_release_records returns this deployment's idle-release records from `since` (an RFC 3339 time) on, read with this session's own claim: " + "every release, resume and hold the daemon recorded, and over them the counts of releases, of the releases among them that suspended no " + "role, of resumes by wake kind and of holds by reason, the pod-hours released, the share of releases woken again within ten minutes, and " + "the median, 90th percentile and maximum seconds from a wake to the woken role's first turn. A wake that a project pause held is " + "counted as `heldByPause` and left out of those seconds, since its wait measures the pause. A release that suspended no role is woken by " + "nothing, so the pod-hours released and the woken share count the releases that suspended a role alone. ",
|
|
64217
|
-
requestBackwardMove: "request_backward_move returns an issue to an earlier phase (`to`, `reason`). A phase worker moves its own issue. " + "The architect that owns an issue in accepting moves it, named by `issue`, back to implementing or testing. That move counts a review round. ",
|
|
64551
|
+
requestBackwardMove: "request_backward_move returns an issue to an earlier phase (`to`, `reason`). A phase worker moves its own issue. " + "The architect that owns an issue in accepting moves it, named by `issue`, back to planning, implementing or testing. That move counts a review round. ",
|
|
64218
64552
|
readBuild: "read_build reports the build this process runs: the plugin package and version the process loaded, and the contract that build speaks. " + "It also reports the contract the daemon states on its answer to the health route. " + "That contract is null where the daemon stated none, where the daemon refused the health route and where no answer reached this process at all, and a note of its own says which. " + "The two numbers can differ, and the answer shows both. " + "Report the version this call answers, never the one at the plugin's path on the image. " + "In a pod, an Oh My Pi role relaunched onto the daemon's contract loads the build that relaunch installed under the role's own state home, " + "and a Claude Code role installs no plugin: it loads its pod image's own claude-envoy. " + "read_build reads no project state. "
|
|
64219
64553
|
};
|
|
64220
64554
|
var STALE_ENTRY_INSTRUCTION = "End this turn without completing. The task of the entry the phase is on is owed to this claim, and the daemon sends it by itself. " + "That task is work of its own: do what it asks at the head it names and complete it with a handoff of its own, never this completion's " + "record, commit or verdict";
|