@sjawhar/claude-envoy 2.0.0 → 2.2.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/dispatch.js +370 -56
- package/dist/envoy-channel.js +371 -57
- package/dist/session-hook.js +370 -56
- package/dist/session-title-hook.js +10 -1
- package/legion/skills/legion-architect/SKILL.md +6 -5
- package/legion/skills/legion-architect/references/acceptance.md +5 -5
- package/legion/skills/legion-architect/references/design-gate.md +87 -3
- package/legion/skills/legion-architect/references/wake-routing.md +1 -1
- package/legion/skills/legion-retro/SKILL.md +4 -4
- package/legion/skills/legion-worker/SKILL.md +1 -1
- package/legion/skills/legion-worker/references/merge-gate.md +6 -5
- package/legion/skills/legion-worker/references/pr-body.md +18 -18
- package/package.json +1 -1
package/dist/session-hook.js
CHANGED
|
@@ -14113,8 +14113,14 @@ function brokenParts(parts) {
|
|
|
14113
14113
|
var CONTENT_IS_MARKDOWN = "content is stored as a Markdown document, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
|
|
14114
14114
|
var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
|
|
14115
14115
|
var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so with content the name ends in .md or .markdown or has no extension; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
|
|
14116
|
+
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. Send the upload again with force (--force) to write the next version.";
|
|
14117
|
+
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}.`;
|
|
14116
14118
|
var NAME_EXTENSION = /\.([^\s.]+)$/u;
|
|
14117
14119
|
var MARKDOWN_EXTENSION = /^(md|markdown)$/i;
|
|
14120
|
+
function pathKeepsBytesOf(name) {
|
|
14121
|
+
const extension = NAME_EXTENSION.exec(name.trim())?.[1];
|
|
14122
|
+
return extension === undefined || !MARKDOWN_EXTENSION.test(extension);
|
|
14123
|
+
}
|
|
14118
14124
|
var artifactOwner = documentOwnerValidation(false);
|
|
14119
14125
|
function artifactProblem(value) {
|
|
14120
14126
|
const input = value;
|
|
@@ -14256,6 +14262,42 @@ var handoffValidation = {
|
|
|
14256
14262
|
message: HANDOFF_RULE,
|
|
14257
14263
|
refusal: (value) => handoffProblem(value) ?? HANDOFF_RULE
|
|
14258
14264
|
};
|
|
14265
|
+
var RESULT_REQUIRED_FIELDS = ["issue", "check", "role", "verdict", "commit"];
|
|
14266
|
+
var RESULT_RECORD_FIELDS = [
|
|
14267
|
+
...RESULT_REQUIRED_FIELDS,
|
|
14268
|
+
"surface",
|
|
14269
|
+
"run",
|
|
14270
|
+
"observed",
|
|
14271
|
+
"negative_control",
|
|
14272
|
+
"failed",
|
|
14273
|
+
"skipped",
|
|
14274
|
+
"excluded",
|
|
14275
|
+
"screenshots"
|
|
14276
|
+
];
|
|
14277
|
+
var RESULT_RETRACT_RULE = "Pass retract with the id of a result recorded before, and reason with why that result is " + "wrong, to retract it.";
|
|
14278
|
+
var RESULT_SHAPE_RULE = `${RESULT_RETRACT_RULE} A call with retract takes reason and no other argument. A call ` + "without retract records a result, and it takes issue, check, role, verdict and commit.";
|
|
14279
|
+
function resultProblem(value) {
|
|
14280
|
+
const input = value;
|
|
14281
|
+
const carried = RESULT_RECORD_FIELDS.filter((field) => input[field] !== undefined);
|
|
14282
|
+
if (typeof input["retract"] === "string") {
|
|
14283
|
+
const reason = input["reason"];
|
|
14284
|
+
if (typeof reason !== "string" || reason.trim() === "") {
|
|
14285
|
+
return "retract needs reason, the words that say why the result is wrong.";
|
|
14286
|
+
}
|
|
14287
|
+
if (carried.length > 0) {
|
|
14288
|
+
return `retract takes reason alone, and this call also carries ${carried.join(", ")}. Retract the result, then record a new one with a call of its own.`;
|
|
14289
|
+
}
|
|
14290
|
+
return;
|
|
14291
|
+
}
|
|
14292
|
+
if (input["reason"] !== undefined) {
|
|
14293
|
+
return "reason goes with retract, and this call carries no retract. Name the result to retract, or drop reason.";
|
|
14294
|
+
}
|
|
14295
|
+
const missing = RESULT_REQUIRED_FIELDS.filter((field) => input[field] === undefined);
|
|
14296
|
+
if (missing.length > 0) {
|
|
14297
|
+
return `recording a result needs ${missing.join(", ")}. ${RESULT_RETRACT_RULE}`;
|
|
14298
|
+
}
|
|
14299
|
+
return;
|
|
14300
|
+
}
|
|
14259
14301
|
var SEARCH_QUERY_MAX = 1000;
|
|
14260
14302
|
var SEARCH_QUERY_HINT = "search with a short phrase of a few words, not a passage";
|
|
14261
14303
|
var SEARCH_KIND_DEPTH = 100;
|
|
@@ -14609,13 +14651,13 @@ var dispatchToolSpecs = [
|
|
|
14609
14651
|
verdict: "pass",
|
|
14610
14652
|
commit: "1111111111111111111111111111111111111111"
|
|
14611
14653
|
},
|
|
14612
|
-
description: "Record one result of one check of an issue's Verification document,
|
|
14654
|
+
description: "Record one result of one check of an issue's Verification document, or retract a result " + "recorded before. A record prints the pull-request body line it implies. Write that line " + "into the pull-request body unchanged: it is the one grammar every writer uses, and it " + "carries no link to Dispatch. " + "Name the check by its block id. Where two Verification documents in reach hold that id, " + "name it by its canonical reference (dispatch://KEY/artifact/verification-md#b-<id>). " + "409 CHECK_AMBIGUOUS names both documents. An id no Verification document of the issue " + "or of an issue above it holds is 400 UNKNOWN_CHECK. " + "A pass that counts a failed, a skipped or an excluded case contradicts itself, and is " + "400 RESULT_CONTRADICTS. " + "Dispatch asks GitHub whether the repository of the check's issue holds the commit. A " + "commit that repository does not hold is 400 RESULT_COMMIT_UNKNOWN, which names the " + "commit and that owner/repo. Record the result after the commit is pushed. A repository " + "Dispatch cannot read records the result as before. " + "The result is recorded against the check's own issue, so a child's run of a parent's " + "check appears under that check. A closed issue takes a result only for a check whose " + "when is after_merge or default_branch, the production check after the merge. It refuses " + "every other record with 409 ISSUE_CLOSED, as it refuses every other write. " + RESULT_RETRACT_RULE + " The retraction keeps both records: the result stays readable, and it proves nothing " + "from then on. Record a new result where the check still needs one. A retraction is " + "taken on a closed issue and for a check of any when. Three callers may retract: the " + "session that recorded the result, a session that holds the Dispatch claim of the issue " + "the result was recorded on, and a caller whose credential carries a person. Every other " + "caller is 403 RETRACTION_FORBIDDEN. A result retracted already is 409 RESULT_RETRACTED. " + ISSUE_REFERENCE,
|
|
14613
14655
|
arguments: (z) => ({
|
|
14614
|
-
issue: z.string().describe(ISSUE_REFERENCE),
|
|
14615
|
-
check: z.string().describe("The check block's id, or its canonical reference dispatch://KEY/artifact/verification-md#b-<id> when the id is not unique among the issue's Verification document and those of the issues above it."),
|
|
14616
|
-
role: z.string({ max: 32 }).describe("Who ran it: implementer, tester, reviewer. At most 32 characters of a-z and -, printed in the pull-request line."),
|
|
14617
|
-
verdict: z.enum(["pass", "fail"]).describe("Whether the check passed."),
|
|
14618
|
-
commit: z.string().describe("The 40-character lowercase hex commit the check ran at."),
|
|
14656
|
+
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
14657
|
+
check: z.string().describe("The check block's id, or its canonical reference dispatch://KEY/artifact/verification-md#b-<id> when the id is not unique among the issue's Verification document and those of the issues above it.").optional(),
|
|
14658
|
+
role: z.string({ max: 32 }).describe("Who ran it: implementer, tester, reviewer. At most 32 characters of a-z and -, printed in the pull-request line.").optional(),
|
|
14659
|
+
verdict: z.enum(["pass", "fail"]).describe("Whether the check passed.").optional(),
|
|
14660
|
+
commit: z.string().describe("The 40-character lowercase hex commit the check ran at.").optional(),
|
|
14619
14661
|
surface: z.string().describe("Where a person reaches the change.").optional(),
|
|
14620
14662
|
run: z.string().describe("The command that proved it.").optional(),
|
|
14621
14663
|
observed: z.string().describe("What the command printed.").optional(),
|
|
@@ -14623,28 +14665,38 @@ var dispatchToolSpecs = [
|
|
|
14623
14665
|
failed: z.number({ int: true, min: 0 }).describe("Cases the run failed; 0 by default.").optional(),
|
|
14624
14666
|
skipped: z.number({ int: true, min: 0 }).describe("Cases the run skipped; 0 by default.").optional(),
|
|
14625
14667
|
excluded: z.number({ int: true, min: 0 }).describe("Cases the run excluded; 0 by default.").optional(),
|
|
14626
|
-
screenshots: z.array(z.string()).describe("dispatch:// references to image documents of this issue or of the check's issue.").optional()
|
|
14627
|
-
|
|
14668
|
+
screenshots: z.array(z.string()).describe("dispatch:// references to image documents of this issue or of the check's issue.").optional(),
|
|
14669
|
+
retract: z.string().describe("The id of a result recorded before. It records that the result is wrong, and it takes reason alone beside it.").optional(),
|
|
14670
|
+
reason: z.string().describe("Why the retracted result is wrong. It goes with retract and with nothing else.").optional()
|
|
14671
|
+
}),
|
|
14672
|
+
validation: {
|
|
14673
|
+
check: (value) => resultProblem(value) === undefined,
|
|
14674
|
+
message: RESULT_SHAPE_RULE,
|
|
14675
|
+
refusal: (value) => resultProblem(value) ?? RESULT_SHAPE_RULE
|
|
14676
|
+
}
|
|
14628
14677
|
},
|
|
14629
14678
|
{
|
|
14630
14679
|
name: "dispatch_results",
|
|
14631
14680
|
example: { issue: "DSP-1" },
|
|
14632
|
-
description: "Print each check of an issue's Verification document with
|
|
14681
|
+
description: "Print each check of an issue's Verification document with every result recorded against " + "it, newest first. " + "Each check prints what Dispatch compared its results with. A before_merge check is " + "compared with the head of each pull request Dispatch holds for the check's issue, open " + "or merged. An after_merge check is compared with the branch that issue's pull request " + "merged into and with the repository's default branch, and with the default branch alone " + "where Dispatch holds no merge of the issue. A default_branch check is compared with the " + "repository's default branch alone, whatever branch the pull request merged into. Where " + "a check compared with nothing, it says which of three things happened: the issue has no " + "pull request and no branch to compare with, Dispatch cannot read the repository, or a " + "read Dispatch made did not answer. " + "Each check then prints one line that answers the gate: whether a pass of it stands, and " + "from which roles. A pass stands when its commit is one of the commits the check " + "compared with, the check's words did not move after the result was recorded, and no " + "retraction stands against it. " + "The check's own words print once, under the check. Each result then prints its verdict, " + "its role, its whole 40-character commit, where that commit stands, whether the check's " + "words moved after it was recorded, the time, its id, and the reading the role recorded. " + "A result nobody gave a reading says so. A retracted result prints as retracted, with " + "the reason and the caller that retracted it. A check with no result says so. " + "A push that moves a pull request's head leaves a result at the commit before it, with " + "no write of anyone's: record the check again at the new head. " + ISSUE_REFERENCE,
|
|
14633
14682
|
arguments: (z) => ({
|
|
14634
|
-
issue: z.string().describe(ISSUE_REFERENCE)
|
|
14683
|
+
issue: z.string().describe(ISSUE_REFERENCE),
|
|
14684
|
+
at: z.string().describe("One commit of 40 lowercase hex characters. It becomes the only thing every check is compared with, and Dispatch reads GitHub for none of it.").optional(),
|
|
14685
|
+
brief: z.boolean().describe("Cut each reading whose result stands at none of the compared commits to its first 200 characters. Every other reading prints whole.").optional()
|
|
14635
14686
|
})
|
|
14636
14687
|
},
|
|
14637
14688
|
{
|
|
14638
14689
|
name: "dispatch_artifact",
|
|
14639
14690
|
example: { issue: "DSP-1", name: "design.md", content: `# Design
|
|
14640
14691
|
` },
|
|
14641
|
-
description: "Attach a local file or inline text as an issue artifact or project document. 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.
|
|
14692
|
+
description: "Attach a local file or inline text as an issue artifact or project document. 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. Exactly one of path or content is required; a markdown document is at most 1 MiB and any other file at most 25 MiB. " + `${ARTIFACT_NAME_EXISTS_RULE} ` + `${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. " + `${OWNER_REFERENCE}`,
|
|
14642
14693
|
arguments: (z) => ({
|
|
14643
14694
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
14644
14695
|
project: z.string().describe("Project key for an unlinked document.").optional(),
|
|
14645
14696
|
name: z.string().describe("Artifact filename shown in Dispatch."),
|
|
14646
14697
|
path: z.string().describe("Local path to the file to upload.").optional(),
|
|
14647
|
-
content: z.string().describe("Inline text to store as a Markdown document, under a name ending in .md or .markdown or with no extension
|
|
14698
|
+
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(),
|
|
14699
|
+
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(),
|
|
14648
14700
|
summary: z.string().describe("Optional version summary.").optional()
|
|
14649
14701
|
}),
|
|
14650
14702
|
validation: {
|
|
@@ -16114,8 +16166,17 @@ function askAnswerText(answer) {
|
|
|
16114
16166
|
}
|
|
16115
16167
|
|
|
16116
16168
|
// ../envoy-client/src/errors.ts
|
|
16169
|
+
function dispatchCode(error) {
|
|
16170
|
+
if (!("fromDispatch" in error) || !("code" in error))
|
|
16171
|
+
return;
|
|
16172
|
+
const code = error.code;
|
|
16173
|
+
return typeof code === "string" && code !== "" ? code : undefined;
|
|
16174
|
+
}
|
|
16117
16175
|
function messageFor(error) {
|
|
16118
|
-
|
|
16176
|
+
if (!(error instanceof Error))
|
|
16177
|
+
return String(error);
|
|
16178
|
+
const code = dispatchCode(error);
|
|
16179
|
+
return code === undefined || error.message.startsWith(code) ? error.message : `${code}: ${error.message}`;
|
|
16119
16180
|
}
|
|
16120
16181
|
function hasErrnoCode(error, code) {
|
|
16121
16182
|
return error instanceof Error && "code" in error && error.code === code;
|
|
@@ -17084,6 +17145,13 @@ class DispatchClient {
|
|
|
17084
17145
|
return answer;
|
|
17085
17146
|
throw new Error(`GET ${this.#url(path, query)} asked for the unpaged listing and got ${whyNotAnArray(answer)}.`);
|
|
17086
17147
|
}
|
|
17148
|
+
async listIssueArtifacts(issue) {
|
|
17149
|
+
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "artifacts"]);
|
|
17150
|
+
}
|
|
17151
|
+
async markdownRoundTrip(markdown) {
|
|
17152
|
+
const answer = await this.#json("POST", ["api", "v1", "markdown", "round-trip"], { markdown });
|
|
17153
|
+
return answer.markdown;
|
|
17154
|
+
}
|
|
17087
17155
|
async listProjectArtifacts(project, unlinked = false) {
|
|
17088
17156
|
return this.#json("GET", ["api", "v1", "projects", project, "artifacts"], undefined, unlinked ? { unlinked: "true" } : undefined);
|
|
17089
17157
|
}
|
|
@@ -17271,8 +17339,11 @@ class DispatchClient {
|
|
|
17271
17339
|
async recordResult(issue, input) {
|
|
17272
17340
|
return this.#json("POST", ["api", "v1", "issues", await this.#resolveIssue(issue), "results"], input);
|
|
17273
17341
|
}
|
|
17274
|
-
async issueResults(issue) {
|
|
17275
|
-
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "results"]);
|
|
17342
|
+
async issueResults(issue, at) {
|
|
17343
|
+
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "results"], undefined, at === undefined ? undefined : { at });
|
|
17344
|
+
}
|
|
17345
|
+
async retractResult(resultID, input) {
|
|
17346
|
+
return this.#json("POST", ["api", "v1", "results", resultID, "retract"], input);
|
|
17276
17347
|
}
|
|
17277
17348
|
async editAsk(id, input) {
|
|
17278
17349
|
return this.#json("PATCH", ["api", "v1", "asks", id], input);
|
|
@@ -17347,6 +17418,9 @@ class DispatchClient {
|
|
|
17347
17418
|
async docRead(id, version) {
|
|
17348
17419
|
return version === undefined ? this.#json("GET", ["api", "v1", "artifacts", id, "text"]) : this.#json("GET", ["api", "v1", "artifacts", id, "versions", String(version)]);
|
|
17349
17420
|
}
|
|
17421
|
+
async docReadWithBlocks(id) {
|
|
17422
|
+
return this.#json("GET", ["api", "v1", "artifacts", id, "text"], undefined, { blocks: true });
|
|
17423
|
+
}
|
|
17350
17424
|
async fileVersion(id, version) {
|
|
17351
17425
|
const url = this.#url(["api", "v1", "artifacts", id, "versions", String(version)]);
|
|
17352
17426
|
const response = await this.#send("GET", url, undefined, "*/*");
|
|
@@ -20132,11 +20206,11 @@ async function sessionAnswersSettled(session) {
|
|
|
20132
20206
|
class ToolInputError extends Error {
|
|
20133
20207
|
tool;
|
|
20134
20208
|
problems;
|
|
20135
|
-
constructor(tool, problems) {
|
|
20209
|
+
constructor(tool, problems, options) {
|
|
20136
20210
|
const count = problems.length;
|
|
20137
20211
|
const cli = isDispatchTool(tool);
|
|
20138
20212
|
const help = cli ? [
|
|
20139
|
-
`Allowed flags: ${commandFlags(tool).join(", ")}
|
|
20213
|
+
...options?.aboutAFlag === false ? [] : [`Allowed flags: ${commandFlags(tool).join(", ")}`],
|
|
20140
20214
|
`Example: ${commandLine(tool, exampleFor(tool))}`
|
|
20141
20215
|
] : [];
|
|
20142
20216
|
super([
|
|
@@ -20630,7 +20704,7 @@ async function refuseItemOffRef(tool, kind, ref, refText, item, documentId) {
|
|
|
20630
20704
|
`${refText} names ${kind} ${item.id} on ${refOwnerName(ref)}, but it is on ${where}`
|
|
20631
20705
|
]);
|
|
20632
20706
|
}
|
|
20633
|
-
async function resolveIdPrefix(tool, kind, id, ownerName, list) {
|
|
20707
|
+
async function resolveIdPrefix(tool, kind, id, ownerName, list, candidates) {
|
|
20634
20708
|
const fullID = normalizeUUID(id);
|
|
20635
20709
|
if (fullID !== undefined)
|
|
20636
20710
|
return fullID;
|
|
@@ -20640,9 +20714,13 @@ async function resolveIdPrefix(tool, kind, id, ownerName, list) {
|
|
|
20640
20714
|
]);
|
|
20641
20715
|
}
|
|
20642
20716
|
const prefix = id.toLowerCase();
|
|
20643
|
-
const
|
|
20717
|
+
const all = await list();
|
|
20718
|
+
const matches = all.filter((item) => item.id.toLowerCase().startsWith(prefix));
|
|
20644
20719
|
if (matches.length === 1 && matches[0] !== undefined)
|
|
20645
20720
|
return matches[0].id;
|
|
20721
|
+
if (candidates !== undefined) {
|
|
20722
|
+
throw new ToolInputError(tool, [candidates.refusal(matches, all)], { aboutAFlag: false });
|
|
20723
|
+
}
|
|
20646
20724
|
throw new ToolInputError(tool, [
|
|
20647
20725
|
matches.length === 0 ? `${kind} id ${id} matches none of the ${kind}s on ${ownerName}; use the full id` : `${kind} id ${id} matches ${matches.length} ${kind}s on ${ownerName}; use the full id`
|
|
20648
20726
|
]);
|
|
@@ -21093,6 +21171,9 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
21093
21171
|
if (tool === "dispatch_read" && typeof args.message === "string") {
|
|
21094
21172
|
return { args, ref, owner: null };
|
|
21095
21173
|
}
|
|
21174
|
+
if (tool === "dispatch_result" && typeof args["retract"] === "string") {
|
|
21175
|
+
return { args, ref, owner: null };
|
|
21176
|
+
}
|
|
21096
21177
|
const legionIssue = env.LEGION_ISSUE;
|
|
21097
21178
|
if (!legionIssue) {
|
|
21098
21179
|
problems.push(ownerRequiredProblem);
|
|
@@ -21251,9 +21332,14 @@ function boundedEditDistance(a, b, limit) {
|
|
|
21251
21332
|
return Math.min(previous[b.length], limit + 1);
|
|
21252
21333
|
}
|
|
21253
21334
|
var askHintLimit = 8;
|
|
21254
|
-
function
|
|
21335
|
+
function openAskChoices(asks, owner) {
|
|
21336
|
+
if (asks.length === 0)
|
|
21337
|
+
return `${owner} holds no open ask.`;
|
|
21255
21338
|
const hints = asks.slice(0, askHintLimit).map((ask) => `${ask.id.slice(0, 8)}\u2026 ${textHead(ask.question)}`);
|
|
21256
|
-
return `
|
|
21339
|
+
return `The open asks of ${owner} are: ${hints.join(", ")}.`;
|
|
21340
|
+
}
|
|
21341
|
+
function askIDInputProblem(asks, owner) {
|
|
21342
|
+
return `ask ids are uuids. Write the whole id, or at least its first 8 characters. ${openAskChoices(asks, owner)}`;
|
|
21257
21343
|
}
|
|
21258
21344
|
async function movedApprovalLine(client, askID) {
|
|
21259
21345
|
const ask = (await client.getAsk(askID).catch(() => {
|
|
@@ -21267,14 +21353,29 @@ async function movedApprovalLine(client, askID) {
|
|
|
21267
21353
|
const owner = ask.issue_key === null ? `--project ${ask.approval_artifact?.project ?? "<project>"} --artifact ${approval.artifact_id}` : ask.approval_artifact?.primary === true ? `--issue ${ask.issue_key}` : `--issue ${ask.issue_key} --artifact ${approval.artifact_id}`;
|
|
21268
21354
|
return `The reply did not hand the ask to the human: it is the approval request for ${approval.name} ` + `at version ${approval.requested_version}, and ${approval.name} is now version ${approval.version}. ` + "No reply hands a moved approval request back. Once the human has agreed to every point in " + `version ${approval.version}, run: dispatch request-approval ${owner} --summary ` + `'<what changed since version ${approval.requested_version}>'`;
|
|
21269
21355
|
}
|
|
21270
|
-
async function
|
|
21356
|
+
async function replyToAskCandidates(client, owner, resolved) {
|
|
21271
21357
|
if (owner.kind === "issue") {
|
|
21272
21358
|
const issue = resolved?.issue ?? await client.getIssue(owner.issue);
|
|
21273
|
-
return
|
|
21359
|
+
return { asks: issue.open_asks ?? [], owner: "this issue" };
|
|
21274
21360
|
}
|
|
21275
21361
|
if (resolved === undefined)
|
|
21276
21362
|
throw new Error("project document is missing its resolved artifact");
|
|
21277
|
-
return
|
|
21363
|
+
return {
|
|
21364
|
+
asks: await client.getArtifactAsks(resolved.artifact.id, "open"),
|
|
21365
|
+
owner: "this document"
|
|
21366
|
+
};
|
|
21367
|
+
}
|
|
21368
|
+
async function resolveReplyToAsk(tool, client, target, resolved, id) {
|
|
21369
|
+
const whole = normalizeUUID(id);
|
|
21370
|
+
if (whole !== undefined)
|
|
21371
|
+
return whole;
|
|
21372
|
+
const { asks, owner } = await replyToAskCandidates(client, target, resolved);
|
|
21373
|
+
if (!isIdPrefix(id)) {
|
|
21374
|
+
throw new ToolInputError(tool, [askIDInputProblem(asks, owner)], { aboutAFlag: false });
|
|
21375
|
+
}
|
|
21376
|
+
return resolveIdPrefix(tool, "ask", id, owner, async () => asks, {
|
|
21377
|
+
refusal: (found, all) => found.length === 0 ? `reply_to_ask ${id} names no open ask of ${owner}. ${openAskChoices(all, owner)}` : `reply_to_ask ${id} names ${found.length} open asks of ${owner}. Write more of the id. ${openAskChoices(all, owner)}`
|
|
21378
|
+
});
|
|
21278
21379
|
}
|
|
21279
21380
|
function anchor(artifact, args) {
|
|
21280
21381
|
const quote = optionalString(args, "quote");
|
|
@@ -21314,6 +21415,89 @@ function approvalLine(artifact) {
|
|
|
21314
21415
|
return `Approval: ${approval.state} on v${approval.version}${content}`;
|
|
21315
21416
|
}
|
|
21316
21417
|
}
|
|
21418
|
+
function artifactUnderName(artifacts, name) {
|
|
21419
|
+
const written = name.trim();
|
|
21420
|
+
return artifacts.find((held) => held.slug === written) ?? artifacts.find((held) => held.name === written);
|
|
21421
|
+
}
|
|
21422
|
+
function artifactNameExistsProblem(held, owner) {
|
|
21423
|
+
const versions = held.versions ?? [];
|
|
21424
|
+
const newest = versions[versions.length - 1];
|
|
21425
|
+
if (newest === undefined) {
|
|
21426
|
+
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}`;
|
|
21427
|
+
}
|
|
21428
|
+
const authors = (newest.authors ?? []).map(actorText);
|
|
21429
|
+
const wroteIt = authors.length === 0 ? actorText(held.created_by) : authors.join(" and ");
|
|
21430
|
+
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${ARTIFACT_NAME_EXISTS_RULE}`;
|
|
21431
|
+
}
|
|
21432
|
+
var STORED_LINE_QUOTED = 200;
|
|
21433
|
+
function quotedStoredLine(line) {
|
|
21434
|
+
if (line.length <= STORED_LINE_QUOTED)
|
|
21435
|
+
return JSON.stringify(line);
|
|
21436
|
+
const head = JSON.stringify(line.slice(0, STORED_LINE_QUOTED));
|
|
21437
|
+
return `${head} (cut after ${STORED_LINE_QUOTED} of its ${line.length} characters)`;
|
|
21438
|
+
}
|
|
21439
|
+
function firstStoredDifference(given, stored) {
|
|
21440
|
+
const written = given.split(`
|
|
21441
|
+
`);
|
|
21442
|
+
const holds = stored.split(`
|
|
21443
|
+
`);
|
|
21444
|
+
for (let line = 0;line < Math.max(written.length, holds.length); line += 1) {
|
|
21445
|
+
const wrote = written[line];
|
|
21446
|
+
const held = holds[line];
|
|
21447
|
+
if (wrote === held)
|
|
21448
|
+
continue;
|
|
21449
|
+
if (wrote === undefined && held !== undefined) {
|
|
21450
|
+
return `the store writes a line ${line + 1}, ${quotedStoredLine(held)}`;
|
|
21451
|
+
}
|
|
21452
|
+
if (held === undefined && wrote !== undefined) {
|
|
21453
|
+
return `the store drops line ${line + 1}, ${quotedStoredLine(wrote)}`;
|
|
21454
|
+
}
|
|
21455
|
+
if (wrote !== undefined && held !== undefined) {
|
|
21456
|
+
return `line ${line + 1} reads ${quotedStoredLine(wrote)} and is stored as ${quotedStoredLine(held)}`;
|
|
21457
|
+
}
|
|
21458
|
+
}
|
|
21459
|
+
return "the stored text differs from the text given";
|
|
21460
|
+
}
|
|
21461
|
+
var STORED_TEXT_PRINTED = 2000;
|
|
21462
|
+
function storedTextPrinted(stored) {
|
|
21463
|
+
if (stored.length <= STORED_TEXT_PRINTED)
|
|
21464
|
+
return { text: stored, cut: "" };
|
|
21465
|
+
const head = stored.slice(0, STORED_TEXT_PRINTED);
|
|
21466
|
+
const lastLineFeed = head.lastIndexOf(`
|
|
21467
|
+
`);
|
|
21468
|
+
const text = lastLineFeed === -1 ? head : head.slice(0, lastLineFeed + 1);
|
|
21469
|
+
return {
|
|
21470
|
+
text,
|
|
21471
|
+
cut: ` The text below is cut after ${text.length} of its ${stored.length} characters: change the line named above and send the text again.`
|
|
21472
|
+
};
|
|
21473
|
+
}
|
|
21474
|
+
function storedTextProblem(given, stored, name) {
|
|
21475
|
+
const asBytes = pathKeepsBytesOf(name) ? ` To keep the text as you wrote it, send it as a file with ${PATH_KEEPS_BYTES}.` : "";
|
|
21476
|
+
const printed = storedTextPrinted(stored);
|
|
21477
|
+
return [
|
|
21478
|
+
`Dispatch stores this text under another spelling: ${firstStoredDifference(given, stored)}.`,
|
|
21479
|
+
` Send the text Dispatch stores, which is between the two marker lines below.${asBytes}`,
|
|
21480
|
+
`${printed.cut}
|
|
21481
|
+
--- the text Dispatch stores ---
|
|
21482
|
+
${printed.text}`,
|
|
21483
|
+
"--- end of the text Dispatch stores ---"
|
|
21484
|
+
].join("");
|
|
21485
|
+
}
|
|
21486
|
+
function storedTextCheckFailed(error, name) {
|
|
21487
|
+
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)}.`;
|
|
21488
|
+
if (!dispatchAnswered(error, 413)) {
|
|
21489
|
+
return `${failure} Send the upload again once that call is answered.`;
|
|
21490
|
+
}
|
|
21491
|
+
const asBytes = pathKeepsBytesOf(name) ? ` Send it as a file with ${PATH_KEEPS_BYTES}, which asks this check nothing.` : "";
|
|
21492
|
+
return `${failure} This text is longer than the check reads, and sending the upload again does not change that: a markdown document is at most 1 MiB, so shorten it or split it across documents of at most that.${asBytes}`;
|
|
21493
|
+
}
|
|
21494
|
+
function roundTripRouteAbsent(error) {
|
|
21495
|
+
return dispatchAnswered(error, 404) || dispatchAnswered(error, 405);
|
|
21496
|
+
}
|
|
21497
|
+
function withoutFinalLineFeed(text) {
|
|
21498
|
+
return text.endsWith(`
|
|
21499
|
+
`) ? text.slice(0, -1) : text;
|
|
21500
|
+
}
|
|
21317
21501
|
function componentsLine(components) {
|
|
21318
21502
|
const ids = components.ids ?? [];
|
|
21319
21503
|
const unknown = components.unknown ?? [];
|
|
@@ -21407,7 +21591,96 @@ function progressText(progress, sep) {
|
|
|
21407
21591
|
}
|
|
21408
21592
|
return parts.join(sep);
|
|
21409
21593
|
}
|
|
21410
|
-
|
|
21594
|
+
var BRIEF_READING_CHARACTERS = 200;
|
|
21595
|
+
var COMPARISON_REASONS = {
|
|
21596
|
+
no_pull_request_or_branch: "the issue has no pull request and no branch to compare with",
|
|
21597
|
+
repository_unreadable: "Dispatch cannot read the repository",
|
|
21598
|
+
read_failed: "a read Dispatch made did not answer"
|
|
21599
|
+
};
|
|
21600
|
+
function learnedText(learned) {
|
|
21601
|
+
if (learned.kind === "read_at")
|
|
21602
|
+
return `Dispatch read it ${learned.at}`;
|
|
21603
|
+
return `GitHub updated it ${learned.at}`;
|
|
21604
|
+
}
|
|
21605
|
+
function basisText(basis) {
|
|
21606
|
+
const learned = basis.learned_at === undefined ? "" : ` (${learnedText(basis.learned_at)})`;
|
|
21607
|
+
if (basis.kind === "pull_request") {
|
|
21608
|
+
const number = basis.pull_request === undefined ? "" : `#${basis.pull_request} `;
|
|
21609
|
+
return `the head of pull request ${number}at ${basis.commit ?? "an unnamed commit"}${learned}`;
|
|
21610
|
+
}
|
|
21611
|
+
if (basis.kind === "branch")
|
|
21612
|
+
return `branch ${basis.branch ?? "unnamed"}${learned}`;
|
|
21613
|
+
return `the commit you named, ${basis.commit ?? ""}${learned}`;
|
|
21614
|
+
}
|
|
21615
|
+
function basisPlace(basis) {
|
|
21616
|
+
if (basis.kind === "pull_request") {
|
|
21617
|
+
return basis.pull_request === undefined ? "the head of a pull request" : `the head of pull request #${basis.pull_request}`;
|
|
21618
|
+
}
|
|
21619
|
+
if (basis.kind === "branch")
|
|
21620
|
+
return `on branch ${basis.branch ?? "unnamed"}`;
|
|
21621
|
+
return "the commit you named";
|
|
21622
|
+
}
|
|
21623
|
+
function commitStandsText(stands) {
|
|
21624
|
+
if (stands === undefined) {
|
|
21625
|
+
return "Where that commit stands is not known: this Dispatch server does not say";
|
|
21626
|
+
}
|
|
21627
|
+
if (stands.answer === "at_basis") {
|
|
21628
|
+
return stands.basis === undefined ? "That commit is one of the compared commits" : `That commit is ${basisPlace(stands.basis)}`;
|
|
21629
|
+
}
|
|
21630
|
+
if (stands.answer === "other_commit")
|
|
21631
|
+
return "That commit is none of the compared commits";
|
|
21632
|
+
return stands.reason === undefined ? "Where that commit stands is not known" : `Where that commit stands is not known: ${COMPARISON_REASONS[stands.reason]}`;
|
|
21633
|
+
}
|
|
21634
|
+
function checkWordsText(check, result) {
|
|
21635
|
+
const versions = `result version ${result.check_version}, check version ${check.version}`;
|
|
21636
|
+
if (result.check_words_moved === undefined) {
|
|
21637
|
+
return `Whether the check's words moved is not known (${versions})`;
|
|
21638
|
+
}
|
|
21639
|
+
return result.check_words_moved ? `The check's words moved after this result (${versions})` : `The check's words did not move after this result (${versions})`;
|
|
21640
|
+
}
|
|
21641
|
+
function passStandsText(pass) {
|
|
21642
|
+
if (pass === undefined)
|
|
21643
|
+
return "Whether a pass stands is not known: this Dispatch server does not say";
|
|
21644
|
+
if (pass.answer === "yes") {
|
|
21645
|
+
const roles = pass.roles ?? [];
|
|
21646
|
+
return roles.length === 0 ? "A pass stands: yes" : `A pass stands: yes, from ${roles.join(", ")}`;
|
|
21647
|
+
}
|
|
21648
|
+
if (pass.answer === "no")
|
|
21649
|
+
return "A pass stands: no";
|
|
21650
|
+
return "A pass stands: not known";
|
|
21651
|
+
}
|
|
21652
|
+
function readingLines(result, brief) {
|
|
21653
|
+
const observed = result.observed;
|
|
21654
|
+
if (observed === "")
|
|
21655
|
+
return [" The role recorded no reading."];
|
|
21656
|
+
const cut = brief && result.commit_stands?.answer !== "at_basis";
|
|
21657
|
+
if (cut && observed.length > BRIEF_READING_CHARACTERS) {
|
|
21658
|
+
return [` Reading: ${observed.slice(0, BRIEF_READING_CHARACTERS)}\u2026 (result ${result.id})`];
|
|
21659
|
+
}
|
|
21660
|
+
return [` Reading: ${observed}`];
|
|
21661
|
+
}
|
|
21662
|
+
function resultLines(check, result, brief) {
|
|
21663
|
+
const lines = [
|
|
21664
|
+
` - ${result.verdict} by ${result.role} at ${result.commit_sha}. ${commitStandsText(result.commit_stands)}. ${checkWordsText(check, result)}. Recorded ${result.created_at}. Result ${result.id}.`
|
|
21665
|
+
];
|
|
21666
|
+
const retracted = result.retracted;
|
|
21667
|
+
if (retracted !== undefined) {
|
|
21668
|
+
lines.push(` Retracted by ${actorText(retracted.actor)} at ${retracted.created_at}. The reason: ${retracted.reason}`);
|
|
21669
|
+
}
|
|
21670
|
+
return [...lines, ...readingLines(result, brief)];
|
|
21671
|
+
}
|
|
21672
|
+
function checkLines(check, brief) {
|
|
21673
|
+
const bases = check.compared_with ?? [];
|
|
21674
|
+
const reason = check.compared_nothing;
|
|
21675
|
+
const compared = bases.length > 0 ? `Compared with ${bases.map(basisText).join(", ")}` : reason === undefined ? "Compared with nothing, and this Dispatch server does not say why" : `Compared with nothing: ${COMPARISON_REASONS[reason]}`;
|
|
21676
|
+
const results = check.results ?? [];
|
|
21677
|
+
return [
|
|
21678
|
+
`- ${check.block_id} (${check.when}). ${compared}. ${passStandsText(check.pass_stands)}.`,
|
|
21679
|
+
` The check's words: ${check.text}`,
|
|
21680
|
+
...results.length === 0 ? [" No result is recorded for this check."] : results.flatMap((result) => resultLines(check, result, brief))
|
|
21681
|
+
];
|
|
21682
|
+
}
|
|
21683
|
+
function formatCheckResults(results, brief = false) {
|
|
21411
21684
|
if (results.verification_artifact_id === "") {
|
|
21412
21685
|
return `${results.issue} has no Verification document, so it has no checks. Write one (verification.md) with a check block per thing that must be proved.`;
|
|
21413
21686
|
}
|
|
@@ -21415,15 +21688,10 @@ function formatCheckResults(results) {
|
|
|
21415
21688
|
if (checks.length === 0) {
|
|
21416
21689
|
return `${results.issue}'s Verification document holds no check blocks.`;
|
|
21417
21690
|
}
|
|
21418
|
-
const
|
|
21419
|
-
|
|
21420
|
-
|
|
21421
|
-
|
|
21422
|
-
return `${head}no result yet. ${check.text}`;
|
|
21423
|
-
}
|
|
21424
|
-
return `${head}${latest.verdict} at ${latest.commit_sha} by ${latest.role}, ${latest.currency ?? "unknown"}. ${check.text}`;
|
|
21425
|
-
});
|
|
21426
|
-
return [`Checks of ${results.issue}:`, ...lines].join(`
|
|
21691
|
+
const blocks = checks.map((check) => checkLines(check, brief).join(`
|
|
21692
|
+
`));
|
|
21693
|
+
return [`Checks of ${results.issue}:`, ...blocks].join(`
|
|
21694
|
+
|
|
21427
21695
|
`);
|
|
21428
21696
|
}
|
|
21429
21697
|
function repositoryLine(issue) {
|
|
@@ -22090,9 +22358,6 @@ ${text}`,
|
|
|
22090
22358
|
var BLOCK_OPENING_CHARS = 60;
|
|
22091
22359
|
async function listDocumentBlocks(client, artifact) {
|
|
22092
22360
|
const live = await liveBlocks(client, artifact);
|
|
22093
|
-
if (live === undefined) {
|
|
22094
|
-
throw new Error(`${artifact.name} changed while dispatch doc-read --blocks read it, so the opening words could name the wrong text; nothing is listed. Run it again.`);
|
|
22095
|
-
}
|
|
22096
22361
|
const { bytes, blocks } = live;
|
|
22097
22362
|
const decoder = new TextDecoder;
|
|
22098
22363
|
const lines = [
|
|
@@ -22129,15 +22394,19 @@ async function listDocumentBlocks(client, artifact) {
|
|
|
22129
22394
|
holders.push(block);
|
|
22130
22395
|
}
|
|
22131
22396
|
return { text: lines.join(`
|
|
22132
|
-
`), token: live.token };
|
|
22397
|
+
`), token: live.token, version: live.version };
|
|
22133
22398
|
}
|
|
22134
22399
|
async function liveBlocks(client, artifact) {
|
|
22135
|
-
const
|
|
22136
|
-
|
|
22137
|
-
|
|
22138
|
-
|
|
22139
|
-
|
|
22140
|
-
|
|
22400
|
+
const read = await client.docReadWithBlocks(artifact.id);
|
|
22401
|
+
if (read.blocks === undefined) {
|
|
22402
|
+
throw new Error(`${artifact.name} was read from a Dispatch older than this command: it serves a document's blocks only on their own route, not beside the text they index, so nothing was listed.`);
|
|
22403
|
+
}
|
|
22404
|
+
return {
|
|
22405
|
+
bytes: new TextEncoder().encode(read.markdown),
|
|
22406
|
+
token: read.token,
|
|
22407
|
+
version: read.version ?? null,
|
|
22408
|
+
blocks: read.blocks
|
|
22409
|
+
};
|
|
22141
22410
|
}
|
|
22142
22411
|
async function refuseOpenDecisionBlocks(client, tool, resolved) {
|
|
22143
22412
|
const artifact = resolved.artifact;
|
|
@@ -22920,12 +23189,7 @@ async function executeDispatchTool(input) {
|
|
|
22920
23189
|
const anchored = resolved ? anchor(resolved.artifact, args) : undefined;
|
|
22921
23190
|
const replyTo = itemReplyTo(args, "reply_to");
|
|
22922
23191
|
const replyToAskTarget = itemReplyTo(args, "reply_to_ask");
|
|
22923
|
-
const replyToAsk = replyToAskTarget === undefined ? undefined :
|
|
22924
|
-
if (replyToAskTarget !== undefined && replyToAsk === undefined) {
|
|
22925
|
-
throw new ToolInputError(input.tool, [
|
|
22926
|
-
await invalidReplyToAskProblem(client, owner, resolved)
|
|
22927
|
-
]);
|
|
22928
|
-
}
|
|
23192
|
+
const replyToAsk = replyToAskTarget === undefined ? undefined : await resolveReplyToAsk(input.tool, client, owner, resolved, replyToAskTarget.id);
|
|
22929
23193
|
const replyToBlock = replyTo?.block ?? replyToAskTarget?.block;
|
|
22930
23194
|
const requestedTurn = optionalString(args, "turn");
|
|
22931
23195
|
const body = await writePictures(resolved, stringArg(args, "body"));
|
|
@@ -23146,10 +23410,15 @@ async function executeDispatchTool(input) {
|
|
|
23146
23410
|
throw new Error(`${resolved.artifact.name} is an uploaded ${resolved.artifact.kind}, not a document, so it has no blocks. Read it with dispatch doc-read without --blocks.`);
|
|
23147
23411
|
}
|
|
23148
23412
|
const listed = await listDocumentBlocks(client, resolved.artifact);
|
|
23413
|
+
const trailer = [
|
|
23414
|
+
...listed.token === undefined ? [] : [`Document token: ${listed.token}`],
|
|
23415
|
+
`Document version: ${listed.version === null ? "none yet" : listed.version}`
|
|
23416
|
+
];
|
|
23149
23417
|
return {
|
|
23150
|
-
text:
|
|
23418
|
+
text: `${listed.text}
|
|
23151
23419
|
|
|
23152
|
-
|
|
23420
|
+
${trailer.join(`
|
|
23421
|
+
`)}`,
|
|
23153
23422
|
details: resolved.owner.kind === "project" ? {
|
|
23154
23423
|
project: resolved.artifact.project,
|
|
23155
23424
|
document: documentLabel(resolved.artifact.project, resolved.artifact.slug)
|
|
@@ -23250,6 +23519,23 @@ Document token: ${listed.token}`,
|
|
|
23250
23519
|
};
|
|
23251
23520
|
}
|
|
23252
23521
|
case "dispatch_result": {
|
|
23522
|
+
const retract = optionalString(args, "retract");
|
|
23523
|
+
if (retract !== undefined) {
|
|
23524
|
+
const retraction = await client.retractResult(retract, {
|
|
23525
|
+
actor,
|
|
23526
|
+
reason: stringArg(args, "reason")
|
|
23527
|
+
});
|
|
23528
|
+
return {
|
|
23529
|
+
text: `Retracted result ${retraction.result_id}. ${actorText(retraction.actor)} retracted it at ${retraction.created_at}. The reason: ${retraction.reason}
|
|
23530
|
+
|
|
23531
|
+
The result stays readable, and it proves nothing from now on. Record a new result where the check still needs one.`,
|
|
23532
|
+
details: {
|
|
23533
|
+
result: retraction.result_id,
|
|
23534
|
+
reason: retraction.reason,
|
|
23535
|
+
created_at: retraction.created_at
|
|
23536
|
+
}
|
|
23537
|
+
};
|
|
23538
|
+
}
|
|
23253
23539
|
const issue = stringArg(args, "issue");
|
|
23254
23540
|
const optional = {
|
|
23255
23541
|
...defined("surface", optionalString(args, "surface")),
|
|
@@ -23285,16 +23571,45 @@ ${recorded.line}`,
|
|
|
23285
23571
|
}
|
|
23286
23572
|
case "dispatch_results": {
|
|
23287
23573
|
const issue = stringArg(args, "issue");
|
|
23288
|
-
const
|
|
23574
|
+
const at = optionalString(args, "at");
|
|
23575
|
+
const brief = optionalBoolean(args, "brief") === true;
|
|
23576
|
+
const results = await client.issueResults(issue, at);
|
|
23577
|
+
const checks = results.checks ?? [];
|
|
23289
23578
|
return {
|
|
23290
|
-
text: formatCheckResults(results),
|
|
23291
|
-
details: {
|
|
23579
|
+
text: formatCheckResults(results, brief),
|
|
23580
|
+
details: {
|
|
23581
|
+
issue,
|
|
23582
|
+
checks: checks.length,
|
|
23583
|
+
results: checks.reduce((total, check) => total + (check.results ?? []).length, 0)
|
|
23584
|
+
}
|
|
23292
23585
|
};
|
|
23293
23586
|
}
|
|
23294
23587
|
case "dispatch_artifact": {
|
|
23295
23588
|
const summary = optionalString(args, "summary");
|
|
23296
23589
|
const name = stringArg(args, "name");
|
|
23297
23590
|
const content = optionalString(args, "content");
|
|
23591
|
+
const artifactOwner = documentOwner();
|
|
23592
|
+
if (optionalBoolean(args, "force") !== true) {
|
|
23593
|
+
const held = artifactUnderName(artifactOwner.kind === "project" ? await client.listProjectArtifacts(artifactOwner.project, true) : await client.listIssueArtifacts(issue()), name);
|
|
23594
|
+
if (held !== undefined) {
|
|
23595
|
+
throw new ToolInputError(input.tool, [
|
|
23596
|
+
artifactNameExistsProblem(held, artifactOwner.kind === "project" ? `project ${artifactOwner.project}` : `issue ${issue()}`)
|
|
23597
|
+
]);
|
|
23598
|
+
}
|
|
23599
|
+
}
|
|
23600
|
+
if (content !== undefined) {
|
|
23601
|
+
let stored;
|
|
23602
|
+
try {
|
|
23603
|
+
stored = await client.markdownRoundTrip(content);
|
|
23604
|
+
} catch (error) {
|
|
23605
|
+
if (!roundTripRouteAbsent(error)) {
|
|
23606
|
+
throw new Error(storedTextCheckFailed(error, name), { cause: error });
|
|
23607
|
+
}
|
|
23608
|
+
}
|
|
23609
|
+
if (stored !== undefined && withoutFinalLineFeed(stored) !== withoutFinalLineFeed(content)) {
|
|
23610
|
+
throw new ToolInputError(input.tool, [storedTextProblem(content, stored, name)]);
|
|
23611
|
+
}
|
|
23612
|
+
}
|
|
23298
23613
|
const artifactInput = content === undefined ? {
|
|
23299
23614
|
name,
|
|
23300
23615
|
file: input.uploadBytes === undefined ? Bun.file(resolvePath2(input.cwd, stringArg(args, "path"))) : new Blob([new Uint8Array(input.uploadBytes)], {
|
|
@@ -23308,7 +23623,6 @@ ${recorded.line}`,
|
|
|
23308
23623
|
...summary === undefined ? {} : { summary },
|
|
23309
23624
|
actor
|
|
23310
23625
|
};
|
|
23311
|
-
const artifactOwner = documentOwner();
|
|
23312
23626
|
const result = artifactOwner.kind === "project" ? await client.projectArtifact(artifactOwner.project, artifactInput) : await client.artifact(issue(), artifactInput);
|
|
23313
23627
|
const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
|
|
23314
23628
|
const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
|