pi-agent-ide 0.9.7 → 1.0.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 (900) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +5 -3
  3. package/dist/chunk-2EY3LEZ7.js +1 -0
  4. package/dist/chunk-2QCE7GOV.js +1 -0
  5. package/dist/chunk-3V3OQO5S.js +118 -0
  6. package/dist/chunk-45EJ4762.js +33 -0
  7. package/dist/chunk-4AEYLVSR.js +5 -0
  8. package/dist/chunk-4DLSZYUO.js +1 -0
  9. package/dist/chunk-54EFJYUB.js +1 -0
  10. package/dist/{chunk-5DN2XBVI.js → chunk-5TPYHUJV.js} +1 -1
  11. package/dist/{chunk-KQV2ZXLP.js → chunk-6DC2Q5BI.js} +1 -1
  12. package/dist/chunk-72WO7H5T.js +1 -0
  13. package/dist/chunk-72X24ARV.js +2 -0
  14. package/dist/chunk-AB6RSWMB.js +23 -0
  15. package/dist/chunk-AKUBFJAR.js +1 -0
  16. package/dist/chunk-ASVMQMPX.js +10 -0
  17. package/dist/chunk-BW3XONMZ.js +1 -0
  18. package/dist/{chunk-R2U5WXYR.js → chunk-D23NS4VV.js} +1 -1
  19. package/dist/chunk-DSB6A5P5.js +53 -0
  20. package/dist/chunk-E4V4VNRM.js +3 -0
  21. package/dist/chunk-E6G3UVS7.js +1 -0
  22. package/dist/chunk-E7JBYW43.js +1 -0
  23. package/dist/chunk-FVWMI4GP.js +1 -0
  24. package/dist/chunk-GDIF3WT6.js +12 -0
  25. package/dist/chunk-GNYFA6FS.js +2 -0
  26. package/dist/{chunk-DHOIQZUF.js → chunk-GQXZEOND.js} +1 -1
  27. package/dist/chunk-GT2JPOBM.js +1 -0
  28. package/dist/chunk-GTZOIJCH.js +1 -0
  29. package/dist/chunk-HRZAIZGR.js +1 -0
  30. package/dist/{chunk-H6FEBUAP.js → chunk-HSAGZWPO.js} +1 -1
  31. package/dist/chunk-HUICUICD.js +3 -0
  32. package/dist/{chunk-2DSY4U73.js → chunk-I3G6K7QU.js} +1 -1
  33. package/dist/chunk-IRLWXPL4.js +7 -0
  34. package/dist/chunk-IZTOXSTR.js +6 -0
  35. package/dist/chunk-J5CKSIH7.js +1 -0
  36. package/dist/chunk-JKM4E5VB.js +5 -0
  37. package/dist/chunk-JMCI2ZE2.js +3 -0
  38. package/dist/{chunk-YZTVC7ME.js → chunk-JY63UUC2.js} +1 -1
  39. package/dist/chunk-KJ6HZC6L.js +7 -0
  40. package/dist/chunk-LG22ELG4.js +2 -0
  41. package/dist/chunk-LRAMFOUP.js +37 -0
  42. package/dist/chunk-MJMRV76H.js +1 -0
  43. package/dist/chunk-MMQIHUU5.js +1 -0
  44. package/dist/chunk-MNAIMZRO.js +9 -0
  45. package/dist/chunk-NGWQRV25.js +13 -0
  46. package/dist/chunk-NKI4TZSS.js +2 -0
  47. package/dist/chunk-NWCTAVGR.js +4 -0
  48. package/dist/chunk-O2C3F3MA.js +1 -0
  49. package/dist/chunk-OA26FH5G.js +1 -0
  50. package/dist/chunk-OEEE5BLN.js +16 -0
  51. package/dist/chunk-OLMACWQX.js +11 -0
  52. package/dist/{chunk-72FL5FHZ.js → chunk-PBMHSK6J.js} +1 -1
  53. package/dist/chunk-QC6VFZSB.js +2 -0
  54. package/dist/chunk-QCAGAJHJ.js +1 -0
  55. package/dist/{chunk-P7FUD4WY.js → chunk-QR7JR3P2.js} +1 -1
  56. package/dist/chunk-QSU5AEKW.js +1 -0
  57. package/dist/chunk-R7576HPO.js +25 -0
  58. package/dist/{chunk-B5UJCNQU.js → chunk-RNDSWVJF.js} +1 -1
  59. package/dist/chunk-S4GTWS2J.js +6 -0
  60. package/dist/chunk-SF44YQCB.js +2 -0
  61. package/dist/chunk-SJQGFUXR.js +6 -0
  62. package/dist/chunk-SKHD2QIT.js +1 -0
  63. package/dist/chunk-SKZTIAE4.js +4 -0
  64. package/dist/chunk-SZRC24OB.js +1 -0
  65. package/dist/chunk-T5PXAYWC.js +1 -0
  66. package/dist/chunk-TIZ4QDF3.js +1 -0
  67. package/dist/chunk-UHGHVYAW.js +4 -0
  68. package/dist/chunk-V2LLMBTA.js +1 -0
  69. package/dist/chunk-VB5P3TXJ.js +111 -0
  70. package/dist/chunk-VNG4QPPT.js +12 -0
  71. package/dist/chunk-VNNAVC4S.js +15 -0
  72. package/dist/chunk-VPBGKSFI.js +3 -0
  73. package/dist/chunk-WZ7MNISG.js +5 -0
  74. package/dist/chunk-X4CU7CMR.js +19 -0
  75. package/dist/chunk-X7CHS7JB.js +1 -0
  76. package/dist/chunk-XEPCURYZ.js +1 -0
  77. package/dist/chunk-XKVU6AAS.js +7 -0
  78. package/dist/chunk-XLTAP5YC.js +24 -0
  79. package/dist/chunk-XQMNVPNS.js +1 -0
  80. package/dist/chunk-YI32H7Z2.js +4 -0
  81. package/dist/chunk-YSGPCH52.js +18 -0
  82. package/dist/chunk-ZYG5E3DI.js +9 -0
  83. package/dist/entry-0.js +1 -1
  84. package/dist/entry-12.js +1 -1
  85. package/dist/entry-15.js +1 -1
  86. package/dist/entry-17.js +1 -1
  87. package/dist/entry-18.js +1 -1
  88. package/dist/entry-19.js +1 -1
  89. package/dist/entry-20.js +1 -1
  90. package/dist/entry-21.js +1 -1
  91. package/dist/entry-22.js +1 -1
  92. package/dist/entry-27.js +1 -1
  93. package/dist/entry-28.js +1 -1
  94. package/dist/entry-31.js +2 -2
  95. package/dist/entry-32.js +1 -1
  96. package/dist/entry-33.js +1 -1
  97. package/dist/entry-34.js +1 -1
  98. package/dist/entry-35.js +1 -1
  99. package/dist/entry-36.js +1 -1
  100. package/dist/entry-37.js +1 -1
  101. package/dist/entry-38.js +19 -13
  102. package/dist/entry-4.js +1 -1
  103. package/dist/entry-40.js +1 -1
  104. package/dist/entry-41.js +1 -1
  105. package/dist/entry-43.js +1 -1
  106. package/dist/entry-44.js +1 -1
  107. package/dist/entry-45.js +1 -1
  108. package/dist/entry-48.js +1 -1
  109. package/dist/entry-49.js +1 -1
  110. package/dist/entry-50.js +1 -1
  111. package/dist/entry-51.js +1 -1
  112. package/dist/entry-52.js +1 -1
  113. package/dist/entry-53.js +1 -1
  114. package/dist/entry-54.js +1 -1
  115. package/dist/entry-55.js +1 -1
  116. package/dist/entry-56.js +1 -1
  117. package/dist/entry-57.js +1 -1
  118. package/dist/entry-58.js +1 -1
  119. package/dist/entry-59.js +1 -1
  120. package/dist/entry-60.js +1 -1
  121. package/dist/entry-61.js +1 -1
  122. package/dist/entry-62.js +1 -1
  123. package/dist/entry-63.js +1 -1
  124. package/dist/entry-64.js +1 -1
  125. package/dist/entry-65.js +1 -1
  126. package/dist/entry-66.js +1 -1
  127. package/dist/entry-67.js +1 -1
  128. package/dist/entry-68.js +1 -0
  129. package/dist/entry-69.js +1 -1
  130. package/dist/entry-71.js +1 -1
  131. package/dist/entry-72.js +0 -1
  132. package/dist/entry-73.js +1 -1
  133. package/dist/entry-74.js +1 -1
  134. package/dist/entry-75.js +1 -1
  135. package/dist/entry-76.js +1 -1
  136. package/dist/entry-77.js +1 -1
  137. package/dist/entry-78.js +1 -0
  138. package/dist/entry-79.js +1 -1
  139. package/dist/entry-8.js +1 -1
  140. package/dist/entry-80.js +1 -0
  141. package/dist/entry-81.js +0 -1
  142. package/dist/entry-82.js +1 -1
  143. package/dist/entry-83.js +1 -1
  144. package/dist/entry-84.js +0 -1
  145. package/dist/entry-85.js +1 -1
  146. package/dist/entry-86.js +1 -2
  147. package/dist/entry-87.js +1 -1
  148. package/dist/entry-88.js +1 -1
  149. package/dist/entry-89.js +1 -1
  150. package/dist/entry-90.js +1 -1
  151. package/dist/entry-91.js +1 -3
  152. package/dist/entry-92.js +1 -1
  153. package/dist/entry-93.js +1 -1
  154. package/dist/entry-94.js +1 -1
  155. package/dist/entry-95.js +3 -0
  156. package/dist/entry-96.js +1 -0
  157. package/dist/entry-97.js +1 -0
  158. package/dist/entry-98.js +1 -0
  159. package/dist/pi-agent-ide.js +26 -13
  160. package/docs/agent-guides/ast-search.md +15 -4
  161. package/docs/agent-guides/debugger.md +1 -1
  162. package/docs/agent-guides/git-changes.md +1 -0
  163. package/docs/agent-guides/ssh.md +27 -7
  164. package/docs/agent-guides/terminal.md +4 -0
  165. package/docs/configuration.md +65 -11
  166. package/docs/development.md +4 -0
  167. package/docs/extensions.md +6 -4
  168. package/docs/structured-results.md +29 -15
  169. package/docs/tools.md +95 -29
  170. package/docs/user-hooks.md +1 -1
  171. package/node_modules/pi-agent-doctor/package.json +1 -1
  172. package/node_modules/pi-agent-doctor/src/catalog.ts +2 -0
  173. package/node_modules/pi-agent-doctor/src/executable.ts +1 -1
  174. package/node_modules/pi-agent-documentation/package.json +1 -1
  175. package/node_modules/pi-agent-filesystem/package.json +7 -7
  176. package/node_modules/pi-agent-filesystem/src/file-write-lock.ts +6 -4
  177. package/node_modules/pi-agent-filesystem/src/replace-file.ts +5 -2
  178. package/node_modules/pi-agent-filesystem/src/resolver.ts +26 -10
  179. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  180. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  181. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  182. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  183. package/node_modules/pi-agent-ide-ast/package.json +13 -13
  184. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +56 -65
  185. package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +197 -130
  186. package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +2 -1
  187. package/node_modules/pi-agent-ide-ast/src/ast-grep-binary.ts +46 -0
  188. package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +119 -97
  189. package/node_modules/pi-agent-ide-ast/src/extension.ts +9 -24
  190. package/node_modules/pi-agent-ide-ast/src/outline-page.ts +96 -0
  191. package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +42 -78
  192. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +5 -1
  193. package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +2 -1
  194. package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +24 -5
  195. package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +2 -1
  196. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +406 -200
  197. package/node_modules/pi-agent-ide-ast/src/tool-ast-search.ts +27 -9
  198. package/node_modules/pi-agent-ide-ast/src/tool-outline.ts +191 -0
  199. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  200. package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +63 -20
  201. package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +1 -0
  202. package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +25 -0
  203. package/node_modules/pi-agent-ide-changes/src/changes/git-paths.ts +13 -6
  204. package/node_modules/pi-agent-ide-changes/src/index-mutation-queue.ts +12 -8
  205. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +88 -78
  206. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +29 -3
  207. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  208. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +39 -3
  209. package/node_modules/pi-agent-ide-formatter/src/rustfmt.ts +101 -0
  210. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  211. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  212. package/node_modules/pi-agent-ide-lint/src/catalog.ts +20 -14
  213. package/node_modules/pi-agent-ide-lint/src/registry.ts +2 -2
  214. package/node_modules/pi-agent-ide-lsp/index.ts +15 -88
  215. package/node_modules/pi-agent-ide-lsp/package.json +12 -12
  216. package/node_modules/pi-agent-ide-lsp/src/catalog.ts +21 -9
  217. package/node_modules/pi-agent-ide-lsp/src/lsp/clang-coverage.ts +265 -0
  218. package/node_modules/pi-agent-ide-lsp/src/lsp/clangd-launch.ts +48 -0
  219. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +66 -11
  220. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +514 -207
  221. package/node_modules/pi-agent-ide-lsp/src/lsp/corrected-names.ts +211 -0
  222. package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +20 -1
  223. package/node_modules/pi-agent-ide-lsp/src/lsp/files-containing.ts +70 -0
  224. package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +1 -1
  225. package/node_modules/pi-agent-ide-lsp/src/lsp/line-breaks.ts +16 -0
  226. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +60 -16
  227. package/node_modules/pi-agent-ide-lsp/src/lsp/missing-sources.ts +21 -0
  228. package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +44 -0
  229. package/node_modules/pi-agent-ide-lsp/src/lsp/position-map.ts +17 -0
  230. package/node_modules/pi-agent-ide-lsp/src/lsp/range-match.ts +49 -0
  231. package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +16 -5
  232. package/node_modules/pi-agent-ide-lsp/src/lsp/server-request-handlers.mjs +7 -1
  233. package/node_modules/pi-agent-ide-lsp/src/lsp/shared-server-host.mjs +133 -37
  234. package/node_modules/pi-agent-ide-lsp/src/lsp/shared-servers.ts +164 -13
  235. package/node_modules/pi-agent-ide-lsp/src/lsp/source-changes.ts +18 -6
  236. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +346 -164
  237. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-selectors.ts +376 -0
  238. package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +6 -0
  239. package/node_modules/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +10 -0
  240. package/node_modules/pi-agent-ide-lsp/src/name-captures.ts +66 -0
  241. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +383 -92
  242. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +305 -77
  243. package/node_modules/pi-agent-ide-lsp/src/tool-lsp-search.ts +33 -11
  244. package/node_modules/pi-agent-image/package.json +2 -2
  245. package/node_modules/pi-agent-image/src/image-converter.ts +13 -2
  246. package/node_modules/pi-agent-invariant/package.json +1 -1
  247. package/node_modules/pi-agent-pdf/package.json +2 -2
  248. package/node_modules/pi-agent-read/package.json +7 -7
  249. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  250. package/node_modules/pi-agent-read/src/api/read-parameters.ts +51 -12
  251. package/node_modules/pi-agent-read/src/api/tools/read.ts +39 -3
  252. package/node_modules/pi-agent-read/src/core/extension.ts +80 -3
  253. package/node_modules/pi-agent-read/src/core/read-core.ts +6 -0
  254. package/node_modules/pi-agent-read/src/core/tools/read/list-result.ts +79 -0
  255. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +45 -4
  256. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +18 -9
  257. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +16 -3
  258. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +37 -9
  259. package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +15 -4
  260. package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +49 -18
  261. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +158 -51
  262. package/node_modules/pi-agent-resource/package.json +5 -1
  263. package/node_modules/pi-agent-resource/src/file-text-read.ts +86 -0
  264. package/node_modules/pi-agent-resource/src/index.ts +54 -0
  265. package/node_modules/pi-agent-resource/src/json-structured-arguments.ts +131 -0
  266. package/node_modules/pi-agent-resource/src/line-map.ts +750 -0
  267. package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
  268. package/node_modules/pi-agent-resource/src/resource-scheduler.ts +63 -23
  269. package/node_modules/pi-agent-resource/src/resource.ts +5 -0
  270. package/node_modules/pi-agent-resource/src/result-targets.ts +693 -66
  271. package/node_modules/pi-agent-resource/src/script-calls.ts +21 -0
  272. package/node_modules/pi-agent-resource/src/tool-deadline.ts +199 -0
  273. package/node_modules/pi-agent-resource/src/tool-result.ts +14 -5
  274. package/node_modules/pi-agent-resource/src/unchanged-read.ts +62 -0
  275. package/node_modules/pi-agent-search/package.json +8 -9
  276. package/node_modules/pi-agent-search/runtime/entry-57.js +0 -1
  277. package/node_modules/pi-agent-search/src/api/fuzzy.ts +2 -1
  278. package/node_modules/pi-agent-search/src/api/null-fields.ts +50 -0
  279. package/node_modules/pi-agent-search/src/api/path-list.ts +68 -0
  280. package/node_modules/pi-agent-search/src/api/presentation.ts +2 -1
  281. package/node_modules/pi-agent-search/src/api/search-call-policy.ts +16 -0
  282. package/node_modules/pi-agent-search/src/api/search-capture.ts +56 -0
  283. package/node_modules/pi-agent-search/src/api/search-parameters.ts +26 -4
  284. package/node_modules/pi-agent-search/src/api/search-scope.ts +38 -2
  285. package/node_modules/pi-agent-search/src/api/search.ts +46 -3
  286. package/node_modules/pi-agent-search/src/api/structured-result.ts +96 -25
  287. package/node_modules/pi-agent-search/src/core/extension.ts +75 -42
  288. package/node_modules/pi-agent-search/src/core/search-config.ts +2 -2
  289. package/node_modules/pi-agent-search/src/core/search-core.ts +103 -39
  290. package/node_modules/pi-agent-search-text/index.ts +62 -20
  291. package/node_modules/pi-agent-search-text/package.json +15 -15
  292. package/node_modules/pi-agent-search-text/runtime/entry-59.js +1 -0
  293. package/node_modules/pi-agent-search-text/src/current-matches.ts +314 -0
  294. package/node_modules/pi-agent-search-text/src/file-search.ts +178 -99
  295. package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +40 -17
  296. package/node_modules/pi-agent-search-text/src/persisted-result.ts +3 -8
  297. package/node_modules/pi-agent-search-text/src/resolvers.ts +395 -103
  298. package/node_modules/pi-agent-search-text/src/ripgrep.ts +142 -0
  299. package/node_modules/pi-agent-search-text/src/scoped-search.ts +24 -12
  300. package/node_modules/pi-agent-search-text/src/search-backend.ts +333 -108
  301. package/node_modules/pi-agent-search-text/src/search-presentation.ts +6 -0
  302. package/node_modules/pi-agent-search-text/src/search-query.ts +69 -34
  303. package/node_modules/pi-agent-search-text/src/search-recipe.ts +80 -8
  304. package/node_modules/pi-agent-search-text/src/search-renderer.ts +2 -1
  305. package/node_modules/pi-agent-search-text/src/search-result.ts +10 -1
  306. package/node_modules/pi-agent-search-text/src/search-session.ts +449 -58
  307. package/node_modules/pi-agent-search-text/src/tool-file-search.ts +51 -6
  308. package/node_modules/pi-agent-text/package.json +3 -3
  309. package/node_modules/pi-agent-text/runtime/entry-63.js +1 -0
  310. package/node_modules/pi-agent-text/src/index.ts +18 -0
  311. package/node_modules/pi-agent-text/src/line-anchors.ts +211 -0
  312. package/node_modules/pi-agent-text/src/no-final-line-break.ts +12 -0
  313. package/node_modules/pi-agent-text/src/search-highlight.ts +8 -0
  314. package/node_modules/pi-agent-text/src/source-line.ts +7 -1
  315. package/node_modules/pi-agent-text/src/text-anchor.ts +34 -3
  316. package/node_modules/pi-agent-text/src/text-converter.ts +2 -1
  317. package/node_modules/pi-agent-text/src/text-document.ts +9 -23
  318. package/node_modules/pi-agent-text/src/text-target.ts +14 -6
  319. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  320. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-64.js +2 -0
  321. package/node_modules/pi-agent-text-anchor-exact/index.ts +1 -65
  322. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  323. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-65.js +0 -1
  324. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-66.js +2 -0
  325. package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +185 -184
  326. package/node_modules/pi-agent-text-anchor-exact/src/anchored-literal-view.ts +122 -0
  327. package/node_modules/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +2 -1
  328. package/node_modules/pi-agent-text-anchor-exact/src/literal-match.ts +359 -0
  329. package/node_modules/pi-agent-text-anchor-exact/src/recovery.ts +1 -0
  330. package/node_modules/pi-agent-text-anchor-line-hash/index.ts +5 -3
  331. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  332. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-67.js +0 -1
  333. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-68.js +2 -0
  334. package/node_modules/pi-agent-text-anchor-line-hash/src/anchor.ts +92 -67
  335. package/node_modules/pi-agent-text-anchor-line-hash/src/range-history.ts +105 -0
  336. package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +22 -17
  337. package/node_modules/pi-agent-text-editor/index.ts +0 -10
  338. package/node_modules/pi-agent-text-editor/package.json +37 -26
  339. package/node_modules/pi-agent-text-editor/runtime/entry-84.js +0 -1
  340. package/node_modules/pi-agent-text-editor/runtime/entry-85.js +1 -0
  341. package/node_modules/pi-agent-text-editor/runtime/entry-86.js +1 -0
  342. package/node_modules/pi-agent-text-editor/runtime/entry-88.js +2 -0
  343. package/node_modules/pi-agent-text-editor/src/api/anchor-excerpt.ts +7 -0
  344. package/node_modules/pi-agent-text-editor/src/api/anchor-inspection.ts +2 -1
  345. package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +2 -0
  346. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +40 -8
  347. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +6 -1
  348. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +37 -2
  349. package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
  350. package/node_modules/pi-agent-text-editor/src/api/native-files.ts +16 -2
  351. package/node_modules/pi-agent-text-editor/src/api/pi-edit-text.ts +82 -0
  352. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +9 -2
  353. package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +1 -0
  354. package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +13 -2
  355. package/node_modules/pi-agent-text-editor/src/api/text-selector-fields.ts +210 -0
  356. package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -0
  357. package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
  358. package/node_modules/pi-agent-text-editor/src/core/already-done.ts +123 -0
  359. package/node_modules/pi-agent-text-editor/src/core/anchor-candidates.ts +116 -0
  360. package/node_modules/pi-agent-text-editor/src/core/anchor-preview.ts +32 -0
  361. package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +109 -23
  362. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +19 -5
  363. package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +6 -5
  364. package/node_modules/pi-agent-text-editor/src/core/extension.ts +54 -21
  365. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +7 -3
  366. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +14 -5
  367. package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +32 -11
  368. package/node_modules/pi-agent-text-editor/src/core/file-transfers.ts +67 -38
  369. package/node_modules/pi-agent-text-editor/src/core/file-write-observations.ts +287 -0
  370. package/node_modules/pi-agent-text-editor/src/core/image-write.ts +16 -4
  371. package/node_modules/pi-agent-text-editor/src/core/lookalike-bytes.ts +254 -0
  372. package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +29 -12
  373. package/node_modules/pi-agent-text-editor/src/core/mutation-result/compact-receipt.ts +48 -0
  374. package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +2 -1
  375. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +24 -34
  376. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +13 -20
  377. package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +32 -3
  378. package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +36 -2
  379. package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +26 -19
  380. package/node_modules/pi-agent-text-editor/src/core/native-snapshot-source.ts +13 -0
  381. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +526 -148
  382. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +28 -3
  383. package/node_modules/pi-agent-text-editor/src/core/read-fragment-resolver.ts +34 -14
  384. package/node_modules/pi-agent-text-editor/src/core/reference-list.ts +95 -0
  385. package/node_modules/pi-agent-text-editor/src/core/result-scope.ts +129 -0
  386. package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +20 -8
  387. package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +86 -69
  388. package/node_modules/pi-agent-text-editor/src/core/source-aliases.ts +92 -0
  389. package/node_modules/pi-agent-text-editor/src/core/source-change-retry.ts +92 -7
  390. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +2 -0
  391. package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +162 -47
  392. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +321 -101
  393. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +206 -134
  394. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -2
  395. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +133 -18
  396. package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +13 -0
  397. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +823 -226
  398. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +51 -1
  399. package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +7 -4
  400. package/node_modules/pi-agent-text-editor/src/tools/display-marker.ts +15 -0
  401. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +268 -159
  402. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +37 -32
  403. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +24 -70
  404. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +23 -36
  405. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +31 -45
  406. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +33 -65
  407. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +80 -42
  408. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +27 -16
  409. package/node_modules/pi-agent-text-editor-renderer/index.ts +0 -14
  410. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  411. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-89.js +2 -0
  412. package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +204 -78
  413. package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +75 -8
  414. package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +4 -1
  415. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +4 -3
  416. package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +44 -30
  417. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +170 -26
  418. package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +83 -83
  419. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -6
  420. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  421. package/node_modules/pi-agent-tool-call-interception/runtime/entry-91.js +1 -0
  422. package/node_modules/pi-agent-tool-ui/package.json +3 -3
  423. package/node_modules/pi-agent-tool-ui/runtime/entry-92.js +1 -0
  424. package/node_modules/pi-agent-tool-ui/runtime/entry-93.js +1 -0
  425. package/node_modules/pi-agent-web/index.ts +0 -3
  426. package/node_modules/pi-agent-web/package.json +8 -8
  427. package/node_modules/pi-agent-web/src/search.ts +1 -2
  428. package/node_modules/pi-agent-web-html/package.json +3 -3
  429. package/node_modules/pi-agent-web-html/runtime/entry-95.js +2 -0
  430. package/node_modules/pi-agent-web-image/package.json +4 -4
  431. package/node_modules/pi-agent-web-image/runtime/entry-96.js +2 -0
  432. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  433. package/node_modules/pi-agent-web-pdf/runtime/entry-97.js +2 -0
  434. package/node_modules/pi-agent-web-text/package.json +4 -4
  435. package/node_modules/pi-agent-web-text/runtime/entry-98.js +2 -0
  436. package/package.json +39 -38
  437. package/skills/capture-code-review-rule/SKILL.md +1 -1
  438. package/skills/configure-agent-ide/SKILL.md +1 -1
  439. package/src/api/code-view.ts +0 -2
  440. package/src/api/tool-config/linters.json +1 -0
  441. package/src/api/tool-config/lsp-servers.json +5 -0
  442. package/src/api/tool-config.ts +23 -2
  443. package/src/backend/config.ts +2 -0
  444. package/src/backend/configured-process.ts +1 -0
  445. package/src/backend/dap-java-transport.ts +4 -2
  446. package/src/backend/dap-java-worker.py +11 -4
  447. package/src/backend/dap-node-transport.ts +4 -2
  448. package/src/backend/dap-tcp-transport.ts +2 -3
  449. package/src/backend/debugger-workspace-owner.ts +6 -6
  450. package/src/backend/doctor-probe-worker.py +23 -15
  451. package/src/backend/doctor-workspace.ts +19 -18
  452. package/src/backend/file-transfer.ts +160 -56
  453. package/src/backend/formatter-registration.ts +54 -2
  454. package/src/backend/identity.ts +81 -12
  455. package/src/backend/lsp-file-watchers.ts +7 -9
  456. package/src/backend/lsp-workspace-owner.ts +25 -1
  457. package/src/backend/object-transfer.ts +28 -15
  458. package/src/backend/owned-command.ts +2 -1
  459. package/src/backend/owned-read-command.ts +2 -1
  460. package/src/backend/packaged-source.ts +12 -0
  461. package/src/backend/process-environment.ts +7 -9
  462. package/src/backend/process-metadata.ts +5 -5
  463. package/src/backend/recipe-evidence-worker.py +2 -0
  464. package/src/backend/recipe-evidence.ts +7 -8
  465. package/src/backend/registration.ts +2 -1
  466. package/src/backend/registry.ts +12 -2
  467. package/src/backend/resource-resolver.ts +11 -32
  468. package/src/backend/search-environment.ts +61 -4
  469. package/src/backend/ssh-channel-worker.py +6 -304
  470. package/src/backend/ssh-channel.ts +287 -36
  471. package/src/backend/ssh-connection-loss.ts +123 -0
  472. package/src/backend/ssh-file-stream.ts +216 -0
  473. package/src/backend/ssh-master.ts +443 -0
  474. package/src/backend/ssh-transfer-worker-windows.py +84 -0
  475. package/src/backend/ssh-transfer-worker.py +43 -10
  476. package/src/backend/ssh-transport.ts +238 -24
  477. package/src/backend/ssh-worker.py +7 -728
  478. package/src/backend/ssh.ts +83 -35
  479. package/src/backend/ssh_channel_common.py +68 -0
  480. package/src/backend/ssh_channel_posix.py +324 -0
  481. package/src/backend/ssh_channel_windows.py +527 -0
  482. package/src/backend/ssh_paths.py +23 -0
  483. package/src/backend/ssh_windows_files.py +254 -0
  484. package/src/backend/ssh_worker_common.py +96 -0
  485. package/src/backend/ssh_worker_posix.py +780 -0
  486. package/src/backend/ssh_worker_windows.py +687 -0
  487. package/src/backend/tool-config-access.ts +14 -11
  488. package/src/backend/tool-project.ts +4 -3
  489. package/src/backend/web-browser.ts +2 -3
  490. package/src/backend/web-http.ts +5 -5
  491. package/src/code-view/diagnostic-view.ts +12 -30
  492. package/src/code-view/reference.ts +9 -18
  493. package/src/code-view/source-view.ts +2 -1
  494. package/src/composite/codemode-tool-names.ts +79 -0
  495. package/src/composite/detached-results.ts +25 -6
  496. package/src/composite/ide-alias-rendering.ts +26 -4
  497. package/src/composite/module-labels.ts +2 -2
  498. package/src/composite/module-settings.ts +1 -0
  499. package/src/composite/nested-tool-rendering.ts +70 -24
  500. package/src/composite/output-limits.ts +12 -5
  501. package/src/composite/parallel-tool-guidance.ts +38 -0
  502. package/src/composite/script-values/ast-search.ts +56 -0
  503. package/src/composite/script-values/copy.ts +8 -0
  504. package/src/composite/script-values/delete.ts +5 -0
  505. package/src/composite/script-values/diff.ts +28 -0
  506. package/src/composite/script-values/edit-selection.ts +48 -0
  507. package/src/composite/script-values/failures.ts +170 -0
  508. package/src/composite/script-values/file-receipts.ts +63 -0
  509. package/src/composite/script-values/file-search.ts +10 -0
  510. package/src/composite/script-values/index.ts +55 -0
  511. package/src/composite/script-values/insert.ts +5 -0
  512. package/src/composite/script-values/lsp-search.ts +92 -0
  513. package/src/composite/script-values/match.ts +53 -0
  514. package/src/composite/script-values/move.ts +8 -0
  515. package/src/composite/script-values/path-list.ts +25 -0
  516. package/src/composite/script-values/provider-value.ts +21 -0
  517. package/src/composite/script-values/read.ts +206 -0
  518. package/src/composite/script-values/replace.ts +5 -0
  519. package/src/composite/script-values/result-reference.ts +9 -0
  520. package/src/composite/script-values/search-matches.ts +113 -0
  521. package/src/composite/script-values/search.ts +64 -0
  522. package/src/composite/script-values/semantic-search.ts +8 -0
  523. package/src/composite/script-values/terminal.ts +112 -0
  524. package/src/composite/script-values/text.ts +7 -0
  525. package/src/composite/script-values/types.ts +56 -0
  526. package/src/composite/script-values/undo.ts +5 -0
  527. package/src/composite/script-values/write.ts +8 -0
  528. package/src/composite/settings-panel.ts +18 -2
  529. package/src/composite/text-results.ts +488 -175
  530. package/src/composite/tool-availability.ts +29 -16
  531. package/src/composite/tool-discovery-guidance.ts +97 -0
  532. package/src/documentation/attachment.ts +31 -0
  533. package/src/documentation/extension.ts +6 -2
  534. package/src/documentation/search.ts +1 -7
  535. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  536. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  537. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  538. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  539. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  540. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/file-write-lock.ts +6 -4
  541. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/replace-file.ts +5 -2
  542. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +26 -10
  543. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +0 -3
  544. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
  545. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  546. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-95.js +2 -0
  547. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  548. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-96.js +2 -0
  549. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  550. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-97.js +2 -0
  551. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  552. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-98.js +2 -0
  553. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-94.js +2 -0
  554. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +1 -2
  555. package/src/extensions/pi-agent-read/package.json +7 -7
  556. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  557. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +51 -12
  558. package/src/extensions/pi-agent-read/src/api/tools/read.ts +39 -3
  559. package/src/extensions/pi-agent-read/src/core/extension.ts +80 -3
  560. package/src/extensions/pi-agent-read/src/core/read-core.ts +6 -0
  561. package/src/extensions/pi-agent-read/src/core/tools/read/list-result.ts +79 -0
  562. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +45 -4
  563. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +18 -9
  564. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +16 -3
  565. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +37 -9
  566. package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +15 -4
  567. package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +49 -18
  568. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +158 -51
  569. package/src/extensions/pi-agent-search/package.json +8 -9
  570. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +62 -20
  571. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +15 -15
  572. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-59.js +1 -0
  573. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-62.js +1 -0
  574. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/current-matches.ts +314 -0
  575. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +178 -99
  576. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +40 -17
  577. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +3 -8
  578. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +395 -103
  579. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/ripgrep.ts +142 -0
  580. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +24 -12
  581. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +333 -108
  582. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +6 -0
  583. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +69 -34
  584. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +80 -8
  585. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +2 -1
  586. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +10 -1
  587. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +449 -58
  588. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/tool-file-search.ts +51 -6
  589. package/src/extensions/pi-agent-search/runtime/entry-57.js +0 -1
  590. package/src/extensions/pi-agent-search/runtime/entry-58.js +2 -0
  591. package/src/extensions/pi-agent-search/src/api/fuzzy.ts +2 -1
  592. package/src/extensions/pi-agent-search/src/api/null-fields.ts +50 -0
  593. package/src/extensions/pi-agent-search/src/api/path-list.ts +68 -0
  594. package/src/extensions/pi-agent-search/src/api/presentation.ts +2 -1
  595. package/src/extensions/pi-agent-search/src/api/search-call-policy.ts +16 -0
  596. package/src/extensions/pi-agent-search/src/api/search-capture.ts +56 -0
  597. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +26 -4
  598. package/src/extensions/pi-agent-search/src/api/search-scope.ts +38 -2
  599. package/src/extensions/pi-agent-search/src/api/search.ts +46 -3
  600. package/src/extensions/pi-agent-search/src/api/structured-result.ts +96 -25
  601. package/src/extensions/pi-agent-search/src/core/extension.ts +75 -42
  602. package/src/extensions/pi-agent-search/src/core/search-config.ts +2 -2
  603. package/src/extensions/pi-agent-search/src/core/search-core.ts +103 -39
  604. package/src/extensions/pi-agent-text-editor/index.ts +0 -10
  605. package/src/extensions/pi-agent-text-editor/package.json +37 -26
  606. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  607. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-64.js +2 -0
  608. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +1 -65
  609. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  610. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-65.js +0 -1
  611. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-66.js +2 -0
  612. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +185 -184
  613. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchored-literal-view.ts +122 -0
  614. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +2 -1
  615. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/literal-match.ts +359 -0
  616. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/recovery.ts +1 -0
  617. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +5 -3
  618. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  619. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-67.js +0 -1
  620. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-68.js +2 -0
  621. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/anchor.ts +92 -67
  622. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/range-history.ts +105 -0
  623. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +22 -17
  624. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +0 -14
  625. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  626. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-89.js +2 -0
  627. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +204 -78
  628. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +75 -8
  629. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +4 -1
  630. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +4 -3
  631. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +44 -30
  632. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +170 -26
  633. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +83 -83
  634. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -6
  635. package/src/extensions/pi-agent-text-editor/runtime/entry-84.js +0 -1
  636. package/src/extensions/pi-agent-text-editor/runtime/entry-85.js +1 -0
  637. package/src/extensions/pi-agent-text-editor/runtime/entry-86.js +1 -0
  638. package/src/extensions/pi-agent-text-editor/runtime/entry-87.js +1 -0
  639. package/src/extensions/pi-agent-text-editor/runtime/entry-88.js +2 -0
  640. package/src/extensions/pi-agent-text-editor/src/api/anchor-excerpt.ts +7 -0
  641. package/src/extensions/pi-agent-text-editor/src/api/anchor-inspection.ts +2 -1
  642. package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +2 -0
  643. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +40 -8
  644. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +6 -1
  645. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +37 -2
  646. package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
  647. package/src/extensions/pi-agent-text-editor/src/api/native-files.ts +16 -2
  648. package/src/extensions/pi-agent-text-editor/src/api/pi-edit-text.ts +82 -0
  649. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +9 -2
  650. package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +1 -0
  651. package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +13 -2
  652. package/src/extensions/pi-agent-text-editor/src/api/text-selector-fields.ts +210 -0
  653. package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -0
  654. package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
  655. package/src/extensions/pi-agent-text-editor/src/core/already-done.ts +123 -0
  656. package/src/extensions/pi-agent-text-editor/src/core/anchor-candidates.ts +116 -0
  657. package/src/extensions/pi-agent-text-editor/src/core/anchor-preview.ts +32 -0
  658. package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +109 -23
  659. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +19 -5
  660. package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +6 -5
  661. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +54 -21
  662. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +7 -3
  663. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +14 -5
  664. package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +32 -11
  665. package/src/extensions/pi-agent-text-editor/src/core/file-transfers.ts +67 -38
  666. package/src/extensions/pi-agent-text-editor/src/core/file-write-observations.ts +287 -0
  667. package/src/extensions/pi-agent-text-editor/src/core/image-write.ts +16 -4
  668. package/src/extensions/pi-agent-text-editor/src/core/lookalike-bytes.ts +254 -0
  669. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +29 -12
  670. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/compact-receipt.ts +48 -0
  671. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +2 -1
  672. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +24 -34
  673. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +13 -20
  674. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +32 -3
  675. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +36 -2
  676. package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +26 -19
  677. package/src/extensions/pi-agent-text-editor/src/core/native-snapshot-source.ts +13 -0
  678. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +526 -148
  679. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +28 -3
  680. package/src/extensions/pi-agent-text-editor/src/core/read-fragment-resolver.ts +34 -14
  681. package/src/extensions/pi-agent-text-editor/src/core/reference-list.ts +95 -0
  682. package/src/extensions/pi-agent-text-editor/src/core/result-scope.ts +129 -0
  683. package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +20 -8
  684. package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +86 -69
  685. package/src/extensions/pi-agent-text-editor/src/core/source-aliases.ts +92 -0
  686. package/src/extensions/pi-agent-text-editor/src/core/source-change-retry.ts +92 -7
  687. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +2 -0
  688. package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +162 -47
  689. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +321 -101
  690. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +206 -134
  691. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -2
  692. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +133 -18
  693. package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +13 -0
  694. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +823 -226
  695. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +51 -1
  696. package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +7 -4
  697. package/src/extensions/pi-agent-text-editor/src/tools/display-marker.ts +15 -0
  698. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +268 -159
  699. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +37 -32
  700. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +24 -70
  701. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +23 -36
  702. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +31 -45
  703. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +33 -65
  704. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +80 -42
  705. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +27 -16
  706. package/src/pi-agent-ide.ts +41 -32
  707. package/src/plugins/pi-agent-ide-ast/package.json +13 -13
  708. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +56 -65
  709. package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +197 -130
  710. package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +2 -1
  711. package/src/plugins/pi-agent-ide-ast/src/ast-grep-binary.ts +46 -0
  712. package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +119 -97
  713. package/src/plugins/pi-agent-ide-ast/src/extension.ts +9 -24
  714. package/src/plugins/pi-agent-ide-ast/src/outline-page.ts +96 -0
  715. package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +42 -78
  716. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +5 -1
  717. package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +2 -1
  718. package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +24 -5
  719. package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +2 -1
  720. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +406 -200
  721. package/src/plugins/pi-agent-ide-ast/src/tool-ast-search.ts +27 -9
  722. package/src/plugins/pi-agent-ide-ast/src/tool-outline.ts +191 -0
  723. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  724. package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +63 -20
  725. package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +1 -0
  726. package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +25 -0
  727. package/src/plugins/pi-agent-ide-changes/src/changes/git-paths.ts +13 -6
  728. package/src/plugins/pi-agent-ide-changes/src/index-mutation-queue.ts +12 -8
  729. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +88 -78
  730. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +29 -3
  731. package/src/plugins/pi-agent-ide-debugger/index.ts +42 -32
  732. package/src/plugins/pi-agent-ide-debugger/src/string-enum.ts +14 -0
  733. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +124 -79
  734. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  735. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +39 -3
  736. package/src/plugins/pi-agent-ide-formatter/src/rustfmt.ts +101 -0
  737. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  738. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  739. package/src/plugins/pi-agent-ide-lint/src/catalog.ts +20 -14
  740. package/src/plugins/pi-agent-ide-lint/src/registry.ts +2 -2
  741. package/src/plugins/pi-agent-ide-lsp/index.ts +15 -88
  742. package/src/plugins/pi-agent-ide-lsp/package.json +12 -12
  743. package/src/plugins/pi-agent-ide-lsp/src/catalog.ts +21 -9
  744. package/src/plugins/pi-agent-ide-lsp/src/lsp/clang-coverage.ts +265 -0
  745. package/src/plugins/pi-agent-ide-lsp/src/lsp/clangd-launch.ts +48 -0
  746. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +66 -11
  747. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +514 -207
  748. package/src/plugins/pi-agent-ide-lsp/src/lsp/corrected-names.ts +211 -0
  749. package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +20 -1
  750. package/src/plugins/pi-agent-ide-lsp/src/lsp/files-containing.ts +70 -0
  751. package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +1 -1
  752. package/src/plugins/pi-agent-ide-lsp/src/lsp/line-breaks.ts +16 -0
  753. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +60 -16
  754. package/src/plugins/pi-agent-ide-lsp/src/lsp/missing-sources.ts +21 -0
  755. package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +44 -0
  756. package/src/plugins/pi-agent-ide-lsp/src/lsp/position-map.ts +17 -0
  757. package/src/plugins/pi-agent-ide-lsp/src/lsp/range-match.ts +49 -0
  758. package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +16 -5
  759. package/src/plugins/pi-agent-ide-lsp/src/lsp/server-request-handlers.mjs +7 -1
  760. package/src/plugins/pi-agent-ide-lsp/src/lsp/shared-server-host.mjs +133 -37
  761. package/src/plugins/pi-agent-ide-lsp/src/lsp/shared-servers.ts +164 -13
  762. package/src/plugins/pi-agent-ide-lsp/src/lsp/source-changes.ts +18 -6
  763. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +346 -164
  764. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-selectors.ts +376 -0
  765. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +6 -0
  766. package/src/plugins/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +10 -0
  767. package/src/plugins/pi-agent-ide-lsp/src/name-captures.ts +66 -0
  768. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +383 -92
  769. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +305 -77
  770. package/src/plugins/pi-agent-ide-lsp/src/tool-lsp-search.ts +33 -11
  771. package/src/plugins/pi-agent-ide-processes/src/registry.ts +64 -3
  772. package/src/plugins/pi-agent-ide-processes/src/ui.ts +57 -1
  773. package/src/plugins/pi-agent-ide-semantic/src/backend.ts +18 -6
  774. package/src/plugins/pi-agent-ide-semantic/src/vera-backend.ts +16 -9
  775. package/src/plugins/pi-agent-ide-terminal/index.ts +23 -7
  776. package/src/plugins/pi-agent-ide-terminal/src/list.ts +79 -0
  777. package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +22 -0
  778. package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +3 -0
  779. package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +18 -6
  780. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +132 -18
  781. package/src/plugins/pi-agent-ide-terminal/src/search.ts +117 -50
  782. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +94 -10
  783. package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +24 -1
  784. package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +5 -2
  785. package/src/plugins/pi-agent-ide-terminal/src/terminal-text.ts +173 -0
  786. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +266 -112
  787. package/src/plugins/pi-agent-ide-terminal/src/types.ts +6 -1
  788. package/src/plugins/pi-agent-ide-terminal/src/ui.ts +11 -6
  789. package/src/plugins/pi-agent-ide-terminal/src/unix-pty-output.ts +47 -0
  790. package/src/post-edit/gate.ts +16 -1
  791. package/src/semantic/extension.ts +8 -2
  792. package/src/standalone/scoped-api.ts +85 -18
  793. package/src/toolchain/types.ts +4 -0
  794. package/dist/chunk-2AANEKFS.js +0 -1
  795. package/dist/chunk-33U3RUM3.js +0 -12
  796. package/dist/chunk-34IYWKY5.js +0 -1
  797. package/dist/chunk-4CSNQX54.js +0 -23
  798. package/dist/chunk-53IV6EKV.js +0 -1
  799. package/dist/chunk-5AROEOJB.js +0 -1
  800. package/dist/chunk-5D4C225L.js +0 -1
  801. package/dist/chunk-5W6QQZFI.js +0 -2
  802. package/dist/chunk-6W4OJLCJ.js +0 -1
  803. package/dist/chunk-6ZYCTWQE.js +0 -1
  804. package/dist/chunk-756K3LJY.js +0 -1
  805. package/dist/chunk-AMSNDWBT.js +0 -2
  806. package/dist/chunk-APWMLLSE.js +0 -17
  807. package/dist/chunk-BMSAVDRD.js +0 -13
  808. package/dist/chunk-BRJIXNFU.js +0 -5
  809. package/dist/chunk-C2GZLLSP.js +0 -5
  810. package/dist/chunk-ECSMTGVM.js +0 -6
  811. package/dist/chunk-EWTVVPUA.js +0 -11
  812. package/dist/chunk-FBR7ZLLN.js +0 -1
  813. package/dist/chunk-FGN2ZMEN.js +0 -1
  814. package/dist/chunk-FJSYWOE6.js +0 -1
  815. package/dist/chunk-FTECKRK6.js +0 -1
  816. package/dist/chunk-GRZTKMXQ.js +0 -1
  817. package/dist/chunk-HFCHOFLV.js +0 -2
  818. package/dist/chunk-HFF4GY7R.js +0 -3
  819. package/dist/chunk-HJXSEPO7.js +0 -111
  820. package/dist/chunk-HSEDKYH4.js +0 -1
  821. package/dist/chunk-II7AOJNH.js +0 -9
  822. package/dist/chunk-J34VKQGJ.js +0 -1
  823. package/dist/chunk-J6CDIH3S.js +0 -84
  824. package/dist/chunk-JHWLRL4U.js +0 -1
  825. package/dist/chunk-JMQ67UNK.js +0 -3
  826. package/dist/chunk-JRIP33PC.js +0 -13
  827. package/dist/chunk-K5M65CAF.js +0 -1
  828. package/dist/chunk-KJAR2WDO.js +0 -1
  829. package/dist/chunk-KX7MG72M.js +0 -1
  830. package/dist/chunk-L2B4DTVS.js +0 -1
  831. package/dist/chunk-LEKC4GQK.js +0 -5
  832. package/dist/chunk-LIGOOMJS.js +0 -10
  833. package/dist/chunk-LY2UANKU.js +0 -6
  834. package/dist/chunk-M7P7V4WI.js +0 -25
  835. package/dist/chunk-MXLSGMRZ.js +0 -3
  836. package/dist/chunk-N2NEFXHB.js +0 -13
  837. package/dist/chunk-NF74ITWT.js +0 -2
  838. package/dist/chunk-NQYUIQRH.js +0 -1
  839. package/dist/chunk-OCU6NW5Y.js +0 -1
  840. package/dist/chunk-OIEA4QWF.js +0 -4
  841. package/dist/chunk-ON5HDFNL.js +0 -10
  842. package/dist/chunk-P43GGKUC.js +0 -28
  843. package/dist/chunk-PPCWY4BB.js +0 -1
  844. package/dist/chunk-QGXZ4RWX.js +0 -1
  845. package/dist/chunk-S3T5NOSL.js +0 -1
  846. package/dist/chunk-S7E2D5K7.js +0 -5
  847. package/dist/chunk-SIYPD5MM.js +0 -3
  848. package/dist/chunk-STUZZM5B.js +0 -1
  849. package/dist/chunk-T4FTT3U4.js +0 -1
  850. package/dist/chunk-T5ACAOKJ.js +0 -4
  851. package/dist/chunk-TILMPAF2.js +0 -1
  852. package/dist/chunk-TSNY2FSU.js +0 -1
  853. package/dist/chunk-TWJINFQB.js +0 -9
  854. package/dist/chunk-TWQ6ACOI.js +0 -1
  855. package/dist/chunk-UDVVKVG4.js +0 -1
  856. package/dist/chunk-V2D5MLGE.js +0 -1
  857. package/dist/chunk-VDSSAP6Y.js +0 -1
  858. package/dist/chunk-VHYJTAXX.js +0 -1
  859. package/dist/chunk-WCSWQDJ2.js +0 -22
  860. package/dist/chunk-WQTF6Q2X.js +0 -3
  861. package/dist/chunk-XE4W5YTE.js +0 -2
  862. package/dist/chunk-YFPU2LRR.js +0 -23
  863. package/dist/chunk-YLEERRX3.js +0 -33
  864. package/dist/chunk-YOJHCARZ.js +0 -1
  865. package/dist/chunk-YPTDPMK5.js +0 -1
  866. package/docs/agent-guides/editing.md +0 -43
  867. package/docs/agent-guides/search.md +0 -38
  868. package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +0 -73
  869. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-63.js +0 -2
  870. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-64.js +0 -1
  871. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-66.js +0 -1
  872. package/node_modules/pi-agent-text-editor/runtime/entry-68.js +0 -1
  873. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-85.js +0 -2
  874. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +0 -2
  875. package/node_modules/pi-agent-tool-ui/runtime/entry-88.js +0 -1
  876. package/node_modules/pi-agent-tool-ui/runtime/entry-89.js +0 -1
  877. package/node_modules/pi-agent-web-html/runtime/entry-91.js +0 -2
  878. package/node_modules/pi-agent-web-image/runtime/entry-92.js +0 -2
  879. package/node_modules/pi-agent-web-pdf/runtime/entry-93.js +0 -2
  880. package/src/composite/search-facts.ts +0 -45
  881. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-91.js +0 -2
  882. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-92.js +0 -2
  883. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-93.js +0 -2
  884. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-94.js +0 -2
  885. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-58.js +0 -2
  886. package/src/extensions/pi-agent-search/runtime/entry-54.js +0 -1
  887. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-63.js +0 -2
  888. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-64.js +0 -1
  889. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-66.js +0 -1
  890. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-85.js +0 -2
  891. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +0 -2
  892. package/src/extensions/pi-agent-text-editor/runtime/entry-68.js +0 -1
  893. package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +0 -73
  894. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-54.js +0 -0
  895. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-58.js +0 -0
  896. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-62.js +0 -0
  897. /package/node_modules/{pi-agent-tool-call-interception → pi-agent-text-editor}/runtime/entry-87.js +0 -0
  898. /package/node_modules/{pi-agent-web → pi-agent-text-editor-stale-anchor}/runtime/entry-90.js +0 -0
  899. /package/node_modules/{pi-agent-web-text → pi-agent-web}/runtime/entry-94.js +0 -0
  900. /package/src/extensions/{pi-agent-read/extensions/pi-agent-web → pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor}/runtime/entry-90.js +0 -0
@@ -0,0 +1,18 @@
1
+ import{a as sr,c as or}from"./chunk-PBMHSK6J.js";import{b as er,c as tr,g as nr,j as rr,p as wt}from"./chunk-OA26FH5G.js";import{a as Zn}from"./chunk-BXGMMZT3.js";import{a as kn,b as An,c as we,e as Mn,f as On,k as Nn,l as $n,o as ht,q as jn,r as Un,s as Wn}from"./chunk-4AEYLVSR.js";import{a as qn}from"./chunk-47SPPIXK.js";import{a as Dn,b as Tn}from"./chunk-VAXLSPPU.js";import{a as Cn,e as Pn}from"./chunk-BW3XONMZ.js";import{f as En,g as In}from"./chunk-JXULBI4S.js";import{a as Gn}from"./chunk-2YO6RVX4.js";import{b as Fn,c as Hn}from"./chunk-MLFJU2US.js";import{a as Vn}from"./chunk-JY63UUC2.js";import{a as _n}from"./chunk-I3G6K7QU.js";import{a as bn,b as Sn}from"./chunk-HSAGZWPO.js";import{a as Xe,e as xn}from"./chunk-PS2B6THP.js";import{d as Ln,e as Rn}from"./chunk-XEPCURYZ.js";import{B as dn,G as un,H as pn,I as gn,e as mt,fa as fn,ia as mn,la as hn,ma as yn,ra as wn,ta as vn}from"./chunk-OEEE5BLN.js";import{d as zn,f as Bn}from"./chunk-YNOR4LIE.js";import{f as Xn}from"./chunk-JKM4E5VB.js";import{a as yt,b as Oe,c as Jn,d as Z}from"./chunk-XQMNVPNS.js";import{m as Me}from"./chunk-IRLWXPL4.js";import{a as F}from"./chunk-ZC65Z3CK.js";import{a as Yn}from"./chunk-ZAWRSA7N.js";import{a as Kn,b as Qn}from"./chunk-OFILFO6D.js";import{a}from"./chunk-EI7MMDWY.js";import Oi from"node:path";var ve=[{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"]}]}}},N("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}}),N("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"]}}},N("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"]),N("dart-language-server",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],{dart:[".dart"]},["dart","language-server","--protocol=lsp"],"https://dart.dev/tools/dart-language-server"),N("r-language-server",["r"],["Rscript"],["DESCRIPTION",".lintr",".Rprofile"],{r:[".r"]},["Rscript","-e","languageserver::run()"],"https://github.com/REditorSupport/languageserver"),N("zls",["zig"],["zls"],["build.zig","build.zig.zon","zls.json"],{zig:[".zig",".zon"]},["zls"],"https://zigtools.org/zls/"),N("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/"),N("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"]),N("basedpyright",["python"],["basedpyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),N("pyright",["python"],["pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["pyright-langserver","--stdio"],"https://microsoft.github.io/pyright/",["pyright"]),N("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),{id:"rust-analyzer",name:"rust-analyzer",kind:"lsp",languages:["rust"],executables:["rust-analyzer"],configFiles:["Cargo.toml","rust-project.json"],documentation:"https://rust-analyzer.github.io/",lsp:{command:["rust-analyzer"],rootMarkers:["Cargo.toml","rust-project.json"],languageIds:{rust:[".rs"]},initializationOptions:{checkOnSave:!1,cargo:{buildScripts:{enable:!1}},procMacro:{enable:!1}}}},N("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),N("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),N("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"),N("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),N("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),N("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),N("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),N("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),N("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:{}}),N("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"),N("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"),N("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),N("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),N("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),N("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"),N("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"),N("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"),N("neocmakelsp",["cmake"],["neocmakelsp"],["CMakeLists.txt",".neocmake.toml",".neocmakelint.toml"],{cmake:[".cmake"]},["neocmakelsp","stdio"],"https://github.com/neocmakelsp/neocmakelsp",void 0,{cmake:["CMakeLists.txt"]}),N("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"),N("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),N("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),N("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 N(t,e,n,r,s,o,i,c,l,d){return{id:t,name:t,kind:"lsp",languages:e,executables:n,configFiles:r,documentation:i,...c&&{dependencies:c},lsp:{command:o,rootMarkers:r,languageIds:s,...l&&{fileNames:l},...d&&{settings:d}}}}a(N,"recipe");var Ke="lsp.idle-timeout";function vt(t){let e=t.trim(),n=e===""?10:Number(e);if(!Number.isFinite(n)||n<=0)throw new Error(`Invalid ${Ke} setting "${t}": use a positive number of minutes.`);return Math.round(n*6e4)}a(vt,"lspIdleTimeoutMs");import{readFile as ur}from"node:fs/promises";import{URI as pr}from"vscode-uri";var Ne={Error:1,Warning:2,Information:3,Hint:4};var ir={command:"typescript.tsserverRequest",async request(t,e,n){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async s=>{let o=await t.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[s,{file:t.serverDocumentPath(e),includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},n);if(!bt(o)||o.success!==!0||!Array.isArray(o.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${s}`);return o.body.map(Ss)}))).flat()}};function Qe(t){return t.supportsCommand(ir.command)?ir:void 0}a(Qe,"completedDiagnosticAdapter");function Ss(t){if(!bt(t)||typeof t.message!="string"||typeof t.code!="number"&&typeof t.code!="string"||!bt(t.startLocation)||!Number.isInteger(t.startLocation.line)||!Number.isInteger(t.startLocation.offset)||Number(t.startLocation.line)<1||Number(t.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(t.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(t.code),message:t.message,line:Number(t.startLocation.line),column:Number(t.startLocation.offset),severity:t.category==="error"?"error":t.category==="warning"?"warning":t.category==="suggestion"?"hint":"info"}}a(Ss,"convertTypeScriptDiagnostic");function bt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}a(bt,"isRecord");function Ye(t){return t!==null&&typeof t=="object"&&"code"in t&&t.code===-32601}a(Ye,"isMethodNotFound");import{watch as ar}from"node:fs";import{readdir as _s,stat as cr}from"node:fs/promises";import G from"node:path";import{URI as St}from"vscode-uri";var Ct=4,lr=-32090,et="pi/sharedDiagnosticsSuperseded",$e=class{static{a(this,"LspFileWatchers")}#e=new Map;#t;#r=!1;#n;#s;#o;constructor(e,n,r){this.#n=G.resolve(e),this.#s=n,this.#o=r}async register(e,n){if(this.#r)throw new Error("Language server file watchers are disposed");let r=[];for(let s of n){let o=s.globPattern,i=typeof o=="string"?this.#n:G.resolve(St.parse(typeof o.baseUri=="string"?o.baseUri:o.baseUri.uri).fsPath);!Ze(i,this.#n)&&!Ze(this.#n,i)||r.push({base:i,expression:typeof o=="string"?o:o.pattern,kind:s.kind??7})}this.#e.set(e,r),r.length>0?await this.#a():this.#i()}unregister(e){this.#e.delete(e),this.#i()}dispose(){this.#r=!0,this.#e.clear(),this.#i()}#a(){if(this.#t)return this.#t.ready;let e=new Rt(this.#n,(n,r)=>this.#c(e,n,r),n=>{this.#t===e&&this.#o(n)});return this.#t=e,e.ready}#i(){[...this.#e.values()].some(e=>e.length>0)||(this.#t?.close(),this.#t=void 0)}#c(e,n,r){let s=a(o=>[...this.#e.values()].some(i=>i.some(c=>(c.kind&1<<o-1)!==0&&Ls(c,r))),"matching");!s(1)&&!s(2)&&!s(3)||cr(r).then(o=>{if(this.#t!==e||o.isDirectory())return;let i=n==="rename"?1:2;s(i)&&this.#s({uri:St.file(r).toString(),type:i})},o=>{this.#t===e&&(o.code!=="ENOENT"?this.#o(o):s(3)&&this.#s({uri:St.file(r).toString(),type:3}))})}};function Ls(t,e){return G.isAbsolute(t.expression)?G.matchesGlob(e,t.expression):Ze(e,t.base)?G.matchesGlob(G.relative(t.base,e),t.expression):!1}a(Ls,"matches");function Ze(t,e){return t===e||t.startsWith(e.endsWith(G.sep)?e:e+G.sep)}a(Ze,"within");var _t=new Set([".git"]),Lt=new Set(["node_modules"]),Rt=class{static{a(this,"TreeWatcher")}#e=new Map;#t;#r=!1;#n;#s;ready=Promise.resolve();constructor(e,n,r){if(this.#n=n,this.#s=r,process.platform==="linux"){this.ready=this.#o(e);return}let s=ar(e,{recursive:!0},(o,i)=>{if(!i)return;let c=G.join(e,i);Rs(G.relative(e,c))&&this.#n(o,c)});s.on("error",o=>this.#s(o)),this.#t=s}close(){this.#r=!0,this.#t?.close();for(let e of this.#e.values())e.close();this.#e.clear()}async#o(e){if(this.#r||this.#e.has(e))return;let n;try{n=ar(e,(s,o)=>{o&&this.#a(s,G.join(e,o))})}catch(s){this.#i(s);return}if(n.on("error",s=>{n.close(),this.#e.get(e)===n&&this.#e.delete(e),this.#i(s)}),this.#e.set(e,n),Lt.has(G.basename(e)))return;let r;try{r=await _s(e,{withFileTypes:!0})}catch(s){this.#i(s);return}for(let s of r)s.isDirectory()&&!_t.has(s.name)&&await this.#o(G.join(e,s.name))}#a(e,n){if(this.#r||(this.#n(e,n),e!=="rename"))return;let r=G.basename(G.dirname(n));_t.has(G.basename(n))||Lt.has(r)||cr(n).then(s=>{s.isDirectory()&&this.#o(n)},()=>{for(let[s,o]of this.#e)Ze(s,n)&&(o.close(),this.#e.delete(s))})}#i(e){let n=e.code;this.#r||n==="ENOENT"||n==="EACCES"||n==="EPERM"||this.#s(e instanceof Error?e:new Error(String(e)))}};function Rs(t){let e=t.split(G.sep);return!e.some((n,r)=>_t.has(n)||Lt.has(n)&&r<e.length-2)}a(Rs,"included");function dr(t,e){return e.map(n=>{let r=t??null;for(let s of n.section?.split(".").filter(Boolean)??[])r=typeof r=="object"&&r!==null?r[s]??null:null;return r})}a(dr,"configurationItems");async function ee(t,e){if(e?.aborted)throw t.catch(()=>{}),e.reason;if(!e)return t;let n;try{return await Promise.race([t,new Promise((r,s)=>{n=a(()=>s(e.reason),"onAbort"),e.addEventListener("abort",n,{once:!0})})])}finally{n&&e.removeEventListener("abort",n)}}a(ee,"waitWithSignal");function je(t,e){let n;return ee(new Promise(r=>{n=setTimeout(r,t)}),e).finally(()=>clearTimeout(n))}a(je,"delayWithSignal");var be=class{static{a(this,"SharedStartup")}controller=new AbortController;promise;settled=!1;waiters=0;constructor(e){this.promise=e(this.controller.signal);let n=a(()=>{this.settled=!0},"settled");this.promise.then(n,n)}async wait(e){this.waiters+=1;let n=await ee(this.promise,e).then(r=>({value:r}),r=>({error:r}));if(this.waiters-=1,!this.settled&&this.waiters===0){this.controller.abort(e?.reason);try{await this.promise}catch(r){if(r!==this.controller.signal.reason)throw new AggregateError([this.controller.signal.reason,r],"Startup cancellation and cleanup failed",{cause:r})}}if("error"in n)throw n.error;return n.value}};var tt="SOURCE_CHANGED",Cs=[0,100,250,500];function O(t,e){return Object.assign(new Error(t,e),{code:tt})}a(O,"sourceChanged");function Pt(t){return t?.code===tt}a(Pt,"isSourceChanged");async function te(t,e,n){for(let r=0;;r+=1)try{return await t()}catch(s){let o=Cs[r];if(o===void 0||e?.aborted||!Pt(s)&&!n?.(s))throw s;o>0&&await je(o,e)}}a(te,"retryWhileSourceChanges");async function pe(t,e,n,r={}){let s=new AbortController,o=AbortSignal.any([s.signal,...r.signal?[r.signal]:[]]),i=setTimeout(()=>s.abort(new Error(`[lsp] ${t.serverId}: diagnostics timed out for ${e}`)),t.timeoutMs);try{return await Ps(t,e,n,r.content,o)}finally{clearTimeout(i)}}a(pe,"requestDiagnostics");async function Ps(t,e,n,r,s){if(s.throwIfAborted(),t.diagnosticMode!=="push"){let l=t.documentVersion(e),d=t.pulledReport(e);try{let u=await t.sendRequest("textDocument/diagnostic",{textDocument:{uri:e},...d!==void 0&&{previousResultId:d.resultId}},s),p=u.kind==="full"&&Array.isArray(u.items)?u.items:u.kind==="unchanged"&&d!==void 0&&u.resultId===d.resultId?[...d.diagnostics]:void 0;if(p===void 0)throw new Error("Invalid full diagnostic report");if(t.documentVersion(e)!==l)throw new Error("Document changed during diagnostic request");return t.setDiagnosticMode("pull"),l!==void 0&&typeof u.resultId=="string"&&t.rememberPulledReport(e,{version:l,resultId:u.resultId,diagnostics:p}),gr(p,!1,!0)}catch(u){if(!Ye(u))throw u;t.setDiagnosticMode("push")}}let o=Qe(t);if(o){t.documentVersion(e)===void 0&&t.syncDocument(e,r??await ur(pr.parse(e).fsPath,"utf8"),n??"plaintext");let l=t.documentVersion(e),d=await o.request(t,e,s);if(s.throwIfAborted(),t.documentVersion(e)!==l)throw new Error("Document changed during diagnostic request");return{diagnostics:d,syntaxErrors:[],otherDiagnostics:d,unversioned:!1,complete:!0}}s.throwIfAborted();let i=t.documentVersion(e)!==void 0,c=i?void 0:r??await ur(pr.parse(e).fsPath,"utf8");s.throwIfAborted(),t.beginDiagnosticRequest(e);try{return await new Promise((l,d)=>{let u=t.documentVersion(e),p=a(b=>{let L=b;L.uri!==e||!Array.isArray(L.diagnostics)||L.version!==void 0&&L.version!==u||t.documentVersion(e)===u&&(w(),l(gr(L.diagnostics,L.version===void 0)))},"receive"),f=t.onNotification("textDocument/publishDiagnostics",p),y=a(()=>{w(),d(O("The language server has newer file text; resync before checking diagnostics."))},"superseded"),S=t.shared?t.onNotification(et,b=>{let L=b;L.uri===e&&L.version===u&&y()}):void 0,h=a(()=>{w(),d(s.reason)},"onAbort");function w(){f(),S?.(),s.removeEventListener("abort",h)}a(w,"cleanup"),s.addEventListener("abort",h,{once:!0});try{i||t.syncDocument(e,c??"",n??"plaintext"),u=t.documentVersion(e);let b=t.diagnosticPublication(e);b?p({uri:e,...b}):t.diagnosticSuperseded(e)&&y()}catch(b){w(),d(b)}})}finally{t.endDiagnosticRequest(e)}}a(Ps,"requestCurrentDiagnostics");function xt(t){return{code:String(t.code??"LSP"),message:t.message,line:t.range.start.line+1,column:t.range.start.character+1,severity:t.severity===Ne.Warning?"warning":t.severity===Ne.Information?"info":t.severity===Ne.Hint?"hint":"error"}}a(xt,"toDiagnostic");function gr(t,e,n=!1){let r=t.map(xt);return{diagnostics:r,syntaxErrors:[],otherDiagnostics:r,unversioned:e,complete:n}}a(gr,"classify");function mr(t,e=(n,r)=>Promise.resolve({cwd:r,external:!1})){return{id:"lsp",async diagnose(n,r){let s=await e(n,r.cwd,r.signal);if(s===void 0)return{status:"unavailable",diagnostics:[],reason:"No local language-server project found for this file"};let o=await t(s.cwd,s.external,r.signal);r.signal.throwIfAborted();let i=await o.getOrStart(n,s.cwd,"diagnostics",r.signal);if(r.signal.throwIfAborted(),!i)return{status:"unavailable",diagnostics:[],reason:"No language server configured for this file"};let c=i.toUri(n),l=o.languageId(n),d=i.retainDocument(c);try{i.syncDocument(c,r.content,l,!0)}catch(g){throw d(),g}let u=i.documentVersion(c),p={active:!0,queued:!1},f=a(()=>!r.signal.aborted&&i.documentVersion(c)===u,"current"),y=a(async()=>(await i.waitUntilLoaded(r.signal),pe(i,c,l,{signal:r.signal,content:r.content})),"request"),S,h,w=a(async()=>{if(S=void 0,h=void 0,!(p.active||!p.queued||!f())){p.active=!0,p.queued=!1;try{let g=await y();f()&&r.publish(fr(g,i.commandName))}catch(g){f()&&r.publish({status:"unavailable",diagnostics:[],reason:g instanceof Error?g.message:String(g),source:i.commandName})}finally{p.active=!1,b()}}},"pullAgain"),b=a(()=>{if(p.active||!p.queued||!f())return;let g=Date.now();h??=g,clearTimeout(S),S=setTimeout(()=>void w(),Math.max(0,Math.min(xs,h+Es-g)))},"schedule"),L=a(()=>{p.queued=!0,b()},"refresh"),T=i.onNotification("workspace/diagnostic/refresh",()=>{f()&&i.diagnosticMode==="pull"&&L()}),k=o.onPushDiagnostics(g=>{!f()||g.uri!==c||g.serverId!==i.serverId||g.cwd!==s.cwd||g.version!==void 0&&g.version!==u||(i.diagnosticMode==="pull"||Qe(i)?L():r.publish({status:"snapshot",diagnostics:g.diagnostics,source:i.commandName,reason:hr(g.version===void 0)}))}),M=a(()=>{clearTimeout(S),k(),T()},"unsubscribe");r.signal.addEventListener("abort",M,{once:!0});try{let g=await y();return u=i.documentVersion(c),fr(g,i.commandName)}catch(g){throw p.queued=!1,M(),r.signal.removeEventListener("abort",M),g}finally{d(),p.active=!1,b()}}}}a(mr,"createLspDiagnosticSource");var xs=750,Es=3e3;function hr(t){return`Latest push snapshot; completion is unknown${t?"; language server omitted the document version":""}`}a(hr,"snapshotReason");function fr(t,e){return t.complete?{status:"ready",diagnostics:t.diagnostics,source:e}:{status:"snapshot",diagnostics:t.diagnostics,reason:hr(t.unversioned),source:e}}a(fr,"toReport");import{URI as Do}from"vscode-uri";import yo from"node:path";import wo from"cross-spawn";import{createMessageConnection as vo,CancellationTokenSource as bo,ResponseError as kr,StreamMessageReader as So}from"vscode-jsonrpc/node";import{URI as Dr}from"vscode-uri";import{spawn as Is}from"node:child_process";import{closeSync as Ds,openSync as Ts,readFileSync as vr,renameSync as ks,statSync as As}from"node:fs";import{createHash as Ms}from"node:crypto";import{lstat as Os,mkdir as br,mkdtemp as Ns,rename as $s,rm as js,stat as Us,symlink as Ws,utimes as qs,writeFile as Fs}from"node:fs/promises";import{createRequire as Hs}from"node:module";import Gs from"node:net";import Sr from"node:os";import J from"node:path";import{PassThrough as yr}from"node:stream";var _r=10*6e4,Vs="PI_AGENT_IDE_LSP_LINGER_MS";function Lr(t){let e=t[Vs];return e!==void 0&&/^\d+$/u.test(e)?Number(e):void 0}a(Lr,"sharedServerLingerOverride");var It=["shared-server-host.mjs","server-request-handlers.mjs"],Rr=It[0],Et=zs();function zs(){try{return It.map(t=>vr(new URL(t,new URL("../src/plugins/pi-agent-ide-lsp/src/lsp/shared-servers.ts",import.meta.url).href),"utf8"))}catch(t){return t instanceof Error?t:new Error(String(t))}}a(zs,"readHostSources");var Cr=1e4,Bs=25,nt=class{static{a(this,"LspSharedServers")}_directory;constructor(e={}){this._directory=e.directory??J.join(Sr.tmpdir(),`pi-agent-ide-lsp-${wr()}`)}async attach(e){let n=Ks(),r=Js(e,n.version),s=await this._socketPath(r),o=await Pr(s,e.signal);if(!o){let i=await Zs(this._directory,n),c=eo(i,s,r,this._directory);o=await oo(s,c,e.signal)}try{let i=await io(o,{protocol:Ct,key:r,command:e.command,cwd:e.cwd,env:e.env,settings:e.settings,initialize:e.initialize,lingerMs:e.lingerMs,timeoutMs:e.timeoutMs},e.timeoutMs+Cr,e.signal);if(typeof i.pid!="number")throw new Error(typeof i.error=="string"?i.error:"Shared language server did not attach");return ao(o,i.pid)}catch(i){throw o.destroy(),i}}async _socketPath(e){if(await br(this._directory,{recursive:!0,mode:448}),process.platform==="win32")return`\\\\.\\pipe\\pi-agent-ide-lsp-${Dt(Xs())}-${e}`;let n=await Os(this._directory);if(!n.isDirectory()||n.uid!==wr()||(n.mode&63)!==0)throw new Error(`Shared language server directory is not private: ${this._directory}`);return J.join(this._directory,`${e}.sock`)}};function Js(t,e){return Dt(JSON.stringify([Ct,e,t.serverId,t.command,t.configuredEnv,t.initialize.rootUri,t.initialize.initializationOptions??null,t.settings??null]))}a(Js,"sharedServerKey");function wr(){return process.getuid?.()??-1}a(wr,"currentUid");function Xs(){try{return Sr.userInfo().username}catch{return process.env.USERNAME||process.env.USER||"unknown"}}a(Xs,"currentUserName");function Dt(t){return Ms("sha256").update(t).digest("hex").slice(0,24)}a(Dt,"hash");function Ks(){if(Et instanceof Error)throw Et;let t=Et,e=Hs(new URL(Rr,new URL("../src/plugins/pi-agent-ide-lsp/src/lsp/shared-servers.ts",import.meta.url).href)),n=new Map([...new Set(t.flatMap(Qs))].toSorted().map(r=>[r,Ys(r,e.resolve(r))]));return{sources:t,packages:n,version:Dt(JSON.stringify([t,[...n]]))}}a(Ks,"loadedHost");function Qs(t){return[...t.matchAll(/\bfrom\s+["']([^"'.][^"']*)["']/gu)].map(([,e=""])=>e).filter(e=>!e.startsWith("node:")).map(e=>{let n=e.split("/");return(e.startsWith("@")?n.slice(0,2):n.slice(0,1)).join("/")})}a(Qs,"packageImports");function Ys(t,e){for(let n=J.dirname(e);;n=J.dirname(n)){try{if(JSON.parse(vr(J.join(n,"package.json"),"utf8")).name===t)return n}catch{}if(J.dirname(n)===n)throw new Error(`Shared language server host package not found: ${t}`)}}a(Ys,"packageRoot");async function Zs(t,e){let n=J.join(t,`host-${e.version}`),r=J.join(n,Rr),s=a(async()=>{try{await Us(r);let i=new Date;return await qs(n,i,i),!0}catch{return!1}},"present");if(await s())return r;let o=await Ns(J.join(t,"staging-"));try{await Promise.all(It.map((i,c)=>Fs(J.join(o,i),e.sources[c]??"")));for(let[i,c]of e.packages){let l=J.join(o,"node_modules",i);await br(J.dirname(l),{recursive:!0}),await Ws(c,l,"junction")}await $s(o,n)}catch(i){if(await js(o,{recursive:!0,force:!0}),!await s())throw i}return r}a(Zs,"writeHost");function eo(t,e,n,r){let s=process.versions.bun||!so()?process.execPath:"node",o=J.join(r,`${n}.log`);to(o);let i=Ts(o,"w",384);try{let c=Is(s,[t,e,n,o],{cwd:r,detached:!0,env:no(),stdio:["ignore","ignore",i],windowsHide:!0});return c.unref(),c}finally{Ds(i)}}a(eo,"startHost");function to(t){try{let{mtimeMs:e,size:n}=As(t);n>0&&ks(t,t.replace(/\.log$/u,`.${String(Math.round(e))}.log`))}catch{}}a(to,"keepFailureLog");function no(){let t={};for(let e of ro){let n=process.env[e];n!==void 0&&(t[e]=n)}return process.versions.bun&&(t.BUN_BE_BUN="1"),t}a(no,"hostEnvironment");var ro=["PATH","Path","HOME","USERPROFILE","TMPDIR","TMP","TEMP","SystemRoot","LANG"];function so(){return process.getBuiltinModule("node:sea")?.isSea?.()??!1}a(so,"singleExecutable");function Pr(t,e){return e?.throwIfAborted(),new Promise((n,r)=>{let s=Gs.connect(t);s.once("connect",()=>{s.removeAllListeners("error"),s.on("error",()=>{}),n(s)}),s.once("error",o=>{s.destroy(),o.code==="ENOENT"||o.code==="ECONNREFUSED"?n(void 0):r(o)})})}a(Pr,"connect");async function oo(t,e,n){let r;e.once("error",o=>r=o),e.once("exit",o=>{o!==0&&(r=new Error(`Shared language server host exited with code ${o}`))});let s=Date.now()+Cr;for(;;){if(r)throw r;let o=await Pr(t,n);if(o)return o;if(Date.now()>s)throw new Error("Shared language server host did not start");await new Promise(i=>setTimeout(i,Bs))}}a(oo,"waitForHost");function io(t,e,n,r){return new Promise((s,o)=>{let i=Buffer.alloc(0),c=a(f=>{i=Buffer.concat([i,f]);let y=i.indexOf(10);if(y!==-1){p(),t.pause(),y+1<i.length&&t.unshift(i.subarray(y+1));try{s(JSON.parse(i.subarray(0,y).toString("utf8")))}catch(S){o(S)}}},"onData"),l=a(()=>{p(),o(new Error("Shared language server host closed the connection"))},"onClose"),d=a(()=>{p(),o(r?.reason)},"onAbort"),u=setTimeout(()=>{p(),o(new Error("Shared language server attach timed out"))},n),p=a(()=>{clearTimeout(u),t.off("data",c),t.off("close",l),r?.removeEventListener("abort",d)},"finish");t.on("data",c),t.once("close",l),r?.addEventListener("abort",d,{once:!0}),t.write(`${JSON.stringify(e)}
2
+ `)})}a(io,"exchange");function ao(t,e){let n=!1,r=new Promise(i=>t.once("close",()=>i())),s=new yr;s.end();let o=t.pipe(new yr);return{stdin:t,stdout:o,stderr:s,pid:e,completion:r.then(()=>({exitCode:n?0:1})),async stop(){n=!0,t.end();let i=setTimeout(()=>t.destroy(),1e3);await r,clearTimeout(i)}}}a(ao,"sharedServer");import{StreamMessageWriter as co}from"vscode-jsonrpc/node";var rt=class extends co{constructor(n,r){super(n);this.fail=r}static{a(this,"TransportWriter")}async write(n){try{await super.write(n)}catch(r){this.fail(r)}}};import lo from"node:path";import{URI as uo}from"vscode-uri";function X(t,e){if(e.startsWith("ssh://")){let n=xr(e);if(t.includes("://")){let s=xr(t);if(s.host!==n.host)throw new Error("Document belongs to another language server owner");return s.href}let r=lo.posix.resolve(decodeURIComponent(n.pathname),t);return n.pathname=r.split("/").map(encodeURIComponent).join("/"),n.href}if(t.startsWith("ssh://")||t.includes("://")&&!t.startsWith("file://"))throw new Error("Document belongs to another language server owner");return t.startsWith("file://")?t:uo.file(t).toString()}a(X,"documentUri");function xr(t){let e=new URL(t);if(e.protocol!=="ssh:"||!e.hostname||e.username||e.password||e.port||e.search||e.hash)throw new Error("Invalid language server resource owner");return decodeURIComponent(e.pathname),e}a(xr,"checkedRemote");var po=new Set(["uri","targetUri","target","oldUri","newUri","rootUri","documentUri","scopeUri","baseUri"]),go=new Set(["changes","relatedDocuments"]);function ce(t,e){return Array.isArray(t)?t.map(n=>ce(n,e)):typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([n,r])=>po.has(n)&&typeof r=="string"?[n,e(r)]:go.has(n)&&typeof r=="object"&&r!==null&&!Array.isArray(r)?[n,Object.fromEntries(Object.entries(r).map(([s,o])=>[e(s),ce(o,e)]))]:[n,ce(r,e)]))}a(ce,"mapLspUris");import fo from"node:path";var mo=/^clangd(?:-\d+(?:\.\d+)*)?$/u,ho=['u="${XDG_CONFIG_HOME:-$HOME/.config}/clangd/config.yaml"',"write() {",' c="$1/clangd/config.yaml"',' mkdir -p "$1/clangd" && {'," printf '%s\\n' '# Written by pi-agent-ide for the clangd it starts: report every error.' 'CompileFlags:' ' Add: [-ferror-limit=0]'",` if [ -f "$u" ] && [ "$u" != "$c" ]; then printf '%s\\n' '---'; cat "$u"; fi`,' } > "$c.$$" && mv -f "$c.$$" "$c" || { rm -f "$c.$$"; false; }',"}",'d="${XDG_CACHE_HOME:-$HOME/.cache}/pi-agent-ide/clangd-config"','if write "$d" 2>/dev/null || { d=$(mktemp -d "${TMPDIR:-/tmp}/pi-agent-ide-clangd.XXXXXX") && write "$d"; } 2>/dev/null; then',' XDG_CONFIG_HOME="$d"'," export XDG_CONFIG_HOME","fi",'exec "$@"'].join(`
3
+ `);function Er(t,e){let n=t[0];return!e||n===void 0||!mo.test(fo.posix.basename(n))?[...t]:["sh","-c",ho,"pi-agent-ide-clangd",...t]}a(Er,"launchCommand");function Ir(t=process.platform){return t!=="win32"&&t!=="darwin"}a(Ir,"localXdgConfig");var ge=class{static{a(this,"LspClient")}_process=null;_ownedProcess=null;_ownedStartup;_ownerTransport;_sharedServers;_sharedServer=null;_connection=null;_initialized=!1;_serverCapabilities=null;_disposed=!1;_shutdownPromise;_crashed=!1;_stderr="";_fileWatchers;_fileWatcherCleanup=Promise.resolve();_handlers=new Map;_documentVersions=new Map;_lastSharedDocumentVersion=0;_documentContents=new Map;_diagnosticPublications=new Map;_supersededDiagnostics=new Set;_pulledReports=new Map;_diagnosticMode="unknown";_pullRegistration;_versionedDiagnostics=!1;_activeDiagnosticRequests=new Set;_serverStatus;_serverStatusListeners=new Set;_pendingSaves=new Set;_documentLeases=new Map;_pendingRequests=0;_idleTimer;_idleTimeoutMs;_onIdle;serverId;rootUri;_command;_launch;_args;_env;_initOptions;_settings;_timeoutMs;constructor(e){this.serverId=e.serverId,this.rootUri=e.rootUri,this._command=e.command,this._launch=Er(e.command,e.ownerTransport!==void 0||Ir()),this._args=this._launch.slice(1),this._env=e.env??{},this._initOptions=e.initOptions,this._settings=e.settings,this._timeoutMs=e.timeoutMs??3e4,this._ownerTransport=e.ownerTransport,this._sharedServers=e.sharedServers,this._idleTimeoutMs=e.idleTimeoutMs,this._onIdle=e.onIdle}get ready(){return this._initialized&&!this._disposed}get crashed(){return this._crashed}get pid(){return this._process?.pid??this._sharedServer?.pid??null}get shared(){return this._sharedServer!==null}get remote(){return this._ownedProcess?.remote}get commandName(){return er(this._command)}get diagnosticMode(){return this._diagnosticMode}setDiagnosticMode(e){this._diagnosticMode=e}get timeoutMs(){return this._timeoutMs}supportsCommand(e){let n=this._serverCapabilities?.executeCommandProvider;return Array.isArray(n?.commands)&&n.commands.includes(e)}get loading(){return this._serverStatus?.quiescent===!1}async waitUntilLoaded(e){if(!this.loading)return;let n,r;try{await ee(new Promise((s,o)=>{n=a(()=>{this.loading||s()},"listener"),this._serverStatusListeners.add(n),r=setTimeout(()=>{let i=this._serverStatus?.message;o(Object.assign(new Error(`[lsp] ${this.serverId} is still loading the project${i?` (${i})`:""}; its results would be incomplete. Try again later.`),{code:"SERVER_LOADING"}))},this._timeoutMs)}),e)}finally{clearTimeout(r),n&&this._serverStatusListeners.delete(n)}}_setServerStatus(e){this._serverStatus=e;for(let n of[...this._serverStatusListeners])n()}get hasWorkspaceSymbolCapability(){let e=this._serverCapabilities?.workspaceSymbolProvider;return e===!0||typeof e=="object"&&e!==null}get hasFoldingRangeCapability(){let e=this._serverCapabilities?.foldingRangeProvider;return e===!0||typeof e=="object"&&e!==null}documentContent(e){return this._documentContents.get(e)}documentVersion(e){return this._documentVersions.get(e)}diagnosticPublication(e){return this._diagnosticPublications.get(e)}diagnosticSuperseded(e){return this._supersededDiagnostics.has(e)}pulledReport(e){let n=this._pulledReports.get(e);return n?.version===this.documentVersion(e)?n:void 0}rememberPulledReport(e,n){n.version===this.documentVersion(e)&&this._pulledReports.set(e,n)}beginDiagnosticRequest(e){this._activeDiagnosticRequests.add(e)}endDiagnosticRequest(e){this._activeDiagnosticRequests.delete(e)}hasActiveDiagnosticRequest(e){return this._activeDiagnosticRequests.has(e)}async start(e){e?.throwIfAborted();try{await this._start(e)}catch(n){try{await this.shutdown()}catch(r){throw new AggregateError([e?.aborted?e.reason:n,r],`[lsp] ${this.serverId}: startup and cleanup failed`,{cause:r})}throw e?.throwIfAborted(),n}}async _start(e){if(this._initialized)return;if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);if(!this.rootUri.startsWith("file://")&&!this._ownerTransport)throw Object.assign(new Error("No language server process transport for this resource owner"),{code:"UNSUPPORTED_SOURCE"});if(await this._closeFileWatchers(),e?.throwIfAborted(),this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let n=F(this._launch[0]),r=this._ownerTransport?decodeURIComponent(new URL(this.rootUri).pathname):Dr.parse(this.rootUri).fsPath,s=[{uri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,name:yo.basename(r)||r}],o=this._ownerTransport?this._ownerTransport.fileWatchers!==void 0:!0,i={processId:this._ownerTransport?null:process.pid,rootUri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,workspaceFolders:s,capabilities:{workspace:{applyEdit:!1,configuration:!0,workspaceFolders:!0,didChangeWatchedFiles:{dynamicRegistration:o,relativePatternSupport:o},symbol:{dynamicRegistration:!1}},experimental:{serverStatusNotification:!0},textDocument:{synchronization:{didOpen:!0,didChange:!0,didClose:!0},publishDiagnostics:{relatedInformation:!0,versionSupport:!0},diagnostic:{dynamicRegistration:!0,relatedDocumentSupport:!1},documentSymbol:{hierarchicalDocumentSymbolSupport:!0},foldingRange:{lineFoldingOnly:!0}}},initializationOptions:this._initOptions};this._ownedStartup=this._ownerTransport?.start({rootUri:this.rootUri,command:this._launch,env:this._env,signal:e});let c=await this._ownedStartup;if(this._ownedProcess=c??null,e?.throwIfAborted(),this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let l=c?void 0:await this._attachSharedServer(r,i,e);if(this._disposed)throw await l?.stop(),new Error(`[lsp] ${this.serverId}: disposed`);this._sharedServer=l??null,e?.throwIfAborted();let d=c||l?void 0:wo(n,this._args,{stdio:["pipe","pipe","pipe"],...e&&{signal:e},cwd:r,env:wt({command:this._command,env:this._env},r,process.env)});this._process=d??null;let u=d?xo(d):Promise.resolve(),p=c??l,f=F(p?.stdin??d?.stdin),y=F(p?.stdout??d?.stdout),S=F(p?.stderr??d?.stderr);f.on("error",()=>{}),y.on("error",()=>{}),S.on("error",()=>{}),this._stderr="";let h=new Promise(m=>{S.once("end",m),S.once("close",m)}),w,b=a(()=>{},"markExited"),L=new Promise(m=>{b=m});S.setEncoding("utf8"),S.on("data",m=>{this._stderr=(this._stderr+m).slice(-4096)}),d?.on("error",m=>{("code"in m?m.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,m),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null});let T=a(()=>c?this._ownedProcess===c:l?this._sharedServer===l:this._process===d,"current"),k=a(m=>{T()&&(w??=m,b(),this._closeFileWatchers(),!this._disposed&&m!==0&&m!==null&&(this._crashed=!0),this._connection?.dispose(),this._connection=null,this._diagnosticPublications.clear(),this._supersededDiagnostics.clear(),this._pulledReports.clear(),this._activeDiagnosticRequests.clear(),this._diagnosticMode="unknown",this._pullRegistration=void 0,this._versionedDiagnostics=!1,this._setServerStatus(void 0),this._process=null,this._initialized=!1)},"onExit");d?.on("exit",k),p?.completion.then(({exitCode:m})=>k(m),()=>{T()&&(this._crashed=!0,k(null))}),await ee(u,e);let M=vo(new So(y),new rt(f,m=>{this._connection!==M||this._disposed||(this._crashed=!0,this._initialized=!1,this._closeFileWatchers(),M.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,m))}));this._connection=M,this._connection.onError(m=>{console.error(`[lsp] ${this.serverId}: connection error:`,m)});let g=a(m=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[m]})},"changed"),C=a(m=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,m),"failed");this._fileWatchers=this._ownerTransport?this._ownerTransport.fileWatchers?.(this.rootUri,g,C):l?void 0:new $e(r,g,C),this._connection.onRequest("client/registerCapability",async m=>{for(let P of m.registrations)if(P.method!=="workspace/didChangeConfiguration"){if(P.method==="textDocument/diagnostic"){this._pullRegistration=P.id,this._initialized&&(this._diagnosticMode="pull");continue}if(P.method!=="workspace/didChangeWatchedFiles")throw new Error(`Unsupported dynamic capability: ${P.method}`);if(!this._fileWatchers)throw new Error("File watching is unavailable for this server owner");await this._fileWatchers.register(P.id,P.registerOptions?.watchers??[])}return null}),this._connection.onRequest("client/unregisterCapability",async m=>{for(let P of m.unregisterations)P.id===this._pullRegistration?(this._pullRegistration=void 0,this._initialized&&(this._diagnosticMode="push")):await this._fileWatchers?.unregister(P.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/diagnostic/refresh",()=>{for(let m of this._handlers.get("workspace/diagnostic/refresh")??[])m(void 0);return null}),this._connection.onRequest("workspace/configuration",m=>dr(this._settings,m.items)),this._connection.listen(),this._connection.onNotification((m,...P)=>{let I=this._ownerTransport,A=I?ce(P[0],x=>I.fromServerUri(x)):P[0];if(m===et){let x=A;if(!this.shared||typeof x?.uri!="string"||typeof x.version!="number"||x.version!==this.documentVersion(x.uri))return;this._supersededDiagnostics.add(x.uri)}if(m==="textDocument/publishDiagnostics"){let x=A;if(typeof x?.version=="number")this._versionedDiagnostics=!0;else if(this._versionedDiagnostics&&typeof x?.uri=="string"&&this._documentVersions.has(x.uri))return;x&&typeof x.uri=="string"&&Array.isArray(x.diagnostics)&&this._documentVersions.has(x.uri)&&(x.version===void 0||x.version===this.documentVersion(x.uri))&&(this._supersededDiagnostics.delete(x.uri),this._diagnosticPublications.set(x.uri,{diagnostics:x.diagnostics,...typeof x.version=="number"&&{version:x.version}}))}if(m==="experimental/serverStatus"){let x=A;this._setServerStatus({quiescent:x?.quiescent!==!1,...typeof x?.message=="string"&&{message:x.message}})}for(let x of this._handlers.get(m)?.slice()??[])x(A)}),this._connection.onRequest("workspace/workspaceFolders",()=>s);let E=await ee(Tr(this._connection.sendRequest("initialize",i),this._timeoutMs,`[lsp] ${this.serverId}: initialize timed out`),e).catch(async m=>{if(e?.aborted)throw m;await Promise.race([Promise.all([h,L]),je(_o,e)]).catch(()=>{});let P=this._stderr.trim(),I=w===void 0?void 0:`exited during startup${w===null?"":` with code ${w}`}`;if(!P&&!I)throw m;let A=`[lsp] ${this.serverId}${I?` ${I}`:""}${P?`: ${P}`:""}`;throw I?new Error(A):new Error(A,{cause:m})});if(await this._connection.sendNotification("initialized",{capabilities:E.capabilities}),this._settings!==void 0&&await this._connection.sendNotification("workspace/didChangeConfiguration",{settings:this._settings}),this._crashed)throw new Error(`[lsp] ${this.serverId}: transport failed during initialization`);e?.throwIfAborted(),this._initialized=!0,this._serverCapabilities=E.capabilities,this._diagnosticMode=E.capabilities.diagnosticProvider||this._pullRegistration!==void 0?"pull":"push"}async _attachSharedServer(e,n,r){if(this._sharedServers)try{return await this._sharedServers.attach({serverId:this.serverId,command:this._launch,cwd:e,configuredEnv:this._env,env:wt({command:this._command,env:this._env},e,process.env),settings:this._settings,initialize:n,lingerMs:Lr(process.env)??this._idleTimeoutMs??_r,timeoutMs:this._timeoutMs,...r&&{signal:r}})}catch{r?.throwIfAborted();return}}touch(){if(clearTimeout(this._idleTimer),this._idleTimer=void 0,this._idleTimeoutMs===void 0||this._disposed||this._busy)return;let e=setTimeout(()=>{this._idleTimer===e&&(this._idleTimer=void 0,this.ready&&!this._busy&&this._onIdle?.())},this._idleTimeoutMs);e.unref(),this._idleTimer=e}get _busy(){return this._pendingRequests>0||this._documentLeases.size>0}retainDocument(e){this._documentLeases.set(e,(this._documentLeases.get(e)??0)+1),this.touch();let n=!1;return()=>{if(n)return;n=!0;let r=(this._documentLeases.get(e)??1)-1;if(r>0){this._documentLeases.set(e,r);return}this._documentLeases.delete(e),this.ready&&this._documentVersions.has(e)&&this.closeDocument(e),this.touch()}}async restart(e){await this.shutdown(),this._closeFileWatchers(),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1,this._crashed=!1,this._disposed=!1,this._shutdownPromise=void 0,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._supersededDiagnostics.clear(),this._pulledReports.clear(),this._diagnosticMode="unknown",this._versionedDiagnostics=!1,this._activeDiagnosticRequests.clear(),this._serverCapabilities=null,await this.start(e)}async sendRequest(e,n,r){this._assertReady(),r?.throwIfAborted(),this._pendingRequests++,this.touch();try{let s=!1;for(let o=0;;o++){let i;try{i=await this._sendRequest(e,n,r)}catch(c){if(this.shared&&c instanceof kr&&c.code===lr)throw O(c.message);let l=Lo[o];if(l===void 0||!Po(c))throw c;await je(l,r),this._assertReady();continue}if(s||!this.loading||e==="workspace/executeCommand")return i;s=!0,await this.waitUntilLoaded(r),this._assertReady()}}finally{this._pendingRequests--,this.touch()}}async _sendRequest(e,n,r){let s=this._ownerTransport,o=s?ce(n,d=>s.toServerUri(d)):n,i=a(d=>s?ce(d,u=>s.fromServerUri(u)):d,"mapResult");if(!r)return i(await F(this._connection).sendRequest(e,o));let c=new bo,l;try{let d=F(this._connection).sendRequest(e,o,c.token);return i(await Promise.race([d,new Promise((u,p)=>{l=a(()=>{c.cancel(),p(r.reason)},"onAbort"),r.addEventListener("abort",l,{once:!0})})]))}finally{l&&r.removeEventListener("abort",l),c.dispose()}}sendNotification(e,n){this._assertReady(),this._sendNotification(e,n)}_sendNotification(e,n){let r=this._connection;if(!r)return;let s=this._ownerTransport,o=s?ce(n,i=>s.toServerUri(i)):n;r.sendNotification(e,o).catch(i=>{this._connection!==r||this._disposed||(this._crashed=!0,this._initialized=!1,this._closeFileWatchers(),r.dispose(),console.error(`[lsp] ${this.serverId}: notification ${e} failed:`,i))})}onNotification(e,n){let r=this._handlers.get(e)??[];return r.push(n),this._handlers.set(e,r),()=>{let s=r.indexOf(n);s!==-1&&r.splice(s,1)}}toUri(e){return X(e,this.rootUri)}serverDocumentPath(e){let n=this.toUri(e),r=this._ownerTransport?.toServerUri(n)??n;return this._ownerTransport?decodeURIComponent(new URL(r).pathname):Dr.parse(r).fsPath}openDocument(e,n,r,s=1){let o=this._documentVersions.get(e);if(o!==void 0){this.changeDocument(e,n,Math.max(s,o+1));return}this._diagnosticPublications.delete(e),this._supersededDiagnostics.delete(e),this._pulledReports.delete(e);let i=this._sharedDocumentVersion(s);this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:r,version:i,text:n}}),this._documentVersions.set(e,i),this._documentContents.set(e,n)}syncDocument(e,n,r,s=!1){if(this._documentContents.get(e)===n&&!this.diagnosticSuperseded(e))return;let o=this._documentVersions.get(e);o===void 0?this.openDocument(e,n,r):this.changeDocument(e,n,o+1),s&&(this.loading?this._deferSave(e):this._sendSave(e))}_sendSave(e){let n=this._serverCapabilities?.textDocumentSync,r=typeof n=="object"&&n!==null?n.save:void 0,s=this._documentContents.get(e);!r||s===void 0||this.sendNotification("textDocument/didSave",{textDocument:{uri:e},...typeof r=="object"&&r.includeText&&{text:s}})}_deferSave(e){let n=this._pendingSaves.size>0;if(this._pendingSaves.add(e),n)return;let r=a(()=>{if(this.loading)return;this._serverStatusListeners.delete(r);let s=[...this._pendingSaves];this._pendingSaves.clear();for(let o of s)this._sendSave(o)},"listener");this._serverStatusListeners.add(r)}changeDocument(e,n,r){let s=this._documentVersions.get(e),o=this._sharedDocumentVersion(Math.max(r,(s??0)+1));this._diagnosticPublications.delete(e),this._supersededDiagnostics.delete(e),this._pulledReports.delete(e),this.sendNotification("textDocument/didChange",{textDocument:{uri:e,version:o},contentChanges:[{text:n}]}),this._documentVersions.set(e,o),this._documentContents.set(e,n)}_sharedDocumentVersion(e){return this.shared?this._lastSharedDocumentVersion=Math.max(e,this._lastSharedDocumentVersion+1):e}closeDocument(e){this.sendNotification("textDocument/didClose",{textDocument:{uri:e}}),this._documentVersions.delete(e),this._documentContents.delete(e),this._diagnosticPublications.delete(e),this._supersededDiagnostics.delete(e),this._pulledReports.delete(e)}shutdown(){return this._shutdownPromise??=this._shutdown()}async _shutdown(){this._disposed=!0,this._setServerStatus(void 0),clearTimeout(this._idleTimer),this._idleTimer=void 0;let e=this._closeFileWatchers();if(this._connection&&this._initialized)try{await Tr(this._connection.sendRequest("shutdown"),Math.min(this._timeoutMs,1e3),`[lsp] ${this.serverId}: shutdown timed out`),await this._connection.sendNotification("exit").catch(()=>{})}catch{}this._connection?.dispose(),this._connection=null;let n=this._ownedProcess??await this._ownedStartup?.catch(()=>{});this._ownedProcess=null,this._ownedStartup=void 0;let r=Promise.resolve().then(()=>n?.stop()),s=this._sharedServer;this._sharedServer=null;let o=Promise.resolve().then(()=>s?.stop()),i=this._process;this._process=null,i&&!i.killed&&(i.kill("SIGTERM"),setTimeout(()=>{i.exitCode===null&&i.signalCode===null&&i.kill("SIGKILL")},2e3).unref()),this._initialized=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._supersededDiagnostics.clear(),this._pulledReports.clear(),this._diagnosticMode="unknown",this._versionedDiagnostics=!1,this._activeDiagnosticRequests.clear(),this._serverCapabilities=null;let c=await Promise.allSettled([r,o,e]),l=[];for(let d of c)d.status==="rejected"&&l.push(d.reason);if(l.length>0)throw new AggregateError(l,`[lsp] ${this.serverId}: owned cleanup failed`)}dispose(){return this.shutdown()}_closeFileWatchers(){let e=this._fileWatchers;return this._fileWatchers=void 0,e&&(this._fileWatcherCleanup=this._fileWatcherCleanup.catch(()=>{}).then(()=>e.dispose()),this._fileWatcherCleanup.catch(n=>{console.error(`[lsp] ${this.serverId}: file watcher cleanup failed:`,n)})),this._fileWatcherCleanup}_assertReady(){if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);if(this._crashed)throw new Error(`[lsp] ${this.serverId}: crashed \u2014 call restart()`);if(!this._initialized)throw new Error(`[lsp] ${this.serverId}: not started \u2014 call start()`);if(!this._connection)throw new Error(`[lsp] ${this.serverId}: connection lost`)}},_o=250,Lo=[50,100,200,400,800],Ro=-32801,Co=-32802;function Po(t){if(!(t instanceof kr))return!1;if(t.code===Ro)return!0;if(t.code!==Co)return!1;let e=t.data;return!(e!==null&&typeof e=="object"&&"retriggerRequest"in e&&e.retriggerRequest===!1)}a(Po,"isRetryableCancellation");function xo(t){return new Promise((e,n)=>{let r=a(()=>{t.off("spawn",s),t.off("error",o)},"cleanup"),s=a(()=>{r(),e()},"onSpawn"),o=a(i=>{r(),n(i)},"onError");t.once("spawn",s),t.once("error",o)})}a(xo,"waitForSpawn");function Tr(t,e,n){return new Promise((r,s)=>{let o=setTimeout(()=>{s(new Error(n))},e);t.then(i=>{clearTimeout(o),r(i)}).catch(i=>{clearTimeout(o),s(i instanceof Error?i:new Error(String(i)))})})}a(Tr,"withTimeout");import H from"node:path";import{existsSync as Eo}from"node:fs";function Ar(t){let e=new Map,n=new Map;for(let[r,s]of Object.entries(t))for(let[o,i]of Object.entries(s.languages))for(let c of i.extensions){let l=c.toLowerCase(),d=e.get(l);if(d!==void 0&&d!==o)throw new Error(`[lsp] extension conflict: "${l}" claimed by "${d}" and "${o}"`);e.set(l,o);let u=n.get(l)??[];u.push(r),n.set(l,u)}return{extToLanguageId:e,extToServerIds:n}}a(Ar,"buildLanguageLookup");var ie=class t{constructor(e,n,r){this._projectRoot=r;this._entries=e;let s=e.filter(o=>o.layer!=="built-in"||n.has(o.id));this._servers=Object.fromEntries(s.map(o=>[o.id,o.config])),this._lookup=Ar(this._servers)}static{a(this,"LspServerRegistry")}_servers;_entries;_lookup;static async fromPackageDir(e,n={}){n.signal?.throwIfAborted();let r=await nr(e,"lsp-servers",l=>Io(l).servers,n);if(n.signal?.throwIfAborted(),e.startsWith("ssh://")&&(!n.executableAvailable&&!n.executableAvailability||n.requireBuiltInEvidence&&!n.recipeEvidence))throw Object.assign(new Error("Remote language server availability needs its workspace owner"),{code:"UNSUPPORTED_SOURCE"});let s=n.environment??process.env,o=r.entries.filter(l=>l.layer==="built-in"),i=[];if(n.executableAvailability){let l=await n.executableAvailability(o.map(d=>d.config));if(l.length!==o.length||l.some(d=>typeof d!="boolean"))throw new TypeError("Invalid owner executable availability report");for(let[d,u]of o.entries())i.push({id:u.id,available:l[d]===!0})}else if(n.executableAvailable)for(let l of o)i.push({id:l.id,available:await n.executableAvailable(l.config)});else i.push(...await Promise.all(o.map(async l=>({id:l.id,available:await rr(l.config,e,s,n.signal)}))));n.signal?.throwIfAborted();let c=n.requireBuiltInEvidence?n.recipeEvidence?await n.recipeEvidence(n.recipes??[]):await Zn(e,n.recipes??[],void 0,n.signal):void 0;return n.signal?.throwIfAborted(),new t(r.entries,new Set(i.filter(l=>l.available&&(c===void 0||(c.get(l.id)?.score??0)>0)).map(l=>l.id)),e.startsWith("ssh://")?e:H.resolve(e))}static fromConfig(e,n=process.cwd()){return new t(Object.entries(e.servers).map(([r,s])=>({id:r,config:s,layer:"project",sourcePath:"<memory>"})),new Set,n.startsWith("ssh://")?n:H.resolve(n))}resolve(e){return this.candidates(e).filter(n=>!n.config.requireRootMarker||this.hasRootMarker(e,n.config.rootMarkers))}candidates(e){let n=H.basename(e),r=H.extname(e)||(e.startsWith(".")?e:`.${e}`),s=a(i=>process.platform==="win32"?i.toLowerCase():i,"normalizeName"),o=[];for(let i of this._entries)if(this._servers[i.id]){for(let[c,l]of Object.entries(i.config.languages))if(l.extensions.some(d=>d.toLowerCase()===r.toLowerCase())||l.fileNames?.some(d=>s(d)===s(n))){o.push({serverId:i.id,config:i.config,languageId:c,layer:i.layer,sourcePath:i.sourcePath});break}}return o}async resolveOwned(e,n){if(!this._projectRoot.startsWith("ssh://"))return this.resolve(e);let r=new URL(this._projectRoot),s=decodeURIComponent(r.pathname),o=e.startsWith(".")&&!e.includes("/"),i=e.includes("://")?new URL(e):new URL(r.href),c=e.includes("://")?decodeURIComponent(i.pathname):H.posix.resolve(s,e),l=H.posix.relative(s,c);if(i.origin!==r.origin||i.host!==r.host||i.protocol!==r.protocol||i.username||i.password||i.port||i.search||i.hash||l===".."||l.startsWith("../"))throw Object.assign(new Error("Language server resource belongs to another owner"),{code:"UNSUPPORTED_SOURCE"});let d=[];for(let u of this.candidates(o?e:c)){if(!u.config.requireRootMarker){d.push(u);continue}let p=o||c===s?s:H.posix.dirname(c);for(;;){let f=!1;for(let y of u.config.rootMarkers){let S=H.posix.resolve(p,y),h=H.posix.relative(s,S);if(h===".."||h.startsWith("../"))continue;let w=new URL(r.href);if(w.pathname=S.split("/").map(encodeURIComponent).join("/"),await n(w.href)){f=!0;break}}if(f){d.push(u);break}if(p===s)break;p=H.posix.dirname(p)}}return d}hasRootMarker(e,n){let r=H.dirname(H.resolve(this._projectRoot,e));for(e.startsWith(".")&&!e.includes(H.sep)&&(r=this._projectRoot);;){let s=H.relative(this._projectRoot,r);if(s===".."||s.startsWith(`..${H.sep}`)||H.isAbsolute(s))return!1;if(n.some(o=>Eo(H.join(r,o))))return!0;if(r===this._projectRoot)return!1;r=H.dirname(r)}}get projectRoot(){return this._projectRoot}get servers(){return this._servers}get entries(){return this._entries}get knownExtensions(){return new Set(this._lookup.extToLanguageId.keys())}languageId(e){let n=e.startsWith("ssh://")?decodeURIComponent(new URL(e).pathname):e;return(this._projectRoot.startsWith("ssh://")?this.candidates(n):this.resolve(n))[0]?.languageId??e.slice(1)}};function Io(t){if(typeof t!="object"||t===null||Array.isArray(t))throw new Error("LSP config must be an object");let e=t;if(e.version!==1)throw new Error("LSP config version must be 1");if(typeof e.servers!="object"||e.servers===null||Array.isArray(e.servers))throw new Error("LSP config servers must be an object");for(let[n,r]of Object.entries(e.servers)){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`LSP server ${n} must be an object`);let s=r;if(!Array.isArray(s.command)||s.command.length===0||s.command.some(o=>typeof o!="string"||o.length===0))throw new Error(`LSP server ${n}.command must be a non-empty string array`);if(s.transport!==void 0&&s.transport!=="stdio")throw new Error(`LSP server ${n} only supports stdio transport`);if(!Array.isArray(s.rootMarkers)||s.rootMarkers.some(o=>typeof o!="string"))throw new Error(`LSP server ${n}.rootMarkers must be a string array`);if(s.requireRootMarker!==void 0&&typeof s.requireRootMarker!="boolean")throw new TypeError(`LSP server ${n}.requireRootMarker must be a boolean`);if(s.requireRootMarker&&s.rootMarkers.length===0)throw new Error(`LSP server ${n}.requireRootMarker requires rootMarkers`);if(typeof s.languages!="object"||s.languages===null||Array.isArray(s.languages))throw new Error(`LSP server ${n}.languages must be an object`);for(let[o,i]of Object.entries(s.languages)){let c=typeof i=="object"&&i!==null&&!Array.isArray(i)?i.extensions:void 0;if(!Array.isArray(c)||c.length===0||c.some(d=>typeof d!="string"))throw new Error(`LSP server ${n} language ${o} requires extensions`);let l=i.fileNames;if(l!==void 0&&(!Array.isArray(l)||l.some(d=>typeof d!="string"||d.length===0||/[/\\]/u.test(d))))throw new Error(`LSP server ${n} language ${o}.fileNames must contain basenames`)}if(!Array.isArray(s.capabilities))throw new TypeError(`LSP server ${n}.capabilities must be an array`)}return t}a(Io,"parseLspConfig");var Mr={protocol:Fn,apiVersion:Hn,id:"lsp",setup(t){for(let e of ve)t.addToolRecipe(e);t.addSetupCheck({id:"effective-config",inspect:To}),t.addCheck({id:"config",title:"LSP",async run(e){try{let n=await ie.fromPackageDir(e.cwd,Or(e)),r=ko(n,e.files);return r.length===0?[{status:"skip",message:"No language server matches the inspected project files"}]:await Promise.all(r.map(async s=>{let o=`${s.serverId} [${s.layer}] command ${JSON.stringify(s.config.command)}`,i=e.workspace,c=new ge({serverId:s.serverId,rootUri:i?e.cwd:Do.file(e.cwd).toString(),...i&&{ownerTransport:{start:a(l=>i.start(l.command,l.env,l.signal),"start"),toServerUri:a(l=>i.toNativeUri(l),"toServerUri"),fromServerUri:a(l=>i.fromNativeUri(l),"fromServerUri")}},command:s.config.command,env:Ao(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 c.start(e.signal),{status:"pass",message:`${o}: initialized`,detail:s.sourcePath}}catch(l){return{status:"fail",message:`${o}: ${l instanceof Error?l.message:String(l)}`,detail:s.sourcePath}}finally{await c.shutdown()}}))}catch(n){return e.signal?.throwIfAborted(),[{status:"fail",message:n instanceof Error?n.message:String(n)}]}}})}};async function To(t){try{let e=await ie.fromPackageDir(t.cwd,Or(t)),n=[],r=new Map;for(let[s,o]of t.detectedLanguages){let i=o.flatMap(c=>e.resolve(c)).find(c=>c.languageId===s);i!==void 0&&(n.push({kind:"lsp",languageId:s,toolId:i.serverId}),await or(t,i.config)||r.set(i.serverId,{id:`lsp-${i.serverId}-unavailable`,message:`Configured language server ${i.serverId} cannot run ${JSON.stringify(i.config.command)}`}))}return{selections:n,actions:[...r.values()]}}catch(e){return t.signal?.throwIfAborted(),{actions:[{id:"lsp-config-invalid",message:`Language server configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}a(To,"inspectLspSetup");function Or(t){let e=t.workspace;return{...sr(t),recipeEvidence:e?n=>e.evidence(n,t.signal):void 0}}a(Or,"lspOptions");function ko(t,e){let n=new Map;for(let r of e){let s=t.resolve(r)[0];s!==void 0&&!n.has(s.serverId)&&n.set(s.serverId,s)}return[...n.values()]}a(ko,"applicableServers");function Ao(t,e){return Object.fromEntries(Object.entries({...t,...e}).filter(n=>n[1]!==void 0))}a(Ao,"definedEnvironment");var Mo={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 Se(t){return Mo[t]??`SymbolKind(${t})`}a(Se,"symbolKindName");async function Ue(t,e,n){let r=t.documentVersion(e),s=await t.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}},n);if(t.documentVersion(e)!==r)throw O("The document changed while the server listed its symbols.");return s??[]}a(Ue,"requestDocumentSymbols");async function Tt(t,e,n=100,r){return(await t.sendRequest("workspace/symbol",{query:e},r)??[]).slice(0,n)}a(Tt,"requestWorkspaceSymbols");import{ResponseError as Oo}from"vscode-jsonrpc/node";async function kt(t,e,n,r,s){try{return await t.sendRequest("textDocument/rename",{textDocument:{uri:e},position:n,newName:r},s)}catch(o){throw o instanceof Oo&&/^Files? must be saved first: /u.test(o.message)?O("The language server text changed during rename."):o}}a(kt,"requestRename");import ze from"node:path";import{diffLines as Wo}from"diff";var No=/^[\p{L}\p{Nl}_$][\p{L}\p{N}\p{Mn}\p{Mc}\p{Pc}$]*$/u,At=/^fatal_too_many_errors$|too many errors emitted/iu,$o=new Set(["fatal_too_many_errors","module_not_found","module_not_built","module_build_disabled","module_shadowed","module_build_shadowed_submodule","module_cycle","module_prebuilt","module_rebuild_finalized","cannot_open_file","file_modified","sloc_space_too_large","unsupported_bom","module_format_unhandled","pp_file_not_found","pp_through_header_not_found","pp_through_header_not_seen","pp_pragma_hdrstop_not_seen","pp_error_opening_file","fe_error_backend","fe_linking_module","fe_invalid_code_complete_file","fe_remap_missing_to_file","fe_remap_missing_from_file","module_map_not_found","missing_module","modules_embed_file_not_found","module_header_file_not_found","missing_vfs_overlay_file","invalid_vfs_overlay","extract_api_ignores_file_not_found","fe_pch_malformed","fe_pch_malformed_block","fe_ast_file_modified","module_file_conflict","ast_file_not_found","ast_file_out_of_date","ast_file_invalid","module_file_not_module","module_file_missing_top_level_submodule","imported_module_modmap_changed","imported_module_relocated","function_scope_depth_exceeded","bracket_depth_exceeded"]);function jo(t,e){return $o.has(t.replace(/^err_/u,""))||At.test(e)}a(jo,"isFatalClangError");function Nr(t){return`${t.line}:${t.character}`}a(Nr,"positionKey");async function _e(t,e,n,r){let s=[...new Set(n.flatMap(i=>i.match(/[\p{L}\p{N}_$]+/gu)??[]))],o=[];for(let i of t){let{uri:c,start:l,text:d}=e(i);if(!No.test(d)||s.includes(d)){o.push(i);continue}let u=await r(c);u!==void 0&&(u.starts.has(Nr(l))||u.stopped&&s.some(f=>Uo(d,f)))||o.push(i)}return o}a(_e,"withoutCorrectedNames");function Uo(t,e){let n=Math.floor((t.length+2)/3);if(Math.abs(t.length-e.length)>n)return!1;let r=Array.from({length:e.length+1},(s,o)=>o);for(let s=1;s<=t.length;s++){let o=[s];for(let i=1;i<=e.length;i++)o[i]=Math.min((r[i]??0)+1,(o[i-1]??0)+1,(r[i-1]??0)+(t[s-1]===e[i-1]?0:1));r=o}return(r[e.length]??1/0)<=n}a(Uo,"withinTypoDistance");function ne(t,e){let n=[0];for(let i=t.indexOf(`
4
+ `);i!==-1;i=t.indexOf(`
5
+ `,i+1))n.push(i+1);let r=a(i=>{let c=n[i.line];return c===void 0?void 0:c+i.character},"offset"),s=r(e.start),o=r(e.end);return s===void 0||o===void 0||o<s?"":t.slice(s,o)}a(ne,"textInRange");function Le(t,e){let n=new Map,r=a(async s=>{try{let o=await t(s);if(!o)return;let{diagnostics:i}=await pe(o.client,o.uri,o.languageId,{...e&&{signal:e}}),c=i.filter(l=>l.severity==="error");return{starts:new Set(c.map(l=>Nr({line:l.line-1,character:l.column-1}))),stopped:c.some(l=>At.test(l.code)||At.test(l.message)),fatal:c.filter(l=>jo(l.code,l.message)).map(({line:l,message:d})=>({line:l,message:d}))}}catch(o){if(e?.throwIfAborted(),Pt(o))throw o;if(o instanceof Error)return;throw o}},"read");return s=>{let o=n.get(s);return o===void 0&&(o=r(s),n.set(s,o)),o}}a(Le,"diagnosticErrors");function st(t,e,n,r){let s=t.mapRange(e);return s!==void 0&&ne(n,s)===r?s:void 0}a(st,"followRange");var qo=500,ae=class t{constructor(e){this.runs=e}static{a(this,"LinePositionMap")}static between(e,n){if(e===n)return new t([[0,0,Number.MAX_SAFE_INTEGER]]);let r=Wo(e,n,{timeout:qo});if(r===void 0)return new t(void 0);let s=[],o=0,i=0;for(let c of r){let l=c.count;c.added?i+=l:c.removed?o+=l:(s.push([o,i,l]),o+=l,i+=l)}return new t(s)}mapRange(e){let n=this.runs?.find(([s,,o])=>e.start.line>=s&&e.end.line<s+o);if(n===void 0)return;let r=n[1]-n[0];return{start:{line:e.start.line+r,character:e.start.character},end:{line:e.end.line+r,character:e.end.character}}}};import{URI as ci}from"vscode-uri";import{createHash as Bo}from"node:crypto";import{readdir as Jo,stat as Fr}from"node:fs/promises";import le from"node:path";import{URI as ot}from"vscode-uri";async function Mt(t,e){if(!t.supportsCommand("typescript.tsserverRequest"))return;if((await t.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:e,needFileNameList:!0},{isAsync:!1,expectsResult:!0}]}))?.success!==!0)throw new Error("TypeScript could not load the project for a workspace query.")}a(Mt,"prepareProjectQuery");import{AsyncLocalStorage as Fo}from"node:async_hooks";var Ot=new Fo;async function re(t){if(Ot.getStore()!==void 0)return t();let e=new Map;try{return await Ot.run(e,t)}finally{for(let n of e.values())for(let r of n.values())r()}}a(re,"withLspDocuments");function $r(t,e){let n=Ot.getStore();if(n===void 0)return;let r=n.get(t)??new Map;n.set(t,r),r.has(e)||r.set(e,t.retainDocument(e))}a($r,"retainForCurrentOperation");import{execFile as Ho}from"node:child_process";import{existsSync as Go}from"node:fs";import Vo from"node:os";import Nt from"node:path";function jr(t,e){return["--files-with-matches","--fixed-strings","--word-regexp","--no-config","--no-messages","--path-separator=/",...e.flatMap(n=>["--glob",`*${n}`]),"--regexp",t,"--","."]}a(jr,"filesContainingArguments");function Ur(t){return t.split(`
6
+ `).map(e=>e.replace(/\r$/u,"").replace(/^\.\//u,"")).filter(e=>e.length>0)}a(Ur,"filesContainingOutput");function zo(){let t=process.env.PI_CODING_AGENT_DIR??Nt.join(Vo.homedir(),".pi","agent"),e=Nt.join(t,"bin",process.platform==="win32"?"rg.exe":"rg");return Go(e)?e:"rg"}a(zo,"ripgrep");function Wr(t,e,n,r){return new Promise((s,o)=>{Ho(zo(),[...jr(e,n)],{cwd:t,maxBuffer:64*1024*1024,...r&&{signal:r}},(i,c,l)=>{if(i&&i.code!==1){o(r?.aborted?r.reason:new Error(`Listing files that contain ${e} failed: ${l||i.message}`));return}s(Ur(c).map(d=>Nt.join(t,d)))})})}a(Wr,"localFilesContaining");function qr(t,e){let n=a(r=>typeof r=="string"?r.replaceAll("{project}",()=>e):Array.isArray(r)?r.map(n):r!==null&&typeof r=="object"?Object.fromEntries(Object.entries(r).map(([s,o])=>[s,n(o)])):r,"expand");return Object.fromEntries(Object.entries(t).map(([r,s])=>[r,n(s)]))}a(qr,"resolveInitializationOptions");var fe=class t{constructor(e,n,r={}){this._registry=e;this._owner=n;this._options=r}static{a(this,"LspManager")}_clients=new Map;_clientStarts=new Map;_pushUnsubscribers=new Map;_pushHandlers=new Set;_pushFingerprints=new Map;_disposed=!1;static _instance=null;static getInstance(){if(!t._instance)throw new Error("[lsp] LspManager not initialized");return t._instance}static getInstanceOrNull(){return t._instance}static init(e,n,r={}){let s=t._instance;return s?._disposed?(s._registry=e,s._owner=n,s._options=r,s._disposed=!1,s):(t._instance=new t(e,n,r),t._instance)}static async resetForTest(){t._instance&&(await t._instance.shutdownAll(),t._instance=null)}requireOwner(){if(!this._owner)throw Object.assign(new Error("No language server workspace owner"),{code:"UNSUPPORTED_SOURCE"});return this._owner}get workspaceRoot(){return this._registry.projectRoot}get clientCount(){return this._clients.size}onPushDiagnostics(e){return this._pushHandlers.add(e),()=>this._pushHandlers.delete(e)}async getOrStart(e,n,r,s){if(s?.throwIfAborted(),this._disposed)return null;let o=n.startsWith("ssh://"),i=o?this.requireOwner():void 0,c=i?await this._registry.resolveOwned(e,w=>i.exists(w,s)):this._registry.resolve(e);if(s?.throwIfAborted(),this._disposed)return null;let l=r==="symbols"?c[0]:c.find(w=>w.config.capabilities.includes(r));if(!l)return null;let d=o?n:ot.file(n).toString(),u=`${l.serverId}:${d}`,p=this._clientStarts.get(u);if(p)return p.controller.signal.aborted?(await ee(p.promise.catch(()=>{}),s),this.getOrStart(e,n,r,s)):p.wait(s);let f=this._clients.get(u);if(f?.ready)return f.touch(),f;let y=new be(w=>this._startClient(u,d,l,f,w));this._clientStarts.set(u,y);let S=a(()=>{this._clientStarts.get(u)===y&&this._clientStarts.delete(u)},"settled");y.promise.then(S,S);let h=await y.wait(s);return h.touch(),h}_stopIdleClient(e,n){if(this._clients.get(e)===n){this._clients.delete(e),this._pushUnsubscribers.get(e)?.(),this._pushUnsubscribers.delete(e);for(let r of this._pushFingerprints.keys())r.startsWith(`${e}:`)&&this._pushFingerprints.delete(r)}n.shutdown().catch(r=>{console.error(`[lsp] ${n.serverId}: idle shutdown failed:`,r)})}async _startClient(e,n,r,s,o){let i=s??new ge({serverId:r.serverId,rootUri:n,command:r.config.command,...n.startsWith("ssh://")&&this._owner&&{ownerTransport:this._owner.transport(n)},...!n.startsWith("ssh://")&&this._options.sharedServers&&{sharedServers:this._options.sharedServers},...r.config.env&&{env:r.config.env},...r.config.initializationOptions&&{initOptions:qr(r.config.initializationOptions,n.startsWith("ssh://")?decodeURIComponent(new URL(n).pathname):ot.parse(n).fsPath)},...r.config.settings&&{settings:r.config.settings},...r.config.timeoutMs&&{timeoutMs:r.config.timeoutMs},...this._options.idleTimeoutMs!==void 0&&{idleTimeoutMs:this._options.idleTimeoutMs,onIdle:a(()=>this._stopIdleClient(e,i),"onIdle")}});try{s?await s.restart(o):await i.start(o),o.throwIfAborted()}catch(c){try{await i.shutdown()}catch(l){if(l!==c)throw new AggregateError([c,l],"Language server startup and cleanup failed",{cause:l})}throw c}if(this._disposed)throw await i.shutdown(),new Error(`[lsp] ${r.serverId}: manager disposed during startup`);return this._clients.set(e,i),this._subscribeToPushDiagnostics(e,i),i}async isSourceFile(e,n,r){if(r?.throwIfAborted(),n.startsWith("ssh://")){if(this._owner===void 0)throw new Error("No language server workspace owner");return this._owner.isFile(X(e,n),r)}let s=await Fr(le.resolve(n,e));return r?.throwIfAborted(),s.isFile()}async filesContaining(e,n,r,s){s?.throwIfAborted();let o=[...this._registry.knownExtensions].filter(i=>r.has(this._registry.languageId(i)));return o.length===0?[]:e.rootUri.startsWith("ssh://")?this.requireOwner().filesContaining?.(e.rootUri,n,o,s):Wr(ot.parse(e.rootUri).fsPath,n,o,s)}async getWorkspaceClients(e,n="symbols",r=e,s=()=>!0,o,i){if(o?.throwIfAborted(),e.startsWith("ssh://")){let f=this._owner;if(!f)throw Object.assign(new Error("No language server workspace owner"),{code:"UNSUPPORTED_SOURCE"});let y=new Set,S=new Set(this._registry.knownExtensions),h=new Set([".git",".cache","node_modules","dist","build"]),w=a(async L=>{if(o?.throwIfAborted(),S.size!==0)for(let T of await f.entries(L,o)){o?.throwIfAborted();let k=X(T.name,`${L}/`);if(T.kind==="directory")h.has(T.name)||await w(k);else if(T.kind==="file"){let M=le.posix.extname(T.name).toLowerCase();if(!S.has(M)||!s(k))continue;let g=await this.openFile(k,e,n,o,i);g&&(y.add(g.client),S.delete(M))}}},"visit"),b=X(r,e);if(await f.isFile(b,o)){if(!s(b))return[];let L=await this.openFile(b,e,n,o,i);return L?[L.client]:[]}return await w(b),[...y]}let c=new Set,l=new Set(this._registry.knownExtensions),d=new Set([".git",".cache","node_modules","dist","build"]),u=a(async f=>{if(o?.throwIfAborted(),l.size===0)return;let y;try{y=await Jo(f,{withFileTypes:!0})}catch{return}for(let S of y){if(o?.throwIfAborted(),l.size===0)return;if(S.isDirectory()){d.has(S.name)||await u(le.join(f,S.name));continue}if(!S.isFile())continue;let h=le.extname(S.name).toLowerCase();if(!l.has(h))continue;let w=le.join(f,S.name);if(!s(w))continue;let b=await this.openFile(w,e,n,o,i);b&&(l.delete(h),b.client.hasWorkspaceSymbolCapability&&(await Mt(b.client,w),c.add(b.client)))}},"visit"),p=le.resolve(e,r);if((await Fr(p)).isFile()){if(!s(p))return[];let f=await this.openFile(p,e,n,o,i);return f===null||!f.client.hasWorkspaceSymbolCapability?[]:(await Mt(f.client,p),[f.client])}return await u(p),o?.throwIfAborted(),[...c]}async prepareWorkspaceSymbols(e,n=e,r,s,o){return this.getWorkspaceClients(e,"symbols",n,r,s,o)}hasServerFor(e){return this._registry.resolve(e).length>0}languageId(e){return this._registry.languageId(e)}syncEditedSource(e,n){for(let r of this._clients.values()){if(!r.ready)continue;let s=r.toUri(e);if(r.documentContent(s)===void 0)continue;let o=this.languageId(le.extname(decodeURIComponent(new URL(s).pathname)));r.syncDocument(s,n,o,!0)}}async readSourceSnapshot(e,n){if(n?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readSnapshot(e,n);if(e.includes("://"))throw Object.assign(new Error("Unsupported rename source"),{code:"UNSUPPORTED_SOURCE"});let r=await mn(e,()=>this.readSourceText(e,n),(s,o)=>s===o,this._options.fileGeneration);if(r===void 0)throw O("A rename source changed while reading it. No edits applied.");return{content:r.value,version:Bo("sha256").update(r.stamp).update("\0").update(r.value).digest("hex")}}async readSourceBytes(e,n){if(n?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readBytes(e,n);if(e.includes("://"))throw Object.assign(new Error("Unsupported declaration source"),{code:"UNSUPPORTED_SOURCE"});let{readFile:r}=await import("node:fs/promises");return r(e,{signal:n})}async readSourceText(e,n){if(n?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readText(e,n);if(e.includes("://"))throw Object.assign(new Error("Unsupported declaration source"),{code:"UNSUPPORTED_SOURCE"});let{readFile:r}=await import("node:fs/promises");return r(e,{encoding:"utf8",signal:n})}async openFile(e,n,r="diagnostics",s,o){if(s?.throwIfAborted(),e.startsWith("ssh://")&&!n.startsWith("ssh://")){if(!this._registry.projectRoot.startsWith("ssh://"))throw Object.assign(new Error("Remote document has no workspace owner"),{code:"UNSUPPORTED_SOURCE"});n=this._registry.projectRoot}let i=n.startsWith("ssh://"),c=i?X(e,n):le.resolve(n,e),l=await this.getOrStart(c,n,r,s);if(!l)return null;let d=l.toUri(c);$r(l,d);let u=i?this.requireOwner():void 0,f=(u?await this._registry.resolveOwned(c,y=>u.exists(y,s)):this._registry.resolve(c))[0]?.languageId??"plaintext";if(u){let y=o?await o(c):await u.readText(d,s);return s?.throwIfAborted(),l.syncDocument(d,y,f),await l.waitUntilLoaded(s),{client:l,uri:d,languageId:f}}try{let{readFile:y}=await import("node:fs/promises"),S=o?await o(c):await y(c,{encoding:"utf8",signal:s});s?.throwIfAborted(),l.syncDocument(d,S,f)}catch(y){if(s?.throwIfAborted(),!(y instanceof Error&&"code"in y&&y.code==="ENOENT"))throw y}return await l.waitUntilLoaded(s),{client:l,uri:d,languageId:f}}_subscribeToPushDiagnostics(e,n){if(this._pushUnsubscribers.has(e))return;let r=n.onNotification("textDocument/publishDiagnostics",s=>{let o=Xo(s);if(!o||n.hasActiveDiagnosticRequest(o.uri))return;let i=n.documentVersion(o.uri);if(o.version!==void 0&&i!==void 0&&o.version<i)return;let c=`${e}:${o.uri}`,l=o.diagnostics.map(xt),d=JSON.stringify([o.version,i,l]);if(this._pushFingerprints.get(c)===d)return;this._pushFingerprints.set(c,d);let u={cwd:n.rootUri.startsWith("ssh://")?n.rootUri:ot.parse(n.rootUri).fsPath,serverId:n.serverId,uri:o.uri,diagnostics:l,...o.version!==void 0&&{version:o.version}};for(let p of this._pushHandlers)p(u)});this._pushUnsubscribers.set(e,r)}async shutdownAll(){this._disposed=!0;let e=[...this._clientStarts.values()];for(let i of e)i.controller.abort(new Error("Language server manager stopped"));let n=await Promise.allSettled(e.map(i=>i.promise)),r=[];for(let[i,c]of n.entries())c.status==="rejected"&&c.reason!==e[i]?.controller.signal.reason&&r.push(c.reason);let s=[...this._clients.values()],o=await Promise.allSettled(s.map(i=>i.shutdown()));for(let i of this._pushUnsubscribers.values())i();this._pushUnsubscribers.clear(),this._clientStarts.clear(),this._pushFingerprints.clear(),this._pushHandlers.clear(),this._clients.clear();for(let i of o)i.status==="rejected"&&r.push(i.reason);if(r.length>0)throw new AggregateError(r,"Language server cleanup failed")}dispose(){return this.shutdownAll()}};function Xo(t){if(t===null||typeof t!="object")return;let e=t;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}a(Xo,"parsePushNotification");async function jt(t,e){let n=new AbortController,r=t?AbortSignal.any([t,n.signal]):n.signal,s=setTimeout(()=>{n.abort(Object.assign(new Error(`LSP search timed out after ${mt/1e3} s. Retry or search the text.`),{code:"LSP_NAVIGATION_TIMEOUT"}))},mt);try{r.throwIfAborted();let o=await e(r);return r.throwIfAborted(),o}catch(o){throw r.throwIfAborted(),o}finally{clearTimeout(s)}}a(jt,"withNavigationDeadline");async function $t(t){try{return await t}catch(e){if(Ye(e))return;throw e}}a($t,"unlessUnsupported");async function Ut(t,e,n){if(n?.throwIfAborted(),!t.supportsCommand("typescript.tsserverRequest"))return;let r=await t.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:t.serverDocumentPath(e),needFileNameList:!0},{isAsync:!1,expectsResult:!0}]},n);if(n?.throwIfAborted(),r?.success!==!0)throw new Error("TypeScript could not load the project for the workspace query.")}a(Ut,"loadQueryProject");async function We(t,e,n,r){return await Ut(t,e,r),await t.sendRequest("textDocument/references",{textDocument:{uri:e},position:n,context:{includeDeclaration:!0}},r)??[]}a(We,"requestReferences");function it(t,e){if(e.length===0)throw O(`The language server returned no locations for "${t}", including its known declaration. Retry or search the text.`)}a(it,"requireReferenceReply");async function Wt(t,e,n,r){let s=await $t(t.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:n},r));if(s===void 0)return{items:[],incoming:[],outgoing:[],unsupported:["incoming","outgoing"]};let o=s?.[0];if(!o)return{items:[],incoming:[],outgoing:[],unsupported:[]};let[i,c]=await Promise.all([$t(t.sendRequest("callHierarchy/incomingCalls",{item:o},r)),$t(t.sendRequest("callHierarchy/outgoingCalls",{item:o},r))]);return{items:s,incoming:i??[],outgoing:c??[],unsupported:[...i===void 0?["incoming"]:[],...c===void 0?["outgoing"]:[]]}}a(Wt,"requestCallHierarchy");function Re(t){if(/\r(?!\n)/u.test(t))throw Object.assign(new Error("This file holds a carriage return that is not followed by a line feed. Language servers disagree about the line it ends, so its LSP positions cannot select exact text. Use text search for this file."),{code:"LSP_AMBIGUOUS_LINE_BREAK"})}a(Re,"assertLspLines");function qe(t,e,n){Re(e.content);let{start:r,end:s}=n;for(let l of[r,s]){let d=e.lines[l.line];if(!Number.isInteger(l.line)||!Number.isInteger(l.character)||d===void 0||l.character<0||l.character>d.content.length-(d.content.endsWith("\r")?1:0))throw O("LSP range does not match its source snapshot.")}let o=a(l=>e.lines.slice(0,l).reduce((d,u)=>d+u.content.length+u.lineEnding.length,0),"offset"),i=o(r.line)+r.character,c=o(s.line)+s.character;if(c<i)throw new Error("LSP returned a reversed source range.");return{source:t,lineNumber:r.line+1,endLineNumber:s.line+1,startColumn:r.character,endColumn:s.character,matchedText:e.content.slice(i,c),lineText:F(e.lines[r.line]).content}}a(qe,"lspRangeMatch");var de=new Set(["c","cpp","objective-c","objective-cpp"]),Ko=32;function Qo(t){return t.match(/[\p{L}\p{N}_$]+/gu)?.at(-1)}a(Qo,"searchedWord");function Pe(t){let{manager:e,cwd:n,errorsOf:r,signal:s}=t,o=new Map,i=0,c=a(async(l,d)=>{let u=await e.filesContaining(l,d,de,s);if(u===void 0)return{client:l,opened:[],unopened:[],unlisted:!0};let p=[],f=[];for(let y of[...new Set(u)].sort()){if(s?.throwIfAborted(),t.accepts!==void 0&&!t.accepts(y))continue;let S=l.toUri(y);if(l.documentContent(S)===void 0){if(i>=Ko){f.push(y);continue}if(i+=1,(await e.openFile(y,n,"symbols",s))?.client!==l){f.push(y);continue}}p.push(S)}return await Promise.all(p.map(y=>r(y))),{client:l,opened:p,unopened:f,unlisted:!1}},"reach");return async(l,d,u)=>{if(!de.has(d))return;let p=Qo(u);if(p===void 0)return{client:l,opened:[],unopened:[],unlisted:!1};let f=JSON.stringify([l.serverId,l.rootUri,p]),y=o.get(f);return y===void 0&&(y=c(l,p),o.set(f,y)),y}}a(Pe,"createClangReach");async function xe(t,e,n,r){let s=[...new Set([...e,...t.opened])].filter(i=>t.client.documentContent(i)!==void 0),o=await Promise.all(s.map(i=>n(i)));return{fatal:s.flatMap((i,c)=>(o[c]?.fatal??[]).map(l=>({source:r(i),...l}))),unopened:t.unopened,missingDiagnostics:s.flatMap((i,c)=>o[c]===void 0?[r(i)]:[]),unlisted:t.unlisted}}a(xe,"clangCoverage");function Ee(t){return t===void 0||t.fatal.length===0&&t.unopened.length===0&&t.missingDiagnostics.length===0&&!t.unlisted}a(Ee,"coverageComplete");function Ie(t){let e=t.filter(r=>r!==void 0);if(e.length===0)return;let n=new Map;for(let r of e.flatMap(s=>s.fatal))n.set(JSON.stringify([r.source,r.line,r.message]),r);return{fatal:[...n.values()],unopened:[...new Set(e.flatMap(r=>r.unopened))].sort(),missingDiagnostics:[...new Set(e.flatMap(r=>r.missingDiagnostics))].sort(),unlisted:e.some(r=>r.unlisted)}}a(Ie,"mergeCoverage");function De(t,e){if(t===void 0)return[];let n=[];if(t.fatal.length>0){let r=t.fatal.map(o=>`${e(o.source)}:${o.line} ${o.message}`).join("; "),s=e(F(t.fatal[0]).source);n.push(`Incomplete: clang stopped with a fatal error (${r}), so references after it can be missing. Fix it (diagnostics with path ${s}) and search again, or search the text.`)}return t.unopened.length>0&&n.push(`Incomplete: the name scan found these files, but the server did not check them: ${Ce(t.unopened,e)}. Search those files for references.`),t.missingDiagnostics.length>0&&n.push(`Incomplete: the server did not provide diagnostics for ${Ce(t.missingDiagnostics,e)}. The reference list may be incomplete.`),t.unlisted&&n.push("Incomplete: files that contain the name could not be listed, so references from files the server has not opened can be missing. Search the text."),n}a(De,"coverageNotes");function Ce(t,e){let r=t.slice(0,8).map(e).join(", ");return t.length>8?`${r} (and ${t.length-8} more)`:r}a(Ce,"displayFiles");function Hr(t,e){if(Ee(t)||t===void 0)return;let n=[];if(t.fatal.length>0){let r=t.fatal.map(s=>`${e(s.source)}:${s.line} ${s.message}`).join("; ");n.push(`clang stopped with a fatal error (${r}), so places after it can be missing from the rename. Fix it (diagnostics with path ${e(F(t.fatal[0]).source)}) and rename again.`)}return t.unopened.length>0&&n.push(`The server did not check these files: ${Ce(t.unopened,e)}.`),t.missingDiagnostics.length>0&&n.push(`The server did not provide diagnostics for ${Ce(t.missingDiagnostics,e)}.`),t.unlisted&&n.push("Files that contain the name could not be listed, so the rename can miss files the server has not opened."),`LSP rename refused; no edits applied. ${n.join(" ")} Or replace the text instead.`}a(Hr,"renameRefusal");function Fe(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}a(Fe,"isMissingSource");function Te(t,e){return t.length===0?[]:[`Skipped places in deleted files that the server still indexes: ${Ce(t,e)}.`]}a(Te,"missingSourcesNotes");var qt="(<[{",Gr=")>]}";function Ge(t,e=[]){let n=t.map(s=>({symbol:s,selectionRange:s.selectionRange??s.range})).filter(s=>s.selectionRange!==void 0),r=new Map;for(let{symbol:s,selectionRange:o}of n){let i=r.get(s.name)??new Set;i.add(Br(s,o)),r.set(s.name,i)}return n.map(({symbol:s,selectionRange:o})=>{let c=(r.get(s.name)?.size??0)>1?ti(s.name,s.detail)??s.name:s.name,l=[...e,c];return{name:s.name,kind:s.kind,...s.detail!==void 0&&s.detail!==""&&{detail:s.detail},range:s.range??o,selectionRange:o,selector:l,children:Ge(s.children??[],l)}}).sort(si)}a(Ge,"normalizeDocumentSymbols");function Gt(t,e,n){if(e.length===0)throw new TypeError("A symbol selector must contain at least one segment.");let r=t,s=[];for(let[o,i]of e.entries()){if(s=e.length===1?Zo(t,i):ei(r,i),s.length===0)throw ai(t,e,n);let c=zt(s);if(c.length>1)throw ii(c,e,o,n);r=s.flatMap(l=>l.children)}return s}a(Gt,"resolveSymbolDeclaration");function Yo(t,e){let[n]=t;if(n!==void 0&&t.length===1)return n;let r=t.filter(s=>ne(e,s.range).trimEnd().endsWith("}"));return r.length===1?r[0]:void 0}a(Yo,"bodyEntry");function Ve(t,e){return(e===void 0?void 0:Yo(t,e))??F(t[0])}a(Ve,"preferredDeclaration");function Vt(t,e){let n=a(r=>r.flatMap(s=>[...s.name===e?[s]:[],...n(s.children)]),"named");return zt(n(t))}a(Vt,"declarationsNamed");function Vr(t,e){let n=a(o=>o.flatMap(i=>[i,...n(i.children)]),"all"),r=n(t),s=r.find(o=>oi(o.selectionRange,e));if(s!==void 0)return zt(r.filter(o=>o.name===s.name)).find(o=>o.includes(s))}a(Vr,"declarationAt");function Zo(t,e){let n=[],r=[],s=[],o=a(i=>{for(let c of i){let l=zr(c,e);l==="named"?n.push(c):l==="exact"?r.push(c):l==="loose"&&s.push(c),o(c.children)}},"visit");return o(t),n.length>0?n:r.length>0?r:s}a(Zo,"matchAtAnyDepth");function ei(t,e){let n=t.map(r=>({symbol:r,grade:zr(r,e)}));for(let r of["named","exact","loose"]){let s=n.filter(o=>o.grade===r).map(o=>o.symbol);if(s.length>0)return s}return[]}a(ei,"matchSegment");function zr(t,e){if(t.name===e)return"named";if(!e.startsWith(t.name))return;let n=e.slice(t.name.length).trimStart();if(!n.startsWith("("))return;let r=Xr(n),s=t.detail===void 0?void 0:Jr(t.detail);if(!(r===void 0||s===void 0)&&r.parameters.length===s.parameters.length){if(r.qualifiers===s.qualifiers&&r.parameters.every((o,i)=>o===s.parameters[i]))return"exact";if(!(r.qualifiers!==""&&r.qualifiers!==s.qualifiers))return r.parameters.every((o,i)=>{let c=s.parameters[i];return o===c||ri(o)===c})?"loose":void 0}}a(zr,"segmentGrade");function zt(t){let e=new Map;for(let n of t){let r=JSON.stringify([n.selector.slice(0,-1),n.name,Br(n,n.selectionRange)]),s=e.get(r)??[];s.push(n),e.set(r,s)}return[...e.values()]}a(zt,"groupDeclarations");function Br(t,e){let n=t.detail?.trim().replace(/\s+/gu," ")??"";return JSON.stringify(n===""?[t.kind,e.start.line,e.start.character]:[t.kind,n])}a(Br,"declarationKey");function ti(t,e){let n=e===void 0?void 0:Jr(e);if(n===void 0)return;let r=n.qualifiers===""?"":` ${n.qualifiers}`;return`${t}(${n.parameters.join(", ")})${r}`}a(ti,"signatureSegment");function Jr(t){let e;for(let n=0;n<t.length;n+=1){if(t[n]!=="("){let s=Ft(t,n);s!==void 0&&(n=s);continue}e=n;let r=Ft(t,n);if(r===void 0)return;n=r}return e===void 0?void 0:Xr(t.slice(e))}a(Jr,"detailSignature");function Xr(t){let e=Ft(t,0);if(e===void 0)return;let n=t.slice(1,e),r=ni(n).map(Ht);return{parameters:r.length===1&&(r[0]===""||r[0]==="void")||r.length===0?[]:r,qualifiers:Ht(t.slice(e+1))}}a(Xr,"parseSignature");function Ft(t,e){if(!qt.includes(t[e]??""))return;let n=0;for(let r=e;r<t.length;r+=1){let s=t[r]??"";if(qt.includes(s))n+=1;else if(Gr.includes(s)&&(n-=1,n===0))return r}}a(Ft,"matchingClose");function ni(t){let e=[],n=0,r=0;for(let s=0;s<t.length;s+=1){let o=t[s]??"";qt.includes(o)?n+=1:Gr.includes(o)?n-=1:o===","&&n===0&&(e.push(t.slice(r,s)),r=s+1)}return e.push(t.slice(r)),e}a(ni,"splitTopLevel");function Ht(t){return t.trim().replace(/\s+/gu," ").replace(/\s*([&*,<>()[\]:])\s*/gu,"$1")}a(Ht,"normalizeType");function ri(t){let e=t.replace(/=.*$/u,"").trim(),n=/^(.*?[\s&*>\]])[\p{L}_][\p{L}\p{N}_]*$/u.exec(e);return n?.[1]===void 0?e:Ht(n[1])}a(ri,"withoutParameterName");function si(t,e){return t.range.start.line-e.range.start.line||t.range.start.character-e.range.start.character||t.name.localeCompare(e.name)}a(si,"compareSymbols");function oi(t,e){return t.start.line===e.start.line&&t.start.character===e.start.character&&t.end.line===e.end.line&&t.end.character===e.end.character}a(oi,"sameRange");function Kr(t,e){let[n]=t;if(n===void 0)return e;let r=t.map(s=>s.selectionRange.start.line+1).join(", ");return`${e}#${Z(n.selector)} (line ${r})`}a(Kr,"describeDeclaration");function ii(t,e,n,r){let s=t.slice(0,10).map(d=>Kr(d,r)),o=t.length>s.length?`, ${t.length-s.length} more`:"",i=new Set(t.map(d=>Z(d[0]?.selector??[]))),c=e.length>1?` at "${e[n]??""}"`:"",l=i.size===t.length?"Use one of these selectors.":"The language server reports no signatures that tell them apart.";return new Error(`Symbol selector "${Z(e)}"${c} matches ${t.length} declarations in ${r}: ${s.join(", ")}${o}. ${l}`)}a(ii,"ambiguousSelector");var He=class extends Error{static{a(this,"SymbolNotFoundError")}};function ai(t,e,n){let r=e.at(-1)??"",s=/^[^(]+/u.exec(r)?.[0].trim()??r,i=(s===r?[]:Vt(t,s)).slice(0,10).map(c=>Kr(c,n));return new He(`Symbol "${Z(e)}" was not found in ${n}.${i.length>0?` Declarations named "${s}": ${i.join(", ")}.`:""}`)}a(ai,"symbolNotFound");function oe(t,e,n){let r=e.startsWith("ssh://"),s=r?ze.posix:ze,o=a(d=>r?decodeURIComponent(new URL(X(d,e)).pathname):d,"native"),i=a(d=>{let u=r?o(d??e):ze.resolve(e,d??"."),p=s.relative(u,o(t));return!(p===".."||p.startsWith(`..${s.sep}`)||s.isAbsolute(p))},"inside");if(!(n.paths??[n.path]).some(i))return!1;let c=s.relative(o(e),o(t)).split(s.sep).join("/"),l=a(d=>Wn(d).some(u=>s.matchesGlob(u.includes("/")?c:s.basename(o(t)),u)),"matches");return(n.include===void 0||l(n.include))&&(n.exclude===void 0||!l(n.exclude))}a(oe,"withinScope");function se(t,e){let n=X(t,e);if(n.startsWith("ssh://"))return n;let r=ci.parse(n);if(r.scheme!=="file")throw new Error("Unsupported LSP source location.");return ze.resolve(r.fsPath)}a(se,"sourceOf");async function Bt(t,e,n,r,s={},o=fe.getInstance()){return te(()=>li(t,e,n,r,s,o),r)}a(Bt,"searchSymbols");async function li(t,e,n,r,s,o){r?.throwIfAborted();let i=s.resultScope;if(i?.targets.length===0)return{hits:[],contents:new Map,complete:i.complete};if(i===void 0&&s.path!==void 0&&!oe(e.startsWith("ssh://")?X(s.path,e):ze.resolve(e,s.path),e,s)&&await o.isSourceFile(s.path,e,r))return{hits:[],contents:new Map,complete:!0};let c=new Map,l=new Map,d=a(v=>{let R=l.get(v);return R===void 0&&(R=o.readSourceSnapshot(v,r).then(({content:_,version:$})=>{let D={document:Me(v,_),version:$};return c.set(v,D),D}),l.set(v,R)),R},"snapshotOf"),u=a(async v=>(await d(se(v,e))).document.content,"readText"),p=i?.targets.map(v=>v.source)??s.paths??[s.path??e],f=new Set((await Promise.all(p.map(v=>o.prepareWorkspaceSymbols(e,v,R=>oe(R,e,s),r,u)))).flat());if(f.size===0)throw new Error("LSP symbol search is unavailable: no provider supports workspace/symbol in this scope.");let y=new Map,S=new Map,h=a((v,R,_,$)=>{let D=S.get(v);return(D===void 0||D.served!==R)&&(D={served:R},S.set(v,D)),D[$]??=$==="toSnapshot"?ae.between(R,_):ae.between(_,R)},"lineDiff"),w=a(async(v,R)=>{r?.throwIfAborted();let _=se(v.uri,e),{document:$}=await d(_);i!==void 0&&!y.has(_)&&y.set(_,wn({targets:i.targets.filter(Je=>Je.source===_),complete:i.complete},new Map([[_,$.content]])));let D=R?.documentContent(v.uri),Q=D===void 0||D===$.content?v.range:h(_,D,$.content,"toSnapshot").mapRange(v.range);if(Q===void 0)throw O("LSP range does not match its source snapshot.");return qe(_,$,Q)},"toMatch"),b=a((v,R,_)=>{let $={line:_.lineNumber-1,character:_.startColumn},D=v.documentContent(R),Q=c.get(_.source)?.document.content;if(D===void 0||Q===void 0||D===Q)return $;let Je={start:$,end:{line:(_.endLineNumber??_.lineNumber)-1,character:_.endColumn}},Ae=st(h(_.source,D,Q,"toServed"),Je,D,_.matchedText);if(Ae===void 0)throw O(`The line of declaration "${_.matchedText}" changed before the server was asked for its references.`);return Ae.start},"servedPosition"),L=a(v=>oe(v.source,e,s)&&(i===void 0||Un(F(y.get(v.source)),v)),"included"),T=[],k=new Set,M=Le(v=>o.openFile(se(v,e),e,"symbols",r,u),r),g=a(v=>s.navigation==="references"?oe(v,e,{}):oe(v,e,s)&&(i===void 0||i.targets.some(R=>R.source===v)),"listable"),C=Pe({manager:o,cwd:e,errorsOf:M,accepts:g,...r&&{signal:r}}),E=new Set,m=a(async v=>{try{return await d(v),!0}catch(R){if(!Fe(R))throw R;return g(v)&&E.add(v),!1}},"exists"),P=[],I=new Set,A=new Map,x=a((v,R)=>{let _=A.get(R);return _===void 0&&(_=Ue(v,R,r).then(Ge),A.set(R,_)),_},"outlineOf");for(let v of f){r?.throwIfAborted();let R=await Tt(v,t,Number.MAX_SAFE_INTEGER,r);for(let _ of R){if(r?.throwIfAborted(),!oe(se(_.location.uri,e),e,{})||!await m(se(_.location.uri,e)))continue;let $=await w(_.location,v).catch(me=>{if(me?.code!=="SOURCE_CHANGED")throw me}),D=await o.openFile(se(_.location.uri,e),e,"symbols",r,u);if(D===null)throw new Error("LSP references are unavailable for a discovered declaration.");let Q=await x(D.client,D.uri),Ae=$?.matchedText===_.name?[Vr(Q,_.location.range)]:Vt(Q,_.name);if(Ae.length===0)throw O(`LSP declaration "${_.name}" is not among the current symbols of its file.`);for(let me of Ae){r?.throwIfAborted();let he=me===void 0?void 0:Ve(me,D.client.documentContent(D.uri)??await o.readSourceText(se(D.uri,e),r)),an=he===void 0?_.location:{uri:D.uri,range:he.selectionRange},cn=JSON.stringify([D.uri,(me?.[0]?.selectionRange??_.location.range).start]);if(I.has(cn))continue;I.add(cn);let z=await w(an,D.client),ye={id:JSON.stringify([v.serverId,z.source,an.range]),name:he?.name??_.name,kind:String(he?.kind??_.kind),...he!==void 0&&{selector:he.selector},source:z.source,range:{startLine:z.lineNumber,startColumn:z.startColumn,endLine:z.endLineNumber??z.lineNumber,endColumn:z.endColumn}},pt=await C(D.client,D.languageId,ye.name),ws=D.client.documentContent(D.uri),vs=b(D.client,D.uri,z),ln=await We(D.client,D.uri,vs,r);if(D.client.documentContent(D.uri)!==ws)throw O("The server's text changed while it answered a references request.");r?.throwIfAborted(),pt!==void 0&&it(ye.name,ln);let gt=[{...z,role:"definition",symbol:ye}],ft=[];for(let q of ln){if(!oe(se(q.uri,e),e,{})||!await m(se(q.uri,e)))continue;let Y=await w(q,D.client);Y.source===z.source&&Y.lineNumber===z.lineNumber&&Y.startColumn===z.startColumn&&Y.endLineNumber===z.endLineNumber&&Y.endColumn===z.endColumn||ft.push({location:q,reference:Y})}let bs=await _e(ft,({location:q,reference:Y})=>({uri:q.uri,start:q.range.start,text:Y.matchedText}),[ye.name,z.matchedText],M);for(let{reference:q}of bs)gt.push({...q,role:"reference",symbol:ye});if(gt.some(L)){pt!==void 0&&P.push(await xe(pt,[D.uri,...ft.map(({location:q})=>q.uri)],M,q=>se(q,e)));for(let q of gt){if(s.navigation!=="references"&&!L(q)||s.navigation==="references"&&!oe(q.source,e,{}))continue;let Y=JSON.stringify([ye.id,q.source,q.lineNumber,q.startColumn,q.endLineNumber,q.endColumn]);k.has(Y)||(k.add(Y),T.push(q))}}}}}r?.throwIfAborted();let j=new Map,W=new Map;for(let v of new Set(T.map(R=>R.source))){let R=F(c.get(v)),_=await o.readSourceSnapshot(v,r).catch($=>{if(!Fe($))throw $});if(_===void 0){g(v)&&E.add(v);continue}W.set(v,_.content),_.version!==R.version&&_.content!==R.document.content&&j.set(v,ae.between(R.document.content,_.content))}let U=T.filter(v=>W.has(v.source));for(let[v,R]of U.entries()){let _=j.get(R.source);if(_===void 0)continue;let $=_.mapRange({start:{line:R.lineNumber-1,character:R.startColumn},end:{line:(R.endLineNumber??R.lineNumber)-1,character:R.endColumn}});if($===void 0)throw O("LSP source changed during search.");U[v]={...R,lineNumber:$.start.line+1,endLineNumber:$.end.line+1}}U.sort((v,R)=>v.source.localeCompare(R.source)||v.lineNumber-R.lineNumber||v.startColumn-R.startColumn||v.endColumn-R.endColumn||v.symbol.id.localeCompare(R.symbol.id));let K=U.slice(0,n),B=Ie(P);return{hits:K,contents:new Map(K.map(v=>[v.source,F(W.get(v.source))])),complete:(i?.complete??!0)&&U.length<=n&&Ee(B),...B!==void 0&&!Ee(B)&&{coverage:B},...E.size>0&&{missing:[...E].sort()}}}a(li,"searchSymbolsOnce");import Jt from"node:path";import{fileURLToPath as Qr}from"node:url";var Xt=10,Kt=5,ke=10,di=new Set([6,9,12,25]);async function Yr(t,e,n,r,s){return te(()=>ui(t,e,n,r,s),s,rs)}a(Yr,"resolveLspDeclaration");async function ui(t,e,n,r,s){ue(s);let o=await dt(t,e,r,s),i=ss(o,n),c=await t.readSourceText(o.filePath,s);ue(s);let l=o.servedText??c,d=Ve(i,l),u=l===c?void 0:ae.between(l,c),p=u===void 0?d.range:u.mapRange(d.range),f=u===void 0?d.selectionRange:u.mapRange(d.selectionRange);if(p===void 0||f===void 0)throw O("The symbol source changed during resolution. Read it again before editing.");return{source:o.filePath,range:p,selectionRange:f,content:c}}a(ui,"resolveLspDeclarationOnce");async function Zr(t,e,n,r,s,o){ue(o);let i=await dt(t,e,r,o,s);if(i.servedText!==s)throw O("The language server changed documents during rename resolution.");return ue(o),{client:i.client,uri:i.uri,entries:Gt(i.symbols,n,i.displayPath),content:s}}a(Zr,"resolveLspRenameTarget");function es(t,e,n,r){let s=Le(o=>t.openFile(Be(o),e,"symbols",r),r);return{errorsOf:s,texts:new Yt(t,r),...n&&{reachOf:Pe({manager:t,cwd:e,errorsOf:s,accepts:a(o=>oe(o,e,{}),"accepts"),...r&&{signal:r}})}}}a(es,"relationContext");function Be(t){return t.startsWith("ssh://")?t:Qr(t)}a(Be,"fileOf");async function en(t,e,n,r,s){return te(async()=>{ue(s);let o=await dt(t,e,r,s),i=ss(o,n),c=Ve(i,o.servedText),l=es(t,r,!0,s),d=await os(o,c,l,s),u=new lt(r),p=await fi(o,c,d,u);return ts(p,[d],l.texts)},s,rs)}a(en,"readLspSymbolGraph");async function ts(t,e,n){let r=new Map,s=a(async i=>{let c=new Map;for(let{uri:l,range:d}of i){let u=Be(l);r.set(u,await n.snapshot(l)),c.set(JSON.stringify([u,d]),{source:u,range:d})}return[...c.values()].sort((l,d)=>l.source.localeCompare(d.source)||l.range.start.line-d.range.start.line||l.range.start.character-d.range.start.character)},"locate"),o=a(i=>i.map(c=>({uri:c.uri,range:c.declaration})),"declarations");return{text:t,references:await s(e.flatMap(i=>i.references)),incoming:await s(e.flatMap(i=>o(i.incoming))),outgoing:await s(e.flatMap(i=>o(i.outgoing))),complete:e.every(i=>Ee(i.coverage)&&i.unsupported.length===0&&!i.callItemMissing&&!i.referenceReplyMissing),contents:r,missing:ns(e)}}a(ts,"graphOf");function ns(t){return[...new Set(t.flatMap(e=>e.missing))].sort()}a(ns,"missingOf");var Yt=class{static{a(this,"ReportedTexts")}#e;#t;#r=new Map;#n=new Map;constructor(e,n){this.#e=e,this.#t=n}snapshot(e){let n=this.#r.get(e);return n===void 0&&(n=this.#e.readSourceText(Be(e),this.#t),this.#r.set(e,n)),n}between(e,n){let r=this.#n.get(e);r===void 0&&(r=new Map,this.#n.set(e,r));let s=r.get(n);return s===void 0&&(s=ae.between(e,n),r.set(n,s)),s}async report(e,n,r){if(n===void 0)return r;let s=await this.snapshot(e);if(n===s)return r;let o=this.between(n,s).mapRange(r);if(o===void 0)throw O("A line the language server reported changed in the file. Read it again.");return o}};async function tn(t,e,n,r){return te(async()=>{ue(r);let s=await dt(t,e,n,r),o=new lt(n),i=[`## file graph: ${s.displayPath}`,`Top-level declarations: ${s.symbols.length}`],c=es(t,n,!1,r),l=[];for(let d of s.symbols){ue(r);let u=await os(s,d,c,r);l.push(u),i.push("",...await wi(s,d,u,o))}return i.splice(2,0,...De(Ie(l.map(d=>d.coverage)),d=>o.display(d)),...Te(ns(l),d=>o.display(d))),ts(i.join(`
7
+ `),l,c.texts)},r)}a(tn,"readLspFileGraph");var at=class extends Error{static{a(this,"LspSelectorUnconfirmedError")}code="LSP_SELECTOR_UNCONFIRMED"};function rs(t){return t instanceof at}a(rs,"isUnconfirmedSelector");function ss(t,e){try{return Gt(t.symbols,e,t.displayPath)}catch(n){if(!(n instanceof He)||!de.has(t.languageId))throw n;let r=e.at(-1)??"",s=/^~?([\p{ID_Start}_$][\p{ID_Continue}$]*)(?=\s*\(|$)/u.exec(r)?.[1];throw s===void 0||t.servedText===void 0||!new RegExp(`(?<![\\p{ID_Continue}$])${s.replaceAll("$","\\$")}(?![\\p{ID_Continue}$])`,"u").test(t.servedText)?n:new at(`The language server could not confirm "${Z(e)}" in ${t.displayPath}. Check the current outline before trying again.`,{cause:n})}}a(ss,"resolveNavigationDeclaration");async function dt(t,e,n,r,s){let o=Oe(e,n),i=await t.openFile(o,n,"symbols",r,s===void 0?void 0:()=>Promise.resolve(s));if(!i)throw new Error(`No LSP server with symbol support is configured for ${Zt(o,n)}.`);let c=i.client.documentContent(i.uri),l=await Ue(i.client,i.uri,r),d=Ge(l);return{client:i.client,uri:i.uri,filePath:o,displayPath:Zt(o,n),symbols:d,servedText:c,languageId:i.languageId}}a(dt,"openCodeDocument");async function os(t,e,n,r){let{errorsOf:s,texts:o}=n,i=de.has(t.languageId)?await n.reachOf?.(t.client,t.languageId,e.name)??{client:t.client,opened:[],unopened:[],unlisted:!1}:void 0,c=t.client.documentContent(t.uri),l=gi(t,e,c,o),[d,u]=await Promise.all([We(t.client,t.uri,l,r),Wt(t.client,t.uri,l,r)]);if(ue(r),t.client.documentContent(t.uri)!==c)throw O("The server's text changed while it answered a call graph request.");n.reachOf!==void 0&&de.has(t.languageId)&&it(e.name,d);let p=await pi([...d.map(g=>g.uri),...u.incoming.map(g=>g.from.uri),...u.outgoing.map(g=>g.to.uri)].filter(g=>g!==t.uri),o),f=d.filter(g=>!p.has(g.uri)),y=u.incoming.filter(g=>!p.has(g.from.uri)),S=u.outgoing.filter(g=>!p.has(g.to.uri)),h=new Map([[t.uri,c]]);for(let g of[...f.map(C=>C.uri),...y.map(C=>C.from.uri),...S.map(C=>C.to.uri)])h.has(g)||h.set(g,t.client.documentContent(g));let w=a(async g=>h.get(g)??o.snapshot(g),"contentOf"),b=a(async(g,C)=>o.report(g,h.get(g),C),"report"),L=[e.name,ne(t.servedText??"",e.selectionRange)],T=a(async(g,C)=>g.length===0?[]:(await _e(await Promise.all(g.map(async E=>{let m=C(E);return{item:E,uri:m.uri,start:m.range.start,text:ne(await w(m.uri),m.range)}})),E=>E,L,s)).map(({item:E})=>E),"named"),k=await Promise.all(y.map(async g=>({...g,fromRanges:await T(g.fromRanges,C=>({uri:g.from.uri,range:C}))}))),M=a(async(g,C)=>({name:g.name,kind:g.kind,uri:g.uri,line:(await b(g.uri,C)).start.line,declaration:await b(g.uri,g.range)}),"site");return{definitionLine:(await o.report(t.uri,t.servedText,e.selectionRange)).start.line,references:await Promise.all((await T(f,g=>g)).map(async g=>({uri:g.uri,range:await b(g.uri,g.range)}))),coverage:i&&await xe(i,[t.uri,...f.map(g=>g.uri),...y.map(g=>g.from.uri)],s,Be),incoming:await Promise.all(k.filter((g,C)=>g.fromRanges.length>0||y[C]?.fromRanges.length===0).map(g=>M(g.from,g.fromRanges[0]??g.from.selectionRange))),outgoing:await Promise.all(S.map(g=>M(g.to,g.to.selectionRange))),unsupported:u.unsupported,callItemMissing:u.items.length===0&&u.unsupported.length===0&&di.has(e.kind),referenceReplyMissing:i!==void 0&&d.length===0,missing:[...p].map(Be).sort()}}a(os,"queryRelations");async function pi(t,e){let n=new Set;return await Promise.all([...new Set(t)].map(async r=>{try{await e.snapshot(r)}catch(s){if(!Fe(s))throw s;n.add(r)}})),n}a(pi,"missingFiles");function gi(t,e,n,r){let s=t.servedText,o=e.selectionRange;if(n===void 0||s===void 0||n===s)return o.start;let i=st(r.between(s,n),o,n,ne(s,o));if(i===void 0)throw O(`The line of declaration "${e.name}" changed before the server was asked for its calls.`);return i.start}a(gi,"servedPosition");async function fi(t,e,n,r){let s=Z(e.selector),o=await r.line(t.uri,n.definitionLine+1);return[`## graph: ${s}`,`Definition: ${t.displayPath} ${o} (${Se(e.kind)})`,`Source: calls ${as(t.displayPath,e.selector)}`,...De(n.coverage,c=>r.display(c)),...Te(n.missing,c=>r.display(c)),"",...await mi(n.references,r),"",...ct(t,n,"incoming")??await hi(n.incoming,r),"",...ct(t,n,"outgoing")??await yi(n.outgoing,r)].join(`
8
+ `)}a(fi,"formatSymbolGraph");async function mi(t,e){let n=cs(t),r=[`References: ${t.length} in ${n.length} file(s)`];for(let[s,o]of n.slice(0,Xt)){r.push(`- ${e.display(s)} (${o.length})`);for(let i of o.slice(0,Kt))r.push(` - ${await e.line(s,i.range.start.line+1)}`);o.length>Kt&&r.push(` - ... ${o.length-Kt} more`)}return n.length>Xt&&r.push(`- ... ${n.length-Xt} more file(s)`),r}a(mi,"formatReferences");function ct(t,e,n){let r=n==="incoming"?"Incoming calls":"Outgoing calls";if(e.unsupported.includes(n))return[`${r}: not supported by ${t.client.serverId}`];if(e.callItemMissing)return[`${r}: unavailable; the server could not resolve the callable declaration.`]}a(ct,"unavailableCalls");async function hi(t,e){let n=[`Incoming calls: ${t.length}`];t.length===0&&n.push("- none found; the server's index can miss callers added in the last seconds");for(let r of t.slice(0,ke))n.push(await is(r,e));return t.length>ke&&n.push(`- ... ${t.length-ke} more`),n}a(hi,"formatIncomingCalls");async function yi(t,e){let n=[`Outgoing calls: ${t.length}`];for(let r of t.slice(0,ke))n.push(await is(r,e));return t.length>ke&&n.push(`- ... ${t.length-ke} more`),n}a(yi,"formatOutgoingCalls");async function is(t,e){let n=await e.line(t.uri,t.line+1);return`- ${Se(t.kind)} ${t.name} \u2014 ${e.display(t.uri)} ${n}`}a(is,"formatCallSite");async function wi(t,e,n,r){let s=Se(e.kind),o=await r.line(t.uri,n.definitionLine+1),i=cs(n.references).map(([p,f])=>`${r.display(p)} (${f.length})`),c=a(p=>p.map(f=>`${f.name} (${r.display(f.uri)})`),"named"),l=c(n.incoming),d=c(n.outgoing),u=[`### ${s} ${e.name}`,`Selector: ${Z(e.selector)}`,`Definition: ${o}`,n.referenceReplyMissing?"Used by: unavailable; the server returned no locations for this declaration.":`Used by: ${Qt(i)}`,...ct(t,n,"incoming")??[`Incoming calls: ${Qt(l)}`],...ct(t,n,"outgoing")??[`Outgoing calls: ${Qt(d)}`]];if(e.children.length>0){u.push("Members:");for(let p of e.children){let f=as(t.displayPath,p.selector);u.push(`- ${Se(p.kind)} ${p.name} \u2014 calls ${f}`)}}return u}a(wi,"formatFileGraphSymbol");function as(t,e){return Jn("graph",t,e).slice(6)}a(as,"callsReference");function Qt(t,e=5){if(t.length===0)return"none";let n=t.slice(0,e).join(", ");return t.length>e?`${n}, ... ${t.length-e} more`:n}a(Qt,"summarize");function cs(t){let e=new Map;for(let n of t){let r=e.get(n.uri)??[];r.push(n),e.set(n.uri,r)}return[...e].map(([n,r])=>[n,r.sort((s,o)=>s.range.start.line-o.range.start.line||s.range.start.character-o.range.start.character)]).sort(([n],[r])=>n.localeCompare(r))}a(cs,"groupLocationsByUri");var lt=class{static{a(this,"LocationPresenter")}#e;constructor(e){this.#e=e}display(e){return Zt(vi(e),this.#e)}line(e,n){return Promise.resolve(String(n))}};function vi(t){if(!t.startsWith("file://"))return t;try{return Qr(t)}catch{return decodeURIComponent(t.slice(7))}}a(vi,"filePathFromUri");function Zt(t,e){if(t.startsWith("ssh://"))return t;let n=Jt.relative(e,t);return n.length===0||n.startsWith("..")||Jt.isAbsolute(n)?t:n.replaceAll(Jt.sep,"/")}a(Zt,"displayFilePath");function ue(t){if(t?.aborted===!0)throw bi(t)}a(ue,"throwIfAborted");function bi(t,e){if(t.reason instanceof Error)return t.reason;if(e instanceof Error)return e;let n=new Error("The operation was aborted");return n.name="AbortError",n}a(bi,"abortReason");function nn(t){let e=null;return{kind:"compiler",name:"lsp",priority:100,extensions:["*"],detect:a(()=>Promise.resolve(!0),"detect"),async compile({filePath:n},r){r.signal?.throwIfAborted();let s=await t(r.cwd,n,r.signal);r.signal?.throwIfAborted();let o=await re(()=>Si(n,r,s));if(!o)throw new Error("No diagnostic language server for this source");let{client:i,diagnostics:c,syntaxErrors:l,otherDiagnostics:d}=o;return e=i,{ok:!c.some(u=>u.severity==="error"),diagnostics:c,syntaxErrors:l,otherDiagnostics:d}},async restart(){e&&(await e.restart(),e=null)}}}a(nn,"createLspCompiler");async function Si(t,e,n){let r=await n.openFile(t,e.cwd,"diagnostics",e.signal);if(e.signal?.throwIfAborted(),!r)return null;let s=await pe(r.client,r.uri,r.languageId,{signal:e.signal});if(e.signal?.throwIfAborted(),!s.complete)throw new Error("Language server diagnostics are a snapshot, not a completed report");return{client:r.client,...s}}a(Si,"openAndDiagnose");import _i from"node:path";function ls(t){let e=t.options?.lsp;return typeof e=="object"&&e!==null?e:void 0}a(ls,"lspOptions");var Li={resolveLspDeclaration:Yr,readLspFileGraph:tn,readLspSymbolGraph:en,searchSymbols:Bt};function ds(t,e,n=Li,r){return{id:"lsp",supportsResultScope:!0,supportsPathList:!0,readResources:a(s=>ls(s)===void 0?[]:void 0,"readResources"),toScriptData(s){let o=s;return o.mode==="calls"?{kind:"custom",resolverId:"lsp",value:o.data}:o.data},tryResolve(s,o){let i=ls(s),c=i?.calls!==void 0||i?.declaration!==void 0||i?.references===!0;return a(d=>c?jt(o.signal,u=>re(()=>d({...o,signal:u}))):re(()=>d(o)),"withDocuments")(async d=>{let u=a(async C=>{try{return await e(C,d)}catch(E){throw E instanceof Error&&E.name==="SearchSnapshotChangedError"?O(E.message):E}},"register");if(i===void 0)return{kind:"not-handled"};if([i.query,i.declaration,i.calls].filter(C=>C!==void 0).length!==1)return{kind:"failed",error:new Error("Pass exactly one of query, declaration or calls.")};if(i.calls!==void 0){let C=yt(`graph:${i.calls}`,"graph");if(C===void 0)throw new Error("calls requires a file path.");let E=Oe(C.path,d.cwd),m=C.selector,P=a(async j=>{let W=await t(d.cwd,E,j),U=m===void 0?await n.readLspFileGraph(W,E,d.cwd,j):await n.readLspSymbolGraph(W,E,m,d.cwd,j);return{text:U.text,complete:U.complete,...Ri(U)}},"graph"),I=["references","incoming","outgoing"],{text:A,data:x}=await te(async()=>{let j=await P(d.signal),W=[];for(let v of I)W.push(await u({request:s,matches:j[v],complete:j.complete,contents:j.contents,refresh:a(R=>re(async()=>{let _=await P(R);return{matches:_[v],complete:_.complete,contents:_.contents}}),"refresh")}));let[U,K,B]=I.map((v,R)=>{let _=F(W[R]);return we(_.matches,j.complete,_.id,_)});return{text:j.text,data:{target:F(W[0]).target,complete:j.complete,matches:U,incoming:K,outgoing:B}}},d.signal);return{kind:"resolved",payload:{mode:"calls",text:A,data:x}}}if(i.declaration!==void 0){let C=i.declaration.includes("#")?yt(`graph:${i.declaration}`,"graph"):void 0;if(C?.selector===void 0)throw new Error("declaration requires file#selector, such as src/app.ts#App/start.");let E=Oe(C.path,d.cwd),m=C.selector,P=a(async j=>{let W=await t(d.cwd,E,j),U=await n.resolveLspDeclaration(W,E,m,d.cwd,j);return{match:structuredClone(us(U.source,U.content,U.range)),name:qe(U.source,Me(U.source,U.content),U.selectionRange),contents:new Map([[U.source,U.content]])}},"resolve"),{match:I,session:A,captured:x}=await te(async()=>{let{match:j,name:W,contents:U}=await P(d.signal),K=await u({request:s,matches:[W],complete:!0,contents:U,refresh:a(async()=>{throw new Error("Name captures cannot refresh; repeat lsp_search.")},"refresh")});r?.register([K.target,...K.matchTargets??[]],{source:E,selector:m});let B=we(K.matches,!0,void 0,K),v=await u({request:s,matches:[j],complete:!0,contents:U,refresh:a(R=>jt(R,_=>re(async()=>{let $=await P(_);return{matches:[$.match],complete:!0,contents:$.contents}})),"refresh")});return{match:j,session:v,captured:B}},d.signal);return{kind:"resolved",payload:{mode:"declaration",sessionId:A.id,selector:i.declaration,match:I,nameTarget:x.target,data:{...we(A.matches,!0,A.id,A),matches:we(A.matches,!0,A.id,A).matches.map(j=>({...j,captures:{name:x.matches}}))}}}}let f=(i.query??"").trim();if(f.length===0)return{kind:"failed",error:new Error("query must not be empty")};let y=i.references===!0,S=d.scope,h=a(async(C,E)=>{let m=new Map,P=a(async I=>{let A=await t(d.cwd,I,E),x=m.get(A)??{targets:[],paths:[]};return m.set(A,x),x},"group");if(C===void 0){s.paths===void 0&&await P(s.path);for(let I of s.paths??[])(await P(I)).paths.push(I);return m}for(let I of C.targets)(await P(I.source)).targets.push(I);return m},"groupScope"),w=await h(S,d.signal),b=s.limit??100,L=a(async(C,E=!1)=>{let m=E?await jn(d,C):S,P=E?await h(m,C):w,I=[],A=new Map,x=new Set,j=m?.complete??!0,W=[],U=new Set;for(let[B,{targets:v,paths:R}]of P){let _=await n.searchSymbols(f,B.workspaceRoot,b,C,{...s.path===void 0?{}:{path:s.path},...s.paths===void 0?{}:{paths:R},...s.include===void 0?{}:{include:s.include},...s.exclude===void 0?{}:{exclude:s.exclude},...y?{navigation:"references"}:{},...m===void 0?{}:{resultScope:{targets:v,complete:m.complete}}},B);I.push(..._.hits);for(let[$,D]of _.contents){let Q=A.get($);Q===void 0?A.set($,D):Q!==D&&x.add($)}j=j&&_.complete,W.push(_.coverage);for(let $ of _.missing??[])U.add($)}for(let B of x)A.delete(B);let K=Ie(W);return{...structuredClone({hits:I.slice(0,b),complete:j&&I.length<=b,...K&&{coverage:K},...U.size>0&&{missing:[...U].sort()}}),contents:A}},"collect"),T=0,{found:k,session:M}=await te(async()=>{let{contents:C,...E}=await L(d.signal,T++>0),m=await u({request:s,matches:E.hits,complete:E.complete,contents:C,refresh:a(P=>re(async()=>{let I=await L(P,!0);return{matches:I.hits,complete:I.complete,contents:I.contents}}),"refresh")});return{found:E,session:m}},d.signal),g=we(M.matches,k.complete,M.id,M);return{kind:"resolved",payload:{mode:"symbols",sessionId:M.id,hits:k.hits,complete:k.complete,...k.coverage&&{coverage:k.coverage},...k.missing&&{missing:k.missing},references:y,data:{...g,matches:g.matches.map((C,E)=>({...C,role:k.hits[E]?.role,symbol:k.hits[E]?.symbol}))}}}})},renderResult(s,o,i){let c=s.details;return c.mode==="calls"?new Xe({summary:c.text.split(`
9
+ `,1)[0]??"Calls",rows:c.text.split(`
10
+ `).slice(1).map(l=>({kind:"note",text:l}))},i,o.expanded):c.mode==="declaration"?ht([c.match],!0,i,o.expanded,c.cwd,[],[c.selector]):ht(c.hits,c.complete,i,o.expanded,c.cwd,[...c.references?["LSP reference navigation \xB7 may leave input scope"]:[],...De(c.coverage,l=>rn(l,c.cwd)),...Te(c.missing??[],l=>rn(l,c.cwd))],c.hits.map(l=>`${l.role} ${l.symbol.name}`))},format(s,o){let i=s,c=a(u=>rn(u,o.cwd),"display");if(i.mode==="calls")return{content:[{type:"text",text:i.text}],details:{mode:"calls",text:i.text}};if(i.mode==="declaration"){let{match:u}=i,p=u.endLineNumber??u.lineNumber,f=p>u.lineNumber&&u.endColumn===0?p-1:p;return{content:[{type:"text",text:[`SEARCH#${i.sessionId}:1:match ${c(u.source)}:${u.lineNumber}-${f} declaration ${i.selector}`,u.matchedText.replace(/\r?\n$/u,""),...i.nameTarget?[`capture name: ${i.nameTarget} \xB7 replace this capture to rename through LSP; replacing the declaration edits only its text.`]:[]].join(`
11
+ `)}],details:{...i,cwd:o.cwd}}}let l=i.references?"LSP reference navigation (may leave input scope)":"LSP symbols inside scope",d=i.hits.length===0?["No symbols found."]:i.hits.slice(0,100).map((u,p)=>`SEARCH#${i.sessionId}:${p+1}:match ${c(u.source)}:${u.lineNumber}:${u.startColumn+1} ${u.role} ${u.symbol.name} \xB7 ${u.role==="definition"&&u.symbol.selector!==void 0?`selector ${c(u.symbol.source)}#${Z(u.symbol.selector)}`:`declared at ${c(u.symbol.source)}:${u.symbol.range.startLine}:${u.symbol.range.startColumn+1}`}`);return i.complete&&i.hits.length&&d.unshift(`SEARCH#${i.sessionId}:all:match selects all exact symbol matches.`),i.hits.length>100&&d.push("Preview shortened; full source targets retained."),d.push(...De(i.coverage,c)),d.push(...Te(i.missing??[],c)),{content:[{type:"text",text:[l,...d].join(`
12
+ `)}],details:{...i,cwd:o.cwd}}}}}a(ds,"createLspSearchResolver");function rn(t,e){return t.startsWith("ssh://")?t:_i.relative(e,t)}a(rn,"displaySource");function Ri(t){let e=a(o=>F(t.contents.get(o)),"textOf"),n=new Map,r=a(o=>{let i=n.get(o)??Me(o,e(o));return n.set(o,i),i},"documentOf"),s=a(o=>o.map(({source:i,range:c})=>structuredClone(us(i,e(i),c))),"declarations");return{references:t.references.map(({source:o,range:i})=>structuredClone(qe(o,r(o),i))),incoming:s(t.incoming),outgoing:s(t.outgoing),contents:t.contents}}a(Ri,"graphMatches");function us(t,e,n){Re(e);let r=e.split(`
13
+ `),s=[0];for(let p of r)s.push((s.at(-1)??0)+p.length+1);let o=n.start.line,i=n.end.line+1<r.length,c=i?n.end.line+1:n.end.line,l=i?0:(r[n.end.line]??"").length,d=s[o]??e.length,u=Math.min(e.length,(s[c]??e.length)+l);return{source:t,lineNumber:o+1,startColumn:0,...c===o?{}:{endLineNumber:c+1},endColumn:l,matchedText:e.slice(d,u),lineText:r[o]??""}}a(us,"declarationMatch");import{Type as V}from"typebox";var ps=V.Object({query:V.Optional(V.String({minLength:1,description:"Symbol name to find in the workspace."})),declaration:V.Optional(V.String({minLength:1,description:"file#selector, such as src/app.ts#App/start or main.cpp#clamp(int, float) for one overload: returns the editable declaration with captures.name. Replace its name capture with a new identifier to rename through LSP; replacing the declaration edits only its text."})),calls:V.Optional(V.String({minLength:1,description:"file or file#selector: references and incoming/outgoing calls."})),path:V.Optional(V.Union(hn.anyOf,{description:"For query: file, directory, unchanged Read/Search/edit result or its UUID, or an array of paths or of results."})),references:V.Optional(V.Boolean({description:"For query: also follow symbols found inside path to their references outside it."})),include:V.Optional(V.String({description:"Include glob for query"})),exclude:V.Optional(V.String({description:"Exclude glob for query"})),limit:V.Optional(V.Integer({minimum:1,maximum:1e3,description:"Maximum matches (default 100; in Codemode, all matches)."}))},{additionalProperties:!1});async function gs(t,e){let n;e.then(s=>n=s);let r=gn(t,"lsp_search");t.registerTool(In({name:"lsp_search",label:"lsp_search",exposure:"direct",namespace:{name:"ide_lsp_search",description:"Navigate code through language servers: symbol definitions, references and call graphs."},annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},description:"Use lsp_search to find symbol declarations and references, read one declaration, or list a symbol's calls and references through the project's language servers. Matches and declarations are editable selections.",promptSnippet:"Find symbols, references, declarations and call graphs through language servers",parameters:ps,outputSchema:An,prepareArguments:a(s=>Mn(s,ps),"prepareArguments"),renderCall(s,o,i){return xn(i.lastComponent,{tool:"lsp_search",primary:{text:s.query??s.declaration??s.calls??"",color:"accent",truncate:"end"},qualifiers:[...s.declaration===void 0?[]:[{text:"declaration"}],...s.calls===void 0?[]:[{text:"calls"}],...s.path===void 0?[]:[{text:`in ${Nn(s.path)}`,color:"accent",truncate:"start"}],...s.references===!0?[{text:"references",color:"warning"}]:[]],expanded:i.expanded},o)},renderResult(s,o,i,c){let l=s.details;if(n?.resolver.renderResult!==void 0&&l?.payload!==void 0&&!c.isError&&!o.isPartial)return n.resolver.renderResult({...s,details:l.payload},o,i,c);let d=s.content.flatMap(u=>u.type==="text"?[u.text]:[]).join(`
14
+ `);return new Xe({summary:c.isError?"lsp_search failed":"lsp_search",rows:d.split(`
15
+ `).map(u=>({kind:"note",text:u}))},i,o.expanded)},async execute(s,o,i,c,l){let d=On(o);if(d!==void 0)return sn(d);let u=o.query??o.declaration??o.calls,p=[o.query,o.declaration,o.calls].filter(b=>b!==void 0);if(u===void 0||p.length!==1)return sn("Pass exactly one of query, declaration or calls.");let f={...o.query===void 0?{}:{query:o.query},...o.declaration===void 0?{}:{declaration:o.declaration},...o.calls===void 0?{}:{calls:o.calls},...o.references===!0?{references:!0}:{}};if(n===void 0)return sn("lsp_search needs the Search module (search.core), which is not loaded.");let{api:y,resolver:S}=n,{limit:h,audience:w}=$n(o.limit,r(s),"matches");return await y.searchWith(S,{query:u,...o.path===void 0?{}:{path:o.path},...o.include===void 0?{}:{include:o.include},...o.exclude===void 0?{}:{exclude:o.exclude},...h===void 0?{}:{limit:h},options:{lsp:f}},{cwd:l.cwd,...i!==void 0&&{signal:i},...c!==void 0&&{onUpdate:c}},w)}},new En))}a(gs,"registerLspSearchTool");function sn(t){return pn({content:[{type:"text",text:t}],details:{failure:{code:"INVALID_REQUEST",message:t}}},kn,{status:"error",errors:[un(new Error(t),"SEARCH_FAILED")]})}a(sn,"failure");var ut=class{static{a(this,"NameCaptures")}#e=new Map;register(e,n){for(let r of e)r!==void 0&&(this.#e.set(r,n),r.startsWith("RESULT#")&&this.#e.set(r.slice(7),n))}get(e){let n=yn(e)??e;return typeof n=="string"?this.#e.get(n):void 0}find(e){if(typeof e!="object"||e===null)return;let n=a(s=>{if(Array.isArray(s)){for(let i of s){let c=n(i);if(c!==void 0)return c}return}let o=this.get(s);return o===void 0?void 0:{capture:o,reference:s}},"find"),r=e;for(let s of["path","at","from","after","through","before"]){let o=n(r[s]);if(o!==void 0)return o}}matches(e){return this.find(e)!==void 0}};async function fs(t,e,n,r){let s=await t.resolveCurrent(e,n,r),o=s.targets[0],i=o?.ranges[0];if(!s.complete||s.targets.length!==1||o?.ranges.length!==1||i===void 0||i.adjusted)throw new Error("The name capture changed. Repeat lsp_search before renaming.");return await t.verify(s,r),{target:o,range:i}}a(fs,"currentNameCapture");import on from"node:path";import{fileURLToPath as Ci}from"node:url";function Pi(t,e){let n=t.split(`
16
+ `)[e.line]??"";for(let r of n.matchAll(/[\p{L}\p{N}_$]+/gu))if(r.index<=e.character&&e.character<r.index+r[0].length)return r[0];return""}a(Pi,"identifierAt");function xi(t,e){if(t===null)throw new Error("The language server did not provide rename edits. No text fallback was applied.");let n=new Map(Object.entries(t.changes??{}));for(let r of t.documentChanges??[]){if(!("textDocument"in r)||!("edits"in r))throw new Error("Rename returned an unsupported file operation. No edits applied.");if(r.textDocument.version!=null&&r.textDocument.version!==e.documentVersion(r.textDocument.uri))throw new Error("Rename refers to an unavailable document revision. No edits applied.");if(n.has(r.textDocument.uri))throw new Error("Rename returned duplicate document edits.");n.set(r.textDocument.uri,r.edits)}return n}a(xi,"renameEntries");function hs(t){Re(t);let e=0,n=t.split(`
17
+ `).map(r=>{let s={start:e,length:r.replace(/\r$/u,"").length};return e+=r.length+1,s});return({line:r,character:s})=>{let o=n[r];if(!Number.isInteger(r)||r<0||o===void 0||!Number.isInteger(s)||s<0||s>o.length)throw new Error("The language server returned an invalid text position.");return o.start+s}}a(hs,"offsets");function Ei(t,e,n,r,s){let o=a(u=>/^[ \t]*\r?$/u.test(u)||/^[ \t]*\/\/[^\\@#\r]*\r?$/u.test(u)&&!u.includes("*/")&&!u.includes("??/")&&!u.includes(n)&&!u.includes(r),"isTrivia"),i=a(u=>u.split(`
18
+ `).flatMap((p,f)=>{if(o(p))return[];let y=p.replace(/^[ \t]*/u,"");return[{index:f,text:y,indent:p.slice(0,p.length-y.length)}]}),"significantLines"),c=i(t),l=i(e);if(c.length!==l.length)return;let d=new Map;for(let[u,p]of c.entries()){let f=l[u];if(f===void 0||f.text!==p.text||!s&&f.indent!==p.indent)return;d.set(p.index,{line:f.index,shift:f.indent.length-p.indent.length})}return d}a(Ei,"matchLayout");function Ii(t,e,n,r,s,o,i){if(!de.has(i))return;let c=/R"|__LINE__|__builtin_LINE|__builtin_COLUMN|source_location|##|%:%:|\?\?=\?\?=|(?:\\|\?\?\/)[ \t]*\r?\n/u;if(c.test(t)||c.test(e))return;let l=/^[\p{L}_$][\p{L}\p{N}_$]*$/u;if(!l.test(s)||!l.test(o))return;let d=/#|%:|\?\?=|\bimport\b/u.test(t),u=Ei(t,e,s,o,!d);if(u===void 0)return;let p=fn(t,e),f=hs(e),y=[];for(let[S,{range:{start:h,end:w},newText:b}]of n.entries()){let L=r[S],T=u.get(h.line);if(L===void 0||b!==o||t.slice(L.from,L.to)!==s||T===void 0||h.line!==w.line)return;let k=p.move({start:{lineNumber:h.line+1,column:h.character},end:{lineNumber:w.line+1,column:w.character}}),M=T.line;if(k===void 0||k.start.lineNumber!==M+1||k.end.lineNumber!==M+1||k.start.column!==h.character+T.shift||k.end.column!==w.character+T.shift)return;let g=f({line:M,character:k.start.column}),C=f({line:M,character:k.end.column});if(e.slice(g,C)!==s)return;y.push({from:g,to:C,insert:b})}return y}a(Ii,"rebaseRename");var Di=12e3,Ti=4e3,ki=[0,50,100,200,400,500,500,500,500],ms=new WeakSet;function Ai(t){return t instanceof dn&&t.code==="RESOURCE_CHANGED"||t?.code===tt}a(Ai,"sourceMoved");function ys(t,e,n,r){let s=performance.now(),o=t.input,i=n.find(o);if(i===void 0)return;let c=n.get(o.path),l,d;function u(f){return ms.add(f),d??=AbortSignal.timeout(Di)}a(u,"startRefresh");function p(){return`The rename could not catch up with newer text after ${((performance.now()-s)/1e3).toFixed(1)} s. Nothing was written. Repeat the same replace call with the same name capture and new name.`}return a(p,"exhaustedMessage"),{...t,...c!==void 0&&{sourceChangeRetry:{delaysMs:ki,start:a(()=>u(c),"start"),exhaustedMessage:p}},input:{...o,path:i.capture.source},planEdit:a(async()=>{if(c===void 0||typeof o.text!="string"||o.text.trim()===""||Pn(o,Cn))throw new Error("Rename needs one declaration name capture and a non-empty new name. Omit text selectors. Use replace with "+JSON.stringify({path:i.reference,text:"newName"}));t.signal?.throwIfAborted();let f=ms.has(c)?u(c):void 0;if(f?.aborted)throw O(p());if(l!==void 0)return l;let y=f===void 0?void 0:AbortSignal.timeout(Ti),S=y===void 0||f===void 0?t.signal:AbortSignal.any([f,y,...t.signal?[t.signal]:[]]);try{let h={...c,newName:o.text},w=await re(()=>Mi(t.cwd,S,h,e,()=>fs(r,o.path,t.cwd,S)));return S?.throwIfAborted(),l={files:w.files.map(b=>({...b,rebase(L){let T=b.rebase?.(L);return T===void 0&&(l=void 0,u(c)),T}}))},l}catch(h){throw t.signal?.throwIfAborted(),f?.aborted?O(p(),{cause:h}):y?.aborted&&h===y.reason?O("The language server did not finish the rename refresh in time."):(Ai(h)&&u(c),h)}},"planEdit"),metadata:{...t.metadata,semanticEdit:{mode:"lsp-rename",referencesUpdated:!0},diffStatuses:[{text:"Renamed through LSP",tone:"success"}]}}}a(ys,"prepareSymbolRename");async function Mi(t,e,{source:n,selector:r,newName:s},o,i){let c=await i(),l=c.target.expectedContent;if(c.target.source!==n)throw new Error("The name capture no longer identifies this declaration. Repeat lsp_search.");let d=await o(t,n,e),u=await Zr(d,n,r,t,l,e),p=u.entries.find(({selectionRange:{start:m,end:P}})=>c.range.start.lineNumber===m.line+1&&c.range.start.column===m.character&&c.range.end.lineNumber===P.line+1&&c.range.end.column===P.character);if(p===void 0)throw new Error("The name capture no longer identifies this declaration. Repeat lsp_search.");let f=p.selectionRange.start,y=a(m=>m.startsWith("ssh://")?m:Ci(m),"fileOf"),{client:S,uri:h}=u,w=new Map([[h,{file:n,content:l,version:S.documentVersion(h)}]]);function b(){e?.throwIfAborted();for(let[m,P]of w)if(S.documentVersion(m)!==P.version||S.documentContent(m)!==P.content)throw O("A rename participant changed on the language server. No edits applied.")}a(b,"checkSnapshots");let L=Le(m=>{let P=w.get(m);return d.openFile(y(m),t,"symbols",e,P===void 0?void 0:()=>Promise.resolve(P.content))},e);await Ut(S,h,e);let T=[p.name,Pi(u.content,f)],k=await Pe({manager:d,cwd:t,errorsOf:L,...e&&{signal:e}})(u.client,d.languageId(on.extname(n)),T[1]||T[0]||"");async function M(){b();let m=await kt(S,h,f,s,e);return b(),xi(m,S)}a(M,"renameOnSnapshots");let g=await M();for(let m of g.keys()){if(m===h)continue;if(e?.throwIfAborted(),X(m,S.rootUri)!==m)throw new Error("Rename returned a non-canonical participant. No edits applied.");let I=y(m),{content:A}=await d.readSourceSnapshot(I,e),x=await d.openFile(I,t,"symbols",e,()=>Promise.resolve(A));if(x?.client!==S||x.uri!==m)throw new Error("A rename participant has a different language server owner. No edits applied.");if(S.documentContent(m)!==A)throw O("A rename participant changed during synchronization. No edits applied.");w.set(m,{file:I,content:A,version:S.documentVersion(m)})}let C=w.size===1?g:await M();if(k!==void 0){let m=Hr(await xe(k,[u.uri,...C.keys()],L,y),P=>P.startsWith("ssh://")?P:on.relative(t,P));if(m!==void 0)throw new Error(m)}let E=[];for(let[m,P]of C){let I=w.get(m);if(!I)throw new Error("Rename discovered a new participant after preflight. No edits applied.");let A=await _e(P,W=>({uri:m,start:W.range.start,text:ne(I.content,W.range)}),T,L);if(A.length===0)continue;let x=hs(I.content),j=A.map(W=>({from:x(W.range.start),to:x(W.range.end),insert:W.newText}));E.push({source:I.file,expectedContent:I.content,changes:j,rebase:a(W=>Ii(I.content,W,A,j,T[1]??"",s,d.languageId(on.extname(I.file))),"rebase")})}return b(),{files:E}}a(Mi,"planRename");async function Ni(t){await $i(t)}a(Ni,"registerLsp");async function $i(t,e){let n=new ut,r=vn(t),s,o=new Promise(h=>s=h),i=new Map,c=new nt,l=!1,d=a(async(h,w=!1,b)=>{if(b?.throwIfAborted(),l)throw new Error("LSP session has ended");let L=JSON.stringify([h,w]),T=i.get(L);if(T?.controller.signal.aborted)return await ee(T.promise.catch(()=>{}),b),i.get(L)===T&&i.delete(L),d(h,w,b);if(!T){T=new be(async M=>{let g=e?await e.loadRegistry(h,w,M):await Ui(h,w,M),C=await ji(t,h);if(M.throwIfAborted(),l)throw new Error("LSP session has ended");return fe.init(g,e?.workspace(h),{idleTimeoutMs:C,sharedServers:c})});let k=T;i.set(L,k),k.promise.catch(()=>{i.get(L)===k&&i.delete(L)})}return T.wait(b)},"managerFor"),u=a(async(h,w,b)=>{if(b?.throwIfAborted(),e)return e.resolveProject(h,w,b);let L=await tr(w,h,"lsp-servers",ve,b);return b?.throwIfAborted(),L===void 0?void 0:{cwd:L,external:L!==Oi.resolve(w)}},"resolveLspProject"),p=a(async(h,w,b)=>{if(b?.throwIfAborted(),!w)return d(h,!1,b);let L=await u(w,h,b);if(b?.throwIfAborted(),!L)throw new Error("No language server project for this source");return d(L.cwd,L.external,b)},"managerForFile"),f={...nn(p),name:"pi-agent-ide-lsp",priority:200},y={protocol:Kn,apiVersion:5,id:"lsp",setup(h){h.addTool(f),h.addDiagnosticSource(mr(d,u))}};t.on("session_shutdown",async()=>{l=!0,await Promise.allSettled([...i.values()].map(async h=>{h.settled||h.controller.abort(new Error("LSP session has ended")),await(await h.promise).shutdownAll()})),i.clear()});let S={protocol:bn,apiVersion:Sn,id:"lsp",setup(h){h.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler:Xn()})}};await Promise.all([Yn(t,y),Vn(t,{protocol:Ln,apiVersion:Rn,id:"lsp-declarations",setup(h){h.onDidEdit(async w=>{await Promise.all([...i.values()].filter(b=>b.settled).map(b=>b.promise.then(L=>L.syncEditedSource(w.source,w.after.content),()=>{})))}),h.tool("replace").addHandler({stage:"text-pre-edit",when:a(w=>n.matches(w),"when"),handler:a(w=>ys(w,p,n,r)??w,"handler")})}}),_n(t,S),Gn(t,Mr),qn(t,{protocol:Dn,apiVersion:Tn,id:"lsp-search",setup(h){s({api:h,resolver:ds(p,h.registerSelection,void 0,n)})}}),gs(t,o)])}a($i,"registerLspWithOwner");async function ji(t,e){try{let{value:n}=await Bn(t.events,Ke,e);if(typeof n!="string")throw new Error(`Invalid ${Ke} setting`);return vt(n)}catch(n){if(n instanceof Error&&"code"in n&&n.code===zn)return vt("");throw n}}a(ji,"readIdleTimeoutMs");async function Ui(t,e,n){let r=e?t:process.env.PI_AGENT_IDE_CONFIG_DIR??t;return ie.fromPackageDir(r,{signal:n,includeGlobal:!e,requireBuiltInEvidence:e,recipes:ve})}a(Ui,"loadRegistry");export{ve as a,ie as b,jr as c,Ur as d,Ni as e,$i as f};
@@ -0,0 +1,9 @@
1
+ import{a as Z,c as Oe}from"./chunk-QSU5AEKW.js";import{a as Re}from"./chunk-54EFJYUB.js";import{a as ke}from"./chunk-4DLSZYUO.js";import{a as Ae,b as xe}from"./chunk-VPBGKSFI.js";import"./chunk-T5PXAYWC.js";import{b as Ee}from"./chunk-V2LLMBTA.js";import{b as X,c as Q,f as V,h as Pe,j as D,k as Ie,l as Ce,m as Te}from"./chunk-S4GTWS2J.js";import{c as Se}from"./chunk-XHFAV2NI.js";import{a as be,b as ve,c as De}from"./chunk-JYITLCXC.js";import"./chunk-PBMHSK6J.js";import{d as we,e as L}from"./chunk-OA26FH5G.js";import{a as ye}from"./chunk-BXGMMZT3.js";import{a as K,b as le,c as ue,d as fe,e as ge,g as he}from"./chunk-MLFJU2US.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import{d as me}from"./chunk-2EY3LEZ7.js";import{a as N}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{mkdir as Xe,readFile as Qe,writeFile as Ze}from"node:fs/promises";async function $e(n,r,t,o){if(o?.throwIfAborted(),n.includes("://")&&!t||t&&t.source!==n)throw Object.assign(new Error("Doctor configuration needs its project owner"),{code:"UNSUPPORTED_SOURCE"});t||await Xe(we(n),{recursive:!0});let e=[],i=r.filter(f=>f.recipe.formatter!==void 0),a=r.filter(f=>f.recipe.linter!==void 0),l=r.filter(f=>f.recipe.lsp!==void 0);if(i.length>0){let f=t?(await t.configPaths("formatters",o)).project:L(n,"formatters"),{config:h,previous:d}=await q(f,{version:1,formatters:{}},t,o),m=ee(h,"formatters");for(let w of i)m[w.recipe.id]??=w.recipe.formatter;await te(f,h,d,t,o)&&e.push(f)}if(a.length>0){let f=t?(await t.configPaths("linters",o)).project:L(n,"linters"),{config:h,previous:d}=await q(f,{version:1,linters:{}},t,o),m=ee(h,"linters");for(let w of a)m[w.recipe.id]??=w.recipe.linter;await te(f,h,d,t,o)&&e.push(f)}if(l.length>0){let f=t?(await t.configPaths("lsp-servers",o)).project:L(n,"lsp-servers"),{config:h,previous:d}=await q(f,{version:1,servers:{}},t,o),m=ee(h,"servers");for(let w of l){let g=N(w.recipe.lsp);m[w.recipe.id]??={command:g.command,transport:"stdio",rootMarkers:g.rootMarkers,...g.initializationOptions!==void 0&&{initializationOptions:g.initializationOptions},...g.settings!==void 0&&{settings:g.settings},...g.requireRootMarker!==void 0&&{requireRootMarker:g.requireRootMarker},languages:Object.fromEntries(Object.entries(g.languageIds).map(([y,C])=>[y,{extensions:C,...g.fileNames?.[y]&&{fileNames:g.fileNames[y]}}])),capabilities:["diagnostics"]}}await te(f,h,d,t,o)&&e.push(f)}return e}s($e,"writeSuggestedConfigs");async function q(n,r,t,o){let e;try{e=t?await t.readText(n,o):await Qe(n,{encoding:"utf8",signal:o})}catch(a){if(o?.throwIfAborted(),!(typeof a=="object"&&a!==null&&"code"in a&&a.code==="ENOENT"))throw a}if(o?.throwIfAborted(),e===void 0)return{config:r,previous:e};let i=JSON.parse(e);if(typeof i!="object"||i===null||Array.isArray(i))throw new Error(`${n} must contain an object`);return{config:i,previous:e}}s(q,"readObject");function ee(n,r){let t=n[r];if(typeof t!="object"||t===null||Array.isArray(t))throw new Error(`${r} must be an object`);return t}s(ee,"objectMember");async function te(n,r,t,o,e){e?.throwIfAborted();let i=`${JSON.stringify(r,null,2)}
2
+ `;return t===i?!1:(o?await o.writeText(n,i,t,e):await Ze(n,i,{encoding:"utf8",signal:e}),!0)}s(te,"writeJson");function je(n,r){let t=new Set,o;for(let e of n.trim().split(/\s+/u).filter(Boolean))if(["--apply","--no-apply","--agent"].includes(e))t.add(e);else if(e.startsWith("ssh://")&&o===void 0)o=e;else throw new TypeError("Use /agent-ide-doctor [ssh://target/path] [--apply | --no-apply] [--agent]");if(t.has("--apply")&&t.has("--no-apply"))throw new TypeError("Choose --apply or --no-apply, not both");return{cwd:o??r,flags:t}}s(je,"parseDoctorArguments");var Y=class{static{s(this,"DoctorCore")}plugins=new Map;languages=[];recipes=[];setupChecks=[];checks=[];queue=Promise.resolve();registerPlugin(r){let t=this.plugins.get(r.id);if(t!==void 0)return t;let o=this.queue.then(async()=>{let e=!0,i=[],a=[],l=[],f=[],h={addLanguage:s(d=>{z(d,i,r.id,"language",()=>e)},"addLanguage"),addToolRecipe:s(d=>{z(d,a,r.id,"tool recipe",()=>e)},"addToolRecipe"),addSetupCheck:s(d=>{z(d,l,r.id,"setup check",()=>e)},"addSetupCheck"),addCheck:s(d=>{z(d,f,r.id,"check",()=>e)},"addCheck")};try{await r.setup(h)}finally{e=!1}Ne(this.languages,i,"language"),Ne(this.recipes,a,"tool recipe"),this.languages.push(...i),this.recipes.push(...a),this.setupChecks.push(...l),this.checks.push(...f)});return this.plugins.set(r.id,o),this.queue=o.catch(()=>{}),o.catch(()=>{this.plugins.delete(r.id)}),o}async waitForPlugins(){await Promise.all(this.plugins.values())}snapshot(){return{languages:[...this.languages],recipes:[...this.recipes],setupChecks:[...this.setupChecks],checks:[...this.checks]}}};async function Le(n,r){let t=[],o=[];for(let e of n.setupChecks)try{let i=await e.value.inspect(r);t.push(...(i.selections??[]).map(a=>({...a,pluginId:e.pluginId}))),o.push(...(i.actions??[]).map(a=>({...a,pluginId:e.pluginId})))}catch{}return{selections:t,actions:o}}s(Le,"runContributedSetupChecks");async function _e(n,r){let t=[];for(let o of n.checks)try{t.push({pluginId:o.pluginId,title:o.value.title,findings:await o.value.run(r)})}catch(e){t.push({pluginId:o.pluginId,title:o.value.title,findings:[{status:"fail",message:e instanceof Error?e.message:String(e)}]})}return t}s(_e,"runContributedChecks");function Ne(n,r,t){for(let o of r){let e=n.find(i=>i.value.id===o.value.id)?.pluginId;if(e!==void 0)throw new Error(`${t} ${o.value.id} is already owned by doctor plugin ${e}`)}}s(Ne,"assertAvailable");function z(n,r,t,o,e){if(!e())throw new Error(`Doctor plugin ${t} setup is complete`);if(!/^[a-z0-9][a-z0-9.-]*$/u.test(n.id))throw new Error(`Invalid ${o} ID: ${n.id}`);if(r.some(i=>i.value.id===n.id))throw new Error(`Doctor plugin ${t} registered ${o} ${n.id} twice`);r.push({pluginId:t,value:n})}s(z,"add");import at from"node:path";import{readFile as qe}from"node:fs/promises";async function Ue(n,r,t,o=process.env,e,i){e?.throwIfAborted();let a=t.filter(({value:g})=>g.languages.some(y=>r.has(y))),l=a.map(g=>g.value),f=i?await i.evidence(l,e):await ye(n,l,void 0,e),h=await tt(n,e,i),d=[...new Set(l.flatMap(g=>g.executables))],m=i?await i.executableAvailability(d.map(g=>({command:[g]})),e):void 0;if(e?.throwIfAborted(),m&&(m.length!==d.length||m.some(g=>typeof g!="boolean")))throw new TypeError("Invalid Doctor executable availability report");let w=[];for(let g of a){e?.throwIfAborted();let y=g.value,C=[],I=1,b=f.get(y.id),O=b?.config;O!==void 0&&(I+=6,C.push(`project config: ${O}`)),h.has(`${y.kind}:${y.id}`)&&(I+=6,C.push("Pi Agent IDE config"));let p=b?.dependency;p!==void 0&&(I+=4,C.push(`project dependency: ${p}`));let c=m?y.executables.find(u=>m[d.indexOf(u)]===!0):await et(n,y.executables,o,e);c!==void 0&&(I+=3,C.push(`executable: ${c}`)),w.push({pluginId:g.pluginId,recipe:y,score:I,evidence:C,...c&&{executable:c}})}return w.sort((g,y)=>y.score-g.score||g.recipe.id.localeCompare(y.recipe.id))}s(Ue,"discoverRecipeCandidates");function Be(n,r,t=[]){let o=new Map,e=new Map(t.map(i=>[`${i.kind}:${i.languageId}`,i.toolId]));for(let i of r)for(let a of["formatter","linter","lsp"]){let l=e.get(`${a}:${i}`),f=l===void 0?4:7,h=n.filter(m=>m.recipe.kind===a&&m.recipe.languages.includes(i)&&m.executable!==void 0&&m.recipe.id!==l&&m.score>=f),d=h[0];d!==void 0&&(h.filter(m=>m.score===d.score).length>1||o.set(`${d.recipe.kind}:${d.recipe.id}`,d))}return[...o.values()]}s(Be,"selectSuggestedRecipes");async function et(n,r,t,o){for(let e of r)if(await me(e,n,t,o))return e}s(et,"firstExecutable");async function tt(n,r,t){let o=new Set;for(let[e,i,a]of[["formatters","formatters","formatter"],["linters","linters","linter"],["lsp-servers","servers","lsp"]])try{r?.throwIfAborted();let l=t?(await t.configPaths(e,r)).project:L(n,e),f=t?await t.readText(l,r):await qe(l,{encoding:"utf8",signal:r});if(r?.throwIfAborted(),f===void 0)continue;let h=JSON.parse(f);if(typeof h!="object"||h===null||Array.isArray(h))continue;let m=h[i];if(typeof m=="object"&&m!==null&&!Array.isArray(m))for(let w of Object.keys(m))o.add(`${a}:${w}`)}catch(l){if(r?.throwIfAborted(),!(l instanceof SyntaxError)&&!(typeof l=="object"&&l!==null&&"code"in l&&l.code==="ENOENT"))throw l}return o}s(tt,"managedRecipeIds");import{execFile as ot}from"node:child_process";import{readdir as nt}from"node:fs/promises";import _ from"node:path";import{promisify as rt}from"node:util";var it=rt(ot),st=new Set([".git",".hg",".svn","node_modules","vendor","build","dist","coverage",".cache",".next","target"]);async function Fe(n,r){r?.throwIfAborted();try{let o=(await it("git",["ls-files","--cached","--others","--exclude-standard","-z"],{cwd:n,encoding:"utf8",maxBuffer:16777216,signal:r})).stdout.split("\0").filter(Boolean).map(e=>_.resolve(n,e)).filter(e=>!We(e));return r?.throwIfAborted(),o.length>0?o:await oe(n,r)}catch{return r?.throwIfAborted(),oe(n,r)}}s(Fe,"collectProjectFiles");function Me(n,r,t=process.platform){let o=new Map,e=t==="win32"?_.win32:_;for(let i of r){let a=new Set(i.extensions.map(d=>d.toLowerCase())),l=s(d=>t==="win32"?d.toLowerCase():d,"normalizeName"),f=new Set(i.fileNames?.map(l)),h=n.filter(d=>!d.split(_.sep).join("/").includes("/.pi/pi-agent-ide/")&&(a.has(e.extname(d).toLowerCase())||f.has(l(e.basename(d)))));h.length>0&&o.set(i.id,h)}return o}s(Me,"detectProjectLanguages");async function oe(n,r){r?.throwIfAborted();let t=[];for(let o of await nt(n,{withFileTypes:!0})){if(o.isDirectory()&&st.has(o.name))continue;let e=_.join(n,o.name);We(e)||(o.isDirectory()?t.push(...await oe(e,r)):o.isFile()&&t.push(e))}return t}s(oe,"walk");function We(n){return n.split(_.sep).join("/").includes("/.pi/pi-agent-ide/")}s(We,"isManagedIdeConfig");function ct(n,r){if(n.includes("://")&&!r||r&&r.source!==n)throw Object.assign(new Error(`Doctor requires the owner of ${n}`),{code:"UNSUPPORTED_SOURCE"})}s(ct,"assertWorkspace");async function ne(n,r,t=process.env,o,e){o?.throwIfAborted(),ct(r,e);let i=e?await e.files(o):await Fe(r,o);o?.throwIfAborted();let a=Me(i,n.languages.map(w=>w.value),e?.platform),l=new Set(a.keys()),f={cwd:r,files:i,detectedLanguageIds:l,detectedLanguages:a,env:e?{...e.toolPaths}:t,signal:o,workspace:e},[h,d]=await Promise.all([Ue(r,l,n.recipes,e?{...e.toolPaths}:t,o,e),Le(n,f)]);o?.throwIfAborted();let m=new Map;for(let w of l)for(let g of["formatter","linter","lsp"]){if(d.selections.some(b=>b.languageId===w&&b.kind===g))continue;let y=h.filter(b=>b.recipe.kind===g&&b.recipe.languages.includes(w)),C=s(b=>b.score-(b.executable===void 0?0:3),"nativeScore"),I=Math.max(1,...y.map(C));for(let b of y){if(b.executable!==void 0||C(b)!==I||I<=1)continue;let O=`${g}-${b.recipe.id}-unavailable`;m.set(O,{id:O,pluginId:b.pluginId,message:`Native project setup selects ${b.recipe.id}, but its executable is unavailable. Install ${b.recipe.executables.join(" or ")} and run Doctor again.`})}}return{cwd:r,files:i,detectedLanguages:a,candidates:h,selections:d.selections,actions:[...d.actions,...m.values()],suggestions:Be(h,l,d.selections)}}s(ne,"inspectDoctorSetup");async function G(n,r,t=process.env,o,e){let i=await ne(n,r,t,o,e),a=new Set(i.detectedLanguages.keys()),l={cwd:r,files:i.files,detectedLanguageIds:a,detectedLanguages:i.detectedLanguages,env:e?{...e.toolPaths}:t,signal:o,workspace:e},f=await _e(n,l);o?.throwIfAborted();let h=[{status:"pass",message:`Project: ${r}`},i.files.length>0?{status:"pass",message:`${i.files.length} project files inspected`}:{status:"warn",message:"No project files found"},a.size>0?{status:"pass",message:`Detected: ${[...a].join(", ")}`}:{status:"warn",message:"No registered project languages detected"}];return{...i,sections:[{title:"Project",pluginId:"doctor",findings:h},...f]}}s(G,"runDoctor");function M(n){let r=["Agent IDE doctor",""];for(let t of n.sections){r.push(`${t.title} (${t.pluginId})`);for(let o of t.findings)r.push(` ${o.status.toUpperCase().padEnd(4)} ${o.message}`),o.detail!==void 0&&r.push(` \`${o.detail}\``);r.push("")}if(n.actions.length>0){r.push("Setup needs attention");for(let t of n.actions)r.push(` ${t.message} [${t.pluginId}]`);r.push("")}if(n.suggestions.length>0){r.push("Suggested configuration");for(let t of n.suggestions){let o=t.evidence.length>0?` \u2014 ${t.evidence.join(", ")}`:"";r.push(` ${t.recipe.kind.padEnd(9)} ${t.recipe.id} [${t.pluginId}]${o}`)}r.push("")}return r.join(`
3
+ `).trimEnd()}s(M,"formatDoctorReport");function re(n){return n.actions.length>0||n.suggestions.length>0||n.sections.some(r=>r.findings.some(t=>t.status==="fail"))}s(re,"doctorNeedsWork");function Je(n){let r=n.candidates.map(t=>({owner:t.pluginId,id:t.recipe.id,kind:t.recipe.kind,languages:t.recipe.languages,evidence:t.evidence,documentation:t.recipe.documentation}));return["Finish configuring Pi Agent IDE for this project.","Preserve existing formatter, linter, compiler, and style rules. Do not invent or replace native project settings.","Do not install packages, write credentials, or change source files without the user's normal confirmation.","Pi Agent IDE project configs live in .pi/pi-agent-ide/.","Use only the relevant plugin contributions listed below; each owner remains responsible for its own scope.","",M(n),"","Relevant registered recipes:",JSON.stringify(r,null,2),"",`Project root: ${n.cwd.includes("://")?n.cwd:at.resolve(n.cwd)}`].join(`
4
+ `)}s(Je,"buildDoctorAgentPrompt");import{createHash as dt}from"node:crypto";var pt="doctor",ie=3;function Ve(n,r){let t=be(n,lt(r));t!==void 0&&t.catch(()=>{})}s(Ve,"registerDoctorTipProvider");function lt(n){return{protocol:ve,apiVersion:De,id:pt,async getTip(r){let t=await n(r),o=ut(t);if(o.length===0)return;let e=o.slice(0,ie).map(i=>`\u2022 ${i.message}`);return o.length>ie&&e.push(`\u2022 ${o.length-ie} more`),{id:`doctor-setup-${ft(o)}`,title:o.length===1?"Project setup needs attention":`${o.length} project setup items`,body:[...e,"Run /agent-ide-doctor"].join(`
5
+ `)}}}}s(lt,"createDoctorTipProvider");function ut(n){let r=n.actions.map(o=>({id:`action:${o.pluginId}:${o.id}`,message:o.message})),t=n.suggestions.map(o=>{let e=o.recipe.languages.filter(a=>n.detectedLanguages.has(a)).join(", "),i={debugger:"debugging",formatter:"formatting",linter:"linting",lsp:"language support"}[o.recipe.kind];return{id:`suggestion:${o.pluginId}:${o.recipe.kind}:${o.recipe.id}`,message:`Use ${o.recipe.name} for ${e} ${i}`}});return[...r,...t].sort((o,e)=>o.id.localeCompare(e.id))}s(ut,"setupItems");function ft(n){return dt("sha256").update(n.map(r=>`${r.id}\0${r.message}`).join("\0")).digest("hex").slice(0,12)}s(ft,"fingerprint");async function ze(n,r){let t=new Y;Ve(n,async i=>(await t.waitForPlugins(),ne(t.snapshot(),i.cwd,process.env,i.signal)));let o,e=n.events.on(ge,i=>{if(!he(i))throw new Error("Invalid doctor plugin registration request");i.accept(t.registerPlugin(i.plugin))});n.on("session_shutdown",e),n.registerCommand("agent-ide-doctor",{description:"Check and configure this project or an explicit ssh://target/path",handler:s(async(i,a)=>{let{cwd:l,flags:f}=je(i,a.cwd),h=await r?.(l);await t.waitForPlugins();let d=await G(t.snapshot(),l,process.env,void 0,h);if(se(n,M(d)),d.suggestions.length>0&&!f.has("--no-apply")&&(f.has("--apply")||a.hasUI&&await a.ui.confirm("Apply suggested configuration?","Add detected tools to .pi/pi-agent-ide/. Existing entries and native tool settings are kept."))){let g=await $e(l,d.suggestions,h),y=g.length===0?"Pi Agent IDE configs are already up to date":`Updated ${g.length} Pi Agent IDE config ${g.length===1?"file":"files"}`;a.ui.notify(y,"info"),d=await G(t.snapshot(),l,process.env,void 0,h),se(n,M(d))}if(!re(d)&&!f.has("--agent"))return;(f.has("--agent")||a.hasUI&&await a.ui.confirm("Ask the agent to finish setup?","The agent will receive this redacted report and relevant plugin recipes."))&&(o={cwd:l,workspace:h},n.sendUserMessage(Je(d)))},"handler")}),n.on("agent_end",async(i,a)=>{let l=o;if(l===void 0)return;o=void 0;let f=await G(t.snapshot(),l.cwd,process.env,void 0,l.workspace);se(n,`Doctor recheck after agent setup
6
+
7
+ ${M(f)}`),re(f)?a.ui.notify("Pi Agent IDE setup still needs attention","warning"):a.ui.notify("Pi Agent IDE setup is ready","info")}),n.events.emit(fe,{protocol:le,apiVersion:ue}),await t.waitForPlugins()}s(ze,"registerDoctorWithOwner");function se(n,r){n.sendMessage({customType:"agent-ide-doctor",content:r,display:!0},{triggerTurn:!1})}s(se,"sendReport");import U from"node:path";import{Type as E}from"typebox";import{Value as ae}from"typebox/value";var Ye={"doctor-inventory-worker.py":Q(new URL("./doctor-inventory-worker.py",new URL("../src/backend/doctor-workspace.ts",import.meta.url).href)),"doctor-probe-worker.py":Q(new URL("./doctor-probe-worker.py",new URL("../src/backend/doctor-workspace.ts",import.meta.url).href))},gt=E.Object({directory:E.String(),device:E.String({pattern:"^[0-9]+$"}),inode:E.String({pattern:"^[0-9]+$"}),containerCreated:E.Boolean(),containerDevice:E.String({pattern:"^[0-9]+$"}),containerInode:E.String({pattern:"^[0-9]+$"})});async function Ge(n,r,t){t?.throwIfAborted();let o=n.resolve(r);if(!o)throw new D("UNSUPPORTED_SOURCE",r,"not-applied");let e=o.location,i=o.backend;if((await i.stat(e.path,{signal:t})).kind!=="directory")throw new D("NOT_DIRECTORY",e.source,"not-applied");let a=s(p=>{let c=n.resolve(p);if(!c||c.location.target!==e.target)throw new D("UNSUPPORTED_SOURCE",p,"not-applied");return c.location.path},"resolve"),l=await Z({...i.target,workspace:e.path},V("import json,os,sys; keys=json.loads(sys.argv[1]); print(json.dumps({k:os.environ[k] for k in keys if k in os.environ}))"),[JSON.stringify(K)],e.source,{signal:t,timeoutMs:5e3,maxBytes:128*1024});if(l.exitCode!==0)throw new D("DEPENDENCY_UNAVAILABLE",e.source,"not-applied");let f=JSON.parse(l.stdout.toString("utf8")),h=E.Object(Object.fromEntries(K.map(p=>[p,E.Optional(E.String({maxLength:4096}))])),{additionalProperties:!1});if(!ae.Check(h,f))throw new D("INVALID_RESPONSE",e.source,"not-applied");let d=Ae(n),m=Re(n),w=ke(n,e.source),g=new Map,y=s(async(p,c,u)=>{u?.throwIfAborted();let S=await Ye[p],P=await Z(i.target,V(S),c,e.source,{signal:u,timeoutMs:3e4,maxBytes:32*1024*1024});if(P.exitCode!==0)throw new D("DOCTOR_FAILED",e.source,"not-applied");return JSON.parse(P.stdout.toString("utf8"))},"executeWorker"),C=s(async(p,c,u)=>{u?.throwIfAborted();let S=await Ye["doctor-probe-worker.py"],P=new AbortController,$=u?AbortSignal.any([u,P.signal]):P.signal,j=setTimeout(()=>P.abort(new D("TIMEOUT",e.source,"not-applied")),3e4),R,x=!1,T,k;try{R=await Pe(i.target,V(S),[JSON.stringify({operation:"create",source:p})],i.target.workspace,{signal:$});let v=0,B=s(A=>(v+=A.length,v<=128*1024?!0:(P.abort(new D("BYTE_LIMIT",e.source,"not-applied")),!1)),"consume");R.stderr.on("data",A=>{B(A)});let H=R,W=new Promise((A,He)=>{let F=Buffer.alloc(0),ce=!1;H.stdout.on("data",de=>{if(!B(de)||ce)return;F=Buffer.concat([F,de]);let pe=F.indexOf(`
8
+ `);if(!(pe<0)){ce=!0;try{A(JSON.parse(F.subarray(0,pe).toString("utf8")))}catch(Ke){He(Ke)}F=Buffer.alloc(0)}})}),J=await Promise.race([W,R.completion.then(()=>{throw new D("PROBE_FAILED",e.source,"not-applied")})]);if(u?.throwIfAborted(),!ae.Check(gt,J))throw new D("PROBE_FAILED",e.source,"not-applied");if(k=J,await R.write(Buffer.from(`retain
9
+ `)),await R.end(),(await R.completion).exitCode!==0)throw new D("PROBE_FAILED",e.source,"not-applied")}catch(v){x=!0,T=u?.aborted?u.reason:P.signal.aborted?P.signal.reason:v}finally{clearTimeout(j)}try{let v=await R?.stop();if(v?.exitCode===0&&k&&c(k),v?.exitCode===2)throw new D("PROBE_CLEANUP_FAILED",e.source,"unknown")}catch(v){throw new AggregateError(x?[T,v]:[v],"Doctor allocation cleanup failed",{cause:v})}if(x)throw T},"allocateProbe"),I=new Map,b=s(async p=>{for(;;){let c=I.get(p);if(c?.cleanup){await c.cleanup;continue}let u=c??{users:0};return u.users++,I.set(p,u),u}},"acquireContainer"),O=s(async(p,c)=>{c.users--,c.users===0&&(c.cleanup=Promise.resolve().then(async()=>{if(c.created&&await y("doctor-probe-worker.py",[JSON.stringify({operation:"remove-container",...c.created})])!==null)throw new D("PROBE_CLEANUP_FAILED",e.source,"unknown")}).finally(()=>{I.get(p)===c&&I.delete(p)}),await c.cleanup)},"releaseContainer");return{source:e.source,platform:"linux",toolPaths:f,async probeBrowser(p){return await Oe({...i.target,workspace:e.path},e.source,p),{ok:!0,detail:"Target Playwright and Chromium started without navigation"}},async files(p){let c=await y("doctor-inventory-worker.py",[e.path],p);if(!ae.Check(E.Array(E.String()),c))throw new D(typeof c=="object"&&c!==null&&"error"in c&&c.error==="BYTE_LIMIT"?"BYTE_LIMIT":"INVENTORY_FAILED",e.source,"not-applied");return c.map(u=>{let S=U.posix.resolve(e.path,u);if(U.posix.isAbsolute(u)||!(S.startsWith(`${e.path}/`)||e.path==="/"))throw new D("INVALID_RESPONSE",e.source,"not-applied");return X(e.target,S).source})},async readText(p,c){try{let u=await i.read(a(p),{signal:c}),S=u.bytes.toString("utf8");return g.set(p,{content:S,version:u.version}),S}catch(u){if(u instanceof D&&u.code==="ENOENT")return;throw u}},async writeText(p,c,u,S){let P=g.get(p);if(u!==void 0&&(!P||P.content!==u))throw new D("CONFLICT",p,"not-applied");await i.write(a(p),Buffer.from(c),u===void 0?null:P?.version??null,{signal:S})},configPaths:s((p,c)=>d.paths(e.source,p,c),"configPaths"),async exists(p,c){try{return await i.stat(a(p),{signal:c}),!0}catch(u){if(u instanceof D&&u.code==="ENOENT")return!1;throw u}},evidence:s((p,c)=>xe(i,e.path,p,c),"evidence"),executableAvailability:s((p,c)=>Ee(i,e.path,p,c),"executableAvailability"),run:s((p,c,u)=>m.run(p,{projectRoot:e.source,filePath:c,signal:u}),"run"),async withProbeCopy(p,c,u){u?.throwIfAborted();let S=a(p),P=U.posix.join(U.posix.dirname(S),".tmp"),$=await b(P),j,R=U.posix.basename(S),x=[],T;try{let v=$.allocation,B={};$.allocation=new Promise(A=>{B.resolve=A});let H=N(B.resolve);try{await v,u?.throwIfAborted(),await C(S,A=>{j=A,A.containerCreated&&($.created={container:P,device:A.containerDevice,inode:A.containerInode})},u)}finally{H()}let W=U.posix.join(N(j).directory,R),J=await i.lstat(S,{signal:u});await i.copy(S,W,J.revision,null,{signal:u}),u?.throwIfAborted(),x.push({value:await c(X(e.target,W).source)})}catch(v){T=v}let k=[];if(j)try{if(await y("doctor-probe-worker.py",[JSON.stringify({operation:"remove",...j,name:R})])!==null)throw new D("PROBE_CLEANUP_FAILED",p,"unknown")}catch(v){k.push(v)}try{await O(P,$)}catch(v){k.push(v)}if(k.length>0)throw new AggregateError(x.length===0?[T,...k]:k,"Doctor probe cleanup failed",{cause:k[0]});if(x.length===0)throw T;return N(x[0]).value},start:s((p,c,u)=>w.start({rootUri:e.source,command:p,env:c,signal:u}),"start"),toNativeUri:s(p=>w.toServerUri(p),"toNativeUri"),fromNativeUri:s(p=>w.fromServerUri(p),"fromNativeUri")}}s(Ge,"createSshDoctorWorkspace");async function ht(n){let r=new Te(await Ce(Ie(Se())));await ze(n,t=>t.startsWith("ssh://")?Ge(r,t):Promise.resolve(void 0))}s(ht,"registerOwnedDoctor");export{ht as default};
package/dist/entry-0.js CHANGED
@@ -1 +1 @@
1
- import{a as le}from"./chunk-ON5HDFNL.js";import{c as te,d as re}from"./chunk-J6CDIH3S.js";import"./chunk-J34VKQGJ.js";import{a as ie}from"./chunk-WCSWQDJ2.js";import{b as oe}from"./chunk-YHADTHQM.js";import"./chunk-EWTVVPUA.js";import"./chunk-MXLSGMRZ.js";import"./chunk-UDVVKVG4.js";import{a as ae}from"./chunk-YOJHCARZ.js";import"./chunk-HJXSEPO7.js";import{a as ne}from"./chunk-TWQ6ACOI.js";import"./chunk-FGN2ZMEN.js";import"./chunk-STUZZM5B.js";import{a as q}from"./chunk-WQTF6Q2X.js";import{b as ee}from"./chunk-APWMLLSE.js";import"./chunk-OCU6NW5Y.js";import"./chunk-ECSMTGVM.js";import"./chunk-K5M65CAF.js";import"./chunk-P7FUD4WY.js";import{a as se}from"./chunk-B5UJCNQU.js";import{a as K,b as Z}from"./chunk-YFPU2LRR.js";import"./chunk-NF74ITWT.js";import"./chunk-5D4C225L.js";import"./chunk-JXULBI4S.js";import"./chunk-R2U5WXYR.js";import"./chunk-HFCHOFLV.js";import"./chunk-5AROEOJB.js";import"./chunk-47SPPIXK.js";import"./chunk-VAXLSPPU.js";import{a as F}from"./chunk-M7P7V4WI.js";import"./chunk-33U3RUM3.js";import"./chunk-YGGKGZO2.js";import"./chunk-N2NEFXHB.js";import"./chunk-KQV2ZXLP.js";import"./chunk-MPT3R4BL.js";import"./chunk-KN6VPARZ.js";import"./chunk-2YO6RVX4.js";import"./chunk-MLFJU2US.js";import"./chunk-C2GZLLSP.js";import"./chunk-LY2UANKU.js";import{e as Q}from"./chunk-PS2B6THP.js";import"./chunk-QGXZ4RWX.js";import"./chunk-YZTVC7ME.js";import{c as B,d as Y}from"./chunk-VDSSAP6Y.js";import{a as X}from"./chunk-2DSY4U73.js";import{a as V,b as J}from"./chunk-H6FEBUAP.js";import{N as k}from"./chunk-SIYPD5MM.js";import"./chunk-756K3LJY.js";import{c as G}from"./chunk-RQ7JJ7GV.js";import"./chunk-S7E2D5K7.js";import"./chunk-ZC65Z3CK.js";import{a as n}from"./chunk-EI7MMDWY.js";import{Type as Re}from"typebox";var ce=["read","search","write","replace","insert","delete","copy","move","diff"],de={read:["path"],search:["path"],write:["path"],replace:["path"],insert:["path"],delete:["path"],copy:["path","target"],move:["path","target"],diff:["before","after"]},ue=new Set(["read","search","diff"]),pe="pi-agent-ide/standalone-reservation/v1",m=n(a=>a!==null&&typeof a=="object"&&!Array.isArray(a),"record"),fe=n(a=>a.startsWith("pi-agent-ide/operation-approval/")||a.startsWith("pi-agent-ide/settings/"),"shared");function me(a,h){let d=h.namespace.name;if(!/^[a-z][a-z0-9_]*$/u.test(d))throw new Error("Resource host namespace must be a lowercase identifier.");let w=new Set(h.tools??ce);if([...w].some(e=>!ce.includes(e)))throw new Error("Unsupported resource host tool.");let p={namespace:d,claimed:!1};if(a.events.emit(pe,p),p.claimed)throw new Error(`Resource host namespace already registered: ${d}`);let A=a.events.on(pe,e=>{m(e)&&e.namespace===d&&(e.claimed=!0)}),R=new Map,u=new Set,g=[A],S=new Map,I=new Map,C=new Set,E=!1,D,_,y=n(e=>`${d}_${e}`,"publicName"),b=n(e=>typeof e=="string"&&e.startsWith(d+"_")&&w.has(e.slice(d.length+1))?e.slice(d.length+1):void 0,"localName"),H=n(e=>e.replace(/\b(?:read|search|select|write|replace|insert|delete|copy|move|diff)\b/gu,(o,t)=>{let s=e.slice(0,t),r=e.slice(t+o.length);return s.endsWith("tools.")||s.endsWith("`")&&/^[`.]/u.test(r)||/(?:\bUse|\band) $/u.test(s)&&r.startsWith(" to ")?y(o):o}),"words");function U(e,o){let t=e.startsWith("raw:")&&!o?e.slice(4):e;return!o&&(t.startsWith("docs:")||t.startsWith("temp:"))?!0:/^[a-z][a-z\d+.-]*:\/\//iu.test(t)&&!/^(?:file:|[a-z]:[/\\])/iu.test(t)&&h.ownsSource(t)}n(U,"owns");let j=n(()=>k(_),"targets");async function x(e,o,t){let s=j().source(e,o.cwd,!t);if(Array.isArray(s)){for(let r of s)await x(r,o,t);return}if(m(s)&&"path"in s){await x(s.path,o,t);return}if(typeof s!="string")throw new Error("Use an owned resource URI or an issued source result.");if(s.startsWith("RESULT#")){let r=j().resolve(s,o.cwd);if(r.targets.some(f=>!U(f.source,t)))throw new Error("Source selection belongs outside this resource host.");await j().verify(r,o.signal);return}if(s.startsWith("SEARCH#")){let r=await D?.read({path:s},{cwd:o.cwd,signal:o.signal},"script");if(r?.isError||r?.script?.kind!=="text"||!r.script.target)throw new Error("Unknown or expired resource search selection.");await x(r.script.target,o,t);return}if(!U(s,t))throw new Error("Use this host only for its provider-owned resource URIs; local paths are not supported.")}n(x,"checkSource");async function M(e,o,t){if(E)throw new Error("Standalone resource host is closed.");if(!m(o))throw new Error("Resource tool arguments must be an object.");let s=!ue.has(e),r=de[e]??[];if(["read","search"].includes(e)&&o.path===void 0)throw new Error("Supply an explicit owned resource or source result.");if(s&&o.path===void 0){let f=oe(_)?.source;if(!f)throw new Error("Supply an owned source before editing.");await x(f,t,!0)}for(let f of r)o[f]!==void 0&&await x(o[f],t,s);for(let f of["start","end","anchor","targetStart","targetEnd"]){let c=o[f];typeof c=="string"&&/^(?:RESULT#|SEARCH#|<system-result)/u.test(c)&&await x(c,t,s)}if(e==="write"&&typeof o.content!="string")throw new Error("Standalone resource Write accepts text/JSON content, not filesystem image writes.")}n(M,"validate");let P=n((e,o)=>a.on(e,async(t,s)=>await o({...t},s)),"subscribe");g.push(P("tool_call",async(e,o)=>{let t=b(e.toolName);if(t)try{await M(t,e.input,o)}catch(s){return{block:!0,reason:s instanceof Error?s.message:String(s)}}}));let ge=n((e,o)=>{let t=o;if(e==="session_shutdown")return u.add(t),()=>{u.delete(t)};let s=P(e,async(r,f)=>{if(E)return;let c=r;if(e.startsWith("tool_")){let i=b(r.toolName);if(i)typeof r.parentToolCallId=="string"&&C.add(r.parentToolCallId),c={...r,toolName:i};else if(typeof r.toolCallId=="string"&&C.has(r.toolCallId))c={...r,toolName:r.toolName==="codemode"?"codemode":"__standalone_parent"};else return}if(e==="message_end"){if(!m(r.message)||r.message.role!=="toolResult")return;let i=b(r.message.toolName);if(!i)return;c={...r,message:{...r.message,toolName:i}}}e==="context"&&Array.isArray(r.messages)&&(c={...r,messages:r.messages.map(i=>m(i)&&typeof i.toolName=="string"?{...i,toolName:b(i.toolName)??"__outside_resource_host"}:i)});let l=await t(c,f);if(!m(l))return l;if(e==="message_end"&&m(l.message)&&m(r.message))return{...l,message:{...l.message,toolName:r.message.toolName}};if(e==="context"&&Array.isArray(l.messages)&&Array.isArray(r.messages)){let i=r.messages;if(l.messages.length!==i.length)throw new Error("Resource host context handlers must preserve message positions.");return{...l,messages:l.messages.map((N,O)=>{let T=i[O];return m(N)&&m(T)&&typeof T.toolName=="string"?{...N,toolName:T.toolName}:N})}}return l});return g.push(s),s},"on"),he={emit(e,o){if(E)throw new Error("Standalone resource host is closed.");if(fe(e))a.events.emit(e,o);else for(let t of R.get(e)??[])t(o)},on(e,o){if(fe(e)){let s=a.events.on(e,o);return g.push(s),s}let t=R.get(e);return t||R.set(e,t=new Set),t.add(o),()=>{t.delete(o)}}};function W(e){return Array.isArray(e)?e.map(W):m(e)?Object.fromEntries(Object.entries(e).map(([o,t])=>[o,o==="description"&&typeof t=="string"?H(t):W(t)])):e}n(W,"descriptions");function we(e){return{...e,tools:e.tools.flatMap(o=>{let t=b(o.name);return t?[{...o,name:t}]:[]}),executeTool(o,t,s){if(!w.has(o))throw new Error("Tool is not owned by this resource host.");return e.executeTool(y(o),t,s)}}}n(we,"toolContext"),_={...a,events:he,on:ge,registerTool:n(e=>{let o=e.name;if(!w.has(o))return;let t=Object.getOwnPropertyDescriptors(e);t.name={value:y(o),enumerable:!0,configurable:!0},t.label={value:y(o),enumerable:!0,configurable:!0},t.namespace={value:h.namespace,enumerable:!0,configurable:!0},t.exposure={value:"deferred",enumerable:!0,configurable:!0},t.description={get:n(()=>`Use ${y(o)} to ${o==="read"?"inspect provider-owned resources and packaged guides":o==="search"?"find objects or text within an explicit provider-owned resource":`${o} provider-owned text resources`}.`,"get"),enumerable:!0,configurable:!0},t.promptSnippet={get:n(()=>H(e.promptSnippet??""),"get"),enumerable:!0,configurable:!0},t.promptGuidelines={get:n(()=>[...(e.promptGuidelines??[]).map(H),"Use only this namespace's owned resource URIs and issued results. Local filesystem paths are not supported."],"get"),enumerable:!0,configurable:!0},t.parameters={get:n(()=>{let c=W(e.parameters),l=m(c.properties)?{...c.properties}:{};for(let i of de[o]??[])m(l[i])&&(l[i]={...l[i],description:"Provider-owned resource URI, unchanged source result, or an issued reference."});return o==="write"&&(l.content=Re.String({description:"Complete text/Markdown or JSON payload for the selected provider resource."})),Object.assign({},e.parameters,c,{properties:l})},"get"),enumerable:!0,configurable:!0};let s=n(async(c,l,i,N,O)=>{if(E)throw new Error("Standalone resource host is closed.");let T=new AbortController,L=n(()=>{},"finish"),ye=new Promise(v=>{L=v});S.set(T,ye);let be=[i,O.signal,T.signal].filter(v=>v!==void 0),$=AbortSignal.any(be);try{let v={...we(O),signal:$};return await M(o,l,v),$.throwIfAborted(),await e.execute(c,l,$,N,v)}finally{S.delete(T),L()}},"execute");t.execute={value:s,enumerable:!0,configurable:!0};let r=n((c,l,i)=>!ue.has(o)&&e.renderCall?e.renderCall(c,l,i):Q(i.lastComponent,{tool:y(o),primary:{text:m(c)?String(c.path??c.query??"owned resource"):"owned resource",truncate:"end"},expanded:i.expanded},l),"renderCall");t.renderCall={value:r,enumerable:!0,configurable:!0};let f=Object.defineProperties({},t);I.set(o,()=>a.registerTool({...f,exposure:"hidden"})),a.registerTool(f)},"registerTool"),getActiveTools:n(()=>a.getActiveTools().flatMap(e=>{let o=b(e);return o?[o]:[]}),"getActiveTools"),getAllTools:n(()=>a.getAllTools().flatMap(e=>{let o=b(e.name);return o?[{...e,name:o}]:[]}),"getAllTools"),setActiveTools(e){let o=a.getActiveTools().filter(t=>!b(t));a.setActiveTools([...o,...e.filter(t=>w.has(t)).map(y)])}},g.push(P("session_start",()=>{C.clear(),!(a.getSettings().defaultTools??[]).includes("-tool_search")&&a.getAllTools().some(e=>e.name==="tool_search"&&e.exposure!=="hidden")&&!a.getActiveTools().includes("tool_search")&&a.setActiveTools([...a.getActiveTools(),"tool_search"])})),g.push(P("agent_end",()=>{C.clear()}));async function z(e,o=!0){if(E)return;E=!0;for(let r of S.keys())r.abort();await Promise.all(S.values());let t=await Promise.allSettled([...u].map(r=>r({type:"session_shutdown"},e)));for(let r of g)r();if(R.clear(),u.clear(),C.clear(),o)for(let r of I.values())r();I.clear();let s=t.find(r=>r.status==="rejected");if(s?.status==="rejected")throw s.reason}return n(z,"dispose"),g.push(P("session_shutdown",(e,o)=>z(o,!1))),{api:_,owns:U,tools:[...w].map(y),dispose:z,setApi(e){_=e},setRead(e){D=e}}}n(me,"createResourceHostApi");async function Se(a,h){G(a);let d=me(a,h),w=F(d.api,{resourceOutput:!0,promptSection:`resource_${h.namespace.name}_results`}),p=w.api;d.setApi(p);try{await Z(p);let A;await X(p,{protocol:V,apiVersion:J,id:"standalone-resource-boundary",setup(u){A=u,d.setRead(u),u.addResourceGuard({id:"standalone-resource-boundary",guard:n(g=>d.owns(g.resourceSource,!1)?{kind:"accepted"}:{kind:"rejected",reason:"Resource belongs outside this standalone host."},"guard")}),u.addHandler({stage:"post-read",handler:K(k(p),u.read,g=>d.owns(g,!0))})}}),await q(p);let R=await te(p);if(await R.registerPlugin({protocol:B,apiVersion:Y,id:"standalone-resource-boundary",setup(u){u.addMutationGuard({id:"standalone-resource-boundary",guard:n(g=>g.resources.every(S=>d.owns(S.source,!0)&&S.binary===void 0)?{kind:"accepted"}:{kind:"rejected",rejection:{code:"RESOURCE_HOST_BOUNDARY",reason:"Resource belongs outside this standalone host.",message:"Use this host only for its provider-owned text resources.",effect:"not-applied"}},"guard")})}}),await se(p),await ne(p),await ae(p),await ee(p),!A)throw new Error("Standalone Read host did not initialize.");return await le(p,{recordType:`agent-documentation-read/${h.namespace.name}`,ownsTool:n(u=>typeof u=="string"&&d.tools.includes(u),"ownsTool")}),await ie(p,{preferences:{},toolName:n(u=>`${h.namespace.name}_${u}`,"toolName")}),re(p,R),w.finalize(),{api:p,tools:d.tools,dispose:n(u=>d.dispose(u),"dispose")}}catch(A){throw await d.dispose(),A}}n(Se,"createStandaloneResourceHost");export{Se as createStandaloneResourceHost};
1
+ import{a as he}from"./chunk-UHGHVYAW.js";import{c as de,d as ue}from"./chunk-VB5P3TXJ.js";import{a as ge}from"./chunk-XLTAP5YC.js";import{b as ce}from"./chunk-YHADTHQM.js";import"./chunk-J5CKSIH7.js";import"./chunk-TIZ4QDF3.js";import"./chunk-JMCI2ZE2.js";import{a as pe}from"./chunk-RNDSWVJF.js";import{a as me}from"./chunk-HRZAIZGR.js";import"./chunk-3V3OQO5S.js";import"./chunk-ASVMQMPX.js";import{a as fe}from"./chunk-E7JBYW43.js";import"./chunk-MJMRV76H.js";import"./chunk-72WO7H5T.js";import{a as ie}from"./chunk-HUICUICD.js";import{b as le}from"./chunk-X4CU7CMR.js";import"./chunk-QC6VFZSB.js";import"./chunk-KJ6HZC6L.js";import"./chunk-SF44YQCB.js";import"./chunk-QR7JR3P2.js";import{a as ae}from"./chunk-R7576HPO.js";import"./chunk-LG22ELG4.js";import"./chunk-SKHD2QIT.js";import"./chunk-D23NS4VV.js";import"./chunk-4AEYLVSR.js";import"./chunk-47SPPIXK.js";import"./chunk-VAXLSPPU.js";import{a as se}from"./chunk-DSB6A5P5.js";import"./chunk-XKVU6AAS.js";import"./chunk-E4V4VNRM.js";import"./chunk-GDIF3WT6.js";import"./chunk-VNG4QPPT.js";import"./chunk-YGGKGZO2.js";import"./chunk-VNNAVC4S.js";import"./chunk-6DC2Q5BI.js";import{d as oe}from"./chunk-BW3XONMZ.js";import"./chunk-GTZOIJCH.js";import"./chunk-JXULBI4S.js";import"./chunk-MPT3R4BL.js";import"./chunk-KN6VPARZ.js";import"./chunk-2YO6RVX4.js";import"./chunk-MLFJU2US.js";import{a as ne}from"./chunk-SJQGFUXR.js";import"./chunk-IZTOXSTR.js";import"./chunk-QCAGAJHJ.js";import"./chunk-JY63UUC2.js";import{a as Z}from"./chunk-I3G6K7QU.js";import{a as K,b as Q}from"./chunk-HSAGZWPO.js";import{e as re}from"./chunk-PS2B6THP.js";import{d as ee,e as te}from"./chunk-XEPCURYZ.js";import{G as J,H as X,ma as B,ta as k}from"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import"./chunk-2EY3LEZ7.js";import{c as Y}from"./chunk-RQ7JJ7GV.js";import"./chunk-IRLWXPL4.js";import"./chunk-ZC65Z3CK.js";import{a as n}from"./chunk-EI7MMDWY.js";import{Type as we}from"typebox";var ye=["read","search","write","replace","insert","delete","copy","move","diff"],Re={read:["path"],search:["path"],write:["path"],replace:["path"],insert:["path"],delete:["path"],copy:["path","target"],move:["path","target"],diff:["before","after"]},be=new Set(["read","search","diff"]),Se="pi-agent-ide/standalone-reservation/v1",g=n(a=>a!==null&&typeof a=="object"&&!Array.isArray(a),"record"),Ee=n(a=>a.startsWith("pi-agent-ide/operation-approval/")||a.startsWith("pi-agent-ide/settings/"),"shared"),H=class extends Error{constructor(d,w){super(w?"Local filesystem paths are not supported by this standalone host. Use a provider-owned resource URI.":"This resource URI is not owned by this standalone host. Use a resource owned by this namespace.");this.source=d;this.code=w?"RESOURCE_HOST_LOCAL_PATH":"RESOURCE_HOST_FOREIGN_SOURCE"}static{n(this,"ResourceHostSourceError")}code};function Te(a,y){let d=y.namespace.name;if(!/^[a-z][a-z0-9_]*$/u.test(d))throw new Error("Resource host namespace must be a lowercase identifier.");let w=new Set(y.tools??ye);if([...w].some(e=>!ye.includes(e)))throw new Error("Unsupported resource host tool.");let p={namespace:d,claimed:!1};if(a.events.emit(Se,p),p.claimed)throw new Error(`Resource host namespace already registered: ${d}`);let _=a.events.on(Se,e=>{g(e)&&e.namespace===d&&(e.claimed=!0)}),E=new Map,u=new Set,h=[_],T=new Map,U=new Map,v=new Set,C=!1,z,P,b=n(e=>`${d}_${e}`,"publicName"),S=n(e=>typeof e=="string"&&e.startsWith(d+"_")&&w.has(e.slice(d.length+1))?e.slice(d.length+1):void 0,"localName"),$=n(e=>e.replace(/\b(?:read|search|select|write|replace|insert|delete|copy|move|diff)\b/gu,(t,o)=>{let s=e.slice(0,o),r=e.slice(o+t.length);return s.endsWith("tools.")||s.endsWith("`")&&/^[`.]/u.test(r)||/(?:\bUse|\band) $/u.test(s)&&r.startsWith(" to ")?b(t):t}),"words");function j(e,t){let o=e.startsWith("raw:")&&!t?e.slice(4):e;return!t&&(o.startsWith("docs:")||o.startsWith("temp:"))?!0:/^[a-z][a-z\d+.-]*:\/\//iu.test(o)&&!/^(?:file:|[a-z]:[/\\])/iu.test(o)&&y.ownsSource(o)}n(j,"owns");let M=n((e,t)=>{let o=e.startsWith("raw:")&&!t?e.slice(4):e,s=!/^[a-z][a-z\d+.-]*:/iu.test(o)||/^(?:file:|[a-z]:)/iu.test(o);return new H(e,s)},"sourceError"),W=n(()=>k(P),"targets");async function O(e,t,o){let s=W().source(e,t.cwd,!o);if(Array.isArray(s)){for(let r of s)await O(r,t,o);return}if(g(s)&&"path"in s){await O(s.path,t,o);return}if(typeof s!="string")throw new Error("Use an owned resource URI or an issued source result.");if(s.startsWith("RESULT#")){let r=W().resolve(s,t.cwd),m=r.targets.find(i=>!j(i.source,o));if(m)throw M(m.source,o);await W().verify(r,t.signal);return}if(s.startsWith("SEARCH#")){let r=await z?.read({path:s},{cwd:t.cwd,signal:t.signal},"script");if(r?.isError||r?.script?.kind!=="text"||!r.script.target)throw new Error("Unknown or expired resource search selection.");await O(r.script.target,t,o);return}if(!j(s,o))throw M(s,o)}n(O,"checkSource");async function G(e,t,o){if(C)throw new Error("Standalone resource host is closed.");if(!g(t))throw new Error("Resource tool arguments must be an object.");let s=!be.has(e),r=Re[e]??[];if(["read","search"].includes(e)&&t.path===void 0)throw new Error("Supply an explicit owned resource or source result.");if(s&&t.path===void 0){let m=ce(P)?.source;if(!m)throw new Error("Supply an owned source before editing.");await O(m,o,!0)}for(let m of r)t[m]!==void 0&&await O(t[m],o,s);for(let m of oe(e)){let i=t[m];(B(i)!==void 0||typeof i=="string"&&/^(?:RESULT#|SEARCH#|<system-result)/u.test(i))&&await O(i,o,s)}if(e==="write"&&typeof t.content!="string")throw new Error("Standalone resource Write accepts text/JSON content, not filesystem image writes.")}n(G,"validate");let I=n((e,t)=>a.on(e,async(o,s)=>await t({...o},s)),"subscribe"),A=new Map;h.push(I("tool_call",async(e,t)=>{let o=S(e.toolName);if(o)try{await G(o,e.input,t)}catch(s){if(typeof e.toolCallId=="string")A.set(e.toolCallId,s instanceof Error?s:new Error(String(s)));else return{block:!0,reason:s instanceof Error?s.message:String(s)}}}));let Ae=n((e,t)=>{let o=t;if(e==="session_shutdown")return u.add(o),()=>{u.delete(o)};let s=I(e,async(r,m)=>{if(C||e==="tool_call"&&typeof r.toolCallId=="string"&&A.has(r.toolCallId))return;let i=r;if(e.startsWith("tool_")){let c=S(r.toolName);if(c)typeof r.parentToolCallId=="string"&&v.add(r.parentToolCallId),i={...r,toolName:c};else if(typeof r.toolCallId=="string"&&v.has(r.toolCallId))i={...r,toolName:r.toolName==="codemode"?"codemode":"__standalone_parent"};else return}if(e==="message_end"){if(!g(r.message)||r.message.role!=="toolResult")return;let c=S(r.message.toolName);if(!c)return;i={...r,message:{...r.message,toolName:c}}}e==="context"&&Array.isArray(r.messages)&&(i={...r,messages:r.messages.map(c=>g(c)&&typeof c.toolName=="string"?{...c,toolName:S(c.toolName)??"__outside_resource_host"}:c)});let l=await o(i,m);if(!g(l))return l;if(e==="message_end"&&g(l.message)&&g(r.message))return{...l,message:{...l.message,toolName:r.message.toolName}};if(e==="context"&&Array.isArray(l.messages)&&Array.isArray(r.messages)){let c=r.messages;if(l.messages.length!==c.length)throw new Error("Resource host context handlers must preserve message positions.");return{...l,messages:l.messages.map((R,N)=>{let x=c[N];return g(R)&&g(x)&&typeof x.toolName=="string"?{...R,toolName:x.toolName}:R})}}return l});return h.push(s),s},"on"),xe={emit(e,t){if(C)throw new Error("Standalone resource host is closed.");if(Ee(e))a.events.emit(e,t);else for(let o of E.get(e)??[])o(t)},on(e,t){if(Ee(e)){let s=a.events.on(e,t);return h.push(s),s}let o=E.get(e);return o||E.set(e,o=new Set),o.add(t),()=>{o.delete(t)}}};function D(e){return Array.isArray(e)?e.map(D):g(e)?Object.fromEntries(Object.entries(e).map(([t,o])=>[t,t==="description"&&typeof o=="string"?$(o):D(o)])):e}n(D,"descriptions");function _e(e){return{...e,tools:e.tools.flatMap(t=>{let o=S(t.name);return o?[{...t,name:o}]:[]}),executeTool(t,o,s){if(!w.has(t))throw new Error("Tool is not owned by this resource host.");return e.executeTool(b(t),o,s)}}}n(_e,"toolContext"),P={...a,events:xe,on:Ae,registerTool:n(e=>{let t=e.name;if(!w.has(t))return;let o=Object.getOwnPropertyDescriptors(e);o.name={value:b(t),enumerable:!0,configurable:!0},o.label={value:b(t),enumerable:!0,configurable:!0},o.namespace={value:y.namespace,enumerable:!0,configurable:!0},o.exposure={value:"deferred",enumerable:!0,configurable:!0},o.description={get:n(()=>`Use ${b(t)} to ${t==="read"?"inspect provider-owned resources and packaged guides":t==="search"?"find objects or text within an explicit provider-owned resource":`${t} provider-owned text resources`}.`,"get"),enumerable:!0,configurable:!0},o.promptSnippet={get:n(()=>$(e.promptSnippet??""),"get"),enumerable:!0,configurable:!0},o.promptGuidelines={get:n(()=>[...(e.promptGuidelines??[]).map($),"Use only this namespace's owned resource URIs and issued results. Local filesystem paths are not supported."],"get"),enumerable:!0,configurable:!0},o.parameters={get:n(()=>{let i=D(e.parameters),l=g(i.properties)?{...i.properties}:{};for(let R of Re[t]??[])g(l[R])&&(l[R]={...l[R],description:"Provider-owned resource URI, unchanged source result, or an issued reference."});if(t!=="write")return Object.assign({},e.parameters,i,{properties:l});delete l.image,l.content=we.String({description:"Complete text/Markdown or JSON payload for the selected provider resource."});let c=Array.isArray(i.required)?i.required:[];return Object.assign({},e.parameters,i,{properties:l,required:[...new Set([...c,"content"])]})},"get"),enumerable:!0,configurable:!0};let s=n(async(i,l,c,R,N)=>{if(C)throw new Error("Standalone resource host is closed.");let x=new AbortController,q=n(()=>{},"finish"),Ce=new Promise(f=>{q=f});T.set(x,Ce);let Oe=[c,N.signal,x.signal].filter(f=>f!==void 0),L=AbortSignal.any(Oe);try{let f=A.get(i);if(A.delete(i),f)throw f;let F={..._e(N),signal:L};return await G(t,l,F),L.throwIfAborted(),await e.execute(i,l,L,R,F)}catch(f){if(!(f instanceof H))throw f;return X({content:[{type:"text",text:`${f.code}: ${f.message} (${f.source})`}],details:{boundary:{code:f.code,source:f.source}}},we.Unknown(),{status:"error",errors:[J(f,f.code,f.source)]})}finally{T.delete(x),q()}},"execute");o.execute={value:s,enumerable:!0,configurable:!0};let r=n((i,l,c)=>!be.has(t)&&e.renderCall?e.renderCall(i,l,c):re(c.lastComponent,{tool:b(t),primary:{text:g(i)?String(i.path??i.query??"owned resource"):"owned resource",truncate:"end"},expanded:c.expanded},l),"renderCall");o.renderCall={value:r,enumerable:!0,configurable:!0};let m=Object.defineProperties({},o);U.set(t,()=>a.registerTool({...m,exposure:"hidden"})),a.registerTool(m)},"registerTool"),getActiveTools:n(()=>a.getActiveTools().flatMap(e=>{let t=S(e);return t?[t]:[]}),"getActiveTools"),getAllTools:n(()=>a.getAllTools().flatMap(e=>{let t=S(e.name);return t?[{...e,name:t}]:[]}),"getAllTools"),setActiveTools(e){let t=a.getActiveTools().filter(o=>!S(o));a.setActiveTools([...t,...e.filter(o=>w.has(o)).map(b)])}},h.push(I("session_start",()=>{v.clear(),A.clear(),!(a.getSettings().defaultTools??[]).includes("-tool_search")&&a.getAllTools().some(e=>e.name==="tool_search"&&e.exposure!=="hidden")&&!a.getActiveTools().includes("tool_search")&&a.setActiveTools([...a.getActiveTools(),"tool_search"])})),h.push(I("agent_end",()=>{v.clear(),A.clear()}));async function V(e,t=!0){if(C)return;C=!0;for(let r of T.keys())r.abort();await Promise.all(T.values());let o=await Promise.allSettled([...u].map(r=>r({type:"session_shutdown"},e)));for(let r of h)r();if(E.clear(),u.clear(),v.clear(),A.clear(),t)for(let r of U.values())r();U.clear();let s=o.find(r=>r.status==="rejected");if(s?.status==="rejected")throw s.reason}return n(V,"dispose"),h.push(I("session_shutdown",(e,t)=>V(t,!1))),{api:P,owns:j,tools:[...w].map(b),dispose:V,setApi(e){P=e},setRead(e){z=e}}}n(Te,"createResourceHostApi");async function ve(a,y){Y(a);let d=Te(a,y),w=se(d.api,{resourceOutput:!0,promptSection:`resource_${y.namespace.name}_results`}),p=w.api;d.setApi(p);try{await ae(p);let _;await Z(p,{protocol:K,apiVersion:Q,id:"standalone-resource-boundary",setup(u){_=u,d.setRead(u),u.addResourceGuard({id:"standalone-resource-boundary",guard:n(h=>d.owns(h.resourceSource,!1)?{kind:"accepted"}:{kind:"rejected",reason:"Resource belongs outside this standalone host."},"guard")}),u.addHandler({stage:"post-read",handler:ne(k(p),u.read,h=>d.owns(h,!0))})}}),await ie(p);let E=await de(p);if(await E.registerPlugin({protocol:ee,apiVersion:te,id:"standalone-resource-boundary",setup(u){u.addMutationGuard({id:"standalone-resource-boundary",guard:n(h=>h.resources.every(T=>d.owns(T.source,!0)&&T.binary===void 0)?{kind:"accepted"}:{kind:"rejected",rejection:{code:"RESOURCE_HOST_BOUNDARY",reason:"Resource belongs outside this standalone host.",message:"Use this host only for its provider-owned text resources.",effect:"not-applied"}},"guard")})}}),await pe(p),await fe(p),await me(p),await le(p),!_)throw new Error("Standalone Read host did not initialize.");return await he(p,{recordType:`agent-documentation-read/${y.namespace.name}`,ownsTool:n(u=>typeof u=="string"&&d.tools.includes(u),"ownsTool")}),await ge(p,{preferences:{},toolName:n(u=>`${y.namespace.name}_${u}`,"toolName")}),ue(p,E),w.finalize(),{api:p,tools:d.tools,dispose:n(u=>d.dispose(u),"dispose")}}catch(_){throw await d.dispose(),_}}n(ve,"createStandaloneResourceHost");export{ve as createStandaloneResourceHost};
package/dist/entry-12.js CHANGED
@@ -1 +1 @@
1
- import{a as h,b as i,c as j,d as k}from"./chunk-72FL5FHZ.js";import"./chunk-S3T5NOSL.js";import"./chunk-BXGMMZT3.js";import{a,b,c,d,e,f,g}from"./chunk-MLFJU2US.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{c as DOCTOR_API_VERSION,d as DOCTOR_CORE_READY_EVENT,e as DOCTOR_PLUGIN_REGISTER_EVENT,b as DOCTOR_PROTOCOL,a as DOCTOR_TOOL_PATH_KEYS,j as doctorExecutableAvailable,i as doctorProcessAccess,h as doctorRuntimeOptions,f as isDoctorCoreReady,g as isDoctorPluginRegistrationRequest,k as withDoctorProbeCopy};
1
+ import{a as h,b as i,c as j,d as k}from"./chunk-PBMHSK6J.js";import"./chunk-OA26FH5G.js";import"./chunk-BXGMMZT3.js";import{a,b,c,d,e,f,g}from"./chunk-MLFJU2US.js";import"./chunk-2EY3LEZ7.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{c as DOCTOR_API_VERSION,d as DOCTOR_CORE_READY_EVENT,e as DOCTOR_PLUGIN_REGISTER_EVENT,b as DOCTOR_PROTOCOL,a as DOCTOR_TOOL_PATH_KEYS,j as doctorExecutableAvailable,i as doctorProcessAccess,h as doctorRuntimeOptions,f as isDoctorCoreReady,g as isDoctorPluginRegistrationRequest,k as withDoctorProbeCopy};
package/dist/entry-15.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-3PMHFEJY.js";import"./chunk-DHOIQZUF.js";import"./chunk-NNCZYO4Q.js";import"./chunk-IQD6PON5.js";import"./chunk-C2GZLLSP.js";import"./chunk-LY2UANKU.js";import"./chunk-PS2B6THP.js";import"./chunk-QGXZ4RWX.js";import{a as l}from"./chunk-YZTVC7ME.js";import{c as a,d as s}from"./chunk-VDSSAP6Y.js";import{a as p}from"./chunk-2DSY4U73.js";import{a as u,b as y}from"./chunk-H6FEBUAP.js";import"./chunk-SIYPD5MM.js";import"./chunk-756K3LJY.js";import"./chunk-S7E2D5K7.js";import"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";function x(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/before-delete/${e.id}`,setup(t){t.addDeleteGuard({id:e.id,guard:d(n=>e.run(n),"guard")})}})}d(x,"connectBeforeDeleteHook");function m(o,e){return c(e),p(o,{protocol:u,apiVersion:y,id:`hook/before-read/${e.id}`,setup(t){t.addResourceGuard({id:e.id,async guard(n){let r=await e.run(n);return r.decision==="allow"?{kind:"accepted"}:{kind:"rejected",reason:r.reason}}})}})}d(m,"connectBeforeReadHook");function A(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/before-edit/${e.id}`,setup(t){t.addMutationGuard({id:e.id,async guard(n,r){let f=await e.run({cwd:r.cwd,intent:r.intent??"edit",resources:n.resources.map(i=>({resourceSource:i.source,existed:i.existed,before:i.before,after:i.after,changes:i.changes,...i.binary===void 0?{}:{binary:i.binary}})),...r.signal!==void 0&&{signal:r.signal}});return f.decision==="allow"?{kind:"accepted"}:{kind:"rejected",rejection:{code:"MUTATION_REJECTED",reason:f.reason,message:`Edit blocked by hook ${e.id}: ${f.reason}`,effect:"not-applied"}}}})}})}d(A,"connectBeforeEditHook");function v(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/after-edit/${e.id}`,setup(t){t.onDidEdit(async n=>{if(n.postProcessing!=="deferred")try{return await e.run(n)}catch(r){return{feedback:`After-edit hook ${e.id} failed after the edit was saved: ${r instanceof Error?r.message:String(r)}`,tone:"error"}}})}})}d(v,"connectAfterEditHook");function c(o){if(o.id.trim().length===0||typeof o.run!="function")throw new TypeError("A file hook needs a non-empty id and run function")}d(c,"assertHook");export{v as connectAfterEditHook,x as connectBeforeDeleteHook,A as connectBeforeEditHook,m as connectBeforeReadHook};
1
+ import"./chunk-3PMHFEJY.js";import"./chunk-GQXZEOND.js";import"./chunk-NNCZYO4Q.js";import"./chunk-IQD6PON5.js";import"./chunk-SJQGFUXR.js";import"./chunk-IZTOXSTR.js";import"./chunk-QCAGAJHJ.js";import{a as l}from"./chunk-JY63UUC2.js";import{a as p}from"./chunk-I3G6K7QU.js";import{a as u,b as y}from"./chunk-HSAGZWPO.js";import"./chunk-PS2B6THP.js";import{d as a,e as s}from"./chunk-XEPCURYZ.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import"./chunk-2EY3LEZ7.js";import"./chunk-IRLWXPL4.js";import"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";function x(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/before-delete/${e.id}`,setup(t){t.addDeleteGuard({id:e.id,guard:d(n=>e.run(n),"guard")})}})}d(x,"connectBeforeDeleteHook");function m(o,e){return c(e),p(o,{protocol:u,apiVersion:y,id:`hook/before-read/${e.id}`,setup(t){t.addResourceGuard({id:e.id,async guard(n){let r=await e.run(n);return r.decision==="allow"?{kind:"accepted"}:{kind:"rejected",reason:r.reason}}})}})}d(m,"connectBeforeReadHook");function A(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/before-edit/${e.id}`,setup(t){t.addMutationGuard({id:e.id,async guard(n,r){let f=await e.run({cwd:r.cwd,intent:r.intent??"edit",resources:n.resources.map(i=>({resourceSource:i.source,existed:i.existed,before:i.before,after:i.after,changes:i.changes,...i.binary===void 0?{}:{binary:i.binary}})),...r.signal!==void 0&&{signal:r.signal}});return f.decision==="allow"?{kind:"accepted"}:{kind:"rejected",rejection:{code:"MUTATION_REJECTED",reason:f.reason,message:`Edit blocked by hook ${e.id}: ${f.reason}`,effect:"not-applied"}}}})}})}d(A,"connectBeforeEditHook");function v(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/after-edit/${e.id}`,setup(t){t.onDidEdit(async n=>{if(n.postProcessing!=="deferred")try{return await e.run(n)}catch(r){return{feedback:`After-edit hook ${e.id} failed after the edit was saved: ${r instanceof Error?r.message:String(r)}`,tone:"error"}}})}})}d(v,"connectAfterEditHook");function c(o){if(o.id.trim().length===0||typeof o.run!="function")throw new TypeError("A file hook needs a non-empty id and run function")}d(c,"assertHook");export{v as connectAfterEditHook,x as connectBeforeDeleteHook,A as connectBeforeEditHook,m as connectBeforeReadHook};
package/dist/entry-17.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-3PMHFEJY.js";import{a as u}from"./chunk-DHOIQZUF.js";import"./chunk-NNCZYO4Q.js";import{a as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q,q as r}from"./chunk-C2GZLLSP.js";import{b as s,d as t}from"./chunk-LY2UANKU.js";import"./chunk-PS2B6THP.js";import{a as h}from"./chunk-2DSY4U73.js";import{a,b,c,d,e,f,g}from"./chunk-H6FEBUAP.js";import"./chunk-SIYPD5MM.js";import"./chunk-756K3LJY.js";import"./chunk-S7E2D5K7.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{s as COMPACT_READ_ROWS,b as READ_API_VERSION,c as READ_CORE_READY_EVENT,d as READ_PLUGIN_REGISTER_EVENT,a as READ_PROTOCOL,h as connectReadPlugin,u as createJqReadHandler,t as createReadResultRenderer,q as isFragmentResolverRegistration,e as isReadCoreReady,r as isReadFragmentResolution,o as isReadHandlerRegistration,f as isReadPlugin,g as isReadPluginRegistrationRequest,p as isReadViewRegistration,n as isResourceResolverRegistration,m as isTextTargetResolverRegistration,j as readDataSchema,k as readOutputSchema,i as readParameters,l as structuredRead};
1
+ import"./chunk-3PMHFEJY.js";import{a as w}from"./chunk-GQXZEOND.js";import"./chunk-NNCZYO4Q.js";import{a as i,i as j,j as k,m as l,n as m,o as n,p as o,q as p,r as q,s as r,t as s,u as t}from"./chunk-SJQGFUXR.js";import{b as u,d as v}from"./chunk-IZTOXSTR.js";import{a as h}from"./chunk-I3G6K7QU.js";import{a,b,c,d,e,f,g}from"./chunk-HSAGZWPO.js";import"./chunk-PS2B6THP.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import"./chunk-2EY3LEZ7.js";import"./chunk-IRLWXPL4.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{u as COMPACT_READ_ROWS,b as READ_API_VERSION,c as READ_CORE_READY_EVENT,d as READ_PLUGIN_REGISTER_EVENT,a as READ_PROTOCOL,h as connectReadPlugin,w as createJqReadHandler,v as createReadResultRenderer,i as createReadResultTargetHandler,s as isFragmentResolverRegistration,e as isReadCoreReady,t as isReadFragmentResolution,q as isReadHandlerRegistration,f as isReadPlugin,g as isReadPluginRegistrationRequest,r as isReadViewRegistration,p as isResourceResolverRegistration,o as isTextTargetResolverRegistration,l as readDataSchema,m as readOutputSchema,j as readParameters,k as readRequestOf,n as structuredRead};
package/dist/entry-18.js CHANGED
@@ -1 +1 @@
1
- import{a as r}from"./chunk-XE4W5YTE.js";import{a as e}from"./chunk-UGWRUW77.js";import"./chunk-EI7MMDWY.js";export{r as createImageContentConverter,e as createPdfContentConverter};
1
+ import{a as r}from"./chunk-72X24ARV.js";import{a as e}from"./chunk-UGWRUW77.js";import"./chunk-EI7MMDWY.js";export{r as createImageContentConverter,e as createPdfContentConverter};
package/dist/entry-19.js CHANGED
@@ -1 +1 @@
1
- import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s,v as u,w as v,x as w,y,z}from"./chunk-SIYPD5MM.js";import"./chunk-EI7MMDWY.js";export{D as CONTENT_API_VERSION,F as CONTENT_CONVERTER_REGISTER_EVENT,E as CONTENT_HOST_READY_EVENT,C as CONTENT_PROTOCOL,c as MAX_STRUCTURED_BYTES,x as ResourceError,o as ResourceScheduler,O as ResultImageStore,L as ResultTargetStore,f as TempResourceStore,z as UnsupportedContentError,d as assertJsonData,J as connectContentConverter,P as connectResultImages,N as connectResultTargets,I as createContentHost,A as createContentRunner,j as isAgentContent,w as isContentConversionAttempt,u as isContentConversionContext,v as isContentConverter,y as isContentConverterRegistration,H as isContentConverterRegistrationRequest,G as isContentHostReady,s as isContentInput,q as isContentTarget,k as isResource,n as isResourceResolutionAttempt,l as isResourceResolver,i as renderContentDescription,e as resourceAccesses,p as resourceErrorMetadata,t as resourceErrorMetadataOf,m as resourceErrorMetadataSchema,r as resourceScheduler,g as resultError,a as resultErrorSchema,K as resultInputSchema,b as structuredResultSchema,B as targetsEqual,M as verifyResultTargets,h as withStructuredResult};
1
+ import{$ as oo,A as B,B as C,C as D,D as E,E as F,F as G,G as H,H as I,I as J,J as K,K as L,L as M,M as N,N as O,O as P,P as Q,Q as R,R as S,S as T,T as U,U as V,V as W,W as X,X as Y,Y as Z,Z as _,_ as $,a as r,aa as ro,b as e,ba as eo,c as f,ca as fo,d as m,da as mo,e as p,ea as po,f as t,fa as to,g as x,ga as xo,h as a,ha as ao,i as b,ia as bo,j as c,ja as co,k as d,ka as go,l as g,la as ho,m as h,ma as io,n as i,na as jo,o as j,oa as ko,p as k,pa as lo,q as l,qa as no,r as n,ra as qo,s as q,sa as so,t as s,ta as uo,u,ua as vo,v,va as wo,w,x as y,y as z,z as A}from"./chunk-OEEE5BLN.js";import{a as o}from"./chunk-2QCE7GOV.js";import"./chunk-EI7MMDWY.js";export{Z as CONTENT_API_VERSION,$ as CONTENT_CONVERTER_REGISTER_EVENT,_ as CONTENT_HOST_READY_EVENT,Y as CONTENT_PROTOCOL,m as EDIT_EXECUTION_TIMEOUT_MS,f as EDIT_WAIT_TIMEOUT_MS,l as FILE_TEXT_READ_EVENT,n as FILE_TEXT_VISIBLE_EVENT,F as MAX_STRUCTURED_BYTES,p as NAVIGATION_TIMEOUT_MS,C as ResourceError,r as ResourceScheduler,vo as ResultImageStore,ko as ResultTargetStore,t as SEARCH_TIMEOUT_MS,y as TempResourceStore,a as ToolDeadlineError,V as UnsupportedContentError,G as assertJsonData,q as attachFileTextWindows,g as configureSearchDeadline,fo as connectContentConverter,wo as connectResultImages,uo as connectResultTargets,eo as createContentHost,W as createContentRunner,mo as createLineMap,to as createRangeTracker,no as currentResultTargets,so as describeAdjustedRanges,ao as describeLostRange,v as fileTextDigest,w as fileTextKeys,x as ideToolTimeoutMs,L as isAgentContent,T as isContentConversionAttempt,R as isContentConversionContext,S as isContentConverter,U as isContentConverterRegistration,ro as isContentConverterRegistrationRequest,oo as isContentHostReady,Q as isContentInput,P as isContentTarget,M as isResource,O as isResourceResolutionAttempt,N as isResourceResolver,o as normalizeStructuredArguments,xo as rangesInText,bo as readUnchanged,po as rebaseOrRelocateRange,K as renderContentDescription,d as reportToolEffect,k as resourceAccesses,A as resourceErrorMetadata,B as resourceErrorMetadataOf,z as resourceErrorMetadataSchema,e as resourceScheduler,H as resultError,D as resultErrorSchema,ho as resultInputSchema,go as resultSourceSchema,qo as resultTargetsInText,io as resultValueId,jo as resultValueReference,co as resultValueSchema,u as retainFileTextWindows,h as runWithToolDeadline,i as runWithinToolDeadline,b as snapshotOnToolDeadline,E as structuredResultSchema,s as takeFileTextWindows,X as targetsEqual,j as toolDeadlineFailure,J as trackScriptCalls,c as trackToolCleanup,lo as verifyResultTargets,I as withStructuredResult};
package/dist/entry-20.js CHANGED
@@ -1 +1 @@
1
- import{a as g,b as h,c as i,d as j,e as k,f as l,g as n,h as q,i as s,j as u}from"./chunk-HFCHOFLV.js";import{b as x,c as a,d as b,e as c}from"./chunk-5AROEOJB.js";import{a as d}from"./chunk-47SPPIXK.js";import{a as o,b as r,c as e,d as f,e as m,f as p,g as t}from"./chunk-VAXLSPPU.js";import"./chunk-PS2B6THP.js";import"./chunk-SIYPD5MM.js";import"./chunk-EI7MMDWY.js";export{n as FuzzyVocabulary,r as SEARCH_API_VERSION,e as SEARCH_CORE_READY_EVENT,f as SEARCH_PLUGIN_REGISTER_EVENT,o as SEARCH_PROTOCOL,d as connectSearchPlugin,h as containsSearchMatch,u as formatFuzzyCandidate,s as fuzzyCandidateData,j as fuzzyLimits,l as isFuzzyQuery,k as isFuzzyResultData,m as isSearchCoreReady,p as isSearchPlugin,t as isSearchPluginRegistrationRequest,q as rankFuzzyIdentifiers,g as renderSearchMatches,x as searchDataSchema,a as searchOutputSchema,c as searchSchema,b as selectionData,i as splitGlobList};
1
+ import{A as F,B as G,a as x,b as a,c as b,e as c,f as d,g,h,i,j,k,l,m as n,o as q,p as s,q as u,r as v,s as w,t as y,u as z,v as A,w as B,x as C,y as D,z as E}from"./chunk-4AEYLVSR.js";import{a as H}from"./chunk-47SPPIXK.js";import{a as o,b as r,c as e,d as f,e as m,f as p,g as t}from"./chunk-VAXLSPPU.js";import"./chunk-PS2B6THP.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import"./chunk-EI7MMDWY.js";export{D as FuzzyVocabulary,r as SEARCH_API_VERSION,e as SEARCH_CORE_READY_EVENT,f as SEARCH_PLUGIN_REGISTER_EVENT,o as SEARCH_PROTOCOL,z as SearchCaptureGuard,y as SearchCaptureLimitError,s as SearchScopeChangedError,H as connectSearchPlugin,v as containsSearchMatch,u as currentScope,k as describePathArgument,G as formatFuzzyCandidate,F as fuzzyCandidateData,A as fuzzyLimits,C as isFuzzyQuery,B as isFuzzyResultData,g as isResultReference,m as isSearchCoreReady,p as isSearchPlugin,t as isSearchPluginRegistrationRequest,c as markNullFields,d as nullFieldsMessage,j as pathMachine,h as plainPathList,E as rankFuzzyIdentifiers,q as renderSearchMatches,l as searchCallPolicy,x as searchDataSchema,a as searchOutputSchema,n as searchSchema,b as selectionData,w as splitGlobList,i as uniquePaths};
package/dist/entry-21.js CHANGED
@@ -1 +1 @@
1
- import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s}from"./chunk-S7E2D5K7.js";import"./chunk-EI7MMDWY.js";export{o as TextAnchor,r as attachTextAnchorRenderer,j as createTextContentConverter,g as createTextDocument,e as getTextAnchorRenderer,a as getTextSourceLine,t as isTextAnchorRecoveryOutcome,p as isTextAnchorResolutionAttempt,m as isTextAnchorResolver,c as isTextLinePresenter,d as isTextPresenterRegistration,n as isTextTargetResolutionAttempt,k as isTextualMediaType,i as renderPresentedTextDocument,x as renderPresentedTextRows,f as renderTextAnchor,h as renderTextDocument,s as restoreText,q as storeText,l as textFromAgentContent,b as withTextSourceLine};
1
+ import{A,B,C,D,E,F,G,a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s,v as u,w as v,x as w,y,z}from"./chunk-IRLWXPL4.js";import"./chunk-EI7MMDWY.js";export{j as LINE_ANCHOR_PATTERN,C as NO_FINAL_LINE_BREAK,k as PRESENTED_LINE_ANCHOR_PATTERN,F as SEARCH_HIGHLIGHT_CLOSE,E as SEARCH_HIGHLIGHT_OPEN,o as TextAnchor,r as attachTextAnchorRenderer,v as createTextContentConverter,g as createTextDocument,q as documentLineAnchors,D as endsWithNoFinalLineBreakMarker,e as getTextAnchorRenderer,a as getTextSourceLine,l as isLineAnchor,t as isTextAnchorRecoveryOutcome,p as isTextAnchorResolutionAttempt,m as isTextAnchorResolver,c as isTextLinePresenter,d as isTextPresenterRegistration,z as isTextTargetResolutionAttempt,w as isTextualMediaType,n as lineAnchors,u as linesWithAnchor,i as renderPresentedTextDocument,x as renderPresentedTextRows,f as renderTextAnchor,h as renderTextDocument,B as restoreText,A as storeText,G as stripSearchHighlights,y as textFromAgentContent,s as textLineAnchors,b as withTextSourceLine};
package/dist/entry-22.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-IQD6PON5.js";import{m as q}from"./chunk-QGXZ4RWX.js";import{a as p}from"./chunk-YZTVC7ME.js";import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-VDSSAP6Y.js";import"./chunk-SIYPD5MM.js";import"./chunk-S7E2D5K7.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{d as TEXT_EDITOR_API_VERSION,g as TEXT_EDITOR_CORE_READY_EVENT,h as TEXT_EDITOR_PLUGIN_REGISTER_EVENT,c as TEXT_EDITOR_PROTOCOL,e as TEXT_POSITION_ANCHOR_KIND,f as TEXT_SEARCH_ANCHOR_KIND,p as connectTextEditorPlugin,q as connectTextEditorPostEditHandler,j as isResourceResolverRegistration,k as isTextAnchorResolverRegistration,l as isTextAnchorResourceResolutionAttempt,m as isTextEditorCoreReady,n as isTextEditorPlugin,o as isTextEditorPluginRegistrationRequest,i as isTextEditorToolId,b as localFileTransferAccess,a as snapshotLocalObjects};
1
+ import"./chunk-IQD6PON5.js";import{m as r}from"./chunk-QCAGAJHJ.js";import{a as q}from"./chunk-JY63UUC2.js";import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-XEPCURYZ.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import"./chunk-IRLWXPL4.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{e as TEXT_EDITOR_API_VERSION,h as TEXT_EDITOR_CORE_READY_EVENT,i as TEXT_EDITOR_PLUGIN_REGISTER_EVENT,d as TEXT_EDITOR_PROTOCOL,f as TEXT_POSITION_ANCHOR_KIND,g as TEXT_SEARCH_ANCHOR_KIND,q as connectTextEditorPlugin,r as connectTextEditorPostEditHandler,k as isResourceResolverRegistration,l as isTextAnchorResolverRegistration,m as isTextAnchorResourceResolutionAttempt,n as isTextEditorCoreReady,o as isTextEditorPlugin,p as isTextEditorPluginRegistrationRequest,j as isTextEditorToolId,c as localFileTransferAccess,a as localObjectMode,b as snapshotLocalObjects};