@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/session-hook.js
CHANGED
|
@@ -17522,6 +17522,8 @@ var ASK_OPTIONS_CONTRACT = "Options carry the genuinely different approaches. Ea
|
|
|
17522
17522
|
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.";
|
|
17523
17523
|
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.";
|
|
17524
17524
|
var HUMAN_AGREED_TO_DOCUMENT = "the human has agreed to every point in the document";
|
|
17525
|
+
var DOCUMENT_OWNER_RULE = "Exactly one of issue and project is required; with project, artifact names the document.";
|
|
17526
|
+
var NAMED_DOCUMENT_OWNER_RULE = "Exactly one of issue and project is required; artifact or ref must name the document.";
|
|
17525
17527
|
function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false) {
|
|
17526
17528
|
return {
|
|
17527
17529
|
check: (value) => {
|
|
@@ -17532,15 +17534,21 @@ function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false)
|
|
|
17532
17534
|
const hasRef = typeof input.ref === "string";
|
|
17533
17535
|
return (hasIssue !== hasProject || !hasIssue && !hasProject && hasRef) && (!hasProject || !requireArtifact || hasArtifact) && (!alwaysRequireArtifact || hasArtifact || hasRef);
|
|
17534
17536
|
},
|
|
17535
|
-
message: alwaysRequireArtifact ?
|
|
17537
|
+
message: alwaysRequireArtifact ? NAMED_DOCUMENT_OWNER_RULE : DOCUMENT_OWNER_RULE
|
|
17536
17538
|
};
|
|
17537
17539
|
}
|
|
17538
17540
|
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.";
|
|
17539
|
-
var ARTIFACT_OWNER_AND_SOURCE_RULE = `${ARTIFACT_SOURCE_RULE}
|
|
17541
|
+
var ARTIFACT_OWNER_AND_SOURCE_RULE = `${ARTIFACT_SOURCE_RULE} ${DOCUMENT_OWNER_RULE}`;
|
|
17540
17542
|
function brokenParts(parts) {
|
|
17541
17543
|
const broken = parts.filter(([kept]) => !kept).map(([, message]) => message);
|
|
17542
17544
|
return broken.length === 0 ? undefined : broken.join(" ");
|
|
17543
17545
|
}
|
|
17546
|
+
function withoutOwnerRule(refusal) {
|
|
17547
|
+
const rule = DISPATCH_OWNER_RULES.find((owner) => refusal === owner || refusal.startsWith(`${owner} `));
|
|
17548
|
+
if (rule === undefined)
|
|
17549
|
+
return refusal;
|
|
17550
|
+
return refusal === rule ? undefined : refusal.slice(rule.length + 1);
|
|
17551
|
+
}
|
|
17544
17552
|
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)";
|
|
17545
17553
|
var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
|
|
17546
17554
|
var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
|
|
@@ -17584,18 +17592,13 @@ function pathKeepsBytesOf(name) {
|
|
|
17584
17592
|
var artifactOwner = documentOwnerValidation(false);
|
|
17585
17593
|
function artifactProblem(value) {
|
|
17586
17594
|
const input = value;
|
|
17587
|
-
const
|
|
17595
|
+
const extension = typeof input.path === "string" || typeof input.name !== "string" ? undefined : NAME_EXTENSION.exec(input.name.trim())?.[1];
|
|
17596
|
+
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.`;
|
|
17597
|
+
return brokenParts([
|
|
17588
17598
|
[artifactOwner.check(value), artifactOwner.message],
|
|
17589
|
-
[typeof input.path !== "string" || typeof input.content !== "string", ARTIFACT_SOURCE_RULE]
|
|
17599
|
+
[typeof input.path !== "string" || typeof input.content !== "string", ARTIFACT_SOURCE_RULE],
|
|
17600
|
+
[nameProblem === undefined, nameProblem ?? ""]
|
|
17590
17601
|
]);
|
|
17591
|
-
if (ownerOrSourceProblem !== undefined)
|
|
17592
|
-
return ownerOrSourceProblem;
|
|
17593
|
-
if (typeof input.path === "string" || typeof input.name !== "string")
|
|
17594
|
-
return;
|
|
17595
|
-
const extension = NAME_EXTENSION.exec(input.name.trim())?.[1];
|
|
17596
|
-
if (extension === undefined || MARKDOWN_EXTENSION.test(extension))
|
|
17597
|
-
return;
|
|
17598
|
-
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.`;
|
|
17599
17602
|
}
|
|
17600
17603
|
var documentEditOwner = documentOwnerValidation(true);
|
|
17601
17604
|
var PRECONDITION_RULE = "A precondition selects exactly one of document or blocks.";
|
|
@@ -17690,34 +17693,100 @@ var ISSUE_UPDATE_FIELDS_RULE = "Issue update requires at least one field besides
|
|
|
17690
17693
|
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";
|
|
17691
17694
|
var ISSUE_UPDATE_REASON_RULE = "reason goes only with status done";
|
|
17692
17695
|
var ISSUE_UPDATE_LABELS_RULE = "labels_add goes without labels";
|
|
17693
|
-
var
|
|
17694
|
-
|
|
17695
|
-
|
|
17696
|
+
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.`;
|
|
17697
|
+
var ISSUE_STATUS_OPTIONS = [
|
|
17698
|
+
"include_children",
|
|
17699
|
+
"unlink_children",
|
|
17700
|
+
"include_parent"
|
|
17701
|
+
];
|
|
17702
|
+
function issueStatusOptionsOf(input) {
|
|
17703
|
+
return ISSUE_STATUS_OPTIONS.filter((option) => input[option] === true);
|
|
17704
|
+
}
|
|
17705
|
+
var ISSUE_UPDATE_PATCH_FIELDS = [
|
|
17706
|
+
"title",
|
|
17707
|
+
"labels",
|
|
17708
|
+
"labels_add",
|
|
17709
|
+
"priority",
|
|
17710
|
+
"assignee",
|
|
17711
|
+
"external_links",
|
|
17712
|
+
"route",
|
|
17713
|
+
"parent",
|
|
17714
|
+
"blocked_by",
|
|
17715
|
+
"advances",
|
|
17716
|
+
"advances_revision",
|
|
17717
|
+
"components",
|
|
17718
|
+
"repo",
|
|
17719
|
+
"before",
|
|
17720
|
+
"after"
|
|
17721
|
+
];
|
|
17722
|
+
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.";
|
|
17723
|
+
var ISSUE_UPDATE_RULE = `${ISSUE_UPDATE_FIELDS_RULE} ${ISSUE_UPDATE_DONE_RULE}; ${ISSUE_UPDATE_REASON_RULE}; ${ISSUE_UPDATE_LABELS_RULE}. ${ISSUE_UPDATE_OPTIONS_RULE}`;
|
|
17724
|
+
function issueStatusOptionsProblem(input) {
|
|
17725
|
+
const options = issueStatusOptionsOf(input);
|
|
17726
|
+
if (options.length === 0)
|
|
17727
|
+
return;
|
|
17728
|
+
const named = options.join(", ").replace(/, ([^,]*)$/, " and $1");
|
|
17729
|
+
const others = ISSUE_UPDATE_PATCH_FIELDS.filter((field) => input[field] !== undefined);
|
|
17730
|
+
return brokenParts([
|
|
17731
|
+
[
|
|
17732
|
+
!(input["include_children"] === true && input["unlink_children"] === true),
|
|
17733
|
+
"include_children does not go with unlink_children. The open children move with the issue or leave it, so name one of the two."
|
|
17734
|
+
],
|
|
17735
|
+
[
|
|
17736
|
+
!(input["include_children"] === true && input["status"] === "done"),
|
|
17737
|
+
"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."
|
|
17738
|
+
],
|
|
17739
|
+
[
|
|
17740
|
+
typeof input["status"] === "string",
|
|
17741
|
+
`status is required with ${named}. Add status, or drop ${named}.`
|
|
17742
|
+
],
|
|
17743
|
+
[
|
|
17744
|
+
others.length === 0,
|
|
17745
|
+
`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.`
|
|
17746
|
+
]
|
|
17747
|
+
]);
|
|
17748
|
+
}
|
|
17749
|
+
function issueReasonProblem(input) {
|
|
17696
17750
|
if (input.status === "done") {
|
|
17697
|
-
|
|
17698
|
-
return `${ISSUE_UPDATE_DONE_RULE}.`;
|
|
17699
|
-
}
|
|
17700
|
-
} else if (input.reason !== undefined) {
|
|
17701
|
-
const status = typeof input.status === "string" ? `status ${input.status}` : "an update without status done";
|
|
17702
|
-
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.`;
|
|
17703
|
-
}
|
|
17704
|
-
if (input.labels !== undefined && input.labels_add !== undefined) {
|
|
17705
|
-
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.`;
|
|
17751
|
+
return typeof input.reason !== "string" || input.reason.trim() === "" ? `${ISSUE_UPDATE_DONE_RULE}.` : undefined;
|
|
17706
17752
|
}
|
|
17753
|
+
if (input.reason === undefined)
|
|
17754
|
+
return;
|
|
17755
|
+
const status = typeof input.status === "string" ? `status ${input.status}` : "an update without status done";
|
|
17756
|
+
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.`;
|
|
17757
|
+
}
|
|
17758
|
+
function issueUpdateProblem(value) {
|
|
17759
|
+
const input = value;
|
|
17760
|
+
const reasonProblem = issueReasonProblem(input);
|
|
17761
|
+
const optionsProblem = issueStatusOptionsProblem(value);
|
|
17762
|
+
const broken = brokenParts([
|
|
17763
|
+
[reasonProblem === undefined, reasonProblem ?? ""],
|
|
17764
|
+
[input.labels === undefined || input.labels_add === undefined, ISSUE_UPDATE_LABELS_REFUSAL],
|
|
17765
|
+
[optionsProblem === undefined, optionsProblem ?? ""]
|
|
17766
|
+
]);
|
|
17767
|
+
if (broken !== undefined)
|
|
17768
|
+
return broken;
|
|
17707
17769
|
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";
|
|
17708
17770
|
return changesAField ? undefined : ISSUE_UPDATE_FIELDS_RULE;
|
|
17709
17771
|
}
|
|
17772
|
+
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.";
|
|
17710
17773
|
var messageValidation = {
|
|
17711
17774
|
check: (value) => {
|
|
17712
17775
|
const input = value;
|
|
17713
17776
|
return typeof input.issue === "string" || typeof input.in_reply_to === "string";
|
|
17714
17777
|
},
|
|
17715
|
-
message:
|
|
17778
|
+
message: MESSAGE_OWNER_RULE
|
|
17716
17779
|
};
|
|
17717
17780
|
var readOwner = documentOwnerValidation(false);
|
|
17718
17781
|
var READ_OWNER_RULE = "Exactly one of issue and project is required; project alone lists its documents, and with artifact names one.";
|
|
17719
17782
|
var READ_MESSAGE_RULE = "message stands alone: it names the conversation, so name no issue, project, artifact, or ref with it.";
|
|
17720
17783
|
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.";
|
|
17784
|
+
var DISPATCH_OWNER_RULES = [
|
|
17785
|
+
DOCUMENT_OWNER_RULE,
|
|
17786
|
+
NAMED_DOCUMENT_OWNER_RULE,
|
|
17787
|
+
READ_OWNER_RULE,
|
|
17788
|
+
MESSAGE_OWNER_RULE
|
|
17789
|
+
];
|
|
17721
17790
|
function readProblem(value) {
|
|
17722
17791
|
const input = value;
|
|
17723
17792
|
const historyKept = input.history !== true || typeof input.ref === "string";
|
|
@@ -17908,11 +17977,14 @@ var dispatchToolSpecs = [
|
|
|
17908
17977
|
priority: 1,
|
|
17909
17978
|
before: "DSP-2"
|
|
17910
17979
|
},
|
|
17911
|
-
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}`,
|
|
17980
|
+
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}`,
|
|
17912
17981
|
arguments: (z) => ({
|
|
17913
17982
|
issue: z.string().describe(ISSUE_REFERENCE),
|
|
17914
17983
|
status: z.enum(ISSUE_STATUSES).describe("New lifecycle status.").optional(),
|
|
17915
17984
|
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(),
|
|
17985
|
+
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(),
|
|
17986
|
+
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(),
|
|
17987
|
+
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(),
|
|
17916
17988
|
title: z.string({ min: 1, max: ISSUE_TITLE_MAX }).describe("Replacement title, at most 1,000 characters.").optional(),
|
|
17917
17989
|
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(),
|
|
17918
17990
|
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(),
|
|
@@ -18366,7 +18438,7 @@ var dispatchToolSpecs = [
|
|
|
18366
18438
|
{
|
|
18367
18439
|
name: "dispatch_issues",
|
|
18368
18440
|
example: { project: "PROJ", limit: 250, offset: 250 },
|
|
18369
|
-
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.",
|
|
18441
|
+
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.",
|
|
18370
18442
|
arguments: (z) => ({
|
|
18371
18443
|
project: z.string().describe("Project key to list issues from."),
|
|
18372
18444
|
status: z.enum(ISSUE_STATUSES).describe("Optional lifecycle status filter.").optional(),
|
|
@@ -18377,7 +18449,8 @@ var dispatchToolSpecs = [
|
|
|
18377
18449
|
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(),
|
|
18378
18450
|
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(),
|
|
18379
18451
|
offset: z.number({ int: true, min: 0 }).describe("Rows to skip before the page; nonnegative integer; default 0.").optional(),
|
|
18380
|
-
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()
|
|
18452
|
+
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(),
|
|
18453
|
+
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()
|
|
18381
18454
|
})
|
|
18382
18455
|
},
|
|
18383
18456
|
{
|
|
@@ -23958,18 +24031,22 @@ var DISPATCH_URL_SETTING = "the configured Dispatch URL";
|
|
|
23958
24031
|
class DispatchServiceError extends Error {
|
|
23959
24032
|
code;
|
|
23960
24033
|
status;
|
|
24034
|
+
name = "DispatchServiceError";
|
|
24035
|
+
fromDispatch = true;
|
|
23961
24036
|
candidates;
|
|
23962
24037
|
current;
|
|
23963
24038
|
mismatches;
|
|
23964
|
-
|
|
23965
|
-
|
|
23966
|
-
constructor(code, status, message,
|
|
24039
|
+
issues;
|
|
24040
|
+
changed;
|
|
24041
|
+
constructor(code, status, message, details = {}) {
|
|
23967
24042
|
super(message);
|
|
23968
24043
|
this.code = code;
|
|
23969
24044
|
this.status = status;
|
|
23970
|
-
this.candidates = candidates;
|
|
23971
|
-
this.current = current;
|
|
23972
|
-
this.mismatches = mismatches;
|
|
24045
|
+
this.candidates = details.candidates;
|
|
24046
|
+
this.current = details.current;
|
|
24047
|
+
this.mismatches = details.mismatches;
|
|
24048
|
+
this.issues = details.issues;
|
|
24049
|
+
this.changed = details.changed;
|
|
23973
24050
|
}
|
|
23974
24051
|
}
|
|
23975
24052
|
|
|
@@ -24070,6 +24147,9 @@ function reviewNoRouteRefusal(baseUrl, route, version) {
|
|
|
24070
24147
|
function resultDryRunNoRouteRefusal(baseUrl, route) {
|
|
24071
24148
|
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.");
|
|
24072
24149
|
}
|
|
24150
|
+
function statusChangeNoRouteRefusal(baseUrl, route) {
|
|
24151
|
+
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.");
|
|
24152
|
+
}
|
|
24073
24153
|
var ISSUE_EVENTS_PAGE_MAX = 200;
|
|
24074
24154
|
var DISPATCH_TOOL_DEADLINE_MS = 60000;
|
|
24075
24155
|
function requestSignal(signal, deadlineMs) {
|
|
@@ -24388,6 +24468,14 @@ class DispatchClient {
|
|
|
24388
24468
|
async updateIssue(issue, input) {
|
|
24389
24469
|
return this.#json("PATCH", ["api", "v1", "issues", await this.#resolveIssue(issue)], input);
|
|
24390
24470
|
}
|
|
24471
|
+
async changeIssueStatus(issue, input) {
|
|
24472
|
+
const path = ["api", "v1", "issues", await this.#resolveIssue(issue), "status-change"];
|
|
24473
|
+
try {
|
|
24474
|
+
return await this.#json("POST", path, input);
|
|
24475
|
+
} catch (error) {
|
|
24476
|
+
throw this.#refusalOfNoRoute(error, path, (route) => statusChangeNoRouteRefusal(this.#baseUrl, route));
|
|
24477
|
+
}
|
|
24478
|
+
}
|
|
24391
24479
|
async claimIssue(issue, input = {}) {
|
|
24392
24480
|
return this.#json("POST", ["api", "v1", "issues", await this.#resolveIssue(issue), "claim"], input);
|
|
24393
24481
|
}
|
|
@@ -24542,10 +24630,7 @@ class DispatchClient {
|
|
|
24542
24630
|
try {
|
|
24543
24631
|
return await this.#json("POST", path, body);
|
|
24544
24632
|
} catch (error) {
|
|
24545
|
-
|
|
24546
|
-
throw error;
|
|
24547
|
-
const route = `POST /${path.map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
24548
|
-
throw reviewNoRouteRefusal(this.#baseUrl, route, version);
|
|
24633
|
+
throw this.#refusalOfNoRoute(error, path, (route) => reviewNoRouteRefusal(this.#baseUrl, route, version));
|
|
24549
24634
|
}
|
|
24550
24635
|
}
|
|
24551
24636
|
async recordResult(issue, input) {
|
|
@@ -24556,10 +24641,7 @@ class DispatchClient {
|
|
|
24556
24641
|
try {
|
|
24557
24642
|
return await this.#writingNothing(path, input, { writes: false });
|
|
24558
24643
|
} catch (error) {
|
|
24559
|
-
|
|
24560
|
-
throw error;
|
|
24561
|
-
const route = `POST /${path.map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
24562
|
-
throw resultDryRunNoRouteRefusal(this.#baseUrl, route);
|
|
24644
|
+
throw this.#refusalOfNoRoute(error, path, (route) => resultDryRunNoRouteRefusal(this.#baseUrl, route));
|
|
24563
24645
|
}
|
|
24564
24646
|
}
|
|
24565
24647
|
async issueResults(issue, at) {
|
|
@@ -24804,6 +24886,11 @@ class DispatchClient {
|
|
|
24804
24886
|
sleep: this.#sleep
|
|
24805
24887
|
});
|
|
24806
24888
|
}
|
|
24889
|
+
#refusalOfNoRoute(error, path, refuse) {
|
|
24890
|
+
if (!(error instanceof DispatchNoRouteError) && !isNoRoute(error))
|
|
24891
|
+
return error;
|
|
24892
|
+
return refuse(`POST /${path.map((segment) => encodeURIComponent(segment)).join("/")}`);
|
|
24893
|
+
}
|
|
24807
24894
|
#writeCall(method, url, key, writes = true) {
|
|
24808
24895
|
if (method !== "POST" && method !== "PATCH")
|
|
24809
24896
|
return;
|
|
@@ -25137,7 +25224,7 @@ class DispatchClient {
|
|
|
25137
25224
|
if (response.status === 409 && error.code === IDEMPOTENCY_KEY_COMMITTED) {
|
|
25138
25225
|
throw new DispatchWriteLandedError(IDEMPOTENCY_KEY_COMMITTED, response.status, method, requestForText(this.#baseUrl, url, DISPATCH_URL_SETTING));
|
|
25139
25226
|
}
|
|
25140
|
-
throw new DispatchServiceError(error.code ?? `HTTP_${response.status}`, response.status, error.error, error
|
|
25227
|
+
throw new DispatchServiceError(error.code ?? `HTTP_${response.status}`, response.status, error.error, error);
|
|
25141
25228
|
}
|
|
25142
25229
|
throw this.#gatewayError(method, url, response, text, "Dispatch's error JSON");
|
|
25143
25230
|
}
|
|
@@ -26933,6 +27020,7 @@ var pictureSendingTools = {
|
|
|
26933
27020
|
};
|
|
26934
27021
|
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";
|
|
26935
27022
|
var ownerRequiredProblem = "issue is required; supply issue or set LEGION_ISSUE";
|
|
27023
|
+
var ownerStandInIssue = "OWNER-1";
|
|
26936
27024
|
function argumentProblems(tool, args) {
|
|
26937
27025
|
const problems = [];
|
|
26938
27026
|
switch (tool) {
|
|
@@ -27218,7 +27306,7 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
27218
27306
|
const legionIssue = env.LEGION_ISSUE;
|
|
27219
27307
|
if (!legionIssue) {
|
|
27220
27308
|
problems.push(ownerRequiredProblem);
|
|
27221
|
-
return { args, ref, owner: null };
|
|
27309
|
+
return { args, ref, owner: null, ownerMissing: true };
|
|
27222
27310
|
}
|
|
27223
27311
|
if (nativeIssueKeyPattern.test(legionIssue) || externalIssueRefPattern.test(legionIssue)) {
|
|
27224
27312
|
const issue = canonicalExternalIssueRef(legionIssue);
|
|
@@ -27226,18 +27314,24 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
27226
27314
|
}
|
|
27227
27315
|
if (!bareIssueNumberPattern.test(legionIssue)) {
|
|
27228
27316
|
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");
|
|
27229
|
-
return { args, ref, owner: null };
|
|
27317
|
+
return { args, ref, owner: null, ownerMissing: true };
|
|
27230
27318
|
}
|
|
27231
27319
|
const repo = await resolveCwdRepo(cwd, exec);
|
|
27232
27320
|
if (!repo) {
|
|
27233
27321
|
problems.push("issue is required; LEGION_ISSUE needs a GitHub repository in cwd");
|
|
27234
|
-
return { args, ref, owner: null };
|
|
27322
|
+
return { args, ref, owner: null, ownerMissing: true };
|
|
27235
27323
|
}
|
|
27236
27324
|
const issue = `${repo}#${legionIssue}`;
|
|
27237
27325
|
return { args: { ...args, issue }, ref, owner: { kind: "issue", issue } };
|
|
27238
27326
|
}
|
|
27239
|
-
function
|
|
27240
|
-
|
|
27327
|
+
function withoutMissingOwner(issue) {
|
|
27328
|
+
if (issue.code === "invalid_type" && issue.path.length === 1 && issue.path[0] === "issue" && issue.input === undefined) {
|
|
27329
|
+
return;
|
|
27330
|
+
}
|
|
27331
|
+
if (issue.code !== "custom" || issue.path.length !== 0)
|
|
27332
|
+
return issue;
|
|
27333
|
+
const message = withoutOwnerRule(issue.message);
|
|
27334
|
+
return message === undefined ? undefined : message === issue.message ? issue : { ...issue, message };
|
|
27241
27335
|
}
|
|
27242
27336
|
function dispatchServerUrls(config) {
|
|
27243
27337
|
return config.publicUrl === undefined ? [config.url] : [config.url, config.publicUrl];
|
|
@@ -27248,11 +27342,12 @@ async function checkDispatchCall(input) {
|
|
|
27248
27342
|
const owner = await resolveOwnerArguments(tool, args, cwd, input.env ?? process.env, input.exec ?? defaultExec, input.serverUrls, problems);
|
|
27249
27343
|
const conflicts = issueFreeTools[tool] === true ? [] : ownerConflictProblems(tool, args, owner.ref, optionalString(owner.args, "ref"));
|
|
27250
27344
|
problems.push(...conflicts);
|
|
27251
|
-
const
|
|
27345
|
+
const ownerAlreadySaid = issueFreeTools[tool] !== true && (owner.owner === null || conflicts.length > 0);
|
|
27252
27346
|
const schema = toolSchema(tool);
|
|
27253
|
-
const
|
|
27347
|
+
const standIn = owner.ownerMissing === true;
|
|
27348
|
+
const parsed = schema.safeParse(standIn ? { ...owner.args, issue: ownerStandInIssue } : owner.args, { reportInput: true });
|
|
27254
27349
|
if (!parsed.success) {
|
|
27255
|
-
const issues =
|
|
27350
|
+
const issues = standIn ? parsed.error.issues : ownerAlreadySaid ? parsed.error.issues.flatMap((issue) => withoutMissingOwner(issue) ?? []) : parsed.error.issues;
|
|
27256
27351
|
problems.push(...formatZodIssues(issues, schema, tool));
|
|
27257
27352
|
}
|
|
27258
27353
|
problems.push(...argumentProblems(tool, owner.args));
|
|
@@ -27260,7 +27355,7 @@ async function checkDispatchCall(input) {
|
|
|
27260
27355
|
return {
|
|
27261
27356
|
problems,
|
|
27262
27357
|
owner,
|
|
27263
|
-
args: parsed.success ? parsed.data : owner.args,
|
|
27358
|
+
args: parsed.success && !standIn ? parsed.data : owner.args,
|
|
27264
27359
|
pictures
|
|
27265
27360
|
};
|
|
27266
27361
|
}
|
|
@@ -27278,7 +27373,75 @@ function refusalWithCode(error, ...clauses) {
|
|
|
27278
27373
|
}
|
|
27279
27374
|
if (!(error instanceof DispatchServiceError))
|
|
27280
27375
|
return error;
|
|
27281
|
-
|
|
27376
|
+
const told = joined !== "" && /[.!?]$/.test(error.message) ? `${error.message} ${suffix.charAt(0).toUpperCase()}${suffix.slice(1)}` : `${error.message}${joined}`;
|
|
27377
|
+
return new DispatchServiceError(error.code, error.status, `${error.code}: ${told}`, error);
|
|
27378
|
+
}
|
|
27379
|
+
function parentStatusConflictLines(error, tool, args, legionIssue) {
|
|
27380
|
+
if (!dispatchAnswered(error, 409) || error.code !== "PARENT_STATUS_CONFLICT")
|
|
27381
|
+
return;
|
|
27382
|
+
const issues = error.issues ?? [];
|
|
27383
|
+
if (issues.length === 0)
|
|
27384
|
+
return;
|
|
27385
|
+
const parents = issues.filter((issue) => issue.relation === "parent").map(({ key }) => key);
|
|
27386
|
+
const children = issues.filter((issue) => issue.relation === "child").map(({ key }) => key);
|
|
27387
|
+
return [
|
|
27388
|
+
messageFor(error),
|
|
27389
|
+
...issues.map((issue) => `${issue.key} [${issue.status}] ${issue.title}`),
|
|
27390
|
+
...nextSteps(tool, args, parents, children, legionIssue)
|
|
27391
|
+
];
|
|
27392
|
+
}
|
|
27393
|
+
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.";
|
|
27394
|
+
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.";
|
|
27395
|
+
function otherProjectSentence(named, keys) {
|
|
27396
|
+
const project = named === undefined ? undefined : issueProject(named);
|
|
27397
|
+
if (project === undefined)
|
|
27398
|
+
return "";
|
|
27399
|
+
const others = keys.filter((key) => {
|
|
27400
|
+
const other = issueProject(key);
|
|
27401
|
+
return other !== undefined && other !== project;
|
|
27402
|
+
});
|
|
27403
|
+
if (others.length === 0)
|
|
27404
|
+
return "";
|
|
27405
|
+
const one = others.length === 1;
|
|
27406
|
+
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.`;
|
|
27407
|
+
}
|
|
27408
|
+
function includeParentCall(key) {
|
|
27409
|
+
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`;
|
|
27410
|
+
}
|
|
27411
|
+
function nextSteps(tool, args, parents, children, legionIssue) {
|
|
27412
|
+
if (tool === "dispatch_issue") {
|
|
27413
|
+
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.`);
|
|
27414
|
+
}
|
|
27415
|
+
const issueUpdate = tool === "dispatch_issue_update";
|
|
27416
|
+
const written = issueUpdate ? args : {};
|
|
27417
|
+
const fields = Object.keys(written).filter((field) => field !== "issue" && written[field] !== undefined);
|
|
27418
|
+
const issue = optionalString(written, "issue");
|
|
27419
|
+
const named = issueUpdate ? issue ?? legionIssue : undefined;
|
|
27420
|
+
const childHolds = children.length > 0;
|
|
27421
|
+
const childScope = otherProjectSentence(named, children);
|
|
27422
|
+
const status = optionalString(written, "status");
|
|
27423
|
+
const parent = optionalString(written, "parent");
|
|
27424
|
+
const alone = `--status${status === "done" ? " and --reason" : ""} alone`;
|
|
27425
|
+
if (parent !== undefined && parent !== "") {
|
|
27426
|
+
const issueFlag = issue === undefined ? "" : ` --issue ${issue}`;
|
|
27427
|
+
const statusFlag = status === undefined || childHolds ? "" : ` --status ${status}`;
|
|
27428
|
+
const kept = fields.filter((field) => field !== "parent" && field !== "status" && !(childHolds && field === "reason"));
|
|
27429
|
+
const otherFlags = kept.length > 0 ? ", with the call's other flags" : "";
|
|
27430
|
+
const reparent = `dispatch issue-update${issueFlag} --parent ${parent}${statusFlag}${otherFlags}`;
|
|
27431
|
+
const afterStatus = childHolds ? ", after the status change," : "";
|
|
27432
|
+
return [
|
|
27433
|
+
...childHolds ? [
|
|
27434
|
+
`${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}`
|
|
27435
|
+
] : [],
|
|
27436
|
+
...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}.`)
|
|
27437
|
+
];
|
|
27438
|
+
}
|
|
27439
|
+
const others = ISSUE_UPDATE_PATCH_FIELDS.some((field) => written[field] !== undefined);
|
|
27440
|
+
const apart = (subject) => others ? ` ${subject} with ${alone}, so send the call's other changes in a call of their own.` : "";
|
|
27441
|
+
return [
|
|
27442
|
+
...childHolds ? [`${CHILD_FLAGS}${apart("Each goes")}${childScope}`] : [],
|
|
27443
|
+
...parents.length > 0 ? [`${PARENT_FLAG}${apart("It goes")}${otherProjectSentence(named, parents)}`] : []
|
|
27444
|
+
];
|
|
27282
27445
|
}
|
|
27283
27446
|
function dispatchAnswered(error, status) {
|
|
27284
27447
|
return error instanceof DispatchServiceError && error.fromDispatch && error.status === status;
|
|
@@ -27303,6 +27466,11 @@ function writeMayHaveLanded(error) {
|
|
|
27303
27466
|
return error.mayHaveReachedDispatch;
|
|
27304
27467
|
return !(error instanceof DispatchServiceError) || error.status >= 500;
|
|
27305
27468
|
}
|
|
27469
|
+
function closeAccount(error, closingNote) {
|
|
27470
|
+
const posted = `the reason already landed as message ${closingNote.id} (${closingNote.ref})`;
|
|
27471
|
+
const fix = error instanceof DispatchGatewayError && error.transient ? "" : "fix what refused the close, then ";
|
|
27472
|
+
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}`;
|
|
27473
|
+
}
|
|
27306
27474
|
function withAccount(error, account) {
|
|
27307
27475
|
const message = messageFor(error);
|
|
27308
27476
|
const told = /[.!?]$/.test(message) ? `${message} ${account.charAt(0).toUpperCase()}${account.slice(1)}` : `${message}; ${account}`;
|
|
@@ -28656,6 +28824,85 @@ async function followedAskDetails(client, ask, artifact) {
|
|
|
28656
28824
|
return { ...await askOwnerDetails(client, ask, artifact), follows: { ask: ask.id } };
|
|
28657
28825
|
}
|
|
28658
28826
|
|
|
28827
|
+
// ../envoy-client/src/dispatch-commands/status-change.ts
|
|
28828
|
+
async function issuesBeforeStatusChange(client, before, options) {
|
|
28829
|
+
const issues = new Map([
|
|
28830
|
+
[before.key, { status: before.status, parent: before.parent ?? null }]
|
|
28831
|
+
]);
|
|
28832
|
+
for (const child of before.children ?? []) {
|
|
28833
|
+
issues.set(child.key, { status: child.status, parent: before.key });
|
|
28834
|
+
}
|
|
28835
|
+
try {
|
|
28836
|
+
if (options.includes("include_children")) {
|
|
28837
|
+
for (const row of await client.listAllIssues({ project: before.project })) {
|
|
28838
|
+
issues.set(row.key, { status: row.status, parent: row.parent ?? null });
|
|
28839
|
+
}
|
|
28840
|
+
} else if (options.includes("include_parent")) {
|
|
28841
|
+
let parent = before.parent ?? null;
|
|
28842
|
+
while (parent !== null && !issues.has(parent)) {
|
|
28843
|
+
const above = await client.getIssue(parent);
|
|
28844
|
+
issues.set(above.key, { status: above.status, parent: above.parent ?? null });
|
|
28845
|
+
parent = above.parent ?? null;
|
|
28846
|
+
}
|
|
28847
|
+
}
|
|
28848
|
+
} catch (error) {
|
|
28849
|
+
throw refusalWithCode(error);
|
|
28850
|
+
}
|
|
28851
|
+
return issues;
|
|
28852
|
+
}
|
|
28853
|
+
async function statusChangeCommand(context, before, options, issuesBefore, closingNote) {
|
|
28854
|
+
const { args, client, actor, input, issue } = context;
|
|
28855
|
+
const status = stringArg(args, "status");
|
|
28856
|
+
const change = (entry) => {
|
|
28857
|
+
const was = issuesBefore.get(entry.key);
|
|
28858
|
+
if (entry.key !== before.key && entry.parent === null && was?.parent === before.key) {
|
|
28859
|
+
return `unlinked from ${before.key}`;
|
|
28860
|
+
}
|
|
28861
|
+
return was === undefined ? `status -> ${entry.status}` : `status ${was.status} -> ${entry.status}`;
|
|
28862
|
+
};
|
|
28863
|
+
let answer;
|
|
28864
|
+
try {
|
|
28865
|
+
answer = await client.changeIssueStatus(issue(), {
|
|
28866
|
+
status,
|
|
28867
|
+
...options.includes("include_children") ? { include_children: true } : {},
|
|
28868
|
+
...options.includes("unlink_children") ? { unlink_children: true } : {},
|
|
28869
|
+
...options.includes("include_parent") ? { include_parent: true } : {},
|
|
28870
|
+
actor
|
|
28871
|
+
});
|
|
28872
|
+
} catch (error) {
|
|
28873
|
+
if (error instanceof DispatchWriteLandedError)
|
|
28874
|
+
throw error;
|
|
28875
|
+
const committed = error instanceof DispatchServiceError ? error.changed ?? [] : [];
|
|
28876
|
+
const changed = committed.length === 0 ? "" : `the steps before the refusal changed ${committed.map((entry) => `${entry.key} (${change(entry)})`).join(", ")}`;
|
|
28877
|
+
if (closingNote === undefined)
|
|
28878
|
+
throw refusalWithCode(error, changed);
|
|
28879
|
+
const landed = closeAccount(error, closingNote);
|
|
28880
|
+
if (error instanceof DispatchServiceError)
|
|
28881
|
+
throw refusalWithCode(error, changed, landed);
|
|
28882
|
+
throw withAccount(error, landed);
|
|
28883
|
+
}
|
|
28884
|
+
const suffix = await notSubscribed(issueTopic(before.key), input.subscriptions);
|
|
28885
|
+
const namedLine = (after) => `${before.key}: ${[
|
|
28886
|
+
...closingNote === undefined ? [] : [`reason posted as message ${closingNote.id} (${closingNote.ref})`],
|
|
28887
|
+
`status ${before.status} -> ${after}`
|
|
28888
|
+
].join("; ")}${suffix}`;
|
|
28889
|
+
const changed = answer.changed ?? [];
|
|
28890
|
+
const lines = changed.map((entry) => entry.key === before.key ? namedLine(entry.status) : `${entry.key}: ${change(entry)}`);
|
|
28891
|
+
if (!changed.some((entry) => entry.key === before.key))
|
|
28892
|
+
lines.push(namedLine(answer.issue.status));
|
|
28893
|
+
return {
|
|
28894
|
+
text: lines.join(`
|
|
28895
|
+
`),
|
|
28896
|
+
details: {
|
|
28897
|
+
issue: before.key,
|
|
28898
|
+
status: answer.issue.status,
|
|
28899
|
+
external_links: (answer.issue.external_links ?? []).map((link) => link.url),
|
|
28900
|
+
changed: changed.map(({ key, status, parent }) => ({ key, status, parent })),
|
|
28901
|
+
...closingNote === undefined ? {} : { message: closingNote.id }
|
|
28902
|
+
}
|
|
28903
|
+
};
|
|
28904
|
+
}
|
|
28905
|
+
|
|
28659
28906
|
// ../envoy-client/src/dispatch-commands/issues.ts
|
|
28660
28907
|
function componentsChange(input, after) {
|
|
28661
28908
|
switch (input.mode) {
|
|
@@ -28807,6 +29054,7 @@ async function issueUpdateCommand(context) {
|
|
|
28807
29054
|
const advances = optionalStringArray(args, "advances");
|
|
28808
29055
|
const advancesRevision = optionalNumber(args, "advances_revision");
|
|
28809
29056
|
const requestedLinks = Array.isArray(args.external_links) ? [...new Set(args.external_links)] : undefined;
|
|
29057
|
+
const options = issueStatusOptionsOf(args);
|
|
28810
29058
|
let before;
|
|
28811
29059
|
try {
|
|
28812
29060
|
before = await client.getIssue(issueKey);
|
|
@@ -28817,6 +29065,7 @@ async function issueUpdateCommand(context) {
|
|
|
28817
29065
|
if (status === "done" && typeof before.closed_at === "string") {
|
|
28818
29066
|
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`);
|
|
28819
29067
|
}
|
|
29068
|
+
const issuesBefore = options.length === 0 ? undefined : await issuesBeforeStatusChange(client, before, options);
|
|
28820
29069
|
let closingNote;
|
|
28821
29070
|
if (reason !== undefined) {
|
|
28822
29071
|
try {
|
|
@@ -28835,6 +29084,9 @@ async function issueUpdateCommand(context) {
|
|
|
28835
29084
|
throw withAccount(error, told);
|
|
28836
29085
|
}
|
|
28837
29086
|
}
|
|
29087
|
+
if (issuesBefore !== undefined) {
|
|
29088
|
+
return statusChangeCommand(context, before, options, issuesBefore, closingNote);
|
|
29089
|
+
}
|
|
28838
29090
|
const existingLinks = before.external_links ?? [];
|
|
28839
29091
|
const linked = existingLinks.map((link) => link.url);
|
|
28840
29092
|
const newLinks = requestedLinks?.filter((url) => !linked.includes(url)) ?? [];
|
|
@@ -28873,9 +29125,7 @@ async function issueUpdateCommand(context) {
|
|
|
28873
29125
|
}
|
|
28874
29126
|
throw refusalWithCode(error, taken);
|
|
28875
29127
|
}
|
|
28876
|
-
const
|
|
28877
|
-
const fix = error instanceof DispatchGatewayError && error.transient ? "" : "fix what refused the close, then ";
|
|
28878
|
-
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}`;
|
|
29128
|
+
const landed = closeAccount(error, closingNote);
|
|
28879
29129
|
if (error instanceof DispatchServiceError)
|
|
28880
29130
|
throw refusalWithCode(error, taken, landed);
|
|
28881
29131
|
throw withAccount(error, [taken, landed].filter((clause) => clause !== "").join("; "));
|
|
@@ -28997,8 +29247,11 @@ async function relatedCommand(context) {
|
|
|
28997
29247
|
details: { project, suggestions }
|
|
28998
29248
|
};
|
|
28999
29249
|
}
|
|
29250
|
+
function printsJson(tool, args) {
|
|
29251
|
+
return tool === "dispatch_issues" && args["json"] === true;
|
|
29252
|
+
}
|
|
29000
29253
|
async function issuesCommand(context) {
|
|
29001
|
-
const { args, client } = context;
|
|
29254
|
+
const { args, client, input } = context;
|
|
29002
29255
|
const project = stringArg(args, "project");
|
|
29003
29256
|
const status = optionalString(args, "status");
|
|
29004
29257
|
const parent = optionalString(args, "parent");
|
|
@@ -29041,6 +29294,10 @@ async function issuesCommand(context) {
|
|
|
29041
29294
|
updated_at: row.updated_at,
|
|
29042
29295
|
progress: row.progress
|
|
29043
29296
|
}));
|
|
29297
|
+
const listing = { issues: rows, total, offset, limit };
|
|
29298
|
+
if (printsJson(input.tool, args)) {
|
|
29299
|
+
return { text: JSON.stringify(listing), details: listing };
|
|
29300
|
+
}
|
|
29044
29301
|
const agents = await liveAgents(client, rows.some((row) => holdsSession(row.claim)));
|
|
29045
29302
|
const isPartial = offset !== 0 || rows.length !== total;
|
|
29046
29303
|
const showing = !isPartial ? "" : rows.length === 0 ? `showing 0-0 of ${total}` : pageSummaryText(offset, rows.length, total);
|
|
@@ -29053,7 +29310,7 @@ async function issuesCommand(context) {
|
|
|
29053
29310
|
})
|
|
29054
29311
|
].join(`
|
|
29055
29312
|
`),
|
|
29056
|
-
details:
|
|
29313
|
+
details: listing
|
|
29057
29314
|
};
|
|
29058
29315
|
}
|
|
29059
29316
|
function dryRunAsksDispatch(tool, args) {
|