pi-agent-ide 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (377) hide show
  1. package/CHANGELOG.md +26 -40
  2. package/README.md +12 -7
  3. package/dist/{chunk-MOJ5RR35.js → chunk-246NTPOS.js} +1 -1
  4. package/dist/{chunk-NULNW6GK.js → chunk-2ITKAXHO.js} +1 -1
  5. package/dist/{chunk-SBNR4WZF.js → chunk-3WO2NOEQ.js} +1 -1
  6. package/dist/{chunk-N7LMRL64.js → chunk-47SPPIXK.js} +1 -1
  7. package/dist/{chunk-EY65TFHJ.js → chunk-4HWKBCBH.js} +1 -1
  8. package/dist/{chunk-JMVDFOTQ.js → chunk-57F5GTHO.js} +1 -1
  9. package/dist/{chunk-KL776TGR.js → chunk-7LOVUWNI.js} +1 -1
  10. package/dist/{chunk-7JV4VN73.js → chunk-A64JRDZK.js} +1 -1
  11. package/dist/{chunk-Z3PGADVA.js → chunk-AIT3YWR5.js} +1 -1
  12. package/dist/{chunk-E4HPRLRB.js → chunk-AKNHSDGV.js} +1 -1
  13. package/dist/{chunk-4XPUN4QN.js → chunk-AUL5FGGK.js} +1 -1
  14. package/dist/chunk-BB4A5UI3.js +5 -0
  15. package/dist/{chunk-CTJV77FR.js → chunk-BQAKA3FU.js} +1 -1
  16. package/dist/{chunk-PNP2KNGP.js → chunk-BR7GRH4A.js} +1 -1
  17. package/dist/{chunk-4OYVLXWD.js → chunk-D4IA2MTA.js} +1 -1
  18. package/dist/{chunk-R5XJSEOE.js → chunk-DXONCYWF.js} +3 -3
  19. package/dist/{chunk-TWWND6NI.js → chunk-E2PHA4SQ.js} +1 -1
  20. package/dist/{chunk-MZXX353D.js → chunk-EMRJP6EM.js} +1 -1
  21. package/dist/{chunk-7HDK3NRQ.js → chunk-GEMDU6XW.js} +1 -1
  22. package/dist/chunk-GNACBJM3.js +1 -0
  23. package/dist/{chunk-3G54ZL2L.js → chunk-HCK7OIQ3.js} +1 -1
  24. package/dist/chunk-HFJGCYFO.js +11 -0
  25. package/dist/{chunk-CSXHCSTH.js → chunk-ID4RJIVZ.js} +1 -1
  26. package/dist/{chunk-SBLKPTL3.js → chunk-JKMXND6V.js} +1 -1
  27. package/dist/{chunk-WE42GBGU.js → chunk-LAJQSHEI.js} +1 -1
  28. package/dist/{chunk-HCN5W76B.js → chunk-LLRUJD62.js} +1 -1
  29. package/dist/{chunk-2K65BSXS.js → chunk-M4TVRCMZ.js} +1 -1
  30. package/dist/{chunk-IUSLSROY.js → chunk-N56WAVYA.js} +1 -1
  31. package/dist/chunk-OI3HBIPK.js +2 -0
  32. package/dist/{chunk-GW6NZQTQ.js → chunk-PRLIHLCS.js} +1 -1
  33. package/dist/{chunk-7TJ6DWW3.js → chunk-Q5X6OXNS.js} +1 -1
  34. package/dist/{chunk-75SWXD2Z.js → chunk-SWA5B5B2.js} +1 -1
  35. package/dist/chunk-T7MWQQIF.js +3 -0
  36. package/dist/{chunk-ICDI27GZ.js → chunk-TGC2ZACO.js} +1 -1
  37. package/dist/{chunk-7NS3QUIE.js → chunk-TXG2H7YQ.js} +1 -1
  38. package/dist/{chunk-RAZP42IQ.js → chunk-VAXLSPPU.js} +1 -1
  39. package/dist/chunk-VMGZMXEM.js +10 -0
  40. package/dist/{chunk-CPZJPGLG.js → chunk-VNTY7BKC.js} +1 -1
  41. package/dist/chunk-W3YFF6OO.js +1 -0
  42. package/dist/{chunk-OLI3JPHJ.js → chunk-W7M3V7FR.js} +1 -1
  43. package/dist/{chunk-UUJJRXHG.js → chunk-WMHSVEIT.js} +1 -1
  44. package/dist/{chunk-OJX3RJ5A.js → chunk-WPBQ45ZL.js} +1 -1
  45. package/dist/{chunk-XZDOVPRC.js → chunk-WXGTU2M6.js} +1 -1
  46. package/dist/{chunk-3ZGDMTMD.js → chunk-XSIKDVAR.js} +1 -1
  47. package/dist/{chunk-QP2QSQ4U.js → chunk-YHREORHH.js} +1 -1
  48. package/dist/chunk-YTYLS2UM.js +1 -0
  49. package/dist/chunk-Z2QGNTGQ.js +1 -0
  50. package/dist/{chunk-UBH6X3D3.js → chunk-ZV5ETNLQ.js} +1 -1
  51. package/dist/entry-11.js +1 -1
  52. package/dist/entry-13.js +1 -1
  53. package/dist/entry-14.js +1 -1
  54. package/dist/entry-15.js +1 -1
  55. package/dist/entry-16.js +1 -1
  56. package/dist/entry-17.js +1 -1
  57. package/dist/entry-18.js +1 -0
  58. package/dist/entry-20.js +1 -1
  59. package/dist/entry-21.js +1 -1
  60. package/dist/entry-22.js +1 -1
  61. package/dist/entry-23.js +1 -1
  62. package/dist/entry-24.js +1 -1
  63. package/dist/entry-25.js +1 -1
  64. package/dist/entry-26.js +1 -2
  65. package/dist/entry-27.js +2 -1
  66. package/dist/entry-28.js +1 -4
  67. package/dist/entry-29.js +4 -1
  68. package/dist/entry-30.js +1 -1
  69. package/dist/entry-31.js +1 -1
  70. package/dist/entry-32.js +1 -18
  71. package/dist/entry-33.js +18 -1
  72. package/dist/entry-34.js +1 -1
  73. package/dist/entry-35.js +1 -1
  74. package/dist/entry-36.js +1 -1
  75. package/dist/entry-37.js +1 -1
  76. package/dist/entry-38.js +1 -1
  77. package/dist/entry-39.js +1 -1
  78. package/dist/entry-40.js +1 -1
  79. package/dist/entry-41.js +1 -1
  80. package/dist/entry-42.js +1 -1
  81. package/dist/entry-43.js +1 -1
  82. package/dist/entry-44.js +1 -1
  83. package/dist/entry-45.js +1 -1
  84. package/dist/entry-46.js +1 -25
  85. package/dist/entry-47.js +25 -1
  86. package/dist/entry-48.js +1 -1
  87. package/dist/entry-49.js +1 -1
  88. package/dist/entry-50.js +1 -1
  89. package/dist/entry-51.js +1 -3
  90. package/dist/entry-52.js +3 -13
  91. package/dist/entry-53.js +13 -1
  92. package/dist/entry-54.js +1 -1
  93. package/dist/entry-55.js +1 -1
  94. package/dist/entry-56.js +1 -1
  95. package/dist/entry-57.js +1 -1
  96. package/dist/entry-58.js +1 -1
  97. package/dist/entry-59.js +1 -1
  98. package/dist/entry-6.js +1 -1
  99. package/dist/entry-60.js +1 -1
  100. package/dist/entry-61.js +1 -1
  101. package/dist/entry-62.js +1 -0
  102. package/dist/entry-63.js +0 -1
  103. package/dist/entry-64.js +1 -0
  104. package/dist/entry-65.js +0 -1
  105. package/dist/entry-66.js +1 -1
  106. package/dist/entry-67.js +1 -1
  107. package/dist/entry-68.js +1 -1
  108. package/dist/entry-69.js +1 -1
  109. package/dist/entry-7.js +1 -1
  110. package/dist/entry-70.js +1 -1
  111. package/dist/entry-71.js +1 -1
  112. package/dist/entry-72.js +1 -0
  113. package/dist/entry-73.js +0 -1
  114. package/dist/entry-74.js +1 -0
  115. package/dist/entry-75.js +0 -1
  116. package/dist/entry-76.js +1 -1
  117. package/dist/entry-77.js +1 -1
  118. package/dist/entry-78.js +1 -80
  119. package/dist/entry-79.js +76 -17
  120. package/dist/entry-80.js +22 -2
  121. package/dist/entry-81.js +2 -1
  122. package/dist/entry-82.js +1 -1
  123. package/dist/entry-83.js +1 -1
  124. package/dist/entry-84.js +1 -3
  125. package/dist/entry-85.js +3 -1
  126. package/dist/entry-86.js +1 -1
  127. package/dist/entry-87.js +1 -1
  128. package/dist/entry-88.js +1 -0
  129. package/dist/pi-agent-ide.js +53 -24
  130. package/docs/agent-guides/search-code.md +3 -1
  131. package/docs/agent-guides/ssh.md +1 -1
  132. package/docs/configuration.md +18 -6
  133. package/docs/development.md +1 -13
  134. package/docs/extensions.md +1 -1
  135. package/docs/releases.md +1 -1
  136. package/docs/settings-help.md +39 -0
  137. package/docs/tools.md +1 -0
  138. package/docs/user-hooks.md +3 -1
  139. package/node_modules/pi-agent-doctor/package.json +7 -10
  140. package/node_modules/pi-agent-documentation/package.json +2 -2
  141. package/node_modules/pi-agent-documentation/runtime/entry-26.js +1 -0
  142. package/node_modules/pi-agent-filesystem/package.json +8 -8
  143. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  144. package/node_modules/pi-agent-filesystem-jq/package.json +6 -7
  145. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  146. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  147. package/node_modules/pi-agent-filesystem-text/runtime/entry-31.js +2 -0
  148. package/node_modules/pi-agent-ide-ast/package.json +15 -41
  149. package/node_modules/pi-agent-ide-ast/runtime/entry-32.js +0 -1
  150. package/node_modules/pi-agent-ide-ast/runtime/entry-33.js +2 -0
  151. package/node_modules/pi-agent-ide-changes/package.json +10 -11
  152. package/node_modules/pi-agent-ide-changes/runtime/entry-34.js +0 -1
  153. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  154. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  155. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  156. package/node_modules/pi-agent-ide-lsp/package.json +10 -13
  157. package/node_modules/pi-agent-ide-lsp/runtime/entry-39.js +2 -0
  158. package/node_modules/pi-agent-image/package.json +3 -3
  159. package/node_modules/pi-agent-invariant/package.json +2 -2
  160. package/node_modules/pi-agent-pdf/package.json +3 -4
  161. package/node_modules/pi-agent-read/package.json +12 -12
  162. package/node_modules/pi-agent-read/runtime/entry-46.js +0 -1
  163. package/node_modules/pi-agent-read/runtime/entry-47.js +2 -0
  164. package/node_modules/pi-agent-resource/package.json +2 -2
  165. package/node_modules/pi-agent-resource/src/result-targets.ts +9 -0
  166. package/node_modules/pi-agent-search/package.json +9 -9
  167. package/node_modules/pi-agent-search/runtime/entry-51.js +0 -1
  168. package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  169. package/node_modules/pi-agent-search/src/api/presentation.ts +10 -2
  170. package/node_modules/pi-agent-search/src/api/search-parameters.ts +1 -1
  171. package/node_modules/pi-agent-search/src/api/search.ts +7 -0
  172. package/node_modules/pi-agent-search/src/core/search-core.ts +23 -3
  173. package/node_modules/pi-agent-search-text/index.ts +2 -0
  174. package/node_modules/pi-agent-search-text/package.json +14 -14
  175. package/node_modules/pi-agent-search-text/runtime/entry-53.js +1 -0
  176. package/node_modules/pi-agent-search-text/src/search-backend.ts +18 -10
  177. package/node_modules/pi-agent-search-text/src/search-session.ts +68 -9
  178. package/node_modules/pi-agent-text/package.json +3 -3
  179. package/node_modules/pi-agent-text/runtime/entry-57.js +1 -0
  180. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  181. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-58.js +2 -0
  182. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -6
  183. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-59.js +0 -1
  184. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-60.js +2 -0
  185. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  186. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-61.js +0 -1
  187. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-62.js +2 -0
  188. package/node_modules/pi-agent-text-editor/package.json +26 -34
  189. package/node_modules/pi-agent-text-editor/runtime/entry-78.js +0 -1
  190. package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +1 -1
  191. package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
  192. package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +6 -12
  193. package/node_modules/pi-agent-text-editor/src/core/extension.ts +1 -0
  194. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +49 -21
  195. package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +18 -9
  196. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +2 -2
  197. package/node_modules/pi-agent-text-editor/src/core/temporary-directories.ts +13 -9
  198. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +16 -8
  199. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +118 -36
  200. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +7 -4
  201. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +6 -8
  202. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +22 -1
  203. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -8
  204. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +22 -0
  205. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  206. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +2 -0
  207. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  208. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  209. package/node_modules/pi-agent-tool-ui/runtime/entry-83.js +1 -0
  210. package/node_modules/pi-agent-web/package.json +8 -11
  211. package/node_modules/pi-agent-web-html/package.json +3 -5
  212. package/node_modules/pi-agent-web-image/package.json +4 -4
  213. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  214. package/node_modules/pi-agent-web-text/package.json +4 -4
  215. package/node_modules/pi-agent-web-text/runtime/entry-88.js +2 -0
  216. package/package.json +43 -39
  217. package/skills/configure-agent-ide/SKILL.md +38 -0
  218. package/src/api/content.ts +6 -0
  219. package/src/api/tips.ts +3 -0
  220. package/src/composite/nested-tool-rendering.ts +16 -5
  221. package/src/composite/preferences.ts +13 -0
  222. package/src/composite/settings-documentation.ts +59 -0
  223. package/src/composite/settings-help.ts +106 -0
  224. package/src/composite/text-results.ts +50 -22
  225. package/src/documentation/extension.ts +12 -0
  226. package/src/documentation/search.ts +166 -0
  227. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
  228. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  229. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +6 -7
  230. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  231. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  232. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-31.js +2 -0
  233. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-27.js +2 -0
  234. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -11
  235. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -5
  236. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  237. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  238. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  239. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-88.js +2 -0
  240. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-84.js +2 -0
  241. package/src/extensions/pi-agent-read/package.json +12 -12
  242. package/src/extensions/pi-agent-read/runtime/entry-46.js +0 -1
  243. package/src/extensions/pi-agent-read/runtime/entry-47.js +2 -0
  244. package/src/extensions/pi-agent-search/package.json +9 -9
  245. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +2 -0
  246. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +14 -14
  247. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +1 -0
  248. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-56.js +1 -0
  249. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +18 -10
  250. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +68 -9
  251. package/src/extensions/pi-agent-search/runtime/entry-51.js +0 -1
  252. package/src/extensions/pi-agent-search/runtime/entry-52.js +2 -0
  253. package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  254. package/src/extensions/pi-agent-search/src/api/presentation.ts +10 -2
  255. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +1 -1
  256. package/src/extensions/pi-agent-search/src/api/search.ts +7 -0
  257. package/src/extensions/pi-agent-search/src/core/search-core.ts +23 -3
  258. package/src/extensions/pi-agent-text-editor/package.json +26 -34
  259. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  260. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-58.js +2 -0
  261. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -6
  262. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-59.js +0 -1
  263. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-60.js +2 -0
  264. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  265. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-61.js +0 -1
  266. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-62.js +2 -0
  267. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -8
  268. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +22 -0
  269. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  270. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +2 -0
  271. package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +0 -1
  272. package/src/extensions/pi-agent-text-editor/runtime/entry-79.js +2 -0
  273. package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +1 -1
  274. package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
  275. package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +6 -12
  276. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +1 -0
  277. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +49 -21
  278. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +18 -9
  279. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +2 -2
  280. package/src/extensions/pi-agent-text-editor/src/core/temporary-directories.ts +13 -9
  281. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +16 -8
  282. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +118 -36
  283. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +7 -4
  284. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +6 -8
  285. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +22 -1
  286. package/src/pi-agent-ide.ts +14 -2
  287. package/src/plugins/pi-agent-ide-ast/package.json +15 -41
  288. package/src/plugins/pi-agent-ide-ast/runtime/entry-32.js +0 -1
  289. package/src/plugins/pi-agent-ide-ast/runtime/entry-33.js +2 -0
  290. package/src/plugins/pi-agent-ide-changes/package.json +10 -11
  291. package/src/plugins/pi-agent-ide-changes/runtime/entry-34.js +0 -1
  292. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  293. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  294. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  295. package/src/plugins/pi-agent-ide-lsp/package.json +10 -13
  296. package/src/plugins/pi-agent-ide-lsp/runtime/entry-39.js +2 -0
  297. package/src/tips/core.ts +5 -2
  298. package/src/tips/extension.ts +30 -2
  299. package/src/tips/persistence.ts +29 -27
  300. package/src/tips/setup-hint.ts +19 -0
  301. package/dist/chunk-5KFVDYCI.js +0 -1
  302. package/dist/chunk-ABFCAOU5.js +0 -1
  303. package/dist/chunk-BIG45IPN.js +0 -2
  304. package/dist/chunk-BMOJTJJJ.js +0 -3
  305. package/dist/chunk-BQ67M4NC.js +0 -3
  306. package/dist/chunk-IH5NW5JX.js +0 -11
  307. package/dist/chunk-NRZO5KJT.js +0 -9
  308. package/dist/chunk-O36UC74T.js +0 -1
  309. package/dist/chunk-SSWUUBIR.js +0 -1
  310. package/dist/entry-19.js +0 -1
  311. package/docs/research/apply-native-capability-matrix.md +0 -174
  312. package/docs/research/apply-read-latency.md +0 -221
  313. package/docs/research/codemode-write-context.md +0 -56
  314. package/docs/research/lpt-393-fuzzy-results/file.json +0 -152
  315. package/docs/research/lpt-393-fuzzy-results/repo.json +0 -122
  316. package/docs/research/lpt-393-search-fuzzy-fallback.md +0 -97
  317. package/docs/research/native-codemode-batch-decision.md +0 -31
  318. package/docs/research/native-codemode-batching.md +0 -65
  319. package/node_modules/pi-agent-doctor/runtime/entry-19.js +0 -1
  320. package/node_modules/pi-agent-filesystem/runtime/entry-26.js +0 -2
  321. package/node_modules/pi-agent-ide-ast/runtime/entry-31.js +0 -1
  322. package/node_modules/pi-agent-ide-changes/runtime/entry-33.js +0 -1
  323. package/node_modules/pi-agent-image/runtime/entry-39.js +0 -1
  324. package/node_modules/pi-agent-resource/runtime/entry-47.js +0 -1
  325. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-57.js +0 -2
  326. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-58.js +0 -1
  327. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-60.js +0 -1
  328. package/node_modules/pi-agent-text-editor/runtime/entry-62.js +0 -1
  329. package/node_modules/pi-agent-tool-call-interception/runtime/entry-81.js +0 -1
  330. package/node_modules/pi-agent-web/runtime/entry-83.js +0 -2
  331. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-27.js +0 -2
  332. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-26.js +0 -2
  333. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-84.js +0 -2
  334. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +0 -2
  335. package/src/extensions/pi-agent-read/runtime/entry-42.js +0 -1
  336. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-52.js +0 -2
  337. package/src/extensions/pi-agent-search/runtime/entry-48.js +0 -1
  338. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-57.js +0 -2
  339. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-58.js +0 -1
  340. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-60.js +0 -1
  341. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-79.js +0 -2
  342. package/src/extensions/pi-agent-text-editor/runtime/entry-62.js +0 -1
  343. package/src/plugins/pi-agent-ide-ast/runtime/entry-31.js +0 -1
  344. package/src/plugins/pi-agent-ide-changes/runtime/entry-33.js +0 -1
  345. /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-25.js +0 -0
  346. /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-27.js +0 -0
  347. /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-28.js +0 -0
  348. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-29.js +0 -0
  349. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-30.js +0 -0
  350. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-35.js +0 -0
  351. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-36.js +0 -0
  352. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-37.js +0 -0
  353. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-38.js +0 -0
  354. /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-40.js +0 -0
  355. /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-41.js +0 -0
  356. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-42.js +0 -0
  357. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-48.js +0 -0
  358. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-52.js +0 -0
  359. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-56.js +0 -0
  360. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-79.js +0 -0
  361. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-80.js +0 -0
  362. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-82.js +0 -0
  363. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-84.js +0 -0
  364. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-85.js +0 -0
  365. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-86.js +0 -0
  366. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-87.js +0 -0
  367. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-28.js +0 -0
  368. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-29.js +0 -0
  369. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-30.js +0 -0
  370. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-85.js +0 -0
  371. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-86.js +0 -0
  372. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-87.js +0 -0
  373. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-80.js +0 -0
  374. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-35.js +0 -0
  375. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-36.js +0 -0
  376. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-37.js +0 -0
  377. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-38.js +0 -0
@@ -1,4 +1,4 @@
1
- import{a as le,b as fe,c as ue}from"./chunk-HCN5W76B.js";import{a as de}from"./chunk-7TJ6DWW3.js";import{a as N,g as l}from"./chunk-EY65TFHJ.js";import{c as ce}from"./chunk-W7CASEO3.js";import{e as q,f as Z}from"./chunk-T7I2VX3J.js";import{a as ne}from"./chunk-2K65BSXS.js";import{b as te,c as re,d as oe}from"./chunk-ICDI27GZ.js";import"./chunk-NNCZYO4Q.js";import{d as ee}from"./chunk-IICJXZBU.js";import{a as G}from"./chunk-BU7IZLKB.js";import{a as H,b as V}from"./chunk-S5PL5DFQ.js";import{a as se}from"./chunk-N7LMRL64.js";import{a as ie,b as ae}from"./chunk-RAZP42IQ.js";import"./chunk-PS2B6THP.js";import{F as z}from"./chunk-R5XJSEOE.js";import{r as J}from"./chunk-ZPT5D4VP.js";import{a as X}from"./chunk-ZAWRSA7N.js";import{a as x,b as Q}from"./chunk-OFILFO6D.js";import"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import pe from"node:path";import{StringDecoder as Oe}from"node:string_decoder";function he(r){return(i,a)=>{let n=r.resolve(i.path??".",a.cwd);if(n===void 0)return;let{backend:c,location:w}=n,e=s((t,o=w.source)=>{let m=r.resolve(t,o);if(m===void 0||m.backend!==c)throw new l("UNSUPPORTED_SOURCE",t,"not-applied");return m.location},"own");return{resolve:s((t,o)=>e(o,t.includes("://")?t:w.source).source,"resolve"),dirname:s(t=>N(w.target,pe.posix.dirname(e(t).path)).source,"dirname"),basename:s(t=>pe.posix.basename(e(t).path),"basename"),isDirectory:s(async(t,o)=>(await c.stat(e(t).path,{signal:o})).kind==="directory","isDirectory"),byteSize:s(async(t,o)=>(await c.stat(e(t).path,{signal:o})).size,"byteSize"),readText:s(async(t,o)=>(await c.read(e(t).path,{signal:o})).bytes.toString("utf8"),"readText"),async execute(t,o,m,R){let d=await c.execute(t,o,e(m).path,{signal:R});return{code:d.exitCode,stdout:d.stdout.toString("utf8"),stderr:d.stderr.toString("utf8")}},async runLines(t,o,m,R){let d=await c.startProcess("rg",t,e(o).path,{signal:R}),g=new Oe("utf8"),u=[],p=0,f="",h,y=s(k=>{let E=k.split(`
1
+ import{a as le,b as fe,c as ue}from"./chunk-LLRUJD62.js";import{a as de}from"./chunk-Q5X6OXNS.js";import{a as N,g as l}from"./chunk-4HWKBCBH.js";import{a as se}from"./chunk-47SPPIXK.js";import{a as ie,b as ae}from"./chunk-VAXLSPPU.js";import{c as ce}from"./chunk-W7CASEO3.js";import{e as q,f as Z}from"./chunk-T7I2VX3J.js";import{a as ne}from"./chunk-M4TVRCMZ.js";import{b as te,c as re,d as oe}from"./chunk-TGC2ZACO.js";import"./chunk-NNCZYO4Q.js";import{d as ee}from"./chunk-IICJXZBU.js";import"./chunk-PS2B6THP.js";import{a as G}from"./chunk-BU7IZLKB.js";import{a as H,b as V}from"./chunk-S5PL5DFQ.js";import{F as z}from"./chunk-DXONCYWF.js";import{r as J}from"./chunk-ZPT5D4VP.js";import{a as X}from"./chunk-ZAWRSA7N.js";import{a as x,b as Q}from"./chunk-OFILFO6D.js";import"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import pe from"node:path";import{StringDecoder as Oe}from"node:string_decoder";function he(r){return(i,a)=>{let n=r.resolve(i.path??".",a.cwd);if(n===void 0)return;let{backend:c,location:w}=n,e=s((t,o=w.source)=>{let m=r.resolve(t,o);if(m===void 0||m.backend!==c)throw new l("UNSUPPORTED_SOURCE",t,"not-applied");return m.location},"own");return{resolve:s((t,o)=>e(o,t.includes("://")?t:w.source).source,"resolve"),dirname:s(t=>N(w.target,pe.posix.dirname(e(t).path)).source,"dirname"),basename:s(t=>pe.posix.basename(e(t).path),"basename"),isDirectory:s(async(t,o)=>(await c.stat(e(t).path,{signal:o})).kind==="directory","isDirectory"),byteSize:s(async(t,o)=>(await c.stat(e(t).path,{signal:o})).size,"byteSize"),readText:s(async(t,o)=>(await c.read(e(t).path,{signal:o})).bytes.toString("utf8"),"readText"),async execute(t,o,m,R){let d=await c.execute(t,o,e(m).path,{signal:R});return{code:d.exitCode,stdout:d.stdout.toString("utf8"),stderr:d.stderr.toString("utf8")}},async runLines(t,o,m,R){let d=await c.startProcess("rg",t,e(o).path,{signal:R}),g=new Oe("utf8"),u=[],p=0,f="",h,y=s(k=>{let E=k.split(`
2
2
  `);for(let[O,b]of E.entries()){if(u.push(b),p+=Buffer.byteLength(b),p>32*1024*1024)throw new l("CONTENT_LIMIT",w.source,"not-applied");O<E.length-1&&(m(u.join("")),u.length=0,p=0)}},"consume"),v=(async()=>{try{for await(let k of d.stdout)y(g.write(k));y(g.end()),p>0&&m(u.join(""))}catch(k){h=k,await d.stop()}})(),T=(async()=>{for await(let k of d.stderr)f+=k.toString("utf8"),f.length>65536&&(f=f.slice(-65536))})();try{try{await d.end()}catch(E){if(!(E instanceof l)||E.code!=="INPUT_CLOSED")throw E}let k=await d.completion;if(await Promise.all([v,T]),h!==void 0)throw h instanceof Error?h:new Error("Search output failed.",{cause:h});return R?.throwIfAborted(),{code:k.exitCode,stderr:f}}finally{await d.stop(),await Promise.allSettled([v,T])}}}}}s(he,"createSshSearchEnvironmentProvider");import{lstat as Ue,mkdir as ke,rm as Me,symlink as He,unlink as Ve,open as Ge}from"node:fs/promises";import A from"node:path";import{constants as $}from"node:fs";import{createHash as Pe,randomBytes as Te}from"node:crypto";import{constants as we}from"node:fs";import{lstat as Ie,mkdir as Ne,open as me,readFile as Ce,rename as _e,rm as Ae,unlink as Fe}from"node:fs/promises";import D from"node:path";import{fileURLToPath as Le}from"node:url";function C(r,i,a){if(a?.has(r)&&a.get(r)!==i)throw new l("CONFLICT",r,"not-applied")}s(C,"checkCapturedRevision");var Be=1024*1024,De=Ce(new URL("./ssh-transfer-worker.py",new URL("../src/backend/file-transfer.ts",import.meta.url).href),"utf8");function j(r,i){if(r.startsWith("file:"))try{return Le(r)}catch{throw new l("UNSUPPORTED_SOURCE",r,"not-applied")}if(/^[a-z][a-z\d+.-]*:/iu.test(r)&&!/^[a-z]:[\\/]/iu.test(r))throw new l("UNSUPPORTED_SOURCE",r,"not-applied");if(i.startsWith("ssh://"))throw new l("UNSUPPORTED_SOURCE",r,"not-applied");return D.resolve(i,r)}s(j,"localTransferSource");function F(r){return[r.dev,r.ino,r.mode,r.uid,r.gid,r.size,r.mtimeNs,r.ctimeNs].join(":")}s(F,"localRevision");async function U(r){let i=await Ie(r,{bigint:!0});if(!i.isFile()||i.isSymbolicLink())throw new l("INVALID_FILE_TYPE",r,"not-applied");if(i.size>BigInt(Number.MAX_SAFE_INTEGER))throw new l("CONTENT_LIMIT",r,"not-applied");return i}s(U,"localEntry");function ye(r){return r!==null&&typeof r=="object"&&"code"in r&&r.code==="ENOENT"}s(ye,"missing");function ge(r){return r!==null&&typeof r=="object"&&"code"in r&&typeof r.code=="string"&&/^[A-Z][A-Z0-9_]*$/u.test(r.code)?r.code:"TRANSFER_FAILED"}s(ge,"errorCode");async function je(r,i,a,n){a.signal?.throwIfAborted();let c=r.resolve(i.path,a.cwd),w=r.resolve(i.target??"",a.cwd),e=c?.location.source??j(i.path,a.cwd),t=w?.location.source??j(i.target??"",a.cwd);if(e===t)throw new l("SAME_FILE",e,"not-applied");let o=c?await c.backend.lstat(c.location.path,a):await U(e);if("kind"in o&&o.kind!=="file")throw new l("INVALID_FILE_TYPE",e,"not-applied");let m=Number(o.size),R=Number(o.mode),d="revision"in o?o.revision:F(o);C(e,d,n);let g;try{g=w?await w.backend.lstat(w.location.path,a):await U(t)}catch(p){if(!ye(p))throw p}if(g!==void 0){if("kind"in g&&g.kind!=="file")throw new l("INVALID_FILE_TYPE",t,"not-applied");if(C(t,"revision"in g?g.revision:F(g),n),c&&w&&c.backend.target.host===w.backend.target.host&&c.backend.target.configFile===w.backend.target.configFile&&"identity"in o&&"identity"in g&&o.identity.device===g.identity.device&&o.identity.inode===g.identity.inode)throw new l("SAME_FILE",e,"not-applied")}let u=g===void 0?null:"revision"in g?g.revision:F(g);return g===void 0&&C(t,null,n),{source:e,target:t,remoteSource:c,remoteTarget:w,size:m,mode:R,sourceRevision:d,targetRevision:u}}s(je,"prepareTransfer");async function Y(r,i,a,n,c,w){let{source:e,target:t,remoteSource:o,remoteTarget:m,size:R,mode:d,sourceRevision:g,targetRevision:u}=await je(r,a,n,c);await w?.();let p=o?void 0:await me(e,we.O_RDONLY|we.O_NOFOLLOW),f,h,y,v=!1,T="",k=s(async()=>{let E=o?await o.backend.lstat(o.location.path,n):await U(e);if(("revision"in E?E.revision:F(E))!==g)throw new l("CONFLICT",e,"not-applied")},"verifySource");try{if(p&&F(await p.stat({bigint:!0}))!==g)throw new l("CONFLICT",e,"not-applied");m?(y=await de(m.backend.target,"python3",["-c",await De,JSON.stringify({destination:m.location.path,size:R,mode:d,expected:u})],"/",n),y.completion.catch(()=>{}),y.stdout.on("data",b=>{T.length<=8192&&(T+=b.toString("utf8")),T.length>8192&&y?.stop().catch(()=>{})}),y.stderr.resume()):(await Ne(D.dirname(t),{recursive:!0}),f=D.join(D.dirname(t),`.pi-ide-transfer-${Te(12).toString("hex")}`),h=await me(f,"wx",d&4095));let E=Pe("sha256");for(let b=0;b<R;){n.signal?.throwIfAborted();let S=Math.min(Be,R-b),I;if(o){let P=await o.backend.readRange(o.location.path,b,S,n);if(P.revision!==g||P.offset!==b||P.totalBytes!==R)throw new l("CONFLICT",e,"not-applied");I=P.bytes}else{if(p===void 0)throw new Error("Missing source descriptor");let P=Buffer.allocUnsafe(S),{bytesRead:B}=await p.read(P,0,S,b);I=P.subarray(0,B)}if(I.length===0)throw new l("CONFLICT",e,"not-applied");if(E.update(I),y)await y.write(I);else{if(h===void 0)throw new Error("Missing destination descriptor");for(let P=0;P<I.length;){let B=await h.write(I,P,I.length-P);if(B.bytesWritten===0)throw new l("TRANSFER_FAILED",t,"not-applied");P+=B.bytesWritten}}b+=I.length}await k(),await w?.();let O=E.digest("hex");if(n.signal?.throwIfAborted(),y){if(await y.write(Buffer.from(`${JSON.stringify({sha256:O})}
3
3
  `)),await y.end(),(await y.completion).exitCode!==0||T.length>8192)throw new l("TRANSFER_FAILED",t,"unknown");let S;try{S=JSON.parse(T)}catch{throw new l("INVALID_REPLY",t,"unknown")}if(S===null||typeof S!="object"||!("ok"in S))throw new l("INVALID_REPLY",t,"unknown");if(S.ok!==!0){let I="effect"in S&&(S.effect==="not-applied"||S.effect==="applied")?S.effect:"unknown";throw new l(ge(S),t,I)}if(!("sha256"in S)||S.sha256!==O)throw new l("CHECKSUM_MISMATCH",t,"unknown");v=!0}else{if(h===void 0||f===void 0)throw new Error("Missing staged destination");await h.chmod(d&4095),await h.sync(),await h.close(),h=void 0;let b=null;try{b=F(await U(t))}catch(S){if(!ye(S))throw S}if(b!==u)throw new l("CONFLICT",t,"not-applied");n.signal?.throwIfAborted(),await _e(f,t),f=void 0,v=!0}return i==="move"&&(await k(),o?await o.backend.removeEntry(o.location.path,g,n):await Fe(e)),{source:e,target:t}}catch(E){throw v?new l(ge(E),e,"unknown"):E}finally{await p?.close(),await h?.close(),f!==void 0&&await Ae(f,{force:!0}),y&&await y.stop().catch(()=>{})}}s(Y,"transferFile");function Re(r,i,a){let n=r.resolve(i,a.cwd);if(n===void 0){let e=j(i,a.cwd);return{path:e,source:e,cwd:a.cwd,files:te}}let c=r.resolve(a.cwd,a.cwd),w=c?.location.target===n.location.target?c.location.path:n.backend.target.workspace;return{remote:n,source:n.location.source,path:n.location.path,cwd:w,files:{owner:JSON.stringify([n.backend.target.host,n.backend.target.configFile??null]),realpath:s(e=>n.backend.realpath(e,a),"realpath"),inspect:s(e=>n.backend.lstat(e,a),"inspect"),read:s(async e=>(await n.backend.read(e,a)).bytes.toString("utf8"),"read"),git:s((e,t,o)=>n.backend.queryGit(e,t,{...a,signal:o}),"git"),source:s(e=>N(n.location.target,e).source,"source"),snapshot:s((e,t)=>n.backend.objectSnapshot(e,{...a,signal:t}),"snapshot")}}}s(Re,"endpoint");function L(r,i,a){let n=r.remote?A.posix:A;if(n.sep==="\\"&&a.split("/").some(c=>c.includes("\\")||c.includes(":")))throw new l("INVALID_TARGET",r.source,"not-applied");return n.join(i,...a.split("/"))}s(L,"leaf");function K(r,i){return r.remote?N(r.remote.location.target,i).source:i}s(K,"receiptPath");async function _(r,i,a){let n;try{n=await r.files.inspect(i)}catch(c){if(c!==null&&typeof c=="object"&&"code"in c&&c.code==="ENOENT"){if(a===void 0)return}else throw c}if(a===void 0||n?.revision!==a.revision)throw new l("TRANSFER_TARGET_CHANGED",K(r,i),"not-applied")}s(_,"checkEntry");async function M(r){let i;try{i=await Ue(r)}catch(a){if(a===null||typeof a!="object"||!("code"in a)||a.code!=="ENOENT")throw a;await M(A.dirname(r)),await ke(r);return}if(!i.isDirectory()||i.isSymbolicLink())throw new l("INVALID_FILE_TYPE",r,"not-applied");A.dirname(r)!==r&&await M(A.dirname(r))}s(M,"directoryParents");async function ve(r,i,a,n){r.remote?await r.remote.backend.removeObject(i,a.revision,n):(await _(r,i,a),a.kind==="directory"?await Me(i,{recursive:!0,force:!1}):await Ve(i))}s(ve,"remove");async function Ee(r,i,a,n,c,w){let e=Re(r,a.path,n),t=Re(r,a.target??"",n),o=await c.prepareTransfer(i,e,t),m=o.source.entries[0];if(m===void 0)throw new l("ENOENT",e.source,"not-applied");e.remote&&C(e.source,m.revision,w),t.remote&&C(t.source,o.target.entries[0]?.revision??null,w);let R=!1;try{n.signal?.throwIfAborted();for(let d of o.source.entries)L(e,o.source.path,d.relativePath),L(t,o.target.path,d.relativePath);if(o.sourceKind==="file")e.remote&&t.remote&&e.remote.location.target===t.remote.location.target?await e.remote.backend[i](o.source.path,o.target.path,m.revision,o.target.entries[0]?.revision??null,n):await Y(r,i,a,n,w,async()=>{await _(e,o.source.path,m),await _(t,o.target.path,o.target.entries[0])});else{if(i==="move"&&e.remote&&t.remote&&e.files.owner===t.files.owner&&await e.remote.backend.moveObject(o.source,o.target,n))return{kind:"file-operation",operation:i,ok:!0,effect:"applied",path:e.source,target:t.source,sourceKind:o.sourceKind};let d=new Map(o.target.entries.map(u=>[u.relativePath,u])),g=new Map;i==="move"&&o.target.entries[0]&&(R=!0,await ve(t,o.target.path,o.target.entries[0],n),d.clear());for(let u of o.source.entries){n.signal?.throwIfAborted();let p=L(e,o.source.path,u.relativePath),f=L(t,o.target.path,u.relativePath);await _(e,p,u);let h=d.get(u.relativePath);if(await _(t,f,h),u.kind==="directory")h===void 0&&(R=!0),t.remote?await t.remote.backend.ensureObjectDirectory(f,u.mode|448,h?.revision??null,n):h===void 0&&(await M(A.dirname(f)),await ke(f,{mode:u.mode|448})),h===void 0&&g.set(u.relativePath,(await t.files.inspect(f)).identity);else if(u.kind==="symlink"){if(R=!0,u.link===void 0)throw new l("INVALID_RESPONSE",e.source,"unknown");t.remote?await t.remote.backend.createObjectLink(f,u.link,n):(await M(A.dirname(f)),await He(Buffer.from(u.link,"base64"),f))}else{R=!0;let y=K(e,p),v=K(t,f);e.remote&&t.remote&&e.files.owner===t.files.owner?await e.remote.backend.copy(p,f,u.revision,h?.revision??null,n):await Y(r,"copy",{path:y,target:v},n,void 0,async()=>{await _(e,p,u),await _(t,f,h)})}}for(let u of[...o.source.entries].reverse()){if(u.kind!=="directory"||d.has(u.relativePath))continue;let p=L(t,o.target.path,u.relativePath),f=await t.files.inspect(p),h=g.get(u.relativePath);if(f.kind!=="directory"||h?.device!==f.identity.device||h.inode!==f.identity.inode)throw new l("TRANSFER_TARGET_CHANGED",t.source,"unknown");if(t.remote)await t.remote.backend.setObjectMode(p,u.mode,f.revision,n);else{let y=await Ge(p,$.O_RDONLY|$.O_DIRECTORY|$.O_NOFOLLOW);try{let v=await y.stat();if(String(v.dev)!==h.device||String(v.ino)!==h.inode)throw new l("TRANSFER_TARGET_CHANGED",t.source,"unknown");await y.chmod(u.mode&4095)}finally{await y.close()}}}await o.verifySource(),i==="move"&&await ve(e,o.source.path,m,n)}return{kind:"file-operation",operation:i,ok:!0,effect:"applied",path:e.source,target:t.source,sourceKind:o.sourceKind}}catch(d){throw R?Object.assign(d instanceof Error?d:new Error(String(d)),{effect:"unknown"}):d}}s(Ee,"transferObject");function Se(r,i){return async(a,n,c,w)=>{let e=r.resolve(n.path,c.cwd);if(e===void 0&&(n.target===void 0||r.resolve(n.target,c.cwd)===void 0))return;if(a!=="delete"){if(w===void 0)throw new l("TRANSFER_POLICY_REQUIRED",n.path,"not-applied");return Ee(r,a,n,c,w,i)}if(e===void 0)return;let t=await e.backend.lstat(e.location.path,c);C(e.location.source,t.revision,i);{if(w===void 0)throw new l("DELETE_POLICY_REQUIRED",e.location.source,"not-applied");let o=r.resolve(c.cwd,c.cwd);if(o!==void 0&&o.location.target!==e.location.target)throw new l("UNSUPPORTED_SOURCE",e.location.source,"not-applied");let m=o?.location.path??e.backend.target.workspace,R=await w.prepare(e.location.path,m,{temporaryEnvironment:s(d=>e.backend.temporaryEnvironment({...c,signal:d}),"temporaryEnvironment"),realpath:s(d=>e.backend.realpath(d,c),"realpath"),inspect:s(d=>e.backend.lstat(d,c),"inspect"),read:s(async d=>(await e.backend.read(d,c)).bytes.toString("utf8"),"read"),git:s((d,g,u)=>e.backend.queryGit(d,g,{...c,signal:u}),"git"),source:s(d=>N(e.location.target,d).source,"source")});if(R.revision!==t.revision)throw new l("DELETE_TARGET_CHANGED",e.location.source,"not-applied");return await e.backend.removeObject(R.resolvedPath,R.revision,c),{kind:"file-operation",operation:a,ok:!0,effect:"applied",path:e.location.source}}}}s(Se,"createSshFileOperationResolver");function W(r,i,a){return{id:"ssh",async tryResolve(n,c){try{let w=r.resolve(n,c.cwd);if(!w)return{kind:"not-handled"};let{backend:e,location:t}=w,o=!1;try{o=(await e.stat(t.path,c)).kind==="directory"}catch(p){if(!(p instanceof l)||p.code!=="ENOENT")throw p}let m,R,d=s(async p=>{try{let f=await e.read(t.path,p);return m=f.version,f.bytes}catch(f){throw f instanceof l&&f.code==="ENOENT"&&(m=null),f}},"snapshot"),g=s(async p=>{if(R=void 0,o){let h=(await e.list(t.path,p)).map(y=>` ${y.kind==="directory"?"\u{1F4C1}":y.kind==="file"?"\u{1F4C4}":"\u{1F517}"} ${y.name}`);return[{type:"text",text:[`\u{1F4C1} ${t.source}/`,...h.length?["",...h]:[]].join(`
4
4
  `)}]}return R=await d(p),i.convert({source:t.source,bytes:R},p)},"read"),u=s(async(p,f,h)=>{let v=await e.readRange(t.path,p,Math.min(f??4194304,4194304),h),T=[v.bytes],k=v.bytes.length,E=Math.min(f??v.totalBytes,v.totalBytes-v.offset);for(;k<E;){let O=await e.readRange(t.path,v.offset+k,Math.min(E-k,4194304),h);if(O.revision!==v.revision||O.totalBytes!==v.totalBytes||O.offset!==v.offset+k)throw new l("SOURCE_CHANGED",t.source,"not-applied");if(O.bytes.length===0)break;T.push(O.bytes),k+=O.bytes.length}return{bytes:Buffer.concat(T,k),byteOffset:v.offset,totalBytes:v.totalBytes}},"readBytes");return a==="read"||o?{kind:"resolved",resource:{source:t.source,link:t.source,read:g,get sourceBytes(){return R},...o?{}:{readBytes:u}}}:{kind:"resolved",resource:{source:t.source,link:t.source,read:g,readBytes:u,get sourceBytes(){return R},async write(p,f){let h=J(p);if(m===void 0)try{await d(f)}catch(y){if(!(y instanceof l)||y.code!=="ENOENT")throw y}if(m===void 0)throw new l("SNAPSHOT_REQUIRED",t.source,"not-applied");m=await e.write(t.path,Buffer.from(h,"utf8"),m,f)}}}}catch(w){return{kind:"failed",error:w}}}}}s(W,"createSshResourceResolver");async function be(r,i){let a=await q({id:"ssh",description:"Set up SSH targets and use remote resources",triggers:[{tool:"read",resourcePrefixes:["ssh://","raw:ssh://","ast:ssh://","web:ssh://"]},{tool:"search",resourcePrefixes:["ssh://","web:ssh://"]},{tool:"debug",resourcePrefixes:["ssh://"]},...["write","replace","insert","delete","copy","move","stage","unstage","undo"].map(o=>({tool:o,resourcePrefixes:["ssh://"]}))]});if(Z(r,[{...a,markdown:`${a.markdown}
@@ -0,0 +1,3 @@
1
+ import{a as X}from"./chunk-PLKYHUNT.js";import{m as v}from"./chunk-ZPT5D4VP.js";import{a as y}from"./chunk-ZC65Z3CK.js";import{a as u}from"./chunk-EI7MMDWY.js";import{createHash as Ee}from"node:crypto";import{open as Ne,readFile as Me}from"node:fs/promises";import b from"node:path";import{spawn as xe}from"node:child_process";import{stat as we}from"node:fs/promises";import E from"node:path";import{createInterface as Te}from"node:readline";import{existsSync as me}from"node:fs";import ge from"node:os";import Y from"node:path";function Z(e=process.env.PI_CODING_AGENT_DIR??Y.join(ge.homedir(),".pi","agent"),t=process.platform){let r=Y.join(e,"bin",t==="win32"?"rg.exe":"rg");return me(r)?r:"rg"}u(Z,"resolveRipgrepExecutable");function J(e,t=!1){let r=L(e);return $(r)?D(I(new P(e,r).parse(),t)):t?e:G(e)}u(J,"compileSearchQuery");function z(e,t=!1){let r=L(e);return $(r)?I(new P(e,r).parse(),t):void 0}u(z,"compileSearchCondition");function A(e,t){if(e.kind==="term")return t(e.value);let r=A(e.left,t);if(e.kind==="or")return r||A(e.right,t);let n=A(e.right,t);return r&&(e.kind==="not"?!n:n)}u(A,"satisfiesSearchCondition");function te(e){if($(L(e)))return;let t=[...new Set(e.trim().split(/\s+/u).filter(Boolean))];return t.length>1?`(?:${t.map(G).join("|")})`:void 0}u(te,"compileSearchFallbackQuery");function $(e){return e.some(t=>t.quoted===!0||t.type==="and"||t.type==="or"||t.type==="not")}u($,"containsBooleanSyntax");var P=class{static{u(this,"BooleanQueryParser")}#e;#n;#a=0;constructor(t,r){this.#e=t,this.#n=r}parse(){let t=this.#o(),r=this.#t();if(r.type!=="end"){let n=r.type==="right"?"unexpected ')'.":`unexpected ${be(r)}.`;throw T(r.offset,n)}return t}#o(){let t=this.#r();for(;this.#t().type==="or";){let r=this.#i(),n=this.#s(`after ${r.value}`);t={kind:"or",left:t,right:this.#c(n)}}return t}#r(){return this.#c(this.#s())}#c(t){let r=t;for(;;){let n=this.#t();if(n.type==="and"||n.type==="not"){this.#i();let o=this.#s(`after ${n.value}`);r={kind:n.type,left:r,right:o};continue}if(n.type==="term"||n.type==="left"){r={kind:"and",left:r,right:this.#s()};continue}return r}}#s(t){let r=this.#t();if(r.type==="term")return this.#i(),{kind:"term",value:r.value,quoted:r.quoted};if(r.type==="left"){if(this.#i(),this.#t().type==="right"||this.#t().type==="end")throw T(this.#t().offset,"expected a term after '('.");let o=this.#o();if(this.#t().type!=="right")throw T(this.#t().offset,"expected ')'.");return this.#i(),o}if(t===void 0&&(r.type==="and"||r.type==="or"||r.type==="not"))throw T(r.offset,`expected a term before ${r.value}.`);let n=t===void 0?"":` ${t}`;throw T(r.offset,`expected a term${n}.`)}#t(){return this.#n[this.#a]??{type:"end",value:"",offset:this.#e.length}}#i(){let t=this.#t();return this.#a+=1,t}};function L(e){let t=[],r=0;for(;r<e.length;){let n=e.charAt(r);if(/\s/u.test(n)){r+=1;continue}if(n==="("&&Se(e,r)){t.push({type:"left",value:n,offset:r}),r+=1;continue}if(n===")"){t.push({type:"right",value:n,offset:r}),r+=1;continue}if(ee(e,r)){let i=e.charAt(r+1)==="|"?2:1;t.push({type:"or",value:e.slice(r,r+i),offset:r}),r+=i;continue}if(n==="'"||n==='"'){let i=r,c=n,a="";for(r+=1;r<e.length&&e.charAt(r)!==c;)e.charAt(r)==="\\"&&(e.charAt(r+1)===c||e.charAt(r+1)==="\\")&&(r+=1),a+=e.charAt(r++);if(r>=e.length)throw T(i,`unterminated ${c==="'"?"single":"double"}-quoted term.`);if(r+=1,a.length===0)throw T(i,"quoted terms must not be empty.");t.push({type:"term",value:a,offset:i,quoted:!0});continue}let o=r;for(;r<e.length;){let i=e.charAt(r);if(/\s/u.test(i)||i===")"||ee(e,r))break;i==="\\"&&r+1<e.length?r+=2:i==="["||i==="("?r=Q(e,r)??r+1:r+=1}let s=e.slice(o,r);t.push({type:ye(s),value:s,offset:o})}return t.push({type:"end",value:"",offset:e.length}),t}u(L,"tokenize");function ee(e,t){return e.charAt(t)==="|"&&(e.charAt(t+1)==="|"||/\s/u.test(e.charAt(t-1))&&/\s/u.test(e.charAt(t+1)))}u(ee,"isBooleanPipe");function Q(e,t){let r=e.charAt(t)==="["?"]":")",n=t+1;for(;n<e.length;){let o=e.charAt(n);if(o==="\\")n+=2;else{if(o===r)return n+1;if(r===")"&&(o==="("||o==="[")){let s=Q(e,n);if(s===void 0)return;n=s}else n+=1}}}u(Q,"regexBlockEnd");function Se(e,t){let r=Q(e,t);if(r===void 0)return!0;let n=e.slice(t+1,r-1);return n.trim().length===0?!0:$(L(n))}u(Se,"isBooleanGroup");function ye(e){return e==="AND"?"and":e==="OR"?"or":e==="NOT"?"not":"term"}u(ye,"operatorType");function be(e){return e.value.length>0?JSON.stringify(e.value):"the end of the query"}u(be,"quoteToken");function T(e,t){return new SyntaxError(`Invalid Boolean search query at column ${String(e+1)}: ${t}`)}u(T,"syntaxError");function I(e,t){return e.kind==="term"?{kind:"term",value:t&&!e.quoted?e.value:G(e.value)}:{kind:e.kind,left:I(e.left,t),right:I(e.right,t)}}u(I,"compileTerms");function D(e){if(e.kind==="term")return e.value;let t=D(e.left);return e.kind==="not"?t:`(?:${t}|${D(e.right)})`}u(D,"matchPattern");function G(e){return e.replace(/[\\^$.*+?()[\]{}|]/gu,"\\$&")}u(G,"escapeRegex");async function U(e,t,r,n,o){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.");return e.condition!==void 0?ie(e,(s,i)=>re(s,t,r,i,void 0,o),r):re(e,t,r,void 0,n,o)}u(U,"searchText");async function Re(e,t,r,n){if(r===void 0&&(e.path?.includes("://")||t.includes("://")))throw new Error("No search environment owns this scope.");let o=r?.resolve(t,oe(e.path??"."))??E.resolve(t,oe(e.path??".")),s=r===void 0?(await we(o)).isDirectory():await r.isDirectory(o,n);return{cwd:s?o:r?.dirname(o)??E.dirname(o),target:s?".":`./${r?.basename(o)??E.basename(o)}`,arguments:["--no-config","--no-ignore-parent","--color=never",...ne(e.include).flatMap(i=>["--glob",i]),...ne(e.exclude).flatMap(i=>["--glob",`!${i}`])]}}u(Re,"ripgrepScope");async function ve(e,t,r,n){if(e.condition!==void 0)return ie(e,async(s,i)=>{let c=await ve(s,t,r,n);for(let a of c.matches)i?.(a.source,a.lineNumber);return c},n);if(/\r|\n/u.test(e.query))throw new Error("Search supports one-line patterns only.");let o=await j(["--json","--no-config","--color=never","--with-filename","--line-number",...e.regex===!0?["--engine","auto"]:["--fixed-strings"],e.caseSensitive===!0?"--case-sensitive":"--ignore-case",...e.wholeWord===!0?["--word-regexp"]:[],"--",e.query,"-"],r,n,void 0,void 0,t.length===0?`
2
+ `:t);return t.length===0?{...o,matches:o.matches.filter(s=>s.lineNumber===1&&s.startColumn===0&&s.endColumn===0)}:o}u(ve,"searchTextContent");async function re(e,t,r,n,o,s){let i=await Re(e,t,s,r),c=i.cwd,a=["--json","--with-filename","--line-number",e.caseSensitive===!0?"--case-sensitive":"--ignore-case",...e.wholeWord===!0?["--word-regexp"]:[],...i.arguments,"--",e.query,i.target];if(e.regex!==!0)return j(["--fixed-strings",...a],c,r,n,o,void 0,s);try{return await j(["--engine","auto",...a],c,r,n,o,void 0,s)}catch(l){if(!ke(l))throw l instanceof Error&&/PCRE2 is not available|does not support PCRE2/iu.test(l.message)?new Error("This regex requires PCRE2. Install ripgrep with PCRE2 support or simplify the regex.",{cause:l}):l;try{return await j(["--engine","default",...a],c,r,n,o,void 0,s)}catch(d){throw r?.aborted?d:new AggregateError([l,d],"Regex exceeded the PCRE2 match limit and cannot run with the default engine. Narrow the search or simplify the regex.",{cause:d})}}}u(re,"searchPattern");async function ie(e,t,r){let n=e.condition;if(n===void 0)throw new Error("Boolean search requires a line condition.");let o=new Set;function s(p){if(p.kind==="term"){o.add(p.value);return}s(p.left),s(p.right)}u(s,"collect"),s(n);let{condition:i,...c}=e,a=new Map,l=u(p=>JSON.stringify([p.source,p.lineNumber]),"lineKey");for(let p of o){r?.throwIfAborted();let g=new Set;await t({...c,query:p,regex:!0,wholeWord:!1},(w,x)=>g.add(JSON.stringify([w,x]))),a.set(p,g)}let d=await t(c),h=new Set,f=d.matches.filter(p=>{let g=l(p);return h.has(g)||!A(n,w=>a.get(w)?.has(g)===!0)?!1:(h.add(g),!0)});return{...d,matches:f}}u(ie,"searchBoolean");function j(e,t,r,n,o,s,i){return i!==void 0?Ce(e,t,i,r,n,o):new Promise((c,a)=>{let l=xe(Z(),e,{stdio:["pipe","pipe","pipe"],cwd:t}),d=0,h=!1;o!==void 0&&l.stdout.on("data",m=>{d+=m.length,d>o.bytes&&(h=!0,l.kill())});let f=Te({input:l.stdout});l.stdin.on("error",()=>{}),l.stdin.end(s);let p=[],g="",w,x=u(()=>{l.kill()},"abort"),k=u(()=>{r?.removeEventListener("abort",x),f.close()},"cleanup");l.stderr.setEncoding("utf8"),l.stderr.on("data",m=>{g+=m}),f.on("line",m=>{if(!(h||w!==void 0||m.length===0))try{let S=JSON.parse(m);if(S.type!=="match")return;if(n!==void 0){let{path:B,line_number:V}=S.data;B.text!==void 0&&Number.isSafeInteger(V)&&n(E.resolve(t,B.text),V);return}for(let B of ae(S,t)){if(o!==void 0&&p.length===o.matches){h=!0,l.kill();break}p.push(B)}}catch(S){w=S,l.kill()}}),l.once("error",m=>{k(),a(m)}),l.once("close",m=>{if(k(),r?.aborted===!0){let S=new Error("Search was aborted.");S.name="AbortError",a(S);return}if(w!==void 0){a(new Error("Unable to parse ripgrep search output.",{cause:w}));return}if(!h&&m!==0&&m!==1){a(new Error(g.trim()||`ripgrep exited with code ${String(m)}.`));return}p.sort(se),c({matches:p,complete:!h})}),r?.addEventListener("abort",x,{once:!0}),r?.aborted===!0&&x()})}u(j,"runRipgrep");async function Ce(e,t,r,n,o,s){let i=[],c=new AbortController,a=u(()=>c.abort(n?.reason),"abort");n?.addEventListener("abort",a,{once:!0}),n?.aborted&&a();let l=0,d={limited:!1};try{let h=await r.runLines(e,t,f=>{if(d.limited||!f.length)return;if(l+=Buffer.byteLength(f)+1,s!==void 0&&l>s.bytes){d.limited=!0,c.abort();return}let p=JSON.parse(f);if(p.type==="match"){if(o!==void 0){let g=p.data.path.text;g!==void 0&&Number.isSafeInteger(p.data.line_number)&&o(r.resolve(t,g),p.data.line_number);return}for(let g of ae(p,t,r)){if(s!==void 0&&i.length>=s.matches){d.limited=!0,c.abort();break}i.push(g)}}},c.signal);if(h.code!==0&&h.code!==1)throw new Error(h.stderr.trim()||"Ripgrep failed.")}catch(h){if(n?.throwIfAborted(),!d.limited)throw h}finally{n?.removeEventListener("abort",a)}return n?.throwIfAborted(),i.sort(se),{matches:i,complete:!d.limited}}u(Ce,"runOwnedRipgrep");function ke(e){return e instanceof Error&&/PCRE2: error matching: match limit exceeded/iu.test(e.message)}u(ke,"isPcre2MatchLimitError");function ae(e,t,r){let n=e.data.path.text,o=e.data.lines.text;if(n===void 0||o===void 0||!Number.isSafeInteger(e.data.line_number))return[];let s=o.replace(/(?:\r\n|\n)$/u,""),i=Buffer.from(o),c=[];for(let a of e.data.submatches){if(a.start<0||a.end<a.start||a.end>i.length)continue;let l=i.subarray(0,a.start).toString("utf8").length,d=i.subarray(0,a.end).toString("utf8").length;c.push({source:r?.resolve(t,n)??E.resolve(t,n),lineNumber:e.data.line_number,startColumn:l,endColumn:d,matchedText:s.slice(l,d),lineText:s})}return c}u(ae,"matchesFromEvent");function ne(e){if(e===void 0)return[];let t=[],r=0,n="";for(let o of e){if(o==="{"?r+=1:o==="}"&&(r=Math.max(0,r-1)),r===0&&(o===","||/\s/u.test(o))){n.length>0&&(t.push(n),n="");continue}n+=o}return n.length>0&&t.push(n),t}u(ne,"splitGlobList");function oe(e){return e.startsWith("@")?e.slice(1):e}u(oe,"stripFilePrefix");function se(e,t){return e.source.localeCompare(t.source)||e.lineNumber-t.lineNumber||e.startColumn-t.startColumn||e.endColumn-t.endColumn}u(se,"compareMatches");function nt(e){let t=J(e.query),r=J(e.query,!0),n=te(e.query),o=[],s=z(e.query),i=z(e.query,!0);return(r!==t||JSON.stringify(s)!==JSON.stringify(i))&&o.push({query:r,mode:"regex",condition:i}),n!==void 0&&n!==t&&n!==r&&o.push({query:n,mode:"words"}),{...e,query:t,regex:!0,condition:s,fallbacks:o}}u(nt,"createSearchRecipe");async function q(e,t,r,n){let o=e.query,s=await U(e,t,r,void 0,n),i=[];for(let c of e.fallbacks??[]){if(s.matches.length>0||!s.complete)break;r?.throwIfAborted();try{s=await U({...e,query:c.query,regex:!0,condition:c.condition},t,r,void 0,n),o=c.query,i.push(c.mode==="regex"?"Search fallback: no literal matches; tried unquoted terms as regex.":"Search fallback: no matches in earlier modes; tried separate words. Use these matches as location hints; refine the query before editing.")}catch(a){if(c.mode!=="regex"||!Ae(a)||r?.aborted)throw a;i.push("Search fallback: invalid regex skipped; literal search found no matches.")}}return{...s,query:o,notices:i}}u(q,"runSearchRecipe");function Ae(e){return e instanceof Error&&/regex parse error:|PCRE2: error compiling pattern/iu.test(e.message)}u(Ae,"isRegexSyntaxError");var Be=/^SEARCH#([A-F0-9]{4,64}):(all|[1-9]\d*):(line|match)$/u,de=4;function ft(e,t,r,n){return he(e,t,r,n).slice(0,de)}u(ft,"createSearchSessionId");function he(e,t,r,n){let o=r===void 0?Oe(t.map(a=>a.source)):R(r),s=t.map(a=>({match:a,source:a.source.includes("://")?R(a.source):b.relative(o,b.resolve(a.source))})).sort((a,l)=>a.source.localeCompare(l.source)||K(a.match,l.match)).map(({match:a,source:l})=>[l,a.lineNumber,a.startColumn,a.endLineNumber??a.lineNumber,a.endColumn,a.matchedText,a.lineText]),{limit:i,...c}=fe(n??{query:e,regex:!0},o);return Ee("sha256").update(JSON.stringify([e,o,c,s])).digest("hex").toUpperCase()}u(he,"createSearchSessionIdentity");function Pe(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 r=de;r<=e.length;r+=1){let n=e.slice(0,r);if(!t.has(n))return n}throw new Error("Could not allocate a unique search session id.")}u(Pe,"allocateSearchSessionId");function fe(e,t){return{query:e.query,path:He(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,condition:e.condition,fallbacks:e.fallbacks??[]}}u(fe,"normalizeRecipe");var F=class extends Error{static{u(this,"SearchSnapshotChangedError")}constructor(t){super(`Search result in ${t} changed before its anchors were registered.`),this.name="SearchSnapshotChangedError"}},ce=class{constructor(t=he,r,n){this.createIdentity=t;this.resultTargets=r;this.readSource=n}static{u(this,"SearchSessionStore")}#e=new Map;#n=new Map;async register(t,r,n,o,s,i={query:t,regex:!0},c,a,l){let d=r.map(m=>({...m,source:R(m.source)})).sort(K),h=this.readSource,f=h===void 0?void 0:(m,S)=>h(m,o,S),p=await le(d,s,a,l,f),g=this.createIdentity(t,d,o,i),x=this.#n.get(g)??Pe(g,new Set(this.#e.keys())),k={id:x,query:t,matches:d,complete:n,contentBySource:p,read:f,...Ie(this.resultTargets,x,d,p,o,n,(m,S)=>_(m,S,l,f)),...a===void 0?{}:{snapshotByteBudget:a},recipe:i,environment:l,...c!==void 0&&{refresh:c},cwd:R(o)};return this.#n.set(g,x),this.#e.set(x,k),k}async registerIfCurrent(t,r,n,o,s,i,c,a,l){try{return await this.register(t,r,n,o,s,i,c,a,l)}catch(d){if(d instanceof F)return;throw d}}async observeAfterEdit(t,r){let n=new Set(t.flatMap(s=>{let i=typeof s=="string"?N(s):void 0;return i===void 0?[]:[i.id]})),o=[];for(let s of n){let i=this.#e.get(s);if(i===void 0)continue;let c={sessionId:s,query:i.recipe.originalQuery??i.query,scope:fe(i.recipe,i.cwd)};try{let a=i.refresh===void 0?await q(i.recipe,i.cwd,r,i.environment):await i.refresh(r);o.push({...c,matches:a.matches.length,complete:a.complete,notices:a.notices})}catch(a){o.push({...c,error:a instanceof Error?a.message:String(a)})}}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(`
3
+ `),renderFull(t){return t},renderCompact(t){let r=N(t);return r===void 0?"selected result":r.selector==="all"?r.mode==="match"?"all matches":"all lines":r.mode==="match"?`match ${String(r.selector)}`:`line ${String(r.selector)}`},tryResolve:u((t,r)=>this.#a(t,r.source,r.signal),"tryResolve")}}async resolveSearchScope(t,r){if(!t.startsWith("SEARCH#"))return;let n=await this.#o(t,r.cwd,r.signal,!0);if(n.kind!=="resolved")throw new Error(n.kind==="rejected"?n.rejection.reason:"Invalid Search reference.");let o=y(N(t)),s=y(this.#e.get(o.id));return{complete:!0,targets:n.targets.map(i=>{if(i.expectedContent===void 0)throw new Error("Search snapshot is unavailable.");return{source:i.source,expectedContent:i.expectedContent,ranges:i.ranges??[],readCurrent:u(async c=>{let a=await O(i.source,c,s.environment,s.read);if(a===void 0)throw new Error("Search source is unavailable.");return a},"readCurrent")}})}}resourceResolver(){return{id:"search-targets",tryResolve:u((t,r)=>this.#o(t,r.cwd),"tryResolve")}}async#a(t,r,n){let o=N(t);if(o===void 0)return{kind:"not-handled"};let s=this.#e.get(o.id);if(s===void 0)return M();if(o.selector==="all"&&!s.complete)return C();let i=R(r),c=s;if(o.selector==="all"){if(s.refreshedComplete?.complete===!0)c=s.refreshedComplete;else if(s.refreshedComplete!==void 0&&(c=await this.#r(s,n),!c.complete))return C()}let a=H(c,o.selector,o.mode),l=a.filter(f=>f.source===i);if(l.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};let d=await O(i,n,s.environment,s.read);if(d===void 0)return M(y(l[0]).lineNumber);if(o.selector==="all"&&d!==c.contentBySource.get(i)){if(c=await this.#r(s,n),!c.complete)return C();a=H(c,o.selector,o.mode),l=a.filter(f=>f.source===i)}if(l.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};if(o.selector!=="all"&&d!==s.contentBySource.get(i))return M(y(l[0]).lineNumber);let h=v(i,d);return{kind:"resolved",anchor:new X(t,i,l.map(f=>W(h,f,o.mode)))}}async#o(t,r,n,o=!1){let s=N(t);if(s===void 0)return{kind:"not-handled"};let i=this.#e.get(s.id);if(i===void 0||i.cwd!==R(r))return M();if(s.selector==="all"&&!i.complete)return C();let c=i;if(s.selector==="all"){if(i.refreshedComplete?.complete===!0)c=i.refreshedComplete;else if(i.refreshedComplete!==void 0&&(c=await this.#r(i,n),!c.complete))return C();let h=new Set(H(c,s.selector,s.mode).map(f=>f.source));for(let f of h)if(await O(f,n,i.environment,i.read)!==c.contentBySource.get(f)){if(c=await this.#r(i,n),!c.complete)return C();break}}let a=H(c,s.selector,s.mode);if(s.selector!=="all"){let h=a[0]?.source;if(h!==void 0&&await O(h,n,i.environment,i.read)!==c.contentBySource.get(h))return M(a[0]?.lineNumber)}let l=new Map;for(let h of a){let f=l.get(h.source)??[];f.push(W(v(h.source,c.contentBySource.get(h.source)??h.lineText),h,s.mode)),l.set(h.source,f)}let d=[...l].map(([h,f])=>({source:h,ranges:f,expectedContent:c.contentBySource.get(h)}));return d.length===0&&!(o&&s.selector==="all")?{kind:"rejected",rejection:{code:"missing",reason:"search anchor has no matches"}}:{kind:"resolved",targets:d}}async#r(t,r){let n=t.refresh===void 0?await q(t.recipe,t.cwd,r,t.environment):await t.refresh(r),o=n.matches.map(i=>({...i,source:R(i.source)})).sort(K),s={matches:o,complete:n.complete,contentBySource:await le(o,r,t.snapshotByteBudget,t.environment,t.read)};return this.#e.set(t.id,{...t,refreshedComplete:s}),s}};function Ie(e,t,r,n,o,s,i){if(e===void 0)return{};let c=new Map([...n].map(([l,d])=>[l,v(l,d)])),a=r.map(l=>({source:l.source,expectedContent:y(n.get(l.source)),ranges:[W(y(c.get(l.source)),l,"match")],readCurrent:u(d=>i(l.source,d),"readCurrent")}));for(let[l,d]of r.slice(0,100).entries()){let h=e.register([{...y(a[l]),ranges:[W(y(c.get(d.source)),d,"line")]}],o);e.registerSearchReference(`SEARCH#${t}:${l+1}:line`,h,o)}return{target:e.register(a,o,s),matchTargets:a.slice(0,100).map(l=>e.register([l],o,s))}}u(Ie,"registerResultReferences");function N(e){let t=Be.exec(e);if(t!==null)return{id:y(t[1]),selector:t[2]==="all"?"all":Number(t[2]),mode:t[3]==="line"?"line":"match"}}u(N,"parseSearchAnchor");function H(e,t,r){let n=t==="all"?e.matches:[e.matches[t-1]].filter($e);if(r==="match"||t!=="all")return n;let o=new Set;return n.flatMap(s=>{let i=v(s.source,e.contentBySource.get(s.source)??s.lineText),c=pe(s);return i.lines.slice(s.lineNumber-1,c).flatMap(a=>{let l=`${s.source}\0${String(a.lineNumber)}`;return o.has(l)?[]:(o.add(l),[{...s,lineNumber:a.lineNumber,endLineNumber:a.lineNumber,startColumn:0,endColumn:a.content.length,lineText:a.content,matchedText:a.content}])})})}u(H,"selectMatches");function $e(e){return e!==void 0}u($e,"isMatch");function pe(e){let t=e.endLineNumber??e.lineNumber;return t>e.lineNumber&&e.endColumn===0?t-1:t}u(pe,"lastContainingLine");function W(e,t,r){if(r==="match")return{start:{lineNumber:t.lineNumber,column:t.startColumn},end:{lineNumber:t.endLineNumber??t.lineNumber,column:t.endColumn}};let n=pe(t),o=y(e.lines[n-1]);return{start:{lineNumber:t.lineNumber,column:0},end:{lineNumber:n+(o.lineEnding.length>0?1:0),column:o.lineEnding.length>0?0:o.content.length},linewise:!0}}u(W,"selectionRange");function Le(e,t){let r=t.endLineNumber??t.lineNumber;return e.lines.slice(t.lineNumber-1,r).map(n=>{let o=n.lineNumber===t.lineNumber?t.startColumn:0,s=n.lineNumber===r?t.endColumn:n.content.length;return n.content.slice(o,s)+(n.lineNumber===r?"":n.lineEnding)}).join("")}u(Le,"matchedSourceText");async function le(e,t,r,n,o){let s=[...new Set(e.map(a=>a.source))];if(r!==void 0){let a=new Map,l=r;for(let d of s){let h=await je(d,l,t,n,o);l-=Buffer.byteLength(h),ue(d,h,e),a.set(d,h)}return a}let i=await Promise.allSettled(s.map(async a=>{let l=await _(a,t,n,o);return ue(a,l,e),[a,l]})),c=new Map;for(let a of i){if(a.status==="rejected")throw a.reason;c.set(...a.value)}return c}u(le,"snapshotContents");function ue(e,t,r){let n=v(e,t);for(let o of r.filter(s=>s.source===e))if(n.lines[o.lineNumber-1]?.content!==o.lineText||Le(n,o)!==o.matchedText)throw new F(e)}u(ue,"validateSnapshot");async function je(e,t,r,n,o){if(r?.throwIfAborted(),e.includes("://")){let i=await _(e,r,n,o);if(Buffer.byteLength(i)>t)throw new Error("Candidate snapshot byte budget reached.");return i}let s=await Ne(e,"r");try{let i=await s.stat();if(!i.isFile()||i.size>t)throw new Error("Candidate snapshot byte budget reached.");let c=Buffer.alloc(Math.min(i.size+1,t+1)),a=0;for(;a<c.length;){r?.throwIfAborted();let l=await s.read(c,a,c.length-a,a);if(l.bytesRead===0)break;a+=l.bytesRead}if(r?.throwIfAborted(),a>i.size||a>t)throw new Error("Candidate file grew during snapshot capture.");return c.subarray(0,a).toString("utf8")}finally{await s.close()}}u(je,"readBoundedSnapshot");async function O(e,t,r,n){try{return await _(e,t,r,n)}catch{return}}u(O,"readCurrent");function R(e){return e.includes("://")?e:b.resolve(e)}u(R,"canonicalSource");function He(e,t){return t.includes("://")?t:e.includes("://")?new URL(t,e.endsWith("/")?e:e+"/").href:b.resolve(e,t)}u(He,"resolveScope");async function _(e,t,r,n){if(t?.throwIfAborted(),n!==void 0)return n(e,t);if(r!==void 0)return r.readText(e,t);if(e.includes("://"))throw new Error("No search snapshot owner for this source.");return Me(e,{encoding:"utf8",...t!==void 0&&{signal:t}})}u(_,"readOwnedText");function M(e=1){return{kind:"rejected",rejection:{code:"stale",reason:"search anchor is stale",contextRange:{offset:Math.max(1,e-2),limit:5}}}}u(M,"staleAnchor");function C(){return{kind:"rejected",rejection:{code:"missing",reason:"search did not register an all anchor because its result was limited"}}}u(C,"missingCompleteAnchor");function Oe(e){if(e.length===0)return".";let t=b.dirname(b.resolve(y(e[0])));for(let r of e.slice(1)){let n=b.resolve(r);for(;!Fe(t,n);){let o=b.dirname(t);if(o===t)return t;t=o}}return t}u(Oe,"commonSourceDirectory");function Fe(e,t){let r=b.relative(e,t);return r!==".."&&!r.startsWith(`..${b.sep}`)&&!b.isAbsolute(r)}u(Fe,"isWithin");function K(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}u(K,"compareMatches");export{Z as a,U as b,Re as c,ve as d,nt as e,q as f,ft as g,he as h,Pe as i,F as j,ce as k};
@@ -1 +1 @@
1
- import{o as E}from"./chunk-R5XJSEOE.js";import{e as f}from"./chunk-ZPT5D4VP.js";import{a as o}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as n}from"typebox/value";import{execFile as I}from"node:child_process";import{lstat as O,readdir as k,readFile as _,readlink as L,realpath as h}from"node:fs/promises";import i from"node:path";import v from"node:os";import{promisify as C}from"node:util";var F=C(I);function A(t){return t.isSymbolicLink()?"symlink":t.isDirectory()?"directory":t.isFile()?"file":"other"}o(A,"kind");function R(t){return JSON.stringify([t.dev,t.ino,t.birthtimeMs,t.ctimeMs,t.mtimeMs,t.size,t.mode])}o(R,"revision");async function x(t){return O(t).catch(r=>{if(r.code!=="ENOENT")throw r})}o(x,"optionalStat");async function b(t){try{return await h(t)}catch(r){if(r.code!=="ENOENT"||await x(t))throw r;return i.join(await b(i.dirname(t)),i.basename(t))}}o(b,"resolveParent");async function S(t,r){let c=i.join(await b(i.dirname(t)),i.basename(t)),l=[],p=o(async(s,d)=>{r?.throwIfAborted();let a=await x(s);if(a===void 0){if(d!=="")throw Object.assign(new Error("Transfer entry disappeared"),{code:"TRANSFER_TARGET_CHANGED"});return}let T={relativePath:d,kind:A(a),revision:R(a),identity:{device:String(a.dev),inode:String(a.ino)},mode:a.mode,...a.isSymbolicLink()?{link:(await L(s,{encoding:"buffer"})).toString("base64")}:{}};if(l.push(T),T.kind==="directory"){for(let m of(await k(s)).sort())await p(i.join(s,m),d===""?m:`${d}/${m}`);let y=await x(s);if(y===void 0||R(y)!==T.revision)throw Object.assign(new Error("Transfer directory changed while inspecting its children"),{code:"TRANSFER_TARGET_CHANGED"})}},"walk");return await p(c,""),{path:c,entries:l}}o(S,"snapshotLocalObjects");var N={owner:"local",async temporaryEnvironment(t){t?.throwIfAborted();let r=process.env.PI_CODING_AGENT_DIR?.trim();return{home:v.homedir(),temporary:v.tmpdir(),...r?{agentDirectory:i.resolve(r)}:{}}},pathStyle:"native",realpath:h,async inspect(t){let r=await O(t);return{kind:A(r),revision:R(r),identity:{device:String(r.dev),inode:String(r.ino)},mode:r.mode}},read:o(t=>_(t,"utf8"),"read"),async git(t,r,c){let l=Object.fromEntries(Object.entries(process.env).filter(([s])=>!s.startsWith("GIT_"))),{stdout:p}=await F("git",["-C",t,...r],{env:{...l,GIT_OPTIONAL_LOCKS:"0"},signal:c,timeout:5e3,maxBuffer:16*1024*1024});return p},source:o(t=>t,"source"),snapshot:S};var u="pi-agent-text-editor",P=32,oe="pi-agent-text-editor/position",ie="pi-agent-text-editor/search",ne=`${u}/core/ready`,se=`${u}/plugin/register`,g=e.Function([],e.Unknown()),D=e.Object({tryResolve:g},{additionalProperties:!0}),j=e.Object({lineNumber:e.Integer({minimum:1}),column:e.Integer({minimum:0})}),M=e.Object({start:j,end:j,linewise:e.Optional(e.Boolean())}),G=e.Object({source:e.String({minLength:1}),ranges:e.Optional(e.Array(M))}),q=e.Union([e.Object({kind:e.Literal("not-handled")},{additionalProperties:!0}),e.Object({kind:e.Literal("resolved"),targets:e.Array(G,{minItems:1})},{additionalProperties:!0}),e.Object({kind:e.Literal("rejected"),rejection:e.Object({code:e.Union([e.Literal("invalid"),e.Literal("stale"),e.Literal("missing"),e.Literal("ambiguous")]),reason:e.String(),contextRange:e.Optional(e.Object({offset:e.Number(),limit:e.Number()}))})},{additionalProperties:!0}),e.Object({kind:e.Literal("failed"),error:e.Unknown()},{additionalProperties:!0})]),V=e.String({pattern:"\\S"}),X=e.Object({resolver:e.Unknown(),priority:e.Optional(e.Number())}),U=e.Object({resolver:e.Unknown(),resources:e.Optional(e.Unknown()),kind:e.String({pattern:"\\S"}),type:e.Union([e.Literal("major"),e.Literal("auxiliary"),e.Literal("constant")]),priority:e.Optional(e.Number())}),H=e.Object({protocol:e.Literal(u),apiVersion:e.Literal(P)}),w=e.Object({protocol:e.Literal(u),apiVersion:e.Literal(P),id:e.String(),setup:g}),K=e.Object({plugin:w,accept:g});function ae(t){return n.Check(V,t)}o(ae,"isTextEditorToolId");function ce(t){if(!n.Check(X,t))return!1;let r=t;return E(r.resolver)&&(!("priority"in r)||typeof r.priority=="number")}o(ce,"isResourceResolverRegistration");function le(t){if(!n.Check(U,t))return!1;let r=t;return f(r.resolver)&&(!("resources"in r)||n.Check(D,r.resources))&&(!("priority"in r)||typeof r.priority=="number")}o(le,"isTextAnchorResolverRegistration");function pe(t){return n.Check(q,t)}o(pe,"isTextAnchorResourceResolutionAttempt");function de(t){return n.Check(H,t)}o(de,"isTextEditorCoreReady");function ue(t){return n.Check(w,t)}o(ue,"isTextEditorPlugin");function Te(t){return n.Check(K,t)}o(Te,"isTextEditorPluginRegistrationRequest");export{S as a,N as b,u as c,P as d,oe as e,ie as f,ne as g,se as h,ae as i,ce as j,le as k,pe as l,de as m,ue as n,Te as o};
1
+ import{o as E}from"./chunk-DXONCYWF.js";import{e as f}from"./chunk-ZPT5D4VP.js";import{a as o}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as n}from"typebox/value";import{execFile as I}from"node:child_process";import{lstat as O,readdir as k,readFile as _,readlink as L,realpath as h}from"node:fs/promises";import i from"node:path";import v from"node:os";import{promisify as C}from"node:util";var F=C(I);function A(t){return t.isSymbolicLink()?"symlink":t.isDirectory()?"directory":t.isFile()?"file":"other"}o(A,"kind");function R(t){return JSON.stringify([t.dev,t.ino,t.birthtimeMs,t.ctimeMs,t.mtimeMs,t.size,t.mode])}o(R,"revision");async function x(t){return O(t).catch(r=>{if(r.code!=="ENOENT")throw r})}o(x,"optionalStat");async function b(t){try{return await h(t)}catch(r){if(r.code!=="ENOENT"||await x(t))throw r;return i.join(await b(i.dirname(t)),i.basename(t))}}o(b,"resolveParent");async function S(t,r){let c=i.join(await b(i.dirname(t)),i.basename(t)),l=[],p=o(async(s,d)=>{r?.throwIfAborted();let a=await x(s);if(a===void 0){if(d!=="")throw Object.assign(new Error("Transfer entry disappeared"),{code:"TRANSFER_TARGET_CHANGED"});return}let T={relativePath:d,kind:A(a),revision:R(a),identity:{device:String(a.dev),inode:String(a.ino)},mode:a.mode,...a.isSymbolicLink()?{link:(await L(s,{encoding:"buffer"})).toString("base64")}:{}};if(l.push(T),T.kind==="directory"){for(let m of(await k(s)).sort())await p(i.join(s,m),d===""?m:`${d}/${m}`);let y=await x(s);if(y===void 0||R(y)!==T.revision)throw Object.assign(new Error("Transfer directory changed while inspecting its children"),{code:"TRANSFER_TARGET_CHANGED"})}},"walk");return await p(c,""),{path:c,entries:l}}o(S,"snapshotLocalObjects");var N={owner:"local",async temporaryEnvironment(t){t?.throwIfAborted();let r=process.env.PI_CODING_AGENT_DIR?.trim();return{home:v.homedir(),temporary:v.tmpdir(),...r?{agentDirectory:i.resolve(r)}:{}}},pathStyle:"native",realpath:h,async inspect(t){let r=await O(t);return{kind:A(r),revision:R(r),identity:{device:String(r.dev),inode:String(r.ino)},mode:r.mode}},read:o(t=>_(t,"utf8"),"read"),async git(t,r,c){let l=Object.fromEntries(Object.entries(process.env).filter(([s])=>!s.startsWith("GIT_"))),{stdout:p}=await F("git",["-C",t,...r],{env:{...l,GIT_OPTIONAL_LOCKS:"0"},signal:c,timeout:5e3,maxBuffer:16*1024*1024});return p},source:o(t=>t,"source"),snapshot:S};var u="pi-agent-text-editor",P=32,oe="pi-agent-text-editor/position",ie="pi-agent-text-editor/search",ne=`${u}/core/ready`,se=`${u}/plugin/register`,g=e.Function([],e.Unknown()),D=e.Object({tryResolve:g},{additionalProperties:!0}),j=e.Object({lineNumber:e.Integer({minimum:1}),column:e.Integer({minimum:0})}),M=e.Object({start:j,end:j,linewise:e.Optional(e.Boolean())}),G=e.Object({source:e.String({minLength:1}),ranges:e.Optional(e.Array(M))}),q=e.Union([e.Object({kind:e.Literal("not-handled")},{additionalProperties:!0}),e.Object({kind:e.Literal("resolved"),targets:e.Array(G,{minItems:1})},{additionalProperties:!0}),e.Object({kind:e.Literal("rejected"),rejection:e.Object({code:e.Union([e.Literal("invalid"),e.Literal("stale"),e.Literal("missing"),e.Literal("ambiguous")]),reason:e.String(),contextRange:e.Optional(e.Object({offset:e.Number(),limit:e.Number()}))})},{additionalProperties:!0}),e.Object({kind:e.Literal("failed"),error:e.Unknown()},{additionalProperties:!0})]),V=e.String({pattern:"\\S"}),X=e.Object({resolver:e.Unknown(),priority:e.Optional(e.Number())}),U=e.Object({resolver:e.Unknown(),resources:e.Optional(e.Unknown()),kind:e.String({pattern:"\\S"}),type:e.Union([e.Literal("major"),e.Literal("auxiliary"),e.Literal("constant")]),priority:e.Optional(e.Number())}),H=e.Object({protocol:e.Literal(u),apiVersion:e.Literal(P)}),w=e.Object({protocol:e.Literal(u),apiVersion:e.Literal(P),id:e.String(),setup:g}),K=e.Object({plugin:w,accept:g});function ae(t){return n.Check(V,t)}o(ae,"isTextEditorToolId");function ce(t){if(!n.Check(X,t))return!1;let r=t;return E(r.resolver)&&(!("priority"in r)||typeof r.priority=="number")}o(ce,"isResourceResolverRegistration");function le(t){if(!n.Check(U,t))return!1;let r=t;return f(r.resolver)&&(!("resources"in r)||n.Check(D,r.resources))&&(!("priority"in r)||typeof r.priority=="number")}o(le,"isTextAnchorResolverRegistration");function pe(t){return n.Check(q,t)}o(pe,"isTextAnchorResourceResolutionAttempt");function de(t){return n.Check(H,t)}o(de,"isTextEditorCoreReady");function ue(t){return n.Check(w,t)}o(ue,"isTextEditorPlugin");function Te(t){return n.Check(K,t)}o(Te,"isTextEditorPluginRegistrationRequest");export{S as a,N as b,u as c,P as d,oe as e,ie as f,ne as g,se as h,ae as i,ce as j,le as k,pe as l,de as m,ue as n,Te as o};
@@ -1,4 +1,4 @@
1
- import{a as ze,c as He}from"./chunk-TOYN4W4F.js";import{a as Ge}from"./chunk-YJ6T3PEP.js";import{b as Fe,c as Ve}from"./chunk-S72FVLUX.js";import{a as et}from"./chunk-2K65BSXS.js";import{c as Qe,d as Ye,f as Ze}from"./chunk-ICDI27GZ.js";import{d as Xe}from"./chunk-IICJXZBU.js";import{a as Ke}from"./chunk-BU7IZLKB.js";import{a as Be,b as Je}from"./chunk-S5PL5DFQ.js";import{a as nt}from"./chunk-N7LMRL64.js";import{a as tt,b as rt}from"./chunk-RAZP42IQ.js";import{a as ot,b as st}from"./chunk-BIG45IPN.js";import{e as it}from"./chunk-SSWUUBIR.js";import{J as F}from"./chunk-R5XJSEOE.js";import{f as Ie,g as De,h as Ae}from"./chunk-DUUOCBS3.js";import{a as q,b as E,c as J,d as M}from"./chunk-T4FTT3U4.js";import{m as Ee}from"./chunk-ZPT5D4VP.js";import{a as Oe}from"./chunk-ZAWRSA7N.js";import{a as je,b as Te}from"./chunk-OFILFO6D.js";import{b as $e,c as We,g as Ue,j as Ne,p as qe}from"./chunk-IMGIDBCC.js";import{a as Me}from"./chunk-BXGMMZT3.js";import{a as _}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import Dr from"node:path";var V=[{id:"vue-typescript-language-server",name:"vue-typescript-language-server",kind:"lsp",languages:["vue"],executables:["typescript-language-server"],dependencies:["typescript-language-server","@vue/typescript-plugin"],configFiles:["tsconfig.json"],documentation:"https://github.com/vuejs/language-tools/tree/master/packages/typescript-plugin",lsp:{command:["typescript-language-server","--stdio"],rootMarkers:["tsconfig.json","package.json"],languageIds:{vue:[".vue"]},initializationOptions:{plugins:[{name:"@vue/typescript-plugin",location:"{project}/node_modules/@vue/typescript-plugin",languages:["vue"]}]}}},b("elixir-ls",["elixir"],["elixir-ls"],["mix.exs"],{elixir:[".ex",".exs"]},["elixir-ls"],"https://github.com/elixir-lsp/elixir-ls",void 0,void 0,{elixirLS:{mcpEnabled:!1}}),b("metals",["scala"],["metals"],["build.sbt","project.scala",".bsp"],{scala:[".scala",".sc"]},["metals"],"https://scalameta.org/metals/"),{id:"angular-language-server",name:"angular-language-server",kind:"lsp",languages:["typescript","html"],executables:["ngserver"],dependencies:["@angular/language-server"],configFiles:["angular.json"],documentation:"https://github.com/angular/vscode-ng-language-service",lsp:{command:["ngserver","--stdio","--tsProbeLocations",".","--ngProbeLocations","."],rootMarkers:["angular.json"],requireRootMarker:!0,languageIds:{typescript:[".ts"],html:[".html"]}}},b("svelte-language-server",["svelte"],["svelteserver"],["svelte.config.js","package.json"],{svelte:[".svelte"]},["svelteserver","--stdio"],"https://github.com/sveltejs/language-tools/tree/master/packages/language-server",["svelte-language-server"]),b("dart-language-server",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],{dart:[".dart"]},["dart","language-server","--protocol=lsp"],"https://dart.dev/tools/dart-language-server"),b("r-language-server",["r"],["Rscript"],["DESCRIPTION",".lintr",".Rprofile"],{r:[".r"]},["Rscript","-e","languageserver::run()"],"https://github.com/REditorSupport/languageserver"),b("zls",["zig"],["zls"],["build.zig","build.zig.zon","zls.json"],{zig:[".zig",".zon"]},["zls"],"https://zigtools.org/zls/"),b("clangd",["c","cpp"],["clangd"],[".clangd","compile_commands.json","CMakeLists.txt"],{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"]},["clangd"],"https://clangd.llvm.org/"),b("typescript-language-server",["javascript","typescript"],["typescript-language-server"],["tsconfig.json","jsconfig.json","package.json"],{javascript:[".js",".mjs",".cjs"],javascriptreact:[".jsx"],typescript:[".ts",".mts",".cts"],typescriptreact:[".tsx"]},["typescript-language-server","--stdio"],"https://github.com/typescript-language-server/typescript-language-server",["typescript-language-server"]),b("basedpyright",["python"],["basedpyright-langserver","pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),b("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),b("rust-analyzer",["rust"],["rust-analyzer"],["Cargo.toml","rust-project.json"],{rust:[".rs"]},["rust-analyzer"],"https://rust-analyzer.github.io/"),b("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),b("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),b("kotlin-language-server",["kotlin"],["kotlin-language-server"],["build.gradle.kts","pom.xml"],{kotlin:[".kt",".kts"]},["kotlin-language-server"],"https://github.com/fwcd/kotlin-language-server"),b("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),b("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),b("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),b("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),b("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),b("vscode-css-language-server",["css"],["vscode-css-language-server"],["package.json"],{css:[".css",".scss",".less"]},["vscode-css-language-server","--stdio"],"https://github.com/microsoft/vscode-css-languageservice",void 0,void 0,{css:{},scss:{},less:{}}),b("vscode-html-language-server",["html"],["vscode-html-language-server"],["package.json"],{html:[".html",".htm"]},["vscode-html-language-server","--stdio"],"https://github.com/microsoft/vscode-html-languageservice"),b("yaml-language-server",["yaml"],["yaml-language-server"],[".yamllint","package.json"],{yaml:[".yaml",".yml"]},["yaml-language-server","--stdio"],"https://github.com/redhat-developer/yaml-language-server"),b("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),b("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),b("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),b("kotlin-lsp",["kotlin"],["intellij-server"],["build.gradle.kts","build.gradle","pom.xml","settings.gradle.kts"],{kotlin:[".kt",".kts"]},["intellij-server","--stdio"],"https://github.com/Kotlin/kotlin-lsp"),b("julia-language-server",["julia"],["julia"],["Project.toml","JuliaProject.toml"],{julia:[".jl"]},["julia","--startup-file=no","--history-file=no","-e","using LanguageServer; runserver()"],"https://github.com/julia-vscode/LanguageServer.jl"),b("powershell-editor-services",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],{powershell:[".ps1",".psm1",".psd1"]},["pwsh","-NoProfile","-NonInteractive","-Command",'$ErrorActionPreference="Stop";Import-Module PowerShellEditorServices;$d=Join-Path (Get-Location) ".agents/tmp/powershell-lsp-$PID";[IO.Directory]::CreateDirectory($d)|Out-Null;Start-EditorServices -HostName Pi -HostProfileId Pi -HostVersion 1.0.0 -Stdio -LanguageServiceOnly -LogPath (Join-Path $d "server.log") -SessionDetailsPath (Join-Path $d "session.json")'],"https://github.com/PowerShell/PowerShellEditorServices"),b("neocmakelsp",["cmake"],["neocmakelsp"],["CMakeLists.txt",".neocmake.toml",".neocmakelint.toml"],{cmake:[".cmake"]},["neocmakelsp","stdio"],"https://github.com/neocmakelsp/neocmakelsp",void 0,{cmake:["CMakeLists.txt"]}),b("vscode-json-language-server",["json"],["vscode-json-language-server"],["package.json"],{json:[".json",".jsonc"]},["vscode-json-language-server","--stdio"],"https://github.com/microsoft/vscode-json-languageservice"),b("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),b("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),b("docker-langserver",["dockerfile"],["docker-langserver"],["Dockerfile"],{dockerfile:[".dockerfile"]},["docker-langserver","--stdio"],"https://github.com/rcjsuen/dockerfile-language-server-nodejs",void 0,{dockerfile:["Dockerfile","Containerfile"]})];function b(n,e,t,r,o,s,i,l,c,p){return{id:n,name:n,kind:"lsp",languages:e,executables:t,configFiles:r,documentation:i,...l&&{dependencies:l},lsp:{command:s,rootMarkers:r,languageIds:o,...c&&{fileNames:c},...p&&{settings:p}}}}a(b,"recipe");import Jt from"node:path";import Kt from"cross-spawn";import{createMessageConnection as Xt,CancellationTokenSource as Qt,StreamMessageReader as Yt}from"vscode-jsonrpc/node";import{URI as ct}from"vscode-uri";import{watch as Nt}from"node:fs";import{readdir as qt,stat as Ft}from"node:fs/promises";import z from"node:path";import{URI as le}from"vscode-uri";var ne=class{constructor(e,t,r){this.root=e;this.changed=t;this.failed=r}static{a(this,"LspFileWatchers")}registrations=new Map;disposed=!1;async register(e,t){let r=[];try{for(let o of t){let s=o.globPattern,i=typeof s=="string"?this.root:le.parse(typeof s.baseUri=="string"?s.baseUri:s.baseUri.uri).fsPath,l=typeof s=="string"?s:s.pattern,c=a(g=>z.matchesGlob(z.isAbsolute(l)?z.join(i,g):g,l),"matches"),p=new Set((await qt(i,{recursive:!0})).filter(c));if(this.disposed)throw new Error("Language server file watchers are disposed");let d=Nt(i,{recursive:!0},(g,u)=>{!u||!c(u)||Ft(z.join(i,u)).then(()=>{if(!this.registrations.get(e)?.includes(d))return;let m=p.has(u)?2:1;p.add(u),(o.kind??7)&(m===1?1:2)&&this.changed({uri:le.file(z.join(i,u)).toString(),type:m})},m=>{if(this.registrations.get(e)?.includes(d)){if(m.code!=="ENOENT"){this.failed(m);return}p.delete(u)&&(o.kind??7)&4&&this.changed({uri:le.file(z.join(i,u)).toString(),type:3})}})});d.on("error",this.failed),r.push(d)}}catch(o){for(let s of r)s.close();throw o}this.unregister(e),this.registrations.set(e,r)}unregister(e){for(let t of this.registrations.get(e)??[])t.close();this.registrations.delete(e)}dispose(){this.disposed=!0;for(let e of this.registrations.keys())this.unregister(e)}};import{StreamMessageWriter as Vt}from"vscode-jsonrpc/node";var oe=class extends Vt{constructor(t,r){super(t);this.fail=r}static{a(this,"TransportWriter")}async write(t){try{await super.write(t)}catch(r){this.fail(r)}}};import zt from"node:path";import{URI as Ht}from"vscode-uri";function k(n,e){if(e.startsWith("ssh://")){let t=at(e);if(n.includes("://")){let o=at(n);if(o.host!==t.host)throw new Error("Document belongs to another language server owner");return o.href}let r=zt.posix.resolve(decodeURIComponent(t.pathname),n);return t.pathname=r.split("/").map(encodeURIComponent).join("/"),t.href}if(n.startsWith("ssh://")||n.includes("://")&&!n.startsWith("file://"))throw new Error("Document belongs to another language server owner");return n.startsWith("file://")?n:Ht.file(n).toString()}a(k,"documentUri");function at(n){let e=new URL(n);if(e.protocol!=="ssh:"||!e.hostname||e.username||e.password||e.port||e.search||e.hash)throw new Error("Invalid language server resource owner");return decodeURIComponent(e.pathname),e}a(at,"checkedRemote");async function A(n,e){if(e?.aborted)throw n.catch(()=>{}),e.reason;if(!e)return n;let t;try{return await Promise.race([n,new Promise((r,o)=>{t=a(()=>o(e.reason),"onAbort"),e.addEventListener("abort",t,{once:!0})})])}finally{t&&e.removeEventListener("abort",t)}}a(A,"waitWithSignal");var H=class{static{a(this,"SharedStartup")}controller=new AbortController;promise;settled=!1;waiters=0;constructor(e){this.promise=e(this.controller.signal);let t=a(()=>{this.settled=!0},"settled");this.promise.then(t,t)}async wait(e){this.waiters+=1;let t=await A(this.promise,e).then(r=>({value:r}),r=>({error:r}));if(this.waiters-=1,!this.settled&&this.waiters===0){this.controller.abort(e?.reason);try{await this.promise}catch(r){if(r!==this.controller.signal.reason)throw new AggregateError([this.controller.signal.reason,r],"Startup cancellation and cleanup failed",{cause:r})}}if("error"in t)throw t.error;return t.value}};var Gt=new Set(["uri","targetUri","target","oldUri","newUri","rootUri","documentUri","scopeUri","baseUri"]),Bt=new Set(["changes","relatedDocuments"]);function j(n,e){return Array.isArray(n)?n.map(t=>j(t,e)):typeof n!="object"||n===null?n:Object.fromEntries(Object.entries(n).map(([t,r])=>Gt.has(t)&&typeof r=="string"?[t,e(r)]:Bt.has(t)&&typeof r=="object"&&r!==null&&!Array.isArray(r)?[t,Object.fromEntries(Object.entries(r).map(([o,s])=>[e(o),j(s,e)]))]:[t,j(r,e)]))}a(j,"mapLspUris");var $=class{static{a(this,"LspClient")}_process=null;_ownedProcess=null;_ownedStartup;_ownerTransport;_connection=null;_initialized=!1;_serverCapabilities=null;_disposed=!1;_shutdownPromise;_crashed=!1;_stderr="";_fileWatchers;_fileWatcherCleanup=Promise.resolve();_handlers=new Map;_documentVersions=new Map;_documentContents=new Map;_diagnosticPublications=new Map;_diagnosticMode="unknown";_activeDiagnosticRequests=new Set;serverId;rootUri;_command;_args;_env;_initOptions;_settings;_timeoutMs;constructor(e){this.serverId=e.serverId,this.rootUri=e.rootUri,this._command=e.command,this._args=e.command.slice(1),this._env=e.env??{},this._initOptions=e.initOptions,this._settings=e.settings,this._timeoutMs=e.timeoutMs??3e4,this._ownerTransport=e.ownerTransport}get ready(){return this._initialized&&!this._disposed}get crashed(){return this._crashed}get pid(){return this._process?.pid??null}get remote(){return this._ownedProcess?.remote}get commandName(){return $e(this._command)}get diagnosticMode(){return this._diagnosticMode}setDiagnosticMode(e){this._diagnosticMode=e}get timeoutMs(){return this._timeoutMs}supportsCommand(e){let t=this._serverCapabilities?.executeCommandProvider;return Array.isArray(t?.commands)&&t.commands.includes(e)}get hasWorkspaceSymbolCapability(){let e=this._serverCapabilities?.workspaceSymbolProvider;return e===!0||typeof e=="object"&&e!==null}get hasFoldingRangeCapability(){let e=this._serverCapabilities?.foldingRangeProvider;return e===!0||typeof e=="object"&&e!==null}documentContent(e){return this._documentContents.get(e)}documentVersion(e){return this._documentVersions.get(e)}diagnosticPublication(e){return this._diagnosticPublications.get(e)}beginDiagnosticRequest(e){this._activeDiagnosticRequests.add(e)}endDiagnosticRequest(e){this._activeDiagnosticRequests.delete(e)}hasActiveDiagnosticRequest(e){return this._activeDiagnosticRequests.has(e)}async start(e){e?.throwIfAborted();try{await this._start(e)}catch(t){try{await this.shutdown()}catch(r){throw new AggregateError([e?.aborted?e.reason:t,r],`[lsp] ${this.serverId}: startup and cleanup failed`,{cause:r})}throw e?.throwIfAborted(),t}}async _start(e){if(this._initialized)return;if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);if(!this.rootUri.startsWith("file://")&&!this._ownerTransport)throw Object.assign(new Error("No language server process transport for this resource owner"),{code:"UNSUPPORTED_SOURCE"});if(await this._closeFileWatchers(),e?.throwIfAborted(),this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let t=_(this._command[0]),r=this._ownerTransport?decodeURIComponent(new URL(this.rootUri).pathname):ct.parse(this.rootUri).fsPath,o=[{uri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,name:Jt.basename(r)||r}];this._ownedStartup=this._ownerTransport?.start({rootUri:this.rootUri,command:this._command,env:this._env,signal:e});let s=await this._ownedStartup;if(this._ownedProcess=s??null,e?.throwIfAborted(),this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let i=s?void 0:Kt(t,this._args,{stdio:["pipe","pipe","pipe"],...e&&{signal:e},cwd:r,env:qe({command:this._command,env:this._env},r,process.env)});this._process=i??null;let l=i?Zt(i):Promise.resolve(),c=_(s?.stdin??i?.stdin),p=_(s?.stdout??i?.stdout),d=_(s?.stderr??i?.stderr);c.on("error",()=>{}),p.on("error",()=>{}),d.on("error",()=>{}),this._stderr="",d.setEncoding("utf8"),d.on("data",h=>{this._stderr=(this._stderr+h).slice(-4096)}),i?.on("error",h=>{("code"in h?h.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,h),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null});let g=a(h=>{(s?this._ownedProcess!==s:this._process!==i)||(this._closeFileWatchers(),!this._disposed&&h!==0&&h!==null&&(this._crashed=!0),this._connection?.dispose(),this._connection=null,this._diagnosticPublications.clear(),this._activeDiagnosticRequests.clear(),this._diagnosticMode="unknown",this._process=null,this._initialized=!1)},"onExit");i?.on("exit",g),s?.completion.then(({exitCode:h})=>g(h),()=>{this._ownedProcess===s&&(this._crashed=!0,g(null))}),await A(l,e);let u=Xt(new Yt(p),new oe(c,h=>{this._connection!==u||this._disposed||(this._crashed=!0,this._initialized=!1,this._closeFileWatchers(),u.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,h))}));this._connection=u,this._connection.onError(h=>{console.error(`[lsp] ${this.serverId}: connection error:`,h)});let m=a(h=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[h]})},"changed"),y=a(h=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,h),"failed");this._fileWatchers=this._ownerTransport?this._ownerTransport.fileWatchers?.(this.rootUri,m,y):new ne(r,m,y),this._connection.onRequest("client/registerCapability",async h=>{for(let w of h.registrations)if(w.method!=="workspace/didChangeConfiguration"){if(w.method!=="workspace/didChangeWatchedFiles")throw new Error(`Unsupported dynamic capability: ${w.method}`);if(!this._fileWatchers)throw new Error("File watching is unavailable for this server owner");await this._fileWatchers.register(w.id,w.registerOptions?.watchers??[])}return null}),this._connection.onRequest("client/unregisterCapability",async h=>{for(let w of h.unregisterations)await this._fileWatchers?.unregister(w.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/configuration",h=>h.items.map(w=>{let S=this._settings??null;for(let R of w.section?.split(".").filter(Boolean)??[])S=typeof S=="object"&&S!==null?S[R]??null:null;return S})),this._connection.listen(),this._connection.onNotification((h,...w)=>{let S=this._ownerTransport,R=S?j(w[0],v=>S.fromServerUri(v)):w[0];if(h==="textDocument/publishDiagnostics"){let v=R;v&&typeof v.uri=="string"&&Array.isArray(v.diagnostics)&&this._documentVersions.has(v.uri)&&(v.version===void 0||v.version===this.documentVersion(v.uri))&&this._diagnosticPublications.set(v.uri,{diagnostics:v.diagnostics,...typeof v.version=="number"&&{version:v.version}})}for(let v of this._handlers.get(h)??[])v(R)}),this._connection.onRequest("workspace/workspaceFolders",()=>o);let f=await A(lt(this._connection.sendRequest("initialize",{processId:this._ownerTransport?null:process.pid,rootUri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,workspaceFolders:o,capabilities:{workspace:{applyEdit:!1,configuration:!0,workspaceFolders:!0,didChangeWatchedFiles:{dynamicRegistration:this._fileWatchers!==void 0,relativePatternSupport:this._fileWatchers!==void 0},symbol:{dynamicRegistration:!1}},textDocument:{synchronization:{didOpen:!0,didChange:!0,didClose:!0},publishDiagnostics:{relatedInformation:!0},diagnostic:{dynamicRegistration:!1,relatedDocumentSupport:!1},documentSymbol:{hierarchicalDocumentSymbolSupport:!0},foldingRange:{lineFoldingOnly:!0}}},initializationOptions:this._initOptions}),this._timeoutMs,`[lsp] ${this.serverId}: initialize timed out`),e).catch(h=>{let w=this._stderr.trim();throw w?new Error(`[lsp] ${this.serverId}: ${w}`,{cause:h}):h});if(await this._connection.sendNotification("initialized",{capabilities:f.capabilities}),this._settings!==void 0&&await this._connection.sendNotification("workspace/didChangeConfiguration",{settings:this._settings}),this._crashed)throw new Error(`[lsp] ${this.serverId}: transport failed during initialization`);e?.throwIfAborted(),this._initialized=!0,this._serverCapabilities=f.capabilities,this._diagnosticMode=f.capabilities.diagnosticProvider?"pull":"push"}touch(){}async restart(e){await this.shutdown(),this._closeFileWatchers(),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1,this._crashed=!1,this._disposed=!1,this._shutdownPromise=void 0,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null,await this.start(e)}async sendRequest(e,t,r){this._assertReady(),r?.throwIfAborted();let o=this._ownerTransport,s=o?j(t,p=>o.toServerUri(p)):t,i=a(p=>o?j(p,d=>o.fromServerUri(d)):p,"mapResult");if(!r)return i(await _(this._connection).sendRequest(e,s));let l=new Qt,c;try{let p=_(this._connection).sendRequest(e,s,l.token);return i(await Promise.race([p,new Promise((d,g)=>{c=a(()=>{l.cancel(),g(r.reason)},"onAbort"),r.addEventListener("abort",c,{once:!0})})]))}finally{c&&r.removeEventListener("abort",c),l.dispose()}}sendNotification(e,t){this._assertReady(),this._sendNotification(e,t)}_sendNotification(e,t){let r=this._connection;if(!r)return;let o=this._ownerTransport,s=o?j(t,i=>o.toServerUri(i)):t;r.sendNotification(e,s).catch(i=>{this._connection!==r||this._disposed||(this._crashed=!0,this._initialized=!1,this._closeFileWatchers(),r.dispose(),console.error(`[lsp] ${this.serverId}: notification ${e} failed:`,i))})}onNotification(e,t){let r=this._handlers.get(e)??[];return r.push(t),this._handlers.set(e,r),()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}toUri(e){return k(e,this.rootUri)}serverDocumentPath(e){let t=this.toUri(e),r=this._ownerTransport?.toServerUri(t)??t;return this._ownerTransport?decodeURIComponent(new URL(r).pathname):ct.parse(r).fsPath}openDocument(e,t,r,o=1){let s=this._documentVersions.get(e);if(s!==void 0){this.changeDocument(e,t,Math.max(o,s+1));return}this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:r,version:o,text:t}}),this._documentVersions.set(e,o),this._documentContents.set(e,t)}syncDocument(e,t,r,o=!1){if(this._documentContents.get(e)===t)return;let s=this._documentVersions.get(e);s===void 0?this.openDocument(e,t,r):this.changeDocument(e,t,s+1);let i=this._serverCapabilities?.textDocumentSync,l=typeof i=="object"&&i!==null?i.save:void 0;o&&l&&this.sendNotification("textDocument/didSave",{textDocument:{uri:e},...typeof l=="object"&&l.includeText&&{text:t}})}changeDocument(e,t,r){let o=this._documentVersions.get(e),s=Math.max(r,(o??0)+1);this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didChange",{textDocument:{uri:e,version:s},contentChanges:[{text:t}]}),this._documentVersions.set(e,s),this._documentContents.set(e,t)}closeDocument(e){this.sendNotification("textDocument/didClose",{textDocument:{uri:e}}),this._documentVersions.delete(e),this._documentContents.delete(e),this._diagnosticPublications.delete(e)}shutdown(){return this._shutdownPromise??=this._shutdown()}async _shutdown(){this._disposed=!0;let e=this._closeFileWatchers();if(this._connection&&this._initialized)try{await lt(this._connection.sendRequest("shutdown"),Math.min(this._timeoutMs,1e3),`[lsp] ${this.serverId}: shutdown timed out`),await this._connection.sendNotification("exit").catch(()=>{})}catch{}this._connection?.dispose(),this._connection=null;let t=this._ownedProcess??await this._ownedStartup?.catch(()=>{});this._ownedProcess=null,this._ownedStartup=void 0;let r=Promise.resolve().then(()=>t?.stop()),o=this._process;this._process=null,o&&!o.killed&&(o.kill("SIGTERM"),setTimeout(()=>{o.exitCode===null&&o.signalCode===null&&o.kill("SIGKILL")},2e3).unref()),this._initialized=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null;let s=await Promise.allSettled([r,e]),i=[];for(let l of s)l.status==="rejected"&&i.push(l.reason);if(i.length>0)throw new AggregateError(i,`[lsp] ${this.serverId}: owned cleanup failed`)}dispose(){return this.shutdown()}_closeFileWatchers(){let e=this._fileWatchers;return this._fileWatchers=void 0,e&&(this._fileWatcherCleanup=this._fileWatcherCleanup.catch(()=>{}).then(()=>e.dispose()),this._fileWatcherCleanup.catch(t=>{console.error(`[lsp] ${this.serverId}: file watcher cleanup failed:`,t)})),this._fileWatcherCleanup}_assertReady(){if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);if(this._crashed)throw new Error(`[lsp] ${this.serverId}: crashed \u2014 call restart()`);if(!this._initialized)throw new Error(`[lsp] ${this.serverId}: not started \u2014 call start()`);if(!this._connection)throw new Error(`[lsp] ${this.serverId}: connection lost`)}};function Zt(n){return new Promise((e,t)=>{let r=a(()=>{n.off("spawn",o),n.off("error",s)},"cleanup"),o=a(()=>{r(),e()},"onSpawn"),s=a(i=>{r(),t(i)},"onError");n.once("spawn",o),n.once("error",s)})}a(Zt,"waitForSpawn");function lt(n,e,t){return new Promise((r,o)=>{let s=setTimeout(()=>{o(new Error(t))},e);n.then(i=>{clearTimeout(s),r(i)}).catch(i=>{clearTimeout(s),o(i instanceof Error?i:new Error(String(i)))})})}a(lt,"withTimeout");import{readFile as pt}from"node:fs/promises";import{URI as ut}from"vscode-uri";var K={Error:1,Warning:2,Information:3,Hint:4};var dt={command:"typescript.tsserverRequest",async request(n,e,t){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async o=>{let s=await n.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[o,{file:n.serverDocumentPath(e),includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},t);if(!de(s)||s.success!==!0||!Array.isArray(s.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${o}`);return s.body.map(er)}))).flat()}};function se(n){return n.supportsCommand(dt.command)?dt:void 0}a(se,"completedDiagnosticAdapter");function er(n){if(!de(n)||typeof n.message!="string"||typeof n.code!="number"&&typeof n.code!="string"||!de(n.startLocation)||!Number.isInteger(n.startLocation.line)||!Number.isInteger(n.startLocation.offset)||Number(n.startLocation.line)<1||Number(n.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(n.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(n.code),message:n.message,line:Number(n.startLocation.line),column:Number(n.startLocation.offset),severity:n.category==="error"?"error":n.category==="warning"?"warning":n.category==="suggestion"?"hint":"info"}}a(er,"convertTypeScriptDiagnostic");function de(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}a(de,"isRecord");async function X(n,e,t,r={}){let o=new AbortController,s=AbortSignal.any([o.signal,...r.signal?[r.signal]:[]]),i=setTimeout(()=>o.abort(new Error(`[lsp] ${n.serverId}: diagnostics timed out for ${e}`)),n.timeoutMs);try{return await tr(n,e,t,r.content,s)}finally{clearTimeout(i)}}a(X,"requestDiagnostics");async function tr(n,e,t,r,o){if(o.throwIfAborted(),n.diagnosticMode!=="push"){let c=n.documentVersion(e);try{let p=await n.sendRequest("textDocument/diagnostic",{textDocument:{uri:e}},o);if(p.kind!=="full"||!Array.isArray(p.items))throw new Error("Invalid full diagnostic report");if(n.documentVersion(e)!==c)throw new Error("Document changed during diagnostic request");return n.setDiagnosticMode("pull"),gt(p.items,!1,!0)}catch(p){if(!rr(p))throw p;n.setDiagnosticMode("push")}}let s=se(n);if(s){n.documentVersion(e)===void 0&&n.syncDocument(e,r??await pt(ut.parse(e).fsPath,"utf8"),t??"plaintext");let c=n.documentVersion(e),p=await s.request(n,e,o);if(o.throwIfAborted(),n.documentVersion(e)!==c)throw new Error("Document changed during diagnostic request");return{diagnostics:p,syntaxErrors:[],otherDiagnostics:p,unversioned:!1,complete:!0}}o.throwIfAborted();let i=n.documentVersion(e)!==void 0,l=i?void 0:r??await pt(ut.parse(e).fsPath,"utf8");o.throwIfAborted(),n.beginDiagnosticRequest(e);try{return await new Promise((c,p)=>{let d=n.documentVersion(e)??1,g=a(f=>{let h=f;h.uri!==e||!Array.isArray(h.diagnostics)||h.version!==void 0&&h.version!==d||n.documentVersion(e)===d&&(y(),c(gt(h.diagnostics,h.version===void 0)))},"receive"),u=n.onNotification("textDocument/publishDiagnostics",g),m=a(()=>{y(),p(o.reason)},"onAbort");function y(){u(),o.removeEventListener("abort",m)}a(y,"cleanup"),o.addEventListener("abort",m,{once:!0});try{i||n.syncDocument(e,l??"",t??"plaintext");let f=n.diagnosticPublication(e);f&&g({uri:e,...f})}catch(f){y(),p(f)}})}finally{n.endDiagnosticRequest(e)}}a(tr,"requestCurrentDiagnostics");function pe(n){return{code:String(n.code??"LSP"),message:n.message,line:n.range.start.line+1,column:n.range.start.character+1,severity:n.severity===K.Warning?"warning":n.severity===K.Information?"info":n.severity===K.Hint?"hint":"error"}}a(pe,"toDiagnostic");function gt(n,e,t=!1){let r=n.map(pe);return{diagnostics:r,syntaxErrors:[],otherDiagnostics:r,unversioned:e,complete:t}}a(gt,"classify");function rr(n){return n!==null&&typeof n=="object"&&"code"in n&&n.code===-32601}a(rr,"isMethodNotFound");var nr={1:"File",2:"Module",3:"Namespace",4:"Package",5:"Class",6:"Method",7:"Property",8:"Field",9:"Constructor",10:"Enum",11:"Interface",12:"Function",13:"Variable",14:"Constant",15:"String",16:"Number",17:"Boolean",18:"Array",19:"Object",20:"Key",21:"Null",22:"EnumMember",23:"Struct",24:"Event",25:"Operator",26:"TypeParameter"};function T(n){return nr[n]??`SymbolKind(${n})`}a(T,"symbolKindName");async function Q(n,e,t){return await n.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}},t)??[]}a(Q,"requestDocumentSymbols");async function ue(n,e,t=100,r){return(await n.sendRequest("workspace/symbol",{query:e},r)??[]).slice(0,t)}a(ue,"requestWorkspaceSymbols");async function ie(n,e,t,r){return await n.sendRequest("textDocument/rename",{textDocument:{uri:e},position:t,newName:r})}a(ie,"requestRename");import Z from"node:path";import{URI as ar}from"vscode-uri";import{createHash as or}from"node:crypto";import{readdir as sr,stat as ae}from"node:fs/promises";import O from"node:path";import{URI as me}from"vscode-uri";async function ge(n,e){if(!n.supportsCommand("typescript.tsserverRequest"))return;if((await n.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:e,needFileNameList:!0},{isAsync:!1,expectsResult:!0}]}))?.success!==!0)throw new Error("TypeScript could not load the project for a workspace query.")}a(ge,"prepareProjectQuery");function mt(n,e){let t=a(r=>typeof r=="string"?r.replaceAll("{project}",()=>e):Array.isArray(r)?r.map(t):r!==null&&typeof r=="object"?Object.fromEntries(Object.entries(r).map(([o,s])=>[o,t(s)])):r,"expand");return Object.fromEntries(Object.entries(n).map(([r,o])=>[r,t(o)]))}a(mt,"resolveInitializationOptions");var W=class n{constructor(e,t){this._registry=e;this._owner=t}static{a(this,"LspManager")}_clients=new Map;_clientStarts=new Map;_openDocs=new Set;_pushUnsubscribers=new Map;_pushHandlers=new Set;_pushFingerprints=new Map;_disposed=!1;static _instance=null;static getInstance(){if(!n._instance)throw new Error("[lsp] LspManager not initialized");return n._instance}static getInstanceOrNull(){return n._instance}static init(e,t){let r=n._instance;return r?._disposed?(r._registry=e,r._owner=t,r._disposed=!1,r):(n._instance=new n(e,t),n._instance)}static async resetForTest(){n._instance&&(await n._instance.shutdownAll(),n._instance=null)}requireOwner(){if(!this._owner)throw Object.assign(new Error("No language server workspace owner"),{code:"UNSUPPORTED_SOURCE"});return this._owner}get workspaceRoot(){return this._registry.projectRoot}get clientCount(){return this._clients.size}onPushDiagnostics(e){return this._pushHandlers.add(e),()=>this._pushHandlers.delete(e)}async getOrStart(e,t,r,o){if(o?.throwIfAborted(),this._disposed)return null;let s=t.startsWith("ssh://"),i=s?this.requireOwner():void 0,l=i?await this._registry.resolveOwned(e,f=>i.exists(f,o)):this._registry.resolve(e);if(o?.throwIfAborted(),this._disposed)return null;let c=r==="symbols"?l[0]:l.find(f=>f.config.capabilities.includes(r));if(!c)return null;let p=s?t:me.file(t).toString(),d=`${c.serverId}:${p}`,g=this._clientStarts.get(d);if(g)return g.controller.signal.aborted?(await A(g.promise.catch(()=>{}),o),this.getOrStart(e,t,r,o)):g.wait(o);let u=this._clients.get(d);if(u?.ready)return u;let m=new H(f=>this._startClient(d,p,c,u,f));this._clientStarts.set(d,m);let y=a(()=>{this._clientStarts.get(d)===m&&this._clientStarts.delete(d)},"settled");return m.promise.then(y,y),m.wait(o)}async _startClient(e,t,r,o,s){let i=o??new $({serverId:r.serverId,rootUri:t,command:r.config.command,...t.startsWith("ssh://")&&this._owner&&{ownerTransport:this._owner.transport(t)},...r.config.env&&{env:r.config.env},...r.config.initializationOptions&&{initOptions:mt(r.config.initializationOptions,t.startsWith("ssh://")?decodeURIComponent(new URL(t).pathname):me.parse(t).fsPath)},...r.config.settings&&{settings:r.config.settings},...r.config.timeoutMs&&{timeoutMs:r.config.timeoutMs}});try{o?await o.restart(s):await i.start(s),s.throwIfAborted()}catch(l){try{await i.shutdown()}catch(c){if(c!==l)throw new AggregateError([l,c],"Language server startup and cleanup failed",{cause:c})}throw l}if(this._disposed)throw await i.shutdown(),new Error(`[lsp] ${r.serverId}: manager disposed during startup`);return this._clients.set(e,i),this._subscribeToPushDiagnostics(e,i),i}async isSourceFile(e,t,r){if(r?.throwIfAborted(),t.startsWith("ssh://")){if(this._owner===void 0)throw new Error("No language server workspace owner");return this._owner.isFile(k(e,t),r)}let o=await ae(O.resolve(t,e));return r?.throwIfAborted(),o.isFile()}async getWorkspaceClients(e,t="symbols",r=e,o=()=>!0,s){if(s?.throwIfAborted(),e.startsWith("ssh://")){let g=this._owner;if(!g)throw Object.assign(new Error("No language server workspace owner"),{code:"UNSUPPORTED_SOURCE"});let u=new Set,m=new Set(this._registry.knownExtensions),y=new Set([".git",".cache","node_modules","dist","build"]),f=a(async w=>{if(s?.throwIfAborted(),m.size!==0)for(let S of await g.entries(w,s)){s?.throwIfAborted();let R=k(S.name,`${w}/`);if(S.kind==="directory")y.has(S.name)||await f(R);else if(S.kind==="file"){let v=O.posix.extname(S.name).toLowerCase();if(!m.has(v)||!o(R))continue;let D=await this.openFile(R,e,t,s);D&&(u.add(D.client),m.delete(v))}}},"visit"),h=k(r,e);if(await g.isFile(h,s)){if(!o(h))return[];let w=await this.openFile(h,e,t,s);return w?[w.client]:[]}return await f(h),[...u]}let i=new Set,l=new Set(this._registry.knownExtensions),c=new Set([".git",".cache","node_modules","dist","build"]),p=a(async g=>{if(s?.throwIfAborted(),l.size===0)return;let u;try{u=await sr(g,{withFileTypes:!0})}catch{return}for(let m of u){if(s?.throwIfAborted(),l.size===0)return;if(m.isDirectory()){c.has(m.name)||await p(O.join(g,m.name));continue}if(!m.isFile())continue;let y=O.extname(m.name).toLowerCase();if(!l.has(y))continue;let f=O.join(g,m.name);if(!o(f))continue;let h=await this.openFile(f,e,t,s);h&&(l.delete(y),h.client.hasWorkspaceSymbolCapability&&(await ge(h.client,f),i.add(h.client)))}},"visit"),d=O.resolve(e,r);if((await ae(d)).isFile()){if(!o(d))return[];let g=await this.openFile(d,e,t,s);return g===null||!g.client.hasWorkspaceSymbolCapability?[]:(await ge(g.client,d),[g.client])}return await p(d),s?.throwIfAborted(),[...i]}async prepareWorkspaceSymbols(e,t=e,r,o){return this.getWorkspaceClients(e,"symbols",t,r,o)}hasServerFor(e){return this._registry.resolve(e).length>0}languageId(e){return this._registry.languageId(e)}isOpen(e){return this._openDocs.has(e)}syncEditedSource(e,t){for(let r of this._clients.values()){if(!r.ready)continue;let o=r.toUri(e);if(r.documentContent(o)===void 0)continue;let s=this.languageId(O.extname(decodeURIComponent(new URL(o).pathname)));r.syncDocument(o,t,s,!0)}}async readSourceSnapshot(e,t){if(t?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readSnapshot(e,t);if(e.includes("://"))throw Object.assign(new Error("Unsupported rename source"),{code:"UNSUPPORTED_SOURCE"});let r=a(i=>`${i.dev}:${i.ino}:${i.mode}:${i.size}:${i.mtimeMs}:${i.ctimeMs}`,"identity"),o=r(await ae(e)),s=await this.readSourceText(e,t);if(o!==r(await ae(e)))throw new Error("A rename source changed while reading it. No edits applied.");return{content:s,version:or("sha256").update(o).update("\0").update(s).digest("hex")}}async readSourceBytes(e,t){if(t?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readBytes(e,t);if(e.includes("://"))throw Object.assign(new Error("Unsupported declaration source"),{code:"UNSUPPORTED_SOURCE"});let{readFile:r}=await import("node:fs/promises");return r(e,{signal:t})}async readSourceText(e,t){if(t?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readText(e,t);if(e.includes("://"))throw Object.assign(new Error("Unsupported declaration source"),{code:"UNSUPPORTED_SOURCE"});let{readFile:r}=await import("node:fs/promises");return r(e,{encoding:"utf8",signal:t})}async openFile(e,t,r="diagnostics",o){if(o?.throwIfAborted(),e.startsWith("ssh://")&&!t.startsWith("ssh://")){if(!this._registry.projectRoot.startsWith("ssh://"))throw Object.assign(new Error("Remote document has no workspace owner"),{code:"UNSUPPORTED_SOURCE"});t=this._registry.projectRoot}let s=t.startsWith("ssh://"),i=s?k(e,t):O.resolve(t,e),l=await this.getOrStart(i,t,r,o);if(!l)return null;let c=l.toUri(i),p=s?this.requireOwner():void 0,g=(p?await this._registry.resolveOwned(i,u=>p.exists(u,o)):this._registry.resolve(i))[0]?.languageId??"plaintext";if(p){let u=await p.readText(c,o);return o?.throwIfAborted(),l.syncDocument(c,u,g),this._openDocs.add(c),{client:l,uri:c,languageId:g}}try{let{readFile:u}=await import("node:fs/promises"),m=await u(i,{encoding:"utf8",signal:o});o?.throwIfAborted(),l.syncDocument(c,m,g),this._openDocs.add(c)}catch(u){if(o?.throwIfAborted(),!(u instanceof Error&&"code"in u&&u.code==="ENOENT"))throw u}return{client:l,uri:c,languageId:g}}_subscribeToPushDiagnostics(e,t){if(this._pushUnsubscribers.has(e))return;let r=t.onNotification("textDocument/publishDiagnostics",o=>{let s=ir(o);if(!s||t.hasActiveDiagnosticRequest(s.uri))return;let i=t.documentVersion(s.uri);if(s.version!==void 0&&i!==void 0&&s.version<i)return;let l=`${e}:${s.uri}`,c=s.diagnostics.map(pe),p=JSON.stringify([s.version,i,c]);if(this._pushFingerprints.get(l)===p)return;this._pushFingerprints.set(l,p);let d={cwd:t.rootUri.startsWith("ssh://")?t.rootUri:me.parse(t.rootUri).fsPath,serverId:t.serverId,uri:s.uri,diagnostics:c,...s.version!==void 0&&{version:s.version}};for(let g of this._pushHandlers)g(d)});this._pushUnsubscribers.set(e,r)}async shutdownAll(){this._disposed=!0;let e=[...this._clientStarts.values()];for(let i of e)i.controller.abort(new Error("Language server manager stopped"));let t=await Promise.allSettled(e.map(i=>i.promise)),r=[];for(let[i,l]of t.entries())l.status==="rejected"&&l.reason!==e[i]?.controller.signal.reason&&r.push(l.reason);let o=[...this._clients.values()],s=await Promise.allSettled(o.map(i=>i.shutdown()));for(let i of this._pushUnsubscribers.values())i();this._pushUnsubscribers.clear(),this._clientStarts.clear(),this._pushFingerprints.clear(),this._pushHandlers.clear(),this._clients.clear();for(let i of s)i.status==="rejected"&&r.push(i.reason);if(r.length>0)throw new AggregateError(r,"Language server cleanup failed")}dispose(){return this.shutdownAll()}};function ir(n){if(n===null||typeof n!="object")return;let e=n;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}a(ir,"parsePushNotification");async function fe(n,e,t){if(t?.throwIfAborted(),!n.supportsCommand("typescript.tsserverRequest"))return;let r=await n.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:n.serverDocumentPath(e),needFileNameList:!0},{isAsync:!1,expectsResult:!0}]},t);if(t?.throwIfAborted(),r?.success!==!0)throw new Error("TypeScript could not load the project for the workspace query.")}a(fe,"loadQueryProject");async function Y(n,e,t,r){return await fe(n,e,r),await n.sendRequest("textDocument/references",{textDocument:{uri:e},position:t,context:{includeDeclaration:!0}},r)??[]}a(Y,"requestReferences");async function he(n,e,t,r){let o=await n.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:t},r),s=o?.[0];if(!s)return{items:[],incoming:[],outgoing:[]};let[i,l]=await Promise.all([n.sendRequest("callHierarchy/incomingCalls",{item:s},r),n.sendRequest("callHierarchy/outgoingCalls",{item:s},r)]);return{items:o,incoming:i??[],outgoing:l??[]}}a(he,"requestCallHierarchy");function G(n,e,t){let r=e.startsWith("ssh://"),o=r?Z.posix:Z,s=a(d=>r?decodeURIComponent(new URL(k(d,e)).pathname):d,"native"),i=r?s(t.path??e):Z.resolve(e,t.path??"."),l=o.relative(i,s(n));if(l===".."||l.startsWith(`..${o.sep}`)||o.isAbsolute(l))return!1;let c=o.relative(s(e),s(n)).split(o.sep).join("/"),p=a(d=>d.split(",").some(g=>{let u=g.trim();return u.length>0&&o.matchesGlob(u.includes("/")?c:o.basename(s(n)),u)}),"matches");return(t.include===void 0||p(t.include))&&(t.exclude===void 0||!p(t.exclude))}a(G,"withinScope");function ye(n,e){let t=k(n,e);if(t.startsWith("ssh://"))return t;let r=ar.parse(t);if(r.scheme!=="file")throw new Error("Unsupported LSP source location.");return Z.resolve(r.fsPath)}a(ye,"sourceOf");function cr(n,e){return n.start.line===e.start.line&&n.start.character===e.start.character&&n.end.line===e.end.line&&n.end.character===e.end.character}a(cr,"sameRange");function ft(n,e,t){return n.flatMap(r=>[...r.name===e&&r.range!==void 0&&cr(r.range,t)&&r.selectionRange!==void 0?[r.selectionRange]:[],...ft(r.children??[],e,t)])}a(ft,"declarationNames");async function we(n,e,t,r,o={},s=W.getInstance()){r?.throwIfAborted();let i=o.resultScope;if(i!==void 0&&(await F(i,r),i.targets.length===0))return{hits:[],complete:i.complete};if(i===void 0&&o.path!==void 0&&!G(e.startsWith("ssh://")?k(o.path,e):Z.resolve(e,o.path),e,o)&&await s.isSourceFile(o.path,e,r))return{hits:[],complete:!0};let l=i?.targets.map(y=>y.source)??[o.path??e],c=new Set((await Promise.all(l.map(y=>s.prepareWorkspaceSymbols(e,y,f=>G(f,e,o),r)))).flat());if(c.size===0)throw new Error("LSP symbol search is unavailable: no provider supports workspace/symbol in this scope.");let p=new Map,d=a(async y=>{r?.throwIfAborted();let f=ye(y.uri,e),h=p.get(f);if(h===void 0){let{content:L,version:N}=await s.readSourceSnapshot(f,r);h={document:Ee(f,L),version:N},p.set(f,h)}let{document:w}=h,{start:S,end:R}=y.range,v=[S,R];for(let L of v){let N=w.lines[L.line];if(!Number.isInteger(L.line)||!Number.isInteger(L.character)||N===void 0||L.character<0||L.character>N.content.length)throw new Error("LSP range does not match its source snapshot.")}let D=_(w.lines[S.line]),re=a(L=>w.lines.slice(0,L).reduce((N,xe)=>N+xe.content.length+xe.lineEnding.length,0),"offset"),U=re(S.line)+S.character,C=re(R.line)+R.character;if(C<U)throw new Error("LSP returned a reversed source range.");return{source:f,lineNumber:S.line+1,endLineNumber:R.line+1,startColumn:S.character,endColumn:R.character,matchedText:w.content.slice(U,C),lineText:D.content}},"toMatch"),g=a(y=>G(y.source,e,o)&&(i===void 0||st(i,y)),"included"),u=[],m=new Set;for(let y of c){r?.throwIfAborted();let f=await ue(y,n,Number.MAX_SAFE_INTEGER,r);for(let h of f){if(r?.throwIfAborted(),!G(ye(h.location.uri,e),e,{}))continue;let w=await d(h.location),S=await s.openFile(w.source,e,"symbols",r);if(S===null)throw new Error("LSP references are unavailable for a discovered declaration.");let R=h.location;if(w.matchedText!==h.name){let C=await Q(S.client,S.uri,r),L=ft(C,h.name,h.location.range);if(L.length!==1)throw new Error("LSP declaration has no unique provider selectionRange; cannot search its references.");R={uri:S.uri,range:_(L[0])}}let v=await d(R),D={id:JSON.stringify([y.serverId,v.source,h.location.range]),name:h.name,kind:String(h.kind),source:v.source,range:{startLine:v.lineNumber,startColumn:v.startColumn,endLine:v.endLineNumber??v.lineNumber,endColumn:v.endColumn}},re=await Y(S.client,S.uri,R.range.start,r);r?.throwIfAborted();let U=[{...v,role:"definition",symbol:D}];for(let C of re){if(!G(ye(C.uri,e),e,{}))continue;let L=await d(C);L.source===v.source&&L.lineNumber===v.lineNumber&&L.startColumn===v.startColumn&&L.endLineNumber===v.endLineNumber&&L.endColumn===v.endColumn||U.push({...L,role:"reference",symbol:D})}if(!(o.navigation==="references"&&!U.some(g)))for(let C of U){if(o.navigation!=="references"&&!g(C)||o.navigation==="references"&&!G(C.source,e,{}))continue;let L=JSON.stringify([D.id,C.source,C.lineNumber,C.startColumn,C.endLineNumber,C.endColumn]);m.has(L)||(m.add(L),u.push(C))}}}r?.throwIfAborted();for(let[y,f]of p){let h=await s.readSourceSnapshot(y,r);if(h.version!==f.version||h.content!==f.document.content)throw new Error("LSP source changed during search.")}return i!==void 0&&await F(i,r),u.sort((y,f)=>y.source.localeCompare(f.source)||y.lineNumber-f.lineNumber||y.startColumn-f.startColumn||y.endColumn-f.endColumn||y.symbol.id.localeCompare(f.symbol.id)),{hits:u.slice(0,t),complete:(i?.complete??!0)&&u.length<=t}}a(we,"searchSymbols");import{readFile as lr}from"node:fs/promises";import ve from"node:path";import{fileURLToPath as dr}from"node:url";var pr={failureLabel:"SYMBOL_READ_FAILED",emptyReason:"no symbol source was produced."},be=10,Se=5,B=10;async function yt(n,e,t,r,o){x(o);let s=await n.readSourceText(e,o),i=await te(n,e,r,o),l=ee(i.symbols,t,i.displayPath),c=await n.readSourceText(i.filePath,o);if(x(o),s!==c)throw new Error("The symbol source changed during resolution. Read it again before editing.");return{source:i.filePath,range:l.range,content:c}}a(yt,"resolveLspDeclaration");async function wt(n,e,t,r,o){x(o);let s=await n.readSourceText(e,o),i=await te(n,e,r,o),l=ee(i.symbols,t,i.displayPath);if(s!==await n.readSourceText(e,o))throw new Error("The rename source changed during resolution.");return x(o),{client:i.client,uri:i.uri,position:l.selectionRange.start,content:s}}a(wt,"resolveLspRenameTarget");async function Pe(n,e,t,r,o){x(o);let s=await te(n,e,r,o),i=ee(s.symbols,t,s.displayPath),l=await yr(s.filePath,n,o);x(o);let c=i.range.start.line+1,p=Math.min(i.range.end.line+1,l.lines.length),d=l.lines.slice(Math.max(0,c-1),Math.max(0,p)).map((u,m)=>{let y=c+m;return Ie({content:u,sourceLine:{source:s.filePath,lineNumber:y,content:u}})}),g={path:s.displayPath,heading:`symbol: ${M(i.selector)}`,details:[`defined in: ${s.displayPath}:${c}-${p} (${T(i.kind)})`],startLine:c,endLine:p,totalLines:l.lines.length,renderedLines:d};return De([g],pr)}a(Pe,"readLspSymbolBody");async function _e(n,e,t,r,o){x(o);let s=await te(n,e,r,o),i=ee(s.symbols,t,s.displayPath),l=await Lt(s,i,o),c=new ce(r);return await ur(s,i,l,c)}a(_e,"readLspSymbolGraph");async function Ce(n,e,t,r){x(r);let o=await te(n,e,t,r),s=new ce(t),i=[`## file graph: ${o.displayPath}`,`Top-level declarations: ${o.symbols.length}`];for(let l of o.symbols){x(r);let c=await Lt(o,l,r);i.push("",...await hr(o,l,c,s))}return i.join(`
1
+ import{a as nt}from"./chunk-47SPPIXK.js";import{a as tt,b as rt}from"./chunk-VAXLSPPU.js";import{a as ot,b as st}from"./chunk-OI3HBIPK.js";import{e as it}from"./chunk-YTYLS2UM.js";import{a as ze,c as He}from"./chunk-TOYN4W4F.js";import{a as Ge}from"./chunk-YJ6T3PEP.js";import{b as Fe,c as Ve}from"./chunk-S72FVLUX.js";import{a as et}from"./chunk-M4TVRCMZ.js";import{c as Qe,d as Ye,f as Ze}from"./chunk-TGC2ZACO.js";import{d as Xe}from"./chunk-IICJXZBU.js";import{a as Ke}from"./chunk-BU7IZLKB.js";import{a as Be,b as Je}from"./chunk-S5PL5DFQ.js";import{J as F}from"./chunk-DXONCYWF.js";import{f as Ie,g as De,h as Ae}from"./chunk-DUUOCBS3.js";import{a as q,b as E,c as J,d as M}from"./chunk-T4FTT3U4.js";import{m as Ee}from"./chunk-ZPT5D4VP.js";import{a as Oe}from"./chunk-ZAWRSA7N.js";import{a as je,b as Te}from"./chunk-OFILFO6D.js";import{b as $e,c as We,g as Ue,j as Ne,p as qe}from"./chunk-IMGIDBCC.js";import{a as Me}from"./chunk-BXGMMZT3.js";import{a as _}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import Dr from"node:path";var V=[{id:"vue-typescript-language-server",name:"vue-typescript-language-server",kind:"lsp",languages:["vue"],executables:["typescript-language-server"],dependencies:["typescript-language-server","@vue/typescript-plugin"],configFiles:["tsconfig.json"],documentation:"https://github.com/vuejs/language-tools/tree/master/packages/typescript-plugin",lsp:{command:["typescript-language-server","--stdio"],rootMarkers:["tsconfig.json","package.json"],languageIds:{vue:[".vue"]},initializationOptions:{plugins:[{name:"@vue/typescript-plugin",location:"{project}/node_modules/@vue/typescript-plugin",languages:["vue"]}]}}},b("elixir-ls",["elixir"],["elixir-ls"],["mix.exs"],{elixir:[".ex",".exs"]},["elixir-ls"],"https://github.com/elixir-lsp/elixir-ls",void 0,void 0,{elixirLS:{mcpEnabled:!1}}),b("metals",["scala"],["metals"],["build.sbt","project.scala",".bsp"],{scala:[".scala",".sc"]},["metals"],"https://scalameta.org/metals/"),{id:"angular-language-server",name:"angular-language-server",kind:"lsp",languages:["typescript","html"],executables:["ngserver"],dependencies:["@angular/language-server"],configFiles:["angular.json"],documentation:"https://github.com/angular/vscode-ng-language-service",lsp:{command:["ngserver","--stdio","--tsProbeLocations",".","--ngProbeLocations","."],rootMarkers:["angular.json"],requireRootMarker:!0,languageIds:{typescript:[".ts"],html:[".html"]}}},b("svelte-language-server",["svelte"],["svelteserver"],["svelte.config.js","package.json"],{svelte:[".svelte"]},["svelteserver","--stdio"],"https://github.com/sveltejs/language-tools/tree/master/packages/language-server",["svelte-language-server"]),b("dart-language-server",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],{dart:[".dart"]},["dart","language-server","--protocol=lsp"],"https://dart.dev/tools/dart-language-server"),b("r-language-server",["r"],["Rscript"],["DESCRIPTION",".lintr",".Rprofile"],{r:[".r"]},["Rscript","-e","languageserver::run()"],"https://github.com/REditorSupport/languageserver"),b("zls",["zig"],["zls"],["build.zig","build.zig.zon","zls.json"],{zig:[".zig",".zon"]},["zls"],"https://zigtools.org/zls/"),b("clangd",["c","cpp"],["clangd"],[".clangd","compile_commands.json","CMakeLists.txt"],{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"]},["clangd"],"https://clangd.llvm.org/"),b("typescript-language-server",["javascript","typescript"],["typescript-language-server"],["tsconfig.json","jsconfig.json","package.json"],{javascript:[".js",".mjs",".cjs"],javascriptreact:[".jsx"],typescript:[".ts",".mts",".cts"],typescriptreact:[".tsx"]},["typescript-language-server","--stdio"],"https://github.com/typescript-language-server/typescript-language-server",["typescript-language-server"]),b("basedpyright",["python"],["basedpyright-langserver","pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),b("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),b("rust-analyzer",["rust"],["rust-analyzer"],["Cargo.toml","rust-project.json"],{rust:[".rs"]},["rust-analyzer"],"https://rust-analyzer.github.io/"),b("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),b("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),b("kotlin-language-server",["kotlin"],["kotlin-language-server"],["build.gradle.kts","pom.xml"],{kotlin:[".kt",".kts"]},["kotlin-language-server"],"https://github.com/fwcd/kotlin-language-server"),b("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),b("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),b("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),b("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),b("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),b("vscode-css-language-server",["css"],["vscode-css-language-server"],["package.json"],{css:[".css",".scss",".less"]},["vscode-css-language-server","--stdio"],"https://github.com/microsoft/vscode-css-languageservice",void 0,void 0,{css:{},scss:{},less:{}}),b("vscode-html-language-server",["html"],["vscode-html-language-server"],["package.json"],{html:[".html",".htm"]},["vscode-html-language-server","--stdio"],"https://github.com/microsoft/vscode-html-languageservice"),b("yaml-language-server",["yaml"],["yaml-language-server"],[".yamllint","package.json"],{yaml:[".yaml",".yml"]},["yaml-language-server","--stdio"],"https://github.com/redhat-developer/yaml-language-server"),b("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),b("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),b("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),b("kotlin-lsp",["kotlin"],["intellij-server"],["build.gradle.kts","build.gradle","pom.xml","settings.gradle.kts"],{kotlin:[".kt",".kts"]},["intellij-server","--stdio"],"https://github.com/Kotlin/kotlin-lsp"),b("julia-language-server",["julia"],["julia"],["Project.toml","JuliaProject.toml"],{julia:[".jl"]},["julia","--startup-file=no","--history-file=no","-e","using LanguageServer; runserver()"],"https://github.com/julia-vscode/LanguageServer.jl"),b("powershell-editor-services",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],{powershell:[".ps1",".psm1",".psd1"]},["pwsh","-NoProfile","-NonInteractive","-Command",'$ErrorActionPreference="Stop";Import-Module PowerShellEditorServices;$d=Join-Path (Get-Location) ".agents/tmp/powershell-lsp-$PID";[IO.Directory]::CreateDirectory($d)|Out-Null;Start-EditorServices -HostName Pi -HostProfileId Pi -HostVersion 1.0.0 -Stdio -LanguageServiceOnly -LogPath (Join-Path $d "server.log") -SessionDetailsPath (Join-Path $d "session.json")'],"https://github.com/PowerShell/PowerShellEditorServices"),b("neocmakelsp",["cmake"],["neocmakelsp"],["CMakeLists.txt",".neocmake.toml",".neocmakelint.toml"],{cmake:[".cmake"]},["neocmakelsp","stdio"],"https://github.com/neocmakelsp/neocmakelsp",void 0,{cmake:["CMakeLists.txt"]}),b("vscode-json-language-server",["json"],["vscode-json-language-server"],["package.json"],{json:[".json",".jsonc"]},["vscode-json-language-server","--stdio"],"https://github.com/microsoft/vscode-json-languageservice"),b("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),b("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),b("docker-langserver",["dockerfile"],["docker-langserver"],["Dockerfile"],{dockerfile:[".dockerfile"]},["docker-langserver","--stdio"],"https://github.com/rcjsuen/dockerfile-language-server-nodejs",void 0,{dockerfile:["Dockerfile","Containerfile"]})];function b(n,e,t,r,o,s,i,l,c,p){return{id:n,name:n,kind:"lsp",languages:e,executables:t,configFiles:r,documentation:i,...l&&{dependencies:l},lsp:{command:s,rootMarkers:r,languageIds:o,...c&&{fileNames:c},...p&&{settings:p}}}}a(b,"recipe");import Jt from"node:path";import Kt from"cross-spawn";import{createMessageConnection as Xt,CancellationTokenSource as Qt,StreamMessageReader as Yt}from"vscode-jsonrpc/node";import{URI as ct}from"vscode-uri";import{watch as Nt}from"node:fs";import{readdir as qt,stat as Ft}from"node:fs/promises";import z from"node:path";import{URI as le}from"vscode-uri";var ne=class{constructor(e,t,r){this.root=e;this.changed=t;this.failed=r}static{a(this,"LspFileWatchers")}registrations=new Map;disposed=!1;async register(e,t){let r=[];try{for(let o of t){let s=o.globPattern,i=typeof s=="string"?this.root:le.parse(typeof s.baseUri=="string"?s.baseUri:s.baseUri.uri).fsPath,l=typeof s=="string"?s:s.pattern,c=a(g=>z.matchesGlob(z.isAbsolute(l)?z.join(i,g):g,l),"matches"),p=new Set((await qt(i,{recursive:!0})).filter(c));if(this.disposed)throw new Error("Language server file watchers are disposed");let d=Nt(i,{recursive:!0},(g,u)=>{!u||!c(u)||Ft(z.join(i,u)).then(()=>{if(!this.registrations.get(e)?.includes(d))return;let m=p.has(u)?2:1;p.add(u),(o.kind??7)&(m===1?1:2)&&this.changed({uri:le.file(z.join(i,u)).toString(),type:m})},m=>{if(this.registrations.get(e)?.includes(d)){if(m.code!=="ENOENT"){this.failed(m);return}p.delete(u)&&(o.kind??7)&4&&this.changed({uri:le.file(z.join(i,u)).toString(),type:3})}})});d.on("error",this.failed),r.push(d)}}catch(o){for(let s of r)s.close();throw o}this.unregister(e),this.registrations.set(e,r)}unregister(e){for(let t of this.registrations.get(e)??[])t.close();this.registrations.delete(e)}dispose(){this.disposed=!0;for(let e of this.registrations.keys())this.unregister(e)}};import{StreamMessageWriter as Vt}from"vscode-jsonrpc/node";var oe=class extends Vt{constructor(t,r){super(t);this.fail=r}static{a(this,"TransportWriter")}async write(t){try{await super.write(t)}catch(r){this.fail(r)}}};import zt from"node:path";import{URI as Ht}from"vscode-uri";function k(n,e){if(e.startsWith("ssh://")){let t=at(e);if(n.includes("://")){let o=at(n);if(o.host!==t.host)throw new Error("Document belongs to another language server owner");return o.href}let r=zt.posix.resolve(decodeURIComponent(t.pathname),n);return t.pathname=r.split("/").map(encodeURIComponent).join("/"),t.href}if(n.startsWith("ssh://")||n.includes("://")&&!n.startsWith("file://"))throw new Error("Document belongs to another language server owner");return n.startsWith("file://")?n:Ht.file(n).toString()}a(k,"documentUri");function at(n){let e=new URL(n);if(e.protocol!=="ssh:"||!e.hostname||e.username||e.password||e.port||e.search||e.hash)throw new Error("Invalid language server resource owner");return decodeURIComponent(e.pathname),e}a(at,"checkedRemote");async function A(n,e){if(e?.aborted)throw n.catch(()=>{}),e.reason;if(!e)return n;let t;try{return await Promise.race([n,new Promise((r,o)=>{t=a(()=>o(e.reason),"onAbort"),e.addEventListener("abort",t,{once:!0})})])}finally{t&&e.removeEventListener("abort",t)}}a(A,"waitWithSignal");var H=class{static{a(this,"SharedStartup")}controller=new AbortController;promise;settled=!1;waiters=0;constructor(e){this.promise=e(this.controller.signal);let t=a(()=>{this.settled=!0},"settled");this.promise.then(t,t)}async wait(e){this.waiters+=1;let t=await A(this.promise,e).then(r=>({value:r}),r=>({error:r}));if(this.waiters-=1,!this.settled&&this.waiters===0){this.controller.abort(e?.reason);try{await this.promise}catch(r){if(r!==this.controller.signal.reason)throw new AggregateError([this.controller.signal.reason,r],"Startup cancellation and cleanup failed",{cause:r})}}if("error"in t)throw t.error;return t.value}};var Gt=new Set(["uri","targetUri","target","oldUri","newUri","rootUri","documentUri","scopeUri","baseUri"]),Bt=new Set(["changes","relatedDocuments"]);function j(n,e){return Array.isArray(n)?n.map(t=>j(t,e)):typeof n!="object"||n===null?n:Object.fromEntries(Object.entries(n).map(([t,r])=>Gt.has(t)&&typeof r=="string"?[t,e(r)]:Bt.has(t)&&typeof r=="object"&&r!==null&&!Array.isArray(r)?[t,Object.fromEntries(Object.entries(r).map(([o,s])=>[e(o),j(s,e)]))]:[t,j(r,e)]))}a(j,"mapLspUris");var $=class{static{a(this,"LspClient")}_process=null;_ownedProcess=null;_ownedStartup;_ownerTransport;_connection=null;_initialized=!1;_serverCapabilities=null;_disposed=!1;_shutdownPromise;_crashed=!1;_stderr="";_fileWatchers;_fileWatcherCleanup=Promise.resolve();_handlers=new Map;_documentVersions=new Map;_documentContents=new Map;_diagnosticPublications=new Map;_diagnosticMode="unknown";_activeDiagnosticRequests=new Set;serverId;rootUri;_command;_args;_env;_initOptions;_settings;_timeoutMs;constructor(e){this.serverId=e.serverId,this.rootUri=e.rootUri,this._command=e.command,this._args=e.command.slice(1),this._env=e.env??{},this._initOptions=e.initOptions,this._settings=e.settings,this._timeoutMs=e.timeoutMs??3e4,this._ownerTransport=e.ownerTransport}get ready(){return this._initialized&&!this._disposed}get crashed(){return this._crashed}get pid(){return this._process?.pid??null}get remote(){return this._ownedProcess?.remote}get commandName(){return $e(this._command)}get diagnosticMode(){return this._diagnosticMode}setDiagnosticMode(e){this._diagnosticMode=e}get timeoutMs(){return this._timeoutMs}supportsCommand(e){let t=this._serverCapabilities?.executeCommandProvider;return Array.isArray(t?.commands)&&t.commands.includes(e)}get hasWorkspaceSymbolCapability(){let e=this._serverCapabilities?.workspaceSymbolProvider;return e===!0||typeof e=="object"&&e!==null}get hasFoldingRangeCapability(){let e=this._serverCapabilities?.foldingRangeProvider;return e===!0||typeof e=="object"&&e!==null}documentContent(e){return this._documentContents.get(e)}documentVersion(e){return this._documentVersions.get(e)}diagnosticPublication(e){return this._diagnosticPublications.get(e)}beginDiagnosticRequest(e){this._activeDiagnosticRequests.add(e)}endDiagnosticRequest(e){this._activeDiagnosticRequests.delete(e)}hasActiveDiagnosticRequest(e){return this._activeDiagnosticRequests.has(e)}async start(e){e?.throwIfAborted();try{await this._start(e)}catch(t){try{await this.shutdown()}catch(r){throw new AggregateError([e?.aborted?e.reason:t,r],`[lsp] ${this.serverId}: startup and cleanup failed`,{cause:r})}throw e?.throwIfAborted(),t}}async _start(e){if(this._initialized)return;if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);if(!this.rootUri.startsWith("file://")&&!this._ownerTransport)throw Object.assign(new Error("No language server process transport for this resource owner"),{code:"UNSUPPORTED_SOURCE"});if(await this._closeFileWatchers(),e?.throwIfAborted(),this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let t=_(this._command[0]),r=this._ownerTransport?decodeURIComponent(new URL(this.rootUri).pathname):ct.parse(this.rootUri).fsPath,o=[{uri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,name:Jt.basename(r)||r}];this._ownedStartup=this._ownerTransport?.start({rootUri:this.rootUri,command:this._command,env:this._env,signal:e});let s=await this._ownedStartup;if(this._ownedProcess=s??null,e?.throwIfAborted(),this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let i=s?void 0:Kt(t,this._args,{stdio:["pipe","pipe","pipe"],...e&&{signal:e},cwd:r,env:qe({command:this._command,env:this._env},r,process.env)});this._process=i??null;let l=i?Zt(i):Promise.resolve(),c=_(s?.stdin??i?.stdin),p=_(s?.stdout??i?.stdout),d=_(s?.stderr??i?.stderr);c.on("error",()=>{}),p.on("error",()=>{}),d.on("error",()=>{}),this._stderr="",d.setEncoding("utf8"),d.on("data",h=>{this._stderr=(this._stderr+h).slice(-4096)}),i?.on("error",h=>{("code"in h?h.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,h),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null});let g=a(h=>{(s?this._ownedProcess!==s:this._process!==i)||(this._closeFileWatchers(),!this._disposed&&h!==0&&h!==null&&(this._crashed=!0),this._connection?.dispose(),this._connection=null,this._diagnosticPublications.clear(),this._activeDiagnosticRequests.clear(),this._diagnosticMode="unknown",this._process=null,this._initialized=!1)},"onExit");i?.on("exit",g),s?.completion.then(({exitCode:h})=>g(h),()=>{this._ownedProcess===s&&(this._crashed=!0,g(null))}),await A(l,e);let u=Xt(new Yt(p),new oe(c,h=>{this._connection!==u||this._disposed||(this._crashed=!0,this._initialized=!1,this._closeFileWatchers(),u.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,h))}));this._connection=u,this._connection.onError(h=>{console.error(`[lsp] ${this.serverId}: connection error:`,h)});let m=a(h=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[h]})},"changed"),y=a(h=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,h),"failed");this._fileWatchers=this._ownerTransport?this._ownerTransport.fileWatchers?.(this.rootUri,m,y):new ne(r,m,y),this._connection.onRequest("client/registerCapability",async h=>{for(let w of h.registrations)if(w.method!=="workspace/didChangeConfiguration"){if(w.method!=="workspace/didChangeWatchedFiles")throw new Error(`Unsupported dynamic capability: ${w.method}`);if(!this._fileWatchers)throw new Error("File watching is unavailable for this server owner");await this._fileWatchers.register(w.id,w.registerOptions?.watchers??[])}return null}),this._connection.onRequest("client/unregisterCapability",async h=>{for(let w of h.unregisterations)await this._fileWatchers?.unregister(w.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/configuration",h=>h.items.map(w=>{let S=this._settings??null;for(let R of w.section?.split(".").filter(Boolean)??[])S=typeof S=="object"&&S!==null?S[R]??null:null;return S})),this._connection.listen(),this._connection.onNotification((h,...w)=>{let S=this._ownerTransport,R=S?j(w[0],v=>S.fromServerUri(v)):w[0];if(h==="textDocument/publishDiagnostics"){let v=R;v&&typeof v.uri=="string"&&Array.isArray(v.diagnostics)&&this._documentVersions.has(v.uri)&&(v.version===void 0||v.version===this.documentVersion(v.uri))&&this._diagnosticPublications.set(v.uri,{diagnostics:v.diagnostics,...typeof v.version=="number"&&{version:v.version}})}for(let v of this._handlers.get(h)??[])v(R)}),this._connection.onRequest("workspace/workspaceFolders",()=>o);let f=await A(lt(this._connection.sendRequest("initialize",{processId:this._ownerTransport?null:process.pid,rootUri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,workspaceFolders:o,capabilities:{workspace:{applyEdit:!1,configuration:!0,workspaceFolders:!0,didChangeWatchedFiles:{dynamicRegistration:this._fileWatchers!==void 0,relativePatternSupport:this._fileWatchers!==void 0},symbol:{dynamicRegistration:!1}},textDocument:{synchronization:{didOpen:!0,didChange:!0,didClose:!0},publishDiagnostics:{relatedInformation:!0},diagnostic:{dynamicRegistration:!1,relatedDocumentSupport:!1},documentSymbol:{hierarchicalDocumentSymbolSupport:!0},foldingRange:{lineFoldingOnly:!0}}},initializationOptions:this._initOptions}),this._timeoutMs,`[lsp] ${this.serverId}: initialize timed out`),e).catch(h=>{let w=this._stderr.trim();throw w?new Error(`[lsp] ${this.serverId}: ${w}`,{cause:h}):h});if(await this._connection.sendNotification("initialized",{capabilities:f.capabilities}),this._settings!==void 0&&await this._connection.sendNotification("workspace/didChangeConfiguration",{settings:this._settings}),this._crashed)throw new Error(`[lsp] ${this.serverId}: transport failed during initialization`);e?.throwIfAborted(),this._initialized=!0,this._serverCapabilities=f.capabilities,this._diagnosticMode=f.capabilities.diagnosticProvider?"pull":"push"}touch(){}async restart(e){await this.shutdown(),this._closeFileWatchers(),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1,this._crashed=!1,this._disposed=!1,this._shutdownPromise=void 0,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null,await this.start(e)}async sendRequest(e,t,r){this._assertReady(),r?.throwIfAborted();let o=this._ownerTransport,s=o?j(t,p=>o.toServerUri(p)):t,i=a(p=>o?j(p,d=>o.fromServerUri(d)):p,"mapResult");if(!r)return i(await _(this._connection).sendRequest(e,s));let l=new Qt,c;try{let p=_(this._connection).sendRequest(e,s,l.token);return i(await Promise.race([p,new Promise((d,g)=>{c=a(()=>{l.cancel(),g(r.reason)},"onAbort"),r.addEventListener("abort",c,{once:!0})})]))}finally{c&&r.removeEventListener("abort",c),l.dispose()}}sendNotification(e,t){this._assertReady(),this._sendNotification(e,t)}_sendNotification(e,t){let r=this._connection;if(!r)return;let o=this._ownerTransport,s=o?j(t,i=>o.toServerUri(i)):t;r.sendNotification(e,s).catch(i=>{this._connection!==r||this._disposed||(this._crashed=!0,this._initialized=!1,this._closeFileWatchers(),r.dispose(),console.error(`[lsp] ${this.serverId}: notification ${e} failed:`,i))})}onNotification(e,t){let r=this._handlers.get(e)??[];return r.push(t),this._handlers.set(e,r),()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}toUri(e){return k(e,this.rootUri)}serverDocumentPath(e){let t=this.toUri(e),r=this._ownerTransport?.toServerUri(t)??t;return this._ownerTransport?decodeURIComponent(new URL(r).pathname):ct.parse(r).fsPath}openDocument(e,t,r,o=1){let s=this._documentVersions.get(e);if(s!==void 0){this.changeDocument(e,t,Math.max(o,s+1));return}this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:r,version:o,text:t}}),this._documentVersions.set(e,o),this._documentContents.set(e,t)}syncDocument(e,t,r,o=!1){if(this._documentContents.get(e)===t)return;let s=this._documentVersions.get(e);s===void 0?this.openDocument(e,t,r):this.changeDocument(e,t,s+1);let i=this._serverCapabilities?.textDocumentSync,l=typeof i=="object"&&i!==null?i.save:void 0;o&&l&&this.sendNotification("textDocument/didSave",{textDocument:{uri:e},...typeof l=="object"&&l.includeText&&{text:t}})}changeDocument(e,t,r){let o=this._documentVersions.get(e),s=Math.max(r,(o??0)+1);this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didChange",{textDocument:{uri:e,version:s},contentChanges:[{text:t}]}),this._documentVersions.set(e,s),this._documentContents.set(e,t)}closeDocument(e){this.sendNotification("textDocument/didClose",{textDocument:{uri:e}}),this._documentVersions.delete(e),this._documentContents.delete(e),this._diagnosticPublications.delete(e)}shutdown(){return this._shutdownPromise??=this._shutdown()}async _shutdown(){this._disposed=!0;let e=this._closeFileWatchers();if(this._connection&&this._initialized)try{await lt(this._connection.sendRequest("shutdown"),Math.min(this._timeoutMs,1e3),`[lsp] ${this.serverId}: shutdown timed out`),await this._connection.sendNotification("exit").catch(()=>{})}catch{}this._connection?.dispose(),this._connection=null;let t=this._ownedProcess??await this._ownedStartup?.catch(()=>{});this._ownedProcess=null,this._ownedStartup=void 0;let r=Promise.resolve().then(()=>t?.stop()),o=this._process;this._process=null,o&&!o.killed&&(o.kill("SIGTERM"),setTimeout(()=>{o.exitCode===null&&o.signalCode===null&&o.kill("SIGKILL")},2e3).unref()),this._initialized=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null;let s=await Promise.allSettled([r,e]),i=[];for(let l of s)l.status==="rejected"&&i.push(l.reason);if(i.length>0)throw new AggregateError(i,`[lsp] ${this.serverId}: owned cleanup failed`)}dispose(){return this.shutdown()}_closeFileWatchers(){let e=this._fileWatchers;return this._fileWatchers=void 0,e&&(this._fileWatcherCleanup=this._fileWatcherCleanup.catch(()=>{}).then(()=>e.dispose()),this._fileWatcherCleanup.catch(t=>{console.error(`[lsp] ${this.serverId}: file watcher cleanup failed:`,t)})),this._fileWatcherCleanup}_assertReady(){if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);if(this._crashed)throw new Error(`[lsp] ${this.serverId}: crashed \u2014 call restart()`);if(!this._initialized)throw new Error(`[lsp] ${this.serverId}: not started \u2014 call start()`);if(!this._connection)throw new Error(`[lsp] ${this.serverId}: connection lost`)}};function Zt(n){return new Promise((e,t)=>{let r=a(()=>{n.off("spawn",o),n.off("error",s)},"cleanup"),o=a(()=>{r(),e()},"onSpawn"),s=a(i=>{r(),t(i)},"onError");n.once("spawn",o),n.once("error",s)})}a(Zt,"waitForSpawn");function lt(n,e,t){return new Promise((r,o)=>{let s=setTimeout(()=>{o(new Error(t))},e);n.then(i=>{clearTimeout(s),r(i)}).catch(i=>{clearTimeout(s),o(i instanceof Error?i:new Error(String(i)))})})}a(lt,"withTimeout");import{readFile as pt}from"node:fs/promises";import{URI as ut}from"vscode-uri";var K={Error:1,Warning:2,Information:3,Hint:4};var dt={command:"typescript.tsserverRequest",async request(n,e,t){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async o=>{let s=await n.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[o,{file:n.serverDocumentPath(e),includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},t);if(!de(s)||s.success!==!0||!Array.isArray(s.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${o}`);return s.body.map(er)}))).flat()}};function se(n){return n.supportsCommand(dt.command)?dt:void 0}a(se,"completedDiagnosticAdapter");function er(n){if(!de(n)||typeof n.message!="string"||typeof n.code!="number"&&typeof n.code!="string"||!de(n.startLocation)||!Number.isInteger(n.startLocation.line)||!Number.isInteger(n.startLocation.offset)||Number(n.startLocation.line)<1||Number(n.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(n.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(n.code),message:n.message,line:Number(n.startLocation.line),column:Number(n.startLocation.offset),severity:n.category==="error"?"error":n.category==="warning"?"warning":n.category==="suggestion"?"hint":"info"}}a(er,"convertTypeScriptDiagnostic");function de(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}a(de,"isRecord");async function X(n,e,t,r={}){let o=new AbortController,s=AbortSignal.any([o.signal,...r.signal?[r.signal]:[]]),i=setTimeout(()=>o.abort(new Error(`[lsp] ${n.serverId}: diagnostics timed out for ${e}`)),n.timeoutMs);try{return await tr(n,e,t,r.content,s)}finally{clearTimeout(i)}}a(X,"requestDiagnostics");async function tr(n,e,t,r,o){if(o.throwIfAborted(),n.diagnosticMode!=="push"){let c=n.documentVersion(e);try{let p=await n.sendRequest("textDocument/diagnostic",{textDocument:{uri:e}},o);if(p.kind!=="full"||!Array.isArray(p.items))throw new Error("Invalid full diagnostic report");if(n.documentVersion(e)!==c)throw new Error("Document changed during diagnostic request");return n.setDiagnosticMode("pull"),gt(p.items,!1,!0)}catch(p){if(!rr(p))throw p;n.setDiagnosticMode("push")}}let s=se(n);if(s){n.documentVersion(e)===void 0&&n.syncDocument(e,r??await pt(ut.parse(e).fsPath,"utf8"),t??"plaintext");let c=n.documentVersion(e),p=await s.request(n,e,o);if(o.throwIfAborted(),n.documentVersion(e)!==c)throw new Error("Document changed during diagnostic request");return{diagnostics:p,syntaxErrors:[],otherDiagnostics:p,unversioned:!1,complete:!0}}o.throwIfAborted();let i=n.documentVersion(e)!==void 0,l=i?void 0:r??await pt(ut.parse(e).fsPath,"utf8");o.throwIfAborted(),n.beginDiagnosticRequest(e);try{return await new Promise((c,p)=>{let d=n.documentVersion(e)??1,g=a(f=>{let h=f;h.uri!==e||!Array.isArray(h.diagnostics)||h.version!==void 0&&h.version!==d||n.documentVersion(e)===d&&(y(),c(gt(h.diagnostics,h.version===void 0)))},"receive"),u=n.onNotification("textDocument/publishDiagnostics",g),m=a(()=>{y(),p(o.reason)},"onAbort");function y(){u(),o.removeEventListener("abort",m)}a(y,"cleanup"),o.addEventListener("abort",m,{once:!0});try{i||n.syncDocument(e,l??"",t??"plaintext");let f=n.diagnosticPublication(e);f&&g({uri:e,...f})}catch(f){y(),p(f)}})}finally{n.endDiagnosticRequest(e)}}a(tr,"requestCurrentDiagnostics");function pe(n){return{code:String(n.code??"LSP"),message:n.message,line:n.range.start.line+1,column:n.range.start.character+1,severity:n.severity===K.Warning?"warning":n.severity===K.Information?"info":n.severity===K.Hint?"hint":"error"}}a(pe,"toDiagnostic");function gt(n,e,t=!1){let r=n.map(pe);return{diagnostics:r,syntaxErrors:[],otherDiagnostics:r,unversioned:e,complete:t}}a(gt,"classify");function rr(n){return n!==null&&typeof n=="object"&&"code"in n&&n.code===-32601}a(rr,"isMethodNotFound");var nr={1:"File",2:"Module",3:"Namespace",4:"Package",5:"Class",6:"Method",7:"Property",8:"Field",9:"Constructor",10:"Enum",11:"Interface",12:"Function",13:"Variable",14:"Constant",15:"String",16:"Number",17:"Boolean",18:"Array",19:"Object",20:"Key",21:"Null",22:"EnumMember",23:"Struct",24:"Event",25:"Operator",26:"TypeParameter"};function T(n){return nr[n]??`SymbolKind(${n})`}a(T,"symbolKindName");async function Q(n,e,t){return await n.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}},t)??[]}a(Q,"requestDocumentSymbols");async function ue(n,e,t=100,r){return(await n.sendRequest("workspace/symbol",{query:e},r)??[]).slice(0,t)}a(ue,"requestWorkspaceSymbols");async function ie(n,e,t,r){return await n.sendRequest("textDocument/rename",{textDocument:{uri:e},position:t,newName:r})}a(ie,"requestRename");import Z from"node:path";import{URI as ar}from"vscode-uri";import{createHash as or}from"node:crypto";import{readdir as sr,stat as ae}from"node:fs/promises";import O from"node:path";import{URI as me}from"vscode-uri";async function ge(n,e){if(!n.supportsCommand("typescript.tsserverRequest"))return;if((await n.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:e,needFileNameList:!0},{isAsync:!1,expectsResult:!0}]}))?.success!==!0)throw new Error("TypeScript could not load the project for a workspace query.")}a(ge,"prepareProjectQuery");function mt(n,e){let t=a(r=>typeof r=="string"?r.replaceAll("{project}",()=>e):Array.isArray(r)?r.map(t):r!==null&&typeof r=="object"?Object.fromEntries(Object.entries(r).map(([o,s])=>[o,t(s)])):r,"expand");return Object.fromEntries(Object.entries(n).map(([r,o])=>[r,t(o)]))}a(mt,"resolveInitializationOptions");var W=class n{constructor(e,t){this._registry=e;this._owner=t}static{a(this,"LspManager")}_clients=new Map;_clientStarts=new Map;_openDocs=new Set;_pushUnsubscribers=new Map;_pushHandlers=new Set;_pushFingerprints=new Map;_disposed=!1;static _instance=null;static getInstance(){if(!n._instance)throw new Error("[lsp] LspManager not initialized");return n._instance}static getInstanceOrNull(){return n._instance}static init(e,t){let r=n._instance;return r?._disposed?(r._registry=e,r._owner=t,r._disposed=!1,r):(n._instance=new n(e,t),n._instance)}static async resetForTest(){n._instance&&(await n._instance.shutdownAll(),n._instance=null)}requireOwner(){if(!this._owner)throw Object.assign(new Error("No language server workspace owner"),{code:"UNSUPPORTED_SOURCE"});return this._owner}get workspaceRoot(){return this._registry.projectRoot}get clientCount(){return this._clients.size}onPushDiagnostics(e){return this._pushHandlers.add(e),()=>this._pushHandlers.delete(e)}async getOrStart(e,t,r,o){if(o?.throwIfAborted(),this._disposed)return null;let s=t.startsWith("ssh://"),i=s?this.requireOwner():void 0,l=i?await this._registry.resolveOwned(e,f=>i.exists(f,o)):this._registry.resolve(e);if(o?.throwIfAborted(),this._disposed)return null;let c=r==="symbols"?l[0]:l.find(f=>f.config.capabilities.includes(r));if(!c)return null;let p=s?t:me.file(t).toString(),d=`${c.serverId}:${p}`,g=this._clientStarts.get(d);if(g)return g.controller.signal.aborted?(await A(g.promise.catch(()=>{}),o),this.getOrStart(e,t,r,o)):g.wait(o);let u=this._clients.get(d);if(u?.ready)return u;let m=new H(f=>this._startClient(d,p,c,u,f));this._clientStarts.set(d,m);let y=a(()=>{this._clientStarts.get(d)===m&&this._clientStarts.delete(d)},"settled");return m.promise.then(y,y),m.wait(o)}async _startClient(e,t,r,o,s){let i=o??new $({serverId:r.serverId,rootUri:t,command:r.config.command,...t.startsWith("ssh://")&&this._owner&&{ownerTransport:this._owner.transport(t)},...r.config.env&&{env:r.config.env},...r.config.initializationOptions&&{initOptions:mt(r.config.initializationOptions,t.startsWith("ssh://")?decodeURIComponent(new URL(t).pathname):me.parse(t).fsPath)},...r.config.settings&&{settings:r.config.settings},...r.config.timeoutMs&&{timeoutMs:r.config.timeoutMs}});try{o?await o.restart(s):await i.start(s),s.throwIfAborted()}catch(l){try{await i.shutdown()}catch(c){if(c!==l)throw new AggregateError([l,c],"Language server startup and cleanup failed",{cause:c})}throw l}if(this._disposed)throw await i.shutdown(),new Error(`[lsp] ${r.serverId}: manager disposed during startup`);return this._clients.set(e,i),this._subscribeToPushDiagnostics(e,i),i}async isSourceFile(e,t,r){if(r?.throwIfAborted(),t.startsWith("ssh://")){if(this._owner===void 0)throw new Error("No language server workspace owner");return this._owner.isFile(k(e,t),r)}let o=await ae(O.resolve(t,e));return r?.throwIfAborted(),o.isFile()}async getWorkspaceClients(e,t="symbols",r=e,o=()=>!0,s){if(s?.throwIfAborted(),e.startsWith("ssh://")){let g=this._owner;if(!g)throw Object.assign(new Error("No language server workspace owner"),{code:"UNSUPPORTED_SOURCE"});let u=new Set,m=new Set(this._registry.knownExtensions),y=new Set([".git",".cache","node_modules","dist","build"]),f=a(async w=>{if(s?.throwIfAborted(),m.size!==0)for(let S of await g.entries(w,s)){s?.throwIfAborted();let R=k(S.name,`${w}/`);if(S.kind==="directory")y.has(S.name)||await f(R);else if(S.kind==="file"){let v=O.posix.extname(S.name).toLowerCase();if(!m.has(v)||!o(R))continue;let D=await this.openFile(R,e,t,s);D&&(u.add(D.client),m.delete(v))}}},"visit"),h=k(r,e);if(await g.isFile(h,s)){if(!o(h))return[];let w=await this.openFile(h,e,t,s);return w?[w.client]:[]}return await f(h),[...u]}let i=new Set,l=new Set(this._registry.knownExtensions),c=new Set([".git",".cache","node_modules","dist","build"]),p=a(async g=>{if(s?.throwIfAborted(),l.size===0)return;let u;try{u=await sr(g,{withFileTypes:!0})}catch{return}for(let m of u){if(s?.throwIfAborted(),l.size===0)return;if(m.isDirectory()){c.has(m.name)||await p(O.join(g,m.name));continue}if(!m.isFile())continue;let y=O.extname(m.name).toLowerCase();if(!l.has(y))continue;let f=O.join(g,m.name);if(!o(f))continue;let h=await this.openFile(f,e,t,s);h&&(l.delete(y),h.client.hasWorkspaceSymbolCapability&&(await ge(h.client,f),i.add(h.client)))}},"visit"),d=O.resolve(e,r);if((await ae(d)).isFile()){if(!o(d))return[];let g=await this.openFile(d,e,t,s);return g===null||!g.client.hasWorkspaceSymbolCapability?[]:(await ge(g.client,d),[g.client])}return await p(d),s?.throwIfAborted(),[...i]}async prepareWorkspaceSymbols(e,t=e,r,o){return this.getWorkspaceClients(e,"symbols",t,r,o)}hasServerFor(e){return this._registry.resolve(e).length>0}languageId(e){return this._registry.languageId(e)}isOpen(e){return this._openDocs.has(e)}syncEditedSource(e,t){for(let r of this._clients.values()){if(!r.ready)continue;let o=r.toUri(e);if(r.documentContent(o)===void 0)continue;let s=this.languageId(O.extname(decodeURIComponent(new URL(o).pathname)));r.syncDocument(o,t,s,!0)}}async readSourceSnapshot(e,t){if(t?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readSnapshot(e,t);if(e.includes("://"))throw Object.assign(new Error("Unsupported rename source"),{code:"UNSUPPORTED_SOURCE"});let r=a(i=>`${i.dev}:${i.ino}:${i.mode}:${i.size}:${i.mtimeMs}:${i.ctimeMs}`,"identity"),o=r(await ae(e)),s=await this.readSourceText(e,t);if(o!==r(await ae(e)))throw new Error("A rename source changed while reading it. No edits applied.");return{content:s,version:or("sha256").update(o).update("\0").update(s).digest("hex")}}async readSourceBytes(e,t){if(t?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readBytes(e,t);if(e.includes("://"))throw Object.assign(new Error("Unsupported declaration source"),{code:"UNSUPPORTED_SOURCE"});let{readFile:r}=await import("node:fs/promises");return r(e,{signal:t})}async readSourceText(e,t){if(t?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readText(e,t);if(e.includes("://"))throw Object.assign(new Error("Unsupported declaration source"),{code:"UNSUPPORTED_SOURCE"});let{readFile:r}=await import("node:fs/promises");return r(e,{encoding:"utf8",signal:t})}async openFile(e,t,r="diagnostics",o){if(o?.throwIfAborted(),e.startsWith("ssh://")&&!t.startsWith("ssh://")){if(!this._registry.projectRoot.startsWith("ssh://"))throw Object.assign(new Error("Remote document has no workspace owner"),{code:"UNSUPPORTED_SOURCE"});t=this._registry.projectRoot}let s=t.startsWith("ssh://"),i=s?k(e,t):O.resolve(t,e),l=await this.getOrStart(i,t,r,o);if(!l)return null;let c=l.toUri(i),p=s?this.requireOwner():void 0,g=(p?await this._registry.resolveOwned(i,u=>p.exists(u,o)):this._registry.resolve(i))[0]?.languageId??"plaintext";if(p){let u=await p.readText(c,o);return o?.throwIfAborted(),l.syncDocument(c,u,g),this._openDocs.add(c),{client:l,uri:c,languageId:g}}try{let{readFile:u}=await import("node:fs/promises"),m=await u(i,{encoding:"utf8",signal:o});o?.throwIfAborted(),l.syncDocument(c,m,g),this._openDocs.add(c)}catch(u){if(o?.throwIfAborted(),!(u instanceof Error&&"code"in u&&u.code==="ENOENT"))throw u}return{client:l,uri:c,languageId:g}}_subscribeToPushDiagnostics(e,t){if(this._pushUnsubscribers.has(e))return;let r=t.onNotification("textDocument/publishDiagnostics",o=>{let s=ir(o);if(!s||t.hasActiveDiagnosticRequest(s.uri))return;let i=t.documentVersion(s.uri);if(s.version!==void 0&&i!==void 0&&s.version<i)return;let l=`${e}:${s.uri}`,c=s.diagnostics.map(pe),p=JSON.stringify([s.version,i,c]);if(this._pushFingerprints.get(l)===p)return;this._pushFingerprints.set(l,p);let d={cwd:t.rootUri.startsWith("ssh://")?t.rootUri:me.parse(t.rootUri).fsPath,serverId:t.serverId,uri:s.uri,diagnostics:c,...s.version!==void 0&&{version:s.version}};for(let g of this._pushHandlers)g(d)});this._pushUnsubscribers.set(e,r)}async shutdownAll(){this._disposed=!0;let e=[...this._clientStarts.values()];for(let i of e)i.controller.abort(new Error("Language server manager stopped"));let t=await Promise.allSettled(e.map(i=>i.promise)),r=[];for(let[i,l]of t.entries())l.status==="rejected"&&l.reason!==e[i]?.controller.signal.reason&&r.push(l.reason);let o=[...this._clients.values()],s=await Promise.allSettled(o.map(i=>i.shutdown()));for(let i of this._pushUnsubscribers.values())i();this._pushUnsubscribers.clear(),this._clientStarts.clear(),this._pushFingerprints.clear(),this._pushHandlers.clear(),this._clients.clear();for(let i of s)i.status==="rejected"&&r.push(i.reason);if(r.length>0)throw new AggregateError(r,"Language server cleanup failed")}dispose(){return this.shutdownAll()}};function ir(n){if(n===null||typeof n!="object")return;let e=n;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}a(ir,"parsePushNotification");async function fe(n,e,t){if(t?.throwIfAborted(),!n.supportsCommand("typescript.tsserverRequest"))return;let r=await n.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:n.serverDocumentPath(e),needFileNameList:!0},{isAsync:!1,expectsResult:!0}]},t);if(t?.throwIfAborted(),r?.success!==!0)throw new Error("TypeScript could not load the project for the workspace query.")}a(fe,"loadQueryProject");async function Y(n,e,t,r){return await fe(n,e,r),await n.sendRequest("textDocument/references",{textDocument:{uri:e},position:t,context:{includeDeclaration:!0}},r)??[]}a(Y,"requestReferences");async function he(n,e,t,r){let o=await n.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:t},r),s=o?.[0];if(!s)return{items:[],incoming:[],outgoing:[]};let[i,l]=await Promise.all([n.sendRequest("callHierarchy/incomingCalls",{item:s},r),n.sendRequest("callHierarchy/outgoingCalls",{item:s},r)]);return{items:o,incoming:i??[],outgoing:l??[]}}a(he,"requestCallHierarchy");function G(n,e,t){let r=e.startsWith("ssh://"),o=r?Z.posix:Z,s=a(d=>r?decodeURIComponent(new URL(k(d,e)).pathname):d,"native"),i=r?s(t.path??e):Z.resolve(e,t.path??"."),l=o.relative(i,s(n));if(l===".."||l.startsWith(`..${o.sep}`)||o.isAbsolute(l))return!1;let c=o.relative(s(e),s(n)).split(o.sep).join("/"),p=a(d=>d.split(",").some(g=>{let u=g.trim();return u.length>0&&o.matchesGlob(u.includes("/")?c:o.basename(s(n)),u)}),"matches");return(t.include===void 0||p(t.include))&&(t.exclude===void 0||!p(t.exclude))}a(G,"withinScope");function ye(n,e){let t=k(n,e);if(t.startsWith("ssh://"))return t;let r=ar.parse(t);if(r.scheme!=="file")throw new Error("Unsupported LSP source location.");return Z.resolve(r.fsPath)}a(ye,"sourceOf");function cr(n,e){return n.start.line===e.start.line&&n.start.character===e.start.character&&n.end.line===e.end.line&&n.end.character===e.end.character}a(cr,"sameRange");function ft(n,e,t){return n.flatMap(r=>[...r.name===e&&r.range!==void 0&&cr(r.range,t)&&r.selectionRange!==void 0?[r.selectionRange]:[],...ft(r.children??[],e,t)])}a(ft,"declarationNames");async function we(n,e,t,r,o={},s=W.getInstance()){r?.throwIfAborted();let i=o.resultScope;if(i!==void 0&&(await F(i,r),i.targets.length===0))return{hits:[],complete:i.complete};if(i===void 0&&o.path!==void 0&&!G(e.startsWith("ssh://")?k(o.path,e):Z.resolve(e,o.path),e,o)&&await s.isSourceFile(o.path,e,r))return{hits:[],complete:!0};let l=i?.targets.map(y=>y.source)??[o.path??e],c=new Set((await Promise.all(l.map(y=>s.prepareWorkspaceSymbols(e,y,f=>G(f,e,o),r)))).flat());if(c.size===0)throw new Error("LSP symbol search is unavailable: no provider supports workspace/symbol in this scope.");let p=new Map,d=a(async y=>{r?.throwIfAborted();let f=ye(y.uri,e),h=p.get(f);if(h===void 0){let{content:L,version:N}=await s.readSourceSnapshot(f,r);h={document:Ee(f,L),version:N},p.set(f,h)}let{document:w}=h,{start:S,end:R}=y.range,v=[S,R];for(let L of v){let N=w.lines[L.line];if(!Number.isInteger(L.line)||!Number.isInteger(L.character)||N===void 0||L.character<0||L.character>N.content.length)throw new Error("LSP range does not match its source snapshot.")}let D=_(w.lines[S.line]),re=a(L=>w.lines.slice(0,L).reduce((N,xe)=>N+xe.content.length+xe.lineEnding.length,0),"offset"),U=re(S.line)+S.character,C=re(R.line)+R.character;if(C<U)throw new Error("LSP returned a reversed source range.");return{source:f,lineNumber:S.line+1,endLineNumber:R.line+1,startColumn:S.character,endColumn:R.character,matchedText:w.content.slice(U,C),lineText:D.content}},"toMatch"),g=a(y=>G(y.source,e,o)&&(i===void 0||st(i,y)),"included"),u=[],m=new Set;for(let y of c){r?.throwIfAborted();let f=await ue(y,n,Number.MAX_SAFE_INTEGER,r);for(let h of f){if(r?.throwIfAborted(),!G(ye(h.location.uri,e),e,{}))continue;let w=await d(h.location),S=await s.openFile(w.source,e,"symbols",r);if(S===null)throw new Error("LSP references are unavailable for a discovered declaration.");let R=h.location;if(w.matchedText!==h.name){let C=await Q(S.client,S.uri,r),L=ft(C,h.name,h.location.range);if(L.length!==1)throw new Error("LSP declaration has no unique provider selectionRange; cannot search its references.");R={uri:S.uri,range:_(L[0])}}let v=await d(R),D={id:JSON.stringify([y.serverId,v.source,h.location.range]),name:h.name,kind:String(h.kind),source:v.source,range:{startLine:v.lineNumber,startColumn:v.startColumn,endLine:v.endLineNumber??v.lineNumber,endColumn:v.endColumn}},re=await Y(S.client,S.uri,R.range.start,r);r?.throwIfAborted();let U=[{...v,role:"definition",symbol:D}];for(let C of re){if(!G(ye(C.uri,e),e,{}))continue;let L=await d(C);L.source===v.source&&L.lineNumber===v.lineNumber&&L.startColumn===v.startColumn&&L.endLineNumber===v.endLineNumber&&L.endColumn===v.endColumn||U.push({...L,role:"reference",symbol:D})}if(!(o.navigation==="references"&&!U.some(g)))for(let C of U){if(o.navigation!=="references"&&!g(C)||o.navigation==="references"&&!G(C.source,e,{}))continue;let L=JSON.stringify([D.id,C.source,C.lineNumber,C.startColumn,C.endLineNumber,C.endColumn]);m.has(L)||(m.add(L),u.push(C))}}}r?.throwIfAborted();for(let[y,f]of p){let h=await s.readSourceSnapshot(y,r);if(h.version!==f.version||h.content!==f.document.content)throw new Error("LSP source changed during search.")}return i!==void 0&&await F(i,r),u.sort((y,f)=>y.source.localeCompare(f.source)||y.lineNumber-f.lineNumber||y.startColumn-f.startColumn||y.endColumn-f.endColumn||y.symbol.id.localeCompare(f.symbol.id)),{hits:u.slice(0,t),complete:(i?.complete??!0)&&u.length<=t}}a(we,"searchSymbols");import{readFile as lr}from"node:fs/promises";import ve from"node:path";import{fileURLToPath as dr}from"node:url";var pr={failureLabel:"SYMBOL_READ_FAILED",emptyReason:"no symbol source was produced."},be=10,Se=5,B=10;async function yt(n,e,t,r,o){x(o);let s=await n.readSourceText(e,o),i=await te(n,e,r,o),l=ee(i.symbols,t,i.displayPath),c=await n.readSourceText(i.filePath,o);if(x(o),s!==c)throw new Error("The symbol source changed during resolution. Read it again before editing.");return{source:i.filePath,range:l.range,content:c}}a(yt,"resolveLspDeclaration");async function wt(n,e,t,r,o){x(o);let s=await n.readSourceText(e,o),i=await te(n,e,r,o),l=ee(i.symbols,t,i.displayPath);if(s!==await n.readSourceText(e,o))throw new Error("The rename source changed during resolution.");return x(o),{client:i.client,uri:i.uri,position:l.selectionRange.start,content:s}}a(wt,"resolveLspRenameTarget");async function Pe(n,e,t,r,o){x(o);let s=await te(n,e,r,o),i=ee(s.symbols,t,s.displayPath),l=await yr(s.filePath,n,o);x(o);let c=i.range.start.line+1,p=Math.min(i.range.end.line+1,l.lines.length),d=l.lines.slice(Math.max(0,c-1),Math.max(0,p)).map((u,m)=>{let y=c+m;return Ie({content:u,sourceLine:{source:s.filePath,lineNumber:y,content:u}})}),g={path:s.displayPath,heading:`symbol: ${M(i.selector)}`,details:[`defined in: ${s.displayPath}:${c}-${p} (${T(i.kind)})`],startLine:c,endLine:p,totalLines:l.lines.length,renderedLines:d};return De([g],pr)}a(Pe,"readLspSymbolBody");async function _e(n,e,t,r,o){x(o);let s=await te(n,e,r,o),i=ee(s.symbols,t,s.displayPath),l=await Lt(s,i,o),c=new ce(r);return await ur(s,i,l,c)}a(_e,"readLspSymbolGraph");async function Ce(n,e,t,r){x(r);let o=await te(n,e,t,r),s=new ce(t),i=[`## file graph: ${o.displayPath}`,`Top-level declarations: ${o.symbols.length}`];for(let l of o.symbols){x(r);let c=await Lt(o,l,r);i.push("",...await hr(o,l,c,s))}return i.join(`
2
2
  `)}a(Ce,"readLspFileGraph");function ee(n,e,t){if(e.length===0)throw new TypeError("A symbol selector must contain at least one segment.");if(e.length===1){let s=St(n,_(e[0]));if(s.length===1)return _(s[0]);throw s.length>1?new Error(`Symbol selector "${M(e)}" is ambiguous in ${t}; use parent/child.`):ht(e,t)}let r=n,o;for(let s of e){let i=r.filter(l=>l.name===s);if(i.length===0)throw ht(e,t);if(i.length>1)throw new Error(`Symbol selector "${M(e)}" is ambiguous at "${s}" in ${t}.`);o=_(i[0]),r=o.children}return _(o)}a(ee,"resolveLspCodeSymbol");async function te(n,e,t,r){let o=E(e,t),s=await n.openFile(o,t,"symbols",r);if(!s)throw new Error(`No LSP server with symbol support is configured for ${Re(o,t)}.`);let i=await Q(s.client,s.uri,r),l=vt(i).sort(bt);return{client:s.client,uri:s.uri,filePath:o,displayPath:Re(o,t),symbols:l}}a(te,"openCodeDocument");function vt(n,e=[]){return n.flatMap(t=>{let r=t.selectionRange??t.range;if(!r)return[];let o=t.range??r,s=[...e,t.name];return[{name:t.name,kind:t.kind,range:o,selectionRange:r,selector:s,children:vt(t.children??[],s).sort(bt)}]})}a(vt,"normalizeDocumentSymbols");function bt(n,e){return n.range.start.line-e.range.start.line||n.range.start.character-e.range.start.character||n.name.localeCompare(e.name)}a(bt,"compareSymbols");function St(n,e){return n.flatMap(t=>[...t.name===e?[t]:[],...St(t.children,e)])}a(St,"collectNamedSymbols");function ht(n,e){return new Error(`Symbol "${M(n)}" was not found in ${e}.`)}a(ht,"symbolNotFound");async function Lt(n,e,t){let r=e.selectionRange.start,[o,s]=await Promise.all([Y(n.client,n.uri,r,t),he(n.client,n.uri,r,t)]);return x(t),{references:o,calls:s}}a(Lt,"queryRelations");async function ur(n,e,t,r){let o=M(e.selector),s=await r.line(n.uri,e.selectionRange.start.line+1);return[`## graph: ${o}`,`Definition: ${n.displayPath} ${s} (${T(e.kind)})`,`Source: ${J("graph",n.displayPath,e.selector)}`,"",...await gr(t.references,r),"",...await mr(t.calls.incoming,r),"",...await fr(t.calls.outgoing,r)].join(`
3
3
  `)}a(ur,"formatSymbolGraph");async function gr(n,e){let t=Rt(n),r=[`References: ${n.length} in ${t.length} file(s)`];for(let[o,s]of t.slice(0,be)){r.push(`- ${e.display(o)} (${s.length})`);for(let i of s.slice(0,Se))r.push(` - ${await e.line(o,i.range.start.line+1)}`);s.length>Se&&r.push(` - ... ${s.length-Se} more`)}return t.length>be&&r.push(`- ... ${t.length-be} more file(s)`),r}a(gr,"formatReferences");async function mr(n,e){let t=[`Incoming calls: ${n.length}`];for(let r of n.slice(0,B)){let o=r.fromRanges[0]?.start.line??r.from.selectionRange.start.line,s=await e.line(r.from.uri,o+1);t.push(`- ${T(r.from.kind)} ${r.from.name} \u2014 ${e.display(r.from.uri)} ${s}`)}return n.length>B&&t.push(`- ... ${n.length-B} more`),t}a(mr,"formatIncomingCalls");async function fr(n,e){let t=[`Outgoing calls: ${n.length}`];for(let r of n.slice(0,B)){let o=await e.line(r.to.uri,r.to.selectionRange.start.line+1);t.push(`- ${T(r.to.kind)} ${r.to.name} \u2014 ${e.display(r.to.uri)} ${o}`)}return n.length>B&&t.push(`- ... ${n.length-B} more`),t}a(fr,"formatOutgoingCalls");async function hr(n,e,t,r){let o=T(e.kind),s=await r.line(n.uri,e.selectionRange.start.line+1),i=Rt(t.references).map(([d,g])=>`${r.display(d)} (${g.length})`),l=t.calls.incoming.map(d=>`${d.from.name} (${r.display(d.from.uri)})`),c=t.calls.outgoing.map(d=>`${d.to.name} (${r.display(d.to.uri)})`),p=[`### ${o} ${e.name}`,`Selector: ${M(e.selector)}`,`Definition: ${s}`,`Used by: ${Le(i)}`,`Incoming calls: ${Le(l)}`,`Outgoing calls: ${Le(c)}`];if(e.children.length>0){p.push("Members:");for(let d of e.children){let g=J("graph",n.displayPath,d.selector);p.push(`- ${T(d.kind)} ${d.name} \u2014 ${g}`)}}return p}a(hr,"formatFileGraphSymbol");function Le(n,e=5){if(n.length===0)return"none";let t=n.slice(0,e).join(", ");return n.length>e?`${t}, ... ${n.length-e} more`:t}a(Le,"summarize");function Rt(n){let e=new Map;for(let t of n){let r=e.get(t.uri)??[];r.push(t),e.set(t.uri,r)}return[...e].map(([t,r])=>[t,r.sort((o,s)=>o.range.start.line-s.range.start.line||o.range.start.character-s.range.start.character)]).sort(([t],[r])=>t.localeCompare(r))}a(Rt,"groupLocationsByUri");async function yr(n,e,t){let r=n.startsWith("ssh://")?Buffer.from(await e.readSourceBytes(n,t)):await lr(n,{signal:t});if(r.byteLength>256*1024)throw new Error(`File exceeds the 262144-byte code-view limit: ${n}`);if(r.includes(0))throw new Error(`File appears to be binary and cannot be read as text: ${n}`);let o=r.toString("utf8").replaceAll(`\r
4
4
  `,`
@@ -1 +1 @@
1
- import{a as o}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as n}from"typebox/value";var t="pi-agent-search",i=5,S="pi-agent-search/core/ready",R="pi-agent-search/plugin/register",a=e.Unsafe({type:"Function"}),s=e.Object({protocol:e.Literal(t),apiVersion:e.Literal(i)}),c=e.Object({protocol:e.Literal(t),apiVersion:e.Literal(i),id:e.String({minLength:1}),setup:a}),p=e.Object({plugin:c,accept:a});function g(r){return n.Check(s,r)}o(g,"isSearchCoreReady");function h(r){return n.Check(c,r)}o(h,"isSearchPlugin");function y(r){return n.Check(p,r)}o(y,"isSearchPluginRegistrationRequest");export{t as a,i as b,S as c,R as d,g as e,h as f,y as g};
1
+ import{a as o}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as n}from"typebox/value";var t="pi-agent-search",i=6,S="pi-agent-search/core/ready",R="pi-agent-search/plugin/register",a=e.Unsafe({type:"Function"}),s=e.Object({protocol:e.Literal(t),apiVersion:e.Literal(i)}),c=e.Object({protocol:e.Literal(t),apiVersion:e.Literal(i),id:e.String({minLength:1}),setup:a}),p=e.Object({plugin:c,accept:a});function g(r){return n.Check(s,r)}o(g,"isSearchCoreReady");function h(r){return n.Check(c,r)}o(h,"isSearchPlugin");function y(r){return n.Check(p,r)}o(y,"isSearchPluginRegistrationRequest");export{t as a,i as b,S as c,R as d,g as e,h as f,y as g};
@@ -0,0 +1,10 @@
1
+ import{a as N}from"./chunk-47SPPIXK.js";import{a as C,b as O}from"./chunk-VAXLSPPU.js";import{a as b}from"./chunk-OI3HBIPK.js";import{e as v}from"./chunk-YTYLS2UM.js";import"./chunk-MPT3R4BL.js";import{a as k,b as A,c as E,d as x}from"./chunk-T7I2VX3J.js";import"./chunk-PS2B6THP.js";import{a as P}from"./chunk-BU7IZLKB.js";import{a as S,b as I}from"./chunk-S5PL5DFQ.js";import"./chunk-DXONCYWF.js";import{a as s}from"./chunk-EI7MMDWY.js";var W=/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/,w=class{static{s(this,"AgentDocumentationRegistry")}#e=new Map;register(t){let o=new Set(this.#e.keys());for(let r of t)U(r,o),o.add(r.id);for(let r of t)this.#e.set(r.id,V(r))}list(){return[...this.#e.values()].sort((t,o)=>t.id.localeCompare(o.id))}get(t){return this.#e.get(t)}matching(t,o){let r=L(o);return r?.startsWith("docs:")===!0?[]:this.list().filter(i=>i.triggers.some(d=>{if(d.tool!==t)return!1;let l=d.resourcePrefixes===void 0||r!==void 0&&d.resourcePrefixes.some(a=>r.startsWith(a)),n=d.viewPrefixes===void 0||z(o).some(a=>d.viewPrefixes?.some(u=>a.startsWith(u)));return l&&n}))}};function U(e,t){if(!W.test(e.id))throw new Error(`Invalid documentation ID: ${e.id}`);if(e.description.trim().length===0)throw new Error(`Documentation ${e.id} has no description`);if(e.markdown.trim().length===0)throw new Error(`Documentation ${e.id} has no Markdown content`);if(e.triggers.length===0||e.triggers.some(o=>o.tool.trim().length===0||o.resourcePrefixes?.some(r=>r.length===0)===!0||o.viewPrefixes?.some(r=>r.length===0)===!0))throw new Error(`Documentation ${e.id} has no valid triggers`);if(t.has(e.id))throw new Error(`Documentation ${e.id} is already registered`)}s(U,"validateDocument");function V(e){return Object.freeze({...e,triggers:Object.freeze(e.triggers.map(t=>Object.freeze({...t,...t.resourcePrefixes===void 0?{}:{resourcePrefixes:Object.freeze([...t.resourcePrefixes])},...t.viewPrefixes===void 0?{}:{viewPrefixes:Object.freeze([...t.viewPrefixes])}})))})}s(V,"freezeDocument");function z(e){if(typeof e!="object"||e===null)return[];let t=e.views;return Array.isArray(t)?t.filter(o=>typeof o=="string"):[]}s(z,"readViews");function L(e){if(typeof e!="object"||e===null)return;let t=e.path;return typeof t=="string"?t:void 0}s(L,"readPath");function _(e){return{id:"agent-documentation",readResources:s(t=>t.path?.startsWith("docs:")===!0?[t.path]:[],"readResources"),async tryResolve(t,o){let r=t.path;if(r===void 0||!r.startsWith("docs:"))return{kind:"not-handled"};if(t.include!==void 0||t.exclude!==void 0)return{kind:"failed",error:new Error("File include/exclude globs do not apply to docs: resources.")};if(/^(?:files|ast|symbols|process):/u.test(t.query))return{kind:"failed",error:new Error("Use a text or regex: query for docs: resources.")};let i=r.slice(5);if(i.length===0)return{kind:"failed",error:new Error("Use docs:all to search all guides or docs:<id> for one guide. Read docs: to list IDs.")};let d=i==="all"?void 0:e.get(i);if(i!=="all"&&d===void 0)return{kind:"failed",error:new Error(`Unknown documentation ID: ${i}`)};let l=G(t),n=[],a=t.limit??50,u=0;for(let h of d===void 0?e.list():[d]){o.signal?.throwIfAborted();for(let[f,c]of h.markdown.split(/\r\n|\n|\r/u).entries()){o.signal?.throwIfAborted();for(let g of c.matchAll(l)){if(g[0].length===0)continue;let p=g.index,y=p+g[0].length;if(t.wholeWord===!0&&(/[\p{L}\p{N}_]/u.test(c[p-1]??"")||/[\p{L}\p{N}_]/u.test(c[y]??"")))continue;if(n.length===a)return{kind:"resolved",payload:{source:r,matches:n,complete:!1,reason:"limit"}};let D={source:`docs:${h.id}`,lineNumber:f+1,startColumn:p,endColumn:y,matchedText:g[0],lineText:c};if(u+=Buffer.byteLength(T(D))+1,u>48*1024)return{kind:"resolved",payload:{source:r,matches:n,complete:!1,reason:"output"}};n.push(D)}}}return{kind:"resolved",payload:{source:r,matches:n,complete:!0}}},toScriptData(t){let o=t;return v(o.matches,o.complete)},format(t){let o=t,r=`${o.matches.length}${o.complete?"":"+"}`;return{content:[{type:"text",text:[o.matches.length===0&&o.complete?`No matches in ${o.source}`:`${r} matches in ${o.source}`,...$(o),...o.matches.map(T)].join(`
2
+ `)}],details:o}},renderResult(t,o,r){let i=t.details;return b(i.matches,i.complete,r,o.expanded,void 0,$(i))}}}s(_,"createDocumentationSearchResolver");function $(e){return["Packaged guides \xB7 read-only. Read docs:<id> for the full guide; search excerpts do not mark it read.",...e.reason==="limit"?["Limit reached \xB7 incomplete results. Narrow the query or raise limit."]:[],...e.reason==="output"?["Output shortened \xB7 incomplete results. Narrow the query."]:[]]}s($,"notices");function T(e){let t=Math.max(0,e.startColumn-64),o=Math.min(e.lineText.length,e.startColumn+192),r=`${t>0?"\u2026":""}${e.lineText.slice(t,o)}${o<e.lineText.length?"\u2026":""}`;return`${e.source}:${e.lineNumber}:${e.startColumn+1} ${r}`}s(T,"matchRow");function G(e){if(/\r|\n/u.test(e.query))throw new Error("Search supports one-line patterns only.");let t=e.query,o=t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t,r=t.startsWith("regex:")?t.slice(6):o.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(r,e.caseSensitive===!0?"gu":"giu")}s(G,"searchPattern");var M="agent-documentation-read";async function B(e){let t=new w,o=new Set,r=new Map,i=new Map,d=s(n=>{let a=n.filter(u=>!o.has(u));if(a.length!==0){e.appendEntry(M,{ids:a});for(let u of a)o.add(u)}},"remember"),l=e.events.on(x,n=>{if(!K(n))throw new Error("Invalid agent documentation registration");t.register(n.documents)});e.on("session_shutdown",l),await P(e,{protocol:S,apiVersion:I,id:"agent-documentation",setup(n){n.addResolver({resolver:{id:"agent-documentation",tryResolve(a){if(!a.startsWith("docs:"))return Promise.resolve({kind:"not-handled"});let u=a.slice(5),h=u.length===0?void 0:t.get(u),f=u.length===0?q(t.list()):h?.markdown;return f===void 0?Promise.resolve({kind:"failed",error:new Error(`Unknown documentation ID: ${u}`)}):Promise.resolve({kind:"resolved",resource:{source:a,read:s(()=>Promise.resolve([{type:"text",text:f}]),"read")}})}}}),n.describe({path:s(()=>t.list().length===0?void 0:"docs: lists packaged agent guidance; docs:<id> reads a listed guide.","path")}),n.addPromptGuideline(()=>F(t.list()))}}),await N(e,{protocol:C,apiVersion:O,id:"agent-documentation",setup(n){n.addResolver({resolver:_(t),priority:-20})}}),e.on("session_start",(n,a)=>{R(a.sessionManager.getBranch(),t,o)}),e.on("session_tree",(n,a)=>{R(a.sessionManager.getBranch(),t,o)}),e.on("session_compact",(n,a)=>{R(a.sessionManager.getBranch(),t,o)}),e.on("tool_call",n=>{n.toolCallId.includes("-preflight-")||n.parentToolCallId!==void 0&&r.set(n.toolCallId,n.parentToolCallId)}),e.on("tool_result",n=>{if(n.toolCallId.includes("-preflight-"))return;let a=r.get(n.toolCallId);r.delete(n.toolCallId);let u=i.get(n.toolCallId)??[];i.delete(n.toolCallId);let h=n.toolName==="read"?H(n.input):void 0;if(h!==void 0){let c=h.slice(5),g=c.length===0||t.get(c)!==void 0,p=t.get(c);return p!==void 0&&!n.isError&&j(n.content,p)&&d([c]),{content:n.content,structuredContent:n.structuredContent,details:{...m(n.details)?n.details:{},documentation:g?c.length===0?{kind:"list",ids:t.list().map(y=>y.id)}:{kind:"document",id:c}:{kind:"error",code:"UNKNOWN_DOCUMENTATION",id:c}},isError:n.isError}}let f=[...u,...t.matching(n.toolName,n.input).filter(c=>!o.has(c.id))];if(f.length!==0){if(d(f.map(c=>c.id)),a!==void 0){i.set(a,[...i.get(a)??[],...f]);return}return{content:[...n.content,...f.map(c=>({type:"text",text:`
3
+
4
+ ---
5
+
6
+ # Guide: ${c.id}
7
+
8
+ ${c.markdown.trim()}`}))],structuredContent:n.structuredContent,details:{...m(n.details)?n.details:{},documentation:{kind:"attachment",ids:f.map(c=>c.id)}},isError:n.isError}}}),e.events.emit(E,{protocol:k,apiVersion:A})}s(B,"registerProgressiveDocumentation");function q(e){return e.length===0?"No agent documentation is currently available.":["# Available agent documentation","",...e.map(t=>`- \`${t.id}\` \u2014 ${t.description}`)].join(`
9
+ `)}s(q,"renderListing");function F(e){if(e.length!==0)return["Read the matching docs:<id> before using any tool or feature with packaged guidance, including tools discovered later or called through Codemode. Read each guide once per branch. Tool descriptions and docs: listings do not replace the full guide.","If a result includes a Guide, read it before your next use. The call has already run: do not repeat it just to obtain documentation. Nested calls keep their guides on the parent result, even when the script does not print the child output.","Available documents:",...e.map(t=>` - ${t.id} \u2014 ${t.description}`)].join(`
10
+ `)}s(F,"renderPromptGuideline");function R(e,t,o){o.clear();for(let i of e){if(!m(i))continue;if(i.type==="custom"&&i.customType===M&&m(i.data)){r(i.data.ids);continue}if(i.type!=="message"||!m(i.message))continue;let d=i.message;if(d.role!=="toolResult"||!m(d.details))continue;let l=d.details.documentation;if(m(l)&&(l.kind==="attachment"&&r(l.ids),l.kind==="document"&&!d.isError&&typeof l.id=="string")){let n=t.get(l.id);n!==void 0&&j(d.content,n)&&r([n.id])}}function r(i){if(Array.isArray(i))for(let d of i)typeof d=="string"&&t.get(d)!==void 0&&o.add(d)}s(r,"addIds")}s(R,"restoreClaims");function j(e,t){return Array.isArray(e)&&e.some(o=>m(o)&&o.type==="text"&&typeof o.text=="string"&&o.text.includes(t.markdown.trim()))}s(j,"containsFullGuide");function H(e){if(!(!m(e)||typeof e.path!="string"||!e.path.startsWith("docs:")))return e.path}s(H,"documentationSource");function K(e){return m(e)&&Array.isArray(e.documents)}s(K,"isRegistrationRequest");function m(e){return typeof e=="object"&&e!==null}s(m,"isRecord");export{B as default};
@@ -1 +1 @@
1
- import{a as C}from"./chunk-E4HPRLRB.js";import{a as w}from"./chunk-IUSLSROY.js";import{a as E,b as g}from"./chunk-7HDK3NRQ.js";import{b as S}from"./chunk-OJX3RJ5A.js";import"./chunk-XZDOVPRC.js";import{a as u,b as v,c as U}from"./chunk-HCN5W76B.js";import"./chunk-7TJ6DWW3.js";import{g as l}from"./chunk-EY65TFHJ.js";import{a as p,b as O,c as f,e as j}from"./chunk-MKEC3U2M.js";import{c as R}from"./chunk-W7CASEO3.js";import"./chunk-TOYN4W4F.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-K5G4FDXD.js";import"./chunk-R5XJSEOE.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import{c as P}from"./chunk-IMGIDBCC.js";import"./chunk-BXGMMZT3.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{fileURLToPath as x}from"node:url";function A(i){let c=E(i),T=w(i);return{async resolveProject(e,o){if(e.startsWith("ssh://")||o.startsWith("ssh://")){let n=i.resolve(e,o);if(!n)throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let a=i.resolve(o);if(a&&a.location.target!==n.location.target)throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let r=await C(n.backend,n.location.path,a?.location.path,"linters",p);return r?{projectRoot:r.cwd,external:r.external}:void 0}if(e.includes("://")||o.includes("://"))throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let t=await P(o,e,"linters",p);return t===void 0?void 0:{projectRoot:t,external:t!==h.resolve(o)}},async loadRegistry(e,o){let t=i.resolve(e);return O.fromDirectory(e,{includeGlobal:!o,requireBuiltInEvidence:!0,...t?{layerAccess:c,executableAvailability:s(n=>S(t.backend,t.location.path,n),"executableAvailability"),recipeEvidence:s(n=>g(t.backend,t.location.path,n),"recipeEvidence")}:{}})},async run(e,o){let t=i.resolve(o.filePath);if(!t)return f(e,o);let n=i.resolve(o.projectRoot);if(!n||n.location.target!==t.location.target)throw new l("UNSUPPORTED_SOURCE",o.filePath,"not-applied");let a=e.check.cwd==="file"?h.posix.dirname(t.location.path):n.location.path;return f(e,{...o,processAccess:T,acceptsFile(r){if(r.startsWith("ssh://")){let d=i.resolve(r);return d?.location.target===t.location.target&&d.location.path===t.location.path}let m=r.startsWith("file:")?x(r):r;return m.includes("://")?!1:h.posix.resolve(a,m)===t.location.path}})}}}s(A,"createOwnedLintRuntime");async function L(i){let c=new U(await v(u(R())));await j(i,A(c))}s(L,"registerOwnedLint");export{A as createOwnedLintRuntime,L as default};
1
+ import{a as C}from"./chunk-AKNHSDGV.js";import{a as w}from"./chunk-N56WAVYA.js";import{a as E,b as g}from"./chunk-GEMDU6XW.js";import{b as S}from"./chunk-WPBQ45ZL.js";import"./chunk-WXGTU2M6.js";import{a as u,b as v,c as U}from"./chunk-LLRUJD62.js";import"./chunk-Q5X6OXNS.js";import{g as l}from"./chunk-4HWKBCBH.js";import{a as p,b as O,c as f,e as j}from"./chunk-MKEC3U2M.js";import{c as R}from"./chunk-W7CASEO3.js";import"./chunk-TOYN4W4F.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-K5G4FDXD.js";import"./chunk-DXONCYWF.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import{c as P}from"./chunk-IMGIDBCC.js";import"./chunk-BXGMMZT3.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{fileURLToPath as x}from"node:url";function A(i){let c=E(i),T=w(i);return{async resolveProject(e,o){if(e.startsWith("ssh://")||o.startsWith("ssh://")){let n=i.resolve(e,o);if(!n)throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let a=i.resolve(o);if(a&&a.location.target!==n.location.target)throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let r=await C(n.backend,n.location.path,a?.location.path,"linters",p);return r?{projectRoot:r.cwd,external:r.external}:void 0}if(e.includes("://")||o.includes("://"))throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let t=await P(o,e,"linters",p);return t===void 0?void 0:{projectRoot:t,external:t!==h.resolve(o)}},async loadRegistry(e,o){let t=i.resolve(e);return O.fromDirectory(e,{includeGlobal:!o,requireBuiltInEvidence:!0,...t?{layerAccess:c,executableAvailability:s(n=>S(t.backend,t.location.path,n),"executableAvailability"),recipeEvidence:s(n=>g(t.backend,t.location.path,n),"recipeEvidence")}:{}})},async run(e,o){let t=i.resolve(o.filePath);if(!t)return f(e,o);let n=i.resolve(o.projectRoot);if(!n||n.location.target!==t.location.target)throw new l("UNSUPPORTED_SOURCE",o.filePath,"not-applied");let a=e.check.cwd==="file"?h.posix.dirname(t.location.path):n.location.path;return f(e,{...o,processAccess:T,acceptsFile(r){if(r.startsWith("ssh://")){let d=i.resolve(r);return d?.location.target===t.location.target&&d.location.path===t.location.path}let m=r.startsWith("file:")?x(r):r;return m.includes("://")?!1:h.posix.resolve(a,m)===t.location.path}})}}}s(A,"createOwnedLintRuntime");async function L(i){let c=new U(await v(u(R())));await j(i,A(c))}s(L,"registerOwnedLint");export{A as createOwnedLintRuntime,L as default};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-Q5X6OXNS.js";import"./chunk-4HWKBCBH.js";import"./chunk-DXONCYWF.js";import"./chunk-EI7MMDWY.js";export{a as startSshProcess};
@@ -1,4 +1,4 @@
1
- import{a as we,b as ye,c as Se}from"./chunk-ESPNEJHK.js";import{a as he}from"./chunk-L2B4DTVS.js";import{a as fe,b as ge,c as L}from"./chunk-HCN5W76B.js";import"./chunk-EY65TFHJ.js";import{c as pe}from"./chunk-W7CASEO3.js";import"./chunk-QUYXINGZ.js";import{a as M}from"./chunk-GW6NZQTQ.js";import{e as ee,f as te}from"./chunk-T7I2VX3J.js";import{a as ae}from"./chunk-2K65BSXS.js";import{c as oe,d as se}from"./chunk-ICDI27GZ.js";import{b as A}from"./chunk-IICJXZBU.js";import{a as ie}from"./chunk-BU7IZLKB.js";import{a as ne,b as re}from"./chunk-S5PL5DFQ.js";import{a as ce}from"./chunk-N7LMRL64.js";import{a as le,b as ue}from"./chunk-RAZP42IQ.js";import{a as de}from"./chunk-BIG45IPN.js";import{e as me}from"./chunk-SSWUUBIR.js";import"./chunk-PS2B6THP.js";import{i as G,j as I}from"./chunk-R5XJSEOE.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import st from"node:path";import{stripVTControlCharacters as at}from"node:util";import{truncateLine as lt}from"@earendil-works/pi-coding-agent";import{Text as P}from"@earendil-works/pi-tui";import{DEFAULT_MAX_BYTES as Te,DEFAULT_MAX_LINES as be,formatSize as it,truncateTail as ot}from"@earendil-works/pi-coding-agent";function k(t){return ot(t,{maxBytes:Te-4096,maxLines:be-32})}a(k,"terminalOutputTail");function _(t){let e=k(t.output),n=[`session: ${t.source}`,`status: ${t.status}`,`shell: ${t.shell}`,`cwd: ${t.cwd}`,`elapsedMs: ${t.elapsedMs}`,t.exitCode===void 0?void 0:`exitCode: ${t.exitCode}`,t.signal===void 0?void 0:`signal: ${t.signal}`,t.error===void 0?void 0:`error: ${t.error}`,t.waitReason===void 0?void 0:`reason: ${t.waitReason}`,t.completionReason===void 0?void 0:`completionReason: ${t.completionReason}`,t.status==="running"&&t.background?`next: Continue independent work or finish your turn; completion or a one-time idle inspection notice will wake the agent. Read ${t.source} to inspect output; use write or insert when input is needed.`:void 0,`outputRange: ${t.outputStart}-${t.outputEnd}`,t.truncated?"retainedOutput: earlier data omitted from memory":void 0,e.truncated?`fullOutput: ${t.fullOutputPath}`:void 0].filter(s=>s!==void 0),r=e.content.trimEnd();if(!e.truncated)return`${n.join(`
1
+ import{a as we,b as ye,c as Se}from"./chunk-ESPNEJHK.js";import{a as he}from"./chunk-L2B4DTVS.js";import{a as fe,b as ge,c as L}from"./chunk-LLRUJD62.js";import"./chunk-4HWKBCBH.js";import{a as ce}from"./chunk-47SPPIXK.js";import{a as le,b as ue}from"./chunk-VAXLSPPU.js";import{a as de}from"./chunk-OI3HBIPK.js";import{e as me}from"./chunk-YTYLS2UM.js";import{c as pe}from"./chunk-W7CASEO3.js";import"./chunk-QUYXINGZ.js";import{a as M}from"./chunk-PRLIHLCS.js";import{e as ee,f as te}from"./chunk-T7I2VX3J.js";import{a as ae}from"./chunk-M4TVRCMZ.js";import{c as oe,d as se}from"./chunk-TGC2ZACO.js";import{b as A}from"./chunk-IICJXZBU.js";import"./chunk-PS2B6THP.js";import{a as ie}from"./chunk-BU7IZLKB.js";import{a as ne,b as re}from"./chunk-S5PL5DFQ.js";import{i as G,j as I}from"./chunk-DXONCYWF.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import st from"node:path";import{stripVTControlCharacters as at}from"node:util";import{truncateLine as lt}from"@earendil-works/pi-coding-agent";import{Text as P}from"@earendil-works/pi-tui";import{DEFAULT_MAX_BYTES as Te,DEFAULT_MAX_LINES as be,formatSize as it,truncateTail as ot}from"@earendil-works/pi-coding-agent";function k(t){return ot(t,{maxBytes:Te-4096,maxLines:be-32})}a(k,"terminalOutputTail");function _(t){let e=k(t.output),n=[`session: ${t.source}`,`status: ${t.status}`,`shell: ${t.shell}`,`cwd: ${t.cwd}`,`elapsedMs: ${t.elapsedMs}`,t.exitCode===void 0?void 0:`exitCode: ${t.exitCode}`,t.signal===void 0?void 0:`signal: ${t.signal}`,t.error===void 0?void 0:`error: ${t.error}`,t.waitReason===void 0?void 0:`reason: ${t.waitReason}`,t.completionReason===void 0?void 0:`completionReason: ${t.completionReason}`,t.status==="running"&&t.background?`next: Continue independent work or finish your turn; completion or a one-time idle inspection notice will wake the agent. Read ${t.source} to inspect output; use write or insert when input is needed.`:void 0,`outputRange: ${t.outputStart}-${t.outputEnd}`,t.truncated?"retainedOutput: earlier data omitted from memory":void 0,e.truncated?`fullOutput: ${t.fullOutputPath}`:void 0].filter(s=>s!==void 0),r=e.content.trimEnd();if(!e.truncated)return`${n.join(`
2
2
  `)}
3
3
  output:${r.length===0?" (empty)":`
4
4
  ${r}`}`;let i=e.truncatedBy==="lines"?`${be} line output budget`:`${it(Te)} output budget`,l=`[Earlier output omitted: showing the last ${e.outputLines} of ${e.totalLines} lines (${i}). Full output: ${t.fullOutputPath}]`;return`${n.join(`
@@ -1,4 +1,4 @@
1
- import{a as Oe,b as Ne,c as He}from"./chunk-ESPNEJHK.js";import{a as Be}from"./chunk-L2B4DTVS.js";import{a as Le}from"./chunk-KL776TGR.js";import{a as je}from"./chunk-OJX3RJ5A.js";import"./chunk-CTJV77FR.js";import{a as xe,b as Ce,c as $e}from"./chunk-HCN5W76B.js";import{a as W,g as v}from"./chunk-EY65TFHJ.js";import{c as Te}from"./chunk-W7CASEO3.js";import{a as ae,b as P,c as R}from"./chunk-R2U5WXYR.js";import{e as we,f as ve}from"./chunk-T7I2VX3J.js";import{a as ye}from"./chunk-YJ6T3PEP.js";import{b as me,c as he}from"./chunk-S72FVLUX.js";import{a as Ie}from"./chunk-2K65BSXS.js";import{c as Ae,d as Re}from"./chunk-ICDI27GZ.js";import{a as N}from"./chunk-K5G4FDXD.js";import{a as Se}from"./chunk-BU7IZLKB.js";import{a as De,b as Pe}from"./chunk-S5PL5DFQ.js";import{e as ke}from"./chunk-PS2B6THP.js";import{f as Ee,i as _e,j as ne}from"./chunk-R5XJSEOE.js";import"./chunk-ZPT5D4VP.js";import{d as be}from"./chunk-756K3LJY.js";import{a as d}from"./chunk-EI7MMDWY.js";import j from"node:path";import{access as or}from"node:fs/promises";import{StringEnum as ir}from"@earendil-works/pi-ai";import{defineTool as sr}from"@earendil-works/pi-coding-agent";import{Type as y}from"typebox";async function V(r,e=process.env,t=process.platform,n=o=>be(o,r,e)){if(e.PI_PYTHON_PATH!==void 0)return{command:e.PI_PYTHON_PATH,args:[]};let o=t==="win32"?[{command:"python",args:[]},{command:"python3",args:[]},{command:"py",args:["-3"]}]:[{command:"python3",args:[]},{command:"python",args:[]}];for(let a of o)if(await n(a.command))return a;return o[0]}d(V,"resolvePythonDebuggerCommand");import St from"cross-spawn";import{cp as kt,mkdtemp as Et,readdir as _t,rm as At,stat as K}from"node:fs/promises";import{tmpdir as Rt}from"node:os";import It from"node:net";import A from"node:path";import{pathToFileURL as Tt}from"node:url";import{createMessageConnection as xt,StreamMessageReader as Ct,StreamMessageWriter as jt}from"vscode-jsonrpc/node";import vt from"cross-spawn";import yt from"node:net";var Dt=new Set(["initialized","stopped","continued","terminated","exited","loadedSource","breakpoint","custom"]),Pt=128,S=class r{static{d(this,"DapClient")}#o;#i;#s;#e;#d;#r=new Map;#c=[];#u=new Set;#w=new Set;#l=Buffer.alloc(0);#b=1;#p;#v;#m;constructor(e,t,n,o){this.#o=e,this.#i=t,this.#s=n,this.#e=o,o&&o.completion.then(()=>this.#a(new Error("Debug adapter transport completed")),a=>this.#a(a instanceof Error?a:new Error("Debug adapter transport failed"))),e.on("data",a=>this.#g(a)),e.once("error",a=>this.#a(a)),t.once("error",a=>this.#a(a)),e.once("close",()=>this.#a(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.#a(a)),n.once("exit",(a,i)=>{this.#a(new Error(`Debug adapter exited${a===null?"":` with code ${a}`}${i===null?"":` (${i})`}`))}))}static start(e,t,n){let a=vt(e,[...t],{cwd:n,env:process.env,stdio:["pipe","pipe","pipe"]});return new r(a.stdout,a.stdin,a)}static fromTransport(e){return new r(e.readable,e.writable,void 0,e)}static fromSocket(e,t=1){let n=new r(e,e);return n.#b=t,n}static connect(e,t="127.0.0.1"){return new Promise((n,o)=>{let a=yt.createConnection({port:e,host:t}),i=d(s=>o(s),"fail");a.once("error",i),a.once("connect",()=>{a.off("error",i),n(new r(a,a))})})}onReverseRequest(e){this.#v=e}onEvent(e){return this.#w.add(e),()=>this.#w.delete(e)}request(e,t,n={}){if(this.#p!==void 0)return Promise.reject(this.#p);if(n.signal?.aborted===!0)return Promise.reject(n.signal.reason instanceof Error?n.signal.reason:new Error("Debug operation aborted"));["continue","next","stepIn","stepOut"].includes(e)&&(this.#m=void 0);let o=this.#b++,a={seq:o,type:"request",command:e,...t===void 0?{}:{arguments:t}},i=new Promise((s,u)=>{let c,l=d(()=>{c!==void 0&&clearTimeout(c),n.signal?.removeEventListener("abort",m)},"cleanup"),m=d(()=>{this.#r.delete(o),l(),u(n.signal?.reason instanceof Error?n.signal.reason:new Error("Debug operation aborted"))},"abort");n.timeoutMs!==void 0&&(c=setTimeout(()=>{this.#r.delete(o),l(),u(new Error(`Timed out waiting for debug response ${e}`))},n.timeoutMs)),this.#r.set(o,{resolve:d(p=>s(p),"resolve"),reject:u,cleanup:l}),n.signal?.addEventListener("abort",m,{once:!0})});return this.#f(a),i}takeEvent(e){let t=this.#c.findIndex(n=>e.includes(n.event));return t<0?void 0:this.#c.splice(t,1)[0]}waitForEvent(e,t=3e4){return this.waitForAnyEvent([e],t)}waitForAnyEvent(e,t=3e4,n){let o=new Set(e),a=this.#c.findIndex(i=>o.has(i.event));return a>=0?Promise.resolve(this.#c.splice(a,1)[0]):this.#p!==void 0?Promise.reject(this.#p):new Promise((i,s)=>{let u={events:o,resolve:d(l=>{clearTimeout(u.timer),this.#u.delete(u),i(l)},"resolve"),reject:d(l=>{clearTimeout(u.timer),this.#u.delete(u),s(l)},"reject"),timer:setTimeout(()=>{this.#u.delete(u),s(new Error(`Timed out waiting for debug event ${e.join(" or ")}`))},t)};this.#u.add(u);let c=d(()=>u.reject(n?.reason instanceof Error?n.reason:new Error("Debug operation aborted")),"abort");n?.aborted===!0?c():n?.addEventListener("abort",c,{once:!0})})}close(){this.#o.destroy(),this.#i.destroy(),this.#s!==void 0&&!this.#s.killed&&this.#s.kill(),this.#a(new Error("Debug adapter closed")),this.#e&&!this.#d&&(this.#d=Promise.resolve().then(()=>this.#e?.stop()),this.#d.catch(()=>{}))}async dispose(){this.close(),await this.#d}#f(e){let t=Buffer.from(JSON.stringify(e),"utf8");this.#i.write(Buffer.concat([Buffer.from(`Content-Length: ${t.length}\r
1
+ import{a as Oe,b as Ne,c as He}from"./chunk-ESPNEJHK.js";import{a as Be}from"./chunk-L2B4DTVS.js";import{a as Le}from"./chunk-7LOVUWNI.js";import{a as je}from"./chunk-WPBQ45ZL.js";import"./chunk-BQAKA3FU.js";import{a as xe,b as Ce,c as $e}from"./chunk-LLRUJD62.js";import{a as W,g as v}from"./chunk-4HWKBCBH.js";import{a as ae,b as P,c as R}from"./chunk-R2U5WXYR.js";import{c as Te}from"./chunk-W7CASEO3.js";import{e as we,f as ve}from"./chunk-T7I2VX3J.js";import{a as ye}from"./chunk-YJ6T3PEP.js";import{b as me,c as he}from"./chunk-S72FVLUX.js";import{a as Ie}from"./chunk-M4TVRCMZ.js";import{c as Ae,d as Re}from"./chunk-TGC2ZACO.js";import{a as N}from"./chunk-K5G4FDXD.js";import{e as ke}from"./chunk-PS2B6THP.js";import{a as Se}from"./chunk-BU7IZLKB.js";import{a as De,b as Pe}from"./chunk-S5PL5DFQ.js";import{f as Ee,i as _e,j as ne}from"./chunk-DXONCYWF.js";import"./chunk-ZPT5D4VP.js";import{d as be}from"./chunk-756K3LJY.js";import{a as d}from"./chunk-EI7MMDWY.js";import j from"node:path";import{access as or}from"node:fs/promises";import{StringEnum as ir}from"@earendil-works/pi-ai";import{defineTool as sr}from"@earendil-works/pi-coding-agent";import{Type as y}from"typebox";async function V(r,e=process.env,t=process.platform,n=o=>be(o,r,e)){if(e.PI_PYTHON_PATH!==void 0)return{command:e.PI_PYTHON_PATH,args:[]};let o=t==="win32"?[{command:"python",args:[]},{command:"python3",args:[]},{command:"py",args:["-3"]}]:[{command:"python3",args:[]},{command:"python",args:[]}];for(let a of o)if(await n(a.command))return a;return o[0]}d(V,"resolvePythonDebuggerCommand");import St from"cross-spawn";import{cp as kt,mkdtemp as Et,readdir as _t,rm as At,stat as K}from"node:fs/promises";import{tmpdir as Rt}from"node:os";import It from"node:net";import A from"node:path";import{pathToFileURL as Tt}from"node:url";import{createMessageConnection as xt,StreamMessageReader as Ct,StreamMessageWriter as jt}from"vscode-jsonrpc/node";import vt from"cross-spawn";import yt from"node:net";var Dt=new Set(["initialized","stopped","continued","terminated","exited","loadedSource","breakpoint","custom"]),Pt=128,S=class r{static{d(this,"DapClient")}#o;#i;#s;#e;#d;#r=new Map;#c=[];#u=new Set;#w=new Set;#l=Buffer.alloc(0);#b=1;#p;#v;#m;constructor(e,t,n,o){this.#o=e,this.#i=t,this.#s=n,this.#e=o,o&&o.completion.then(()=>this.#a(new Error("Debug adapter transport completed")),a=>this.#a(a instanceof Error?a:new Error("Debug adapter transport failed"))),e.on("data",a=>this.#g(a)),e.once("error",a=>this.#a(a)),t.once("error",a=>this.#a(a)),e.once("close",()=>this.#a(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.#a(a)),n.once("exit",(a,i)=>{this.#a(new Error(`Debug adapter exited${a===null?"":` with code ${a}`}${i===null?"":` (${i})`}`))}))}static start(e,t,n){let a=vt(e,[...t],{cwd:n,env:process.env,stdio:["pipe","pipe","pipe"]});return new r(a.stdout,a.stdin,a)}static fromTransport(e){return new r(e.readable,e.writable,void 0,e)}static fromSocket(e,t=1){let n=new r(e,e);return n.#b=t,n}static connect(e,t="127.0.0.1"){return new Promise((n,o)=>{let a=yt.createConnection({port:e,host:t}),i=d(s=>o(s),"fail");a.once("error",i),a.once("connect",()=>{a.off("error",i),n(new r(a,a))})})}onReverseRequest(e){this.#v=e}onEvent(e){return this.#w.add(e),()=>this.#w.delete(e)}request(e,t,n={}){if(this.#p!==void 0)return Promise.reject(this.#p);if(n.signal?.aborted===!0)return Promise.reject(n.signal.reason instanceof Error?n.signal.reason:new Error("Debug operation aborted"));["continue","next","stepIn","stepOut"].includes(e)&&(this.#m=void 0);let o=this.#b++,a={seq:o,type:"request",command:e,...t===void 0?{}:{arguments:t}},i=new Promise((s,u)=>{let c,l=d(()=>{c!==void 0&&clearTimeout(c),n.signal?.removeEventListener("abort",m)},"cleanup"),m=d(()=>{this.#r.delete(o),l(),u(n.signal?.reason instanceof Error?n.signal.reason:new Error("Debug operation aborted"))},"abort");n.timeoutMs!==void 0&&(c=setTimeout(()=>{this.#r.delete(o),l(),u(new Error(`Timed out waiting for debug response ${e}`))},n.timeoutMs)),this.#r.set(o,{resolve:d(p=>s(p),"resolve"),reject:u,cleanup:l}),n.signal?.addEventListener("abort",m,{once:!0})});return this.#f(a),i}takeEvent(e){let t=this.#c.findIndex(n=>e.includes(n.event));return t<0?void 0:this.#c.splice(t,1)[0]}waitForEvent(e,t=3e4){return this.waitForAnyEvent([e],t)}waitForAnyEvent(e,t=3e4,n){let o=new Set(e),a=this.#c.findIndex(i=>o.has(i.event));return a>=0?Promise.resolve(this.#c.splice(a,1)[0]):this.#p!==void 0?Promise.reject(this.#p):new Promise((i,s)=>{let u={events:o,resolve:d(l=>{clearTimeout(u.timer),this.#u.delete(u),i(l)},"resolve"),reject:d(l=>{clearTimeout(u.timer),this.#u.delete(u),s(l)},"reject"),timer:setTimeout(()=>{this.#u.delete(u),s(new Error(`Timed out waiting for debug event ${e.join(" or ")}`))},t)};this.#u.add(u);let c=d(()=>u.reject(n?.reason instanceof Error?n.reason:new Error("Debug operation aborted")),"abort");n?.aborted===!0?c():n?.addEventListener("abort",c,{once:!0})})}close(){this.#o.destroy(),this.#i.destroy(),this.#s!==void 0&&!this.#s.killed&&this.#s.kill(),this.#a(new Error("Debug adapter closed")),this.#e&&!this.#d&&(this.#d=Promise.resolve().then(()=>this.#e?.stop()),this.#d.catch(()=>{}))}async dispose(){this.close(),await this.#d}#f(e){let t=Buffer.from(JSON.stringify(e),"utf8");this.#i.write(Buffer.concat([Buffer.from(`Content-Length: ${t.length}\r
2
2
  \r
3
3
  `),t]))}#g(e){for(this.#l=Buffer.concat([this.#l,e]);;){let t=this.#l.indexOf(`\r
4
4
  \r
@@ -1 +1 @@
1
- import{g as d}from"./chunk-EY65TFHJ.js";import{a as p}from"./chunk-EI7MMDWY.js";import l from"node:path";async function y(e,o,t={},r){r?.throwIfAborted();for(let n of Object.keys(t))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(n))throw new TypeError("Invalid remote process environment key");let i=await e.execute("python3",["-c",'import os; print(os.environ.get("PATH", os.defpath), end="")'],o,{signal:r});if(i.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",e.target.id,"not-applied");return{...t,PATH:[...["node_modules/.bin",".venv/bin","venv/bin","vendor/bin"].map(n=>l.posix.join(o,n)),t.PATH??i.stdout].join(":")}}p(y,"sshProjectEnvironment");async function v(e,o,t,r){r?.throwIfAborted();let i=t.map(s=>{for(let h of Object.keys(s.env??{}))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(h))throw new TypeError("Invalid remote process environment key");return{command:s.command[0]?.replaceAll("{project}",o)??"",path:s.env?.PATH}}),n=await e.execute("python3",["-c","import json,os,shutil,sys; candidates=json.loads(sys.argv[1]); root=sys.argv[2]; prefixes=[os.path.join(root,p) for p in ['node_modules/.bin','.venv/bin','venv/bin','vendor/bin']]; print(json.dumps([bool(shutil.which(c['command'],path=os.pathsep.join(prefixes+[c.get('path',os.environ.get('PATH',os.defpath))]))) for c in candidates]))",JSON.stringify(i),o],o,{signal:r});if(n.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",e.target.id,"not-applied");let a=JSON.parse(n.stdout.toString("utf8"));if(!Array.isArray(a)||a.length!==t.length||a.some(s=>typeof s!="boolean"))throw new d("INVALID_RESPONSE",e.target.id,"not-applied");return a}p(v,"sshProjectExecutableAvailability");export{y as a,v as b};
1
+ import{g as d}from"./chunk-4HWKBCBH.js";import{a as p}from"./chunk-EI7MMDWY.js";import l from"node:path";async function y(e,o,t={},r){r?.throwIfAborted();for(let n of Object.keys(t))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(n))throw new TypeError("Invalid remote process environment key");let i=await e.execute("python3",["-c",'import os; print(os.environ.get("PATH", os.defpath), end="")'],o,{signal:r});if(i.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",e.target.id,"not-applied");return{...t,PATH:[...["node_modules/.bin",".venv/bin","venv/bin","vendor/bin"].map(n=>l.posix.join(o,n)),t.PATH??i.stdout].join(":")}}p(y,"sshProjectEnvironment");async function v(e,o,t,r){r?.throwIfAborted();let i=t.map(s=>{for(let h of Object.keys(s.env??{}))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(h))throw new TypeError("Invalid remote process environment key");return{command:s.command[0]?.replaceAll("{project}",o)??"",path:s.env?.PATH}}),n=await e.execute("python3",["-c","import json,os,shutil,sys; candidates=json.loads(sys.argv[1]); root=sys.argv[2]; prefixes=[os.path.join(root,p) for p in ['node_modules/.bin','.venv/bin','venv/bin','vendor/bin']]; print(json.dumps([bool(shutil.which(c['command'],path=os.pathsep.join(prefixes+[c.get('path',os.environ.get('PATH',os.defpath))]))) for c in candidates]))",JSON.stringify(i),o],o,{signal:r});if(n.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",e.target.id,"not-applied");let a=JSON.parse(n.stdout.toString("utf8"));if(!Array.isArray(a)||a.length!==t.length||a.some(s=>typeof s!="boolean"))throw new d("INVALID_RESPONSE",e.target.id,"not-applied");return a}p(v,"sshProjectExecutableAvailability");export{y as a,v as b};
@@ -1 +1 @@
1
- import{a as w}from"./chunk-7TJ6DWW3.js";import{g as f}from"./chunk-EY65TFHJ.js";import{a as s}from"./chunk-EI7MMDWY.js";async function I(l,g,h,i,e){if(!Number.isFinite(e.timeoutMs)||e.timeoutMs<=0||!Number.isSafeInteger(e.maxBytes)||e.maxBytes<=0)throw new TypeError("Owned command deadlines and byte limits must be positive");e.signal?.throwIfAborted();let o=new AbortController,y=e.signal?AbortSignal.any([e.signal,o.signal]):o.signal,B=setTimeout(()=>o.abort(new f("TIMEOUT",i,e.effect)),e.timeoutMs),a,u,d;try{a=await w(l,g,h,l.workspace,{signal:y,timeoutMs:e.timeoutMs});let r=[],n=[],c=0,m=s((t,T)=>{c+=t.length,c>e.maxBytes?o.abort(new f(e.limitCode??"BYTE_LIMIT",i,e.effect)):T.push(t)},"consume");if(a.stdout.on("data",t=>m(t,r)),a.stderr.on("data",t=>m(t,n)),e.input!==void 0)for(let t=0;t<e.input.length;t+=65536)await a.write(e.input.subarray(t,t+65536));if(e.closeInput||e.input!==void 0)try{await a.end()}catch(t){if(!(t instanceof f)||t.code!=="INPUT_CLOSED")throw t}let{exitCode:b}=await a.completion;d={stdout:Buffer.concat(r),stderr:Buffer.concat(n),exitCode:b}}catch(r){let n=o.signal.aborted?o.signal.reason:r;u=n instanceof f&&(n.source!==i||n.effect==="unknown"&&e.effect==="not-applied")?new f(n.code,i,n.effect==="not-applied"?"not-applied":e.effect,{cause:n}):n}finally{clearTimeout(B)}try{await a?.stop()}catch(r){throw d===void 0?new AggregateError([u,r],"Target command and cleanup failed",{cause:r}):r}if(d===void 0)throw u;return d}s(I,"runOwnedSshCommand");export{I as a};
1
+ import{a as w}from"./chunk-Q5X6OXNS.js";import{g as f}from"./chunk-4HWKBCBH.js";import{a as s}from"./chunk-EI7MMDWY.js";async function I(l,g,h,i,e){if(!Number.isFinite(e.timeoutMs)||e.timeoutMs<=0||!Number.isSafeInteger(e.maxBytes)||e.maxBytes<=0)throw new TypeError("Owned command deadlines and byte limits must be positive");e.signal?.throwIfAborted();let o=new AbortController,y=e.signal?AbortSignal.any([e.signal,o.signal]):o.signal,B=setTimeout(()=>o.abort(new f("TIMEOUT",i,e.effect)),e.timeoutMs),a,u,d;try{a=await w(l,g,h,l.workspace,{signal:y,timeoutMs:e.timeoutMs});let r=[],n=[],c=0,m=s((t,T)=>{c+=t.length,c>e.maxBytes?o.abort(new f(e.limitCode??"BYTE_LIMIT",i,e.effect)):T.push(t)},"consume");if(a.stdout.on("data",t=>m(t,r)),a.stderr.on("data",t=>m(t,n)),e.input!==void 0)for(let t=0;t<e.input.length;t+=65536)await a.write(e.input.subarray(t,t+65536));if(e.closeInput||e.input!==void 0)try{await a.end()}catch(t){if(!(t instanceof f)||t.code!=="INPUT_CLOSED")throw t}let{exitCode:b}=await a.completion;d={stdout:Buffer.concat(r),stderr:Buffer.concat(n),exitCode:b}}catch(r){let n=o.signal.aborted?o.signal.reason:r;u=n instanceof f&&(n.source!==i||n.effect==="unknown"&&e.effect==="not-applied")?new f(n.code,i,n.effect==="not-applied"?"not-applied":e.effect,{cause:n}):n}finally{clearTimeout(B)}try{await a?.stop()}catch(r){throw d===void 0?new AggregateError([u,r],"Target command and cleanup failed",{cause:r}):r}if(d===void 0)throw u;return d}s(I,"runOwnedSshCommand");export{I as a};