@sjawhar/pi-envoy 17.28.0 → 17.28.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.
- package/dist/dispatch.js +34 -11
- package/dist/envoy.js +35 -12
- package/package.json +1 -1
package/dist/dispatch.js
CHANGED
|
@@ -20923,22 +20923,35 @@ function anchor(artifact, args) {
|
|
|
20923
20923
|
const occurrence = optionalNumber(args, "occurrence");
|
|
20924
20924
|
return { artifact: artifact.id, quote, ...occurrence === undefined ? {} : { occurrence } };
|
|
20925
20925
|
}
|
|
20926
|
-
function
|
|
20926
|
+
function documentPlaysPlan(artifact) {
|
|
20927
|
+
return artifact.role === "plan" || (artifact.role ?? "") === "" && typeof artifact.issue_key === "string" && artifact.slug === "plan-md";
|
|
20928
|
+
}
|
|
20929
|
+
function approvalLine(artifact, issueClosed) {
|
|
20927
20930
|
const approval = artifact.approval;
|
|
20928
20931
|
if (approval === undefined || approval.state === "draft")
|
|
20929
20932
|
return;
|
|
20930
20933
|
const content = approval.content_sha256 === undefined ? "" : `, content sha256:${approval.content_sha256}${approval.content_sha256_source === "backfill" ? " (hashed after approval)" : ""}`;
|
|
20934
|
+
const by = approval.by?.id ?? "unknown";
|
|
20935
|
+
const approver = approval.kind === "plan_review" ? `plan review (${by})` : by;
|
|
20931
20936
|
switch (approval.state) {
|
|
20932
20937
|
case "awaiting": {
|
|
20933
20938
|
const turn = approval.waiting_on === undefined ? "" : `, waiting on ${approval.waiting_on}`;
|
|
20934
20939
|
return `Approval: awaiting${turn} (requested by ${approval.requested_by?.id ?? "unknown"}, ask ${approval.ask_id ?? "?"})`;
|
|
20935
20940
|
}
|
|
20936
20941
|
case "approved":
|
|
20937
|
-
return `Approval: approved v${approval.version} by ${
|
|
20938
|
-
case "stale":
|
|
20939
|
-
|
|
20942
|
+
return `Approval: approved v${approval.version} by ${approver}${content}`;
|
|
20943
|
+
case "stale": {
|
|
20944
|
+
const changed = `Approval: approved v${approval.version} by ${approver}, changed since (now v${approval.latest_version})`;
|
|
20945
|
+
if (issueClosed) {
|
|
20946
|
+
return `${changed} - its issue is closed, and Dispatch records no approval of a closed issue's document${content}`;
|
|
20947
|
+
}
|
|
20948
|
+
if (documentPlaysPlan(artifact)) {
|
|
20949
|
+
return `${changed} - a plan review of this version records a new approval with dispatch plan-approve${content}`;
|
|
20950
|
+
}
|
|
20951
|
+
return `${changed} - the human's own answer to a decision block carries the approval when that answer is the whole change since v${approval.version}; for any other change, request approval again once the human has agreed to every point in this version, with a --summary naming what changed since v${approval.version}${content}`;
|
|
20952
|
+
}
|
|
20940
20953
|
case "changes_requested":
|
|
20941
|
-
return `Approval: changes requested on v${approval.version} by ${
|
|
20954
|
+
return `Approval: changes requested on v${approval.version} by ${by}: ${approval.reason ?? ""}${content}`;
|
|
20942
20955
|
default:
|
|
20943
20956
|
return;
|
|
20944
20957
|
}
|
|
@@ -21376,7 +21389,7 @@ function renderAdvice(tool, key, advice, opts) {
|
|
|
21376
21389
|
const named = gates.map((gate) => `${gate.issue}, step ${gate.step}`).join("; ");
|
|
21377
21390
|
parts.push(`A Legion design gate records this document, so every READY in ${gates.length === 1 ? "its" : "each"} tree is refused until that approval comes back: ${named}.`);
|
|
21378
21391
|
}
|
|
21379
|
-
parts.push("Meant to change the approved design? Request approval with `dispatch request-approval`. Meant a correction beside it? Tell the tree's architect, and keep the next one in a comment or in the plan.");
|
|
21392
|
+
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 tree's architect, and keep the next one in a comment or in the plan.");
|
|
21380
21393
|
lines.push(parts.join(" "));
|
|
21381
21394
|
}
|
|
21382
21395
|
if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
|
|
@@ -22527,7 +22540,9 @@ async function docEditCommand(context) {
|
|
|
22527
22540
|
configUrl: linkBase
|
|
22528
22541
|
});
|
|
22529
22542
|
const declinedLines = resolved.issue === undefined ? [] : declinedAskLines(edited.advice, resolved.issue.key, linkBase);
|
|
22530
|
-
const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, resolvedTopic(resolved).label, edited.advice, {
|
|
22543
|
+
const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, resolvedTopic(resolved).label, edited.advice, {
|
|
22544
|
+
isPlan: documentPlaysPlan(resolved.artifact)
|
|
22545
|
+
}));
|
|
22531
22546
|
const written = edited.written;
|
|
22532
22547
|
const writtenLines = written === undefined || written === "" ? [] : [written];
|
|
22533
22548
|
const tokenTrailer = edited.token === undefined ? [] : [`Document token: ${edited.token}`];
|
|
@@ -22599,7 +22614,7 @@ ${trailer.join(`
|
|
|
22599
22614
|
if (threadsResult.status === "rejected")
|
|
22600
22615
|
throw threadsResult.reason;
|
|
22601
22616
|
const threads = threadsResult.value;
|
|
22602
|
-
const approval = approvalLine(resolved.artifact);
|
|
22617
|
+
const approval = approvalLine(resolved.artifact, typeof resolved.issue?.closed_at === "string");
|
|
22603
22618
|
const trailer = [
|
|
22604
22619
|
..."token" in document && document.token !== undefined ? [`Document token: ${document.token}`] : [],
|
|
22605
22620
|
..."sha256" in document && document.sha256 !== undefined ? [`Content: sha256:${document.sha256}`] : [],
|
|
@@ -22804,7 +22819,8 @@ async function artifactCommand(context) {
|
|
|
22804
22819
|
const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
|
|
22805
22820
|
const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
|
|
22806
22821
|
const adviceLines = renderAdvice(input.tool, uploadOwner.label, result.advice, {
|
|
22807
|
-
isPrimarySpec: result.artifact.primary || result.artifact.name === "spec.md"
|
|
22822
|
+
isPrimarySpec: result.artifact.primary || result.artifact.name === "spec.md",
|
|
22823
|
+
isPlan: documentPlaysPlan(result.artifact)
|
|
22808
22824
|
});
|
|
22809
22825
|
return {
|
|
22810
22826
|
text: [
|
|
@@ -23017,7 +23033,7 @@ function issueSummary(issue, events, references, graph, linkBase, coverage, agen
|
|
|
23017
23033
|
const links = issue.external_links ?? [];
|
|
23018
23034
|
const members = typeof references === "string" ? [] : references.members ?? [];
|
|
23019
23035
|
const spec = issue.artifacts?.find((artifact) => artifact.primary);
|
|
23020
|
-
const specApproval = spec === undefined ? undefined : approvalLine(spec);
|
|
23036
|
+
const specApproval = spec === undefined ? undefined : approvalLine(spec, typeof issue.closed_at === "string");
|
|
23021
23037
|
if (issue.priority === undefined)
|
|
23022
23038
|
throw new Error("Dispatch issue is missing priority");
|
|
23023
23039
|
if (issue.assignee === undefined)
|
|
@@ -23095,6 +23111,13 @@ function eventHead(event) {
|
|
|
23095
23111
|
return textHead(event.payload.body);
|
|
23096
23112
|
case "artifact.version":
|
|
23097
23113
|
return textHead(`${event.payload.name} v${event.payload.version.number}${event.payload.version.summary ? `: ${event.payload.version.summary}` : ""}`);
|
|
23114
|
+
case "artifact.approved":
|
|
23115
|
+
case "artifact.changes_requested": {
|
|
23116
|
+
const { name, version, kind, reason } = event.payload;
|
|
23117
|
+
const verb = event.type === "artifact.approved" ? "approved" : "changes requested";
|
|
23118
|
+
const reviewer = kind === "plan_review" ? " by plan review" : kind === "person" ? " by a person" : "";
|
|
23119
|
+
return textHead(`${name} v${version} ${verb}${reviewer}${reason ? `: ${reason}` : ""}`);
|
|
23120
|
+
}
|
|
23098
23121
|
case "artifact.human_edited":
|
|
23099
23122
|
return textHead(humanEditHead(event.payload));
|
|
23100
23123
|
case "issue.created": {
|
|
@@ -24013,7 +24036,7 @@ async function readCommand(context) {
|
|
|
24013
24036
|
const { artifact } = resolved;
|
|
24014
24037
|
const ownerKey = resolved.issue?.key ?? artifact.project;
|
|
24015
24038
|
const documentRef = dispatchDocumentRef(ownerKey, artifact.slug);
|
|
24016
|
-
const approval = approvalLine(artifact);
|
|
24039
|
+
const approval = approvalLine(artifact, typeof resolved.issue?.closed_at === "string");
|
|
24017
24040
|
return {
|
|
24018
24041
|
text: [
|
|
24019
24042
|
`Document: ${ownerKey} / ${artifact.name}`,
|
package/dist/envoy.js
CHANGED
|
@@ -42185,22 +42185,35 @@ function anchor(artifact, args) {
|
|
|
42185
42185
|
const occurrence = optionalNumber(args, "occurrence");
|
|
42186
42186
|
return { artifact: artifact.id, quote, ...occurrence === undefined ? {} : { occurrence } };
|
|
42187
42187
|
}
|
|
42188
|
-
function
|
|
42188
|
+
function documentPlaysPlan(artifact) {
|
|
42189
|
+
return artifact.role === "plan" || (artifact.role ?? "") === "" && typeof artifact.issue_key === "string" && artifact.slug === "plan-md";
|
|
42190
|
+
}
|
|
42191
|
+
function approvalLine(artifact, issueClosed) {
|
|
42189
42192
|
const approval = artifact.approval;
|
|
42190
42193
|
if (approval === undefined || approval.state === "draft")
|
|
42191
42194
|
return;
|
|
42192
42195
|
const content = approval.content_sha256 === undefined ? "" : `, content sha256:${approval.content_sha256}${approval.content_sha256_source === "backfill" ? " (hashed after approval)" : ""}`;
|
|
42196
|
+
const by = approval.by?.id ?? "unknown";
|
|
42197
|
+
const approver = approval.kind === "plan_review" ? `plan review (${by})` : by;
|
|
42193
42198
|
switch (approval.state) {
|
|
42194
42199
|
case "awaiting": {
|
|
42195
42200
|
const turn = approval.waiting_on === undefined ? "" : `, waiting on ${approval.waiting_on}`;
|
|
42196
42201
|
return `Approval: awaiting${turn} (requested by ${approval.requested_by?.id ?? "unknown"}, ask ${approval.ask_id ?? "?"})`;
|
|
42197
42202
|
}
|
|
42198
42203
|
case "approved":
|
|
42199
|
-
return `Approval: approved v${approval.version} by ${
|
|
42200
|
-
case "stale":
|
|
42201
|
-
|
|
42204
|
+
return `Approval: approved v${approval.version} by ${approver}${content}`;
|
|
42205
|
+
case "stale": {
|
|
42206
|
+
const changed = `Approval: approved v${approval.version} by ${approver}, changed since (now v${approval.latest_version})`;
|
|
42207
|
+
if (issueClosed) {
|
|
42208
|
+
return `${changed} - its issue is closed, and Dispatch records no approval of a closed issue's document${content}`;
|
|
42209
|
+
}
|
|
42210
|
+
if (documentPlaysPlan(artifact)) {
|
|
42211
|
+
return `${changed} - a plan review of this version records a new approval with dispatch plan-approve${content}`;
|
|
42212
|
+
}
|
|
42213
|
+
return `${changed} - the human's own answer to a decision block carries the approval when that answer is the whole change since v${approval.version}; for any other change, request approval again once the human has agreed to every point in this version, with a --summary naming what changed since v${approval.version}${content}`;
|
|
42214
|
+
}
|
|
42202
42215
|
case "changes_requested":
|
|
42203
|
-
return `Approval: changes requested on v${approval.version} by ${
|
|
42216
|
+
return `Approval: changes requested on v${approval.version} by ${by}: ${approval.reason ?? ""}${content}`;
|
|
42204
42217
|
default:
|
|
42205
42218
|
return;
|
|
42206
42219
|
}
|
|
@@ -42606,7 +42619,7 @@ function renderAdvice(tool, key, advice, opts) {
|
|
|
42606
42619
|
const named = gates.map((gate) => `${gate.issue}, step ${gate.step}`).join("; ");
|
|
42607
42620
|
parts.push(`A Legion design gate records this document, so every READY in ${gates.length === 1 ? "its" : "each"} tree is refused until that approval comes back: ${named}.`);
|
|
42608
42621
|
}
|
|
42609
|
-
parts.push("Meant to change the approved design? Request approval with `dispatch request-approval`. Meant a correction beside it? Tell the tree's architect, and keep the next one in a comment or in the plan.");
|
|
42622
|
+
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 tree's architect, and keep the next one in a comment or in the plan.");
|
|
42610
42623
|
lines.push(parts.join(" "));
|
|
42611
42624
|
}
|
|
42612
42625
|
if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
|
|
@@ -43718,7 +43731,9 @@ async function docEditCommand(context) {
|
|
|
43718
43731
|
configUrl: linkBase
|
|
43719
43732
|
});
|
|
43720
43733
|
const declinedLines = resolved.issue === undefined ? [] : declinedAskLines(edited.advice, resolved.issue.key, linkBase);
|
|
43721
|
-
const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, resolvedTopic(resolved).label, edited.advice, {
|
|
43734
|
+
const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, resolvedTopic(resolved).label, edited.advice, {
|
|
43735
|
+
isPlan: documentPlaysPlan(resolved.artifact)
|
|
43736
|
+
}));
|
|
43722
43737
|
const written = edited.written;
|
|
43723
43738
|
const writtenLines = written === undefined || written === "" ? [] : [written];
|
|
43724
43739
|
const tokenTrailer = edited.token === undefined ? [] : [`Document token: ${edited.token}`];
|
|
@@ -43790,7 +43805,7 @@ ${trailer.join(`
|
|
|
43790
43805
|
if (threadsResult.status === "rejected")
|
|
43791
43806
|
throw threadsResult.reason;
|
|
43792
43807
|
const threads = threadsResult.value;
|
|
43793
|
-
const approval = approvalLine(resolved.artifact);
|
|
43808
|
+
const approval = approvalLine(resolved.artifact, typeof resolved.issue?.closed_at === "string");
|
|
43794
43809
|
const trailer = [
|
|
43795
43810
|
..."token" in document && document.token !== undefined ? [`Document token: ${document.token}`] : [],
|
|
43796
43811
|
..."sha256" in document && document.sha256 !== undefined ? [`Content: sha256:${document.sha256}`] : [],
|
|
@@ -43995,7 +44010,8 @@ async function artifactCommand(context) {
|
|
|
43995
44010
|
const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
|
|
43996
44011
|
const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
|
|
43997
44012
|
const adviceLines = renderAdvice(input.tool, uploadOwner.label, result.advice, {
|
|
43998
|
-
isPrimarySpec: result.artifact.primary || result.artifact.name === "spec.md"
|
|
44013
|
+
isPrimarySpec: result.artifact.primary || result.artifact.name === "spec.md",
|
|
44014
|
+
isPlan: documentPlaysPlan(result.artifact)
|
|
43999
44015
|
});
|
|
44000
44016
|
return {
|
|
44001
44017
|
text: [
|
|
@@ -44208,7 +44224,7 @@ function issueSummary(issue, events, references, graph, linkBase, coverage, agen
|
|
|
44208
44224
|
const links = issue.external_links ?? [];
|
|
44209
44225
|
const members = typeof references === "string" ? [] : references.members ?? [];
|
|
44210
44226
|
const spec = issue.artifacts?.find((artifact) => artifact.primary);
|
|
44211
|
-
const specApproval = spec === undefined ? undefined : approvalLine(spec);
|
|
44227
|
+
const specApproval = spec === undefined ? undefined : approvalLine(spec, typeof issue.closed_at === "string");
|
|
44212
44228
|
if (issue.priority === undefined)
|
|
44213
44229
|
throw new Error("Dispatch issue is missing priority");
|
|
44214
44230
|
if (issue.assignee === undefined)
|
|
@@ -44286,6 +44302,13 @@ function eventHead(event) {
|
|
|
44286
44302
|
return textHead(event.payload.body);
|
|
44287
44303
|
case "artifact.version":
|
|
44288
44304
|
return textHead(`${event.payload.name} v${event.payload.version.number}${event.payload.version.summary ? `: ${event.payload.version.summary}` : ""}`);
|
|
44305
|
+
case "artifact.approved":
|
|
44306
|
+
case "artifact.changes_requested": {
|
|
44307
|
+
const { name, version, kind, reason } = event.payload;
|
|
44308
|
+
const verb = event.type === "artifact.approved" ? "approved" : "changes requested";
|
|
44309
|
+
const reviewer = kind === "plan_review" ? " by plan review" : kind === "person" ? " by a person" : "";
|
|
44310
|
+
return textHead(`${name} v${version} ${verb}${reviewer}${reason ? `: ${reason}` : ""}`);
|
|
44311
|
+
}
|
|
44289
44312
|
case "artifact.human_edited":
|
|
44290
44313
|
return textHead(humanEditHead(event.payload));
|
|
44291
44314
|
case "issue.created": {
|
|
@@ -45204,7 +45227,7 @@ async function readCommand(context) {
|
|
|
45204
45227
|
const { artifact } = resolved;
|
|
45205
45228
|
const ownerKey = resolved.issue?.key ?? artifact.project;
|
|
45206
45229
|
const documentRef = dispatchDocumentRef(ownerKey, artifact.slug);
|
|
45207
|
-
const approval = approvalLine(artifact);
|
|
45230
|
+
const approval = approvalLine(artifact, typeof resolved.issue?.closed_at === "string");
|
|
45208
45231
|
return {
|
|
45209
45232
|
text: [
|
|
45210
45233
|
`Document: ${ownerKey} / ${artifact.name}`,
|
|
@@ -47628,7 +47651,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
|
|
|
47628
47651
|
|
|
47629
47652
|
// package.json
|
|
47630
47653
|
var name = "@sjawhar/pi-envoy";
|
|
47631
|
-
var version2 = "17.28.
|
|
47654
|
+
var version2 = "17.28.1";
|
|
47632
47655
|
var package_default = {
|
|
47633
47656
|
name,
|
|
47634
47657
|
version: version2,
|