pi-agent-ide 0.1.1 → 0.2.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 (670) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +11 -5
  3. package/dist/chunk-266RH77Z.js +1 -0
  4. package/dist/chunk-2SKAED2I.js +2 -0
  5. package/dist/chunk-2ZMYT6ZC.js +1 -0
  6. package/dist/chunk-34ZQTTU2.js +2 -0
  7. package/dist/chunk-3H2EU7VQ.js +0 -0
  8. package/dist/chunk-3YK4XMWB.js +0 -0
  9. package/dist/chunk-476MR2QB.js +1 -0
  10. package/dist/chunk-4KQOODGE.js +13 -0
  11. package/dist/chunk-4SQQKEVD.js +16 -0
  12. package/dist/chunk-52BM6J6I.js +6 -0
  13. package/dist/chunk-5A25RATC.js +3 -0
  14. package/dist/chunk-5BWUVAR4.js +1 -0
  15. package/dist/chunk-6DN7NO7L.js +1 -0
  16. package/dist/chunk-6SMFVLTY.js +1 -0
  17. package/dist/chunk-7NDBZ4WX.js +1 -0
  18. package/dist/chunk-AP7Z3VWC.js +1 -0
  19. package/dist/chunk-BYWAG6X3.js +6 -0
  20. package/dist/chunk-DEP55R35.js +1 -0
  21. package/dist/chunk-E2RESHYR.js +1 -0
  22. package/dist/chunk-E4SECPF4.js +1 -0
  23. package/dist/chunk-EEH4WYI7.js +1 -0
  24. package/dist/chunk-EI7MMDWY.js +1 -0
  25. package/dist/chunk-ERVMDQGX.js +1 -0
  26. package/dist/chunk-EW2KVKCN.js +2 -0
  27. package/dist/chunk-F6SESI3P.js +4 -0
  28. package/dist/chunk-GTK5AREE.js +2 -0
  29. package/dist/chunk-HOBTFFQR.js +1 -0
  30. package/dist/chunk-IMVCVPMP.js +3 -0
  31. package/dist/chunk-IOCABSRL.js +1 -0
  32. package/dist/chunk-JASLOB2X.js +1 -0
  33. package/dist/chunk-JMVDFOTQ.js +1 -0
  34. package/dist/chunk-K4ZMRDEI.js +0 -0
  35. package/dist/chunk-KINKBPPX.js +1 -0
  36. package/dist/chunk-KNMWCDDK.js +7 -0
  37. package/dist/chunk-KP37XTDI.js +1 -0
  38. package/dist/chunk-KYVOMBO5.js +1 -0
  39. package/dist/chunk-KZBAJFCV.js +1 -0
  40. package/dist/chunk-LFV6G5Z3.js +1 -0
  41. package/dist/chunk-MB6VVVAF.js +2 -0
  42. package/dist/chunk-MBUXFKIW.js +3 -0
  43. package/dist/chunk-MTTKFJV6.js +1 -0
  44. package/dist/chunk-NI2NK4JU.js +1 -0
  45. package/dist/chunk-NNCZYO4Q.js +0 -0
  46. package/dist/chunk-OBWZ5RYN.js +1 -0
  47. package/dist/chunk-OIL6BB2S.js +33 -0
  48. package/dist/chunk-ORAPGW7W.js +1 -0
  49. package/dist/chunk-OVUYPHDE.js +1 -0
  50. package/dist/chunk-PETQCA7G.js +1 -0
  51. package/dist/chunk-PODWLGNO.js +6 -0
  52. package/dist/chunk-QNZVPFSP.js +3 -0
  53. package/dist/chunk-QW5O42QJ.js +2 -0
  54. package/dist/chunk-SJYDLHEF.js +108 -0
  55. package/dist/chunk-SSZB66C3.js +3 -0
  56. package/dist/chunk-STUZZM5B.js +1 -0
  57. package/dist/chunk-T2RPMEM2.js +1 -0
  58. package/dist/chunk-TG6H6EOI.js +1 -0
  59. package/dist/chunk-TNWYEXFG.js +1 -0
  60. package/dist/chunk-U4D6FT66.js +1 -0
  61. package/dist/chunk-VCCMVQXU.js +1 -0
  62. package/dist/chunk-VFBLX4TG.js +1 -0
  63. package/dist/chunk-VSP2QQPQ.js +2 -0
  64. package/dist/chunk-VUNCBASK.js +10 -0
  65. package/dist/chunk-VWVLBOMU.js +8 -0
  66. package/dist/chunk-W3XYKJ5H.js +1 -0
  67. package/dist/chunk-XGUAL3CA.js +1 -0
  68. package/dist/chunk-XNXQYPVT.js +10 -0
  69. package/dist/chunk-YHUTTZC6.js +2 -0
  70. package/dist/chunk-YPHXLAQF.js +1 -0
  71. package/dist/chunk-YQTLJ5ZV.js +58 -0
  72. package/dist/chunk-ZC65Z3CK.js +1 -0
  73. package/dist/entry-0.js +1 -0
  74. package/dist/entry-1.js +1 -0
  75. package/dist/entry-10.js +1 -0
  76. package/dist/entry-11.js +1 -0
  77. package/dist/entry-12.js +1 -0
  78. package/dist/entry-13.js +1 -0
  79. package/dist/entry-14.js +1 -0
  80. package/dist/entry-16.js +1 -0
  81. package/dist/entry-17.js +1 -0
  82. package/dist/entry-18.js +1 -0
  83. package/dist/entry-19.js +1 -0
  84. package/dist/entry-2.js +1 -0
  85. package/dist/entry-20.js +1 -0
  86. package/dist/entry-21.js +1 -0
  87. package/dist/entry-22.js +1 -0
  88. package/dist/entry-23.js +1 -0
  89. package/dist/entry-24.js +1 -0
  90. package/dist/entry-25.js +1 -0
  91. package/dist/entry-26.js +1 -0
  92. package/dist/entry-27.js +1 -0
  93. package/dist/entry-28.js +1 -0
  94. package/dist/entry-29.js +1 -0
  95. package/dist/entry-3.js +1 -0
  96. package/dist/entry-30.js +1 -0
  97. package/dist/entry-31.js +1 -0
  98. package/dist/entry-32.js +1 -0
  99. package/dist/entry-33.js +1 -0
  100. package/dist/entry-34.js +1 -0
  101. package/dist/entry-35.js +1 -0
  102. package/dist/entry-36.js +1 -0
  103. package/dist/entry-37.js +1 -0
  104. package/dist/entry-38.js +1 -0
  105. package/dist/entry-39.js +1 -0
  106. package/dist/entry-4.js +1 -0
  107. package/dist/entry-40.js +1 -0
  108. package/dist/entry-41.js +1 -0
  109. package/dist/entry-42.js +1 -0
  110. package/dist/entry-43.js +1 -0
  111. package/dist/entry-44.js +1 -0
  112. package/dist/entry-45.js +1 -0
  113. package/dist/entry-46.js +1 -0
  114. package/dist/entry-47.js +1 -0
  115. package/dist/entry-48.js +1 -0
  116. package/dist/entry-49.js +1 -0
  117. package/dist/entry-5.js +1 -0
  118. package/dist/entry-50.js +1 -0
  119. package/dist/entry-51.js +1 -0
  120. package/dist/entry-52.js +1 -0
  121. package/dist/entry-53.js +0 -0
  122. package/dist/entry-54.js +1 -0
  123. package/dist/entry-55.js +0 -0
  124. package/dist/entry-56.js +1 -0
  125. package/dist/entry-57.js +1 -0
  126. package/dist/entry-58.js +1 -0
  127. package/dist/entry-59.js +1 -0
  128. package/dist/entry-6.js +1 -0
  129. package/dist/entry-60.js +1 -0
  130. package/dist/entry-61.js +1 -0
  131. package/dist/entry-62.js +0 -0
  132. package/dist/entry-63.js +1 -0
  133. package/dist/entry-64.js +0 -0
  134. package/dist/entry-65.js +1 -0
  135. package/dist/entry-66.js +1 -0
  136. package/dist/entry-67.js +1 -0
  137. package/dist/entry-68.js +1 -0
  138. package/dist/entry-69.js +1 -0
  139. package/dist/entry-7.js +1 -0
  140. package/dist/entry-70.js +1 -0
  141. package/dist/entry-71.js +1 -0
  142. package/dist/entry-72.js +1 -0
  143. package/dist/entry-73.js +1 -0
  144. package/dist/entry-74.js +1 -0
  145. package/dist/entry-75.js +1 -0
  146. package/dist/entry-76.js +1 -0
  147. package/dist/entry-77.js +1 -0
  148. package/dist/entry-78.js +1 -0
  149. package/dist/entry-79.js +1 -0
  150. package/dist/entry-8.js +1 -0
  151. package/dist/entry-9.js +1 -0
  152. package/dist/pi-agent-ide.js +13 -0
  153. package/docs/architecture.md +21 -17
  154. package/docs/configuration.md +149 -52
  155. package/docs/development.md +105 -5
  156. package/docs/extensions.md +64 -4
  157. package/docs/generated/tool-catalog/css.md +7 -6
  158. package/docs/generated/tool-catalog/html.md +6 -5
  159. package/docs/generated/tool-catalog/javascript.md +8 -6
  160. package/docs/generated/tool-catalog/json.md +7 -6
  161. package/docs/generated/tool-catalog/markdown.md +6 -5
  162. package/docs/generated/tool-catalog/toml.md +6 -5
  163. package/docs/generated/tool-catalog/typescript.md +8 -6
  164. package/docs/generated/tool-catalog/yaml.md +6 -5
  165. package/docs/tools.md +88 -6
  166. package/node_modules/pi-agent-doctor/package.json +8 -5
  167. package/node_modules/pi-agent-doctor/runtime/entry-16.js +1 -0
  168. package/node_modules/pi-agent-doctor/runtime/entry-17.js +1 -0
  169. package/node_modules/pi-agent-doctor/runtime/entry-18.js +1 -0
  170. package/node_modules/pi-agent-doctor/runtime/entry-19.js +1 -0
  171. package/node_modules/pi-agent-doctor/src/executable.ts +33 -0
  172. package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +30 -4
  173. package/node_modules/pi-agent-filesystem/index.ts +4 -3
  174. package/node_modules/pi-agent-filesystem/package.json +7 -7
  175. package/node_modules/pi-agent-filesystem/runtime/entry-20.js +2 -0
  176. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  177. package/node_modules/pi-agent-filesystem-image/runtime/entry-21.js +2 -0
  178. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  179. package/node_modules/pi-agent-filesystem-pdf/runtime/entry-22.js +2 -0
  180. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  181. package/node_modules/pi-agent-filesystem-text/runtime/entry-23.js +2 -0
  182. package/node_modules/pi-agent-ide-ast/package.json +11 -10
  183. package/node_modules/pi-agent-ide-ast/runtime/entry-24.js +1 -0
  184. package/node_modules/pi-agent-ide-ast/runtime/entry-25.js +2 -0
  185. package/node_modules/pi-agent-ide-ast/src/api/scope.ts +1 -1
  186. package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +1 -1
  187. package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +25 -0
  188. package/node_modules/pi-agent-ide-ast/src/extension.ts +13 -5
  189. package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +6 -0
  190. package/node_modules/pi-agent-ide-changes/index.ts +6 -2
  191. package/node_modules/pi-agent-ide-changes/package.json +8 -7
  192. package/node_modules/pi-agent-ide-changes/runtime/entry-26.js +1 -0
  193. package/node_modules/pi-agent-ide-changes/runtime/entry-27.js +2 -0
  194. package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +6 -0
  195. package/node_modules/pi-agent-ide-changes/src/changes/change-groups.ts +1 -1
  196. package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +1 -1
  197. package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +1 -0
  198. package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +1 -1
  199. package/node_modules/pi-agent-ide-changes/src/doctor-plugin.ts +31 -1
  200. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +5 -0
  201. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +7 -0
  202. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  203. package/node_modules/pi-agent-ide-formatter/runtime/entry-28.js +2 -0
  204. package/node_modules/pi-agent-ide-formatter/src/catalog.ts +34 -0
  205. package/node_modules/pi-agent-ide-formatter/src/doctor-plugin.ts +115 -63
  206. package/node_modules/pi-agent-ide-formatter/src/registry.ts +71 -28
  207. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  208. package/node_modules/pi-agent-ide-languages/runtime/entry-29.js +2 -0
  209. package/node_modules/pi-agent-ide-lint/index.ts +30 -155
  210. package/node_modules/pi-agent-ide-lint/package.json +8 -7
  211. package/node_modules/pi-agent-ide-lint/runtime/entry-30.js +2 -0
  212. package/node_modules/pi-agent-ide-lint/src/catalog.ts +14 -2
  213. package/node_modules/pi-agent-ide-lint/src/command-linter.ts +60 -4
  214. package/node_modules/pi-agent-ide-lint/src/diagnostics.ts +3 -1
  215. package/node_modules/pi-agent-ide-lint/src/doctor-plugin.ts +115 -64
  216. package/node_modules/pi-agent-ide-lint/src/registry.ts +72 -27
  217. package/node_modules/pi-agent-ide-lsp/index.ts +35 -134
  218. package/node_modules/pi-agent-ide-lsp/package.json +9 -8
  219. package/node_modules/pi-agent-ide-lsp/runtime/entry-31.js +2 -0
  220. package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +1 -1
  221. package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +113 -0
  222. package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +108 -53
  223. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +94 -27
  224. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +2 -1
  225. package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +76 -0
  226. package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +137 -144
  227. package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +2 -2
  228. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +9 -32
  229. package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +86 -50
  230. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +1 -0
  231. package/node_modules/pi-agent-ide-lsp/src/lsp/types.ts +8 -6
  232. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +5 -5
  233. package/node_modules/pi-agent-image/package.json +3 -3
  234. package/node_modules/pi-agent-image/runtime/entry-32.js +1 -0
  235. package/node_modules/pi-agent-invariant/package.json +12 -0
  236. package/node_modules/pi-agent-invariant/runtime/entry-33.js +1 -0
  237. package/node_modules/pi-agent-pdf/package.json +3 -3
  238. package/node_modules/pi-agent-pdf/runtime/entry-34.js +1 -0
  239. package/node_modules/pi-agent-pdf/src/pdf-converter.ts +3 -2
  240. package/node_modules/pi-agent-read/package.json +11 -9
  241. package/node_modules/pi-agent-read/runtime/entry-35.js +1 -0
  242. package/node_modules/pi-agent-read/runtime/entry-36.js +1 -0
  243. package/node_modules/pi-agent-read/runtime/entry-37.js +1 -0
  244. package/node_modules/pi-agent-read/runtime/entry-38.js +1 -0
  245. package/node_modules/pi-agent-read/runtime/entry-39.js +2 -0
  246. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  247. package/node_modules/pi-agent-read/src/api/tools/read.ts +113 -2
  248. package/node_modules/pi-agent-read/src/core/extension.ts +19 -0
  249. package/node_modules/pi-agent-read/src/core/read-core.ts +85 -13
  250. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +26 -10
  251. package/node_modules/pi-agent-read/src/core/tools/read/persisted-result.ts +72 -0
  252. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +102 -12
  253. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +27 -3
  254. package/node_modules/pi-agent-read/src/core/tools/read/views.ts +29 -0
  255. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +532 -46
  256. package/node_modules/pi-agent-resource/package.json +5 -2
  257. package/node_modules/pi-agent-resource/runtime/entry-40.js +1 -0
  258. package/node_modules/pi-agent-resource/src/content-conversion/content-converter.ts +1 -1
  259. package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +1 -1
  260. package/node_modules/pi-agent-resource/src/content-conversion/content-runner.ts +1 -1
  261. package/node_modules/pi-agent-resource/src/content-conversion/validation.ts +1 -1
  262. package/node_modules/pi-agent-search/package.json +7 -6
  263. package/node_modules/pi-agent-search/runtime/entry-41.js +1 -0
  264. package/node_modules/pi-agent-search/runtime/entry-42.js +1 -0
  265. package/node_modules/pi-agent-search/runtime/entry-43.js +1 -0
  266. package/node_modules/pi-agent-search/runtime/entry-44.js +2 -0
  267. package/node_modules/pi-agent-search/src/api/search.ts +4 -0
  268. package/node_modules/pi-agent-search/src/core/extension.ts +99 -27
  269. package/node_modules/pi-agent-search/src/core/search-config.ts +98 -0
  270. package/node_modules/pi-agent-search/src/core/search-core.ts +32 -28
  271. package/node_modules/pi-agent-search/src/core/search-timeout.ts +54 -0
  272. package/node_modules/pi-agent-search-text/index.ts +53 -3
  273. package/node_modules/pi-agent-search-text/package.json +9 -9
  274. package/node_modules/pi-agent-search-text/runtime/entry-45.js +2 -0
  275. package/node_modules/pi-agent-search-text/runtime/entry-46.js +1 -0
  276. package/node_modules/pi-agent-search-text/src/doctor-plugin.ts +20 -1
  277. package/node_modules/pi-agent-search-text/src/persisted-result.ts +56 -0
  278. package/node_modules/pi-agent-search-text/src/resolvers.ts +36 -34
  279. package/node_modules/pi-agent-search-text/src/search-query.ts +254 -71
  280. package/node_modules/pi-agent-search-text/src/search-recipe.ts +68 -0
  281. package/node_modules/pi-agent-search-text/src/search-renderer.ts +71 -117
  282. package/node_modules/pi-agent-search-text/src/search-result.ts +1 -0
  283. package/node_modules/pi-agent-search-text/src/search-session.ts +276 -110
  284. package/node_modules/pi-agent-text/package.json +6 -3
  285. package/node_modules/pi-agent-text/runtime/entry-47.js +1 -0
  286. package/node_modules/pi-agent-text/src/index.ts +23 -0
  287. package/node_modules/pi-agent-text/src/stored-text.ts +14 -0
  288. package/node_modules/pi-agent-text/src/text-anchor.ts +160 -16
  289. package/node_modules/pi-agent-text/src/text-document.ts +26 -5
  290. package/node_modules/pi-agent-text/src/text-target.ts +105 -0
  291. package/node_modules/pi-agent-text-anchor-constant/package.json +7 -4
  292. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-48.js +2 -0
  293. package/node_modules/pi-agent-text-anchor-constant/src/resolver.ts +6 -0
  294. package/node_modules/pi-agent-text-anchor-exact/index.ts +34 -0
  295. package/node_modules/pi-agent-text-anchor-exact/package.json +27 -0
  296. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-49.js +1 -0
  297. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-50.js +2 -0
  298. package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +230 -0
  299. package/node_modules/pi-agent-text-anchor-exact/src/config.ts +159 -0
  300. package/node_modules/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +100 -0
  301. package/node_modules/pi-agent-text-anchor-exact/src/recovery.ts +151 -0
  302. package/node_modules/pi-agent-text-anchor-line-hash/index.ts +8 -2
  303. package/node_modules/pi-agent-text-anchor-line-hash/package.json +10 -6
  304. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-51.js +1 -0
  305. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-52.js +2 -0
  306. package/node_modules/pi-agent-text-anchor-line-hash/src/anchor.ts +32 -1
  307. package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +20 -12
  308. package/node_modules/pi-agent-text-editor/package.json +22 -21
  309. package/node_modules/pi-agent-text-editor/runtime/entry-53.js +1 -0
  310. package/node_modules/pi-agent-text-editor/runtime/entry-54.js +1 -0
  311. package/node_modules/pi-agent-text-editor/runtime/entry-55.js +1 -0
  312. package/node_modules/pi-agent-text-editor/runtime/entry-56.js +1 -0
  313. package/node_modules/pi-agent-text-editor/runtime/entry-57.js +1 -0
  314. package/node_modules/pi-agent-text-editor/runtime/entry-58.js +1 -0
  315. package/node_modules/pi-agent-text-editor/runtime/entry-59.js +1 -0
  316. package/node_modules/pi-agent-text-editor/runtime/entry-60.js +1 -0
  317. package/node_modules/pi-agent-text-editor/runtime/entry-61.js +1 -0
  318. package/node_modules/pi-agent-text-editor/runtime/entry-62.js +1 -0
  319. package/node_modules/pi-agent-text-editor/runtime/entry-63.js +1 -0
  320. package/node_modules/pi-agent-text-editor/runtime/entry-64.js +1 -0
  321. package/node_modules/pi-agent-text-editor/runtime/entry-65.js +1 -0
  322. package/node_modules/pi-agent-text-editor/runtime/entry-66.js +1 -0
  323. package/node_modules/pi-agent-text-editor/runtime/entry-67.js +1 -0
  324. package/node_modules/pi-agent-text-editor/runtime/entry-68.js +2 -0
  325. package/node_modules/pi-agent-text-editor/src/api/anchor-inspection.ts +2 -0
  326. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +1 -0
  327. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +38 -0
  328. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +30 -15
  329. package/node_modules/pi-agent-text-editor/src/api/text-selection-anchor.ts +10 -13
  330. package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -1
  331. package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +12 -5
  332. package/node_modules/pi-agent-text-editor/src/core/extension.ts +15 -1
  333. package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +14 -10
  334. package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +1 -1
  335. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +3 -2
  336. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +19 -2
  337. package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +64 -0
  338. package/node_modules/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +1 -1
  339. package/node_modules/pi-agent-text-editor/src/core/read-fragment-resolver.ts +83 -0
  340. package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +96 -8
  341. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +4 -1
  342. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +1 -1
  343. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +194 -35
  344. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +43 -13
  345. package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +95 -0
  346. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +75 -5
  347. package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +7 -0
  348. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +541 -130
  349. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +5 -9
  350. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +2 -0
  351. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +228 -6
  352. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +50 -70
  353. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +25 -26
  354. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +30 -21
  355. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +57 -71
  356. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +30 -27
  357. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -0
  358. package/node_modules/pi-agent-text-editor-argument-order/package.json +3 -3
  359. package/node_modules/pi-agent-text-editor-argument-order/runtime/entry-69.js +2 -0
  360. package/node_modules/pi-agent-text-editor-overwrite/index.ts +1 -1
  361. package/node_modules/pi-agent-text-editor-overwrite/package.json +4 -3
  362. package/node_modules/pi-agent-text-editor-overwrite/runtime/entry-70.js +2 -0
  363. package/node_modules/pi-agent-text-editor-renderer/index.ts +21 -1
  364. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -3
  365. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-71.js +2 -0
  366. package/node_modules/pi-agent-text-editor-renderer/src/animation-pressure.ts +50 -0
  367. package/node_modules/pi-agent-text-editor-renderer/src/config.ts +73 -0
  368. package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +1 -1
  369. package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +77 -22
  370. package/node_modules/pi-agent-text-editor-renderer/src/diff-theme.ts +1 -1
  371. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +140 -24
  372. package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +274 -43
  373. package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +33 -6
  374. package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +47 -0
  375. package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +7 -0
  376. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +265 -105
  377. package/node_modules/pi-agent-text-editor-renderer/src/typing-interpolation.ts +96 -15
  378. package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +22 -6
  379. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -4
  380. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-72.js +2 -0
  381. package/node_modules/pi-agent-tool-call-interception/package.json +5 -2
  382. package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +1 -0
  383. package/node_modules/pi-agent-tool-call-interception/src/index.ts +175 -32
  384. package/node_modules/pi-agent-tool-ui/package.json +15 -0
  385. package/node_modules/pi-agent-tool-ui/runtime/entry-74.js +1 -0
  386. package/node_modules/pi-agent-tool-ui/src/index.ts +318 -0
  387. package/node_modules/pi-agent-web/index.ts +16 -6
  388. package/node_modules/pi-agent-web/package.json +8 -6
  389. package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
  390. package/node_modules/pi-agent-web/src/browser-loader.ts +180 -0
  391. package/node_modules/pi-agent-web/src/doctor-plugin.ts +41 -0
  392. package/node_modules/pi-agent-web/src/resolver.ts +128 -24
  393. package/node_modules/pi-agent-web-html/package.json +6 -3
  394. package/node_modules/pi-agent-web-html/runtime/entry-76.js +2 -0
  395. package/node_modules/pi-agent-web-html/src/extract-readable-html.ts +19 -6
  396. package/node_modules/pi-agent-web-image/package.json +4 -4
  397. package/node_modules/pi-agent-web-image/runtime/entry-77.js +2 -0
  398. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  399. package/node_modules/pi-agent-web-pdf/runtime/entry-78.js +2 -0
  400. package/node_modules/pi-agent-web-text/package.json +4 -4
  401. package/node_modules/pi-agent-web-text/runtime/entry-79.js +2 -0
  402. package/package.json +68 -54
  403. package/src/api/code-view.ts +4 -0
  404. package/src/api/connect-tip-provider.ts +49 -0
  405. package/src/api/plugin-protocol.ts +41 -2
  406. package/src/api/tips.ts +77 -0
  407. package/src/api/tool-config/formatters.json +215 -0
  408. package/src/api/tool-config/linters.json +257 -0
  409. package/src/api/tool-config/lsp-servers.json +275 -0
  410. package/src/api/tool-config.ts +217 -13
  411. package/src/api/toolchain.ts +0 -5
  412. package/src/code-view/diagnostic-view.ts +117 -26
  413. package/src/code-view/source-view.ts +1 -1
  414. package/src/composite/builtin-extensions.ts +12 -6
  415. package/src/composite/extensions-config.ts +137 -0
  416. package/src/composite/selection.ts +58 -3
  417. package/src/core/diagnostic-store.ts +244 -0
  418. package/src/core/extension.ts +40 -0
  419. package/src/core/ide-core.ts +48 -3
  420. package/src/doctor/config-writer.ts +1 -1
  421. package/src/doctor/core.ts +47 -0
  422. package/src/doctor/discovery.ts +10 -2
  423. package/src/doctor/extension.ts +12 -1
  424. package/src/doctor/inventory.ts +24 -6
  425. package/src/doctor/run.ts +68 -87
  426. package/src/doctor/tip-provider.ts +92 -0
  427. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +4 -3
  428. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  429. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  430. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-21.js +2 -0
  431. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  432. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-22.js +2 -0
  433. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  434. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-23.js +2 -0
  435. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-20.js +2 -0
  436. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +16 -6
  437. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -6
  438. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +6 -3
  439. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +2 -0
  440. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/extract-readable-html.ts +19 -6
  441. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  442. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-77.js +2 -0
  443. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  444. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-78.js +2 -0
  445. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  446. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-79.js +2 -0
  447. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +2 -0
  448. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +180 -0
  449. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/doctor-plugin.ts +41 -0
  450. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +128 -24
  451. package/src/extensions/pi-agent-read/package.json +11 -9
  452. package/src/extensions/pi-agent-read/runtime/entry-35.js +1 -0
  453. package/src/extensions/pi-agent-read/runtime/entry-36.js +1 -0
  454. package/src/extensions/pi-agent-read/runtime/entry-37.js +1 -0
  455. package/src/extensions/pi-agent-read/runtime/entry-38.js +1 -0
  456. package/src/extensions/pi-agent-read/runtime/entry-39.js +2 -0
  457. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  458. package/src/extensions/pi-agent-read/src/api/tools/read.ts +113 -2
  459. package/src/extensions/pi-agent-read/src/core/extension.ts +19 -0
  460. package/src/extensions/pi-agent-read/src/core/read-core.ts +85 -13
  461. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +26 -10
  462. package/src/extensions/pi-agent-read/src/core/tools/read/persisted-result.ts +72 -0
  463. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +102 -12
  464. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +27 -3
  465. package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +29 -0
  466. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +532 -46
  467. package/src/extensions/pi-agent-search/package.json +7 -6
  468. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +53 -3
  469. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
  470. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-45.js +2 -0
  471. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-46.js +1 -0
  472. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/doctor-plugin.ts +20 -1
  473. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +56 -0
  474. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +36 -34
  475. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +254 -71
  476. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +68 -0
  477. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +71 -117
  478. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +1 -0
  479. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +276 -110
  480. package/src/extensions/pi-agent-search/runtime/entry-41.js +1 -0
  481. package/src/extensions/pi-agent-search/runtime/entry-42.js +1 -0
  482. package/src/extensions/pi-agent-search/runtime/entry-43.js +1 -0
  483. package/src/extensions/pi-agent-search/runtime/entry-44.js +2 -0
  484. package/src/extensions/pi-agent-search/src/api/search.ts +4 -0
  485. package/src/extensions/pi-agent-search/src/core/extension.ts +99 -27
  486. package/src/extensions/pi-agent-search/src/core/search-config.ts +98 -0
  487. package/src/extensions/pi-agent-search/src/core/search-core.ts +32 -28
  488. package/src/extensions/pi-agent-search/src/core/search-timeout.ts +54 -0
  489. package/src/extensions/pi-agent-text-editor/package.json +22 -21
  490. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +7 -4
  491. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-48.js +2 -0
  492. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/src/resolver.ts +6 -0
  493. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +34 -0
  494. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +27 -0
  495. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-49.js +1 -0
  496. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-50.js +2 -0
  497. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +230 -0
  498. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/config.ts +159 -0
  499. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +100 -0
  500. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/recovery.ts +151 -0
  501. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +8 -2
  502. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +10 -6
  503. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-51.js +1 -0
  504. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-52.js +2 -0
  505. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/anchor.ts +32 -1
  506. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +20 -12
  507. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +3 -3
  508. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-69.js +2 -0
  509. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +1 -1
  510. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +4 -3
  511. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/runtime/entry-70.js +2 -0
  512. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +21 -1
  513. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -3
  514. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-71.js +2 -0
  515. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/animation-pressure.ts +50 -0
  516. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/config.ts +73 -0
  517. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +1 -1
  518. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +77 -22
  519. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-theme.ts +1 -1
  520. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +140 -24
  521. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +274 -43
  522. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +33 -6
  523. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +47 -0
  524. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +7 -0
  525. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +265 -105
  526. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/typing-interpolation.ts +96 -15
  527. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +22 -6
  528. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -4
  529. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-72.js +2 -0
  530. package/src/extensions/pi-agent-text-editor/runtime/entry-53.js +1 -0
  531. package/src/extensions/pi-agent-text-editor/runtime/entry-54.js +1 -0
  532. package/src/extensions/pi-agent-text-editor/runtime/entry-55.js +1 -0
  533. package/src/extensions/pi-agent-text-editor/runtime/entry-56.js +1 -0
  534. package/src/extensions/pi-agent-text-editor/runtime/entry-57.js +1 -0
  535. package/src/extensions/pi-agent-text-editor/runtime/entry-58.js +1 -0
  536. package/src/extensions/pi-agent-text-editor/runtime/entry-59.js +1 -0
  537. package/src/extensions/pi-agent-text-editor/runtime/entry-60.js +1 -0
  538. package/src/extensions/pi-agent-text-editor/runtime/entry-61.js +1 -0
  539. package/src/extensions/pi-agent-text-editor/runtime/entry-62.js +1 -0
  540. package/src/extensions/pi-agent-text-editor/runtime/entry-63.js +1 -0
  541. package/src/extensions/pi-agent-text-editor/runtime/entry-64.js +1 -0
  542. package/src/extensions/pi-agent-text-editor/runtime/entry-65.js +1 -0
  543. package/src/extensions/pi-agent-text-editor/runtime/entry-66.js +1 -0
  544. package/src/extensions/pi-agent-text-editor/runtime/entry-67.js +1 -0
  545. package/src/extensions/pi-agent-text-editor/runtime/entry-68.js +2 -0
  546. package/src/extensions/pi-agent-text-editor/src/api/anchor-inspection.ts +2 -0
  547. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +1 -0
  548. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +38 -0
  549. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +30 -15
  550. package/src/extensions/pi-agent-text-editor/src/api/text-selection-anchor.ts +10 -13
  551. package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -1
  552. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +12 -5
  553. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +15 -1
  554. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +14 -10
  555. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +1 -1
  556. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +3 -2
  557. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +19 -2
  558. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +64 -0
  559. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +1 -1
  560. package/src/extensions/pi-agent-text-editor/src/core/read-fragment-resolver.ts +83 -0
  561. package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +96 -8
  562. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +4 -1
  563. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +1 -1
  564. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +194 -35
  565. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +43 -13
  566. package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +95 -0
  567. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +75 -5
  568. package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +7 -0
  569. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +541 -130
  570. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +5 -9
  571. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +2 -0
  572. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +228 -6
  573. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +50 -70
  574. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +25 -26
  575. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +30 -21
  576. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +57 -71
  577. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +30 -27
  578. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -0
  579. package/src/pi-agent-ide.ts +15 -3
  580. package/src/plugins/pi-agent-ide-ast/package.json +11 -10
  581. package/src/plugins/pi-agent-ide-ast/runtime/entry-24.js +1 -0
  582. package/src/plugins/pi-agent-ide-ast/runtime/entry-25.js +2 -0
  583. package/src/plugins/pi-agent-ide-ast/src/api/scope.ts +1 -1
  584. package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +1 -1
  585. package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +25 -0
  586. package/src/plugins/pi-agent-ide-ast/src/extension.ts +13 -5
  587. package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +6 -0
  588. package/src/plugins/pi-agent-ide-changes/index.ts +6 -2
  589. package/src/plugins/pi-agent-ide-changes/package.json +8 -7
  590. package/src/plugins/pi-agent-ide-changes/runtime/entry-26.js +1 -0
  591. package/src/plugins/pi-agent-ide-changes/runtime/entry-27.js +2 -0
  592. package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +6 -0
  593. package/src/plugins/pi-agent-ide-changes/src/changes/change-groups.ts +1 -1
  594. package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +1 -1
  595. package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +1 -0
  596. package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +1 -1
  597. package/src/plugins/pi-agent-ide-changes/src/doctor-plugin.ts +31 -1
  598. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +5 -0
  599. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +7 -0
  600. package/src/plugins/pi-agent-ide-diagnostics/index.ts +1 -0
  601. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +191 -0
  602. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  603. package/src/plugins/pi-agent-ide-formatter/runtime/entry-28.js +2 -0
  604. package/src/plugins/pi-agent-ide-formatter/src/catalog.ts +34 -0
  605. package/src/plugins/pi-agent-ide-formatter/src/doctor-plugin.ts +115 -63
  606. package/src/plugins/pi-agent-ide-formatter/src/registry.ts +71 -28
  607. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  608. package/src/plugins/pi-agent-ide-languages/runtime/entry-29.js +2 -0
  609. package/src/plugins/pi-agent-ide-lint/index.ts +30 -155
  610. package/src/plugins/pi-agent-ide-lint/package.json +8 -7
  611. package/src/plugins/pi-agent-ide-lint/runtime/entry-30.js +2 -0
  612. package/src/plugins/pi-agent-ide-lint/src/catalog.ts +14 -2
  613. package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +60 -4
  614. package/src/plugins/pi-agent-ide-lint/src/diagnostics.ts +3 -1
  615. package/src/plugins/pi-agent-ide-lint/src/doctor-plugin.ts +115 -64
  616. package/src/plugins/pi-agent-ide-lint/src/registry.ts +72 -27
  617. package/src/plugins/pi-agent-ide-lsp/index.ts +35 -134
  618. package/src/plugins/pi-agent-ide-lsp/package.json +9 -8
  619. package/src/plugins/pi-agent-ide-lsp/runtime/entry-31.js +2 -0
  620. package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +1 -1
  621. package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +113 -0
  622. package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +108 -53
  623. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +94 -27
  624. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +2 -1
  625. package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +76 -0
  626. package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +137 -144
  627. package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +2 -2
  628. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +9 -32
  629. package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +86 -50
  630. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +1 -0
  631. package/src/plugins/pi-agent-ide-lsp/src/lsp/types.ts +8 -6
  632. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +5 -5
  633. package/src/post-edit/gate.ts +17 -141
  634. package/src/tips/core.ts +86 -0
  635. package/src/tips/extension.ts +115 -0
  636. package/src/tips/persistence.ts +225 -0
  637. package/src/tips/tip-callout.ts +77 -0
  638. package/src/toolchain/registry.ts +8 -23
  639. package/src/toolchain/types.ts +6 -74
  640. package/node_modules/pi-agent-search-semantic/index.ts +0 -97
  641. package/node_modules/pi-agent-search-semantic/package.json +0 -17
  642. package/node_modules/pi-agent-search-text/src/lucene-query-parser.d.ts +0 -20
  643. package/node_modules/pi-agent-search-web/index.ts +0 -82
  644. package/node_modules/pi-agent-search-web/package.json +0 -20
  645. package/node_modules/pi-agent-search-web/src/config.ts +0 -560
  646. package/node_modules/pi-agent-search-web/src/doctor-plugin.ts +0 -40
  647. package/node_modules/pi-agent-search-web/src/providers/duckduckgo-html.ts +0 -74
  648. package/node_modules/pi-agent-search-web/src/providers/endpoints.ts +0 -81
  649. package/node_modules/pi-agent-search-web/src/providers/request.ts +0 -427
  650. package/node_modules/pi-agent-search-web/src/providers/response.ts +0 -353
  651. package/node_modules/pi-agent-search-web/src/search-format.ts +0 -24
  652. package/node_modules/pi-agent-search-web/src/search.ts +0 -376
  653. package/node_modules/pi-agent-search-web/src/types.ts +0 -141
  654. package/src/composite/config.ts +0 -100
  655. package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/index.ts +0 -97
  656. package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/package.json +0 -17
  657. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/lucene-query-parser.d.ts +0 -20
  658. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/index.ts +0 -82
  659. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/package.json +0 -20
  660. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/config.ts +0 -560
  661. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/doctor-plugin.ts +0 -40
  662. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/duckduckgo-html.ts +0 -74
  663. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/endpoints.ts +0 -81
  664. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/request.ts +0 -427
  665. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/response.ts +0 -353
  666. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search-format.ts +0 -24
  667. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search.ts +0 -376
  668. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/types.ts +0 -141
  669. package/src/toolchain/gate.ts +0 -305
  670. /package/{src/utils/required-value.ts → node_modules/pi-agent-invariant/src/index.ts} +0 -0
@@ -330,15 +330,7 @@ class InterceptorImpl implements ToolCallInterceptor {
330
330
  pi.on("agent_end", async () => {
331
331
  await this.finalizeRecovery();
332
332
 
333
- for (const [contentIndex, entry] of this.streamedBatchEntries) {
334
- if (
335
- !entry.complete &&
336
- !this.recoveryAppliedBatchIndexes.has(entry.index) &&
337
- !this.emittedToolCallAnnotationKinds.get(contentIndex)?.has("stale-anchor")
338
- ) {
339
- this.annotateContent(contentIndex, { kind: "aborted" });
340
- }
341
- }
333
+ this.annotateIncompleteCalls();
342
334
 
343
335
  this.cleanupAll();
344
336
  });
@@ -585,8 +577,12 @@ class InterceptorImpl implements ToolCallInterceptor {
585
577
  }
586
578
  private annotateIncompleteCalls(): void {
587
579
  for (const [contentIndex, entry] of this.streamedBatchEntries) {
580
+ // Contents whose transient state was already cleaned up ended one way or
581
+ // another; re-annotating them would leak the annotation onto the next
582
+ // call that reuses the same content index.
588
583
  if (
589
584
  !entry.complete &&
585
+ this.contentNames.has(contentIndex) &&
590
586
  !this.recoveryAppliedBatchIndexes.has(entry.index) &&
591
587
  !this.emittedToolCallAnnotationKinds.get(contentIndex)?.has("stale-anchor")
592
588
  ) {
@@ -1,4 +1,6 @@
1
1
  export {
2
+ TOOL_CALL_INTERCEPTION_ANCHOR_RENDER_PATCH,
2
3
  ToolCallInterceptionRenderStore,
4
+ type ToolCallAnchorRenderState,
3
5
  withToolCallInterceptionRendering,
4
6
  } from "pi-agent-tool-call-interception";
@@ -1,4 +1,4 @@
1
- import { requiredValue } from "../../../../utils/required-value.js";
1
+ import { requiredValue } from "pi-agent-invariant";
2
2
  import { TextSelectionAnchor, type TextSelectionRange } from "#src/api/text-selection-anchor.js";
3
3
 
4
4
  import type { TextMutationContext } from "#src/api/mutation-tool.js";
@@ -33,6 +33,192 @@ export function lineAnchor(anchors: ReadonlyMap<string, TextAnchor>, field: stri
33
33
  return requiredValue(anchors.values().next().value);
34
34
  }
35
35
 
36
+ export interface TextAnchorSpan {
37
+ readonly source: string;
38
+ readonly from: number;
39
+ readonly to: number;
40
+ readonly selection: boolean;
41
+ readonly preservesTrailingLineBreak: boolean;
42
+ /** First selected line when this span represents whole lines. */
43
+ readonly linewiseStartLine?: number;
44
+ /** Last selected line when this span represents whole lines. */
45
+ readonly linewiseEndLine?: number;
46
+ }
47
+
48
+ /** Resolves one anchor to one character span, converting line anchors to whole-line spans. */
49
+ export function singleAnchorSpan(
50
+ context: TextMutationContext,
51
+ anchors: ReadonlyMap<string, TextAnchor>,
52
+ field: string,
53
+ ): TextAnchorSpan {
54
+ if (anchors.size !== 1) {
55
+ throw new Error(`Anchor ${field} must resolve in one resource.`);
56
+ }
57
+
58
+ const [source, anchor] = requiredValue(anchors.entries().next().value);
59
+ if (TextSelectionAnchor.is(anchor)) {
60
+ if (anchor.ranges.length !== 1) {
61
+ throw new Error(`Anchor ${field} must select one match for this operation.`);
62
+ }
63
+ const selectedRange = requiredValue(anchor.ranges[0]);
64
+ const document = context.documentFor(source);
65
+ const exactRange = selectionRange(context, source, selectedRange);
66
+ const endLine = linewiseSelectionEndLine(selectedRange);
67
+ if (endLine !== undefined) {
68
+ const range = document.lineRange(selectedRange.start.lineNumber, endLine);
69
+ return {
70
+ source,
71
+ ...range,
72
+ selection: false,
73
+ preservesTrailingLineBreak: true,
74
+ linewiseStartLine: selectedRange.start.lineNumber,
75
+ linewiseEndLine: endLine,
76
+ };
77
+ }
78
+ return { source, ...exactRange, selection: true, preservesTrailingLineBreak: false };
79
+ }
80
+
81
+ const range = context.documentFor(source).lineRange(anchor.lineNumber, anchor.lineNumber);
82
+ return {
83
+ source,
84
+ ...range,
85
+ selection: false,
86
+ preservesTrailingLineBreak: true,
87
+ linewiseStartLine: anchor.lineNumber,
88
+ linewiseEndLine: anchor.lineNumber,
89
+ };
90
+ }
91
+
92
+ /** Builds a natural range from the left edge of start through the right edge of end. */
93
+ export function anchorSpanRange(
94
+ context: TextMutationContext,
95
+ starts: ReadonlyMap<string, TextAnchor>,
96
+ ends: ReadonlyMap<string, TextAnchor> | undefined,
97
+ startField: string,
98
+ endField: string,
99
+ ): TextAnchorSpan {
100
+ const start = singleAnchorSpan(context, starts, startField);
101
+ const end = ends === undefined ? start : singleAnchorSpan(context, ends, endField);
102
+ if (start.source !== end.source) {
103
+ throw new Error(`Anchors ${startField} and ${endField} must resolve in one resource.`);
104
+ }
105
+ if (start.from > end.to) {
106
+ throw new Error(`Anchor ${startField} must not come after ${endField}.`);
107
+ }
108
+ return {
109
+ source: start.source,
110
+ from: start.from,
111
+ to: end.to,
112
+ selection: start.selection || end.selection,
113
+ preservesTrailingLineBreak: end.preservesTrailingLineBreak,
114
+ };
115
+ }
116
+
117
+ /** Converts inserted line endings to the target document's style. */
118
+ export function targetText(context: TextMutationContext, source: string, text: string): string {
119
+ const separator = context.documentFor(source).content.includes("\r\n") ? "\r\n" : "\n";
120
+ return text.replace(/\r\n|\r|\n/gu, separator);
121
+ }
122
+
123
+ /** Creates a replacement while preserving a line endpoint's trailing separator. */
124
+ export function replaceAnchorSpan(
125
+ context: TextMutationContext,
126
+ span: TextAnchorSpan,
127
+ text: string,
128
+ ): { readonly from: number; readonly to: number; readonly insert: string } {
129
+ const document = context.documentFor(span.source);
130
+ let insert = targetText(context, span.source, text);
131
+ const selected = document.text(span);
132
+ if (span.preservesTrailingLineBreak && !/(?:\r\n|\r|\n)$/u.test(insert)) {
133
+ const ending = /(?:\r\n|\r|\n)$/u.exec(selected)?.[0];
134
+ if (ending !== undefined) {
135
+ insert += ending;
136
+ }
137
+ }
138
+ return { from: span.from, to: span.to, insert };
139
+ }
140
+
141
+ /** Creates a deletion while keeping whole-line deletion behavior at EOF. */
142
+ export function deleteAnchorSpan(
143
+ context: TextMutationContext,
144
+ span: TextAnchorSpan,
145
+ ): { readonly from: number; readonly to: number; readonly insert: "" } {
146
+ const content = context.documentFor(span.source).content;
147
+ if (
148
+ !span.selection &&
149
+ span.to === content.length &&
150
+ span.from > 0 &&
151
+ !/(?:\r\n|\r|\n)$/u.test(content)
152
+ ) {
153
+ const prefix = content.slice(0, span.from);
154
+ const match = /(?:\r\n|\r|\n)$/u.exec(prefix);
155
+ if (match !== null) {
156
+ return { from: span.from - match[0].length, to: span.to, insert: "" };
157
+ }
158
+ }
159
+ return { from: span.from, to: span.to, insert: "" };
160
+ }
161
+
162
+ /** Creates an insertion after a selection span or after a line anchor. */
163
+ export function insertionAfterAnchor(
164
+ context: TextMutationContext,
165
+ anchors: ReadonlyMap<string, TextAnchor>,
166
+ field: string,
167
+ insert: string,
168
+ ): readonly [string, { readonly from: number; readonly to: number; readonly insert: string }] {
169
+ const span = singleAnchorSpan(context, anchors, field);
170
+ const normalizedInsert = targetText(context, span.source, insert);
171
+ if (span.selection) {
172
+ return [span.source, { from: span.to, to: span.to, insert: normalizedInsert }];
173
+ }
174
+
175
+ const lineNumber = span.linewiseEndLine ?? lineAnchor(anchors, field).lineNumber;
176
+ return [
177
+ span.source,
178
+ context.documentFor(span.source).insertAfterLine(lineNumber, normalizedInsert),
179
+ ];
180
+ }
181
+
182
+ /** Creates an insertion before a selection span or before a line anchor. */
183
+ export function insertionBeforeAnchor(
184
+ context: TextMutationContext,
185
+ anchors: ReadonlyMap<string, TextAnchor>,
186
+ field: string,
187
+ insert: string,
188
+ ): readonly [string, { readonly from: number; readonly to: number; readonly insert: string }] {
189
+ const span = singleAnchorSpan(context, anchors, field);
190
+ const normalizedInsert = targetText(context, span.source, insert);
191
+ if (span.selection) {
192
+ return [span.source, { from: span.from, to: span.from, insert: normalizedInsert }];
193
+ }
194
+
195
+ const lineNumber = span.linewiseStartLine ?? lineAnchor(anchors, field).lineNumber;
196
+ return [
197
+ span.source,
198
+ context.documentFor(span.source).insertBeforeLine(lineNumber, normalizedInsert),
199
+ ];
200
+ }
201
+
202
+ function coalesceAdjacentLinewiseRanges(
203
+ ranges: readonly TextSelectionRange[],
204
+ ): readonly TextSelectionRange[] {
205
+ const result: TextSelectionRange[] = [];
206
+ for (const range of ranges) {
207
+ const previous = result.at(-1);
208
+ if (
209
+ previous?.linewise === true &&
210
+ range.linewise === true &&
211
+ previous.end.lineNumber === range.start.lineNumber &&
212
+ previous.end.column === range.start.column
213
+ ) {
214
+ result[result.length - 1] = { ...previous, end: range.end };
215
+ } else {
216
+ result.push(range);
217
+ }
218
+ }
219
+ return result;
220
+ }
221
+
36
222
  export function selectionChanges(
37
223
  context: TextMutationContext,
38
224
  selections: ReadonlyMap<string, TextSelectionAnchor>,
@@ -44,15 +230,30 @@ export function selectionChanges(
44
230
  return new Map(
45
231
  [...selections].map(([source, anchor]) => [
46
232
  source,
47
- anchor.ranges.map((range) => ({ ...selectionRange(context, source, range), insert })),
233
+ (insert.length === 0 ? coalesceAdjacentLinewiseRanges(anchor.ranges) : anchor.ranges).map(
234
+ (range) => {
235
+ const span = selectionRange(context, source, range);
236
+ const lineSpan = {
237
+ source,
238
+ ...span,
239
+ selection: false,
240
+ preservesTrailingLineBreak: range.linewise === true && insert.length > 0,
241
+ };
242
+ return insert.length === 0 && range.linewise === true
243
+ ? deleteAnchorSpan(context, lineSpan)
244
+ : replaceAnchorSpan(context, lineSpan, insert);
245
+ },
246
+ ),
48
247
  ]),
49
248
  );
50
249
  }
51
250
 
251
+ /** Creates insertions before or after every selected range. */
52
252
  export function insertionChanges(
53
253
  context: TextMutationContext,
54
254
  selections: ReadonlyMap<string, TextSelectionAnchor>,
55
255
  insert: string,
256
+ before = false,
56
257
  ): ReadonlyMap<
57
258
  string,
58
259
  readonly { readonly from: number; readonly to: number; readonly insert: string }[]
@@ -61,10 +262,22 @@ export function insertionChanges(
61
262
  [...selections].map(([source, anchor]) => [
62
263
  source,
63
264
  anchor.ranges.map((range) => {
64
- const at = context
65
- .documentFor(source)
66
- .range(range.end.lineNumber, range.end.column, range.end.lineNumber, range.end.column);
67
- return { ...at, insert };
265
+ const document = context.documentFor(source);
266
+ const normalizedInsert = targetText(context, source, insert);
267
+ const linewiseEnd = linewiseSelectionEndLine(range);
268
+ if (linewiseEnd !== undefined) {
269
+ return before
270
+ ? document.insertBeforeLine(range.start.lineNumber, normalizedInsert)
271
+ : document.insertAfterLine(linewiseEnd, normalizedInsert);
272
+ }
273
+ const position = before ? range.start : range.end;
274
+ const at = document.range(
275
+ position.lineNumber,
276
+ position.column,
277
+ position.lineNumber,
278
+ position.column,
279
+ );
280
+ return { ...at, insert: normalizedInsert };
68
281
  }),
69
282
  ]),
70
283
  );
@@ -96,3 +309,12 @@ export function selectionRange(
96
309
  .documentFor(source)
97
310
  .range(range.start.lineNumber, range.start.column, range.end.lineNumber, range.end.column);
98
311
  }
312
+
313
+ function linewiseSelectionEndLine(range: TextSelectionRange): number | undefined {
314
+ if (range.linewise !== true) {
315
+ return undefined;
316
+ }
317
+ return range.end.column === 0 && range.end.lineNumber > range.start.lineNumber
318
+ ? range.end.lineNumber - 1
319
+ : range.end.lineNumber;
320
+ }
@@ -2,29 +2,40 @@ import { Type } from "typebox";
2
2
 
3
3
  import { TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND } from "#src/api/plugin-protocol.js";
4
4
  import {
5
- lineAnchor,
6
- selectionRange,
7
- singleSelection,
8
- textSelections,
5
+ anchorSpanRange,
6
+ insertionAfterAnchor,
7
+ replaceAnchorSpan,
9
8
  } from "#src/tools/text-selection.js";
10
9
 
11
10
  import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
12
11
 
13
12
  export const copySchema = Type.Object(
14
13
  {
15
- path: Type.Optional(Type.String({ description: "Source file to copy from" })),
16
- start: Type.String({ description: "Registered text anchor selecting the first line to copy" }),
17
- end: Type.Optional(
14
+ path: Type.Optional(
18
15
  Type.String({
19
- description: "Registered text anchor selecting the last line; defaults to start",
16
+ description:
17
+ "Source resource reference or file path; a typed resource may select one source span",
18
+ }),
19
+ ),
20
+ start: Type.Optional(
21
+ Type.String({
22
+ description: "Registered text anchor or unique exact text at the source start",
23
+ }),
24
+ ),
25
+ end: Type.Optional(Type.String({ description: "Source end anchor; defaults to start" })),
26
+ target: Type.Optional(
27
+ Type.String({
28
+ description:
29
+ "Target resource reference or file path; a typed resource may select the destination; defaults to the source",
30
+ }),
31
+ ),
32
+ targetStart: Type.Optional(
33
+ Type.String({
34
+ description: "Target anchor; copied text is inserted after it when targetEnd is omitted",
20
35
  }),
21
36
  ),
22
- target: Type.Optional(Type.String({ description: "Target file; defaults to the source file" })),
23
- targetStart: Type.String({
24
- description: "First target line; copied text is inserted after it when targetEnd is omitted",
25
- }),
26
37
  targetEnd: Type.Optional(
27
- Type.String({ description: "Last target line; the inclusive target range is replaced" }),
38
+ Type.String({ description: "Target end anchor; the natural target range is replaced" }),
28
39
  ),
29
40
  },
30
41
  { additionalProperties: false },
@@ -32,17 +43,19 @@ export const copySchema = Type.Object(
32
43
 
33
44
  interface CopyParameters {
34
45
  readonly path?: string;
35
- readonly start: string;
46
+ readonly start?: string;
36
47
  readonly end?: string;
37
48
  readonly target?: string;
38
- readonly targetStart: string;
49
+ readonly targetStart?: string;
39
50
  readonly targetEnd?: string;
40
51
  }
41
52
 
42
53
  export const copyMutationTool: TextMutationToolRegistration<typeof copySchema> = {
43
54
  name: "copy",
44
- description:
45
- "Copy selected lines and insert them after targetStart, or replace targetStart through targetEnd.",
55
+ description: "Copy one span or an anchor range, then insert it or replace a target range.",
56
+
57
+ promptSnippet:
58
+ "Make precise file edits by copying text within or between files using exact matches or anchors",
46
59
  parameters: copySchema,
47
60
  source: { field: "path", inherited: true, targets: [{ field: "target", fallbackTo: "path" }] },
48
61
  anchors: [
@@ -72,64 +85,31 @@ export const copyMutationTool: TextMutationToolRegistration<typeof copySchema> =
72
85
  pair: ["start", "end"],
73
86
  mutate: async (context, parameters: CopyParameters) => {
74
87
  const starts = await context.resolveAnchors("start");
75
- const sourceSelections = textSelections(starts, "start");
76
- let copied: string;
77
-
78
- if (sourceSelections === undefined) {
79
- const source = context.sourceFor("path");
80
- const start = lineAnchor(starts, "start");
81
- const end =
82
- parameters.end === undefined
83
- ? start
84
- : lineAnchor(await context.resolveAnchors("end"), "end");
85
- const sourceDocument = context.documentFor(source);
86
- copied = sourceDocument.text(sourceDocument.lineRange(start.lineNumber, end.lineNumber));
87
- } else {
88
- if (parameters.end !== undefined) {
89
- throw new Error("end cannot be combined with a search selection.");
90
- }
91
-
92
- const [source, range] = singleSelection(sourceSelections, "start");
93
- copied = context.documentFor(source).text(selectionRange(context, source, range));
94
- }
88
+ const ends = parameters.end === undefined ? undefined : await context.resolveAnchors("end");
89
+ const sourceSpan = anchorSpanRange(context, starts, ends, "start", "end");
90
+ const copied = context.documentFor(sourceSpan.source).text(sourceSpan);
95
91
 
96
92
  const targetStarts = await context.resolveAnchors("targetStart");
97
- const targetSelections = textSelections(targetStarts, "targetStart");
98
-
99
- if (targetSelections !== undefined) {
100
- if (parameters.targetEnd !== undefined) {
101
- throw new Error("targetEnd cannot be combined with a search selection.");
102
- }
103
-
104
- const [target, range] = singleSelection(targetSelections, "targetStart");
105
- const targetDocument = context.documentFor(target);
106
- const insertion = targetDocument.range(
107
- range.end.lineNumber,
108
- range.end.column,
109
- range.end.lineNumber,
110
- range.end.column,
111
- );
112
- return {
113
- edits: new Map([
114
- [target, { changes: [{ ...insertion, insert: copied }], action: "edited" }],
115
- ]),
116
- };
93
+ if (parameters.targetEnd === undefined) {
94
+ const [target, change] = insertionAfterAnchor(context, targetStarts, "targetStart", copied);
95
+ return { edits: new Map([[target, { changes: [change], action: "edited" }]]) };
117
96
  }
118
97
 
119
- const target = context.sourceFor("target");
120
- const targetDocument = context.documentFor(target);
121
- const targetStart = lineAnchor(targetStarts, "targetStart");
122
- const targetEnd =
123
- parameters.targetEnd === undefined
124
- ? undefined
125
- : lineAnchor(await context.resolveAnchors("targetEnd"), "targetEnd");
126
- const change =
127
- targetEnd === undefined
128
- ? targetDocument.insertAfterLine(targetStart.lineNumber, copied)
129
- : targetDocument.replaceLines(targetStart.lineNumber, targetEnd.lineNumber, copied);
130
-
98
+ const targetEnds = await context.resolveAnchors("targetEnd");
99
+ const targetSpan = anchorSpanRange(
100
+ context,
101
+ targetStarts,
102
+ targetEnds,
103
+ "targetStart",
104
+ "targetEnd",
105
+ );
131
106
  return {
132
- edits: new Map([[target, { changes: [change], action: "edited" }]]),
107
+ edits: new Map([
108
+ [
109
+ targetSpan.source,
110
+ { changes: [replaceAnchorSpan(context, targetSpan, copied)], action: "edited" },
111
+ ],
112
+ ]),
133
113
  };
134
114
  },
135
115
  };
@@ -1,18 +1,32 @@
1
1
  import { Type } from "typebox";
2
2
 
3
3
  import { TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND } from "#src/api/plugin-protocol.js";
4
- import { lineAnchor, selectionChanges, textSelections } from "#src/tools/text-selection.js";
4
+ import {
5
+ anchorSpanRange,
6
+ deleteAnchorSpan,
7
+ selectionChanges,
8
+ textSelections,
9
+ } from "#src/tools/text-selection.js";
5
10
 
6
11
  import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
7
12
 
8
13
  export const deleteSchema = Type.Object(
9
14
  {
10
- path: Type.Optional(Type.String({ description: "File path to edit" })),
15
+ path: Type.Optional(
16
+ Type.String({
17
+ description:
18
+ "Source resource reference or file path. A typed SEARCH#... resource can select deletion ranges.",
19
+ }),
20
+ ),
11
21
  start: Type.Optional(
12
- Type.String({ description: "Registered text anchor selecting the first line to delete" }),
22
+ Type.String({
23
+ description: "Registered text anchor or unique exact text selecting the first span",
24
+ }),
13
25
  ),
14
26
  end: Type.Optional(
15
- Type.String({ description: "Registered text anchor selecting the last line to delete" }),
27
+ Type.String({
28
+ description: "Registered text anchor or unique exact text selecting the last span",
29
+ }),
16
30
  ),
17
31
  },
18
32
  { additionalProperties: false },
@@ -26,7 +40,9 @@ interface DeleteParameters {
26
40
 
27
41
  export const deleteMutationTool: TextMutationToolRegistration<typeof deleteSchema> = {
28
42
  name: "delete",
29
- description: "Delete lines selected by registered text anchors.",
43
+ description: "Delete one selected span or the natural range between two anchors.",
44
+
45
+ promptSnippet: "Make precise file edits by deleting text using exact matches or anchors",
30
46
  parameters: deleteSchema,
31
47
  source: { field: "path", inherited: true },
32
48
  anchors: [
@@ -45,18 +61,9 @@ export const deleteMutationTool: TextMutationToolRegistration<typeof deleteSchem
45
61
  ],
46
62
  pair: ["start", "end"],
47
63
  mutate: async (context, parameters: DeleteParameters) => {
48
- if (parameters.start === undefined) {
49
- throw new Error("start anchor is required.");
50
- }
51
-
52
64
  const starts = await context.resolveAnchors("start");
53
65
  const selections = textSelections(starts, "start");
54
-
55
- if (selections !== undefined) {
56
- if (parameters.end !== undefined) {
57
- throw new Error("end cannot be combined with a search selection.");
58
- }
59
-
66
+ if (parameters.end === undefined && selections !== undefined) {
60
67
  const changes = selectionChanges(context, selections, "");
61
68
  return {
62
69
  edits: new Map(
@@ -68,19 +75,11 @@ export const deleteMutationTool: TextMutationToolRegistration<typeof deleteSchem
68
75
  };
69
76
  }
70
77
 
71
- const source = context.sourceFor("path");
72
- const start = lineAnchor(starts, "start");
73
- const end =
74
- parameters.end === undefined ? start : lineAnchor(await context.resolveAnchors("end"), "end");
78
+ const ends = parameters.end === undefined ? undefined : await context.resolveAnchors("end");
79
+ const span = anchorSpanRange(context, starts, ends, "start", "end");
75
80
  return {
76
81
  edits: new Map([
77
- [
78
- source,
79
- {
80
- changes: [context.documentFor(source).deleteLines(start.lineNumber, end.lineNumber)],
81
- action: "edited",
82
- },
83
- ],
82
+ [span.source, { changes: [deleteAnchorSpan(context, span)], action: "edited" }],
84
83
  ]),
85
84
  };
86
85
  },
@@ -1,30 +1,49 @@
1
1
  import { Type } from "typebox";
2
2
 
3
3
  import { TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND } from "#src/api/plugin-protocol.js";
4
- import { insertionChanges, lineAnchor, textSelections } from "#src/tools/text-selection.js";
4
+ import {
5
+ insertionAfterAnchor,
6
+ insertionBeforeAnchor,
7
+ insertionChanges,
8
+ textSelections,
9
+ } from "#src/tools/text-selection.js";
5
10
 
6
11
  import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
7
12
 
8
13
  export const insertSchema = Type.Object(
9
14
  {
10
- path: Type.Optional(Type.String({ description: "File path to edit" })),
11
- anchor: Type.String({
12
- description: "Registered text anchor; text is inserted after its resolved line",
13
- }),
15
+ path: Type.Optional(
16
+ Type.String({
17
+ description:
18
+ "Source resource reference or file path. A typed SEARCH#... resource can select insertion positions.",
19
+ }),
20
+ ),
21
+ anchor: Type.Optional(
22
+ Type.String({
23
+ description: "Registered text anchor or unique exact text span",
24
+ }),
25
+ ),
14
26
  text: Type.String({ description: "Content to insert" }),
27
+ before: Type.Optional(
28
+ Type.Boolean({ description: "Insert before the anchor instead of after it" }),
29
+ ),
15
30
  },
16
31
  { additionalProperties: false },
17
32
  );
18
33
 
19
34
  interface InsertParameters {
20
35
  readonly path?: string;
21
- readonly anchor: string;
36
+ readonly anchor?: string;
22
37
  readonly text: string;
38
+ readonly before?: boolean;
23
39
  }
24
40
 
25
41
  export const insertMutationTool: TextMutationToolRegistration<typeof insertSchema> = {
26
42
  name: "insert",
27
- description: "Insert text after the line resolved by a registered text anchor.",
43
+ description: "Insert text before or after a registered anchor or one unique exact text span.",
44
+
45
+ promptSnippet:
46
+ "Make precise file edits by inserting text before or after exact matches or anchors",
28
47
  parameters: insertSchema,
29
48
  source: { field: "path", inherited: true },
30
49
  anchors: [
@@ -39,7 +58,7 @@ export const insertMutationTool: TextMutationToolRegistration<typeof insertSchem
39
58
  const selections = textSelections(anchors, "anchor");
40
59
 
41
60
  if (selections !== undefined) {
42
- const changes = insertionChanges(context, selections, parameters.text);
61
+ const changes = insertionChanges(context, selections, parameters.text, parameters.before);
43
62
  return {
44
63
  edits: new Map(
45
64
  [...changes].map(([source, sourceChanges]) => [
@@ -50,20 +69,10 @@ export const insertMutationTool: TextMutationToolRegistration<typeof insertSchem
50
69
  };
51
70
  }
52
71
 
53
- const source = context.sourceFor("path");
54
- const anchor = lineAnchor(anchors, "anchor");
72
+ const insertion = parameters.before === true ? insertionBeforeAnchor : insertionAfterAnchor;
73
+ const [source, change] = insertion(context, anchors, "anchor", parameters.text);
55
74
  return {
56
- edits: new Map([
57
- [
58
- source,
59
- {
60
- changes: [
61
- context.documentFor(source).insertAfterLine(anchor.lineNumber, parameters.text),
62
- ],
63
- action: "edited",
64
- },
65
- ],
66
- ]),
75
+ edits: new Map([[source, { changes: [change], action: "edited" }]]),
67
76
  };
68
77
  },
69
78
  };