@sjawhar/claude-envoy 5.23.6 → 5.24.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 +315 -58
- package/dist/dispatch.js +9202 -8938
- package/dist/envoy-channel.js +321 -60
- package/dist/session-hook.js +315 -58
- package/package.json +2 -2
package/dist/codex-hook.js
CHANGED
|
@@ -14072,6 +14072,8 @@ var ASK_OPTIONS_CONTRACT = "Options carry the genuinely different approaches. Ea
|
|
|
14072
14072
|
var ASK_IS_FOR_A_PERSON = "An ask is a question for a person, never a request to another agent. Ask an agent by envoy_send or a comment on the issue.";
|
|
14073
14073
|
var ASK_WAITS_ON_THE_ASSIGNEE = "An ask waits on its asked-of person, else the issue's assignee, else the project's default assignee; no agent hands one on.";
|
|
14074
14074
|
var HUMAN_AGREED_TO_DOCUMENT = "the human has agreed to every point in the document";
|
|
14075
|
+
var DOCUMENT_OWNER_RULE = "Exactly one of issue and project is required; with project, artifact names the document.";
|
|
14076
|
+
var NAMED_DOCUMENT_OWNER_RULE = "Exactly one of issue and project is required; artifact or ref must name the document.";
|
|
14075
14077
|
function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false) {
|
|
14076
14078
|
return {
|
|
14077
14079
|
check: (value) => {
|
|
@@ -14082,15 +14084,21 @@ function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false)
|
|
|
14082
14084
|
const hasRef = typeof input.ref === "string";
|
|
14083
14085
|
return (hasIssue !== hasProject || !hasIssue && !hasProject && hasRef) && (!hasProject || !requireArtifact || hasArtifact) && (!alwaysRequireArtifact || hasArtifact || hasRef);
|
|
14084
14086
|
},
|
|
14085
|
-
message: alwaysRequireArtifact ?
|
|
14087
|
+
message: alwaysRequireArtifact ? NAMED_DOCUMENT_OWNER_RULE : DOCUMENT_OWNER_RULE
|
|
14086
14088
|
};
|
|
14087
14089
|
}
|
|
14088
14090
|
var ARTIFACT_SOURCE_RULE = "Give at most one of path and content. A call with neither makes an empty document under the name, which a person or an agent writes in afterwards with dispatch doc-edit.";
|
|
14089
|
-
var ARTIFACT_OWNER_AND_SOURCE_RULE = `${ARTIFACT_SOURCE_RULE}
|
|
14091
|
+
var ARTIFACT_OWNER_AND_SOURCE_RULE = `${ARTIFACT_SOURCE_RULE} ${DOCUMENT_OWNER_RULE}`;
|
|
14090
14092
|
function brokenParts(parts) {
|
|
14091
14093
|
const broken = parts.filter(([kept]) => !kept).map(([, message]) => message);
|
|
14092
14094
|
return broken.length === 0 ? undefined : broken.join(" ");
|
|
14093
14095
|
}
|
|
14096
|
+
function withoutOwnerRule(refusal) {
|
|
14097
|
+
const rule = DISPATCH_OWNER_RULES.find((owner) => refusal === owner || refusal.startsWith(`${owner} `));
|
|
14098
|
+
if (rule === undefined)
|
|
14099
|
+
return refusal;
|
|
14100
|
+
return refusal === rule ? undefined : refusal.slice(rule.length + 1);
|
|
14101
|
+
}
|
|
14094
14102
|
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)";
|
|
14095
14103
|
var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
|
|
14096
14104
|
var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
|
|
@@ -14134,18 +14142,13 @@ function pathKeepsBytesOf(name) {
|
|
|
14134
14142
|
var artifactOwner = documentOwnerValidation(false);
|
|
14135
14143
|
function artifactProblem(value) {
|
|
14136
14144
|
const input = value;
|
|
14137
|
-
const
|
|
14145
|
+
const extension = typeof input.path === "string" || typeof input.name !== "string" ? undefined : NAME_EXTENSION.exec(input.name.trim())?.[1];
|
|
14146
|
+
const nameProblem = extension === undefined || MARKDOWN_EXTENSION.test(extension) ? undefined : `${DOCUMENT_IS_MARKDOWN}, and ${JSON.stringify(input.name)} is not a Markdown name. Upload the file under the same name with ${PATH_KEEPS_BYTES}; a document takes a name ending in .md or .markdown or with no extension.`;
|
|
14147
|
+
return brokenParts([
|
|
14138
14148
|
[artifactOwner.check(value), artifactOwner.message],
|
|
14139
|
-
[typeof input.path !== "string" || typeof input.content !== "string", ARTIFACT_SOURCE_RULE]
|
|
14149
|
+
[typeof input.path !== "string" || typeof input.content !== "string", ARTIFACT_SOURCE_RULE],
|
|
14150
|
+
[nameProblem === undefined, nameProblem ?? ""]
|
|
14140
14151
|
]);
|
|
14141
|
-
if (ownerOrSourceProblem !== undefined)
|
|
14142
|
-
return ownerOrSourceProblem;
|
|
14143
|
-
if (typeof input.path === "string" || typeof input.name !== "string")
|
|
14144
|
-
return;
|
|
14145
|
-
const extension = NAME_EXTENSION.exec(input.name.trim())?.[1];
|
|
14146
|
-
if (extension === undefined || MARKDOWN_EXTENSION.test(extension))
|
|
14147
|
-
return;
|
|
14148
|
-
return `${DOCUMENT_IS_MARKDOWN}, and ${JSON.stringify(input.name)} is not a Markdown name. Upload the file under the same name with ${PATH_KEEPS_BYTES}; a document takes a name ending in .md or .markdown or with no extension.`;
|
|
14149
14152
|
}
|
|
14150
14153
|
var documentEditOwner = documentOwnerValidation(true);
|
|
14151
14154
|
var PRECONDITION_RULE = "A precondition selects exactly one of document or blocks.";
|
|
@@ -14240,34 +14243,100 @@ var ISSUE_UPDATE_FIELDS_RULE = "Issue update requires at least one field besides
|
|
|
14240
14243
|
var ISSUE_UPDATE_DONE_RULE = "status done requires reason, a non-empty note saying why the issue is closing, posted on the issue before it closes so the close carries its note";
|
|
14241
14244
|
var ISSUE_UPDATE_REASON_RULE = "reason goes only with status done";
|
|
14242
14245
|
var ISSUE_UPDATE_LABELS_RULE = "labels_add goes without labels";
|
|
14243
|
-
var
|
|
14244
|
-
|
|
14245
|
-
|
|
14246
|
+
var ISSUE_UPDATE_LABELS_REFUSAL = `${ISSUE_UPDATE_LABELS_RULE}: labels replaces every label the issue holds and labels_add adds to them, so name the labels to add in labels_add alone, or the whole set in labels alone.`;
|
|
14247
|
+
var ISSUE_STATUS_OPTIONS = [
|
|
14248
|
+
"include_children",
|
|
14249
|
+
"unlink_children",
|
|
14250
|
+
"include_parent"
|
|
14251
|
+
];
|
|
14252
|
+
function issueStatusOptionsOf(input) {
|
|
14253
|
+
return ISSUE_STATUS_OPTIONS.filter((option) => input[option] === true);
|
|
14254
|
+
}
|
|
14255
|
+
var ISSUE_UPDATE_PATCH_FIELDS = [
|
|
14256
|
+
"title",
|
|
14257
|
+
"labels",
|
|
14258
|
+
"labels_add",
|
|
14259
|
+
"priority",
|
|
14260
|
+
"assignee",
|
|
14261
|
+
"external_links",
|
|
14262
|
+
"route",
|
|
14263
|
+
"parent",
|
|
14264
|
+
"blocked_by",
|
|
14265
|
+
"advances",
|
|
14266
|
+
"advances_revision",
|
|
14267
|
+
"components",
|
|
14268
|
+
"repo",
|
|
14269
|
+
"before",
|
|
14270
|
+
"after"
|
|
14271
|
+
];
|
|
14272
|
+
var ISSUE_UPDATE_OPTIONS_RULE = "include_children, unlink_children and include_parent go with status, and with reason when the status is done, and with no other field. include_children does not go with unlink_children, or with status done.";
|
|
14273
|
+
var ISSUE_UPDATE_RULE = `${ISSUE_UPDATE_FIELDS_RULE} ${ISSUE_UPDATE_DONE_RULE}; ${ISSUE_UPDATE_REASON_RULE}; ${ISSUE_UPDATE_LABELS_RULE}. ${ISSUE_UPDATE_OPTIONS_RULE}`;
|
|
14274
|
+
function issueStatusOptionsProblem(input) {
|
|
14275
|
+
const options = issueStatusOptionsOf(input);
|
|
14276
|
+
if (options.length === 0)
|
|
14277
|
+
return;
|
|
14278
|
+
const named = options.join(", ").replace(/, ([^,]*)$/, " and $1");
|
|
14279
|
+
const others = ISSUE_UPDATE_PATCH_FIELDS.filter((field) => input[field] !== undefined);
|
|
14280
|
+
return brokenParts([
|
|
14281
|
+
[
|
|
14282
|
+
!(input["include_children"] === true && input["unlink_children"] === true),
|
|
14283
|
+
"include_children does not go with unlink_children. The open children move with the issue or leave it, so name one of the two."
|
|
14284
|
+
],
|
|
14285
|
+
[
|
|
14286
|
+
!(input["include_children"] === true && input["status"] === "done"),
|
|
14287
|
+
"include_children does not go with status done. Only a person who is signed in at a browser can close the open issues under an issue together with it, and this call presents a token. That person does it on the issue's page in Dispatch: Close issue, then Move them with it."
|
|
14288
|
+
],
|
|
14289
|
+
[
|
|
14290
|
+
typeof input["status"] === "string",
|
|
14291
|
+
`status is required with ${named}. Add status, or drop ${named}.`
|
|
14292
|
+
],
|
|
14293
|
+
[
|
|
14294
|
+
others.length === 0,
|
|
14295
|
+
`With ${named}, give status alone, and reason when the status is done. This call also names ${others.join(", ")}. Send those fields in a call of their own.`
|
|
14296
|
+
]
|
|
14297
|
+
]);
|
|
14298
|
+
}
|
|
14299
|
+
function issueReasonProblem(input) {
|
|
14246
14300
|
if (input.status === "done") {
|
|
14247
|
-
|
|
14248
|
-
return `${ISSUE_UPDATE_DONE_RULE}.`;
|
|
14249
|
-
}
|
|
14250
|
-
} else if (input.reason !== undefined) {
|
|
14251
|
-
const status = typeof input.status === "string" ? `status ${input.status}` : "an update without status done";
|
|
14252
|
-
return `${ISSUE_UPDATE_REASON_RULE}: it is the note posted on the issue as it closes, and ${status} closes nothing. Drop reason, or set status done to close the issue.`;
|
|
14253
|
-
}
|
|
14254
|
-
if (input.labels !== undefined && input.labels_add !== undefined) {
|
|
14255
|
-
return `${ISSUE_UPDATE_LABELS_RULE}: labels replaces every label the issue holds and labels_add adds to them, so name the labels to add in labels_add alone, or the whole set in labels alone.`;
|
|
14301
|
+
return typeof input.reason !== "string" || input.reason.trim() === "" ? `${ISSUE_UPDATE_DONE_RULE}.` : undefined;
|
|
14256
14302
|
}
|
|
14303
|
+
if (input.reason === undefined)
|
|
14304
|
+
return;
|
|
14305
|
+
const status = typeof input.status === "string" ? `status ${input.status}` : "an update without status done";
|
|
14306
|
+
return `${ISSUE_UPDATE_REASON_RULE}: it is the note posted on the issue as it closes, and ${status} closes nothing. Drop reason, or set status done to close the issue.`;
|
|
14307
|
+
}
|
|
14308
|
+
function issueUpdateProblem(value) {
|
|
14309
|
+
const input = value;
|
|
14310
|
+
const reasonProblem = issueReasonProblem(input);
|
|
14311
|
+
const optionsProblem = issueStatusOptionsProblem(value);
|
|
14312
|
+
const broken = brokenParts([
|
|
14313
|
+
[reasonProblem === undefined, reasonProblem ?? ""],
|
|
14314
|
+
[input.labels === undefined || input.labels_add === undefined, ISSUE_UPDATE_LABELS_REFUSAL],
|
|
14315
|
+
[optionsProblem === undefined, optionsProblem ?? ""]
|
|
14316
|
+
]);
|
|
14317
|
+
if (broken !== undefined)
|
|
14318
|
+
return broken;
|
|
14257
14319
|
const changesAField = typeof input.status === "string" || typeof input.title === "string" || Array.isArray(input.labels) || Array.isArray(input.labels_add) || typeof input.priority === "number" || input.priority === null || typeof input.assignee === "string" || input.assignee === null || Array.isArray(input.external_links) || typeof input.route === "string" || typeof input.parent === "string" || Array.isArray(input.blocked_by) || Array.isArray(input.advances) || typeof input.components === "object" && input.components !== null || typeof input.repo === "string" || typeof input.before === "string" || typeof input.after === "string";
|
|
14258
14320
|
return changesAField ? undefined : ISSUE_UPDATE_FIELDS_RULE;
|
|
14259
14321
|
}
|
|
14322
|
+
var MESSAGE_OWNER_RULE = "issue is required unless in_reply_to names a message delivered to this session, which is the one message with no issue.";
|
|
14260
14323
|
var messageValidation = {
|
|
14261
14324
|
check: (value) => {
|
|
14262
14325
|
const input = value;
|
|
14263
14326
|
return typeof input.issue === "string" || typeof input.in_reply_to === "string";
|
|
14264
14327
|
},
|
|
14265
|
-
message:
|
|
14328
|
+
message: MESSAGE_OWNER_RULE
|
|
14266
14329
|
};
|
|
14267
14330
|
var readOwner = documentOwnerValidation(false);
|
|
14268
14331
|
var READ_OWNER_RULE = "Exactly one of issue and project is required; project alone lists its documents, and with artifact names one.";
|
|
14269
14332
|
var READ_MESSAGE_RULE = "message stands alone: it names the conversation, so name no issue, project, artifact, or ref with it.";
|
|
14270
14333
|
var READ_HISTORY_RULE = "history reads each body an edit or the delete of one post replaced, so it needs a ref naming one comment or one issue message: message stands alone and names a whole conversation, which keeps no history of its own.";
|
|
14334
|
+
var DISPATCH_OWNER_RULES = [
|
|
14335
|
+
DOCUMENT_OWNER_RULE,
|
|
14336
|
+
NAMED_DOCUMENT_OWNER_RULE,
|
|
14337
|
+
READ_OWNER_RULE,
|
|
14338
|
+
MESSAGE_OWNER_RULE
|
|
14339
|
+
];
|
|
14271
14340
|
function readProblem(value) {
|
|
14272
14341
|
const input = value;
|
|
14273
14342
|
const historyKept = input.history !== true || typeof input.ref === "string";
|
|
@@ -14458,11 +14527,14 @@ var dispatchToolSpecs = [
|
|
|
14458
14527
|
priority: 1,
|
|
14459
14528
|
before: "DSP-2"
|
|
14460
14529
|
},
|
|
14461
|
-
description: "Update an existing issue: move its lifecycle status, retitle it, add labels to it or " + "replace its labels, set " + "its priority, set or clear its assignee, link a URL (the pull request that delivers it, a " + "run, a document), set its " + "route, set or clear its parent, replace the issues it is blocked by, replace the " + "priorities it advances, attach it to " + "architecture components, set the repository it targets, or move it on its project's " + "board. Status is one of " + `${ISSUE_STATUSES.join(", ")}; outside Legion, move it yourself as the work advances; inside ` + "Legion the daemon moves it. labels_add adds labels and keeps every label the issue holds; " + "labels replaces the whole set, so a label it does not name is removed, and the two never " + "go together. A non-empty external_links is " + "merged into the issue's existing links by URL, so linking the pull request you just opened " + "keeps every earlier link; an empty external_links removes every link instead. components " + "replaces the issue's own attachment. Closing an issue " + "(status done) requires reason, the note that says why: it is posted on the issue as a " + "message, then the issue closes, so the close carries its note; closing an issue that is " + "already closed is refused (ISSUE_CLOSED) before anything is posted. Reason goes only " + "with status done. Closing an issue withdraws every open ask " + "it holds (resolution kind withdrawn, naming the closer), and reopening it brings exactly " + "those asks back. " + "A closed issue still takes messages and comments, though not asks or artifacts; of this " + "tool's fields it takes only a board move " + "(before, after), components, " + "a reopening status (any status but done), and an external_links write that adds no new " + "link (so a link can move to the issue that replaced it); everything else, priority " + "included, waits for the reopen. " + "priority is yours to set and a human overrides it. assignee is the person who answers " + "this issue's asks, and every ask on it waits on them until a person hands that ask on. " + "Passing null unassigns the issue, and every ask on it then waits on the project's default " + "assignee: a question reaches the person it was handed to, else the issue's assignee, else " + "the project's default assignee, so every question reaches a person. " + "Set the assignee when a person said who owns the work, as you " + "file the issue or hand it over. before and after move the issue on " + "its project's board: before puts it above that issue, after below, and both together " + "land it between them. A project's board order is one agent's to keep; in a Legion " + "deployment that is the controller. Never reassign an issue a person holds to get a " + "faster answer: who holds it is their call. At least one " + `field besides issue is required. ${ISSUE_REFERENCE}`,
|
|
14530
|
+
description: "Update an existing issue: move its lifecycle status, retitle it, add labels to it or " + "replace its labels, set " + "its priority, set or clear its assignee, link a URL (the pull request that delivers it, a " + "run, a document), set its " + "route, set or clear its parent, replace the issues it is blocked by, replace the " + "priorities it advances, attach it to " + "architecture components, set the repository it targets, or move it on its project's " + "board. Status is one of " + `${ISSUE_STATUSES.join(", ")}; outside Legion, move it yourself as the work advances; inside ` + "Legion the daemon moves it. labels_add adds labels and keeps every label the issue holds; " + "labels replaces the whole set, so a label it does not name is removed, and the two never " + "go together. A non-empty external_links is " + "merged into the issue's existing links by URL, so linking the pull request you just opened " + "keeps every earlier link; an empty external_links removes every link instead. components " + "replaces the issue's own attachment. Closing an issue " + "(status done) requires reason, the note that says why: it is posted on the issue as a " + "message, then the issue closes, so the close carries its note; closing an issue that is " + "already closed is refused (ISSUE_CLOSED) before anything is posted. Reason goes only " + "with status done. Closing an issue withdraws every open ask " + "it holds (resolution kind withdrawn, naming the closer), and reopening it brings exactly " + "those asks back. " + "Dispatch puts the statuses in three groups: not started (triage, icebox, backlog), in work " + "(todo, in_progress, testing, needs_review, retro) and done. A parent is done only when each " + "child is done, and while a child is in work its parent is in work. Where Dispatch keeps " + "this rule, it refuses a status or parent change that breaks it with 409 " + "PARENT_STATUS_CONFLICT, which names each issue that holds it. include_children, " + "unlink_children and include_parent tell Dispatch what to do with those issues. Each goes " + "with status alone, and with reason when the status is done. include_children does not go " + "with done: only a person signed in at a browser closes the open issues under an issue " + "together with it, on the issue's page. " + "A closed issue still takes messages and comments, though not asks or artifacts; of this " + "tool's fields it takes only a board move " + "(before, after), components, " + "a reopening status (any status but done), and an external_links write that adds no new " + "link (so a link can move to the issue that replaced it); everything else, priority " + "included, waits for the reopen. " + "priority is yours to set and a human overrides it. assignee is the person who answers " + "this issue's asks, and every ask on it waits on them until a person hands that ask on. " + "Passing null unassigns the issue, and every ask on it then waits on the project's default " + "assignee: a question reaches the person it was handed to, else the issue's assignee, else " + "the project's default assignee, so every question reaches a person. " + "Set the assignee when a person said who owns the work, as you " + "file the issue or hand it over. before and after move the issue on " + "its project's board: before puts it above that issue, after below, and both together " + "land it between them. A project's board order is one agent's to keep; in a Legion " + "deployment that is the controller. Never reassign an issue a person holds to get a " + "faster answer: who holds it is their call. At least one " + `field besides issue is required. ${ISSUE_REFERENCE}`,
|
|
14462
14531
|
arguments: (z) => ({
|
|
14463
14532
|
issue: z.string().describe(ISSUE_REFERENCE),
|
|
14464
14533
|
status: z.enum(ISSUE_STATUSES).describe("New lifecycle status.").optional(),
|
|
14465
14534
|
reason: z.string().describe(`Required with status done, and only with it: why the issue is closing. Posted on the issue as a message before it closes. ${BODY_BLOCK_RULE}`).optional(),
|
|
14535
|
+
include_children: z.boolean().describe("With status, also write that status on each open issue under this issue, at any depth, whose status is in another group. Not with status done, which this tool refuses before anything is sent: only a person who is signed in at a browser can close the open issues under an issue together with it, on the issue's page in Dispatch (Close issue, then Move them with it).").optional(),
|
|
14536
|
+
unlink_children: z.boolean().describe("With status, also remove each open child from this issue, so that it has no parent. Each child keeps its status, and a done child stays.").optional(),
|
|
14537
|
+
include_parent: z.boolean().describe("With status, also move each issue above this issue that is not in work to in_progress, a done one included.").optional(),
|
|
14466
14538
|
title: z.string({ min: 1, max: ISSUE_TITLE_MAX }).describe("Replacement title, at most 1,000 characters.").optional(),
|
|
14467
14539
|
labels: z.array(z.string({ min: 1, max: ISSUE_LABEL_MAX }), { max: MAX_ISSUE_LABELS }).describe(`Replacement label set, at most ${MAX_ISSUE_LABELS} labels of up to ${ISSUE_LABEL_MAX} characters; replaces every existing label, so a label it does not name is removed. To add labels and keep the others, use labels_add. Not with labels_add.`).optional(),
|
|
14468
14540
|
labels_add: z.array(z.string({ min: 1, max: ISSUE_LABEL_MAX }), { max: MAX_ISSUE_LABELS }).describe(`Labels to add, at most ${MAX_ISSUE_LABELS} of up to ${ISSUE_LABEL_MAX} characters: each is added to the labels the issue holds when the write lands, and every label it holds stays; the issue holds at most ${MAX_ISSUE_LABELS} in all. Not with labels.`).optional(),
|
|
@@ -14916,7 +14988,7 @@ var dispatchToolSpecs = [
|
|
|
14916
14988
|
{
|
|
14917
14989
|
name: "dispatch_issues",
|
|
14918
14990
|
example: { project: "PROJ", limit: 250, offset: 250 },
|
|
14919
|
-
description: "List a project's issues for a roadmap or backlog pass: every issue in one project, each carrying " + "its status, priority, parent, labels, open-ask count, progress (its spec's task-list items and " + "its direct children, each done of total, as `tasks 3/7 \xB7 children 2/5`, each only when it has " + "any), and route with whether it reaches anyone, " + "so you can see backlog shape without opening every issue. Optionally filter by status, parent, " + "label, priority, route status, or how recently it changed; priority takes one or more of 0-3 " + "(P0-P3) and null for an issue with no priority, so an owner's P0/P1 audit is priority [0, 1]. " + 'route_status "no_holder" lists every open issue whose route names a role nobody holds or a ' + "session that is not running, as of the server's copy of the listener's session list, at " + "most 5 s old, whatever its priority. A restarting " + "session is absent for minutes, so an issue is unowned only when a read ten minutes later agrees. " + "Do not use it to search by keyword or phrase; dispatch search remains the keyword surface. " + "Dispatch pages the list: limit sets the page size (default " + `${DEFAULT_ISSUE_PAGE_LIMIT}, max ${MAX_ISSUE_PAGE_LIMIT}) and offset selects where it starts ` + "(default 0), and the answer names how many issues match, so repeat with the next offset to " + "walk every matching issue. A walk is exact only while the list does not change: an issue " + "that enters or leaves what the filters match, or whose status or rank changes, between two " + "pages shifts rows across a page boundary, so one issue can come back twice and another never. " + "all takes the whole filtered list in one read instead, for a caller that must not miss or " + "repeat a row while other writers change the list, and especially for one whose own writes " + "move issues out of what it filtered on.",
|
|
14991
|
+
description: "List a project's issues for a roadmap or backlog pass: every issue in one project, each carrying " + "its status, priority, parent, labels, open-ask count, progress (its spec's task-list items and " + "its direct children, each done of total, as `tasks 3/7 \xB7 children 2/5`, each only when it has " + "any), and route with whether it reaches anyone, " + "so you can see backlog shape without opening every issue. Optionally filter by status, parent, " + "label, priority, route status, or how recently it changed; priority takes one or more of 0-3 " + "(P0-P3) and null for an issue with no priority, so an owner's P0/P1 audit is priority [0, 1]. " + 'route_status "no_holder" lists every open issue whose route names a role nobody holds or a ' + "session that is not running, as of the server's copy of the listener's session list, at " + "most 5 s old, whatever its priority. A restarting " + "session is absent for minutes, so an issue is unowned only when a read ten minutes later agrees. " + "Do not use it to search by keyword or phrase; dispatch search remains the keyword surface. " + "Dispatch pages the list: limit sets the page size (default " + `${DEFAULT_ISSUE_PAGE_LIMIT}, max ${MAX_ISSUE_PAGE_LIMIT}) and offset selects where it starts ` + "(default 0), and the answer names how many issues match, so repeat with the next offset to " + "walk every matching issue. A walk is exact only while the list does not change: an issue " + "that enters or leaves what the filters match, or whose status or rank changes, between two " + "pages shifts rows across a page boundary, so one issue can come back twice and another never. " + "all takes the whole filtered list in one read instead, for a caller that must not miss or " + "repeat a row while other writers change the list, and especially for one whose own writes " + "move issues out of what it filtered on. json prints the listing as one JSON object, for a " + "program such as jq to read.",
|
|
14920
14992
|
arguments: (z) => ({
|
|
14921
14993
|
project: z.string().describe("Project key to list issues from."),
|
|
14922
14994
|
status: z.enum(ISSUE_STATUSES).describe("Optional lifecycle status filter.").optional(),
|
|
@@ -14927,7 +14999,8 @@ var dispatchToolSpecs = [
|
|
|
14927
14999
|
route_status: z.enum(ISSUE_ROUTE_STATUSES).describe("Optional: only open issues whose route is in this state. live: a running session holds " + "the role or is the routed session. holder_unresponsive: that session has missed its " + "heartbeats without ending, so the route still reaches it and its messages wait. " + "no_holder: nobody running holds the role, or the session is gone, right now. " + "unknown: the Envoy listener did not answer.").optional(),
|
|
14928
15000
|
limit: z.number({ int: true, min: 1, max: MAX_ISSUE_PAGE_LIMIT }).describe(`Maximum rows, 1-${MAX_ISSUE_PAGE_LIMIT}; default ${DEFAULT_ISSUE_PAGE_LIMIT}.`).optional(),
|
|
14929
15001
|
offset: z.number({ int: true, min: 0 }).describe("Rows to skip before the page; nonnegative integer; default 0.").optional(),
|
|
14930
|
-
all: z.boolean().describe("Take every matching issue in one unpaged read, so no row is missed or repeated while " + "the list changes. Refused with limit or offset.").optional()
|
|
15002
|
+
all: z.boolean().describe("Take every matching issue in one unpaged read, so no row is missed or repeated while " + "the list changes. Refused with limit or offset.").optional(),
|
|
15003
|
+
json: z.boolean().describe("Print the listing as one JSON object and nothing else: {issues, total, offset, limit}, " + "each issue with its status, parent and labels. The dispatch command prints it whole, " + "also on a host that cuts long output.").optional()
|
|
14931
15004
|
})
|
|
14932
15005
|
},
|
|
14933
15006
|
{
|
|
@@ -21158,18 +21231,22 @@ var DISPATCH_URL_SETTING = "the configured Dispatch URL";
|
|
|
21158
21231
|
class DispatchServiceError extends Error {
|
|
21159
21232
|
code;
|
|
21160
21233
|
status;
|
|
21234
|
+
name = "DispatchServiceError";
|
|
21235
|
+
fromDispatch = true;
|
|
21161
21236
|
candidates;
|
|
21162
21237
|
current;
|
|
21163
21238
|
mismatches;
|
|
21164
|
-
|
|
21165
|
-
|
|
21166
|
-
constructor(code, status, message,
|
|
21239
|
+
issues;
|
|
21240
|
+
changed;
|
|
21241
|
+
constructor(code, status, message, details = {}) {
|
|
21167
21242
|
super(message);
|
|
21168
21243
|
this.code = code;
|
|
21169
21244
|
this.status = status;
|
|
21170
|
-
this.candidates = candidates;
|
|
21171
|
-
this.current = current;
|
|
21172
|
-
this.mismatches = mismatches;
|
|
21245
|
+
this.candidates = details.candidates;
|
|
21246
|
+
this.current = details.current;
|
|
21247
|
+
this.mismatches = details.mismatches;
|
|
21248
|
+
this.issues = details.issues;
|
|
21249
|
+
this.changed = details.changed;
|
|
21173
21250
|
}
|
|
21174
21251
|
}
|
|
21175
21252
|
|
|
@@ -21270,6 +21347,9 @@ function reviewNoRouteRefusal(baseUrl, route, version) {
|
|
|
21270
21347
|
function resultDryRunNoRouteRefusal(baseUrl, route) {
|
|
21271
21348
|
return new DispatchServiceError("NOT_FOUND", 404, `Dispatch at ${urlForText(baseUrl, DISPATCH_URL_SETTING)} answered no route for ${route} each ` + "time the dry run was sent: this build is older than a result's dry run, so it cannot show " + "the pull-request body line before the record. Nothing was recorded.");
|
|
21272
21349
|
}
|
|
21350
|
+
function statusChangeNoRouteRefusal(baseUrl, route) {
|
|
21351
|
+
return new DispatchServiceError("NOT_FOUND", 404, `Dispatch at ${urlForText(baseUrl, DISPATCH_URL_SETTING)} answered no route for ${route} each ` + "time the status change was sent. This build is older than that route, so it takes no " + "include_children, unlink_children or include_parent, and nothing changed. No PATCH was " + "sent in its place, since a PATCH would write the status without the option.");
|
|
21352
|
+
}
|
|
21273
21353
|
var ISSUE_EVENTS_PAGE_MAX = 200;
|
|
21274
21354
|
var DISPATCH_TOOL_DEADLINE_MS = 60000;
|
|
21275
21355
|
function requestSignal(signal, deadlineMs) {
|
|
@@ -21588,6 +21668,14 @@ class DispatchClient {
|
|
|
21588
21668
|
async updateIssue(issue, input) {
|
|
21589
21669
|
return this.#json("PATCH", ["api", "v1", "issues", await this.#resolveIssue(issue)], input);
|
|
21590
21670
|
}
|
|
21671
|
+
async changeIssueStatus(issue, input) {
|
|
21672
|
+
const path = ["api", "v1", "issues", await this.#resolveIssue(issue), "status-change"];
|
|
21673
|
+
try {
|
|
21674
|
+
return await this.#json("POST", path, input);
|
|
21675
|
+
} catch (error) {
|
|
21676
|
+
throw this.#refusalOfNoRoute(error, path, (route) => statusChangeNoRouteRefusal(this.#baseUrl, route));
|
|
21677
|
+
}
|
|
21678
|
+
}
|
|
21591
21679
|
async claimIssue(issue, input = {}) {
|
|
21592
21680
|
return this.#json("POST", ["api", "v1", "issues", await this.#resolveIssue(issue), "claim"], input);
|
|
21593
21681
|
}
|
|
@@ -21742,10 +21830,7 @@ class DispatchClient {
|
|
|
21742
21830
|
try {
|
|
21743
21831
|
return await this.#json("POST", path, body);
|
|
21744
21832
|
} catch (error) {
|
|
21745
|
-
|
|
21746
|
-
throw error;
|
|
21747
|
-
const route = `POST /${path.map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
21748
|
-
throw reviewNoRouteRefusal(this.#baseUrl, route, version);
|
|
21833
|
+
throw this.#refusalOfNoRoute(error, path, (route) => reviewNoRouteRefusal(this.#baseUrl, route, version));
|
|
21749
21834
|
}
|
|
21750
21835
|
}
|
|
21751
21836
|
async recordResult(issue, input) {
|
|
@@ -21756,10 +21841,7 @@ class DispatchClient {
|
|
|
21756
21841
|
try {
|
|
21757
21842
|
return await this.#writingNothing(path, input, { writes: false });
|
|
21758
21843
|
} catch (error) {
|
|
21759
|
-
|
|
21760
|
-
throw error;
|
|
21761
|
-
const route = `POST /${path.map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
21762
|
-
throw resultDryRunNoRouteRefusal(this.#baseUrl, route);
|
|
21844
|
+
throw this.#refusalOfNoRoute(error, path, (route) => resultDryRunNoRouteRefusal(this.#baseUrl, route));
|
|
21763
21845
|
}
|
|
21764
21846
|
}
|
|
21765
21847
|
async issueResults(issue, at) {
|
|
@@ -22004,6 +22086,11 @@ class DispatchClient {
|
|
|
22004
22086
|
sleep: this.#sleep
|
|
22005
22087
|
});
|
|
22006
22088
|
}
|
|
22089
|
+
#refusalOfNoRoute(error, path, refuse) {
|
|
22090
|
+
if (!(error instanceof DispatchNoRouteError) && !isNoRoute(error))
|
|
22091
|
+
return error;
|
|
22092
|
+
return refuse(`POST /${path.map((segment) => encodeURIComponent(segment)).join("/")}`);
|
|
22093
|
+
}
|
|
22007
22094
|
#writeCall(method, url, key, writes = true) {
|
|
22008
22095
|
if (method !== "POST" && method !== "PATCH")
|
|
22009
22096
|
return;
|
|
@@ -22337,7 +22424,7 @@ class DispatchClient {
|
|
|
22337
22424
|
if (response.status === 409 && error.code === IDEMPOTENCY_KEY_COMMITTED) {
|
|
22338
22425
|
throw new DispatchWriteLandedError(IDEMPOTENCY_KEY_COMMITTED, response.status, method, requestForText(this.#baseUrl, url, DISPATCH_URL_SETTING));
|
|
22339
22426
|
}
|
|
22340
|
-
throw new DispatchServiceError(error.code ?? `HTTP_${response.status}`, response.status, error.error, error
|
|
22427
|
+
throw new DispatchServiceError(error.code ?? `HTTP_${response.status}`, response.status, error.error, error);
|
|
22341
22428
|
}
|
|
22342
22429
|
throw this.#gatewayError(method, url, response, text, "Dispatch's error JSON");
|
|
22343
22430
|
}
|
|
@@ -24133,6 +24220,7 @@ var pictureSendingTools = {
|
|
|
24133
24220
|
};
|
|
24134
24221
|
var refGrammarProblem = "ref must be a valid dispatch:// reference such as dispatch://KEY-1, " + "dispatch://KEY-1/ask/<uuid>, dispatch://KEY-1/comment/<uuid>, " + "dispatch://KEY-1/message/<uuid>, dispatch://KEY-1/artifact/<slug>, " + "dispatch://PROJECT/artifact/<document-ref> (an artifact id, slug, or filename), " + "dispatch://KEY-1/spec#b-<block id>, dispatch://KEY-1/artifact/<slug>#b-<block id> or " + "dispatch://PROJECT/artifact/<slug>#b-<block id> (one block of a document, its id " + "percent-encoded, optionally pinned to a version of the document with @v<N> after it; for " + "dispatch read), dispatch://KEY-1/ask/<uuid>#b-<part id> or " + "dispatch://PROJECT/artifact/<slug>/ask/<uuid>#b-<part id> (one part of an ask: its question, " + "one of its options or its answer, optionally pinned to a revision of the ask's parts with " + "@v<N> after it; for dispatch read), dispatch://KEY-1/comment/<uuid>#b-<block id>, " + "dispatch://PROJECT/artifact/<slug>/comment/<uuid>#b-<block id> or " + "dispatch://KEY-1/message/<uuid>#b-<block id> (one block of a comment or message, a " + "comment's optionally pinned to a revision of the comment with @v<N> after it; for dispatch " + "read), or " + "dispatch://agent/<session id>/artifact/<slug> (a picture in a conversation on the Agents page, " + "for dispatch doc-read); a dashboard URL on this Dispatch server is accepted too";
|
|
24135
24222
|
var ownerRequiredProblem = "issue is required; supply issue or set LEGION_ISSUE";
|
|
24223
|
+
var ownerStandInIssue = "OWNER-1";
|
|
24136
24224
|
function argumentProblems(tool, args) {
|
|
24137
24225
|
const problems = [];
|
|
24138
24226
|
switch (tool) {
|
|
@@ -24418,7 +24506,7 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
24418
24506
|
const legionIssue = env.LEGION_ISSUE;
|
|
24419
24507
|
if (!legionIssue) {
|
|
24420
24508
|
problems.push(ownerRequiredProblem);
|
|
24421
|
-
return { args, ref, owner: null };
|
|
24509
|
+
return { args, ref, owner: null, ownerMissing: true };
|
|
24422
24510
|
}
|
|
24423
24511
|
if (nativeIssueKeyPattern.test(legionIssue) || externalIssueRefPattern.test(legionIssue)) {
|
|
24424
24512
|
const issue = canonicalExternalIssueRef(legionIssue);
|
|
@@ -24426,18 +24514,24 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
24426
24514
|
}
|
|
24427
24515
|
if (!bareIssueNumberPattern.test(legionIssue)) {
|
|
24428
24516
|
problems.push("LEGION_ISSUE must be a native issue key (e.g. LEGION-3), an external owner/repo#n reference, or a bare positive issue number");
|
|
24429
|
-
return { args, ref, owner: null };
|
|
24517
|
+
return { args, ref, owner: null, ownerMissing: true };
|
|
24430
24518
|
}
|
|
24431
24519
|
const repo = await resolveCwdRepo(cwd, exec);
|
|
24432
24520
|
if (!repo) {
|
|
24433
24521
|
problems.push("issue is required; LEGION_ISSUE needs a GitHub repository in cwd");
|
|
24434
|
-
return { args, ref, owner: null };
|
|
24522
|
+
return { args, ref, owner: null, ownerMissing: true };
|
|
24435
24523
|
}
|
|
24436
24524
|
const issue = `${repo}#${legionIssue}`;
|
|
24437
24525
|
return { args: { ...args, issue }, ref, owner: { kind: "issue", issue } };
|
|
24438
24526
|
}
|
|
24439
|
-
function
|
|
24440
|
-
|
|
24527
|
+
function withoutMissingOwner(issue) {
|
|
24528
|
+
if (issue.code === "invalid_type" && issue.path.length === 1 && issue.path[0] === "issue" && issue.input === undefined) {
|
|
24529
|
+
return;
|
|
24530
|
+
}
|
|
24531
|
+
if (issue.code !== "custom" || issue.path.length !== 0)
|
|
24532
|
+
return issue;
|
|
24533
|
+
const message = withoutOwnerRule(issue.message);
|
|
24534
|
+
return message === undefined ? undefined : message === issue.message ? issue : { ...issue, message };
|
|
24441
24535
|
}
|
|
24442
24536
|
function dispatchServerUrls(config) {
|
|
24443
24537
|
return config.publicUrl === undefined ? [config.url] : [config.url, config.publicUrl];
|
|
@@ -24448,11 +24542,12 @@ async function checkDispatchCall(input) {
|
|
|
24448
24542
|
const owner = await resolveOwnerArguments(tool, args, cwd, input.env ?? process.env, input.exec ?? defaultExec, input.serverUrls, problems);
|
|
24449
24543
|
const conflicts = issueFreeTools[tool] === true ? [] : ownerConflictProblems(tool, args, owner.ref, optionalString(owner.args, "ref"));
|
|
24450
24544
|
problems.push(...conflicts);
|
|
24451
|
-
const
|
|
24545
|
+
const ownerAlreadySaid = issueFreeTools[tool] !== true && (owner.owner === null || conflicts.length > 0);
|
|
24452
24546
|
const schema = toolSchema(tool);
|
|
24453
|
-
const
|
|
24547
|
+
const standIn = owner.ownerMissing === true;
|
|
24548
|
+
const parsed = schema.safeParse(standIn ? { ...owner.args, issue: ownerStandInIssue } : owner.args, { reportInput: true });
|
|
24454
24549
|
if (!parsed.success) {
|
|
24455
|
-
const issues =
|
|
24550
|
+
const issues = standIn ? parsed.error.issues : ownerAlreadySaid ? parsed.error.issues.flatMap((issue) => withoutMissingOwner(issue) ?? []) : parsed.error.issues;
|
|
24456
24551
|
problems.push(...formatZodIssues(issues, schema, tool));
|
|
24457
24552
|
}
|
|
24458
24553
|
problems.push(...argumentProblems(tool, owner.args));
|
|
@@ -24460,7 +24555,7 @@ async function checkDispatchCall(input) {
|
|
|
24460
24555
|
return {
|
|
24461
24556
|
problems,
|
|
24462
24557
|
owner,
|
|
24463
|
-
args: parsed.success ? parsed.data : owner.args,
|
|
24558
|
+
args: parsed.success && !standIn ? parsed.data : owner.args,
|
|
24464
24559
|
pictures
|
|
24465
24560
|
};
|
|
24466
24561
|
}
|
|
@@ -24478,7 +24573,75 @@ function refusalWithCode(error, ...clauses) {
|
|
|
24478
24573
|
}
|
|
24479
24574
|
if (!(error instanceof DispatchServiceError))
|
|
24480
24575
|
return error;
|
|
24481
|
-
|
|
24576
|
+
const told = joined !== "" && /[.!?]$/.test(error.message) ? `${error.message} ${suffix.charAt(0).toUpperCase()}${suffix.slice(1)}` : `${error.message}${joined}`;
|
|
24577
|
+
return new DispatchServiceError(error.code, error.status, `${error.code}: ${told}`, error);
|
|
24578
|
+
}
|
|
24579
|
+
function parentStatusConflictLines(error, tool, args, legionIssue) {
|
|
24580
|
+
if (!dispatchAnswered(error, 409) || error.code !== "PARENT_STATUS_CONFLICT")
|
|
24581
|
+
return;
|
|
24582
|
+
const issues = error.issues ?? [];
|
|
24583
|
+
if (issues.length === 0)
|
|
24584
|
+
return;
|
|
24585
|
+
const parents = issues.filter((issue) => issue.relation === "parent").map(({ key }) => key);
|
|
24586
|
+
const children = issues.filter((issue) => issue.relation === "child").map(({ key }) => key);
|
|
24587
|
+
return [
|
|
24588
|
+
messageFor(error),
|
|
24589
|
+
...issues.map((issue) => `${issue.key} [${issue.status}] ${issue.title}`),
|
|
24590
|
+
...nextSteps(tool, args, parents, children, legionIssue)
|
|
24591
|
+
];
|
|
24592
|
+
}
|
|
24593
|
+
var CHILD_FLAGS = "dispatch issue-update --status takes --unlink-children, which removes its open children from it, or, with a status other than done, --include-children, which moves the open issues under the issue with it. A person signed in at a browser closes them with it on the issue's page.";
|
|
24594
|
+
var PARENT_FLAG = "dispatch issue-update --status takes --include-parent, which moves each issue above the issue that is not in work to in_progress.";
|
|
24595
|
+
function otherProjectSentence(named, keys) {
|
|
24596
|
+
const project = named === undefined ? undefined : issueProject(named);
|
|
24597
|
+
if (project === undefined)
|
|
24598
|
+
return "";
|
|
24599
|
+
const others = keys.filter((key) => {
|
|
24600
|
+
const other = issueProject(key);
|
|
24601
|
+
return other !== undefined && other !== project;
|
|
24602
|
+
});
|
|
24603
|
+
if (others.length === 0)
|
|
24604
|
+
return "";
|
|
24605
|
+
const one = others.length === 1;
|
|
24606
|
+
return ` ${others.join(", ")} ${one ? "is" : "are"} not in the project of ${named}. A credential scoped to one project is refused a step that writes ${one ? "it" : "them"} (403 PROJECT_SCOPE), so a person, or a credential that names no project, must make that step.`;
|
|
24607
|
+
}
|
|
24608
|
+
function includeParentCall(key) {
|
|
24609
|
+
return `${commandLine("dispatch_issue_update", { issue: key, status: "in_progress", include_parent: true })}, which also moves each issue above ${key} that is not in work`;
|
|
24610
|
+
}
|
|
24611
|
+
function nextSteps(tool, args, parents, children, legionIssue) {
|
|
24612
|
+
if (tool === "dispatch_issue") {
|
|
24613
|
+
return parents.map((key) => `dispatch issue takes no flag that moves a done parent. Reopen ${key} first, with ${includeParentCall(key)}, then run dispatch issue again; or run it with --parent naming an open issue, or with no --parent.`);
|
|
24614
|
+
}
|
|
24615
|
+
const issueUpdate = tool === "dispatch_issue_update";
|
|
24616
|
+
const written = issueUpdate ? args : {};
|
|
24617
|
+
const fields = Object.keys(written).filter((field) => field !== "issue" && written[field] !== undefined);
|
|
24618
|
+
const issue = optionalString(written, "issue");
|
|
24619
|
+
const named = issueUpdate ? issue ?? legionIssue : undefined;
|
|
24620
|
+
const childHolds = children.length > 0;
|
|
24621
|
+
const childScope = otherProjectSentence(named, children);
|
|
24622
|
+
const status = optionalString(written, "status");
|
|
24623
|
+
const parent = optionalString(written, "parent");
|
|
24624
|
+
const alone = `--status${status === "done" ? " and --reason" : ""} alone`;
|
|
24625
|
+
if (parent !== undefined && parent !== "") {
|
|
24626
|
+
const issueFlag = issue === undefined ? "" : ` --issue ${issue}`;
|
|
24627
|
+
const statusFlag = status === undefined || childHolds ? "" : ` --status ${status}`;
|
|
24628
|
+
const kept = fields.filter((field) => field !== "parent" && field !== "status" && !(childHolds && field === "reason"));
|
|
24629
|
+
const otherFlags = kept.length > 0 ? ", with the call's other flags" : "";
|
|
24630
|
+
const reparent = `dispatch issue-update${issueFlag} --parent ${parent}${statusFlag}${otherFlags}`;
|
|
24631
|
+
const afterStatus = childHolds ? ", after the status change," : "";
|
|
24632
|
+
return [
|
|
24633
|
+
...childHolds ? [
|
|
24634
|
+
`${CHILD_FLAGS} Each goes with ${alone}, so run the status change first, in a call of its own, and the reparent after it: ${reparent}.${childScope}`
|
|
24635
|
+
] : [],
|
|
24636
|
+
...parents.map((key) => `dispatch issue-update takes no flag that moves the parent a reparent names. Move ${key} into work first, with ${includeParentCall(key)}; then${afterStatus} run the reparent again: ${reparent}.`)
|
|
24637
|
+
];
|
|
24638
|
+
}
|
|
24639
|
+
const others = ISSUE_UPDATE_PATCH_FIELDS.some((field) => written[field] !== undefined);
|
|
24640
|
+
const apart = (subject) => others ? ` ${subject} with ${alone}, so send the call's other changes in a call of their own.` : "";
|
|
24641
|
+
return [
|
|
24642
|
+
...childHolds ? [`${CHILD_FLAGS}${apart("Each goes")}${childScope}`] : [],
|
|
24643
|
+
...parents.length > 0 ? [`${PARENT_FLAG}${apart("It goes")}${otherProjectSentence(named, parents)}`] : []
|
|
24644
|
+
];
|
|
24482
24645
|
}
|
|
24483
24646
|
function dispatchAnswered(error, status) {
|
|
24484
24647
|
return error instanceof DispatchServiceError && error.fromDispatch && error.status === status;
|
|
@@ -24503,6 +24666,11 @@ function writeMayHaveLanded(error) {
|
|
|
24503
24666
|
return error.mayHaveReachedDispatch;
|
|
24504
24667
|
return !(error instanceof DispatchServiceError) || error.status >= 500;
|
|
24505
24668
|
}
|
|
24669
|
+
function closeAccount(error, closingNote) {
|
|
24670
|
+
const posted = `the reason already landed as message ${closingNote.id} (${closingNote.ref})`;
|
|
24671
|
+
const fix = error instanceof DispatchGatewayError && error.transient ? "" : "fix what refused the close, then ";
|
|
24672
|
+
return writeMayHaveLanded(error) ? `${posted}, and the close may or may not have taken effect. Read the issue's status before retrying: done means it closed; otherwise retry with a reason that points at message ${closingNote.id}, since retrying this call posts its reason again` : `${posted} but the issue did not close. Retrying this call posts its reason again, so ${fix}retry with a reason that points at message ${closingNote.id}`;
|
|
24673
|
+
}
|
|
24506
24674
|
function withAccount(error, account) {
|
|
24507
24675
|
const message = messageFor(error);
|
|
24508
24676
|
const told = /[.!?]$/.test(message) ? `${message} ${account.charAt(0).toUpperCase()}${account.slice(1)}` : `${message}; ${account}`;
|
|
@@ -25856,6 +26024,85 @@ async function followedAskDetails(client, ask, artifact) {
|
|
|
25856
26024
|
return { ...await askOwnerDetails(client, ask, artifact), follows: { ask: ask.id } };
|
|
25857
26025
|
}
|
|
25858
26026
|
|
|
26027
|
+
// ../envoy-client/src/dispatch-commands/status-change.ts
|
|
26028
|
+
async function issuesBeforeStatusChange(client, before, options) {
|
|
26029
|
+
const issues = new Map([
|
|
26030
|
+
[before.key, { status: before.status, parent: before.parent ?? null }]
|
|
26031
|
+
]);
|
|
26032
|
+
for (const child of before.children ?? []) {
|
|
26033
|
+
issues.set(child.key, { status: child.status, parent: before.key });
|
|
26034
|
+
}
|
|
26035
|
+
try {
|
|
26036
|
+
if (options.includes("include_children")) {
|
|
26037
|
+
for (const row of await client.listAllIssues({ project: before.project })) {
|
|
26038
|
+
issues.set(row.key, { status: row.status, parent: row.parent ?? null });
|
|
26039
|
+
}
|
|
26040
|
+
} else if (options.includes("include_parent")) {
|
|
26041
|
+
let parent = before.parent ?? null;
|
|
26042
|
+
while (parent !== null && !issues.has(parent)) {
|
|
26043
|
+
const above = await client.getIssue(parent);
|
|
26044
|
+
issues.set(above.key, { status: above.status, parent: above.parent ?? null });
|
|
26045
|
+
parent = above.parent ?? null;
|
|
26046
|
+
}
|
|
26047
|
+
}
|
|
26048
|
+
} catch (error) {
|
|
26049
|
+
throw refusalWithCode(error);
|
|
26050
|
+
}
|
|
26051
|
+
return issues;
|
|
26052
|
+
}
|
|
26053
|
+
async function statusChangeCommand(context, before, options, issuesBefore, closingNote) {
|
|
26054
|
+
const { args, client, actor, input, issue } = context;
|
|
26055
|
+
const status = stringArg(args, "status");
|
|
26056
|
+
const change = (entry) => {
|
|
26057
|
+
const was = issuesBefore.get(entry.key);
|
|
26058
|
+
if (entry.key !== before.key && entry.parent === null && was?.parent === before.key) {
|
|
26059
|
+
return `unlinked from ${before.key}`;
|
|
26060
|
+
}
|
|
26061
|
+
return was === undefined ? `status -> ${entry.status}` : `status ${was.status} -> ${entry.status}`;
|
|
26062
|
+
};
|
|
26063
|
+
let answer;
|
|
26064
|
+
try {
|
|
26065
|
+
answer = await client.changeIssueStatus(issue(), {
|
|
26066
|
+
status,
|
|
26067
|
+
...options.includes("include_children") ? { include_children: true } : {},
|
|
26068
|
+
...options.includes("unlink_children") ? { unlink_children: true } : {},
|
|
26069
|
+
...options.includes("include_parent") ? { include_parent: true } : {},
|
|
26070
|
+
actor
|
|
26071
|
+
});
|
|
26072
|
+
} catch (error) {
|
|
26073
|
+
if (error instanceof DispatchWriteLandedError)
|
|
26074
|
+
throw error;
|
|
26075
|
+
const committed = error instanceof DispatchServiceError ? error.changed ?? [] : [];
|
|
26076
|
+
const changed = committed.length === 0 ? "" : `the steps before the refusal changed ${committed.map((entry) => `${entry.key} (${change(entry)})`).join(", ")}`;
|
|
26077
|
+
if (closingNote === undefined)
|
|
26078
|
+
throw refusalWithCode(error, changed);
|
|
26079
|
+
const landed = closeAccount(error, closingNote);
|
|
26080
|
+
if (error instanceof DispatchServiceError)
|
|
26081
|
+
throw refusalWithCode(error, changed, landed);
|
|
26082
|
+
throw withAccount(error, landed);
|
|
26083
|
+
}
|
|
26084
|
+
const suffix = await notSubscribed(issueTopic(before.key), input.subscriptions);
|
|
26085
|
+
const namedLine = (after) => `${before.key}: ${[
|
|
26086
|
+
...closingNote === undefined ? [] : [`reason posted as message ${closingNote.id} (${closingNote.ref})`],
|
|
26087
|
+
`status ${before.status} -> ${after}`
|
|
26088
|
+
].join("; ")}${suffix}`;
|
|
26089
|
+
const changed = answer.changed ?? [];
|
|
26090
|
+
const lines = changed.map((entry) => entry.key === before.key ? namedLine(entry.status) : `${entry.key}: ${change(entry)}`);
|
|
26091
|
+
if (!changed.some((entry) => entry.key === before.key))
|
|
26092
|
+
lines.push(namedLine(answer.issue.status));
|
|
26093
|
+
return {
|
|
26094
|
+
text: lines.join(`
|
|
26095
|
+
`),
|
|
26096
|
+
details: {
|
|
26097
|
+
issue: before.key,
|
|
26098
|
+
status: answer.issue.status,
|
|
26099
|
+
external_links: (answer.issue.external_links ?? []).map((link) => link.url),
|
|
26100
|
+
changed: changed.map(({ key, status, parent }) => ({ key, status, parent })),
|
|
26101
|
+
...closingNote === undefined ? {} : { message: closingNote.id }
|
|
26102
|
+
}
|
|
26103
|
+
};
|
|
26104
|
+
}
|
|
26105
|
+
|
|
25859
26106
|
// ../envoy-client/src/dispatch-commands/issues.ts
|
|
25860
26107
|
function componentsChange(input, after) {
|
|
25861
26108
|
switch (input.mode) {
|
|
@@ -26007,6 +26254,7 @@ async function issueUpdateCommand(context) {
|
|
|
26007
26254
|
const advances = optionalStringArray(args, "advances");
|
|
26008
26255
|
const advancesRevision = optionalNumber(args, "advances_revision");
|
|
26009
26256
|
const requestedLinks = Array.isArray(args.external_links) ? [...new Set(args.external_links)] : undefined;
|
|
26257
|
+
const options = issueStatusOptionsOf(args);
|
|
26010
26258
|
let before;
|
|
26011
26259
|
try {
|
|
26012
26260
|
before = await client.getIssue(issueKey);
|
|
@@ -26017,6 +26265,7 @@ async function issueUpdateCommand(context) {
|
|
|
26017
26265
|
if (status === "done" && typeof before.closed_at === "string") {
|
|
26018
26266
|
throw refusalWithCode(new DispatchServiceError("ISSUE_CLOSED", 409, "issue is closed"), `${issueKey} closed at ${before.closed_at}, so the reason was not posted and the close was not sent`);
|
|
26019
26267
|
}
|
|
26268
|
+
const issuesBefore = options.length === 0 ? undefined : await issuesBeforeStatusChange(client, before, options);
|
|
26020
26269
|
let closingNote;
|
|
26021
26270
|
if (reason !== undefined) {
|
|
26022
26271
|
try {
|
|
@@ -26035,6 +26284,9 @@ async function issueUpdateCommand(context) {
|
|
|
26035
26284
|
throw withAccount(error, told);
|
|
26036
26285
|
}
|
|
26037
26286
|
}
|
|
26287
|
+
if (issuesBefore !== undefined) {
|
|
26288
|
+
return statusChangeCommand(context, before, options, issuesBefore, closingNote);
|
|
26289
|
+
}
|
|
26038
26290
|
const existingLinks = before.external_links ?? [];
|
|
26039
26291
|
const linked = existingLinks.map((link) => link.url);
|
|
26040
26292
|
const newLinks = requestedLinks?.filter((url) => !linked.includes(url)) ?? [];
|
|
@@ -26073,9 +26325,7 @@ async function issueUpdateCommand(context) {
|
|
|
26073
26325
|
}
|
|
26074
26326
|
throw refusalWithCode(error, taken);
|
|
26075
26327
|
}
|
|
26076
|
-
const
|
|
26077
|
-
const fix = error instanceof DispatchGatewayError && error.transient ? "" : "fix what refused the close, then ";
|
|
26078
|
-
const landed = writeMayHaveLanded(error) ? `${posted}, and the close may or may not have taken effect. Read the issue's status before retrying: done means it closed; otherwise retry with a reason that points at message ${closingNote.id}, since retrying this call posts its reason again` : `${posted} but the issue did not close. Retrying this call posts its reason again, so ${fix}retry with a reason that points at message ${closingNote.id}`;
|
|
26328
|
+
const landed = closeAccount(error, closingNote);
|
|
26079
26329
|
if (error instanceof DispatchServiceError)
|
|
26080
26330
|
throw refusalWithCode(error, taken, landed);
|
|
26081
26331
|
throw withAccount(error, [taken, landed].filter((clause) => clause !== "").join("; "));
|
|
@@ -26197,8 +26447,11 @@ async function relatedCommand(context) {
|
|
|
26197
26447
|
details: { project, suggestions }
|
|
26198
26448
|
};
|
|
26199
26449
|
}
|
|
26450
|
+
function printsJson(tool, args) {
|
|
26451
|
+
return tool === "dispatch_issues" && args["json"] === true;
|
|
26452
|
+
}
|
|
26200
26453
|
async function issuesCommand(context) {
|
|
26201
|
-
const { args, client } = context;
|
|
26454
|
+
const { args, client, input } = context;
|
|
26202
26455
|
const project = stringArg(args, "project");
|
|
26203
26456
|
const status = optionalString(args, "status");
|
|
26204
26457
|
const parent = optionalString(args, "parent");
|
|
@@ -26241,6 +26494,10 @@ async function issuesCommand(context) {
|
|
|
26241
26494
|
updated_at: row.updated_at,
|
|
26242
26495
|
progress: row.progress
|
|
26243
26496
|
}));
|
|
26497
|
+
const listing = { issues: rows, total, offset, limit };
|
|
26498
|
+
if (printsJson(input.tool, args)) {
|
|
26499
|
+
return { text: JSON.stringify(listing), details: listing };
|
|
26500
|
+
}
|
|
26244
26501
|
const agents = await liveAgents(client, rows.some((row) => holdsSession(row.claim)));
|
|
26245
26502
|
const isPartial = offset !== 0 || rows.length !== total;
|
|
26246
26503
|
const showing = !isPartial ? "" : rows.length === 0 ? `showing 0-0 of ${total}` : pageSummaryText(offset, rows.length, total);
|
|
@@ -26253,7 +26510,7 @@ async function issuesCommand(context) {
|
|
|
26253
26510
|
})
|
|
26254
26511
|
].join(`
|
|
26255
26512
|
`),
|
|
26256
|
-
details:
|
|
26513
|
+
details: listing
|
|
26257
26514
|
};
|
|
26258
26515
|
}
|
|
26259
26516
|
function dryRunAsksDispatch(tool, args) {
|