pi-agent-ide 0.9.4 → 0.9.6

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 (776) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +1 -1
  3. package/dist/{chunk-ZXO4D5UB.js → chunk-2AANEKFS.js} +1 -1
  4. package/dist/{chunk-BU7IZLKB.js → chunk-2DSY4U73.js} +1 -1
  5. package/dist/chunk-2YO6RVX4.js +1 -0
  6. package/dist/{chunk-WES2E4VR.js → chunk-33U3RUM3.js} +1 -1
  7. package/dist/{chunk-CJPS4GXD.js → chunk-34IYWKY5.js} +1 -1
  8. package/dist/{chunk-2TTSJOLO.js → chunk-4CSNQX54.js} +1 -1
  9. package/dist/{chunk-DAZQSXUW.js → chunk-53IV6EKV.js} +1 -1
  10. package/dist/{chunk-7PVDTMEM.js → chunk-5AROEOJB.js} +1 -1
  11. package/dist/{chunk-IG5DXVDJ.js → chunk-5D4C225L.js} +1 -1
  12. package/dist/{chunk-GHO6TCPJ.js → chunk-5DN2XBVI.js} +1 -1
  13. package/dist/{chunk-FHRHYY4M.js → chunk-5W6QQZFI.js} +1 -1
  14. package/dist/{chunk-5PC5INOL.js → chunk-6W4OJLCJ.js} +1 -1
  15. package/dist/chunk-6ZYCTWQE.js +1 -0
  16. package/dist/{chunk-B25LXXNV.js → chunk-72FL5FHZ.js} +1 -1
  17. package/dist/{chunk-BB4A5UI3.js → chunk-7JWZPJI5.js} +1 -1
  18. package/dist/{chunk-T3Z4KXOX.js → chunk-AMSNDWBT.js} +1 -1
  19. package/dist/{chunk-DFXXT6MJ.js → chunk-APWMLLSE.js} +6 -6
  20. package/dist/{chunk-NA2NEU4V.js → chunk-B5UJCNQU.js} +1 -1
  21. package/dist/chunk-BMSAVDRD.js +13 -0
  22. package/dist/{chunk-MPNE25CY.js → chunk-BRJIXNFU.js} +1 -1
  23. package/dist/chunk-C2GZLLSP.js +5 -0
  24. package/dist/{chunk-XCPIIDFS.js → chunk-DHOIQZUF.js} +1 -1
  25. package/dist/chunk-ECSMTGVM.js +6 -0
  26. package/dist/{chunk-DEP55R35.js → chunk-EHFWODRT.js} +1 -1
  27. package/dist/{chunk-6WCHBHFW.js → chunk-EWTVVPUA.js} +1 -1
  28. package/dist/{chunk-H3GEEOOL.js → chunk-FBR7ZLLN.js} +1 -1
  29. package/dist/{chunk-UD3DMY3Q.js → chunk-FGN2ZMEN.js} +1 -1
  30. package/dist/{chunk-MKDOT76B.js → chunk-FJSYWOE6.js} +1 -1
  31. package/dist/{chunk-LF325WYO.js → chunk-FTECKRK6.js} +1 -1
  32. package/dist/chunk-GRZTKMXQ.js +1 -0
  33. package/dist/chunk-H6FEBUAP.js +1 -0
  34. package/dist/{chunk-FYOU4RBH.js → chunk-HFCHOFLV.js} +1 -1
  35. package/dist/chunk-HFF4GY7R.js +3 -0
  36. package/dist/{chunk-QJ6V5IAY.js → chunk-HJXSEPO7.js} +14 -12
  37. package/dist/{chunk-SRFWT562.js → chunk-HSEDKYH4.js} +1 -1
  38. package/dist/{chunk-6P7LTQZT.js → chunk-II7AOJNH.js} +1 -1
  39. package/dist/chunk-J6CDIH3S.js +84 -0
  40. package/dist/{chunk-USG6WHAT.js → chunk-JHWLRL4U.js} +1 -1
  41. package/dist/{chunk-35LZOKEW.js → chunk-JMQ67UNK.js} +1 -1
  42. package/dist/{chunk-7OUML24Z.js → chunk-JRIP33PC.js} +1 -1
  43. package/dist/chunk-JXULBI4S.js +2 -0
  44. package/dist/chunk-JYITLCXC.js +1 -0
  45. package/dist/{chunk-4IWEKRSP.js → chunk-KJAR2WDO.js} +1 -1
  46. package/dist/{chunk-GS5ZRTUG.js → chunk-KQV2ZXLP.js} +1 -1
  47. package/dist/{chunk-AMIIOWFL.js → chunk-KX7MG72M.js} +1 -1
  48. package/dist/{chunk-HGCJDIRR.js → chunk-LIGOOMJS.js} +5 -5
  49. package/dist/{chunk-OMNKD7WW.js → chunk-LY2UANKU.js} +3 -3
  50. package/dist/chunk-M7P7V4WI.js +25 -0
  51. package/dist/chunk-N2NEFXHB.js +13 -0
  52. package/dist/{chunk-2TZDG2JH.js → chunk-NF74ITWT.js} +2 -2
  53. package/dist/{chunk-AP2BOC24.js → chunk-NQYUIQRH.js} +1 -1
  54. package/dist/{chunk-7C73WVPB.js → chunk-OCU6NW5Y.js} +1 -1
  55. package/dist/chunk-OIEA4QWF.js +4 -0
  56. package/dist/{chunk-FXPY3V4L.js → chunk-ON5HDFNL.js} +1 -1
  57. package/dist/{chunk-U2N73BUY.js → chunk-P43GGKUC.js} +5 -5
  58. package/dist/{chunk-5BGWNYQS.js → chunk-P7FUD4WY.js} +1 -1
  59. package/dist/{chunk-VMLPXSMK.js → chunk-PPCWY4BB.js} +1 -1
  60. package/dist/{chunk-YPYROPQF.js → chunk-QGXZ4RWX.js} +1 -1
  61. package/dist/chunk-S3T5NOSL.js +1 -0
  62. package/dist/chunk-S7E2D5K7.js +5 -0
  63. package/dist/{chunk-DDH3FP4G.js → chunk-SIYPD5MM.js} +3 -3
  64. package/dist/{chunk-6A3ORNW3.js → chunk-T5ACAOKJ.js} +3 -3
  65. package/dist/chunk-TILMPAF2.js +1 -0
  66. package/dist/{chunk-RIJRPAL2.js → chunk-TSNY2FSU.js} +1 -1
  67. package/dist/{chunk-UI4KSKS3.js → chunk-TWJINFQB.js} +4 -4
  68. package/dist/chunk-TWQ6ACOI.js +1 -0
  69. package/dist/chunk-UDVVKVG4.js +1 -0
  70. package/dist/{chunk-WQIMM4SU.js → chunk-V2D5MLGE.js} +1 -1
  71. package/dist/{chunk-PQWANILR.js → chunk-VDSSAP6Y.js} +1 -1
  72. package/dist/{chunk-AVJVTF5H.js → chunk-VHYJTAXX.js} +1 -1
  73. package/dist/{chunk-MJFY4RGT.js → chunk-WCSWQDJ2.js} +1 -1
  74. package/dist/{chunk-JWSJCEIB.js → chunk-WQTF6Q2X.js} +1 -1
  75. package/dist/chunk-YFPU2LRR.js +23 -0
  76. package/dist/{chunk-KWJD7FBS.js → chunk-YLEERRX3.js} +14 -14
  77. package/dist/chunk-YNOR4LIE.js +1 -0
  78. package/dist/{chunk-WEE3NM6L.js → chunk-YOJHCARZ.js} +1 -1
  79. package/dist/chunk-YPTDPMK5.js +1 -0
  80. package/dist/{chunk-GXL4NMHR.js → chunk-YZTVC7ME.js} +1 -1
  81. package/dist/entry-0.js +1 -1
  82. package/dist/entry-10.js +1 -1
  83. package/dist/entry-11.js +1 -1
  84. package/dist/entry-12.js +1 -1
  85. package/dist/entry-14.js +1 -1
  86. package/dist/entry-15.js +1 -1
  87. package/dist/entry-17.js +1 -1
  88. package/dist/entry-19.js +1 -1
  89. package/dist/entry-2.js +1 -1
  90. package/dist/entry-20.js +1 -1
  91. package/dist/entry-21.js +1 -1
  92. package/dist/entry-22.js +1 -1
  93. package/dist/entry-25.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 +13 -13
  102. package/dist/entry-39.js +1 -1
  103. package/dist/entry-4.js +1 -1
  104. package/dist/entry-40.js +1 -1
  105. package/dist/entry-41.js +1 -1
  106. package/dist/entry-42.js +1 -1
  107. package/dist/entry-43.js +1 -1
  108. package/dist/entry-44.js +1 -1
  109. package/dist/entry-48.js +1 -1
  110. package/dist/entry-49.js +1 -1
  111. package/dist/entry-50.js +1 -1
  112. package/dist/entry-51.js +1 -1
  113. package/dist/entry-52.js +1 -1
  114. package/dist/entry-53.js +1 -1
  115. package/dist/entry-56.js +1 -1
  116. package/dist/entry-57.js +1 -1
  117. package/dist/entry-58.js +1 -1
  118. package/dist/entry-59.js +1 -1
  119. package/dist/entry-60.js +1 -1
  120. package/dist/entry-61.js +1 -1
  121. package/dist/entry-62.js +1 -1
  122. package/dist/entry-63.js +1 -1
  123. package/dist/entry-64.js +1 -1
  124. package/dist/entry-65.js +1 -1
  125. package/dist/entry-66.js +1 -1
  126. package/dist/entry-67.js +1 -1
  127. package/dist/entry-69.js +1 -1
  128. package/dist/entry-72.js +1 -1
  129. package/dist/entry-74.js +1 -1
  130. package/dist/entry-75.js +1 -1
  131. package/dist/entry-77.js +1 -1
  132. package/dist/entry-79.js +1 -1
  133. package/dist/entry-8.js +1 -1
  134. package/dist/entry-82.js +1 -1
  135. package/dist/entry-84.js +1 -1
  136. package/dist/entry-85.js +1 -1
  137. package/dist/entry-86.js +1 -1
  138. package/dist/entry-87.js +1 -1
  139. package/dist/entry-90.js +1 -1
  140. package/dist/entry-91.js +1 -1
  141. package/dist/entry-92.js +1 -1
  142. package/dist/entry-93.js +1 -1
  143. package/dist/entry-94.js +1 -1
  144. package/dist/pi-agent-ide.js +11 -11
  145. package/docs/development.md +2 -0
  146. package/docs/generated/tool-catalog/python.md +1 -0
  147. package/docs/tools.md +2 -0
  148. package/node_modules/pi-agent-doctor/package.json +1 -1
  149. package/node_modules/pi-agent-doctor/src/connect-plugin.ts +2 -2
  150. package/node_modules/pi-agent-doctor/src/evidence.ts +1 -1
  151. package/node_modules/pi-agent-doctor/src/fixtures/executable-probe.ts +2 -2
  152. package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +4 -4
  153. package/node_modules/pi-agent-doctor/src/project-probes.ts +2 -2
  154. package/node_modules/pi-agent-doctor/src/workspace.ts +2 -2
  155. package/node_modules/pi-agent-documentation/package.json +1 -1
  156. package/node_modules/pi-agent-filesystem/index.ts +2 -2
  157. package/node_modules/pi-agent-filesystem/package.json +7 -7
  158. package/node_modules/pi-agent-filesystem/src/file-write-lock.ts +70 -0
  159. package/node_modules/pi-agent-filesystem/src/replace-file.ts +50 -0
  160. package/node_modules/pi-agent-filesystem/src/resolver.ts +28 -8
  161. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  162. package/node_modules/pi-agent-filesystem-jq/index.ts +1 -1
  163. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  164. package/node_modules/pi-agent-filesystem-jq/src/api/jq.ts +1 -1
  165. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  166. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  167. package/node_modules/pi-agent-ide-ast/index.ts +1 -1
  168. package/node_modules/pi-agent-ide-ast/package.json +13 -13
  169. package/node_modules/pi-agent-ide-ast/src/api/scope.ts +1 -1
  170. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +33 -11
  171. package/node_modules/pi-agent-ide-ast/src/ast/native-parser.ts +1 -1
  172. package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +60 -55
  173. package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +4 -3
  174. package/node_modules/pi-agent-ide-ast/src/extension.ts +10 -10
  175. package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +3 -3
  176. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +1 -1
  177. package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +35 -8
  178. package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
  179. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +161 -23
  180. package/node_modules/pi-agent-ide-ast/src/tool-ast-search.ts +1 -1
  181. package/node_modules/pi-agent-ide-changes/index.ts +9 -9
  182. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  183. package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +4 -4
  184. package/node_modules/pi-agent-ide-changes/src/changes/change-groups.ts +1 -1
  185. package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +4 -4
  186. package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +1 -1
  187. package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +4 -4
  188. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +5 -5
  189. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +6 -6
  190. package/node_modules/pi-agent-ide-formatter/index.ts +5 -5
  191. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  192. package/node_modules/pi-agent-ide-formatter/src/doctor-plugin.ts +2 -2
  193. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +2 -2
  194. package/node_modules/pi-agent-ide-formatter/src/registry.ts +1 -1
  195. package/node_modules/pi-agent-ide-languages/index.ts +1 -1
  196. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  197. package/node_modules/pi-agent-ide-lint/index.ts +9 -9
  198. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  199. package/node_modules/pi-agent-ide-lint/src/catalog.ts +4 -0
  200. package/node_modules/pi-agent-ide-lint/src/command-linter.ts +15 -6
  201. package/node_modules/pi-agent-ide-lint/src/diagnostics.ts +8 -14
  202. package/node_modules/pi-agent-ide-lint/src/doctor-plugin.ts +3 -3
  203. package/node_modules/pi-agent-ide-lint/src/registry.ts +1 -1
  204. package/node_modules/pi-agent-ide-lsp/index.ts +37 -16
  205. package/node_modules/pi-agent-ide-lsp/package.json +12 -12
  206. package/node_modules/pi-agent-ide-lsp/src/catalog.ts +12 -1
  207. package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +21 -14
  208. package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +63 -20
  209. package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +4 -4
  210. package/node_modules/pi-agent-ide-lsp/src/idle-timeout.ts +15 -0
  211. package/node_modules/pi-agent-ide-lsp/src/lsp/abort.ts +11 -0
  212. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +434 -80
  213. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +121 -35
  214. package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +1 -1
  215. package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +26 -12
  216. package/node_modules/pi-agent-ide-lsp/src/lsp/document-leases.ts +31 -0
  217. package/node_modules/pi-agent-ide-lsp/src/lsp/errors.ts +4 -0
  218. package/node_modules/pi-agent-ide-lsp/src/lsp/file-watchers.ts +1 -77
  219. package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +19 -19
  220. package/node_modules/pi-agent-ide-lsp/src/lsp/language-map.ts +1 -1
  221. package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +5 -4
  222. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +59 -28
  223. package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +42 -22
  224. package/node_modules/pi-agent-ide-lsp/src/lsp/owner-transport.ts +1 -1
  225. package/node_modules/pi-agent-ide-lsp/src/lsp/position-map.ts +52 -0
  226. package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +1 -1
  227. package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +2 -2
  228. package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +2 -2
  229. package/node_modules/pi-agent-ide-lsp/src/lsp/server-request-handlers.mjs +325 -0
  230. package/node_modules/pi-agent-ide-lsp/src/lsp/shared-server-host.mjs +797 -0
  231. package/node_modules/pi-agent-ide-lsp/src/lsp/shared-servers.ts +322 -0
  232. package/node_modules/pi-agent-ide-lsp/src/lsp/source-changes.ts +29 -0
  233. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +76 -17
  234. package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +3 -3
  235. package/node_modules/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +1 -1
  236. package/node_modules/pi-agent-ide-lsp/src/manager-provider.ts +1 -1
  237. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +16 -8
  238. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +149 -134
  239. package/node_modules/pi-agent-ide-lsp/src/tool-lsp-search.ts +1 -1
  240. package/node_modules/pi-agent-image/package.json +2 -2
  241. package/node_modules/pi-agent-image/src/index.ts +1 -1
  242. package/node_modules/pi-agent-invariant/package.json +1 -1
  243. package/node_modules/pi-agent-pdf/package.json +2 -2
  244. package/node_modules/pi-agent-pdf/src/index.ts +1 -1
  245. package/node_modules/pi-agent-read/index.ts +1 -1
  246. package/node_modules/pi-agent-read/package.json +7 -7
  247. package/node_modules/pi-agent-read/src/api/connect-plugin.ts +1 -1
  248. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  249. package/node_modules/pi-agent-read/src/api/read-parameters.ts +1 -1
  250. package/node_modules/pi-agent-read/src/api/rendering.ts +2 -2
  251. package/node_modules/pi-agent-read/src/api/tools/read.ts +8 -2
  252. package/node_modules/pi-agent-read/src/core/extension.ts +4 -4
  253. package/node_modules/pi-agent-read/src/core/read-core.ts +4 -4
  254. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +2 -2
  255. package/node_modules/pi-agent-read/src/core/tools/read/persisted-result.ts +1 -1
  256. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +3 -3
  257. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +4 -4
  258. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +21 -14
  259. package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +24 -18
  260. package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +2 -2
  261. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +44 -18
  262. package/node_modules/pi-agent-resource/package.json +1 -1
  263. package/node_modules/pi-agent-resource/src/content-conversion/connect-plugin.ts +4 -4
  264. package/node_modules/pi-agent-resource/src/content-conversion/content-converter.ts +1 -1
  265. package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +1 -1
  266. package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +4 -4
  267. package/node_modules/pi-agent-resource/src/content-conversion/content-runner.ts +3 -3
  268. package/node_modules/pi-agent-resource/src/content-conversion/plugin-protocol.ts +2 -2
  269. package/node_modules/pi-agent-resource/src/content-conversion/validation.ts +2 -2
  270. package/node_modules/pi-agent-resource/src/index.ts +19 -19
  271. package/node_modules/pi-agent-resource/src/resolver.ts +1 -1
  272. package/node_modules/pi-agent-resource/src/resource-access.ts +1 -1
  273. package/node_modules/pi-agent-resource/src/resource-error.ts +1 -1
  274. package/node_modules/pi-agent-resource/src/resource.ts +1 -1
  275. package/node_modules/pi-agent-resource/src/result-images.ts +1 -1
  276. package/node_modules/pi-agent-resource/src/result-targets.ts +23 -2
  277. package/node_modules/pi-agent-resource/src/temp-resource-store.ts +2 -2
  278. package/node_modules/pi-agent-resource/src/tool-result.ts +2 -2
  279. package/node_modules/pi-agent-resource/src/validation.ts +3 -3
  280. package/node_modules/pi-agent-search/index.ts +1 -1
  281. package/node_modules/pi-agent-search/package.json +5 -5
  282. package/node_modules/pi-agent-search/src/api/connect-plugin.ts +1 -1
  283. package/node_modules/pi-agent-search/src/api/fuzzy.ts +2 -2
  284. package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  285. package/node_modules/pi-agent-search/src/api/presentation.ts +1 -1
  286. package/node_modules/pi-agent-search/src/api/search-scope.ts +1 -1
  287. package/node_modules/pi-agent-search/src/api/search.ts +7 -7
  288. package/node_modules/pi-agent-search/src/core/extension.ts +7 -7
  289. package/node_modules/pi-agent-search/src/core/search-core.ts +3 -3
  290. package/node_modules/pi-agent-search-text/index.ts +8 -8
  291. package/node_modules/pi-agent-search-text/package.json +10 -10
  292. package/node_modules/pi-agent-search-text/src/doctor-plugin.ts +1 -1
  293. package/node_modules/pi-agent-search-text/src/file-search.ts +1 -1
  294. package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +2 -2
  295. package/node_modules/pi-agent-search-text/src/persisted-result.ts +1 -1
  296. package/node_modules/pi-agent-search-text/src/resolvers.ts +9 -9
  297. package/node_modules/pi-agent-search-text/src/scoped-search.ts +4 -4
  298. package/node_modules/pi-agent-search-text/src/search-backend.ts +3 -3
  299. package/node_modules/pi-agent-search-text/src/search-presentation.ts +1 -1
  300. package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -2
  301. package/node_modules/pi-agent-search-text/src/search-renderer.ts +3 -3
  302. package/node_modules/pi-agent-search-text/src/search-result.ts +2 -2
  303. package/node_modules/pi-agent-search-text/src/search-session.ts +132 -67
  304. package/node_modules/pi-agent-search-text/src/tool-file-search.ts +1 -1
  305. package/node_modules/pi-agent-text/package.json +2 -2
  306. package/node_modules/pi-agent-text/src/index.ts +7 -7
  307. package/node_modules/pi-agent-text/src/source-line.ts +1 -1
  308. package/node_modules/pi-agent-text/src/text-document.ts +50 -2
  309. package/node_modules/pi-agent-text-anchor-constant/index.ts +1 -1
  310. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  311. package/node_modules/pi-agent-text-anchor-exact/index.ts +2 -2
  312. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  313. package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +63 -48
  314. package/node_modules/pi-agent-text-anchor-exact/src/recovery.ts +3 -3
  315. package/node_modules/pi-agent-text-anchor-line-hash/index.ts +2 -2
  316. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  317. package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +23 -12
  318. package/node_modules/pi-agent-text-editor/index.ts +5 -5
  319. package/node_modules/pi-agent-text-editor/package.json +9 -9
  320. package/node_modules/pi-agent-text-editor/src/api/connect-plugin.ts +1 -1
  321. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +2 -2
  322. package/node_modules/pi-agent-text-editor/src/api/file-operations.ts +2 -2
  323. package/node_modules/pi-agent-text-editor/src/api/file-transfers.ts +1 -1
  324. package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +4 -4
  325. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -3
  326. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +2 -2
  327. package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +1 -1
  328. package/node_modules/pi-agent-text-editor/src/api/native-files.ts +1 -1
  329. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +14 -14
  330. package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +3 -3
  331. package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -1
  332. package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +2 -2
  333. package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +3 -3
  334. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +3 -3
  335. package/node_modules/pi-agent-text-editor/src/core/extension.ts +13 -13
  336. package/node_modules/pi-agent-text-editor/src/core/file-operation-guards.ts +2 -2
  337. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +6 -6
  338. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +5 -5
  339. package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +1 -1
  340. package/node_modules/pi-agent-text-editor/src/core/file-transfers.ts +3 -3
  341. package/node_modules/pi-agent-text-editor/src/core/image-write.ts +1 -1
  342. package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +11 -6
  343. package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +213 -20
  344. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +4 -4
  345. package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +39 -3
  346. package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +1 -1
  347. package/node_modules/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +1 -1
  348. package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +6 -6
  349. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +22 -22
  350. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +1 -1
  351. package/node_modules/pi-agent-text-editor/src/core/read-fragment-resolver.ts +3 -3
  352. package/node_modules/pi-agent-text-editor/src/core/result-input.ts +1 -1
  353. package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +2 -2
  354. package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +4 -4
  355. package/node_modules/pi-agent-text-editor/src/core/source-change-retry.ts +41 -0
  356. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +2 -2
  357. package/node_modules/pi-agent-text-editor/src/core/temporary-directories.ts +2 -2
  358. package/node_modules/pi-agent-text-editor/src/core/text-anchor-recovery.ts +1 -1
  359. package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +3 -3
  360. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +4 -7
  361. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +2 -2
  362. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +2 -2
  363. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +34 -21
  364. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -4
  365. package/node_modules/pi-agent-text-editor/src/core/text-edit-origin.ts +1 -1
  366. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +72 -30
  367. package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +1 -1
  368. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +211 -159
  369. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +4 -4
  370. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +1 -1
  371. package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +3 -3
  372. package/node_modules/pi-agent-text-editor/src/tools/extension.ts +7 -7
  373. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +2 -2
  374. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +4 -4
  375. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +4 -4
  376. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +3 -3
  377. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +5 -5
  378. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +4 -4
  379. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +1 -1
  380. package/node_modules/pi-agent-text-editor-renderer/index.ts +5 -5
  381. package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
  382. package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +3 -3
  383. package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +1 -1
  384. package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +2 -2
  385. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +4 -4
  386. package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +2 -2
  387. package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +3 -3
  388. package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +2 -2
  389. package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +1 -1
  390. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +7 -7
  391. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  392. package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
  393. package/node_modules/pi-agent-tool-call-interception/src/index.ts +32 -9
  394. package/node_modules/pi-agent-tool-ui/package.json +1 -1
  395. package/node_modules/pi-agent-tool-ui/src/index.ts +1 -1
  396. package/node_modules/pi-agent-tool-ui/src/result-panel.ts +1 -1
  397. package/node_modules/pi-agent-web/index.ts +3 -3
  398. package/node_modules/pi-agent-web/package.json +7 -7
  399. package/node_modules/pi-agent-web/src/doctor-plugin.ts +1 -1
  400. package/node_modules/pi-agent-web/src/resolver.ts +1 -1
  401. package/node_modules/pi-agent-web-html/index.ts +1 -1
  402. package/node_modules/pi-agent-web-html/package.json +2 -2
  403. package/node_modules/pi-agent-web-html/src/html-converter.ts +1 -1
  404. package/node_modules/pi-agent-web-image/package.json +3 -3
  405. package/node_modules/pi-agent-web-pdf/package.json +3 -3
  406. package/node_modules/pi-agent-web-text/package.json +3 -3
  407. package/package.json +36 -36
  408. package/src/api/code-view.ts +3 -3
  409. package/src/api/connect-plugin.ts +1 -1
  410. package/src/api/connect-tip-provider.ts +2 -2
  411. package/src/api/doctor-runtime.ts +1 -1
  412. package/src/api/doctor.ts +1 -1
  413. package/src/api/hooks.ts +2 -2
  414. package/src/api/plugin-protocol.ts +1 -1
  415. package/src/api/settings.ts +6 -1
  416. package/src/api/standalone.ts +1 -1
  417. package/src/api/tips.ts +1 -1
  418. package/src/api/tool-config/linters.json +1 -1
  419. package/src/api/tool-config/lsp-servers.json +11 -0
  420. package/src/api/tool-config.ts +45 -5
  421. package/src/api/toolchain.ts +3 -3
  422. package/src/backend/config.ts +2 -2
  423. package/src/backend/configured-process.ts +5 -5
  424. package/src/backend/dap-java-transport.ts +6 -6
  425. package/src/backend/dap-node-transport.ts +5 -5
  426. package/src/backend/dap-tcp-transport.ts +3 -3
  427. package/src/backend/dap-transport.ts +5 -5
  428. package/src/backend/debugger-registration.ts +7 -7
  429. package/src/backend/debugger-workspace-owner.ts +10 -10
  430. package/src/backend/doctor-registration.ts +5 -5
  431. package/src/backend/doctor-workspace.ts +13 -13
  432. package/src/backend/file-operation-resolver.ts +5 -5
  433. package/src/backend/file-revision.ts +1 -1
  434. package/src/backend/file-transfer.ts +4 -4
  435. package/src/backend/formatter-registration.ts +11 -11
  436. package/src/backend/git-registration.ts +4 -4
  437. package/src/backend/index.ts +3 -3
  438. package/src/backend/lint-registration.ts +11 -11
  439. package/src/backend/lsp-file-watchers.ts +5 -5
  440. package/src/backend/lsp-registration.ts +11 -11
  441. package/src/backend/lsp-transport.ts +7 -7
  442. package/src/backend/lsp-workspace-owner.ts +4 -4
  443. package/src/backend/object-transfer.ts +5 -5
  444. package/src/backend/owned-command.ts +2 -2
  445. package/src/backend/owned-process-stop.ts +4 -4
  446. package/src/backend/owned-read-command.ts +2 -2
  447. package/src/backend/process-environment.ts +2 -2
  448. package/src/backend/process-metadata.ts +2 -2
  449. package/src/backend/recipe-evidence.ts +2 -2
  450. package/src/backend/registration.ts +8 -8
  451. package/src/backend/registry.ts +2 -2
  452. package/src/backend/resource-resolver.ts +2 -2
  453. package/src/backend/search-environment.ts +3 -3
  454. package/src/backend/ssh-channel.ts +3 -3
  455. package/src/backend/ssh-transport.ts +2 -2
  456. package/src/backend/ssh.ts +6 -6
  457. package/src/backend/tool-config-access.ts +4 -4
  458. package/src/backend/tool-project.ts +5 -5
  459. package/src/backend/web-browser.ts +3 -3
  460. package/src/backend/web-http.ts +2 -2
  461. package/src/backend/web-owner.ts +5 -5
  462. package/src/backend/web-registration.ts +5 -5
  463. package/src/code-review/extension.ts +3 -3
  464. package/src/code-review/reviewer.ts +2 -2
  465. package/src/code-view/diagnostic-view.ts +4 -4
  466. package/src/composite/builtin-extensions.ts +37 -37
  467. package/src/composite/capabilities.ts +2 -2
  468. package/src/composite/capability-schemas.ts +1 -1
  469. package/src/composite/detached-results.ts +32 -0
  470. package/src/composite/extensions-config.ts +2 -2
  471. package/src/composite/module-settings-store.ts +2 -2
  472. package/src/composite/module-settings.ts +12 -12
  473. package/src/composite/nested-tool-rendering.ts +3 -3
  474. package/src/composite/output-limits.ts +6 -1
  475. package/src/composite/preferences.ts +10 -0
  476. package/src/composite/presets.ts +1 -1
  477. package/src/composite/reload-required.ts +6 -6
  478. package/src/composite/settings-documentation.ts +5 -5
  479. package/src/composite/settings-registry.ts +4 -4
  480. package/src/composite/text-results.ts +2 -2
  481. package/src/core/diagnostic-entry.ts +2 -2
  482. package/src/core/diagnostic-store.ts +3 -3
  483. package/src/core/extension.ts +8 -8
  484. package/src/core/ide-core.ts +4 -4
  485. package/src/doctor/config-writer.ts +3 -3
  486. package/src/doctor/core.ts +2 -2
  487. package/src/doctor/discovery.ts +4 -4
  488. package/src/doctor/extension.ts +7 -7
  489. package/src/doctor/index.ts +1 -1
  490. package/src/doctor/inventory.ts +1 -1
  491. package/src/doctor/run.ts +6 -6
  492. package/src/doctor/tip-provider.ts +2 -2
  493. package/src/documentation/extension.ts +3 -3
  494. package/src/documentation/registry.ts +1 -1
  495. package/src/documentation/search.ts +1 -1
  496. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +2 -2
  497. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  498. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  499. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +1 -1
  500. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  501. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/api/jq.ts +1 -1
  502. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  503. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  504. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/file-write-lock.ts +70 -0
  505. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/replace-file.ts +50 -0
  506. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +28 -8
  507. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +3 -3
  508. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  509. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/index.ts +1 -1
  510. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
  511. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +1 -1
  512. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
  513. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
  514. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
  515. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/doctor-plugin.ts +1 -1
  516. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +1 -1
  517. package/src/extensions/pi-agent-read/index.ts +1 -1
  518. package/src/extensions/pi-agent-read/package.json +7 -7
  519. package/src/extensions/pi-agent-read/src/api/connect-plugin.ts +1 -1
  520. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  521. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +1 -1
  522. package/src/extensions/pi-agent-read/src/api/rendering.ts +2 -2
  523. package/src/extensions/pi-agent-read/src/api/tools/read.ts +8 -2
  524. package/src/extensions/pi-agent-read/src/core/extension.ts +4 -4
  525. package/src/extensions/pi-agent-read/src/core/read-core.ts +4 -4
  526. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +2 -2
  527. package/src/extensions/pi-agent-read/src/core/tools/read/persisted-result.ts +1 -1
  528. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +3 -3
  529. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +4 -4
  530. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +21 -14
  531. package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +24 -18
  532. package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +2 -2
  533. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +44 -18
  534. package/src/extensions/pi-agent-search/index.ts +1 -1
  535. package/src/extensions/pi-agent-search/package.json +5 -5
  536. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +8 -8
  537. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +10 -10
  538. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/doctor-plugin.ts +1 -1
  539. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +1 -1
  540. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +2 -2
  541. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +1 -1
  542. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +9 -9
  543. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +4 -4
  544. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +3 -3
  545. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +1 -1
  546. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -2
  547. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +3 -3
  548. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +2 -2
  549. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +132 -67
  550. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/tool-file-search.ts +1 -1
  551. package/src/extensions/pi-agent-search/src/api/connect-plugin.ts +1 -1
  552. package/src/extensions/pi-agent-search/src/api/fuzzy.ts +2 -2
  553. package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  554. package/src/extensions/pi-agent-search/src/api/presentation.ts +1 -1
  555. package/src/extensions/pi-agent-search/src/api/search-scope.ts +1 -1
  556. package/src/extensions/pi-agent-search/src/api/search.ts +7 -7
  557. package/src/extensions/pi-agent-search/src/core/extension.ts +7 -7
  558. package/src/extensions/pi-agent-search/src/core/search-core.ts +3 -3
  559. package/src/extensions/pi-agent-text-editor/index.ts +5 -5
  560. package/src/extensions/pi-agent-text-editor/package.json +9 -9
  561. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/index.ts +1 -1
  562. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  563. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +2 -2
  564. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  565. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +63 -48
  566. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/recovery.ts +3 -3
  567. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +2 -2
  568. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  569. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +23 -12
  570. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +5 -5
  571. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
  572. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +3 -3
  573. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +1 -1
  574. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +2 -2
  575. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +4 -4
  576. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +2 -2
  577. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +3 -3
  578. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +2 -2
  579. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +1 -1
  580. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +7 -7
  581. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  582. package/src/extensions/pi-agent-text-editor/src/api/connect-plugin.ts +1 -1
  583. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +2 -2
  584. package/src/extensions/pi-agent-text-editor/src/api/file-operations.ts +2 -2
  585. package/src/extensions/pi-agent-text-editor/src/api/file-transfers.ts +1 -1
  586. package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +4 -4
  587. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -3
  588. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +2 -2
  589. package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +1 -1
  590. package/src/extensions/pi-agent-text-editor/src/api/native-files.ts +1 -1
  591. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +14 -14
  592. package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +3 -3
  593. package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -1
  594. package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +2 -2
  595. package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +3 -3
  596. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +3 -3
  597. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +13 -13
  598. package/src/extensions/pi-agent-text-editor/src/core/file-operation-guards.ts +2 -2
  599. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +6 -6
  600. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +5 -5
  601. package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +1 -1
  602. package/src/extensions/pi-agent-text-editor/src/core/file-transfers.ts +3 -3
  603. package/src/extensions/pi-agent-text-editor/src/core/image-write.ts +1 -1
  604. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +11 -6
  605. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +213 -20
  606. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +4 -4
  607. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +39 -3
  608. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +1 -1
  609. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +1 -1
  610. package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +6 -6
  611. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +22 -22
  612. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +1 -1
  613. package/src/extensions/pi-agent-text-editor/src/core/read-fragment-resolver.ts +3 -3
  614. package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +1 -1
  615. package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +2 -2
  616. package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +4 -4
  617. package/src/extensions/pi-agent-text-editor/src/core/source-change-retry.ts +41 -0
  618. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +2 -2
  619. package/src/extensions/pi-agent-text-editor/src/core/temporary-directories.ts +2 -2
  620. package/src/extensions/pi-agent-text-editor/src/core/text-anchor-recovery.ts +1 -1
  621. package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +3 -3
  622. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +4 -7
  623. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +2 -2
  624. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +2 -2
  625. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +34 -21
  626. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -4
  627. package/src/extensions/pi-agent-text-editor/src/core/text-edit-origin.ts +1 -1
  628. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +72 -30
  629. package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +1 -1
  630. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +211 -159
  631. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +4 -4
  632. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +1 -1
  633. package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +3 -3
  634. package/src/extensions/pi-agent-text-editor/src/tools/extension.ts +7 -7
  635. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +2 -2
  636. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +4 -4
  637. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +4 -4
  638. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +3 -3
  639. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +5 -5
  640. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +4 -4
  641. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +1 -1
  642. package/src/index.ts +1 -1
  643. package/src/pi-agent-ide.ts +22 -20
  644. package/src/plugins/pi-agent-ide-ast/index.ts +1 -1
  645. package/src/plugins/pi-agent-ide-ast/package.json +13 -13
  646. package/src/plugins/pi-agent-ide-ast/src/api/scope.ts +1 -1
  647. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +33 -11
  648. package/src/plugins/pi-agent-ide-ast/src/ast/native-parser.ts +1 -1
  649. package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +60 -55
  650. package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +4 -3
  651. package/src/plugins/pi-agent-ide-ast/src/extension.ts +10 -10
  652. package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +3 -3
  653. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +1 -1
  654. package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +35 -8
  655. package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
  656. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +161 -23
  657. package/src/plugins/pi-agent-ide-ast/src/tool-ast-search.ts +1 -1
  658. package/src/plugins/pi-agent-ide-changes/index.ts +9 -9
  659. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  660. package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +4 -4
  661. package/src/plugins/pi-agent-ide-changes/src/changes/change-groups.ts +1 -1
  662. package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +4 -4
  663. package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +1 -1
  664. package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +4 -4
  665. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +5 -5
  666. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +6 -6
  667. package/src/plugins/pi-agent-ide-debugger/index.ts +21 -13
  668. package/src/plugins/pi-agent-ide-debugger/src/breakpoint-view.ts +1 -1
  669. package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +4 -4
  670. package/src/plugins/pi-agent-ide-debugger/src/java-runtime.ts +2 -2
  671. package/src/plugins/pi-agent-ide-debugger/src/process-provider.ts +3 -3
  672. package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +1 -1
  673. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +5 -5
  674. package/src/plugins/pi-agent-ide-debugger/src/ui.ts +1 -1
  675. package/src/plugins/pi-agent-ide-debugger/src/vscode-backend.ts +1 -1
  676. package/src/plugins/pi-agent-ide-debugger/src/workspace-owner.ts +2 -2
  677. package/src/plugins/pi-agent-ide-diagnostics/index.ts +1 -1
  678. package/src/plugins/pi-agent-ide-formatter/index.ts +5 -5
  679. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  680. package/src/plugins/pi-agent-ide-formatter/src/doctor-plugin.ts +2 -2
  681. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +2 -2
  682. package/src/plugins/pi-agent-ide-formatter/src/registry.ts +1 -1
  683. package/src/plugins/pi-agent-ide-languages/index.ts +1 -1
  684. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  685. package/src/plugins/pi-agent-ide-lint/index.ts +9 -9
  686. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  687. package/src/plugins/pi-agent-ide-lint/src/catalog.ts +4 -0
  688. package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +15 -6
  689. package/src/plugins/pi-agent-ide-lint/src/diagnostics.ts +8 -14
  690. package/src/plugins/pi-agent-ide-lint/src/doctor-plugin.ts +3 -3
  691. package/src/plugins/pi-agent-ide-lint/src/registry.ts +1 -1
  692. package/src/plugins/pi-agent-ide-lsp/index.ts +37 -16
  693. package/src/plugins/pi-agent-ide-lsp/package.json +12 -12
  694. package/src/plugins/pi-agent-ide-lsp/src/catalog.ts +12 -1
  695. package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +21 -14
  696. package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +63 -20
  697. package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +4 -4
  698. package/src/plugins/pi-agent-ide-lsp/src/idle-timeout.ts +15 -0
  699. package/src/plugins/pi-agent-ide-lsp/src/lsp/abort.ts +11 -0
  700. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +434 -80
  701. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +121 -35
  702. package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +1 -1
  703. package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +26 -12
  704. package/src/plugins/pi-agent-ide-lsp/src/lsp/document-leases.ts +31 -0
  705. package/src/plugins/pi-agent-ide-lsp/src/lsp/errors.ts +4 -0
  706. package/src/plugins/pi-agent-ide-lsp/src/lsp/file-watchers.ts +1 -77
  707. package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +19 -19
  708. package/src/plugins/pi-agent-ide-lsp/src/lsp/language-map.ts +1 -1
  709. package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +5 -4
  710. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +59 -28
  711. package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +42 -22
  712. package/src/plugins/pi-agent-ide-lsp/src/lsp/owner-transport.ts +1 -1
  713. package/src/plugins/pi-agent-ide-lsp/src/lsp/position-map.ts +52 -0
  714. package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +1 -1
  715. package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +2 -2
  716. package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +2 -2
  717. package/src/plugins/pi-agent-ide-lsp/src/lsp/server-request-handlers.mjs +325 -0
  718. package/src/plugins/pi-agent-ide-lsp/src/lsp/shared-server-host.mjs +797 -0
  719. package/src/plugins/pi-agent-ide-lsp/src/lsp/shared-servers.ts +322 -0
  720. package/src/plugins/pi-agent-ide-lsp/src/lsp/source-changes.ts +29 -0
  721. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +76 -17
  722. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +3 -3
  723. package/src/plugins/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +1 -1
  724. package/src/plugins/pi-agent-ide-lsp/src/manager-provider.ts +1 -1
  725. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +16 -8
  726. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +149 -134
  727. package/src/plugins/pi-agent-ide-lsp/src/tool-lsp-search.ts +1 -1
  728. package/src/plugins/pi-agent-ide-processes/index.ts +4 -4
  729. package/src/plugins/pi-agent-ide-processes/src/ui.ts +1 -1
  730. package/src/plugins/pi-agent-ide-semantic/src/vera-backend.ts +2 -2
  731. package/src/plugins/pi-agent-ide-terminal/index.ts +17 -17
  732. package/src/plugins/pi-agent-ide-terminal/src/origin.ts +1 -1
  733. package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +1 -1
  734. package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +3 -3
  735. package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +3 -3
  736. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +5 -5
  737. package/src/plugins/pi-agent-ide-terminal/src/screen-image.ts +1 -1
  738. package/src/plugins/pi-agent-ide-terminal/src/search.ts +2 -2
  739. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +3 -3
  740. package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +1 -1
  741. package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +1 -1
  742. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +9 -9
  743. package/src/plugins/pi-agent-ide-terminal/src/types.ts +1 -1
  744. package/src/plugins/pi-agent-ide-terminal/src/ui.ts +3 -3
  745. package/src/post-edit/gate.ts +1 -1
  746. package/src/semantic/extension.ts +2 -2
  747. package/src/semantic/index.ts +4 -4
  748. package/src/standalone/resource-host.ts +13 -13
  749. package/src/standalone/scoped-api.ts +2 -2
  750. package/src/tips/core.ts +1 -1
  751. package/src/tips/extension.ts +6 -6
  752. package/src/tips/setup-hint.ts +1 -1
  753. package/src/toolchain/diagnostic.ts +1 -1
  754. package/src/toolchain/registry.ts +1 -1
  755. package/dist/chunk-2AY526TN.js +0 -3
  756. package/dist/chunk-52PFWQMU.js +0 -5
  757. package/dist/chunk-57F5GTHO.js +0 -1
  758. package/dist/chunk-5S74Z6Y4.js +0 -7
  759. package/dist/chunk-7D7PXIVV.js +0 -1
  760. package/dist/chunk-BT2CFM7D.js +0 -11
  761. package/dist/chunk-C2JT2G5K.js +0 -1
  762. package/dist/chunk-DEWWWKUF.js +0 -6
  763. package/dist/chunk-FEZLTM4L.js +0 -1
  764. package/dist/chunk-G4PRFO6G.js +0 -1
  765. package/dist/chunk-H5Z54BEU.js +0 -25
  766. package/dist/chunk-HISGZD3C.js +0 -81
  767. package/dist/chunk-HRBUY2FF.js +0 -4
  768. package/dist/chunk-ICIRQLZ4.js +0 -23
  769. package/dist/chunk-LIQ4BVOB.js +0 -1
  770. package/dist/chunk-LXDF2NWX.js +0 -1
  771. package/dist/chunk-MDD5ORB6.js +0 -1
  772. package/dist/chunk-OJEIX7OZ.js +0 -1
  773. package/dist/chunk-S5PL5DFQ.js +0 -1
  774. package/dist/chunk-U7YDLVFL.js +0 -1
  775. package/dist/chunk-VDJSH3DQ.js +0 -2
  776. package/dist/chunk-XH5WN5XA.js +0 -2
@@ -0,0 +1,6 @@
1
+ import{a as Z}from"./chunk-K5M65CAF.js";import{a as ee}from"./chunk-P7FUD4WY.js";import{c as J}from"./chunk-HFCHOFLV.js";import{m as k}from"./chunk-S7E2D5K7.js";import{a as w}from"./chunk-ZC65Z3CK.js";import{a as u}from"./chunk-EI7MMDWY.js";import{createHash as me}from"node:crypto";import{open as Be,readFile as Pe}from"node:fs/promises";import x from"node:path";import{spawn as Re}from"node:child_process";import{stat as Ce}from"node:fs/promises";import E from"node:path";import{createInterface as ke}from"node:readline";function z(e,t=!1){let n=O(e);return L(n)?_($(new I(e,n).parse(),t)):t?e:G(e)}u(z,"compileSearchQuery");function Q(e,t=!1){let n=O(e);return L(n)?$(new I(e,n).parse(),t):void 0}u(Q,"compileSearchCondition");function A(e,t){if(e.kind==="term")return t(e.value);let n=A(e.left,t);if(e.kind==="or")return n||A(e.right,t);let r=A(e.right,t);return n&&(e.kind==="not"?!r:r)}u(A,"satisfiesSearchCondition");function ne(e){if(L(O(e)))return;let t=[...new Set(e.trim().split(/\s+/u).filter(Boolean))];return t.length>1?`(?:${t.map(G).join("|")})`:void 0}u(ne,"compileSearchFallbackQuery");function L(e){return e.some(t=>t.quoted===!0||t.type==="and"||t.type==="or"||t.type==="not")}u(L,"containsBooleanSyntax");var I=class{static{u(this,"BooleanQueryParser")}#e;#r;#s=0;constructor(t,n){this.#e=t,this.#r=n}parse(){let t=this.#o(),n=this.#t();if(n.type!=="end"){let r=n.type==="right"?"unexpected ')'.":`unexpected ${Te(n)}.`;throw R(n.offset,r)}return t}#o(){let t=this.#n();for(;this.#t().type==="or";){let n=this.#i(),r=this.#a(`after ${n.value}`);t={kind:"or",left:t,right:this.#c(r)}}return t}#n(){return this.#c(this.#a())}#c(t){let n=t;for(;;){let r=this.#t();if(r.type==="and"||r.type==="not"){this.#i();let o=this.#a(`after ${r.value}`);n={kind:r.type,left:n,right:o};continue}if(r.type==="term"||r.type==="left"){n={kind:"and",left:n,right:this.#a()};continue}return n}}#a(t){let n=this.#t();if(n.type==="term")return this.#i(),{kind:"term",value:n.value,quoted:n.quoted};if(n.type==="left"){if(this.#i(),this.#t().type==="right"||this.#t().type==="end")throw R(this.#t().offset,"expected a term after '('.");let o=this.#o();if(this.#t().type!=="right")throw R(this.#t().offset,"expected ')'.");return this.#i(),o}if(t===void 0&&(n.type==="and"||n.type==="or"||n.type==="not"))throw R(n.offset,`expected a term before ${n.value}.`);let r=t===void 0?"":` ${t}`;throw R(n.offset,`expected a term${r}.`)}#t(){return this.#r[this.#s]??{type:"end",value:"",offset:this.#e.length}}#i(){let t=this.#t();return this.#s+=1,t}};function O(e){let t=[],n=0;for(;n<e.length;){let r=e.charAt(n);if(/\s/u.test(r)){n+=1;continue}if(r==="("&&xe(e,n)){t.push({type:"left",value:r,offset:n}),n+=1;continue}if(r===")"){t.push({type:"right",value:r,offset:n}),n+=1;continue}if(te(e,n)){let i=e.charAt(n+1)==="|"?2:1;t.push({type:"or",value:e.slice(n,n+i),offset:n}),n+=i;continue}if(r==="'"||r==='"'){let i=n,c=r,s="";for(n+=1;n<e.length&&e.charAt(n)!==c;)e.charAt(n)==="\\"&&(e.charAt(n+1)===c||e.charAt(n+1)==="\\")&&(n+=1),s+=e.charAt(n++);if(n>=e.length)throw R(i,`unterminated ${c==="'"?"single":"double"}-quoted term.`);if(n+=1,s.length===0)throw R(i,"quoted terms must not be empty.");t.push({type:"term",value:s,offset:i,quoted:!0});continue}let o=n;for(;n<e.length;){let i=e.charAt(n);if(/\s/u.test(i)||i===")"||te(e,n))break;i==="\\"&&n+1<e.length?n+=2:i==="["||i==="("?n=U(e,n)??n+1:n+=1}let a=e.slice(o,n);t.push({type:we(a),value:a,offset:o})}return t.push({type:"end",value:"",offset:e.length}),t}u(O,"tokenize");function te(e,t){return e.charAt(t)==="|"&&(e.charAt(t+1)==="|"||/\s/u.test(e.charAt(t-1))&&/\s/u.test(e.charAt(t+1)))}u(te,"isBooleanPipe");function U(e,t){let n=e.charAt(t)==="["?"]":")",r=t+1;for(;r<e.length;){let o=e.charAt(r);if(o==="\\")r+=2;else{if(o===n)return r+1;if(n===")"&&(o==="("||o==="[")){let a=U(e,r);if(a===void 0)return;r=a}else r+=1}}}u(U,"regexBlockEnd");function xe(e,t){let n=U(e,t);if(n===void 0)return!0;let r=e.slice(t+1,n-1);return r.trim().length===0?!0:L(O(r))}u(xe,"isBooleanGroup");function we(e){return e==="AND"?"and":e==="OR"?"or":e==="NOT"?"not":"term"}u(we,"operatorType");function Te(e){return e.value.length>0?JSON.stringify(e.value):"the end of the query"}u(Te,"quoteToken");function R(e,t){return new SyntaxError(`Invalid Boolean search query at column ${String(e+1)}: ${t}`)}u(R,"syntaxError");function $(e,t){return e.kind==="term"?{kind:"term",value:t&&!e.quoted?e.value:G(e.value)}:{kind:e.kind,left:$(e.left,t),right:$(e.right,t)}}u($,"compileTerms");function _(e){if(e.kind==="term")return e.value;let t=_(e.left);return e.kind==="not"?t:`(?:${t}|${_(e.right)})`}u(_,"matchPattern");function G(e){return e.replace(/[\\^$.*+?()[\]{}|]/gu,"\\$&")}u(G,"escapeRegex");function ie(e){if(e.multiline===!0){if(e.condition!==void 0)throw new Error("Boolean conditions check single lines and cannot be combined with multiline. Use one regex with multiline instead.");return}if(/\r|\n/u.test(e.query))throw new Error("A pattern with line breaks requires multiline: true.")}u(ie,"assertSupportedPattern");function se(e){return e.multiline===!0?["--multiline","--multiline-dotall"]:[]}u(se,"multilineArguments");async function K(e,t,n,r,o){if(e.query.length===0)throw new Error("Search query must not be empty.");return ie(e),e.condition!==void 0?ae(e,(a,i)=>re(a,t,n,i,void 0,o),n):re(e,t,n,void 0,r,o)}u(K,"searchText");async function ve(e,t,n,r){if(n===void 0&&(e.path?.includes("://")||t.includes("://")))throw new Error("No search environment owns this scope.");let o=n?.resolve(t,oe(e.path??"."))??E.resolve(t,oe(e.path??".")),a=n===void 0?(await Ce(o)).isDirectory():await n.isDirectory(o,r);return{cwd:a?o:n?.dirname(o)??E.dirname(o),target:a?".":`./${n?.basename(o)??E.basename(o)}`,arguments:["--no-config","--no-ignore-parent","--color=never",...J(e.include).flatMap(i=>["--glob",i]),...J(e.exclude).flatMap(i=>["--glob",`!${i}`])]}}u(ve,"ripgrepScope");async function Ae(e,t,n,r){if(ie(e),e.condition!==void 0)return ae(e,async(a,i)=>{let c=await Ae(a,t,n,r);for(let s of c.matches)i?.(s.source,s.lineNumber);return c},r);let o=await j(["--json","--no-config","--color=never","--with-filename","--line-number",...e.regex===!0?["--engine","auto"]:["--fixed-strings"],e.caseSensitive===!0?"--case-sensitive":"--ignore-case",...e.wholeWord===!0?["--word-regexp"]:[],...se(e),"--",e.query,"-"],n,r,void 0,void 0,t.length===0?`
2
+ `:t);return t.length===0?{...o,matches:o.matches.filter(a=>a.lineNumber===1&&a.startColumn===0&&a.endColumn===0)}:o}u(Ae,"searchTextContent");async function re(e,t,n,r,o,a){let i=await ve(e,t,a,n),c=i.cwd,s=["--json","--with-filename","--line-number",e.caseSensitive===!0?"--case-sensitive":"--ignore-case",...e.wholeWord===!0?["--word-regexp"]:[],...se(e),...i.arguments,"--",e.query,i.target];if(e.regex!==!0)return j(["--fixed-strings",...s],c,n,r,o,void 0,a);try{return await j(["--engine","auto",...s],c,n,r,o,void 0,a)}catch(l){if(!Me(l))throw l instanceof Error&&/PCRE2 is not available|does not support PCRE2/iu.test(l.message)?new Error("This regex requires PCRE2. Install ripgrep with PCRE2 support or simplify the regex.",{cause:l}):l;try{return await j(["--engine","default",...s],c,n,r,o,void 0,a)}catch(d){throw n?.aborted?d:new AggregateError([l,d],"Regex exceeded the PCRE2 match limit and cannot run with the default engine. Narrow the search or simplify the regex.",{cause:d})}}}u(re,"searchPattern");async function ae(e,t,n){let r=e.condition;if(r===void 0)throw new Error("Boolean search requires a line condition.");let o=new Set;function a(p){if(p.kind==="term"){o.add(p.value);return}a(p.left),a(p.right)}u(a,"collect"),a(r);let{condition:i,...c}=e,s=new Map,l=u(p=>JSON.stringify([p.source,p.lineNumber]),"lineKey");for(let p of o){n?.throwIfAborted();let f=new Set;await t({...c,query:p,regex:!0,wholeWord:!1},(m,y)=>f.add(JSON.stringify([m,y]))),s.set(p,f)}let d=await t(c),h=new Set,g=d.matches.filter(p=>{let f=l(p);return h.has(f)||!A(r,m=>s.get(m)?.has(f)===!0)?!1:(h.add(f),!0)});return{...d,matches:g}}u(ae,"searchBoolean");function j(e,t,n,r,o,a,i){return i!==void 0?Ee(e,t,i,n,r,o):new Promise((c,s)=>{let l=Re(Z(),e,{stdio:["pipe","pipe","pipe"],cwd:t}),d=0,h=!1;o!==void 0&&l.stdout.on("data",S=>{d+=S.length,d>o.bytes&&(h=!0,l.kill())});let g=ke({input:l.stdout});l.stdin.on("error",()=>{}),l.stdin.end(a);let p=[],f="",m,y=u(()=>{l.kill()},"abort"),T=u(()=>{n?.removeEventListener("abort",y),g.close()},"cleanup");l.stderr.setEncoding("utf8"),l.stderr.on("data",S=>{f+=S}),g.on("line",S=>{if(!(h||m!==void 0||S.length===0))try{let b=JSON.parse(S);if(b.type!=="match")return;if(r!==void 0){let{path:P,line_number:Y}=b.data;P.text!==void 0&&Number.isSafeInteger(Y)&&r(E.resolve(t,P.text),Y);return}for(let P of ce(b,t)){if(o!==void 0&&p.length===o.matches){h=!0,l.kill();break}p.push(P)}}catch(b){m=b,l.kill()}}),l.once("error",S=>{T(),s(S)}),l.once("close",S=>{if(T(),n?.aborted===!0){let b=new Error("Search was aborted.");b.name="AbortError",s(b);return}if(m!==void 0){s(new Error("Unable to parse ripgrep search output.",{cause:m}));return}if(!h&&S!==0&&S!==1){s(new Error(f.trim()||`ripgrep exited with code ${String(S)}.`));return}p.sort(ue),c({matches:p,complete:!h})}),n?.addEventListener("abort",y,{once:!0}),n?.aborted===!0&&y()})}u(j,"runRipgrep");async function Ee(e,t,n,r,o,a){let i=[],c=new AbortController,s=u(()=>c.abort(r?.reason),"abort");r?.addEventListener("abort",s,{once:!0}),r?.aborted&&s();let l=0,d={limited:!1};try{let h=await n.runLines(e,t,g=>{if(d.limited||!g.length)return;if(l+=Buffer.byteLength(g)+1,a!==void 0&&l>a.bytes){d.limited=!0,c.abort();return}let p=JSON.parse(g);if(p.type==="match"){if(o!==void 0){let f=p.data.path.text;f!==void 0&&Number.isSafeInteger(p.data.line_number)&&o(n.resolve(t,f),p.data.line_number);return}for(let f of ce(p,t,n)){if(a!==void 0&&i.length>=a.matches){d.limited=!0,c.abort();break}i.push(f)}}},c.signal);if(h.code!==0&&h.code!==1)throw new Error(h.stderr.trim()||"Ripgrep failed.")}catch(h){if(r?.throwIfAborted(),!d.limited)throw h}finally{r?.removeEventListener("abort",s)}return r?.throwIfAborted(),i.sort(ue),{matches:i,complete:!d.limited}}u(Ee,"runOwnedRipgrep");function Me(e){return e instanceof Error&&/PCRE2: error matching: match limit exceeded/iu.test(e.message)}u(Me,"isPcre2MatchLimitError");function ce(e,t,n){let r=e.data.path.text,o=e.data.lines.text;if(r===void 0||o===void 0||!Number.isSafeInteger(e.data.line_number))return[];let a=o.split(`
3
+ `).map(l=>l.replace(/\r$/u,"")),i=Buffer.from(o),c=u(l=>{let d=i.subarray(0,l).toString("utf8");return{lineIndex:d.split(`
4
+ `).length-1,column:d.length-d.lastIndexOf(`
5
+ `)-1}},"position"),s=[];for(let l of e.data.submatches){if(l.start<0||l.end<l.start||l.end>i.length)continue;let d=c(l.start),h=c(l.end);s.push({source:n?.resolve(t,r)??E.resolve(t,r),lineNumber:e.data.line_number+d.lineIndex,startColumn:d.column,...h.lineIndex===d.lineIndex?{}:{endLineNumber:e.data.line_number+h.lineIndex},endColumn:h.column,matchedText:h.lineIndex===d.lineIndex?(a[d.lineIndex]??"").slice(d.column,h.column):i.subarray(l.start,l.end).toString("utf8"),lineText:a[d.lineIndex]??""})}return s}u(ce,"matchesFromEvent");function oe(e){return e.startsWith("@")?e.slice(1):e}u(oe,"stripFilePrefix");function ue(e,t){return e.source.localeCompare(t.source)||e.lineNumber-t.lineNumber||e.startColumn-t.startColumn||e.endColumn-t.endColumn}u(ue,"compareMatches");function nt(e){let t=z(e.query),n=z(e.query,!0),r=ne(e.query),o=[],a=Q(e.query),i=Q(e.query,!0);return(n!==t||JSON.stringify(a)!==JSON.stringify(i))&&o.push({query:n,mode:"regex",condition:i}),e.multiline!==!0&&r!==void 0&&r!==t&&r!==n&&o.push({query:r,mode:"words"}),{...e,query:t,regex:!0,condition:a,fallbacks:o}}u(nt,"createSearchRecipe");async function V(e,t,n,r){let o=e.query,a=await K(e,t,n,void 0,r),i=[];for(let c of e.fallbacks??[]){if(a.matches.length>0||!a.complete)break;n?.throwIfAborted();try{a=await K({...e,query:c.query,regex:!0,condition:c.condition},t,n,void 0,r),o=c.query,i.push(c.mode==="regex"?"Search fallback: no literal matches; tried unquoted terms as regex.":"Search fallback: no matches in earlier modes; tried separate words. Use these matches as location hints; refine the query before editing.")}catch(s){if(c.mode!=="regex"||!Ne(s)||n?.aborted)throw s;i.push("Search fallback: invalid regex skipped; literal search found no matches.")}}return{...a,query:o,notices:i}}u(V,"runSearchRecipe");function Ne(e){return e instanceof Error&&/regex parse error:|PCRE2: error compiling pattern/iu.test(e.message)}u(Ne,"isRegexSyntaxError");var Ie=/^SEARCH#([A-F0-9]{4,64}):(all|[1-9]\d*):(line|match)$/u,pe=4;function ht(e,t,n,r){return ge(e,t,n,r).slice(0,pe)}u(ht,"createSearchSessionId");function ge(e,t,n,r){let o=n===void 0?We(t.map(s=>s.source)):C(n),a=t.map(s=>({match:s,source:s.source.includes("://")?C(s.source):x.relative(o,x.resolve(s.source))})).sort((s,l)=>s.source.localeCompare(l.source)||X(s.match,l.match)).map(({match:s,source:l})=>[l,s.lineNumber,s.startColumn,s.endLineNumber??s.lineNumber,s.endColumn,s.matchedText,s.lineText]),{limit:i,...c}=Se(r??{query:e,regex:!0},o);return me("sha256").update(JSON.stringify([e,o,c,a])).digest("hex").toUpperCase()}u(ge,"createSearchSessionIdentity");function $e(e,t){if(!/^[A-F0-9]{64}$/u.test(e))throw new Error("Search session identity must be a 64-character uppercase hexadecimal value.");for(let n=pe;n<=e.length;n+=1){let r=e.slice(0,n);if(!t.has(r))return r}throw new Error("Could not allocate a unique search session id.")}u($e,"allocateSearchSessionId");function Se(e,t){return{query:e.query,path:De(t,e.path??"."),include:e.include??"",exclude:e.exclude??"",caseSensitive:e.caseSensitive===!0,wholeWord:e.wholeWord===!0,multiline:e.multiline===!0,limit:e.limit??50,regex:e.regex===!0,condition:e.condition,fallbacks:e.fallbacks??[]}}u(Se,"normalizeRecipe");var D=class extends Error{static{u(this,"SearchSnapshotChangedError")}constructor(t){super(`Search result in ${t} changed before its anchors were registered.`),this.name="SearchSnapshotChangedError"}},le=class{constructor(t=ge,n,r){this.createIdentity=t;this.resultTargets=n;this.readSource=r}static{u(this,"SearchSessionStore")}#e=new Map;#r=new Map;async register(t,n,r,o,a,i={query:t,regex:!0},c,s,l){let d=structuredClone(n).map(S=>({...S,source:C(S.source)})).sort(X),h=this.readSource,g=h===void 0?void 0:(S,b)=>h(S,o,b),p=await he(d,a,s,l,g),f=this.createIdentity(t,d,o,i),y=this.#r.get(f)??$e(f,new Set(this.#e.keys())),T={id:y,query:t,matches:d,complete:r,digestBySource:de(p),read:g,...Le(this.resultTargets,y,d,p,o,r,(S,b)=>W(S,b,l,g)),...s===void 0?{}:{snapshotByteBudget:s},recipe:i,environment:l,...c!==void 0&&{refresh:c},cwd:C(o)};return this.#r.set(f,y),this.#e.set(y,T),T}async registerIfCurrent(t,n,r,o,a,i,c,s,l){try{return await this.register(t,n,r,o,a,i,c,s,l)}catch(d){if(d instanceof D)return;throw d}}async observeAfterEdit(t,n){let r=new Set(t.flatMap(a=>{let i=typeof a=="string"?M(a):void 0;return i===void 0?[]:[i.id]})),o=[];for(let a of r){let i=this.#e.get(a);if(i===void 0)continue;let c={sessionId:a,query:i.recipe.originalQuery??i.query,scope:Se(i.recipe,i.cwd)};try{let s=i.refresh===void 0?await V(i.recipe,i.cwd,n,i.environment):await i.refresh(n);o.push({...c,matches:s.matches.length,complete:s.complete,notices:s.notices})}catch(s){o.push({...c,error:s instanceof Error?s.message:String(s)})}}return o}anchorResolver(){return{id:"search",description:["`SEARCH#HASH:N:line` selects one result's full line; `SEARCH#HASH:N:match` selects its exact match.","`SEARCH#HASH:all:line` selects each unique containing line; `SEARCH#HASH:all:match` selects every exact match.","Omit `path` when `all` spans files."].join(`
6
+ `),renderFull(t){return t},renderCompact(t){let n=M(t);return n===void 0?"selected result":n.selector==="all"?n.mode==="match"?"all matches":"all lines":n.mode==="match"?`match ${String(n.selector)}`:`line ${String(n.selector)}`},tryResolve:u((t,n)=>this.#s(t,n.source,n.signal),"tryResolve")}}async resolveSearchScope(t,n){if(!t.startsWith("SEARCH#"))return;let r=await this.#o(t,n.cwd,n.signal,!0);if(r.kind!=="resolved")throw new Error(r.kind==="rejected"?r.rejection.reason:"Invalid Search reference.");let o=w(M(t)),a=w(this.#e.get(o.id));return{complete:!0,targets:r.targets.map(i=>{if(i.expectedContent===void 0)throw new Error("Search snapshot is unavailable.");return{source:i.source,expectedContent:i.expectedContent,ranges:i.ranges??[],readCurrent:u(async c=>{let s=await H(i.source,c,a.environment,a.read);if(s===void 0)throw new Error("Search source is unavailable.");return s},"readCurrent")}})}}resourceResolver(){return{id:"search-targets",tryResolve:u((t,n)=>this.#o(t,n.cwd),"tryResolve")}}async#s(t,n,r){let o=M(t);if(o===void 0)return{kind:"not-handled"};let a=this.#e.get(o.id);if(a===void 0)return B();if(o.selector==="all"&&!a.complete)return v();let i=C(n),c=a,s;if(o.selector==="all"){if(a.refreshedComplete?.complete===!0)c=a.refreshedComplete;else if(a.refreshedComplete!==void 0&&({snapshot:c,contents:s}=await this.#n(a,r),!c.complete))return v()}let l=N(c,o.selector,"match").find(m=>m.source===i);if(l===void 0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};let d=await H(i,r,a.environment,a.read);if(d===void 0)return B(l.lineNumber);let h=F(d);if(o.selector==="all"&&h!==c.digestBySource.get(i)&&({snapshot:c,contents:s}=await this.#n(a,r),!c.complete))return v();let g=u(m=>s===void 0?m===i?d:void 0:s.get(m),"contentOf"),p=N(c,o.selector,o.mode,g).filter(m=>m.source===i);if(p.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};if(o.selector!=="all"&&h!==a.digestBySource.get(i))return B(w(p[0]).lineNumber);let f=k(i,d);return{kind:"resolved",anchor:new ee(t,i,p.map(m=>q(f,m,o.mode)))}}async#o(t,n,r,o=!1){let a=M(t);if(a===void 0)return{kind:"not-handled"};let i=this.#e.get(a.id);if(i===void 0||i.cwd!==C(n))return B();if(a.selector==="all"&&!i.complete)return v();let c=i,s=new Map;if(a.selector==="all"){if(i.refreshedComplete?.complete===!0)c=i.refreshedComplete;else if(i.refreshedComplete!==void 0&&({snapshot:c}=await this.#n(i,r),!c.complete))return v();let f=new Set(N(c,a.selector,"match").map(m=>m.source));for(let m of f){let y=await H(m,r,i.environment,i.read);if(y===void 0||F(y)!==c.digestBySource.get(m)){let T=await this.#n(i,r);if(c=T.snapshot,s=new Map(T.contents),!c.complete)return v();break}s.set(m,y)}}else{let f=N(c,a.selector,a.mode)[0];if(f!==void 0){let m=await H(f.source,r,i.environment,i.read);if(m===void 0||F(m)!==c.digestBySource.get(f.source))return B(f.lineNumber);s.set(f.source,m)}}let l=N(c,a.selector,a.mode,f=>s.get(f)),d=new Map,h=u(f=>{let m=d.get(f.source);return m===void 0&&(m=k(f.source,s.get(f.source)??f.lineText),d.set(f.source,m)),m},"documentOf"),g=new Map;for(let f of l){let m=g.get(f.source)??[];m.push(q(h(f),f,a.mode)),g.set(f.source,m)}let p=[...g].map(([f,m])=>({source:f,ranges:m,expectedContent:s.get(f)}));return p.length===0&&!(o&&a.selector==="all")?{kind:"rejected",rejection:{code:"missing",reason:"search anchor has no matches"}}:{kind:"resolved",targets:p}}async#n(t,n){let r=t.refresh===void 0?await V(t.recipe,t.cwd,n,t.environment):await t.refresh(n),o=r.matches.map(c=>({...c,source:C(c.source)})).sort(X),a=await he(o,n,t.snapshotByteBudget,t.environment,t.read),i={matches:o,complete:r.complete,digestBySource:de(a)};return this.#e.set(t.id,{...t,refreshedComplete:i}),{snapshot:i,contents:a}}};function Le(e,t,n,r,o,a,i){if(e===void 0)return{};let c=new Map,s=u(d=>{let h=c.get(d);return h===void 0&&(h=k(d,w(r.get(d))),c.set(d,h)),h},"documentOf"),l=n.map(d=>({source:d.source,expectedContent:w(r.get(d.source)),ranges:[be(d)],readCurrent:Oe(i,d.source)}));for(let[d,h]of n.slice(0,100).entries()){let g=e.register([{...w(l[d]),ranges:[q(s(h.source),h,"line")]}],o);e.registerSearchReference(`SEARCH#${t}:${d+1}:line`,g,o)}return{target:e.register(l,o,a),matchTargets:l.slice(0,100).map(d=>e.register([d],o,a))}}u(Le,"registerResultReferences");function M(e){let t=Ie.exec(e);if(t!==null)return{id:w(t[1]),selector:t[2]==="all"?"all":Number(t[2]),mode:t[3]==="line"?"line":"match"}}u(M,"parseSearchAnchor");function Oe(e,t){return n=>e(t,n)}u(Oe,"sourceReader");function F(e){return me("sha256").update(e).digest("hex")}u(F,"digestContent");function de(e){return new Map([...e].map(([t,n])=>[t,F(n)]))}u(de,"digestContents");function N(e,t,n,r=()=>{}){let o=t==="all"?e.matches:[e.matches[t-1]].filter(je);if(n==="match"||t!=="all")return o;let a=new Set,i=new Map;return o.flatMap(c=>{let s=r(c.source),l=s===void 0?void 0:i.get(c.source);l===void 0&&(l=k(c.source,s??c.lineText),s!==void 0&&i.set(c.source,l));let d=ye(c);return l.lines.slice(c.lineNumber-1,d).flatMap(h=>{let g=`${c.source}\0${String(h.lineNumber)}`;return a.has(g)?[]:(a.add(g),[{...c,lineNumber:h.lineNumber,endLineNumber:h.lineNumber,startColumn:0,endColumn:h.content.length,lineText:h.content,matchedText:h.content}])})})}u(N,"selectMatches");function je(e){return e!==void 0}u(je,"isMatch");function ye(e){let t=e.endLineNumber??e.lineNumber;return t>e.lineNumber&&e.endColumn===0?t-1:t}u(ye,"lastContainingLine");function q(e,t,n){if(n==="match")return be(t);let r=ye(t),o=w(e.lines[r-1]);return{start:{lineNumber:t.lineNumber,column:0},end:{lineNumber:r+(o.lineEnding.length>0?1:0),column:o.lineEnding.length>0?0:o.content.length},linewise:!0}}u(q,"selectionRange");function be(e){return{start:{lineNumber:e.lineNumber,column:e.startColumn},end:{lineNumber:e.endLineNumber??e.lineNumber,column:e.endColumn}}}u(be,"matchRange");function He(e,t){let n=t.endLineNumber??t.lineNumber;return e.lines.slice(t.lineNumber-1,n).map(r=>{let o=r.lineNumber===t.lineNumber?t.startColumn:0,a=r.lineNumber===n?t.endColumn:r.content.length;return r.content.slice(o,a)+(r.lineNumber===n?"":r.lineEnding)}).join("")}u(He,"matchedSourceText");async function he(e,t,n,r,o){let a=[...new Set(e.map(s=>s.source))];if(n!==void 0){let s=new Map,l=n;for(let d of a){let h=await Fe(d,l,t,r,o);l-=Buffer.byteLength(h),fe(d,h,e),s.set(d,h)}return s}let i=await Promise.allSettled(a.map(async s=>{let l=await W(s,t,r,o);return fe(s,l,e),[s,l]})),c=new Map;for(let s of i){if(s.status==="rejected")throw s.reason;c.set(...s.value)}return c}u(he,"snapshotContents");function fe(e,t,n){let r=k(e,t);for(let o of n.filter(a=>a.source===e))if(r.lines[o.lineNumber-1]?.content!==o.lineText||He(r,o)!==o.matchedText)throw new D(e)}u(fe,"validateSnapshot");async function Fe(e,t,n,r,o){if(n?.throwIfAborted(),e.includes("://")){let i=await W(e,n,r,o);if(Buffer.byteLength(i)>t)throw new Error("Candidate snapshot byte budget reached.");return i}let a=await Be(e,"r");try{let i=await a.stat();if(!i.isFile()||i.size>t)throw new Error("Candidate snapshot byte budget reached.");let c=Buffer.alloc(Math.min(i.size+1,t+1)),s=0;for(;s<c.length;){n?.throwIfAborted();let l=await a.read(c,s,c.length-s,s);if(l.bytesRead===0)break;s+=l.bytesRead}if(n?.throwIfAborted(),s>i.size||s>t)throw new Error("Candidate file grew during snapshot capture.");return c.subarray(0,s).toString("utf8")}finally{await a.close()}}u(Fe,"readBoundedSnapshot");async function H(e,t,n,r){try{return await W(e,t,n,r)}catch{return}}u(H,"readCurrent");function C(e){return e.includes("://")?e:x.resolve(e)}u(C,"canonicalSource");function De(e,t){return t.includes("://")?t:e.includes("://")?new URL(t,e.endsWith("/")?e:e+"/").href:x.resolve(e,t)}u(De,"resolveScope");async function W(e,t,n,r){if(t?.throwIfAborted(),r!==void 0)return r(e,t);if(n!==void 0)return n.readText(e,t);if(e.includes("://"))throw new Error("No search snapshot owner for this source.");return Pe(e,{encoding:"utf8",...t!==void 0&&{signal:t}})}u(W,"readOwnedText");function B(e=1){return{kind:"rejected",rejection:{code:"stale",reason:"search anchor is stale",contextRange:{offset:Math.max(1,e-2),limit:5}}}}u(B,"staleAnchor");function v(){return{kind:"rejected",rejection:{code:"missing",reason:"search did not register an all anchor because its result was limited"}}}u(v,"missingCompleteAnchor");function We(e){if(e.length===0)return".";let t=x.dirname(x.resolve(w(e[0])));for(let n of e.slice(1)){let r=x.resolve(n);for(;!Je(t,r);){let o=x.dirname(t);if(o===t)return t;t=o}}return t}u(We,"commonSourceDirectory");function Je(e,t){let n=x.relative(e,t);return n!==".."&&!n.startsWith(`..${x.sep}`)&&!x.isAbsolute(n)}u(Je,"isWithin");function X(e,t){return e.source.localeCompare(t.source)||e.lineNumber-t.lineNumber||e.startColumn-t.startColumn||(e.endLineNumber??e.lineNumber)-(t.endLineNumber??t.lineNumber)||e.endColumn-t.endColumn}u(X,"compareMatches");export{K as a,ve as b,Ae as c,nt as d,V as e,ht as f,ge as g,$e as h,D as i,le as j};
@@ -1 +1 @@
1
- import{a as l}from"./chunk-ZC65Z3CK.js";import{a as u}from"./chunk-EI7MMDWY.js";import{createHash as w}from"node:crypto";import{diffLines as v}from"diff";var f=3,G=4;function P(t,a,r,n){let e=S(a,n),s=I(e,a,n),d=S(a,r),c=new Map,g=s.map(i=>{let o=N(i,a,r,n,d),E=j(n,i.currentStart),C=B(n,i.currentEnd),h=JSON.stringify({contextAfter:C,contextBefore:E,headText:o.headText,repositoryPath:t,worktreeText:o.worktreeText}),m=c.get(h)??0;c.set(h,m+1);let b=H(`${h}\0${m}`).toUpperCase();return{selector:b,digest:b,duplicateOrder:m,repositoryPath:t,state:O(o),currentStartLine:R(n,i.currentStart),currentEndLine:R(n,Math.max(i.currentStart,i.currentEnd-1)),contextBefore:E,contextAfter:C,canonicalContent:h,segments:[o]}});return g.map(i=>({...i,selector:`CHANGE#${L(i.digest,g.map(({digest:o})=>o))}`}))}u(P,"createChangeGroups");function U(t,a){let r=t;for(let n of[...a.segments].sort((e,s)=>s.currentStart-e.currentStart)){if(r.slice(n.currentStart,n.currentEnd)!==n.worktreeText)return;r=r.slice(0,n.currentStart)+n.headText+r.slice(n.currentEnd)}return r}u(U,"reverseChangeGroup");function _(t,a,r,n,e){let s=x(r,n,S(t,a));return a.slice(0,s.start)+e+a.slice(s.end)}u(_,"replaceHeadRangeInIndex");function N(t,a,r,n,e){let s=x(t.headStart,t.headEnd,e);return{headText:a.slice(t.headStart,t.headEnd),indexText:r.slice(s.start,s.end),worktreeText:n.slice(t.currentStart,t.currentEnd),headStart:t.headStart,headEnd:t.headEnd,indexStart:s.start,indexEnd:s.end,currentStart:t.currentStart,currentEnd:t.currentEnd}}u(N,"createSegment");function O(t){return t.indexText===t.worktreeText?"staged":t.indexText===t.headText?"unstaged":"partial"}u(O,"changeState");function S(t,a){let r=v(t,a),n=[],e=0,s=0,d=0;for(;d<r.length;){let c=l(r[d]);if(!c.added&&!c.removed){e+=c.value.length,s+=c.value.length,d++;continue}let g={head:e,current:s};for(;d<r.length&&(l(r[d]).added||l(r[d]).removed);){let i=l(r[d]);i.removed?e+=i.value.length:s+=i.value.length,d++}n.push({headStart:g.head,headEnd:e,currentStart:g.current,currentEnd:s})}return n}u(S,"collectRawChanges");function I(t,a,r){let n=[];for(let e of t){let s=n.at(-1);if(s!==void 0&&p(r.slice(s.currentEnd,e.currentStart))<=f*2&&p(a.slice(s.headEnd,e.headStart))<=f*2){n[n.length-1]={headStart:s.headStart,headEnd:e.headEnd,currentStart:s.currentStart,currentEnd:e.currentEnd};continue}n.push(e)}return n}u(I,"mergeNearbyChanges");function x(t,a,r){return{start:y(t,"start",r),end:y(a,"end",r)}}u(x,"projectHeadRange");function y(t,a,r){let n=0;for(let e of r){if(t<e.headStart)return t+n;if(e.headStart===e.headEnd&&t===e.headStart)return a==="start"?e.currentStart:e.currentEnd;if(t===e.headStart)return e.currentStart;if(t<e.headEnd)return a==="start"?e.currentStart:e.currentEnd;if(t===e.headEnd)return e.currentEnd;n=e.currentEnd-e.headEnd}return t+n}u(y,"projectHeadBoundary");function j(t,a){return t.slice(0,a).split(/(?<=\n)/u).filter(Boolean).slice(-f)}u(j,"linesBefore");function B(t,a){return t.slice(a).split(/(?<=\n)/u).filter(Boolean).slice(0,f)}u(B,"linesAfter");function R(t,a){return p(t.slice(0,a))+1}u(R,"lineAtOffset");function p(t){return[...t.matchAll(/\n/gu)].length}u(p,"lineBreakCount");function H(t){return w("sha256").update(t).digest("hex")}u(H,"sha256");function L(t,a){for(let r=G;r<=t.length;r++){let n=t.slice(0,r);if(a.filter(e=>e.startsWith(n)).length===1)return n}return t}u(L,"shortestUniquePrefix");export{P as a,U as b,_ as c};
1
+ import{a as l}from"./chunk-ZC65Z3CK.js";import{a as u}from"./chunk-EI7MMDWY.js";import{createHash as w}from"node:crypto";import{diffLines as v}from"diff";var f=3,G=4;function P(t,a,r,n){let e=S(a,n),s=I(e,a,n),d=S(a,r),c=new Map,g=s.map(i=>{let o=N(i,a,r,n,d),E=B(n,i.currentStart),C=H(n,i.currentEnd),h=JSON.stringify({contextAfter:C,contextBefore:E,headText:o.headText,repositoryPath:t,worktreeText:o.worktreeText}),m=c.get(h)??0;c.set(h,m+1);let b=L(`${h}\0${m}`).toUpperCase();return{selector:b,digest:b,duplicateOrder:m,repositoryPath:t,state:O(o),currentStartLine:R(n,i.currentStart),currentEndLine:R(n,Math.max(i.currentStart,i.currentEnd-1)),contextBefore:E,contextAfter:C,canonicalContent:h,segments:[o]}});return g.map(i=>({...i,selector:`CHANGE#${T(i.digest,g.map(({digest:o})=>o))}`}))}u(P,"createChangeGroups");function U(t,a){let r=t;for(let n of[...a.segments].sort((e,s)=>s.currentStart-e.currentStart)){if(r.slice(n.currentStart,n.currentEnd)!==n.worktreeText)return;r=r.slice(0,n.currentStart)+n.headText+r.slice(n.currentEnd)}return r}u(U,"reverseChangeGroup");function _(t,a,r,n,e){let s=x(r,n,S(t,a));return a.slice(0,s.start)+e+a.slice(s.end)}u(_,"replaceHeadRangeInIndex");function N(t,a,r,n,e){let s=x(t.headStart,t.headEnd,e);return{headText:a.slice(t.headStart,t.headEnd),indexText:r.slice(s.start,s.end),worktreeText:n.slice(t.currentStart,t.currentEnd),headStart:t.headStart,headEnd:t.headEnd,indexStart:s.start,indexEnd:s.end,currentStart:t.currentStart,currentEnd:t.currentEnd}}u(N,"createSegment");function O(t){return t.indexText===t.worktreeText?"staged":t.indexText===t.headText?"unstaged":"partial"}u(O,"changeState");function S(t,a){let r=v(t,a),n=[],e=0,s=0,d=0;for(;d<r.length;){let c=l(r[d]);if(!c.added&&!c.removed){e+=c.value.length,s+=c.value.length,d++;continue}let g={head:e,current:s};for(;d<r.length&&(l(r[d]).added||l(r[d]).removed);){let i=l(r[d]);i.removed?e+=i.value.length:s+=i.value.length,d++}n.push({headStart:g.head,headEnd:e,currentStart:g.current,currentEnd:s})}return n}u(S,"collectRawChanges");function I(t,a,r){let n=[];for(let e of t){let s=n.at(-1);if(s!==void 0&&p(r.slice(s.currentEnd,e.currentStart))<=f*2&&p(a.slice(s.headEnd,e.headStart))<=f*2){n[n.length-1]={headStart:s.headStart,headEnd:e.headEnd,currentStart:s.currentStart,currentEnd:e.currentEnd};continue}n.push(e)}return n}u(I,"mergeNearbyChanges");function x(t,a,r){return{start:y(t,"start",r),end:y(a,"end",r)}}u(x,"projectHeadRange");function y(t,a,r){let n=0;for(let e of r){if(t<e.headStart)return t+n;if(e.headStart===e.headEnd&&t===e.headStart)return a==="start"?e.currentStart:e.currentEnd;if(t===e.headStart)return e.currentStart;if(t<e.headEnd)return a==="start"?e.currentStart:e.currentEnd;if(t===e.headEnd)return e.currentEnd;n=e.currentEnd-e.headEnd}return t+n}u(y,"projectHeadBoundary");function B(t,a){return t.slice(0,a).split(/(?<=\n)/u).filter(Boolean).slice(-f)}u(B,"linesBefore");function H(t,a){return t.slice(a).split(/(?<=\n)/u).filter(Boolean).slice(0,f)}u(H,"linesAfter");function R(t,a){return p(t.slice(0,a))+1}u(R,"lineAtOffset");function p(t){return[...t.matchAll(/\n/gu)].length}u(p,"lineBreakCount");function L(t){return w("sha256").update(t).digest("hex")}u(L,"sha256");function T(t,a){for(let r=G;r<=t.length;r++){let n=t.slice(0,r);if(a.filter(e=>e.startsWith(n)).length===1)return n}return t}u(T,"shortestUniquePrefix");export{P as a,U as b,_ as c};
@@ -1,4 +1,4 @@
1
- import{d as M,h as N}from"./chunk-XH5WN5XA.js";import{a as _}from"./chunk-GS5ZRTUG.js";import{l as w,m as P,n as B}from"./chunk-DDH3FP4G.js";import{a as m}from"./chunk-EI7MMDWY.js";import{Allow as $}from"partial-json";import{Guard as h}from"typebox-guard/guard";import{Allow as W,parse as U}from"partial-json";function O(o,e=W.ALL){if(!(!o||o.trim().length===0))try{let t=U(o,e);return t==null||typeof t!="object"||Array.isArray(t)?void 0:t}catch{return}}m(O,"resolvePartial");var S=class{static{m(this,"PartialToolRecoveryRegistry")}registrations=new Map;states=new Map;register(e){this.registrations.set(e.recoveryKey??e.toolName,e)}unregister(e){for(let[t,n]of this.registrations)(n.toolName===e||t===e)&&this.registrations.delete(t)}recoveryKeyFor(e){for(let[t,n]of this.registrations)if(n.toolName===e||n.toolNames?.includes(e)||t===e)return t}async recover(e){let t=this.states.get(e.contentIndex);if(t?.status==="done")return t.result;if(t?.status==="running")return t.promise;let n=this.registrations.get(e.recoveryKey??e.toolName);if(!n)return;let r=this.run(n,e);this.states.set(e.contentIndex,{status:"running",promise:r});let a=await r;return this.states.set(e.contentIndex,{status:"done",result:a}),a}cancel(e){this.states.delete(e)}cleanup(e){this.states.delete(e)}cleanupAll(){this.states.clear()}async run(e,t){let n=[],r=new Set(t.completedEntryIndexes),a=new Set(t.blockedEntryIndexes),d=e.extractEntries(t).filter(u=>{if(r.has(u.index))return n.push({index:u.index,reason:"entry already completed before recovery"}),!1;if(a.has(u.index))return n.push({index:u.index,reason:"entry was blocked by a guard"}),!1;let p=e.isCompleteEntry?.(u,t)??u.complete;return p||n.push({index:u.index,reason:t.recoverCompleteBatch?"entry was incomplete in the recovered batch":"entry was incomplete before the stale entry"}),!t.recoverCompleteBatch&&t.staleEntryIndex!==void 0&&u.index>=t.staleEntryIndex?!1:p}),l=e.filterEntries?.(d,t)??d,s=new Set(l.map(u=>u.index));for(let u of d)s.has(u.index)||n.push({index:u.index,reason:"entry was excluded by recovery filtering"});let c=[];for(let u of l)try{e.validateEntry?.(u,t),c.push(u)}catch(p){n.push({index:u.index,reason:p instanceof Error?p.message:String(p)})}let g={toolName:t.toolName,contentIndex:t.contentIndex,...t.staleEntryIndex!==void 0&&{staleEntryIndex:t.staleEntryIndex},staleDetails:t.staleDetails};if(c.length===0)return{...g,status:"skipped",appliedEntries:[],skippedEntries:n};try{let u=e.buildParams(c,t),p=await e.execute(u,{contentIndex:t.contentIndex,toolCallId:t.toolCallId,toolName:t.toolName,cwd:t.cwd,ctx:t.ctx,signal:new AbortController().signal});return{...g,status:"recovered",appliedEntries:e.getAppliedEntries?.(p,c,t)??c.map(v=>v.index),skippedEntries:n,normalResult:p}}catch(u){return{...g,status:"failed",appliedEntries:[],skippedEntries:n,error:u instanceof Error?u.message:String(u)}}}};import{createAssistantMessageEventStream as Q}from"@earendil-works/pi-ai";var j=Symbol.for("pi-agent-text-editor.tool-call-interceptor.streaming-provider.state");function K(o,e,t,n){let r=new Map,a={context:void 0,processStreamEvent:e,markStreamEventProcessed:t,finalizeStreamInterception:n},i=m((s,c)=>{if(!s)return;let g=c.modelRegistry.getProvider(s.provider);if(!g)return;let u=m(f=>{let x=c.modelRegistry.getRegisteredNativeProvider(s.provider);if(x)o.registerProvider(D(x,f));else{let I=c.modelRegistry.getRegisteredProviderConfig(s.provider);o.registerProvider(s.provider,{...I,api:s.api,streamSimple:f})}},"register"),p=r.get(s.provider);if(p){if(p.subscribers.add(a),p.api===s.api&&g.streamSimple===p.wrapper)return;p.api=s.api,u(p.wrapper);return}let v=g.streamSimple[j];if(v){if(v.subscribers.add(a),r.set(s.provider,v),v.api===s.api)return;v.api=s.api,u(v.wrapper);return}let R=g.streamSimple.bind(g),C=new Set([a]),y=m((f,x,I)=>q(R,f,x,I,C),"wrapper"),b={api:s.api,originalStreamSimple:g.streamSimple,wrapper:y,subscribers:C};y[j]=b,u(y),r.set(s.provider,b)},"install"),d=!1,l=m((s,c)=>{d||(a.context=s,i(c??s.model,s))},"attach");o.on("before_provider_request",(s,c)=>l(c)),o.on("turn_start",(s,c)=>l(c)),o.on("agent_start",(s,c)=>l(c)),o.on("session_start",(s,c)=>{d=!1,l(c)}),o.on("model_select",(s,c)=>l(c,s.model)),o.on("session_shutdown",()=>{d=!0;for(let[s,c]of r){if(c.subscribers.delete(a),c.subscribers.size!==0)continue;let g=a.context?.modelRegistry;if(g?.getProvider(s)?.streamSimple!==c.wrapper)continue;let p=g?.getRegisteredNativeProvider(s);p?o.registerProvider(D(p,c.originalStreamSimple)):o.unregisterProvider(s)}r.clear(),a.context=void 0})}m(K,"registerStreamingInterceptorProvider");function D(o,e){return Object.create(Object.getPrototypeOf(o),{...Object.getOwnPropertyDescriptors(o),streamSimple:{value:e,writable:!0,enumerable:!0,configurable:!0}})}m(D,"withStreamSimple");function q(o,e,t,n,r){let a=Q(),i=new AbortController,d=n?.signal,l=!1,s=Z(e),c=new Set,g=new Set,u=new Set,p=new Set,v=m(C=>{for(let y of r)y.markStreamEventProcessed(C)},"markStreamEventProcessed"),R=m(()=>{i.abort()},"abortFromParent");return d&&(d.aborted?i.abort():d.addEventListener("abort",R,{once:!0})),(async()=>{try{let C=o(e,t,{...n,signal:i.signal});for await(let y of C){if(l)continue;y.type==="done"?s=structuredClone(y.message):y.type==="error"?s=structuredClone(y.error):s=structuredClone(y.partial),J(y,c);let b;for(let f of r){let x=f.context;if(x){let I=await f.processStreamEvent(y,x);b??=I}}if(v(y),V(y,g,u,p),a.push(structuredClone(y)),b){if(y.type==="toolcall_delta"||y.type==="toolcall_end")for(let E of r)E.finalizeStreamInterception(y.contentIndex);l=!0,i.abort();let f=y.type==="toolcall_delta"||y.type==="toolcall_end"?y.contentIndex:void 0,x={...s,content:s.content.filter((E,A)=>c.has(A)&&(f===void 0||A<=f||p.has(A))).map(E=>E.type==="toolCall"&&E.id===b.toolCallId?{...E,arguments:structuredClone(b.arguments)}:E)};Y(a,v,x,c,g,u,p);let{errorMessage:I,...H}=x;a.push({type:"done",reason:"toolUse",message:{...H,stopReason:"toolUse"}}),a.end();continue}if(y.type==="done"||y.type==="error"){a.end();return}}}catch(C){if(l)return;let y=s,b=d?.aborted===!0?"aborted":"error",f={...y,stopReason:b,errorMessage:C instanceof Error?C.message:String(C)};a.push({type:"error",reason:b,error:f}),a.end()}finally{d?.removeEventListener("abort",R)}})(),a}m(q,"wrapStream");function J(o,e){(o.type==="text_start"||o.type==="thinking_start"||o.type==="toolcall_start")&&e.add(o.contentIndex)}m(J,"rememberStartEvent");function V(o,e,t,n){switch(o.type){case"text_end":{e.add(o.contentIndex);break}case"thinking_end":{t.add(o.contentIndex);break}case"toolcall_end":{n.add(o.contentIndex);break}}}m(V,"rememberEndEvent");function Y(o,e,t,n,r,a,i){for(let[d,l]of t.content.entries())if(n.has(d)){if(l.type==="text"&&!r.has(d)){let s={type:"text_end",contentIndex:d,content:l.text,partial:t};e(s),o.push(s)}else if(l.type==="thinking"&&!a.has(d)){let s={type:"thinking_end",contentIndex:d,content:l.thinking,partial:t};e(s),o.push(s)}else if(l.type==="toolCall"&&!i.has(d)){let s={type:"toolcall_end",contentIndex:d,toolCall:l,partial:t};e(s),o.push(s)}}}m(Y,"emitMissingEndEvents");function Z(o){return{role:"assistant",content:[],api:o.api,provider:o.provider,model:o.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"toolUse",timestamp:Date.now()}}m(Z,"emptyAssistantMessage");var ee="agentic-ide-partial-tool-recovery",L="pi-agent-text-editor/tool-call-annotation",k=new WeakMap,T=class{constructor(e){this.pi=e;e.on("tool_call",t=>{let n=this.toolCallRecords.get(t.toolCallId),r=n?.blockExecution?n.guardResult:void 0;return r?{block:!0,reason:r.content.filter(i=>i.type==="text").map(i=>i.text).join(`
1
+ import{d as M,h as N}from"./chunk-JXULBI4S.js";import{a as _}from"./chunk-KQV2ZXLP.js";import{l as w,m as P,n as B}from"./chunk-SIYPD5MM.js";import{a as m}from"./chunk-EI7MMDWY.js";import{Allow as $}from"partial-json";import{Guard as h}from"typebox-guard/guard";import{Allow as W,parse as U}from"partial-json";function O(o,e=W.ALL){if(!(!o||o.trim().length===0))try{let t=U(o,e);return t==null||typeof t!="object"||Array.isArray(t)?void 0:t}catch{return}}m(O,"resolvePartial");var S=class{static{m(this,"PartialToolRecoveryRegistry")}registrations=new Map;states=new Map;register(e){this.registrations.set(e.recoveryKey??e.toolName,e)}unregister(e){for(let[t,n]of this.registrations)(n.toolName===e||t===e)&&this.registrations.delete(t)}recoveryKeyFor(e){for(let[t,n]of this.registrations)if(n.toolName===e||n.toolNames?.includes(e)||t===e)return t}async recover(e){let t=this.states.get(e.contentIndex);if(t?.status==="done")return t.result;if(t?.status==="running")return t.promise;let n=this.registrations.get(e.recoveryKey??e.toolName);if(!n)return;let r=this.run(n,e);this.states.set(e.contentIndex,{status:"running",promise:r});let a=await r;return this.states.set(e.contentIndex,{status:"done",result:a}),a}cancel(e){this.states.delete(e)}cleanup(e){this.states.delete(e)}cleanupAll(){this.states.clear()}async run(e,t){let n=[],r=new Set(t.completedEntryIndexes),a=new Set(t.blockedEntryIndexes),d=e.extractEntries(t).filter(u=>{if(r.has(u.index))return n.push({index:u.index,reason:"entry already completed before recovery"}),!1;if(a.has(u.index))return n.push({index:u.index,reason:"entry was blocked by a guard"}),!1;let p=e.isCompleteEntry?.(u,t)??u.complete;return p||n.push({index:u.index,reason:t.recoverCompleteBatch?"entry was incomplete in the recovered batch":"entry was incomplete before the stale entry"}),!t.recoverCompleteBatch&&t.staleEntryIndex!==void 0&&u.index>=t.staleEntryIndex?!1:p}),l=e.filterEntries?.(d,t)??d,s=new Set(l.map(u=>u.index));for(let u of d)s.has(u.index)||n.push({index:u.index,reason:"entry was excluded by recovery filtering"});let c=[];for(let u of l)try{e.validateEntry?.(u,t),c.push(u)}catch(p){n.push({index:u.index,reason:p instanceof Error?p.message:String(p)})}let g={toolName:t.toolName,contentIndex:t.contentIndex,...t.staleEntryIndex!==void 0&&{staleEntryIndex:t.staleEntryIndex},staleDetails:t.staleDetails};if(c.length===0)return{...g,status:"skipped",appliedEntries:[],skippedEntries:n};try{let u=e.buildParams(c,t),p=await e.execute(u,{contentIndex:t.contentIndex,toolCallId:t.toolCallId,toolName:t.toolName,cwd:t.cwd,ctx:t.ctx,signal:new AbortController().signal});return{...g,status:"recovered",appliedEntries:e.getAppliedEntries?.(p,c,t)??c.map(v=>v.index),skippedEntries:n,normalResult:p}}catch(u){return{...g,status:"failed",appliedEntries:[],skippedEntries:n,error:u instanceof Error?u.message:String(u)}}}};import{createAssistantMessageEventStream as Q}from"@earendil-works/pi-ai";var j=Symbol.for("pi-agent-text-editor.tool-call-interceptor.streaming-provider.state");function K(o,e,t,n){let r=new Map,a={context:void 0,processStreamEvent:e,markStreamEventProcessed:t,finalizeStreamInterception:n},i=m((s,c)=>{if(!s)return;let g=c.modelRegistry.getProvider(s.provider);if(!g)return;let u=m(f=>{let x=c.modelRegistry.getRegisteredNativeProvider(s.provider);if(x)o.registerProvider(D(x,f));else{let I=c.modelRegistry.getRegisteredProviderConfig(s.provider);o.registerProvider(s.provider,{...I,api:s.api,streamSimple:f})}},"register"),p=r.get(s.provider);if(p){if(p.subscribers.add(a),p.api===s.api&&g.streamSimple===p.wrapper)return;p.api=s.api,u(p.wrapper);return}let v=g.streamSimple[j];if(v){if(v.subscribers.add(a),r.set(s.provider,v),v.api===s.api)return;v.api=s.api,u(v.wrapper);return}let R=g.streamSimple.bind(g),C=new Set([a]),y=m((f,x,I)=>q(R,f,x,I,C),"wrapper"),b={api:s.api,originalStreamSimple:g.streamSimple,wrapper:y,subscribers:C};y[j]=b,u(y),r.set(s.provider,b)},"install"),d=!1,l=m((s,c)=>{d||(a.context=s,i(c??s.model,s))},"attach");o.on("before_provider_request",(s,c)=>l(c)),o.on("turn_start",(s,c)=>l(c)),o.on("agent_start",(s,c)=>l(c)),o.on("session_start",(s,c)=>{d=!1,l(c)}),o.on("model_select",(s,c)=>l(c,s.model)),o.on("session_shutdown",()=>{d=!0;for(let[s,c]of r){if(c.subscribers.delete(a),c.subscribers.size!==0)continue;let g=a.context?.modelRegistry;if(g?.getProvider(s)?.streamSimple!==c.wrapper)continue;let p=g?.getRegisteredNativeProvider(s);p?o.registerProvider(D(p,c.originalStreamSimple)):o.unregisterProvider(s)}r.clear(),a.context=void 0})}m(K,"registerStreamingInterceptorProvider");function D(o,e){return Object.create(Object.getPrototypeOf(o),{...Object.getOwnPropertyDescriptors(o),streamSimple:{value:e,writable:!0,enumerable:!0,configurable:!0}})}m(D,"withStreamSimple");function q(o,e,t,n,r){let a=Q(),i=new AbortController,d=n?.signal,l=!1,s=Z(e),c=new Set,g=new Set,u=new Set,p=new Set,v=m(C=>{for(let y of r)y.markStreamEventProcessed(C)},"markStreamEventProcessed"),R=m(()=>{i.abort()},"abortFromParent");return d&&(d.aborted?i.abort():d.addEventListener("abort",R,{once:!0})),(async()=>{try{let C=o(e,t,{...n,signal:i.signal});for await(let y of C){if(l)continue;y.type==="done"?s=structuredClone(y.message):y.type==="error"?s=structuredClone(y.error):s=structuredClone(y.partial),J(y,c);let b;for(let f of r){let x=f.context;if(x){let I=await f.processStreamEvent(y,x);b??=I}}if(v(y),V(y,g,u,p),a.push(structuredClone(y)),b){if(y.type==="toolcall_delta"||y.type==="toolcall_end")for(let E of r)E.finalizeStreamInterception(y.contentIndex);l=!0,i.abort();let f=y.type==="toolcall_delta"||y.type==="toolcall_end"?y.contentIndex:void 0,x={...s,content:s.content.filter((E,A)=>c.has(A)&&(f===void 0||A<=f||p.has(A))).map(E=>E.type==="toolCall"&&E.id===b.toolCallId?{...E,arguments:structuredClone(b.arguments)}:E)};Y(a,v,x,c,g,u,p);let{errorMessage:I,...H}=x;a.push({type:"done",reason:"toolUse",message:{...H,stopReason:"toolUse"}}),a.end();continue}if(y.type==="done"||y.type==="error"){a.end();return}}}catch(C){if(l)return;let y=s,b=d?.aborted===!0?"aborted":"error",f={...y,stopReason:b,errorMessage:C instanceof Error?C.message:String(C)};a.push({type:"error",reason:b,error:f}),a.end()}finally{d?.removeEventListener("abort",R)}})(),a}m(q,"wrapStream");function J(o,e){(o.type==="text_start"||o.type==="thinking_start"||o.type==="toolcall_start")&&e.add(o.contentIndex)}m(J,"rememberStartEvent");function V(o,e,t,n){switch(o.type){case"text_end":{e.add(o.contentIndex);break}case"thinking_end":{t.add(o.contentIndex);break}case"toolcall_end":{n.add(o.contentIndex);break}}}m(V,"rememberEndEvent");function Y(o,e,t,n,r,a,i){for(let[d,l]of t.content.entries())if(n.has(d)){if(l.type==="text"&&!r.has(d)){let s={type:"text_end",contentIndex:d,content:l.text,partial:t};e(s),o.push(s)}else if(l.type==="thinking"&&!a.has(d)){let s={type:"thinking_end",contentIndex:d,content:l.thinking,partial:t};e(s),o.push(s)}else if(l.type==="toolCall"&&!i.has(d)){let s={type:"toolcall_end",contentIndex:d,toolCall:l,partial:t};e(s),o.push(s)}}}m(Y,"emitMissingEndEvents");function Z(o){return{role:"assistant",content:[],api:o.api,provider:o.provider,model:o.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"toolUse",timestamp:Date.now()}}m(Z,"emptyAssistantMessage");var ee="agentic-ide-partial-tool-recovery",L="pi-agent-text-editor/tool-call-annotation",k=new WeakMap,T=class{constructor(e){this.pi=e;e.on("tool_call",t=>{let n=this.toolCallRecords.get(t.toolCallId),r=n?.blockExecution?n.guardResult:void 0;return r?{block:!0,reason:r.content.filter(i=>i.type==="text").map(i=>i.text).join(`
2
2
  `)||`Tool call ${t.toolName} was blocked by a streaming interceptor.`}:void 0}),e.on("tool_result",t=>{let n=this.toolCallBatchEntryIndexes.get(t.toolCallId);n!==void 0&&this.completedBatchEntryIndexes.add(n);let r=this.toolCallRecords.get(t.toolCallId)?.guardResult;if(this.toolCallRecords.delete(t.toolCallId),r){let a=r.details,i=typeof a=="object"&&a!==null&&"effect"in a&&(a.effect==="not-applied"||a.effect==="applied")?a.effect:"unknown",d=r.content.flatMap(l=>l.type==="text"?[l.text]:[]).join(`
3
3
  `);return B({content:r.content,details:a},_(t.toolName),{status:"error",errors:[P(d,"INTERCEPTED")],data:{operation:t.toolName,operationId:t.toolCallId,effect:i,files:[]}})}}),e.on("message_update",async(t,n)=>{let r=t.assistantMessageEvent;this.consumeProcessedStreamEvent(r)||await this.processStreamEvent(r,n)}),e.on("message_end",async t=>{if(await this.finalizeRecovery(),this.annotateIncompleteCalls(),t.message.role==="toolResult"){let r=this.toolCallRecords.get(t.message.toolCallId),a=r?.blockExecution?r.guardResult:void 0;if(a){this.toolCallRecords.delete(t.message.toolCallId);let i=a.details;i!==void 0&&w(i);let d=this.toolCallBatchEntryIndexes.get(t.message.toolCallId);return d!==void 0&&this.completedBatchEntryIndexes.add(d),{message:{...t.message,content:a.content,...i!==void 0&&{details:i},isError:!0}}}}if(t.message.role!=="assistant")return;let n=this.pendingAbortReason;if(this.pendingAbortReason=void 0,!(n===void 0||t.message.stopReason!=="aborted"))return{message:{...t.message,errorMessage:n}}}),e.on("agent_end",async()=>{await this.finalizeRecovery(),this.annotateIncompleteCalls(),this.cleanupAll()})}static{m(this,"InterceptorImpl")}handlers=new Map;recoveryRegistry=new S;pendingRecoveryBlocks=[];pendingAbortReason;recoveryAppliedBatchIndexes=new Set;partialBuffers=new Map;completeArgumentContentIndices=new Set;streamedBatchEntries=new Map;batchEntryIndexes=new Map;toolCallBatchEntryIndexes=new Map;completedBatchEntryIndexes=new Set;nextBatchEntryIndex=0;contentNames=new Map;contentToolCallIds=new Map;pendingToolCallAnnotations=new Map;emittedToolCallAnnotationKinds=new Map;abortedContentIndices=new Set;dispatchQueues=new Map;abortCleanups=new Map;processedStreamEvents=new WeakSet;processedStreamEventKeys=new Map;toolCallRecords=new Map;blockedCallSink;processStreamEvent(e,t){if(e.type==="toolcall_start"){let n=e.partial.content[e.contentIndex];if(n?.type==="toolCall"){let r=this.getOrCreateBatchEntryIndex(e.contentIndex);this.contentNames.set(e.contentIndex,n.name),typeof n.id=="string"&&this.bindToolCallId(e.contentIndex,n.id),this.partialBuffers.set(e.contentIndex,""),this.streamedBatchEntries.set(e.contentIndex,{index:r,toolName:n.name,args:{},complete:!1}),this.installAbortCleanup(e.contentIndex,t.signal)}return Promise.resolve(void 0)}return e.type==="toolcall_delta"?this.enqueue(e.contentIndex,async()=>{let n=this.contentNames.get(e.contentIndex),r=this.contentToolCallIds.get(e.contentIndex);if(!n)return;let a=(this.partialBuffers.get(e.contentIndex)??"")+e.delta;this.partialBuffers.set(e.contentIndex,a),this.installAbortCleanup(e.contentIndex,t.signal);let i=O(a,$.OBJ|$.ARR)??{},d=ne(a),l=this.getOrCreateBatchEntryIndex(e.contentIndex);this.streamedBatchEntries.set(e.contentIndex,{index:l,toolName:n,args:i,complete:d!==void 0});let s=this.handlers.get(n);if(!r||!s||s.length===0||!d&&Object.keys(i).length===0)return;let c=d!==void 0;if(c&&this.completeArgumentContentIndices.has(e.contentIndex))return;c&&this.completeArgumentContentIndices.add(e.contentIndex);let g=d??i,u=await this.dispatchHandlers(s,{toolCall:{id:r,name:n,arguments:g},args:g,...!c&&{partialArgs:i},batchEntryIndex:l,batchEntries:this.getBatchEntries(l),contentIndex:e.contentIndex,cwd:t.cwd,signal:t.signal,ctx:t});return u&&this.rememberOriginalArguments(u.toolCallId,u.arguments),u}):e.type==="toolcall_end"?this.enqueue(e.contentIndex,async()=>{let n=e.toolCall.name,r=this.handlers.get(n),a=this.getOrCreateBatchEntryIndex(e.contentIndex);this.bindToolCallId(e.contentIndex,e.toolCall.id);let i=this.toolCallRecords.get(e.toolCall.id);this.toolCallRecords.set(e.toolCall.id,{originalArguments:structuredClone(e.toolCall.arguments),...i?.guardResult&&{guardResult:i.guardResult},...i?.blockExecution&&{blockExecution:!0}}),this.streamedBatchEntries.set(e.contentIndex,{index:a,toolName:n,args:e.toolCall.arguments,complete:!1});let d=!this.completeArgumentContentIndices.has(e.contentIndex),l;d&&(this.completeArgumentContentIndices.add(e.contentIndex),l=r&&r.length>0?await this.dispatchHandlers(r,{toolCall:e.toolCall,args:e.toolCall.arguments,batchEntryIndex:a,batchEntries:this.getBatchEntries(a),contentIndex:e.contentIndex,cwd:t.cwd,signal:t.signal,ctx:t}):void 0);let s=this.streamedBatchEntries.get(e.contentIndex);return s&&this.streamedBatchEntries.set(e.contentIndex,{...s,complete:!0}),this.cleanupContent(e.contentIndex,n),l}):Promise.resolve(void 0)}markStreamEventProcessed(e){this.processedStreamEvents.add(e);let t=G(e);t!==void 0&&this.processedStreamEventKeys.set(t,(this.processedStreamEventKeys.get(t)??0)+1)}consumeProcessedStreamEvent(e){let t=this.processedStreamEvents.delete(e),n=G(e);if(n===void 0)return t;let r=this.processedStreamEventKeys.get(n)??0;return r===0?t:(r===1?this.processedStreamEventKeys.delete(n):this.processedStreamEventKeys.set(n,r-1),!0)}finalizeStreamInterception(e){this.cleanupTransientContent(e,void 0,!0)}getToolCallRecord(e){return this.toolCallRecords.get(e)}rememberOriginalArguments(e,t){let n=this.toolCallRecords.get(e);n&&this.toolCallRecords.set(e,{originalArguments:structuredClone(t),...n.guardResult&&{guardResult:n.guardResult},...n.blockExecution&&{blockExecution:!0}})}async dispatchHandlers(e,t){for(let n of e){let r=await n.intercept(t);if(r!==void 0){this.pendingRecoveryBlocks.push({blocked:r,ctx:t});let a={content:[{type:"text",text:r.message.content}],details:r.message.details??null};return this.blockedCallSink?.({callId:t.toolCall.id,toolName:t.toolCall.name,arguments:structuredClone(t.args),...t.contentIndex!==void 0&&{contentIndex:t.contentIndex},...t.batchEntryIndex!==void 0&&{batchEntryIndex:t.batchEntryIndex},...r.message.details!==void 0&&{details:r.message.details},result:a,nativeExecutionBlocked:n.blockExecution===!0}),{toolCallId:t.toolCall.id,arguments:structuredClone(t.args),result:this.abortToolCall(r,t,n.name,n.blockExecution===!0)}}}}annotateIncompleteCalls(){for(let[e,t]of this.streamedBatchEntries)!t.complete&&this.contentNames.has(e)&&!this.recoveryAppliedBatchIndexes.has(t.index)&&!this.emittedToolCallAnnotationKinds.get(e)?.has("stale-anchor")&&this.annotateContent(e,{kind:"aborted"})}bindToolCallId(e,t){this.contentToolCallIds.set(e,t);let n=this.batchEntryIndexes.get(e);n!==void 0&&this.toolCallBatchEntryIndexes.set(t,n);let r=this.pendingToolCallAnnotations.get(e);if(r){for(let a of r)this.emitToolCallAnnotation(t,a);this.pendingToolCallAnnotations.delete(e)}}annotateContent(e,t){let n=this.emittedToolCallAnnotationKinds.get(e)??new Set;if(n.has(t.kind))return;n.add(t.kind),this.emittedToolCallAnnotationKinds.set(e,n);let r=this.contentToolCallIds.get(e);if(r){this.emitToolCallAnnotation(r,t);return}let a=this.pendingToolCallAnnotations.get(e)??[];a.push(t),this.pendingToolCallAnnotations.set(e,a)}emitToolCallAnnotation(e,t){let n={toolCallId:e,annotation:t};this.pi.events.emit(L,n)}getOrCreateBatchEntryIndex(e){let t=this.batchEntryIndexes.get(e);if(t!==void 0)return t;let n=this.nextBatchEntryIndex;return this.nextBatchEntryIndex+=1,this.batchEntryIndexes.set(e,n),n}getBatchEntries(e){return[...this.streamedBatchEntries.values()].filter(t=>t.index<=e).sort((t,n)=>t.index-n.index)}getAllBatchEntries(){return[...this.streamedBatchEntries.values()].sort((e,t)=>e.index-t.index)}abortToolCall(e,t,n,r){let a=te(e,n),i=e.annotation?e.annotation.kind==="aborted"&&e.annotation.label===void 0?{...e.annotation,label:a}:e.annotation:e.message.customType==="text-editor-stale-anchor-block"?{kind:"stale-anchor",label:a}:{kind:"aborted",label:a,color:"error"};t.contentIndex!==void 0&&(this.abortedContentIndices.add(t.contentIndex),this.annotateContent(t.contentIndex,i));let d={content:[{type:"text",text:e.message.content}],details:M(e.message.details,i,a)};return this.toolCallRecords.set(t.toolCall.id,{originalArguments:structuredClone(t.args),guardResult:d,...r&&{blockExecution:!0}}),d}async finalizeRecovery(){let e=this.pendingRecoveryBlocks.splice(0);if(e.length===0)return;let t=new Map;for(let n of e){let r=this.recoveryRegistry.recoveryKeyFor(n.ctx.toolCall.name);if(r===void 0)continue;let a=t.get(r)??[];a.push(n),t.set(r,a)}for(let n of t.values()){let r=n[0];if(!r)continue;let a=await this.recoverIfNeeded(r.blocked,r.ctx,this.getAllBatchEntries(),n);if(a===r.blocked)continue;let i=a.message.details,l=(h.IsObjectNotArray(i)&&h.IsObjectNotArray(i.recovery)?i.recovery:void 0)?.appliedEntries;if(Array.isArray(l))for(let s of l)typeof s=="number"&&this.recoveryAppliedBatchIndexes.add(s)}}async recoverIfNeeded(e,t,n,r){if(t.contentIndex===void 0)return e;let a=e.message.details,i=h.IsObjectNotArray(a)&&typeof a.entryIndex=="number"?a.entryIndex:void 0,d=[...new Set(r.map(p=>p.ctx.batchEntryIndex).filter(p=>p!==void 0))],l=[...new Set(r.map(p=>p.ctx.toolCall.id))],s=r.map(p=>p.blocked.message.details),c=r[0],g=c?this.recoveryRegistry.recoveryKeyFor(c.ctx.toolCall.name):void 0;if(!g)return e;let u=await this.recoveryRegistry.recover({contentIndex:t.contentIndex,toolCallId:t.toolCall.id,toolName:t.toolCall.name,...i!==void 0&&{staleEntryIndex:i},staleDetails:a,...t.partialArgs&&{partialArgs:t.partialArgs},args:t.args,batchEntries:n,...t.batchEntryIndex!==void 0&&{batchEntryIndex:t.batchEntryIndex},recoverCompleteBatch:!0,completedEntryIndexes:[...this.completedBatchEntryIndexes],blockedEntryIndexes:d,blockedToolCallIds:l,blockedDetails:s,recoveryKey:g,cwd:t.cwd,ctx:t.ctx});return u&&(u.appliedEntries.length>0||u.skippedEntries.length>0)?ae(e,u):e}async enqueue(e,t){let r=(this.dispatchQueues.get(e)??Promise.resolve()).catch(()=>{}).then(t);this.dispatchQueues.set(e,r);try{return await r}finally{this.dispatchQueues.get(e)===r&&this.dispatchQueues.delete(e)}}installAbortCleanup(e,t){if(!t||this.abortCleanups.has(e))return;let n=m(()=>{let r=this.contentNames.get(e),a=r?this.handlers.get(r):void 0;for(let i of a??[])i.onAbort?.(e)},"listener");t.addEventListener("abort",n,{once:!0}),this.abortCleanups.set(e,()=>{t.removeEventListener("abort",n)})}cleanupContent(e,t){this.cleanupTransientContent(e,t),this.recoveryRegistry.cleanup(e)}cleanupTransientContent(e,t,n=!1){let r=t??this.contentNames.get(e),a=r?this.handlers.get(r):void 0;for(let i of a??[])n&&i.onAbort?.(e),i.onContentEnd?.(e);this.abortCleanups.get(e)?.(),this.abortCleanups.delete(e),this.contentNames.delete(e),this.contentToolCallIds.delete(e),this.pendingToolCallAnnotations.delete(e),this.emittedToolCallAnnotationKinds.delete(e),this.completeArgumentContentIndices.delete(e),this.partialBuffers.delete(e),this.abortedContentIndices.delete(e)}cleanupAll(){for(let e of this.handlers.values())for(let t of e)t.onAgentEnd?.();for(let e of this.abortCleanups.values())e();this.abortCleanups.clear(),this.contentNames.clear(),this.contentToolCallIds.clear(),this.pendingToolCallAnnotations.clear(),this.completeArgumentContentIndices.clear(),this.emittedToolCallAnnotationKinds.clear(),this.partialBuffers.clear(),this.streamedBatchEntries.clear(),this.batchEntryIndexes.clear(),this.toolCallBatchEntryIndexes.clear(),this.toolCallRecords.clear(),this.completedBatchEntryIndexes.clear(),this.nextBatchEntryIndex=0,this.abortedContentIndices.clear(),this.pendingAbortReason=void 0,this.dispatchQueues.clear(),this.processedStreamEventKeys.clear(),this.recoveryRegistry.cleanupAll(),this.pendingRecoveryBlocks.length=0,this.recoveryAppliedBatchIndexes.clear()}registerRecovery(e){this.recoveryRegistry.register(e)}unregisterRecovery(e){this.recoveryRegistry.unregister(e)}registerBlockedCallSink(e){this.blockedCallSink=e}register(e){let t=new Set(e.toolNames);for(let[n,r]of this.handlers){let a=r.findIndex(i=>i.name===e.name);a!==-1&&(t.has(n)?(r[a]=e,t.delete(n)):r.splice(a,1))}for(let n of t){let r=this.handlers.get(n)??[];r.push(e),this.handlers.set(n,r)}}unregister(e){for(let[t,n]of this.handlers)this.handlers.set(t,n.filter(r=>r.name!==e))}};function G(o){if(o.type==="toolcall_end")return`${o.type}\0${o.contentIndex}\0${o.toolCall.id}`;if(o.type!=="toolcall_start"&&o.type!=="toolcall_delta")return;let e=o.partial.content[o.contentIndex],t=e?.type==="toolCall"?e.id:"",n=o.type==="toolcall_delta"?o.delta:"";return`${o.type}\0${o.contentIndex}\0${t}\0${n}`}m(G,"toolStreamEventKey");function te(o,e){return o.annotation?.reason?o.annotation.reason:o.annotation?.label?o.annotation.label:o.message.customType==="text-editor-stale-anchor-block"?"Stale Anchor":e.replace(/[-_]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase())||"Blocked"}m(te,"abortReason");function ne(o){try{let e=JSON.parse(o);return h.IsObjectNotArray(e)?e:void 0}catch{return}}m(ne,"parseCompleteArguments");function re(o){let e=o.normalResult;if(!h.IsObjectNotArray(e)||!h.IsObjectNotArray(e.details))return[];let t=e.details.results;if(!Array.isArray(t))return[];let n=h.IsObjectNotArray(o.staleDetails)&&typeof o.staleDetails.path=="string"?o.staleDetails.path:void 0,r=t.filter(h.IsObjectNotArray).map(l=>h.IsObjectNotArray(l.data)?l.data:l),a=n===void 0?r:r.filter(l=>l.path===n),d=(a.length>0?a:r).flatMap(l=>{let s=l.freshAnchors;return Array.isArray(s)?s.filter(c=>typeof c=="string"):[]});return[...new Set(d)]}m(re,"freshAnchorsAfterRecovery");function oe(o,e){let n=o.indexOf(`
4
4
 
@@ -1 +1 @@
1
- import{b as y}from"./chunk-USG6WHAT.js";import{a as c,g as m}from"./chunk-4IWEKRSP.js";import{q as w}from"./chunk-7D7PXIVV.js";import{a as p}from"./chunk-EI7MMDWY.js";import a from"node:path";async function C(e,f,t,v,h,n){n?.throwIfAborted();let i=c(e.target.id,f).path;if(t&&x(t,i))return{cwd:c(e.target.id,t).source,external:!1};let d=!1;try{d=(await e.stat(i,{signal:n})).kind==="directory"}catch(r){if(!(r instanceof m)||r.code!=="ENOENT")throw r}let g=d?h:h.filter(r=>w(r,i)),T=t===void 0&&x(e.target.workspace,i)?e.target.workspace:void 0,o=d?i:a.posix.dirname(i);for(;;){n?.throwIfAborted();let r=a.posix.join(o,".pi","pi-agent-ide",`${v}.json`),l=!1;try{await e.stat(r,{signal:n}),l=!0}catch(s){if(!(s instanceof m)||s.code!=="ENOENT")throw s}let E=!l&&g.length>0?[...(await y(e,o,g,n)).values()].some(s=>s.score>0):!1;if(l||E||o===T)return{cwd:c(e.target.id,o).source,external:t!==void 0};let u=a.posix.dirname(o);if(u===o)return;o=u}}p(C,"resolveSshToolProject");function x(e,f){let t=a.posix.relative(e,f);return t===""||t!==".."&&!t.startsWith("../")&&!a.posix.isAbsolute(t)}p(x,"inside");export{C as a};
1
+ import{b as y}from"./chunk-JHWLRL4U.js";import{a as c,g as m}from"./chunk-KJAR2WDO.js";import{q as w}from"./chunk-S3T5NOSL.js";import{a as p}from"./chunk-EI7MMDWY.js";import a from"node:path";async function C(e,f,t,v,h,n){n?.throwIfAborted();let i=c(e.target.id,f).path;if(t&&x(t,i))return{cwd:c(e.target.id,t).source,external:!1};let d=!1;try{d=(await e.stat(i,{signal:n})).kind==="directory"}catch(r){if(!(r instanceof m)||r.code!=="ENOENT")throw r}let g=d?h:h.filter(r=>w(r,i)),T=t===void 0&&x(e.target.workspace,i)?e.target.workspace:void 0,o=d?i:a.posix.dirname(i);for(;;){n?.throwIfAborted();let r=a.posix.join(o,".pi","pi-agent-ide",`${v}.json`),l=!1;try{await e.stat(r,{signal:n}),l=!0}catch(s){if(!(s instanceof m)||s.code!=="ENOENT")throw s}let E=!l&&g.length>0?[...(await y(e,o,g,n)).values()].some(s=>s.score>0):!1;if(l||E||o===T)return{cwd:c(e.target.id,o).source,external:t!==void 0};let u=a.posix.dirname(o);if(u===o)return;o=u}}p(C,"resolveSshToolProject");function x(e,f){let t=a.posix.relative(e,f);return t===""||t!==".."&&!t.startsWith("../")&&!a.posix.isAbsolute(t)}p(x,"inside");export{C as a};
@@ -1 +1 @@
1
- import{a as m}from"./chunk-VDJSH3DQ.js";import{a as h}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{createHash as g}from"node:crypto";var u=/^([1-9]\d*)#([A-Z0-9]{3,4})$/,x=/(?<![A-Za-z0-9])([1-9]\d*#[A-Z0-9]{3,4})(?![A-Za-z0-9])/g;function A(e){let n=[...e.matchAll(x)],t=n[0];return n.length===1&&t!==void 0?h(t[1]):e}s(A,"normalizeLineHashAnchor");var d=class extends m{static{s(this,"LineHashTextAnchor")}constructor(n,t){super(`${n}#${f(t)}`,n)}};function f(e){return g("sha1").update(e).digest("hex").slice(0,4).toUpperCase()}s(f,"hashLine");function p(e,n){return new d(e,n)}s(p,"createLineHashAnchor");function v(e,n){return p(e,n).value}s(v,"formatLineHashAnchor");function y(e,n=1,t=e.length){let o=Math.max(1,n),r=Math.min(e.length,t);if(r<o)return[];let a=e.map((i,l)=>v(l+1,i)),c=Math.max(0,...a.map(i=>i.length));return e.slice(o-1,r).map((i,l)=>`${h(a[o+l-1]).padStart(c)}|${i}`)}s(y,"renderLineHashLines");function k(){return{id:"line-hash",description:"Use the complete `LINE#HASH` printed before a source line, for example `12#A4F0`; the hash rejects stale text.",normalize:A,renderFull(e){return e},renderCompact(e){return`line ${u.exec(e)?.[1]??"?"}`},tryResolve(e,n){return Promise.resolve(b(e,n))},recover(e,n){let t=u.exec(e);if(t===null)return Promise.resolve({kind:"unavailable"});let o=Number(t[1]),r=Math.min(Math.max(1,o),n.lines.length),a=n.lines[r-1];return a===void 0?Promise.resolve({kind:"unavailable"}):Promise.resolve({kind:"candidates",total:1,candidates:[{rank:1,range:{start:{lineNumber:r,column:0},end:{lineNumber:r,column:a.length}}}]})}}}s(k,"createLineHashAnchorResolver");function b(e,n){let t=u.exec(e);if(t===null)return{kind:"not-handled"};let o=Number(t[1]),r=n.lines[o-1];if(r===void 0||f(r)!==t[2]){let c=Math.max(1,o-5),i=Math.min(n.lines.length,o+5);return{kind:"rejected",rejection:{code:r===void 0?"missing":"stale",reason:r===void 0?"line hash anchor is out of range":"line hash anchor is stale",contextRange:{offset:c,limit:i-c+1}}}}return{kind:"resolved",anchor:p(o,r)}}s(b,"resolveLineHashAnchor");export{f as a,p as b,v as c,y as d,k as e};
1
+ import{a as m}from"./chunk-S7E2D5K7.js";import{a as h}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{createHash as g}from"node:crypto";var u=/^([1-9]\d*)#([A-Z0-9]{3,4})$/,x=/(?<![A-Za-z0-9])([1-9]\d*#[A-Z0-9]{3,4})(?![A-Za-z0-9])/g;function A(e){let n=[...e.matchAll(x)],t=n[0];return n.length===1&&t!==void 0?h(t[1]):e}s(A,"normalizeLineHashAnchor");var d=class extends m{static{s(this,"LineHashTextAnchor")}constructor(n,t){super(`${n}#${f(t)}`,n)}};function f(e){return g("sha1").update(e).digest("hex").slice(0,4).toUpperCase()}s(f,"hashLine");function p(e,n){return new d(e,n)}s(p,"createLineHashAnchor");function v(e,n){return p(e,n).value}s(v,"formatLineHashAnchor");function y(e,n=1,t=e.length){let o=Math.max(1,n),r=Math.min(e.length,t);if(r<o)return[];let a=e.map((i,l)=>v(l+1,i)),c=Math.max(0,...a.map(i=>i.length));return e.slice(o-1,r).map((i,l)=>`${h(a[o+l-1]).padStart(c)}|${i}`)}s(y,"renderLineHashLines");function k(){return{id:"line-hash",description:"Use the complete `LINE#HASH` printed before a source line, for example `12#A4F0`; the hash rejects stale text.",normalize:A,renderFull(e){return e},renderCompact(e){return`line ${u.exec(e)?.[1]??"?"}`},tryResolve(e,n){return Promise.resolve(b(e,n))},recover(e,n){let t=u.exec(e);if(t===null)return Promise.resolve({kind:"unavailable"});let o=Number(t[1]),r=Math.min(Math.max(1,o),n.lines.length),a=n.lines[r-1];return a===void 0?Promise.resolve({kind:"unavailable"}):Promise.resolve({kind:"candidates",total:1,candidates:[{rank:1,range:{start:{lineNumber:r,column:0},end:{lineNumber:r,column:a.length}}}]})}}}s(k,"createLineHashAnchorResolver");function b(e,n){let t=u.exec(e);if(t===null)return{kind:"not-handled"};let o=Number(t[1]),r=n.lines[o-1];if(r===void 0||f(r)!==t[2]){let c=Math.max(1,o-5),i=Math.min(n.lines.length,o+5);return{kind:"rejected",rejection:{code:r===void 0?"missing":"stale",reason:r===void 0?"line hash anchor is out of range":"line hash anchor is stale",contextRange:{offset:c,limit:i-c+1}}}}return{kind:"resolved",anchor:p(o,r)}}s(b,"resolveLineHashAnchor");export{f as a,p as b,v as c,y as d,k as e};
@@ -1 +1 @@
1
- import{a as C}from"./chunk-H3GEEOOL.js";import{a as w}from"./chunk-RIJRPAL2.js";import{a as E,b as g}from"./chunk-USG6WHAT.js";import{b as S}from"./chunk-LF325WYO.js";import"./chunk-VMLPXSMK.js";import{a as u,b as v,c as U}from"./chunk-WQIMM4SU.js";import"./chunk-FHRHYY4M.js";import{g as l}from"./chunk-4IWEKRSP.js";import{a as p,b as O,c as f,e as j}from"./chunk-HRBUY2FF.js";import"./chunk-K5G4FDXD.js";import{c as R}from"./chunk-XHFAV2NI.js";import"./chunk-B25LXXNV.js";import{c as P}from"./chunk-7D7PXIVV.js";import"./chunk-BXGMMZT3.js";import"./chunk-MDD5ORB6.js";import"./chunk-MLFJU2US.js";import"./chunk-DDH3FP4G.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{fileURLToPath as x}from"node:url";function A(i){let c=E(i),T=w(i);return{async resolveProject(e,o){if(e.startsWith("ssh://")||o.startsWith("ssh://")){let n=i.resolve(e,o);if(!n)throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let a=i.resolve(o);if(a&&a.location.target!==n.location.target)throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let r=await C(n.backend,n.location.path,a?.location.path,"linters",p);return r?{projectRoot:r.cwd,external:r.external}:void 0}if(e.includes("://")||o.includes("://"))throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let t=await P(o,e,"linters",p);return t===void 0?void 0:{projectRoot:t,external:t!==h.resolve(o)}},async loadRegistry(e,o){let t=i.resolve(e);return O.fromDirectory(e,{includeGlobal:!o,requireBuiltInEvidence:!0,...t?{layerAccess:c,executableAvailability:s(n=>S(t.backend,t.location.path,n),"executableAvailability"),recipeEvidence:s(n=>g(t.backend,t.location.path,n),"recipeEvidence")}:{}})},async run(e,o){let t=i.resolve(o.filePath);if(!t)return f(e,o);let n=i.resolve(o.projectRoot);if(!n||n.location.target!==t.location.target)throw new l("UNSUPPORTED_SOURCE",o.filePath,"not-applied");let a=e.check.cwd==="file"?h.posix.dirname(t.location.path):n.location.path;return f(e,{...o,processAccess:T,acceptsFile(r){if(r.startsWith("ssh://")){let d=i.resolve(r);return d?.location.target===t.location.target&&d.location.path===t.location.path}let m=r.startsWith("file:")?x(r):r;return m.includes("://")?!1:h.posix.resolve(a,m)===t.location.path}})}}}s(A,"createOwnedLintRuntime");async function L(i){let c=new U(await v(u(R())));await j(i,A(c))}s(L,"registerOwnedLint");export{A as createOwnedLintRuntime,L as default};
1
+ import{a as C}from"./chunk-FBR7ZLLN.js";import{a as w}from"./chunk-TSNY2FSU.js";import{a as E,b as g}from"./chunk-JHWLRL4U.js";import{b as S}from"./chunk-FTECKRK6.js";import"./chunk-PPCWY4BB.js";import{a as u,b as v,c as U}from"./chunk-V2D5MLGE.js";import"./chunk-5W6QQZFI.js";import{g as l}from"./chunk-KJAR2WDO.js";import{a as p,b as O,c as f,e as j}from"./chunk-OIEA4QWF.js";import"./chunk-K5G4FDXD.js";import{c as R}from"./chunk-XHFAV2NI.js";import"./chunk-72FL5FHZ.js";import{c as P}from"./chunk-S3T5NOSL.js";import"./chunk-BXGMMZT3.js";import"./chunk-2YO6RVX4.js";import"./chunk-MLFJU2US.js";import"./chunk-SIYPD5MM.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{fileURLToPath as x}from"node:url";function A(i){let c=E(i),T=w(i);return{async resolveProject(e,o){if(e.startsWith("ssh://")||o.startsWith("ssh://")){let n=i.resolve(e,o);if(!n)throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let a=i.resolve(o);if(a&&a.location.target!==n.location.target)throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let r=await C(n.backend,n.location.path,a?.location.path,"linters",p);return r?{projectRoot:r.cwd,external:r.external}:void 0}if(e.includes("://")||o.includes("://"))throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let t=await P(o,e,"linters",p);return t===void 0?void 0:{projectRoot:t,external:t!==h.resolve(o)}},async loadRegistry(e,o){let t=i.resolve(e);return O.fromDirectory(e,{includeGlobal:!o,requireBuiltInEvidence:!0,...t?{layerAccess:c,executableAvailability:s(n=>S(t.backend,t.location.path,n),"executableAvailability"),recipeEvidence:s(n=>g(t.backend,t.location.path,n),"recipeEvidence")}:{}})},async run(e,o){let t=i.resolve(o.filePath);if(!t)return f(e,o);let n=i.resolve(o.projectRoot);if(!n||n.location.target!==t.location.target)throw new l("UNSUPPORTED_SOURCE",o.filePath,"not-applied");let a=e.check.cwd==="file"?h.posix.dirname(t.location.path):n.location.path;return f(e,{...o,processAccess:T,acceptsFile(r){if(r.startsWith("ssh://")){let d=i.resolve(r);return d?.location.target===t.location.target&&d.location.path===t.location.path}let m=r.startsWith("file:")?x(r):r;return m.includes("://")?!1:h.posix.resolve(a,m)===t.location.path}})}}}s(A,"createOwnedLintRuntime");async function L(i){let c=new U(await v(u(R())));await j(i,A(c))}s(L,"registerOwnedLint");export{A as createOwnedLintRuntime,L as default};
@@ -1 +1 @@
1
- import{g as d}from"./chunk-4IWEKRSP.js";import{a as p}from"./chunk-EI7MMDWY.js";import l from"node:path";async function y(e,o,t={},r){r?.throwIfAborted();for(let n of Object.keys(t))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(n))throw new TypeError("Invalid remote process environment key");let i=await e.execute("python3",["-c",'import os; print(os.environ.get("PATH", os.defpath), end="")'],o,{signal:r});if(i.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",e.target.id,"not-applied");return{...t,PATH:[...["node_modules/.bin",".venv/bin","venv/bin","vendor/bin"].map(n=>l.posix.join(o,n)),t.PATH??i.stdout].join(":")}}p(y,"sshProjectEnvironment");async function v(e,o,t,r){r?.throwIfAborted();let i=t.map(s=>{for(let h of Object.keys(s.env??{}))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(h))throw new TypeError("Invalid remote process environment key");return{command:s.command[0]?.replaceAll("{project}",o)??"",path:s.env?.PATH}}),n=await e.execute("python3",["-c","import json,os,shutil,sys; candidates=json.loads(sys.argv[1]); root=sys.argv[2]; prefixes=[os.path.join(root,p) for p in ['node_modules/.bin','.venv/bin','venv/bin','vendor/bin']]; print(json.dumps([bool(shutil.which(c['command'],path=os.pathsep.join(prefixes+[c.get('path',os.environ.get('PATH',os.defpath))]))) for c in candidates]))",JSON.stringify(i),o],o,{signal:r});if(n.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",e.target.id,"not-applied");let a=JSON.parse(n.stdout.toString("utf8"));if(!Array.isArray(a)||a.length!==t.length||a.some(s=>typeof s!="boolean"))throw new d("INVALID_RESPONSE",e.target.id,"not-applied");return a}p(v,"sshProjectExecutableAvailability");export{y as a,v as b};
1
+ import{g as d}from"./chunk-KJAR2WDO.js";import{a as p}from"./chunk-EI7MMDWY.js";import l from"node:path";async function y(e,o,t={},r){r?.throwIfAborted();for(let n of Object.keys(t))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(n))throw new TypeError("Invalid remote process environment key");let i=await e.execute("python3",["-c",'import os; print(os.environ.get("PATH", os.defpath), end="")'],o,{signal:r});if(i.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",e.target.id,"not-applied");return{...t,PATH:[...["node_modules/.bin",".venv/bin","venv/bin","vendor/bin"].map(n=>l.posix.join(o,n)),t.PATH??i.stdout].join(":")}}p(y,"sshProjectEnvironment");async function v(e,o,t,r){r?.throwIfAborted();let i=t.map(s=>{for(let h of Object.keys(s.env??{}))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(h))throw new TypeError("Invalid remote process environment key");return{command:s.command[0]?.replaceAll("{project}",o)??"",path:s.env?.PATH}}),n=await e.execute("python3",["-c","import json,os,shutil,sys; candidates=json.loads(sys.argv[1]); root=sys.argv[2]; prefixes=[os.path.join(root,p) for p in ['node_modules/.bin','.venv/bin','venv/bin','vendor/bin']]; print(json.dumps([bool(shutil.which(c['command'],path=os.pathsep.join(prefixes+[c.get('path',os.environ.get('PATH',os.defpath))]))) for c in candidates]))",JSON.stringify(i),o],o,{signal:r});if(n.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",e.target.id,"not-applied");let a=JSON.parse(n.stdout.toString("utf8"));if(!Array.isArray(a)||a.length!==t.length||a.some(s=>typeof s!="boolean"))throw new d("INVALID_RESPONSE",e.target.id,"not-applied");return a}p(v,"sshProjectExecutableAvailability");export{y as a,v as b};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-5W6QQZFI.js";import"./chunk-KJAR2WDO.js";import"./chunk-SIYPD5MM.js";import"./chunk-EI7MMDWY.js";export{a as startSshProcess};
@@ -0,0 +1 @@
1
+ import{a as t}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as n}from"typebox/value";var i="pi-agent-read",r=14,c=`${i}/core/ready`,s=`${i}/plugin/register`,a=e.Function([],e.Unknown()),p=e.Object({protocol:e.Literal(i),apiVersion:e.Literal(r)}),R=e.Object({protocol:e.Literal(i),apiVersion:e.Literal(r),id:e.String(),setup:a}),l=e.Object({plugin:R,accept:a});function g(o){return n.Check(p,o)}t(g,"isReadCoreReady");function P(o){return n.Check(R,o)}t(P,"isReadPlugin");function y(o){return n.Check(l,o)}t(y,"isReadPluginRegistrationRequest");export{i as a,r as b,c,s as d,g as e,P as f,y as g};
@@ -1,2 +1,2 @@
1
- import{a as k,d as m}from"./chunk-7PVDTMEM.js";import{a as v,b}from"./chunk-PS2B6THP.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{pathToFileURL as T}from"node:url";function P(e,n,t,r,i,a=[],l=[]){let c=a.map(o=>({kind:"note",text:o}));c.push(...b(e.flatMap(o=>{let y=h.isAbsolute(o.source),D=y&&i?h.relative(i,o.source)||h.basename(o.source):o.source,z=y?T(o.source).href:/^https?:/iu.test(o.source)?o.source:void 0,x=o.endLineNumber??o.lineNumber;return(x===o.lineNumber?[o.lineText]:[o.lineText,...o.matchedText.split(/\r\n|\n|\r/u).slice(1)]).slice(0,20).map((R,f)=>({source:o.source,label:D,...z===void 0?{}:{link:z},...y?{}:{badge:o.source.startsWith("docs:")?"DOC":/^https?:/iu.test(o.source)?"WEB":"SH"},lineNumber:o.lineNumber+f,text:R,ranges:[{from:f?0:o.startColumn,to:o.lineNumber+f===x?o.endColumn:R.length}]}))}))),e.length||c.push({kind:"note",text:"No matches found"}),e.some(o=>(o.endLineNumber??o.lineNumber)-o.lineNumber>=20)&&c.push({kind:"note",text:"\u2026 source preview shortened"}),c.push(...l.map(o=>({kind:"note",text:o,expandedOnly:!0})));let u=`${e.length}${n?"":"+"}`,p=new Set(e.map(o=>o.source)),F=e.length>0&&e.every(o=>h.isAbsolute(o.source));return new v({summary:`${u} ${e.length===1?"match":"matches"} in ${p.size} ${F?p.size===1?"file":"files":p.size===1?"source":"sources"}`,rows:c},t,r)}s(P,"renderSearchMatches");function $(e,n){return e.targets.some(t=>t.source===n.source&&t.ranges.some(r=>(r.start.lineNumber<n.lineNumber||r.start.lineNumber===n.lineNumber&&r.start.column<=n.startColumn)&&(r.end.lineNumber>(n.endLineNumber??n.lineNumber)||r.end.lineNumber===(n.endLineNumber??n.lineNumber)&&r.end.column>=n.endColumn)))}s($,"containsSearchMatch");function I(e){if(e===void 0)return[];let n=[],t=0,r="";for(let i of e){if(i==="{"?t+=1:i==="}"&&(t=Math.max(0,t-1)),t===0&&(i===","||/\s/u.test(i))){r.length>0&&(n.push(r),r="");continue}r+=i}return r.length>0&&n.push(r),n}s(I,"splitGlobList");import{Value as N}from"typebox/value";var d={candidates:5,previewMatches:3,identifiers:2e4,identifierLength:80,vocabularyBytes:8*1024*1024,matchesPerCandidate:200,verificationBytes:4*1024*1024,timeoutMs:2e3};function L(e){return N.Check(k,e)}s(L,"isFuzzyResultData");function g(e){return e.length>=5&&e.length<=d.identifierLength&&/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(e)&&/[A-Za-z]/u.test(e)}s(g,"isFuzzyQuery");var S=class{static{s(this,"FuzzyVocabulary")}names=new Set;bytes=0;limited=!1;account(n){return this.bytes+=n,this.bytes>d.vocabularyBytes&&(this.limited=!0),!this.limited}add(n){if(!(this.limited||!g(n)||this.names.has(n))){if(this.names.size===d.identifiers){this.limited=!0;return}this.names.add(n)}}addText(n){if(this.account(Buffer.byteLength(n))){for(let t of n.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/gu))if(this.add(t[0]),this.limited)break}}};function w(e){return e.replace(/([A-Z]+)([A-Z][a-z])/gu,"$1 $2").replace(/([a-z0-9])([A-Z])/gu,"$1 $2").split(/[^A-Za-z0-9]+/u).filter(Boolean).map(n=>n.toLowerCase())}s(w,"splitName");function C(e,n){return e.length===n.length&&e.every((t,r)=>t===n[r])}s(C,"same");function M(e,n){if(e.length<5||n.length<5||Math.abs(e.length-n.length)>1||/\d/u.test(e+n))return!1;let t=0;for(;t<Math.min(e.length,n.length)&&e[t]===n[t];)t++;if(e.length===n.length)return e.slice(t+1)===n.slice(t+1)||e[t]===n[t+1]&&e[t+1]===n[t]&&e.slice(t+2)===n.slice(t+2);let r=e.length<n.length?e:n,i=e.length<n.length?n:e;return r.slice(t)===i.slice(t+1)}s(M,"oneTypo");function E(e,n){if(e.join("")===n.join(""))return{kind:"normalized",reason:"same spelling with different case or separators"};let t=e.length<n.length?e:n,r=e.length<n.length?n:e;if(r.length===t.length+1&&t.length>=2&&t.every(l=>l.length>=3)){let l=C(t,r.slice(1)),c=C(t,r.slice(0,-1));if(l||c)return{kind:"component",reason:`${e.length>n.length?"remove":"add"} ${l?"leading":"trailing"} component '${l?r[0]:r.at(-1)}'`}}if(e.length!==n.length)return;let i=e.flatMap((l,c)=>{let u=n[c];return u!==void 0&&l!==u?[{word:l,other:u}]:[]}),a=i[0];if(!(i.length!==1||!a||!M(a.word,a.other)))return{kind:"typo",reason:`one character edit: '${a.word}' \u2192 '${a.other}'`}}s(E,"relation");var A={normalized:0,component:1,typo:2};function _(e,n){if(!g(e))return[];let t=w(e);if(t.length===0)return[];let r=[];for(let i of new Set(n)){if(i===e||!g(i))continue;let a=E(t,w(i));a&&r.push({identifier:i,...a})}return r.sort((i,a)=>A[i.kind]-A[a.kind]||(i.identifier<a.identifier?-1:i.identifier>a.identifier?1:0)).slice(0,d.candidates)}s(_,"rankFuzzyIdentifiers");function O(e,n,t){return{identifier:e.identifier,kind:e.kind,reason:e.reason,matchCount:e.matches.length,fileCount:new Set(e.matches.map(r=>r.source)).size,selection:{...m(e.matches.slice(0,d.previewMatches),e.complete,n,t),truncated:e.matches.length>d.previewMatches}}}s(O,"fuzzyCandidateData");function Z(e){let n=e.selection.complete?"":"+",t=e.selection.all?.line??e.selection.matches[0]?.references?.line,r=e.selection.matches[0],i=t??r?.source;return[`Possible name: ${e.identifier} (${e.reason})`,`${e.matchCount}${n} ${e.matchCount===1&&e.selection.complete?"match":"matches"} in ${e.fileCount}${n} ${e.fileCount===1&&e.selection.complete?"file":"files"}`,`Exact alternative: ${JSON.stringify(e.identifier)} (case-sensitive, whole identifier)`,...e.selection.complete?[]:["Capture limit reached; no complete all reference. Inspect the returned location; do not treat this candidate as a complete match set."],...i?[`Read: ${i}${t||!r?"":` \xB7 line ${r.range.startLine}`}`]:[]].join(`
1
+ import{a as k,d as m}from"./chunk-5AROEOJB.js";import{a as v,b}from"./chunk-PS2B6THP.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{pathToFileURL as T}from"node:url";function P(e,n,t,r,i,a=[],l=[]){let c=a.map(o=>({kind:"note",text:o}));c.push(...b(e.flatMap(o=>{let y=h.isAbsolute(o.source),D=y&&i?h.relative(i,o.source)||h.basename(o.source):o.source,z=y?T(o.source).href:/^https?:/iu.test(o.source)?o.source:void 0,x=o.endLineNumber??o.lineNumber;return(x===o.lineNumber?[o.lineText]:[o.lineText,...o.matchedText.split(/\r\n|\n|\r/u).slice(1)]).slice(0,20).map((R,f)=>({source:o.source,label:D,...z===void 0?{}:{link:z},...y?{}:{badge:o.source.startsWith("docs:")?"DOC":/^https?:/iu.test(o.source)?"WEB":"SH"},lineNumber:o.lineNumber+f,text:R,ranges:[{from:f?0:o.startColumn,to:o.lineNumber+f===x?o.endColumn:R.length}]}))}))),e.length||c.push({kind:"note",text:"No matches found"}),e.some(o=>(o.endLineNumber??o.lineNumber)-o.lineNumber>=20)&&c.push({kind:"note",text:"\u2026 source preview shortened"}),c.push(...l.map(o=>({kind:"note",text:o,expandedOnly:!0})));let u=`${e.length}${n?"":"+"}`,p=new Set(e.map(o=>o.source)),F=e.length>0&&e.every(o=>h.isAbsolute(o.source));return new v({summary:`${u} ${e.length===1?"match":"matches"} in ${p.size} ${F?p.size===1?"file":"files":p.size===1?"source":"sources"}`,rows:c},t,r)}s(P,"renderSearchMatches");function $(e,n){return e.targets.some(t=>t.source===n.source&&t.ranges.some(r=>(r.start.lineNumber<n.lineNumber||r.start.lineNumber===n.lineNumber&&r.start.column<=n.startColumn)&&(r.end.lineNumber>(n.endLineNumber??n.lineNumber)||r.end.lineNumber===(n.endLineNumber??n.lineNumber)&&r.end.column>=n.endColumn)))}s($,"containsSearchMatch");function I(e){if(e===void 0)return[];let n=[],t=0,r="";for(let i of e){if(i==="{"?t+=1:i==="}"&&(t=Math.max(0,t-1)),t===0&&(i===","||/\s/u.test(i))){r.length>0&&(n.push(r),r="");continue}r+=i}return r.length>0&&n.push(r),n}s(I,"splitGlobList");import{Value as N}from"typebox/value";var d={candidates:5,previewMatches:3,identifiers:2e4,identifierLength:80,vocabularyBytes:8*1024*1024,matchesPerCandidate:200,verificationBytes:4*1024*1024,timeoutMs:2e3};function L(e){return N.Check(k,e)}s(L,"isFuzzyResultData");function g(e){return e.length>=5&&e.length<=d.identifierLength&&/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(e)&&/[A-Za-z]/u.test(e)}s(g,"isFuzzyQuery");var S=class{static{s(this,"FuzzyVocabulary")}names=new Set;bytes=0;limited=!1;account(n){return this.bytes+=n,this.bytes>d.vocabularyBytes&&(this.limited=!0),!this.limited}add(n){if(!(this.limited||!g(n)||this.names.has(n))){if(this.names.size===d.identifiers){this.limited=!0;return}this.names.add(n)}}addText(n){if(this.account(Buffer.byteLength(n))){for(let t of n.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/gu))if(this.add(t[0]),this.limited)break}}};function w(e){return e.replace(/([A-Z]+)([A-Z][a-z])/gu,"$1 $2").replace(/([a-z0-9])([A-Z])/gu,"$1 $2").split(/[^A-Za-z0-9]+/u).filter(Boolean).map(n=>n.toLowerCase())}s(w,"splitName");function C(e,n){return e.length===n.length&&e.every((t,r)=>t===n[r])}s(C,"same");function M(e,n){if(e.length<5||n.length<5||Math.abs(e.length-n.length)>1||/\d/u.test(e+n))return!1;let t=0;for(;t<Math.min(e.length,n.length)&&e[t]===n[t];)t++;if(e.length===n.length)return e.slice(t+1)===n.slice(t+1)||e[t]===n[t+1]&&e[t+1]===n[t]&&e.slice(t+2)===n.slice(t+2);let r=e.length<n.length?e:n,i=e.length<n.length?n:e;return r.slice(t)===i.slice(t+1)}s(M,"oneTypo");function E(e,n){if(e.join("")===n.join(""))return{kind:"normalized",reason:"same spelling with different case or separators"};let t=e.length<n.length?e:n,r=e.length<n.length?n:e;if(r.length===t.length+1&&t.length>=2&&t.every(l=>l.length>=3)){let l=C(t,r.slice(1)),c=C(t,r.slice(0,-1));if(l||c)return{kind:"component",reason:`${e.length>n.length?"remove":"add"} ${l?"leading":"trailing"} component '${l?r[0]:r.at(-1)}'`}}if(e.length!==n.length)return;let i=e.flatMap((l,c)=>{let u=n[c];return u!==void 0&&l!==u?[{word:l,other:u}]:[]}),a=i[0];if(!(i.length!==1||!a||!M(a.word,a.other)))return{kind:"typo",reason:`one character edit: '${a.word}' \u2192 '${a.other}'`}}s(E,"relation");var A={normalized:0,component:1,typo:2};function _(e,n){if(!g(e))return[];let t=w(e);if(t.length===0)return[];let r=[];for(let i of new Set(n)){if(i===e||!g(i))continue;let a=E(t,w(i));a&&r.push({identifier:i,...a})}return r.sort((i,a)=>A[i.kind]-A[a.kind]||(i.identifier<a.identifier?-1:i.identifier>a.identifier?1:0)).slice(0,d.candidates)}s(_,"rankFuzzyIdentifiers");function O(e,n,t){return{identifier:e.identifier,kind:e.kind,reason:e.reason,matchCount:e.matches.length,fileCount:new Set(e.matches.map(r=>r.source)).size,selection:{...m(e.matches.slice(0,d.previewMatches),e.complete,n,t),truncated:e.matches.length>d.previewMatches}}}s(O,"fuzzyCandidateData");function Z(e){let n=e.selection.complete?"":"+",t=e.selection.all?.line??e.selection.matches[0]?.references?.line,r=e.selection.matches[0],i=t??r?.source;return[`Possible name: ${e.identifier} (${e.reason})`,`${e.matchCount}${n} ${e.matchCount===1&&e.selection.complete?"match":"matches"} in ${e.fileCount}${n} ${e.fileCount===1&&e.selection.complete?"file":"files"}`,`Exact alternative: ${JSON.stringify(e.identifier)} (case-sensitive, whole identifier)`,...e.selection.complete?[]:["Capture limit reached; no complete all reference. Inspect the returned location; do not treat this candidate as a complete match set."],...i?[`Read: ${i}${t||!r?"":` \xB7 line ${r.range.startLine}`}`]:[]].join(`
2
2
  `)}s(Z,"formatFuzzyCandidate");export{P as a,$ as b,I as c,d,L as e,g as f,S as g,_ as h,O as i,Z as j};
@@ -0,0 +1,3 @@
1
+ import{a as S}from"./chunk-S7E2D5K7.js";import{a as c}from"./chunk-EI7MMDWY.js";import{createRequire as F}from"node:module";import{Lang as y,parse as R,registerDynamicLanguage as B}from"@ast-grep/napi";var D=F(new URL("../src/plugins/pi-agent-ide-ast/src/ast/native-parser.ts",import.meta.url).href),$={bash:"@ast-grep/lang-bash",csharp:"@ast-grep/lang-csharp",dart:"@ast-grep/lang-dart",elixir:"@ast-grep/lang-elixir",go:"@ast-grep/lang-go",html:"@ast-grep/lang-html",java:"@ast-grep/lang-java",kotlin:"@ast-grep/lang-kotlin",lua:"@ast-grep/lang-lua",markdown:"@ast-grep/lang-markdown",php:"@ast-grep/lang-php",ruby:"@ast-grep/lang-ruby",scala:"@ast-grep/lang-scala",sql:"@ast-grep/lang-sql",swift:"@ast-grep/lang-swift"},O={".bash":"bash",".cs":"csharp",".css":y.Css,".less":y.Css,".scss":y.Css,".dart":"dart",".ex":"elixir",".exs":"elixir",".go":"go",".htm":"html",".html":"html",".java":"java",".kt":"kotlin",".kts":"kotlin",".lua":"lua",".md":"markdown",".mdx":"markdown",".php":"php",".rb":"ruby",".rake":"ruby",".scala":"scala",".sc":"scala",".sql":"sql",".sh":"bash",".swift":"swift"},N=!1;function q(){if(N)return;let r={};for(let[e,t]of Object.entries($))r[e]=D(t);B(r),N=!0}c(q,"ensureLanguagesRegistered");function P(r,e){let t=O[r];if(t)return q(),{rootNode:new b(R(t,e).root(),e)}}c(P,"parseNativeDocument");var b=class r{constructor(e,t){this.node=e;this.source=t}static{c(this,"NativeSyntaxNode")}get type(){return String(this.node.kind())}get text(){return this.node.text()}get isNamed(){return this.node.isNamed()}get hasError(){return this.type==="ERROR"||this.node.children().some(e=>new r(e,this.source).hasError)}get startIndex(){return C(this.source,this.node.range().start.index)}get endIndex(){return C(this.source,this.node.range().end.index)}get startPosition(){let{line:e,column:t}=this.node.range().start;return{row:e,column:t}}get endPosition(){let{line:e,column:t}=this.node.range().end;return{row:e,column:t}}get parent(){let e=this.node.parent();return e?new r(e,this.source):null}get namedChildCount(){return this.namedChildren.length}get namedChildren(){return this.node.children().filter(e=>e.isNamed()).map(e=>new r(e,this.source))}childForFieldName(e){let t=this.node.field(e);return t?new r(t,this.source):null}};function C(r,e){return Buffer.from(r).subarray(0,e).toString("utf8").length}c(C,"byteOffsetToStringIndex");import{createHash as W}from"node:crypto";import{createRequire as I}from"node:module";import L from"node:path";import*as p from"web-tree-sitter";var M=I(new URL("../src/plugins/pi-agent-ide-ast/src/ast/manager.ts",import.meta.url).href),G=new Set(["program","module"]),x=new Set(["body","consequence","alternative","handler","finalizer"]);function k(r){let{startPosition:e,endPosition:t}=r;return`${r.type}:${e.row}:${e.column}:${t.row}:${t.column}`}c(k,"siblingKey");var T,A=new Map;function U(r){switch(r){case".ts":case".tsx":case".mts":case".cts":return"tree-sitter-typescript/tree-sitter-typescript.wasm";case".js":case".jsx":case".mjs":case".cjs":return"tree-sitter-javascript/tree-sitter-javascript.wasm";case".py":case".pyi":return"tree-sitter-python/tree-sitter-python.wasm";case".rs":return"tree-sitter-rust/tree-sitter-rust.wasm";case".c":case".cc":case".hh":case".hxx":case".cpp":case".cxx":case".h":case".hpp":return"tree-sitter-cpp/tree-sitter-cpp.wasm";case".json":case".jsonc":return"tree-sitter-json/tree-sitter-json.wasm";case".yaml":case".yml":return"@tree-sitter-grammars/tree-sitter-yaml/tree-sitter-yaml.wasm";case".toml":return"@tree-sitter-grammars/tree-sitter-toml/tree-sitter-toml.wasm";default:return}}c(U,"grammarWasmPath");async function H(r){let e=U(r);if(!e)return;T??=p.Parser.init(),await T;let t=A.get(e);if(t===void 0){let o=M.resolve(e);t=p.Language.load(o),A.set(e,t)}let i=await t,a=new p.Parser;return a.setLanguage(i),a}c(H,"ensureParser");async function K(r,e,t,i){let a=await z(r,e,t);try{return await i(a)}finally{a?.delete?.()}}c(K,"withParsedDocument");async function z(r,e,t){if(t.length===0)return;let i=r.includes("://")||L.isAbsolute(r)?r:L.resolve(e,r),a=L.extname(i).toLowerCase(),o=t.join(`
2
+ `),d=await H(a);if(d)try{return d.parse(o)??void 0}finally{d.delete()}return P(a,o)}c(z,"parseDocument");function v(r,e,t){let i=r.slice(Math.max(0,e-1),Math.max(0,t)).join(`
3
+ `);return W("sha1").update(i).digest("hex").slice(0,4).toUpperCase()}c(v,"hashScope");var w=class extends S{static{c(this,"AstScopeTextAnchor")}constructor(e,t,i,a){super(`scope-${e}-${t}${a===void 0?"":`-${a}`}`,i)}};function h(r,e,t,i){return new w(r,e,t,i)}c(h,"createScopeAnchor");var E=class{static{c(this,"AstScopeManager")}async getDocumentScopes(e,t,i){return i.length===0?[]:await K(e,t,i,a=>{if(!a)return[];let o=[];return this.collectCandidates(a.rootNode,o),this.buildEntries(o,i)})}collectCandidates(e,t,i=0,a=!1){if(i>100||!e.isNamed)return;let o=e.type;if(!o||G.has(o)){for(let n of e.namedChildren)this.collectCandidates(n,t,i+1);return}let d=new Set;for(let n of x){let s=e.childForFieldName(n);if(!s?.isNamed)continue;d.add(k(s));let u=s.startPosition.row+1,m=s.endPosition.row+1,l=m-u>=3,g=[...x].some(j=>s.childForFieldName(j)!==null);l&&!g&&t.push({startLine:u,endLine:m,kind:`${o}.${n}`,fromBodyField:!0}),this.collectCandidates(s,t,i+1,!0)}if(![...x].some(n=>e.childForFieldName(n)!==null)&&!a){let n=e.startPosition.row+1,s=e.endPosition.row+1;s-n>=3&&e.namedChildren.length>0&&t.push({startLine:n,endLine:s,kind:o,fromBodyField:!1})}for(let n of e.namedChildren)d.has(k(n))||this.collectCandidates(n,t,i+1)}buildEntries(e,t){let i=new Map;for(let n of e){let s=i.get(n.startLine);(!s||n.endLine>s.endLine||n.endLine===s.endLine&&n.fromBodyField&&!s.fromBodyField)&&i.set(n.startLine,n)}let a=[...i.values()].sort((n,s)=>n.startLine-s.startLine||s.endLine-n.endLine),o=[];for(let n of a)o.some(u=>u.startLine<n.startLine&&u.endLine===n.endLine)||o.push(n);let d=new Map;for(let n of o){let s=v(t,n.startLine,n.endLine);d.set(s,(d.get(s)??0)+1)}let f=new Map;return o.map(n=>{let s=v(t,n.startLine,n.endLine),u=d.get(s)??1,m=(f.get(s)??0)+1;f.set(s,m);let l=u>1?m:void 0;return{name:n.kind,kind:n.kind,startLine:n.startLine,endLine:n.endLine,depth:o.filter(g=>g!==n&&g.startLine<=n.startLine&&g.endLine>=n.endLine&&(g.startLine<n.startLine||g.endLine>n.endLine)).length,hash:s,blockHash:s,...l!==void 0&&{occurrence:l},beginAnchor:h("begin",s,n.startLine,l),endScopeAnchor:h("end",s,n.endLine,l),scopeBeginAnchor:h("begin",s,n.startLine,l),scopeEndAnchor:h("end",s,n.endLine,l)}})}};export{O as a,K as b,E as c};
@@ -1,4 +1,4 @@
1
- import{a as p}from"./chunk-5BGWNYQS.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Worker as L}from"node:worker_threads";var x=String.raw`
1
+ import{a as x}from"./chunk-P7FUD4WY.js";import{a}from"./chunk-EI7MMDWY.js";import{Worker as v}from"node:worker_threads";var y=String.raw`
2
2
  const { parentPort, workerData } = require("node:worker_threads");
3
3
  let fuzzy;
4
4
  let prepared;
@@ -96,14 +96,16 @@ parentPort.once("message", (message) => {
96
96
  prepare().catch((error) => {
97
97
  parentPort.postMessage({ kind: "failed", message: error instanceof Error ? error.message : String(error) });
98
98
  });
99
- `;async function b(n,e,r){if(e.rejection.code==="ambiguous"){let i=v(n,e,r.exactCandidateLimit);return{kind:"candidates",total:i.total,candidates:i.ranges.map((a,c)=>({rank:c+1,range:a}))}}if(e.rejection.code!=="missing"||!z(n,e.content,r))return{kind:"unavailable"};if(e.signal!==void 0&&e.signal.aborted)return{kind:"failed",error:e.signal.reason};let t=await R(n,e.lines,r,e.signal);if(t.kind!=="blocks")return t.outcome;let o=[];for(let[i,a]of t.blocks.entries()){let c=e.lines[a.endLine-1];if(c===void 0)return{kind:"failed",error:new Error("Fuzzy Worker returned an invalid source range")};o.push({rank:i+1,range:{start:{lineNumber:a.startLine,column:0},end:{lineNumber:a.endLine,column:c.length}}})}return{kind:"candidates",candidates:o,total:o.length}}s(b,"recoverExactText");function z(n,e,r){if(!r.fuzzyEnabled||n.replace(/\s/gu,"").length<4)return!1;let t=new TextEncoder;return t.encode(n).byteLength<=r.maxQuerySizeKiB*1024&&t.encode(e).byteLength<=r.maxFileSizeMiB*1024*1024}s(z,"canSearch");function R(n,e,r,t){return new Promise(o=>{let i=new L(x,{eval:!0,workerData:{moduleUrl:import.meta.resolve("fast-fuzzy"),value:n,sourceLines:e,config:r}}),a=!1,c,l=s(u=>{a||(a=!0,c!==void 0&&clearTimeout(c),t!==void 0&&t.removeEventListener("abort",d),i.terminate(),o(u))},"finish"),d=s(()=>{t!==void 0&&l({kind:"outcome",outcome:{kind:"failed",error:t.reason}})},"abort");t!==void 0&&t.addEventListener("abort",d,{once:!0}),i.on("error",u=>l({kind:"outcome",outcome:{kind:"failed",error:u}})),i.on("message",u=>{if(u.kind==="ready"){c=setTimeout(()=>l({kind:"outcome",outcome:{kind:"timed-out"}}),r.timeoutMs),i.postMessage("search",[]);return}if(u.kind==="failed"){l({kind:"outcome",outcome:{kind:"failed",error:new Error(u.message??"Fuzzy Worker failed")}});return}if(u.blocks===void 0){l({kind:"outcome",outcome:{kind:"failed",error:new Error("Fuzzy Worker omitted result blocks")}});return}l({kind:"blocks",blocks:u.blocks})})})}s(R,"runFuzzyWorker");function q(n,e=()=>!1){return{id:"exact-text",description:"Any non-empty value not handled as a structured anchor selects one unique exact text span.",renderFull(r){return r},renderCompact(){return"selected text"},tryResolve(r,t){return Promise.resolve(e(t.source,t.cwd)?m("invalid","Exact-text editing is blocked for this file; use a current returned anchor for the next edit."):T(r,t))},recover(r,t){return b(r,t,n)}}}s(q,"createExactTextAnchorResolver");function T(n,e){if(n.length===0)return m("invalid","exact text anchor must be non-empty");let r=g(h(e.content)),t=g(h(n)).text,o=A(r.text,t,2);if(o.length===0)return m("missing","exact text anchor was not found");if(o.length>1)return m("ambiguous","exact text anchor matched more than once");let i=o[0];if(i===void 0)return{kind:"failed",error:new Error("Exact match index is missing")};let a=e.content.startsWith("\uFEFF")?1:0,c=a+k(r.boundaries,i),l=a+k(r.boundaries,i+t.length),d=w(e.content,c,l),u=d&&!t.endsWith(`
100
- `)?E(e.content,l):l,y={start:f(e.content,c),end:f(e.content,u),...d&&{linewise:!0}};return{kind:"resolved",anchor:new p(n,e.source,[y],[{start:y.start,end:f(e.content,l)}])}}s(T,"resolveExactTextAnchor");function v(n,e,r){let t=g(h(e.content)),o=g(h(n)).text;if(o.length===0)return{ranges:[],total:0};let i=C(t.text,o,r),a=e.content.startsWith("\uFEFF")?1:0;return{total:i.total,ranges:i.starts.map(c=>({start:f(e.content,a+k(t.boundaries,c)),end:f(e.content,a+k(t.boundaries,c+o.length))}))}}s(v,"findExactTextMatches");function w(n,e,r){let t=e===0||n[e-1]===`
101
- `||n[e-1]==="\r",o=r===n.length||n[r]===`
102
- `||n[r]==="\r"||n[r-1]===`
103
- `||n[r-1]==="\r";return t&&o}s(w,"isWholeLineMatch");function E(n,e){return n[e]==="\r"&&n[e+1]===`
104
- `?e+2:n[e]==="\r"||n[e]===`
105
- `?e+1:e}s(E,"includeTrailingLineBreak");function m(n,e){return{kind:"rejected",rejection:{code:n,reason:e}}}s(m,"rejected");function h(n){return n.startsWith("\uFEFF")?n.slice(1):n}s(h,"stripInitialBom");function g(n){let e=[],r=[0];for(let t=0;t<n.length;t+=1){let o=n[t];if(o==="\r"){let i=n[t+1]===`
106
- `?2:1;e.push(`
107
- `),t+=i-1,r.push(t+1);continue}e.push(o??""),r.push(t+1)}return{text:e.join(""),boundaries:r}}s(g,"normalizeText");function A(n,e,r){if(e.length===0)return[];let t=[],o=0;for(;t.length<r&&o<=n.length-e.length;){let i=n.indexOf(e,o);if(i===-1)break;t.push(i),o=i+1}return t}s(A,"overlappingMatches");function C(n,e,r){if(e.length===0)return{starts:[],total:0};let t=[],o=0,i=0;for(;i<=n.length-e.length;){let a=n.indexOf(e,i);if(a===-1)break;o+=1,t.length<r&&t.push(a),i=a+1}return{starts:t,total:o}}s(C,"scanMatches");function k(n,e){let r=n[e];if(r===void 0)throw new RangeError("Exact text match is outside normalized source boundaries");return r}s(k,"boundaryAt");function f(n,e){let r=1,t=0;for(let o=0;o<e;o+=1){let i=n[o];i==="\r"?(n[o+1]===`
108
- `&&(o+=1),r+=1,t=0):i===`
109
- `?(r+=1,t=0):t+=1}return{lineNumber:r,column:t}}s(f,"positionAt");export{q as a,T as b,v as c};
99
+ `;async function p(e,n,r){if(n.rejection.code==="ambiguous"){let i=b(e,n,r.exactCandidateLimit);return{kind:"candidates",total:i.total,candidates:i.ranges.map((s,c)=>({rank:c+1,range:s}))}}if(n.rejection.code!=="missing"||!z(e,n.content,r))return{kind:"unavailable"};if(n.signal!==void 0&&n.signal.aborted)return{kind:"failed",error:n.signal.reason};let t=await R(e,n.lines,r,n.signal);if(t.kind!=="blocks")return t.outcome;let o=[];for(let[i,s]of t.blocks.entries()){let c=n.lines[s.endLine-1];if(c===void 0)return{kind:"failed",error:new Error("Fuzzy Worker returned an invalid source range")};o.push({rank:i+1,range:{start:{lineNumber:s.startLine,column:0},end:{lineNumber:s.endLine,column:c.length}}})}return{kind:"candidates",candidates:o,total:o.length}}a(p,"recoverExactText");function z(e,n,r){if(!r.fuzzyEnabled||e.replace(/\s/gu,"").length<4)return!1;let t=new TextEncoder;return t.encode(e).byteLength<=r.maxQuerySizeKiB*1024&&t.encode(n).byteLength<=r.maxFileSizeMiB*1024*1024}a(z,"canSearch");function R(e,n,r,t){return new Promise(o=>{let i=new v(y,{eval:!0,workerData:{moduleUrl:import.meta.resolve("fast-fuzzy"),value:e,sourceLines:n,config:r}}),s=!1,c,l=a(u=>{s||(s=!0,c!==void 0&&clearTimeout(c),t!==void 0&&t.removeEventListener("abort",d),i.terminate(),o(u))},"finish"),d=a(()=>{t!==void 0&&l({kind:"outcome",outcome:{kind:"failed",error:t.reason}})},"abort");t!==void 0&&t.addEventListener("abort",d,{once:!0}),i.on("error",u=>l({kind:"outcome",outcome:{kind:"failed",error:u}})),i.on("message",u=>{if(u.kind==="ready"){c=setTimeout(()=>l({kind:"outcome",outcome:{kind:"timed-out"}}),r.timeoutMs),i.postMessage("search",[]);return}if(u.kind==="failed"){l({kind:"outcome",outcome:{kind:"failed",error:new Error(u.message??"Fuzzy Worker failed")}});return}if(u.blocks===void 0){l({kind:"outcome",outcome:{kind:"failed",error:new Error("Fuzzy Worker omitted result blocks")}});return}l({kind:"blocks",blocks:u.blocks})})})}a(R,"runFuzzyWorker");function D(e,n=()=>!1){return{id:"exact-text",description:"Any non-empty value not handled as a structured anchor selects one unique exact text span.",renderFull(r){return r},renderCompact(){return"selected text"},tryResolve(r,t){return Promise.resolve(n(t.source,t.cwd)?m("invalid","Exact-text editing is blocked for this file; use a current returned anchor for the next edit."):T(r,t))},recover(r,t){return p(r,t,e)}}}a(D,"createExactTextAnchorResolver");function T(e,n){if(e.length===0)return m("invalid","exact text anchor must be non-empty");let r=g(h(n.content)),t=g(h(e)).text,o=A(r.text,t,2);if(o.length===0)return m("missing","exact text anchor was not found");if(o.length>1)return m("ambiguous","exact text anchor matched more than once");let i=o[0];if(i===void 0)return{kind:"failed",error:new Error("Exact match index is missing")};let s=n.content.startsWith("\uFEFF")?1:0,c=s+r.sourceOffset(i),l=s+r.sourceOffset(i+t.length),d=w(n.content,c,l),u=d&&!t.endsWith(`
100
+ `)?O(n.content,l):l,k={start:f(n.content,c),end:f(n.content,u),...d&&{linewise:!0}};return{kind:"resolved",anchor:new x(e,n.source,[k],[{start:k.start,end:f(n.content,l)}])}}a(T,"resolveExactTextAnchor");function b(e,n,r){let t=g(h(n.content)),o=g(h(e)).text;if(o.length===0)return{ranges:[],total:0};let i=C(t.text,o,r),s=n.content.startsWith("\uFEFF")?1:0;return{total:i.total,ranges:i.starts.map(c=>({start:f(n.content,s+t.sourceOffset(c)),end:f(n.content,s+t.sourceOffset(c+o.length))}))}}a(b,"findExactTextMatches");function w(e,n,r){let t=n===0||e[n-1]===`
101
+ `||e[n-1]==="\r",o=r===e.length||e[r]===`
102
+ `||e[r]==="\r"||e[r-1]===`
103
+ `||e[r-1]==="\r";return t&&o}a(w,"isWholeLineMatch");function O(e,n){return e[n]==="\r"&&e[n+1]===`
104
+ `?n+2:e[n]==="\r"||e[n]===`
105
+ `?n+1:n}a(O,"includeTrailingLineBreak");function m(e,n){return{kind:"rejected",rejection:{code:e,reason:n}}}a(m,"rejected");function h(e){return e.startsWith("\uFEFF")?e.slice(1):e}a(h,"stripInitialBom");function g(e){if(!e.includes("\r"))return{text:e,sourceOffset:a(o=>L(o,e.length),"sourceOffset")};let n=[],r=0;for(let o=e.indexOf(`\r
106
+ `);o!==-1;o=e.indexOf(`\r
107
+ `,o+2))n.push(o-r),r+=1;let t=e.replace(/\r\n?/gu,`
108
+ `);return{text:t,sourceOffset:a(o=>L(o,t.length)+E(n,o),"sourceOffset")}}a(g,"normalizeText");function L(e,n){if(e<0||e>n)throw new RangeError("Exact text match is outside normalized source boundaries");return e}a(L,"checkedOffset");function E(e,n){let r=0,t=e.length;for(;r<t;){let o=r+t>>>1;(e[o]??1/0)<n?r=o+1:t=o}return r}a(E,"countBefore");function A(e,n,r){if(n.length===0)return[];let t=[],o=0;for(;t.length<r&&o<=e.length-n.length;){let i=e.indexOf(n,o);if(i===-1)break;t.push(i),o=i+1}return t}a(A,"overlappingMatches");function C(e,n,r){if(n.length===0)return{starts:[],total:0};let t=[],o=0,i=0;for(;i<=e.length-n.length;){let s=e.indexOf(n,i);if(s===-1)break;o+=1,t.length<r&&t.push(s),i=s+1}return{starts:t,total:o}}a(C,"scanMatches");function f(e,n){let r=1,t=0,o=e.indexOf("\r"),i=e.indexOf(`
109
+ `);for(;;){let s=o===-1?i:i===-1?o:Math.min(o,i);if(s===-1||s>=n)break;t=e[s]==="\r"&&e[s+1]===`
110
+ `?s+2:s+1,r+=1,o!==-1&&o<t&&(o=e.indexOf("\r",t)),i!==-1&&i<t&&(i=e.indexOf(`
111
+ `,t))}return{lineNumber:r,column:Math.max(0,n-t)}}a(f,"positionAt");export{D as a,T as b,b as c};
@@ -1 +1 @@
1
- import{a as _}from"./chunk-AMIIOWFL.js";import{a as A}from"./chunk-LF325WYO.js";import{a as W,g as n}from"./chunk-4IWEKRSP.js";import{a as u}from"./chunk-EI7MMDWY.js";import{Writable as M}from"node:stream";import{callbackify as N}from"node:util";import{fileURLToPath as $,pathToFileURL as G}from"node:url";import{readFile as x}from"node:fs/promises";import U from"node:path";import{createInterface as H}from"node:readline";import{fileURLToPath as j}from"node:url";import{Type as i}from"typebox";import{Value as B}from"typebox/value";var V=i.Union([i.Object({kind:i.Literal("ready")}),i.Object({kind:i.Literal("change"),path:i.String(),type:i.Union([i.Literal(1),i.Literal(2),i.Literal(3)])}),i.Object({kind:i.Literal("error"),code:i.Union([i.Literal("WATCH_FAILED"),i.Literal("WATCH_LIMIT"),i.Literal("WATCH_OVERFLOW")])})]);function J(h,s){let c=U.posix.relative(h,s);return c===""||c!==".."&&!c.startsWith("../")&&!U.posix.isAbsolute(c)}u(J,"inside");function I(h,s,c,e){let r=h.resolve(s);if(!r)throw new n("UNSUPPORTED_SOURCE",s,"not-applied");let d=!1,m=new Map,l=new Set,P=u(o=>d||o.closed,"closed"),p=u(o=>(o.closed=!0,o.channel&&(o.stopping??=o.channel.stop().then(()=>{})),o.stopping??Promise.resolve()),"release"),y={async register(o,w){if(d)throw new n("WATCH_DISPOSED",s,"not-applied");let E=w.map(L=>{let f=L.globPattern,S=typeof f=="string"?s:typeof f.baseUri=="string"?f.baseUri:f.baseUri.uri,g=S.startsWith("file://")?W(r.location.target,j(S)).source:S,v=h.resolve(g);if(!v||v.location.target!==r.location.target)throw new n("UNSUPPORTED_SOURCE",g,"not-applied");let O=L.kind??7;if(!Number.isInteger(O)||O<0||O>7)throw new TypeError("Invalid file watcher event mask");return{root:v.location.path,expression:typeof f=="string"?f:f.pattern,kind:O}});if(E.length===0){await y.unregister(o);return}let t={id:o,closed:!1,starting:Promise.resolve()};l.add(t),t.starting=(async()=>{let L=await x(new URL("./file-watch-worker.py",new URL("../src/backend/lsp-file-watchers.ts",import.meta.url).href),"utf8");if(P(t))throw new n("WATCH_DISPOSED",s,"not-applied");let f=await r.backend.startProcess("python3",["-u","-c",L,JSON.stringify([...new Set(E.map(k=>k.root))])],r.location.path);if(t.channel=f,f.stderr.resume(),P(t))throw await p(t),new n("WATCH_DISPOSED",s,"not-applied");let S=H({input:f.stdout}),g=!1,v=!1;if(await new Promise((k,b)=>{let R=u(C=>{if(v||t.closed)return;v=!0;let a=new n(C,s,"not-applied");g?e(a):b(a),p(t).catch(e)},"fail");S.on("line",C=>{if(t.closed)return;let a;try{a=JSON.parse(C)}catch{R("INVALID_RESPONSE");return}if(!B.Check(V,a)){R("INVALID_RESPONSE");return}if(a.kind==="ready"){g=!0,k();return}if(a.kind==="error"){R(a.code);return}if(!g){R("INVALID_RESPONSE");return}if(m.get(o)!==t)return;E.some(T=>{if(!J(T.root,a.path))return!1;let F=U.posix.relative(T.root,a.path);return(T.kind&(a.type===1?1:a.type===2?2:4))!==0&&U.matchesGlob(U.posix.isAbsolute(T.expression)?a.path:F,T.expression)})&&c({uri:W(r.location.target,a.path).source,type:a.type})}),f.completion.then(()=>{S.close(),g?t.closed||R("WATCH_FAILED"):b(new n("WATCH_FAILED",s,"not-applied"))},()=>{S.close(),g?t.closed||R("WATCH_FAILED"):b(new n("WATCH_FAILED",s,"not-applied"))})}),P(t))throw await p(t),new n("WATCH_DISPOSED",s,"not-applied");let D=m.get(o);m.set(o,t),D&&await p(D)})();try{await t.starting}catch(L){throw await p(t),L}finally{l.delete(t)}},async unregister(o){let w=m.get(o);m.delete(o);let E=[...l].filter(t=>t.id===o);await Promise.all([...E,...w?[w]:[]].map(p)),await Promise.allSettled(E.map(t=>t.starting))},async dispose(){d=!0;let o=new Set([...m.keys(),...[...l].map(w=>w.id)]);await Promise.all([...o].map(w=>y.unregister(w)))}};return y}u(I,"createSshLspFileWatchers");function he(h,s){let c=h.resolve(s);if(!c)throw new n("UNSUPPORTED_SOURCE",s,"not-applied");return{async start(e){let r=h.resolve(e.rootUri);if(!r||r.location.target!==c.location.target)throw new n("UNSUPPORTED_SOURCE",e.rootUri,"not-applied");let d=e.command.map(p=>p.replaceAll("{project}",r.location.path));if(!d[0])throw new TypeError("Language server command is empty");let m=Object.entries(await A(r.backend,r.location.path,e.env,e.signal)).map(([p,y])=>`${p}=${y}`),l=await r.backend.startProcess("env",[...m,...d],r.location.path,{signal:e.signal}),P=new M({write:N(async(p,y)=>{await l.write(p)}),final:N(async()=>{await l.end()})});return{stdin:P,stdout:l.stdout,stderr:l.stderr,completion:l.completion,remote:{target:r.location.target,pid:l.pid},async stop(){try{await _(l,h,e.rootUri)}finally{P.destroy()}}}},fileWatchers(e,r,d){let m=h.resolve(e);if(!m||m.location.target!==c.location.target)throw new n("UNSUPPORTED_SOURCE",e,"not-applied");return I(h,e,r,d)},toServerUri(e){if(!e.startsWith("ssh://")){if(e.startsWith("file://"))throw new n("UNSUPPORTED_SOURCE",e,"not-applied");return e}let r=h.resolve(e);if(!r||r.location.target!==c.location.target)throw new n("UNSUPPORTED_SOURCE",e,"not-applied");return G(r.location.path).href},fromServerUri(e){return e.startsWith("file://")?W(c.location.target,$(e)).source:e}}}u(he,"createSshLspTransport");export{he as a};
1
+ import{a as _}from"./chunk-KX7MG72M.js";import{a as A}from"./chunk-FTECKRK6.js";import{a as W,g as n}from"./chunk-KJAR2WDO.js";import{a as u}from"./chunk-EI7MMDWY.js";import{Writable as M}from"node:stream";import{callbackify as N}from"node:util";import{fileURLToPath as $,pathToFileURL as G}from"node:url";import{readFile as x}from"node:fs/promises";import U from"node:path";import{createInterface as H}from"node:readline";import{fileURLToPath as B}from"node:url";import{Type as i}from"typebox";import{Value as j}from"typebox/value";var V=i.Union([i.Object({kind:i.Literal("ready")}),i.Object({kind:i.Literal("change"),path:i.String(),type:i.Union([i.Literal(1),i.Literal(2),i.Literal(3)])}),i.Object({kind:i.Literal("error"),code:i.Union([i.Literal("WATCH_FAILED"),i.Literal("WATCH_LIMIT"),i.Literal("WATCH_OVERFLOW")])})]);function J(h,s){let c=U.posix.relative(h,s);return c===""||c!==".."&&!c.startsWith("../")&&!U.posix.isAbsolute(c)}u(J,"inside");function I(h,s,c,t){let r=h.resolve(s);if(!r)throw new n("UNSUPPORTED_SOURCE",s,"not-applied");let d=!1,m=new Map,l=new Set,P=u(o=>d||o.closed,"closed"),p=u(o=>(o.closed=!0,o.channel&&(o.stopping??=o.channel.stop().then(()=>{})),o.stopping??Promise.resolve()),"release"),y={async register(o,w){if(d)throw new n("WATCH_DISPOSED",s,"not-applied");let E=w.map(L=>{let f=L.globPattern,S=typeof f=="string"?s:typeof f.baseUri=="string"?f.baseUri:f.baseUri.uri,g=S.startsWith("file://")?W(r.location.target,B(S)).source:S,v=h.resolve(g);if(!v||v.location.target!==r.location.target)throw new n("UNSUPPORTED_SOURCE",g,"not-applied");let O=L.kind??7;if(!Number.isInteger(O)||O<0||O>7)throw new TypeError("Invalid file watcher event mask");return{root:v.location.path,expression:typeof f=="string"?f:f.pattern,kind:O}});if(E.length===0){await y.unregister(o);return}let e={id:o,closed:!1,starting:Promise.resolve()};l.add(e),e.starting=(async()=>{let L=await x(new URL("./file-watch-worker.py",new URL("../src/backend/lsp-file-watchers.ts",import.meta.url).href),"utf8");if(P(e))throw new n("WATCH_DISPOSED",s,"not-applied");let f=await r.backend.startProcess("python3",["-u","-c",L,JSON.stringify([...new Set(E.map(k=>k.root))])],r.location.path);if(e.channel=f,f.stderr.resume(),P(e))throw await p(e),new n("WATCH_DISPOSED",s,"not-applied");let S=H({input:f.stdout}),g=!1,v=!1;if(await new Promise((k,b)=>{let R=u(C=>{if(v||e.closed)return;v=!0;let a=new n(C,s,"not-applied");g?t(a):b(a),p(e).catch(t)},"fail");S.on("line",C=>{if(e.closed)return;let a;try{a=JSON.parse(C)}catch{R("INVALID_RESPONSE");return}if(!j.Check(V,a)){R("INVALID_RESPONSE");return}if(a.kind==="ready"){g=!0,k();return}if(a.kind==="error"){R(a.code);return}if(!g){R("INVALID_RESPONSE");return}if(m.get(o)!==e)return;E.some(T=>{if(!J(T.root,a.path))return!1;let F=U.posix.relative(T.root,a.path);return(T.kind&(a.type===1?1:a.type===2?2:4))!==0&&U.matchesGlob(U.posix.isAbsolute(T.expression)?a.path:F,T.expression)})&&c({uri:W(r.location.target,a.path).source,type:a.type})}),f.completion.then(()=>{S.close(),g?e.closed||R("WATCH_FAILED"):b(new n("WATCH_FAILED",s,"not-applied"))},()=>{S.close(),g?e.closed||R("WATCH_FAILED"):b(new n("WATCH_FAILED",s,"not-applied"))})}),P(e))throw await p(e),new n("WATCH_DISPOSED",s,"not-applied");let D=m.get(o);m.set(o,e),D&&await p(D)})();try{await e.starting}catch(L){throw await p(e),L}finally{l.delete(e)}},async unregister(o){let w=m.get(o);m.delete(o);let E=[...l].filter(e=>e.id===o);await Promise.all([...E,...w?[w]:[]].map(p)),await Promise.allSettled(E.map(e=>e.starting))},async dispose(){d=!0;let o=new Set([...m.keys(),...[...l].map(w=>w.id)]);await Promise.all([...o].map(w=>y.unregister(w)))}};return y}u(I,"createSshLspFileWatchers");function ht(h,s){let c=h.resolve(s);if(!c)throw new n("UNSUPPORTED_SOURCE",s,"not-applied");return{async start(t){let r=h.resolve(t.rootUri);if(!r||r.location.target!==c.location.target)throw new n("UNSUPPORTED_SOURCE",t.rootUri,"not-applied");let d=t.command.map(p=>p.replaceAll("{project}",r.location.path));if(!d[0])throw new TypeError("Language server command is empty");let m=Object.entries(await A(r.backend,r.location.path,t.env,t.signal)).map(([p,y])=>`${p}=${y}`),l=await r.backend.startProcess("env",[...m,...d],r.location.path,{signal:t.signal}),P=new M({write:N(async(p,y)=>{await l.write(p)}),final:N(async()=>{await l.end()})});return{stdin:P,stdout:l.stdout,stderr:l.stderr,completion:l.completion,remote:{target:r.location.target,pid:l.pid},async stop(){try{await _(l,h,t.rootUri)}finally{P.destroy()}}}},fileWatchers(t,r,d){let m=h.resolve(t);if(!m||m.location.target!==c.location.target)throw new n("UNSUPPORTED_SOURCE",t,"not-applied");return I(h,t,r,d)},toServerUri(t){if(!t.startsWith("ssh://")){if(t.startsWith("file://"))throw new n("UNSUPPORTED_SOURCE",t,"not-applied");return t}let r=h.resolve(t);if(!r||r.location.target!==c.location.target)throw new n("UNSUPPORTED_SOURCE",t,"not-applied");return G(r.location.path).href},fromServerUri(t){return t.startsWith("file://")?W(c.location.target,$(t)).source:t}}}u(ht,"createSshLspTransport");export{ht as a};
@@ -1,4 +1,4 @@
1
- import{a as le,b as fe,c as ue}from"./chunk-WQIMM4SU.js";import{a as de}from"./chunk-FHRHYY4M.js";import{a as N,g as l}from"./chunk-4IWEKRSP.js";import{c as ce}from"./chunk-XHFAV2NI.js";import"./chunk-NNCZYO4Q.js";import{a as ne}from"./chunk-47SPPIXK.js";import{a as te,b as re}from"./chunk-VAXLSPPU.js";import{f as Z,g as ee}from"./chunk-KN6VPARZ.js";import{d as q}from"./chunk-OMNKD7WW.js";import"./chunk-PS2B6THP.js";import{a as ie}from"./chunk-GXL4NMHR.js";import{b as x,c as Q,d as X}from"./chunk-PQWANILR.js";import{a as W}from"./chunk-BU7IZLKB.js";import{a as $,b as K}from"./chunk-S5PL5DFQ.js";import{I as H}from"./chunk-DDH3FP4G.js";import{r as J}from"./chunk-VDJSH3DQ.js";import"./chunk-ZC65Z3CK.js";import{a as se}from"./chunk-ZAWRSA7N.js";import{a as oe,b as ae}from"./chunk-OFILFO6D.js";import{a as s}from"./chunk-EI7MMDWY.js";import pe from"node:path";import{StringDecoder as Oe}from"node:string_decoder";function he(r){return(o,a)=>{let i=r.resolve(o.path??".",a.cwd);if(i===void 0)return;let{backend:c,location:w}=i,e=s((t,n=w.source)=>{let m=r.resolve(t,n);if(m===void 0||m.backend!==c)throw new l("UNSUPPORTED_SOURCE",t,"not-applied");return m.location},"own");return{resolve:s((t,n)=>e(n,t.includes("://")?t:w.source).source,"resolve"),dirname:s(t=>N(w.target,pe.posix.dirname(e(t).path)).source,"dirname"),basename:s(t=>pe.posix.basename(e(t).path),"basename"),isDirectory:s(async(t,n)=>(await c.stat(e(t).path,{signal:n})).kind==="directory","isDirectory"),byteSize:s(async(t,n)=>(await c.stat(e(t).path,{signal:n})).size,"byteSize"),readText:s(async(t,n)=>(await c.read(e(t).path,{signal:n})).bytes.toString("utf8"),"readText"),async execute(t,n,m,R){let d=await c.execute(t,n,e(m).path,{signal:R});return{code:d.exitCode,stdout:d.stdout.toString("utf8"),stderr:d.stderr.toString("utf8")}},async runLines(t,n,m,R){let d=await c.startProcess("rg",t,e(n).path,{signal:R}),g=new Oe("utf8"),u=[],p=0,f="",h,y=s(E=>{let k=E.split(`
1
+ import{a as le,b as fe,c as ue}from"./chunk-V2D5MLGE.js";import{a as de}from"./chunk-5W6QQZFI.js";import{a as N,g as l}from"./chunk-KJAR2WDO.js";import{c as ce}from"./chunk-XHFAV2NI.js";import"./chunk-NNCZYO4Q.js";import{a as ne}from"./chunk-47SPPIXK.js";import{a as te,b as re}from"./chunk-VAXLSPPU.js";import{f as Z,g as ee}from"./chunk-KN6VPARZ.js";import{d as q}from"./chunk-LY2UANKU.js";import"./chunk-PS2B6THP.js";import{a as ie}from"./chunk-YZTVC7ME.js";import{b as x,c as Q,d as X}from"./chunk-VDSSAP6Y.js";import{a as W}from"./chunk-2DSY4U73.js";import{a as $,b as K}from"./chunk-H6FEBUAP.js";import{I as H}from"./chunk-SIYPD5MM.js";import{r as J}from"./chunk-S7E2D5K7.js";import"./chunk-ZC65Z3CK.js";import{a as se}from"./chunk-ZAWRSA7N.js";import{a as oe,b as ae}from"./chunk-OFILFO6D.js";import{a as s}from"./chunk-EI7MMDWY.js";import pe from"node:path";import{StringDecoder as Oe}from"node:string_decoder";function he(r){return(o,a)=>{let i=r.resolve(o.path??".",a.cwd);if(i===void 0)return;let{backend:c,location:w}=i,e=s((t,n=w.source)=>{let m=r.resolve(t,n);if(m===void 0||m.backend!==c)throw new l("UNSUPPORTED_SOURCE",t,"not-applied");return m.location},"own");return{resolve:s((t,n)=>e(n,t.includes("://")?t:w.source).source,"resolve"),dirname:s(t=>N(w.target,pe.posix.dirname(e(t).path)).source,"dirname"),basename:s(t=>pe.posix.basename(e(t).path),"basename"),isDirectory:s(async(t,n)=>(await c.stat(e(t).path,{signal:n})).kind==="directory","isDirectory"),byteSize:s(async(t,n)=>(await c.stat(e(t).path,{signal:n})).size,"byteSize"),readText:s(async(t,n)=>(await c.read(e(t).path,{signal:n})).bytes.toString("utf8"),"readText"),async execute(t,n,m,R){let d=await c.execute(t,n,e(m).path,{signal:R});return{code:d.exitCode,stdout:d.stdout.toString("utf8"),stderr:d.stderr.toString("utf8")}},async runLines(t,n,m,R){let d=await c.startProcess("rg",t,e(n).path,{signal:R}),g=new Oe("utf8"),u=[],p=0,f="",h,y=s(E=>{let k=E.split(`
2
2
  `);for(let[O,b]of k.entries()){if(u.push(b),p+=Buffer.byteLength(b),p>32*1024*1024)throw new l("CONTENT_LIMIT",w.source,"not-applied");O<k.length-1&&(m(u.join("")),u.length=0,p=0)}},"consume"),v=(async()=>{try{for await(let E of d.stdout)y(g.write(E));y(g.end()),p>0&&m(u.join(""))}catch(E){h=E,await d.stop()}})(),T=(async()=>{for await(let E of d.stderr)f+=E.toString("utf8"),f.length>65536&&(f=f.slice(-65536))})();try{try{await d.end()}catch(k){if(!(k instanceof l)||k.code!=="INPUT_CLOSED")throw k}let E=await d.completion;if(await Promise.all([v,T]),h!==void 0)throw h instanceof Error?h:new Error("Search output failed.",{cause:h});return R?.throwIfAborted(),{code:E.exitCode,stderr:f}}finally{await d.stop(),await Promise.allSettled([v,T])}}}}}s(he,"createSshSearchEnvironmentProvider");import{lstat as Ue,mkdir as Ee,rm as Me,symlink as He,unlink as Ve,open as ze}from"node:fs/promises";import A from"node:path";import{constants as z}from"node:fs";import{createHash as Pe,randomBytes as Te}from"node:crypto";import{constants as we}from"node:fs";import{lstat as Ie,mkdir as Ne,open as me,readFile as Ce,rename as _e,rm as Ae,unlink as Fe}from"node:fs/promises";import D from"node:path";import{fileURLToPath as Le}from"node:url";function C(r,o,a){if(a?.has(r)&&a.get(r)!==o)throw new l("CONFLICT",r,"not-applied")}s(C,"checkCapturedRevision");var Be=1024*1024,De=Ce(new URL("./ssh-transfer-worker.py",new URL("../src/backend/file-transfer.ts",import.meta.url).href),"utf8");function j(r,o){if(r.startsWith("file:"))try{return Le(r)}catch{throw new l("UNSUPPORTED_SOURCE",r,"not-applied")}if(/^[a-z][a-z\d+.-]*:/iu.test(r)&&!/^[a-z]:[\\/]/iu.test(r))throw new l("UNSUPPORTED_SOURCE",r,"not-applied");if(o.startsWith("ssh://"))throw new l("UNSUPPORTED_SOURCE",r,"not-applied");return D.resolve(o,r)}s(j,"localTransferSource");function F(r){return[r.dev,r.ino,r.mode,r.uid,r.gid,r.size,r.mtimeNs,r.ctimeNs].join(":")}s(F,"localRevision");async function U(r){let o=await Ie(r,{bigint:!0});if(!o.isFile()||o.isSymbolicLink())throw new l("INVALID_FILE_TYPE",r,"not-applied");if(o.size>BigInt(Number.MAX_SAFE_INTEGER))throw new l("CONTENT_LIMIT",r,"not-applied");return o}s(U,"localEntry");function ye(r){return r!==null&&typeof r=="object"&&"code"in r&&r.code==="ENOENT"}s(ye,"missing");function ge(r){return r!==null&&typeof r=="object"&&"code"in r&&typeof r.code=="string"&&/^[A-Z][A-Z0-9_]*$/u.test(r.code)?r.code:"TRANSFER_FAILED"}s(ge,"errorCode");async function je(r,o,a,i){a.signal?.throwIfAborted();let c=r.resolve(o.path,a.cwd),w=r.resolve(o.target??"",a.cwd),e=c?.location.source??j(o.path,a.cwd),t=w?.location.source??j(o.target??"",a.cwd);if(e===t)throw new l("SAME_FILE",e,"not-applied");let n=c?await c.backend.lstat(c.location.path,a):await U(e);if("kind"in n&&n.kind!=="file")throw new l("INVALID_FILE_TYPE",e,"not-applied");let m=Number(n.size),R=Number(n.mode),d="revision"in n?n.revision:F(n);C(e,d,i);let g;try{g=w?await w.backend.lstat(w.location.path,a):await U(t)}catch(p){if(!ye(p))throw p}if(g!==void 0){if("kind"in g&&g.kind!=="file")throw new l("INVALID_FILE_TYPE",t,"not-applied");if(C(t,"revision"in g?g.revision:F(g),i),c&&w&&c.backend.target.host===w.backend.target.host&&c.backend.target.configFile===w.backend.target.configFile&&"identity"in n&&"identity"in g&&n.identity.device===g.identity.device&&n.identity.inode===g.identity.inode)throw new l("SAME_FILE",e,"not-applied")}let u=g===void 0?null:"revision"in g?g.revision:F(g);return g===void 0&&C(t,null,i),{source:e,target:t,remoteSource:c,remoteTarget:w,size:m,mode:R,sourceRevision:d,targetRevision:u}}s(je,"prepareTransfer");async function V(r,o,a,i,c,w){let{source:e,target:t,remoteSource:n,remoteTarget:m,size:R,mode:d,sourceRevision:g,targetRevision:u}=await je(r,a,i,c);await w?.();let p=n?void 0:await me(e,we.O_RDONLY|we.O_NOFOLLOW),f,h,y,v=!1,T="",E=s(async()=>{let k=n?await n.backend.lstat(n.location.path,i):await U(e);if(("revision"in k?k.revision:F(k))!==g)throw new l("CONFLICT",e,"not-applied")},"verifySource");try{if(p&&F(await p.stat({bigint:!0}))!==g)throw new l("CONFLICT",e,"not-applied");m?(y=await de(m.backend.target,"python3",["-c",await De,JSON.stringify({destination:m.location.path,size:R,mode:d,expected:u})],"/",i),y.completion.catch(()=>{}),y.stdout.on("data",b=>{T.length<=8192&&(T+=b.toString("utf8")),T.length>8192&&y?.stop().catch(()=>{})}),y.stderr.resume()):(await Ne(D.dirname(t),{recursive:!0}),f=D.join(D.dirname(t),`.pi-ide-transfer-${Te(12).toString("hex")}`),h=await me(f,"wx",d&4095));let k=Pe("sha256");for(let b=0;b<R;){i.signal?.throwIfAborted();let S=Math.min(Be,R-b),I;if(n){let P=await n.backend.readRange(n.location.path,b,S,i);if(P.revision!==g||P.offset!==b||P.totalBytes!==R)throw new l("CONFLICT",e,"not-applied");I=P.bytes}else{if(p===void 0)throw new Error("Missing source descriptor");let P=Buffer.allocUnsafe(S),{bytesRead:B}=await p.read(P,0,S,b);I=P.subarray(0,B)}if(I.length===0)throw new l("CONFLICT",e,"not-applied");if(k.update(I),y)await y.write(I);else{if(h===void 0)throw new Error("Missing destination descriptor");for(let P=0;P<I.length;){let B=await h.write(I,P,I.length-P);if(B.bytesWritten===0)throw new l("TRANSFER_FAILED",t,"not-applied");P+=B.bytesWritten}}b+=I.length}await E(),await w?.();let O=k.digest("hex");if(i.signal?.throwIfAborted(),y){if(await y.write(Buffer.from(`${JSON.stringify({sha256:O})}
3
3
  `)),await y.end(),(await y.completion).exitCode!==0||T.length>8192)throw new l("TRANSFER_FAILED",t,"unknown");let S;try{S=JSON.parse(T)}catch{throw new l("INVALID_REPLY",t,"unknown")}if(S===null||typeof S!="object"||!("ok"in S))throw new l("INVALID_REPLY",t,"unknown");if(S.ok!==!0){let I="effect"in S&&(S.effect==="not-applied"||S.effect==="applied")?S.effect:"unknown";throw new l(ge(S),t,I)}if(!("sha256"in S)||S.sha256!==O)throw new l("CHECKSUM_MISMATCH",t,"unknown");v=!0}else{if(h===void 0||f===void 0)throw new Error("Missing staged destination");await h.chmod(d&4095),await h.sync(),await h.close(),h=void 0;let b=null;try{b=F(await U(t))}catch(S){if(!ye(S))throw S}if(b!==u)throw new l("CONFLICT",t,"not-applied");i.signal?.throwIfAborted(),await _e(f,t),f=void 0,v=!0}return o==="move"&&(await E(),n?await n.backend.removeEntry(n.location.path,g,i):await Fe(e)),{source:e,target:t}}catch(k){throw v?new l(ge(k),e,"unknown"):k}finally{await p?.close(),await h?.close(),f!==void 0&&await Ae(f,{force:!0}),y&&await y.stop().catch(()=>{})}}s(V,"transferFile");function Re(r,o,a){let i=r.resolve(o,a.cwd);if(i===void 0){let e=j(o,a.cwd);return{path:e,source:e,cwd:a.cwd,files:x}}let c=r.resolve(a.cwd,a.cwd),w=c?.location.target===i.location.target?c.location.path:i.backend.target.workspace;return{remote:i,source:i.location.source,path:i.location.path,cwd:w,files:{owner:JSON.stringify([i.backend.target.host,i.backend.target.configFile??null]),realpath:s(e=>i.backend.realpath(e,a),"realpath"),inspect:s(e=>i.backend.lstat(e,a),"inspect"),read:s(async e=>(await i.backend.read(e,a)).bytes.toString("utf8"),"read"),git:s((e,t,n)=>i.backend.queryGit(e,t,{...a,signal:n}),"git"),source:s(e=>N(i.location.target,e).source,"source"),snapshot:s((e,t)=>i.backend.objectSnapshot(e,{...a,signal:t}),"snapshot")}}}s(Re,"endpoint");function L(r,o,a){let i=r.remote?A.posix:A;if(i.sep==="\\"&&a.split("/").some(c=>c.includes("\\")||c.includes(":")))throw new l("INVALID_TARGET",r.source,"not-applied");return i.join(o,...a.split("/"))}s(L,"leaf");function G(r,o){return r.remote?N(r.remote.location.target,o).source:o}s(G,"receiptPath");async function _(r,o,a){let i;try{i=await r.files.inspect(o)}catch(c){if(c!==null&&typeof c=="object"&&"code"in c&&c.code==="ENOENT"){if(a===void 0)return}else throw c}if(a===void 0||i?.revision!==a.revision)throw new l("TRANSFER_TARGET_CHANGED",G(r,o),"not-applied")}s(_,"checkEntry");async function M(r){let o;try{o=await Ue(r)}catch(a){if(a===null||typeof a!="object"||!("code"in a)||a.code!=="ENOENT")throw a;await M(A.dirname(r)),await Ee(r);return}if(!o.isDirectory()||o.isSymbolicLink())throw new l("INVALID_FILE_TYPE",r,"not-applied");A.dirname(r)!==r&&await M(A.dirname(r))}s(M,"directoryParents");async function ve(r,o,a,i){r.remote?await r.remote.backend.removeObject(o,a.revision,i):(await _(r,o,a),a.kind==="directory"?await Me(o,{recursive:!0,force:!1}):await Ve(o))}s(ve,"remove");async function ke(r,o,a,i,c,w){let e=Re(r,a.path,i),t=Re(r,a.target??"",i),n=await c.prepareTransfer(o,e,t),m=n.source.entries[0];if(m===void 0)throw new l("ENOENT",e.source,"not-applied");e.remote&&C(e.source,m.revision,w),t.remote&&C(t.source,n.target.entries[0]?.revision??null,w);let R=!1;try{i.signal?.throwIfAborted();for(let d of n.source.entries)L(e,n.source.path,d.relativePath),L(t,n.target.path,d.relativePath);if(n.sourceKind==="file")e.remote&&t.remote&&e.remote.location.target===t.remote.location.target?await e.remote.backend[o](n.source.path,n.target.path,m.revision,n.target.entries[0]?.revision??null,i):await V(r,o,a,i,w,async()=>{await _(e,n.source.path,m),await _(t,n.target.path,n.target.entries[0])});else{if(o==="move"&&e.remote&&t.remote&&e.files.owner===t.files.owner&&await e.remote.backend.moveObject(n.source,n.target,i))return{kind:"file-operation",operation:o,ok:!0,effect:"applied",path:e.source,target:t.source,sourceKind:n.sourceKind};let d=new Map(n.target.entries.map(u=>[u.relativePath,u])),g=new Map;o==="move"&&n.target.entries[0]&&(R=!0,await ve(t,n.target.path,n.target.entries[0],i),d.clear());for(let u of n.source.entries){i.signal?.throwIfAborted();let p=L(e,n.source.path,u.relativePath),f=L(t,n.target.path,u.relativePath);await _(e,p,u);let h=d.get(u.relativePath);if(await _(t,f,h),u.kind==="directory")h===void 0&&(R=!0),t.remote?await t.remote.backend.ensureObjectDirectory(f,u.mode|448,h?.revision??null,i):h===void 0&&(await M(A.dirname(f)),await Ee(f,{mode:u.mode|448})),h===void 0&&g.set(u.relativePath,(await t.files.inspect(f)).identity);else if(u.kind==="symlink"){if(R=!0,u.link===void 0)throw new l("INVALID_RESPONSE",e.source,"unknown");t.remote?await t.remote.backend.createObjectLink(f,u.link,i):(await M(A.dirname(f)),await He(Buffer.from(u.link,"base64"),f))}else{R=!0;let y=G(e,p),v=G(t,f);e.remote&&t.remote&&e.files.owner===t.files.owner?await e.remote.backend.copy(p,f,u.revision,h?.revision??null,i):await V(r,"copy",{path:y,target:v},i,void 0,async()=>{await _(e,p,u),await _(t,f,h)})}}for(let u of[...n.source.entries].reverse()){if(u.kind!=="directory"||d.has(u.relativePath))continue;let p=L(t,n.target.path,u.relativePath),f=await t.files.inspect(p),h=g.get(u.relativePath);if(f.kind!=="directory"||h?.device!==f.identity.device||h.inode!==f.identity.inode)throw new l("TRANSFER_TARGET_CHANGED",t.source,"unknown");if(t.remote)await t.remote.backend.setObjectMode(p,u.mode,f.revision,i);else{let y=await ze(p,z.O_RDONLY|z.O_DIRECTORY|z.O_NOFOLLOW);try{let v=await y.stat();if(String(v.dev)!==h.device||String(v.ino)!==h.inode)throw new l("TRANSFER_TARGET_CHANGED",t.source,"unknown");await y.chmod(u.mode&4095)}finally{await y.close()}}}await n.verifySource(),o==="move"&&await ve(e,n.source.path,m,i)}return{kind:"file-operation",operation:o,ok:!0,effect:"applied",path:e.source,target:t.source,sourceKind:n.sourceKind}}catch(d){throw R?Object.assign(d instanceof Error?d:new Error(String(d)),{effect:"unknown"}):d}}s(ke,"transferObject");function Se(r,o){return async(a,i,c,w)=>{let e=r.resolve(i.path,c.cwd);if(e===void 0&&(i.target===void 0||r.resolve(i.target,c.cwd)===void 0))return;if(a!=="delete"){if(w===void 0)throw new l("TRANSFER_POLICY_REQUIRED",i.path,"not-applied");return ke(r,a,i,c,w,o)}if(e===void 0)return;let t=await e.backend.lstat(e.location.path,c);C(e.location.source,t.revision,o);{if(w===void 0)throw new l("DELETE_POLICY_REQUIRED",e.location.source,"not-applied");let n=r.resolve(c.cwd,c.cwd);if(n!==void 0&&n.location.target!==e.location.target)throw new l("UNSUPPORTED_SOURCE",e.location.source,"not-applied");let m=n?.location.path??e.backend.target.workspace,R=await w.prepare(e.location.path,m,{temporaryEnvironment:s(d=>e.backend.temporaryEnvironment({...c,signal:d}),"temporaryEnvironment"),realpath:s(d=>e.backend.realpath(d,c),"realpath"),inspect:s(d=>e.backend.lstat(d,c),"inspect"),read:s(async d=>(await e.backend.read(d,c)).bytes.toString("utf8"),"read"),git:s((d,g,u)=>e.backend.queryGit(d,g,{...c,signal:u}),"git"),source:s(d=>N(e.location.target,d).source,"source")});if(R.revision!==t.revision)throw new l("DELETE_TARGET_CHANGED",e.location.source,"not-applied");return await e.backend.removeObject(R.resolvedPath,R.revision,c),{kind:"file-operation",operation:a,ok:!0,effect:"applied",path:e.location.source}}}}s(Se,"createSshFileOperationResolver");function Y(r,o,a){return{id:"ssh",async tryResolve(i,c){try{let w=r.resolve(i,c.cwd);if(!w)return{kind:"not-handled"};let{backend:e,location:t}=w,n=!1;try{n=(await e.stat(t.path,c)).kind==="directory"}catch(p){if(!(p instanceof l)||p.code!=="ENOENT")throw p}let m,R,d=s(async p=>{try{let f=await e.read(t.path,p);return m=f.version,f.bytes}catch(f){throw f instanceof l&&f.code==="ENOENT"&&(m=null),f}},"snapshot"),g=s(async p=>{if(R=void 0,n){let h=(await e.list(t.path,p)).map(y=>` ${y.kind==="directory"?"\u{1F4C1}":y.kind==="file"?"\u{1F4C4}":"\u{1F517}"} ${y.name}`);return[{type:"text",text:[`\u{1F4C1} ${t.source}/`,...h.length?["",...h]:[]].join(`
4
4
  `)}]}return R=await d(p),o.convert({source:t.source,bytes:R},p)},"read"),u=s(async(p,f,h)=>{let v=await e.readRange(t.path,p,Math.min(f??4194304,4194304),h),T=[v.bytes],E=v.bytes.length,k=Math.min(f??v.totalBytes,v.totalBytes-v.offset);for(;E<k;){let O=await e.readRange(t.path,v.offset+E,Math.min(k-E,4194304),h);if(O.revision!==v.revision||O.totalBytes!==v.totalBytes||O.offset!==v.offset+E)throw new l("SOURCE_CHANGED",t.source,"not-applied");if(O.bytes.length===0)break;T.push(O.bytes),E+=O.bytes.length}return{bytes:Buffer.concat(T,E),byteOffset:v.offset,totalBytes:v.totalBytes}},"readBytes");return a==="read"||n?{kind:"resolved",resource:{source:t.source,link:t.source,read:g,get sourceBytes(){return R},...n?{}:{readBytes:u}}}:{kind:"resolved",resource:{source:t.source,link:t.source,read:g,readBytes:u,get sourceBytes(){return R},async write(p,f){let h=J(p);if(m===void 0)try{await d(f)}catch(y){if(!(y instanceof l)||y.code!=="ENOENT")throw y}if(m===void 0)throw new l("SNAPSHOT_REQUIRED",t.source,"not-applied");m=await e.write(t.path,Buffer.from(h,"utf8"),m,f)}}}}catch(w){return{kind:"failed",error:w}}}}}s(Y,"createSshResourceResolver");async function be(r,o){let a=await Z({id:"ssh",description:"Set up SSH targets and use remote resources",triggers:[{tool:"read",resourcePrefixes:["ssh://","raw:ssh://","ast:ssh://","web:ssh://"]},{tool:"search",resourcePrefixes:["ssh://","web:ssh://"]},{tool:"debug",resourcePrefixes:["ssh://"]},...["write","replace","insert","delete","copy","move","stage","unstage","undo"].map(n=>({tool:n,resourcePrefixes:["ssh://"]}))]});if(ee(r,[{...a,markdown:`${a.markdown}