@sjawhar/pi-legion 19.28.0 → 19.28.2

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/legion.js CHANGED
@@ -22652,22 +22652,35 @@ function anchor(artifact, args) {
22652
22652
  const occurrence = optionalNumber(args, "occurrence");
22653
22653
  return { artifact: artifact.id, quote, ...occurrence === undefined ? {} : { occurrence } };
22654
22654
  }
22655
- function approvalLine(artifact) {
22655
+ function documentPlaysPlan(artifact) {
22656
+ return artifact.role === "plan" || (artifact.role ?? "") === "" && typeof artifact.issue_key === "string" && artifact.slug === "plan-md";
22657
+ }
22658
+ function approvalLine(artifact, issueClosed) {
22656
22659
  const approval = artifact.approval;
22657
22660
  if (approval === undefined || approval.state === "draft")
22658
22661
  return;
22659
22662
  const content = approval.content_sha256 === undefined ? "" : `, content sha256:${approval.content_sha256}${approval.content_sha256_source === "backfill" ? " (hashed after approval)" : ""}`;
22663
+ const by = approval.by?.id ?? "unknown";
22664
+ const approver = approval.kind === "plan_review" ? `plan review (${by})` : by;
22660
22665
  switch (approval.state) {
22661
22666
  case "awaiting": {
22662
22667
  const turn = approval.waiting_on === undefined ? "" : `, waiting on ${approval.waiting_on}`;
22663
22668
  return `Approval: awaiting${turn} (requested by ${approval.requested_by?.id ?? "unknown"}, ask ${approval.ask_id ?? "?"})`;
22664
22669
  }
22665
22670
  case "approved":
22666
- return `Approval: approved v${approval.version} by ${approval.by?.id ?? "unknown"}${content}`;
22667
- case "stale":
22668
- return `Approval: approved v${approval.version} by ${approval.by?.id ?? "unknown"}, changed since (now v${approval.latest_version}) - 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}`;
22671
+ return `Approval: approved v${approval.version} by ${approver}${content}`;
22672
+ case "stale": {
22673
+ const changed = `Approval: approved v${approval.version} by ${approver}, changed since (now v${approval.latest_version})`;
22674
+ if (issueClosed) {
22675
+ return `${changed} - its issue is closed, and Dispatch records no approval of a closed issue's document${content}`;
22676
+ }
22677
+ if (documentPlaysPlan(artifact)) {
22678
+ return `${changed} - a plan review of this version records a new approval with dispatch plan-approve${content}`;
22679
+ }
22680
+ 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}`;
22681
+ }
22669
22682
  case "changes_requested":
22670
- return `Approval: changes requested on v${approval.version} by ${approval.by?.id ?? "unknown"}: ${approval.reason ?? ""}${content}`;
22683
+ return `Approval: changes requested on v${approval.version} by ${by}: ${approval.reason ?? ""}${content}`;
22671
22684
  default:
22672
22685
  return;
22673
22686
  }
@@ -23035,7 +23048,7 @@ function renderAdvice(tool, key, advice, opts) {
23035
23048
  const named = gates.map((gate) => `${gate.issue}, step ${gate.step}`).join("; ");
23036
23049
  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}.`);
23037
23050
  }
23038
- 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.");
23051
+ 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.");
23039
23052
  lines.push(parts.join(" "));
23040
23053
  }
23041
23054
  if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
@@ -24164,7 +24177,9 @@ async function docEditCommand(context) {
24164
24177
  configUrl: linkBase
24165
24178
  });
24166
24179
  const declinedLines = resolved.issue === undefined ? [] : declinedAskLines(edited.advice, resolved.issue.key, linkBase);
24167
- const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, resolvedTopic(resolved).label, edited.advice, {}));
24180
+ const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, resolvedTopic(resolved).label, edited.advice, {
24181
+ isPlan: documentPlaysPlan(resolved.artifact)
24182
+ }));
24168
24183
  const written = edited.written;
24169
24184
  const writtenLines = written === undefined || written === "" ? [] : [written];
24170
24185
  const tokenTrailer = edited.token === undefined ? [] : [`Document token: ${edited.token}`];
@@ -24236,7 +24251,7 @@ ${trailer.join(`
24236
24251
  if (threadsResult.status === "rejected")
24237
24252
  throw threadsResult.reason;
24238
24253
  const threads = threadsResult.value;
24239
- const approval = approvalLine(resolved.artifact);
24254
+ const approval = approvalLine(resolved.artifact, typeof resolved.issue?.closed_at === "string");
24240
24255
  const trailer = [
24241
24256
  ..."token" in document && document.token !== undefined ? [`Document token: ${document.token}`] : [],
24242
24257
  ..."sha256" in document && document.sha256 !== undefined ? [`Content: sha256:${document.sha256}`] : [],
@@ -24441,7 +24456,8 @@ async function artifactCommand(context) {
24441
24456
  const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
24442
24457
  const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
24443
24458
  const adviceLines = renderAdvice(input.tool, uploadOwner.label, result.advice, {
24444
- isPrimarySpec: result.artifact.primary || result.artifact.name === "spec.md"
24459
+ isPrimarySpec: result.artifact.primary || result.artifact.name === "spec.md",
24460
+ isPlan: documentPlaysPlan(result.artifact)
24445
24461
  });
24446
24462
  return {
24447
24463
  text: [
@@ -24654,7 +24670,7 @@ function issueSummary(issue, events, references, graph, linkBase, coverage, agen
24654
24670
  const links = issue.external_links ?? [];
24655
24671
  const members = typeof references === "string" ? [] : references.members ?? [];
24656
24672
  const spec = issue.artifacts?.find((artifact) => artifact.primary);
24657
- const specApproval = spec === undefined ? undefined : approvalLine(spec);
24673
+ const specApproval = spec === undefined ? undefined : approvalLine(spec, typeof issue.closed_at === "string");
24658
24674
  if (issue.priority === undefined)
24659
24675
  throw new Error("Dispatch issue is missing priority");
24660
24676
  if (issue.assignee === undefined)
@@ -24732,6 +24748,13 @@ function eventHead(event) {
24732
24748
  return textHead(event.payload.body);
24733
24749
  case "artifact.version":
24734
24750
  return textHead(`${event.payload.name} v${event.payload.version.number}${event.payload.version.summary ? `: ${event.payload.version.summary}` : ""}`);
24751
+ case "artifact.approved":
24752
+ case "artifact.changes_requested": {
24753
+ const { name, version, kind, reason } = event.payload;
24754
+ const verb = event.type === "artifact.approved" ? "approved" : "changes requested";
24755
+ const reviewer = kind === "plan_review" ? " by plan review" : kind === "person" ? " by a person" : "";
24756
+ return textHead(`${name} v${version} ${verb}${reviewer}${reason ? `: ${reason}` : ""}`);
24757
+ }
24735
24758
  case "artifact.human_edited":
24736
24759
  return textHead(humanEditHead(event.payload));
24737
24760
  case "issue.created": {
@@ -25650,7 +25673,7 @@ async function readCommand(context) {
25650
25673
  const { artifact } = resolved;
25651
25674
  const ownerKey = resolved.issue?.key ?? artifact.project;
25652
25675
  const documentRef = dispatchDocumentRef(ownerKey, artifact.slug);
25653
- const approval = approvalLine(artifact);
25676
+ const approval = approvalLine(artifact, typeof resolved.issue?.closed_at === "string");
25654
25677
  return {
25655
25678
  text: [
25656
25679
  `Document: ${ownerKey} / ${artifact.name}`,
@@ -29720,7 +29743,7 @@ import { logger as logger3 } from "@oh-my-pi/pi-utils";
29720
29743
  // package.json
29721
29744
  var package_default = {
29722
29745
  name: "@sjawhar/pi-legion",
29723
- version: "19.28.0",
29746
+ version: "19.28.2",
29724
29747
  license: "Apache-2.0",
29725
29748
  type: "module",
29726
29749
  omp: {
@@ -51,9 +51,18 @@ Every path it cites is in cybermonklabs/legion.
51
51
 
52
52
  ```bash
53
53
  base=$(gh pr view <n> -R <owner>/<repo> --json baseRefName -q '.baseRefName | @json') && \
54
- jj -R "$LEGION_WORKSPACE" new legion/<KEY> "${base}@origin" -m "merge: resolve conflict against ${base}@origin"
54
+ jj -R "$LEGION_WORKSPACE" new legion/<KEY> "${base}@origin" -m "<message>"
55
55
  ```
56
56
 
57
+ `<message>` is written in the repository's own commit convention, read from the repository
58
+ itself: its commit-message check (a commitlint configuration or the workflow that lints
59
+ commits) where it has one, else its recent commits on the base. Where it uses Conventional
60
+ Commits, that is a listed type and the merge in words, for example
61
+ `chore(<scope>): merge <base> into <branch>`. Where neither shows a convention, it is the
62
+ merge in words alone, for example `Merge <base> into <branch>`. Never a fixed prefix of the
63
+ skill's own: a check that lints every commit of the pull request refuses a type its list does
64
+ not hold, and `merge` is in no Conventional Commits list.
65
+
57
66
  Merge from the bookmark, never from `@`: a `jj split` leaves `@` an empty, undescribed
58
67
  commit above the described one the bookmark already names, and `jj git push` refuses to push
59
68
  any commit without a description — merging from `@` drags that undescribed commit into the
@@ -66,7 +75,7 @@ Every path it cites is in cybermonklabs/legion.
66
75
  fast-forward and *Rewriting pushed commits* never applies.
67
76
  - **After a retarget.** Retargeting a pull request to a new base does not re-run Tests. Read
68
77
  `base` again and merge the bookmark onto it in one command
69
- (`base=$(gh pr view <n> -R <owner>/<repo> --json baseRefName -q '.baseRefName | @json') && jj -R "$LEGION_WORKSPACE" new legion/<KEY> "${base}@origin" -m "<message>"`) and push it the
78
+ (`base=$(gh pr view <n> -R <owner>/<repo> --json baseRefName -q '.baseRefName | @json') && jj -R "$LEGION_WORKSPACE" new legion/<KEY> "${base}@origin" -m "<message>"`, its `<message>` in the repository's own commit convention, as above) and push it the
70
79
  ordinary way — a genuine fast-forward, never `--allow-backwards` — so the new head runs Tests
71
80
  against the new merge result, and cite that run in the PR body.
72
81
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-legion",
3
- "version": "19.28.0",
3
+ "version": "19.28.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "omp": {