@sjawhar/claude-envoy 6.31.0 → 6.31.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.
@@ -2,5 +2,5 @@
2
2
  "name": "claude-envoy",
3
3
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
4
4
  "mcpServers": "./.mcp.json",
5
- "version": "6.31.0"
5
+ "version": "6.31.1"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "6.31.0",
3
+ "version": "6.31.1",
4
4
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
5
5
  "mcpServers": {}
6
6
  }
@@ -29336,7 +29336,7 @@ function renderAdvice(tool, key, advice, opts) {
29336
29336
  const issueAdvice = "issue_status" in advice ? advice : undefined;
29337
29337
  const hasIssueAdvice = issueAdvice !== undefined;
29338
29338
  const openAsks = issueAdvice?.your_open_asks ?? undefined;
29339
- const writesSinceHuman = issueAdvice?.session_writes_since_human;
29339
+ const cadence = cadenceCount(tool, issueAdvice, opts.isAskReply);
29340
29340
  const lines = [];
29341
29341
  const unparsed = advice.unparsed_openers;
29342
29342
  if (unparsed !== undefined && unparsed.count > 0 && (tool === "dispatch_issue" || tool === "dispatch_artifact")) {
@@ -29391,12 +29391,45 @@ function renderAdvice(tool, key, advice, opts) {
29391
29391
  parts.push(opts.isPlan === true ? `A plan is approved by its plan review, and Dispatch refuses a request for a person's approval of a plan. Once a plan review approves version ${superseded.version}, record it with \`dispatch plan-approve --issue ${key} --version ${superseded.version}\`.` : "Meant to change the approved design? Request approval with `dispatch request-approval`. Meant a correction beside it? Tell the issue's architect, and keep the next one in a comment or in the plan.");
29392
29392
  lines.push(parts.join(" "));
29393
29393
  }
29394
- if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
29395
- const middle = writesSinceHuman >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
29396
- lines.push(`Posted. You've sent ${writesSinceHuman} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
29394
+ if (cadence !== undefined && opts.legionRunsIssue !== true) {
29395
+ const middle = cadence >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
29396
+ lines.push(`Posted. You've sent ${cadence} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
29397
29397
  }
29398
29398
  return lines;
29399
29399
  }
29400
+ function cadenceCount(tool, issueAdvice, isAskReply) {
29401
+ const count = issueAdvice?.session_writes_since_human;
29402
+ const posts = tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && isAskReply !== true;
29403
+ return posts && count !== undefined && count >= 3 ? count : undefined;
29404
+ }
29405
+ async function legionRunsPostedIssue(client, tool, issueKey, advice, isAskReply) {
29406
+ const issueAdvice = advice !== undefined && "issue_status" in advice ? advice : undefined;
29407
+ if (issueKey === null || cadenceCount(tool, issueAdvice, isAskReply) === undefined)
29408
+ return false;
29409
+ const answered = issueAdvice?.legion_managed_status;
29410
+ if (answered !== undefined)
29411
+ return answered;
29412
+ try {
29413
+ return await legionLabelOnChain(client, issueKey);
29414
+ } catch {
29415
+ return false;
29416
+ }
29417
+ }
29418
+ async function legionLabelOnChain(client, key) {
29419
+ let issue = await client.getIssue(key);
29420
+ const project = issue.project;
29421
+ const read = new Set;
29422
+ while (!(issue.labels ?? []).some((label) => /^legion$/i.test(label))) {
29423
+ read.add(issue.key);
29424
+ const parent = issue.parent ?? null;
29425
+ if (parent === null || read.has(parent))
29426
+ return false;
29427
+ issue = await client.getIssue(parent);
29428
+ if (issue.project !== project)
29429
+ return false;
29430
+ }
29431
+ return true;
29432
+ }
29400
29433
  async function otherAdviceLines(render) {
29401
29434
  try {
29402
29435
  return await render();
@@ -32006,7 +32039,9 @@ async function askCommand(context) {
32006
32039
  });
32007
32040
  const reviewLines = await otherAdviceLines(() => standingReviewLines(ask.advice));
32008
32041
  const declinedLines = ask.issue_key === null ? [] : declinedAskLines(ask.advice, ask.issue_key, linkBase);
32009
- const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, askOwner.label, ask.advice, {}));
32042
+ const adviceLines = await otherAdviceLines(async () => renderAdvice(input.tool, askOwner.label, ask.advice, {
32043
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, ask.issue_key, ask.advice)
32044
+ }));
32010
32045
  const asked = waitsOnPerson(ask);
32011
32046
  return {
32012
32047
  text: [
@@ -32215,9 +32250,11 @@ async function commentCommand(context) {
32215
32250
  const comment = resolved?.owner.kind === "project" ? await client.artifactComment(resolved.artifact.id, commentInput) : await client.comment(issue(), commentInput);
32216
32251
  const commentOwner = resolved === undefined ? issueTopic(issue()) : resolvedTopic(resolved);
32217
32252
  const commentDetails = resolved === undefined ? { issue: comment.issue_key, comment: comment.id } : writeResultDetails(resolved, { comment: comment.id });
32253
+ const isAskReply = replyToAsk !== undefined;
32218
32254
  const adviceLines = renderAdvice(input.tool, commentOwner.label, comment.advice, {
32219
- isAskReply: replyToAsk !== undefined,
32220
- replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false)
32255
+ isAskReply,
32256
+ replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false),
32257
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, comment.issue_key, comment.advice, isAskReply)
32221
32258
  });
32222
32259
  if (replyToAsk !== undefined) {
32223
32260
  const askState = comment.ask_waiting_on === undefined ? "" : `; ask now waiting on ${comment.ask_waiting_on}`;
@@ -32321,7 +32358,9 @@ async function messageCommand(context) {
32321
32358
  actor
32322
32359
  });
32323
32360
  const messageRef = dispatchChildRef(dispatchIssueRef(issueKey), "message", message.id);
32324
- const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {});
32361
+ const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {
32362
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, issueKey, message.advice)
32363
+ });
32325
32364
  return {
32326
32365
  text: [
32327
32366
  `Posted message ${message.id} (${messageRef})${await notSubscribed(issueTopic(issueKey), input.subscriptions)}`,
package/dist/dispatch.js CHANGED
@@ -32195,7 +32195,7 @@ function renderAdvice(tool, key, advice, opts) {
32195
32195
  const issueAdvice = "issue_status" in advice ? advice : undefined;
32196
32196
  const hasIssueAdvice = issueAdvice !== undefined;
32197
32197
  const openAsks = issueAdvice?.your_open_asks ?? undefined;
32198
- const writesSinceHuman = issueAdvice?.session_writes_since_human;
32198
+ const cadence = cadenceCount(tool, issueAdvice, opts.isAskReply);
32199
32199
  const lines = [];
32200
32200
  const unparsed = advice.unparsed_openers;
32201
32201
  if (unparsed !== undefined && unparsed.count > 0 && (tool === "dispatch_issue" || tool === "dispatch_artifact")) {
@@ -32250,12 +32250,45 @@ function renderAdvice(tool, key, advice, opts) {
32250
32250
  parts.push(opts.isPlan === true ? `A plan is approved by its plan review, and Dispatch refuses a request for a person's approval of a plan. Once a plan review approves version ${superseded.version}, record it with \`dispatch plan-approve --issue ${key} --version ${superseded.version}\`.` : "Meant to change the approved design? Request approval with `dispatch request-approval`. Meant a correction beside it? Tell the issue's architect, and keep the next one in a comment or in the plan.");
32251
32251
  lines.push(parts.join(" "));
32252
32252
  }
32253
- if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
32254
- const middle = writesSinceHuman >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
32255
- lines.push(`Posted. You've sent ${writesSinceHuman} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
32253
+ if (cadence !== undefined && opts.legionRunsIssue !== true) {
32254
+ const middle = cadence >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
32255
+ lines.push(`Posted. You've sent ${cadence} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
32256
32256
  }
32257
32257
  return lines;
32258
32258
  }
32259
+ function cadenceCount(tool, issueAdvice, isAskReply) {
32260
+ const count = issueAdvice?.session_writes_since_human;
32261
+ const posts = tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && isAskReply !== true;
32262
+ return posts && count !== undefined && count >= 3 ? count : undefined;
32263
+ }
32264
+ async function legionRunsPostedIssue(client, tool, issueKey, advice, isAskReply) {
32265
+ const issueAdvice = advice !== undefined && "issue_status" in advice ? advice : undefined;
32266
+ if (issueKey === null || cadenceCount(tool, issueAdvice, isAskReply) === undefined)
32267
+ return false;
32268
+ const answered = issueAdvice?.legion_managed_status;
32269
+ if (answered !== undefined)
32270
+ return answered;
32271
+ try {
32272
+ return await legionLabelOnChain(client, issueKey);
32273
+ } catch {
32274
+ return false;
32275
+ }
32276
+ }
32277
+ async function legionLabelOnChain(client, key) {
32278
+ let issue = await client.getIssue(key);
32279
+ const project = issue.project;
32280
+ const read = new Set;
32281
+ while (!(issue.labels ?? []).some((label) => /^legion$/i.test(label))) {
32282
+ read.add(issue.key);
32283
+ const parent = issue.parent ?? null;
32284
+ if (parent === null || read.has(parent))
32285
+ return false;
32286
+ issue = await client.getIssue(parent);
32287
+ if (issue.project !== project)
32288
+ return false;
32289
+ }
32290
+ return true;
32291
+ }
32259
32292
  async function otherAdviceLines(render) {
32260
32293
  try {
32261
32294
  return await render();
@@ -38383,7 +38416,9 @@ async function askCommand(context) {
38383
38416
  });
38384
38417
  const reviewLines = await otherAdviceLines(() => standingReviewLines(ask.advice));
38385
38418
  const declinedLines = ask.issue_key === null ? [] : declinedAskLines(ask.advice, ask.issue_key, linkBase);
38386
- const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, askOwner.label, ask.advice, {}));
38419
+ const adviceLines = await otherAdviceLines(async () => renderAdvice(input.tool, askOwner.label, ask.advice, {
38420
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, ask.issue_key, ask.advice)
38421
+ }));
38387
38422
  const asked = waitsOnPerson(ask);
38388
38423
  return {
38389
38424
  text: [
@@ -38592,9 +38627,11 @@ async function commentCommand(context) {
38592
38627
  const comment = resolved?.owner.kind === "project" ? await client.artifactComment(resolved.artifact.id, commentInput) : await client.comment(issue(), commentInput);
38593
38628
  const commentOwner = resolved === undefined ? issueTopic(issue()) : resolvedTopic(resolved);
38594
38629
  const commentDetails = resolved === undefined ? { issue: comment.issue_key, comment: comment.id } : writeResultDetails(resolved, { comment: comment.id });
38630
+ const isAskReply = replyToAsk !== undefined;
38595
38631
  const adviceLines = renderAdvice(input.tool, commentOwner.label, comment.advice, {
38596
- isAskReply: replyToAsk !== undefined,
38597
- replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false)
38632
+ isAskReply,
38633
+ replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false),
38634
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, comment.issue_key, comment.advice, isAskReply)
38598
38635
  });
38599
38636
  if (replyToAsk !== undefined) {
38600
38637
  const askState = comment.ask_waiting_on === undefined ? "" : `; ask now waiting on ${comment.ask_waiting_on}`;
@@ -38698,7 +38735,9 @@ async function messageCommand(context) {
38698
38735
  actor
38699
38736
  });
38700
38737
  const messageRef = dispatchChildRef(dispatchIssueRef(issueKey), "message", message.id);
38701
- const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {});
38738
+ const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {
38739
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, issueKey, message.advice)
38740
+ });
38702
38741
  return {
38703
38742
  text: [
38704
38743
  `Posted message ${message.id} (${messageRef})${await notSubscribed(issueTopic(issueKey), input.subscriptions)}`,
@@ -57208,7 +57208,7 @@ function renderAdvice(tool, key, advice, opts) {
57208
57208
  const issueAdvice = "issue_status" in advice ? advice : undefined;
57209
57209
  const hasIssueAdvice = issueAdvice !== undefined;
57210
57210
  const openAsks = issueAdvice?.your_open_asks ?? undefined;
57211
- const writesSinceHuman = issueAdvice?.session_writes_since_human;
57211
+ const cadence = cadenceCount(tool, issueAdvice, opts.isAskReply);
57212
57212
  const lines = [];
57213
57213
  const unparsed = advice.unparsed_openers;
57214
57214
  if (unparsed !== undefined && unparsed.count > 0 && (tool === "dispatch_issue" || tool === "dispatch_artifact")) {
@@ -57263,12 +57263,45 @@ function renderAdvice(tool, key, advice, opts) {
57263
57263
  parts.push(opts.isPlan === true ? `A plan is approved by its plan review, and Dispatch refuses a request for a person's approval of a plan. Once a plan review approves version ${superseded.version}, record it with \`dispatch plan-approve --issue ${key} --version ${superseded.version}\`.` : "Meant to change the approved design? Request approval with `dispatch request-approval`. Meant a correction beside it? Tell the issue's architect, and keep the next one in a comment or in the plan.");
57264
57264
  lines.push(parts.join(" "));
57265
57265
  }
57266
- if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
57267
- const middle = writesSinceHuman >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
57268
- lines.push(`Posted. You've sent ${writesSinceHuman} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
57266
+ if (cadence !== undefined && opts.legionRunsIssue !== true) {
57267
+ const middle = cadence >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
57268
+ lines.push(`Posted. You've sent ${cadence} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
57269
57269
  }
57270
57270
  return lines;
57271
57271
  }
57272
+ function cadenceCount(tool, issueAdvice, isAskReply) {
57273
+ const count = issueAdvice?.session_writes_since_human;
57274
+ const posts = tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && isAskReply !== true;
57275
+ return posts && count !== undefined && count >= 3 ? count : undefined;
57276
+ }
57277
+ async function legionRunsPostedIssue(client, tool, issueKey, advice, isAskReply) {
57278
+ const issueAdvice = advice !== undefined && "issue_status" in advice ? advice : undefined;
57279
+ if (issueKey === null || cadenceCount(tool, issueAdvice, isAskReply) === undefined)
57280
+ return false;
57281
+ const answered = issueAdvice?.legion_managed_status;
57282
+ if (answered !== undefined)
57283
+ return answered;
57284
+ try {
57285
+ return await legionLabelOnChain(client, issueKey);
57286
+ } catch {
57287
+ return false;
57288
+ }
57289
+ }
57290
+ async function legionLabelOnChain(client, key) {
57291
+ let issue = await client.getIssue(key);
57292
+ const project = issue.project;
57293
+ const read = new Set;
57294
+ while (!(issue.labels ?? []).some((label) => /^legion$/i.test(label))) {
57295
+ read.add(issue.key);
57296
+ const parent = issue.parent ?? null;
57297
+ if (parent === null || read.has(parent))
57298
+ return false;
57299
+ issue = await client.getIssue(parent);
57300
+ if (issue.project !== project)
57301
+ return false;
57302
+ }
57303
+ return true;
57304
+ }
57272
57305
  async function otherAdviceLines(render) {
57273
57306
  try {
57274
57307
  return await render();
@@ -59507,7 +59540,9 @@ async function askCommand(context) {
59507
59540
  });
59508
59541
  const reviewLines = await otherAdviceLines(() => standingReviewLines(ask.advice));
59509
59542
  const declinedLines = ask.issue_key === null ? [] : declinedAskLines(ask.advice, ask.issue_key, linkBase);
59510
- const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, askOwner.label, ask.advice, {}));
59543
+ const adviceLines = await otherAdviceLines(async () => renderAdvice(input.tool, askOwner.label, ask.advice, {
59544
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, ask.issue_key, ask.advice)
59545
+ }));
59511
59546
  const asked = waitsOnPerson(ask);
59512
59547
  return {
59513
59548
  text: [
@@ -59716,9 +59751,11 @@ async function commentCommand(context) {
59716
59751
  const comment = resolved?.owner.kind === "project" ? await client.artifactComment(resolved.artifact.id, commentInput) : await client.comment(issue(), commentInput);
59717
59752
  const commentOwner = resolved === undefined ? issueTopic(issue()) : resolvedTopic(resolved);
59718
59753
  const commentDetails = resolved === undefined ? { issue: comment.issue_key, comment: comment.id } : writeResultDetails(resolved, { comment: comment.id });
59754
+ const isAskReply = replyToAsk !== undefined;
59719
59755
  const adviceLines = renderAdvice(input.tool, commentOwner.label, comment.advice, {
59720
- isAskReply: replyToAsk !== undefined,
59721
- replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false)
59756
+ isAskReply,
59757
+ replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false),
59758
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, comment.issue_key, comment.advice, isAskReply)
59722
59759
  });
59723
59760
  if (replyToAsk !== undefined) {
59724
59761
  const askState = comment.ask_waiting_on === undefined ? "" : `; ask now waiting on ${comment.ask_waiting_on}`;
@@ -59822,7 +59859,9 @@ async function messageCommand(context) {
59822
59859
  actor
59823
59860
  });
59824
59861
  const messageRef = dispatchChildRef(dispatchIssueRef(issueKey), "message", message.id);
59825
- const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {});
59862
+ const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {
59863
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, issueKey, message.advice)
59864
+ });
59826
59865
  return {
59827
59866
  text: [
59828
59867
  `Posted message ${message.id} (${messageRef})${await notSubscribed(issueTopic(issueKey), input.subscriptions)}`,
@@ -69068,7 +69107,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
69068
69107
 
69069
69108
  // package.json
69070
69109
  var name2 = "@sjawhar/claude-envoy";
69071
- var version2 = "6.31.0";
69110
+ var version2 = "6.31.1";
69072
69111
  var package_default = {
69073
69112
  name: name2,
69074
69113
  version: version2,
@@ -32253,7 +32253,7 @@ function renderAdvice(tool, key, advice, opts) {
32253
32253
  const issueAdvice = "issue_status" in advice ? advice : undefined;
32254
32254
  const hasIssueAdvice = issueAdvice !== undefined;
32255
32255
  const openAsks = issueAdvice?.your_open_asks ?? undefined;
32256
- const writesSinceHuman = issueAdvice?.session_writes_since_human;
32256
+ const cadence = cadenceCount(tool, issueAdvice, opts.isAskReply);
32257
32257
  const lines = [];
32258
32258
  const unparsed = advice.unparsed_openers;
32259
32259
  if (unparsed !== undefined && unparsed.count > 0 && (tool === "dispatch_issue" || tool === "dispatch_artifact")) {
@@ -32308,12 +32308,45 @@ function renderAdvice(tool, key, advice, opts) {
32308
32308
  parts.push(opts.isPlan === true ? `A plan is approved by its plan review, and Dispatch refuses a request for a person's approval of a plan. Once a plan review approves version ${superseded.version}, record it with \`dispatch plan-approve --issue ${key} --version ${superseded.version}\`.` : "Meant to change the approved design? Request approval with `dispatch request-approval`. Meant a correction beside it? Tell the issue's architect, and keep the next one in a comment or in the plan.");
32309
32309
  lines.push(parts.join(" "));
32310
32310
  }
32311
- if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
32312
- const middle = writesSinceHuman >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
32313
- lines.push(`Posted. You've sent ${writesSinceHuman} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
32311
+ if (cadence !== undefined && opts.legionRunsIssue !== true) {
32312
+ const middle = cadence >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
32313
+ lines.push(`Posted. You've sent ${cadence} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
32314
32314
  }
32315
32315
  return lines;
32316
32316
  }
32317
+ function cadenceCount(tool, issueAdvice, isAskReply) {
32318
+ const count = issueAdvice?.session_writes_since_human;
32319
+ const posts = tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && isAskReply !== true;
32320
+ return posts && count !== undefined && count >= 3 ? count : undefined;
32321
+ }
32322
+ async function legionRunsPostedIssue(client, tool, issueKey, advice, isAskReply) {
32323
+ const issueAdvice = advice !== undefined && "issue_status" in advice ? advice : undefined;
32324
+ if (issueKey === null || cadenceCount(tool, issueAdvice, isAskReply) === undefined)
32325
+ return false;
32326
+ const answered = issueAdvice?.legion_managed_status;
32327
+ if (answered !== undefined)
32328
+ return answered;
32329
+ try {
32330
+ return await legionLabelOnChain(client, issueKey);
32331
+ } catch {
32332
+ return false;
32333
+ }
32334
+ }
32335
+ async function legionLabelOnChain(client, key) {
32336
+ let issue = await client.getIssue(key);
32337
+ const project = issue.project;
32338
+ const read = new Set;
32339
+ while (!(issue.labels ?? []).some((label) => /^legion$/i.test(label))) {
32340
+ read.add(issue.key);
32341
+ const parent = issue.parent ?? null;
32342
+ if (parent === null || read.has(parent))
32343
+ return false;
32344
+ issue = await client.getIssue(parent);
32345
+ if (issue.project !== project)
32346
+ return false;
32347
+ }
32348
+ return true;
32349
+ }
32317
32350
  async function otherAdviceLines(render) {
32318
32351
  try {
32319
32352
  return await render();
@@ -34923,7 +34956,9 @@ async function askCommand(context) {
34923
34956
  });
34924
34957
  const reviewLines = await otherAdviceLines(() => standingReviewLines(ask.advice));
34925
34958
  const declinedLines = ask.issue_key === null ? [] : declinedAskLines(ask.advice, ask.issue_key, linkBase);
34926
- const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, askOwner.label, ask.advice, {}));
34959
+ const adviceLines = await otherAdviceLines(async () => renderAdvice(input.tool, askOwner.label, ask.advice, {
34960
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, ask.issue_key, ask.advice)
34961
+ }));
34927
34962
  const asked = waitsOnPerson(ask);
34928
34963
  return {
34929
34964
  text: [
@@ -35132,9 +35167,11 @@ async function commentCommand(context) {
35132
35167
  const comment = resolved?.owner.kind === "project" ? await client.artifactComment(resolved.artifact.id, commentInput) : await client.comment(issue(), commentInput);
35133
35168
  const commentOwner = resolved === undefined ? issueTopic(issue()) : resolvedTopic(resolved);
35134
35169
  const commentDetails = resolved === undefined ? { issue: comment.issue_key, comment: comment.id } : writeResultDetails(resolved, { comment: comment.id });
35170
+ const isAskReply = replyToAsk !== undefined;
35135
35171
  const adviceLines = renderAdvice(input.tool, commentOwner.label, comment.advice, {
35136
- isAskReply: replyToAsk !== undefined,
35137
- replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false)
35172
+ isAskReply,
35173
+ replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false),
35174
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, comment.issue_key, comment.advice, isAskReply)
35138
35175
  });
35139
35176
  if (replyToAsk !== undefined) {
35140
35177
  const askState = comment.ask_waiting_on === undefined ? "" : `; ask now waiting on ${comment.ask_waiting_on}`;
@@ -35238,7 +35275,9 @@ async function messageCommand(context) {
35238
35275
  actor
35239
35276
  });
35240
35277
  const messageRef = dispatchChildRef(dispatchIssueRef(issueKey), "message", message.id);
35241
- const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {});
35278
+ const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {
35279
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, issueKey, message.advice)
35280
+ });
35242
35281
  return {
35243
35282
  text: [
35244
35283
  `Posted message ${message.id} (${messageRef})${await notSubscribed(issueTopic(issueKey), input.subscriptions)}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "6.31.0",
3
+ "version": "6.31.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",