pi-agent-ide 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (377) hide show
  1. package/CHANGELOG.md +26 -40
  2. package/README.md +12 -7
  3. package/dist/{chunk-MOJ5RR35.js → chunk-246NTPOS.js} +1 -1
  4. package/dist/{chunk-NULNW6GK.js → chunk-2ITKAXHO.js} +1 -1
  5. package/dist/{chunk-SBNR4WZF.js → chunk-3WO2NOEQ.js} +1 -1
  6. package/dist/{chunk-N7LMRL64.js → chunk-47SPPIXK.js} +1 -1
  7. package/dist/{chunk-EY65TFHJ.js → chunk-4HWKBCBH.js} +1 -1
  8. package/dist/{chunk-JMVDFOTQ.js → chunk-57F5GTHO.js} +1 -1
  9. package/dist/{chunk-KL776TGR.js → chunk-7LOVUWNI.js} +1 -1
  10. package/dist/{chunk-7JV4VN73.js → chunk-A64JRDZK.js} +1 -1
  11. package/dist/{chunk-Z3PGADVA.js → chunk-AIT3YWR5.js} +1 -1
  12. package/dist/{chunk-E4HPRLRB.js → chunk-AKNHSDGV.js} +1 -1
  13. package/dist/{chunk-4XPUN4QN.js → chunk-AUL5FGGK.js} +1 -1
  14. package/dist/chunk-BB4A5UI3.js +5 -0
  15. package/dist/{chunk-CTJV77FR.js → chunk-BQAKA3FU.js} +1 -1
  16. package/dist/{chunk-PNP2KNGP.js → chunk-BR7GRH4A.js} +1 -1
  17. package/dist/{chunk-4OYVLXWD.js → chunk-D4IA2MTA.js} +1 -1
  18. package/dist/{chunk-R5XJSEOE.js → chunk-DXONCYWF.js} +3 -3
  19. package/dist/{chunk-TWWND6NI.js → chunk-E2PHA4SQ.js} +1 -1
  20. package/dist/{chunk-MZXX353D.js → chunk-EMRJP6EM.js} +1 -1
  21. package/dist/{chunk-7HDK3NRQ.js → chunk-GEMDU6XW.js} +1 -1
  22. package/dist/chunk-GNACBJM3.js +1 -0
  23. package/dist/{chunk-3G54ZL2L.js → chunk-HCK7OIQ3.js} +1 -1
  24. package/dist/chunk-HFJGCYFO.js +11 -0
  25. package/dist/{chunk-CSXHCSTH.js → chunk-ID4RJIVZ.js} +1 -1
  26. package/dist/{chunk-SBLKPTL3.js → chunk-JKMXND6V.js} +1 -1
  27. package/dist/{chunk-WE42GBGU.js → chunk-LAJQSHEI.js} +1 -1
  28. package/dist/{chunk-HCN5W76B.js → chunk-LLRUJD62.js} +1 -1
  29. package/dist/{chunk-2K65BSXS.js → chunk-M4TVRCMZ.js} +1 -1
  30. package/dist/{chunk-IUSLSROY.js → chunk-N56WAVYA.js} +1 -1
  31. package/dist/chunk-OI3HBIPK.js +2 -0
  32. package/dist/{chunk-GW6NZQTQ.js → chunk-PRLIHLCS.js} +1 -1
  33. package/dist/{chunk-7TJ6DWW3.js → chunk-Q5X6OXNS.js} +1 -1
  34. package/dist/{chunk-75SWXD2Z.js → chunk-SWA5B5B2.js} +1 -1
  35. package/dist/chunk-T7MWQQIF.js +3 -0
  36. package/dist/{chunk-ICDI27GZ.js → chunk-TGC2ZACO.js} +1 -1
  37. package/dist/{chunk-7NS3QUIE.js → chunk-TXG2H7YQ.js} +1 -1
  38. package/dist/{chunk-RAZP42IQ.js → chunk-VAXLSPPU.js} +1 -1
  39. package/dist/chunk-VMGZMXEM.js +10 -0
  40. package/dist/{chunk-CPZJPGLG.js → chunk-VNTY7BKC.js} +1 -1
  41. package/dist/chunk-W3YFF6OO.js +1 -0
  42. package/dist/{chunk-OLI3JPHJ.js → chunk-W7M3V7FR.js} +1 -1
  43. package/dist/{chunk-UUJJRXHG.js → chunk-WMHSVEIT.js} +1 -1
  44. package/dist/{chunk-OJX3RJ5A.js → chunk-WPBQ45ZL.js} +1 -1
  45. package/dist/{chunk-XZDOVPRC.js → chunk-WXGTU2M6.js} +1 -1
  46. package/dist/{chunk-3ZGDMTMD.js → chunk-XSIKDVAR.js} +1 -1
  47. package/dist/{chunk-QP2QSQ4U.js → chunk-YHREORHH.js} +1 -1
  48. package/dist/chunk-YTYLS2UM.js +1 -0
  49. package/dist/chunk-Z2QGNTGQ.js +1 -0
  50. package/dist/{chunk-UBH6X3D3.js → chunk-ZV5ETNLQ.js} +1 -1
  51. package/dist/entry-11.js +1 -1
  52. package/dist/entry-13.js +1 -1
  53. package/dist/entry-14.js +1 -1
  54. package/dist/entry-15.js +1 -1
  55. package/dist/entry-16.js +1 -1
  56. package/dist/entry-17.js +1 -1
  57. package/dist/entry-18.js +1 -0
  58. package/dist/entry-20.js +1 -1
  59. package/dist/entry-21.js +1 -1
  60. package/dist/entry-22.js +1 -1
  61. package/dist/entry-23.js +1 -1
  62. package/dist/entry-24.js +1 -1
  63. package/dist/entry-25.js +1 -1
  64. package/dist/entry-26.js +1 -2
  65. package/dist/entry-27.js +2 -1
  66. package/dist/entry-28.js +1 -4
  67. package/dist/entry-29.js +4 -1
  68. package/dist/entry-30.js +1 -1
  69. package/dist/entry-31.js +1 -1
  70. package/dist/entry-32.js +1 -18
  71. package/dist/entry-33.js +18 -1
  72. package/dist/entry-34.js +1 -1
  73. package/dist/entry-35.js +1 -1
  74. package/dist/entry-36.js +1 -1
  75. package/dist/entry-37.js +1 -1
  76. package/dist/entry-38.js +1 -1
  77. package/dist/entry-39.js +1 -1
  78. package/dist/entry-40.js +1 -1
  79. package/dist/entry-41.js +1 -1
  80. package/dist/entry-42.js +1 -1
  81. package/dist/entry-43.js +1 -1
  82. package/dist/entry-44.js +1 -1
  83. package/dist/entry-45.js +1 -1
  84. package/dist/entry-46.js +1 -25
  85. package/dist/entry-47.js +25 -1
  86. package/dist/entry-48.js +1 -1
  87. package/dist/entry-49.js +1 -1
  88. package/dist/entry-50.js +1 -1
  89. package/dist/entry-51.js +1 -3
  90. package/dist/entry-52.js +3 -13
  91. package/dist/entry-53.js +13 -1
  92. package/dist/entry-54.js +1 -1
  93. package/dist/entry-55.js +1 -1
  94. package/dist/entry-56.js +1 -1
  95. package/dist/entry-57.js +1 -1
  96. package/dist/entry-58.js +1 -1
  97. package/dist/entry-59.js +1 -1
  98. package/dist/entry-6.js +1 -1
  99. package/dist/entry-60.js +1 -1
  100. package/dist/entry-61.js +1 -1
  101. package/dist/entry-62.js +1 -0
  102. package/dist/entry-63.js +0 -1
  103. package/dist/entry-64.js +1 -0
  104. package/dist/entry-65.js +0 -1
  105. package/dist/entry-66.js +1 -1
  106. package/dist/entry-67.js +1 -1
  107. package/dist/entry-68.js +1 -1
  108. package/dist/entry-69.js +1 -1
  109. package/dist/entry-7.js +1 -1
  110. package/dist/entry-70.js +1 -1
  111. package/dist/entry-71.js +1 -1
  112. package/dist/entry-72.js +1 -0
  113. package/dist/entry-73.js +0 -1
  114. package/dist/entry-74.js +1 -0
  115. package/dist/entry-75.js +0 -1
  116. package/dist/entry-76.js +1 -1
  117. package/dist/entry-77.js +1 -1
  118. package/dist/entry-78.js +1 -80
  119. package/dist/entry-79.js +76 -17
  120. package/dist/entry-80.js +22 -2
  121. package/dist/entry-81.js +2 -1
  122. package/dist/entry-82.js +1 -1
  123. package/dist/entry-83.js +1 -1
  124. package/dist/entry-84.js +1 -3
  125. package/dist/entry-85.js +3 -1
  126. package/dist/entry-86.js +1 -1
  127. package/dist/entry-87.js +1 -1
  128. package/dist/entry-88.js +1 -0
  129. package/dist/pi-agent-ide.js +53 -24
  130. package/docs/agent-guides/search-code.md +3 -1
  131. package/docs/agent-guides/ssh.md +1 -1
  132. package/docs/configuration.md +18 -6
  133. package/docs/development.md +1 -13
  134. package/docs/extensions.md +1 -1
  135. package/docs/releases.md +1 -1
  136. package/docs/settings-help.md +39 -0
  137. package/docs/tools.md +1 -0
  138. package/docs/user-hooks.md +3 -1
  139. package/node_modules/pi-agent-doctor/package.json +7 -10
  140. package/node_modules/pi-agent-documentation/package.json +2 -2
  141. package/node_modules/pi-agent-documentation/runtime/entry-26.js +1 -0
  142. package/node_modules/pi-agent-filesystem/package.json +8 -8
  143. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  144. package/node_modules/pi-agent-filesystem-jq/package.json +6 -7
  145. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  146. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  147. package/node_modules/pi-agent-filesystem-text/runtime/entry-31.js +2 -0
  148. package/node_modules/pi-agent-ide-ast/package.json +15 -41
  149. package/node_modules/pi-agent-ide-ast/runtime/entry-32.js +0 -1
  150. package/node_modules/pi-agent-ide-ast/runtime/entry-33.js +2 -0
  151. package/node_modules/pi-agent-ide-changes/package.json +10 -11
  152. package/node_modules/pi-agent-ide-changes/runtime/entry-34.js +0 -1
  153. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  154. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  155. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  156. package/node_modules/pi-agent-ide-lsp/package.json +10 -13
  157. package/node_modules/pi-agent-ide-lsp/runtime/entry-39.js +2 -0
  158. package/node_modules/pi-agent-image/package.json +3 -3
  159. package/node_modules/pi-agent-invariant/package.json +2 -2
  160. package/node_modules/pi-agent-pdf/package.json +3 -4
  161. package/node_modules/pi-agent-read/package.json +12 -12
  162. package/node_modules/pi-agent-read/runtime/entry-46.js +0 -1
  163. package/node_modules/pi-agent-read/runtime/entry-47.js +2 -0
  164. package/node_modules/pi-agent-resource/package.json +2 -2
  165. package/node_modules/pi-agent-resource/src/result-targets.ts +9 -0
  166. package/node_modules/pi-agent-search/package.json +9 -9
  167. package/node_modules/pi-agent-search/runtime/entry-51.js +0 -1
  168. package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  169. package/node_modules/pi-agent-search/src/api/presentation.ts +10 -2
  170. package/node_modules/pi-agent-search/src/api/search-parameters.ts +1 -1
  171. package/node_modules/pi-agent-search/src/api/search.ts +7 -0
  172. package/node_modules/pi-agent-search/src/core/search-core.ts +23 -3
  173. package/node_modules/pi-agent-search-text/index.ts +2 -0
  174. package/node_modules/pi-agent-search-text/package.json +14 -14
  175. package/node_modules/pi-agent-search-text/runtime/entry-53.js +1 -0
  176. package/node_modules/pi-agent-search-text/src/search-backend.ts +18 -10
  177. package/node_modules/pi-agent-search-text/src/search-session.ts +68 -9
  178. package/node_modules/pi-agent-text/package.json +3 -3
  179. package/node_modules/pi-agent-text/runtime/entry-57.js +1 -0
  180. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  181. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-58.js +2 -0
  182. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -6
  183. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-59.js +0 -1
  184. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-60.js +2 -0
  185. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  186. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-61.js +0 -1
  187. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-62.js +2 -0
  188. package/node_modules/pi-agent-text-editor/package.json +26 -34
  189. package/node_modules/pi-agent-text-editor/runtime/entry-78.js +0 -1
  190. package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +1 -1
  191. package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
  192. package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +6 -12
  193. package/node_modules/pi-agent-text-editor/src/core/extension.ts +1 -0
  194. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +49 -21
  195. package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +18 -9
  196. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +2 -2
  197. package/node_modules/pi-agent-text-editor/src/core/temporary-directories.ts +13 -9
  198. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +16 -8
  199. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +118 -36
  200. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +7 -4
  201. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +6 -8
  202. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +22 -1
  203. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -8
  204. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +22 -0
  205. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  206. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +2 -0
  207. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  208. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  209. package/node_modules/pi-agent-tool-ui/runtime/entry-83.js +1 -0
  210. package/node_modules/pi-agent-web/package.json +8 -11
  211. package/node_modules/pi-agent-web-html/package.json +3 -5
  212. package/node_modules/pi-agent-web-image/package.json +4 -4
  213. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  214. package/node_modules/pi-agent-web-text/package.json +4 -4
  215. package/node_modules/pi-agent-web-text/runtime/entry-88.js +2 -0
  216. package/package.json +43 -39
  217. package/skills/configure-agent-ide/SKILL.md +38 -0
  218. package/src/api/content.ts +6 -0
  219. package/src/api/tips.ts +3 -0
  220. package/src/composite/nested-tool-rendering.ts +16 -5
  221. package/src/composite/preferences.ts +13 -0
  222. package/src/composite/settings-documentation.ts +59 -0
  223. package/src/composite/settings-help.ts +106 -0
  224. package/src/composite/text-results.ts +50 -22
  225. package/src/documentation/extension.ts +12 -0
  226. package/src/documentation/search.ts +166 -0
  227. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
  228. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  229. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +6 -7
  230. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  231. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  232. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-31.js +2 -0
  233. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-27.js +2 -0
  234. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -11
  235. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -5
  236. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  237. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  238. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  239. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-88.js +2 -0
  240. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-84.js +2 -0
  241. package/src/extensions/pi-agent-read/package.json +12 -12
  242. package/src/extensions/pi-agent-read/runtime/entry-46.js +0 -1
  243. package/src/extensions/pi-agent-read/runtime/entry-47.js +2 -0
  244. package/src/extensions/pi-agent-search/package.json +9 -9
  245. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +2 -0
  246. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +14 -14
  247. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +1 -0
  248. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-56.js +1 -0
  249. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +18 -10
  250. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +68 -9
  251. package/src/extensions/pi-agent-search/runtime/entry-51.js +0 -1
  252. package/src/extensions/pi-agent-search/runtime/entry-52.js +2 -0
  253. package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  254. package/src/extensions/pi-agent-search/src/api/presentation.ts +10 -2
  255. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +1 -1
  256. package/src/extensions/pi-agent-search/src/api/search.ts +7 -0
  257. package/src/extensions/pi-agent-search/src/core/search-core.ts +23 -3
  258. package/src/extensions/pi-agent-text-editor/package.json +26 -34
  259. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  260. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-58.js +2 -0
  261. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -6
  262. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-59.js +0 -1
  263. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-60.js +2 -0
  264. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  265. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-61.js +0 -1
  266. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-62.js +2 -0
  267. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -8
  268. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +22 -0
  269. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  270. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +2 -0
  271. package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +0 -1
  272. package/src/extensions/pi-agent-text-editor/runtime/entry-79.js +2 -0
  273. package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +1 -1
  274. package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
  275. package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +6 -12
  276. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +1 -0
  277. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +49 -21
  278. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +18 -9
  279. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +2 -2
  280. package/src/extensions/pi-agent-text-editor/src/core/temporary-directories.ts +13 -9
  281. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +16 -8
  282. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +118 -36
  283. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +7 -4
  284. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +6 -8
  285. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +22 -1
  286. package/src/pi-agent-ide.ts +14 -2
  287. package/src/plugins/pi-agent-ide-ast/package.json +15 -41
  288. package/src/plugins/pi-agent-ide-ast/runtime/entry-32.js +0 -1
  289. package/src/plugins/pi-agent-ide-ast/runtime/entry-33.js +2 -0
  290. package/src/plugins/pi-agent-ide-changes/package.json +10 -11
  291. package/src/plugins/pi-agent-ide-changes/runtime/entry-34.js +0 -1
  292. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  293. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  294. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  295. package/src/plugins/pi-agent-ide-lsp/package.json +10 -13
  296. package/src/plugins/pi-agent-ide-lsp/runtime/entry-39.js +2 -0
  297. package/src/tips/core.ts +5 -2
  298. package/src/tips/extension.ts +30 -2
  299. package/src/tips/persistence.ts +29 -27
  300. package/src/tips/setup-hint.ts +19 -0
  301. package/dist/chunk-5KFVDYCI.js +0 -1
  302. package/dist/chunk-ABFCAOU5.js +0 -1
  303. package/dist/chunk-BIG45IPN.js +0 -2
  304. package/dist/chunk-BMOJTJJJ.js +0 -3
  305. package/dist/chunk-BQ67M4NC.js +0 -3
  306. package/dist/chunk-IH5NW5JX.js +0 -11
  307. package/dist/chunk-NRZO5KJT.js +0 -9
  308. package/dist/chunk-O36UC74T.js +0 -1
  309. package/dist/chunk-SSWUUBIR.js +0 -1
  310. package/dist/entry-19.js +0 -1
  311. package/docs/research/apply-native-capability-matrix.md +0 -174
  312. package/docs/research/apply-read-latency.md +0 -221
  313. package/docs/research/codemode-write-context.md +0 -56
  314. package/docs/research/lpt-393-fuzzy-results/file.json +0 -152
  315. package/docs/research/lpt-393-fuzzy-results/repo.json +0 -122
  316. package/docs/research/lpt-393-search-fuzzy-fallback.md +0 -97
  317. package/docs/research/native-codemode-batch-decision.md +0 -31
  318. package/docs/research/native-codemode-batching.md +0 -65
  319. package/node_modules/pi-agent-doctor/runtime/entry-19.js +0 -1
  320. package/node_modules/pi-agent-filesystem/runtime/entry-26.js +0 -2
  321. package/node_modules/pi-agent-ide-ast/runtime/entry-31.js +0 -1
  322. package/node_modules/pi-agent-ide-changes/runtime/entry-33.js +0 -1
  323. package/node_modules/pi-agent-image/runtime/entry-39.js +0 -1
  324. package/node_modules/pi-agent-resource/runtime/entry-47.js +0 -1
  325. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-57.js +0 -2
  326. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-58.js +0 -1
  327. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-60.js +0 -1
  328. package/node_modules/pi-agent-text-editor/runtime/entry-62.js +0 -1
  329. package/node_modules/pi-agent-tool-call-interception/runtime/entry-81.js +0 -1
  330. package/node_modules/pi-agent-web/runtime/entry-83.js +0 -2
  331. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-27.js +0 -2
  332. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-26.js +0 -2
  333. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-84.js +0 -2
  334. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +0 -2
  335. package/src/extensions/pi-agent-read/runtime/entry-42.js +0 -1
  336. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-52.js +0 -2
  337. package/src/extensions/pi-agent-search/runtime/entry-48.js +0 -1
  338. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-57.js +0 -2
  339. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-58.js +0 -1
  340. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-60.js +0 -1
  341. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-79.js +0 -2
  342. package/src/extensions/pi-agent-text-editor/runtime/entry-62.js +0 -1
  343. package/src/plugins/pi-agent-ide-ast/runtime/entry-31.js +0 -1
  344. package/src/plugins/pi-agent-ide-changes/runtime/entry-33.js +0 -1
  345. /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-25.js +0 -0
  346. /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-27.js +0 -0
  347. /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-28.js +0 -0
  348. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-29.js +0 -0
  349. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-30.js +0 -0
  350. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-35.js +0 -0
  351. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-36.js +0 -0
  352. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-37.js +0 -0
  353. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-38.js +0 -0
  354. /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-40.js +0 -0
  355. /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-41.js +0 -0
  356. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-42.js +0 -0
  357. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-48.js +0 -0
  358. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-52.js +0 -0
  359. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-56.js +0 -0
  360. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-79.js +0 -0
  361. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-80.js +0 -0
  362. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-82.js +0 -0
  363. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-84.js +0 -0
  364. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-85.js +0 -0
  365. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-86.js +0 -0
  366. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-87.js +0 -0
  367. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-28.js +0 -0
  368. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-29.js +0 -0
  369. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-30.js +0 -0
  370. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-85.js +0 -0
  371. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-86.js +0 -0
  372. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-87.js +0 -0
  373. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-80.js +0 -0
  374. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-35.js +0 -0
  375. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-36.js +0 -0
  376. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-37.js +0 -0
  377. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-38.js +0 -0
@@ -1,4 +1,4 @@
1
- import{a as S,m as ee}from"./chunk-7JV4VN73.js";import{a as I}from"./chunk-2K65BSXS.js";import{c as R,d as D}from"./chunk-ICDI27GZ.js";import"./chunk-R5XJSEOE.js";import{b as P}from"./chunk-T4FTT3U4.js";import"./chunk-ZPT5D4VP.js";import{a as H,b as X,c as K,d as Q,g as Z}from"./chunk-OFILFO6D.js";import{a as Y}from"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";var $=[],C=[],j=[];function L(i,e,t){if(e.some(r=>r.name===t))throw new Error(`[pi-agent-ide] ${i} "${t}" is already registered. Use a unique name.`)}d(L,"assertUniqueName");function ie(i){let e=new Set;for(let t of i){let r=`${t.kind}:${t.name}`;if(e.has(r))throw new Error(`[pi-agent-ide] ${t.kind} "${t.name}" is registered twice by one plugin.`);switch(e.add(r),t.kind){case"compiler":{L(t.kind,C,t.name);break}case"formatter":{L(t.kind,$,t.name);break}case"linter":{L(t.kind,j,t.name);break}}}for(let t of i)switch(t.kind){case"compiler":{C.push(t);break}case"formatter":{$.push(t);break}case"linter":{j.push(t);break}}}d(ie,"registerTools");async function te(i,e){let t=[];for(let r of i)try{await r.detect(e)&&t.push(r)}catch(n){console.error(`[pi-agent-ide] detect failed for "${r.name}":`,n)}return t.sort((r,n)=>n.priority-r.priority),we(t),t}d(te,"filterActive");function we(i){let e=new Map;for(let t of i)for(let r of t.extensions){let n=`${r}@${t.priority}`,o=e.get(n);if(o!==void 0)throw new Error(`[pi-agent-ide] priority conflict: tools "${o}" and "${t.name}" both claim "${r}" at priority ${t.priority}.`);e.set(n,t.name)}}d(we,"assertNoPriorityConflicts");async function re(i){let[e,t]=await Promise.all([te($,i),te(C.filter(r=>r.syntaxOnly===!0),i)]);return{ctx:i,formatters:e,compilers:t,linters:[]}}d(re,"warmupFormatting");function J(){$.length=0,C.length=0,j.length=0}d(J,"resetRegistry");import{readFile as ve}from"node:fs/promises";import k from"node:path";var A=class{constructor(e,t={}){this.sources=e;this.options=t}static{d(this,"DiagnosticStore")}files=new Map;dirty=new Set;sent=new Map;queue=[];running=0;disposed=!1;changeListeners=new Set;onDidChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}schedule(e,t,{cwd:r}){this.disposed||this.ensure(e,t,r)}async read(e,{cwd:t,mode:r,signal:n}){n?.throwIfAborted(),this.assertActive();let o=P(e,t),s=await this.readText(o,t,n);this.assertActive();let a=this.ensure(o,s,t);r==="complete"?await this.waitComplete(a,n):r!=="snapshot"&&await be(Promise.all(a.jobs),this.options.readWaitMs??5e3),n?.throwIfAborted(),this.assertActive();let l=await this.readText(o,t,n);this.assertActive();let c=this.ensure(o,l,t);if(r==="complete"&&c!==a)throw Object.assign(new Error("File changed during diagnostics"),{code:"DIAGNOSTICS_STALE"});return{filePath:o,content:c.content,results:[...c.results.values()]}}async waitComplete(e,t){let r=t?AbortSignal.any([t,e.controller.signal]):e.controller.signal;r.throwIfAborted();let n=[];await new Promise((o,s)=>{let a=d(p=>s(Object.assign(new Error(p),{code:p,details:[...e.results.values()]})),"fail"),l=d(()=>{let p=[...e.results.values()];p.some(f=>f.status==="unavailable")?a("DIAGNOSTICS_UNAVAILABLE"):p.every(f=>f.status==="ready")&&o()},"check"),c=d(()=>s(r.reason),"abort"),u=this.onDidChange(l),g=setTimeout(()=>a("DIAGNOSTICS_TIMEOUT"),this.options.checkTimeoutMs??3e4);r.addEventListener("abort",c,{once:!0});let h=d(()=>{clearTimeout(g),u(),r.removeEventListener("abort",c)},"cleanup");Promise.resolve().then(l),n.push(h)}).finally(()=>{for(let o of n)o()})}async takeNotifications(e){let t=[];for(let r of[...this.dirty]){if(r.cwd!==(e.includes("://")?e:k.resolve(e))||(this.dirty.delete(r),!await this.isCurrent(r)))continue;let n=[...r.results.values()].filter(c=>c.status!=="pending"&&c.status!=="unavailable"&&c.diagnostics.length>0),o=this.key(r.filePath,r.cwd),s=JSON.stringify(n);if(this.sent.get(o)===s||(this.sent.set(o,s),n.length===0))continue;let a=n.map(c=>{let u=["error","warning","info","hint"].flatMap(g=>{let h=c.diagnostics.filter(p=>p.severity===g).length;return h>0?[`${h} ${g}`]:[]});return`${c.source} ${u.join(", ")}${c.status==="snapshot"?" (snapshot; completion unknown)":c.status==="unversioned"?" (unversioned)":""}`}).join("; "),l=r.filePath.includes("://")?r.filePath:k.relative(e,r.filePath);t.push({filePath:l,results:n,text:`${JSON.stringify(l)}: ${a}.`})}return t}dispose(){this.disposed=!0,this.changeListeners.clear();for(let e of this.files.values())e.controller.abort();this.files.clear(),this.dirty.clear(),this.sent.clear(),this.pump()}async readText(e,t,r){for(let n of this.options.readers??[]){let o=await n.readText(e,{cwd:t,signal:r});if(o!==void 0)return o}if(e.includes("://"))throw Object.assign(new Error("No diagnostic reader for resource owner"),{code:"UNSUPPORTED_SOURCE"});return ve(e,{encoding:"utf8",signal:r})}key(e,t){return JSON.stringify([t.includes("://")?t:k.resolve(t),P(e,t)])}ensure(e,t,r){let n=this.key(e,r),o=this.files.get(n);if(o?.content===t)return o;o?.controller.abort(),o&&this.dirty.delete(o);let s={cwd:r.includes("://")?r:k.resolve(r),filePath:P(e,r),content:t,controller:new AbortController,results:new Map,jobs:[],publications:new Map};this.files.set(n,s),this.sources.length===0&&s.results.set("diagnostics",{source:"diagnostics",status:"unavailable",diagnostics:[],reason:"No diagnostic sources registered"}),this.dirty.add(s);for(let a of this.sources){s.results.set(a.id,{source:a.id,status:"pending",diagnostics:[]});let l=new Promise(c=>{this.queue.push(async()=>{try{await this.check(s,a)}finally{c()}})});s.jobs.push(l)}return queueMicrotask(()=>this.pump()),s}pump(){for(;this.running<(this.options.concurrency??4)&&this.queue.length>0;){let e=this.queue.shift();if(!e)break;this.running++,e().finally(()=>{this.running--,this.pump()})}}active(e){return!this.disposed&&!e.controller.signal.aborted}assertActive(){if(this.disposed)throw new Error("Diagnostics session has ended")}async isCurrent(e){if(!this.active(e))return!1;let t=await this.readText(e.filePath,e.cwd,e.controller.signal).catch(()=>{});return this.active(e)&&t===e.content}async publish(e,t,r){let n=(e.publications.get(t)??0)+1;if(e.publications.set(t,n),!await this.isCurrent(e)||e.publications.get(t)!==n)return;let o={...r,source:r.source??t};if(JSON.stringify(e.results.get(t))===JSON.stringify(o))return;e.results.set(t,o),this.dirty.add(e);let s=[...e.results.values()].some(a=>a.status!=="pending"&&a.status!=="unavailable"&&a.diagnostics.length>0);s||this.sent.delete(this.key(e.filePath,e.cwd));for(let a of this.changeListeners)a(e.cwd,s)}async check(e,t){if(!await this.isCurrent(e))return;let r=new AbortController,n=AbortSignal.any([r.signal,e.controller.signal]);if(n.aborted)return;let o,s;try{let a=new Promise((c,u)=>{s=d(()=>u(n.reason),"onAbort"),n.addEventListener("abort",s,{once:!0}),o=setTimeout(()=>r.abort(new Error("Diagnostic check timed out")),this.options.checkTimeoutMs??3e4)}),l=await Promise.race([t.diagnose(e.filePath,{cwd:e.cwd,content:e.content,signal:n,publish:d(c=>{n.aborted||this.publish(e,t.id,c)},"publish")}),a]);await this.publish(e,t.id,l)}catch(a){await this.publish(e,t.id,{status:"unavailable",diagnostics:[],reason:a instanceof Error?a.message:String(a)})}finally{clearTimeout(o),s&&n.removeEventListener("abort",s)}}};async function be(i,e){let t;try{await Promise.race([i,new Promise(r=>{t=setTimeout(r,e)})])}finally{clearTimeout(t)}}d(be,"waitAtMost");function ne(){let i=new Map,e=[],t=[],r=new A(e,{readers:t}),n=Promise.resolve();return{diagnostics:r,registerPlugin(o){if(o.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let s=i.get(o.id);if(s!==void 0)return s;let a=n.then(async()=>{let l=[],c=[],u=[],g=!0,h={addTool(f){if(!g)throw new Error(`Plugin ${o.id} setup is already complete`);Ee(f),l.push(f)},addDiagnosticSource(f){if(!g)throw new Error(`Plugin ${o.id} setup is already complete`);Te(f),c.push(f)},addDiagnosticFileReader(f){if(!g)throw new Error(`Plugin ${o.id} setup is already complete`);if(!f.id.trim()||typeof f.readText!="function")throw new TypeError("Invalid diagnostic file reader");u.push(f)},readDiagnostics(f,E){return r.read(f,E)}};try{await o.setup(h)}catch(f){throw g=!1,f}g=!1,xe(e,c);let p=new Set(t.map(f=>f.id));for(let f of u){if(p.has(f.id))throw new Error(`Diagnostic file reader ${f.id} is already registered`);p.add(f.id)}ie(l),e.push(...c),t.push(...u)});return i.set(o.id,a),n=a.catch(()=>{}),a.catch(()=>{i.delete(o.id)}),a},async waitForPendingPlugins(){await Promise.all(i.values())}}}d(ne,"createIdeCore");function xe(i,e){let t=new Set(i.map(r=>r.id));for(let r of e){if(t.has(r.id))throw new Error(`Diagnostic source ${r.id} is already registered`);t.add(r.id)}}d(xe,"assertUniqueDiagnosticSources");function Ee(i){if(!oe(i))throw new TypeError("IDE tool must be an object");let e=i.kind,t=e==="compiler"?i.compile:e==="formatter"?i.format:e==="linter"?i.lint:void 0;if(t===void 0||typeof t!="function"||typeof i.detect!="function"||typeof i.name!="string"||i.name.trim().length===0||typeof i.priority!="number"||!Number.isFinite(i.priority)||!Array.isArray(i.extensions)||i.extensions.length===0||i.extensions.some(r=>typeof r!="string"||r.length===0))throw new TypeError("Invalid pi-agent-ide tool contribution")}d(Ee,"assertIdeTool");function Te(i){if(!oe(i)||typeof i.id!="string"||i.id.trim().length===0||typeof i.diagnose!="function")throw new TypeError("Invalid pi-agent-ide diagnostic source contribution")}d(Te,"assertDiagnosticSource");function oe(i){return typeof i=="object"&&i!==null}d(oe,"isRecord");function se(i,e,t=console.error){let r=new Map,n=!1,o=Promise.resolve();return{schedule(s){if(n||r.has(s))return;let a=setTimeout(()=>{r.delete(s),o=o.then(async()=>{n||await i(s)}).catch(t)},e);r.set(s,a)},dispose(){n=!0;for(let s of r.values())clearTimeout(s);r.clear()}}}d(se,"createDiagnosticDelivery");import{Text as ae}from"@earendil-works/pi-tui";var G="ide-diagnostic-summary";function ce(i){return{filePath:i.filePath,sources:i.results.map(e=>{let t={error:0,warning:0,info:0,hint:0};for(let r of e.diagnostics)t[r.severity]++;return{source:e.source,status:e.status,counts:t}})}}d(ce,"diagnosticEntryData");function V(i,e,t=!1){return{render(r){let n=i.sources.filter(a=>a.status!=="pending"&&a.status!=="unavailable"&&Object.values(a.counts).some(l=>l>0));if(n.length===0)return[];let o=n.map(a=>`${U(a.counts,e)} ${e.fg("dim",`(${q(a.source)})`)}`+(a.status==="ready"?"":` \xB7 ${e.fg("dim",a.status)}`)).join(" \xB7 "),s=[`${e.fg("accent","Diagnostics")} ${e.fg("toolTitle",q(i.filePath))} \xB7 ${o}`];if(t)for(let a of n)s.push(` ${e.fg("dim",q(a.source))} \xB7 ${U(a.counts,e)} \xB7 ${e.fg("dim",a.status)}`);return new ae(s.join(`
1
+ import{a as S,m as ee}from"./chunk-A64JRDZK.js";import{a as I}from"./chunk-M4TVRCMZ.js";import{c as R,d as D}from"./chunk-TGC2ZACO.js";import"./chunk-DXONCYWF.js";import{b as P}from"./chunk-T4FTT3U4.js";import"./chunk-ZPT5D4VP.js";import{a as H,b as X,c as K,d as Q,g as Z}from"./chunk-OFILFO6D.js";import{a as Y}from"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";var $=[],C=[],j=[];function L(i,e,t){if(e.some(r=>r.name===t))throw new Error(`[pi-agent-ide] ${i} "${t}" is already registered. Use a unique name.`)}d(L,"assertUniqueName");function ie(i){let e=new Set;for(let t of i){let r=`${t.kind}:${t.name}`;if(e.has(r))throw new Error(`[pi-agent-ide] ${t.kind} "${t.name}" is registered twice by one plugin.`);switch(e.add(r),t.kind){case"compiler":{L(t.kind,C,t.name);break}case"formatter":{L(t.kind,$,t.name);break}case"linter":{L(t.kind,j,t.name);break}}}for(let t of i)switch(t.kind){case"compiler":{C.push(t);break}case"formatter":{$.push(t);break}case"linter":{j.push(t);break}}}d(ie,"registerTools");async function te(i,e){let t=[];for(let r of i)try{await r.detect(e)&&t.push(r)}catch(n){console.error(`[pi-agent-ide] detect failed for "${r.name}":`,n)}return t.sort((r,n)=>n.priority-r.priority),we(t),t}d(te,"filterActive");function we(i){let e=new Map;for(let t of i)for(let r of t.extensions){let n=`${r}@${t.priority}`,o=e.get(n);if(o!==void 0)throw new Error(`[pi-agent-ide] priority conflict: tools "${o}" and "${t.name}" both claim "${r}" at priority ${t.priority}.`);e.set(n,t.name)}}d(we,"assertNoPriorityConflicts");async function re(i){let[e,t]=await Promise.all([te($,i),te(C.filter(r=>r.syntaxOnly===!0),i)]);return{ctx:i,formatters:e,compilers:t,linters:[]}}d(re,"warmupFormatting");function J(){$.length=0,C.length=0,j.length=0}d(J,"resetRegistry");import{readFile as ve}from"node:fs/promises";import k from"node:path";var A=class{constructor(e,t={}){this.sources=e;this.options=t}static{d(this,"DiagnosticStore")}files=new Map;dirty=new Set;sent=new Map;queue=[];running=0;disposed=!1;changeListeners=new Set;onDidChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}schedule(e,t,{cwd:r}){this.disposed||this.ensure(e,t,r)}async read(e,{cwd:t,mode:r,signal:n}){n?.throwIfAborted(),this.assertActive();let o=P(e,t),s=await this.readText(o,t,n);this.assertActive();let a=this.ensure(o,s,t);r==="complete"?await this.waitComplete(a,n):r!=="snapshot"&&await be(Promise.all(a.jobs),this.options.readWaitMs??5e3),n?.throwIfAborted(),this.assertActive();let l=await this.readText(o,t,n);this.assertActive();let c=this.ensure(o,l,t);if(r==="complete"&&c!==a)throw Object.assign(new Error("File changed during diagnostics"),{code:"DIAGNOSTICS_STALE"});return{filePath:o,content:c.content,results:[...c.results.values()]}}async waitComplete(e,t){let r=t?AbortSignal.any([t,e.controller.signal]):e.controller.signal;r.throwIfAborted();let n=[];await new Promise((o,s)=>{let a=d(p=>s(Object.assign(new Error(p),{code:p,details:[...e.results.values()]})),"fail"),l=d(()=>{let p=[...e.results.values()];p.some(f=>f.status==="unavailable")?a("DIAGNOSTICS_UNAVAILABLE"):p.every(f=>f.status==="ready")&&o()},"check"),c=d(()=>s(r.reason),"abort"),u=this.onDidChange(l),g=setTimeout(()=>a("DIAGNOSTICS_TIMEOUT"),this.options.checkTimeoutMs??3e4);r.addEventListener("abort",c,{once:!0});let h=d(()=>{clearTimeout(g),u(),r.removeEventListener("abort",c)},"cleanup");Promise.resolve().then(l),n.push(h)}).finally(()=>{for(let o of n)o()})}async takeNotifications(e){let t=[];for(let r of[...this.dirty]){if(r.cwd!==(e.includes("://")?e:k.resolve(e))||(this.dirty.delete(r),!await this.isCurrent(r)))continue;let n=[...r.results.values()].filter(c=>c.status!=="pending"&&c.status!=="unavailable"&&c.diagnostics.length>0),o=this.key(r.filePath,r.cwd),s=JSON.stringify(n);if(this.sent.get(o)===s||(this.sent.set(o,s),n.length===0))continue;let a=n.map(c=>{let u=["error","warning","info","hint"].flatMap(g=>{let h=c.diagnostics.filter(p=>p.severity===g).length;return h>0?[`${h} ${g}`]:[]});return`${c.source} ${u.join(", ")}${c.status==="snapshot"?" (snapshot; completion unknown)":c.status==="unversioned"?" (unversioned)":""}`}).join("; "),l=r.filePath.includes("://")?r.filePath:k.relative(e,r.filePath);t.push({filePath:l,results:n,text:`${JSON.stringify(l)}: ${a}.`})}return t}dispose(){this.disposed=!0,this.changeListeners.clear();for(let e of this.files.values())e.controller.abort();this.files.clear(),this.dirty.clear(),this.sent.clear(),this.pump()}async readText(e,t,r){for(let n of this.options.readers??[]){let o=await n.readText(e,{cwd:t,signal:r});if(o!==void 0)return o}if(e.includes("://"))throw Object.assign(new Error("No diagnostic reader for resource owner"),{code:"UNSUPPORTED_SOURCE"});return ve(e,{encoding:"utf8",signal:r})}key(e,t){return JSON.stringify([t.includes("://")?t:k.resolve(t),P(e,t)])}ensure(e,t,r){let n=this.key(e,r),o=this.files.get(n);if(o?.content===t)return o;o?.controller.abort(),o&&this.dirty.delete(o);let s={cwd:r.includes("://")?r:k.resolve(r),filePath:P(e,r),content:t,controller:new AbortController,results:new Map,jobs:[],publications:new Map};this.files.set(n,s),this.sources.length===0&&s.results.set("diagnostics",{source:"diagnostics",status:"unavailable",diagnostics:[],reason:"No diagnostic sources registered"}),this.dirty.add(s);for(let a of this.sources){s.results.set(a.id,{source:a.id,status:"pending",diagnostics:[]});let l=new Promise(c=>{this.queue.push(async()=>{try{await this.check(s,a)}finally{c()}})});s.jobs.push(l)}return queueMicrotask(()=>this.pump()),s}pump(){for(;this.running<(this.options.concurrency??4)&&this.queue.length>0;){let e=this.queue.shift();if(!e)break;this.running++,e().finally(()=>{this.running--,this.pump()})}}active(e){return!this.disposed&&!e.controller.signal.aborted}assertActive(){if(this.disposed)throw new Error("Diagnostics session has ended")}async isCurrent(e){if(!this.active(e))return!1;let t=await this.readText(e.filePath,e.cwd,e.controller.signal).catch(()=>{});return this.active(e)&&t===e.content}async publish(e,t,r){let n=(e.publications.get(t)??0)+1;if(e.publications.set(t,n),!await this.isCurrent(e)||e.publications.get(t)!==n)return;let o={...r,source:r.source??t};if(JSON.stringify(e.results.get(t))===JSON.stringify(o))return;e.results.set(t,o),this.dirty.add(e);let s=[...e.results.values()].some(a=>a.status!=="pending"&&a.status!=="unavailable"&&a.diagnostics.length>0);s||this.sent.delete(this.key(e.filePath,e.cwd));for(let a of this.changeListeners)a(e.cwd,s)}async check(e,t){if(!await this.isCurrent(e))return;let r=new AbortController,n=AbortSignal.any([r.signal,e.controller.signal]);if(n.aborted)return;let o,s;try{let a=new Promise((c,u)=>{s=d(()=>u(n.reason),"onAbort"),n.addEventListener("abort",s,{once:!0}),o=setTimeout(()=>r.abort(new Error("Diagnostic check timed out")),this.options.checkTimeoutMs??3e4)}),l=await Promise.race([t.diagnose(e.filePath,{cwd:e.cwd,content:e.content,signal:n,publish:d(c=>{n.aborted||this.publish(e,t.id,c)},"publish")}),a]);await this.publish(e,t.id,l)}catch(a){await this.publish(e,t.id,{status:"unavailable",diagnostics:[],reason:a instanceof Error?a.message:String(a)})}finally{clearTimeout(o),s&&n.removeEventListener("abort",s)}}};async function be(i,e){let t;try{await Promise.race([i,new Promise(r=>{t=setTimeout(r,e)})])}finally{clearTimeout(t)}}d(be,"waitAtMost");function ne(){let i=new Map,e=[],t=[],r=new A(e,{readers:t}),n=Promise.resolve();return{diagnostics:r,registerPlugin(o){if(o.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let s=i.get(o.id);if(s!==void 0)return s;let a=n.then(async()=>{let l=[],c=[],u=[],g=!0,h={addTool(f){if(!g)throw new Error(`Plugin ${o.id} setup is already complete`);Ee(f),l.push(f)},addDiagnosticSource(f){if(!g)throw new Error(`Plugin ${o.id} setup is already complete`);Te(f),c.push(f)},addDiagnosticFileReader(f){if(!g)throw new Error(`Plugin ${o.id} setup is already complete`);if(!f.id.trim()||typeof f.readText!="function")throw new TypeError("Invalid diagnostic file reader");u.push(f)},readDiagnostics(f,E){return r.read(f,E)}};try{await o.setup(h)}catch(f){throw g=!1,f}g=!1,xe(e,c);let p=new Set(t.map(f=>f.id));for(let f of u){if(p.has(f.id))throw new Error(`Diagnostic file reader ${f.id} is already registered`);p.add(f.id)}ie(l),e.push(...c),t.push(...u)});return i.set(o.id,a),n=a.catch(()=>{}),a.catch(()=>{i.delete(o.id)}),a},async waitForPendingPlugins(){await Promise.all(i.values())}}}d(ne,"createIdeCore");function xe(i,e){let t=new Set(i.map(r=>r.id));for(let r of e){if(t.has(r.id))throw new Error(`Diagnostic source ${r.id} is already registered`);t.add(r.id)}}d(xe,"assertUniqueDiagnosticSources");function Ee(i){if(!oe(i))throw new TypeError("IDE tool must be an object");let e=i.kind,t=e==="compiler"?i.compile:e==="formatter"?i.format:e==="linter"?i.lint:void 0;if(t===void 0||typeof t!="function"||typeof i.detect!="function"||typeof i.name!="string"||i.name.trim().length===0||typeof i.priority!="number"||!Number.isFinite(i.priority)||!Array.isArray(i.extensions)||i.extensions.length===0||i.extensions.some(r=>typeof r!="string"||r.length===0))throw new TypeError("Invalid pi-agent-ide tool contribution")}d(Ee,"assertIdeTool");function Te(i){if(!oe(i)||typeof i.id!="string"||i.id.trim().length===0||typeof i.diagnose!="function")throw new TypeError("Invalid pi-agent-ide diagnostic source contribution")}d(Te,"assertDiagnosticSource");function oe(i){return typeof i=="object"&&i!==null}d(oe,"isRecord");function se(i,e,t=console.error){let r=new Map,n=!1,o=Promise.resolve();return{schedule(s){if(n||r.has(s))return;let a=setTimeout(()=>{r.delete(s),o=o.then(async()=>{n||await i(s)}).catch(t)},e);r.set(s,a)},dispose(){n=!0;for(let s of r.values())clearTimeout(s);r.clear()}}}d(se,"createDiagnosticDelivery");import{Text as ae}from"@earendil-works/pi-tui";var G="ide-diagnostic-summary";function ce(i){return{filePath:i.filePath,sources:i.results.map(e=>{let t={error:0,warning:0,info:0,hint:0};for(let r of e.diagnostics)t[r.severity]++;return{source:e.source,status:e.status,counts:t}})}}d(ce,"diagnosticEntryData");function V(i,e,t=!1){return{render(r){let n=i.sources.filter(a=>a.status!=="pending"&&a.status!=="unavailable"&&Object.values(a.counts).some(l=>l>0));if(n.length===0)return[];let o=n.map(a=>`${U(a.counts,e)} ${e.fg("dim",`(${q(a.source)})`)}`+(a.status==="ready"?"":` \xB7 ${e.fg("dim",a.status)}`)).join(" \xB7 "),s=[`${e.fg("accent","Diagnostics")} ${e.fg("toolTitle",q(i.filePath))} \xB7 ${o}`];if(t)for(let a of n)s.push(` ${e.fg("dim",q(a.source))} \xB7 ${U(a.counts,e)} \xB7 ${e.fg("dim",a.status)}`);return new ae(s.join(`
2
2
  `),0,0).render(r)},invalidate(){}}}d(V,"renderDiagnosticEntry");function de(i){i.registerEntryRenderer(G,(e,t,r)=>{let n=Y(e.data);return"files"in n?Pe(n.files,r,t.expanded):V(n,r,t.expanded)})}d(de,"registerDiagnosticEntryRenderer");function Pe(i,e,t=!1){return{render(r){let n=i.filter(l=>l.sources.some(c=>c.status!=="pending"&&c.status!=="unavailable"&&Object.values(c.counts).some(u=>u>0)));if(n.length===1&&n[0])return V(n[0],e,t).render(r);if(n.length===0)return[];let o={error:0,warning:0,info:0,hint:0},s=new Set;for(let l of n)for(let c of l.sources)if(!(c.status==="pending"||c.status==="unavailable")){s.add(c.source);for(let u of["error","warning","info","hint"])o[u]+=c.counts[u]}let a=new ae(`${e.fg("accent","Diagnostics")} \xB7 ${n.length} files \xB7 ${U(o,e)} \xB7 ${s.size} tools`,0,0).render(r);return t?[...a,...n.flatMap(l=>V(l,e,!0).render(r))]:a},invalidate(){}}}d(Pe,"renderDiagnosticBatch");function U(i,e){return["error","warning","info","hint"].filter(t=>i[t]>0).map(t=>{let r=i[t],n=t==="info"||r===1?t:`${t}s`,o=r>0&&(t==="error"||t==="warning")?t:"muted";return e.fg(o,`${r} ${n}`)}).join(", ")}d(U,"renderCounts");function q(i){return i.replace(/[\u0000-\u001f\u007f-\u009f]/g," ")}d(q,"plain");import le from"node:path";async function ue(i){if(!le.isAbsolute(i.resourceSource)&&!i.resourceSource.startsWith("ssh://"))return{formatting:{status:"unavailable"}};let e;try{let t=await re({cwd:i.cwd}),r=le.extname(i.resourceSource).toLowerCase(),n=d(l=>l.extensions.includes(r)||l.extensions.includes("*"),"matches"),o=t.compilers.find(n);if(o&&(await o.compile({filePath:i.resourceSource},t.ctx)).syntaxErrors.length>0)return{formatting:{status:"skipped-syntax"}};let s=t.formatters.find(n);if(!s)return{formatting:{status:"unavailable"}};e=s.name;let a=await s.format({filePath:i.resourceSource},t.ctx);return a.formatter===null?{formatting:{status:"unavailable"}}:(e=a.formatter??s.name,{formatting:{status:a.ok?a.edits>0?"changed":"unchanged":"failed",formatter:e},...a.ok?{diffStatuses:[{text:`Formatted (${e})`,tone:"success",formatter:e}]}:{diffStatuses:[{text:`Formatting failed (${e})`,formatter:e,tone:"error"}]}})}catch{return{diffStatuses:[{text:"Formatting failed",tone:"error",formattingStatus:"failed",...e===void 0?{}:{formatter:e}}],formatting:{status:"failed",...e===void 0?{}:{formatter:e}}}}}d(ue,"runIdePostEditGate");import{readFile as Fe}from"node:fs/promises";import me from"node:path";import{Text as _e}from"@earendil-works/pi-tui";import{readFile as Re}from"node:fs/promises";import De from"node:path";import{Type as v}from"typebox";import{Value as Ie}from"typebox/value";import{parseDocument as Se}from"yaml";var F=".pi/pi-agent-ide/code-review.yaml",$e=v.Object({rules:v.Array(v.Object({id:v.String({pattern:"^[a-z][a-z0-9-]*$",maxLength:64}),description:v.String({minLength:1,maxLength:2048}),enabled:v.Optional(v.Boolean())},{additionalProperties:!1}),{maxItems:32})},{additionalProperties:!1});function Ce(i){if(Buffer.byteLength(i,"utf8")>65536)throw new Error("Review rules file is too large (64 KiB limit).");let e=Se(i),[t]=e.errors;if(t)throw new Error(t.message);let r=e.toJS({maxAliasCount:0});if(!Ie.Check($e,r))throw new Error("Expected rules: [{ id, description, enabled? }]; at most 32 rules with descriptions up to 2048 characters.");let n=new Set,o=[];for(let s of r.rules){if(n.has(s.id))throw new Error(`Duplicate review rule: ${s.id}`);if(n.add(s.id),!s.description.trim())throw new Error(`Empty description for ${s.id}`);s.enabled!==!1&&o.push({id:s.id,description:s.description.trim()})}return o}d(Ce,"parseReviewRules");async function fe(i){let e=De.resolve(i,F);try{return Ce(await Re(e,"utf8"))}catch(t){if(t.code==="ENOENT")return[];throw new Error(`Cannot load ${e}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}d(fe,"readReviewRules");import{createHash as Ae}from"node:crypto";import{structuredPatch as ke}from"diff";function ge(i,e){if(i===e)return[];if(i.length+e.length>3e5)throw new Error("File is too large for automatic review.");let t=ke("before","after",i,e,void 0,void 0,{context:3,timeout:100});if(!t)throw new Error("Diff exceeded the automatic review time limit.");if(t.hunks.length>16)throw new Error("Change has too many fragments for automatic review (16 limit).");return t.hunks.map(r=>{let n=`@@ -${r.oldStart},${r.oldLines} +${r.newStart},${r.newLines} @@
3
3
  ${r.lines.join(`
4
4
  `)}`;if(n.length>12e3)throw new Error("Fragment is too large for automatic review (12000 character limit).");return{diff:n}})}d(ge,"reviewFragments");function pe(i,e=300){let t=new Map,r=!1,n=Promise.resolve(),o=d(c=>!r&&i.enabled()&&t.get(c.edit.file)===c&&!c.controller.signal.aborted,"valid"),s=d(async c=>o(c)&&await i.current(c.edit.file)===c.edit.after&&o(c),"fresh");async function a(c){if(!o(c))return;c.started=!0;let{edit:u}=c;try{let g=i.runtime();if(!g)return;let h=AbortSignal.any([c.controller.signal,AbortSignal.timeout(15e3)]),p=await g.available(h),f=p.find(m=>m.provider==="typesafe"&&/jev/i.test(m.id))??p.find(m=>/jev/i.test(m.id));if(!f||!o(c))return;let E=await i.rules(u.cwd);if(E.length===0||!await s(c))return;let he=Object.fromEntries(E.map(m=>[m.id,{type:"choice",instructions:`Check whether this change violates the following project rule: ${m.description}
@@ -1,2 +1,2 @@
1
- import{f as m,j as g,k as x,o as h}from"./chunk-R5XJSEOE.js";import{a as i}from"./chunk-EI7MMDWY.js";import{Type as r}from"typebox";import{Value as y}from"typebox/value";import{Type as l}from"typebox";var u=l.Object({path:l.Optional(l.String({description:"What to read: a supported resource such as a file or directory path, URL, returned temp: reference, SEARCH# or RESULT# reference, or registered protocol source. Supply a path; an empty call cannot select a source."})),offset:l.Optional(l.Number({description:"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor, SEARCH or RESULT# selections, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit."})),limit:l.Optional(l.Number({description:"For raw: sources, use a non-negative byte count (0 reads no bytes). Otherwise, maximum lines from the selected starting position. Output is bounded; omit for the default read. For image and sequence views, limit is the square grid cell size in pixels; omit offset to select cell 0, or omit both for the bounded full image."})),views:l.Optional(l.Array(l.String(),{description:`Optional source-specific presentations. Combine views when both presentations are needed, for example ["anchors", "ast"]. Omit for the source's default presentation.`}))}),L={path:"Source to read: a resource path, unchanged source result or its UUID. Supply a source; an empty call cannot select one. temp:<id> reads saved output. raw:<local-file> reads original bytes from a regular file; relative, absolute and file:// paths are accepted.",offset:"For raw: sources, a zero-based integer byte offset; negative offsets count from the file end. For text sources, the first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end.",limit:"For raw: sources, a non-negative integer byte count (0 reads no bytes). For text sources, the maximum lines from the selected starting position. Omit for the default read. For other non-text sources, use only a range form described for that source.",views:"Source-specific presentations. Omit for the source's default presentation. Supply settings after a colon using the syntax below. Combine views only when their contracts allow it. raw: sources do not accept views."};function _(e){let n=i((s,a)=>({...s,description:[L[a],e[a]].filter(R=>R!==void 0).join(`
1
+ import{f as m,j as g,k as x,o as h}from"./chunk-DXONCYWF.js";import{a as i}from"./chunk-EI7MMDWY.js";import{Type as r}from"typebox";import{Value as y}from"typebox/value";import{Type as l}from"typebox";var u=l.Object({path:l.Optional(l.String({description:"What to read: a supported resource such as a file or directory path, URL, returned temp: reference, SEARCH# or RESULT# reference, or registered protocol source. Supply a path; an empty call cannot select a source."})),offset:l.Optional(l.Number({description:"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor, SEARCH or RESULT# selections, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit."})),limit:l.Optional(l.Number({description:"For raw: sources, use a non-negative byte count (0 reads no bytes). Otherwise, maximum lines from the selected starting position. Output is bounded; omit for the default read. For image and sequence views, limit is the square grid cell size in pixels; omit offset to select cell 0, or omit both for the bounded full image."})),views:l.Optional(l.Array(l.String(),{description:`Optional source-specific presentations. Combine views when both presentations are needed, for example ["anchors", "ast"]. Omit for the source's default presentation.`}))}),L={path:"Source to read: a resource path, unchanged source result or its UUID. Supply a source; an empty call cannot select one. temp:<id> reads saved output. raw:<local-file> reads original bytes from a regular file; relative, absolute and file:// paths are accepted.",offset:"For raw: sources, a zero-based integer byte offset; negative offsets count from the file end. For text sources, the first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end.",limit:"For raw: sources, a non-negative integer byte count (0 reads no bytes). For text sources, the maximum lines from the selected starting position. Omit for the default read. For other non-text sources, use only a range form described for that source.",views:"Source-specific presentations. Omit for the source's default presentation. Supply settings after a colon using the syntax below. Combine views only when their contracts allow it. raw: sources do not accept views."};function _(e){let n=i((s,a)=>({...s,description:[L[a],e[a]].filter(R=>R!==void 0).join(`
2
2
  `)}),"describe");return{...u,properties:{path:n(u.properties.path,"path"),offset:n(u.properties.offset,"offset"),limit:n(u.properties.limit,"limit"),views:n(u.properties.views,"views")}}}i(_,"describeReadParameters");import{Type as t}from"typebox";var k=t.Object({value:t.String(),kind:t.String(),state:t.Optional(t.String())},{additionalProperties:!1}),w=t.Object({lineNumber:t.Integer(),content:t.String(),lineEnding:t.String(),anchors:t.Optional(t.Array(t.String()))},{additionalProperties:!1}),P=t.Object({path:t.String(),offset:t.Integer()},{additionalProperties:!1}),f={source:t.String(),truncated:t.Boolean(),continuation:t.Optional(P),fullResult:t.Optional(t.String())},b=t.Object({...f,kind:t.Literal("text"),target:t.Optional(t.String()),lines:t.Array(w),startLine:t.Integer(),endLine:t.Integer(),totalLines:t.Integer(),references:t.Optional(t.Array(k))},{additionalProperties:!1}),S=t.Object({...f,kind:t.Literal("bytes"),bytes:t.Array(t.Integer({minimum:0,maximum:255})),byteOffset:t.Integer(),byteLength:t.Integer(),totalBytes:t.Integer()},{additionalProperties:!1}),v=t.Union([t.Object({type:t.Literal("text"),text:t.String()},{additionalProperties:!1}),t.Object({type:t.Literal("image"),mimeType:t.String()},{additionalProperties:!1})]),T=t.Object({...f,kind:t.Literal("native"),blocks:t.Array(v)},{additionalProperties:!1}),p=t.Union([t.Object({kind:t.Literal("recovery"),source:t.String(),candidates:t.Array(t.Object({path:t.String()},{additionalProperties:!1}))},{additionalProperties:!1}),b,S,T,t.Object({kind:t.Literal("resources"),source:t.Optional(t.String()),resources:t.Array(t.Union([b,S,T])),truncated:t.Boolean(),fullResult:t.Optional(t.String())},{additionalProperties:!1})]),C=m(p);function E(e){return{lineNumber:e.lineNumber,content:e.content,lineEnding:e.lineEnding,...e.anchors===void 0?{}:{anchors:[...e.anchors]}}}i(E,"publicLine");function O(e){if(e.kind==="resources"){let o=e.resources.map(d=>O(d));return{kind:e.kind,...e.source===void 0?{}:{source:e.source},resources:o,truncated:o.some(d=>typeof d=="object"&&d!==null&&"truncated"in d&&d.truncated===!0)}}if(e.kind==="bytes"){let o=e.bytes.slice(0,32768),d=e.truncated===!0||o.length<e.bytes.length;return{kind:e.kind,source:e.source,bytes:o,byteOffset:e.byteOffset,byteLength:o.length,totalBytes:e.totalBytes,truncated:d,...e.byteOffset+o.length<e.totalBytes?{continuation:{path:e.source,offset:e.byteOffset+o.length}}:{}}}if(e.kind==="native")return{kind:e.kind,source:e.source,truncated:!1,blocks:e.blocks.map(o=>{if(o.type==="text")return{type:o.type,text:o.text};if(o.type==="image")return{type:o.type,mimeType:o.mimeType};throw new TypeError("Custom content requires a structured adapter")})};let n=[],s=0;for(let o of e.lines){let d=E(o);if(s+=Buffer.byteLength(JSON.stringify(d)),n.length>=2e3||s>512*1024)break;n.push(d)}if(n.length===0&&e.lines.length>0)throw new RangeError("Selected line exceeds the structured window; use a raw byte range or a source-specific view");let a=n.length<e.lines.length,R=n.at(-1)?.lineNumber??e.startLine-1;return{kind:e.kind,source:e.source,...e.target===void 0?{}:{target:e.target},lines:n,startLine:n[0]?.lineNumber??0,endLine:n.at(-1)?.lineNumber??0,totalLines:e.totalLines,truncated:a,...e.target===void 0?{}:{target:e.target},...e.references===void 0?{}:{references:e.references},...a||R<e.totalLines?{continuation:{path:e.source,offset:R+1}}:{}}}i(O,"publicData");function D(e){let n=e.details.failure,s=n?.cause instanceof x?n.cause:void 0;if(e.isError||n!==void 0)return g(e,p,{status:"error",...n?.candidates?.length&&n.source!==void 0?{data:{kind:"recovery",source:n.source,candidates:n.candidates}}:{},errors:[{code:s?.code??n?.code??"READ_FAILED",message:s===void 0?n?.message??"Read failed":`${s.code}: ${n?.source??s.source}`,...n?.source===void 0?{}:{source:n.source}}]});try{if(e.script===void 0)throw new TypeError("Read handler must return structured script data");let a=O(e.script);return g(e,p,{status:"success",data:e.details.temporarySource!==void 0&&typeof a=="object"&&a!==null?{...a,fullResult:e.details.temporarySource}:a,errors:[]})}catch(a){return g(e,p,{status:"error",errors:[{code:a instanceof RangeError?"STRUCTURED_RESULT_TOO_LARGE":"STRUCTURED_ADAPTER_REQUIRED",message:a instanceof Error?a.message:String(a)}]})}}i(D,"structuredRead");var c=r.Function([],r.Unknown()),A=r.Object({resolver:r.Unknown(),matchesCall:r.Optional(c),renderCall:r.Optional(c),priority:r.Optional(r.Number()),renderResult:r.Optional(c),preserveTruncatedOutput:r.Optional(r.Boolean())}),F=r.Object({resolver:r.Unknown(),priority:r.Optional(r.Number())}),N=r.Object({id:r.String({pattern:"\\S"}),priority:r.Optional(r.Number()),resolve:c}),U=r.Object({view:r.String({pattern:"\\S"}),contentKind:r.Optional(r.Union([r.Literal("text"),r.Literal("any")])),includes:r.Optional(r.Array(r.String({pattern:"\\S"}))),presenter:r.Object({id:r.String(),present:c}),priority:r.Optional(r.Number())}),j=r.Object({resolvedBy:r.String({pattern:"\\S"}),contentKind:r.Union([r.Literal("text"),r.Literal("any")])}),I=r.Union([r.Object({stage:r.Literal("pre-read"),handler:c}),r.Object({stage:r.Literal("read"),when:j,handler:c}),r.Object({stage:r.Literal("post-read"),handler:c})]);function J(e){if(!y.Check(F,e))return!1;let n=e,s=n.resolver;return typeof s.id=="string"&&s.id.length>0&&typeof s.tryResolve=="function"&&(!("priority"in n)||typeof n.priority=="number")}i(J,"isTextTargetResolverRegistration");function Y(e){if(!y.Check(A,e))return!1;let n=e;return h(n.resolver)?n.resolver.id!=="any"&&(!("priority"in n)||typeof n.priority=="number")&&(!("matchesCall"in n)||typeof n.matchesCall=="function")&&(!("renderCall"in n)||typeof n.renderCall=="function")&&"matchesCall"in n=="renderCall"in n&&(!("renderResult"in n)||typeof n.renderResult=="function"):!1}i(Y,"isResourceResolverRegistration");function X(e){return y.Check(I,e)}i(X,"isReadHandlerRegistration");function Z(e){return y.Check(U,e)}i(Z,"isReadViewRegistration");function ee(e){return y.Check(N,e)}i(ee,"isFragmentResolverRegistration");function te(e){return B(e)?e.kind==="not-handled"?!0:e.kind==="failed"?typeof e.message=="string"&&e.message.length>0:e.kind==="resolved"&&typeof e.originLine=="number":!1}i(te,"isReadFragmentResolution");function B(e){return typeof e=="object"&&e!==null}i(B,"isRecord");export{u as a,_ as b,p as c,C as d,D as e,J as f,Y as g,X as h,Z as i,ee as j,te as k};
@@ -0,0 +1 @@
1
+ import{H as d,f as c}from"./chunk-DXONCYWF.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Type as t}from"typebox";var b=t.Object({query:t.String({minLength:1,description:"Text to find or a Boolean expression. Quote text to keep it literal. Use regex:<pattern> for regular expressions, files:<pattern> for file paths, ast:<pattern> for syntax patterns, symbols:<query> for language symbols, or process:<query> for running processes."}),path:t.Optional({...d,description:"File, directory, URL, docs:all for all packaged guide bodies, docs:<id> for one guide, unchanged Read/Search/Select/edit result, its UUID, or an array of such results. Use literal text or regex: for docs: sources. Results select only their registered ranges unless symbols: navigation follows external references."}),navigation:t.Optional(t.Literal("references",{description:"Only for symbols: queries. Explicitly follow symbols represented inside path to their references outside that scope. Without navigation, all returned ranges stay inside path."})),include:t.Optional(t.String({description:"Optional include glob for local or SSH files"})),exclude:t.Optional(t.String({description:"Optional exclude glob for local or SSH files"})),caseSensitive:t.Optional(t.Boolean({description:"Match letter case"})),wholeWord:t.Optional(t.Boolean({description:"Match complete words"})),limit:t.Optional(t.Integer({minimum:1,maximum:1e3,description:"Maximum displayed items, including compact file summaries (default 50)."}))},{additionalProperties:!1});import{Type as e}from"typebox";var u=e.Object({startLine:e.Integer(),startColumn:e.Integer(),endLine:e.Integer(),endColumn:e.Integer()},{additionalProperties:!1}),m=e.Object({line:e.Optional(e.String()),match:e.Optional(e.String())},{additionalProperties:!1}),p={source:e.String(),target:e.Optional(e.String()),range:u,matchedText:e.Optional(e.String()),textTruncated:e.Optional(e.Boolean()),references:e.Optional(m)},f=e.Object({...p,captures:e.Optional(e.Record(e.String(),e.Array(e.Object(p,{additionalProperties:!1})))),role:e.Optional(e.Union([e.Literal("definition"),e.Literal("reference")])),symbol:e.Optional(e.Object({id:e.String(),name:e.String(),kind:e.String(),source:e.String(),range:u},{additionalProperties:!1}))},{additionalProperties:!1}),g={target:e.Optional(e.String()),kind:e.Literal("matches"),truncated:e.Optional(e.Boolean()),fullResult:e.Optional(e.String()),complete:e.Boolean(),matches:e.Array(f),all:e.Optional(m),notices:e.Optional(e.Array(e.String()))},O=e.Object({status:e.Union([e.Literal("ready"),e.Literal("skipped")]),message:e.Optional(e.String()),candidates:e.Array(e.Object({identifier:e.String(),kind:e.Union([e.Literal("normalized"),e.Literal("component"),e.Literal("typo")]),reason:e.String(),matchCount:e.Integer(),fileCount:e.Integer(),selection:e.Object(g,{additionalProperties:!1})},{additionalProperties:!1}))},{additionalProperties:!1}),h=e.Union([e.Object({...g,fuzzy:e.Optional(O)},{additionalProperties:!1}),e.Object({kind:e.Literal("files"),complete:e.Boolean(),files:e.Array(e.String())},{additionalProperties:!1}),e.Object({kind:e.Literal("custom"),resolverId:e.String(),value:e.Unknown()},{additionalProperties:!1})]),P=c(h);function T(o,l,n,i){return{kind:"matches",...i?.target===void 0?{}:{target:i.target},truncated:o.length>100,complete:l,matches:o.slice(0,100).map((r,a)=>({source:r.source,...i?.matchTargets?.[a]===void 0?{}:{target:i.matchTargets[a]},range:{startLine:r.lineNumber,startColumn:r.startColumn,endLine:r.endLineNumber??r.lineNumber,endColumn:r.endColumn},...Buffer.byteLength(r.matchedText)<=4096?{matchedText:r.matchedText}:{textTruncated:!0},...n===void 0?{}:{references:{line:`SEARCH#${n}:${a+1}:line`,match:`SEARCH#${n}:${a+1}:match`}}})),...l&&n!==void 0?{all:{line:`SEARCH#${n}:all:line`,match:`SEARCH#${n}:all:match`}}:{}}}s(T,"selectionData");export{b as a,O as b,h as c,P as d,T as e};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-WXGTU2M6.js";import"./chunk-Q5X6OXNS.js";import"./chunk-4HWKBCBH.js";import"./chunk-DXONCYWF.js";import"./chunk-EI7MMDWY.js";export{a as runOwnedSshCommand};
@@ -1 +1 @@
1
- import{a as d,b as u,c as w}from"./chunk-HCN5W76B.js";import"./chunk-EY65TFHJ.js";import{b as f}from"./chunk-WE42GBGU.js";import"./chunk-DEP55R35.js";import{c}from"./chunk-W7CASEO3.js";import"./chunk-R2U5WXYR.js";import"./chunk-T7I2VX3J.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-2K65BSXS.js";import"./chunk-ICDI27GZ.js";import"./chunk-BU7IZLKB.js";import"./chunk-S5PL5DFQ.js";import"./chunk-R5XJSEOE.js";import"./chunk-ZPT5D4VP.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import{a as i}from"./chunk-EI7MMDWY.js";import{readFile as x}from"node:fs/promises";async function g(o){let n=new w(await u(d(c())));await f(o,m(o,n))}i(g,"registerOwnedGit");function m(o,n){return{exec:i(async(t,r,e)=>{let a=n.resolve(e.cwd);if(!a){if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(e.cwd))throw new Error(`Unsupported Git resource: ${e.cwd}`);return o.exec(t,r,e)}let s=await a.backend.execute(t,r,a.location.path,e);return{code:s.exitCode,stdout:s.stdout.toString("utf8"),stderr:s.stderr.toString("utf8")}},"exec"),async writeIndex(t,r){let e=n.resolve(r.cwd);return e?(await e.backend.writeGitIndex(e.location.path,t,r),!0):!1},async readText(t,r){let e=n.resolve(t);if(e)return(await e.backend.read(e.location.path,{signal:r})).bytes.toString("utf8");if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(t))throw new Error(`Unsupported Git resource: ${t}`);return x(t,{encoding:"utf8",signal:r})}}}i(m,"createOwnedGitExecutor");export{m as createOwnedGitExecutor,g as default};
1
+ import{a as d,b as u,c as w}from"./chunk-LLRUJD62.js";import"./chunk-4HWKBCBH.js";import{b as f}from"./chunk-LAJQSHEI.js";import"./chunk-DEP55R35.js";import"./chunk-R2U5WXYR.js";import{c}from"./chunk-W7CASEO3.js";import"./chunk-T7I2VX3J.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-M4TVRCMZ.js";import"./chunk-TGC2ZACO.js";import"./chunk-BU7IZLKB.js";import"./chunk-S5PL5DFQ.js";import"./chunk-DXONCYWF.js";import"./chunk-ZPT5D4VP.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import{a as i}from"./chunk-EI7MMDWY.js";import{readFile as x}from"node:fs/promises";async function g(o){let n=new w(await u(d(c())));await f(o,m(o,n))}i(g,"registerOwnedGit");function m(o,n){return{exec:i(async(t,r,e)=>{let a=n.resolve(e.cwd);if(!a){if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(e.cwd))throw new Error(`Unsupported Git resource: ${e.cwd}`);return o.exec(t,r,e)}let s=await a.backend.execute(t,r,a.location.path,e);return{code:s.exitCode,stdout:s.stdout.toString("utf8"),stderr:s.stderr.toString("utf8")}},"exec"),async writeIndex(t,r){let e=n.resolve(r.cwd);return e?(await e.backend.writeGitIndex(e.location.path,t,r),!0):!1},async readText(t,r){let e=n.resolve(t);if(e)return(await e.backend.read(e.location.path,{signal:r})).bytes.toString("utf8");if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(t))throw new Error(`Unsupported Git resource: ${t}`);return x(t,{encoding:"utf8",signal:r})}}}i(m,"createOwnedGitExecutor");export{m as createOwnedGitExecutor,g as default};
package/dist/entry-11.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-IQD6PON5.js";import"./chunk-7JV4VN73.js";import{a as l}from"./chunk-2K65BSXS.js";import{c as a,d as s}from"./chunk-ICDI27GZ.js";import"./chunk-U2JKHKLK.js";import"./chunk-QP2QSQ4U.js";import"./chunk-NNCZYO4Q.js";import"./chunk-IICJXZBU.js";import{a as p}from"./chunk-BU7IZLKB.js";import{a as u,b as y}from"./chunk-S5PL5DFQ.js";import"./chunk-PS2B6THP.js";import"./chunk-R5XJSEOE.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";function x(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/before-delete/${e.id}`,setup(t){t.addDeleteGuard({id:e.id,guard:d(n=>e.run(n),"guard")})}})}d(x,"connectBeforeDeleteHook");function m(o,e){return c(e),p(o,{protocol:u,apiVersion:y,id:`hook/before-read/${e.id}`,setup(t){t.addResourceGuard({id:e.id,async guard(n){let r=await e.run(n);return r.decision==="allow"?{kind:"accepted"}:{kind:"rejected",reason:r.reason}}})}})}d(m,"connectBeforeReadHook");function A(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/before-edit/${e.id}`,setup(t){t.addMutationGuard({id:e.id,async guard(n,r){let f=await e.run({cwd:r.cwd,intent:r.intent??"edit",resources:n.resources.map(i=>({resourceSource:i.source,existed:i.existed,before:i.before,after:i.after,changes:i.changes,...i.binary===void 0?{}:{binary:i.binary}})),...r.signal!==void 0&&{signal:r.signal}});return f.decision==="allow"?{kind:"accepted"}:{kind:"rejected",rejection:{code:"MUTATION_REJECTED",reason:f.reason,message:`Edit blocked by hook ${e.id}: ${f.reason}`,effect:"not-applied"}}}})}})}d(A,"connectBeforeEditHook");function v(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/after-edit/${e.id}`,setup(t){t.onDidEdit(async n=>{if(n.postProcessing!=="deferred")try{return await e.run(n)}catch(r){return{feedback:`After-edit hook ${e.id} failed after the edit was saved: ${r instanceof Error?r.message:String(r)}`,tone:"error"}}})}})}d(v,"connectAfterEditHook");function c(o){if(o.id.trim().length===0||typeof o.run!="function")throw new TypeError("A file hook needs a non-empty id and run function")}d(c,"assertHook");export{v as connectAfterEditHook,x as connectBeforeDeleteHook,A as connectBeforeEditHook,m as connectBeforeReadHook};
1
+ import"./chunk-IQD6PON5.js";import"./chunk-A64JRDZK.js";import{a as l}from"./chunk-M4TVRCMZ.js";import{c as a,d as s}from"./chunk-TGC2ZACO.js";import"./chunk-U2JKHKLK.js";import"./chunk-YHREORHH.js";import"./chunk-NNCZYO4Q.js";import"./chunk-IICJXZBU.js";import"./chunk-PS2B6THP.js";import{a as p}from"./chunk-BU7IZLKB.js";import{a as u,b as y}from"./chunk-S5PL5DFQ.js";import"./chunk-DXONCYWF.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";function x(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/before-delete/${e.id}`,setup(t){t.addDeleteGuard({id:e.id,guard:d(n=>e.run(n),"guard")})}})}d(x,"connectBeforeDeleteHook");function m(o,e){return c(e),p(o,{protocol:u,apiVersion:y,id:`hook/before-read/${e.id}`,setup(t){t.addResourceGuard({id:e.id,async guard(n){let r=await e.run(n);return r.decision==="allow"?{kind:"accepted"}:{kind:"rejected",reason:r.reason}}})}})}d(m,"connectBeforeReadHook");function A(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/before-edit/${e.id}`,setup(t){t.addMutationGuard({id:e.id,async guard(n,r){let f=await e.run({cwd:r.cwd,intent:r.intent??"edit",resources:n.resources.map(i=>({resourceSource:i.source,existed:i.existed,before:i.before,after:i.after,changes:i.changes,...i.binary===void 0?{}:{binary:i.binary}})),...r.signal!==void 0&&{signal:r.signal}});return f.decision==="allow"?{kind:"accepted"}:{kind:"rejected",rejection:{code:"MUTATION_REJECTED",reason:f.reason,message:`Edit blocked by hook ${e.id}: ${f.reason}`,effect:"not-applied"}}}})}})}d(A,"connectBeforeEditHook");function v(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/after-edit/${e.id}`,setup(t){t.onDidEdit(async n=>{if(n.postProcessing!=="deferred")try{return await e.run(n)}catch(r){return{feedback:`After-edit hook ${e.id} failed after the edit was saved: ${r instanceof Error?r.message:String(r)}`,tone:"error"}}})}})}d(v,"connectAfterEditHook");function c(o){if(o.id.trim().length===0||typeof o.run!="function")throw new TypeError("A file hook needs a non-empty id and run function")}d(c,"assertHook");export{v as connectAfterEditHook,x as connectBeforeDeleteHook,A as connectBeforeEditHook,m as connectBeforeReadHook};
package/dist/entry-13.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-U2JKHKLK.js";import{a as k,c as l,d as m,e as n,f as o,g as p,h as q,i as r,j as s,k as t}from"./chunk-QP2QSQ4U.js";import"./chunk-NNCZYO4Q.js";import{b as i,d as j}from"./chunk-IICJXZBU.js";import{a as h}from"./chunk-BU7IZLKB.js";import{a,b,c,d,e,f,g}from"./chunk-S5PL5DFQ.js";import"./chunk-PS2B6THP.js";import"./chunk-R5XJSEOE.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{i as COMPACT_READ_ROWS,b as READ_API_VERSION,c as READ_CORE_READY_EVENT,d as READ_PLUGIN_REGISTER_EVENT,a as READ_PROTOCOL,h as connectReadPlugin,j as createReadResultRenderer,s as isFragmentResolverRegistration,e as isReadCoreReady,t as isReadFragmentResolution,q as isReadHandlerRegistration,f as isReadPlugin,g as isReadPluginRegistrationRequest,r as isReadViewRegistration,p as isResourceResolverRegistration,o as isTextTargetResolverRegistration,l as readDataSchema,m as readOutputSchema,k as readParameters,n as structuredRead};
1
+ import"./chunk-U2JKHKLK.js";import{a as k,c as l,d as m,e as n,f as o,g as p,h as q,i as r,j as s,k as t}from"./chunk-YHREORHH.js";import"./chunk-NNCZYO4Q.js";import{b as i,d as j}from"./chunk-IICJXZBU.js";import"./chunk-PS2B6THP.js";import{a as h}from"./chunk-BU7IZLKB.js";import{a,b,c,d,e,f,g}from"./chunk-S5PL5DFQ.js";import"./chunk-DXONCYWF.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{i as COMPACT_READ_ROWS,b as READ_API_VERSION,c as READ_CORE_READY_EVENT,d as READ_PLUGIN_REGISTER_EVENT,a as READ_PROTOCOL,h as connectReadPlugin,j as createReadResultRenderer,s as isFragmentResolverRegistration,e as isReadCoreReady,t as isReadFragmentResolution,q as isReadHandlerRegistration,f as isReadPlugin,g as isReadPluginRegistrationRequest,r as isReadViewRegistration,p as isResourceResolverRegistration,o as isTextTargetResolverRegistration,l as readDataSchema,m as readOutputSchema,k as readParameters,n as structuredRead};
package/dist/entry-14.js CHANGED
@@ -1 +1 @@
1
- import{A,B,C,D,E,F,G,H,I,J,K,a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s,v as u,w as v,x as w,y,z}from"./chunk-R5XJSEOE.js";import"./chunk-EI7MMDWY.js";export{A as CONTENT_API_VERSION,C as CONTENT_CONVERTER_REGISTER_EVENT,B as CONTENT_HOST_READY_EVENT,z as CONTENT_PROTOCOL,t as MAX_STRUCTURED_BYTES,c as ResourceError,o as ResourceScheduler,I as ResultTargetStore,f as TempResourceStore,v as UnsupportedContentError,x as assertJsonData,G as connectContentConverter,K as connectResultTargets,F as createContentHost,w as createContentRunner,g as isAgentContent,s as isContentConversionAttempt,n as isContentConversionContext,q as isContentConverter,u as isContentConverterRegistration,E as isContentConverterRegistrationRequest,D as isContentHostReady,l as isContentInput,k as isContentTarget,h as isResource,j as isResourceResolutionAttempt,i as isResourceResolver,d as renderContentDescription,e as resourceAccesses,r as resourceScheduler,a as resultError,m as resultErrorSchema,H as resultInputSchema,p as structuredResultSchema,y as targetsEqual,J as verifyResultTargets,b as withStructuredResult};
1
+ import{a as r}from"./chunk-QIJMV2P2.js";import{a as e}from"./chunk-BHSO2MDK.js";import"./chunk-EI7MMDWY.js";export{r as createImageContentConverter,e as createPdfContentConverter};
package/dist/entry-15.js CHANGED
@@ -1 +1 @@
1
- import{a as x}from"./chunk-N7LMRL64.js";import{a as o,b as r,c as e,d as f,e as m,f as p,g as t}from"./chunk-RAZP42IQ.js";import{a as b,b as c,c as i,d as j,e as k,f as l,g as n,h as q,i as s}from"./chunk-BIG45IPN.js";import{a,c as d,d as g,e as h}from"./chunk-SSWUUBIR.js";import"./chunk-PS2B6THP.js";import"./chunk-R5XJSEOE.js";import"./chunk-EI7MMDWY.js";export{l as FuzzyVocabulary,r as SEARCH_API_VERSION,e as SEARCH_CORE_READY_EVENT,f as SEARCH_PLUGIN_REGISTER_EVENT,o as SEARCH_PROTOCOL,x as connectSearchPlugin,c as containsSearchMatch,s as formatFuzzyCandidate,q as fuzzyCandidateData,i as fuzzyLimits,k as isFuzzyQuery,j as isFuzzyResultData,m as isSearchCoreReady,p as isSearchPlugin,t as isSearchPluginRegistrationRequest,n as rankFuzzyIdentifiers,b as renderSearchMatches,d as searchDataSchema,g as searchOutputSchema,a as searchSchema,h as selectionData};
1
+ import{A,B,C,D,E,F,G,H,I,J,K,a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s,v as u,w as v,x as w,y,z}from"./chunk-DXONCYWF.js";import"./chunk-EI7MMDWY.js";export{A as CONTENT_API_VERSION,C as CONTENT_CONVERTER_REGISTER_EVENT,B as CONTENT_HOST_READY_EVENT,z as CONTENT_PROTOCOL,t as MAX_STRUCTURED_BYTES,c as ResourceError,o as ResourceScheduler,I as ResultTargetStore,f as TempResourceStore,v as UnsupportedContentError,x as assertJsonData,G as connectContentConverter,K as connectResultTargets,F as createContentHost,w as createContentRunner,g as isAgentContent,s as isContentConversionAttempt,n as isContentConversionContext,q as isContentConverter,u as isContentConverterRegistration,E as isContentConverterRegistrationRequest,D as isContentHostReady,l as isContentInput,k as isContentTarget,h as isResource,j as isResourceResolutionAttempt,i as isResourceResolver,d as renderContentDescription,e as resourceAccesses,r as resourceScheduler,a as resultError,m as resultErrorSchema,H as resultInputSchema,p as structuredResultSchema,y as targetsEqual,J as verifyResultTargets,b as withStructuredResult};
package/dist/entry-16.js CHANGED
@@ -1 +1 @@
1
- import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s}from"./chunk-ZPT5D4VP.js";import"./chunk-EI7MMDWY.js";export{o as TextAnchor,r as attachTextAnchorRenderer,j as createTextContentConverter,g as createTextDocument,e as getTextAnchorRenderer,a as getTextSourceLine,t as isTextAnchorRecoveryOutcome,p as isTextAnchorResolutionAttempt,m as isTextAnchorResolver,c as isTextLinePresenter,d as isTextPresenterRegistration,n as isTextTargetResolutionAttempt,k as isTextualMediaType,i as renderPresentedTextDocument,x as renderPresentedTextRows,f as renderTextAnchor,h as renderTextDocument,s as restoreText,q as storeText,l as textFromAgentContent,b as withTextSourceLine};
1
+ import{a as x}from"./chunk-47SPPIXK.js";import{a as o,b as r,c as e,d as f,e as m,f as p,g as t}from"./chunk-VAXLSPPU.js";import{a as b,b as c,c as i,d as j,e as k,f as l,g as n,h as q,i as s}from"./chunk-OI3HBIPK.js";import{a,c as d,d as g,e as h}from"./chunk-YTYLS2UM.js";import"./chunk-PS2B6THP.js";import"./chunk-DXONCYWF.js";import"./chunk-EI7MMDWY.js";export{l as FuzzyVocabulary,r as SEARCH_API_VERSION,e as SEARCH_CORE_READY_EVENT,f as SEARCH_PLUGIN_REGISTER_EVENT,o as SEARCH_PROTOCOL,x as connectSearchPlugin,c as containsSearchMatch,s as formatFuzzyCandidate,q as fuzzyCandidateData,i as fuzzyLimits,k as isFuzzyQuery,j as isFuzzyResultData,m as isSearchCoreReady,p as isSearchPlugin,t as isSearchPluginRegistrationRequest,n as rankFuzzyIdentifiers,b as renderSearchMatches,d as searchDataSchema,g as searchOutputSchema,a as searchSchema,h as selectionData};
package/dist/entry-17.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-IQD6PON5.js";import{m as q}from"./chunk-7JV4VN73.js";import{a as p}from"./chunk-2K65BSXS.js";import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-ICDI27GZ.js";import"./chunk-R5XJSEOE.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{d as TEXT_EDITOR_API_VERSION,g as TEXT_EDITOR_CORE_READY_EVENT,h as TEXT_EDITOR_PLUGIN_REGISTER_EVENT,c as TEXT_EDITOR_PROTOCOL,e as TEXT_POSITION_ANCHOR_KIND,f as TEXT_SEARCH_ANCHOR_KIND,p as connectTextEditorPlugin,q as connectTextEditorPostEditHandler,j as isResourceResolverRegistration,k as isTextAnchorResolverRegistration,l as isTextAnchorResourceResolutionAttempt,m as isTextEditorCoreReady,n as isTextEditorPlugin,o as isTextEditorPluginRegistrationRequest,i as isTextEditorToolId,b as localFileTransferAccess,a as snapshotLocalObjects};
1
+ import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s}from"./chunk-ZPT5D4VP.js";import"./chunk-EI7MMDWY.js";export{o as TextAnchor,r as attachTextAnchorRenderer,j as createTextContentConverter,g as createTextDocument,e as getTextAnchorRenderer,a as getTextSourceLine,t as isTextAnchorRecoveryOutcome,p as isTextAnchorResolutionAttempt,m as isTextAnchorResolver,c as isTextLinePresenter,d as isTextPresenterRegistration,n as isTextTargetResolutionAttempt,k as isTextualMediaType,i as renderPresentedTextDocument,x as renderPresentedTextRows,f as renderTextAnchor,h as renderTextDocument,s as restoreText,q as storeText,l as textFromAgentContent,b as withTextSourceLine};
@@ -0,0 +1 @@
1
+ import"./chunk-IQD6PON5.js";import{m as q}from"./chunk-A64JRDZK.js";import{a as p}from"./chunk-M4TVRCMZ.js";import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-TGC2ZACO.js";import"./chunk-DXONCYWF.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{d as TEXT_EDITOR_API_VERSION,g as TEXT_EDITOR_CORE_READY_EVENT,h as TEXT_EDITOR_PLUGIN_REGISTER_EVENT,c as TEXT_EDITOR_PROTOCOL,e as TEXT_POSITION_ANCHOR_KIND,f as TEXT_SEARCH_ANCHOR_KIND,p as connectTextEditorPlugin,q as connectTextEditorPostEditHandler,j as isResourceResolverRegistration,k as isTextAnchorResolverRegistration,l as isTextAnchorResourceResolutionAttempt,m as isTextEditorCoreReady,n as isTextEditorPlugin,o as isTextEditorPluginRegistrationRequest,i as isTextEditorToolId,b as localFileTransferAccess,a as snapshotLocalObjects};
package/dist/entry-20.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-EI7MMDWY.js";export{a as connectDoctorPlugin};
1
+ import"./chunk-K4ZMRDEI.js";
package/dist/entry-21.js CHANGED
@@ -1 +1 @@
1
- import{a,b}from"./chunk-BXGMMZT3.js";import"./chunk-EI7MMDWY.js";export{b as hasProjectMarker,a as inspectRecipeEvidence};
1
+ import{a}from"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-EI7MMDWY.js";export{a as connectDoctorPlugin};
package/dist/entry-22.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e}from"./chunk-756K3LJY.js";import"./chunk-EI7MMDWY.js";export{d as isExecutableAvailable,b as normalizeProcessEnvironment,e as probeExecutable,a as projectExecutableDirectories,c as projectProcessEnvironment};
1
+ import{a,b}from"./chunk-BXGMMZT3.js";import"./chunk-EI7MMDWY.js";export{b as hasProjectMarker,a as inspectRecipeEvidence};
package/dist/entry-23.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c}from"./chunk-R2U5WXYR.js";import"./chunk-756K3LJY.js";import"./chunk-EI7MMDWY.js";export{b as probeProjectExecutable,c as projectExecutableAvailable,a as projectFileExists};
1
+ import{a,b,c,d,e}from"./chunk-756K3LJY.js";import"./chunk-EI7MMDWY.js";export{d as isExecutableAvailable,b as normalizeProcessEnvironment,e as probeExecutable,a as projectExecutableDirectories,c as projectProcessEnvironment};
package/dist/entry-24.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g}from"./chunk-S72FVLUX.js";import"./chunk-EI7MMDWY.js";export{c as DOCTOR_API_VERSION,d as DOCTOR_CORE_READY_EVENT,e as DOCTOR_PLUGIN_REGISTER_EVENT,b as DOCTOR_PROTOCOL,a as DOCTOR_TOOL_PATH_KEYS,f as isDoctorCoreReady,g as isDoctorPluginRegistrationRequest};
1
+ import{a,b,c}from"./chunk-R2U5WXYR.js";import"./chunk-756K3LJY.js";import"./chunk-EI7MMDWY.js";export{b as probeProjectExecutable,c as projectExecutableAvailable,a as projectFileExists};
package/dist/entry-25.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e,f}from"./chunk-T7I2VX3J.js";import"./chunk-EI7MMDWY.js";export{b as DOCUMENTATION_API_VERSION,a as DOCUMENTATION_PROTOCOL,c as DOCUMENTATION_READY_EVENT,d as DOCUMENTATION_REGISTER_EVENT,f as connectAgentDocumentation,e as loadPackagedAgentGuide};
1
+ import{a,b,c,d,e,f,g}from"./chunk-S72FVLUX.js";import"./chunk-EI7MMDWY.js";export{c as DOCTOR_API_VERSION,d as DOCTOR_CORE_READY_EVENT,e as DOCTOR_PLUGIN_REGISTER_EVENT,b as DOCTOR_PROTOCOL,a as DOCTOR_TOOL_PATH_KEYS,f as isDoctorCoreReady,g as isDoctorPluginRegistrationRequest};
package/dist/entry-26.js CHANGED
@@ -1,2 +1 @@
1
- import{a as I}from"./chunk-2K65BSXS.js";import{c as D,d as k}from"./chunk-ICDI27GZ.js";import"./chunk-NNCZYO4Q.js";import{d as A}from"./chunk-IICJXZBU.js";import{a as T}from"./chunk-BU7IZLKB.js";import{a as C,b as P}from"./chunk-S5PL5DFQ.js";import"./chunk-PS2B6THP.js";import{F as v,l as E}from"./chunk-R5XJSEOE.js";import{r as F}from"./chunk-ZPT5D4VP.js";import{a as y}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{readdirSync as W,realpathSync as B,statSync as V}from"node:fs";import{mkdir as j,readFile as $,writeFile as z}from"node:fs/promises";import O from"node:path";import{fileURLToPath as Z,pathToFileURL as G}from"node:url";function S(e){return x("read",e)}s(S,"createFilesystemReadResolver");function _(e){return x("write",e)}s(_,"createFilesystemWriteResolver");function x(e,t){return{id:"filesystem",tryResolve(r,o){return Promise.resolve(X(r,o,e,t))}}}s(x,"createFilesystemResolver");function X(e,t,r,o){if(e.length===0)return{kind:"failed",error:new TypeError("Filesystem source must not be empty")};if(!K(e))return{kind:"not-handled"};if(t.signal?.aborted===!0)return{kind:"failed",error:H()};let n=e.startsWith("file://")?B(Z(new URL(e))):O.resolve(t.cwd,e),i=G(n).href,m=(()=>{try{return V(n).isDirectory()}catch{return!1}})(),c,p={source:n,link:i,read:s(async({signal:f})=>(c=void 0,m?q(n,f):J(n,o,f,l=>{c=l})),"read"),get sourceBytes(){return c}};return r==="read"||m?{kind:"resolved",resource:p}:{kind:"resolved",resource:{...p,get sourceBytes(){return c},async write(f,l){g(l.signal);let h=F(f);await j(O.dirname(n),{recursive:!0}),g(l.signal),await z(n,h,{encoding:"utf8",...l.signal!==void 0&&{signal:l.signal}})}}}}s(X,"resolveFilesystemSource");function q(e,t){g(t);let r=W(e,{withFileTypes:!0}),o=[`\u{1F4C1} ${e}/`];r.length>0&&o.push("");for(let n of r){let i=n.isDirectory()?"\u{1F4C1}":n.isFile()?"\u{1F4C4}":"\u{1F517}";o.push(` ${i} ${n.name}`)}return[{type:"text",text:o.join(`
2
- `)}]}s(q,"readDirectoryContent");async function J(e,t,r,o){g(r);let n=await $(e,{encoding:null,...r!==void 0&&{signal:r}});return g(r),o(n),t.convert({source:e,bytes:n},r===void 0?{}:{signal:r})}s(J,"readFilesystemContent");function K(e){return/^[A-Za-z]:[\\/]/u.test(e)||e.startsWith("file://")?!0:!/^[A-Za-z][A-Za-z\d+.-]*:/u.test(e)}s(K,"isFilesystemSource");function g(e){if(e?.aborted===!0)throw H()}s(g,"throwIfAborted");function H(){let e=new Error("The operation was aborted");return e.name="AbortError",e}s(H,"abortError");import{execFile as Q}from"node:child_process";import{existsSync as Y}from"node:fs";import{realpath as L}from"node:fs/promises";import ee from"node:os";import u from"node:path";import{fileURLToPath as te}from"node:url";async function N(e,t){let r=e.cause,o=Date.now()+500;if(t.signal?.aborted||e.source===void 0||typeof r!="object"||r===null||!("code"in r)||r.code!=="ENOENT")return;let n=e.source.startsWith("file://")?te(e.source):e.source,i=u.relative(t.cwd,u.resolve(t.cwd,n));if(!w(i)||i.includes("#"))return;let m=u.basename(i).toLowerCase();if(m.length<3||m.length>160)return;let c=u.join(process.env.PI_CODING_AGENT_DIR??u.join(ee.homedir(),".pi","agent"),"bin",process.platform==="win32"?"rg.exe":"rg"),b=await new Promise(a=>{Q(Y(c)?c:"rg",["--files","--hidden","--no-config","--no-ignore-parent","--null","--glob","!.git/**"],{cwd:t.cwd,timeout:250,maxBuffer:2*1024*1024,...t.signal===void 0?{}:{signal:t.signal}},(d,R)=>a(d?[]:R.split("\0").filter(Boolean).slice(0,2e4)))}),p=Math.min(3,Math.max(1,Math.floor(m.length*.2))),f=b.flatMap(a=>{if(t.signal?.aborted||Date.now()>o||!w(a))return[];let d=u.basename(a).toLowerCase();if(d.length>160||Math.abs(d.length-m.length)>p)return[];let R=re(m,d);if(R>p)return[];let M=u.dirname(i).toLowerCase(),U=u.dirname(a).toLowerCase();return[{path:a,distance:R,directoryDistance:M===U?0:1}]}).sort((a,d)=>a.distance-d.distance||a.directoryDistance-d.directoryDistance||a.path.localeCompare(d.path)),l=[],h=await L(t.cwd);for(let a of f.slice(0,20)){if(t.signal?.aborted||Date.now()>o)return;try{let d=await L(u.resolve(t.cwd,a.path));w(u.relative(h,d))&&l.push({path:a.path})}catch{}if(l.length===3)break}return l.length?l:void 0}s(N,"recoverFilesystemPath");function w(e){return e!==""&&!/^\.\.(?:[\\/]|$)/u.test(e)&&!u.isAbsolute(e)}s(w,"insideWorkspace");function re(e,t){let r=Array.from({length:t.length+1},(o,n)=>n);for(let o=1;o<=e.length;o++){let n=[o];for(let i=1;i<=t.length;i++)n[i]=Math.min(y(n[i-1])+1,y(r[i])+1,y(r[i-1])+(e[o-1]===t[i-1]?0:1));r=n}return y(r[t.length])}s(re,"editDistance");var ne={provider:"filesystem",capability:"read"},oe={provider:"filesystem",capability:"write"},ie=A({kind:"source",nativeResources:!0});async function se(e){let t=v(e,ne),r=v(e,oe),o=S(t),n=_(r),i={protocol:C,apiVersion:P,id:"filesystem",setup(c){c.addResolver({resolver:o,renderResult:ie,recoverFailure:N}),c.describe({path:s(()=>E("File path \u2014 file content; directory path \u2014 entry listing. Relative, absolute and file:// paths accepted.",t.listDescriptions()),"path")})}},m={protocol:D,apiVersion:k,id:"filesystem",setup(c){c.addResolver({resolver:n})}};await Promise.all([T(e,i),I(e,m)])}s(se,"registerFilesystemPlugin");export{se as default};
1
+ import{a,b,c,d,e,f}from"./chunk-T7I2VX3J.js";import"./chunk-EI7MMDWY.js";export{b as DOCUMENTATION_API_VERSION,a as DOCUMENTATION_PROTOCOL,c as DOCUMENTATION_READY_EVENT,d as DOCUMENTATION_REGISTER_EVENT,f as connectAgentDocumentation,e as loadPackagedAgentGuide};
package/dist/entry-27.js CHANGED
@@ -1 +1,2 @@
1
- import{a as r}from"./chunk-QIJMV2P2.js";import{G as e}from"./chunk-R5XJSEOE.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:100};async function i(o){await e(o,n)}t(i,"registerFilesystemImage");export{i as default};
1
+ import{a as I}from"./chunk-M4TVRCMZ.js";import{c as D,d as k}from"./chunk-TGC2ZACO.js";import"./chunk-NNCZYO4Q.js";import{d as A}from"./chunk-IICJXZBU.js";import"./chunk-PS2B6THP.js";import{a as T}from"./chunk-BU7IZLKB.js";import{a as C,b as P}from"./chunk-S5PL5DFQ.js";import{F as v,l as E}from"./chunk-DXONCYWF.js";import{r as F}from"./chunk-ZPT5D4VP.js";import{a as y}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{readdirSync as W,realpathSync as B,statSync as V}from"node:fs";import{mkdir as j,readFile as $,writeFile as z}from"node:fs/promises";import O from"node:path";import{fileURLToPath as Z,pathToFileURL as G}from"node:url";function S(e){return x("read",e)}s(S,"createFilesystemReadResolver");function _(e){return x("write",e)}s(_,"createFilesystemWriteResolver");function x(e,t){return{id:"filesystem",tryResolve(r,o){return Promise.resolve(X(r,o,e,t))}}}s(x,"createFilesystemResolver");function X(e,t,r,o){if(e.length===0)return{kind:"failed",error:new TypeError("Filesystem source must not be empty")};if(!K(e))return{kind:"not-handled"};if(t.signal?.aborted===!0)return{kind:"failed",error:H()};let n=e.startsWith("file://")?B(Z(new URL(e))):O.resolve(t.cwd,e),i=G(n).href,m=(()=>{try{return V(n).isDirectory()}catch{return!1}})(),c,p={source:n,link:i,read:s(async({signal:f})=>(c=void 0,m?q(n,f):J(n,o,f,l=>{c=l})),"read"),get sourceBytes(){return c}};return r==="read"||m?{kind:"resolved",resource:p}:{kind:"resolved",resource:{...p,get sourceBytes(){return c},async write(f,l){g(l.signal);let h=F(f);await j(O.dirname(n),{recursive:!0}),g(l.signal),await z(n,h,{encoding:"utf8",...l.signal!==void 0&&{signal:l.signal}})}}}}s(X,"resolveFilesystemSource");function q(e,t){g(t);let r=W(e,{withFileTypes:!0}),o=[`\u{1F4C1} ${e}/`];r.length>0&&o.push("");for(let n of r){let i=n.isDirectory()?"\u{1F4C1}":n.isFile()?"\u{1F4C4}":"\u{1F517}";o.push(` ${i} ${n.name}`)}return[{type:"text",text:o.join(`
2
+ `)}]}s(q,"readDirectoryContent");async function J(e,t,r,o){g(r);let n=await $(e,{encoding:null,...r!==void 0&&{signal:r}});return g(r),o(n),t.convert({source:e,bytes:n},r===void 0?{}:{signal:r})}s(J,"readFilesystemContent");function K(e){return/^[A-Za-z]:[\\/]/u.test(e)||e.startsWith("file://")?!0:!/^[A-Za-z][A-Za-z\d+.-]*:/u.test(e)}s(K,"isFilesystemSource");function g(e){if(e?.aborted===!0)throw H()}s(g,"throwIfAborted");function H(){let e=new Error("The operation was aborted");return e.name="AbortError",e}s(H,"abortError");import{execFile as Q}from"node:child_process";import{existsSync as Y}from"node:fs";import{realpath as L}from"node:fs/promises";import ee from"node:os";import u from"node:path";import{fileURLToPath as te}from"node:url";async function N(e,t){let r=e.cause,o=Date.now()+500;if(t.signal?.aborted||e.source===void 0||typeof r!="object"||r===null||!("code"in r)||r.code!=="ENOENT")return;let n=e.source.startsWith("file://")?te(e.source):e.source,i=u.relative(t.cwd,u.resolve(t.cwd,n));if(!w(i)||i.includes("#"))return;let m=u.basename(i).toLowerCase();if(m.length<3||m.length>160)return;let c=u.join(process.env.PI_CODING_AGENT_DIR??u.join(ee.homedir(),".pi","agent"),"bin",process.platform==="win32"?"rg.exe":"rg"),b=await new Promise(a=>{Q(Y(c)?c:"rg",["--files","--hidden","--no-config","--no-ignore-parent","--null","--glob","!.git/**"],{cwd:t.cwd,timeout:250,maxBuffer:2*1024*1024,...t.signal===void 0?{}:{signal:t.signal}},(d,R)=>a(d?[]:R.split("\0").filter(Boolean).slice(0,2e4)))}),p=Math.min(3,Math.max(1,Math.floor(m.length*.2))),f=b.flatMap(a=>{if(t.signal?.aborted||Date.now()>o||!w(a))return[];let d=u.basename(a).toLowerCase();if(d.length>160||Math.abs(d.length-m.length)>p)return[];let R=re(m,d);if(R>p)return[];let M=u.dirname(i).toLowerCase(),U=u.dirname(a).toLowerCase();return[{path:a,distance:R,directoryDistance:M===U?0:1}]}).sort((a,d)=>a.distance-d.distance||a.directoryDistance-d.directoryDistance||a.path.localeCompare(d.path)),l=[],h=await L(t.cwd);for(let a of f.slice(0,20)){if(t.signal?.aborted||Date.now()>o)return;try{let d=await L(u.resolve(t.cwd,a.path));w(u.relative(h,d))&&l.push({path:a.path})}catch{}if(l.length===3)break}return l.length?l:void 0}s(N,"recoverFilesystemPath");function w(e){return e!==""&&!/^\.\.(?:[\\/]|$)/u.test(e)&&!u.isAbsolute(e)}s(w,"insideWorkspace");function re(e,t){let r=Array.from({length:t.length+1},(o,n)=>n);for(let o=1;o<=e.length;o++){let n=[o];for(let i=1;i<=t.length;i++)n[i]=Math.min(y(n[i-1])+1,y(r[i])+1,y(r[i-1])+(e[o-1]===t[i-1]?0:1));r=n}return y(r[t.length])}s(re,"editDistance");var ne={provider:"filesystem",capability:"read"},oe={provider:"filesystem",capability:"write"},ie=A({kind:"source",nativeResources:!0});async function se(e){let t=v(e,ne),r=v(e,oe),o=S(t),n=_(r),i={protocol:C,apiVersion:P,id:"filesystem",setup(c){c.addResolver({resolver:o,renderResult:ie,recoverFailure:N}),c.describe({path:s(()=>E("File path \u2014 file content; directory path \u2014 entry listing. Relative, absolute and file:// paths accepted.",t.listDescriptions()),"path")})}},m={protocol:D,apiVersion:k,id:"filesystem",setup(c){c.addResolver({resolver:n})}};await Promise.all([T(e,i),I(e,m)])}s(se,"registerFilesystemPlugin");export{se as default};
package/dist/entry-28.js CHANGED
@@ -1,4 +1 @@
1
- import{e as b,f as x}from"./chunk-T7I2VX3J.js";import{a as P}from"./chunk-YJ6T3PEP.js";import{b as y,c as E}from"./chunk-S72FVLUX.js";import{a as R}from"./chunk-BU7IZLKB.js";import{a as O,b as T}from"./chunk-S5PL5DFQ.js";import{m as q}from"./chunk-ZPT5D4VP.js";import{c as h,d as j,e as v}from"./chunk-756K3LJY.js";import{a as d}from"./chunk-EI7MMDWY.js";import C from"cross-spawn";import{fileURLToPath as D}from"node:url";var S=5e3,A=10*1024*1024,L=D(new URL(".",new URL("../src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts",import.meta.url).href));function _(n){let t=n?.filter(r=>r==="jq"||r.startsWith("jq:"))??[];if(t.length===0)return;if(t.length>1)throw new Error("Read accepts only one jq view");if(n?.length!==1)throw new Error("The jq view cannot be combined with other views. Keep only one jq:<filter> in views.");let e=t[0];if(e===void 0||e==="jq"||e.slice(3).trim().length===0)throw new Error('The jq view requires a filter, for example views: ["jq:.scripts"]');return{filter:e.slice(3)}}d(_,"parseJqView");function k(n,t,e){return e.signal?.aborted===!0?Promise.reject(new Error("jq execution was cancelled")):V(n)?Promise.reject(new Error("jq module loading is disabled")):new Promise((r,s)=>{let i=C(e.command??"jq",["-L",L,"--",n],{cwd:e.cwd,env:N(e.cwd),shell:!1,stdio:["pipe","pipe","pipe"],windowsHide:!0}),a="",l="",u=!1,f=0,c=d(o=>{u||(u=!0,clearTimeout(m),e.signal?.removeEventListener("abort",g),o===void 0?r(a):s(o))},"finish"),p=d(o=>{i.kill(),c(o)},"stop"),g=d(()=>p(new Error("jq execution was cancelled")),"abort"),m=setTimeout(()=>p(new Error(`jq did not finish within ${S/1e3} seconds`)),S);m.unref(),e.signal?.addEventListener("abort",g,{once:!0}),i.stdout?.setEncoding("utf8"),i.stderr?.setEncoding("utf8"),i.stdout?.on("data",o=>{if(f+=Buffer.byteLength(o),f>A){p(new Error(`jq output exceeded ${A/1024/1024}MB`));return}a+=o}),i.stderr?.on("data",o=>{Buffer.byteLength(l)<16384&&(l+=o)}),i.once("error",o=>c(new Error(`Cannot start jq: ${o.message}`))),i.once("close",(o,w)=>{if(!u)if(o===0)c();else{let I=l.trim().split(/\r?\n/u).slice(0,8).join(`
2
- `);c(new Error(I||`jq exited ${w===null?`with code ${String(o)}`:`after signal ${w}`}`))}}),i.stdin?.once("error",o=>c(new Error(`Cannot send JSON to jq: ${o.message}`))),i.stdin?.end(t)})}d(k,"executeJq");function V(n){let t=[0],e=0,r="";for(;e<n.length;){let s=n[e],i=t.at(-1);if(i==="string"){s==="\\"?(n[e+1]==="("&&(t.push(0),r=""),e+=2):(s==='"'&&(t.pop(),r='"'),e+=1);continue}if(s==="#"){let a=n.indexOf(`
3
- `,e);e=a<0?n.length:a+1;continue}if(s==='"')t.push("string");else if(s==="(")t[t.length-1]=(i??0)+1;else if(s===")")t.length>1&&i===0?t.pop():t[t.length-1]=Math.max(0,(i??0)-1);else if(/[A-Za-z_]/u.test(s??"")){let a=e;for(;/[A-Za-z0-9_]/u.test(n[e]??"");)e+=1;let l=n.slice(a,e),u=B(n,e),f=r==="."||r==="$",c=u.startsWith(":")&&!u.startsWith("::");if(!f&&!c&&(l==="include"||l==="import"||l==="modulemeta"))return!0;r=l;continue}s!==void 0&&!/\s/u.test(s)&&(r=s),e+=1}return!1}d(V,"hasModuleOperation");function B(n,t){let e=t;for(;e<n.length;)if(/\s/u.test(n[e]??""))e+=1;else if(n[e]==="#"){let r=n.indexOf(`
4
- `,e);e=r<0?n.length:r+1}else break;return n.slice(e,e+2)}d(B,"nextCode");function N(n){let t=h(n,process.env),e={};for(let r of["PATH","PATHEXT","SystemRoot","SYSTEMROOT","WINDIR"])t[r]!==void 0&&(e[r]=t[r]);return e}d(N,"safeEnvironment");async function $(n){x(n,[await b({id:"json-reading",description:"Query and transform JSON resources with jq read views",triggers:[{tool:"read",viewPrefixes:["jq:"]}]})]),await Promise.all([R(n,M),P(n,U)])}d($,"registerFilesystemJq");var M={protocol:O,apiVersion:T,id:"filesystem-jq",setup(n){n.addView({view:"jq",presenter:{id:"filesystem-jq",present:d(t=>t,"present")}}),n.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},async handler(t){let e=t.state;if(e?.contentKind!=="text"||e.resolvedBy!=="filesystem"&&e.resolvedBy!=="ssh")return{kind:"continue",context:t};let r;try{r=_(t.request.views)}catch(a){return J(e,a instanceof Error?a.message:String(a))}if(r===void 0)return{kind:"continue",context:t};let s;try{s=await k(r.filter,e.content[0].text,{cwd:t.resolverContext.cwd,...t.resolverContext.signal===void 0?{}:{signal:t.resolverContext.signal}})}catch(a){return J(e,a instanceof Error?a.message:String(a))}let i={...e,content:[{type:"text",text:s}],text:q(e.source,s),preserveTruncatedOutput:!0};return{kind:"continue",context:{...t,sourceText:void 0,state:i}}}}),n.describe({views:'jq:<filter> \u2014 query local JSON text with the installed jq executable, e.g. ["jq:.scripts | keys"]. Exactly one non-empty jq filter is required; it cannot be combined with other views. offset/limit apply to the transformed output, not original source lines.'})}};function J(n,t){return{kind:"return",result:{content:[{type:"text",text:`jq failed: ${t}`}],details:{source:n.source,resolvedBy:n.resolvedBy,failure:{code:"READ_FAILED",source:n.source,resolverId:n.resolvedBy,pluginId:"filesystem-jq",stage:"read",message:t}},isError:!0}}}d(J,"jqFailure");var U={protocol:y,apiVersion:E,id:"filesystem-jq",setup(n){n.addSetupCheck({id:"jq",async inspect(t){return await j("jq",t.workspace?process.cwd():t.cwd,t.workspace?process.env:t.env,t.signal)?{}:{actions:[{id:"jq-unavailable",message:"JSON jq views are unavailable because jq was not found"}]}}}),n.addCheck({id:"jq",title:"JSON jq views",async run(t){t.signal?.throwIfAborted();let e=await v("jq",["--version"],t.workspace?process.cwd():t.cwd,t.workspace?process.env:t.env,t.signal);return t.signal?.throwIfAborted(),[e.ok?{status:"pass",message:"jq is available",detail:t.workspace?`Controller content adapter: ${e.detail}`:e.detail}:{status:"fail",message:"jq is not available",detail:e.detail}]}})}};export{$ as default};
1
+ import{a as r}from"./chunk-QIJMV2P2.js";import{G as e}from"./chunk-DXONCYWF.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:100};async function i(o){await e(o,n)}t(i,"registerFilesystemImage");export{i as default};
package/dist/entry-29.js CHANGED
@@ -1 +1,4 @@
1
- import{a as r}from"./chunk-BHSO2MDK.js";import{G as e}from"./chunk-R5XJSEOE.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:200};async function i(o){await e(o,n)}t(i,"registerFilesystemPdf");export{i as default};
1
+ import{e as b,f as x}from"./chunk-T7I2VX3J.js";import{a as P}from"./chunk-YJ6T3PEP.js";import{b as y,c as E}from"./chunk-S72FVLUX.js";import{a as R}from"./chunk-BU7IZLKB.js";import{a as O,b as T}from"./chunk-S5PL5DFQ.js";import{m as q}from"./chunk-ZPT5D4VP.js";import{c as h,d as j,e as v}from"./chunk-756K3LJY.js";import{a as d}from"./chunk-EI7MMDWY.js";import C from"cross-spawn";import{fileURLToPath as D}from"node:url";var S=5e3,A=10*1024*1024,L=D(new URL(".",new URL("../src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts",import.meta.url).href));function _(n){let t=n?.filter(r=>r==="jq"||r.startsWith("jq:"))??[];if(t.length===0)return;if(t.length>1)throw new Error("Read accepts only one jq view");if(n?.length!==1)throw new Error("The jq view cannot be combined with other views. Keep only one jq:<filter> in views.");let e=t[0];if(e===void 0||e==="jq"||e.slice(3).trim().length===0)throw new Error('The jq view requires a filter, for example views: ["jq:.scripts"]');return{filter:e.slice(3)}}d(_,"parseJqView");function k(n,t,e){return e.signal?.aborted===!0?Promise.reject(new Error("jq execution was cancelled")):V(n)?Promise.reject(new Error("jq module loading is disabled")):new Promise((r,s)=>{let i=C(e.command??"jq",["-L",L,"--",n],{cwd:e.cwd,env:N(e.cwd),shell:!1,stdio:["pipe","pipe","pipe"],windowsHide:!0}),a="",l="",u=!1,f=0,c=d(o=>{u||(u=!0,clearTimeout(m),e.signal?.removeEventListener("abort",g),o===void 0?r(a):s(o))},"finish"),p=d(o=>{i.kill(),c(o)},"stop"),g=d(()=>p(new Error("jq execution was cancelled")),"abort"),m=setTimeout(()=>p(new Error(`jq did not finish within ${S/1e3} seconds`)),S);m.unref(),e.signal?.addEventListener("abort",g,{once:!0}),i.stdout?.setEncoding("utf8"),i.stderr?.setEncoding("utf8"),i.stdout?.on("data",o=>{if(f+=Buffer.byteLength(o),f>A){p(new Error(`jq output exceeded ${A/1024/1024}MB`));return}a+=o}),i.stderr?.on("data",o=>{Buffer.byteLength(l)<16384&&(l+=o)}),i.once("error",o=>c(new Error(`Cannot start jq: ${o.message}`))),i.once("close",(o,w)=>{if(!u)if(o===0)c();else{let I=l.trim().split(/\r?\n/u).slice(0,8).join(`
2
+ `);c(new Error(I||`jq exited ${w===null?`with code ${String(o)}`:`after signal ${w}`}`))}}),i.stdin?.once("error",o=>c(new Error(`Cannot send JSON to jq: ${o.message}`))),i.stdin?.end(t)})}d(k,"executeJq");function V(n){let t=[0],e=0,r="";for(;e<n.length;){let s=n[e],i=t.at(-1);if(i==="string"){s==="\\"?(n[e+1]==="("&&(t.push(0),r=""),e+=2):(s==='"'&&(t.pop(),r='"'),e+=1);continue}if(s==="#"){let a=n.indexOf(`
3
+ `,e);e=a<0?n.length:a+1;continue}if(s==='"')t.push("string");else if(s==="(")t[t.length-1]=(i??0)+1;else if(s===")")t.length>1&&i===0?t.pop():t[t.length-1]=Math.max(0,(i??0)-1);else if(/[A-Za-z_]/u.test(s??"")){let a=e;for(;/[A-Za-z0-9_]/u.test(n[e]??"");)e+=1;let l=n.slice(a,e),u=B(n,e),f=r==="."||r==="$",c=u.startsWith(":")&&!u.startsWith("::");if(!f&&!c&&(l==="include"||l==="import"||l==="modulemeta"))return!0;r=l;continue}s!==void 0&&!/\s/u.test(s)&&(r=s),e+=1}return!1}d(V,"hasModuleOperation");function B(n,t){let e=t;for(;e<n.length;)if(/\s/u.test(n[e]??""))e+=1;else if(n[e]==="#"){let r=n.indexOf(`
4
+ `,e);e=r<0?n.length:r+1}else break;return n.slice(e,e+2)}d(B,"nextCode");function N(n){let t=h(n,process.env),e={};for(let r of["PATH","PATHEXT","SystemRoot","SYSTEMROOT","WINDIR"])t[r]!==void 0&&(e[r]=t[r]);return e}d(N,"safeEnvironment");async function $(n){x(n,[await b({id:"json-reading",description:"Query and transform JSON resources with jq read views",triggers:[{tool:"read",viewPrefixes:["jq:"]}]})]),await Promise.all([R(n,M),P(n,U)])}d($,"registerFilesystemJq");var M={protocol:O,apiVersion:T,id:"filesystem-jq",setup(n){n.addView({view:"jq",presenter:{id:"filesystem-jq",present:d(t=>t,"present")}}),n.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},async handler(t){let e=t.state;if(e?.contentKind!=="text"||e.resolvedBy!=="filesystem"&&e.resolvedBy!=="ssh")return{kind:"continue",context:t};let r;try{r=_(t.request.views)}catch(a){return J(e,a instanceof Error?a.message:String(a))}if(r===void 0)return{kind:"continue",context:t};let s;try{s=await k(r.filter,e.content[0].text,{cwd:t.resolverContext.cwd,...t.resolverContext.signal===void 0?{}:{signal:t.resolverContext.signal}})}catch(a){return J(e,a instanceof Error?a.message:String(a))}let i={...e,content:[{type:"text",text:s}],text:q(e.source,s),preserveTruncatedOutput:!0};return{kind:"continue",context:{...t,sourceText:void 0,state:i}}}}),n.describe({views:'jq:<filter> \u2014 query local JSON text with the installed jq executable, e.g. ["jq:.scripts | keys"]. Exactly one non-empty jq filter is required; it cannot be combined with other views. offset/limit apply to the transformed output, not original source lines.'})}};function J(n,t){return{kind:"return",result:{content:[{type:"text",text:`jq failed: ${t}`}],details:{source:n.source,resolvedBy:n.resolvedBy,failure:{code:"READ_FAILED",source:n.source,resolverId:n.resolvedBy,pluginId:"filesystem-jq",stage:"read",message:t}},isError:!0}}}d(J,"jqFailure");var U={protocol:y,apiVersion:E,id:"filesystem-jq",setup(n){n.addSetupCheck({id:"jq",async inspect(t){return await j("jq",t.workspace?process.cwd():t.cwd,t.workspace?process.env:t.env,t.signal)?{}:{actions:[{id:"jq-unavailable",message:"JSON jq views are unavailable because jq was not found"}]}}}),n.addCheck({id:"jq",title:"JSON jq views",async run(t){t.signal?.throwIfAborted();let e=await v("jq",["--version"],t.workspace?process.cwd():t.cwd,t.workspace?process.env:t.env,t.signal);return t.signal?.throwIfAborted(),[e.ok?{status:"pass",message:"jq is available",detail:t.workspace?`Controller content adapter: ${e.detail}`:e.detail}:{status:"fail",message:"jq is not available",detail:e.detail}]}})}};export{$ as default};
package/dist/entry-30.js CHANGED
@@ -1 +1 @@
1
- import{G as t}from"./chunk-R5XJSEOE.js";import{p as i}from"./chunk-ZPT5D4VP.js";import{a as r}from"./chunk-EI7MMDWY.js";var o=i(),n={target:{provider:"filesystem",capability:"read"},converter:o,priority:300},s={target:{provider:"filesystem",capability:"write"},converter:o,priority:300};async function a(e){await Promise.all([t(e,n),t(e,s)])}r(a,"registerFilesystemText");export{a as default};
1
+ import{a as r}from"./chunk-BHSO2MDK.js";import{G as e}from"./chunk-DXONCYWF.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:200};async function i(o){await e(o,n)}t(i,"registerFilesystemPdf");export{i as default};
package/dist/entry-31.js CHANGED
@@ -1 +1 @@
1
- import{b as e,c as o}from"./chunk-UEVGZUII.js";import"./chunk-ZPT5D4VP.js";import"./chunk-EI7MMDWY.js";export{o as AstScopeManager,e as parseDocument};
1
+ import{G as t}from"./chunk-DXONCYWF.js";import{p as i}from"./chunk-ZPT5D4VP.js";import{a as r}from"./chunk-EI7MMDWY.js";var o=i(),n={target:{provider:"filesystem",capability:"read"},converter:o,priority:300},s={target:{provider:"filesystem",capability:"write"},converter:o,priority:300};async function a(e){await Promise.all([t(e,n),t(e,s)])}r(a,"registerFilesystemText");export{a as default};
package/dist/entry-32.js CHANGED
@@ -1,18 +1 @@
1
- import{a as Te}from"./chunk-LEKC4GQK.js";import{b as Le}from"./chunk-MZXX353D.js";import"./chunk-4OYVLXWD.js";import{f as Re,g as Ae}from"./chunk-XH5WN5XA.js";import{b as P,c as Oe}from"./chunk-UEVGZUII.js";import{b as Ie,c as ve}from"./chunk-R2U5WXYR.js";import{e as te,f as ne}from"./chunk-T7I2VX3J.js";import{a as re}from"./chunk-YJ6T3PEP.js";import{b as Z,c as ee}from"./chunk-S72FVLUX.js";import{a as ye}from"./chunk-2K65BSXS.js";import{c as fe,d as ge,e as he}from"./chunk-ICDI27GZ.js";import"./chunk-NNCZYO4Q.js";import{d as de}from"./chunk-IICJXZBU.js";import{a as ie}from"./chunk-BU7IZLKB.js";import{a as oe,b as se}from"./chunk-S5PL5DFQ.js";import{a as we}from"./chunk-N7LMRL64.js";import{a as be,b as Se}from"./chunk-RAZP42IQ.js";import{b as xe}from"./chunk-BIG45IPN.js";import{e as N}from"./chunk-SSWUUBIR.js";import{a as ae,b as ce,e as le}from"./chunk-PS2B6THP.js";import{H as D,J as k,K as me,f as ue,i as pe,j as M}from"./chunk-R5XJSEOE.js";import{h as Q}from"./chunk-DUUOCBS3.js";import{a as J,b as X,c as W}from"./chunk-T4FTT3U4.js";import{m as Y}from"./chunk-ZPT5D4VP.js";import"./chunk-KINKBPPX.js";import"./chunk-756K3LJY.js";import{a as K}from"./chunk-ZC65Z3CK.js";import{a as p}from"./chunk-EI7MMDWY.js";import{readFile as dt}from"node:fs/promises";var ut={cmake:"no compatible Tree-sitter parser is packaged",dockerfile:"no compatible Tree-sitter parser is packaged",julia:"no compatible Tree-sitter parser is packaged",powershell:"no compatible Tree-sitter parser is packaged",r:"no compatible Tree-sitter parser is packaged",svelte:"the container grammar is not available as an ast-grep language package",terraform:"the HCL grammar is not available as an ast-grep language package",vue:"the container grammar is not available as an ast-grep language package",xml:"no compatible Tree-sitter parser is packaged",zig:"no compatible Tree-sitter parser is packaged"},U=new Set(["c","cpp","csharp","css","dart","elixir","go","html","java","kotlin","lua","markdown","php","ruby","scala","shell","sql","swift","javascript","typescript","python","rust","json","yaml","toml"]),Ee={protocol:Z,apiVersion:ee,id:"ast",setup(t){t.addSetupCheck({id:"structural-search",async inspect(e){return[...e.detectedLanguageIds].some(o=>U.has(o))?await ve(e,"ast-grep")?{}:{actions:[{id:"ast-grep-unavailable",message:"Structural search is unavailable because ast-grep was not found"}]}:{}}}),t.addCheck({id:"parsers",title:"AST",async run(e){let n=[];for(let o of e.detectedLanguageIds){let r=ut[o];if(r!==void 0){n.push({status:"skip",message:`${o} AST is unavailable: ${r}`});continue}if(!U.has(o))continue;let s=e.files.find(i=>pt(i,o));if(s!==void 0)try{e.signal?.throwIfAborted();let i=e.workspace?await e.workspace.readText(s,e.signal):await dt(s,{encoding:"utf8",signal:e.signal});if(i===void 0)throw new Error(`Source disappeared: ${s}`);e.signal?.throwIfAborted();let a=await P(s,e.cwd,i.replaceAll(`\r
2
- `,`
3
- `).split(`
4
- `));n.push(a===void 0?{status:"fail",message:`${o} parser did not return a tree`}:{status:"pass",message:`${o} parser loaded`,detail:s})}catch(i){e.signal?.throwIfAborted(),n.push({status:"fail",message:`${o}: ${i instanceof Error?i.message:String(i)}`})}}return n.length>0?n:[{status:"skip",message:"No supported AST files found"}]}}),t.addCheck({id:"ast-grep",title:"Structural search",async run(e){if(![...e.detectedLanguageIds].some(o=>U.has(o)))return[{status:"skip",message:"No supported structural-search files found"}];let n=await Ie(e,"ast-grep",["--version"]);return[n.ok?{status:"pass",message:"ast-grep is available",detail:n.detail}:{status:"fail",message:"ast-grep is not available",detail:n.detail}]}})}};function pt(t,e){let n=t.slice(t.lastIndexOf(".")).toLowerCase();return{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"],csharp:[".cs"],css:[".css",".scss",".less"],dart:[".dart"],elixir:[".ex",".exs"],go:[".go"],html:[".html",".htm"],java:[".java"],kotlin:[".kt",".kts"],lua:[".lua"],markdown:[".md",".mdx"],php:[".php"],ruby:[".rb",".rake"],scala:[".scala",".sc"],shell:[".sh",".bash"],sql:[".sql"],swift:[".swift"],javascript:[".js",".jsx",".mjs",".cjs"],typescript:[".ts",".tsx",".mts",".cts"],python:[".py",".pyi"],rust:[".rs"],json:[".json",".jsonc"],yaml:[".yaml",".yml"],toml:[".toml"]}[e]?.includes(n)??!1}p(pt,"matchesLanguage");var mt,ft;function ke(t,e){return{id:"ast",tryResolve(n,o){return Promise.resolve(gt(n,o,t,e))}}}p(ke,"createAstOutlineResolver");function gt(t,e,n,o){let r;try{r=J(t,"ast")}catch(a){return{kind:"failed",error:a}}if(r===void 0)return{kind:"not-handled"};let s;try{s=X(r.path,e.cwd)}catch(a){return{kind:"failed",error:a}}let i=W("ast",s);return{kind:"resolved",resource:{source:s,link:i,async read({signal:a}){a?.throwIfAborted();let l=await(ft??=import("./chunk-4W7GH3T7.js")),d=n??(mt??=new l.AstOutlineManager),u;if(s.startsWith("ssh://")){if(o===void 0)throw new Error("No AST snapshot owner for this resource.");let f=await o(s,{...e,signal:a});if(Buffer.byteLength(f.lines.join(`
5
- `))>Te)throw new Error("File exceeds the 262144-byte AST outline limit.");if(f.lines.some(g=>g.includes("\0")))throw new Error("Binary resources cannot be read as AST outlines.");u=await d.readDocumentOutline(f.source,e.cwd,f.lines)}else u=await d.readFileOutline(s,e.cwd);return a?.throwIfAborted(),[l.formatAstOutline(u)]}}}}p(gt,"resolveAstOutlineSource");import{DEFAULT_MAX_BYTES as ht,DEFAULT_MAX_LINES as yt,truncateHead as G}from"@earendil-works/pi-coding-agent";var B=p(async(t,e,n)=>{let{source:o,resolvedBy:r,lines:s,totalLines:i,startLine:a}=t.details;if(!(o===void 0||r!=="filesystem"&&!o.startsWith("ssh://")||s===void 0||s.length!==i||a!==void 0&&a!==1))try{let{AstOutlineManager:l,isSupportedOutlinePath:d}=await import("./chunk-4W7GH3T7.js");if(!d(o))return;let u=p(h=>[`Code overview of ${h.path}, source lines 1-${h.totalLines}: the requested text exceeded the output limit.`,`Some source text is omitted. Read ${JSON.stringify(o)} with offset and limit for exact source text.`,...h.renderedLines.map(b=>`${b.sourceLine?.lineNumber??"\u2026"} | ${b.text}`)].join(`
6
- `),"format");e.signal?.throwIfAborted();let f=await new l(12).readDocumentOutline(o,e.cwd,s.map(h=>h.content),h=>(e.signal?.throwIfAborted(),!G(u(h),n).truncated)),g=u(f);return G(g,n).truncated?void 0:{script:t.script,content:[{type:"text",text:g}],details:{source:o,resolvedBy:"ast-overflow"}}}catch{e.signal?.throwIfAborted();return}},"reduceAstReadOutput");function Ne(){return async t=>{let{state:e,result:n}=t,o=n?.content.length===1?n.content[0]:void 0;if(t.audience==="script"||n===void 0||e?.contentKind!=="text"||e.resolvedBy!=="filesystem"&&!e.source.startsWith("ssh://")||o?.type!=="text"||!G(o.text).truncated)return{kind:"continue",context:t};let r=await B({...n,details:{...n.details,source:e.source,resolvedBy:e.resolvedBy,lines:e.text.lines,startLine:1,totalLines:e.text.lines.length}},t.resolverContext,{maxBytes:ht,maxLines:yt});return r===void 0?{kind:"continue",context:t}:{kind:"continue",context:t,transform:p(s=>({...r,script:s.script}),"transform")}}}p(Ne,"createAstOverflowHandler");var Pe="pi-agent-ast";function je(t){return{id:"ast-scopes",async present(e,n){if(n.resolvedBy!=="filesystem"&&!e.source.startsWith("ssh://"))return e;try{let o=await t.getDocumentScopes(e.source,n.cwd,e.lines.map(s=>s.content)),r=bt(e.lines,o);return r===e.lines?e:{...e,lines:r}}catch{return e}}}}p(je,"createAstScopePresenter");function Ce(){return t=>{let e=t.state,n=t.result;if(e?.contentKind!=="text"||n===void 0)return{kind:"continue",context:t};let o=n.details.lines;if(o===void 0)return{kind:"continue",context:t};let r=new Map(e.text.lines.map(u=>[u.lineNumber,u])),s=new Set(o.map(u=>u.lineNumber)),i=new Map;for(let u of o){let f=r.get(u.lineNumber),g=$e(f);for(let h of g?.boundaries??[]){if(s.has(h.endLine))continue;let b=r.get(h.endLine);b!==void 0&&i.set(h.endLine,b)}}if(i.size===0)return{kind:"continue",context:t};let a=[...i.values()].sort((u,f)=>u.lineNumber-f.lineNumber),l=[...o,...a],d=o.at(-1);return{kind:"continue",context:t,transform:p(u=>St(u,l,d),"transform")}}}p(Ce,"createAstScopePostReadHandler");function bt(t,e){if(e.length===0)return t;let n=new Map,o=new Map;for(let r of e){let s=n.get(r.startLine)??[];s.push(r.beginAnchor.value),n.set(r.startLine,s);let i=o.get(r.startLine)??[];i.push({endLine:r.endLine,beginAnchor:r.beginAnchor.value,endAnchor:r.endScopeAnchor.value}),o.set(r.startLine,i);let a=n.get(r.endLine)??[];a.push(r.endScopeAnchor.value),n.set(r.endLine,a)}return t.map(r=>{let s=n.get(r.lineNumber),i=o.get(r.lineNumber);return s===void 0&&i===void 0?r:{...r,...s!==void 0&&{anchors:[...new Set([...r.anchors??[],...s])],presentation:{...r.presentation,suffix:`${r.presentation?.suffix??""}${s.map(a=>` <!-- ${a} -->`).join("")}`}},metadata:{...r.metadata,[Pe]:{...$e(r),...i!==void 0&&{boundaries:i}}}}})}p(bt,"addScopeMarkers");function $e(t){let e=t?.metadata?.[Pe];if(!(typeof e!="object"||e===null))return e}p($e,"getAstScopeMetadata");function St(t,e,n){let o=t.content.length===1?t.content[0]:void 0;if(o?.type!=="text"||t.details.lines===void 0)return t;let r=e.slice(t.details.lines.length);if(r.length===0)return t;let s=n?.lineEnding!==void 0&&n.lineEnding.length>0?n.lineEnding:r[0]?.lineEnding!==void 0&&r[0].lineEnding.length>0?r[0].lineEnding:`
7
- `,i=r.map((d,u)=>{let g=u===r.length-1?d.lineEnding:d.lineEnding||s,h=d.presentation?.prefix??"",b=d.presentation?.suffix??"";return`${h}${d.content}${b}${g}`}).join(""),a=/(?:\r\n|\r|\n)$/.test(o.text)?"":s,l=`${o.text}${a}${i}`;return{...t,content:[{...o,text:l}],details:{...t.details,lines:e}}}p(St,"appendTextLines");var _e=/^scope-(begin|end)-[A-Z0-9]{3,4}(?:-[1-9]\d*)?$/;function Me(t){return{id:"ast-scope",description:'`scope-begin-HASH` / `scope-end-HASH` from read views: ["ast"] \u2014 first/last lines of a scope. Any numeric suffix is part of the anchor.',renderFull(e){return e},renderCompact(e){return _e.exec(e)?.[1]==="begin"?"scope start":"scope end"},async tryResolve(e,n){if(!_e.test(e))return{kind:"not-handled"};try{let r=(await t.getDocumentScopes(n.source,n.cwd,n.lines)).find(s=>s.beginAnchor.value===e||s.endScopeAnchor.value===e);return r===void 0?{kind:"rejected",rejection:{code:"stale",reason:`AST scope anchor ${e} is stale`}}:{kind:"resolved",anchor:r.beginAnchor.value===e?r.beginAnchor:r.endScopeAnchor}}catch(o){return{kind:"failed",error:o}}}}}p(Me,"createAstScopeAnchorResolver");import It from"cross-spawn";import{readFile as vt,stat as Ge}from"node:fs/promises";import Lt from"node:path";import De from"node:path";import{pathToFileURL as wt}from"node:url";function Ue(t,e,n,o,r){let s=new Map;for(let a of e){let l=s.get(a.file)??[];l.push(a),s.set(a.file,l)}let i=[...s.entries()].map(([a,l])=>xt(a,l,o));return{sessionId:r,query:t,matchCount:e.length,fileCount:i.length,complete:n,files:i}}p(Ue,"createAstSearchPresentation");function xt(t,e,n){let o=new Map;e.forEach((a,l)=>{let d=a.lines.replace(/\r/gu,"").split(`
8
- `);d.at(-1)===""&&d.pop();let u=`${t}:${String(l)}`;d.forEach((f,g)=>{let h=a.range.start.line+g+1,b=Rt(a,f,g,d.length);if(b===void 0)return;let w=o.get(h)??{text:f,ranges:[],logicalMatchIds:[]};w.ranges.push(b),w.logicalMatchIds.push(u),o.set(h,w)})});let r=[...o.entries()].sort(([a],[l])=>a-l).map(([a,l])=>{let d=At(l.ranges);return{lineNumber:a,text:l.text,matchCount:d.length,ranges:d,logicalMatchIds:[...new Set(l.logicalMatchIds)]}}),s=t.includes("://"),i=s?t:De.resolve(n,t);return{path:s?i:De.relative(n,i),link:s?i:wt(i).href,matchCount:e.length,lines:r}}p(xt,"createFilePresentation");function Rt(t,e,n,o){let r=n===0,s=n===o-1,i=r?t.range.start.column:0,a=s?t.range.end.column:e.length;if(!(a<=i))return{from:Math.min(i,e.length),to:Math.min(a,e.length)}}p(Rt,"highlightedRange");function At(t){let e=[...t].sort((o,r)=>o.from-r.from||o.to-r.to),n=[];for(let o of e){let r=n.at(-1);r===void 0||o.from>r.to?n.push(o):n[n.length-1]={from:r.from,to:Math.max(r.to,o.to)}}return n}p(At,"mergeRanges");function He(t){return{id:"ast",supportsResultScope:!0,readResources:p((e,n)=>e.query.startsWith("ast:")?n.scope?.targets.map(o=>o.source)??[e.path??n.cwd]:[],"readResources"),renderResult:Le,async tryResolve(e,n){if(!e.query.startsWith("ast:"))return{kind:"not-handled"};let o=e.query.slice(4).trim();if(o.length===0)return{kind:"failed",error:new Error("ast: pattern must not be empty")};let r=p(f=>n.environmentForSource?.(f)??n.environment,"owner"),s=p(async f=>{n.scope!==void 0&&await k(n.scope,f);let g=[];if(n.scope===void 0)g.push(...await Ve(o,e,n.cwd,f,n.environment));else for(let m of new Set(n.scope.targets.map(y=>y.source)))f?.throwIfAborted(),g.push(...await Ve(o,{...e,path:m},n.cwd,f,r(m)));let h=g.map(m=>({...m,file:j(n.cwd,m.file,r(m.file))}));h.sort((m,y)=>m.file.localeCompare(y.file)||m.range.byteOffset.start-y.range.byteOffset.start||m.range.byteOffset.end-y.range.byteOffset.end);let b=[];for(let m of h){let y=(await Be([m],n.cwd,f,r(m.file)))[0];if(y===void 0)throw new Error("Missing AST selection snapshot");n.scope!==void 0&&!xe(n.scope,y)||b.push({selection:y,raw:{...m,range:{...m.range,start:{line:y.lineNumber-1,column:y.startColumn},end:{line:(y.endLineNumber??y.lineNumber)-1,column:y.endColumn}}}})}let w=b.slice(0,e.limit??100);return n.scope!==void 0&&await k(n.scope,f),{raw:w.map(m=>m.raw),matches:w.map(m=>m.selection),complete:(n.scope?.complete??!0)&&b.length<=(e.limit??100)}},"collect"),i=await s(n.signal),a=await t({request:e,matches:i.matches,complete:i.complete,refresh:s},n),l=N(i.matches,i.complete,a.id,a),d=[],u=[];for(let f of i.raw.slice(0,l.matches.length)){let g=Object.entries({...Object.fromEntries(Object.entries(f.metaVariables?.single??{}).map(([w,m])=>[w,[m]])),...f.metaVariables?.multi}),h=[],b={};for(let[w,m]of g){for(let R of m)if(R.range.byteOffset.start<f.range.byteOffset.start||R.range.byteOffset.end>f.range.byteOffset.end)throw new Error("AST capture lies outside its parent match.");let y=await Be(m.map(R=>({...f,...R})),n.cwd,n.signal,r(f.file)),x=await t({request:e,matches:y,complete:i.complete,refresh:p(async()=>{throw new Error("Capture snapshots cannot refresh; repeat the AST search.")},"refresh")},n);b[w]={target:K(N(y,i.complete,void 0,x).target),nodes:y.length};let A=[];for(let R=0;R<y.length;R+=100){let E=y.slice(R,R+100),I=await t({request:e,matches:E,complete:i.complete,refresh:p(async()=>{throw new Error("Capture snapshots cannot refresh; repeat the AST search.")},"refresh")},n);A.push(...N(E,i.complete,void 0,I).matches)}h.push([w,A])}d.push(Object.fromEntries(h)),u.push(b)}return n.scope!==void 0&&await k(n.scope,n.signal),{kind:"resolved",payload:{data:{...l,matches:l.matches.map((f,g)=>({...f,captures:d[g]}))},captureGroups:u,pattern:o,matches:i.raw.map((f,g)=>({...f,selection:i.matches[g]})),complete:i.complete,sessionId:a.id,presentation:Ue(e.query,i.raw,i.complete,n.cwd,a.id)}}},toScriptData(e){return e.data},format(e){let n=e;if(n.matches.length===0)return{content:[{type:"text",text:"No AST matches found."}],details:n.presentation};let o=n.matches.flatMap((r,s)=>{let i=[`SEARCH#${n.sessionId}:${s+1}:match ${r.file}:${r.range.start.line+1}:${r.range.start.column+1} ${r.language}`,` ${r.lines.trim()}`];for(let[a,l]of Object.entries(n.captureGroups[s]??{}))i.push(` capture ${a}: ${l.target} ${l.nodes} node(s)`);return i});return n.complete&&o.unshift(`SEARCH#${n.sessionId}:all:match selects all exact AST matches.`),{content:[{type:"text",text:o.join(`
9
- `)}],details:n.presentation}}}}p(He,"createAstSearchResolver");async function Be(t,e,n,o){let r=new Map;for(let s of t){let i=j(e,s.file,o);if(!r.has(i))if(o!==void 0)r.set(i,Buffer.from(await o.readText(i,n)));else{let a=await Ge(i),l=await vt(i,{signal:n}),d=await Ge(i);if(a.mtimeMs!==d.mtimeMs||a.size!==d.size)throw new Error("AST source changed during search. Run the structural query again.");r.set(i,l)}}return t.map(s=>{let i=j(e,s.file,o),a=r.get(i);if(a===void 0)throw new Error("Missing AST source snapshot");let{start:l,end:d}=s.range.byteOffset;if(!Number.isInteger(l)||!Number.isInteger(d)||l<0||d<l||d>a.length||a.subarray(l,d).toString("utf8")!==s.text)throw new Error("AST range does not match its source snapshot. Search again.");let u=a.subarray(0,l).toString("utf8"),f=a.subarray(0,d).toString("utf8"),g=u.split(`
10
- `).length;return{source:i,lineNumber:g,endLineNumber:f.split(`
11
- `).length,startColumn:u.length-u.lastIndexOf(`
12
- `)-1,endColumn:f.length-f.lastIndexOf(`
13
- `)-1,matchedText:s.text,lineText:a.toString("utf8").split(`
14
- `)[g-1]?.replace(/\r$/u,"")??""}})}p(Be,"selectionMatches");function Ve(t,e,n,o,r){o?.throwIfAborted();let s=["run","--pattern",t,"--json=compact","--no-ignore","parent"];for(let i of Fe(e.include))s.push("--globs",i);for(let i of Fe(e.exclude))s.push("--globs",`!${i}`);return r!==void 0?Ot(r,s,e,n,o):(j(n,e.path??"."),s.push(e.path??"."),new Promise((i,a)=>{let l=It("ast-grep",s,{cwd:n,stdio:["ignore","pipe","pipe"]}),d="",u="";l.stdout.setEncoding("utf8"),l.stderr.setEncoding("utf8"),l.stdout.on("data",g=>d+=g),l.stderr.on("data",g=>u+=g);let f=p(()=>{l.kill("SIGTERM")},"abort");o?.addEventListener("abort",f,{once:!0}),l.once("error",a),l.once("close",g=>{if(o?.removeEventListener("abort",f),o?.aborted===!0){a(o.reason instanceof Error?o.reason:new Error("AST search aborted"));return}if(g!==0&&g!==1){a(new Error(u.trim()||`ast-grep exited with code ${String(g)}`));return}try{let h=JSON.parse(d.length===0?"[]":d);if(!Array.isArray(h))throw new TypeError("ast-grep returned non-array JSON");i(h)}catch(h){a(h instanceof Error?h:new Error(String(h)))}})}))}p(Ve,"runAstGrep");function j(t,e,n){if(n!==void 0)return n.resolve(t,e);if(e.includes("://")||t.includes("://"))throw new Error("No structural search owner for this resource.");return Lt.resolve(t,e)}p(j,"resolveSource");async function Ot(t,e,n,o,r){if(t.execute===void 0)throw new Error("This resource owner does not support structural search execution.");let s=t.resolve(o,n.path??"."),i=await t.isDirectory(s,r),a=i?s:t.dirname(s);e.push(i?".":`./${t.basename(s)}`);let l=await t.execute("ast-grep",e,a,r);if(r?.throwIfAborted(),l.code!==0&&l.code!==1)throw new Error(`Structural search failed with exit ${String(l.code)}.`);let d=JSON.parse(l.stdout.length===0?"[]":l.stdout);if(!Array.isArray(d))throw new TypeError("ast-grep returned non-array JSON");return d.map(u=>({...u,file:t.resolve(a,u.file)}))}p(Ot,"runOwnedAstGrep");function Fe(t){return t?.split(",").map(e=>e.trim()).filter(Boolean)??[]}p(Fe,"splitGlobs");import{Text as Ft}from"@earendil-works/pi-tui";import ze from"node:path";import{pathToFileURL as Tt}from"node:url";function qe(t,e,n,o){let r=new Map;for(let a of t){let l=r.get(a.target.source);l?l.push(a):r.set(a.target.source,[a])}let s=[];t.length||s.push({kind:"note",text:"No selections"}),e||s.push({kind:"note",text:"Incomplete input; not a complete edit scope"}),n&&s.push({kind:"note",text:`${n} input(s) without a selection`});let i=100;for(let[a,l]of r){if(!i)break;let d=l.slice(0,i);i-=d.length;let u=a.startsWith("ssh://"),f=u?a:ze.relative(o,a)||ze.basename(a),g=[],h=!1,b=l[0]?.target.expectedContent.split(/\r\n|\n|\r/u)??[];for(let m of d){let{start:y,end:x}=m.range,R=y.lineNumber===x.lineNumber&&y.column===x.column?y.lineNumber:x.lineNumber-(x.column===0?1:0),E=Math.min(R,y.lineNumber+19);h||=E<R;for(let I=y.lineNumber;I<=E;I++){let q=b[I-1]??"";g.push({source:a,label:f,link:u?a:Tt(a).href,lineNumber:I,text:q,ranges:[{from:I===y.lineNumber?y.column:0,to:I===x.lineNumber?x.column:q.length}]})}}let w=ce(g);s.push(...w.map(m=>m.kind==="source"?{...m,count:l.length}:m)),h&&s.push({kind:"note",text:"\u2026 selection preview shortened \xB7 full target retained"});for(let m of d){m.range.start.lineNumber===m.range.end.lineNumber&&m.range.start.column===m.range.end.column&&s.push({kind:"note",text:`zero-width \xB7 ${m.range.start.lineNumber}:${m.range.start.column}`});let{start:y,end:x}=m.range;s.push({kind:"note",expandedOnly:!0,text:`${m.syntax?`${m.syntax.object}${m.syntax.part?`/${m.syntax.part}`:""} \xB7 `:""}${y.lineNumber}:${y.column}\u2013${x.lineNumber}:${x.column} \xB7 ${m.origins.length} origin(s)${m.origins.some(A=>A.expanded)?" \xB7 expanded":""}`});for(let A of m.origins.slice(0,20)){let R=A.range;s.push({kind:"note",expandedOnly:!0,text:`from ${R.startLine}:${R.startColumn}\u2013${R.endLine}:${R.endColumn}`})}m.origins.length>20&&s.push({kind:"note",expandedOnly:!0,text:"\u2026 more origins retained in this result reference"})}}return t.length>100&&s.push({kind:"note",text:"\u2026 more selections \xB7 consume the complete result target"}),{summary:`${t.length} ${t.length===1?"selection":"selections"} in ${r.size} ${r.size===1?"file":"files"}${e?"":" \xB7 incomplete"}`,rows:s}}p(qe,"selectPresentation");import Pt from"node:path";var S=class extends Error{constructor(n,o){super(o);this.code=n}static{p(this,"SelectionError")}};function v(t){return{startLine:t.start.lineNumber,startColumn:t.start.column,endLine:t.end.lineNumber,endColumn:t.end.column}}p(v,"publicRange");function T(t,e){let n=JSON.stringify([e.target.source,e.range]),o=t.get(n);t.set(n,o?{...e,origins:[...o.origins,...e.origins]}:e)}p(T,"retainRegion");var L=class{constructor(e){this.content=e;let n=0,o=Y("",e),r=o.lines.map(s=>{let i=n;return n+=s.content.length+s.lineEnding.length,{start:i,length:s.content.length,end:n}});(r.length===0||o.lines.at(-1)?.lineEnding)&&r.push({start:n,length:0,end:n}),this.lines=r}static{p(this,"SourceText")}lines;boundary(e){if(!Number.isSafeInteger(e)||e<0||e>this.content.length)throw new S("INVALID_RANGE","Text bounds are outside the retained snapshot.");let n=this.content.charCodeAt(e-1),o=this.content.charCodeAt(e);if(n>=55296&&n<=56319&&o>=56320&&o<=57343||n===13&&o===10)throw new S("INVALID_BOUNDARY","Text boundary splits a surrogate pair or CRLF separator.")}offset(e){let n=this.lines[e.lineNumber-1];if(!Number.isSafeInteger(e.lineNumber)||!n||!Number.isSafeInteger(e.column)||e.column<0||e.column>n.length)throw new S("INVALID_RANGE","Source bounds are outside the retained snapshot.");let o=n.start+e.column;return this.boundary(o),o}lineIndex(e){let n=0,o=this.lines.length-1;for(;n<o;){let r=Math.ceil((n+o)/2);(this.lines[r]?.start??0)<=e?n=r:o=r-1}return n}position(e){this.boundary(e);let n=this.lineIndex(e);return{lineNumber:n+1,column:e-(this.lines[n]?.start??0)}}range(e,n){if(n<e)throw new S("INVALID_RANGE","Text bounds are reversed.");return{start:this.position(e),end:this.position(n)}}fullLines(e,n){let o=this.lines[this.lineIndex(e)],r=this.lines[this.lineIndex(n>e?n-1:e)];if(!o||!r)throw new S("INVALID_RANGE","Source line bounds are unavailable.");return{from:o.start,to:r.end}}};function Je(t,e,n){let o=t;for(;o.parent&&o.parent.node.startIndex===o.node.startIndex&&o.parent.node.endIndex===o.node.endIndex;)o=o.parent;let r=o.parent;if(!r||!(r.node.type==="arguments"&&r.parent?.object==="call"||r.node.type==="formal_parameters"&&r.parent?.object==="function")||o.node.type==="comment")throw new S("EXACT_LIST_ELEMENT_REQUIRED","elementExtent requires an exact direct call argument or parenthesized function parameter. Use a full AST capture; partial expressions and other lists are not supported.");let s=r.node.startIndex,i=r.node.endIndex-1;if(n[s]!=="("||n[i]!==")")throw new S("UNSUPPORTED_LIST","Only parenthesized argument and parameter lists are supported.");if(e==="inside")return{startIndex:o.node.startIndex,endIndex:o.node.endIndex};let a=r.children.filter(w=>w.node.type!=="comment"),l=a.indexOf(o),d=a[l-1],u=a[l+1],f=d?.node.endIndex??s+1,g=u?.node.startIndex??i,h=n.slice(f,o.node.startIndex),b=n.slice(o.node.endIndex,g);if(!(d?/^\s*,\s*$/u:/^\s*$/u).test(h)||!(u?/^\s*,\s*$/u:/^\s*,?\s*$/u).test(b))throw new S("AMBIGUOUS_LIST_TRIVIA","Comments or unsupported trivia in adjacent list gaps have no inferred owner. Use inside for the exact element, or choose explicit text boundaries.");return a.length===1?{startIndex:s+1,endIndex:i}:u||b.includes(",")?{startIndex:o.node.startIndex,endIndex:g}:{startIndex:f,endIndex:o.node.endIndex}}p(Je,"listElementExtent");var Et={function_declaration:"function",generator_function_declaration:"function",function_expression:"function",generator_function:"function",arrow_function:"function",method_definition:"function",function_signature:"function",method_signature:"function",abstract_method_signature:"function",call_expression:"call",new_expression:"call",class_declaration:"class",class:"class",abstract_class_declaration:"class",if_statement:"if",switch_statement:"switch",for_statement:"loop",for_in_statement:"loop",while_statement:"loop",do_statement:"loop",try_statement:"try",catch_clause:"catch",variable_declarator:"binding",assignment_expression:"assignment",augmented_assignment_expression:"assignment",object:"object",object_pattern:"object",pair:"property",pair_pattern:"property",shorthand_property_identifier:"property",shorthand_property_identifier_pattern:"property",array:"array",array_pattern:"array",return_statement:"return",throw_statement:"throw"};function Xe(t,e){let n=[],o=[{node:t,parent:void 0}];for(;o.length;){e?.throwIfAborted();let r=o.pop();if(!r)continue;let s={node:r.node,object:Et[r.node.type],parent:r.parent,children:[]};r.parent?.children.push(s),n.push(s);for(let i of r.node.namedChildren.toReversed())o.push({node:i,parent:s})}return n}p(Xe,"constructIndex");function O(t){let e=t.parent;for(;e&&!e.object;)e=e.parent;return e}p(O,"constructParent");function V(t,e,n){let o=[],r=[...t.children].reverse();for(;r.length;){n?.throwIfAborted();let s=r.pop();s&&(s.object&&o.push(s),(e||!s.object)&&r.push(...s.children.toReversed()))}return o}p(V,"constructChildren");var kt={function:[["name",["name"]],["body",["body"]],["parameters",["parameters","parameter"]],["returnType",["return_type"]]],call:[["callee",["function","constructor"]],["arguments",["arguments"]]],class:[["name",["name"]],["body",["body"]]],if:[["condition",["condition"]],["then",["consequence"]],["else",["alternative"]]],switch:[["condition",["value"]],["body",["body"]]],loop:[["condition",["condition"]],["body",["body"]]],try:[["body",["body"]],["handler",["handler"]],["finalizer",["finalizer"]]],catch:[["body",["body"]],["parameter",["parameter"]]],binding:[["name",["name"]],["type",["type"]],["value",["value"]]],assignment:[["left",["left"]],["right",["right"]]],property:[["key",["key"]],["value",["value"]]],return:[["value",[]]],throw:[["value",[]]],object:[],array:[]};function Nt(t){return t.node.type==="for_statement"?[["initializer",["initializer"]],["condition",["condition"]],["update",["increment"]],["body",["body"]]]:t.node.type==="for_in_statement"?[["left",["left"]],["iterable",["right"]],["body",["body"]]]:t.node.type==="finally_clause"?[["body",["body"]]]:t.object?kt[t.object]:[]}p(Nt,"partFields");function We(t,e){let n=Nt(t),o=n.find(([r])=>r===e)?.[1];if(!o)throw new S("UNSUPPORTED_PART",`Unsupported part ${e} for ${t.object??"this syntax container"}; supported parts: ${n.map(([r])=>r).join(", ")||"none"}. Use navigate children/descendants for nested constructs.`);if(t.object==="property"&&t.node.type.startsWith("shorthand_property_identifier"))return t.node;if(t.object==="return"||t.object==="throw")return t.node.namedChildren.find(r=>r.type!=="comment");for(let r of o){let s=t.node.childForFieldName(r);if(s)return s}}p(We,"constructPart");var jt=new Set([".js",".mjs",".cjs",".ts",".mts",".cts"]);function Ct(t,e,n){let o=t.filter(s=>s.node.startIndex===e&&s.node.endIndex===n),r=o.find(s=>s.object)??o.at(-1);if(!r)throw new S("EXACT_NODE_REQUIRED","Navigation and parts require an exact syntax node. Use object/enclosing first for a partial match; use a returned part target to navigate its contents.");return r}p(Ct,"exactNode");function $t(t,e,n,o){let r;for(let i of t)i.object!==o.object||i.node.startIndex>e||i.node.endIndex<n||e===n&&i.node.endIndex===n||(!r||i.node.endIndex-i.node.startIndex<r.node.endIndex-r.node.startIndex)&&(r=i);if(!r&&t.some(i=>i.object===o.object&&i.node.startIndex<n&&i.node.endIndex>e))throw new S("AMBIGUOUS_SEED","The seed crosses a construct boundary or spans separate constructs; select narrower input ranges.");let s=1;for(;r&&s<(o.level??1);){for(r=O(r);r&&r.object!==o.object;)r=O(r);s++}return r}p($t,"enclosing");function _t(t,e,n,o){let r;switch(e.relation){case"parent":{let s=O(t);r=s?[s]:[];break}case"ancestors":{r=[];let s=O(t);for(;s;)o?.throwIfAborted(),r.push(s),s=O(s);break}case"children":case"descendants":{r=V(t,e.relation==="descendants",o);break}case"siblings":{if(!t.object)throw new S("EXACT_CONSTRUCT_REQUIRED","siblings requires an exact supported construct, not a part container. Use enclosing first.");let s=V(O(t)??n,!1,o),i=s.indexOf(t),a=e.direction??"all",l=a==="previous"?s[i-1]:s[i+1];r=a==="all"?s.filter(d=>d!==t):l?[l]:[];break}}return r.filter(s=>!e.object||s.object===e.object).sort((s,i)=>s.node.startIndex-i.node.startIndex||i.node.endIndex-s.node.endIndex)}p(_t,"navigate");async function Ke(t,e,n,o){let r=new Map,s=0;for(let i of t.targets){if(o?.throwIfAborted(),!jt.has(Pt.extname(i.source).toLowerCase()))throw new S("UNSUPPORTED_LANGUAGE","Select AST supports JavaScript and TypeScript files, without JSX/TSX.");let a=await P(i.source,n,i.expectedContent.split(`
15
- `));if(!a)throw new S("UNSUPPORTED_PROVIDER","No syntax provider is available for this source.");try{if(a.rootNode.hasError)throw new S("INVALID_SYNTAX","The syntax provider reports errors; no structural targets were created.");let l=Xe(a.rootNode,o),d=l[0];if(!d)throw Error("Missing syntax root");let u=new L(i.expectedContent);for(let f of i.ranges){o?.throwIfAborted();let g=u.offset(f.start),h=u.offset(f.end),b=e.kind==="object"?$t(l,g,h,e):Ct(l,g,h),w=b&&e.kind==="elementExtent"?Je(b,e.extent,i.expectedContent):void 0,m=b?e.kind==="part"?[We(b,e.part)].filter(y=>y!==void 0).map(y=>({node:y,object:b.object})):e.kind==="navigate"?_t(b,e,d,o):[b]:[];m.length||s++;for(let y of m){let x=w??y.node,A=y.object&&e.kind!=="elementExtent"?{object:y.object,...e.kind==="part"?{part:e.part}:{}}:void 0;T(r,{target:i,range:{start:u.position(x.startIndex),end:u.position(x.endIndex)},text:i.expectedContent.slice(x.startIndex,x.endIndex),origins:[{source:i.source,range:v({start:f.start,end:u.position(h)}),expanded:x.startIndex<g||x.endIndex>h}],...A?{syntax:A}:{}})}}}finally{a.delete?.()}}return{regions:[...r.values()],missingInputs:s}}p(Ke,"selectStructuralRegions");function Qe(t,e,n){n?.throwIfAborted();let o=e.kind==="range"||e.kind==="lines";if(o&&new Set(t.targets.map(i=>i.source)).size>1)throw new S("MULTIPLE_SOURCES","Absolute text bounds require one source.");let r=new Map,s=0;for(let i of t.targets){n?.throwIfAborted();let a=new L(i.expectedContent),l=o?Mt(a,e):void 0,d=!1;for(let u of i.ranges){n?.throwIfAborted();let f=a.offset(u.start),g=a.offset(u.end);a.range(f,g);let h=l?l.from>=f&&l.to<=g?[l]:[]:Dt(a,{from:f,to:g},e,n);h.length?d=!0:s++;for(let b of h){n?.throwIfAborted();let w=a.range(b.from,b.to),m=b.from<f||b.to>g;if(m&&e.kind!=="linesOf"&&!(e.kind==="between"&&e.extent==="lines"))throw new S("OUTSIDE_SCOPE","Text selection exceeds its input scope.");T(r,{target:i,range:w,text:a.content.slice(b.from,b.to),origins:[{source:i.source,range:v(u),expanded:m}]})}}if(l&&!d)throw new S("OUTSIDE_SCOPE","Requested text bounds are outside every input scope.")}return{regions:[...r.values()],missingInputs:s}}p(Qe,"selectTextRegions");function Mt(t,e){if(e.kind==="range"){let r=t.offset({lineNumber:e.startLine,column:e.startColumn}),s=t.offset({lineNumber:e.endLine,column:e.endColumn});return t.range(r,s),{from:r,to:s}}let n=t.lines[e.first-1],o=t.lines[e.last-1];if(!Number.isSafeInteger(e.first)||!Number.isSafeInteger(e.last)||!n||!o||e.last<e.first)throw new S("INVALID_RANGE","Line bounds are outside the retained snapshot or reversed.");return{from:n.start,to:o.end}}p(Mt,"absoluteInterval");function Dt(t,e,n,o){let r=t.content.slice(e.from,e.to);switch(n.kind){case"between":{F(n.start),F(n.end);let s=[],i=0;for(;i<=r.length;){o?.throwIfAborted();let a=r.indexOf(n.start,i);if(a<0)break;let l=r.indexOf(n.end,a+n.start.length);if(l<0)throw new S("UNMATCHED_MARKER","Opening marker has no following closing marker in its input scope.");let d=e.from+a,u=e.from+l+n.end.length;t.boundary(d),t.boundary(d+n.start.length),t.boundary(e.from+l),t.boundary(u),s.push(n.extent==="lines"?t.fullLines(d,u):{from:n.extent==="inside"?d+n.start.length:d,to:n.extent==="inside"?e.from+l:u}),i=l+n.end.length}return s}case"sliceText":{let s=n.to??r.length;return Ye(n.from,s,r.length),[{from:e.from+n.from,to:e.from+s}]}case"trim":{if(!r.trim().length)return[{from:e.to,to:e.to}];let s=n.side==="end"?0:r.length-r.trimStart().length,i=n.side==="start"?r.length:r.trimEnd().length;return[{from:e.from+s,to:e.from+i}]}case"split":{F(n.delimiter);let s=[],i=0;for(;i<=r.length;){o?.throwIfAborted();let a=r.indexOf(n.delimiter,i);if(s.push({from:e.from+i,to:a<0?e.to:e.from+a}),a<0)break;i=a+n.delimiter.length}return s}case"linesOf":return[t.fullLines(e.from,e.to)];case"position":{let s=n.edge==="before"?e.from:e.to;return[{from:s,to:s}]}case"columns":{let s=[],i=t.lineIndex(e.from),a=t.lineIndex(e.to>e.from?e.to-1:e.from);for(let l=i;l<=a;l++){o?.throwIfAborted();let d=t.lines[l];if(!d)throw new S("INVALID_RANGE","Source line bounds are unavailable.");Ye(n.from,n.to,d.length);let u={from:d.start+n.from,to:d.start+n.to};if(u.from<e.from||u.to>e.to)throw new S("OUTSIDE_SCOPE","Requested columns exceed their input scope.");s.push(u)}return s}case"range":case"lines":throw new S("INVALID_RANGE","Absolute bounds must resolve against one source.")}}p(Dt,"transform");function F(t){if(!t.length)throw new S("INVALID_MARKER","Use a non-empty literal marker or delimiter.")}p(F,"nonEmpty");function Ye(t,e,n){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(e)||t<0||e<t||e>n)throw new S("INVALID_RANGE","Text bounds are outside their region or reversed.")}p(Ye,"orderedBounds");function tt(t,e,n,o){o?.throwIfAborted();let r=new Map;for(let d of[...t.targets,...n.targets]){o?.throwIfAborted();let u=r.get(d.source);if(u&&u.content!==d.expectedContent)throw new S("INCOMPATIBLE_SNAPSHOTS","Geometry inputs use different snapshots of the same source.");u||r.set(d.source,new L(d.expectedContent))}let s=Ze(t,r,o),i=Ze(n,r,o),a=new Map,l=0;for(let[d,u]of s){o?.throwIfAborted();let f=r.get(d);if(!f)throw new S("MISSING_SOURCE","Verified source text is unavailable.");let g=i.get(d)??[],h=et(g.map($),!0,o),b=[];if(e.kind==="merge")b.push(...et(u.map($),e.adjacent??!1,o));else for(let w of u){o?.throwIfAborted();let m=Ut(w,g,h,e.kind,o);m.length||l++,b.push(...m)}for(let w of b){o?.throwIfAborted();let m=w.seeds[0];if(!m)throw new S("MISSING_ORIGIN","Geometry output has no candidate origin.");T(a,{target:m.target,range:f.range(w.from,w.to),text:f.content.slice(w.from,w.to),origins:w.seeds.map(y=>({source:d,range:v(y.range),expanded:w.from<y.from||w.to>y.to}))})}}return{regions:[...a.values()],missingInputs:l}}p(tt,"selectGeometryRegions");function Ze(t,e,n){let o=new Map;for(let r of t.targets){let s=e.get(r.source);if(!s)throw new S("MISSING_SOURCE","Verified source text is unavailable.");let i=o.get(r.source)??[];for(let a of r.ranges){n?.throwIfAborted();let l=s.offset(a.start),d=s.offset(a.end);s.range(l,d),i.push({target:r,range:a,from:l,to:d})}o.set(r.source,i)}return o}p(Ze,"seedsBySource");function $(t){return{from:t.from,to:t.to,seeds:[t]}}p($,"asSpan");function C(t,e){return e.from===e.to?t.from===t.to?e.from===t.from:t.from<=e.from&&e.from<t.to:t.from<=e.from&&e.to<=t.to}p(C,"contains");function Ut(t,e,n,o,r){if(o==="within")return e.some(a=>C(a,t))?[$(t)]:[];if(t.from===t.to)return n.some(l=>C(l,t))===(o==="intersection")?[$(t)]:[];if(o==="intersection"){let a=[];for(let l of n)if(r?.throwIfAborted(),l.from===l.to)C(t,l)&&a.push({from:l.from,to:l.to,seeds:[t]});else{let d=Math.max(t.from,l.from),u=Math.min(t.to,l.to);d<u&&a.push({from:d,to:u,seeds:[t]})}return a}let s=[],i=t.from;for(let a of n)if(r?.throwIfAborted(),!(a.from===a.to||a.to<=i||a.from>=t.to)&&(a.from>i&&s.push({from:i,to:a.from,seeds:[t]}),i=Math.max(i,a.to),i>=t.to))break;return i<t.to&&s.push({from:i,to:t.to,seeds:[t]}),s}p(Ut,"transform");function et(t,e,n){let o=[...t].sort((i,a)=>i.from-a.from||i.to-a.to),r=[];for(let i of o){if(n?.throwIfAborted(),i.from===i.to)continue;let a=r.at(-1);a&&(i.from<a.to||e&&i.from===a.to)?r[r.length-1]={from:a.from,to:Math.max(a.to,i.to),seeds:[...a.seeds,...i.seeds]}:r.push(i)}let s=new Map;for(let i of o){if(n?.throwIfAborted(),i.from!==i.to)continue;let a=r.findIndex(u=>C(u,i)),l=a>=0?r[a]:s.get(i.from),d=l?{...l,seeds:[...l.seeds,...i.seeds]}:i;a>=0?r[a]=d:s.set(i.from,d)}return[...r,...s.values()].sort((i,a)=>i.from-a.from||i.to-a.to)}p(et,"mergeSpans");import{Type as c}from"typebox";var Gt=c.Union([c.Object({kind:c.Literal("range"),startLine:c.Integer({minimum:1}),startColumn:c.Integer({minimum:0}),endLine:c.Integer({minimum:1}),endColumn:c.Integer({minimum:0})},{additionalProperties:!1,description:"Use absolute one-based lines and exclusive UTF-16 columns in one source. Require full containment in an input region."}),c.Object({kind:c.Literal("lines"),first:c.Integer({minimum:1}),last:c.Integer({minimum:1})},{additionalProperties:!1,description:"Use inclusive absolute line numbers in one source. Include existing line endings; require full containment in an input region."}),c.Object({kind:c.Literal("between"),start:c.String({minLength:1}),end:c.String({minLength:1}),extent:c.Union([c.Literal("inside"),c.Literal("around"),c.Literal("lines")])},{additionalProperties:!1,description:"Pair non-empty literal opening markers with the next closing marker per region, without nesting. Resume after each pair; unmatched openings are errors. inside excludes markers, around includes them, lines explicitly expands to complete containing lines."}),c.Object({kind:c.Literal("sliceText"),from:c.Integer({minimum:0}),to:c.Optional(c.Integer({minimum:0}))},{additionalProperties:!1,description:"Slice each region by non-negative relative UTF-16 offsets. The exclusive to defaults to its end. Equal offsets select a zero-width point."}),c.Object({kind:c.Literal("trim"),side:c.Union([c.Literal("start"),c.Literal("end"),c.Literal("both")])},{additionalProperties:!1,description:"Trim Unicode whitespace from the requested edges of each region. A whitespace-only region selects a zero-width point at its end."}),c.Object({kind:c.Literal("split"),delimiter:c.String({minLength:1})},{additionalProperties:!1,description:"Split each region by a non-empty literal delimiter, excluding delimiters and retaining empty segments as zero-width points."}),c.Object({kind:c.Literal("linesOf")},{additionalProperties:!1,description:"Expand each region to complete containing lines, preserving line endings and reporting expansion. An exclusive end at next-line column zero does not include that next line."}),c.Object({kind:c.Literal("position"),edge:c.Union([c.Literal("before"),c.Literal("after")])},{additionalProperties:!1,description:"Select the zero-width start or end of each region. Use a whole-file Read for file edges."}),c.Object({kind:c.Literal("columns"),from:c.Integer({minimum:0}),to:c.Integer({minimum:0})},{additionalProperties:!1,description:"Select an exclusive UTF-16 column interval on each touched line, excluding line endings. Every interval must fit its line and original input region; no clipping."})]);function H(t,e){return c.Object({kind:c.Literal(t),scopes:{...D,description:"Comparison scopes: unchanged results, issued UUIDs or item references, arrays of those strings, or a readable source path. Match sets by source, not array position."}},{additionalProperties:!1,description:e})}p(H,"scopedOperation");var Bt=c.Union([H("within","Retain each candidate whole only when one comparison scope contains it. Never clip or join scopes for containment."),H("intersection","Clip each candidate to the union of comparison scopes in its source. Touching text ranges do not create a point."),H("difference","Subtract comparison scopes from each candidate, retaining separate surviving fragments. Point scopes do not cut text."),c.Object({kind:c.Literal("merge"),adjacent:c.Optional(c.Boolean({description:"Also merge touching nonempty ranges. Default false; never fill a gap or extend text for a point."}))},{additionalProperties:!1,description:"Explicitly merge overlapping ranges by source, retaining every contributing origin. Covered points are absorbed; other points remain separate."})]),z=c.Union([c.Literal("function"),c.Literal("call"),c.Literal("class"),c.Literal("if"),c.Literal("switch"),c.Literal("loop"),c.Literal("try"),c.Literal("catch"),c.Literal("binding"),c.Literal("assignment"),c.Literal("object"),c.Literal("property"),c.Literal("array"),c.Literal("return"),c.Literal("throw")]),ot=c.Union([c.Literal("name"),c.Literal("body"),c.Literal("parameters"),c.Literal("returnType"),c.Literal("type"),c.Literal("callee"),c.Literal("arguments"),c.Literal("condition"),c.Literal("then"),c.Literal("else"),c.Literal("initializer"),c.Literal("update"),c.Literal("iterable"),c.Literal("left"),c.Literal("right"),c.Literal("value"),c.Literal("key"),c.Literal("handler"),c.Literal("finalizer"),c.Literal("parameter")]),nt=c.Optional({...z,description:"Filter results by construct category after navigation. The filter does not change parent/child/sibling relationships."}),Vt=c.Union([c.Object({kind:c.Literal("elementExtent"),extent:c.Union([c.Literal("inside"),c.Literal("around")])},{additionalProperties:!1,description:"Select an exact direct JS/TS call argument or parenthesized function parameter. inside keeps the element; around includes owned comma/whitespace. around includes the following gap; the last element without a trailing comma includes the preceding gap, and an only element includes the whole list interior. Adjacent boundary comments reject around. No destination syntax repair."}),c.Object({kind:c.Literal("object"),object:z,relation:c.Optional(c.Literal("enclosing")),level:c.Optional(c.Integer({minimum:1,description:"Default 1 (nearest). Count only constructs of the requested category."})),extent:c.Optional(c.Literal("around"))},{additionalProperties:!1,description:"Select the requested containing construct. level=1 is nearest and includes an exact seed; higher levels count only that category. Match the entire seed, not its first character."}),c.Object({kind:c.Literal("part"),part:ot},{additionalProperties:!1,description:"Select an exact supported construct's named part, including delimiters belonging to its syntax node. A supported optional part may be absent; unsupported parts are errors with available names. Use an enclosing object first for partial input."}),c.Object({kind:c.Literal("navigate"),relation:c.Union([c.Literal("parent"),c.Literal("ancestors"),c.Literal("children"),c.Literal("descendants")]),object:nt},{additionalProperties:!1,description:"Navigate from an exact named syntax node, including constructs, part targets and the document root. Skip parser-only wrappers in results. Exclude the starting node; ancestors/descendants return results in source order. parent/children never skip recognized constructs to satisfy a filter. Use enclosing first for ranges that cut through a node."}),c.Object({kind:c.Literal("navigate"),relation:c.Literal("siblings"),object:nt,direction:c.Optional(c.Union([c.Literal("previous"),c.Literal("next"),c.Literal("all")],{description:"Default all. previous/next select the immediate sibling before category filtering, not the next matching category."}))},{additionalProperties:!1,description:"Select siblings of an exact supported construct under the same normalized parent. Exclude the input; return source order. A missing neighbor is valid absence."})]),st=c.Object({path:{...D,description:"File path, unchanged Read/Search/Select/edit result, its UUID, or an array of such results. Pass the whole result; do not rebuild it from preview text."},operation:c.Union([Vt,Gt,Bt],{description:"Choose a text, syntax or range-set operation. Text operations apply separately to each input region; range/lines require one source. Use UTF-16 bounds that do not split surrogate pairs or CRLF. Range-set operations match sources and snapshots, not array positions."})},{additionalProperties:!1}),rt=c.Object({startLine:c.Integer({minimum:1}),startColumn:c.Integer({minimum:0}),endLine:c.Integer({minimum:1}),endColumn:c.Integer({minimum:0})},{additionalProperties:!1}),_=c.Object({kind:c.Literal("selection"),target:c.String({description:"Stored target for every selected range, including items beyond the preview."}),complete:c.Boolean({description:"Execution completeness inherited from all inputs, independent of preview limits."}),totalItems:c.Integer({minimum:0}),missingInputs:c.Integer({minimum:0}),truncated:c.Boolean(),items:c.Array(c.Object({target:c.String(),source:c.String(),range:rt,syntax:c.Optional(c.Object({object:z,part:c.Optional(ot)},{additionalProperties:!1,description:"Parser-derived normalized construct category and selected part. This describes the target; it is not edit authority."})),origins:c.Array(c.Object({source:c.String(),range:rt,expanded:c.Boolean()},{additionalProperties:!1})),preview:c.String({maxLength:1e3}),textTruncated:c.Boolean()},{additionalProperties:!1}),{maxItems:100})},{additionalProperties:!1}),it=ue(_);function Ht(t){let e=[`${t.totalItems} selection(s)${t.complete?"":" \xB7 incomplete input"}`];t.complete||e.push("Obtain complete source selections before checking absence or editing."),t.missingInputs&&e.push(`${t.missingInputs} input range(s) produced no selection`);for(let n of t.items){let o=n.range;e.push(`${n.target} ${n.source}:${o.startLine}:${o.startColumn}\u2013${o.endLine}:${o.endColumn}${n.syntax?` ${n.syntax.object}${n.syntax.part?`/${n.syntax.part}`:""}`:""}`,n.preview),o.startLine===o.endLine&&o.startColumn===o.endColumn&&e.push("Zero-width position; no text selected."),n.textTruncated&&e.push("\u2026 preview shortened; pass this item reference to consume the full selection")}return t.truncated&&e.push("\u2026 more selections retained; pass the whole result to consume all selections"),e.join(`
16
- `)}p(Ht,"selectionText");function zt(t){switch(t.kind){case"object":return`enclosing ${t.object} \xB7 level ${t.level??1}`;case"part":return`part ${t.part}`;case"elementExtent":return`list element \xB7 ${t.extent}`;case"navigate":return`${t.relation}${t.relation==="siblings"?` ${t.direction??"all"}`:""}${t.object?` \xB7 ${t.object}`:""}`;case"between":return`between ${JSON.stringify(t.start)} \u2026 ${JSON.stringify(t.end)} \xB7 ${t.extent}`;case"range":return`range ${t.startLine}:${t.startColumn}\u2013${t.endLine}:${t.endColumn}`;case"lines":return`lines ${t.first}\u2013${t.last}`;case"sliceText":return`text slice ${t.from}\u2013${t.to??"end"}`;case"trim":return`trim ${t.side}`;case"split":return`split ${JSON.stringify(t.delimiter)}`;case"linesOf":return"containing lines";case"position":return`position ${t.edge}`;case"columns":return`columns ${t.from}\u2013${t.to}`;case"within":case"intersection":case"difference":return t.kind;case"merge":return t.adjacent?"merge overlaps and adjacent ranges":"merge overlaps"}}p(zt,"operationLabel");function at(t){return t.kind==="within"||t.kind==="intersection"||t.kind==="difference"||t.kind==="merge"}p(at,"isGeometryOperation");async function ct(t,e){let n=me(t);ne(t,[await te({id:"select-code",description:"Derive text and AST boundaries, navigate constructs and combine source-range sets",triggers:[{tool:"select"}]})]),t.registerTool(Ae({name:"select",label:"select",exposure:"direct",namespace:{name:"ide_select",description:"Derive exact source boundaries from existing targets."},annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},description:"Use select to derive text ranges or positions, navigate JavaScript/TypeScript constructs and their parts (without JSX/TSX), and combine source-local selections. Pass the returned result or an item reference to Read, Search or an edit tool. Select does not change files.",promptSnippet:"Derive text and AST boundaries, navigate constructs and combine source-range sets",promptGuidelines:["Use Search for predicate matches and existing captures; use Select when a target needs new text or structural boundaries.","Compare the enclosing owner of each inner match with the original function when checking a condition in that function's own body."],parameters:st,outputSchema:it,renderCall(o,r,s){return le(s.lastComponent,{tool:"select",primary:{text:zt(o.operation),color:"accent"},qualifiers:[{text:typeof o.path=="string"&&!o.path.startsWith("RESULT#")?o.path:"in result scope"}],expanded:s.expanded},r)},renderResult(o,r,s){let i=o.details;return typeof i?.summary=="string"&&Array.isArray(i.rows)?new ae(i,s,r.expanded):new Ft(o.content.flatMap(a=>a.type==="text"?[a.text]:[]).join(`
17
- `),0,0)},async execute(o,r,s,i,a){try{s?.throwIfAborted();let l=p(async m=>{if(typeof m=="string"&&!m.startsWith("RESULT#")){let y=await e.read({path:m},{cwd:a.cwd,...s!==void 0&&{signal:s}},"script");if(y.isError)throw new Error("Select could not read this source.");m=y.script}return n.resolve(m,a.cwd)},"resolve"),d=await l(r.path),u=r.operation,f=at(u)&&"scopes"in u?await l(u.scopes):{targets:[],complete:!0},g={targets:[...d.targets,...f.targets],complete:d.complete&&f.complete};await n.verify(g,s);let h=at(u)?tt(d,u,f,s):u.kind==="object"||u.kind==="part"||u.kind==="navigate"||u.kind==="elementExtent"?await Ke(d,u,a.cwd,s):Qe(d,u,s);await n.verify(g,s),s?.throwIfAborted();let b=h.regions.map(m=>({...m.target,ranges:[m.range]})),w={kind:"selection",target:n.register(b,a.cwd,g.complete),complete:g.complete,totalItems:h.regions.length,missingInputs:h.missingInputs,truncated:h.regions.length>100,items:h.regions.slice(0,100).map(m=>{let y=m.text.slice(0,1e3).replace(/[\uD800-\uDBFF]$/u,"");return{target:n.register([{...m.target,ranges:[m.range]}],a.cwd,g.complete),source:m.target.source,range:v(m.range),origins:m.origins,...m.syntax?{syntax:m.syntax}:{},preview:y,textTruncated:y.length<m.text.length}})};return M({content:[{type:"text",text:Ht(w)}],details:qe(h.regions,g.complete,h.missingInputs,a.cwd)},_,{status:"success",data:w,errors:[]})}catch(l){if(s?.aborted)throw l;return M({content:[{type:"text",text:`${l instanceof Error?l.message:String(l)}
18
- Resolve the reported error before retrying. Do not treat a failed selection as an empty result.`}],details:void 0},_,{status:"error",errors:[pe(l,"SELECT_FAILED")]})}}},new Re))}p(ct,"registerSelect");var qt=de({kind:"code-view",label:"AST"});async function lt(t){let e=new Oe,n=je(e),o={protocol:oe,apiVersion:se,id:"ast",async setup(s){s.addResolver({resolver:ke(void 0,async(l,d)=>{let u=await s.read({path:l},d,"script");if(u.isError===!0)throw new Error(u.details.failure?.message??"Could not acquire an owned text snapshot for the AST outline.");if(u.script?.kind!=="text")throw new Error("AST outlines require an owned text snapshot.");return{source:u.script.source,lines:u.script.lines.map(f=>f.content)}}),renderResult:qt}),s.addHandler({stage:"read",when:{resolvedBy:"ast",contentKind:"text"},handler:Q()}),s.addView({view:"ast",presenter:n});let i=Ne();s.addOutputReducer(B);let a=Ce();s.addHandler({stage:"post-read",async handler(l){let d=await i(l);return d.kind==="return"||d.transform!==void 0?d:a(d.context)}}),s.describe({path:"ast:<path> \u2014 compact declaration outline for a code file.",views:"ast \u2014 scope boundaries alongside source text."}),await ct(t,s)}},r={protocol:fe,apiVersion:ge,id:"ast",setup(s){s.addAnchorResolver({resolver:Me(e),kind:he,type:"auxiliary"}),s.addTextPresenter({presenter:n})}};await Promise.all([ie(t,o),re(t,Ee),ye(t,r),we(t,{protocol:be,apiVersion:Se,id:"ast-search",setup(s){s.addResolver({resolver:He(s.registerSelection)}),s.describe("Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search. Use returned SEARCH# references to read, replace, copy, move or delete exact AST matches, including multiline nodes. A single :match reference becomes stale after its file changes; :all:match reruns the original structural query. Incomplete results do not provide all selections. Use the displayed capture NAME reference as a Search/Select/edit source. Single captures contain one node; multi captures retain provider nodes, including punctuation. Strict result scopes return only wholly contained matches. These edits do not update imports or references.")}})])}p(lt,"registerAst");export{lt as default};
1
+ import{b as e,c as o}from"./chunk-UEVGZUII.js";import"./chunk-ZPT5D4VP.js";import"./chunk-EI7MMDWY.js";export{o as AstScopeManager,e as parseDocument};