pi-agent-ide 0.6.4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (395) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +2 -2
  3. package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
  4. package/dist/{chunk-QEJGED4V.js → chunk-3HYXQ4YA.js} +1 -1
  5. package/dist/chunk-3JO7QFIL.js +1 -0
  6. package/dist/{chunk-5J43L2RL.js → chunk-4NIFBFFR.js} +1 -1
  7. package/dist/{chunk-BSICWXMH.js → chunk-64M3SQPG.js} +1 -1
  8. package/dist/{chunk-3BBJZSMS.js → chunk-7LD2OQH3.js} +1 -1
  9. package/dist/chunk-7LZKOHH2.js +1 -0
  10. package/dist/chunk-AJRIASPQ.js +2 -0
  11. package/dist/chunk-EAZGN5ND.js +7 -0
  12. package/dist/{chunk-GIRAEVUJ.js → chunk-F5YZG77W.js} +1 -1
  13. package/dist/chunk-FK42RSF4.js +1 -0
  14. package/dist/{chunk-WJTHY6AG.js → chunk-FXNKMNSJ.js} +1 -1
  15. package/dist/chunk-GBLKIB6O.js +2 -0
  16. package/dist/{chunk-KUPHNMUK.js → chunk-KBP3QUDT.js} +1 -1
  17. package/dist/{chunk-VBICI5YA.js → chunk-KR36BT5E.js} +1 -1
  18. package/dist/chunk-OE7QVAI2.js +5 -0
  19. package/dist/chunk-PNU3E7IO.js +3 -0
  20. package/dist/chunk-PS2B6THP.js +3 -0
  21. package/dist/{chunk-HPUAIWIH.js → chunk-PYPPV2F5.js} +1 -1
  22. package/dist/{chunk-FUG2TEKI.js → chunk-QFTBY67N.js} +2 -2
  23. package/dist/chunk-S5LXX32D.js +28 -0
  24. package/dist/chunk-SQKAXYIR.js +2 -0
  25. package/dist/chunk-VCGNVTXQ.js +1 -0
  26. package/dist/chunk-XYS4FSCC.js +12 -0
  27. package/dist/{chunk-FBOW7XOV.js → chunk-YRF7OATP.js} +1 -1
  28. package/dist/entry-11.js +1 -1
  29. package/dist/entry-13.js +1 -1
  30. package/dist/entry-14.js +1 -1
  31. package/dist/entry-15.js +1 -1
  32. package/dist/entry-17.js +1 -1
  33. package/dist/entry-25.js +1 -1
  34. package/dist/entry-26.js +1 -1
  35. package/dist/entry-28.js +1 -1
  36. package/dist/entry-29.js +1 -1
  37. package/dist/entry-30.js +1 -1
  38. package/dist/entry-31.js +13 -11
  39. package/dist/entry-33.js +1 -1
  40. package/dist/entry-37.js +6 -6
  41. package/dist/entry-42.js +1 -1
  42. package/dist/entry-44.js +1 -1
  43. package/dist/entry-45.js +13 -13
  44. package/dist/entry-46.js +1 -1
  45. package/dist/entry-49.js +1 -1
  46. package/dist/entry-50.js +3 -6
  47. package/dist/entry-51.js +11 -9
  48. package/dist/entry-52.js +1 -1
  49. package/dist/entry-53.js +1 -1
  50. package/dist/entry-54.js +1 -1
  51. package/dist/entry-56.js +1 -1
  52. package/dist/entry-58.js +1 -1
  53. package/dist/entry-60.js +1 -1
  54. package/dist/entry-61.js +0 -1
  55. package/dist/entry-62.js +1 -0
  56. package/dist/entry-63.js +0 -1
  57. package/dist/entry-64.js +1 -0
  58. package/dist/entry-65.js +1 -1
  59. package/dist/entry-66.js +1 -1
  60. package/dist/entry-67.js +1 -1
  61. package/dist/entry-68.js +1 -1
  62. package/dist/entry-69.js +1 -1
  63. package/dist/entry-70.js +1 -1
  64. package/dist/entry-71.js +0 -1
  65. package/dist/entry-72.js +1 -0
  66. package/dist/entry-73.js +0 -1
  67. package/dist/entry-74.js +1 -0
  68. package/dist/entry-75.js +1 -1
  69. package/dist/entry-76.js +1 -1
  70. package/dist/entry-77.js +67 -1
  71. package/dist/entry-78.js +14 -325
  72. package/dist/entry-79.js +2 -18
  73. package/dist/entry-80.js +1 -2
  74. package/dist/entry-81.js +1 -1
  75. package/dist/entry-82.js +5 -1
  76. package/dist/entry-83.js +3 -5
  77. package/dist/entry-84.js +1 -3
  78. package/dist/entry-85.js +1 -1
  79. package/dist/entry-86.js +1 -1
  80. package/dist/pi-agent-ide.js +5 -5
  81. package/docs/agent-guides/editing.md +20 -4
  82. package/docs/agent-guides/git-changes.md +1 -1
  83. package/docs/agent-guides/read-resources.md +9 -1
  84. package/docs/agent-guides/search-code.md +38 -1
  85. package/docs/agent-guides/select-code.md +194 -0
  86. package/docs/configuration.md +12 -17
  87. package/docs/development.md +2 -1
  88. package/docs/releases.md +1 -1
  89. package/docs/research/apply-native-capability-matrix.md +174 -0
  90. package/docs/research/apply-read-latency.md +2 -0
  91. package/docs/research/lpt-393-fuzzy-results/file.json +152 -0
  92. package/docs/research/lpt-393-fuzzy-results/repo.json +122 -0
  93. package/docs/research/lpt-393-search-fuzzy-fallback.md +97 -0
  94. package/docs/research/native-codemode-batch-decision.md +2 -0
  95. package/docs/research/native-codemode-batching.md +1 -1
  96. package/docs/structured-results.md +32 -5
  97. package/docs/tools.md +6 -2
  98. package/docs/user-hooks.md +1 -1
  99. package/node_modules/pi-agent-doctor/package.json +1 -1
  100. package/node_modules/pi-agent-documentation/package.json +1 -1
  101. package/node_modules/pi-agent-filesystem/package.json +7 -7
  102. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  103. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  104. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  105. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  106. package/node_modules/pi-agent-ide-ast/package.json +15 -10
  107. package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
  108. package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
  109. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +5 -1
  110. package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +204 -0
  111. package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
  112. package/node_modules/pi-agent-ide-ast/src/extension.ts +4 -2
  113. package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
  114. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +107 -21
  115. package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +104 -0
  116. package/node_modules/pi-agent-ide-ast/src/select-schema.ts +384 -0
  117. package/node_modules/pi-agent-ide-ast/src/selection-region.ts +41 -0
  118. package/node_modules/pi-agent-ide-ast/src/source-text.ts +92 -0
  119. package/node_modules/pi-agent-ide-ast/src/text-selection.ts +214 -0
  120. package/node_modules/pi-agent-ide-ast/src/tool-select.ts +251 -0
  121. package/node_modules/pi-agent-ide-changes/index.ts +2 -18
  122. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  123. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
  124. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
  125. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  126. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  127. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  128. package/node_modules/pi-agent-ide-lsp/index.ts +2 -2
  129. package/node_modules/pi-agent-ide-lsp/package.json +9 -9
  130. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
  131. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
  132. package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
  133. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
  134. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
  135. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +88 -45
  136. package/node_modules/pi-agent-image/package.json +2 -2
  137. package/node_modules/pi-agent-invariant/package.json +1 -1
  138. package/node_modules/pi-agent-pdf/package.json +2 -2
  139. package/node_modules/pi-agent-read/package.json +7 -7
  140. package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
  141. package/node_modules/pi-agent-read/src/api/tools/read.ts +4 -0
  142. package/node_modules/pi-agent-read/src/core/extension.ts +11 -0
  143. package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
  144. package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +2 -0
  145. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +8 -1
  146. package/node_modules/pi-agent-resource/package.json +1 -1
  147. package/node_modules/pi-agent-resource/src/index.ts +10 -0
  148. package/node_modules/pi-agent-resource/src/result-targets.ts +233 -0
  149. package/node_modules/pi-agent-search/package.json +5 -5
  150. package/node_modules/pi-agent-search/src/api/fuzzy.ts +208 -0
  151. package/node_modules/pi-agent-search/src/api/presentation.ts +68 -0
  152. package/node_modules/pi-agent-search/src/api/search-parameters.ts +9 -3
  153. package/node_modules/pi-agent-search/src/api/search-scope.ts +22 -0
  154. package/node_modules/pi-agent-search/src/api/search.ts +28 -0
  155. package/node_modules/pi-agent-search/src/api/structured-result.ts +69 -14
  156. package/node_modules/pi-agent-search/src/core/extension.ts +56 -16
  157. package/node_modules/pi-agent-search/src/core/search-core.ts +9 -1
  158. package/node_modules/pi-agent-search-text/index.ts +3 -1
  159. package/node_modules/pi-agent-search-text/package.json +7 -6
  160. package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +164 -0
  161. package/node_modules/pi-agent-search-text/src/resolvers.ts +161 -30
  162. package/node_modules/pi-agent-search-text/src/scoped-search.ts +103 -0
  163. package/node_modules/pi-agent-search-text/src/search-backend.ts +104 -17
  164. package/node_modules/pi-agent-search-text/src/search-renderer.ts +89 -292
  165. package/node_modules/pi-agent-search-text/src/search-result.ts +77 -0
  166. package/node_modules/pi-agent-search-text/src/search-session.ts +96 -11
  167. package/node_modules/pi-agent-text/package.json +2 -2
  168. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  169. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  170. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  171. package/node_modules/pi-agent-text-editor/index.ts +0 -5
  172. package/node_modules/pi-agent-text-editor/package.json +26 -31
  173. package/node_modules/pi-agent-text-editor/runtime/entry-77.js +1 -0
  174. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
  175. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
  176. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
  177. package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
  178. package/node_modules/pi-agent-text-editor/src/core/extension.ts +12 -2
  179. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
  180. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +1 -1
  181. package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
  182. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +1 -1
  183. package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
  184. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +199 -19
  185. package/node_modules/pi-agent-text-editor/src/core/result-input.ts +22 -0
  186. package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
  187. package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
  188. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +109 -11
  189. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
  190. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
  191. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +211 -223
  192. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
  193. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
  194. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
  195. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
  196. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
  197. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
  198. package/node_modules/pi-agent-text-editor-renderer/index.ts +1 -72
  199. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  200. package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
  201. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
  202. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  203. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  204. package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +1 -0
  205. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  206. package/node_modules/pi-agent-tool-ui/src/index.ts +7 -0
  207. package/node_modules/pi-agent-tool-ui/src/result-panel.ts +298 -0
  208. package/node_modules/pi-agent-web/index.ts +3 -0
  209. package/node_modules/pi-agent-web/package.json +8 -8
  210. package/node_modules/pi-agent-web/runtime/entry-82.js +2 -0
  211. package/node_modules/pi-agent-web/src/search.ts +111 -2
  212. package/node_modules/pi-agent-web-html/package.json +3 -3
  213. package/node_modules/pi-agent-web-image/package.json +4 -4
  214. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  215. package/node_modules/pi-agent-web-text/package.json +4 -4
  216. package/package.json +35 -36
  217. package/src/composite/module-labels.ts +1 -1
  218. package/src/composite/preferences.ts +0 -5
  219. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  220. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  221. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  222. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  223. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  224. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +3 -0
  225. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
  226. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  227. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +2 -0
  228. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  229. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  230. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  231. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +2 -0
  232. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +111 -2
  233. package/src/extensions/pi-agent-read/package.json +7 -7
  234. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
  235. package/src/extensions/pi-agent-read/src/api/tools/read.ts +4 -0
  236. package/src/extensions/pi-agent-read/src/core/extension.ts +11 -0
  237. package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
  238. package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +2 -0
  239. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +8 -1
  240. package/src/extensions/pi-agent-search/package.json +5 -5
  241. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +3 -1
  242. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -6
  243. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +164 -0
  244. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +161 -30
  245. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +103 -0
  246. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +104 -17
  247. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +89 -292
  248. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +77 -0
  249. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +96 -11
  250. package/src/extensions/pi-agent-search/src/api/fuzzy.ts +208 -0
  251. package/src/extensions/pi-agent-search/src/api/presentation.ts +68 -0
  252. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +9 -3
  253. package/src/extensions/pi-agent-search/src/api/search-scope.ts +22 -0
  254. package/src/extensions/pi-agent-search/src/api/search.ts +28 -0
  255. package/src/extensions/pi-agent-search/src/api/structured-result.ts +69 -14
  256. package/src/extensions/pi-agent-search/src/core/extension.ts +56 -16
  257. package/src/extensions/pi-agent-search/src/core/search-core.ts +9 -1
  258. package/src/extensions/pi-agent-text-editor/index.ts +0 -5
  259. package/src/extensions/pi-agent-text-editor/package.json +26 -31
  260. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  261. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  262. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  263. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +1 -72
  264. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  265. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +2 -0
  266. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
  267. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
  268. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  269. package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +1 -0
  270. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
  271. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
  272. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
  273. package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
  274. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +12 -2
  275. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
  276. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +1 -1
  277. package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
  278. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +1 -1
  279. package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
  280. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +199 -19
  281. package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +22 -0
  282. package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
  283. package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
  284. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +109 -11
  285. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
  286. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
  287. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +211 -223
  288. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
  289. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
  290. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
  291. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
  292. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
  293. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
  294. package/src/pi-agent-ide.ts +0 -6
  295. package/src/plugins/pi-agent-ide-ast/package.json +15 -10
  296. package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
  297. package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
  298. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +5 -1
  299. package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +204 -0
  300. package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
  301. package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -2
  302. package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
  303. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +107 -21
  304. package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +104 -0
  305. package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +384 -0
  306. package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +41 -0
  307. package/src/plugins/pi-agent-ide-ast/src/source-text.ts +92 -0
  308. package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +214 -0
  309. package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +251 -0
  310. package/src/plugins/pi-agent-ide-changes/index.ts +2 -18
  311. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  312. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
  313. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
  314. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  315. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  316. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  317. package/src/plugins/pi-agent-ide-lsp/index.ts +2 -2
  318. package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
  319. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
  320. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
  321. package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
  322. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
  323. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
  324. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +88 -45
  325. package/src/plugins/pi-agent-ide-terminal/src/search.ts +10 -36
  326. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +1 -1
  327. package/src/plugins/pi-agent-ide-vision/index.ts +19 -0
  328. package/dist/chunk-2P2OGO3G.js +0 -2
  329. package/dist/chunk-6EYWFBNG.js +0 -0
  330. package/dist/chunk-7AVXUV4A.js +0 -7
  331. package/dist/chunk-7WCZOO5I.js +0 -1
  332. package/dist/chunk-BAYETTZZ.js +0 -16
  333. package/dist/chunk-BVK5A7ED.js +0 -28
  334. package/dist/chunk-F7NVAC4Q.js +0 -0
  335. package/dist/chunk-FZBCKIJJ.js +0 -1
  336. package/dist/chunk-I5JLCFUX.js +0 -1
  337. package/dist/chunk-MIZAFRDR.js +0 -1
  338. package/dist/chunk-PJPA5EEE.js +0 -2
  339. package/dist/chunk-PXWDDBBC.js +0 -0
  340. package/dist/chunk-TQZBVOTT.js +0 -5
  341. package/dist/chunk-VWW3RLUX.js +0 -12
  342. package/dist/chunk-YHUTTZC6.js +0 -2
  343. package/dist/chunk-ZODCBFBL.js +0 -2
  344. package/dist/entry-87.js +0 -1
  345. package/docs/agent-guides/apply.md +0 -333
  346. package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
  347. package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -159
  348. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
  349. package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
  350. package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
  351. package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
  352. package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
  353. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +0 -276
  354. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
  355. package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
  356. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
  357. package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +0 -137
  358. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
  359. package/node_modules/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
  360. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
  361. package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
  362. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
  363. package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +0 -1
  364. package/node_modules/pi-agent-web-text/runtime/entry-87.js +0 -2
  365. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-87.js +0 -2
  366. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +0 -2
  367. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
  368. package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +0 -2
  369. package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
  370. package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -159
  371. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
  372. package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
  373. package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
  374. package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
  375. package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
  376. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +0 -276
  377. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
  378. package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
  379. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
  380. package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +0 -137
  381. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
  382. package/src/extensions/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
  383. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
  384. package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
  385. /package/node_modules/{pi-agent-text-editor → pi-agent-text-editor-renderer}/runtime/entry-78.js +0 -0
  386. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
  387. /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-81.js +0 -0
  388. /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-83.js +0 -0
  389. /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
  390. /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
  391. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
  392. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
  393. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
  394. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
  395. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
package/dist/entry-45.js CHANGED
@@ -1,18 +1,18 @@
1
- import{e as z,f as xe,g as Te}from"./chunk-GIRAEVUJ.js";import{e as se,f as ae}from"./chunk-T7I2VX3J.js";import{a as he,c as we,d as Y,e as B,f as j,g as G,h as H,i as q,j as ve}from"./chunk-FZBCKIJJ.js";import{a as ce,c as fe,d as pe}from"./chunk-BSICWXMH.js";import"./chunk-YHUTTZC6.js";import{a as V,b as U,c as de,d as ue,g as le}from"./chunk-OBNING2A.js";import{b as ge,c as Re,k as me,n as ye}from"./chunk-2P2OGO3G.js";import{m as ne,o as oe,s as ie}from"./chunk-ZPT5D4VP.js";import{a as A}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Text as $e}from"@earendil-works/pi-tui";import{DEFAULT_MAX_BYTES as qe,DEFAULT_MAX_LINES as ze,formatSize as W,truncateHead as We}from"@earendil-works/pi-coding-agent";var I=qe,M=ze;async function Q(e,t,o,r){let n=r?.originLine,i=e.content.length===1?e.content[0]:void 0;if(i?.type!=="text")return e;let d=We(i.text,{maxBytes:I,maxLines:M});if(d.truncated){let R=o===void 0?void 0:await o(i.text),h=d.firstLineExceedsLimit?Xe(i.text,e.details,t):Ye(d,e.details,t,n),f=R===void 0?h:Ke(h,R);return{...e,content:[{...i,text:Pe(d.content,f)}],details:{...Ze(e.details,d),...R!==void 0&&{temporarySource:R}}}}let a=Je(e.details,t,n);return a===void 0?e:{...e,content:[{...i,text:Pe(i.text,a)}]}}s(Q,"limitReadOutput");function Ke(e,t){return`${e.slice(0,-1)} Full output: ${t}. Available until this runtime is disposed.]`}s(Ke,"appendTemporarySource");function Xe(e,t,o){let r=e.split(/\r\n|\r|\n/u,1)[0]??"",n=W(Buffer.byteLength(r,"utf8")),i=J(t,o);return`[${i===void 0?"First output line":`Line ${i}`} is ${n}, exceeds ${W(I)} limit. Use a source-specific tool to read this line in smaller byte ranges.]`}s(Xe,"oversizedFirstLineNotice");function Ye(e,t,o,r){let n=Qe(e,t,o);if(n!==void 0&&n.endLine<n.totalLines){let d=e.truncatedBy==="bytes"?` (${W(e.maxBytes)} limit)`:"",a=Ee(n.endLine+1,r);return`[Showing lines ${n.startLine}-${n.endLine} of ${n.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(Ye,"truncatedOutputNotice");function Qe(e,t,o){let r=t.totalLines,n=J(t,o);if(r===void 0||r===0||n===void 0||e.outputLines===0)return;let d=(t.endLine===void 0||t.endLine<n?r:t.endLine)-n+1,a=Math.min(e.outputLines,d);return{startLine:n,endLine:n+a-1,totalLines:r}}s(Qe,"shownSourceRange");function Je(e,t,o){if(t.limit===void 0||e.totalLines===void 0||e.totalLines===0)return;let r=J(e,t);if(r===void 0)return;let n=e.endLine===void 0||e.endLine<r?r:e.endLine+1;return n>e.totalLines?void 0:`[${e.totalLines-n+1} more lines in source. Use offset=${Ee(n,o)} to continue.]`}s(Je,"explicitLimitNotice");function Ee(e,t){return t===void 0?e:e-t+1}s(Ee,"continuationOffset");function J(e,t){if(e.startLine!==void 0&&e.startLine>0)return e.startLine;if(e.totalLines===void 0||e.totalLines===0)return;let o=t.offset===void 0?1:Math.trunc(t.offset);return o<0?Math.max(1,e.totalLines+o+1):Math.max(1,o)}s(J,"sourceStartLine");function Ze(e,t){return{...e,...e.lines!==void 0&&{lines:e.lines.slice(0,t.outputLines)},truncation:t}}s(Ze,"truncatedDetails");function Pe(e,t){return e.length===0?t:`${e}
1
+ import{e as K,f as Pe,g as Ee}from"./chunk-F5YZG77W.js";import{e as ae,f as de}from"./chunk-T7I2VX3J.js";import{a as we,c as xe,d as J,e as H,f as G,g as z,h as q,i as W,j as Te}from"./chunk-7LZKOHH2.js";import{a as fe,c as pe,d as ge}from"./chunk-64M3SQPG.js";import{a as V,b as U,c as ue,d as le,g as ce}from"./chunk-OBNING2A.js";import"./chunk-PS2B6THP.js";import{I as ve,b as Re,c as me,k as ye,n as he}from"./chunk-SQKAXYIR.js";import{m as oe,o as ie,s as se}from"./chunk-ZPT5D4VP.js";import{a as b}from"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";import{readFile as Ke}from"node:fs/promises";function Le(e){return async t=>{let r=t.state;if(r?.contentKind!=="text"||r.resolvedBy!=="filesystem")return{kind:"continue",context:t};let n;try{n=await Ke(r.source,{encoding:"utf8",signal:t.resolverContext.signal})}catch{return t.resolverContext.signal?.throwIfAborted(),{kind:"continue",context:t}}if(n!==r.text.content)return{kind:"continue",context:t};let o=t.sourceTarget===void 0?void 0:e.resolve(t.sourceTarget,t.resolverContext.cwd),i=o?.targets.filter(s=>s.source===r.source);return i?.some(s=>s.expectedContent!==n)?{kind:"continue",context:t}:{kind:"continue",context:t,transform(s){let a=s.script;if(s.isError||a?.kind!=="text"||a.source!==r.source||!a.lines.every(u=>{let m=r.text.lines[u.lineNumber-1];return m?.content===u.content&&m.lineEnding===u.lineEnding}))return s;let p=a.lines[0],y=a.lines.at(-1),f=p===void 0||y===void 0?n.length===0?{start:{lineNumber:1,column:0},end:{lineNumber:1,column:0}}:void 0:{start:{lineNumber:p.lineNumber,column:0},end:y.lineEnding.length>0?{lineNumber:y.lineNumber+1,column:0}:{lineNumber:y.lineNumber,column:y.content.length},linewise:!0},c=f===void 0?[]:i===void 0?[f]:i.flatMap(u=>u.ranges.flatMap(m=>Xe(m,f))),g=e.register(c.length===0?[]:[{source:r.source,expectedContent:n,ranges:c}],t.resolverContext.cwd,o?.complete??!0);return{...s,script:{...a,target:g}}}}}}d(Le,"createReadResultTargetHandler");function B(e,t){return e.lineNumber-t.lineNumber||e.column-t.column}d(B,"comparePosition");function Xe(e,t){let r=B(e.start,t.start)>=0?e.start:t.start,n=B(e.end,t.end)<=0?e.end:t.end;return B(r,n)>0||B(r,n)===0&&B(e.start,e.end)!==0?[]:[{start:r,end:n}]}d(Xe,"intersectRange");import{Text as De}from"@earendil-works/pi-tui";import{DEFAULT_MAX_BYTES as Ye,DEFAULT_MAX_LINES as Qe,formatSize as X,truncateHead as Je}from"@earendil-works/pi-coding-agent";var I=Ye,j=Qe;async function Z(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 s=Je(i.text,{maxBytes:I,maxLines:j});if(s.truncated){let p=r===void 0?void 0:await r(i.text),y=s.firstLineExceedsLimit?et(i.text,e.details,t):tt(s,e.details,t,o),f=p===void 0?y:Ze(y,p);return{...e,content:[{...i,text:Se(s.content,f)}],details:{...ot(e.details,s),...p!==void 0&&{temporarySource:p}}}}let a=nt(e.details,t,o);return a===void 0?e:{...e,content:[{...i,text:Se(i.text,a)}]}}d(Z,"limitReadOutput");function Ze(e,t){return`${e.slice(0,-1)} Full output: ${t}. Available until this runtime is disposed.]`}d(Ze,"appendTemporarySource");function et(e,t,r){let n=e.split(/\r\n|\r|\n/u,1)[0]??"",o=X(Buffer.byteLength(n,"utf8")),i=ee(t,r);return`[${i===void 0?"First output line":`Line ${i}`} is ${o}, exceeds ${X(I)} limit. Use a source-specific tool to read this line in smaller byte ranges.]`}d(et,"oversizedFirstLineNotice");function tt(e,t,r,n){let o=rt(e,t,r);if(o!==void 0&&o.endLine<o.totalLines){let s=e.truncatedBy==="bytes"?` (${X(e.maxBytes)} limit)`:"",a=be(o.endLine+1,n);return`[Showing lines ${o.startLine}-${o.endLine} of ${o.totalLines}${s}. Use offset=${a} to continue.]`}let i=e.truncatedBy==="lines"?`${e.maxLines} line limit`:`${X(e.maxBytes)} limit`;return`[Output truncated: showing ${e.outputLines} of ${e.totalLines} rendered lines (${i}). Use a smaller line range to read this source.]`}d(tt,"truncatedOutputNotice");function rt(e,t,r){let n=t.totalLines,o=ee(t,r);if(n===void 0||n===0||o===void 0||e.outputLines===0)return;let s=(t.endLine===void 0||t.endLine<o?n:t.endLine)-o+1,a=Math.min(e.outputLines,s);return{startLine:o,endLine:o+a-1,totalLines:n}}d(rt,"shownSourceRange");function nt(e,t,r){if(t.limit===void 0||e.totalLines===void 0||e.totalLines===0)return;let n=ee(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=${be(o,r)} to continue.]`}d(nt,"explicitLimitNotice");function be(e,t){return t===void 0?e:e-t+1}d(be,"continuationOffset");function ee(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)}d(ee,"sourceStartLine");function ot(e,t){return{...e,...e.lines!==void 0&&{lines:e.lines.slice(0,t.outputLines)},truncation:t}}d(ot,"truncatedDetails");function Se(e,t){return e.length===0?t:`${e}
2
2
 
3
- ${t}`}s(Pe,"appendNotice");function Se(e,t,o,r){if(!ot(e))return{content:e,source:t,resolvedBy:o,preserveTruncatedOutput:r.preserveTruncatedOutput,textMode:r.textMode,contentKind:"other"};let n=e[0].text;return{content:e,source:t,resolvedBy:o,preserveTruncatedOutput:r.preserveTruncatedOutput,textMode:r.textMode,contentKind:"text",text:ne(t,n)}}s(Se,"createReadState");function K(e,t,o){if(e.contentKind!=="text"){if(t.offset!==void 0||t.limit!==void 0)return x({code:"UNSUPPORTED_RANGE",source:e.source,resolverId:e.resolvedBy,message:"Line ranges require textual content"});let h=tt(e.content);return{script:{kind:"native",source:e.source,blocks:e.content},content:h.content,details:{...Le(e),...h.unsupportedContentBlocks!==void 0&&{unsupportedContentBlocks:h.unsupportedContentBlocks}}}}let r=e.text.lines.length,n=rt(t,r,o?.originLine),i=e.text.lines.slice(n.startIndex,n.endIndex),d=e.textMode==="final"?et(i,n.endIndex<r):oe({...e.text,lines:i.map((h,f)=>({...h,lineEnding:f===i.length-1&&n.endIndex<r?"":h.lineEnding}))}),a=e.content[0],R=[{type:"text",text:d,...a.textSignature!==void 0&&{textSignature:a.textSignature}}];return{script:{kind:"text",...e.text.references===void 0?{}:{references:e.text.references},source:e.source,content:i.map(h=>h.content+h.lineEnding).join(""),lines:i,startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:r},content:R,details:{...Le(e),startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:r,lines:i}}}s(K,"projectReadState");function et(e,t){return e.map((o,r)=>`${o.content}${r===e.length-1&&t?"":o.lineEnding}`).join("")}s(et,"renderFinalTextLines");function x(e){return{content:[{type:"text",text:[`${e.code}: ${e.message}`,...e.candidates?.length?["","Possible matches:",...e.candidates.map(t=>`- ${JSON.stringify(t.path)}`),"","Retry read with an exact candidate path."]:[]].join(`
4
- `)}],details:{failure:e},isError:!0}}s(x,"failureResult");function Le(e){return{source:e.source,resolvedBy:e.resolvedBy}}s(Le,"readDetails");function tt(e){let t=[],o=[];for(let[n,i]of e.entries()){if(i.type!=="custom"){t.push(i);continue}o.push({index:n,kind:i.kind}),t.push({type:"text",text:`[unsupported_content_block kind=${i.kind} index=${n}]`})}let r=o[0];return{content:t,...r!==void 0&&{unsupportedContentBlocks:[r,...o.slice(1)]}}}s(tt,"projectAgentContent");function rt(e,t,o){let r=e.offset===void 0?1:Math.trunc(e.offset),n=nt(r,t,o),i=e.limit===void 0?t:Math.max(0,Math.trunc(e.limit));return{startIndex:Math.min(t,n-1),endIndex:Math.min(t,n-1+i)}}s(rt,"resolveTextRange");function nt(e,t,o){if(o===void 0)return e<0?Math.max(1,t+e+1):Math.max(1,e);let r=e<0?o+e:o+Math.max(1,e)-1;return Math.max(1,r)}s(nt,"anchoredStartLine");function ot(e){return e.length===1&&e[0].type==="text"}s(ot,"isSingleTextContent");import{randomUUID as it}from"node:crypto";import{mkdir as st,mkdtemp as at,readFile as dt,rm as ut,writeFile as lt}from"node:fs/promises";import{tmpdir as ct}from"node:os";import be 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??ct(),this.resolver={id:"temp",tryResolve:s(o=>Promise.resolve(this.#a(o)),"tryResolve")}}async save(t){if(this.#e!==void 0)throw new Error("Temporary resource store is closed");let o=this.#i(t);this.#n.add(o);try{return await o}finally{this.#n.delete(o)}}dispose(){return this.#e??=this.#s(),this.#e}async#i(t){let o=await this.#u(),r=it(),n=`temp:${r}`,i=be.join(o,`${r}.txt`);return await lt(i,t,{encoding:"utf8",flag:"wx"}),this.#t.set(n,i),n}async#s(){await Promise.allSettled(this.#n),this.#t.clear(),this.#r!==void 0&&await ut(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 o=this.#t.get(t);if(this.#e!==void 0||o===void 0)throw new Error(`Temporary resource ${t} does not exist in this runtime`);return[{type:"text",text:await dt(o,"utf8")}]}async#u(){return this.#r??=(async()=>(await st(this.#o,{recursive:!0}),at(be.join(this.#o,"pi-agent-read-"))))(),this.#r}};import{open as ft,realpath as pt,stat as gt}from"node:fs/promises";import Rt from"node:path";import{fileURLToPath as mt}from"node:url";async function Ae(e,t,o,r=[]){let n=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=n.slice(4);if(a.length===0)throw new Error("Supply a local file after raw:");let R=a.startsWith("file://")?mt(a):Rt.resolve(t.cwd,a),h=await pt(R),f=`raw:${h}`;for(let{registration:g}of r)try{let l=await g.guard({requestedSource:n,resourceSource:f,resolvedBy:"raw",cwd:t.cwd,request:e,audience:o,...t.signal!==void 0&&{signal:t.signal}});if(l.kind==="rejected")return x({code:"READ_FAILED",source:f,resolverId:"raw",message:`Read blocked by hook ${g.id}: ${l.reason}`})}catch(l){return x({code:"READ_FAILED",source:f,resolverId:"raw",message:`Read blocked because hook ${g.id} failed: ${l instanceof Error?l.message:String(l)}`,cause:l})}if(t.signal?.throwIfAborted(),!(await gt(h)).isFile())throw new Error("Raw reads require a regular file");let c=await ft(h,"r");try{let g=await c.stat();if(!g.isFile())throw new Error("Raw reads require a regular file");let l=Math.min(g.size,Math.max(0,i<0?g.size+i:i)),y=Math.min(d??g.size,g.size-l),v=16*Math.max(1,Math.min(M-4,Math.floor((I-1024)/90))),P=o==="script"?y:Math.min(y,v),m=Buffer.alloc(P),T=0;for(;T<P;){t.signal?.throwIfAborted();let D=await c.read(m,T,P-T,l+T);if(D.bytesRead===0)break;T+=D.bytesRead}t.signal?.throwIfAborted();let S=m.subarray(0,T),p=l+T,E=p<g.size,u=`${f}
5
- Bytes ${l}..${p} (end exclusive), ${g.size} bytes total`,k=yt(S,l),b=E?`
6
- Use offset=${p} to continue in bytes.`:"";return{content:[{type:"text",text:`${u}
7
- ${k}${b}`}],details:{source:f,resolvedBy:"raw",byteOffset:l,byteLength:T,totalBytes:g.size},script:{kind:"bytes",source:f,byteOffset:l,byteLength:T,totalBytes:g.size,bytes:Array.from(S),truncated:T<y}}}finally{await c.close()}}catch(i){if(t.signal?.aborted)throw i;return x({code:"READ_FAILED",source:n,message:i instanceof Error?i.message:String(i),cause:i})}}s(Ae,"readRaw");function yt(e,t){let o=[];for(let r=0;r<e.length;r+=16){let n=e.subarray(r,r+16),i=Array.from(n,a=>a.toString(16).padStart(2,"0")).join(" "),d=Array.from(n,a=>a>=32&&a<=126?String.fromCharCode(a):".").join("");o.push(`${(t+r).toString(16).padStart(8,"0")} ${i.padEnd(47)} |${d}|`)}return o.join(`
8
- `)}s(yt,"formatRawBytes");var ht=pe({kind:"source"});function _e(e,t="compact"){let o=new X,r=[{resolver:o.resolver,preserveTruncatedOutput:!1,priority:Number.MIN_SAFE_INTEGER,order:0}],n=[],i=[],d=[],a=[],R=[],h="read";return{saveTemporary:s(f=>o.save(f),"saveTemporary"),tool:{name:h,exposure:"direct",namespace:{name:"ide_read",description:"Read resources and compare sources."},annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},label:h,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 ${I/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:he,outputSchema:we,renderCall(f,c,g){let l=typeof f.path=="string"?f.path:void 0,y=l===void 0?void 0:r.find(({matchesCall:P})=>P?.(l)===!0)?.renderCall,v=g.expanded?"full":t;return v==="disabled"?new $e(c.fg("toolTitle","read"),0,0):(y??fe)(f,c,{...g,expanded:v==="full"})},renderResult(f,c,g,l){let y=f.details.resolvedBy,v=y===void 0?void 0:r.find(({resolver:m})=>m.id===y)?.renderResult,P=c.expanded?"full":t;return P==="disabled"&&!l.isError&&!c.isPartial?new $e(g.fg("success","\u2713 read"),0,0):(v??ht)(f,{...c,expanded:P==="full"},g,l)},async execute(f,c,g,l,y){let v={cwd:y.cwd,...g!==void 0&&{signal:g}};try{let P=await ke(c,v,r,i,d,o,a,R,n);return Y(P)}catch(P){if(g?.aborted)throw P;return Y(x({code:"READ_FAILED",source:c.path,message:P instanceof Error?P.message:String(P)}))}}},execute(f,c,g="agent"){return ke(f,c,r,i,d,o,a,R,n,g)},registerContributions(f,c){let g=[...c.resourceGuards??[]],l=[...c.resolvers??[]],y=[...c.targetResolvers??[]],v=[...c.handlers??[]],P=[...c.views??[]],m=[...c.fragments??[]],T=new Set(n.map(({registration:u})=>u.id));for(let u of g){if(u.id.trim().length===0||typeof u.guard!="function")throw new TypeError(`Plugin ${f} provided an invalid Resource guard`);if(T.has(u.id))throw new Error(`Resource guard ${u.id} is already registered`);T.add(u.id)}Ot(f,l,v,r,i),Ct(f,m,a);let S=new Set(R.map(({resolver:u})=>u.id));for(let u of y){if(!B(u))throw new TypeError(`Plugin ${f} provided an invalid text target resolver`);if(S.has(u.resolver.id))throw new Error(`Text target resolver ${u.resolver.id} is already registered`);S.add(u.resolver.id)}let p=new Set(d.map(({registration:u})=>u.view)),E=new Set(d.map(({registration:u})=>`${u.view}/${u.presenter.id}`));for(let u of P){if(!H(u))throw new TypeError(`Plugin ${f} provided an invalid view registration`);let k=`${u.view}/${u.presenter.id}`;if(E.has(k))throw new Error(`View ${u.view} already has a presenter ${u.presenter.id}`);p.add(u.view),E.add(k)}for(let u of g)n.push({pluginId:f,registration:u});for(let u of l)r.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,...u.recoverFailure===void 0?{}:{recoverFailure:u.recoverFailure},order:r.length});for(let u of y)R.push({resolver:u.resolver,priority:u.priority??0,order:R.length});for(let u of v)i.push({pluginId:f,registration:u});for(let u of P)d.push({pluginId:f,registration:u,order:d.length});for(let u of m)a.push({registration:u,priority:u.priority??0,order:a.length})},dispose(){return o.dispose()}}}s(_e,"createReadTool");async function ke(e,t,o,r,n,i,d,a,R,h="agent"){if(e.path?.startsWith("raw:"))return Ae(e,t,h,R);t={...t,audience:h};let f=h==="script"?async w=>w:Q,c=[...o].sort((w,L)=>w.priority-L.priority||w.order-L.order),g=[...r],l=[...n].sort((w,L)=>(w.registration.priority??0)-(L.registration.priority??0)||w.order-L.order),y=[...d].sort((w,L)=>w.priority-L.priority||w.order-L.order),v=[...a].sort((w,L)=>w.priority-L.priority||w.order-L.order),P=[...e.views??[],...h==="script"?l.map(({registration:w})=>w.view):[]],m=new Set(P.map(Oe)),T=new Set([...l.map(({registration:w})=>w.view)]),S=P.filter(w=>!T.has(Oe(w)));if(e.path!==void 0&&v.length>0){let w=await xt(e,t,v,c,g,l,m,S,h,R);if(w!==void 0)return w}let p={request:{...e},resolverContext:t,audience:h};if(!p.request.path?.startsWith("temp:")){let w=await Fe(p,g);if(w.kind==="return")return $(await f(w.result,p.request),S);p=w.context}let E=p.request.path;if(E===void 0||E.length===0)return x({code:"INVALID_REQUEST",message:"No source was provided"});let u=await Z(p,c,R,e.path??E),k;if(u.kind==="return"&&u.result.isError===!0&&vt(u.result)&&!E.startsWith("temp:")){let w=Tt(E);if(w!==void 0){let L={result:u,pipeline:p},te={...p,request:{...p.request,path:w.source}},re=await Z(te,c,R,e.path??E);re.kind==="continue"?(u=re,p=te,k=w.fragment):u=L.result}}if(u.kind==="return")return f(u.result,p.request);p=u.context;let b;if(k!==void 0){let w=await Pt(p,y,k);if(typeof w!="number")return w;b=w}if(p.state?.textMode==="final")return $(await f(K(p.state,p.request,{originLine:b,audience:h}),p.request,void 0,{originLine:b}),S);let D=await Ne(p,g);if(D.kind==="return")return $(await f(D.result,p.request,void 0,{originLine:b}),S);p=D.context,p=await Me(p,l,m);let O=K(A(p.state),p.request,{audience:h,originLine:b});p={...p,result:O};let C=await Ve(p,g),F=C.kind==="return"?C.result:A(C.context.result),N=p.request.limit===void 0&&p.state?.preserveTruncatedOutput===!0?w=>i.save(w):void 0;return $(await f(F,p.request,N,{originLine:b}),S)}s(ke,"executeRead");var wt=new Set(["INVALID_RESOLVER_RESULT","NO_RESOLVER","READ_FAILED","RESOLVE_FAILED"]);function vt(e){let t=e.details.failure?.code;return t!==void 0&&wt.has(t)}s(vt,"isRetryableFailure");async function xt(e,t,o,r,n,i,d,a,R,h){let f=R==="script"?async c=>c:Q;for(let{resolver:c}of o){let g;try{g=await c.tryResolve(e.path??"",t)}catch(p){return x({code:"RESOLVE_FAILED",source:e.path,message:_(`Text target resolver ${c.id} failed`,p),cause:p})}if(!ie(g))return x({code:"INVALID_RESOLVER_RESULT",source:e.path,message:`Text target resolver ${c.id} returned an invalid result`,cause:g});let l=g;if(l.kind==="not-handled")continue;if(l.kind==="rejected")return x({code:"RESOLVE_FAILED",source:e.path,message:l.rejection.reason});if(l.kind==="failed")return x({code:"RESOLVE_FAILED",source:e.path,message:l.error instanceof Error?l.error.message:String(l.error)});if(l.targets.length===0)return x({code:"RESOLVE_FAILED",source:e.path,message:"Text target resolver returned no targets"});let y=[],v=[],P,m=l.targets.flatMap(p=>(p.ranges??[{start:{lineNumber:1,column:0},end:{lineNumber:1,column:1}}]).map(async u=>{let k=Math.max(1,u.end.lineNumber-u.start.lineNumber),b={request:{...e,path:p.source,limit:e.limit??k},resolverContext:t,audience:R};if(!p.source.startsWith("temp:")){let L=await Fe(b,n);if(L.kind==="return")return L.result.isError===!0?$(L.result,a):L.result;b=L.context}let D=await Z(b,r,h,e.path??p.source);if(D.kind==="return")return $(D.result,a);let O=await Ne(D.context,n);if(O.kind==="return")return O.result.isError===!0?$(O.result,a):O.result;let C=await Me(O.context,i,d),F=K(A(C.state),C.request,{audience:R,originLine:u.start.lineNumber}),N=await Ve({...C,result:F},n);if(F.isError===!0)return $(F,a);let w=N.kind==="return"?N.result:A(N.context.result);return w.isError===!0?$(w,a):w})),T=await Promise.allSettled(m);for(let p of T){if(p.status==="rejected")throw p.reason;let E=p.value;if(E.isError===!0)return $(E,a);for(let u of E.content)u.type==="text"&&y.push(u.text);v.push(E),P??=E.details}let S={script:v.length===1&&v[0]?.script!==void 0?v[0].script:{kind:"resources",source:e.path,resources:v.map(p=>A(p.script))},content:[{type:"text",text:y.join(`
9
- `)}],details:R==="script"?{source:e.path,resources:v}:P??{source:e.path}};return $(await f(S,{path:e.path,views:e.views}),a)}}s(xt,"resolveTextTargets");var De="#";function Tt(e){let t=e.indexOf(De);if(!(t<=0||t===e.length-1))return{source:e.slice(0,t),fragment:e.slice(t+De.length)}}s(Tt,"splitAnchoredSource");async function Pt(e,t,o){let r=A(e.state);if(r.contentKind!=="text")return x({code:"UNSUPPORTED_RANGE",source:r.source,resolverId:r.resolvedBy,message:"Anchored reads require textual content"});if(t.length===0)return x({code:"NO_FRAGMENT_RESOLVER",source:r.source,message:`No fragment resolver is registered for anchor "${o}"`});for(let{registration:n}of t){let i;try{i=await n.resolve({source:r.source,fragment:o,text:r.text,cwd:e.resolverContext.cwd,...e.resolverContext.signal!==void 0&&{signal:e.resolverContext.signal}})}catch(d){return x({code:"FRAGMENT_FAILED",source:r.source,resolverId:n.id,message:_(`Fragment resolver ${n.id} failed`,d),cause:d})}if(!ve(i))return x({code:"INVALID_RESOLVER_RESULT",source:r.source,resolverId:n.id,message:`Fragment resolver ${n.id} returned an invalid result`,cause:i});if(i.kind!=="not-handled")return i.kind==="failed"?x({code:"FRAGMENT_FAILED",source:r.source,resolverId:n.id,message:i.message}):!Number.isInteger(i.originLine)||i.originLine<1||i.originLine>r.text.lines.length?x({code:"INVALID_RESOLVER_RESULT",source:r.source,resolverId:n.id,message:`Fragment resolver ${n.id} returned out-of-range origin line ${i.originLine}`}):i.originLine}return x({code:"NO_FRAGMENT_RESOLVER",source:r.source,message:`No fragment resolver handled anchor "${o}"`})}s(Pt,"resolveAnchoredOrigin");async function Z(e,t,o,r){let n=A(e.request.path),i=e.resolverContext;for(let a of t){let{resolver:R}=a,h=s(async l=>{try{let y=await a.recoverFailure?.(l,i);return x({...l,...y?.length?{candidates:y}:{}})}catch{return x(l)}},"recoveredFailure"),f;try{f=await R.tryResolve(n,i)}catch(l){return{kind:"return",result:await h({code:"RESOLVE_FAILED",source:n,resolverId:R.id,message:_(`Resolver ${R.id} failed`,l),cause:l})}}if(!ye(f))return{kind:"return",result:x({code:"INVALID_RESOLVER_RESULT",source:n,resolverId:R.id,message:`Resolver ${R.id} returned an invalid result`,cause:f})};if(f.kind==="not-handled")continue;if(f.kind==="failed")return{kind:"return",result:await h({code:"RESOLVE_FAILED",source:n,resolverId:R.id,message:_(`Resolver ${R.id} failed`,f.error),cause:f.error})};let c=f.resource;if(c.read===void 0)return{kind:"return",result:x({code:"UNSUPPORTED_CAPABILITY",source:c.source,resolverId:R.id,message:`Resource ${c.source} does not support reading`})};for(let{registration:l}of o)try{let y=await l.guard({requestedSource:r,resourceSource:c.source,resolvedBy:R.id,cwd:i.cwd,request:e.request,audience:e.audience??"agent",...i.signal!==void 0&&{signal:i.signal}});if(y.kind==="rejected")return{kind:"return",result:z(x({code:"READ_FAILED",source:c.source,resolverId:R.id,message:`Read blocked by hook ${l.id}: ${y.reason}`}),y.reason)}}catch(y){return{kind:"return",result:z(x({code:"READ_FAILED",source:c.source,resolverId:R.id,message:_(`Read blocked because hook ${l.id} failed`,y),cause:y}),`Hook ${l.id} failed`)}}let g;try{g=await ge.run(Re(c.source,i.cwd,"read"),()=>A(c.read)({...i.signal!==void 0&&{signal:i.signal}}),i.signal)}catch(l){return{kind:"return",result:await h({code:"READ_FAILED",source:c.source,resolverId:R.id,message:_(`Unable to read ${c.source}`,l),cause:l})}}return me(g)?{kind:"continue",context:{...e,state:Se(g,c.source,R.id,{preserveTruncatedOutput:a.preserveTruncatedOutput,textMode:R.id==="temp"?"final":"normal"})}}:{kind:"return",result:x({code:"INVALID_RESOURCE_CONTENT",source:c.source,resolverId:R.id,message:`Resource ${c.source} returned invalid content`,cause:g})}}let d=`No resolver handled ${n}`;return{kind:"return",result:z(x({code:"NO_RESOLVER",source:n,message:d}),d)}}s(Z,"resolveSource");async function Fe(e,t){let o=e;for(let r of t){if(r.registration.stage!=="pre-read")continue;let n=await ee(r.registration.handler,o,r.pluginId,"pre-read");if(n.kind==="return")return n;o=n.context}return{kind:"continue",context:o}}s(Fe,"runPreReadHandlers");async function Ne(e,t){let o=e.state,r=o===void 0?[]:t.filter(i=>i.registration.stage==="read"&&Dt(i.registration,o)),n=e;for(let i of r){let d=i.registration;if(d.stage!=="read")continue;let a=await ee(d.handler,n,i.pluginId,"read");if(a.kind==="return")return a;n=a.context}return{kind:"continue",context:n}}s(Ne,"runReadHandlers");async function Me(e,t,o){let r=e.state;if(r?.contentKind!=="text"||o.size===0)return e;let n=r.text,i={purpose:"read",audience:e.resolverContext.audience,requestedViews:e.request.views,source:r.source,cwd:e.resolverContext.cwd,resolvedBy:r.resolvedBy,...e.resolverContext.signal!==void 0&&{signal:e.resolverContext.signal}},d=t.filter(({registration:c})=>o.has(c.view)),a=new Set(d.flatMap(({registration:c})=>c.includes??[])),R=d.filter(({registration:c})=>!a.has(c.view)),h=await Promise.all(R.map(async({registration:c})=>({presenterId:c.presenter.id,document:await c.presenter.present(n,i)}))),f=Et(n,h);return{...e,state:{...r,text:f}}}s(Me,"runTextPresenters");function Oe(e){let t=e.indexOf(":");return t<0?e:e.slice(0,t)}s(Oe,"viewName");function $(e,t){if(t.length===0)return e;let o=`note: ignored unknown views: ${t.join(", ")}`,r=e.content[0],n=r?.type==="text"?[{...r,text:`${o}
10
- ${r.text}`}]:[...e.content];return{...e,content:n,details:{...e.details,ignoredViews:t}}}s($,"withIgnoredViews");function Et(e,t){let o=e.lines;for(let n of t)Lt(e,n),o=o.map((i,d)=>St(A(e.lines[d]),i,A(n.document.lines[d])));let r=[...new Map([e,...t.map(n=>n.document)].flatMap(n=>n.references??[]).map(n=>[n.value,n])).values()];return{...e,lines:o,...r.length===0?{}:{references:r}}}s(Et,"mergeViewContributions");function Lt(e,t){let o=t.document;if(o.source!==e.source||o.content!==e.content||o.lines.length!==e.lines.length)throw new Error(`Text presenter ${t.presenterId} changed canonical text`);for(let[r,n]of o.lines.entries()){let i=A(e.lines[r]);if(n.lineNumber!==i.lineNumber||n.content!==i.content||n.lineEnding!==i.lineEnding)throw new Error(`Text presenter ${t.presenterId} changed canonical text`)}}s(Lt,"assertPresentationOnly");function St(e,t,o){let r=bt(e.presentation,t.presentation,o.presentation),n=kt(e.metadata,t.metadata,o.metadata),i=o.anchors===void 0?t.anchors:[...new Set([...t.anchors??[],...o.anchors])];return r===t.presentation&&n===t.metadata&&i===t.anchors?t:{...t,...r!==void 0&&{presentation:r},...n!==void 0&&{metadata:n},...i!==void 0&&{anchors:i}}}s(St,"mergePresentedLine");function bt(e,t,o){if(o===e)return t;let r=Ce(e?.prefix,t?.prefix,o?.prefix),n=Ce(e?.suffix,t?.suffix,o?.suffix),i=Ie(e?.before,t?.before,o?.before),d=Ie(e?.after,t?.after,o?.after),a=o?.marker===e?.marker?t?.marker:o?.marker;return r===t?.prefix&&n===t?.suffix&&i===t?.before&&d===t?.after&&a===t?.marker?t:{...t,...r!==void 0&&{prefix:r},...n!==void 0&&{suffix:n},...i!==void 0&&{before:i},...d!==void 0&&{after:d},...a!==void 0&&{marker:a}}}s(bt,"mergeLinePresentation");function Ce(e,t,o){if(o===e)return t;let r=e??"",n=t??"",i=o??"";return r.length>0&&i.startsWith(r)?`${n}${i.slice(r.length)}`:r.length>0&&i.endsWith(r)?`${i.slice(0,-r.length)}${n}`:`${n}${i}`}s(Ce,"mergePresentedText");function Ie(e,t,o){if(o===e)return t;let r=e??[],n=t??[],i=o??[];return At(i,r)?[...n,...i.slice(r.length)]:$t(i,r)?[...i.slice(0,i.length-r.length),...n]:[...n,...i]}s(Ie,"mergePresentedRows");function At(e,t){return t.length>0&&t.length<=e.length&&t.every((o,r)=>e[r]===o)}s(At,"startsWithRows");function $t(e,t){let o=e.length-t.length;return t.length>0&&o>=0&&t.every((r,n)=>e[o+n]===r)}s($t,"endsWithRows");function kt(e,t,o){if(o===e||o===void 0)return t;let r=Object.fromEntries(Object.entries(o).filter(([n,i])=>e?.[n]!==i));return Object.keys(r).length===0?t:{...t,...r}}s(kt,"mergeLineMetadata");async function Ve(e,t){let o=t.filter(({registration:i})=>i.stage==="post-read"),r=await Promise.all(o.map(i=>ee(i.registration.handler,e,i.pluginId,"post-read")));for(let i of r)if(i.kind==="return")return i;let n=e.result;for(let i of r)if(!(i.kind==="return"||i.transform===void 0)){if(n===void 0)throw new Error("Post-read transform requires a read result");n=i.transform(n)}return{kind:"continue",context:n===void 0?e:{...e,result:n}}}s(Ve,"runPostReadHandlers");async function ee(e,t,o,r){try{return await e(t)}catch(n){return{kind:"return",result:x({code:"PIPELINE_FAILED",...t.state?.source===void 0?t.result?.details.source===void 0?{}:{source:t.result.details.source}:{source:t.state.source},pluginId:o,stage:r,message:`Plugin ${o} failed during ${r}`,cause:n})}}}s(ee,"invokeHandler");function Dt(e,t){return(e.when.resolvedBy==="any"||e.when.resolvedBy===t.resolvedBy)&&(e.when.contentKind==="any"||e.when.contentKind===t.contentKind)}s(Dt,"matchesReadState");function Ot(e,t,o,r,n){let i=new Set(r.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(n.filter(a=>a.pluginId===e).map(a=>a.registration.stage));for(let a of o){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(Ot,"validateContributions");function Ct(e,t,o){let r=new Set(o.map(({registration:n})=>n.id));for(let n of t){if(!q(n))throw new TypeError(`Plugin ${e} provided an invalid fragment resolver`);if(r.has(n.id))throw new Error(`Fragment resolver ${n.id} is already registered`);r.add(n.id)}}s(Ct,"validateFragmentRegistrations");function _(e,t){return!(t instanceof Error)||t.message.length===0?e:`${e}: ${t.message}`}s(_,"appendErrorMessage");function Be(e="compact"){let t=[],o=new Set,r=new Map,n=_e(()=>Ft(r),e),i=Promise.resolve();return{read:n,registerPlugin(d){let a=It(d);if(a!==void 0)return Promise.reject(a);let R=r.get(d.id);if(R?.plugin===d)return R.ready;if(R!==void 0)return Promise.reject(new Error(`Plugin ${d.id} is already registered`));let h={status:"pending"},f=[],c=[],g=_t(d.id,n,c,f,t),l=i.then(async()=>{try{await d.setup(g.api),g.commit(),h.status="active";return}catch(v){throw g.close(),v}}),y={lifecycle:h,plugin:d,promptGuidelines:c,promptContributions:f,ready:l};return r.set(d.id,y),o.add(l),i=l.catch(()=>{}),l.then(()=>{o.delete(l)},()=>{o.delete(l),r.get(d.id)===y&&r.delete(d.id)}),l},renderPluginPromptGuideline:s(()=>Nt(r),"renderPluginPromptGuideline"),async waitForPendingPlugins(){await Promise.all(o)}}}s(Be,"createReadCore");function It(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(It,"getPluginValidationError");function _t(e,t,o,r,n){let i=[],d=[],a=[],R=[],h=[],f=[],c=[],g=[],l=[],y="setup",v=s(()=>{if(y==="closed")throw new Error(`Plugin ${e} API is closed`)},"assertAvailable");return{api:{addOutputReducer(m){if(v(),typeof m!="function")throw new TypeError("Expected an output reducer");(y==="setup"?i:n).push(m)},async reduceOutput(m,T,S){v();for(let p of n){T.signal?.throwIfAborted();let E=await p(m,T,S);if(E!==void 0)return E}},saveTemporary(m){return v(),t.saveTemporary(m)},read(m,T,S){return v(),t.execute(m,T,S)},addResourceGuard(m){v(),y==="setup"?R.push(m):t.registerContributions(e,{resourceGuards:[m]})},addResolver(m){if(v(),!j(m))throw new TypeError(`Plugin ${e} provided an invalid resource resolver`);if(y==="setup"){h.push(m);return}t.registerContributions(e,{resolvers:[m]})},addTargetResolver(m){if(v(),!B(m))throw new TypeError(`Plugin ${e} provided an invalid text target resolver`);if(y==="setup"){f.push(m);return}t.registerContributions(e,{targetResolvers:[m]})},addHandler(m){if(v(),!G(m))throw new TypeError(`Plugin ${e} provided an invalid read handler`);if(y==="setup"){c.push(m);return}t.registerContributions(e,{handlers:[m]})},addView(m){if(v(),!H(m))throw new TypeError(`Plugin ${e} provided an invalid view registration`);if(y==="setup"){g.push(m);return}t.registerContributions(e,{views:[m]})},addFragmentResolver(m){if(v(),!q(m))throw new TypeError(`Plugin ${e} provided an invalid fragment resolver`);if(y==="setup"){l.push(m);return}t.registerContributions(e,{fragments:[m]})},describe(m){if(v(),d.length>0||r.length>0)throw new Error(`Plugin ${e} provides more than one description`);let T=Ue(m);if(y==="setup"){d.push(T);return}r.push(T)},addPromptGuideline(m){v();let T=Ue(m);if(y==="setup"){a.push(T);return}o.push(T)}},close(){y="closed"},commit(){if(y!=="setup")throw new Error(`Plugin ${e} setup contributions cannot be committed`);t.registerContributions(e,{resourceGuards:R,resolvers:h,targetResolvers:f,handlers:c,views:g,fragments:l}),r.push(...d),n.push(...i),o.push(...a),y="active"}}}s(_t,"createPluginContributionController");function Ft(e){let t=[];for(let o of e.values())if(o.lifecycle.status==="active")for(let r of o.promptGuidelines){let n=je(r);n!==void 0&&t.push(n)}return t}s(Ft,"renderPromptGuidelines");function Nt(e){let t=[];for(let o of e.values()){if(o.lifecycle.status!=="active")continue;let r=o.promptContributions[0];if(r===void 0)continue;let n=je(r);n!==void 0&&t.push(n)}return t.length===0?void 0:[...new Set(t.flatMap(o=>o.split(`
3
+ ${t}`}d(Se,"appendNotice");function $e(e,t,r,n){if(!ut(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:oe(t,o)}}d($e,"createReadState");function Y(e,t,r){if(e.contentKind!=="text"){if(t.offset!==void 0||t.limit!==void 0)return x({code:"UNSUPPORTED_RANGE",source:e.source,resolverId:e.resolvedBy,message:"Line ranges require textual content"});let y=st(e.content);return{script:{kind:"native",source:e.source,blocks:e.content},content:y.content,details:{...Ae(e),...y.unsupportedContentBlocks!==void 0&&{unsupportedContentBlocks:y.unsupportedContentBlocks}}}}let n=e.text.lines.length,o=at(t,n,r?.originLine),i=e.text.lines.slice(o.startIndex,o.endIndex),s=e.textMode==="final"?it(i,o.endIndex<n):ie({...e.text,lines:i.map((y,f)=>({...y,lineEnding:f===i.length-1&&o.endIndex<n?"":y.lineEnding}))}),a=e.content[0],p=[{type:"text",text:s,...a.textSignature!==void 0&&{textSignature:a.textSignature}}];return{script:{kind:"text",...e.text.references===void 0?{}:{references:e.text.references},source:e.source,content:i.map(y=>y.content+y.lineEnding).join(""),lines:i,startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:n},content:p,details:{...Ae(e),startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:n,lines:i}}}d(Y,"projectReadState");function it(e,t){return e.map((r,n)=>`${r.content}${n===e.length-1&&t?"":r.lineEnding}`).join("")}d(it,"renderFinalTextLines");function x(e){return{content:[{type:"text",text:[`${e.code}: ${e.message}`,...e.candidates?.length?["","Possible matches:",...e.candidates.map(t=>`- ${JSON.stringify(t.path)}`),"","Retry read with an exact candidate path."]:[]].join(`
4
+ `)}],details:{failure:e},isError:!0}}d(x,"failureResult");function Ae(e){return{source:e.source,resolvedBy:e.resolvedBy}}d(Ae,"readDetails");function st(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)]}}}d(st,"projectAgentContent");function at(e,t,r){let n=e.offset===void 0?1:Math.trunc(e.offset),o=dt(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)}}d(at,"resolveTextRange");function dt(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)}d(dt,"anchoredStartLine");function ut(e){return e.length===1&&e[0].type==="text"}d(ut,"isSingleTextContent");import{randomUUID as lt}from"node:crypto";import{mkdir as ct,mkdtemp as ft,readFile as pt,rm as gt,writeFile as Rt}from"node:fs/promises";import{tmpdir as mt}from"node:os";import ke from"node:path";var Q=class{static{d(this,"TempResourceStore")}resolver;#t=new Map;#n=new Set;#o;#r;#e;constructor(t={}){this.#o=t.parentDirectory??mt(),this.resolver={id:"temp",tryResolve:d(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=lt(),o=`temp:${n}`,i=ke.join(r,`${n}.txt`);return await Rt(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 gt(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:d(()=>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 pt(r,"utf8")}]}async#u(){return this.#r??=(async()=>(await ct(this.#o,{recursive:!0}),ft(ke.join(this.#o,"pi-agent-read-"))))(),this.#r}};import{open as yt,realpath as ht,stat as vt}from"node:fs/promises";import wt from"node:path";import{fileURLToPath as xt}from"node:url";async function Ce(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,s=e.limit;if(!Number.isSafeInteger(i)||s!==void 0&&(!Number.isSafeInteger(s)||s<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 p=a.startsWith("file://")?xt(a):wt.resolve(t.cwd,a),y=await ht(p),f=`raw:${y}`;for(let{registration:g}of n)try{let u=await g.guard({requestedSource:o,resourceSource:f,resolvedBy:"raw",cwd:t.cwd,request:e,audience:r,...t.signal!==void 0&&{signal:t.signal}});if(u.kind==="rejected")return x({code:"READ_FAILED",source:f,resolverId:"raw",message:`Read blocked by hook ${g.id}: ${u.reason}`})}catch(u){return x({code:"READ_FAILED",source:f,resolverId:"raw",message:`Read blocked because hook ${g.id} failed: ${u instanceof Error?u.message:String(u)}`,cause:u})}if(t.signal?.throwIfAborted(),!(await vt(y)).isFile())throw new Error("Raw reads require a regular file");let c=await yt(y,"r");try{let g=await c.stat();if(!g.isFile())throw new Error("Raw reads require a regular file");let u=Math.min(g.size,Math.max(0,i<0?g.size+i:i)),m=Math.min(s??g.size,g.size-u),w=16*Math.max(1,Math.min(j-4,Math.floor((I-1024)/90))),P=r==="script"?m:Math.min(m,w),h=Buffer.alloc(P),T=0;for(;T<P;){t.signal?.throwIfAborted();let C=await c.read(h,T,P-T,u+T);if(C.bytesRead===0)break;T+=C.bytesRead}t.signal?.throwIfAborted();let L=h.subarray(0,T),R=u+T,E=R<g.size,l=`${f}
5
+ Bytes ${u}..${R} (end exclusive), ${g.size} bytes total`,A=Tt(L,u),k=E?`
6
+ Use offset=${R} to continue in bytes.`:"";return{content:[{type:"text",text:`${l}
7
+ ${A}${k}`}],details:{source:f,resolvedBy:"raw",byteOffset:u,byteLength:T,totalBytes:g.size},script:{kind:"bytes",source:f,byteOffset:u,byteLength:T,totalBytes:g.size,bytes:Array.from(L),truncated:T<m}}}finally{await c.close()}}catch(i){if(t.signal?.aborted)throw i;return x({code:"READ_FAILED",source:o,message:i instanceof Error?i.message:String(i),cause:i})}}d(Ce,"readRaw");function Tt(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(" "),s=Array.from(o,a=>a>=32&&a<=126?String.fromCharCode(a):".").join("");r.push(`${(t+n).toString(16).padStart(8,"0")} ${i.padEnd(47)} |${s}|`)}return r.join(`
8
+ `)}d(Tt,"formatRawBytes");var Pt=ge({kind:"source"});function Me(e,t="compact"){let r=new Q,n=[{resolver:r.resolver,preserveTruncatedOutput:!1,priority:Number.MIN_SAFE_INTEGER,order:0}],o=[],i=[],s=[],a=[],p=[],y="read";return{saveTemporary:d(f=>r.save(f),"saveTemporary"),tool:{name:y,exposure:"direct",namespace:{name:"ide_read",description:"Read resources and compare sources."},annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},label:y,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 ${j} lines or ${I/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:we,outputSchema:xe,renderCall(f,c,g){let u=typeof f.path=="string"?f.path:void 0,m=u===void 0?void 0:n.find(({matchesCall:P})=>P?.(u)===!0)?.renderCall,w=g.expanded?"full":t;return w==="disabled"?new De(c.fg("toolTitle","read"),0,0):(m??pe)(f,c,{...g,expanded:w==="full"})},renderResult(f,c,g,u){let m=f.details.resolvedBy,w=m===void 0?void 0:n.find(({resolver:h})=>h.id===m)?.renderResult,P=c.expanded?"full":t;return P==="disabled"&&!u.isError&&!c.isPartial?new De(g.fg("success","\u2713 read"),0,0):(w??Pt)(f,{...c,expanded:P==="full"},g,u)},async execute(f,c,g,u,m){let w={cwd:m.cwd,...g!==void 0&&{signal:g}};try{let P=await Oe(c,w,n,i,s,r,a,p,o);return J(P)}catch(P){if(g?.aborted)throw P;return J(x({code:"READ_FAILED",source:c.path,message:P instanceof Error?P.message:String(P)}))}}},execute(f,c,g="agent"){return Oe(f,c,n,i,s,r,a,p,o,g)},registerContributions(f,c){let g=[...c.resourceGuards??[]],u=[...c.resolvers??[]],m=[...c.targetResolvers??[]],w=[...c.handlers??[]],P=[...c.views??[]],h=[...c.fragments??[]],T=new Set(o.map(({registration:l})=>l.id));for(let l of g){if(l.id.trim().length===0||typeof l.guard!="function")throw new TypeError(`Plugin ${f} provided an invalid Resource guard`);if(T.has(l.id))throw new Error(`Resource guard ${l.id} is already registered`);T.add(l.id)}Nt(f,u,w,n,i),Mt(f,h,a);let L=new Set(p.map(({resolver:l})=>l.id));for(let l of m){if(!H(l))throw new TypeError(`Plugin ${f} provided an invalid text target resolver`);if(L.has(l.resolver.id))throw new Error(`Text target resolver ${l.resolver.id} is already registered`);L.add(l.resolver.id)}let R=new Set(s.map(({registration:l})=>l.view)),E=new Set(s.map(({registration:l})=>`${l.view}/${l.presenter.id}`));for(let l of P){if(!q(l))throw new TypeError(`Plugin ${f} provided an invalid view registration`);let A=`${l.view}/${l.presenter.id}`;if(E.has(A))throw new Error(`View ${l.view} already has a presenter ${l.presenter.id}`);R.add(l.view),E.add(A)}for(let l of g)o.push({pluginId:f,registration:l});for(let l of u)n.push({resolver:l.resolver,...l.matchesCall!==void 0&&{matchesCall:l.matchesCall,renderCall:l.renderCall},...l.renderResult!==void 0&&{renderResult:l.renderResult},priority:l.priority??0,preserveTruncatedOutput:l.preserveTruncatedOutput??!1,...l.recoverFailure===void 0?{}:{recoverFailure:l.recoverFailure},order:n.length});for(let l of m)p.push({resolver:l.resolver,priority:l.priority??0,order:p.length});for(let l of w)i.push({pluginId:f,registration:l});for(let l of P)s.push({pluginId:f,registration:l,order:s.length});for(let l of h)a.push({registration:l,priority:l.priority??0,order:a.length})},dispose(){return r.dispose()}}}d(Me,"createReadTool");async function Oe(e,t,r,n,o,i,s,a,p,y="agent"){if(e.path?.startsWith("raw:"))return Ce(e,t,y,p);t={...t,audience:y};let f=y==="script"?async v=>v:Z,c=[...r].sort((v,S)=>v.priority-S.priority||v.order-S.order),g=[...n],u=[...o].sort((v,S)=>(v.registration.priority??0)-(S.registration.priority??0)||v.order-S.order),m=[...s].sort((v,S)=>v.priority-S.priority||v.order-S.order),w=[...a].sort((v,S)=>v.priority-S.priority||v.order-S.order),P=[...e.views??[],...y==="script"?u.map(({registration:v})=>v.view):[]],h=new Set(P.map(_e)),T=new Set([...u.map(({registration:v})=>v.view)]),L=P.filter(v=>!T.has(_e(v)));if(e.path!==void 0&&w.length>0){let v=await St(e,t,w,c,g,u,h,L,y,p);if(v!==void 0)return v}let R={request:{...e},resolverContext:t,audience:y};if(!R.request.path?.startsWith("temp:")){let v=await Ve(R,g);if(v.kind==="return")return $(await f(v.result,R.request),L);R=v.context}let E=R.request.path;if(E===void 0||E.length===0)return x({code:"INVALID_REQUEST",message:"No source was provided"});let l=await te(R,c,p,e.path??E),A;if(l.kind==="return"&&l.result.isError===!0&&Lt(l.result)&&!E.startsWith("temp:")){let v=bt(E);if(v!==void 0){let S={result:l,pipeline:R},O={...R,request:{...R.request,path:v.source}},ne=await te(O,c,p,e.path??E);ne.kind==="continue"?(l=ne,R=O,A=v.fragment):l=S.result}}if(l.kind==="return")return f(l.result,R.request);R=l.context;let k;if(A!==void 0){let v=await At(R,m,A);if(typeof v!="number")return v;k=v}if(R.state?.textMode==="final")return $(await f(Y(R.state,R.request,{originLine:k,audience:y}),R.request,void 0,{originLine:k}),L);let C=await Ue(R,g);if(C.kind==="return")return $(await f(C.result,R.request,void 0,{originLine:k}),L);R=C.context,R=await Be(R,u,h);let F=Y(b(R.state),R.request,{audience:y,originLine:k});R={...R,result:F};let D=await je(R,g),N=D.kind==="return"?D.result:b(D.context.result),M=R.request.limit===void 0&&R.state?.preserveTruncatedOutput===!0?v=>i.save(v):void 0;return $(await f(N,R.request,M,{originLine:k}),L)}d(Oe,"executeRead");var Et=new Set(["INVALID_RESOLVER_RESULT","NO_RESOLVER","READ_FAILED","RESOLVE_FAILED"]);function Lt(e){let t=e.details.failure?.code;return t!==void 0&&Et.has(t)}d(Lt,"isRetryableFailure");async function St(e,t,r,n,o,i,s,a,p,y){let f=p==="script"?async c=>c:Z;for(let{resolver:c}of r){let g;try{g=await c.tryResolve(e.path??"",t)}catch(R){return x({code:"RESOLVE_FAILED",source:e.path,message:_(`Text target resolver ${c.id} failed`,R),cause:R})}if(!se(g))return x({code:"INVALID_RESOLVER_RESULT",source:e.path,message:`Text target resolver ${c.id} returned an invalid result`,cause:g});let u=g;if(u.kind==="not-handled")continue;if(u.kind==="rejected")return x({code:"RESOLVE_FAILED",source:e.path,message:u.rejection.reason});if(u.kind==="failed")return x({code:"RESOLVE_FAILED",source:e.path,message:u.error instanceof Error?u.error.message:String(u.error)});if(u.targets.length===0)return x({code:"RESOLVE_FAILED",source:e.path,message:"Text target resolver returned no targets"});let m=[],w=[],P,h=u.targets.flatMap(R=>(R.ranges??[{start:{lineNumber:1,column:0},end:{lineNumber:1,column:1}}]).map(async l=>{let A=e.path?.startsWith("RESULT#")?e.path:void 0,k=Math.max(1,l.end.lineNumber-l.start.lineNumber+(A!==void 0&&l.end.column>0?1:0)),C={sourceTarget:A,request:{...e,path:R.source,limit:e.limit??k},resolverContext:t,audience:p};if(!R.source.startsWith("temp:")){let O=await Ve(C,o);if(O.kind==="return")return O.result.isError===!0?$(O.result,a):O.result;C=O.context}let F=await te(C,n,y,e.path??R.source);if(F.kind==="return")return $(F.result,a);let D=await Ue(F.context,o);if(D.kind==="return")return D.result.isError===!0?$(D.result,a):D.result;let N=await Be(D.context,i,s),M=Y(b(N.state),N.request,{audience:p,originLine:l.start.lineNumber}),v=await je({...N,result:M},o);if(M.isError===!0)return $(M,a);let S=v.kind==="return"?v.result:b(v.context.result);return S.isError===!0?$(S,a):S})),T=await Promise.allSettled(h);for(let R of T){if(R.status==="rejected")throw R.reason;let E=R.value;if(E.isError===!0)return $(E,a);for(let l of E.content)l.type==="text"&&m.push(l.text);w.push(E),P??=E.details}let L={script:w.length===1&&w[0]?.script!==void 0?w[0].script:{kind:"resources",source:e.path,resources:w.map(R=>b(R.script))},content:[{type:"text",text:m.join(`
9
+ `)}],details:p==="script"?{source:e.path,resources:w}:P??{source:e.path}};return $(await f(L,{path:e.path,views:e.views}),a)}}d(St,"resolveTextTargets");var Ie="#";function bt(e){let t=e.indexOf(Ie);if(!(t<=0||t===e.length-1))return{source:e.slice(0,t),fragment:e.slice(t+Ie.length)}}d(bt,"splitAnchoredSource");async function At(e,t,r){let n=b(e.state);if(n.contentKind!=="text")return x({code:"UNSUPPORTED_RANGE",source:n.source,resolverId:n.resolvedBy,message:"Anchored reads require textual content"});if(t.length===0)return x({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(s){return x({code:"FRAGMENT_FAILED",source:n.source,resolverId:o.id,message:_(`Fragment resolver ${o.id} failed`,s),cause:s})}if(!Te(i))return x({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"?x({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?x({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 x({code:"NO_FRAGMENT_RESOLVER",source:n.source,message:`No fragment resolver handled anchor "${r}"`})}d(At,"resolveAnchoredOrigin");async function te(e,t,r,n){let o=b(e.request.path),i=e.resolverContext;for(let a of t){let{resolver:p}=a,y=d(async u=>{try{let m=await a.recoverFailure?.(u,i);return x({...u,...m?.length?{candidates:m}:{}})}catch{return x(u)}},"recoveredFailure"),f;try{f=await p.tryResolve(o,i)}catch(u){return{kind:"return",result:await y({code:"RESOLVE_FAILED",source:o,resolverId:p.id,message:_(`Resolver ${p.id} failed`,u),cause:u})}}if(!he(f))return{kind:"return",result:x({code:"INVALID_RESOLVER_RESULT",source:o,resolverId:p.id,message:`Resolver ${p.id} returned an invalid result`,cause:f})};if(f.kind==="not-handled")continue;if(f.kind==="failed")return{kind:"return",result:await y({code:"RESOLVE_FAILED",source:o,resolverId:p.id,message:_(`Resolver ${p.id} failed`,f.error),cause:f.error})};let c=f.resource;if(c.read===void 0)return{kind:"return",result:x({code:"UNSUPPORTED_CAPABILITY",source:c.source,resolverId:p.id,message:`Resource ${c.source} does not support reading`})};for(let{registration:u}of r)try{let m=await u.guard({requestedSource:n,resourceSource:c.source,resolvedBy:p.id,cwd:i.cwd,request:e.request,audience:e.audience??"agent",...i.signal!==void 0&&{signal:i.signal}});if(m.kind==="rejected")return{kind:"return",result:K(x({code:"READ_FAILED",source:c.source,resolverId:p.id,message:`Read blocked by hook ${u.id}: ${m.reason}`}),m.reason)}}catch(m){return{kind:"return",result:K(x({code:"READ_FAILED",source:c.source,resolverId:p.id,message:_(`Read blocked because hook ${u.id} failed`,m),cause:m}),`Hook ${u.id} failed`)}}let g;try{g=await Re.run(me(c.source,i.cwd,"read"),()=>b(c.read)({...i.signal!==void 0&&{signal:i.signal}}),i.signal)}catch(u){return{kind:"return",result:await y({code:"READ_FAILED",source:c.source,resolverId:p.id,message:_(`Unable to read ${c.source}`,u),cause:u})}}return ye(g)?{kind:"continue",context:{...e,state:$e(g,c.source,p.id,{preserveTruncatedOutput:a.preserveTruncatedOutput,textMode:p.id==="temp"?"final":"normal"})}}:{kind:"return",result:x({code:"INVALID_RESOURCE_CONTENT",source:c.source,resolverId:p.id,message:`Resource ${c.source} returned invalid content`,cause:g})}}let s=`No resolver handled ${o}`;return{kind:"return",result:K(x({code:"NO_RESOLVER",source:o,message:s}),s)}}d(te,"resolveSource");async function Ve(e,t){let r=e;for(let n of t){if(n.registration.stage!=="pre-read")continue;let o=await re(n.registration.handler,r,n.pluginId,"pre-read");if(o.kind==="return")return o;r=o.context}return{kind:"continue",context:r}}d(Ve,"runPreReadHandlers");async function Ue(e,t){let r=e.state,n=r===void 0?[]:t.filter(i=>i.registration.stage==="read"&&Ft(i.registration,r)),o=e;for(let i of n){let s=i.registration;if(s.stage!=="read")continue;let a=await re(s.handler,o,i.pluginId,"read");if(a.kind==="return")return a;o=a.context}return{kind:"continue",context:o}}d(Ue,"runReadHandlers");async function Be(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}},s=t.filter(({registration:c})=>r.has(c.view)),a=new Set(s.flatMap(({registration:c})=>c.includes??[])),p=s.filter(({registration:c})=>!a.has(c.view)),y=await Promise.all(p.map(async({registration:c})=>({presenterId:c.presenter.id,document:await c.presenter.present(o,i)}))),f=$t(o,y);return{...e,state:{...n,text:f}}}d(Be,"runTextPresenters");function _e(e){let t=e.indexOf(":");return t<0?e:e.slice(0,t)}d(_e,"viewName");function $(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}
10
+ ${n.text}`}]:[...e.content];return{...e,content:o,details:{...e.details,ignoredViews:t}}}d($,"withIgnoredViews");function $t(e,t){let r=e.lines;for(let o of t)kt(e,o),r=r.map((i,s)=>Ct(b(e.lines[s]),i,b(o.document.lines[s])));let n=[...new Map([e,...t.map(o=>o.document)].flatMap(o=>o.references??[]).map(o=>[o.value,o])).values()];return{...e,lines:r,...n.length===0?{}:{references:n}}}d($t,"mergeViewContributions");function kt(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=b(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`)}}d(kt,"assertPresentationOnly");function Ct(e,t,r){let n=Dt(e.presentation,t.presentation,r.presentation),o=_t(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}}}d(Ct,"mergePresentedLine");function Dt(e,t,r){if(r===e)return t;let n=Fe(e?.prefix,t?.prefix,r?.prefix),o=Fe(e?.suffix,t?.suffix,r?.suffix),i=Ne(e?.before,t?.before,r?.before),s=Ne(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&&s===t?.after&&a===t?.marker?t:{...t,...n!==void 0&&{prefix:n},...o!==void 0&&{suffix:o},...i!==void 0&&{before:i},...s!==void 0&&{after:s},...a!==void 0&&{marker:a}}}d(Dt,"mergeLinePresentation");function Fe(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}`}d(Fe,"mergePresentedText");function Ne(e,t,r){if(r===e)return t;let n=e??[],o=t??[],i=r??[];return Ot(i,n)?[...o,...i.slice(n.length)]:It(i,n)?[...i.slice(0,i.length-n.length),...o]:[...o,...i]}d(Ne,"mergePresentedRows");function Ot(e,t){return t.length>0&&t.length<=e.length&&t.every((r,n)=>e[n]===r)}d(Ot,"startsWithRows");function It(e,t){let r=e.length-t.length;return t.length>0&&r>=0&&t.every((n,o)=>e[r+o]===n)}d(It,"endsWithRows");function _t(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}}d(_t,"mergeLineMetadata");async function je(e,t){let r=t.filter(({registration:i})=>i.stage==="post-read"),n=await Promise.all(r.map(i=>re(i.registration.handler,e,i.pluginId,"post-read")));for(let i of n)if(i.kind==="return")return i;let o=e.result;for(let i of n)if(!(i.kind==="return"||i.transform===void 0)){if(o===void 0)throw new Error("Post-read transform requires a read result");o=i.transform(o)}return{kind:"continue",context:o===void 0?e:{...e,result:o}}}d(je,"runPostReadHandlers");async function re(e,t,r,n){try{return await e(t)}catch(o){return{kind:"return",result:x({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})}}}d(re,"invokeHandler");function Ft(e,t){return(e.when.resolvedBy==="any"||e.when.resolvedBy===t.resolvedBy)&&(e.when.contentKind==="any"||e.when.contentKind===t.contentKind)}d(Ft,"matchesReadState");function Nt(e,t,r,n,o){let i=new Set(n.map(({resolver:a})=>a.id));for(let a of t){if(!G(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 s=new Set(o.filter(a=>a.pluginId===e).map(a=>a.registration.stage));for(let a of r){if(!z(a))throw new TypeError(`Plugin ${e} provided an invalid read handler`);if(s.has(a.stage))throw new Error(`Plugin ${e} already handles ${a.stage}`);s.add(a.stage)}}d(Nt,"validateContributions");function Mt(e,t,r){let n=new Set(r.map(({registration:o})=>o.id));for(let o of t){if(!W(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)}}d(Mt,"validateFragmentRegistrations");function _(e,t){return!(t instanceof Error)||t.message.length===0?e:`${e}: ${t.message}`}d(_,"appendErrorMessage");function Ge(e="compact"){let t=[],r=new Set,n=new Map,o=Me(()=>Bt(n),e),i=Promise.resolve();return{read:o,registerPlugin(s){let a=Vt(s);if(a!==void 0)return Promise.reject(a);let p=n.get(s.id);if(p?.plugin===s)return p.ready;if(p!==void 0)return Promise.reject(new Error(`Plugin ${s.id} is already registered`));let y={status:"pending"},f=[],c=[],g=Ut(s.id,o,c,f,t),u=i.then(async()=>{try{await s.setup(g.api),g.commit(),y.status="active";return}catch(w){throw g.close(),w}}),m={lifecycle:y,plugin:s,promptGuidelines:c,promptContributions:f,ready:u};return n.set(s.id,m),r.add(u),i=u.catch(()=>{}),u.then(()=>{r.delete(u)},()=>{r.delete(u),n.get(s.id)===m&&n.delete(s.id)}),u},renderPluginPromptGuideline:d(()=>jt(n),"renderPluginPromptGuideline"),async waitForPendingPlugins(){await Promise.all(r)}}}d(Ge,"createReadCore");function Vt(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")}d(Vt,"getPluginValidationError");function Ut(e,t,r,n,o){let i=[],s=[],a=[],p=[],y=[],f=[],c=[],g=[],u=[],m="setup",w=d(()=>{if(m==="closed")throw new Error(`Plugin ${e} API is closed`)},"assertAvailable");return{api:{addOutputReducer(h){if(w(),typeof h!="function")throw new TypeError("Expected an output reducer");(m==="setup"?i:o).push(h)},async reduceOutput(h,T,L){w();for(let R of o){T.signal?.throwIfAborted();let E=await R(h,T,L);if(E!==void 0)return E}},saveTemporary(h){return w(),t.saveTemporary(h)},read(h,T,L){return w(),t.execute(h,T,L)},addResourceGuard(h){w(),m==="setup"?p.push(h):t.registerContributions(e,{resourceGuards:[h]})},addResolver(h){if(w(),!G(h))throw new TypeError(`Plugin ${e} provided an invalid resource resolver`);if(m==="setup"){y.push(h);return}t.registerContributions(e,{resolvers:[h]})},addTargetResolver(h){if(w(),!H(h))throw new TypeError(`Plugin ${e} provided an invalid text target resolver`);if(m==="setup"){f.push(h);return}t.registerContributions(e,{targetResolvers:[h]})},addHandler(h){if(w(),!z(h))throw new TypeError(`Plugin ${e} provided an invalid read handler`);if(m==="setup"){c.push(h);return}t.registerContributions(e,{handlers:[h]})},addView(h){if(w(),!q(h))throw new TypeError(`Plugin ${e} provided an invalid view registration`);if(m==="setup"){g.push(h);return}t.registerContributions(e,{views:[h]})},addFragmentResolver(h){if(w(),!W(h))throw new TypeError(`Plugin ${e} provided an invalid fragment resolver`);if(m==="setup"){u.push(h);return}t.registerContributions(e,{fragments:[h]})},describe(h){if(w(),s.length>0||n.length>0)throw new Error(`Plugin ${e} provides more than one description`);let T=He(h);if(m==="setup"){s.push(T);return}n.push(T)},addPromptGuideline(h){w();let T=He(h);if(m==="setup"){a.push(T);return}r.push(T)}},close(){m="closed"},commit(){if(m!=="setup")throw new Error(`Plugin ${e} setup contributions cannot be committed`);t.registerContributions(e,{resourceGuards:p,resolvers:y,targetResolvers:f,handlers:c,views:g,fragments:u}),n.push(...s),o.push(...i),r.push(...a),m="active"}}}d(Ut,"createPluginContributionController");function Bt(e){let t=[];for(let r of e.values())if(r.lifecycle.status==="active")for(let n of r.promptGuidelines){let o=ze(n);o!==void 0&&t.push(o)}return t}d(Bt,"renderPromptGuidelines");function jt(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=ze(n);o!==void 0&&t.push(o)}return t.length===0?void 0:[...new Set(t.flatMap(r=>r.split(`
11
11
  `)))].join(`
12
- `)}s(Nt,"renderPluginPromptGuideline");function Ue(e){if(typeof e=="string")return Ge(e);if(typeof e=="function")return e;throw new TypeError("Read plugin prompt description must be a string or callback")}s(Ue,"normalizeDescriptionSource");function je(e){if(typeof e=="string")return e;let t=e();return t===void 0?void 0:Ge(t)}s(je,"renderDescriptionSource");function Ge(e){if(typeof e!="string")throw new TypeError("Read plugin prompt description must be a string");let t=e.replaceAll(`\r
12
+ `)}d(jt,"renderPluginPromptGuideline");function He(e){if(typeof e=="string")return qe(e);if(typeof e=="function")return e;throw new TypeError("Read plugin prompt description must be a string or callback")}d(He,"normalizeDescriptionSource");function ze(e){if(typeof e=="string")return e;let t=e();return t===void 0?void 0:qe(t)}d(ze,"renderDescriptionSource");function qe(e){if(typeof e!="string")throw new TypeError("Read plugin prompt description must be a string");let t=e.replaceAll(`\r
13
13
  `,`
14
14
  `).replaceAll("\r",`
15
15
  `).split(`
16
- `).map(r=>r.trimEnd());for(;t[0]?.trim().length===0;)t.shift();for(;t.at(-1)?.trim().length===0;)t.pop();let o=t.join(`
17
- `);if(o.trim().length===0)throw new Error("Read plugin prompt description is empty");return o}s(Ge,"normalizeDescription");function Mt(e){return typeof e=="object"&&e!==null}s(Mt,"isRecord");function Vt(e){return e==="full"||e==="disabled"?e:"compact"}s(Vt,"parsePresentation");async function He(e,t){ae(e,[await se({id:"read-resources",description:"Resource selection, windows, views, raw bytes, and continuation",triggers:[{tool:"read"}]})]);let o=Be(Vt(t?.preferences["ui.read"])),r=e.events.on(ue,i=>{if(!le(i))throw new Error("Invalid pi-agent-read plugin registration request");i.accept(o.registerPlugin(i.plugin))});e.on("session_shutdown",async()=>{r(),await o.read.dispose()});let n=new xe;e.registerTool(Te(o.read.tool,n)),e.on("tool_result",i=>{if(!(i.toolName!=="read"||!Mt(i.details)))return{details:ce(i.details,i.content.flatMap(d=>d.type==="text"?[d.text]:[]).join(`
18
- `)),...i.details.failure!==void 0&&{isError:!0}}}),e.events.emit(de,{protocol:V,apiVersion:U}),await o.waitForPendingPlugins()}s(He,"registerReadCore");export{He as default};
16
+ `).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(`
17
+ `);if(r.trim().length===0)throw new Error("Read plugin prompt description is empty");return r}d(qe,"normalizeDescription");function Ht(e){return typeof e=="object"&&e!==null}d(Ht,"isRecord");function Gt(e){return e==="full"||e==="disabled"?e:"compact"}d(Gt,"parsePresentation");async function We(e,t){de(e,[await ae({id:"read-resources",description:"Resource selection, windows, views, raw bytes, and continuation",triggers:[{tool:"read"}]})]);let r=Ge(Gt(t?.preferences["ui.read"])),n=ve(e);await r.registerPlugin({protocol:V,apiVersion:U,id:"result-targets",setup(s){s.addHandler({stage:"post-read",handler:Le(n)})}});let o=e.events.on(le,s=>{if(!ce(s))throw new Error("Invalid pi-agent-read plugin registration request");s.accept(r.registerPlugin(s.plugin))});e.on("session_shutdown",async()=>{o(),await r.read.dispose()});let i=new Pe;e.registerTool(Ee(r.read.tool,i)),e.on("tool_result",s=>{if(!(s.toolName!=="read"||!Ht(s.details)))return{details:fe(s.details,s.content.flatMap(a=>a.type==="text"?[a.text]:[]).join(`
18
+ `)),...s.details.failure!==void 0&&{isError:!0}}}),e.events.emit(ue,{protocol:V,apiVersion:U}),await r.waitForPendingPlugins()}d(We,"registerReadCore");export{We as default};
package/dist/entry-46.js CHANGED
@@ -1 +1 @@
1
- import{A,B,C,D,E,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-2P2OGO3G.js";import"./chunk-EI7MMDWY.js";export{y as CONTENT_API_VERSION,A as CONTENT_CONVERTER_REGISTER_EVENT,z as CONTENT_HOST_READY_EVENT,x as CONTENT_PROTOCOL,f as MAX_STRUCTURED_BYTES,a as ResourceScheduler,u as UnsupportedContentError,g as assertJsonData,E as connectContentConverter,D as createContentHost,v as createContentRunner,k as isAgentContent,s as isContentConversionAttempt,q as isContentConversionContext,r as isContentConverter,t as isContentConverterRegistration,C as isContentConverterRegistrationRequest,B as isContentHostReady,p as isContentInput,o as isContentTarget,l as isResource,n as isResourceResolutionAttempt,m as isResourceResolver,j as renderContentDescription,c as resourceAccesses,b as resourceScheduler,h as resultError,d as resultErrorSchema,e as structuredResultSchema,w as targetsEqual,i as withStructuredResult};
1
+ import{A,B,C,D,E,F,G,H,I,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-SQKAXYIR.js";import"./chunk-EI7MMDWY.js";export{y as CONTENT_API_VERSION,A as CONTENT_CONVERTER_REGISTER_EVENT,z as CONTENT_HOST_READY_EVENT,x as CONTENT_PROTOCOL,f as MAX_STRUCTURED_BYTES,a as ResourceScheduler,G as ResultTargetStore,u as UnsupportedContentError,g as assertJsonData,E as connectContentConverter,I as connectResultTargets,D as createContentHost,v as createContentRunner,k as isAgentContent,s as isContentConversionAttempt,q as isContentConversionContext,r as isContentConverter,t as isContentConverterRegistration,C as isContentConverterRegistrationRequest,B as isContentHostReady,p as isContentInput,o as isContentTarget,l as isResource,n as isResourceResolutionAttempt,m as isResourceResolver,j as renderContentDescription,c as resourceAccesses,b as resourceScheduler,h as resultError,d as resultErrorSchema,F as resultInputSchema,e as structuredResultSchema,w as targetsEqual,H as verifyResultTargets,i as withStructuredResult};
package/dist/entry-49.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-F7NVAC4Q.js";import{a,b,c,d}from"./chunk-MIZAFRDR.js";import"./chunk-2P2OGO3G.js";import"./chunk-EI7MMDWY.js";export{b as searchDataSchema,c as searchOutputSchema,a as searchSchema,d as selectionData};
1
+ import{a as b,b as c,c as g,d as h,e as i,f as j,g as k,h as l,i as m}from"./chunk-AJRIASPQ.js";import{a,c as d,d as e,e as f}from"./chunk-FK42RSF4.js";import"./chunk-PS2B6THP.js";import"./chunk-SQKAXYIR.js";import"./chunk-EI7MMDWY.js";export{j as FuzzyVocabulary,c as containsSearchMatch,m as formatFuzzyCandidate,l as fuzzyCandidateData,g as fuzzyLimits,i as isFuzzyQuery,h as isFuzzyResultData,k as rankFuzzyIdentifiers,b as renderSearchMatches,d as searchDataSchema,e as searchOutputSchema,a as searchSchema,f as selectionData};
package/dist/entry-50.js CHANGED
@@ -1,6 +1,3 @@
1
- import{e as J,f as z,g as K}from"./chunk-GIRAEVUJ.js";import{e as O,f as N}from"./chunk-T7I2VX3J.js";import{c as M}from"./chunk-YHUTTZC6.js";import{a as U,b,c as W}from"./chunk-MIZAFRDR.js";import{a as H,b as V,c as G,d as _,g as q}from"./chunk-7UGNGK7Y.js";import{b as L,c as j,h as F,i as T}from"./chunk-2P2OGO3G.js";import{a as i}from"./chunk-EI7MMDWY.js";import{keyText as me}from"@earendil-works/pi-coding-agent";import{Text as $}from"@earendil-works/pi-tui";import ge from"node:os";function Y(){let e=[],r,a=new Map,o=new Map,p=new Map,h=new Map,m=Promise.resolve(),u={registerPlugin(n){if(n.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let s=h.get(n.id);if(s!==void 0)return s;let S=m.then(async()=>{let f=[],g=[],y,v,w=[],c={addSelectionProvider(t){if(y!==void 0||r!==void 0)throw new Error("Search selection provider is already registered");y=t},registerSelection(t,l){if(r===void 0)throw new Error("Search selections are unavailable. Enable the shared search selection plugin.");return r(t,l)},addResolver(t){se(t),f.push(t)},addAction(t){ae(t),g.push(t)},describe(t){if(v!==void 0)throw new Error(`Plugin ${n.id} provides more than one description`);v=Q(t)},addPromptGuideline(t){w.push(Q(t))},search:i((t,l,d)=>u.execute(t,l,d),"search"),runAction(t,l){return u.runAction(t.reference,t.capability,t.resolverId,t.input,l)}};await n.setup(c);let E=new Set(e.map(({registration:t})=>t.resolver.id));for(let t of f){if(E.has(t.resolver.id))throw new Error(`Search resolver ${t.resolver.id} is already registered`);E.add(t.resolver.id)}for(let t of g){let l=A(t.resolverId,t.capability);if(a.has(l)||g.some(d=>d!==t&&A(d.resolverId,d.capability)===l))throw new Error(`Search action ${l} is already registered`)}for(let t of f)e.push({pluginId:n.id,registration:t,order:e.length});y!==void 0&&(r=y);for(let t of g)a.set(A(t.resolverId,t.capability),t);v!==void 0&&p.set(n.id,v),w.length>0&&o.set(n.id,w)});return h.set(n.id,S),m=S.catch(()=>{}),S.catch(()=>{h.delete(n.id)}),S},async waitForPendingPlugins(){await Promise.all(h.values())},async execute(n,s,S="agent"){if(n.query.trim().length===0)return R("INVALID_REQUEST","Search query must not be empty");let f=[...e].sort((w,c)=>+(w.registration.fallback===!0)-+(c.registration.fallback===!0)||(w.registration.priority??0)-(c.registration.priority??0)||w.order-c.order),g=/^[a-z][\w-]*:\s*$/iu.test(n.query),y=/^[a-z][\w-]*:/iu.test(n.query);for(let w of f){if(g&&!w.registration.fallback)continue;let c=w.registration.resolver;try{let E=Promise.resolve().then(async()=>{let l=await c.readResources?.(n,s);return l===void 0?[{resource:"*",mode:"read"}]:(await Promise.all(l.map(d=>j(d,s.cwd,"read")))).flat()}),t=await L.run(E,async()=>{let l;try{s.signal?.throwIfAborted(),l=await c.tryResolve(n,s)}catch(d){return R("RESOLVE_FAILED",x(d,`Resolver ${c.id} failed`),c.id,d)}if(!ce(l))return R("INVALID_RESOLVER_RESULT",`Resolver ${c.id} returned an invalid result`,c.id);if(l.kind!=="not-handled"){if(l.kind==="failed")return R("RESOLVE_FAILED",x(l.error,`Resolver ${c.id} failed`),c.id,l.error);try{let d=await c.format(l.payload,s);if(!de(d))return R("FORMAT_FAILED",`Resolver ${c.id} formatter returned an invalid result`,c.id);let I=c.toScriptData?.(l.payload,d.details),ie=I===void 0;return T({content:w.registration.fallback&&y?[{type:"text",text:g?"Search fallback: empty protocol query; searched the original text.":"Search fallback: unhandled protocol query; searched the original text."},...d.content]:d.content,details:{resolverId:c.id,payload:d.details},...S==="script"&&{script:{resolverId:c.id,data:l.payload,details:d.details}},...d.usage!==void 0&&{usage:d.usage}},b,ie?{status:"error",errors:[{code:"STRUCTURED_ADAPTER_REQUIRED",message:`Search resolver ${c.id} must provide toScriptData`}]}:d.isError?{status:"error",data:I,errors:[{code:"RESOLVE_FAILED",message:`Search resolver ${c.id} returned an error`}]}:{status:"success",data:I,errors:[]})}catch(d){return R("FORMAT_FAILED",x(d,`Resolver ${c.id} formatter failed`),c.id,d)}}},s.signal);if(t!==void 0)return t}catch(E){return R("RESOLVE_FAILED",x(E,`Resolver ${c.id} failed`),c.id,E)}}let v=`No search resolver handled ${n.query}`;return J(R("NO_RESOLVER",v),v)},runAction(n,s,S,f,g){let y=a.get(A(S,s));if(y===void 0)throw new Error(`Search reference does not support ${s}`);return y.execute(n,f,g)},renderDescriptions(){return[...p.values()].flatMap(n=>{let s=B(n);return s===void 0?[]:[s]})},renderPromptGuidelines(){return[...o.values()].flat().flatMap(n=>{let s=B(n);return s===void 0?[]:[s]})},renderer(n){return e.find(({registration:s})=>s.resolver.id===n)?.registration.resolver.renderResult}};return u}i(Y,"createSearchCore");function se(e){if(!k(e)||!k(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")}i(se,"assertResolver");function ae(e){if(!k(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")}i(ae,"assertAction");function k(e){return typeof e=="object"&&e!==null}i(k,"isRecord");function ce(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}i(ce,"isAttempt");function de(e){return typeof e=="object"&&e!==null&&Array.isArray(e.content)}i(de,"isAgentToolResult");function R(e,r,a,o){return T({isError:!0,content:[{type:"text",text:r}],details:{failure:{code:e,message:r,...a!==void 0&&{resolverId:a},...o!==void 0&&{cause:o}}}},b,{status:"error",errors:[{code:e,message:r}]})}i(R,"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()}i(Q,"normalizeDescriptionSource");function B(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()}}i(B,"renderDescription");function A(e,r){return`${e}:${r}`}i(A,"actionKey");function x(e,r){return!(e instanceof Error)||e.message.trim().length===0?r:e instanceof SyntaxError?e.message:`${r}: ${e.message}`}i(x,"messageFor");import{readFile as le}from"node:fs/promises";import ue from"node:os";import D from"node:path";var fe=3e4;function Z(e=process.env,r=ue.homedir(),a=process.cwd()){let o=e.PI_CODING_AGENT_DIR?.trim(),p=o===void 0||o.length===0?D.join(r,".pi","agent"):D.resolve(o);return{globalPath:D.join(p,"pi-agent-ide","search.json"),projectPath:D.resolve(a,".pi","pi-agent-ide","search.json")}}i(Z,"resolveSearchConfigPaths");async function ee(e){let[r,a]=await Promise.all([X(e.globalPath),X(e.projectPath)]),o=a!==void 0?a:r;return{timeoutMs:o===void 0?fe:o}}i(ee,"loadSearchConfig");async function X(e){let r;try{r=await le(e,"utf8")}catch(h){if(pe(h))return;throw new Error(`Cannot read Pi Agent IDE search config at ${e}`,{cause:h})}let a;try{a=JSON.parse(r)}catch(h){throw new Error(`Invalid JSON in Pi Agent IDE search config at ${e}`,{cause:h})}if(!re(a))throw new TypeError(`Pi Agent IDE search config at ${e} must be a JSON object`);let o=Object.keys(a).find(h=>h!=="timeoutMs");if(o!==void 0)throw new TypeError(`Pi Agent IDE search config at ${e} contains unknown key ${o}`);let p=a.timeoutMs;if(p==null)return p;if(typeof p!="number"||!Number.isSafeInteger(p)||p<=0)throw new TypeError(`timeoutMs must be a positive integer or null in Pi Agent IDE search config at ${e}`);return p}i(X,"readTimeout");function pe(e){return re(e)&&e.code==="ENOENT"}i(pe,"isMissingFile");function re(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(re,"isRecord");var te=Symbol("search-timeout"),C=class extends Error{static{i(this,"SearchTimeoutError")}constructor(r){super(r),this.name="SearchTimeoutError"}};async function ne(e,r,a){if(e===null)return a(r);let o=new AbortController,p=r===void 0?o.signal:AbortSignal.any([r,o.signal]),h,m=new Promise(u=>{h=setTimeout(()=>{u(te),o.abort()},e)});try{let u=await Promise.race([a(p),m]);if(u===te)throw new C(`Search timed out after ${he(e)}. Try a smaller path scope.`);return u}finally{clearTimeout(h)}}i(ne,"runWithSearchTimeout");function he(e){if(e%1e3!==0)return`${String(e)}ms`;let r=e/1e3;return`${String(r)} ${r===1?"second":"seconds"}`}i(he,"formatDuration");function Se(e,r){let a=[...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:a,details:we(e),expanded:r}}i(Se,"searchCallModel");function ye(e){return e==="full"||e==="disabled"?e:"compact"}i(ye,"parsePresentation");async function oe(e,r){let a=ye(r?.preferences["ui.search"]);N(e,[await O({id:"search-code",description:"Text search, AST patterns, symbols, graphs, and semantic rename",triggers:[{tool:"search"},{tool:"read",resourcePrefixes:["ast:","symbol:","symbols:","graph:"]}]})]);let o=Y(),p=new z,h=e.events.on(_,m=>{if(!q(m))throw new Error("Invalid pi-agent-search plugin registration request");m.accept(o.registerPlugin(m.plugin))});e.on("session_shutdown",h),e.registerTool(K({name:"search",exposure:"direct",namespace:{name:"ide_search",description:"Find workspace text, paths and code structures."},annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},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.",...o.renderPromptGuidelines()]},parameters:U,outputSchema:W,renderCall(m,u,n){let s=n.expanded?"full":a;return s==="disabled"?new $(u.fg("toolTitle","search"),0,0):M(n.lastComponent,Se(m,s==="full"),u)},renderResult(m,u,n,s){let S=u.expanded?"full":a;if(S==="disabled"&&!s.isError&&!u.isPartial)return new $(n.fg("success","\u2713 search"),0,0);u={...u,expanded:S==="full"};let f=m.details,g=f?.resolverId===void 0?void 0:o.renderer(f.resolverId);if(g!==void 0){let y={...m,details:f?.payload};return g(y,u,n,s)}return Re(m,u,n)},async execute(m,u,n,s,S){try{let f=await ee(Z(process.env,ge.homedir(),S.cwd));return await ne(f.timeoutMs,n,async g=>(await o.waitForPendingPlugins(),o.execute(u,{cwd:S.cwd,...g!==void 0&&{signal:g},...s!==void 0&&{onUpdate:s}})))}catch(f){if(n?.aborted)throw f;let g=f instanceof Error?f.message:String(f);return T({content:[{type:"text",text:g}],details:{failure:{code:"RESOLVE_FAILED",message:g}}},b,{status:"error",errors:[F(f,"SEARCH_FAILED")]})}}},p)),e.events.emit(G,{protocol:H,apiVersion:V}),await o.waitForPendingPlugins()}i(oe,"registerSearchCore");function we(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))]}i(we,"searchCallDetails");function P(e,r){return r===void 0?[]:[{label:e,value:r}]}i(P,"optionalDetail");function Re(e,r,a){let o=e.content.flatMap(m=>m.type==="text"?[m.text]:[]).join(`
2
- `),p=r.expanded?o:o.split(`
3
- `).slice(0,8).join(`
4
- `),h=!r.expanded&&o.split(`
5
- `).length>8?`
6
- ${a.fg("dim",`${me("app.tools.expand")} to expand`)}`:"";return new $(`${a.fg("muted",p)}${h}`,0,0)}i(Re,"fallbackResult");export{oe as default};
1
+ import{e as Q,f as K,g as B}from"./chunk-F5YZG77W.js";import{e as O,f as N}from"./chunk-T7I2VX3J.js";import{a as _,c as A,d as z}from"./chunk-FK42RSF4.js";import{a as G,b as q,c as U,d as W,g as J}from"./chunk-7UGNGK7Y.js";import{a as L,e as M}from"./chunk-PS2B6THP.js";import{I as V,b as j,c as F,h as H,i as b}from"./chunk-SQKAXYIR.js";import{a as i}from"./chunk-EI7MMDWY.js";import{Text as se}from"@earendil-works/pi-tui";import Se from"node:os";function Z(){let e=[],r,a=new Map,s=new Map,d=new Map,y=new Map,T=Promise.resolve(),u={registerPlugin(t){if(t.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let o=y.get(t.id);if(o!==void 0)return o;let p=T.then(async()=>{let S=[],l=[],f,w,h=[],E={addSelectionProvider(n){if(f!==void 0||r!==void 0)throw new Error("Search selection provider is already registered");f=n},registerSelection(n,R){if(r===void 0)throw new Error("Search selections are unavailable. Enable the shared search selection plugin.");return r(n,R)},addResolver(n){de(n),S.push(n)},addAction(n){le(n),l.push(n)},describe(n){if(w!==void 0)throw new Error(`Plugin ${t.id} provides more than one description`);w=Y(n)},addPromptGuideline(n){h.push(Y(n))},search:i((n,R,g)=>u.execute(n,R,g),"search"),runAction(n,R){return u.runAction(n.reference,n.capability,n.resolverId,n.input,R)}};await t.setup(E);let c=new Set(e.map(({registration:n})=>n.resolver.id));for(let n of S){if(c.has(n.resolver.id))throw new Error(`Search resolver ${n.resolver.id} is already registered`);c.add(n.resolver.id)}for(let n of l){let R=x(n.resolverId,n.capability);if(a.has(R)||l.some(g=>g!==n&&x(g.resolverId,g.capability)===R))throw new Error(`Search action ${R} is already registered`)}for(let n of S)e.push({pluginId:t.id,registration:n,order:e.length});f!==void 0&&(r=f);for(let n of l)a.set(x(n.resolverId,n.capability),n);w!==void 0&&d.set(t.id,w),h.length>0&&s.set(t.id,h)});return y.set(t.id,p),T=p.catch(()=>{}),p.catch(()=>{y.delete(t.id)}),p},async waitForPendingPlugins(){await Promise.all(y.values())},async execute(t,o,p="agent"){if(t.query.trim().length===0)return v("INVALID_REQUEST","Search query must not be empty");if(t.navigation!==void 0&&!t.query.startsWith("symbols:"))return v("INVALID_REQUEST","navigation is supported only for symbols: queries.");let S=[...e].sort((h,E)=>+(h.registration.fallback===!0)-+(E.registration.fallback===!0)||(h.registration.priority??0)-(E.registration.priority??0)||h.order-E.order),l=/^[a-z][\w-]*:\s*$/iu.test(t.query),f=/^[a-z][\w-]*:/iu.test(t.query);for(let h of S){if(o.scope!==void 0&&h.registration.resolver.supportsResultScope!==!0)continue;let E=/^(?:ast|symbols):/u.test(t.query);if(h.registration.fallback&&E&&o.scope!==void 0||l&&!h.registration.fallback&&o.scope===void 0)continue;let c=h.registration.resolver;try{let n=Promise.resolve().then(async()=>{let g=await c.readResources?.(t,o);return g===void 0?[{resource:"*",mode:"read"}]:(await Promise.all(g.map(m=>F(m,o.cwd,"read")))).flat()}),R=await j.run(n,async()=>{let g;try{o.signal?.throwIfAborted(),g=await c.tryResolve(t,o)}catch(m){return v("RESOLVE_FAILED",D(m,`Resolver ${c.id} failed`),c.id,m)}if(!ue(g))return v("INVALID_RESOLVER_RESULT",`Resolver ${c.id} returned an invalid result`,c.id);if(g.kind!=="not-handled"){if(g.kind==="failed")return v("RESOLVE_FAILED",D(g.error,`Resolver ${c.id} failed`),c.id,g.error);try{let m=await c.format(g.payload,o);if(!fe(m))return v("FORMAT_FAILED",`Resolver ${c.id} formatter returned an invalid result`,c.id);let k=c.toScriptData?.(g.payload,m.details),ce=k===void 0;return b({content:h.registration.fallback&&f?[{type:"text",text:l?"Search fallback: empty protocol query; searched the original text.":"Search fallback: unhandled protocol query; searched the original text."},...m.content]:m.content,details:{resolverId:c.id,payload:m.details},...p==="script"&&{script:{resolverId:c.id,data:g.payload,details:m.details}},...m.usage!==void 0&&{usage:m.usage}},A,ce?{status:"error",errors:[{code:"STRUCTURED_ADAPTER_REQUIRED",message:`Search resolver ${c.id} must provide toScriptData`}]}:m.isError?{status:"error",data:k,errors:[{code:"RESOLVE_FAILED",message:`Search resolver ${c.id} returned an error`}]}:{status:"success",data:k,errors:[]})}catch(m){return v("FORMAT_FAILED",D(m,`Resolver ${c.id} formatter failed`),c.id,m)}}},o.signal);if(R!==void 0)return R}catch(n){return v("RESOLVE_FAILED",D(n,`Resolver ${c.id} failed`),c.id,n)}}let w=`No search resolver handled ${t.query}`;return Q(v("NO_RESOLVER",w),w)},runAction(t,o,p,S,l){let f=a.get(x(p,o));if(f===void 0)throw new Error(`Search reference does not support ${o}`);return f.execute(t,S,l)},renderDescriptions(){return[...d.values()].flatMap(t=>{let o=X(t);return o===void 0?[]:[o]})},renderPromptGuidelines(){return[...s.values()].flat().flatMap(t=>{let o=X(t);return o===void 0?[]:[o]})},renderer(t){return e.find(({registration:o})=>o.resolver.id===t)?.registration.resolver.renderResult}};return u}i(Z,"createSearchCore");function de(e){if(!C(e)||!C(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")}i(de,"assertResolver");function le(e){if(!C(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")}i(le,"assertAction");function C(e){return typeof e=="object"&&e!==null}i(C,"isRecord");function ue(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}i(ue,"isAttempt");function fe(e){return typeof e=="object"&&e!==null&&Array.isArray(e.content)}i(fe,"isAgentToolResult");function v(e,r,a,s){return b({isError:!0,content:[{type:"text",text:r}],details:{failure:{code:e,message:r,...a!==void 0&&{resolverId:a},...s!==void 0&&{cause:s}}}},A,{status:"error",errors:[{code:e,message:r}]})}i(v,"failure");function Y(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()}i(Y,"normalizeDescriptionSource");function X(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()}}i(X,"renderDescription");function x(e,r){return`${e}:${r}`}i(x,"actionKey");function D(e,r){return!(e instanceof Error)||e.message.trim().length===0?r:e instanceof SyntaxError?e.message:`${r}: ${e.message}`}i(D,"messageFor");import{readFile as pe}from"node:fs/promises";import he from"node:os";import I from"node:path";var ge=3e4;function re(e=process.env,r=he.homedir(),a=process.cwd()){let s=e.PI_CODING_AGENT_DIR?.trim(),d=s===void 0||s.length===0?I.join(r,".pi","agent"):I.resolve(s);return{globalPath:I.join(d,"pi-agent-ide","search.json"),projectPath:I.resolve(a,".pi","pi-agent-ide","search.json")}}i(re,"resolveSearchConfigPaths");async function te(e){let[r,a]=await Promise.all([ee(e.globalPath),ee(e.projectPath)]),s=a!==void 0?a:r;return{timeoutMs:s===void 0?ge:s}}i(te,"loadSearchConfig");async function ee(e){let r;try{r=await pe(e,"utf8")}catch(y){if(me(y))return;throw new Error(`Cannot read Pi Agent IDE search config at ${e}`,{cause:y})}let a;try{a=JSON.parse(r)}catch(y){throw new Error(`Invalid JSON in Pi Agent IDE search config at ${e}`,{cause:y})}if(!ne(a))throw new TypeError(`Pi Agent IDE search config at ${e} must be a JSON object`);let s=Object.keys(a).find(y=>y!=="timeoutMs");if(s!==void 0)throw new TypeError(`Pi Agent IDE search config at ${e} contains unknown key ${s}`);let d=a.timeoutMs;if(d==null)return d;if(typeof d!="number"||!Number.isSafeInteger(d)||d<=0)throw new TypeError(`timeoutMs must be a positive integer or null in Pi Agent IDE search config at ${e}`);return d}i(ee,"readTimeout");function me(e){return ne(e)&&e.code==="ENOENT"}i(me,"isMissingFile");function ne(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(ne,"isRecord");var oe=Symbol("search-timeout"),$=class extends Error{static{i(this,"SearchTimeoutError")}constructor(r){super(r),this.name="SearchTimeoutError"}};async function ie(e,r,a){if(e===null)return a(r);let s=new AbortController,d=r===void 0?s.signal:AbortSignal.any([r,s.signal]),y,T=new Promise(u=>{y=setTimeout(()=>{u(oe),s.abort()},e)});try{let u=await Promise.race([a(d),T]);if(u===oe)throw new $(`Search timed out after ${ye(e)}. Try a smaller path scope.`);return u}finally{clearTimeout(y)}}i(ie,"runWithSearchTimeout");function ye(e){if(e%1e3!==0)return`${String(e)}ms`;let r=e/1e3;return`${String(r)} ${r===1?"second":"seconds"}`}i(ye,"formatDuration");function we(e,r){let a=[...e.path===void 0?[]:[{text:typeof e.path=="string"?`in ${e.path}`:"in result scope",color:"accent",underline:!0,truncate:"start"}],...e.navigation===void 0?[]:[{text:"reference navigation",color:"warning"}],...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:a,details:ve(e),expanded:r}}i(we,"searchCallModel");function Re(e){return e==="full"||e==="disabled"?e:"compact"}i(Re,"parsePresentation");async function ae(e,r){let a=Re(r?.preferences["ui.search"]);N(e,[await O({id:"search-code",description:"Text search, AST patterns, symbols, graphs, and semantic rename",triggers:[{tool:"search"},{tool:"read",resourcePrefixes:["ast:","symbol:","symbols:","graph:"]}]})]);let s=Z(),d=V(e),y=new K,T=e.events.on(W,u=>{if(!J(u))throw new Error("Invalid pi-agent-search plugin registration request");u.accept(s.registerPlugin(u.plugin))});e.on("session_shutdown",T),e.registerTool(B({name:"search",exposure:"direct",namespace:{name:"ide_search",description:"Find workspace text, paths and code structures."},annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},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.",...s.renderPromptGuidelines()]},parameters:_,outputSchema:z,renderCall(u,t,o){let p=o.expanded?"full":a;return p==="disabled"?new se(t.fg("toolTitle","search"),0,0):M(o.lastComponent,we(u,p==="full"),t)},renderResult(u,t,o,p){let S=t.expanded?"full":a;if(S==="disabled"&&!p.isError&&!t.isPartial)return new se(o.fg("success","\u2713 search"),0,0);t={...t,expanded:S==="full"};let l=u.details,f=l?.resolverId===void 0?void 0:s.renderer(l.resolverId);if(f!==void 0&&l?.payload!==void 0&&!p.isError&&!t.isPartial){let w={...u,details:l.payload};return f(w,t,o,p)}return Ee(u,t,o)},async execute(u,t,o,p,S){try{let l=await te(re(process.env,Se.homedir(),S.cwd));return await ie(l.timeoutMs,o,async f=>{await s.waitForPendingPlugins();let w=t.path!==void 0&&(typeof t.path!="string"||t.path.startsWith("RESULT#")),h=w?d.resolve(t.path,S.cwd):void 0;if(h!==void 0&&(await d.verify(h,f),/^(?:files|symbol|graph|process):/u.test(t.query)))throw new Error("This query provider does not support result scopes yet.");return s.execute({...t,path:typeof t.path=="string"&&!w?t.path:void 0},{cwd:S.cwd,...h===void 0?{}:{scope:h},...f!==void 0&&{signal:f},...p!==void 0&&{onUpdate:p}})})}catch(l){if(o?.aborted)throw l;let f=l instanceof Error?l.message:String(l);return b({content:[{type:"text",text:f}],details:{failure:{code:"RESOLVE_FAILED",message:f}}},A,{status:"error",errors:[H(l,"SEARCH_FAILED")]})}}},y)),e.events.emit(U,{protocol:G,apiVersion:q}),await s.waitForPendingPlugins()}i(ae,"registerSearchCore");function ve(e){return[{label:"query",value:JSON.stringify(e.query)},...P("path",e.path===void 0?void 0:typeof e.path=="string"?e.path:"result scope"),...P("navigation",e.navigation),...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))]}i(ve,"searchCallDetails");function P(e,r){return r===void 0?[]:[{label:e,value:r}]}i(P,"optionalDetail");function Ee(e,r,a){let s=e.content.flatMap(d=>d.type==="text"?[d.text]:[]).join(`
2
+ `);return new L({summary:e.details&&typeof e.details=="object"&&"failure"in e.details?"Search failed":"Search results",rows:s.split(`
3
+ `).map(d=>({kind:"note",text:d}))},a,r.expanded)}i(Ee,"fallbackResult");export{ae as default};
package/dist/entry-51.js CHANGED
@@ -1,10 +1,12 @@
1
- import{a as S,b as _,c as D,d as U,h as M}from"./chunk-ZODCBFBL.js";import"./chunk-PLKYHUNT.js";import{a as L,b as j}from"./chunk-PJPA5EEE.js";import{a as k,b as x,c as N}from"./chunk-7WCZOO5I.js";import{a as A}from"./chunk-MGCHOGQD.js";import{a as v,b as C}from"./chunk-T6LX2RX5.js";import{a as q}from"./chunk-FBOW7XOV.js";import{a as E,b as $,d as T}from"./chunk-WJTHY6AG.js";import"./chunk-F7NVAC4Q.js";import{d as I}from"./chunk-MIZAFRDR.js";import{a as H}from"./chunk-ZTYWHL2F.js";import{a as O,b as P}from"./chunk-7UGNGK7Y.js";import"./chunk-2P2OGO3G.js";import"./chunk-ZPT5D4VP.js";import{d as b,e as w}from"./chunk-N34ATN52.js";import"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";var F={protocol:v,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 w(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 V from"node:path";import{spawn as K}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 s of G(r.include))i.push("--glob",s);for(let s of G(r.exclude))i.push("--glob",`!${s}`);return r.path!==void 0&&i.push(r.path),new Promise((s,u)=>{let a=K(S(),i,{cwd:t,stdio:["ignore","pipe","pipe"]}),f="",h="";a.stdout.setEncoding("utf8"),a.stderr.setEncoding("utf8"),a.stdout.on("data",l=>f+=l),a.stderr.on("data",l=>h+=l);let p=c(()=>{a.kill("SIGTERM")},"abort");n?.addEventListener("abort",p,{once:!0}),a.once("error",u),a.once("close",l=>{if(n?.removeEventListener("abort",p),n?.aborted===!0){u(n.reason instanceof Error?n.reason:new Error("File search aborted"));return}if(l!==0&&l!==1){u(new Error(h.trim()||`rg exited with code ${String(l)}`));return}let m=f.split(`
2
- `).filter(Boolean).map(d=>y.relative(t,y.resolve(t,d))).filter(d=>Y(d,e)).sort((d,g)=>d.localeCompare(g));s({files:m.slice(0,o),complete:m.length<=o})})})}c(B,"searchFiles");function G(e){return e?.split(",").map(r=>r.trim()).filter(Boolean)??[]}c(G,"splitGlobs");function Y(e,r){if(/[*?[\]{}]/u.test(r)){let t=r.replace(/^\.\//u,"");return y.matchesGlob(t.includes("/")?e:y.basename(e),t)}return Z(e,r)}c(Y,"matchFile");function Z(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}c(Z,"fuzzyMatch");function W(e){return X("text",e,_)}c(W,"createTextResolver");function J(e){return X("regex",e,r=>r.query.startsWith("regex:")?{...r,query:r.query.slice(6),regex:!0}:void 0)}c(J,"createRegexResolver");function Q(){return{id:"files",readResources:c((e,r)=>e.query.startsWith("files:")?[e.path??r.cwd]:[],"readResources"),toScriptData(e){let r=e;return{kind:"files",files:[...r.files],complete:r.complete}},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}}}}}c(Q,"createFileResolver");function X(e,r,t){return{readResources:c((n,o)=>t(n)===void 0?[]:[n.path??o.cwd],"readResources"),id:e,toScriptData(n,o){let i=n,s=o.sessionId;return{...I(i.matches,i.complete,s),notices:[...i.notices]}},async tryResolve(n,o){let i=t(n);if(i===void 0)return{kind:"not-handled"};let s=await D(i,o.cwd,o.signal);return{kind:"resolved",payload:{request:{...n,query:s.query},...s,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 s=i.request.limit??50,u=await r.registerIfCurrent(i.request.query,i.matches,i.complete,o.cwd,o.signal,i.recipe),a=u??{query:i.request.query,matches:i.matches,complete:i.complete};return{content:[{type:"text",text:[...i.notices,ee(a,o.cwd,s,u!==void 0)].join(`
5
- `)}],details:x(a.query,a.matches,a.complete,o.cwd,u?.id,s)}},renderResult:j}}c(X,"createMatchResolver");function ee(e,r,t,n=!0){let o=new Set(e.matches.map(p=>p.source)).size,i=e.matches.length,s=`${String(i)}${e.complete?"":"+"} ${z(i,"match","matches")} in ${String(o)} ${z(o,"file","files")}`,u=n?e.complete?`SEARCH#${e.id}:all:line / SEARCH#${e.id}:all:match \u2014 ${s}`:`${s} (limit reached; no all anchors were registered)`:`${s} (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)",u]:[u],f=new Map(e.matches.map((p,l)=>[p,l+1])),h=k(e.matches,t);for(let[p,l]of h.files.entries()){p>0&&a.push("");let m=ne(l.source,r);if(l.kind==="compacted"){a.push(`${m}: ${String(l.matchCount)} matches across ${String(l.uniqueLineCount)} unique line texts (compacted)`);for(let d of l.groups)a.push(` \xD7${String(d.matchCount)} ${re(d.text)}`);l.groups.length<l.uniqueLineCount&&a.push(` \u2026 ${String(l.uniqueLineCount-l.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 l.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,` ${te(d)}`)}}return a.join(`
6
- `)}c(ee,"formatSearchSession");function te(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":""}`}c(te,"previewMatch");function re(e){return`${e.slice(0,129)}${e.length>129?"\u2026":""}`}c(re,"previewLine");function ne(e,r){let t=V.relative(r,e);return t.length>0&&!t.startsWith("..")&&!V.isAbsolute(t)?t:e}c(ne,"displaySource");function z(e,r,t){return e===1?r:t}c(z,"plural");async function oe(e){let r=new M;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,s=Array.isArray(i)?i:await r.observeAfterEdit([t.input.path,t.input.start,t.input.end],n.signal);if(s.length!==0)return{content:[...t.content,{type:"text",text:["Original search observed after editing (not task validation):",...s.map(u=>{let{query:a,fallbacks:f,...h}=u.scope;return[`SEARCH#${u.sessionId}: ${JSON.stringify(u.query)}`,`Scope and options: ${JSON.stringify(h)}`,u.error===void 0?`Matches: ${u.matches}${u.complete===!0?"; complete search.":"+; incomplete search, lower bound only."}`:`Search failed: ${u.error}. Applied edits remain applied.`,...u.notices??[]].join(`
1
+ import{a as v,b as ee,c as te,d as re,e as ne,f as se,g as Re,k as ue}from"./chunk-PNU3E7IO.js";import"./chunk-PLKYHUNT.js";import{a as ce,b as le}from"./chunk-GBLKIB6O.js";import{a as oe,b as A,c as ae,d as ie}from"./chunk-3JO7QFIL.js";import{a as _}from"./chunk-MGCHOGQD.js";import{a as F,b as H}from"./chunk-T6LX2RX5.js";import{a as G}from"./chunk-YRF7OATP.js";import{a as M,b as j,d as B}from"./chunk-FXNKMNSJ.js";import{c as S,e as U,f as X,g as Z,h as K,i as Y}from"./chunk-AJRIASPQ.js";import{e as Q}from"./chunk-FK42RSF4.js";import{a as J}from"./chunk-ZTYWHL2F.js";import{a as V,b as W}from"./chunk-7UGNGK7Y.js";import{a as D}from"./chunk-PS2B6THP.js";import{I as L}from"./chunk-SQKAXYIR.js";import{m as I}from"./chunk-ZPT5D4VP.js";import{d as N,e as O}from"./chunk-N34ATN52.js";import"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";var de={protocol:F,apiVersion:1,id:"search-text",setup(t){t.addSetupCheck({id:"ripgrep",async inspect(s){let e=v(s.env.PI_CODING_AGENT_DIR);return await N(e,s.cwd,s.env)?{}:{actions:[{id:"ripgrep-unavailable",message:"Local search is unavailable because ripgrep was not found"}]}}}),t.addCheck({id:"ripgrep",title:"Local search",async run(s){let e=s.env.PI_CODING_AGENT_DIR,r=v(e),n=await O(r,["--version"],s.cwd,s.env);return[n.ok?{status:"pass",message:"ripgrep is available",detail:n.detail}:{status:"fail",message:"ripgrep is not available",detail:n.detail}]}})}};import k from"node:path";import{pathToFileURL as $e}from"node:url";import{readFile as we}from"node:fs/promises";async function $(t,s,e,r){if(t.include!==void 0||t.exclude!==void 0)throw new Error("Include/exclude globs are unsupported for result scopes; filter the target array instead.");let n=d(async(l,p=t.condition)=>{let h=[],f=new Set;for(let c of s.targets){if(r?.throwIfAborted(),await we(c.source,{encoding:"utf8",signal:r})!==c.expectedContent)throw new Error("Result target is stale; repeat Read/Search.");let u=I(c.source,c.expectedContent),m=[0];for(let g of u.lines)m.push((m.at(-1)??0)+g.content.length+g.lineEnding.length);for(let g of c.ranges){let y=(m[g.start.lineNumber-1]??u.content.length)+g.start.column,w=(m[g.end.lineNumber-1]??u.content.length)+g.end.column,b=await re({...t,query:l,condition:p},u.content.slice(y,w),e,r);for(let x of b.matches){let R=g.start.lineNumber+x.lineNumber-1,z=x.lineNumber===1?g.start.column:0,C={...x,source:c.source,lineNumber:R,startColumn:x.startColumn+z,endColumn:x.endColumn+z,lineText:u.lines[R-1]?.content??""},P=JSON.stringify([C.source,R,C.startColumn,C.endColumn]);f.has(P)||(f.add(P),h.push(C))}}}return h.sort((c,u)=>c.source.localeCompare(u.source)||c.lineNumber-u.lineNumber||c.startColumn-u.startColumn||c.endColumn-u.endColumn),{matches:h,complete:s.complete}},"search"),o=t.query,a=await n(o),i=[];for(let l of t.fallbacks??[]){if(a.matches.length>0||!a.complete)break;try{a=await n(l.query,l.condition),o=l.query,i.push(l.mode==="regex"?"Search fallback: no literal matches; tried unquoted terms as regex.":"Search fallback: no matches in earlier modes; tried separate words.")}catch(p){if(r?.aborted||l.mode!=="regex"||!(p instanceof Error)||!/regex parse error:|PCRE2: error compiling pattern/iu.test(p.message))throw p;i.push("Search fallback: invalid regex skipped; literal search found no matches.")}}return{...a,query:o,notices:i}}d($,"runScopedSearch");import{spawn as ve}from"node:child_process";import T from"node:path";function pe(t,s,e,r){let n=s.limit??100,o=["--files","--hidden","--no-config","--no-ignore-parent","--glob","!.git/**"];for(let a of fe(s.include))o.push("--glob",a);for(let a of fe(s.exclude))o.push("--glob",`!${a}`);return s.path!==void 0&&o.push(s.path),new Promise((a,i)=>{let l=ve(v(),o,{cwd:e,stdio:["ignore","pipe","pipe"]}),p="",h="";l.stdout.setEncoding("utf8"),l.stderr.setEncoding("utf8"),l.stdout.on("data",c=>p+=c),l.stderr.on("data",c=>h+=c);let f=d(()=>{l.kill("SIGTERM")},"abort");r?.addEventListener("abort",f,{once:!0}),l.once("error",i),l.once("close",c=>{if(r?.removeEventListener("abort",f),r?.aborted===!0){i(r.reason instanceof Error?r.reason:new Error("File search aborted"));return}if(c!==0&&c!==1){i(new Error(h.trim()||`rg exited with code ${String(c)}`));return}let u=p.split(`
2
+ `).filter(Boolean).map(m=>T.relative(e,T.resolve(e,m))).filter(m=>ze(m,t)).sort((m,g)=>m.localeCompare(g));a({files:u.slice(0,n),complete:u.length<=n})})})}d(pe,"searchFiles");function fe(t){return t?.split(",").map(s=>s.trim()).filter(Boolean)??[]}d(fe,"splitGlobs");function ze(t,s){if(/[*?[\]{}]/u.test(s)){let e=s.replace(/^\.\//u,"");return T.matchesGlob(e.includes("/")?t:T.basename(t),e)}return Ce(t,s)}d(ze,"matchFile");function Ce(t,s){if(s.length===0)return!0;let e=0,r=t.toLowerCase();for(let n of s.toLowerCase()){if(e=r.indexOf(n,e),e===-1)return!1;e+=1}return!0}d(Ce,"fuzzyMatch");import{spawn as Ae}from"node:child_process";import{stat as Te}from"node:fs/promises";async function me(t,s,e){let r=AbortSignal.timeout(S.timeoutMs),n=e===void 0?r:AbortSignal.any([e,r]);try{n.throwIfAborted();let o=await Ee(t,s,n);if(o.limited)return E("name collection reached its byte or unique-name budget");let a=[],i=0,l=new Set;for(let p of Z(t.query,o.names)){n.throwIfAborted();let h=await q({...t,query:p.identifier},s,n);if(h.matches.length===0){if(!h.complete)return E("candidate verification reached its byte budget before capturing a match");continue}for(let f of h.matches)if(!l.has(f.source)&&(l.add(f.source),i+=(await Te(f.source)).size,i>S.vocabularyBytes))return E("candidate source snapshots exceeded the byte budget");a.push({...p,...h})}return a.length===0?void 0:{status:"ready",candidates:a}}catch(o){return e?.throwIfAborted(),E(r.aborted?"extra search reached its time budget":`extra search failed: ${o instanceof Error?o.message:String(o)}`)}}d(me,"searchFuzzy");async function q(t,s,e){let r=AbortSignal.timeout(S.timeoutMs),n=e===void 0?r:AbortSignal.any([e,r]),o=await ee({...t,regex:!1,caseSensitive:!0,wholeWord:!0},s,n,{matches:S.matchesPerCandidate,bytes:S.verificationBytes});return{...o,matches:o.matches.filter(a=>a.lineText[a.startColumn-1]!=="$"&&a.lineText[a.endColumn]!=="$")}}d(q,"searchFuzzyAlternative");function E(t){return{status:"skipped",message:t,candidates:[]}}d(E,"skipped");async function Ee(t,s,e){let r=await te(t,s);return e.throwIfAborted(),new Promise((n,o)=>{let a=Ae(v(),["--only-matching","--no-filename","--case-sensitive",...r.arguments,"--","[A-Za-z_$][A-Za-z0-9_$]*",r.target],{cwd:r.cwd,stdio:["ignore","pipe","pipe"]}),i=new X,l="",p=!1,h="",f=d(()=>{a.kill()},"abort"),c=d(()=>{e.removeEventListener("abort",f)},"cleanup");a.stdout.on("data",u=>{if(!i.account(u.length)){a.kill();return}for(let m of u)if(m===10){if(p||i.add(l),l="",p=!1,i.limited){a.kill();break}}else p||(l.length===S.identifierLength?(l="",p=!0):l+=String.fromCharCode(m))}),a.stderr.setEncoding("utf8"),a.stderr.on("data",u=>{h=(h+u).slice(0,4096)}),a.once("error",u=>{c(),o(u)}),a.once("close",u=>{if(c(),e.aborted){o(e.reason);return}if(!i.limited&&u!==0&&u!==1){o(new Error(h.trim()||`ripgrep exited with code ${String(u)}`));return}n(i)}),e.addEventListener("abort",f,{once:!0}),e.aborted&&f()})}d(Ee,"collectNames");var ge="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)";function ye(t){return xe("text",t,ne)}d(ye,"createTextResolver");function Se(t){return xe("regex",t,s=>s.query.startsWith("regex:")?{...s,query:s.query.slice(6),regex:!0}:void 0)}d(Se,"createRegexResolver");function be(){return{id:"files",readResources:d((t,s)=>t.query.startsWith("files:")?[t.path??s.cwd]:[],"readResources"),toScriptData(t){let s=t;return{kind:"files",files:[...s.files],complete:s.complete}},async tryResolve(t,s){if(!t.query.startsWith("files:"))return{kind:"not-handled"};let e=t.query.slice(6).trim(),r=await pe(e,t,s.cwd,s.signal);return{kind:"resolved",payload:{query:e,...r}}},renderResult(t,s,e){let r=t.details;return new D({summary:`${r.files.length}${r.complete?"":"+"} ${r.files.length===1?"file":"files"}`,rows:r.files.length?r.files.map(n=>({kind:"source",label:n,link:$e(k.resolve(r.cwd,n)).href})):[{kind:"note",text:"No files found"}]},e,s.expanded)},format(t,s){let e=t;return{content:[{type:"text",text:[e.complete?`${String(e.files.length)} files`:`${String(e.files.length)}+ files (limit reached)`,...e.files].join(`
3
+ `)}],details:{query:e.query,files:e.files,complete:e.complete,cwd:s.cwd}}}}}d(be,"createFileResolver");function xe(t,s,e){return{readResources:d((r,n)=>e(r)===void 0?[]:n.scope?.targets.map(o=>o.source)??[r.path??n.cwd],"readResources"),id:t,supportsResultScope:!0,toScriptData(r,n){let o=r,a=n,i=a.sessionId;return{...Q(o.matches,o.complete,i,a),notices:[...o.notices],...a.fuzzy===void 0?{}:{fuzzy:a.fuzzy}}},async tryResolve(r,n){let o=e(r);if(o===void 0)return{kind:"not-handled"};let a=n.scope===void 0?await se(o,n.cwd,n.signal):await $(o,n.scope,n.cwd,n.signal),i=n.scope===void 0&&t==="text"&&a.complete&&a.matches.length===0&&U(r.query)?await me({...r,query:r.query},n.cwd,n.signal):void 0;return{kind:"resolved",payload:{request:{...r,query:a.query},...a,recipe:{...o,originalQuery:r.query},...i===void 0?{}:{fuzzy:i}}}},async format(r,n){let o=r,a=n.scope,i=await s.registerIfCurrent(o.request.query,o.matches,o.complete,n.cwd,n.signal,o.recipe,a===void 0?void 0:h=>$(o.recipe,a,n.cwd,h));if(o.fuzzy!==void 0){let h=A(o.request.query,[],o.complete,n.cwd),f=[],c=!1,u=AbortSignal.timeout(S.timeoutMs),m=n.signal===void 0?u:AbortSignal.any([n.signal,u]);for(let b of o.fuzzy.candidates){let x={...o.request,query:b.identifier,regex:!1,caseSensitive:!0,wholeWord:!0},R;try{R=await s.registerIfCurrent(b.identifier,b.matches,b.complete,n.cwd,m,x,z=>q(x,n.cwd,z),S.vocabularyBytes)}catch{n.signal?.throwIfAborted()}R===void 0&&(c=!0),f.push(K(b,R?.id,R))}let g=c?"Some candidate files changed or could not be registered; locations are shown without stable references.":o.fuzzy.message,y={status:o.fuzzy.status,...g===void 0?{}:{message:g},candidates:f},w=[...o.notices,"No matches found."];return f.some(b=>b.selection.matches[0]?.references!==void 0)&&w.push(ge),y.status==="ready"&&y.message!==void 0&&w.push(y.message),y.status==="skipped"&&w.push(`Possible-name fallback skipped: ${y.message}`),f.length>0&&w.push("Possible names \u2014 spelling suggestions, not equivalent behavior.",...f.map(Y)),{content:[{type:"text",text:w.join(`
4
+
5
+ `)}],details:{...h,...i?.target===void 0?{}:{target:i.target,matchTargets:[]},fuzzyPresentation:ae(o.fuzzy.candidates,n.cwd),fuzzy:y}}}let l=o.request.limit??50;if(o.matches.length===0)return{content:[{type:"text",text:[...o.notices,"No matches found."].join(`
6
+ `)}],details:{...A(o.request.query,[],o.complete,n.cwd),...i?.target===void 0?{}:{target:i.target,matchTargets:[]}}};let p=i??{query:o.request.query,matches:o.matches,complete:o.complete};return{content:[{type:"text",text:[...o.notices,qe(p,n.cwd,l,i!==void 0)].join(`
7
+ `)}],details:{...A(p.query,p.matches,p.complete,n.cwd,i?.id,l),...i?.target===void 0?{}:{target:i.target,matchTargets:i.matchTargets}}}},renderResult:le}}d(xe,"createMatchResolver");function qe(t,s,e,r=!0){let n=new Set(t.matches.map(f=>f.source)).size,o=t.matches.length,a=`${String(o)}${t.complete?"":"+"} ${he(o,"match","matches")} in ${String(n)} ${he(n,"file","files")}`,i=r?t.complete?`SEARCH#${t.id}:all:line / SEARCH#${t.id}:all:match \u2014 ${a}`:`${a} (limit reached; no all anchors were registered)`:`${a} (files changed during search; results shown without anchors)`,l=r?[ge,i]:[i],p=new Map(t.matches.map((f,c)=>[f,c+1])),h=oe(t.matches,e);for(let[f,c]of h.files.entries()){f>0&&l.push("");let u=Ie(c.source,s);if(c.kind==="compacted"){l.push(`${u}: ${String(c.matchCount)} matches across ${String(c.uniqueLineCount)} unique line texts (compacted)`);for(let m of c.groups)l.push(` \xD7${String(m.matchCount)} ${Pe(m.text)}`);c.groups.length<c.uniqueLineCount&&l.push(` \u2026 ${String(c.uniqueLineCount-c.groups.length)} more unique line texts`),l.push(` Search again with path: ${JSON.stringify(u)} and a narrower query to see individual matches.`);continue}for(let m of c.matches){let g=p.get(m);if(g===void 0)continue;let y=`${u}:${String(m.lineNumber)}:${String(m.startColumn+1)}-${String(m.endColumn+1)}`;l.push(r?`${y} SEARCH#${t.id}:${String(g)}:line SEARCH#${t.id}:${String(g)}:match`:y,` ${ke(m)}`)}}return l.join(`
8
+ `)}d(qe,"formatSearchSession");function ke(t){let e=Math.max(0,t.startColumn-64),r=Math.min(t.lineText.length,t.endColumn+64);return`${e>0?"\u2026":""}${t.lineText.slice(e,t.startColumn)}\u27E6${t.lineText.slice(t.startColumn,t.endColumn)}\u27E7${t.lineText.slice(t.endColumn,r)}${r<t.lineText.length?"\u2026":""}`}d(ke,"previewMatch");function Pe(t){return`${t.slice(0,129)}${t.length>129?"\u2026":""}`}d(Pe,"previewLine");function Ie(t,s){let e=k.relative(s,t);return e.length>0&&!e.startsWith("..")&&!k.isAbsolute(e)?e:t}d(Ie,"displaySource");function he(t,s,e){return t===1?s:e}d(he,"plural");async function Ne(t){let s=new ue(void 0,L(t));t.on("tool_result",async(e,r)=>{if(e.toolName!=="replace"||e.isError||typeof e.details!="object"||e.details===null)return;let n="metadata"in e.details?e.details.metadata:void 0,o=n&&typeof n=="object"&&"searchObservations"in n?n.searchObservations:void 0,a=Array.isArray(o)?o:await s.observeAfterEdit([e.input.path,e.input.start,e.input.end],r.signal);if(a.length!==0)return{content:[...e.content,{type:"text",text:["Original search observed after editing (not task validation):",...a.map(i=>{let{query:l,fallbacks:p,...h}=i.scope;return[`SEARCH#${i.sessionId}: ${JSON.stringify(i.query)}`,`Scope and options: ${JSON.stringify(h)}`,i.error===void 0?`Matches: ${i.matches}${i.complete===!0?"; complete search.":"+; incomplete search, lower bound only."}`:`Search failed: ${i.error}. Applied edits remain applied.`,...i.notices??[]].join(`
7
9
  `)})].join(`
8
- `)}],details:{...t.details,searchObservations:s},...t.structuredContent===void 0?{}:{structuredContent:t.structuredContent}}}),e.on("tool_result",t=>{if(t.toolName!=="search"||typeof t.details!="object"||t.details===null)return;let n=t.details;if(N(n.payload))return{details:{...n,payload:L(n.payload,t.content.flatMap(o=>o.type==="text"?[o.text]:[]).join(`
9
- `))}}}),await Promise.all([A(e,F),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:W(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:E,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})}})])}c(oe,"registerTextSearch");export{U as createSearchSessionId,oe as default};
10
+ `)}],details:{...e.details,searchObservations:a},...e.structuredContent===void 0?{}:{structuredContent:e.structuredContent}}}),t.on("tool_result",e=>{if(e.toolName!=="search"||typeof e.details!="object"||e.details===null)return;let r=e.details;if(ie(r.payload))return{details:{...r,payload:ce(r.payload,e.content.flatMap(n=>n.type==="text"?[n.text]:[]).join(`
11
+ `))}}}),await Promise.all([_(t,de),J(t,{protocol:V,apiVersion:W,id:"local",setup(e){e.addSelectionProvider((r,n)=>s.register(r.request.query,r.matches,r.complete,n.cwd,n.signal,{...r.request,regex:!1},r.refresh)),e.addResolver({resolver:Se(s),priority:-10}),e.addResolver({resolver:be(),priority:-10}),e.addResolver({resolver:ye(s),fallback:!0}),e.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.","After a complete zero result, a single unquoted ASCII identifier may produce separate possible-name groups: naming-style changes, one leading/trailing component, then small typos. Each group reports a verified case-sensitive whole-identifier alternative in the same scope, its count/completeness, and Read references. Budget skips are explicit. A candidate all-reference refreshes that exact alternative, not the fuzzy ranking. Registered local candidate selections also expose strict snapshot targets. Structured result scopes stay exact and do not run this extra branch.","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(`
12
+ `))}}),G(t,{protocol:M,apiVersion:j,id:"search-anchors",setup(e){e.tool("replace").addHandler({stage:"text-post-edit",async handler(r){if(!r.result||typeof r.result!="object"||!("kind"in r.result)||r.result.kind!=="completed"||!r.input||typeof r.input!="object")return r;let n=r.input,o=await s.observeAfterEdit([n.path,n.start,n.end],r.signal);return o.length===0?r:{...r,metadata:{...r.metadata,searchObservations:o}}}}),e.addAnchorResolver({resolver:s.anchorResolver(),resources:s.resourceResolver(),kind:B,type:"auxiliary",describeInPrompt:!1})}})])}d(Ne,"registerTextSearch");export{Re as createSearchSessionId,Ne as default};
package/dist/entry-52.js CHANGED
@@ -1 +1 @@
1
- import{d as a,e as b,f as c,g as d,h as e}from"./chunk-ZODCBFBL.js";import"./chunk-PLKYHUNT.js";import"./chunk-ZPT5D4VP.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{g as a,h as b,i as c,j as d,k as e}from"./chunk-PNU3E7IO.js";import"./chunk-PLKYHUNT.js";import"./chunk-ZPT5D4VP.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{b as a,c as b}from"./chunk-PJPA5EEE.js";import"./chunk-7WCZOO5I.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{b as SearchResultPanel,a as renderSearchResult};
1
+ import{b as a,c as b}from"./chunk-GBLKIB6O.js";import"./chunk-3JO7QFIL.js";import"./chunk-AJRIASPQ.js";import"./chunk-FK42RSF4.js";import"./chunk-PS2B6THP.js";import"./chunk-SQKAXYIR.js";import"./chunk-ZPT5D4VP.js";import"./chunk-EI7MMDWY.js";export{b as SearchResultPanel,a as renderSearchResult};
package/dist/entry-54.js CHANGED
@@ -1 +1 @@
1
- import{b as a,c as b}from"./chunk-7WCZOO5I.js";import"./chunk-EI7MMDWY.js";export{a as createSearchToolDetails,b as isSearchToolDetails};
1
+ import{b as a,c as b,d as c}from"./chunk-3JO7QFIL.js";import"./chunk-AJRIASPQ.js";import"./chunk-FK42RSF4.js";import"./chunk-PS2B6THP.js";import"./chunk-SQKAXYIR.js";import"./chunk-EI7MMDWY.js";export{b as createFuzzyPresentation,a as createSearchToolDetails,c as isSearchToolDetails};
package/dist/entry-56.js CHANGED
@@ -1 +1 @@
1
- import{a as d}from"./chunk-FBOW7XOV.js";import{a as s,b as l,c}from"./chunk-WJTHY6AG.js";import"./chunk-2P2OGO3G.js";import{a as i}from"./chunk-ZPT5D4VP.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 d}from"./chunk-YRF7OATP.js";import{a as s,b as l,c}from"./chunk-FXNKMNSJ.js";import"./chunk-SQKAXYIR.js";import{a as i}from"./chunk-ZPT5D4VP.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-58.js CHANGED
@@ -1 +1 @@
1
- import{a as m}from"./chunk-EDURPQAV.js";import"./chunk-PLKYHUNT.js";import{a as f}from"./chunk-FBOW7XOV.js";import{a as c,b as u,d as s}from"./chunk-WJTHY6AG.js";import"./chunk-2P2OGO3G.js";import"./chunk-ZPT5D4VP.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{a as m}from"./chunk-EDURPQAV.js";import"./chunk-PLKYHUNT.js";import{a as f}from"./chunk-YRF7OATP.js";import{a as c,b as u,d as s}from"./chunk-FXNKMNSJ.js";import"./chunk-SQKAXYIR.js";import"./chunk-ZPT5D4VP.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-60.js CHANGED
@@ -1 +1 @@
1
- import{b as x,e as T}from"./chunk-KZC7TI5M.js";import{a as P}from"./chunk-FBOW7XOV.js";import{a as u,b as h,c as f}from"./chunk-WJTHY6AG.js";import{a as l}from"./chunk-6CZO43OH.js";import{a as d,b as m}from"./chunk-OBNING2A.js";import"./chunk-2P2OGO3G.js";import{i as p}from"./chunk-ZPT5D4VP.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{b as x,e as T}from"./chunk-KZC7TI5M.js";import{a as P}from"./chunk-YRF7OATP.js";import{a as u,b as h,c as f}from"./chunk-FXNKMNSJ.js";import{a as l}from"./chunk-6CZO43OH.js";import{a as d,b as m}from"./chunk-OBNING2A.js";import"./chunk-SQKAXYIR.js";import{i as p}from"./chunk-ZPT5D4VP.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 +0,0 @@
1
- import"./chunk-6EYWFBNG.js";import{i as a,k as b}from"./chunk-BAYETTZZ.js";import"./chunk-7AVXUV4A.js";import"./chunk-FZBCKIJJ.js";import"./chunk-NNCZYO4Q.js";import"./chunk-BSICWXMH.js";import"./chunk-YHUTTZC6.js";import"./chunk-2P2OGO3G.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as createApplyCallRenderer,b as createApplyResultRenderer};
package/dist/entry-62.js CHANGED
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-YRF7OATP.js";import"./chunk-FXNKMNSJ.js";import"./chunk-SQKAXYIR.js";import"./chunk-ZPT5D4VP.js";import"./chunk-EI7MMDWY.js";export{a as connectTextEditorPlugin};
package/dist/entry-63.js CHANGED
@@ -1 +0,0 @@
1
- import{a}from"./chunk-FBOW7XOV.js";import"./chunk-WJTHY6AG.js";import"./chunk-2P2OGO3G.js";import"./chunk-ZPT5D4VP.js";import"./chunk-EI7MMDWY.js";export{a as connectTextEditorPlugin};
package/dist/entry-64.js CHANGED
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-U22JNO6N.js";import"./chunk-EI7MMDWY.js";export{a as isTextEditHandlerRegistration};
package/dist/entry-65.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-U22JNO6N.js";import"./chunk-EI7MMDWY.js";export{a as isTextEditHandlerRegistration};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-FXNKMNSJ.js";import"./chunk-SQKAXYIR.js";import"./chunk-ZPT5D4VP.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-66.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-WJTHY6AG.js";import"./chunk-2P2OGO3G.js";import"./chunk-ZPT5D4VP.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{a}from"./chunk-MBUXFKIW.js";import"./chunk-EI7MMDWY.js";export{a as formatStaleAnchorMessage};
package/dist/entry-67.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-MBUXFKIW.js";import"./chunk-EI7MMDWY.js";export{a as formatStaleAnchorMessage};
1
+ import{a}from"./chunk-PLKYHUNT.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as TextSelectionAnchor};
package/dist/entry-68.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-PLKYHUNT.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as TextSelectionAnchor};
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-KR36BT5E.js";import"./chunk-FXNKMNSJ.js";import"./chunk-SQKAXYIR.js";import"./chunk-ZPT5D4VP.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-69.js CHANGED
@@ -1 +1 @@
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-VBICI5YA.js";import"./chunk-WJTHY6AG.js";import"./chunk-2P2OGO3G.js";import"./chunk-ZPT5D4VP.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};
1
+ import{a}from"./chunk-YGGKGZO2.js";import"./chunk-EI7MMDWY.js";export{a as NATIVE_EDIT_BATCH_EVENT};
package/dist/entry-70.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-YGGKGZO2.js";import"./chunk-EI7MMDWY.js";export{a as NATIVE_EDIT_BATCH_EVENT};
1
+ import{a,b,d as c}from"./chunk-EAZGN5ND.js";import{a as d,b as e,d as f}from"./chunk-VCGNVTXQ.js";import"./chunk-SQKAXYIR.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{b as FileMutationResult,a as FileRange,c as computeChangedRanges,d as mutationDataSchema,e as mutationOutputSchema,f as structuredMutation};