pi-agent-ide 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (403) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +13 -8
  3. package/dist/chunk-3SE372WC.js +3 -0
  4. package/dist/chunk-5MSNYFDE.js +1 -0
  5. package/dist/chunk-5VSE5X5R.js +2 -0
  6. package/dist/chunk-6DZA4CLO.js +4 -0
  7. package/dist/chunk-6EYWFBNG.js +0 -0
  8. package/dist/{chunk-ORAPGW7W.js → chunk-72EEL2DW.js} +1 -1
  9. package/dist/chunk-7JYQMAEL.js +14 -0
  10. package/dist/{chunk-T2RPMEM2.js → chunk-7UGNGK7Y.js} +1 -1
  11. package/dist/{chunk-STUZZM5B.js → chunk-AADJ2KIB.js} +1 -1
  12. package/dist/{chunk-XF5PVZOS.js → chunk-B5KB2I7J.js} +1 -1
  13. package/dist/chunk-DQF5QMJ2.js +1 -0
  14. package/dist/chunk-EJ5OACQM.js +1 -0
  15. package/dist/chunk-GFW5QPQV.js +2 -0
  16. package/dist/{chunk-LQYZG62K.js → chunk-GUTQ3PWL.js} +1 -1
  17. package/dist/chunk-HGPUI7F3.js +1 -0
  18. package/dist/{chunk-OBWZ5RYN.js → chunk-HKMBQLEK.js} +1 -1
  19. package/dist/chunk-ITSNK5YG.js +7 -0
  20. package/dist/chunk-J34VKQGJ.js +1 -0
  21. package/dist/chunk-KAB3AYA2.js +1 -0
  22. package/dist/{chunk-76WHES5H.js → chunk-M5L42DWE.js} +5 -5
  23. package/dist/chunk-M5MJP7Z2.js +1 -0
  24. package/dist/chunk-NMFQGKPE.js +2 -0
  25. package/dist/chunk-NTYXZ3EL.js +3 -0
  26. package/dist/{chunk-P6T3Q7LB.js → chunk-QDST6VIU.js} +1 -1
  27. package/dist/chunk-ROXXK6TW.js +0 -0
  28. package/dist/{chunk-WNMGUALD.js → chunk-TI5GMJ7Q.js} +1 -1
  29. package/dist/{chunk-4ZTEPMJO.js → chunk-TPIHQYK2.js} +1 -1
  30. package/dist/chunk-XSTHESNR.js +25 -0
  31. package/dist/{chunk-THSCUT2L.js → chunk-Y7ZMR4LT.js} +1 -1
  32. package/dist/chunk-YHADTHQM.js +1 -0
  33. package/dist/{chunk-KZBAJFCV.js → chunk-Z3VC3S2T.js} +1 -1
  34. package/dist/{chunk-ZXN3TWWW.js → chunk-ZM4L5AGN.js} +1 -1
  35. package/dist/{chunk-E2RESHYR.js → chunk-ZTYWHL2F.js} +1 -1
  36. package/dist/entry-0.js +1 -1
  37. package/dist/entry-1.js +1 -1
  38. package/dist/entry-10.js +1 -1
  39. package/dist/entry-12.js +1 -1
  40. package/dist/entry-13.js +1 -1
  41. package/dist/entry-14.js +1 -1
  42. package/dist/entry-2.js +1 -1
  43. package/dist/entry-21.js +1 -1
  44. package/dist/entry-24.js +1 -1
  45. package/dist/entry-25.js +1 -1
  46. package/dist/entry-26.js +10 -5
  47. package/dist/entry-28.js +1 -1
  48. package/dist/entry-29.js +1 -1
  49. package/dist/entry-31.js +3 -3
  50. package/dist/entry-32.js +6 -5
  51. package/dist/entry-36.js +1 -1
  52. package/dist/entry-37.js +1 -1
  53. package/dist/entry-38.js +1 -1
  54. package/dist/entry-39.js +1 -1
  55. package/dist/entry-4.js +1 -1
  56. package/dist/entry-40.js +12 -8
  57. package/dist/entry-42.js +1 -1
  58. package/dist/entry-43.js +1 -1
  59. package/dist/entry-44.js +1 -1
  60. package/dist/entry-45.js +4 -4
  61. package/dist/entry-46.js +10 -10
  62. package/dist/entry-47.js +1 -1
  63. package/dist/entry-48.js +1 -1
  64. package/dist/entry-49.js +1 -1
  65. package/dist/entry-50.js +1 -1
  66. package/dist/entry-51.js +1 -1
  67. package/dist/entry-52.js +1 -1
  68. package/dist/entry-53.js +1 -1
  69. package/dist/entry-54.js +1 -0
  70. package/dist/entry-55.js +0 -1
  71. package/dist/entry-56.js +1 -0
  72. package/dist/entry-57.js +0 -1
  73. package/dist/entry-58.js +1 -1
  74. package/dist/entry-59.js +1 -1
  75. package/dist/entry-60.js +1 -1
  76. package/dist/entry-61.js +1 -1
  77. package/dist/entry-62.js +1 -1
  78. package/dist/entry-63.js +1 -0
  79. package/dist/entry-64.js +0 -1
  80. package/dist/entry-65.js +1 -0
  81. package/dist/entry-66.js +0 -1
  82. package/dist/entry-67.js +1 -1
  83. package/dist/entry-68.js +1 -1
  84. package/dist/entry-69.js +1 -59
  85. package/dist/entry-70.js +123 -4
  86. package/dist/entry-71.js +30 -1
  87. package/dist/entry-72.js +2 -29
  88. package/dist/entry-73.js +1 -2
  89. package/dist/entry-74.js +1 -1
  90. package/dist/entry-75.js +1 -1
  91. package/dist/entry-76.js +3 -1
  92. package/dist/entry-77.js +1 -3
  93. package/dist/entry-78.js +1 -1
  94. package/dist/entry-79.js +1 -1
  95. package/dist/pi-agent-ide.js +3 -2
  96. package/docs/configuration.md +32 -11
  97. package/docs/tools.md +17 -0
  98. package/node_modules/pi-agent-doctor/package.json +1 -1
  99. package/node_modules/pi-agent-filesystem/package.json +6 -6
  100. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  101. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  102. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  103. package/node_modules/pi-agent-ide-ast/package.json +9 -9
  104. package/node_modules/pi-agent-ide-ast/src/extension.ts +4 -3
  105. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +68 -45
  106. package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +8 -1
  107. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +83 -5
  108. package/node_modules/pi-agent-ide-changes/index.ts +21 -5
  109. package/node_modules/pi-agent-ide-changes/package.json +6 -6
  110. package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
  111. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +4 -2
  112. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  113. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +26 -8
  114. package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -1
  115. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  116. package/node_modules/pi-agent-ide-lint/index.ts +46 -17
  117. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  118. package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -1
  119. package/node_modules/pi-agent-ide-lsp/index.ts +126 -8
  120. package/node_modules/pi-agent-ide-lsp/package.json +9 -8
  121. package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
  122. package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +18 -3
  123. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +4 -0
  124. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
  125. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
  126. package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
  127. package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
  128. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
  129. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
  130. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
  131. package/node_modules/pi-agent-image/package.json +2 -2
  132. package/node_modules/pi-agent-invariant/package.json +1 -1
  133. package/node_modules/pi-agent-pdf/package.json +2 -2
  134. package/node_modules/pi-agent-read/package.json +6 -6
  135. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  136. package/node_modules/pi-agent-read/src/api/read-parameters.ts +29 -0
  137. package/node_modules/pi-agent-read/src/api/tools/read.ts +73 -1
  138. package/node_modules/pi-agent-read/src/core/read-core.ts +26 -2
  139. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
  140. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
  141. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +64 -14
  142. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
  143. package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
  144. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +73 -44
  145. package/node_modules/pi-agent-resource/package.json +1 -1
  146. package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
  147. package/node_modules/pi-agent-resource/src/resource.ts +2 -0
  148. package/node_modules/pi-agent-search/package.json +3 -3
  149. package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  150. package/node_modules/pi-agent-search/src/api/search-parameters.ts +25 -0
  151. package/node_modules/pi-agent-search/src/api/search.ts +55 -1
  152. package/node_modules/pi-agent-search/src/core/extension.ts +2 -23
  153. package/node_modules/pi-agent-search/src/core/search-core.ts +28 -3
  154. package/node_modules/pi-agent-search-text/index.ts +44 -4
  155. package/node_modules/pi-agent-search-text/package.json +6 -6
  156. package/node_modules/pi-agent-search-text/src/search-session.ts +65 -25
  157. package/node_modules/pi-agent-text/package.json +2 -2
  158. package/node_modules/pi-agent-text/src/text-document.ts +5 -0
  159. package/node_modules/pi-agent-text/src/text-target.ts +4 -0
  160. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  161. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  162. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  163. package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
  164. package/node_modules/pi-agent-text-editor/index.ts +1 -3
  165. package/node_modules/pi-agent-text-editor/package.json +34 -24
  166. package/node_modules/pi-agent-text-editor/runtime/entry-69.js +0 -1
  167. package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
  168. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
  169. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
  170. package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
  171. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
  172. package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +3 -0
  173. package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
  174. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
  175. package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
  176. package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
  177. package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
  178. package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
  179. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +216 -0
  180. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
  181. package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
  182. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
  183. package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +133 -0
  184. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
  185. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
  186. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
  187. package/node_modules/pi-agent-text-editor/src/core/extension.ts +6 -0
  188. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
  189. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +153 -0
  190. package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
  191. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +1 -0
  192. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +6 -1
  193. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
  194. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
  195. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +17 -0
  196. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +212 -51
  197. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +273 -11
  198. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
  199. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -1
  200. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
  201. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
  202. package/node_modules/pi-agent-text-editor-renderer/index.ts +88 -1
  203. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  204. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +42 -25
  205. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +20 -12
  206. package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
  207. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  208. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  209. package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +1 -0
  210. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  211. package/node_modules/pi-agent-web/package.json +7 -7
  212. package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
  213. package/node_modules/pi-agent-web/src/browser-loader.ts +1 -0
  214. package/node_modules/pi-agent-web-html/package.json +3 -3
  215. package/node_modules/pi-agent-web-image/package.json +4 -4
  216. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  217. package/node_modules/pi-agent-web-text/package.json +4 -4
  218. package/package.json +41 -38
  219. package/src/api/plugin-protocol.ts +10 -2
  220. package/src/api/tool-config.ts +73 -2
  221. package/src/code-view/diagnostic-view.ts +22 -3
  222. package/src/composite/builtin-extensions.ts +10 -15
  223. package/src/composite/extensions-config.ts +59 -0
  224. package/src/composite/feature-flags.ts +32 -0
  225. package/src/composite/module-labels.ts +59 -0
  226. package/src/composite/module-settings-store.ts +60 -0
  227. package/src/composite/module-settings.ts +162 -0
  228. package/src/composite/preferences.ts +26 -0
  229. package/src/composite/selection.ts +4 -4
  230. package/src/composite/settings-panel.ts +103 -0
  231. package/src/core/diagnostic-delivery.ts +29 -0
  232. package/src/core/diagnostic-entry.ts +51 -3
  233. package/src/core/diagnostic-store.ts +56 -5
  234. package/src/core/extension.ts +34 -33
  235. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -6
  236. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  237. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  238. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  239. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  240. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  241. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +2 -0
  242. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  243. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  244. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  245. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +2 -0
  246. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +1 -0
  247. package/src/extensions/pi-agent-read/package.json +6 -6
  248. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  249. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +29 -0
  250. package/src/extensions/pi-agent-read/src/api/tools/read.ts +73 -1
  251. package/src/extensions/pi-agent-read/src/core/read-core.ts +26 -2
  252. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
  253. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
  254. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +64 -14
  255. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
  256. package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
  257. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +73 -44
  258. package/src/extensions/pi-agent-search/package.json +3 -3
  259. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +44 -4
  260. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
  261. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +65 -25
  262. package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  263. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +25 -0
  264. package/src/extensions/pi-agent-search/src/api/search.ts +55 -1
  265. package/src/extensions/pi-agent-search/src/core/extension.ts +2 -23
  266. package/src/extensions/pi-agent-search/src/core/search-core.ts +28 -3
  267. package/src/extensions/pi-agent-text-editor/index.ts +1 -3
  268. package/src/extensions/pi-agent-text-editor/package.json +34 -24
  269. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  270. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  271. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  272. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
  273. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +88 -1
  274. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  275. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +42 -25
  276. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +20 -12
  277. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
  278. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  279. package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +0 -1
  280. package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +2 -0
  281. package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
  282. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
  283. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
  284. package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
  285. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
  286. package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +3 -0
  287. package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
  288. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
  289. package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
  290. package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
  291. package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
  292. package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
  293. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +216 -0
  294. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
  295. package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
  296. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
  297. package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +133 -0
  298. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
  299. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
  300. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
  301. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +6 -0
  302. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
  303. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +153 -0
  304. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
  305. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +1 -0
  306. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +6 -1
  307. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
  308. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
  309. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +17 -0
  310. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +212 -51
  311. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +273 -11
  312. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
  313. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -1
  314. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
  315. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
  316. package/src/pi-agent-ide.ts +43 -8
  317. package/src/plugins/pi-agent-ide-ast/package.json +9 -9
  318. package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -3
  319. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +68 -45
  320. package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +8 -1
  321. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +83 -5
  322. package/src/plugins/pi-agent-ide-changes/index.ts +21 -5
  323. package/src/plugins/pi-agent-ide-changes/package.json +6 -6
  324. package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
  325. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +4 -2
  326. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +62 -11
  327. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  328. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +26 -8
  329. package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -1
  330. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  331. package/src/plugins/pi-agent-ide-lint/index.ts +46 -17
  332. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  333. package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -1
  334. package/src/plugins/pi-agent-ide-lsp/index.ts +126 -8
  335. package/src/plugins/pi-agent-ide-lsp/package.json +9 -8
  336. package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
  337. package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +18 -3
  338. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +4 -0
  339. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
  340. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
  341. package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
  342. package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
  343. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
  344. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
  345. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
  346. package/src/plugins/pi-agent-ide-terminal/index.ts +34 -0
  347. package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +238 -0
  348. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +461 -0
  349. package/src/plugins/pi-agent-ide-terminal/src/screen-image.ts +127 -0
  350. package/src/plugins/pi-agent-ide-terminal/src/search.ts +159 -0
  351. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +529 -0
  352. package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +56 -0
  353. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +157 -0
  354. package/src/plugins/pi-agent-ide-terminal/src/types.ts +66 -0
  355. package/src/plugins/pi-agent-ide-terminal/src/ui.ts +336 -0
  356. package/src/post-edit/gate.ts +15 -2
  357. package/dist/chunk-4U6KGABH.js +0 -1
  358. package/dist/chunk-6ACQQBUY.js +0 -7
  359. package/dist/chunk-GFWDXTOB.js +0 -4
  360. package/dist/chunk-JASLOB2X.js +0 -1
  361. package/dist/chunk-JJVXUL5U.js +0 -2
  362. package/dist/chunk-KCEOTU5Z.js +0 -3
  363. package/dist/chunk-KVGQG43U.js +0 -1
  364. package/dist/chunk-QJFRAMK7.js +0 -2
  365. package/dist/chunk-RAZOACDD.js +0 -2
  366. package/dist/chunk-RIGRP3FD.js +0 -1
  367. package/dist/chunk-VCCMVQXU.js +0 -1
  368. package/dist/chunk-X6MPU7UO.js +0 -3
  369. package/dist/chunk-YPHXLAQF.js +0 -1
  370. package/dist/entry-80.js +0 -1
  371. package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +0 -14
  372. package/node_modules/pi-agent-text-editor-argument-order/index.ts +0 -26
  373. package/node_modules/pi-agent-text-editor-argument-order/package.json +0 -16
  374. package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
  375. package/node_modules/pi-agent-text-editor-overwrite/index.ts +0 -365
  376. package/node_modules/pi-agent-text-editor-overwrite/package.json +0 -17
  377. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
  378. package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +0 -1
  379. package/node_modules/pi-agent-web-text/runtime/entry-80.js +0 -2
  380. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +0 -2
  381. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +0 -2
  382. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +0 -26
  383. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +0 -16
  384. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-70.js +0 -2
  385. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
  386. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +0 -365
  387. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +0 -17
  388. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
  389. package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +0 -14
  390. /package/dist/{chunk-3H2EU7VQ.js → chunk-4U2GUKNJ.js} +0 -0
  391. /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-70.js +0 -0
  392. /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
  393. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
  394. /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-74.js +0 -0
  395. /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-76.js +0 -0
  396. /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
  397. /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
  398. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
  399. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
  400. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
  401. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
  402. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
  403. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
package/dist/entry-31.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as T}from"./chunk-WZI4YC2O.js";import{a as A}from"./chunk-ERVMDQGX.js";import{a as $,b as I}from"./chunk-VFBLX4TG.js";import{a as j}from"./chunk-OBWZ5RYN.js";import{a as b,b as L}from"./chunk-KZBAJFCV.js";import{b as P,f as R,h as E,i as w,j as S,m as D}from"./chunk-KVGQG43U.js";import"./chunk-N34ATN52.js";import{a as u}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import x from"node:path";import{fileURLToPath as K}from"node:url";function O(t,e){if(t.trim().length===0)return[];switch(e.format){case"pi-json":return F(t);case"eslint-json":return J(t);case"sarif":return V(t);case"checkstyle":return W(t);case"gcc":case"clang":return G(t);case"regex":return Z(t,u(e.pattern),e.columnBase??1)}}s(O,"parseDiagnostics");function F(t){let e=JSON.parse(t);return Array.isArray(e.diagnostics)?e.diagnostics.flatMap(p):[]}s(F,"parsePiJson");function J(t){return JSON.parse(t).flatMap(n=>Array.isArray(n.messages)?n.messages.flatMap(i=>p(i).map(r=>({...r,...n.filePath&&{file:n.filePath}}))):[])}s(J,"parseEslintJson");function V(t){return(JSON.parse(t).runs??[]).flatMap(n=>(n.results??[]).flatMap(i=>{let r=i.locations?.[0]?.physicalLocation,c=r?.region??{},o=i.message;return p({file:r?.artifactLocation?.uri,line:c.startLine,column:c.startColumn,message:o?.text,code:i.ruleId,severity:U(i.level)})}))}s(V,"parseSarif");function W(t){let e=[];for(let n of t.matchAll(/<file\s+([^>]+)>([\s\S]*?)<\/file>/gu)){let i=N(u(n[1])).name;for(let r of u(n[2]).matchAll(/<error\s+([^>]+?)\/?>(?:<\/error>)?/gu)){let c=N(u(r[1]));e.push(...p({file:i,line:Number(c.line),column:Number(c.column??1),message:c.message,code:c.source,severity:c.severity}))}}return e}s(W,"parseCheckstyle");function N(t){return Object.fromEntries([...t.matchAll(/([\w-]+)="([^"]*)"/gu)].map(e=>[u(e[1]),X(u(e[2]))]))}s(N,"xmlAttributes");function G(t){return B(t,/^(?<file>.+?):(?<line>\d+):(?<column>\d+):\s*(?<severity>fatal error|error|warning|note|info|hint):\s*(?<message>.*?)(?:\s+\[(?<code>[^\]]+)\])?$/u)}s(G,"parseCompilerLines");function Z(t,e,n){return[...t.replaceAll(`\r
1
+ import{a as O}from"./chunk-ERVMDQGX.js";import{a as T,b as N}from"./chunk-VFBLX4TG.js";import{a as L}from"./chunk-HKMBQLEK.js";import{a as j,b as P}from"./chunk-Z3VC3S2T.js";import{b as E,c as S,g as D,i as $,j as w,k as I,n as A}from"./chunk-M5MJP7Z2.js";import{a as R}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import{a as g}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import oe from"node:path";var p=[c("dart-analyze",["dart"],["dart"],["analysis_options.yaml","pubspec.yaml"],[".dart"],["dart","analyze","--format","machine","{file}"],"regex","https://dart.dev/tools/dart-analyze","^(?<severity>[^|]+)\\|[^|]+\\|(?<code>[^|]+)\\|(?<file>[^|]+)\\|(?<line>\\d+)\\|(?<column>\\d+)\\|\\d+\\|(?<message>.*)$",void 0,[0,1,2,3]),c("zig-ast-check",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","ast-check","{file}"],"gcc","https://ziglang.org/documentation/master/"),c("lintr",["r"],["Rscript"],[".lintr","DESCRIPTION"],[".r"],["Rscript","-e","print(lintr::lint(commandArgs(TRUE)[1]))","{file}"],"regex","https://lintr.r-lib.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[^:]+): \\[(?<code>[^\\]]+)\\] (?<message>.*)$"),c("clang-tidy",["c","cpp"],["clang-tidy"],[".clang-tidy","compile_commands.json"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-tidy","{file}"],"clang","https://clang.llvm.org/extra/clang-tidy/"),c("eslint",["javascript","typescript","vue","svelte"],["eslint"],["eslint.config.js","eslint.config.mjs","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts",".eslintrc",".eslintrc.json",".eslintrc.js",".eslintrc.cjs",".eslintrc.yaml",".eslintrc.yml"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".vue",".svelte"],["eslint","--format","json","{file}"],"eslint-json","https://eslint.org/docs/latest/",void 0,["eslint"]),c("oxlint",["javascript","typescript"],["oxlint"],[".oxlintrc.json",".oxlintrc.jsonc","oxlint.config.ts","oxlint.config.mts"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts"],["oxlint","--format","sarif","{file}"],"sarif","https://oxc.rs/docs/guide/usage/linter.html",void 0,["oxlint"]),c("ruff",["python"],["ruff"],["pyproject.toml","ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","check","--output-format","concise","{file}"],"regex","https://docs.astral.sh/ruff/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<code>\\S+) (?<message>.+)$",["ruff"]),c("golangci-lint",["go"],["golangci-lint"],[".golangci.yml",".golangci.yaml","go.mod"],[".go"],["golangci-lint","run","--output.text.path=","--output.checkstyle.path=stdout","--show-stats=false","./..."],"checkstyle","https://golangci-lint.run/"),c("clippy",["rust"],["cargo"],["Cargo.toml","clippy.toml"],[".rs"],["cargo","clippy","--message-format","short"],"gcc","https://doc.rust-lang.org/clippy/"),c("dotnet-format",["csharp"],["dotnet"],[".editorconfig","global.json"],[".cs"],["dotnet","format","--verify-no-changes","--include","{relativeFile}"],"regex","https://learn.microsoft.com/dotnet/core/tools/dotnet-format","^(?<file>.+)\\((?<line>\\d+),(?<column>\\d+)\\): (?<severity>error|warning) (?<code>[^:]+): (?<message>.*?)(?: \\[.*\\])?$",void 0,[0,2]),c("checkstyle",["java"],["checkstyle"],["checkstyle.xml","pom.xml"],[".java"],["checkstyle","-c","checkstyle.xml","-f","xml","{file}"],"checkstyle","https://checkstyle.org/"),c("detekt",["kotlin"],["detekt"],["detekt.yml","build.gradle.kts"],[".kt",".kts"],["detekt","--input","{file}","--config","detekt.yml"],"regex","https://detekt.dev/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<message>.*?) \\[(?<code>[^\\]]+)\\]$",void 0,[0,2]),c("rubocop",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--format","clang","{file}"],"regex","https://docs.rubocop.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?:\\[Correctable\\] )?(?<code>[^:]+): (?<message>.*)$"),c("phpcs",["php"],["phpcs"],["phpcs.xml","phpcs.xml.dist","composer.json"],[".php"],["phpcs","--report=checkstyle","{file}"],"checkstyle","https://github.com/PHPCSStandards/PHP_CodeSniffer",void 0,void 0,[0,1,2,3]),c("swiftlint",["swift"],["swiftlint"],[".swiftlint.yml","Package.swift"],[".swift"],["swiftlint","lint","--quiet","--reporter","checkstyle","{file}"],"checkstyle","https://github.com/realm/SwiftLint",void 0,void 0,[0,2]),c("scalafix",["scala"],["scalafix"],[".scalafix.conf"],[".scala",".sc"],["scalafix","--check","--files","{file}"],"gcc","https://scalacenter.github.io/scalafix/",void 0,void 0,[0,2,64,66]),c("credo",["elixir"],["mix"],["mix.exs",".credo.exs"],[".ex",".exs"],["mix","credo","--strict","--format","flycheck","--files-included","{file}"],"regex","https://hexdocs.pm/credo/","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?<message>.+)$",void 0,Array.from({length:32},(t,e)=>e)),c("psscriptanalyzer",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};Invoke-ScriptAnalyzer -Path $args[0] @options | ForEach-Object {"$($_.ScriptPath):$($_.Line):$($_.Column): $($_.Severity): $($_.Message) [$($_.RuleName)]"}',"{file}"],"regex","https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-scriptanalyzer","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>\\w+): (?<message>.+) \\[(?<code>[^\\]]+)\\]$",void 0,[0]),c("luacheck",["lua"],["luacheck"],[".luacheckrc"],[".lua"],["luacheck","--formatter","plain","--codes","--no-color","{file}"],"regex","https://github.com/lunarmodules/luacheck","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): \\((?<code>(?<severity>[WE])\\d+)\\) (?<message>.+)$",void 0,[0,1,2]),c("shellcheck",["shell"],["shellcheck"],[".shellcheckrc"],[".sh",".bash",".zsh"],["shellcheck","-f","gcc","{file}"],"gcc","https://www.shellcheck.net/"),c("stylelint",["css"],["stylelint"],["stylelint.config.js",".stylelintrc.json"],[".css",".scss",".sass",".less"],["stylelint","--formatter","compact","{file}"],"regex","https://stylelint.io/","^(?<file>.+): line (?<line>\\d+), col (?<column>\\d+), (?<severity>error|warning) - (?<message>.+) \\((?<code>[^)]+)\\)$",["stylelint"],[0,2]),c("yamllint",["yaml"],["yamllint"],[".yamllint",".yamllint.yml"],[".yaml",".yml"],["yamllint","-f","parsable","{file}"],"regex","https://yamllint.readthedocs.io/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): \\[(?<severity>[^\\]]+)\\] (?<message>.*?) \\((?<code>[^)]+)\\)$"),c("markdownlint",["markdown"],["markdownlint"],[".markdownlint.json",".markdownlint.yaml"],[".md",".mdx"],["markdownlint","{file}"],"regex","https://github.com/DavidAnson/markdownlint","^(?<file>.+?):(?<line>\\d+)(?::(?<column>\\d+))? (?<severity>error|warning) (?<code>MD\\d+)(?:/\\S+)? (?<message>.*)$"),c("sqlfluff",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","lint","--format","sarif","{file}"],"sarif","https://docs.sqlfluff.com/"),c("hadolint",["dockerfile"],["hadolint"],[".hadolint.yaml"],[".dockerfile"],["hadolint","--format","checkstyle","{file}"],"checkstyle","https://github.com/hadolint/hadolint",void 0,void 0,[0,1],void 0,["Dockerfile","Containerfile"]),c("tflint",["terraform"],["tflint"],[".tflint.hcl"],[".tf"],["tflint","--format","checkstyle"],"checkstyle","https://github.com/terraform-linters/tflint",void 0,void 0,[0,2]),c("cmake-lint",["cmake"],["cmake-lint"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-lint","{file}"],"regex","https://cmake-format.readthedocs.io/","^(?<file>.+?):(?<line>\\d+),(?<column>\\d+): \\[(?<code>(?<severity>[A-Z])\\d+)\\] (?<message>.*)$",void 0,[0,1],0,["CMakeLists.txt"]),c("htmlhint",["html"],["htmlhint"],[".htmlhintrc"],[".html",".htm"],["htmlhint","--format","checkstyle","--nocolor","{file}"],"checkstyle","https://htmlhint.com/"),c("jsonlint",["json"],["jsonlint"],[".jsonlintrc",".jsonlintrc.json",".jsonlintrc.yaml",".jsonlintrc.yml",".jsonlintrc.js",".jsonlintrc.cjs","jsonlint.config.js","jsonlint.config.cjs"],[".json"],["jsonlint","-q","{file}"],"regex","https://github.com/prantlf/jsonlint","^(?:Error: )?(?<message>Parse (?<severity>error) on line (?<line>\\d+)(?:, column (?<column>\\d+))?:[^\\n]*)$",["@prantlf/jsonlint","jsonlint"]),c("taplo-check",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","check","--colors","never","{file}"],"regex","https://taplo.tamasfe.dev/","^(?<severity>error): (?<message>[^\\n]+)\\n\\s*\u250C\u2500 (?<file>.+):(?<line>\\d+):(?<column>\\d+)"),c("xmllint",["xml"],["xmllint"],[".xmllintrc"],[".xml",".xsd",".xsl"],["xmllint","--noout","{file}"],"regex","https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html","^(?<file>.+?):(?<line>\\d+): (?<severity>(?:parser |validity )?(?:error|warning)) : (?<message>.*)$",void 0,[0,1,2,3,4])];function c(t,e,n,i,r,f,s,l,o,d,x=[0,1],u,h){return{id:t,name:t,kind:"linter",languages:e,executables:n,configFiles:i,documentation:l,...d&&{dependencies:d},linter:{extensions:r,...h&&{fileNames:h},check:{command:f,successExitCodes:x},diagnostics:{format:s,...o&&{pattern:o},...u!==void 0&&{columnBase:u}}}}}a(c,"recipe");import b from"node:path";import{fileURLToPath as Y}from"node:url";function M(t,e){if(t.trim().length===0)return[];switch(e.format){case"pi-json":return V(t);case"eslint-json":return B(t);case"sarif":return G(t);case"checkstyle":return W(t);case"gcc":case"clang":return Z(t);case"regex":return H(t,g(e.pattern),e.columnBase??1)}}a(M,"parseDiagnostics");function V(t){let e=JSON.parse(t);return Array.isArray(e.diagnostics)?e.diagnostics.flatMap(y):[]}a(V,"parsePiJson");function B(t){return JSON.parse(t).flatMap(n=>Array.isArray(n.messages)?n.messages.flatMap(i=>y(i).map(r=>({...r,...n.filePath&&{file:n.filePath}}))):[])}a(B,"parseEslintJson");function G(t){return(JSON.parse(t).runs??[]).flatMap(n=>(n.results??[]).flatMap(i=>{let r=i.locations?.[0]?.physicalLocation,f=r?.region??{},s=i.message;return y({file:r?.artifactLocation?.uri,line:f.startLine,column:f.startColumn,message:s?.text,code:i.ruleId,severity:K(i.level)})}))}a(G,"parseSarif");function W(t){let e=[];for(let n of t.matchAll(/<file\s+([^>]+)>([\s\S]*?)<\/file>/gu)){let i=z(g(n[1])).name;for(let r of g(n[2]).matchAll(/<error\s+([^>]+?)\/?>(?:<\/error>)?/gu)){let f=z(g(r[1]));e.push(...y({file:i,line:Number(f.line),column:Number(f.column??1),message:f.message,code:f.source,severity:f.severity}))}}return e}a(W,"parseCheckstyle");function z(t){return Object.fromEntries([...t.matchAll(/([\w-]+)="([^"]*)"/gu)].map(e=>[g(e[1]),Q(g(e[2]))]))}a(z,"xmlAttributes");function Z(t){return U(t,/^(?<file>.+?):(?<line>\d+):(?<column>\d+):\s*(?<severity>fatal error|error|warning|note|info|hint):\s*(?<message>.*?)(?:\s+\[(?<code>[^\]]+)\])?$/u)}a(Z,"parseCompilerLines");function H(t,e,n){return[...t.replaceAll(`\r
2
2
  `,`
3
- `).matchAll(new RegExp(e,"gmu"))].flatMap(i=>i.groups===void 0?[]:p({...i.groups,...i.groups.column!==void 0&&{column:Number(i.groups.column)+(1-n)}}))}s(Z,"parseRegexLines");function B(t,e){return t.split(/\r?\n/u).flatMap(n=>{let i=n.match(e)?.groups;return i===void 0?[]:p(i)})}s(B,"parseMatchingLines");function p(t){if(typeof t!="object"||t===null)return[];let e=t,n=z(e.line??e.startLine),i=z(e.column??e.startColumn,1),r=typeof e.message=="string"?e.message:void 0;return n===void 0||r===void 0?[]:[{...typeof e.file=="string"&&{file:e.file},code:_(e.code??e.ruleId,"lint"),message:r,line:n,column:i??1,severity:H(e.severity)}]}s(p,"normalizeDiagnostic");function z(t,e){let n=typeof t=="string"?Number.parseInt(t,10):t;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:e}s(z,"numberValue");function _(t,e){return typeof t=="string"||typeof t=="number"?String(t):e}s(_,"stringValue");function H(t){if(t===2)return"error";if(t===1)return"warning";let e=_(t,"warning").toLowerCase();return e.includes("error")||e==="e"||e==="f"||e==="fatal"?"error":e==="info"||e==="note"||e==="notice"?"info":e==="hint"?"hint":"warning"}s(H,"severityValue");function U(t){return t==="error"||t==="warning"||t==="note"?t:"warning"}s(U,"sarifSeverity");function X(t){return t.replace(/&#(x[0-9a-f]+|\d+);/giu,(e,n)=>{let i=n.toLowerCase().startsWith("x")?Number.parseInt(n.slice(1),16):Number(n);return i<=1114111?String.fromCodePoint(i):e}).replaceAll("&quot;",'"').replaceAll("&apos;","'").replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&")}s(X,"decodeXml");var C=[a("dart-analyze",["dart"],["dart"],["analysis_options.yaml","pubspec.yaml"],[".dart"],["dart","analyze","--format","machine","{file}"],"regex","https://dart.dev/tools/dart-analyze","^(?<severity>[^|]+)\\|[^|]+\\|(?<code>[^|]+)\\|(?<file>[^|]+)\\|(?<line>\\d+)\\|(?<column>\\d+)\\|\\d+\\|(?<message>.*)$",void 0,[0,1,2,3]),a("zig-ast-check",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","ast-check","{file}"],"gcc","https://ziglang.org/documentation/master/"),a("lintr",["r"],["Rscript"],[".lintr","DESCRIPTION"],[".r"],["Rscript","-e","print(lintr::lint(commandArgs(TRUE)[1]))","{file}"],"regex","https://lintr.r-lib.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[^:]+): \\[(?<code>[^\\]]+)\\] (?<message>.*)$"),a("clang-tidy",["c","cpp"],["clang-tidy"],[".clang-tidy","compile_commands.json"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-tidy","{file}"],"clang","https://clang.llvm.org/extra/clang-tidy/"),a("eslint",["javascript","typescript","vue","svelte"],["eslint"],["eslint.config.js","eslint.config.mjs","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts",".eslintrc",".eslintrc.json",".eslintrc.js",".eslintrc.cjs",".eslintrc.yaml",".eslintrc.yml"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".vue",".svelte"],["eslint","--format","json","{file}"],"eslint-json","https://eslint.org/docs/latest/",void 0,["eslint"]),a("oxlint",["javascript","typescript"],["oxlint"],[".oxlintrc.json",".oxlintrc.jsonc","oxlint.config.ts","oxlint.config.mts"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts"],["oxlint","--format","sarif","{file}"],"sarif","https://oxc.rs/docs/guide/usage/linter.html",void 0,["oxlint"]),a("ruff",["python"],["ruff"],["pyproject.toml","ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","check","--output-format","concise","{file}"],"regex","https://docs.astral.sh/ruff/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<code>\\S+) (?<message>.+)$",["ruff"]),a("golangci-lint",["go"],["golangci-lint"],[".golangci.yml",".golangci.yaml","go.mod"],[".go"],["golangci-lint","run","--output.text.path=","--output.checkstyle.path=stdout","--show-stats=false","./..."],"checkstyle","https://golangci-lint.run/"),a("clippy",["rust"],["cargo"],["Cargo.toml","clippy.toml"],[".rs"],["cargo","clippy","--message-format","short"],"gcc","https://doc.rust-lang.org/clippy/"),a("dotnet-format",["csharp"],["dotnet"],[".editorconfig","global.json"],[".cs"],["dotnet","format","--verify-no-changes","--include","{relativeFile}"],"regex","https://learn.microsoft.com/dotnet/core/tools/dotnet-format","^(?<file>.+)\\((?<line>\\d+),(?<column>\\d+)\\): (?<severity>error|warning) (?<code>[^:]+): (?<message>.*?)(?: \\[.*\\])?$",void 0,[0,2]),a("checkstyle",["java"],["checkstyle"],["checkstyle.xml","pom.xml"],[".java"],["checkstyle","-c","checkstyle.xml","-f","xml","{file}"],"checkstyle","https://checkstyle.org/"),a("detekt",["kotlin"],["detekt"],["detekt.yml","build.gradle.kts"],[".kt",".kts"],["detekt","--input","{file}","--config","detekt.yml"],"regex","https://detekt.dev/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<message>.*?) \\[(?<code>[^\\]]+)\\]$",void 0,[0,2]),a("rubocop",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--format","clang","{file}"],"regex","https://docs.rubocop.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?:\\[Correctable\\] )?(?<code>[^:]+): (?<message>.*)$"),a("phpcs",["php"],["phpcs"],["phpcs.xml","phpcs.xml.dist","composer.json"],[".php"],["phpcs","--report=checkstyle","{file}"],"checkstyle","https://github.com/PHPCSStandards/PHP_CodeSniffer",void 0,void 0,[0,1,2,3]),a("swiftlint",["swift"],["swiftlint"],[".swiftlint.yml","Package.swift"],[".swift"],["swiftlint","lint","--quiet","--reporter","checkstyle","{file}"],"checkstyle","https://github.com/realm/SwiftLint",void 0,void 0,[0,2]),a("scalafix",["scala"],["scalafix"],[".scalafix.conf"],[".scala",".sc"],["scalafix","--check","--files","{file}"],"gcc","https://scalacenter.github.io/scalafix/",void 0,void 0,[0,2,64,66]),a("credo",["elixir"],["mix"],["mix.exs",".credo.exs"],[".ex",".exs"],["mix","credo","--strict","--format","flycheck","--files-included","{file}"],"regex","https://hexdocs.pm/credo/","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?<message>.+)$",void 0,Array.from({length:32},(t,e)=>e)),a("psscriptanalyzer",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};Invoke-ScriptAnalyzer -Path $args[0] @options | ForEach-Object {"$($_.ScriptPath):$($_.Line):$($_.Column): $($_.Severity): $($_.Message) [$($_.RuleName)]"}',"{file}"],"regex","https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-scriptanalyzer","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>\\w+): (?<message>.+) \\[(?<code>[^\\]]+)\\]$",void 0,[0]),a("luacheck",["lua"],["luacheck"],[".luacheckrc"],[".lua"],["luacheck","--formatter","plain","--codes","--no-color","{file}"],"regex","https://github.com/lunarmodules/luacheck","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): \\((?<code>(?<severity>[WE])\\d+)\\) (?<message>.+)$",void 0,[0,1,2]),a("shellcheck",["shell"],["shellcheck"],[".shellcheckrc"],[".sh",".bash",".zsh"],["shellcheck","-f","gcc","{file}"],"gcc","https://www.shellcheck.net/"),a("stylelint",["css"],["stylelint"],["stylelint.config.js",".stylelintrc.json"],[".css",".scss",".sass",".less"],["stylelint","--formatter","compact","{file}"],"regex","https://stylelint.io/","^(?<file>.+): line (?<line>\\d+), col (?<column>\\d+), (?<severity>error|warning) - (?<message>.+) \\((?<code>[^)]+)\\)$",["stylelint"],[0,2]),a("yamllint",["yaml"],["yamllint"],[".yamllint",".yamllint.yml"],[".yaml",".yml"],["yamllint","-f","parsable","{file}"],"regex","https://yamllint.readthedocs.io/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): \\[(?<severity>[^\\]]+)\\] (?<message>.*?) \\((?<code>[^)]+)\\)$"),a("markdownlint",["markdown"],["markdownlint"],[".markdownlint.json",".markdownlint.yaml"],[".md",".mdx"],["markdownlint","{file}"],"regex","https://github.com/DavidAnson/markdownlint","^(?<file>.+?):(?<line>\\d+)(?::(?<column>\\d+))? (?<severity>error|warning) (?<code>MD\\d+)(?:/\\S+)? (?<message>.*)$"),a("sqlfluff",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","lint","--format","sarif","{file}"],"sarif","https://docs.sqlfluff.com/"),a("hadolint",["dockerfile"],["hadolint"],[".hadolint.yaml"],[".dockerfile"],["hadolint","--format","checkstyle","{file}"],"checkstyle","https://github.com/hadolint/hadolint",void 0,void 0,[0,1],void 0,["Dockerfile","Containerfile"]),a("tflint",["terraform"],["tflint"],[".tflint.hcl"],[".tf"],["tflint","--format","checkstyle"],"checkstyle","https://github.com/terraform-linters/tflint",void 0,void 0,[0,2]),a("cmake-lint",["cmake"],["cmake-lint"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-lint","{file}"],"regex","https://cmake-format.readthedocs.io/","^(?<file>.+?):(?<line>\\d+),(?<column>\\d+): \\[(?<code>(?<severity>[A-Z])\\d+)\\] (?<message>.*)$",void 0,[0,1],0,["CMakeLists.txt"]),a("htmlhint",["html"],["htmlhint"],[".htmlhintrc"],[".html",".htm"],["htmlhint","--format","checkstyle","--nocolor","{file}"],"checkstyle","https://htmlhint.com/"),a("jsonlint",["json"],["jsonlint"],[".jsonlintrc",".jsonlintrc.json",".jsonlintrc.yaml",".jsonlintrc.yml",".jsonlintrc.js",".jsonlintrc.cjs","jsonlint.config.js","jsonlint.config.cjs"],[".json"],["jsonlint","-q","{file}"],"regex","https://github.com/prantlf/jsonlint","^(?:Error: )?(?<message>Parse (?<severity>error) on line (?<line>\\d+)(?:, column (?<column>\\d+))?:[^\\n]*)$",["@prantlf/jsonlint","jsonlint"]),a("taplo-check",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","check","--colors","never","{file}"],"regex","https://taplo.tamasfe.dev/","^(?<severity>error): (?<message>[^\\n]+)\\n\\s*\u250C\u2500 (?<file>.+):(?<line>\\d+):(?<column>\\d+)"),a("xmllint",["xml"],["xmllint"],[".xmllintrc"],[".xml",".xsd",".xsl"],["xmllint","--noout","{file}"],"regex","https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html","^(?<file>.+?):(?<line>\\d+): (?<severity>(?:parser |validity )?(?:error|warning)) : (?<message>.*)$",void 0,[0,1,2,3,4])];function a(t,e,n,i,r,c,o,d,l,f,y=[0,1],h,g){return{id:t,name:t,kind:"linter",languages:e,executables:n,configFiles:i,documentation:d,...f&&{dependencies:f},linter:{extensions:r,...g&&{fileNames:g},check:{command:c,successExitCodes:y},diagnostics:{format:o,...l&&{pattern:l},...h!==void 0&&{columnBase:h}}}}}s(a,"recipe");var m=class t{constructor(e,n,i=new Map){this.linters=e;this.availableBuiltIns=n;this.evidence=i}static{s(this,"LintCommandRegistry")}static async fromDirectory(e,n={}){let i=await R(e,"linters",l=>D(l).linters,n),r=n.environment??process.env,c=await Promise.all(i.entries.filter(l=>l.layer==="built-in").map(async l=>({id:l.id,available:await w(l.config.check,e,r)}))),o=await T(e,C),d=[...i.entries].sort((l,f)=>l.layer==="built-in"&&f.layer==="built-in"?(o.get(f.id)?.score??0)-(o.get(l.id)?.score??0):0);return new t(d,new Set(c.filter(l=>l.available).map(l=>l.id)),o)}static fromConfig(e){return new t(Object.entries(e.linters).map(([n,i])=>({id:n,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(e,n){return this.resolveEntry(e,n)?.config}resolveEntry(e,n){return E(this.linters,this.availableBuiltIns,this.evidence,e,n)}get entries(){return this.linters}};async function k(t,e){let n;try{n=await S(t.check,e)}catch(d){return{ok:!1,diagnostics:[],failure:`command could not start: ${d instanceof Error?d.message:String(d)}`}}let i=t.diagnostics.format==="regex"||t.diagnostics.format==="clang"?[n.stdout,n.stderr].filter(d=>d.trim().length>0).join(`
4
- `):n.stdout.trim().length>0?n.stdout:n.stderr,r;try{r=O(i,t.diagnostics)}catch{return{ok:!1,diagnostics:[],failure:`invalid ${t.diagnostics.format} diagnostics: ${i.trim().slice(0,200)||"empty command output"}`}}let c=n.ok&&(n.exitCode===0||r.length>0),o=t.check.cwd==="file"?x.dirname(e.filePath):e.projectRoot;return r=r.filter(d=>{if(d.file===void 0)return!0;let l=d.file.startsWith("file:")?K(d.file):d.file;return x.resolve(o,l)===x.resolve(e.filePath)}).map(({file:d,...l})=>l),{ok:c,diagnostics:r,...!c&&{failure:n.stderr.trim().slice(0,200)||`command exited with code ${String(n.exitCode)}`}}}s(k,"runConfiguredLinter");function M(t){return{kind:"linter",name:"command-lint",priority:100,extensions:["*"],detect:s(()=>Promise.resolve(!0),"detect"),async lint({filePath:e,fix:n},i){let r=t.resolve(e,i.cwd);if(r===void 0)return{ok:!0,diagnostics:[]};let c=n===!0&&r.fix!==void 0?r.fix:r.check,o=await k({...r,check:c},{projectRoot:i.cwd,filePath:e});return{ok:o.ok,diagnostics:o.diagnostics}}}}s(M,"createCommandLinter");import{copyFile as Q,mkdtemp as Y,rm as ee}from"node:fs/promises";import v from"node:path";var q={protocol:$,apiVersion:1,id:"lint",setup(t){for(let e of C)t.addToolRecipe(e);t.addSetupCheck({id:"effective-config",inspect:te}),t.addCheck({id:"config",title:"Linter",async run(e){try{let n=await m.fromDirectory(e.cwd,{environment:e.env}),i=ne(n,e.files,e.cwd);return i.length===0?[{status:"skip",message:"No linter matches the inspected project files"}]:await Promise.all(i.map(async({entry:r,source:c})=>{let o=`${r.id} [${r.layer}] command ${JSON.stringify(r.config.check.command)}`,d=await Y(v.join(v.dirname(c),".pi-agent-ide-doctor-")),l=v.join(d,v.basename(c));try{await Q(c,l);let f=await k(r.config,{projectRoot:e.cwd,filePath:l,env:e.env});return f.ok?{status:"pass",message:`${o}: probe passed`,detail:r.sourcePath}:{status:"fail",message:`${o}: probe failed`,detail:f.failure??r.sourcePath}}catch(f){return{status:"fail",message:`${o}: ${f instanceof Error?f.message:String(f)}`,detail:r.sourcePath}}finally{await ee(d,{recursive:!0,force:!0})}}))}catch(n){return[{status:"fail",message:n instanceof Error?n.message:String(n)}]}}})}};async function te(t){try{let e=await m.fromDirectory(t.cwd,{environment:t.env}),n=[],i=new Map;for(let[r,c]of t.detectedLanguages){let o=c.map(d=>e.resolveEntry(d,t.cwd)).find(d=>d!==void 0);o!==void 0&&(n.push({kind:"linter",languageId:r,toolId:o.id}),await w(o.config.check,t.cwd,t.env)||i.set(o.id,{id:`linter-${o.id}-unavailable`,message:`Configured linter ${o.id} cannot run ${JSON.stringify(o.config.check.command)}`}))}return{selections:n,actions:[...i.values()]}}catch(e){return{actions:[{id:"linter-config-invalid",message:`Linter configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}s(te,"inspectLinterSetup");function ne(t,e,n){let i=new Map;for(let r of e){let c=t.resolveEntry(r,n);c!==void 0&&!i.has(c.id)&&i.set(c.id,{entry:c,source:r})}return[...i.values()]}s(ne,"applicableLinters");async function ie(t){let e,n,i=s(o=>((n===void 0||e!==o)&&(e=o,n=re(o)),n),"registryFor"),r={kind:"linter",name:"pi-agent-ide-lint",priority:200,extensions:["*"],detect:s(async o=>(await i(o.cwd),!0),"detect"),async lint(o,d){let l=await i(d.cwd);return M(l).lint(o,d)}},c={protocol:b,apiVersion:3,id:"lint",setup(o){o.addTool(r),o.addDiagnosticSource({id:"lint",async diagnose(d,l){let f=await i(l.cwd);l.signal.throwIfAborted();let y=f.resolve(d,l.cwd);if(!y)return{status:"unavailable",diagnostics:[],reason:"No linter configured for this file"};let h=P(y.check.command),g=await k(y,{projectRoot:l.cwd,filePath:d,signal:l.signal});return!g.ok&&g.diagnostics.length===0?{status:"unavailable",diagnostics:[],reason:g.failure??"Lint check failed",source:h}:{status:"ready",diagnostics:g.diagnostics,source:h}}})}};await Promise.all([j(t,c),A(t,q)])}s(ie,"registerLint");async function re(t){let e=process.env.PI_AGENT_IDE_CONFIG_DIR??t;return m.fromDirectory(e)}s(re,"loadRegistry");export{ie as default};
3
+ `).matchAll(new RegExp(e,"gmu"))].flatMap(i=>i.groups===void 0?[]:y({...i.groups,...i.groups.column!==void 0&&{column:Number(i.groups.column)+(1-n)}}))}a(H,"parseRegexLines");function U(t,e){return t.split(/\r?\n/u).flatMap(n=>{let i=n.match(e)?.groups;return i===void 0?[]:y(i)})}a(U,"parseMatchingLines");function y(t){if(typeof t!="object"||t===null)return[];let e=t,n=_(e.line??e.startLine),i=_(e.column??e.startColumn,1),r=typeof e.message=="string"?e.message:void 0;return n===void 0||r===void 0?[]:[{...typeof e.file=="string"&&{file:e.file},code:q(e.code??e.ruleId,"lint"),message:r,line:n,column:i??1,severity:X(e.severity)}]}a(y,"normalizeDiagnostic");function _(t,e){let n=typeof t=="string"?Number.parseInt(t,10):t;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:e}a(_,"numberValue");function q(t,e){return typeof t=="string"||typeof t=="number"?String(t):e}a(q,"stringValue");function X(t){if(t===2)return"error";if(t===1)return"warning";let e=q(t,"warning").toLowerCase();return e.includes("error")||e==="e"||e==="f"||e==="fatal"?"error":e==="info"||e==="note"||e==="notice"?"info":e==="hint"?"hint":"warning"}a(X,"severityValue");function K(t){return t==="error"||t==="warning"||t==="note"?t:"warning"}a(K,"sarifSeverity");function Q(t){return t.replace(/&#(x[0-9a-f]+|\d+);/giu,(e,n)=>{let i=n.toLowerCase().startsWith("x")?Number.parseInt(n.slice(1),16):Number(n);return i<=1114111?String.fromCodePoint(i):e}).replaceAll("&quot;",'"').replaceAll("&apos;","'").replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&")}a(Q,"decodeXml");var m=class t{constructor(e,n,i=new Map){this.linters=e;this.availableBuiltIns=n;this.evidence=i}static{a(this,"LintCommandRegistry")}static async fromDirectory(e,n={}){let i=await D(e,"linters",o=>A(o).linters,n),r=n.environment??process.env,f=await Promise.all(i.entries.filter(o=>o.layer==="built-in").map(async o=>({id:o.id,available:await w(o.config.check,e,r)}))),s=await R(e,p),l=[...i.entries].sort((o,d)=>o.layer==="built-in"&&d.layer==="built-in"?(s.get(d.id)?.score??0)-(s.get(o.id)?.score??0):0);return new t(l,new Set(f.filter(o=>o.available&&(!n.requireBuiltInEvidence||(s.get(o.id)?.score??0)>0)).map(o=>o.id)),s)}static fromConfig(e){return new t(Object.entries(e.linters).map(([n,i])=>({id:n,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(e,n){return this.resolveEntry(e,n)?.config}resolveEntry(e,n){return $(this.linters,this.availableBuiltIns,this.evidence,e,n)}get entries(){return this.linters}};async function k(t,e){let n;try{n=await I(t.check,e)}catch(l){return{ok:!1,diagnostics:[],failure:`command could not start: ${l instanceof Error?l.message:String(l)}`}}let i=t.diagnostics.format==="regex"||t.diagnostics.format==="clang"?[n.stdout,n.stderr].filter(l=>l.trim().length>0).join(`
4
+ `):n.stdout.trim().length>0?n.stdout:n.stderr,r;try{r=M(i,t.diagnostics)}catch{return{ok:!1,diagnostics:[],failure:`invalid ${t.diagnostics.format} diagnostics: ${i.trim().slice(0,200)||"empty command output"}`}}let f=n.ok&&(n.exitCode===0||r.length>0),s=t.check.cwd==="file"?b.dirname(e.filePath):e.projectRoot;return r=r.filter(l=>{if(l.file===void 0)return!0;let o=l.file.startsWith("file:")?Y(l.file):l.file;return b.resolve(s,o)===b.resolve(e.filePath)}).map(({file:l,...o})=>o),{ok:f,diagnostics:r,...!f&&{failure:n.stderr.trim().slice(0,200)||`command exited with code ${String(n.exitCode)}`}}}a(k,"runConfiguredLinter");function F(t){return{kind:"linter",name:"command-lint",priority:100,extensions:["*"],detect:a(()=>Promise.resolve(!0),"detect"),async lint({filePath:e,fix:n},i){let r=t.resolve(e,i.cwd);if(r===void 0)return{ok:!0,diagnostics:[]};let f=n===!0&&r.fix!==void 0?r.fix:r.check,s=await k({...r,check:f},{projectRoot:i.cwd,filePath:e});return{ok:s.ok,diagnostics:s.diagnostics}}}}a(F,"createCommandLinter");import{copyFile as ee,mkdtemp as te,rm as ne}from"node:fs/promises";import C from"node:path";var J={protocol:T,apiVersion:1,id:"lint",setup(t){for(let e of p)t.addToolRecipe(e);t.addSetupCheck({id:"effective-config",inspect:ie}),t.addCheck({id:"config",title:"Linter",async run(e){try{let n=await m.fromDirectory(e.cwd,{environment:e.env}),i=re(n,e.files,e.cwd);return i.length===0?[{status:"skip",message:"No linter matches the inspected project files"}]:await Promise.all(i.map(async({entry:r,source:f})=>{let s=`${r.id} [${r.layer}] command ${JSON.stringify(r.config.check.command)}`,l=await te(C.join(C.dirname(f),".pi-agent-ide-doctor-")),o=C.join(l,C.basename(f));try{await ee(f,o);let d=await k(r.config,{projectRoot:e.cwd,filePath:o,env:e.env});return d.ok?{status:"pass",message:`${s}: probe passed`,detail:r.sourcePath}:{status:"fail",message:`${s}: probe failed`,detail:d.failure??r.sourcePath}}catch(d){return{status:"fail",message:`${s}: ${d instanceof Error?d.message:String(d)}`,detail:r.sourcePath}}finally{await ne(l,{recursive:!0,force:!0})}}))}catch(n){return[{status:"fail",message:n instanceof Error?n.message:String(n)}]}}})}};async function ie(t){try{let e=await m.fromDirectory(t.cwd,{environment:t.env}),n=[],i=new Map;for(let[r,f]of t.detectedLanguages){let s=f.map(l=>e.resolveEntry(l,t.cwd)).find(l=>l!==void 0);s!==void 0&&(n.push({kind:"linter",languageId:r,toolId:s.id}),await w(s.config.check,t.cwd,t.env)||i.set(s.id,{id:`linter-${s.id}-unavailable`,message:`Configured linter ${s.id} cannot run ${JSON.stringify(s.config.check.command)}`}))}return{selections:n,actions:[...i.values()]}}catch(e){return{actions:[{id:"linter-config-invalid",message:`Linter configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}a(ie,"inspectLinterSetup");function re(t,e,n){let i=new Map;for(let r of e){let f=t.resolveEntry(r,n);f!==void 0&&!i.has(f.id)&&i.set(f.id,{entry:f,source:r})}return[...i.values()]}a(re,"applicableLinters");async function se(t){let e=new Map,n=a((s,l=!1)=>{let o=JSON.stringify([s,l]),d=e.get(o);return d===void 0&&(d=le(s,l),e.set(o,d)),d},"registryFor"),i=a(async(s,l)=>{let o=await S(l,s,"linters",p);return o===void 0?void 0:{projectRoot:o,external:o!==oe.resolve(l)}},"resolveProject"),r={kind:"linter",name:"pi-agent-ide-lint",priority:200,extensions:["*"],detect:a(async s=>(await n(s.cwd),!0),"detect"),async lint(s,l){let o=await i(s.filePath,l.cwd);if(o===void 0)return{ok:!0,diagnostics:[]};let d=await n(o.projectRoot,o.external);return F(d).lint(s,{cwd:o.projectRoot})}},f={protocol:j,apiVersion:4,id:"lint",setup(s){s.addTool(r),s.addDiagnosticSource({id:"lint",async diagnose(l,o){let d=await i(l,o.cwd);if(d===void 0)return{status:"unavailable",diagnostics:[],reason:"No local linter project found for this file"};let x=await n(d.projectRoot,d.external);o.signal.throwIfAborted();let u=x.resolve(l,d.projectRoot);if(!u)return{status:"unavailable",diagnostics:[],reason:"No linter configured for this file"};let h=E(u.check.command),v=await k(u,{projectRoot:d.projectRoot,filePath:l,signal:o.signal});return!v.ok&&v.diagnostics.length===0?{status:"unavailable",diagnostics:[],reason:v.failure??"Lint check failed",source:h}:{status:"ready",diagnostics:v.diagnostics,source:h}}})}};await Promise.all([L(t,f),O(t,J)])}a(se,"registerLint");async function le(t,e){let n=e?t:process.env.PI_AGENT_IDE_CONFIG_DIR??t;return m.fromDirectory(n,{includeGlobal:!e,requireBuiltInEvidence:e})}a(le,"loadRegistry");export{se as default};
package/dist/entry-32.js CHANGED
@@ -1,8 +1,9 @@
1
- import{a as be}from"./chunk-ERVMDQGX.js";import{a as ye,b as ve}from"./chunk-VFBLX4TG.js";import"./chunk-NNCZYO4Q.js";import{c as Re}from"./chunk-KCEOTU5Z.js";import"./chunk-YHUTTZC6.js";import{a as Se}from"./chunk-ORAPGW7W.js";import{a as we,b as Le}from"./chunk-JASLOB2X.js";import{a as Pe}from"./chunk-E2RESHYR.js";import{a as _e,b as ke}from"./chunk-T2RPMEM2.js";import{a as oe,b as ae,c as E,d as R,j as ce,k as le,l as pe}from"./chunk-X6MPU7UO.js";import"./chunk-RAZOACDD.js";import{a as ge}from"./chunk-OBWZ5RYN.js";import{a as de,b as ue}from"./chunk-KZBAJFCV.js";import"./chunk-KINKBPPX.js";import{b as me,f as fe,i as A,n as he}from"./chunk-KVGQG43U.js";import"./chunk-N34ATN52.js";import{a as h}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import it from"node:path";import ot from"cross-spawn";import{createMessageConnection as at,CancellationTokenSource as ct,StreamMessageReader as lt}from"vscode-jsonrpc/node";import{URI as Ce}from"vscode-uri";import{watch as tt}from"node:fs";import{readdir as rt,stat as nt}from"node:fs/promises";import C from"node:path";import{URI as F}from"vscode-uri";var O=class{constructor(e,t,n){this.root=e;this.changed=t;this.failed=n}static{c(this,"LspFileWatchers")}registrations=new Map;disposed=!1;async register(e,t){let n=[];try{for(let s of t){let i=s.globPattern,o=typeof i=="string"?this.root:F.parse(typeof i.baseUri=="string"?i.baseUri:i.baseUri.uri).fsPath,l=typeof i=="string"?i:i.pattern,a=c(m=>C.matchesGlob(C.isAbsolute(l)?C.join(o,m):m,l),"matches"),p=new Set((await rt(o,{recursive:!0})).filter(a));if(this.disposed)throw new Error("Language server file watchers are disposed");let d=tt(o,{recursive:!0},(m,f)=>{!f||!a(f)||nt(C.join(o,f)).then(()=>{if(!this.registrations.get(e)?.includes(d))return;let g=p.has(f)?2:1;p.add(f),(s.kind??7)&(g===1?1:2)&&this.changed({uri:F.file(C.join(o,f)).toString(),type:g})},g=>{if(this.registrations.get(e)?.includes(d)){if(g.code!=="ENOENT"){this.failed(g);return}p.delete(f)&&(s.kind??7)&4&&this.changed({uri:F.file(C.join(o,f)).toString(),type:3})}})});d.on("error",this.failed),n.push(d)}}catch(s){for(let i of n)i.close();throw s}this.unregister(e),this.registrations.set(e,n)}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 st}from"vscode-jsonrpc/node";var T=class extends st{constructor(t,n){super(t);this.fail=n}static{c(this,"TransportWriter")}async write(t){try{await super.write(t)}catch(n){this.fail(n)}}};var _=class{static{c(this,"LspClient")}_process=null;_connection=null;_initialized=!1;_serverCapabilities=null;_disposed=!1;_crashed=!1;_stderr="";_fileWatchers;_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}get ready(){return this._initialized&&!this._disposed}get crashed(){return this._crashed}get pid(){return this._process?.pid??null}get commandName(){return me(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 hasFoldingRangeCapability(){let e=this._serverCapabilities?.foldingRangeProvider;return e===!0||typeof e=="object"&&e!==null}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(){if(this._initialized)return;if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let e=h(this._command[0]),t=Ce.parse(this.rootUri).fsPath,n=[{uri:this.rootUri,name:it.basename(t)||t}],s=ot(e,this._args,{stdio:["pipe","pipe","pipe"],cwd:t,env:he({command:this._command,env:this._env},t,process.env)});this._process=s;let i=pt(s);s.stdin?.on("error",()=>{}),s.stdout?.on("error",()=>{}),s.stderr?.on("error",()=>{}),this._stderr="",s.stderr?.setEncoding("utf8"),s.stderr?.on("data",a=>{this._stderr=(this._stderr+a).slice(-4096)}),s.on("error",a=>{("code"in a?a.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,a),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null}),s.on("exit",(a,p)=>{this._fileWatchers?.dispose(),!this._disposed&&a!==0&&a!==null&&(this._crashed=!0),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1}),await i;let o=at(new lt(h(s.stdout)),new T(h(s.stdin),a=>{this._connection!==o||this._disposed||(this._crashed=!0,this._initialized=!1,this._fileWatchers?.dispose(),o.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,a))}));this._connection=o,this._connection.onError(a=>{console.error(`[lsp] ${this.serverId}: connection error:`,a)}),this._fileWatchers=new O(t,a=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[a]})},a=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,a)),this._connection.onRequest("client/registerCapability",async a=>{for(let p of a.registrations)if(p.method!=="workspace/didChangeConfiguration"){if(p.method!=="workspace/didChangeWatchedFiles")throw new Error(`Unsupported dynamic capability: ${p.method}`);await this._fileWatchers?.register(p.id,p.registerOptions?.watchers??[])}return null}),this._connection.onRequest("client/unregisterCapability",a=>{for(let p of a.unregisterations)this._fileWatchers?.unregister(p.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/configuration",a=>a.items.map(p=>{let d=this._settings??null;for(let m of p.section?.split(".").filter(Boolean)??[])d=typeof d=="object"&&d!==null?d[m]??null:null;return d})),this._connection.listen(),this._connection.onNotification((a,...p)=>{if(a==="textDocument/publishDiagnostics"){let d=p[0];d&&typeof d.uri=="string"&&Array.isArray(d.diagnostics)&&this._documentVersions.has(d.uri)&&(d.version===void 0||d.version===this.documentVersion(d.uri))&&this._diagnosticPublications.set(d.uri,{diagnostics:d.diagnostics,...typeof d.version=="number"&&{version:d.version}})}for(let d of this._handlers.get(a)??[])d(p[0])}),this._connection.onRequest("workspace/workspaceFolders",()=>n);let l=await xe(this._connection.sendRequest("initialize",{processId:process.pid,rootUri:this.rootUri,workspaceFolders:n,capabilities:{workspace:{applyEdit:!1,configuration:!0,workspaceFolders:!0,didChangeWatchedFiles:{dynamicRegistration:!0,relativePatternSupport:!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`).catch(a=>{let p=this._stderr.trim();throw p?new Error(`[lsp] ${this.serverId}: ${p}`,{cause:a}):a});if(await this._connection.sendNotification("initialized",{capabilities:l.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`);this._initialized=!0,this._serverCapabilities=l.capabilities,this._diagnosticMode=l.capabilities.diagnosticProvider?"pull":"push"}touch(){}async restart(){this._fileWatchers?.dispose(),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1,this._crashed=!1,this._disposed=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null,await this.start()}async sendRequest(e,t,n){if(this._assertReady(),n?.throwIfAborted(),!n)return h(this._connection).sendRequest(e,t);let s=new ct,i;try{let o=h(this._connection).sendRequest(e,t,s.token);return await Promise.race([o,new Promise((l,a)=>{i=c(()=>{s.cancel(),a(n.reason)},"onAbort"),n.addEventListener("abort",i,{once:!0})})])}finally{i&&n.removeEventListener("abort",i),s.dispose()}}sendNotification(e,t){this._assertReady(),this._sendNotification(e,t)}_sendNotification(e,t){let n=this._connection;n&&n.sendNotification(e,t).catch(s=>{this._connection!==n||this._disposed||(this._crashed=!0,this._initialized=!1,this._fileWatchers?.dispose(),n.dispose(),console.error(`[lsp] ${this.serverId}: notification ${e} failed:`,s))})}onNotification(e,t){let n=this._handlers.get(e)??[];return n.push(t),this._handlers.set(e,n),()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}toUri(e){return e.startsWith("file://")?e:Ce.file(e).toString()}openDocument(e,t,n,s=1){let i=this._documentVersions.get(e);if(i!==void 0){this.changeDocument(e,t,Math.max(s,i+1));return}this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:n,version:s,text:t}}),this._documentVersions.set(e,s),this._documentContents.set(e,t)}syncDocument(e,t,n,s=!1){if(this._documentContents.get(e)===t)return;let i=this._documentVersions.get(e);i===void 0?this.openDocument(e,t,n):this.changeDocument(e,t,i+1);let o=this._serverCapabilities?.textDocumentSync,l=typeof o=="object"&&o!==null?o.save:void 0;s&&l&&this.sendNotification("textDocument/didSave",{textDocument:{uri:e},...typeof l=="object"&&l.includeText&&{text:t}})}changeDocument(e,t,n){let s=this._documentVersions.get(e),i=Math.max(n,(s??0)+1);this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didChange",{textDocument:{uri:e,version:i},contentChanges:[{text:t}]}),this._documentVersions.set(e,i),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)}async shutdown(){if(!this._disposed){if(this._disposed=!0,this._fileWatchers?.dispose(),this._connection&&this._initialized)try{await xe(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,this._process&&!this._process.killed&&(this._process.kill("SIGTERM"),setTimeout(()=>{this._process&&!this._process.killed&&this._process.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}}dispose(){this.shutdown()}_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 pt(r){return new Promise((e,t)=>{let n=c(()=>{r.off("spawn",s),r.off("error",i)},"cleanup"),s=c(()=>{n(),e()},"onSpawn"),i=c(o=>{n(),t(o)},"onError");r.once("spawn",s),r.once("error",i)})}c(pt,"waitForSpawn");function xe(r,e,t){return new Promise((n,s)=>{let i=setTimeout(()=>{s(new Error(t))},e);r.then(o=>{clearTimeout(i),n(o)}).catch(o=>{clearTimeout(i),s(o instanceof Error?o:new Error(String(o)))})})}c(xe,"withTimeout");import{readFile as Ee}from"node:fs/promises";import{URI as Ie}from"vscode-uri";var I={Error:1,Warning:2,Information:3,Hint:4};var De={command:"typescript.tsserverRequest",async request(r,e,t){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async s=>{let i=await r.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[s,{file:e,includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},t);if(!W(i)||i.success!==!0||!Array.isArray(i.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${s}`);return i.body.map(dt)}))).flat()}};function q(r){return r.supportsCommand(De.command)?De:void 0}c(q,"completedDiagnosticAdapter");function dt(r){if(!W(r)||typeof r.message!="string"||typeof r.code!="number"&&typeof r.code!="string"||!W(r.startLocation)||!Number.isInteger(r.startLocation.line)||!Number.isInteger(r.startLocation.offset)||Number(r.startLocation.line)<1||Number(r.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(r.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(r.code),message:r.message,line:Number(r.startLocation.line),column:Number(r.startLocation.offset),severity:r.category==="error"?"error":r.category==="warning"?"warning":r.category==="suggestion"?"hint":"info"}}c(dt,"convertTypeScriptDiagnostic");function W(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}c(W,"isRecord");async function j(r,e,t,n={}){let s=new AbortController,i=AbortSignal.any([s.signal,...n.signal?[n.signal]:[]]),o=setTimeout(()=>s.abort(new Error(`[lsp] ${r.serverId}: diagnostics timed out for ${e}`)),r.timeoutMs);try{return await ut(r,e,t,n.content,i)}finally{clearTimeout(o)}}c(j,"requestDiagnostics");async function ut(r,e,t,n,s){if(s.throwIfAborted(),r.diagnosticMode!=="push"){let a=r.documentVersion(e);try{let p=await r.sendRequest("textDocument/diagnostic",{textDocument:{uri:e}},s);if(p.kind!=="full"||!Array.isArray(p.items))throw new Error("Invalid full diagnostic report");if(r.documentVersion(e)!==a)throw new Error("Document changed during diagnostic request");return r.setDiagnosticMode("pull"),je(p.items,!1,!0)}catch(p){if(!gt(p))throw p;r.setDiagnosticMode("push")}}let i=q(r);if(i){r.documentVersion(e)===void 0&&r.syncDocument(e,n??await Ee(Ie.parse(e).fsPath,"utf8"),t??"plaintext");let a=r.documentVersion(e),p=await i.request(r,e,s);if(s.throwIfAborted(),r.documentVersion(e)!==a)throw new Error("Document changed during diagnostic request");return{diagnostics:p,syntaxErrors:[],otherDiagnostics:p,unversioned:!1,complete:!0}}s.throwIfAborted();let o=r.documentVersion(e)!==void 0,l=o?void 0:n??await Ee(Ie.parse(e).fsPath,"utf8");s.throwIfAborted(),r.beginDiagnosticRequest(e);try{return await new Promise((a,p)=>{let d=r.documentVersion(e)??1,m=c(w=>{let v=w;v.uri!==e||!Array.isArray(v.diagnostics)||v.version!==void 0&&v.version!==d||r.documentVersion(e)===d&&(b(),a(je(v.diagnostics,v.version===void 0)))},"receive"),f=r.onNotification("textDocument/publishDiagnostics",m),g=c(()=>{b(),p(s.reason)},"onAbort");function b(){f(),s.removeEventListener("abort",g)}c(b,"cleanup"),s.addEventListener("abort",g,{once:!0});try{o||r.syncDocument(e,l??"",t??"plaintext");let w=r.diagnosticPublication(e);w&&m({uri:e,...w})}catch(w){b(),p(w)}})}finally{r.endDiagnosticRequest(e)}}c(ut,"requestCurrentDiagnostics");function z(r){return{code:String(r.code??"LSP"),message:r.message,line:r.range.start.line+1,column:r.range.start.character+1,severity:r.severity===I.Warning?"warning":r.severity===I.Information?"info":r.severity===I.Hint?"hint":"error"}}c(z,"toDiagnostic");function je(r,e,t=!1){let n=r.map(z);return{diagnostics:n,syntaxErrors:[],otherDiagnostics:n,unversioned:e,complete:t}}c(je,"classify");function gt(r){return r!==null&&typeof r=="object"&&"code"in r&&r.code===-32601}c(gt,"isMethodNotFound");var mt={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 L(r){return mt[r]??`SymbolKind(${r})`}c(L,"symbolKindName");async function H(r,e){return await r.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}})??[]}c(H,"requestDocumentSymbols");async function U(r,e,t=100){return(await r.sendRequest("workspace/symbol",{query:e})??[]).slice(0,t)}c(U,"requestWorkspaceSymbols");import yt from"node:path";import{URI as vt}from"vscode-uri";import{readdir as ft}from"node:fs/promises";import N from"node:path";import{URI as G}from"vscode-uri";function Me(r,e){let t=c(n=>typeof n=="string"?n.replaceAll("{project}",()=>e):Array.isArray(n)?n.map(t):n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([s,i])=>[s,t(i)])):n,"expand");return Object.fromEntries(Object.entries(r).map(([n,s])=>[n,t(s)]))}c(Me,"resolveInitializationOptions");var k=class r{constructor(e){this._registry=e}static{c(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(!r._instance)throw new Error("[lsp] LspManager not initialized");return r._instance}static getInstanceOrNull(){return r._instance}static init(e){let t=r._instance;return t?._disposed?(t._registry=e,t._disposed=!1,t):(r._instance=new r(e),r._instance)}static async resetForTest(){r._instance&&(await r._instance.shutdownAll(),r._instance=null)}get clientCount(){return this._clients.size}onPushDiagnostics(e){return this._pushHandlers.add(e),()=>this._pushHandlers.delete(e)}async getOrStart(e,t,n){if(this._disposed)return null;let s=this._registry.resolve(e),i=n==="symbols"?s[0]:s.find(m=>m.config.capabilities.includes(n));if(!i)return null;let o=G.file(t).toString(),l=`${i.serverId}:${o}`,a=this._clientStarts.get(l);if(a)return a;let p=this._clients.get(l);if(p?.ready)return p;let d=this._startClient(l,o,i,p);this._clientStarts.set(l,d);try{return await d}finally{this._clientStarts.get(l)===d&&this._clientStarts.delete(l)}}async _startClient(e,t,n,s){let i=s??new _({serverId:n.serverId,rootUri:t,command:n.config.command,...n.config.env&&{env:n.config.env},...n.config.initializationOptions&&{initOptions:Me(n.config.initializationOptions,G.parse(t).fsPath)},...n.config.settings&&{settings:n.config.settings},...n.config.timeoutMs&&{timeoutMs:n.config.timeoutMs}});try{s?await s.restart():await i.start()}catch(o){throw await i.shutdown().catch(()=>{}),o}if(this._disposed)throw await i.shutdown(),new Error(`[lsp] ${n.serverId}: manager disposed during startup`);return this._clients.set(e,i),this._subscribeToPushDiagnostics(e,i),i}async getWorkspaceClients(e,t="symbols"){let n=new Set;for(let s of this._registry.knownExtensions)try{let i=await this.getOrStart(s,e,t);i&&n.add(i)}catch{}return[...n]}async prepareWorkspaceSymbols(e){let t=await this.getWorkspaceClients(e),n=new Set(this._registry.knownExtensions),s=new Set([".git",".cache","node_modules","dist","build"]),i=c(async o=>{if(n.size===0)return;let l;try{l=await ft(o,{withFileTypes:!0})}catch{return}for(let a of l){if(n.size===0)return;if(a.isDirectory()){s.has(a.name)||await i(N.join(o,a.name));continue}if(!a.isFile())continue;let p=N.extname(a.name).toLowerCase();if(!n.has(p))continue;let d=N.join(o,a.name);await this.openFile(d,e,"symbols").catch(()=>null)&&n.delete(p)}},"visit");return await i(e),t}hasServerFor(e){return this._registry.resolve(e).length>0}languageId(e){return this._registry.languageId(e)}isOpen(e){return this._openDocs.has(e)}async openFile(e,t,n="diagnostics"){let s=N.resolve(t,e),i=await this.getOrStart(s,t,n);if(!i)return null;let o=i.toUri(s),a=this._registry.resolve(s)[0]?.languageId??"plaintext";try{let{readFile:p}=await import("node:fs/promises"),d=await p(s,"utf8");i.openDocument(o,d,a),this._openDocs.add(o)}catch{}return{client:i,uri:o,languageId:a}}_subscribeToPushDiagnostics(e,t){if(this._pushUnsubscribers.has(e))return;let n=t.onNotification("textDocument/publishDiagnostics",s=>{let i=ht(s);if(!i||t.hasActiveDiagnosticRequest(i.uri))return;let o=t.documentVersion(i.uri);if(i.version!==void 0&&o!==void 0&&i.version<o)return;let l=`${e}:${i.uri}`,a=i.diagnostics.map(z),p=JSON.stringify([i.version,o,a]);if(this._pushFingerprints.get(l)===p)return;this._pushFingerprints.set(l,p);let d={cwd:G.parse(t.rootUri).fsPath,serverId:t.serverId,uri:i.uri,diagnostics:a,...i.version!==void 0&&{version:i.version}};for(let m of this._pushHandlers)m(d)});this._pushUnsubscribers.set(e,n)}async shutdownAll(){this._disposed=!0,await Promise.allSettled(this._clientStarts.values());let e=[...this._clients.values()];await Promise.all(e.map(t=>t.shutdown()));for(let t of this._pushUnsubscribers.values())t();this._pushUnsubscribers.clear(),this._clientStarts.clear(),this._pushFingerprints.clear(),this._pushHandlers.clear(),this._clients.clear()}dispose(){this.shutdownAll()}};function ht(r){if(r===null||typeof r!="object")return;let e=r;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}c(ht,"parsePushNotification");async function M(r,e,t){return await r.sendRequest("textDocument/references",{textDocument:{uri:e},position:t,context:{includeDeclaration:!0}})??[]}c(M,"requestReferences");async function B(r,e,t){let n=await r.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:t}),s=n?.[0];if(!s)return{items:[],incoming:[],outgoing:[]};let[i,o]=await Promise.all([r.sendRequest("callHierarchy/incomingCalls",{item:s}).catch(()=>[]),r.sendRequest("callHierarchy/outgoingCalls",{item:s}).catch(()=>[])]);return{items:n,incoming:i??[],outgoing:o??[]}}c(B,"requestCallHierarchy");function Ae(r){try{return vt.parse(r).fsPath}catch{return r.startsWith("file://")?decodeURIComponent(r.slice(7)):r}}c(Ae,"uriToFilePath");function $e(r,e,t,n,s){let i=Ae(t),o=yt.relative(r,i);return{filePath:o.startsWith("..")?i:o,lineNumber:n+1,column:s+1,kind:String(e.kind),name:e.name}}c($e,"toHit");async function J(r,e,t,n){if(n?.aborted)throw new Error("Operation aborted");let s=k.getInstance(),i=await s.prepareWorkspaceSymbols(e),o=[];for(let p of i){if(n?.aborted)throw new Error("Operation aborted");try{o.push(...await U(p,r,t))}catch{}}let l=new Set,a=[];for(let p of o){if(n?.aborted)throw new Error("Operation aborted");if(a.length>=t)break;let d=p.location,m=$e(e,p,d.uri,d.range.start.line,d.range.start.character),f=`${m.filePath}:${m.lineNumber}:${m.column}`;if(l.has(f)||(l.add(f),a.push(m)),a.length>=t)break;let g=Ae(d.uri),b=await s.openFile(g,e,"symbols").catch(()=>null);if(!b)continue;let w=await M(b.client,b.uri,d.range.start).catch(()=>[]);for(let v of w){let $=$e(e,p,v.uri,v.range.start.line,v.range.start.character),ie=`${$.filePath}:${$.lineNumber}:${$.column}`;if(l.has(ie)||(l.add(ie),a.push($)),a.length>=t)break}}return a}c(J,"searchSymbols");import{readFile as bt}from"node:fs/promises";import x from"node:path";import{fileURLToPath as wt}from"node:url";var Lt={failureLabel:"SYMBOL_READ_FAILED",emptyReason:"no symbol source was produced."},K=10,X=5,D=10;async function Z(r,e,t,n,s){P(s);let i=await ne(r,e,n),o=re(i.symbols,t,i.displayPath),l=await Ct(i.filePath);P(s);let a=o.range.start.line+1,p=Math.min(o.range.end.line+1,l.lines.length),d=l.lines.slice(Math.max(0,a-1),Math.max(0,p)).map((f,g)=>{let b=a+g;return ce({content:f,sourceLine:{source:i.filePath,lineNumber:b,content:f}})}),m={path:i.displayPath,heading:`symbol: ${R(o.selector)}`,details:[`defined in: ${i.displayPath}:${a}-${p} (${L(o.kind)})`],startLine:a,endLine:p,totalLines:l.lines.length,renderedLines:d};return le([m],Lt)}c(Z,"readLspSymbolBody");async function ee(r,e,t,n,s){P(s);let i=await ne(r,e,n),o=re(i.symbols,t,i.displayPath),l=await Fe(i,o,s),a=new V(n);return await St(i,o,l,a)}c(ee,"readLspSymbolGraph");async function te(r,e,t,n){P(n);let s=await ne(r,e,t),i=new V(t),o=[`## file graph: ${s.displayPath}`,`Top-level declarations: ${s.symbols.length}`];for(let l of s.symbols){P(n);let a=await Fe(s,l,n);o.push("",...await Pt(s,l,a,i))}return o.join(`
2
- `)}c(te,"readLspFileGraph");function re(r,e,t){if(e.length===0)throw new TypeError("A symbol selector must contain at least one segment.");if(e.length===1){let i=Ve(r,h(e[0]));if(i.length===1)return h(i[0]);throw i.length>1?new Error(`Symbol selector "${R(e)}" is ambiguous in ${t}; use parent/child.`):Oe(e,t)}let n=r,s;for(let i of e){let o=n.filter(l=>l.name===i);if(o.length===0)throw Oe(e,t);if(o.length>1)throw new Error(`Symbol selector "${R(e)}" is ambiguous at "${i}" in ${t}.`);s=h(o[0]),n=s.children}return h(s)}c(re,"resolveLspCodeSymbol");async function ne(r,e,t){let n=x.isAbsolute(e)?x.normalize(e):x.resolve(t,e),s=await r.openFile(n,t,"symbols");if(!s)throw new Error(`No LSP server with symbol support is configured for ${Q(n,t)}.`);let i=await H(s.client,s.uri),o=qe(i).sort(Ne);return{client:s.client,uri:s.uri,filePath:n,displayPath:Q(n,t),symbols:o}}c(ne,"openCodeDocument");function qe(r,e=[]){return r.flatMap(t=>{let n=t.selectionRange??t.range;if(!n)return[];let s=t.range??n,i=[...e,t.name];return[{name:t.name,kind:t.kind,range:s,selectionRange:n,selector:i,children:qe(t.children??[],i).sort(Ne)}]})}c(qe,"normalizeDocumentSymbols");function Ne(r,e){return r.range.start.line-e.range.start.line||r.range.start.character-e.range.start.character||r.name.localeCompare(e.name)}c(Ne,"compareSymbols");function Ve(r,e){return r.flatMap(t=>[...t.name===e?[t]:[],...Ve(t.children,e)])}c(Ve,"collectNamedSymbols");function Oe(r,e){return new Error(`Symbol "${R(r)}" was not found in ${e}.`)}c(Oe,"symbolNotFound");async function Fe(r,e,t){let n=e.selectionRange.start,[s,i]=await Promise.all([Te(M(r.client,r.uri,n),[],t),Te(B(r.client,r.uri,n),{items:[],incoming:[],outgoing:[]},t)]);return P(t),{references:s,calls:i}}c(Fe,"queryRelations");async function Te(r,e,t){try{let n=await r;return P(t),n}catch(n){if(t?.aborted===!0)throw ze(t,n);return e}}c(Te,"optionalRequest");async function St(r,e,t,n){let s=R(e.selector),i=await n.line(r.uri,e.selectionRange.start.line+1);return[`## graph: ${s}`,`Definition: ${r.displayPath} ${i} (${L(e.kind)})`,`Source: ${E("graph",r.displayPath,e.selector)}`,"",...await Rt(t.references,n),"",...await _t(t.calls.incoming,n),"",...await kt(t.calls.outgoing,n)].join(`
3
- `)}c(St,"formatSymbolGraph");async function Rt(r,e){let t=We(r),n=[`References: ${r.length} in ${t.length} file(s)`];for(let[s,i]of t.slice(0,K)){n.push(`- ${e.display(s)} (${i.length})`);for(let o of i.slice(0,X))n.push(` - ${await e.line(s,o.range.start.line+1)}`);i.length>X&&n.push(` - ... ${i.length-X} more`)}return t.length>K&&n.push(`- ... ${t.length-K} more file(s)`),n}c(Rt,"formatReferences");async function _t(r,e){let t=[`Incoming calls: ${r.length}`];for(let n of r.slice(0,D)){let s=n.fromRanges[0]?.start.line??n.from.selectionRange.start.line,i=await e.line(n.from.uri,s+1);t.push(`- ${L(n.from.kind)} ${n.from.name} \u2014 ${e.display(n.from.uri)} ${i}`)}return r.length>D&&t.push(`- ... ${r.length-D} more`),t}c(_t,"formatIncomingCalls");async function kt(r,e){let t=[`Outgoing calls: ${r.length}`];for(let n of r.slice(0,D)){let s=await e.line(n.to.uri,n.to.selectionRange.start.line+1);t.push(`- ${L(n.to.kind)} ${n.to.name} \u2014 ${e.display(n.to.uri)} ${s}`)}return r.length>D&&t.push(`- ... ${r.length-D} more`),t}c(kt,"formatOutgoingCalls");async function Pt(r,e,t,n){let s=L(e.kind),i=await n.line(r.uri,e.selectionRange.start.line+1),o=We(t.references).map(([d,m])=>`${n.display(d)} (${m.length})`),l=t.calls.incoming.map(d=>`${d.from.name} (${n.display(d.from.uri)})`),a=t.calls.outgoing.map(d=>`${d.to.name} (${n.display(d.to.uri)})`),p=[`### ${s} ${e.name}`,`Selector: ${R(e.selector)}`,`Definition: ${i}`,`Used by: ${Y(o)}`,`Incoming calls: ${Y(l)}`,`Outgoing calls: ${Y(a)}`];if(e.children.length>0){p.push("Members:");for(let d of e.children){let m=E("graph",r.displayPath,d.selector);p.push(`- ${L(d.kind)} ${d.name} \u2014 ${m}`)}}return p}c(Pt,"formatFileGraphSymbol");function Y(r,e=5){if(r.length===0)return"none";let t=r.slice(0,e).join(", ");return r.length>e?`${t}, ... ${r.length-e} more`:t}c(Y,"summarize");function We(r){let e=new Map;for(let t of r){let n=e.get(t.uri)??[];n.push(t),e.set(t.uri,n)}return[...e].map(([t,n])=>[t,n.sort((s,i)=>s.range.start.line-i.range.start.line||s.range.start.character-i.range.start.character)]).sort(([t],[n])=>t.localeCompare(n))}c(We,"groupLocationsByUri");async function Ct(r){let e=await bt(r);if(e.byteLength>256*1024)throw new Error(`File exceeds the 262144-byte code-view limit: ${r}`);if(e.includes(0))throw new Error(`File appears to be binary and cannot be read as text: ${r}`);let t=e.toString("utf8").replaceAll(`\r
1
+ import{a as Ce}from"./chunk-ERVMDQGX.js";import{a as _e,b as ke}from"./chunk-VFBLX4TG.js";import"./chunk-NNCZYO4Q.js";import{d as Ie}from"./chunk-3SE372WC.js";import"./chunk-YHUTTZC6.js";import{a as Ee}from"./chunk-72EEL2DW.js";import{a as xe,b as De}from"./chunk-KAB3AYA2.js";import{a as $e}from"./chunk-ZTYWHL2F.js";import{a as je,b as Me}from"./chunk-7UGNGK7Y.js";import{a as qe}from"./chunk-TI5GMJ7Q.js";import{a as Ae,b as Te,d as Oe}from"./chunk-Y7ZMR4LT.js";import"./chunk-S3ZPXWX7.js";import{a as D,b as E,c as $,d as k,j as me,k as fe,l as he}from"./chunk-NTYXZ3EL.js";import"./chunk-5VSE5X5R.js";import{a as be}from"./chunk-HKMBQLEK.js";import{a as ye,b as ve}from"./chunk-Z3VC3S2T.js";import"./chunk-KINKBPPX.js";import{b as Le,c as Se,g as Re,j as H,o as Pe}from"./chunk-M5MJP7Z2.js";import{a as we}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import{a as v}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import sr from"node:path";var A=[{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"]}]}}},m("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}}),m("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"]}}},m("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"]),m("dart-language-server",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],{dart:[".dart"]},["dart","language-server","--protocol=lsp"],"https://dart.dev/tools/dart-language-server"),m("r-language-server",["r"],["Rscript"],["DESCRIPTION",".lintr",".Rprofile"],{r:[".r"]},["Rscript","-e","languageserver::run()"],"https://github.com/REditorSupport/languageserver"),m("zls",["zig"],["zls"],["build.zig","build.zig.zon","zls.json"],{zig:[".zig",".zon"]},["zls"],"https://zigtools.org/zls/"),m("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/"),m("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"]),m("basedpyright",["python"],["basedpyright-langserver","pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),m("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),m("rust-analyzer",["rust"],["rust-analyzer"],["Cargo.toml","rust-project.json"],{rust:[".rs"]},["rust-analyzer"],"https://rust-analyzer.github.io/"),m("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),m("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),m("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"),m("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),m("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),m("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),m("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),m("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),m("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:{}}),m("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"),m("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"),m("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),m("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),m("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),m("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"),m("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"),m("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"),m("neocmakelsp",["cmake"],["neocmakelsp"],["CMakeLists.txt",".neocmake.toml",".neocmakelint.toml"],{cmake:[".cmake"]},["neocmakelsp","stdio"],"https://github.com/neocmakelsp/neocmakelsp",void 0,{cmake:["CMakeLists.txt"]}),m("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"),m("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),m("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),m("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 m(r,e,t,n,s,i,o,u,a,l){return{id:r,name:r,kind:"lsp",languages:e,executables:t,configFiles:n,documentation:o,...u&&{dependencies:u},lsp:{command:i,rootMarkers:n,languageIds:s,...a&&{fileNames:a},...l&&{settings:l}}}}c(m,"recipe");import St from"node:path";import Rt from"cross-spawn";import{createMessageConnection as Pt,CancellationTokenSource as _t,StreamMessageReader as kt}from"vscode-jsonrpc/node";import{URI as Ne}from"vscode-uri";import{watch as vt}from"node:fs";import{readdir as bt,stat as wt}from"node:fs/promises";import I from"node:path";import{URI as X}from"vscode-uri";var U=class{constructor(e,t,n){this.root=e;this.changed=t;this.failed=n}static{c(this,"LspFileWatchers")}registrations=new Map;disposed=!1;async register(e,t){let n=[];try{for(let s of t){let i=s.globPattern,o=typeof i=="string"?this.root:X.parse(typeof i.baseUri=="string"?i.baseUri:i.baseUri.uri).fsPath,u=typeof i=="string"?i:i.pattern,a=c(p=>I.matchesGlob(I.isAbsolute(u)?I.join(o,p):p,u),"matches"),l=new Set((await bt(o,{recursive:!0})).filter(a));if(this.disposed)throw new Error("Language server file watchers are disposed");let d=vt(o,{recursive:!0},(p,g)=>{!g||!a(g)||wt(I.join(o,g)).then(()=>{if(!this.registrations.get(e)?.includes(d))return;let h=l.has(g)?2:1;l.add(g),(s.kind??7)&(h===1?1:2)&&this.changed({uri:X.file(I.join(o,g)).toString(),type:h})},h=>{if(this.registrations.get(e)?.includes(d)){if(h.code!=="ENOENT"){this.failed(h);return}l.delete(g)&&(s.kind??7)&4&&this.changed({uri:X.file(I.join(o,g)).toString(),type:3})}})});d.on("error",this.failed),n.push(d)}}catch(s){for(let i of n)i.close();throw s}this.unregister(e),this.registrations.set(e,n)}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 Lt}from"vscode-jsonrpc/node";var G=class extends Lt{constructor(t,n){super(t);this.fail=n}static{c(this,"TransportWriter")}async write(t){try{await super.write(t)}catch(n){this.fail(n)}}};var C=class{static{c(this,"LspClient")}_process=null;_connection=null;_initialized=!1;_serverCapabilities=null;_disposed=!1;_crashed=!1;_stderr="";_fileWatchers;_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}get ready(){return this._initialized&&!this._disposed}get crashed(){return this._crashed}get pid(){return this._process?.pid??null}get commandName(){return Le(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 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(){if(this._initialized)return;if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let e=v(this._command[0]),t=Ne.parse(this.rootUri).fsPath,n=[{uri:this.rootUri,name:St.basename(t)||t}],s=Rt(e,this._args,{stdio:["pipe","pipe","pipe"],cwd:t,env:Pe({command:this._command,env:this._env},t,process.env)});this._process=s;let i=Ct(s);s.stdin?.on("error",()=>{}),s.stdout?.on("error",()=>{}),s.stderr?.on("error",()=>{}),this._stderr="",s.stderr?.setEncoding("utf8"),s.stderr?.on("data",a=>{this._stderr=(this._stderr+a).slice(-4096)}),s.on("error",a=>{("code"in a?a.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,a),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null}),s.on("exit",(a,l)=>{this._fileWatchers?.dispose(),!this._disposed&&a!==0&&a!==null&&(this._crashed=!0),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1}),await i;let o=Pt(new kt(v(s.stdout)),new G(v(s.stdin),a=>{this._connection!==o||this._disposed||(this._crashed=!0,this._initialized=!1,this._fileWatchers?.dispose(),o.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,a))}));this._connection=o,this._connection.onError(a=>{console.error(`[lsp] ${this.serverId}: connection error:`,a)}),this._fileWatchers=new U(t,a=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[a]})},a=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,a)),this._connection.onRequest("client/registerCapability",async a=>{for(let l of a.registrations)if(l.method!=="workspace/didChangeConfiguration"){if(l.method!=="workspace/didChangeWatchedFiles")throw new Error(`Unsupported dynamic capability: ${l.method}`);await this._fileWatchers?.register(l.id,l.registerOptions?.watchers??[])}return null}),this._connection.onRequest("client/unregisterCapability",a=>{for(let l of a.unregisterations)this._fileWatchers?.unregister(l.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/configuration",a=>a.items.map(l=>{let d=this._settings??null;for(let p of l.section?.split(".").filter(Boolean)??[])d=typeof d=="object"&&d!==null?d[p]??null:null;return d})),this._connection.listen(),this._connection.onNotification((a,...l)=>{if(a==="textDocument/publishDiagnostics"){let d=l[0];d&&typeof d.uri=="string"&&Array.isArray(d.diagnostics)&&this._documentVersions.has(d.uri)&&(d.version===void 0||d.version===this.documentVersion(d.uri))&&this._diagnosticPublications.set(d.uri,{diagnostics:d.diagnostics,...typeof d.version=="number"&&{version:d.version}})}for(let d of this._handlers.get(a)??[])d(l[0])}),this._connection.onRequest("workspace/workspaceFolders",()=>n);let u=await Ve(this._connection.sendRequest("initialize",{processId:process.pid,rootUri:this.rootUri,workspaceFolders:n,capabilities:{workspace:{applyEdit:!1,configuration:!0,workspaceFolders:!0,didChangeWatchedFiles:{dynamicRegistration:!0,relativePatternSupport:!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`).catch(a=>{let l=this._stderr.trim();throw l?new Error(`[lsp] ${this.serverId}: ${l}`,{cause:a}):a});if(await this._connection.sendNotification("initialized",{capabilities:u.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`);this._initialized=!0,this._serverCapabilities=u.capabilities,this._diagnosticMode=u.capabilities.diagnosticProvider?"pull":"push"}touch(){}async restart(){this._fileWatchers?.dispose(),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1,this._crashed=!1,this._disposed=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null,await this.start()}async sendRequest(e,t,n){if(this._assertReady(),n?.throwIfAborted(),!n)return v(this._connection).sendRequest(e,t);let s=new _t,i;try{let o=v(this._connection).sendRequest(e,t,s.token);return await Promise.race([o,new Promise((u,a)=>{i=c(()=>{s.cancel(),a(n.reason)},"onAbort"),n.addEventListener("abort",i,{once:!0})})])}finally{i&&n.removeEventListener("abort",i),s.dispose()}}sendNotification(e,t){this._assertReady(),this._sendNotification(e,t)}_sendNotification(e,t){let n=this._connection;n&&n.sendNotification(e,t).catch(s=>{this._connection!==n||this._disposed||(this._crashed=!0,this._initialized=!1,this._fileWatchers?.dispose(),n.dispose(),console.error(`[lsp] ${this.serverId}: notification ${e} failed:`,s))})}onNotification(e,t){let n=this._handlers.get(e)??[];return n.push(t),this._handlers.set(e,n),()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}toUri(e){return e.startsWith("file://")?e:Ne.file(e).toString()}openDocument(e,t,n,s=1){let i=this._documentVersions.get(e);if(i!==void 0){this.changeDocument(e,t,Math.max(s,i+1));return}this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:n,version:s,text:t}}),this._documentVersions.set(e,s),this._documentContents.set(e,t)}syncDocument(e,t,n,s=!1){if(this._documentContents.get(e)===t)return;let i=this._documentVersions.get(e);i===void 0?this.openDocument(e,t,n):this.changeDocument(e,t,i+1);let o=this._serverCapabilities?.textDocumentSync,u=typeof o=="object"&&o!==null?o.save:void 0;s&&u&&this.sendNotification("textDocument/didSave",{textDocument:{uri:e},...typeof u=="object"&&u.includeText&&{text:t}})}changeDocument(e,t,n){let s=this._documentVersions.get(e),i=Math.max(n,(s??0)+1);this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didChange",{textDocument:{uri:e,version:i},contentChanges:[{text:t}]}),this._documentVersions.set(e,i),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)}async shutdown(){if(!this._disposed){if(this._disposed=!0,this._fileWatchers?.dispose(),this._connection&&this._initialized)try{await Ve(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,this._process&&!this._process.killed&&(this._process.kill("SIGTERM"),setTimeout(()=>{this._process&&!this._process.killed&&this._process.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}}dispose(){this.shutdown()}_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 Ct(r){return new Promise((e,t)=>{let n=c(()=>{r.off("spawn",s),r.off("error",i)},"cleanup"),s=c(()=>{n(),e()},"onSpawn"),i=c(o=>{n(),t(o)},"onError");r.once("spawn",s),r.once("error",i)})}c(Ct,"waitForSpawn");function Ve(r,e,t){return new Promise((n,s)=>{let i=setTimeout(()=>{s(new Error(t))},e);r.then(o=>{clearTimeout(i),n(o)}).catch(o=>{clearTimeout(i),s(o instanceof Error?o:new Error(String(o)))})})}c(Ve,"withTimeout");import{readFile as We}from"node:fs/promises";import{URI as ze}from"vscode-uri";var T={Error:1,Warning:2,Information:3,Hint:4};var Fe={command:"typescript.tsserverRequest",async request(r,e,t){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async s=>{let i=await r.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[s,{file:e,includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},t);if(!Y(i)||i.success!==!0||!Array.isArray(i.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${s}`);return i.body.map(xt)}))).flat()}};function B(r){return r.supportsCommand(Fe.command)?Fe:void 0}c(B,"completedDiagnosticAdapter");function xt(r){if(!Y(r)||typeof r.message!="string"||typeof r.code!="number"&&typeof r.code!="string"||!Y(r.startLocation)||!Number.isInteger(r.startLocation.line)||!Number.isInteger(r.startLocation.offset)||Number(r.startLocation.line)<1||Number(r.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(r.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(r.code),message:r.message,line:Number(r.startLocation.line),column:Number(r.startLocation.offset),severity:r.category==="error"?"error":r.category==="warning"?"warning":r.category==="suggestion"?"hint":"info"}}c(xt,"convertTypeScriptDiagnostic");function Y(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}c(Y,"isRecord");async function O(r,e,t,n={}){let s=new AbortController,i=AbortSignal.any([s.signal,...n.signal?[n.signal]:[]]),o=setTimeout(()=>s.abort(new Error(`[lsp] ${r.serverId}: diagnostics timed out for ${e}`)),r.timeoutMs);try{return await Dt(r,e,t,n.content,i)}finally{clearTimeout(o)}}c(O,"requestDiagnostics");async function Dt(r,e,t,n,s){if(s.throwIfAborted(),r.diagnosticMode!=="push"){let a=r.documentVersion(e);try{let l=await r.sendRequest("textDocument/diagnostic",{textDocument:{uri:e}},s);if(l.kind!=="full"||!Array.isArray(l.items))throw new Error("Invalid full diagnostic report");if(r.documentVersion(e)!==a)throw new Error("Document changed during diagnostic request");return r.setDiagnosticMode("pull"),He(l.items,!1,!0)}catch(l){if(!Et(l))throw l;r.setDiagnosticMode("push")}}let i=B(r);if(i){r.documentVersion(e)===void 0&&r.syncDocument(e,n??await We(ze.parse(e).fsPath,"utf8"),t??"plaintext");let a=r.documentVersion(e),l=await i.request(r,e,s);if(s.throwIfAborted(),r.documentVersion(e)!==a)throw new Error("Document changed during diagnostic request");return{diagnostics:l,syntaxErrors:[],otherDiagnostics:l,unversioned:!1,complete:!0}}s.throwIfAborted();let o=r.documentVersion(e)!==void 0,u=o?void 0:n??await We(ze.parse(e).fsPath,"utf8");s.throwIfAborted(),r.beginDiagnosticRequest(e);try{return await new Promise((a,l)=>{let d=r.documentVersion(e)??1,p=c(f=>{let w=f;w.uri!==e||!Array.isArray(w.diagnostics)||w.version!==void 0&&w.version!==d||r.documentVersion(e)===d&&(y(),a(He(w.diagnostics,w.version===void 0)))},"receive"),g=r.onNotification("textDocument/publishDiagnostics",p),h=c(()=>{y(),l(s.reason)},"onAbort");function y(){g(),s.removeEventListener("abort",h)}c(y,"cleanup"),s.addEventListener("abort",h,{once:!0});try{o||r.syncDocument(e,u??"",t??"plaintext");let f=r.diagnosticPublication(e);f&&p({uri:e,...f})}catch(f){y(),l(f)}})}finally{r.endDiagnosticRequest(e)}}c(Dt,"requestCurrentDiagnostics");function Q(r){return{code:String(r.code??"LSP"),message:r.message,line:r.range.start.line+1,column:r.range.start.character+1,severity:r.severity===T.Warning?"warning":r.severity===T.Information?"info":r.severity===T.Hint?"hint":"error"}}c(Q,"toDiagnostic");function He(r,e,t=!1){let n=r.map(Q);return{diagnostics:n,syntaxErrors:[],otherDiagnostics:n,unversioned:e,complete:t}}c(He,"classify");function Et(r){return r!==null&&typeof r=="object"&&"code"in r&&r.code===-32601}c(Et,"isMethodNotFound");var It={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 P(r){return It[r]??`SymbolKind(${r})`}c(P,"symbolKindName");async function Z(r,e){return await r.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}})??[]}c(Z,"requestDocumentSymbols");async function ee(r,e,t=100){return(await r.sendRequest("workspace/symbol",{query:e})??[]).slice(0,t)}c(ee,"requestWorkspaceSymbols");async function te(r,e,t,n){return await r.sendRequest("textDocument/rename",{textDocument:{uri:e},position:t,newName:n})}c(te,"requestRename");import S from"node:path";import{URI as At}from"vscode-uri";import{readdir as jt,stat as Mt}from"node:fs/promises";import q from"node:path";import{URI as re}from"vscode-uri";function Ue(r,e){let t=c(n=>typeof n=="string"?n.replaceAll("{project}",()=>e):Array.isArray(n)?n.map(t):n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([s,i])=>[s,t(i)])):n,"expand");return Object.fromEntries(Object.entries(r).map(([n,s])=>[n,t(s)]))}c(Ue,"resolveInitializationOptions");var x=class r{constructor(e){this._registry=e}static{c(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(!r._instance)throw new Error("[lsp] LspManager not initialized");return r._instance}static getInstanceOrNull(){return r._instance}static init(e){let t=r._instance;return t?._disposed?(t._registry=e,t._disposed=!1,t):(r._instance=new r(e),r._instance)}static async resetForTest(){r._instance&&(await r._instance.shutdownAll(),r._instance=null)}get clientCount(){return this._clients.size}onPushDiagnostics(e){return this._pushHandlers.add(e),()=>this._pushHandlers.delete(e)}async getOrStart(e,t,n){if(this._disposed)return null;let s=this._registry.resolve(e),i=n==="symbols"?s[0]:s.find(p=>p.config.capabilities.includes(n));if(!i)return null;let o=re.file(t).toString(),u=`${i.serverId}:${o}`,a=this._clientStarts.get(u);if(a)return a;let l=this._clients.get(u);if(l?.ready)return l;let d=this._startClient(u,o,i,l);this._clientStarts.set(u,d);try{return await d}finally{this._clientStarts.get(u)===d&&this._clientStarts.delete(u)}}async _startClient(e,t,n,s){let i=s??new C({serverId:n.serverId,rootUri:t,command:n.config.command,...n.config.env&&{env:n.config.env},...n.config.initializationOptions&&{initOptions:Ue(n.config.initializationOptions,re.parse(t).fsPath)},...n.config.settings&&{settings:n.config.settings},...n.config.timeoutMs&&{timeoutMs:n.config.timeoutMs}});try{s?await s.restart():await i.start()}catch(o){throw await i.shutdown().catch(()=>{}),o}if(this._disposed)throw await i.shutdown(),new Error(`[lsp] ${n.serverId}: manager disposed during startup`);return this._clients.set(e,i),this._subscribeToPushDiagnostics(e,i),i}async getWorkspaceClients(e,t="symbols",n=e){let s=new Set,i=new Set(this._registry.knownExtensions),o=new Set([".git",".cache","node_modules","dist","build"]),u=c(async l=>{if(i.size===0)return;let d;try{d=await jt(l,{withFileTypes:!0})}catch{return}for(let p of d){if(i.size===0)return;if(p.isDirectory()){o.has(p.name)||await u(q.join(l,p.name));continue}if(!p.isFile())continue;let g=q.extname(p.name).toLowerCase();if(!i.has(g))continue;let h=q.join(l,p.name),y=await this.openFile(h,e,t).catch(()=>null);y&&(s.add(y.client),i.delete(g))}},"visit"),a=q.resolve(e,n);if((await Mt(a)).isFile()){let l=await this.openFile(a,e,t);return l===null?[]:[l.client]}return await u(a),[...s]}async prepareWorkspaceSymbols(e,t=e){return this.getWorkspaceClients(e,"symbols",t)}hasServerFor(e){return this._registry.resolve(e).length>0}languageId(e){return this._registry.languageId(e)}isOpen(e){return this._openDocs.has(e)}async openFile(e,t,n="diagnostics"){let s=q.resolve(t,e),i=await this.getOrStart(s,t,n);if(!i)return null;let o=i.toUri(s),a=this._registry.resolve(s)[0]?.languageId??"plaintext";try{let{readFile:l}=await import("node:fs/promises"),d=await l(s,"utf8");i.openDocument(o,d,a),this._openDocs.add(o)}catch{}return{client:i,uri:o,languageId:a}}_subscribeToPushDiagnostics(e,t){if(this._pushUnsubscribers.has(e))return;let n=t.onNotification("textDocument/publishDiagnostics",s=>{let i=$t(s);if(!i||t.hasActiveDiagnosticRequest(i.uri))return;let o=t.documentVersion(i.uri);if(i.version!==void 0&&o!==void 0&&i.version<o)return;let u=`${e}:${i.uri}`,a=i.diagnostics.map(Q),l=JSON.stringify([i.version,o,a]);if(this._pushFingerprints.get(u)===l)return;this._pushFingerprints.set(u,l);let d={cwd:re.parse(t.rootUri).fsPath,serverId:t.serverId,uri:i.uri,diagnostics:a,...i.version!==void 0&&{version:i.version}};for(let p of this._pushHandlers)p(d)});this._pushUnsubscribers.set(e,n)}async shutdownAll(){this._disposed=!0,await Promise.allSettled(this._clientStarts.values());let e=[...this._clients.values()];await Promise.all(e.map(t=>t.shutdown()));for(let t of this._pushUnsubscribers.values())t();this._pushUnsubscribers.clear(),this._clientStarts.clear(),this._pushFingerprints.clear(),this._pushHandlers.clear(),this._clients.clear()}dispose(){this.shutdownAll()}};function $t(r){if(r===null||typeof r!="object")return;let e=r;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}c($t,"parsePushNotification");async function N(r,e,t){return await r.sendRequest("textDocument/references",{textDocument:{uri:e},position:t,context:{includeDeclaration:!0}})??[]}c(N,"requestReferences");async function ne(r,e,t){let n=await r.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:t}),s=n?.[0];if(!s)return{items:[],incoming:[],outgoing:[]};let[i,o]=await Promise.all([r.sendRequest("callHierarchy/incomingCalls",{item:s}).catch(()=>[]),r.sendRequest("callHierarchy/outgoingCalls",{item:s}).catch(()=>[])]);return{items:n,incoming:i??[],outgoing:o??[]}}c(ne,"requestCallHierarchy");function Ge(r,e,t){let n=S.relative(S.resolve(e,t.path??"."),r);if(n===".."||n.startsWith(`..${S.sep}`)||S.isAbsolute(n))return!1;let s=S.relative(e,r).split(S.sep).join("/"),i=c(o=>o.split(",").some(u=>{let a=u.trim();return a.length>0&&S.matchesGlob(a.includes("/")?s:S.basename(r),a)}),"matches");return(t.include===void 0||i(t.include))&&(t.exclude===void 0||!i(t.exclude))}c(Ge,"withinScope");function J(r){try{return At.parse(r).fsPath}catch{return r.startsWith("file://")?decodeURIComponent(r.slice(7)):r}}c(J,"uriToFilePath");function Be(r,e,t,n,s){let i=J(t),o=S.relative(r,i);return{filePath:o.startsWith("..")?i:o,lineNumber:n+1,column:s+1,kind:String(e.kind),name:e.name}}c(Be,"toHit");async function se(r,e,t,n,s={},i=x.getInstance()){if(n?.aborted)throw new Error("Operation aborted");let o=await i.prepareWorkspaceSymbols(e,s.path??e),u=[];for(let d of o){if(n?.aborted)throw new Error("Operation aborted");try{u.push(...await ee(d,r,Number.MAX_SAFE_INTEGER))}catch{}}let a=new Set,l=[];for(let d of u){if(n?.aborted)throw new Error("Operation aborted");if(l.length>=t)break;let p=d.location,g=Be(e,d,p.uri,p.range.start.line,p.range.start.character),h=`${g.filePath}:${g.lineNumber}:${g.column}`;if(Ge(J(p.uri),e,s)&&!a.has(h)&&(a.add(h),l.push(g)),l.length>=t)break;let y=J(p.uri),f=await i.openFile(y,e,"symbols").catch(()=>null);if(!f)continue;let w=await N(f.client,f.uri,p.range.start).catch(()=>[]);for(let R of w){let z=Be(e,d,R.uri,R.range.start.line,R.range.start.character),ge=`${z.filePath}:${z.lineNumber}:${z.column}`;if(Ge(J(R.uri),e,s)&&!a.has(ge)&&(a.add(ge),l.push(z)),l.length>=t)break}}return l}c(se,"searchSymbols");import{readFile as V}from"node:fs/promises";import j from"node:path";import{fileURLToPath as Tt}from"node:url";var Ot={failureLabel:"SYMBOL_READ_FAILED",emptyReason:"no symbol source was produced."},ie=10,oe=5,M=10;async function Xe(r,e,t,n,s){L(s);let i=await V(e,"utf8"),o=await W(r,e,n),u=F(o.symbols,t,o.displayPath),a=await V(o.filePath,"utf8");if(L(s),i!==a)throw new Error("The symbol source changed during resolution. Read it again before editing.");return{source:o.filePath,range:u.range,content:a}}c(Xe,"resolveLspDeclaration");async function Ye(r,e,t,n,s){L(s);let i=await V(e,"utf8"),o=await W(r,e,n),u=F(o.symbols,t,o.displayPath);if(i!==await V(e,"utf8"))throw new Error("The rename source changed during resolution.");return L(s),{client:o.client,uri:o.uri,position:u.selectionRange.start,content:i}}c(Ye,"resolveLspRenameTarget");async function le(r,e,t,n,s){L(s);let i=await W(r,e,n),o=F(i.symbols,t,i.displayPath),u=await zt(i.filePath);L(s);let a=o.range.start.line+1,l=Math.min(o.range.end.line+1,u.lines.length),d=u.lines.slice(Math.max(0,a-1),Math.max(0,l)).map((g,h)=>{let y=a+h;return me({content:g,sourceLine:{source:i.filePath,lineNumber:y,content:g}})}),p={path:i.displayPath,heading:`symbol: ${k(o.selector)}`,details:[`defined in: ${i.displayPath}:${a}-${l} (${P(o.kind)})`],startLine:a,endLine:l,totalLines:u.lines.length,renderedLines:d};return fe([p],Ot)}c(le,"readLspSymbolBody");async function de(r,e,t,n,s){L(s);let i=await W(r,e,n),o=F(i.symbols,t,i.displayPath),u=await tt(i,o,s),a=new K(n);return await qt(i,o,u,a)}c(de,"readLspSymbolGraph");async function ue(r,e,t,n){L(n);let s=await W(r,e,t),i=new K(t),o=[`## file graph: ${s.displayPath}`,`Top-level declarations: ${s.symbols.length}`];for(let u of s.symbols){L(n);let a=await tt(s,u,n);o.push("",...await Wt(s,u,a,i))}return o.join(`
2
+ `)}c(ue,"readLspFileGraph");function F(r,e,t){if(e.length===0)throw new TypeError("A symbol selector must contain at least one segment.");if(e.length===1){let i=et(r,v(e[0]));if(i.length===1)return v(i[0]);throw i.length>1?new Error(`Symbol selector "${k(e)}" is ambiguous in ${t}; use parent/child.`):Je(e,t)}let n=r,s;for(let i of e){let o=n.filter(u=>u.name===i);if(o.length===0)throw Je(e,t);if(o.length>1)throw new Error(`Symbol selector "${k(e)}" is ambiguous at "${i}" in ${t}.`);s=v(o[0]),n=s.children}return v(s)}c(F,"resolveLspCodeSymbol");async function W(r,e,t){let n=j.isAbsolute(e)?j.normalize(e):j.resolve(t,e),s=await r.openFile(n,t,"symbols");if(!s)throw new Error(`No LSP server with symbol support is configured for ${ce(n,t)}.`);let i=await Z(s.client,s.uri),o=Qe(i).sort(Ze);return{client:s.client,uri:s.uri,filePath:n,displayPath:ce(n,t),symbols:o}}c(W,"openCodeDocument");function Qe(r,e=[]){return r.flatMap(t=>{let n=t.selectionRange??t.range;if(!n)return[];let s=t.range??n,i=[...e,t.name];return[{name:t.name,kind:t.kind,range:s,selectionRange:n,selector:i,children:Qe(t.children??[],i).sort(Ze)}]})}c(Qe,"normalizeDocumentSymbols");function Ze(r,e){return r.range.start.line-e.range.start.line||r.range.start.character-e.range.start.character||r.name.localeCompare(e.name)}c(Ze,"compareSymbols");function et(r,e){return r.flatMap(t=>[...t.name===e?[t]:[],...et(t.children,e)])}c(et,"collectNamedSymbols");function Je(r,e){return new Error(`Symbol "${k(r)}" was not found in ${e}.`)}c(Je,"symbolNotFound");async function tt(r,e,t){let n=e.selectionRange.start,[s,i]=await Promise.all([Ke(N(r.client,r.uri,n),[],t),Ke(ne(r.client,r.uri,n),{items:[],incoming:[],outgoing:[]},t)]);return L(t),{references:s,calls:i}}c(tt,"queryRelations");async function Ke(r,e,t){try{let n=await r;return L(t),n}catch(n){if(t?.aborted===!0)throw nt(t,n);return e}}c(Ke,"optionalRequest");async function qt(r,e,t,n){let s=k(e.selector),i=await n.line(r.uri,e.selectionRange.start.line+1);return[`## graph: ${s}`,`Definition: ${r.displayPath} ${i} (${P(e.kind)})`,`Source: ${$("graph",r.displayPath,e.selector)}`,"",...await Nt(t.references,n),"",...await Vt(t.calls.incoming,n),"",...await Ft(t.calls.outgoing,n)].join(`
3
+ `)}c(qt,"formatSymbolGraph");async function Nt(r,e){let t=rt(r),n=[`References: ${r.length} in ${t.length} file(s)`];for(let[s,i]of t.slice(0,ie)){n.push(`- ${e.display(s)} (${i.length})`);for(let o of i.slice(0,oe))n.push(` - ${await e.line(s,o.range.start.line+1)}`);i.length>oe&&n.push(` - ... ${i.length-oe} more`)}return t.length>ie&&n.push(`- ... ${t.length-ie} more file(s)`),n}c(Nt,"formatReferences");async function Vt(r,e){let t=[`Incoming calls: ${r.length}`];for(let n of r.slice(0,M)){let s=n.fromRanges[0]?.start.line??n.from.selectionRange.start.line,i=await e.line(n.from.uri,s+1);t.push(`- ${P(n.from.kind)} ${n.from.name} \u2014 ${e.display(n.from.uri)} ${i}`)}return r.length>M&&t.push(`- ... ${r.length-M} more`),t}c(Vt,"formatIncomingCalls");async function Ft(r,e){let t=[`Outgoing calls: ${r.length}`];for(let n of r.slice(0,M)){let s=await e.line(n.to.uri,n.to.selectionRange.start.line+1);t.push(`- ${P(n.to.kind)} ${n.to.name} \u2014 ${e.display(n.to.uri)} ${s}`)}return r.length>M&&t.push(`- ... ${r.length-M} more`),t}c(Ft,"formatOutgoingCalls");async function Wt(r,e,t,n){let s=P(e.kind),i=await n.line(r.uri,e.selectionRange.start.line+1),o=rt(t.references).map(([d,p])=>`${n.display(d)} (${p.length})`),u=t.calls.incoming.map(d=>`${d.from.name} (${n.display(d.from.uri)})`),a=t.calls.outgoing.map(d=>`${d.to.name} (${n.display(d.to.uri)})`),l=[`### ${s} ${e.name}`,`Selector: ${k(e.selector)}`,`Definition: ${i}`,`Used by: ${ae(o)}`,`Incoming calls: ${ae(u)}`,`Outgoing calls: ${ae(a)}`];if(e.children.length>0){l.push("Members:");for(let d of e.children){let p=$("graph",r.displayPath,d.selector);l.push(`- ${P(d.kind)} ${d.name} \u2014 ${p}`)}}return l}c(Wt,"formatFileGraphSymbol");function ae(r,e=5){if(r.length===0)return"none";let t=r.slice(0,e).join(", ");return r.length>e?`${t}, ... ${r.length-e} more`:t}c(ae,"summarize");function rt(r){let e=new Map;for(let t of r){let n=e.get(t.uri)??[];n.push(t),e.set(t.uri,n)}return[...e].map(([t,n])=>[t,n.sort((s,i)=>s.range.start.line-i.range.start.line||s.range.start.character-i.range.start.character)]).sort(([t],[n])=>t.localeCompare(n))}c(rt,"groupLocationsByUri");async function zt(r){let e=await V(r);if(e.byteLength>256*1024)throw new Error(`File exceeds the 262144-byte code-view limit: ${r}`);if(e.includes(0))throw new Error(`File appears to be binary and cannot be read as text: ${r}`);let t=e.toString("utf8").replaceAll(`\r
4
4
  `,`
5
5
  `),n=t.endsWith(`
6
6
  `)?t.slice(0,-1):t,s=n.length===0?[]:n.split(`
7
- `);return{content:t,lines:s}}c(Ct,"readTextFile");var V=class{static{c(this,"LocationPresenter")}#e;constructor(e){this.#e=e}display(e){return Q(xt(e),this.#e)}line(e,t){return Promise.resolve(String(t))}};function xt(r){if(!r.startsWith("file://"))return r;try{return wt(r)}catch{return decodeURIComponent(r.slice(7))}}c(xt,"filePathFromUri");function Q(r,e){let t=x.relative(e,r);return t.length===0||t.startsWith("..")||x.isAbsolute(t)?r:t.replaceAll(x.sep,"/")}c(Q,"displayFilePath");function P(r){if(r?.aborted===!0)throw ze(r)}c(P,"throwIfAborted");function ze(r,e){if(r.reason instanceof Error)return r.reason;if(e instanceof Error)return e;let t=new Error("The operation was aborted");return t.name="AbortError",t}c(ze,"abortReason");function se(r){let e=null;return{kind:"compiler",name:"lsp",priority:100,extensions:["*"],detect:c(()=>Promise.resolve(!0),"detect"),async compile({filePath:t},n){let s=await Dt(t,n,r);if(!s)return Et();let{client:i,diagnostics:o,syntaxErrors:l,otherDiagnostics:a}=s;return e=i,{ok:!o.some(p=>p.severity==="error"),diagnostics:o,syntaxErrors:l,otherDiagnostics:a}},async restart(){e&&(await e.restart(),e=null)}}}c(se,"createLspCompiler");async function Dt(r,e,t){let n=await t.openFile(r,e.cwd);if(!n)return null;let s=await j(n.client,n.uri,n.languageId);return{client:n.client,...s}}c(Dt,"openAndDiagnose");function Et(){return{ok:!0,diagnostics:[],syntaxErrors:[],otherDiagnostics:[]}}c(Et,"skipOk");import y from"node:path";import{existsSync as It}from"node:fs";function He(r){let e=new Map,t=new Map;for(let[n,s]of Object.entries(r))for(let[i,o]of Object.entries(s.languages))for(let l of o.extensions){let a=l.toLowerCase(),p=e.get(a);if(p!==void 0&&p!==i)throw new Error(`[lsp] extension conflict: "${a}" claimed by "${p}" and "${i}"`);e.set(a,i);let d=t.get(a)??[];d.push(n),t.set(a,d)}return{extToLanguageId:e,extToServerIds:t}}c(He,"buildLanguageLookup");var S=class r{constructor(e,t,n){this._projectRoot=n;this._entries=e;let s=e.filter(i=>i.layer!=="built-in"||t.has(i.id));this._servers=Object.fromEntries(s.map(i=>[i.id,i.config])),this._lookup=He(this._servers)}static{c(this,"LspServerRegistry")}_servers;_entries;_lookup;static async fromPackageDir(e,t={}){let n=await fe(e,"lsp-servers",o=>jt(o).servers,t),s=t.environment??process.env,i=await Promise.all(n.entries.filter(o=>o.layer==="built-in").map(async o=>({id:o.id,available:await A(o.config,e,s)})));return new r(n.entries,new Set(i.filter(o=>o.available).map(o=>o.id)),y.resolve(e))}static fromConfig(e,t=process.cwd()){return new r(Object.entries(e.servers).map(([n,s])=>({id:n,config:s,layer:"project",sourcePath:"<memory>"})),new Set,y.resolve(t))}resolve(e){let t=y.basename(e),n=y.extname(e)||(e.startsWith(".")?e:`.${e}`),s=c(o=>process.platform==="win32"?o.toLowerCase():o,"normalizeName"),i=[];for(let o of this._entries)if(this._servers[o.id]&&!(o.config.requireRootMarker&&!this.hasRootMarker(e,o.config.rootMarkers))){for(let[l,a]of Object.entries(o.config.languages))if(a.extensions.some(p=>p.toLowerCase()===n.toLowerCase())||a.fileNames?.some(p=>s(p)===s(t))){i.push({serverId:o.id,config:o.config,languageId:l,layer:o.layer,sourcePath:o.sourcePath});break}}return i}hasRootMarker(e,t){let n=y.dirname(y.resolve(this._projectRoot,e));for(e.startsWith(".")&&!e.includes(y.sep)&&(n=this._projectRoot);;){let s=y.relative(this._projectRoot,n);if(s===".."||s.startsWith(`..${y.sep}`)||y.isAbsolute(s))return!1;if(t.some(i=>It(y.join(n,i))))return!0;if(n===this._projectRoot)return!1;n=y.dirname(n)}}get servers(){return this._servers}get entries(){return this._entries}get knownExtensions(){return new Set(this._lookup.extToLanguageId.keys())}languageId(e){return this.resolve(e)[0]?.languageId??e.slice(1)}};function jt(r){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error("LSP config must be an object");let e=r;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,n]of Object.entries(e.servers)){if(typeof n!="object"||n===null||Array.isArray(n))throw new Error(`LSP server ${t} must be an object`);let s=n;if(!Array.isArray(s.command)||s.command.length===0||s.command.some(i=>typeof i!="string"||i.length===0))throw new Error(`LSP server ${t}.command must be a non-empty string array`);if(s.transport!==void 0&&s.transport!=="stdio")throw new Error(`LSP server ${t} only supports stdio transport`);if(!Array.isArray(s.rootMarkers)||s.rootMarkers.some(i=>typeof i!="string"))throw new Error(`LSP server ${t}.rootMarkers must be a string array`);if(s.requireRootMarker!==void 0&&typeof s.requireRootMarker!="boolean")throw new TypeError(`LSP server ${t}.requireRootMarker must be a boolean`);if(s.requireRootMarker&&s.rootMarkers.length===0)throw new Error(`LSP server ${t}.requireRootMarker requires rootMarkers`);if(typeof s.languages!="object"||s.languages===null||Array.isArray(s.languages))throw new Error(`LSP server ${t}.languages must be an object`);for(let[i,o]of Object.entries(s.languages)){let l=typeof o=="object"&&o!==null&&!Array.isArray(o)?o.extensions:void 0;if(!Array.isArray(l)||l.length===0||l.some(p=>typeof p!="string"))throw new Error(`LSP server ${t} language ${i} requires extensions`);let a=o.fileNames;if(a!==void 0&&(!Array.isArray(a)||a.some(p=>typeof p!="string"||p.length===0||/[/\\]/u.test(p))))throw new Error(`LSP server ${t} language ${i}.fileNames must contain basenames`)}if(!Array.isArray(s.capabilities))throw new TypeError(`LSP server ${t}.capabilities must be an array`)}return r}c(jt,"parseLspConfig");function Ue(r){return Be("symbol","lsp-symbol",r,async e=>await Z(e.manager,e.filePath,h(e.selector),e.cwd,e.signal))}c(Ue,"createLspSymbolResolver");function Ge(r){return Be("graph","lsp-graph",r,async e=>e.selector===void 0?await te(e.manager,e.filePath,e.cwd,e.signal):await ee(e.manager,e.filePath,e.selector,e.cwd,e.signal))}c(Ge,"createLspGraphResolver");function Be(r,e,t,n){return{id:e,tryResolve(s,i){return Promise.resolve(Mt(s,i,r,t,n))}}}c(Be,"createCodeViewResolver");function Mt(r,e,t,n,s){let i;try{i=oe(r,t)}catch(a){return{kind:"failed",error:a}}if(i===void 0)return{kind:"not-handled"};let o;try{o=ae(i.path,e.cwd)}catch(a){return{kind:"failed",error:a}}return{kind:"resolved",resource:{source:E(t,o,i.selector),async read(a){let p=await n(e.cwd),d=await s({manager:p,filePath:o,cwd:e.cwd,...$t(i.selector),...At(a.signal)});return[typeof d=="string"?{type:"text",text:d}:d]}}}}c(Mt,"resolveCodeViewSource");function $t(r){return r===void 0?{}:{selector:r}}c($t,"optionalSelector");function At(r){return r===void 0?{}:{signal:r}}c(At,"optionalSignal");function Ke(r){return{id:"lsp",async diagnose(e,t){let n=await r(t.cwd);t.signal.throwIfAborted();let s=await n.getOrStart(e,t.cwd,"diagnostics");if(t.signal.throwIfAborted(),!s)return{status:"unavailable",diagnostics:[],reason:"No language server configured for this file"};let i=s.toUri(e),o=n.languageId(e);s.syncDocument(i,t.content,o,!0);let l=s.documentVersion(i),a={active:!0,queued:!1},p=c(()=>!t.signal.aborted&&s.documentVersion(i)===l,"current"),d=c(()=>j(s,i,o,{signal:t.signal,content:t.content}),"request"),m=c(async()=>{if(a.queued=!0,!a.active){a.active=!0;try{for(;a.queued&&p();){a.queued=!1;let g=await d();p()&&t.publish(Je(g,s.commandName))}}catch(g){p()&&t.publish({status:"unavailable",diagnostics:[],reason:g instanceof Error?g.message:String(g),source:s.commandName})}finally{a.active=!1}}},"refresh"),f=n.onPushDiagnostics(g=>{!p()||g.uri!==i||g.serverId!==s.serverId||g.cwd!==t.cwd||g.version!==void 0&&g.version!==l||(s.diagnosticMode==="pull"||q(s)?m():t.publish({status:"snapshot",diagnostics:g.diagnostics,source:s.commandName,reason:Xe(g.version===void 0)}))});t.signal.addEventListener("abort",f,{once:!0});try{let g=await d();return l=s.documentVersion(i),Je(g,s.commandName)}catch(g){throw a.queued=!1,f(),t.signal.removeEventListener("abort",f),g}finally{a.active=!1,a.queued&&p()&&queueMicrotask(()=>{m()})}}}}c(Ke,"createLspDiagnosticSource");function Xe(r){return`Latest push snapshot; completion is unknown${r?"; language server omitted the document version":""}`}c(Xe,"snapshotReason");function Je(r,e){return r.complete?{status:"ready",diagnostics:r.diagnostics,source:e}:{status:"snapshot",diagnostics:r.diagnostics,reason:Xe(r.unversioned),source:e}}c(Je,"toReport");import{URI as Ot}from"vscode-uri";var Ye=[{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"]}]}}},u("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}}),u("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"]}}},u("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"]),u("dart-language-server",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],{dart:[".dart"]},["dart","language-server","--protocol=lsp"],"https://dart.dev/tools/dart-language-server"),u("r-language-server",["r"],["Rscript"],["DESCRIPTION",".lintr",".Rprofile"],{r:[".r"]},["Rscript","-e","languageserver::run()"],"https://github.com/REditorSupport/languageserver"),u("zls",["zig"],["zls"],["build.zig","build.zig.zon","zls.json"],{zig:[".zig",".zon"]},["zls"],"https://zigtools.org/zls/"),u("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/"),u("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"]),u("basedpyright",["python"],["basedpyright-langserver","pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),u("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),u("rust-analyzer",["rust"],["rust-analyzer"],["Cargo.toml","rust-project.json"],{rust:[".rs"]},["rust-analyzer"],"https://rust-analyzer.github.io/"),u("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),u("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),u("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"),u("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),u("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),u("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),u("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),u("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),u("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:{}}),u("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"),u("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"),u("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),u("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),u("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),u("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"),u("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"),u("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"),u("neocmakelsp",["cmake"],["neocmakelsp"],["CMakeLists.txt",".neocmake.toml",".neocmakelint.toml"],{cmake:[".cmake"]},["neocmakelsp","stdio"],"https://github.com/neocmakelsp/neocmakelsp",void 0,{cmake:["CMakeLists.txt"]}),u("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"),u("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),u("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),u("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 u(r,e,t,n,s,i,o,l,a,p){return{id:r,name:r,kind:"lsp",languages:e,executables:t,configFiles:n,documentation:o,...l&&{dependencies:l},lsp:{command:i,rootMarkers:n,languageIds:s,...a&&{fileNames:a},...p&&{settings:p}}}}c(u,"recipe");var Qe={protocol:ye,apiVersion:1,id:"lsp",setup(r){for(let e of Ye)r.addToolRecipe(e);r.addSetupCheck({id:"effective-config",inspect:Tt}),r.addCheck({id:"config",title:"LSP",async run(e){try{let t=await S.fromPackageDir(e.cwd,{environment:e.env}),n=qt(t,e.files);return n.length===0?[{status:"skip",message:"No language server matches the inspected project files"}]:await Promise.all(n.map(async s=>{let i=`${s.serverId} [${s.layer}] command ${JSON.stringify(s.config.command)}`,o=new _({serverId:s.serverId,rootUri:Ot.file(e.cwd).toString(),command:s.config.command,env:Nt(e.env,s.config.env),...s.config.initializationOptions&&{initOptions:s.config.initializationOptions},...s.config.settings&&{settings:s.config.settings},...s.config.timeoutMs&&{timeoutMs:s.config.timeoutMs}});try{return await o.start(),{status:"pass",message:`${i}: initialized`,detail:s.sourcePath}}catch(l){return{status:"fail",message:`${i}: ${l instanceof Error?l.message:String(l)}`,detail:s.sourcePath}}finally{await o.shutdown().catch(()=>{})}}))}catch(t){return[{status:"fail",message:t instanceof Error?t.message:String(t)}]}}})}};async function Tt(r){try{let e=await S.fromPackageDir(r.cwd,{environment:r.env}),t=[],n=new Map;for(let[s,i]of r.detectedLanguages){let o=i.flatMap(l=>e.resolve(l)).find(l=>l.languageId===s);o!==void 0&&(t.push({kind:"lsp",languageId:s,toolId:o.serverId}),await A(o.config,r.cwd,r.env)||n.set(o.serverId,{id:`lsp-${o.serverId}-unavailable`,message:`Configured language server ${o.serverId} cannot run ${JSON.stringify(o.config.command)}`}))}return{selections:t,actions:[...n.values()]}}catch(e){return{actions:[{id:"lsp-config-invalid",message:`Language server configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}c(Tt,"inspectLspSetup");function qt(r,e){let t=new Map;for(let n of e){let s=r.resolve(n)[0];s!==void 0&&!t.has(s.serverId)&&t.set(s.serverId,s)}return[...t.values()]}c(qt,"applicableServers");function Nt(r,e){return Object.fromEntries(Object.entries({...r,...e}).filter(t=>t[1]!==void 0))}c(Nt,"definedEnvironment");function Ze(r){return{id:"symbols",async tryResolve(e,t){if(!e.query.startsWith("symbols:"))return{kind:"not-handled"};let n=e.query.slice(8).trim();if(n.length===0)return{kind:"failed",error:new Error("symbols: query must not be empty")};await r(t.cwd);let s=await J(n,t.cwd,e.limit??100,t.signal);return{kind:"resolved",payload:{query:n,hits:s}}},format(e){let{query:t,hits:n}=e;return{content:[{type:"text",text:n.length===0?"No symbols found.":n.map((i,o)=>`${String(o+1)}. ${i.filePath}:${String(i.lineNumber)}:${String(i.column)} ${i.kind} ${i.name}`).join(`
8
- `)}],details:{query:t,hits:n}}}}}c(Ze,"createLspSearchResolver");var et=Re({kind:"code-view",label:"LSP"});async function Vt(r){let e=new Map,t=!1,n=c(l=>{if(t)return Promise.reject(new Error("LSP session has ended"));let a=e.get(l);return a||(a=Ft(l).then(p=>{if(t)throw new Error("LSP session has ended");return k.init(p)}),e.set(l,a)),a},"managerFor"),s={kind:"compiler",name:"pi-agent-ide-lsp",priority:200,extensions:["*"],detect:c(async l=>(await n(l.cwd),!0),"detect"),async compile(l,a){let p=await n(a.cwd);return se(p).compile(l,a)}},i={protocol:de,apiVersion:3,id:"lsp",setup(l){l.addTool(s),l.addDiagnosticSource(Ke(n))}};r.on("session_shutdown",async()=>{t=!0,await Promise.allSettled([...e.values()].map(async l=>(await l).shutdownAll())),e.clear()});let o={protocol:we,apiVersion:Le,id:"lsp",setup(l){l.addResolver({resolver:Ue(n),renderResult:et}),l.addResolver({resolver:Ge(n),renderResult:et}),l.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler:pe()}),l.describe("symbol:<file>#<selector> \u2014 declaration source, e.g. symbol:src/catalog.ts#Catalog/find. graph:<file> \u2014 top-level declarations, references and calls; members include selectors. graph:<file>#<selector> \u2014 references and incoming/outgoing calls for that declaration or member.")}};await Promise.all([ge(r,i),Se(r,o),be(r,Qe),Pe(r,{protocol:_e,apiVersion:ke,id:"symbols",setup(l){l.addResolver({resolver:Ze(n)}),l.describe("Use `symbols:<query>` to search workspace symbols and their references through configured language servers.")}})])}c(Vt,"registerLsp");async function Ft(r){let e=process.env.PI_AGENT_IDE_CONFIG_DIR??r;return S.fromPackageDir(e)}c(Ft,"loadRegistry");export{Vt as default};
7
+ `);return{content:t,lines:s}}c(zt,"readTextFile");var K=class{static{c(this,"LocationPresenter")}#e;constructor(e){this.#e=e}display(e){return ce(Ht(e),this.#e)}line(e,t){return Promise.resolve(String(t))}};function Ht(r){if(!r.startsWith("file://"))return r;try{return Tt(r)}catch{return decodeURIComponent(r.slice(7))}}c(Ht,"filePathFromUri");function ce(r,e){let t=j.relative(e,r);return t.length===0||t.startsWith("..")||j.isAbsolute(t)?r:t.replaceAll(j.sep,"/")}c(ce,"displayFilePath");function L(r){if(r?.aborted===!0)throw nt(r)}c(L,"throwIfAborted");function nt(r,e){if(r.reason instanceof Error)return r.reason;if(e instanceof Error)return e;let t=new Error("The operation was aborted");return t.name="AbortError",t}c(nt,"abortReason");function pe(r){let e=null;return{kind:"compiler",name:"lsp",priority:100,extensions:["*"],detect:c(()=>Promise.resolve(!0),"detect"),async compile({filePath:t},n){let s=await Ut(t,n,r);if(!s)return Gt();let{client:i,diagnostics:o,syntaxErrors:u,otherDiagnostics:a}=s;return e=i,{ok:!o.some(l=>l.severity==="error"),diagnostics:o,syntaxErrors:u,otherDiagnostics:a}},async restart(){e&&(await e.restart(),e=null)}}}c(pe,"createLspCompiler");async function Ut(r,e,t){let n=await t.openFile(r,e.cwd);if(!n)return null;let s=await O(n.client,n.uri,n.languageId);return{client:n.client,...s}}c(Ut,"openAndDiagnose");function Gt(){return{ok:!0,diagnostics:[],syntaxErrors:[],otherDiagnostics:[]}}c(Gt,"skipOk");import b from"node:path";import{existsSync as Bt}from"node:fs";function st(r){let e=new Map,t=new Map;for(let[n,s]of Object.entries(r))for(let[i,o]of Object.entries(s.languages))for(let u of o.extensions){let a=u.toLowerCase(),l=e.get(a);if(l!==void 0&&l!==i)throw new Error(`[lsp] extension conflict: "${a}" claimed by "${l}" and "${i}"`);e.set(a,i);let d=t.get(a)??[];d.push(n),t.set(a,d)}return{extToLanguageId:e,extToServerIds:t}}c(st,"buildLanguageLookup");var _=class r{constructor(e,t,n){this._projectRoot=n;this._entries=e;let s=e.filter(i=>i.layer!=="built-in"||t.has(i.id));this._servers=Object.fromEntries(s.map(i=>[i.id,i.config])),this._lookup=st(this._servers)}static{c(this,"LspServerRegistry")}_servers;_entries;_lookup;static async fromPackageDir(e,t={}){let n=await Re(e,"lsp-servers",u=>Jt(u).servers,t),s=t.environment??process.env,i=await Promise.all(n.entries.filter(u=>u.layer==="built-in").map(async u=>({id:u.id,available:await H(u.config,e,s)}))),o=t.requireBuiltInEvidence?await we(e,t.recipes??[]):void 0;return new r(n.entries,new Set(i.filter(u=>u.available&&(o===void 0||(o.get(u.id)?.score??0)>0)).map(u=>u.id)),b.resolve(e))}static fromConfig(e,t=process.cwd()){return new r(Object.entries(e.servers).map(([n,s])=>({id:n,config:s,layer:"project",sourcePath:"<memory>"})),new Set,b.resolve(t))}resolve(e){let t=b.basename(e),n=b.extname(e)||(e.startsWith(".")?e:`.${e}`),s=c(o=>process.platform==="win32"?o.toLowerCase():o,"normalizeName"),i=[];for(let o of this._entries)if(this._servers[o.id]&&!(o.config.requireRootMarker&&!this.hasRootMarker(e,o.config.rootMarkers))){for(let[u,a]of Object.entries(o.config.languages))if(a.extensions.some(l=>l.toLowerCase()===n.toLowerCase())||a.fileNames?.some(l=>s(l)===s(t))){i.push({serverId:o.id,config:o.config,languageId:u,layer:o.layer,sourcePath:o.sourcePath});break}}return i}hasRootMarker(e,t){let n=b.dirname(b.resolve(this._projectRoot,e));for(e.startsWith(".")&&!e.includes(b.sep)&&(n=this._projectRoot);;){let s=b.relative(this._projectRoot,n);if(s===".."||s.startsWith(`..${b.sep}`)||b.isAbsolute(s))return!1;if(t.some(i=>Bt(b.join(n,i))))return!0;if(n===this._projectRoot)return!1;n=b.dirname(n)}}get servers(){return this._servers}get entries(){return this._entries}get knownExtensions(){return new Set(this._lookup.extToLanguageId.keys())}languageId(e){return this.resolve(e)[0]?.languageId??e.slice(1)}};function Jt(r){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error("LSP config must be an object");let e=r;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,n]of Object.entries(e.servers)){if(typeof n!="object"||n===null||Array.isArray(n))throw new Error(`LSP server ${t} must be an object`);let s=n;if(!Array.isArray(s.command)||s.command.length===0||s.command.some(i=>typeof i!="string"||i.length===0))throw new Error(`LSP server ${t}.command must be a non-empty string array`);if(s.transport!==void 0&&s.transport!=="stdio")throw new Error(`LSP server ${t} only supports stdio transport`);if(!Array.isArray(s.rootMarkers)||s.rootMarkers.some(i=>typeof i!="string"))throw new Error(`LSP server ${t}.rootMarkers must be a string array`);if(s.requireRootMarker!==void 0&&typeof s.requireRootMarker!="boolean")throw new TypeError(`LSP server ${t}.requireRootMarker must be a boolean`);if(s.requireRootMarker&&s.rootMarkers.length===0)throw new Error(`LSP server ${t}.requireRootMarker requires rootMarkers`);if(typeof s.languages!="object"||s.languages===null||Array.isArray(s.languages))throw new Error(`LSP server ${t}.languages must be an object`);for(let[i,o]of Object.entries(s.languages)){let u=typeof o=="object"&&o!==null&&!Array.isArray(o)?o.extensions:void 0;if(!Array.isArray(u)||u.length===0||u.some(l=>typeof l!="string"))throw new Error(`LSP server ${t} language ${i} requires extensions`);let a=o.fileNames;if(a!==void 0&&(!Array.isArray(a)||a.some(l=>typeof l!="string"||l.length===0||/[/\\]/u.test(l))))throw new Error(`LSP server ${t} language ${i}.fileNames must contain basenames`)}if(!Array.isArray(s.capabilities))throw new TypeError(`LSP server ${t}.capabilities must be an array`)}return r}c(Jt,"parseLspConfig");function it(r){return at("symbol","lsp-symbol",r,async e=>await le(e.manager,e.filePath,v(e.selector),e.cwd,e.signal))}c(it,"createLspSymbolResolver");function ot(r){return at("graph","lsp-graph",r,async e=>e.selector===void 0?await ue(e.manager,e.filePath,e.cwd,e.signal):await de(e.manager,e.filePath,e.selector,e.cwd,e.signal))}c(ot,"createLspGraphResolver");function at(r,e,t,n){return{id:e,tryResolve(s,i){return Promise.resolve(Kt(s,i,r,t,n))}}}c(at,"createCodeViewResolver");function Kt(r,e,t,n,s){let i;try{i=D(r,t)}catch(a){return{kind:"failed",error:a}}if(i===void 0)return{kind:"not-handled"};let o;try{o=E(i.path,e.cwd)}catch(a){return{kind:"failed",error:a}}return{kind:"resolved",resource:{source:$(t,o,i.selector),async read(a){let l=await n(e.cwd),d=await s({manager:l,filePath:o,cwd:e.cwd,...Xt(i.selector),...Yt(a.signal)});return[typeof d=="string"?{type:"text",text:d}:d]}}}}c(Kt,"resolveCodeViewSource");function Xt(r){return r===void 0?{}:{selector:r}}c(Xt,"optionalSelector");function Yt(r){return r===void 0?{}:{signal:r}}c(Yt,"optionalSignal");function lt(r,e=(t,n)=>Promise.resolve({cwd:n,external:!1})){return{id:"lsp",async diagnose(t,n){let s=await e(t,n.cwd);if(s===void 0)return{status:"unavailable",diagnostics:[],reason:"No local language-server project found for this file"};let i=await r(s.cwd,s.external);n.signal.throwIfAborted();let o=await i.getOrStart(t,s.cwd,"diagnostics");if(n.signal.throwIfAborted(),!o)return{status:"unavailable",diagnostics:[],reason:"No language server configured for this file"};let u=o.toUri(t),a=i.languageId(t);o.syncDocument(u,n.content,a,!0);let l=o.documentVersion(u),d={active:!0,queued:!1},p=c(()=>!n.signal.aborted&&o.documentVersion(u)===l,"current"),g=c(()=>O(o,u,a,{signal:n.signal,content:n.content}),"request"),h=c(async()=>{if(d.queued=!0,!d.active){d.active=!0;try{for(;d.queued&&p();){d.queued=!1;let f=await g();p()&&n.publish(ct(f,o.commandName))}}catch(f){p()&&n.publish({status:"unavailable",diagnostics:[],reason:f instanceof Error?f.message:String(f),source:o.commandName})}finally{d.active=!1}}},"refresh"),y=i.onPushDiagnostics(f=>{!p()||f.uri!==u||f.serverId!==o.serverId||f.cwd!==s.cwd||f.version!==void 0&&f.version!==l||(o.diagnosticMode==="pull"||B(o)?h():n.publish({status:"snapshot",diagnostics:f.diagnostics,source:o.commandName,reason:dt(f.version===void 0)}))});n.signal.addEventListener("abort",y,{once:!0});try{let f=await g();return l=o.documentVersion(u),ct(f,o.commandName)}catch(f){throw d.queued=!1,y(),n.signal.removeEventListener("abort",y),f}finally{d.active=!1,d.queued&&p()&&queueMicrotask(()=>{h()})}}}}c(lt,"createLspDiagnosticSource");function dt(r){return`Latest push snapshot; completion is unknown${r?"; language server omitted the document version":""}`}c(dt,"snapshotReason");function ct(r,e){return r.complete?{status:"ready",diagnostics:r.diagnostics,source:e}:{status:"snapshot",diagnostics:r.diagnostics,reason:dt(r.unversioned),source:e}}c(ct,"toReport");import{URI as Qt}from"vscode-uri";var ut={protocol:_e,apiVersion:1,id:"lsp",setup(r){for(let e of A)r.addToolRecipe(e);r.addSetupCheck({id:"effective-config",inspect:Zt}),r.addCheck({id:"config",title:"LSP",async run(e){try{let t=await _.fromPackageDir(e.cwd,{environment:e.env}),n=er(t,e.files);return n.length===0?[{status:"skip",message:"No language server matches the inspected project files"}]:await Promise.all(n.map(async s=>{let i=`${s.serverId} [${s.layer}] command ${JSON.stringify(s.config.command)}`,o=new C({serverId:s.serverId,rootUri:Qt.file(e.cwd).toString(),command:s.config.command,env:tr(e.env,s.config.env),...s.config.initializationOptions&&{initOptions:s.config.initializationOptions},...s.config.settings&&{settings:s.config.settings},...s.config.timeoutMs&&{timeoutMs:s.config.timeoutMs}});try{return await o.start(),{status:"pass",message:`${i}: initialized`,detail:s.sourcePath}}catch(u){return{status:"fail",message:`${i}: ${u instanceof Error?u.message:String(u)}`,detail:s.sourcePath}}finally{await o.shutdown().catch(()=>{})}}))}catch(t){return[{status:"fail",message:t instanceof Error?t.message:String(t)}]}}})}};async function Zt(r){try{let e=await _.fromPackageDir(r.cwd,{environment:r.env}),t=[],n=new Map;for(let[s,i]of r.detectedLanguages){let o=i.flatMap(u=>e.resolve(u)).find(u=>u.languageId===s);o!==void 0&&(t.push({kind:"lsp",languageId:s,toolId:o.serverId}),await H(o.config,r.cwd,r.env)||n.set(o.serverId,{id:`lsp-${o.serverId}-unavailable`,message:`Configured language server ${o.serverId} cannot run ${JSON.stringify(o.config.command)}`}))}return{selections:t,actions:[...n.values()]}}catch(e){return{actions:[{id:"lsp-config-invalid",message:`Language server configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}c(Zt,"inspectLspSetup");function er(r,e){let t=new Map;for(let n of e){let s=r.resolve(n)[0];s!==void 0&&!t.has(s.serverId)&&t.set(s.serverId,s)}return[...t.values()]}c(er,"applicableServers");function tr(r,e){return Object.fromEntries(Object.entries({...r,...e}).filter(t=>t[1]!==void 0))}c(tr,"definedEnvironment");function pt(r){return{id:"symbols",async tryResolve(e,t){if(!e.query.startsWith("symbols:"))return{kind:"not-handled"};let n=e.query.slice(8).trim();if(n.length===0)return{kind:"failed",error:new Error("symbols: query must not be empty")};let s=await r(t.cwd),i=await se(n,t.cwd,e.limit??100,t.signal,e,s);return{kind:"resolved",payload:{query:n,hits:i}}},format(e){let{query:t,hits:n}=e;return{content:[{type:"text",text:n.length===0?"No symbols found.":n.map((i,o)=>`${String(o+1)}. ${i.filePath}:${String(i.lineNumber)}:${String(i.column)} ${i.kind} ${i.name}`).join(`
8
+ `)}],details:{query:t,hits:n}}}}}c(pt,"createLspSearchResolver");function gt(r){return{id:"lsp-declaration-target",async tryResolve(e,t){let n=D(e,"symbol");if(n===void 0)return{kind:"not-handled"};if(n.selector===void 0)return{kind:"rejected",rejection:{code:"invalid",reason:"Use symbol:<file>#<selector> to choose one declaration"}};try{let s=await Xe(await r(t.cwd),E(n.path,t.cwd),n.selector,t.cwd,t.signal);return{kind:"resolved",targets:[{source:s.source,expectedContent:s.content,ranges:[{start:{lineNumber:s.range.start.line+1,column:s.range.start.character},end:{lineNumber:s.range.end.line+1,column:s.range.end.character}}]}]}}catch(s){return{kind:"failed",error:new Error(`${s instanceof Error?s.message:String(s)} Read the physical file and use explicit text anchors if declaration resolution is unavailable.`,{cause:s})}}}}}c(gt,"createDeclarationTargets");import{readFile as rr,stat as mt}from"node:fs/promises";import{fileURLToPath as nr}from"node:url";function ft(r,e){let t=r.split(`
9
+ `),n=t[e.line];if(!Number.isInteger(e.line)||e.line<0||n===void 0||!Number.isInteger(e.character)||e.character<0||e.character>n.replace(/\r$/u,"").length)throw new Error("The language server returned an invalid text position.");return t.slice(0,e.line).reduce((s,i)=>s+i.length+1,0)+e.character}c(ft,"offset");async function ht(r,e){let t=r.input;if(typeof t.path!="string"||!t.path.startsWith("symbol:")||!t.path.endsWith("#name"))return;if(typeof t.text!="string"||t.text.trim()===""||t.start!==void 0||t.end!==void 0)throw new Error("Rename needs a symbol #name path and a non-empty new name in text, without start/end.");let n=D(t.path.slice(0,-5),"symbol");if(n?.selector===void 0)throw new Error("Rename needs an exact symbol selector before #name.");let s=E(n.path,r.cwd),i=await Ye(await e(r.cwd),s,n.selector,r.cwd,r.signal);if(i.client.supportsCommand("typescript.tsserverRequest")&&(await i.client.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:s,needFileNameList:!0},{isAsync:!1,expectsResult:!0}]}))?.success!==!0)throw new Error("TypeScript could not load the project for rename. No edits applied.");let o=Date.now(),u=await te(i.client,i.uri,i.position,t.text);if(r.signal?.throwIfAborted(),u===null)throw new Error("The language server did not provide rename edits. No text fallback was applied.");let a=new Map(Object.entries(u.changes??{}));for(let d of u.documentChanges??[]){if(!("textDocument"in d)||!("edits"in d))throw new Error("Rename returned a file operation that is not supported; no edits applied.");if(d.textDocument.version!=null&&d.textDocument.version!==i.client.documentVersion(d.textDocument.uri))throw new Error("Rename refers to an unavailable document revision. Refresh the source before retrying.");if(a.has(d.textDocument.uri))throw new Error("Rename returned duplicate document edits.");a.set(d.textDocument.uri,d.edits)}let l=[];for(let[d,p]of a){let g=nr(d),h=await mt(g),y=await rr(g,"utf8"),f=await mt(g),w=i.client.documentContent(d);if(w!==void 0&&w!==y)throw new Error("The language server has stale text for a rename target. Read that symbol again before retrying.");if(h.mtimeMs>o||h.mtimeMs!==f.mtimeMs||h.size!==f.size||g===s&&y!==i.content)throw new Error("A rename source changed during the language-server request. Retry from a fresh symbol read.");l.push({source:g,expectedContent:y,changes:p.map(R=>({from:ft(y,R.range.start),to:ft(y,R.range.end),insert:R.newText}))})}return{...r,editPlan:{files:l},metadata:{...r.metadata,semanticEdit:{mode:"lsp-rename",server:i.client.serverId,referencesUpdated:!0},diffStatuses:[{text:"Renamed through LSP",tone:"success"}]}}}c(ht,"prepareSymbolRename");var yt=Ie({kind:"code-view",label:"LSP"});async function ir(r){let e=new Map,t=!1,n=c((a,l=!1)=>{if(t)return Promise.reject(new Error("LSP session has ended"));let d=JSON.stringify([a,l]),p=e.get(d);return p||(p=or(a,l).then(g=>{if(t)throw new Error("LSP session has ended");return x.init(g)}),e.set(d,p)),p},"managerFor"),s=c(async(a,l)=>{let d=await Se(l,a,"lsp-servers",A);return d===void 0?void 0:{cwd:d,external:d!==sr.resolve(l)}},"resolveLspProject"),i={kind:"compiler",name:"pi-agent-ide-lsp",priority:200,extensions:["*"],detect:c(async a=>(await n(a.cwd),!0),"detect"),async compile(a,l){let d=await n(l.cwd);return pe(d).compile(a,l)}},o={protocol:ye,apiVersion:4,id:"lsp",setup(a){a.addTool(i),a.addDiagnosticSource(lt(n,s))}};r.on("session_shutdown",async()=>{t=!0,await Promise.allSettled([...e.values()].map(async a=>(await a).shutdownAll())),e.clear()});let u={protocol:xe,apiVersion:De,id:"lsp",setup(a){a.addResolver({resolver:it(n),renderResult:yt}),a.addResolver({resolver:ot(n),renderResult:yt}),a.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler:he()}),a.describe("symbol:<file>#<selector> \u2014 declaration source, e.g. symbol:src/catalog.ts#Catalog/find. graph:<file> \u2014 top-level declarations, references and calls; members include selectors. graph:<file>#<selector> \u2014 references and incoming/outgoing calls for that declaration or member.")}};await Promise.all([be(r,o),qe(r,{protocol:Ae,apiVersion:Te,id:"lsp-declarations",setup(a){a.addAnchorResolver({kind:Oe,type:"auxiliary",resolver:{id:"lsp-declaration",description:"symbol:<file>#<selector> selects an exact declaration for text fallback editing; imports and references are not rewritten.",renderFull:c(l=>l,"renderFull"),renderCompact:c(l=>l,"renderCompact"),tryResolve:c(()=>Promise.resolve({kind:"not-handled"}),"tryResolve")},resources:gt(n),describeInPrompt:!1});for(let l of["copy","move","delete","replace"])a.tool(l).describe("Use symbol:<file>#<selector> as path to select one exact declaration without start/end. Use parent/child for ambiguous names. Copy/move require an explicit target and destination anchor. This text fallback leaves imports and references unchanged; it is not semantic rename."+(l==="replace"?" Use symbol:<file>#<selector>#name with text containing the new name for native LSP rename across references. Omit start/end. A failed server rename never falls back to identifier text replacement.":"")),a.tool(l).addHandler({stage:"text-pre-edit",async handler(d){if(l==="replace"){let h=await ht(d,n);if(h!==void 0)return h}let p=d.input;if(![p.path,p.start,p.end,p.target,p.targetStart,p.targetEnd].some(h=>typeof h=="string"&&h.startsWith("symbol:")))return d;if((l==="copy"||l==="move")&&typeof p.target!="string")throw new Error("Copying or moving a symbol requires an explicit target file and destination anchor.");return{...d,metadata:{...d.metadata,semanticEdit:{mode:"declaration-text",referencesUpdated:!1,importsUpdated:!1},diffStatuses:[{text:"Text fallback: imports and references unchanged",tone:"warning"}]}}}});a.tool("insert").describe("Symbol targets are unsupported for insert. Read the declaration and select an ordinary text line anchor instead."),a.tool("insert").addHandler({stage:"text-pre-edit",handler(l){let d=l.input;if([d.path,d.anchor].some(p=>typeof p=="string"&&p.startsWith("symbol:")))throw new Error("Semantic insert is not supported. Read the declaration and use an explicit text line anchor instead.");return l}})}}),Ee(r,u),Ce(r,ut),$e(r,{protocol:je,apiVersion:Me,id:"symbols",setup(a){a.addResolver({resolver:pt(n)}),a.describe("Use `symbols:<query>` to search workspace symbols and their references through configured language servers.")}})])}c(ir,"registerLsp");async function or(r,e){let t=e?r:process.env.PI_AGENT_IDE_CONFIG_DIR??r;return _.fromPackageDir(t,{includeGlobal:!e,requireBuiltInEvidence:e,recipes:A})}c(or,"loadRegistry");export{ir as default};
package/dist/entry-36.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-ORAPGW7W.js";import"./chunk-JASLOB2X.js";import"./chunk-EI7MMDWY.js";export{a as connectReadPlugin};
1
+ import{a}from"./chunk-72EEL2DW.js";import"./chunk-KAB3AYA2.js";import"./chunk-EI7MMDWY.js";export{a as connectReadPlugin};
package/dist/entry-37.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-NNCZYO4Q.js";import{c as a}from"./chunk-KCEOTU5Z.js";import"./chunk-YHUTTZC6.js";import"./chunk-RAZOACDD.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as createReadResultRenderer};
1
+ import"./chunk-NNCZYO4Q.js";import{d as a}from"./chunk-3SE372WC.js";import"./chunk-YHUTTZC6.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as createReadResultRenderer};
package/dist/entry-38.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g}from"./chunk-JASLOB2X.js";import"./chunk-EI7MMDWY.js";export{b as READ_API_VERSION,c as READ_CORE_READY_EVENT,d as READ_PLUGIN_REGISTER_EVENT,a as READ_PROTOCOL,e as isReadCoreReady,f as isReadPlugin,g as isReadPluginRegistrationRequest};
1
+ import{a,b,c,d,e,f,g}from"./chunk-KAB3AYA2.js";import"./chunk-EI7MMDWY.js";export{b as READ_API_VERSION,c as READ_CORE_READY_EVENT,d as READ_PLUGIN_REGISTER_EVENT,a as READ_PROTOCOL,e as isReadCoreReady,f as isReadPlugin,g as isReadPluginRegistrationRequest};
package/dist/entry-39.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e,f}from"./chunk-4U6KGABH.js";import"./chunk-S3ZPXWX7.js";import"./chunk-EI7MMDWY.js";export{e as isFragmentResolverRegistration,f as isReadFragmentResolution,c as isReadHandlerRegistration,d as isReadViewRegistration,b as isResourceResolverRegistration,a as isTextTargetResolverRegistration};
1
+ import{a,b,c,d,e,f,g}from"./chunk-5MSNYFDE.js";import"./chunk-S3ZPXWX7.js";import"./chunk-EI7MMDWY.js";export{f as isFragmentResolverRegistration,g as isReadFragmentResolution,d as isReadHandlerRegistration,e as isReadViewRegistration,c as isResourceResolverRegistration,b as isTextTargetResolverRegistration,a as readParameters};
package/dist/entry-4.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n}from"./chunk-KVGQG43U.js";import"./chunk-N34ATN52.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as TOOL_CONFIG_VERSION,b as configuredExecutableName,n as createConfiguredProcessEnvironment,i as hasConfiguredExecutable,f as loadLayeredToolConfig,g as matchesConfiguredFile,l as parseFormattersConfig,m as parseLintersConfig,c as projectIdeConfigDirectory,d as projectIdeConfigPath,e as resolveToolConfigPaths,k as runConfiguredFormatter,j as runConfiguredProcess,h as selectConfiguredEntry};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-M5MJP7Z2.js";import"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as TOOL_CONFIG_VERSION,b as configuredExecutableName,o as createConfiguredProcessEnvironment,j as hasConfiguredExecutable,g as loadLayeredToolConfig,h as matchesConfiguredFile,m as parseFormattersConfig,n as parseLintersConfig,d as projectIdeConfigDirectory,e as projectIdeConfigPath,c as resolveExternalToolProjectRoot,f as resolveToolConfigPaths,l as runConfiguredFormatter,k as runConfiguredProcess,i as selectConfiguredEntry};