@sjawhar/claude-envoy 6.11.1 → 6.12.1

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.
Files changed (30) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.omp-plugin/plugin.json +1 -1
  3. package/dist/codex-hook.js +201 -21
  4. package/dist/dispatch.js +201 -21
  5. package/dist/envoy-channel.js +203 -23
  6. package/dist/session-hook.js +201 -21
  7. package/legion/skills/legion-architect/SKILL.md +2 -2
  8. package/legion/skills/legion-architect/references/acceptance.md +1 -1
  9. package/legion/skills/legion-architect/references/decomposition.md +2 -2
  10. package/legion/skills/legion-architect/references/operations.md +1 -1
  11. package/legion/skills/legion-controller/SKILL.md +5 -5
  12. package/legion/skills/legion-controller/references/backlog-stewardship.md +3 -3
  13. package/legion/skills/legion-controller/references/consolidation.md +1 -1
  14. package/legion/skills/legion-controller/references/daily-report.md +6 -17
  15. package/legion/skills/legion-controller/references/escalation.md +1 -1
  16. package/legion/skills/legion-controller/references/finding-asks-steps.md +4 -4
  17. package/legion/skills/legion-controller/references/finding-asks.md +16 -15
  18. package/legion/skills/legion-controller/references/operations-steps.md +2 -2
  19. package/legion/skills/legion-controller/references/operations.md +5 -5
  20. package/legion/skills/legion-controller/references/park-asks.md +2 -2
  21. package/legion/skills/legion-controller/references/triage.md +1 -1
  22. package/legion/skills/legion-oracle/SKILL.md +1 -1
  23. package/legion/skills/legion-worker/references/conflicts-and-rewrites.md +0 -2
  24. package/legion/skills/legion-worker/references/findings-steps.md +5 -5
  25. package/legion/skills/legion-worker/references/findings.md +13 -22
  26. package/legion/skills/legion-worker/references/results.md +15 -2
  27. package/package.json +1 -1
  28. package/skills/dispatch/SKILL.md +7 -3
  29. package/skills/dispatch-first/SKILL.md +1 -1
  30. package/skills/dispatch-writing-specs/SKILL.md +1 -1
@@ -36916,8 +36916,8 @@ function dispatchToolSchema(spec, z, opts) {
36916
36916
  var ISSUE_REFERENCE = "An issue is a native KEY or external owner/repo#n reference. An external reference addresses an existing Dispatch issue, including one linked to that GitHub pull request; only dispatch issue with --external creates a native issue.";
36917
36917
  var BOARD_NEIGHBOUR_REFUSAL = "The server refuses a key that does not exist, one in another project, this issue itself, an empty value, and a pair the board does not hold in that order.";
36918
36918
  var OWNER_REFERENCE = "Exactly one of issue and project is required. An issue is a native KEY or external owner/repo#n reference; a project is a project key such as CORE and addresses an unlinked project document named by artifact.";
36919
- var ASK_QUESTION_CONTRACT = "The question names the concrete case first: which machines, files, sessions or people, and the " + "numbers. It asks the choice in those terms, saying what happens to whom under each option " + '("Ship Friday and risk signing out 1,240 users, or hold to Monday?"), never "How should we ' + 'proceed?" or "Which option?", because a reader cannot work back from a general question to ' + "the case. It carries every fact the reader needs to decide and nothing " + "that does not change the decision. Generalize only after the specifics, if at all. Then give " + "your recommendation and its reason.";
36920
- var ASK_OPTIONS_CONTRACT = "Options carry the genuinely different approaches. Each option has a label, and its description " + "says what that approach costs.";
36919
+ var ASK_QUESTION_CONTRACT = "The question names the concrete case first: which machines, files, sessions or people, and the " + "numbers. It asks the choice in those terms, saying what happens to whom under each option " + '("Ship Friday and risk signing out 1,240 users, or hold to Monday?"), never "How should we ' + 'proceed?" or "Which option?", because a reader cannot work back from a general question to ' + "the case. It carries every fact the reader needs to decide and nothing " + "that does not change the decision. Generalize only after the specifics, if at all. A question " + "between two or more real choices gives one recommendation and its reason. A request for one " + "act only the person can do (an approval, a credential, a grant, a setting of their own " + "account) says what the act is, what it changes and how to do it, and gives no recommendation.";
36920
+ var ASK_OPTIONS_CONTRACT = "Options carry only the real choices: each is within your rules, and a person could choose " + "it. Add no option that breaks your rules or that no one would choose. Each option has a " + "label, and its description says what that approach costs. A request for one act only the " + "person can do has the two options Done and Can't.";
36921
36921
  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.";
36922
36922
  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.";
36923
36923
  var HUMAN_AGREED_TO_DOCUMENT = "the human has agreed to every point in the document";
@@ -37288,6 +37288,39 @@ var RESULT_RECORD_FIELDS = [
37288
37288
  ];
37289
37289
  var RESULT_RETRACT_RULE = "Pass retract with the id of a result recorded before, and reason with why that result is " + "wrong, to retract it.";
37290
37290
  var RESULT_SHAPE_RULE = `${RESULT_RETRACT_RULE} A call with retract takes reason and no other argument. A call ` + "without retract records a result, and it takes issue, check, role, verdict and commit.";
37291
+ var DEPLOY_REPO = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
37292
+ var DEPLOY_PROGRAM = /^[a-z0-9-]{1,64}$/;
37293
+ var DEPLOY_COMMIT = /^[0-9a-f]{40}$/;
37294
+ var DEPLOY_TIME = /^(\d{4})-(\d{2})-(\d{2})T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;
37295
+ function deployRepoProblem(value) {
37296
+ const input = value;
37297
+ return typeof input["repo"] !== "string" || !DEPLOY_REPO.test(input["repo"]) ? "repo must be owner/repo" : undefined;
37298
+ }
37299
+ function deployProblem(value) {
37300
+ const input = value;
37301
+ const repo = deployRepoProblem(input);
37302
+ if (repo !== undefined)
37303
+ return repo;
37304
+ if (typeof input["program"] !== "string" || !DEPLOY_PROGRAM.test(input["program"]))
37305
+ return "program must be 1 to 64 lowercase letters, digits or hyphens";
37306
+ if (typeof input["commit"] !== "string" || !DEPLOY_COMMIT.test(input["commit"]))
37307
+ return "commit must be 40 lowercase hexadecimal characters";
37308
+ if (input["deployed_at"] !== undefined) {
37309
+ const value = input["deployed_at"];
37310
+ if (typeof value !== "string")
37311
+ return "deployed_at must be RFC3339";
37312
+ const parts = DEPLOY_TIME.exec(value);
37313
+ const timestamp = Date.parse(value);
37314
+ if (parts === null || !Number.isFinite(timestamp))
37315
+ return "deployed_at must be RFC3339";
37316
+ const calendar = new Date(`${parts[1]}-${parts[2]}-${parts[3]}T00:00:00Z`);
37317
+ if (calendar.toISOString().slice(0, 10) !== value.slice(0, 10))
37318
+ return "deployed_at must be a valid calendar date";
37319
+ if (timestamp > Date.now() + 5 * 60 * 1000)
37320
+ return "deployed_at must not be more than five minutes in the future";
37321
+ }
37322
+ return;
37323
+ }
37291
37324
  function resultProblem(value) {
37292
37325
  const input = value;
37293
37326
  const carried = RESULT_RECORD_FIELDS.filter((field) => input[field] !== undefined);
@@ -37469,7 +37502,7 @@ var dispatchToolSpecs = [
37469
37502
  }
37470
37503
  ]
37471
37504
  },
37472
- description: `${ASK_IS_FOR_A_PERSON} ${ASK_WAITS_ON_THE_ASSIGNEE} ` + "Open a to-do or permission only a human can give, or a decision that has no document to " + "live in. A question about the design an issue's document records is not this tool: write " + "it into that document as a decision block (dispatch doc-edit inserting an ask block at the " + "end of the section it concerns), at every phase, approved spec or not; the block reaches " + "the Inbox and its answer lands next to its context. Never give an ask an Approve option: a " + "document is approved through dispatch request-approval. Do not use this tool for a status " + "update or discussion; use dispatch message instead. Never create an issue to park a " + "question: the question is an ask on the issue it concerns. " + ASK_QUESTION_CONTRACT + " " + ASK_OPTIONS_CONTRACT + " For an action only a human can perform, state what it changes and risks as constraints. " + "Anything that requires a human to do, including a credential or grant renewal, is an ask, " + "never a message. Measure what you can first, and put the measurement and the size of the " + "population it covers in the question; drop an option that cannot fix most of that " + "population, never offer it cut down, and keep an option not to act (Hold). Set urgency high " + "when your work halts on the answer, and keep working on everything else. " + "Anchor a to-do about a document passage, thread reply_to/reply_to_ask, or cite a dispatch:// " + `reference \u2014 it must be answerable from its own text and anchor alone, never "see above". ` + `A quote anchor is pinned to its block. ${ASK_BOUND_RULE} The lines images appends count ` + `toward that bound, and an ask has at most 8 options. ${RELATED_CHECK_RESULT} ` + `An ask among the related items says whether it is answered, by whom and with which options. ${OWNER_REFERENCE}`,
37505
+ description: `${ASK_IS_FOR_A_PERSON} ${ASK_WAITS_ON_THE_ASSIGNEE} ` + "Open a to-do or permission only a human can give, or a decision that has no document to " + "live in. Ask for a decision only when two or more choices are real. Where only one is " + "real, make it, and tell the person what you did and why. A question about the design an " + "issue's document records is not this tool: write " + "it into that document as a decision block (dispatch doc-edit inserting an ask block at the " + "end of the section it concerns), at every phase, approved spec or not; the block reaches " + "the Inbox and its answer lands next to its context. Never give an ask an Approve option: a " + "document is approved through dispatch request-approval. Do not use this tool for a status " + "update or discussion; use dispatch message instead. Never create an issue to park a " + "question: the question is an ask on the issue it concerns. " + ASK_QUESTION_CONTRACT + " " + ASK_OPTIONS_CONTRACT + " For an action only a human can perform, state what it changes and risks as constraints, " + "and a safer alternative as a fact, never as an option. " + "Anything that requires a human to do, including a credential or grant renewal, is an ask, " + "never a message. Measure what you can first, and put the measurement and the size of the " + "population it covers in the question; drop an option that cannot fix most of that " + "population, and never offer it cut down. Offer an option not to act (Hold) only where not " + "acting is a real choice and the question names its cost. Set urgency high " + "when your work halts on the answer, and keep working on everything else. " + "Anchor a to-do about a document passage, thread reply_to/reply_to_ask, or cite a dispatch:// " + `reference \u2014 it must be answerable from its own text and anchor alone, never "see above". ` + `A quote anchor is pinned to its block. ${ASK_BOUND_RULE} The lines images appends count ` + `toward that bound, and an ask has at most 8 options. ${RELATED_CHECK_RESULT} ` + `An ask among the related items says whether it is answered, by whom and with which options. ${OWNER_REFERENCE}`,
37473
37506
  arguments: (z) => ({
37474
37507
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
37475
37508
  project: z.string().describe("Project key owning the document.").optional(),
@@ -37789,14 +37822,51 @@ var dispatchToolSpecs = [
37789
37822
  refusal: (value) => resultProblem(value) ?? RESULT_SHAPE_RULE
37790
37823
  }
37791
37824
  },
37825
+ {
37826
+ name: "dispatch_deploy",
37827
+ example: {
37828
+ repo: "acme/widgets",
37829
+ program: "worker",
37830
+ commit: "1111111111111111111111111111111111111111"
37831
+ },
37832
+ description: "Record a deployed program's build. Dispatch records the credential's writer; the body cannot choose one. A repeat of the current commit changes nothing, including its time. An older time at another commit is DEPLOY_NOT_NEWEST and names the current build. The repository must hold the commit. A project-scoped credential cannot write a deployment-wide fact. --dry-run checks the arguments and sends nothing; --json prints the complete wire answer.",
37833
+ arguments: (z) => ({
37834
+ repo: z.string().describe("The deployed repository, owner/repo."),
37835
+ program: z.string().describe("The deployed program, 1 to 64 lowercase letters, digits or hyphens."),
37836
+ commit: z.string().describe("The deployed build, 40 lowercase hexadecimal characters."),
37837
+ deployed_at: z.string().describe("The deployment time in RFC3339. Omit it for the server's clock; a time over five minutes ahead is refused.").optional(),
37838
+ url: z.string().describe("The deployment's URL, if it has one.").optional(),
37839
+ json: z.boolean().describe("Print the complete wire answer as JSON.").optional()
37840
+ }),
37841
+ validation: {
37842
+ check: (value) => deployProblem(value) === undefined,
37843
+ message: "Name repo, program and commit.",
37844
+ refusal: (value) => deployProblem(value) ?? "Name repo, program and commit."
37845
+ }
37846
+ },
37847
+ {
37848
+ name: "dispatch_deploys",
37849
+ example: { repo: "acme/widgets" },
37850
+ description: "Read the current deploy of each program in a repository, in program order, with its commit, deployment time, source and URL. --json prints the complete wire answer, including the writer and a known workflow attempt or null for an unknown attempt.",
37851
+ arguments: (z) => ({
37852
+ repo: z.string().describe("The deployed repository, owner/repo."),
37853
+ json: z.boolean().describe("Print the complete wire answer as JSON.").optional()
37854
+ }),
37855
+ validation: {
37856
+ check: (value) => deployRepoProblem(value) === undefined,
37857
+ message: "repo must be owner/repo",
37858
+ refusal: (value) => deployRepoProblem(value) ?? "repo must be owner/repo"
37859
+ }
37860
+ },
37792
37861
  {
37793
37862
  name: "dispatch_results",
37794
37863
  example: { issue: "DSP-1" },
37795
- description: "Print each check of an issue's Verification document with every result recorded against " + "it, newest first. " + "Each check prints what Dispatch compared its results with. A before_merge check is " + "compared with the head of each pull request Dispatch holds for the check's issue, open " + "or merged. An after_merge check is compared with the branch that issue's pull request " + "merged into and with the repository's default branch, and with the default branch alone " + "where Dispatch holds no merge of the issue. A default_branch check is compared with the " + "repository's default branch alone, whatever branch the pull request merged into. Where " + "a check compared with nothing, it says which of three things happened: the issue has no " + "pull request and no branch to compare with, Dispatch cannot read the repository, or a " + "read Dispatch made did not answer. " + "Each check then prints one line that answers the gate: whether a pass of it stands, and " + "from which roles. A pass stands when its commit is one of the commits the check " + "compared with, the check's words did not move after the result was recorded, and no " + "retraction stands against it. " + "The check's own words print once, under the check. Each result then prints its verdict, " + "its role, its whole 40-character commit, where that commit stands, whether the check's " + "words moved after it was recorded, the time, its id, and the reading the role recorded. " + "A result nobody gave a reading says so. A retracted result prints as retracted, with " + "the reason and the caller that retracted it. A check with no result says so. " + `${CHECK_PROVED_BY_CI}: ` + "no role records its result, and Dispatch reads it from GitHub at the head of the " + "issue's open pull request of the highest number, else at the head of its merged one of " + "the highest number. Its one result prints as `- <id> (before_merge): <verdict> at " + "<commit> by ci (CI run <name>, <conclusion>), <where that commit stands>. <the check's " + "words>`, then the `A pass stands:` line a recorded check prints, then `Pull request line:` " + "and the line to write into the pull-request body unchanged, then the reading: the " + "conclusion, the run's output title and summary, and its URL. A run that proves nothing " + "prints `- <id> (before_merge): no result:`, the sentence that names why, and the check's " + "words, then the `A pass stands:` line, then `Pull request line:` and `- Check <id> " + "(before_merge): CI run <name> has no result (<case>)`. That is a run that has not " + "concluded, one that concluded neutral, skipped or cancelled, one absent at the head, an " + "issue with no pull request head, or GitHub not read, with what GitHub answered. " + "A pull-request line writes `CI run <name>` only when it keeps every word of the name, " + "and `the CI run the check names` in its place where it drops one: a word the line drops, " + "such as an issue key or a word holding `_`. " + "A push that moves a pull request's head leaves a result at the commit before it, with " + "no write of anyone's: record the check again at the new head. A check CI proves is read " + "again at the new head by itself. " + ISSUE_REFERENCE,
37864
+ description: "Print each check of an issue's Verification document with every result recorded against " + "it, newest first. " + "Each check prints what Dispatch compared its results with. A before_merge check is " + "compared with every open pull request head, or the final head of the last to merge when " + "none is open. An after_merge result counts only at a commit that holds the work's merge " + "on the compared branch. A default_branch check names the default branch alone. " + "With no known merge, an after_merge check compares with nothing and says so. " + "A read that failed is not known, never a pass or a fail. The newest branch result decides " + "and names its id and commit. A pass and fail at that commit are not known until retraction. " + "Production and graph checks count only results recorded for the current deploy of the " + "program they read. The output names that deploy and says why an excluded result counts " + "for nothing. The check's words must be unchanged and the result unretracted. " + "The check's own words print once, under the check. Each result then prints its verdict, " + "its role, its whole 40-character commit, where that commit stands, whether the check's " + "words moved after it was recorded, the time, its id, and the reading the role recorded. " + "A result nobody gave a reading says so. A retracted result prints as retracted, with " + "the reason and the caller that retracted it. A check with no result says so. " + `${CHECK_PROVED_BY_CI}: ` + "no role records its result. Dispatch reads GitHub at every open head, or the final head " + "of the last pull request to merge when none is open. Its result prints as `- <id> (before_merge): <verdict> at " + "<commit> by ci (CI run <name>, <conclusion>), <where that commit stands>. <the check's " + "words>`, then the `A pass stands:` line a recorded check prints, then `Pull request line:` " + "and the line to write into the pull-request body unchanged, then the reading: the " + "conclusion, the run's output title and summary, and its URL. A run that proves nothing " + "prints `- <id> (before_merge): no result:`, the sentence that names why, and the check's " + "words, then the `A pass stands:` line, then `Pull request line:` and `- Check <id> " + "(before_merge): CI run <name> has no result (<case>)`. That is a run that has not " + "concluded, one that concluded neutral, skipped or cancelled, one absent at the head, an " + "issue with no pull request head, or GitHub not read, with what GitHub answered. " + "A pull-request line writes `CI run <name>` only when it keeps every word of the name, " + "and `the CI run the check names` in its place where it drops one: a word the line drops, " + "such as an issue key or a word holding `_`. " + "A push that moves a pull request's head leaves a result at the commit before it, with " + "no write of anyone's: record the check again at the new head. A check CI proves is read " + "again at the new head by itself. " + ISSUE_REFERENCE,
37796
37865
  arguments: (z) => ({
37797
37866
  issue: z.string().describe(ISSUE_REFERENCE),
37798
- at: z.string().describe("One commit of 40 lowercase hex characters. It becomes the only thing every check is compared with. Dispatch reads GitHub for none of it, except the check runs of a check CI proves, which it reads at the issue's newest pull request head as on every read, so that check's result stands at this commit only where it is that head.").optional(),
37799
- brief: z.boolean().describe("Cut each reading whose result stands at none of the compared commits to its first 200 characters. Every other reading prints whole.").optional()
37867
+ at: z.string().describe("One commit of 40 lowercase hex characters. It becomes the only thing every check is compared with. Dispatch reads GitHub for none of it, except the check runs of a check CI proves, which it reads at each open pull request head, or with none open the final head of the newest merged one, as on every read, so that check's result stands at this commit only where it is the head it was read at.").optional(),
37868
+ brief: z.boolean().describe("Cut each reading whose result stands at none of the compared commits to its first 200 characters. Every other reading prints whole.").optional(),
37869
+ json: z.boolean().describe("Print the complete results wire answer as JSON.").optional()
37800
37870
  })
37801
37871
  },
37802
37872
  {
@@ -38138,6 +38208,13 @@ var IssueDeployedEventPayloadSchema = strictObject({
38138
38208
  run_id: number2().int().positive(),
38139
38209
  completed_at: exports_iso.datetime()
38140
38210
  });
38211
+ var DeployRecordedEventPayloadSchema = strictObject({
38212
+ repo: string2(),
38213
+ program: string2(),
38214
+ commit: string2(),
38215
+ deployed_at: string2(),
38216
+ source: _enum2(["delivery_run", "route"])
38217
+ });
38141
38218
  var childStatusEventPayloadFields = {
38142
38219
  child_key: string2(),
38143
38220
  from: string2(),
@@ -38524,6 +38601,7 @@ var EVENT_TYPE_MEMBERS = {
38524
38601
  "comment.reopened": true,
38525
38602
  "comment.resolved": true,
38526
38603
  "decision.kept": true,
38604
+ "deploy.recorded": true,
38527
38605
  "handoff.recorded": true,
38528
38606
  "issue.claimed": true,
38529
38607
  "issue.closed": true,
@@ -46787,20 +46865,18 @@ function tradeProjects(env) {
46787
46865
  }
46788
46866
  return sorted;
46789
46867
  }
46868
+ var ROLE_KEY_NAMED = `this role's agent-secrets key in the directory ${KEY_DIR_VAR} names`;
46790
46869
  async function machineKey(env) {
46791
46870
  const dir = value(env, KEY_DIR_VAR);
46792
46871
  if (value(env, IDENTITY_VAR) !== IDENTITY_KUBERNETES || dir === "")
46793
46872
  return await newDpopKey();
46794
- const path = join4(dir, ROLE_KEY_FILE);
46795
46873
  let pem;
46796
46874
  try {
46797
- pem = await readFile4(path, "utf8");
46875
+ pem = await readFile4(join4(dir, ROLE_KEY_FILE), "utf8");
46798
46876
  } catch (error) {
46799
- throw new Error(`read this role's agent-secrets key ${path}: ${messageOf(error)}`, {
46800
- cause: error
46801
- });
46877
+ throw new Error(`read ${ROLE_KEY_NAMED}: ${readErrorCode(error)}`);
46802
46878
  }
46803
- return await importDpopKey(pem, `this role's agent-secrets key ${path}`);
46879
+ return await importDpopKey(pem, ROLE_KEY_NAMED);
46804
46880
  }
46805
46881
  async function brokerTokenClient(env, own = "", read) {
46806
46882
  const brokerUrl = value(env, BROKER_URL_VAR);
@@ -48876,6 +48952,12 @@ class DispatchClient {
48876
48952
  async issueResults(issue, at) {
48877
48953
  return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "results"], undefined, at === undefined ? undefined : { at });
48878
48954
  }
48955
+ async recordDeploy(input) {
48956
+ return this.#json("POST", ["api", "v1", "deploys"], input);
48957
+ }
48958
+ async deploys(repo) {
48959
+ return this.#json("GET", ["api", "v1", "deploys"], undefined, { repo });
48960
+ }
48879
48961
  async retractResult(resultID, input) {
48880
48962
  return this.#json("POST", ["api", "v1", "results", resultID, "retract"], input);
48881
48963
  }
@@ -54632,6 +54714,8 @@ var issueFreeTools = {
54632
54714
  dispatch_limits: true,
54633
54715
  dispatch_api: true,
54634
54716
  dispatch_inbox: true,
54717
+ dispatch_deploy: true,
54718
+ dispatch_deploys: true,
54635
54719
  dispatch_send_to_agent: true,
54636
54720
  dispatch_architecture_sync: true
54637
54721
  };
@@ -56175,7 +56259,8 @@ var BRIEF_READING_CHARACTERS = 200;
56175
56259
  var COMPARISON_REASONS = {
56176
56260
  no_pull_request_or_branch: () => "the issue has no pull request and no branch to compare with",
56177
56261
  repository_unreadable: (repo = "the repository") => `Dispatch cannot read ${repo}`,
56178
- read_failed: (repo) => repo === undefined ? "a read Dispatch made did not answer" : `a read Dispatch made of ${repo} did not answer`
56262
+ read_failed: (repo) => repo === undefined ? "a read Dispatch made did not answer" : `a read Dispatch made of ${repo} did not answer`,
56263
+ not_merged: () => "the work has no merge that Dispatch knows"
56179
56264
  };
56180
56265
  function isComparisonReason(reason) {
56181
56266
  return Object.hasOwn(COMPARISON_REASONS, reason);
@@ -56203,8 +56288,13 @@ function basisText(basis) {
56203
56288
  const pullRequest = basis.pull_request === undefined ? "pull request " : `${pullRequestName(basis, basis.pull_request)} `;
56204
56289
  return `the head of ${pullRequest}at ${basis.commit ?? "an unnamed commit"}${learned}`;
56205
56290
  }
56206
- if (basis.kind === "branch")
56207
- return `branch ${branchName(basis)}${learned}`;
56291
+ if (basis.kind === "branch") {
56292
+ if (basis.merge_commit === undefined)
56293
+ return `branch ${branchName(basis)}${learned}`;
56294
+ const repository = basis.repo === undefined ? "" : `in ${basis.repo} `;
56295
+ const merged = basis.merge_commit === undefined ? "" : `, merged at ${basis.merge_commit}`;
56296
+ return `${repository}branch ${basis.branch ?? "unnamed"}${merged}${learned}`;
56297
+ }
56208
56298
  return `the commit you named, ${basis.commit ?? ""}${learned}`;
56209
56299
  }
56210
56300
  function basisPlace(basis) {
@@ -56237,9 +56327,53 @@ function checkWordsText(check, result) {
56237
56327
  }
56238
56328
  return result.check_words_moved ? `The check's words moved after this result (${versions})` : `The check's words did not move after this result (${versions})`;
56239
56329
  }
56240
- function passStandsText(pass) {
56330
+ function passStandsText(pass, check, repository) {
56241
56331
  if (pass === undefined)
56242
56332
  return "Whether a pass stands is not known: this Dispatch server does not say";
56333
+ const branch = check !== undefined && (check.when === "after_merge" || check.when === "default_branch") && !(check.compared_with ?? []).some((basis) => basis.kind === "named");
56334
+ if (branch && check !== undefined) {
56335
+ const results = check.results ?? [];
56336
+ const deciding = pass.results ?? [];
56337
+ const passed = results.find((result) => result.verdict === "pass" && deciding.includes(result.id));
56338
+ const failed = results.find((result) => result.verdict === "fail" && deciding.includes(result.id));
56339
+ const result = results.find((result) => deciding.includes(result.id));
56340
+ const repo = repository ?? check.compared_with?.[0]?.repo ?? "the repository";
56341
+ const deploy = pass.deploy;
56342
+ const program = deploy?.program ?? check.program ?? "the program";
56343
+ const roles = (pass.roles ?? []).join(", ");
56344
+ if (pass.answer === "yes" && passed !== undefined)
56345
+ return `A pass stands: yes, from ${roles}, as the newest result is pass ${passed.id} at ${pass.commit ?? passed.commit_sha}`;
56346
+ switch (pass.reason) {
56347
+ case "fail":
56348
+ if (failed !== undefined)
56349
+ return `A pass stands: no, as the newest result is fail ${failed.id} at ${pass.commit ?? failed.commit_sha}`;
56350
+ break;
56351
+ case "no_result":
56352
+ return "A pass stands: no, as no result counts at a commit that holds the merge";
56353
+ case "pass_and_fail":
56354
+ if (passed !== undefined && failed !== undefined)
56355
+ return `A pass stands: not known, as pass ${passed.id} and fail ${failed.id} both count at ${pass.commit ?? passed.commit_sha}. A retraction of the wrong one ends it`;
56356
+ break;
56357
+ case "not_placed":
56358
+ if (result !== undefined)
56359
+ return `A pass stands: not known, as Dispatch could not place ${result.verdict} ${result.id} at ${pass.commit ?? result.commit_sha}`;
56360
+ break;
56361
+ case "read_failed":
56362
+ return "A pass stands: not known, as a read Dispatch made did not answer";
56363
+ case "program_not_named":
56364
+ return `A pass stands: not known, as ${repo} runs more than one program and this check names none`;
56365
+ case "no_deploy":
56366
+ return `A pass stands: not known, as Dispatch holds no deploy of ${program} in ${repo}`;
56367
+ case "deploy_not_merged":
56368
+ if (deploy !== undefined)
56369
+ return `A pass stands: not known, as ${program} runs ${deploy.commit} since ${deploy.deployed_at}, which does not hold the merge`;
56370
+ break;
56371
+ case "no_result_from_deploy":
56372
+ if (deploy !== undefined)
56373
+ return `A pass stands: not known, as no result counts for ${program} at ${deploy.commit}, deployed ${deploy.deployed_at}`;
56374
+ break;
56375
+ }
56376
+ }
56243
56377
  if (pass.answer === "yes") {
56244
56378
  const roles = pass.roles ?? [];
56245
56379
  return roles.length === 0 ? "A pass stands: yes" : `A pass stands: yes, from ${roles.join(", ")}`;
@@ -56268,6 +56402,8 @@ function resultLines(check, result, brief) {
56268
56402
  if (retracted !== undefined) {
56269
56403
  lines.push(` Retracted by ${actorText(retracted.actor)} at ${retracted.created_at}. The reason: ${retracted.reason}`);
56270
56404
  }
56405
+ if (result.not_counted !== undefined && result.not_counted !== "")
56406
+ lines.push(` It counts for nothing: ${result.not_counted}.`);
56271
56407
  return [...lines, ...readingLines(result, brief)];
56272
56408
  }
56273
56409
  function ciCheckLines(check, ci, brief) {
@@ -56289,7 +56425,7 @@ function ciCheckLines(check, ci, brief) {
56289
56425
  ...readingLines(derived, brief, " ")
56290
56426
  ];
56291
56427
  }
56292
- function checkLines(check, brief) {
56428
+ function checkLines(check, brief, repository) {
56293
56429
  if (check.ci !== undefined)
56294
56430
  return ciCheckLines(check, check.ci, brief);
56295
56431
  const bases = check.compared_with ?? [];
@@ -56297,12 +56433,15 @@ function checkLines(check, brief) {
56297
56433
  const compared = bases.length > 0 ? `Compared with ${bases.map(basisText).join(", ")}` : reason === undefined ? "Compared with nothing, and this Dispatch server does not say why" : `Compared with nothing: ${reasonText(reason)}`;
56298
56434
  const results = check.results ?? [];
56299
56435
  return [
56300
- `- ${check.block_id} (${check.when}). ${compared}. ${passStandsText(check.pass_stands)}.`,
56436
+ `- ${check.block_id} (${check.when}). ${compared}. ${passStandsText(check.pass_stands, check, repository)}.`,
56437
+ ...check.pass_stands?.deploy === undefined ? [] : [
56438
+ ` Program ${check.pass_stands.deploy.program} runs ${check.pass_stands.deploy.commit} since ${check.pass_stands.deploy.deployed_at}; a pass of this check must come from this deploy.`
56439
+ ],
56301
56440
  ` The check's words: ${check.text}`,
56302
56441
  ...results.length === 0 ? [" No result is recorded for this check."] : results.flatMap((result) => resultLines(check, result, brief))
56303
56442
  ];
56304
56443
  }
56305
- function formatCheckResults(results, brief = false) {
56444
+ function formatCheckResults(results, brief = false, repositories) {
56306
56445
  if (results.verification_artifact_id === "") {
56307
56446
  return `${results.issue} has no Verification document, so it has no checks. Write one (verification.md) with a check block per thing that must be proved.`;
56308
56447
  }
@@ -56310,7 +56449,7 @@ function formatCheckResults(results, brief = false) {
56310
56449
  if (checks.length === 0) {
56311
56450
  return `${results.issue}'s Verification document holds no check blocks.`;
56312
56451
  }
56313
- const blocks = checks.map((check) => checkLines(check, brief).join(`
56452
+ const blocks = checks.map((check) => checkLines(check, brief, repositories?.[check.issue_key]).join(`
56314
56453
  `));
56315
56454
  return [`Checks of ${results.issue}:`, ...blocks].join(`
56316
56455
 
@@ -57046,8 +57185,15 @@ async function resultsCommand(context) {
57046
57185
  const brief = optionalBoolean(args, "brief") === true;
57047
57186
  const results = await client.issueResults(issue, at);
57048
57187
  const checks = results.checks ?? [];
57188
+ const repositories = {};
57189
+ const owners = new Set(checks.filter((check) => check.pass_stands?.reason === "program_not_named" || check.pass_stands?.reason === "no_deploy").map((check) => check.issue_key));
57190
+ await Promise.all([...owners].map(async (owner) => {
57191
+ const issue = await client.getIssue(owner);
57192
+ if (issue.resolved_repo != null)
57193
+ repositories[owner] = issue.resolved_repo;
57194
+ }));
57049
57195
  return {
57050
- text: formatCheckResults(results, brief),
57196
+ text: formatCheckResults(results, brief, repositories),
57051
57197
  details: {
57052
57198
  issue,
57053
57199
  checks: checks.length,
@@ -57101,6 +57247,7 @@ var WRITE_ROUTES = [
57101
57247
  { method: "POST", pattern: "/api/v1/issues/{key}/results", commands: ["result"] },
57102
57248
  { method: "POST", pattern: "/api/v1/issues/{key}/results/dry-run", commands: ["result"] },
57103
57249
  { method: "POST", pattern: "/api/v1/results/{id}/retract", commands: ["result"] },
57250
+ { method: "POST", pattern: "/api/v1/deploys", commands: ["deploy"] },
57104
57251
  { method: "POST", pattern: "/api/v1/issues/{key}/handoffs/{phase}", commands: ["handoff-write"] },
57105
57252
  { method: "POST", pattern: "/api/v1/issues/{key}/artifacts", commands: ["artifact"] },
57106
57253
  { method: "POST", pattern: "/api/v1/projects/{key}/artifacts", commands: ["artifact"] },
@@ -58046,6 +58193,37 @@ async function sendToAgentCommand(context) {
58046
58193
  };
58047
58194
  }
58048
58195
 
58196
+ // ../envoy-client/src/dispatch-commands/deploy.ts
58197
+ function deployText(deploy) {
58198
+ const link = deploy.url === "" ? "" : ` ${deploy.url}`;
58199
+ return `${deploy.program}: ${deploy.commit} since ${deploy.deployed_at} (source: ${deploy.source}, recorded by ${actorText(deploy.recorded_by)}).${link}`;
58200
+ }
58201
+ async function deployCommand(context) {
58202
+ const { args, client } = context;
58203
+ const input = {
58204
+ repo: stringArg(args, "repo"),
58205
+ program: stringArg(args, "program"),
58206
+ commit: stringArg(args, "commit"),
58207
+ ...defined("deployed_at", optionalString(args, "deployed_at")),
58208
+ ...defined("url", optionalString(args, "url"))
58209
+ };
58210
+ const result = await client.recordDeploy(input);
58211
+ return {
58212
+ text: optionalBoolean(args, "json") === true ? JSON.stringify(result, null, 2) : deployText(result.deploy),
58213
+ details: { repo: input.repo, deploy: result.deploy }
58214
+ };
58215
+ }
58216
+ async function deploysCommand(context) {
58217
+ const { args, client } = context;
58218
+ const result = await client.deploys(stringArg(args, "repo"));
58219
+ const deploys = result.deploys ?? [];
58220
+ return {
58221
+ text: optionalBoolean(args, "json") === true ? JSON.stringify(result, null, 2) : deploys.length === 0 ? `Dispatch holds no deploys for ${result.repo}.` : deploys.map(deployText).join(`
58222
+ `),
58223
+ details: { repo: result.repo, deploys }
58224
+ };
58225
+ }
58226
+
58049
58227
  // ../envoy-client/src/dispatch-commands/documents.ts
58050
58228
  import { resolve as resolvePath3 } from "path";
58051
58229
 
@@ -60254,6 +60432,8 @@ var dispatchCommands = {
60254
60432
  dispatch_review: acting(reviewCommand),
60255
60433
  dispatch_result: acting(resultCommand),
60256
60434
  dispatch_results: acting(resultsCommand),
60435
+ dispatch_deploy: acting(deployCommand),
60436
+ dispatch_deploys: acting(deploysCommand),
60257
60437
  dispatch_artifact: {
60258
60438
  ...acting(artifactCommand),
60259
60439
  dryRun: artifactDryRun,
@@ -66334,7 +66514,7 @@ var envoyToolSpecs = [
66334
66514
  },
66335
66515
  {
66336
66516
  name: "envoy_publish",
66337
- description: `Publish an Envoy message to a notifications. topic. ${STORED_DELIVERY} A role or built-in topic is delivered as its guide says. A role message has three possible answers. First, a live session holds the role, and the stream stores the forward for that holder's consumer. Its 200 says the stream stored it. It does not say that the holder read it. It names the holder and the state the listener resolved the holder in. Second, no live session holds the role: nobody claims it, or its holder is unresponsive or gone. The listener then keeps the message for one hour. This is a success. The result says that the listener kept the message, and its kept_until is the time that hour ends. For a holder that is not live, the result also names that holder and its state. The next session to hold the role live before kept_until gets the message. That can be the same holder when it answers again. If no session takes the message by kept_until, Envoy drops it. If the publish named your session as its source, Envoy then sends your session a message that names the dropped message, unless it dropped it more than an hour late. Third, the listener keeps nothing and errs, which tells you to reach the agent some other way: the holder refuses the message, or the forward is not stored within four seconds. A team topic (such as notifications.team.deploy-squad.all) is stored like every other, so a session subscribed to it that was away still receives it when it returns, and one that subscribes after you publish does not. A notifications. topic no stream subject captures is refused by name: nothing would store it. ${NOT_SENT_GUIDE} ${PUBLISH_COUNTS} ${SESSION_STATE_GUIDE} ${DELIVERY_CONTRACT}`,
66517
+ description: `Publish an Envoy message to a notifications. topic. ${STORED_DELIVERY} A role or built-in topic is delivered as its guide says. A role message has three possible answers. First, a live session holds the role, and the stream stores the forward for that holder's consumer. Its 200 says the stream stored it. It does not say that the holder read it. It names the holder and the state the listener resolved the holder in. Second, no live session holds the role: nobody claims it, or its holder is unresponsive or gone. The listener then keeps the message for one hour. This is a success. The result says that the listener kept the message, and its kept_until is the time that hour ends. For a holder that is not live, the result also names that holder and its state. The next session to hold the role live before kept_until gets the message. That can be the same holder when it answers again. If no session takes the message by kept_until, Envoy drops it. If the publish named your session as its source, Envoy then sends your session a message that names the dropped message, unless it dropped it more than an hour late. Third, the listener keeps nothing and errs, which tells you to reach the agent some other way: the holder refuses the message, the forward is not stored within four seconds, or no live session holds the role and the publish names no session of yours as its source, so nothing could tell you that a kept copy expired. A team topic (such as notifications.team.deploy-squad.all) is stored like every other, so a session subscribed to it that was away still receives it when it returns, and one that subscribes after you publish does not. A notifications. topic no stream subject captures is refused by name: nothing would store it. ${NOT_SENT_GUIDE} ${PUBLISH_COUNTS} ${SESSION_STATE_GUIDE} ${DELIVERY_CONTRACT}`,
66338
66518
  arguments: (schema) => ({ topic: schema.string(), ...messageArguments(schema) }),
66339
66519
  operation: EnvoyToolOperation.publish
66340
66520
  },
@@ -66668,7 +66848,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
66668
66848
 
66669
66849
  // package.json
66670
66850
  var name2 = "@sjawhar/claude-envoy";
66671
- var version2 = "6.11.1";
66851
+ var version2 = "6.12.1";
66672
66852
  var package_default = {
66673
66853
  name: name2,
66674
66854
  version: version2,