pi-agent-ide 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{chunk-TVH2ND35.js → chunk-35LZOKEW.js} +1 -1
  3. package/dist/chunk-3LVBARLW.js +33 -0
  4. package/dist/chunk-4GBFIGH3.js +1 -1
  5. package/dist/{chunk-64JTD2DJ.js → chunk-5PC5INOL.js} +1 -1
  6. package/dist/{chunk-FKKAHI62.js → chunk-BT2CFM7D.js} +1 -1
  7. package/dist/{chunk-VN3XBH2Q.js → chunk-DVNL5NZE.js} +1 -1
  8. package/dist/{chunk-PLMHBXWI.js → chunk-FXPY3V4L.js} +1 -1
  9. package/dist/{chunk-AJZVKDYC.js → chunk-HGCJDIRR.js} +1 -1
  10. package/dist/{chunk-RVFMH77U.js → chunk-HISGZD3C.js} +43 -44
  11. package/dist/{chunk-KFBRL2V4.js → chunk-HKYVP2Q6.js} +1 -1
  12. package/dist/{chunk-TVXZE4KW.js → chunk-HRBUY2FF.js} +1 -1
  13. package/dist/{chunk-QM5WDEFI.js → chunk-IOGWZNWT.js} +1 -1
  14. package/dist/{chunk-HT7LZN5A.js → chunk-IUJUECXH.js} +1 -1
  15. package/dist/chunk-LXDF2NWX.js +1 -0
  16. package/dist/{chunk-TVSZYABY.js → chunk-MPNE25CY.js} +1 -1
  17. package/dist/{chunk-Y74EKJOY.js → chunk-O7V6G3OO.js} +1 -1
  18. package/dist/chunk-OUCVZBOR.js +28 -0
  19. package/dist/{chunk-WUO3UW4J.js → chunk-PCGBM2D6.js} +1 -1
  20. package/dist/{chunk-V4J3TLCV.js → chunk-RIZARTUM.js} +1 -1
  21. package/dist/{chunk-LTADNZKW.js → chunk-T3Z4KXOX.js} +1 -1
  22. package/dist/chunk-TSQ6FBTB.js +1 -0
  23. package/dist/{chunk-CVOYSEBE.js → chunk-VNWGT367.js} +1 -1
  24. package/dist/{chunk-FS3KCKFX.js → chunk-X2WFNMQR.js} +1 -1
  25. package/dist/{chunk-7SG756UO.js → chunk-XCPIIDFS.js} +1 -1
  26. package/dist/entry-0.js +1 -1
  27. package/dist/entry-1.js +1 -1
  28. package/dist/entry-10.js +1 -1
  29. package/dist/entry-11.js +1 -1
  30. package/dist/entry-12.js +1 -1
  31. package/dist/entry-13.js +1 -1
  32. package/dist/entry-14.js +1 -1
  33. package/dist/entry-15.js +1 -1
  34. package/dist/entry-16.js +1 -1
  35. package/dist/entry-17.js +1 -1
  36. package/dist/entry-18.js +1 -1
  37. package/dist/entry-19.js +1 -1
  38. package/dist/entry-2.js +1 -1
  39. package/dist/entry-20.js +1 -1
  40. package/dist/entry-21.js +1 -1
  41. package/dist/entry-22.js +1 -0
  42. package/dist/entry-24.js +1 -1
  43. package/dist/entry-25.js +1 -1
  44. package/dist/entry-26.js +1 -1
  45. package/dist/entry-27.js +1 -1
  46. package/dist/entry-28.js +1 -1
  47. package/dist/entry-29.js +1 -1
  48. package/dist/entry-3.js +1 -1
  49. package/dist/entry-30.js +1 -2
  50. package/dist/entry-31.js +2 -1
  51. package/dist/entry-32.js +1 -1
  52. package/dist/entry-33.js +1 -1
  53. package/dist/entry-34.js +1 -1
  54. package/dist/entry-35.js +1 -1
  55. package/dist/entry-36.js +1 -1
  56. package/dist/entry-37.js +1 -15
  57. package/dist/entry-38.js +15 -1
  58. package/dist/entry-39.js +1 -1
  59. package/dist/entry-4.js +1 -1
  60. package/dist/entry-40.js +1 -1
  61. package/dist/entry-41.js +1 -1
  62. package/dist/entry-42.js +1 -1
  63. package/dist/entry-43.js +1 -1
  64. package/dist/entry-44.js +1 -1
  65. package/dist/entry-45.js +1 -1
  66. package/dist/entry-46.js +1 -1
  67. package/dist/entry-47.js +1 -1
  68. package/dist/entry-48.js +1 -1
  69. package/dist/entry-49.js +1 -1
  70. package/dist/entry-5.js +1 -1
  71. package/dist/entry-50.js +1 -1
  72. package/dist/entry-51.js +1 -1
  73. package/dist/entry-52.js +1 -1
  74. package/dist/entry-53.js +1 -1
  75. package/dist/entry-54.js +1 -1
  76. package/dist/entry-55.js +1 -1
  77. package/dist/entry-56.js +1 -1
  78. package/dist/entry-57.js +1 -1
  79. package/dist/entry-58.js +1 -1
  80. package/dist/entry-59.js +1 -1
  81. package/dist/entry-6.js +1 -1
  82. package/dist/entry-60.js +1 -1
  83. package/dist/entry-61.js +1 -1
  84. package/dist/entry-62.js +1 -1
  85. package/dist/entry-63.js +1 -1
  86. package/dist/entry-64.js +1 -1
  87. package/dist/entry-65.js +1 -1
  88. package/dist/entry-66.js +1 -1
  89. package/dist/entry-67.js +1 -0
  90. package/dist/entry-68.js +0 -1
  91. package/dist/entry-69.js +1 -0
  92. package/dist/entry-7.js +1 -1
  93. package/dist/entry-70.js +0 -1
  94. package/dist/entry-71.js +1 -1
  95. package/dist/entry-72.js +1 -1
  96. package/dist/entry-73.js +1 -1
  97. package/dist/entry-74.js +1 -1
  98. package/dist/entry-75.js +1 -1
  99. package/dist/entry-76.js +1 -1
  100. package/dist/entry-77.js +1 -0
  101. package/dist/entry-78.js +0 -1
  102. package/dist/entry-79.js +1 -0
  103. package/dist/entry-8.js +1 -1
  104. package/dist/entry-80.js +0 -1
  105. package/dist/entry-81.js +1 -1
  106. package/dist/entry-82.js +1 -1
  107. package/dist/entry-83.js +1 -1
  108. package/dist/entry-84.js +1 -1
  109. package/dist/entry-85.js +1 -2
  110. package/dist/entry-86.js +2 -1
  111. package/dist/entry-87.js +1 -1
  112. package/dist/entry-88.js +1 -1
  113. package/dist/entry-89.js +1 -1
  114. package/dist/entry-9.js +1 -1
  115. package/dist/entry-90.js +1 -3
  116. package/dist/entry-91.js +3 -1
  117. package/dist/entry-92.js +1 -1
  118. package/dist/entry-93.js +1 -1
  119. package/dist/entry-94.js +1 -0
  120. package/dist/pi-agent-ide.js +13 -10
  121. package/docs/agent-guides/editing.md +3 -0
  122. package/docs/tools.md +2 -2
  123. package/node_modules/pi-agent-doctor/package.json +7 -7
  124. package/node_modules/pi-agent-documentation/package.json +2 -2
  125. package/node_modules/pi-agent-documentation/runtime/entry-30.js +1 -0
  126. package/node_modules/pi-agent-filesystem/package.json +8 -8
  127. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  128. package/node_modules/pi-agent-filesystem-image/runtime/entry-32.js +2 -0
  129. package/node_modules/pi-agent-filesystem-jq/package.json +7 -7
  130. package/node_modules/pi-agent-filesystem-jq/runtime/entry-33.js +0 -1
  131. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  132. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  133. package/node_modules/pi-agent-filesystem-text/runtime/entry-36.js +2 -0
  134. package/node_modules/pi-agent-ide-ast/package.json +15 -15
  135. package/node_modules/pi-agent-ide-ast/runtime/entry-37.js +0 -1
  136. package/node_modules/pi-agent-ide-ast/runtime/entry-38.js +2 -0
  137. package/node_modules/pi-agent-ide-changes/package.json +10 -10
  138. package/node_modules/pi-agent-ide-changes/runtime/entry-39.js +0 -1
  139. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  140. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  141. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  142. package/node_modules/pi-agent-ide-lsp/package.json +13 -13
  143. package/node_modules/pi-agent-ide-lsp/runtime/entry-44.js +2 -0
  144. package/node_modules/pi-agent-image/package.json +3 -3
  145. package/node_modules/pi-agent-invariant/package.json +2 -2
  146. package/node_modules/pi-agent-pdf/package.json +3 -3
  147. package/node_modules/pi-agent-read/package.json +12 -12
  148. package/node_modules/pi-agent-read/runtime/entry-51.js +0 -1
  149. package/node_modules/pi-agent-read/runtime/entry-52.js +2 -0
  150. package/node_modules/pi-agent-resource/package.json +2 -2
  151. package/node_modules/pi-agent-search/package.json +9 -9
  152. package/node_modules/pi-agent-search/runtime/entry-56.js +0 -1
  153. package/node_modules/pi-agent-search-text/package.json +15 -15
  154. package/node_modules/pi-agent-search-text/runtime/entry-58.js +1 -0
  155. package/node_modules/pi-agent-text/package.json +3 -3
  156. package/node_modules/pi-agent-text/runtime/entry-62.js +1 -0
  157. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  158. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-63.js +2 -0
  159. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  160. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-64.js +0 -1
  161. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-65.js +2 -0
  162. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  163. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-66.js +0 -1
  164. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-67.js +2 -0
  165. package/node_modules/pi-agent-text-editor/package.json +26 -26
  166. package/node_modules/pi-agent-text-editor/runtime/entry-83.js +0 -1
  167. package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +2 -6
  168. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +17 -36
  169. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +40 -82
  170. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +1 -1
  171. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -9
  172. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -3
  173. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -5
  174. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +2 -8
  175. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  176. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +6 -6
  177. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +2 -0
  178. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  179. package/node_modules/pi-agent-tool-ui/package.json +3 -3
  180. package/node_modules/pi-agent-tool-ui/runtime/entry-89.js +1 -0
  181. package/node_modules/pi-agent-web/package.json +8 -8
  182. package/node_modules/pi-agent-web-html/package.json +3 -3
  183. package/node_modules/pi-agent-web-image/package.json +4 -4
  184. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  185. package/node_modules/pi-agent-web-text/package.json +4 -4
  186. package/node_modules/pi-agent-web-text/runtime/entry-94.js +2 -0
  187. package/package.json +60 -56
  188. package/src/api/capabilities.ts +60 -0
  189. package/src/composite/capabilities.ts +252 -0
  190. package/src/composite/capability-schemas.ts +53 -0
  191. package/src/composite/responses-tools.ts +27 -9
  192. package/src/composite/tool-availability.ts +28 -13
  193. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
  194. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  195. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-32.js +2 -0
  196. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +7 -7
  197. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-33.js +0 -1
  198. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  199. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  200. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-36.js +2 -0
  201. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-31.js +2 -0
  202. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
  203. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  204. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  205. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  206. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  207. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-94.js +2 -0
  208. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-90.js +2 -0
  209. package/src/extensions/pi-agent-read/package.json +12 -12
  210. package/src/extensions/pi-agent-read/runtime/entry-51.js +0 -1
  211. package/src/extensions/pi-agent-read/runtime/entry-52.js +2 -0
  212. package/src/extensions/pi-agent-search/package.json +9 -9
  213. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +15 -15
  214. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-58.js +1 -0
  215. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-61.js +1 -0
  216. package/src/extensions/pi-agent-search/runtime/entry-56.js +0 -1
  217. package/src/extensions/pi-agent-search/runtime/entry-57.js +2 -0
  218. package/src/extensions/pi-agent-text-editor/package.json +26 -26
  219. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  220. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-63.js +2 -0
  221. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  222. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-64.js +0 -1
  223. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-65.js +2 -0
  224. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  225. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-66.js +0 -1
  226. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-67.js +2 -0
  227. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  228. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +6 -6
  229. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +2 -0
  230. package/src/extensions/pi-agent-text-editor/runtime/entry-83.js +0 -1
  231. package/src/extensions/pi-agent-text-editor/runtime/entry-84.js +2 -0
  232. package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +2 -6
  233. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +17 -36
  234. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +40 -82
  235. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +1 -1
  236. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -9
  237. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -3
  238. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -5
  239. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +2 -8
  240. package/src/pi-agent-ide.ts +4 -1
  241. package/src/plugins/pi-agent-ide-ast/package.json +15 -15
  242. package/src/plugins/pi-agent-ide-ast/runtime/entry-37.js +0 -1
  243. package/src/plugins/pi-agent-ide-ast/runtime/entry-38.js +2 -0
  244. package/src/plugins/pi-agent-ide-changes/package.json +10 -10
  245. package/src/plugins/pi-agent-ide-changes/runtime/entry-39.js +0 -1
  246. package/src/plugins/pi-agent-ide-debugger/index.ts +31 -26
  247. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  248. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  249. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  250. package/src/plugins/pi-agent-ide-lsp/package.json +13 -13
  251. package/src/plugins/pi-agent-ide-lsp/runtime/entry-44.js +2 -0
  252. package/src/plugins/pi-agent-ide-terminal/index.ts +42 -0
  253. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +0 -21
  254. package/src/plugins/pi-agent-ide-terminal/src/search.ts +0 -3
  255. package/dist/chunk-7URANI6I.js +0 -28
  256. package/dist/chunk-K4UTEMDU.js +0 -1
  257. package/dist/chunk-TNAUCNUT.js +0 -33
  258. package/dist/entry-23.js +0 -1
  259. package/node_modules/pi-agent-doctor/runtime/entry-23.js +0 -1
  260. package/node_modules/pi-agent-filesystem/runtime/entry-30.js +0 -2
  261. package/node_modules/pi-agent-filesystem-jq/runtime/entry-32.js +0 -1
  262. package/node_modules/pi-agent-ide-ast/runtime/entry-36.js +0 -1
  263. package/node_modules/pi-agent-ide-changes/runtime/entry-38.js +0 -1
  264. package/node_modules/pi-agent-image/runtime/entry-44.js +0 -1
  265. package/node_modules/pi-agent-resource/runtime/entry-52.js +0 -1
  266. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-62.js +0 -2
  267. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-63.js +0 -1
  268. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-65.js +0 -1
  269. package/node_modules/pi-agent-text-editor/runtime/entry-67.js +0 -1
  270. package/node_modules/pi-agent-tool-call-interception/runtime/entry-86.js +0 -1
  271. package/node_modules/pi-agent-web/runtime/entry-89.js +0 -2
  272. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-31.js +0 -2
  273. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-32.js +0 -1
  274. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-30.js +0 -2
  275. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-90.js +0 -2
  276. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-89.js +0 -2
  277. package/src/extensions/pi-agent-read/runtime/entry-47.js +0 -1
  278. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-57.js +0 -2
  279. package/src/extensions/pi-agent-search/runtime/entry-53.js +0 -1
  280. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-62.js +0 -2
  281. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-63.js +0 -1
  282. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-65.js +0 -1
  283. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-84.js +0 -2
  284. package/src/extensions/pi-agent-text-editor/runtime/entry-67.js +0 -1
  285. package/src/plugins/pi-agent-ide-ast/runtime/entry-36.js +0 -1
  286. package/src/plugins/pi-agent-ide-changes/runtime/entry-38.js +0 -1
  287. /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-29.js +0 -0
  288. /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-31.js +0 -0
  289. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-34.js +0 -0
  290. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-35.js +0 -0
  291. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-40.js +0 -0
  292. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-41.js +0 -0
  293. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-42.js +0 -0
  294. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-43.js +0 -0
  295. /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-45.js +0 -0
  296. /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-46.js +0 -0
  297. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-47.js +0 -0
  298. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-53.js +0 -0
  299. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-57.js +0 -0
  300. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-61.js +0 -0
  301. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-84.js +0 -0
  302. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-85.js +0 -0
  303. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-87.js +0 -0
  304. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-90.js +0 -0
  305. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-91.js +0 -0
  306. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-92.js +0 -0
  307. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-93.js +0 -0
  308. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-34.js +0 -0
  309. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-35.js +0 -0
  310. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-91.js +0 -0
  311. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-92.js +0 -0
  312. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-93.js +0 -0
  313. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-85.js +0 -0
  314. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-40.js +0 -0
  315. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-41.js +0 -0
  316. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-42.js +0 -0
  317. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-43.js +0 -0
@@ -1,4 +1,4 @@
1
- import{a as gt,c as mt}from"./chunk-B25LXXNV.js";import{f as ze,g as Ve}from"./chunk-XH5WN5XA.js";import{a as Ke}from"./chunk-47SPPIXK.js";import{a as He,b as Ge}from"./chunk-VAXLSPPU.js";import{a as pe,b as Ze,c as et}from"./chunk-FYOU4RBH.js";import{b as Be,c as Je,d as ue}from"./chunk-7PVDTMEM.js";import{a as Ye}from"./chunk-MDD5ORB6.js";import{b as Xe,c as Qe}from"./chunk-MLFJU2US.js";import{a as te,e as Fe}from"./chunk-PS2B6THP.js";import{a as tt}from"./chunk-GXL4NMHR.js";import{c as Ue,d as We,f as qe}from"./chunk-PQWANILR.js";import{a as $e}from"./chunk-BU7IZLKB.js";import{a as Oe,b as Me}from"./chunk-S5PL5DFQ.js";import{K as Te,M as z,m as Ae,n as je}from"./chunk-DDH3FP4G.js";import{h as nt}from"./chunk-TVH2ND35.js";import{a as N,b as I,c as rt,d as V}from"./chunk-T4FTT3U4.js";import{m as Ne}from"./chunk-VDJSH3DQ.js";import{a as it}from"./chunk-ZAWRSA7N.js";import{a as ot,b as st}from"./chunk-OFILFO6D.js";import{b as ct,c as lt,g as dt,j as ut,p as pt}from"./chunk-7D7PXIVV.js";import{a as at}from"./chunk-BXGMMZT3.js";import{a as k}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import Or from"node:path";var H=[{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"]}]}}},S("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}}),S("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"]}}},S("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"]),S("dart-language-server",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],{dart:[".dart"]},["dart","language-server","--protocol=lsp"],"https://dart.dev/tools/dart-language-server"),S("r-language-server",["r"],["Rscript"],["DESCRIPTION",".lintr",".Rprofile"],{r:[".r"]},["Rscript","-e","languageserver::run()"],"https://github.com/REditorSupport/languageserver"),S("zls",["zig"],["zls"],["build.zig","build.zig.zon","zls.json"],{zig:[".zig",".zon"]},["zls"],"https://zigtools.org/zls/"),S("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/"),S("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"]),S("basedpyright",["python"],["basedpyright-langserver","pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),S("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),S("rust-analyzer",["rust"],["rust-analyzer"],["Cargo.toml","rust-project.json"],{rust:[".rs"]},["rust-analyzer"],"https://rust-analyzer.github.io/"),S("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),S("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),S("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"),S("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),S("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),S("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),S("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),S("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),S("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:{}}),S("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"),S("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"),S("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),S("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),S("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),S("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"),S("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"),S("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"),S("neocmakelsp",["cmake"],["neocmakelsp"],["CMakeLists.txt",".neocmake.toml",".neocmakelint.toml"],{cmake:[".cmake"]},["neocmakelsp","stdio"],"https://github.com/neocmakelsp/neocmakelsp",void 0,{cmake:["CMakeLists.txt"]}),S("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"),S("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),S("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),S("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 S(o,e,t,r,n,s,i,d,c,l){return{id:o,name:o,kind:"lsp",languages:e,executables:t,configFiles:r,documentation:i,...d&&{dependencies:d},lsp:{command:s,rootMarkers:r,languageIds:n,...c&&{fileNames:c},...l&&{settings:l}}}}a(S,"recipe");import{readFile as ft}from"node:fs/promises";import{URI as yt}from"vscode-uri";var X={Error:1,Warning:2,Information:3,Hint:4};var ht={command:"typescript.tsserverRequest",async request(o,e,t){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async n=>{let s=await o.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[n,{file:o.serverDocumentPath(e),includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},t);if(!ge(s)||s.success!==!0||!Array.isArray(s.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${n}`);return s.body.map(Gt)}))).flat()}};function re(o){return o.supportsCommand(ht.command)?ht:void 0}a(re,"completedDiagnosticAdapter");function Gt(o){if(!ge(o)||typeof o.message!="string"||typeof o.code!="number"&&typeof o.code!="string"||!ge(o.startLocation)||!Number.isInteger(o.startLocation.line)||!Number.isInteger(o.startLocation.offset)||Number(o.startLocation.line)<1||Number(o.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(o.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(o.code),message:o.message,line:Number(o.startLocation.line),column:Number(o.startLocation.offset),severity:o.category==="error"?"error":o.category==="warning"?"warning":o.category==="suggestion"?"hint":"info"}}a(Gt,"convertTypeScriptDiagnostic");function ge(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)}a(ge,"isRecord");async function Q(o,e,t,r={}){let n=new AbortController,s=AbortSignal.any([n.signal,...r.signal?[r.signal]:[]]),i=setTimeout(()=>n.abort(new Error(`[lsp] ${o.serverId}: diagnostics timed out for ${e}`)),o.timeoutMs);try{return await Bt(o,e,t,r.content,s)}finally{clearTimeout(i)}}a(Q,"requestDiagnostics");async function Bt(o,e,t,r,n){if(n.throwIfAborted(),o.diagnosticMode!=="push"){let c=o.documentVersion(e);try{let l=await o.sendRequest("textDocument/diagnostic",{textDocument:{uri:e}},n);if(l.kind!=="full"||!Array.isArray(l.items))throw new Error("Invalid full diagnostic report");if(o.documentVersion(e)!==c)throw new Error("Document changed during diagnostic request");return o.setDiagnosticMode("pull"),wt(l.items,!1,!0)}catch(l){if(!Jt(l))throw l;o.setDiagnosticMode("push")}}let s=re(o);if(s){o.documentVersion(e)===void 0&&o.syncDocument(e,r??await ft(yt.parse(e).fsPath,"utf8"),t??"plaintext");let c=o.documentVersion(e),l=await s.request(o,e,n);if(n.throwIfAborted(),o.documentVersion(e)!==c)throw new Error("Document changed during diagnostic request");return{diagnostics:l,syntaxErrors:[],otherDiagnostics:l,unversioned:!1,complete:!0}}n.throwIfAborted();let i=o.documentVersion(e)!==void 0,d=i?void 0:r??await ft(yt.parse(e).fsPath,"utf8");n.throwIfAborted(),o.beginDiagnosticRequest(e);try{return await new Promise((c,l)=>{let m=o.documentVersion(e)??1,y=a(g=>{let p=g;p.uri!==e||!Array.isArray(p.diagnostics)||p.version!==void 0&&p.version!==m||o.documentVersion(e)===m&&(f(),c(wt(p.diagnostics,p.version===void 0)))},"receive"),u=o.onNotification("textDocument/publishDiagnostics",y),h=a(()=>{f(),l(n.reason)},"onAbort");function f(){u(),n.removeEventListener("abort",h)}a(f,"cleanup"),n.addEventListener("abort",h,{once:!0});try{i||o.syncDocument(e,d??"",t??"plaintext");let g=o.diagnosticPublication(e);g&&y({uri:e,...g})}catch(g){f(),l(g)}})}finally{o.endDiagnosticRequest(e)}}a(Bt,"requestCurrentDiagnostics");function me(o){return{code:String(o.code??"LSP"),message:o.message,line:o.range.start.line+1,column:o.range.start.character+1,severity:o.severity===X.Warning?"warning":o.severity===X.Information?"info":o.severity===X.Hint?"hint":"error"}}a(me,"toDiagnostic");function wt(o,e,t=!1){let r=o.map(me);return{diagnostics:r,syntaxErrors:[],otherDiagnostics:r,unversioned:e,complete:t}}a(wt,"classify");function Jt(o){return o!==null&&typeof o=="object"&&"code"in o&&o.code===-32601}a(Jt,"isMethodNotFound");function bt(o,e=(t,r)=>Promise.resolve({cwd:r,external:!1})){return{id:"lsp",async diagnose(t,r){let n=await e(t,r.cwd,r.signal);if(n===void 0)return{status:"unavailable",diagnostics:[],reason:"No local language-server project found for this file"};let s=await o(n.cwd,n.external,r.signal);r.signal.throwIfAborted();let i=await s.getOrStart(t,n.cwd,"diagnostics",r.signal);if(r.signal.throwIfAborted(),!i)return{status:"unavailable",diagnostics:[],reason:"No language server configured for this file"};let d=i.toUri(t),c=s.languageId(t);i.syncDocument(d,r.content,c,!0);let l=i.documentVersion(d),m={active:!0,queued:!1},y=a(()=>!r.signal.aborted&&i.documentVersion(d)===l,"current"),u=a(()=>Q(i,d,c,{signal:r.signal,content:r.content}),"request"),h=a(async()=>{if(m.queued=!0,!m.active){m.active=!0;try{for(;m.queued&&y();){m.queued=!1;let g=await u();y()&&r.publish(vt(g,i.commandName))}}catch(g){y()&&r.publish({status:"unavailable",diagnostics:[],reason:g instanceof Error?g.message:String(g),source:i.commandName})}finally{m.active=!1}}},"refresh"),f=s.onPushDiagnostics(g=>{!y()||g.uri!==d||g.serverId!==i.serverId||g.cwd!==n.cwd||g.version!==void 0&&g.version!==l||(i.diagnosticMode==="pull"||re(i)?h():r.publish({status:"snapshot",diagnostics:g.diagnostics,source:i.commandName,reason:St(g.version===void 0)}))});r.signal.addEventListener("abort",f,{once:!0});try{let g=await u();return l=i.documentVersion(d),vt(g,i.commandName)}catch(g){throw m.queued=!1,f(),r.signal.removeEventListener("abort",f),g}finally{m.active=!1,m.queued&&y()&&queueMicrotask(()=>{h()})}}}}a(bt,"createLspDiagnosticSource");function St(o){return`Latest push snapshot; completion is unknown${o?"; language server omitted the document version":""}`}a(St,"snapshotReason");function vt(o,e){return o.complete?{status:"ready",diagnostics:o.diagnostics,source:e}:{status:"snapshot",diagnostics:o.diagnostics,reason:St(o.unversioned),source:e}}a(vt,"toReport");import{URI as ur}from"vscode-uri";import nr from"node:path";import or from"cross-spawn";import{createMessageConnection as sr,CancellationTokenSource as ir,StreamMessageReader as ar}from"vscode-jsonrpc/node";import{URI as Rt}from"vscode-uri";import{watch as Kt}from"node:fs";import{readdir as Xt,stat as Qt}from"node:fs/promises";import G from"node:path";import{URI as he}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 n of t){let s=n.globPattern,i=typeof s=="string"?this.root:he.parse(typeof s.baseUri=="string"?s.baseUri:s.baseUri.uri).fsPath,d=typeof s=="string"?s:s.pattern,c=a(y=>G.matchesGlob(G.isAbsolute(d)?G.join(i,y):y,d),"matches"),l=new Set((await Xt(i,{recursive:!0})).filter(c));if(this.disposed)throw new Error("Language server file watchers are disposed");let m=Kt(i,{recursive:!0},(y,u)=>{!u||!c(u)||Qt(G.join(i,u)).then(()=>{if(!this.registrations.get(e)?.includes(m))return;let h=l.has(u)?2:1;l.add(u),(n.kind??7)&(h===1?1:2)&&this.changed({uri:he.file(G.join(i,u)).toString(),type:h})},h=>{if(this.registrations.get(e)?.includes(m)){if(h.code!=="ENOENT"){this.failed(h);return}l.delete(u)&&(n.kind??7)&4&&this.changed({uri:he.file(G.join(i,u)).toString(),type:3})}})});m.on("error",this.failed),r.push(m)}}catch(n){for(let s of r)s.close();throw n}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 Yt}from"vscode-jsonrpc/node";var oe=class extends Yt{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 er}from"vscode-uri";function E(o,e){if(e.startsWith("ssh://")){let t=Lt(e);if(o.includes("://")){let n=Lt(o);if(n.host!==t.host)throw new Error("Document belongs to another language server owner");return n.href}let r=Zt.posix.resolve(decodeURIComponent(t.pathname),o);return t.pathname=r.split("/").map(encodeURIComponent).join("/"),t.href}if(o.startsWith("ssh://")||o.includes("://")&&!o.startsWith("file://"))throw new Error("Document belongs to another language server owner");return o.startsWith("file://")?o:er.file(o).toString()}a(E,"documentUri");function Lt(o){let e=new URL(o);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(Lt,"checkedRemote");async function T(o,e){if(e?.aborted)throw o.catch(()=>{}),e.reason;if(!e)return o;let t;try{return await Promise.race([o,new Promise((r,n)=>{t=a(()=>n(e.reason),"onAbort"),e.addEventListener("abort",t,{once:!0})})])}finally{t&&e.removeEventListener("abort",t)}}a(T,"waitWithSignal");var B=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 T(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 tr=new Set(["uri","targetUri","target","oldUri","newUri","rootUri","documentUri","scopeUri","baseUri"]),rr=new Set(["changes","relatedDocuments"]);function O(o,e){return Array.isArray(o)?o.map(t=>O(t,e)):typeof o!="object"||o===null?o:Object.fromEntries(Object.entries(o).map(([t,r])=>tr.has(t)&&typeof r=="string"?[t,e(r)]:rr.has(t)&&typeof r=="object"&&r!==null&&!Array.isArray(r)?[t,Object.fromEntries(Object.entries(r).map(([n,s])=>[e(n),O(s,e)]))]:[t,O(r,e)]))}a(O,"mapLspUris");var U=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 ct(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=k(this._command[0]),r=this._ownerTransport?decodeURIComponent(new URL(this.rootUri).pathname):Rt.parse(this.rootUri).fsPath,n=[{uri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,name:nr.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:or(t,this._args,{stdio:["pipe","pipe","pipe"],...e&&{signal:e},cwd:r,env:pt({command:this._command,env:this._env},r,process.env)});this._process=i??null;let d=i?cr(i):Promise.resolve(),c=k(s?.stdin??i?.stdin),l=k(s?.stdout??i?.stdout),m=k(s?.stderr??i?.stderr);c.on("error",()=>{}),l.on("error",()=>{}),m.on("error",()=>{}),this._stderr="",m.setEncoding("utf8"),m.on("data",p=>{this._stderr=(this._stderr+p).slice(-4096)}),i?.on("error",p=>{("code"in p?p.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,p),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null});let y=a(p=>{(s?this._ownedProcess!==s:this._process!==i)||(this._closeFileWatchers(),!this._disposed&&p!==0&&p!==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",y),s?.completion.then(({exitCode:p})=>y(p),()=>{this._ownedProcess===s&&(this._crashed=!0,y(null))}),await T(d,e);let u=sr(new ar(l),new oe(c,p=>{this._connection!==u||this._disposed||(this._crashed=!0,this._initialized=!1,this._closeFileWatchers(),u.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,p))}));this._connection=u,this._connection.onError(p=>{console.error(`[lsp] ${this.serverId}: connection error:`,p)});let h=a(p=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[p]})},"changed"),f=a(p=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,p),"failed");this._fileWatchers=this._ownerTransport?this._ownerTransport.fileWatchers?.(this.rootUri,h,f):new ne(r,h,f),this._connection.onRequest("client/registerCapability",async p=>{for(let w of p.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 p=>{for(let w of p.unregisterations)await this._fileWatchers?.unregister(w.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/configuration",p=>p.items.map(w=>{let v=this._settings??null;for(let L of w.section?.split(".").filter(Boolean)??[])v=typeof v=="object"&&v!==null?v[L]??null:null;return v})),this._connection.listen(),this._connection.onNotification((p,...w)=>{let v=this._ownerTransport,L=v?O(w[0],b=>v.fromServerUri(b)):w[0];if(p==="textDocument/publishDiagnostics"){let b=L;b&&typeof b.uri=="string"&&Array.isArray(b.diagnostics)&&this._documentVersions.has(b.uri)&&(b.version===void 0||b.version===this.documentVersion(b.uri))&&this._diagnosticPublications.set(b.uri,{diagnostics:b.diagnostics,...typeof b.version=="number"&&{version:b.version}})}for(let b of this._handlers.get(p)??[])b(L)}),this._connection.onRequest("workspace/workspaceFolders",()=>n);let g=await T(Pt(this._connection.sendRequest("initialize",{processId:this._ownerTransport?null:process.pid,rootUri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,workspaceFolders:n,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(p=>{let w=this._stderr.trim();throw w?new Error(`[lsp] ${this.serverId}: ${w}`,{cause:p}):p});if(await this._connection.sendNotification("initialized",{capabilities:g.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=g.capabilities,this._diagnosticMode=g.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 n=this._ownerTransport,s=n?O(t,l=>n.toServerUri(l)):t,i=a(l=>n?O(l,m=>n.fromServerUri(m)):l,"mapResult");if(!r)return i(await k(this._connection).sendRequest(e,s));let d=new ir,c;try{let l=k(this._connection).sendRequest(e,s,d.token);return i(await Promise.race([l,new Promise((m,y)=>{c=a(()=>{d.cancel(),y(r.reason)},"onAbort"),r.addEventListener("abort",c,{once:!0})})]))}finally{c&&r.removeEventListener("abort",c),d.dispose()}}sendNotification(e,t){this._assertReady(),this._sendNotification(e,t)}_sendNotification(e,t){let r=this._connection;if(!r)return;let n=this._ownerTransport,s=n?O(t,i=>n.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 n=r.indexOf(t);n!==-1&&r.splice(n,1)}}toUri(e){return E(e,this.rootUri)}serverDocumentPath(e){let t=this.toUri(e),r=this._ownerTransport?.toServerUri(t)??t;return this._ownerTransport?decodeURIComponent(new URL(r).pathname):Rt.parse(r).fsPath}openDocument(e,t,r,n=1){let s=this._documentVersions.get(e);if(s!==void 0){this.changeDocument(e,t,Math.max(n,s+1));return}this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:r,version:n,text:t}}),this._documentVersions.set(e,n),this._documentContents.set(e,t)}syncDocument(e,t,r,n=!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,d=typeof i=="object"&&i!==null?i.save:void 0;n&&d&&this.sendNotification("textDocument/didSave",{textDocument:{uri:e},...typeof d=="object"&&d.includeText&&{text:t}})}changeDocument(e,t,r){let n=this._documentVersions.get(e),s=Math.max(r,(n??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 Pt(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()),n=this._process;this._process=null,n&&!n.killed&&(n.kill("SIGTERM"),setTimeout(()=>{n.exitCode===null&&n.signalCode===null&&n.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 d of s)d.status==="rejected"&&i.push(d.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 cr(o){return new Promise((e,t)=>{let r=a(()=>{o.off("spawn",n),o.off("error",s)},"cleanup"),n=a(()=>{r(),e()},"onSpawn"),s=a(i=>{r(),t(i)},"onError");o.once("spawn",n),o.once("error",s)})}a(cr,"waitForSpawn");function Pt(o,e,t){return new Promise((r,n)=>{let s=setTimeout(()=>{n(new Error(t))},e);o.then(i=>{clearTimeout(s),r(i)}).catch(i=>{clearTimeout(s),n(i instanceof Error?i:new Error(String(i)))})})}a(Pt,"withTimeout");import _ from"node:path";import{existsSync as lr}from"node:fs";function _t(o){let e=new Map,t=new Map;for(let[r,n]of Object.entries(o))for(let[s,i]of Object.entries(n.languages))for(let d of i.extensions){let c=d.toLowerCase(),l=e.get(c);if(l!==void 0&&l!==s)throw new Error(`[lsp] extension conflict: "${c}" claimed by "${l}" and "${s}"`);e.set(c,s);let m=t.get(c)??[];m.push(r),t.set(c,m)}return{extToLanguageId:e,extToServerIds:t}}a(_t,"buildLanguageLookup");var A=class o{constructor(e,t,r){this._projectRoot=r;this._entries=e;let n=e.filter(s=>s.layer!=="built-in"||t.has(s.id));this._servers=Object.fromEntries(n.map(s=>[s.id,s.config])),this._lookup=_t(this._servers)}static{a(this,"LspServerRegistry")}_servers;_entries;_lookup;static async fromPackageDir(e,t={}){t.signal?.throwIfAborted();let r=await dt(e,"lsp-servers",c=>dr(c).servers,t);if(t.signal?.throwIfAborted(),e.startsWith("ssh://")&&(!t.executableAvailable&&!t.executableAvailability||t.requireBuiltInEvidence&&!t.recipeEvidence))throw Object.assign(new Error("Remote language server availability needs its workspace owner"),{code:"UNSUPPORTED_SOURCE"});let n=t.environment??process.env,s=r.entries.filter(c=>c.layer==="built-in"),i=[];if(t.executableAvailability){let c=await t.executableAvailability(s.map(l=>l.config));if(c.length!==s.length||c.some(l=>typeof l!="boolean"))throw new TypeError("Invalid owner executable availability report");for(let[l,m]of s.entries())i.push({id:m.id,available:c[l]===!0})}else if(t.executableAvailable)for(let c of s)i.push({id:c.id,available:await t.executableAvailable(c.config)});else i.push(...await Promise.all(s.map(async c=>({id:c.id,available:await ut(c.config,e,n,t.signal)}))));t.signal?.throwIfAborted();let d=t.requireBuiltInEvidence?t.recipeEvidence?await t.recipeEvidence(t.recipes??[]):await at(e,t.recipes??[],void 0,t.signal):void 0;return t.signal?.throwIfAborted(),new o(r.entries,new Set(i.filter(c=>c.available&&(d===void 0||(d.get(c.id)?.score??0)>0)).map(c=>c.id)),e.startsWith("ssh://")?e:_.resolve(e))}static fromConfig(e,t=process.cwd()){return new o(Object.entries(e.servers).map(([r,n])=>({id:r,config:n,layer:"project",sourcePath:"<memory>"})),new Set,t.startsWith("ssh://")?t:_.resolve(t))}resolve(e){return this.candidates(e).filter(t=>!t.config.requireRootMarker||this.hasRootMarker(e,t.config.rootMarkers))}candidates(e){let t=_.basename(e),r=_.extname(e)||(e.startsWith(".")?e:`.${e}`),n=a(i=>process.platform==="win32"?i.toLowerCase():i,"normalizeName"),s=[];for(let i of this._entries)if(this._servers[i.id]){for(let[d,c]of Object.entries(i.config.languages))if(c.extensions.some(l=>l.toLowerCase()===r.toLowerCase())||c.fileNames?.some(l=>n(l)===n(t))){s.push({serverId:i.id,config:i.config,languageId:d,layer:i.layer,sourcePath:i.sourcePath});break}}return s}async resolveOwned(e,t){if(!this._projectRoot.startsWith("ssh://"))return this.resolve(e);let r=new URL(this._projectRoot),n=decodeURIComponent(r.pathname),s=e.startsWith(".")&&!e.includes("/"),i=e.includes("://")?new URL(e):new URL(r.href),d=e.includes("://")?decodeURIComponent(i.pathname):_.posix.resolve(n,e),c=_.posix.relative(n,d);if(i.origin!==r.origin||i.host!==r.host||i.protocol!==r.protocol||i.username||i.password||i.port||i.search||i.hash||c===".."||c.startsWith("../"))throw Object.assign(new Error("Language server resource belongs to another owner"),{code:"UNSUPPORTED_SOURCE"});let l=[];for(let m of this.candidates(s?e:d)){if(!m.config.requireRootMarker){l.push(m);continue}let y=s||d===n?n:_.posix.dirname(d);for(;;){let u=!1;for(let h of m.config.rootMarkers){let f=_.posix.resolve(y,h),g=_.posix.relative(n,f);if(g===".."||g.startsWith("../"))continue;let p=new URL(r.href);if(p.pathname=f.split("/").map(encodeURIComponent).join("/"),await t(p.href)){u=!0;break}}if(u){l.push(m);break}if(y===n)break;y=_.posix.dirname(y)}}return l}hasRootMarker(e,t){let r=_.dirname(_.resolve(this._projectRoot,e));for(e.startsWith(".")&&!e.includes(_.sep)&&(r=this._projectRoot);;){let n=_.relative(this._projectRoot,r);if(n===".."||n.startsWith(`..${_.sep}`)||_.isAbsolute(n))return!1;if(t.some(s=>lr(_.join(r,s))))return!0;if(r===this._projectRoot)return!1;r=_.dirname(r)}}get projectRoot(){return this._projectRoot}get servers(){return this._servers}get entries(){return this._entries}get knownExtensions(){return new Set(this._lookup.extToLanguageId.keys())}languageId(e){let t=e.startsWith("ssh://")?decodeURIComponent(new URL(e).pathname):e;return(this._projectRoot.startsWith("ssh://")?this.candidates(t):this.resolve(t))[0]?.languageId??e.slice(1)}};function dr(o){if(typeof o!="object"||o===null||Array.isArray(o))throw new Error("LSP config must be an object");let e=o;if(e.version!==1)throw new Error("LSP config version must be 1");if(typeof e.servers!="object"||e.servers===null||Array.isArray(e.servers))throw new Error("LSP config servers must be an object");for(let[t,r]of Object.entries(e.servers)){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`LSP server ${t} must be an object`);let n=r;if(!Array.isArray(n.command)||n.command.length===0||n.command.some(s=>typeof s!="string"||s.length===0))throw new Error(`LSP server ${t}.command must be a non-empty string array`);if(n.transport!==void 0&&n.transport!=="stdio")throw new Error(`LSP server ${t} only supports stdio transport`);if(!Array.isArray(n.rootMarkers)||n.rootMarkers.some(s=>typeof s!="string"))throw new Error(`LSP server ${t}.rootMarkers must be a string array`);if(n.requireRootMarker!==void 0&&typeof n.requireRootMarker!="boolean")throw new TypeError(`LSP server ${t}.requireRootMarker must be a boolean`);if(n.requireRootMarker&&n.rootMarkers.length===0)throw new Error(`LSP server ${t}.requireRootMarker requires rootMarkers`);if(typeof n.languages!="object"||n.languages===null||Array.isArray(n.languages))throw new Error(`LSP server ${t}.languages must be an object`);for(let[s,i]of Object.entries(n.languages)){let d=typeof i=="object"&&i!==null&&!Array.isArray(i)?i.extensions:void 0;if(!Array.isArray(d)||d.length===0||d.some(l=>typeof l!="string"))throw new Error(`LSP server ${t} language ${s} requires extensions`);let c=i.fileNames;if(c!==void 0&&(!Array.isArray(c)||c.some(l=>typeof l!="string"||l.length===0||/[/\\]/u.test(l))))throw new Error(`LSP server ${t} language ${s}.fileNames must contain basenames`)}if(!Array.isArray(n.capabilities))throw new TypeError(`LSP server ${t}.capabilities must be an array`)}return o}a(dr,"parseLspConfig");var Ct={protocol:Xe,apiVersion:Qe,id:"lsp",setup(o){for(let e of H)o.addToolRecipe(e);o.addSetupCheck({id:"effective-config",inspect:pr}),o.addCheck({id:"config",title:"LSP",async run(e){try{let t=await A.fromPackageDir(e.cwd,xt(e)),r=gr(t,e.files);return r.length===0?[{status:"skip",message:"No language server matches the inspected project files"}]:await Promise.all(r.map(async n=>{let s=`${n.serverId} [${n.layer}] command ${JSON.stringify(n.config.command)}`,i=e.workspace,d=new U({serverId:n.serverId,rootUri:i?e.cwd:ur.file(e.cwd).toString(),...i&&{ownerTransport:{start:a(c=>i.start(c.command,c.env,c.signal),"start"),toServerUri:a(c=>i.toNativeUri(c),"toServerUri"),fromServerUri:a(c=>i.fromNativeUri(c),"fromServerUri")}},command:n.config.command,env:mr(e.env,n.config.env),...n.config.initializationOptions&&{initOptions:n.config.initializationOptions},...n.config.settings&&{settings:n.config.settings},...n.config.timeoutMs&&{timeoutMs:n.config.timeoutMs}});try{return await d.start(e.signal),{status:"pass",message:`${s}: initialized`,detail:n.sourcePath}}catch(c){return{status:"fail",message:`${s}: ${c instanceof Error?c.message:String(c)}`,detail:n.sourcePath}}finally{await d.shutdown()}}))}catch(t){return e.signal?.throwIfAborted(),[{status:"fail",message:t instanceof Error?t.message:String(t)}]}}})}};async function pr(o){try{let e=await A.fromPackageDir(o.cwd,xt(o)),t=[],r=new Map;for(let[n,s]of o.detectedLanguages){let i=s.flatMap(d=>e.resolve(d)).find(d=>d.languageId===n);i!==void 0&&(t.push({kind:"lsp",languageId:n,toolId:i.serverId}),await mt(o,i.config)||r.set(i.serverId,{id:`lsp-${i.serverId}-unavailable`,message:`Configured language server ${i.serverId} cannot run ${JSON.stringify(i.config.command)}`}))}return{selections:t,actions:[...r.values()]}}catch(e){return o.signal?.throwIfAborted(),{actions:[{id:"lsp-config-invalid",message:`Language server configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}a(pr,"inspectLspSetup");function xt(o){let e=o.workspace;return{...gt(o),recipeEvidence:e?t=>e.evidence(t,o.signal):void 0}}a(xt,"lspOptions");function gr(o,e){let t=new Map;for(let r of e){let n=o.resolve(r)[0];n!==void 0&&!t.has(n.serverId)&&t.set(n.serverId,n)}return[...t.values()]}a(gr,"applicableServers");function mr(o,e){return Object.fromEntries(Object.entries({...o,...e}).filter(t=>t[1]!==void 0))}a(mr,"definedEnvironment");var hr={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 W(o){return hr[o]??`SymbolKind(${o})`}a(W,"symbolKindName");async function Y(o,e,t){return await o.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}},t)??[]}a(Y,"requestDocumentSymbols");async function fe(o,e,t=100,r){return(await o.sendRequest("workspace/symbol",{query:e},r)??[]).slice(0,t)}a(fe,"requestWorkspaceSymbols");async function se(o,e,t,r){return await o.sendRequest("textDocument/rename",{textDocument:{uri:e},position:t,newName:r})}a(se,"requestRename");import ee from"node:path";import{URI as vr}from"vscode-uri";import{createHash as fr}from"node:crypto";import{readdir as yr,stat as ie}from"node:fs/promises";import M from"node:path";import{URI as we}from"vscode-uri";async function ye(o,e){if(!o.supportsCommand("typescript.tsserverRequest"))return;if((await o.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(ye,"prepareProjectQuery");function kt(o,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(([n,s])=>[n,t(s)])):r,"expand");return Object.fromEntries(Object.entries(o).map(([r,n])=>[r,t(n)]))}a(kt,"resolveInitializationOptions");var q=class o{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(!o._instance)throw new Error("[lsp] LspManager not initialized");return o._instance}static getInstanceOrNull(){return o._instance}static init(e,t){let r=o._instance;return r?._disposed?(r._registry=e,r._owner=t,r._disposed=!1,r):(o._instance=new o(e,t),o._instance)}static async resetForTest(){o._instance&&(await o._instance.shutdownAll(),o._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,n){if(n?.throwIfAborted(),this._disposed)return null;let s=t.startsWith("ssh://"),i=s?this.requireOwner():void 0,d=i?await this._registry.resolveOwned(e,g=>i.exists(g,n)):this._registry.resolve(e);if(n?.throwIfAborted(),this._disposed)return null;let c=r==="symbols"?d[0]:d.find(g=>g.config.capabilities.includes(r));if(!c)return null;let l=s?t:we.file(t).toString(),m=`${c.serverId}:${l}`,y=this._clientStarts.get(m);if(y)return y.controller.signal.aborted?(await T(y.promise.catch(()=>{}),n),this.getOrStart(e,t,r,n)):y.wait(n);let u=this._clients.get(m);if(u?.ready)return u;let h=new B(g=>this._startClient(m,l,c,u,g));this._clientStarts.set(m,h);let f=a(()=>{this._clientStarts.get(m)===h&&this._clientStarts.delete(m)},"settled");return h.promise.then(f,f),h.wait(n)}async _startClient(e,t,r,n,s){let i=n??new U({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:kt(r.config.initializationOptions,t.startsWith("ssh://")?decodeURIComponent(new URL(t).pathname):we.parse(t).fsPath)},...r.config.settings&&{settings:r.config.settings},...r.config.timeoutMs&&{timeoutMs:r.config.timeoutMs}});try{n?await n.restart(s):await i.start(s),s.throwIfAborted()}catch(d){try{await i.shutdown()}catch(c){if(c!==d)throw new AggregateError([d,c],"Language server startup and cleanup failed",{cause:c})}throw d}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(E(e,t),r)}let n=await ie(M.resolve(t,e));return r?.throwIfAborted(),n.isFile()}async getWorkspaceClients(e,t="symbols",r=e,n=()=>!0,s){if(s?.throwIfAborted(),e.startsWith("ssh://")){let y=this._owner;if(!y)throw Object.assign(new Error("No language server workspace owner"),{code:"UNSUPPORTED_SOURCE"});let u=new Set,h=new Set(this._registry.knownExtensions),f=new Set([".git",".cache","node_modules","dist","build"]),g=a(async w=>{if(s?.throwIfAborted(),h.size!==0)for(let v of await y.entries(w,s)){s?.throwIfAborted();let L=E(v.name,`${w}/`);if(v.kind==="directory")f.has(v.name)||await g(L);else if(v.kind==="file"){let b=M.posix.extname(v.name).toLowerCase();if(!h.has(b)||!n(L))continue;let x=await this.openFile(L,e,t,s);x&&(u.add(x.client),h.delete(b))}}},"visit"),p=E(r,e);if(await y.isFile(p,s)){if(!n(p))return[];let w=await this.openFile(p,e,t,s);return w?[w.client]:[]}return await g(p),[...u]}let i=new Set,d=new Set(this._registry.knownExtensions),c=new Set([".git",".cache","node_modules","dist","build"]),l=a(async y=>{if(s?.throwIfAborted(),d.size===0)return;let u;try{u=await yr(y,{withFileTypes:!0})}catch{return}for(let h of u){if(s?.throwIfAborted(),d.size===0)return;if(h.isDirectory()){c.has(h.name)||await l(M.join(y,h.name));continue}if(!h.isFile())continue;let f=M.extname(h.name).toLowerCase();if(!d.has(f))continue;let g=M.join(y,h.name);if(!n(g))continue;let p=await this.openFile(g,e,t,s);p&&(d.delete(f),p.client.hasWorkspaceSymbolCapability&&(await ye(p.client,g),i.add(p.client)))}},"visit"),m=M.resolve(e,r);if((await ie(m)).isFile()){if(!n(m))return[];let y=await this.openFile(m,e,t,s);return y===null||!y.client.hasWorkspaceSymbolCapability?[]:(await ye(y.client,m),[y.client])}return await l(m),s?.throwIfAborted(),[...i]}async prepareWorkspaceSymbols(e,t=e,r,n){return this.getWorkspaceClients(e,"symbols",t,r,n)}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 n=r.toUri(e);if(r.documentContent(n)===void 0)continue;let s=this.languageId(M.extname(decodeURIComponent(new URL(n).pathname)));r.syncDocument(n,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"),n=r(await ie(e)),s=await this.readSourceText(e,t);if(n!==r(await ie(e)))throw new Error("A rename source changed while reading it. No edits applied.");return{content:s,version:fr("sha256").update(n).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",n){if(n?.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?E(e,t):M.resolve(t,e),d=await this.getOrStart(i,t,r,n);if(!d)return null;let c=d.toUri(i),l=s?this.requireOwner():void 0,y=(l?await this._registry.resolveOwned(i,u=>l.exists(u,n)):this._registry.resolve(i))[0]?.languageId??"plaintext";if(l){let u=await l.readText(c,n);return n?.throwIfAborted(),d.syncDocument(c,u,y),this._openDocs.add(c),{client:d,uri:c,languageId:y}}try{let{readFile:u}=await import("node:fs/promises"),h=await u(i,{encoding:"utf8",signal:n});n?.throwIfAborted(),d.syncDocument(c,h,y),this._openDocs.add(c)}catch(u){if(n?.throwIfAborted(),!(u instanceof Error&&"code"in u&&u.code==="ENOENT"))throw u}return{client:d,uri:c,languageId:y}}_subscribeToPushDiagnostics(e,t){if(this._pushUnsubscribers.has(e))return;let r=t.onNotification("textDocument/publishDiagnostics",n=>{let s=wr(n);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 d=`${e}:${s.uri}`,c=s.diagnostics.map(me),l=JSON.stringify([s.version,i,c]);if(this._pushFingerprints.get(d)===l)return;this._pushFingerprints.set(d,l);let m={cwd:t.rootUri.startsWith("ssh://")?t.rootUri:we.parse(t.rootUri).fsPath,serverId:t.serverId,uri:s.uri,diagnostics:c,...s.version!==void 0&&{version:s.version}};for(let y of this._pushHandlers)y(m)});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,d]of t.entries())d.status==="rejected"&&d.reason!==e[i]?.controller.signal.reason&&r.push(d.reason);let n=[...this._clients.values()],s=await Promise.allSettled(n.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 wr(o){if(o===null||typeof o!="object")return;let e=o;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}a(wr,"parsePushNotification");async function ve(o,e,t){if(t?.throwIfAborted(),!o.supportsCommand("typescript.tsserverRequest"))return;let r=await o.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:o.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(ve,"loadQueryProject");async function Z(o,e,t,r){return await ve(o,e,r),await o.sendRequest("textDocument/references",{textDocument:{uri:e},position:t,context:{includeDeclaration:!0}},r)??[]}a(Z,"requestReferences");async function be(o,e,t,r){let n=await o.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:t},r),s=n?.[0];if(!s)return{items:[],incoming:[],outgoing:[]};let[i,d]=await Promise.all([o.sendRequest("callHierarchy/incomingCalls",{item:s},r),o.sendRequest("callHierarchy/outgoingCalls",{item:s},r)]);return{items:n,incoming:i??[],outgoing:d??[]}}a(be,"requestCallHierarchy");function J(o,e,t){let r=e.startsWith("ssh://"),n=r?ee.posix:ee,s=a(m=>r?decodeURIComponent(new URL(E(m,e)).pathname):m,"native"),i=r?s(t.path??e):ee.resolve(e,t.path??"."),d=n.relative(i,s(o));if(d===".."||d.startsWith(`..${n.sep}`)||n.isAbsolute(d))return!1;let c=n.relative(s(e),s(o)).split(n.sep).join("/"),l=a(m=>et(m).some(y=>n.matchesGlob(y.includes("/")?c:n.basename(s(o)),y)),"matches");return(t.include===void 0||l(t.include))&&(t.exclude===void 0||!l(t.exclude))}a(J,"withinScope");function Se(o,e){let t=E(o,e);if(t.startsWith("ssh://"))return t;let r=vr.parse(t);if(r.scheme!=="file")throw new Error("Unsupported LSP source location.");return ee.resolve(r.fsPath)}a(Se,"sourceOf");function br(o,e){return o.start.line===e.start.line&&o.start.character===e.start.character&&o.end.line===e.end.line&&o.end.character===e.end.character}a(br,"sameRange");function Et(o,e,t){return o.flatMap(r=>[...r.name===e&&r.range!==void 0&&br(r.range,t)&&r.selectionRange!==void 0?[r.selectionRange]:[],...Et(r.children??[],e,t)])}a(Et,"declarationNames");async function Le(o,e,t,r,n={},s=q.getInstance()){r?.throwIfAborted();let i=n.resultScope;if(i!==void 0&&(await z(i,r),i.targets.length===0))return{hits:[],complete:i.complete};if(i===void 0&&n.path!==void 0&&!J(e.startsWith("ssh://")?E(n.path,e):ee.resolve(e,n.path),e,n)&&await s.isSourceFile(n.path,e,r))return{hits:[],complete:!0};let d=i?.targets.map(f=>f.source)??[n.path??e],c=new Set((await Promise.all(d.map(f=>s.prepareWorkspaceSymbols(e,f,g=>J(g,e,n),r)))).flat());if(c.size===0)throw new Error("LSP symbol search is unavailable: no provider supports workspace/symbol in this scope.");let l=new Map,m=a(async f=>{r?.throwIfAborted();let g=Se(f.uri,e),p=l.get(g);if(p===void 0){let{content:R,version:F}=await s.readSourceSnapshot(g,r);p={document:Ne(g,R),version:F},l.set(g,p)}let{document:w}=p,{start:v,end:L}=f.range,b=[v,L];for(let R of b){let F=w.lines[R.line];if(!Number.isInteger(R.line)||!Number.isInteger(R.character)||F===void 0||R.character<0||R.character>F.content.length)throw new Error("LSP range does not match its source snapshot.")}let x=k(w.lines[v.line]),D=a(R=>w.lines.slice(0,R).reduce((F,De)=>F+De.content.length+De.lineEnding.length,0),"offset"),j=D(v.line)+v.character,P=D(L.line)+L.character;if(P<j)throw new Error("LSP returned a reversed source range.");return{source:g,lineNumber:v.line+1,endLineNumber:L.line+1,startColumn:v.character,endColumn:L.character,matchedText:w.content.slice(j,P),lineText:x.content}},"toMatch"),y=a(f=>J(f.source,e,n)&&(i===void 0||Ze(i,f)),"included"),u=[],h=new Set;for(let f of c){r?.throwIfAborted();let g=await fe(f,o,Number.MAX_SAFE_INTEGER,r);for(let p of g){if(r?.throwIfAborted(),!J(Se(p.location.uri,e),e,{}))continue;let w=await m(p.location),v=await s.openFile(w.source,e,"symbols",r);if(v===null)throw new Error("LSP references are unavailable for a discovered declaration.");let L=p.location;if(w.matchedText!==p.name){let P=await Y(v.client,v.uri,r),R=Et(P,p.name,p.location.range);if(R.length!==1)throw new Error("LSP declaration has no unique provider selectionRange; cannot search its references.");L={uri:v.uri,range:k(R[0])}}let b=await m(L),x={id:JSON.stringify([f.serverId,b.source,p.location.range]),name:p.name,kind:String(p.kind),source:b.source,range:{startLine:b.lineNumber,startColumn:b.startColumn,endLine:b.endLineNumber??b.lineNumber,endColumn:b.endColumn}},D=await Z(v.client,v.uri,L.range.start,r);r?.throwIfAborted();let j=[{...b,role:"definition",symbol:x}];for(let P of D){if(!J(Se(P.uri,e),e,{}))continue;let R=await m(P);R.source===b.source&&R.lineNumber===b.lineNumber&&R.startColumn===b.startColumn&&R.endLineNumber===b.endLineNumber&&R.endColumn===b.endColumn||j.push({...R,role:"reference",symbol:x})}if(!(n.navigation==="references"&&!j.some(y)))for(let P of j){if(n.navigation!=="references"&&!y(P)||n.navigation==="references"&&!J(P.source,e,{}))continue;let R=JSON.stringify([x.id,P.source,P.lineNumber,P.startColumn,P.endLineNumber,P.endColumn]);h.has(R)||(h.add(R),u.push(P))}}}r?.throwIfAborted();for(let[f,g]of l){let p=await s.readSourceSnapshot(f,r);if(p.version!==g.version||p.content!==g.document.content)throw new Error("LSP source changed during search.")}return i!==void 0&&await z(i,r),u.sort((f,g)=>f.source.localeCompare(g.source)||f.lineNumber-g.lineNumber||f.startColumn-g.startColumn||f.endColumn-g.endColumn||f.symbol.id.localeCompare(g.symbol.id)),{hits:u.slice(0,t),complete:(i?.complete??!0)&&u.length<=t}}a(Le,"searchSymbols");import Re from"node:path";import{fileURLToPath as Sr}from"node:url";var Pe=10,_e=5,K=10;async function ce(o,e,t,r,n){$(n);let s=await o.readSourceText(e,n),i=await de(o,e,r,n),d=le(i.symbols,t,i.displayPath),c=await o.readSourceText(i.filePath,n);if($(n),s!==c)throw new Error("The symbol source changed during resolution. Read it again before editing.");return{source:i.filePath,range:d.range,content:c}}a(ce,"resolveLspDeclaration");async function Dt(o,e,t,r,n){$(n);let s=await o.readSourceText(e,n),i=await de(o,e,r,n),d=le(i.symbols,t,i.displayPath);if(s!==await o.readSourceText(e,n))throw new Error("The rename source changed during resolution.");return $(n),{client:i.client,uri:i.uri,position:d.selectionRange.start,content:s}}a(Dt,"resolveLspRenameTarget");async function ke(o,e,t,r,n){$(n);let s=await de(o,e,r,n),i=le(s.symbols,t,s.displayPath),d=await Ot(s,i,n),c=new ae(r);return await Lr(s,i,d,c)}a(ke,"readLspSymbolGraph");async function Ee(o,e,t,r){$(r);let n=await de(o,e,t,r),s=new ae(t),i=[`## file graph: ${n.displayPath}`,`Top-level declarations: ${n.symbols.length}`];for(let d of n.symbols){$(r);let c=await Ot(n,d,r);i.push("",...await Cr(n,d,c,s))}return i.join(`
1
+ import{a as gt,c as mt}from"./chunk-B25LXXNV.js";import{b as ct,c as lt,g as dt,j as ut,p as pt}from"./chunk-7D7PXIVV.js";import{a as at}from"./chunk-BXGMMZT3.js";import{f as ze,g as Ve}from"./chunk-XH5WN5XA.js";import{a as pe,b as Ze,c as et}from"./chunk-FYOU4RBH.js";import{b as Be,c as Je,d as ue}from"./chunk-7PVDTMEM.js";import{a as Ke}from"./chunk-47SPPIXK.js";import{a as He,b as Ge}from"./chunk-VAXLSPPU.js";import{a as Ye}from"./chunk-MDD5ORB6.js";import{b as Xe,c as Qe}from"./chunk-MLFJU2US.js";import{a as te,e as Fe}from"./chunk-PS2B6THP.js";import{a as tt}from"./chunk-GXL4NMHR.js";import{c as Ue,d as We,f as qe}from"./chunk-PQWANILR.js";import{a as $e}from"./chunk-BU7IZLKB.js";import{a as Oe,b as Me}from"./chunk-S5PL5DFQ.js";import{K as Te,M as z,m as Ae,n as je}from"./chunk-DDH3FP4G.js";import{h as nt}from"./chunk-35LZOKEW.js";import{a as N,b as I,c as rt,d as V}from"./chunk-T4FTT3U4.js";import{m as Ne}from"./chunk-VDJSH3DQ.js";import{a as k}from"./chunk-ZC65Z3CK.js";import{a as it}from"./chunk-ZAWRSA7N.js";import{a as ot,b as st}from"./chunk-OFILFO6D.js";import{a}from"./chunk-EI7MMDWY.js";import Or from"node:path";var H=[{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"]}]}}},S("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}}),S("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"]}}},S("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"]),S("dart-language-server",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],{dart:[".dart"]},["dart","language-server","--protocol=lsp"],"https://dart.dev/tools/dart-language-server"),S("r-language-server",["r"],["Rscript"],["DESCRIPTION",".lintr",".Rprofile"],{r:[".r"]},["Rscript","-e","languageserver::run()"],"https://github.com/REditorSupport/languageserver"),S("zls",["zig"],["zls"],["build.zig","build.zig.zon","zls.json"],{zig:[".zig",".zon"]},["zls"],"https://zigtools.org/zls/"),S("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/"),S("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"]),S("basedpyright",["python"],["basedpyright-langserver","pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),S("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),S("rust-analyzer",["rust"],["rust-analyzer"],["Cargo.toml","rust-project.json"],{rust:[".rs"]},["rust-analyzer"],"https://rust-analyzer.github.io/"),S("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),S("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),S("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"),S("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),S("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),S("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),S("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),S("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),S("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:{}}),S("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"),S("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"),S("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),S("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),S("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),S("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"),S("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"),S("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"),S("neocmakelsp",["cmake"],["neocmakelsp"],["CMakeLists.txt",".neocmake.toml",".neocmakelint.toml"],{cmake:[".cmake"]},["neocmakelsp","stdio"],"https://github.com/neocmakelsp/neocmakelsp",void 0,{cmake:["CMakeLists.txt"]}),S("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"),S("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),S("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),S("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 S(o,e,t,r,n,s,i,d,c,l){return{id:o,name:o,kind:"lsp",languages:e,executables:t,configFiles:r,documentation:i,...d&&{dependencies:d},lsp:{command:s,rootMarkers:r,languageIds:n,...c&&{fileNames:c},...l&&{settings:l}}}}a(S,"recipe");import{readFile as ft}from"node:fs/promises";import{URI as yt}from"vscode-uri";var X={Error:1,Warning:2,Information:3,Hint:4};var ht={command:"typescript.tsserverRequest",async request(o,e,t){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async n=>{let s=await o.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[n,{file:o.serverDocumentPath(e),includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},t);if(!ge(s)||s.success!==!0||!Array.isArray(s.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${n}`);return s.body.map(Gt)}))).flat()}};function re(o){return o.supportsCommand(ht.command)?ht:void 0}a(re,"completedDiagnosticAdapter");function Gt(o){if(!ge(o)||typeof o.message!="string"||typeof o.code!="number"&&typeof o.code!="string"||!ge(o.startLocation)||!Number.isInteger(o.startLocation.line)||!Number.isInteger(o.startLocation.offset)||Number(o.startLocation.line)<1||Number(o.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(o.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(o.code),message:o.message,line:Number(o.startLocation.line),column:Number(o.startLocation.offset),severity:o.category==="error"?"error":o.category==="warning"?"warning":o.category==="suggestion"?"hint":"info"}}a(Gt,"convertTypeScriptDiagnostic");function ge(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)}a(ge,"isRecord");async function Q(o,e,t,r={}){let n=new AbortController,s=AbortSignal.any([n.signal,...r.signal?[r.signal]:[]]),i=setTimeout(()=>n.abort(new Error(`[lsp] ${o.serverId}: diagnostics timed out for ${e}`)),o.timeoutMs);try{return await Bt(o,e,t,r.content,s)}finally{clearTimeout(i)}}a(Q,"requestDiagnostics");async function Bt(o,e,t,r,n){if(n.throwIfAborted(),o.diagnosticMode!=="push"){let c=o.documentVersion(e);try{let l=await o.sendRequest("textDocument/diagnostic",{textDocument:{uri:e}},n);if(l.kind!=="full"||!Array.isArray(l.items))throw new Error("Invalid full diagnostic report");if(o.documentVersion(e)!==c)throw new Error("Document changed during diagnostic request");return o.setDiagnosticMode("pull"),wt(l.items,!1,!0)}catch(l){if(!Jt(l))throw l;o.setDiagnosticMode("push")}}let s=re(o);if(s){o.documentVersion(e)===void 0&&o.syncDocument(e,r??await ft(yt.parse(e).fsPath,"utf8"),t??"plaintext");let c=o.documentVersion(e),l=await s.request(o,e,n);if(n.throwIfAborted(),o.documentVersion(e)!==c)throw new Error("Document changed during diagnostic request");return{diagnostics:l,syntaxErrors:[],otherDiagnostics:l,unversioned:!1,complete:!0}}n.throwIfAborted();let i=o.documentVersion(e)!==void 0,d=i?void 0:r??await ft(yt.parse(e).fsPath,"utf8");n.throwIfAborted(),o.beginDiagnosticRequest(e);try{return await new Promise((c,l)=>{let m=o.documentVersion(e)??1,y=a(g=>{let p=g;p.uri!==e||!Array.isArray(p.diagnostics)||p.version!==void 0&&p.version!==m||o.documentVersion(e)===m&&(f(),c(wt(p.diagnostics,p.version===void 0)))},"receive"),u=o.onNotification("textDocument/publishDiagnostics",y),h=a(()=>{f(),l(n.reason)},"onAbort");function f(){u(),n.removeEventListener("abort",h)}a(f,"cleanup"),n.addEventListener("abort",h,{once:!0});try{i||o.syncDocument(e,d??"",t??"plaintext");let g=o.diagnosticPublication(e);g&&y({uri:e,...g})}catch(g){f(),l(g)}})}finally{o.endDiagnosticRequest(e)}}a(Bt,"requestCurrentDiagnostics");function me(o){return{code:String(o.code??"LSP"),message:o.message,line:o.range.start.line+1,column:o.range.start.character+1,severity:o.severity===X.Warning?"warning":o.severity===X.Information?"info":o.severity===X.Hint?"hint":"error"}}a(me,"toDiagnostic");function wt(o,e,t=!1){let r=o.map(me);return{diagnostics:r,syntaxErrors:[],otherDiagnostics:r,unversioned:e,complete:t}}a(wt,"classify");function Jt(o){return o!==null&&typeof o=="object"&&"code"in o&&o.code===-32601}a(Jt,"isMethodNotFound");function bt(o,e=(t,r)=>Promise.resolve({cwd:r,external:!1})){return{id:"lsp",async diagnose(t,r){let n=await e(t,r.cwd,r.signal);if(n===void 0)return{status:"unavailable",diagnostics:[],reason:"No local language-server project found for this file"};let s=await o(n.cwd,n.external,r.signal);r.signal.throwIfAborted();let i=await s.getOrStart(t,n.cwd,"diagnostics",r.signal);if(r.signal.throwIfAborted(),!i)return{status:"unavailable",diagnostics:[],reason:"No language server configured for this file"};let d=i.toUri(t),c=s.languageId(t);i.syncDocument(d,r.content,c,!0);let l=i.documentVersion(d),m={active:!0,queued:!1},y=a(()=>!r.signal.aborted&&i.documentVersion(d)===l,"current"),u=a(()=>Q(i,d,c,{signal:r.signal,content:r.content}),"request"),h=a(async()=>{if(m.queued=!0,!m.active){m.active=!0;try{for(;m.queued&&y();){m.queued=!1;let g=await u();y()&&r.publish(vt(g,i.commandName))}}catch(g){y()&&r.publish({status:"unavailable",diagnostics:[],reason:g instanceof Error?g.message:String(g),source:i.commandName})}finally{m.active=!1}}},"refresh"),f=s.onPushDiagnostics(g=>{!y()||g.uri!==d||g.serverId!==i.serverId||g.cwd!==n.cwd||g.version!==void 0&&g.version!==l||(i.diagnosticMode==="pull"||re(i)?h():r.publish({status:"snapshot",diagnostics:g.diagnostics,source:i.commandName,reason:St(g.version===void 0)}))});r.signal.addEventListener("abort",f,{once:!0});try{let g=await u();return l=i.documentVersion(d),vt(g,i.commandName)}catch(g){throw m.queued=!1,f(),r.signal.removeEventListener("abort",f),g}finally{m.active=!1,m.queued&&y()&&queueMicrotask(()=>{h()})}}}}a(bt,"createLspDiagnosticSource");function St(o){return`Latest push snapshot; completion is unknown${o?"; language server omitted the document version":""}`}a(St,"snapshotReason");function vt(o,e){return o.complete?{status:"ready",diagnostics:o.diagnostics,source:e}:{status:"snapshot",diagnostics:o.diagnostics,reason:St(o.unversioned),source:e}}a(vt,"toReport");import{URI as ur}from"vscode-uri";import nr from"node:path";import or from"cross-spawn";import{createMessageConnection as sr,CancellationTokenSource as ir,StreamMessageReader as ar}from"vscode-jsonrpc/node";import{URI as Rt}from"vscode-uri";import{watch as Kt}from"node:fs";import{readdir as Xt,stat as Qt}from"node:fs/promises";import G from"node:path";import{URI as he}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 n of t){let s=n.globPattern,i=typeof s=="string"?this.root:he.parse(typeof s.baseUri=="string"?s.baseUri:s.baseUri.uri).fsPath,d=typeof s=="string"?s:s.pattern,c=a(y=>G.matchesGlob(G.isAbsolute(d)?G.join(i,y):y,d),"matches"),l=new Set((await Xt(i,{recursive:!0})).filter(c));if(this.disposed)throw new Error("Language server file watchers are disposed");let m=Kt(i,{recursive:!0},(y,u)=>{!u||!c(u)||Qt(G.join(i,u)).then(()=>{if(!this.registrations.get(e)?.includes(m))return;let h=l.has(u)?2:1;l.add(u),(n.kind??7)&(h===1?1:2)&&this.changed({uri:he.file(G.join(i,u)).toString(),type:h})},h=>{if(this.registrations.get(e)?.includes(m)){if(h.code!=="ENOENT"){this.failed(h);return}l.delete(u)&&(n.kind??7)&4&&this.changed({uri:he.file(G.join(i,u)).toString(),type:3})}})});m.on("error",this.failed),r.push(m)}}catch(n){for(let s of r)s.close();throw n}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 Yt}from"vscode-jsonrpc/node";var oe=class extends Yt{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 er}from"vscode-uri";function E(o,e){if(e.startsWith("ssh://")){let t=Lt(e);if(o.includes("://")){let n=Lt(o);if(n.host!==t.host)throw new Error("Document belongs to another language server owner");return n.href}let r=Zt.posix.resolve(decodeURIComponent(t.pathname),o);return t.pathname=r.split("/").map(encodeURIComponent).join("/"),t.href}if(o.startsWith("ssh://")||o.includes("://")&&!o.startsWith("file://"))throw new Error("Document belongs to another language server owner");return o.startsWith("file://")?o:er.file(o).toString()}a(E,"documentUri");function Lt(o){let e=new URL(o);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(Lt,"checkedRemote");async function T(o,e){if(e?.aborted)throw o.catch(()=>{}),e.reason;if(!e)return o;let t;try{return await Promise.race([o,new Promise((r,n)=>{t=a(()=>n(e.reason),"onAbort"),e.addEventListener("abort",t,{once:!0})})])}finally{t&&e.removeEventListener("abort",t)}}a(T,"waitWithSignal");var B=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 T(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 tr=new Set(["uri","targetUri","target","oldUri","newUri","rootUri","documentUri","scopeUri","baseUri"]),rr=new Set(["changes","relatedDocuments"]);function O(o,e){return Array.isArray(o)?o.map(t=>O(t,e)):typeof o!="object"||o===null?o:Object.fromEntries(Object.entries(o).map(([t,r])=>tr.has(t)&&typeof r=="string"?[t,e(r)]:rr.has(t)&&typeof r=="object"&&r!==null&&!Array.isArray(r)?[t,Object.fromEntries(Object.entries(r).map(([n,s])=>[e(n),O(s,e)]))]:[t,O(r,e)]))}a(O,"mapLspUris");var U=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 ct(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=k(this._command[0]),r=this._ownerTransport?decodeURIComponent(new URL(this.rootUri).pathname):Rt.parse(this.rootUri).fsPath,n=[{uri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,name:nr.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:or(t,this._args,{stdio:["pipe","pipe","pipe"],...e&&{signal:e},cwd:r,env:pt({command:this._command,env:this._env},r,process.env)});this._process=i??null;let d=i?cr(i):Promise.resolve(),c=k(s?.stdin??i?.stdin),l=k(s?.stdout??i?.stdout),m=k(s?.stderr??i?.stderr);c.on("error",()=>{}),l.on("error",()=>{}),m.on("error",()=>{}),this._stderr="",m.setEncoding("utf8"),m.on("data",p=>{this._stderr=(this._stderr+p).slice(-4096)}),i?.on("error",p=>{("code"in p?p.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,p),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null});let y=a(p=>{(s?this._ownedProcess!==s:this._process!==i)||(this._closeFileWatchers(),!this._disposed&&p!==0&&p!==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",y),s?.completion.then(({exitCode:p})=>y(p),()=>{this._ownedProcess===s&&(this._crashed=!0,y(null))}),await T(d,e);let u=sr(new ar(l),new oe(c,p=>{this._connection!==u||this._disposed||(this._crashed=!0,this._initialized=!1,this._closeFileWatchers(),u.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,p))}));this._connection=u,this._connection.onError(p=>{console.error(`[lsp] ${this.serverId}: connection error:`,p)});let h=a(p=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[p]})},"changed"),f=a(p=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,p),"failed");this._fileWatchers=this._ownerTransport?this._ownerTransport.fileWatchers?.(this.rootUri,h,f):new ne(r,h,f),this._connection.onRequest("client/registerCapability",async p=>{for(let w of p.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 p=>{for(let w of p.unregisterations)await this._fileWatchers?.unregister(w.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/configuration",p=>p.items.map(w=>{let v=this._settings??null;for(let L of w.section?.split(".").filter(Boolean)??[])v=typeof v=="object"&&v!==null?v[L]??null:null;return v})),this._connection.listen(),this._connection.onNotification((p,...w)=>{let v=this._ownerTransport,L=v?O(w[0],b=>v.fromServerUri(b)):w[0];if(p==="textDocument/publishDiagnostics"){let b=L;b&&typeof b.uri=="string"&&Array.isArray(b.diagnostics)&&this._documentVersions.has(b.uri)&&(b.version===void 0||b.version===this.documentVersion(b.uri))&&this._diagnosticPublications.set(b.uri,{diagnostics:b.diagnostics,...typeof b.version=="number"&&{version:b.version}})}for(let b of this._handlers.get(p)??[])b(L)}),this._connection.onRequest("workspace/workspaceFolders",()=>n);let g=await T(Pt(this._connection.sendRequest("initialize",{processId:this._ownerTransport?null:process.pid,rootUri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,workspaceFolders:n,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(p=>{let w=this._stderr.trim();throw w?new Error(`[lsp] ${this.serverId}: ${w}`,{cause:p}):p});if(await this._connection.sendNotification("initialized",{capabilities:g.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=g.capabilities,this._diagnosticMode=g.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 n=this._ownerTransport,s=n?O(t,l=>n.toServerUri(l)):t,i=a(l=>n?O(l,m=>n.fromServerUri(m)):l,"mapResult");if(!r)return i(await k(this._connection).sendRequest(e,s));let d=new ir,c;try{let l=k(this._connection).sendRequest(e,s,d.token);return i(await Promise.race([l,new Promise((m,y)=>{c=a(()=>{d.cancel(),y(r.reason)},"onAbort"),r.addEventListener("abort",c,{once:!0})})]))}finally{c&&r.removeEventListener("abort",c),d.dispose()}}sendNotification(e,t){this._assertReady(),this._sendNotification(e,t)}_sendNotification(e,t){let r=this._connection;if(!r)return;let n=this._ownerTransport,s=n?O(t,i=>n.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 n=r.indexOf(t);n!==-1&&r.splice(n,1)}}toUri(e){return E(e,this.rootUri)}serverDocumentPath(e){let t=this.toUri(e),r=this._ownerTransport?.toServerUri(t)??t;return this._ownerTransport?decodeURIComponent(new URL(r).pathname):Rt.parse(r).fsPath}openDocument(e,t,r,n=1){let s=this._documentVersions.get(e);if(s!==void 0){this.changeDocument(e,t,Math.max(n,s+1));return}this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:r,version:n,text:t}}),this._documentVersions.set(e,n),this._documentContents.set(e,t)}syncDocument(e,t,r,n=!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,d=typeof i=="object"&&i!==null?i.save:void 0;n&&d&&this.sendNotification("textDocument/didSave",{textDocument:{uri:e},...typeof d=="object"&&d.includeText&&{text:t}})}changeDocument(e,t,r){let n=this._documentVersions.get(e),s=Math.max(r,(n??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 Pt(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()),n=this._process;this._process=null,n&&!n.killed&&(n.kill("SIGTERM"),setTimeout(()=>{n.exitCode===null&&n.signalCode===null&&n.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 d of s)d.status==="rejected"&&i.push(d.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 cr(o){return new Promise((e,t)=>{let r=a(()=>{o.off("spawn",n),o.off("error",s)},"cleanup"),n=a(()=>{r(),e()},"onSpawn"),s=a(i=>{r(),t(i)},"onError");o.once("spawn",n),o.once("error",s)})}a(cr,"waitForSpawn");function Pt(o,e,t){return new Promise((r,n)=>{let s=setTimeout(()=>{n(new Error(t))},e);o.then(i=>{clearTimeout(s),r(i)}).catch(i=>{clearTimeout(s),n(i instanceof Error?i:new Error(String(i)))})})}a(Pt,"withTimeout");import _ from"node:path";import{existsSync as lr}from"node:fs";function _t(o){let e=new Map,t=new Map;for(let[r,n]of Object.entries(o))for(let[s,i]of Object.entries(n.languages))for(let d of i.extensions){let c=d.toLowerCase(),l=e.get(c);if(l!==void 0&&l!==s)throw new Error(`[lsp] extension conflict: "${c}" claimed by "${l}" and "${s}"`);e.set(c,s);let m=t.get(c)??[];m.push(r),t.set(c,m)}return{extToLanguageId:e,extToServerIds:t}}a(_t,"buildLanguageLookup");var A=class o{constructor(e,t,r){this._projectRoot=r;this._entries=e;let n=e.filter(s=>s.layer!=="built-in"||t.has(s.id));this._servers=Object.fromEntries(n.map(s=>[s.id,s.config])),this._lookup=_t(this._servers)}static{a(this,"LspServerRegistry")}_servers;_entries;_lookup;static async fromPackageDir(e,t={}){t.signal?.throwIfAborted();let r=await dt(e,"lsp-servers",c=>dr(c).servers,t);if(t.signal?.throwIfAborted(),e.startsWith("ssh://")&&(!t.executableAvailable&&!t.executableAvailability||t.requireBuiltInEvidence&&!t.recipeEvidence))throw Object.assign(new Error("Remote language server availability needs its workspace owner"),{code:"UNSUPPORTED_SOURCE"});let n=t.environment??process.env,s=r.entries.filter(c=>c.layer==="built-in"),i=[];if(t.executableAvailability){let c=await t.executableAvailability(s.map(l=>l.config));if(c.length!==s.length||c.some(l=>typeof l!="boolean"))throw new TypeError("Invalid owner executable availability report");for(let[l,m]of s.entries())i.push({id:m.id,available:c[l]===!0})}else if(t.executableAvailable)for(let c of s)i.push({id:c.id,available:await t.executableAvailable(c.config)});else i.push(...await Promise.all(s.map(async c=>({id:c.id,available:await ut(c.config,e,n,t.signal)}))));t.signal?.throwIfAborted();let d=t.requireBuiltInEvidence?t.recipeEvidence?await t.recipeEvidence(t.recipes??[]):await at(e,t.recipes??[],void 0,t.signal):void 0;return t.signal?.throwIfAborted(),new o(r.entries,new Set(i.filter(c=>c.available&&(d===void 0||(d.get(c.id)?.score??0)>0)).map(c=>c.id)),e.startsWith("ssh://")?e:_.resolve(e))}static fromConfig(e,t=process.cwd()){return new o(Object.entries(e.servers).map(([r,n])=>({id:r,config:n,layer:"project",sourcePath:"<memory>"})),new Set,t.startsWith("ssh://")?t:_.resolve(t))}resolve(e){return this.candidates(e).filter(t=>!t.config.requireRootMarker||this.hasRootMarker(e,t.config.rootMarkers))}candidates(e){let t=_.basename(e),r=_.extname(e)||(e.startsWith(".")?e:`.${e}`),n=a(i=>process.platform==="win32"?i.toLowerCase():i,"normalizeName"),s=[];for(let i of this._entries)if(this._servers[i.id]){for(let[d,c]of Object.entries(i.config.languages))if(c.extensions.some(l=>l.toLowerCase()===r.toLowerCase())||c.fileNames?.some(l=>n(l)===n(t))){s.push({serverId:i.id,config:i.config,languageId:d,layer:i.layer,sourcePath:i.sourcePath});break}}return s}async resolveOwned(e,t){if(!this._projectRoot.startsWith("ssh://"))return this.resolve(e);let r=new URL(this._projectRoot),n=decodeURIComponent(r.pathname),s=e.startsWith(".")&&!e.includes("/"),i=e.includes("://")?new URL(e):new URL(r.href),d=e.includes("://")?decodeURIComponent(i.pathname):_.posix.resolve(n,e),c=_.posix.relative(n,d);if(i.origin!==r.origin||i.host!==r.host||i.protocol!==r.protocol||i.username||i.password||i.port||i.search||i.hash||c===".."||c.startsWith("../"))throw Object.assign(new Error("Language server resource belongs to another owner"),{code:"UNSUPPORTED_SOURCE"});let l=[];for(let m of this.candidates(s?e:d)){if(!m.config.requireRootMarker){l.push(m);continue}let y=s||d===n?n:_.posix.dirname(d);for(;;){let u=!1;for(let h of m.config.rootMarkers){let f=_.posix.resolve(y,h),g=_.posix.relative(n,f);if(g===".."||g.startsWith("../"))continue;let p=new URL(r.href);if(p.pathname=f.split("/").map(encodeURIComponent).join("/"),await t(p.href)){u=!0;break}}if(u){l.push(m);break}if(y===n)break;y=_.posix.dirname(y)}}return l}hasRootMarker(e,t){let r=_.dirname(_.resolve(this._projectRoot,e));for(e.startsWith(".")&&!e.includes(_.sep)&&(r=this._projectRoot);;){let n=_.relative(this._projectRoot,r);if(n===".."||n.startsWith(`..${_.sep}`)||_.isAbsolute(n))return!1;if(t.some(s=>lr(_.join(r,s))))return!0;if(r===this._projectRoot)return!1;r=_.dirname(r)}}get projectRoot(){return this._projectRoot}get servers(){return this._servers}get entries(){return this._entries}get knownExtensions(){return new Set(this._lookup.extToLanguageId.keys())}languageId(e){let t=e.startsWith("ssh://")?decodeURIComponent(new URL(e).pathname):e;return(this._projectRoot.startsWith("ssh://")?this.candidates(t):this.resolve(t))[0]?.languageId??e.slice(1)}};function dr(o){if(typeof o!="object"||o===null||Array.isArray(o))throw new Error("LSP config must be an object");let e=o;if(e.version!==1)throw new Error("LSP config version must be 1");if(typeof e.servers!="object"||e.servers===null||Array.isArray(e.servers))throw new Error("LSP config servers must be an object");for(let[t,r]of Object.entries(e.servers)){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`LSP server ${t} must be an object`);let n=r;if(!Array.isArray(n.command)||n.command.length===0||n.command.some(s=>typeof s!="string"||s.length===0))throw new Error(`LSP server ${t}.command must be a non-empty string array`);if(n.transport!==void 0&&n.transport!=="stdio")throw new Error(`LSP server ${t} only supports stdio transport`);if(!Array.isArray(n.rootMarkers)||n.rootMarkers.some(s=>typeof s!="string"))throw new Error(`LSP server ${t}.rootMarkers must be a string array`);if(n.requireRootMarker!==void 0&&typeof n.requireRootMarker!="boolean")throw new TypeError(`LSP server ${t}.requireRootMarker must be a boolean`);if(n.requireRootMarker&&n.rootMarkers.length===0)throw new Error(`LSP server ${t}.requireRootMarker requires rootMarkers`);if(typeof n.languages!="object"||n.languages===null||Array.isArray(n.languages))throw new Error(`LSP server ${t}.languages must be an object`);for(let[s,i]of Object.entries(n.languages)){let d=typeof i=="object"&&i!==null&&!Array.isArray(i)?i.extensions:void 0;if(!Array.isArray(d)||d.length===0||d.some(l=>typeof l!="string"))throw new Error(`LSP server ${t} language ${s} requires extensions`);let c=i.fileNames;if(c!==void 0&&(!Array.isArray(c)||c.some(l=>typeof l!="string"||l.length===0||/[/\\]/u.test(l))))throw new Error(`LSP server ${t} language ${s}.fileNames must contain basenames`)}if(!Array.isArray(n.capabilities))throw new TypeError(`LSP server ${t}.capabilities must be an array`)}return o}a(dr,"parseLspConfig");var Ct={protocol:Xe,apiVersion:Qe,id:"lsp",setup(o){for(let e of H)o.addToolRecipe(e);o.addSetupCheck({id:"effective-config",inspect:pr}),o.addCheck({id:"config",title:"LSP",async run(e){try{let t=await A.fromPackageDir(e.cwd,xt(e)),r=gr(t,e.files);return r.length===0?[{status:"skip",message:"No language server matches the inspected project files"}]:await Promise.all(r.map(async n=>{let s=`${n.serverId} [${n.layer}] command ${JSON.stringify(n.config.command)}`,i=e.workspace,d=new U({serverId:n.serverId,rootUri:i?e.cwd:ur.file(e.cwd).toString(),...i&&{ownerTransport:{start:a(c=>i.start(c.command,c.env,c.signal),"start"),toServerUri:a(c=>i.toNativeUri(c),"toServerUri"),fromServerUri:a(c=>i.fromNativeUri(c),"fromServerUri")}},command:n.config.command,env:mr(e.env,n.config.env),...n.config.initializationOptions&&{initOptions:n.config.initializationOptions},...n.config.settings&&{settings:n.config.settings},...n.config.timeoutMs&&{timeoutMs:n.config.timeoutMs}});try{return await d.start(e.signal),{status:"pass",message:`${s}: initialized`,detail:n.sourcePath}}catch(c){return{status:"fail",message:`${s}: ${c instanceof Error?c.message:String(c)}`,detail:n.sourcePath}}finally{await d.shutdown()}}))}catch(t){return e.signal?.throwIfAborted(),[{status:"fail",message:t instanceof Error?t.message:String(t)}]}}})}};async function pr(o){try{let e=await A.fromPackageDir(o.cwd,xt(o)),t=[],r=new Map;for(let[n,s]of o.detectedLanguages){let i=s.flatMap(d=>e.resolve(d)).find(d=>d.languageId===n);i!==void 0&&(t.push({kind:"lsp",languageId:n,toolId:i.serverId}),await mt(o,i.config)||r.set(i.serverId,{id:`lsp-${i.serverId}-unavailable`,message:`Configured language server ${i.serverId} cannot run ${JSON.stringify(i.config.command)}`}))}return{selections:t,actions:[...r.values()]}}catch(e){return o.signal?.throwIfAborted(),{actions:[{id:"lsp-config-invalid",message:`Language server configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}a(pr,"inspectLspSetup");function xt(o){let e=o.workspace;return{...gt(o),recipeEvidence:e?t=>e.evidence(t,o.signal):void 0}}a(xt,"lspOptions");function gr(o,e){let t=new Map;for(let r of e){let n=o.resolve(r)[0];n!==void 0&&!t.has(n.serverId)&&t.set(n.serverId,n)}return[...t.values()]}a(gr,"applicableServers");function mr(o,e){return Object.fromEntries(Object.entries({...o,...e}).filter(t=>t[1]!==void 0))}a(mr,"definedEnvironment");var hr={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 W(o){return hr[o]??`SymbolKind(${o})`}a(W,"symbolKindName");async function Y(o,e,t){return await o.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}},t)??[]}a(Y,"requestDocumentSymbols");async function fe(o,e,t=100,r){return(await o.sendRequest("workspace/symbol",{query:e},r)??[]).slice(0,t)}a(fe,"requestWorkspaceSymbols");async function se(o,e,t,r){return await o.sendRequest("textDocument/rename",{textDocument:{uri:e},position:t,newName:r})}a(se,"requestRename");import ee from"node:path";import{URI as vr}from"vscode-uri";import{createHash as fr}from"node:crypto";import{readdir as yr,stat as ie}from"node:fs/promises";import M from"node:path";import{URI as we}from"vscode-uri";async function ye(o,e){if(!o.supportsCommand("typescript.tsserverRequest"))return;if((await o.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(ye,"prepareProjectQuery");function kt(o,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(([n,s])=>[n,t(s)])):r,"expand");return Object.fromEntries(Object.entries(o).map(([r,n])=>[r,t(n)]))}a(kt,"resolveInitializationOptions");var q=class o{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(!o._instance)throw new Error("[lsp] LspManager not initialized");return o._instance}static getInstanceOrNull(){return o._instance}static init(e,t){let r=o._instance;return r?._disposed?(r._registry=e,r._owner=t,r._disposed=!1,r):(o._instance=new o(e,t),o._instance)}static async resetForTest(){o._instance&&(await o._instance.shutdownAll(),o._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,n){if(n?.throwIfAborted(),this._disposed)return null;let s=t.startsWith("ssh://"),i=s?this.requireOwner():void 0,d=i?await this._registry.resolveOwned(e,g=>i.exists(g,n)):this._registry.resolve(e);if(n?.throwIfAborted(),this._disposed)return null;let c=r==="symbols"?d[0]:d.find(g=>g.config.capabilities.includes(r));if(!c)return null;let l=s?t:we.file(t).toString(),m=`${c.serverId}:${l}`,y=this._clientStarts.get(m);if(y)return y.controller.signal.aborted?(await T(y.promise.catch(()=>{}),n),this.getOrStart(e,t,r,n)):y.wait(n);let u=this._clients.get(m);if(u?.ready)return u;let h=new B(g=>this._startClient(m,l,c,u,g));this._clientStarts.set(m,h);let f=a(()=>{this._clientStarts.get(m)===h&&this._clientStarts.delete(m)},"settled");return h.promise.then(f,f),h.wait(n)}async _startClient(e,t,r,n,s){let i=n??new U({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:kt(r.config.initializationOptions,t.startsWith("ssh://")?decodeURIComponent(new URL(t).pathname):we.parse(t).fsPath)},...r.config.settings&&{settings:r.config.settings},...r.config.timeoutMs&&{timeoutMs:r.config.timeoutMs}});try{n?await n.restart(s):await i.start(s),s.throwIfAborted()}catch(d){try{await i.shutdown()}catch(c){if(c!==d)throw new AggregateError([d,c],"Language server startup and cleanup failed",{cause:c})}throw d}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(E(e,t),r)}let n=await ie(M.resolve(t,e));return r?.throwIfAborted(),n.isFile()}async getWorkspaceClients(e,t="symbols",r=e,n=()=>!0,s){if(s?.throwIfAborted(),e.startsWith("ssh://")){let y=this._owner;if(!y)throw Object.assign(new Error("No language server workspace owner"),{code:"UNSUPPORTED_SOURCE"});let u=new Set,h=new Set(this._registry.knownExtensions),f=new Set([".git",".cache","node_modules","dist","build"]),g=a(async w=>{if(s?.throwIfAborted(),h.size!==0)for(let v of await y.entries(w,s)){s?.throwIfAborted();let L=E(v.name,`${w}/`);if(v.kind==="directory")f.has(v.name)||await g(L);else if(v.kind==="file"){let b=M.posix.extname(v.name).toLowerCase();if(!h.has(b)||!n(L))continue;let x=await this.openFile(L,e,t,s);x&&(u.add(x.client),h.delete(b))}}},"visit"),p=E(r,e);if(await y.isFile(p,s)){if(!n(p))return[];let w=await this.openFile(p,e,t,s);return w?[w.client]:[]}return await g(p),[...u]}let i=new Set,d=new Set(this._registry.knownExtensions),c=new Set([".git",".cache","node_modules","dist","build"]),l=a(async y=>{if(s?.throwIfAborted(),d.size===0)return;let u;try{u=await yr(y,{withFileTypes:!0})}catch{return}for(let h of u){if(s?.throwIfAborted(),d.size===0)return;if(h.isDirectory()){c.has(h.name)||await l(M.join(y,h.name));continue}if(!h.isFile())continue;let f=M.extname(h.name).toLowerCase();if(!d.has(f))continue;let g=M.join(y,h.name);if(!n(g))continue;let p=await this.openFile(g,e,t,s);p&&(d.delete(f),p.client.hasWorkspaceSymbolCapability&&(await ye(p.client,g),i.add(p.client)))}},"visit"),m=M.resolve(e,r);if((await ie(m)).isFile()){if(!n(m))return[];let y=await this.openFile(m,e,t,s);return y===null||!y.client.hasWorkspaceSymbolCapability?[]:(await ye(y.client,m),[y.client])}return await l(m),s?.throwIfAborted(),[...i]}async prepareWorkspaceSymbols(e,t=e,r,n){return this.getWorkspaceClients(e,"symbols",t,r,n)}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 n=r.toUri(e);if(r.documentContent(n)===void 0)continue;let s=this.languageId(M.extname(decodeURIComponent(new URL(n).pathname)));r.syncDocument(n,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"),n=r(await ie(e)),s=await this.readSourceText(e,t);if(n!==r(await ie(e)))throw new Error("A rename source changed while reading it. No edits applied.");return{content:s,version:fr("sha256").update(n).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",n){if(n?.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?E(e,t):M.resolve(t,e),d=await this.getOrStart(i,t,r,n);if(!d)return null;let c=d.toUri(i),l=s?this.requireOwner():void 0,y=(l?await this._registry.resolveOwned(i,u=>l.exists(u,n)):this._registry.resolve(i))[0]?.languageId??"plaintext";if(l){let u=await l.readText(c,n);return n?.throwIfAborted(),d.syncDocument(c,u,y),this._openDocs.add(c),{client:d,uri:c,languageId:y}}try{let{readFile:u}=await import("node:fs/promises"),h=await u(i,{encoding:"utf8",signal:n});n?.throwIfAborted(),d.syncDocument(c,h,y),this._openDocs.add(c)}catch(u){if(n?.throwIfAborted(),!(u instanceof Error&&"code"in u&&u.code==="ENOENT"))throw u}return{client:d,uri:c,languageId:y}}_subscribeToPushDiagnostics(e,t){if(this._pushUnsubscribers.has(e))return;let r=t.onNotification("textDocument/publishDiagnostics",n=>{let s=wr(n);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 d=`${e}:${s.uri}`,c=s.diagnostics.map(me),l=JSON.stringify([s.version,i,c]);if(this._pushFingerprints.get(d)===l)return;this._pushFingerprints.set(d,l);let m={cwd:t.rootUri.startsWith("ssh://")?t.rootUri:we.parse(t.rootUri).fsPath,serverId:t.serverId,uri:s.uri,diagnostics:c,...s.version!==void 0&&{version:s.version}};for(let y of this._pushHandlers)y(m)});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,d]of t.entries())d.status==="rejected"&&d.reason!==e[i]?.controller.signal.reason&&r.push(d.reason);let n=[...this._clients.values()],s=await Promise.allSettled(n.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 wr(o){if(o===null||typeof o!="object")return;let e=o;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}a(wr,"parsePushNotification");async function ve(o,e,t){if(t?.throwIfAborted(),!o.supportsCommand("typescript.tsserverRequest"))return;let r=await o.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:o.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(ve,"loadQueryProject");async function Z(o,e,t,r){return await ve(o,e,r),await o.sendRequest("textDocument/references",{textDocument:{uri:e},position:t,context:{includeDeclaration:!0}},r)??[]}a(Z,"requestReferences");async function be(o,e,t,r){let n=await o.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:t},r),s=n?.[0];if(!s)return{items:[],incoming:[],outgoing:[]};let[i,d]=await Promise.all([o.sendRequest("callHierarchy/incomingCalls",{item:s},r),o.sendRequest("callHierarchy/outgoingCalls",{item:s},r)]);return{items:n,incoming:i??[],outgoing:d??[]}}a(be,"requestCallHierarchy");function J(o,e,t){let r=e.startsWith("ssh://"),n=r?ee.posix:ee,s=a(m=>r?decodeURIComponent(new URL(E(m,e)).pathname):m,"native"),i=r?s(t.path??e):ee.resolve(e,t.path??"."),d=n.relative(i,s(o));if(d===".."||d.startsWith(`..${n.sep}`)||n.isAbsolute(d))return!1;let c=n.relative(s(e),s(o)).split(n.sep).join("/"),l=a(m=>et(m).some(y=>n.matchesGlob(y.includes("/")?c:n.basename(s(o)),y)),"matches");return(t.include===void 0||l(t.include))&&(t.exclude===void 0||!l(t.exclude))}a(J,"withinScope");function Se(o,e){let t=E(o,e);if(t.startsWith("ssh://"))return t;let r=vr.parse(t);if(r.scheme!=="file")throw new Error("Unsupported LSP source location.");return ee.resolve(r.fsPath)}a(Se,"sourceOf");function br(o,e){return o.start.line===e.start.line&&o.start.character===e.start.character&&o.end.line===e.end.line&&o.end.character===e.end.character}a(br,"sameRange");function Et(o,e,t){return o.flatMap(r=>[...r.name===e&&r.range!==void 0&&br(r.range,t)&&r.selectionRange!==void 0?[r.selectionRange]:[],...Et(r.children??[],e,t)])}a(Et,"declarationNames");async function Le(o,e,t,r,n={},s=q.getInstance()){r?.throwIfAborted();let i=n.resultScope;if(i!==void 0&&(await z(i,r),i.targets.length===0))return{hits:[],complete:i.complete};if(i===void 0&&n.path!==void 0&&!J(e.startsWith("ssh://")?E(n.path,e):ee.resolve(e,n.path),e,n)&&await s.isSourceFile(n.path,e,r))return{hits:[],complete:!0};let d=i?.targets.map(f=>f.source)??[n.path??e],c=new Set((await Promise.all(d.map(f=>s.prepareWorkspaceSymbols(e,f,g=>J(g,e,n),r)))).flat());if(c.size===0)throw new Error("LSP symbol search is unavailable: no provider supports workspace/symbol in this scope.");let l=new Map,m=a(async f=>{r?.throwIfAborted();let g=Se(f.uri,e),p=l.get(g);if(p===void 0){let{content:R,version:F}=await s.readSourceSnapshot(g,r);p={document:Ne(g,R),version:F},l.set(g,p)}let{document:w}=p,{start:v,end:L}=f.range,b=[v,L];for(let R of b){let F=w.lines[R.line];if(!Number.isInteger(R.line)||!Number.isInteger(R.character)||F===void 0||R.character<0||R.character>F.content.length)throw new Error("LSP range does not match its source snapshot.")}let x=k(w.lines[v.line]),D=a(R=>w.lines.slice(0,R).reduce((F,De)=>F+De.content.length+De.lineEnding.length,0),"offset"),j=D(v.line)+v.character,P=D(L.line)+L.character;if(P<j)throw new Error("LSP returned a reversed source range.");return{source:g,lineNumber:v.line+1,endLineNumber:L.line+1,startColumn:v.character,endColumn:L.character,matchedText:w.content.slice(j,P),lineText:x.content}},"toMatch"),y=a(f=>J(f.source,e,n)&&(i===void 0||Ze(i,f)),"included"),u=[],h=new Set;for(let f of c){r?.throwIfAborted();let g=await fe(f,o,Number.MAX_SAFE_INTEGER,r);for(let p of g){if(r?.throwIfAborted(),!J(Se(p.location.uri,e),e,{}))continue;let w=await m(p.location),v=await s.openFile(w.source,e,"symbols",r);if(v===null)throw new Error("LSP references are unavailable for a discovered declaration.");let L=p.location;if(w.matchedText!==p.name){let P=await Y(v.client,v.uri,r),R=Et(P,p.name,p.location.range);if(R.length!==1)throw new Error("LSP declaration has no unique provider selectionRange; cannot search its references.");L={uri:v.uri,range:k(R[0])}}let b=await m(L),x={id:JSON.stringify([f.serverId,b.source,p.location.range]),name:p.name,kind:String(p.kind),source:b.source,range:{startLine:b.lineNumber,startColumn:b.startColumn,endLine:b.endLineNumber??b.lineNumber,endColumn:b.endColumn}},D=await Z(v.client,v.uri,L.range.start,r);r?.throwIfAborted();let j=[{...b,role:"definition",symbol:x}];for(let P of D){if(!J(Se(P.uri,e),e,{}))continue;let R=await m(P);R.source===b.source&&R.lineNumber===b.lineNumber&&R.startColumn===b.startColumn&&R.endLineNumber===b.endLineNumber&&R.endColumn===b.endColumn||j.push({...R,role:"reference",symbol:x})}if(!(n.navigation==="references"&&!j.some(y)))for(let P of j){if(n.navigation!=="references"&&!y(P)||n.navigation==="references"&&!J(P.source,e,{}))continue;let R=JSON.stringify([x.id,P.source,P.lineNumber,P.startColumn,P.endLineNumber,P.endColumn]);h.has(R)||(h.add(R),u.push(P))}}}r?.throwIfAborted();for(let[f,g]of l){let p=await s.readSourceSnapshot(f,r);if(p.version!==g.version||p.content!==g.document.content)throw new Error("LSP source changed during search.")}return i!==void 0&&await z(i,r),u.sort((f,g)=>f.source.localeCompare(g.source)||f.lineNumber-g.lineNumber||f.startColumn-g.startColumn||f.endColumn-g.endColumn||f.symbol.id.localeCompare(g.symbol.id)),{hits:u.slice(0,t),complete:(i?.complete??!0)&&u.length<=t}}a(Le,"searchSymbols");import Re from"node:path";import{fileURLToPath as Sr}from"node:url";var Pe=10,_e=5,K=10;async function ce(o,e,t,r,n){$(n);let s=await o.readSourceText(e,n),i=await de(o,e,r,n),d=le(i.symbols,t,i.displayPath),c=await o.readSourceText(i.filePath,n);if($(n),s!==c)throw new Error("The symbol source changed during resolution. Read it again before editing.");return{source:i.filePath,range:d.range,content:c}}a(ce,"resolveLspDeclaration");async function Dt(o,e,t,r,n){$(n);let s=await o.readSourceText(e,n),i=await de(o,e,r,n),d=le(i.symbols,t,i.displayPath);if(s!==await o.readSourceText(e,n))throw new Error("The rename source changed during resolution.");return $(n),{client:i.client,uri:i.uri,position:d.selectionRange.start,content:s}}a(Dt,"resolveLspRenameTarget");async function ke(o,e,t,r,n){$(n);let s=await de(o,e,r,n),i=le(s.symbols,t,s.displayPath),d=await Ot(s,i,n),c=new ae(r);return await Lr(s,i,d,c)}a(ke,"readLspSymbolGraph");async function Ee(o,e,t,r){$(r);let n=await de(o,e,t,r),s=new ae(t),i=[`## file graph: ${n.displayPath}`,`Top-level declarations: ${n.symbols.length}`];for(let d of n.symbols){$(r);let c=await Ot(n,d,r);i.push("",...await Cr(n,d,c,s))}return i.join(`
2
2
  `)}a(Ee,"readLspFileGraph");function le(o,e,t){if(e.length===0)throw new TypeError("A symbol selector must contain at least one segment.");if(e.length===1){let s=Tt(o,k(e[0]));if(s.length===1)return k(s[0]);throw s.length>1?new Error(`Symbol selector "${V(e)}" is ambiguous in ${t}; use parent/child.`):It(e,t)}let r=o,n;for(let s of e){let i=r.filter(d=>d.name===s);if(i.length===0)throw It(e,t);if(i.length>1)throw new Error(`Symbol selector "${V(e)}" is ambiguous at "${s}" in ${t}.`);n=k(i[0]),r=n.children}return k(n)}a(le,"resolveLspCodeSymbol");async function de(o,e,t,r){let n=I(e,t),s=await o.openFile(n,t,"symbols",r);if(!s)throw new Error(`No LSP server with symbol support is configured for ${xe(n,t)}.`);let i=await Y(s.client,s.uri,r),d=At(i).sort(jt);return{client:s.client,uri:s.uri,filePath:n,displayPath:xe(n,t),symbols:d}}a(de,"openCodeDocument");function At(o,e=[]){return o.flatMap(t=>{let r=t.selectionRange??t.range;if(!r)return[];let n=t.range??r,s=[...e,t.name];return[{name:t.name,kind:t.kind,range:n,selectionRange:r,selector:s,children:At(t.children??[],s).sort(jt)}]})}a(At,"normalizeDocumentSymbols");function jt(o,e){return o.range.start.line-e.range.start.line||o.range.start.character-e.range.start.character||o.name.localeCompare(e.name)}a(jt,"compareSymbols");function Tt(o,e){return o.flatMap(t=>[...t.name===e?[t]:[],...Tt(t.children,e)])}a(Tt,"collectNamedSymbols");function It(o,e){return new Error(`Symbol "${V(o)}" was not found in ${e}.`)}a(It,"symbolNotFound");async function Ot(o,e,t){let r=e.selectionRange.start,[n,s]=await Promise.all([Z(o.client,o.uri,r,t),be(o.client,o.uri,r,t)]);return $(t),{references:n,calls:s}}a(Ot,"queryRelations");async function Lr(o,e,t,r){let n=V(e.selector),s=await r.line(o.uri,e.selectionRange.start.line+1);return[`## graph: ${n}`,`Definition: ${o.displayPath} ${s} (${W(e.kind)})`,`Source: calls ${Mt(o.displayPath,e.selector)}`,"",...await Rr(t.references,r),"",...await Pr(t.calls.incoming,r),"",...await _r(t.calls.outgoing,r)].join(`
3
3
  `)}a(Lr,"formatSymbolGraph");async function Rr(o,e){let t=$t(o),r=[`References: ${o.length} in ${t.length} file(s)`];for(let[n,s]of t.slice(0,Pe)){r.push(`- ${e.display(n)} (${s.length})`);for(let i of s.slice(0,_e))r.push(` - ${await e.line(n,i.range.start.line+1)}`);s.length>_e&&r.push(` - ... ${s.length-_e} more`)}return t.length>Pe&&r.push(`- ... ${t.length-Pe} more file(s)`),r}a(Rr,"formatReferences");async function Pr(o,e){let t=[`Incoming calls: ${o.length}`];for(let r of o.slice(0,K)){let n=r.fromRanges[0]?.start.line??r.from.selectionRange.start.line,s=await e.line(r.from.uri,n+1);t.push(`- ${W(r.from.kind)} ${r.from.name} \u2014 ${e.display(r.from.uri)} ${s}`)}return o.length>K&&t.push(`- ... ${o.length-K} more`),t}a(Pr,"formatIncomingCalls");async function _r(o,e){let t=[`Outgoing calls: ${o.length}`];for(let r of o.slice(0,K)){let n=await e.line(r.to.uri,r.to.selectionRange.start.line+1);t.push(`- ${W(r.to.kind)} ${r.to.name} \u2014 ${e.display(r.to.uri)} ${n}`)}return o.length>K&&t.push(`- ... ${o.length-K} more`),t}a(_r,"formatOutgoingCalls");async function Cr(o,e,t,r){let n=W(e.kind),s=await r.line(o.uri,e.selectionRange.start.line+1),i=$t(t.references).map(([m,y])=>`${r.display(m)} (${y.length})`),d=t.calls.incoming.map(m=>`${m.from.name} (${r.display(m.from.uri)})`),c=t.calls.outgoing.map(m=>`${m.to.name} (${r.display(m.to.uri)})`),l=[`### ${n} ${e.name}`,`Selector: ${V(e.selector)}`,`Definition: ${s}`,`Used by: ${Ce(i)}`,`Incoming calls: ${Ce(d)}`,`Outgoing calls: ${Ce(c)}`];if(e.children.length>0){l.push("Members:");for(let m of e.children){let y=Mt(o.displayPath,m.selector);l.push(`- ${W(m.kind)} ${m.name} \u2014 calls ${y}`)}}return l}a(Cr,"formatFileGraphSymbol");function Mt(o,e){return rt("graph",o,e).slice(6)}a(Mt,"callsReference");function Ce(o,e=5){if(o.length===0)return"none";let t=o.slice(0,e).join(", ");return o.length>e?`${t}, ... ${o.length-e} more`:t}a(Ce,"summarize");function $t(o){let e=new Map;for(let t of o){let r=e.get(t.uri)??[];r.push(t),e.set(t.uri,r)}return[...e].map(([t,r])=>[t,r.sort((n,s)=>n.range.start.line-s.range.start.line||n.range.start.character-s.range.start.character)]).sort(([t],[r])=>t.localeCompare(r))}a($t,"groupLocationsByUri");var ae=class{static{a(this,"LocationPresenter")}#e;constructor(e){this.#e=e}display(e){return xe(xr(e),this.#e)}line(e,t){return Promise.resolve(String(t))}};function xr(o){if(!o.startsWith("file://"))return o;try{return Sr(o)}catch{return decodeURIComponent(o.slice(7))}}a(xr,"filePathFromUri");function xe(o,e){if(o.startsWith("ssh://"))return o;let t=Re.relative(e,o);return t.length===0||t.startsWith("..")||Re.isAbsolute(t)?o:t.replaceAll(Re.sep,"/")}a(xe,"displayFilePath");function $(o){if(o?.aborted===!0)throw kr(o)}a($,"throwIfAborted");function kr(o,e){if(o.reason instanceof Error)return o.reason;if(e instanceof Error)return e;let t=new Error("The operation was aborted");return t.name="AbortError",t}a(kr,"abortReason");function Ie(o){let e=null;return{kind:"compiler",name:"lsp",priority:100,extensions:["*"],detect:a(()=>Promise.resolve(!0),"detect"),async compile({filePath:t},r){r.signal?.throwIfAborted();let n=await o(r.cwd,t,r.signal);r.signal?.throwIfAborted();let s=await Er(t,r,n);if(!s)throw new Error("No diagnostic language server for this source");let{client:i,diagnostics:d,syntaxErrors:c,otherDiagnostics:l}=s;return e=i,{ok:!d.some(m=>m.severity==="error"),diagnostics:d,syntaxErrors:c,otherDiagnostics:l}},async restart(){e&&(await e.restart(),e=null)}}}a(Ie,"createLspCompiler");async function Er(o,e,t){let r=await t.openFile(o,e.cwd,"diagnostics",e.signal);if(e.signal?.throwIfAborted(),!r)return null;let n=await Q(r.client,r.uri,r.languageId,{signal:e.signal});if(e.signal?.throwIfAborted(),!n.complete)throw new Error("Language server diagnostics are a snapshot, not a completed report");return{client:r.client,...n}}a(Er,"openAndDiagnose");import Ir from"node:path";function Nt(o){let e=o.options?.lsp;return typeof e=="object"&&e!==null?e:void 0}a(Nt,"lspOptions");var Dr={resolveLspDeclaration:ce,readLspFileGraph:Ee,readLspSymbolGraph:ke,searchSymbols:Le};function Ut(o,e,t=Dr){return{id:"lsp",supportsResultScope:!0,readResources:a(r=>Nt(r)===void 0?[]:void 0,"readResources"),toScriptData(r){let n=r;return n.mode==="calls"?{kind:"custom",resolverId:"lsp",value:{calls:n.text}}:n.data},async tryResolve(r,n){let s=Nt(r);if(s===void 0)return{kind:"not-handled"};if([s.query,s.declaration,s.calls].filter(p=>p!==void 0).length!==1)return{kind:"failed",error:new Error("Pass exactly one of query, declaration or calls.")};if(s.calls!==void 0){let p=N(`graph:${s.calls}`,"graph");if(p===void 0)throw new Error("calls requires a file path.");let w=I(p.path,n.cwd),v=await o(n.cwd,w,n.signal);return{kind:"resolved",payload:{mode:"calls",text:p.selector===void 0?await t.readLspFileGraph(v,w,n.cwd,n.signal):await t.readLspSymbolGraph(v,w,p.selector,n.cwd,n.signal)}}}if(s.declaration!==void 0){let p=s.declaration.includes("#")?N(`symbol:${s.declaration}`,"symbol"):void 0;if(p?.selector===void 0)throw new Error("declaration requires file#selector, such as src/app.ts#App/start.");let w=I(p.path,n.cwd),v=p.selector,L=a(async D=>{let j=await o(n.cwd,w,D),P=await t.resolveLspDeclaration(j,w,v,n.cwd,D);return Ar(P.source,P.content,P.range)},"resolve"),b=await L(n.signal),x=await e({request:r,matches:[b],complete:!0,refresh:a(async D=>({matches:[await L(D)],complete:!0}),"refresh")},n);return{kind:"resolved",payload:{mode:"declaration",sessionId:x.id,selector:s.declaration,match:b,data:ue([b],!0,x.id,x)}}}let d=(s.query??"").trim();if(d.length===0)return{kind:"failed",error:new Error("query must not be empty")};let c=s.references===!0,l=n.scope,m=new Map;if(l!==void 0){await z(l,n.signal);for(let p of l.targets){let w=await o(n.cwd,p.source,n.signal),v=m.get(w)??[];v.push(p),m.set(w,v)}}else m.set(await o(n.cwd,r.path,n.signal),[]);let y=r.limit??100,u=a(async p=>{let w=[],v=l?.complete??!0;for(let[L,b]of m){let x=await t.searchSymbols(d,L.workspaceRoot,y,p,{...r.path===void 0?{}:{path:r.path},...r.include===void 0?{}:{include:r.include},...r.exclude===void 0?{}:{exclude:r.exclude},...c?{navigation:"references"}:{},...l===void 0?{}:{resultScope:{targets:b,complete:l.complete}}},L);w.push(...x.hits),v=v&&x.complete}return l!==void 0&&await z(l,p),{hits:w.slice(0,y),complete:v&&w.length<=y}},"collect"),h=await u(n.signal),f=await e({request:r,matches:h.hits,complete:h.complete,refresh:a(async p=>{let w=await u(p);return{matches:w.hits,complete:w.complete}},"refresh")},n),g=ue(h.hits,h.complete,f.id,f);return{kind:"resolved",payload:{mode:"symbols",sessionId:f.id,hits:h.hits,complete:h.complete,references:c,data:{...g,matches:g.matches.map((p,w)=>({...p,role:h.hits[w]?.role,symbol:h.hits[w]?.symbol}))}}}},renderResult(r,n,s){let i=r.details;return i.mode==="calls"?new te({summary:i.text.split(`
4
4
  `,1)[0]??"Calls",rows:i.text.split(`
@@ -1 +1 @@
1
- import{a as C}from"./chunk-H3GEEOOL.js";import{a as w}from"./chunk-RIJRPAL2.js";import{a as E,b as g}from"./chunk-USG6WHAT.js";import{b as S}from"./chunk-LF325WYO.js";import"./chunk-VMLPXSMK.js";import{a as u,b as v,c as U}from"./chunk-WQIMM4SU.js";import"./chunk-FHRHYY4M.js";import{g as l}from"./chunk-4IWEKRSP.js";import{a as p,b as O,c as f,e as j}from"./chunk-TVXZE4KW.js";import{c as R}from"./chunk-W7CASEO3.js";import"./chunk-B25LXXNV.js";import"./chunk-K5G4FDXD.js";import"./chunk-MDD5ORB6.js";import"./chunk-MLFJU2US.js";import"./chunk-DDH3FP4G.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import{c as P}from"./chunk-7D7PXIVV.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-H3GEEOOL.js";import{a as w}from"./chunk-RIJRPAL2.js";import{a as E,b as g}from"./chunk-USG6WHAT.js";import{b as S}from"./chunk-LF325WYO.js";import"./chunk-VMLPXSMK.js";import{a as u,b as v,c as U}from"./chunk-WQIMM4SU.js";import"./chunk-FHRHYY4M.js";import{g as l}from"./chunk-4IWEKRSP.js";import{a as p,b as O,c as f,e as j}from"./chunk-HRBUY2FF.js";import"./chunk-K5G4FDXD.js";import{c as R}from"./chunk-W7CASEO3.js";import"./chunk-B25LXXNV.js";import{c as P}from"./chunk-7D7PXIVV.js";import"./chunk-BXGMMZT3.js";import"./chunk-MDD5ORB6.js";import"./chunk-MLFJU2US.js";import"./chunk-DDH3FP4G.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.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,4 +1,4 @@
1
- import{a as N}from"./chunk-47SPPIXK.js";import{a as I,b as C}from"./chunk-VAXLSPPU.js";import{a as $}from"./chunk-FYOU4RBH.js";import{d as b}from"./chunk-7PVDTMEM.js";import{a as S,b as P,c as O,d as T}from"./chunk-KN6VPARZ.js";import{a as x}from"./chunk-BU7IZLKB.js";import{a as A,b as E}from"./chunk-S5PL5DFQ.js";import{a as s}from"./chunk-EI7MMDWY.js";var W=/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/,R=class{static{s(this,"AgentDocumentationRegistry")}#e=new Map;register(t){let n=new Set(this.#e.keys());for(let r of t)U(r,n),n.add(r.id);for(let r of t)this.#e.set(r.id,V(r))}list(){return[...this.#e.values()].sort((t,n)=>t.id.localeCompare(n.id))}get(t){return this.#e.get(t)}matching(t,n){let r=L(n);return r?.startsWith("docs:")===!0?[]:this.list().filter(c=>c.triggers.some(i=>{if(i.tool!==t)return!1;let l=i.resourcePrefixes===void 0||r!==void 0&&i.resourcePrefixes.some(o=>r.startsWith(o)),u=i.viewPrefixes===void 0||z(n).some(o=>i.viewPrefixes?.some(a=>o.startsWith(a)));return l&&u}))}};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(n=>n.tool.trim().length===0||n.resourcePrefixes?.some(r=>r.length===0)===!0||n.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){let t={...e,triggers:Object.freeze(e.triggers.map(r=>Object.freeze({...r,...r.resourcePrefixes===void 0?{}:{resourcePrefixes:Object.freeze([...r.resourcePrefixes])},...r.viewPrefixes===void 0?{}:{viewPrefixes:Object.freeze([...r.viewPrefixes])}})))},n=Object.getOwnPropertyDescriptor(e,"markdown");return n?.get!==void 0&&Object.defineProperty(t,"markdown",{get:n.get.bind(e),enumerable:!0}),Object.freeze(t)}s(V,"freezeDocument");function z(e){if(typeof e!="object"||e===null)return[];let t=e.views;return Array.isArray(t)?t.filter(n=>typeof n=="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 M(e){return{id:"agent-documentation",readResources:s(t=>t.path?.startsWith("docs:")===!0?[t.path]:[],"readResources"),async tryResolve(t,n){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 c=r.slice(5);if(c.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 i=c==="all"?void 0:e.get(c);if(c!=="all"&&i===void 0)return{kind:"failed",error:new Error(`Unknown documentation ID: ${c}`)};let l=G(t),u=[],o=t.limit??50,a=0;for(let f of i===void 0?e.list():[i]){n.signal?.throwIfAborted();for(let[h,m]of f.markdown.split(/\r\n|\n|\r/u).entries()){n.signal?.throwIfAborted();for(let d of m.matchAll(l)){if(d[0].length===0)continue;let p=d.index,w=p+d[0].length;if(t.wholeWord===!0&&(/[\p{L}\p{N}_]/u.test(m[p-1]??"")||/[\p{L}\p{N}_]/u.test(m[w]??"")))continue;if(u.length===o)return{kind:"resolved",payload:{source:r,matches:u,complete:!1,reason:"limit"}};let D={source:`docs:${f.id}`,lineNumber:h+1,startColumn:p,endColumn:w,matchedText:d[0],lineText:m};if(a+=Buffer.byteLength(_(D))+1,a>48*1024)return{kind:"resolved",payload:{source:r,matches:u,complete:!1,reason:"output"}};u.push(D)}}}return{kind:"resolved",payload:{source:r,matches:u,complete:!0}}},toScriptData(t){let n=t;return b(n.matches,n.complete)},format(t){let n=t,r=`${n.matches.length}${n.complete?"":"+"}`;return{content:[{type:"text",text:[n.matches.length===0&&n.complete?`No matches in ${n.source}`:`${r} matches in ${n.source}`,...v(n),...n.matches.map(_)].join(`
1
+ import{a as $}from"./chunk-FYOU4RBH.js";import{d as b}from"./chunk-7PVDTMEM.js";import{a as N}from"./chunk-47SPPIXK.js";import{a as I,b as C}from"./chunk-VAXLSPPU.js";import{a as S,b as P,c as O,d as T}from"./chunk-KN6VPARZ.js";import{a as x}from"./chunk-BU7IZLKB.js";import{a as A,b as E}from"./chunk-S5PL5DFQ.js";import{a as s}from"./chunk-EI7MMDWY.js";var W=/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/,R=class{static{s(this,"AgentDocumentationRegistry")}#e=new Map;register(t){let n=new Set(this.#e.keys());for(let r of t)U(r,n),n.add(r.id);for(let r of t)this.#e.set(r.id,V(r))}list(){return[...this.#e.values()].sort((t,n)=>t.id.localeCompare(n.id))}get(t){return this.#e.get(t)}matching(t,n){let r=L(n);return r?.startsWith("docs:")===!0?[]:this.list().filter(c=>c.triggers.some(i=>{if(i.tool!==t)return!1;let l=i.resourcePrefixes===void 0||r!==void 0&&i.resourcePrefixes.some(o=>r.startsWith(o)),u=i.viewPrefixes===void 0||z(n).some(o=>i.viewPrefixes?.some(a=>o.startsWith(a)));return l&&u}))}};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(n=>n.tool.trim().length===0||n.resourcePrefixes?.some(r=>r.length===0)===!0||n.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){let t={...e,triggers:Object.freeze(e.triggers.map(r=>Object.freeze({...r,...r.resourcePrefixes===void 0?{}:{resourcePrefixes:Object.freeze([...r.resourcePrefixes])},...r.viewPrefixes===void 0?{}:{viewPrefixes:Object.freeze([...r.viewPrefixes])}})))},n=Object.getOwnPropertyDescriptor(e,"markdown");return n?.get!==void 0&&Object.defineProperty(t,"markdown",{get:n.get.bind(e),enumerable:!0}),Object.freeze(t)}s(V,"freezeDocument");function z(e){if(typeof e!="object"||e===null)return[];let t=e.views;return Array.isArray(t)?t.filter(n=>typeof n=="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 M(e){return{id:"agent-documentation",readResources:s(t=>t.path?.startsWith("docs:")===!0?[t.path]:[],"readResources"),async tryResolve(t,n){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 c=r.slice(5);if(c.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 i=c==="all"?void 0:e.get(c);if(c!=="all"&&i===void 0)return{kind:"failed",error:new Error(`Unknown documentation ID: ${c}`)};let l=G(t),u=[],o=t.limit??50,a=0;for(let f of i===void 0?e.list():[i]){n.signal?.throwIfAborted();for(let[h,m]of f.markdown.split(/\r\n|\n|\r/u).entries()){n.signal?.throwIfAborted();for(let d of m.matchAll(l)){if(d[0].length===0)continue;let p=d.index,w=p+d[0].length;if(t.wholeWord===!0&&(/[\p{L}\p{N}_]/u.test(m[p-1]??"")||/[\p{L}\p{N}_]/u.test(m[w]??"")))continue;if(u.length===o)return{kind:"resolved",payload:{source:r,matches:u,complete:!1,reason:"limit"}};let D={source:`docs:${f.id}`,lineNumber:h+1,startColumn:p,endColumn:w,matchedText:d[0],lineText:m};if(a+=Buffer.byteLength(_(D))+1,a>48*1024)return{kind:"resolved",payload:{source:r,matches:u,complete:!1,reason:"output"}};u.push(D)}}}return{kind:"resolved",payload:{source:r,matches:u,complete:!0}}},toScriptData(t){let n=t;return b(n.matches,n.complete)},format(t){let n=t,r=`${n.matches.length}${n.complete?"":"+"}`;return{content:[{type:"text",text:[n.matches.length===0&&n.complete?`No matches in ${n.source}`:`${r} matches in ${n.source}`,...v(n),...n.matches.map(_)].join(`
2
2
  `)}],details:n}},renderResult(t,n,r){let c=t.details;return $(c.matches,c.complete,r,n.expanded,void 0,v(c))}}}s(M,"createDocumentationSearchResolver");function v(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(v,"notices");function _(e){let t=Math.max(0,e.startColumn-64),n=Math.min(e.lineText.length,e.startColumn+192),r=`${t>0?"\u2026":""}${e.lineText.slice(t,n)}${n<e.lineText.length?"\u2026":""}`;return`${e.source}:${e.lineNumber}:${e.startColumn+1} ${r}`}s(_,"matchRow");function G(e){if(/\r|\n/u.test(e.query))throw new Error("Search supports one-line patterns only.");let t=e.query,n=t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t,r=t.startsWith("regex:")?t.slice(6):n.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(r,e.caseSensitive===!0?"gu":"giu")}s(G,"searchPattern");var y="agent-documentation-read";async function B(e,t={}){let n=new R,r=new Set,c=new Map,i=new Map,l=s(o=>{let a=o.filter(f=>!r.has(f));if(a.length!==0){e.appendEntry(t.recordType??y,{ids:a});for(let f of a)r.add(f)}},"remember"),u=e.events.on(T,o=>{if(!K(o))throw new Error("Invalid agent documentation registration");n.register(o.documents)});e.on("session_shutdown",u),await x(e,{protocol:A,apiVersion:E,id:"agent-documentation",setup(o){o.addResolver({resolver:{id:"agent-documentation",tryResolve(a){if(!a.startsWith("docs:"))return Promise.resolve({kind:"not-handled"});let f=a.slice(5),h=f.length===0?void 0:n.get(f),m=f.length===0?H(n.list()):h?.markdown;return m===void 0?Promise.resolve({kind:"failed",error:new Error(`Unknown documentation ID: ${f}`)}):Promise.resolve({kind:"resolved",resource:{source:a,read:s(()=>Promise.resolve([{type:"text",text:m}]),"read")}})}}}),o.describe({path:s(()=>n.list().length===0?void 0:"docs: \u2014 list of guides; docs:<id> \u2014 one guide.","path")}),o.addPromptGuideline(()=>q(n.list()))}}),await N(e,{protocol:I,apiVersion:C,id:"agent-documentation",setup(o){o.addResolver({resolver:M(n),priority:-20})}}),e.on("session_start",(o,a)=>{k(a.sessionManager.getBranch(),n,r,t)}),e.on("session_tree",(o,a)=>{k(a.sessionManager.getBranch(),n,r,t)}),e.on("session_compact",(o,a)=>{k(a.sessionManager.getBranch(),n,r,t)}),e.on("tool_call",o=>{o.toolCallId.includes("-preflight-")||o.parentToolCallId!==void 0&&c.set(o.toolCallId,o.parentToolCallId)}),e.on("tool_result",o=>{if(o.toolCallId.includes("-preflight-"))return;let a=c.get(o.toolCallId);c.delete(o.toolCallId);let f=i.get(o.toolCallId)??[];i.delete(o.toolCallId);let h=o.toolName==="read"?F(o.input):void 0;if(h!==void 0){let d=h.slice(5),p=d.length===0||n.get(d)!==void 0,w=n.get(d);return w!==void 0&&!o.isError&&j(o.content,w)&&l([d]),{content:o.content,structuredContent:o.structuredContent,details:{...g(o.details)?o.details:{},documentation:{owner:t.recordType??y,...p?d.length===0?{kind:"list",ids:n.list().map(D=>D.id)}:{kind:"document",id:d}:{kind:"error",code:"UNKNOWN_DOCUMENTATION",id:d}}},isError:o.isError}}let m=[...f,...n.matching(o.toolName,o.input).filter(d=>!r.has(d.id))];if(m.length!==0){if(l(m.map(d=>d.id)),a!==void 0){i.set(a,[...i.get(a)??[],...m]);return}return{content:[...o.content,...m.map(d=>({type:"text",text:`
3
3
 
4
4
  ---
@@ -1,4 +1,4 @@
1
- import{b as N}from"./chunk-LEKC4GQK.js";import{a as k,b as E,c as v}from"./chunk-2AY526TN.js";import{f as I,g as S}from"./chunk-TVH2ND35.js";import"./chunk-T4FTT3U4.js";import"./chunk-VDJSH3DQ.js";import"./chunk-KINKBPPX.js";import{a as b}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import h from"node:path";import{readdir as Y}from"node:fs/promises";import K from"node:path";async function P(e){let n=[],t=await Y(e,{withFileTypes:!0});for(let i of t){let o=K.join(e,i.name);i.isDirectory()?n.push(...await P(o)):(i.isFile()||i.isSymbolicLink())&&n.push(o)}return n}a(P,"collectFiles");var W=new Set([...Object.keys(k),".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".py",".pyi",".rs",".c",".cc",".hh",".hxx",".cpp",".cxx",".h",".hpp",".json",".jsonc",".yaml",".yml",".toml"]),H=new Set([".json",".jsonc",".yaml",".yml",".toml"]),j=new Set(["class_declaration","class_definition","class_specifier","enum_declaration","enum_definition","enum_item","enum_specifier","export_statement","function_declaration","function_definition","function_item","impl_item","interface_declaration","lexical_declaration","namespace_definition","mod_item","public_field_definition","method_definition","method_signature","property_signature","field_declaration","struct_item","struct_specifier","trait_item","type_alias_declaration","type_item","variable_declaration","assignment"]),X=new Set(["module","program","source_file"]),G=new Set(["import_declaration","import_from_statement","import_statement","use_declaration"]),A=new Set(["arrow_function","function_declaration","function_definition","function_item","function_expression","method_definition"]),q=new Set(["public_field_definition","variable_declarator","assignment"]),F=new Set(["field_identifier","identifier","property_identifier","shorthand_property_identifier_pattern","type_identifier"]);function w(e){return W.has(h.extname(e).toLowerCase())}a(w,"isSupportedOutlinePath");var L={failureLabel:"PEEK_FAILED",emptyReason:"no entries to peek.",recovery:['Call peek with { peers: [{ path: "path/to/file.ts" }, ...] }.']},Z={failureLabel:"AST_OUTLINE_FAILED",emptyReason:"no AST outline was produced."};function Ie(e){return S([e],Z)}a(Ie,"formatAstOutline");var M=class{constructor(n=Number.POSITIVE_INFINITY){this.maxDepth=n}static{a(this,"AstOutlineManager")}fallbackScopeManager=new v;async readFileOutline(n,t){let i=T(n,t),o=i.includes("://")?i:h.relative(t,i)||i;if(!w(i))throw new Error(`AST outline is not supported for ${o}.`);let r=await N(i);return this.readDocumentOutline(i,t,r.lines)}async readDocumentOutline(n,t,i,o){let r=T(n,t),c=r.includes("://")?r:h.relative(t,r)||r;if(!w(r))throw new Error(`AST outline is not supported for ${c}.`);let s=await E(r,t,i);if(!s)throw new Error(`No AST parser is available for ${c}.`);if(Number.isFinite(this.maxDepth)&&s.rootNode.hasError)throw new Error(`Cannot build an automatic outline from invalid syntax in ${c}.`);let u=i.join(`
1
+ import{b as N}from"./chunk-LEKC4GQK.js";import{a as k,b as E,c as v}from"./chunk-2AY526TN.js";import{f as I,g as S}from"./chunk-35LZOKEW.js";import"./chunk-T4FTT3U4.js";import"./chunk-VDJSH3DQ.js";import{a as b}from"./chunk-ZC65Z3CK.js";import"./chunk-KINKBPPX.js";import{a}from"./chunk-EI7MMDWY.js";import h from"node:path";import{readdir as Y}from"node:fs/promises";import K from"node:path";async function P(e){let n=[],t=await Y(e,{withFileTypes:!0});for(let i of t){let o=K.join(e,i.name);i.isDirectory()?n.push(...await P(o)):(i.isFile()||i.isSymbolicLink())&&n.push(o)}return n}a(P,"collectFiles");var W=new Set([...Object.keys(k),".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".py",".pyi",".rs",".c",".cc",".hh",".hxx",".cpp",".cxx",".h",".hpp",".json",".jsonc",".yaml",".yml",".toml"]),H=new Set([".json",".jsonc",".yaml",".yml",".toml"]),j=new Set(["class_declaration","class_definition","class_specifier","enum_declaration","enum_definition","enum_item","enum_specifier","export_statement","function_declaration","function_definition","function_item","impl_item","interface_declaration","lexical_declaration","namespace_definition","mod_item","public_field_definition","method_definition","method_signature","property_signature","field_declaration","struct_item","struct_specifier","trait_item","type_alias_declaration","type_item","variable_declaration","assignment"]),X=new Set(["module","program","source_file"]),G=new Set(["import_declaration","import_from_statement","import_statement","use_declaration"]),A=new Set(["arrow_function","function_declaration","function_definition","function_item","function_expression","method_definition"]),q=new Set(["public_field_definition","variable_declarator","assignment"]),F=new Set(["field_identifier","identifier","property_identifier","shorthand_property_identifier_pattern","type_identifier"]);function w(e){return W.has(h.extname(e).toLowerCase())}a(w,"isSupportedOutlinePath");var L={failureLabel:"PEEK_FAILED",emptyReason:"no entries to peek.",recovery:['Call peek with { peers: [{ path: "path/to/file.ts" }, ...] }.']},Z={failureLabel:"AST_OUTLINE_FAILED",emptyReason:"no AST outline was produced."};function Ie(e){return S([e],Z)}a(Ie,"formatAstOutline");var M=class{constructor(n=Number.POSITIVE_INFINITY){this.maxDepth=n}static{a(this,"AstOutlineManager")}fallbackScopeManager=new v;async readFileOutline(n,t){let i=T(n,t),o=i.includes("://")?i:h.relative(t,i)||i;if(!w(i))throw new Error(`AST outline is not supported for ${o}.`);let r=await N(i);return this.readDocumentOutline(i,t,r.lines)}async readDocumentOutline(n,t,i,o){let r=T(n,t),c=r.includes("://")?r:h.relative(t,r)||r;if(!w(r))throw new Error(`AST outline is not supported for ${c}.`);let s=await E(r,t,i);if(!s)throw new Error(`No AST parser is available for ${c}.`);if(Number.isFinite(this.maxDepth)&&s.rootNode.hasError)throw new Error(`Cannot build an automatic outline from invalid syntax in ${c}.`);let u=i.join(`
2
2
  `);for(let d=this.maxDepth;;d-=1){let l=await this.createSourceViewBlock(s.rootNode,r,c,t,i,u,h.extname(r).toLowerCase(),void 0,void 0,d);if(o===void 0||o(l)||d<=0||!Number.isFinite(d))return l}}async formatFile(n,t){let i=T(n,t),o=i.includes("://")?i:h.relative(t,i)||i;if(!w(i)){let r=await N(i);return S([z(i,o,r.lines)],L)}try{return S([await this.readFileOutline(i,t)],L)}catch(r){let c=r instanceof Error?r.message:String(r);return S([R(o,c)],L)}}async formatSymbol(n,t){let o=(await P(t)).filter(r=>w(r)).sort();for(let r of o){let c;try{c=await N(r)}catch{continue}let s;try{s=await E(r,t,c.lines)}catch{continue}if(!s)continue;let u=ee(s.rootNode,n);if(!u)continue;let d=h.relative(t,r)||r,l=await this.createSourceViewBlock(u,r,d,t,c.lines,c.content,h.extname(r).toLowerCase(),n,[`defined in: ${d}:${u.startPosition.row+1}`]);return S([l],L)}return S([R("",`symbol not found: ${n}`,"PEEK_NOT_FOUND")],L)}async createSourceViewBlock(n,t,i,o,r,c,s,u,d,l=this.maxDepth){let f=re(n,c,s,l),m=await J(this.fallbackScopeManager,t,o,r),_=Q(m),g=f.map(y=>{let p=y.sourceLine,x=p===void 0?void 0:r[p-1]??"",O=(p===void 0?void 0:_.get(p))?.map(U=>` <!-- ${U} -->`).join("")??"";return I({content:y.content,...!(p===void 0||x===void 0)&&{sourceLine:{source:t,lineNumber:p,content:x}},...O.length>0&&{suffix:O}})});return{path:i,...u!==void 0&&{heading:u},...d!==void 0&&{details:d},startLine:n.startPosition.row+1,endLine:n.endPosition.row+1,totalLines:r.length,renderedLines:g}}};function z(e,n,t){return{path:n,startLine:t.length>0?1:0,endLine:t.length,totalLines:t.length,renderedLines:t.map((i,o)=>I({content:i,sourceLine:{source:e,lineNumber:o+1,content:i}}))}}a(z,"formatUnsupportedSourceBlock");function R(e,n,t="PEEK_FAILED"){return{path:e,startLine:0,endLine:0,totalLines:0,renderedLines:[],status:"failed",error:n,code:t}}a(R,"failedSourceViewBlock");function J(e,n,t,i){return e.getDocumentScopes(n,t,i)}a(J,"getOutlineScopes");function Q(e){let n=new Map;for(let t of e){let i=n.get(t.startLine)??[];i.push(t.beginAnchor.value),n.set(t.startLine,i);let o=n.get(t.endLine)??[];o.push(t.endScopeAnchor.value),n.set(t.endLine,o)}return n}a(Q,"buildScopeMarkers");function T(e,n){return e.startsWith("ssh://")?e:e.startsWith("file://")?decodeURIComponent(e.slice(7)):h.isAbsolute(e)?e:h.resolve(n,e)}a(T,"resolvePath");function ee(e,n){let t,i=a(o=>{if(!t){if(j.has(o.type)&&te(o)===n){t=ne(o);return}for(let r of o.namedChildren)i(r)}},"visit");return i(e),t}a(ee,"findSymbol");function te(e){let n=e.childForFieldName("name");if(n&&F.has(n.type))return n.text;for(let t of e.namedChildren)if(F.has(t.type))return t.text;if(e.type==="lexical_declaration"||e.type==="variable_declaration")return e.namedChildren.find(o=>o.type==="variable_declarator")?.childForFieldName("name")?.text;if(e.type==="function_definition"){let t=e.childForFieldName("declarator");return t?B(t):void 0}}a(te,"getNodeName");function B(e){if(F.has(e.type))return e.text;for(let n of e.namedChildren){let t=B(n);if(t)return t}}a(B,"findNestedName");function ne(e){let n=e.parent;return n&&(n.type==="export_statement"||n.type==="decorated_definition"||n.type==="template_declaration")?n:e}a(ne,"unwrapDeclaration");function re(e,n,t,i){let o=[];H.has(t)?D(e,t,o,i):$(e,t,o,!1,i);let r=ie(n,e.startIndex),c=oe(n,e.endIndex),s=o.filter(l=>l.start>=r&&l.end<=c).sort((l,f)=>f.start-l.start),u=se(n,r,c);for(let l of s){let f=l.start-r,m=l.end-r,_=ae(l);u.splice(f,m-f,..._)}for(;u.length>0&&/\s/u.test(b(u.at(-1)).char);)u.pop();let d=[[]];for(let l of u)l.char===`
3
3
  `?d.push([]):b(d.at(-1)).push(l);return d.map(l=>{let f=[...new Set(l.flatMap(m=>m.sourceLine===void 0?[]:[m.sourceLine]))];return{content:l.map(m=>m.char).join(""),...f.length===1&&{sourceLine:f[0]}}})}a(re,"renderNodeLines");function ie(e,n){return e.lastIndexOf(`
4
4
  `,Math.max(0,n-1))+1}a(ie,"lineStartAt");function oe(e,n){let t=e.indexOf(`