@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/session-hook.js
CHANGED
|
@@ -14272,7 +14272,7 @@ var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text
|
|
|
14272
14272
|
var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
|
|
14273
14273
|
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}.`;
|
|
14274
14274
|
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).`;
|
|
14275
|
-
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}.`;
|
|
14275
|
+
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}.`;
|
|
14276
14276
|
var NAME_EXTENSION = /\.([^\s.]+)$/u;
|
|
14277
14277
|
var MARKDOWN_EXTENSION = /^(md|markdown)$/i;
|
|
14278
14278
|
function preconditionArgument(z) {
|
|
@@ -14574,7 +14574,7 @@ var dispatchToolSpecs = [
|
|
|
14574
14574
|
{
|
|
14575
14575
|
name: "dispatch_issue",
|
|
14576
14576
|
example: { project: "DSP", title: "Native workspace" },
|
|
14577
|
-
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. " + "
|
|
14577
|
+
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}`,
|
|
14578
14578
|
arguments: (z) => ({
|
|
14579
14579
|
project: z.string().describe("Project key for the new issue."),
|
|
14580
14580
|
title: z.string({ max: ISSUE_TITLE_MAX }).describe("Concise issue title, at most 1,000 characters."),
|
|
@@ -14859,12 +14859,12 @@ var dispatchToolSpecs = [
|
|
|
14859
14859
|
{
|
|
14860
14860
|
name: "dispatch_request_approval",
|
|
14861
14861
|
example: { issue: "DSP-1", summary: "A live sync replaces the nightly export." },
|
|
14862
|
-
description: "Ask a human to approve a document at its current version.
|
|
14862
|
+
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,
|
|
14863
14863
|
arguments: (z) => ({
|
|
14864
14864
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
14865
14865
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
14866
14866
|
artifact: z.string().describe("Project document artifact id, slug, or filename; primary document by default for an issue.").optional(),
|
|
14867
|
-
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.
|
|
14867
|
+
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}.`),
|
|
14868
14868
|
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()
|
|
14869
14869
|
}),
|
|
14870
14870
|
validation: documentOwnerValidation(true)
|
|
@@ -14946,7 +14946,7 @@ var dispatchToolSpecs = [
|
|
|
14946
14946
|
project: z.string().describe("Project key for an unlinked document.").optional(),
|
|
14947
14947
|
name: z.string().describe("Artifact filename shown in Dispatch."),
|
|
14948
14948
|
path: z.string().describe("Local path to the file to upload.").optional(),
|
|
14949
|
-
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(),
|
|
14949
|
+
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(),
|
|
14950
14950
|
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(),
|
|
14951
14951
|
precondition: uploadPreconditionArgument(z),
|
|
14952
14952
|
summary: z.string().describe("Optional version summary.").optional()
|
|
@@ -25460,27 +25460,327 @@ import { resolve as resolvePath2 } from "path";
|
|
|
25460
25460
|
// ../contracts/src/go-blank.ts
|
|
25461
25461
|
var goBlankPattern = /^[\t\n\v\f\r \u0085\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]*$/u;
|
|
25462
25462
|
|
|
25463
|
-
// ../envoy-client/src/
|
|
25464
|
-
function
|
|
25465
|
-
|
|
25466
|
-
|
|
25463
|
+
// ../envoy-client/src/typed-block-opener.ts
|
|
25464
|
+
function runOf(text, index, char) {
|
|
25465
|
+
let end = index;
|
|
25466
|
+
while (text.charAt(end) === char)
|
|
25467
|
+
end++;
|
|
25468
|
+
return end - index;
|
|
25469
|
+
}
|
|
25470
|
+
function directiveNameChar(char) {
|
|
25471
|
+
return /^[A-Za-z0-9_-]$/.test(char);
|
|
25472
|
+
}
|
|
25473
|
+
function typedFenceBrace(text, at) {
|
|
25474
|
+
const nameStart = at + runOf(text, at, ":");
|
|
25475
|
+
if (nameStart - at < 3)
|
|
25476
|
+
return -1;
|
|
25477
|
+
let brace = nameStart;
|
|
25478
|
+
while (directiveNameChar(text.charAt(brace)))
|
|
25479
|
+
brace++;
|
|
25480
|
+
return brace > nameStart && text.charAt(brace) === "{" ? brace : -1;
|
|
25481
|
+
}
|
|
25482
|
+
function typedOpenerAt(text, at) {
|
|
25483
|
+
const brace = typedFenceBrace(text, at);
|
|
25484
|
+
if (brace === -1 || !text.endsWith("}"))
|
|
25485
|
+
return;
|
|
25486
|
+
const attributes = directiveAttributes(text.slice(brace + 1, -1));
|
|
25487
|
+
if (attributes === undefined)
|
|
25488
|
+
return;
|
|
25489
|
+
const colons = runOf(text, at, ":");
|
|
25490
|
+
return { ...attributes, name: text.slice(at + colons, brace), colons };
|
|
25491
|
+
}
|
|
25492
|
+
function refusedDirective(text) {
|
|
25493
|
+
if (text.startsWith(":::"))
|
|
25494
|
+
return text !== ":::" && typedOpenerAt(text, 0) === undefined;
|
|
25495
|
+
if (text.startsWith("::"))
|
|
25496
|
+
return text.length > 2 && directiveNameChar(text.charAt(2));
|
|
25497
|
+
return text.length > 1 && directiveNameChar(text.charAt(1)) && text.includes("{");
|
|
25498
|
+
}
|
|
25499
|
+
function attributeSpace(char) {
|
|
25500
|
+
return char === " " || char >= "\t" && char <= "\r";
|
|
25501
|
+
}
|
|
25502
|
+
var BLOCK_ID_ATTRIBUTE = "blockId";
|
|
25503
|
+
function directiveAttributes(value) {
|
|
25504
|
+
const attributes = [];
|
|
25505
|
+
const gaps = [];
|
|
25506
|
+
const named = new Set;
|
|
25507
|
+
let hasId = false;
|
|
25508
|
+
let id;
|
|
25509
|
+
let offset = 0;
|
|
25510
|
+
for (;; ) {
|
|
25511
|
+
const gap = offset;
|
|
25512
|
+
while (offset < value.length && attributeSpace(value.charAt(offset)))
|
|
25513
|
+
offset++;
|
|
25514
|
+
gaps.push(value.slice(gap, offset));
|
|
25515
|
+
if (offset === value.length)
|
|
25516
|
+
break;
|
|
25517
|
+
const start = offset;
|
|
25518
|
+
const sigil = value.charAt(start);
|
|
25519
|
+
let name;
|
|
25520
|
+
if (sigil === "#") {
|
|
25521
|
+
offset = start + 1;
|
|
25522
|
+
while (offset < value.length && !TYPED_BLOCK_ID_SHORTCUT_EXCLUDED.includes(value.charAt(offset)))
|
|
25523
|
+
offset++;
|
|
25524
|
+
if (offset === start + 1 || hasId)
|
|
25525
|
+
return;
|
|
25526
|
+
hasId = true;
|
|
25527
|
+
id = value.slice(start + 1, offset);
|
|
25528
|
+
name = "id";
|
|
25529
|
+
} else if (sigil === ".") {
|
|
25530
|
+
offset = start + 1;
|
|
25531
|
+
while (offset < value.length && directiveNameChar(value.charAt(offset)))
|
|
25532
|
+
offset++;
|
|
25533
|
+
if (offset === start + 1)
|
|
25534
|
+
return;
|
|
25535
|
+
named.add("class");
|
|
25536
|
+
name = "class";
|
|
25537
|
+
} else {
|
|
25538
|
+
while (offset < value.length && directiveNameChar(value.charAt(offset)))
|
|
25539
|
+
offset++;
|
|
25540
|
+
name = value.slice(start, offset);
|
|
25541
|
+
if (name === "")
|
|
25542
|
+
return;
|
|
25543
|
+
if (name === "id") {
|
|
25544
|
+
const close = value.startsWith('="', offset) ? value.indexOf('"', offset + 2) : -1;
|
|
25545
|
+
if (close === -1 || close === offset + 2 || hasId)
|
|
25546
|
+
return;
|
|
25547
|
+
hasId = true;
|
|
25548
|
+
id = decodedId(value.slice(offset + 2, close));
|
|
25549
|
+
offset = close + 1;
|
|
25550
|
+
} else {
|
|
25551
|
+
if (name === BLOCK_ID_ATTRIBUTE || named.has(name))
|
|
25552
|
+
return;
|
|
25553
|
+
named.add(name);
|
|
25554
|
+
if (offset < value.length && value.charAt(offset) !== " ") {
|
|
25555
|
+
const close = value.startsWith('="', offset) ? value.indexOf('"', offset + 2) : -1;
|
|
25556
|
+
if (close === -1)
|
|
25557
|
+
return;
|
|
25558
|
+
offset = close + 1;
|
|
25559
|
+
}
|
|
25560
|
+
}
|
|
25561
|
+
}
|
|
25562
|
+
if (offset < value.length && !attributeSpace(value.charAt(offset)))
|
|
25563
|
+
return;
|
|
25564
|
+
attributes.push({ name, text: value.slice(start, offset) });
|
|
25565
|
+
}
|
|
25566
|
+
return { attributes, gaps, id };
|
|
25567
|
+
}
|
|
25568
|
+
var NAMED_REFERENCES = new Map([
|
|
25569
|
+
["amp;", "&"],
|
|
25570
|
+
["amp", "&"],
|
|
25571
|
+
["lt;", "<"],
|
|
25572
|
+
["lt", "<"],
|
|
25573
|
+
["gt;", ">"],
|
|
25574
|
+
["gt", ">"],
|
|
25575
|
+
["quot;", '"'],
|
|
25576
|
+
["quot", '"'],
|
|
25577
|
+
["apos;", "'"],
|
|
25578
|
+
["nbsp;", "\xA0"],
|
|
25579
|
+
["nbsp", "\xA0"]
|
|
25580
|
+
]);
|
|
25581
|
+
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";
|
|
25582
|
+
function decodedId(raw) {
|
|
25583
|
+
let id = "";
|
|
25584
|
+
let at = 0;
|
|
25585
|
+
for (let amp = raw.indexOf("&");amp !== -1; amp = raw.indexOf("&", at)) {
|
|
25586
|
+
id += raw.slice(at, amp);
|
|
25587
|
+
const s = raw.slice(amp);
|
|
25588
|
+
let i = 1;
|
|
25589
|
+
if (s.charAt(1) === "#") {
|
|
25590
|
+
const hex = s.charAt(2) === "x" || s.charAt(2) === "X";
|
|
25591
|
+
let x = 0;
|
|
25592
|
+
i = hex ? 3 : 2;
|
|
25593
|
+
while (s.length > 3 && i < s.length) {
|
|
25594
|
+
const c = s.charAt(i++);
|
|
25595
|
+
const digit = (hex ? /^[0-9A-Fa-f]$/ : /^[0-9]$/).test(c) ? Number.parseInt(c, 16) : -1;
|
|
25596
|
+
if (digit >= 0) {
|
|
25597
|
+
x = Math.imul(x, hex ? 16 : 10) + digit | 0;
|
|
25598
|
+
continue;
|
|
25599
|
+
}
|
|
25600
|
+
if (c !== ";")
|
|
25601
|
+
i--;
|
|
25602
|
+
break;
|
|
25603
|
+
}
|
|
25604
|
+
if (s.length <= 3 || i <= 3) {
|
|
25605
|
+
id += "&";
|
|
25606
|
+
i = 1;
|
|
25607
|
+
} else if (x >= 128 && x <= 159) {
|
|
25608
|
+
id += WINDOWS_1252.charAt(x - 128);
|
|
25609
|
+
} else if (x <= 0 || x >= 55296 && x <= 57343 || x > 1114111) {
|
|
25610
|
+
id += "\uFFFD";
|
|
25611
|
+
} else {
|
|
25612
|
+
id += String.fromCodePoint(x);
|
|
25613
|
+
}
|
|
25614
|
+
} else {
|
|
25615
|
+
while (i < s.length && /^[A-Za-z0-9]$/.test(s.charAt(i)))
|
|
25616
|
+
i++;
|
|
25617
|
+
if (s.charAt(i) === ";")
|
|
25618
|
+
i++;
|
|
25619
|
+
const name = s.slice(1, i);
|
|
25620
|
+
const decoded = NAMED_REFERENCES.get(name);
|
|
25621
|
+
if (decoded !== undefined)
|
|
25622
|
+
id += decoded;
|
|
25623
|
+
else if (name.replace(/;$/, "").length > 1 && /^[A-Za-z]/.test(name))
|
|
25624
|
+
return;
|
|
25625
|
+
else
|
|
25626
|
+
id += s.slice(0, i);
|
|
25627
|
+
}
|
|
25628
|
+
at = amp + i;
|
|
25629
|
+
}
|
|
25630
|
+
return id + raw.slice(at);
|
|
25467
25631
|
}
|
|
25468
|
-
|
|
25469
|
-
|
|
25470
|
-
|
|
25471
|
-
|
|
25472
|
-
|
|
25632
|
+
|
|
25633
|
+
// ../envoy-client/src/dispatch-commands/stored-spelling.ts
|
|
25634
|
+
function headedOpener(line) {
|
|
25635
|
+
for (let at = 0;at < line.length; at += Math.max(1, runOf(line, at, ":"))) {
|
|
25636
|
+
const brace = typedFenceBrace(line, at);
|
|
25637
|
+
if (brace === -1)
|
|
25638
|
+
continue;
|
|
25639
|
+
const opener = typedOpenerAt(line, at);
|
|
25640
|
+
return opener === undefined ? undefined : { ...opener, head: line.slice(0, brace + 1) };
|
|
25473
25641
|
}
|
|
25474
|
-
|
|
25475
|
-
|
|
25476
|
-
|
|
25642
|
+
return;
|
|
25643
|
+
}
|
|
25644
|
+
function attributesByName(attributes) {
|
|
25645
|
+
const byName = new Map(attributes.map((attribute) => [attribute.name, attribute.text]));
|
|
25646
|
+
return byName.size === attributes.length ? byName : undefined;
|
|
25647
|
+
}
|
|
25648
|
+
function inStoredOrder(given, stored) {
|
|
25649
|
+
const written = attributesByName(given.attributes);
|
|
25650
|
+
if (written === undefined || attributesByName(stored.attributes) === undefined || stored.attributes.length !== given.attributes.length) {
|
|
25651
|
+
return;
|
|
25652
|
+
}
|
|
25653
|
+
let line = `${given.head}${given.gaps[0] ?? ""}`;
|
|
25654
|
+
for (const [index, attribute] of stored.attributes.entries()) {
|
|
25655
|
+
const text = written.get(attribute.name);
|
|
25656
|
+
if (text === undefined)
|
|
25657
|
+
return;
|
|
25658
|
+
line += `${text}${given.gaps[index + 1] ?? ""}`;
|
|
25659
|
+
}
|
|
25660
|
+
return `${line}}`;
|
|
25661
|
+
}
|
|
25662
|
+
function onlyReordered(given, held, stored) {
|
|
25663
|
+
return given !== undefined && stored !== undefined && inStoredOrder(given, stored) === held;
|
|
25664
|
+
}
|
|
25665
|
+
function reorderedBlockLine(line, opener) {
|
|
25666
|
+
const named = `${opener.name} block${opener.id === undefined ? "" : ` ${opener.id}`}`;
|
|
25667
|
+
const order = opener.attributes.map((attribute) => attribute.name).join(", ");
|
|
25668
|
+
return `This upload put the attributes of ${named} (line ${line}) in the order Dispatch stores: ${order}.`;
|
|
25669
|
+
}
|
|
25670
|
+
function attributesReordered(given, stored) {
|
|
25671
|
+
const written = withoutFinalLineFeed(given).split(`
|
|
25672
|
+
`);
|
|
25673
|
+
const holds = withoutFinalLineFeed(stored).split(`
|
|
25674
|
+
`);
|
|
25675
|
+
if (written.length !== holds.length)
|
|
25676
|
+
return;
|
|
25677
|
+
const lines = [];
|
|
25678
|
+
for (const [index, held] of holds.entries()) {
|
|
25679
|
+
const wrote = written[index];
|
|
25680
|
+
if (wrote === held)
|
|
25681
|
+
continue;
|
|
25682
|
+
const opener = headedOpener(held);
|
|
25683
|
+
if (wrote === undefined || opener === undefined || !onlyReordered(headedOpener(wrote), held, opener)) {
|
|
25684
|
+
return;
|
|
25685
|
+
}
|
|
25686
|
+
lines.push(reorderedBlockLine(index + 1, opener));
|
|
25687
|
+
}
|
|
25688
|
+
return lines;
|
|
25477
25689
|
}
|
|
25478
25690
|
var STORED_LINE_QUOTED = 200;
|
|
25479
|
-
function quotedStoredLine(
|
|
25480
|
-
|
|
25481
|
-
|
|
25482
|
-
const
|
|
25483
|
-
|
|
25691
|
+
function quotedStoredLine(characters, from) {
|
|
25692
|
+
const shown = characters.slice(from, from + STORED_LINE_QUOTED);
|
|
25693
|
+
const quote = JSON.stringify(shown.join(""));
|
|
25694
|
+
const cutAfter = from + shown.length < characters.length;
|
|
25695
|
+
if (from === 0 && !cutAfter)
|
|
25696
|
+
return quote;
|
|
25697
|
+
const cut = from === 0 ? "after" : cutAfter ? "before and after" : "before the last";
|
|
25698
|
+
return `${quote} (cut ${cut} ${shown.length} of its ${characters.length} characters)`;
|
|
25699
|
+
}
|
|
25700
|
+
function lineWords(line, opener) {
|
|
25701
|
+
const plain = (text) => (text.match(/\s+|\S+/g) ?? []).map((word) => ({ text: word, attribute: false }));
|
|
25702
|
+
if (opener === undefined)
|
|
25703
|
+
return plain(line);
|
|
25704
|
+
const words = plain(opener.head);
|
|
25705
|
+
for (const [index, gap] of opener.gaps.entries()) {
|
|
25706
|
+
if (gap !== "")
|
|
25707
|
+
words.push({ text: gap, attribute: false });
|
|
25708
|
+
const attribute = opener.attributes[index];
|
|
25709
|
+
if (attribute !== undefined)
|
|
25710
|
+
words.push({ text: attribute.text, attribute: true });
|
|
25711
|
+
}
|
|
25712
|
+
words.push({ text: "}", attribute: false });
|
|
25713
|
+
return words;
|
|
25714
|
+
}
|
|
25715
|
+
function wordText(word, from = 0, characters = Array.from(word.text)) {
|
|
25716
|
+
if (word.attribute)
|
|
25717
|
+
return `the attribute ${word.text}`;
|
|
25718
|
+
return `${/\S/.test(word.text) ? "the word" : "the space"} ${quotedStoredLine(characters, from)}`;
|
|
25719
|
+
}
|
|
25720
|
+
function wordDifference(written, holds) {
|
|
25721
|
+
let before = 0;
|
|
25722
|
+
for (let index = 0;index < Math.max(written.length, holds.length); index += 1) {
|
|
25723
|
+
const given = written[index];
|
|
25724
|
+
const stored = holds[index];
|
|
25725
|
+
if (given !== undefined && stored !== undefined && given.text === stored.text) {
|
|
25726
|
+
before += Array.from(given.text).length;
|
|
25727
|
+
continue;
|
|
25728
|
+
}
|
|
25729
|
+
if (given === undefined && stored !== undefined) {
|
|
25730
|
+
return `ends after character ${before}, where Dispatch goes on with ${wordText(stored)}`;
|
|
25731
|
+
}
|
|
25732
|
+
if (given !== undefined && stored === undefined) {
|
|
25733
|
+
return `reads ${wordText(given)} at character ${before + 1}, where Dispatch ends the line`;
|
|
25734
|
+
}
|
|
25735
|
+
if (given !== undefined && stored !== undefined) {
|
|
25736
|
+
const wrote = Array.from(given.text);
|
|
25737
|
+
const held = Array.from(stored.text);
|
|
25738
|
+
let from = 0;
|
|
25739
|
+
if (!given.attribute && !stored.attribute && Math.max(wrote.length, held.length) > STORED_LINE_QUOTED) {
|
|
25740
|
+
while (from < wrote.length && wrote[from] === held[from])
|
|
25741
|
+
from += 1;
|
|
25742
|
+
const tail = Math.max(0, from - STORED_LINE_QUOTED);
|
|
25743
|
+
if (from === wrote.length) {
|
|
25744
|
+
return `ends ${wordText(given, tail, wrote)} after character ${before + from}, where Dispatch goes on with ${wordText(stored, from, held)}`;
|
|
25745
|
+
}
|
|
25746
|
+
if (from === held.length) {
|
|
25747
|
+
return `reads ${wordText(given, from, wrote)} at character ${before + from + 1}, where Dispatch ends ${wordText(stored, tail, held)}`;
|
|
25748
|
+
}
|
|
25749
|
+
}
|
|
25750
|
+
return `reads ${wordText(given, from, wrote)} at character ${before + from + 1}, where Dispatch stores ${wordText(stored, from, held)}`;
|
|
25751
|
+
}
|
|
25752
|
+
}
|
|
25753
|
+
return "differs from the line Dispatch stores";
|
|
25754
|
+
}
|
|
25755
|
+
function attributeDifference(line, given, stored) {
|
|
25756
|
+
const written = attributesByName(given.attributes);
|
|
25757
|
+
if (written === undefined)
|
|
25758
|
+
return;
|
|
25759
|
+
for (const attribute of stored.attributes) {
|
|
25760
|
+
const text = written.get(attribute.name);
|
|
25761
|
+
if (text === undefined)
|
|
25762
|
+
return `Dispatch adds the attribute ${attribute.text} to line ${line}`;
|
|
25763
|
+
if (text !== attribute.text) {
|
|
25764
|
+
return `line ${line} holds the attribute ${text}, which Dispatch stores as ${attribute.text}`;
|
|
25765
|
+
}
|
|
25766
|
+
}
|
|
25767
|
+
const held = new Set(stored.attributes.map((attribute) => attribute.name));
|
|
25768
|
+
const dropped = given.attributes.find((attribute) => !held.has(attribute.name));
|
|
25769
|
+
return dropped === undefined ? undefined : `line ${line} holds the attribute ${dropped.text}, which Dispatch drops`;
|
|
25770
|
+
}
|
|
25771
|
+
function lineDifference(line, wrote, given, held, stored) {
|
|
25772
|
+
if (given === undefined || stored === undefined) {
|
|
25773
|
+
return `line ${line} ${wordDifference(lineWords(wrote, undefined), lineWords(held, undefined))}`;
|
|
25774
|
+
}
|
|
25775
|
+
const attribute = attributeDifference(line, given, stored);
|
|
25776
|
+
if (attribute !== undefined)
|
|
25777
|
+
return attribute;
|
|
25778
|
+
const reordered = inStoredOrder(given, stored);
|
|
25779
|
+
if (reordered !== undefined && reordered !== wrote) {
|
|
25780
|
+
const words = lineWords(reordered, headedOpener(reordered));
|
|
25781
|
+
return `line ${line}, with its attributes put in the order Dispatch stores, ${wordDifference(words, lineWords(held, stored))}`;
|
|
25782
|
+
}
|
|
25783
|
+
return `line ${line} ${wordDifference(lineWords(wrote, given), lineWords(held, stored))}`;
|
|
25484
25784
|
}
|
|
25485
25785
|
function firstStoredDifference(given, stored) {
|
|
25486
25786
|
const written = given.split(`
|
|
@@ -25493,13 +25793,17 @@ function firstStoredDifference(given, stored) {
|
|
|
25493
25793
|
if (wrote === held)
|
|
25494
25794
|
continue;
|
|
25495
25795
|
if (wrote === undefined && held !== undefined) {
|
|
25496
|
-
return `the store writes a line ${line + 1}, ${quotedStoredLine(held)}`;
|
|
25796
|
+
return `the store writes a line ${line + 1}, ${quotedStoredLine(Array.from(held), 0)}`;
|
|
25497
25797
|
}
|
|
25498
25798
|
if (held === undefined && wrote !== undefined) {
|
|
25499
|
-
return `the store drops line ${line + 1}, ${quotedStoredLine(wrote)}`;
|
|
25799
|
+
return `the store drops line ${line + 1}, ${quotedStoredLine(Array.from(wrote), 0)}`;
|
|
25500
25800
|
}
|
|
25501
25801
|
if (wrote !== undefined && held !== undefined) {
|
|
25502
|
-
|
|
25802
|
+
const givenOpener = headedOpener(wrote);
|
|
25803
|
+
const storedOpener = headedOpener(held);
|
|
25804
|
+
if (onlyReordered(givenOpener, held, storedOpener))
|
|
25805
|
+
continue;
|
|
25806
|
+
return lineDifference(line + 1, wrote, givenOpener, held, storedOpener);
|
|
25503
25807
|
}
|
|
25504
25808
|
}
|
|
25505
25809
|
return "the stored text differs from the text given";
|
|
@@ -25529,6 +25833,33 @@ ${printed.text}`,
|
|
|
25529
25833
|
"--- end of the text Dispatch stores ---"
|
|
25530
25834
|
].join("");
|
|
25531
25835
|
}
|
|
25836
|
+
function withoutFinalLineFeed(text) {
|
|
25837
|
+
return text.endsWith(`
|
|
25838
|
+
`) ? text.slice(0, -1) : text;
|
|
25839
|
+
}
|
|
25840
|
+
function storedUpload(given, stored, name) {
|
|
25841
|
+
if (withoutFinalLineFeed(stored) === withoutFinalLineFeed(given)) {
|
|
25842
|
+
return { sent: given, reordered: [] };
|
|
25843
|
+
}
|
|
25844
|
+
const reordered = attributesReordered(given, stored);
|
|
25845
|
+
return reordered === undefined ? { refusal: storedTextProblem(given, stored, name) } : { sent: stored, reordered };
|
|
25846
|
+
}
|
|
25847
|
+
|
|
25848
|
+
// ../envoy-client/src/dispatch-commands/upload-checks.ts
|
|
25849
|
+
function artifactUnderName(artifacts, name) {
|
|
25850
|
+
const written = name.trim();
|
|
25851
|
+
return artifacts.find((held) => held.slug === written) ?? artifacts.find((held) => held.name === written);
|
|
25852
|
+
}
|
|
25853
|
+
function artifactNameExistsProblem(held, owner) {
|
|
25854
|
+
const versions = held.versions ?? [];
|
|
25855
|
+
const newest = versions[versions.length - 1];
|
|
25856
|
+
if (newest === undefined) {
|
|
25857
|
+
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}`;
|
|
25858
|
+
}
|
|
25859
|
+
const authors = (newest.authors ?? []).map(actorText);
|
|
25860
|
+
const wroteIt = authors.length === 0 ? actorText(held.created_by) : authors.join(" and ");
|
|
25861
|
+
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${ARTIFACT_NAME_EXISTS_RULE}`;
|
|
25862
|
+
}
|
|
25532
25863
|
function storedTextCheckFailed(error, name) {
|
|
25533
25864
|
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)}.`;
|
|
25534
25865
|
if (!dispatchAnswered(error, 413)) {
|
|
@@ -25540,10 +25871,6 @@ function storedTextCheckFailed(error, name) {
|
|
|
25540
25871
|
function roundTripRouteAbsent(error) {
|
|
25541
25872
|
return dispatchAnswered(error, 404) || dispatchAnswered(error, 405);
|
|
25542
25873
|
}
|
|
25543
|
-
function withoutFinalLineFeed(text) {
|
|
25544
|
-
return text.endsWith(`
|
|
25545
|
-
`) ? text.slice(0, -1) : text;
|
|
25546
|
-
}
|
|
25547
25874
|
|
|
25548
25875
|
// ../envoy-client/src/dispatch-commands/documents.ts
|
|
25549
25876
|
async function blockAsks(client, resolved, state) {
|
|
@@ -25927,6 +26254,8 @@ async function artifactCommand(context) {
|
|
|
25927
26254
|
]);
|
|
25928
26255
|
}
|
|
25929
26256
|
}
|
|
26257
|
+
let sent = content;
|
|
26258
|
+
let reordered = [];
|
|
25930
26259
|
if (!blank) {
|
|
25931
26260
|
let stored;
|
|
25932
26261
|
try {
|
|
@@ -25936,8 +26265,12 @@ async function artifactCommand(context) {
|
|
|
25936
26265
|
throw new Error(storedTextCheckFailed(error, name), { cause: error });
|
|
25937
26266
|
}
|
|
25938
26267
|
}
|
|
25939
|
-
if (stored !== undefined
|
|
25940
|
-
|
|
26268
|
+
if (stored !== undefined) {
|
|
26269
|
+
const upload = storedUpload(content, stored, name);
|
|
26270
|
+
if ("refusal" in upload)
|
|
26271
|
+
throw new ToolInputError(input.tool, [upload.refusal]);
|
|
26272
|
+
sent = upload.sent;
|
|
26273
|
+
reordered = upload.reordered;
|
|
25941
26274
|
}
|
|
25942
26275
|
}
|
|
25943
26276
|
const artifactInput = path !== undefined ? {
|
|
@@ -25945,7 +26278,7 @@ async function artifactCommand(context) {
|
|
|
25945
26278
|
file: input.uploadBytes === undefined ? Bun.file(resolvePath2(input.cwd, path)) : new Blob([new Uint8Array(input.uploadBytes)], {
|
|
25946
26279
|
type: Bun.file(resolvePath2(input.cwd, path)).type
|
|
25947
26280
|
})
|
|
25948
|
-
} :
|
|
26281
|
+
} : sent !== undefined ? { ...options, content: sent } : options;
|
|
25949
26282
|
const result = artifactOwner.kind === "project" ? await client.projectArtifact(artifactOwner.project, artifactInput) : await client.artifact(issue(), artifactInput);
|
|
25950
26283
|
const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
|
|
25951
26284
|
const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
|
|
@@ -25956,6 +26289,7 @@ async function artifactCommand(context) {
|
|
|
25956
26289
|
return {
|
|
25957
26290
|
text: [
|
|
25958
26291
|
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)}`,
|
|
26292
|
+
...reordered,
|
|
25959
26293
|
...adviceLines
|
|
25960
26294
|
].join(`
|
|
25961
26295
|
`),
|
|
@@ -4,7 +4,7 @@ description: |
|
|
|
4
4
|
Plan and spec reviewer. It changes nothing. Use after drafting a plan: checks that it can be
|
|
5
5
|
carried out as written, approves when in doubt except on the goal and the requirements, where
|
|
6
6
|
doubt is a rejection, and names at most three blocking issues, each
|
|
7
|
-
with its evidence. Use before
|
|
7
|
+
with its evidence. Use on a spec before an approval request: checks each factual claim in it
|
|
8
8
|
against the code, the docs or a read-only command it runs, and marks each claim verified, false
|
|
9
9
|
or unverified.
|
|
10
10
|
tools: Read, Bash
|