pi-agent-ide 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +10 -4
  3. package/dist/chunk-22CLOM2D.js +1 -0
  4. package/dist/{chunk-LY6U5EAD.js → chunk-2527OQ4Y.js} +1 -1
  5. package/dist/chunk-3XJ3KDPZ.js +16 -0
  6. package/dist/chunk-5JELU6RV.js +7 -0
  7. package/dist/chunk-DDKHZZDO.js +5 -0
  8. package/dist/chunk-FEDVTZJG.js +1 -0
  9. package/dist/chunk-HSM6R7IB.js +27 -0
  10. package/dist/chunk-K5G4FDXD.js +1 -0
  11. package/dist/chunk-M5IVSCR2.js +1 -0
  12. package/dist/chunk-OYWIZII6.js +1 -0
  13. package/dist/{chunk-7ALCBKCW.js → chunk-PCZH7GOX.js} +11 -11
  14. package/dist/{chunk-DQXPQOF7.js → chunk-SQ7ZTGOP.js} +1 -1
  15. package/dist/entry-10.js +1 -1
  16. package/dist/entry-11.js +1 -1
  17. package/dist/entry-12.js +1 -1
  18. package/dist/entry-13.js +1 -1
  19. package/dist/entry-14.js +1 -1
  20. package/dist/entry-15.js +1 -1
  21. package/dist/entry-16.js +1 -0
  22. package/dist/entry-18.js +1 -1
  23. package/dist/entry-19.js +1 -1
  24. package/dist/entry-20.js +1 -1
  25. package/dist/entry-21.js +1 -1
  26. package/dist/entry-22.js +1 -2
  27. package/dist/entry-23.js +2 -1
  28. package/dist/entry-24.js +1 -1
  29. package/dist/entry-25.js +1 -1
  30. package/dist/entry-26.js +1 -1
  31. package/dist/entry-27.js +1 -12
  32. package/dist/entry-28.js +12 -1
  33. package/dist/entry-29.js +1 -1
  34. package/dist/entry-30.js +1 -1
  35. package/dist/entry-31.js +1 -1
  36. package/dist/entry-32.js +1 -4
  37. package/dist/entry-33.js +3 -8
  38. package/dist/entry-34.js +9 -1
  39. package/dist/entry-35.js +1 -1
  40. package/dist/entry-36.js +1 -1
  41. package/dist/entry-37.js +1 -1
  42. package/dist/entry-38.js +1 -1
  43. package/dist/entry-39.js +1 -1
  44. package/dist/entry-40.js +1 -1
  45. package/dist/entry-41.js +1 -18
  46. package/dist/entry-42.js +18 -1
  47. package/dist/entry-43.js +1 -1
  48. package/dist/entry-44.js +1 -1
  49. package/dist/entry-45.js +1 -1
  50. package/dist/entry-46.js +1 -7
  51. package/dist/entry-47.js +7 -11
  52. package/dist/entry-48.js +11 -1
  53. package/dist/entry-49.js +1 -1
  54. package/dist/entry-50.js +1 -1
  55. package/dist/entry-51.js +1 -1
  56. package/dist/entry-52.js +1 -1
  57. package/dist/entry-53.js +1 -1
  58. package/dist/entry-54.js +1 -1
  59. package/dist/entry-55.js +1 -1
  60. package/dist/entry-56.js +1 -0
  61. package/dist/entry-57.js +0 -1
  62. package/dist/entry-58.js +1 -0
  63. package/dist/entry-59.js +0 -1
  64. package/dist/entry-60.js +1 -1
  65. package/dist/entry-61.js +1 -1
  66. package/dist/entry-62.js +1 -1
  67. package/dist/entry-63.js +1 -1
  68. package/dist/entry-64.js +1 -1
  69. package/dist/entry-65.js +1 -0
  70. package/dist/entry-66.js +0 -1
  71. package/dist/entry-67.js +1 -0
  72. package/dist/entry-68.js +0 -1
  73. package/dist/entry-69.js +1 -1
  74. package/dist/entry-70.js +1 -1
  75. package/dist/entry-71.js +1 -203
  76. package/dist/entry-72.js +254 -25
  77. package/dist/entry-73.js +30 -2
  78. package/dist/entry-74.js +2 -1
  79. package/dist/entry-75.js +1 -1
  80. package/dist/entry-76.js +1 -3
  81. package/dist/entry-77.js +3 -3
  82. package/dist/entry-78.js +3 -1
  83. package/dist/entry-79.js +1 -1
  84. package/dist/entry-80.js +1 -1
  85. package/dist/entry-81.js +1 -0
  86. package/dist/pi-agent-ide.js +3 -3
  87. package/docs/configuration.md +3 -1
  88. package/docs/tools.md +12 -0
  89. package/node_modules/pi-agent-doctor/package.json +6 -6
  90. package/node_modules/pi-agent-doctor/runtime/entry-22.js +1 -0
  91. package/node_modules/pi-agent-filesystem/package.json +7 -7
  92. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  93. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  94. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  95. package/node_modules/pi-agent-filesystem-text/runtime/entry-26.js +2 -0
  96. package/node_modules/pi-agent-ide-ast/package.json +12 -11
  97. package/node_modules/pi-agent-ide-ast/runtime/entry-27.js +0 -1
  98. package/node_modules/pi-agent-ide-ast/runtime/entry-28.js +2 -0
  99. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +8 -6
  100. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  101. package/node_modules/pi-agent-ide-changes/runtime/entry-29.js +0 -1
  102. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  103. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  104. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  105. package/node_modules/pi-agent-ide-lint/src/command-linter.ts +3 -1
  106. package/node_modules/pi-agent-ide-lsp/package.json +10 -10
  107. package/node_modules/pi-agent-ide-lsp/runtime/entry-34.js +2 -0
  108. package/node_modules/pi-agent-image/package.json +3 -3
  109. package/node_modules/pi-agent-invariant/package.json +2 -2
  110. package/node_modules/pi-agent-pdf/package.json +3 -3
  111. package/node_modules/pi-agent-read/package.json +11 -11
  112. package/node_modules/pi-agent-read/runtime/entry-41.js +0 -1
  113. package/node_modules/pi-agent-read/runtime/entry-42.js +2 -0
  114. package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
  115. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +11 -6
  116. package/node_modules/pi-agent-resource/package.json +2 -2
  117. package/node_modules/pi-agent-search/package.json +7 -7
  118. package/node_modules/pi-agent-search/runtime/entry-46.js +0 -1
  119. package/node_modules/pi-agent-search-text/package.json +9 -9
  120. package/node_modules/pi-agent-search-text/runtime/entry-48.js +1 -0
  121. package/node_modules/pi-agent-text/package.json +3 -3
  122. package/node_modules/pi-agent-text/runtime/entry-50.js +1 -0
  123. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  124. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-51.js +2 -0
  125. package/node_modules/pi-agent-text-anchor-exact/index.ts +3 -3
  126. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  127. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-52.js +0 -1
  128. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-53.js +2 -0
  129. package/node_modules/pi-agent-text-anchor-exact/src/config.ts +2 -2
  130. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  131. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-54.js +0 -1
  132. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-55.js +2 -0
  133. package/node_modules/pi-agent-text-editor/package.json +25 -25
  134. package/node_modules/pi-agent-text-editor/runtime/entry-71.js +0 -1
  135. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +125 -3
  136. package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +1 -1
  137. package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +14 -0
  138. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +32 -3
  139. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +21 -19
  140. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +37 -0
  141. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +85 -34
  142. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +2 -3
  143. package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +589 -241
  144. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +5 -0
  145. package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +3 -3
  146. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +9 -1
  147. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +53 -0
  148. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +11 -41
  149. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +8 -18
  150. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +11 -41
  151. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -19
  152. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  153. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  154. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +2 -0
  155. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  156. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  157. package/node_modules/pi-agent-tool-ui/runtime/entry-76.js +1 -0
  158. package/node_modules/pi-agent-web/package.json +7 -7
  159. package/node_modules/pi-agent-web-html/package.json +3 -3
  160. package/node_modules/pi-agent-web-image/package.json +4 -4
  161. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  162. package/node_modules/pi-agent-web-text/package.json +4 -4
  163. package/node_modules/pi-agent-web-text/runtime/entry-81.js +2 -0
  164. package/package.json +43 -38
  165. package/src/api/path-identity.ts +15 -0
  166. package/src/composite/builtin-extensions.ts +7 -2
  167. package/src/composite/module-labels.ts +4 -0
  168. package/src/composite/module-settings.ts +34 -14
  169. package/src/composite/preferences.ts +46 -3
  170. package/src/composite/selection.ts +5 -1
  171. package/src/doctor/inventory.ts +7 -2
  172. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  173. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  174. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  175. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  176. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-26.js +2 -0
  177. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-23.js +2 -0
  178. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  179. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  180. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  181. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  182. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  183. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-81.js +2 -0
  184. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-77.js +2 -0
  185. package/src/extensions/pi-agent-read/package.json +11 -11
  186. package/src/extensions/pi-agent-read/runtime/entry-41.js +0 -1
  187. package/src/extensions/pi-agent-read/runtime/entry-42.js +2 -0
  188. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
  189. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +11 -6
  190. package/src/extensions/pi-agent-search/package.json +7 -7
  191. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
  192. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +1 -0
  193. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-49.js +1 -0
  194. package/src/extensions/pi-agent-search/runtime/entry-46.js +0 -1
  195. package/src/extensions/pi-agent-search/runtime/entry-47.js +2 -0
  196. package/src/extensions/pi-agent-text-editor/package.json +25 -25
  197. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  198. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-51.js +2 -0
  199. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +3 -3
  200. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  201. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-52.js +0 -1
  202. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-53.js +2 -0
  203. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/config.ts +2 -2
  204. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  205. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-54.js +0 -1
  206. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-55.js +2 -0
  207. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  208. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  209. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +2 -0
  210. package/src/extensions/pi-agent-text-editor/runtime/entry-71.js +0 -1
  211. package/src/extensions/pi-agent-text-editor/runtime/entry-72.js +2 -0
  212. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +125 -3
  213. package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +1 -1
  214. package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +14 -0
  215. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +32 -3
  216. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +21 -19
  217. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +37 -0
  218. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +85 -34
  219. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +2 -3
  220. package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +589 -241
  221. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +5 -0
  222. package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +3 -3
  223. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +9 -1
  224. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +53 -0
  225. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +11 -41
  226. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +8 -18
  227. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +11 -41
  228. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -19
  229. package/src/pi-agent-ide.ts +15 -2
  230. package/src/plugins/pi-agent-ide-ast/package.json +12 -11
  231. package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +0 -1
  232. package/src/plugins/pi-agent-ide-ast/runtime/entry-28.js +2 -0
  233. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +8 -6
  234. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  235. package/src/plugins/pi-agent-ide-changes/runtime/entry-29.js +0 -1
  236. package/src/plugins/pi-agent-ide-debugger/index.ts +2 -8
  237. package/src/plugins/pi-agent-ide-debugger/src/adapter-executables.ts +31 -0
  238. package/src/plugins/pi-agent-ide-debugger/src/breakpoint-view.ts +3 -1
  239. package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +24 -23
  240. package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +5 -2
  241. package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +55 -17
  242. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +55 -22
  243. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  244. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  245. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  246. package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +3 -1
  247. package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
  248. package/src/plugins/pi-agent-ide-lsp/runtime/entry-34.js +2 -0
  249. package/src/plugins/pi-agent-ide-processes/src/registry.ts +4 -0
  250. package/src/plugins/pi-agent-ide-processes/src/ui.ts +18 -9
  251. package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +1 -0
  252. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +1 -0
  253. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +2 -2
  254. package/src/plugins/pi-agent-ide-terminal/src/types.ts +1 -0
  255. package/src/plugins/pi-agent-ide-vision/index.ts +232 -0
  256. package/src/plugins/pi-agent-ide-vision/src/vision.ts +530 -0
  257. package/src/plugins/pi-agent-ide-vision/src/windows-display-capture.ps1 +30 -0
  258. package/src/plugins/pi-agent-ide-vision/src/windows-window-capture.ps1 +33 -0
  259. package/dist/chunk-5PLV4HLG.js +0 -1
  260. package/dist/chunk-G725MARR.js +0 -16
  261. package/dist/chunk-HKXDP2FD.js +0 -7
  262. package/dist/chunk-IRECDTJG.js +0 -27
  263. package/dist/chunk-J4RTW44E.js +0 -1
  264. package/dist/chunk-NZYDMBM6.js +0 -1
  265. package/dist/chunk-WGGIQ7IJ.js +0 -1
  266. package/dist/entry-17.js +0 -1
  267. package/node_modules/pi-agent-doctor/runtime/entry-17.js +0 -1
  268. package/node_modules/pi-agent-filesystem/runtime/entry-22.js +0 -2
  269. package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +0 -1
  270. package/node_modules/pi-agent-ide-changes/runtime/entry-28.js +0 -1
  271. package/node_modules/pi-agent-image/runtime/entry-34.js +0 -1
  272. package/node_modules/pi-agent-resource/runtime/entry-42.js +0 -1
  273. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-50.js +0 -2
  274. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
  275. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
  276. package/node_modules/pi-agent-text-editor/runtime/entry-55.js +0 -1
  277. package/node_modules/pi-agent-tool-call-interception/runtime/entry-74.js +0 -1
  278. package/node_modules/pi-agent-web/runtime/entry-76.js +0 -2
  279. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-23.js +0 -2
  280. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-22.js +0 -2
  281. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-77.js +0 -2
  282. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +0 -2
  283. package/src/extensions/pi-agent-read/runtime/entry-37.js +0 -1
  284. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-47.js +0 -2
  285. package/src/extensions/pi-agent-search/runtime/entry-43.js +0 -1
  286. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-50.js +0 -2
  287. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
  288. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
  289. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-72.js +0 -2
  290. package/src/extensions/pi-agent-text-editor/runtime/entry-55.js +0 -1
  291. package/src/plugins/pi-agent-ide-ast/runtime/entry-26.js +0 -1
  292. package/src/plugins/pi-agent-ide-changes/runtime/entry-28.js +0 -1
  293. /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-23.js +0 -0
  294. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-24.js +0 -0
  295. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-25.js +0 -0
  296. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-30.js +0 -0
  297. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-31.js +0 -0
  298. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-32.js +0 -0
  299. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-33.js +0 -0
  300. /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-35.js +0 -0
  301. /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-36.js +0 -0
  302. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-37.js +0 -0
  303. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-43.js +0 -0
  304. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-47.js +0 -0
  305. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-49.js +0 -0
  306. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-72.js +0 -0
  307. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-73.js +0 -0
  308. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-75.js +0 -0
  309. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-77.js +0 -0
  310. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-78.js +0 -0
  311. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-79.js +0 -0
  312. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-80.js +0 -0
  313. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-24.js +0 -0
  314. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-25.js +0 -0
  315. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-78.js +0 -0
  316. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-79.js +0 -0
  317. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-80.js +0 -0
  318. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-73.js +0 -0
  319. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-30.js +0 -0
  320. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-31.js +0 -0
  321. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-32.js +0 -0
  322. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-33.js +0 -0
package/dist/entry-30.js CHANGED
@@ -1 +1 @@
1
- import{a as P}from"./chunk-MGCHOGQD.js";import{a as F,b as R}from"./chunk-T6LX2RX5.js";import{a as j}from"./chunk-HKMBQLEK.js";import{a as h,b as v}from"./chunk-Z3VC3S2T.js";import{b as C,c as w,g as k,i as x,j as g,l as u,m as E}from"./chunk-M5MJP7Z2.js";import{a as b}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import"./chunk-ZC65Z3CK.js";import{a as f}from"./chunk-EI7MMDWY.js";import{copyFile as $,mkdtemp as A,rm as M}from"node:fs/promises";import y from"node:path";var D=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".html",".md",".yaml",".yml",".vue",".svelte"],z=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".less",".html",".htm",".md",".markdown",".mdx",".yaml",".yml",".toml"],d=[e("dart-format",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],[".dart"],["dart","format","{file}"],"https://dart.dev/tools/dart-format"),e("zig-format",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","fmt","{file}"],"https://ziglang.org/documentation/master/"),e("styler",["r"],["Rscript"],[".Rprofile","DESCRIPTION"],[".r"],["Rscript","-e","styler::style_file(commandArgs(TRUE)[1])","{file}"],"https://styler.r-lib.org/"),e("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"),e("prettier",["javascript","typescript","html","css","json","yaml","markdown","vue","svelte"],["prettier"],[".prettierrc",".prettierrc.json",".prettierrc.json5",".prettierrc.yaml",".prettierrc.yml",".prettierrc.toml",".prettierrc.js",".prettierrc.cjs",".prettierrc.mjs","prettier.config.js","prettier.config.cjs","prettier.config.mjs","prettier.config.ts","prettier.config.mts","prettier.config.cts"],D,["prettier","--write","{file}"],"https://prettier.io/docs/",["prettier"],{"package.json":["prettier"]}),e("biome",["javascript","typescript","json","css"],["biome"],["biome.json","biome.jsonc"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css"],["biome","format","--write","{file}"],"https://biomejs.dev/",["@biomejs/biome"]),e("oxfmt",["javascript","typescript","json","css","html","markdown","yaml","toml"],["oxfmt"],[".oxfmtrc.json",".oxfmtrc.jsonc","oxfmt.config.ts","oxfmt.config.mts"],z,["oxfmt","--write","{file}"],"https://oxc.rs/docs/guide/usage/formatter.html",["oxfmt"]),e("ruff-format",["python"],["ruff"],["ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","format","{file}"],"https://docs.astral.sh/ruff/formatter/",["ruff"],{"pyproject.toml":["tool.ruff"]}),e("black",["python"],["black"],[],[".py",".pyi"],["black","--quiet","{file}"],"https://black.readthedocs.io/",["black"],{"pyproject.toml":["tool.black"]}),e("gofmt",["go"],["gofmt"],["go.mod"],[".go"],["gofmt","-w","{file}"],"https://pkg.go.dev/cmd/gofmt"),e("goimports",["go"],["goimports"],["go.mod"],[".go"],["goimports","-w","{file}"],"https://pkg.go.dev/golang.org/x/tools/cmd/goimports"),e("rustfmt",["rust"],["rustfmt"],["rustfmt.toml",".rustfmt.toml","Cargo.toml"],[".rs"],["rustfmt","{file}"],"https://github.com/rust-lang/rustfmt"),e("csharpier",["csharp"],["csharpier"],[".csharpierrc",".csharpierrc.json",".csharpierrc.yaml",".csharpierrc.yml"],[".cs"],["csharpier","format","{file}"],"https://csharpier.com/"),e("google-java-format",["java"],["google-java-format"],["pom.xml","build.gradle"],[".java"],["google-java-format","--replace","{file}"],"https://github.com/google/google-java-format"),e("ktlint-format",["kotlin"],["ktlint"],[".editorconfig","build.gradle.kts"],[".kt",".kts"],["ktlint","-F","{file}"],"https://pinterest.github.io/ktlint/"),e("rubocop-format",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--fix-layout","{file}"],"https://docs.rubocop.org/"),e("pint",["php"],["pint"],["pint.json","composer.json"],[".php"],["pint","{file}"],"https://laravel.com/docs/pint"),e("swift-format",["swift"],["swift-format"],[".swift-format","Package.swift"],[".swift"],["swift-format","format","--in-place","{file}"],"https://github.com/swiftlang/swift-format"),e("stylua",["lua"],["stylua"],["stylua.toml",".stylua.toml"],[".lua"],["stylua","{file}"],"https://github.com/JohnnyMorganz/StyLua"),e("shfmt",["shell"],["shfmt"],[".editorconfig"],[".sh",".bash",".zsh"],["shfmt","-w","{file}"],"https://github.com/mvdan/sh"),e("taplo",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","format","{file}"],"https://taplo.tamasfe.dev/"),e("sqlfluff-format",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","format","{file}"],"https://docs.sqlfluff.com/"),e("terraform-fmt",["terraform"],["terraform"],[".terraform.lock.hcl"],[".tf",".tfvars"],["terraform","fmt","{file}"],"https://developer.hashicorp.com/terraform/cli/commands/fmt"),e("cmake-format",["cmake"],["cmake-format"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-format","-i","{file}"],"https://cmake-format.readthedocs.io/",void 0,void 0,["CMakeLists.txt"]),e("xmlformat",["xml"],["xmlformat"],[".xmlformat.conf"],[".xml",".xsd",".xsl"],["xmlformat","--overwrite","{file}"],"https://github.com/pamoller/xmlformatter"),e("mix-format",["elixir"],["mix"],["mix.exs",".formatter.exs"],[".ex",".exs"],["mix","format","{file}"],"https://hexdocs.pm/mix/Mix.Tasks.Format.html"),e("scalafmt",["scala"],["scalafmt"],[".scalafmt.conf"],[".scala",".sc",".sbt"],["scalafmt","{file}"],"https://scalameta.org/scalafmt/"),e("julia-format",["julia"],["julia"],[".JuliaFormatter.toml","Project.toml"],[".jl"],["julia","--startup-file=no","--history-file=no","-e","using JuliaFormatter; format_file(ARGS[1])","{file}"],"https://github.com/domluna/JuliaFormatter.jl"),e("powershell-format",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$p=$args[0];$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};[IO.File]::WriteAllText($p,(Invoke-Formatter -ScriptDefinition ([IO.File]::ReadAllText($p)) @options))',"{file}"],"https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-formatter"),e("dockfmt",["dockerfile"],["dockfmt"],["Dockerfile","Containerfile"],[".dockerfile"],["dockfmt","fmt","--write","{file}"],"https://github.com/jessfraz/dockfmt",void 0,void 0,["Dockerfile","Containerfile"])];function e(o,t,r,i,n,m,a,l,s,c){return{id:o,name:o,kind:"formatter",languages:t,executables:r,configFiles:i,documentation:a,...l&&{dependencies:l},...s&&{configSections:s},formatter:{extensions:n,...c&&{fileNames:c},run:{command:m},output:"in-place"}}}f(e,"recipe");var p=class o{constructor(t,r,i=new Map){this.formatters=t;this.availableBuiltIns=r;this.evidence=i}static{f(this,"FormatterCommandRegistry")}static async fromDirectory(t,r={}){let i=await k(t,"formatters",s=>E(s).formatters,r),n=r.environment??process.env,m=await Promise.all(i.entries.filter(s=>s.layer==="built-in").map(async s=>({id:s.id,available:await g(s.config.run,t,n)}))),a=await b(t,d),l=[...i.entries].sort((s,c)=>s.layer==="built-in"&&c.layer==="built-in"?(a.get(c.id)?.score??0)-(a.get(s.id)?.score??0):0);return new o(l,new Set(m.filter(s=>s.available&&(!r.requireBuiltInEvidence||(a.get(s.id)?.score??0)>0)).map(s=>s.id)),a)}static fromConfig(t){return new o(Object.entries(t.formatters).map(([r,i])=>({id:r,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(t,r){return this.resolveEntry(t,r)?.config}resolveEntry(t,r){return x(this.formatters,this.availableBuiltIns,this.evidence,t,r)}get entries(){return this.formatters}};var T={protocol:F,apiVersion:1,id:"formatter",setup(o){for(let t of d)o.addToolRecipe(t);o.addSetupCheck({id:"effective-config",inspect:_}),o.addCheck({id:"config",title:"Formatter",async run(t){try{let r=await p.fromDirectory(t.cwd,{environment:t.env}),i=q(r,t.files,t.cwd);return i.length===0?[{status:"skip",message:"No formatter matches the inspected project files"}]:await Promise.all(i.map(async({entry:n,source:m})=>{let a=`${n.id} [${n.layer}] command ${JSON.stringify(n.config.run.command)}`,l=await A(y.join(y.dirname(m),".pi-agent-ide-doctor-")),s=y.join(l,y.basename(m));try{return await $(m,s),(await u(n.config,{projectRoot:t.cwd,filePath:s,env:t.env})).ok?{status:"pass",message:`${a}: probe passed`,detail:n.sourcePath}:{status:"fail",message:`${a}: probe failed`,detail:n.sourcePath}}catch(c){return{status:"fail",message:`${a}: ${c instanceof Error?c.message:String(c)}`,detail:n.sourcePath}}finally{await M(l,{recursive:!0,force:!0})}}))}catch(r){return[{status:"fail",message:r instanceof Error?r.message:String(r)}]}}})}};async function _(o){try{let t=await p.fromDirectory(o.cwd,{environment:o.env}),r=[],i=new Map;for(let[n,m]of o.detectedLanguages){let a=m.map(l=>t.resolveEntry(l,o.cwd)).find(l=>l!==void 0);a!==void 0&&(r.push({kind:"formatter",languageId:n,toolId:a.id}),await g(a.config.run,o.cwd,o.env)||i.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:[...i.values()]}}catch(t){return{actions:[{id:"formatter-config-invalid",message:`Formatter configuration cannot load: ${t instanceof Error?t.message:String(t)}`}]}}}f(_,"inspectFormatterSetup");function q(o,t,r){let i=new Map;for(let n of t){let m=o.resolveEntry(n,r);m!==void 0&&!i.has(m.id)&&i.set(m.id,{entry:m,source:n})}return[...i.values()]}f(q,"applicableFormatters");import L from"node:path";var S=new Map;function O(){return{kind:"formatter",name:"formatter",priority:100,extensions:["*"],detect:f(async o=>(await I(o.cwd),!0),"detect"),async format({filePath:o},t){let r=await w(t.cwd,o,"formatters",d);if(r===void 0)return{ok:!0,edits:0,formatter:null};let i=r!==L.resolve(t.cwd),m=(await I(r,i)).resolve(o,r);if(m===void 0)return{ok:!0,edits:0,formatter:null};let a=C(m.run.command);try{let l=await u(m,{projectRoot:r,filePath:o});return{ok:l.ok,edits:l.changed?1:0,formatter:a}}catch{return{ok:!1,edits:0,formatter:a}}}}}f(O,"createFormatter");async function I(o,t=!1){let r=JSON.stringify([o,t]),i=S.get(r);return i===void 0&&(i=p.fromDirectory(o,{includeGlobal:!t,requireBuiltInEvidence:t}),S.set(r,i)),i}f(I,"loadRegistry");async function N(o){let t={kind:"formatter",name:"pi-agent-ide-formatter",priority:200,extensions:["*"],detect:f(()=>Promise.resolve(!0),"detect"),async format(i,n){return O().format(i,n)}},r={protocol:h,apiVersion:4,id:"formatter",setup(i){i.addTool(t)}};await Promise.all([j(o,r),P(o,T)])}f(N,"registerFormatter");export{N as default};
1
+ import{a as V,b as z,c as Q}from"./chunk-DEP55R35.js";import{a as O}from"./chunk-MGCHOGQD.js";import{a as L,b as N}from"./chunk-T6LX2RX5.js";import{a as B}from"./chunk-L7JMDDSD.js";import{a as M,b as _}from"./chunk-O6LE42GK.js";import{a as j}from"./chunk-6CZO43OH.js";import{a as U,b as F}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{a as H}from"./chunk-5VSE5X5R.js";import{d as $,e as D}from"./chunk-N34ATN52.js";import{a as x}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Value as De}from"typebox/value";import{access as ne}from"node:fs/promises";import re from"node:path";var K={protocol:L,apiVersion:1,id:"changes",setup(n){n.addSetupCheck({id:"git",async inspect(e){return await oe(e.cwd)?await $("git",e.cwd,e.env)?{}:{actions:[{id:"git-unavailable",message:"Git integration is unavailable because Git was not found"}]}:{}}}),n.addCheck({id:"git",title:"Git changes",async run(e){let t=await D("git",["--version"],e.cwd,e.env);return[t.ok?{status:"pass",message:"Git is available",detail:t.detail}:{status:"warn",message:"Git is not available; change anchors and index tools are disabled",detail:t.detail}]}})}};async function oe(n){try{return await ne(re.join(n,".git")),!0}catch{return!1}}s(oe,"isGitProject");import{mkdtemp as ae,rm as ie,writeFile as se}from"node:fs/promises";import de from"node:os";import m from"node:path";var b=class n{constructor(e,t){this.executor=e;this.repositoryRoot=t}static{s(this,"GitChangesBackend")}static async create(e,t,r){let o=await e.exec("git",["rev-parse","--show-toplevel"],{cwd:t,...r!==void 0&&{signal:r}});return o.code!==0?{status:"unavailable",reason:"no-worktree",message:o.stderr.trim()||"not inside a Git worktree"}:{status:"ready",backend:new n(e,m.resolve(o.stdout.trim()))}}async readTrackedFile(e,t,r){let o=m.resolve(t,e),a=m.relative(this.repositoryRoot,o);return a===".."||a.startsWith(`..${m.sep}`)||m.isAbsolute(a)?{status:"unavailable",reason:"outside-worktree",message:`${o} is outside ${this.repositoryRoot}`}:this.readTrackedRepositoryFile(a.split(m.sep).join("/"),r)}async readTrackedRepositoryFile(e,t){let r=await this.git(["rev-parse","--verify","HEAD"],t);if(r.code!==0)return{status:"unavailable",reason:"missing-head",message:r.stderr.trim()||"Git HEAD does not exist"};let o=await this.git(["--literal-pathspecs","ls-tree","-z","HEAD","--",e],t);if(o.code!==0)return{status:"unavailable",reason:"head-file-lookup-failed",message:o.stderr.trim()||`could not inspect HEAD:${e}`};let a=ce(o.stdout);if(a===void 0)return{status:"untracked"};let i=await this.readBlob(a.blob,"HEAD",e,t);if(i.status!=="found")return i;let c=await this.git(["--literal-pathspecs","ls-files","--stage","-z","--",e],t);if(c.code!==0)return{status:"unavailable",reason:"index-file-lookup-failed",message:c.stderr.trim()||`could not inspect the index entry for ${e}`};let d=ue(c.stdout);if(d.some(({stage:g})=>g!==0))return{status:"unavailable",reason:"conflicted",message:`${e} has unresolved Git index entries`};let u=d.find(({stage:g})=>g===0),l="";if(u!==void 0){let g=await this.readBlob(u.blob,"index",e,t);if(g.status!=="found")return g;l=g.text}return{status:"found",head:r.stdout.trim(),repositoryPath:e,repositoryRoot:this.repositoryRoot,headText:i.text,indexText:l,indexMode:u?.mode??a.mode}}async writeIndexFile(e,t,r,o){let a=await ae(m.join(de.tmpdir(),"pi-agent-index-")),i=m.join(a,"content");try{await se(i,r,"utf8");let c=await this.git(["hash-object","-w",`--path=${e}`,i],o);if(c.code!==0||c.stdout.trim().length===0)throw new Error(c.stderr.trim()||`could not write a Git blob for ${e}`);let d=await this.git(["update-index","--add","--cacheinfo",t,c.stdout.trim(),e],o);if(d.code!==0)throw new Error(d.stderr.trim()||`could not update the Git index entry for ${e}`)}finally{await ie(a,{recursive:!0,force:!0})}}async readBlob(e,t,r,o){let a=await this.git(["cat-file","blob",e],o);return a.code!==0?{status:"unavailable",reason:t==="HEAD"?"head-file-lookup-failed":"index-file-lookup-failed",message:a.stderr.trim()||`could not read ${t}:${r}`}:{status:"found",text:a.stdout}}git(e,t){return this.executor.exec("git",e,{cwd:this.repositoryRoot,...t!==void 0&&{signal:t}})}};function ce(n){let e=n.split("\0",1)[0];if(e===void 0||e.length===0)return;let t=e.indexOf(" ");if(t===-1)return;let[r,o,a]=e.slice(0,t).split(" ",3);return r===void 0||o!=="blob"||a===void 0?void 0:{mode:r,blob:a,path:e.slice(t+1)}}s(ce,"parseTreeEntry");function ue(n){return n.split("\0").filter(Boolean).flatMap(e=>{let t=e.indexOf(" ");if(t===-1)return[];let[r,o,a]=e.slice(0,t).split(" ",3),i=Number(a);return r===void 0||o===void 0||!Number.isInteger(i)?[]:[{mode:r,blob:o,stage:i,path:e.slice(t+1)}]})}s(ue,"parseIndexEntries");function W(n){return{exec:s((e,t,r)=>n.exec(e,t,r),"exec")}}s(W,"extensionGitExecutor");var f=class n{constructor(e){this.git=e}static{s(this,"ChangeService")}static async create(e,t,r){let o=await b.create(e,t,r);return o.status==="unavailable"?o:{status:"ready",service:new n(o.backend)}}async inspect(e){if(e.worktreeText.includes("\0"))return{status:"unavailable",reason:"binary",message:"worktree file contains binary content"};let t=await this.git.readTrackedFile(e.source,e.cwd,e.signal);if(t.status!=="found")return t.status==="untracked"?{status:"not-applicable",reason:"untracked"}:t;if(t.headText.includes("\0")||t.indexText.includes("\0"))return{status:"unavailable",reason:"binary",message:"Git file state contains binary content"};let r=V(t.repositoryPath,t.headText,t.indexText,e.worktreeText);return r.length===0?{status:"not-applicable",reason:"clean"}:{status:"applicable",head:t.head,repositoryRoot:t.repositoryRoot,repositoryPath:t.repositoryPath,groups:r}}async changeIndex(e,t,r){let o=await this.inspect(e);if(o.status!=="applicable")return o;let a=o.groups.find(u=>u.selector===t);if(a===void 0)return A(t,o.groups.map(({selector:u})=>u));let i=r==="stage"?"staged":"unstaged";if(a.state===i)return{status:"unchanged",state:i,group:a};let c=x(a.segments[0]),d={head:o.head,repositoryPath:o.repositoryPath,headStart:c.headStart,headEnd:c.headEnd,replacementText:r==="stage"?c.worktreeText:c.headText};try{await this.applyIndexUpdate(d,e.signal)}catch(u){return{status:"unavailable",reason:"index-write-failed",message:le(u)}}return{status:"applied",state:i,group:a}}async prepareUndo(e,t){let r=await this.inspect(e);if(r.status!=="applicable")return r;let o=r.groups.find(d=>d.selector===t);if(o===void 0)return A(t,r.groups.map(({selector:d})=>d));let a=z(e.worktreeText,o);if(a===void 0)return A(t,r.groups.map(({selector:d})=>d));let i=x(o.segments[0]),c=o.state==="unstaged"?void 0:{head:r.head,repositoryPath:r.repositoryPath,headStart:i.headStart,headEnd:i.headEnd,replacementText:i.headText};return{status:"applied",worktreeText:a,group:o,...c!==void 0&&{indexUpdate:c}}}async applyIndexUpdate(e,t){let r=await this.git.readTrackedRepositoryFile(e.repositoryPath,t);if(r.status!=="found")throw new Error(r.status==="untracked"?`${e.repositoryPath} is no longer tracked by HEAD`:r.message);if(r.head!==e.head)throw new Error(`Git HEAD changed while updating ${e.repositoryPath}`);let o=Q(r.headText,r.indexText,e.headStart,e.headEnd,e.replacementText);o!==r.indexText&&await this.git.writeIndexFile(e.repositoryPath,r.indexMode,o,t)}};function A(n,e){return{status:"unavailable",reason:"stale-selector",message:`${n} is not available in the current file state`,availableSelectors:e}}s(A,"staleSelector");function le(n){return n instanceof Error?n.message:String(n)}s(le,"errorMessage");var T="pi-agent-ide-changes/change",ge=/^CHANGE#[0-9A-F]{4,64}$/,pe=/^[A-Za-z][A-Za-z\d+.-]*:\/\//,G=class extends H{static{s(this,"ChangeTextAnchor")}constructor(e){super(e.selector,e.currentStartLine)}};function Y(n){return{resolver:fe(s(async t=>{if(pe.test(t.source))return;let r=await f.create(n,t.cwd,t.signal);if(r.status!=="ready")throw new Error(r.message);return r.service.inspect({source:t.source,worktreeText:t.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}})},"inspect"))}}s(Y,"createChangeAnchorRegistration");function fe(n){return{id:"git-change",description:"Use the complete `CHANGE#HASH` shown beside a current Git change.",renderFull(e){return e},renderCompact(e){return e},async tryResolve(e,t){if(!ge.test(e))return{kind:"not-handled"};try{let r=await n(t);if(r===void 0)return{kind:"not-handled"};if(r.status==="unavailable")return{kind:"failed",error:new Error(r.message)};let o=r.status==="applicable"?r.groups.find(a=>a.selector===e):void 0;return o===void 0?{kind:"rejected",rejection:{code:"stale",reason:`Change anchor ${e} is stale or unknown`}}:{kind:"resolved",anchor:new G(o)}}catch(r){return{kind:"failed",error:r}}}}}s(fe,"createChangeAnchorResolver");import{diffLines as he}from"diff";var me="filesystem";function q(n){return{id:"current-git-changes",async present(e,t){if(t.purpose!=="read"||t.resolvedBy!==me)return e;let r=await f.create(n,t.cwd,t.signal);if(r.status!=="ready")return e;let o=await r.service.inspect({source:t.source,worktreeText:e.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}});return o.status!=="applicable"?e:ye(e,o.groups)}}}s(q,"createCurrentChangePresenter");function ye(n,e){let t=new Map;for(let r of e)xe(n,r,t);return{...n,lines:n.lines.map(r=>be(r,t.get(r.lineNumber)))}}s(ye,"presentChangeGroups");function xe(n,e,t){let r=x(e.segments[0]),o=he(r.headText,r.worktreeText),a=e.currentStartLine,i,c;for(let d of o){let u=ve(d.value);if(d.removed){let l=Te(n,a),g=R(t,l.lineNumber),p=l.after?g.after:g.before;for(let h of u){let w={kind:"synthetic",rows:p,index:p.length};p.push({marker:"-",prefix:"|",content:h}),i??=w,c=w}continue}if(d.added){for(let l of u){let g=R(t,a),p={kind:"current",lineNumber:a};g.added=!0,i??=p,c=p,a++}continue}a+=u.length}if(i!==void 0&&c!==void 0){let d=`${e.selector} \xB7 ${e.state}`;we(i,c)?I(t,i,`<!-- change: ${d} -->`):(I(t,i,`<!-- change-begin: ${d} -->`),I(t,c,`<!-- change-end: ${d} -->`))}}s(xe,"presentChangeGroup");function we(n,e){return n.kind==="current"&&e.kind==="current"?n.lineNumber===e.lineNumber:n.kind==="synthetic"&&e.kind==="synthetic"?n.rows===e.rows&&n.index===e.index:!1}s(we,"sameTarget");function I(n,e,t){if(e.kind==="current"){R(n,e.lineNumber).annotations.push(t);return}let r=x(e.rows[e.index]);e.rows[e.index]={...r,suffix:`${r.suffix??""} ${t}`}}s(I,"annotateTarget");function be(n,e){if(e===void 0)return n;let t=e.annotations.length===0?"":` ${e.annotations.join(" ")}`;return{...n,presentation:{...n.presentation,...e.added&&{marker:"+"},before:[...n.presentation?.before??[],...e.before],after:[...e.after,...n.presentation?.after??[]],suffix:`${n.presentation?.suffix??""}${t}`}}}s(be,"presentLine");function R(n,e){let t=n.get(e);if(t!==void 0)return t;let r={before:[],after:[],annotations:[],added:!1};return n.set(e,r),r}s(R,"presentationsFor");function Te(n,e){return e<=n.lines.length?{lineNumber:Math.max(1,e),after:!1}:{lineNumber:n.lines.length,after:!0}}s(Te,"placementFor");function ve(n){if(n.length===0)return[];let e=n.split(/\r\n|\r|\n/u);return e.at(-1)===""&&e.pop(),e}s(ve,"splitLines");var v=class{static{s(this,"IndexMutationQueue")}tail=Promise.resolve();run(e){let t=this.tail.then(e,e);return this.tail=t.then(()=>{},()=>{}),t}};import{createHash as Ce}from"node:crypto";import{realpathSync as ke}from"node:fs";import J from"node:path";import{fileURLToPath as Ee}from"node:url";var k=class{static{s(this,"LastTextTransactionStore")}#e=new Map;observe(e){let t=X(e.resourceSource,e.cwd);if(e.postProcessing==="final"){let r=this.#e.get(t);r&&r.afterDigest===C(e.before.content)?this.#e.set(t,{...r,afterDigest:C(e.after.content)}):this.#e.delete(t);return}if(e.intent!=="edit"||!e.existed||e.before.content===e.after.content){this.#e.delete(t);return}this.#e.set(t,{before:e.before.content,afterDigest:C(e.after.content)})}restore(e,t,r){let o=X(e,t),a=this.#e.get(o);if(a===void 0)throw new Error(`No last text transaction is available for ${e}.`);if(a.afterDigest!==C(r))throw this.#e.delete(o),new Error(`${e} changed after its last text transaction; refusing to overwrite newer text.`);return a.before}};function X(n,e){return n.startsWith("file://")?Z(Ee(new URL(n))):/^[a-z][a-z\d+.-]*:/iu.test(n)?n:Z(J.resolve(e,n))}s(X,"sourceKey");function Z(n){try{return ke.native(n)}catch{return J.normalize(n)}}s(Z,"canonicalFile");function C(n){return Ce("sha256").update(n).digest("hex")}s(C,"textDigest");import{readFile as Pe}from"node:fs/promises";import Ae from"node:path";import{defineTool as Ge,withFileMutationQueue as Ie}from"@earendil-works/pi-coding-agent";import{Type as S}from"typebox";var P=S.Object({file:S.String({description:"Path to the tracked text file"}),change:S.String({description:"Complete CHANGE#HASH anchor shown by read",pattern:"^CHANGE#[0-9A-F]{4,64}$"})},{additionalProperties:!1});function ee(n,e,t){n.registerTool(E("stage",e,t)),n.registerTool(E("unstage",e,t))}s(ee,"registerIndexChangeTools");function E(n,e,t){let r=n==="stage"?"staged":"unstaged",o=n==="stage"?"Staged":"Unstaged";return Ge({name:n,label:n,promptSnippet:`${o.slice(0,-1)} a selected Git change`,description:`Use ${n} to ${n==="stage"?"add one current Git change to the index":"remove one current Git change from the index"}. Select the change with a CHANGE# anchor; worktree content is kept.`,parameters:P,async execute(a,i,c,d,u){let l=Re(i.file,u.cwd);return Ie(l,()=>t.run(async()=>{let g=await Pe(l,"utf8"),p=await f.create(e,u.cwd,c);if(p.status!=="ready")throw new Error(p.message);let h=await p.service.changeIndex({source:l,worktreeText:g,cwd:u.cwd,...c!==void 0&&{signal:c}},i.change,n);if(h.status==="unavailable")throw new Error(h.message);if(h.status==="not-applicable")throw new Error(`${n} is not applicable to ${l}: ${h.reason}`);let w=h.status==="unchanged";return{content:[{type:"text",text:w?`${i.change} is already ${r} in ${i.file}.`:`${o} ${i.change} in ${i.file}.`}],details:{action:n,change:i.change,file:l,state:r,unchanged:w}}}))}})}s(E,"createIndexChangeTool");function Re(n,e){let t=n.startsWith("@")?n.slice(1):n;return Ae.resolve(e,t)}s(Re,"resolveFile");import{diffChars as Se}from"diff";import{Type as y}from"typebox";var He=y.Object({file:y.Optional(y.String({description:"File to restore; may be omitted to inherit the previous batched source"})),change:y.Optional(y.String({description:"Complete CHANGE#HASH anchor shown by read, or last for this file's latest text-editor transaction",pattern:"^(?:CHANGE#[0-9A-F]{4,64}|last)$"})),transaction:y.Optional(y.String({description:"APPLY# receipt returned by a successful Apply transaction",pattern:"^APPLY#[0-9A-F]{12}$"}))},{additionalProperties:!1});function te(n,e,t,r){return{name:"undo",description:"Use undo to revert an APPLY# transaction receipt, a selected uncommitted Git change, or the latest text-editor transaction for one file. Apply receipts restore every touched path atomically; CHANGE# restores that change to HEAD in both worktree and index; last restores one file's latest text edit.",promptSnippet:"Restore an Apply transaction, Git change, or latest text edit",direct:{matches:s(o=>o!==null&&typeof o=="object"&&"transaction"in o&&typeof o.transaction=="string","matches"),async execute(o,a){if(a.change!==void 0)throw new Error("transaction cannot be combined with change");let i=String(a.transaction),c=await r(i,o.signal);return{source:i,summary:`Restored ${String(c.restored.length)} paths from ${i}.`,data:{kind:"apply-undo",ok:!0,transaction:i,restored:c.restored}}}},parameters:He,intent:"restore",source:{field:"file",inherited:!0},anchors:[{field:"change",sourceField:"file",kinds:[T],nonAnchorValues:["last"]}],async mutate(o,a){if(a.change===void 0)throw new Error("change is required when transaction is omitted");let i=o.sourceFor("file"),c,d;if(a.change==="last")c=e.restore(i,o.cwd,o.sourceDocument.content);else{await o.resolveAnchor("change");let u=await f.create(n,o.cwd,o.signal);if(u.status!=="ready")throw new Error(u.message);let l=await u.service.prepareUndo({source:i,worktreeText:o.sourceDocument.content,cwd:o.cwd,...o.signal!==void 0&&{signal:o.signal}},a.change);if(l.status!=="applied")throw l.status==="unavailable"?new Error(l.message):new Error(`Undo is not applicable to ${i}: ${l.reason}`);if(c=l.worktreeText,l.indexUpdate!==void 0){let g=l.indexUpdate;d=s(()=>t.run(()=>u.service.applyIndexUpdate(g,o.signal)),"afterWrite")}}return{edits:new Map([[i,{changes:$e(o.sourceDocument.content,c),action:"edited"}]]),...d!==void 0&&{afterWrite:d}}}}}s(te,"createUndoMutationTool");function $e(n,e){let t=[],r=0,o,a=0,i="",c=s(()=>{o!==void 0&&(t.push({from:o,to:o+a,insert:i}),o=void 0,a=0,i="")},"flush");for(let d of Se(n,e)){if(!d.added&&!d.removed){c(),r+=d.value.length;continue}o??=r,d.removed?(r+=d.value.length,a+=d.value.length):i+=d.value}return c(),t}s($e,"createTextChanges");async function Le(n){let e=W(n),t=new k,r=new v,o=q(e),a=Y(e),i={protocol:U,apiVersion:F,id:"current-git-changes",setup(d){d.addView({view:"changes",presenter:o}),d.describe('views: ["changes"] \u2014 uncommitted edits in tracked files, staged/unstaged state, and CHANGE# anchors for stage, unstage and undo.')}},c={protocol:M,apiVersion:_,id:"current-git-changes",setup(d){d.addAnchorResolver({...a,kind:T,type:"auxiliary"}),d.onDidEdit(u=>{t.observe(u)}),d.addMutationTool(te(e,t,r,d.restoreApplyUndo));for(let u of["stage","unstage"]){let l=E(u,e,r);d.addScriptIndexOperation({name:u,parameters:P,execute:s((g,p,h)=>l.execute(`apply-${u}`,De.Decode(P,g),p,void 0,h),"execute")})}d.addTextPresenter({presenter:o})}};await Promise.all([O(n,K),j(n,i),B(n,c)]),ee(n,e,r)}s(Le,"registerGitChanges");export{Le as default};
package/dist/entry-31.js CHANGED
@@ -1 +1 @@
1
- import{a as p}from"./chunk-MGCHOGQD.js";import{a as n,b as c}from"./chunk-T6LX2RX5.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("dart","Dart",[".dart"],["pubspec.yaml","analysis_options.yaml"]),t("powershell","PowerShell",[".ps1",".psm1",".psd1"],["PSScriptAnalyzerSettings.psd1"]),t("r","R",[".r"],["DESCRIPTION",".lintr",".Rprofile"]),t("scala","Scala",[".scala",".sc"],["build.sbt","project.scala",".scalafmt.conf"]),t("elixir","Elixir",[".ex",".exs"],["mix.exs",".formatter.exs"]),t("zig","Zig",[".zig",".zon"],["build.zig","build.zig.zon","zls.json"]),t("julia","Julia",[".jl"],["Project.toml",".JuliaFormatter.toml"]),t("vue","Vue",[".vue"],["package.json"]),t("svelte","Svelte",[".svelte"],["svelte.config.js","svelte.config.ts"]),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(s,i,o,r,l,a){return{id:s,name:i,extensions:o,projectMarkers:r,...l&&{ast:l},...a&&{fileNames:a}}}e(t,"language");function g(s){return p(s,{protocol:n,apiVersion:1,id:"languages",setup(o){for(let r of m)o.addLanguage(r)}})}e(g,"registerLanguages");export{g as default};
1
+ import{a as P}from"./chunk-MGCHOGQD.js";import{a as F,b as R}from"./chunk-T6LX2RX5.js";import{a as j}from"./chunk-HKMBQLEK.js";import{a as h,b as v}from"./chunk-Z3VC3S2T.js";import{b as C,c as w,g as k,i as x,j as g,l as u,m as E}from"./chunk-M5MJP7Z2.js";import{a as b}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import"./chunk-ZC65Z3CK.js";import{a as f}from"./chunk-EI7MMDWY.js";import{copyFile as $,mkdtemp as A,rm as M}from"node:fs/promises";import y from"node:path";var D=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".html",".md",".yaml",".yml",".vue",".svelte"],z=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".less",".html",".htm",".md",".markdown",".mdx",".yaml",".yml",".toml"],d=[e("dart-format",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],[".dart"],["dart","format","{file}"],"https://dart.dev/tools/dart-format"),e("zig-format",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","fmt","{file}"],"https://ziglang.org/documentation/master/"),e("styler",["r"],["Rscript"],[".Rprofile","DESCRIPTION"],[".r"],["Rscript","-e","styler::style_file(commandArgs(TRUE)[1])","{file}"],"https://styler.r-lib.org/"),e("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"),e("prettier",["javascript","typescript","html","css","json","yaml","markdown","vue","svelte"],["prettier"],[".prettierrc",".prettierrc.json",".prettierrc.json5",".prettierrc.yaml",".prettierrc.yml",".prettierrc.toml",".prettierrc.js",".prettierrc.cjs",".prettierrc.mjs","prettier.config.js","prettier.config.cjs","prettier.config.mjs","prettier.config.ts","prettier.config.mts","prettier.config.cts"],D,["prettier","--write","{file}"],"https://prettier.io/docs/",["prettier"],{"package.json":["prettier"]}),e("biome",["javascript","typescript","json","css"],["biome"],["biome.json","biome.jsonc"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css"],["biome","format","--write","{file}"],"https://biomejs.dev/",["@biomejs/biome"]),e("oxfmt",["javascript","typescript","json","css","html","markdown","yaml","toml"],["oxfmt"],[".oxfmtrc.json",".oxfmtrc.jsonc","oxfmt.config.ts","oxfmt.config.mts"],z,["oxfmt","--write","{file}"],"https://oxc.rs/docs/guide/usage/formatter.html",["oxfmt"]),e("ruff-format",["python"],["ruff"],["ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","format","{file}"],"https://docs.astral.sh/ruff/formatter/",["ruff"],{"pyproject.toml":["tool.ruff"]}),e("black",["python"],["black"],[],[".py",".pyi"],["black","--quiet","{file}"],"https://black.readthedocs.io/",["black"],{"pyproject.toml":["tool.black"]}),e("gofmt",["go"],["gofmt"],["go.mod"],[".go"],["gofmt","-w","{file}"],"https://pkg.go.dev/cmd/gofmt"),e("goimports",["go"],["goimports"],["go.mod"],[".go"],["goimports","-w","{file}"],"https://pkg.go.dev/golang.org/x/tools/cmd/goimports"),e("rustfmt",["rust"],["rustfmt"],["rustfmt.toml",".rustfmt.toml","Cargo.toml"],[".rs"],["rustfmt","{file}"],"https://github.com/rust-lang/rustfmt"),e("csharpier",["csharp"],["csharpier"],[".csharpierrc",".csharpierrc.json",".csharpierrc.yaml",".csharpierrc.yml"],[".cs"],["csharpier","format","{file}"],"https://csharpier.com/"),e("google-java-format",["java"],["google-java-format"],["pom.xml","build.gradle"],[".java"],["google-java-format","--replace","{file}"],"https://github.com/google/google-java-format"),e("ktlint-format",["kotlin"],["ktlint"],[".editorconfig","build.gradle.kts"],[".kt",".kts"],["ktlint","-F","{file}"],"https://pinterest.github.io/ktlint/"),e("rubocop-format",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--fix-layout","{file}"],"https://docs.rubocop.org/"),e("pint",["php"],["pint"],["pint.json","composer.json"],[".php"],["pint","{file}"],"https://laravel.com/docs/pint"),e("swift-format",["swift"],["swift-format"],[".swift-format","Package.swift"],[".swift"],["swift-format","format","--in-place","{file}"],"https://github.com/swiftlang/swift-format"),e("stylua",["lua"],["stylua"],["stylua.toml",".stylua.toml"],[".lua"],["stylua","{file}"],"https://github.com/JohnnyMorganz/StyLua"),e("shfmt",["shell"],["shfmt"],[".editorconfig"],[".sh",".bash",".zsh"],["shfmt","-w","{file}"],"https://github.com/mvdan/sh"),e("taplo",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","format","{file}"],"https://taplo.tamasfe.dev/"),e("sqlfluff-format",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","format","{file}"],"https://docs.sqlfluff.com/"),e("terraform-fmt",["terraform"],["terraform"],[".terraform.lock.hcl"],[".tf",".tfvars"],["terraform","fmt","{file}"],"https://developer.hashicorp.com/terraform/cli/commands/fmt"),e("cmake-format",["cmake"],["cmake-format"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-format","-i","{file}"],"https://cmake-format.readthedocs.io/",void 0,void 0,["CMakeLists.txt"]),e("xmlformat",["xml"],["xmlformat"],[".xmlformat.conf"],[".xml",".xsd",".xsl"],["xmlformat","--overwrite","{file}"],"https://github.com/pamoller/xmlformatter"),e("mix-format",["elixir"],["mix"],["mix.exs",".formatter.exs"],[".ex",".exs"],["mix","format","{file}"],"https://hexdocs.pm/mix/Mix.Tasks.Format.html"),e("scalafmt",["scala"],["scalafmt"],[".scalafmt.conf"],[".scala",".sc",".sbt"],["scalafmt","{file}"],"https://scalameta.org/scalafmt/"),e("julia-format",["julia"],["julia"],[".JuliaFormatter.toml","Project.toml"],[".jl"],["julia","--startup-file=no","--history-file=no","-e","using JuliaFormatter; format_file(ARGS[1])","{file}"],"https://github.com/domluna/JuliaFormatter.jl"),e("powershell-format",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$p=$args[0];$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};[IO.File]::WriteAllText($p,(Invoke-Formatter -ScriptDefinition ([IO.File]::ReadAllText($p)) @options))',"{file}"],"https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-formatter"),e("dockfmt",["dockerfile"],["dockfmt"],["Dockerfile","Containerfile"],[".dockerfile"],["dockfmt","fmt","--write","{file}"],"https://github.com/jessfraz/dockfmt",void 0,void 0,["Dockerfile","Containerfile"])];function e(o,t,r,i,n,m,a,l,s,c){return{id:o,name:o,kind:"formatter",languages:t,executables:r,configFiles:i,documentation:a,...l&&{dependencies:l},...s&&{configSections:s},formatter:{extensions:n,...c&&{fileNames:c},run:{command:m},output:"in-place"}}}f(e,"recipe");var p=class o{constructor(t,r,i=new Map){this.formatters=t;this.availableBuiltIns=r;this.evidence=i}static{f(this,"FormatterCommandRegistry")}static async fromDirectory(t,r={}){let i=await k(t,"formatters",s=>E(s).formatters,r),n=r.environment??process.env,m=await Promise.all(i.entries.filter(s=>s.layer==="built-in").map(async s=>({id:s.id,available:await g(s.config.run,t,n)}))),a=await b(t,d),l=[...i.entries].sort((s,c)=>s.layer==="built-in"&&c.layer==="built-in"?(a.get(c.id)?.score??0)-(a.get(s.id)?.score??0):0);return new o(l,new Set(m.filter(s=>s.available&&(!r.requireBuiltInEvidence||(a.get(s.id)?.score??0)>0)).map(s=>s.id)),a)}static fromConfig(t){return new o(Object.entries(t.formatters).map(([r,i])=>({id:r,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(t,r){return this.resolveEntry(t,r)?.config}resolveEntry(t,r){return x(this.formatters,this.availableBuiltIns,this.evidence,t,r)}get entries(){return this.formatters}};var T={protocol:F,apiVersion:1,id:"formatter",setup(o){for(let t of d)o.addToolRecipe(t);o.addSetupCheck({id:"effective-config",inspect:_}),o.addCheck({id:"config",title:"Formatter",async run(t){try{let r=await p.fromDirectory(t.cwd,{environment:t.env}),i=q(r,t.files,t.cwd);return i.length===0?[{status:"skip",message:"No formatter matches the inspected project files"}]:await Promise.all(i.map(async({entry:n,source:m})=>{let a=`${n.id} [${n.layer}] command ${JSON.stringify(n.config.run.command)}`,l=await A(y.join(y.dirname(m),".pi-agent-ide-doctor-")),s=y.join(l,y.basename(m));try{return await $(m,s),(await u(n.config,{projectRoot:t.cwd,filePath:s,env:t.env})).ok?{status:"pass",message:`${a}: probe passed`,detail:n.sourcePath}:{status:"fail",message:`${a}: probe failed`,detail:n.sourcePath}}catch(c){return{status:"fail",message:`${a}: ${c instanceof Error?c.message:String(c)}`,detail:n.sourcePath}}finally{await M(l,{recursive:!0,force:!0})}}))}catch(r){return[{status:"fail",message:r instanceof Error?r.message:String(r)}]}}})}};async function _(o){try{let t=await p.fromDirectory(o.cwd,{environment:o.env}),r=[],i=new Map;for(let[n,m]of o.detectedLanguages){let a=m.map(l=>t.resolveEntry(l,o.cwd)).find(l=>l!==void 0);a!==void 0&&(r.push({kind:"formatter",languageId:n,toolId:a.id}),await g(a.config.run,o.cwd,o.env)||i.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:[...i.values()]}}catch(t){return{actions:[{id:"formatter-config-invalid",message:`Formatter configuration cannot load: ${t instanceof Error?t.message:String(t)}`}]}}}f(_,"inspectFormatterSetup");function q(o,t,r){let i=new Map;for(let n of t){let m=o.resolveEntry(n,r);m!==void 0&&!i.has(m.id)&&i.set(m.id,{entry:m,source:n})}return[...i.values()]}f(q,"applicableFormatters");import L from"node:path";var S=new Map;function O(){return{kind:"formatter",name:"formatter",priority:100,extensions:["*"],detect:f(async o=>(await I(o.cwd),!0),"detect"),async format({filePath:o},t){let r=await w(t.cwd,o,"formatters",d);if(r===void 0)return{ok:!0,edits:0,formatter:null};let i=r!==L.resolve(t.cwd),m=(await I(r,i)).resolve(o,r);if(m===void 0)return{ok:!0,edits:0,formatter:null};let a=C(m.run.command);try{let l=await u(m,{projectRoot:r,filePath:o});return{ok:l.ok,edits:l.changed?1:0,formatter:a}}catch{return{ok:!1,edits:0,formatter:a}}}}}f(O,"createFormatter");async function I(o,t=!1){let r=JSON.stringify([o,t]),i=S.get(r);return i===void 0&&(i=p.fromDirectory(o,{includeGlobal:!t,requireBuiltInEvidence:t}),S.set(r,i)),i}f(I,"loadRegistry");async function N(o){let t={kind:"formatter",name:"pi-agent-ide-formatter",priority:200,extensions:["*"],detect:f(()=>Promise.resolve(!0),"detect"),async format(i,n){return O().format(i,n)}},r={protocol:h,apiVersion:4,id:"formatter",setup(i){i.addTool(t)}};await Promise.all([j(o,r),P(o,T)])}f(N,"registerFormatter");export{N as default};
package/dist/entry-32.js CHANGED
@@ -1,4 +1 @@
1
- import{a as O}from"./chunk-MGCHOGQD.js";import{a as T,b as N}from"./chunk-T6LX2RX5.js";import{a as L}from"./chunk-HKMBQLEK.js";import{a as j,b as P}from"./chunk-Z3VC3S2T.js";import{b as E,c as S,g as D,i as $,j as w,k as I,n as A}from"./chunk-M5MJP7Z2.js";import{a as R}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import{a as g}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import oe from"node:path";var p=[c("dart-analyze",["dart"],["dart"],["analysis_options.yaml","pubspec.yaml"],[".dart"],["dart","analyze","--format","machine","{file}"],"regex","https://dart.dev/tools/dart-analyze","^(?<severity>[^|]+)\\|[^|]+\\|(?<code>[^|]+)\\|(?<file>[^|]+)\\|(?<line>\\d+)\\|(?<column>\\d+)\\|\\d+\\|(?<message>.*)$",void 0,[0,1,2,3]),c("zig-ast-check",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","ast-check","{file}"],"gcc","https://ziglang.org/documentation/master/"),c("lintr",["r"],["Rscript"],[".lintr","DESCRIPTION"],[".r"],["Rscript","-e","print(lintr::lint(commandArgs(TRUE)[1]))","{file}"],"regex","https://lintr.r-lib.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[^:]+): \\[(?<code>[^\\]]+)\\] (?<message>.*)$"),c("clang-tidy",["c","cpp"],["clang-tidy"],[".clang-tidy","compile_commands.json"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-tidy","{file}"],"clang","https://clang.llvm.org/extra/clang-tidy/"),c("eslint",["javascript","typescript","vue","svelte"],["eslint"],["eslint.config.js","eslint.config.mjs","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts",".eslintrc",".eslintrc.json",".eslintrc.js",".eslintrc.cjs",".eslintrc.yaml",".eslintrc.yml"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".vue",".svelte"],["eslint","--format","json","{file}"],"eslint-json","https://eslint.org/docs/latest/",void 0,["eslint"]),c("oxlint",["javascript","typescript"],["oxlint"],[".oxlintrc.json",".oxlintrc.jsonc","oxlint.config.ts","oxlint.config.mts"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts"],["oxlint","--format","sarif","{file}"],"sarif","https://oxc.rs/docs/guide/usage/linter.html",void 0,["oxlint"]),c("ruff",["python"],["ruff"],["pyproject.toml","ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","check","--output-format","concise","{file}"],"regex","https://docs.astral.sh/ruff/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<code>\\S+) (?<message>.+)$",["ruff"]),c("golangci-lint",["go"],["golangci-lint"],[".golangci.yml",".golangci.yaml","go.mod"],[".go"],["golangci-lint","run","--output.text.path=","--output.checkstyle.path=stdout","--show-stats=false","./..."],"checkstyle","https://golangci-lint.run/"),c("clippy",["rust"],["cargo"],["Cargo.toml","clippy.toml"],[".rs"],["cargo","clippy","--message-format","short"],"gcc","https://doc.rust-lang.org/clippy/"),c("dotnet-format",["csharp"],["dotnet"],[".editorconfig","global.json"],[".cs"],["dotnet","format","--verify-no-changes","--include","{relativeFile}"],"regex","https://learn.microsoft.com/dotnet/core/tools/dotnet-format","^(?<file>.+)\\((?<line>\\d+),(?<column>\\d+)\\): (?<severity>error|warning) (?<code>[^:]+): (?<message>.*?)(?: \\[.*\\])?$",void 0,[0,2]),c("checkstyle",["java"],["checkstyle"],["checkstyle.xml","pom.xml"],[".java"],["checkstyle","-c","checkstyle.xml","-f","xml","{file}"],"checkstyle","https://checkstyle.org/"),c("detekt",["kotlin"],["detekt"],["detekt.yml","build.gradle.kts"],[".kt",".kts"],["detekt","--input","{file}","--config","detekt.yml"],"regex","https://detekt.dev/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<message>.*?) \\[(?<code>[^\\]]+)\\]$",void 0,[0,2]),c("rubocop",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--format","clang","{file}"],"regex","https://docs.rubocop.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?:\\[Correctable\\] )?(?<code>[^:]+): (?<message>.*)$"),c("phpcs",["php"],["phpcs"],["phpcs.xml","phpcs.xml.dist","composer.json"],[".php"],["phpcs","--report=checkstyle","{file}"],"checkstyle","https://github.com/PHPCSStandards/PHP_CodeSniffer",void 0,void 0,[0,1,2,3]),c("swiftlint",["swift"],["swiftlint"],[".swiftlint.yml","Package.swift"],[".swift"],["swiftlint","lint","--quiet","--reporter","checkstyle","{file}"],"checkstyle","https://github.com/realm/SwiftLint",void 0,void 0,[0,2]),c("scalafix",["scala"],["scalafix"],[".scalafix.conf"],[".scala",".sc"],["scalafix","--check","--files","{file}"],"gcc","https://scalacenter.github.io/scalafix/",void 0,void 0,[0,2,64,66]),c("credo",["elixir"],["mix"],["mix.exs",".credo.exs"],[".ex",".exs"],["mix","credo","--strict","--format","flycheck","--files-included","{file}"],"regex","https://hexdocs.pm/credo/","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?<message>.+)$",void 0,Array.from({length:32},(t,e)=>e)),c("psscriptanalyzer",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};Invoke-ScriptAnalyzer -Path $args[0] @options | ForEach-Object {"$($_.ScriptPath):$($_.Line):$($_.Column): $($_.Severity): $($_.Message) [$($_.RuleName)]"}',"{file}"],"regex","https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-scriptanalyzer","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>\\w+): (?<message>.+) \\[(?<code>[^\\]]+)\\]$",void 0,[0]),c("luacheck",["lua"],["luacheck"],[".luacheckrc"],[".lua"],["luacheck","--formatter","plain","--codes","--no-color","{file}"],"regex","https://github.com/lunarmodules/luacheck","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): \\((?<code>(?<severity>[WE])\\d+)\\) (?<message>.+)$",void 0,[0,1,2]),c("shellcheck",["shell"],["shellcheck"],[".shellcheckrc"],[".sh",".bash",".zsh"],["shellcheck","-f","gcc","{file}"],"gcc","https://www.shellcheck.net/"),c("stylelint",["css"],["stylelint"],["stylelint.config.js",".stylelintrc.json"],[".css",".scss",".sass",".less"],["stylelint","--formatter","compact","{file}"],"regex","https://stylelint.io/","^(?<file>.+): line (?<line>\\d+), col (?<column>\\d+), (?<severity>error|warning) - (?<message>.+) \\((?<code>[^)]+)\\)$",["stylelint"],[0,2]),c("yamllint",["yaml"],["yamllint"],[".yamllint",".yamllint.yml"],[".yaml",".yml"],["yamllint","-f","parsable","{file}"],"regex","https://yamllint.readthedocs.io/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): \\[(?<severity>[^\\]]+)\\] (?<message>.*?) \\((?<code>[^)]+)\\)$"),c("markdownlint",["markdown"],["markdownlint"],[".markdownlint.json",".markdownlint.yaml"],[".md",".mdx"],["markdownlint","{file}"],"regex","https://github.com/DavidAnson/markdownlint","^(?<file>.+?):(?<line>\\d+)(?::(?<column>\\d+))? (?<severity>error|warning) (?<code>MD\\d+)(?:/\\S+)? (?<message>.*)$"),c("sqlfluff",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","lint","--format","sarif","{file}"],"sarif","https://docs.sqlfluff.com/"),c("hadolint",["dockerfile"],["hadolint"],[".hadolint.yaml"],[".dockerfile"],["hadolint","--format","checkstyle","{file}"],"checkstyle","https://github.com/hadolint/hadolint",void 0,void 0,[0,1],void 0,["Dockerfile","Containerfile"]),c("tflint",["terraform"],["tflint"],[".tflint.hcl"],[".tf"],["tflint","--format","checkstyle"],"checkstyle","https://github.com/terraform-linters/tflint",void 0,void 0,[0,2]),c("cmake-lint",["cmake"],["cmake-lint"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-lint","{file}"],"regex","https://cmake-format.readthedocs.io/","^(?<file>.+?):(?<line>\\d+),(?<column>\\d+): \\[(?<code>(?<severity>[A-Z])\\d+)\\] (?<message>.*)$",void 0,[0,1],0,["CMakeLists.txt"]),c("htmlhint",["html"],["htmlhint"],[".htmlhintrc"],[".html",".htm"],["htmlhint","--format","checkstyle","--nocolor","{file}"],"checkstyle","https://htmlhint.com/"),c("jsonlint",["json"],["jsonlint"],[".jsonlintrc",".jsonlintrc.json",".jsonlintrc.yaml",".jsonlintrc.yml",".jsonlintrc.js",".jsonlintrc.cjs","jsonlint.config.js","jsonlint.config.cjs"],[".json"],["jsonlint","-q","{file}"],"regex","https://github.com/prantlf/jsonlint","^(?:Error: )?(?<message>Parse (?<severity>error) on line (?<line>\\d+)(?:, column (?<column>\\d+))?:[^\\n]*)$",["@prantlf/jsonlint","jsonlint"]),c("taplo-check",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","check","--colors","never","{file}"],"regex","https://taplo.tamasfe.dev/","^(?<severity>error): (?<message>[^\\n]+)\\n\\s*\u250C\u2500 (?<file>.+):(?<line>\\d+):(?<column>\\d+)"),c("xmllint",["xml"],["xmllint"],[".xmllintrc"],[".xml",".xsd",".xsl"],["xmllint","--noout","{file}"],"regex","https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html","^(?<file>.+?):(?<line>\\d+): (?<severity>(?:parser |validity )?(?:error|warning)) : (?<message>.*)$",void 0,[0,1,2,3,4])];function c(t,e,n,i,r,f,s,l,o,d,x=[0,1],u,h){return{id:t,name:t,kind:"linter",languages:e,executables:n,configFiles:i,documentation:l,...d&&{dependencies:d},linter:{extensions:r,...h&&{fileNames:h},check:{command:f,successExitCodes:x},diagnostics:{format:s,...o&&{pattern:o},...u!==void 0&&{columnBase:u}}}}}a(c,"recipe");import b from"node:path";import{fileURLToPath as Y}from"node:url";function M(t,e){if(t.trim().length===0)return[];switch(e.format){case"pi-json":return V(t);case"eslint-json":return B(t);case"sarif":return G(t);case"checkstyle":return W(t);case"gcc":case"clang":return Z(t);case"regex":return H(t,g(e.pattern),e.columnBase??1)}}a(M,"parseDiagnostics");function V(t){let e=JSON.parse(t);return Array.isArray(e.diagnostics)?e.diagnostics.flatMap(y):[]}a(V,"parsePiJson");function B(t){return JSON.parse(t).flatMap(n=>Array.isArray(n.messages)?n.messages.flatMap(i=>y(i).map(r=>({...r,...n.filePath&&{file:n.filePath}}))):[])}a(B,"parseEslintJson");function G(t){return(JSON.parse(t).runs??[]).flatMap(n=>(n.results??[]).flatMap(i=>{let r=i.locations?.[0]?.physicalLocation,f=r?.region??{},s=i.message;return y({file:r?.artifactLocation?.uri,line:f.startLine,column:f.startColumn,message:s?.text,code:i.ruleId,severity:K(i.level)})}))}a(G,"parseSarif");function W(t){let e=[];for(let n of t.matchAll(/<file\s+([^>]+)>([\s\S]*?)<\/file>/gu)){let i=z(g(n[1])).name;for(let r of g(n[2]).matchAll(/<error\s+([^>]+?)\/?>(?:<\/error>)?/gu)){let f=z(g(r[1]));e.push(...y({file:i,line:Number(f.line),column:Number(f.column??1),message:f.message,code:f.source,severity:f.severity}))}}return e}a(W,"parseCheckstyle");function z(t){return Object.fromEntries([...t.matchAll(/([\w-]+)="([^"]*)"/gu)].map(e=>[g(e[1]),Q(g(e[2]))]))}a(z,"xmlAttributes");function Z(t){return U(t,/^(?<file>.+?):(?<line>\d+):(?<column>\d+):\s*(?<severity>fatal error|error|warning|note|info|hint):\s*(?<message>.*?)(?:\s+\[(?<code>[^\]]+)\])?$/u)}a(Z,"parseCompilerLines");function H(t,e,n){return[...t.replaceAll(`\r
2
- `,`
3
- `).matchAll(new RegExp(e,"gmu"))].flatMap(i=>i.groups===void 0?[]:y({...i.groups,...i.groups.column!==void 0&&{column:Number(i.groups.column)+(1-n)}}))}a(H,"parseRegexLines");function U(t,e){return t.split(/\r?\n/u).flatMap(n=>{let i=n.match(e)?.groups;return i===void 0?[]:y(i)})}a(U,"parseMatchingLines");function y(t){if(typeof t!="object"||t===null)return[];let e=t,n=_(e.line??e.startLine),i=_(e.column??e.startColumn,1),r=typeof e.message=="string"?e.message:void 0;return n===void 0||r===void 0?[]:[{...typeof e.file=="string"&&{file:e.file},code:q(e.code??e.ruleId,"lint"),message:r,line:n,column:i??1,severity:X(e.severity)}]}a(y,"normalizeDiagnostic");function _(t,e){let n=typeof t=="string"?Number.parseInt(t,10):t;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:e}a(_,"numberValue");function q(t,e){return typeof t=="string"||typeof t=="number"?String(t):e}a(q,"stringValue");function X(t){if(t===2)return"error";if(t===1)return"warning";let e=q(t,"warning").toLowerCase();return e.includes("error")||e==="e"||e==="f"||e==="fatal"?"error":e==="info"||e==="note"||e==="notice"?"info":e==="hint"?"hint":"warning"}a(X,"severityValue");function K(t){return t==="error"||t==="warning"||t==="note"?t:"warning"}a(K,"sarifSeverity");function Q(t){return t.replace(/&#(x[0-9a-f]+|\d+);/giu,(e,n)=>{let i=n.toLowerCase().startsWith("x")?Number.parseInt(n.slice(1),16):Number(n);return i<=1114111?String.fromCodePoint(i):e}).replaceAll("&quot;",'"').replaceAll("&apos;","'").replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&")}a(Q,"decodeXml");var m=class t{constructor(e,n,i=new Map){this.linters=e;this.availableBuiltIns=n;this.evidence=i}static{a(this,"LintCommandRegistry")}static async fromDirectory(e,n={}){let i=await D(e,"linters",o=>A(o).linters,n),r=n.environment??process.env,f=await Promise.all(i.entries.filter(o=>o.layer==="built-in").map(async o=>({id:o.id,available:await w(o.config.check,e,r)}))),s=await R(e,p),l=[...i.entries].sort((o,d)=>o.layer==="built-in"&&d.layer==="built-in"?(s.get(d.id)?.score??0)-(s.get(o.id)?.score??0):0);return new t(l,new Set(f.filter(o=>o.available&&(!n.requireBuiltInEvidence||(s.get(o.id)?.score??0)>0)).map(o=>o.id)),s)}static fromConfig(e){return new t(Object.entries(e.linters).map(([n,i])=>({id:n,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(e,n){return this.resolveEntry(e,n)?.config}resolveEntry(e,n){return $(this.linters,this.availableBuiltIns,this.evidence,e,n)}get entries(){return this.linters}};async function k(t,e){let n;try{n=await I(t.check,e)}catch(l){return{ok:!1,diagnostics:[],failure:`command could not start: ${l instanceof Error?l.message:String(l)}`}}let i=t.diagnostics.format==="regex"||t.diagnostics.format==="clang"?[n.stdout,n.stderr].filter(l=>l.trim().length>0).join(`
4
- `):n.stdout.trim().length>0?n.stdout:n.stderr,r;try{r=M(i,t.diagnostics)}catch{return{ok:!1,diagnostics:[],failure:`invalid ${t.diagnostics.format} diagnostics: ${i.trim().slice(0,200)||"empty command output"}`}}let f=n.ok&&(n.exitCode===0||r.length>0),s=t.check.cwd==="file"?b.dirname(e.filePath):e.projectRoot;return r=r.filter(l=>{if(l.file===void 0)return!0;let o=l.file.startsWith("file:")?Y(l.file):l.file;return b.resolve(s,o)===b.resolve(e.filePath)}).map(({file:l,...o})=>o),{ok:f,diagnostics:r,...!f&&{failure:n.stderr.trim().slice(0,200)||`command exited with code ${String(n.exitCode)}`}}}a(k,"runConfiguredLinter");function F(t){return{kind:"linter",name:"command-lint",priority:100,extensions:["*"],detect:a(()=>Promise.resolve(!0),"detect"),async lint({filePath:e,fix:n},i){let r=t.resolve(e,i.cwd);if(r===void 0)return{ok:!0,diagnostics:[]};let f=n===!0&&r.fix!==void 0?r.fix:r.check,s=await k({...r,check:f},{projectRoot:i.cwd,filePath:e});return{ok:s.ok,diagnostics:s.diagnostics}}}}a(F,"createCommandLinter");import{copyFile as ee,mkdtemp as te,rm as ne}from"node:fs/promises";import C from"node:path";var J={protocol:T,apiVersion:1,id:"lint",setup(t){for(let e of p)t.addToolRecipe(e);t.addSetupCheck({id:"effective-config",inspect:ie}),t.addCheck({id:"config",title:"Linter",async run(e){try{let n=await m.fromDirectory(e.cwd,{environment:e.env}),i=re(n,e.files,e.cwd);return i.length===0?[{status:"skip",message:"No linter matches the inspected project files"}]:await Promise.all(i.map(async({entry:r,source:f})=>{let s=`${r.id} [${r.layer}] command ${JSON.stringify(r.config.check.command)}`,l=await te(C.join(C.dirname(f),".pi-agent-ide-doctor-")),o=C.join(l,C.basename(f));try{await ee(f,o);let d=await k(r.config,{projectRoot:e.cwd,filePath:o,env:e.env});return d.ok?{status:"pass",message:`${s}: probe passed`,detail:r.sourcePath}:{status:"fail",message:`${s}: probe failed`,detail:d.failure??r.sourcePath}}catch(d){return{status:"fail",message:`${s}: ${d instanceof Error?d.message:String(d)}`,detail:r.sourcePath}}finally{await ne(l,{recursive:!0,force:!0})}}))}catch(n){return[{status:"fail",message:n instanceof Error?n.message:String(n)}]}}})}};async function ie(t){try{let e=await m.fromDirectory(t.cwd,{environment:t.env}),n=[],i=new Map;for(let[r,f]of t.detectedLanguages){let s=f.map(l=>e.resolveEntry(l,t.cwd)).find(l=>l!==void 0);s!==void 0&&(n.push({kind:"linter",languageId:r,toolId:s.id}),await w(s.config.check,t.cwd,t.env)||i.set(s.id,{id:`linter-${s.id}-unavailable`,message:`Configured linter ${s.id} cannot run ${JSON.stringify(s.config.check.command)}`}))}return{selections:n,actions:[...i.values()]}}catch(e){return{actions:[{id:"linter-config-invalid",message:`Linter configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}a(ie,"inspectLinterSetup");function re(t,e,n){let i=new Map;for(let r of e){let f=t.resolveEntry(r,n);f!==void 0&&!i.has(f.id)&&i.set(f.id,{entry:f,source:r})}return[...i.values()]}a(re,"applicableLinters");async function se(t){let e=new Map,n=a((s,l=!1)=>{let o=JSON.stringify([s,l]),d=e.get(o);return d===void 0&&(d=le(s,l),e.set(o,d)),d},"registryFor"),i=a(async(s,l)=>{let o=await S(l,s,"linters",p);return o===void 0?void 0:{projectRoot:o,external:o!==oe.resolve(l)}},"resolveProject"),r={kind:"linter",name:"pi-agent-ide-lint",priority:200,extensions:["*"],detect:a(async s=>(await n(s.cwd),!0),"detect"),async lint(s,l){let o=await i(s.filePath,l.cwd);if(o===void 0)return{ok:!0,diagnostics:[]};let d=await n(o.projectRoot,o.external);return F(d).lint(s,{cwd:o.projectRoot})}},f={protocol:j,apiVersion:4,id:"lint",setup(s){s.addTool(r),s.addDiagnosticSource({id:"lint",async diagnose(l,o){let d=await i(l,o.cwd);if(d===void 0)return{status:"unavailable",diagnostics:[],reason:"No local linter project found for this file"};let x=await n(d.projectRoot,d.external);o.signal.throwIfAborted();let u=x.resolve(l,d.projectRoot);if(!u)return{status:"unavailable",diagnostics:[],reason:"No linter configured for this file"};let h=E(u.check.command),v=await k(u,{projectRoot:d.projectRoot,filePath:l,signal:o.signal});return!v.ok&&v.diagnostics.length===0?{status:"unavailable",diagnostics:[],reason:v.failure??"Lint check failed",source:h}:{status:"ready",diagnostics:v.diagnostics,source:h}}})}};await Promise.all([L(t,f),O(t,J)])}a(se,"registerLint");async function le(t,e){let n=e?t:process.env.PI_AGENT_IDE_CONFIG_DIR??t;return m.fromDirectory(n,{includeGlobal:!e,requireBuiltInEvidence:e})}a(le,"loadRegistry");export{se as default};
1
+ import{a as p}from"./chunk-MGCHOGQD.js";import{a as n,b as c}from"./chunk-T6LX2RX5.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("dart","Dart",[".dart"],["pubspec.yaml","analysis_options.yaml"]),t("powershell","PowerShell",[".ps1",".psm1",".psd1"],["PSScriptAnalyzerSettings.psd1"]),t("r","R",[".r"],["DESCRIPTION",".lintr",".Rprofile"]),t("scala","Scala",[".scala",".sc"],["build.sbt","project.scala",".scalafmt.conf"]),t("elixir","Elixir",[".ex",".exs"],["mix.exs",".formatter.exs"]),t("zig","Zig",[".zig",".zon"],["build.zig","build.zig.zon","zls.json"]),t("julia","Julia",[".jl"],["Project.toml",".JuliaFormatter.toml"]),t("vue","Vue",[".vue"],["package.json"]),t("svelte","Svelte",[".svelte"],["svelte.config.js","svelte.config.ts"]),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(s,i,o,r,l,a){return{id:s,name:i,extensions:o,projectMarkers:r,...l&&{ast:l},...a&&{fileNames:a}}}e(t,"language");function g(s){return p(s,{protocol:n,apiVersion:1,id:"languages",setup(o){for(let r of m)o.addLanguage(r)}})}e(g,"registerLanguages");export{g as default};
package/dist/entry-33.js CHANGED
@@ -1,9 +1,4 @@
1
- import{a as xe}from"./chunk-MGCHOGQD.js";import{a as _e,b as ke}from"./chunk-T6LX2RX5.js";import"./chunk-NNCZYO4Q.js";import{d as Ie}from"./chunk-526E364R.js";import"./chunk-YHUTTZC6.js";import{a as Ee}from"./chunk-6CZO43OH.js";import{a as Ce,b as De}from"./chunk-OBNING2A.js";import{a as qe}from"./chunk-ZTYWHL2F.js";import{a as Te,b as Oe}from"./chunk-7UGNGK7Y.js";import{a as Ae}from"./chunk-L7JMDDSD.js";import{a as je,b as Me,d as $e}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import{a as D,b as E,c as $,d as k,j as me,k as fe,l as he}from"./chunk-NTYXZ3EL.js";import"./chunk-5VSE5X5R.js";import{a as be}from"./chunk-HKMBQLEK.js";import{a as ye,b as ve}from"./chunk-Z3VC3S2T.js";import"./chunk-KINKBPPX.js";import{b as Le,c as Se,g as Re,j as U,o as Pe}from"./chunk-M5MJP7Z2.js";import{a as we}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import{a as v}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import sr from"node:path";var A=[{id:"vue-typescript-language-server",name:"vue-typescript-language-server",kind:"lsp",languages:["vue"],executables:["typescript-language-server"],dependencies:["typescript-language-server","@vue/typescript-plugin"],configFiles:["tsconfig.json"],documentation:"https://github.com/vuejs/language-tools/tree/master/packages/typescript-plugin",lsp:{command:["typescript-language-server","--stdio"],rootMarkers:["tsconfig.json","package.json"],languageIds:{vue:[".vue"]},initializationOptions:{plugins:[{name:"@vue/typescript-plugin",location:"{project}/node_modules/@vue/typescript-plugin",languages:["vue"]}]}}},m("elixir-ls",["elixir"],["elixir-ls"],["mix.exs"],{elixir:[".ex",".exs"]},["elixir-ls"],"https://github.com/elixir-lsp/elixir-ls",void 0,void 0,{elixirLS:{mcpEnabled:!1}}),m("metals",["scala"],["metals"],["build.sbt","project.scala",".bsp"],{scala:[".scala",".sc"]},["metals"],"https://scalameta.org/metals/"),{id:"angular-language-server",name:"angular-language-server",kind:"lsp",languages:["typescript","html"],executables:["ngserver"],dependencies:["@angular/language-server"],configFiles:["angular.json"],documentation:"https://github.com/angular/vscode-ng-language-service",lsp:{command:["ngserver","--stdio","--tsProbeLocations",".","--ngProbeLocations","."],rootMarkers:["angular.json"],requireRootMarker:!0,languageIds:{typescript:[".ts"],html:[".html"]}}},m("svelte-language-server",["svelte"],["svelteserver"],["svelte.config.js","package.json"],{svelte:[".svelte"]},["svelteserver","--stdio"],"https://github.com/sveltejs/language-tools/tree/master/packages/language-server",["svelte-language-server"]),m("dart-language-server",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],{dart:[".dart"]},["dart","language-server","--protocol=lsp"],"https://dart.dev/tools/dart-language-server"),m("r-language-server",["r"],["Rscript"],["DESCRIPTION",".lintr",".Rprofile"],{r:[".r"]},["Rscript","-e","languageserver::run()"],"https://github.com/REditorSupport/languageserver"),m("zls",["zig"],["zls"],["build.zig","build.zig.zon","zls.json"],{zig:[".zig",".zon"]},["zls"],"https://zigtools.org/zls/"),m("clangd",["c","cpp"],["clangd"],[".clangd","compile_commands.json","CMakeLists.txt"],{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"]},["clangd"],"https://clangd.llvm.org/"),m("typescript-language-server",["javascript","typescript"],["typescript-language-server"],["tsconfig.json","jsconfig.json","package.json"],{javascript:[".js",".mjs",".cjs"],javascriptreact:[".jsx"],typescript:[".ts",".mts",".cts"],typescriptreact:[".tsx"]},["typescript-language-server","--stdio"],"https://github.com/typescript-language-server/typescript-language-server",["typescript-language-server"]),m("basedpyright",["python"],["basedpyright-langserver","pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),m("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),m("rust-analyzer",["rust"],["rust-analyzer"],["Cargo.toml","rust-project.json"],{rust:[".rs"]},["rust-analyzer"],"https://rust-analyzer.github.io/"),m("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),m("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),m("kotlin-language-server",["kotlin"],["kotlin-language-server"],["build.gradle.kts","pom.xml"],{kotlin:[".kt",".kts"]},["kotlin-language-server"],"https://github.com/fwcd/kotlin-language-server"),m("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),m("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),m("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),m("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),m("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),m("vscode-css-language-server",["css"],["vscode-css-language-server"],["package.json"],{css:[".css",".scss",".less"]},["vscode-css-language-server","--stdio"],"https://github.com/microsoft/vscode-css-languageservice",void 0,void 0,{css:{},scss:{},less:{}}),m("vscode-html-language-server",["html"],["vscode-html-language-server"],["package.json"],{html:[".html",".htm"]},["vscode-html-language-server","--stdio"],"https://github.com/microsoft/vscode-html-languageservice"),m("yaml-language-server",["yaml"],["yaml-language-server"],[".yamllint","package.json"],{yaml:[".yaml",".yml"]},["yaml-language-server","--stdio"],"https://github.com/redhat-developer/yaml-language-server"),m("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),m("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),m("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),m("kotlin-lsp",["kotlin"],["intellij-server"],["build.gradle.kts","build.gradle","pom.xml","settings.gradle.kts"],{kotlin:[".kt",".kts"]},["intellij-server","--stdio"],"https://github.com/Kotlin/kotlin-lsp"),m("julia-language-server",["julia"],["julia"],["Project.toml","JuliaProject.toml"],{julia:[".jl"]},["julia","--startup-file=no","--history-file=no","-e","using LanguageServer; runserver()"],"https://github.com/julia-vscode/LanguageServer.jl"),m("powershell-editor-services",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],{powershell:[".ps1",".psm1",".psd1"]},["pwsh","-NoProfile","-NonInteractive","-Command",'$ErrorActionPreference="Stop";Import-Module PowerShellEditorServices;$d=Join-Path (Get-Location) ".agents/tmp/powershell-lsp-$PID";[IO.Directory]::CreateDirectory($d)|Out-Null;Start-EditorServices -HostName Pi -HostProfileId Pi -HostVersion 1.0.0 -Stdio -LanguageServiceOnly -LogPath (Join-Path $d "server.log") -SessionDetailsPath (Join-Path $d "session.json")'],"https://github.com/PowerShell/PowerShellEditorServices"),m("neocmakelsp",["cmake"],["neocmakelsp"],["CMakeLists.txt",".neocmake.toml",".neocmakelint.toml"],{cmake:[".cmake"]},["neocmakelsp","stdio"],"https://github.com/neocmakelsp/neocmakelsp",void 0,{cmake:["CMakeLists.txt"]}),m("vscode-json-language-server",["json"],["vscode-json-language-server"],["package.json"],{json:[".json",".jsonc"]},["vscode-json-language-server","--stdio"],"https://github.com/microsoft/vscode-json-languageservice"),m("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),m("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),m("docker-langserver",["dockerfile"],["docker-langserver"],["Dockerfile"],{dockerfile:[".dockerfile"]},["docker-langserver","--stdio"],"https://github.com/rcjsuen/dockerfile-language-server-nodejs",void 0,{dockerfile:["Dockerfile","Containerfile"]})];function m(r,e,t,n,s,i,o,u,a,l){return{id:r,name:r,kind:"lsp",languages:e,executables:t,configFiles:n,documentation:o,...u&&{dependencies:u},lsp:{command:i,rootMarkers:n,languageIds:s,...a&&{fileNames:a},...l&&{settings:l}}}}c(m,"recipe");import St from"node:path";import Rt from"cross-spawn";import{createMessageConnection as Pt,CancellationTokenSource as _t,StreamMessageReader as kt}from"vscode-jsonrpc/node";import{URI as Ne}from"vscode-uri";import{watch as vt}from"node:fs";import{readdir as bt,stat as wt}from"node:fs/promises";import I from"node:path";import{URI as X}from"vscode-uri";var H=class{constructor(e,t,n){this.root=e;this.changed=t;this.failed=n}static{c(this,"LspFileWatchers")}registrations=new Map;disposed=!1;async register(e,t){let n=[];try{for(let s of t){let i=s.globPattern,o=typeof i=="string"?this.root:X.parse(typeof i.baseUri=="string"?i.baseUri:i.baseUri.uri).fsPath,u=typeof i=="string"?i:i.pattern,a=c(p=>I.matchesGlob(I.isAbsolute(u)?I.join(o,p):p,u),"matches"),l=new Set((await bt(o,{recursive:!0})).filter(a));if(this.disposed)throw new Error("Language server file watchers are disposed");let d=vt(o,{recursive:!0},(p,g)=>{!g||!a(g)||wt(I.join(o,g)).then(()=>{if(!this.registrations.get(e)?.includes(d))return;let h=l.has(g)?2:1;l.add(g),(s.kind??7)&(h===1?1:2)&&this.changed({uri:X.file(I.join(o,g)).toString(),type:h})},h=>{if(this.registrations.get(e)?.includes(d)){if(h.code!=="ENOENT"){this.failed(h);return}l.delete(g)&&(s.kind??7)&4&&this.changed({uri:X.file(I.join(o,g)).toString(),type:3})}})});d.on("error",this.failed),n.push(d)}}catch(s){for(let i of n)i.close();throw s}this.unregister(e),this.registrations.set(e,n)}unregister(e){for(let t of this.registrations.get(e)??[])t.close();this.registrations.delete(e)}dispose(){this.disposed=!0;for(let e of this.registrations.keys())this.unregister(e)}};import{StreamMessageWriter as Lt}from"vscode-jsonrpc/node";var G=class extends Lt{constructor(t,n){super(t);this.fail=n}static{c(this,"TransportWriter")}async write(t){try{await super.write(t)}catch(n){this.fail(n)}}};var x=class{static{c(this,"LspClient")}_process=null;_connection=null;_initialized=!1;_serverCapabilities=null;_disposed=!1;_crashed=!1;_stderr="";_fileWatchers;_handlers=new Map;_documentVersions=new Map;_documentContents=new Map;_diagnosticPublications=new Map;_diagnosticMode="unknown";_activeDiagnosticRequests=new Set;serverId;rootUri;_command;_args;_env;_initOptions;_settings;_timeoutMs;constructor(e){this.serverId=e.serverId,this.rootUri=e.rootUri,this._command=e.command,this._args=e.command.slice(1),this._env=e.env??{},this._initOptions=e.initOptions,this._settings=e.settings,this._timeoutMs=e.timeoutMs??3e4}get ready(){return this._initialized&&!this._disposed}get crashed(){return this._crashed}get pid(){return this._process?.pid??null}get commandName(){return Le(this._command)}get diagnosticMode(){return this._diagnosticMode}setDiagnosticMode(e){this._diagnosticMode=e}get timeoutMs(){return this._timeoutMs}supportsCommand(e){let t=this._serverCapabilities?.executeCommandProvider;return Array.isArray(t?.commands)&&t.commands.includes(e)}get hasFoldingRangeCapability(){let e=this._serverCapabilities?.foldingRangeProvider;return e===!0||typeof e=="object"&&e!==null}documentContent(e){return this._documentContents.get(e)}documentVersion(e){return this._documentVersions.get(e)}diagnosticPublication(e){return this._diagnosticPublications.get(e)}beginDiagnosticRequest(e){this._activeDiagnosticRequests.add(e)}endDiagnosticRequest(e){this._activeDiagnosticRequests.delete(e)}hasActiveDiagnosticRequest(e){return this._activeDiagnosticRequests.has(e)}async start(){if(this._initialized)return;if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let e=v(this._command[0]),t=Ne.parse(this.rootUri).fsPath,n=[{uri:this.rootUri,name:St.basename(t)||t}],s=Rt(e,this._args,{stdio:["pipe","pipe","pipe"],cwd:t,env:Pe({command:this._command,env:this._env},t,process.env)});this._process=s;let i=xt(s);s.stdin?.on("error",()=>{}),s.stdout?.on("error",()=>{}),s.stderr?.on("error",()=>{}),this._stderr="",s.stderr?.setEncoding("utf8"),s.stderr?.on("data",a=>{this._stderr=(this._stderr+a).slice(-4096)}),s.on("error",a=>{("code"in a?a.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,a),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null}),s.on("exit",(a,l)=>{this._fileWatchers?.dispose(),!this._disposed&&a!==0&&a!==null&&(this._crashed=!0),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1}),await i;let o=Pt(new kt(v(s.stdout)),new G(v(s.stdin),a=>{this._connection!==o||this._disposed||(this._crashed=!0,this._initialized=!1,this._fileWatchers?.dispose(),o.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,a))}));this._connection=o,this._connection.onError(a=>{console.error(`[lsp] ${this.serverId}: connection error:`,a)}),this._fileWatchers=new H(t,a=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[a]})},a=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,a)),this._connection.onRequest("client/registerCapability",async a=>{for(let l of a.registrations)if(l.method!=="workspace/didChangeConfiguration"){if(l.method!=="workspace/didChangeWatchedFiles")throw new Error(`Unsupported dynamic capability: ${l.method}`);await this._fileWatchers?.register(l.id,l.registerOptions?.watchers??[])}return null}),this._connection.onRequest("client/unregisterCapability",a=>{for(let l of a.unregisterations)this._fileWatchers?.unregister(l.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/configuration",a=>a.items.map(l=>{let d=this._settings??null;for(let p of l.section?.split(".").filter(Boolean)??[])d=typeof d=="object"&&d!==null?d[p]??null:null;return d})),this._connection.listen(),this._connection.onNotification((a,...l)=>{if(a==="textDocument/publishDiagnostics"){let d=l[0];d&&typeof d.uri=="string"&&Array.isArray(d.diagnostics)&&this._documentVersions.has(d.uri)&&(d.version===void 0||d.version===this.documentVersion(d.uri))&&this._diagnosticPublications.set(d.uri,{diagnostics:d.diagnostics,...typeof d.version=="number"&&{version:d.version}})}for(let d of this._handlers.get(a)??[])d(l[0])}),this._connection.onRequest("workspace/workspaceFolders",()=>n);let u=await Ve(this._connection.sendRequest("initialize",{processId:process.pid,rootUri:this.rootUri,workspaceFolders:n,capabilities:{workspace:{applyEdit:!1,configuration:!0,workspaceFolders:!0,didChangeWatchedFiles:{dynamicRegistration:!0,relativePatternSupport:!0},symbol:{dynamicRegistration:!1}},textDocument:{synchronization:{didOpen:!0,didChange:!0,didClose:!0},publishDiagnostics:{relatedInformation:!0},diagnostic:{dynamicRegistration:!1,relatedDocumentSupport:!1},documentSymbol:{hierarchicalDocumentSymbolSupport:!0},foldingRange:{lineFoldingOnly:!0}}},initializationOptions:this._initOptions}),this._timeoutMs,`[lsp] ${this.serverId}: initialize timed out`).catch(a=>{let l=this._stderr.trim();throw l?new Error(`[lsp] ${this.serverId}: ${l}`,{cause:a}):a});if(await this._connection.sendNotification("initialized",{capabilities:u.capabilities}),this._settings!==void 0&&await this._connection.sendNotification("workspace/didChangeConfiguration",{settings:this._settings}),this._crashed)throw new Error(`[lsp] ${this.serverId}: transport failed during initialization`);this._initialized=!0,this._serverCapabilities=u.capabilities,this._diagnosticMode=u.capabilities.diagnosticProvider?"pull":"push"}touch(){}async restart(){this._fileWatchers?.dispose(),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1,this._crashed=!1,this._disposed=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null,await this.start()}async sendRequest(e,t,n){if(this._assertReady(),n?.throwIfAborted(),!n)return v(this._connection).sendRequest(e,t);let s=new _t,i;try{let o=v(this._connection).sendRequest(e,t,s.token);return await Promise.race([o,new Promise((u,a)=>{i=c(()=>{s.cancel(),a(n.reason)},"onAbort"),n.addEventListener("abort",i,{once:!0})})])}finally{i&&n.removeEventListener("abort",i),s.dispose()}}sendNotification(e,t){this._assertReady(),this._sendNotification(e,t)}_sendNotification(e,t){let n=this._connection;n&&n.sendNotification(e,t).catch(s=>{this._connection!==n||this._disposed||(this._crashed=!0,this._initialized=!1,this._fileWatchers?.dispose(),n.dispose(),console.error(`[lsp] ${this.serverId}: notification ${e} failed:`,s))})}onNotification(e,t){let n=this._handlers.get(e)??[];return n.push(t),this._handlers.set(e,n),()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}toUri(e){return e.startsWith("file://")?e:Ne.file(e).toString()}openDocument(e,t,n,s=1){let i=this._documentVersions.get(e);if(i!==void 0){this.changeDocument(e,t,Math.max(s,i+1));return}this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:n,version:s,text:t}}),this._documentVersions.set(e,s),this._documentContents.set(e,t)}syncDocument(e,t,n,s=!1){if(this._documentContents.get(e)===t)return;let i=this._documentVersions.get(e);i===void 0?this.openDocument(e,t,n):this.changeDocument(e,t,i+1);let o=this._serverCapabilities?.textDocumentSync,u=typeof o=="object"&&o!==null?o.save:void 0;s&&u&&this.sendNotification("textDocument/didSave",{textDocument:{uri:e},...typeof u=="object"&&u.includeText&&{text:t}})}changeDocument(e,t,n){let s=this._documentVersions.get(e),i=Math.max(n,(s??0)+1);this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didChange",{textDocument:{uri:e,version:i},contentChanges:[{text:t}]}),this._documentVersions.set(e,i),this._documentContents.set(e,t)}closeDocument(e){this.sendNotification("textDocument/didClose",{textDocument:{uri:e}}),this._documentVersions.delete(e),this._documentContents.delete(e),this._diagnosticPublications.delete(e)}async shutdown(){if(!this._disposed){if(this._disposed=!0,this._fileWatchers?.dispose(),this._connection&&this._initialized)try{await Ve(this._connection.sendRequest("shutdown"),Math.min(this._timeoutMs,1e3),`[lsp] ${this.serverId}: shutdown timed out`),await this._connection.sendNotification("exit").catch(()=>{})}catch{}this._connection?.dispose(),this._connection=null,this._process&&!this._process.killed&&(this._process.kill("SIGTERM"),setTimeout(()=>{this._process&&!this._process.killed&&this._process.kill("SIGKILL")},2e3).unref()),this._initialized=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null}}dispose(){this.shutdown()}_assertReady(){if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);if(this._crashed)throw new Error(`[lsp] ${this.serverId}: crashed \u2014 call restart()`);if(!this._initialized)throw new Error(`[lsp] ${this.serverId}: not started \u2014 call start()`);if(!this._connection)throw new Error(`[lsp] ${this.serverId}: connection lost`)}};function xt(r){return new Promise((e,t)=>{let n=c(()=>{r.off("spawn",s),r.off("error",i)},"cleanup"),s=c(()=>{n(),e()},"onSpawn"),i=c(o=>{n(),t(o)},"onError");r.once("spawn",s),r.once("error",i)})}c(xt,"waitForSpawn");function Ve(r,e,t){return new Promise((n,s)=>{let i=setTimeout(()=>{s(new Error(t))},e);r.then(o=>{clearTimeout(i),n(o)}).catch(o=>{clearTimeout(i),s(o instanceof Error?o:new Error(String(o)))})})}c(Ve,"withTimeout");import{readFile as We}from"node:fs/promises";import{URI as ze}from"vscode-uri";var T={Error:1,Warning:2,Information:3,Hint:4};var Fe={command:"typescript.tsserverRequest",async request(r,e,t){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async s=>{let i=await r.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[s,{file:e,includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},t);if(!Y(i)||i.success!==!0||!Array.isArray(i.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${s}`);return i.body.map(Ct)}))).flat()}};function B(r){return r.supportsCommand(Fe.command)?Fe:void 0}c(B,"completedDiagnosticAdapter");function Ct(r){if(!Y(r)||typeof r.message!="string"||typeof r.code!="number"&&typeof r.code!="string"||!Y(r.startLocation)||!Number.isInteger(r.startLocation.line)||!Number.isInteger(r.startLocation.offset)||Number(r.startLocation.line)<1||Number(r.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(r.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(r.code),message:r.message,line:Number(r.startLocation.line),column:Number(r.startLocation.offset),severity:r.category==="error"?"error":r.category==="warning"?"warning":r.category==="suggestion"?"hint":"info"}}c(Ct,"convertTypeScriptDiagnostic");function Y(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}c(Y,"isRecord");async function O(r,e,t,n={}){let s=new AbortController,i=AbortSignal.any([s.signal,...n.signal?[n.signal]:[]]),o=setTimeout(()=>s.abort(new Error(`[lsp] ${r.serverId}: diagnostics timed out for ${e}`)),r.timeoutMs);try{return await Dt(r,e,t,n.content,i)}finally{clearTimeout(o)}}c(O,"requestDiagnostics");async function Dt(r,e,t,n,s){if(s.throwIfAborted(),r.diagnosticMode!=="push"){let a=r.documentVersion(e);try{let l=await r.sendRequest("textDocument/diagnostic",{textDocument:{uri:e}},s);if(l.kind!=="full"||!Array.isArray(l.items))throw new Error("Invalid full diagnostic report");if(r.documentVersion(e)!==a)throw new Error("Document changed during diagnostic request");return r.setDiagnosticMode("pull"),Ue(l.items,!1,!0)}catch(l){if(!Et(l))throw l;r.setDiagnosticMode("push")}}let i=B(r);if(i){r.documentVersion(e)===void 0&&r.syncDocument(e,n??await We(ze.parse(e).fsPath,"utf8"),t??"plaintext");let a=r.documentVersion(e),l=await i.request(r,e,s);if(s.throwIfAborted(),r.documentVersion(e)!==a)throw new Error("Document changed during diagnostic request");return{diagnostics:l,syntaxErrors:[],otherDiagnostics:l,unversioned:!1,complete:!0}}s.throwIfAborted();let o=r.documentVersion(e)!==void 0,u=o?void 0:n??await We(ze.parse(e).fsPath,"utf8");s.throwIfAborted(),r.beginDiagnosticRequest(e);try{return await new Promise((a,l)=>{let d=r.documentVersion(e)??1,p=c(f=>{let w=f;w.uri!==e||!Array.isArray(w.diagnostics)||w.version!==void 0&&w.version!==d||r.documentVersion(e)===d&&(y(),a(Ue(w.diagnostics,w.version===void 0)))},"receive"),g=r.onNotification("textDocument/publishDiagnostics",p),h=c(()=>{y(),l(s.reason)},"onAbort");function y(){g(),s.removeEventListener("abort",h)}c(y,"cleanup"),s.addEventListener("abort",h,{once:!0});try{o||r.syncDocument(e,u??"",t??"plaintext");let f=r.diagnosticPublication(e);f&&p({uri:e,...f})}catch(f){y(),l(f)}})}finally{r.endDiagnosticRequest(e)}}c(Dt,"requestCurrentDiagnostics");function Q(r){return{code:String(r.code??"LSP"),message:r.message,line:r.range.start.line+1,column:r.range.start.character+1,severity:r.severity===T.Warning?"warning":r.severity===T.Information?"info":r.severity===T.Hint?"hint":"error"}}c(Q,"toDiagnostic");function Ue(r,e,t=!1){let n=r.map(Q);return{diagnostics:n,syntaxErrors:[],otherDiagnostics:n,unversioned:e,complete:t}}c(Ue,"classify");function Et(r){return r!==null&&typeof r=="object"&&"code"in r&&r.code===-32601}c(Et,"isMethodNotFound");var It={1:"File",2:"Module",3:"Namespace",4:"Package",5:"Class",6:"Method",7:"Property",8:"Field",9:"Constructor",10:"Enum",11:"Interface",12:"Function",13:"Variable",14:"Constant",15:"String",16:"Number",17:"Boolean",18:"Array",19:"Object",20:"Key",21:"Null",22:"EnumMember",23:"Struct",24:"Event",25:"Operator",26:"TypeParameter"};function P(r){return It[r]??`SymbolKind(${r})`}c(P,"symbolKindName");async function Z(r,e){return await r.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}})??[]}c(Z,"requestDocumentSymbols");async function ee(r,e,t=100){return(await r.sendRequest("workspace/symbol",{query:e})??[]).slice(0,t)}c(ee,"requestWorkspaceSymbols");async function te(r,e,t,n){return await r.sendRequest("textDocument/rename",{textDocument:{uri:e},position:t,newName:n})}c(te,"requestRename");import S from"node:path";import{URI as At}from"vscode-uri";import{readdir as jt,stat as Mt}from"node:fs/promises";import q from"node:path";import{URI as re}from"vscode-uri";function He(r,e){let t=c(n=>typeof n=="string"?n.replaceAll("{project}",()=>e):Array.isArray(n)?n.map(t):n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([s,i])=>[s,t(i)])):n,"expand");return Object.fromEntries(Object.entries(r).map(([n,s])=>[n,t(s)]))}c(He,"resolveInitializationOptions");var C=class r{constructor(e){this._registry=e}static{c(this,"LspManager")}_clients=new Map;_clientStarts=new Map;_openDocs=new Set;_pushUnsubscribers=new Map;_pushHandlers=new Set;_pushFingerprints=new Map;_disposed=!1;static _instance=null;static getInstance(){if(!r._instance)throw new Error("[lsp] LspManager not initialized");return r._instance}static getInstanceOrNull(){return r._instance}static init(e){let t=r._instance;return t?._disposed?(t._registry=e,t._disposed=!1,t):(r._instance=new r(e),r._instance)}static async resetForTest(){r._instance&&(await r._instance.shutdownAll(),r._instance=null)}get clientCount(){return this._clients.size}onPushDiagnostics(e){return this._pushHandlers.add(e),()=>this._pushHandlers.delete(e)}async getOrStart(e,t,n){if(this._disposed)return null;let s=this._registry.resolve(e),i=n==="symbols"?s[0]:s.find(p=>p.config.capabilities.includes(n));if(!i)return null;let o=re.file(t).toString(),u=`${i.serverId}:${o}`,a=this._clientStarts.get(u);if(a)return a;let l=this._clients.get(u);if(l?.ready)return l;let d=this._startClient(u,o,i,l);this._clientStarts.set(u,d);try{return await d}finally{this._clientStarts.get(u)===d&&this._clientStarts.delete(u)}}async _startClient(e,t,n,s){let i=s??new x({serverId:n.serverId,rootUri:t,command:n.config.command,...n.config.env&&{env:n.config.env},...n.config.initializationOptions&&{initOptions:He(n.config.initializationOptions,re.parse(t).fsPath)},...n.config.settings&&{settings:n.config.settings},...n.config.timeoutMs&&{timeoutMs:n.config.timeoutMs}});try{s?await s.restart():await i.start()}catch(o){throw await i.shutdown().catch(()=>{}),o}if(this._disposed)throw await i.shutdown(),new Error(`[lsp] ${n.serverId}: manager disposed during startup`);return this._clients.set(e,i),this._subscribeToPushDiagnostics(e,i),i}async getWorkspaceClients(e,t="symbols",n=e){let s=new Set,i=new Set(this._registry.knownExtensions),o=new Set([".git",".cache","node_modules","dist","build"]),u=c(async l=>{if(i.size===0)return;let d;try{d=await jt(l,{withFileTypes:!0})}catch{return}for(let p of d){if(i.size===0)return;if(p.isDirectory()){o.has(p.name)||await u(q.join(l,p.name));continue}if(!p.isFile())continue;let g=q.extname(p.name).toLowerCase();if(!i.has(g))continue;let h=q.join(l,p.name),y=await this.openFile(h,e,t).catch(()=>null);y&&(s.add(y.client),i.delete(g))}},"visit"),a=q.resolve(e,n);if((await Mt(a)).isFile()){let l=await this.openFile(a,e,t);return l===null?[]:[l.client]}return await u(a),[...s]}async prepareWorkspaceSymbols(e,t=e){return this.getWorkspaceClients(e,"symbols",t)}hasServerFor(e){return this._registry.resolve(e).length>0}languageId(e){return this._registry.languageId(e)}isOpen(e){return this._openDocs.has(e)}async openFile(e,t,n="diagnostics"){let s=q.resolve(t,e),i=await this.getOrStart(s,t,n);if(!i)return null;let o=i.toUri(s),a=this._registry.resolve(s)[0]?.languageId??"plaintext";try{let{readFile:l}=await import("node:fs/promises"),d=await l(s,"utf8");i.openDocument(o,d,a),this._openDocs.add(o)}catch{}return{client:i,uri:o,languageId:a}}_subscribeToPushDiagnostics(e,t){if(this._pushUnsubscribers.has(e))return;let n=t.onNotification("textDocument/publishDiagnostics",s=>{let i=$t(s);if(!i||t.hasActiveDiagnosticRequest(i.uri))return;let o=t.documentVersion(i.uri);if(i.version!==void 0&&o!==void 0&&i.version<o)return;let u=`${e}:${i.uri}`,a=i.diagnostics.map(Q),l=JSON.stringify([i.version,o,a]);if(this._pushFingerprints.get(u)===l)return;this._pushFingerprints.set(u,l);let d={cwd:re.parse(t.rootUri).fsPath,serverId:t.serverId,uri:i.uri,diagnostics:a,...i.version!==void 0&&{version:i.version}};for(let p of this._pushHandlers)p(d)});this._pushUnsubscribers.set(e,n)}async shutdownAll(){this._disposed=!0,await Promise.allSettled(this._clientStarts.values());let e=[...this._clients.values()];await Promise.all(e.map(t=>t.shutdown()));for(let t of this._pushUnsubscribers.values())t();this._pushUnsubscribers.clear(),this._clientStarts.clear(),this._pushFingerprints.clear(),this._pushHandlers.clear(),this._clients.clear()}dispose(){this.shutdownAll()}};function $t(r){if(r===null||typeof r!="object")return;let e=r;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}c($t,"parsePushNotification");async function N(r,e,t){return await r.sendRequest("textDocument/references",{textDocument:{uri:e},position:t,context:{includeDeclaration:!0}})??[]}c(N,"requestReferences");async function ne(r,e,t){let n=await r.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:t}),s=n?.[0];if(!s)return{items:[],incoming:[],outgoing:[]};let[i,o]=await Promise.all([r.sendRequest("callHierarchy/incomingCalls",{item:s}).catch(()=>[]),r.sendRequest("callHierarchy/outgoingCalls",{item:s}).catch(()=>[])]);return{items:n,incoming:i??[],outgoing:o??[]}}c(ne,"requestCallHierarchy");function Ge(r,e,t){let n=S.relative(S.resolve(e,t.path??"."),r);if(n===".."||n.startsWith(`..${S.sep}`)||S.isAbsolute(n))return!1;let s=S.relative(e,r).split(S.sep).join("/"),i=c(o=>o.split(",").some(u=>{let a=u.trim();return a.length>0&&S.matchesGlob(a.includes("/")?s:S.basename(r),a)}),"matches");return(t.include===void 0||i(t.include))&&(t.exclude===void 0||!i(t.exclude))}c(Ge,"withinScope");function J(r){try{return At.parse(r).fsPath}catch{return r.startsWith("file://")?decodeURIComponent(r.slice(7)):r}}c(J,"uriToFilePath");function Be(r,e,t,n,s){let i=J(t),o=S.relative(r,i);return{filePath:o.startsWith("..")?i:o,lineNumber:n+1,column:s+1,kind:String(e.kind),name:e.name}}c(Be,"toHit");async function se(r,e,t,n,s={},i=C.getInstance()){if(n?.aborted)throw new Error("Operation aborted");let o=await i.prepareWorkspaceSymbols(e,s.path??e),u=[];for(let d of o){if(n?.aborted)throw new Error("Operation aborted");try{u.push(...await ee(d,r,Number.MAX_SAFE_INTEGER))}catch{}}let a=new Set,l=[];for(let d of u){if(n?.aborted)throw new Error("Operation aborted");if(l.length>=t)break;let p=d.location,g=Be(e,d,p.uri,p.range.start.line,p.range.start.character),h=`${g.filePath}:${g.lineNumber}:${g.column}`;if(Ge(J(p.uri),e,s)&&!a.has(h)&&(a.add(h),l.push(g)),l.length>=t)break;let y=J(p.uri),f=await i.openFile(y,e,"symbols").catch(()=>null);if(!f)continue;let w=await N(f.client,f.uri,p.range.start).catch(()=>[]);for(let R of w){let z=Be(e,d,R.uri,R.range.start.line,R.range.start.character),ge=`${z.filePath}:${z.lineNumber}:${z.column}`;if(Ge(J(R.uri),e,s)&&!a.has(ge)&&(a.add(ge),l.push(z)),l.length>=t)break}}return l}c(se,"searchSymbols");import{readFile as V}from"node:fs/promises";import j from"node:path";import{fileURLToPath as Tt}from"node:url";var Ot={failureLabel:"SYMBOL_READ_FAILED",emptyReason:"no symbol source was produced."},ie=10,oe=5,M=10;async function Xe(r,e,t,n,s){L(s);let i=await V(e,"utf8"),o=await W(r,e,n),u=F(o.symbols,t,o.displayPath),a=await V(o.filePath,"utf8");if(L(s),i!==a)throw new Error("The symbol source changed during resolution. Read it again before editing.");return{source:o.filePath,range:u.range,content:a}}c(Xe,"resolveLspDeclaration");async function Ye(r,e,t,n,s){L(s);let i=await V(e,"utf8"),o=await W(r,e,n),u=F(o.symbols,t,o.displayPath);if(i!==await V(e,"utf8"))throw new Error("The rename source changed during resolution.");return L(s),{client:o.client,uri:o.uri,position:u.selectionRange.start,content:i}}c(Ye,"resolveLspRenameTarget");async function le(r,e,t,n,s){L(s);let i=await W(r,e,n),o=F(i.symbols,t,i.displayPath),u=await zt(i.filePath);L(s);let a=o.range.start.line+1,l=Math.min(o.range.end.line+1,u.lines.length),d=u.lines.slice(Math.max(0,a-1),Math.max(0,l)).map((g,h)=>{let y=a+h;return me({content:g,sourceLine:{source:i.filePath,lineNumber:y,content:g}})}),p={path:i.displayPath,heading:`symbol: ${k(o.selector)}`,details:[`defined in: ${i.displayPath}:${a}-${l} (${P(o.kind)})`],startLine:a,endLine:l,totalLines:u.lines.length,renderedLines:d};return fe([p],Ot)}c(le,"readLspSymbolBody");async function de(r,e,t,n,s){L(s);let i=await W(r,e,n),o=F(i.symbols,t,i.displayPath),u=await tt(i,o,s),a=new K(n);return await qt(i,o,u,a)}c(de,"readLspSymbolGraph");async function ue(r,e,t,n){L(n);let s=await W(r,e,t),i=new K(t),o=[`## file graph: ${s.displayPath}`,`Top-level declarations: ${s.symbols.length}`];for(let u of s.symbols){L(n);let a=await tt(s,u,n);o.push("",...await Wt(s,u,a,i))}return o.join(`
2
- `)}c(ue,"readLspFileGraph");function F(r,e,t){if(e.length===0)throw new TypeError("A symbol selector must contain at least one segment.");if(e.length===1){let i=et(r,v(e[0]));if(i.length===1)return v(i[0]);throw i.length>1?new Error(`Symbol selector "${k(e)}" is ambiguous in ${t}; use parent/child.`):Je(e,t)}let n=r,s;for(let i of e){let o=n.filter(u=>u.name===i);if(o.length===0)throw Je(e,t);if(o.length>1)throw new Error(`Symbol selector "${k(e)}" is ambiguous at "${i}" in ${t}.`);s=v(o[0]),n=s.children}return v(s)}c(F,"resolveLspCodeSymbol");async function W(r,e,t){let n=j.isAbsolute(e)?j.normalize(e):j.resolve(t,e),s=await r.openFile(n,t,"symbols");if(!s)throw new Error(`No LSP server with symbol support is configured for ${ce(n,t)}.`);let i=await Z(s.client,s.uri),o=Qe(i).sort(Ze);return{client:s.client,uri:s.uri,filePath:n,displayPath:ce(n,t),symbols:o}}c(W,"openCodeDocument");function Qe(r,e=[]){return r.flatMap(t=>{let n=t.selectionRange??t.range;if(!n)return[];let s=t.range??n,i=[...e,t.name];return[{name:t.name,kind:t.kind,range:s,selectionRange:n,selector:i,children:Qe(t.children??[],i).sort(Ze)}]})}c(Qe,"normalizeDocumentSymbols");function Ze(r,e){return r.range.start.line-e.range.start.line||r.range.start.character-e.range.start.character||r.name.localeCompare(e.name)}c(Ze,"compareSymbols");function et(r,e){return r.flatMap(t=>[...t.name===e?[t]:[],...et(t.children,e)])}c(et,"collectNamedSymbols");function Je(r,e){return new Error(`Symbol "${k(r)}" was not found in ${e}.`)}c(Je,"symbolNotFound");async function tt(r,e,t){let n=e.selectionRange.start,[s,i]=await Promise.all([Ke(N(r.client,r.uri,n),[],t),Ke(ne(r.client,r.uri,n),{items:[],incoming:[],outgoing:[]},t)]);return L(t),{references:s,calls:i}}c(tt,"queryRelations");async function Ke(r,e,t){try{let n=await r;return L(t),n}catch(n){if(t?.aborted===!0)throw nt(t,n);return e}}c(Ke,"optionalRequest");async function qt(r,e,t,n){let s=k(e.selector),i=await n.line(r.uri,e.selectionRange.start.line+1);return[`## graph: ${s}`,`Definition: ${r.displayPath} ${i} (${P(e.kind)})`,`Source: ${$("graph",r.displayPath,e.selector)}`,"",...await Nt(t.references,n),"",...await Vt(t.calls.incoming,n),"",...await Ft(t.calls.outgoing,n)].join(`
3
- `)}c(qt,"formatSymbolGraph");async function Nt(r,e){let t=rt(r),n=[`References: ${r.length} in ${t.length} file(s)`];for(let[s,i]of t.slice(0,ie)){n.push(`- ${e.display(s)} (${i.length})`);for(let o of i.slice(0,oe))n.push(` - ${await e.line(s,o.range.start.line+1)}`);i.length>oe&&n.push(` - ... ${i.length-oe} more`)}return t.length>ie&&n.push(`- ... ${t.length-ie} more file(s)`),n}c(Nt,"formatReferences");async function Vt(r,e){let t=[`Incoming calls: ${r.length}`];for(let n of r.slice(0,M)){let s=n.fromRanges[0]?.start.line??n.from.selectionRange.start.line,i=await e.line(n.from.uri,s+1);t.push(`- ${P(n.from.kind)} ${n.from.name} \u2014 ${e.display(n.from.uri)} ${i}`)}return r.length>M&&t.push(`- ... ${r.length-M} more`),t}c(Vt,"formatIncomingCalls");async function Ft(r,e){let t=[`Outgoing calls: ${r.length}`];for(let n of r.slice(0,M)){let s=await e.line(n.to.uri,n.to.selectionRange.start.line+1);t.push(`- ${P(n.to.kind)} ${n.to.name} \u2014 ${e.display(n.to.uri)} ${s}`)}return r.length>M&&t.push(`- ... ${r.length-M} more`),t}c(Ft,"formatOutgoingCalls");async function Wt(r,e,t,n){let s=P(e.kind),i=await n.line(r.uri,e.selectionRange.start.line+1),o=rt(t.references).map(([d,p])=>`${n.display(d)} (${p.length})`),u=t.calls.incoming.map(d=>`${d.from.name} (${n.display(d.from.uri)})`),a=t.calls.outgoing.map(d=>`${d.to.name} (${n.display(d.to.uri)})`),l=[`### ${s} ${e.name}`,`Selector: ${k(e.selector)}`,`Definition: ${i}`,`Used by: ${ae(o)}`,`Incoming calls: ${ae(u)}`,`Outgoing calls: ${ae(a)}`];if(e.children.length>0){l.push("Members:");for(let d of e.children){let p=$("graph",r.displayPath,d.selector);l.push(`- ${P(d.kind)} ${d.name} \u2014 ${p}`)}}return l}c(Wt,"formatFileGraphSymbol");function ae(r,e=5){if(r.length===0)return"none";let t=r.slice(0,e).join(", ");return r.length>e?`${t}, ... ${r.length-e} more`:t}c(ae,"summarize");function rt(r){let e=new Map;for(let t of r){let n=e.get(t.uri)??[];n.push(t),e.set(t.uri,n)}return[...e].map(([t,n])=>[t,n.sort((s,i)=>s.range.start.line-i.range.start.line||s.range.start.character-i.range.start.character)]).sort(([t],[n])=>t.localeCompare(n))}c(rt,"groupLocationsByUri");async function zt(r){let e=await V(r);if(e.byteLength>256*1024)throw new Error(`File exceeds the 262144-byte code-view limit: ${r}`);if(e.includes(0))throw new Error(`File appears to be binary and cannot be read as text: ${r}`);let t=e.toString("utf8").replaceAll(`\r
1
+ import{a as N}from"./chunk-MGCHOGQD.js";import{a as A,b as T}from"./chunk-T6LX2RX5.js";import{a as O}from"./chunk-K5G4FDXD.js";import{a as P}from"./chunk-HKMBQLEK.js";import{a as b,b as j}from"./chunk-Z3VC3S2T.js";import{b as R,c as E,g as S,i as D,j as w,k as $,n as I}from"./chunk-M5MJP7Z2.js";import{a as L}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import{a as g}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import se from"node:path";var p=[c("dart-analyze",["dart"],["dart"],["analysis_options.yaml","pubspec.yaml"],[".dart"],["dart","analyze","--format","machine","{file}"],"regex","https://dart.dev/tools/dart-analyze","^(?<severity>[^|]+)\\|[^|]+\\|(?<code>[^|]+)\\|(?<file>[^|]+)\\|(?<line>\\d+)\\|(?<column>\\d+)\\|\\d+\\|(?<message>.*)$",void 0,[0,1,2,3]),c("zig-ast-check",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","ast-check","{file}"],"gcc","https://ziglang.org/documentation/master/"),c("lintr",["r"],["Rscript"],[".lintr","DESCRIPTION"],[".r"],["Rscript","-e","print(lintr::lint(commandArgs(TRUE)[1]))","{file}"],"regex","https://lintr.r-lib.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[^:]+): \\[(?<code>[^\\]]+)\\] (?<message>.*)$"),c("clang-tidy",["c","cpp"],["clang-tidy"],[".clang-tidy","compile_commands.json"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-tidy","{file}"],"clang","https://clang.llvm.org/extra/clang-tidy/"),c("eslint",["javascript","typescript","vue","svelte"],["eslint"],["eslint.config.js","eslint.config.mjs","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts",".eslintrc",".eslintrc.json",".eslintrc.js",".eslintrc.cjs",".eslintrc.yaml",".eslintrc.yml"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".vue",".svelte"],["eslint","--format","json","{file}"],"eslint-json","https://eslint.org/docs/latest/",void 0,["eslint"]),c("oxlint",["javascript","typescript"],["oxlint"],[".oxlintrc.json",".oxlintrc.jsonc","oxlint.config.ts","oxlint.config.mts"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts"],["oxlint","--format","sarif","{file}"],"sarif","https://oxc.rs/docs/guide/usage/linter.html",void 0,["oxlint"]),c("ruff",["python"],["ruff"],["pyproject.toml","ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","check","--output-format","concise","{file}"],"regex","https://docs.astral.sh/ruff/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<code>\\S+) (?<message>.+)$",["ruff"]),c("golangci-lint",["go"],["golangci-lint"],[".golangci.yml",".golangci.yaml","go.mod"],[".go"],["golangci-lint","run","--output.text.path=","--output.checkstyle.path=stdout","--show-stats=false","./..."],"checkstyle","https://golangci-lint.run/"),c("clippy",["rust"],["cargo"],["Cargo.toml","clippy.toml"],[".rs"],["cargo","clippy","--message-format","short"],"gcc","https://doc.rust-lang.org/clippy/"),c("dotnet-format",["csharp"],["dotnet"],[".editorconfig","global.json"],[".cs"],["dotnet","format","--verify-no-changes","--include","{relativeFile}"],"regex","https://learn.microsoft.com/dotnet/core/tools/dotnet-format","^(?<file>.+)\\((?<line>\\d+),(?<column>\\d+)\\): (?<severity>error|warning) (?<code>[^:]+): (?<message>.*?)(?: \\[.*\\])?$",void 0,[0,2]),c("checkstyle",["java"],["checkstyle"],["checkstyle.xml","pom.xml"],[".java"],["checkstyle","-c","checkstyle.xml","-f","xml","{file}"],"checkstyle","https://checkstyle.org/"),c("detekt",["kotlin"],["detekt"],["detekt.yml","build.gradle.kts"],[".kt",".kts"],["detekt","--input","{file}","--config","detekt.yml"],"regex","https://detekt.dev/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<message>.*?) \\[(?<code>[^\\]]+)\\]$",void 0,[0,2]),c("rubocop",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--format","clang","{file}"],"regex","https://docs.rubocop.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?:\\[Correctable\\] )?(?<code>[^:]+): (?<message>.*)$"),c("phpcs",["php"],["phpcs"],["phpcs.xml","phpcs.xml.dist","composer.json"],[".php"],["phpcs","--report=checkstyle","{file}"],"checkstyle","https://github.com/PHPCSStandards/PHP_CodeSniffer",void 0,void 0,[0,1,2,3]),c("swiftlint",["swift"],["swiftlint"],[".swiftlint.yml","Package.swift"],[".swift"],["swiftlint","lint","--quiet","--reporter","checkstyle","{file}"],"checkstyle","https://github.com/realm/SwiftLint",void 0,void 0,[0,2]),c("scalafix",["scala"],["scalafix"],[".scalafix.conf"],[".scala",".sc"],["scalafix","--check","--files","{file}"],"gcc","https://scalacenter.github.io/scalafix/",void 0,void 0,[0,2,64,66]),c("credo",["elixir"],["mix"],["mix.exs",".credo.exs"],[".ex",".exs"],["mix","credo","--strict","--format","flycheck","--files-included","{file}"],"regex","https://hexdocs.pm/credo/","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?<message>.+)$",void 0,Array.from({length:32},(t,e)=>e)),c("psscriptanalyzer",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};Invoke-ScriptAnalyzer -Path $args[0] @options | ForEach-Object {"$($_.ScriptPath):$($_.Line):$($_.Column): $($_.Severity): $($_.Message) [$($_.RuleName)]"}',"{file}"],"regex","https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-scriptanalyzer","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>\\w+): (?<message>.+) \\[(?<code>[^\\]]+)\\]$",void 0,[0]),c("luacheck",["lua"],["luacheck"],[".luacheckrc"],[".lua"],["luacheck","--formatter","plain","--codes","--no-color","{file}"],"regex","https://github.com/lunarmodules/luacheck","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): \\((?<code>(?<severity>[WE])\\d+)\\) (?<message>.+)$",void 0,[0,1,2]),c("shellcheck",["shell"],["shellcheck"],[".shellcheckrc"],[".sh",".bash",".zsh"],["shellcheck","-f","gcc","{file}"],"gcc","https://www.shellcheck.net/"),c("stylelint",["css"],["stylelint"],["stylelint.config.js",".stylelintrc.json"],[".css",".scss",".sass",".less"],["stylelint","--formatter","compact","{file}"],"regex","https://stylelint.io/","^(?<file>.+): line (?<line>\\d+), col (?<column>\\d+), (?<severity>error|warning) - (?<message>.+) \\((?<code>[^)]+)\\)$",["stylelint"],[0,2]),c("yamllint",["yaml"],["yamllint"],[".yamllint",".yamllint.yml"],[".yaml",".yml"],["yamllint","-f","parsable","{file}"],"regex","https://yamllint.readthedocs.io/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): \\[(?<severity>[^\\]]+)\\] (?<message>.*?) \\((?<code>[^)]+)\\)$"),c("markdownlint",["markdown"],["markdownlint"],[".markdownlint.json",".markdownlint.yaml"],[".md",".mdx"],["markdownlint","{file}"],"regex","https://github.com/DavidAnson/markdownlint","^(?<file>.+?):(?<line>\\d+)(?::(?<column>\\d+))? (?<severity>error|warning) (?<code>MD\\d+)(?:/\\S+)? (?<message>.*)$"),c("sqlfluff",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","lint","--format","sarif","{file}"],"sarif","https://docs.sqlfluff.com/"),c("hadolint",["dockerfile"],["hadolint"],[".hadolint.yaml"],[".dockerfile"],["hadolint","--format","checkstyle","{file}"],"checkstyle","https://github.com/hadolint/hadolint",void 0,void 0,[0,1],void 0,["Dockerfile","Containerfile"]),c("tflint",["terraform"],["tflint"],[".tflint.hcl"],[".tf"],["tflint","--format","checkstyle"],"checkstyle","https://github.com/terraform-linters/tflint",void 0,void 0,[0,2]),c("cmake-lint",["cmake"],["cmake-lint"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-lint","{file}"],"regex","https://cmake-format.readthedocs.io/","^(?<file>.+?):(?<line>\\d+),(?<column>\\d+): \\[(?<code>(?<severity>[A-Z])\\d+)\\] (?<message>.*)$",void 0,[0,1],0,["CMakeLists.txt"]),c("htmlhint",["html"],["htmlhint"],[".htmlhintrc"],[".html",".htm"],["htmlhint","--format","checkstyle","--nocolor","{file}"],"checkstyle","https://htmlhint.com/"),c("jsonlint",["json"],["jsonlint"],[".jsonlintrc",".jsonlintrc.json",".jsonlintrc.yaml",".jsonlintrc.yml",".jsonlintrc.js",".jsonlintrc.cjs","jsonlint.config.js","jsonlint.config.cjs"],[".json"],["jsonlint","-q","{file}"],"regex","https://github.com/prantlf/jsonlint","^(?:Error: )?(?<message>Parse (?<severity>error) on line (?<line>\\d+)(?:, column (?<column>\\d+))?:[^\\n]*)$",["@prantlf/jsonlint","jsonlint"]),c("taplo-check",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","check","--colors","never","{file}"],"regex","https://taplo.tamasfe.dev/","^(?<severity>error): (?<message>[^\\n]+)\\n\\s*\u250C\u2500 (?<file>.+):(?<line>\\d+):(?<column>\\d+)"),c("xmllint",["xml"],["xmllint"],[".xmllintrc"],[".xml",".xsd",".xsl"],["xmllint","--noout","{file}"],"regex","https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html","^(?<file>.+?):(?<line>\\d+): (?<severity>(?:parser |validity )?(?:error|warning)) : (?<message>.*)$",void 0,[0,1,2,3,4])];function c(t,e,n,i,r,f,s,l,o,d,x=[0,1],u,h){return{id:t,name:t,kind:"linter",languages:e,executables:n,configFiles:i,documentation:l,...d&&{dependencies:d},linter:{extensions:r,...h&&{fileNames:h},check:{command:f,successExitCodes:x},diagnostics:{format:s,...o&&{pattern:o},...u!==void 0&&{columnBase:u}}}}}a(c,"recipe");import F from"node:path";import{fileURLToPath as ee}from"node:url";function M(t,e){if(t.trim().length===0)return[];switch(e.format){case"pi-json":return B(t);case"eslint-json":return G(t);case"sarif":return W(t);case"checkstyle":return Z(t);case"gcc":case"clang":return H(t);case"regex":return U(t,g(e.pattern),e.columnBase??1)}}a(M,"parseDiagnostics");function B(t){let e=JSON.parse(t);return Array.isArray(e.diagnostics)?e.diagnostics.flatMap(y):[]}a(B,"parsePiJson");function G(t){return JSON.parse(t).flatMap(n=>Array.isArray(n.messages)?n.messages.flatMap(i=>y(i).map(r=>({...r,...n.filePath&&{file:n.filePath}}))):[])}a(G,"parseEslintJson");function W(t){return(JSON.parse(t).runs??[]).flatMap(n=>(n.results??[]).flatMap(i=>{let r=i.locations?.[0]?.physicalLocation,f=r?.region??{},s=i.message;return y({file:r?.artifactLocation?.uri,line:f.startLine,column:f.startColumn,message:s?.text,code:i.ruleId,severity:Q(i.level)})}))}a(W,"parseSarif");function Z(t){let e=[];for(let n of t.matchAll(/<file\s+([^>]+)>([\s\S]*?)<\/file>/gu)){let i=z(g(n[1])).name;for(let r of g(n[2]).matchAll(/<error\s+([^>]+?)\/?>(?:<\/error>)?/gu)){let f=z(g(r[1]));e.push(...y({file:i,line:Number(f.line),column:Number(f.column??1),message:f.message,code:f.source,severity:f.severity}))}}return e}a(Z,"parseCheckstyle");function z(t){return Object.fromEntries([...t.matchAll(/([\w-]+)="([^"]*)"/gu)].map(e=>[g(e[1]),Y(g(e[2]))]))}a(z,"xmlAttributes");function H(t){return X(t,/^(?<file>.+?):(?<line>\d+):(?<column>\d+):\s*(?<severity>fatal error|error|warning|note|info|hint):\s*(?<message>.*?)(?:\s+\[(?<code>[^\]]+)\])?$/u)}a(H,"parseCompilerLines");function U(t,e,n){return[...t.replaceAll(`\r
4
2
  `,`
5
- `),n=t.endsWith(`
6
- `)?t.slice(0,-1):t,s=n.length===0?[]:n.split(`
7
- `);return{content:t,lines:s}}c(zt,"readTextFile");var K=class{static{c(this,"LocationPresenter")}#e;constructor(e){this.#e=e}display(e){return ce(Ut(e),this.#e)}line(e,t){return Promise.resolve(String(t))}};function Ut(r){if(!r.startsWith("file://"))return r;try{return Tt(r)}catch{return decodeURIComponent(r.slice(7))}}c(Ut,"filePathFromUri");function ce(r,e){let t=j.relative(e,r);return t.length===0||t.startsWith("..")||j.isAbsolute(t)?r:t.replaceAll(j.sep,"/")}c(ce,"displayFilePath");function L(r){if(r?.aborted===!0)throw nt(r)}c(L,"throwIfAborted");function nt(r,e){if(r.reason instanceof Error)return r.reason;if(e instanceof Error)return e;let t=new Error("The operation was aborted");return t.name="AbortError",t}c(nt,"abortReason");function pe(r){let e=null;return{kind:"compiler",name:"lsp",priority:100,extensions:["*"],detect:c(()=>Promise.resolve(!0),"detect"),async compile({filePath:t},n){let s=await Ht(t,n,r);if(!s)return Gt();let{client:i,diagnostics:o,syntaxErrors:u,otherDiagnostics:a}=s;return e=i,{ok:!o.some(l=>l.severity==="error"),diagnostics:o,syntaxErrors:u,otherDiagnostics:a}},async restart(){e&&(await e.restart(),e=null)}}}c(pe,"createLspCompiler");async function Ht(r,e,t){let n=await t.openFile(r,e.cwd);if(!n)return null;let s=await O(n.client,n.uri,n.languageId);return{client:n.client,...s}}c(Ht,"openAndDiagnose");function Gt(){return{ok:!0,diagnostics:[],syntaxErrors:[],otherDiagnostics:[]}}c(Gt,"skipOk");import b from"node:path";import{existsSync as Bt}from"node:fs";function st(r){let e=new Map,t=new Map;for(let[n,s]of Object.entries(r))for(let[i,o]of Object.entries(s.languages))for(let u of o.extensions){let a=u.toLowerCase(),l=e.get(a);if(l!==void 0&&l!==i)throw new Error(`[lsp] extension conflict: "${a}" claimed by "${l}" and "${i}"`);e.set(a,i);let d=t.get(a)??[];d.push(n),t.set(a,d)}return{extToLanguageId:e,extToServerIds:t}}c(st,"buildLanguageLookup");var _=class r{constructor(e,t,n){this._projectRoot=n;this._entries=e;let s=e.filter(i=>i.layer!=="built-in"||t.has(i.id));this._servers=Object.fromEntries(s.map(i=>[i.id,i.config])),this._lookup=st(this._servers)}static{c(this,"LspServerRegistry")}_servers;_entries;_lookup;static async fromPackageDir(e,t={}){let n=await Re(e,"lsp-servers",u=>Jt(u).servers,t),s=t.environment??process.env,i=await Promise.all(n.entries.filter(u=>u.layer==="built-in").map(async u=>({id:u.id,available:await U(u.config,e,s)}))),o=t.requireBuiltInEvidence?await we(e,t.recipes??[]):void 0;return new r(n.entries,new Set(i.filter(u=>u.available&&(o===void 0||(o.get(u.id)?.score??0)>0)).map(u=>u.id)),b.resolve(e))}static fromConfig(e,t=process.cwd()){return new r(Object.entries(e.servers).map(([n,s])=>({id:n,config:s,layer:"project",sourcePath:"<memory>"})),new Set,b.resolve(t))}resolve(e){let t=b.basename(e),n=b.extname(e)||(e.startsWith(".")?e:`.${e}`),s=c(o=>process.platform==="win32"?o.toLowerCase():o,"normalizeName"),i=[];for(let o of this._entries)if(this._servers[o.id]&&!(o.config.requireRootMarker&&!this.hasRootMarker(e,o.config.rootMarkers))){for(let[u,a]of Object.entries(o.config.languages))if(a.extensions.some(l=>l.toLowerCase()===n.toLowerCase())||a.fileNames?.some(l=>s(l)===s(t))){i.push({serverId:o.id,config:o.config,languageId:u,layer:o.layer,sourcePath:o.sourcePath});break}}return i}hasRootMarker(e,t){let n=b.dirname(b.resolve(this._projectRoot,e));for(e.startsWith(".")&&!e.includes(b.sep)&&(n=this._projectRoot);;){let s=b.relative(this._projectRoot,n);if(s===".."||s.startsWith(`..${b.sep}`)||b.isAbsolute(s))return!1;if(t.some(i=>Bt(b.join(n,i))))return!0;if(n===this._projectRoot)return!1;n=b.dirname(n)}}get servers(){return this._servers}get entries(){return this._entries}get knownExtensions(){return new Set(this._lookup.extToLanguageId.keys())}languageId(e){return this.resolve(e)[0]?.languageId??e.slice(1)}};function Jt(r){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error("LSP config must be an object");let e=r;if(e.version!==1)throw new Error("LSP config version must be 1");if(typeof e.servers!="object"||e.servers===null||Array.isArray(e.servers))throw new Error("LSP config servers must be an object");for(let[t,n]of Object.entries(e.servers)){if(typeof n!="object"||n===null||Array.isArray(n))throw new Error(`LSP server ${t} must be an object`);let s=n;if(!Array.isArray(s.command)||s.command.length===0||s.command.some(i=>typeof i!="string"||i.length===0))throw new Error(`LSP server ${t}.command must be a non-empty string array`);if(s.transport!==void 0&&s.transport!=="stdio")throw new Error(`LSP server ${t} only supports stdio transport`);if(!Array.isArray(s.rootMarkers)||s.rootMarkers.some(i=>typeof i!="string"))throw new Error(`LSP server ${t}.rootMarkers must be a string array`);if(s.requireRootMarker!==void 0&&typeof s.requireRootMarker!="boolean")throw new TypeError(`LSP server ${t}.requireRootMarker must be a boolean`);if(s.requireRootMarker&&s.rootMarkers.length===0)throw new Error(`LSP server ${t}.requireRootMarker requires rootMarkers`);if(typeof s.languages!="object"||s.languages===null||Array.isArray(s.languages))throw new Error(`LSP server ${t}.languages must be an object`);for(let[i,o]of Object.entries(s.languages)){let u=typeof o=="object"&&o!==null&&!Array.isArray(o)?o.extensions:void 0;if(!Array.isArray(u)||u.length===0||u.some(l=>typeof l!="string"))throw new Error(`LSP server ${t} language ${i} requires extensions`);let a=o.fileNames;if(a!==void 0&&(!Array.isArray(a)||a.some(l=>typeof l!="string"||l.length===0||/[/\\]/u.test(l))))throw new Error(`LSP server ${t} language ${i}.fileNames must contain basenames`)}if(!Array.isArray(s.capabilities))throw new TypeError(`LSP server ${t}.capabilities must be an array`)}return r}c(Jt,"parseLspConfig");function it(r){return at("symbol","lsp-symbol",r,async e=>await le(e.manager,e.filePath,v(e.selector),e.cwd,e.signal))}c(it,"createLspSymbolResolver");function ot(r){return at("graph","lsp-graph",r,async e=>e.selector===void 0?await ue(e.manager,e.filePath,e.cwd,e.signal):await de(e.manager,e.filePath,e.selector,e.cwd,e.signal))}c(ot,"createLspGraphResolver");function at(r,e,t,n){return{id:e,tryResolve(s,i){return Promise.resolve(Kt(s,i,r,t,n))}}}c(at,"createCodeViewResolver");function Kt(r,e,t,n,s){let i;try{i=D(r,t)}catch(a){return{kind:"failed",error:a}}if(i===void 0)return{kind:"not-handled"};let o;try{o=E(i.path,e.cwd)}catch(a){return{kind:"failed",error:a}}return{kind:"resolved",resource:{source:$(t,o,i.selector),async read(a){let l=await n(e.cwd),d=await s({manager:l,filePath:o,cwd:e.cwd,...Xt(i.selector),...Yt(a.signal)});return[typeof d=="string"?{type:"text",text:d}:d]}}}}c(Kt,"resolveCodeViewSource");function Xt(r){return r===void 0?{}:{selector:r}}c(Xt,"optionalSelector");function Yt(r){return r===void 0?{}:{signal:r}}c(Yt,"optionalSignal");function lt(r,e=(t,n)=>Promise.resolve({cwd:n,external:!1})){return{id:"lsp",async diagnose(t,n){let s=await e(t,n.cwd);if(s===void 0)return{status:"unavailable",diagnostics:[],reason:"No local language-server project found for this file"};let i=await r(s.cwd,s.external);n.signal.throwIfAborted();let o=await i.getOrStart(t,s.cwd,"diagnostics");if(n.signal.throwIfAborted(),!o)return{status:"unavailable",diagnostics:[],reason:"No language server configured for this file"};let u=o.toUri(t),a=i.languageId(t);o.syncDocument(u,n.content,a,!0);let l=o.documentVersion(u),d={active:!0,queued:!1},p=c(()=>!n.signal.aborted&&o.documentVersion(u)===l,"current"),g=c(()=>O(o,u,a,{signal:n.signal,content:n.content}),"request"),h=c(async()=>{if(d.queued=!0,!d.active){d.active=!0;try{for(;d.queued&&p();){d.queued=!1;let f=await g();p()&&n.publish(ct(f,o.commandName))}}catch(f){p()&&n.publish({status:"unavailable",diagnostics:[],reason:f instanceof Error?f.message:String(f),source:o.commandName})}finally{d.active=!1}}},"refresh"),y=i.onPushDiagnostics(f=>{!p()||f.uri!==u||f.serverId!==o.serverId||f.cwd!==s.cwd||f.version!==void 0&&f.version!==l||(o.diagnosticMode==="pull"||B(o)?h():n.publish({status:"snapshot",diagnostics:f.diagnostics,source:o.commandName,reason:dt(f.version===void 0)}))});n.signal.addEventListener("abort",y,{once:!0});try{let f=await g();return l=o.documentVersion(u),ct(f,o.commandName)}catch(f){throw d.queued=!1,y(),n.signal.removeEventListener("abort",y),f}finally{d.active=!1,d.queued&&p()&&queueMicrotask(()=>{h()})}}}}c(lt,"createLspDiagnosticSource");function dt(r){return`Latest push snapshot; completion is unknown${r?"; language server omitted the document version":""}`}c(dt,"snapshotReason");function ct(r,e){return r.complete?{status:"ready",diagnostics:r.diagnostics,source:e}:{status:"snapshot",diagnostics:r.diagnostics,reason:dt(r.unversioned),source:e}}c(ct,"toReport");import{URI as Qt}from"vscode-uri";var ut={protocol:_e,apiVersion:1,id:"lsp",setup(r){for(let e of A)r.addToolRecipe(e);r.addSetupCheck({id:"effective-config",inspect:Zt}),r.addCheck({id:"config",title:"LSP",async run(e){try{let t=await _.fromPackageDir(e.cwd,{environment:e.env}),n=er(t,e.files);return n.length===0?[{status:"skip",message:"No language server matches the inspected project files"}]:await Promise.all(n.map(async s=>{let i=`${s.serverId} [${s.layer}] command ${JSON.stringify(s.config.command)}`,o=new x({serverId:s.serverId,rootUri:Qt.file(e.cwd).toString(),command:s.config.command,env:tr(e.env,s.config.env),...s.config.initializationOptions&&{initOptions:s.config.initializationOptions},...s.config.settings&&{settings:s.config.settings},...s.config.timeoutMs&&{timeoutMs:s.config.timeoutMs}});try{return await o.start(),{status:"pass",message:`${i}: initialized`,detail:s.sourcePath}}catch(u){return{status:"fail",message:`${i}: ${u instanceof Error?u.message:String(u)}`,detail:s.sourcePath}}finally{await o.shutdown().catch(()=>{})}}))}catch(t){return[{status:"fail",message:t instanceof Error?t.message:String(t)}]}}})}};async function Zt(r){try{let e=await _.fromPackageDir(r.cwd,{environment:r.env}),t=[],n=new Map;for(let[s,i]of r.detectedLanguages){let o=i.flatMap(u=>e.resolve(u)).find(u=>u.languageId===s);o!==void 0&&(t.push({kind:"lsp",languageId:s,toolId:o.serverId}),await U(o.config,r.cwd,r.env)||n.set(o.serverId,{id:`lsp-${o.serverId}-unavailable`,message:`Configured language server ${o.serverId} cannot run ${JSON.stringify(o.config.command)}`}))}return{selections:t,actions:[...n.values()]}}catch(e){return{actions:[{id:"lsp-config-invalid",message:`Language server configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}c(Zt,"inspectLspSetup");function er(r,e){let t=new Map;for(let n of e){let s=r.resolve(n)[0];s!==void 0&&!t.has(s.serverId)&&t.set(s.serverId,s)}return[...t.values()]}c(er,"applicableServers");function tr(r,e){return Object.fromEntries(Object.entries({...r,...e}).filter(t=>t[1]!==void 0))}c(tr,"definedEnvironment");function pt(r){return{id:"symbols",async tryResolve(e,t){if(!e.query.startsWith("symbols:"))return{kind:"not-handled"};let n=e.query.slice(8).trim();if(n.length===0)return{kind:"failed",error:new Error("symbols: query must not be empty")};let s=await r(t.cwd),i=await se(n,t.cwd,e.limit??100,t.signal,e,s);return{kind:"resolved",payload:{query:n,hits:i}}},format(e){let{query:t,hits:n}=e;return{content:[{type:"text",text:n.length===0?"No symbols found.":n.map((i,o)=>`${String(o+1)}. ${i.filePath}:${String(i.lineNumber)}:${String(i.column)} ${i.kind} ${i.name}`).join(`
8
- `)}],details:{query:t,hits:n}}}}}c(pt,"createLspSearchResolver");function gt(r){return{id:"lsp-declaration-target",async tryResolve(e,t){let n=D(e,"symbol");if(n===void 0)return{kind:"not-handled"};if(n.selector===void 0)return{kind:"rejected",rejection:{code:"invalid",reason:"Use symbol:<file>#<selector> to choose one declaration"}};try{let s=await Xe(await r(t.cwd),E(n.path,t.cwd),n.selector,t.cwd,t.signal);return{kind:"resolved",targets:[{source:s.source,expectedContent:s.content,ranges:[{start:{lineNumber:s.range.start.line+1,column:s.range.start.character},end:{lineNumber:s.range.end.line+1,column:s.range.end.character}}]}]}}catch(s){return{kind:"failed",error:new Error(`${s instanceof Error?s.message:String(s)} Read the physical file and use explicit text anchors if declaration resolution is unavailable.`,{cause:s})}}}}}c(gt,"createDeclarationTargets");import{readFile as rr,stat as mt}from"node:fs/promises";import{fileURLToPath as nr}from"node:url";function ft(r,e){let t=r.split(`
9
- `),n=t[e.line];if(!Number.isInteger(e.line)||e.line<0||n===void 0||!Number.isInteger(e.character)||e.character<0||e.character>n.replace(/\r$/u,"").length)throw new Error("The language server returned an invalid text position.");return t.slice(0,e.line).reduce((s,i)=>s+i.length+1,0)+e.character}c(ft,"offset");async function ht(r,e){let t=r.input;if(typeof t.path!="string"||!t.path.startsWith("symbol:")||!t.path.endsWith("#name"))return;if(typeof t.text!="string"||t.text.trim()===""||t.start!==void 0||t.end!==void 0)throw new Error("Rename needs a symbol #name path and a non-empty new name in text, without start/end.");let n=D(t.path.slice(0,-5),"symbol");if(n?.selector===void 0)throw new Error("Rename needs an exact symbol selector before #name.");let s=E(n.path,r.cwd),i=await Ye(await e(r.cwd),s,n.selector,r.cwd,r.signal);if(i.client.supportsCommand("typescript.tsserverRequest")&&(await i.client.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:s,needFileNameList:!0},{isAsync:!1,expectsResult:!0}]}))?.success!==!0)throw new Error("TypeScript could not load the project for rename. No edits applied.");let o=Date.now(),u=await te(i.client,i.uri,i.position,t.text);if(r.signal?.throwIfAborted(),u===null)throw new Error("The language server did not provide rename edits. No text fallback was applied.");let a=new Map(Object.entries(u.changes??{}));for(let d of u.documentChanges??[]){if(!("textDocument"in d)||!("edits"in d))throw new Error("Rename returned a file operation that is not supported; no edits applied.");if(d.textDocument.version!=null&&d.textDocument.version!==i.client.documentVersion(d.textDocument.uri))throw new Error("Rename refers to an unavailable document revision. Refresh the source before retrying.");if(a.has(d.textDocument.uri))throw new Error("Rename returned duplicate document edits.");a.set(d.textDocument.uri,d.edits)}let l=[];for(let[d,p]of a){let g=nr(d),h=await mt(g),y=await rr(g,"utf8"),f=await mt(g),w=i.client.documentContent(d);if(w!==void 0&&w!==y)throw new Error("The language server has stale text for a rename target. Read that symbol again before retrying.");if(h.mtimeMs>o||h.mtimeMs!==f.mtimeMs||h.size!==f.size||g===s&&y!==i.content)throw new Error("A rename source changed during the language-server request. Retry from a fresh symbol read.");l.push({source:g,expectedContent:y,changes:p.map(R=>({from:ft(y,R.range.start),to:ft(y,R.range.end),insert:R.newText}))})}return{...r,editPlan:{files:l},metadata:{...r.metadata,semanticEdit:{mode:"lsp-rename",server:i.client.serverId,referencesUpdated:!0},diffStatuses:[{text:"Renamed through LSP",tone:"success"}]}}}c(ht,"prepareSymbolRename");var yt=Ie({kind:"code-view",label:"LSP"});async function ir(r){let e=new Map,t=!1,n=c((a,l=!1)=>{if(t)return Promise.reject(new Error("LSP session has ended"));let d=JSON.stringify([a,l]),p=e.get(d);return p||(p=or(a,l).then(g=>{if(t)throw new Error("LSP session has ended");return C.init(g)}),e.set(d,p)),p},"managerFor"),s=c(async(a,l)=>{let d=await Se(l,a,"lsp-servers",A);return d===void 0?void 0:{cwd:d,external:d!==sr.resolve(l)}},"resolveLspProject"),i={kind:"compiler",name:"pi-agent-ide-lsp",priority:200,extensions:["*"],detect:c(async a=>(await n(a.cwd),!0),"detect"),async compile(a,l){let d=await n(l.cwd);return pe(d).compile(a,l)}},o={protocol:ye,apiVersion:4,id:"lsp",setup(a){a.addTool(i),a.addDiagnosticSource(lt(n,s))}};r.on("session_shutdown",async()=>{t=!0,await Promise.allSettled([...e.values()].map(async a=>(await a).shutdownAll())),e.clear()});let u={protocol:Ce,apiVersion:De,id:"lsp",setup(a){a.addResolver({resolver:it(n),renderResult:yt}),a.addResolver({resolver:ot(n),renderResult:yt}),a.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler:he()}),a.describe("symbol:<file>#<selector> \u2014 declaration source, e.g. symbol:src/catalog.ts#Catalog/find. graph:<file> \u2014 top-level declarations, references and calls; members include selectors. graph:<file>#<selector> \u2014 references and incoming/outgoing calls for that declaration or member."),a.addPromptGuideline("Use semantic code views first when exploring code supported by a configured language server. Use `symbols:<query>` to locate named declaration and reference candidates when the file is unknown. Use `graph:<file>` to map the declarations and relationships in a known file before reading implementation bodies. Use `graph:<file>#<selector>` to inspect references and incoming/outgoing calls for one declaration. Use `symbol:<file>#<selector>` to read that declaration\u2019s source. Use text search for exact text, non-code files, or when semantic views are unavailable.")}};await Promise.all([be(r,o),Ae(r,{protocol:je,apiVersion:Me,id:"lsp-declarations",setup(a){a.addAnchorResolver({kind:$e,type:"auxiliary",resolver:{id:"lsp-declaration",description:"symbol:<file>#<selector> selects an exact declaration for text fallback editing; imports and references are not rewritten.",renderFull:c(l=>l,"renderFull"),renderCompact:c(l=>l,"renderCompact"),tryResolve:c(()=>Promise.resolve({kind:"not-handled"}),"tryResolve")},resources:gt(n),describeInPrompt:!1});for(let l of["copy","move","delete","replace"])a.tool(l).describe("Use symbol:<file>#<selector> as path to select one exact declaration without start/end. Use parent/child for ambiguous names. Copy/move require an explicit target and destination anchor. This text fallback leaves imports and references unchanged; it is not semantic rename."+(l==="replace"?" Use symbol:<file>#<selector>#name with text containing the new name for native LSP rename across references. Omit start/end. A failed server rename never falls back to identifier text replacement.":"")),a.tool(l).addHandler({stage:"text-pre-edit",async handler(d){if(l==="replace"){let h=await ht(d,n);if(h!==void 0)return h}let p=d.input;if(![p.path,p.start,p.end,p.target,p.targetStart,p.targetEnd].some(h=>typeof h=="string"&&h.startsWith("symbol:")))return d;if((l==="copy"||l==="move")&&typeof p.target!="string")throw new Error("Copying or moving a symbol requires an explicit target file and destination anchor.");return{...d,metadata:{...d.metadata,semanticEdit:{mode:"declaration-text",referencesUpdated:!1,importsUpdated:!1},diffStatuses:[{text:"Text fallback: imports and references unchanged",tone:"warning"}]}}}});a.tool("insert").describe("Symbol targets are unsupported for insert. Read the declaration and select an ordinary text line anchor instead."),a.tool("insert").addHandler({stage:"text-pre-edit",handler(l){let d=l.input;if([d.path,d.anchor].some(p=>typeof p=="string"&&p.startsWith("symbol:")))throw new Error("Semantic insert is not supported. Read the declaration and use an explicit text line anchor instead.");return l}})}}),Ee(r,u),xe(r,ut),qe(r,{protocol:Te,apiVersion:Oe,id:"symbols",setup(a){a.addResolver({resolver:pt(n)}),a.describe("Use `symbols:<query>` to locate named workspace declarations and references through configured language servers when the file is unknown.")}})])}c(ir,"registerLsp");async function or(r,e){let t=e?r:process.env.PI_AGENT_IDE_CONFIG_DIR??r;return _.fromPackageDir(t,{includeGlobal:!e,requireBuiltInEvidence:e,recipes:A})}c(or,"loadRegistry");export{ir as default};
3
+ `).matchAll(new RegExp(e,"gmu"))].flatMap(i=>i.groups===void 0?[]:y({...i.groups,...i.groups.column!==void 0&&{column:Number(i.groups.column)+(1-n)}}))}a(U,"parseRegexLines");function X(t,e){return t.split(/\r?\n/u).flatMap(n=>{let i=n.match(e)?.groups;return i===void 0?[]:y(i)})}a(X,"parseMatchingLines");function y(t){if(typeof t!="object"||t===null)return[];let e=t,n=_(e.line??e.startLine),i=_(e.column??e.startColumn,1),r=typeof e.message=="string"?e.message:void 0;return n===void 0||r===void 0?[]:[{...typeof e.file=="string"&&{file:e.file},code:q(e.code??e.ruleId,"lint"),message:r,line:n,column:i??1,severity:K(e.severity)}]}a(y,"normalizeDiagnostic");function _(t,e){let n=typeof t=="string"?Number.parseInt(t,10):t;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:e}a(_,"numberValue");function q(t,e){return typeof t=="string"||typeof t=="number"?String(t):e}a(q,"stringValue");function K(t){if(t===2)return"error";if(t===1)return"warning";let e=q(t,"warning").toLowerCase();return e.includes("error")||e==="e"||e==="f"||e==="fatal"?"error":e==="info"||e==="note"||e==="notice"?"info":e==="hint"?"hint":"warning"}a(K,"severityValue");function Q(t){return t==="error"||t==="warning"||t==="note"?t:"warning"}a(Q,"sarifSeverity");function Y(t){return t.replace(/&#(x[0-9a-f]+|\d+);/giu,(e,n)=>{let i=n.toLowerCase().startsWith("x")?Number.parseInt(n.slice(1),16):Number(n);return i<=1114111?String.fromCodePoint(i):e}).replaceAll("&quot;",'"').replaceAll("&apos;","'").replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&")}a(Y,"decodeXml");var m=class t{constructor(e,n,i=new Map){this.linters=e;this.availableBuiltIns=n;this.evidence=i}static{a(this,"LintCommandRegistry")}static async fromDirectory(e,n={}){let i=await S(e,"linters",o=>I(o).linters,n),r=n.environment??process.env,f=await Promise.all(i.entries.filter(o=>o.layer==="built-in").map(async o=>({id:o.id,available:await w(o.config.check,e,r)}))),s=await L(e,p),l=[...i.entries].sort((o,d)=>o.layer==="built-in"&&d.layer==="built-in"?(s.get(d.id)?.score??0)-(s.get(o.id)?.score??0):0);return new t(l,new Set(f.filter(o=>o.available&&(!n.requireBuiltInEvidence||(s.get(o.id)?.score??0)>0)).map(o=>o.id)),s)}static fromConfig(e){return new t(Object.entries(e.linters).map(([n,i])=>({id:n,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(e,n){return this.resolveEntry(e,n)?.config}resolveEntry(e,n){return D(this.linters,this.availableBuiltIns,this.evidence,e,n)}get entries(){return this.linters}};async function k(t,e){let n;try{n=await $(t.check,e)}catch(l){return{ok:!1,diagnostics:[],failure:`command could not start: ${l instanceof Error?l.message:String(l)}`}}let i=t.diagnostics.format==="regex"||t.diagnostics.format==="clang"?[n.stdout,n.stderr].filter(l=>l.trim().length>0).join(`
4
+ `):n.stdout.trim().length>0?n.stdout:n.stderr,r;try{r=M(i,t.diagnostics)}catch{return{ok:!1,diagnostics:[],failure:`invalid ${t.diagnostics.format} diagnostics: ${i.trim().slice(0,200)||"empty command output"}`}}let f=n.ok&&(n.exitCode===0||r.length>0),s=t.check.cwd==="file"?F.dirname(e.filePath):e.projectRoot;return r=r.filter(l=>{if(l.file===void 0)return!0;let o=l.file.startsWith("file:")?ee(l.file):l.file;return O(F.resolve(s,o),e.filePath)}).map(({file:l,...o})=>o),{ok:f,diagnostics:r,...!f&&{failure:n.stderr.trim().slice(0,200)||`command exited with code ${String(n.exitCode)}`}}}a(k,"runConfiguredLinter");function J(t){return{kind:"linter",name:"command-lint",priority:100,extensions:["*"],detect:a(()=>Promise.resolve(!0),"detect"),async lint({filePath:e,fix:n},i){let r=t.resolve(e,i.cwd);if(r===void 0)return{ok:!0,diagnostics:[]};let f=n===!0&&r.fix!==void 0?r.fix:r.check,s=await k({...r,check:f},{projectRoot:i.cwd,filePath:e});return{ok:s.ok,diagnostics:s.diagnostics}}}}a(J,"createCommandLinter");import{copyFile as te,mkdtemp as ne,rm as ie}from"node:fs/promises";import C from"node:path";var V={protocol:A,apiVersion:1,id:"lint",setup(t){for(let e of p)t.addToolRecipe(e);t.addSetupCheck({id:"effective-config",inspect:re}),t.addCheck({id:"config",title:"Linter",async run(e){try{let n=await m.fromDirectory(e.cwd,{environment:e.env}),i=oe(n,e.files,e.cwd);return i.length===0?[{status:"skip",message:"No linter matches the inspected project files"}]:await Promise.all(i.map(async({entry:r,source:f})=>{let s=`${r.id} [${r.layer}] command ${JSON.stringify(r.config.check.command)}`,l=await ne(C.join(C.dirname(f),".pi-agent-ide-doctor-")),o=C.join(l,C.basename(f));try{await te(f,o);let d=await k(r.config,{projectRoot:e.cwd,filePath:o,env:e.env});return d.ok?{status:"pass",message:`${s}: probe passed`,detail:r.sourcePath}:{status:"fail",message:`${s}: probe failed`,detail:d.failure??r.sourcePath}}catch(d){return{status:"fail",message:`${s}: ${d instanceof Error?d.message:String(d)}`,detail:r.sourcePath}}finally{await ie(l,{recursive:!0,force:!0})}}))}catch(n){return[{status:"fail",message:n instanceof Error?n.message:String(n)}]}}})}};async function re(t){try{let e=await m.fromDirectory(t.cwd,{environment:t.env}),n=[],i=new Map;for(let[r,f]of t.detectedLanguages){let s=f.map(l=>e.resolveEntry(l,t.cwd)).find(l=>l!==void 0);s!==void 0&&(n.push({kind:"linter",languageId:r,toolId:s.id}),await w(s.config.check,t.cwd,t.env)||i.set(s.id,{id:`linter-${s.id}-unavailable`,message:`Configured linter ${s.id} cannot run ${JSON.stringify(s.config.check.command)}`}))}return{selections:n,actions:[...i.values()]}}catch(e){return{actions:[{id:"linter-config-invalid",message:`Linter configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}a(re,"inspectLinterSetup");function oe(t,e,n){let i=new Map;for(let r of e){let f=t.resolveEntry(r,n);f!==void 0&&!i.has(f.id)&&i.set(f.id,{entry:f,source:r})}return[...i.values()]}a(oe,"applicableLinters");async function le(t){let e=new Map,n=a((s,l=!1)=>{let o=JSON.stringify([s,l]),d=e.get(o);return d===void 0&&(d=ae(s,l),e.set(o,d)),d},"registryFor"),i=a(async(s,l)=>{let o=await E(l,s,"linters",p);return o===void 0?void 0:{projectRoot:o,external:o!==se.resolve(l)}},"resolveProject"),r={kind:"linter",name:"pi-agent-ide-lint",priority:200,extensions:["*"],detect:a(async s=>(await n(s.cwd),!0),"detect"),async lint(s,l){let o=await i(s.filePath,l.cwd);if(o===void 0)return{ok:!0,diagnostics:[]};let d=await n(o.projectRoot,o.external);return J(d).lint(s,{cwd:o.projectRoot})}},f={protocol:b,apiVersion:4,id:"lint",setup(s){s.addTool(r),s.addDiagnosticSource({id:"lint",async diagnose(l,o){let d=await i(l,o.cwd);if(d===void 0)return{status:"unavailable",diagnostics:[],reason:"No local linter project found for this file"};let x=await n(d.projectRoot,d.external);o.signal.throwIfAborted();let u=x.resolve(l,d.projectRoot);if(!u)return{status:"unavailable",diagnostics:[],reason:"No linter configured for this file"};let h=R(u.check.command),v=await k(u,{projectRoot:d.projectRoot,filePath:l,signal:o.signal});return!v.ok&&v.diagnostics.length===0?{status:"unavailable",diagnostics:[],reason:v.failure??"Lint check failed",source:h}:{status:"ready",diagnostics:v.diagnostics,source:h}}})}};await Promise.all([P(t,f),N(t,V)])}a(le,"registerLint");async function ae(t,e){let n=e?t:process.env.PI_AGENT_IDE_CONFIG_DIR??t;return m.fromDirectory(n,{includeGlobal:!e,requireBuiltInEvidence:e})}a(ae,"loadRegistry");export{le as default};