@herbertgao/pi-extensions 2026.11.19 → 2026.11.21

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 (185) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +10 -10
  3. package/THIRD_PARTY_NOTICES.md +3 -3
  4. package/node_modules/@estebanforge/pi-antigravity-bridge/CHANGELOG.md +8 -0
  5. package/node_modules/@estebanforge/pi-antigravity-bridge/README.md +9 -5
  6. package/node_modules/@estebanforge/pi-antigravity-bridge/extensions/index.ts +11 -1
  7. package/node_modules/@estebanforge/pi-antigravity-bridge/package.json +1 -1
  8. package/node_modules/@estebanforge/pi-antigravity-bridge/src/config.ts +71 -13
  9. package/node_modules/@estebanforge/pi-antigravity-bridge/src/provider.ts +148 -47
  10. package/node_modules/@narumitw/pi-btw/CHANGELOG.md +7 -0
  11. package/node_modules/@narumitw/pi-btw/dist/chunks/{main-tree-picker-3PXJARQW.ts → main-tree-picker-WMTVRTR2.ts} +1 -1
  12. package/node_modules/@narumitw/pi-btw/dist/chunks/main-tree-picker-WMTVRTR2.ts.map +7 -0
  13. package/node_modules/@narumitw/pi-btw/dist/index.ts +1 -1
  14. package/node_modules/@narumitw/pi-btw/docs/core-alignment.md +6 -0
  15. package/node_modules/@narumitw/pi-btw/package.json +5 -5
  16. package/node_modules/@narumitw/pi-btw/src/main-tree-picker.ts +1 -1
  17. package/node_modules/@narumitw/pi-caffeinate/CHANGELOG.md +7 -0
  18. package/node_modules/@narumitw/pi-caffeinate/package.json +3 -3
  19. package/node_modules/pi-lens/CHANGELOG-USER.md +6 -6
  20. package/node_modules/pi-lens/CHANGELOG.md +121 -0
  21. package/node_modules/pi-lens/README.md +9 -2
  22. package/node_modules/pi-lens/dist/{chunk-ZVQUYCBU.js → chunk-2ERVW2UF.js} +161 -100
  23. package/node_modules/pi-lens/dist/{chunk-AFSG6YUB.js → chunk-2K7BUOKS.js} +13 -13
  24. package/node_modules/pi-lens/dist/{chunk-BJGWP4UX.js → chunk-3JJ4OAJI.js} +10 -10
  25. package/node_modules/pi-lens/dist/{chunk-GIK6VUCY.js → chunk-3UHGSUVL.js} +1 -1
  26. package/node_modules/pi-lens/dist/{chunk-EKQDQPX6.js → chunk-463WN3VP.js} +1 -1
  27. package/node_modules/pi-lens/dist/{chunk-F7BFIENK.js → chunk-4X3ML2UQ.js} +29 -32
  28. package/node_modules/pi-lens/dist/{chunk-7JMEPY6P.js → chunk-5BI5YP57.js} +10 -10
  29. package/node_modules/pi-lens/dist/{chunk-MKW7ZUTT.js → chunk-5Z4XLUFF.js} +3 -3
  30. package/node_modules/pi-lens/dist/{chunk-NIZKGBOU.js → chunk-62AJH3IN.js} +12 -14
  31. package/node_modules/pi-lens/dist/{chunk-4GLSO2EM.js → chunk-6F34GMP7.js} +12 -12
  32. package/node_modules/pi-lens/dist/{chunk-35UJUF27.js → chunk-6LIUVGOR.js} +13 -3
  33. package/node_modules/pi-lens/dist/{chunk-WJ7GY5WJ.js → chunk-6REF4GCO.js} +1 -1
  34. package/node_modules/pi-lens/dist/{chunk-HFIFEH46.js → chunk-7KRR24GO.js} +3 -3
  35. package/node_modules/pi-lens/dist/{chunk-WAK2AXQQ.js → chunk-7OMOMBEQ.js} +9 -9
  36. package/node_modules/pi-lens/dist/{chunk-S7KUDW73.js → chunk-7ZFXICNN.js} +15 -15
  37. package/node_modules/pi-lens/dist/{chunk-VEF3GFOL.js → chunk-ABKRQVOY.js} +28 -52
  38. package/node_modules/pi-lens/dist/{chunk-Y2LIOCA7.js → chunk-ANSLRJBG.js} +1 -1
  39. package/node_modules/pi-lens/dist/{chunk-ARTCVE6I.js → chunk-AWMFBPGJ.js} +9 -9
  40. package/node_modules/pi-lens/dist/{chunk-H6DNTQ4V.js → chunk-BG7KHGNX.js} +2 -2
  41. package/node_modules/pi-lens/dist/{chunk-FD4LJQ6Y.js → chunk-BK2R2223.js} +10 -8
  42. package/node_modules/pi-lens/dist/{chunk-TWAQFMLW.js → chunk-BXXC6KRR.js} +31 -34
  43. package/node_modules/pi-lens/dist/{chunk-S247BOH2.js → chunk-CKJS2AUI.js} +4 -4
  44. package/node_modules/pi-lens/dist/{chunk-GNK2IHVG.js → chunk-COGU5KQJ.js} +15 -15
  45. package/node_modules/pi-lens/dist/{chunk-P7EV5ISR.js → chunk-CQNXALZJ.js} +12 -6
  46. package/node_modules/pi-lens/dist/{chunk-IO6P3NBP.js → chunk-CSZESDPP.js} +1 -1
  47. package/node_modules/pi-lens/dist/chunk-CZ5TCJPB.js +98 -0
  48. package/node_modules/pi-lens/dist/{chunk-DLGJYQML.js → chunk-D2LFEA5U.js} +9 -2
  49. package/node_modules/pi-lens/dist/chunk-D3KLF5CD.js +50 -0
  50. package/node_modules/pi-lens/dist/{chunk-W2JPGW7Q.js → chunk-ENJ2M76Y.js} +20 -20
  51. package/node_modules/pi-lens/dist/{chunk-2DWNYVUN.js → chunk-EQKF6BAK.js} +3 -3
  52. package/node_modules/pi-lens/dist/{chunk-KIQSNH3F.js → chunk-F2SAP2FM.js} +38 -45
  53. package/node_modules/pi-lens/dist/{chunk-BYIEU4E4.js → chunk-F6QAJXQV.js} +2 -2
  54. package/node_modules/pi-lens/dist/chunk-GR2QDWH5.js +25 -0
  55. package/node_modules/pi-lens/dist/{chunk-T2D2WWP6.js → chunk-GVE5VZYQ.js} +5 -5
  56. package/node_modules/pi-lens/dist/{chunk-HMXWZUQW.js → chunk-GWZZOJD2.js} +1 -1
  57. package/node_modules/pi-lens/dist/chunk-GZS6VPIE.js +27 -0
  58. package/node_modules/pi-lens/dist/chunk-H4B4SC7I.js +71 -0
  59. package/node_modules/pi-lens/dist/{chunk-2RQREVGO.js → chunk-HA6TUJOE.js} +1 -1
  60. package/node_modules/pi-lens/dist/{chunk-NAACKIKT.js → chunk-HKPJTI47.js} +2 -2
  61. package/node_modules/pi-lens/dist/{chunk-NHHS5T52.js → chunk-HPKC55MA.js} +1 -1
  62. package/node_modules/pi-lens/dist/{chunk-B2QO7GHY.js → chunk-I65CQLCG.js} +1 -1
  63. package/node_modules/pi-lens/dist/{chunk-BQ72NQQM.js → chunk-IDKLWVKY.js} +11 -11
  64. package/node_modules/pi-lens/dist/chunk-IUM2Q7NF.js +25 -0
  65. package/node_modules/pi-lens/dist/{chunk-PVV27TOX.js → chunk-J24IS3KZ.js} +5 -5
  66. package/node_modules/pi-lens/dist/{chunk-DKXIUGNA.js → chunk-J2DAHH4T.js} +2 -2
  67. package/node_modules/pi-lens/dist/{chunk-CDAJQBKJ.js → chunk-JBDZVOFL.js} +11 -11
  68. package/node_modules/pi-lens/dist/{chunk-T7KHGEJ5.js → chunk-JC6NFC57.js} +3 -3
  69. package/node_modules/pi-lens/dist/{chunk-BWGNVM33.js → chunk-JTHEUTW7.js} +11 -11
  70. package/node_modules/pi-lens/dist/{chunk-WWZLT6AM.js → chunk-JWW3ODBN.js} +2 -2
  71. package/node_modules/pi-lens/dist/{chunk-Q32RJDYC.js → chunk-K3ZIYLHT.js} +4 -4
  72. package/node_modules/pi-lens/dist/{chunk-LDPY22FS.js → chunk-KDPZA2UE.js} +2 -3
  73. package/node_modules/pi-lens/dist/{chunk-YIEHUKX2.js → chunk-KMY2OU4T.js} +489 -285
  74. package/node_modules/pi-lens/dist/{chunk-WH6O4IFD.js → chunk-KQF7VT26.js} +10 -10
  75. package/node_modules/pi-lens/dist/{chunk-OG3UCAHV.js → chunk-KVGA7X76.js} +3 -3
  76. package/node_modules/pi-lens/dist/{chunk-TABDCX35.js → chunk-KW7O72AK.js} +2 -2
  77. package/node_modules/pi-lens/dist/{chunk-AOEVZXR6.js → chunk-LEQTVRSV.js} +9 -9
  78. package/node_modules/pi-lens/dist/{chunk-7BWPQZHE.js → chunk-LKPSBM6S.js} +3 -3
  79. package/node_modules/pi-lens/dist/{chunk-WA6U2URH.js → chunk-LKW2HFSZ.js} +6 -6
  80. package/node_modules/pi-lens/dist/{chunk-M3QGXGY4.js → chunk-LURFD4HD.js} +624 -97
  81. package/node_modules/pi-lens/dist/{chunk-2YQ5LI7R.js → chunk-M6ELTECW.js} +4 -4
  82. package/node_modules/pi-lens/dist/{chunk-OHTHVILU.js → chunk-MGVVYYKW.js} +12 -12
  83. package/node_modules/pi-lens/dist/{chunk-W2YHHNY3.js → chunk-MQBKGRSB.js} +7 -7
  84. package/node_modules/pi-lens/dist/{chunk-MET776XM.js → chunk-MVG2ZEAO.js} +6 -6
  85. package/node_modules/pi-lens/dist/{chunk-2XALJI2K.js → chunk-MY4XNNTX.js} +39 -41
  86. package/node_modules/pi-lens/dist/{chunk-GFCPPCNR.js → chunk-N4AJVFRF.js} +11 -11
  87. package/node_modules/pi-lens/dist/{chunk-UARVPNAU.js → chunk-OFKKMXWM.js} +31 -36
  88. package/node_modules/pi-lens/dist/{chunk-DHFJS2I4.js → chunk-OFZE4ANN.js} +8 -8
  89. package/node_modules/pi-lens/dist/chunk-OLXBUTJR.js +61 -0
  90. package/node_modules/pi-lens/dist/{chunk-SJ2SR432.js → chunk-OZGEHOSG.js} +38 -17
  91. package/node_modules/pi-lens/dist/{chunk-6MDWNZ7E.js → chunk-PKGOROPQ.js} +40 -2
  92. package/node_modules/pi-lens/dist/{chunk-3IWMNN2S.js → chunk-Q6D5QKRG.js} +17 -17
  93. package/node_modules/pi-lens/dist/{chunk-JGCBMCCS.js → chunk-QECLJFHI.js} +12 -17
  94. package/node_modules/pi-lens/dist/{chunk-KXKM2DFP.js → chunk-QJA33VD5.js} +4 -4
  95. package/node_modules/pi-lens/dist/{chunk-YV7XVYSJ.js → chunk-R5XVJ6AN.js} +11 -11
  96. package/node_modules/pi-lens/dist/{chunk-62PIU4TO.js → chunk-REZL4OM4.js} +1 -1
  97. package/node_modules/pi-lens/dist/{chunk-NNDZ7DOP.js → chunk-RK5RBREN.js} +74 -107
  98. package/node_modules/pi-lens/dist/chunk-RP5ZQTHO.js +86 -0
  99. package/node_modules/pi-lens/dist/{chunk-HKRESBMC.js → chunk-RURPX2YV.js} +23 -23
  100. package/node_modules/pi-lens/dist/chunk-TB5MGZLS.js +53 -0
  101. package/node_modules/pi-lens/dist/chunk-TC63XRYP.js +27 -0
  102. package/node_modules/pi-lens/dist/chunk-TJOYHAXJ.js +69 -0
  103. package/node_modules/pi-lens/dist/{chunk-NZ7NSKIW.js → chunk-TRXKDCBP.js} +13 -13
  104. package/node_modules/pi-lens/dist/{chunk-7WAQ3K26.js → chunk-TTK37D7R.js} +22 -23
  105. package/node_modules/pi-lens/dist/{chunk-ALTHJUZO.js → chunk-UH3QHLR5.js} +2 -2
  106. package/node_modules/pi-lens/dist/{chunk-6MZLS6CK.js → chunk-UNTJJ7GN.js} +7 -7
  107. package/node_modules/pi-lens/dist/{chunk-XRLZ75YY.js → chunk-UPAFSETJ.js} +54 -59
  108. package/node_modules/pi-lens/dist/{chunk-N2U644ZW.js → chunk-UX75PTQW.js} +50 -17
  109. package/node_modules/pi-lens/dist/{chunk-EXHSWN3P.js → chunk-V353PYMK.js} +423 -233
  110. package/node_modules/pi-lens/dist/{chunk-SL4G67AP.js → chunk-V4TFQY5G.js} +2 -2
  111. package/node_modules/pi-lens/dist/{chunk-YOMLAKU6.js → chunk-VC3W54G3.js} +289 -138
  112. package/node_modules/pi-lens/dist/{chunk-KSQJBGRO.js → chunk-VSBCJVPC.js} +5 -5
  113. package/node_modules/pi-lens/dist/{chunk-EBXCYEII.js → chunk-WAQQGXVV.js} +3 -3
  114. package/node_modules/pi-lens/dist/{chunk-7ORBRDFY.js → chunk-WLEVWR7Y.js} +2 -2
  115. package/node_modules/pi-lens/dist/{chunk-Q4UQNTLB.js → chunk-WPMPVP5I.js} +4 -4
  116. package/node_modules/pi-lens/dist/{chunk-TQKWR5AZ.js → chunk-WXNLFOC2.js} +7 -7
  117. package/node_modules/pi-lens/dist/{chunk-HOWHAKXO.js → chunk-Y3ZNOZZS.js} +6 -6
  118. package/node_modules/pi-lens/dist/{chunk-DNJJVKJZ.js → chunk-YL6JQTWC.js} +29 -32
  119. package/node_modules/pi-lens/dist/{chunk-HUWW77QY.js → chunk-YVE5Q2UU.js} +86 -217
  120. package/node_modules/pi-lens/dist/{chunk-25CAONWT.js → chunk-YZNARDMM.js} +12 -9
  121. package/node_modules/pi-lens/dist/{chunk-HERQPNY6.js → chunk-ZDWNFZJ2.js} +8 -8
  122. package/node_modules/pi-lens/dist/{chunk-MKQFSW2Q.js → chunk-ZEUF7BIN.js} +2 -2
  123. package/node_modules/pi-lens/dist/{chunk-AB26NAHA.js → chunk-ZIF4WLWR.js} +45 -25
  124. package/node_modules/pi-lens/dist/{chunk-6MWX2J5H.js → chunk-ZSPVF7KI.js} +227 -24
  125. package/node_modules/pi-lens/dist/{chunk-QQGZY2BR.js → chunk-ZX6OKBVO.js} +2 -2
  126. package/node_modules/pi-lens/dist/index.js +6455 -5243
  127. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +8 -8
  128. package/node_modules/pi-lens/dist/mcp/cli.js +39 -41
  129. package/node_modules/pi-lens/dist/mcp/server.js +870 -559
  130. package/node_modules/pi-lens/dist/mcp/worker.js +68 -59
  131. package/node_modules/pi-lens/dist/probes/installer.js +19 -20
  132. package/node_modules/pi-lens/docs/configuration.md +24 -10
  133. package/node_modules/pi-lens/docs/defect-shapes.md +18 -2
  134. package/node_modules/pi-lens/docs/environment-variables.md +18 -9
  135. package/node_modules/pi-lens/docs/globalconfig.md +16 -0
  136. package/node_modules/pi-lens/docs/invariants/dispatch-runners.md +7 -0
  137. package/node_modules/pi-lens/docs/invariants/lsp-trust-exec.md +33 -3
  138. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +23 -10
  139. package/node_modules/pi-lens/docs/lsp-idle-eviction.md +8 -3
  140. package/node_modules/pi-lens/docs/release-qa-baseline.md +22 -17
  141. package/node_modules/pi-lens/docs/servercapabilities.md +1 -1
  142. package/node_modules/pi-lens/docs/settings.md +9 -2
  143. package/node_modules/pi-lens/docs/tools.md +1 -1
  144. package/node_modules/pi-lens/package.json +3 -3
  145. package/node_modules/pi-typesafe/README.md +1 -1
  146. package/node_modules/pi-typesafe/dist/ask.js +6 -3
  147. package/node_modules/pi-typesafe/dist/auth.d.ts +31 -7
  148. package/node_modules/pi-typesafe/dist/auth.js +159 -55
  149. package/node_modules/pi-typesafe/dist/batch.d.ts +16 -2
  150. package/node_modules/pi-typesafe/dist/batch.js +62 -22
  151. package/node_modules/pi-typesafe/dist/calibrate.d.ts +38 -11
  152. package/node_modules/pi-typesafe/dist/calibrate.js +56 -24
  153. package/node_modules/pi-typesafe/dist/client.d.ts +13 -0
  154. package/node_modules/pi-typesafe/dist/client.js +67 -27
  155. package/node_modules/pi-typesafe/dist/errors.d.ts +20 -0
  156. package/node_modules/pi-typesafe/dist/errors.js +105 -2
  157. package/node_modules/pi-typesafe/dist/extension.d.ts +106 -0
  158. package/node_modules/pi-typesafe/dist/extension.js +206 -106
  159. package/node_modules/pi-typesafe/dist/index.d.ts +8 -8
  160. package/node_modules/pi-typesafe/dist/index.js +3 -3
  161. package/node_modules/pi-typesafe/dist/key-prompt.d.ts +20 -0
  162. package/node_modules/pi-typesafe/dist/key-prompt.js +23 -3
  163. package/node_modules/pi-typesafe/dist/login.d.ts +58 -1
  164. package/node_modules/pi-typesafe/dist/login.js +167 -13
  165. package/node_modules/pi-typesafe/dist/schema.d.ts +3 -0
  166. package/node_modules/pi-typesafe/dist/schema.js +47 -13
  167. package/node_modules/pi-typesafe/dist/ui.d.ts +2 -1
  168. package/node_modules/pi-typesafe/dist/usage.d.ts +53 -0
  169. package/node_modules/pi-typesafe/dist/usage.js +79 -40
  170. package/node_modules/pi-typesafe/package.json +3 -3
  171. package/package.json +8 -8
  172. package/node_modules/@narumitw/pi-btw/dist/chunks/main-tree-picker-3PXJARQW.ts.map +0 -7
  173. package/node_modules/pi-lens/dist/chunk-3UTDLQWO.js +0 -88
  174. package/node_modules/pi-lens/dist/chunk-3Z7Z3B7V.js +0 -27
  175. package/node_modules/pi-lens/dist/chunk-4E4OCW3L.js +0 -38
  176. package/node_modules/pi-lens/dist/chunk-5HVDD7IA.js +0 -17
  177. package/node_modules/pi-lens/dist/chunk-BKJ6WZKP.js +0 -255
  178. package/node_modules/pi-lens/dist/chunk-D3UQWOCB.js +0 -46
  179. package/node_modules/pi-lens/dist/chunk-EH6EHFW2.js +0 -73
  180. package/node_modules/pi-lens/dist/chunk-J7VNGHLN.js +0 -69
  181. package/node_modules/pi-lens/dist/chunk-L3Q72QGQ.js +0 -25
  182. package/node_modules/pi-lens/dist/chunk-TFSBHRL2.js +0 -25
  183. package/node_modules/pi-lens/dist/chunk-UWBD3JMH.js +0 -56
  184. package/node_modules/pi-lens/dist/chunk-XWWFESYZ.js +0 -27
  185. package/node_modules/pi-lens/dist/chunk-XZSXSM4K.js +0 -27
@@ -99,33 +99,80 @@ function zeroUsage(): Usage {
99
99
  };
100
100
  }
101
101
 
102
- /** Extract the latest user message as a flat prompt string. agy maintains its
103
- * own conversation history via --conversation, so we collapse pi's structured
104
- * message to text. Returns null if the last message isn't a user message. */
105
- function extractUserPrompt(context: TranscriptContext): string | null {
106
- const last = context.messages[context.messages.length - 1];
107
- if (!last || last.role !== "user") return null;
108
- const content = last.content;
109
- if (typeof content === "string") return content;
110
- // Flatten text blocks; images ride separately via extractImages (native
111
- // blocks on ACP, staged files on stream-json via prompt-images.ts).
112
- return content
113
- .filter((b): b is { type: "text"; text: string } => b.type === "text")
114
- .map((b) => b.text)
115
- .join("\n")
116
- .trim() || null;
102
+ /** Flatten one message's text + image blocks (pi-ai ImageContent: base64
103
+ * data + mimeType). The pre-#24 extraction shape, kept for the untrusted-
104
+ * boundary fallback and the single-message resume paths. */
105
+ function lastMessageParts(m: Message | undefined): { text: string | null; images: Array<{ data: string; mimeType: string }> } {
106
+ if (!m || m.role !== "user") return { text: null, images: [] };
107
+ if (typeof m.content === "string") return { text: m.content.trim() || null, images: [] };
108
+ const images: Array<{ data: string; mimeType: string }> = [];
109
+ const texts: string[] = [];
110
+ for (const b of m.content) {
111
+ if (b.type === "text") texts.push(b.text);
112
+ else if (b.type === "image") images.push({ data: b.data, mimeType: b.mimeType });
113
+ }
114
+ return { text: texts.join("\n").trim() || null, images };
117
115
  }
118
116
 
119
- /** Image blocks of the latest user message (pi-ai ImageContent: base64 data
120
- * + mimeType). On the ACP engine they ride session/prompt as native
121
- * content blocks; on stream-json they are staged to temp files and the
122
- * prompt names the paths (see prompt-images.ts). */
123
- function extractImages(context: TranscriptContext): Array<{ data: string; mimeType: string }> {
124
- const last = context.messages[context.messages.length - 1];
125
- if (!last || last.role !== "user" || typeof last.content === "string") return [];
126
- return last.content
127
- .filter((b): b is { type: "image"; data: string; mimeType: string } => b.type === "image")
128
- .map((b) => ({ data: b.data, mimeType: b.mimeType }));
117
+ /** pi-side history shapes that can sit inside a trailing user run; a run
118
+ * member matching one truncates the run to the messages after it. */
119
+ function isBacklogUserShape(text: string): boolean {
120
+ return text.includes(COMPACTION_MARKER) || text.startsWith(BRANCH_SUMMARY_PREFIX) || text.startsWith(BASH_RUN_PREFIX);
121
+ }
122
+
123
+ /** The trailing run of role:"user" messages is the active turn: pi stacks
124
+ * the prompt, queued nextTurn messages, and before_agent_start notes as
125
+ * consecutive user messages, so reading only the LAST one dropped every
126
+ * earlier prompt text and image (issue #24). The run is left-bounded by
127
+ * the validated watermark: messages at or before it belong to turns agy
128
+ * already saw (a failed pass never advances the watermark, so joining them
129
+ * could re-execute a half-run task; they stay digest/continuity context).
130
+ * A mismatched boundary fingerprint makes the count untrustworthy, so the
131
+ * run collapses to the last message - the pre-#24 behavior - instead of
132
+ * guessing. `texts` feeds the stream-json per-member truncation guard. */
133
+ function extractTrailingUserRun(
134
+ messages: Message[],
135
+ watermark: number,
136
+ boundaryTrusted: boolean,
137
+ ): { prompt: string | null; images: Array<{ data: string; mimeType: string }>; runStart: number; texts: string[] } {
138
+ const last = messages.length - 1;
139
+ const empty = { prompt: null, images: [], runStart: messages.length, texts: [] };
140
+ if (last < 0 || messages[last].role !== "user") return empty;
141
+ if (!boundaryTrusted) {
142
+ const only = lastMessageParts(messages[last]);
143
+ return { prompt: only.text, images: only.images, runStart: last, texts: only.text ? [only.text] : [] };
144
+ }
145
+ let start = last;
146
+ while (start > 0 && messages[start - 1].role === "user") start--;
147
+ for (let i = start; i < messages.length; i++) {
148
+ if (isBacklogUserShape(blocksToText(messages[i].content))) start = i + 1;
149
+ }
150
+ if (watermark > start) start = watermark;
151
+ if (start > last) {
152
+ // The stored count reaches past the run (a transcript that shrank
153
+ // under a matching or stale boundary - pi's retry re-emits look
154
+ // exactly like this): the pre-#24 read is the only safe one.
155
+ const only = lastMessageParts(messages[last]);
156
+ return { prompt: only.text, images: only.images, runStart: last, texts: only.text ? [only.text] : [] };
157
+ }
158
+ const texts: string[] = [];
159
+ const images: Array<{ data: string; mimeType: string }> = [];
160
+ for (let i = start; i <= last; i++) {
161
+ const m = messages[i];
162
+ if (typeof m.content === "string") {
163
+ if (m.content.trim()) texts.push(m.content);
164
+ continue;
165
+ }
166
+ for (const b of m.content) {
167
+ if (b.type === "text") {
168
+ if (b.text.trim()) texts.push(b.text);
169
+ } else if (b.type === "image") {
170
+ images.push({ data: b.data, mimeType: b.mimeType });
171
+ }
172
+ }
173
+ }
174
+ const prompt = texts.join("\n\n").trim() || null;
175
+ return { prompt, images, runStart: start, texts };
129
176
  }
130
177
 
131
178
  // --- G1: pi-side context digest --------------------------------------------------
@@ -140,6 +187,14 @@ function extractImages(context: TranscriptContext): Array<{ data: string; mimeTy
140
187
 
141
188
  const COMPACTION_MARKER = "compacted into the following summary";
142
189
 
190
+ /** pi's convertToLlm maps branch summaries and bash runs to role:"user", so
191
+ * a watermark-0 transcript can hold them as backlog inside a trailing user
192
+ * run. Neither contains COMPACTION_MARKER, so the run scan (issue #24)
193
+ * needs their shapes too (core/messages.js BRANCH_SUMMARY_PREFIX /
194
+ * bashExecutionToText). */
195
+ const BRANCH_SUMMARY_PREFIX = "The following is a summary of a branch";
196
+ const BASH_RUN_PREFIX = "Ran `";
197
+
143
198
  /** Synthetic prompt for a resume turn (issue #8): pi's retry dropped the
144
199
  * failed attempt from the projected context (_omitRecoveryAttempt), leaving
145
200
  * a toolResult or assistant tail with no live agy turn. The bound
@@ -253,8 +308,14 @@ export interface DigestOptions {
253
308
  /** Include the trailing message in the delta window instead of reserving
254
309
  * it as the current user prompt. Used when resuming into a fresh
255
310
  * post-compaction conversation whose transcript ends in a toolResult or
256
- * assistant message. Default false. */
311
+ * assistant message. Default false. Ignored when `end` is set. */
257
312
  includeLast?: boolean;
313
+ /** Exclusive window end. The trailing user run (issue #24) joins the
314
+ * prompt, so its members must not reappear as digest continuity
315
+ * context; the provider passes the run's start index here. Default:
316
+ * length-1 (reserve the last message as the prompt), or length when
317
+ * includeLast is set. */
318
+ end?: number;
258
319
  }
259
320
 
260
321
  /** Soft cap on the digest body when no tighter budget applies. */
@@ -367,7 +428,12 @@ export function buildContextDigest(
367
428
  } else if (watermark > messages.length) {
368
429
  start = 0;
369
430
  }
370
- const end = opts.includeLast ? messages.length : Math.max(0, messages.length - 1);
431
+ const end =
432
+ opts.end !== undefined
433
+ ? opts.end
434
+ : opts.includeLast
435
+ ? messages.length
436
+ : Math.max(0, messages.length - 1);
371
437
  for (let i = start; i < end; i++) {
372
438
  const m = messages[i];
373
439
  if (m.role === "assistant") {
@@ -1622,8 +1688,24 @@ async function runTurnDriver(
1622
1688
  return;
1623
1689
  }
1624
1690
  // Fresh pass, or a stranded escalated result being re-delivered.
1625
- const userPrompt = extractUserPrompt(context);
1626
- const images = extractImages(context);
1691
+ // Watermark first: the trailing user run is left-bounded by it, so
1692
+ // failed-turn backlog never joins the prompt (issue #24 / issue #1).
1693
+ const rawWatermark = existing?.lastMessageCount ?? 0;
1694
+ // Boundary fingerprint check (see boundaryFingerprint): a transcript
1695
+ // mutated under the stored count (/tree, /fork, context-hook rewrites)
1696
+ // resets the delta to the full digest instead of a silently wrong one.
1697
+ // Records written before the fingerprint existed (digestBoundary unset)
1698
+ // trust the count: the old code advanced it the same way, so reseting
1699
+ // would dump a one-time full delta of history agy already holds.
1700
+ const storedBoundary = existing?.digestBoundary;
1701
+ const boundaryTrusted =
1702
+ rawWatermark === 0 ||
1703
+ storedBoundary === undefined ||
1704
+ storedBoundary === boundaryFingerprint(context.messages[rawWatermark - 1]);
1705
+ const watermark = rawWatermark > 0 && boundaryTrusted ? rawWatermark : 0;
1706
+ const run = extractTrailingUserRun(context.messages, watermark, boundaryTrusted);
1707
+ const userPrompt = run.prompt;
1708
+ const images = run.images;
1627
1709
  // Resume pass (issue #8): pi's retry dropped the failed attempt from the
1628
1710
  // projected context, so the transcript ends in a toolResult or assistant
1629
1711
  // message and there is no user prompt, no pending park, and nothing
@@ -1666,20 +1748,6 @@ async function runTurnDriver(
1666
1748
  finalize(stream, blocks, "error", "No user message to send to agy.");
1667
1749
  return;
1668
1750
  }
1669
- const rawWatermark = existing?.lastMessageCount ?? 0;
1670
- // Boundary fingerprint check (see boundaryFingerprint): a transcript
1671
- // mutated under the stored count (/tree, /fork, context-hook rewrites)
1672
- // resets the delta to the full digest instead of a silently wrong one.
1673
- // Records written before the fingerprint existed (digestBoundary unset)
1674
- // trust the count: the old code advanced it the same way, so reseting
1675
- // would dump a one-time full delta of history agy already holds.
1676
- const storedBoundary = existing?.digestBoundary;
1677
- const watermark =
1678
- rawWatermark > 0 &&
1679
- (storedBoundary === undefined ||
1680
- storedBoundary === boundaryFingerprint(context.messages[rawWatermark - 1]))
1681
- ? rawWatermark
1682
- : 0;
1683
1751
  // Late and resume turns re-open the conversation with a synthetic
1684
1752
  // prompt; the digest would re-send context agy already holds (against a
1685
1753
  // stale watermark: a failed pass never advances it), so skip it.
@@ -1687,15 +1755,48 @@ async function runTurnDriver(
1687
1755
  // once even if config.digest is false, because the old agy conversation
1688
1756
  // was rotated and the fresh conversation has no prior history.
1689
1757
  const engine = deps.engine ?? config.engine;
1690
- const promptBytes = Buffer.byteLength(prompt ?? "", "utf8");
1758
+ // A joined run can outgrow the stream-json silent-drop cap on its own
1759
+ // (issue #24): the digest budget used to absorb these bytes. Truncate
1760
+ // oldest-first, keeping the newest run members; synthetic resume
1761
+ // prompts have no run behind them and keep their existing behavior.
1762
+ let deliveredPrompt = prompt ?? "";
1763
+ let runTruncated = false;
1764
+ if (engine !== "acp" && run.texts.length > 0) {
1765
+ const budget = STREAM_JSON_PROMPT_CAP - STREAM_JSON_PROMPT_MARGIN;
1766
+ if (Buffer.byteLength(deliveredPrompt, "utf8") > budget) {
1767
+ const kept: string[] = [];
1768
+ let used = 0;
1769
+ for (let i = run.texts.length - 1; i >= 0; i--) {
1770
+ const cost = Buffer.byteLength(run.texts[i], "utf8") + 2;
1771
+ if (used + cost > budget - 16) break;
1772
+ kept.unshift(run.texts[i]);
1773
+ used += cost;
1774
+ }
1775
+ runTruncated = true;
1776
+ if (kept.length > 0) {
1777
+ deliveredPrompt = `[truncated]\n${kept.join("\n\n")}`;
1778
+ } else {
1779
+ // A single member bigger than the whole budget: hard-slice it
1780
+ // (visible truncation) rather than ship a silently dropped
1781
+ // turn (issue #2) or an empty prompt.
1782
+ const head = Buffer.from(run.texts[run.texts.length - 1], "utf8").subarray(0, Math.max(0, budget - 32));
1783
+ deliveredPrompt = `[truncated]\n${head.toString("utf8")}`;
1784
+ }
1785
+ }
1786
+ }
1787
+ const promptBytes = Buffer.byteLength(deliveredPrompt, "utf8");
1788
+ // A truncated run ships alone: the digest budget is spent, and a
1789
+ // marker-only digest beside a sliced prompt is noise that also breaks
1790
+ // agy's server-side prompt cache.
1791
+ const wantDigest = (config.digest || compactionHandoff || compactionResume) && !runTruncated;
1691
1792
  const maxChars = digestMaxCharsForEngine(engine, promptBytes);
1692
- const wantDigest = config.digest || compactionHandoff || compactionResume;
1693
1793
  const digest =
1694
1794
  wantDigest && maxChars !== null && late.length === 0 && !resume
1695
1795
  ? buildContextDigest(context.messages, watermark, {
1696
1796
  bound: Boolean(existing?.conversationId),
1697
1797
  seenSummaryId: existing?.digestSummaryId,
1698
1798
  maxChars,
1799
+ end: run.runStart,
1699
1800
  includeLast: compactionResume,
1700
1801
  })
1701
1802
  : "";
@@ -1768,8 +1869,8 @@ async function runTurnDriver(
1768
1869
  const runImages = [...images, ...late.flatMap((l) => l.images ?? [])];
1769
1870
  const fullPrompt =
1770
1871
  (late.length > 0
1771
- ? buildLateResultPrompt(late, prompt || undefined)
1772
- : buildFullPrompt(sysPrompt, embeddedDigest ? "" : digestFinal, prompt ?? "")) +
1872
+ ? buildLateResultPrompt(late, deliveredPrompt || undefined)
1873
+ : buildFullPrompt(sysPrompt, embeddedDigest ? "" : digestFinal, deliveredPrompt)) +
1773
1874
  stageImageNote(runImages);
1774
1875
  try {
1775
1876
  handle = await deps.driver.run({
@@ -1,5 +1,12 @@
1
1
  # @narumitw/pi-btw
2
2
 
3
+ ## 0.63.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [1cbb470]
8
+ - @narumitw/pi-tui-kit@0.71.0
9
+
3
10
  ## 0.63.8
4
11
 
5
12
  ### Patch Changes
@@ -331,4 +331,4 @@ export {
331
331
  pickMainEntry,
332
332
  prepareTreeSnapshot
333
333
  };
334
- //# sourceMappingURL=main-tree-picker-3PXJARQW.ts.map
334
+ //# sourceMappingURL=main-tree-picker-WMTVRTR2.ts.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/main-tree-picker.ts"],
4
+ "sourcesContent": ["import {\n copyToClipboard,\n type ExtensionAPI,\n type ExtensionCommandContext,\n type SessionEntry,\n type SessionTreeNode,\n TreeSelectorComponent,\n} from \"@earendil-works/pi-coding-agent\";\nimport { type Component, type Focusable, Key, matchesKey } from \"@earendil-works/pi-tui\";\nimport { showBtwCustomPreservingEditor } from \"./menu.js\";\nimport { sanitizeSingleLine } from \"./text.js\";\n\nexport type MainEntryPickResult = { kind: \"selected\"; entryId: string } | { kind: \"back\" } | { kind: \"closed\" };\n\nexport interface MainThreadTreeSelector extends Component, Focusable {\n onCopy?: (text: string | undefined) => void;\n setViewLabel?(entryId: string, label: string | undefined, labelTimestamp?: string): void;\n dispose?(): void;\n}\n\nexport interface MainThreadTreeSelectorOptions {\n tree: SessionTreeNode[];\n currentLeafId: string | null;\n terminalRows: number;\n onSelect: (entryId: string) => void;\n onCancel: () => void;\n onCopy: (entryId: string | undefined, displayText: string | undefined) => void;\n onLabelChange: (entryId: string, label: string | undefined) => void;\n}\n\nexport interface MainThreadTreePickerDependencies {\n createSelector?: (options: MainThreadTreeSelectorOptions) => MainThreadTreeSelector;\n copyToClipboard?: (text: string, signal: AbortSignal) => Promise<void>;\n}\n\nclass MainThreadTreePickerComponent implements Component, Focusable {\n constructor(\n private readonly selector: MainThreadTreeSelector,\n private readonly onClose: () => void,\n ) {}\n\n get focused(): boolean {\n return this.selector.focused;\n }\n\n set focused(value: boolean) {\n this.selector.focused = value;\n }\n\n get wantsKeyRelease(): boolean | undefined {\n return this.selector.wantsKeyRelease;\n }\n\n render(width: number) {\n return this.selector.render(width);\n }\n\n handleInput(data: string): void {\n if (matchesKey(data, Key.ctrl(\"c\"))) {\n this.onClose();\n return;\n }\n this.selector.handleInput?.(data);\n }\n\n invalidate(): void {\n this.selector.invalidate();\n }\n\n dispose(): void {\n this.selector.dispose?.();\n this.onClose();\n }\n}\n\nexport async function pickMainEntry(\n pi: ExtensionAPI,\n ctx: ExtensionCommandContext,\n dependencies: MainThreadTreePickerDependencies = {},\n): Promise<MainEntryPickResult> {\n let rawTree: SessionTreeNode[];\n let currentLeafId: string | null;\n try {\n rawTree = ctx.sessionManager.getTree();\n currentLeafId = ctx.sessionManager.getLeafId();\n } catch {\n return { kind: \"closed\" };\n }\n\n if (rawTree.length === 0) {\n notifySafely(ctx, \"No main-thread entries are available\", \"warning\");\n return { kind: \"back\" };\n }\n\n const { tree, rawCopyText, savedLabels } = prepareTreeSnapshot(rawTree);\n const createSelector = dependencies.createSelector ?? createNativeTreeSelector;\n const copy = dependencies.copyToClipboard ?? copyText;\n const copyControllers = new Set<AbortController>();\n const copyTasks = new Set<Promise<void>>();\n const abortCopies = () => {\n for (const controller of copyControllers) {\n controller.abort(new Error(\"The main-thread tree picker closed\"));\n }\n };\n const result = await showBtwCustomPreservingEditor<MainEntryPickResult>(ctx, (tui, _theme, _keybindings, done) => {\n let settled = false;\n let selector: MainThreadTreeSelector | undefined;\n const finish = (value: MainEntryPickResult) => {\n if (settled) return;\n settled = true;\n abortCopies();\n done(value);\n };\n const onCopy = (entryId: string | undefined, displayText: string | undefined) => {\n if (settled) return;\n let text: string | undefined;\n try {\n const source = entryId ? rawCopyText.get(entryId) : displayText;\n text = typeof source === \"string\" ? source : source?.join(\"\");\n } catch (error: unknown) {\n notifySafely(ctx, `Could not copy selected message: ${formatError(error)}`, \"error\");\n return;\n }\n if (!text) {\n notifySafely(ctx, \"Selected entry has no text to copy\", \"warning\");\n return;\n }\n const controller = new AbortController();\n copyControllers.add(controller);\n let operation: Promise<void>;\n try {\n operation = copy(text, controller.signal);\n } catch (error: unknown) {\n operation = Promise.reject(error);\n }\n let task!: Promise<void>;\n task = operation\n .then(() => {\n if (!settled) notifySafely(ctx, \"Copied selected message\", \"info\");\n })\n .catch((error: unknown) => {\n if (!settled && !controller.signal.aborted) {\n notifySafely(ctx, `Could not copy selected message: ${formatError(error)}`, \"error\");\n }\n })\n .finally(() => {\n copyControllers.delete(controller);\n copyTasks.delete(task);\n });\n copyTasks.add(task);\n };\n const restoreLabel = (entryId: string) => {\n const previous = savedLabels.get(entryId);\n selector?.setViewLabel?.(entryId, previous?.label, previous?.labelTimestamp);\n tui.requestRender();\n };\n const onLabelChange = (entryId: string, label: string | undefined) => {\n if (settled) return;\n try {\n if (!ctx.sessionManager.getEntry(entryId)) {\n restoreLabel(entryId);\n notifySafely(ctx, \"The selected main-thread entry is no longer available\", \"warning\");\n return;\n }\n const persistedLabel = label === undefined ? undefined : sanitizeSingleLine(label);\n pi.setLabel(entryId, persistedLabel);\n if (persistedLabel === undefined) savedLabels.delete(entryId);\n else savedLabels.set(entryId, { label: persistedLabel });\n selector?.setViewLabel?.(entryId, persistedLabel);\n tui.requestRender();\n } catch (error: unknown) {\n restoreLabel(entryId);\n notifySafely(ctx, `Could not update tree label: ${formatError(error)}`, \"error\");\n }\n };\n selector = createSelector({\n tree,\n currentLeafId,\n terminalRows: tui.terminal.rows,\n onSelect: (entryId) => finish({ kind: \"selected\", entryId }),\n onCancel: () => finish({ kind: \"back\" }),\n onCopy,\n onLabelChange,\n });\n return new MainThreadTreePickerComponent(selector, () => finish({ kind: \"closed\" }));\n });\n abortCopies();\n await Promise.allSettled([...copyTasks]);\n\n return result ?? { kind: \"closed\" };\n}\n\nfunction createNativeTreeSelector(options: MainThreadTreeSelectorOptions): MainThreadTreeSelector {\n const selector = new TreeSelectorComponent(\n options.tree,\n options.currentLeafId,\n options.terminalRows,\n options.onSelect,\n options.onCancel,\n options.onLabelChange,\n );\n selector.onCopy = (displayText) => options.onCopy(selector.getTreeList().getSelectedNode()?.entry.id, displayText);\n const result = selector as MainThreadTreeSelector;\n result.setViewLabel = (entryId, label, labelTimestamp) =>\n selector.getTreeList().updateNodeLabel(entryId, label, labelTimestamp);\n return result;\n}\n\ntype RawCopySource = string | readonly string[];\n\n/** @internal Package-local snapshot test boundary; not an extension entrypoint. */\nexport function prepareTreeSnapshot(rawTree: readonly SessionTreeNode[]): {\n tree: SessionTreeNode[];\n rawCopyText: Map<string, RawCopySource>;\n savedLabels: Map<string, SavedLabel>;\n} {\n const tree: SessionTreeNode[] = [];\n const rawCopyText = new Map<string, RawCopySource>();\n const savedLabels = new Map<string, SavedLabel>();\n // Keep traversal state on the heap: valid session histories can be arbitrarily deep.\n const stack = [{ source: rawTree, target: tree, index: 0 }];\n while (stack.length > 0) {\n const frame = stack[stack.length - 1];\n if (frame.index === frame.source.length) {\n stack.pop();\n continue;\n }\n const node = frame.source[frame.index++];\n const label = node.label === undefined ? undefined : sanitizeSingleLine(node.label);\n const labelTimestamp = node.labelTimestamp === undefined ? undefined : sanitizeSingleLine(node.labelTimestamp);\n const displayNode: SessionTreeNode = {\n entry: sanitizeEntryForDisplay(node.entry),\n children: [],\n };\n if (label !== undefined) displayNode.label = label;\n if (labelTimestamp !== undefined) displayNode.labelTimestamp = labelTimestamp;\n frame.target.push(displayNode);\n const source = captureRawCopySource(node.entry);\n if (source !== undefined) rawCopyText.set(node.entry.id, source);\n if (label !== undefined || labelTimestamp !== undefined) {\n savedLabels.set(node.entry.id, { label, labelTimestamp });\n }\n if (node.children.length > 0) {\n stack.push({ source: node.children, target: displayNode.children, index: 0 });\n }\n }\n return { tree, rawCopyText, savedLabels };\n}\n\nfunction sanitizeEntryForDisplay(entry: SessionEntry): SessionEntry {\n switch (entry.type) {\n case \"message\": {\n const message = { ...entry.message } as Record<string, unknown>;\n if (\"content\" in entry.message) message.content = sanitizeDisplayContent(entry.message.content);\n for (const key of [\"role\", \"errorMessage\", \"command\", \"toolName\"] as const) {\n const value = message[key];\n if (typeof value === \"string\") message[key] = sanitizeSingleLine(value);\n }\n return { ...entry, message } as unknown as SessionEntry;\n }\n case \"custom_message\":\n return {\n ...entry,\n customType: sanitizeSingleLine(entry.customType),\n content: sanitizeDisplayContent(entry.content) as typeof entry.content,\n };\n case \"compaction\":\n return { ...entry, summary: sanitizeSingleLine(entry.summary) };\n case \"branch_summary\":\n return { ...entry, summary: sanitizeSingleLine(entry.summary) };\n case \"model_change\":\n return {\n ...entry,\n provider: sanitizeSingleLine(entry.provider),\n modelId: sanitizeSingleLine(entry.modelId),\n };\n case \"thinking_level_change\":\n return { ...entry, thinkingLevel: sanitizeSingleLine(entry.thinkingLevel) };\n case \"custom\":\n return { ...entry, customType: sanitizeSingleLine(entry.customType) };\n case \"context_edit\":\n return { ...entry, targetId: sanitizeSingleLine(entry.targetId) };\n case \"label\":\n return {\n ...entry,\n label: entry.label === undefined ? undefined : sanitizeSingleLine(entry.label),\n };\n case \"session_info\":\n return {\n ...entry,\n name: entry.name === undefined ? undefined : sanitizeSingleLine(entry.name),\n };\n case \"usage\":\n return {\n ...entry,\n kind: sanitizeSingleLine(entry.kind),\n provider: sanitizeSingleLine(entry.provider),\n model: sanitizeSingleLine(entry.model),\n note: entry.note === undefined ? undefined : sanitizeSingleLine(entry.note),\n };\n }\n}\n\nfunction sanitizeDisplayContent(content: unknown): unknown {\n if (typeof content === \"string\") return sanitizeSingleLine(content);\n if (!Array.isArray(content)) return content;\n return content.map((block) => {\n if (block === null || typeof block !== \"object\" || !(\"type\" in block)) return block;\n if (block.type === \"text\" && \"text\" in block && typeof block.text === \"string\") {\n return { ...block, text: sanitizeSingleLine(block.text) };\n }\n if (block.type === \"toolCall\") {\n const copy = { ...block } as Record<string, unknown>;\n if (typeof copy.name === \"string\") copy.name = sanitizeSingleLine(copy.name);\n copy.arguments = sanitizeToolArguments(copy.arguments, new WeakMap());\n return copy;\n }\n return block;\n });\n}\n\nfunction sanitizeToolArguments(value: unknown, seen: WeakMap<object, unknown>): unknown {\n if (typeof value === \"string\") return sanitizeSingleLine(value);\n if (value === null || typeof value !== \"object\") return value;\n const existing = seen.get(value);\n if (existing !== undefined) return existing;\n if (Array.isArray(value)) {\n const result: unknown[] = [];\n seen.set(value, result);\n for (const item of value) result.push(sanitizeToolArguments(item, seen));\n return result;\n }\n const result: Record<string, unknown> = {};\n seen.set(value, result);\n for (const [key, item] of Object.entries(value)) {\n result[key] = sanitizeToolArguments(item, seen);\n }\n return result;\n}\n\nfunction captureRawCopySource(entry: SessionEntry): RawCopySource | undefined {\n let source: RawCopySource | undefined;\n if (entry.type === \"message\") {\n if (entry.message.role === \"bashExecution\") source = entry.message.command;\n else if (\"content\" in entry.message) {\n source = captureRawText(entry.message.content);\n const empty = typeof source === \"string\" ? source.length === 0 : source.every((part) => part.length === 0);\n if (empty && entry.message.role === \"assistant\") source = entry.message.errorMessage;\n }\n } else if (entry.type === \"custom_message\") source = captureRawText(entry.content);\n else if (entry.type === \"compaction\" || entry.type === \"branch_summary\") source = entry.summary;\n if (typeof source === \"string\") return /\\S/u.test(source) ? source : undefined;\n return source?.some((part) => /\\S/u.test(part)) ? source : undefined;\n}\n\nfunction captureRawText(content: unknown): RawCopySource {\n if (typeof content === \"string\") return content;\n if (!Array.isArray(content)) return \"\";\n // Retain immutable strings, not live blocks or joined copies of every message.\n const parts: string[] = [];\n for (const block of content) {\n if (\n block !== null &&\n typeof block === \"object\" &&\n \"type\" in block &&\n block.type === \"text\" &&\n \"text\" in block &&\n typeof block.text === \"string\"\n ) {\n parts.push(block.text);\n }\n }\n return parts.length === 1 ? parts[0] : parts;\n}\n\ninterface SavedLabel {\n label: string | undefined;\n labelTimestamp?: string;\n}\n\nasync function copyText(text: string, signal: AbortSignal): Promise<void> {\n signal.throwIfAborted();\n await copyToClipboard(text);\n signal.throwIfAborted();\n}\n\nfunction notifySafely(\n ctx: ExtensionCommandContext,\n message: string,\n level: Parameters<ExtensionCommandContext[\"ui\"][\"notify\"]>[1],\n): void {\n try {\n ctx.ui.notify(sanitizeSingleLine(message), level);\n } catch {\n // The command context may have been replaced while the selector was open.\n }\n}\n\nfunction formatError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EAKA;AAAA,OACK;AACP,SAAyC,KAAK,kBAAkB;AA2BhE,IAAM,gCAAN,MAAoE;AAAA,EAClE,YACmB,UACA,SACjB;AAFiB;AACA;AAAA,EAChB;AAAA,EAFgB;AAAA,EACA;AAAA,EAGnB,IAAI,UAAmB;AACrB,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,IAAI,QAAQ,OAAgB;AAC1B,SAAK,SAAS,UAAU;AAAA,EAC1B;AAAA,EAEA,IAAI,kBAAuC;AACzC,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,OAAO,OAAe;AACpB,WAAO,KAAK,SAAS,OAAO,KAAK;AAAA,EACnC;AAAA,EAEA,YAAY,MAAoB;AAC9B,QAAI,WAAW,MAAM,IAAI,KAAK,GAAG,CAAC,GAAG;AACnC,WAAK,QAAQ;AACb;AAAA,IACF;AACA,SAA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BAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;",
6
+ "names": ["result"]
7
+ }
@@ -217,7 +217,7 @@ var runFullscreenOnFirstUse = async (ctx, run, options) => {
217
217
  return runBtwFullscreen(ctx, run, options);
218
218
  };
219
219
  var pickEntryOnFirstUse = async (pi, ctx) => {
220
- const { pickMainEntry } = await import("./chunks/main-tree-picker-3PXJARQW.ts");
220
+ const { pickMainEntry } = await import("./chunks/main-tree-picker-WMTVRTR2.ts");
221
221
  if (ctx.signal?.aborted) return { kind: "closed" };
222
222
  return pickMainEntry(pi, ctx);
223
223
  };
@@ -292,6 +292,12 @@ The Pi core maintainer owns API design, implementation, tests, and publication a
292
292
  A later authorized BTW migration must pass the existing native-dispatch and terminal-restoration regressions before removing the workaround.
293
293
  No new Kit API or raised BTW dependency floor was required for that upstream API proposal. The separate shared physical-handoff extraction above must require the Kit release that first contains its API before dependent publication.
294
294
 
295
+ ## Idle main-submission verification
296
+
297
+ The idle-submission fix merged as `bab4b678` for issue #1752. Its four manager/direct and left/right readiness regressions failed against the original implementation and passed with the fix; all 751 BTW tests passed at that checkpoint. The Unix local-provider PTY matrix passed all 22 cases, and its original six-case matrix also passed. Native Windows ConPTY passed six right-pane cases at 140-by-40 with default F6, covering regular/fullscreen parents and idle manager, idle direct, and gated-streaming openings. Each main request completed and reached `agent_settled` before BTW closed; restored input and shutdown passed.
298
+
299
+ That implementation also passed package-directory RPC loading, generated-entry/lazy-boundary tests, pack inspection, and the asynchronous ownership/settings/terminal semantic audit. Its unfiltered root suite had one reproduced unchanged Starship failure; that historical failure was disclosed, not waived. At repository baseline `01525ffe`, sequential `npm run check` and full `npm test` passed: 947 files, 21,379 tests, 34 skips, and no unhandled errors. The completed idle-submission plan is removed; these results retain its evidence without claiming physical-terminal, IME, clipboard, or visual acceptance. The manual terminal handoff below still applies, and publication requires separate approval.
300
+
295
301
  ## Verification and remaining acceptance
296
302
 
297
303
  From the repository root, build before loading the declared package directory:
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-btw",
3
- "version": "0.63.8",
3
+ "version": "0.63.9",
4
4
  "description": "Pi extension that adds a /btw side-question command.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,9 +33,9 @@
33
33
  "prepack": "npm run build"
34
34
  },
35
35
  "devDependencies": {
36
- "@earendil-works/pi-ai": "1.5.0",
37
- "@earendil-works/pi-coding-agent": "1.5.0",
38
- "@earendil-works/pi-tui": "1.5.0",
36
+ "@earendil-works/pi-ai": "1.6.0",
37
+ "@earendil-works/pi-coding-agent": "1.6.0",
38
+ "@earendil-works/pi-tui": "1.6.0",
39
39
  "esbuild": "0.28.2",
40
40
  "typescript": "7.0.2"
41
41
  },
@@ -45,7 +45,7 @@
45
45
  "directory": "packages/pi-btw"
46
46
  },
47
47
  "dependencies": {
48
- "@narumitw/pi-tui-kit": "^0.70.0"
48
+ "@narumitw/pi-tui-kit": "^0.71.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@earendil-works/pi-ai": "*",
@@ -51,7 +51,7 @@ class MainThreadTreePickerComponent implements Component, Focusable {
51
51
  return this.selector.wantsKeyRelease;
52
52
  }
53
53
 
54
- render(width: number): string[] {
54
+ render(width: number) {
55
55
  return this.selector.render(width);
56
56
  }
57
57
 
@@ -1,5 +1,12 @@
1
1
  # @narumitw/pi-caffeinate
2
2
 
3
+ ## 0.49.16
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [1cbb470]
8
+ - @narumitw/pi-tui-kit@0.71.0
9
+
3
10
  ## 0.49.15
4
11
 
5
12
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-caffeinate",
3
- "version": "0.49.15",
3
+ "version": "0.49.16",
4
4
  "description": "Pi extension that keeps the computer awake while the agent is running.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "@earendil-works/pi-coding-agent": "*"
37
37
  },
38
38
  "devDependencies": {
39
- "@earendil-works/pi-coding-agent": "1.5.0",
39
+ "@earendil-works/pi-coding-agent": "1.6.0",
40
40
  "@types/node": "26.6.6",
41
41
  "esbuild": "0.28.2",
42
42
  "typescript": "7.0.2"
@@ -47,7 +47,7 @@
47
47
  "directory": "packages/pi-caffeinate"
48
48
  },
49
49
  "dependencies": {
50
- "@narumitw/pi-tui-kit": "^0.70.0",
50
+ "@narumitw/pi-tui-kit": "^0.71.0",
51
51
  "dbus-native": "^0.16.3"
52
52
  }
53
53
  }
@@ -1,5 +1,11 @@
1
1
  # User changelog
2
2
 
3
+ ## [4.5.2] - 2026-11-22
4
+
5
+ 1 feature, 23 fixes, 2 other changes.
6
+
7
+ Full notes: https://github.com/apmantza/pi-lens/releases/tag/v4.5.2
8
+
3
9
  ## [4.5.1] - 2026-11-16
4
10
 
5
11
  1 feature, 26 fixes, 1 other change.
@@ -23,9 +29,3 @@ Full notes: https://github.com/apmantza/pi-lens/releases/tag/v4.4.12
23
29
  32 fixes, 2 other changes.
24
30
 
25
31
  Full notes: https://github.com/apmantza/pi-lens/releases/tag/v4.4.11
26
-
27
- ## [4.4.10] - 2026-11-06
28
-
29
- 2 features, 7 fixes, 1 other change.
30
-
31
- Full notes: https://github.com/apmantza/pi-lens/releases/tag/v4.4.10
@@ -16,6 +16,127 @@ All notable changes to pi-lens will be documented in this file.
16
16
 
17
17
  ### Security
18
18
 
19
+ ## [4.5.2] - 2026-11-22
20
+
21
+ ### Added
22
+
23
+ #### Configuration and flags
24
+
25
+ - **The diagnostics widget can now move above the editor or hide when clean.** Set `widget.position` to `"aboveEditor"` or `"belowEditor"` (the default), and set `widget.hideWhenClean` to `true` to hide the widget 5 seconds after it first shows `✓ clean`. With the hide on, the widget also draws nothing until a first check gives it something to show. It returns on any finding, unchecked file, suppressed finding, failed formatter or starting server. Both keys are global-only and have no CLI flag. (refs #5724)
26
+
27
+ ### Changed
28
+
29
+ #### Install and updates
30
+
31
+ - **The jscpd installer pins 5.4.3, and pi 1.5.2 is the tested host.** New installs get jscpd 5.4.3 in place of 5.4.2. (refs #5670)
32
+
33
+ - **pi-lens no longer installs rubocop, rustfmt or rust-clippy without asking.** Their installs (`gem install`, `rustup component add`) change your whole gem root or toolchain. The three still run when present. When they are absent, the rubocop runner reports `not-installed`, the rust-clippy runner reports `probe-rejected`, and the rustfmt and rubocop formatters skip silently. (refs #5410)
34
+
35
+ ### Fixed
36
+
37
+ #### Language servers
38
+
39
+ - **Esc now cancels a project-wide diagnostics pull and a TypeScript project probe.** A `lens_diagnostics` full scan and the `projectInfo` request sent when a TypeScript file opens used to keep waiting on the language server after you aborted. Both now send a cancel and return at once. (refs #5097)
40
+
41
+ - **A language-server edit keeps the line ending of the edited line.** In a file with mixed line endings, new lines inserted by a rename or code action took the file's first line ending, so a CRLF line in an LF-first file got a bare LF (and the reverse). Files with one line-ending style are unchanged. (refs #5670)
42
+
43
+ - **Python servers reach global fallbacks, and PATH never runs unadmitted project files.** Python servers now reach global fallbacks for adopted projects: absent project candidates are reported as missing before trust is considered, while existing refused candidates no longer end a launch stage when installation is disabled. For an adopted project, or one pi has not trusted, a PATH entry inside the project (relative entries such as `bin` or `.` included) is skipped when a language server is looked up, and a PATH link into the project is refused. When PATH reaches such a project, managed lookups read only the pi-lens tool store, so the TypeScript and Jedi fallbacks and the Go, Ruby and .NET runtime installs no longer probe or run its `tsc`, `python` or `go`. (refs #5674)
44
+
45
+ - **The cascade now re-asks a push-only server about dependents it answered before your edit.** A server such as jdtls republishes a dependent when its own model changes, not when asked, so importers of an edited Java file stayed unconfirmed every time. For a server declared to re-check unchanged bytes (jdtls, TypeScript, Python) the cascade re-sends the dependent once per run and reads the answer; other servers are left as they were. A server that stays silent still leaves the dependent unconfirmed, never clean. (refs #5675)
46
+
47
+ - **LSP timeout notices now name the server and cause.** An unconfirmed document no longer reports only the generic unavailable message; the dispatch record carries the same reason for later inspection. (refs #5692)
48
+
49
+ - **On Windows, more language servers now end when pi ends.** A server whose path held a space, such as PowerShell 7 under `C:\Program Files`, or one installed as an npm 9 or later `.cmd` shim, ran behind `cmd.exe`, so pi's exit ended only the wrapper and the server kept running. pi-lens now starts these servers as its own direct child, so Windows ends them with pi even when pi is killed. A server started through another wrapper, such as a pnpm shim or a shim that passes Node flags, still runs behind `cmd.exe` and can outlive pi; pi-lens records each one as `lsp-server-uncontained`. (refs #5694)
50
+
51
+ - **Language servers now end with the pi or MCP process that started them.** On Linux and macOS, a server that ignored stdin EOF and SIGTERM outlived a pi quit, an MCP client disconnect, a SIGTERM to the MCP host and every `fresh` analysis worker. pi-lens now sends each held server's process group SIGKILL when its host exits. A host killed before that keeps its `instances.json` row, and the next pi or MCP start reaps the server. A server's child that ignores SIGTERM after the server exits is killed too, and `fresh` analysis now reads `lsp.json`. (refs #5699)
52
+
53
+ - **Language servers close old files and stop when a session goes idle.** Each client keeps at most 256 documents open (`PI_LENS_LSP_OPEN_DOCUMENT_CAP`) and closes the least recently sent one with `didClose`. A closed file's last findings stay readable, marked `closed: true` in the `lsp_navigation` workspace snapshot, and the next touch opens it again. Every server not declared `resident` is now released after the idle window on the pi host and the MCP host. Before, 32 servers, including every server a project declares, were never released. Only five project indexers (expert, kotlin, powershell, rust, svelte) stay resident. The pi host's session idle reset now restarts after a turn that edited files; before, such a turn cancelled it and nothing armed it again. (refs #5700)
54
+
55
+ - **Deno projects now use the Deno language server for TypeScript files.** TypeScript no longer claims files governed by `deno.json` or `deno.jsonc`, allowing the configured Deno fallback to start. (refs #5720)
56
+
57
+ - **An uncaught host error now runs exit cleanup for held language servers.** The LSP crash guard prints the stack and exits non-zero through Node's normal exit path, so pi RPC/print mode and the MCP host no longer leave a server behind. The stack report writes at most 16 KiB and waits at most 1 s for a full stderr pipe, so it cannot hold a crashing host. (refs #5744)
58
+
59
+ - **A checkout or rebase in a sibling worktree now refreshes the language server.**
60
+ A bash command that moved HEAD in another linked worktree it named, or
61
+ discarded edits there, left the server holding the old files with no record,
62
+ so it reported errors against code that no longer existed. (refs #5718)
63
+
64
+ #### Blockers and sessions
65
+
66
+ - **A file reached through a symlink no longer blocks its own export.** The duplicate-export STOP, the cached-export refresh and the deferred runner blocker each compared two spellings of one file as two files, so an edit through the real path left a removed export cached, the next write that declared it was refused, and a deferred blocker lost its line text. All three now compare by path identity. (refs #2556)
67
+
68
+ - **A fixed ast-grep blocker no longer stays "Still unfixed" while the language server is silent.** When a file's language server did not answer or could not start, pi-lens kept every blocker it had recorded for the file, including ast-grep ones that the ast-grep server had just checked clean. The fix then read as unfixed, stayed in `lens_diagnostics`, was listed again at turn end, and kept the commit gate shut. A recorded blocker is now judged by its own server's answer; blockers of a server that did not answer still stay. (refs #5727)
69
+
70
+ - **A STOP block now names the file a cross-file blocker belongs to.** The mypy
71
+ runner reports errors in the modules an edit imports, and those rows used to read as
72
+ lines of the edited file, with that file's line shown as their snippet. An
73
+ agent then marked them against the wrong file, where the mark never applied. (refs #5710)
74
+
75
+ - **A false-positive mark made from a STOP block now hides that finding.** Marking
76
+ what the block shows (the `[rule]` bracket as the rule, the rest as the message,
77
+ no tool) used to anchor on an identity the finding never had, so the same
78
+ finding came back on every edit. (refs #5709)
79
+
80
+ #### Runners and scanners
81
+
82
+ - **Prisma and Vite+ project edits no longer start an extra process per save.** The prisma and oxlint runners probed `prisma --version` and `vp --version` on PATH and kept no answer, so a tool that was slow to start or failed its probe cost every edit again. Both now read the shared per-project verdict like every other runner. (refs #5410)
83
+
84
+ - **A project that ships its own jscpd is no longer reported as missing.** The duplicate-code, circular-dependency, unused-code and secret scans now check their binary the way the linters do, so a managed gitleaks or opengrep that fails its version check falls back to the one on PATH instead of triggering an install. (refs #5410)
85
+
86
+ #### Tools and reports
87
+
88
+ - **Suppressing a diagnostic no longer rewrites a CRLF file's line endings.** The inline `pi-lens-ignore` comment takes the ending of the line it is inserted above, every existing line ending is kept, and a whitespace-only CRLF line no longer lends its bare `\r` to the inserted comment's indentation. (refs #5686)
89
+
90
+ #### Configuration and flags
91
+
92
+ - **Config readers now agree on `ignorePaths`, `effective_config` tools and legacy files.** A rule's `ignorePaths` match from the folder of the config file that declares them, so `/gen/**` in `repo/.pi-lens.json` skips `repo/gen` wherever you start pi. `effective_config` reports the tool switches your session uses, from the repository's own `.pi-lens.json` and your global config. Once a `.pi-lens.json` sits in the chain from your working directory up to the git root, a legacy `pi-lens.json` is ignored everywhere except the language-server settings. (refs #5738, #5739, #5740)
93
+
94
+ #### Install and updates
95
+
96
+ - **Installer downloads are streamed into bounded temporary files.** Release assets no longer collect the full download and decompressed binary in memory before installation. Downloads are capped, timed out, cleaned on failure, and only then moved into the managed install. (refs #5701)
97
+
98
+ #### Hosts and integrations
99
+
100
+ - **pi-lens now reaps its leftover logs, state and sockets at session start.** Oversized tool-result spill logs, saved session state, endpoint sockets whose owner process is gone, and project data directories whose project no longer exists used to accumulate forever; a disk audit measured 431 MB of project directories, 16 spill files from September, and 36 stale sockets on one machine. The session-start sweep now reaps each of these past its retention window. A project data directory goes only after 30 days, only when no path on disk can still be the project it was named for, and never on Windows; anything the sweep cannot judge stays. (refs #5702)
101
+
102
+ #### Security
103
+
104
+ - **A directory named with a backslash no longer counts as inside the project.** On Linux and macOS, a sibling directory such as `proj\evil` next to the session root `proj` was treated as part of it, so edits there got session treatment. (refs #2556)
105
+
106
+ - **On Windows, an untrusted project's gopls or rust-analyzer no longer runs through a sibling file.** When `$GOPATH\bin` or `$CARGO_HOME\bin` sat inside the repository and pi did not trust it, pi-lens refused the project's `<tool>.exe` but still offered the extensionless name, which Windows completes to any `.cmd`, `.bat` or `.com` beside it. The extensionless name is now withheld from an untrusted project directory, and refusing a sibling file that exists there is recorded as `trust-refusal`. (refs #5715)
107
+
108
+ ### Internal
109
+
110
+ <details>
111
+ <summary>10 internal changes: tests, CI, tooling, and refactors</summary>
112
+
113
+ - A settled `publishes after save only` cell in the LSP capability matrix now changes only after two nights agree, as `clean-behavior` does. One night's silent no-save arm had flipped powershell from `no` to `yes (saved write)` on 2026-11-15. (refs #3405)
114
+
115
+ - The idle-eviction doc's `result`, `reason`, `respawn` and `coverage` cells now change only after two nights agree, a night that could not spawn a server leaves its row alone, and the nightly seed step restores the doc with the matrix, so one night's reading no longer flips a row (opengrep on 2026-11-14) and a move between `unavailable` and `eligible` (csharp, dart, fsharp, go and ruby on 2026-11-06) waits for its second agreeing night. A census names the hold or the reason for every generated measured column. (refs #5667)
116
+
117
+ - The `--no-lens` control case in `tests/index-4913-cli-flag-timing.test.ts` and the mark-only turn case in `tests/index-4698-mark-only-turn-gate.test.ts` no longer carry the process's one-time cold start inside their 5 s cap, so both keep their headroom on a slow CI runner, and their stale timeout-headroom baseline rows are gone. (refs #5731)
118
+
119
+ - The whole-module `vi.mock` export ratchet now reds on a baseline count above the live count, as the flake-shape and LSP-double ratchets do. (refs #4907)
120
+
121
+ - The PR-gating `host range · newest-in-range` lane now installs the newest stable pi (the npm dist-tag `latest`) with no hand-kept ceiling, so a new pi release is exercised by a gating lane at once; a registry failure resolving `latest` fails the lane closed. The `PI_HOST_SUPPORTED_RANGE` ceiling is gone and the floor stays 0.86.1. (refs #5749)
122
+
123
+ - The nightly LSP census tracker files its drift issue only when a census output is not success. A job failure outside the census no longer files an issue with an empty census section (refs #5676).
124
+
125
+ - The `forgetTurnSession` FileTime test now passes on macOS. It looked up FileTime
126
+ under the temp directory's linked spelling, while the read guard stamps a
127
+ file's resolved path, so it failed whenever `TMPDIR` was a link. (refs #5716)
128
+
129
+ - Test workers no longer inherit the shell's active Python environment. An
130
+ exported `VIRTUAL_ENV`, `CONDA_PREFIX` or `UV_PROJECT_ENVIRONMENT`, and the bin
131
+ directory activation put on PATH, gave every test that environment's tools.
132
+ A developer with a global venv active saw tests read its pyright and pytest. (refs #5712)
133
+
134
+ - The Qodo review bot is retired: its trial ended and its billing notice read as unanswered findings at the land gate. `.pr_agent.toml` is deleted; CodeRabbit and Greptile keep their configs. (refs #4685)
135
+
136
+ - Four process-wide slots (the spawn-timeout cooldown, the opaque baseline store, the probe-home memo and safe-spawn's lifetime registry) now live behind `getProcessSingleton`, and a new sweep (`tests/config/process-slot-sweep.test.ts`) reds a hand-rolled `globalThis`, `Symbol.for` or `process` slot outside it. (refs #4907)
137
+
138
+ </details>
139
+
19
140
  ## [4.5.1] - 2026-11-16
20
141
 
21
142
  ### Added