@sjawhar/pi-legion-envoy 1.55.1 → 1.56.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/dist/envoy.js CHANGED
@@ -32567,6 +32567,36 @@ function notSubscribed(owner) {
32567
32567
  function followsAsk(owner) {
32568
32568
  return `You follow this ask: its answer and replies reach you directly. For every event on ${owner.label}: envoy_subscribe ${owner.topic}`;
32569
32569
  }
32570
+ var triageAdviceShown = new Set;
32571
+ function renderAdvice(tool, key, advice, opts) {
32572
+ if (advice === undefined)
32573
+ return [];
32574
+ const hasIssueAdvice = advice.issue_status !== undefined;
32575
+ const openAsks = advice.your_open_asks;
32576
+ const writesSinceHuman = advice.session_writes_since_human;
32577
+ const lines = [];
32578
+ if (advice.decision_blocks === 0 && opts.isPrimarySpec === true && (tool === "dispatch_issue" || tool === "dispatch_artifact")) {
32579
+ lines.push('No decision blocks in this spec \u2014 nothing here reaches a human\'s inbox. Want human feedback? See the `dispatch` skill, "Decision blocks".');
32580
+ }
32581
+ if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
32582
+ const middle = writesSinceHuman >= 6 ? "Stop posting here until a human replies." : "Progress ledger or scratchpad? If so, stop.";
32583
+ lines.push(`You've sent ${writesSinceHuman} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
32584
+ }
32585
+ if (advice.issue_status === "triage" && tool !== "dispatch_issue" && !(tool === "dispatch_issue_update" && opts.setsStatus === true) && !triageAdviceShown.has(key)) {
32586
+ triageAdviceShown.add(key);
32587
+ lines.push(`${key} is still in triage \u2014 nobody can see its development status. See the \`dispatch\` skill, "Issue status is yours to move".`);
32588
+ }
32589
+ if (hasIssueAdvice && openAsks !== undefined && openAsks.length > 0 && (tool === "dispatch_message" || tool === "dispatch_doc_edit" || tool === "dispatch_issue_update" || tool === "dispatch_comment" && opts.replyToOwnAsk !== true)) {
32590
+ const askCount = Math.min(openAsks.length, 2);
32591
+ for (let index = 0;index < askCount; index += 1) {
32592
+ const ask = openAsks[index];
32593
+ if (ask === undefined)
32594
+ break;
32595
+ lines.push(`You still have an open ask on ${key}: "${ask.question.slice(0, 80)}" (${ask.id}). Still needed? See the \`dispatch\` skill, "Close what you opened".`);
32596
+ }
32597
+ }
32598
+ return lines;
32599
+ }
32570
32600
  function documentResultDetails(artifact) {
32571
32601
  return {
32572
32602
  project: artifact.project,
@@ -33455,9 +33485,19 @@ async function executeDispatchTool(input) {
33455
33485
  ...Array.isArray(labels) ? { labels } : {},
33456
33486
  actor
33457
33487
  });
33488
+ const adviceLines = renderAdvice(input.tool, created.key, created.advice, {
33489
+ isPrimarySpec: spec !== undefined
33490
+ });
33458
33491
  return {
33459
- text: `Created ${created.key}: ${created.title} ${notSubscribed(issueTopic(created.key))}`,
33460
- details: { issue: created.key }
33492
+ text: [
33493
+ `Created ${created.key}: ${created.title} ${notSubscribed(issueTopic(created.key))}`,
33494
+ ...adviceLines
33495
+ ].join(`
33496
+ `),
33497
+ details: {
33498
+ issue: created.key,
33499
+ ...created.advice === undefined ? {} : { advice: created.advice }
33500
+ }
33461
33501
  };
33462
33502
  } catch (error) {
33463
33503
  if (!(error instanceof DispatchServiceError) || error.code !== "POSSIBLE_DUPLICATE") {
@@ -33514,12 +33554,20 @@ async function executeDispatchTool(input) {
33514
33554
  ...parent === undefined ? [] : [after.parent === null ? "parent cleared" : `parent -> ${after.parent}`],
33515
33555
  ...components === undefined ? [] : [componentsChange(components, after.components)]
33516
33556
  ];
33557
+ const adviceLines = renderAdvice(input.tool, after.key, after.advice, {
33558
+ setsStatus: status !== undefined
33559
+ });
33517
33560
  return {
33518
- text: `${after.key}: ${changes.join("; ")} ${notSubscribed(issueTopic(after.key))}`,
33561
+ text: [
33562
+ `${after.key}: ${changes.join("; ")} ${notSubscribed(issueTopic(after.key))}`,
33563
+ ...adviceLines
33564
+ ].join(`
33565
+ `),
33519
33566
  details: {
33520
33567
  issue: after.key,
33521
33568
  status: after.status,
33522
- external_links: after.external_links.map((link) => link.url)
33569
+ external_links: after.external_links.map((link) => link.url),
33570
+ ...after.advice === undefined ? {} : { advice: after.advice }
33523
33571
  }
33524
33572
  };
33525
33573
  } catch (error) {
@@ -33650,10 +33698,18 @@ async function executeDispatchTool(input) {
33650
33698
  };
33651
33699
  const ask = resolved?.owner.kind === "project" ? await client.artifactAsk(resolved.artifact.id, askInput) : await client.ask(issue(), askInput);
33652
33700
  const askOwner = ask.issue_key !== null ? issueTopic(ask.issue_key) : resolved === undefined ? issueTopic(issue()) : documentTopic(resolved.artifact);
33701
+ const adviceLines = renderAdvice(input.tool, askOwner.label, ask.advice, {});
33653
33702
  return {
33654
- text: `Asked ${ask.id} on ${askOwner.label} (urgency ${ask.urgency}): ${ask.question}
33703
+ text: [
33704
+ `Asked ${ask.id} on ${askOwner.label} (urgency ${ask.urgency}): ${ask.question}
33655
33705
  ${followsAsk(askOwner)}`,
33656
- details: await followedAskDetails(client, ask, resolved?.artifact)
33706
+ ...adviceLines
33707
+ ].join(`
33708
+ `),
33709
+ details: {
33710
+ ...await followedAskDetails(client, ask, resolved?.artifact),
33711
+ ...ask.advice === undefined ? {} : { advice: ask.advice }
33712
+ }
33657
33713
  };
33658
33714
  }
33659
33715
  case "dispatch_edit_ask": {
@@ -33698,21 +33754,34 @@ ${followsAsk(askOwner)}`,
33698
33754
  const comment = resolved?.owner.kind === "project" ? await client.artifactComment(resolved.artifact.id, commentInput) : await client.comment(issue(), commentInput);
33699
33755
  const commentOwner = resolved === undefined ? issueTopic(issue()) : resolvedTopic(resolved);
33700
33756
  const commentDetails = resolved === undefined ? { issue: comment.issue_key, comment: comment.id } : writeResultDetails(resolved, { comment: comment.id });
33757
+ const adviceLines = renderAdvice(input.tool, commentOwner.label, comment.advice, {
33758
+ isAskReply: replyToAsk !== undefined,
33759
+ replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false)
33760
+ });
33701
33761
  if (replyToAsk !== undefined) {
33702
33762
  const askState = comment.turn === null ? "" : `; ask now waiting on ${comment.turn}`;
33703
33763
  return {
33704
- text: `Replied on ask ${replyToAsk} (comment ${comment.id}${askState}). ${followsAsk(commentOwner)}`,
33764
+ text: [
33765
+ `Replied on ask ${replyToAsk} (comment ${comment.id}${askState}). ${followsAsk(commentOwner)}`,
33766
+ ...adviceLines
33767
+ ].join(`
33768
+ `),
33705
33769
  details: {
33706
33770
  ...commentDetails,
33707
33771
  ask: replyToAsk,
33708
33772
  follows: { ask: replyToAsk },
33709
- ...comment.turn === null ? {} : { ask_waiting_on: comment.turn }
33773
+ ...comment.turn === null ? {} : { ask_waiting_on: comment.turn },
33774
+ ...comment.advice === undefined ? {} : { advice: comment.advice }
33710
33775
  }
33711
33776
  };
33712
33777
  }
33713
33778
  return {
33714
- text: `Posted comment ${comment.id} ${notSubscribed(commentOwner)}`,
33715
- details: commentDetails
33779
+ text: [`Posted comment ${comment.id} ${notSubscribed(commentOwner)}`, ...adviceLines].join(`
33780
+ `),
33781
+ details: {
33782
+ ...commentDetails,
33783
+ ...comment.advice === undefined ? {} : { advice: comment.advice }
33784
+ }
33716
33785
  };
33717
33786
  }
33718
33787
  case "dispatch_suggest": {
@@ -33742,9 +33811,18 @@ ${followsAsk(askOwner)}`,
33742
33811
  actor
33743
33812
  });
33744
33813
  const messageRef = dispatchChildRef(dispatchIssueRef(issueKey), "message", message.id);
33814
+ const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {});
33745
33815
  return {
33746
- text: `Posted message ${message.id} (${messageRef}) ${notSubscribed(issueTopic(issueKey))}`,
33747
- details: { issue: issueKey, message: message.id }
33816
+ text: [
33817
+ `Posted message ${message.id} (${messageRef}) ${notSubscribed(issueTopic(issueKey))}`,
33818
+ ...adviceLines
33819
+ ].join(`
33820
+ `),
33821
+ details: {
33822
+ issue: issueKey,
33823
+ message: message.id,
33824
+ ...message.advice === undefined ? {} : { advice: message.advice }
33825
+ }
33748
33826
  };
33749
33827
  }
33750
33828
  case "dispatch_doc_edit": {
@@ -33762,11 +33840,14 @@ ${followsAsk(askOwner)}`,
33762
33840
  const retyped = ops.filter((operation) => operation.op === "retype").length;
33763
33841
  const versionText = edited.version === null ? "no new version" : `version ${edited.version.number}`;
33764
33842
  const applied = retyped === 0 ? `Applied ${edited.applied} ops (${versionText})` : `Applied ${edited.applied} ops; retyped ${retyped} block${retyped === 1 ? "" : "s"} (${versionText})`;
33843
+ const adviceLines = renderAdvice(input.tool, resolvedTopic(resolved).label, edited.advice, {});
33765
33844
  return {
33766
- text: `${applied} ${notSubscribed(resolvedTopic(resolved))}`,
33845
+ text: [`${applied} ${notSubscribed(resolvedTopic(resolved))}`, ...adviceLines].join(`
33846
+ `),
33767
33847
  details: writeResultDetails(resolved, {
33768
33848
  applied: edited.applied,
33769
- ...edited.version === null ? {} : { version: edited.version.number }
33849
+ ...edited.version === null ? {} : { version: edited.version.number },
33850
+ ...edited.advice === undefined ? {} : { advice: edited.advice }
33770
33851
  })
33771
33852
  };
33772
33853
  }
@@ -33838,15 +33919,24 @@ ${trailer.join(`
33838
33919
  const result = artifactOwner.kind === "project" ? await client.projectArtifact(artifactOwner.project, artifactInput) : await client.artifact(issue(), artifactInput);
33839
33920
  const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
33840
33921
  const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
33922
+ const adviceLines = renderAdvice(input.tool, uploadOwner.label, result.advice, {
33923
+ isPrimarySpec: result.artifact.primary || result.artifact.name === "spec.md"
33924
+ });
33841
33925
  return {
33842
- text: `Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef}) ${notSubscribed(uploadOwner)}`,
33926
+ text: [
33927
+ `Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef}) ${notSubscribed(uploadOwner)}`,
33928
+ ...adviceLines
33929
+ ].join(`
33930
+ `),
33843
33931
  details: artifactOwner.kind === "project" ? {
33844
33932
  ...documentResultDetails(result.artifact),
33845
- version: result.version.number
33933
+ version: result.version.number,
33934
+ ...result.advice === undefined ? {} : { advice: result.advice }
33846
33935
  } : {
33847
33936
  issue: issue(),
33848
33937
  artifact: result.artifact.id,
33849
- version: result.version.number
33938
+ version: result.version.number,
33939
+ ...result.advice === undefined ? {} : { advice: result.advice }
33850
33940
  }
33851
33941
  };
33852
33942
  }
package/dist/legion.js CHANGED
@@ -16145,7 +16145,7 @@ import { logger } from "@oh-my-pi/pi-utils";
16145
16145
  // package.json
16146
16146
  var package_default = {
16147
16147
  name: "@sjawhar/pi-legion-envoy",
16148
- version: "1.55.1",
16148
+ version: "1.56.0",
16149
16149
  type: "module",
16150
16150
  omp: {
16151
16151
  extensions: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-legion-envoy",
3
- "version": "1.55.1",
3
+ "version": "1.56.0",
4
4
  "type": "module",
5
5
  "omp": {
6
6
  "extensions": [