@herbertgao/pi-extensions 2026.11.13 → 2026.11.15

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 (198) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +7 -7
  3. package/THIRD_PARTY_NOTICES.md +1 -1
  4. package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +6 -0
  5. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +3 -2
  6. package/node_modules/@herbertgao/pi-cc-extensions/README.md +3 -2
  7. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +5 -0
  8. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +9 -0
  9. package/node_modules/@herbertgao/pi-cc-extensions/extensions/index.ts +32 -2
  10. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +26 -21
  11. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/table-copy.ts +753 -0
  12. package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/fullscreen-detect.ts +11 -0
  13. package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
  14. package/node_modules/@herbertgao/pi-inline-skill-commands/README.md +6 -2
  15. package/node_modules/@herbertgao/pi-inline-skill-commands/package.json +1 -1
  16. package/node_modules/@herbertgao/pi-inline-skill-commands/src/index.ts +41 -15
  17. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +16 -0
  18. package/node_modules/@herbertgao/pi-subagents/README.md +54 -22
  19. package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +114 -35
  20. package/node_modules/@herbertgao/pi-subagents/package.json +9 -4
  21. package/node_modules/@herbertgao/pi-subagents/skills/workflow-authoring/SKILL.md +147 -0
  22. package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +48 -32
  23. package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +34 -13
  24. package/node_modules/@herbertgao/pi-subagents/src/agent-types.ts +88 -0
  25. package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +16 -6
  26. package/node_modules/@herbertgao/pi-subagents/src/index.ts +114 -98
  27. package/node_modules/@herbertgao/pi-subagents/src/mention-clone.ts +6 -2
  28. package/node_modules/@herbertgao/pi-subagents/src/mention.ts +5 -7
  29. package/node_modules/@herbertgao/pi-subagents/src/nested-tools.ts +18 -2
  30. package/node_modules/@herbertgao/pi-subagents/src/prompts.ts +25 -3
  31. package/node_modules/@herbertgao/pi-subagents/src/settings.ts +26 -0
  32. package/node_modules/@herbertgao/pi-subagents/src/structured-output.ts +13 -5
  33. package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +55 -8
  34. package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-card-redraw.ts +86 -0
  35. package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-card.ts +5 -5
  36. package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-dialog.ts +478 -115
  37. package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-menu.ts +77 -6
  38. package/node_modules/@herbertgao/pi-subagents/src/workflow/agent-detail.ts +148 -0
  39. package/node_modules/@herbertgao/pi-subagents/src/workflow/host.ts +88 -14
  40. package/node_modules/@herbertgao/pi-subagents/src/workflow/journal.ts +8 -0
  41. package/node_modules/@herbertgao/pi-subagents/src/workflow/json-schema.ts +507 -57
  42. package/node_modules/@herbertgao/pi-subagents/src/workflow/progress.ts +41 -11
  43. package/node_modules/@herbertgao/pi-subagents/src/workflow/runtime.ts +106 -34
  44. package/node_modules/@herbertgao/pi-subagents/src/workflow/task.ts +43 -5
  45. package/node_modules/@herbertgao/pi-subagents/src/workflow/tool-description.ts +93 -153
  46. package/node_modules/@herbertgao/pi-subagents/src/workflow/worker-source.ts +283 -71
  47. package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +288 -177
  48. package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -1
  49. package/node_modules/@pi-plugins/fast-mode/package.json +7 -7
  50. package/node_modules/pi-commandcode-provider/CHANGELOG.md +20 -0
  51. package/node_modules/pi-commandcode-provider/README.md +1 -1
  52. package/node_modules/pi-commandcode-provider/index.ts +2 -1
  53. package/node_modules/pi-commandcode-provider/package.json +1 -1
  54. package/node_modules/pi-commandcode-provider/src/commandcode-catalog.ts +9 -2
  55. package/node_modules/pi-commandcode-provider/src/pricing.ts +5 -1
  56. package/node_modules/pi-commandcode-provider/src/responses-compat.ts +24 -1
  57. package/node_modules/pi-commandcode-provider/src/responses-stream.ts +99 -6
  58. package/node_modules/pi-lens/CHANGELOG-USER.md +6 -6
  59. package/node_modules/pi-lens/CHANGELOG.md +132 -0
  60. package/node_modules/pi-lens/README.md +2 -0
  61. package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +1 -0
  62. package/node_modules/pi-lens/dist/{chunk-LGH2HHZG.js → chunk-25CAONWT.js} +36 -25
  63. package/node_modules/pi-lens/dist/{chunk-ZQSSO7LO.js → chunk-2DWNYVUN.js} +3 -3
  64. package/node_modules/pi-lens/dist/{chunk-YCR6ZYTE.js → chunk-2RQREVGO.js} +1 -1
  65. package/node_modules/pi-lens/dist/{chunk-VWEBZ2JV.js → chunk-2XALJI2K.js} +40 -40
  66. package/node_modules/pi-lens/dist/{chunk-PQXUZYTQ.js → chunk-2YQ5LI7R.js} +4 -4
  67. package/node_modules/pi-lens/dist/{chunk-VSQT6IHZ.js → chunk-35UJUF27.js} +18 -4
  68. package/node_modules/pi-lens/dist/{chunk-OLWGYBYT.js → chunk-3IWMNN2S.js} +17 -17
  69. package/node_modules/pi-lens/dist/chunk-3UTDLQWO.js +88 -0
  70. package/node_modules/pi-lens/dist/chunk-3Z7Z3B7V.js +27 -0
  71. package/node_modules/pi-lens/dist/{chunk-UNP6Y4JV.js → chunk-4E4OCW3L.js} +16 -16
  72. package/node_modules/pi-lens/dist/{chunk-37IDWT6O.js → chunk-4GLSO2EM.js} +13 -11
  73. package/node_modules/pi-lens/dist/{chunk-QV3JPCMK.js → chunk-5HVDD7IA.js} +1 -1
  74. package/node_modules/pi-lens/dist/{chunk-ZRQMENT4.js → chunk-62PIU4TO.js} +1 -1
  75. package/node_modules/pi-lens/dist/{chunk-3TSMQZG6.js → chunk-6MDWNZ7E.js} +2 -2
  76. package/node_modules/pi-lens/dist/{chunk-WLD6BGON.js → chunk-6MWX2J5H.js} +4 -0
  77. package/node_modules/pi-lens/dist/{chunk-SCU62JLX.js → chunk-6MZLS6CK.js} +7 -7
  78. package/node_modules/pi-lens/dist/{chunk-B42AIWPJ.js → chunk-7BWPQZHE.js} +3 -3
  79. package/node_modules/pi-lens/dist/{chunk-I3NZVAMN.js → chunk-7JMEPY6P.js} +10 -10
  80. package/node_modules/pi-lens/dist/{chunk-7DPXUPRF.js → chunk-7ORBRDFY.js} +2 -2
  81. package/node_modules/pi-lens/dist/{chunk-6E5QLMWI.js → chunk-7WAQ3K26.js} +23 -23
  82. package/node_modules/pi-lens/dist/{chunk-2H5GHZKC.js → chunk-AB26NAHA.js} +7 -7
  83. package/node_modules/pi-lens/dist/{chunk-BBSDJTOV.js → chunk-AFSG6YUB.js} +13 -13
  84. package/node_modules/pi-lens/dist/{chunk-XDNWR7SG.js → chunk-ALTHJUZO.js} +2 -2
  85. package/node_modules/pi-lens/dist/{chunk-UN72ZAJ5.js → chunk-AOEVZXR6.js} +9 -9
  86. package/node_modules/pi-lens/dist/{chunk-HRLF35WL.js → chunk-ARTCVE6I.js} +9 -9
  87. package/node_modules/pi-lens/dist/{chunk-LQQNFCQJ.js → chunk-B2QO7GHY.js} +1 -1
  88. package/node_modules/pi-lens/dist/{chunk-I2FYOZNW.js → chunk-BJGWP4UX.js} +10 -10
  89. package/node_modules/pi-lens/dist/{chunk-G53LBDNU.js → chunk-BKJ6WZKP.js} +6 -6
  90. package/node_modules/pi-lens/dist/{chunk-P5MSLVUW.js → chunk-BQ72NQQM.js} +11 -11
  91. package/node_modules/pi-lens/dist/{chunk-K7O6AHSJ.js → chunk-BWGNVM33.js} +11 -11
  92. package/node_modules/pi-lens/dist/{chunk-ADYQRETD.js → chunk-BYIEU4E4.js} +2 -2
  93. package/node_modules/pi-lens/dist/{chunk-7ZVTFLCC.js → chunk-CDAJQBKJ.js} +11 -11
  94. package/node_modules/pi-lens/dist/{chunk-BKWFDWYM.js → chunk-D3UQWOCB.js} +16 -16
  95. package/node_modules/pi-lens/dist/{chunk-3PAS2ERX.js → chunk-DHFJS2I4.js} +8 -8
  96. package/node_modules/pi-lens/dist/{chunk-KNSOA43J.js → chunk-DKXIUGNA.js} +2 -2
  97. package/node_modules/pi-lens/dist/{chunk-LOEJFTF2.js → chunk-DLGJYQML.js} +2 -2
  98. package/node_modules/pi-lens/dist/{chunk-VGRGW4UL.js → chunk-DNJJVKJZ.js} +31 -31
  99. package/node_modules/pi-lens/dist/{chunk-5HBQL7DH.js → chunk-EBXCYEII.js} +3 -3
  100. package/node_modules/pi-lens/dist/chunk-EH6EHFW2.js +73 -0
  101. package/node_modules/pi-lens/dist/{chunk-W26QZ3OM.js → chunk-EKQDQPX6.js} +10 -10
  102. package/node_modules/pi-lens/dist/{chunk-TWEOJE3D.js → chunk-EXHSWN3P.js} +844 -377
  103. package/node_modules/pi-lens/dist/{chunk-4IZZEN63.js → chunk-F7BFIENK.js} +33 -33
  104. package/node_modules/pi-lens/dist/{chunk-ZI7YHV6I.js → chunk-FD4LJQ6Y.js} +5 -5
  105. package/node_modules/pi-lens/dist/{chunk-RIH3UBK4.js → chunk-GFCPPCNR.js} +11 -11
  106. package/node_modules/pi-lens/dist/{chunk-5JB4WENL.js → chunk-GIK6VUCY.js} +1 -1
  107. package/node_modules/pi-lens/dist/{chunk-PPQHMSPH.js → chunk-GNK2IHVG.js} +15 -15
  108. package/node_modules/pi-lens/dist/{chunk-CXQYK4YT.js → chunk-H6DNTQ4V.js} +2 -2
  109. package/node_modules/pi-lens/dist/{chunk-NGNBJIUO.js → chunk-HERQPNY6.js} +8 -8
  110. package/node_modules/pi-lens/dist/{chunk-INBK3HIT.js → chunk-HFIFEH46.js} +3 -3
  111. package/node_modules/pi-lens/dist/{chunk-J2ZB5MDS.js → chunk-HKRESBMC.js} +20 -20
  112. package/node_modules/pi-lens/dist/{chunk-AZG5UJYY.js → chunk-HMXWZUQW.js} +1 -1
  113. package/node_modules/pi-lens/dist/{chunk-XSC3BCN3.js → chunk-HOWHAKXO.js} +6 -6
  114. package/node_modules/pi-lens/dist/{chunk-7CLWC2UH.js → chunk-HUWW77QY.js} +1 -1
  115. package/node_modules/pi-lens/dist/{chunk-KZ732ZVW.js → chunk-IO6P3NBP.js} +1 -1
  116. package/node_modules/pi-lens/dist/{chunk-7WKVCZI4.js → chunk-J7VNGHLN.js} +2 -2
  117. package/node_modules/pi-lens/dist/{chunk-QE7BJQ6K.js → chunk-JGCBMCCS.js} +8 -8
  118. package/node_modules/pi-lens/dist/{chunk-PFJLYRO3.js → chunk-KIQSNH3F.js} +34 -34
  119. package/node_modules/pi-lens/dist/{chunk-JGUDT5KD.js → chunk-KSQJBGRO.js} +5 -5
  120. package/node_modules/pi-lens/dist/{chunk-RJ3APNIP.js → chunk-KXKM2DFP.js} +4 -4
  121. package/node_modules/pi-lens/dist/chunk-L3Q72QGQ.js +25 -0
  122. package/node_modules/pi-lens/dist/{chunk-6GLMMGCX.js → chunk-LDPY22FS.js} +2 -2
  123. package/node_modules/pi-lens/dist/{chunk-3PO4YYOX.js → chunk-M3QGXGY4.js} +3793 -3814
  124. package/node_modules/pi-lens/dist/{chunk-NNEQOC3U.js → chunk-MET776XM.js} +9 -7
  125. package/node_modules/pi-lens/dist/{chunk-X33QECRJ.js → chunk-MKQFSW2Q.js} +2 -2
  126. package/node_modules/pi-lens/dist/{chunk-7U36VQL6.js → chunk-MKW7ZUTT.js} +3 -3
  127. package/node_modules/pi-lens/dist/{chunk-PQF6YGYB.js → chunk-N2U644ZW.js} +4 -18
  128. package/node_modules/pi-lens/dist/{chunk-DI4AZZNY.js → chunk-NAACKIKT.js} +2 -2
  129. package/node_modules/pi-lens/dist/{chunk-O6LCSHHI.js → chunk-NHHS5T52.js} +1 -1
  130. package/node_modules/pi-lens/dist/{chunk-DCA2MXVQ.js → chunk-NIZKGBOU.js} +51 -27
  131. package/node_modules/pi-lens/dist/{chunk-PKWEBMCA.js → chunk-NNDZ7DOP.js} +194 -111
  132. package/node_modules/pi-lens/dist/{chunk-Q7J3JYJ2.js → chunk-NZ7NSKIW.js} +13 -13
  133. package/node_modules/pi-lens/dist/{chunk-S6MCMD27.js → chunk-OG3UCAHV.js} +3 -3
  134. package/node_modules/pi-lens/dist/{chunk-3QXFUP6T.js → chunk-OHTHVILU.js} +12 -12
  135. package/node_modules/pi-lens/dist/{chunk-NHA5K226.js → chunk-P7EV5ISR.js} +17 -2
  136. package/node_modules/pi-lens/dist/{chunk-L6BDRYUK.js → chunk-PVV27TOX.js} +5 -5
  137. package/node_modules/pi-lens/dist/{chunk-HIRBC72R.js → chunk-Q32RJDYC.js} +4 -4
  138. package/node_modules/pi-lens/dist/{chunk-QE5DJ7MX.js → chunk-Q4UQNTLB.js} +4 -4
  139. package/node_modules/pi-lens/dist/{chunk-SDYLT45T.js → chunk-QQGZY2BR.js} +2 -2
  140. package/node_modules/pi-lens/dist/{chunk-QMWKSYWB.js → chunk-S247BOH2.js} +4 -4
  141. package/node_modules/pi-lens/dist/{chunk-ARTYCUGF.js → chunk-S7KUDW73.js} +121 -18
  142. package/node_modules/pi-lens/dist/{chunk-6CFSDLHE.js → chunk-SJ2SR432.js} +17 -17
  143. package/node_modules/pi-lens/dist/{chunk-CQY2HEH7.js → chunk-SL4G67AP.js} +2 -2
  144. package/node_modules/pi-lens/dist/{chunk-LVLPA32Q.js → chunk-T2D2WWP6.js} +48 -11
  145. package/node_modules/pi-lens/dist/{chunk-HIJ4CHFF.js → chunk-T7KHGEJ5.js} +3 -3
  146. package/node_modules/pi-lens/dist/{chunk-74AMPWNC.js → chunk-TABDCX35.js} +2 -2
  147. package/node_modules/pi-lens/dist/chunk-TFSBHRL2.js +25 -0
  148. package/node_modules/pi-lens/dist/{chunk-KNJH6WJQ.js → chunk-TQKWR5AZ.js} +7 -7
  149. package/node_modules/pi-lens/dist/chunk-TWAQFMLW.js +110 -0
  150. package/node_modules/pi-lens/dist/{chunk-TKOFTLGB.js → chunk-UARVPNAU.js} +33 -33
  151. package/node_modules/pi-lens/dist/chunk-UWBD3JMH.js +56 -0
  152. package/node_modules/pi-lens/dist/{chunk-K4Z7MK6T.js → chunk-VEF3GFOL.js} +15 -15
  153. package/node_modules/pi-lens/dist/{chunk-4DAHGU3V.js → chunk-W2JPGW7Q.js} +27 -25
  154. package/node_modules/pi-lens/dist/{chunk-CZJGAOKL.js → chunk-W2YHHNY3.js} +7 -7
  155. package/node_modules/pi-lens/dist/{chunk-R4L7KZ7R.js → chunk-WA6U2URH.js} +9 -9
  156. package/node_modules/pi-lens/dist/{chunk-OZQQ3AIR.js → chunk-WAK2AXQQ.js} +9 -9
  157. package/node_modules/pi-lens/dist/{chunk-DFKOA74L.js → chunk-WH6O4IFD.js} +10 -10
  158. package/node_modules/pi-lens/dist/{chunk-27JQHK7Y.js → chunk-WJ7GY5WJ.js} +1 -1
  159. package/node_modules/pi-lens/dist/{chunk-KXGTLAUW.js → chunk-WWZLT6AM.js} +2 -2
  160. package/node_modules/pi-lens/dist/{chunk-O2MHF7QM.js → chunk-XRLZ75YY.js} +38 -38
  161. package/node_modules/pi-lens/dist/chunk-XWWFESYZ.js +27 -0
  162. package/node_modules/pi-lens/dist/chunk-XZSXSM4K.js +27 -0
  163. package/node_modules/pi-lens/dist/{chunk-C5PLBTNR.js → chunk-Y2LIOCA7.js} +1 -1
  164. package/node_modules/pi-lens/dist/{chunk-AXAR5ZW2.js → chunk-YIEHUKX2.js} +84 -169
  165. package/node_modules/pi-lens/dist/{chunk-B2OXE4AH.js → chunk-YOMLAKU6.js} +182 -180
  166. package/node_modules/pi-lens/dist/{chunk-MOAVEPC4.js → chunk-YV7XVYSJ.js} +11 -11
  167. package/node_modules/pi-lens/dist/{chunk-ZULZS2I6.js → chunk-ZVQUYCBU.js} +996 -365
  168. package/node_modules/pi-lens/dist/index.js +4911 -2376
  169. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +8 -8
  170. package/node_modules/pi-lens/dist/mcp/cli.js +40 -40
  171. package/node_modules/pi-lens/dist/mcp/server.js +321 -234
  172. package/node_modules/pi-lens/dist/mcp/worker.js +58 -58
  173. package/node_modules/pi-lens/dist/probes/installer.js +21 -21
  174. package/node_modules/pi-lens/docs/ci-bot-pr-checks.md +18 -9
  175. package/node_modules/pi-lens/docs/ci.md +7 -0
  176. package/node_modules/pi-lens/docs/defect-shapes.md +43 -28
  177. package/node_modules/pi-lens/docs/globalconfig.md +1 -0
  178. package/node_modules/pi-lens/docs/invariants/dispatch-runners.md +15 -0
  179. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +3 -3
  180. package/node_modules/pi-lens/docs/lsp-idle-eviction.md +3 -2
  181. package/node_modules/pi-lens/docs/module-report-read-symbol.md +6 -2
  182. package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +3 -2
  183. package/node_modules/pi-lens/docs/pi-lens-orchestration.md +2 -1
  184. package/node_modules/pi-lens/docs/pi-lens-subagent.md +2 -1
  185. package/node_modules/pi-lens/docs/servercapabilities.md +1 -1
  186. package/node_modules/pi-lens/docs/settings.md +1 -0
  187. package/node_modules/pi-lens/docs/usage.md +1 -0
  188. package/node_modules/pi-lens/package.json +1 -1
  189. package/package.json +9 -7
  190. package/node_modules/pi-lens/dist/chunk-2H7NFZ4Q.js +0 -25
  191. package/node_modules/pi-lens/dist/chunk-5YJXF2IS.js +0 -56
  192. package/node_modules/pi-lens/dist/chunk-GCSDF5IE.js +0 -27
  193. package/node_modules/pi-lens/dist/chunk-H5API74E.js +0 -67
  194. package/node_modules/pi-lens/dist/chunk-HBX55MWO.js +0 -27
  195. package/node_modules/pi-lens/dist/chunk-JOIKBUQN.js +0 -88
  196. package/node_modules/pi-lens/dist/chunk-M2YMBT5G.js +0 -73
  197. package/node_modules/pi-lens/dist/chunk-MJRGPEQ5.js +0 -25
  198. package/node_modules/pi-lens/dist/chunk-TFKN5EIR.js +0 -27
@@ -21,8 +21,7 @@
21
21
 
22
22
  /**
23
23
  * Suggestion trigger: `@` at a token boundary plus the partial handle typed so
24
- * far. Ported from Claude Code, including the CJK sentence-ending punctuation
25
- * it accepts as a boundary.
24
+ * far, including CJK sentence-ending punctuation as a boundary.
26
25
  */
27
26
  export const MENTION_TRIGGER = /(^|[\s。、?!])@([\w-]*)$/
28
27
 
@@ -30,7 +29,7 @@ export const MENTION_TRIGGER = /(^|[\s。、?!])@([\w-]*)$/
30
29
  const MENTION_SEND = /^@([\w-]+)\s+([\s\S]+)$/
31
30
 
32
31
  /**
33
- * Upper bound on a handle, matching Claude Code's `dSS`. Nothing here generates
32
+ * Upper bound on a handle. Nothing here generates
34
33
  * a name this long, but an agent type or a model-supplied name can be arbitrary
35
34
  * text, and an unbounded handle would wrap the suggestion popup.
36
35
  */
@@ -38,8 +37,7 @@ const MAX_HANDLE_LENGTH = 64
38
37
 
39
38
  /**
40
39
  * Handles that address something other than a subagent, and so can never be
41
- * allocated to one. Claude Code reserves exactly this name (`Vq = "main"`),
42
- * refusing it at spawn and routing it to the main conversation instead.
40
+ * allocated to one. This name is refused at spawn and routed to the main conversation instead.
43
41
  */
44
42
  const RESERVED_HANDLES: ReadonlySet<string> = new Set(["main"])
45
43
 
@@ -123,8 +121,8 @@ export function describeMention(message: string): string {
123
121
  * allowed-tools narrowing, and the Task tool is not even named. The model reads
124
122
  * this and calls the tool itself.
125
123
  *
126
- * Ported verbatim from the 2.1.233 bundle's attachment renderer, trailing space
127
- * before the closing newline included, so the wording the model was trained
124
+ * Fixed wording, trailing space before the closing newline
125
+ * included, so the wording the model was trained
128
126
  * against is the wording it gets. The one substitution is ours: pi's equivalent
129
127
  * of Task is the `Agent` tool, and the agent listing that teaches valid
130
128
  * `subagent_type` values is the tool spec rather than a separate attachment.
@@ -10,8 +10,10 @@ import { Type } from "typebox"
10
10
  import { abortable } from "./abortable.js"
11
11
  import {
12
12
  buildAgentRegistry,
13
+ formatAgentTypeList,
13
14
  getAgentConfigIn,
14
15
  getAvailableTypesIn,
16
+ getToolDescriptionMode,
15
17
  resolveEnabledTypeIn,
16
18
  resolveTypeIn,
17
19
  } from "./agent-types.js"
@@ -196,12 +198,26 @@ export function createNestedSubagentTools(
196
198
  )
197
199
  }
198
200
 
201
+ const registry = loadRegistry()
202
+ const available = availableIn(registry)
203
+ // Same list as the main session's Agent tool (#457); a "custom" description
204
+ // is written for the main session, so it counts as full here.
205
+ const typeList =
206
+ available.length > 0
207
+ ? formatAgentTypeList(
208
+ available,
209
+ (name) => getAgentConfigIn(registry, name),
210
+ getToolDescriptionMode() === "compact",
211
+ )
212
+ : "none"
213
+
199
214
  const agentTool = defineTool({
200
215
  name: NESTED_TOOL_NAMES[0],
201
216
  label: "Agent",
202
217
  description:
203
218
  "Launch a child-safe nested subagent for bounded delegated work. " +
204
- "Only use agent types allowed by this parent agent; nesting is depth-limited. " +
219
+ "Only use agent types allowed by this parent agent; nesting is depth-limited.\n\n" +
220
+ `Available agent types and the tools they have access to:\n${typeList}\n\n` +
205
221
  // Overrides the main session's inherited Agent guideline ("you will be
206
222
  // notified on completion"), which does not hold for nested children.
207
223
  "A background nested agent does NOT notify you when it finishes: collect each one with get_subagent_result (wait: true) before you end your turn, or it is stopped and its work is lost.",
@@ -213,7 +229,7 @@ export function createNestedSubagentTools(
213
229
  description: "Short 3-5 word task description.",
214
230
  }),
215
231
  subagent_type: Type.String({
216
- description: `Allowed nested agent type. Available: ${availableIn(loadRegistry()).join(", ") || "none"}.`,
232
+ description: `Allowed nested agent type. Available: ${available.join(", ") || "none"}.`,
217
233
  }),
218
234
  model: Type.Optional(
219
235
  Type.String({ description: "Optional provider/model override." }),
@@ -189,9 +189,7 @@ ${envBlock}`
189
189
  * @param cwd The cwd the parent's prompt was rendered with.
190
190
  */
191
191
  export function inheritableParentPrompt(rendered: string, cwd: string): string {
192
- const cwdAt = rendered.lastIndexOf(
193
- `\n\n<cwd>\n${cwd.replace(/\\/g, "/")}\n</cwd>`,
194
- )
192
+ const cwdAt = rendered.lastIndexOf(cwdSection(cwd))
195
193
  if (cwdAt < 0) return rendered
196
194
  const head = rendered.slice(0, cwdAt)
197
195
  if (!head.endsWith("\n</skills>")) return head
@@ -199,6 +197,30 @@ export function inheritableParentPrompt(rendered: string, cwd: string): string {
199
197
  return skillsAt < 0 ? head : head.slice(0, skillsAt)
200
198
  }
201
199
 
200
+ /**
201
+ * The parent's rendered system prompt without its `cwd` section, for a session that
202
+ * renders its own `cwd` after the prompt it is given and adds nothing else.
203
+ *
204
+ * Everything else is kept, including sections after `cwd` (extension sections present
205
+ * while the parent's turn runs). A prompt without the section (for example, a forced
206
+ * prompt) is returned unchanged.
207
+ *
208
+ * @param rendered The parent's `ctx.getSystemPrompt()`.
209
+ * @param cwd The cwd the parent's prompt was rendered with.
210
+ */
211
+ export function withoutCwdSection(rendered: string, cwd: string): string {
212
+ const section = cwdSection(cwd)
213
+ const at = rendered.lastIndexOf(section)
214
+ return at < 0
215
+ ? rendered
216
+ : rendered.slice(0, at) + rendered.slice(at + section.length)
217
+ }
218
+
219
+ /** The `cwd` section as pi renders it after the preceding section. */
220
+ function cwdSection(cwd: string): string {
221
+ return `\n\n<cwd>\n${cwd.replace(/\\/g, "/")}\n</cwd>`
222
+ }
223
+
202
224
  /** Fallback base prompt when parent system prompt is unavailable in append mode. */
203
225
  const genericBase = `# Role
204
226
  You are a general-purpose coding agent for complex, multi-step tasks.
@@ -137,6 +137,18 @@ export interface SubagentsSettings {
137
137
  * next pi session.
138
138
  */
139
139
  toolDescriptionMode?: ToolDescriptionMode
140
+ /**
141
+ * Where the SubagentWorkflow script reference reaches the model. "inline"
142
+ * (default) puts it in the tool description, where the model cannot skip it.
143
+ * "skill" saves about 4k tokens every session: one line points at the
144
+ * bundled `workflow-authoring` skill file by path instead, and the model has
145
+ * to choose to read it before writing a script — a model that does not
146
+ * writes the script without the reference. "deferred" keeps the tool out of
147
+ * the tool spec until pi's `tool_search` loads it, then carries the inline
148
+ * reference; it needs `tool_search` active. Read once at tool registration;
149
+ * applies on the next pi session.
150
+ */
151
+ workflowToolExposure?: WorkflowToolExposureMode
140
152
  /**
141
153
  * Whether the Claude Code-style FleetView (the navigable main+subagents list
142
154
  * rendered below the editor) is shown. Defaults to `true`. Pure-UI: when off,
@@ -360,6 +372,7 @@ export interface SubagentsSettings {
360
372
  }
361
373
 
362
374
  export type ToolDescriptionMode = "full" | "compact" | "custom"
375
+ export type WorkflowToolExposureMode = "skill" | "inline" | "deferred"
363
376
 
364
377
  /** Setter hooks used by applySettings to wire persisted values into in-memory state. */
365
378
  export interface SettingsAppliers {
@@ -375,6 +388,7 @@ export interface SettingsAppliers {
375
388
  setStrictAgentFiles: (b: boolean) => void
376
389
  setDisableDefaultAgents: (b: boolean) => void
377
390
  setToolDescriptionMode: (mode: ToolDescriptionMode) => void
391
+ setWorkflowToolExposure: (mode: WorkflowToolExposureMode) => void
378
392
  setFleetView: (b: boolean) => void
379
393
  setAgentMentions: (mode: AgentMentionMode) => void
380
394
  setRememberAgents: (b: boolean) => void
@@ -402,6 +416,8 @@ const VALID_JOIN_MODES: ReadonlySet<string> = new Set<JoinMode>([
402
416
  ])
403
417
  const VALID_TOOL_DESCRIPTION_MODES: ReadonlySet<string> =
404
418
  new Set<ToolDescriptionMode>(["full", "compact", "custom"])
419
+ const VALID_WORKFLOW_TOOL_EXPOSURE_MODES: ReadonlySet<string> =
420
+ new Set<WorkflowToolExposureMode>(["skill", "inline", "deferred"])
405
421
  const VALID_WIDGET_MODES: ReadonlySet<string> = new Set<WidgetMode>([
406
422
  "all",
407
423
  "background",
@@ -478,6 +494,7 @@ export const SETTING_DEFAULTS: {
478
494
  strictAgentFiles: false,
479
495
  disableDefaultAgents: false,
480
496
  toolDescriptionMode: "full",
497
+ workflowToolExposure: "inline",
481
498
  fleetView: true,
482
499
  agentMentions: "model",
483
500
  rememberAgents: true,
@@ -557,6 +574,13 @@ function sanitize(raw: unknown): SubagentsSettings {
557
574
  ) {
558
575
  out.toolDescriptionMode = r.toolDescriptionMode as ToolDescriptionMode
559
576
  }
577
+ if (
578
+ typeof r.workflowToolExposure === "string" &&
579
+ VALID_WORKFLOW_TOOL_EXPOSURE_MODES.has(r.workflowToolExposure)
580
+ ) {
581
+ out.workflowToolExposure =
582
+ r.workflowToolExposure as WorkflowToolExposureMode
583
+ }
560
584
  if (typeof r.fleetView === "boolean") {
561
585
  out.fleetView = r.fleetView
562
586
  }
@@ -792,6 +816,8 @@ export function applySettings(
792
816
  appliers.setDisableDefaultAgents(s.disableDefaultAgents)
793
817
  if (s.toolDescriptionMode)
794
818
  appliers.setToolDescriptionMode(s.toolDescriptionMode)
819
+ if (s.workflowToolExposure)
820
+ appliers.setWorkflowToolExposure(s.workflowToolExposure)
795
821
  if (typeof s.fleetView === "boolean") appliers.setFleetView(s.fleetView)
796
822
  if (s.agentMentions) appliers.setAgentMentions(s.agentMentions)
797
823
  if (typeof s.rememberAgents === "boolean")
@@ -67,13 +67,16 @@ export function createStructuredOutputTool(
67
67
  return defineTool({
68
68
  name: STRUCTURED_OUTPUT_TOOL_NAME,
69
69
  label: "Structured Output",
70
+ // The guidelines below carry what a forced call would make unnecessary:
71
+ // prose outside the call is discarded, and a rejected call should be made
72
+ // again.
70
73
  description:
71
- "Report your final answer. Call this exactly once, with the complete result, and put everything the " +
72
- "caller needs inside the arguments — text written outside this call is discarded. If a call is " +
73
- "rejected for not matching the schema, fix the reported fields and call it again.",
74
+ "Use this tool to return your final response in the requested structured format. You MUST call this " +
75
+ "tool exactly once at the end of your response to provide the structured output.",
74
76
  promptSnippet: "Report your final answer as structured data",
75
77
  promptGuidelines: [
76
78
  "Your final answer MUST be reported by calling StructuredOutput. Prose outside that call is discarded.",
79
+ "If a StructuredOutput call is rejected for not matching the schema, fix the reported fields and call it again.",
77
80
  ],
78
81
  // The caller's schema *is* the tool's input schema, verbatim — that is what
79
82
  // makes the provider fill the fields. pi types this as TypeBox's `TSchema`,
@@ -105,7 +108,7 @@ export function createStructuredOutputTool(
105
108
  content: [
106
109
  {
107
110
  type: "text",
108
- text: `StructuredOutput did not match the required schema:\n${verdict}\nCall it again with a corrected value.`,
111
+ text: `Output does not match required schema: ${verdict}`,
109
112
  },
110
113
  ],
111
114
  isError: true,
@@ -115,7 +118,12 @@ export function createStructuredOutputTool(
115
118
  // Last valid call wins: a model that calls twice meant the second one.
116
119
  capture.json = JSON.stringify(params)
117
120
  capture.lastError = undefined
118
- return { content: [{ type: "text", text: "Recorded." }], details: {} }
121
+ return {
122
+ content: [
123
+ { type: "text", text: "Structured output provided successfully" },
124
+ ],
125
+ details: {},
126
+ }
119
127
  },
120
128
  }) as ToolDefinition
121
129
  }
@@ -105,6 +105,8 @@ export interface FleetWorkflow {
105
105
  status: "running" | "completed" | "failed" | "killed" | "paused"
106
106
  doneCount: number
107
107
  totalCount: number
108
+ /** `Reviewing (2/3)` — the run's active phases, or "" for none. */
109
+ phase: string
108
110
  startedAt: number
109
111
  /** Set once the run settles, which is what freezes its clock. */
110
112
  completedAt?: number
@@ -141,6 +143,25 @@ export function formatFleetTokens(count: number): string {
141
143
  return `↓ ${compact} tokens`
142
144
  }
143
145
 
146
+ /** Cells in a workflow row's progress bar — Claude Code's width. */
147
+ export const PROGRESS_BAR_CELLS = 20
148
+
149
+ /**
150
+ * `▰▰▰▱▱…` — a run's done share as filled cells, returned as two runs so the
151
+ * caller can colour them. A run with no agents yet is all empty.
152
+ */
153
+ export function formatProgressBar(
154
+ done: number,
155
+ total: number,
156
+ cells = PROGRESS_BAR_CELLS,
157
+ ): { filled: string; empty: string } {
158
+ const n =
159
+ total > 0
160
+ ? Math.min(cells, Math.max(0, Math.round((cells * done) / total)))
161
+ : 0
162
+ return { filled: "▰".repeat(n), empty: "▱".repeat(cells - n) }
163
+ }
164
+
144
165
  /**
145
166
  * Place `right` flush to `width`, truncating `left` first so the stats survive.
146
167
  * The final clamp guarantees the line never exceeds `width` (which would wrap and
@@ -157,6 +178,7 @@ function rightAlign(left: string, right: string, width: number): string {
157
178
  export class FleetList {
158
179
  private ui: FleetUICtx | undefined
159
180
  private tui: any | undefined
181
+ private onTuiMode?: (mode: string) => void
160
182
  private inputUnsub: (() => void) | undefined
161
183
  private widgetRegistered = false
162
184
  private timer: ReturnType<typeof setInterval> | undefined
@@ -242,6 +264,15 @@ export class FleetList {
242
264
  this.update()
243
265
  }
244
266
 
267
+ /**
268
+ * Told pi's renderer mode (`"fullscreen"` | `"regular"`) each time the list is
269
+ * drawn into a TUI. pi hands over a new TUI on a mode switch, so this is how
270
+ * the extension learns of one.
271
+ */
272
+ setTuiModeObserver(observer: (mode: string) => void): void {
273
+ this.onTuiMode = observer
274
+ }
275
+
245
276
  /** Capture the UI context and (re)register the global input handler. */
246
277
  setUICtx(ui: FleetUICtx): void {
247
278
  if (ui === this.ui) return
@@ -322,6 +353,7 @@ export class FleetList {
322
353
  FLEET_KEY,
323
354
  (tui, theme) => {
324
355
  this.tui = tui
356
+ if (typeof tui?.mode === "string") this.onTuiMode?.(tui.mode)
325
357
  return {
326
358
  render: (w: number) => this.renderBar(w, theme),
327
359
  invalidate: () => {
@@ -765,9 +797,13 @@ export class FleetList {
765
797
  }
766
798
 
767
799
  /**
768
- * A run's row. Shaped like an agent's — gutter, dot, kind, name, stats flush
769
- * right — so the two read as one list, with the agent count where an agent
770
- * has its description and the same elapsed/token tail.
800
+ * A run's row: gutter, dot, a `workflow` label where an agent has its type,
801
+ * the name, then a progress bar, `done/total agents` and the active phases
802
+ * where an agent has its description, and the same elapsed/token tail flush right. Claude Code
803
+ * has no label and runs its stats inline after the bar; the label says what
804
+ * the row is, and the flush-right tail lines up with the agent rows.
805
+ * `rightAlign` cuts the left side first, so a narrow terminal loses the
806
+ * count and bar before the elapsed/token tail.
771
807
  */
772
808
  private renderWorkflowRow(
773
809
  rosterIndex: number,
@@ -777,17 +813,28 @@ export class FleetList {
777
813
  theme: Theme,
778
814
  ): string {
779
815
  const selected = rosterIndex === cursor
780
- const kind = theme.fg(selected ? "text" : "muted", "workflow")
781
816
  const name = selected ? theme.fg("text", workflow.name) : workflow.name
782
817
  const dot = this.dot(workflow.id === this.viewingWorkflowId, theme)
783
- const left = `${this.gutter(rosterIndex, cursor, theme)}${dot} ${kind} ${name}`
818
+ const { filled, empty } = formatProgressBar(
819
+ workflow.doneCount,
820
+ workflow.totalCount,
821
+ )
822
+ const bar =
823
+ theme.fg(workflow.status === "completed" ? "success" : "accent", filled) +
824
+ theme.fg("dim", empty)
825
+ const muted = (text: string) => theme.fg(selected ? "text" : "dim", text)
826
+ const kind = theme.fg(selected ? "text" : "muted", "workflow")
827
+ const count = muted(
828
+ `${workflow.doneCount}/${workflow.totalCount} agents${workflow.phase ? ` · ${workflow.phase}` : ""}`,
829
+ )
830
+ const left = `${this.gutter(rosterIndex, cursor, theme)}${dot} ${kind} ${name} ${bar} ${count}`
784
831
  // Frozen once the run settles, exactly as an agent's clock is.
785
832
  const elapsed = (workflow.completedAt ?? Date.now()) - workflow.startedAt
786
- const agents = `${workflow.doneCount}/${workflow.totalCount} agent${workflow.totalCount === 1 ? "" : "s"}`
787
- const stats = `${agents} · ${formatFleetElapsed(elapsed)} · ${formatFleetTokens(workflow.tokens)}`
788
833
  return rightAlign(
789
834
  left,
790
- selected ? theme.fg("text", stats) : theme.fg("dim", stats),
835
+ muted(
836
+ `${formatFleetElapsed(elapsed)} · ${formatFleetTokens(workflow.tokens)}`,
837
+ ),
791
838
  width,
792
839
  )
793
840
  }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * workflow-card-redraw.ts — when a background run's inline card redraws.
3
+ *
4
+ * pi re-runs a tool's `renderResult` only when told to, through
5
+ * `renderContext.invalidate`. A `SubagentWorkflow` call settles at launch, so
6
+ * without this the card keeps its first frame (#284).
7
+ *
8
+ * The redraw cost depends on pi's renderer. In fullscreen only the visible
9
+ * rows are diffed, so redrawing a card that has scrolled off screen is free. In
10
+ * regular mode a change above the viewport clears the screen and scrollback
11
+ * and replays the session (#317). So a card follows its run live only when
12
+ * `isLive()` says fullscreen, and redraws once when the run ends either way.
13
+ */
14
+
15
+ import { WORKFLOW_TICK_MS } from "./workflow-card.js"
16
+
17
+ interface Card {
18
+ invalidate: () => void
19
+ lastAt: number
20
+ timer?: ReturnType<typeof setTimeout>
21
+ }
22
+
23
+ export class WorkflowCardRedraws {
24
+ /** Live runs' cards, by run id. */
25
+ private cards = new Map<string, Card>()
26
+
27
+ constructor(
28
+ /** Read at every decision, because pi can switch renderers mid-run. */
29
+ private isLive: () => boolean,
30
+ private tickMs = WORKFLOW_TICK_MS,
31
+ ) {}
32
+
33
+ /**
34
+ * The handle of the component currently drawing this run's card. The latest
35
+ * one wins: pi rebuilds the chat on some navigations, which replaces the
36
+ * component.
37
+ */
38
+ track(id: string, invalidate: () => void): void {
39
+ const card = this.cards.get(id)
40
+ if (card) card.invalidate = invalidate
41
+ else this.cards.set(id, { invalidate, lastAt: 0 })
42
+ }
43
+
44
+ /** The run changed: redraw now, or once when the current window closes. */
45
+ request(id: string): void {
46
+ const card = this.cards.get(id)
47
+ if (!card || card.timer || !this.isLive()) return
48
+ const fire = () => {
49
+ card.timer = undefined
50
+ // The timer was armed in fullscreen. Leaving that mode must not redeem
51
+ // it: a regular-mode redraw above the viewport clears scrollback.
52
+ if (!this.isLive()) return
53
+ card.lastAt = Date.now()
54
+ card.invalidate()
55
+ }
56
+ const wait = card.lastAt + this.tickMs - Date.now()
57
+ if (wait <= 0) {
58
+ fire()
59
+ } else {
60
+ card.timer = setTimeout(fire, wait)
61
+ card.timer.unref?.()
62
+ }
63
+ }
64
+
65
+ /** The run ended: one last redraw, in either renderer, and release the card. */
66
+ flush(id: string): void {
67
+ const card = this.cards.get(id)
68
+ if (!card) return
69
+ clearTimeout(card.timer)
70
+ this.cards.delete(id)
71
+ card.invalidate()
72
+ }
73
+
74
+ /**
75
+ * The renderer changed: every live card redraws once. A card drawn in one
76
+ * mode is wrong for the other: the full tree can't follow the run in regular
77
+ * mode, and the launch line hides it in fullscreen.
78
+ */
79
+ redrawAll(): void {
80
+ for (const card of this.cards.values()) {
81
+ clearTimeout(card.timer)
82
+ card.timer = undefined
83
+ card.invalidate()
84
+ }
85
+ }
86
+ }
@@ -131,10 +131,10 @@ export const ASCII_GLYPHS: WorkflowGlyphs = {
131
131
  * ------------------------------------------------------------------------- */
132
132
 
133
133
  /**
134
- * pi theme keys. Claude Code's palette maps as success→success, error→error,
134
+ * pi theme keys. The palette maps as success→success, error→error,
135
135
  * subtle→dim, permission→warning for a blocked row and accent for selection;
136
136
  * an undefined colour means "leave it at the terminal default", which is what
137
- * the recovered inline mapping asks for on a running row.
137
+ * a running row shows.
138
138
  *
139
139
  * `accent` is unused by the card and exists for the workflows dialog, which
140
140
  * shares these segment types.
@@ -254,7 +254,7 @@ export function formatThinking(entry: WorkflowAgentEntry): string | undefined {
254
254
  export const REPLAYED_ANNOTATION = "from resume journal"
255
255
 
256
256
  /**
257
- * The `·`-separated tail of an agent row, in the recovered order: agentType,
257
+ * The `·`-separated tail of an agent row, in this order: agentType,
258
258
  * model, tokens, toolCalls, durationMs. Absent values drop out entirely rather
259
259
  * than rendering a placeholder.
260
260
  */
@@ -273,7 +273,7 @@ export function agentStatSegments(entry: WorkflowAgentEntry): string[] {
273
273
  }
274
274
 
275
275
  /**
276
- * The recovered inline mapping — keyed on the raw entry state. `skipped` and
276
+ * The inline view's glyphs and colours — keyed on the raw entry state. `skipped` and
277
277
  * `blocked` are not distinguished here; that is the dialog's job.
278
278
  */
279
279
  function rowGlyph(
@@ -423,7 +423,7 @@ export function layoutWorkflowCard(
423
423
  ]
424
424
 
425
425
  // Prepended rather than folded into `agentStatSegments`, which is the
426
- // ported stat tail in its recovered order. A replayed agent otherwise
426
+ // stat tail in its fixed order. A replayed agent otherwise
427
427
  // renders as a tick with no tokens and no duration — indistinguishable
428
428
  // from one that somehow did the work for free.
429
429
  const statParts = entry.cached