pi-agent-ide 0.8.0 → 0.8.1

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 (377) hide show
  1. package/CHANGELOG.md +26 -40
  2. package/README.md +12 -7
  3. package/dist/{chunk-MOJ5RR35.js → chunk-246NTPOS.js} +1 -1
  4. package/dist/{chunk-NULNW6GK.js → chunk-2ITKAXHO.js} +1 -1
  5. package/dist/{chunk-SBNR4WZF.js → chunk-3WO2NOEQ.js} +1 -1
  6. package/dist/{chunk-N7LMRL64.js → chunk-47SPPIXK.js} +1 -1
  7. package/dist/{chunk-EY65TFHJ.js → chunk-4HWKBCBH.js} +1 -1
  8. package/dist/{chunk-JMVDFOTQ.js → chunk-57F5GTHO.js} +1 -1
  9. package/dist/{chunk-KL776TGR.js → chunk-7LOVUWNI.js} +1 -1
  10. package/dist/{chunk-7JV4VN73.js → chunk-A64JRDZK.js} +1 -1
  11. package/dist/{chunk-Z3PGADVA.js → chunk-AIT3YWR5.js} +1 -1
  12. package/dist/{chunk-E4HPRLRB.js → chunk-AKNHSDGV.js} +1 -1
  13. package/dist/{chunk-4XPUN4QN.js → chunk-AUL5FGGK.js} +1 -1
  14. package/dist/chunk-BB4A5UI3.js +5 -0
  15. package/dist/{chunk-CTJV77FR.js → chunk-BQAKA3FU.js} +1 -1
  16. package/dist/{chunk-PNP2KNGP.js → chunk-BR7GRH4A.js} +1 -1
  17. package/dist/{chunk-4OYVLXWD.js → chunk-D4IA2MTA.js} +1 -1
  18. package/dist/{chunk-R5XJSEOE.js → chunk-DXONCYWF.js} +3 -3
  19. package/dist/{chunk-TWWND6NI.js → chunk-E2PHA4SQ.js} +1 -1
  20. package/dist/{chunk-MZXX353D.js → chunk-EMRJP6EM.js} +1 -1
  21. package/dist/{chunk-7HDK3NRQ.js → chunk-GEMDU6XW.js} +1 -1
  22. package/dist/chunk-GNACBJM3.js +1 -0
  23. package/dist/{chunk-3G54ZL2L.js → chunk-HCK7OIQ3.js} +1 -1
  24. package/dist/chunk-HFJGCYFO.js +11 -0
  25. package/dist/{chunk-CSXHCSTH.js → chunk-ID4RJIVZ.js} +1 -1
  26. package/dist/{chunk-SBLKPTL3.js → chunk-JKMXND6V.js} +1 -1
  27. package/dist/{chunk-WE42GBGU.js → chunk-LAJQSHEI.js} +1 -1
  28. package/dist/{chunk-HCN5W76B.js → chunk-LLRUJD62.js} +1 -1
  29. package/dist/{chunk-2K65BSXS.js → chunk-M4TVRCMZ.js} +1 -1
  30. package/dist/{chunk-IUSLSROY.js → chunk-N56WAVYA.js} +1 -1
  31. package/dist/chunk-OI3HBIPK.js +2 -0
  32. package/dist/{chunk-GW6NZQTQ.js → chunk-PRLIHLCS.js} +1 -1
  33. package/dist/{chunk-7TJ6DWW3.js → chunk-Q5X6OXNS.js} +1 -1
  34. package/dist/{chunk-75SWXD2Z.js → chunk-SWA5B5B2.js} +1 -1
  35. package/dist/chunk-T7MWQQIF.js +3 -0
  36. package/dist/{chunk-ICDI27GZ.js → chunk-TGC2ZACO.js} +1 -1
  37. package/dist/{chunk-7NS3QUIE.js → chunk-TXG2H7YQ.js} +1 -1
  38. package/dist/{chunk-RAZP42IQ.js → chunk-VAXLSPPU.js} +1 -1
  39. package/dist/chunk-VMGZMXEM.js +10 -0
  40. package/dist/{chunk-CPZJPGLG.js → chunk-VNTY7BKC.js} +1 -1
  41. package/dist/chunk-W3YFF6OO.js +1 -0
  42. package/dist/{chunk-OLI3JPHJ.js → chunk-W7M3V7FR.js} +1 -1
  43. package/dist/{chunk-UUJJRXHG.js → chunk-WMHSVEIT.js} +1 -1
  44. package/dist/{chunk-OJX3RJ5A.js → chunk-WPBQ45ZL.js} +1 -1
  45. package/dist/{chunk-XZDOVPRC.js → chunk-WXGTU2M6.js} +1 -1
  46. package/dist/{chunk-3ZGDMTMD.js → chunk-XSIKDVAR.js} +1 -1
  47. package/dist/{chunk-QP2QSQ4U.js → chunk-YHREORHH.js} +1 -1
  48. package/dist/chunk-YTYLS2UM.js +1 -0
  49. package/dist/chunk-Z2QGNTGQ.js +1 -0
  50. package/dist/{chunk-UBH6X3D3.js → chunk-ZV5ETNLQ.js} +1 -1
  51. package/dist/entry-11.js +1 -1
  52. package/dist/entry-13.js +1 -1
  53. package/dist/entry-14.js +1 -1
  54. package/dist/entry-15.js +1 -1
  55. package/dist/entry-16.js +1 -1
  56. package/dist/entry-17.js +1 -1
  57. package/dist/entry-18.js +1 -0
  58. package/dist/entry-20.js +1 -1
  59. package/dist/entry-21.js +1 -1
  60. package/dist/entry-22.js +1 -1
  61. package/dist/entry-23.js +1 -1
  62. package/dist/entry-24.js +1 -1
  63. package/dist/entry-25.js +1 -1
  64. package/dist/entry-26.js +1 -2
  65. package/dist/entry-27.js +2 -1
  66. package/dist/entry-28.js +1 -4
  67. package/dist/entry-29.js +4 -1
  68. package/dist/entry-30.js +1 -1
  69. package/dist/entry-31.js +1 -1
  70. package/dist/entry-32.js +1 -18
  71. package/dist/entry-33.js +18 -1
  72. package/dist/entry-34.js +1 -1
  73. package/dist/entry-35.js +1 -1
  74. package/dist/entry-36.js +1 -1
  75. package/dist/entry-37.js +1 -1
  76. package/dist/entry-38.js +1 -1
  77. package/dist/entry-39.js +1 -1
  78. package/dist/entry-40.js +1 -1
  79. package/dist/entry-41.js +1 -1
  80. package/dist/entry-42.js +1 -1
  81. package/dist/entry-43.js +1 -1
  82. package/dist/entry-44.js +1 -1
  83. package/dist/entry-45.js +1 -1
  84. package/dist/entry-46.js +1 -25
  85. package/dist/entry-47.js +25 -1
  86. package/dist/entry-48.js +1 -1
  87. package/dist/entry-49.js +1 -1
  88. package/dist/entry-50.js +1 -1
  89. package/dist/entry-51.js +1 -3
  90. package/dist/entry-52.js +3 -13
  91. package/dist/entry-53.js +13 -1
  92. package/dist/entry-54.js +1 -1
  93. package/dist/entry-55.js +1 -1
  94. package/dist/entry-56.js +1 -1
  95. package/dist/entry-57.js +1 -1
  96. package/dist/entry-58.js +1 -1
  97. package/dist/entry-59.js +1 -1
  98. package/dist/entry-6.js +1 -1
  99. package/dist/entry-60.js +1 -1
  100. package/dist/entry-61.js +1 -1
  101. package/dist/entry-62.js +1 -0
  102. package/dist/entry-63.js +0 -1
  103. package/dist/entry-64.js +1 -0
  104. package/dist/entry-65.js +0 -1
  105. package/dist/entry-66.js +1 -1
  106. package/dist/entry-67.js +1 -1
  107. package/dist/entry-68.js +1 -1
  108. package/dist/entry-69.js +1 -1
  109. package/dist/entry-7.js +1 -1
  110. package/dist/entry-70.js +1 -1
  111. package/dist/entry-71.js +1 -1
  112. package/dist/entry-72.js +1 -0
  113. package/dist/entry-73.js +0 -1
  114. package/dist/entry-74.js +1 -0
  115. package/dist/entry-75.js +0 -1
  116. package/dist/entry-76.js +1 -1
  117. package/dist/entry-77.js +1 -1
  118. package/dist/entry-78.js +1 -80
  119. package/dist/entry-79.js +76 -17
  120. package/dist/entry-80.js +22 -2
  121. package/dist/entry-81.js +2 -1
  122. package/dist/entry-82.js +1 -1
  123. package/dist/entry-83.js +1 -1
  124. package/dist/entry-84.js +1 -3
  125. package/dist/entry-85.js +3 -1
  126. package/dist/entry-86.js +1 -1
  127. package/dist/entry-87.js +1 -1
  128. package/dist/entry-88.js +1 -0
  129. package/dist/pi-agent-ide.js +53 -24
  130. package/docs/agent-guides/search-code.md +3 -1
  131. package/docs/agent-guides/ssh.md +1 -1
  132. package/docs/configuration.md +18 -6
  133. package/docs/development.md +1 -13
  134. package/docs/extensions.md +1 -1
  135. package/docs/releases.md +1 -1
  136. package/docs/settings-help.md +39 -0
  137. package/docs/tools.md +1 -0
  138. package/docs/user-hooks.md +3 -1
  139. package/node_modules/pi-agent-doctor/package.json +7 -10
  140. package/node_modules/pi-agent-documentation/package.json +2 -2
  141. package/node_modules/pi-agent-documentation/runtime/entry-26.js +1 -0
  142. package/node_modules/pi-agent-filesystem/package.json +8 -8
  143. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  144. package/node_modules/pi-agent-filesystem-jq/package.json +6 -7
  145. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  146. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  147. package/node_modules/pi-agent-filesystem-text/runtime/entry-31.js +2 -0
  148. package/node_modules/pi-agent-ide-ast/package.json +15 -41
  149. package/node_modules/pi-agent-ide-ast/runtime/entry-32.js +0 -1
  150. package/node_modules/pi-agent-ide-ast/runtime/entry-33.js +2 -0
  151. package/node_modules/pi-agent-ide-changes/package.json +10 -11
  152. package/node_modules/pi-agent-ide-changes/runtime/entry-34.js +0 -1
  153. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  154. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  155. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  156. package/node_modules/pi-agent-ide-lsp/package.json +10 -13
  157. package/node_modules/pi-agent-ide-lsp/runtime/entry-39.js +2 -0
  158. package/node_modules/pi-agent-image/package.json +3 -3
  159. package/node_modules/pi-agent-invariant/package.json +2 -2
  160. package/node_modules/pi-agent-pdf/package.json +3 -4
  161. package/node_modules/pi-agent-read/package.json +12 -12
  162. package/node_modules/pi-agent-read/runtime/entry-46.js +0 -1
  163. package/node_modules/pi-agent-read/runtime/entry-47.js +2 -0
  164. package/node_modules/pi-agent-resource/package.json +2 -2
  165. package/node_modules/pi-agent-resource/src/result-targets.ts +9 -0
  166. package/node_modules/pi-agent-search/package.json +9 -9
  167. package/node_modules/pi-agent-search/runtime/entry-51.js +0 -1
  168. package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  169. package/node_modules/pi-agent-search/src/api/presentation.ts +10 -2
  170. package/node_modules/pi-agent-search/src/api/search-parameters.ts +1 -1
  171. package/node_modules/pi-agent-search/src/api/search.ts +7 -0
  172. package/node_modules/pi-agent-search/src/core/search-core.ts +23 -3
  173. package/node_modules/pi-agent-search-text/index.ts +2 -0
  174. package/node_modules/pi-agent-search-text/package.json +14 -14
  175. package/node_modules/pi-agent-search-text/runtime/entry-53.js +1 -0
  176. package/node_modules/pi-agent-search-text/src/search-backend.ts +18 -10
  177. package/node_modules/pi-agent-search-text/src/search-session.ts +68 -9
  178. package/node_modules/pi-agent-text/package.json +3 -3
  179. package/node_modules/pi-agent-text/runtime/entry-57.js +1 -0
  180. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  181. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-58.js +2 -0
  182. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -6
  183. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-59.js +0 -1
  184. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-60.js +2 -0
  185. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  186. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-61.js +0 -1
  187. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-62.js +2 -0
  188. package/node_modules/pi-agent-text-editor/package.json +26 -34
  189. package/node_modules/pi-agent-text-editor/runtime/entry-78.js +0 -1
  190. package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +1 -1
  191. package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
  192. package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +6 -12
  193. package/node_modules/pi-agent-text-editor/src/core/extension.ts +1 -0
  194. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +49 -21
  195. package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +18 -9
  196. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +2 -2
  197. package/node_modules/pi-agent-text-editor/src/core/temporary-directories.ts +13 -9
  198. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +16 -8
  199. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +118 -36
  200. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +7 -4
  201. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +6 -8
  202. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +22 -1
  203. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -8
  204. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +22 -0
  205. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  206. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +2 -0
  207. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  208. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  209. package/node_modules/pi-agent-tool-ui/runtime/entry-83.js +1 -0
  210. package/node_modules/pi-agent-web/package.json +8 -11
  211. package/node_modules/pi-agent-web-html/package.json +3 -5
  212. package/node_modules/pi-agent-web-image/package.json +4 -4
  213. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  214. package/node_modules/pi-agent-web-text/package.json +4 -4
  215. package/node_modules/pi-agent-web-text/runtime/entry-88.js +2 -0
  216. package/package.json +43 -39
  217. package/skills/configure-agent-ide/SKILL.md +38 -0
  218. package/src/api/content.ts +6 -0
  219. package/src/api/tips.ts +3 -0
  220. package/src/composite/nested-tool-rendering.ts +16 -5
  221. package/src/composite/preferences.ts +13 -0
  222. package/src/composite/settings-documentation.ts +59 -0
  223. package/src/composite/settings-help.ts +106 -0
  224. package/src/composite/text-results.ts +50 -22
  225. package/src/documentation/extension.ts +12 -0
  226. package/src/documentation/search.ts +166 -0
  227. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
  228. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  229. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +6 -7
  230. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  231. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  232. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-31.js +2 -0
  233. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-27.js +2 -0
  234. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -11
  235. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -5
  236. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  237. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  238. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  239. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-88.js +2 -0
  240. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-84.js +2 -0
  241. package/src/extensions/pi-agent-read/package.json +12 -12
  242. package/src/extensions/pi-agent-read/runtime/entry-46.js +0 -1
  243. package/src/extensions/pi-agent-read/runtime/entry-47.js +2 -0
  244. package/src/extensions/pi-agent-search/package.json +9 -9
  245. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +2 -0
  246. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +14 -14
  247. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +1 -0
  248. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-56.js +1 -0
  249. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +18 -10
  250. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +68 -9
  251. package/src/extensions/pi-agent-search/runtime/entry-51.js +0 -1
  252. package/src/extensions/pi-agent-search/runtime/entry-52.js +2 -0
  253. package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  254. package/src/extensions/pi-agent-search/src/api/presentation.ts +10 -2
  255. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +1 -1
  256. package/src/extensions/pi-agent-search/src/api/search.ts +7 -0
  257. package/src/extensions/pi-agent-search/src/core/search-core.ts +23 -3
  258. package/src/extensions/pi-agent-text-editor/package.json +26 -34
  259. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  260. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-58.js +2 -0
  261. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -6
  262. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-59.js +0 -1
  263. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-60.js +2 -0
  264. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  265. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-61.js +0 -1
  266. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-62.js +2 -0
  267. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -8
  268. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +22 -0
  269. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  270. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +2 -0
  271. package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +0 -1
  272. package/src/extensions/pi-agent-text-editor/runtime/entry-79.js +2 -0
  273. package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +1 -1
  274. package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
  275. package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +6 -12
  276. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +1 -0
  277. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +49 -21
  278. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +18 -9
  279. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +2 -2
  280. package/src/extensions/pi-agent-text-editor/src/core/temporary-directories.ts +13 -9
  281. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +16 -8
  282. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +118 -36
  283. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +7 -4
  284. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +6 -8
  285. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +22 -1
  286. package/src/pi-agent-ide.ts +14 -2
  287. package/src/plugins/pi-agent-ide-ast/package.json +15 -41
  288. package/src/plugins/pi-agent-ide-ast/runtime/entry-32.js +0 -1
  289. package/src/plugins/pi-agent-ide-ast/runtime/entry-33.js +2 -0
  290. package/src/plugins/pi-agent-ide-changes/package.json +10 -11
  291. package/src/plugins/pi-agent-ide-changes/runtime/entry-34.js +0 -1
  292. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  293. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  294. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  295. package/src/plugins/pi-agent-ide-lsp/package.json +10 -13
  296. package/src/plugins/pi-agent-ide-lsp/runtime/entry-39.js +2 -0
  297. package/src/tips/core.ts +5 -2
  298. package/src/tips/extension.ts +30 -2
  299. package/src/tips/persistence.ts +29 -27
  300. package/src/tips/setup-hint.ts +19 -0
  301. package/dist/chunk-5KFVDYCI.js +0 -1
  302. package/dist/chunk-ABFCAOU5.js +0 -1
  303. package/dist/chunk-BIG45IPN.js +0 -2
  304. package/dist/chunk-BMOJTJJJ.js +0 -3
  305. package/dist/chunk-BQ67M4NC.js +0 -3
  306. package/dist/chunk-IH5NW5JX.js +0 -11
  307. package/dist/chunk-NRZO5KJT.js +0 -9
  308. package/dist/chunk-O36UC74T.js +0 -1
  309. package/dist/chunk-SSWUUBIR.js +0 -1
  310. package/dist/entry-19.js +0 -1
  311. package/docs/research/apply-native-capability-matrix.md +0 -174
  312. package/docs/research/apply-read-latency.md +0 -221
  313. package/docs/research/codemode-write-context.md +0 -56
  314. package/docs/research/lpt-393-fuzzy-results/file.json +0 -152
  315. package/docs/research/lpt-393-fuzzy-results/repo.json +0 -122
  316. package/docs/research/lpt-393-search-fuzzy-fallback.md +0 -97
  317. package/docs/research/native-codemode-batch-decision.md +0 -31
  318. package/docs/research/native-codemode-batching.md +0 -65
  319. package/node_modules/pi-agent-doctor/runtime/entry-19.js +0 -1
  320. package/node_modules/pi-agent-filesystem/runtime/entry-26.js +0 -2
  321. package/node_modules/pi-agent-ide-ast/runtime/entry-31.js +0 -1
  322. package/node_modules/pi-agent-ide-changes/runtime/entry-33.js +0 -1
  323. package/node_modules/pi-agent-image/runtime/entry-39.js +0 -1
  324. package/node_modules/pi-agent-resource/runtime/entry-47.js +0 -1
  325. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-57.js +0 -2
  326. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-58.js +0 -1
  327. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-60.js +0 -1
  328. package/node_modules/pi-agent-text-editor/runtime/entry-62.js +0 -1
  329. package/node_modules/pi-agent-tool-call-interception/runtime/entry-81.js +0 -1
  330. package/node_modules/pi-agent-web/runtime/entry-83.js +0 -2
  331. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-27.js +0 -2
  332. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-26.js +0 -2
  333. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-84.js +0 -2
  334. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +0 -2
  335. package/src/extensions/pi-agent-read/runtime/entry-42.js +0 -1
  336. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-52.js +0 -2
  337. package/src/extensions/pi-agent-search/runtime/entry-48.js +0 -1
  338. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-57.js +0 -2
  339. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-58.js +0 -1
  340. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-60.js +0 -1
  341. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-79.js +0 -2
  342. package/src/extensions/pi-agent-text-editor/runtime/entry-62.js +0 -1
  343. package/src/plugins/pi-agent-ide-ast/runtime/entry-31.js +0 -1
  344. package/src/plugins/pi-agent-ide-changes/runtime/entry-33.js +0 -1
  345. /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-25.js +0 -0
  346. /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-27.js +0 -0
  347. /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-28.js +0 -0
  348. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-29.js +0 -0
  349. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-30.js +0 -0
  350. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-35.js +0 -0
  351. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-36.js +0 -0
  352. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-37.js +0 -0
  353. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-38.js +0 -0
  354. /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-40.js +0 -0
  355. /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-41.js +0 -0
  356. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-42.js +0 -0
  357. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-48.js +0 -0
  358. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-52.js +0 -0
  359. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-56.js +0 -0
  360. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-79.js +0 -0
  361. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-80.js +0 -0
  362. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-82.js +0 -0
  363. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-84.js +0 -0
  364. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-85.js +0 -0
  365. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-86.js +0 -0
  366. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-87.js +0 -0
  367. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-28.js +0 -0
  368. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-29.js +0 -0
  369. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-30.js +0 -0
  370. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-85.js +0 -0
  371. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-86.js +0 -0
  372. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-87.js +0 -0
  373. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-80.js +0 -0
  374. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-35.js +0 -0
  375. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-36.js +0 -0
  376. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-37.js +0 -0
  377. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-38.js +0 -0
package/dist/entry-80.js CHANGED
@@ -1,2 +1,22 @@
1
- import{a as I}from"./chunk-2RTCSZB3.js";import{b as _}from"./chunk-YHADTHQM.js";import{a as x}from"./chunk-IH5NW5JX.js";import{a as v}from"./chunk-MXLSGMRZ.js";import"./chunk-XH5WN5XA.js";import"./chunk-GW6NZQTQ.js";import{a as S}from"./chunk-2K65BSXS.js";import{c as O,d as b}from"./chunk-ICDI27GZ.js";import{a as C}from"./chunk-BU7IZLKB.js";import{a as k,b as w}from"./chunk-S5PL5DFQ.js";import"./chunk-PS2B6THP.js";import"./chunk-R5XJSEOE.js";import"./chunk-ZPT5D4VP.js";import{a as M}from"./chunk-ZC65Z3CK.js";import{a as h}from"./chunk-EI7MMDWY.js";var P="\0",$="";async function H(t){let i,n={protocol:k,apiVersion:w,id:"text-editor-stale-anchor",setup(r){i=r}},d={protocol:O,apiVersion:b,id:"text-editor-stale-anchor",setup(r){let a=V(t,r,()=>{if(i===void 0)throw new Error("pi-agent-read is unavailable");return i});x(t,a.handler),r.onMutationTool(a.add)}};await Promise.all([C(t,n),S(t,d)])}h(H,"registerTextEditorStaleAnchor");function V(t,i,n){let d=new Map,r=[],a=new Map,l=new Map,c=new Map,g={name:"text-editor-stale-anchor-inspection",blockExecution:!0,toolNames:r,async intercept(e){let s=d.get(e.toolCall.name);if(s===void 0)return;let p=e.partialArgs??e.args,o=j(p,e,a,s.source.field,s.source.inherited?_(t)?.source:void 0);if(o===void 0)return;let m=await B(i,n(),e,s,p,o,l,c);if(m!==void 0)return m;let A=s.pair?.every(u=>{let R=s.anchors?.find(T=>T.field===u);return R!==void 0&&I(R,p[u])})===!0?new Set(s.pair):new Set;for(let u of s.anchors??[]){if(A.has(u.field))continue;let R=p[u.field];if(!I(u,R))continue;let T=p[u.sourceField],y=typeof T=="string"?T:o,f=await D(i,n(),e,u.field,y,[R],[u.kinds],l,c);if(f!==void 0)return f}},onContentEnd(e){l.delete(e),c.delete(e)},onAbort(e){l.delete(e),c.delete(e),a.delete(e)},onAgentEnd(){l.clear(),c.clear(),a.clear()}};return{handler:g,add(e){(e.anchors?.length??0)>0&&(d.set(e.name,e),r.push(e.name),x(t,g))}}}h(V,"createHandler");function j(t,i,n,d,r){let a=t[d];if(typeof a=="string")return i.contentIndex!==void 0&&n.set(i.contentIndex,a),a;if(i.contentIndex!==void 0)for(let l=i.contentIndex-1;l>=0;l-=1){let c=n.get(l);if(c!==void 0)return t[d]=c,c}return r!==void 0&&(t[d]=r),r}h(j,"resolveSource");async function B(t,i,n,d,r,a,l,c){if(d.pair===void 0)return;let[g,e]=d.pair,s=r[g],p=r[e];if(typeof s!="string"||typeof p!="string")return;let o=d.anchors?.find(({field:A})=>A===g),m=d.anchors?.find(({field:A})=>A===e);if(!(o===void 0||m===void 0)&&!(!I(o,s)||!I(m,p)))return D(t,i,n,e,a,[s,p],[o.kinds,m.kinds],l,c)}h(B,"inspectAnchorPair");async function D(t,i,n,d,r,a,l,c,g){let e=n.contentIndex??-1,s=`${r}${P}${a.join(P)}${P}${l.map(f=>f.join($)).join(P)}`,p=g.get(e)?.get(s);if(p!==void 0)return p;let o=c.get(e)?.get(s);if(o===void 0){let f=await t.inspectTextAnchors({source:r,anchors:a,kinds:l,cwd:n.cwd,...n.signal!==void 0&&{signal:n.signal}}),E=c.get(e)??new Map;E.set(s,f),c.set(e,E),o=f}if(o.kind==="valid")return;if(o.kind==="failed")return L(n.toolCall.name,r,o.reason);if(o.rejectionCode!=="stale")return;let m=o.anchorIndex,u=(o.contextRange===void 0?void 0:await i.read({path:r,views:["anchors"],...o.contextRange},{cwd:n.cwd,...n.signal!==void 0&&{signal:n.signal}}))?.content.filter(f=>f.type==="text").map(f=>f.text).join(`
2
- `),R={guardId:"stale-anchor",effect:"not-applied",toolName:n.toolCall.name,field:d,path:r,anchor:M(a[m]),...!(u===void 0||u.length===0)&&{context:u}},T=N(R,o.reason),y=g.get(e)??new Map;return y.set(s,T),g.set(e,y),T}h(D,"inspectAnchors");function L(t,i,n){return{annotation:{kind:"blocked",reason:n},message:{customType:"text-editor-resolver-block",content:`[SYSTEM] ${t} blocked: ${n}`,display:!1,details:{guardId:"resolver",effect:"not-applied",toolName:t,source:i,reason:n}}}}h(L,"makeResolverBlockResult");function N(t,i){return{annotation:{kind:"stale-anchor"},message:{customType:"text-editor-stale-anchor-block",content:v(t,i),display:!1,details:t}}}h(N,"makeBlockResult");export{H as default};
1
+ import{b as x}from"./chunk-XH5WN5XA.js";import{a as z,b as A,c as ye,d as we,e as P,f as ve}from"./chunk-IM24DB3K.js";import"./chunk-QUYXINGZ.js";import"./chunk-PRLIHLCS.js";import{i as Re}from"./chunk-A64JRDZK.js";import{a as be}from"./chunk-M4TVRCMZ.js";import{c as pe,d as me}from"./chunk-TGC2ZACO.js";import{g as he,h as H,i as K}from"./chunk-PS2B6THP.js";import"./chunk-DXONCYWF.js";import"./chunk-ZPT5D4VP.js";import{a as w}from"./chunk-ZC65Z3CK.js";import{a as u}from"./chunk-EI7MMDWY.js";import{Text as Nt}from"@earendil-works/pi-tui";import{getLanguageFromPath as In,highlightCode as Hn}from"@earendil-works/pi-coding-agent";import{Box as Vn,truncateToWidth as We,visibleWidth as Wn,wrapTextWithAnsi as Un}from"@earendil-works/pi-tui";import{keyHint as Pn}from"@earendil-works/pi-coding-agent";import{truncateToWidth as Fe,visibleWidth as ie,wrapTextWithAnsi as Sn}from"@earendil-works/pi-tui";var hn=.055,pn=.115,mn=.42,bn=.58,Rn=.045,yn=.06,wn=.12,vn=.65,Ae=3,Tn=1.6,Mn=2,J=[0,95,135,175,215,255],_n=[{red:0,green:0,blue:0},{red:128,green:0,blue:0},{red:0,green:128,blue:0},{red:128,green:128,blue:0},{red:0,green:0,blue:128},{red:128,green:0,blue:128},{red:0,green:128,blue:128},{red:192,green:192,blue:192},{red:128,green:128,blue:128},{red:255,green:0,blue:0},{red:0,green:255,blue:0},{red:255,green:255,blue:0},{red:0,green:0,blue:255},{red:255,green:0,blue:255},{red:0,green:255,blue:255},{red:255,green:255,blue:255}],Cn=8,Pe=Array.from({length:256},(e,n)=>ke(n)),Te=Pe.map(e=>V(e)),Se=new Set;function Ee(e,n){let t=e.getBgAnsi(n?"toolPendingBg":"toolSuccessBg"),r=L(t)??L(e.getBgAnsi("selectedBg")),i=e.getColorMode(),o=new Set,d=te(t);d!==void 0&&o.add(d);let a=Q(Me(e,"toolDiffAdded","success"),r,t,i,o),s=Q(Me(e,"toolDiffRemoved","error"),r,t,i,o),f=Q(e.getFgAnsi("warning"),r,t,i,o);return{added:a,removed:s,modified:f,contextForeground:e.getFgAnsi("toolDiffContext"),restoreBackground:t}}u(Ee,"createDiffThemePalette");function Me(e,n,t){let r=e.getFgAnsi(n);return L(r)===void 0?e.getFgAnsi(t):r}u(Me,"semanticForeground");function Q(e,n,t,r,i){let o=L(e);if(n===void 0||o===void 0)return{foreground:e,background:t,emphasisBackground:t};let d=V(n),a=V(o),s=d.lightness<vn,f=r==="256color"?Tn:1,l=r==="256color"?Mn:1,c=_e(d,a,s,hn*f,mn*l,Rn*l),h=_e(d,a,s,pn*f,bn*l,yn*l),p=Z(c,48,r,i),g=te(p);g!==void 0&&i.add(g);let b=L(p)??c,m=xn(a,b,s);return{foreground:Z(m,38,r,Se,b),background:p,emphasisBackground:Z(h,48,r,i)}}u(Q,"createTone");function _e(e,n,t,r,i,o){let d=Math.hypot(n.a,n.b),a=d===0?0:Math.atan2(n.b,n.a),s=Math.min(d*i,o),f=t?1:-1,l=k(e.lightness+f*r,.08,.97);return ne(l,s,a)}u(_e,"deriveBackground");function xn(e,n,t){let r=Math.hypot(e.a,e.b),i=r===0?0:Math.atan2(e.b,e.a),o=Math.min(r,wn),d=t?k(e.lightness,.67,.86):k(e.lightness,.34,.62),a=ne(d,o,i);for(let s=0;s<24&&Le(a,n)<Ae;s++)d=k(d+(t?.012:-.012),.12,.96),a=ne(d,o,i);return a}u(xn,"deriveForeground");function L(e){let n=e.startsWith("\x1B[")?e.slice(2):e,t=/^(?:38|48);2;(\d+);(\d+);(\d+)m$/u.exec(n);if(t!==null)return{red:E(Number(t[1])),green:E(Number(t[2])),blue:E(Number(t[3]))};let r=te(e);return r===void 0?void 0:ke(r)}u(L,"ansiToRgb");function te(e){let n=e.startsWith("\x1B[")?e.slice(2):e,t=/^(?:38|48);5;(\d+)m$/u.exec(n);return t===null?void 0:k(Math.round(Number(t[1])),0,255)}u(te,"ansi256Index");function ke(e){if(e<16)return w(_n[e]);if(e<232){let t=e-16;return{red:w(J[Math.floor(t/36)]),green:w(J[Math.floor(t%36/6)]),blue:w(J[t%6])}}let n=8+(e-232)*10;return{red:n,green:n,blue:n}}u(ke,"ansi256ToRgb");function Z(e,n,t,r=Se,i){return t==="256color"?`\x1B[${n};5;${De(e,r,i)}m`:`\x1B[${n};2;${e.red};${e.green};${e.blue}m`}u(Z,"colorAnsi");function De(e,n,t){let r=V(e),i,o=1/0;for(let d=16;d<Te.length;d++){let a=w(Pe[d]);if(n.has(d)||t!==void 0&&Le(a,t)<Ae)continue;let s=w(Te[d]),f=r.lightness-s.lightness,l=r.a-s.a,c=r.b-s.b,h=f**2+Cn*(l**2+c**2);h<o&&(i=d,o=h)}return i??(t===void 0?16:De(e,n))}u(De,"rgbTo256");function V(e){let n=S(e.red/255),t=S(e.green/255),r=S(e.blue/255),i=Math.cbrt(.4122214708*n+.5363325363*t+.0514459929*r),o=Math.cbrt(.2119034982*n+.6806995451*t+.1073969566*r),d=Math.cbrt(.0883024619*n+.2817188376*t+.6299787005*r);return{lightness:.2104542553*i+.793617785*o-.0040720468*d,a:1.9779984951*i-2.428592205*o+.4505937099*d,b:.0259040371*i+.7827717662*o-.808675766*d}}u(V,"rgbToOklab");function ne(e,n,t){let r=0,i=n,o=Ce({lightness:e,a:0,b:0});for(let d=0;d<18;d++){let a=d===0?i:(r+i)/2,s=Ce({lightness:e,a:Math.cos(t)*a,b:Math.sin(t)*a});if(An(s)){if(o=s,r=a,d===0)break}else i=a}return{red:E(Math.round(o[0]*255)),green:E(Math.round(o[1]*255)),blue:E(Math.round(o[2]*255))}}u(ne,"oklchToRgb");function Ce(e){let n=(e.lightness+.3963377774*e.a+.2158037573*e.b)**3,t=(e.lightness-.1055613458*e.a-.0638541728*e.b)**3,r=(e.lightness-.0894841775*e.a-1.291485548*e.b)**3;return[ee(4.0767416621*n-3.3077115913*t+.2309699292*r),ee(-1.2684380046*n+2.6097574011*t-.3413193965*r),ee(-.0041960863*n-.7034186147*t+1.707614701*r)]}u(Ce,"oklabToSrgb");function An(e){return e.every(n=>n>=0&&n<=1)}u(An,"inGamut");function S(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}u(S,"srgbToLinear");function ee(e){return e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055}u(ee,"linearToSrgb");function Le(e,n){let t=xe(e),r=xe(n);return(Math.max(t,r)+.05)/(Math.min(t,r)+.05)}u(Le,"contrast");function xe(e){return .2126*S(e.red/255)+.7152*S(e.green/255)+.0722*S(e.blue/255)}u(xe,"relativeLuminance");function E(e){return k(e,0,255)}u(E,"clampByte");function k(e,n,t){return Math.min(t,Math.max(n,e))}u(k,"clamp");function $e(e){if(e.rows.length<=12)return e.rows.map(i=>({row:i}));let n=Math.max(0,Math.min(e.focusRow-5,e.rows.length-12)),t=n+12,r=e.rows.slice(n,t).map(i=>({row:i}));return n>0&&(r[0]={omitted:n+1,omittedChanged:e.rows.slice(0,n+1).filter(i=>i.changed).length}),t<e.rows.length&&(r[r.length-1]={omitted:e.rows.length-t+1,omittedChanged:e.rows.slice(t-1).filter(i=>i.changed).length}),r}u($e,"compactViewport");function Oe(e){return e.rows.map(n=>({row:n}))}u(Oe,"expandedViewport");function Ne(e,n,t,r,i,o,d=!1){let s=Math.max(20,n)-2,f=Ee(t,i),l=u(m=>t.fg("borderMuted",m),"styleFrame"),c=[On(e,s,t,l,d)],h=r?Oe(e.model):$e(e.model),p=0;for(let m of e.model.rows)p=Math.max(p,m.beforeLine??0,m.afterLine??0);let g=Math.max(3,String(p).length),b=!1;for(let m of h){let T=!r&&m.omitted!==void 0&&!b;T&&(b=!0);let y=Be(m.row?.kind,f),R=y===void 0?void 0:C=>Bn(y.background,C,f.restoreBackground),v=m.row!==void 0&&e.cursor!==void 0&&e.cursor.line===m.row.afterLine&&m.row.kind!=="removed",M=m.row===void 0||v?void 0:o?.get(m.row);if(M!==void 0){c.push(...M);continue}let D=En(m,e,g,s,t,f,T).map(C=>Nn(C,s,l,R));m.row!==void 0&&!v&&o?.set(m.row,D),c.push(...D)}return c.push(l(He("\u2570","\u2500","\u256F",s))),c}u(Ne,"renderDiffPanel");function En(e,n,t,r,i,o,d){let a=e.omitted??e.row?.omitted;if(a!==void 0){let R=$(o.contextForeground,` \xB7\xB7\xB7 ${String(a)} lines omitted${e.omittedChanged?` (${e.omittedChanged} changed)`:""}`);return[d?`${R}${$(o.contextForeground," \xB7 ")}${Pn("app.tools.expand","to expand")}${$(o.contextForeground," \xB7\xB7\xB7")}`:`${R}${$(o.contextForeground," \xB7\xB7\xB7")}`]}if(e.row===void 0)return[""];let s=e.row,f=String(s.kind==="removed"?s.beforeLine??"":s.afterLine??"").padStart(t),l=s.kind==="added"?"+":s.kind==="removed"?"-":s.kind==="modified"?"~":" ",c=`${f} ${l} `,h=Be(s.kind,o),p=$(h?.foreground??o.contextForeground,c),g=n.highlightedRows.get(s)??s.text.replaceAll(" "," ".repeat(4));s.kind==="modified"&&(g=kn(g,s.text,s.addedRanges??[],o.modified,s.deletedOffsets??[]));let b=n.cursor;b!==void 0&&b.line===s.afterLine&&s.kind!=="removed"&&(g=$n(g,re(s.text,b.column),i.fg("accent","\u258C")));let m=Math.max(1,r-1-ie(c)),T=Sn(g,m),y=" ".repeat(c.length);return T.map((R,v)=>`${v===0?p:y}${R}`)}u(En,"renderRow");function Be(e,n){return e==="added"?n.added:e==="removed"?n.removed:e==="modified"?n.modified:void 0}u(Be,"diffTone");function kn(e,n,t,r,i){let o=Ln([...t,...Dn(n,i)]).map(({from:p,to:g})=>({from:re(n,p),to:re(n,g)})),d=r.emphasisBackground,a=r.background,s="",f=0,l=0,c=0,h=!1;for(;f<e.length;){let p=Ie(e,f);if(p!==void 0){s+=p,h&&(s+=d),f+=p.length;continue}h&&o[c]?.to===l&&(s+=a,h=!1,c++),!h&&o[c]?.from===l&&(s+=d,h=!0),s+=e[f],f++,l++}return h&&(s+=a),s}u(kn,"highlightRanges");function Dn(e,n){let t=[...e.matchAll(/[\p{L}\p{M}\p{N}_$]+/gu)].map(r=>({from:r.index,to:r.index+r[0].length}));return n.flatMap(r=>{let i=t.find(({to:o})=>o>r)??t.at(-1);return i===void 0?[]:[i]})}u(Dn,"deletionWordRanges");function Ln(e){let n=[];for(let t of[...e].sort((r,i)=>r.from-i.from)){let r=n.at(-1);r!==void 0&&t.from<=r.to?n[n.length-1]={from:r.from,to:Math.max(r.to,t.to)}:n.push(t)}return n}u(Ln,"mergeRanges");function Ie(e,n){if(!(e[n]!=="\x1B"||e[n+1]!=="["))for(let t=n+2;t<e.length;t++){let r=w(e.codePointAt(t));if(r>=64&&r<=126)return e.slice(n,t+1)}}u(Ie,"ansiSequenceAt");function $n(e,n,t){let r=0;for(let i=0;i<e.length;){if(r===n)return`${e.slice(0,i)}${t}${e.slice(i)}`;let o=Ie(e,i);o===void 0?(i++,r++):i+=o.length}return`${e}${t}`}u($n,"insertCursor");function re(e,n){return e.slice(0,n).replaceAll(" "," ".repeat(4)).length}u(re,"expandedOffset");function On(e,n,t,r,i){if(!i)return r(He("\u256D","\u2500","\u256E",n));let o=Fe(e.path,Math.max(1,n-3)),a=` ${Fn(o,e.link,t)} `,s="\u2500".repeat(Math.max(0,n-ie(a)-1));return`${r("\u256D\u2500")}${a}${r(`${s}\u256E`)}`}u(On,"renderTopBorder");function Fn(e,n,t){let r=t.underline(t.fg("accent",e));return n===void 0||n.includes("\x07")||n.includes("\x1B")?r:`\x1B]8;;${n}\x07${r}\x1B]8;;\x07`}u(Fn,"renderResourcePath");function Nn(e,n,t,r){let i=Fe(` ${e}`,n),o=`${i}${" ".repeat(Math.max(0,n-ie(i)))}`;return`${t("\u2502")}${r?.(o)??o}${t("\u2502")}`}u(Nn,"framed");function $(e,n){return`${e}${n}\x1B[39m`}u($,"withForeground");function Bn(e,n,t){return`${e}${H(n,e)}${t}`}u(Bn,"withBackground");function He(e,n,t,r){return`${e}${n.repeat(r)}${t}`}u(He,"border");function Ve(e){let n=new Set,t=new Set,r=new Set,i=new Set,o=new Map;for(let d of e)for(let a of d.diffStatuses??[]){if(a.formatter!==void 0&&a.tone==="success"&&(a.formattingStatus===void 0||a.formattingStatus==="changed"||a.formattingStatus==="unchanged")){a.formattingStatus==="unchanged"?(r.add(d.path),i.add(a.formatter)):(n.add(d.path),t.add(a.formatter));continue}let s=JSON.stringify([a.text,a.tone]),f=o.get(s);f||(f={status:a,paths:new Set},o.set(s,f)),f.paths.add(d.path)}return{formatted:[...n],formatters:[...t],alreadyFormatted:[...r],unchangedFormatters:[...i],statuses:[...o.values()].map(({status:d,paths:a})=>({status:d,paths:[...a]}))}}u(Ve,"summarizeStatuses");var _=class{constructor(n,t=!1){this.theme=n;this.ownsShell=t;this.themeColors=n.colors,this.themeAppearance=n.appearance,this.themeColorMode=n.getColorMode()}static{u(this,"MutationPanel")}resources=[];diffPanels=[];header="";headerDetails=[];headerExpanded=!1;background="toolPendingBg";expanded=!1;diffsVisible=!0;resourceLabelsVisible=!1;cache;renderedRows=new Map;renderedWidth;themeColors;themeAppearance;themeColorMode;setTheme(n){this.theme===n&&this.themeColors===n.colors&&this.themeAppearance===n.appearance&&this.themeColorMode===n.getColorMode()||(this.theme=n,this.themeColors=n.colors,this.themeAppearance=n.appearance,this.themeColorMode=n.getColorMode(),this.diffPanels=[],this.renderedRows.clear(),this.rebuildPanels())}setBackground(n){this.background!==n&&(this.background=n,this.invalidate())}setExpanded(n){this.expanded!==n&&(this.expanded=n,this.renderedRows.clear(),this.invalidate())}setDiffsVisible(n){this.diffsVisible!==n&&(this.diffsVisible=n,this.invalidate())}setResourceLabelsVisible(n){this.resourceLabelsVisible!==n&&(this.resourceLabelsVisible=n,this.invalidate())}setHeader(n,t=[],r=!1){this.header===n&&this.headerDetails===t&&this.headerExpanded===r||(this.header=n,this.headerDetails=t,this.headerExpanded=r,this.invalidate())}setPreviewResources(n){this.resources=n,this.rebuildPanels()}setResultResources(n){this.resources=n,this.rebuildPanels()}hasResources(){return this.resources.length>0}invalidate(){this.cache=void 0}rebuildPanels(){let n=this.diffPanels;this.diffPanels=this.resources.filter(t=>t.model!==void 0||t.beforeContent!==t.afterContent).flatMap(t=>{let r=t.model??A(t.beforeContent,t.afterContent,t.ranges);if(r.added===0&&r.modified===0&&r.removed===0)return[];let i=n.find(o=>o.path===t.path);return[{path:t.path,...t.link!==void 0&&{link:t.link},model:r,highlightedRows:Xn(t.path,r,i?.highlightedRows),...t.cursorOffset!==void 0&&{cursor:Yn(t.afterContent,t.cursorOffset)}}]}),this.invalidate()}render(n){this.setTheme(this.theme);let t=this.ownsShell?Math.max(1,n-2):n;if(this.renderedWidth!==t&&(this.renderedRows.clear(),this.renderedWidth=t),this.cache?.width===t&&this.cache.expanded===this.expanded&&this.cache.diffsVisible===this.diffsVisible&&this.cache.header===this.header&&this.cache.headerDetails===this.headerDetails&&this.cache.headerExpanded===this.headerExpanded&&this.cache.resourceLabelsVisible===this.resourceLabelsVisible)return this.renderShell(this.cache.lines,n);let r=this.diffsVisible?qn(this.diffPanels,f=>Ne(f,t,this.theme,this.expanded,this.background==="toolPendingBg",this.renderedRows,this.resourceLabelsVisible)):[],i=`${this.theme.getBgAnsi(this.background)}...`,o=this.header.length===0?[]:[We(this.header,t,i)],d=this.headerExpanded?he(this.headerDetails,this.theme,t):[],a=jn(this.resources,this.theme,t),s=[...o,...d,...r,...a].map(f=>H(We(f,t),this.theme.getBgAnsi(this.background)));return this.cache={width:t,expanded:this.expanded,diffsVisible:this.diffsVisible,header:this.header,headerDetails:this.headerDetails,headerExpanded:this.headerExpanded,resourceLabelsVisible:this.resourceLabelsVisible,lines:s},this.renderShell(s,n)}renderShell(n,t){if(!this.ownsShell||n.length===0)return n;let r=new Vn(1,1,i=>this.theme.bg(this.background,i));return r.addChild({render:u(()=>n,"render"),invalidate(){}}),r.render(t)}};function jn(e,n,t){let r=Gn(e,n),i=Ve(e.map(a=>({path:a.path,diffStatuses:[...a.diffStatuses??[],...a.model?.rows.some(s=>s.inlineUnavailable)?[{text:"Inline diff unavailable: comparison limit reached",tone:"warning"}]:[],...a.model?.omittedChanges===void 0?[]:[{text:a.model.omittedChanges.unavailable?"Local diff unavailable: alignment limit reached":[...a.model.omittedChanges.outside>0?[`${a.model.omittedChanges.outside} changed rows outside this area`]:[],...a.model.omittedChanges.ambiguous>0?[`${a.model.omittedChanges.ambiguous} changed rows unassigned`]:[]].join("; "),tone:"warning"}]]}))),o=i.statuses.map(({status:a,paths:s})=>{let f=e.length>1?`${s.join(", ")}: ${a.text}`:a.text;return n.fg(a.tone??"muted",f.replace(/[\u0000-\u001f\u007f-\u009f]/g," "))});if(i.formatted.length>0){let a=i.formatters.length===1?i.formatters[0]:`${i.formatters.length} formatters`,s=e.length===1?`Formatted (${a})`:`Formatted ${i.formatted.length} files by ${a}`;o.unshift(n.fg("success",s.replace(/[\u0000-\u001f\u007f-\u009f]/g," ")))}if(i.alreadyFormatted.length>0){let a=i.unchangedFormatters.length===1?i.unchangedFormatters[0]:`${i.unchangedFormatters.length} formatters`,s=e.length===1?`Already formatted (${a})`:`Already formatted ${i.alreadyFormatted.length} files by ${a}`;o.unshift(n.fg("success",s.replace(/[\u0000-\u001f\u007f-\u009f]/g," ")))}let d=[r,...o].filter(a=>a!==void 0).join(n.fg("dim"," \xB7 "));return d.length===0?[]:Wn(d)<=t?[d]:Un(d,Math.max(1,t))}u(jn,"renderTail");function Gn(e,n){let t={added:0,modified:0,removed:0},r=!1;for(let i of e){let o=i.model??A(i.beforeContent,i.afterContent,i.ranges);t.added+=o.added,t.modified+=o.modified,t.removed+=o.removed,r||=o.added+o.modified+o.removed>0}if(r)return`${n.fg("success",`+${t.added}`)} ${n.fg("warning",`~${t.modified}`)} ${n.fg("error",`-${t.removed}`)}`}u(Gn,"renderCounts");function qn(e,n){return e.flatMap((t,r)=>[...r===0?[]:[""],...n(t)])}u(qn,"renderPanels");function Xn(e,n,t){let r=new Map,i=[],o=[];for(let a of n.rows){let s=t?.get(a);if(s!==void 0){o.length>0&&(i.push(o),o=[]),r.set(a,s);continue}let f=Ue(a),l=o.at(-1),c=l===void 0?void 0:Ue(l);(f===void 0||l!==void 0&&(oe(l)!==oe(a)||c===void 0||f!==c+1))&&o.length>0&&(i.push(o),o=[]),f!==void 0&&o.push(a)}o.length>0&&i.push(o);let d=In(e);for(let a of i){let s=a.map(({text:l})=>l.replaceAll(" "," ".repeat(4))),f=Hn(s.join(`
2
+ `),d);for(let[l,c]of a.entries())r.set(c,f[l]??s[l]??"")}return r}u(Xn,"highlightRows");function Ue(e){return oe(e)?e.beforeLine:e.afterLine}u(Ue,"sourceLine");function oe(e){return e.kind==="removed"}u(oe,"isBeforeRow");function Yn(e,n){let r=e.slice(0,n).replaceAll(`\r
3
+ `,`
4
+ `).split(`
5
+ `);return{line:r.length,column:r.at(-1)?.length??0}}u(Yn,"cursorPosition");function je(e){let n=new Map;return e.on("message_update",t=>{let r=t.assistantMessageEvent;if(r.type!=="toolcall_start")return;let i=r.partial.content[r.contentIndex];if(i?.type==="toolCall")for(let[o,d]of n)o!==i.id&&d()}),{track(t,r){return n.set(t,r),()=>{n.get(t)===r&&n.delete(t)}}}}u(je,"createMutationAnimationPressure");import{Text as N}from"@earendil-works/pi-tui";function Xe(e,n,t=n){return e.map(r=>et(r,n,t))}u(Xe,"projectTypingResources");function se(e,n){return e.length!==n.length?n:n.map((t,r)=>{let i=e[r];if(i?.path!==t.path||!zn(i,t)||i.model===void 0||t.model===void 0)return t;let o=[...t.model.rows],d=0,a=!1;for(let s of i.model.rows.slice(0,i.model.focusRow)){let f=o.findIndex((l,c)=>c>=d&&l.afterLine===s.afterLine&&l.text===s.text);f!==-1&&(o[f]=s,d=f+1,a=!0)}return a?{...t,model:{...t.model,rows:o,added:o.filter(({kind:s})=>s==="added").length,modified:o.filter(({kind:s})=>s==="modified").length,removed:t.model.removed}}:t})}u(se,"preserveCompletedTypingRows");function Kn(e,n){return e===n?!0:e===void 0||n===void 0||e.length!==n.length?!1:e.every((t,r)=>{let i=w(n[r]);return t.from===i.from&&t.to===i.to})}u(Kn,"sameRanges");function zn(e,n){let t=e.typingIdentity?.beforeRanges??e.beforeRanges,r=n.typingIdentity?.beforeRanges??n.beforeRanges,i=e.typingIdentity?.ranges??e.ranges,o=n.typingIdentity?.ranges??n.ranges;if(e.beforeContent!==n.beforeContent||!Kn(t,r)||i.length!==1||o.length!==1)return!1;let d=w(i[0]),a=w(o[0]);return d.from===a.from&&d.to<=a.to&&e.afterContent.slice(0,d.to)===n.afterContent.slice(0,d.to)&&e.afterContent.slice(d.to)===n.afterContent.slice(a.to)}u(zn,"samePreviewTarget");function Ye(e,n,t,r,i){if(e.length!==t.length||e.length!==1||!i.startsWith(r)||!n.startsWith(i))return;let o=i.slice(r.length);if(o.length===0)return;let d=[];for(let[a,s]of e.entries()){let f=t[a],l=f===void 0?void 0:Jn(s,n,r,i,o,f);if(l===void 0)return;d.push(l)}return d}u(Ye,"advanceTypingProjectionResources");function Jn(e,n,t,r,i,o){let d=e.ranges.length===1?e.ranges[0]:void 0,a=e.beforeRanges?.length===1?e.beforeRanges[0]:void 0,s=o.model;if(d===void 0||s===void 0||o.path!==e.path||o.beforeContent!==e.beforeContent)return;let f=a!==void 0&&O(e,a,d),l=Math.min(d.from+n.length,d.to),c=Math.min(d.from+r.length,l);if(f)return Qn(e,t,r,i,o);let h=W(e.afterContent,c),p=s.rows.findLastIndex(y=>y.afterLine===h&&y.kind!=="removed"),g=s.rows[p];if(g===void 0||g.kind==="omitted"||g.beforeLine!==void 0)return;let b=e.afterContent.slice(de(e.afterContent,c),c);if(`${g.text}${i}`!==b||/\s/u.test(i)||g.text.trimEnd()!==g.text)return;let m=[...s.rows],T="added";return m[p]={...g,kind:T,text:b,changed:!0,addedRanges:Zn(g.addedRanges,g.text.length,b.length)},{...e,cursorOffset:c,model:{...s,rows:m,added:s.added+1-(g.kind==="added"?1:0),modified:s.modified-(g.kind==="modified"?1:0),focusRow:p}}}u(Jn,"advanceTypingProjectionResource");function Qn(e,n,t,r,i){let o=i.model,d=e.ranges.length===1?e.ranges[0]:void 0,a=e.beforeRanges?.length===1?e.beforeRanges[0]:void 0;if(o===void 0||d===void 0||a===void 0||i.path!==e.path||i.beforeContent!==e.beforeContent||!O(e,a,d))return;let s=Math.min(d.from+t.length,d.to),f=i.beforeLines??F(e.beforeContent),l=[...o.rows],c=o.added,h=o.modified,p=n.endsWith(`
6
+ `),g=performance.now()+100,b=l.at(-1),m=[...F(p?r:`${b?.text??""}${r}`)];if(b!==void 0&&m.length>0){let y=Ge(f,w(m[0]),l.length-1,t.endsWith(`
7
+ `)&&m.length===1&&w(m[0]).length===0,m.length>1,g);(b.text!==y.text||b.kind!==y.kind||b.deletedOffsets?.join(",")!==y.deletedOffsets?.join(","))&&(c+=(y.kind==="added"?1:0)-(b.kind==="added"?1:0),h+=(y.kind==="modified"?1:0)-(b.kind==="modified"?1:0),l[l.length-1]=y),m.shift()}for(let[y,R]of m.entries()){let v=Ge(f,R,l.length,y===m.length-1&&t.endsWith(`
8
+ `),y<m.length-1,g);l.push(v),h+=v.kind==="modified"?1:0,c+=v.kind==="added"?1:0}if(l.length<o.rows.length)return;let T=(b?.afterLine??1)+ot(r);return{...e,beforeLines:f,cursorOffset:s,model:{...o,rows:l,modified:h,added:c,focusRow:ue(l,T)}}}u(Qn,"advanceFullFileTypingResource");function Ge(e,n,t,r=!1,i=!1,o=performance.now()+100){let d=e[t];return r||d?.trim()===n.trim()?{kind:"context",text:n,...d!==void 0&&{beforeLine:t+1},afterLine:t+1,changed:!1}:{kind:d===void 0?"added":"modified",text:n,...d!==void 0&&{beforeLine:t+1},afterLine:t+1,changed:!0,...Ke(d,n,i,o)}}u(Ge,"createTypingLine");function Zn(e,n,t){let r=e?.at(-1);return r?.to===n?[...e?.slice(0,-1)??[],{from:r.from,to:t}]:[...e??[],{from:n,to:t}]}u(Zn,"appendedRange");function ae(e,n,t){if(!t.startsWith(n))return;if(t===n)return e;let r=t.slice(n.length),i=[];for(let o of e){let d=o.ranges.length===1?o.ranges[0]:void 0,a=d===void 0?-1:d.from+n.length;if(d===void 0||a>d.to||o.afterContent.slice(d.from,a)!==n)return;i.push({...o,afterContent:o.afterContent.slice(0,a)+r+o.afterContent.slice(a),ranges:[{from:d.from,to:d.to+r.length}]})}return i}u(ae,"extendTypingPreviewResources");function et(e,n,t){let r=e.beforeRanges;if(r?.length!==1||e.ranges.length!==1)return e;let i=w(r[0]),o=w(e.ranges[0]),d=Math.min(o.from+n.length,o.to),a=Math.min(o.from+t.length,d),s=O(e,i,o)?F(e.beforeContent):void 0;return{...e,...s!==void 0&&{beforeLines:s},cursorOffset:a,model:nt(e,i,o,d,a)}}u(et,"projectTypingResource");function nt(e,n,t,r,i){let o=O(e,n,t)?e.afterContent.slice(t.from,i):e.afterContent.slice(t.from,i)+e.afterContent.slice(r,t.to);if(O(e,n,t))return tt(e.beforeContent,o,i);let d=rt(e.beforeContent,n.from),a=it(e.beforeContent,n.to),s=e.beforeContent.slice(d,a),f=e.beforeContent.slice(d,n.from)+o+e.beforeContent.slice(n.to,a),l=W(e.beforeContent,d)-1,c=W(e.afterContent,i),h={beforeLineOffset:l,afterLineOffset:l,project:!1,focusAfterLine:c},p=A(s,f,[],h),g=p.rows.flatMap(qe),b=ue(g,c),m=e.beforeContent.slice(d,n.from)+e.afterContent.slice(t.from,t.to)+e.beforeContent.slice(n.to,a),T=A(s,m,[],h).rows.flatMap(qe),y=g.map((R,v)=>v>=b?R:T.find(M=>M.afterLine===R.afterLine&&M.text===R.text)??R);return{rows:y,...p.omittedChanges!==void 0&&{omittedChanges:p.omittedChanges},added:y.filter(({kind:R})=>R==="added").length,modified:y.filter(({kind:R})=>R==="modified").length,removed:0,focusRow:b}}u(nt,"createTypingModel");function O(e,n,t){return n.from===0&&n.to===e.beforeContent.length&&t.from===0&&t.to===e.afterContent.length}u(O,"isFullFileTyping");function tt(e,n,t){let r=F(e),i=F(n),o=performance.now()+100,d=W(n,t),a=i.map((s,f)=>{let l=f+1,c=r[f],h=l===d&&f===i.length-1&&s.length===0&&n.endsWith(`
9
+ `);return c?.trim()===s.trim()||h?{kind:"context",text:s,...c!==void 0&&{beforeLine:l},afterLine:l,changed:!1}:{kind:c===void 0?"added":"modified",text:s,...c!==void 0&&{beforeLine:l},afterLine:l,changed:!0,...Ke(c,s,f<i.length-1,o)}});return{rows:a,added:a.filter(({kind:s})=>s==="added").length,modified:a.filter(({kind:s})=>s==="modified").length,removed:0,focusRow:ue(a,d)}}u(tt,"createFullFileTypingModel");function F(e){return e.length===0?[]:e.replaceAll(`\r
10
+ `,`
11
+ `).split(`
12
+ `)}u(F,"fullFileLines");function qe(e){return e.kind==="removed"?[]:e.kind==="added"?[{...e,addedRanges:ze(e.text)}]:[e]}u(qe,"projectTypingRow");function Ke(e,n,t,r){if(e===void 0)return{addedRanges:ze(n)};let i=ye(e,n,r);return i===void 0?{addedRanges:[],inlineUnavailable:!0}:{...i,deletedOffsets:t?i.deletedOffsets:[]}}u(Ke,"typingChanges");function ze(e){let n=e.length-e.trimStart().length,t=e.trimEnd().length;return n<t?[{from:n,to:t}]:[]}u(ze,"typingTextRanges");function rt(e,n){let t=de(e,n);for(let r=0;r<z&&t>0;r++)t=de(e,t-1);return t}u(rt,"contextStart");function it(e,n){let t=n;for(let r=0;r<z&&t<e.length;r++){let i=e.indexOf(`
13
+ `,t);t=i===-1?e.length:i+1}return t}u(it,"contextEnd");function de(e,n){return e.lastIndexOf(`
14
+ `,Math.max(0,n-1))+1}u(de,"lineStart");function ot(e){let n=0;for(let t of e)t===`
15
+ `&&n++;return n}u(ot,"countNewlines");function W(e,n){let t=1;for(let r=0;r<Math.min(n,e.length);r++)e[r]===`
16
+ `&&t++;return t}u(W,"lineAtOffset");function ue(e,n){let t=e.findLastIndex(r=>r.afterLine!==void 0&&r.afterLine<=n);return t===-1?Math.max(0,e.length-1):t}u(ue,"typingFocusRow");var dt=240,Je=12,Qe=1600,st=600,at=75,ut=8,lt=40,ft=110,ct=7,gt=40,Ze=1500,ht=80,pt=24,mt=96,fe=20,bt=new Intl.Segmenter(void 0,{granularity:"grapheme"}),j=class{static{u(this,"TypingInterpolation")}observedText="";observedCharacters=[];targetText="";targetCharacters=[];visibleCount=0;visibleTextCache;arrivals=[];firstTargetAt;lastFrameAt;credit=0;started=!1;finished=!1;catchUpBy;observe(n,t){if(n===this.observedText)return;let r=this.incrementalCharacters(n,this.observedText,this.observedCharacters);n.startsWith(this.observedText)||(this.arrivals=[]);let o={at:t,length:r.length};this.arrivals.at(-1)?.at===t?this.arrivals[this.arrivals.length-1]=o:this.arrivals.push(o),this.observedText=n,this.observedCharacters=r,this.pruneArrivals(t)}setTarget(n,t){if(n===this.targetText)return!1;let r=this.incrementalCharacters(n,this.targetText,this.targetCharacters),i=Rt(this.targetCharacters,r),o=i<this.visibleCount;return o&&(this.visibleCount=i,this.credit=0),this.visibleTextCache!==void 0&&this.visibleTextCache.count>i&&(this.visibleTextCache=void 0),this.targetText=n,this.targetCharacters=r,this.firstTargetAt??=t,this.lastFrameAt??=t,r.length<=this.visibleCount?this.finished||(this.catchUpBy=void 0):this.catchUpBy??=t+Ze,o}finish(n=this.lastFrameAt??performance.now(),t=Ze){this.finished=!0,this.started=!0;let r=n+Math.max(0,t);this.catchUpBy=Math.min(this.catchUpBy??r,r)}advance(n){let t=this.lastFrameAt;if(this.lastFrameAt=n,t===void 0)return!1;let r=this.targetCharacters.length-this.visibleCount;if(r<=0)return this.credit=0,this.finished||(this.catchUpBy=void 0),!1;let i=this.estimatedRate(n),o=U(Math.round(i*at/1e3),ut,lt);if(!this.started){let b=n-(this.firstTargetAt??n);if(r<o&&b<ft)return!1;this.started=!0}let d=U(n-t,0,ht),a=(r-o)*ct,s=U(i+a,Math.max(Je,i*.35),Math.min(Qe,Math.max(360,i*2.5))),f=this.finished?Math.max(s,r*1e3/gt):s;this.credit+=f*d/1e3;let l=this.finished?mt:pt,c=Math.min(l,Math.floor(this.credit)),h=yt(r,n,t,this.catchUpBy),p=this.visibleCount===0?Math.min(l,h):h,g=Math.min(r,Math.max(c,p));return g===0?!1:(this.visibleCount+=g,this.credit=Math.max(0,this.credit-g),this.visibleCount===this.targetCharacters.length&&(this.finished||(this.catchUpBy=void 0)),this.visibleTextCache=void 0,!0)}incrementalCharacters(n,t,r){if(!n.startsWith(t))return le(n);let i=n.slice(t.length);if(i.length===0)return r;let o=r.at(-1);return o===void 0?le(i):[...r.slice(0,-1),...le(o+i)]}get visibleText(){if(this.visibleTextCache?.count===this.visibleCount)return this.visibleTextCache.value;let n=this.visibleTextCache,t=n!==void 0&&n.count<this.visibleCount?n.value+this.targetCharacters.slice(n.count,this.visibleCount).join(""):this.targetCharacters.slice(0,this.visibleCount).join("");return this.visibleTextCache={count:this.visibleCount,value:t},t}get hasVisibleText(){return this.visibleCount>0}get caughtUp(){return this.visibleCount===this.targetCharacters.length}estimatedRate(n){this.pruneArrivals(n);let t=this.arrivals[0],r=this.arrivals.at(-1);return t===void 0||r===void 0||r.at-t.at<20||r.length<=t.length?dt:U((r.length-t.length)*1e3/(r.at-t.at),Je,Qe)}pruneArrivals(n){let t=n-st;for(;this.arrivals.length>2&&w(this.arrivals[1]).at<t;)this.arrivals.shift()}};function le(e){return[...bt.segment(e)].map(({segment:n})=>n)}u(le,"graphemes");function Rt(e,n){let t=Math.min(e.length,n.length),r=0;for(;r<t&&e[r]===n[r];)r++;return r}u(Rt,"commonPrefixLength");function U(e,n,t){return Math.max(n,Math.min(t,e))}u(U,"clamp");function yt(e,n,t,r){if(r===void 0)return 0;let i=r-n;if(i<=0)return e;let o=Math.max(fe,n-t),d=Math.max(1,Math.ceil(i/o));return Math.ceil(e/d)}u(yt,"catchUpStep");var vt=[],en=120;function an(e,n,t=()=>!0,r="compact"){e.onMutationTool(i=>{e.addToolRenderer(Tt(e,i,n,t,r))})}u(an,"registerMutationRenderers");function Tt(e,n,t,r,i){let o=n.name;return{tool:o,fallback:!0,renderCall(d,a,s){let f=Mt(s.lastComponent,a,!1),l=kt(d),c=s.state;c.registration=n;let h=performance.now();c.panel=f,c.input=l,c.theme=a,c.invalidate=s.invalidate,c.cwd=s.cwd;let p=s.expanded?"full":i;c.presentation=i,f.setExpanded(p==="full"),f.setDiffsVisible(p!=="disabled"),c.expanded=s.expanded,f.setResourceLabelsVisible(q(l[n.source.field])===void 0),f.setBackground(s.isError?"toolErrorBg":"toolPendingBg");let g=Et(o,l),b=I(n,l,c.preview,a,c[x],s.expanded),m=q(l[n.source.field])!==void 0||c.preview?.kind==="completed",T=Y(o)===void 0?s.argsComplete:g!==void 0,y=m&&T,R=c.stableHeader?.expanded===s.expanded?c.stableHeader:{value:b,expanded:s.expanded};if(y&&(c.stableHeader=R),f.setHeader(y?R.value:b,B(n.name,l,s.expanded),s.expanded),!s.isPartial&&!s.argsComplete)return cn(c),f;let v=s.argsComplete,M=`${v?"complete":"typing"}:${JSON.stringify(l)}`;if(g!==void 0&&r()){let D=c.typing??=new j;if(c.releaseAnimationPressure??=t?.track(s.toolCallId,()=>{c.typing?.finish(performance.now(),300),G(c)}),D.observe(g,h),c.latestGenerated=g,v&&D.finish(h),c.key!==M&&g.length>0){c.key=M;let C={identity:St(o,l),input:l,generated:g,cwd:s.cwd};_t(c,C,h)||un(c,C,e,o)}G(c)}return c.preview?.kind==="completed"&&!f.hasResources()&&f.setPreviewResources(c.preview.resources),f},renderResult(d,a,s,f){let l=f.state;l.registration=n;let c=l.viewports;l.theme=s,l.cwd=f.cwd,l.invalidate=f.invalidate,l.expanded=a.expanded,l.presentation=i;let h=a.expanded?"full":i;l.panel?.setExpanded(h==="full"),l.panel?.setDiffsVisible(h!=="disabled"),l.panel?.setBackground(f.isError?"toolErrorBg":"toolSuccessBg"),ce(l);let p=P(d.details,c,!1);if(!f.isError&&p.length>0){let R=l.typing;return R!==void 0&&l.target!==void 0&&l.latestGenerated===l.target.generated&&!R.caughtUp?(R.finish(performance.now()),l.pendingResult={details:d.details,expanded:a.expanded,theme:s},G(l),new N("",0,0)):(fn(l,P(d.details,n.name==="write"?void 0:c),a.expanded,s),new N(n.name==="copy"&&typeof d.details.metadata?.targetUnavailable=="string"?s.fg("muted","No verified text selection. Read the destination before further edits."):"",0,0))}if(X(l),delete l.preview,delete l.viewports,l.panel?.setHeader(I(n,l.input??{},void 0,s,l[x],a.expanded),B(n.name,l.input??{},a.expanded),a.expanded),l.panel?.setPreviewResources([]),!f.isError&&d.details.metadata?.emptyTargets===!0)return new N(s.fg("muted",n.name==="copy"?"No changes: empty selection.":"No changes \xB7 empty target set"),0,0);let g=$t(d.details);if(g!==void 0){let R=typeof d.details.metadata?.targetUnavailable=="string"?" \xB7 no verified text selection; read destination before further edits":"";return new N([s.fg(g.color,g.text+R),...g.diffStatuses.map(v=>s.fg(v.tone??"muted",v.text))].join(`
17
+ `),0,0)}let b=d.content.filter(R=>R.type==="text").map(R=>R.text).join(`
18
+ `),m=n.name==="copy"?d.details.metadata?.copyRollback:void 0,T=n.name==="copy"&&d.details.metadata?.copyExecution==="uncertain",y=f.isError?T?"Copy failed \xB7 effects uncertain; read destination before retrying":m==="restored"?"Copy failed \xB7 changes rolled back":m==="failed"?"Copy failed \xB7 rollback failed; read destination before retrying":Ot(b,d.details):b;return new N(y.length===0?"":s.fg(f.isError?"error":"toolOutput",y),0,0)}}}u(Tt,"createRenderer");function Mt(e,n,t){let r=e instanceof _?e:new _(n,t);return r.setTheme(n),r}u(Mt,"panel");function _t(e,n,t){let r=e.target;if(r?.identity!==n.identity)return!1;let i=ae(r.resources,r.generated,n.generated);return i===void 0?!1:((e.previewRunning||e.queuedPreview!==void 0)&&ce(e),e.target={identity:n.identity,input:n.input,generated:n.generated,resources:i},e.typing?.setTarget(n.generated,t),!0)}u(_t,"advancePreviewTarget");function un(e,n,t,r){if(e.queuedPreview=n,e.previewRunning)return;let i=e.epoch??0;e.epoch=i,e.previewRunning=!0,Promise.resolve().then(()=>Ct(e,t,r,i)).finally(()=>{e.epoch===i&&(e.previewRunning=!1,e.queuedPreview!==void 0&&un(e,e.queuedPreview,t,r))})}u(un,"queuePreview");async function Ct(e,n,t,r){for(;e.epoch===r;){let i=e.queuedPreview;if(i===void 0)return;delete e.queuedPreview;let o=new AbortController;e.controller=o;try{let d=await n.previewMutation({tool:t,input:i.input,cwd:i.cwd,signal:o.signal});if(e.epoch!==r||o.signal.aborted)return;d.kind==="completed"?xt(e,i,d.resources,performance.now()):nn(e)||tn(e,d.reason)}catch(d){if(e.epoch!==r||o.signal.aborted)return;nn(e)||tn(e,d instanceof Error?d.message:String(d))}finally{e.controller===o&&delete e.controller}}}u(Ct,"runPreviewWorker");function nn(e){return e.queuedPreview!==void 0}u(nn,"hasQueuedPreview");function xt(e,n,t,r){let i=n,o=t,d=e.queuedPreview;if(d?.identity===n.identity){let f=ae(t,n.generated,d.generated);f!==void 0&&(i=d,o=f,delete e.queuedPreview)}e.target={identity:i.identity,input:i.input,generated:i.generated,resources:o};let a=e.typing,s=a?.setTarget(i.generated,r)??!1;G(e),(s||a?.hasVisibleText===!0)&&ln(e)&&ge(e)}u(xt,"acceptPreview");function tn(e,n){let t={kind:"failed",reason:n};e.preview=t,e.panel!==void 0&&e.theme!==void 0&&e.panel.setHeader(e.stableHeader?.value??I(e.registration,e.input??{},t,e.theme,e[x],e.expanded??!1),B(e.registration.name,e.input??{},e.expanded??!1),e.expanded??!1),ge(e)}u(tn,"showPreviewFailure");function G(e){e.timer!==void 0||e.panel===void 0||(e.timer=setInterval(()=>{let n=e.typing,t=!1;n?.advance(performance.now())===!0&&(t=ln(e)),e.pendingResult!==void 0&&n?.caughtUp===!0&&e.target?.generated===e.latestGenerated&&(t=At(e)||t),t&&ge(e)},fe),e.timer.unref())}u(G,"ensureTypingTimer");function ln(e){let n=e.target,t=e.typing,r=e.panel,i=e.theme;if(n===void 0||t===void 0||r===void 0||i===void 0||!t.hasVisibleText&&n.generated.length>0)return!1;let o=t.visibleText,a=(e.displayedResources===void 0||e.displayedText===void 0?void 0:Ye(n.resources,n.generated,e.displayedResources,e.displayedText,o))??se(e.displayedResources??[],Xe(n.resources,n.generated,o));e.displayedResources=a,e.displayedText=o;let s={kind:"completed",resources:a};return e.preview=s,e.viewports=we(a),r.setPreviewResources(a),r.setHeader(e.stableHeader?.value??I(e.registration,e.input??n.input,s,i,e[x],e.expanded??!1),B(e.registration.name,e.input??n.input,e.expanded??!1),e.expanded??!1),!0}u(ln,"updateTypingPanel");function At(e){let n=e.pendingResult;if(n===void 0)return!1;let t=P(n.details,void 0);return delete e.pendingResult,t.length===0?(X(e),!1):(fn(e,t,n.expanded,n.theme),!0)}u(At,"finishPendingResult");function fn(e,n,t,r){let i=se(e.displayedResources??[],n),o={kind:"completed",resources:i};e.preview=o,e.panel?.setHeader(e.stableHeader?.value??I(e.registration,e.input??{},o,r,e[x],t),B(e.registration.name,e.input??{},t),t),e.panel?.setResultResources(i);let d=t?"full":e.presentation??"compact";e.panel?.setExpanded(d==="full"),e.panel?.setDiffsVisible(d!=="disabled"),X(e)}u(fn,"applyResultResources");function ce(e){e.epoch=(e.epoch??0)+1,e.controller?.abort(),delete e.controller,delete e.queuedPreview,e.previewRunning=!1}u(ce,"cancelPreviewWorker");function X(e){e.timer!==void 0&&(clearInterval(e.timer),delete e.timer),delete e.stableHeader,delete e.typing,e.releaseAnimationPressure?.(),delete e.releaseAnimationPressure,delete e.target,delete e.latestGenerated,delete e.displayedResources,delete e.displayedText,delete e.pendingResult,delete e.key}u(X,"clearTypingRuntime");function cn(e){ce(e),X(e)}u(cn,"disposeRenderState");function ge(e){e.invalidate===void 0||Pt(e.invalidate)||cn(e)}u(ge,"invalidateState");function Pt(e){try{return e(),!0}catch{return!1}}u(Pt,"invalidateActiveRenderer");function St(e,n){let t=Y(e);return JSON.stringify(Object.fromEntries(Object.entries(n).filter(([r])=>r!==t)))}u(St,"previewIdentity");function Y(e){return e==="write"?"content":e==="insert"||e==="replace"?"text":void 0}u(Y,"generatedField");function Et(e,n){let t=Y(e),r=t===void 0?void 0:n[t];return typeof r=="string"?r:void 0}u(Et,"generatedText");function kt(e){return typeof e=="object"&&e!==null?e:{}}u(kt,"asInput");function B(e,n,t){if(!t)return vt;let r=Y(e);return Object.entries(n).map(([i,o])=>{let d=["path","file","target"].includes(i)&&o!==null&&typeof o=="object"?Array.isArray(o)?`${o.length} returned targets`:"result scope":typeof o=="string"?o:JSON.stringify(o),a=typeof d=="string"?d:String(o);return{label:i,value:a.length>en?`${a.slice(0,en)}\u2026 (${String(a.length)} chars${i===r?"; full value shown in diff":""})`:a}})}u(B,"mutationCallDetails");function rn(e){return typeof e=="string"&&e.startsWith("RESULT#")?"result scope":q(e)??(e!==null&&typeof e=="object"?"result scope":void 0)}u(rn,"sourceLabel");function I(e,n,t,r,i,o){let d=e.source,a=rn(n[d.field]),s=t?.kind==="completed"?t.resources:[],f=a??(s.length===1?w(s[0]).path:s.length>1?`${String(s.length)} files`:""),l=a===void 0&&s.length===1?w(s[0]).link:dn(t,a),c=(d.targets??[]).map(({field:p})=>({field:p,path:rn(n[p])})).filter(p=>p.path!==void 0&&(p.path==="result scope"||p.path!==a)),h=`${r.fg("toolTitle",r.bold(e.name))} ${sn(f,l,r)}${on(e,d.field,n,i,r,o)}`;for(let p of c)h+=` ${r.fg("muted","->")} ${sn(p.path,dn(t,p.path),r)}`,h+=on(e,p.field,n,i,r,o);return h}u(I,"renderHeader");function on(e,n,t,r,i,o){let d=(e.anchors??[]).filter(f=>f.sourceField===n),a=n===e.source.field&&e.pair!==void 0?e.pair:d.slice(0,2).map(({field:f})=>f),s=u(f=>{if(f===void 0)return;let l=q(t[f]);if(l!==void 0){let h=K(l),p=/^(?:\d+#[0-9A-F]+|CHANGE#[0-9A-F]+|SEARCH#|scope-(?:begin|end)-|begin$|end$)/.test(l);return o||p||h.length<=100?h:`${h.slice(0,60)}\u2026${h.slice(-30)} (${l.length} chars)`}let c=r?.[f];return c?.kind==="resolved"?K(o?c.full:c.compact):void 0},"renderField");return Dt(s(a.at(0)),s(a.at(1)),i)}u(on,"renderAnchorRange");function dn(e,n){return e?.kind==="completed"?e.resources.find(t=>t.path===n)?.link:void 0}u(dn,"resourceLink");function sn(e,n,t){if(e.length===0)return t.fg("muted","...");let r=t.underline(t.fg("accent",e));return n===void 0||n.includes("\x07")||n.includes("\x1B")?r:`\x1B]8;;${n}\x07${r}\x1B]8;;\x07`}u(sn,"renderPath");function Dt(e,n,t){if(e===void 0)return"";let r=n===void 0?e:Lt(e,n);return`${t.fg("dim"," \xB7 ")}${t.fg("warning",r)}`}u(Dt,"range");function Lt(e,n){let t=/^line (\d+)$/u.exec(e)?.[1],r=/^line (\d+)$/u.exec(n)?.[1];return t!==void 0&&r!==void 0?`lines ${t}\u2013${r}`:`${e}\u2013${n}`}u(Lt,"semanticRange");function $t(e){if(e===null||typeof e!="object"||!("metadata"in e))return;let n=e.metadata;if(n===null||typeof n!="object"||!("semanticAction"in n))return;let t=n.semanticAction;if(t===null||typeof t!="object"||!("kind"in t)||t.kind!=="file-operation"&&t.kind!=="direct-mutation"||!("ok"in t)||typeof t.ok!="boolean")return;let r="effect"in t&&(t.effect==="applied"||t.effect==="not-applied"||t.effect==="unknown")?t.effect:t.ok?"applied":"not-applied",i;if("postProcessingError"in t)i="post-processing failed";else if(!t.ok){let d="error"in t?t.error:void 0,a=d!==null&&typeof d=="object"&&"code"in d&&typeof d.code=="string"?d.code:void 0;i=a===void 0?"file operation failed":gn(a)}let o=r==="unknown"?`Effects unknown \xB7 ${"operation"in t?String(t.operation):"file operation"} failed; read ${"operation"in t&&t.operation==="delete"?"the source":"source and destination"} before retrying`:r==="applied"?"\u2713 Applied":"\u2717 Not applied";return{text:i===void 0?o:`${o} \xB7 ${i}`,diffStatuses:Re(t)?t.diffStatuses:[],color:r==="not-applied"?"error":r==="unknown"||i!==void 0?"warning":"success"}}u($t,"wholeFileOperationSummary");function gn(e){switch(e){case"WRITE_FAILED":return"resource write failed";case"POST_WRITE_FAILED":return"post-write processing failed";case"APPLY_UNDO_OWNER_CHANGED":return"resource owner changed";case"APPLY_UNDO_CLEANUP_FAILED":return"journal cleanup failed";case"UNSUPPORTED_SOURCE":return"no file provider for this resource";case"UNKNOWN_TARGET":return"SSH target is not configured";case"CONNECTION_LOST":return"connection lost";case"CONFLICT":return"file changed";case"EEXIST":return"target already exists";case"ENOENT":return"file was not found";case"EACCES":case"EPERM":return"permission denied";case"INVALID_FILE_TYPE":return"a regular file is required";case"SAME_FILE":return"source and target are the same file";case"TIMEOUT":return"operation timed out";case"CANCELLED":return"operation was canceled";default:return"file operation failed"}}u(gn,"wholeFileFailureCause");function Ot(e,n){let t=new Set(n?.results?.flatMap(r=>(r.data.errors??[]).map(i=>gn(i.code??""))));return[Ft(e,n),...[...t].map(r=>`Reason: ${r}`),...n?.effect==="unknown"?["Read the affected resource before retrying."]:[]].join(`
19
+ `)}u(Ot,"userFacingFailure");function Ft(e,n){let t=n?.results?.flatMap(r=>r.data.rollback?[r.data.rollback]:[])??[];if(t.length>0){let r=[...new Set(t.flatMap(o=>o.failedSources))],i=[...new Set(t.flatMap(o=>o.restoredSources))];return r.length===0&&n?.effect==="unknown"?["Effects unknown \xB7 edit failed",...i.length>0?[`Rolled back: ${i.join(", ")}`]:[]].join(`
20
+ `):[r.length===0?"Rolled back \xB7 write failed":"State unknown \xB7 rollback failed",...r.length>0?[`Unknown: ${r.join(", ")}`]:[],...i.length>0?[`Rolled back: ${i.join(", ")}`]:[]].join(`
21
+ `)}return n?.effect==="unknown"?"Effects unknown \xB7 edit failed":n?.effect==="applied"?"Saved \xB7 post-write step failed":n?.metadata?.rollback==="restored"?"Rolled back \xB7 edit failed":/\banchor\b[\s\S]*\bis ambiguous\./iu.test(e)?"Not changed \xB7 selection is ambiguous":/\banchor\b[\s\S]*\bis stale\./iu.test(e)?"Not changed \xB7 selection is out of date":/\banchor\b[\s\S]*\bwas not found\./iu.test(e)?"Not changed \xB7 selected text was not found":/\banchor\b[\s\S]*\bis invalid\./iu.test(e)?"Not changed \xB7 selection is invalid":"Not changed \xB7 edit failed"}u(Ft,"mutationFailureSummary");function q(e){return typeof e=="string"&&e.length>0?e:void 0}u(q,"stringValue");function Bt(e){return e==="full"||e==="disabled"?e:"compact"}u(Bt,"parsePresentation");async function It(e,n){let t=Bt(n?.preferences["ui.diffs"]),r=je(e),i=e.getFlag("pi-agent-ide-no-animations")!==!0,o=u(()=>{i=e.getFlag("pi-agent-ide-no-animations")!==!0},"refreshAnimations");e.on("session_start",o),e.on("before_agent_start",o),await be(e,{protocol:pe,apiVersion:me,id:"text-editor-renderer",setup(a){a.addToolRenderer({tool:"diff",renderResult(f,l,c,h){let p=f.details;if(h.isError||p?.results===void 0)return new Nt(f.content.filter(m=>m.type==="text").map(m=>m.text).join(`
22
+ `),0,0);let g=new _(c);g.setBackground("toolSuccessBg");let b=l.expanded?"full":t;return g.setExpanded(b==="full"),g.setDiffsVisible(b!=="disabled"),g.setResourceLabelsVisible(!0),g.setResultResources(P(p,void 0)),g}});let s=new Set;a.onMutationTool(({name:f})=>s.add(f)),an(a,r,()=>i,t),e.on("tool_result",f=>{if(!s.has(f.toolName)||typeof f.details!="object"||f.details===null)return;let l=f.details;if(Array.isArray(l.results))return{details:ve(l)}})}})}u(It,"registerTextEditorRenderer");export{It as default};
package/dist/entry-81.js CHANGED
@@ -1 +1,2 @@
1
- import{a,b,c,d,e,f,g,h}from"./chunk-XH5WN5XA.js";import"./chunk-PS2B6THP.js";import"./chunk-EI7MMDWY.js";export{b as TOOL_CALL_INTERCEPTION_ANCHOR_RENDER_PATCH,a as TOOL_CALL_INTERCEPTION_DETAILS_KEY,f as ToolCallInterceptionRenderStore,c as getToolCallInterception,h as isToolCallAnnotation,e as withBlockedToolResult,d as withToolCallInterceptionDetails,g as withToolCallInterceptionRendering};
1
+ import{a as I}from"./chunk-2RTCSZB3.js";import{b as _}from"./chunk-YHADTHQM.js";import{a as x}from"./chunk-HFJGCYFO.js";import{a as v}from"./chunk-MXLSGMRZ.js";import"./chunk-XH5WN5XA.js";import"./chunk-PRLIHLCS.js";import{a as S}from"./chunk-M4TVRCMZ.js";import{c as O,d as b}from"./chunk-TGC2ZACO.js";import"./chunk-PS2B6THP.js";import{a as C}from"./chunk-BU7IZLKB.js";import{a as k,b as w}from"./chunk-S5PL5DFQ.js";import"./chunk-DXONCYWF.js";import"./chunk-ZPT5D4VP.js";import{a as M}from"./chunk-ZC65Z3CK.js";import{a as h}from"./chunk-EI7MMDWY.js";var P="\0",$="";async function H(t){let i,n={protocol:k,apiVersion:w,id:"text-editor-stale-anchor",setup(r){i=r}},d={protocol:O,apiVersion:b,id:"text-editor-stale-anchor",setup(r){let a=V(t,r,()=>{if(i===void 0)throw new Error("pi-agent-read is unavailable");return i});x(t,a.handler),r.onMutationTool(a.add)}};await Promise.all([C(t,n),S(t,d)])}h(H,"registerTextEditorStaleAnchor");function V(t,i,n){let d=new Map,r=[],a=new Map,l=new Map,c=new Map,g={name:"text-editor-stale-anchor-inspection",blockExecution:!0,toolNames:r,async intercept(e){let s=d.get(e.toolCall.name);if(s===void 0)return;let p=e.partialArgs??e.args,o=j(p,e,a,s.source.field,s.source.inherited?_(t)?.source:void 0);if(o===void 0)return;let m=await B(i,n(),e,s,p,o,l,c);if(m!==void 0)return m;let A=s.pair?.every(u=>{let R=s.anchors?.find(T=>T.field===u);return R!==void 0&&I(R,p[u])})===!0?new Set(s.pair):new Set;for(let u of s.anchors??[]){if(A.has(u.field))continue;let R=p[u.field];if(!I(u,R))continue;let T=p[u.sourceField],y=typeof T=="string"?T:o,f=await D(i,n(),e,u.field,y,[R],[u.kinds],l,c);if(f!==void 0)return f}},onContentEnd(e){l.delete(e),c.delete(e)},onAbort(e){l.delete(e),c.delete(e),a.delete(e)},onAgentEnd(){l.clear(),c.clear(),a.clear()}};return{handler:g,add(e){(e.anchors?.length??0)>0&&(d.set(e.name,e),r.push(e.name),x(t,g))}}}h(V,"createHandler");function j(t,i,n,d,r){let a=t[d];if(typeof a=="string")return i.contentIndex!==void 0&&n.set(i.contentIndex,a),a;if(i.contentIndex!==void 0)for(let l=i.contentIndex-1;l>=0;l-=1){let c=n.get(l);if(c!==void 0)return t[d]=c,c}return r!==void 0&&(t[d]=r),r}h(j,"resolveSource");async function B(t,i,n,d,r,a,l,c){if(d.pair===void 0)return;let[g,e]=d.pair,s=r[g],p=r[e];if(typeof s!="string"||typeof p!="string")return;let o=d.anchors?.find(({field:A})=>A===g),m=d.anchors?.find(({field:A})=>A===e);if(!(o===void 0||m===void 0)&&!(!I(o,s)||!I(m,p)))return D(t,i,n,e,a,[s,p],[o.kinds,m.kinds],l,c)}h(B,"inspectAnchorPair");async function D(t,i,n,d,r,a,l,c,g){let e=n.contentIndex??-1,s=`${r}${P}${a.join(P)}${P}${l.map(f=>f.join($)).join(P)}`,p=g.get(e)?.get(s);if(p!==void 0)return p;let o=c.get(e)?.get(s);if(o===void 0){let f=await t.inspectTextAnchors({source:r,anchors:a,kinds:l,cwd:n.cwd,...n.signal!==void 0&&{signal:n.signal}}),E=c.get(e)??new Map;E.set(s,f),c.set(e,E),o=f}if(o.kind==="valid")return;if(o.kind==="failed")return L(n.toolCall.name,r,o.reason);if(o.rejectionCode!=="stale")return;let m=o.anchorIndex,u=(o.contextRange===void 0?void 0:await i.read({path:r,views:["anchors"],...o.contextRange},{cwd:n.cwd,...n.signal!==void 0&&{signal:n.signal}}))?.content.filter(f=>f.type==="text").map(f=>f.text).join(`
2
+ `),R={guardId:"stale-anchor",effect:"not-applied",toolName:n.toolCall.name,field:d,path:r,anchor:M(a[m]),...!(u===void 0||u.length===0)&&{context:u}},T=N(R,o.reason),y=g.get(e)??new Map;return y.set(s,T),g.set(e,y),T}h(D,"inspectAnchors");function L(t,i,n){return{annotation:{kind:"blocked",reason:n},message:{customType:"text-editor-resolver-block",content:`[SYSTEM] ${t} blocked: ${n}`,display:!1,details:{guardId:"resolver",effect:"not-applied",toolName:t,source:i,reason:n}}}}h(L,"makeResolverBlockResult");function N(t,i){return{annotation:{kind:"stale-anchor"},message:{customType:"text-editor-stale-anchor-block",content:v(t,i),display:!1,details:t}}}h(N,"makeBlockResult");export{H as default};
package/dist/entry-82.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i}from"./chunk-PS2B6THP.js";import"./chunk-EI7MMDWY.js";export{a as ResultPanel,d as ToolCallHeader,h as preserveEnclosingBackground,g as renderToolCallDetails,f as renderToolCallHeader,i as singleLine,b as sourceRows,c as toolBackgroundAnsi,e as toolCallHeader};
1
+ import{a,b,c,d,e,f,g,h}from"./chunk-XH5WN5XA.js";import"./chunk-PS2B6THP.js";import"./chunk-EI7MMDWY.js";export{b as TOOL_CALL_INTERCEPTION_ANCHOR_RENDER_PATCH,a as TOOL_CALL_INTERCEPTION_DETAILS_KEY,f as ToolCallInterceptionRenderStore,c as getToolCallInterception,h as isToolCallAnnotation,e as withBlockedToolResult,d as withToolCallInterceptionDetails,g as withToolCallInterceptionRendering};
package/dist/entry-83.js CHANGED
@@ -1 +1 @@
1
- import{a,b}from"./chunk-Z3PGADVA.js";import"./chunk-VDP5CQHM.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-NNCZYO4Q.js";import"./chunk-IICJXZBU.js";import"./chunk-BU7IZLKB.js";import"./chunk-S5PL5DFQ.js";import"./chunk-N7LMRL64.js";import"./chunk-RAZP42IQ.js";import"./chunk-BIG45IPN.js";import"./chunk-SSWUUBIR.js";import"./chunk-PS2B6THP.js";import"./chunk-R5XJSEOE.js";import"./chunk-ZPT5D4VP.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as default,b as registerWebWithOwner};
1
+ import{a,b,c,d,e,f,g,h,i}from"./chunk-PS2B6THP.js";import"./chunk-EI7MMDWY.js";export{a as ResultPanel,d as ToolCallHeader,h as preserveEnclosingBackground,g as renderToolCallDetails,f as renderToolCallHeader,i as singleLine,b as sourceRows,c as toolBackgroundAnsi,e as toolCallHeader};
package/dist/entry-84.js CHANGED
@@ -1,3 +1 @@
1
- import{G as c}from"./chunk-R5XJSEOE.js";import{a as r}from"./chunk-EI7MMDWY.js";import{parseHTML as g}from"linkedom";async function d(t,n,e=p){try{let o=await e(t,n);return{content:o.content.trim(),title:o.title.trim(),usedFallback:!1}}catch{return{...b(t,n),usedFallback:!0}}}r(d,"extractReadableHtml");async function p(t,n){let e=u(t,n),{Defuddle:o}=await import("defuddle/node"),i=await o(e,n,{markdown:!0,useAsync:!1});return{content:i.content,title:i.title}}r(p,"extractWithDefuddle");function b(t,n){let e=u(t,n);for(let a of e.querySelectorAll("script, style, nav, footer, header, aside, noscript, template"))a.remove();let o=e.querySelector("article, main")??e.body??e.documentElement,i=s(o?.textContent??""),l=s(e.querySelector("title")?.textContent??"");return{content:i,title:l}}r(b,"extractPlainText");function u(t,n){let e=g(t);try{Object.defineProperty(e.document,"location",{value:new URL(n),configurable:!0})}catch{}return e.document}r(u,"parseDocument");function s(t){return t.replace(/\s+/gu," ").trim()}r(s,"normalizeWhitespace");var x=new Set(["application/xhtml+xml","text/html"]),w=/^\u{FEFF}?\s*(?:<!doctype\s+html\b|<(?:article|body|head|html)\b)/iu;function f(){return{id:"html",description:"Web page URLs return readable page content.",async tryConvert(t,n){if(!E(t.bytes,t.mediaType))return{kind:"not-handled"};let e=m(n.signal);if(e!==void 0)return{kind:"failed",error:e};let o;try{o=new TextDecoder("utf8",{fatal:!0}).decode(t.bytes)}catch(y){return{kind:"failed",error:new TypeError(`${t.source} is not valid UTF-8 HTML`,{cause:y})}}let i=await d(o,t.source),l=m(n.signal);return l!==void 0?{kind:"failed",error:l}:{kind:"converted",content:[{type:"text",text:i.title.length===0?i.content:i.content.length===0?`# ${i.title}`:`# ${i.title}
2
-
3
- ${i.content}`}]}}}}r(f,"createHtmlContentConverter");function E(t,n){if(n!==void 0){let o=n.split(";",1)[0]?.trim().toLowerCase()??"";if(x.has(o))return!0}let e=new TextDecoder("utf8").decode(t.subarray(0,1024));return w.test(e)}r(E,"isHtmlInput");function m(t){if(t?.aborted===!0)return t.reason instanceof Error?t.reason:C()}r(m,"cancellationError");function C(){let t=new Error("The operation was aborted");return t.name="AbortError",t}r(C,"abortError");var h={target:{provider:"web",capability:"read"},converter:f(),priority:200};async function H(t){await c(t,h)}r(H,"registerWebHtml");export{H as default};
1
+ import{a,b}from"./chunk-AIT3YWR5.js";import"./chunk-VDP5CQHM.js";import"./chunk-47SPPIXK.js";import"./chunk-VAXLSPPU.js";import"./chunk-OI3HBIPK.js";import"./chunk-YTYLS2UM.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-NNCZYO4Q.js";import"./chunk-IICJXZBU.js";import"./chunk-PS2B6THP.js";import"./chunk-BU7IZLKB.js";import"./chunk-S5PL5DFQ.js";import"./chunk-DXONCYWF.js";import"./chunk-ZPT5D4VP.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as default,b as registerWebWithOwner};
package/dist/entry-85.js CHANGED
@@ -1 +1,3 @@
1
- import{a as r}from"./chunk-QIJMV2P2.js";import{G as e}from"./chunk-R5XJSEOE.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"web",capability:"read"},converter:r(),priority:100};async function i(o){await e(o,n)}t(i,"registerWebImage");export{i as default};
1
+ import{G as c}from"./chunk-DXONCYWF.js";import{a as r}from"./chunk-EI7MMDWY.js";import{parseHTML as g}from"linkedom";async function d(t,n,e=p){try{let o=await e(t,n);return{content:o.content.trim(),title:o.title.trim(),usedFallback:!1}}catch{return{...b(t,n),usedFallback:!0}}}r(d,"extractReadableHtml");async function p(t,n){let e=u(t,n),{Defuddle:o}=await import("defuddle/node"),i=await o(e,n,{markdown:!0,useAsync:!1});return{content:i.content,title:i.title}}r(p,"extractWithDefuddle");function b(t,n){let e=u(t,n);for(let a of e.querySelectorAll("script, style, nav, footer, header, aside, noscript, template"))a.remove();let o=e.querySelector("article, main")??e.body??e.documentElement,i=s(o?.textContent??""),l=s(e.querySelector("title")?.textContent??"");return{content:i,title:l}}r(b,"extractPlainText");function u(t,n){let e=g(t);try{Object.defineProperty(e.document,"location",{value:new URL(n),configurable:!0})}catch{}return e.document}r(u,"parseDocument");function s(t){return t.replace(/\s+/gu," ").trim()}r(s,"normalizeWhitespace");var x=new Set(["application/xhtml+xml","text/html"]),w=/^\u{FEFF}?\s*(?:<!doctype\s+html\b|<(?:article|body|head|html)\b)/iu;function f(){return{id:"html",description:"Web page URLs return readable page content.",async tryConvert(t,n){if(!E(t.bytes,t.mediaType))return{kind:"not-handled"};let e=m(n.signal);if(e!==void 0)return{kind:"failed",error:e};let o;try{o=new TextDecoder("utf8",{fatal:!0}).decode(t.bytes)}catch(y){return{kind:"failed",error:new TypeError(`${t.source} is not valid UTF-8 HTML`,{cause:y})}}let i=await d(o,t.source),l=m(n.signal);return l!==void 0?{kind:"failed",error:l}:{kind:"converted",content:[{type:"text",text:i.title.length===0?i.content:i.content.length===0?`# ${i.title}`:`# ${i.title}
2
+
3
+ ${i.content}`}]}}}}r(f,"createHtmlContentConverter");function E(t,n){if(n!==void 0){let o=n.split(";",1)[0]?.trim().toLowerCase()??"";if(x.has(o))return!0}let e=new TextDecoder("utf8").decode(t.subarray(0,1024));return w.test(e)}r(E,"isHtmlInput");function m(t){if(t?.aborted===!0)return t.reason instanceof Error?t.reason:C()}r(m,"cancellationError");function C(){let t=new Error("The operation was aborted");return t.name="AbortError",t}r(C,"abortError");var h={target:{provider:"web",capability:"read"},converter:f(),priority:200};async function H(t){await c(t,h)}r(H,"registerWebHtml");export{H as default};
package/dist/entry-86.js CHANGED
@@ -1 +1 @@
1
- import{a as r}from"./chunk-BHSO2MDK.js";import{G as e}from"./chunk-R5XJSEOE.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"web",capability:"read"},converter:r(),priority:200};async function i(o){await e(o,n)}t(i,"registerWebPdf");export{i as default};
1
+ import{a as r}from"./chunk-QIJMV2P2.js";import{G as e}from"./chunk-DXONCYWF.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"web",capability:"read"},converter:r(),priority:100};async function i(o){await e(o,n)}t(i,"registerWebImage");export{i as default};
package/dist/entry-87.js CHANGED
@@ -1 +1 @@
1
- import{G as r}from"./chunk-R5XJSEOE.js";import{p as e}from"./chunk-ZPT5D4VP.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"web",capability:"read"},converter:e(),priority:300};async function i(o){await r(o,n)}t(i,"registerWebText");export{i as default};
1
+ import{a as r}from"./chunk-BHSO2MDK.js";import{G as e}from"./chunk-DXONCYWF.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"web",capability:"read"},converter:r(),priority:200};async function i(o){await e(o,n)}t(i,"registerWebPdf");export{i as default};
@@ -0,0 +1 @@
1
+ import{G as r}from"./chunk-DXONCYWF.js";import{p as e}from"./chunk-ZPT5D4VP.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"web",capability:"read"},converter:e(),priority:300};async function i(o){await r(o,n)}t(i,"registerWebText");export{i as default};
@@ -1,43 +1,72 @@
1
- import{a as j,b as $,c as F,d as Z,e as ee,f as B}from"./chunk-W7CASEO3.js";import{f as q}from"./chunk-IM24DB3K.js";import{a as te}from"./chunk-YGGKGZO2.js";import"./chunk-QUYXINGZ.js";import"./chunk-GW6NZQTQ.js";import{a as Y}from"./chunk-BU7IZLKB.js";import{a as V,b as X}from"./chunk-S5PL5DFQ.js";import{K as Q,d as K}from"./chunk-R5XJSEOE.js";import"./chunk-ZC65Z3CK.js";import{a as f}from"./chunk-EI7MMDWY.js";var G={"ide.core":["IDE services","Shared services used by language, formatting and diagnostic modules."],"ide.tips":["Getting started tips","Show contextual guidance while setting up a project."],"ide.documentation":["Progressive agent documentation","Expose packaged guides and attach them on first relevant tool use."],"ide.doctor":["Setup doctor","Check external tools and help configure project support."],"ide.languages":["Language setup","Discover languages and their recommended toolchains."],"ide.processes":["Agent IDE processes","Show active terminal and debugger sessions in one shared process surface."],"ide.vision":["Agent vision","Inspect process metadata and capture supported windows and web pages as images."],"ide.debugger":["Debugger sessions","Debug local programs through addressable DAP sessions and anchored breakpoints."],"ide.terminal":["Terminal sessions","Run and manage local interactive and background terminal processes."],"read.core":["Read tools","Read sources through the configured readers and views."],"read.filesystem":["Local files","Resolve files and folders from the local filesystem."],"read.ssh":["SSH files","Read and edit configured SSH file sources through existing tools."],"read.filesystem.jq":["JSON queries","Query local JSON files through jq read views."],"read.filesystem.image":["Local images","Read local images as visual content."],"read.filesystem.pdf":["Local PDFs","Extract readable content from local PDF documents."],"read.filesystem.text":["Local text","Read local text files with their source coordinates."],"read.web":["Web sources","Read remote sources over HTTP and HTTPS."],"read.web.html":["Web pages","Extract readable content from HTML pages."],"read.web.image":["Web images","Read remote images as visual content."],"read.web.pdf":["Web PDFs","Extract text from remote PDF documents."],"read.web.text":["Web text","Read remote plain-text sources."],"search.core":["Search tools","Run searches through the configured search providers."],"search.text":["Text search","Find text and files and register reusable search selections."],"editor.core":["Editing tools","Make guarded text and whole-file changes, directly or through native Codemode."],"editor.renderer":["Edit previews","Display changes in the shared colored diff panels."],"editor.anchor.constant":["File boundary selectors","Use begin and end to select file boundaries."],"editor.anchor.line-hash":["Checked line selectors","Select lines with hashes that detect stale content."],"editor.anchor.exact":["Exact text selectors","Locate edit ranges using unique source text."],"editor.stale-anchor":["Stale selection recovery","Provide recovery guidance when an edit selection is outdated."],"ide.ast":["Structural code support","Read code outlines and search or edit exact syntax-tree nodes."],"ide.formatter":["Code formatting","Run configured formatters after edits."],"ide.lint":["Lint checks","Run configured linters and collect their findings."],"ide.changes":["Git changes","Inspect and manage uncommitted changes and undo history."],"ide.lsp":["Language servers","Resolve symbols, rename references and collect language-server diagnostics."],"ide.diagnostics":["Diagnostic views","Show diagnostic findings through read views and sources."]};var M=[A("ide.core",()=>import("./chunk-3ZGDMTMD.js")),A("ide.tips",()=>import("./chunk-BMOJTJJJ.js")),A("ide.doctor",()=>import("./chunk-CSXHCSTH.js")),A("ide.languages",()=>import("./entry-36.js"),["ide.doctor"]),A("read.core",()=>import("./entry-46.js")),A("ide.documentation",()=>import("./chunk-NRZO5KJT.js"),["read.core"]),A("read.filesystem",()=>import("./entry-26.js"),["read.core","editor.core"]),A("read.ssh",()=>import("./chunk-75SWXD2Z.js"),["read.filesystem"]),A("read.filesystem.jq",()=>import("./entry-28.js"),["read.filesystem","ide.documentation","ide.doctor"]),A("read.filesystem.image",()=>import("./entry-27.js"),["read.filesystem"]),A("read.filesystem.pdf",()=>import("./entry-29.js"),["read.filesystem"]),A("read.filesystem.text",()=>import("./entry-30.js"),["read.filesystem"]),A("read.web",()=>import("./chunk-O36UC74T.js"),["read.core"]),A("read.web.html",()=>import("./entry-84.js"),["read.web"]),A("read.web.image",()=>import("./entry-85.js"),["read.web"]),A("read.web.pdf",()=>import("./entry-86.js"),["read.web"]),A("read.web.text",()=>import("./entry-87.js"),["read.web"]),A("search.core",()=>import("./entry-51.js")),A("search.text",()=>import("./entry-52.js"),["search.core"]),A("editor.renderer",()=>import("./entry-79.js"),["editor.core"]),A("editor.core",()=>import("./entry-78.js")),A("editor.anchor.constant",()=>import("./entry-57.js"),["read.core","editor.core"]),A("editor.anchor.line-hash",()=>import("./entry-61.js"),["read.core","editor.core"]),A("editor.anchor.exact",()=>import("./entry-59.js"),["editor.core"]),A("editor.stale-anchor",()=>import("./entry-80.js"),["editor.core"]),A("ide.ast",()=>import("./entry-32.js"),["ide.core","read.core","search.core","editor.core"]),A("ide.formatter",()=>import("./chunk-MOJ5RR35.js"),["ide.core"]),A("ide.lint",()=>import("./chunk-CPZJPGLG.js"),["ide.core"]),A("ide.changes",()=>import("./chunk-UBH6X3D3.js"),["ide.core","read.core","editor.core"]),A("ide.lsp",()=>import("./chunk-SBNR4WZF.js"),["ide.core","read.core","search.core"]),A("ide.processes",()=>import("./chunk-OM4LYD3S.js")),A("ide.vision",()=>import("./chunk-PNP2KNGP.js"),["ide.processes","read.core","search.core"]),A("ide.debugger",()=>import("./chunk-UUJJRXHG.js"),["ide.processes","read.core","editor.core"]),A("ide.terminal",()=>import("./chunk-OLI3JPHJ.js"),["ide.processes","read.core","search.core","editor.core","editor.anchor.constant"]),A("ide.diagnostics",()=>import("./chunk-4XPUN4QN.js"),["ide.core","read.core"])];function A(e,l,p=[],c=!0){return{id:e,name:G[e][0],description:G[e][1],dependencies:p,async register(r,m){await(await l()).default(r,m)},...c?{}:{defaultEnabled:!1}}}f(A,"builtin");function L(e,l,p){return{kind:"choice",id:e,name:l,description:p,default:"compact",group:"ui",values:[{value:"full",label:"Full"},{value:"compact",label:"Compact"},{value:"disabled",label:"Disabled"}]}}f(L,"presentationPreference");var ne=[L("ui.diffs","Diffs","Choose how mutation and comparison diffs are displayed."),L("ui.read","Read","Choose how Read calls and results are displayed."),L("ui.search","Search","Choose how Search calls and results are displayed."),L("ui.terminal","Terminal","Choose how shell commands and terminal output are displayed."),{kind:"choice",id:"processes.activity",name:"Active Agent IDE processes",description:"Choose detailed process cards, a compact active count, or no persistent Agent IDE process UI.",default:"detailed",group:"ui",values:[{value:"detailed",label:"Detailed cards"},{value:"compact",label:"Compact count"},{value:"off",label:"Off"}]},{kind:"text",id:"vision.sequenceDurationSeconds",name:"Vision sequence duration",description:"Default sequence duration in seconds. Requests may override it, up to 10 seconds.",default:"2",group:"features"},{kind:"text",id:"vision.sequenceIntervalSeconds",name:"Vision sequence interval",description:"Default seconds between sequence frames. A sequence may contain at most 20 frames.",default:"0.5",group:"features"},{kind:"text",id:"vision.imageScale",name:"Vision image scale",description:"Default image downscale from greater than 0 through 1.",default:"0.5",group:"features"},{kind:"text",id:"vision.allowedExecutables",name:"Vision allowed executables",description:"Comma-separated executable file names that may be captured without arbitrary-window access.",default:"",group:"features",placeholder:"Unity.exe,UnrealEditor.exe"}];function U(e,l,p=[]){let c=new Map;for(let u of e){if(c.has(u.id))throw new Error(`Duplicate Pi Agent IDE extension ID: ${u.id}`);c.set(u.id,u)}for(let u of e)for(let w of u.dependencies)if(!c.has(w))throw new Error(`Pi Agent IDE extension ${u.id} has unknown dependency ${w}`);let r=new Set;for(let u of l)c.has(u)&&r.add(u);for(let u of p)if(!c.has(u))throw new Error(`Unknown Pi Agent IDE extension ID in enabled: ${u}`);let m=Ae(c,p,r),h=new Set;for(let u of e)(u.defaultEnabled===!1&&!m.has(u.id)||r.has(u.id))&&h.add(u.id);let T=!0;for(;T;){T=!1;for(let u of e)h.has(u.id)||u.dependencies.every(w=>!h.has(w))||(h.add(u.id),T=!0)}return{enabled:e.filter(u=>!h.has(u.id)),disabled:h}}f(U,"selectBuiltinExtensions");function Ae(e,l,p){let c=new Set,r=[...l];for(;r.length>0;){let m=r.pop();if(!(c.has(m)||p.has(m))){c.add(m);for(let h of e.get(m)?.dependencies??[])c.has(h)||r.push(h)}}return c}f(Ae,"collectForcedOn");import{Input as Ne}from"@earendil-works/pi-tui";import{mkdir as Te,readFile as Se,writeFile as Re}from"node:fs/promises";import Pe from"node:path";import{withFileMutationQueue as Ce}from"@earendil-works/pi-coding-agent";async function oe(e,l,p=new Map,c=new Map,r){await Ce(e,async()=>{let m=await B(e),h={};try{h=JSON.parse(await Se(e,"utf8"))}catch(n){if(!(n instanceof Error&&"code"in n&&n.code==="ENOENT"))throw n}let T=new Set(m.disabled),u=new Set(m.enabled);for(let[n,s]of l)T.delete(n),u.delete(n),s==="disabled"&&T.add(n),s==="enabled"&&u.add(n);let w={...m.preferences};for(let[n,s]of c)s===void 0?delete w[n]:w[n]=s;let g={...m.flags};for(let[n,s]of p)n==="pi-agent-ide-no-animations"&&delete h.noAnimations,n==="pi-agent-ide-no-post-processing"&&delete h.noPostProcessing,s===void 0?delete g[n]:g[n]=s;await Te(Pe.dirname(e),{recursive:!0}),await Re(e,`${JSON.stringify({...h,disabled:[...T],enabled:[...u],...r===void 0?{}:{preset:r},...p.size>0?{flags:g}:{},...c.size>0?{preferences:w}:{}},null,2)}
2
- `)})}f(oe,"saveModuleChoices");import{getSettingsListTheme as ke}from"@earendil-works/pi-coding-agent";import{matchesKey as W,SettingsList as _e,truncateToWidth as se,visibleWidth as re}from"@earendil-works/pi-tui";function ie(e,l,p,c,r=""){let m=["extensions","behavior","ui"],h="extensions",T=f(i=>i==="extensions"?"modules":i==="behavior"?"features":"ui","itemKey"),u=f(i=>i==="extensions"?"modules":i==="behavior"?"features":"ui","changeKey"),w=f(()=>{let i=T(h),o=l()[i]??[];return new _e(o,12,ke(),(d,a)=>{p(u(h),d,a);for(let x of l()[i]??[]){let b=o.find(E=>E.id===x.id);b&&Object.assign(b,x)}},()=>c(!1),{enableSearch:!0})},"createList"),g=w(),n=f(i=>e.fg("borderMuted",i),"border"),s=f((i,o)=>{if(o<=1)return n("\u2502");let d=o-2,a=se(i,d);return`${n("\u2502")}${a}${" ".repeat(Math.max(0,d-re(a)))}${n("\u2502")}`},"row"),t=f(i=>n(i<=1?"\u251C":`\u251C${"\u2500".repeat(Math.max(0,i-2))}\u2524`),"rule");return{render(i){let o=Math.max(1,i),d=Math.max(1,o-4),a=` Agent IDE settings${r?` \xB7 ${r}`:""} `,x=o<=1?n("\u256D"):`${n("\u256D\u2500")}${e.fg("accent",e.bold(se(a,Math.max(0,o-3),"")))}${n(`${"\u2500".repeat(Math.max(0,o-re(a)-3))}\u256E`)}`,b={extensions:"Features",behavior:"Behavior",ui:"UI"},E=m.map(v=>v===h?e.fg("accent",e.bold(`[ ${b[v]} ]`)):e.fg("dim",` ${b[v]} `)).join(" "),I=g.render(d).map(v=>s(` ${v} `,o)),S=e.fg("dim"," Tab switch \xB7 Enter change \xB7 Ctrl+S save \xB7 Esc cancel ");return[x,s(` ${E} `,o),t(o),...I,t(o),s(S,o),n(o<=1?"\u2570":`\u2570${"\u2500".repeat(Math.max(0,o-2))}\u256F`)]},invalidate(){g.invalidate()},handleInput(i){W(i,"tab")||W(i,"shift+tab")?(h=m[(m.indexOf(h)+(W(i,"shift+tab")?2:1))%m.length]??"extensions",g=w()):W(i,"ctrl+s")?c(!0):g.handleInput(i)}}}f(ie,"createSettingsPanel");function ae(e,l=[],p=[]){e.registerCommand("agent-ide-settings",{description:"Configure Agent IDE modules and features",async handler(c,r){if(r.hasUI)try{let m=await r.ui.select("Agent IDE settings \u2014 save scope",["Project","Global"]);if(m===void 0)return;let h=F(process.env,void 0,r.cwd),T=m==="Project"?h.projectPath:h.globalPath,u=await B(T),w=await B(m==="Project"?h.globalPath:h.projectPath),g=new Map,n=new Map,s=new Map,t;if(!await r.ui.custom((o,d,a,x)=>{let b=ie(d,()=>{let E=new Set(u.disabled),I=new Set(u.enabled);for(let[P,y]of g)E.delete(P),I.delete(P),y==="disabled"&&E.add(P),y==="enabled"&&I.add(P);let S=U(M,[...$(M,t??u.preset??"full"),...E,...$(M,w.preset??"full"),...w.disabled],[...I,...w.enabled]);return{modules:M.map(P=>({id:P.id,label:P.name??P.id,description:`${P.description??""} Effective: ${S.disabled.has(P.id)?"off":"on"}.${w.disabled.includes(P.id)?" Disabled in the other scope.":P.dependencies.some(y=>S.disabled.has(y))?" A dependency is disabled.":""}`,currentValue:g.get(P.id)??(u.disabled.includes(P.id)?"disabled":u.enabled.includes(P.id)?"enabled":"default"),values:["default","enabled","disabled"]})),features:[v(),...k("features"),...R("features")],ui:[...k("ui"),...R("ui")]};function v(){let P=t??u.preset??"full";return{id:"preset",label:"Preset",description:"Choose the built-in Agent IDE capability set. Reload required.",currentValue:j.find(y=>y.value===P)?.label??P,values:j.map(y=>y.label)}}function R(P){return p.filter(y=>y.group===P).map(y=>{let C=s.has(y.id)?s.get(y.id):u.preferences?.[y.id];return{id:y.id,label:y.name,description:`${y.description} Default: ${y.kind==="choice"?y.values.find(_=>_.value===y.default)?.label??y.default:y.default||"empty"}.`,currentValue:C===void 0?"default":y.kind==="choice"?y.values.find(_=>_.value===C)?.label??C:C,...y.kind==="choice"?{values:["default",...y.values.map(_=>_.label)]}:{submenu:f((_,z)=>{let D=new Ne,H=_==="default"?y.default:_;return H.length>0&&D.handleInput(H),D.focused=!0,D.onSubmit=ve=>z(ve),D.onEscape=()=>z(),D},"submenu")}}})}function k(P){return l.filter(y=>(y.group??"features")===P).map(y=>{let C=n.has(y.id)?n.get(y.id):ee(u)[y.id];return{id:y.id,label:y.name,description:y.description,currentValue:C===void 0?"default":C?y.labels?.on??"enabled":y.labels?.off??"disabled",values:["default",y.labels?.off??"disabled",y.labels?.on??"enabled"]}})}},(E,I,S)=>{if(E==="modules")g.set(I,S);else if(I==="preset")t=j.find(v=>v.label===S)?.value;else if(p.some(v=>v.id===I)){let v=p.find(R=>R.id===I);s.set(I,S==="default"||S.length===0?void 0:v?.kind==="choice"?v.values.find(R=>R.label===S)?.value:S)}else n.set(I,S==="default"?void 0:S===(l.find(v=>v.id===I)?.labels?.on??"enabled"))},x,m);return{render:f(E=>b.render(E),"render"),invalidate:f(()=>b.invalidate(),"invalidate"),handleInput(E){b.handleInput(E),o.requestRender()}}})||g.size+n.size+s.size+(t===void 0?0:1)===0)return;if(await oe(T,g,n,s,t),r.ui.notify(`Saved ${m.toLowerCase()} Agent IDE settings. Reload required.`,"info"),await r.ui.confirm("Reload Pi?","Reload extensions to apply settings. In-memory extension state may reset.")){await r.reload();return}}catch(m){r.ui.notify(m instanceof Error?m.message:String(m),"error")}}})}f(ae,"registerModuleSettings");function de(e,l){let p=[];return{definitions:p,register(c){if(p.some(r=>r.id===c.id))throw new Error(`Duplicate feature flag: ${c.id}`);p.push(c),e.registerFlag(c.id,{type:"boolean",description:c.description,default:l[c.id]??c.default})}}}f(de,"createFeatureFlags");function le(e){let l=new Map,p=new Set;return{api:{...e,registerTool:f(r=>{r.namespace?.name.startsWith("ide_")===!0&&l.set(r.name,{hide:f(()=>e.registerTool({...r,get description(){return r.description},get promptGuidelines(){return r.promptGuidelines},exposure:"hidden"}),"hide"),restore:f(()=>e.registerTool(r),"restore")}),p.has(r.name)?l.get(r.name)?.hide():e.registerTool(r)},"registerTool")},reconcile(r=!1,m=[]){let h=new Set,T=new Set;for(let s of e.getSettings().defaultTools??[])if(s.startsWith("-"))h.add(s.slice(1)),T.delete(s.slice(1));else{let t=s.startsWith("+")?s.slice(1):s;h.delete(t),T.add(t)}for(let[s,t]of l)h.has(s)!==p.has(s)&&(h.has(s)?(t.hide(),p.add(s)):(t.restore(),p.delete(s)));let u=e.getAllTools().filter(s=>s.exposure!=="hidden"),w=new Set(e.getActiveTools());for(let s of u)r&&l.has(s.name)&&(T.has(s.name)||s.exposure==="deferred"&&m.includes(s.name))&&w.add(s.name);r&&!h.has("tool_search")&&u.some(s=>s.name==="tool_search")&&u.some(s=>l.has(s.name)&&s.exposure==="deferred")&&w.add("tool_search");let g=e.getActiveTools(),n=[...w].filter(s=>!p.has(s));(n.length!==g.length||n.some(s=>!g.includes(s)))&&e.setActiveTools(n)}}}f(le,"createIdeToolAvailability");import{ToolExecutionComponent as ce}from"@earendil-works/pi-coding-agent";import{Container as Me,Spacer as Oe,Text as ue}from"@earendil-works/pi-tui";var J="ide-nested-results",fe=256,pe=512*1024,ge=8*1024,De=32*1024,$e=f(()=>({argumentsTruncated:!1,resultsOmitted:!1,callsOmitted:!1,resultsUnavailable:!1}),"retained");function Be(e){let l=e.retention,p=[l?.argumentsTruncated&&"arguments shortened",l?.resultsOmitted&&"result displays omitted",l?.callsOmitted&&"call panels omitted",l?.resultsUnavailable&&"results unavailable"].filter(Boolean);if(p.length>0)return`Nested IDE display: ${p.join("; ")}. Tool execution and parent output are unchanged.`;if(!l&&e.complete===!1)return"Nested IDE display is incomplete; omission details are unavailable."}f(Be,"retentionWarning");function me(e){let l=new Map,p=new Map,c=new Map,r,m=new WeakMap,h=f((g,n,s)=>{n.result=s,n.resultOmitted=!1;try{let i=JSON.stringify(g);if(Buffer.byteLength(i)<=pe){n.result=JSON.parse(JSON.stringify(s));return}}catch{}let t=s.details&&typeof s.details=="object"?Object.entries(s.details).filter(([i,o])=>(i==="source"||i==="fullOutputPath")&&typeof o=="string").map(([i,o])=>`${i}: ${String(o)}`):[];n.result={content:[{type:"text",text:["Result presentation omitted (history size limit or unsupported payload).",...t].join(`
3
- `)}],details:void 0,isError:s.isError},n.resultOmitted=!0},"retainResult"),T=f(()=>{p.clear(),c.clear()},"clear");e.on("session_start",(g,n)=>{T(),n.mode==="tui"&&n.ui.setWidget(J,s=>(r=s,{render:f(()=>[],"render"),invalidate:f(()=>{},"invalidate")}))}),e.on("session_tree",T),e.on("session_shutdown",T),e.on("tool_execution_start",(g,n)=>{if(g.parentToolCallId===void 0)return;let s=p.get(g.parentToolCallId)??g.parentToolCallId;if(p.set(g.toolCallId,s),!l.has(g.toolName))return;let t=c.get(s);if(t||(t={parentToolCallId:s,cwd:n.cwd,calls:[],retention:$e()},c.set(s,t)),t.calls.length>=fe){t.retention.callsOmitted=!0;return}let i=JSON.stringify(g.args),o=De-t.calls.reduce((b,E)=>b+Buffer.byteLength(JSON.stringify(E.args)),0)-(fe-t.calls.length-1)*2,d=Buffer.byteLength(i)>Math.min(ge,o),a=d?Object.fromEntries(Object.entries(g.args).map(([b,E])=>[b,typeof E=="string"?E.slice(0,200)+(E.length>200?"\u2026 [omitted]":""):"[omitted]"])):JSON.parse(i),x=Buffer.byteLength(JSON.stringify(a))<=Math.min(ge,o)?a:{};t.calls.push({id:g.toolCallId,name:g.toolName,args:x,argumentsTruncated:d})}),e.on("tool_execution_end",g=>{let n=p.get(g.toolCallId);if(n===void 0)return;p.delete(g.toolCallId);let s=c.get(n),t=s?.calls.find(i=>i.id===g.toolCallId);if(s&&t){let i=g.result;h(s,t,{content:i.content.filter(o=>o.type!=="text"||!o.text.startsWith(`
1
+ import{a as O,b as B,c as U,d as re,e as ie,f as F}from"./chunk-W7CASEO3.js";import{f as H}from"./chunk-IM24DB3K.js";import"./chunk-QUYXINGZ.js";import"./chunk-PRLIHLCS.js";import{a as ae}from"./chunk-YGGKGZO2.js";import"./chunk-MPT3R4BL.js";import{f as Z}from"./chunk-T7I2VX3J.js";import{a as ne}from"./chunk-BU7IZLKB.js";import{a as ee,b as te}from"./chunk-S5PL5DFQ.js";import{K as se,d as oe}from"./chunk-DXONCYWF.js";import"./chunk-ZC65Z3CK.js";import{a as u}from"./chunk-EI7MMDWY.js";var z={"ide.core":["IDE services","Shared services used by language, formatting and diagnostic modules."],"ide.tips":["Getting started tips","Show contextual guidance while setting up a project."],"ide.documentation":["Progressive agent documentation","Expose packaged guides and attach them on first relevant tool use."],"ide.doctor":["Setup doctor","Check external tools and help configure project support."],"ide.languages":["Language setup","Discover languages and their recommended toolchains."],"ide.processes":["Agent IDE processes","Show active terminal and debugger sessions in one shared process surface."],"ide.vision":["Agent vision","Inspect process metadata and capture supported windows and web pages as images."],"ide.debugger":["Debugger sessions","Debug local programs through addressable DAP sessions and anchored breakpoints."],"ide.terminal":["Terminal sessions","Run and manage local interactive and background terminal processes."],"read.core":["Read tools","Read sources through the configured readers and views."],"read.filesystem":["Local files","Resolve files and folders from the local filesystem."],"read.ssh":["SSH files","Read and edit configured SSH file sources through existing tools."],"read.filesystem.jq":["JSON queries","Query local JSON files through jq read views."],"read.filesystem.image":["Local images","Read local images as visual content."],"read.filesystem.pdf":["Local PDFs","Extract readable content from local PDF documents."],"read.filesystem.text":["Local text","Read local text files with their source coordinates."],"read.web":["Web sources","Read remote sources over HTTP and HTTPS."],"read.web.html":["Web pages","Extract readable content from HTML pages."],"read.web.image":["Web images","Read remote images as visual content."],"read.web.pdf":["Web PDFs","Extract text from remote PDF documents."],"read.web.text":["Web text","Read remote plain-text sources."],"search.core":["Search tools","Run searches through the configured search providers."],"search.text":["Text search","Find text and files and register reusable search selections."],"editor.core":["Editing tools","Make guarded text and whole-file changes, directly or through native Codemode."],"editor.renderer":["Edit previews","Display changes in the shared colored diff panels."],"editor.anchor.constant":["File boundary selectors","Use begin and end to select file boundaries."],"editor.anchor.line-hash":["Checked line selectors","Select lines with hashes that detect stale content."],"editor.anchor.exact":["Exact text selectors","Locate edit ranges using unique source text."],"editor.stale-anchor":["Stale selection recovery","Provide recovery guidance when an edit selection is outdated."],"ide.ast":["Structural code support","Read code outlines and search or edit exact syntax-tree nodes."],"ide.formatter":["Code formatting","Run configured formatters after edits."],"ide.lint":["Lint checks","Run configured linters and collect their findings."],"ide.changes":["Git changes","Inspect and manage uncommitted changes and undo history."],"ide.lsp":["Language servers","Resolve symbols, rename references and collect language-server diagnostics."],"ide.diagnostics":["Diagnostic views","Show diagnostic findings through read views and sources."]};var N=[A("ide.core",()=>import("./chunk-XSIKDVAR.js")),A("ide.tips",()=>import("./chunk-BB4A5UI3.js")),A("ide.doctor",()=>import("./chunk-ID4RJIVZ.js")),A("ide.languages",()=>import("./entry-37.js"),["ide.doctor"]),A("read.core",()=>import("./entry-47.js")),A("ide.documentation",()=>import("./chunk-VMGZMXEM.js"),["read.core"]),A("read.filesystem",()=>import("./entry-27.js"),["read.core","editor.core"]),A("read.ssh",()=>import("./chunk-SWA5B5B2.js"),["read.filesystem"]),A("read.filesystem.jq",()=>import("./entry-29.js"),["read.filesystem","ide.documentation","ide.doctor"]),A("read.filesystem.image",()=>import("./entry-28.js"),["read.filesystem"]),A("read.filesystem.pdf",()=>import("./entry-30.js"),["read.filesystem"]),A("read.filesystem.text",()=>import("./entry-31.js"),["read.filesystem"]),A("read.web",()=>import("./chunk-GNACBJM3.js"),["read.core"]),A("read.web.html",()=>import("./entry-85.js"),["read.web"]),A("read.web.image",()=>import("./entry-86.js"),["read.web"]),A("read.web.pdf",()=>import("./entry-87.js"),["read.web"]),A("read.web.text",()=>import("./entry-88.js"),["read.web"]),A("search.core",()=>import("./entry-52.js")),A("search.text",()=>import("./entry-53.js"),["search.core"]),A("editor.renderer",()=>import("./entry-80.js"),["editor.core"]),A("editor.core",()=>import("./entry-79.js")),A("editor.anchor.constant",()=>import("./entry-58.js"),["read.core","editor.core"]),A("editor.anchor.line-hash",()=>import("./entry-62.js"),["read.core","editor.core"]),A("editor.anchor.exact",()=>import("./entry-60.js"),["editor.core"]),A("editor.stale-anchor",()=>import("./entry-81.js"),["editor.core"]),A("ide.ast",()=>import("./entry-33.js"),["ide.core","read.core","search.core","editor.core"]),A("ide.formatter",()=>import("./chunk-246NTPOS.js"),["ide.core"]),A("ide.lint",()=>import("./chunk-VNTY7BKC.js"),["ide.core"]),A("ide.changes",()=>import("./chunk-ZV5ETNLQ.js"),["ide.core","read.core","editor.core"]),A("ide.lsp",()=>import("./chunk-3WO2NOEQ.js"),["ide.core","read.core","search.core"]),A("ide.processes",()=>import("./chunk-OM4LYD3S.js")),A("ide.vision",()=>import("./chunk-BR7GRH4A.js"),["ide.processes","read.core","search.core"]),A("ide.debugger",()=>import("./chunk-WMHSVEIT.js"),["ide.processes","read.core","editor.core"]),A("ide.terminal",()=>import("./chunk-W7M3V7FR.js"),["ide.processes","read.core","search.core","editor.core","editor.anchor.constant"]),A("ide.diagnostics",()=>import("./chunk-AUL5FGGK.js"),["ide.core","read.core"])];function A(e,s,f=[],l=!0){return{id:e,name:z[e][0],description:z[e][1],dependencies:f,async register(o,g){await(await s()).default(o,g)},...l?{}:{defaultEnabled:!1}}}u(A,"builtin");function W(e,s,f){return{kind:"choice",id:e,name:s,description:f,default:"compact",group:"ui",values:[{value:"full",label:"Full"},{value:"compact",label:"Compact"},{value:"disabled",label:"Disabled"}]}}u(W,"presentationPreference");var G=[{kind:"choice",id:"ui.codemode",name:"Show tool results from Codemode",description:"Show extra Agent IDE result panels using each tool's presentation setting. Off hides successful panels; errors stay visible. Codemode's own output and other tools are unchanged.",default:"off",group:"ui",values:[{value:"off",label:"Off"},{value:"on",label:"On"}]},W("ui.diffs","Diffs","Choose how mutation and comparison diffs are displayed."),W("ui.read","Read","Choose how Read calls and results are displayed."),W("ui.search","Search","Choose how Search calls and results are displayed."),W("ui.terminal","Terminal","Choose how shell commands and terminal output are displayed."),{kind:"choice",id:"processes.activity",name:"Active Agent IDE processes",description:"Choose detailed process cards, a compact active count, or no persistent Agent IDE process UI.",default:"detailed",group:"ui",values:[{value:"detailed",label:"Detailed cards"},{value:"compact",label:"Compact count"},{value:"off",label:"Off"}]},{kind:"text",id:"vision.sequenceDurationSeconds",name:"Vision sequence duration",description:"Default sequence duration in seconds. Requests may override it, up to 10 seconds.",default:"2",group:"features"},{kind:"text",id:"vision.sequenceIntervalSeconds",name:"Vision sequence interval",description:"Default seconds between sequence frames. A sequence may contain at most 20 frames.",default:"0.5",group:"features"},{kind:"text",id:"vision.imageScale",name:"Vision image scale",description:"Default image downscale from greater than 0 through 1.",default:"0.5",group:"features"},{kind:"text",id:"vision.allowedExecutables",name:"Vision allowed executables",description:"Comma-separated executable file names that may be captured without arbitrary-window access.",default:"",group:"features",placeholder:"Unity.exe,UnrealEditor.exe"}];function q(e,s,f=[]){let l=new Map;for(let m of e){if(l.has(m.id))throw new Error(`Duplicate Pi Agent IDE extension ID: ${m.id}`);l.set(m.id,m)}for(let m of e)for(let x of m.dependencies)if(!l.has(x))throw new Error(`Pi Agent IDE extension ${m.id} has unknown dependency ${x}`);let o=new Set;for(let m of s)l.has(m)&&o.add(m);for(let m of f)if(!l.has(m))throw new Error(`Unknown Pi Agent IDE extension ID in enabled: ${m}`);let g=Ne(l,f,o),y=new Set;for(let m of e)(m.defaultEnabled===!1&&!g.has(m.id)||o.has(m.id))&&y.add(m.id);let E=!0;for(;E;){E=!1;for(let m of e)y.has(m.id)||m.dependencies.every(x=>!y.has(x))||(y.add(m.id),E=!0)}return{enabled:e.filter(m=>!y.has(m.id)),disabled:y}}u(q,"selectBuiltinExtensions");function Ne(e,s,f){let l=new Set,o=[...s];for(;o.length>0;){let g=o.pop();if(!(l.has(g)||f.has(g))){l.add(g);for(let y of e.get(g)?.dependencies??[])l.has(y)||o.push(y)}}return l}u(Ne,"collectForcedOn");import{Input as Le}from"@earendil-works/pi-tui";import{mkdir as De,readFile as Me,writeFile as Oe}from"node:fs/promises";import je from"node:path";import{withFileMutationQueue as $e}from"@earendil-works/pi-coding-agent";async function le(e,s,f=new Map,l=new Map,o){await $e(e,async()=>{let g=await F(e),y={};try{y=JSON.parse(await Me(e,"utf8"))}catch(i){if(!(i instanceof Error&&"code"in i&&i.code==="ENOENT"))throw i}let E=new Set(g.disabled),m=new Set(g.enabled);for(let[i,n]of s)E.delete(i),m.delete(i),n==="disabled"&&E.add(i),n==="enabled"&&m.add(i);let x={...g.preferences};for(let[i,n]of l)n===void 0?delete x[i]:x[i]=n;let S={...g.flags};for(let[i,n]of f)i==="pi-agent-ide-no-animations"&&delete y.noAnimations,i==="pi-agent-ide-no-post-processing"&&delete y.noPostProcessing,n===void 0?delete S[i]:S[i]=n;await De(je.dirname(e),{recursive:!0}),await Oe(e,`${JSON.stringify({...y,disabled:[...E],enabled:[...m],...o===void 0?{}:{preset:o},...f.size>0?{flags:S}:{},...l.size>0?{preferences:x}:{}},null,2)}
2
+ `)})}u(le,"saveModuleChoices");import{getSettingsListTheme as Be}from"@earendil-works/pi-coding-agent";import{matchesKey as J,SettingsList as Fe,truncateToWidth as de,visibleWidth as ce}from"@earendil-works/pi-tui";function ue(e,s,f,l,o=""){let g=["extensions","behavior","ui"],y="extensions",E=u(t=>t==="extensions"?"modules":t==="behavior"?"features":"ui","itemKey"),m=u(t=>t==="extensions"?"modules":t==="behavior"?"features":"ui","changeKey"),x=u(()=>{let t=E(y),a=s()[t]??[];return new Fe(a,12,Be(),(r,c)=>{f(m(y),r,c);for(let d of s()[t]??[]){let b=a.find(p=>p.id===d.id);b&&Object.assign(b,d)}},()=>l(!1),{enableSearch:!0})},"createList"),S=x(),i=u(t=>e.fg("borderMuted",t),"border"),n=u((t,a)=>{if(a<=1)return i("\u2502");let r=a-2,c=de(t,r);return`${i("\u2502")}${c}${" ".repeat(Math.max(0,r-ce(c)))}${i("\u2502")}`},"row"),h=u(t=>i(t<=1?"\u251C":`\u251C${"\u2500".repeat(Math.max(0,t-2))}\u2524`),"rule");return{render(t){let a=Math.max(1,t),r=Math.max(1,a-4),c=` Agent IDE settings${o?` \xB7 ${o}`:""} `,d=a<=1?i("\u256D"):`${i("\u256D\u2500")}${e.fg("accent",e.bold(de(c,Math.max(0,a-3),"")))}${i(`${"\u2500".repeat(Math.max(0,a-ce(c)-3))}\u256E`)}`,b={extensions:"Features",behavior:"Behavior",ui:"UI"},p=g.map(T=>T===y?e.fg("accent",e.bold(`[ ${b[T]} ]`)):e.fg("dim",` ${b[T]} `)).join(" "),w=S.render(r).map(T=>n(` ${T} `,a)),I=e.fg("dim"," Tab switch \xB7 Enter change \xB7 Ctrl+S save \xB7 Esc cancel ");return[d,n(` ${p} `,a),h(a),...w,h(a),n(I,a),i(a<=1?"\u2570":`\u2570${"\u2500".repeat(Math.max(0,a-2))}\u256F`)]},invalidate(){S.invalidate()},handleInput(t){J(t,"tab")||J(t,"shift+tab")?(y=g[(g.indexOf(y)+(J(t,"shift+tab")?2:1))%g.length]??"extensions",S=x()):J(t,"ctrl+s")?l(!0):S.handleInput(t)}}}u(ue,"createSettingsPanel");function fe(e,s=[],f=[]){e.registerCommand("agent-ide-settings",{description:"Configure Agent IDE modules and features",async handler(l,o){if(o.hasUI)try{let g=await o.ui.select("Agent IDE settings \u2014 save scope",["Project","Global"]);if(g===void 0)return;let y=U(process.env,void 0,o.cwd),E=g==="Project"?y.projectPath:y.globalPath,m=await F(E),x=await F(g==="Project"?y.globalPath:y.projectPath),S=new Map,i=new Map,n=new Map,h;if(!await o.ui.custom((a,r,c,d)=>{let b=ue(r,()=>{let p=new Set(m.disabled),w=new Set(m.enabled);for(let[R,v]of S)p.delete(R),w.delete(R),v==="disabled"&&p.add(R),v==="enabled"&&w.add(R);let I=q(N,[...B(N,h??m.preset??"full"),...p,...B(N,x.preset??"full"),...x.disabled],[...w,...x.enabled]);return{modules:N.map(R=>({id:R.id,label:R.name??R.id,description:`${R.description??""} Effective: ${I.disabled.has(R.id)?"off":"on"}.${x.disabled.includes(R.id)?" Disabled in the other scope.":R.dependencies.some(v=>I.disabled.has(v))?" A dependency is disabled.":""}`,currentValue:S.get(R.id)??(m.disabled.includes(R.id)?"disabled":m.enabled.includes(R.id)?"enabled":"default"),values:["default","enabled","disabled"]})),features:[T(),...P("features"),...C("features")],ui:[...P("ui"),...C("ui")]};function T(){let R=h??m.preset??"full";return{id:"preset",label:"Preset",description:"Choose the built-in Agent IDE capability set. Reload required.",currentValue:O.find(v=>v.value===R)?.label??R,values:O.map(v=>v.label)}}function C(R){return f.filter(v=>v.group===R).map(v=>{let _=n.has(v.id)?n.get(v.id):m.preferences?.[v.id];return{id:v.id,label:v.name,description:`${v.description} Default: ${v.kind==="choice"?v.values.find(k=>k.value===v.default)?.label??v.default:v.default||"empty"}.`,currentValue:_===void 0?"default":v.kind==="choice"?v.values.find(k=>k.value===_)?.label??_:_,...v.kind==="choice"?{values:["default",...v.values.map(k=>k.label)]}:{submenu:u((k,L)=>{let $=new Le,Q=k==="default"?v.default:k;return Q.length>0&&$.handleInput(Q),$.focused=!0,$.onSubmit=_e=>L(_e),$.onEscape=()=>L(),$},"submenu")}}})}function P(R){return s.filter(v=>(v.group??"features")===R).map(v=>{let _=i.has(v.id)?i.get(v.id):ie(m)[v.id];return{id:v.id,label:v.name,description:v.description,currentValue:_===void 0?"default":_?v.labels?.on??"enabled":v.labels?.off??"disabled",values:["default",v.labels?.off??"disabled",v.labels?.on??"enabled"]}})}},(p,w,I)=>{if(p==="modules")S.set(w,I);else if(w==="preset")h=O.find(T=>T.label===I)?.value;else if(f.some(T=>T.id===w)){let T=f.find(C=>C.id===w);n.set(w,I==="default"||I.length===0?void 0:T?.kind==="choice"?T.values.find(C=>C.label===I)?.value:I)}else i.set(w,I==="default"?void 0:I===(s.find(T=>T.id===w)?.labels?.on??"enabled"))},d,g);return{render:u(p=>b.render(p),"render"),invalidate:u(()=>b.invalidate(),"invalidate"),handleInput(p){b.handleInput(p),a.requestRender()}}})||S.size+i.size+n.size+(h===void 0?0:1)===0)return;if(await le(E,S,i,n,h),o.ui.notify(`Saved ${g.toLowerCase()} Agent IDE settings. Reload required.`,"info"),await o.ui.confirm("Reload Pi?","Reload extensions to apply settings. In-memory extension state may reset.")){await o.reload();return}}catch(g){o.ui.notify(g instanceof Error?g.message:String(g),"error")}}})}u(fe,"registerModuleSettings");import{readFile as Ue}from"node:fs/promises";import V from"node:path";import{getMarkdownTheme as We}from"@earendil-works/pi-coding-agent";import{Markdown as Ge,matchesKey as M,ScrollView as qe,truncateToWidth as Je}from"@earendil-works/pi-tui";function He(){return Ue(V.join(V.dirname(V.dirname(import.meta.dirname)),"docs/settings-help.md"),"utf8")}u(He,"readSettingsHelp");function pe(e){e.registerCommand("agent-ide-help",{description:"Read the short Agent IDE settings guide",async handler(s,f){if(!(f.mode!=="tui"||!f.hasUI))try{let l=await He();await f.ui.custom((o,g,y,E)=>new X(l,g,()=>Math.max(5,Math.min(36,o.terminal.rows-4)),()=>o.requestRender(),E),{overlay:!0,overlayOptions:{width:92,margin:1}})}catch(l){f.ui.notify(l instanceof Error?l.message:String(l),"error")}}})}u(pe,"registerSettingsHelp");var X=class{constructor(s,f,l,o,g){this.content=s;this.theme=f;this.height=l;this.requestRender=o;this.done=g;this.markdown=this.createMarkdown(),this.scroll=new qe(this.markdown)}static{u(this,"SettingsHelpPanel")}markdown;scroll;createMarkdown(){return new Ge(this.content,0,0,We(),{color:u(s=>this.theme.fg("text",s),"color")})}invalidate(){this.markdown.invalidate()}handleInput(s){if(M(s,"escape")){this.done();return}M(s,"up")?this.scroll.scrollBy(-1):M(s,"down")?this.scroll.scrollBy(1):M(s,"pageUp")?this.scroll.scrollBy(-this.scroll.viewportHeight):M(s,"pageDown")||M(s,"space")?this.scroll.scrollBy(this.scroll.viewportHeight):M(s,"home")?this.scroll.scrollToStart():M(s,"end")&&this.scroll.scrollToEnd()}render(s){let f=Math.max(1,s-4),l=this.markdown.render(f),o=Math.max(1,this.height()-4);this.scroll.updateLayout(l.length,o,this.requestRender);let g=l.slice(this.scroll.scrollTop,this.scroll.scrollTop+o);for(;g.length<o;)g.push("");let y=this.theme.fg("border","\u2500".repeat(Math.max(0,s-2))),E=u(m=>this.theme.fg("border","\u2502 ")+Je(m,f,"\u2026",!0)+this.theme.fg("border"," \u2502"),"row");return[this.theme.fg("border","\u256D")+y+this.theme.fg("border","\u256E"),E(this.theme.fg("accent","Agent IDE settings help")),...g.map(E),E(this.theme.fg("muted","\u2191\u2193 scroll \xB7 PgUp/PgDn page \xB7 Home/End \xB7 Esc close")),this.theme.fg("border","\u2570")+y+this.theme.fg("border","\u256F")]}};function ge(e,s){let f=[];return{definitions:f,register(l){if(f.some(o=>o.id===l.id))throw new Error(`Duplicate feature flag: ${l.id}`);f.push(l),e.registerFlag(l.id,{type:"boolean",description:l.description,default:s[l.id]??l.default})}}}u(ge,"createFeatureFlags");function me(e){let s={preferences:G,flags:e,modules:N.map(({id:l,name:o,description:g,defaultEnabled:y,dependencies:E})=>({id:l,name:o,description:g,default:y!==!1,dependencies:E})),presets:O},f=Object.entries(s).map(([l,o])=>` "${l}": [
3
+ ${o.map(g=>` ${JSON.stringify(g)}`).join(`,
4
+ `)}
5
+ ]`).join(`,
6
+ `);return{id:"ide-settings",description:"Registered IDE settings, choices, defaults, configuration scopes and inheritance.",triggers:[{tool:"read",resourcePrefixes:["docs:ide-settings"]}],markdown:`# IDE settings
7
+
8
+ This catalog describes supported settings, not current saved values or live runtime state. It is generated from the registrations used by /agent-ide-settings. Read both configuration scopes to inspect overrides. Reload or restart applies saved changes; CLI flags may override them for an invocation.
9
+
10
+ ## Configuration scopes
11
+
12
+ - Project: <current project>/.pi/pi-agent-ide/extensions.json.
13
+ - Global: <PI_CODING_AGENT_DIR>/pi-agent-ide/extensions.json when that environment variable is non-empty; otherwise <home>/.pi/agent/pi-agent-ide/extensions.json. Resolve a relative PI_CODING_AGENT_DIR against the process working directory.
14
+ - Missing files mean no overrides. Invalid JSON or invalid field types are errors, not defaults.
15
+ - preferences maps registered IDs to strings; flags maps registered IDs to booleans. Project overrides Global per key. Default removes only the selected scope's key, allowing inheritance.
16
+ - preset is a registered preset value. Project overrides Global; without either, full is used. Default removes the selected scope's preset field.
17
+ - disabled and enabled are arrays of unique non-empty module IDs, merged across scopes. Disabled wins in either scope and cascades to dependents. enabled can activate default-off modules and dependencies; it cannot undo a disable or a preset restriction.
18
+ - A module's default below is its built-in default before preset and dependency selection, not its current effective state.
19
+ - Existing noAnimations and noPostProcessing booleans still work. Their registered flags are pi-agent-ide-no-animations and pi-agent-ide-no-post-processing. Within each scope a flags entry wins over its corresponding legacy boolean. When changing or resetting that flag, remove its legacy boolean in the same scope, as the menu does.
20
+ - Text preference values are strings, not JSON numbers. An empty default means no override; saved strings must be non-empty. Read each description for valid ranges. Do not treat storage validation as validation of every preference value.
21
+
22
+ ## Registered settings
23
+
24
+ Choices carry their saved value and human label. Text settings carry a description and optional placeholder. Boolean flag defaults do not include saved or CLI overrides. Preserve unrelated fields when editing configuration.
25
+
26
+ \`\`\`json
27
+ {
28
+ ${f}
29
+ }
30
+ \`\`\`
31
+ `}}u(me,"createIdeSettingsDocumentation");function he(e){let s=new Map,f=new Set;return{api:{...e,registerTool:u(o=>{o.namespace?.name.startsWith("ide_")===!0&&s.set(o.name,{hide:u(()=>e.registerTool({...o,get description(){return o.description},get promptGuidelines(){return o.promptGuidelines},exposure:"hidden"}),"hide"),restore:u(()=>e.registerTool(o),"restore")}),f.has(o.name)?s.get(o.name)?.hide():e.registerTool(o)},"registerTool")},reconcile(o=!1,g=[]){let y=new Set,E=new Set;for(let n of e.getSettings().defaultTools??[])if(n.startsWith("-"))y.add(n.slice(1)),E.delete(n.slice(1));else{let h=n.startsWith("+")?n.slice(1):n;y.delete(h),E.add(h)}for(let[n,h]of s)y.has(n)!==f.has(n)&&(y.has(n)?(h.hide(),f.add(n)):(h.restore(),f.delete(n)));let m=e.getAllTools().filter(n=>n.exposure!=="hidden"),x=new Set(e.getActiveTools());for(let n of m)o&&s.has(n.name)&&(E.has(n.name)||n.exposure==="deferred"&&g.includes(n.name))&&x.add(n.name);o&&!y.has("tool_search")&&m.some(n=>n.name==="tool_search")&&m.some(n=>s.has(n.name)&&n.exposure==="deferred")&&x.add("tool_search");let S=e.getActiveTools(),i=[...x].filter(n=>!f.has(n));(i.length!==S.length||i.some(n=>!S.includes(n)))&&e.setActiveTools(i)}}}u(he,"createIdeToolAvailability");import{ToolExecutionComponent as ye}from"@earendil-works/pi-coding-agent";import{Container as be,Spacer as ze,Text as Y}from"@earendil-works/pi-tui";var K="ide-nested-results",we=256,xe=512*1024,ve=8*1024,Ve=32*1024,Xe=u(()=>({argumentsTruncated:!1,resultsOmitted:!1,callsOmitted:!1,resultsUnavailable:!1}),"retained");function Ee(e){let s=e.retention,f=[s?.argumentsTruncated&&"arguments shortened",s?.resultsOmitted&&"result displays omitted",s?.callsOmitted&&"call panels omitted",s?.resultsUnavailable&&"results unavailable"].filter(Boolean);if(f.length>0)return`Nested IDE display: ${f.join("; ")}. Tool execution and parent output are unchanged.`;if(!s&&e.complete===!1)return"Nested IDE display is incomplete; omission details are unavailable."}u(Ee,"retentionWarning");function Ie(e,s=!1){let f=new Map,l=new Map,o=new Map,g,y=new WeakMap,E=u((i,n,h)=>{n.result=h,n.resultOmitted=!1;try{let a=JSON.stringify(i);if(Buffer.byteLength(a)<=xe){n.result=JSON.parse(JSON.stringify(h));return}}catch{}let t=h.details&&typeof h.details=="object"?Object.entries(h.details).filter(([a,r])=>(a==="source"||a==="fullOutputPath")&&typeof r=="string").map(([a,r])=>`${a}: ${String(r)}`):[];n.result={content:[{type:"text",text:["Result presentation omitted (history size limit or unsupported payload).",...t].join(`
32
+ `)}],details:void 0,isError:h.isError},n.resultOmitted=!0},"retainResult"),m=u(()=>{l.clear(),o.clear()},"clear");e.on("session_start",(i,n)=>{m(),n.mode==="tui"&&n.ui.setWidget(K,h=>(g=h,{render:u(()=>[],"render"),invalidate:u(()=>{},"invalidate")}))}),e.on("session_tree",m),e.on("session_shutdown",m),e.on("tool_execution_start",(i,n)=>{if(i.parentToolCallId===void 0)return;let h=l.get(i.parentToolCallId)??i.parentToolCallId;if(l.set(i.toolCallId,h),!f.has(i.toolName))return;let t=o.get(h);if(t||(t={parentToolCallId:h,cwd:n.cwd,calls:[],retention:Xe()},o.set(h,t)),t.calls.length>=we){t.retention.callsOmitted=!0;return}let a=JSON.stringify(i.args),r=Ve-t.calls.reduce((p,w)=>p+Buffer.byteLength(JSON.stringify(w.args)),0)-(we-t.calls.length-1)*2,c=Buffer.byteLength(a)>Math.min(ve,r),d=c?Object.fromEntries(Object.entries(i.args).map(([p,w])=>[p,typeof w=="string"?w.slice(0,200)+(w.length>200?"\u2026 [omitted]":""):"[omitted]"])):JSON.parse(a),b=Buffer.byteLength(JSON.stringify(d))<=Math.min(ve,r)?d:{};t.calls.push({id:i.toolCallId,name:i.toolName,args:b,argumentsTruncated:c})}),e.on("tool_execution_end",i=>{let n=l.get(i.toolCallId);if(n===void 0)return;l.delete(i.toolCallId);let h=o.get(n),t=h?.calls.find(a=>a.id===i.toolCallId);if(h&&t){let a=i.result;E(h,t,{content:a.content.filter(r=>r.type!=="text"||!r.text.startsWith(`
4
33
 
5
34
  ---
6
35
 
7
- # Guide:`)),details:i.details,isError:g.isError})}}),e.on("message_end",g=>{if(g.message.role!=="toolResult")return;let n=c.get(g.message.toolCallId);if(!n)return;c.delete(g.message.toolCallId);for(let[o,d]of p)d===n.parentToolCallId&&p.delete(o);let s=n.calls.filter(o=>!o.batched),t={...n,calls:[],retention:{...n.retention,argumentsTruncated:s.some(o=>o.argumentsTruncated===!0),resultsOmitted:s.some(o=>o.resultOmitted===!0),resultsUnavailable:s.some(o=>!o.result)}},i=Buffer.byteLength(JSON.stringify(t));for(let o of s){let d=JSON.stringify(o);if(i+=Buffer.byteLength(d)+(t.calls.length>0?1:0),i>pe){t.retention.callsOmitted=!0;break}t.calls.push(JSON.parse(d))}e.appendEntry(J,t)}),e.registerEntryRenderer(J,f(function g(n,s,t){if(!Array.isArray(n.data?.calls))return;if(!r)return{render:f(a=>r?g(n,s,t)?.render(a)??[]:[],"render"),invalidate:f(()=>{n.data&&m.get(n.data)?.invalidate()},"invalidate")};let i=Be(n.data),o=m.get(n.data);if(!o){o=new Me;for(let a of n.data.calls){let x=new ce(a.name,a.id,a.renderArgs??a.args,{showImages:!0},a.resultOmitted||a.omitted||!a.result?void 0:l.get(a.name),r,n.data.cwd);a.result?x.updateResult(a.result):x.updateResult({content:[{type:"text",text:"Result unavailable in this saved display."}],isError:!0}),o.addChild(new Oe(1)),o.addChild(x)}i&&o.addChild(new ue(t.fg("warning",i),0,0)),m.set(n.data,o)}let d=o.children.at(-1);i&&d instanceof ue&&d.setText(t.fg("warning",i));for(let a of o.children)a instanceof ce&&a.setExpanded(s.expanded);return o},"renderEntry"));let u=f(()=>{e.events.on(te,g=>{let n=g,s=c.get(n.parentToolCallId);if(!s)return;let t=q(n.result.details),i=n.calls.findLast(d=>!n.unchangedCopyCalls?.includes(d)),o="callIdsByResult"in t&&Array.isArray(t.callIdsByResult)?t.callIdsByResult:[];for(let d of n.calls){let a=s.calls.find(I=>I.id===d);if(!a)continue;let x=t.results?.filter((I,S)=>(o[S]===d||o.length===0&&n.calls.length===1)&&I.data.errors?.some(v=>v.code==="POST_WRITE_FAILED"||v.code==="POST_EDIT_FAILED"))??[];if(a.postWriteFailure=x.length>0,a.postWriteFailure){a.batched=!1,delete a.renderArgs,h(s,a,{content:n.result.content,details:{results:x,effect:"applied"},isError:!0});continue}let b=n.copyResults?.get(d),E=b?.details.metadata?.copyRollback;if(a.name==="copy"&&b&&(E==="restored"||E==="failed")){a.copyRollback=E,a.batched=!1,h(s,a,{content:b.content,details:q(b.details),isError:!0});continue}if(a.unchangedCopy=a.name==="copy"&&n.unchangedCopyCalls?.includes(d)===!0,a.batched=!a.unchangedCopy&&d!==i,a.unchangedCopy)h(s,a,{content:[{type:"text",text:"No changes: destination already has this text."}],details:{},isError:!1});else if(a.batched)a.result=void 0;else{new Set(t.mutationRender?.map(S=>S.path)).size>1&&(a.renderArgs={}),a.rollback=t.results?.some(S=>S.data.rollback!==void 0)===!0;let I=a.result?.details?.metadata?.targetUnavailable;h(s,a,{content:n.result.content,details:typeof I=="string"?{...t,metadata:{...t.metadata,targetUnavailable:I}}:t,isError:n.result.isError===!0||a.rollback})}}}),e.on("tool_result",g=>{let n=g.details,s=c.get(g.toolCallId);if(s&&n&&typeof n=="object"&&"editorBatchResults"in n&&Array.isArray(n.editorBatchResults))for(let t of n.editorBatchResults)for(let i of t.data?.operations??[]){let o=s.calls.find(a=>a.id===i.id);if(!o)continue;let d=i.errors.map(a=>a.message);o.rollback||o.postWriteFailure||o.copyRollback!==void 0||o.unchangedCopy&&d.length===0&&i.effect==="not-applied"||(d.length>0||i.effect!=="applied")&&(o.batched=!1,delete o.renderArgs,h(s,o,{content:[{type:"text",text:`${o.name}: ${i.effect}.
8
- ${d.join(`
9
- `)}`}],details:void 0,isError:d.length>0||i.effect==="unknown"}))}})},"finalize");return{api:{...e,registerTool:f(g=>{l.set(g.name,g),e.registerTool(g)},"registerTool")},finalize:u}}f(me,"createNestedIdeRendering");import{createCanvas as je,loadImage as Fe}from"@napi-rs/canvas";import{DEFAULT_MAX_BYTES as Le,DEFAULT_MAX_LINES as Ue,truncateHead as We}from"@earendil-works/pi-coding-agent";var N={bytes:Le,lines:Ue,pixels:4e6,images:20,imageBytes:20*1024*1024};async function O(e,l="",p){let c=typeof l=="string"?[l]:l,r=[],m=e.flatMap(d=>{if(d.type!=="text")return[];let a=c.find(x=>x.length>0&&d.text.endsWith(x));return a?(r.push(a),[d.text.slice(0,-a.length)]):[d.text]}).join(`
10
- `),h=r.join(""),T=We(m,{maxBytes:N.bytes,maxLines:N.lines}),u=[],w;if(T.truncated&&p!==void 0)try{w=await p(m)}catch{u.push("[Full output could not be saved. Narrow the request to inspect it.]")}T.truncated&&u.push(`[Output truncated: useful content is limited to ${N.bytes} bytes / ${N.lines} lines. Narrow the request or read a smaller source range.]`),w!==void 0&&u.push(`[Full output: ${JSON.stringify(w)}. Read with offset/limit, or read ${JSON.stringify("raw:"+w)} for byte ranges. Available until this runtime is disposed.]`);let g=e.filter(d=>d.type==="image"),n=g.slice(0,N.images),s=[],t=Math.floor(N.pixels/Math.max(1,n.length)),i=0,o=g.length-n.length;for(let[d,a]of n.entries())try{let x=Buffer.from(a.data,"base64"),b=await Fe(x),E=Math.min(1,Math.sqrt(t/(b.width*b.height))),I=Math.min(t,Math.max(1,Math.floor(b.height*E))),S=Math.min(Math.floor(t/I),Math.max(1,Math.floor(b.width*E))),v=x,R=a.mimeType;if(E<1||i+v.byteLength>N.imageBytes){let k=je(S,I);k.getContext("2d").drawImage(b,0,0,S,I),v=await k.encode("png"),R="image/png"}if(i+v.byteLength>N.imageBytes){o++;continue}i+=v.byteLength,s.push({type:"image",data:v.toString("base64"),mimeType:R}),E<1&&u.push(`[Image ${d+1} resized from ${b.width}x${b.height} to ${S}x${I} to fit the shared media budget.]`)}catch{o++,u.push(`[Image ${d+1} could not be decoded and was not returned.]`)}return o>0&&u.push(`[${o} images omitted from the result. Read fewer frames or a smaller image region.]`),{text:T.firstLineExceedsLimit?qe(m):T.content,textTruncated:T.truncated,images:s,notices:u,metadataSuffix:h,fullOutput:w}}f(O,"limitIdeOutput");function qe(e){let l=0,p=0;for(let c of e){let r=Buffer.byteLength(c);if(l+r>N.bytes)break;l+=r,p+=c.length}return e.slice(0,p)}f(qe,"bytePrefix");var he={read:["path"],search:["path"],select:["path"],replace:["path"],insert:["path"],delete:["path"],write:["path"],copy:["path","target"],move:["path","target"],undo:["file"],diff:["before","after"]};function ye(e){let l=Q(e),p=new Set,c=new K,r=f(t=>c.saveFile(t),"saveFullOutput"),m=new Set,h=new Map;Y(e,{protocol:V,apiVersion:X,id:"ide-output-retention",setup(t){t.setOutputSaver(r)}}),e.on("session_shutdown",()=>c.dispose());let T=f((t,i)=>{let o=i;return t!=="tool_call"?e.on(t,o):e.on("tool_call",async(d,a)=>{let x=await o(d,a);if(!x?.block||!p.has(d.toolName)||x.reason===void 0)return x;let b=await O([{type:"text",text:x.reason}],"",r);return m.add(d.toolCallId),{...x,reason:b.text+(b.notices.length?`
36
+ # Guide:`)),details:a.details,isError:i.isError})}}),e.on("message_end",i=>{if(i.message.role!=="toolResult")return;let n=o.get(i.message.toolCallId);if(!n)return;o.delete(i.message.toolCallId);for(let[r,c]of l)c===n.parentToolCallId&&l.delete(r);let h=n.calls.filter(r=>!r.batched),t={...n,parentToolName:i.message.toolName,calls:[],retention:{...n.retention,argumentsTruncated:h.some(r=>r.argumentsTruncated===!0),resultsOmitted:h.some(r=>r.resultOmitted===!0),resultsUnavailable:h.some(r=>!r.result)}},a=Buffer.byteLength(JSON.stringify(t));for(let r of h){let c=JSON.stringify(r);if(a+=Buffer.byteLength(c)+(t.calls.length>0?1:0),a>xe){t.retention.callsOmitted=!0;break}t.calls.push(JSON.parse(c))}e.appendEntry(K,t)}),e.registerEntryRenderer(K,u(function i(n,h,t){if(!Array.isArray(n.data?.calls))return;let a=s&&n.data.parentToolName==="codemode"&&!h.expanded,r=a?n.data.calls.filter(p=>p.result?.isError):n.data.calls;if(a&&r.length===0){let p=Ee(n.data);return p?new Y(t.fg("warning",p),0,0):new be}if(!g)return{render:u(p=>g?i(n,h,t)?.render(p)??[]:[],"render"),invalidate:u(()=>{n.data&&y.get(n.data)?.invalidate()},"invalidate")};let c=Ee(n.data),d=a?void 0:y.get(n.data);if(!d){d=new be;for(let p of r){let w=new ye(p.name,p.id,p.renderArgs??p.args,{showImages:!0},p.resultOmitted||p.omitted||!p.result?void 0:f.get(p.name),g,n.data.cwd);p.result?w.updateResult(p.result):w.updateResult({content:[{type:"text",text:"Result unavailable in this saved display."}],isError:!0}),d.addChild(new ze(1)),d.addChild(w)}c&&d.addChild(new Y(t.fg("warning",c),0,0)),a||y.set(n.data,d)}let b=d.children.at(-1);c&&b instanceof Y&&b.setText(t.fg("warning",c));for(let p of d.children)p instanceof ye&&p.setExpanded(h.expanded);return d},"renderEntry"));let x=u(()=>{e.events.on(ae,i=>{let n=i,h=o.get(n.parentToolCallId);if(!h)return;let t=H(n.result.details),a=n.calls.findLast(c=>!n.unchangedCopyCalls?.includes(c)),r="callIdsByResult"in t&&Array.isArray(t.callIdsByResult)?t.callIdsByResult:[];for(let c of n.calls){let d=h.calls.find(I=>I.id===c);if(!d)continue;let b=t.results?.filter((I,T)=>(r[T]===c||r.length===0&&n.calls.length===1)&&I.data.errors?.some(C=>C.code==="POST_WRITE_FAILED"||C.code==="POST_EDIT_FAILED"))??[];if(d.postWriteFailure=b.length>0,d.postWriteFailure){d.batched=!1,delete d.renderArgs,E(h,d,{content:n.result.content,details:{results:b,effect:"applied"},isError:!0});continue}let p=n.mutationResults?.get(c),w=p?.details.metadata?.copyRollback;if(d.name==="copy"&&p&&(w==="restored"||w==="failed")){d.copyRollback=w,d.batched=!1,E(h,d,{content:p.content,details:H(p.details),isError:!0});continue}if(d.unchangedCopy=d.name==="copy"&&n.unchangedCopyCalls?.includes(c)===!0,d.batched=!d.unchangedCopy&&c!==a,d.unchangedCopy)E(h,d,{content:[{type:"text",text:"No changes: destination already has this text."}],details:{},isError:!1});else if(d.batched)d.result=void 0;else{new Set(t.mutationRender?.map(T=>T.path)).size>1&&(d.renderArgs={}),d.rollback=t.results?.some(T=>T.data.rollback!==void 0)===!0;let I=d.result?.details?.metadata?.targetUnavailable;E(h,d,{content:n.result.content,details:typeof I=="string"?{...t,metadata:{...t.metadata,targetUnavailable:I}}:t,isError:n.result.isError===!0||d.rollback})}}}),e.on("tool_result",i=>{let n=i.details,h=o.get(i.toolCallId);if(h&&n&&typeof n=="object"&&"editorBatchResults"in n&&Array.isArray(n.editorBatchResults))for(let t of n.editorBatchResults)for(let a of t.data?.operations??[]){let r=h.calls.find(d=>d.id===a.id);if(!r)continue;let c=a.errors.map(d=>d.message);r.rollback||r.postWriteFailure||r.copyRollback!==void 0||r.unchangedCopy&&c.length===0&&a.effect==="not-applied"||(c.length>0||a.effect!=="applied")&&(r.batched=!1,delete r.renderArgs,E(h,r,{content:[{type:"text",text:`${r.name}: ${a.effect}.
37
+ ${c.join(`
38
+ `)}`}],details:void 0,isError:c.length>0||a.effect==="unknown"}))}})},"finalize");return{api:{...e,registerTool:u(i=>{f.set(i.name,i),e.registerTool(i)},"registerTool")},finalize:x}}u(Ie,"createNestedIdeRendering");import{createHash as nt}from"node:crypto";import{createCanvas as Ye,loadImage as Ke}from"@napi-rs/canvas";import{DEFAULT_MAX_BYTES as Qe,DEFAULT_MAX_LINES as Ze,truncateHead as et}from"@earendil-works/pi-coding-agent";var D={bytes:Qe,lines:Ze,pixels:4e6,images:20,imageBytes:20*1024*1024};async function j(e,s="",f){let l=typeof s=="string"?[s]:s,o=[],g=e.flatMap(r=>{if(r.type!=="text")return[];let c=l.find(d=>d.length>0&&r.text.endsWith(d));return c?(o.push(c),[r.text.slice(0,-c.length)]):[r.text]}).join(`
39
+ `),y=o.join(""),E=et(g,{maxBytes:D.bytes,maxLines:D.lines}),m=[],x;if(E.truncated&&f!==void 0)try{x=await f(g)}catch{m.push("[Full output could not be saved. Narrow the request to inspect it.]")}E.truncated&&m.push(`[Output truncated: useful content is limited to ${D.bytes} bytes / ${D.lines} lines. Narrow the request or read a smaller source range.]`),x!==void 0&&m.push(`[Full output: ${JSON.stringify(x)}. Read with offset/limit, or read ${JSON.stringify("raw:"+x)} for byte ranges. Available until this runtime is disposed.]`);let S=e.filter(r=>r.type==="image"),i=S.slice(0,D.images),n=[],h=Math.floor(D.pixels/Math.max(1,i.length)),t=0,a=S.length-i.length;for(let[r,c]of i.entries())try{let d=Buffer.from(c.data,"base64"),b=await Ke(d),p=Math.min(1,Math.sqrt(h/(b.width*b.height))),w=Math.min(h,Math.max(1,Math.floor(b.height*p))),I=Math.min(Math.floor(h/w),Math.max(1,Math.floor(b.width*p))),T=d,C=c.mimeType;if(p<1||t+T.byteLength>D.imageBytes){let P=Ye(I,w);P.getContext("2d").drawImage(b,0,0,I,w),T=await P.encode("png"),C="image/png"}if(t+T.byteLength>D.imageBytes){a++;continue}t+=T.byteLength,n.push({type:"image",data:T.toString("base64"),mimeType:C}),p<1&&m.push(`[Image ${r+1} resized from ${b.width}x${b.height} to ${I}x${w} to fit the shared media budget.]`)}catch{a++,m.push(`[Image ${r+1} could not be decoded and was not returned.]`)}return a>0&&m.push(`[${a} images omitted from the result. Read fewer frames or a smaller image region.]`),{text:E.firstLineExceedsLimit?tt(g):E.content,textTruncated:E.truncated,images:n,notices:m,metadataSuffix:y,fullOutput:x}}u(j,"limitIdeOutput");function tt(e){let s=0,f=0;for(let l of e){let o=Buffer.byteLength(l);if(s+o>D.bytes)break;s+=o,f+=l.length}return e.slice(0,f)}u(tt,"bytePrefix");var Te={read:["path"],search:["path"],select:["path"],replace:["path"],insert:["path"],delete:["path"],write:["path"],copy:["path","target"],move:["path","target"],undo:["file"],diff:["before","after"]};function Ae(e){let s=se(e),f=new Set,l=new oe,o=u(t=>l.saveFile(t),"saveFullOutput"),g=new Map,y=u(t=>nt("sha256").update(JSON.stringify(t)).digest("hex"),"signature"),E=u(async(t,a)=>{let r=y(a),c=g.get(t);if(c&&(c.source===r||y(await c.content)===r))return c.content;let d=j(a,"",o).then(b=>[{type:"text",text:b.text+(b.notices.length?`
11
40
 
12
41
  ${b.notices.join(`
13
- `)}`:"")}})},"on"),u=new Map,w=new Map,g=f(()=>{u.clear(),w.clear(),m.clear(),h.clear()},"clear");e.on("session_start",g),e.on("session_shutdown",g),e.on("before_agent_start",t=>({systemPrompt:`${t.systemPrompt}
42
+ `)}`:"")},...b.images]);return g.set(t,{source:r,content:d}),d},"limitError");ne(e,{protocol:ee,apiVersion:te,id:"ide-output-retention",setup(t){t.setOutputSaver(o)}}),e.on("session_shutdown",()=>l.dispose());let m=u((t,a)=>{if(t==="message_end"){let c=a;return e.on("message_end",async(d,b)=>{let p=await c(d,b),w=p?.message??d.message;return w.role!=="toolResult"||!w.isError||!f.has(w.toolName)||w.content.some(I=>I.type==="text"&&I.text.startsWith("<system-result"))?p:{...p,message:{...w,content:await E(w.toolCallId,w.content)}}})}let r=a;return t!=="tool_call"?e.on(t,r):e.on("tool_call",async(c,d)=>{let b=await r(c,d);if(!b?.block||!f.has(c.toolName)||b.reason===void 0)return b;let p=await j([{type:"text",text:b.reason}],"",o);return{...b,reason:p.text+(p.notices.length?`
43
+
44
+ ${p.notices.join(`
45
+ `)}`:"")}})},"on"),x=new Map,S=new Map,i=u(()=>{x.clear(),S.clear(),g.clear()},"clear");e.on("session_start",i),e.on("session_shutdown",i),e.on("before_agent_start",t=>({systemPrompt:`${t.systemPrompt}
14
46
 
15
47
  <ide_results>
16
48
  IDE tools return readable text. The leading system-result envelope is an internal reference, not file content; do not edit it. Compose tools by passing the unchanged result to a source parameter. Outside Codemode, pass the same text or its UUID. Store/load preserves these strings within the session. Use returned anchors to choose individual selections. Changed snapshots and previous sessions cannot be reused.
17
- </ide_results>`})),e.on("tool_execution_start",t=>{t.parentToolCallId!==void 0&&u.set(t.toolCallId,u.get(t.parentToolCallId)??t.parentToolCallId)}),T("tool_call",(t,i)=>{if(!p.has(t.toolName))return;let o={...t.input};try{for(let d of he[t.toolName]??[]){let a=o[d];if(a!==void 0)if(t.toolName==="diff"&&a!==null&&typeof a=="object"&&"path"in a)o[d]={...a,path:l.source(a.path,i.cwd,!0)};else{let x=l.source(a,i.cwd,t.toolName==="read"?!0:["write","insert","delete"].includes(t.toolName)?"live":!1);if(t.toolName==="read"&&Array.isArray(x)){let b=l.resolve(x,i.cwd);o[d]=l.register(b.targets,i.cwd,b.complete)}else o[d]=x}}t.toolName==="select"&&o.operation&&typeof o.operation=="object"&&"scopes"in o.operation&&(o.operation={...o.operation,scopes:l.source(o.operation.scopes,i.cwd)});for(let d of["text","content"]){let a=o[d];if(typeof a=="string"&&(a.trimStart().startsWith("<system-result")||/<system-result\b[^>]*><uuid>[a-f\d-]{36}<\/uuid><\/system-result>/iu.test(a)))return{block:!0,reason:"A system result reference is not file content. Do not insert it into a file."}}Object.assign(t.input,o)}catch(d){return{block:!0,reason:d instanceof Error?d.message:String(d)}}});let n=f(t=>{p.add(t.name);let i={},o=Object.getOwnPropertyDescriptors(t);delete o.outputSchema;let d=f(async(...b)=>{let E=await t.execute(...b).catch(async v=>{let R=await O([{type:"text",text:v instanceof Error?v.message:String(v)}],"",r);throw m.add(b[0]),R.notices.length===0?v:new Error(R.text+`
49
+ </ide_results>`})),e.on("tool_execution_start",t=>{t.parentToolCallId!==void 0&&x.set(t.toolCallId,x.get(t.parentToolCallId)??t.parentToolCallId)}),m("tool_call",(t,a)=>{if(!f.has(t.toolName))return;let r={...t.input};try{for(let c of Te[t.toolName]??[]){let d=r[c];if(d!==void 0)if(t.toolName==="diff"&&d!==null&&typeof d=="object"&&"path"in d)r[c]={...d,path:s.source(d.path,a.cwd,!0)};else{let b=s.source(d,a.cwd,t.toolName==="read"?!0:["write","insert","delete"].includes(t.toolName)?"live":!1);if(t.toolName==="read"&&Array.isArray(b)){let p=s.resolve(b,a.cwd);r[c]=s.register(p.targets,a.cwd,p.complete)}else r[c]=b}}t.toolName==="select"&&r.operation&&typeof r.operation=="object"&&"scopes"in r.operation&&(r.operation={...r.operation,scopes:s.source(r.operation.scopes,a.cwd)});for(let c of["text","content"]){let d=r[c];if(typeof d=="string"&&(d.trimStart().startsWith("<system-result")||/<system-result\b[^>]*><uuid>[a-f\d-]{36}<\/uuid><\/system-result>/iu.test(d)))return{block:!0,reason:"A system result reference is not file content. Do not insert it into a file."}}Object.assign(t.input,r)}catch(c){return{block:!0,reason:c instanceof Error?c.message:String(c)}}});let n=u(t=>{f.add(t.name);let a={},r=Object.getOwnPropertyDescriptors(t);delete r.outputSchema;let c=u(async(...p)=>{let w=await t.execute(...p).catch(async C=>{let P=await j([{type:"text",text:C instanceof Error?C.message:String(C)}],"",o);throw P.notices.length===0?C:new Error(P.text+`
18
50
 
19
- ${R.notices.join(`
20
- `)}`,{cause:v})}),I=await O(E.content,be(E.details),r),S=I.text+I.metadataSuffix;return{...E,content:[{type:"text",text:S+(I.notices.length?`
51
+ ${P.notices.join(`
52
+ `)}`,{cause:C})}),I=await j(w.content,Se(w.details),o),T=I.text+I.metadataSuffix;return{...w,content:[{type:"text",text:T+(I.notices.length?`
21
53
 
22
54
  ${I.notices.join(`
23
- `)}`:"")},...I.images]}},"execute");o.execute={value:d,enumerable:!0,configurable:!0,writable:!0};let a=t.renderCall;if(a){let b=f((E,I,S)=>a(Ge(t.name,E),I,S),"renderCall");o.renderCall={value:b,enumerable:!0,configurable:!0,writable:!0}}let x=t.renderResult;if(x){let b=f((E,I,S,v)=>x({...E,content:E.content.map(R=>R.type==="text"?{...R,text:R.text.replace(/^<system-result\b[^>]*><uuid>[a-f\d-]{36}<\/uuid><\/system-result>\n/u,"")}:R)},I,S,v),"renderer");o.renderResult={value:b,enumerable:!0,configurable:!0,writable:!0}}Object.defineProperties(i,o),e.registerTool(i)},"registerTool"),s=f(()=>{e.on("context",async t=>({messages:await Promise.all(t.messages.map(async i=>{if(i.role!=="toolResult"||!i.isError||!p.has(i.toolName)||m.has(i.toolCallId)||i.content.some(d=>d.type==="text"&&d.text.startsWith("<system-result")))return i;let o=h.get(i.toolCallId);return o===void 0&&(o=O(i.content,"",r).then(d=>[{type:"text",text:d.text+(d.notices.length?`
24
-
25
- ${d.notices.join(`
26
- `)}`:"")},...d.images]),h.set(i.toolCallId,o)),{...i,content:await o}}))})),e.on("tool_result",async(t,i)=>{if(t.toolName==="codemode"){l.refreshAll();let R=w.get(t.toolCallId)??[];w.delete(t.toolCallId);for(let[C,_]of u)_===t.toolCallId&&u.delete(C);let k=t.content.filter(C=>C.type==="text"&&C.text.startsWith(`
55
+ `)}`:"")},...I.images]}},"execute");r.execute={value:c,enumerable:!0,configurable:!0,writable:!0};let d=t.renderCall;if(d){let p=u((w,I,T)=>d(ot(t.name,w),I,T),"renderCall");r.renderCall={value:p,enumerable:!0,configurable:!0,writable:!0}}let b=t.renderResult;if(b){let p=u((w,I,T,C)=>b({...w,content:w.content.map(P=>P.type==="text"?{...P,text:P.text.replace(/^<system-result\b[^>]*><uuid>[a-f\d-]{36}<\/uuid><\/system-result>\n/u,"")}:P)},I,T,C),"renderer");r.renderResult={value:p,enumerable:!0,configurable:!0,writable:!0}}Object.defineProperties(a,r),e.registerTool(a)},"registerTool"),h=u(()=>{e.on("context",async t=>({messages:await Promise.all(t.messages.map(async a=>a.role!=="toolResult"||!a.isError||!f.has(a.toolName)||a.content.some(r=>r.type==="text"&&r.text.startsWith("<system-result"))?a:{...a,content:await E(a.toolCallId,a.content)}))})),e.on("tool_result",async(t,a)=>{if(t.toolName==="codemode"){s.refreshAll();let P=S.get(t.toolCallId)??[];S.delete(t.toolCallId);for(let[k,L]of x)L===t.toolCallId&&x.delete(k);let R=t.content.filter(k=>k.type==="text"&&k.text.startsWith(`
27
56
 
28
57
  ---
29
58
 
30
- # Guide:`)),P=t.content.filter(C=>!k.includes(C)),y=await O([...P,...R],"",r);return{content:[...y.textTruncated?[{type:"text",text:y.text}]:P.filter(C=>C.type==="text"),...y.images,...y.notices.length?[{type:"text",text:`
59
+ # Guide:`)),v=t.content.filter(k=>!R.includes(k)),_=await j([...v,...P],"",o);return{content:[..._.textTruncated?[{type:"text",text:_.text}]:v.filter(k=>k.type==="text"),..._.images,..._.notices.length?[{type:"text",text:`
31
60
 
32
- ${y.notices.join(`
33
- `)}`}]:[],...k]}}if(!p.has(t.toolName))return;let o=t.content.filter(R=>R.type==="text").map(R=>R.text).join(`
34
- `),d=t.structuredContent,a=d!==null&&typeof d=="object"&&"data"in d?d:{status:t.isError?"error":"success",data:d},x=a.data,b=x!==null&&typeof x=="object"&&"effect"in x&&x.effect==="applied"&&"targetUnavailable"in x&&typeof x.targetUnavailable=="string"?x.targetUnavailable:void 0,E=b===void 0?o:`${o}
61
+ ${_.notices.join(`
62
+ `)}`}]:[],...R]}}if(!f.has(t.toolName))return;let r=t.content.filter(P=>P.type==="text").map(P=>P.text).join(`
63
+ `),c=t.structuredContent,d=c!==null&&typeof c=="object"&&"data"in c?c:{status:t.isError?"error":"success",data:c},b=d.data,p=b!==null&&typeof b=="object"&&"effect"in b&&b.effect==="applied"&&"targetUnavailable"in b&&typeof b.targetUnavailable=="string"?b.targetUnavailable:void 0,w=p===void 0?r:`${r}
35
64
 
36
- This result has no verified text selection: ${b}
37
- Read/Search the file before the next edit; do not repeat the applied edit.`,I=xe(a),S=l.publish(a,E,i.cwd,I),v=u.get(t.toolCallId);if(u.delete(t.toolCallId),v!==void 0){let R=t.content.filter(k=>k.type==="image");R.length&&w.set(v,[...w.get(v)??[],...R])}return{content:[{type:"text",text:S},...t.content.filter(R=>R.type!=="text")]}})},"finalize");return{api:{...e,on:T,registerTool:n},finalize:s}}f(ye,"createIdeTextResults");function be(e){if(e===null||typeof e!="object")return[];let l="outputNotice"in e&&typeof e.outputNotice=="string"?[e.outputNotice]:[];if("resources"in e&&Array.isArray(e.resources)){let p=e.resources;for(let c of p)c!==null&&typeof c=="object"&&"details"in c&&l.push(...be(c.details))}return l}f(be,"outputNotices");function Ge(e,l){let p=f(r=>{if(Array.isArray(r))return r.map(p);if(typeof r!="string")return r;let m=/^<system-result\b[^>]*><uuid>([a-f\d-]{36})<\/uuid>/u.exec(r)?.[1];return m?`RESULT#${m}`:r},"label"),c={...l};for(let r of he[e]??[])Object.assign(c,{[r]:p(l[r])});return c}f(Ge,"displaySources");function xe(e){if(e===null||typeof e!="object"||!("data"in e))return[];let l=e.data;return l===null||typeof l!="object"?[]:"resources"in l&&Array.isArray(l.resources)?l.resources.flatMap(c=>xe({data:c})):"files"in l&&Array.isArray(l.files)?l.files.flatMap(c=>c!==null&&typeof c=="object"&&"source"in c&&typeof c.source=="string"&&/^(?:shell|debug):/u.test(c.source)?[c.source]:[]):"source"in l&&typeof l.source=="string"?[l.source]:[]}f(xe,"resultResources");function we(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}f(we,"isRecord");function Ee(e,l){if(!we(e)||!Array.isArray(e.tools))return e;let p=e.tools,c=p.map(r=>!we(r)||r.type!=="function"||typeof r.name!="string"||!l.has(r.name)||r.strict!==void 0?r:{...r,strict:!1});return c.some((r,m)=>r!==p[m])?{...e,tools:c}:e}f(Ee,"preserveResponsesToolOmission");import{VERSION as Je}from"@earendil-works/pi-coding-agent";import{getCurrentTools as ze}from"@earendil-works/pi-ai";function Ie(e){let l=/^(\d+)\.(\d+)\.(\d+)(-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u.exec(e),p=[0,99,1],r=l?.slice(1,4).map(Number)?.map((m,h)=>m-(p[h]??0)).find(m=>m!==0)??0;if(l===null||r<0||r===0&&l[4]!==void 0)throw new Error(`Pi Agent IDE requires Pi 0.99.1 or newer; this host is ${e}. Update Pi before loading the extension.`)}f(Ie,"assertSupportedHost");async function He(e){Ie(Je);let l=me(e),p=ye(l.api),c=le(p.api);e.on("before_provider_request",(u,w)=>{if(w.model?.api!=="openai-responses")return;let g=new Set(e.getAllTools().filter(n=>n.namespace?.name.startsWith("ide_")).map(n=>n.name));return Ee(u.payload,g)}),e.on("session_start",(u,w)=>{let g=u.reason==="reload"?[]:ze(w.sessionManager.getBranch().flatMap(n=>n.type==="message"?[n.message]:[])).map(n=>n.name);c.reconcile(!0,g)}),e.on("before_agent_start",u=>{c.reconcile();let w=u.systemPrompt.replace("- bash: Execute bash commands (ls, grep, find, etc.)","- bash: Execute Bash commands").replace(`- Use bash for file operations like ls, rg, find
38
- `,""),g=e.getAllTools().filter(d=>d.exposure!=="hidden"),n=e.getActiveTools(),s=n.includes("tool_search")?"Use tool_search to find":n.includes("codemode")?"Use searchTools inside codemode to find":"Enable native tool_search to find",t=g.filter(d=>d.namespace?.name==="ide_git").map(d=>d.name),i=[...t.length===0?[]:[`${s} ${t.join(" and ")} in ide_git when staging or unstaging selected Git changes.`],...g.some(d=>d.name==="debug"&&d.namespace?.name==="ide_debug")?[`${s} debug in ide_debug when creating a debugger session.`]:[]],o=i.length===0?w:`${w}
65
+ This result has no verified text selection: ${p}
66
+ Read/Search the file before the next edit; do not repeat the applied edit.`,I=Re(d),T=s.publish(d,w,a.cwd,I),C=x.get(t.toolCallId);if(x.delete(t.toolCallId),C!==void 0){let P=t.content.filter(R=>R.type==="image");P.length&&S.set(C,[...S.get(C)??[],...P])}return{content:[{type:"text",text:T},...t.content.filter(P=>P.type!=="text")]}})},"finalize");return{api:{...e,on:m,registerTool:n},finalize:h}}u(Ae,"createIdeTextResults");function Se(e){if(e===null||typeof e!="object")return[];let s="outputNotice"in e&&typeof e.outputNotice=="string"?[e.outputNotice]:[];if("resources"in e&&Array.isArray(e.resources)){let f=e.resources;for(let l of f)l!==null&&typeof l=="object"&&"details"in l&&s.push(...Se(l.details))}return s}u(Se,"outputNotices");function ot(e,s){let f=u(o=>{if(Array.isArray(o))return o.map(f);if(typeof o!="string")return o;let g=/^<system-result\b[^>]*><uuid>([a-f\d-]{36})<\/uuid>/u.exec(o)?.[1];return g?`RESULT#${g}`:o},"label"),l={...s};for(let o of Te[e]??[])Object.assign(l,{[o]:f(s[o])});return l}u(ot,"displaySources");function Re(e){if(e===null||typeof e!="object"||!("data"in e))return[];let s=e.data;return s===null||typeof s!="object"?[]:"resources"in s&&Array.isArray(s.resources)?s.resources.flatMap(l=>Re({data:l})):"files"in s&&Array.isArray(s.files)?s.files.flatMap(l=>l!==null&&typeof l=="object"&&"source"in l&&typeof l.source=="string"&&/^(?:shell|debug):/u.test(l.source)?[l.source]:[]):"source"in s&&typeof s.source=="string"?[s.source]:[]}u(Re,"resultResources");function Pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}u(Pe,"isRecord");function Ce(e,s){if(!Pe(e)||!Array.isArray(e.tools))return e;let f=e.tools,l=f.map(o=>!Pe(o)||o.type!=="function"||typeof o.name!="string"||!s.has(o.name)||o.strict!==void 0?o:{...o,strict:!1});return l.some((o,g)=>o!==f[g])?{...e,tools:l}:e}u(Ce,"preserveResponsesToolOmission");import{VERSION as st}from"@earendil-works/pi-coding-agent";import{getCurrentTools as rt}from"@earendil-works/pi-ai";function ke(e){let s=/^(\d+)\.(\d+)\.(\d+)(-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u.exec(e),f=[0,99,1],o=s?.slice(1,4).map(Number)?.map((g,y)=>g-(f[y]??0)).find(g=>g!==0)??0;if(s===null||o<0||o===0&&s[4]!==void 0)throw new Error(`Pi Agent IDE requires Pi 0.99.1 or newer; this host is ${e}. Update Pi before loading the extension.`)}u(ke,"assertSupportedHost");async function it(e){ke(st);let s=await re(U()),f=s.preferences?.["ui.codemode"]!=="on",l=Ie(e,f),o=Ae(l.api),g=he(o.api);e.on("before_provider_request",(x,S)=>{if(S.model?.api!=="openai-responses")return;let i=new Set(e.getAllTools().filter(n=>n.namespace?.name.startsWith("ide_")).map(n=>n.name));return Ce(x.payload,i)}),e.on("session_start",(x,S)=>{let i=x.reason==="reload"?[]:rt(S.sessionManager.getBranch().flatMap(n=>n.type==="message"?[n.message]:[])).map(n=>n.name);g.reconcile(!0,i)}),e.on("before_agent_start",x=>{g.reconcile();let S=x.systemPrompt.replace("- bash: Execute bash commands (ls, grep, find, etc.)","- bash: Execute Bash commands").replace(`- Use bash for file operations like ls, rg, find
67
+ `,""),i=e.getAllTools().filter(c=>c.exposure!=="hidden"),n=e.getActiveTools(),h=n.includes("tool_search")?"Use tool_search to find":n.includes("codemode")?"Use searchTools inside codemode to find":"Enable native tool_search to find",t=i.filter(c=>c.namespace?.name==="ide_git").map(c=>c.name),a=[...t.length===0?[]:[`${h} ${t.join(" and ")} in ide_git when staging or unstaging selected Git changes.`],...i.some(c=>c.name==="debug"&&c.namespace?.name==="ide_debug")?[`${h} debug in ide_debug when creating a debugger session.`]:[]],r=a.length===0?S:`${S}
39
68
 
40
69
  <ide_discovery>
41
- ${i.join(`
70
+ ${a.join(`
42
71
  `)}
43
- </ide_discovery>`;return o===u.systemPrompt?void 0:{systemPrompt:o}});let r=await Z(F()),m=de(e,{"pi-agent-ide-no-animations":r.noAnimations??!1,"pi-agent-ide-no-post-processing":r.noPostProcessing??!1,...r.flags});m.register({id:"pi-agent-ide-no-animations",name:"Static edit previews",group:"ui",description:"Show edit results immediately, without animated playback.",default:!1}),m.register({id:"pi-agent-ide-no-post-processing",name:"Skip automatic post-processing",description:"Skip automatic formatting and diagnostics after edits. Explicit diagnostic reads still work.",default:!1}),m.register({id:"pi-agent-ide-vision-arbitrary-windows",name:"Capture arbitrary windows",description:"Allow window:PID capture for processes not owned by Agent IDE. Keep disabled unless the agent may inspect other desktop apps.",default:!1}),m.register({id:"pi-agent-ide-vision-displays",name:"Capture full displays",description:"Allow display screenshots through display: and display:#N resources. Keep disabled unless the agent may inspect the full desktop.",default:!1}),m.register({id:"pi-agent-ide-no-diagnostic-buffer",name:"Immediate diagnostic notices",description:"Send findings immediately instead of combining reports received over five seconds.",group:"ui",default:!1}),m.register({id:"pi-agent-ide-code-review",name:"Jev code review",description:"Review saved edit fragments against project YAML rules in the background. Sends code to a connected Jev provider.",default:!1}),m.register({id:"pi-agent-ide-code-review-capture",name:"Capture code-review rules",description:"Use the packaged skill to propose reusable rules from user review feedback. Save only after confirmation.",default:!1}),ae(e,m.definitions,ne);let h=$(M,r.preset??"full"),{enabled:T}=U(M,[...h,...r.disabled],r.enabled);for(let u of T)await u.register(c.api,{preferences:r.preferences??{}});l.finalize(),p.finalize()}f(He,"registerUnifiedPiAgentIde");export{He as default};
72
+ </ide_discovery>`;return r===x.systemPrompt?void 0:{systemPrompt:r}});let y=ge(e,{"pi-agent-ide-no-animations":s.noAnimations??!1,"pi-agent-ide-no-post-processing":s.noPostProcessing??!1,...s.flags});y.register({id:"pi-agent-ide-developer-mode",name:"Developer mode",description:"Enable development commands, including manual setup-hint previews.",default:!1}),y.register({id:"pi-agent-ide-no-animations",name:"Static edit previews",group:"ui",description:"Show edit results immediately, without animated playback.",default:!1}),y.register({id:"pi-agent-ide-no-post-processing",name:"Skip automatic post-processing",description:"Skip automatic formatting and diagnostics after edits. Explicit diagnostic reads still work.",default:!1}),y.register({id:"pi-agent-ide-vision-arbitrary-windows",name:"Capture arbitrary windows",description:"Allow window:PID capture for processes not owned by Agent IDE. Keep disabled unless the agent may inspect other desktop apps.",default:!1}),y.register({id:"pi-agent-ide-vision-displays",name:"Capture full displays",description:"Allow display screenshots through display: and display:#N resources. Keep disabled unless the agent may inspect the full desktop.",default:!1}),y.register({id:"pi-agent-ide-no-diagnostic-buffer",name:"Immediate diagnostic notices",description:"Send findings immediately instead of combining reports received over five seconds.",group:"ui",default:!1}),y.register({id:"pi-agent-ide-code-review",name:"Jev code review",description:"Review saved edit fragments against project YAML rules in the background. Sends code to a connected Jev provider.",default:!1}),y.register({id:"pi-agent-ide-code-review-capture",name:"Capture code-review rules",description:"Use the packaged skill to propose reusable rules from user review feedback. Save only after confirmation.",default:!1}),fe(e,y.definitions,G),pe(e),Z(e,[me(y.definitions)]);let E=B(N,s.preset??"full"),{enabled:m}=q(N,[...E,...s.disabled],s.enabled);for(let x of m)await x.register(g.api,{preferences:s.preferences??{}});l.finalize(),o.finalize()}u(it,"registerUnifiedPiAgentIde");export{it as default};