@codyswann/lisa 8.1.0 → 8.2.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.
Files changed (237) hide show
  1. package/all/copy-overwrite/scripts/lib/npm-update-bun.mjs +8 -3
  2. package/all/copy-overwrite/scripts/lib/npm-update-cache-seed.mjs +145 -0
  3. package/all/copy-overwrite/scripts/lib/npm-update-helper-inventory.mjs +1 -0
  4. package/all/copy-overwrite/scripts/lib/npm-update-prepare.mjs +34 -6
  5. package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +14 -3
  6. package/dist/core/lisa-owned-hash-ledger.json +24 -2
  7. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  8. package/dist/core/upstream-evidence-manifest.json +158 -17
  9. package/package.json +4 -4
  10. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  11. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  12. package/plugins/lisa/.codex-plugin/scripts/queue-contract-resolution.mjs +583 -0
  13. package/plugins/lisa/.codex-plugin/scripts/ready-queue-order.mjs +99 -25
  14. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-comment.mjs +185 -0
  15. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-confirm.mjs +130 -0
  16. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-edges.mjs +466 -0
  17. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-pending.mjs +257 -0
  18. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-restore.mjs +180 -0
  19. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-summary.mjs +222 -0
  20. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-sweep.mjs +394 -0
  21. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-verify.mjs +193 -0
  22. package/plugins/lisa/.codex-plugin/skills/lisa-atlassian-access/SKILL.md +1 -0
  23. package/plugins/lisa/.codex-plugin/skills/lisa-github-build-intake/SKILL.md +2 -7
  24. package/plugins/lisa/.codex-plugin/skills/lisa-jira-build-intake/SKILL.md +2 -0
  25. package/plugins/lisa/.codex-plugin/skills/lisa-linear-access/SKILL.md +44 -0
  26. package/plugins/lisa/.codex-plugin/skills/lisa-linear-build-intake/SKILL.md +2 -0
  27. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +127 -2
  28. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  29. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  30. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  31. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  32. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  33. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  34. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  35. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  36. package/plugins/lisa/scripts/ready-queue-order.mjs +99 -25
  37. package/plugins/lisa/scripts/stale-blocker-comment.mjs +185 -0
  38. package/plugins/lisa/scripts/stale-blocker-confirm.mjs +130 -0
  39. package/plugins/lisa/scripts/stale-blocker-edges.mjs +466 -0
  40. package/plugins/lisa/scripts/stale-blocker-pending.mjs +257 -0
  41. package/plugins/lisa/scripts/stale-blocker-restore.mjs +180 -0
  42. package/plugins/lisa/scripts/stale-blocker-summary.mjs +222 -0
  43. package/plugins/lisa/scripts/stale-blocker-sweep.mjs +394 -0
  44. package/plugins/lisa/scripts/stale-blocker-verify.mjs +193 -0
  45. package/plugins/lisa/skills/lisa-atlassian-access/SKILL.md +1 -0
  46. package/plugins/lisa/skills/lisa-github-build-intake/SKILL.md +2 -7
  47. package/plugins/lisa/skills/lisa-jira-build-intake/SKILL.md +2 -0
  48. package/plugins/lisa/skills/lisa-linear-access/SKILL.md +44 -0
  49. package/plugins/lisa/skills/lisa-linear-build-intake/SKILL.md +2 -0
  50. package/plugins/lisa/skills/lisa-session-manager/SKILL.md +127 -2
  51. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  52. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  53. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  54. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  55. package/plugins/lisa/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  56. package/plugins/lisa/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  57. package/plugins/lisa/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  58. package/plugins/lisa/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  59. package/plugins/lisa-agy/plugin.json +1 -1
  60. package/plugins/lisa-agy/scripts/ready-queue-order.mjs +99 -25
  61. package/plugins/lisa-agy/scripts/stale-blocker-comment.mjs +185 -0
  62. package/plugins/lisa-agy/scripts/stale-blocker-confirm.mjs +130 -0
  63. package/plugins/lisa-agy/scripts/stale-blocker-edges.mjs +466 -0
  64. package/plugins/lisa-agy/scripts/stale-blocker-pending.mjs +257 -0
  65. package/plugins/lisa-agy/scripts/stale-blocker-restore.mjs +180 -0
  66. package/plugins/lisa-agy/scripts/stale-blocker-summary.mjs +222 -0
  67. package/plugins/lisa-agy/scripts/stale-blocker-sweep.mjs +394 -0
  68. package/plugins/lisa-agy/scripts/stale-blocker-verify.mjs +193 -0
  69. package/plugins/lisa-agy/skills/lisa-atlassian-access/SKILL.md +1 -0
  70. package/plugins/lisa-agy/skills/lisa-github-build-intake/SKILL.md +2 -7
  71. package/plugins/lisa-agy/skills/lisa-jira-build-intake/SKILL.md +2 -0
  72. package/plugins/lisa-agy/skills/lisa-linear-access/SKILL.md +44 -0
  73. package/plugins/lisa-agy/skills/lisa-linear-build-intake/SKILL.md +2 -0
  74. package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +127 -2
  75. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  76. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  77. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  78. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  79. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  80. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  81. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  82. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  83. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  84. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  85. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  86. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  87. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  88. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  89. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  90. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  91. package/plugins/lisa-copilot/scripts/ready-queue-order.mjs +99 -25
  92. package/plugins/lisa-copilot/scripts/stale-blocker-comment.mjs +185 -0
  93. package/plugins/lisa-copilot/scripts/stale-blocker-confirm.mjs +130 -0
  94. package/plugins/lisa-copilot/scripts/stale-blocker-edges.mjs +466 -0
  95. package/plugins/lisa-copilot/scripts/stale-blocker-pending.mjs +257 -0
  96. package/plugins/lisa-copilot/scripts/stale-blocker-restore.mjs +180 -0
  97. package/plugins/lisa-copilot/scripts/stale-blocker-summary.mjs +222 -0
  98. package/plugins/lisa-copilot/scripts/stale-blocker-sweep.mjs +394 -0
  99. package/plugins/lisa-copilot/scripts/stale-blocker-verify.mjs +193 -0
  100. package/plugins/lisa-copilot/skills/lisa-atlassian-access/SKILL.md +1 -0
  101. package/plugins/lisa-copilot/skills/lisa-github-build-intake/SKILL.md +2 -7
  102. package/plugins/lisa-copilot/skills/lisa-jira-build-intake/SKILL.md +2 -0
  103. package/plugins/lisa-copilot/skills/lisa-linear-access/SKILL.md +44 -0
  104. package/plugins/lisa-copilot/skills/lisa-linear-build-intake/SKILL.md +2 -0
  105. package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +127 -2
  106. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  107. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  108. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  109. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  110. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  111. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  112. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  113. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  114. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  115. package/plugins/lisa-cursor/scripts/ready-queue-order.mjs +99 -25
  116. package/plugins/lisa-cursor/scripts/stale-blocker-comment.mjs +185 -0
  117. package/plugins/lisa-cursor/scripts/stale-blocker-confirm.mjs +130 -0
  118. package/plugins/lisa-cursor/scripts/stale-blocker-edges.mjs +466 -0
  119. package/plugins/lisa-cursor/scripts/stale-blocker-pending.mjs +257 -0
  120. package/plugins/lisa-cursor/scripts/stale-blocker-restore.mjs +180 -0
  121. package/plugins/lisa-cursor/scripts/stale-blocker-summary.mjs +222 -0
  122. package/plugins/lisa-cursor/scripts/stale-blocker-sweep.mjs +394 -0
  123. package/plugins/lisa-cursor/scripts/stale-blocker-verify.mjs +193 -0
  124. package/plugins/lisa-cursor/skills/lisa-atlassian-access/SKILL.md +1 -0
  125. package/plugins/lisa-cursor/skills/lisa-github-build-intake/SKILL.md +2 -7
  126. package/plugins/lisa-cursor/skills/lisa-jira-build-intake/SKILL.md +2 -0
  127. package/plugins/lisa-cursor/skills/lisa-linear-access/SKILL.md +44 -0
  128. package/plugins/lisa-cursor/skills/lisa-linear-build-intake/SKILL.md +2 -0
  129. package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +127 -2
  130. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  131. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  132. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  133. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  134. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  135. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  136. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  137. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  138. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  139. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  140. package/plugins/lisa-devin/scripts/ready-queue-order.mjs +99 -25
  141. package/plugins/lisa-devin/scripts/stale-blocker-comment.mjs +185 -0
  142. package/plugins/lisa-devin/scripts/stale-blocker-confirm.mjs +130 -0
  143. package/plugins/lisa-devin/scripts/stale-blocker-edges.mjs +466 -0
  144. package/plugins/lisa-devin/scripts/stale-blocker-pending.mjs +257 -0
  145. package/plugins/lisa-devin/scripts/stale-blocker-restore.mjs +180 -0
  146. package/plugins/lisa-devin/scripts/stale-blocker-summary.mjs +222 -0
  147. package/plugins/lisa-devin/scripts/stale-blocker-sweep.mjs +394 -0
  148. package/plugins/lisa-devin/scripts/stale-blocker-verify.mjs +193 -0
  149. package/plugins/lisa-devin/skills/lisa-atlassian-access/SKILL.md +1 -0
  150. package/plugins/lisa-devin/skills/lisa-github-build-intake/SKILL.md +2 -7
  151. package/plugins/lisa-devin/skills/lisa-jira-build-intake/SKILL.md +2 -0
  152. package/plugins/lisa-devin/skills/lisa-linear-access/SKILL.md +44 -0
  153. package/plugins/lisa-devin/skills/lisa-linear-build-intake/SKILL.md +2 -0
  154. package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +127 -2
  155. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  156. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  157. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  158. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  159. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  160. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  161. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  162. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  163. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  164. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  165. package/plugins/lisa-expo-agy/plugin.json +1 -1
  166. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  167. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  168. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  169. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  170. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  171. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  172. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  173. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  174. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  175. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  176. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  177. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  178. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  179. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  180. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  181. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  182. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  183. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  184. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  185. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  186. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  187. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  188. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  189. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  190. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  191. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  192. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  193. package/plugins/lisa-rails-agy/plugin.json +1 -1
  194. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  195. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  196. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  197. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  198. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  199. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  200. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  201. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  202. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  203. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  204. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  205. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  206. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  207. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  208. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  209. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  210. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  211. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  212. package/plugins/src/base/scripts/ready-queue-order.mjs +99 -25
  213. package/plugins/src/base/scripts/stale-blocker-comment.mjs +185 -0
  214. package/plugins/src/base/scripts/stale-blocker-confirm.mjs +130 -0
  215. package/plugins/src/base/scripts/stale-blocker-edges.mjs +466 -0
  216. package/plugins/src/base/scripts/stale-blocker-pending.mjs +257 -0
  217. package/plugins/src/base/scripts/stale-blocker-restore.mjs +180 -0
  218. package/plugins/src/base/scripts/stale-blocker-summary.mjs +222 -0
  219. package/plugins/src/base/scripts/stale-blocker-sweep.mjs +394 -0
  220. package/plugins/src/base/scripts/stale-blocker-verify.mjs +193 -0
  221. package/plugins/src/base/skills/lisa-atlassian-access/SKILL.md +1 -0
  222. package/plugins/src/base/skills/lisa-github-build-intake/SKILL.md +2 -7
  223. package/plugins/src/base/skills/lisa-jira-build-intake/SKILL.md +2 -0
  224. package/plugins/src/base/skills/lisa-linear-access/SKILL.md +44 -0
  225. package/plugins/src/base/skills/lisa-linear-build-intake/SKILL.md +2 -0
  226. package/plugins/src/base/skills/lisa-session-manager/SKILL.md +127 -2
  227. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  228. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  229. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  230. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  231. package/plugins/src/base/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  232. package/plugins/src/base/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  233. package/plugins/src/base/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  234. package/plugins/src/base/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  235. package/scripts/record-npm-update-dual-lock-seed.mjs +203 -0
  236. package/scripts/two-channel-couplings.json +1 -1
  237. package/typescript/copy-overwrite/.prettierignore +1 -0
@@ -0,0 +1,185 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The operator comment and marker dedupe for the stale-link sweep
4
+ * (CodySwannGT/lisa#5065), split from `stale-blocker-sweep.mjs`.
5
+ *
6
+ * The comment is read by a non-technical operator, so it says in plain words
7
+ * which links went and why, which blockers still hold the item, and which
8
+ * could not be opened. It starts with the prefix of whoever posts it (the
9
+ * session manager, or build intake on a runtime without one), and ends with
10
+ * one `[lisa-stale-blocker-link] blocker=<ref>` marker per removed link.
11
+ * @module stale-blocker-comment
12
+ */
13
+
14
+ import { adfText } from "./ready-queue-order.mjs";
15
+
16
+ /** Visible marker, one per removed blocker, so a re-run never re-comments. */
17
+ export const STALE_LINK_MARKER = "[lisa-stale-blocker-link]";
18
+
19
+ /** Who may post the comment, and the prefix each one posts under. */
20
+ export const STALE_LINK_POSTERS = Object.freeze({
21
+ "session-manager": "[lisa-session-manager]",
22
+ "build-intake": "[claude-build-intake]",
23
+ });
24
+
25
+ /**
26
+ * The marker line for one blocker.
27
+ * @param {string} blockerRef
28
+ * @returns {string}
29
+ */
30
+ export const markerLine = blockerRef =>
31
+ `${STALE_LINK_MARKER} blocker=${blockerRef}`;
32
+
33
+ /**
34
+ * An item's comments as one flat `{ body }` list, whatever envelope the
35
+ * vendor read used: a flat array (`comments: [{ body }]`), Linear's
36
+ * connection (`comments: { nodes: [...] }`), or Jira's issue field
37
+ * (`fields.comment.comments`). A comment given as a bare string is a body.
38
+ * Anything else is skipped, never thrown on, so a marker in any of these
39
+ * shapes is always found.
40
+ * @param {Record<string, any> | null | undefined} raw - The raw item
41
+ * @returns {{ body: unknown }[]}
42
+ */
43
+ export function commentsOf(raw) {
44
+ const list = value => {
45
+ if (Array.isArray(value)) return value;
46
+ if (Array.isArray(value?.nodes)) return value.nodes;
47
+ if (Array.isArray(value?.comments)) return value.comments;
48
+ return [];
49
+ };
50
+ return [...list(raw?.comments), ...list(raw?.fields?.comment)]
51
+ .map(comment => (typeof comment === "string" ? { body: comment } : comment))
52
+ .filter(comment => comment && typeof comment === "object");
53
+ }
54
+
55
+ /**
56
+ * Blockers this item's comments already record as removed. A Jira comment
57
+ * body is Atlassian Document Format, so it is flattened to text first.
58
+ * @param {readonly { body?: unknown }[] | undefined} comments
59
+ * @returns {Set<string>}
60
+ */
61
+ export function markedBlockers(comments) {
62
+ const pattern = /\[lisa-stale-blocker-link\] blocker=(\S+)/g;
63
+ return new Set(
64
+ (Array.isArray(comments) ? comments : []).flatMap(comment =>
65
+ [...adfText(comment?.body).matchAll(pattern)].map(match => match[1])
66
+ )
67
+ );
68
+ }
69
+
70
+ /**
71
+ * A plain-English list: "A", "A and B", "A, B and C".
72
+ * @param {readonly string[]} refs
73
+ * @returns {string}
74
+ */
75
+ const listOf = refs =>
76
+ refs.length < 2
77
+ ? refs.join("")
78
+ : `${refs.slice(0, -1).join(", ")} and ${refs[refs.length - 1]}`;
79
+
80
+ /**
81
+ * "is" or "are", "was" or "were", matched to how many refs there are.
82
+ * @param {readonly string[]} refs
83
+ * @param {string} one
84
+ * @param {string} many
85
+ * @returns {string}
86
+ */
87
+ const agree = (refs, one, many) => (refs.length === 1 ? one : many);
88
+
89
+ /**
90
+ * @param {readonly { blockerRef: string }[]} edges
91
+ * @returns {string[]} Unique blocker refs
92
+ */
93
+ const unique = edges => [...new Set(edges.map(edge => edge.blockerRef))];
94
+
95
+ /**
96
+ * The sentences about the links this sweep removes.
97
+ * @param {readonly { blockerRef: string, verdict: string }[]} stale
98
+ * @returns {string[]}
99
+ */
100
+ function removedSentences(stale) {
101
+ const finished = unique(stale.filter(e => e.verdict !== "cancelled"));
102
+ const cancelled = unique(stale.filter(e => e.verdict === "cancelled"));
103
+ const lines = [];
104
+ if (finished.length > 0) {
105
+ lines.push(
106
+ `This was marked as waiting on ${listOf(finished)}, which ${agree(finished, "is", "are")} done or closed, so ${agree(finished, "it", "they")} cannot hold this up.`
107
+ );
108
+ }
109
+ if (cancelled.length > 0) {
110
+ const lead = finished.length > 0 ? "It was also" : "This was";
111
+ lines.push(
112
+ `${lead} marked as waiting on ${listOf(cancelled)}, which ${agree(cancelled, "was", "were")} cancelled and will not be built, so ${agree(cancelled, "it", "they")} cannot hold this up.`
113
+ );
114
+ }
115
+ const removed = unique(stale);
116
+ lines.push(
117
+ `I removed ${agree(removed, "the link", "those links")}. Nothing else changed.`
118
+ );
119
+ return lines;
120
+ }
121
+
122
+ /**
123
+ * The one comment an operator reads for this item's clean-up.
124
+ * @param {{ stale: object[], real: object[], crossProject: object[], inaccessible: object[] }} sorted
125
+ * @param {string} [poster] - A key of {@link STALE_LINK_POSTERS}
126
+ * @param {string} [posterName] - The configured name of who posts it (the
127
+ * session manager's `sessionManager.name`), so the operator sees which
128
+ * manager acted; the prefix stays the machine-read marker
129
+ * @returns {string}
130
+ */
131
+ export function formatStaleLinkComment(
132
+ sorted,
133
+ poster = "session-manager",
134
+ posterName = ""
135
+ ) {
136
+ if (!Object.hasOwn(STALE_LINK_POSTERS, poster)) {
137
+ throw new Error(
138
+ `Unknown stale-link poster '${poster}'. Expected one of: ${Object.keys(STALE_LINK_POSTERS).join(", ")}.`
139
+ );
140
+ }
141
+ const lines = [
142
+ `${STALE_LINK_POSTERS[poster]} ${posterName.trim() ? `${posterName.trim()} cleared` : "Cleared"} waiting-on links.`,
143
+ ...removedSentences(sorted.stale),
144
+ ];
145
+ const open = unique([
146
+ ...sorted.real,
147
+ ...sorted.crossProject.filter(edge => edge.verdict === "open"),
148
+ ]);
149
+ if (open.length > 0) {
150
+ lines.push(
151
+ `It is still waiting on ${listOf(open)}, which ${agree(open, "is", "are")} not finished yet.`
152
+ );
153
+ }
154
+ const unreadable = unique(sorted.inaccessible);
155
+ if (unreadable.length > 0) {
156
+ lines.push(
157
+ `I could not open ${listOf(unreadable)}, so I left ${agree(unreadable, "that link", "those links")} alone.`
158
+ );
159
+ }
160
+ return [lines.join(" "), "", ...unique(sorted.stale).map(markerLine)].join(
161
+ "\n"
162
+ );
163
+ }
164
+
165
+ /**
166
+ * The comment as an Atlassian Document Format document. Jira Cloud's REST v3
167
+ * comment endpoint takes ADF, not a string, so a Jira plan posts this: one
168
+ * paragraph per non-empty line, so each marker stays on its own line and
169
+ * {@link markedBlockers} finds it again through `adfText`.
170
+ * @param {string} comment - From {@link formatStaleLinkComment}
171
+ * @returns {{ type: "doc", version: 1, content: object[] }}
172
+ */
173
+ export function staleLinkCommentAdf(comment) {
174
+ return {
175
+ type: "doc",
176
+ version: 1,
177
+ content: comment
178
+ .split("\n")
179
+ .filter(line => line.trim() !== "")
180
+ .map(line => ({
181
+ type: "paragraph",
182
+ content: [{ type: "text", text: line }],
183
+ })),
184
+ };
185
+ }
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Re-check one planned stale-link clean-up against a fresh read, right before
4
+ * the writes (CodySwannGT/lisa#5065).
5
+ *
6
+ * A plan is a snapshot. Between planning and writing, a blocker can be
7
+ * reopened (its link is real again and must stay), a person can edit the
8
+ * item's body (a precomputed body would overwrite that edit), or the item can
9
+ * move to the blocked role (the Blocked sweep owns it then). So the writer
10
+ * re-reads the item AND each of its blockers, and this module rebuilds the
11
+ * plan from that fresh read:
12
+ *
13
+ * - only links the original plan removes, and that are still stale now, are
14
+ * removed; the rest are reported in `skipped` with the reason;
15
+ * - the GitHub body is rebuilt by `removeBlockedByRefs` on the FRESH body, so
16
+ * a concurrent edit is kept;
17
+ * - the comment describes the fresh state.
18
+ *
19
+ * A link that became stale only after the plan is left for the next cycle's
20
+ * plan, so a confirmation never widens what a plan does.
21
+ * @module stale-blocker-confirm
22
+ */
23
+
24
+ import {
25
+ itemPlan,
26
+ itemRoles,
27
+ normalizeStaleLinkItem,
28
+ edgeIdentity,
29
+ sortEdges,
30
+ } from "./stale-blocker-sweep.mjs";
31
+
32
+ /**
33
+ * Why a planned removal is no longer made.
34
+ * @param {string} blockerRef
35
+ * @param {ReturnType<typeof sortEdges>} sorted
36
+ * @returns {"blocker-not-resolved" | "link-changed" | "link-already-gone"}
37
+ */
38
+ function skipReason(blockerRef, sorted) {
39
+ // Still stale, but not the relationship the plan named (a new native
40
+ // dependency in place of a planned body ref, say): left for the next plan.
41
+ if (sorted.stale.some(edge => edge.blockerRef === blockerRef)) {
42
+ return "link-changed";
43
+ }
44
+ const present = [
45
+ ...sorted.real,
46
+ ...sorted.crossProject,
47
+ ...sorted.inaccessible,
48
+ ...sorted.keptByPerson,
49
+ // Moved back to an intermediate done rung: not finished, link kept.
50
+ ...sorted.landed,
51
+ ].some(edge => edge.blockerRef === blockerRef);
52
+ return present ? "blocker-not-resolved" : "link-already-gone";
53
+ }
54
+
55
+ /**
56
+ * Why the whole item is left alone now, or "" when it is not.
57
+ * @param {ReturnType<typeof normalizeStaleLinkItem>} item
58
+ * @param {{ inBlocked: boolean }} roles
59
+ * @returns {"" | "item-closed" | "status-unknown" | "blocked-role"}
60
+ */
61
+ function holdReason(item, roles) {
62
+ // The sweep is scoped to open items: one closed since the plan is not
63
+ // edited.
64
+ if (item.closed) return "item-closed";
65
+ if (!item.statusKnown) return "status-unknown";
66
+ return roles.inBlocked ? "blocked-role" : "";
67
+ }
68
+
69
+ /**
70
+ * Rebuild one item's plan from a fresh read of the item and its blockers.
71
+ * @param {{
72
+ * tracker: "github" | "jira" | "linear",
73
+ * plan: { ref: string, removed: readonly string[], edges?: readonly string[] },
74
+ * fresh: Record<string, any>,
75
+ * doneRoles: readonly string[],
76
+ * landedRoles?: readonly string[],
77
+ * roles: { ready?: string, blocked?: string },
78
+ * poster?: "session-manager" | "build-intake",
79
+ * posterName?: string,
80
+ * }} input - `fresh` is the raw item in the same shape the plan read it
81
+ * @returns {{ plan: import("./stale-blocker-sweep.mjs").StaleLinkPlan | null, skipped: { blocker: string, reason: string }[] }}
82
+ */
83
+ export function confirmStaleLinkPlan(input) {
84
+ const item = normalizeStaleLinkItem(input.tracker, input.fresh);
85
+ if (item.ref !== input.plan.ref) {
86
+ throw new Error(
87
+ `The fresh read is ${item.ref}, but the plan is for ${input.plan.ref}.`
88
+ );
89
+ }
90
+ if (!item.relationsRead) {
91
+ // probe-direction: fail-closed — a read with no relation list cannot say
92
+ // which links are still there, so nothing is confirmed from it.
93
+ throw new Error(
94
+ `The fresh read of ${item.ref} has no blocker relation list; read it with its links.`
95
+ );
96
+ }
97
+ const planned = new Set(input.plan.removed);
98
+ const roles = itemRoles(item, input.roles);
99
+ const hold = holdReason(item, roles);
100
+ if (hold) {
101
+ return {
102
+ plan: null,
103
+ skipped: [...planned].map(blocker => ({ blocker, reason: hold })),
104
+ };
105
+ }
106
+ const sorted = sortEdges(item, input.doneRoles, input.landedRoles);
107
+ // Only the planned relationships: a link added since the plan, even to the
108
+ // same blocker (a native dependency beside a planned body ref), was never
109
+ // authorized and stays.
110
+ const identities = new Set(input.plan.edges ?? []);
111
+ const stale = sorted.stale.filter(
112
+ edge => planned.has(edge.blockerRef) && identities.has(edgeIdentity(edge))
113
+ );
114
+ const kept = new Set(stale.map(edge => edge.blockerRef));
115
+ const skipped = [...planned]
116
+ .filter(blocker => !kept.has(blocker))
117
+ .map(blocker => ({ blocker, reason: skipReason(blocker, sorted) }));
118
+ if (stale.length === 0) return { plan: null, skipped };
119
+ return {
120
+ plan: itemPlan({
121
+ tracker: input.tracker,
122
+ item,
123
+ sorted: { ...sorted, stale },
124
+ ready: roles.ready,
125
+ poster: input.poster,
126
+ posterName: input.posterName,
127
+ }),
128
+ skipped,
129
+ };
130
+ }