pi-agent-ide 0.6.0 → 0.6.2

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 (448) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +146 -68
  3. package/assets/social-preview.png +0 -0
  4. package/assets/summary/debugging.png +0 -0
  5. package/assets/summary/editing.png +0 -0
  6. package/assets/summary/read.png +0 -0
  7. package/assets/summary/search-and-replace.png +0 -0
  8. package/assets/summary/search.png +0 -0
  9. package/assets/summary/settings.png +0 -0
  10. package/assets/summary/terminal.png +0 -0
  11. package/assets/summary/thumbs/debugging.png +0 -0
  12. package/assets/summary/thumbs/editing.png +0 -0
  13. package/assets/summary/thumbs/read.png +0 -0
  14. package/assets/summary/thumbs/search-and-replace.png +0 -0
  15. package/assets/summary/thumbs/search.png +0 -0
  16. package/assets/summary/thumbs/settings.png +0 -0
  17. package/assets/summary/thumbs/terminal.png +0 -0
  18. package/assets/summary/thumbs/user_terminal.png +0 -0
  19. package/assets/summary/user_terminal.png +0 -0
  20. package/dist/chunk-3E2NTWCN.js +2 -0
  21. package/dist/chunk-7WCZOO5I.js +1 -0
  22. package/dist/chunk-CEX3VOJ7.js +2 -0
  23. package/dist/chunk-FA6BKC5Y.js +1 -0
  24. package/dist/{chunk-2527OQ4Y.js → chunk-HMLH43ZS.js} +1 -1
  25. package/dist/chunk-LVWMWWWF.js +28 -0
  26. package/dist/chunk-MPT3R4BL.js +0 -0
  27. package/dist/chunk-PZFOOHY2.js +15 -0
  28. package/dist/{chunk-HKMBQLEK.js → chunk-QDLTO5PH.js} +1 -1
  29. package/dist/{chunk-Z3VC3S2T.js → chunk-QIK2E64R.js} +1 -1
  30. package/dist/{chunk-OYWIZII6.js → chunk-S6QRG3TQ.js} +1 -1
  31. package/dist/chunk-T7CZIACQ.js +27 -0
  32. package/dist/chunk-T7I2VX3J.js +1 -0
  33. package/dist/chunk-VCTK4JSN.js +3 -0
  34. package/dist/chunk-VXD6FZP5.js +5 -0
  35. package/dist/chunk-W7CASEO3.js +1 -0
  36. package/dist/chunk-YT42LKFV.js +16 -0
  37. package/dist/entry-1.js +1 -1
  38. package/dist/entry-10.js +1 -1
  39. package/dist/entry-11.js +1 -1
  40. package/dist/entry-12.js +1 -1
  41. package/dist/entry-13.js +1 -1
  42. package/dist/entry-14.js +1 -1
  43. package/dist/entry-15.js +1 -1
  44. package/dist/entry-16.js +1 -1
  45. package/dist/entry-17.js +1 -0
  46. package/dist/entry-19.js +1 -1
  47. package/dist/entry-2.js +1 -1
  48. package/dist/entry-20.js +1 -1
  49. package/dist/entry-21.js +1 -1
  50. package/dist/entry-22.js +1 -1
  51. package/dist/entry-23.js +1 -2
  52. package/dist/entry-24.js +1 -1
  53. package/dist/entry-25.js +2 -1
  54. package/dist/entry-26.js +1 -1
  55. package/dist/entry-27.js +2 -1
  56. package/dist/entry-28.js +1 -12
  57. package/dist/entry-29.js +1 -1
  58. package/dist/entry-30.js +1 -1
  59. package/dist/entry-31.js +13 -1
  60. package/dist/entry-32.js +1 -1
  61. package/dist/entry-33.js +1 -4
  62. package/dist/entry-34.js +1 -9
  63. package/dist/entry-35.js +1 -1
  64. package/dist/entry-36.js +4 -1
  65. package/dist/entry-37.js +9 -1
  66. package/dist/entry-38.js +1 -1
  67. package/dist/entry-39.js +1 -1
  68. package/dist/entry-40.js +1 -1
  69. package/dist/entry-41.js +1 -1
  70. package/dist/entry-42.js +1 -18
  71. package/dist/entry-43.js +1 -1
  72. package/dist/entry-44.js +1 -1
  73. package/dist/entry-45.js +17 -1
  74. package/dist/entry-46.js +1 -1
  75. package/dist/entry-47.js +1 -7
  76. package/dist/entry-48.js +1 -11
  77. package/dist/entry-49.js +1 -1
  78. package/dist/entry-50.js +6 -1
  79. package/dist/entry-51.js +10 -1
  80. package/dist/entry-52.js +1 -1
  81. package/dist/entry-53.js +1 -1
  82. package/dist/entry-54.js +1 -1
  83. package/dist/entry-55.js +1 -1
  84. package/dist/entry-56.js +1 -1
  85. package/dist/entry-57.js +1 -0
  86. package/dist/entry-58.js +1 -1
  87. package/dist/entry-59.js +1 -0
  88. package/dist/entry-60.js +1 -1
  89. package/dist/entry-61.js +1 -1
  90. package/dist/entry-62.js +0 -1
  91. package/dist/entry-63.js +1 -1
  92. package/dist/entry-64.js +0 -1
  93. package/dist/entry-65.js +1 -1
  94. package/dist/entry-66.js +1 -0
  95. package/dist/entry-67.js +1 -1
  96. package/dist/entry-68.js +1 -0
  97. package/dist/entry-69.js +1 -1
  98. package/dist/entry-70.js +1 -1
  99. package/dist/entry-71.js +0 -1
  100. package/dist/entry-72.js +1 -259
  101. package/dist/entry-73.js +0 -30
  102. package/dist/entry-74.js +1 -2
  103. package/dist/entry-75.js +1 -1
  104. package/dist/entry-76.js +1 -1
  105. package/dist/entry-77.js +315 -3
  106. package/dist/entry-78.js +30 -3
  107. package/dist/entry-79.js +2 -1
  108. package/dist/entry-80.js +1 -1
  109. package/dist/entry-81.js +1 -1
  110. package/dist/entry-82.js +3 -0
  111. package/dist/entry-83.js +3 -0
  112. package/dist/entry-84.js +1 -0
  113. package/dist/entry-85.js +1 -0
  114. package/dist/entry-86.js +1 -0
  115. package/dist/entry-9.js +1 -1
  116. package/dist/pi-agent-ide.js +3 -3
  117. package/docs/agent-guides/apply.md +333 -0
  118. package/docs/agent-guides/debugger.md +5 -0
  119. package/docs/agent-guides/diagnostics.md +5 -0
  120. package/docs/agent-guides/editing.md +44 -0
  121. package/docs/agent-guides/git-changes.md +5 -0
  122. package/docs/agent-guides/json-reading.md +41 -0
  123. package/docs/agent-guides/read-resources.md +44 -0
  124. package/docs/agent-guides/search-code.md +29 -0
  125. package/docs/agent-guides/terminal.md +7 -0
  126. package/docs/agent-guides/vision.md +5 -0
  127. package/docs/configuration.md +6 -14
  128. package/docs/research/apply-read-latency.md +219 -0
  129. package/node_modules/pi-agent-doctor/package.json +6 -6
  130. package/node_modules/pi-agent-doctor/runtime/entry-23.js +1 -0
  131. package/node_modules/pi-agent-documentation/package.json +15 -0
  132. package/node_modules/pi-agent-documentation/runtime/entry-24.js +1 -0
  133. package/node_modules/pi-agent-documentation/src/index.ts +69 -0
  134. package/node_modules/pi-agent-filesystem/index.ts +0 -4
  135. package/node_modules/pi-agent-filesystem/package.json +7 -7
  136. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  137. package/node_modules/pi-agent-filesystem-jq/index.ts +134 -0
  138. package/node_modules/pi-agent-filesystem-jq/package.json +23 -0
  139. package/node_modules/pi-agent-filesystem-jq/runtime/entry-27.js +2 -0
  140. package/node_modules/pi-agent-filesystem-jq/src/jq.ts +107 -0
  141. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  142. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  143. package/node_modules/pi-agent-filesystem-text/runtime/entry-29.js +2 -0
  144. package/node_modules/pi-agent-ide-ast/package.json +12 -11
  145. package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +1 -0
  146. package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +117 -0
  147. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +20 -2
  148. package/node_modules/pi-agent-ide-changes/index.ts +8 -0
  149. package/node_modules/pi-agent-ide-changes/package.json +9 -8
  150. package/node_modules/pi-agent-ide-changes/runtime/entry-32.js +1 -0
  151. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  152. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +1 -1
  153. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  154. package/node_modules/pi-agent-ide-languages/runtime/entry-35.js +2 -0
  155. package/node_modules/pi-agent-ide-lint/index.ts +1 -1
  156. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  157. package/node_modules/pi-agent-ide-lint/runtime/entry-36.js +2 -0
  158. package/node_modules/pi-agent-ide-lint/src/command-linter.ts +17 -1
  159. package/node_modules/pi-agent-ide-lsp/index.ts +0 -3
  160. package/node_modules/pi-agent-ide-lsp/package.json +10 -10
  161. package/node_modules/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
  162. package/node_modules/pi-agent-image/package.json +3 -3
  163. package/node_modules/pi-agent-invariant/package.json +2 -2
  164. package/node_modules/pi-agent-pdf/package.json +3 -3
  165. package/node_modules/pi-agent-read/package.json +12 -11
  166. package/node_modules/pi-agent-read/runtime/entry-42.js +0 -1
  167. package/node_modules/pi-agent-read/runtime/entry-45.js +2 -0
  168. package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
  169. package/node_modules/pi-agent-read/src/core/extension.ts +16 -2
  170. package/node_modules/pi-agent-read/src/core/read-core.ts +4 -5
  171. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
  172. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +19 -12
  173. package/node_modules/pi-agent-resource/package.json +2 -2
  174. package/node_modules/pi-agent-search/package.json +8 -7
  175. package/node_modules/pi-agent-search/runtime/entry-47.js +0 -1
  176. package/node_modules/pi-agent-search/runtime/entry-48.js +1 -0
  177. package/node_modules/pi-agent-search/runtime/entry-50.js +2 -0
  178. package/node_modules/pi-agent-search/src/core/extension.ts +29 -10
  179. package/node_modules/pi-agent-search-text/package.json +17 -9
  180. package/node_modules/pi-agent-search-text/runtime/entry-53.js +1 -0
  181. package/node_modules/pi-agent-search-text/src/persisted-result.ts +9 -7
  182. package/node_modules/pi-agent-search-text/src/search-renderer.ts +10 -4
  183. package/node_modules/pi-agent-search-text/src/search-result.ts +8 -1
  184. package/node_modules/pi-agent-text/package.json +3 -3
  185. package/node_modules/pi-agent-text/runtime/entry-55.js +1 -0
  186. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  187. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-56.js +2 -0
  188. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  189. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-58.js +2 -0
  190. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  191. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-60.js +2 -0
  192. package/node_modules/pi-agent-text-editor/index.ts +15 -0
  193. package/node_modules/pi-agent-text-editor/package.json +26 -25
  194. package/node_modules/pi-agent-text-editor/runtime/entry-72.js +0 -1
  195. package/node_modules/pi-agent-text-editor/runtime/entry-73.js +1 -0
  196. package/node_modules/pi-agent-text-editor/runtime/entry-74.js +1 -0
  197. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +24 -18
  198. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +4 -2
  199. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +5 -44
  200. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +13 -5
  201. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +124 -26
  202. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +2 -6
  203. package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +186 -1
  204. package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
  205. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
  206. package/node_modules/pi-agent-text-editor/src/core/extension.ts +0 -11
  207. package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +1 -1
  208. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
  209. package/node_modules/pi-agent-text-editor-renderer/index.ts +17 -4
  210. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  211. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
  212. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
  213. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  214. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  215. package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +1 -0
  216. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  217. package/node_modules/pi-agent-tool-ui/runtime/entry-81.js +1 -0
  218. package/node_modules/pi-agent-web/package.json +7 -7
  219. package/node_modules/pi-agent-web/runtime/entry-82.js +2 -0
  220. package/node_modules/pi-agent-web-html/package.json +3 -3
  221. package/node_modules/pi-agent-web-html/runtime/entry-83.js +2 -0
  222. package/node_modules/pi-agent-web-image/package.json +4 -4
  223. package/node_modules/pi-agent-web-image/runtime/entry-84.js +2 -0
  224. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  225. package/node_modules/pi-agent-web-pdf/runtime/entry-85.js +2 -0
  226. package/node_modules/pi-agent-web-text/package.json +4 -4
  227. package/node_modules/pi-agent-web-text/runtime/entry-86.js +2 -0
  228. package/package.json +108 -44
  229. package/src/api/documentation.ts +2 -0
  230. package/src/api/plugin-protocol.ts +10 -4
  231. package/src/composite/builtin-extensions.ts +7 -0
  232. package/src/composite/extensions-config.ts +6 -0
  233. package/src/composite/module-labels.ts +5 -0
  234. package/src/composite/module-settings-store.ts +3 -0
  235. package/src/composite/module-settings.ts +39 -5
  236. package/src/composite/preferences.ts +37 -0
  237. package/src/composite/presentation.ts +14 -0
  238. package/src/composite/presets.ts +57 -0
  239. package/src/documentation/extension.ts +295 -0
  240. package/src/documentation/registry.ts +98 -0
  241. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +0 -4
  242. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  243. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  244. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +134 -0
  245. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +23 -0
  246. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-27.js +2 -0
  247. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +107 -0
  248. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  249. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-28.js +2 -0
  250. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  251. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-29.js +2 -0
  252. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-25.js +2 -0
  253. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  254. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  255. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +2 -0
  256. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  257. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-84.js +2 -0
  258. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  259. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-85.js +2 -0
  260. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  261. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-86.js +2 -0
  262. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +2 -0
  263. package/src/extensions/pi-agent-read/package.json +12 -11
  264. package/src/extensions/pi-agent-read/runtime/entry-42.js +0 -1
  265. package/src/extensions/pi-agent-read/runtime/entry-43.js +1 -0
  266. package/src/extensions/pi-agent-read/runtime/entry-45.js +2 -0
  267. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
  268. package/src/extensions/pi-agent-read/src/core/extension.ts +16 -2
  269. package/src/extensions/pi-agent-read/src/core/read-core.ts +4 -5
  270. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
  271. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +19 -12
  272. package/src/extensions/pi-agent-search/package.json +8 -7
  273. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +17 -9
  274. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +1 -0
  275. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +9 -7
  276. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +10 -4
  277. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +8 -1
  278. package/src/extensions/pi-agent-search/runtime/entry-47.js +0 -1
  279. package/src/extensions/pi-agent-search/runtime/entry-48.js +1 -0
  280. package/src/extensions/pi-agent-search/runtime/entry-49.js +1 -0
  281. package/src/extensions/pi-agent-search/runtime/entry-50.js +2 -0
  282. package/src/extensions/pi-agent-search/src/core/extension.ts +29 -10
  283. package/src/extensions/pi-agent-text-editor/index.ts +15 -0
  284. package/src/extensions/pi-agent-text-editor/package.json +26 -25
  285. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  286. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-56.js +2 -0
  287. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  288. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-57.js +1 -0
  289. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-58.js +2 -0
  290. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  291. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-59.js +1 -0
  292. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-60.js +2 -0
  293. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +17 -4
  294. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  295. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +2 -0
  296. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
  297. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
  298. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  299. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-79.js +2 -0
  300. package/src/extensions/pi-agent-text-editor/runtime/entry-72.js +0 -1
  301. package/src/extensions/pi-agent-text-editor/runtime/entry-73.js +1 -0
  302. package/src/extensions/pi-agent-text-editor/runtime/entry-74.js +1 -0
  303. package/src/extensions/pi-agent-text-editor/runtime/entry-75.js +1 -0
  304. package/src/extensions/pi-agent-text-editor/runtime/entry-76.js +1 -0
  305. package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +2 -0
  306. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +24 -18
  307. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +4 -2
  308. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +5 -44
  309. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +13 -5
  310. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +124 -26
  311. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +2 -6
  312. package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +186 -1
  313. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
  314. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
  315. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +0 -11
  316. package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +1 -1
  317. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
  318. package/src/pi-agent-ide.ts +7 -10
  319. package/src/plugins/pi-agent-ide-ast/package.json +12 -11
  320. package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +1 -0
  321. package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +117 -0
  322. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +20 -2
  323. package/src/plugins/pi-agent-ide-changes/index.ts +8 -0
  324. package/src/plugins/pi-agent-ide-changes/package.json +9 -8
  325. package/src/plugins/pi-agent-ide-changes/runtime/entry-32.js +1 -0
  326. package/src/plugins/pi-agent-ide-debugger/index.ts +44 -14
  327. package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +10 -1
  328. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +39 -0
  329. package/src/plugins/pi-agent-ide-debugger/src/ui.ts +42 -5
  330. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +9 -4
  331. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  332. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +1 -1
  333. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  334. package/src/plugins/pi-agent-ide-languages/runtime/entry-35.js +2 -0
  335. package/src/plugins/pi-agent-ide-lint/index.ts +1 -1
  336. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  337. package/src/plugins/pi-agent-ide-lint/runtime/entry-36.js +2 -0
  338. package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +17 -1
  339. package/src/plugins/pi-agent-ide-lsp/index.ts +0 -3
  340. package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
  341. package/src/plugins/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
  342. package/src/plugins/pi-agent-ide-terminal/index.ts +27 -2
  343. package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +27 -2
  344. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +88 -12
  345. package/src/plugins/pi-agent-ide-terminal/src/screen-image.ts +6 -2
  346. package/src/plugins/pi-agent-ide-terminal/src/search.ts +0 -3
  347. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +7 -4
  348. package/src/plugins/pi-agent-ide-vision/index.ts +10 -7
  349. package/src/plugins/pi-agent-ide-vision/src/vision.ts +17 -3
  350. package/assets/gallery/apply-editing.png +0 -0
  351. package/assets/gallery/debugging.png +0 -0
  352. package/assets/gallery/read-web.png +0 -0
  353. package/assets/gallery/search-replace.png +0 -0
  354. package/assets/gallery/terminal.png +0 -0
  355. package/assets/gallery/tool-editing.png +0 -0
  356. package/dist/chunk-22CLOM2D.js +0 -1
  357. package/dist/chunk-3XJ3KDPZ.js +0 -16
  358. package/dist/chunk-526E364R.js +0 -3
  359. package/dist/chunk-DDKHZZDO.js +0 -5
  360. package/dist/chunk-EJ5OACQM.js +0 -1
  361. package/dist/chunk-HSM6R7IB.js +0 -27
  362. package/dist/chunk-PCZH7GOX.js +0 -26
  363. package/dist/chunk-SQ7ZTGOP.js +0 -2
  364. package/dist/entry-18.js +0 -1
  365. package/node_modules/pi-agent-doctor/runtime/entry-18.js +0 -1
  366. package/node_modules/pi-agent-filesystem/runtime/entry-23.js +0 -2
  367. package/node_modules/pi-agent-filesystem-image/runtime/entry-24.js +0 -2
  368. package/node_modules/pi-agent-ide-ast/runtime/entry-27.js +0 -1
  369. package/node_modules/pi-agent-ide-changes/runtime/entry-29.js +0 -1
  370. package/node_modules/pi-agent-ide-changes/runtime/entry-30.js +0 -2
  371. package/node_modules/pi-agent-ide-languages/runtime/entry-32.js +0 -2
  372. package/node_modules/pi-agent-image/runtime/entry-35.js +0 -1
  373. package/node_modules/pi-agent-invariant/runtime/entry-36.js +0 -1
  374. package/node_modules/pi-agent-pdf/runtime/entry-37.js +0 -1
  375. package/node_modules/pi-agent-search/runtime/entry-45.js +0 -1
  376. package/node_modules/pi-agent-search-text/runtime/entry-48.js +0 -2
  377. package/node_modules/pi-agent-text/runtime/entry-50.js +0 -1
  378. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-53.js +0 -2
  379. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-55.js +0 -2
  380. package/node_modules/pi-agent-text-editor/runtime/entry-56.js +0 -1
  381. package/node_modules/pi-agent-text-editor/runtime/entry-58.js +0 -1
  382. package/node_modules/pi-agent-text-editor/runtime/entry-60.js +0 -1
  383. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-73.js +0 -2
  384. package/node_modules/pi-agent-text-editor-renderer/src/config.ts +0 -73
  385. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +0 -2
  386. package/node_modules/pi-agent-web-pdf/runtime/entry-80.js +0 -2
  387. package/node_modules/pi-agent-web-text/runtime/entry-81.js +0 -2
  388. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-24.js +0 -2
  389. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-25.js +0 -2
  390. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-23.js +0 -2
  391. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-78.js +0 -2
  392. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-79.js +0 -2
  393. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-80.js +0 -2
  394. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-81.js +0 -2
  395. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-77.js +0 -2
  396. package/src/extensions/pi-agent-read/runtime/entry-38.js +0 -1
  397. package/src/extensions/pi-agent-read/runtime/entry-39.js +0 -1
  398. package/src/extensions/pi-agent-read/runtime/entry-40.js +0 -1
  399. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +0 -2
  400. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-49.js +0 -1
  401. package/src/extensions/pi-agent-search/runtime/entry-45.js +0 -1
  402. package/src/extensions/pi-agent-search/runtime/entry-46.js +0 -1
  403. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-53.js +0 -2
  404. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-55.js +0 -2
  405. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-73.js +0 -2
  406. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/config.ts +0 -73
  407. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +0 -2
  408. package/src/extensions/pi-agent-text-editor/runtime/entry-56.js +0 -1
  409. package/src/extensions/pi-agent-text-editor/runtime/entry-57.js +0 -1
  410. package/src/extensions/pi-agent-text-editor/runtime/entry-58.js +0 -1
  411. package/src/extensions/pi-agent-text-editor/runtime/entry-59.js +0 -1
  412. package/src/extensions/pi-agent-text-editor/runtime/entry-60.js +0 -1
  413. package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +0 -1
  414. package/src/plugins/pi-agent-ide-ast/runtime/entry-28.js +0 -2
  415. package/src/plugins/pi-agent-ide-changes/runtime/entry-29.js +0 -1
  416. package/src/plugins/pi-agent-ide-changes/runtime/entry-30.js +0 -2
  417. package/src/plugins/pi-agent-ide-languages/runtime/entry-32.js +0 -2
  418. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem}/runtime/entry-25.js +0 -0
  419. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-image}/runtime/entry-26.js +0 -0
  420. /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-pdf}/runtime/entry-28.js +0 -0
  421. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
  422. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
  423. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-34.js +0 -0
  424. /package/node_modules/{pi-agent-read → pi-agent-image}/runtime/entry-38.js +0 -0
  425. /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-39.js +0 -0
  426. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-40.js +0 -0
  427. /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-43.js +0 -0
  428. /package/node_modules/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
  429. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-46.js +0 -0
  430. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-49.js +0 -0
  431. /package/node_modules/{pi-agent-text-anchor-constant → pi-agent-search-text}/runtime/entry-51.js +0 -0
  432. /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-search-text}/runtime/entry-52.js +0 -0
  433. /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-search-text}/runtime/entry-54.js +0 -0
  434. /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-exact}/runtime/entry-57.js +0 -0
  435. /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-59.js +0 -0
  436. /package/node_modules/{pi-agent-tool-call-interception → pi-agent-text-editor}/runtime/entry-75.js +0 -0
  437. /package/node_modules/{pi-agent-tool-ui → pi-agent-text-editor}/runtime/entry-76.js +0 -0
  438. /package/node_modules/{pi-agent-web → pi-agent-text-editor}/runtime/entry-77.js +0 -0
  439. /package/node_modules/{pi-agent-web-html → pi-agent-text-editor-renderer}/runtime/entry-78.js +0 -0
  440. /package/node_modules/{pi-agent-web-image → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
  441. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-image}/runtime/entry-26.js +0 -0
  442. /package/src/extensions/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
  443. /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-constant → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-51.js +0 -0
  444. /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-exact → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-52.js +0 -0
  445. /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-54.js +0 -0
  446. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
  447. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
  448. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-34.js +0 -0
package/dist/entry-45.js CHANGED
@@ -1 +1,17 @@
1
- import{a,b,c,d,e,f,g}from"./chunk-7UGNGK7Y.js";import"./chunk-EI7MMDWY.js";export{b as SEARCH_API_VERSION,c as SEARCH_CORE_READY_EVENT,d as SEARCH_PLUGIN_REGISTER_EVENT,a as SEARCH_PROTOCOL,e as isSearchCoreReady,f as isSearchPlugin,g as isSearchPluginRegistrationRequest};
1
+ import{e as q,f as ye,g as he}from"./chunk-GIRAEVUJ.js";import{e as ie,f as se}from"./chunk-T7I2VX3J.js";import{a as Re,b as B,c as j,d as G,e as H,f as z,g as me}from"./chunk-FA6BKC5Y.js";import{a as le,c as ce,d as fe}from"./chunk-VCTK4JSN.js";import"./chunk-YHUTTZC6.js";import{a as V,b as U,c as ae,d as de,g as ue}from"./chunk-OBNING2A.js";import{b as pe,e as ge}from"./chunk-S3ZPXWX7.js";import{m as re,o as ne,s as oe}from"./chunk-5VSE5X5R.js";import{a as C}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Text as Le}from"@earendil-works/pi-tui";import{DEFAULT_MAX_BYTES as Be,DEFAULT_MAX_LINES as je,formatSize as W,truncateHead as Ge}from"@earendil-works/pi-coding-agent";var _=Be,M=je;async function Y(e,t,r,n){let o=n?.originLine,i=e.content.length===1?e.content[0]:void 0;if(i?.type!=="text")return e;let d=Ge(i.text,{maxBytes:_,maxLines:M});if(d.truncated){let g=r===void 0?void 0:await r(i.text),m=d.firstLineExceedsLimit?ze(i.text,e.details,t):qe(d,e.details,t,o),l=g===void 0?m:He(m,g);return{...e,content:[{...i,text:we(d.content,l)}],details:{...Xe(e.details,d),...g!==void 0&&{temporarySource:g}}}}let a=Ke(e.details,t,o);return a===void 0?e:{...e,content:[{...i,text:we(i.text,a)}]}}s(Y,"limitReadOutput");function He(e,t){return`${e.slice(0,-1)} Full output: ${t}. Available until this runtime is disposed.]`}s(He,"appendTemporarySource");function ze(e,t,r){let n=e.split(/\r\n|\r|\n/u,1)[0]??"",o=W(Buffer.byteLength(n,"utf8")),i=Q(t,r);return`[${i===void 0?"First output line":`Line ${i}`} is ${o}, exceeds ${W(_)} limit. Use a source-specific tool to read this line in smaller byte ranges.]`}s(ze,"oversizedFirstLineNotice");function qe(e,t,r,n){let o=We(e,t,r);if(o!==void 0&&o.endLine<o.totalLines){let d=e.truncatedBy==="bytes"?` (${W(e.maxBytes)} limit)`:"",a=ve(o.endLine+1,n);return`[Showing lines ${o.startLine}-${o.endLine} of ${o.totalLines}${d}. Use offset=${a} to continue.]`}let i=e.truncatedBy==="lines"?`${e.maxLines} line limit`:`${W(e.maxBytes)} limit`;return`[Output truncated: showing ${e.outputLines} of ${e.totalLines} rendered lines (${i}). Use a smaller line range to read this source.]`}s(qe,"truncatedOutputNotice");function We(e,t,r){let n=t.totalLines,o=Q(t,r);if(n===void 0||n===0||o===void 0||e.outputLines===0)return;let d=(t.endLine===void 0||t.endLine<o?n:t.endLine)-o+1,a=Math.min(e.outputLines,d);return{startLine:o,endLine:o+a-1,totalLines:n}}s(We,"shownSourceRange");function Ke(e,t,r){if(t.limit===void 0||e.totalLines===void 0||e.totalLines===0)return;let n=Q(e,t);if(n===void 0)return;let o=e.endLine===void 0||e.endLine<n?n:e.endLine+1;return o>e.totalLines?void 0:`[${e.totalLines-o+1} more lines in source. Use offset=${ve(o,r)} to continue.]`}s(Ke,"explicitLimitNotice");function ve(e,t){return t===void 0?e:e-t+1}s(ve,"continuationOffset");function Q(e,t){if(e.startLine!==void 0&&e.startLine>0)return e.startLine;if(e.totalLines===void 0||e.totalLines===0)return;let r=t.offset===void 0?1:Math.trunc(t.offset);return r<0?Math.max(1,e.totalLines+r+1):Math.max(1,r)}s(Q,"sourceStartLine");function Xe(e,t){return{...e,...e.lines!==void 0&&{lines:e.lines.slice(0,t.outputLines)},truncation:t}}s(Xe,"truncatedDetails");function we(e,t){return e.length===0?t:`${e}
2
+
3
+ ${t}`}s(we,"appendNotice");function Te(e,t,r,n){if(!et(e))return{content:e,source:t,resolvedBy:r,preserveTruncatedOutput:n.preserveTruncatedOutput,textMode:n.textMode,contentKind:"other"};let o=e[0].text;return{content:e,source:t,resolvedBy:r,preserveTruncatedOutput:n.preserveTruncatedOutput,textMode:n.textMode,contentKind:"text",text:re(t,o)}}s(Te,"createReadState");function K(e,t,r){if(e.contentKind!=="text"){if(t.offset!==void 0||t.limit!==void 0)return T({code:"UNSUPPORTED_RANGE",source:e.source,resolverId:e.resolvedBy,message:"Line ranges require textual content"});let m=Qe(e.content);return{...r?.audience==="script"&&{script:{kind:"native",source:e.source,blocks:e.content}},content:m.content,details:{...xe(e),...m.unsupportedContentBlocks!==void 0&&{unsupportedContentBlocks:m.unsupportedContentBlocks}}}}let n=e.text.lines.length,o=Je(t,n,r?.originLine),i=e.text.lines.slice(o.startIndex,o.endIndex),d=e.textMode==="final"?Ye(i,o.endIndex<n):ne({...e.text,lines:i.map((m,l)=>({...m,lineEnding:l===i.length-1&&o.endIndex<n?"":m.lineEnding}))}),a=e.content[0],g=[{type:"text",text:d,...a.textSignature!==void 0&&{textSignature:a.textSignature}}];return{...r?.audience==="script"&&{script:{kind:"text",source:e.source,content:i.map(m=>m.content+m.lineEnding).join(""),lines:i,startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:n}},content:g,details:{...xe(e),startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:n,lines:i}}}s(K,"projectReadState");function Ye(e,t){return e.map((r,n)=>`${r.content}${n===e.length-1&&t?"":r.lineEnding}`).join("")}s(Ye,"renderFinalTextLines");function T(e){return{content:[{type:"text",text:`${e.code}: ${e.message}`}],details:{failure:e},isError:!0}}s(T,"failureResult");function xe(e){return{source:e.source,resolvedBy:e.resolvedBy}}s(xe,"readDetails");function Qe(e){let t=[],r=[];for(let[o,i]of e.entries()){if(i.type!=="custom"){t.push(i);continue}r.push({index:o,kind:i.kind}),t.push({type:"text",text:`[unsupported_content_block kind=${i.kind} index=${o}]`})}let n=r[0];return{content:t,...n!==void 0&&{unsupportedContentBlocks:[n,...r.slice(1)]}}}s(Qe,"projectAgentContent");function Je(e,t,r){let n=e.offset===void 0?1:Math.trunc(e.offset),o=Ze(n,t,r),i=e.limit===void 0?t:Math.max(0,Math.trunc(e.limit));return{startIndex:Math.min(t,o-1),endIndex:Math.min(t,o-1+i)}}s(Je,"resolveTextRange");function Ze(e,t,r){if(r===void 0)return e<0?Math.max(1,t+e+1):Math.max(1,e);let n=e<0?r+e:r+Math.max(1,e)-1;return Math.max(1,n)}s(Ze,"anchoredStartLine");function et(e){return e.length===1&&e[0].type==="text"}s(et,"isSingleTextContent");import{randomUUID as tt}from"node:crypto";import{mkdir as rt,mkdtemp as nt,readFile as ot,rm as it,writeFile as st}from"node:fs/promises";import{tmpdir as at}from"node:os";import Pe from"node:path";var X=class{static{s(this,"TempResourceStore")}resolver;#t=new Map;#n=new Set;#o;#r;#e;constructor(t={}){this.#o=t.parentDirectory??at(),this.resolver={id:"temp",tryResolve:s(r=>Promise.resolve(this.#a(r)),"tryResolve")}}async save(t){if(this.#e!==void 0)throw new Error("Temporary resource store is closed");let r=this.#i(t);this.#n.add(r);try{return await r}finally{this.#n.delete(r)}}dispose(){return this.#e??=this.#s(),this.#e}async#i(t){let r=await this.#u(),n=tt(),o=`temp:${n}`,i=Pe.join(r,`${n}.txt`);return await st(i,t,{encoding:"utf8",flag:"wx"}),this.#t.set(o,i),o}async#s(){await Promise.allSettled(this.#n),this.#t.clear(),this.#r!==void 0&&await it(await this.#r,{recursive:!0,force:!0})}#a(t){return t.startsWith("temp:")?this.#e!==void 0||!this.#t.has(t)?{kind:"failed",error:new Error(`Temporary resource ${t} does not exist in this runtime`)}:{kind:"resolved",resource:{source:t,read:s(()=>this.#d(t),"read")}}:{kind:"not-handled"}}async#d(t){let r=this.#t.get(t);if(this.#e!==void 0||r===void 0)throw new Error(`Temporary resource ${t} does not exist in this runtime`);return[{type:"text",text:await ot(r,"utf8")}]}async#u(){return this.#r??=(async()=>(await rt(this.#o,{recursive:!0}),nt(Pe.join(this.#o,"pi-agent-read-"))))(),this.#r}};import{open as dt,realpath as ut,stat as lt}from"node:fs/promises";import ct from"node:path";import{fileURLToPath as ft}from"node:url";async function Ee(e,t,r,n=[]){let o=e.path??"";try{if((e.views?.length??0)>0)throw new Error("Raw byte reads do not accept text views");let i=e.offset??0,d=e.limit;if(!Number.isSafeInteger(i)||d!==void 0&&(!Number.isSafeInteger(d)||d<0))throw new Error("Use an integer byte offset and a non-negative integer byte limit");let a=o.slice(4);if(a.length===0)throw new Error("Supply a local file after raw:");let g=a.startsWith("file://")?ft(a):ct.resolve(t.cwd,a),m=await ut(g),l=`raw:${m}`;for(let{registration:f}of n)try{let c=await f.guard({requestedSource:o,resourceSource:l,resolvedBy:"raw",cwd:t.cwd,request:e,audience:r,...t.signal!==void 0&&{signal:t.signal}});if(c.kind==="rejected")return T({code:"READ_FAILED",source:l,resolverId:"raw",message:`Read blocked by hook ${f.id}: ${c.reason}`})}catch(c){return T({code:"READ_FAILED",source:l,resolverId:"raw",message:`Read blocked because hook ${f.id} failed: ${c instanceof Error?c.message:String(c)}`,cause:c})}if(t.signal?.throwIfAborted(),!(await lt(m)).isFile())throw new Error("Raw reads require a regular file");let p=await dt(m,"r");try{let f=await p.stat();if(!f.isFile())throw new Error("Raw reads require a regular file");let c=Math.min(f.size,Math.max(0,i<0?f.size+i:i)),x=Math.min(d??f.size,f.size-c),w=16*Math.max(1,Math.min(M-4,Math.floor((_-1024)/90))),P=r==="script"?x:Math.min(x,w),R=Buffer.alloc(P),v=0;for(;v<P;){t.signal?.throwIfAborted();let k=await p.read(R,v,P-v,c+v);if(k.bytesRead===0)break;v+=k.bytesRead}t.signal?.throwIfAborted();let E=R.subarray(0,v),y=c+v,L=y<f.size,u=`${l}
4
+ Bytes ${c}..${y} (end exclusive), ${f.size} bytes total`,$=pt(E,c),S=L?`
5
+ Use offset=${y} to continue in bytes.`:"";return{content:[{type:"text",text:`${u}
6
+ ${$}${S}`}],details:{source:l,resolvedBy:"raw",byteOffset:c,byteLength:v,totalBytes:f.size},...r==="script"&&{script:{kind:"bytes",source:l,byteOffset:c,byteLength:v,totalBytes:f.size,bytes:Array.from(E)}}}}finally{await p.close()}}catch(i){if(t.signal?.aborted)throw i;return T({code:"READ_FAILED",source:o,message:i instanceof Error?i.message:String(i),cause:i})}}s(Ee,"readRaw");function pt(e,t){let r=[];for(let n=0;n<e.length;n+=16){let o=e.subarray(n,n+16),i=Array.from(o,a=>a.toString(16).padStart(2,"0")).join(" "),d=Array.from(o,a=>a>=32&&a<=126?String.fromCharCode(a):".").join("");r.push(`${(t+n).toString(16).padStart(8,"0")} ${i.padEnd(47)} |${d}|`)}return r.join(`
7
+ `)}s(pt,"formatRawBytes");var gt=fe({kind:"source"});function Ce(e,t="compact"){let r=new X,n=[{resolver:r.resolver,preserveTruncatedOutput:!1,priority:Number.MIN_SAFE_INTEGER,order:0}],o=[],i=[],d=[],a=[],g=[],m="read";return{saveTemporary:s(l=>r.save(l),"saveTemporary"),tool:{name:m,label:m,promptSnippet:"Read supported sources as text or bytes, with optional views",get description(){return`Use read to inspect supported resources. path selects the source; offset and limit select a bounded window; views request source-specific presentations. Text output is limited to ${M} lines or ${_/1024}KB; follow a returned continuation offset or temp: reference when present.`},get promptGuidelines(){return["Use read to inspect supported sources and search to locate workspace content.",...e?.()??[]]},parameters:Re,renderCall(l,p,f){let c=typeof l.path=="string"?l.path:void 0,x=c===void 0?void 0:n.find(({matchesCall:P})=>P?.(c)===!0)?.renderCall,w=f.expanded?"full":t;return w==="disabled"?new Le(p.fg("toolTitle","read"),0,0):(x??ce)(l,p,{...f,expanded:w==="full"})},renderResult(l,p,f,c){let x=l.details.resolvedBy,w=x===void 0?void 0:n.find(({resolver:R})=>R.id===x)?.renderResult,P=p.expanded?"full":t;return P==="disabled"&&!c.isError&&!p.isPartial?new Le(f.fg("success","\u2713 read"),0,0):(w??gt)(l,{...p,expanded:P==="full"},f,c)},async execute(l,p,f,c,x){let w={cwd:x.cwd,...f!==void 0&&{signal:f}};return Se(p,w,n,i,d,r,a,g,o)}},execute(l,p,f="agent"){return Se(l,p,n,i,d,r,a,g,o,f)},registerContributions(l,p){let f=[...p.resourceGuards??[]],c=[...p.resolvers??[]],x=[...p.targetResolvers??[]],w=[...p.handlers??[]],P=[...p.views??[]],R=[...p.fragments??[]],v=new Set(o.map(({registration:u})=>u.id));for(let u of f){if(u.id.trim().length===0||typeof u.guard!="function")throw new TypeError(`Plugin ${l} provided an invalid Resource guard`);if(v.has(u.id))throw new Error(`Resource guard ${u.id} is already registered`);v.add(u.id)}At(l,c,w,n,i),$t(l,R,a);let E=new Set(g.map(({resolver:u})=>u.id));for(let u of x){if(!B(u))throw new TypeError(`Plugin ${l} provided an invalid text target resolver`);if(E.has(u.resolver.id))throw new Error(`Text target resolver ${u.resolver.id} is already registered`);E.add(u.resolver.id)}let y=new Set(d.map(({registration:u})=>u.view)),L=new Set(d.map(({registration:u})=>`${u.view}/${u.presenter.id}`));for(let u of P){if(!H(u))throw new TypeError(`Plugin ${l} provided an invalid view registration`);let $=`${u.view}/${u.presenter.id}`;if(L.has($))throw new Error(`View ${u.view} already has a presenter ${u.presenter.id}`);y.add(u.view),L.add($)}for(let u of f)o.push({pluginId:l,registration:u});for(let u of c)n.push({resolver:u.resolver,...u.matchesCall!==void 0&&{matchesCall:u.matchesCall,renderCall:u.renderCall},...u.renderResult!==void 0&&{renderResult:u.renderResult},priority:u.priority??0,preserveTruncatedOutput:u.preserveTruncatedOutput??!1,order:n.length});for(let u of x)g.push({resolver:u.resolver,priority:u.priority??0,order:g.length});for(let u of w)i.push({pluginId:l,registration:u});for(let u of P)d.push({pluginId:l,registration:u,order:d.length});for(let u of R)a.push({registration:u,priority:u.priority??0,order:a.length})},dispose(){return r.dispose()}}}s(Ce,"createReadTool");async function Se(e,t,r,n,o,i,d,a,g,m="agent"){if(e.path?.startsWith("raw:"))return Ee(e,t,m,g);t={...t,audience:m};let l=m==="script"?async h=>h:Y,p=[...r].sort((h,A)=>h.priority-A.priority||h.order-A.order),f=[...n],c=[...o].sort((h,A)=>(h.registration.priority??0)-(A.registration.priority??0)||h.order-A.order),x=[...d].sort((h,A)=>h.priority-A.priority||h.order-A.order),w=[...a].sort((h,A)=>h.priority-A.priority||h.order-A.order),P=[...e.views??[],...m==="script"?c.map(({registration:h})=>h.view):[]],R=new Set(P.map(Ae)),v=new Set([...c.map(({registration:h})=>h.view)]),E=P.filter(h=>!v.has(Ae(h)));if(e.path!==void 0&&w.length>0){let h=await yt(e,t,w,p,f,c,R,E,m,g);if(h!==void 0)return h}let y={request:{...e},resolverContext:t,audience:m};if(!y.request.path?.startsWith("temp:")){let h=await De(y,f);if(h.kind==="return")return D(await l(h.result,y.request),E);y=h.context}let L=y.request.path;if(L===void 0||L.length===0)return T({code:"INVALID_REQUEST",message:"No source was provided"});let u=await J(y,p,g,e.path??L),$;if(u.kind==="return"&&u.result.isError===!0&&mt(u.result)&&!L.startsWith("temp:")){let h=ht(L);if(h!==void 0){let A={result:u,pipeline:y},ee={...y,request:{...y.request,path:h.source}},te=await J(ee,p,g,e.path??L);te.kind==="continue"?(u=te,y=ee,$=h.fragment):u=A.result}}if(u.kind==="return")return l(u.result,y.request);y=u.context;let S;if($!==void 0){let h=await wt(y,x,$);if(typeof h!="number")return h;S=h}if(y.state?.textMode==="final")return D(await l(K(y.state,y.request,{originLine:S,audience:m}),y.request,void 0,{originLine:S}),E);let k=await Oe(y,f);if(k.kind==="return")return D(await l(k.result,y.request,void 0,{originLine:S}),E);y=k.context,y=await Ie(y,c,R);let N=K(C(y.state),y.request,{audience:m,originLine:S});y={...y,result:N};let O=await _e(y,f),I=O.kind==="return"?O.result:C(O.context.result),b=y.request.limit===void 0&&y.state?.preserveTruncatedOutput===!0?h=>i.save(h):void 0;return D(await l(I,y.request,b,{originLine:S}),E)}s(Se,"executeRead");var Rt=new Set(["INVALID_RESOLVER_RESULT","NO_RESOLVER","READ_FAILED","RESOLVE_FAILED"]);function mt(e){let t=e.details.failure?.code;return t!==void 0&&Rt.has(t)}s(mt,"isRetryableFailure");async function yt(e,t,r,n,o,i,d,a,g,m){let l=g==="script"?async p=>p:Y;for(let{resolver:p}of r){let f;try{f=await p.tryResolve(e.path??"",t)}catch(v){return T({code:"RESOLVE_FAILED",source:e.path,message:F(`Text target resolver ${p.id} failed`,v),cause:v})}if(!oe(f))return T({code:"INVALID_RESOLVER_RESULT",source:e.path,message:`Text target resolver ${p.id} returned an invalid result`,cause:f});let c=f;if(c.kind==="not-handled")continue;if(c.kind==="rejected")return T({code:"RESOLVE_FAILED",source:e.path,message:c.rejection.reason});if(c.kind==="failed")return T({code:"RESOLVE_FAILED",source:e.path,message:c.error instanceof Error?c.error.message:String(c.error)});if(c.targets.length===0)return T({code:"RESOLVE_FAILED",source:e.path,message:"Text target resolver returned no targets"});let x=[],w=[],P;for(let v of c.targets){let E=v.ranges??[{start:{lineNumber:1,column:0},end:{lineNumber:1,column:1}}];for(let y of E){let L=Math.max(1,y.end.lineNumber-y.start.lineNumber),u={request:{...e,path:v.source,limit:e.limit??L},resolverContext:t,audience:g};if(!v.source.startsWith("temp:")){let b=await De(u,o);if(b.kind==="return"){if(b.result.isError===!0)return D(b.result,a);for(let h of b.result.content)h.type==="text"&&x.push(h.text);w.push(b.result),P??=b.result.details;continue}u=b.context}let $=await J(u,n,m,e.path??v.source);if($.kind==="return")return D($.result,a);let S=await Oe($.context,o);if(S.kind==="return"){if(S.result.isError===!0)return D(S.result,a);for(let b of S.result.content)b.type==="text"&&x.push(b.text);w.push(S.result),P??=S.result.details;continue}let k=await Ie(S.context,i,d),N=K(C(k.state),k.request,{audience:g,originLine:y.start.lineNumber}),O=await _e({...k,result:N},o);if(N.isError===!0)return D(N,a);let I=O.kind==="return"?O.result:C(O.context.result);if(I.isError===!0)return D(I,a);for(let b of I.content)b.type==="text"&&x.push(b.text);w.push(I),P??=I.details}}let R={...g==="script"&&{script:w.length===1&&w[0]?.script!==void 0?w[0].script:{kind:"resources",source:e.path,resources:w.map(v=>v.script??{kind:"native",source:v.details.source??e.path??"",blocks:v.content})}},content:[{type:"text",text:x.join(`
8
+ `)}],details:g==="script"?{source:e.path,resources:w}:P??{source:e.path}};return D(await l(R,{path:e.path,views:e.views}),a)}}s(yt,"resolveTextTargets");var be="#";function ht(e){let t=e.indexOf(be);if(!(t<=0||t===e.length-1))return{source:e.slice(0,t),fragment:e.slice(t+be.length)}}s(ht,"splitAnchoredSource");async function wt(e,t,r){let n=C(e.state);if(n.contentKind!=="text")return T({code:"UNSUPPORTED_RANGE",source:n.source,resolverId:n.resolvedBy,message:"Anchored reads require textual content"});if(t.length===0)return T({code:"NO_FRAGMENT_RESOLVER",source:n.source,message:`No fragment resolver is registered for anchor "${r}"`});for(let{registration:o}of t){let i;try{i=await o.resolve({source:n.source,fragment:r,text:n.text,cwd:e.resolverContext.cwd,...e.resolverContext.signal!==void 0&&{signal:e.resolverContext.signal}})}catch(d){return T({code:"FRAGMENT_FAILED",source:n.source,resolverId:o.id,message:F(`Fragment resolver ${o.id} failed`,d),cause:d})}if(!me(i))return T({code:"INVALID_RESOLVER_RESULT",source:n.source,resolverId:o.id,message:`Fragment resolver ${o.id} returned an invalid result`,cause:i});if(i.kind!=="not-handled")return i.kind==="failed"?T({code:"FRAGMENT_FAILED",source:n.source,resolverId:o.id,message:i.message}):!Number.isInteger(i.originLine)||i.originLine<1||i.originLine>n.text.lines.length?T({code:"INVALID_RESOLVER_RESULT",source:n.source,resolverId:o.id,message:`Fragment resolver ${o.id} returned out-of-range origin line ${i.originLine}`}):i.originLine}return T({code:"NO_FRAGMENT_RESOLVER",source:n.source,message:`No fragment resolver handled anchor "${r}"`})}s(wt,"resolveAnchoredOrigin");async function J(e,t,r,n){let o=C(e.request.path),i=e.resolverContext;for(let a of t){let{resolver:g}=a,m;try{m=await g.tryResolve(o,i)}catch(f){return{kind:"return",result:T({code:"RESOLVE_FAILED",source:o,resolverId:g.id,message:F(`Resolver ${g.id} failed`,f),cause:f})}}if(!ge(m))return{kind:"return",result:T({code:"INVALID_RESOLVER_RESULT",source:o,resolverId:g.id,message:`Resolver ${g.id} returned an invalid result`,cause:m})};if(m.kind==="not-handled")continue;if(m.kind==="failed")return{kind:"return",result:T({code:"RESOLVE_FAILED",source:o,resolverId:g.id,message:F(`Resolver ${g.id} failed`,m.error),cause:m.error})};let l=m.resource;if(l.read===void 0)return{kind:"return",result:T({code:"UNSUPPORTED_CAPABILITY",source:l.source,resolverId:g.id,message:`Resource ${l.source} does not support reading`})};for(let{registration:f}of r)try{let c=await f.guard({requestedSource:n,resourceSource:l.source,resolvedBy:g.id,cwd:i.cwd,request:e.request,audience:e.audience??"agent",...i.signal!==void 0&&{signal:i.signal}});if(c.kind==="rejected")return{kind:"return",result:q(T({code:"READ_FAILED",source:l.source,resolverId:g.id,message:`Read blocked by hook ${f.id}: ${c.reason}`}),c.reason)}}catch(c){return{kind:"return",result:q(T({code:"READ_FAILED",source:l.source,resolverId:g.id,message:F(`Read blocked because hook ${f.id} failed`,c),cause:c}),`Hook ${f.id} failed`)}}let p;try{p=await l.read({...i.signal!==void 0&&{signal:i.signal}})}catch(f){return{kind:"return",result:T({code:"READ_FAILED",source:l.source,resolverId:g.id,message:F(`Unable to read ${l.source}`,f),cause:f})}}return pe(p)?{kind:"continue",context:{...e,state:Te(p,l.source,g.id,{preserveTruncatedOutput:a.preserveTruncatedOutput,textMode:g.id==="temp"?"final":"normal"})}}:{kind:"return",result:T({code:"INVALID_RESOURCE_CONTENT",source:l.source,resolverId:g.id,message:`Resource ${l.source} returned invalid content`,cause:p})}}let d=`No resolver handled ${o}`;return{kind:"return",result:q(T({code:"NO_RESOLVER",source:o,message:d}),d)}}s(J,"resolveSource");async function De(e,t){let r=e;for(let n of t){if(n.registration.stage!=="pre-read")continue;let o=await Z(n.registration.handler,r,n.pluginId,"pre-read");if(o.kind==="return")return o;r=o.context}return{kind:"continue",context:r}}s(De,"runPreReadHandlers");async function Oe(e,t){let r=e.state,n=r===void 0?[]:t.filter(i=>i.registration.stage==="read"&&bt(i.registration,r)),o=e;for(let i of n){let d=i.registration;if(d.stage!=="read")continue;let a=await Z(d.handler,o,i.pluginId,"read");if(a.kind==="return")return a;o=a.context}return{kind:"continue",context:o}}s(Oe,"runReadHandlers");async function Ie(e,t,r){let n=e.state;if(n?.contentKind!=="text"||r.size===0)return e;let o=n.text,i={purpose:"read",audience:e.resolverContext.audience,requestedViews:e.request.views,source:n.source,cwd:e.resolverContext.cwd,resolvedBy:n.resolvedBy,...e.resolverContext.signal!==void 0&&{signal:e.resolverContext.signal}},d=t.filter(({registration:p})=>r.has(p.view)),a=new Set(d.flatMap(({registration:p})=>p.includes??[])),g=d.filter(({registration:p})=>!a.has(p.view)),m=await Promise.all(g.map(async({registration:p})=>({presenterId:p.presenter.id,document:await p.presenter.present(o,i)}))),l=vt(o,m);return{...e,state:{...n,text:l}}}s(Ie,"runTextPresenters");function Ae(e){let t=e.indexOf(":");return t<0?e:e.slice(0,t)}s(Ae,"viewName");function D(e,t){if(t.length===0)return e;let r=`note: ignored unknown views: ${t.join(", ")}`,n=e.content[0],o=n?.type==="text"?[{...n,text:`${r}
9
+ ${n.text}`}]:[...e.content];return{...e,content:o,details:{...e.details,ignoredViews:t}}}s(D,"withIgnoredViews");function vt(e,t){let r=e.lines;for(let n of t)xt(e,n),r=r.map((o,i)=>Tt(C(e.lines[i]),o,C(n.document.lines[i])));return r===e.lines?e:{...e,lines:r}}s(vt,"mergeViewContributions");function xt(e,t){let r=t.document;if(r.source!==e.source||r.content!==e.content||r.lines.length!==e.lines.length)throw new Error(`Text presenter ${t.presenterId} changed canonical text`);for(let[n,o]of r.lines.entries()){let i=C(e.lines[n]);if(o.lineNumber!==i.lineNumber||o.content!==i.content||o.lineEnding!==i.lineEnding)throw new Error(`Text presenter ${t.presenterId} changed canonical text`)}}s(xt,"assertPresentationOnly");function Tt(e,t,r){let n=Pt(e.presentation,t.presentation,r.presentation),o=St(e.metadata,t.metadata,r.metadata),i=r.anchors===void 0?t.anchors:[...new Set([...t.anchors??[],...r.anchors])];return n===t.presentation&&o===t.metadata&&i===t.anchors?t:{...t,...n!==void 0&&{presentation:n},...o!==void 0&&{metadata:o},...i!==void 0&&{anchors:i}}}s(Tt,"mergePresentedLine");function Pt(e,t,r){if(r===e)return t;let n=$e(e?.prefix,t?.prefix,r?.prefix),o=$e(e?.suffix,t?.suffix,r?.suffix),i=ke(e?.before,t?.before,r?.before),d=ke(e?.after,t?.after,r?.after),a=r?.marker===e?.marker?t?.marker:r?.marker;return n===t?.prefix&&o===t?.suffix&&i===t?.before&&d===t?.after&&a===t?.marker?t:{...t,...n!==void 0&&{prefix:n},...o!==void 0&&{suffix:o},...i!==void 0&&{before:i},...d!==void 0&&{after:d},...a!==void 0&&{marker:a}}}s(Pt,"mergeLinePresentation");function $e(e,t,r){if(r===e)return t;let n=e??"",o=t??"",i=r??"";return n.length>0&&i.startsWith(n)?`${o}${i.slice(n.length)}`:n.length>0&&i.endsWith(n)?`${i.slice(0,-n.length)}${o}`:`${o}${i}`}s($e,"mergePresentedText");function ke(e,t,r){if(r===e)return t;let n=e??[],o=t??[],i=r??[];return Et(i,n)?[...o,...i.slice(n.length)]:Lt(i,n)?[...i.slice(0,i.length-n.length),...o]:[...o,...i]}s(ke,"mergePresentedRows");function Et(e,t){return t.length>0&&t.length<=e.length&&t.every((r,n)=>e[n]===r)}s(Et,"startsWithRows");function Lt(e,t){let r=e.length-t.length;return t.length>0&&r>=0&&t.every((n,o)=>e[r+o]===n)}s(Lt,"endsWithRows");function St(e,t,r){if(r===e||r===void 0)return t;let n=Object.fromEntries(Object.entries(r).filter(([o,i])=>e?.[o]!==i));return Object.keys(n).length===0?t:{...t,...n}}s(St,"mergeLineMetadata");async function _e(e,t){let r=e;for(let n of t){if(n.registration.stage!=="post-read")continue;let o=await Z(n.registration.handler,r,n.pluginId,"post-read");if(o.kind==="return")return o;r=o.context}return{kind:"continue",context:r}}s(_e,"runPostReadHandlers");async function Z(e,t,r,n){try{return await e(t)}catch(o){return{kind:"return",result:T({code:"PIPELINE_FAILED",...t.state?.source===void 0?t.result?.details.source===void 0?{}:{source:t.result.details.source}:{source:t.state.source},pluginId:r,stage:n,message:`Plugin ${r} failed during ${n}`,cause:o})}}}s(Z,"invokeHandler");function bt(e,t){return(e.when.resolvedBy==="any"||e.when.resolvedBy===t.resolvedBy)&&(e.when.contentKind==="any"||e.when.contentKind===t.contentKind)}s(bt,"matchesReadState");function At(e,t,r,n,o){let i=new Set(n.map(({resolver:a})=>a.id));for(let a of t){if(!j(a))throw new TypeError(`Plugin ${e} provided an invalid resource resolver`);if(i.has(a.resolver.id))throw new Error(`Resource resolver ${a.resolver.id} is already registered`);i.add(a.resolver.id)}let d=new Set(o.filter(a=>a.pluginId===e).map(a=>a.registration.stage));for(let a of r){if(!G(a))throw new TypeError(`Plugin ${e} provided an invalid read handler`);if(d.has(a.stage))throw new Error(`Plugin ${e} already handles ${a.stage}`);d.add(a.stage)}}s(At,"validateContributions");function $t(e,t,r){let n=new Set(r.map(({registration:o})=>o.id));for(let o of t){if(!z(o))throw new TypeError(`Plugin ${e} provided an invalid fragment resolver`);if(n.has(o.id))throw new Error(`Fragment resolver ${o.id} is already registered`);n.add(o.id)}}s($t,"validateFragmentRegistrations");function F(e,t){return!(t instanceof Error)||t.message.length===0?e:`${e}: ${t.message}`}s(F,"appendErrorMessage");function Ne(e="compact"){let t=[],r=new Set,n=new Map,o=Ce(()=>Dt(n),e),i=Promise.resolve();return{read:o,registerPlugin(d){let a=kt(d);if(a!==void 0)return Promise.reject(a);let g=n.get(d.id);if(g?.plugin===d)return g.ready;if(g!==void 0)return Promise.reject(new Error(`Plugin ${d.id} is already registered`));let m={status:"pending"},l=[],p=[],f=Ct(d.id,o,p,l,t),c=i.then(async()=>{try{await d.setup(f.api),f.commit(),m.status="active";return}catch(w){throw f.close(),w}}),x={lifecycle:m,plugin:d,promptGuidelines:p,promptContributions:l,ready:c};return n.set(d.id,x),r.add(c),i=c.catch(()=>{}),c.then(()=>{r.delete(c)},()=>{r.delete(c),n.get(d.id)===x&&n.delete(d.id)}),c},renderPluginPromptGuideline:s(()=>Ot(n),"renderPluginPromptGuideline"),async waitForPendingPlugins(){await Promise.all(r)}}}s(Ne,"createReadCore");function kt(e){if(e.protocol!==V)return new Error(`Plugin ${e.id} uses an unsupported protocol`);if(e.apiVersion!==U)return new Error(`Plugin ${e.id} uses an unsupported API version`);if(e.id.trim().length===0)return new Error("Plugin ID must not be empty")}s(kt,"getPluginValidationError");function Ct(e,t,r,n,o){let i=[],d=[],a=[],g=[],m=[],l=[],p=[],f=[],c=[],x="setup",w=s(()=>{if(x==="closed")throw new Error(`Plugin ${e} API is closed`)},"assertAvailable");return{api:{addOutputReducer(R){if(w(),typeof R!="function")throw new TypeError("Expected an output reducer");(x==="setup"?i:o).push(R)},async reduceOutput(R,v,E){w();for(let y of o){v.signal?.throwIfAborted();let L=await y(R,v,E);if(L!==void 0)return L}},saveTemporary(R){return w(),t.saveTemporary(R)},read(R,v,E){return w(),t.execute(R,v,E)},addResourceGuard(R){w(),x==="setup"?g.push(R):t.registerContributions(e,{resourceGuards:[R]})},addResolver(R){if(w(),!j(R))throw new TypeError(`Plugin ${e} provided an invalid resource resolver`);if(x==="setup"){m.push(R);return}t.registerContributions(e,{resolvers:[R]})},addTargetResolver(R){if(w(),!B(R))throw new TypeError(`Plugin ${e} provided an invalid text target resolver`);if(x==="setup"){l.push(R);return}t.registerContributions(e,{targetResolvers:[R]})},addHandler(R){if(w(),!G(R))throw new TypeError(`Plugin ${e} provided an invalid read handler`);if(x==="setup"){p.push(R);return}t.registerContributions(e,{handlers:[R]})},addView(R){if(w(),!H(R))throw new TypeError(`Plugin ${e} provided an invalid view registration`);if(x==="setup"){f.push(R);return}t.registerContributions(e,{views:[R]})},addFragmentResolver(R){if(w(),!z(R))throw new TypeError(`Plugin ${e} provided an invalid fragment resolver`);if(x==="setup"){c.push(R);return}t.registerContributions(e,{fragments:[R]})},describe(R){if(w(),d.length>0||n.length>0)throw new Error(`Plugin ${e} provides more than one description`);let v=Fe(R);if(x==="setup"){d.push(v);return}n.push(v)},addPromptGuideline(R){w();let v=Fe(R);if(x==="setup"){a.push(v);return}r.push(v)}},close(){x="closed"},commit(){if(x!=="setup")throw new Error(`Plugin ${e} setup contributions cannot be committed`);t.registerContributions(e,{resourceGuards:g,resolvers:m,targetResolvers:l,handlers:p,views:f,fragments:c}),n.push(...d),o.push(...i),r.push(...a),x="active"}}}s(Ct,"createPluginContributionController");function Dt(e){let t=[];for(let r of e.values())if(r.lifecycle.status==="active")for(let n of r.promptGuidelines){let o=Me(n);o!==void 0&&t.push(o)}return t}s(Dt,"renderPromptGuidelines");function Ot(e){let t=[];for(let r of e.values()){if(r.lifecycle.status!=="active")continue;let n=r.promptContributions[0];if(n===void 0)continue;let o=Me(n);o!==void 0&&t.push(o)}return t.length===0?void 0:[...new Set(t.flatMap(r=>r.split(`
10
+ `)))].join(`
11
+ `)}s(Ot,"renderPluginPromptGuideline");function Fe(e){if(typeof e=="string")return Ve(e);if(typeof e=="function")return e;throw new TypeError("Read plugin prompt description must be a string or callback")}s(Fe,"normalizeDescriptionSource");function Me(e){if(typeof e=="string")return e;let t=e();return t===void 0?void 0:Ve(t)}s(Me,"renderDescriptionSource");function Ve(e){if(typeof e!="string")throw new TypeError("Read plugin prompt description must be a string");let t=e.replaceAll(`\r
12
+ `,`
13
+ `).replaceAll("\r",`
14
+ `).split(`
15
+ `).map(n=>n.trimEnd());for(;t[0]?.trim().length===0;)t.shift();for(;t.at(-1)?.trim().length===0;)t.pop();let r=t.join(`
16
+ `);if(r.trim().length===0)throw new Error("Read plugin prompt description is empty");return r}s(Ve,"normalizeDescription");function It(e){return typeof e=="object"&&e!==null}s(It,"isRecord");function _t(e){return e==="full"||e==="disabled"?e:"compact"}s(_t,"parsePresentation");async function Ue(e,t){se(e,[await ie({id:"read-resources",description:"Resource selection, windows, views, raw bytes, and continuation",triggers:[{tool:"read"}]})]);let r=Ne(_t(t?.preferences["ui.read"])),n=e.events.on(de,i=>{if(!ue(i))throw new Error("Invalid pi-agent-read plugin registration request");i.accept(r.registerPlugin(i.plugin))});e.on("session_shutdown",async()=>{n(),await r.read.dispose()});let o=new ye;e.registerTool(he(r.read.tool,o)),e.on("tool_result",i=>{if(!(i.toolName!=="read"||!It(i.details)))return{details:le(i.details,i.content.flatMap(d=>d.type==="text"?[d.text]:[]).join(`
17
+ `)),...i.details.failure!==void 0&&{isError:!0}}}),e.events.emit(ae,{protocol:V,apiVersion:U}),await r.waitForPendingPlugins()}s(Ue,"registerReadCore");export{Ue as default};
package/dist/entry-46.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-ROXXK6TW.js";import{a}from"./chunk-KII2JQC5.js";import"./chunk-EI7MMDWY.js";export{a as searchSchema};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v}from"./chunk-S3ZPXWX7.js";import"./chunk-EI7MMDWY.js";export{p as CONTENT_API_VERSION,r as CONTENT_CONVERTER_REGISTER_EVENT,q as CONTENT_HOST_READY_EVENT,o as CONTENT_PROTOCOL,l as UnsupportedContentError,v as connectContentConverter,u as createContentHost,m as createContentRunner,b as isAgentContent,j as isContentConversionAttempt,h as isContentConversionContext,i as isContentConverter,k as isContentConverterRegistration,t as isContentConverterRegistrationRequest,s as isContentHostReady,g as isContentInput,f as isContentTarget,c as isResource,e as isResourceResolutionAttempt,d as isResourceResolver,a as renderContentDescription,n as targetsEqual};
package/dist/entry-47.js CHANGED
@@ -1,7 +1 @@
1
- import{e as j,f as F,g as L}from"./chunk-GIRAEVUJ.js";import{c as I}from"./chunk-YHUTTZC6.js";import{a as O}from"./chunk-KII2JQC5.js";import{a as C,b as D,c as $,d as N,g as M}from"./chunk-7UGNGK7Y.js";import{a as o}from"./chunk-EI7MMDWY.js";import{keyText as oe}from"@earendil-works/pi-coding-agent";import{Text as ie}from"@earendil-works/pi-tui";import se from"node:os";function V(){let e=[],r,s=new Map,a=new Map,i=new Map,c=new Map,u=Promise.resolve(),f={registerPlugin(n){if(n.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let d=c.get(n.id);if(d!==void 0)return d;let p=u.then(async()=>{let m=[],y=[],S,R,h=[],l={addSelectionProvider(t){if(S!==void 0||r!==void 0)throw new Error("Search selection provider is already registered");S=t},registerSelection(t,w){if(r===void 0)throw new Error("Search selections are unavailable. Enable the shared search selection plugin.");return r(t,w)},addResolver(t){B(t),m.push(t)},addAction(t){Q(t),y.push(t)},describe(t){if(R!==void 0)throw new Error(`Plugin ${n.id} provides more than one description`);R=G(t)},addPromptGuideline(t){h.push(G(t))},search:o((t,w,T)=>f.execute(t,w,T),"search"),runAction(t,w){return f.runAction(t.reference,t.capability,t.resolverId,t.input,w)}};await n.setup(l);let g=new Set(e.map(({registration:t})=>t.resolver.id));for(let t of m){if(g.has(t.resolver.id))throw new Error(`Search resolver ${t.resolver.id} is already registered`);g.add(t.resolver.id)}for(let t of y){let w=E(t.resolverId,t.capability);if(s.has(w)||y.some(T=>T!==t&&E(T.resolverId,T.capability)===w))throw new Error(`Search action ${w} is already registered`)}for(let t of m)e.push({pluginId:n.id,registration:t,order:e.length});S!==void 0&&(r=S);for(let t of y)s.set(E(t.resolverId,t.capability),t);R!==void 0&&i.set(n.id,R),h.length>0&&a.set(n.id,h)});return c.set(n.id,p),u=p.catch(()=>{}),p.catch(()=>{c.delete(n.id)}),p},async waitForPendingPlugins(){await Promise.all(c.values())},async execute(n,d,p="agent"){if(n.query.trim().length===0)return v("INVALID_REQUEST","Search query must not be empty");let m=[...e].sort((h,l)=>+(h.registration.fallback===!0)-+(l.registration.fallback===!0)||(h.registration.priority??0)-(l.registration.priority??0)||h.order-l.order),y=/^[a-z][\w-]*:\s*$/iu.test(n.query),S=/^[a-z][\w-]*:/iu.test(n.query);for(let h of m){if(y&&!h.registration.fallback)continue;let l=h.registration.resolver,g;try{d.signal?.throwIfAborted(),g=await l.tryResolve(n,d)}catch(t){return v("RESOLVE_FAILED",x(t,`Resolver ${l.id} failed`),l.id,t)}if(!Y(g))return v("INVALID_RESOLVER_RESULT",`Resolver ${l.id} returned an invalid result`,l.id);if(g.kind!=="not-handled"){if(g.kind==="failed")return v("RESOLVE_FAILED",x(g.error,`Resolver ${l.id} failed`),l.id,g.error);try{let t=await l.format(g.payload,d);return X(t)?{content:h.registration.fallback&&S?[{type:"text",text:y?"Search fallback: empty protocol query; searched the original text.":"Search fallback: unhandled protocol query; searched the original text."},...t.content]:t.content,details:{resolverId:l.id,payload:t.details},...p==="script"&&{script:{resolverId:l.id,data:g.payload,details:t.details}},...t.usage!==void 0&&{usage:t.usage}}:v("FORMAT_FAILED",`Resolver ${l.id} formatter returned an invalid result`,l.id)}catch(t){return v("FORMAT_FAILED",x(t,`Resolver ${l.id} formatter failed`),l.id,t)}}}let R=`No search resolver handled ${n.query}`;return j(v("NO_RESOLVER",R),R)},runAction(n,d,p,m,y){let S=s.get(E(p,d));if(S===void 0)throw new Error(`Search reference does not support ${d}`);return S.execute(n,m,y)},renderDescriptions(){return[...i.values()].flatMap(n=>{let d=H(n);return d===void 0?[]:[d]})},renderPromptGuidelines(){return[...a.values()].flat().flatMap(n=>{let d=H(n);return d===void 0?[]:[d]})},renderer(n){return e.find(({registration:d})=>d.resolver.id===n)?.registration.resolver.renderResult}};return f}o(V,"createSearchCore");function B(e){if(!A(e)||!A(e.resolver))throw new TypeError("Invalid search resolver registration");let r=e.resolver;if(typeof r.id!="string"||r.id.trim().length===0||typeof r.tryResolve!="function"||typeof r.format!="function")throw new TypeError("Invalid search resolver registration");if(e.priority!==void 0&&(typeof e.priority!="number"||!Number.isFinite(e.priority)))throw new TypeError("Invalid search resolver priority")}o(B,"assertResolver");function Q(e){if(!A(e)||typeof e.resolverId!="string"||e.resolverId.trim().length===0||typeof e.capability!="string"||e.capability.trim().length===0||typeof e.execute!="function")throw new TypeError("Invalid search action registration")}o(Q,"assertAction");function A(e){return typeof e=="object"&&e!==null}o(A,"isRecord");function Y(e){if(typeof e!="object"||e===null||!("kind"in e))return!1;let r=e.kind;return r==="not-handled"||r==="resolved"&&"payload"in e||r==="failed"&&"error"in e}o(Y,"isAttempt");function X(e){return typeof e=="object"&&e!==null&&Array.isArray(e.content)}o(X,"isAgentToolResult");function v(e,r,s,a){return{content:[{type:"text",text:r}],details:{failure:{code:e,message:r,...s!==void 0&&{resolverId:s},...a!==void 0&&{cause:a}}}}}o(v,"failure");function G(e){if(typeof e=="function")return e;if(typeof e!="string"||e.trim().length===0)throw new TypeError("Search description must not be empty");return e.trim()}o(G,"normalizeDescriptionSource");function H(e){let r=typeof e=="function"?e():e;if(r!==void 0){if(typeof r!="string"||r.trim().length===0)throw new TypeError("Search description must not be empty");return r.trim()}}o(H,"renderDescription");function E(e,r){return`${e}:${r}`}o(E,"actionKey");function x(e,r){return!(e instanceof Error)||e.message.trim().length===0?r:e instanceof SyntaxError?e.message:`${r}: ${e.message}`}o(x,"messageFor");import{readFile as Z}from"node:fs/promises";import ee from"node:os";import b from"node:path";var re=3e4;function J(e=process.env,r=ee.homedir(),s=process.cwd()){let a=e.PI_CODING_AGENT_DIR?.trim(),i=a===void 0||a.length===0?b.join(r,".pi","agent"):b.resolve(a);return{globalPath:b.join(i,"pi-agent-ide","search.json"),projectPath:b.resolve(s,".pi","pi-agent-ide","search.json")}}o(J,"resolveSearchConfigPaths");async function W(e){let[r,s]=await Promise.all([q(e.globalPath),q(e.projectPath)]),a=s!==void 0?s:r;return{timeoutMs:a===void 0?re:a}}o(W,"loadSearchConfig");async function q(e){let r;try{r=await Z(e,"utf8")}catch(c){if(te(c))return;throw new Error(`Cannot read Pi Agent IDE search config at ${e}`,{cause:c})}let s;try{s=JSON.parse(r)}catch(c){throw new Error(`Invalid JSON in Pi Agent IDE search config at ${e}`,{cause:c})}if(!U(s))throw new TypeError(`Pi Agent IDE search config at ${e} must be a JSON object`);let a=Object.keys(s).find(c=>c!=="timeoutMs");if(a!==void 0)throw new TypeError(`Pi Agent IDE search config at ${e} contains unknown key ${a}`);let i=s.timeoutMs;if(i==null)return i;if(typeof i!="number"||!Number.isSafeInteger(i)||i<=0)throw new TypeError(`timeoutMs must be a positive integer or null in Pi Agent IDE search config at ${e}`);return i}o(q,"readTimeout");function te(e){return U(e)&&e.code==="ENOENT"}o(te,"isMissingFile");function U(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}o(U,"isRecord");var z=Symbol("search-timeout"),k=class extends Error{static{o(this,"SearchTimeoutError")}constructor(r){super(r),this.name="SearchTimeoutError"}};async function _(e,r,s){if(e===null)return s(r);let a=new AbortController,i=r===void 0?a.signal:AbortSignal.any([r,a.signal]),c,u=new Promise(f=>{c=setTimeout(()=>{f(z),a.abort()},e)});try{let f=await Promise.race([s(i),u]);if(f===z)throw new k(`Search timed out after ${ne(e)}. Try a smaller path scope.`);return f}finally{clearTimeout(c)}}o(_,"runWithSearchTimeout");function ne(e){if(e%1e3!==0)return`${String(e)}ms`;let r=e/1e3;return`${String(r)} ${r===1?"second":"seconds"}`}o(ne,"formatDuration");function ae(e,r){let s=[...e.path===void 0?[]:[{text:`in ${e.path}`,color:"accent",underline:!0,truncate:"start"}],...e.include===void 0?[]:[{text:`include ${e.include}`}],...e.exclude===void 0?[]:[{text:`exclude ${e.exclude}`}],...e.caseSensitive===!0?[{text:"case sensitive"}]:[],...e.wholeWord===!0?[{text:"whole word"}]:[],...e.limit===void 0?[]:[{text:`limit ${String(e.limit)}`}]];return{tool:"search",primary:{text:JSON.stringify(e.query),color:"accent",truncate:"end"},qualifiers:s,details:ce(e),expanded:r}}o(ae,"searchCallModel");async function K(e){let r=V(),s=new F,a=e.events.on(N,i=>{if(!M(i))throw new Error("Invalid pi-agent-search plugin registration request");i.accept(r.registerPlugin(i.plugin))});e.on("session_shutdown",a),e.registerTool(L({name:"search",label:"search",get description(){return["Use search to locate text, file paths and code structures in the workspace.",...r.renderDescriptions()].join(`
2
- `)},promptSnippet:"Search files and text with literals or regular expressions, plus syntax trees and language symbols",get promptGuidelines(){return["Use the narrowest useful search query and scope; broaden when needed.",...r.renderPromptGuidelines()]},parameters:O,renderCall(i,c,u){return I(u.lastComponent,ae(i,u.expanded),c)},renderResult(i,c,u,f){let n=i.details,d=n?.resolverId===void 0?void 0:r.renderer(n.resolverId);if(d!==void 0){let p={...i,details:n?.payload};return d(p,c,u,f)}return de(i,c,u)},async execute(i,c,u,f,n){let d=await W(J(process.env,se.homedir(),n.cwd));return _(d.timeoutMs,u,async p=>(await r.waitForPendingPlugins(),r.execute(c,{cwd:n.cwd,...p!==void 0&&{signal:p},...f!==void 0&&{onUpdate:o(m=>{f(m)},"onUpdate")}})))}},s)),e.events.emit($,{protocol:C,apiVersion:D}),await r.waitForPendingPlugins()}o(K,"registerSearchCore");function ce(e){return[{label:"query",value:JSON.stringify(e.query)},...P("path",e.path),...P("include",e.include),...P("exclude",e.exclude),...P("caseSensitive",e.caseSensitive===void 0?void 0:String(e.caseSensitive)),...P("wholeWord",e.wholeWord===void 0?void 0:String(e.wholeWord)),...P("limit",e.limit===void 0?void 0:String(e.limit))]}o(ce,"searchCallDetails");function P(e,r){return r===void 0?[]:[{label:e,value:r}]}o(P,"optionalDetail");function de(e,r,s){let a=e.content.flatMap(u=>u.type==="text"?[u.text]:[]).join(`
3
- `),i=r.expanded?a:a.split(`
4
- `).slice(0,8).join(`
5
- `),c=!r.expanded&&a.split(`
6
- `).length>8?`
7
- ${s.fg("dim",`${oe("app.tools.expand")} to expand`)}`:"";return new ie(`${s.fg("muted",i)}${c}`,0,0)}o(de,"fallbackResult");export{K as default};
1
+ import{a}from"./chunk-ZTYWHL2F.js";import"./chunk-7UGNGK7Y.js";import"./chunk-EI7MMDWY.js";export{a as connectSearchPlugin};
package/dist/entry-48.js CHANGED
@@ -1,11 +1 @@
1
- import{a as x,b as J,c as X,d as fe,h as Q}from"./chunk-P7XO5CIP.js";import"./chunk-GUTQ3PWL.js";import{a as H}from"./chunk-MGCHOGQD.js";import{a as F,b as I}from"./chunk-T6LX2RX5.js";import{a as W}from"./chunk-L7JMDDSD.js";import{a as _,b as j,d as B}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import{a as z}from"./chunk-ZTYWHL2F.js";import{a as G,b as V}from"./chunk-7UGNGK7Y.js";import{t as L,u as O}from"./chunk-5VSE5X5R.js";import{d as N,e as v}from"./chunk-N34ATN52.js";import{a as M}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";var U={protocol:F,apiVersion:1,id:"search-text",setup(e){e.addSetupCheck({id:"ripgrep",async inspect(t){let r=x(t.env.PI_CODING_AGENT_DIR);return await N(r,t.cwd,t.env)?{}:{actions:[{id:"ripgrep-unavailable",message:"Local search is unavailable because ripgrep was not found"}]}}}),e.addCheck({id:"ripgrep",title:"Local search",async run(t){let r=t.env.PI_CODING_AGENT_DIR,n=x(r),a=await v(n,["--version"],t.cwd,t.env);return[a.ok?{status:"pass",message:"ripgrep is available",detail:a.detail}:{status:"fail",message:"ripgrep is not available",detail:a.detail}]}})}};import ce from"node:path";import{spawn as ge}from"node:child_process";import T from"node:path";function Y(e,t,r,n){let a=t.limit??100,o=["--files","--hidden","--no-config","--no-ignore-parent","--glob","!.git/**"];for(let i of K(t.include))o.push("--glob",i);for(let i of K(t.exclude))o.push("--glob",`!${i}`);return t.path!==void 0&&o.push(t.path),new Promise((i,s)=>{let l=ge(x(),o,{cwd:r,stdio:["ignore","pipe","pipe"]}),u="",h="";l.stdout.setEncoding("utf8"),l.stderr.setEncoding("utf8"),l.stdout.on("data",d=>u+=d),l.stderr.on("data",d=>h+=d);let p=c(()=>{l.kill("SIGTERM")},"abort");n?.addEventListener("abort",p,{once:!0}),l.once("error",s),l.once("close",d=>{if(n?.removeEventListener("abort",p),n?.aborted===!0){s(n.reason instanceof Error?n.reason:new Error("File search aborted"));return}if(d!==0&&d!==1){s(new Error(h.trim()||`rg exited with code ${String(d)}`));return}let g=u.split(`
2
- `).filter(Boolean).map(m=>T.relative(r,T.resolve(r,m))).filter(m=>ye(m,e)).sort((m,b)=>m.localeCompare(b));i({files:g.slice(0,a),complete:g.length<=a})})})}c(Y,"searchFiles");function K(e){return e?.split(",").map(t=>t.trim()).filter(Boolean)??[]}c(K,"splitGlobs");function ye(e,t){if(/[*?[\]{}]/u.test(t)){let r=t.replace(/^\.\//u,"");return T.matchesGlob(r.includes("/")?e:T.basename(e),r)}return Se(e,t)}c(ye,"matchFile");function Se(e,t){if(t.length===0)return!0;let r=0,n=e.toLowerCase();for(let a of t.toLowerCase()){if(r=n.indexOf(a,r),r===-1)return!1;r+=1}return!0}c(Se,"fuzzyMatch");import Te from"node:path";import{keyText as ie}from"@earendil-works/pi-coding-agent";import{Text as $e,truncateToWidth as C,visibleWidth as f,wrapTextWithAnsi as Ae}from"@earendil-works/pi-tui";import Z from"node:path";import{pathToFileURL as ee}from"node:url";function $(e,t){let r=new Map;for(let s of e){let l=r.get(s.source)??[];l.push(s),r.set(s.source,l)}let n=new Set,a=e.length,o=[...r].sort(([s,l],[u,h])=>h.length-l.length||s.localeCompare(u));for(let[s,l]of o){if(a<=t)break;n.add(s),a-=l.length}return{files:[...r].sort(([s],[l])=>s.localeCompare(l)).map(([s,l])=>{if(!n.has(s))return{kind:"detailed",source:s,matches:l};let u=new Map;for(let h of l)u.set(h.lineText,(u.get(h.lineText)??0)+1);return{kind:"compacted",source:s,matchCount:l.length,uniqueLineCount:u.size,groups:r.size===1?[...u].sort(([h,p],[d,g])=>g-p||h.localeCompare(d)).slice(0,t).map(([h,p])=>({text:h,matchCount:p})):[]}})}}c($,"planSearchPresentation");function E(e,t,r,n,a,o=50){let s=$(t,o).files.map(l=>l.kind==="detailed"?be(l.source,l.matches,n):{path:te(l.source,n),link:ee(l.source).href,matchCount:l.matchCount,uniqueLineCount:l.uniqueLineCount,groups:l.groups,lines:[]});return{...a!==void 0&&{sessionId:a},query:e,matchCount:t.length,fileCount:s.length,complete:r,files:s}}c(E,"createSearchToolDetails");function A(e){if(!R(e)||typeof e.query!="string"||!y(e.matchCount)||!y(e.fileCount)||typeof e.complete!="boolean"||e.sessionId!==void 0&&typeof e.sessionId!="string"||!Array.isArray(e.files)||!e.files.every(xe))return!1;let t=e.files;return e.fileCount===t.length&&e.matchCount===t.reduce((r,n)=>r+n.matchCount,0)}c(A,"isSearchToolDetails");function be(e,t,r){let n=new Map;for(let o of t){let i=n.get(o.lineNumber);if(i!==void 0&&i.text!==o.lineText)throw new Error(`Search results disagree about line ${String(o.lineNumber)} in ${e}.`);let s=i??{lineNumber:o.lineNumber,text:o.lineText,ranges:[]};s.ranges.push({from:o.startColumn,to:o.endColumn}),n.set(o.lineNumber,s)}let a=[...n.values()].sort((o,i)=>o.lineNumber-i.lineNumber).map(o=>{let i=[...o.ranges].sort((s,l)=>s.from-l.from||s.to-l.to);return{lineNumber:o.lineNumber,text:o.text,matchCount:i.length,ranges:i}});return{path:te(e,r),link:ee(e).href,matchCount:t.length,lines:a}}c(be,"createSearchResultFile");function xe(e){if(!R(e)||typeof e.path!="string"||typeof e.link!="string"||!y(e.matchCount)||!Array.isArray(e.lines)||!e.lines.every(Re))return!1;let t=e.lines,r=e.groups;return(r===void 0||Array.isArray(r)&&r.every(n=>R(n)&&typeof n.text=="string"&&y(n.matchCount)))&&(e.uniqueLineCount===void 0||y(e.uniqueLineCount))&&(t.length===0||e.matchCount===t.reduce((n,a)=>n+a.matchCount,0))}c(xe,"isSearchResultFile");function Re(e){return R(e)&&Number.isSafeInteger(e.lineNumber)&&e.lineNumber>=1&&typeof e.text=="string"&&y(e.matchCount)&&Array.isArray(e.ranges)&&e.ranges.length===e.matchCount&&e.ranges.every(t=>Ce(t,e.text))}c(Re,"isSearchResultLine");function Ce(e,t){return R(e)&&Number.isSafeInteger(e.from)&&Number.isSafeInteger(e.to)&&e.from>=0&&e.to>e.from&&e.to<=t.length}c(Ce,"isSearchResultRange");function R(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}c(R,"isRecord");function y(e){return Number.isSafeInteger(e)&&e>=0}c(y,"isCount");function te(e,t){let r=Z.relative(t,e);return r.length>0&&!r.startsWith("..")&&!Z.isAbsolute(r)?r:e}c(te,"displaySource");function re(e){return e.replaceAll("\u27E6","").replaceAll("\u27E7","")}c(re,"sourceText");function ne(e,t){let{files:r,...n}=e,a=re(t);return{...n,storedFiles:r.map(({lines:o,...i})=>({...i,lines:o.map(s=>[s.lineNumber,L(s.text,a),s.ranges])}))}}c(ne,"compactSearchDetails");function oe(e,t){if("files"in e)return e;let{storedFiles:r,...n}=e,a=re(t);return{...n,files:r.map(({lines:o,...i})=>({...i,lines:o.map(([s,l,u])=>({lineNumber:s,text:O(l,a),ranges:u,matchCount:u.length}))}))}}c(oe,"restoreSearchDetails");var ae=new WeakMap,k=12,we={".ts":{label:"TS",color:"accent"},".tsx":{label:"TX",color:"accent"},".js":{label:"JS",color:"warning"},".jsx":{label:"JX",color:"warning"},".json":{label:"{}",color:"warning"},".md":{label:"MD",color:"mdHeading"},".py":{label:"PY",color:"accent"},".rs":{label:"RS",color:"accent"},".go":{label:"GO",color:"accent"},".css":{label:"CS",color:"accent"},".html":{label:"<>",color:"accent"}};function se(e,t,r,n){if(typeof e.details=="object"){let i=ae.get(e.details);i===void 0&&(i=oe(e.details,e.content.flatMap(s=>s.type==="text"?[s.text]:[]).join(`
3
- `)),ae.set(e.details,i)),e={...e,details:i}}if(t.isPartial||n.isError||!A(e.details)){let i=e.content[0],s=i?.type==="text"?i.text:"",l=n.isError?"error":t.isPartial?"dim":"toolOutput";return new $e(r.fg(l,s),0,0)}let o=(n.lastComponent instanceof q?n.lastComponent:void 0)??new q(e.details,r,t.expanded);return o.update(e.details,r,t.expanded),o}c(se,"renderSearchResult");var q=class{constructor(t,r,n){this.details=t;this.theme=r;this.expanded=n}static{c(this,"SearchResultPanel")}cached;update(t,r,n){this.details===t&&this.theme===r&&this.expanded===n||(this.details=t,this.theme=r,this.expanded=n,this.invalidate())}render(t){if(this.cached?.width===t)return this.cached.lines;if(t<4){let u=[C(le(this.details),Math.max(1,t))];return this.cached={width:t,lines:u},u}let r=t-2,n=ke(this.details,this.expanded),a=Fe(this.details.files),o=n.flatMap(u=>Ee(u,r,a,this.theme)),i=qe(o,this.expanded,r,this.theme),s=[Le(this.details,r,this.theme),...i];s.push(this.theme.fg("borderMuted",`\u2570${"\u2500".repeat(r)}\u256F`));let l=s.map(u=>C(u,t));return this.cached={width:t,lines:l},l}invalidate(){this.cached=void 0}};function ke(e,t){let r=e.files.length===0?[{kind:"empty"}]:e.files.flatMap(o=>[{kind:"file",file:o},...o.uniqueLineCount===void 0?o.lines.map(i=>({kind:"line",file:o,line:i})):[{kind:"summary",text:`${String(o.uniqueLineCount)} unique line texts \xB7 search this path with a narrower query`},...(o.groups??[]).map(i=>({kind:"summary",text:`\xD7${String(i.matchCount)} ${i.text}`}))]]);if(t||r.length<=k)return r;let n=r.slice(0,k-1);for(;n.at(-1)?.kind==="file";)n.pop();let a=n.reduce((o,i)=>o+(i.kind==="line"?i.line.matchCount:0),0);return[...n,{kind:"omitted",matches:e.matchCount-a}]}c(ke,"searchViewport");function qe(e,t,r,n){if(t||e.length<=k)return e;let a=`${ie("app.tools.expand")} to expand`,o=S(n.fg("dim",` \u2026 output truncated \xB7 ${a}`),r,n);return[...e.slice(0,k-1),o]}c(qe,"compactRenderedRows");function Ee(e,t,r,n){if(e.kind==="file")return[S(Pe(e.file,t,n),t,n,!0)];if(e.kind==="line")return De(e.line,t,r,n);if(e.kind==="summary")return[S(n.fg("dim",` ${w(e.text)}`),t,n)];if(e.kind==="omitted"){let a=`${ie("app.tools.expand")} to expand`;return[S(n.fg("dim",` \u2026 ${String(e.matches)} more ${P(e.matches,"match","matches")} \xB7 ${a}`),t,n)]}return[S(n.fg("dim"," No matches found"),t,n)]}c(Ee,"renderPanelRow");function Pe(e,t,r){let n=Oe(e.path,r),a=r.fg("accent",r.bold(String(e.matchCount))),o=f(n)+f(a)+4,i=Math.max(1,t-o),s=ve(e.path,i),l=Ne(s,e.link,r),u=` ${n} ${l}`,h=" ".repeat(Math.max(1,t-f(u)-f(a)-1));return C(`${u}${h}${a} `,t)}c(Pe,"renderFileHeader");function De(e,t,r,n){let a=String(e.lineNumber).padStart(r),o=` ${n.fg("dim",a)} ${n.fg("borderMuted","\u2502")} `,i=Math.max(1,t-f(o)-1),s=Ae(Me(e,n),i),l=" ".repeat(f(o));return s.map((u,h)=>S(`${h===0?o:l}${u}`,t,n))}c(De,"renderMatchLine");function Me(e,t){let r="",n=0;for(let a of e.ranges){a.from>n&&(r+=t.fg("toolOutput",w(e.text.slice(n,a.from))));let o=w(e.text.slice(a.from,a.to));r+=t.bg("selectedBg",t.fg("accent",t.bold(o))),n=a.to}return n<e.text.length&&(r+=t.fg("toolOutput",w(e.text.slice(n)))),r}c(Me,"renderHighlightedLine");function Le(e,t,r){let n=c(i=>r.fg("borderMuted",i),"frame"),a=C(` ${le(e)} `,Math.max(0,t-1),""),o="\u2500".repeat(Math.max(0,t-f(a)-1));return`${n("\u256D\u2500")}${r.fg("accent",a)}${n(`${o}\u256E`)}`}c(Le,"renderTopBorder");function le(e){return e.matchCount===0?"No matches":`${`${String(e.matchCount)}${e.complete?"":"+"}`} ${P(e.matchCount,"match","matches")} in ${String(e.fileCount)} ${P(e.fileCount,"file","files")}`}c(le,"searchSummary");function S(e,t,r,n=!1){let a=C(e,t),o=`${a}${" ".repeat(Math.max(0,t-f(a)))}`,i=n?r.bg("selectedBg",o):o,s=r.fg("borderMuted","\u2502");return`${s}${i}${s}`}c(S,"framed");function Oe(e,t){let r=Te.extname(e).toLowerCase(),n=we[r]??{label:"\u25C7 ",color:r.length===0?"muted":"accent"};return t.fg(n.color,t.bold(n.label))}c(Oe,"fileBadge");function Ne(e,t,r){let n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),a=n===-1?"":e.slice(0,n+1),o=n===-1?e:e.slice(n+1),i=r.fg("muted",a)+r.underline(r.fg("accent",o));return t.includes("\x07")||t.includes("\x1B")?i:`\x1B]8;;${t}\x07${i}\x1B]8;;\x07`}c(Ne,"fileLink");function ve(e,t){return f(e)<=t?e:t<=1?"\u2026":`\u2026${e.slice(-(t-1))}`}c(ve,"truncatePath");function w(e){let t="";for(let r of e){if(r===" "){t+=" ".repeat(4);continue}let n=M(r.codePointAt(0));t+=n<32||n===127?"\uFFFD":r}return t}c(w,"safeText");function Fe(e){let t=1;for(let r of e)for(let n of r.lines)t=Math.max(t,n.lineNumber);return Math.max(3,String(t).length)}c(Fe,"maximumLineNumberWidth");function P(e,t,r){return e===1?t:r}c(P,"plural");function de(e){return pe("text",e,J)}c(de,"createTextResolver");function he(e){return pe("regex",e,t=>t.query.startsWith("regex:")?{...t,query:t.query.slice(6),regex:!0}:void 0)}c(he,"createRegexResolver");function me(){return{id:"files",async tryResolve(e,t){if(!e.query.startsWith("files:"))return{kind:"not-handled"};let r=e.query.slice(6).trim(),n=await Y(r,e,t.cwd,t.signal);return{kind:"resolved",payload:{query:r,...n}}},format(e){let t=e;return{content:[{type:"text",text:[t.complete?`${String(t.files.length)} files`:`${String(t.files.length)}+ files (limit reached)`,...t.files].join(`
4
- `)}],details:{query:t.query,files:t.files,complete:t.complete}}}}}c(me,"createFileResolver");function pe(e,t,r){return{id:e,async tryResolve(n,a){let o=r(n);if(o===void 0)return{kind:"not-handled"};let i=await X(o,a.cwd,a.signal);return{kind:"resolved",payload:{request:{...n,query:i.query},...i,recipe:{...o,originalQuery:n.query}}}},async format(n,a){let o=n;if(o.matches.length===0)return{content:[{type:"text",text:[...o.notices,"No matches found."].join(`
5
- `)}],details:E(o.request.query,[],o.complete,a.cwd)};let i=o.request.limit??50,s=await t.registerIfCurrent(o.request.query,o.matches,o.complete,a.cwd,a.signal,o.recipe),l=s??{query:o.request.query,matches:o.matches,complete:o.complete};return{content:[{type:"text",text:[...o.notices,Ie(l,a.cwd,i,s!==void 0)].join(`
6
- `)}],details:E(l.query,l.matches,l.complete,a.cwd,s?.id,i)}},renderResult:se}}c(pe,"createMatchResolver");function Ie(e,t,r,n=!0){let a=new Set(e.matches.map(p=>p.source)).size,o=e.matches.length,i=`${String(o)}${e.complete?"":"+"} ${ue(o,"match","matches")} in ${String(a)} ${ue(a,"file","files")}`,s=n?e.complete?`SEARCH#${e.id}:all:line / SEARCH#${e.id}:all:match \u2014 ${i}`:`${i} (limit reached; no all anchors were registered)`:`${i} (files changed during search; results shown without anchors)`,l=n?["Anchors: SEARCH#HASH:N:line (line), SEARCH#HASH:N:match (exact match), SEARCH#HASH:all:line (each unique containing line), SEARCH#HASH:all:match (every exact match)",s]:[s],u=new Map(e.matches.map((p,d)=>[p,d+1])),h=$(e.matches,r);for(let[p,d]of h.files.entries()){p>0&&l.push("");let g=je(d.source,t);if(d.kind==="compacted"){l.push(`${g}: ${String(d.matchCount)} matches across ${String(d.uniqueLineCount)} unique line texts (compacted)`);for(let m of d.groups)l.push(` \xD7${String(m.matchCount)} ${_e(m.text)}`);d.groups.length<d.uniqueLineCount&&l.push(` \u2026 ${String(d.uniqueLineCount-d.groups.length)} more unique line texts`),l.push(` Search again with path: ${JSON.stringify(g)} and a narrower query to see individual matches.`);continue}for(let m of d.matches){let b=u.get(m);if(b===void 0)continue;let D=`${g}:${String(m.lineNumber)}:${String(m.startColumn+1)}-${String(m.endColumn+1)}`;l.push(n?`${D} SEARCH#${e.id}:${String(b)}:line SEARCH#${e.id}:${String(b)}:match`:D,` ${He(m)}`)}}return l.join(`
7
- `)}c(Ie,"formatSearchSession");function He(e){let r=Math.max(0,e.startColumn-64),n=Math.min(e.lineText.length,e.endColumn+64);return`${r>0?"\u2026":""}${e.lineText.slice(r,e.startColumn)}\u27E6${e.lineText.slice(e.startColumn,e.endColumn)}\u27E7${e.lineText.slice(e.endColumn,n)}${n<e.lineText.length?"\u2026":""}`}c(He,"previewMatch");function _e(e){return`${e.slice(0,129)}${e.length>129?"\u2026":""}`}c(_e,"previewLine");function je(e,t){let r=ce.relative(t,e);return r.length>0&&!r.startsWith("..")&&!ce.isAbsolute(r)?r:e}c(je,"displaySource");function ue(e,t,r){return e===1?t:r}c(ue,"plural");async function Be(e){let t=new Q;e.on("tool_result",async(r,n)=>{if(r.toolName!=="replace"||r.isError||typeof r.details!="object"||r.details===null)return;let a="metadata"in r.details?r.details.metadata:void 0,o=a&&typeof a=="object"&&"searchObservations"in a?a.searchObservations:void 0,i=Array.isArray(o)?o:await t.observeAfterEdit([r.input.path,r.input.start,r.input.end],n.signal);if(i.length!==0)return{content:[...r.content,{type:"text",text:["Original search observed after editing (not task validation):",...i.map(s=>{let{query:l,fallbacks:u,...h}=s.scope;return[`SEARCH#${s.sessionId}: ${JSON.stringify(s.query)}`,`Scope and options: ${JSON.stringify(h)}`,s.error===void 0?`Matches: ${s.matches}${s.complete===!0?"; complete search.":"+; incomplete search, lower bound only."}`:`Search failed: ${s.error}. Applied edits remain applied.`,...s.notices??[]].join(`
8
- `)})].join(`
9
- `)}],details:{...r.details,searchObservations:i}}}),e.on("tool_result",r=>{if(r.toolName!=="search"||typeof r.details!="object"||r.details===null)return;let n=r.details;if(A(n.payload))return{details:{...n,payload:ne(n.payload,r.content.flatMap(a=>a.type==="text"?[a.text]:[]).join(`
10
- `))}}}),await Promise.all([H(e,U),z(e,{protocol:G,apiVersion:V,id:"local",setup(r){r.addSelectionProvider((n,a)=>t.register(n.request.query,n.matches,n.complete,a.cwd,a.signal,{...n.request,regex:!1},n.refresh)),r.addResolver({resolver:he(t),priority:-10}),r.addResolver({resolver:me(),priority:-10}),r.addResolver({resolver:de(t),fallback:!0}),r.describe(["Local queries try literal terms first, then unquoted terms as regex when no literal results exist, then separate words for ordinary multi-word queries. Quoted terms stay literal. Boolean conditions stay intact across fallback. Uppercase AND/OR, infix NOT, ||, and space-separated | are Boolean operators; unspaced | and regex groups/classes belong to regex terms. Parentheses containing Boolean operators group Boolean conditions. regex:<pattern> forces regex-only matching; files:<pattern> searches file paths: glob patterns use *, **, ?, character classes and braces; other queries use case-insensitive subsequence matching. Slash-containing globs match cwd-relative paths; basename globs match at any depth.","The result says when a query was broadened. Empty or unknown prefixes are searched as plain text. A recognized prefixed query returns its own results or error; it does not silently become a text search.","SEARCH#HASH:N:line selects one containing line; :match selects its exact match. :all:line selects all unique containing lines and :all:match selects all matches. Read returns containing lines for both forms. A SEARCH resource can be used as a read path or mutation path/anchor; omit the file path for an all-selection spanning files.","Use SEARCH references exactly as returned to select the matching content. A single-result reference becomes stale when its file changes; obtain a fresh result before using it again. An :all reference refreshes the original query when a selected file changes. Search compacts noisy files when the detail limit is exceeded; narrow the query to that file to see individual matches. Compaction does not remove complete :all selections."].join(`
11
- `))}}),W(e,{protocol:_,apiVersion:j,id:"search-anchors",setup(r){r.tool("replace").addHandler({stage:"text-post-edit",async handler(n){if(!n.result||typeof n.result!="object"||!("kind"in n.result)||n.result.kind!=="completed"||!n.input||typeof n.input!="object")return n;let a=n.input,o=await t.observeAfterEdit([a.path,a.start,a.end],n.signal);return o.length===0?n:{...n,metadata:{...n.metadata,searchObservations:o}}}}),r.addAnchorResolver({resolver:t.anchorResolver(),resources:t.resourceResolver(),kind:B,type:"auxiliary",describeInPrompt:!1})}})])}c(Be,"registerTextSearch");export{fe as createSearchSessionId,Be as default};
1
+ import{a,b,c,d,e,f,g}from"./chunk-7UGNGK7Y.js";import"./chunk-EI7MMDWY.js";export{b as SEARCH_API_VERSION,c as SEARCH_CORE_READY_EVENT,d as SEARCH_PLUGIN_REGISTER_EVENT,a as SEARCH_PROTOCOL,e as isSearchCoreReady,f as isSearchPlugin,g as isSearchPluginRegistrationRequest};
package/dist/entry-49.js CHANGED
@@ -1 +1 @@
1
- import{d as a,e as b,f as c,g as d,h as e}from"./chunk-P7XO5CIP.js";import"./chunk-GUTQ3PWL.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{e as SearchSessionStore,d as SearchSnapshotChangedError,c as allocateSearchSessionId,a as createSearchSessionId,b as createSearchSessionIdentity};
1
+ import"./chunk-ROXXK6TW.js";import{a}from"./chunk-KII2JQC5.js";import"./chunk-EI7MMDWY.js";export{a as searchSchema};
package/dist/entry-50.js CHANGED
@@ -1 +1,6 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u}from"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{a as TextAnchor,b as attachTextAnchorRenderer,p as createTextContentConverter,m as createTextDocument,c as getTextAnchorRenderer,i as getTextSourceLine,g as isTextAnchorRecoveryOutcome,f as isTextAnchorResolutionAttempt,e as isTextAnchorResolver,k as isTextLinePresenter,l as isTextPresenterRegistration,s as isTextTargetResolutionAttempt,q as isTextualMediaType,o as renderPresentedTextDocument,h as renderPresentedTextRows,d as renderTextAnchor,n as renderTextDocument,u as restoreText,t as storeText,r as textFromAgentContent,j as withTextSourceLine};
1
+ import{e as G,f as H,g as V}from"./chunk-GIRAEVUJ.js";import{e as C,f as D}from"./chunk-T7I2VX3J.js";import{c as $}from"./chunk-YHUTTZC6.js";import{a as L}from"./chunk-KII2JQC5.js";import{a as N,b as M,c as O,d as j,g as F}from"./chunk-7UGNGK7Y.js";import{a as o}from"./chunk-EI7MMDWY.js";import{keyText as ae}from"@earendil-works/pi-coding-agent";import{Text as I}from"@earendil-works/pi-tui";import ce from"node:os";function W(){let e=[],r,s=new Map,i=new Map,l=new Map,u=new Map,f=Promise.resolve(),c={registerPlugin(n){if(n.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let a=u.get(n.id);if(a!==void 0)return a;let h=f.then(async()=>{let g=[],p=[],m,R,y=[],d={addSelectionProvider(t){if(m!==void 0||r!==void 0)throw new Error("Search selection provider is already registered");m=t},registerSelection(t,w){if(r===void 0)throw new Error("Search selections are unavailable. Enable the shared search selection plugin.");return r(t,w)},addResolver(t){X(t),g.push(t)},addAction(t){Z(t),p.push(t)},describe(t){if(R!==void 0)throw new Error(`Plugin ${n.id} provides more than one description`);R=q(t)},addPromptGuideline(t){y.push(q(t))},search:o((t,w,T)=>c.execute(t,w,T),"search"),runAction(t,w){return c.runAction(t.reference,t.capability,t.resolverId,t.input,w)}};await n.setup(d);let S=new Set(e.map(({registration:t})=>t.resolver.id));for(let t of g){if(S.has(t.resolver.id))throw new Error(`Search resolver ${t.resolver.id} is already registered`);S.add(t.resolver.id)}for(let t of p){let w=b(t.resolverId,t.capability);if(s.has(w)||p.some(T=>T!==t&&b(T.resolverId,T.capability)===w))throw new Error(`Search action ${w} is already registered`)}for(let t of g)e.push({pluginId:n.id,registration:t,order:e.length});m!==void 0&&(r=m);for(let t of p)s.set(b(t.resolverId,t.capability),t);R!==void 0&&l.set(n.id,R),y.length>0&&i.set(n.id,y)});return u.set(n.id,h),f=h.catch(()=>{}),h.catch(()=>{u.delete(n.id)}),h},async waitForPendingPlugins(){await Promise.all(u.values())},async execute(n,a,h="agent"){if(n.query.trim().length===0)return P("INVALID_REQUEST","Search query must not be empty");let g=[...e].sort((y,d)=>+(y.registration.fallback===!0)-+(d.registration.fallback===!0)||(y.registration.priority??0)-(d.registration.priority??0)||y.order-d.order),p=/^[a-z][\w-]*:\s*$/iu.test(n.query),m=/^[a-z][\w-]*:/iu.test(n.query);for(let y of g){if(p&&!y.registration.fallback)continue;let d=y.registration.resolver,S;try{a.signal?.throwIfAborted(),S=await d.tryResolve(n,a)}catch(t){return P("RESOLVE_FAILED",x(t,`Resolver ${d.id} failed`),d.id,t)}if(!ee(S))return P("INVALID_RESOLVER_RESULT",`Resolver ${d.id} returned an invalid result`,d.id);if(S.kind!=="not-handled"){if(S.kind==="failed")return P("RESOLVE_FAILED",x(S.error,`Resolver ${d.id} failed`),d.id,S.error);try{let t=await d.format(S.payload,a);return re(t)?{content:y.registration.fallback&&m?[{type:"text",text:p?"Search fallback: empty protocol query; searched the original text.":"Search fallback: unhandled protocol query; searched the original text."},...t.content]:t.content,details:{resolverId:d.id,payload:t.details},...h==="script"&&{script:{resolverId:d.id,data:S.payload,details:t.details}},...t.usage!==void 0&&{usage:t.usage}}:P("FORMAT_FAILED",`Resolver ${d.id} formatter returned an invalid result`,d.id)}catch(t){return P("FORMAT_FAILED",x(t,`Resolver ${d.id} formatter failed`),d.id,t)}}}let R=`No search resolver handled ${n.query}`;return G(P("NO_RESOLVER",R),R)},runAction(n,a,h,g,p){let m=s.get(b(h,a));if(m===void 0)throw new Error(`Search reference does not support ${a}`);return m.execute(n,g,p)},renderDescriptions(){return[...l.values()].flatMap(n=>{let a=J(n);return a===void 0?[]:[a]})},renderPromptGuidelines(){return[...i.values()].flat().flatMap(n=>{let a=J(n);return a===void 0?[]:[a]})},renderer(n){return e.find(({registration:a})=>a.resolver.id===n)?.registration.resolver.renderResult}};return c}o(W,"createSearchCore");function X(e){if(!A(e)||!A(e.resolver))throw new TypeError("Invalid search resolver registration");let r=e.resolver;if(typeof r.id!="string"||r.id.trim().length===0||typeof r.tryResolve!="function"||typeof r.format!="function")throw new TypeError("Invalid search resolver registration");if(e.priority!==void 0&&(typeof e.priority!="number"||!Number.isFinite(e.priority)))throw new TypeError("Invalid search resolver priority")}o(X,"assertResolver");function Z(e){if(!A(e)||typeof e.resolverId!="string"||e.resolverId.trim().length===0||typeof e.capability!="string"||e.capability.trim().length===0||typeof e.execute!="function")throw new TypeError("Invalid search action registration")}o(Z,"assertAction");function A(e){return typeof e=="object"&&e!==null}o(A,"isRecord");function ee(e){if(typeof e!="object"||e===null||!("kind"in e))return!1;let r=e.kind;return r==="not-handled"||r==="resolved"&&"payload"in e||r==="failed"&&"error"in e}o(ee,"isAttempt");function re(e){return typeof e=="object"&&e!==null&&Array.isArray(e.content)}o(re,"isAgentToolResult");function P(e,r,s,i){return{content:[{type:"text",text:r}],details:{failure:{code:e,message:r,...s!==void 0&&{resolverId:s},...i!==void 0&&{cause:i}}}}}o(P,"failure");function q(e){if(typeof e=="function")return e;if(typeof e!="string"||e.trim().length===0)throw new TypeError("Search description must not be empty");return e.trim()}o(q,"normalizeDescriptionSource");function J(e){let r=typeof e=="function"?e():e;if(r!==void 0){if(typeof r!="string"||r.trim().length===0)throw new TypeError("Search description must not be empty");return r.trim()}}o(J,"renderDescription");function b(e,r){return`${e}:${r}`}o(b,"actionKey");function x(e,r){return!(e instanceof Error)||e.message.trim().length===0?r:e instanceof SyntaxError?e.message:`${r}: ${e.message}`}o(x,"messageFor");import{readFile as te}from"node:fs/promises";import ne from"node:os";import E from"node:path";var oe=3e4;function z(e=process.env,r=ne.homedir(),s=process.cwd()){let i=e.PI_CODING_AGENT_DIR?.trim(),l=i===void 0||i.length===0?E.join(r,".pi","agent"):E.resolve(i);return{globalPath:E.join(l,"pi-agent-ide","search.json"),projectPath:E.resolve(s,".pi","pi-agent-ide","search.json")}}o(z,"resolveSearchConfigPaths");async function _(e){let[r,s]=await Promise.all([U(e.globalPath),U(e.projectPath)]),i=s!==void 0?s:r;return{timeoutMs:i===void 0?oe:i}}o(_,"loadSearchConfig");async function U(e){let r;try{r=await te(e,"utf8")}catch(u){if(ie(u))return;throw new Error(`Cannot read Pi Agent IDE search config at ${e}`,{cause:u})}let s;try{s=JSON.parse(r)}catch(u){throw new Error(`Invalid JSON in Pi Agent IDE search config at ${e}`,{cause:u})}if(!K(s))throw new TypeError(`Pi Agent IDE search config at ${e} must be a JSON object`);let i=Object.keys(s).find(u=>u!=="timeoutMs");if(i!==void 0)throw new TypeError(`Pi Agent IDE search config at ${e} contains unknown key ${i}`);let l=s.timeoutMs;if(l==null)return l;if(typeof l!="number"||!Number.isSafeInteger(l)||l<=0)throw new TypeError(`timeoutMs must be a positive integer or null in Pi Agent IDE search config at ${e}`);return l}o(U,"readTimeout");function ie(e){return K(e)&&e.code==="ENOENT"}o(ie,"isMissingFile");function K(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}o(K,"isRecord");var B=Symbol("search-timeout"),k=class extends Error{static{o(this,"SearchTimeoutError")}constructor(r){super(r),this.name="SearchTimeoutError"}};async function Q(e,r,s){if(e===null)return s(r);let i=new AbortController,l=r===void 0?i.signal:AbortSignal.any([r,i.signal]),u,f=new Promise(c=>{u=setTimeout(()=>{c(B),i.abort()},e)});try{let c=await Promise.race([s(l),f]);if(c===B)throw new k(`Search timed out after ${se(e)}. Try a smaller path scope.`);return c}finally{clearTimeout(u)}}o(Q,"runWithSearchTimeout");function se(e){if(e%1e3!==0)return`${String(e)}ms`;let r=e/1e3;return`${String(r)} ${r===1?"second":"seconds"}`}o(se,"formatDuration");function de(e,r){let s=[...e.path===void 0?[]:[{text:`in ${e.path}`,color:"accent",underline:!0,truncate:"start"}],...e.include===void 0?[]:[{text:`include ${e.include}`}],...e.exclude===void 0?[]:[{text:`exclude ${e.exclude}`}],...e.caseSensitive===!0?[{text:"case sensitive"}]:[],...e.wholeWord===!0?[{text:"whole word"}]:[],...e.limit===void 0?[]:[{text:`limit ${String(e.limit)}`}]];return{tool:"search",primary:{text:JSON.stringify(e.query),color:"accent",truncate:"end"},qualifiers:s,details:ue(e),expanded:r}}o(de,"searchCallModel");function le(e){return e==="full"||e==="disabled"?e:"compact"}o(le,"parsePresentation");async function Y(e,r){let s=le(r?.preferences["ui.search"]);D(e,[await C({id:"search-code",description:"Text search, AST patterns, symbols, graphs, and semantic rename",triggers:[{tool:"search"},{tool:"read",resourcePrefixes:["ast:","symbol:","symbols:","graph:"]}]})]);let i=W(),l=new H,u=e.events.on(j,f=>{if(!F(f))throw new Error("Invalid pi-agent-search plugin registration request");f.accept(i.registerPlugin(f.plugin))});e.on("session_shutdown",u),e.registerTool(V({name:"search",label:"search",description:"Use search to locate workspace text, file paths, and code structures.",promptSnippet:"Search files and text with literals or regular expressions, plus syntax trees and language symbols",get promptGuidelines(){return["Use the narrowest useful search query and scope; broaden when needed.",...i.renderPromptGuidelines()]},parameters:L,renderCall(f,c,n){let a=n.expanded?"full":s;return a==="disabled"?new I(c.fg("toolTitle","search"),0,0):$(n.lastComponent,de(f,a==="full"),c)},renderResult(f,c,n,a){let h=c.expanded?"full":s;if(h==="disabled"&&!a.isError&&!c.isPartial)return new I(n.fg("success","\u2713 search"),0,0);c={...c,expanded:h==="full"};let g=f.details,p=g?.resolverId===void 0?void 0:i.renderer(g.resolverId);if(p!==void 0){let m={...f,details:g?.payload};return p(m,c,n,a)}return fe(f,c,n)},async execute(f,c,n,a,h){let g=await _(z(process.env,ce.homedir(),h.cwd));return Q(g.timeoutMs,n,async p=>(await i.waitForPendingPlugins(),i.execute(c,{cwd:h.cwd,...p!==void 0&&{signal:p},...a!==void 0&&{onUpdate:o(m=>{a(m)},"onUpdate")}})))}},l)),e.events.emit(O,{protocol:N,apiVersion:M}),await i.waitForPendingPlugins()}o(Y,"registerSearchCore");function ue(e){return[{label:"query",value:JSON.stringify(e.query)},...v("path",e.path),...v("include",e.include),...v("exclude",e.exclude),...v("caseSensitive",e.caseSensitive===void 0?void 0:String(e.caseSensitive)),...v("wholeWord",e.wholeWord===void 0?void 0:String(e.wholeWord)),...v("limit",e.limit===void 0?void 0:String(e.limit))]}o(ue,"searchCallDetails");function v(e,r){return r===void 0?[]:[{label:e,value:r}]}o(v,"optionalDetail");function fe(e,r,s){let i=e.content.flatMap(f=>f.type==="text"?[f.text]:[]).join(`
2
+ `),l=r.expanded?i:i.split(`
3
+ `).slice(0,8).join(`
4
+ `),u=!r.expanded&&i.split(`
5
+ `).length>8?`
6
+ ${s.fg("dim",`${ae("app.tools.expand")} to expand`)}`:"";return new I(`${s.fg("muted",l)}${u}`,0,0)}o(fe,"fallbackResult");export{Y as default};
package/dist/entry-51.js CHANGED
@@ -1 +1,10 @@
1
- import{a as d}from"./chunk-L7JMDDSD.js";import{a as s,b as l,c}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import{a as i}from"./chunk-5VSE5X5R.js";import{a as t}from"./chunk-EI7MMDWY.js";var o=class extends i{static{t(this,"ConstantTextAnchor")}constructor(n,r){super(n,r)}};function p(){return{id:"file-position",description:"`begin` and `end` select the first and last existing lines.",renderFull(e){return e},renderCompact(e){return e==="begin"?"file start":"file end"},tryResolve(e,n){return Promise.resolve(a(e,n))}}}t(p,"createConstantTextAnchorResolver");function a(e,n){return e!=="begin"&&e!=="end"?{kind:"not-handled"}:n.lines.length===0?{kind:"failed",error:new Error(`${e} cannot resolve in an empty file`)}:{kind:"resolved",anchor:new o(e,e==="begin"?1:n.lines.length)}}t(a,"resolveConstantAnchor");async function T(e){await d(e,{protocol:s,apiVersion:l,id:"text-anchor-constant",setup(r){r.addAnchorResolver({resolver:p(),kind:c,type:"constant"})}})}t(T,"registerConstantTextAnchors");export{T as default};
1
+ import{a as S,b as _,c as I,d as X,h as j}from"./chunk-P7XO5CIP.js";import"./chunk-GUTQ3PWL.js";import{a as D,b as L}from"./chunk-CEX3VOJ7.js";import{a as N,b as x,c as k}from"./chunk-7WCZOO5I.js";import{a as E}from"./chunk-MGCHOGQD.js";import{a as w,b as A}from"./chunk-T6LX2RX5.js";import{a as q}from"./chunk-L7JMDDSD.js";import{a as C,b as $,d as T}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import{a as H}from"./chunk-ZTYWHL2F.js";import{a as O,b as P}from"./chunk-7UGNGK7Y.js";import"./chunk-5VSE5X5R.js";import{d as b,e as v}from"./chunk-N34ATN52.js";import"./chunk-ZC65Z3CK.js";import{a as u}from"./chunk-EI7MMDWY.js";var M={protocol:w,apiVersion:1,id:"search-text",setup(e){e.addSetupCheck({id:"ripgrep",async inspect(r){let t=S(r.env.PI_CODING_AGENT_DIR);return await b(t,r.cwd,r.env)?{}:{actions:[{id:"ripgrep-unavailable",message:"Local search is unavailable because ripgrep was not found"}]}}}),e.addCheck({id:"ripgrep",title:"Local search",async run(r){let t=r.env.PI_CODING_AGENT_DIR,n=S(t),o=await v(n,["--version"],r.cwd,r.env);return[o.ok?{status:"pass",message:"ripgrep is available",detail:o.detail}:{status:"fail",message:"ripgrep is not available",detail:o.detail}]}})}};import G from"node:path";import{spawn as U}from"node:child_process";import y from"node:path";function B(e,r,t,n){let o=r.limit??100,i=["--files","--hidden","--no-config","--no-ignore-parent","--glob","!.git/**"];for(let l of F(r.include))i.push("--glob",l);for(let l of F(r.exclude))i.push("--glob",`!${l}`);return r.path!==void 0&&i.push(r.path),new Promise((l,c)=>{let a=U(S(),i,{cwd:t,stdio:["ignore","pipe","pipe"]}),f="",h="";a.stdout.setEncoding("utf8"),a.stderr.setEncoding("utf8"),a.stdout.on("data",s=>f+=s),a.stderr.on("data",s=>h+=s);let p=u(()=>{a.kill("SIGTERM")},"abort");n?.addEventListener("abort",p,{once:!0}),a.once("error",c),a.once("close",s=>{if(n?.removeEventListener("abort",p),n?.aborted===!0){c(n.reason instanceof Error?n.reason:new Error("File search aborted"));return}if(s!==0&&s!==1){c(new Error(h.trim()||`rg exited with code ${String(s)}`));return}let m=f.split(`
2
+ `).filter(Boolean).map(d=>y.relative(t,y.resolve(t,d))).filter(d=>K(d,e)).sort((d,g)=>d.localeCompare(g));l({files:m.slice(0,o),complete:m.length<=o})})})}u(B,"searchFiles");function F(e){return e?.split(",").map(r=>r.trim()).filter(Boolean)??[]}u(F,"splitGlobs");function K(e,r){if(/[*?[\]{}]/u.test(r)){let t=r.replace(/^\.\//u,"");return y.matchesGlob(t.includes("/")?e:y.basename(e),t)}return Y(e,r)}u(K,"matchFile");function Y(e,r){if(r.length===0)return!0;let t=0,n=e.toLowerCase();for(let o of r.toLowerCase()){if(t=n.indexOf(o,t),t===-1)return!1;t+=1}return!0}u(Y,"fuzzyMatch");function z(e){return W("text",e,_)}u(z,"createTextResolver");function J(e){return W("regex",e,r=>r.query.startsWith("regex:")?{...r,query:r.query.slice(6),regex:!0}:void 0)}u(J,"createRegexResolver");function Q(){return{id:"files",async tryResolve(e,r){if(!e.query.startsWith("files:"))return{kind:"not-handled"};let t=e.query.slice(6).trim(),n=await B(t,e,r.cwd,r.signal);return{kind:"resolved",payload:{query:t,...n}}},format(e){let r=e;return{content:[{type:"text",text:[r.complete?`${String(r.files.length)} files`:`${String(r.files.length)}+ files (limit reached)`,...r.files].join(`
3
+ `)}],details:{query:r.query,files:r.files,complete:r.complete}}}}}u(Q,"createFileResolver");function W(e,r,t){return{id:e,async tryResolve(n,o){let i=t(n);if(i===void 0)return{kind:"not-handled"};let l=await I(i,o.cwd,o.signal);return{kind:"resolved",payload:{request:{...n,query:l.query},...l,recipe:{...i,originalQuery:n.query}}}},async format(n,o){let i=n;if(i.matches.length===0)return{content:[{type:"text",text:[...i.notices,"No matches found."].join(`
4
+ `)}],details:x(i.request.query,[],i.complete,o.cwd)};let l=i.request.limit??50,c=await r.registerIfCurrent(i.request.query,i.matches,i.complete,o.cwd,o.signal,i.recipe),a=c??{query:i.request.query,matches:i.matches,complete:i.complete};return{content:[{type:"text",text:[...i.notices,Z(a,o.cwd,l,c!==void 0)].join(`
5
+ `)}],details:x(a.query,a.matches,a.complete,o.cwd,c?.id,l)}},renderResult:L}}u(W,"createMatchResolver");function Z(e,r,t,n=!0){let o=new Set(e.matches.map(p=>p.source)).size,i=e.matches.length,l=`${String(i)}${e.complete?"":"+"} ${V(i,"match","matches")} in ${String(o)} ${V(o,"file","files")}`,c=n?e.complete?`SEARCH#${e.id}:all:line / SEARCH#${e.id}:all:match \u2014 ${l}`:`${l} (limit reached; no all anchors were registered)`:`${l} (files changed during search; results shown without anchors)`,a=n?["Anchors: SEARCH#HASH:N:line (line), SEARCH#HASH:N:match (exact match), SEARCH#HASH:all:line (each unique containing line), SEARCH#HASH:all:match (every exact match)",c]:[c],f=new Map(e.matches.map((p,s)=>[p,s+1])),h=N(e.matches,t);for(let[p,s]of h.files.entries()){p>0&&a.push("");let m=re(s.source,r);if(s.kind==="compacted"){a.push(`${m}: ${String(s.matchCount)} matches across ${String(s.uniqueLineCount)} unique line texts (compacted)`);for(let d of s.groups)a.push(` \xD7${String(d.matchCount)} ${te(d.text)}`);s.groups.length<s.uniqueLineCount&&a.push(` \u2026 ${String(s.uniqueLineCount-s.groups.length)} more unique line texts`),a.push(` Search again with path: ${JSON.stringify(m)} and a narrower query to see individual matches.`);continue}for(let d of s.matches){let g=f.get(d);if(g===void 0)continue;let R=`${m}:${String(d.lineNumber)}:${String(d.startColumn+1)}-${String(d.endColumn+1)}`;a.push(n?`${R} SEARCH#${e.id}:${String(g)}:line SEARCH#${e.id}:${String(g)}:match`:R,` ${ee(d)}`)}}return a.join(`
6
+ `)}u(Z,"formatSearchSession");function ee(e){let t=Math.max(0,e.startColumn-64),n=Math.min(e.lineText.length,e.endColumn+64);return`${t>0?"\u2026":""}${e.lineText.slice(t,e.startColumn)}\u27E6${e.lineText.slice(e.startColumn,e.endColumn)}\u27E7${e.lineText.slice(e.endColumn,n)}${n<e.lineText.length?"\u2026":""}`}u(ee,"previewMatch");function te(e){return`${e.slice(0,129)}${e.length>129?"\u2026":""}`}u(te,"previewLine");function re(e,r){let t=G.relative(r,e);return t.length>0&&!t.startsWith("..")&&!G.isAbsolute(t)?t:e}u(re,"displaySource");function V(e,r,t){return e===1?r:t}u(V,"plural");async function ne(e){let r=new j;e.on("tool_result",async(t,n)=>{if(t.toolName!=="replace"||t.isError||typeof t.details!="object"||t.details===null)return;let o="metadata"in t.details?t.details.metadata:void 0,i=o&&typeof o=="object"&&"searchObservations"in o?o.searchObservations:void 0,l=Array.isArray(i)?i:await r.observeAfterEdit([t.input.path,t.input.start,t.input.end],n.signal);if(l.length!==0)return{content:[...t.content,{type:"text",text:["Original search observed after editing (not task validation):",...l.map(c=>{let{query:a,fallbacks:f,...h}=c.scope;return[`SEARCH#${c.sessionId}: ${JSON.stringify(c.query)}`,`Scope and options: ${JSON.stringify(h)}`,c.error===void 0?`Matches: ${c.matches}${c.complete===!0?"; complete search.":"+; incomplete search, lower bound only."}`:`Search failed: ${c.error}. Applied edits remain applied.`,...c.notices??[]].join(`
7
+ `)})].join(`
8
+ `)}],details:{...t.details,searchObservations:l}}}),e.on("tool_result",t=>{if(t.toolName!=="search"||typeof t.details!="object"||t.details===null)return;let n=t.details;if(k(n.payload))return{details:{...n,payload:D(n.payload,t.content.flatMap(o=>o.type==="text"?[o.text]:[]).join(`
9
+ `))}}}),await Promise.all([E(e,M),H(e,{protocol:O,apiVersion:P,id:"local",setup(t){t.addSelectionProvider((n,o)=>r.register(n.request.query,n.matches,n.complete,o.cwd,o.signal,{...n.request,regex:!1},n.refresh)),t.addResolver({resolver:J(r),priority:-10}),t.addResolver({resolver:Q(),priority:-10}),t.addResolver({resolver:z(r),fallback:!0}),t.describe(["Local queries try literal terms first, then unquoted terms as regex when no literal results exist, then separate words for ordinary multi-word queries. Quoted terms stay literal. Boolean conditions stay intact across fallback. Uppercase AND/OR, infix NOT, ||, and space-separated | are Boolean operators; unspaced | and regex groups/classes belong to regex terms. Parentheses containing Boolean operators group Boolean conditions. regex:<pattern> forces regex-only matching; files:<pattern> searches file paths: glob patterns use *, **, ?, character classes and braces; other queries use case-insensitive subsequence matching. Slash-containing globs match cwd-relative paths; basename globs match at any depth.","The result says when a query was broadened. Empty or unknown prefixes are searched as plain text. A recognized prefixed query returns its own results or error; it does not silently become a text search.","SEARCH#HASH:N:line selects one containing line; :match selects its exact match. :all:line selects all unique containing lines and :all:match selects all matches. Read returns containing lines for both forms. A SEARCH resource can be used as a read path or mutation path/anchor; omit the file path for an all-selection spanning files.","Use SEARCH references exactly as returned to select the matching content. A single-result reference becomes stale when its file changes; obtain a fresh result before using it again. An :all reference refreshes the original query when a selected file changes. Search compacts noisy files when the detail limit is exceeded; narrow the query to that file to see individual matches. Compaction does not remove complete :all selections."].join(`
10
+ `))}}),q(e,{protocol:C,apiVersion:$,id:"search-anchors",setup(t){t.tool("replace").addHandler({stage:"text-post-edit",async handler(n){if(!n.result||typeof n.result!="object"||!("kind"in n.result)||n.result.kind!=="completed"||!n.input||typeof n.input!="object")return n;let o=n.input,i=await r.observeAfterEdit([o.path,o.start,o.end],n.signal);return i.length===0?n:{...n,metadata:{...n.metadata,searchObservations:i}}}}),t.addAnchorResolver({resolver:r.anchorResolver(),resources:r.resourceResolver(),kind:T,type:"auxiliary",describeInPrompt:!1})}})])}u(ne,"registerTextSearch");export{X as createSearchSessionId,ne as default};
package/dist/entry-52.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c}from"./chunk-ZM4L5AGN.js";import"./chunk-GUTQ3PWL.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as createExactTextAnchorResolver,c as findExactTextMatches,b as resolveExactTextAnchor};
1
+ import{d as a,e as b,f as c,g as d,h as e}from"./chunk-P7XO5CIP.js";import"./chunk-GUTQ3PWL.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{e as SearchSessionStore,d as SearchSnapshotChangedError,c as allocateSearchSessionId,a as createSearchSessionId,b as createSearchSessionIdentity};
package/dist/entry-53.js CHANGED
@@ -1 +1 @@
1
- import{a as m}from"./chunk-ZM4L5AGN.js";import"./chunk-GUTQ3PWL.js";import{a as f}from"./chunk-L7JMDDSD.js";import{a as c,b as u,d as s}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import{a as i}from"./chunk-EI7MMDWY.js";import{readFileSync as z}from"node:fs";import w from"node:path";function x(e){let n=b(e.settings,"recovery.exactText");n!==void 0&&p(n,["fuzzyEnabled","threshold","exactCandidateLimit","fuzzyCandidateLimit","maxFileSizeMiB","maxQuerySizeKiB","seedLimit","blockLineVariance"],"recovery.exactText");let t=i(o=>n===void 0?void 0:n[o],"value");return{fuzzyEnabled:g(t("fuzzyEnabled"),"fuzzyEnabled")??!0,threshold:d(t("threshold"),"threshold",0,1)??.8,exactCandidateLimit:a(t("exactCandidateLimit"),"exactCandidateLimit",1,100)??20,fuzzyCandidateLimit:a(t("fuzzyCandidateLimit"),"fuzzyCandidateLimit",1,20)??5,maxFileSizeMiB:d(t("maxFileSizeMiB"),"maxFileSizeMiB",.01,100)??20,maxQuerySizeKiB:d(t("maxQuerySizeKiB"),"maxQuerySizeKiB",.01,4096)??1024,seedLimit:a(t("seedLimit"),"seedLimit",1,10)??3,blockLineVariance:a(t("blockLineVariance"),"blockLineVariance",0,10)??2,contextLines:e.contextLines,timeoutMs:e.timeoutMs}}i(x,"parseExactTextRecoveryConfig");function l(e,n){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError(`${n} must be an object`);return Object.fromEntries(Object.entries(e))}i(l,"objectRecord");function b(e,n){return e===void 0?void 0:l(e,n)}i(b,"optionalObject");function p(e,n,t){let o=new Set(n),r=Object.keys(e).find(y=>!o.has(y));if(r!==void 0)throw new TypeError(`${t} contains unknown key ${r}`)}i(p,"assertKeys");function g(e,n){if(e===void 0||typeof e=="boolean")return e;throw new TypeError(`${n} must be a boolean`)}i(g,"optionalBoolean");function d(e,n,t,o){if(e!==void 0){if(typeof e!="number"||!Number.isFinite(e)||e<t||e>o)throw new RangeError(`${n} must be between ${t} and ${o}`);return e}}i(d,"optionalNumber");function a(e,n,t,o){let r=d(e,n,t,o);if(r!==void 0&&!Number.isInteger(r))throw new TypeError(`${n} must be an integer`);return r}i(a,"optionalInteger");async function E(e){await f(e,{protocol:c,apiVersion:u,id:"text-anchor-exact",setup(t){t.addAnchorResolver({resolver:m(x(t.recoveryConfig("exactText"))),kind:s,type:"auxiliary",describeInPrompt:!1,priority:1e4})}})}i(E,"registerExactTextAnchor");export{E as default};
1
+ import{b as a,c as b}from"./chunk-CEX3VOJ7.js";import"./chunk-7WCZOO5I.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{b as SearchResultPanel,a as renderSearchResult};
package/dist/entry-54.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e}from"./chunk-QDST6VIU.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{b as createLineHashAnchor,e as createLineHashAnchorResolver,c as formatLineHashAnchor,a as hashLine,d as renderLineHashLines};
1
+ import{b as a,c as b}from"./chunk-7WCZOO5I.js";import"./chunk-EI7MMDWY.js";export{a as createSearchToolDetails,b as isSearchToolDetails};
package/dist/entry-55.js CHANGED
@@ -1 +1 @@
1
- import{b as x,e as T}from"./chunk-QDST6VIU.js";import{a as P}from"./chunk-L7JMDDSD.js";import{a as u,b as h,c as f}from"./chunk-O6LE42GK.js";import{a as l}from"./chunk-6CZO43OH.js";import{a as d,b as m}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{i as p}from"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";function g(){return{id:"line-hash",present(n,o){let i=n.lines.map(e=>{let t=o.resolvedBy==="filesystem"?{lineNumber:e.lineNumber,content:e.content}:p(e);return t===void 0?void 0:{anchor:x(t.lineNumber,t.content),lineNumber:t.lineNumber}}),c=Math.max(0,...i.map(e=>e?.anchor.value.length??0)),r=Math.max(0,...i.map(e=>String(e?.lineNumber??"").length)),E=n.lines.map((e,t)=>{let s=i[t];return s===void 0?e:{...e,anchors:[...new Set([...e.anchors??[],s.anchor.value])],presentation:{...e.presentation,prefix:`${s.anchor.value.padStart(c)}|${e.presentation?.prefix??""}`,compactPrefix:e.presentation?.compactPrefix??`${String(s.lineNumber).padStart(r)} \u2502 `}}});return{...n,lines:E}}}}a(g,"createLineHashPresenter");async function R(n){let o=g(),i={protocol:d,apiVersion:m,id:"text-anchor-line-hash",setup(r){r.addView({view:"anchors",presenter:o}),r.describe('views: ["anchors"] \u2014 LINE#HASH references for editing individual source lines.')}},c={protocol:u,apiVersion:h,id:"text-anchor-line-hash",setup(r){r.addAnchorResolver({resolver:T(),kind:f,type:"major"}),r.addTextPresenter({presenter:o})}};await Promise.all([l(n,i),P(n,c)])}a(R,"registerLineHashTextAnchor");export{R as default};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u}from"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{a as TextAnchor,b as attachTextAnchorRenderer,p as createTextContentConverter,m as createTextDocument,c as getTextAnchorRenderer,i as getTextSourceLine,g as isTextAnchorRecoveryOutcome,f as isTextAnchorResolutionAttempt,e as isTextAnchorResolver,k as isTextLinePresenter,l as isTextPresenterRegistration,s as isTextTargetResolutionAttempt,q as isTextualMediaType,o as renderPresentedTextDocument,h as renderPresentedTextRows,d as renderTextAnchor,n as renderTextDocument,u as restoreText,t as storeText,r as textFromAgentContent,j as withTextSourceLine};
package/dist/entry-56.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-6EYWFBNG.js";import{g as a,i as b}from"./chunk-3XJ3KDPZ.js";import"./chunk-ITSNK5YG.js";import"./chunk-22CLOM2D.js";import"./chunk-NNCZYO4Q.js";import"./chunk-526E364R.js";import"./chunk-YHUTTZC6.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as createApplyCallRenderer,b as createApplyResultRenderer};
1
+ import{a as d}from"./chunk-L7JMDDSD.js";import{a as s,b as l,c}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import{a as i}from"./chunk-5VSE5X5R.js";import{a as t}from"./chunk-EI7MMDWY.js";var o=class extends i{static{t(this,"ConstantTextAnchor")}constructor(n,r){super(n,r)}};function p(){return{id:"file-position",description:"`begin` and `end` select the first and last existing lines.",renderFull(e){return e},renderCompact(e){return e==="begin"?"file start":"file end"},tryResolve(e,n){return Promise.resolve(a(e,n))}}}t(p,"createConstantTextAnchorResolver");function a(e,n){return e!=="begin"&&e!=="end"?{kind:"not-handled"}:n.lines.length===0?{kind:"failed",error:new Error(`${e} cannot resolve in an empty file`)}:{kind:"resolved",anchor:new o(e,e==="begin"?1:n.lines.length)}}t(a,"resolveConstantAnchor");async function T(e){await d(e,{protocol:s,apiVersion:l,id:"text-anchor-constant",setup(r){r.addAnchorResolver({resolver:p(),kind:c,type:"constant"})}})}t(T,"registerConstantTextAnchors");export{T as default};
package/dist/entry-57.js CHANGED
@@ -0,0 +1 @@
1
+ import{a,b,c}from"./chunk-ZM4L5AGN.js";import"./chunk-GUTQ3PWL.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as createExactTextAnchorResolver,c as findExactTextMatches,b as resolveExactTextAnchor};
package/dist/entry-58.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-L7JMDDSD.js";import"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{a as connectTextEditorPlugin};
1
+ import{a as m}from"./chunk-ZM4L5AGN.js";import"./chunk-GUTQ3PWL.js";import{a as f}from"./chunk-L7JMDDSD.js";import{a as c,b as u,d as s}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import{a as i}from"./chunk-EI7MMDWY.js";import{readFileSync as z}from"node:fs";import w from"node:path";function x(e){let n=b(e.settings,"recovery.exactText");n!==void 0&&p(n,["fuzzyEnabled","threshold","exactCandidateLimit","fuzzyCandidateLimit","maxFileSizeMiB","maxQuerySizeKiB","seedLimit","blockLineVariance"],"recovery.exactText");let t=i(o=>n===void 0?void 0:n[o],"value");return{fuzzyEnabled:g(t("fuzzyEnabled"),"fuzzyEnabled")??!0,threshold:d(t("threshold"),"threshold",0,1)??.8,exactCandidateLimit:a(t("exactCandidateLimit"),"exactCandidateLimit",1,100)??20,fuzzyCandidateLimit:a(t("fuzzyCandidateLimit"),"fuzzyCandidateLimit",1,20)??5,maxFileSizeMiB:d(t("maxFileSizeMiB"),"maxFileSizeMiB",.01,100)??20,maxQuerySizeKiB:d(t("maxQuerySizeKiB"),"maxQuerySizeKiB",.01,4096)??1024,seedLimit:a(t("seedLimit"),"seedLimit",1,10)??3,blockLineVariance:a(t("blockLineVariance"),"blockLineVariance",0,10)??2,contextLines:e.contextLines,timeoutMs:e.timeoutMs}}i(x,"parseExactTextRecoveryConfig");function l(e,n){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError(`${n} must be an object`);return Object.fromEntries(Object.entries(e))}i(l,"objectRecord");function b(e,n){return e===void 0?void 0:l(e,n)}i(b,"optionalObject");function p(e,n,t){let o=new Set(n),r=Object.keys(e).find(y=>!o.has(y));if(r!==void 0)throw new TypeError(`${t} contains unknown key ${r}`)}i(p,"assertKeys");function g(e,n){if(e===void 0||typeof e=="boolean")return e;throw new TypeError(`${n} must be a boolean`)}i(g,"optionalBoolean");function d(e,n,t,o){if(e!==void 0){if(typeof e!="number"||!Number.isFinite(e)||e<t||e>o)throw new RangeError(`${n} must be between ${t} and ${o}`);return e}}i(d,"optionalNumber");function a(e,n,t,o){let r=d(e,n,t,o);if(r!==void 0&&!Number.isInteger(r))throw new TypeError(`${n} must be an integer`);return r}i(a,"optionalInteger");async function E(e){await f(e,{protocol:c,apiVersion:u,id:"text-anchor-exact",setup(t){t.addAnchorResolver({resolver:m(x(t.recoveryConfig("exactText"))),kind:s,type:"auxiliary",describeInPrompt:!1,priority:1e4})}})}i(E,"registerExactTextAnchor");export{E as default};
package/dist/entry-59.js CHANGED
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e}from"./chunk-QDST6VIU.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{b as createLineHashAnchor,e as createLineHashAnchorResolver,c as formatLineHashAnchor,a as hashLine,d as renderLineHashLines};
package/dist/entry-60.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-U22JNO6N.js";import"./chunk-EI7MMDWY.js";export{a as isTextEditHandlerRegistration};
1
+ import{b as x,e as T}from"./chunk-QDST6VIU.js";import{a as P}from"./chunk-L7JMDDSD.js";import{a as u,b as h,c as f}from"./chunk-O6LE42GK.js";import{a as l}from"./chunk-6CZO43OH.js";import{a as d,b as m}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{i as p}from"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";function g(){return{id:"line-hash",present(n,o){let i=n.lines.map(e=>{let t=o.resolvedBy==="filesystem"?{lineNumber:e.lineNumber,content:e.content}:p(e);return t===void 0?void 0:{anchor:x(t.lineNumber,t.content),lineNumber:t.lineNumber}}),c=Math.max(0,...i.map(e=>e?.anchor.value.length??0)),r=Math.max(0,...i.map(e=>String(e?.lineNumber??"").length)),E=n.lines.map((e,t)=>{let s=i[t];return s===void 0?e:{...e,anchors:[...new Set([...e.anchors??[],s.anchor.value])],presentation:{...e.presentation,prefix:`${s.anchor.value.padStart(c)}|${e.presentation?.prefix??""}`,compactPrefix:e.presentation?.compactPrefix??`${String(s.lineNumber).padStart(r)} \u2502 `}}});return{...n,lines:E}}}}a(g,"createLineHashPresenter");async function R(n){let o=g(),i={protocol:d,apiVersion:m,id:"text-anchor-line-hash",setup(r){r.addView({view:"anchors",presenter:o}),r.describe('views: ["anchors"] \u2014 LINE#HASH references for editing individual source lines.')}},c={protocol:u,apiVersion:h,id:"text-anchor-line-hash",setup(r){r.addAnchorResolver({resolver:T(),kind:f,type:"major"}),r.addTextPresenter({presenter:o})}};await Promise.all([l(n,i),P(n,c)])}a(R,"registerLineHashTextAnchor");export{R as default};
package/dist/entry-61.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{b as TEXT_EDITOR_API_VERSION,e as TEXT_EDITOR_CORE_READY_EVENT,f as TEXT_EDITOR_PLUGIN_REGISTER_EVENT,a as TEXT_EDITOR_PROTOCOL,c as TEXT_POSITION_ANCHOR_KIND,d as TEXT_SEARCH_ANCHOR_KIND,h as isResourceResolverRegistration,i as isTextAnchorResolverRegistration,j as isTextAnchorResourceResolutionAttempt,k as isTextEditorCoreReady,l as isTextEditorPlugin,m as isTextEditorPluginRegistrationRequest,g as isTextEditorToolId};
1
+ import"./chunk-6EYWFBNG.js";import{g as a,i as b}from"./chunk-YT42LKFV.js";import"./chunk-ITSNK5YG.js";import"./chunk-FA6BKC5Y.js";import"./chunk-NNCZYO4Q.js";import"./chunk-VCTK4JSN.js";import"./chunk-YHUTTZC6.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as createApplyCallRenderer,b as createApplyResultRenderer};
package/dist/entry-62.js CHANGED
@@ -1 +0,0 @@
1
- import{a}from"./chunk-MBUXFKIW.js";import"./chunk-EI7MMDWY.js";export{a as formatStaleAnchorMessage};
package/dist/entry-63.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-GUTQ3PWL.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as TextSelectionAnchor};
1
+ import{a}from"./chunk-L7JMDDSD.js";import"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{a as connectTextEditorPlugin};
package/dist/entry-64.js CHANGED
@@ -1 +0,0 @@
1
- import{a,d as b,g as c,h as d,i as e,j as f,k as g,l as h,m as i}from"./chunk-FEDVTZJG.js";import"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{c as TEXT_EDITOR_POST_EDIT_REGISTER_EVENT,a as afterPostEditScope,i as connectTextEditorPostEditHandler,b as hasDeferredPostEdit,e as isDiffStatusContribution,d as isFormattingContribution,h as isTextMutationResultContributionData,f as isTextPostEditHandlerRegistration,g as isTextPostEditHandlerRegistrationRequest};
package/dist/entry-65.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-4U2GUKNJ.js";import{b as a,c as b,d as c}from"./chunk-ITSNK5YG.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{c as FileMutationResult,b as FileRange,a as computeChangedRanges};
1
+ import{a}from"./chunk-U22JNO6N.js";import"./chunk-EI7MMDWY.js";export{a as isTextEditHandlerRegistration};
package/dist/entry-66.js CHANGED
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{b as TEXT_EDITOR_API_VERSION,e as TEXT_EDITOR_CORE_READY_EVENT,f as TEXT_EDITOR_PLUGIN_REGISTER_EVENT,a as TEXT_EDITOR_PROTOCOL,c as TEXT_POSITION_ANCHOR_KIND,d as TEXT_SEARCH_ANCHOR_KIND,h as isResourceResolverRegistration,i as isTextAnchorResolverRegistration,j as isTextAnchorResourceResolutionAttempt,k as isTextEditorCoreReady,l as isTextEditorPlugin,m as isTextEditorPluginRegistrationRequest,g as isTextEditorToolId};
package/dist/entry-67.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c}from"./chunk-AWXVJ5AC.js";import"./chunk-EI7MMDWY.js";export{b as assertTextMutationToolRegistration,a as isMutationAnchorValue,c as mutationSource};
1
+ import{a}from"./chunk-MBUXFKIW.js";import"./chunk-EI7MMDWY.js";export{a as formatStaleAnchorMessage};
package/dist/entry-68.js CHANGED
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-GUTQ3PWL.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as TextSelectionAnchor};
package/dist/entry-69.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c}from"./chunk-YHADTHQM.js";import"./chunk-EI7MMDWY.js";export{c as clearLastResolvedResource,b as getLastResolvedResource,a as rememberLastResolvedResource};
1
+ import{a,d as b,g as c,h as d,i as e,j as f,k as g,l as h,m as i}from"./chunk-FEDVTZJG.js";import"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{c as TEXT_EDITOR_POST_EDIT_REGISTER_EVENT,a as afterPostEditScope,i as connectTextEditorPostEditHandler,b as hasDeferredPostEdit,e as isDiffStatusContribution,d as isFormattingContribution,h as isTextMutationResultContributionData,f as isTextPostEditHandlerRegistration,g as isTextPostEditHandlerRegistrationRequest};
package/dist/entry-70.js CHANGED
@@ -1 +1 @@
1
- import{a as b,b as c}from"./chunk-4LUW26BX.js";import{c as a}from"./chunk-GIRAEVUJ.js";import"./chunk-YHUTTZC6.js";import"./chunk-EI7MMDWY.js";export{a as getToolCallInterception,c as registerToolCallAnnotationSink,b as registerToolCallInterceptor};
1
+ import"./chunk-4U2GUKNJ.js";import{b as a,c as b,d as c}from"./chunk-ITSNK5YG.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{c as FileMutationResult,b as FileRange,a as computeChangedRanges};
package/dist/entry-71.js CHANGED
@@ -1 +0,0 @@
1
- import{a}from"./chunk-J34VKQGJ.js";import"./chunk-EI7MMDWY.js";export{a as isTextEditorToolRendererRegistration};