@herbertgao/pi-extensions 2026.10.13 → 2026.10.14

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 (265) hide show
  1. package/README.md +11 -11
  2. package/THIRD_PARTY_NOTICES.md +2 -2
  3. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +2 -2
  4. package/node_modules/@herbertgao/pi-cc-extensions/README.md +2 -2
  5. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +1 -0
  6. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +3 -6
  7. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +22 -5
  8. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +44 -14
  9. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +1 -5
  10. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/index.ts +20 -5
  11. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +4 -1
  12. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +42 -18
  13. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/layout.ts +12 -3
  14. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/ccstyle-tool.ts +131 -0
  15. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +217 -113
  16. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +12 -5
  17. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/subagent-notification.ts +556 -0
  18. package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/ansi-text.ts +50 -0
  19. package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/format.ts +11 -0
  20. package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/patch-keys.ts +4 -0
  21. package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
  22. package/node_modules/@juicesharp/rpiv-ask-user-question/README.md +1 -0
  23. package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +27 -3
  24. package/node_modules/@juicesharp/rpiv-ask-user-question/config.ts +23 -0
  25. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/configuration.md +15 -0
  26. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/keyboard.md +9 -2
  27. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/de.json +7 -4
  28. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/en.json +8 -5
  29. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/es.json +7 -4
  30. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/fr.json +7 -4
  31. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/pt-BR.json +7 -4
  32. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/pt.json +7 -4
  33. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/ru.json +7 -4
  34. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/uk.json +7 -4
  35. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/zh.json +7 -4
  36. package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +4 -3
  37. package/node_modules/@juicesharp/rpiv-ask-user-question/presentation.ts +11 -1
  38. package/node_modules/@juicesharp/rpiv-ask-user-question/state/build-questionnaire.ts +6 -0
  39. package/node_modules/@juicesharp/rpiv-ask-user-question/state/key-router.ts +49 -8
  40. package/node_modules/@juicesharp/rpiv-ask-user-question/state/questionnaire-session.ts +6 -0
  41. package/node_modules/@juicesharp/rpiv-ask-user-question/state/state-reducer.ts +13 -1
  42. package/node_modules/@juicesharp/rpiv-ask-user-question/state/state.ts +2 -0
  43. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-block-renderer.ts +19 -7
  44. package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-builder.ts +36 -7
  45. package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-copy.ts +13 -2
  46. package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-content-strategy.ts +24 -8
  47. package/node_modules/@juicesharp/rpiv-ask-user-question/view/transcript.ts +144 -0
  48. package/node_modules/@narumitw/pi-btw/README.md +7 -2
  49. package/node_modules/@narumitw/pi-btw/dist/index.ts +371 -118
  50. package/node_modules/@narumitw/pi-btw/dist/index.ts.map +4 -4
  51. package/node_modules/@narumitw/pi-btw/docs/main-context-runtime.md +45 -0
  52. package/node_modules/@narumitw/pi-btw/docs/workflows.md +48 -5
  53. package/node_modules/@narumitw/pi-btw/package.json +1 -1
  54. package/node_modules/@narumitw/pi-btw/src/btw.ts +39 -14
  55. package/node_modules/@narumitw/pi-btw/src/import-main-updates.ts +84 -0
  56. package/node_modules/@narumitw/pi-btw/src/keybindings.ts +29 -4
  57. package/node_modules/@narumitw/pi-btw/src/main-context-snapshot.ts +125 -0
  58. package/node_modules/@narumitw/pi-btw/src/menu.ts +1 -0
  59. package/node_modules/@narumitw/pi-btw/src/side-thread.ts +66 -17
  60. package/node_modules/@narumitw/pi-btw/src/transcript-markdown.ts +5 -5
  61. package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +47 -6
  62. package/node_modules/pi-lens/CHANGELOG.md +440 -0
  63. package/node_modules/pi-lens/README.md +13 -3
  64. package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +1 -0
  65. package/node_modules/pi-lens/dist/chunk-22Y2BM7H.js +23 -0
  66. package/node_modules/pi-lens/dist/{chunk-ATKJFDQN.js → chunk-27VWVB23.js} +12 -14
  67. package/node_modules/pi-lens/dist/{chunk-S2HEXIWI.js → chunk-2FYKETQJ.js} +10 -6
  68. package/node_modules/pi-lens/dist/{chunk-SRYEJNES.js → chunk-2LDMXL2M.js} +2 -2
  69. package/node_modules/pi-lens/dist/{chunk-ZHH37KZL.js → chunk-2SDHYHHO.js} +17 -17
  70. package/node_modules/pi-lens/dist/chunk-2Y6OJRSI.js +38 -0
  71. package/node_modules/pi-lens/dist/chunk-3SNDVPOR.js +507 -0
  72. package/node_modules/pi-lens/dist/{chunk-5OFV52AM.js → chunk-3WCEHYOI.js} +1 -1
  73. package/node_modules/pi-lens/dist/chunk-44X7VIKR.js +73 -0
  74. package/node_modules/pi-lens/dist/{chunk-DEL2U6CM.js → chunk-4FHUGDKU.js} +16 -14
  75. package/node_modules/pi-lens/dist/{chunk-CT4MN5IU.js → chunk-4ODSZ35Z.js} +353 -359
  76. package/node_modules/pi-lens/dist/{chunk-ZIVJBOO3.js → chunk-4U7GDSZQ.js} +2 -2
  77. package/node_modules/pi-lens/dist/chunk-54NIOJJZ.js +25 -0
  78. package/node_modules/pi-lens/dist/{chunk-N5FLEO7W.js → chunk-5DKE4HGX.js} +37 -37
  79. package/node_modules/pi-lens/dist/{chunk-P63GXC37.js → chunk-5LRUKYFA.js} +31 -4
  80. package/node_modules/pi-lens/dist/{chunk-HRNHZA3N.js → chunk-63NMUNYP.js} +12 -16
  81. package/node_modules/pi-lens/dist/{chunk-HWCCCQNX.js → chunk-6XSESGWD.js} +13 -6
  82. package/node_modules/pi-lens/dist/{chunk-UMS2MFPZ.js → chunk-72J27ICO.js} +2 -3
  83. package/node_modules/pi-lens/dist/{chunk-ED36RF6Y.js → chunk-7FLRUH6B.js} +1 -1
  84. package/node_modules/pi-lens/dist/chunk-7IYC4ENJ.js +297 -0
  85. package/node_modules/pi-lens/dist/chunk-7WWQAW5P.js +30 -0
  86. package/node_modules/pi-lens/dist/{chunk-3DA2JDOL.js → chunk-7ZS7MC24.js} +551 -203
  87. package/node_modules/pi-lens/dist/{chunk-WMYE35PX.js → chunk-AHWA4AKM.js} +7 -5
  88. package/node_modules/pi-lens/dist/{chunk-JW3YWBVB.js → chunk-AI3GP74G.js} +17 -19
  89. package/node_modules/pi-lens/dist/{chunk-AGSS7277.js → chunk-APFJKOP6.js} +6 -23
  90. package/node_modules/pi-lens/dist/{chunk-ZVUL7QYY.js → chunk-ASRAO7KG.js} +29 -32
  91. package/node_modules/pi-lens/dist/{chunk-BW5KFIQC.js → chunk-AWQWXSW4.js} +1 -0
  92. package/node_modules/pi-lens/dist/{chunk-TLX72JTG.js → chunk-CG5V25HX.js} +1 -1
  93. package/node_modules/pi-lens/dist/chunk-CKEQFGLT.js +32 -0
  94. package/node_modules/pi-lens/dist/{chunk-Y6GZHWSJ.js → chunk-COOUUC5W.js} +6 -6
  95. package/node_modules/pi-lens/dist/{chunk-XTBDCR27.js → chunk-CPZ5JJW6.js} +4 -4
  96. package/node_modules/pi-lens/dist/{chunk-RKKOYPRA.js → chunk-DS2USX5G.js} +13 -15
  97. package/node_modules/pi-lens/dist/chunk-EA2ZRG44.js +27 -0
  98. package/node_modules/pi-lens/dist/{chunk-GSLNCYGG.js → chunk-EDMLIW6W.js} +13 -14
  99. package/node_modules/pi-lens/dist/{chunk-2EECBNC5.js → chunk-EIKRZ32J.js} +75 -0
  100. package/node_modules/pi-lens/dist/chunk-EKNWOL2I.js +27 -0
  101. package/node_modules/pi-lens/dist/{chunk-R3T7CLQ2.js → chunk-ELZRSR5N.js} +41 -41
  102. package/node_modules/pi-lens/dist/{chunk-GMX5OS7B.js → chunk-EN5AM7PX.js} +11 -12
  103. package/node_modules/pi-lens/dist/{chunk-3RKP3FMS.js → chunk-EWXXLS26.js} +226 -24
  104. package/node_modules/pi-lens/dist/chunk-EX4EXBW7.js +37 -0
  105. package/node_modules/pi-lens/dist/{chunk-XHJBS436.js → chunk-EXVXBSGN.js} +25 -25
  106. package/node_modules/pi-lens/dist/{chunk-MZGQNL3Y.js → chunk-F7BO6FWH.js} +12 -13
  107. package/node_modules/pi-lens/dist/{chunk-V35JG4JB.js → chunk-FEDWAYDS.js} +152 -334
  108. package/node_modules/pi-lens/dist/{chunk-J64T55EI.js → chunk-FWZRGGGY.js} +73 -9
  109. package/node_modules/pi-lens/dist/{chunk-T57LYLZT.js → chunk-G224FADB.js} +1 -1
  110. package/node_modules/pi-lens/dist/chunk-G5UCJFT7.js +26 -0
  111. package/node_modules/pi-lens/dist/{chunk-LLJNQKQW.js → chunk-GLW3YDZZ.js} +20 -13
  112. package/node_modules/pi-lens/dist/{chunk-GXFV6MYU.js → chunk-GTDSYEA2.js} +72 -39
  113. package/node_modules/pi-lens/dist/{chunk-DUO2TU77.js → chunk-GYRZ72R4.js} +10 -4
  114. package/node_modules/pi-lens/dist/chunk-HYVXA3BB.js +49 -0
  115. package/node_modules/pi-lens/dist/{chunk-W66O5E25.js → chunk-IEBJF3PN.js} +13 -15
  116. package/node_modules/pi-lens/dist/{chunk-GAQ7OQG6.js → chunk-IL7K66ZQ.js} +83 -94
  117. package/node_modules/pi-lens/dist/{chunk-T7FEBKXN.js → chunk-JWOVP5BL.js} +7 -9
  118. package/node_modules/pi-lens/dist/{chunk-UBOQLVT2.js → chunk-K2GUZ4DN.js} +4 -4
  119. package/node_modules/pi-lens/dist/{chunk-5VSF4UUQ.js → chunk-K4SZB56V.js} +34 -39
  120. package/node_modules/pi-lens/dist/{chunk-7D6L4MTX.js → chunk-KCBRHV5E.js} +3 -3
  121. package/node_modules/pi-lens/dist/{chunk-GSM5UU7A.js → chunk-KFXCL4OV.js} +38 -28
  122. package/node_modules/pi-lens/dist/{chunk-J6MPGQTS.js → chunk-KJJAVH3X.js} +81 -15
  123. package/node_modules/pi-lens/dist/{chunk-BWD5EPKO.js → chunk-KPVLQHCZ.js} +4 -6
  124. package/node_modules/pi-lens/dist/{chunk-MPNJLASA.js → chunk-KX56K73G.js} +10 -13
  125. package/node_modules/pi-lens/dist/{chunk-AWSCPCN2.js → chunk-LMCTHJ2H.js} +19 -19
  126. package/node_modules/pi-lens/dist/{chunk-IWDLU6K3.js → chunk-MEFLGBCS.js} +4 -6
  127. package/node_modules/pi-lens/dist/{chunk-TOY6QKOH.js → chunk-MKPCELNI.js} +17 -17
  128. package/node_modules/pi-lens/dist/{chunk-POMLXPMY.js → chunk-N3PLNNCW.js} +1 -1
  129. package/node_modules/pi-lens/dist/chunk-N5FBM25N.js +22 -0
  130. package/node_modules/pi-lens/dist/{chunk-CYRKQRPM.js → chunk-NFNVDDGB.js} +2 -4
  131. package/node_modules/pi-lens/dist/{chunk-RMLC67LF.js → chunk-NLIVE7L6.js} +2 -30
  132. package/node_modules/pi-lens/dist/{chunk-24AKHFGP.js → chunk-OMJ3OFBJ.js} +6 -6
  133. package/node_modules/pi-lens/dist/{chunk-IQWN5JCP.js → chunk-OZNCKLOX.js} +13 -14
  134. package/node_modules/pi-lens/dist/chunk-P5XUGPIX.js +31 -0
  135. package/node_modules/pi-lens/dist/{chunk-2KXTHF3M.js → chunk-PJXNTPB2.js} +253 -33
  136. package/node_modules/pi-lens/dist/chunk-PKOXJIVT.js +88 -0
  137. package/node_modules/pi-lens/dist/{chunk-DGUKIYSI.js → chunk-PP2A5V2T.js} +8 -10
  138. package/node_modules/pi-lens/dist/{chunk-KAPJINKN.js → chunk-Q42LJANT.js} +2 -2
  139. package/node_modules/pi-lens/dist/{chunk-UZ2XCLYS.js → chunk-Q4BKKOVC.js} +8 -8
  140. package/node_modules/pi-lens/dist/{chunk-TIQ2PKDW.js → chunk-QT66NEYN.js} +4 -4
  141. package/node_modules/pi-lens/dist/{chunk-U44DJXQP.js → chunk-RCHO5W7M.js} +15 -18
  142. package/node_modules/pi-lens/dist/{chunk-YH5MVY2U.js → chunk-RG3MXTRI.js} +7 -7
  143. package/node_modules/pi-lens/dist/chunk-RG7OODGM.js +57 -0
  144. package/node_modules/pi-lens/dist/{chunk-OHKJ7PQF.js → chunk-RU34BA4D.js} +43 -39
  145. package/node_modules/pi-lens/dist/{chunk-JMYYOTQG.js → chunk-S26LC76R.js} +13 -1
  146. package/node_modules/pi-lens/dist/{chunk-XBJVAEEO.js → chunk-S55TEC7I.js} +3 -2
  147. package/node_modules/pi-lens/dist/{chunk-RVK72CZX.js → chunk-SJHC3BCZ.js} +1397 -481
  148. package/node_modules/pi-lens/dist/{chunk-IYNJ6YPZ.js → chunk-SNEUMLM7.js} +4 -4
  149. package/node_modules/pi-lens/dist/{chunk-S67KYG37.js → chunk-T4NGVFYI.js} +2 -2
  150. package/node_modules/pi-lens/dist/{chunk-YCWYO6TQ.js → chunk-THEXI2QO.js} +48 -45
  151. package/node_modules/pi-lens/dist/{chunk-AMERCH6V.js → chunk-TL2TCJYL.js} +15 -16
  152. package/node_modules/pi-lens/dist/{chunk-KUA4OJ5Y.js → chunk-TPYYEDP5.js} +823 -350
  153. package/node_modules/pi-lens/dist/{chunk-YNE3RP52.js → chunk-TVZRLTG6.js} +8 -1
  154. package/node_modules/pi-lens/dist/{chunk-ROYSX2S5.js → chunk-UCVMSOXF.js} +2 -2
  155. package/node_modules/pi-lens/dist/chunk-UL5SXQVX.js +32 -0
  156. package/node_modules/pi-lens/dist/{chunk-7HXE67BN.js → chunk-UO66IMVP.js} +2 -2
  157. package/node_modules/pi-lens/dist/{chunk-VOOAPROD.js → chunk-UVY4TOJH.js} +3 -3
  158. package/node_modules/pi-lens/dist/{chunk-RKBXZN3A.js → chunk-VIDEKABZ.js} +2 -2
  159. package/node_modules/pi-lens/dist/{chunk-2FN63LPV.js → chunk-VITFDI3O.js} +13 -14
  160. package/node_modules/pi-lens/dist/{chunk-6DLWKFEX.js → chunk-VUAVE3QC.js} +41 -42
  161. package/node_modules/pi-lens/dist/{chunk-FM4RDMKT.js → chunk-WUY4BZEP.js} +10 -12
  162. package/node_modules/pi-lens/dist/{chunk-SD4I7ZO4.js → chunk-X3UTCXAA.js} +43 -53
  163. package/node_modules/pi-lens/dist/chunk-XHDBJODR.js +45 -0
  164. package/node_modules/pi-lens/dist/{chunk-5IUSNGOC.js → chunk-XHLK33VM.js} +28 -21
  165. package/node_modules/pi-lens/dist/{chunk-3KAZU3VR.js → chunk-XI34NWDI.js} +2 -2
  166. package/node_modules/pi-lens/dist/{chunk-QBFBRV2B.js → chunk-XWFIHYCH.js} +4 -2
  167. package/node_modules/pi-lens/dist/{chunk-JUKMK5Y4.js → chunk-Y2TPADJR.js} +10 -11
  168. package/node_modules/pi-lens/dist/{chunk-EBC36LNN.js → chunk-Y5KTA2OB.js} +17 -17
  169. package/node_modules/pi-lens/dist/{chunk-HYGZEMX6.js → chunk-YKVDBNPO.js} +11 -5
  170. package/node_modules/pi-lens/dist/{chunk-KN35K52N.js → chunk-YSDPVDFC.js} +3 -3
  171. package/node_modules/pi-lens/dist/chunk-YWNO5Q4R.js +44 -0
  172. package/node_modules/pi-lens/dist/{chunk-US7ECLD7.js → chunk-YWWG4AQA.js} +119 -28
  173. package/node_modules/pi-lens/dist/{chunk-O4NWQT6I.js → chunk-YXDCRUKQ.js} +4 -4
  174. package/node_modules/pi-lens/dist/{chunk-XYURS6EN.js → chunk-YXGRRORB.js} +15 -17
  175. package/node_modules/pi-lens/dist/{chunk-IUE7SSKV.js → chunk-ZAPSUBLU.js} +13 -7
  176. package/node_modules/pi-lens/dist/{chunk-EUXZEFTV.js → chunk-ZPJM7DID.js} +3 -3
  177. package/node_modules/pi-lens/dist/{chunk-5HSRT26B.js → chunk-ZSUX7KEM.js} +16 -15
  178. package/node_modules/pi-lens/dist/index.js +37155 -32210
  179. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +11 -12
  180. package/node_modules/pi-lens/dist/mcp/cli.js +46 -45
  181. package/node_modules/pi-lens/dist/mcp/server.js +1210 -574
  182. package/node_modules/pi-lens/dist/mcp/worker.js +65 -65
  183. package/node_modules/pi-lens/dist/probes/installer.js +21 -23
  184. package/node_modules/pi-lens/docs/adr/0010-trace-validation-session-lifecycle.md +390 -0
  185. package/node_modules/pi-lens/docs/adr/README.md +1 -0
  186. package/node_modules/pi-lens/docs/ast-grep_rules_catalog.md +5 -3
  187. package/node_modules/pi-lens/docs/configuration.md +9 -0
  188. package/node_modules/pi-lens/docs/engineering-principles.md +12 -0
  189. package/node_modules/pi-lens/docs/environment-variables.md +20 -0
  190. package/node_modules/pi-lens/docs/features.md +16 -1
  191. package/node_modules/pi-lens/docs/globalconfig.md +37 -8
  192. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +105 -12
  193. package/node_modules/pi-lens/docs/lsp-idle-eviction.md +37 -18
  194. package/node_modules/pi-lens/docs/pi-lens-fixer.md +22 -1
  195. package/node_modules/pi-lens/docs/pi-lens-investigator.md +14 -0
  196. package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +23 -10
  197. package/node_modules/pi-lens/docs/pi-lens-monitor.md +64 -8
  198. package/node_modules/pi-lens/docs/pi-lens-retro.md +2 -2
  199. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +48 -1
  200. package/node_modules/pi-lens/docs/pi-lens-subagent.md +8 -1
  201. package/node_modules/pi-lens/docs/release-qa-baseline.md +19 -7
  202. package/node_modules/pi-lens/docs/servercapabilities.md +47 -47
  203. package/node_modules/pi-lens/docs/settings.md +9 -5
  204. package/node_modules/pi-lens/docs/subagent-compat.md +1 -1
  205. package/node_modules/pi-lens/docs/usage.md +1 -0
  206. package/node_modules/pi-lens/package.json +6 -4
  207. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-return-value-in-generator-test.yml +17 -0
  208. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-js-test.yml +86 -0
  209. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-test.yml +86 -0
  210. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/unchecked-numeric-parse-python-test.yml +15 -0
  211. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-return-value-in-generator.yml +9 -4
  212. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +119 -0
  213. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +119 -0
  214. package/node_modules/pi-lens/rules/ast-grep-rules/rules/unchecked-numeric-parse-python.yml +13 -2
  215. package/node_modules/pi-lens/rules/rule-catalog.json +25 -1
  216. package/node_modules/pi-lens/scripts/analyze-pi-lens-logs.mjs +15 -5
  217. package/node_modules/pi-lens/scripts/lib/is-main-module.mjs +27 -0
  218. package/node_modules/pi-lens/scripts/lib/scratch-home-env.mjs +21 -0
  219. package/node_modules/pi-lens/scripts/rpc-load-check.mjs +4 -6
  220. package/node_modules/pi-lens/scripts/warm-loader-cache.mjs +2 -5
  221. package/node_modules/pi-next-cue/package.json +4 -1
  222. package/node_modules/pi-typesafe/README.md +6 -6
  223. package/node_modules/pi-typesafe/dist/ask.js +9 -2
  224. package/node_modules/pi-typesafe/dist/auth.d.ts +3 -2
  225. package/node_modules/pi-typesafe/dist/auth.js +2 -2
  226. package/node_modules/pi-typesafe/dist/backends.d.ts +20 -5
  227. package/node_modules/pi-typesafe/dist/backends.js +32 -8
  228. package/node_modules/pi-typesafe/dist/batch.d.ts +1 -1
  229. package/node_modules/pi-typesafe/dist/batch.js +2 -2
  230. package/node_modules/pi-typesafe/dist/client.d.ts +1 -1
  231. package/node_modules/pi-typesafe/dist/client.js +24 -12
  232. package/node_modules/pi-typesafe/dist/credentials.d.ts +8 -6
  233. package/node_modules/pi-typesafe/dist/credentials.js +70 -16
  234. package/node_modules/pi-typesafe/dist/extension.js +118 -26
  235. package/node_modules/pi-typesafe/dist/index.d.ts +1 -1
  236. package/node_modules/pi-typesafe/dist/index.js +1 -1
  237. package/node_modules/pi-typesafe/dist/key-prompt.d.ts +1 -1
  238. package/node_modules/pi-typesafe/dist/key-prompt.js +6 -6
  239. package/node_modules/pi-typesafe/dist/login.d.ts +11 -10
  240. package/node_modules/pi-typesafe/dist/login.js +24 -21
  241. package/node_modules/pi-typesafe/dist/schema.d.ts +8 -8
  242. package/node_modules/pi-typesafe/dist/schema.js +29 -7
  243. package/node_modules/pi-typesafe/package.json +2 -2
  244. package/package.json +11 -11
  245. package/node_modules/pi-lens/dist/chunk-3PTHXJXR.js +0 -28
  246. package/node_modules/pi-lens/dist/chunk-3QED2P4V.js +0 -31
  247. package/node_modules/pi-lens/dist/chunk-5WRPDP2A.js +0 -47
  248. package/node_modules/pi-lens/dist/chunk-ABBOA7UD.js +0 -157
  249. package/node_modules/pi-lens/dist/chunk-CUHSHSB6.js +0 -273
  250. package/node_modules/pi-lens/dist/chunk-GL5LUMZE.js +0 -51
  251. package/node_modules/pi-lens/dist/chunk-HAD7QRQI.js +0 -30
  252. package/node_modules/pi-lens/dist/chunk-JORED7EX.js +0 -44
  253. package/node_modules/pi-lens/dist/chunk-KYUB6QDC.js +0 -72
  254. package/node_modules/pi-lens/dist/chunk-LZSEQW6A.js +0 -57
  255. package/node_modules/pi-lens/dist/chunk-M2IFVFWU.js +0 -79
  256. package/node_modules/pi-lens/dist/chunk-M2UD3LPU.js +0 -88
  257. package/node_modules/pi-lens/dist/chunk-MBKQHGA7.js +0 -39
  258. package/node_modules/pi-lens/dist/chunk-R7YOCSNV.js +0 -23
  259. package/node_modules/pi-lens/dist/chunk-SKAMFC7A.js +0 -28
  260. package/node_modules/pi-lens/dist/chunk-SYE6T2EB.js +0 -28
  261. package/node_modules/pi-lens/dist/chunk-TRETHTQO.js +0 -26
  262. package/node_modules/pi-lens/dist/chunk-UA7ZXYDR.js +0 -184
  263. package/node_modules/pi-lens/dist/chunk-XTFDJI3T.js +0 -24
  264. package/node_modules/pi-lens/dist/chunk-Z3CCVDUB.js +0 -76
  265. package/node_modules/pi-next-cue/.github/workflows/publish.yml +0 -20
@@ -3,6 +3,7 @@ import { ThinkingPreviewBlock } from "../../feature/compact-thinking.ts";
3
3
  import { isCompactAssistantComponent } from "../compact-mode.ts";
4
4
  import { ToolGroupComponent } from "../tool/grouping.ts";
5
5
  import { isMessageDisplayComponent } from "../tool/message-display.ts";
6
+ import { isSubagentNotificationView } from "../tool/subagent-notification.ts";
6
7
  import { isToolExecutionComponent, stripTerminalSequencesPreservingLayout } from "./packets.ts";
7
8
  import { getScrollButtonWidget } from "./scroll.ts";
8
9
 
@@ -15,11 +16,19 @@ export type ComponentRowHit = {
15
16
  owner?: any;
16
17
  };
17
18
 
19
+ /**
20
+ * 消息类卡片:skill/压缩/分支摘要三种消息组件,以及单独出现的 subagent 通知行。
21
+ * 点击、悬停与 single-expand 规则相同。
22
+ */
23
+ export function isMessageCard(component: any): boolean {
24
+ return isMessageDisplayComponent(component) || isSubagentNotificationView(component);
25
+ }
26
+
18
27
  /** 行内 [click to show more] / [↑ Collapse] 提示的命中列区间(1-based,含两端)。 */
19
28
  export function collapsedHintHitbox(line: string): { startCol: number; endCol: number } | null {
20
29
  const plain = stripTerminalSequencesPreservingLayout(line);
21
30
  const match =
22
- /(\([^()\n]* \/ click\)|click to show more|to show more|↑ Collapse|to collapse)(?=\)?\s*$)/.exec(
31
+ /(\([^()\n]*(?: \/ click|, (?:[\w/+]+\s+)?to (?:expand|show more))\)|click to show more|to show more|↑ Collapse|to collapse)(?=\)?\s*$)/.exec(
23
32
  plain,
24
33
  );
25
34
  if (!match?.[1]) return null;
@@ -140,7 +149,7 @@ export function componentAtLocalRow(
140
149
  if (component instanceof ThinkingPreviewBlock) {
141
150
  return { component, row: localRow };
142
151
  }
143
- if (isMessageDisplayComponent(component)) {
152
+ if (isMessageCard(component)) {
144
153
  return { component, row: localRow };
145
154
  }
146
155
  if (component === getScrollButtonWidget()) {
@@ -182,7 +191,7 @@ export function collectFullscreenToolCards(
182
191
  component instanceof ToolGroupComponent ||
183
192
  isCompactAssistantComponent(component) ||
184
193
  component instanceof ThinkingPreviewBlock ||
185
- isMessageDisplayComponent(component)
194
+ isMessageCard(component)
186
195
  ) {
187
196
  out.push(component);
188
197
  return;
@@ -30,6 +30,7 @@ import {
30
30
  expandedBodyComponent,
31
31
  formatToolDuration,
32
32
  insetComponent,
33
+ renderCollapsedToolResult,
33
34
  renderCollapsedToolResultToWidth,
34
35
  textFromResult,
35
36
  toolViewportWidth,
@@ -46,6 +47,12 @@ import {
46
47
  toolIconColor,
47
48
  } from "./tool-state.ts";
48
49
  import { showMoreHintText } from "./names.ts";
50
+ import { oneLine } from "../../utils/format.ts";
51
+ import {
52
+ isFailedSubagentStatus,
53
+ measuredStats,
54
+ agentStatusLabel,
55
+ } from "./subagent-notification.ts";
49
56
 
50
57
  /** 成功勾:亮绿 truecolor(与 message-display 一致)。 */
51
58
  const BRIGHT_GREEN = "";
@@ -82,6 +89,8 @@ function renderDefault(tool: any, slot: "renderCall" | "renderResult", args: any
82
89
  return new Text(fallback, 0, 0);
83
90
  }
84
91
 
92
+ export const AGENT_TOOL_NAME = "Agent";
93
+
85
94
  type ParsedTask = { id: string; status: string; subject: string };
86
95
 
87
96
  function parseTaskList(text: string): ParsedTask[] {
@@ -185,6 +194,114 @@ function shellDurationText(toolName: string, context: any, isPartial: boolean):
185
194
  return elapsed === undefined ? "" : formatToolDuration(elapsed);
186
195
  }
187
196
 
197
+ /**
198
+ * Agent 的 renderResult:与 pi-subagents 保持同样的分支,但收敛成 ccstyle 的 ↳ 行。
199
+ * running/partial 转交原渲染器(只有它有 spinner frame 和 activity 文案);
200
+ * background/completed/stopped/error 画单行摘要,展开态结果正文交给通用展开视图。
201
+ */
202
+ function renderAgentResult(
203
+ originalTool: any,
204
+ result: any,
205
+ options: any,
206
+ theme: any,
207
+ context: any,
208
+ expanded: boolean,
209
+ isError: boolean,
210
+ ): any | undefined {
211
+ const details = result?.details;
212
+ const text = textFromResult(result);
213
+ // 没拿到子代理状态(pi-subagents 原始路径的兜底)就沿用通用渲染。
214
+ if (!details?.status) return undefined;
215
+
216
+ const isPartial = Boolean(options?.isPartial);
217
+ const status = String(details.status);
218
+
219
+ // running:pi-subagents 的 spinner/activity 组件才能实时动,原样转交。
220
+ if (isPartial || status === "running") {
221
+ return renderDefault(originalTool, "renderResult", [result, options, theme, context], text);
222
+ }
223
+
224
+ const stats = measuredStats(details).join(" · ");
225
+
226
+ const agentId = details.agentId ? `ID: ${details.agentId}` : "";
227
+ const tail = (body: string) => (stats ? `${body} · ${stats}` : body);
228
+
229
+ if (status === "background") {
230
+ if (!expanded) {
231
+ const body = tail(`Running in background${agentId ? ` · ${agentId}` : ""}`);
232
+ return new Text(theme.fg("muted", renderCollapsedToolResult(body, "")), 0, 0);
233
+ }
234
+ const view = renderExpandedToolResult(
235
+ `Running in background${agentId ? ` · ${agentId}` : ""}`,
236
+ theme,
237
+ false,
238
+ context?.lastComponent,
239
+ context?.args,
240
+ context,
241
+ true,
242
+ );
243
+ return view;
244
+ }
245
+
246
+ if (status === "completed" || status === "steered") {
247
+ if (!expanded) {
248
+ const label = status === "steered" ? "Wrapped up (turn limit)" : "Done";
249
+ const body = [label, stats].filter(Boolean).join(" · ");
250
+ return new Text(theme.fg("muted", renderCollapsedToolResult(body, "")), 0, 0);
251
+ }
252
+ const view = renderExpandedToolResult(
253
+ text || "Done",
254
+ theme,
255
+ Boolean(isError),
256
+ context?.lastComponent,
257
+ context?.args,
258
+ context,
259
+ true,
260
+ );
261
+ return view;
262
+ }
263
+
264
+ if (status === "stopped") {
265
+ if (!expanded) {
266
+ const body = tail("Stopped");
267
+ return new Text(theme.fg("muted", renderCollapsedToolResult(body, "")), 0, 0);
268
+ }
269
+ return renderExpandedToolResult(
270
+ text || "Stopped",
271
+ theme,
272
+ Boolean(isError),
273
+ context?.lastComponent,
274
+ context?.args,
275
+ context,
276
+ true,
277
+ );
278
+ }
279
+
280
+ // error / aborted:折叠时首行错误文案 + 统计;展开时走通用展开视图。
281
+ const label = agentStatusLabel(status);
282
+ const firstLine = text.split("\n").find((line) => line.trim()) ?? label;
283
+ if (!expanded) {
284
+ const body = tail(oneLine(firstLine, 72));
285
+ return new Text(
286
+ theme.fg(
287
+ isFailedSubagentStatus(status) ? "error" : "muted",
288
+ renderCollapsedToolResult(body, ""),
289
+ ),
290
+ 0,
291
+ 0,
292
+ );
293
+ }
294
+ return renderExpandedToolResult(
295
+ text || label,
296
+ theme,
297
+ isFailedSubagentStatus(status) || Boolean(isError),
298
+ context?.lastComponent,
299
+ context?.args,
300
+ context,
301
+ true,
302
+ );
303
+ }
304
+
188
305
  /** 用 ccstyle call/result 包装任意工具定义。 */
189
306
  export function createCcstyleTool(
190
307
  originalTool: any,
@@ -315,6 +432,20 @@ export function createCcstyleTool(
315
432
 
316
433
  const expanded = isToolExpanded(options, context);
317
434
  const isError = Boolean(options?.isError || context?.isError);
435
+ // Agent:running 转交原渲染器(spinner/activity 只有它有);其余画 ↳ 摘要行。
436
+ // toolName 大小写宽松匹配:上游改名也不静默失效。
437
+ if (toolName.toLowerCase() === AGENT_TOOL_NAME.toLowerCase()) {
438
+ const agentResult = renderAgentResult(
439
+ originalTool,
440
+ result,
441
+ options,
442
+ theme,
443
+ context,
444
+ expanded,
445
+ isError,
446
+ );
447
+ if (agentResult) return agentResult;
448
+ }
318
449
  // codemode:折叠态自己画子调用树,展开态给全部子调用与去掉脚本头的输出
319
450
  if (toolName === CODEMODE_TOOL_NAME) {
320
451
  if (!options?.isPartial) setToolVisualState(context, isError ? "error" : "success");
@@ -7,7 +7,7 @@ import {
7
7
  type Component,
8
8
  } from "@earendil-works/pi-tui";
9
9
  import { config } from "../../config/config.ts";
10
- import { aggregateToolCardBgSlot, toolCardStatus } from "./tool-state.ts";
10
+ import { TOOL_CARD_BG_SLOT, toolCardStatus } from "./tool-state.ts";
11
11
  import { TOOL_LOADING_INTERVAL_MS, toolLoadingIcon } from "../../utils/tool-loading-icon.ts";
12
12
  import {
13
13
  ASK_USER_QUESTION_TOOL_NAME,
@@ -24,7 +24,13 @@ import {
24
24
  import { getToolMouseTui } from "../mouse/scroll.ts";
25
25
  import { mcpToolTitle } from "./mcp-title.ts";
26
26
  import { collapseHintText, isToolTuiFullscreen, showMoreHintText } from "./names.ts";
27
- import { stripAnsi, stripBackgroundAnsi, stripLeadingStatusIcon } from "../../utils/ansi-text.ts";
27
+ import {
28
+ contentRowRange,
29
+ imagePlacement,
30
+ stripAnsi,
31
+ stripBackgroundAnsi,
32
+ stripLeadingStatusIcon,
33
+ } from "../../utils/ansi-text.ts";
28
34
  import { walkComponentTree } from "../../utils/component-tree.ts";
29
35
  import {
30
36
  fitToolCallSummary,
@@ -36,6 +42,11 @@ import {
36
42
  } from "./names.ts";
37
43
  import { formatToolDuration, headTruncateToWidth, toolViewportWidth } from "./result.ts";
38
44
  import { isLiveToolCall } from "./tool-state.ts";
45
+ import {
46
+ AGENT_TOOL_NAME,
47
+ isSubagentNotificationComponent,
48
+ subagentNotificationItems,
49
+ } from "./subagent-notification.ts";
39
50
  import {
40
51
  patchRegistry,
41
52
  TOOL_GROUPING_GENERATION_KEY as GENERATION_KEY,
@@ -76,10 +87,15 @@ function toolTitle(tool: any): string {
76
87
  );
77
88
  }
78
89
 
79
- function isGroupable(value: unknown): boolean {
90
+ function isGroupableTool(value: unknown): boolean {
80
91
  return value instanceof ToolExecutionComponent && !NON_GROUPABLE.has(toolName(value));
81
92
  }
82
93
 
94
+ /** 可分组项:工具,或子代理完成通知(只是展示项,不是工具执行)。 */
95
+ function isGroupable(value: unknown): boolean {
96
+ return isGroupableTool(value) || isSubagentNotificationComponent(value);
97
+ }
98
+
83
99
  function isIgnorable(value: unknown): boolean {
84
100
  if (value instanceof Spacer) return true;
85
101
  if (!(value instanceof AssistantMessageComponent)) return false;
@@ -103,7 +119,36 @@ function previousSibling(
103
119
  return undefined;
104
120
  }
105
121
 
106
- type ToolStatus = "pending" | "success" | "error";
122
+ export type ToolStatus = "pending" | "success" | "error";
123
+
124
+ type Fg = (color: string, text: string) => string;
125
+
126
+ function themeFg(theme: any): Fg {
127
+ return (color, text) => theme?.fg?.(color, text) ?? text;
128
+ }
129
+
130
+ /**
131
+ * 分组里的一行显示项:工具一项;子代理完成通知按 agent 各一项。
132
+ * 分组只管计数、树形缩进与展开状态转发,每项自己负责摘要与展开内容。
133
+ */
134
+ export type GroupDisplayItem = {
135
+ /** 组头判定「是否同一种」用的身份:工具原名,或通知类型。 */
136
+ name: string;
137
+ /** 组头工具列表与子行用的显示名。 */
138
+ label: string;
139
+ status: ToolStatus;
140
+ /** 折叠行正文(接在树枝与状态图标之后),width 为剩余可用宽度。 */
141
+ summary(width: number, theme: any): string;
142
+ /**
143
+ * 展开行:首行接在树枝与状态图标之后,其余作为续行。width 为面板内宽(含树枝前缀)。
144
+ * 输入不变时返回同一数组:分组展开缓存按引用比对。
145
+ */
146
+ expandedRows(width: number, theme: any): string[];
147
+ /** 展开态里这些行对应的内部卡片;没有时行归分组本身(点击收起整组)。 */
148
+ hitTarget?: unknown;
149
+ /** 丢掉该项自己缓存的行(换主题后颜色要重算);分组 invalidate 时转发。 */
150
+ invalidate?(): void;
151
+ };
107
152
 
108
153
  function status(tool: any): ToolStatus {
109
154
  return toolCardStatus(tool);
@@ -154,8 +199,22 @@ function requestAnimationRender(patch: Patch): void {
154
199
  getToolMouseTui()?.requestRender?.();
155
200
  }
156
201
 
202
+ /** 丢掉空白行;内联图片锚点行与它占用的空行要留着,否则终端里图片盖住后续行。 */
157
203
  function visibleLines(lines: string[]): string[] {
158
- return lines.filter((line) => stripAnsi(line).trim());
204
+ const keep = new Set<number>();
205
+ for (let index = 0; index < lines.length; index++) {
206
+ const placement = imagePlacement(lines[index]);
207
+ if (!placement) {
208
+ if (stripAnsi(lines[index]).trim()) keep.add(index);
209
+ continue;
210
+ }
211
+ const start = placement.grows === "up" ? index - placement.rows + 1 : index;
212
+ const end = placement.grows === "down" ? index + placement.rows - 1 : index;
213
+ for (let row = Math.max(0, start); row <= Math.min(lines.length - 1, end); row++) {
214
+ keep.add(row);
215
+ }
216
+ }
217
+ return lines.filter((_line, index) => keep.has(index));
159
218
  }
160
219
 
161
220
  function stripLeadingSpaces(line: string, count: number): string {
@@ -275,29 +334,85 @@ function shellResultTail(
275
334
  return duration ? ` ${fg("dim", `· ${duration}`)}` : "";
276
335
  }
277
336
 
278
- /** 分组折叠态的一行子工具:`├/└` + 状态图标 + 与组内同一套摘要。 */
279
- function collapsedGroupToolLine(
280
- tool: any,
337
+ /** 子工具折叠行正文:与组内同一套摘要。 */
338
+ function toolSummaryText(tool: any, toolStatus: ToolStatus, width: number, fg: Fg): string {
339
+ const summary = askUserResultSummary(tool) ?? codemodeResultSummary(tool) ?? toolSummary(tool);
340
+ const detail = fg("dim", summary.detail);
341
+ const result = agentResultTail(tool, fg) + shellResultTail(tool, fg, toolStatus);
342
+ const mainWidth = Math.max(0, width - visibleWidth(detail) - visibleWidth(result));
343
+ return `${renderToolSummary(summary, mainWidth, fg)}${detail}${result}`;
344
+ }
345
+
346
+ /**
347
+ * Agent 的折叠行尾巴:`-> Running in background · ID: xxx`。参考 ask_user_question 的
348
+ * 问题 -> 回答写法:跑后台的结果状态放在 payload 后,比单独的 ↳ 行省一行。
349
+ */
350
+ function agentResultTail(tool: any, fg: Fg): string {
351
+ if (toolName(tool).toLowerCase() !== AGENT_TOOL_NAME.toLowerCase() || !tool?.result) return "";
352
+ const details = tool.result.details;
353
+ if (details?.status !== "background") return "";
354
+ const agentId = details.agentId ? ` ID: ${details.agentId}` : "";
355
+ return ` ${fg("dim", "\u2192")} ${fg("dim", `Running in background${agentId}`)}`;
356
+ }
357
+
358
+ /** 原始 paint → 去掉状态图标与外层缩进后的展开行;paint 引用不变就复用。 */
359
+ const expandedToolRowsCache = new WeakMap<string[], string[]>();
360
+
361
+ function expandedToolRows(tool: any, width: number): string[] {
362
+ const paint = tool.render?.(width);
363
+ if (!Array.isArray(paint)) return [toolSummary(tool).main];
364
+ const cached = expandedToolRowsCache.get(paint);
365
+ if (cached) return cached;
366
+ const rendered = visibleLines(paint);
367
+ if (rendered.length) {
368
+ rendered[0] = stripLeadingStatusIcon(rendered[0])
369
+ .replace(/^ +/, "")
370
+ .replace(/^((?:\x1b\[[0-?]*[ -/]*[@-~])*) +/, "$1");
371
+ }
372
+ const rows = rendered.length
373
+ ? // 续行只剥外层 Box 的 1 格 left pad,保留 Input/Output 相对缩进
374
+ rendered.map((line, index) => (index === 0 ? line : stripLeadingSpaces(line, 1)))
375
+ : [toolSummary(tool).main];
376
+ expandedToolRowsCache.set(paint, rows);
377
+ return rows;
378
+ }
379
+
380
+ function toolItem(tool: any): GroupDisplayItem {
381
+ const toolStatus = status(tool);
382
+ return {
383
+ name: toolName(tool),
384
+ label: toolTitle(tool),
385
+ status: toolStatus,
386
+ summary: (width, theme) => toolSummaryText(tool, toolStatus, width, themeFg(theme)),
387
+ expandedRows: (width) => expandedToolRows(tool, width),
388
+ hitTarget: tool,
389
+ };
390
+ }
391
+
392
+ function groupItems(children: readonly unknown[]): GroupDisplayItem[] {
393
+ return children.flatMap((child) => subagentNotificationItems(child) ?? [toolItem(child)]);
394
+ }
395
+
396
+ /** 分组折叠态的一行:`├/└` + 状态图标 + 该项摘要。 */
397
+ function collapsedGroupLine(
398
+ item: GroupDisplayItem,
281
399
  last: boolean,
282
- fg: (color: string, text: string) => string,
400
+ theme: any,
283
401
  width: number,
284
402
  ): string {
285
- const toolStatus = status(tool);
286
- const color = toolStatus === "pending" ? "dim" : toolStatus;
287
- const summary = askUserResultSummary(tool) ?? codemodeResultSummary(tool) ?? toolSummary(tool);
288
- const prefix = ` ${fg("dim", last ? "└" : "├")} ${fg(color, statusIcon(toolStatus))} `;
289
- const detail = fg("dim", summary.detail);
290
- const result = shellResultTail(tool, fg, toolStatus);
403
+ const fg = themeFg(theme);
404
+ const color = item.status === "pending" ? "dim" : item.status;
405
+ const prefix = ` ${fg("dim", last ? "└" : "├")} ${fg(color, statusIcon(item.status))} `;
291
406
  const rowWidth = toolViewportWidth(width);
292
- const mainWidth = Math.max(
293
- 0,
294
- rowWidth - visibleWidth(prefix) - visibleWidth(detail) - visibleWidth(result),
295
- );
296
- return truncateToWidth(
297
- `${prefix}${renderToolSummary(summary, mainWidth, fg)}${detail}${result}`,
298
- rowWidth,
299
- "",
300
- );
407
+ const room = Math.max(0, rowWidth - visibleWidth(prefix));
408
+ return truncateToWidth(`${prefix}${item.summary(room, theme)}`, rowWidth, "");
409
+ }
410
+
411
+ /** 末项结尾的尾随空行不计入卡高(内联图片的占位行除外,见 contentRowRange)。 */
412
+ function panelRows(rows: string[], last: boolean): string[] {
413
+ if (!last) return rows;
414
+ const end = Math.max(1, contentRowRange(rows).last + 1);
415
+ return end >= rows.length ? rows : rows.slice(0, end);
301
416
  }
302
417
 
303
418
  type GroupHeaderCounts = { pending: number; success: number; error: number };
@@ -326,10 +441,9 @@ function groupOverallStatus(counts: GroupHeaderCounts): ToolStatus {
326
441
  * 组头的工具列表:名称用与单组标题、子行同一套人性化写法,次数一律带上(各跑一次也报 ×1)。
327
442
  * 同名(同显示标题)的合并成一项,避免 `MCP call×1, MCP call×1` 这种重复。
328
443
  */
329
- function toolNameList(tools: any[]): string {
444
+ function toolNameList(items: readonly GroupDisplayItem[]): string {
330
445
  const counts = new Map<string, number>();
331
- for (const tool of tools) {
332
- const label = toolTitle(tool);
446
+ for (const { label } of items) {
333
447
  counts.set(label, (counts.get(label) ?? 0) + 1);
334
448
  }
335
449
  return [...counts].map(([label, count]) => `${label}×${count}`).join(", ");
@@ -425,17 +539,18 @@ export class ToolGroupComponent extends Container {
425
539
  childAtRow(localRow: number, width: number): { component: any; row: number } | null {
426
540
  if (!this._expanded || localRow < 2) return null;
427
541
  let offset = 2;
428
- for (const tool of this.children) {
429
- let lines: string[] = [];
542
+ const items = groupItems(this.children);
543
+ for (let index = 0; index < items.length; index++) {
544
+ const item = items[index];
545
+ let lineCount = 1;
430
546
  try {
431
- const rendered = tool.render?.(Math.max(1, width - 2));
432
- if (Array.isArray(rendered)) lines = visibleLines(rendered.map((line) => String(line)));
547
+ const rows = item.expandedRows(Math.max(1, width - 2), this.patch.theme);
548
+ lineCount = Math.max(1, panelRows(rows, index === items.length - 1).length);
433
549
  } catch {
434
- lines = [];
550
+ lineCount = 1;
435
551
  }
436
- const lineCount = Math.max(1, lines.length);
437
552
  if (localRow < offset + lineCount) {
438
- return { component: tool, row: localRow - offset };
553
+ return item.hitTarget ? { component: item.hitTarget, row: localRow - offset } : null;
439
554
  }
440
555
  offset += lineCount;
441
556
  }
@@ -445,6 +560,7 @@ export class ToolGroupComponent extends Container {
445
560
  invalidate(): void {
446
561
  this.clearPaintCache();
447
562
  for (const tool of this.children) tool.invalidate?.();
563
+ for (const item of groupItems(this.children)) item.invalidate?.();
448
564
  }
449
565
 
450
566
  private settledCacheHit(width: number): string[] | undefined {
@@ -466,7 +582,7 @@ export class ToolGroupComponent extends Container {
466
582
  cache.children[i] !== tool ||
467
583
  cache.args[i] !== tool?.args ||
468
584
  cache.results[i] !== tool?.result ||
469
- status(tool) === "pending"
585
+ (!isSubagentNotificationComponent(tool) && status(tool) === "pending")
470
586
  ) {
471
587
  return;
472
588
  }
@@ -491,12 +607,15 @@ export class ToolGroupComponent extends Container {
491
607
  const cached = this.settledCacheHit(width);
492
608
  if (cached) return cached;
493
609
  const theme = this.patch.theme;
494
- const fg = (color: string, text: string) => theme?.fg?.(color, text) ?? text;
610
+ const fg = themeFg(theme);
611
+ const items = groupItems(this.children);
495
612
  const counts = { pending: 0, success: 0, error: 0 };
496
- for (const tool of this.children) counts[status(tool)]++;
613
+ // 组头按行计数:通知的每个 agent 算一行(与工具各一行同一口径,避免
614
+ // 「5 done 其实是 4 工具 + 1 通知行」这类误导)。
615
+ for (const item of items) counts[item.status]++;
497
616
  const countText = groupCountText(counts, fg);
498
- const names = new Set(this.children.map(toolName));
499
- const label = names.size === 1 ? toolTitle(this.children[0]) : "Multiple Tools";
617
+ const names = new Set(items.map((item) => item.name));
618
+ const label = names.size === 1 ? items[0].label : "Multiple Tools";
500
619
  const overall = groupOverallStatus(counts);
501
620
  if ((this.children as any[]).some(isAnimatingTool)) scheduleGroupAnimation(this.patch);
502
621
  const overallColor = overall === "pending" ? "dim" : overall;
@@ -512,76 +631,58 @@ export class ToolGroupComponent extends Container {
512
631
  // 连一个工具名都放不下就不放列表:退化成 `· …` 只会把行撑爆。
513
632
  const nameList =
514
633
  names.size > 1 && listRoom >= 4
515
- ? ` ${fg("dim", `· ${headTruncateToWidth(toolNameList(this.children), listRoom)}`)}`
634
+ ? ` ${fg("dim", `· ${headTruncateToWidth(toolNameList(items), listRoom)}`)}`
516
635
  : "";
517
636
  const lines = ["", truncateToWidth(`${head}${nameList}${tail}`, rowWidth, "")];
518
- const total = this.children.length;
519
- const childPaints = this._expanded
520
- ? (this.children as any[]).map((tool) => tool.render?.(Math.max(1, width - 2)))
521
- : undefined;
522
- if (this._expanded && childPaints) {
523
- const expandedHit = this.expandedPaintCache;
524
- if (
525
- expandedHit &&
526
- expandedHit.width === width &&
527
- expandedHit.hover === this.hintHovered &&
528
- expandedHit.theme === this.patch.theme &&
529
- expandedHit.fullscreen === isToolTuiFullscreen() &&
530
- expandedHit.bgSlot === aggregateToolCardBgSlot(this.children) &&
531
- expandedHit.paints.length === childPaints.length &&
532
- expandedHit.paints.every((paint, index) => paint === childPaints[index])
533
- ) {
534
- return expandedHit.lines;
637
+ const total = items.length;
638
+ if (!this._expanded) {
639
+ for (let index = 0; index < total; index++) {
640
+ lines.push(collapsedGroupLine(items[index], index === total - 1, theme, width));
535
641
  }
642
+ if (counts.pending === 0) this.storeSettledCache(width, lines);
643
+ return lines;
644
+ }
645
+ // 有一个失败整卡用失败底色;没有失败但还有进行中用进行中底色。
646
+ const backgroundSlot = TOOL_CARD_BG_SLOT[overall];
647
+ const itemPaints = items.map((item) => item.expandedRows(Math.max(1, width - 2), theme));
648
+ const expandedHit = this.expandedPaintCache;
649
+ if (
650
+ expandedHit &&
651
+ expandedHit.width === width &&
652
+ expandedHit.hover === this.hintHovered &&
653
+ expandedHit.theme === this.patch.theme &&
654
+ expandedHit.fullscreen === isToolTuiFullscreen() &&
655
+ expandedHit.bgSlot === backgroundSlot &&
656
+ expandedHit.paints.length === itemPaints.length &&
657
+ expandedHit.paints.every((paint, index) => paint === itemPaints[index])
658
+ ) {
659
+ return expandedHit.lines;
536
660
  }
537
- const expandedLines: string[] = [];
538
661
  for (let index = 0; index < total; index++) {
539
- const tool = this.children[index];
540
- const toolStatus = status(tool);
541
- const color = toolStatus === "pending" ? "dim" : toolStatus;
542
- const branch = index === total - 1 ? "└" : "├";
543
- const continuation = index === total - 1 ? " " : "│ ";
544
- if (!this._expanded) {
545
- lines.push(collapsedGroupToolLine(tool, index === total - 1, fg, width));
546
- continue;
547
- }
548
- const rendered = visibleLines(Array.isArray(childPaints?.[index]) ? childPaints[index] : []);
549
- if (rendered.length) {
550
- rendered[0] = stripLeadingStatusIcon(rendered[0])
551
- .replace(/^ +/, "")
552
- .replace(/^((?:\x1b\[[0-?]*[ -/]*[@-~])*) +/, "$1");
553
- }
554
- const childLines = rendered.length ? rendered : [toolSummary(tool).main];
555
- for (let lineIndex = 0; lineIndex < childLines.length; lineIndex++) {
556
- const content =
557
- // 续行只剥外层 Box 的 1 格 left pad,保留 Input/Output 相对缩进
558
- lineIndex === 0 ? childLines[lineIndex] : stripLeadingSpaces(childLines[lineIndex], 1);
662
+ const item = items[index];
663
+ const color = item.status === "pending" ? "dim" : item.status;
664
+ const last = index === total - 1;
665
+ const branch = last ? "└" : "├";
666
+ const continuation = last ? " " : "│ ";
667
+ const rows = panelRows(itemPaints[index], last);
668
+ for (let lineIndex = 0; lineIndex < rows.length; lineIndex++) {
559
669
  const prefix =
560
670
  lineIndex === 0
561
- ? `${fg("dim", branch)} ${fg(color, statusIcon(toolStatus))} `
671
+ ? `${fg("dim", branch)} ${fg(color, statusIcon(item.status))} `
562
672
  : fg("dim", continuation);
563
- expandedLines.push(prefix + content);
564
- }
565
- }
566
- if (this._expanded) {
567
- // 有一个失败整卡用失败底色;没有失败但还有进行中用进行中底色。
568
- const backgroundSlot = aggregateToolCardBgSlot(this.children);
569
- for (const line of expandedLines) {
570
- lines.push(paddedBackgroundRow(theme, backgroundSlot, line, width));
673
+ lines.push(paddedBackgroundRow(theme, backgroundSlot, prefix + rows[lineIndex], width));
571
674
  }
572
- lines.push(paddedBackgroundRow(theme, backgroundSlot, "", width));
573
- this.expandedPaintCache = {
574
- width,
575
- hover: this.hintHovered,
576
- theme: this.patch.theme,
577
- fullscreen: isToolTuiFullscreen(),
578
- bgSlot: backgroundSlot,
579
- paints: childPaints ?? [],
580
- lines,
581
- };
582
- } else if (counts.pending === 0) {
583
- this.storeSettledCache(width, lines);
584
675
  }
676
+ lines.push(paddedBackgroundRow(theme, backgroundSlot, "", width));
677
+ this.expandedPaintCache = {
678
+ width,
679
+ hover: this.hintHovered,
680
+ theme: this.patch.theme,
681
+ fullscreen: isToolTuiFullscreen(),
682
+ bgSlot: backgroundSlot,
683
+ paints: itemPaints,
684
+ lines,
685
+ };
585
686
  return lines;
586
687
  }
587
688
  }
@@ -605,8 +706,9 @@ function ungroup(patch: Patch): void {
605
706
  }
606
707
  }
607
708
 
709
+ /** 至少两项展示内容就保留分组:一个通知组件也可能包含多个 agent。 */
608
710
  function normalizeGroup(patch: Patch, group: ToolGroupComponent): void {
609
- if (group.children.length > 1) return;
711
+ if (groupItems(group.children).length > 1) return;
610
712
  const parent = (group as any)[PARENT_KEY];
611
713
  const index = parent?.children?.indexOf(group) ?? -1;
612
714
  const tools = group.releaseTools();
@@ -615,12 +717,8 @@ function normalizeGroup(patch: Patch, group: ToolGroupComponent): void {
615
717
  for (const tool of tools) delete tool[PARENT_KEY];
616
718
  return;
617
719
  }
618
- if (tools.length === 1) {
619
- tools[0][PARENT_KEY] = parent;
620
- parent.children.splice(index, 1, tools[0]);
621
- } else {
622
- parent.children.splice(index, 1);
623
- }
720
+ for (const tool of tools) tool[PARENT_KEY] = parent;
721
+ parent.children.splice(index, 1, ...tools);
624
722
  }
625
723
 
626
724
  function maybeGroup(patch: Patch, parent: any, component: any): void {
@@ -636,19 +734,25 @@ function maybeGroup(patch: Patch, parent: any, component: any): void {
636
734
  if (!Array.isArray(children)) return;
637
735
  const index = children.indexOf(component);
638
736
  const prior = previousSibling(children, index - 1);
639
- if (!prior) return;
640
- if (prior.child instanceof ToolGroupComponent && (prior.child as any).patch === patch) {
737
+ if (prior?.child instanceof ToolGroupComponent && (prior.child as any).patch === patch) {
641
738
  children.splice(index, 1);
642
739
  prior.child.addTool(component);
643
740
  return;
644
741
  }
645
- if (!isGroupable(prior.child) || prior.child[GENERATION_KEY] !== patch.generation) return;
742
+ const members = [component];
743
+ let firstIndex = index;
744
+ if (prior && isGroupable(prior.child) && prior.child[GENERATION_KEY] === patch.generation) {
745
+ members.unshift(prior.child);
746
+ firstIndex = prior.index;
747
+ }
748
+ // 按展示项而非消息数决定:单条批量通知也成组,原消息仍完整地留在组内。
749
+ if (groupItems(members).length < 2) return;
646
750
  const group = new ToolGroupComponent(patch);
647
- group.addTool(prior.child);
648
- group.addTool(component);
751
+ for (const member of members) group.addTool(member);
649
752
  (group as any)[PARENT_KEY] = parent;
650
- children[prior.index] = group;
651
- children.splice(index, 1);
753
+ // 两个相邻组件合并时移走后者;夹在中间的空行留在分组之后。
754
+ if (firstIndex !== index) children.splice(index, 1);
755
+ children[firstIndex] = group;
652
756
  }
653
757
 
654
758
  /** /reload 不会重新 addChild;扫描当前 mounted roots,把已有工具重新送入同一分组规则。 */