pi-agent-ide 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/chunk-2XYXV5HS.js +4 -0
  3. package/dist/{chunk-YQTLJ5ZV.js → chunk-6XQQBKPE.js} +1 -1
  4. package/dist/{chunk-VUNCBASK.js → chunk-KH5KPBCR.js} +3 -3
  5. package/dist/chunk-L4FA6OD4.js +1 -0
  6. package/dist/chunk-LGN7EJYR.js +13 -0
  7. package/dist/chunk-MTQSGWZJ.js +1 -0
  8. package/dist/chunk-N34ATN52.js +1 -0
  9. package/dist/{chunk-52BM6J6I.js → chunk-NXHPO7ER.js} +3 -3
  10. package/dist/{chunk-QW5O42QJ.js → chunk-OFHVDY4Q.js} +1 -1
  11. package/dist/{chunk-E4SECPF4.js → chunk-ONWUJXUR.js} +1 -1
  12. package/dist/chunk-QZANC2IG.js +1 -0
  13. package/dist/{chunk-QNZVPFSP.js → chunk-SMSIT3CE.js} +1 -1
  14. package/dist/{chunk-KP37XTDI.js → chunk-UTTW55S2.js} +1 -1
  15. package/dist/chunk-VEJGSURY.js +8 -0
  16. package/dist/chunk-WZI4YC2O.js +1 -0
  17. package/dist/{chunk-5A25RATC.js → chunk-ZIHEF6K3.js} +3 -3
  18. package/dist/entry-0.js +1 -1
  19. package/dist/entry-18.js +1 -1
  20. package/dist/entry-19.js +1 -1
  21. package/dist/entry-20.js +1 -1
  22. package/dist/entry-21.js +1 -1
  23. package/dist/entry-22.js +1 -1
  24. package/dist/entry-23.js +1 -1
  25. package/dist/entry-24.js +1 -1
  26. package/dist/entry-25.js +1 -1
  27. package/dist/entry-26.js +1 -1
  28. package/dist/entry-27.js +1 -1
  29. package/dist/entry-28.js +1 -1
  30. package/dist/entry-29.js +1 -1
  31. package/dist/entry-30.js +1 -1
  32. package/dist/entry-31.js +1 -1
  33. package/dist/entry-32.js +1 -1
  34. package/dist/entry-33.js +1 -1
  35. package/dist/entry-34.js +1 -1
  36. package/dist/entry-35.js +1 -1
  37. package/dist/entry-36.js +1 -1
  38. package/dist/entry-37.js +1 -1
  39. package/dist/entry-38.js +1 -1
  40. package/dist/entry-39.js +1 -1
  41. package/dist/entry-4.js +1 -1
  42. package/dist/entry-40.js +1 -1
  43. package/dist/entry-41.js +1 -1
  44. package/dist/entry-42.js +1 -1
  45. package/dist/entry-43.js +1 -1
  46. package/dist/entry-44.js +1 -1
  47. package/dist/entry-45.js +1 -1
  48. package/dist/entry-46.js +1 -1
  49. package/dist/entry-47.js +1 -1
  50. package/dist/entry-48.js +1 -1
  51. package/dist/entry-49.js +1 -1
  52. package/dist/entry-50.js +1 -1
  53. package/dist/entry-51.js +1 -1
  54. package/dist/entry-52.js +1 -1
  55. package/dist/entry-53.js +1 -0
  56. package/dist/entry-54.js +0 -1
  57. package/dist/entry-55.js +1 -0
  58. package/dist/entry-56.js +0 -1
  59. package/dist/entry-57.js +1 -1
  60. package/dist/entry-58.js +1 -1
  61. package/dist/entry-59.js +1 -1
  62. package/dist/entry-60.js +1 -1
  63. package/dist/entry-61.js +1 -1
  64. package/dist/entry-62.js +1 -0
  65. package/dist/entry-63.js +0 -1
  66. package/dist/entry-64.js +1 -0
  67. package/dist/entry-65.js +0 -1
  68. package/dist/entry-66.js +1 -1
  69. package/dist/entry-67.js +1 -1
  70. package/dist/entry-68.js +1 -1
  71. package/dist/entry-69.js +1 -1
  72. package/dist/entry-70.js +1 -1
  73. package/dist/entry-71.js +1 -1
  74. package/dist/entry-72.js +1 -1
  75. package/dist/entry-73.js +1 -1
  76. package/dist/entry-74.js +1 -1
  77. package/dist/entry-75.js +1 -1
  78. package/dist/entry-76.js +1 -1
  79. package/dist/entry-77.js +1 -1
  80. package/dist/entry-78.js +1 -1
  81. package/dist/entry-79.js +1 -1
  82. package/dist/entry-80.js +1 -0
  83. package/dist/pi-agent-ide.js +12 -12
  84. package/docs/configuration.md +32 -1
  85. package/docs/generated/tool-catalog/cmake.md +5 -5
  86. package/docs/generated/tool-catalog/csharp.md +5 -5
  87. package/docs/generated/tool-catalog/css.md +7 -7
  88. package/docs/generated/tool-catalog/dart.md +9 -0
  89. package/docs/generated/tool-catalog/dockerfile.md +5 -5
  90. package/docs/generated/tool-catalog/elixir.md +9 -0
  91. package/docs/generated/tool-catalog/html.md +7 -6
  92. package/docs/generated/tool-catalog/index.md +9 -0
  93. package/docs/generated/tool-catalog/javascript.md +8 -8
  94. package/docs/generated/tool-catalog/json.md +7 -7
  95. package/docs/generated/tool-catalog/julia.md +8 -0
  96. package/docs/generated/tool-catalog/kotlin.md +6 -5
  97. package/docs/generated/tool-catalog/markdown.md +6 -6
  98. package/docs/generated/tool-catalog/powershell.md +9 -0
  99. package/docs/generated/tool-catalog/python.md +6 -6
  100. package/docs/generated/tool-catalog/r.md +9 -0
  101. package/docs/generated/tool-catalog/scala.md +9 -0
  102. package/docs/generated/tool-catalog/svelte.md +9 -0
  103. package/docs/generated/tool-catalog/typescript.md +9 -8
  104. package/docs/generated/tool-catalog/vue.md +9 -0
  105. package/docs/generated/tool-catalog/yaml.md +6 -6
  106. package/docs/generated/tool-catalog/zig.md +9 -0
  107. package/node_modules/pi-agent-doctor/package.json +10 -3
  108. package/node_modules/pi-agent-doctor/runtime/entry-20.js +1 -0
  109. package/node_modules/pi-agent-doctor/src/catalog.ts +27 -1
  110. package/node_modules/pi-agent-doctor/src/evidence.ts +118 -0
  111. package/node_modules/pi-agent-doctor/src/executable.ts +63 -17
  112. package/node_modules/pi-agent-filesystem/package.json +7 -7
  113. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  114. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  115. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  116. package/node_modules/pi-agent-filesystem-text/runtime/entry-24.js +2 -0
  117. package/node_modules/pi-agent-ide-ast/package.json +11 -11
  118. package/node_modules/pi-agent-ide-ast/runtime/entry-25.js +0 -1
  119. package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +2 -0
  120. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +3 -0
  121. package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +3 -0
  122. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  123. package/node_modules/pi-agent-ide-changes/runtime/entry-27.js +0 -1
  124. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  125. package/node_modules/pi-agent-ide-formatter/src/catalog.ts +131 -13
  126. package/node_modules/pi-agent-ide-formatter/src/registry.ts +20 -8
  127. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  128. package/node_modules/pi-agent-ide-languages/src/languages.ts +15 -0
  129. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  130. package/node_modules/pi-agent-ide-lint/src/catalog.ts +196 -39
  131. package/node_modules/pi-agent-ide-lint/src/command-linter.ts +23 -3
  132. package/node_modules/pi-agent-ide-lint/src/diagnostics.ts +73 -33
  133. package/node_modules/pi-agent-ide-lint/src/registry.ts +20 -8
  134. package/node_modules/pi-agent-ide-lsp/package.json +9 -9
  135. package/node_modules/pi-agent-ide-lsp/runtime/entry-32.js +2 -0
  136. package/node_modules/pi-agent-ide-lsp/src/catalog.ts +161 -7
  137. package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +3 -6
  138. package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +2 -4
  139. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +154 -11
  140. package/node_modules/pi-agent-ide-lsp/src/lsp/file-watchers.ts +88 -0
  141. package/node_modules/pi-agent-ide-lsp/src/lsp/initialization-options.ts +14 -0
  142. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -4
  143. package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +69 -34
  144. package/node_modules/pi-agent-ide-lsp/src/lsp/transport-writer.ts +24 -0
  145. package/node_modules/pi-agent-ide-lsp/src/lsp/types.ts +5 -0
  146. package/node_modules/pi-agent-image/package.json +3 -3
  147. package/node_modules/pi-agent-invariant/package.json +2 -2
  148. package/node_modules/pi-agent-pdf/package.json +3 -3
  149. package/node_modules/pi-agent-read/package.json +11 -11
  150. package/node_modules/pi-agent-read/runtime/entry-39.js +0 -1
  151. package/node_modules/pi-agent-read/runtime/entry-40.js +2 -0
  152. package/node_modules/pi-agent-resource/package.json +2 -2
  153. package/node_modules/pi-agent-search/package.json +7 -7
  154. package/node_modules/pi-agent-search/runtime/entry-44.js +0 -1
  155. package/node_modules/pi-agent-search-text/package.json +9 -9
  156. package/node_modules/pi-agent-search-text/runtime/entry-46.js +1 -0
  157. package/node_modules/pi-agent-text/package.json +3 -3
  158. package/node_modules/pi-agent-text/runtime/entry-48.js +1 -0
  159. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  160. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-49.js +2 -0
  161. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  162. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
  163. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-51.js +2 -0
  164. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  165. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
  166. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-53.js +2 -0
  167. package/node_modules/pi-agent-text-editor/package.json +22 -22
  168. package/node_modules/pi-agent-text-editor/runtime/entry-68.js +0 -1
  169. package/node_modules/pi-agent-text-editor-argument-order/package.json +3 -3
  170. package/node_modules/pi-agent-text-editor-overwrite/package.json +4 -4
  171. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  172. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  173. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
  174. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  175. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  176. package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +1 -0
  177. package/node_modules/pi-agent-web/package.json +7 -7
  178. package/node_modules/pi-agent-web-html/package.json +3 -3
  179. package/node_modules/pi-agent-web-image/package.json +4 -4
  180. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  181. package/node_modules/pi-agent-web-text/package.json +4 -4
  182. package/node_modules/pi-agent-web-text/runtime/entry-80.js +2 -0
  183. package/package.json +35 -35
  184. package/src/api/tool-config/formatters.json +70 -12
  185. package/src/api/tool-config/linters.json +148 -66
  186. package/src/api/tool-config/lsp-servers.json +142 -7
  187. package/src/api/tool-config.ts +56 -24
  188. package/src/code-view/diagnostic-view.ts +14 -10
  189. package/src/doctor/config-writer.ts +14 -1
  190. package/src/doctor/discovery.ts +13 -68
  191. package/src/doctor/run.ts +33 -1
  192. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  193. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  194. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  195. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  196. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-24.js +2 -0
  197. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-21.js +2 -0
  198. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  199. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  200. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  201. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  202. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  203. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +2 -0
  204. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +2 -0
  205. package/src/extensions/pi-agent-read/package.json +11 -11
  206. package/src/extensions/pi-agent-read/runtime/entry-39.js +0 -1
  207. package/src/extensions/pi-agent-read/runtime/entry-40.js +2 -0
  208. package/src/extensions/pi-agent-search/package.json +7 -7
  209. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
  210. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-46.js +1 -0
  211. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-47.js +1 -0
  212. package/src/extensions/pi-agent-search/runtime/entry-44.js +0 -1
  213. package/src/extensions/pi-agent-search/runtime/entry-45.js +2 -0
  214. package/src/extensions/pi-agent-text-editor/package.json +22 -22
  215. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  216. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-49.js +2 -0
  217. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  218. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
  219. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-51.js +2 -0
  220. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  221. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
  222. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-53.js +2 -0
  223. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +3 -3
  224. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +4 -4
  225. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  226. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  227. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
  228. package/src/extensions/pi-agent-text-editor/runtime/entry-68.js +0 -1
  229. package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +2 -0
  230. package/src/plugins/pi-agent-ide-ast/package.json +11 -11
  231. package/src/plugins/pi-agent-ide-ast/runtime/entry-25.js +0 -1
  232. package/src/plugins/pi-agent-ide-ast/runtime/entry-26.js +2 -0
  233. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +3 -0
  234. package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +3 -0
  235. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  236. package/src/plugins/pi-agent-ide-changes/runtime/entry-27.js +0 -1
  237. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +8 -0
  238. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  239. package/src/plugins/pi-agent-ide-formatter/src/catalog.ts +131 -13
  240. package/src/plugins/pi-agent-ide-formatter/src/registry.ts +20 -8
  241. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  242. package/src/plugins/pi-agent-ide-languages/src/languages.ts +15 -0
  243. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  244. package/src/plugins/pi-agent-ide-lint/src/catalog.ts +196 -39
  245. package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +23 -3
  246. package/src/plugins/pi-agent-ide-lint/src/diagnostics.ts +73 -33
  247. package/src/plugins/pi-agent-ide-lint/src/registry.ts +20 -8
  248. package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
  249. package/src/plugins/pi-agent-ide-lsp/runtime/entry-32.js +2 -0
  250. package/src/plugins/pi-agent-ide-lsp/src/catalog.ts +161 -7
  251. package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +3 -6
  252. package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +2 -4
  253. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +154 -11
  254. package/src/plugins/pi-agent-ide-lsp/src/lsp/file-watchers.ts +88 -0
  255. package/src/plugins/pi-agent-ide-lsp/src/lsp/initialization-options.ts +14 -0
  256. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -4
  257. package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +69 -34
  258. package/src/plugins/pi-agent-ide-lsp/src/lsp/transport-writer.ts +24 -0
  259. package/src/plugins/pi-agent-ide-lsp/src/lsp/types.ts +5 -0
  260. package/src/toolchain/types.ts +2 -0
  261. package/dist/chunk-476MR2QB.js +0 -1
  262. package/dist/chunk-4KQOODGE.js +0 -13
  263. package/dist/chunk-7NDBZ4WX.js +0 -1
  264. package/dist/chunk-AP7Z3VWC.js +0 -1
  265. package/dist/chunk-TNWYEXFG.js +0 -1
  266. package/dist/chunk-U4D6FT66.js +0 -1
  267. package/dist/chunk-VWVLBOMU.js +0 -8
  268. package/node_modules/pi-agent-filesystem/runtime/entry-20.js +0 -2
  269. package/node_modules/pi-agent-ide-ast/runtime/entry-24.js +0 -1
  270. package/node_modules/pi-agent-ide-changes/runtime/entry-26.js +0 -1
  271. package/node_modules/pi-agent-image/runtime/entry-32.js +0 -1
  272. package/node_modules/pi-agent-resource/runtime/entry-40.js +0 -1
  273. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-48.js +0 -2
  274. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-49.js +0 -1
  275. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-51.js +0 -1
  276. package/node_modules/pi-agent-text-editor/runtime/entry-53.js +0 -1
  277. package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +0 -1
  278. package/node_modules/pi-agent-web/runtime/entry-75.js +0 -2
  279. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-21.js +0 -2
  280. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-20.js +0 -2
  281. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +0 -2
  282. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +0 -2
  283. package/src/extensions/pi-agent-read/runtime/entry-35.js +0 -1
  284. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-45.js +0 -2
  285. package/src/extensions/pi-agent-search/runtime/entry-41.js +0 -1
  286. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-48.js +0 -2
  287. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-49.js +0 -1
  288. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-51.js +0 -1
  289. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-69.js +0 -2
  290. package/src/extensions/pi-agent-text-editor/runtime/entry-53.js +0 -1
  291. package/src/plugins/pi-agent-ide-ast/runtime/entry-24.js +0 -1
  292. package/src/plugins/pi-agent-ide-changes/runtime/entry-26.js +0 -1
  293. /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-21.js +0 -0
  294. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-22.js +0 -0
  295. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-23.js +0 -0
  296. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-28.js +0 -0
  297. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-29.js +0 -0
  298. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-30.js +0 -0
  299. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-31.js +0 -0
  300. /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-33.js +0 -0
  301. /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-34.js +0 -0
  302. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-35.js +0 -0
  303. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-41.js +0 -0
  304. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-45.js +0 -0
  305. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-47.js +0 -0
  306. /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-69.js +0 -0
  307. /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-argument-order}/runtime/entry-70.js +0 -0
  308. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-overwrite}/runtime/entry-71.js +0 -0
  309. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
  310. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-74.js +0 -0
  311. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-76.js +0 -0
  312. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
  313. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
  314. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
  315. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-22.js +0 -0
  316. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-23.js +0 -0
  317. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
  318. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
  319. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
  320. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-argument-order}/runtime/entry-70.js +0 -0
  321. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-overwrite}/runtime/entry-71.js +0 -0
  322. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
  323. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-28.js +0 -0
  324. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-29.js +0 -0
  325. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-30.js +0 -0
  326. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-31.js +0 -0
@@ -0,0 +1,88 @@
1
+ import { watch, type FSWatcher } from "node:fs";
2
+ import { readdir, stat } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { URI } from "vscode-uri";
5
+
6
+ interface WatchPattern {
7
+ globPattern: string | { baseUri: string | { uri: string }; pattern: string };
8
+ kind?: number;
9
+ }
10
+
11
+ /** A native filesystem event translated to the LSP file change types. */
12
+ export interface WatchedFileChange {
13
+ uri: string;
14
+ type: 1 | 2 | 3;
15
+ }
16
+
17
+ /** Own the filesystem subscriptions requested by one language server. */
18
+ export class LspFileWatchers {
19
+ private readonly registrations = new Map<string, FSWatcher[]>();
20
+
21
+ private disposed = false;
22
+
23
+ constructor(
24
+ private readonly root: string,
25
+ private readonly changed: (change: WatchedFileChange) => void,
26
+ private readonly failed: (error: Error) => void,
27
+ ) {}
28
+
29
+ /** Install all patterns for one workspace/didChangeWatchedFiles registration. */
30
+ async register(id: string, patterns: readonly WatchPattern[]): Promise<void> {
31
+ const watchers: FSWatcher[] = [];
32
+ try {
33
+ for (const pattern of patterns) {
34
+ const glob = pattern.globPattern;
35
+ const root =
36
+ typeof glob === "string"
37
+ ? this.root
38
+ : URI.parse(typeof glob.baseUri === "string" ? glob.baseUri : glob.baseUri.uri).fsPath;
39
+ const expression = typeof glob === "string" ? glob : glob.pattern;
40
+ const matches = (file: string) =>
41
+ path.matchesGlob(path.isAbsolute(expression) ? path.join(root, file) : file, expression);
42
+ const existing = new Set((await readdir(root, { recursive: true })).filter(matches));
43
+
44
+ if (this.disposed) throw new Error("Language server file watchers are disposed");
45
+ const watcher = watch(root, { recursive: true }, (_event, name) => {
46
+ if (!name || !matches(name)) return;
47
+ void stat(path.join(root, name)).then(
48
+ () => {
49
+ if (!this.registrations.get(id)?.includes(watcher)) return;
50
+ const type = existing.has(name) ? 2 : 1;
51
+ existing.add(name);
52
+ if ((pattern.kind ?? 7) & (type === 1 ? 1 : 2))
53
+ this.changed({ uri: URI.file(path.join(root, name)).toString(), type });
54
+ },
55
+ (error: NodeJS.ErrnoException) => {
56
+ if (!this.registrations.get(id)?.includes(watcher)) return;
57
+ if (error.code !== "ENOENT") {
58
+ this.failed(error);
59
+ return;
60
+ }
61
+ if (existing.delete(name) && (pattern.kind ?? 7) & 4)
62
+ this.changed({ uri: URI.file(path.join(root, name)).toString(), type: 3 });
63
+ },
64
+ );
65
+ });
66
+ watcher.on("error", this.failed);
67
+ watchers.push(watcher);
68
+ }
69
+ } catch (error) {
70
+ for (const watcher of watchers) watcher.close();
71
+ throw error;
72
+ }
73
+ this.unregister(id);
74
+ this.registrations.set(id, watchers);
75
+ }
76
+
77
+ /** Stop a server registration without affecting its other subscriptions. */
78
+ unregister(id: string): void {
79
+ for (const watcher of this.registrations.get(id) ?? []) watcher.close();
80
+ this.registrations.delete(id);
81
+ }
82
+
83
+ /** Close all subscriptions when the server exits or the session ends. */
84
+ dispose(): void {
85
+ this.disposed = true;
86
+ for (const id of this.registrations.keys()) this.unregister(id);
87
+ }
88
+ }
@@ -0,0 +1,14 @@
1
+ /** Expand the project path in JSON initialization options, including plugin locations. */
2
+ export function resolveInitializationOptions(
3
+ value: Record<string, unknown>,
4
+ projectRoot: string,
5
+ ): Record<string, unknown> {
6
+ const expand = (item: unknown): unknown => {
7
+ if (typeof item === "string") return item.replaceAll("{project}", () => projectRoot);
8
+ if (Array.isArray(item)) return item.map(expand);
9
+ if (item !== null && typeof item === "object")
10
+ return Object.fromEntries(Object.entries(item).map(([key, child]) => [key, expand(child)]));
11
+ return item;
12
+ };
13
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, expand(item)]));
14
+ }
@@ -4,6 +4,8 @@ import path from "node:path";
4
4
  import { URI } from "vscode-uri";
5
5
 
6
6
  import { LspClient } from "./client.js";
7
+
8
+ import { resolveInitializationOptions } from "./initialization-options.js";
7
9
  import { toDiagnostic } from "./diagnostics.js";
8
10
  import { type LspDiagnostic, type ResolvedServer } from "./types.js";
9
11
 
@@ -159,7 +161,10 @@ export class LspManager {
159
161
  command: match.config.command,
160
162
  ...(match.config.env && { env: match.config.env }),
161
163
  ...(match.config.initializationOptions && {
162
- initOptions: match.config.initializationOptions,
164
+ initOptions: resolveInitializationOptions(
165
+ match.config.initializationOptions,
166
+ URI.parse(rootUri).fsPath,
167
+ ),
163
168
  }),
164
169
  ...(match.config.settings && { settings: match.config.settings }),
165
170
  ...(match.config.timeoutMs && { timeoutMs: match.config.timeoutMs }),
@@ -299,16 +304,15 @@ export class LspManager {
299
304
  cwd: string,
300
305
  capability: "diagnostics" | "symbols" = "diagnostics",
301
306
  ): Promise<{ client: LspClient; uri: string; languageId: string } | null> {
302
- const extension = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
303
307
  const absolutePath = path.resolve(cwd, filePath);
304
- const client = await this.getOrStart(extension, cwd, capability);
308
+ const client = await this.getOrStart(absolutePath, cwd, capability);
305
309
 
306
310
  if (!client) {
307
311
  return null;
308
312
  }
309
313
 
310
314
  const uri = client.toUri(absolutePath);
311
- const resolved = this._registry.resolve(extension);
315
+ const resolved = this._registry.resolve(absolutePath);
312
316
  const languageId = resolved[0]?.languageId ?? "plaintext";
313
317
 
314
318
  // Read file content for didOpen
@@ -1,4 +1,6 @@
1
- import { requiredValue } from "pi-agent-invariant";
1
+ import path from "node:path";
2
+
3
+ import { existsSync } from "node:fs";
2
4
 
3
5
  import { hasConfiguredExecutable, loadLayeredToolConfig } from "pi-agent-ide/api/tool-config";
4
6
 
@@ -16,15 +18,14 @@ LSP server configuration in project, global, and built-in priority order.
16
18
  export class LspServerRegistry {
17
19
  private readonly _servers: Record<string, ServerConfig>;
18
20
  private readonly _entries: readonly EffectiveToolConfigEntry<ServerConfig>[];
19
- private readonly _entriesById: ReadonlyMap<string, EffectiveToolConfigEntry<ServerConfig>>;
20
21
  private readonly _lookup: LanguageLookup;
21
22
 
22
23
  private constructor(
23
24
  entries: readonly EffectiveToolConfigEntry<ServerConfig>[],
24
25
  availableBuiltIns: ReadonlySet<string>,
26
+ private readonly _projectRoot: string,
25
27
  ) {
26
28
  this._entries = entries;
27
- this._entriesById = new Map(entries.map((entry) => [entry.id, entry]));
28
29
  const activeEntries = entries.filter(
29
30
  (entry) => entry.layer !== "built-in" || availableBuiltIns.has(entry.id),
30
31
  );
@@ -57,13 +58,14 @@ export class LspServerRegistry {
57
58
  return new LspServerRegistry(
58
59
  effective.entries,
59
60
  new Set(available.filter((entry) => entry.available).map((entry) => entry.id)),
61
+ path.resolve(packageDir),
60
62
  );
61
63
  }
62
64
 
63
65
  /**
64
66
  Creates a project-layer registry from an already-parsed config.
65
67
  */
66
- static fromConfig(config: LspServersConfig): LspServerRegistry {
68
+ static fromConfig(config: LspServersConfig, projectRoot = process.cwd()): LspServerRegistry {
67
69
  return new LspServerRegistry(
68
70
  Object.entries(config.servers).map(([id, server]) => ({
69
71
  id,
@@ -72,38 +74,56 @@ export class LspServerRegistry {
72
74
  sourcePath: "<memory>",
73
75
  })),
74
76
  new Set(),
77
+ path.resolve(projectRoot),
75
78
  );
76
79
  }
77
80
 
78
- /**
79
- Resolves a file extension to matching LSP servers in layer priority order.
80
- */
81
- resolve(extension: string): ResolvedServer[] {
82
- const normalized = extension.startsWith(".")
83
- ? extension.toLowerCase()
84
- : `.${extension.toLowerCase()}`;
85
- const serverIds = this._lookup.extToServerIds.get(normalized);
86
-
87
- if (!serverIds || serverIds.length === 0) {
88
- return [];
81
+ /** Resolve a file path or extension to servers in layer priority order. */
82
+ resolve(file: string): ResolvedServer[] {
83
+ const basename = path.basename(file);
84
+ const extension = path.extname(file) || (file.startsWith(".") ? file : `.${file}`);
85
+ const normalizeName = (name: string) =>
86
+ process.platform === "win32" ? name.toLowerCase() : name;
87
+ const matches: ResolvedServer[] = [];
88
+ for (const entry of this._entries) {
89
+ if (!this._servers[entry.id]) continue;
90
+
91
+ if (entry.config.requireRootMarker && !this.hasRootMarker(file, entry.config.rootMarkers))
92
+ continue;
93
+ for (const [languageId, language] of Object.entries(entry.config.languages)) {
94
+ if (
95
+ language.extensions.some(
96
+ (candidate) => candidate.toLowerCase() === extension.toLowerCase(),
97
+ ) ||
98
+ language.fileNames?.some((name) => normalizeName(name) === normalizeName(basename))
99
+ ) {
100
+ matches.push({
101
+ serverId: entry.id,
102
+ config: entry.config,
103
+ languageId,
104
+ layer: entry.layer,
105
+ sourcePath: entry.sourcePath,
106
+ });
107
+ break;
108
+ }
109
+ }
89
110
  }
111
+ return matches;
112
+ }
90
113
 
91
- const languageId = this._lookup.extToLanguageId.get(normalized);
92
-
93
- if (!languageId) {
94
- return [];
114
+ private hasRootMarker(file: string, markers: readonly string[]): boolean {
115
+ let directory = path.dirname(path.resolve(this._projectRoot, file));
116
+ if (file.startsWith(".") && !file.includes(path.sep)) directory = this._projectRoot;
117
+ for (;;) {
118
+ const relative = path.relative(this._projectRoot, directory);
119
+ // This checks containment; it does not construct a parent-relative path.
120
+ // eslint-disable-next-line repo/no-parent-paths
121
+ if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative))
122
+ return false;
123
+ if (markers.some((marker) => existsSync(path.join(directory, marker)))) return true;
124
+ if (directory === this._projectRoot) return false;
125
+ directory = path.dirname(directory);
95
126
  }
96
-
97
- return serverIds.map((serverId) => {
98
- const entry = requiredValue(this._entriesById.get(serverId));
99
- return {
100
- serverId,
101
- config: entry.config,
102
- languageId,
103
- layer: entry.layer,
104
- sourcePath: entry.sourcePath,
105
- };
106
- });
107
127
  }
108
128
 
109
129
  /**
@@ -131,10 +151,7 @@ export class LspServerRegistry {
131
151
  Resolves a file extension to the canonical LSP languageId.
132
152
  */
133
153
  languageId(extension: string): string {
134
- const normalized = extension.startsWith(".")
135
- ? extension.toLowerCase()
136
- : `.${extension.toLowerCase()}`;
137
- return this._lookup.extToLanguageId.get(normalized) ?? extension.slice(1);
154
+ return this.resolve(extension)[0]?.languageId ?? extension.slice(1);
138
155
  }
139
156
  }
140
157
 
@@ -182,6 +199,13 @@ export function parseLspConfig(value: unknown): LspServersConfig {
182
199
  throw new Error(`LSP server ${id}.rootMarkers must be a string array`);
183
200
  }
184
201
 
202
+ if (server.requireRootMarker !== undefined && typeof server.requireRootMarker !== "boolean") {
203
+ throw new TypeError(`LSP server ${id}.requireRootMarker must be a boolean`);
204
+ }
205
+ if (server.requireRootMarker && (server.rootMarkers as string[]).length === 0) {
206
+ throw new Error(`LSP server ${id}.requireRootMarker requires rootMarkers`);
207
+ }
208
+
185
209
  if (
186
210
  typeof server.languages !== "object" ||
187
211
  server.languages === null ||
@@ -205,6 +229,17 @@ export function parseLspConfig(value: unknown): LspServersConfig {
205
229
  ) {
206
230
  throw new Error(`LSP server ${id} language ${language} requires extensions`);
207
231
  }
232
+
233
+ const fileNames = (languageValue as Record<string, unknown>).fileNames;
234
+ if (
235
+ fileNames !== undefined &&
236
+ (!Array.isArray(fileNames) ||
237
+ fileNames.some(
238
+ (name) => typeof name !== "string" || name.length === 0 || /[/\\]/u.test(name),
239
+ ))
240
+ ) {
241
+ throw new Error(`LSP server ${id} language ${language}.fileNames must contain basenames`);
242
+ }
208
243
  }
209
244
 
210
245
  if (!Array.isArray(server.capabilities)) {
@@ -0,0 +1,24 @@
1
+ import type { Writable } from "node:stream";
2
+ import { StreamMessageWriter, type Message } from "vscode-jsonrpc/node";
3
+
4
+ /**
5
+ * Ends the connection on write failure instead of rejecting into JSON-RPC 9's
6
+ * async Promise executor. The owner must dispose the connection so pending
7
+ * requests reject; a failed transport must never look like a successful request.
8
+ */
9
+ export class TransportWriter extends StreamMessageWriter {
10
+ constructor(
11
+ stream: Writable,
12
+ private readonly fail: (error: unknown) => void,
13
+ ) {
14
+ super(stream);
15
+ }
16
+
17
+ override async write(message: Message): Promise<void> {
18
+ try {
19
+ await super.write(message);
20
+ } catch (error) {
21
+ this.fail(error);
22
+ }
23
+ }
24
+ }
@@ -53,6 +53,8 @@ export interface LspTextEdit {
53
53
 
54
54
  export interface LanguageEntry {
55
55
  extensions: string[];
56
+ /** Exact basenames for files such as Dockerfile and CMakeLists.txt. */
57
+ fileNames?: string[];
56
58
  }
57
59
 
58
60
  export type ServerCapability = "diagnostics";
@@ -61,6 +63,9 @@ export interface ServerConfig {
61
63
  command: string[];
62
64
  transport?: "stdio";
63
65
  rootMarkers: string[];
66
+
67
+ /** Require a root marker in the file's directory or an ancestor inside the project. */
68
+ requireRootMarker?: boolean;
64
69
  languages: Record<string, LanguageEntry>;
65
70
  capabilities: ServerCapability[];
66
71
  env?: Record<string, string>;
@@ -3,6 +3,8 @@
3
3
  export type Severity = "error" | "warning" | "info" | "hint";
4
4
 
5
5
  export interface Diagnostic {
6
+ /** Source path when a tool reports more than the requested file. */
7
+ file?: string;
6
8
  code: string;
7
9
  message: string;
8
10
  /**
@@ -1 +0,0 @@
1
- import{a as E}from"./chunk-ERVMDQGX.js";import{a as D,b as R}from"./chunk-VFBLX4TG.js";import{a as L}from"./chunk-OBWZ5RYN.js";import{a as w,b}from"./chunk-KZBAJFCV.js";import{e as v,f as j,g as h,h as x,k as P}from"./chunk-7NDBZ4WX.js";import{a as d}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";function S(n,t){if(n.trim().length===0)return[];switch(t.format){case"pi-json":return q(n);case"eslint-json":return M(n);case"sarif":return F(n);case"checkstyle":return J(n);case"gcc":case"clang":return V(n);case"regex":return z(n,d(t.pattern))}}s(S,"parseDiagnostics");function q(n){let t=JSON.parse(n);return Array.isArray(t.diagnostics)?t.diagnostics.flatMap(u):[]}s(q,"parsePiJson");function M(n){return JSON.parse(n).flatMap(e=>Array.isArray(e.messages)?e.messages.flatMap(u):[])}s(M,"parseEslintJson");function F(n){return(JSON.parse(n).runs??[]).flatMap(e=>(e.results??[]).flatMap(r=>{let i=r.locations?.[0]?.physicalLocation?.region??{},a=r.message;return u({line:i.startLine,column:i.startColumn,message:a?.text,code:r.ruleId,severity:B(r.level)})}))}s(F,"parseSarif");function J(n){let t=[],e=/<error\s+([^>]+?)\/?>(?:<\/error>)?/gu;for(let r of n.matchAll(e)){let i=Object.fromEntries([...d(r[1]).matchAll(/([\w-]+)="([^"]*)"/gu)].map(a=>[d(a[1]),H(d(a[2]))]));t.push(...u({line:Number(i.line),column:Number(i.column??1),message:i.message,code:i.source,severity:i.severity}))}return t}s(J,"parseCheckstyle");function V(n){return T(n,/^(?<file>.+?):(?<line>\d+):(?<column>\d+):\s*(?<severity>fatal error|error|warning|note|info|hint):\s*(?<message>.*?)(?:\s+\[(?<code>[^\]]+)\])?$/u)}s(V,"parseCompilerLines");function z(n,t){return T(n,new RegExp(t,"u"))}s(z,"parseRegexLines");function T(n,t){return n.split(/\r?\n/u).flatMap(e=>{let r=e.match(t)?.groups;return r===void 0?[]:u(r)})}s(T,"parseMatchingLines");function u(n){if(typeof n!="object"||n===null)return[];let t=n,e=I(t.line??t.startLine),r=I(t.column??t.startColumn,1),i=typeof t.message=="string"?t.message:void 0;return e===void 0||i===void 0?[]:[{code:O(t.code??t.ruleId,"lint"),message:i,line:e,column:r??1,severity:G(t.severity)}]}s(u,"normalizeDiagnostic");function I(n,t){let e=typeof n=="string"?Number.parseInt(n,10):n;return typeof e=="number"&&Number.isInteger(e)&&e>=1?e:t}s(I,"numberValue");function O(n,t){return typeof n=="string"||typeof n=="number"?String(n):t}s(O,"stringValue");function G(n){if(n===2)return"error";if(n===1)return"warning";let t=O(n,"warning").toLowerCase();return t.includes("error")?"error":t==="info"||t==="note"||t==="notice"?"info":t==="hint"?"hint":"warning"}s(G,"severityValue");function B(n){return n==="error"||n==="warning"||n==="note"?n:"warning"}s(B,"sarifSeverity");function H(n){return n.replaceAll("&quot;",'"').replaceAll("&apos;","'").replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&")}s(H,"decodeXml");import A from"node:path";var f=class n{constructor(t,e){this.linters=t;this.availableBuiltIns=e}static{s(this,"LintCommandRegistry")}static async fromDirectory(t,e={}){let r=await v(t,"linters",o=>P(o).linters,e),i=e.environment??process.env,a=await Promise.all(r.entries.filter(o=>o.layer==="built-in").map(async o=>({id:o.id,available:await h(o.config.check,t,i)})));return new n(r.entries,new Set(a.filter(o=>o.available).map(o=>o.id)))}static fromConfig(t){return new n(Object.entries(t.linters).map(([e,r])=>({id:e,config:r,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(t,e){return this.resolveEntry(t,e)?.config}resolveEntry(t,e){let r=A.isAbsolute(t)?t:A.join(e,t);return this.linters.find(i=>(i.layer!=="built-in"||this.availableBuiltIns.has(i.id))&&j(i.config,r,e))}get entries(){return this.linters}};async function p(n,t){let e;try{e=await x(n.check,t)}catch(a){return{ok:!1,diagnostics:[],failure:`command could not start: ${a instanceof Error?a.message:String(a)}`}}let r=e.stdout.trim().length>0?e.stdout:e.stderr,i;try{i=S(r,n.diagnostics)}catch{return{ok:!1,diagnostics:[],failure:`invalid ${n.diagnostics.format} diagnostics: ${r.trim().slice(0,200)||"empty command output"}`}}return{ok:e.ok,diagnostics:i,...!e.ok&&{failure:e.stderr.trim().slice(0,200)||`command exited with code ${String(e.exitCode)}`}}}s(p,"runConfiguredLinter");function N(n){return{kind:"linter",name:"command-lint",priority:100,extensions:["*"],detect:s(()=>Promise.resolve(!0),"detect"),async lint({filePath:t,fix:e},r){let i=n.resolve(t,r.cwd);if(i===void 0)return{ok:!0,diagnostics:[]};let a=e===!0&&i.fix!==void 0?i.fix:i.check,o=await p({...i,check:a},{projectRoot:r.cwd,filePath:t});return{ok:o.ok,diagnostics:o.diagnostics}}}}s(N,"createCommandLinter");import{copyFile as X,mkdtemp as K,rm as Q}from"node:fs/promises";import k from"node:path";var $=[c("clang-tidy",["c","cpp"],["clang-tidy"],[".clang-tidy","compile_commands.json"],[".c",".h",".cc",".cpp",".cxx",".hpp"],["clang-tidy","{file}"],"clang","https://clang.llvm.org/extra/clang-tidy/"),c("eslint",["javascript","typescript"],["eslint"],["eslint.config.js","eslint.config.mjs",".eslintrc.json"],[".js",".jsx",".mjs",".cjs",".ts",".tsx"],["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","{file}"],"gcc","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"],"gcc","https://learn.microsoft.com/dotnet/core/tools/dotnet-format"),c("checkstyle",["java"],["checkstyle"],["checkstyle.xml","pom.xml"],[".java"],["checkstyle","-f","xml","{file}"],"checkstyle","https://checkstyle.org/"),c("detekt",["kotlin"],["detekt"],["detekt.yml","build.gradle.kts"],[".kt",".kts"],["detekt","--input","{file}"],"gcc","https://detekt.dev/"),c("rubocop",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--format","clang","{file}"],"clang","https://docs.rubocop.org/"),c("phpcs",["php"],["phpcs"],["phpcs.xml","phpcs.xml.dist","composer.json"],[".php"],["phpcs","--report=emacs","{file}"],"gcc","https://github.com/PHPCSStandards/PHP_CodeSniffer"),c("swiftlint",["swift"],["swiftlint"],[".swiftlint.yml","Package.swift"],[".swift"],["swiftlint","lint","--path","{file}"],"gcc","https://github.com/realm/SwiftLint"),c("luacheck",["lua"],["luacheck"],[".luacheckrc"],[".lua"],["luacheck","--formatter","plain","{file}"],"gcc","https://github.com/lunarmodules/luacheck"),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}"],"gcc","https://stylelint.io/",void 0,["stylelint"]),c("yamllint",["yaml"],["yamllint"],[".yamllint",".yamllint.yml"],[".yaml",".yml"],["yamllint","-f","parsable","{file}"],"gcc","https://yamllint.readthedocs.io/"),c("markdownlint",["markdown"],["markdownlint"],[".markdownlint.json",".markdownlint.yaml"],[".md",".mdx"],["markdownlint","{file}"],"gcc","https://github.com/DavidAnson/markdownlint"),c("sqlfluff",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","lint","--format","sarif","{file}"],"sarif","https://docs.sqlfluff.com/"),c("hadolint",["dockerfile"],["hadolint"],[".hadolint.yaml"],["*"],["hadolint","--format","tty","{file}"],"gcc","https://github.com/hadolint/hadolint"),c("tflint",["terraform"],["tflint"],[".tflint.hcl"],[".tf"],["tflint","--format","compact"],"gcc","https://github.com/terraform-linters/tflint"),c("cmake-lint",["cmake"],["cmake-lint"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-lint","{file}"],"gcc","https://cmake-format.readthedocs.io/"),c("htmlhint",["html"],["htmlhint"],[".htmlhintrc"],[".html",".htm"],["htmlhint","--format","unix","{file}"],"gcc","https://htmlhint.com/"),c("jsonlint",["json"],["jsonlint"],["package.json"],[".json",".jsonc"],["jsonlint","-q","{file}"],"gcc","https://github.com/zaach/jsonlint"),c("taplo-check",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","check","{file}"],"gcc","https://taplo.tamasfe.dev/"),c("xmllint",["xml"],["xmllint"],[".xmllintrc"],[".xml",".xsd",".xsl"],["xmllint","--noout","{file}"],"gcc","https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html")];function c(n,t,e,r,i,a,o,l,m,g){return{id:n,name:n,kind:"linter",languages:t,executables:e,configFiles:r,documentation:l,...g&&{dependencies:g},linter:{extensions:i,check:{command:a,successExitCodes:[0,1]},diagnostics:{format:o,...m&&{pattern:m}}}}}s(c,"recipe");var _={protocol:D,apiVersion:1,id:"lint",setup(n){for(let t of $)n.addToolRecipe(t);n.addSetupCheck({id:"effective-config",inspect:U}),n.addCheck({id:"config",title:"Linter",async run(t){try{let e=await f.fromDirectory(t.cwd,{environment:t.env}),r=W(e,t.files,t.cwd);return r.length===0?[{status:"skip",message:"No linter matches the inspected project files"}]:await Promise.all(r.map(async({entry:i,source:a})=>{let o=`${i.id} [${i.layer}] command ${JSON.stringify(i.config.check.command)}`,l=await K(k.join(k.dirname(a),".pi-agent-ide-doctor-")),m=k.join(l,k.basename(a));try{await X(a,m);let g=await p(i.config,{projectRoot:t.cwd,filePath:m,env:t.env});return g.ok?{status:"pass",message:`${o}: probe passed`,detail:i.sourcePath}:{status:"fail",message:`${o}: probe failed`,detail:g.failure??i.sourcePath}}catch(g){return{status:"fail",message:`${o}: ${g instanceof Error?g.message:String(g)}`,detail:i.sourcePath}}finally{await Q(l,{recursive:!0,force:!0})}}))}catch(e){return[{status:"fail",message:e instanceof Error?e.message:String(e)}]}}})}};async function U(n){try{let t=await f.fromDirectory(n.cwd,{environment:n.env}),e=[],r=new Map;for(let[i,a]of n.detectedLanguages){let o=a.map(l=>t.resolveEntry(l,n.cwd)).find(l=>l!==void 0);o!==void 0&&(e.push({kind:"linter",languageId:i,toolId:o.id}),await h(o.config.check,n.cwd,n.env)||r.set(o.id,{id:`linter-${o.id}-unavailable`,message:`Configured linter ${o.id} cannot run ${JSON.stringify(o.config.check.command)}`}))}return{selections:e,actions:[...r.values()]}}catch(t){return{actions:[{id:"linter-config-invalid",message:`Linter configuration cannot load: ${t instanceof Error?t.message:String(t)}`}]}}}s(U,"inspectLinterSetup");function W(n,t,e){let r=new Map;for(let i of t){let a=n.resolveEntry(i,e);a!==void 0&&!r.has(a.id)&&r.set(a.id,{entry:a,source:i})}return[...r.values()]}s(W,"applicableLinters");async function Y(n){let t,e,r=s(o=>((e===void 0||t!==o)&&(t=o,e=Z(o)),e),"registryFor"),i={kind:"linter",name:"pi-agent-ide-lint",priority:200,extensions:["*"],detect:s(async o=>(await r(o.cwd),!0),"detect"),async lint(o,l){let m=await r(l.cwd);return N(m).lint(o,l)}},a={protocol:w,apiVersion:3,id:"lint",setup(o){o.addTool(i),o.addDiagnosticSource({id:"lint",async diagnose(l,m){let g=await r(m.cwd);m.signal.throwIfAborted();let C=g.resolve(l,m.cwd);if(!C)return{status:"unavailable",diagnostics:[],reason:"No linter configured for this file"};let y=await p(C,{projectRoot:m.cwd,filePath:l,signal:m.signal});return!y.ok&&y.diagnostics.length===0?{status:"unavailable",diagnostics:[],reason:y.failure??"Lint check failed"}:{status:"ready",diagnostics:y.diagnostics}}})}};await Promise.all([L(n,a),E(n,_)])}s(Y,"registerLint");async function Z(n){let t=process.env.PI_AGENT_IDE_CONFIG_DIR??n;return f.fromDirectory(t)}s(Z,"loadRegistry");export{Y as a};
@@ -1,13 +0,0 @@
1
- import{a as N,b as O}from"./chunk-QNZVPFSP.js";import{j as b,k as g}from"./chunk-5A25RATC.js";import"./chunk-2SKAED2I.js";import"./chunk-KINKBPPX.js";import{a as w}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{readdir as $}from"node:fs/promises";import U from"node:path";async function E(e){let n=[],t=await $(e,{withFileTypes:!0});for(let i of t){let r=U.join(e,i.name);i.isDirectory()?n.push(...await E(r)):(i.isFile()||i.isSymbolicLink())&&n.push(r)}return n}s(E,"collectFiles");import{readFile as Y}from"node:fs/promises";var k=256*1024;async function T(e){let n=await Y(e);if(n.byteLength>k)throw new Error(`File exceeds the ${k}-byte AST outline limit: ${e}`);if(n.includes(0))throw new Error(`File appears to be binary and cannot be read as text: ${e}`);let t=n.toString("utf8").replaceAll(`\r
2
- `,`
3
- `),i=t.endsWith(`
4
- `)?t.slice(0,-1):t,r=i.length===0?[]:i.split(`
5
- `);return{content:t,lines:r}}s(T,"readTextFile");var K=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".py",".rs",".c",".cpp",".cxx",".h",".hpp",".json",".jsonc",".yaml",".yml",".toml"]),H=new Set([".json",".jsonc",".yaml",".yml",".toml"]),R=new Set(["class_declaration","class_definition","class_specifier","enum_declaration","enum_definition","enum_item","enum_specifier","export_statement","function_declaration","function_definition","function_item","impl_item","interface_declaration","lexical_declaration","namespace_definition","mod_item","public_field_definition","method_definition","method_signature","property_signature","field_declaration","struct_item","struct_specifier","trait_item","type_alias_declaration","type_item","variable_declaration","assignment"]),X=new Set(["module","program","source_file"]),q=new Set(["import_declaration","import_from_statement","import_statement","use_declaration"]),A=new Set(["arrow_function","function_declaration","function_definition","function_item","function_expression","method_definition"]),Z=new Set(["public_field_definition","variable_declarator","assignment"]),F=new Set(["field_identifier","identifier","property_identifier","shorthand_property_identifier_pattern","type_identifier"]);function I(e){return K.has(h.extname(e).toLowerCase())}s(I,"isSupportedOutlinePath");var _={failureLabel:"PEEK_FAILED",emptyReason:"no entries to peek.",recovery:['Call peek with { peers: [{ path: "path/to/file.ts" }, ...] }.']},z={failureLabel:"AST_OUTLINE_FAILED",emptyReason:"no AST outline was produced."};function Ee(e){return g([e],z)}s(Ee,"formatAstOutline");var v=class{static{s(this,"AstOutlineManager")}fallbackScopeManager=new O;async readFileOutline(n,t){let i=W(n,t),r=h.relative(t,i)||i;if(!I(i))throw new Error(`AST outline is not supported for ${r}.`);let o=await T(i),c=await N(i,t,o.lines);if(!c)throw new Error(`No AST parser is available for ${r}.`);return await this.createSourceViewBlock(c.rootNode,i,r,t,o.lines,o.content,h.extname(i).toLowerCase())}async formatFile(n,t){let i=W(n,t),r=h.relative(t,i)||i;if(!I(i)){let o=await T(i);return g([G(i,r,o.lines)],_)}try{return g([await this.readFileOutline(i,t)],_)}catch(o){let c=o instanceof Error?o.message:String(o);return g([M(r,c)],_)}}async formatSymbol(n,t){let r=(await E(t)).filter(o=>I(o)).sort();for(let o of r){let c;try{c=await T(o)}catch{continue}let l;try{l=await N(o,t,c.lines)}catch{continue}if(!l)continue;let d=ee(l.rootNode,n);if(!d)continue;let a=h.relative(t,o)||o,u=await this.createSourceViewBlock(d,o,a,t,c.lines,c.content,h.extname(o).toLowerCase(),n,[`defined in: ${a}:${d.startPosition.row+1}`]);return g([u],_)}return g([M("",`symbol not found: ${n}`,"PEEK_NOT_FOUND")],_)}async createSourceViewBlock(n,t,i,r,o,c,l,d,a){let u=re(n,c,l),p=await J(this.fallbackScopeManager,t,r,o),S=Q(p),x=u.map(y=>{let f=y.sourceLine,m=f===void 0?void 0:o[f-1]??"",C=(f===void 0?void 0:S.get(f))?.map(D=>` <!-- ${D} -->`).join("")??"";return b({content:y.content,...!(f===void 0||m===void 0)&&{sourceLine:{source:t,lineNumber:f,content:m}},...C.length>0&&{suffix:C}})});return{path:i,...d!==void 0&&{heading:d},...a!==void 0&&{details:a},startLine:n.startPosition.row+1,endLine:n.endPosition.row+1,totalLines:o.length,renderedLines:x}}};function G(e,n,t){return{path:n,startLine:t.length>0?1:0,endLine:t.length,totalLines:t.length,renderedLines:t.map((i,r)=>b({content:i,sourceLine:{source:e,lineNumber:r+1,content:i}}))}}s(G,"formatUnsupportedSourceBlock");function M(e,n,t="PEEK_FAILED"){return{path:e,startLine:0,endLine:0,totalLines:0,renderedLines:[],status:"failed",error:n,code:t}}s(M,"failedSourceViewBlock");function J(e,n,t,i){return e.getDocumentScopes(n,t,i)}s(J,"getOutlineScopes");function Q(e){let n=new Map;for(let t of e){let i=n.get(t.startLine)??[];i.push(t.beginAnchor.value),n.set(t.startLine,i);let r=n.get(t.endLine)??[];r.push(t.endScopeAnchor.value),n.set(t.endLine,r)}return n}s(Q,"buildScopeMarkers");function W(e,n){return e.startsWith("file://")?decodeURIComponent(e.slice(7)):h.isAbsolute(e)?e:h.resolve(n,e)}s(W,"resolvePath");function ee(e,n){let t,i=s(r=>{if(!t){if(R.has(r.type)&&te(r)===n){t=ne(r);return}for(let o of r.namedChildren)i(o)}},"visit");return i(e),t}s(ee,"findSymbol");function te(e){let n=e.childForFieldName("name");if(n&&F.has(n.type))return n.text;for(let t of e.namedChildren)if(F.has(t.type))return t.text;if(e.type==="lexical_declaration"||e.type==="variable_declaration")return e.namedChildren.find(r=>r.type==="variable_declarator")?.childForFieldName("name")?.text;if(e.type==="function_definition"){let t=e.childForFieldName("declarator");return t?B(t):void 0}}s(te,"getNodeName");function B(e){if(F.has(e.type))return e.text;for(let n of e.namedChildren){let t=B(n);if(t)return t}}s(B,"findNestedName");function ne(e){let n=e.parent;return n&&(n.type==="export_statement"||n.type==="decorated_definition"||n.type==="template_declaration")?n:e}s(ne,"unwrapDeclaration");function re(e,n,t){let i=[];H.has(t)?j(e,t,i):V(e,t,i);let r=ie(n,e.startIndex),o=oe(n,e.endIndex),c=i.filter(a=>a.start>=r&&a.end<=o).sort((a,u)=>u.start-a.start),l=se(n,r,o);for(let a of c){let u=a.start-r,p=a.end-r,S=ae(a);l.splice(u,p-u,...S)}for(;l.length>0&&/\s/u.test(w(l.at(-1)).char);)l.pop();let d=[[]];for(let a of l)a.char===`
6
- `?d.push([]):w(d.at(-1)).push(a);return d.map(a=>{let u=[...new Set(a.flatMap(p=>p.sourceLine===void 0?[]:[p.sourceLine]))];return{content:a.map(p=>p.char).join(""),...u.length===1&&{sourceLine:u[0]}}})}s(re,"renderNodeLines");function ie(e,n){return e.lastIndexOf(`
7
- `,Math.max(0,n-1))+1}s(ie,"lineStartAt");function oe(e,n){let t=e.indexOf(`
8
- `,n);return t===-1?e.length:t}s(oe,"lineEndAt");function se(e,n,t){let i=e.slice(0,n).split(`
9
- `).length,r=[];for(let o of e.slice(n,t))r.push({char:o,sourceLine:i}),o===`
10
- `&&(i+=1);return r}s(se,"mapSourceRange");function ae(e){let n=e.lineSourceLines??[],t=0,i=[];for(let r=0;r<e.text.length;r+=1){let o=w(e.text[r]),c=n[t];i.push(c===void 0?{char:o}:{char:o,sourceLine:c}),o===`
11
- `&&(t+=1)}return i}s(ae,"mapReplacement");function j(e,n,t){for(let i of e.namedChildren){if(ce(i,n)){le(i)||t.push({start:i.startIndex,end:i.endIndex,text:"\u2026",lineSourceLines:[i.startPosition.row+1]});continue}j(i,n,t)}}s(j,"collectDataReplacements");function ce(e,n){return(n===".json"||n===".jsonc"?["string","number","true","false","null"]:n===".yaml"||n===".yml"?["string_scalar","integer_scalar","float_scalar","boolean_scalar","null_scalar","block_scalar"]:["string","integer","float","boolean","date_time","offset_date_time","local_date_time","local_date","local_time"]).includes(e.type)}s(ce,"isDataScalar");function le(e){let n=e.parent;for(;n&&!n.type.endsWith("pair")&&n.type!=="pair"&&n.type!=="table";)n=n.parent;let t=n?.namedChildren[0];return t!==void 0&&t.startIndex<=e.startIndex&&t.endIndex>=e.endIndex}s(le,"isDataKey");function V(e,n,t,i=!1){if(i&&!de(e)){t.push({start:e.startIndex,end:e.endIndex,text:"\u2026",lineSourceLines:[e.startPosition.row+1]});return}if(A.has(e.type)){let r=ue(e);if(r){let o=pe(r,n);t.push({start:r.startIndex,end:r.endIndex,text:o.text,lineSourceLines:o.lineSourceLines});return}}if(Z.has(e.type)){let r=e.childForFieldName("value");if(r&&!A.has(r.type)){t.push({start:r.startIndex,end:r.endIndex,text:"\u2026",lineSourceLines:[r.startPosition.row+1]});return}}for(let r of e.namedChildren)V(r,n,t,X.has(e.type))}s(V,"collectReplacements");function de(e){return R.has(e.type)||q.has(e.type)||e.type==="comment"||e.type.startsWith("preproc")}s(de,"isTopLevelInterfaceNode");function ue(e){let n=e.childForFieldName("body");return n||e.namedChildren.find(t=>t.type==="block"||t.type==="compound_statement"||t.type==="statement_block")}s(ue,"findBody");function pe(e,n){let t=e.startPosition.row+1,i=e.endPosition.row+1;if(n===".py")return{text:"...",lineSourceLines:[t]};let r=e.text.split(`
12
- `),o=r[0]??"",c=r.at(-1)??"",l=o.indexOf("{"),d=c.lastIndexOf("}");if(l===-1||d===-1)return{text:"\u2026",lineSourceLines:[t]};if(r.length===1){let m=o.slice(l+1,d);return m.trim()===""?{text:e.text,lineSourceLines:[t]}:{text:o.slice(0,l+1)+P(m)+o.slice(d),lineSourceLines:[t]}}let a=o.slice(l+1),u=c.slice(0,d),p=r.slice(1,-1).some(m=>m.trim()!==""),S=a.trim()!=="",x=u.trim()!=="";if(!p&&!S&&!x)return{text:e.text,lineSourceLines:r.map((m,L)=>t+L)};let y=[],f=[];if(y.push(S?o.slice(0,l+1)+P(a):o),f.push(t),!S&&p){let m=r.slice(1,-1).find(L=>L.trim()!=="")?.match(/^\s*/u)?.[0]??"";y.push(`${m}\u2026`),f.push(void 0)}return y.push(x?P(u)+c.slice(d):c),f.push(i),{text:y.join(`
13
- `),lineSourceLines:f}}s(pe,"renderBodyPlaceholder");function P(e){let n=/^\s*/u.exec(e)?.[0]??"",t=/\s*$/u.exec(e)?.[0]??"";return`${n}\u2026${t}`}s(P,"maskSegment");export{v as AstOutlineManager,Ee as formatAstOutline,I as isSupportedOutlinePath};
@@ -1 +0,0 @@
1
- import{a as m}from"./chunk-ZC65Z3CK.js";import{a as i}from"./chunk-EI7MMDWY.js";import N from"cross-spawn";import{constants as F}from"node:fs";import{access as O,readFile as h,writeFile as b}from"node:fs/promises";import S from"node:os";import s from"node:path";import{fileURLToPath as I}from"node:url";var j=1;function A(e){return s.join(e,".pi","pi-agent-ide")}i(A,"projectIdeConfigDirectory");function M(e,o){return s.join(A(e),`${o}.json`)}i(M,"projectIdeConfigPath");function _(e,o,n={}){let t=(n.environment??process.env).PI_CODING_AGENT_DIR?.trim(),c=t===void 0||t.length===0?s.join(n.homeDirectory??S.homedir(),".pi","agent"):s.resolve(t);return{project:M(e,o),global:s.join(c,"extensions","pi-agent-ide",`${o}.json`),builtIn:I(new URL(`tool-config/${o}.json`,new URL("../src/api/tool-config.ts",import.meta.url).href))}}i(_,"resolveToolConfigPaths");async function Q(e,o,n,r={}){let t=_(e,o,r),c=[{layer:"project",sourcePath:t.project,optional:!0},{layer:"global",sourcePath:t.global,optional:!0},{layer:"built-in",sourcePath:t.builtIn,optional:!1}],a=[],g=new Set;for(let d of c){let w=await J(d,o,n);for(let[l,y]of Object.entries(w))g.has(l)||(g.add(l),a.push({id:l,config:y,layer:d.layer,sourcePath:d.sourcePath}))}return{entries:a,paths:t}}i(Q,"loadLayeredToolConfig");function Y(e,o,n){let r=s.extname(o).toLowerCase();if(e.extensions.every(a=>!(G(a)===r||a==="*")))return!1;let t=s.relative(n,o).split(s.sep).join("/"),c=i(a=>a?.some(g=>s.matchesGlob(t,g))??!1,"matches");return(e.include===void 0||c(e.include))&&!c(e.exclude)}i(Y,"matchesConfiguredFile");async function Z(e,o,n=process.env){p(e,"process");let r=m(e.command[0]).replaceAll("{project}",o),t=L(e,o,n),c=s.isAbsolute(r)||s.dirname(r)!=="."?[s.resolve(o,r)]:(t.PATH??"").split(s.delimiter).filter(Boolean).map(a=>s.join(a,r));for(let a of c)try{return await O(a,F.X_OK),!0}catch{}return!1}i(Z,"hasConfiguredExecutable");async function D(e,o){p(e,"process");let n=e.command.map(d=>B(d,o)),r=m(n[0]),t=n.slice(1),c=e.cwd==="file"?s.dirname(o.filePath):o.projectRoot,a=e.successExitCodes??[0],g=L(e,o.projectRoot,o.env??process.env);return new Promise((d,w)=>{let l=N(r,t,{cwd:c,env:g,signal:o.signal,killSignal:"SIGKILL",stdio:["ignore","pipe","pipe"]}),y="",P="",v=m(l.stdout),T=m(l.stderr),E=!1,x=setTimeout(()=>{E=!0,l.kill("SIGKILL")},e.timeoutMs??3e4);v.setEncoding("utf8"),T.setEncoding("utf8"),v.on("data",f=>{y+=f}),T.on("data",f=>{P+=f}),l.on("error",f=>{clearTimeout(x),w(f)}),l.on("close",f=>{clearTimeout(x),d({ok:!E&&f!==null&&a.includes(f),exitCode:f,stdout:y,stderr:P})})})}i(D,"runConfiguredProcess");async function ee(e,o){let n=await h(o.filePath,"utf8"),r=await D(e.run,o);if(!r.ok)return e.output==="in-place"&&await h(o.filePath,"utf8")!==n&&await b(o.filePath,n,"utf8"),{ok:!1,changed:!1};e.output==="stdout"&&r.stdout!==n&&await b(o.filePath,r.stdout,"utf8");let t=await h(o.filePath,"utf8");return{ok:!0,changed:n!==t}}i(ee,"runConfiguredFormatter");function oe(e){let o=R(e,"formatters");for(let[n,r]of Object.entries(o.entries)){let t=u(r,`formatter ${n}`);if(k(t,`formatter ${n}`),p(t.run,`formatter ${n}.run`),t.output!=="in-place"&&t.output!=="stdout")throw new Error(`formatter ${n}.output must be in-place or stdout`)}return e}i(oe,"parseFormattersConfig");function ne(e){let o=R(e,"linters"),n=new Set(["pi-json","eslint-json","sarif","checkstyle","gcc","clang","regex"]);for(let[r,t]of Object.entries(o.entries)){let c=u(t,`linter ${r}`);k(c,`linter ${r}`),p(c.check,`linter ${r}.check`),c.fix!==void 0&&p(c.fix,`linter ${r}.fix`);let a=u(c.diagnostics,`linter ${r}.diagnostics`);if(!n.has(String(a.format)))throw new Error(`linter ${r} has an unsupported diagnostics format`);if(a.format==="regex"&&typeof a.pattern!="string")throw new Error(`linter ${r} regex diagnostics require pattern`)}return e}i(ne,"parseLintersConfig");function R(e,o){let n=u(e,"tool config");if(n.version!==j)throw new Error(`tool config version must be ${j}`);return{entries:u(n[o],o)}}i(R,"configRoot");function k(e,o){C(e.extensions,`${o}.extensions`,!1),e.include!==void 0&&C(e.include,`${o}.include`,!1),e.exclude!==void 0&&C(e.exclude,`${o}.exclude`,!0)}i(k,"assertMatcher");function p(e,o){let n=u(e,o);if(C(n.command,`${o}.command`,!1),n.cwd!==void 0&&n.cwd!=="project"&&n.cwd!=="file")throw new Error(`${o}.cwd must be project or file`);if(n.timeoutMs!==void 0&&(!Number.isFinite(n.timeoutMs)||Number(n.timeoutMs)<=0))throw new Error(`${o}.timeoutMs must be positive`);if(n.successExitCodes!==void 0&&(!Array.isArray(n.successExitCodes)||n.successExitCodes.some(r=>!Number.isInteger(r))))throw new Error(`${o}.successExitCodes must contain integers`);if(n.env!==void 0){let r=u(n.env,`${o}.env`);if(Object.values(r).some(t=>typeof t!="string"))throw new Error(`${o}.env values must be strings`)}}i(p,"assertProcessConfig");function C(e,o,n){if(!Array.isArray(e)||!n&&e.length===0||e.some(r=>typeof r!="string"||r.length===0))throw new Error(`${o} must be ${n?"an":"a non-empty"} array of strings`)}i(C,"assertStringArray");function u(e,o){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${o} must be an object`);return e}i(u,"configRecord");function G(e){return e.startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`}i(G,"normalizeExtension");async function J(e,o,n){let r;try{r=await h(e.sourcePath,"utf8")}catch(t){if(e.optional&&V(t))return{};throw new Error(`Cannot read ${e.layer} ${o} config at ${e.sourcePath}: ${$(t)}`,{cause:t})}try{return n(JSON.parse(r))}catch(t){throw new Error(`Invalid ${e.layer} ${o} config at ${e.sourcePath}: ${$(t)}`,{cause:t})}}i(J,"readToolConfigLayer");function V(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}i(V,"isMissingFile");function $(e){return e instanceof Error?e.message:String(e)}i($,"errorMessage");function L(e,o,n){let r={...n,...e.env},t=s.resolve(o,"node_modules",".bin");return r.PATH=[t,r.PATH].filter(Boolean).join(s.delimiter),r}i(L,"createConfiguredProcessEnvironment");function B(e,o){let n=s.relative(o.projectRoot,o.filePath);return e.replaceAll("{project}",o.projectRoot).replaceAll("{fileDir}",s.dirname(o.filePath)).replaceAll("{relativeFile}",n).replaceAll("{file}",o.filePath)}i(B,"expandPlaceholders");export{j as a,A as b,M as c,_ as d,Q as e,Y as f,Z as g,D as h,ee as i,oe as j,ne as k,L as l};
@@ -1 +0,0 @@
1
- import{a as p}from"./chunk-ERVMDQGX.js";import{a as l,b as c}from"./chunk-VFBLX4TG.js";import{a as e}from"./chunk-EI7MMDWY.js";var m=[t("c","C",[".c",".h"],["CMakeLists.txt","meson.build","compile_commands.json"],"tree-sitter"),t("cpp","C++",[".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["CMakeLists.txt","meson.build","compile_commands.json","conanfile.py","vcpkg.json"],"tree-sitter"),t("csharp","C#",[".cs"],[".sln",".csproj","global.json"]),t("go","Go",[".go"],["go.mod","go.work"]),t("java","Java",[".java"],["pom.xml","build.gradle","build.gradle.kts"]),t("kotlin","Kotlin",[".kt",".kts"],["build.gradle.kts","settings.gradle.kts"]),t("javascript","JavaScript",[".js",".jsx",".mjs",".cjs"],["package.json"],"tree-sitter"),t("typescript","TypeScript",[".ts",".tsx",".mts",".cts"],["tsconfig.json","package.json"],"tree-sitter"),t("python","Python",[".py",".pyi"],["pyproject.toml","requirements.txt","setup.py"],"tree-sitter"),t("rust","Rust",[".rs"],["Cargo.toml"],"tree-sitter"),t("ruby","Ruby",[".rb",".rake"],["Gemfile",".ruby-version"]),t("php","PHP",[".php"],["composer.json"]),t("swift","Swift",[".swift"],["Package.swift"]),t("lua","Lua",[".lua"],[".luarc.json","stylua.toml"]),t("shell","Shell",[".sh",".bash",".zsh"],[".shellcheckrc"]),t("html","HTML",[".html",".htm"],[]),t("css","CSS",[".css",".scss",".sass",".less"],["stylelint.config.js"]),t("json","JSON",[".json",".jsonc"],[],"tree-sitter"),t("yaml","YAML",[".yaml",".yml"],[".yamllint"],"tree-sitter"),t("toml","TOML",[".toml"],["taplo.toml"],"tree-sitter"),t("xml","XML",[".xml",".xsd",".xsl"],[]),t("markdown","Markdown",[".md",".mdx"],[".markdownlint.json"]),t("sql","SQL",[".sql"],[".sqlfluff"]),t("dockerfile","Dockerfile",[],["Dockerfile","compose.yaml"],void 0,["Dockerfile","Containerfile"]),t("terraform","Terraform",[".tf",".tfvars"],[".terraform.lock.hcl"]),t("cmake","CMake",[".cmake"],["CMakeLists.txt"],void 0,["CMakeLists.txt"])];function t(o,i,s,r,n,a){return{id:o,name:i,extensions:s,projectMarkers:r,...n&&{ast:n},...a&&{fileNames:a}}}e(t,"language");function g(o){return p(o,{protocol:l,apiVersion:1,id:"languages",setup(s){for(let r of m)s.addLanguage(r)}})}e(g,"registerLanguages");export{g as a};
@@ -1 +0,0 @@
1
- import{a as E}from"./chunk-ERVMDQGX.js";import{a as k,b as j}from"./chunk-VFBLX4TG.js";import{a as v}from"./chunk-OBWZ5RYN.js";import{a as y,b as h}from"./chunk-KZBAJFCV.js";import{e as b,f as C,g as p,i as g,j as w}from"./chunk-7NDBZ4WX.js";import{a as m}from"./chunk-EI7MMDWY.js";import{copyFile as S,mkdtemp as $,rm as q}from"node:fs/promises";import d from"node:path";var F=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".json",".jsonc",".css",".scss",".html",".md"],O=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".less",".html",".htm",".md",".markdown",".mdx",".yaml",".yml",".toml"],x=[s("clang-format",["c","cpp"],["clang-format"],[".clang-format","_clang-format"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-format","-i","{file}"],"https://clang.llvm.org/docs/ClangFormat.html"),s("prettier",["javascript","typescript","html","css","json","yaml","markdown"],["prettier"],[".prettierrc",".prettierrc.json","prettier.config.js"],F,["prettier","--write","{file}"],"https://prettier.io/docs/",["prettier"]),s("biome",["javascript","typescript","json","css"],["biome"],["biome.json","biome.jsonc"],F,["biome","format","--write","{file}"],"https://biomejs.dev/",["@biomejs/biome"]),s("oxfmt",["javascript","typescript","json","css","html","markdown","yaml","toml"],["oxfmt"],[".oxfmtrc.json",".oxfmtrc.jsonc","oxfmt.config.ts","oxfmt.config.mts"],O,["oxfmt","--write","{file}"],"https://oxc.rs/docs/guide/usage/formatter.html",["oxfmt"]),s("ruff-format",["python"],["ruff"],["pyproject.toml","ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","format","{file}"],"https://docs.astral.sh/ruff/formatter/",["ruff"]),s("black",["python"],["black"],["pyproject.toml"],[".py",".pyi"],["black","--quiet","{file}"],"https://black.readthedocs.io/",["black"]),s("gofmt",["go"],["gofmt"],["go.mod"],[".go"],["gofmt","-w","{file}"],"https://pkg.go.dev/cmd/gofmt"),s("goimports",["go"],["goimports"],["go.mod"],[".go"],["goimports","-w","{file}"],"https://pkg.go.dev/golang.org/x/tools/cmd/goimports"),s("rustfmt",["rust"],["rustfmt"],["rustfmt.toml",".rustfmt.toml","Cargo.toml"],[".rs"],["rustfmt","{file}"],"https://github.com/rust-lang/rustfmt"),s("csharpier",["csharp"],["dotnet-csharpier","csharpier"],[".csharpierrc",".csharpierrc.json"],[".cs"],["dotnet-csharpier","format","{file}"],"https://csharpier.com/"),s("google-java-format",["java"],["google-java-format"],["pom.xml","build.gradle"],[".java"],["google-java-format","--replace","{file}"],"https://github.com/google/google-java-format"),s("ktlint-format",["kotlin"],["ktlint"],[".editorconfig","build.gradle.kts"],[".kt",".kts"],["ktlint","-F","{file}"],"https://pinterest.github.io/ktlint/"),s("rubocop-format",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","-A","{file}"],"https://docs.rubocop.org/"),s("pint",["php"],["pint"],["pint.json","composer.json"],[".php"],["pint","{file}"],"https://laravel.com/docs/pint"),s("swift-format",["swift"],["swift-format"],[".swift-format","Package.swift"],[".swift"],["swift-format","format","--in-place","{file}"],"https://github.com/swiftlang/swift-format"),s("stylua",["lua"],["stylua"],["stylua.toml",".stylua.toml"],[".lua"],["stylua","{file}"],"https://github.com/JohnnyMorganz/StyLua"),s("shfmt",["shell"],["shfmt"],[".editorconfig"],[".sh",".bash",".zsh"],["shfmt","-w","{file}"],"https://github.com/mvdan/sh"),s("taplo",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","format","{file}"],"https://taplo.tamasfe.dev/"),s("sqlfluff-format",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","format","{file}"],"https://docs.sqlfluff.com/"),s("terraform-fmt",["terraform"],["terraform"],[".terraform.lock.hcl"],[".tf",".tfvars"],["terraform","fmt","{file}"],"https://developer.hashicorp.com/terraform/cli/commands/fmt"),s("cmake-format",["cmake"],["cmake-format"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-format","-i","{file}"],"https://cmake-format.readthedocs.io/"),s("xmlformat",["xml"],["xmlformat"],[".xmlformat.conf"],[".xml",".xsd",".xsl"],["xmlformat","--overwrite","{file}"],"https://github.com/pamoller/xmlformatter"),s("dockfmt",["dockerfile"],["dockfmt"],["Dockerfile"],["*"],["dockfmt","fmt","{file}"],"https://github.com/jessfraz/dockfmt")];function s(o,t,r,e,i,n,a,f){return{id:o,name:o,kind:"formatter",languages:t,executables:r,configFiles:e,documentation:a,...f&&{dependencies:f},formatter:{extensions:i,run:{command:n},output:"in-place"}}}m(s,"recipe");import P from"node:path";var c=class o{constructor(t,r){this.formatters=t;this.availableBuiltIns=r}static{m(this,"FormatterCommandRegistry")}static async fromDirectory(t,r={}){let e=await b(t,"formatters",a=>w(a).formatters,r),i=r.environment??process.env,n=await Promise.all(e.entries.filter(a=>a.layer==="built-in").map(async a=>({id:a.id,available:await p(a.config.run,t,i)})));return new o(e.entries,new Set(n.filter(a=>a.available).map(a=>a.id)))}static fromConfig(t){return new o(Object.entries(t.formatters).map(([r,e])=>({id:r,config:e,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(t,r){return this.resolveEntry(t,r)?.config}resolveEntry(t,r){let e=P.isAbsolute(t)?t:P.join(r,t);return this.formatters.find(i=>(i.layer!=="built-in"||this.availableBuiltIns.has(i.id))&&C(i.config,e,r))}get entries(){return this.formatters}};var R={protocol:k,apiVersion:1,id:"formatter",setup(o){for(let t of x)o.addToolRecipe(t);o.addSetupCheck({id:"effective-config",inspect:A}),o.addCheck({id:"config",title:"Formatter",async run(t){try{let r=await c.fromDirectory(t.cwd,{environment:t.env}),e=L(r,t.files,t.cwd);return e.length===0?[{status:"skip",message:"No formatter matches the inspected project files"}]:await Promise.all(e.map(async({entry:i,source:n})=>{let a=`${i.id} [${i.layer}] command ${JSON.stringify(i.config.run.command)}`,f=await $(d.join(d.dirname(n),".pi-agent-ide-doctor-")),u=d.join(f,d.basename(n));try{return await S(n,u),(await g(i.config,{projectRoot:t.cwd,filePath:u,env:t.env})).ok?{status:"pass",message:`${a}: probe passed`,detail:i.sourcePath}:{status:"fail",message:`${a}: probe failed`,detail:i.sourcePath}}catch(l){return{status:"fail",message:`${a}: ${l instanceof Error?l.message:String(l)}`,detail:i.sourcePath}}finally{await q(f,{recursive:!0,force:!0})}}))}catch(r){return[{status:"fail",message:r instanceof Error?r.message:String(r)}]}}})}};async function A(o){try{let t=await c.fromDirectory(o.cwd,{environment:o.env}),r=[],e=new Map;for(let[i,n]of o.detectedLanguages){let a=n.map(f=>t.resolveEntry(f,o.cwd)).find(f=>f!==void 0);a!==void 0&&(r.push({kind:"formatter",languageId:i,toolId:a.id}),await p(a.config.run,o.cwd,o.env)||e.set(a.id,{id:`formatter-${a.id}-unavailable`,message:`Configured formatter ${a.id} cannot run ${JSON.stringify(a.config.run.command)}`}))}return{selections:r,actions:[...e.values()]}}catch(t){return{actions:[{id:"formatter-config-invalid",message:`Formatter configuration cannot load: ${t instanceof Error?t.message:String(t)}`}]}}}m(A,"inspectFormatterSetup");function L(o,t,r){let e=new Map;for(let i of t){let n=o.resolveEntry(i,r);n!==void 0&&!e.has(n.id)&&e.set(n.id,{entry:n,source:i})}return[...e.values()]}m(L,"applicableFormatters");var T=new Map;function D(){return{kind:"formatter",name:"formatter",priority:100,extensions:["*"],detect:m(async o=>(await I(o.cwd),!0),"detect"),async format({filePath:o},t){let e=(await I(t.cwd)).resolve(o,t.cwd);if(e===void 0)return{ok:!0,edits:0};let i=await g(e,{projectRoot:t.cwd,filePath:o});return{ok:i.ok,edits:i.changed?1:0}}}}m(D,"createFormatter");async function I(o){let t=T.get(o);return t===void 0&&(t=c.fromDirectory(o),T.set(o,t)),t}m(I,"loadRegistry");async function M(o){let t={kind:"formatter",name:"pi-agent-ide-formatter",priority:200,extensions:["*"],detect:m(()=>Promise.resolve(!0),"detect"),async format(e,i){return D().format(e,i)}},r={protocol:y,apiVersion:3,id:"formatter",setup(e){e.addTool(t)}};await Promise.all([v(o,r),E(o,R)])}m(M,"registerFormatter");export{M as a};
@@ -1 +0,0 @@
1
- import{a as l}from"./chunk-EI7MMDWY.js";import{spawn as b}from"node:child_process";import{constants as m}from"node:fs";import{access as x}from"node:fs/promises";import o from"node:path";async function v(t,i,a){let u=o.isAbsolute(t)||o.dirname(t)!=="."?[o.resolve(i,t)]:[o.join(i,"node_modules",".bin",t),...(a.PATH??"").split(o.delimiter).filter(Boolean).map(s=>o.join(s,t))];for(let s of u)try{return await x(s,m.X_OK),!0}catch{}return!1}l(v,"isExecutableAvailable");function w(t,i,a,u){return new Promise(s=>{let r=b(t,i,{cwd:a,env:u,stdio:["ignore","pipe","pipe"],windowsHide:!0}),c="",f="",p=!1,g=setTimeout(()=>{r.kill(),d(!1,`${t} did not respond within 5 seconds`)},5e3),d=l((e,n)=>{p||(p=!0,clearTimeout(g),s(e?{ok:!0,detail:n}:{ok:!1,detail:n}))},"finish");r.stdout.setEncoding("utf8"),r.stderr.setEncoding("utf8"),r.stdout.on("data",e=>c+=e),r.stderr.on("data",e=>f+=e),r.once("error",e=>d(!1,e.message)),r.once("close",e=>{let n=(c.trim()||f.trim()).split(/\r?\n/u)[0];d(e===0,n||`${t} exited with code ${String(e)}`)}),g.unref()})}l(w,"probeExecutable");export{v as a,w as b};
@@ -1,8 +0,0 @@
1
- import{a as ue}from"./chunk-ERVMDQGX.js";import{a as pe,b as de}from"./chunk-VFBLX4TG.js";import{c as he}from"./chunk-SSZB66C3.js";import{a as fe}from"./chunk-ORAPGW7W.js";import{a as ge,b as me}from"./chunk-JASLOB2X.js";import{a as be}from"./chunk-E2RESHYR.js";import{a as ye,b as ve}from"./chunk-T2RPMEM2.js";import{a as ee,b as te,c as D,d as S,j as ne,k as re,l as se}from"./chunk-5A25RATC.js";import{a as ae}from"./chunk-OBWZ5RYN.js";import{a as oe,b as ie}from"./chunk-KZBAJFCV.js";import{e as ce,g as $,l as le}from"./chunk-7NDBZ4WX.js";import{a as f}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import Ye from"cross-spawn";import{createMessageConnection as Je,CancellationTokenSource as Xe,StreamMessageReader as Qe,StreamMessageWriter as Ze}from"vscode-jsonrpc/node";import{URI as we}from"vscode-uri";var R=class{static{a(this,"LspClient")}_process=null;_connection=null;_initialized=!1;_serverCapabilities=null;_disposed=!1;_crashed=!1;_handlers=new Map;_documentVersions=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 diagnosticMode(){return this._diagnosticMode}setDiagnosticMode(e){this._diagnosticMode=e}get timeoutMs(){return this._timeoutMs}supportsCommand(e){let n=this._serverCapabilities?.executeCommandProvider;return Array.isArray(n?.commands)&&n.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=f(this._command[0]),n=we.parse(this.rootUri).fsPath,r=Ye(e,this._args,{stdio:["pipe","pipe","pipe"],cwd:n,env:le({command:this._command,env:this._env},n,process.env)});this._process=r;let s=et(r);r.stdin?.on("error",()=>{}),r.stdout?.on("error",()=>{}),r.stderr?.on("error",()=>{}),r.on("error",i=>{("code"in i?i.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,i),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null}),r.on("exit",(i,c)=>{!this._disposed&&i!==0&&i!==null&&(this._crashed=!0),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1}),await s,this._connection=Je(new Qe(f(r.stdout)),new Ze(f(r.stdin))),this._connection.onError(i=>{console.error(`[lsp] ${this.serverId}: connection error:`,i)}),this._connection.listen(),this._connection.onNotification((i,...c)=>{if(i==="textDocument/publishDiagnostics"){let l=c[0];l&&typeof l.uri=="string"&&Array.isArray(l.diagnostics)&&this._documentVersions.has(l.uri)&&(l.version===void 0||l.version===this.documentVersion(l.uri))&&this._diagnosticPublications.set(l.uri,{diagnostics:l.diagnostics,...typeof l.version=="number"&&{version:l.version}})}for(let l of this._handlers.get(i)??[])l(c[0])});let o=await Le(this._connection.sendRequest("initialize",{processId:process.pid,rootUri:this.rootUri,capabilities:{workspace:{applyEdit:!1,symbol:{dynamicRegistration:!1}},textDocument:{synchronization:{didOpen:!0,didChange:!0,didClose:!0},publishDiagnostics:{relatedInformation:!0},documentSymbol:{hierarchicalDocumentSymbolSupport:!0},foldingRange:{lineFoldingOnly:!0}}},initializationOptions:this._initOptions}),this._timeoutMs,`[lsp] ${this.serverId}: initialize timed out`);this._connection.sendNotification("initialized",{capabilities:o.capabilities}),this._settings!==void 0&&this._connection.sendNotification("workspace/didChangeConfiguration",{settings:this._settings}),this._initialized=!0,this._serverCapabilities=o.capabilities}touch(){}async restart(){this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1,this._crashed=!1,this._disposed=!1,this._documentVersions.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null,await this.start()}async sendRequest(e,n,r){if(this._assertReady(),r?.throwIfAborted(),!r)return f(this._connection).sendRequest(e,n);let s=new Xe,o;try{let i=f(this._connection).sendRequest(e,n,s.token);return await Promise.race([i,new Promise((c,l)=>{o=a(()=>{s.cancel(),l(r.reason)},"onAbort"),r.addEventListener("abort",o,{once:!0})})])}finally{o&&r.removeEventListener("abort",o),s.dispose()}}sendNotification(e,n){this._assertReady(),f(this._connection).sendNotification(e,n)}onNotification(e,n){let r=this._handlers.get(e)??[];return r.push(n),this._handlers.set(e,r),()=>{let s=r.indexOf(n);s!==-1&&r.splice(s,1)}}toUri(e){return e.startsWith("file://")?e:we.file(e).toString()}openDocument(e,n,r,s=1){let o=this._documentVersions.get(e);if(o!==void 0){this.changeDocument(e,n,Math.max(s,o+1));return}this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:r,version:s,text:n}}),this._documentVersions.set(e,s)}syncDocument(e,n,r){let s=this._documentVersions.get(e);if(s===void 0){this.openDocument(e,n,r);return}this.changeDocument(e,n,s+1)}changeDocument(e,n,r){let s=this._documentVersions.get(e),o=Math.max(r,(s??0)+1);this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didChange",{textDocument:{uri:e,version:o},contentChanges:[{text:n}]}),this._documentVersions.set(e,o)}closeDocument(e){this.sendNotification("textDocument/didClose",{textDocument:{uri:e}}),this._documentVersions.delete(e),this._diagnosticPublications.delete(e)}async shutdown(){if(!this._disposed){if(this._disposed=!0,this._connection&&this._initialized)try{await Le(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._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 et(t){return new Promise((e,n)=>{let r=a(()=>{t.off("spawn",s),t.off("error",o)},"cleanup"),s=a(()=>{r(),e()},"onSpawn"),o=a(i=>{r(),n(i)},"onError");t.once("spawn",s),t.once("error",o)})}a(et,"waitForSpawn");function Le(t,e,n){return new Promise((r,s)=>{let o=setTimeout(()=>{s(new Error(n))},e);t.then(i=>{clearTimeout(o),r(i)}).catch(i=>{clearTimeout(o),s(i instanceof Error?i:new Error(String(i)))})})}a(Le,"withTimeout");import{readFile as Re}from"node:fs/promises";import{URI as Ce}from"vscode-uri";var x={Error:1,Warning:2,Information:3,Hint:4};var Se={command:"typescript.tsserverRequest",async request(t,e,n){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async s=>{let o=await t.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[s,{file:e,includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},n);if(!O(o)||o.success!==!0||!Array.isArray(o.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${s}`);return o.body.map(tt)}))).flat()}};function j(t){return t.supportsCommand(Se.command)?Se:void 0}a(j,"completedDiagnosticAdapter");function tt(t){if(!O(t)||typeof t.message!="string"||typeof t.code!="number"&&typeof t.code!="string"||!O(t.startLocation)||!Number.isInteger(t.startLocation.line)||!Number.isInteger(t.startLocation.offset)||Number(t.startLocation.line)<1||Number(t.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(t.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(t.code),message:t.message,line:Number(t.startLocation.line),column:Number(t.startLocation.offset),severity:t.category==="error"?"error":t.category==="warning"?"warning":t.category==="suggestion"?"hint":"info"}}a(tt,"convertTypeScriptDiagnostic");function O(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}a(O,"isRecord");async function I(t,e,n,r={}){let s=new AbortController,o=AbortSignal.any([s.signal,...r.signal?[r.signal]:[]]),i=setTimeout(()=>s.abort(new Error(`[lsp] ${t.serverId}: diagnostics timed out for ${e}`)),t.timeoutMs);try{return await nt(t,e,n,r.content,o)}finally{clearTimeout(i)}}a(I,"requestDiagnostics");async function nt(t,e,n,r,s){if(s.throwIfAborted(),t.diagnosticMode!=="push"){let l=t.documentVersion(e);try{let p=await t.sendRequest("textDocument/diagnostic",{textDocument:{uri:e}},s);if(p.kind!=="full"||!Array.isArray(p.items))throw new Error("Invalid full diagnostic report");if(t.documentVersion(e)!==l)throw new Error("Document changed during diagnostic request");return t.setDiagnosticMode("pull"),_e(p.items,!1,!0)}catch(p){if(!rt(p))throw p;t.setDiagnosticMode("push")}}let o=j(t);if(o){t.documentVersion(e)===void 0&&t.syncDocument(e,r??await Re(Ce.parse(e).fsPath,"utf8"),n??"plaintext");let l=t.documentVersion(e),p=await o.request(t,e,s);if(s.throwIfAborted(),t.documentVersion(e)!==l)throw new Error("Document changed during diagnostic request");return{diagnostics:p,syntaxErrors:[],otherDiagnostics:p,unversioned:!1,complete:!0}}s.throwIfAborted();let i=t.documentVersion(e)!==void 0,c=i?void 0:r??await Re(Ce.parse(e).fsPath,"utf8");s.throwIfAborted(),t.beginDiagnosticRequest(e);try{return await new Promise((l,p)=>{let d=t.documentVersion(e)??1,m=a(b=>{let v=b;v.uri!==e||!Array.isArray(v.diagnostics)||v.version!==void 0&&v.version!==d||t.documentVersion(e)===d&&(u(),l(_e(v.diagnostics,v.version===void 0)))},"receive"),h=t.onNotification("textDocument/publishDiagnostics",m),y=a(()=>{u(),p(s.reason)},"onAbort");function u(){h(),s.removeEventListener("abort",y)}a(u,"cleanup"),s.addEventListener("abort",y,{once:!0});try{i||t.syncDocument(e,c??"",n??"plaintext");let b=t.diagnosticPublication(e);b&&m({uri:e,...b})}catch(b){u(),p(b)}})}finally{t.endDiagnosticRequest(e)}}a(nt,"requestCurrentDiagnostics");function q(t){return{code:String(t.code??"LSP"),message:t.message,line:t.range.start.line+1,column:t.range.start.character+1,severity:t.severity===x.Warning?"warning":t.severity===x.Information?"info":t.severity===x.Hint?"hint":"error"}}a(q,"toDiagnostic");function _e(t,e,n=!1){let r=t.map(q);return{diagnostics:r,syntaxErrors:[],otherDiagnostics:r,unversioned:e,complete:n}}a(_e,"classify");function rt(t){return t!==null&&typeof t=="object"&&"code"in t&&t.code===-32601}a(rt,"isMethodNotFound");var st={1:"File",2:"Module",3:"Namespace",4:"Package",5:"Class",6:"Method",7:"Property",8:"Field",9:"Constructor",10:"Enum",11:"Interface",12:"Function",13:"Variable",14:"Constant",15:"String",16:"Number",17:"Boolean",18:"Array",19:"Object",20:"Key",21:"Null",22:"EnumMember",23:"Struct",24:"Event",25:"Operator",26:"TypeParameter"};function w(t){return st[t]??`SymbolKind(${t})`}a(w,"symbolKindName");async function V(t,e){return await t.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}})??[]}a(V,"requestDocumentSymbols");async function N(t,e,n=100){return(await t.sendRequest("workspace/symbol",{query:e})??[]).slice(0,n)}a(N,"requestWorkspaceSymbols");import at from"node:path";import{URI as ct}from"vscode-uri";import{readdir as ot}from"node:fs/promises";import A from"node:path";import{URI as Pe}from"vscode-uri";var C=class t{constructor(e){this._registry=e}static{a(this,"LspManager")}_clients=new Map;_clientStarts=new Map;_openDocs=new Set;_pushUnsubscribers=new Map;_pushHandlers=new Set;_pushFingerprints=new Map;_disposed=!1;static _instance=null;static getInstance(){if(!t._instance)throw new Error("[lsp] LspManager not initialized");return t._instance}static getInstanceOrNull(){return t._instance}static init(e){let n=t._instance;return n?._disposed?(n._registry=e,n._disposed=!1,n):(t._instance=new t(e),t._instance)}static async resetForTest(){t._instance&&(await t._instance.shutdownAll(),t._instance=null)}get clientCount(){return this._clients.size}onPushDiagnostics(e){return this._pushHandlers.add(e),()=>this._pushHandlers.delete(e)}async getOrStart(e,n,r){if(this._disposed)return null;let s=this._registry.resolve(e),o=r==="symbols"?s[0]:s.find(m=>m.config.capabilities.includes(r));if(!o)return null;let i=Pe.file(n).toString(),c=`${o.serverId}:${i}`,l=this._clientStarts.get(c);if(l)return l;let p=this._clients.get(c);if(p?.ready)return p;let d=this._startClient(c,i,o,p);this._clientStarts.set(c,d);try{return await d}finally{this._clientStarts.get(c)===d&&this._clientStarts.delete(c)}}async _startClient(e,n,r,s){let o=s??new R({serverId:r.serverId,rootUri:n,command:r.config.command,...r.config.env&&{env:r.config.env},...r.config.initializationOptions&&{initOptions:r.config.initializationOptions},...r.config.settings&&{settings:r.config.settings},...r.config.timeoutMs&&{timeoutMs:r.config.timeoutMs}});try{s?await s.restart():await o.start()}catch(i){throw await o.shutdown().catch(()=>{}),i}if(this._disposed)throw await o.shutdown(),new Error(`[lsp] ${r.serverId}: manager disposed during startup`);return this._clients.set(e,o),this._subscribeToPushDiagnostics(e,o),o}async getWorkspaceClients(e,n="symbols"){let r=new Set;for(let s of this._registry.knownExtensions)try{let o=await this.getOrStart(s,e,n);o&&r.add(o)}catch{}return[...r]}async prepareWorkspaceSymbols(e){let n=await this.getWorkspaceClients(e),r=new Set(this._registry.knownExtensions),s=new Set([".git",".cache","node_modules","dist","build"]),o=a(async i=>{if(r.size===0)return;let c;try{c=await ot(i,{withFileTypes:!0})}catch{return}for(let l of c){if(r.size===0)return;if(l.isDirectory()){s.has(l.name)||await o(A.join(i,l.name));continue}if(!l.isFile())continue;let p=A.extname(l.name).toLowerCase();if(!r.has(p))continue;let d=A.join(i,l.name);await this.openFile(d,e,"symbols").catch(()=>null)&&r.delete(p)}},"visit");return await o(e),n}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,n,r="diagnostics"){let s=e.slice(e.lastIndexOf(".")).toLowerCase(),o=A.resolve(n,e),i=await this.getOrStart(s,n,r);if(!i)return null;let c=i.toUri(o),p=this._registry.resolve(s)[0]?.languageId??"plaintext";try{let{readFile:d}=await import("node:fs/promises"),m=await d(o,"utf8");i.openDocument(c,m,p),this._openDocs.add(c)}catch{}return{client:i,uri:c,languageId:p}}_subscribeToPushDiagnostics(e,n){if(this._pushUnsubscribers.has(e))return;let r=n.onNotification("textDocument/publishDiagnostics",s=>{let o=it(s);if(!o||n.hasActiveDiagnosticRequest(o.uri))return;let i=n.documentVersion(o.uri);if(o.version!==void 0&&i!==void 0&&o.version<i)return;let c=`${e}:${o.uri}`,l=o.diagnostics.map(q),p=JSON.stringify([o.version,i,l]);if(this._pushFingerprints.get(c)===p)return;this._pushFingerprints.set(c,p);let d={cwd:Pe.parse(n.rootUri).fsPath,serverId:n.serverId,uri:o.uri,diagnostics:l,...o.version!==void 0&&{version:o.version}};for(let m of this._pushHandlers)m(d)});this._pushUnsubscribers.set(e,r)}async shutdownAll(){this._disposed=!0,await Promise.allSettled(this._clientStarts.values());let e=[...this._clients.values()];await Promise.all(e.map(n=>n.shutdown()));for(let n of this._pushUnsubscribers.values())n();this._pushUnsubscribers.clear(),this._clientStarts.clear(),this._pushFingerprints.clear(),this._pushHandlers.clear(),this._clients.clear()}dispose(){this.shutdownAll()}};function it(t){if(t===null||typeof t!="object")return;let e=t;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}a(it,"parsePushNotification");async function E(t,e,n){return await t.sendRequest("textDocument/references",{textDocument:{uri:e},position:n,context:{includeDeclaration:!0}})??[]}a(E,"requestReferences");async function F(t,e,n){let r=await t.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:n}),s=r?.[0];if(!s)return{items:[],incoming:[],outgoing:[]};let[o,i]=await Promise.all([t.sendRequest("callHierarchy/incomingCalls",{item:s}).catch(()=>[]),t.sendRequest("callHierarchy/outgoingCalls",{item:s}).catch(()=>[])]);return{items:r,incoming:o??[],outgoing:i??[]}}a(F,"requestCallHierarchy");function De(t){try{return ct.parse(t).fsPath}catch{return t.startsWith("file://")?decodeURIComponent(t.slice(7)):t}}a(De,"uriToFilePath");function ke(t,e,n,r,s){let o=De(n),i=at.relative(t,o);return{filePath:i.startsWith("..")?o:i,lineNumber:r+1,column:s+1,kind:String(e.kind),name:e.name}}a(ke,"toHit");async function H(t,e,n,r){if(r?.aborted)throw new Error("Operation aborted");let s=C.getInstance(),o=await s.prepareWorkspaceSymbols(e),i=[];for(let p of o){if(r?.aborted)throw new Error("Operation aborted");try{i.push(...await N(p,t,n))}catch{}}let c=new Set,l=[];for(let p of i){if(r?.aborted)throw new Error("Operation aborted");if(l.length>=n)break;let d=p.location,m=ke(e,p,d.uri,d.range.start.line,d.range.start.character),h=`${m.filePath}:${m.lineNumber}:${m.column}`;if(c.has(h)||(c.add(h),l.push(m)),l.length>=n)break;let y=De(d.uri),u=await s.openFile(y,e,"symbols").catch(()=>null);if(!u)continue;let b=await E(u.client,u.uri,d.range.start).catch(()=>[]);for(let v of b){let M=ke(e,p,v.uri,v.range.start.line,v.range.start.character),Z=`${M.filePath}:${M.lineNumber}:${M.column}`;if(c.has(Z)||(c.add(Z),l.push(M)),l.length>=n)break}}return l}a(H,"searchSymbols");import{readFile as lt}from"node:fs/promises";import P from"node:path";import{fileURLToPath as pt}from"node:url";var dt={failureLabel:"SYMBOL_READ_FAILED",emptyReason:"no symbol source was produced."},z=10,W=5,k=10;async function B(t,e,n,r,s){_(s);let o=await X(t,e,r),i=J(o.symbols,n,o.displayPath),c=await yt(o.filePath);_(s);let l=i.range.start.line+1,p=Math.min(i.range.end.line+1,c.lines.length),d=c.lines.slice(Math.max(0,l-1),Math.max(0,p)).map((h,y)=>{let u=l+y;return ne({content:h,sourceLine:{source:o.filePath,lineNumber:u,content:h}})}),m={path:o.displayPath,heading:`symbol: ${S(i.selector)}`,details:[`defined in: ${o.displayPath}:${l}-${p} (${w(i.kind)})`],startLine:l,endLine:p,totalLines:c.lines.length,renderedLines:d};return re([m],dt)}a(B,"readLspSymbolBody");async function K(t,e,n,r,s){_(s);let o=await X(t,e,r),i=J(o.symbols,n,o.displayPath),c=await je(o,i,s),l=new T(r);return await ut(o,i,c,l)}a(K,"readLspSymbolGraph");async function Y(t,e,n,r){_(r);let s=await X(t,e,n),o=new T(n),i=[`## file graph: ${s.displayPath}`,`Top-level declarations: ${s.symbols.length}`];for(let c of s.symbols){_(r);let l=await je(s,c,r);i.push("",...await ht(s,c,l,o))}return i.join(`
2
- `)}a(Y,"readLspFileGraph");function J(t,e,n){if(e.length===0)throw new TypeError("A symbol selector must contain at least one segment.");if(e.length===1){let o=$e(t,f(e[0]));if(o.length===1)return f(o[0]);throw o.length>1?new Error(`Symbol selector "${S(e)}" is ambiguous in ${n}; use parent/child.`):xe(e,n)}let r=t,s;for(let o of e){let i=r.filter(c=>c.name===o);if(i.length===0)throw xe(e,n);if(i.length>1)throw new Error(`Symbol selector "${S(e)}" is ambiguous at "${o}" in ${n}.`);s=f(i[0]),r=s.children}return f(s)}a(J,"resolveLspCodeSymbol");async function X(t,e,n){let r=P.isAbsolute(e)?P.normalize(e):P.resolve(n,e),s=await t.openFile(r,n,"symbols");if(!s)throw new Error(`No LSP server with symbol support is configured for ${G(r,n)}.`);let o=await V(s.client,s.uri),i=Ee(o).sort(Me);return{client:s.client,uri:s.uri,filePath:r,displayPath:G(r,n),symbols:i}}a(X,"openCodeDocument");function Ee(t,e=[]){return t.flatMap(n=>{let r=n.selectionRange??n.range;if(!r)return[];let s=n.range??r,o=[...e,n.name];return[{name:n.name,kind:n.kind,range:s,selectionRange:r,selector:o,children:Ee(n.children??[],o).sort(Me)}]})}a(Ee,"normalizeDocumentSymbols");function Me(t,e){return t.range.start.line-e.range.start.line||t.range.start.character-e.range.start.character||t.name.localeCompare(e.name)}a(Me,"compareSymbols");function $e(t,e){return t.flatMap(n=>[...n.name===e?[n]:[],...$e(n.children,e)])}a($e,"collectNamedSymbols");function xe(t,e){return new Error(`Symbol "${S(t)}" was not found in ${e}.`)}a(xe,"symbolNotFound");async function je(t,e,n){let r=e.selectionRange.start,[s,o]=await Promise.all([Ie(E(t.client,t.uri,r),[],n),Ie(F(t.client,t.uri,r),{items:[],incoming:[],outgoing:[]},n)]);return _(n),{references:s,calls:o}}a(je,"queryRelations");async function Ie(t,e,n){try{let r=await t;return _(n),r}catch(r){if(n?.aborted===!0)throw Te(n,r);return e}}a(Ie,"optionalRequest");async function ut(t,e,n,r){let s=S(e.selector),o=await r.line(t.uri,e.selectionRange.start.line+1);return[`## graph: ${s}`,`Definition: ${t.displayPath} ${o} (${w(e.kind)})`,`Source: ${D("graph",t.displayPath,e.selector)}`,"",...await gt(n.references,r),"",...await mt(n.calls.incoming,r),"",...await ft(n.calls.outgoing,r)].join(`
3
- `)}a(ut,"formatSymbolGraph");async function gt(t,e){let n=Ae(t),r=[`References: ${t.length} in ${n.length} file(s)`];for(let[s,o]of n.slice(0,z)){r.push(`- ${e.display(s)} (${o.length})`);for(let i of o.slice(0,W))r.push(` - ${await e.line(s,i.range.start.line+1)}`);o.length>W&&r.push(` - ... ${o.length-W} more`)}return n.length>z&&r.push(`- ... ${n.length-z} more file(s)`),r}a(gt,"formatReferences");async function mt(t,e){let n=[`Incoming calls: ${t.length}`];for(let r of t.slice(0,k)){let s=r.fromRanges[0]?.start.line??r.from.selectionRange.start.line,o=await e.line(r.from.uri,s+1);n.push(`- ${w(r.from.kind)} ${r.from.name} \u2014 ${e.display(r.from.uri)} ${o}`)}return t.length>k&&n.push(`- ... ${t.length-k} more`),n}a(mt,"formatIncomingCalls");async function ft(t,e){let n=[`Outgoing calls: ${t.length}`];for(let r of t.slice(0,k)){let s=await e.line(r.to.uri,r.to.selectionRange.start.line+1);n.push(`- ${w(r.to.kind)} ${r.to.name} \u2014 ${e.display(r.to.uri)} ${s}`)}return t.length>k&&n.push(`- ... ${t.length-k} more`),n}a(ft,"formatOutgoingCalls");async function ht(t,e,n,r){let s=w(e.kind),o=await r.line(t.uri,e.selectionRange.start.line+1),i=Ae(n.references).map(([d,m])=>`${r.display(d)} (${m.length})`),c=n.calls.incoming.map(d=>`${d.from.name} (${r.display(d.from.uri)})`),l=n.calls.outgoing.map(d=>`${d.to.name} (${r.display(d.to.uri)})`),p=[`### ${s} ${e.name}`,`Selector: ${S(e.selector)}`,`Definition: ${o}`,`Used by: ${U(i)}`,`Incoming calls: ${U(c)}`,`Outgoing calls: ${U(l)}`];if(e.children.length>0){p.push("Members:");for(let d of e.children){let m=D("graph",t.displayPath,d.selector);p.push(`- ${w(d.kind)} ${d.name} \u2014 ${m}`)}}return p}a(ht,"formatFileGraphSymbol");function U(t,e=5){if(t.length===0)return"none";let n=t.slice(0,e).join(", ");return t.length>e?`${n}, ... ${t.length-e} more`:n}a(U,"summarize");function Ae(t){let e=new Map;for(let n of t){let r=e.get(n.uri)??[];r.push(n),e.set(n.uri,r)}return[...e].map(([n,r])=>[n,r.sort((s,o)=>s.range.start.line-o.range.start.line||s.range.start.character-o.range.start.character)]).sort(([n],[r])=>n.localeCompare(r))}a(Ae,"groupLocationsByUri");async function yt(t){let e=await lt(t);if(e.byteLength>256*1024)throw new Error(`File exceeds the 262144-byte code-view limit: ${t}`);if(e.includes(0))throw new Error(`File appears to be binary and cannot be read as text: ${t}`);let n=e.toString("utf8").replaceAll(`\r
4
- `,`
5
- `),r=n.endsWith(`
6
- `)?n.slice(0,-1):n,s=r.length===0?[]:r.split(`
7
- `);return{content:n,lines:s}}a(yt,"readTextFile");var T=class{static{a(this,"LocationPresenter")}#e;constructor(e){this.#e=e}display(e){return G(vt(e),this.#e)}line(e,n){return Promise.resolve(String(n))}};function vt(t){if(!t.startsWith("file://"))return t;try{return pt(t)}catch{return decodeURIComponent(t.slice(7))}}a(vt,"filePathFromUri");function G(t,e){let n=P.relative(e,t);return n.length===0||n.startsWith("..")||P.isAbsolute(n)?t:n.replaceAll(P.sep,"/")}a(G,"displayFilePath");function _(t){if(t?.aborted===!0)throw Te(t)}a(_,"throwIfAborted");function Te(t,e){if(t.reason instanceof Error)return t.reason;if(e instanceof Error)return e;let n=new Error("The operation was aborted");return n.name="AbortError",n}a(Te,"abortReason");function Q(t){let e=null;return{kind:"compiler",name:"lsp",priority:100,extensions:["*"],detect:a(()=>Promise.resolve(!0),"detect"),async compile({filePath:n},r){let s=await bt(n,r,t);if(!s)return wt();let{client:o,diagnostics:i,syntaxErrors:c,otherDiagnostics:l}=s;return e=o,{ok:!i.some(p=>p.severity==="error"),diagnostics:i,syntaxErrors:c,otherDiagnostics:l}},async restart(){e&&(await e.restart(),e=null)}}}a(Q,"createLspCompiler");async function bt(t,e,n){let r=await n.openFile(t,e.cwd);if(!r)return null;let s=await I(r.client,r.uri,r.languageId);return{client:r.client,...s}}a(bt,"openAndDiagnose");function wt(){return{ok:!0,diagnostics:[],syntaxErrors:[],otherDiagnostics:[]}}a(wt,"skipOk");function Oe(t){let e=new Map,n=new Map;for(let[r,s]of Object.entries(t))for(let[o,i]of Object.entries(s.languages))for(let c of i.extensions){let l=c.toLowerCase(),p=e.get(l);if(p!==void 0&&p!==o)throw new Error(`[lsp] extension conflict: "${l}" claimed by "${p}" and "${o}"`);e.set(l,o);let d=n.get(l)??[];d.push(r),n.set(l,d)}return{extToLanguageId:e,extToServerIds:n}}a(Oe,"buildLanguageLookup");var L=class t{static{a(this,"LspServerRegistry")}_servers;_entries;_entriesById;_lookup;constructor(e,n){this._entries=e,this._entriesById=new Map(e.map(s=>[s.id,s]));let r=e.filter(s=>s.layer!=="built-in"||n.has(s.id));this._servers=Object.fromEntries(r.map(s=>[s.id,s.config])),this._lookup=Oe(this._servers)}static async fromPackageDir(e,n={}){let r=await ce(e,"lsp-servers",i=>Lt(i).servers,n),s=n.environment??process.env,o=await Promise.all(r.entries.filter(i=>i.layer==="built-in").map(async i=>({id:i.id,available:await $(i.config,e,s)})));return new t(r.entries,new Set(o.filter(i=>i.available).map(i=>i.id)))}static fromConfig(e){return new t(Object.entries(e.servers).map(([n,r])=>({id:n,config:r,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(e){let n=e.startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`,r=this._lookup.extToServerIds.get(n);if(!r||r.length===0)return[];let s=this._lookup.extToLanguageId.get(n);return s?r.map(o=>{let i=f(this._entriesById.get(o));return{serverId:o,config:i.config,languageId:s,layer:i.layer,sourcePath:i.sourcePath}}):[]}get servers(){return this._servers}get entries(){return this._entries}get knownExtensions(){return new Set(this._lookup.extToLanguageId.keys())}languageId(e){let n=e.startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`;return this._lookup.extToLanguageId.get(n)??e.slice(1)}};function Lt(t){if(typeof t!="object"||t===null||Array.isArray(t))throw new Error("LSP config must be an object");let e=t;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[n,r]of Object.entries(e.servers)){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`LSP server ${n} must be an object`);let s=r;if(!Array.isArray(s.command)||s.command.length===0||s.command.some(o=>typeof o!="string"||o.length===0))throw new Error(`LSP server ${n}.command must be a non-empty string array`);if(s.transport!==void 0&&s.transport!=="stdio")throw new Error(`LSP server ${n} only supports stdio transport`);if(!Array.isArray(s.rootMarkers)||s.rootMarkers.some(o=>typeof o!="string"))throw new Error(`LSP server ${n}.rootMarkers must be a string array`);if(typeof s.languages!="object"||s.languages===null||Array.isArray(s.languages))throw new Error(`LSP server ${n}.languages must be an object`);for(let[o,i]of Object.entries(s.languages)){let c=typeof i=="object"&&i!==null&&!Array.isArray(i)?i.extensions:void 0;if(!Array.isArray(c)||c.length===0||c.some(l=>typeof l!="string"))throw new Error(`LSP server ${n} language ${o} requires extensions`)}if(!Array.isArray(s.capabilities))throw new TypeError(`LSP server ${n}.capabilities must be an array`)}return t}a(Lt,"parseLspConfig");function qe(t){return Ne("symbol","lsp-symbol",t,async e=>await B(e.manager,e.filePath,f(e.selector),e.cwd,e.signal))}a(qe,"createLspSymbolResolver");function Ve(t){return Ne("graph","lsp-graph",t,async e=>e.selector===void 0?await Y(e.manager,e.filePath,e.cwd,e.signal):await K(e.manager,e.filePath,e.selector,e.cwd,e.signal))}a(Ve,"createLspGraphResolver");function Ne(t,e,n,r){return{id:e,tryResolve(s,o){return Promise.resolve(St(s,o,t,n,r))}}}a(Ne,"createCodeViewResolver");function St(t,e,n,r,s){let o;try{o=ee(t,n)}catch(l){return{kind:"failed",error:l}}if(o===void 0)return{kind:"not-handled"};let i;try{i=te(o.path,e.cwd)}catch(l){return{kind:"failed",error:l}}return{kind:"resolved",resource:{source:D(n,i,o.selector),async read(l){let p=await r(e.cwd),d=await s({manager:p,filePath:i,cwd:e.cwd,...Rt(o.selector),...Ct(l.signal)});return[typeof d=="string"?{type:"text",text:d}:d]}}}}a(St,"resolveCodeViewSource");function Rt(t){return t===void 0?{}:{selector:t}}a(Rt,"optionalSelector");function Ct(t){return t===void 0?{}:{signal:t}}a(Ct,"optionalSignal");import _t from"node:path";function He(t){return{id:"lsp",async diagnose(e,n){let r=await t(n.cwd);n.signal.throwIfAborted();let s=_t.extname(e).toLowerCase(),o=await r.getOrStart(s,n.cwd,"diagnostics");if(n.signal.throwIfAborted(),!o)return{status:"unavailable",diagnostics:[],reason:"No language server configured for this file"};let i=o.toUri(e),c=r.languageId(s);o.syncDocument(i,n.content,c);let l=o.documentVersion(i),p={active:!0,queued:!1},d=a(()=>!n.signal.aborted&&o.documentVersion(i)===l,"current"),m=a(()=>I(o,i,c,{signal:n.signal,content:n.content}),"request"),h=a(async()=>{if(p.queued=!0,!p.active){p.active=!0;try{for(;p.queued&&d();){p.queued=!1;let u=await m();d()&&n.publish(Fe(u))}}catch(u){d()&&n.publish({status:"unavailable",diagnostics:[],reason:u instanceof Error?u.message:String(u)})}finally{p.active=!1}}},"refresh"),y=r.onPushDiagnostics(u=>{!d()||u.uri!==i||u.serverId!==o.serverId||u.cwd!==n.cwd||u.version!==void 0&&u.version!==l||(o.diagnosticMode==="pull"||j(o)?h():n.publish({status:"snapshot",diagnostics:u.diagnostics,reason:ze(u.version===void 0)}))});n.signal.addEventListener("abort",y,{once:!0});try{let u=await m();return l=o.documentVersion(i),Fe(u)}catch(u){throw p.queued=!1,y(),n.signal.removeEventListener("abort",y),u}finally{p.active=!1,p.queued&&d()&&queueMicrotask(()=>{h()})}}}}a(He,"createLspDiagnosticSource");function ze(t){return`Latest push snapshot; completion is unknown${t?"; language server omitted the document version":""}`}a(ze,"snapshotReason");function Fe(t){return t.complete?{status:"ready",diagnostics:t.diagnostics}:{status:"snapshot",diagnostics:t.diagnostics,reason:ze(t.unversioned)}}a(Fe,"toReport");import Ue from"node:path";import{URI as Pt}from"vscode-uri";var We=[g("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/"),g("typescript-language-server",["javascript","typescript"],["typescript-language-server"],["tsconfig.json","jsconfig.json","package.json"],{javascript:[".js",".jsx",".mjs",".cjs"],typescript:[".ts",".tsx",".mts",".cts"]},["typescript-language-server","--stdio"],"https://github.com/typescript-language-server/typescript-language-server",["typescript-language-server"]),g("basedpyright",["python"],["basedpyright-langserver","pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),g("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),g("rust-analyzer",["rust"],["rust-analyzer"],["Cargo.toml","rust-project.json"],{rust:[".rs"]},["rust-analyzer"],"https://rust-analyzer.github.io/"),g("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),g("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),g("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"),g("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),g("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),g("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),g("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),g("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),g("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"),g("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"),g("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"),g("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),g("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),g("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),g("cmake-language-server",["cmake"],["cmake-language-server"],["CMakeLists.txt"],{cmake:[".cmake"]},["cmake-language-server"],"https://github.com/regen100/cmake-language-server"),g("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"),g("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),g("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),g("docker-langserver",["dockerfile"],["docker-langserver"],["Dockerfile"],{dockerfile:[".dockerfile"]},["docker-langserver","--stdio"],"https://github.com/rcjsuen/dockerfile-language-server-nodejs")];function g(t,e,n,r,s,o,i,c){return{id:t,name:t,kind:"lsp",languages:e,executables:n,configFiles:r,documentation:i,...c&&{dependencies:c},lsp:{command:o,rootMarkers:r,languageIds:s}}}a(g,"recipe");var Ge={protocol:pe,apiVersion:1,id:"lsp",setup(t){for(let e of We)t.addToolRecipe(e);t.addSetupCheck({id:"effective-config",inspect:kt}),t.addCheck({id:"config",title:"LSP",async run(e){try{let n=await L.fromPackageDir(e.cwd,{environment:e.env}),r=Dt(n,e.files);return r.length===0?[{status:"skip",message:"No language server matches the inspected project files"}]:await Promise.all(r.map(async s=>{let o=`${s.serverId} [${s.layer}] command ${JSON.stringify(s.config.command)}`,i=new R({serverId:s.serverId,rootUri:Pt.file(e.cwd).toString(),command:s.config.command,env:xt(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 i.start(),{status:"pass",message:`${o}: initialized`,detail:s.sourcePath}}catch(c){return{status:"fail",message:`${o}: ${c instanceof Error?c.message:String(c)}`,detail:s.sourcePath}}finally{await i.shutdown().catch(()=>{})}}))}catch(n){return[{status:"fail",message:n instanceof Error?n.message:String(n)}]}}})}};async function kt(t){try{let e=await L.fromPackageDir(t.cwd,{environment:t.env}),n=[],r=new Map;for(let[s,o]of t.detectedLanguages){let i=o.flatMap(c=>e.resolve(Ue.extname(c))).find(c=>c.languageId===s);i!==void 0&&(n.push({kind:"lsp",languageId:s,toolId:i.serverId}),await $(i.config,t.cwd,t.env)||r.set(i.serverId,{id:`lsp-${i.serverId}-unavailable`,message:`Configured language server ${i.serverId} cannot run ${JSON.stringify(i.config.command)}`}))}return{selections:n,actions:[...r.values()]}}catch(e){return{actions:[{id:"lsp-config-invalid",message:`Language server configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}a(kt,"inspectLspSetup");function Dt(t,e){let n=new Map;for(let r of e){let s=t.resolve(Ue.extname(r))[0];s!==void 0&&!n.has(s.serverId)&&n.set(s.serverId,s)}return[...n.values()]}a(Dt,"applicableServers");function xt(t,e){return Object.fromEntries(Object.entries({...t,...e}).filter(n=>n[1]!==void 0))}a(xt,"definedEnvironment");function Be(t){return{id:"symbols",async tryResolve(e,n){if(!e.query.startsWith("symbols:"))return{kind:"not-handled"};let r=e.query.slice(8).trim();if(r.length===0)return{kind:"failed",error:new Error("symbols: query must not be empty")};await t(n.cwd);let s=await H(r,n.cwd,e.limit??100,n.signal);return{kind:"resolved",payload:{query:r,hits:s}}},format(e){let{query:n,hits:r}=e;return{content:[{type:"text",text:r.length===0?"No symbols found.":r.map((o,i)=>`${String(i+1)}. ${o.filePath}:${String(o.lineNumber)}:${String(o.column)} ${o.kind} ${o.name}`).join(`
8
- `)}],details:{query:n,hits:r}}}}}a(Be,"createLspSearchResolver");var Ke=he({kind:"code-view",label:"LSP"});async function It(t){let e=new Map,n=!1,r=a(c=>{if(n)return Promise.reject(new Error("LSP session has ended"));let l=e.get(c);return l||(l=Et(c).then(p=>{if(n)throw new Error("LSP session has ended");return C.init(p)}),e.set(c,l)),l},"managerFor"),s={kind:"compiler",name:"pi-agent-ide-lsp",priority:200,extensions:["*"],detect:a(async c=>(await r(c.cwd),!0),"detect"),async compile(c,l){let p=await r(l.cwd);return Q(p).compile(c,l)}},o={protocol:oe,apiVersion:3,id:"lsp",setup(c){c.addTool(s),c.addDiagnosticSource(He(r))}};t.on("session_shutdown",async()=>{n=!0,await Promise.allSettled([...e.values()].map(async c=>(await c).shutdownAll())),e.clear()});let i={protocol:ge,apiVersion:me,id:"lsp",setup(c){c.addResolver({resolver:qe(r),renderResult:Ke}),c.addResolver({resolver:Ve(r),renderResult:Ke}),c.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler:se()}),c.describe("Provides `symbol:<path>#<selector>` for a symbol's implementation, `graph:<path>` for relationships of top-level declarations, and `graph:<path>#<selector>` for one symbol's relationships."),c.addPromptGuideline("You can use read with `symbol:<path>#<selector>` to inspect a known symbol's implementation without searching for it or reading the whole file."),c.addPromptGuideline("You can use read with `graph:<path>` to inspect each top-level declaration's definition, referencing files, and incoming and outgoing calls. Members are listed with selectors; their relationships are not expanded. You can append `#<selector>` to inspect one symbol's references and calls, including a nested method.")}};await Promise.all([ae(t,o),fe(t,i),ue(t,Ge),be(t,{protocol:ye,apiVersion:ve,id:"symbols",setup(c){c.addResolver({resolver:Be(r)}),c.describe("Use `symbols:<query>` to search workspace symbols and their references through configured language servers."),c.addPromptGuideline("You can use search with `symbols:<query>` to find workspace symbols and their references through configured language servers.")}})])}a(It,"registerLsp");async function Et(t){let e=process.env.PI_AGENT_IDE_CONFIG_DIR??t;return L.fromPackageDir(e)}a(Et,"loadRegistry");export{It as a};
@@ -1,2 +0,0 @@
1
- export * from "../../../dist/entry-20.js";
2
- export { default } from "../../../dist/entry-20.js";