pi-agent-ide 0.9.0 → 0.9.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 (317) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{chunk-TVH2ND35.js → chunk-35LZOKEW.js} +1 -1
  3. package/dist/chunk-3LVBARLW.js +33 -0
  4. package/dist/chunk-4GBFIGH3.js +1 -1
  5. package/dist/{chunk-64JTD2DJ.js → chunk-5PC5INOL.js} +1 -1
  6. package/dist/{chunk-FKKAHI62.js → chunk-BT2CFM7D.js} +1 -1
  7. package/dist/{chunk-VN3XBH2Q.js → chunk-DVNL5NZE.js} +1 -1
  8. package/dist/{chunk-PLMHBXWI.js → chunk-FXPY3V4L.js} +1 -1
  9. package/dist/{chunk-AJZVKDYC.js → chunk-HGCJDIRR.js} +1 -1
  10. package/dist/{chunk-RVFMH77U.js → chunk-HISGZD3C.js} +43 -44
  11. package/dist/{chunk-KFBRL2V4.js → chunk-HKYVP2Q6.js} +1 -1
  12. package/dist/{chunk-TVXZE4KW.js → chunk-HRBUY2FF.js} +1 -1
  13. package/dist/{chunk-QM5WDEFI.js → chunk-IOGWZNWT.js} +1 -1
  14. package/dist/{chunk-HT7LZN5A.js → chunk-IUJUECXH.js} +1 -1
  15. package/dist/chunk-LXDF2NWX.js +1 -0
  16. package/dist/{chunk-TVSZYABY.js → chunk-MPNE25CY.js} +1 -1
  17. package/dist/{chunk-Y74EKJOY.js → chunk-O7V6G3OO.js} +1 -1
  18. package/dist/chunk-OUCVZBOR.js +28 -0
  19. package/dist/{chunk-WUO3UW4J.js → chunk-PCGBM2D6.js} +1 -1
  20. package/dist/{chunk-V4J3TLCV.js → chunk-RIZARTUM.js} +1 -1
  21. package/dist/{chunk-LTADNZKW.js → chunk-T3Z4KXOX.js} +1 -1
  22. package/dist/chunk-TSQ6FBTB.js +1 -0
  23. package/dist/{chunk-CVOYSEBE.js → chunk-VNWGT367.js} +1 -1
  24. package/dist/{chunk-FS3KCKFX.js → chunk-X2WFNMQR.js} +1 -1
  25. package/dist/{chunk-7SG756UO.js → chunk-XCPIIDFS.js} +1 -1
  26. package/dist/entry-0.js +1 -1
  27. package/dist/entry-1.js +1 -1
  28. package/dist/entry-10.js +1 -1
  29. package/dist/entry-11.js +1 -1
  30. package/dist/entry-12.js +1 -1
  31. package/dist/entry-13.js +1 -1
  32. package/dist/entry-14.js +1 -1
  33. package/dist/entry-15.js +1 -1
  34. package/dist/entry-16.js +1 -1
  35. package/dist/entry-17.js +1 -1
  36. package/dist/entry-18.js +1 -1
  37. package/dist/entry-19.js +1 -1
  38. package/dist/entry-2.js +1 -1
  39. package/dist/entry-20.js +1 -1
  40. package/dist/entry-21.js +1 -1
  41. package/dist/entry-22.js +1 -0
  42. package/dist/entry-24.js +1 -1
  43. package/dist/entry-25.js +1 -1
  44. package/dist/entry-26.js +1 -1
  45. package/dist/entry-27.js +1 -1
  46. package/dist/entry-28.js +1 -1
  47. package/dist/entry-29.js +1 -1
  48. package/dist/entry-3.js +1 -1
  49. package/dist/entry-30.js +1 -2
  50. package/dist/entry-31.js +2 -1
  51. package/dist/entry-32.js +1 -1
  52. package/dist/entry-33.js +1 -1
  53. package/dist/entry-34.js +1 -1
  54. package/dist/entry-35.js +1 -1
  55. package/dist/entry-36.js +1 -1
  56. package/dist/entry-37.js +1 -15
  57. package/dist/entry-38.js +15 -1
  58. package/dist/entry-39.js +1 -1
  59. package/dist/entry-4.js +1 -1
  60. package/dist/entry-40.js +1 -1
  61. package/dist/entry-41.js +1 -1
  62. package/dist/entry-42.js +1 -1
  63. package/dist/entry-43.js +1 -1
  64. package/dist/entry-44.js +1 -1
  65. package/dist/entry-45.js +1 -1
  66. package/dist/entry-46.js +1 -1
  67. package/dist/entry-47.js +1 -1
  68. package/dist/entry-48.js +1 -1
  69. package/dist/entry-49.js +1 -1
  70. package/dist/entry-5.js +1 -1
  71. package/dist/entry-50.js +1 -1
  72. package/dist/entry-51.js +1 -1
  73. package/dist/entry-52.js +1 -1
  74. package/dist/entry-53.js +1 -1
  75. package/dist/entry-54.js +1 -1
  76. package/dist/entry-55.js +1 -1
  77. package/dist/entry-56.js +1 -1
  78. package/dist/entry-57.js +1 -1
  79. package/dist/entry-58.js +1 -1
  80. package/dist/entry-59.js +1 -1
  81. package/dist/entry-6.js +1 -1
  82. package/dist/entry-60.js +1 -1
  83. package/dist/entry-61.js +1 -1
  84. package/dist/entry-62.js +1 -1
  85. package/dist/entry-63.js +1 -1
  86. package/dist/entry-64.js +1 -1
  87. package/dist/entry-65.js +1 -1
  88. package/dist/entry-66.js +1 -1
  89. package/dist/entry-67.js +1 -0
  90. package/dist/entry-68.js +0 -1
  91. package/dist/entry-69.js +1 -0
  92. package/dist/entry-7.js +1 -1
  93. package/dist/entry-70.js +0 -1
  94. package/dist/entry-71.js +1 -1
  95. package/dist/entry-72.js +1 -1
  96. package/dist/entry-73.js +1 -1
  97. package/dist/entry-74.js +1 -1
  98. package/dist/entry-75.js +1 -1
  99. package/dist/entry-76.js +1 -1
  100. package/dist/entry-77.js +1 -0
  101. package/dist/entry-78.js +0 -1
  102. package/dist/entry-79.js +1 -0
  103. package/dist/entry-8.js +1 -1
  104. package/dist/entry-80.js +0 -1
  105. package/dist/entry-81.js +1 -1
  106. package/dist/entry-82.js +1 -1
  107. package/dist/entry-83.js +1 -1
  108. package/dist/entry-84.js +1 -1
  109. package/dist/entry-85.js +1 -2
  110. package/dist/entry-86.js +2 -1
  111. package/dist/entry-87.js +1 -1
  112. package/dist/entry-88.js +1 -1
  113. package/dist/entry-89.js +1 -1
  114. package/dist/entry-9.js +1 -1
  115. package/dist/entry-90.js +1 -3
  116. package/dist/entry-91.js +3 -1
  117. package/dist/entry-92.js +1 -1
  118. package/dist/entry-93.js +1 -1
  119. package/dist/entry-94.js +1 -0
  120. package/dist/pi-agent-ide.js +13 -10
  121. package/docs/agent-guides/editing.md +3 -0
  122. package/docs/tools.md +2 -2
  123. package/node_modules/pi-agent-doctor/package.json +7 -7
  124. package/node_modules/pi-agent-documentation/package.json +2 -2
  125. package/node_modules/pi-agent-documentation/runtime/entry-30.js +1 -0
  126. package/node_modules/pi-agent-filesystem/package.json +8 -8
  127. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  128. package/node_modules/pi-agent-filesystem-image/runtime/entry-32.js +2 -0
  129. package/node_modules/pi-agent-filesystem-jq/package.json +7 -7
  130. package/node_modules/pi-agent-filesystem-jq/runtime/entry-33.js +0 -1
  131. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  132. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  133. package/node_modules/pi-agent-filesystem-text/runtime/entry-36.js +2 -0
  134. package/node_modules/pi-agent-ide-ast/package.json +15 -15
  135. package/node_modules/pi-agent-ide-ast/runtime/entry-37.js +0 -1
  136. package/node_modules/pi-agent-ide-ast/runtime/entry-38.js +2 -0
  137. package/node_modules/pi-agent-ide-changes/package.json +10 -10
  138. package/node_modules/pi-agent-ide-changes/runtime/entry-39.js +0 -1
  139. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  140. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  141. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  142. package/node_modules/pi-agent-ide-lsp/package.json +13 -13
  143. package/node_modules/pi-agent-ide-lsp/runtime/entry-44.js +2 -0
  144. package/node_modules/pi-agent-image/package.json +3 -3
  145. package/node_modules/pi-agent-invariant/package.json +2 -2
  146. package/node_modules/pi-agent-pdf/package.json +3 -3
  147. package/node_modules/pi-agent-read/package.json +12 -12
  148. package/node_modules/pi-agent-read/runtime/entry-51.js +0 -1
  149. package/node_modules/pi-agent-read/runtime/entry-52.js +2 -0
  150. package/node_modules/pi-agent-resource/package.json +2 -2
  151. package/node_modules/pi-agent-search/package.json +9 -9
  152. package/node_modules/pi-agent-search/runtime/entry-56.js +0 -1
  153. package/node_modules/pi-agent-search-text/package.json +15 -15
  154. package/node_modules/pi-agent-search-text/runtime/entry-58.js +1 -0
  155. package/node_modules/pi-agent-text/package.json +3 -3
  156. package/node_modules/pi-agent-text/runtime/entry-62.js +1 -0
  157. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  158. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-63.js +2 -0
  159. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  160. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-64.js +0 -1
  161. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-65.js +2 -0
  162. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  163. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-66.js +0 -1
  164. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-67.js +2 -0
  165. package/node_modules/pi-agent-text-editor/package.json +26 -26
  166. package/node_modules/pi-agent-text-editor/runtime/entry-83.js +0 -1
  167. package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +2 -6
  168. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +17 -36
  169. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +40 -82
  170. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +1 -1
  171. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -9
  172. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -3
  173. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -5
  174. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +2 -8
  175. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  176. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +6 -6
  177. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +2 -0
  178. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  179. package/node_modules/pi-agent-tool-ui/package.json +3 -3
  180. package/node_modules/pi-agent-tool-ui/runtime/entry-89.js +1 -0
  181. package/node_modules/pi-agent-web/package.json +8 -8
  182. package/node_modules/pi-agent-web-html/package.json +3 -3
  183. package/node_modules/pi-agent-web-image/package.json +4 -4
  184. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  185. package/node_modules/pi-agent-web-text/package.json +4 -4
  186. package/node_modules/pi-agent-web-text/runtime/entry-94.js +2 -0
  187. package/package.json +60 -56
  188. package/src/api/capabilities.ts +60 -0
  189. package/src/composite/capabilities.ts +252 -0
  190. package/src/composite/capability-schemas.ts +53 -0
  191. package/src/composite/responses-tools.ts +27 -9
  192. package/src/composite/tool-availability.ts +28 -13
  193. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
  194. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  195. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-32.js +2 -0
  196. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +7 -7
  197. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-33.js +0 -1
  198. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  199. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  200. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-36.js +2 -0
  201. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-31.js +2 -0
  202. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
  203. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  204. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  205. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  206. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  207. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-94.js +2 -0
  208. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-90.js +2 -0
  209. package/src/extensions/pi-agent-read/package.json +12 -12
  210. package/src/extensions/pi-agent-read/runtime/entry-51.js +0 -1
  211. package/src/extensions/pi-agent-read/runtime/entry-52.js +2 -0
  212. package/src/extensions/pi-agent-search/package.json +9 -9
  213. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +15 -15
  214. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-58.js +1 -0
  215. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-61.js +1 -0
  216. package/src/extensions/pi-agent-search/runtime/entry-56.js +0 -1
  217. package/src/extensions/pi-agent-search/runtime/entry-57.js +2 -0
  218. package/src/extensions/pi-agent-text-editor/package.json +26 -26
  219. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  220. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-63.js +2 -0
  221. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  222. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-64.js +0 -1
  223. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-65.js +2 -0
  224. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  225. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-66.js +0 -1
  226. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-67.js +2 -0
  227. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  228. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +6 -6
  229. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +2 -0
  230. package/src/extensions/pi-agent-text-editor/runtime/entry-83.js +0 -1
  231. package/src/extensions/pi-agent-text-editor/runtime/entry-84.js +2 -0
  232. package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +2 -6
  233. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +17 -36
  234. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +40 -82
  235. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +1 -1
  236. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -9
  237. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -3
  238. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -5
  239. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +2 -8
  240. package/src/pi-agent-ide.ts +4 -1
  241. package/src/plugins/pi-agent-ide-ast/package.json +15 -15
  242. package/src/plugins/pi-agent-ide-ast/runtime/entry-37.js +0 -1
  243. package/src/plugins/pi-agent-ide-ast/runtime/entry-38.js +2 -0
  244. package/src/plugins/pi-agent-ide-changes/package.json +10 -10
  245. package/src/plugins/pi-agent-ide-changes/runtime/entry-39.js +0 -1
  246. package/src/plugins/pi-agent-ide-debugger/index.ts +31 -26
  247. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  248. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  249. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  250. package/src/plugins/pi-agent-ide-lsp/package.json +13 -13
  251. package/src/plugins/pi-agent-ide-lsp/runtime/entry-44.js +2 -0
  252. package/src/plugins/pi-agent-ide-terminal/index.ts +42 -0
  253. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +0 -21
  254. package/src/plugins/pi-agent-ide-terminal/src/search.ts +0 -3
  255. package/dist/chunk-7URANI6I.js +0 -28
  256. package/dist/chunk-K4UTEMDU.js +0 -1
  257. package/dist/chunk-TNAUCNUT.js +0 -33
  258. package/dist/entry-23.js +0 -1
  259. package/node_modules/pi-agent-doctor/runtime/entry-23.js +0 -1
  260. package/node_modules/pi-agent-filesystem/runtime/entry-30.js +0 -2
  261. package/node_modules/pi-agent-filesystem-jq/runtime/entry-32.js +0 -1
  262. package/node_modules/pi-agent-ide-ast/runtime/entry-36.js +0 -1
  263. package/node_modules/pi-agent-ide-changes/runtime/entry-38.js +0 -1
  264. package/node_modules/pi-agent-image/runtime/entry-44.js +0 -1
  265. package/node_modules/pi-agent-resource/runtime/entry-52.js +0 -1
  266. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-62.js +0 -2
  267. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-63.js +0 -1
  268. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-65.js +0 -1
  269. package/node_modules/pi-agent-text-editor/runtime/entry-67.js +0 -1
  270. package/node_modules/pi-agent-tool-call-interception/runtime/entry-86.js +0 -1
  271. package/node_modules/pi-agent-web/runtime/entry-89.js +0 -2
  272. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-31.js +0 -2
  273. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-32.js +0 -1
  274. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-30.js +0 -2
  275. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-90.js +0 -2
  276. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-89.js +0 -2
  277. package/src/extensions/pi-agent-read/runtime/entry-47.js +0 -1
  278. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-57.js +0 -2
  279. package/src/extensions/pi-agent-search/runtime/entry-53.js +0 -1
  280. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-62.js +0 -2
  281. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-63.js +0 -1
  282. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-65.js +0 -1
  283. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-84.js +0 -2
  284. package/src/extensions/pi-agent-text-editor/runtime/entry-67.js +0 -1
  285. package/src/plugins/pi-agent-ide-ast/runtime/entry-36.js +0 -1
  286. package/src/plugins/pi-agent-ide-changes/runtime/entry-38.js +0 -1
  287. /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-29.js +0 -0
  288. /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-31.js +0 -0
  289. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-34.js +0 -0
  290. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-35.js +0 -0
  291. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-40.js +0 -0
  292. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-41.js +0 -0
  293. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-42.js +0 -0
  294. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-43.js +0 -0
  295. /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-45.js +0 -0
  296. /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-46.js +0 -0
  297. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-47.js +0 -0
  298. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-53.js +0 -0
  299. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-57.js +0 -0
  300. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-61.js +0 -0
  301. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-84.js +0 -0
  302. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-85.js +0 -0
  303. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-87.js +0 -0
  304. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-90.js +0 -0
  305. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-91.js +0 -0
  306. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-92.js +0 -0
  307. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-93.js +0 -0
  308. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-34.js +0 -0
  309. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-35.js +0 -0
  310. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-91.js +0 -0
  311. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-92.js +0 -0
  312. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-93.js +0 -0
  313. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-85.js +0 -0
  314. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-40.js +0 -0
  315. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-41.js +0 -0
  316. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-42.js +0 -0
  317. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-43.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.1 — 2026-10-30
4
+
5
+ ### On-demand tool guidance
6
+
7
+ - Terminal and debugger instructions now load on demand, reducing always-on tool metadata.
8
+ - Extension authors can register additive tool descriptions, parameter help and guidelines through `pi-agent-ide/api/capabilities`, with optional discovery loaders. Tool execution and permissions stay unchanged.
9
+ - Capability discovery results render without internal protocol markup in the terminal UI.
10
+
11
+ ### Consistent text selections
12
+
13
+ - Insert now adds text at an exact selection's start or end instead of expanding it to whole lines. Whole-line selections still add needed line breaks.
14
+ - Copy and Move preserve selected text and line endings, independent of the destination. A whole-line source includes its own LF or CRLF even when the destination is a character selection.
15
+ - Deleting an unterminated final line no longer consumes the preceding line separator. Empty Replace removes the same range as Delete.
16
+
17
+ ### Model compatibility
18
+
19
+ - OpenAI Responses keeps optional IDE arguments optional, including tools discovered during a conversation.
20
+
3
21
  ## 0.9.0 — 2026-10-26
4
22
 
5
23
  ### Search split into focused tools
@@ -1,3 +1,3 @@
1
- import{b as x}from"./chunk-T4FTT3U4.js";import{j as $}from"./chunk-VDJSH3DQ.js";import{a as m}from"./chunk-KINKBPPX.js";import{a as p}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";function D(e,n,t){let i=`${n}:`;if(!e.startsWith(i))return;let o=e.slice(i.length);if(o.length===0)throw new Error(`${n}: requires a file path.`);return x(o,t)}a(D,"resolveDiagnosticViewPath");function R(e,n){return`${e}:${n}`}a(R,"formatDiagnosticViewSource");function k(e,n,t,i={}){let o={complete:t.length>0&&t.every(d=>d.status==="ready"),count:t.reduce((d,u)=>d+u.diagnostics.length,0),sources:t.map(d=>d.source)},r=n.split(/\r\n|\r|\n/u),s=b(t,r.length);if(s.size===0)return{type:"text",diagnosticCheck:o,text:L(t)||"No completed diagnostic checks are available.",sourceLines:{}};let c=i.contextLines??5;if(!Number.isInteger(c)||c<0)throw new TypeError("Diagnostic contextLines must be a non-negative integer.");let l=new Set;for(let d of s.keys()){let u=Math.max(1,d-c),f=Math.min(r.length,d+c);for(let g=u;g<=f;g+=1)l.add(g)}let w=L(t),y=w?[w]:[],h={};for(let d of[...l].sort((u,f)=>u-f)){let u=r[d-1]??"",f=(s.get(d)??[]).map(({diagnostic:g,source:V})=>`<!-- ${V}: ${m(g,V)} -->`).join(" ");y.push(f.length===0?u:`${u} ${f}`),h[String(y.length)]={source:e,lineNumber:d,content:u}}return{type:"text",diagnosticCheck:o,text:y.join(`
1
+ import{b as x}from"./chunk-T4FTT3U4.js";import{j as $}from"./chunk-VDJSH3DQ.js";import{a as p}from"./chunk-ZC65Z3CK.js";import{a as m}from"./chunk-KINKBPPX.js";import{a}from"./chunk-EI7MMDWY.js";function D(e,n,t){let i=`${n}:`;if(!e.startsWith(i))return;let o=e.slice(i.length);if(o.length===0)throw new Error(`${n}: requires a file path.`);return x(o,t)}a(D,"resolveDiagnosticViewPath");function R(e,n){return`${e}:${n}`}a(R,"formatDiagnosticViewSource");function k(e,n,t,i={}){let o={complete:t.length>0&&t.every(d=>d.status==="ready"),count:t.reduce((d,u)=>d+u.diagnostics.length,0),sources:t.map(d=>d.source)},r=n.split(/\r\n|\r|\n/u),s=b(t,r.length);if(s.size===0)return{type:"text",diagnosticCheck:o,text:L(t)||"No completed diagnostic checks are available.",sourceLines:{}};let c=i.contextLines??5;if(!Number.isInteger(c)||c<0)throw new TypeError("Diagnostic contextLines must be a non-negative integer.");let l=new Set;for(let d of s.keys()){let u=Math.max(1,d-c),f=Math.min(r.length,d+c);for(let g=u;g<=f;g+=1)l.add(g)}let w=L(t),y=w?[w]:[],h={};for(let d of[...l].sort((u,f)=>u-f)){let u=r[d-1]??"",f=(s.get(d)??[]).map(({diagnostic:g,source:V})=>`<!-- ${V}: ${m(g,V)} -->`).join(" ");y.push(f.length===0?u:`${u} ${f}`),h[String(y.length)]={source:e,lineNumber:d,content:u}}return{type:"text",diagnosticCheck:o,text:y.join(`
2
2
  `),sourceLines:h}}a(k,"createDiagnosticViewContent");function T(e,n){let t=b(n,e.lines.length,/[\r\n]$/u.test(e.content)),i=e.lines.map(o=>{let r=t.get(o.lineNumber);if(r===void 0)return o;let s=r.map(({diagnostic:c,source:l})=>`<!-- ${l}: ${m(c,l)}${c.line===o.lineNumber?"":` @${c.line}:${c.column}`} -->`).join(" ");return{...o,presentation:{...o.presentation,suffix:`${o.presentation?.suffix??""} ${s}`}}});return{...e,lines:i}}a(T,"addDiagnosticAnnotations");function L(e){return e.length>0&&e.every(n=>n.status==="ready"&&n.diagnostics.length===0)?`Checks completed (${e.map(n=>n.source).join(", ")}); no diagnostics found at this point.`:e.filter(n=>n.status&&n.status!=="ready").map(n=>`${n.source}: ${n.status}${n.reason?` (${n.reason})`:""}.`).join(" ")}a(L,"diagnosticStatus");function b(e,n,t=!1){let i=new Map;for(let{diagnostics:o,source:r}of e)for(let s of o){let c=t&&s.line===n+1?n:s.line;if(!Number.isInteger(s.line)||c<1||c>n)continue;let l=i.get(c)??[];l.push({diagnostic:s,source:r}),i.set(c,l)}return i}a(b,"diagnosticsByValidLine");function C(e){return{text:`${e.content}${e.suffix??""}`,...e.sourceLine!==void 0&&{sourceLine:e.sourceLine}}}a(C,"renderSourceViewLine");function v(e,n){if(e.length===0)return S([{text:"<empty-result>"}]);if(e.length===1&&p(e[0]).status==="failed"&&p(e[0]).path===""){let i=p(e[0]),o=n.recovery===void 0?[]:["","Recovery:",...n.recovery],r=n.includeNoChange===!0?["","No file was changed."]:[];return S([i.code??n.failureLabel,"",`Reason: ${i.error??n.unknownFailure??"unknown failure"}`,...r,...o].map(s=>({text:s})))}let t=[];for(let[i,o]of e.entries())i>0&&t.push({text:""},{text:""}),t.push(...M(o,n));return S(t)}a(v,"formatSourceViewResults");function N(){return e=>{let n=e.state;if(n?.contentKind!=="text")return{kind:"continue",context:e};let t=j(n.content[0]);if(t===void 0)return{kind:"continue",context:e};let i=n.text.lines.map(o=>{let r=t[String(o.lineNumber)];return r===void 0?o:$(o,r)});return{kind:"continue",context:{...e,state:{...n,text:{...n.text,lines:i}}}}}}a(N,"createSourceMappedTextReadHandler");function M(e,n){if(e.status==="failed")return[...e.heading===void 0?[`## file: ${e.path||"<unknown>"}`]:[`## ${e.heading}`,...e.details??[]],`${n.failureLabel} | ${e.error??n.unknownFailure??"unknown failure"}`].map(s=>({text:s}));let t=e.heading===void 0?[`## file: ${e.path}`]:[`## ${e.heading}`,...e.details??[]],i=e.continuation??"",o=e.warning===void 0?[]:[{text:""},{text:e.warning}];return[...t.map(r=>({text:r})),{text:`Lines: ${e.startLine}-${e.endLine} of ${e.totalLines}${i}`},{text:""},...e.renderedLines,...o]}a(M,"formatSourceViewBlock");function S(e){let n={};for(let[t,i]of e.entries())i.sourceLine!==void 0&&(n[String(t+1)]=i.sourceLine);return{type:"text",text:e.map(t=>t.text).join(`
3
3
  `),sourceLines:n}}a(S,"sourceMappedContent");function j(e){if(typeof e!="object"||e===null||!("sourceLines"in e))return;let n=e.sourceLines;if(!(typeof n!="object"||n===null)){for(let t of Object.values(n))if(!B(t))return;return n}}a(j,"sourceLineMap");function B(e){if(typeof e!="object"||e===null)return!1;let n=e;return typeof n.source=="string"&&n.source.length>0&&Number.isInteger(n.lineNumber)&&(n.lineNumber??0)>0&&typeof n.content=="string"}a(B,"isTextSourceLine");export{D as a,R as b,k as c,T as d,L as e,C as f,v as g,N as h};
@@ -0,0 +1,33 @@
1
+ import{a as ze,b as Ke,c as Xe}from"./chunk-PBQDHYNX.js";import{a as We}from"./chunk-L2B4DTVS.js";import{a as Je}from"./chunk-AMIIOWFL.js";import{a as Me}from"./chunk-LF325WYO.js";import{a as qe,b as Ve,c as Ge}from"./chunk-WQIMM4SU.js";import{a as X,g as D}from"./chunk-4IWEKRSP.js";import{a as U}from"./chunk-K5G4FDXD.js";import{c as He}from"./chunk-W7CASEO3.js";import{a as ce,b as S,c as T}from"./chunk-R2U5WXYR.js";import{f as je,g as $e}from"./chunk-KN6VPARZ.js";import{a as Oe}from"./chunk-MDD5ORB6.js";import{b as Le,c as Be}from"./chunk-MLFJU2US.js";import{e as Ce}from"./chunk-PS2B6THP.js";import{a as Ne}from"./chunk-GXL4NMHR.js";import{c as Te,d as xe}from"./chunk-PQWANILR.js";import{a as Ie}from"./chunk-BU7IZLKB.js";import{a as Ae,b as Re}from"./chunk-S5PL5DFQ.js";import{j as Ee,m as _e,n as ue}from"./chunk-DDH3FP4G.js";import{d as Ue}from"./chunk-756K3LJY.js";import{d as Fe}from"./chunk-TSQ6FBTB.js";import"./chunk-VDJSH3DQ.js";import{a as d}from"./chunk-EI7MMDWY.js";import O from"node:path";import{access as Jr}from"node:fs/promises";import{StringEnum as At}from"@earendil-works/pi-ai";import{defineTool as Gr}from"@earendil-works/pi-coding-agent";import{Type as y}from"typebox";async function Y(r,e=process.env,t=process.platform,n=o=>Ue(o,r,e)){if(e.PI_PYTHON_PATH!==void 0)return{command:e.PI_PYTHON_PATH,args:[]};let o=t==="win32"?[{command:"python",args:[]},{command:"python3",args:[]},{command:"py",args:["-3"]}]:[{command:"python3",args:[]},{command:"python",args:[]}];for(let a of o)if(await n(a.command))return a;return o[0]}d(Y,"resolvePythonDebuggerCommand");import Mt from"cross-spawn";import{cp as Jt,mkdtemp as Gt,readdir as Wt,rm as zt,stat as Z}from"node:fs/promises";import{tmpdir as Kt}from"node:os";import Xt from"node:net";import A from"node:path";import{pathToFileURL as Yt}from"node:url";import{createMessageConnection as Zt,StreamMessageReader as Qt,StreamMessageWriter as er}from"vscode-jsonrpc/node";import Ft from"cross-spawn";import Ht from"node:net";var qt=new Set(["initialized","stopped","continued","terminated","exited","loadedSource","breakpoint","custom"]),Vt=128,k=class r{static{d(this,"DapClient")}#o;#a;#r;#t;#i;#e=new Map;#u=[];#d=new Set;#m=new Set;#l=Buffer.alloc(0);#f=1;#p;#h;#b;constructor(e,t,n,o){this.#o=e,this.#a=t,this.#r=n,this.#t=o,o&&o.completion.then(()=>this.#s(new Error("Debug adapter transport completed")),a=>this.#s(a instanceof Error?a:new Error("Debug adapter transport failed"))),e.on("data",a=>this.#v(a)),e.once("error",a=>this.#s(a)),t.once("error",a=>this.#s(a)),e.once("close",()=>this.#s(new Error("Debug adapter connection closed"))),n!==void 0&&(n.stderr.on("data",a=>{process.env.PI_DEBUG_DAP_TRACE==="1"&&process.stderr.write(a)}),n.once("error",a=>this.#s(a)),n.once("exit",(a,i)=>{this.#s(new Error(`Debug adapter exited${a===null?"":` with code ${a}`}${i===null?"":` (${i})`}`))}))}static start(e,t,n){let a=Ft(e,[...t],{cwd:n,env:process.env,stdio:["pipe","pipe","pipe"]});return new r(a.stdout,a.stdin,a)}static fromTransport(e){return new r(e.readable,e.writable,void 0,e)}static fromSocket(e,t=1){let n=new r(e,e);return n.#f=t,n}static connect(e,t="127.0.0.1"){return new Promise((n,o)=>{let a=Ht.createConnection({port:e,host:t}),i=d(s=>o(s),"fail");a.once("error",i),a.once("connect",()=>{a.off("error",i),n(new r(a,a))})})}onReverseRequest(e){this.#h=e}onEvent(e){return this.#m.add(e),()=>this.#m.delete(e)}request(e,t,n={}){if(this.#p!==void 0)return Promise.reject(this.#p);if(n.signal?.aborted===!0)return Promise.reject(n.signal.reason instanceof Error?n.signal.reason:new Error("Debug operation aborted"));["continue","next","stepIn","stepOut"].includes(e)&&(this.#b=void 0);let o=this.#f++,a={seq:o,type:"request",command:e,...t===void 0?{}:{arguments:t}},i=new Promise((s,u)=>{let c,p=d(()=>{c!==void 0&&clearTimeout(c),n.signal?.removeEventListener("abort",m)},"cleanup"),m=d(()=>{this.#e.delete(o),p(),u(n.signal?.reason instanceof Error?n.signal.reason:new Error("Debug operation aborted"))},"abort");n.timeoutMs!==void 0&&(c=setTimeout(()=>{this.#e.delete(o),p(),u(new Error(`Timed out waiting for debug response ${e}`))},n.timeoutMs)),this.#e.set(o,{resolve:d(l=>s(l),"resolve"),reject:u,cleanup:p}),n.signal?.addEventListener("abort",m,{once:!0})});return this.#w(a),i}takeEvent(e){let t=this.#u.findIndex(n=>e.includes(n.event));return t<0?void 0:this.#u.splice(t,1)[0]}waitForEvent(e,t=3e4){return this.waitForAnyEvent([e],t)}waitForAnyEvent(e,t=3e4,n){let o=new Set(e),a=this.#u.findIndex(i=>o.has(i.event));return a>=0?Promise.resolve(this.#u.splice(a,1)[0]):this.#p!==void 0?Promise.reject(this.#p):new Promise((i,s)=>{let u={events:o,resolve:d(p=>{clearTimeout(u.timer),this.#d.delete(u),i(p)},"resolve"),reject:d(p=>{clearTimeout(u.timer),this.#d.delete(u),s(p)},"reject"),timer:setTimeout(()=>{this.#d.delete(u),s(new Error(`Timed out waiting for debug event ${e.join(" or ")}`))},t)};this.#d.add(u);let c=d(()=>u.reject(n?.reason instanceof Error?n.reason:new Error("Debug operation aborted")),"abort");n?.aborted===!0?c():n?.addEventListener("abort",c,{once:!0})})}close(){this.#o.destroy(),this.#a.destroy(),this.#r!==void 0&&!this.#r.killed&&this.#r.kill(),this.#s(new Error("Debug adapter closed")),this.#t&&!this.#i&&(this.#i=Promise.resolve().then(()=>this.#t?.stop()),this.#i.catch(()=>{}))}async dispose(){this.close(),await this.#i}#w(e){let t=Buffer.from(JSON.stringify(e),"utf8");this.#a.write(Buffer.concat([Buffer.from(`Content-Length: ${t.length}\r
2
+ \r
3
+ `),t]))}#v(e){for(this.#l=Buffer.concat([this.#l,e]);;){let t=this.#l.indexOf(`\r
4
+ \r
5
+ `);if(t<0)return;let n=this.#l.subarray(0,t).toString("ascii"),o=/^Content-Length:\s*(\d+)$/imu.exec(n);if(o===null){this.#s(new Error("Debug adapter sent a frame without Content-Length"));return}let a=Number(o[1]),i=t+4;if(this.#l.length<i+a)return;let s=this.#l.subarray(i,i+a).toString("utf8");this.#l=this.#l.subarray(i+a);try{this.#y(JSON.parse(s))}catch(u){this.#s(u instanceof Error?u:new Error(String(u)));return}}}#y(e){if(e.type==="event")if(e.event==="stopped"){let t=JSON.stringify(e.body??null);if(t===this.#b)return;this.#b=t}else e.event==="continued"&&(this.#b=void 0);if(e.type==="response"){let t=this.#e.get(e.request_seq);if(t===void 0)return;this.#e.delete(e.request_seq),t.cleanup(),e.success?t.resolve(e.body):t.reject(new Error(`${e.command}: ${e.message??"failed"}`));return}if(e.type==="event"){for(let n of this.#m)n(e);let t=[...this.#d].find(n=>n.events.has(e.event));t!==void 0?t.resolve(e):qt.has(e.event)&&(this.#u.length===Vt&&this.#u.shift(),this.#u.push(e));return}this.#g(e)}async#g(e){try{if(this.#h===void 0)throw new Error(`Client does not support reverse request ${e.command}`);let t=await this.#h(e);this.#w({seq:this.#f++,type:"response",request_seq:e.seq,success:!0,command:e.command,...t===void 0?{}:{body:t}})}catch(t){this.#w({seq:this.#f++,type:"response",request_seq:e.seq,success:!1,command:e.command,message:t instanceof Error?t.message:String(t)})}}#s(e){if(this.#p===void 0){this.#p=e;for(let t of this.#e.values())t.cleanup(),t.reject(e);this.#e.clear();for(let t of this.#d)t.reject(e);this.#d.clear()}}};function ee(r=process.env){return r.PI_JAVA_PATH??(r.JAVA_HOME===void 0?"java":A.join(r.JAVA_HOME,"bin",process.platform==="win32"?"java.exe":"java"))}d(ee,"javaExecutable");async function te(r=process.env,e=process.platform){let t=r.PI_JDTLS_HOME??"/opt/pi-debug-adapters/jdtls",n=r.PI_JAVA_DEBUG_PLUGIN_PATH??"/opt/pi-debug-adapters/java-debug/com.microsoft.java.debug.plugin-0.53.2.jar",o=A.join(t,e==="win32"?"config_win":"config_linux");try{let a=(await Wt(A.join(t,"plugins"))).filter(s=>/^org\.eclipse\.equinox\.launcher_[^/]+\.jar$/u.test(s));if(a.length!==1)throw new Error("Expected one Equinox launcher jar");let i=A.join(t,"plugins",a[0]);if(!(await Z(i)).isFile()||!(await Z(n)).isFile()||!(await Z(o)).isDirectory())throw new Error("Expected JDT LS configuration and Java debug plugin files");return{launcher:i,configuration:o,plugin:n}}catch(a){throw new Error(`Java debugger requires JDT LS (PI_JDTLS_HOME) and java-debug plugin (PI_JAVA_DEBUG_PLUGIN_PATH): ${a instanceof Error?a.message:String(a)}`,{cause:a})}}d(te,"javaDebuggerFiles");var H=class{static{d(this,"JavaDebugRuntime")}#o;#a;#r;#t;#i;#e;get processIds(){return[this.#o?.pid,this.#a?.pid].filter(e=>e!==void 0)}async start(e,t){if(t.throwIfAborted(),e.mainClass===void 0)throw new Error("Java debug sessions require mainClass");let n=await rr(e),o=await this.connect(e.cwd,t);t.throwIfAborted(),this.#a=this.#d(["-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=127.0.0.1:0","-cp",n.join(A.delimiter),e.mainClass,...e.args],e.cwd,process.env);let a=await nr(this.#a,t),i=A.dirname(e.sourceFile);for(let s of e.mainClass.split(".").slice(1))i=A.dirname(i);return{client:o,attach:{hostName:"127.0.0.1",port:a,timeout:1e4,sourcePaths:[i]}}}async connect(e,t,n=process.env){t.throwIfAborted();let o=await te(n);this.#i=await Gt(A.join(Kt(),"pi-java-debug-"));let a=A.join(this.#i,"configuration");await Jt(o.configuration,a,{recursive:!0});let i={...n};delete i.CLIENT_PORT,delete i.CLIENT_HOST,t.throwIfAborted(),this.#o=this.#d(["-Declipse.application=org.eclipse.jdt.ls.core.id1","-Dosgi.bundles.defaultStartLevel=4","-Declipse.product=org.eclipse.jdt.ls.core.product","-Xmx512m","--add-modules=ALL-SYSTEM","--add-opens","java.base/java.util=ALL-UNNAMED","--add-opens","java.base/java.lang=ALL-UNNAMED","-jar",o.launcher,"-configuration",a,"-data",A.join(this.#i,"workspace")],e,i);let s=this.#o;await Q(new Promise((f,g)=>{s.once("spawn",f),s.once("error",g)}),t);let u=new AbortController,c=new class extends er{async write(f){try{await super.write(f)}catch(g){u.abort(g)}}}(s.stdin),p=Zt(new Qt(s.stdout),c);this.#r=p;let m="";s.stderr.on("data",f=>{m=(m+f.toString()).slice(-4e3)}),s.once("error",f=>u.abort(f)),s.once("exit",f=>u.abort(new Error(`Java debugger language server exited (${String(f)}): ${m}`)));let l=AbortSignal.any([t,u.signal]);p.onRequest("workspace/configuration",f=>f.items.map(()=>null)),p.onRequest("client/registerCapability",()=>null),p.onRequest("window/workDoneProgress/create",()=>null),p.listen(),await Q(p.sendRequest("initialize",{processId:process.pid,rootUri:Yt(e).href,capabilities:{},initializationOptions:{bundles:[o.plugin],settings:{java:{import:{gradle:{enabled:!1},maven:{enabled:!1}}}}}}),l),await p.sendNotification("initialized",{});let h=await Q(p.sendRequest("workspace/executeCommand",{command:"vscode.java.startDebugSession",arguments:[]}),l);if(typeof h!="number"||!Number.isInteger(h)||h<1||h>65535)throw new Error("JDT LS did not return a Java DAP port; check PI_JAVA_DEBUG_PLUGIN_PATH");return this.#t=await tr(h,l),this.#t}close(){return this.#e??=this.#u(),this.#e}async#u(){this.#t?.close(),this.#r?.dispose(),await Promise.all([Ye(this.#a),Ye(this.#o)]),this.#i!==void 0&&await zt(this.#i,{recursive:!0,force:!0,maxRetries:10,retryDelay:100})}#d(e,t,n){let o=Mt(ee(n),[...e],{cwd:t,env:n,stdio:"pipe",windowsHide:!0});return o.stdin.on("error",()=>{}),o}};function tr(r,e){return e.throwIfAborted(),new Promise((t,n)=>{let o=Xt.createConnection({port:r,host:"127.0.0.1"}),a=d(()=>{o.destroy(),n(e.reason)},"abort"),i=d(()=>{e.removeEventListener("abort",a)},"cleanup");e.addEventListener("abort",a,{once:!0}),o.once("error",s=>{i(),n(s)}),o.once("connect",()=>{i(),t(k.fromSocket(o))})})}d(tr,"connectDap");async function rr(r){let e=`${r.mainClass.replaceAll(".",A.sep)}.class`,t=["build/classes/java/main","target/classes","out/production","bin","."],n=[];for(let o of t){let a=A.resolve(r.cwd,o);try{(await Z(A.join(a,e))).isFile()&&n.push(a)}catch{}}if(n.length===0)throw new Error(`Java main class ${r.mainClass} is not compiled. Compile with javac -g into build/classes/java/main, target/classes, out/production, bin, or the project directory.`);return n}d(rr,"javaClassPaths");async function Q(r,e){let t=d(()=>{},"abort"),n=new Promise((o,a)=>{t=d(()=>a(e.reason),"abort"),e.addEventListener("abort",t,{once:!0}),e.aborted&&t()});try{return await Promise.race([r,n])}finally{e.removeEventListener("abort",t)}}d(Q,"bounded");function nr(r,e){return Q(new Promise((t,n)=>{let o="",a=d(i=>{o=(o+i.toString()).slice(-4e3);let s=/Listening for transport dt_socket at address: (\d+)/u.exec(o);s!==null&&t(Number(s[1]))},"consume");r.stdout.on("data",a),r.stderr.on("data",a),r.once("error",n),r.once("exit",i=>n(new Error(`Java target exited before JDWP was ready (${String(i)}): ${o}`)))}),e)}d(nr,"targetReady");async function Ye(r){r===void 0||r.pid===void 0||r.exitCode!==null||r.signalCode!==null||await new Promise((e,t)=>{let n=d(()=>{clearTimeout(i),clearTimeout(s),r.removeListener("exit",o),r.removeListener("error",a)},"cleanup"),o=d(()=>{n(),e()},"exited"),a=d(u=>{n(),t(u)},"failed"),i=setTimeout(()=>{r.kill("SIGKILL")},500),s=setTimeout(()=>{n(),t(new Error(`Could not stop owned Java process ${String(r.pid)} within 2 seconds`))},2e3);r.once("exit",o),r.once("error",a),r.kill()})}d(Ye,"stopProcess");var Ze=[{language:"c",backend:"lldb-dap",status:"verified"},{language:"cpp",backend:"lldb-dap",status:"verified"},{language:"csharp",backend:"netcoredbg",status:"verified"},{language:"dart",backend:"dart debug_adapter",status:"verified"},{language:"elixir",backend:"elixir-ls",status:"verified"},{language:"go",backend:"dlv dap",status:"verified"},{language:"java",backend:"java-debug / JDT LS",status:"verified"},{language:"javascript",backend:"vscode-js-debug",status:"verified"},{language:"julia",backend:"DebugAdapter.jl",status:"verified"},{language:"kotlin",backend:"kotlin-debug-adapter",status:"verified"},{language:"lua",backend:"local-lua-debugger-vscode",status:"verified"},{language:"php",backend:"vscode-php-debug",status:"verified"},{language:"powershell",backend:"PowerShellEditorServices",status:"verified"},{language:"python",backend:"debugpy",status:"verified"},{language:"r",backend:"vscDebugger",status:"verified"},{language:"ruby",backend:"rdbg",status:"verified"},{language:"rust",backend:"lldb-dap",status:"verified"},{language:"shell",backend:"bash-debug-adapter",status:"verified"},{language:"swift",backend:"lldb-dap",status:"verified"},{language:"typescript",backend:"vscode-js-debug",status:"verified"},{language:"zig",backend:"lldb-dap",status:"verified"}],le=[{id:"dart-debug-adapter",name:"Dart debug adapter",kind:"debugger",languages:["dart"],executables:["dart"],dependencies:["Dart SDK 3.13.3"],documentation:"https://github.com/dart-lang/sdk/tree/main/third_party/pkg/dap",debugger:{runtimeExecutables:["dart"],adapterExecutables:["dart"],platforms:["linux","win32"],install:"Install Dart SDK 3.13.3 from the official Dart archive."}},{id:"debugpy",name:"debugpy",kind:"debugger",languages:["python"],executables:["python3"],dependencies:["debugpy"],documentation:"https://github.com/microsoft/debugpy",debugger:{runtimeExecutables:["python3"],adapterExecutables:["python3"],platforms:["linux","win32"],install:"Install Python 3 and debugpy for that interpreter."}},{id:"delve",name:"Delve",kind:"debugger",languages:["go"],executables:["dlv"],dependencies:["github.com/go-delve/delve/cmd/dlv@v1.25.2"],documentation:"https://github.com/go-delve/delve/tree/master/Documentation/api/dap",debugger:{runtimeExecutables:["go"],adapterExecutables:["dlv"],platforms:["linux","win32"],install:"Install Go and Delve. Native Windows support requires amd64."}},{id:"elixir-ls-debug-adapter",name:"ElixirLS debug adapter",kind:"debugger",languages:["elixir"],executables:["elixir","mix"],dependencies:["Elixir","Erlang/OTP","ElixirLS 0.31.1"],documentation:"https://github.com/elixir-lsp/elixir-ls",debugger:{runtimeExecutables:["elixir","mix"],adapterExecutables:["debug_adapter.sh","debug_adapter.bat"],platforms:["linux","win32"],install:"Install compatible Erlang/OTP and Elixir releases plus ElixirLS 0.31.1. Use debug_adapter.bat on Windows."}},{id:"vsc-debugger",name:"vscDebugger",kind:"debugger",languages:["r"],executables:["R"],dependencies:["R 4.5.3","R6 2.6.1","jsonlite 2.0.0","vscDebugger 0.5.9"],documentation:"https://manuelhentschel.github.io/vscDebugger/",debugger:{runtimeExecutables:["R"],adapterExecutables:["R"],platforms:["linux","win32"],install:"Install R 4.5.3 and vscDebugger 0.5.9 for that R installation."}},{id:"julia-debug-adapter",name:"DebugAdapter.jl",kind:"debugger",languages:["julia"],executables:["julia"],dependencies:["Julia 1.13.0","DebugAdapter.jl 3.2.1"],documentation:"https://github.com/julia-vscode/DebugAdapter.jl",debugger:{runtimeExecutables:["julia"],adapterExecutables:["julia"],platforms:["linux"],install:"Install Julia 1.13.0 and add DebugAdapter.jl 3.2.1 to /opt/pi-debug-adapters/julia."}},{id:"java-debug",name:"Microsoft Java Debug Server",kind:"debugger",languages:["java"],executables:["java"],dependencies:["JDK 21+","Eclipse JDT LS 1.61.0","Microsoft java-debug 0.53.2"],documentation:"https://github.com/microsoft/java-debug",debugger:{runtimeExecutables:["java"],adapterExecutables:["java"],platforms:["linux","win32"],install:"Install JDK 21+, Eclipse JDT LS 1.61.0 and the java-debug 0.53.2 plugin jar (from vscode-java-debug 0.59.0). Set PI_JAVA_PATH (or JAVA_HOME), PI_JDTLS_HOME and PI_JAVA_DEBUG_PLUGIN_PATH. Compile with javac -g before debugging. Pi owns a suspended target JVM and attaches through JDT LS; Kotlin still uses its own adapter."}},{id:"kotlin-debug-adapter",name:"Kotlin Debug Adapter",kind:"debugger",languages:["kotlin"],executables:["kotlin-debug-adapter"],dependencies:["fwcd/kotlin-debug-adapter 0.4.4","Temurin JDK 21.0.8+9","Kotlin compiler 2.2.20 for Kotlin builds"],documentation:"https://github.com/fwcd/kotlin-debug-adapter",debugger:{runtimeExecutables:["java"],adapterExecutables:["kotlin-debug-adapter"],platforms:["linux"],install:"Install Temurin JDK 21.0.8+9 and fwcd/kotlin-debug-adapter 0.4.4. Compile the target with debug information before launching it."}},{id:"netcoredbg",name:"NetCoreDbg",kind:"debugger",languages:["csharp"],executables:["netcoredbg"],dependencies:["Samsung/netcoredbg 3.2.0-1092",".NET SDK 8"],documentation:"https://github.com/Samsung/netcoredbg",debugger:{runtimeExecutables:["dotnet"],adapterExecutables:["netcoredbg"],platforms:["linux","win32"],install:"Install .NET SDK 8 and NetCoreDbg 3.2.0-1092. On Windows, ensure the selected dotnet SDK is on PATH."}},{id:"lldb-dap",name:"lldb-dap",kind:"debugger",languages:["c","cpp","rust"],executables:["lldb-dap-18","lldb-dap"],dependencies:["lldb-18"],documentation:"https://lldb.llvm.org/use/lldbdap.html",debugger:{runtimeExecutables:[],adapterExecutables:["lldb-dap-18","lldb-dap"],platforms:["linux"],install:"Install LLDB 18 and compile the target with debug information."}},{id:"lldb-dap-swift",name:"lldb-dap for Swift",kind:"debugger",languages:["swift"],executables:["lldb-dap"],dependencies:["Swift 6.3.3 toolchain"],documentation:"https://lldb.llvm.org/use/lldbdap.html",debugger:{runtimeExecutables:["swiftc"],adapterExecutables:["lldb-dap"],platforms:["linux"],install:"Install the official Swift 6.3.3 Linux toolchain, which includes swiftc and lldb-dap."}},{id:"lldb-dap-zig",name:"lldb-dap for Zig",kind:"debugger",languages:["zig"],executables:["lldb-dap-18","lldb-dap"],dependencies:["Zig 0.15.2","lldb-18"],documentation:"https://lldb.llvm.org/use/lldbdap.html",debugger:{runtimeExecutables:["zig"],adapterExecutables:["lldb-dap-18","lldb-dap"],platforms:["linux","win32"],install:"Install Zig 0.15.2 and LLDB 18, then compile the target in Debug mode with the LLVM backend (-fllvm) so LLDB can inspect locals."}},{id:"local-lua-debugger",name:"Local Lua Debugger",kind:"debugger",languages:["lua"],executables:["lua","node"],dependencies:["local-lua-debugger-vscode 0.3.3"],documentation:"https://github.com/tomblind/local-lua-debugger-vscode",debugger:{runtimeExecutables:["lua","node"],adapterExecutables:["debugAdapter.js"],platforms:["linux","win32"],install:"Install Lua 5.3, Node 24, and local-lua-debugger-vscode 0.3.3."}},{id:"powershell-editor-services-debug",name:"PowerShell Editor Services",kind:"debugger",languages:["powershell"],executables:["pwsh"],dependencies:["PowerShellEditorServices 4.7.0"],documentation:"https://github.com/PowerShell/PowerShellEditorServices",debugger:{runtimeExecutables:["pwsh"],adapterExecutables:["Start-EditorServices.ps1"],platforms:["linux","win32"],install:"Install PowerShell 7.4.13 and PowerShellEditorServices 4.7.0."}},{id:"rdbg",name:"rdbg",kind:"debugger",languages:["ruby"],executables:["rdbg"],dependencies:["debug gem 1.11.0 or newer"],documentation:"https://github.com/ruby/debug",debugger:{runtimeExecutables:["ruby"],adapterExecutables:["rdbg","rdbg.bat"],platforms:["linux","win32"],install:"Install Ruby and debug gem 1.11.0 or newer."}},{id:"vscode-bash-debug",name:"Bash Debug",kind:"debugger",languages:["shell"],executables:["bash","node"],dependencies:["Bash Debug 0.3.9"],documentation:"https://github.com/rogalmic/vscode-bash-debug",debugger:{runtimeExecutables:["bash","node"],adapterExecutables:["bashDebug.js"],platforms:["linux"],install:"Install Bash, Node 24, and Bash Debug 0.3.9."}},{id:"vscode-php-debug",name:"PHP Debug",kind:"debugger",languages:["php"],executables:["php","node"],dependencies:["PHP Debug 1.40.1","Xdebug"],documentation:"https://github.com/xdebug/vscode-php-debug",debugger:{runtimeExecutables:["php","node"],adapterExecutables:["phpDebug.js"],platforms:["linux","win32"],install:"Install PHP with Xdebug, Node 24, and PHP Debug 1.40.1."}},{id:"vscode-js-debug",name:"vscode-js-debug",kind:"debugger",languages:["javascript","typescript"],executables:["node"],dependencies:["@vscode/js-debug"],documentation:"https://github.com/microsoft/vscode-js-debug",debugger:{runtimeExecutables:["node"],adapterExecutables:["dapDebugServer.js"],platforms:["linux","win32"],install:"Install Node 24 and js-debug-dap v1.117.0 from the official release archive."}}];function re(r){return le.find(e=>e.languages.includes(r))}d(re,"debuggerRecipeForLanguage");import{readdir as tt,readFile as or}from"node:fs/promises";import{homedir as ge}from"node:os";import R from"node:path";var Qe="2025-06-18",M=class r{static{d(this,"DebugMcpClient")}#o;#a;#r=1;constructor(e){this.#o=e}static async connect(e,t){let n=new r(`http://127.0.0.1:${e}/mcp`);return await n.#t("initialize",{protocolVersion:Qe,capabilities:{},clientInfo:{name:"pi-agent-ide",version:"1"}},t),await n.#i({jsonrpc:"2.0",method:"notifications/initialized"},t),n}async call(e,t,n){let o=await this.#t("tools/call",{name:e,arguments:t},n),a=(o.content??[]).flatMap(i=>i.type==="text"&&i.text!==void 0?[i.text]:[]).join(`
6
+ `);if(o.isError===!0)throw new Error(a||`DebugMCP ${e} failed`);return a}async close(){this.#a!==void 0&&(await fetch(this.#o,{method:"DELETE",headers:this.#e(),signal:AbortSignal.timeout(1e3)}).catch(()=>{}),this.#a=void 0)}async#t(e,t,n){let o=this.#r++,a=await this.#i({jsonrpc:"2.0",id:o,method:e,params:t},n),i=await ar(a,o);if(i.error!==void 0)throw new Error(`DebugMCP ${e} failed: ${i.error.message??"unknown error"}`);return i.result}async#i(e,t){let n=await fetch(this.#o,{method:"POST",headers:{...this.#e(),"content-type":"application/json",accept:"application/json, text/event-stream"},body:JSON.stringify(e),...t===void 0?{}:{signal:t}});if(!n.ok)throw new Error(`DebugMCP returned HTTP ${n.status}: ${await n.text()}`);return this.#a=n.headers.get("mcp-session-id")??this.#a,n}#e(){return this.#a===void 0?{}:{"mcp-session-id":this.#a,"mcp-protocol-version":Qe}}};async function ar(r,e){let t=await r.text(),n=(r.headers.get("content-type")??"").includes("text/event-stream")?t.split(/\r?\n/u).filter(o=>o.startsWith("data:")).map(o=>o.slice(5).trim()):[t];for(let o of n){if(o.length===0)continue;let a=JSON.parse(o);if(a.id===e)return a}throw new Error("DebugMCP returned no response")}d(ar,"responseMessage");var ae="ozzafar.debugmcpextension";function oe(r=process.env){return Number(r.PI_DEBUGMCP_PORT??3001)}d(oe,"debugMcpPort");var ir=6e4,sr=30,et=6e4,dr=new Set([".exe",".out",".bin",".elf",".so",".dll",".dylib"]);function pe(r,e=process.platform){return e==="win32"?r.replace(/^[A-Z](?=:)/u,t=>t.toLowerCase()):r}d(pe,"vscodePath");function ur(r){return dr.has(R.extname(r).toLowerCase())}d(ur,"isExecutable");var cr={continue:"continue_execution",next:"step_over",stepIn:"step_into",stepOut:"step_out"};async function fe(r){for(let e of lr()){let t=await tt(e).catch(()=>[]);for(let n of t){if(!/^window-\d+\.json$/u.test(n))continue;let o=await pr(R.join(e,n));if(o!==void 0&&r.every(a=>o.workspaceFolders.some(i=>fr(a,i))))return o}}}d(fe,"findVscodeWindow");async function rt(){for(let r of[R.join(ge(),".vscode-server","extensions"),R.join(ge(),".vscode","extensions")])if((await tt(r).catch(()=>[])).some(t=>t.startsWith(`${ae}-`)))return!0;return!1}d(rt,"debugMcpInstalled");async function nt(r){try{return await(await M.connect(oe(),r)).close(),!0}catch{return!1}}d(nt,"debugMcpResponds");var ne=class r{static{d(this,"VscodeDebugSession")}window;#o;#a;#r=new Map;#t;constructor(e,t,n){this.window=e,this.#o=t,this.#a=n}static async open(e,t){let n=await fe([e.cwd,e.program,e.sourceFile]);if(n===void 0)throw new Error(`No running VS Code window with DebugMCP has ${e.cwd} open`);let o=oe(),a;try{a=await M.connect(o,t)}catch(s){throw t?.throwIfAborted(),new Error(`DebugMCP did not respond on port ${o}: ${vr(s)}`,{cause:s})}let i=new r(n,a,e.program);try{if(await i.#i(t),(await i.status(0,t)).status!=="no-session")throw new Error(`VS Code window "${n.name}" already has an active debug session`)}catch(s){throw await a.close(),s}return i}async addBreakpoint(e,t,n){let o=`${e}:${t}`,a=this.#r.get(o);if(a!==void 0){this.#r.set(o,a+1);return}let i=await this.#e("list_breakpoints",{},n);mr(i).has(`${R.basename(e)}:${t}`)||(await this.#e("add_breakpoint",{fileFullPath:pe(e),line:t},n),this.#r.set(o,1))}async removeBreakpoint(e,t,n){let o=`${e}:${t}`,a=this.#r.get(o);if(a!==void 0){if(a>1){this.#r.set(o,a-1);return}this.#r.delete(o),await this.#e("remove_breakpoint",{fileFullPath:pe(e),line:t},n)}}async start(e,t){if(e.configuration===void 0&&e.test===void 0&&ur(e.program))throw new Error(`VS Code cannot choose a debugger for the executable ${R.basename(e.program)}. Add a .vscode/launch.json configuration for it (for example "cppvsdbg" or "cppdbg") and pass its name as configuration.`);let n=AbortSignal.timeout(et);try{await this.#e("start_debugging",{fileFullPath:e.program,workingDirectory:e.cwd,...e.configuration===void 0?{}:{configurationName:e.configuration},...e.test===void 0?{}:{testName:e.test}},t===void 0?n:AbortSignal.any([t,n]))}catch(a){throw!n.aborted||t?.aborted===!0?a:(await this.#e("stop_debugging",{}).catch(()=>{}),new Error(`VS Code did not start the debug session within ${et/1e3} s. Check that the VS Code window has the debugger extension for this configuration and that no prompt is waiting in VS Code.`,{cause:a}))}let o=await this.status(0,t);return this.#t=o.configurationName,o}async command(e,t){return await this.#e(cr[e],{},t),this.status(sr,t)}async status(e,t){let n=d(async a=>br(JSON.parse(await this.#e("get_debug_status",a===0?{}:{waitForPauseSeconds:a},t))),"read"),o=await n(e);for(let a=0;o.status==="paused"&&o.frame===void 0&&a<20;a++)await new Promise(i=>setTimeout(i,100)),o=await n(0);return o}async locals(e){let t=hr(await this.#e("list_variable_names",{scope:"local"},e)).slice(0,50);if(t.length===0)return[];let n=await this.#e("get_variables_values",{variableNames:t.map(({name:o})=>o),scope:"local"},e);return wr(n,t)}async evaluate(e,t){return yr(await this.#e("evaluate_expression",{expression:e},t))}async#i(e){await this.#o.call("remove_breakpoint",{fileFullPath:this.#a,line:0},e)}async#e(e,t,n){try{return await this.#o.call(e,t,n)}catch(o){throw await this.#i().catch(()=>{}),o}}async close(e){try{for(let n of this.#r.keys()){let o=n.lastIndexOf(":");await this.#e("remove_breakpoint",{fileFullPath:pe(n.slice(0,o)),line:Number(n.slice(o+1))},e)}this.#r.clear();let t=await this.status(0,e);t.status!=="no-session"&&t.configurationName===this.#t&&await this.#e("stop_debugging",{},e)}finally{await this.#o.close()}}};function lr(){let r=ge();return[R.join(r,".vscode-server","data","User"),R.join(r,".config","Code","User"),R.join(r,"Library","Application Support","Code","User"),...process.env.APPDATA===void 0?[]:[R.join(process.env.APPDATA,"Code","User")]].map(e=>R.join(e,"globalStorage",ae,"window-registry"))}d(lr,"registryDirectories");async function pr(r){try{let e=JSON.parse(await or(r,"utf8"));return typeof e.pid!="number"||typeof e.updatedAt!="number"||!Array.isArray(e.workspaceFolders)||Date.now()-e.updatedAt>ir||!gr(e.pid)?void 0:{pid:e.pid,name:typeof e.name=="string"?e.name:"",workspaceFolders:e.workspaceFolders.filter(t=>typeof t=="string")}}catch{return}}d(pr,"readRegistration");function gr(r){try{return process.kill(r,0),!0}catch(e){return e.code==="EPERM"}}d(gr,"processAlive");function fr(r,e,t=process.platform){let n=t==="win32"?R.win32:R.posix,o=d(s=>t==="win32"?n.resolve(s).toLowerCase():n.resolve(s),"fold"),a=o(e),i=o(r);return i===a||i.startsWith(a.endsWith(n.sep)?a:a+n.sep)}d(fr,"isInside");function br(r){let e=r.status==="paused"||r.status==="running"?r.status:"no-session",t=typeof r.configurationName=="string"?r.configurationName:void 0,n=typeof r.state=="object"&&r.state!==null?r.state:{},o=Array.isArray(n.stackTrace)&&typeof n.stackTrace[0]=="string"?/^(.*):(\d+)$/u.exec(n.stackTrace[0]):null,a=typeof n.currentLine=="number"?n.currentLine:o===null?void 0:Number(o[2]),i=a===void 0?void 0:{id:typeof n.frameId=="number"?n.frameId:0,threadId:typeof n.threadId=="number"?n.threadId:0,name:typeof n.frameName=="string"?n.frameName:o?.[1]??"",...typeof n.fileFullPath=="string"?{file:n.fileFullPath}:{},line:a};return{status:e,...t===void 0?{}:{configurationName:t},...e==="paused"&&i!==void 0?{frame:i}:{}}}d(br,"debugState");function mr(r){return new Set(r.split(/\r?\n/u).flatMap(e=>{let t=/^\d+\. (?:Breakpoint|Logpoint) (.+?):(\d+)(?: \(|$)/u.exec(e);return t===null?[]:[`${t[1]}:${t[2]}`]}))}d(mr,"listedBreakpoints");function hr(r){return r.split(/\r?\n/u).flatMap(e=>{let t=/^ {2}(\S.*?)(?: \(([^()]*)\))?$/u.exec(e);if(t===null||/^(?:No variables in this scope|Error retrieving variables:)/u.test(e.trim()))return[];let n=t[1],o=t[2];return n===void 0?[]:[{name:n,...o===void 0?{}:{type:o}}]})}d(hr,"variableNames");function wr(r,e){let t=r.split(/\r?\n/u);return e.flatMap(({name:n,type:o})=>{let a=` ${n}`,i=t.find(p=>p===a||p.startsWith(`${a}: `)||p.startsWith(`${a} (`));if(i===void 0)return[];let s=i.slice(a.length),u=o===void 0?void 0:` (${o})`,c=s.startsWith(": ")?s.slice(2):"<complex value>";return u!==void 0&&c.endsWith(u)&&(c=c.slice(0,-u.length)),[{name:n,value:c,...o===void 0?{}:{type:o}}]})}d(wr,"variableValues");function yr(r){let e=r.split(/\r?\n/u),t=e.findIndex(a=>a.startsWith("Result: ")),n=/^Result: (.*?)(?: \(([^()]*)\))?$/u.exec(e[t]??"");if(n===null)throw new Error(`DebugMCP returned no evaluation result: ${r}`);let o=e.slice(t+1).filter(a=>/^ {2}\S/u.test(a));return{result:[n[1],...o].join(`
7
+ `),...n[2]===void 0?{}:{type:n[2]}}}d(yr,"evaluation");function vr(r){return r instanceof Error?r.message:String(r)}d(vr,"message");var at="/opt/pi-debug-adapters/js-debug/src/dapDebugServer.js",ot="/opt/pi-debug-adapters/elixir-ls/debug_adapter.sh",it={protocol:Le,apiVersion:Be,id:"debugger",setup(r){for(let e of le)r.addToolRecipe(e);r.addSetupCheck({id:"effective-config",inspect:Dr}),r.addCheck({id:"adapters",title:"Debug adapters",run:Pr}),r.addCheck({id:"vscode",title:"VS Code debugger backend",run:Sr})}};async function Dr(r,e=r.workspace?.platform??process.platform){let t=new Map([...r.detectedLanguageIds].map(re).filter(a=>a!==void 0).map(a=>[a.id,a])),n=[...r.detectedLanguageIds].flatMap(a=>{let i=re(a);return i===void 0?[]:[{kind:"debugger",languageId:a,toolId:i.id}]}),o=[];for(let a of Ze)a.status==="planned"&&r.detectedLanguageIds.has(a.language)&&o.push({id:`debugger-${a.language}-not-verified`,message:`${a.backend} is selected for ${a.language}, but its Linux debugger integration is not verified yet`});for(let a of t.values()){let i=a.debugger;if(i===void 0)continue;let s=e==="linux"||e==="darwin"||e==="win32"?e:void 0;if(s===void 0||!i.platforms.includes(s)){o.push({id:`debugger-${a.id}-platform`,category:"unsupported-platform",message:`${a.name} does not support the ${e} debugger recipe`});continue}let u=a.id==="debugpy"?await be(r,e):void 0,c=await kr(a.id==="java-debug"?[ee(r.env)]:u===void 0?i.runtimeExecutables:[u.command],r);if(c!==void 0){o.push({id:`debugger-${a.id}-runtime`,category:"missing-runtime",message:`Runtime ${c} is unavailable. ${i.install}`});continue}if(!await Er(a.id,r,e)){o.push({id:`debugger-${a.id}-adapter`,category:"missing-adapter",message:`${a.name} is not installed. ${i.install}`});continue}await _r(a.id,r,e)||o.push({id:`debugger-${a.id}-startup`,category:"adapter-startup",message:`${a.name} is installed but cannot start. ${i.install}`})}return{selections:n,actions:o}}d(Dr,"inspectDebuggerSetup");async function Pr(r){let e=[...new Map([...r.detectedLanguageIds].map(re).filter(t=>t!==void 0).map(t=>[t.id,t])).values()];return e.length===0?[{status:"skip",message:"No supported executable language was detected"}]:Promise.all(e.map(async t=>{let n=await dt(t.id,r);if(t.id==="java-debug"&&n.ok&&r.workspace===void 0){let o=new H;try{await o.connect(r.cwd,AbortSignal.timeout(2e4),r.env),n={ok:!0,detail:`${n.detail}
8
+ Java DAP bridge ready`}}catch(a){n={ok:!1,detail:a instanceof Error?a.message:String(a)}}finally{await o.close()}}return{status:n.ok?"pass":"fail",message:`${t.name}: ${n.ok?"available":"unavailable"}`,detail:n.detail}}))}d(Pr,"checkDebuggerAdapters");async function Sr(r){if(r.workspace!==void 0)return[{status:"skip",message:"The VS Code backend debugs only local workspaces"}];let e=await fe([r.cwd]);return e!==void 0?await nt(r.signal)?[{status:"pass",message:`VS Code backend: available in "${e.name}"`}]:[{status:"fail",message:"VS Code backend: DebugMCP does not respond",detail:`"${e.name}" has this workspace open, but DebugMCP does not accept connections on port ${oe(r.env)}. Set PI_DEBUGMCP_PORT when debugmcp.serverPort differs.`}]:await rt()?[{status:"skip",message:"VS Code backend: no VS Code window with DebugMCP has this workspace open",detail:"Open the workspace in VS Code to debug through it; debug uses native adapters meanwhile."}]:await T(r,"code")?[{status:"warn",message:"VS Code backend: DebugMCP is not installed",detail:`Install it with: code --install-extension ${ae}`}]:[{status:"skip",message:"VS Code backend: VS Code is not installed"}]}d(Sr,"checkVscodeBackend");async function st(r,e){if(r.workspace!==void 0)return S(r,"python3",["-c","import glob,os,sys; home,plugin=sys.argv[1:]; launchers=glob.glob(os.path.join(home,'plugins','org.eclipse.equinox.launcher_*.jar')); ok=len(launchers)==1 and os.path.isfile(plugin) and os.path.isdir(os.path.join(home,'config_linux')); print('Java debugger files ready' if ok else 'Missing JDT LS or java-debug plugin'); sys.exit(0 if ok else 1)",r.env.PI_JDTLS_HOME??"/opt/pi-debug-adapters/jdtls",r.env.PI_JAVA_DEBUG_PLUGIN_PATH??"/opt/pi-debug-adapters/java-debug/com.microsoft.java.debug.plugin-0.53.2.jar"]);try{return await te(r.env,e),{ok:!0,detail:"Java debugger files ready"}}catch(t){return r.signal?.throwIfAborted(),{ok:!1,detail:t instanceof Error?t.message:String(t)}}}d(st,"probeJavaFiles");async function kr(r,e){for(let t of r)if(!await T(e,t))return t}d(kr,"firstMissingExecutable");async function Er(r,e,t=e.workspace?.platform??process.platform){let{env:n}=e;if(r==="elixir-ls-debug-adapter")return q(e,n.PI_ELIXIR_LS_DEBUG_PATH??ot);if(r==="vsc-debugger")return(await S(e,n.PI_R_PATH??"R",["--vanilla","--quiet","-e","quit(status=if (requireNamespace('vscDebugger', quietly=TRUE)) 0 else 1)"])).ok;if(r==="vscode-js-debug")return q(e,n.PI_JS_DEBUG_PATH??at);if(r.startsWith("lldb-dap"))return await T(e,n.PI_LLDB_DAP_PATH??(t==="win32"?"lldb-dap":"lldb-dap-18"))||await T(e,"lldb-dap");if(r==="delve")return T(e,n.PI_DELVE_PATH??"dlv");if(r==="java-debug")try{return e.workspace!==void 0?(await st(e,t)).ok:(await te(n,t),!0)}catch{return!1}if(r==="kotlin-debug-adapter")return T(e,n.PI_KOTLIN_DEBUG_ADAPTER_PATH??"kotlin-debug-adapter");if(r==="julia-debug-adapter")return q(e,`${n.PI_JULIA_DEBUG_PROJECT??"/opt/pi-debug-adapters/julia"}/Project.toml`);if(r==="dart-debug-adapter")return T(e,n.PI_DART_PATH??"dart");if(r==="netcoredbg")return T(e,n.PI_NETCOREDBG_PATH??"netcoredbg");if(r==="rdbg")return T(e,n.PI_RUBY_DEBUG_PATH??"rdbg");let a={"vscode-php-debug":n.PI_PHP_DEBUG_PATH??"/opt/pi-debug-adapters/php-debug/extension/out/phpDebug.js","local-lua-debugger":n.PI_LUA_DEBUG_PATH??"/opt/pi-debug-adapters/lua-debug/extension/extension/debugAdapter.js","vscode-bash-debug":n.PI_BASH_DEBUG_PATH??"/opt/pi-debug-adapters/bash-debug/extension/out/bashDebug.js","powershell-editor-services-debug":`${n.PI_POWERSHELL_EDITOR_SERVICES_PATH??"/opt/pi-debug-adapters/powershell-editor-services"}/PowerShellEditorServices/Start-EditorServices.ps1`}[r];if(a!==void 0)return q(e,a);if(r!=="debugpy")return!1;let i=await be(e,t);return(await S(e,i.command,[...i.args,"-c","import importlib.util; raise SystemExit(importlib.util.find_spec('debugpy') is None)"])).ok}d(Er,"adapterInstalled");async function _r(r,e,t=e.workspace?.platform??process.platform){return(await dt(r,e,t)).ok}d(_r,"adapterAvailable");async function dt(r,e,t=e.workspace?.platform??process.platform){let{env:n}=e;if(r==="elixir-ls-debug-adapter")return J(n.PI_ELIXIR_LS_DEBUG_PATH??ot,e);if(r==="vsc-debugger")return S(e,n.PI_R_PATH??"R",["--vanilla","--quiet","-e","library(vscDebugger); cat(as.character(packageVersion('vscDebugger')))"]);if(r==="dart-debug-adapter")return S(e,n.PI_DART_PATH??"dart",["--version"]);if(r==="debugpy"){let a=await be(e,t);return S(e,a.command,[...a.args,"-c","import debugpy; print(debugpy.__version__)"])}if(r==="delve")return S(e,n.PI_DELVE_PATH??"dlv",["version"]);if(r==="julia-debug-adapter"){let a=n.PI_JULIA_DEBUG_PROJECT??"/opt/pi-debug-adapters/julia";return S(e,n.PI_JULIA_PATH??"julia",[`--project=${a}`,"--startup-file=no","-e","using DebugAdapter"])}if(r==="java-debug"){let a=await st(e,t);if(!a.ok)return a;let i=await S(e,ee(n),["-version"]);if(!i.ok)return i;let s=/version "(\d+)/u.exec(i.detail)?.[1];return Number(s)>=21?i:{ok:!1,detail:"Java debugger requires JDK 21 or newer. Set PI_JAVA_PATH or JAVA_HOME."}}if(r==="kotlin-debug-adapter"){let a=await S(e,n.PI_KOTLIN_DEBUG_ADAPTER_PATH??"kotlin-debug-adapter",["--help"]);return a.ok?S(e,"java",["-version"]):a}if(r==="netcoredbg"){let a=await S(e,n.PI_NETCOREDBG_PATH??"netcoredbg",["--version"]);return a.ok?S(e,"dotnet",["--version"]):a}if(r.startsWith("lldb-dap")){let a=n.PI_LLDB_DAP_PATH??(t==="win32"?"lldb-dap":await T(e,"lldb-dap-18")?"lldb-dap-18":"lldb-dap");return S(e,a,["--version"])}if(r==="rdbg")return S(e,n.PI_RUBY_DEBUG_PATH??"rdbg",["--version"]);if(r==="vscode-php-debug"){let a=await S(e,n.PI_PHP_PATH??"php",["-r","exit(extension_loaded('xdebug') ? 0 : 1);"]);return a.ok?J(n.PI_PHP_DEBUG_PATH??"/opt/pi-debug-adapters/php-debug/extension/out/phpDebug.js",e):a}if(r==="local-lua-debugger"){let a=await S(e,n.PI_LUA_PATH??"lua",["-v"]);return a.ok?J(n.PI_LUA_DEBUG_PATH??"/opt/pi-debug-adapters/lua-debug/extension/extension/debugAdapter.js",e):a}if(r==="vscode-bash-debug"){let a=await S(e,n.PI_BASH_PATH??"bash",["--version"]);return a.ok?J(n.PI_BASH_DEBUG_PATH??"/opt/pi-debug-adapters/bash-debug/extension/out/bashDebug.js",e):a}if(r==="powershell-editor-services-debug"){let a=await S(e,n.PI_PWSH_PATH??"pwsh",["--version"]),i=n.PI_POWERSHELL_EDITOR_SERVICES_PATH??"/opt/pi-debug-adapters/powershell-editor-services";return a.ok?J(`${i}/PowerShellEditorServices/Start-EditorServices.ps1`,e):a}if(r!=="vscode-js-debug")return{ok:!1,detail:`Unknown debugger adapter: ${r}`};let o=n.PI_JS_DEBUG_PATH??at;return await q(e,o)?S(e,e.workspace?"node":process.execPath,["-e","const fs=require('node:fs'); fs.accessSync(process.argv[1]); console.log(process.version)",o]):{ok:!1,detail:`${o} does not exist`}}d(dt,"probeAdapter");async function J(r,e){return await q(e,r)?S(e,e.workspace?"node":process.execPath,["-e","const fs=require('node:fs'); fs.accessSync(process.argv[1])",r]):{ok:!1,detail:`${r} does not exist`}}d(J,"probeAdapterFile");async function be(r,e){return Y(r.cwd,r.env,e,t=>T(r,t))}d(be,"pythonCommand");async function q(r,e){if(!r.workspace)return ce(r,e);let t=r.workspace.toNativeUri(r.cwd).replace(/\/?$/u,"/"),n=e.split("/").map(encodeURIComponent).join("/"),o=r.workspace.fromNativeUri(new URL(n,t).href);return ce(r,o)}d(q,"adapterFileExists");import Ar from"node:path";import{fileURLToPath as Rr}from"node:url";function ct(r){return{id:"debug-breakpoints",present(e,t){let n=r.get(t.source),o=r.sourceFile(t.source)??ut(t.source,t.cwd)??ut(e.source,t.cwd);if(o===void 0)return e;let a=r.breakpointsForFile(o,n?.source);if(a.length===0)return e;let i=Ir(a);return{...e,lines:e.lines.map(s=>{let u=i.get(s.lineNumber);return u===void 0?s:{...s,presentation:{...s.presentation,suffix:`${s.presentation?.suffix??""}${Tr(u)}`,compactSuffix:`${s.presentation?.compactSuffix??""}${xr(u)}`}}})}}}}d(ct,"createBreakpointPresenter");function Ir(r){let e=new Map;for(let t of r){let n=e.get(t.line)??[];n.push(t),e.set(t.line,n)}return e}d(Ir,"groupByLine");function ut(r,e){if(r.startsWith("file://"))return Rr(r);if(!/^[a-z][a-z\d+.-]*:/iu.test(r))return Ar.resolve(e,r)}d(ut,"filesystemSource");function Tr(r){return r.map(e=>` ${e.verified?"\u25CF":"\u25CB"} breakpoint ${e.source} (${e.verified?"verified":"pending"})`).join("")}d(Tr,"renderAgentBreakpoints");function xr(r){let t=r.filter(o=>o.verified).length===r.length?"\u25CF":"\u25CB",n=r.length===1?"breakpoint":`${r.length} breakpoints`;return` ${t} ${n}`}d(xr,"renderUserBreakpoints");import ie from"node:path";import{Text as me}from"@earendil-works/pi-tui";function he(r,e,t,n){return new me(`${n.fg("toolTitle",r)} ${n.fg("muted",`\xB7 ${mt(e,t)}`)}
9
+ ${n.fg("accent","\u25C6 configure debugger")}`,0,0)}d(he,"renderDebugCall");function lt(r,e,t){return new me(`${gt(r,t)}
10
+ ${t.fg("accent",jr(e))}`,0,0)}d(lt,"renderDebugActionCall");function G(r,e,t,n,o){let a=Cr(r,e,t);return o!==void 0&&a.unshift(t.fg("error",`\u2717 ${o}`)),n!==void 0&&a.unshift(`${t.fg("accent",n.expression)} ${t.fg("muted","=")} ${t.fg("toolOutput",n.result)}${n.type===void 0?"":t.fg("dim",` ${n.type}`)}`),new me(a.join(`
11
+ `),0,0)}d(G,"renderDebugResult");function pt(r,e){let t=[gt(r,e),ft(r.status,e)];return r.stop?.frame!==void 0&&t.push(` ${e.fg("warning","\u25CF")} ${r.stop.frame.name} ${e.fg("muted",`\xB7 ${bt(r.stop)}`)}`),t}d(pt,"renderActiveDebugger");function Cr(r,e,t){let n=[];if(r.status==="stopped"&&r.stop!==void 0){n.push(t.fg("warning",`\u25CF stopped \xB7 ${r.stop.reason}`),t.fg("text",`${r.stop.frame?.name??"unknown frame"} ${t.fg("muted",`\xB7 ${bt(r.stop)}`)}`));for(let a of r.stop.sourceLines){let i=a.current?t.fg("warning",">"):t.fg("dim","\u2502"),s=a.current?"text":"dim";n.push(`${i} ${String(a.lineNumber).padStart(4)} ${t.fg(s,a.content)}`)}let o=e?r.stop.variables:r.stop.variables.slice(0,6);if(o.length>0){n.push(t.fg("muted","Locals"));for(let a of o)n.push(` ${t.fg("accent",a.name.padEnd(16))} ${t.fg("toolOutput",a.value)}${a.type===void 0?"":t.fg("dim",` ${a.type}`)}`);o.length<r.stop.variables.length&&n.push(t.fg("muted",` \u2026 ${r.stop.variables.length-o.length} more`))}return n}if(n.push(ft(r.status,t)),r.breakpoints.length>0){let o=r.breakpoints.filter(a=>a.verified).length;n.push(t.fg("muted",`${r.breakpoints.length} breakpoint${r.breakpoints.length===1?"":"s"} \xB7 ${o} verified`))}return n}d(Cr,"debugResultLines");function gt(r,e){return`${e.fg("toolTitle",r.options.adapter)} ${e.fg("muted",`\xB7 ${mt(r.options.program,r.options.cwd)}`)}`}d(gt,"debugIdentity");function jr(r){let e=r.trim().toLowerCase();return e==="start"?"\u25B6 start debugging":e==="continue"?"\u25B6 continue":e==="step over"?"\u21B7 step over":e==="step into"?"\u2193 step into":e==="step out"?"\u2191 step out":e.startsWith("evaluate ")?`\u25C6 ${r.trim().slice(9)}`:e.startsWith("breakpoint ")?`\u25CF add ${e}`:e.startsWith("delete-breakpoint ")?`\u25CB remove breakpoint \xB7 ${e.slice(18)}`:e==="breakpoint"?"\u25CF add breakpoint":e==="delete-breakpoint"?"\u25CB remove breakpoint":e==="delete-session"?"\u25A0 stop debugging":e}d(jr,"actionLabel");function ft(r,e){return r==="configured"?e.fg("muted","\u25C7 ready"):r==="running"?e.fg("accent","\u25CF running"):r==="stopped"?e.fg("warning","\u25CF stopped"):e.fg("success","\u25A0 stopped debugging")}d(ft,"statusLine");function bt(r){let e=r.frame?.source?.path??r.frame?.source?.name??"unknown";return`${ie.basename(e)}:${r.frame?.line??"?"}`}d(bt,"shortFrame");function mt(r,e){let t=ie.relative(e,r),n=".".repeat(2),o=t===n||t.startsWith(`${n}${ie.sep}`);return t.length>0&&!o?t:ie.basename(r)}d(mt,"shortPath");function we(r){let e=ye(r);if(e===void 0)return;let t=e.snapshot;return typeof t=="object"&&t!==null?t:void 0}d(we,"debuggerSnapshotFromResult");function ht(r){let e=ye(r);if(e===void 0)return;let t=e.evaluation;if(!(typeof t!="object"||t===null||!("expression"in t)||typeof t.expression!="string"||!("result"in t)||typeof t.result!="string"||!("variablesReference"in t)||typeof t.variablesReference!="number"))return{expression:t.expression,result:t.result,variablesReference:t.variablesReference,..."type"in t&&typeof t.type=="string"?{type:t.type}:{}}}d(ht,"debuggerEvaluationFromResult");function wt(r){let e=ye(r),t=e?.ok===!1?e.error:void 0;return typeof t=="object"&&t!==null&&"message"in t&&typeof t.message=="string"?t.message:void 0}d(wt,"debuggerFailureFromResult");function ye(r){if(typeof r!="object"||r===null)return;let e=r.metadata;if(typeof e!="object"||e===null)return;let t=e.semanticAction;return typeof t=="object"&&t!==null?t:void 0}d(ye,"semanticActionFromResult");function yt(r){return{id:"debugger",onDidChange:d(e=>r.onDidChange(e),"onDidChange"),list:d(()=>r.list().map(e=>r.snapshot(e)).filter(e=>e.status==="configured"||e.status==="running"||e.status==="stopped").map(e=>({source:e.source,...e.remote===void 0?{}:{remote:e.remote},owned:!0,kind:"debugger",title:e.options.adapter,description:e.options.program,status:e.status==="configured"?"configured":e.status==="stopped"?"paused":"running",renderSummary:d(t=>pt(e,t),"renderSummary"),renderDetail:d(t=>G(e,!0,t),"renderDetail"),stop:d(()=>r.delete(e.source),"stop")})),"list")}}d(yt,"debuggerProcessProvider");import V from"cross-spawn";import{randomBytes as vt}from"node:crypto";import{mkdtemp as $r,readFile as Et,rm as Lr}from"node:fs/promises";import _t from"node:net";import{tmpdir as Br}from"node:os";import E from"node:path";var W=class{static{d(this,"DebugSessionManager")}#o=new Map;#a=new Set;#r;constructor(e){this.#r=e}setOwnerResolver(e){this.#r=e}#t(e){let t=this.#r?.(e.options.cwd);if(t?.key!==e.ownerKey)throw new Error("Debugger resource owner changed");return t}create(e,t){let n=this.#r?.(e.cwd);if(!n&&[e.cwd,e.program,e.sourceFile].some(i=>i?.includes("://")))throw new Error("No debugger workspace owner");if(n)for(let i of[e.cwd,e.program,e.sourceFile??e.program])n.serverPath(i);let o=vt(6).toString("hex"),a={id:o,source:`debug:${o}`,options:{...e,sourceFile:e.sourceFile??e.program},...n===void 0?{}:{ownerKey:n.key},...t===void 0?{}:{vscode:t},breakpoints:new Map,status:"configured",stopGeneration:0};return this.#o.set(o,a),this.#n(a),a}get(e){let t=/^debug:([a-f\d]{12})(?:\/|$)/u.exec(e);return t===null?void 0:this.#o.get(t[1])}list(){return[...this.#o.values()]}snapshot(e){return{id:e.id,source:e.source,options:e.options,status:e.status,...e.remote===void 0?{}:{remote:e.remote},breakpoints:[...e.breakpoints.values()].map(t=>({...t})),...e.stop===void 0?{}:{stop:e.stop}}}onDidChange(e){return this.#a.add(e),()=>this.#a.delete(e)}breakpointsForFile(e,t){return this.list().filter(n=>t===void 0||n.source===t).flatMap(n=>[...n.breakpoints.values()]).filter(n=>U(n.file,e))}sourceFile(e){let t=this.get(e);return t!==void 0&&e===`${t.source}/source`?t.options.sourceFile:void 0}sourceResource(e){return`${e.source}/source`}async readSource(e){let t=this.get(e),n=this.sourceFile(e);if(t===void 0||n===void 0)throw new Error(`Unknown debug source ${e}`);let o=this.#t(t);return o===void 0?Et(n,"utf8"):o.readText(n)}async addBreakpoint(e,t,n){let o=this.get(e),a=this.sourceFile(e);if(o===void 0||a===void 0)throw new Error(`Unknown debug source ${e}`);if(this.#t(o),o.status==="terminated")throw new Error("Cannot add a breakpoint to a terminated session");let i=vt(5).toString("hex"),s={id:i,source:`${o.source}/breakpoint/${i}`,file:a,requestedLine:t,line:t,verified:!1};return o.vscode!==void 0&&await o.vscode.addBreakpoint(a,t,n),o.breakpoints.set(i,s),o.client!==void 0&&await this.#s(o,o.client,a,n),this.#n(o),s}breakpoint(e){let t=this.get(e);return t===void 0?void 0:[...t.breakpoints.values()].find(n=>n.source===e)}async start(e,t){return e.vscode!==void 0?this.#i(e,e.vscode,t):e.options.adapter==="java"&&this.#t(e)===void 0?this.#u(e,t):this.#d(e,t,2)}async#i(e,t,n){if(e.status!=="configured")throw new Error(`Session is already ${e.status}`);e.status="running",this.#n(e);try{let{program:o,cwd:a,configuration:i,test:s}=e.options,u=await t.start({program:o,cwd:a,...i===void 0?{}:{configuration:i},...s===void 0?{}:{test:s}},n);await this.#e(e,t,u)}catch(o){throw e.status="configured",this.#n(e),o}return e}async#e(e,t,n,o){if(n.status!=="paused"){e.status=n.status==="running"?"running":"terminated",e.stop=void 0,this.#n(e);return}let a=n.frame===void 0?void 0:{id:n.frame.id,name:n.frame.name,line:n.frame.line,...Nr(n.frame.file??Or(e,n.frame,o))},i=!1;for(let s of e.breakpoints.values())a?.source?.path!==void 0&&U(s.file,a.source.path)&&s.line===a.line&&(s.verified=!0,i=!0);e.stopGeneration++,e.stop={generation:e.stopGeneration,reason:i?"breakpoint":"step",threadId:n.frame?.threadId??0,...a===void 0?{}:{frame:a},variables:a===void 0?[]:await Dt(t),sourceLines:a===void 0?[]:await Pt(a)},e.status="stopped",this.#n(e)}async#u(e,t){if(e.status!=="configured")throw new Error(`Session is already ${e.status}`);let n=new H;e.javaRuntime=n;let o=AbortSignal.any([...t===void 0?[]:[t],AbortSignal.timeout(3e4)]),a=d(()=>{n.close()},"abortStartup");e.status="running",this.#n(e);try{let{client:i,attach:s}=await n.start(e.options,o);return e.client=i,e.controlClient=i,o.addEventListener("abort",a,{once:!0}),e.clients=[i],await ve(i,"java",o),await Promise.all([i.waitForAnyEvent(["initialized"],3e4,o),i.request("attach",s,{signal:o})]),await this.#g(e,i,o),await i.request("configurationDone",void 0,{signal:o}),await this.#c(e,o),this.snapshot(e).status==="terminated"&&await n.close(),e}catch(i){throw await n.close(),e.javaRuntime=void 0,e.client=void 0,e.controlClient=void 0,e.clients=void 0,e.status="configured",this.#n(e),i}finally{o.removeEventListener("abort",a)}}async#d(e,t,n){if(e.status!=="configured")throw new Error(`Session is already ${e.status}`);t?.throwIfAborted();let o=this.#t(e);o===void 0&&e.options.adapter==="powershell"&&(e.adapterTemporaryDirectory=await $r(E.join(Br(),"pi-powershell-debug-")));let a=o===void 0?await this.#m(e):await o.prepare(e.options,t);a.remote&&(e.remote=a.remote);let i=a.client;e.client=i,e.controlClient=i,e.clients=[i],e.options.adapter==="node"&&(e.targetReady=new Promise(s=>{e.resolveTargetReady=s})),e.status="running",this.#n(e);try{if(o!==void 0&&e.options.adapter==="node"){if(!a.connectChild)throw new Error("Owned Node adapter has no child connection");i.onReverseRequest(this.#y(e,a.connectChild))}(o!==void 0||e.options.adapter!=="r")&&await ve(i,a.adapterID,t);let s=i.waitForAnyEvent(["initialized"],3e4,t),u=i.request(a.request,a.launch,{signal:t});await Promise.race([s,u.then(()=>s)]),await this.#g(e,i,t);let c=i.request("configurationDone",void 0,{signal:t});if(e.options.adapter==="kotlin"?c.catch(()=>{}):await c,await u,e.options.adapter==="r"&&(e.rStarted=!0),e.targetReady!==void 0&&await e.targetReady,await this.#c(e,t),this.snapshot(e).status==="terminated"&&n>0&&(e.options.adapter==="dart"||e.options.adapter==="kotlin")&&e.breakpoints.size>0){await Promise.all((e.clients??[i]).map(p=>p.dispose())),e.adapterProcess?.kill(),await Pe(e),e.client=void 0,e.controlClient=void 0,e.clients=void 0,e.adapterProcess=void 0,e.status="configured";for(let p of e.breakpoints.values())p.verified=!1;return this.#n(e),await this.#d(e,t,n-1)}return e}catch(s){throw await Promise.all((e.clients??[i]).map(u=>u.dispose())),e.adapterProcess?.kill(),await Pe(e),e.client=void 0,e.controlClient=void 0,e.clients=void 0,e.adapterProcess=void 0,e.targetReady=void 0,e.resolveTargetReady=void 0,e.status="configured",this.#n(e),s}}async refresh(e){if(e.vscode!==void 0){e.status==="running"&&await this.#e(e,e.vscode,await e.vscode.status(0));return}if(e.client!==void 0){for(let t=e.client.takeEvent(["breakpoint"]);t!==void 0;t=e.client.takeEvent(["breakpoint"]))this.#D(e,t);if(e.status!=="terminated")for(;;){let t=e.client.takeEvent([...e.status==="running"?["stopped"]:[],"terminated","exited"]);if(t===void 0)return;if(t.event==="stopped")await this.#P(e,t);else{e.status="terminated",e.stop=void 0,this.#n(e),await e.javaRuntime?.close();return}}}}async command(e,t,n){if(this.#t(e),await this.refresh(e),e.status!=="stopped"||e.stop===void 0)throw new Error(`Cannot ${t} while session is ${e.status}`);if(e.vscode!==void 0){let i=e.vscode,s=e.stop.frame;return e.stop=void 0,e.status="running",this.#n(e),await this.#e(e,i,await i.command(t,n),s),e}let o=j(e),a=e.stop.threadId;return await o.request(t,{threadId:a},{signal:n}),e.stop=void 0,e.status="running",this.#n(e),await this.#c(e,n),this.snapshot(e).status==="terminated"&&await e.javaRuntime?.close(),e}async evaluate(e,t,n){if(this.#t(e),await this.refresh(e),e.status!=="stopped"||e.stop?.frame===void 0)throw new Error(`Cannot evaluate while session is ${e.status}`);let o=t.trim(),a=e.stop,i=e.stop.frame.id;if(o.length===0)throw new Error("Debug evaluation requires an expression");if(e.vscode!==void 0){let u=await e.vscode.evaluate(o,n);return e.stop={...a,variables:await Dt(e.vscode,n)},this.#n(e),{expression:o,...u,variablesReference:0}}let s=await j(e).request("evaluate",{expression:o,frameId:e.stop.frame.id,context:e.options.adapter==="powershell"?"watch":"repl"},{signal:n});if(typeof s.result!="string")throw new Error("Debug adapter returned no evaluation result");return e.stop={...a,variables:await this.#S(e,i)},this.#n(e),{expression:o,result:s.result,variablesReference:s.variablesReference??0,...s.type===void 0?{}:{type:s.type}}}async delete(e,t){let n=this.get(e);if(n===void 0)throw new Error(`Unknown debug session ${e}`);let o=/\/breakpoint\/([a-f\d]{10})$/u.exec(e);if(o!==null){let a=n.breakpoints.get(o[1]);if(a===void 0)throw new Error(`Unknown debug breakpoint ${e}`);n.breakpoints.delete(a.id),await n.vscode?.removeBreakpoint(a.file,a.requestedLine,t),n.client!==void 0&&n.status!=="terminated"&&await this.#s(n,n.client,a.file,t),this.#n(n);return}if(e!==n.source)throw new Error(`Cannot delete debug resource ${e}`);await n.vscode?.close(t).catch(()=>{}),n.client!==void 0&&(await(n.controlClient??n.client).request("disconnect",{terminateDebuggee:!0},{signal:t,timeoutMs:500}).catch(()=>{}),await Promise.all((n.clients??[n.client]).map(a=>a.dispose()))),await n.javaRuntime?.close(),await Vr(n.adapterProcess),await Pe(n),n.status="terminated",this.#n(n),this.#o.delete(n.id)}async dispose(){await Promise.all(this.list().map(e=>this.delete(e.source)))}async#m(e){let t=await Mr(e.options,e.adapterTemporaryDirectory),n=e.options.adapter==="node"?await this.#v(e):e.options.adapter==="delve"?await this.#f(e):e.options.adapter==="ruby"?await this.#l(e):e.options.adapter==="julia"?await this.#p(e):e.options.adapter==="r"?await this.#h(e):k.start(t.command,t.args,e.options.cwd);return{...t,client:n}}async#l(e){let t=await se(),n=process.env.PI_RUBY_DEBUG_PATH??"rdbg";return e.adapterProcess=V(n,["--open","--host","127.0.0.1","--port",String(t),"--no-rc","--",e.options.program,...e.options.args],{cwd:e.options.cwd,env:process.env,stdio:["ignore","pipe","pipe"]}),De(e.adapterProcess,`rdbg:${String(t)}`),await St(e.adapterProcess,"Debugger can attach via TCP/IP","rdbg"),k.connect(t)}async#f(e){let t=await se(),n=process.env.PI_DELVE_PATH??"dlv";return e.adapterProcess=V(n,["dap",`--listen=127.0.0.1:${String(t)}`,"--log=false"],{cwd:e.options.cwd,env:process.env,stdio:["ignore","pipe","pipe"]}),e.adapterProcess.stderr?.on("data",()=>{}),await St(e.adapterProcess,"DAP server listening","Delve"),k.connect(t)}async#p(e){let t=await se(),n=process.env.PI_JULIA_PATH??"julia",o=process.env.PI_JULIA_DEBUG_PROJECT??"/opt/pi-debug-adapters/julia",a='using Sockets, DebugAdapter; server = listen(ip"127.0.0.1", parse(Int, ARGS[1])); conn = accept(server); run(DebugAdapter.DebugSession(conn)); close(server)';return e.adapterProcess=V(n,["--startup-file=no","--history-file=no",`--project=${o}`,"-e",a,String(t)],{cwd:e.options.cwd,env:process.env,stdio:["ignore","pipe","pipe"]}),De(e.adapterProcess,`DebugAdapter.jl:${String(t)}`),await new Promise(i=>setTimeout(i,25)),kt(t,"DebugAdapter.jl")}async#h(e){let t=_t.createServer();await new Promise((s,u)=>{t.once("error",u),t.listen(0,"127.0.0.1",()=>s())});let n=t.address();if(n===null||typeof n=="string")throw t.close(),new Error("Could not start the vscDebugger DAP listener");let o=new Promise((s,u)=>{t.once("connection",c=>{t.close();let p=k.fromSocket(c,2);p.onEvent(m=>this.#b(e,m)),s(p)}),t.once("error",u)}),a=process.env.PI_R_PATH??"R";e.rPromptInputs=[],e.rAtBrowserPrompt=!1,e.rStarted=!1,e.adapterProcess=V(a,["--vanilla","--quiet"],{cwd:e.options.cwd,env:process.env,stdio:["pipe","pipe","pipe"]}),De(e.adapterProcess,`vscDebugger:${String(n.port)}`),this.#w(e);let i=Fr({seq:1,type:"request",command:"initialize",arguments:{clientID:"pi-agent-ide",adapterID:"R-Debugger",pathFormat:"path",linesStartAt1:!0,columnsStartAt1:!0,supportsVariableType:!0,supportsVariablePaging:!0,supportsWriteToStdinEvent:!0,supportsStdoutReading:!0,rStrings:{packageName:"vscDebugger",prompt:"__PI_R_PROMPT__",continue:"__PI_R_CONTINUE__",attachName:"tools:vscDebugger"},useDapSocket:!0,dapHost:"127.0.0.1",dapPort:n.port}});return e.adapterProcess.stdin?.write(`library(vscDebugger); vscDebugger:::.vsc.handleDap(${JSON.stringify(i)})
12
+ `),Hr(o,e.adapterProcess,t)}#b(e,t){if(process.env.PI_DEBUG_DAP_TRACE==="1"&&process.stderr.write(`[vscDebugger:event] ${JSON.stringify(t)}
13
+ `),t.event!=="custom")return;let n=B(t.body),o=typeof n.reason=="string"?n.reason:"",a=typeof n.text=="string"?n.text:"";if(!(o!=="writeToStdin"||a.length===0)){if(n.when==="browserPrompt"&&e.rAtBrowserPrompt===!0){e.rAtBrowserPrompt=!1,e.adapterProcess?.stdin?.write(`${a}
14
+ `);return}e.rPromptInputs?.push(a)}}#w(e){let t="";e.adapterProcess?.stdout?.on("data",n=>{for(t+=n.toString("utf8");;){let o=/Browse\[\d+\]> /u.exec(t),a=/(?:^|\r?\n)__PI_R_PROMPT__(?:\r?\n|$)/u.exec(t),i=o?.index??Number.POSITIVE_INFINITY,s=a?.index??Number.POSITIVE_INFINITY;if(!Number.isFinite(i)&&!Number.isFinite(s)){t=t.slice(-128);return}if(i<s){t=t.slice(i+(o?.[0].length??0));let u=e.rPromptInputs?.shift();u===void 0?(e.rAtBrowserPrompt=!0,setTimeout(()=>{e.rAtBrowserPrompt===!0&&(e.rAtBrowserPrompt=!1,e.adapterProcess?.stdin?.write(`vscDebugger::.vsc.listenForDAP(timeout=-1)
15
+ `))},100)):e.adapterProcess?.stdin?.write(`${u}
16
+ `)}else t=t.slice(s+(a?.[0].length??0)),e.adapterProcess?.stdin?.write(`vscDebugger::.vsc.listenForDAP(timeout=-1)
17
+ `),e.rStarted===!0&&e.client?.request("custom",{reason:"showingPrompt",which:"topLevel"}).catch(()=>{})}})}async#v(e){let t=await se(),n=process.env.PI_JS_DEBUG_PATH??"/opt/pi-debug-adapters/js-debug/src/dapDebugServer.js";e.adapterProcess=V(process.execPath,[n,String(t),"127.0.0.1"],{cwd:e.options.cwd,env:process.env,stdio:["ignore","pipe","pipe"]}),e.adapterProcess.stderr?.on("data",()=>{}),await qr(e.adapterProcess);let o=await kt(t);return o.onReverseRequest(this.#y(e,()=>k.connect(t))),o}#y(e,t){return async n=>{if(n.command!=="startDebugging")throw new Error(`Client does not support reverse request ${n.command}`);let o=B(n.arguments),a=B(o.configuration),i=this.#t(e),s=await t();e.clients?.push(s),s.onReverseRequest(this.#y(e,t)),await ve(s,"pwa-node");let u=s.waitForEvent("initialized"),c=s.request(typeof o.request=="string"?o.request:"launch",{...a,sourceMaps:!0,pauseForSourceMap:!0,outFiles:[E.join(E.dirname(i?.serverPath(e.options.program)??e.options.program),"**","*.js")]});return await Promise.race([u,c.then(()=>u)]),e.client=s,await this.#g(e,s),await s.request("configurationDone"),await c,e.resolveTargetReady?.(),{}}}async#g(e,t,n){let o=new Set([...e.breakpoints.values()].map(a=>a.file));for(let a of o)await this.#s(e,t,a,n)}async#s(e,t,n,o){let a=[...e.breakpoints.values()].filter(s=>s.file===n),i=await t.request("setBreakpoints",{source:{path:this.#t(e)?.serverPath(n)??n,name:E.basename(n)},breakpoints:a.map(({requestedLine:s})=>({line:s})),sourceModified:!1},{signal:o});for(let[s,u]of a.entries()){let c=i.breakpoints?.[s];u.verified=c?.verified===!0,u.line=c?.line??u.requestedLine,u.adapterId=c?.id}}async#c(e,t){let n=await j(e).waitForAnyEvent(["stopped","terminated","exited","loadedSource","breakpoint","custom"],3e4,t),o=B(n.body);if(n.event==="custom"&&e.options.adapter==="r"){await this.#c(e,t);return}if(n.event==="loadedSource"){let a=B(o.source),i=this.#t(e);if(i!==void 0&&e.options.adapter==="node"&&typeof a.path=="string"&&!E.posix.isAbsolute(a.path)){await this.#c(e,t);return}let s=typeof a.path=="string"?i?.resourcePath(a.path)??E.resolve(a.path):void 0,u=s===void 0?void 0:[...e.breakpoints.values()].find(c=>U(c.file,s))?.file;u!==void 0&&await this.#s(e,j(e),u,t),await this.#c(e,t);return}if(n.event==="breakpoint"){this.#D(e,n),await this.#c(e,t);return}if(o.reason==="exit"){e.status="terminated",e.stop=void 0,this.#n(e);return}if(e.options.adapter==="node"&&o.reason==="entry"){await this.#g(e,j(e),t);let a=typeof o.threadId=="number"?o.threadId:1;await j(e).request("continue",{threadId:a},{signal:t}),await this.#c(e,t);return}if((e.options.adapter==="dart"||e.options.adapter==="kotlin")&&o.reason==="entry"){let a=j(e);if(await this.#g(e,a,t),e.options.adapter==="kotlin"){let s=Date.now()+5e3;for(;[...e.breakpoints.values()].some(u=>!u.verified)&&Date.now()<s;)await new Promise(u=>setTimeout(u,50)),await this.#g(e,a,t)}let i=typeof o.threadId=="number"?o.threadId:1;await a.request("continue",{threadId:i},{signal:t}),await this.#c(e,t);return}if(n.event!=="stopped"){e.status="terminated",e.stop=void 0,this.#n(e);return}if(await this.#P(e,n,e.options.adapter!=="shell"),e.options.adapter==="r"&&e.stop?.frame?.source?.path===void 0){e.stopGeneration--,e.stop=void 0,e.status="running",await this.#c(e,t);return}if(e.options.adapter==="shell"&&e.stopGeneration===1&&e.stop?.frame!==void 0&&![...e.breakpoints.values()].some(a=>U(a.file,e.stop?.frame?.source?.path??"")&&a.line===e.stop?.frame?.line)){let a=e.stop.threadId;e.stopGeneration--,e.stop=void 0,e.status="running",await j(e).request("continue",{threadId:a},{signal:t}),await this.#c(e,t);return}e.options.adapter==="shell"&&this.#n(e)}#D(e,t){let n=B(B(t.body).breakpoint),o=B(n.source);for(let a of e.breakpoints.values())(typeof n.id=="number"&&a.adapterId!==void 0?n.id===a.adapterId:typeof o.path=="string"&&U(this.#t(e)?.resourcePath(o.path)??o.path,a.file)&&n.line===a.requestedLine)&&(typeof n.line=="number"&&(a.line=n.line),a.verified=n.verified===!0);this.#n(e)}async#P(e,t,n=!0){let o=j(e),a=B(t.body),i=(await o.request("threads")).threads?.[0]?.id,s=typeof a.threadId=="number"?a.threadId:i;if(s===void 0)throw new Error("Debugger stopped without a thread");let u=this.#t(e),c=(await Ur(o,s,e.options.adapter==="dart")).stackFrames?.[0],p=c?.source?.path===void 0||u===void 0?c:{...c,source:{...c.source,path:u.resourcePath(c.source.path)}};if(p?.source?.path!==void 0)for(let l of e.breakpoints.values())U(l.file,p.source.path)&&l.line===p.line&&(l.verified=!0);let m=p===void 0?[]:await this.#S(e,p.id);e.stopGeneration++,e.stop={generation:e.stopGeneration,reason:typeof a.reason=="string"?a.reason:"stopped",threadId:s,...p===void 0?{}:{frame:p},variables:m,sourceLines:p===void 0?[]:await Pt(p,u?.readText.bind(u))},e.status="stopped",n&&this.#n(e)}async#S(e,t){let n=j(e),o=(await n.request("scopes",{frameId:t})).scopes??[],a=e.options.adapter==="r"?o:o.filter(s=>[s.name.toLowerCase(),s.presentationHint?.toLowerCase()].some(u=>u?.includes("local")===!0||u==="variables")),i=[];for(let s of a){let u=await n.request("variables",{variablesReference:s.variablesReference,start:0,count:100});i.push(...u.variables??[])}return i}#n(e){let t=this.snapshot(e);for(let n of this.#a)n(t)}};function Or(r,e,t){let n=new Set([...r.breakpoints.values()].filter(o=>o.line===e.line).map(o=>o.file));return n.size===1?[...n][0]:t?.name===e.name?t.source?.path:void 0}d(Or,"inferVscodeFrameFile");function Nr(r){return r===void 0?{}:{source:{path:r}}}d(Nr,"withSourcePath");async function Dt(r,e){return(await r.locals(e)).map(t=>({...t,variablesReference:0}))}d(Dt,"vscodeVariables");async function Pt(r,e){let t=r.source?.path;if(t===void 0)return[];try{let n=(await(e===void 0?Et(t,"utf8"):e(t))).split(/\r?\n/u),o=Math.max(1,r.line-2),a=Math.min(n.length,r.line+2);return n.slice(o-1,a).map((i,s)=>({lineNumber:o+s,content:i,current:o+s===r.line}))}catch(n){if(e!==void 0)throw n;return[]}}d(Pt,"sourceWindow");async function Ur(r,e,t){let n=Date.now()+1e3,o;do{try{let a=await r.request("stackTrace",{threadId:e});if(!t||(a.stackFrames?.length??0)>0)return a;o=new Error("Debugger stack is not ready")}catch(a){if(o=a,!t)throw a}await new Promise(a=>setTimeout(a,25))}while(Date.now()<n);throw o instanceof Error?o:new Error("Could not read debugger stack")}d(Ur,"requestStackTrace");function z(r){let e=[`Session: ${r.source}`,`Adapter: ${r.options.adapter}`,`Program: ${E.relative(r.options.cwd,r.options.program)||r.options.program}`,`Status: ${r.status}`];if(r.breakpoints.size>0){e.push("","Breakpoints:");for(let t of r.breakpoints.values())e.push(`- ${t.source} ${E.relative(r.options.cwd,t.file)}:${t.line} (${t.verified?"verified":"pending"})`)}if(r.stop!==void 0){let{stop:t}=r;if(e.push("",`Stop: ${t.generation} (${t.reason})`,`Thread: ${t.threadId}`),t.frame!==void 0&&e.push(`Frame: ${t.frame.name} at ${t.frame.source?.path??t.frame.source?.name??"unknown"}:${t.frame.line}`),t.variables.length>0){e.push("","Locals:");for(let n of t.variables)e.push(`- ${n.name}: ${n.value}${n.type===void 0?"":` (${n.type})`}`)}}return e.join(`
18
+ `)}d(z,"renderDebugSession");function j(r){if(r.client===void 0)throw new Error("Debug adapter is not running");return r.client}d(j,"requiredClient");function B(r){return typeof r=="object"&&r!==null?r:{}}d(B,"asRecord");function Fr(r){let e=JSON.stringify(r);return`Content-Length: ${Buffer.byteLength(e,"utf8")}\r
19
+ \r
20
+ ${e}`}d(Fr,"dapFrame");function ve(r,e,t){return r.request("initialize",{clientID:"pi-agent-ide",adapterID:e,pathFormat:"path",linesStartAt1:!0,columnsStartAt1:!0,supportsVariableType:!0,supportsVariablePaging:!0,supportsRunInTerminalRequest:!1,supportsStartDebuggingRequest:!0},{signal:t})}d(ve,"initializeClient");function se(){return new Promise((r,e)=>{let t=_t.createServer();t.once("error",e),t.listen(0,"127.0.0.1",()=>{let n=t.address();if(n===null||typeof n=="string"){t.close(),e(new Error("Could not allocate a debug adapter port"));return}t.close(o=>o===void 0?r(n.port):e(o))})})}d(se,"availablePort");function De(r,e){if(process.env.PI_DEBUG_DAP_TRACE==="1"){process.stderr.write(`[${e}] pid=${String(r.pid)}
21
+ `),r.once("exit",(t,n)=>process.stderr.write(`[${e}] exit code=${String(t)} signal=${String(n)}
22
+ `));for(let t of[r.stdout,r.stderr])t?.on("data",n=>process.stderr.write(`[${e}] ${n.toString("utf8")}`))}}d(De,"traceAdapterProcess");function Hr(r,e,t){return new Promise((n,o)=>{let a=setTimeout(()=>s(new Error("Timed out starting vscDebugger")),5e3),i=d(()=>{clearTimeout(a),e.off("error",s),e.off("exit",u)},"cleanup"),s=d(c=>{i(),t.close(),e.killed||e.kill(),o(c)},"fail"),u=d(c=>s(new Error(`vscDebugger exited with code ${String(c)} before connecting`)),"onExit");e.once("error",s),e.once("exit",u),r.then(c=>{i(),n(c)},s)})}d(Hr,"waitForRAdapterConnection");function St(r,e,t){return new Promise((n,o)=>{let a=[r.stdout,r.stderr].filter(c=>c!==null),i=setTimeout(()=>o(new Error(`Timed out starting ${t} server`)),process.platform==="win32"?15e3:5e3),s=d(()=>{clearTimeout(i);for(let c of a)c.off("data",u)},"cleanup"),u=d(c=>{c.toString("utf8").includes(e)&&(s(),n())},"onData");for(let c of a)c.on("data",u);r.once("error",c=>{s(),o(c)}),r.once("exit",c=>{s(),o(new Error(`${t} server exited with code ${String(c)}`))})})}d(St,"waitForAdapterReady");function qr(r){return new Promise((e,t)=>{let n=r.stdout;if(n===null){t(new Error("js-debug server stdout is unavailable"));return}let o=setTimeout(()=>t(new Error("Timed out starting js-debug server")),5e3),a=d(i=>{i.toString("utf8").includes("Debug server listening")&&(clearTimeout(o),n.off("data",a),e())},"onData");n.on("data",a),r.once("error",t),r.once("exit",i=>t(new Error(`js-debug server exited with code ${i}`)))})}d(qr,"waitForJsDebugReady");async function kt(r,e="js-debug"){let t;for(let n=0;n<100;n++)try{return await k.connect(r)}catch(o){t=o,await new Promise(a=>setTimeout(a,25))}throw t instanceof Error?t:new Error(`Could not connect to ${e}`)}d(kt,"connectWithRetry");async function Pe(r){r.adapterTemporaryDirectory!==void 0&&(await Lr(r.adapterTemporaryDirectory,{recursive:!0,force:!0,maxRetries:process.platform==="win32"?10:0,retryDelay:100}),r.adapterTemporaryDirectory=void 0)}d(Pe,"removeAdapterTemporaryDirectory");async function Vr(r){if(!(r===void 0||r.exitCode!==null||r.signalCode!==null)){if(process.platform!=="win32"||r.pid===void 0){r.kill();return}await new Promise(e=>{let t=V("taskkill.exe",["/pid",String(r.pid),"/t","/f"],{stdio:"ignore",windowsHide:!0});t.once("error",()=>{r.kill(),e()}),t.once("exit",()=>e())})}}d(Vr,"terminateOwnedAdapterProcess");async function Mr(r,e){let t={name:"Pi Agent IDE debug session",request:"launch",program:r.program,cwd:r.cwd,args:[...r.args]};if(r.adapter==="dart")return{command:process.env.PI_DART_PATH??"dart",args:["debug_adapter"],adapterID:"dart",request:"launch",launch:{...t,type:"dart",debugSdkLibraries:!1,debugExternalPackageLibraries:!1,stopOnEntry:!0,vmAdditionalArgs:["--pause-isolates-on-start"]}};if(r.adapter==="debugpy"){let n=await Y(r.cwd);return{command:n.command,args:[...n.args,"-m","debugpy.adapter"],adapterID:"debugpy",request:"launch",launch:{...t,type:"python",console:"internalConsole",justMyCode:!1}}}if(r.adapter==="kotlin"){if(r.mainClass===void 0)throw new Error("Java and Kotlin debug sessions require mainClass");return{command:process.env.PI_KOTLIN_DEBUG_ADAPTER_PATH??"kotlin-debug-adapter",args:[],adapterID:r.adapter,request:"launch",launch:{...t,type:"kotlin",mainClass:r.mainClass,projectRoot:r.cwd,stopOnEntry:!0}}}if(r.adapter==="netcoredbg")return{command:process.env.PI_NETCOREDBG_PATH??"netcoredbg",args:["--interpreter=vscode"],adapterID:"coreclr",request:"launch",launch:{...t,type:"coreclr",console:"internalConsole"}};if(r.adapter==="elixir")return{command:process.env.PI_ELIXIR_LS_DEBUG_PATH??(process.platform==="win32"?"debug_adapter.bat":"/opt/pi-debug-adapters/elixir-ls/debug_adapter.sh"),args:[],adapterID:"mix_task",request:"launch",launch:{name:t.name,request:"launch",type:"mix_task",task:"run",taskArgs:[r.program,...r.args],projectDir:r.cwd,startApps:!0,exitAfterTaskReturns:!0}};if(r.adapter==="julia")return{command:process.env.PI_JULIA_PATH??"julia",args:[],adapterID:"julia",request:"launch",launch:{...t,type:"julia",stopOnEntry:!1}};if(r.adapter==="lldb-dap")return{command:E.extname(r.sourceFile).toLowerCase()===".swift"?process.env.PI_SWIFT_LLDB_DAP_PATH??process.env.PI_LLDB_DAP_PATH??"lldb-dap":process.env.PI_LLDB_DAP_PATH??(process.platform==="win32"?"lldb-dap":"lldb-dap-18"),args:[],adapterID:"lldb-dap",request:"launch",launch:{...t,type:"lldb-dap"}};if(r.adapter==="delve")return{command:process.env.PI_DELVE_PATH??"dlv",args:[],adapterID:"go",request:"launch",launch:{...t,type:"go",mode:"debug"}};if(r.adapter==="r")return{command:process.env.PI_R_PATH??"R",args:[],adapterID:"R-Debugger",request:"launch",launch:{name:t.name,request:"launch",type:"R-Debugger",debugMode:"file",file:r.program,workingDirectory:r.cwd,commandLineArgs:[...r.args],allowGlobalDebugging:!1,loadPackages:[],supportsStdoutReading:!0,supportsWriteToStdinEvent:!0,overwriteHelp:!1}};if(r.adapter==="ruby")return{command:process.env.PI_RUBY_DEBUG_PATH??"rdbg",args:[],adapterID:"rdbg",request:"launch",launch:{...t,type:"rdbg"}};if(r.adapter==="php")return{command:process.execPath,args:[process.env.PI_PHP_DEBUG_PATH??"/opt/pi-debug-adapters/php-debug/extension/out/phpDebug.js"],adapterID:"php",request:"launch",launch:{...t,type:"php",runtimeExecutable:process.env.PI_PHP_PATH??"php",runtimeArgs:["-dxdebug.start_with_request=yes"],console:"internalConsole",port:0,env:{XDEBUG_MODE:"debug,develop",XDEBUG_CONFIG:"client_port=${port}"}}};if(r.adapter==="lua")return{command:process.execPath,args:[process.env.PI_LUA_DEBUG_PATH??"/opt/pi-debug-adapters/lua-debug/extension/extension/debugAdapter.js"],adapterID:"lua-local",request:"launch",launch:{...t,type:"lua-local",program:{lua:process.env.PI_LUA_PATH??"lua",file:r.program},extensionPath:E.dirname(E.dirname(process.env.PI_LUA_DEBUG_PATH??"/opt/pi-debug-adapters/lua-debug/extension/extension/debugAdapter.js")),workspacePath:r.cwd}};if(r.adapter==="shell"){let n=process.env.PI_BASH_DEBUG_ROOT??"/opt/pi-debug-adapters/bash-debug/extension";return{command:process.execPath,args:[process.env.PI_BASH_DEBUG_PATH??E.join(n,"out/bashDebug.js")],adapterID:"bashdb",request:"launch",launch:{...t,type:"bashdb",pathBash:process.env.PI_BASH_PATH??"/usr/bin/bash",pathBashdb:E.join(n,"bashdb_dir/bashdb"),pathBashdbLib:E.join(n,"bashdb_dir"),pathCat:"/usr/bin/cat",pathMkfifo:"/usr/bin/mkfifo",pathPkill:"/usr/bin/pkill",terminalKind:"debugConsole",argsString:"",env:{},showDebugOutput:!1,trace:!1}}}if(r.adapter==="powershell"){let n=process.env.PI_POWERSHELL_EDITOR_SERVICES_PATH??"/opt/pi-debug-adapters/powershell-editor-services";if(e===void 0)throw new Error("PowerShell debugger temporary directory was not created");return{command:process.env.PI_PWSH_PATH??"pwsh",args:["-NoLogo","-NoProfile","-Command",`& '${E.join(n,"PowerShellEditorServices/Start-EditorServices.ps1").replaceAll("'","''")}' -LogPath '${E.join(e,"logs").replaceAll("'","''")}' -LogLevel Warning -SessionDetailsPath '${E.join(e,"session.json").replaceAll("'","''")}' -FeatureFlags @() -AdditionalModules @() -HostName 'Pi Agent IDE' -HostProfileId 'pi-agent-ide' -HostVersion '1.0.0' -BundledModulesPath '${n.replaceAll("'","''")}' -Stdio -DebugServiceOnly`],adapterID:"PowerShell",request:"launch",launch:{...t,script:r.program,createTemporaryIntegratedConsole:!1,executeMode:"Call"}}}return{command:process.execPath,args:[],adapterID:"pwa-node",request:"launch",launch:{...t,type:"pwa-node",console:"internalConsole",autoAttachChildProcesses:!1,stopOnEntry:!0,sourceMaps:!0,pauseForSourceMap:!0,outFiles:[E.join(E.dirname(r.program),"**","*.js")]}}}d(Mr,"adapterRecipe");var Se=y.Object({source:y.String(),sourceResource:y.String(),breakpointsResource:y.String(),adapter:y.String(),program:y.String(),cwd:y.String(),status:y.String(),breakpoints:y.Array(y.Object({source:y.String(),file:y.String(),line:y.Integer(),verified:y.Boolean()},{additionalProperties:!1}))},{additionalProperties:!1}),Wr=Ee(Se),zr=y.Object({backend:y.Optional(At(["auto","vscode","native"],{description:"Select the debugger backend. auto (default) debugs through VS Code when the local program is inside a workspace open in VS Code with the DebugMCP extension, that window has no active debug session, and args and mainClass are omitted; otherwise it uses the native adapter. vscode fails with the unmet condition instead of falling back. native always launches the selected adapter."})),adapter:y.Optional(At(["dart","debugpy","delve","java","elixir","julia","kotlin","lldb-dap","lua","netcoredbg","node","php","powershell","r","ruby","shell"],{description:"Select an installed native DAP adapter for Dart, Python, Go, Java, Elixir, Julia, Kotlin, C, C++, Rust, Swift, Zig, Lua, C#, JavaScript, TypeScript, PHP, PowerShell, R, Ruby, or shell scripts. Required for the native backend; VS Code chooses its debugger from launch.json or the file type."})),program:y.String({minLength:1,description:"Source file or executable to launch. Relative paths resolve from cwd."}),source:y.Optional(y.String({description:"Source file used for anchored breakpoints. Defaults to program. Relative paths resolve from cwd."})),args:y.Optional(y.Array(y.String(),{description:"Arguments passed to the debugged program by the native backend. For VS Code, put them in a launch.json configuration."})),mainClass:y.Optional(y.String({minLength:1,description:"Fully qualified JVM main class. Required by Java and Kotlin adapters."})),configuration:y.Optional(y.String({minLength:1,description:"Name of a .vscode/launch.json configuration to launch in VS Code. Use it for program arguments or environment. VS Code backend only."})),test:y.Optional(y.String({minLength:1,description:"Name of one test to debug through the VS Code Testing API; set program to its test file. VS Code backend only."})),cwd:y.Optional(y.String({description:"Select a local working directory or ssh://target/absolute/path. Relative paths resolve from the workspace."}))},{additionalProperties:!1});async function xt(r,e){$e(r,[await je({id:"debugger",description:"Debugger sessions, breakpoints, stepping, and cleanup",triggers:[{tool:"debug"},...["read","insert","delete"].map(m=>({tool:m,resourcePrefixes:["debug:"]}))]})]);let t=Ke("debugger",W)??new W;t.setOwnerResolver(e?.workspace);let n=new Map,o=Rt(t,"debugger-source"),a=Rt(t,"debugger-input"),i=We(r).add(yt(t)),s=ct(t),u={protocol:Ae,apiVersion:Re,id:"debugger",setup(m){m.addResolver({resolver:o,matchesCall:d(l=>t.sourceFile(l)!==void 0,"matchesCall"),renderCall(l,h,f){let g=F(l)?l:{},b=typeof g.path=="string"?g.path:"",v=t.get(b),w=t.sourceFile(b);if(v===void 0||w===void 0)throw new Error("Debugger source header lost its session");let P=O.relative(v.options.cwd,w),_=Array.isArray(g.views)?g.views.filter(K=>typeof K=="string"):[],x=typeof g.offset=="number"?g.offset:1,I=typeof g.limit=="number"?g.limit:void 0,L=I===void 0?String(x):`${x}-${x+I-1}`;return Ce(f.lastComponent,{tool:"debug file",primary:{text:`${P}:${L}`,color:"accent",underline:!0},qualifiers:_.length===0?[]:[{text:`views ${_.join(",")}`}],details:[{label:"source",value:b},{label:"file",value:w},..._.length===0?[]:[{label:"views",value:_.join(",")}]],expanded:f.expanded},h)}}),m.addView({view:"breakpoints",presenter:s})}},c={protocol:Te,apiVersion:xe,id:"debugger",setup(m){m.addResolver({resolver:a}),m.tool("insert").addSemanticHandler({matches:d(l=>Xr(l,t),"matches"),execute:d(async(l,h)=>{let f=h,g=Tt(t,f.path);if(t.sourceFile(f.path)!==void 0){if(f.text!=="breakpoint"||f.anchor===void 0)throw new Error('A debug source accepts text "breakpoint" with one anchor');let v=await l.resolveAnchor("anchor"),w=await t.addBreakpoint(f.path,v.lineNumber,l.signal);return{source:w.source,summary:`Breakpoint ${w.source} registered at ${O.relative(g.options.cwd,w.file)}:${w.line} (${w.verified?"verified":"pending"}).`,data:{kind:"debug-breakpoint",session:g.source,file:w.file,line:w.line,verified:w.verified,snapshot:t.snapshot(g)}}}if(f.path!==g.source||f.anchor!==void 0)throw new Error("Debug commands target the session resource without an anchor");let b;try{b=await Zr(t,g,f.text,l.signal)}catch(v){if(l.signal?.aborted===!0)throw v;let w=v instanceof Error?v.message:String(v);return{source:g.source,summary:`${f.text.trim()} failed: ${w}
23
+
24
+ ${z(g)}`,data:{...It(t,g,f.text),ok:!1,effect:"not-applied",error:{code:"DEBUG_ACTION_FAILED",message:w}}}}return{source:g.source,summary:b===void 0?z(g):`${b.expression} = ${b.result}${b.type===void 0?"":` (${b.type})`}`,data:It(t,g,f.text,b)}},"execute")}),m.tool("delete").addSemanticHandler({matches:d(l=>Yr(l,t),"matches"),execute:d(async(l,h)=>{let f=h.path,g=Tt(t,f),b=t.snapshot(g);n.set(f,b);let v=f.includes("/breakpoint/");await t.delete(f,l.signal);let w=v?t.snapshot(g):{...b,status:"terminated"};return{source:f,summary:`Deleted ${f}.`,data:{kind:v?"debug-breakpoint":"debug-session",deleted:!0,snapshot:w}}},"execute")});for(let l of["insert","delete"])m.addToolRenderer({tool:l,matches(h,f){return f==="call"?F(h)&&typeof h.path=="string"&&(t.get(h.path)!==void 0||n.has(h.path)):we(F(h)&&"details"in h?h.details:h)!==void 0},renderCall(h,f,g){let b=h,v=b.path===void 0?void 0:t.get(b.path),w=b.path===void 0?void 0:n.get(b.path),P=g.state;v!==void 0?P.snapshot=t.snapshot(v):w!==void 0&&(P.snapshot=w);let _=P.snapshot;if(_===void 0)throw new Error("Debugger renderer lost its session");let x=b.path===void 0?void 0:t.breakpoint(b.path)??(w??_).breakpoints.find(K=>K.source===b.path),I=b.path===void 0?void 0:t.sourceFile(b.path),L=l==="delete"?x===void 0?"delete-session":`delete-breakpoint ${O.basename(x.file)}:${x.line}`:b.text==="breakpoint"&&I!==void 0?`breakpoint ${O.basename(I)}:${tn(b)}`:b.text??"debug action";return lt(_,L,f)},renderResult(h,f,g){let b=we(h.details);if(b===void 0)throw new Error("Debugger result is missing its session");let v=ht(h.details);return G(b,f.expanded,g,v,wt(h.details))}})}};await Promise.all([Oe(r,it),Ie(r,u)]),await Ne(r,c),r.registerTool(Gr({name:"debug",exposure:"deferred",namespace:{name:"ide_debug",description:"Create debugger sessions and inspect debug resources."},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},label:"Debug session",promptSnippet:"Configure a local debugger session",description:"Use debug to create a configured debugger session on a local or supported SSH workspace, through VS Code or a native adapter. This does not launch the program yet. The returned debug: resource survives extension reloads.",parameters:zr,outputSchema:Wr,async execute(m,l,h,f,g){let b=l.backend??"auto",v=l.cwd??g.cwd,w=l.program;try{if(h?.throwIfAborted(),b==="vscode"&&[l.cwd,l.program,l.source].some(de=>de?.includes("://")))throw new Error("The VS Code backend debugs only local workspaces");let P=await e?.resolveOptions(l,g.cwd,h);if(P===void 0&&[v,w,l.source].some(de=>de?.includes("://")))throw new Error(`No debugger workspace owner: ${w}`);v=P?.cwd??O.resolve(g.cwd,l.cwd??"."),w=P?.program??O.resolve(v,l.program),P===void 0&&await Jr(w),h?.throwIfAborted();let _=O.resolve(v,l.source??l.program),x=P===void 0&&b!=="native"?await Kr(b,l,{cwd:v,program:w,sourceFile:_},h):{unavailable:"native backend requested"},I;if("vscode"in x)I=t.create({adapter:"vscode",program:w,sourceFile:_,args:[],cwd:v,...l.configuration===void 0?{}:{configuration:l.configuration},...l.test===void 0?{}:{test:l.test}},x.vscode);else{if(l.configuration!==void 0||l.test!==void 0)throw new Error("configuration and test need the VS Code backend");if(P!==void 0)I=t.create(P);else{if(l.adapter===void 0)throw new Error(`Select an adapter for the native debugger backend. VS Code is not used: ${x.unavailable}`);I=t.create({adapter:l.adapter,program:w,sourceFile:_,args:l.args??[],cwd:v,...l.mainClass===void 0?{}:{mainClass:l.mainClass}})}}let L=Qr(t,I),{snapshot:K,stop:hn,...Ut}=L;return ue({content:[{type:"text",text:`${z(I)}
25
+ Source: ${L.sourceResource}
26
+ Breakpoints: ${L.breakpointsResource}
27
+
28
+ Next: read ${I.source} to inspect the configured session. To set a breakpoint, read ${L.sourceResource} with views ["anchors"], then insert "breakpoint" at an anchor.`}],details:L},Se,{status:"success",data:Ut,errors:[]})}catch(P){return ue({content:[{type:"text",text:P instanceof Error?P.message:String(P)}],details:{adapter:l.adapter??b,program:w,cwd:v,status:"failed"},isError:!0},Se,{status:"error",errors:[_e(P,"DEBUG_SESSION_FAILED",w)]})}},renderCall(m,l){let h=typeof m.cwd=="string"?m.cwd:".",f=typeof m.program=="string"?m.program:"program",g=h.startsWith("ssh://")?h:O.resolve(process.cwd(),h),b=f.startsWith("ssh://")||g.startsWith("ssh://")?f:O.resolve(g,f);return he(typeof m.adapter=="string"?m.adapter:m.backend==="vscode"?"vscode":"debugger",b,g,l)},renderResult(m,l,h){let f=F(m.details)?m.details.snapshot:void 0;if(typeof f=="object"&&f!==null)return G(f,l.expanded,h);let g=m.details;return he(g.adapter,g.program,g.cwd,h)}}));let p='For debug:<session> resources, insert performs debugger actions without changing source text. On a debug source, insert "breakpoint" at an anchor. On the session, insert start, continue, step over, step into, step out, or evaluate <expression>. Delete removes a breakpoint or terminates the session.';Fe(r,{version:1,id:"debugger",tools:["debug"],schemas:{read:{parameters:{path:"debug:<session> \u2014 debugger state.",views:"breakpoints \u2014 breakpoints beside the lines."}},insert:{parameters:{path:"debug:<session> controls the debugger; debug:<session>/source with a line anchor sets a breakpoint.",text:"For debug:<session>: start, continue, step over, step into, step out or evaluate <expression> (needs a stopped frame). For debug:<session>/source: breakpoint.",anchor:"Omit for debug:<session>."},promptGuidelines:[p]},delete:{parameters:{path:"debug:<session> ends it; debug:<session>/breakpoint/<id> removes a breakpoint."},promptGuidelines:[p]}}}),r.on("session_shutdown",async m=>{if(i(),m.reason!=="quit"){ze("debugger",t);return}Xe("debugger",t),await t.dispose()})}d(xt,"registerDebuggerWithOwner");async function Kr(r,e,t,n){try{let o=(e.args?.length??0)>0?"args":e.mainClass===void 0?void 0:"mainClass";if(o!==void 0)throw new Error(`it does not accept ${o}; use a launch.json configuration`);return{vscode:await ne.open(t,n)}}catch(o){n?.throwIfAborted();let a=o instanceof Error?o.message:String(o);if(r==="vscode"||e.configuration!==void 0||e.test!==void 0)throw new Error(`VS Code backend unavailable: ${a}`,{cause:o});return{unavailable:a}}}d(Kr,"openVscodeBackend");function Rt(r,e){return{id:e,tryResolve(t){let n=r.get(t);return n===void 0?Promise.resolve({kind:"not-handled"}):Promise.resolve({kind:"resolved",resource:{source:t,async read(){await r.refresh(n);let o=r.sourceFile(t);if(o!==void 0)return[rn(o,await r.readSource(t))];if(t===`${n.source}/breakpoints`)return[{type:"text",text:en(n)}];let a=r.breakpoint(t);if(t!==n.source&&a===void 0)throw new Error(`Unknown debug resource ${t}`);return[{type:"text",text:a===void 0?z(n):`Breakpoint: ${a.source}
29
+ File: ${a.file}
30
+ Line: ${a.line}
31
+ Status: ${a.verified?"verified":"pending"}`}]}}})}}}d(Rt,"createDebugResourceResolver");function Xr(r,e){if(!F(r)||typeof r.path!="string"||typeof r.text!="string")return!1;let t=e.get(r.path);return t!==void 0&&(r.path===t.source||e.sourceFile(r.path)!==void 0)}d(Xr,"matchesDebugInsert");function Yr(r,e){if(!F(r)||typeof r.path!="string")return!1;let t=e.get(r.path);return t!==void 0&&(r.path===t.source||r.path.startsWith(`${t.source}/breakpoint/`))}d(Yr,"matchesDebugDelete");async function Zr(r,e,t,n){let o=t.trim(),a=/^evaluate\s+(.+)$/isu.exec(o);if(a!==null)return await r.evaluate(e,a[1],n);switch(o.toLowerCase()){case"start":{await r.start(e,n);return}case"continue":{await r.command(e,"continue",n);return}case"step over":{await r.command(e,"next",n);return}case"step into":{await r.command(e,"stepIn",n);return}case"step out":{await r.command(e,"stepOut",n);return}default:throw new Error(`Unknown debug command ${JSON.stringify(t)}`)}}d(Zr,"executeSessionCommand");function Qr(r,e){return{source:e.source,sourceResource:r.sourceResource(e),breakpointsResource:`${e.source}/breakpoints`,adapter:e.options.adapter,program:e.options.program,cwd:e.options.cwd,status:e.status,breakpoints:[...e.breakpoints.values()].map(({source:t,file:n,line:o,verified:a})=>({source:t,file:n,line:o,verified:a})),...e.stop===void 0?{}:{stop:e.stop},snapshot:r.snapshot(e)}}d(Qr,"debugDetails");function It(r,e,t,n){return{kind:"debug-command",command:t,status:e.status,breakpoints:[...e.breakpoints.values()].map(({source:o,file:a,line:i,verified:s})=>({source:o,file:a,line:i,verified:s})),...e.stop===void 0?{}:{stop:e.stop},...n===void 0?{}:{evaluation:n},snapshot:r.snapshot(e)}}d(It,"debugActionData");function en(r){return r.breakpoints.size===0?`No breakpoints in ${r.source}.`:[...r.breakpoints.values()].map(e=>`${e.verified?"\u25CF":"\u25CB"} ${e.file}:${e.line} \xB7 ${e.source} (${e.verified?"verified":"pending"})`).join(`
32
+ `)}d(en,"renderBreakpointList");function Tt(r,e){let t=r.get(e);if(t===void 0)throw new Error(`Unknown debug session ${e}`);return t}d(Tt,"requiredSession");function tn(r){let e=F(r)&&typeof r.anchor=="string"?r.anchor:void 0;return/^(\d+)#/u.exec(e??"")?.[1]??e??"selected line"}d(tn,"breakpointLine");function F(r){return typeof r=="object"&&r!==null}d(F,"isRecord");function rn(r,e){return{type:"text",text:e,sourceLines:Object.fromEntries(e.split(/\r?\n/u).map((t,n)=>[String(n+1),{source:r,lineNumber:n+1,content:t}]))}}d(rn,"debugSourceContent");import N from"node:path";import{readFile as Ot}from"node:fs/promises";import{Type as $}from"typebox";import{Value as ln}from"typebox/value";import{Writable as nn}from"node:stream";import{callbackify as Ct}from"node:util";async function C(r,e,t){t.signal?.throwIfAborted();let n=r.resolve(e);if(!n)throw new D("UNSUPPORTED_SOURCE",e,"not-applied");let o=Object.entries(await Me(n.backend,n.location.path,t.env,t.signal)).map(([c,p])=>`${c}=${p}`),a=await n.backend.startProcess("env",[...o,t.command,...t.args],n.location.path,{signal:t.signal});a.stderr.resume();let i=new nn({write:Ct(async(c,p)=>{await a.write(c)}),final:Ct(async()=>{await a.end()})}),s,u=a.completion.then(c=>{if(c.exitCode!==0)throw new D("ADAPTER_EXITED",e,"unknown")});return u.catch(()=>{}),{readable:a.stdout,writable:i,completion:u,remote:{target:n.location.target,pid:a.pid,...a.identity===void 0?{}:{identity:a.identity}},stop(){return s??=Je(a,r,e).finally(()=>{i.destroy()}),s}}}d(C,"startSshDapTransport");import{readFile as an}from"node:fs/promises";var jt;async function $t(r,e,t){t.signal?.throwIfAborted();let n=Buffer.from(JSON.stringify({kind:t.kind,program:t.program,args:t.args})+`
33
+ `);if(n.byteLength>65536)throw new D("BYTE_LIMIT",e,"not-applied");jt??=an(new URL("./dap-tcp-worker.py",new URL("../src/backend/dap-tcp-transport.ts",import.meta.url).href),"utf8");let o=await C(r,e,{command:"python3",args:["-c",await jt],signal:t.signal});try{return await new Promise((a,i)=>{o.writable.once("error",i),o.writable.write(n,s=>s?i(s):a())}),t.signal?.throwIfAborted(),o}catch(a){throw await o.stop(),a}}d($t,"startSshTcpDapTransport");import{readFile as on}from"node:fs/promises";async function Lt(r,e,t,n){n?.throwIfAborted();let o=r.resolve(e);if(!o)throw new D("UNSUPPORTED_SOURCE",e,"not-applied");let a=await o.backend.execute("python3",["-c","import tempfile; print(tempfile.mkdtemp(prefix='pi-agent-ide-node-',dir='/tmp'))"],o.location.path,{signal:n}),i=a.stdout.toString("utf8").trim();if(a.exitCode!==0||!/^\/tmp\/pi-agent-ide-node-[A-Za-z0-9_-]+$/u.test(i))throw new D("INVALID_RESPONSE",e,"unknown");let s,u=new Set,c=new Set,p,m=d(()=>p!==void 0,"isStopping"),l=d(async()=>{if((await o.backend.execute("python3",["-c","import shutil,sys; shutil.rmtree(sys.argv[1])",i],o.location.path)).exitCode!==0)throw new D("CLEANUP_FAILED",e,"unknown")},"cleanup"),h=d(()=>(p??=(async()=>{try{await Promise.allSettled([...c]);let g=(await Promise.allSettled([...u].map(b=>b.stop()))).find(b=>b.status==="rejected");if(g)throw g.reason}finally{try{await s?.stop()}finally{await l()}}})(),p),"stop");try{let f=await on(new URL("./dap-unix-worker.py",new URL("../src/backend/dap-node-transport.ts",import.meta.url).href),"utf8");s=await C(r,e,{command:"python3",args:["-c","import os,sys; script=os.environ.get('PI_JS_DEBUG_PATH','/opt/pi-debug-adapters/js-debug/src/dapDebugServer.js'); os.execvpe('node',['node',script,sys.argv[1]],os.environ)",`${i}/dap.sock`],env:{TMPDIR:i},signal:n}),s.readable.resume();let g=s,b=g.remote.identity;if(!b)throw new D("CAPABILITY_UNAVAILABLE",e,"not-applied");let v=d(async()=>{if(m())throw new D("SESSION_CLOSED",e,"not-applied");let P=C(r,e,{command:"python3",args:["-c",f,`${i}/dap.sock`,String(g.remote.pid),b],signal:n});c.add(P);try{let _=await P;if(u.add(_),m())throw new D("SESSION_CLOSED",e,"not-applied");return _}finally{c.delete(P)}},"connect"),w=await v();return{client:k.fromTransport({readable:w.readable,writable:w.writable,completion:Promise.race([w.completion,g.completion]),stop:h}),connectChild:d(async()=>k.fromTransport(await v()),"connectChild"),adapterID:"pwa-node",request:"launch",remote:g.remote,launch:t}}catch(f){throw await h(),f}}d(Lt,"prepareSshNodeDebugger");import{readFile as sn}from"node:fs/promises";import{Type as ke}from"typebox";import{Value as dn}from"typebox/value";var un=ke.Object({port:ke.Integer({minimum:1,maximum:65535}),sourceRoot:ke.String()},{additionalProperties:!1});async function Bt(r,e,t,n){if(t.mainClass===void 0)throw new D("INVALID_REQUEST",e,"not-applied");let o=await sn(new URL("./dap-java-worker.py",new URL("../src/backend/dap-java-transport.ts",import.meta.url).href),"utf8"),a=AbortSignal.any([...n===void 0?[]:[n],AbortSignal.timeout(4e4)]),i=await C(r,e,{command:"python3",args:["-c",o,JSON.stringify({mainClass:t.mainClass,args:t.args,sourceFile:t.sourceFile})],signal:n});try{let s=await cn(i,e,a);a.throwIfAborted();let u=k.fromTransport(i);return i.readable.resume(),{client:u,adapterID:"java",request:"attach",launch:{hostName:"127.0.0.1",port:s.port,timeout:1e4,sourcePaths:[s.sourceRoot]},remote:i.remote}}catch(s){throw await i.stop(),s}}d(Bt,"prepareSshJavaDebugger");function cn(r,e,t){return new Promise((n,o)=>{let a=Buffer.alloc(0),i=d(()=>{t.removeEventListener("abort",c),r.readable.removeListener("data",p),r.readable.removeListener("end",u),r.readable.removeListener("error",s)},"cleanup"),s=d(m=>{i(),o(m)},"failed"),u=d(()=>s(new D("ADAPTER_EXITED",e,"not-applied")),"closed"),c=d(()=>s(t.reason),"aborted"),p=d(m=>{a=Buffer.concat([a,m]);let l=a.indexOf(10);if(l<0){a.length>4096&&s(new D("INVALID_RESPONSE",e,"not-applied"));return}r.readable.pause(),i();try{if(l>4096)throw new Error("Java startup header limit");let h=JSON.parse(a.subarray(0,l).toString("utf8"));if(!dn.Check(un,h))throw new Error("Invalid Java startup header");a.length>l+1&&r.readable.unshift(a.subarray(l+1)),n(h)}catch{o(new D("INVALID_RESPONSE",e,"not-applied"))}},"received");r.readable.on("data",p),r.readable.once("end",u),r.readable.once("error",s),t.addEventListener("abort",c,{once:!0}),r.completion.then(u,s),t.aborted&&c()})}d(cn,"readReady");var pn=$.Object({phpDebug:$.String(),php:$.String(),luaDebug:$.String(),lua:$.String(),bashRoot:$.String(),bashDebug:$.Union([$.String(),$.Null()]),bash:$.String()},{additionalProperties:!1});async function gn(r,e,t,n,o){let a={phpDebug:["PI_PHP_DEBUG_PATH","/opt/pi-debug-adapters/php-debug/extension/out/phpDebug.js"],php:["PI_PHP_PATH","php"],luaDebug:["PI_LUA_DEBUG_PATH","/opt/pi-debug-adapters/lua-debug/extension/extension/debugAdapter.js"],lua:["PI_LUA_PATH","lua"],bashRoot:["PI_BASH_DEBUG_ROOT","/opt/pi-debug-adapters/bash-debug/extension"],bashDebug:["PI_BASH_DEBUG_PATH",null],bash:["PI_BASH_PATH","/usr/bin/bash"]},i=await r.execute("python3",["-c","import json,os,sys; fields=json.loads(sys.argv[1]); print(json.dumps({k:os.environ.get(v[0],v[1]) for k,v in fields.items()}))",JSON.stringify(a)],n,{signal:o});if(i.exitCode!==0)throw new D("DEPENDENCY_UNAVAILABLE",e.program,"not-applied");let s;try{s=JSON.parse(i.stdout.toString("utf8"))}catch{throw new D("INVALID_RESPONSE",e.program,"not-applied")}if(!ln.Check(pn,s))throw new D("INVALID_RESPONSE",e.program,"not-applied");let u={name:"Pi Agent IDE debug session",request:"launch",program:t,cwd:n,args:[...e.args]};if(e.adapter==="php")return{command:"node",overrides:[],args:[s.phpDebug],adapterID:"php",launch:{...u,type:"php",runtimeExecutable:s.php,runtimeArgs:["-dxdebug.start_with_request=yes"],console:"internalConsole",hostname:"127.0.0.1",port:0,env:{XDEBUG_MODE:"debug,develop",XDEBUG_CONFIG:"client_port=${port}"}}};if(e.adapter==="lua")return{command:"node",overrides:[],args:[s.luaDebug],adapterID:"lua-local",launch:{...u,type:"lua-local",program:{lua:s.lua,file:t},extensionPath:N.posix.dirname(N.posix.dirname(s.luaDebug)),workspacePath:n}};if(e.adapter==="shell")return{command:"node",overrides:[],args:[s.bashDebug??N.posix.join(s.bashRoot,"out/bashDebug.js")],adapterID:"bashdb",launch:{...u,type:"bashdb",pathBash:s.bash,pathBashdb:N.posix.join(s.bashRoot,"bashdb_dir/bashdb"),pathBashdbLib:N.posix.join(s.bashRoot,"bashdb_dir"),pathCat:"/usr/bin/cat",pathMkfifo:"/usr/bin/mkfifo",pathPkill:"/usr/bin/pkill",terminalKind:"debugConsole",argsString:"",env:{},showDebugOutput:!1,trace:!1}};throw new D("CAPABILITY_UNAVAILABLE",e.program,"not-applied")}d(gn,"nodeStdioRecipe");function fn(r,e,t,n){let o={name:"Pi Agent IDE debug session",request:"launch",program:e,cwd:t,args:[...r.args]};switch(r.adapter){case"debugpy":return{command:"python3",overrides:["PI_PYTHON_PATH"],args:["-m","debugpy.adapter"],adapterID:"debugpy",launch:{...o,type:"python",console:"internalConsole",justMyCode:!1}};case"dart":return{command:"dart",overrides:["PI_DART_PATH"],args:["debug_adapter"],adapterID:"dart",launch:{...o,type:"dart",debugSdkLibraries:!1,debugExternalPackageLibraries:!1,stopOnEntry:!0,vmAdditionalArgs:["--pause-isolates-on-start"]}};case"kotlin":{if(r.mainClass===void 0)throw new Error("Java and Kotlin debug sessions require mainClass");return{command:"kotlin-debug-adapter",overrides:["PI_KOTLIN_DEBUG_ADAPTER_PATH"],args:[],adapterID:r.adapter,launch:{...o,type:"kotlin",mainClass:r.mainClass,projectRoot:t,stopOnEntry:!0}}}case"netcoredbg":return{command:"netcoredbg",overrides:["PI_NETCOREDBG_PATH"],args:["--interpreter=vscode"],adapterID:"coreclr",launch:{...o,type:"coreclr",console:"internalConsole"}};case"elixir":return{command:"/opt/pi-debug-adapters/elixir-ls/debug_adapter.sh",overrides:["PI_ELIXIR_LS_DEBUG_PATH"],args:[],adapterID:"mix_task",launch:{name:o.name,request:"launch",type:"mix_task",task:"run",taskArgs:[e,...r.args],projectDir:t,startApps:!0,exitAfterTaskReturns:!0}};case"lldb-dap":{let a=N.posix.extname(n).toLowerCase()===".swift";return{command:a?"lldb-dap":"lldb-dap-18",overrides:a?["PI_SWIFT_LLDB_DAP_PATH","PI_LLDB_DAP_PATH"]:["PI_LLDB_DAP_PATH"],args:[],adapterID:"lldb-dap",launch:{...o,type:"lldb-dap"}}}default:throw new D("CAPABILITY_UNAVAILABLE",r.program,"not-applied")}}d(fn,"stdioRecipe");function Nt(r){return e=>{let t=r.resolve(e);if(!t){if(e.includes("://"))throw new D("UNSUPPORTED_SOURCE",e,"not-applied");return}let n=d(u=>{let c=r.resolve(u,t.location.source);if(!c||c.location.target!==t.location.target)throw new D("UNSUPPORTED_SOURCE",u,"not-applied");return c},"resolve"),{id:o,host:a,workspace:i,configFile:s}=t.backend.target;return{key:JSON.stringify([o,a,i,s??null]),serverPath:d(u=>n(u).location.path,"serverPath"),resourcePath(u){if(!N.posix.isAbsolute(u)||u.includes("\0"))throw new D("INVALID_RESPONSE",t.location.source,"not-applied");return X(t.location.target,u).source},async readText(u){let c=n(u);return new TextDecoder("utf-8",{fatal:!0}).decode((await c.backend.read(c.location.path)).bytes)},async prepare(u,c){c?.throwIfAborted();let p=n(u.program).location.path,m=n(u.cwd).location.path,l=n(u.sourceFile).location.path;if(u.adapter==="java")return await Bt(r,t.location.source,{...u,cwd:m,program:p,sourceFile:l},c);if(u.adapter==="delve"||u.adapter==="ruby"||u.adapter==="julia"){let g=await $t(r,t.location.source,{kind:u.adapter,program:p,args:u.args,signal:c}),b=u.adapter==="delve"?"go":u.adapter==="ruby"?"rdbg":"julia";return{client:k.fromTransport(g),adapterID:b,request:"launch",remote:g.remote,launch:{name:"Pi Agent IDE debug session",request:"launch",type:b,program:p,cwd:m,args:[...u.args],...u.adapter==="delve"?{mode:"debug"}:{},...u.adapter==="julia"?{stopOnEntry:!1}:{}}}}if(u.adapter==="node")return Lt(r,t.location.source,{name:"Pi Agent IDE debug session",request:"launch",type:"pwa-node",program:p,cwd:m,args:[...u.args],console:"internalConsole",autoAttachChildProcesses:!1,stopOnEntry:!0,sourceMaps:!0,pauseForSourceMap:!0,outFiles:[N.posix.join(N.posix.dirname(p),"**","*.js")]},c);if(u.adapter==="r"){let g=await Ot(new URL("./dap-r-worker.py",new URL("../src/backend/debugger-workspace-owner.ts",import.meta.url).href),"utf8"),b=await C(r,t.location.source,{command:"python3",args:["-c",g],signal:c});return{client:k.fromTransport(b),adapterID:"R-Debugger",request:"launch",remote:b.remote,launch:{name:"Pi Agent IDE debug session",request:"launch",type:"R-Debugger",debugMode:"file",file:p,workingDirectory:m,commandLineArgs:[...u.args],allowGlobalDebugging:!1,loadPackages:[],supportsStdoutReading:!0,supportsWriteToStdinEvent:!0,overwriteHelp:!1}}}if(u.adapter==="powershell"){let g=await Ot(new URL("./dap-powershell-worker.py",new URL("../src/backend/debugger-workspace-owner.ts",import.meta.url).href),"utf8"),b=await C(r,t.location.source,{command:"python3",args:["-c",g],signal:c});return{client:k.fromTransport(b),adapterID:"PowerShell",request:"launch",remote:b.remote,launch:{name:"Pi Agent IDE debug session",request:"launch",program:p,script:p,cwd:m,args:[...u.args],createTemporaryIntegratedConsole:!1,executeMode:"Call"}}}let h=u.adapter==="php"||u.adapter==="lua"||u.adapter==="shell"?await gn(t.backend,u,p,m,c):fn(u,p,m,l),f=await C(r,t.location.source,{command:"python3",args:["-c","import json,os,sys; names=json.loads(sys.argv[1]); p=next((os.environ[n] for n in names if os.environ.get(n)),sys.argv[2]); args=json.loads(sys.argv[3]); os.execvpe(p,[p,*args],os.environ)",JSON.stringify(h.overrides),h.command,JSON.stringify(h.args)],signal:c});return{client:k.fromTransport(f),adapterID:h.adapterID,request:"launch",remote:f.remote,launch:h.launch}}}}}d(Nt,"createSshDebuggerWorkspaceOwner");function bn(r){return{workspace:Nt(r),async resolveOptions(e,t,n){n?.throwIfAborted();let o=r.resolve(e.program),a=e.cwd??(o?X(o.location.target,o.backend.target.workspace).source:t),i=r.resolve(a,t);if(!i){if([a,e.program,e.source].some(p=>p?.includes("://")))throw new D("UNSUPPORTED_SOURCE",e.program,"not-applied");return}let s=e.adapter;if(s===void 0)throw new Error("Select an adapter: SSH workspaces use the native debugger backend");let u=r.resolve(e.program,i.location.source),c=r.resolve(e.source??e.program,i.location.source);if(!u||!c||u.location.target!==i.location.target||c.location.target!==i.location.target)throw new D("UNSUPPORTED_SOURCE",e.program,"not-applied");return await u.backend.stat(u.location.path,{signal:n}),c.location.source!==u.location.source&&await c.backend.stat(c.location.path,{signal:n}),{adapter:s,program:u.location.source,sourceFile:c.location.source,cwd:i.location.source,args:e.args??[],...e.mainClass===void 0?{}:{mainClass:e.mainClass}}}}}d(bn,"createSshDebuggerAccess");async function mn(r){let e=new Ge(await Ve(qe(He())));await xt(r,bn(e))}d(mn,"registerOwnedDebugger");export{bn as createSshDebuggerAccess,mn as default};
@@ -1 +1 @@
1
- import{a as d,b as u,c as w}from"./chunk-WQIMM4SU.js";import"./chunk-4IWEKRSP.js";import{b as f}from"./chunk-6A3ORNW3.js";import"./chunk-DEP55R35.js";import{c}from"./chunk-W7CASEO3.js";import"./chunk-R2U5WXYR.js";import"./chunk-KN6VPARZ.js";import"./chunk-MDD5ORB6.js";import"./chunk-MLFJU2US.js";import"./chunk-GXL4NMHR.js";import"./chunk-PQWANILR.js";import"./chunk-BU7IZLKB.js";import"./chunk-S5PL5DFQ.js";import"./chunk-DDH3FP4G.js";import"./chunk-VDJSH3DQ.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import{a as i}from"./chunk-EI7MMDWY.js";import{readFile as x}from"node:fs/promises";async function g(o){let n=new w(await u(d(c())));await f(o,m(o,n))}i(g,"registerOwnedGit");function m(o,n){return{exec:i(async(t,r,e)=>{let a=n.resolve(e.cwd);if(!a){if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(e.cwd))throw new Error(`Unsupported Git resource: ${e.cwd}`);return o.exec(t,r,e)}let s=await a.backend.execute(t,r,a.location.path,e);return{code:s.exitCode,stdout:s.stdout.toString("utf8"),stderr:s.stderr.toString("utf8")}},"exec"),async writeIndex(t,r){let e=n.resolve(r.cwd);return e?(await e.backend.writeGitIndex(e.location.path,t,r),!0):!1},async readText(t,r){let e=n.resolve(t);if(e)return(await e.backend.read(e.location.path,{signal:r})).bytes.toString("utf8");if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(t))throw new Error(`Unsupported Git resource: ${t}`);return x(t,{encoding:"utf8",signal:r})}}}i(m,"createOwnedGitExecutor");export{m as createOwnedGitExecutor,g as default};
1
+ import{a as d,b as u,c as w}from"./chunk-WQIMM4SU.js";import"./chunk-4IWEKRSP.js";import{b as f}from"./chunk-6A3ORNW3.js";import"./chunk-DEP55R35.js";import{c}from"./chunk-W7CASEO3.js";import"./chunk-R2U5WXYR.js";import"./chunk-KN6VPARZ.js";import"./chunk-MDD5ORB6.js";import"./chunk-MLFJU2US.js";import"./chunk-GXL4NMHR.js";import"./chunk-PQWANILR.js";import"./chunk-BU7IZLKB.js";import"./chunk-S5PL5DFQ.js";import"./chunk-DDH3FP4G.js";import"./chunk-756K3LJY.js";import"./chunk-VDJSH3DQ.js";import"./chunk-ZC65Z3CK.js";import{a as i}from"./chunk-EI7MMDWY.js";import{readFile as x}from"node:fs/promises";async function g(o){let n=new w(await u(d(c())));await f(o,m(o,n))}i(g,"registerOwnedGit");function m(o,n){return{exec:i(async(t,r,e)=>{let a=n.resolve(e.cwd);if(!a){if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(e.cwd))throw new Error(`Unsupported Git resource: ${e.cwd}`);return o.exec(t,r,e)}let s=await a.backend.execute(t,r,a.location.path,e);return{code:s.exitCode,stdout:s.stdout.toString("utf8"),stderr:s.stderr.toString("utf8")}},"exec"),async writeIndex(t,r){let e=n.resolve(r.cwd);return e?(await e.backend.writeGitIndex(e.location.path,t,r),!0):!1},async readText(t,r){let e=n.resolve(t);if(e)return(await e.backend.read(e.location.path,{signal:r})).bytes.toString("utf8");if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(t))throw new Error(`Unsupported Git resource: ${t}`);return x(t,{encoding:"utf8",signal:r})}}}i(m,"createOwnedGitExecutor");export{m as createOwnedGitExecutor,g as default};
@@ -1 +1 @@
1
- import{a as g,c as P,d as T}from"./chunk-B25LXXNV.js";import{a as w}from"./chunk-MDD5ORB6.js";import{b as y,c as h}from"./chunk-MLFJU2US.js";import{a as v}from"./chunk-ZAWRSA7N.js";import{a as b,b as j}from"./chunk-OFILFO6D.js";import{b as C,c as k,g as R,i as E,k as F,m as d,n as x}from"./chunk-7D7PXIVV.js";import{a as f}from"./chunk-EI7MMDWY.js";var A=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".html",".md",".yaml",".yml",".vue",".svelte"],z=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".less",".html",".htm",".md",".markdown",".mdx",".yaml",".yml",".toml"],p=[e("dart-format",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],[".dart"],["dart","format","{file}"],"https://dart.dev/tools/dart-format"),e("zig-format",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","fmt","{file}"],"https://ziglang.org/documentation/master/"),e("styler",["r"],["Rscript"],[".Rprofile","DESCRIPTION"],[".r"],["Rscript","-e","styler::style_file(commandArgs(TRUE)[1])","{file}"],"https://styler.r-lib.org/"),e("clang-format",["c","cpp"],["clang-format"],[".clang-format","_clang-format"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-format","-i","{file}"],"https://clang.llvm.org/docs/ClangFormat.html"),e("prettier",["javascript","typescript","html","css","json","yaml","markdown","vue","svelte"],["prettier"],[".prettierrc",".prettierrc.json",".prettierrc.json5",".prettierrc.yaml",".prettierrc.yml",".prettierrc.toml",".prettierrc.js",".prettierrc.cjs",".prettierrc.mjs","prettier.config.js","prettier.config.cjs","prettier.config.mjs","prettier.config.ts","prettier.config.mts","prettier.config.cts"],A,["prettier","--write","{file}"],"https://prettier.io/docs/",["prettier"],{"package.json":["prettier"]}),e("biome",["javascript","typescript","json","css"],["biome"],["biome.json","biome.jsonc"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css"],["biome","format","--write","{file}"],"https://biomejs.dev/",["@biomejs/biome"]),e("oxfmt",["javascript","typescript","json","css","html","markdown","yaml","toml"],["oxfmt"],[".oxfmtrc.json",".oxfmtrc.jsonc","oxfmt.config.ts","oxfmt.config.mts"],z,["oxfmt","--write","{file}"],"https://oxc.rs/docs/guide/usage/formatter.html",["oxfmt"]),e("ruff-format",["python"],["ruff"],["ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","format","{file}"],"https://docs.astral.sh/ruff/formatter/",["ruff"],{"pyproject.toml":["tool.ruff"]}),e("black",["python"],["black"],[],[".py",".pyi"],["black","--quiet","{file}"],"https://black.readthedocs.io/",["black"],{"pyproject.toml":["tool.black"]}),e("gofmt",["go"],["gofmt"],["go.mod"],[".go"],["gofmt","-w","{file}"],"https://pkg.go.dev/cmd/gofmt"),e("goimports",["go"],["goimports"],["go.mod"],[".go"],["goimports","-w","{file}"],"https://pkg.go.dev/golang.org/x/tools/cmd/goimports"),e("rustfmt",["rust"],["rustfmt"],["rustfmt.toml",".rustfmt.toml","Cargo.toml"],[".rs"],["rustfmt","{file}"],"https://github.com/rust-lang/rustfmt"),e("csharpier",["csharp"],["csharpier"],[".csharpierrc",".csharpierrc.json",".csharpierrc.yaml",".csharpierrc.yml"],[".cs"],["csharpier","format","{file}"],"https://csharpier.com/"),e("google-java-format",["java"],["google-java-format"],["pom.xml","build.gradle"],[".java"],["google-java-format","--replace","{file}"],"https://github.com/google/google-java-format"),e("ktlint-format",["kotlin"],["ktlint"],[".editorconfig","build.gradle.kts"],[".kt",".kts"],["ktlint","-F","{file}"],"https://pinterest.github.io/ktlint/"),e("rubocop-format",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--fix-layout","{file}"],"https://docs.rubocop.org/"),e("pint",["php"],["pint"],["pint.json","composer.json"],[".php"],["pint","{file}"],"https://laravel.com/docs/pint"),e("swift-format",["swift"],["swift-format"],[".swift-format","Package.swift"],[".swift"],["swift-format","format","--in-place","{file}"],"https://github.com/swiftlang/swift-format"),e("stylua",["lua"],["stylua"],["stylua.toml",".stylua.toml"],[".lua"],["stylua","{file}"],"https://github.com/JohnnyMorganz/StyLua"),e("shfmt",["shell"],["shfmt"],[".editorconfig"],[".sh",".bash",".zsh"],["shfmt","-w","{file}"],"https://github.com/mvdan/sh"),e("taplo",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","format","{file}"],"https://taplo.tamasfe.dev/"),e("sqlfluff-format",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","format","{file}"],"https://docs.sqlfluff.com/"),e("terraform-fmt",["terraform"],["terraform"],[".terraform.lock.hcl"],[".tf",".tfvars"],["terraform","fmt","{file}"],"https://developer.hashicorp.com/terraform/cli/commands/fmt"),e("cmake-format",["cmake"],["cmake-format"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-format","-i","{file}"],"https://cmake-format.readthedocs.io/",void 0,void 0,["CMakeLists.txt"]),e("xmlformat",["xml"],["xmlformat"],[".xmlformat.conf"],[".xml",".xsd",".xsl"],["xmlformat","--overwrite","{file}"],"https://github.com/pamoller/xmlformatter"),e("mix-format",["elixir"],["mix"],["mix.exs",".formatter.exs"],[".ex",".exs"],["mix","format","{file}"],"https://hexdocs.pm/mix/Mix.Tasks.Format.html"),e("scalafmt",["scala"],["scalafmt"],[".scalafmt.conf"],[".scala",".sc",".sbt"],["scalafmt","{file}"],"https://scalameta.org/scalafmt/"),e("julia-format",["julia"],["julia"],[".JuliaFormatter.toml","Project.toml"],[".jl"],["julia","--startup-file=no","--history-file=no","-e","using JuliaFormatter; format_file(ARGS[1])","{file}"],"https://github.com/domluna/JuliaFormatter.jl"),e("powershell-format",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$p=$args[0];$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};[IO.File]::WriteAllText($p,(Invoke-Formatter -ScriptDefinition ([IO.File]::ReadAllText($p)) @options))',"{file}"],"https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-formatter"),e("dockfmt",["dockerfile"],["dockfmt"],["Dockerfile","Containerfile"],[".dockerfile"],["dockfmt","fmt","--write","{file}"],"https://github.com/jessfraz/dockfmt",void 0,void 0,["Dockerfile","Containerfile"])];function e(r,t,o,i,a,l,n,s,m,u){return{id:r,name:r,kind:"formatter",languages:t,executables:o,configFiles:i,documentation:n,...s&&{dependencies:s},...m&&{configSections:m},formatter:{extensions:a,...u&&{fileNames:u},run:{command:l},output:"in-place"}}}f(e,"recipe");var c=class r{constructor(t,o,i=new Map){this.formatters=t;this.availableBuiltIns=o;this.evidence=i}static{f(this,"FormatterCommandRegistry")}static async fromDirectory(t,o={}){let i=await R(t,"formatters",s=>x(s).formatters,o),{available:a,evidence:l}=await F(t,i.entries.filter(s=>s.layer==="built-in").map(s=>({id:s.id,config:s.config.run})),p,o),n=[...i.entries].sort((s,m)=>s.layer==="built-in"&&m.layer==="built-in"?(l.get(m.id)?.score??0)-(l.get(s.id)?.score??0):0);return new r(n,a,l)}static fromConfig(t){return new r(Object.entries(t.formatters).map(([o,i])=>({id:o,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(t,o){return this.resolveEntry(t,o)?.config}resolveEntry(t,o){return E(this.formatters,this.availableBuiltIns,this.evidence,t,o)}get entries(){return this.formatters}};var I={protocol:y,apiVersion:h,id:"formatter",setup(r){for(let t of p)r.addToolRecipe(t);r.addSetupCheck({id:"effective-config",inspect:$}),r.addCheck({id:"config",title:"Formatter",async run(t){try{let o=await c.fromDirectory(t.cwd,g(t)),i=M(o,t.files,t.cwd);return i.length===0?[{status:"skip",message:"No formatter matches the inspected project files"}]:await Promise.all(i.map(async({entry:a,source:l})=>{let n=`${a.id} [${a.layer}] command ${JSON.stringify(a.config.run.command)}`;return T(t,l,async s=>{try{let m=t.workspace?await t.workspace.run(a.config.run,s,t.signal):await d(a.config,{projectRoot:t.cwd,filePath:s,env:t.env});return t.signal?.throwIfAborted(),m.ok?{status:"pass",message:`${n}: probe passed`,detail:a.sourcePath}:{status:"fail",message:`${n}: probe failed`,detail:a.sourcePath}}catch(m){return t.signal?.throwIfAborted(),{status:"fail",message:`${n}: ${m instanceof Error?m.message:String(m)}`,detail:a.sourcePath}}})}))}catch(o){return t.signal?.throwIfAborted(),[{status:"fail",message:o instanceof Error?o.message:String(o)}]}}})}};async function $(r){try{let t=await c.fromDirectory(r.cwd,g(r)),o=[],i=new Map;for(let[a,l]of r.detectedLanguages){let n=l.map(s=>t.resolveEntry(s,r.cwd)).find(s=>s!==void 0);n!==void 0&&(o.push({kind:"formatter",languageId:a,toolId:n.id}),await P(r,n.config.run)||i.set(n.id,{id:`formatter-${n.id}-unavailable`,message:`Configured formatter ${n.id} cannot run ${JSON.stringify(n.config.run.command)}`}))}return{selections:o,actions:[...i.values()]}}catch(t){return r.signal?.throwIfAborted(),{actions:[{id:"formatter-config-invalid",message:`Formatter configuration cannot load: ${t instanceof Error?t.message:String(t)}`}]}}}f($,"inspectFormatterSetup");function M(r,t,o){let i=new Map;for(let a of t){let l=r.resolveEntry(a,o);l!==void 0&&!i.has(l.id)&&i.set(l.id,{entry:l,source:a})}return[...i.values()]}f(M,"applicableFormatters");import _ from"node:path";var S=new Map;function D(r){return{kind:"formatter",name:"formatter",priority:100,extensions:["*"],detect:f(async t=>(r?await r.loadRegistry(t.cwd,!1):await O(t.cwd),!0),"detect"),async format({filePath:t},o){if(!r&&(t.includes("://")||o.cwd.includes("://")))throw Object.assign(new Error("Formatter requires its resource owner"),{code:"UNSUPPORTED_SOURCE"});let i=r?await r.resolveProject(t,o.cwd):await k(o.cwd,t,"formatters",p).then(m=>m===void 0?void 0:{cwd:m,external:m!==_.resolve(o.cwd)});if(i===void 0)return{ok:!0,edits:0,formatter:null};let a=i.cwd,n=(r?await r.loadRegistry(a,i.external):await O(a,i.external)).resolve(t,a);if(n===void 0)return{ok:!0,edits:0,formatter:null};let s=C(n.run.command);if(r){let m=await r.run(n,a,t);return{ok:m.ok,edits:m.changed?1:0,formatter:s}}try{let m=await d(n,{projectRoot:a,filePath:t});return{ok:m.ok,edits:m.changed?1:0,formatter:s}}catch{return{ok:!1,edits:0,formatter:s}}}}}f(D,"createFormatter");async function O(r,t=!1){let o=JSON.stringify([r,t]),i=S.get(o);return i===void 0&&(i=c.fromDirectory(r,{includeGlobal:!t,requireBuiltInEvidence:!0}),S.set(o,i)),i}f(O,"loadRegistry");async function q(r){await N(r)}f(q,"registerFormatter");async function N(r,t){let o=D(t),i={kind:"formatter",name:"pi-agent-ide-formatter",priority:200,extensions:["*"],detect:f(()=>Promise.resolve(!0),"detect"),async format(l,n){return o.format(l,n)}},a={protocol:b,apiVersion:5,id:"formatter",setup(l){l.addTool(i)}};await Promise.all([v(r,a),w(r,I)])}f(N,"registerFormatterWithOwner");export{p as a,c as b,q as c,N as d};
1
+ import{a as g,c as P,d as T}from"./chunk-B25LXXNV.js";import{b as C,c as k,g as R,i as E,k as F,m as d,n as x}from"./chunk-7D7PXIVV.js";import{a as w}from"./chunk-MDD5ORB6.js";import{b as y,c as h}from"./chunk-MLFJU2US.js";import{a as v}from"./chunk-ZAWRSA7N.js";import{a as b,b as j}from"./chunk-OFILFO6D.js";import{a as f}from"./chunk-EI7MMDWY.js";var A=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".html",".md",".yaml",".yml",".vue",".svelte"],z=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".less",".html",".htm",".md",".markdown",".mdx",".yaml",".yml",".toml"],p=[e("dart-format",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],[".dart"],["dart","format","{file}"],"https://dart.dev/tools/dart-format"),e("zig-format",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","fmt","{file}"],"https://ziglang.org/documentation/master/"),e("styler",["r"],["Rscript"],[".Rprofile","DESCRIPTION"],[".r"],["Rscript","-e","styler::style_file(commandArgs(TRUE)[1])","{file}"],"https://styler.r-lib.org/"),e("clang-format",["c","cpp"],["clang-format"],[".clang-format","_clang-format"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-format","-i","{file}"],"https://clang.llvm.org/docs/ClangFormat.html"),e("prettier",["javascript","typescript","html","css","json","yaml","markdown","vue","svelte"],["prettier"],[".prettierrc",".prettierrc.json",".prettierrc.json5",".prettierrc.yaml",".prettierrc.yml",".prettierrc.toml",".prettierrc.js",".prettierrc.cjs",".prettierrc.mjs","prettier.config.js","prettier.config.cjs","prettier.config.mjs","prettier.config.ts","prettier.config.mts","prettier.config.cts"],A,["prettier","--write","{file}"],"https://prettier.io/docs/",["prettier"],{"package.json":["prettier"]}),e("biome",["javascript","typescript","json","css"],["biome"],["biome.json","biome.jsonc"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css"],["biome","format","--write","{file}"],"https://biomejs.dev/",["@biomejs/biome"]),e("oxfmt",["javascript","typescript","json","css","html","markdown","yaml","toml"],["oxfmt"],[".oxfmtrc.json",".oxfmtrc.jsonc","oxfmt.config.ts","oxfmt.config.mts"],z,["oxfmt","--write","{file}"],"https://oxc.rs/docs/guide/usage/formatter.html",["oxfmt"]),e("ruff-format",["python"],["ruff"],["ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","format","{file}"],"https://docs.astral.sh/ruff/formatter/",["ruff"],{"pyproject.toml":["tool.ruff"]}),e("black",["python"],["black"],[],[".py",".pyi"],["black","--quiet","{file}"],"https://black.readthedocs.io/",["black"],{"pyproject.toml":["tool.black"]}),e("gofmt",["go"],["gofmt"],["go.mod"],[".go"],["gofmt","-w","{file}"],"https://pkg.go.dev/cmd/gofmt"),e("goimports",["go"],["goimports"],["go.mod"],[".go"],["goimports","-w","{file}"],"https://pkg.go.dev/golang.org/x/tools/cmd/goimports"),e("rustfmt",["rust"],["rustfmt"],["rustfmt.toml",".rustfmt.toml","Cargo.toml"],[".rs"],["rustfmt","{file}"],"https://github.com/rust-lang/rustfmt"),e("csharpier",["csharp"],["csharpier"],[".csharpierrc",".csharpierrc.json",".csharpierrc.yaml",".csharpierrc.yml"],[".cs"],["csharpier","format","{file}"],"https://csharpier.com/"),e("google-java-format",["java"],["google-java-format"],["pom.xml","build.gradle"],[".java"],["google-java-format","--replace","{file}"],"https://github.com/google/google-java-format"),e("ktlint-format",["kotlin"],["ktlint"],[".editorconfig","build.gradle.kts"],[".kt",".kts"],["ktlint","-F","{file}"],"https://pinterest.github.io/ktlint/"),e("rubocop-format",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--fix-layout","{file}"],"https://docs.rubocop.org/"),e("pint",["php"],["pint"],["pint.json","composer.json"],[".php"],["pint","{file}"],"https://laravel.com/docs/pint"),e("swift-format",["swift"],["swift-format"],[".swift-format","Package.swift"],[".swift"],["swift-format","format","--in-place","{file}"],"https://github.com/swiftlang/swift-format"),e("stylua",["lua"],["stylua"],["stylua.toml",".stylua.toml"],[".lua"],["stylua","{file}"],"https://github.com/JohnnyMorganz/StyLua"),e("shfmt",["shell"],["shfmt"],[".editorconfig"],[".sh",".bash",".zsh"],["shfmt","-w","{file}"],"https://github.com/mvdan/sh"),e("taplo",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","format","{file}"],"https://taplo.tamasfe.dev/"),e("sqlfluff-format",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","format","{file}"],"https://docs.sqlfluff.com/"),e("terraform-fmt",["terraform"],["terraform"],[".terraform.lock.hcl"],[".tf",".tfvars"],["terraform","fmt","{file}"],"https://developer.hashicorp.com/terraform/cli/commands/fmt"),e("cmake-format",["cmake"],["cmake-format"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-format","-i","{file}"],"https://cmake-format.readthedocs.io/",void 0,void 0,["CMakeLists.txt"]),e("xmlformat",["xml"],["xmlformat"],[".xmlformat.conf"],[".xml",".xsd",".xsl"],["xmlformat","--overwrite","{file}"],"https://github.com/pamoller/xmlformatter"),e("mix-format",["elixir"],["mix"],["mix.exs",".formatter.exs"],[".ex",".exs"],["mix","format","{file}"],"https://hexdocs.pm/mix/Mix.Tasks.Format.html"),e("scalafmt",["scala"],["scalafmt"],[".scalafmt.conf"],[".scala",".sc",".sbt"],["scalafmt","{file}"],"https://scalameta.org/scalafmt/"),e("julia-format",["julia"],["julia"],[".JuliaFormatter.toml","Project.toml"],[".jl"],["julia","--startup-file=no","--history-file=no","-e","using JuliaFormatter; format_file(ARGS[1])","{file}"],"https://github.com/domluna/JuliaFormatter.jl"),e("powershell-format",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$p=$args[0];$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};[IO.File]::WriteAllText($p,(Invoke-Formatter -ScriptDefinition ([IO.File]::ReadAllText($p)) @options))',"{file}"],"https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-formatter"),e("dockfmt",["dockerfile"],["dockfmt"],["Dockerfile","Containerfile"],[".dockerfile"],["dockfmt","fmt","--write","{file}"],"https://github.com/jessfraz/dockfmt",void 0,void 0,["Dockerfile","Containerfile"])];function e(r,t,o,i,a,l,n,s,m,u){return{id:r,name:r,kind:"formatter",languages:t,executables:o,configFiles:i,documentation:n,...s&&{dependencies:s},...m&&{configSections:m},formatter:{extensions:a,...u&&{fileNames:u},run:{command:l},output:"in-place"}}}f(e,"recipe");var c=class r{constructor(t,o,i=new Map){this.formatters=t;this.availableBuiltIns=o;this.evidence=i}static{f(this,"FormatterCommandRegistry")}static async fromDirectory(t,o={}){let i=await R(t,"formatters",s=>x(s).formatters,o),{available:a,evidence:l}=await F(t,i.entries.filter(s=>s.layer==="built-in").map(s=>({id:s.id,config:s.config.run})),p,o),n=[...i.entries].sort((s,m)=>s.layer==="built-in"&&m.layer==="built-in"?(l.get(m.id)?.score??0)-(l.get(s.id)?.score??0):0);return new r(n,a,l)}static fromConfig(t){return new r(Object.entries(t.formatters).map(([o,i])=>({id:o,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(t,o){return this.resolveEntry(t,o)?.config}resolveEntry(t,o){return E(this.formatters,this.availableBuiltIns,this.evidence,t,o)}get entries(){return this.formatters}};var I={protocol:y,apiVersion:h,id:"formatter",setup(r){for(let t of p)r.addToolRecipe(t);r.addSetupCheck({id:"effective-config",inspect:$}),r.addCheck({id:"config",title:"Formatter",async run(t){try{let o=await c.fromDirectory(t.cwd,g(t)),i=M(o,t.files,t.cwd);return i.length===0?[{status:"skip",message:"No formatter matches the inspected project files"}]:await Promise.all(i.map(async({entry:a,source:l})=>{let n=`${a.id} [${a.layer}] command ${JSON.stringify(a.config.run.command)}`;return T(t,l,async s=>{try{let m=t.workspace?await t.workspace.run(a.config.run,s,t.signal):await d(a.config,{projectRoot:t.cwd,filePath:s,env:t.env});return t.signal?.throwIfAborted(),m.ok?{status:"pass",message:`${n}: probe passed`,detail:a.sourcePath}:{status:"fail",message:`${n}: probe failed`,detail:a.sourcePath}}catch(m){return t.signal?.throwIfAborted(),{status:"fail",message:`${n}: ${m instanceof Error?m.message:String(m)}`,detail:a.sourcePath}}})}))}catch(o){return t.signal?.throwIfAborted(),[{status:"fail",message:o instanceof Error?o.message:String(o)}]}}})}};async function $(r){try{let t=await c.fromDirectory(r.cwd,g(r)),o=[],i=new Map;for(let[a,l]of r.detectedLanguages){let n=l.map(s=>t.resolveEntry(s,r.cwd)).find(s=>s!==void 0);n!==void 0&&(o.push({kind:"formatter",languageId:a,toolId:n.id}),await P(r,n.config.run)||i.set(n.id,{id:`formatter-${n.id}-unavailable`,message:`Configured formatter ${n.id} cannot run ${JSON.stringify(n.config.run.command)}`}))}return{selections:o,actions:[...i.values()]}}catch(t){return r.signal?.throwIfAborted(),{actions:[{id:"formatter-config-invalid",message:`Formatter configuration cannot load: ${t instanceof Error?t.message:String(t)}`}]}}}f($,"inspectFormatterSetup");function M(r,t,o){let i=new Map;for(let a of t){let l=r.resolveEntry(a,o);l!==void 0&&!i.has(l.id)&&i.set(l.id,{entry:l,source:a})}return[...i.values()]}f(M,"applicableFormatters");import _ from"node:path";var S=new Map;function D(r){return{kind:"formatter",name:"formatter",priority:100,extensions:["*"],detect:f(async t=>(r?await r.loadRegistry(t.cwd,!1):await O(t.cwd),!0),"detect"),async format({filePath:t},o){if(!r&&(t.includes("://")||o.cwd.includes("://")))throw Object.assign(new Error("Formatter requires its resource owner"),{code:"UNSUPPORTED_SOURCE"});let i=r?await r.resolveProject(t,o.cwd):await k(o.cwd,t,"formatters",p).then(m=>m===void 0?void 0:{cwd:m,external:m!==_.resolve(o.cwd)});if(i===void 0)return{ok:!0,edits:0,formatter:null};let a=i.cwd,n=(r?await r.loadRegistry(a,i.external):await O(a,i.external)).resolve(t,a);if(n===void 0)return{ok:!0,edits:0,formatter:null};let s=C(n.run.command);if(r){let m=await r.run(n,a,t);return{ok:m.ok,edits:m.changed?1:0,formatter:s}}try{let m=await d(n,{projectRoot:a,filePath:t});return{ok:m.ok,edits:m.changed?1:0,formatter:s}}catch{return{ok:!1,edits:0,formatter:s}}}}}f(D,"createFormatter");async function O(r,t=!1){let o=JSON.stringify([r,t]),i=S.get(o);return i===void 0&&(i=c.fromDirectory(r,{includeGlobal:!t,requireBuiltInEvidence:!0}),S.set(o,i)),i}f(O,"loadRegistry");async function q(r){await N(r)}f(q,"registerFormatter");async function N(r,t){let o=D(t),i={kind:"formatter",name:"pi-agent-ide-formatter",priority:200,extensions:["*"],detect:f(()=>Promise.resolve(!0),"detect"),async format(l,n){return o.format(l,n)}},a={protocol:b,apiVersion:5,id:"formatter",setup(l){l.addTool(i)}};await Promise.all([v(r,a),w(r,I)])}f(N,"registerFormatterWithOwner");export{p as a,c as b,q as c,N as d};