pi-agent-ide 0.4.0 → 0.5.0

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 (399) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +7 -7
  3. package/dist/chunk-25CZ5ZIU.js +3 -0
  4. package/dist/chunk-526E364R.js +3 -0
  5. package/dist/chunk-5PLV4HLG.js +1 -0
  6. package/dist/chunk-5QQABP47.js +14 -0
  7. package/dist/{chunk-72EEL2DW.js → chunk-6CZO43OH.js} +1 -1
  8. package/dist/chunk-AWXVJ5AC.js +1 -0
  9. package/dist/chunk-BGUSBUUD.js +26 -0
  10. package/dist/{chunk-GFW5QPQV.js → chunk-DQXPQOF7.js} +1 -1
  11. package/dist/chunk-ESPNEJHK.js +1 -0
  12. package/dist/chunk-G725MARR.js +16 -0
  13. package/dist/{chunk-M5L42DWE.js → chunk-HKXDP2FD.js} +2 -2
  14. package/dist/chunk-IQD6PON5.js +0 -0
  15. package/dist/chunk-J4RTW44E.js +1 -0
  16. package/dist/{chunk-HGPUI7F3.js → chunk-KII2JQC5.js} +1 -1
  17. package/dist/{chunk-TI5GMJ7Q.js → chunk-L7JMDDSD.js} +1 -1
  18. package/dist/{chunk-6DZA4CLO.js → chunk-LY6U5EAD.js} +1 -1
  19. package/dist/{chunk-ERVMDQGX.js → chunk-MGCHOGQD.js} +1 -1
  20. package/dist/{chunk-Y7ZMR4LT.js → chunk-O6LE42GK.js} +1 -1
  21. package/dist/{chunk-KAB3AYA2.js → chunk-OBNING2A.js} +1 -1
  22. package/dist/chunk-QH4ZUDOD.js +1 -0
  23. package/dist/{chunk-VFBLX4TG.js → chunk-T6LX2RX5.js} +1 -1
  24. package/dist/{chunk-AADJ2KIB.js → chunk-U22JNO6N.js} +1 -1
  25. package/dist/chunk-U2JKHKLK.js +0 -0
  26. package/dist/{chunk-DQF5QMJ2.js → chunk-WGGIQ7IJ.js} +1 -1
  27. package/dist/chunk-ZG2MWXCR.js +2 -0
  28. package/dist/chunk-ZUMN6U77.js +27 -0
  29. package/dist/entry-10.js +1 -1
  30. package/dist/entry-11.js +1 -1
  31. package/dist/entry-12.js +1 -1
  32. package/dist/entry-13.js +1 -1
  33. package/dist/entry-14.js +1 -1
  34. package/dist/entry-15.js +1 -0
  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-20.js +1 -1
  39. package/dist/entry-21.js +1 -2
  40. package/dist/entry-22.js +2 -1
  41. package/dist/entry-23.js +1 -1
  42. package/dist/entry-24.js +1 -1
  43. package/dist/entry-25.js +1 -1
  44. package/dist/entry-26.js +1 -12
  45. package/dist/entry-27.js +12 -1
  46. package/dist/entry-28.js +1 -1
  47. package/dist/entry-29.js +1 -1
  48. package/dist/entry-30.js +1 -1
  49. package/dist/entry-31.js +1 -4
  50. package/dist/entry-32.js +3 -8
  51. package/dist/entry-33.js +9 -1
  52. package/dist/entry-34.js +1 -1
  53. package/dist/entry-35.js +1 -1
  54. package/dist/entry-36.js +1 -1
  55. package/dist/entry-37.js +1 -1
  56. package/dist/entry-38.js +1 -1
  57. package/dist/entry-39.js +1 -1
  58. package/dist/entry-40.js +1 -18
  59. package/dist/entry-41.js +18 -1
  60. package/dist/entry-42.js +1 -1
  61. package/dist/entry-43.js +1 -1
  62. package/dist/entry-44.js +1 -1
  63. package/dist/entry-45.js +1 -7
  64. package/dist/entry-46.js +7 -11
  65. package/dist/entry-47.js +11 -1
  66. package/dist/entry-48.js +1 -1
  67. package/dist/entry-49.js +1 -1
  68. package/dist/entry-50.js +1 -1
  69. package/dist/entry-51.js +1 -1
  70. package/dist/entry-52.js +1 -1
  71. package/dist/entry-53.js +1 -1
  72. package/dist/entry-54.js +1 -1
  73. package/dist/entry-55.js +1 -0
  74. package/dist/entry-56.js +0 -1
  75. package/dist/entry-57.js +1 -0
  76. package/dist/entry-58.js +0 -1
  77. package/dist/entry-59.js +1 -1
  78. package/dist/entry-60.js +1 -1
  79. package/dist/entry-61.js +1 -1
  80. package/dist/entry-62.js +1 -1
  81. package/dist/entry-63.js +1 -1
  82. package/dist/entry-64.js +1 -0
  83. package/dist/entry-65.js +0 -1
  84. package/dist/entry-66.js +1 -0
  85. package/dist/entry-67.js +0 -1
  86. package/dist/entry-68.js +1 -1
  87. package/dist/entry-69.js +1 -1
  88. package/dist/entry-70.js +1 -123
  89. package/dist/entry-71.js +198 -25
  90. package/dist/entry-72.js +30 -2
  91. package/dist/entry-73.js +2 -1
  92. package/dist/entry-74.js +1 -1
  93. package/dist/entry-75.js +1 -1
  94. package/dist/entry-76.js +1 -3
  95. package/dist/entry-77.js +3 -1
  96. package/dist/entry-78.js +1 -1
  97. package/dist/entry-79.js +1 -1
  98. package/dist/entry-8.js +1 -1
  99. package/dist/entry-80.js +1 -0
  100. package/dist/entry-9.js +1 -1
  101. package/dist/pi-agent-ide.js +3 -3
  102. package/docs/configuration.md +1 -1
  103. package/docs/user-hooks.md +68 -0
  104. package/node_modules/pi-agent-doctor/package.json +6 -6
  105. package/node_modules/pi-agent-doctor/runtime/entry-21.js +1 -0
  106. package/node_modules/pi-agent-doctor/src/catalog.ts +9 -1
  107. package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +5 -0
  108. package/node_modules/pi-agent-filesystem/package.json +7 -7
  109. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  110. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  111. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  112. package/node_modules/pi-agent-filesystem-text/runtime/entry-25.js +2 -0
  113. package/node_modules/pi-agent-ide-ast/package.json +32 -11
  114. package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +0 -1
  115. package/node_modules/pi-agent-ide-ast/runtime/entry-27.js +2 -0
  116. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +16 -8
  117. package/node_modules/pi-agent-ide-ast/src/ast/native-parser.ts +151 -0
  118. package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +22 -17
  119. package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +25 -0
  120. package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +52 -1
  121. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +4 -1
  122. package/node_modules/pi-agent-ide-changes/index.ts +3 -1
  123. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  124. package/node_modules/pi-agent-ide-changes/runtime/entry-28.js +0 -1
  125. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +42 -9
  126. package/node_modules/pi-agent-ide-formatter/package.json +9 -4
  127. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  128. package/node_modules/pi-agent-ide-lint/package.json +13 -8
  129. package/node_modules/pi-agent-ide-lsp/index.ts +4 -1
  130. package/node_modules/pi-agent-ide-lsp/package.json +15 -10
  131. package/node_modules/pi-agent-ide-lsp/runtime/entry-33.js +2 -0
  132. package/node_modules/pi-agent-image/package.json +3 -3
  133. package/node_modules/pi-agent-invariant/package.json +2 -2
  134. package/node_modules/pi-agent-pdf/package.json +3 -3
  135. package/node_modules/pi-agent-read/package.json +11 -11
  136. package/node_modules/pi-agent-read/runtime/entry-40.js +0 -1
  137. package/node_modules/pi-agent-read/runtime/entry-41.js +2 -0
  138. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  139. package/node_modules/pi-agent-read/src/api/rendering.ts +1 -1
  140. package/node_modules/pi-agent-read/src/api/tools/read.ts +32 -0
  141. package/node_modules/pi-agent-read/src/core/read-core.ts +8 -0
  142. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +38 -4
  143. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +63 -4
  144. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +105 -5
  145. package/node_modules/pi-agent-resource/package.json +2 -2
  146. package/node_modules/pi-agent-search/package.json +7 -7
  147. package/node_modules/pi-agent-search/runtime/entry-45.js +0 -1
  148. package/node_modules/pi-agent-search/src/api/search-parameters.ts +5 -1
  149. package/node_modules/pi-agent-search-text/index.ts +1 -1
  150. package/node_modules/pi-agent-search-text/package.json +9 -9
  151. package/node_modules/pi-agent-search-text/runtime/entry-47.js +1 -0
  152. package/node_modules/pi-agent-search-text/src/resolvers.ts +47 -19
  153. package/node_modules/pi-agent-search-text/src/search-backend.ts +6 -15
  154. package/node_modules/pi-agent-search-text/src/search-presentation.ts +80 -0
  155. package/node_modules/pi-agent-search-text/src/search-renderer.ts +17 -1
  156. package/node_modules/pi-agent-search-text/src/search-result.ts +32 -12
  157. package/node_modules/pi-agent-search-text/src/search-session.ts +6 -3
  158. package/node_modules/pi-agent-text/package.json +3 -3
  159. package/node_modules/pi-agent-text/runtime/entry-49.js +1 -0
  160. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  161. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-50.js +2 -0
  162. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  163. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
  164. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-52.js +2 -0
  165. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  166. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
  167. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-54.js +2 -0
  168. package/node_modules/pi-agent-text-editor/package.json +25 -25
  169. package/node_modules/pi-agent-text-editor/runtime/entry-70.js +0 -1
  170. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +7 -1
  171. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +3 -0
  172. package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
  173. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +47 -0
  174. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +6 -1
  175. package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +155 -0
  176. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +56 -77
  177. package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +7 -12
  178. package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +2 -0
  179. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +37 -8
  180. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +42 -37
  181. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +51 -15
  182. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +119 -20
  183. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +28 -7
  184. package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +387 -0
  185. package/node_modules/pi-agent-text-editor/src/core/extension.ts +3 -2
  186. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +68 -71
  187. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +4 -4
  188. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +11 -0
  189. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
  190. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +141 -6
  191. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +123 -4
  192. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +9 -4
  193. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +3 -2
  194. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -4
  195. package/node_modules/pi-agent-text-editor-renderer/index.ts +5 -0
  196. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  197. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +59 -0
  198. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  199. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
  200. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  201. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  202. package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +1 -0
  203. package/node_modules/pi-agent-web/package.json +7 -7
  204. package/node_modules/pi-agent-web-html/package.json +3 -3
  205. package/node_modules/pi-agent-web-image/package.json +4 -4
  206. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  207. package/node_modules/pi-agent-web-text/package.json +4 -4
  208. package/node_modules/pi-agent-web-text/runtime/entry-80.js +2 -0
  209. package/package.json +58 -38
  210. package/src/api/hooks.ts +168 -0
  211. package/src/api/text-editor.ts +2 -0
  212. package/src/composite/builtin-extensions.ts +7 -0
  213. package/src/composite/module-labels.ts +8 -0
  214. package/src/composite/preferences.ts +3 -3
  215. package/src/core/reload-resource-store.ts +34 -0
  216. package/src/doctor/tip-provider.ts +1 -0
  217. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  218. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  219. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  220. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  221. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-25.js +2 -0
  222. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-22.js +2 -0
  223. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  224. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  225. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  226. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  227. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  228. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +2 -0
  229. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +2 -0
  230. package/src/extensions/pi-agent-read/package.json +11 -11
  231. package/src/extensions/pi-agent-read/runtime/entry-40.js +0 -1
  232. package/src/extensions/pi-agent-read/runtime/entry-41.js +2 -0
  233. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  234. package/src/extensions/pi-agent-read/src/api/rendering.ts +1 -1
  235. package/src/extensions/pi-agent-read/src/api/tools/read.ts +32 -0
  236. package/src/extensions/pi-agent-read/src/core/read-core.ts +8 -0
  237. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +38 -4
  238. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +63 -4
  239. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +105 -5
  240. package/src/extensions/pi-agent-search/package.json +7 -7
  241. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +1 -1
  242. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
  243. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-47.js +1 -0
  244. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +1 -0
  245. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +47 -19
  246. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +6 -15
  247. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +80 -0
  248. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +17 -1
  249. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +32 -12
  250. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +6 -3
  251. package/src/extensions/pi-agent-search/runtime/entry-45.js +0 -1
  252. package/src/extensions/pi-agent-search/runtime/entry-46.js +2 -0
  253. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +5 -1
  254. package/src/extensions/pi-agent-text-editor/package.json +25 -25
  255. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  256. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-50.js +2 -0
  257. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  258. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
  259. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-52.js +2 -0
  260. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  261. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
  262. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-54.js +2 -0
  263. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +5 -0
  264. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  265. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +59 -0
  266. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  267. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
  268. package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +0 -1
  269. package/src/extensions/pi-agent-text-editor/runtime/entry-71.js +2 -0
  270. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +7 -1
  271. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +3 -0
  272. package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
  273. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +47 -0
  274. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +6 -1
  275. package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +155 -0
  276. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +56 -77
  277. package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +7 -12
  278. package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +2 -0
  279. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +37 -8
  280. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +42 -37
  281. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +51 -15
  282. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +119 -20
  283. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +28 -7
  284. package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +387 -0
  285. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +3 -2
  286. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +68 -71
  287. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +4 -4
  288. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +11 -0
  289. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
  290. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +141 -6
  291. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +123 -4
  292. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +9 -4
  293. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +3 -2
  294. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -4
  295. package/src/plugins/pi-agent-ide-ast/package.json +32 -11
  296. package/src/plugins/pi-agent-ide-ast/runtime/entry-26.js +0 -1
  297. package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +2 -0
  298. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +16 -8
  299. package/src/plugins/pi-agent-ide-ast/src/ast/native-parser.ts +151 -0
  300. package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +22 -17
  301. package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +25 -0
  302. package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +52 -1
  303. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +4 -1
  304. package/src/plugins/pi-agent-ide-changes/index.ts +3 -1
  305. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  306. package/src/plugins/pi-agent-ide-changes/runtime/entry-28.js +0 -1
  307. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +42 -9
  308. package/src/plugins/pi-agent-ide-debugger/index.ts +573 -0
  309. package/src/plugins/pi-agent-ide-debugger/src/breakpoint-view.ts +73 -0
  310. package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +306 -0
  311. package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +338 -0
  312. package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +349 -0
  313. package/src/plugins/pi-agent-ide-debugger/src/process-provider.ts +39 -0
  314. package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +152 -0
  315. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +1344 -0
  316. package/src/plugins/pi-agent-ide-debugger/src/ui.ts +14 -0
  317. package/src/plugins/pi-agent-ide-formatter/package.json +9 -4
  318. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  319. package/src/plugins/pi-agent-ide-lint/package.json +13 -8
  320. package/src/plugins/pi-agent-ide-lsp/index.ts +4 -1
  321. package/src/plugins/pi-agent-ide-lsp/package.json +15 -10
  322. package/src/plugins/pi-agent-ide-lsp/runtime/entry-33.js +2 -0
  323. package/src/plugins/pi-agent-ide-processes/index.ts +28 -0
  324. package/src/plugins/pi-agent-ide-processes/src/registry.ts +81 -0
  325. package/src/plugins/pi-agent-ide-processes/src/ui.ts +252 -0
  326. package/src/plugins/pi-agent-ide-terminal/index.ts +19 -13
  327. package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +52 -0
  328. package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +30 -0
  329. package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +24 -58
  330. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +5 -14
  331. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +114 -1
  332. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +23 -29
  333. package/src/plugins/pi-agent-ide-terminal/src/types.ts +13 -1
  334. package/src/plugins/pi-agent-ide-terminal/src/ui.ts +116 -240
  335. package/dist/chunk-3SE372WC.js +0 -3
  336. package/dist/chunk-5MSNYFDE.js +0 -1
  337. package/dist/chunk-7JYQMAEL.js +0 -14
  338. package/dist/chunk-B5KB2I7J.js +0 -3
  339. package/dist/chunk-NMFQGKPE.js +0 -2
  340. package/dist/chunk-OVUYPHDE.js +0 -1
  341. package/dist/chunk-TPIHQYK2.js +0 -14
  342. package/dist/chunk-XSTHESNR.js +0 -25
  343. package/dist/entry-16.js +0 -1
  344. package/node_modules/pi-agent-doctor/runtime/entry-16.js +0 -1
  345. package/node_modules/pi-agent-filesystem/runtime/entry-21.js +0 -2
  346. package/node_modules/pi-agent-ide-ast/runtime/entry-25.js +0 -1
  347. package/node_modules/pi-agent-ide-changes/runtime/entry-27.js +0 -1
  348. package/node_modules/pi-agent-image/runtime/entry-33.js +0 -1
  349. package/node_modules/pi-agent-resource/runtime/entry-41.js +0 -1
  350. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-49.js +0 -2
  351. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
  352. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
  353. package/node_modules/pi-agent-text-editor/runtime/entry-54.js +0 -1
  354. package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +0 -1
  355. package/node_modules/pi-agent-web/runtime/entry-75.js +0 -2
  356. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-22.js +0 -2
  357. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-21.js +0 -2
  358. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +0 -2
  359. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +0 -2
  360. package/src/extensions/pi-agent-read/runtime/entry-36.js +0 -1
  361. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-46.js +0 -2
  362. package/src/extensions/pi-agent-search/runtime/entry-42.js +0 -1
  363. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-49.js +0 -2
  364. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
  365. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
  366. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-71.js +0 -2
  367. package/src/extensions/pi-agent-text-editor/runtime/entry-54.js +0 -1
  368. package/src/plugins/pi-agent-ide-ast/runtime/entry-25.js +0 -1
  369. package/src/plugins/pi-agent-ide-changes/runtime/entry-27.js +0 -1
  370. /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-22.js +0 -0
  371. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-23.js +0 -0
  372. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-24.js +0 -0
  373. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-29.js +0 -0
  374. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-30.js +0 -0
  375. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-31.js +0 -0
  376. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-32.js +0 -0
  377. /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-34.js +0 -0
  378. /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-35.js +0 -0
  379. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-36.js +0 -0
  380. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-42.js +0 -0
  381. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-46.js +0 -0
  382. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-48.js +0 -0
  383. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-71.js +0 -0
  384. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
  385. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-74.js +0 -0
  386. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-76.js +0 -0
  387. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
  388. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
  389. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
  390. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-23.js +0 -0
  391. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-24.js +0 -0
  392. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
  393. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
  394. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
  395. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
  396. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-29.js +0 -0
  397. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-30.js +0 -0
  398. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-31.js +0 -0
  399. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-32.js +0 -0
@@ -0,0 +1 @@
1
+ import{a as w}from"./chunk-5PLV4HLG.js";import{a as C,b as E}from"./chunk-EJ5OACQM.js";import{a as n}from"./chunk-EI7MMDWY.js";import{DynamicBorder as $}from"@earendil-works/pi-coding-agent";import{Container as W,Key as S,matchesKey as M,SelectList as _,Text as m,truncateToWidth as D,visibleWidth as I}from"@earendil-works/pi-tui";var v=class{constructor(e,s,i){this.registry=e;this.activityMode=s;e.onDidChange(()=>this.#s()),i.registerCommand("agent-ide-processes",{description:"Show active terminal and debugger processes created by Agent IDE",handler:n(async(r,d)=>{if(this.bind(d),d.mode!=="tui"){d.ui.notify("The Agent IDE process overlay requires the TUI.","info");return}await this.#r(d)},"handler")})}static{n(this,"AgentIdeProcessesUi")}#t;#i=!1;#e;bind(e){this.#i||(this.#t=e,this.#s())}dispose(){this.#i=!0,this.#e!==void 0&&clearInterval(this.#e),this.#e=void 0,this.#t?.ui.setWidget("agent-ide-processes",void 0),this.#t?.ui.setStatus("agent-ide-processes",void 0),this.#t=void 0}#n(){return this.registry.list()}#s(){let e=this.#t;if(this.#i||e===void 0||!e.hasUI)return;let s=this.#n();if(this.activityMode==="off"||s.length===0){e.ui.setWidget("agent-ide-processes",void 0),e.ui.setStatus("agent-ide-processes",void 0),this.#e!==void 0&&clearInterval(this.#e),this.#e=void 0;return}if(this.activityMode==="compact"){e.ui.setWidget("agent-ide-processes",void 0),e.ui.setStatus("agent-ide-processes",`Agent IDE processes: ${s.length}`);return}e.ui.setStatus("agent-ide-processes",void 0),e.ui.setWidget("agent-ide-processes",(i,r)=>({invalidate(){},render:n(d=>k(s,d,r),"render")}),{placement:"belowEditor"}),this.#e??=setInterval(()=>this.#s(),1e3)}async#r(e){for(;;){if(this.#n().length===0){e.ui.notify("No active Agent IDE processes.","info");return}let s=n(()=>{},"disposeRefresh"),i,r;try{r=await e.ui.custom((u,c,O,x)=>{let y=this.#n(),f="list",g,P=n(l=>{let a=y.map(o=>({value:o.source,label:`${o.status} ${o.kind} ${o.title}`,description:o.description})),p=new _(a,Math.min(a.length,12),{selectedPrefix:n(o=>c.fg("accent",o),"selectedPrefix"),selectedText:n(o=>c.fg("accent",o),"selectedText"),description:n(o=>c.fg("muted",o),"description"),scrollInfo:n(o=>c.fg("dim",o),"scrollInfo"),noMatch:n(o=>c.fg("warning",o),"noMatch")}),b=a.findIndex(o=>o.value===l);return b>=0&&p.setSelectedIndex(b),p.onSelect=o=>{g=y.find(R=>R.source===o.value),f="detail",u.requestRender()},p.onCancel=()=>x(null),p},"createList"),h=P(),A=n(()=>{let l=g?.source??h.getSelectedItem()?.value;y=this.#n(),g=f==="list"?void 0:y.find(a=>a.source===l),h=P(l),u.requestRender()},"refresh");return s=this.registry.onDidChange(A),i=setInterval(A,1e3),{invalidate:n(()=>h.invalidate(),"invalidate"),render(l){let a=new W;return a.addChild(new $(p=>c.fg("accent",p))),f==="list"?(a.addChild(new m(c.fg("accent",c.bold("Agent IDE processes")),1,0)),a.addChild(h),a.addChild(new m(c.fg("dim","enter view \xB7 d stop \xB7 esc close"),1,0))):g===void 0?a.addChild(new m(c.fg("warning","Process is no longer active."),1,0)):(a.addChild(g.renderDetail(c)),a.addChild(new m(c.fg(f==="confirm"?"warning":"dim",f==="confirm"?"Stop this process? y confirm \xB7 n/esc cancel":"esc back \xB7 d stop"),1,0))),a.addChild(new $(p=>c.fg("accent",p))),a.render(l)},handleInput(l){f==="list"?l==="d"?(g=y.find(a=>a.source===h.getSelectedItem()?.value),g!==void 0&&(f="confirm")):h.handleInput(l):f==="detail"?M(l,S.escape)?f="list":l==="d"&&(f="confirm"):l==="y"&&g!==void 0?x({source:g.source}):(l==="n"||M(l,S.escape))&&(f="detail"),u.requestRender()}}},{overlay:!0,overlayOptions:{width:"75%",maxHeight:"80%",minWidth:52}})}finally{s(),i!==void 0&&clearInterval(i)}if(r===null)return;let d=this.#n().find(u=>u.source===r.source);d!==void 0&&await d.stop()}}};function k(t,e,s){if(t.length===0)return[];let i=n(d=>s.fg("accent",d),"accent"),r=[q("Agent IDE Processes",`${t.length} active`,e,i)];for(let[d,u]of t.entries()){for(let c of u.renderSummary(s))r.push(T(` ${c} `,e,i));d<t.length-1&&r.push(T("",e,i))}return r.push(L(e,i)),r}n(k,"renderProcessWidget");function q(t,e,s,i){if(s<=1)return i("\u256D");let r=s-2,d=`\u2500 ${t} `,u=` ${e} \u2500`,c="\u2500".repeat(Math.max(0,r-I(d)-I(u)));return i(`\u256D${D(`${d}${c}${u}`,r).padEnd(r,"\u2500")}\u256E`)}n(q,"borderTop");function T(t,e,s){if(e<=1)return s("\u2502");let i=e-2,r=D(t,i);return`${s("\u2502")}${r}${" ".repeat(Math.max(0,i-I(r)))}${s("\u2502")}`}n(T,"borderLine");function L(t,e){return e(t<=1?"\u2570":`\u2570${"\u2500".repeat(t-2)}\u256F`)}n(L,"borderBottom");async function B(t){let e=w(t),s=await E(C()),i=new v(e,K(s.preferences?.["processes.activity"]),t);t.on("session_start",(r,d)=>i.bind(d)),t.on("session_shutdown",()=>i.dispose())}n(B,"registerAgentIdeProcesses");function K(t){return t==="compact"||t==="off"?t:"detailed"}n(K,"activityMode");export{B as default};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-EI7MMDWY.js";var n="pi-agent-ide-doctor",r=1,i="pi-agent-ide-doctor/core/ready",c="pi-agent-ide-doctor/plugin/register";function a(o){return t(o)&&o.protocol===n&&o.apiVersion===1}e(a,"isDoctorCoreReady");function d(o){return!t(o)||typeof o.accept!="function"||!t(o.plugin)?!1:o.plugin.protocol===n&&o.plugin.apiVersion===1&&typeof o.plugin.id=="string"&&o.plugin.id.length>0&&typeof o.plugin.setup=="function"}e(d,"isDoctorPluginRegistrationRequest");function t(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}e(t,"isRecord");export{n as a,r as b,i as c,c as d,a as e,d as f};
1
+ import{a as e}from"./chunk-EI7MMDWY.js";var n="pi-agent-ide-doctor",r=1,i="pi-agent-ide-doctor/core/ready",a="pi-agent-ide-doctor/plugin/register";function c(o){return t(o)&&o.protocol===n&&o.apiVersion===1}e(c,"isDoctorCoreReady");function d(o){return!t(o)||typeof o.accept!="function"||!t(o.plugin)?!1:o.plugin.protocol===n&&o.plugin.apiVersion===1&&typeof o.plugin.id=="string"&&o.plugin.id.length>0&&typeof o.plugin.setup=="function"}e(d,"isDoctorPluginRegistrationRequest");function t(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}e(t,"isRecord");export{n as a,r as b,i as c,a as d,c as e,d as f};
@@ -1 +1 @@
1
- import{a as n}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as d}from"typebox/value";var t=e.Function([],e.Unknown()),i=e.Union([e.Object({stage:e.Literal("text-pre-edit"),handler:t}),e.Object({stage:e.Literal("text-edit"),handler:t}),e.Object({stage:e.Literal("text-post-edit"),handler:t})]);function l(r){return d.Check(i,r)}n(l,"isTextEditHandlerRegistration");export{l as a};
1
+ import{a as n}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as a}from"typebox/value";var t=e.Function([],e.Unknown()),i=e.Union([e.Object({stage:e.Literal("text-pre-edit"),handler:t}),e.Object({stage:e.Literal("text-edit"),handler:t}),e.Object({stage:e.Literal("text-post-edit"),handler:t})]);function l(r){return a.Check(i,r)}n(l,"isTextEditHandlerRegistration");export{l as a};
File without changes
@@ -1 +1 @@
1
- import{a as p,e as f,k as g}from"./chunk-Y7ZMR4LT.js";import{a as o}from"./chunk-EI7MMDWY.js";import{AsyncLocalStorage as m}from"node:async_hooks";var l=new m,u=new m;function E(t){let e=u.getStore();e?e.push(t):t()}o(E,"afterPostEditScope");async function T(t){if(u.getStore())return t();let e=[];try{return await u.run(e,t)}finally{for(let r of e)r()}}o(T,"collectPostEditNotifications");function b(t,e){let r=l.getStore();return r?(r.set(t,e),!0):!1}o(b,"deferPostEdit");function h(t){return l.getStore()?.has(t)??!1}o(h,"hasDeferredPostEdit");function v(){let t=new Map;return{run(e){return l.run(t,e)},forget(e){t.delete(e)},async finish(e){let r=[...t.values()];t.clear();let d=[],i=[];if(await T(async()=>{for(let a of r)try{let s=await a();d.push(s),e?.(s)}catch(s){i.push(s)}}),i.length>0)throw new AggregateError(i,`Some final post-processing failed; completed edits remain applied. ${i.map(a=>a instanceof Error?a.message:String(a)).join("; ")}`);return d}}}o(v,"createPostEditScope");import{Type as n}from"typebox";import{Value as c}from"typebox/value";var w=`${p}/post-edit/register`;function A(t){return c.Check(n.Object({formatting:n.Object({status:n.Union(["disabled","unavailable","skipped-syntax","unchanged","changed","failed","not-reported","deferred"].map(e=>n.Literal(e))),formatter:n.Optional(n.String())})}),t)}o(A,"isFormattingContribution");function M(t){return c.Check(n.Object({diffStatuses:n.Array(n.Object({text:n.String({minLength:1}),formatter:n.Optional(n.String()),tone:n.Optional(n.Union(["muted","success","warning","error"].map(e=>n.Literal(e))))}))}),t)}o(M,"isDiffStatusContribution");var x=n.Function([],n.Unknown()),y=n.Object({id:n.String({minLength:1}),handler:x}),P=n.Object({registration:y,accept:x});function S(t){return c.Check(y,t)}o(S,"isTextPostEditHandlerRegistration");function _(t){return c.Check(P,t)}o(_,"isTextPostEditHandlerRegistrationRequest");function j(t){if(typeof t!="object"||t===null)return!1;let e=t;return Array.isArray(e.hints)&&typeof e.scopeMarkers=="object"&&e.scopeMarkers!==null&&Array.isArray(e.warnings)}o(j,"isTextMutationResultContributionData");function I(t,e){if(!S(e))throw new TypeError("Invalid text editor post-edit handler registration");let r,d=o(()=>{let a={registration:e,accept(s){if(r!==void 0)throw new Error(`Post-edit handler ${e.id} was accepted more than once`);r=s}};return t.events.emit(w,a),r!==void 0},"announce"),i=o(()=>{},"unsubscribeReady");i=t.events.on(f,a=>{if(!g(a))throw new Error("Invalid pi-agent-text-editor core readiness event");if(!d())throw new Error("pi-agent-text-editor core announced readiness without accepting the post-edit handler");i()}),t.on("session_shutdown",()=>{i(),r?.()}),d()&&i()}o(I,"connectTextEditorPostEditHandler");export{E as a,T as b,b as c,h as d,v as e,w as f,A as g,M as h,S as i,_ as j,j as k,I as l};
1
+ import{a as p,e as f,k as g}from"./chunk-O6LE42GK.js";import{a as o}from"./chunk-EI7MMDWY.js";import{AsyncLocalStorage as m}from"node:async_hooks";var l=new m,u=new m;function E(t){let e=u.getStore();e?e.push(t):t()}o(E,"afterPostEditScope");async function T(t){if(u.getStore())return t();let e=[];try{return await u.run(e,t)}finally{for(let r of e)r()}}o(T,"collectPostEditNotifications");function b(t,e){let r=l.getStore();return r?(r.set(t,e),!0):!1}o(b,"deferPostEdit");function h(t){return l.getStore()?.has(t)??!1}o(h,"hasDeferredPostEdit");function v(){let t=new Map;return{run(e){return l.run(t,e)},forget(e){t.delete(e)},async finish(e){let r=[...t.values()];t.clear();let d=[],i=[];if(await T(async()=>{for(let a of r)try{let s=await a();d.push(s),e?.(s)}catch(s){i.push(s)}}),i.length>0)throw new AggregateError(i,`Some final post-processing failed; completed edits remain applied. ${i.map(a=>a instanceof Error?a.message:String(a)).join("; ")}`);return d}}}o(v,"createPostEditScope");import{Type as n}from"typebox";import{Value as c}from"typebox/value";var w=`${p}/post-edit/register`;function A(t){return c.Check(n.Object({formatting:n.Object({status:n.Union(["disabled","unavailable","skipped-syntax","unchanged","changed","failed","not-reported","deferred"].map(e=>n.Literal(e))),formatter:n.Optional(n.String())})}),t)}o(A,"isFormattingContribution");function M(t){return c.Check(n.Object({diffStatuses:n.Array(n.Object({text:n.String({minLength:1}),formatter:n.Optional(n.String()),tone:n.Optional(n.Union(["muted","success","warning","error"].map(e=>n.Literal(e))))}))}),t)}o(M,"isDiffStatusContribution");var x=n.Function([],n.Unknown()),y=n.Object({id:n.String({minLength:1}),handler:x}),P=n.Object({registration:y,accept:x});function S(t){return c.Check(y,t)}o(S,"isTextPostEditHandlerRegistration");function _(t){return c.Check(P,t)}o(_,"isTextPostEditHandlerRegistrationRequest");function j(t){if(typeof t!="object"||t===null)return!1;let e=t;return Array.isArray(e.hints)&&typeof e.scopeMarkers=="object"&&e.scopeMarkers!==null&&Array.isArray(e.warnings)}o(j,"isTextMutationResultContributionData");function I(t,e){if(!S(e))throw new TypeError("Invalid text editor post-edit handler registration");let r,d=o(()=>{let a={registration:e,accept(s){if(r!==void 0)throw new Error(`Post-edit handler ${e.id} was accepted more than once`);r=s}};return t.events.emit(w,a),r!==void 0},"announce"),i=o(()=>{},"unsubscribeReady");i=t.events.on(f,a=>{if(!g(a))throw new Error("Invalid pi-agent-text-editor core readiness event");if(!d())throw new Error("pi-agent-text-editor core announced readiness without accepting the post-edit handler");i()}),t.on("session_shutdown",()=>{i(),r?.()}),d()&&i()}o(I,"connectTextEditorPostEditHandler");export{E as a,T as b,b as c,h as d,v as e,w as f,A as g,M as h,S as i,_ as j,j as k,I as l};
@@ -0,0 +1,2 @@
1
+ import{a as j}from"./chunk-GUTQ3PWL.js";import{m as S}from"./chunk-5VSE5X5R.js";import{a as g}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import{createHash as le}from"node:crypto";import{readFile as J}from"node:fs/promises";import f from"node:path";import{spawn as Z}from"node:child_process";import _ from"node:path";import{createInterface as ee}from"node:readline";import{existsSync as X}from"node:fs";import Y from"node:os";import H from"node:path";function F(e=process.env.PI_CODING_AGENT_DIR??H.join(Y.homedir(),".pi","agent"),t=process.platform){let n=H.join(e,"bin",t==="win32"?"rg.exe":"rg");return X(n)?n:"rg"}a(F,"resolveRipgrepExecutable");async function R(e,t,n){if(e.query.length===0)throw new Error("Search query must not be empty.");if(/\r|\n/u.test(e.query))throw new Error("Search supports one-line patterns only.");let r=_.resolve(t,re(e.path??".")),o=["--json","--no-config","--no-ignore-parent","--color=never","--with-filename","--line-number",e.caseSensitive===!0?"--case-sensitive":"--ignore-case",...e.wholeWord===!0?["--word-regexp"]:[],...O(e.include).flatMap(i=>["--glob",i]),...O(e.exclude).flatMap(i=>["--glob",`!${i}`]),"--",e.query,r];if(e.regex!==!0)return k(["--fixed-strings",...o],n);try{return await k(["--engine","auto",...o],n)}catch(i){if(!te(i))throw i;return k(["--engine","default",...o],n)}}a(R,"searchText");function k(e,t){return new Promise((n,r)=>{let o=Z(F(),e,{stdio:["ignore","pipe","pipe"]}),i=ee({input:o.stdout}),s=[],l="",c,u=a(()=>{o.kill()},"abort"),d=a(()=>{t?.removeEventListener("abort",u),i.close()},"cleanup");o.stderr.setEncoding("utf8"),o.stderr.on("data",m=>{l+=m}),i.on("line",m=>{if(!(c!==void 0||m.length===0))try{let h=JSON.parse(m);if(h.type!=="match")return;for(let b of ne(h))s.push(b)}catch(h){c=h,o.kill()}}),o.once("error",m=>{d(),r(m)}),o.once("close",m=>{if(d(),t?.aborted===!0){let h=new Error("Search was aborted.");h.name="AbortError",r(h);return}if(c!==void 0){r(new Error("Unable to parse ripgrep search output.",{cause:c}));return}if(m!==0&&m!==1){r(new Error(l.trim()||`ripgrep exited with code ${String(m)}.`));return}s.sort(oe),n({matches:s,complete:!0})}),t?.addEventListener("abort",u,{once:!0}),t?.aborted===!0&&u()})}a(k,"runRipgrep");function te(e){return e instanceof Error&&/PCRE2: error matching: match limit exceeded/iu.test(e.message)}a(te,"isPcre2MatchLimitError");function ne(e){let t=e.data.path.text,n=e.data.lines.text;if(t===void 0||n===void 0||!Number.isSafeInteger(e.data.line_number))return[];let r=n.replace(/(?:\r\n|\n)$/u,""),o=Buffer.from(n),i=[];for(let s of e.data.submatches){if(s.start<0||s.end<=s.start||s.end>o.length)continue;let l=o.subarray(0,s.start).toString("utf8").length,c=o.subarray(0,s.end).toString("utf8").length;i.push({source:_.resolve(t),lineNumber:e.data.line_number,startColumn:l,endColumn:c,matchedText:r.slice(l,c),lineText:r})}return i}a(ne,"matchesFromEvent");function O(e){if(e===void 0)return[];let t=[],n=0,r="";for(let o of e){if(o==="{"?n+=1:o==="}"&&(n=Math.max(0,n-1)),n===0&&(o===","||/\s/u.test(o))){r.length>0&&(t.push(r),r="");continue}r+=o}return r.length>0&&t.push(r),t}a(O,"splitGlobList");function re(e){return e.startsWith("@")?e.slice(1):e}a(re,"stripFilePrefix");function oe(e,t){return e.source.localeCompare(t.source)||e.lineNumber-t.lineNumber||e.startColumn-t.startColumn||e.endColumn-t.endColumn}a(oe,"compareMatches");function E(e,t=!1){let n=C(e);if(!N(n))return t?e:$(e);let r=v(new A(e,n).parse(),t);return`^${r.condition}.*?\\K(${r.match})`}a(E,"compileSearchQuery");function W(e){if(N(C(e)))return;let t=[...new Set(e.trim().split(/\s+/u).filter(Boolean))];return t.length>1?`(?:${t.map($).join("|")})`:void 0}a(W,"compileSearchFallbackQuery");function N(e){return e.some(t=>t.quoted===!0||t.type==="and"||t.type==="or"||t.type==="not")}a(N,"containsBooleanSyntax");var A=class{static{a(this,"BooleanQueryParser")}#t;#r;#i=0;constructor(t,n){this.#t=t,this.#r=n}parse(){let t=this.#s(),n=this.#e();if(n.type!=="end"){let r=n.type==="right"?"unexpected ')'.":`unexpected ${ce(n)}.`;throw p(n.offset,r)}return t}#s(){let t=this.#n();for(;this.#e().type==="or";){let n=this.#o(),r=this.#c(`after ${n.value}`);t={kind:"or",left:t,right:this.#a(r)}}return t}#n(){return this.#a(this.#c())}#a(t){let n=t;for(;;){let r=this.#e();if(r.type==="and"||r.type==="not"){this.#o();let o=this.#c(`after ${r.value}`);n={kind:r.type,left:n,right:o};continue}if(r.type==="term"||r.type==="left"){n={kind:"and",left:n,right:this.#c()};continue}return n}}#c(t){let n=this.#e();if(n.type==="term")return this.#o(),{kind:"term",value:n.value,quoted:n.quoted};if(n.type==="left"){if(this.#o(),this.#e().type==="right"||this.#e().type==="end")throw p(this.#e().offset,"expected a term after '('.");let o=this.#s();if(this.#e().type!=="right")throw p(this.#e().offset,"expected ')'.");return this.#o(),o}if(t===void 0&&(n.type==="and"||n.type==="or"||n.type==="not"))throw p(n.offset,`expected a term before ${n.value}.`);let r=t===void 0?"":` ${t}`;throw p(n.offset,`expected a term${r}.`)}#e(){return this.#r[this.#i]??{type:"end",value:"",offset:this.#t.length}}#o(){let t=this.#e();return this.#i+=1,t}};function C(e){let t=[],n=0;for(;n<e.length;){let r=e.charAt(n);if(/\s/u.test(r)){n+=1;continue}if(r==="("&&ie(e,n)){t.push({type:"left",value:r,offset:n}),n+=1;continue}if(r===")"){t.push({type:"right",value:r,offset:n}),n+=1;continue}if(D(e,n)){let s=e.charAt(n+1)==="|"?2:1;t.push({type:"or",value:e.slice(n,n+s),offset:n}),n+=s;continue}if(r==="'"||r==='"'){let s=n,l=r,c="";for(n+=1;n<e.length&&e.charAt(n)!==l;)e.charAt(n)==="\\"&&(e.charAt(n+1)===l||e.charAt(n+1)==="\\")&&(n+=1),c+=e.charAt(n++);if(n>=e.length)throw p(s,`unterminated ${l==="'"?"single":"double"}-quoted term.`);if(n+=1,c.length===0)throw p(s,"quoted terms must not be empty.");t.push({type:"term",value:c,offset:s,quoted:!0});continue}let o=n;for(;n<e.length;){let s=e.charAt(n);if(/\s/u.test(s)||s===")"||D(e,n))break;s==="\\"&&n+1<e.length?n+=2:s==="["||s==="("?n=M(e,n)??n+1:n+=1}let i=e.slice(o,n);t.push({type:se(i),value:i,offset:o})}return t.push({type:"end",value:"",offset:e.length}),t}a(C,"tokenize");function D(e,t){return e.charAt(t)==="|"&&(e.charAt(t+1)==="|"||/\s/u.test(e.charAt(t-1))&&/\s/u.test(e.charAt(t+1)))}a(D,"isBooleanPipe");function M(e,t){let n=e.charAt(t)==="["?"]":")",r=t+1;for(;r<e.length;){let o=e.charAt(r);if(o==="\\")r+=2;else{if(o===n)return r+1;if(n===")"&&(o==="("||o==="[")){let i=M(e,r);if(i===void 0)return;r=i}else r+=1}}}a(M,"regexBlockEnd");function ie(e,t){let n=M(e,t);if(n===void 0)return!0;let r=e.slice(t+1,n-1);return r.trim().length===0?!0:N(C(r))}a(ie,"isBooleanGroup");function se(e){return e==="AND"?"and":e==="OR"?"or":e==="NOT"?"not":"term"}a(se,"operatorType");function ce(e){return e.value.length>0?JSON.stringify(e.value):"the end of the query"}a(ce,"quoteToken");function p(e,t){return new SyntaxError(`Invalid Boolean search query at column ${String(e+1)}: ${t}`)}a(p,"syntaxError");function v(e,t){if(e.kind==="term"){let o=t&&!e.quoted?e.value:$(e.value);return{condition:`(?=.*(?:${o}))`,match:o}}let n=v(e.left,t),r=v(e.right,t);return e.kind==="or"?{condition:`(?:${n.condition}|${r.condition})`,match:`(?:${n.match}|${r.match})`}:e.kind==="not"?{condition:`${n.condition}(?!${r.condition})`,match:n.match}:{condition:`${n.condition}${r.condition}`,match:`(?:${n.match}|${r.match})`}}a(v,"compileExpression");function $(e){return e.replace(/[\\^$.*+?()[\]{}|]/gu,"\\$&")}a($,"escapeRegex");function $e(e){let t=E(e.query),n=E(e.query,!0),r=W(e.query),o=[];return n!==t&&o.push({query:n,mode:"regex"}),r!==void 0&&r!==t&&r!==n&&o.push({query:r,mode:"words"}),{...e,query:t,regex:!0,fallbacks:o}}a($e,"createSearchRecipe");async function B(e,t,n){let r=e.query,o=await R(e,t,n),i=[];for(let s of e.fallbacks??[]){if(o.matches.length>0||!o.complete)break;n?.throwIfAborted();try{o=await R({...e,query:s.query,regex:!0},t,n),r=s.query,i.push(s.mode==="regex"?"Search fallback: no literal matches; tried unquoted terms as regex.":"Search fallback: no matches in earlier modes; tried separate words.")}catch(l){if(s.mode!=="regex"||!ae(l)||n?.aborted)throw l;i.push("Search fallback: invalid regex skipped; literal search found no matches.")}}return{...o,query:r,notices:i}}a(B,"runSearchRecipe");function ae(e){return e instanceof Error&&/regex parse error:|PCRE2: error compiling pattern/iu.test(e.message)}a(ae,"isRegexSyntaxError");var ue=/^SEARCH#([A-F0-9]{4,64}):(all|[1-9]\d*):(line|match)$/u,z=4;function De(e,t,n,r){return U(e,t,n,r).slice(0,z)}a(De,"createSearchSessionId");function U(e,t,n,r){let o=n===void 0?me(t.map(c=>c.source)):f.resolve(n),i=t.map(c=>({match:c,source:f.relative(o,f.resolve(c.source))})).sort((c,u)=>c.source.localeCompare(u.source)||I(c.match,u.match)).map(({match:c,source:u})=>[u,c.lineNumber,c.startColumn,c.endLineNumber??c.lineNumber,c.endColumn,c.matchedText,c.lineText]),{limit:s,...l}=K(r??{query:e,regex:!0},o);return le("sha256").update(JSON.stringify([e,o,l,i])).digest("hex").toUpperCase()}a(U,"createSearchSessionIdentity");function de(e,t){if(!/^[A-F0-9]{64}$/u.test(e))throw new Error("Search session identity must be a 64-character uppercase hexadecimal value.");for(let n=z;n<=e.length;n+=1){let r=e.slice(0,n);if(!t.has(r))return r}throw new Error("Could not allocate a unique search session id.")}a(de,"allocateSearchSessionId");function K(e,t){return{query:e.query,path:f.resolve(t,e.path??"."),include:e.include??"",exclude:e.exclude??"",caseSensitive:e.caseSensitive===!0,wholeWord:e.wholeWord===!0,limit:e.limit??50,regex:e.regex===!0,fallbacks:e.fallbacks??[]}}a(K,"normalizeRecipe");var Q=class{constructor(t=U){this.createIdentity=t}static{a(this,"SearchSessionStore")}#t=new Map;#r=new Map;async register(t,n,r,o,i,s={query:t,regex:!0},l){let c=n.map(L=>({...L,source:f.resolve(L.source)})).sort(I),u=await G(c,i),d=this.createIdentity(t,c,o,s),h=this.#r.get(d)??de(d,new Set(this.#t.keys())),b={id:h,query:t,matches:c,complete:r,contentBySource:u,recipe:s,...l!==void 0&&{refresh:l},cwd:f.resolve(o)};return this.#r.set(d,h),this.#t.set(h,b),b}async observeAfterEdit(t,n){let r=new Set(t.flatMap(i=>{let s=typeof i=="string"?w(i):void 0;return s===void 0?[]:[s.id]})),o=[];for(let i of r){let s=this.#t.get(i);if(s===void 0)continue;let l={sessionId:i,query:s.recipe.originalQuery??s.query,scope:K(s.recipe,s.cwd)};try{let c=s.refresh===void 0?await B(s.recipe,s.cwd,n):await s.refresh(n);o.push({...l,matches:c.matches.length,complete:c.complete,notices:c.notices})}catch(c){o.push({...l,error:c instanceof Error?c.message:String(c)})}}return o}anchorResolver(){return{id:"search",description:["`SEARCH#HASH:N:line` selects one result's full line; `SEARCH#HASH:N:match` selects its exact match.","`SEARCH#HASH:all:line` selects each unique containing line; `SEARCH#HASH:all:match` selects every exact match.","Omit `path` when `all` spans files."].join(`
2
+ `),renderFull(t){return t},renderCompact(t){let n=w(t);return n===void 0?"selected result":n.selector==="all"?n.mode==="match"?"all matches":"all lines":n.mode==="match"?`match ${String(n.selector)}`:`line ${String(n.selector)}`},tryResolve:a((t,n)=>this.#i(t,n.source,n.signal),"tryResolve")}}resourceResolver(){return{id:"search-targets",tryResolve:a((t,n)=>this.#s(t,n.cwd),"tryResolve")}}async#i(t,n,r){let o=w(t);if(o===void 0)return{kind:"not-handled"};let i=this.#t.get(o.id);if(i===void 0)return x();if(o.selector==="all"&&!i.complete)return y();let s=f.resolve(n),l=i;if(o.selector==="all"){if(i.refreshedComplete?.complete===!0)l=i.refreshedComplete;else if(i.refreshedComplete!==void 0&&(l=await this.#n(i,r),!l.complete))return y()}let c=T(l,o.selector,o.mode),u=c.filter(h=>h.source===s);if(u.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};let d=await P(s,r);if(d===void 0)return x(g(u[0]).lineNumber);if(o.selector==="all"&&d!==l.contentBySource.get(s)){if(l=await this.#n(i,r),!l.complete)return y();c=T(l,o.selector,o.mode),u=c.filter(h=>h.source===s)}if(u.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};if(o.selector!=="all"&&d!==i.contentBySource.get(s))return x(g(u[0]).lineNumber);let m=S(s,d);return{kind:"resolved",anchor:new j(t,s,u.map(h=>q(m,h,o.mode)))}}async#s(t,n){let r=w(t);if(r===void 0)return{kind:"not-handled"};let o=this.#t.get(r.id);if(o===void 0)return x();if(r.selector==="all"&&!o.complete)return y();let i=o;if(r.selector==="all"){if(o.refreshedComplete?.complete===!0)i=o.refreshedComplete;else if(o.refreshedComplete!==void 0&&(i=await this.#n(o),!i.complete))return y();let u=new Set(T(i,r.selector,r.mode).map(d=>d.source));for(let d of u)if(await P(d)!==i.contentBySource.get(d)){if(i=await this.#n(o),!i.complete)return y();break}}let s=T(i,r.selector,r.mode);if(r.selector!=="all"){let u=s[0]?.source;if(u!==void 0&&await P(u)!==i.contentBySource.get(u))return x(s[0]?.lineNumber)}let l=new Map;for(let u of s){let d=l.get(u.source)??[];d.push(q(S(u.source,i.contentBySource.get(u.source)??u.lineText),u,r.mode)),l.set(u.source,d)}let c=[...l].map(([u,d])=>({source:u,ranges:d,expectedContent:i.contentBySource.get(u)}));return c.length===0?{kind:"rejected",rejection:{code:"missing",reason:"search anchor has no matches"}}:{kind:"resolved",targets:c}}async#n(t,n){let r=t.refresh===void 0?await B(t.recipe,t.cwd,n):await t.refresh(n),o=r.matches.map(s=>({...s,source:f.resolve(s.source)})).sort(I),i={matches:o,complete:r.complete,contentBySource:await G(o,n)};return this.#t.set(t.id,{...t,refreshedComplete:i}),i}};function w(e){let t=ue.exec(e);if(t!==null)return{id:g(t[1]),selector:t[2]==="all"?"all":Number(t[2]),mode:t[3]==="line"?"line":"match"}}a(w,"parseSearchAnchor");function T(e,t,n){let r=t==="all"?e.matches:[e.matches[t-1]].filter(he);if(n==="match"||t!=="all")return r;let o=new Set;return r.flatMap(i=>{let s=S(i.source,e.contentBySource.get(i.source)??i.lineText),l=V(i);return s.lines.slice(i.lineNumber-1,l).flatMap(c=>{let u=`${i.source}\0${String(c.lineNumber)}`;return o.has(u)?[]:(o.add(u),[{...i,lineNumber:c.lineNumber,endLineNumber:c.lineNumber,startColumn:0,endColumn:c.content.length,lineText:c.content,matchedText:c.content}])})})}a(T,"selectMatches");function he(e){return e!==void 0}a(he,"isMatch");function V(e){let t=e.endLineNumber??e.lineNumber;return t>e.lineNumber&&e.endColumn===0?t-1:t}a(V,"lastContainingLine");function q(e,t,n){if(n==="match")return{start:{lineNumber:t.lineNumber,column:t.startColumn},end:{lineNumber:t.endLineNumber??t.lineNumber,column:t.endColumn}};let r=V(t),o=g(e.lines[r-1]);return{start:{lineNumber:t.lineNumber,column:0},end:{lineNumber:r+(o.lineEnding.length>0?1:0),column:o.lineEnding.length>0?0:o.content.length},linewise:!0}}a(q,"selectionRange");function fe(e,t){let n=t.endLineNumber??t.lineNumber;return e.lines.slice(t.lineNumber-1,n).map(r=>{let o=r.lineNumber===t.lineNumber?t.startColumn:0,i=r.lineNumber===n?t.endColumn:r.content.length;return r.content.slice(o,i)+(r.lineNumber===n?"":r.lineEnding)}).join("")}a(fe,"matchedSourceText");async function G(e,t){let n=new Map;for(let r of new Set(e.map(o=>o.source))){let o=await J(r,{encoding:"utf8",...t!==void 0&&{signal:t}}),i=S(r,o);for(let s of e.filter(l=>l.source===r))if(i.lines[s.lineNumber-1]?.content!==s.lineText||fe(i,s)!==s.matchedText)throw new Error(`Search result in ${r} changed before its anchors were registered.`);n.set(r,o)}return n}a(G,"snapshotContents");async function P(e,t){try{return await J(e,{encoding:"utf8",...t!==void 0&&{signal:t}})}catch{return}}a(P,"readCurrent");function x(e=1){return{kind:"rejected",rejection:{code:"stale",reason:"search anchor is stale",contextRange:{offset:Math.max(1,e-2),limit:5}}}}a(x,"staleAnchor");function y(){return{kind:"rejected",rejection:{code:"missing",reason:"search did not register an all anchor because its result was limited"}}}a(y,"missingCompleteAnchor");function me(e){if(e.length===0)return".";let t=f.dirname(f.resolve(g(e[0])));for(let n of e.slice(1)){let r=f.resolve(n);for(;!pe(t,r);){let o=f.dirname(t);if(o===t)return t;t=o}}return t}a(me,"commonSourceDirectory");function pe(e,t){let n=f.relative(e,t);return n!==".."&&!n.startsWith(`..${f.sep}`)&&!f.isAbsolute(n)}a(pe,"isWithin");function I(e,t){return e.source.localeCompare(t.source)||e.lineNumber-t.lineNumber||e.startColumn-t.startColumn||(e.endLineNumber??e.lineNumber)-(t.endLineNumber??t.lineNumber)||e.endColumn-t.endColumn}a(I,"compareMatches");export{F as a,$e as b,B as c,De as d,U as e,de as f,Q as g};
@@ -0,0 +1,27 @@
1
+ import{a as ae,b as oe,c as ie}from"./chunk-ESPNEJHK.js";import{a as ne}from"./chunk-5PLV4HLG.js";import{a as K}from"./chunk-MGCHOGQD.js";import{a as W,b as z}from"./chunk-T6LX2RX5.js";import{c as Q}from"./chunk-YHUTTZC6.js";import{a as Y}from"./chunk-6CZO43OH.js";import{a as X,b as Z}from"./chunk-OBNING2A.js";import{a as re}from"./chunk-L7JMDDSD.js";import{a as ee,b as te}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import{d as E,e as y}from"./chunk-N34ATN52.js";import{a as i}from"./chunk-EI7MMDWY.js";import S from"node:path";import{access as et}from"node:fs/promises";import{StringEnum as tt}from"@earendil-works/pi-ai";import{defineTool as rt}from"@earendil-works/pi-coding-agent";import{Type as D}from"typebox";import{access as $}from"node:fs/promises";var se=[{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:"kotlin-debug-adapter",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"}],N=[{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"],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"],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"],install:"Run go install github.com/go-delve/delve/cmd/dlv@v1.25.2."}},{id:"elixir-ls-debug-adapter",name:"ElixirLS debug adapter",kind:"debugger",languages:["elixir"],executables:["elixir","mix"],dependencies:["Elixir 1.14.5","Erlang/OTP 25.3.2.21","ElixirLS 0.29.3"],documentation:"https://github.com/elixir-lsp/elixir-ls",debugger:{runtimeExecutables:["elixir","mix"],adapterExecutables:["debug_adapter.sh"],platforms:["linux"],install:"Install Erlang/OTP 25.3.2.21, Elixir 1.14.5, and the ElixirLS 0.29.3 release at /opt/pi-debug-adapters/elixir-ls."}},{id:"vsc-debugger",name:"vscDebugger",kind:"debugger",languages:["r"],executables:["R"],dependencies:["R 4.3.3","R6 2.5.1","jsonlite 1.8.8","vscDebugger 0.5.2"],documentation:"https://manuelhentschel.github.io/vscDebugger/",debugger:{runtimeExecutables:["R"],adapterExecutables:["R"],platforms:["linux"],install:"Install R 4.3.3 and vscDebugger 0.5.2 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:"kotlin-debug-adapter",name:"Kotlin Debug Adapter",kind:"debugger",languages:["java","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"],install:"Install .NET SDK 8 and NetCoreDbg 3.2.0-1092."}},{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"],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"],install:"Install Lua, 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"],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.1"],documentation:"https://github.com/ruby/debug",debugger:{runtimeExecutables:["ruby"],adapterExecutables:["rdbg"],platforms:["linux"],install:"Install Ruby and debug gem 1.11.1."}},{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"],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"],install:"Install Node 24 and js-debug-dap v1.117.0 from the official release archive."}}];function L(r){return N.find(e=>e.languages.includes(r))}i(L,"debuggerRecipeForLanguage");var de="/opt/pi-debug-adapters/js-debug/src/dapDebugServer.js",ue="/opt/pi-debug-adapters/elixir-ls/debug_adapter.sh",le={protocol:W,apiVersion:1,id:"debugger",setup(r){for(let e of N)r.addToolRecipe(e);r.addSetupCheck({id:"effective-config",inspect:Ae}),r.addCheck({id:"adapters",title:"Debug adapters",run:Te})}};async function Ae(r){let e=new Map([...r.detectedLanguageIds].map(L).filter(a=>a!==void 0).map(a=>[a.id,a])),t=[...r.detectedLanguageIds].flatMap(a=>{let o=L(a);return o===void 0?[]:[{kind:"debugger",languageId:a,toolId:o.id}]}),n=[];for(let a of se)a.status==="planned"&&r.detectedLanguageIds.has(a.language)&&n.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 e.values()){let o=a.debugger;if(o===void 0)continue;if(process.platform!=="linux"||!o.platforms.includes("linux")){n.push({id:`debugger-${a.id}-platform`,category:"unsupported-platform",message:`${a.name} does not support the Linux debugger recipe`});continue}let s=await Ie(o.runtimeExecutables,r.cwd,r.env);if(s!==void 0){n.push({id:`debugger-${a.id}-runtime`,category:"missing-runtime",message:`Runtime ${s} is unavailable. ${o.install}`});continue}if(!await $e(a.id,r.cwd,r.env)){n.push({id:`debugger-${a.id}-adapter`,category:"missing-adapter",message:`${a.name} is not installed. ${o.install}`});continue}await Ce(a.id,r.cwd,r.env)||n.push({id:`debugger-${a.id}-startup`,category:"adapter-startup",message:`${a.name} is installed but cannot start. ${o.install}`})}return{selections:t,actions:n}}i(Ae,"inspectDebuggerSetup");async function Te(r){let e=[...new Map([...r.detectedLanguageIds].map(L).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 ce(t.id,r.cwd,r.env);return{status:n.ok?"pass":"fail",message:`${t.name}: ${n.ok?"available":"unavailable"}`,detail:n.detail}}))}i(Te,"checkDebuggerAdapters");async function Ie(r,e,t){for(let n of r)if(!await E(n,e,t))return n}i(Ie,"firstMissingExecutable");async function $e(r,e,t){if(r==="elixir-ls-debug-adapter")try{return await $(t.PI_ELIXIR_LS_DEBUG_PATH??ue),!0}catch{return!1}if(r==="vsc-debugger")return(await y(t.PI_R_PATH??"R",["--vanilla","--quiet","-e","quit(status=if (requireNamespace('vscDebugger', quietly=TRUE)) 0 else 1)"],e,t)).ok;if(r==="vscode-js-debug")try{return await $(t.PI_JS_DEBUG_PATH??de),!0}catch{return!1}if(r.startsWith("lldb-dap"))return await E(t.PI_LLDB_DAP_PATH??"lldb-dap-18",e,t)||await E("lldb-dap",e,t);if(r==="delve")return E(t.PI_DELVE_PATH??"dlv",e,t);if(r==="kotlin-debug-adapter")return E(t.PI_KOTLIN_DEBUG_ADAPTER_PATH??"kotlin-debug-adapter",e,t);if(r==="julia-debug-adapter")try{return await $(`${t.PI_JULIA_DEBUG_PROJECT??"/opt/pi-debug-adapters/julia"}/Project.toml`),!0}catch{return!1}return r==="dart-debug-adapter"?E(t.PI_DART_PATH??"dart",e,t):(await y("python3",["-c","import importlib.util; raise SystemExit(importlib.util.find_spec('debugpy') is None)"],e,t)).ok}i($e,"adapterInstalled");async function Ce(r,e,t){return(await ce(r,e,t)).ok}i(Ce,"adapterAvailable");async function ce(r,e,t){if(r==="elixir-ls-debug-adapter")return I(t.PI_ELIXIR_LS_DEBUG_PATH??ue,e,t);if(r==="vsc-debugger")return y(t.PI_R_PATH??"R",["--vanilla","--quiet","-e","library(vscDebugger); cat(as.character(packageVersion('vscDebugger')))"],e,t);if(r==="dart-debug-adapter")return y(t.PI_DART_PATH??"dart",["--version"],e,t);if(r==="debugpy")return y("python3",["-c","import debugpy; print(debugpy.__version__)"],e,t);if(r==="delve")return y(t.PI_DELVE_PATH??"dlv",["version"],e,t);if(r==="julia-debug-adapter"){let a=t.PI_JULIA_DEBUG_PROJECT??"/opt/pi-debug-adapters/julia";return y(t.PI_JULIA_PATH??"julia",[`--project=${a}`,"--startup-file=no","-e","using DebugAdapter"],e,t)}if(r==="kotlin-debug-adapter"){let a=await y(t.PI_KOTLIN_DEBUG_ADAPTER_PATH??"kotlin-debug-adapter",["--help"],e,t);return a.ok?y("java",["-version"],e,t):a}if(r==="netcoredbg"){let a=await y(t.PI_NETCOREDBG_PATH??"netcoredbg",["--version"],e,t);return a.ok?y("dotnet",["--version"],e,t):a}if(r.startsWith("lldb-dap")){let a=t.PI_LLDB_DAP_PATH??(await E("lldb-dap-18",e,t)?"lldb-dap-18":"lldb-dap");return y(a,["--version"],e,t)}if(r==="rdbg")return y(t.PI_RUBY_DEBUG_PATH??"rdbg",["--version"],e,t);if(r==="vscode-php-debug"){let a=await y(t.PI_PHP_PATH??"php",["-r","exit(extension_loaded('xdebug') ? 0 : 1);"],e,t);return a.ok?I(t.PI_PHP_DEBUG_PATH??"/opt/pi-debug-adapters/php-debug/extension/out/phpDebug.js",e,t):a}if(r==="local-lua-debugger"){let a=await y(t.PI_LUA_PATH??"lua",["-v"],e,t);return a.ok?I(t.PI_LUA_DEBUG_PATH??"/opt/pi-debug-adapters/lua-debug/extension/extension/debugAdapter.js",e,t):a}if(r==="vscode-bash-debug"){let a=await y(t.PI_BASH_PATH??"bash",["--version"],e,t);return a.ok?I(t.PI_BASH_DEBUG_PATH??"/opt/pi-debug-adapters/bash-debug/extension/out/bashDebug.js",e,t):a}if(r==="powershell-editor-services-debug"){let a=await y(t.PI_PWSH_PATH??"pwsh",["--version"],e,t),o=t.PI_POWERSHELL_EDITOR_SERVICES_PATH??"/opt/pi-debug-adapters/powershell-editor-services";return a.ok?I(`${o}/PowerShellEditorServices/Start-EditorServices.ps1`,e,t):a}let n=t.PI_JS_DEBUG_PATH??de;try{await $(n)}catch{return{ok:!1,detail:`${n} does not exist`}}return y(process.execPath,["-e","const fs=require('node:fs'); fs.accessSync(process.argv[1]); console.log(process.version)",n],e,t)}i(ce,"probeAdapter");async function I(r,e,t){try{await $(r)}catch{return{ok:!1,detail:`${r} does not exist`}}return y(process.execPath,["-e","const fs=require('node:fs'); fs.accessSync(process.argv[1])",r],e,t)}i(I,"probeAdapterFile");import Be from"node:path";import{fileURLToPath as Le}from"node:url";function pe(r){return{id:"debug-breakpoints",present(e,t){let n=r.get(t.source),a=r.sourceFile(t.source)??qe(e.source,t.cwd);if(a===void 0)return e;let o=r.breakpointsForFile(a,n?.source);if(o.length===0)return e;let s=je(o);return{...e,lines:e.lines.map(d=>{let l=s.get(d.lineNumber);return l===void 0?d:{...d,presentation:{...d.presentation,suffix:`${d.presentation?.suffix??""}${He(l)}`,compactSuffix:`${d.presentation?.compactSuffix??""}${Fe(l)}`}}})}}}}i(pe,"createBreakpointPresenter");function je(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}i(je,"groupByLine");function qe(r,e){if(r.startsWith("file://"))return Le(r);if(!/^[a-z][a-z\d+.-]*:/iu.test(r))return Be.resolve(e,r)}i(qe,"filesystemSource");function He(r){return r.map(e=>` ${e.verified?"\u25CF":"\u25CB"} breakpoint ${e.source} (${e.verified?"verified":"pending"})`).join("")}i(He,"renderAgentBreakpoints");function Fe(r){let t=r.filter(a=>a.verified).length===r.length?"\u25CF":"\u25CB",n=r.length===1?"breakpoint":`${r.length} breakpoints`;return` ${t} ${n}`}i(Fe,"renderUserBreakpoints");import j from"node:path";import{Text as M}from"@earendil-works/pi-tui";function G(r,e,t,n){return new M(`${n.fg("toolTitle",r)} ${n.fg("muted",`\xB7 ${ye(e,t)}`)}
2
+ ${n.fg("accent","\u25C6 configure debugger")}`,0,0)}i(G,"renderDebugCall");function ge(r,e,t){return new M(`${fe(r,t)}
3
+ ${t.fg("accent",Ue(e))}`,0,0)}i(ge,"renderDebugActionCall");function C(r,e,t){return new M(Oe(r,e,t).join(`
4
+ `),0,0)}i(C,"renderDebugResult");function be(r,e){let t=[fe(r,e),me(r.status,e)];return r.stop?.frame!==void 0&&t.push(` ${e.fg("warning","\u25CF")} ${r.stop.frame.name} ${e.fg("muted",`\xB7 ${he(r.stop)}`)}`),t}i(be,"renderActiveDebugger");function Oe(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 ${he(r.stop)}`)}`));for(let o of r.stop.sourceLines){let s=o.current?t.fg("warning",">"):t.fg("dim","\u2502"),d=o.current?"text":"dim";n.push(`${s} ${String(o.lineNumber).padStart(4)} ${t.fg(d,o.content)}`)}let a=e?r.stop.variables:r.stop.variables.slice(0,6);if(a.length>0){n.push(t.fg("muted","Locals"));for(let o of a)n.push(` ${t.fg("accent",o.name.padEnd(16))} ${t.fg("toolOutput",o.value)}${o.type===void 0?"":t.fg("dim",` ${o.type}`)}`);a.length<r.stop.variables.length&&n.push(t.fg("muted",` \u2026 ${r.stop.variables.length-a.length} more`))}return n}if(n.push(me(r.status,t)),r.breakpoints.length>0){let a=r.breakpoints.filter(o=>o.verified).length;n.push(t.fg("muted",`${r.breakpoints.length} breakpoint${r.breakpoints.length===1?"":"s"} \xB7 ${a} verified`))}return n}i(Oe,"debugResultLines");function fe(r,e){return`${e.fg("toolTitle",r.options.adapter)} ${e.fg("muted",`\xB7 ${ye(r.options.program,r.options.cwd)}`)}`}i(fe,"debugIdentity");function Ue(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("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}i(Ue,"actionLabel");function me(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")}i(me,"statusLine");function he(r){let e=r.frame?.source?.path??r.frame?.source?.name??"unknown";return`${j.basename(e)}:${r.frame?.line??"?"}`}i(he,"shortFrame");function ye(r,e){let t=j.relative(e,r),n=".".repeat(2),a=t===n||t.startsWith(`${n}${j.sep}`);return t.length>0&&!a?t:j.basename(r)}i(ye,"shortPath");function J(r){if(typeof r!="object"||r===null)return;let e=r.metadata;if(typeof e!="object"||e===null)return;let t=e.semanticAction;if(typeof t!="object"||t===null)return;let n=t.snapshot;return typeof n=="object"&&n!==null?n:void 0}i(J,"debuggerSnapshotFromResult");function ve(r){return{id:"debugger",onDidChange:i(e=>r.onDidChange(e),"onDidChange"),list:i(()=>r.list().map(e=>r.snapshot(e)).filter(e=>e.status==="configured"||e.status==="running"||e.status==="stopped").map(e=>({source:e.source,kind:"debugger",title:e.options.adapter,description:e.options.program,status:e.status==="configured"?"configured":e.status==="stopped"?"paused":"running",renderSummary:i(t=>be(e,t),"renderSummary"),renderDetail:i(t=>C(e,!0,t),"renderDetail"),stop:i(()=>r.delete(e.source),"stop")})),"list")}}i(ve,"debuggerProcessProvider");import{spawn as B}from"node:child_process";import{randomBytes as De}from"node:crypto";import{rmSync as Ge}from"node:fs";import{mkdtemp as Je,readFile as Ee,rm as Ve}from"node:fs/promises";import xe from"node:net";import{tmpdir as We}from"node:os";import m from"node:path";import{spawn as Ne}from"node:child_process";import Me from"node:net";var P=class r{static{i(this,"DapClient")}#a;#u;#l;#o=new Map;#b=[];#i=new Set;#f=new Set;#r=Buffer.alloc(0);#p=1;#s;#g;#n;constructor(e,t,n){this.#a=e,this.#u=t,this.#l=n,e.on("data",a=>this.#t(a)),e.once("error",a=>this.#c(a)),e.once("close",()=>this.#c(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.#c(a)),n.once("exit",(a,o)=>{this.#c(new Error(`Debug adapter exited${a===null?"":` with code ${a}`}${o===null?"":` (${o})`}`))}))}static start(e,t,n){let a=Ne(e,[...t],{cwd:n,env:process.env,stdio:["pipe","pipe","pipe"]});return new r(a.stdout,a.stdin,a)}static fromSocket(e,t=1){let n=new r(e,e);return n.#p=t,n}static connect(e,t="127.0.0.1"){return new Promise((n,a)=>{let o=Me.createConnection({port:e,host:t}),s=i(d=>a(d),"fail");o.once("error",s),o.once("connect",()=>{o.off("error",s),n(new r(o,o))})})}onReverseRequest(e){this.#g=e}onEvent(e){return this.#f.add(e),()=>this.#f.delete(e)}request(e,t,n={}){if(this.#s!==void 0)return Promise.reject(this.#s);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.#n=void 0);let a=this.#p++,o={seq:a,type:"request",command:e,...t===void 0?{}:{arguments:t}},s=new Promise((d,l)=>{let u,c=i(()=>{u!==void 0&&clearTimeout(u),n.signal?.removeEventListener("abort",b)},"cleanup"),b=i(()=>{this.#o.delete(a),c(),l(n.signal?.reason instanceof Error?n.signal.reason:new Error("Debug operation aborted"))},"abort");n.timeoutMs!==void 0&&(u=setTimeout(()=>{this.#o.delete(a),c(),l(new Error(`Timed out waiting for debug response ${e}`))},n.timeoutMs)),this.#o.set(a,{resolve:i(p=>d(p),"resolve"),reject:l,cleanup:c}),n.signal?.addEventListener("abort",b,{once:!0})});return this.#d(o),s}waitForEvent(e,t=3e4){return this.waitForAnyEvent([e],t)}waitForAnyEvent(e,t=3e4,n){let a=new Set(e),o=this.#b.findIndex(s=>a.has(s.event));return o>=0?Promise.resolve(this.#b.splice(o,1)[0]):this.#s!==void 0?Promise.reject(this.#s):new Promise((s,d)=>{let l={events:a,resolve:i(c=>{clearTimeout(l.timer),this.#i.delete(l),s(c)},"resolve"),reject:i(c=>{clearTimeout(l.timer),this.#i.delete(l),d(c)},"reject"),timer:setTimeout(()=>{this.#i.delete(l),d(new Error(`Timed out waiting for debug event ${e.join(" or ")}`))},t)};this.#i.add(l);let u=i(()=>l.reject(n?.reason instanceof Error?n.reason:new Error("Debug operation aborted")),"abort");n?.aborted===!0?u():n?.addEventListener("abort",u,{once:!0})})}close(){this.#a.destroy(),this.#u.destroy(),this.#l!==void 0&&!this.#l.killed&&this.#l.kill(),this.#c(new Error("Debug adapter closed"))}#d(e){let t=Buffer.from(JSON.stringify(e),"utf8");this.#u.write(Buffer.concat([Buffer.from(`Content-Length: ${t.length}\r
5
+ \r
6
+ `),t]))}#t(e){for(this.#r=Buffer.concat([this.#r,e]);;){let t=this.#r.indexOf(`\r
7
+ \r
8
+ `);if(t<0)return;let n=this.#r.subarray(0,t).toString("ascii"),a=/^Content-Length:\s*(\d+)$/imu.exec(n);if(a===null){this.#c(new Error("Debug adapter sent a frame without Content-Length"));return}let o=Number(a[1]),s=t+4;if(this.#r.length<s+o)return;let d=this.#r.subarray(s,s+o).toString("utf8");this.#r=this.#r.subarray(s+o);try{this.#m(JSON.parse(d))}catch(l){this.#c(l instanceof Error?l:new Error(String(l)));return}}}#m(e){if(e.type==="event")if(e.event==="stopped"){let t=JSON.stringify(e.body??null);if(t===this.#n)return;this.#n=t}else e.event==="continued"&&(this.#n=void 0);if(e.type==="response"){let t=this.#o.get(e.request_seq);if(t===void 0)return;this.#o.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.#f)n(e);let t=[...this.#i].find(n=>n.events.has(e.event));t===void 0?this.#b.push(e):t.resolve(e);return}this.#e(e)}async#e(e){try{if(this.#g===void 0)throw new Error(`Client does not support reverse request ${e.command}`);let t=await this.#g(e);this.#d({seq:this.#p++,type:"response",request_seq:e.seq,success:!0,command:e.command,...t===void 0?{}:{body:t}})}catch(t){this.#d({seq:this.#p++,type:"response",request_seq:e.seq,success:!1,command:e.command,message:t instanceof Error?t.message:String(t)})}}#c(e){if(this.#s===void 0){this.#s=e;for(let t of this.#o.values())t.cleanup(),t.reject(e);this.#o.clear();for(let t of this.#i)t.reject(e);this.#i.clear()}}};var H=class{static{i(this,"DebugSessionManager")}#a=new Map;#u=new Set;create(e){let t=De(6).toString("hex"),n={id:t,source:`debug:${t}`,options:{...e,sourceFile:e.sourceFile??e.program},breakpoints:new Map,status:"configured",stopGeneration:0};return this.#a.set(t,n),this.#e(n),n}get(e){let t=/^debug:([a-f\d]{12})(?:\/|$)/u.exec(e);return t===null?void 0:this.#a.get(t[1])}list(){return[...this.#a.values()]}snapshot(e){return{id:e.id,source:e.source,options:e.options,status:e.status,breakpoints:[...e.breakpoints.values()].map(t=>({...t})),...e.stop===void 0?{}:{stop:e.stop}}}onDidChange(e){return this.#u.add(e),()=>this.#u.delete(e)}breakpointsForFile(e,t){let n=m.resolve(e);return this.list().filter(a=>t===void 0||a.source===t).flatMap(a=>[...a.breakpoints.values()]).filter(a=>m.resolve(a.file)===n)}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`}readSource(e){let t=this.sourceFile(e);return t===void 0?Promise.reject(new Error(`Unknown debug source ${e}`)):Ee(t,"utf8")}async addBreakpoint(e,t,n){let a=this.get(e),o=this.sourceFile(e);if(a===void 0||o===void 0)throw new Error(`Unknown debug source ${e}`);if(a.status==="terminated")throw new Error("Cannot add a breakpoint to a terminated session");let s=De(5).toString("hex"),d={id:s,source:`${a.source}/breakpoint/${s}`,file:o,line:t,verified:!1};return a.breakpoints.set(s,d),a.client!==void 0&&await this.#d(a,a.client,o,n),this.#e(a),d}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 this.#l(e,t,2)}async#l(e,t,n){if(e.status!=="configured")throw new Error(`Session is already ${e.status}`);e.options.adapter==="powershell"&&(e.adapterTemporaryDirectory=await Je(m.join(We(),"pi-powershell-debug-")));let a=Qe(e.options,e.adapterTemporaryDirectory),o=e.options.adapter==="node"?await this.#s(e):e.options.adapter==="delve"?await this.#b(e):e.options.adapter==="ruby"?await this.#o(e):e.options.adapter==="julia"?await this.#i(e):e.options.adapter==="r"?await this.#f(e):P.start(a.command,a.args,e.options.cwd);e.client=o,e.controlClient=o,e.clients=[o],e.options.adapter==="node"&&(e.targetReady=new Promise(s=>{e.resolveTargetReady=s})),e.status="running",this.#e(e);try{e.options.adapter!=="r"&&await we(o,a.adapterID,t);let s=o.waitForAnyEvent(["initialized"],3e4,t),d=o.request(a.request,a.launch,{signal:t});await s,await this.#n(e,o,t);let l=o.request("configurationDone",void 0,{signal:t});if(e.options.adapter==="java"||e.options.adapter==="kotlin"?l.catch(()=>{}):await l,await d,e.options.adapter==="r"&&(e.rStarted=!0),e.targetReady!==void 0&&await e.targetReady,await this.#t(e,t),this.snapshot(e).status==="terminated"&&n>0&&(e.options.adapter==="dart"||e.options.adapter==="kotlin")&&e.breakpoints.size>0){for(let u of e.clients??[o])u.close();e.adapterProcess?.kill(),await V(e),e.client=void 0,e.controlClient=void 0,e.clients=void 0,e.adapterProcess=void 0,e.status="configured";for(let u of e.breakpoints.values())u.verified=!1;return this.#e(e),await this.#l(e,t,n-1)}return e}catch(s){for(let d of e.clients??[o])d.close();throw e.adapterProcess?.kill(),await V(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.#e(e),s}}async command(e,t,n){if(e.status!=="stopped"||e.stop===void 0)throw new Error(`Cannot ${t} while session is ${e.status}`);let a=x(e),o=e.stop.threadId;return await a.request(t,{threadId:o},{signal:n}),e.stop=void 0,e.status="running",this.#e(e),await this.#t(e,n),e}async delete(e,t){let n=this.get(e);if(n===void 0)throw new Error(`Unknown debug session ${e}`);let a=/\/breakpoint\/([a-f\d]{10})$/u.exec(e);if(a!==null){let o=n.breakpoints.get(a[1]);if(o===void 0)throw new Error(`Unknown debug breakpoint ${e}`);n.breakpoints.delete(o.id),n.client!==void 0&&n.status!=="terminated"&&await this.#d(n,n.client,o.file,t),this.#e(n);return}if(e!==n.source)throw new Error(`Cannot delete debug resource ${e}`);if(n.client!==void 0){(n.controlClient??n.client).request("disconnect",{terminateDebuggee:!0},{signal:t,timeoutMs:500}).catch(()=>{});for(let o of n.clients??[n.client])o.close();n.adapterProcess?.kill()}await V(n),n.status="terminated",this.#e(n),this.#a.delete(n.id)}dispose(){for(let e of this.#a.values()){for(let t of e.clients??(e.client===void 0?[]:[e.client]))t.close();e.adapterProcess?.kill(),e.adapterTemporaryDirectory!==void 0&&Ge(e.adapterTemporaryDirectory,{recursive:!0,force:!0})}this.#a.clear()}async#o(e){let t=await q(),n=process.env.PI_RUBY_DEBUG_PATH??"rdbg";return e.adapterProcess=B(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"]}),await Se(e.adapterProcess,"Debugger can attach via TCP/IP","rdbg"),P.connect(t)}async#b(e){let t=await q(),n=process.env.PI_DELVE_PATH??"dlv";return e.adapterProcess=B(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 Se(e.adapterProcess,"DAP server listening","Delve"),P.connect(t)}async#i(e){let t=await q(),n=process.env.PI_JULIA_PATH??"julia",a=process.env.PI_JULIA_DEBUG_PROJECT??"/opt/pi-debug-adapters/julia",o='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=B(n,["--startup-file=no","--history-file=no",`--project=${a}`,"-e",o,String(t)],{cwd:e.options.cwd,env:process.env,stdio:["ignore","pipe","pipe"]}),Pe(e.adapterProcess,`DebugAdapter.jl:${String(t)}`),await new Promise(s=>setTimeout(s,25)),ke(t,"DebugAdapter.jl")}async#f(e){let t=xe.createServer();await new Promise((d,l)=>{t.once("error",l),t.listen(0,"127.0.0.1",()=>d())});let n=t.address();if(n===null||typeof n=="string")throw t.close(),new Error("Could not start the vscDebugger DAP listener");let a=new Promise((d,l)=>{t.once("connection",u=>{t.close();let c=P.fromSocket(u,2);c.onEvent(b=>this.#r(e,b)),d(c)}),t.once("error",l)}),o=process.env.PI_R_PATH??"R";e.rPromptInputs=[],e.rAtBrowserPrompt=!1,e.rStarted=!1,e.adapterProcess=B(o,["--vanilla","--quiet"],{cwd:e.options.cwd,env:process.env,stdio:["pipe","pipe","pipe"]}),Pe(e.adapterProcess,`vscDebugger:${String(n.port)}`),this.#p(e);let s=Xe({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(s)})
9
+ `),Ze(a,e.adapterProcess,t)}#r(e,t){if(process.env.PI_DEBUG_DAP_TRACE==="1"&&process.stderr.write(`[vscDebugger:event] ${JSON.stringify(t)}
10
+ `),t.event!=="custom")return;let n=_(t.body),a=typeof n.reason=="string"?n.reason:"",o=typeof n.text=="string"?n.text:"";if(!(a!=="writeToStdin"||o.length===0)){if(n.when==="browserPrompt"&&e.rAtBrowserPrompt===!0){e.rAtBrowserPrompt=!1,e.adapterProcess?.stdin?.write(`${o}
11
+ `);return}e.rPromptInputs?.push(o)}}#p(e){let t="";e.adapterProcess?.stdout?.on("data",n=>{for(t+=n.toString("utf8");;){let a=/Browse\[\d+\]> /u.exec(t),o=/(?:^|\r?\n)__PI_R_PROMPT__(?:\r?\n|$)/u.exec(t),s=a?.index??Number.POSITIVE_INFINITY,d=o?.index??Number.POSITIVE_INFINITY;if(!Number.isFinite(s)&&!Number.isFinite(d)){t=t.slice(-128);return}if(s<d){t=t.slice(s+(a?.[0].length??0));let l=e.rPromptInputs?.shift();l===void 0?(e.rAtBrowserPrompt=!0,setTimeout(()=>{e.rAtBrowserPrompt===!0&&(e.rAtBrowserPrompt=!1,e.adapterProcess?.stdin?.write(`vscDebugger::.vsc.listenForDAP(timeout=-1)
12
+ `))},100)):e.adapterProcess?.stdin?.write(`${l}
13
+ `)}else t=t.slice(d+(o?.[0].length??0)),e.adapterProcess?.stdin?.write(`vscDebugger::.vsc.listenForDAP(timeout=-1)
14
+ `),e.rStarted===!0&&e.client?.request("custom",{reason:"showingPrompt",which:"topLevel"}).catch(()=>{})}})}async#s(e){let t=await q(),n=process.env.PI_JS_DEBUG_PATH??"/opt/pi-debug-adapters/js-debug/src/dapDebugServer.js";e.adapterProcess=B(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 Ye(e.adapterProcess);let a=await ke(t);return a.onReverseRequest(this.#g(e,t)),a}#g(e,t){return async n=>{if(n.command!=="startDebugging")throw new Error(`Client does not support reverse request ${n.command}`);let a=_(n.arguments),o=_(a.configuration),s=await P.connect(t);e.clients?.push(s),s.onReverseRequest(this.#g(e,t)),await we(s,"pwa-node");let d=s.waitForEvent("initialized"),l=s.request(typeof a.request=="string"?a.request:"launch",{...o,sourceMaps:!0,pauseForSourceMap:!0,outFiles:[m.join(m.dirname(e.options.program),"**","*.js")]});return await d,e.client=s,await this.#n(e,s),await s.request("configurationDone"),await l,e.resolveTargetReady?.(),{}}}async#n(e,t,n){let a=new Set([...e.breakpoints.values()].map(o=>o.file));for(let o of a)await this.#d(e,t,o,n)}async#d(e,t,n,a){let o=[...e.breakpoints.values()].filter(d=>d.file===n),s=await t.request("setBreakpoints",{source:{path:n,name:m.basename(n)},breakpoints:o.map(({line:d})=>({line:d})),sourceModified:!1},{signal:a});for(let[d,l]of o.entries())l.verified=s.breakpoints?.[d]?.verified===!0}async#t(e,t){let n=await x(e).waitForAnyEvent(["stopped","terminated","exited","loadedSource","breakpoint","custom"],3e4,t),a=_(n.body);if(n.event==="custom"&&e.options.adapter==="r"){await this.#t(e,t);return}if(n.event==="loadedSource"){let o=_(a.source),s=typeof o.path=="string"?m.resolve(o.path):void 0,d=s===void 0?void 0:[...e.breakpoints.values()].find(l=>m.resolve(l.file)===s)?.file;d!==void 0&&await this.#d(e,x(e),d,t),await this.#t(e,t);return}if(n.event==="breakpoint"){let o=_(a.breakpoint),s=_(o.source);for(let d of e.breakpoints.values())o.verified===!0&&typeof o.line=="number"&&o.line===d.line&&typeof s.path=="string"&&m.resolve(s.path)===m.resolve(d.file)&&(d.verified=!0);await this.#t(e,t);return}if(a.reason==="exit"){e.status="terminated",e.stop=void 0,this.#e(e);return}if(e.options.adapter==="node"&&a.reason==="entry"){await this.#n(e,x(e),t);let o=typeof a.threadId=="number"?a.threadId:1;await x(e).request("continue",{threadId:o},{signal:t}),await this.#t(e,t);return}if((e.options.adapter==="dart"||e.options.adapter==="kotlin")&&a.reason==="entry"){let o=x(e);if(await this.#n(e,o,t),e.options.adapter==="kotlin"){let d=Date.now()+5e3;for(;[...e.breakpoints.values()].some(l=>!l.verified)&&Date.now()<d;)await new Promise(l=>setTimeout(l,50)),await this.#n(e,o,t)}let s=typeof a.threadId=="number"?a.threadId:1;await o.request("continue",{threadId:s},{signal:t}),await this.#t(e,t);return}if(n.event!=="stopped"){e.status="terminated",e.stop=void 0,this.#e(e);return}if(await this.#m(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.#t(e,t);return}if(e.options.adapter==="shell"&&e.stop?.frame!==void 0&&![...e.breakpoints.values()].some(o=>m.resolve(o.file)===m.resolve(e.stop?.frame?.source?.path??"")&&o.line===e.stop?.frame?.line)){let o=e.stop.threadId;e.stopGeneration--,e.stop=void 0,e.status="running",await x(e).request("continue",{threadId:o},{signal:t}),await this.#t(e,t);return}e.options.adapter==="shell"&&this.#e(e)}async#m(e,t,n=!0){let a=x(e),o=_(t.body),s=(await a.request("threads")).threads?.[0]?.id,d=typeof o.threadId=="number"?o.threadId:s;if(d===void 0)throw new Error("Debugger stopped without a thread");let l=(await Ke(a,d,e.options.adapter==="dart")).stackFrames?.[0];if(l?.source?.path!==void 0)for(let c of e.breakpoints.values())m.resolve(c.file)===m.resolve(l.source.path)&&c.line===l.line&&(c.verified=!0);let u=[];if(l!==void 0){let c=(await a.request("scopes",{frameId:l.id})).scopes??[],b=e.options.adapter==="r"?c:c.filter(p=>[p.name.toLowerCase(),p.presentationHint?.toLowerCase()].some(g=>g?.includes("local")===!0||g==="variables"));for(let p of b){let g=await a.request("variables",{variablesReference:p.variablesReference,start:0,count:100});u.push(...g.variables??[])}}e.stopGeneration++,e.stop={generation:e.stopGeneration,reason:typeof o.reason=="string"?o.reason:"stopped",threadId:d,...l===void 0?{}:{frame:l},variables:u,sourceLines:l===void 0?[]:await ze(l)},e.status="stopped",n&&this.#e(e)}#e(e){let t=this.snapshot(e);for(let n of this.#u)n(t)}};async function ze(r){let e=r.source?.path;if(e===void 0)return[];try{let t=(await Ee(e,"utf8")).split(/\r?\n/u),n=Math.max(1,r.line-2),a=Math.min(t.length,r.line+2);return t.slice(n-1,a).map((o,s)=>({lineNumber:n+s,content:o,current:n+s===r.line}))}catch{return[]}}i(ze,"sourceWindow");async function Ke(r,e,t){let n=Date.now()+1e3,a;do{try{let o=await r.request("stackTrace",{threadId:e});if(!t||(o.stackFrames?.length??0)>0)return o;a=new Error("Debugger stack is not ready")}catch(o){if(a=o,!t)throw o}await new Promise(o=>setTimeout(o,25))}while(Date.now()<n);throw a instanceof Error?a:new Error("Could not read debugger stack")}i(Ke,"requestStackTrace");function F(r){let e=[`Session: ${r.source}`,`Adapter: ${r.options.adapter}`,`Program: ${m.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} ${m.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(`
15
+ `)}i(F,"renderDebugSession");function x(r){if(r.client===void 0)throw new Error("Debug adapter is not running");return r.client}i(x,"requiredClient");function _(r){return typeof r=="object"&&r!==null?r:{}}i(_,"asRecord");function Xe(r){let e=JSON.stringify(r);return`Content-Length: ${Buffer.byteLength(e,"utf8")}\r
16
+ \r
17
+ ${e}`}i(Xe,"dapFrame");function we(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})}i(we,"initializeClient");function q(){return new Promise((r,e)=>{let t=xe.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(a=>a===void 0?r(n.port):e(a))})})}i(q,"availablePort");function Pe(r,e){if(process.env.PI_DEBUG_DAP_TRACE==="1"){process.stderr.write(`[${e}] pid=${String(r.pid)}
18
+ `),r.once("exit",(t,n)=>process.stderr.write(`[${e}] exit code=${String(t)} signal=${String(n)}
19
+ `));for(let t of[r.stdout,r.stderr])t?.on("data",n=>process.stderr.write(`[${e}] ${n.toString("utf8")}`))}}i(Pe,"traceAdapterProcess");function Ze(r,e,t){return new Promise((n,a)=>{let o=setTimeout(()=>d(new Error("Timed out starting vscDebugger")),5e3),s=i(()=>{clearTimeout(o),e.off("error",d),e.off("exit",l)},"cleanup"),d=i(u=>{s(),t.close(),e.killed||e.kill(),a(u)},"fail"),l=i(u=>d(new Error(`vscDebugger exited with code ${String(u)} before connecting`)),"onExit");e.once("error",d),e.once("exit",l),r.then(u=>{s(),n(u)},d)})}i(Ze,"waitForRAdapterConnection");function Se(r,e,t){return new Promise((n,a)=>{let o=[r.stdout,r.stderr].filter(u=>u!==null),s=setTimeout(()=>a(new Error(`Timed out starting ${t} server`)),5e3),d=i(()=>{clearTimeout(s);for(let u of o)u.off("data",l)},"cleanup"),l=i(u=>{u.toString("utf8").includes(e)&&(d(),n())},"onData");for(let u of o)u.on("data",l);r.once("error",u=>{d(),a(u)}),r.once("exit",u=>{d(),a(new Error(`${t} server exited with code ${String(u)}`))})})}i(Se,"waitForAdapterReady");function Ye(r){return new Promise((e,t)=>{let n=r.stdout;if(n===null){t(new Error("js-debug server stdout is unavailable"));return}let a=setTimeout(()=>t(new Error("Timed out starting js-debug server")),5e3),o=i(s=>{s.toString("utf8").includes("Debug server listening")&&(clearTimeout(a),n.off("data",o),e())},"onData");n.on("data",o),r.once("error",t),r.once("exit",s=>t(new Error(`js-debug server exited with code ${s}`)))})}i(Ye,"waitForJsDebugReady");async function ke(r,e="js-debug"){let t;for(let n=0;n<100;n++)try{return await P.connect(r)}catch(a){t=a,await new Promise(o=>setTimeout(o,25))}throw t instanceof Error?t:new Error(`Could not connect to ${e}`)}i(ke,"connectWithRetry");async function V(r){r.adapterTemporaryDirectory!==void 0&&(await Ve(r.adapterTemporaryDirectory,{recursive:!0,force:!0}),r.adapterTemporaryDirectory=void 0)}i(V,"removeAdapterTemporaryDirectory");function Qe(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")return{command:"python3",args:["-m","debugpy.adapter"],adapterID:"debugpy",request:"launch",launch:{...t,type:"python",console:"internalConsole",justMyCode:!1}};if(r.adapter==="java"||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??"/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:process.env.PI_LLDB_DAP_PATH??"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:m.dirname(m.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??m.join(n,"out/bashDebug.js")],adapterID:"bashdb",request:"launch",launch:{...t,type:"bashdb",pathBash:process.env.PI_BASH_PATH??"/usr/bin/bash",pathBashdb:m.join(n,"bashdb_dir/bashdb"),pathBashdbLib:m.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",`& '${m.join(n,"PowerShellEditorServices/Start-EditorServices.ps1").replaceAll("'","''")}' -LogPath '${m.join(e,"logs").replaceAll("'","''")}' -LogLevel Warning -SessionDetailsPath '${m.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:[m.join(m.dirname(r.program),"**","*.js")]}}}i(Qe,"adapterRecipe");var nt=D.Object({adapter:tt(["dart","debugpy","delve","java","elixir","julia","kotlin","lldb-dap","lua","netcoredbg","node","php","powershell","r","ruby","shell"],{description:"Select an installed 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."}),program:D.String({minLength:1,description:"Source file or executable to launch. Relative paths resolve from cwd."}),source:D.Optional(D.String({description:"Source file used for anchored breakpoints. Defaults to program."})),args:D.Optional(D.Array(D.String(),{description:"Arguments passed to the debugged program."})),mainClass:D.Optional(D.String({minLength:1,description:"Fully qualified JVM main class. Required by Java and Kotlin adapters."})),cwd:D.Optional(D.String({description:"Working directory. Relative paths resolve from the workspace."}))},{additionalProperties:!1});async function at(r){let e=oe("debugger")??new H,t=new Map,n=_e(e,"debugger-source"),a=_e(e,"debugger-input"),o=ne(r).add(ve(e)),s=pe(e),d={protocol:X,apiVersion:Z,id:"debugger",setup(u){u.addResolver({resolver:n,matchesCall:i(c=>e.sourceFile(c)!==void 0,"matchesCall"),renderCall(c,b,p){let g=A(c)?c:{},f=typeof g.path=="string"?g.path:"",h=e.get(f),v=e.sourceFile(f);if(h===void 0||v===void 0)throw new Error("Debugger source header lost its session");let w=S.relative(h.options.cwd,v),k=Array.isArray(g.views)?g.views.filter(U=>typeof U=="string"):[],R=typeof g.offset=="number"?g.offset:1,T=typeof g.limit=="number"?g.limit:void 0,O=T===void 0?String(R):`${R}-${R+T-1}`;return Q(p.lastComponent,{tool:"debug file",primary:{text:`${w}:${O}`,color:"accent",underline:!0},qualifiers:k.length===0?[]:[{text:`views ${k.join(",")}`}],details:[{label:"source",value:f},{label:"file",value:v},...k.length===0?[]:[{label:"views",value:k.join(",")}]],expanded:p.expanded},b)}}),u.addView({view:"breakpoints",presenter:s}),u.describe('views: ["breakpoints"] \u2014 show current debugger breakpoints beside source lines. On a normal file, all current sessions are included; on a debug source, results are session-scoped. debug:<session> \u2014 debugger state. Read the returned debug source before selecting a breakpoint line.'),u.addPromptGuideline('Use views: ["breakpoints"] when current breakpoint locations matter. Create a debug session with debug. Set adapter to elixir for Elixir or r for R. Read the returned debug source to get current anchors, insert text "breakpoint" at one source anchor, then insert "start" on the session. Use read for the latest stop and delete for a breakpoint or the session.')}},l={protocol:ee,apiVersion:te,id:"debugger",setup(u){u.addResolver({resolver:a}),u.tool("insert").addSemanticHandler({matches:i(c=>ot(c,e),"matches"),execute:i(async(c,b)=>{let p=b,g=Re(e,p.path);if(e.sourceFile(p.path)!==void 0){if(p.text!=="breakpoint"||p.anchor===void 0)throw new Error('A debug source accepts text "breakpoint" with one anchor');let f=await c.resolveAnchor("anchor"),h=await e.addBreakpoint(p.path,f.lineNumber,c.signal);return{source:h.source,summary:`Breakpoint ${h.source} created at ${S.relative(g.options.cwd,h.file)}:${h.line}.`,data:{kind:"debug-breakpoint",session:g.source,file:h.file,line:h.line,verified:h.verified,snapshot:e.snapshot(g)}}}if(p.path!==g.source||p.anchor!==void 0)throw new Error("Debug commands target the session resource without an anchor");return await st(e,g,p.text,c.signal),{source:g.source,summary:F(g),data:ut(e,g,p.text)}},"execute")}),u.tool("delete").addSemanticHandler({matches:i(c=>it(c,e),"matches"),execute:i(async(c,b)=>{let p=b.path,g=Re(e,p),f=e.snapshot(g);t.set(p,f);let h=p.includes("/breakpoint/");await e.delete(p,c.signal);let v=h?e.snapshot(g):{...f,status:"terminated"};return{source:p,summary:`Deleted ${p}.`,data:{kind:h?"debug-breakpoint":"debug-session",deleted:!0,snapshot:v}}},"execute")}),u.describe('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, or step out. Delete removes a breakpoint or terminates the session.');for(let c of["insert","delete"])u.addToolRenderer({tool:c,matches(b,p){return p==="call"?A(b)&&typeof b.path=="string"&&(e.get(b.path)!==void 0||t.has(b.path)):J(A(b)&&"details"in b?b.details:b)!==void 0},renderCall(b,p,g){let f=b,h=f.path===void 0?void 0:e.get(f.path),v=f.path===void 0?void 0:t.get(f.path),w=g.state;h!==void 0?w.snapshot=e.snapshot(h):v!==void 0&&(w.snapshot=v);let k=w.snapshot;if(k===void 0)throw new Error("Debugger renderer lost its session");let R=f.path===void 0?void 0:e.breakpoint(f.path)??k.breakpoints.find(U=>U.source===f.path),T=f.path===void 0?void 0:e.sourceFile(f.path),O=c==="delete"?R===void 0?"delete-session":`delete-breakpoint ${S.basename(R.file)}:${R.line}`:f.text==="breakpoint"&&T!==void 0?`breakpoint ${S.basename(T)}:${ct(f)}`:f.text??"debug action";return ge(k,O,p)},renderResult(b,p,g){let f=J(b.details);if(f===void 0)throw new Error("Debugger result is missing its session");return C(f,p.expanded,g)}})}};await Promise.all([K(r,le),Y(r,d)]),await re(r,l),r.registerTool(rt({name:"debug",label:"Debug session",promptSnippet:"Create a local DAP debug session before setting anchored breakpoints",promptGuidelines:["Use the returned debug source resource rather than the filesystem path when setting breakpoints; its anchors are checked against fresh text without editing that text.","Use java for Java, kotlin for Kotlin, lldb-dap for C, C++, Rust, Swift, or Zig, and julia for Julia.","Use lldb-dap for C, C++, Rust, Swift, or Zig; use julia for Julia.","Use elixir for Elixir; use r for R."],description:"Use debug to create a configured local debugger session. This does not launch the program yet. Sessions survive extension reloads and keep the same debug: resources. Read the returned debug source, set breakpoints with insert, then start and control execution by inserting commands on the session resource.",parameters:nt,async execute(u,c,b,p,g){let f=S.resolve(g.cwd,c.cwd??"."),h=S.resolve(f,c.program);try{await et(h);let v=e.create({adapter:c.adapter,program:h,sourceFile:S.resolve(f,c.source??c.program),args:c.args??[],cwd:f,...c.mainClass===void 0?{}:{mainClass:c.mainClass}}),w=dt(e,v);return{content:[{type:"text",text:`${F(v)}
20
+ Source: ${w.sourceResource}
21
+ Breakpoints: ${w.breakpointsResource}
22
+
23
+ Next: read ${w.sourceResource} with views ["anchors"], then insert a breakpoint at an anchor.`}],details:w}}catch(v){return{content:[{type:"text",text:v instanceof Error?v.message:String(v)}],details:{adapter:c.adapter,program:h,cwd:f,status:"failed"},isError:!0}}},renderCall(u,c){let b=S.resolve(process.cwd(),typeof u.cwd=="string"?u.cwd:"."),p=S.resolve(b,typeof u.program=="string"?u.program:"program");return G(typeof u.adapter=="string"?u.adapter:"debugger",p,b,c)},renderResult(u,c,b){let p=A(u.details)?u.details.snapshot:void 0;if(typeof p=="object"&&p!==null)return C(p,c.expanded,b);let g=u.details;return G(g.adapter,g.program,g.cwd,b)}})),r.on("session_shutdown",u=>{if(o(),u.reason==="reload"){ae("debugger",e);return}ie("debugger",e),e.dispose()})}i(at,"registerDebugger");function _e(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(){let a=r.sourceFile(t);if(a!==void 0)return[pt(a,await r.readSource(t))];if(t===`${n.source}/breakpoints`)return[{type:"text",text:lt(n)}];let o=r.breakpoint(t);if(t!==n.source&&o===void 0)throw new Error(`Unknown debug resource ${t}`);return[{type:"text",text:o===void 0?F(n):`Breakpoint: ${o.source}
24
+ File: ${o.file}
25
+ Line: ${o.line}
26
+ Status: ${o.verified?"verified":"pending"}`}]}}})}}}i(_e,"createDebugResourceResolver");function ot(r,e){if(!A(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)}i(ot,"matchesDebugInsert");function it(r,e){if(!A(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/`))}i(it,"matchesDebugDelete");async function st(r,e,t,n){switch(t.trim().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)}`)}}i(st,"executeSessionCommand");function dt(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:a,verified:o})=>({source:t,file:n,line:a,verified:o})),...e.stop===void 0?{}:{stop:e.stop},snapshot:r.snapshot(e)}}i(dt,"debugDetails");function ut(r,e,t){return{kind:"debug-command",command:t,status:e.status,breakpoints:[...e.breakpoints.values()].map(({source:n,file:a,line:o,verified:s})=>({source:n,file:a,line:o,verified:s})),...e.stop===void 0?{}:{stop:e.stop},snapshot:r.snapshot(e)}}i(ut,"debugActionData");function lt(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}`).join(`
27
+ `)}i(lt,"renderBreakpointList");function Re(r,e){let t=r.get(e);if(t===void 0)throw new Error(`Unknown debug session ${e}`);return t}i(Re,"requiredSession");function ct(r){let e=A(r)&&typeof r.anchor=="string"?r.anchor:void 0;return/^(\d+)#/u.exec(e??"")?.[1]??e??"selected line"}i(ct,"breakpointLine");function A(r){return typeof r=="object"&&r!==null}i(A,"isRecord");function pt(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}]))}}i(pt,"debugSourceContent");export{at as default};
package/dist/entry-10.js CHANGED
@@ -1 +1 @@
1
- import{a as b,b as c,c as d,d as g,e as h,f as i,g as j}from"./chunk-5MSNYFDE.js";import"./chunk-NNCZYO4Q.js";import{d as a}from"./chunk-3SE372WC.js";import"./chunk-YHUTTZC6.js";import{a as x}from"./chunk-72EEL2DW.js";import{a as o,b as r,c as e,d as f,e as m,f as p,g as t}from"./chunk-KAB3AYA2.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{r as READ_API_VERSION,e as READ_CORE_READY_EVENT,f as READ_PLUGIN_REGISTER_EVENT,o as READ_PROTOCOL,x as connectReadPlugin,a as createReadResultRenderer,i as isFragmentResolverRegistration,m as isReadCoreReady,j as isReadFragmentResolution,g as isReadHandlerRegistration,p as isReadPlugin,t as isReadPluginRegistrationRequest,h as isReadViewRegistration,d as isResourceResolverRegistration,c as isTextTargetResolverRegistration,b as readParameters};
1
+ import"./chunk-U2JKHKLK.js";import"./chunk-J4RTW44E.js";import"./chunk-NNCZYO4Q.js";import"./chunk-526E364R.js";import"./chunk-YHUTTZC6.js";import{a as g}from"./chunk-6CZO43OH.js";import{a as f,b as y}from"./chunk-OBNING2A.js";import"./chunk-IQD6PON5.js";import"./chunk-WGGIQ7IJ.js";import{a as l}from"./chunk-L7JMDDSD.js";import{a as s,b as c}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";function x(n,e){return u(e),g(n,{protocol:f,apiVersion:y,id:`hook/before-read/${e.id}`,setup(t){t.addResourceGuard({id:e.id,async guard(o){let r=await e.run(o);return r.decision==="allow"?{kind:"accepted"}:{kind:"rejected",reason:r.reason}}})}})}d(x,"connectBeforeReadHook");function A(n,e){return u(e),l(n,{protocol:s,apiVersion:c,id:`hook/before-edit/${e.id}`,setup(t){t.addMutationGuard({id:e.id,async guard(o,r){let a=await e.run({cwd:r.cwd,intent:r.intent??"edit",resources:o.resources.map(i=>({resourceSource:i.source,existed:i.existed,before:i.before,after:i.after,changes:i.changes})),...r.signal!==void 0&&{signal:r.signal}});return a.decision==="allow"?{kind:"accepted"}:{kind:"rejected",rejection:{code:"MUTATION_REJECTED",reason:a.reason,message:`Edit blocked by hook ${e.id}: ${a.reason}`,effect:"not-applied"}}}})}})}d(A,"connectBeforeEditHook");function m(n,e){return u(e),l(n,{protocol:s,apiVersion:c,id:`hook/after-edit/${e.id}`,setup(t){t.onDidEdit(async o=>{if(o.postProcessing!=="deferred")try{return await e.run(o)}catch(r){return{feedback:`After-edit hook ${e.id} failed after the edit was saved: ${r instanceof Error?r.message:String(r)}`,tone:"error"}}})}})}d(m,"connectAfterEditHook");function u(n){if(n.id.trim().length===0||typeof n.run!="function")throw new TypeError("A file hook needs a non-empty id and run function")}d(u,"assertHook");export{m as connectAfterEditHook,A as connectBeforeEditHook,x as connectBeforeReadHook};
package/dist/entry-11.js CHANGED
@@ -1 +1 @@
1
- import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s,v as u}from"./chunk-S3ZPXWX7.js";import"./chunk-EI7MMDWY.js";export{j as CONTENT_API_VERSION,l as CONTENT_CONVERTER_REGISTER_EVENT,k as CONTENT_HOST_READY_EVENT,i as CONTENT_PROTOCOL,d as UnsupportedContentError,u as connectContentConverter,s as createContentHost,g as createContentRunner,r as isAgentContent,b as isContentConversionAttempt,x as isContentConversionContext,a as isContentConverter,c as isContentConverterRegistration,q as isContentConverterRegistrationRequest,n as isContentHostReady,t as isContentInput,p as isContentTarget,e as isResource,m as isResourceResolutionAttempt,f as isResourceResolver,o as renderContentDescription,h as targetsEqual};
1
+ import"./chunk-U2JKHKLK.js";import{a as k,b as l,c as m,d as n,e as o,f as p,g as q}from"./chunk-J4RTW44E.js";import"./chunk-NNCZYO4Q.js";import{b as i,d as j}from"./chunk-526E364R.js";import"./chunk-YHUTTZC6.js";import{a as h}from"./chunk-6CZO43OH.js";import{a,b,c,d,e,f,g}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{i as COMPACT_READ_ROWS,b as READ_API_VERSION,c as READ_CORE_READY_EVENT,d as READ_PLUGIN_REGISTER_EVENT,a as READ_PROTOCOL,h as connectReadPlugin,j as createReadResultRenderer,p as isFragmentResolverRegistration,e as isReadCoreReady,q as isReadFragmentResolution,n as isReadHandlerRegistration,f as isReadPlugin,g as isReadPluginRegistrationRequest,o as isReadViewRegistration,m as isResourceResolverRegistration,l as isTextTargetResolverRegistration,k as readParameters};
package/dist/entry-12.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-ROXXK6TW.js";import{a}from"./chunk-HGPUI7F3.js";import{a as x}from"./chunk-ZTYWHL2F.js";import{a as o,b as r,c as e,d as f,e as m,f as p,g as t}from"./chunk-7UGNGK7Y.js";import"./chunk-EI7MMDWY.js";export{r as SEARCH_API_VERSION,e as SEARCH_CORE_READY_EVENT,f as SEARCH_PLUGIN_REGISTER_EVENT,o as SEARCH_PROTOCOL,x as connectSearchPlugin,m as isSearchCoreReady,p as isSearchPlugin,t as isSearchPluginRegistrationRequest,a as searchSchema};
1
+ import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s,v as u}from"./chunk-S3ZPXWX7.js";import"./chunk-EI7MMDWY.js";export{j as CONTENT_API_VERSION,l as CONTENT_CONVERTER_REGISTER_EVENT,k as CONTENT_HOST_READY_EVENT,i as CONTENT_PROTOCOL,d as UnsupportedContentError,u as connectContentConverter,s as createContentHost,g as createContentRunner,r as isAgentContent,b as isContentConversionAttempt,x as isContentConversionContext,a as isContentConverter,c as isContentConverterRegistration,q as isContentConverterRegistrationRequest,n as isContentHostReady,t as isContentInput,p as isContentTarget,e as isResource,m as isResourceResolutionAttempt,f as isResourceResolver,o as renderContentDescription,h as targetsEqual};
package/dist/entry-13.js CHANGED
@@ -1 +1 @@
1
- import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s}from"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{o as TextAnchor,r as attachTextAnchorRenderer,j as createTextContentConverter,g as createTextDocument,e as getTextAnchorRenderer,a as getTextSourceLine,t as isTextAnchorRecoveryOutcome,p as isTextAnchorResolutionAttempt,m as isTextAnchorResolver,c as isTextLinePresenter,d as isTextPresenterRegistration,n as isTextTargetResolutionAttempt,k as isTextualMediaType,i as renderPresentedTextDocument,x as renderPresentedTextRows,f as renderTextAnchor,h as renderTextDocument,s as restoreText,q as storeText,l as textFromAgentContent,b as withTextSourceLine};
1
+ import"./chunk-ROXXK6TW.js";import{a}from"./chunk-KII2JQC5.js";import{a as x}from"./chunk-ZTYWHL2F.js";import{a as o,b as r,c as e,d as f,e as m,f as p,g as t}from"./chunk-7UGNGK7Y.js";import"./chunk-EI7MMDWY.js";export{r as SEARCH_API_VERSION,e as SEARCH_CORE_READY_EVENT,f as SEARCH_PLUGIN_REGISTER_EVENT,o as SEARCH_PROTOCOL,x as connectSearchPlugin,m as isSearchCoreReady,p as isSearchPlugin,t as isSearchPluginRegistrationRequest,a as searchSchema};
package/dist/entry-14.js CHANGED
@@ -1 +1 @@
1
- import{l as t}from"./chunk-DQF5QMJ2.js";import{a as E}from"./chunk-TI5GMJ7Q.js";import{a as o,b as e,c as r,d as i,e as n,f as a,g as p,h as x,i as s,j as d,k as f,l as u,m}from"./chunk-Y7ZMR4LT.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{e as TEXT_EDITOR_API_VERSION,n as TEXT_EDITOR_CORE_READY_EVENT,a as TEXT_EDITOR_PLUGIN_REGISTER_EVENT,o as TEXT_EDITOR_PROTOCOL,r as TEXT_POSITION_ANCHOR_KIND,i as TEXT_SEARCH_ANCHOR_KIND,E as connectTextEditorPlugin,t as connectTextEditorPostEditHandler,x as isResourceResolverRegistration,s as isTextAnchorResolverRegistration,d as isTextAnchorResourceResolutionAttempt,f as isTextEditorCoreReady,u as isTextEditorPlugin,m as isTextEditorPluginRegistrationRequest,p as isTextEditorToolId};
1
+ import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s}from"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{o as TextAnchor,r as attachTextAnchorRenderer,j as createTextContentConverter,g as createTextDocument,e as getTextAnchorRenderer,a as getTextSourceLine,t as isTextAnchorRecoveryOutcome,p as isTextAnchorResolutionAttempt,m as isTextAnchorResolver,c as isTextLinePresenter,d as isTextPresenterRegistration,n as isTextTargetResolutionAttempt,k as isTextualMediaType,i as renderPresentedTextDocument,x as renderPresentedTextRows,f as renderTextAnchor,h as renderTextDocument,s as restoreText,q as storeText,l as textFromAgentContent,b as withTextSourceLine};
@@ -0,0 +1 @@
1
+ import"./chunk-IQD6PON5.js";import{l as o}from"./chunk-WGGIQ7IJ.js";import{a as n}from"./chunk-L7JMDDSD.js";import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{b as TEXT_EDITOR_API_VERSION,e as TEXT_EDITOR_CORE_READY_EVENT,f as TEXT_EDITOR_PLUGIN_REGISTER_EVENT,a as TEXT_EDITOR_PROTOCOL,c as TEXT_POSITION_ANCHOR_KIND,d as TEXT_SEARCH_ANCHOR_KIND,n as connectTextEditorPlugin,o as connectTextEditorPostEditHandler,h as isResourceResolverRegistration,i as isTextAnchorResolverRegistration,j as isTextAnchorResourceResolutionAttempt,k as isTextEditorCoreReady,l as isTextEditorPlugin,m as isTextEditorPluginRegistrationRequest,g as isTextEditorToolId};
package/dist/entry-17.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-ERVMDQGX.js";import"./chunk-VFBLX4TG.js";import"./chunk-EI7MMDWY.js";export{a as connectDoctorPlugin};
1
+ import"./chunk-K4ZMRDEI.js";
package/dist/entry-18.js CHANGED
@@ -1 +1 @@
1
- import{a,b}from"./chunk-WZI4YC2O.js";import"./chunk-EI7MMDWY.js";export{b as hasProjectMarker,a as inspectRecipeEvidence};
1
+ import{a}from"./chunk-MGCHOGQD.js";import"./chunk-T6LX2RX5.js";import"./chunk-EI7MMDWY.js";export{a as connectDoctorPlugin};
package/dist/entry-19.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e}from"./chunk-N34ATN52.js";import"./chunk-EI7MMDWY.js";export{d as isExecutableAvailable,b as normalizeProcessEnvironment,e as probeExecutable,a as projectExecutableDirectories,c as projectProcessEnvironment};
1
+ import{a,b}from"./chunk-WZI4YC2O.js";import"./chunk-EI7MMDWY.js";export{b as hasProjectMarker,a as inspectRecipeEvidence};
package/dist/entry-20.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e,f}from"./chunk-VFBLX4TG.js";import"./chunk-EI7MMDWY.js";export{b as DOCTOR_API_VERSION,c as DOCTOR_CORE_READY_EVENT,d as DOCTOR_PLUGIN_REGISTER_EVENT,a as DOCTOR_PROTOCOL,e as isDoctorCoreReady,f as isDoctorPluginRegistrationRequest};
1
+ import{a,b,c,d,e}from"./chunk-N34ATN52.js";import"./chunk-EI7MMDWY.js";export{d as isExecutableAvailable,b as normalizeProcessEnvironment,e as probeExecutable,a as projectExecutableDirectories,c as projectProcessEnvironment};
package/dist/entry-21.js CHANGED
@@ -1,2 +1 @@
1
- import"./chunk-NNCZYO4Q.js";import{d as v}from"./chunk-3SE372WC.js";import"./chunk-YHUTTZC6.js";import{a as R}from"./chunk-72EEL2DW.js";import{a as y,b as p}from"./chunk-KAB3AYA2.js";import{a as w}from"./chunk-TI5GMJ7Q.js";import{a as h,b as F}from"./chunk-Y7ZMR4LT.js";import{a as g,u as m}from"./chunk-S3ZPXWX7.js";import{r as f}from"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import{a as o}from"./chunk-EI7MMDWY.js";import{readdirSync as x,realpathSync as H,statSync as S}from"node:fs";import{mkdir as k,readFile as D,writeFile as O}from"node:fs/promises";import b from"node:path";import{fileURLToPath as I,pathToFileURL as _}from"node:url";function T(e){return P("read",e)}o(T,"createFilesystemReadResolver");function C(e){return P("write",e)}o(C,"createFilesystemWriteResolver");function P(e,s){return{id:"filesystem",tryResolve(t,i){return Promise.resolve(L(t,i,e,s))}}}o(P,"createFilesystemResolver");function L(e,s,t,i){if(e.length===0)return{kind:"failed",error:new TypeError("Filesystem source must not be empty")};if(!W(e))return{kind:"not-handled"};if(s.signal?.aborted===!0)return{kind:"failed",error:E()};let r=e.startsWith("file://")?H(I(new URL(e))):b.resolve(s.cwd,e),l=_(r).href,c=(()=>{try{return S(r).isDirectory()}catch{return!1}})(),n=o(async({signal:d})=>c?U(r,d):V(r,i,d),"read");return t==="read"||c?{kind:"resolved",resource:{source:r,link:l,read:n}}:{kind:"resolved",resource:{source:r,link:l,read:n,async write(d,u){a(u.signal);let A=f(d);await k(b.dirname(r),{recursive:!0}),a(u.signal),await O(r,A,{encoding:"utf8",...u.signal!==void 0&&{signal:u.signal}})}}}}o(L,"resolveFilesystemSource");function U(e,s){a(s);let t=x(e,{withFileTypes:!0}),i=[`\u{1F4C1} ${e}/`];t.length>0&&i.push("");for(let r of t){let l=r.isDirectory()?"\u{1F4C1}":r.isFile()?"\u{1F4C4}":"\u{1F517}";i.push(` ${l} ${r.name}`)}return[{type:"text",text:i.join(`
2
- `)}]}o(U,"readDirectoryContent");async function V(e,s,t){a(t);let i=await D(e,{encoding:null,...t!==void 0&&{signal:t}});return a(t),s.convert({source:e,bytes:i},t===void 0?{}:{signal:t})}o(V,"readFilesystemContent");function W(e){return/^[A-Za-z]:[\\/]/u.test(e)||e.startsWith("file://")?!0:!/^[A-Za-z][A-Za-z\d+.-]*:/u.test(e)}o(W,"isFilesystemSource");function a(e){if(e?.aborted===!0)throw E()}o(a,"throwIfAborted");function E(){let e=new Error("The operation was aborted");return e.name="AbortError",e}o(E,"abortError");var z={provider:"filesystem",capability:"read"},Z={provider:"filesystem",capability:"write"},$=v({kind:"source",nativeResources:!0});async function j(e){let s=m(e,z),t=m(e,Z),i=T(s),r=C(t),l={protocol:y,apiVersion:p,id:"filesystem",setup(n){n.addResolver({resolver:i,renderResult:$}),n.describe(()=>g("File path \u2014 file content; directory path \u2014 entry listing. Relative, absolute and file:// paths accepted.",s.listDescriptions())),n.addPromptGuideline("Use read with paths relative to the current working directory for project files. Use read with absolute paths for files elsewhere on the system.")}},c={protocol:h,apiVersion:F,id:"filesystem",setup(n){n.addResolver({resolver:r})}};await Promise.all([R(e,l),w(e,c)])}o(j,"registerFilesystemPlugin");export{j as default};
1
+ import{a,b,c,d,e,f}from"./chunk-T6LX2RX5.js";import"./chunk-EI7MMDWY.js";export{b as DOCTOR_API_VERSION,c as DOCTOR_CORE_READY_EVENT,d as DOCTOR_PLUGIN_REGISTER_EVENT,a as DOCTOR_PROTOCOL,e as isDoctorCoreReady,f as isDoctorPluginRegistrationRequest};
package/dist/entry-22.js CHANGED
@@ -1 +1,2 @@
1
- import{a as r}from"./chunk-QIJMV2P2.js";import{v as e}from"./chunk-S3ZPXWX7.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:100};async function i(o){await e(o,n)}t(i,"registerFilesystemImage");export{i as default};
1
+ import"./chunk-NNCZYO4Q.js";import{d as v}from"./chunk-526E364R.js";import"./chunk-YHUTTZC6.js";import{a as R}from"./chunk-6CZO43OH.js";import{a as y,b as p}from"./chunk-OBNING2A.js";import{a as w}from"./chunk-L7JMDDSD.js";import{a as h,b as F}from"./chunk-O6LE42GK.js";import{a as g,u as m}from"./chunk-S3ZPXWX7.js";import{r as f}from"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import{a as o}from"./chunk-EI7MMDWY.js";import{readdirSync as x,realpathSync as H,statSync as S}from"node:fs";import{mkdir as k,readFile as D,writeFile as O}from"node:fs/promises";import b from"node:path";import{fileURLToPath as I,pathToFileURL as _}from"node:url";function T(e){return P("read",e)}o(T,"createFilesystemReadResolver");function C(e){return P("write",e)}o(C,"createFilesystemWriteResolver");function P(e,s){return{id:"filesystem",tryResolve(t,i){return Promise.resolve(L(t,i,e,s))}}}o(P,"createFilesystemResolver");function L(e,s,t,i){if(e.length===0)return{kind:"failed",error:new TypeError("Filesystem source must not be empty")};if(!W(e))return{kind:"not-handled"};if(s.signal?.aborted===!0)return{kind:"failed",error:E()};let r=e.startsWith("file://")?H(I(new URL(e))):b.resolve(s.cwd,e),l=_(r).href,c=(()=>{try{return S(r).isDirectory()}catch{return!1}})(),n=o(async({signal:d})=>c?U(r,d):V(r,i,d),"read");return t==="read"||c?{kind:"resolved",resource:{source:r,link:l,read:n}}:{kind:"resolved",resource:{source:r,link:l,read:n,async write(d,u){a(u.signal);let A=f(d);await k(b.dirname(r),{recursive:!0}),a(u.signal),await O(r,A,{encoding:"utf8",...u.signal!==void 0&&{signal:u.signal}})}}}}o(L,"resolveFilesystemSource");function U(e,s){a(s);let t=x(e,{withFileTypes:!0}),i=[`\u{1F4C1} ${e}/`];t.length>0&&i.push("");for(let r of t){let l=r.isDirectory()?"\u{1F4C1}":r.isFile()?"\u{1F4C4}":"\u{1F517}";i.push(` ${l} ${r.name}`)}return[{type:"text",text:i.join(`
2
+ `)}]}o(U,"readDirectoryContent");async function V(e,s,t){a(t);let i=await D(e,{encoding:null,...t!==void 0&&{signal:t}});return a(t),s.convert({source:e,bytes:i},t===void 0?{}:{signal:t})}o(V,"readFilesystemContent");function W(e){return/^[A-Za-z]:[\\/]/u.test(e)||e.startsWith("file://")?!0:!/^[A-Za-z][A-Za-z\d+.-]*:/u.test(e)}o(W,"isFilesystemSource");function a(e){if(e?.aborted===!0)throw E()}o(a,"throwIfAborted");function E(){let e=new Error("The operation was aborted");return e.name="AbortError",e}o(E,"abortError");var z={provider:"filesystem",capability:"read"},Z={provider:"filesystem",capability:"write"},$=v({kind:"source",nativeResources:!0});async function j(e){let s=m(e,z),t=m(e,Z),i=T(s),r=C(t),l={protocol:y,apiVersion:p,id:"filesystem",setup(n){n.addResolver({resolver:i,renderResult:$}),n.describe(()=>g("File path \u2014 file content; directory path \u2014 entry listing. Relative, absolute and file:// paths accepted.",s.listDescriptions())),n.addPromptGuideline("Use read with paths relative to the current working directory for project files. Use read with absolute paths for files elsewhere on the system.")}},c={protocol:h,apiVersion:F,id:"filesystem",setup(n){n.addResolver({resolver:r})}};await Promise.all([R(e,l),w(e,c)])}o(j,"registerFilesystemPlugin");export{j as default};
package/dist/entry-23.js CHANGED
@@ -1 +1 @@
1
- import{a as r}from"./chunk-BHSO2MDK.js";import{v as e}from"./chunk-S3ZPXWX7.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:200};async function i(o){await e(o,n)}t(i,"registerFilesystemPdf");export{i as default};
1
+ import{a as r}from"./chunk-QIJMV2P2.js";import{v as e}from"./chunk-S3ZPXWX7.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:100};async function i(o){await e(o,n)}t(i,"registerFilesystemImage");export{i as default};
package/dist/entry-24.js CHANGED
@@ -1 +1 @@
1
- import{v as t}from"./chunk-S3ZPXWX7.js";import{p as i}from"./chunk-5VSE5X5R.js";import{a as r}from"./chunk-EI7MMDWY.js";var o=i(),n={target:{provider:"filesystem",capability:"read"},converter:o,priority:300},s={target:{provider:"filesystem",capability:"write"},converter:o,priority:300};async function a(e){await Promise.all([t(e,n),t(e,s)])}r(a,"registerFilesystemText");export{a as default};
1
+ import{a as r}from"./chunk-BHSO2MDK.js";import{v as e}from"./chunk-S3ZPXWX7.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:200};async function i(o){await e(o,n)}t(i,"registerFilesystemPdf");export{i as default};
package/dist/entry-25.js CHANGED
@@ -1 +1 @@
1
- import{a as e,b as o}from"./chunk-B5KB2I7J.js";import"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{o as AstScopeManager,e as parseDocument};
1
+ import{v as t}from"./chunk-S3ZPXWX7.js";import{p as i}from"./chunk-5VSE5X5R.js";import{a as r}from"./chunk-EI7MMDWY.js";var o=i(),n={target:{provider:"filesystem",capability:"read"},converter:o,priority:300},s={target:{provider:"filesystem",capability:"write"},converter:o,priority:300};async function a(e){await Promise.all([t(e,n),t(e,s)])}r(a,"registerFilesystemText");export{a as default};
package/dist/entry-26.js CHANGED
@@ -1,12 +1 @@
1
- import{a as j,b as V}from"./chunk-B5KB2I7J.js";import{a as T}from"./chunk-ERVMDQGX.js";import{a as L,b as E}from"./chunk-VFBLX4TG.js";import"./chunk-NNCZYO4Q.js";import{d as $}from"./chunk-3SE372WC.js";import"./chunk-YHUTTZC6.js";import{a as k}from"./chunk-72EEL2DW.js";import{a as P,b as M}from"./chunk-KAB3AYA2.js";import{a as N}from"./chunk-ZTYWHL2F.js";import{a as I,b as C}from"./chunk-7UGNGK7Y.js";import{a as B}from"./chunk-TI5GMJ7Q.js";import{a as _,b as D,c as H}from"./chunk-Y7ZMR4LT.js";import"./chunk-S3ZPXWX7.js";import{a as R,b,c as w,l as v}from"./chunk-NTYXZ3EL.js";import"./chunk-5VSE5X5R.js";import"./chunk-KINKBPPX.js";import{j as O}from"./chunk-M5MJP7Z2.js";import"./chunk-WZI4YC2O.js";import{e as x}from"./chunk-N34ATN52.js";import"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";import{readFile as te}from"node:fs/promises";var y=new Set(["c","cpp","javascript","typescript","python","rust","json","yaml","toml"]),G={protocol:L,apiVersion:1,id:"ast",setup(o){o.addSetupCheck({id:"structural-search",async inspect(e){return[...e.detectedLanguageIds].some(s=>y.has(s))?await O({command:["ast-grep"]},e.cwd,e.env)?{}:{actions:[{id:"ast-grep-unavailable",message:"Structural search is unavailable because ast-grep was not found"}]}:{}}}),o.addCheck({id:"parsers",title:"AST",async run(e){let n=[];for(let s of e.detectedLanguageIds){if(!y.has(s))continue;let t=e.files.find(r=>ne(r,s));if(t!==void 0)try{let r=await te(t,"utf8"),a=await j(t,e.cwd,r.replaceAll(`\r
2
- `,`
3
- `).split(`
4
- `));n.push(a===void 0?{status:"fail",message:`${s} parser did not return a tree`}:{status:"pass",message:`${s} parser loaded`,detail:t})}catch(r){n.push({status:"fail",message:`${s}: ${r instanceof Error?r.message:String(r)}`})}}return n.length>0?n:[{status:"skip",message:"No supported AST files found"}]}}),o.addCheck({id:"ast-grep",title:"Structural search",async run(e){if(![...e.detectedLanguageIds].some(s=>y.has(s)))return[{status:"skip",message:"No supported structural-search files found"}];let n=await x("ast-grep",["--version"],e.cwd,e.env);return[n.ok?{status:"pass",message:"ast-grep is available",detail:n.detail}:{status:"fail",message:"ast-grep is not available",detail:n.detail}]}})}};function ne(o,e){let n=o.slice(o.lastIndexOf(".")).toLowerCase();return{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"],javascript:[".js",".jsx",".mjs",".cjs"],typescript:[".ts",".tsx",".mts",".cts"],python:[".py",".pyi"],rust:[".rs"],json:[".json",".jsonc"],yaml:[".yaml",".yml"],toml:[".toml"]}[e]?.includes(n)??!1}d(ne,"matchesLanguage");var re,se;function F(o){return{id:"ast",tryResolve(e,n){return Promise.resolve(oe(e,n,o))}}}d(F,"createAstOutlineResolver");function oe(o,e,n){let s;try{s=R(o,"ast")}catch(a){return{kind:"failed",error:a}}if(s===void 0)return{kind:"not-handled"};let t;try{t=b(s.path,e.cwd)}catch(a){return{kind:"failed",error:a}}return{kind:"resolved",resource:{source:w("ast",t),async read({signal:a}){a?.throwIfAborted();let i=await(se??=import("./chunk-TPIHQYK2.js")),c=await(n??(re??=new i.AstOutlineManager)).readFileOutline(t,e.cwd);return a?.throwIfAborted(),[i.formatAstOutline(c)]}}}}d(oe,"resolveAstOutlineSource");import{DEFAULT_MAX_BYTES as ae,DEFAULT_MAX_LINES as ie,truncateHead as A}from"@earendil-works/pi-coding-agent";var S=d(async(o,e,n)=>{let{source:s,resolvedBy:t,lines:r,totalLines:a,startLine:i}=o.details;if(!(s===void 0||t!=="filesystem"||r===void 0||r.length!==a||i!==void 0&&i!==1))try{let{AstOutlineManager:u,isSupportedOutlinePath:c}=await import("./chunk-TPIHQYK2.js");if(!c(s))return;let l=d(m=>[`AST overview of ${m.path}, source lines 1-${m.totalLines}: the requested text exceeded the read buffer.`,"Source line numbers are on the left. Detail is reduced to fit the buffer; omitted bodies are not exact source text. Read a small source range when needed.",...m.renderedLines.map(g=>`${g.sourceLine?.lineNumber??"\u2026"} | ${g.text}`)].join(`
5
- `),"format");e.signal?.throwIfAborted();let p=await new u(12).readDocumentOutline(s,e.cwd,r.map(m=>m.content),m=>(e.signal?.throwIfAborted(),!A(l(m),n).truncated)),f=l(p);return A(f,n).truncated?void 0:{content:[{type:"text",text:f}],details:{source:s,resolvedBy:"ast-overflow"}}}catch{e.signal?.throwIfAborted();return}},"reduceAstReadOutput");function X(){return async o=>{let{state:e,result:n}=o,s=n?.content.length===1?n.content[0]:void 0;if(o.audience==="script"||n===void 0||e?.contentKind!=="text"||e.resolvedBy!=="filesystem"||s?.type!=="text"||!A(s.text).truncated)return{kind:"continue",context:o};let t=await S({...n,details:{...n.details,source:e.source,resolvedBy:e.resolvedBy,lines:e.text.lines,startLine:1,totalLines:e.text.lines.length}},o.resolverContext,{maxBytes:ae,maxLines:ie});return t===void 0?{kind:"continue",context:o}:{kind:"return",result:t}}}d(X,"createAstOverflowHandler");var z="pi-agent-ast";function K(o){return{id:"ast-scopes",async present(e,n){if(n.resolvedBy!=="filesystem")return e;try{let s=await o.getDocumentScopes(e.source,n.cwd,e.lines.map(r=>r.content)),t=ce(e.lines,s);return t===e.lines?e:{...e,lines:t}}catch{return e}}}}d(K,"createAstScopePresenter");function U(){return o=>{let e=o.state,n=o.result;if(e?.contentKind!=="text"||n===void 0)return{kind:"continue",context:o};let s=n.details.lines;if(s===void 0)return{kind:"continue",context:o};let t=new Map(e.text.lines.map(l=>[l.lineNumber,l])),r=new Set(s.map(l=>l.lineNumber)),a=new Map;for(let l of s){let p=t.get(l.lineNumber),f=J(p);for(let m of f?.boundaries??[]){if(r.has(m.endLine))continue;let g=t.get(m.endLine);g!==void 0&&a.set(m.endLine,g)}}if(a.size===0)return{kind:"continue",context:o};let i=[...a.values()].sort((l,p)=>l.lineNumber-p.lineNumber),u=[...s,...i],c=de(n,u,s.at(-1));return{kind:"continue",context:{...o,result:c}}}}d(U,"createAstScopePostReadHandler");function ce(o,e){if(e.length===0)return o;let n=new Map,s=new Map;for(let t of e){let r=n.get(t.startLine)??[];r.push(t.beginAnchor.value),n.set(t.startLine,r);let a=s.get(t.startLine)??[];a.push({endLine:t.endLine,beginAnchor:t.beginAnchor.value,endAnchor:t.endScopeAnchor.value}),s.set(t.startLine,a);let i=n.get(t.endLine)??[];i.push(t.endScopeAnchor.value),n.set(t.endLine,i)}return o.map(t=>{let r=n.get(t.lineNumber),a=s.get(t.lineNumber);return r===void 0&&a===void 0?t:{...t,...r!==void 0&&{anchors:[...new Set([...t.anchors??[],...r])],presentation:{...t.presentation,suffix:`${t.presentation?.suffix??""}${r.map(i=>` <!-- ${i} -->`).join("")}`}},metadata:{...t.metadata,[z]:{...J(t),...a!==void 0&&{boundaries:a}}}}})}d(ce,"addScopeMarkers");function J(o){let e=o?.metadata?.[z];if(!(typeof e!="object"||e===null))return e}d(J,"getAstScopeMetadata");function de(o,e,n){let s=o.content.length===1?o.content[0]:void 0;if(s?.type!=="text"||o.details.lines===void 0)return o;let t=e.slice(o.details.lines.length);if(t.length===0)return o;let r=n?.lineEnding!==void 0&&n.lineEnding.length>0?n.lineEnding:t[0]?.lineEnding!==void 0&&t[0].lineEnding.length>0?t[0].lineEnding:`
6
- `,a=t.map((c,l)=>{let f=l===t.length-1?c.lineEnding:c.lineEnding||r,m=c.presentation?.prefix??"",g=c.presentation?.suffix??"";return`${m}${c.content}${g}${f}`}).join(""),i=/(?:\r\n|\r|\n)$/.test(s.text)?"":r,u=`${s.text}${i}${a}`;return{...o,content:[{...s,text:u}],details:{...o.details,lines:e}}}d(de,"appendTextLines");var Y=/^scope-(begin|end)-[A-Z0-9]{3,4}(?:-[1-9]\d*)?$/;function W(o){return{id:"ast-scope",description:'`scope-begin-HASH` / `scope-end-HASH` from read views: ["ast"] \u2014 first/last lines of a scope. Any numeric suffix is part of the anchor.',renderFull(e){return e},renderCompact(e){return Y.exec(e)?.[1]==="begin"?"scope start":"scope end"},async tryResolve(e,n){if(!Y.test(e))return{kind:"not-handled"};try{let t=(await o.getDocumentScopes(n.source,n.cwd,n.lines)).find(r=>r.beginAnchor.value===e||r.endScopeAnchor.value===e);return t===void 0?{kind:"rejected",rejection:{code:"stale",reason:`AST scope anchor ${e} is stale`}}:{kind:"resolved",anchor:t.beginAnchor.value===e?t.beginAnchor:t.endScopeAnchor}}catch(s){return{kind:"failed",error:s}}}}}d(W,"createAstScopeAnchorResolver");import{spawn as le}from"node:child_process";import{readFile as ue,stat as Z}from"node:fs/promises";import h from"node:path";function Q(o){return{id:"ast",async tryResolve(e,n){if(!e.query.startsWith("ast:"))return{kind:"not-handled"};let s=e.query.slice(4).trim();if(s.length===0)return{kind:"failed",error:new Error("ast: pattern must not be empty")};let t=d(async i=>{let u=Date.now(),c=await fe(s,e,n.cwd,i);c.sort((p,f)=>h.resolve(n.cwd,p.file).localeCompare(h.resolve(n.cwd,f.file))||p.range.byteOffset.start-f.range.byteOffset.start||p.range.byteOffset.end-f.range.byteOffset.end);let l=c.slice(0,e.limit??100);return{raw:l,matches:await pe(l,n.cwd,u,i),complete:c.length<=(e.limit??100)}},"collect"),r=await t(n.signal),a=await o({request:e,matches:r.matches,complete:r.complete,refresh:t},n);return{kind:"resolved",payload:{pattern:s,matches:r.raw,complete:r.complete,sessionId:a.id}}},format(e){let n=e;if(n.matches.length===0)return{content:[{type:"text",text:"No AST matches found."}],details:n};let s=n.matches.flatMap((t,r)=>[`SEARCH#${n.sessionId}:${String(r+1)}:match ${t.file}:${String(t.range.start.line+1)}:${String(t.range.start.column+1)} ${t.language}`,` ${t.lines.trim()}`]);return n.complete&&s.unshift(`SEARCH#${n.sessionId}:all:match selects all exact AST matches.`),n.complete||s.push("Result limit reached."),{content:[{type:"text",text:s.join(`
7
- `)}],details:n}}}}d(Q,"createAstSearchResolver");async function pe(o,e,n,s){let t=new Map;for(let r of o){let a=h.resolve(e,r.file);if(t.has(a))continue;let i=await Z(a),u=await ue(a,{signal:s}),c=await Z(a);if(i.mtimeMs>n||i.mtimeMs!==c.mtimeMs||i.size!==c.size)throw new Error("AST source changed during search. Run the structural query again.");t.set(a,u)}return o.map(r=>{let a=h.resolve(e,r.file),i=t.get(a);if(i===void 0)throw new Error("Missing AST source snapshot");let{start:u,end:c}=r.range.byteOffset;if(!Number.isInteger(u)||!Number.isInteger(c)||u<0||c<u||c>i.length||i.subarray(u,c).toString("utf8")!==r.text)throw new Error("AST range does not match its source snapshot. Search again.");let l=i.subarray(0,u).toString("utf8"),p=i.subarray(0,c).toString("utf8"),f=l.split(`
8
- `).length;return{source:a,lineNumber:f,endLineNumber:p.split(`
9
- `).length,startColumn:l.length-l.lastIndexOf(`
10
- `)-1,endColumn:p.length-p.lastIndexOf(`
11
- `)-1,matchedText:r.text,lineText:i.toString("utf8").split(`
12
- `)[f-1]?.replace(/\r$/u,"")??""}})}d(pe,"selectionMatches");function fe(o,e,n,s){let t=["run","--pattern",o,"--json=compact","--no-ignore","parent"];for(let r of q(e.include))t.push("--globs",r);for(let r of q(e.exclude))t.push("--globs",`!${r}`);return t.push(e.path??"."),new Promise((r,a)=>{let i=le("ast-grep",t,{cwd:n,stdio:["ignore","pipe","pipe"]}),u="",c="";i.stdout.setEncoding("utf8"),i.stderr.setEncoding("utf8"),i.stdout.on("data",p=>u+=p),i.stderr.on("data",p=>c+=p);let l=d(()=>{i.kill("SIGTERM")},"abort");s?.addEventListener("abort",l,{once:!0}),i.once("error",a),i.once("close",p=>{if(s?.removeEventListener("abort",l),s?.aborted===!0){a(s.reason instanceof Error?s.reason:new Error("AST search aborted"));return}if(p!==0&&p!==1){a(new Error(c.trim()||`ast-grep exited with code ${String(p)}`));return}try{let f=JSON.parse(u.length===0?"[]":u);if(!Array.isArray(f))throw new TypeError("ast-grep returned non-array JSON");r(f)}catch(f){a(f instanceof Error?f:new Error(String(f)))}})})}d(fe,"runAstGrep");function q(o){return o?.split(",").map(e=>e.trim()).filter(Boolean)??[]}d(q,"splitGlobs");var me=$({kind:"code-view",label:"AST"});async function ee(o){let e=new V,n=K(e),s={protocol:P,apiVersion:M,id:"ast",setup(r){r.addResolver({resolver:F(),renderResult:me}),r.addHandler({stage:"read",when:{resolvedBy:"ast",contentKind:"text"},handler:v()}),r.addView({view:"ast",presenter:n});let a=X();r.addOutputReducer(S);let i=U();r.addHandler({stage:"post-read",async handler(u){let c=await a(u);return c.kind==="return"?c:i(c.context)}}),r.describe('ast:<path> \u2014 compact declaration outline. views: ["ast"] \u2014 scope boundaries alongside source text. Oversized code reads may return an outline with source line numbers; offset/limit read a smaller source range.')}},t={protocol:_,apiVersion:D,id:"ast",setup(r){r.addAnchorResolver({resolver:W(e),kind:H,type:"auxiliary"}),r.addTextPresenter({presenter:n})}};await Promise.all([k(o,s),T(o,G),B(o,t),N(o,{protocol:I,apiVersion:C,id:"ast-search",setup(r){r.addResolver({resolver:Q(r.registerSelection)}),r.describe("Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search. Use returned SEARCH# references to read, replace, copy, move or delete exact AST matches, including multiline nodes. A single :match reference becomes stale after its file changes; :all:match reruns the original structural query. Incomplete results do not provide all selections. Use captures in Apply to compute replacement text; these edits do not update imports or references.")}})])}d(ee,"registerAst");export{ee as default};
1
+ import{b as e,c as o}from"./chunk-25CZ5ZIU.js";import"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{o as AstScopeManager,e as parseDocument};
package/dist/entry-27.js CHANGED
@@ -1 +1,12 @@
1
- import{a,b,c}from"./chunk-DEP55R35.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as createChangeGroups,c as replaceHeadRangeInIndex,b as reverseChangeGroup};
1
+ import{b as B,c as V}from"./chunk-25CZ5ZIU.js";import{a as E}from"./chunk-MGCHOGQD.js";import{a as O,b as L}from"./chunk-T6LX2RX5.js";import"./chunk-NNCZYO4Q.js";import{d as $}from"./chunk-526E364R.js";import"./chunk-YHUTTZC6.js";import{a as M}from"./chunk-6CZO43OH.js";import{a as k,b as P}from"./chunk-OBNING2A.js";import{a as D}from"./chunk-ZTYWHL2F.js";import{a as H,b as j}from"./chunk-7UGNGK7Y.js";import{a as _}from"./chunk-L7JMDDSD.js";import{a as I,b as C,c as N}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import{a as S,b as R,c as w,l as v}from"./chunk-NTYXZ3EL.js";import"./chunk-5VSE5X5R.js";import"./chunk-KINKBPPX.js";import{j as T}from"./chunk-M5MJP7Z2.js";import"./chunk-WZI4YC2O.js";import{e as x}from"./chunk-N34ATN52.js";import"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";import{readFile as te}from"node:fs/promises";var ne={cmake:"no compatible Tree-sitter parser is packaged",dockerfile:"no compatible Tree-sitter parser is packaged",julia:"no compatible Tree-sitter parser is packaged",powershell:"no compatible Tree-sitter parser is packaged",r:"no compatible Tree-sitter parser is packaged",svelte:"the container grammar is not available as an ast-grep language package",terraform:"the HCL grammar is not available as an ast-grep language package",vue:"the container grammar is not available as an ast-grep language package",xml:"no compatible Tree-sitter parser is packaged",zig:"no compatible Tree-sitter parser is packaged"},y=new Set(["c","cpp","csharp","css","dart","elixir","go","html","java","kotlin","lua","markdown","php","ruby","scala","shell","sql","swift","javascript","typescript","python","rust","json","yaml","toml"]),G={protocol:O,apiVersion:1,id:"ast",setup(a){a.addSetupCheck({id:"structural-search",async inspect(e){return[...e.detectedLanguageIds].some(r=>y.has(r))?await T({command:["ast-grep"]},e.cwd,e.env)?{}:{actions:[{id:"ast-grep-unavailable",message:"Structural search is unavailable because ast-grep was not found"}]}:{}}}),a.addCheck({id:"parsers",title:"AST",async run(e){let n=[];for(let r of e.detectedLanguageIds){let t=ne[r];if(t!==void 0){n.push({status:"skip",message:`${r} AST is unavailable: ${t}`});continue}if(!y.has(r))continue;let s=e.files.find(o=>re(o,r));if(s!==void 0)try{let o=await te(s,"utf8"),i=await B(s,e.cwd,o.replaceAll(`\r
2
+ `,`
3
+ `).split(`
4
+ `));n.push(i===void 0?{status:"fail",message:`${r} parser did not return a tree`}:{status:"pass",message:`${r} parser loaded`,detail:s})}catch(o){n.push({status:"fail",message:`${r}: ${o instanceof Error?o.message:String(o)}`})}}return n.length>0?n:[{status:"skip",message:"No supported AST files found"}]}}),a.addCheck({id:"ast-grep",title:"Structural search",async run(e){if(![...e.detectedLanguageIds].some(r=>y.has(r)))return[{status:"skip",message:"No supported structural-search files found"}];let n=await x("ast-grep",["--version"],e.cwd,e.env);return[n.ok?{status:"pass",message:"ast-grep is available",detail:n.detail}:{status:"fail",message:"ast-grep is not available",detail:n.detail}]}})}};function re(a,e){let n=a.slice(a.lastIndexOf(".")).toLowerCase();return{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"],csharp:[".cs"],css:[".css",".scss",".less"],dart:[".dart"],elixir:[".ex",".exs"],go:[".go"],html:[".html",".htm"],java:[".java"],kotlin:[".kt",".kts"],lua:[".lua"],markdown:[".md",".mdx"],php:[".php"],ruby:[".rb",".rake"],scala:[".scala",".sc"],shell:[".sh",".bash"],sql:[".sql"],swift:[".swift"],javascript:[".js",".jsx",".mjs",".cjs"],typescript:[".ts",".tsx",".mts",".cts"],python:[".py",".pyi"],rust:[".rs"],json:[".json",".jsonc"],yaml:[".yaml",".yml"],toml:[".toml"]}[e]?.includes(n)??!1}d(re,"matchesLanguage");var se,ae;function F(a){return{id:"ast",tryResolve(e,n){return Promise.resolve(oe(e,n,a))}}}d(F,"createAstOutlineResolver");function oe(a,e,n){let r;try{r=S(a,"ast")}catch(o){return{kind:"failed",error:o}}if(r===void 0)return{kind:"not-handled"};let t;try{t=R(r.path,e.cwd)}catch(o){return{kind:"failed",error:o}}return{kind:"resolved",resource:{source:w("ast",t),async read({signal:o}){o?.throwIfAborted();let i=await(ae??=import("./chunk-5QQABP47.js")),c=await(n??(se??=new i.AstOutlineManager)).readFileOutline(t,e.cwd);return o?.throwIfAborted(),[i.formatAstOutline(c)]}}}}d(oe,"resolveAstOutlineSource");import{DEFAULT_MAX_BYTES as ie,DEFAULT_MAX_LINES as ce,truncateHead as A}from"@earendil-works/pi-coding-agent";var b=d(async(a,e,n)=>{let{source:r,resolvedBy:t,lines:s,totalLines:o,startLine:i}=a.details;if(!(r===void 0||t!=="filesystem"||s===void 0||s.length!==o||i!==void 0&&i!==1))try{let{AstOutlineManager:l,isSupportedOutlinePath:c}=await import("./chunk-5QQABP47.js");if(!c(r))return;let u=d(m=>[`AST overview of ${m.path}, source lines 1-${m.totalLines}: the requested text exceeded the read buffer.`,"Source line numbers are on the left. Detail is reduced to fit the buffer; omitted bodies are not exact source text. Read a small source range when needed.",...m.renderedLines.map(g=>`${g.sourceLine?.lineNumber??"\u2026"} | ${g.text}`)].join(`
5
+ `),"format");e.signal?.throwIfAborted();let p=await new l(12).readDocumentOutline(r,e.cwd,s.map(m=>m.content),m=>(e.signal?.throwIfAborted(),!A(u(m),n).truncated)),f=u(p);return A(f,n).truncated?void 0:{content:[{type:"text",text:f}],details:{source:r,resolvedBy:"ast-overflow"}}}catch{e.signal?.throwIfAborted();return}},"reduceAstReadOutput");function z(){return async a=>{let{state:e,result:n}=a,r=n?.content.length===1?n.content[0]:void 0;if(a.audience==="script"||n===void 0||e?.contentKind!=="text"||e.resolvedBy!=="filesystem"||r?.type!=="text"||!A(r.text).truncated)return{kind:"continue",context:a};let t=await b({...n,details:{...n.details,source:e.source,resolvedBy:e.resolvedBy,lines:e.text.lines,startLine:1,totalLines:e.text.lines.length}},a.resolverContext,{maxBytes:ie,maxLines:ce});return t===void 0?{kind:"continue",context:a}:{kind:"return",result:t}}}d(z,"createAstOverflowHandler");var X="pi-agent-ast";function K(a){return{id:"ast-scopes",async present(e,n){if(n.resolvedBy!=="filesystem")return e;try{let r=await a.getDocumentScopes(e.source,n.cwd,e.lines.map(s=>s.content)),t=de(e.lines,r);return t===e.lines?e:{...e,lines:t}}catch{return e}}}}d(K,"createAstScopePresenter");function U(){return a=>{let e=a.state,n=a.result;if(e?.contentKind!=="text"||n===void 0)return{kind:"continue",context:a};let r=n.details.lines;if(r===void 0)return{kind:"continue",context:a};let t=new Map(e.text.lines.map(u=>[u.lineNumber,u])),s=new Set(r.map(u=>u.lineNumber)),o=new Map;for(let u of r){let p=t.get(u.lineNumber),f=q(p);for(let m of f?.boundaries??[]){if(s.has(m.endLine))continue;let g=t.get(m.endLine);g!==void 0&&o.set(m.endLine,g)}}if(o.size===0)return{kind:"continue",context:a};let i=[...o.values()].sort((u,p)=>u.lineNumber-p.lineNumber),l=[...r,...i],c=le(n,l,r.at(-1));return{kind:"continue",context:{...a,result:c}}}}d(U,"createAstScopePostReadHandler");function de(a,e){if(e.length===0)return a;let n=new Map,r=new Map;for(let t of e){let s=n.get(t.startLine)??[];s.push(t.beginAnchor.value),n.set(t.startLine,s);let o=r.get(t.startLine)??[];o.push({endLine:t.endLine,beginAnchor:t.beginAnchor.value,endAnchor:t.endScopeAnchor.value}),r.set(t.startLine,o);let i=n.get(t.endLine)??[];i.push(t.endScopeAnchor.value),n.set(t.endLine,i)}return a.map(t=>{let s=n.get(t.lineNumber),o=r.get(t.lineNumber);return s===void 0&&o===void 0?t:{...t,...s!==void 0&&{anchors:[...new Set([...t.anchors??[],...s])],presentation:{...t.presentation,suffix:`${t.presentation?.suffix??""}${s.map(i=>` <!-- ${i} -->`).join("")}`}},metadata:{...t.metadata,[X]:{...q(t),...o!==void 0&&{boundaries:o}}}}})}d(de,"addScopeMarkers");function q(a){let e=a?.metadata?.[X];if(!(typeof e!="object"||e===null))return e}d(q,"getAstScopeMetadata");function le(a,e,n){let r=a.content.length===1?a.content[0]:void 0;if(r?.type!=="text"||a.details.lines===void 0)return a;let t=e.slice(a.details.lines.length);if(t.length===0)return a;let s=n?.lineEnding!==void 0&&n.lineEnding.length>0?n.lineEnding:t[0]?.lineEnding!==void 0&&t[0].lineEnding.length>0?t[0].lineEnding:`
6
+ `,o=t.map((c,u)=>{let f=u===t.length-1?c.lineEnding:c.lineEnding||s,m=c.presentation?.prefix??"",g=c.presentation?.suffix??"";return`${m}${c.content}${g}${f}`}).join(""),i=/(?:\r\n|\r|\n)$/.test(r.text)?"":s,l=`${r.text}${i}${o}`;return{...a,content:[{...r,text:l}],details:{...a.details,lines:e}}}d(le,"appendTextLines");var J=/^scope-(begin|end)-[A-Z0-9]{3,4}(?:-[1-9]\d*)?$/;function Y(a){return{id:"ast-scope",description:'`scope-begin-HASH` / `scope-end-HASH` from read views: ["ast"] \u2014 first/last lines of a scope. Any numeric suffix is part of the anchor.',renderFull(e){return e},renderCompact(e){return J.exec(e)?.[1]==="begin"?"scope start":"scope end"},async tryResolve(e,n){if(!J.test(e))return{kind:"not-handled"};try{let t=(await a.getDocumentScopes(n.source,n.cwd,n.lines)).find(s=>s.beginAnchor.value===e||s.endScopeAnchor.value===e);return t===void 0?{kind:"rejected",rejection:{code:"stale",reason:`AST scope anchor ${e} is stale`}}:{kind:"resolved",anchor:t.beginAnchor.value===e?t.beginAnchor:t.endScopeAnchor}}catch(r){return{kind:"failed",error:r}}}}}d(Y,"createAstScopeAnchorResolver");import{spawn as ue}from"node:child_process";import{readFile as pe,stat as W}from"node:fs/promises";import h from"node:path";function Q(a){return{id:"ast",async tryResolve(e,n){if(!e.query.startsWith("ast:"))return{kind:"not-handled"};let r=e.query.slice(4).trim();if(r.length===0)return{kind:"failed",error:new Error("ast: pattern must not be empty")};let t=d(async i=>{let l=Date.now(),c=await me(r,e,n.cwd,i);c.sort((p,f)=>h.resolve(n.cwd,p.file).localeCompare(h.resolve(n.cwd,f.file))||p.range.byteOffset.start-f.range.byteOffset.start||p.range.byteOffset.end-f.range.byteOffset.end);let u=c.slice(0,e.limit??100);return{raw:u,matches:await fe(u,n.cwd,l,i),complete:c.length<=(e.limit??100)}},"collect"),s=await t(n.signal),o=await a({request:e,matches:s.matches,complete:s.complete,refresh:t},n);return{kind:"resolved",payload:{pattern:r,matches:s.raw.map((i,l)=>({...i,selection:s.matches[l]})),complete:s.complete,sessionId:o.id}}},format(e){let n=e;if(n.matches.length===0)return{content:[{type:"text",text:"No AST matches found."}],details:n};let r=n.matches.flatMap((t,s)=>[`SEARCH#${n.sessionId}:${String(s+1)}:match ${t.file}:${String(t.range.start.line+1)}:${String(t.range.start.column+1)} ${t.language}`,` ${t.lines.trim()}`]);return n.complete&&r.unshift(`SEARCH#${n.sessionId}:all:match selects all exact AST matches.`),n.complete||r.push("Result limit reached."),{content:[{type:"text",text:r.join(`
7
+ `)}],details:n}}}}d(Q,"createAstSearchResolver");async function fe(a,e,n,r){let t=new Map;for(let s of a){let o=h.resolve(e,s.file);if(t.has(o))continue;let i=await W(o),l=await pe(o,{signal:r}),c=await W(o);if(i.mtimeMs>n||i.mtimeMs!==c.mtimeMs||i.size!==c.size)throw new Error("AST source changed during search. Run the structural query again.");t.set(o,l)}return a.map(s=>{let o=h.resolve(e,s.file),i=t.get(o);if(i===void 0)throw new Error("Missing AST source snapshot");let{start:l,end:c}=s.range.byteOffset;if(!Number.isInteger(l)||!Number.isInteger(c)||l<0||c<l||c>i.length||i.subarray(l,c).toString("utf8")!==s.text)throw new Error("AST range does not match its source snapshot. Search again.");let u=i.subarray(0,l).toString("utf8"),p=i.subarray(0,c).toString("utf8"),f=u.split(`
8
+ `).length;return{source:o,lineNumber:f,endLineNumber:p.split(`
9
+ `).length,startColumn:u.length-u.lastIndexOf(`
10
+ `)-1,endColumn:p.length-p.lastIndexOf(`
11
+ `)-1,matchedText:s.text,lineText:i.toString("utf8").split(`
12
+ `)[f-1]?.replace(/\r$/u,"")??""}})}d(fe,"selectionMatches");function me(a,e,n,r){let t=["run","--pattern",a,"--json=compact","--no-ignore","parent"];for(let s of Z(e.include))t.push("--globs",s);for(let s of Z(e.exclude))t.push("--globs",`!${s}`);return t.push(e.path??"."),new Promise((s,o)=>{let i=ue("ast-grep",t,{cwd:n,stdio:["ignore","pipe","pipe"]}),l="",c="";i.stdout.setEncoding("utf8"),i.stderr.setEncoding("utf8"),i.stdout.on("data",p=>l+=p),i.stderr.on("data",p=>c+=p);let u=d(()=>{i.kill("SIGTERM")},"abort");r?.addEventListener("abort",u,{once:!0}),i.once("error",o),i.once("close",p=>{if(r?.removeEventListener("abort",u),r?.aborted===!0){o(r.reason instanceof Error?r.reason:new Error("AST search aborted"));return}if(p!==0&&p!==1){o(new Error(c.trim()||`ast-grep exited with code ${String(p)}`));return}try{let f=JSON.parse(l.length===0?"[]":l);if(!Array.isArray(f))throw new TypeError("ast-grep returned non-array JSON");s(f)}catch(f){o(f instanceof Error?f:new Error(String(f)))}})})}d(me,"runAstGrep");function Z(a){return a?.split(",").map(e=>e.trim()).filter(Boolean)??[]}d(Z,"splitGlobs");var ge=$({kind:"code-view",label:"AST"});async function ee(a){let e=new V,n=K(e),r={protocol:k,apiVersion:P,id:"ast",setup(s){s.addResolver({resolver:F(),renderResult:ge}),s.addHandler({stage:"read",when:{resolvedBy:"ast",contentKind:"text"},handler:v()}),s.addView({view:"ast",presenter:n});let o=z();s.addOutputReducer(b);let i=U();s.addHandler({stage:"post-read",async handler(l){let c=await o(l);return c.kind==="return"?c:i(c.context)}}),s.describe('ast:<path> \u2014 compact declaration outline. views: ["ast"] \u2014 scope boundaries alongside source text. Oversized code reads may return an outline with source line numbers; offset/limit read a smaller source range.')}},t={protocol:I,apiVersion:C,id:"ast",setup(s){s.addAnchorResolver({resolver:Y(e),kind:N,type:"auxiliary"}),s.addTextPresenter({presenter:n})}};await Promise.all([M(a,r),E(a,G),_(a,t),D(a,{protocol:H,apiVersion:j,id:"ast-search",setup(s){s.addResolver({resolver:Q(s.registerSelection)}),s.describe("Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search. Use returned SEARCH# references to read, replace, copy, move or delete exact AST matches, including multiline nodes. A single :match reference becomes stale after its file changes; :all:match reruns the original structural query. Incomplete results do not provide all selections. Use captures in Apply to compute replacement text; these edits do not update imports or references.")}})])}d(ee,"registerAst");export{ee as default};
package/dist/entry-28.js CHANGED
@@ -1 +1 @@
1
- import{a as V,b as z,c as Q}from"./chunk-DEP55R35.js";import{a as O}from"./chunk-ERVMDQGX.js";import{a as L,b as N}from"./chunk-VFBLX4TG.js";import{a as M}from"./chunk-72EEL2DW.js";import{a as F,b as U}from"./chunk-KAB3AYA2.js";import{a as B}from"./chunk-TI5GMJ7Q.js";import{a as j,b as _}from"./chunk-Y7ZMR4LT.js";import"./chunk-S3ZPXWX7.js";import{a as H}from"./chunk-5VSE5X5R.js";import{d as $,e as D}from"./chunk-N34ATN52.js";import{a as x}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import{Value as De}from"typebox/value";import{access as ne}from"node:fs/promises";import re from"node:path";var K={protocol:L,apiVersion:1,id:"changes",setup(r){r.addSetupCheck({id:"git",async inspect(e){return await oe(e.cwd)?await $("git",e.cwd,e.env)?{}:{actions:[{id:"git-unavailable",message:"Git integration is unavailable because Git was not found"}]}:{}}}),r.addCheck({id:"git",title:"Git changes",async run(e){let t=await D("git",["--version"],e.cwd,e.env);return[t.ok?{status:"pass",message:"Git is available",detail:t.detail}:{status:"warn",message:"Git is not available; change anchors and index tools are disabled",detail:t.detail}]}})}};async function oe(r){try{return await ne(re.join(r,".git")),!0}catch{return!1}}a(oe,"isGitProject");import{mkdtemp as ie,rm as ae,writeFile as se}from"node:fs/promises";import de from"node:os";import m from"node:path";var b=class r{constructor(e,t){this.executor=e;this.repositoryRoot=t}static{a(this,"GitChangesBackend")}static async create(e,t,n){let o=await e.exec("git",["rev-parse","--show-toplevel"],{cwd:t,...n!==void 0&&{signal:n}});return o.code!==0?{status:"unavailable",reason:"no-worktree",message:o.stderr.trim()||"not inside a Git worktree"}:{status:"ready",backend:new r(e,m.resolve(o.stdout.trim()))}}async readTrackedFile(e,t,n){let o=m.resolve(t,e),i=m.relative(this.repositoryRoot,o);return i===".."||i.startsWith(`..${m.sep}`)||m.isAbsolute(i)?{status:"unavailable",reason:"outside-worktree",message:`${o} is outside ${this.repositoryRoot}`}:this.readTrackedRepositoryFile(i.split(m.sep).join("/"),n)}async readTrackedRepositoryFile(e,t){let n=await this.git(["rev-parse","--verify","HEAD"],t);if(n.code!==0)return{status:"unavailable",reason:"missing-head",message:n.stderr.trim()||"Git HEAD does not exist"};let o=await this.git(["--literal-pathspecs","ls-tree","-z","HEAD","--",e],t);if(o.code!==0)return{status:"unavailable",reason:"head-file-lookup-failed",message:o.stderr.trim()||`could not inspect HEAD:${e}`};let i=ce(o.stdout);if(i===void 0)return{status:"untracked"};let d=await this.readBlob(i.blob,"HEAD",e,t);if(d.status!=="found")return d;let c=await this.git(["--literal-pathspecs","ls-files","--stage","-z","--",e],t);if(c.code!==0)return{status:"unavailable",reason:"index-file-lookup-failed",message:c.stderr.trim()||`could not inspect the index entry for ${e}`};let s=ue(c.stdout);if(s.some(({stage:g})=>g!==0))return{status:"unavailable",reason:"conflicted",message:`${e} has unresolved Git index entries`};let u=s.find(({stage:g})=>g===0),l="";if(u!==void 0){let g=await this.readBlob(u.blob,"index",e,t);if(g.status!=="found")return g;l=g.text}return{status:"found",head:n.stdout.trim(),repositoryPath:e,repositoryRoot:this.repositoryRoot,headText:d.text,indexText:l,indexMode:u?.mode??i.mode}}async writeIndexFile(e,t,n,o){let i=await ie(m.join(de.tmpdir(),"pi-agent-index-")),d=m.join(i,"content");try{await se(d,n,"utf8");let c=await this.git(["hash-object","-w",`--path=${e}`,d],o);if(c.code!==0||c.stdout.trim().length===0)throw new Error(c.stderr.trim()||`could not write a Git blob for ${e}`);let s=await this.git(["update-index","--add","--cacheinfo",t,c.stdout.trim(),e],o);if(s.code!==0)throw new Error(s.stderr.trim()||`could not update the Git index entry for ${e}`)}finally{await ae(i,{recursive:!0,force:!0})}}async readBlob(e,t,n,o){let i=await this.git(["cat-file","blob",e],o);return i.code!==0?{status:"unavailable",reason:t==="HEAD"?"head-file-lookup-failed":"index-file-lookup-failed",message:i.stderr.trim()||`could not read ${t}:${n}`}:{status:"found",text:i.stdout}}git(e,t){return this.executor.exec("git",e,{cwd:this.repositoryRoot,...t!==void 0&&{signal:t}})}};function ce(r){let e=r.split("\0",1)[0];if(e===void 0||e.length===0)return;let t=e.indexOf(" ");if(t===-1)return;let[n,o,i]=e.slice(0,t).split(" ",3);return n===void 0||o!=="blob"||i===void 0?void 0:{mode:n,blob:i,path:e.slice(t+1)}}a(ce,"parseTreeEntry");function ue(r){return r.split("\0").filter(Boolean).flatMap(e=>{let t=e.indexOf(" ");if(t===-1)return[];let[n,o,i]=e.slice(0,t).split(" ",3),d=Number(i);return n===void 0||o===void 0||!Number.isInteger(d)?[]:[{mode:n,blob:o,stage:d,path:e.slice(t+1)}]})}a(ue,"parseIndexEntries");function W(r){return{exec:a((e,t,n)=>r.exec(e,t,n),"exec")}}a(W,"extensionGitExecutor");var p=class r{constructor(e){this.git=e}static{a(this,"ChangeService")}static async create(e,t,n){let o=await b.create(e,t,n);return o.status==="unavailable"?o:{status:"ready",service:new r(o.backend)}}async inspect(e){if(e.worktreeText.includes("\0"))return{status:"unavailable",reason:"binary",message:"worktree file contains binary content"};let t=await this.git.readTrackedFile(e.source,e.cwd,e.signal);if(t.status!=="found")return t.status==="untracked"?{status:"not-applicable",reason:"untracked"}:t;if(t.headText.includes("\0")||t.indexText.includes("\0"))return{status:"unavailable",reason:"binary",message:"Git file state contains binary content"};let n=V(t.repositoryPath,t.headText,t.indexText,e.worktreeText);return n.length===0?{status:"not-applicable",reason:"clean"}:{status:"applicable",head:t.head,repositoryRoot:t.repositoryRoot,repositoryPath:t.repositoryPath,groups:n}}async changeIndex(e,t,n){let o=await this.inspect(e);if(o.status!=="applicable")return o;let i=o.groups.find(u=>u.selector===t);if(i===void 0)return A(t,o.groups.map(({selector:u})=>u));let d=n==="stage"?"staged":"unstaged";if(i.state===d)return{status:"unchanged",state:d,group:i};let c=x(i.segments[0]),s={head:o.head,repositoryPath:o.repositoryPath,headStart:c.headStart,headEnd:c.headEnd,replacementText:n==="stage"?c.worktreeText:c.headText};try{await this.applyIndexUpdate(s,e.signal)}catch(u){return{status:"unavailable",reason:"index-write-failed",message:le(u)}}return{status:"applied",state:d,group:i}}async prepareUndo(e,t){let n=await this.inspect(e);if(n.status!=="applicable")return n;let o=n.groups.find(s=>s.selector===t);if(o===void 0)return A(t,n.groups.map(({selector:s})=>s));let i=z(e.worktreeText,o);if(i===void 0)return A(t,n.groups.map(({selector:s})=>s));let d=x(o.segments[0]),c=o.state==="unstaged"?void 0:{head:n.head,repositoryPath:n.repositoryPath,headStart:d.headStart,headEnd:d.headEnd,replacementText:d.headText};return{status:"applied",worktreeText:i,group:o,...c!==void 0&&{indexUpdate:c}}}async applyIndexUpdate(e,t){let n=await this.git.readTrackedRepositoryFile(e.repositoryPath,t);if(n.status!=="found")throw new Error(n.status==="untracked"?`${e.repositoryPath} is no longer tracked by HEAD`:n.message);if(n.head!==e.head)throw new Error(`Git HEAD changed while updating ${e.repositoryPath}`);let o=Q(n.headText,n.indexText,e.headStart,e.headEnd,e.replacementText);o!==n.indexText&&await this.git.writeIndexFile(e.repositoryPath,n.indexMode,o,t)}};function A(r,e){return{status:"unavailable",reason:"stale-selector",message:`${r} is not available in the current file state`,availableSelectors:e}}a(A,"staleSelector");function le(r){return r instanceof Error?r.message:String(r)}a(le,"errorMessage");var w="pi-agent-ide-changes/change",ge=/^CHANGE#[0-9A-F]{4,64}$/,fe=/^[A-Za-z][A-Za-z\d+.-]*:\/\//,G=class extends H{static{a(this,"ChangeTextAnchor")}constructor(e){super(e.selector,e.currentStartLine)}};function q(r){return{resolver:pe(a(async t=>{if(fe.test(t.source))return;let n=await p.create(r,t.cwd,t.signal);if(n.status!=="ready")throw new Error(n.message);return n.service.inspect({source:t.source,worktreeText:t.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}})},"inspect"))}}a(q,"createChangeAnchorRegistration");function pe(r){return{id:"git-change",description:"Use the complete `CHANGE#HASH` shown beside a current Git change.",renderFull(e){return e},renderCompact(e){return e},async tryResolve(e,t){if(!ge.test(e))return{kind:"not-handled"};try{let n=await r(t);if(n===void 0)return{kind:"not-handled"};if(n.status==="unavailable")return{kind:"failed",error:new Error(n.message)};let o=n.status==="applicable"?n.groups.find(i=>i.selector===e):void 0;return o===void 0?{kind:"rejected",rejection:{code:"stale",reason:`Change anchor ${e} is stale or unknown`}}:{kind:"resolved",anchor:new G(o)}}catch(n){return{kind:"failed",error:n}}}}}a(pe,"createChangeAnchorResolver");import{diffLines as he}from"diff";var me="filesystem";function X(r){return{id:"current-git-changes",async present(e,t){if(t.purpose!=="read"||t.resolvedBy!==me)return e;let n=await p.create(r,t.cwd,t.signal);if(n.status!=="ready")return e;let o=await n.service.inspect({source:t.source,worktreeText:e.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}});return o.status!=="applicable"?e:xe(e,o.groups)}}}a(X,"createCurrentChangePresenter");function xe(r,e){let t=new Map;for(let n of e)ye(r,n,t);return{...r,lines:r.lines.map(n=>we(n,t.get(n.lineNumber)))}}a(xe,"presentChangeGroups");function ye(r,e,t){let n=x(e.segments[0]),o=he(n.headText,n.worktreeText),i=e.currentStartLine,d,c;for(let s of o){let u=Ce(s.value);if(s.removed){let l=Te(r,i),g=R(t,l.lineNumber),f=l.after?g.after:g.before;for(let h of u){let y={kind:"synthetic",rows:f,index:f.length};f.push({marker:"-",prefix:"|",content:h}),d??=y,c=y}continue}if(s.added){for(let l of u){let g=R(t,i),f={kind:"current",lineNumber:i};g.added=!0,d??=f,c=f,i++}continue}i+=u.length}if(d!==void 0&&c!==void 0){let s=`${e.selector} \xB7 ${e.state}`;be(d,c)?I(t,d,`<!-- change: ${s} -->`):(I(t,d,`<!-- change-begin: ${s} -->`),I(t,c,`<!-- change-end: ${s} -->`))}}a(ye,"presentChangeGroup");function be(r,e){return r.kind==="current"&&e.kind==="current"?r.lineNumber===e.lineNumber:r.kind==="synthetic"&&e.kind==="synthetic"?r.rows===e.rows&&r.index===e.index:!1}a(be,"sameTarget");function I(r,e,t){if(e.kind==="current"){R(r,e.lineNumber).annotations.push(t);return}let n=x(e.rows[e.index]);e.rows[e.index]={...n,suffix:`${n.suffix??""} ${t}`}}a(I,"annotateTarget");function we(r,e){if(e===void 0)return r;let t=e.annotations.length===0?"":` ${e.annotations.join(" ")}`;return{...r,presentation:{...r.presentation,...e.added&&{marker:"+"},before:[...r.presentation?.before??[],...e.before],after:[...e.after,...r.presentation?.after??[]],suffix:`${r.presentation?.suffix??""}${t}`}}}a(we,"presentLine");function R(r,e){let t=r.get(e);if(t!==void 0)return t;let n={before:[],after:[],annotations:[],added:!1};return r.set(e,n),n}a(R,"presentationsFor");function Te(r,e){return e<=r.lines.length?{lineNumber:Math.max(1,e),after:!1}:{lineNumber:r.lines.length,after:!0}}a(Te,"placementFor");function Ce(r){if(r.length===0)return[];let e=r.split(/\r\n|\r|\n/u);return e.at(-1)===""&&e.pop(),e}a(Ce,"splitLines");var T=class{static{a(this,"IndexMutationQueue")}tail=Promise.resolve();run(e){let t=this.tail.then(e,e);return this.tail=t.then(()=>{},()=>{}),t}};import{createHash as ve}from"node:crypto";import{realpathSync as ke}from"node:fs";import J from"node:path";import{fileURLToPath as Ee}from"node:url";var v=class{static{a(this,"LastTextTransactionStore")}#e=new Map;observe(e){let t=Z(e.resourceSource,e.cwd);if(e.postProcessing==="final"){let n=this.#e.get(t);n&&n.afterDigest===C(e.before.content)?this.#e.set(t,{...n,afterDigest:C(e.after.content)}):this.#e.delete(t);return}if(e.intent!=="edit"||!e.existed||e.before.content===e.after.content){this.#e.delete(t);return}this.#e.set(t,{before:e.before.content,afterDigest:C(e.after.content)})}restore(e,t,n){let o=Z(e,t),i=this.#e.get(o);if(i===void 0)throw new Error(`No last text transaction is available for ${e}.`);if(i.afterDigest!==C(n))throw this.#e.delete(o),new Error(`${e} changed after its last text transaction; refusing to overwrite newer text.`);return i.before}};function Z(r,e){return r.startsWith("file://")?Y(Ee(new URL(r))):/^[a-z][a-z\d+.-]*:/iu.test(r)?r:Y(J.resolve(e,r))}a(Z,"sourceKey");function Y(r){try{return ke.native(r)}catch{return J.normalize(r)}}a(Y,"canonicalFile");function C(r){return ve("sha256").update(r).digest("hex")}a(C,"textDigest");import{readFile as Pe}from"node:fs/promises";import Ae from"node:path";import{defineTool as Ge,withFileMutationQueue as Ie}from"@earendil-works/pi-coding-agent";import{Type as S}from"typebox";var E=S.Object({file:S.String({description:"Path to the tracked text file"}),change:S.String({description:"Complete CHANGE#HASH anchor shown by read",pattern:"^CHANGE#[0-9A-F]{4,64}$"})},{additionalProperties:!1});function ee(r,e,t){r.registerTool(k("stage",e,t)),r.registerTool(k("unstage",e,t))}a(ee,"registerIndexChangeTools");function k(r,e,t){let n=r==="stage"?"staged":"unstaged",o=r==="stage"?"Staged":"Unstaged";return Ge({name:r,label:r,promptSnippet:`${o.slice(0,-1)} a selected Git change`,description:`Use ${r} to ${r==="stage"?"add one current Git change to the index":"remove one current Git change from the index"}. Select the change with a CHANGE# anchor; worktree content is kept.`,parameters:E,async execute(i,d,c,s,u){let l=Re(d.file,u.cwd);return Ie(l,()=>t.run(async()=>{let g=await Pe(l,"utf8"),f=await p.create(e,u.cwd,c);if(f.status!=="ready")throw new Error(f.message);let h=await f.service.changeIndex({source:l,worktreeText:g,cwd:u.cwd,...c!==void 0&&{signal:c}},d.change,r);if(h.status==="unavailable")throw new Error(h.message);if(h.status==="not-applicable")throw new Error(`${r} is not applicable to ${l}: ${h.reason}`);let y=h.status==="unchanged";return{content:[{type:"text",text:y?`${d.change} is already ${n} in ${d.file}.`:`${o} ${d.change} in ${d.file}.`}],details:{action:r,change:d.change,file:l,state:n,unchanged:y}}}))}})}a(k,"createIndexChangeTool");function Re(r,e){let t=r.startsWith("@")?r.slice(1):r;return Ae.resolve(e,t)}a(Re,"resolveFile");import{diffChars as Se}from"diff";import{Type as P}from"typebox";var He=P.Object({file:P.Optional(P.String({description:"File to restore; may be omitted to inherit the previous batched source"})),change:P.String({description:"Complete CHANGE#HASH anchor shown by read, or last for this file's latest text-editor transaction",pattern:"^(?:CHANGE#[0-9A-F]{4,64}|last)$"})},{additionalProperties:!1});function te(r,e,t){return{name:"undo",description:"Use undo to revert a selected uncommitted Git change or the latest text-editor transaction for one file. A CHANGE# anchor restores that change to HEAD in both worktree and index; last restores the file's state before its latest text-editor transaction.",promptSnippet:"Restore a Git change or the latest text edit",parameters:He,intent:"restore",source:{field:"file",inherited:!0},anchors:[{field:"change",sourceField:"file",kinds:[w],nonAnchorValues:["last"]}],async mutate(n,o){let i=n.sourceFor("file"),d,c;if(o.change==="last")d=e.restore(i,n.cwd,n.sourceDocument.content);else{await n.resolveAnchor("change");let s=await p.create(r,n.cwd,n.signal);if(s.status!=="ready")throw new Error(s.message);let u=await s.service.prepareUndo({source:i,worktreeText:n.sourceDocument.content,cwd:n.cwd,...n.signal!==void 0&&{signal:n.signal}},o.change);if(u.status!=="applied")throw u.status==="unavailable"?new Error(u.message):new Error(`Undo is not applicable to ${i}: ${u.reason}`);if(d=u.worktreeText,u.indexUpdate!==void 0){let l=u.indexUpdate;c=a(()=>t.run(()=>s.service.applyIndexUpdate(l,n.signal)),"afterWrite")}}return{edits:new Map([[i,{changes:$e(n.sourceDocument.content,d),action:"edited"}]]),...c!==void 0&&{afterWrite:c}}}}}a(te,"createUndoMutationTool");function $e(r,e){let t=[],n=0,o,i=0,d="",c=a(()=>{o!==void 0&&(t.push({from:o,to:o+i,insert:d}),o=void 0,i=0,d="")},"flush");for(let s of Se(r,e)){if(!s.added&&!s.removed){c(),n+=s.value.length;continue}o??=n,s.removed?(n+=s.value.length,i+=s.value.length):d+=s.value}return c(),t}a($e,"createTextChanges");async function Le(r){let e=W(r),t=new v,n=new T,o=X(e),i=q(e),d={protocol:F,apiVersion:U,id:"current-git-changes",setup(s){s.addView({view:"changes",presenter:o}),s.describe('views: ["changes"] \u2014 uncommitted edits in tracked files, staged/unstaged state, and CHANGE# anchors for stage, unstage and undo.')}},c={protocol:j,apiVersion:_,id:"current-git-changes",setup(s){s.addAnchorResolver({...i,kind:w,type:"auxiliary"}),s.onDidEdit(u=>{t.observe(u)}),s.addMutationTool(te(e,t,n));for(let u of["stage","unstage"]){let l=k(u,e,n);s.addScriptIndexOperation({name:u,parameters:E,execute:a((g,f,h)=>l.execute(`apply-${u}`,De.Decode(E,g),f,void 0,h),"execute")})}s.addTextPresenter({presenter:o})}};await Promise.all([O(r,K),M(r,d),B(r,c)]),ee(r,e,n)}a(Le,"registerGitChanges");export{Le as default};
1
+ import{a,b,c}from"./chunk-DEP55R35.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as createChangeGroups,c as replaceHeadRangeInIndex,b as reverseChangeGroup};