pi-agent-ide 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (702) hide show
  1. package/CHANGELOG.md +53 -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-2XYXV5HS.js +4 -0
  6. package/dist/chunk-2ZMYT6ZC.js +1 -0
  7. package/dist/chunk-34ZQTTU2.js +2 -0
  8. package/dist/chunk-3H2EU7VQ.js +0 -0
  9. package/dist/chunk-3YK4XMWB.js +0 -0
  10. package/dist/chunk-4SQQKEVD.js +16 -0
  11. package/dist/chunk-5BWUVAR4.js +1 -0
  12. package/dist/chunk-6DN7NO7L.js +1 -0
  13. package/dist/chunk-6SMFVLTY.js +1 -0
  14. package/dist/chunk-6XQQBKPE.js +58 -0
  15. package/dist/chunk-BYWAG6X3.js +6 -0
  16. package/dist/chunk-DEP55R35.js +1 -0
  17. package/dist/chunk-E2RESHYR.js +1 -0
  18. package/dist/chunk-EEH4WYI7.js +1 -0
  19. package/dist/chunk-EI7MMDWY.js +1 -0
  20. package/dist/chunk-ERVMDQGX.js +1 -0
  21. package/dist/chunk-EW2KVKCN.js +2 -0
  22. package/dist/chunk-F6SESI3P.js +4 -0
  23. package/dist/chunk-GTK5AREE.js +2 -0
  24. package/dist/chunk-HOBTFFQR.js +1 -0
  25. package/dist/chunk-IMVCVPMP.js +3 -0
  26. package/dist/chunk-IOCABSRL.js +1 -0
  27. package/dist/chunk-JASLOB2X.js +1 -0
  28. package/dist/chunk-JMVDFOTQ.js +1 -0
  29. package/dist/chunk-K4ZMRDEI.js +0 -0
  30. package/dist/chunk-KH5KPBCR.js +10 -0
  31. package/dist/chunk-KINKBPPX.js +1 -0
  32. package/dist/chunk-KNMWCDDK.js +7 -0
  33. package/dist/chunk-KYVOMBO5.js +1 -0
  34. package/dist/chunk-KZBAJFCV.js +1 -0
  35. package/dist/chunk-L4FA6OD4.js +1 -0
  36. package/dist/chunk-LFV6G5Z3.js +1 -0
  37. package/dist/chunk-LGN7EJYR.js +13 -0
  38. package/dist/chunk-MB6VVVAF.js +2 -0
  39. package/dist/chunk-MBUXFKIW.js +3 -0
  40. package/dist/chunk-MTQSGWZJ.js +1 -0
  41. package/dist/chunk-MTTKFJV6.js +1 -0
  42. package/dist/chunk-N34ATN52.js +1 -0
  43. package/dist/chunk-NI2NK4JU.js +1 -0
  44. package/dist/chunk-NNCZYO4Q.js +0 -0
  45. package/dist/chunk-NXHPO7ER.js +6 -0
  46. package/dist/chunk-OBWZ5RYN.js +1 -0
  47. package/dist/chunk-OFHVDY4Q.js +2 -0
  48. package/dist/chunk-OIL6BB2S.js +33 -0
  49. package/dist/chunk-ONWUJXUR.js +1 -0
  50. package/dist/chunk-ORAPGW7W.js +1 -0
  51. package/dist/chunk-OVUYPHDE.js +1 -0
  52. package/dist/chunk-PETQCA7G.js +1 -0
  53. package/dist/chunk-PODWLGNO.js +6 -0
  54. package/dist/chunk-QZANC2IG.js +1 -0
  55. package/dist/chunk-SJYDLHEF.js +108 -0
  56. package/dist/chunk-SMSIT3CE.js +3 -0
  57. package/dist/chunk-SSZB66C3.js +3 -0
  58. package/dist/chunk-STUZZM5B.js +1 -0
  59. package/dist/chunk-T2RPMEM2.js +1 -0
  60. package/dist/chunk-TG6H6EOI.js +1 -0
  61. package/dist/chunk-UTTW55S2.js +1 -0
  62. package/dist/chunk-VCCMVQXU.js +1 -0
  63. package/dist/chunk-VEJGSURY.js +8 -0
  64. package/dist/chunk-VFBLX4TG.js +1 -0
  65. package/dist/chunk-VSP2QQPQ.js +2 -0
  66. package/dist/chunk-W3XYKJ5H.js +1 -0
  67. package/dist/chunk-WZI4YC2O.js +1 -0
  68. package/dist/chunk-XGUAL3CA.js +1 -0
  69. package/dist/chunk-XNXQYPVT.js +10 -0
  70. package/dist/chunk-YHUTTZC6.js +2 -0
  71. package/dist/chunk-YPHXLAQF.js +1 -0
  72. package/dist/chunk-ZC65Z3CK.js +1 -0
  73. package/dist/chunk-ZIHEF6K3.js +3 -0
  74. package/dist/entry-0.js +1 -0
  75. package/dist/entry-1.js +1 -0
  76. package/dist/entry-10.js +1 -0
  77. package/dist/entry-11.js +1 -0
  78. package/dist/entry-12.js +1 -0
  79. package/dist/entry-13.js +1 -0
  80. package/dist/entry-14.js +1 -0
  81. package/dist/entry-16.js +1 -0
  82. package/dist/entry-17.js +1 -0
  83. package/dist/entry-18.js +1 -0
  84. package/dist/entry-19.js +1 -0
  85. package/dist/entry-2.js +1 -0
  86. package/dist/entry-20.js +1 -0
  87. package/dist/entry-21.js +1 -0
  88. package/dist/entry-22.js +1 -0
  89. package/dist/entry-23.js +1 -0
  90. package/dist/entry-24.js +1 -0
  91. package/dist/entry-25.js +1 -0
  92. package/dist/entry-26.js +1 -0
  93. package/dist/entry-27.js +1 -0
  94. package/dist/entry-28.js +1 -0
  95. package/dist/entry-29.js +1 -0
  96. package/dist/entry-3.js +1 -0
  97. package/dist/entry-30.js +1 -0
  98. package/dist/entry-31.js +1 -0
  99. package/dist/entry-32.js +1 -0
  100. package/dist/entry-33.js +1 -0
  101. package/dist/entry-34.js +1 -0
  102. package/dist/entry-35.js +1 -0
  103. package/dist/entry-36.js +1 -0
  104. package/dist/entry-37.js +1 -0
  105. package/dist/entry-38.js +1 -0
  106. package/dist/entry-39.js +1 -0
  107. package/dist/entry-4.js +1 -0
  108. package/dist/entry-40.js +1 -0
  109. package/dist/entry-41.js +1 -0
  110. package/dist/entry-42.js +1 -0
  111. package/dist/entry-43.js +1 -0
  112. package/dist/entry-44.js +1 -0
  113. package/dist/entry-45.js +1 -0
  114. package/dist/entry-46.js +1 -0
  115. package/dist/entry-47.js +1 -0
  116. package/dist/entry-48.js +1 -0
  117. package/dist/entry-49.js +1 -0
  118. package/dist/entry-5.js +1 -0
  119. package/dist/entry-50.js +1 -0
  120. package/dist/entry-51.js +1 -0
  121. package/dist/entry-52.js +1 -0
  122. package/dist/entry-53.js +1 -0
  123. package/dist/entry-54.js +0 -0
  124. package/dist/entry-55.js +1 -0
  125. package/dist/entry-56.js +0 -0
  126. package/dist/entry-57.js +1 -0
  127. package/dist/entry-58.js +1 -0
  128. package/dist/entry-59.js +1 -0
  129. package/dist/entry-6.js +1 -0
  130. package/dist/entry-60.js +1 -0
  131. package/dist/entry-61.js +1 -0
  132. package/dist/entry-62.js +1 -0
  133. package/dist/entry-63.js +0 -0
  134. package/dist/entry-64.js +1 -0
  135. package/dist/entry-65.js +0 -0
  136. package/dist/entry-66.js +1 -0
  137. package/dist/entry-67.js +1 -0
  138. package/dist/entry-68.js +1 -0
  139. package/dist/entry-69.js +1 -0
  140. package/dist/entry-7.js +1 -0
  141. package/dist/entry-70.js +1 -0
  142. package/dist/entry-71.js +1 -0
  143. package/dist/entry-72.js +1 -0
  144. package/dist/entry-73.js +1 -0
  145. package/dist/entry-74.js +1 -0
  146. package/dist/entry-75.js +1 -0
  147. package/dist/entry-76.js +1 -0
  148. package/dist/entry-77.js +1 -0
  149. package/dist/entry-78.js +1 -0
  150. package/dist/entry-79.js +1 -0
  151. package/dist/entry-8.js +1 -0
  152. package/dist/entry-80.js +1 -0
  153. package/dist/entry-9.js +1 -0
  154. package/dist/pi-agent-ide.js +13 -0
  155. package/docs/architecture.md +21 -17
  156. package/docs/configuration.md +180 -52
  157. package/docs/development.md +105 -5
  158. package/docs/extensions.md +64 -4
  159. package/docs/generated/tool-catalog/cmake.md +5 -5
  160. package/docs/generated/tool-catalog/csharp.md +5 -5
  161. package/docs/generated/tool-catalog/css.md +7 -6
  162. package/docs/generated/tool-catalog/dart.md +9 -0
  163. package/docs/generated/tool-catalog/dockerfile.md +5 -5
  164. package/docs/generated/tool-catalog/elixir.md +9 -0
  165. package/docs/generated/tool-catalog/html.md +7 -5
  166. package/docs/generated/tool-catalog/index.md +9 -0
  167. package/docs/generated/tool-catalog/javascript.md +8 -6
  168. package/docs/generated/tool-catalog/json.md +7 -6
  169. package/docs/generated/tool-catalog/julia.md +8 -0
  170. package/docs/generated/tool-catalog/kotlin.md +6 -5
  171. package/docs/generated/tool-catalog/markdown.md +6 -5
  172. package/docs/generated/tool-catalog/powershell.md +9 -0
  173. package/docs/generated/tool-catalog/python.md +6 -6
  174. package/docs/generated/tool-catalog/r.md +9 -0
  175. package/docs/generated/tool-catalog/scala.md +9 -0
  176. package/docs/generated/tool-catalog/svelte.md +9 -0
  177. package/docs/generated/tool-catalog/toml.md +6 -5
  178. package/docs/generated/tool-catalog/typescript.md +9 -6
  179. package/docs/generated/tool-catalog/vue.md +9 -0
  180. package/docs/generated/tool-catalog/yaml.md +6 -5
  181. package/docs/generated/tool-catalog/zig.md +9 -0
  182. package/docs/tools.md +88 -6
  183. package/node_modules/pi-agent-doctor/package.json +15 -5
  184. package/node_modules/pi-agent-doctor/runtime/entry-16.js +1 -0
  185. package/node_modules/pi-agent-doctor/runtime/entry-17.js +1 -0
  186. package/node_modules/pi-agent-doctor/runtime/entry-18.js +1 -0
  187. package/node_modules/pi-agent-doctor/runtime/entry-19.js +1 -0
  188. package/node_modules/pi-agent-doctor/runtime/entry-20.js +1 -0
  189. package/node_modules/pi-agent-doctor/src/catalog.ts +27 -1
  190. package/node_modules/pi-agent-doctor/src/evidence.ts +118 -0
  191. package/node_modules/pi-agent-doctor/src/executable.ts +85 -6
  192. package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +30 -4
  193. package/node_modules/pi-agent-filesystem/index.ts +4 -3
  194. package/node_modules/pi-agent-filesystem/package.json +7 -7
  195. package/node_modules/pi-agent-filesystem/runtime/entry-21.js +2 -0
  196. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  197. package/node_modules/pi-agent-filesystem-image/runtime/entry-22.js +2 -0
  198. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  199. package/node_modules/pi-agent-filesystem-pdf/runtime/entry-23.js +2 -0
  200. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  201. package/node_modules/pi-agent-filesystem-text/runtime/entry-24.js +2 -0
  202. package/node_modules/pi-agent-ide-ast/package.json +11 -10
  203. package/node_modules/pi-agent-ide-ast/runtime/entry-25.js +1 -0
  204. package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +2 -0
  205. package/node_modules/pi-agent-ide-ast/src/api/scope.ts +1 -1
  206. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +3 -0
  207. package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +4 -1
  208. package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +25 -0
  209. package/node_modules/pi-agent-ide-ast/src/extension.ts +13 -5
  210. package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +6 -0
  211. package/node_modules/pi-agent-ide-changes/index.ts +6 -2
  212. package/node_modules/pi-agent-ide-changes/package.json +8 -7
  213. package/node_modules/pi-agent-ide-changes/runtime/entry-27.js +1 -0
  214. package/node_modules/pi-agent-ide-changes/runtime/entry-28.js +2 -0
  215. package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +6 -0
  216. package/node_modules/pi-agent-ide-changes/src/changes/change-groups.ts +1 -1
  217. package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +1 -1
  218. package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +1 -0
  219. package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +1 -1
  220. package/node_modules/pi-agent-ide-changes/src/doctor-plugin.ts +31 -1
  221. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +5 -0
  222. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +7 -0
  223. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  224. package/node_modules/pi-agent-ide-formatter/runtime/entry-29.js +2 -0
  225. package/node_modules/pi-agent-ide-formatter/src/catalog.ts +165 -13
  226. package/node_modules/pi-agent-ide-formatter/src/doctor-plugin.ts +115 -63
  227. package/node_modules/pi-agent-ide-formatter/src/registry.ts +86 -31
  228. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  229. package/node_modules/pi-agent-ide-languages/runtime/entry-30.js +2 -0
  230. package/node_modules/pi-agent-ide-languages/src/languages.ts +15 -0
  231. package/node_modules/pi-agent-ide-lint/index.ts +30 -155
  232. package/node_modules/pi-agent-ide-lint/package.json +8 -7
  233. package/node_modules/pi-agent-ide-lint/runtime/entry-31.js +2 -0
  234. package/node_modules/pi-agent-ide-lint/src/catalog.ts +210 -41
  235. package/node_modules/pi-agent-ide-lint/src/command-linter.ts +80 -4
  236. package/node_modules/pi-agent-ide-lint/src/diagnostics.ts +76 -34
  237. package/node_modules/pi-agent-ide-lint/src/doctor-plugin.ts +115 -64
  238. package/node_modules/pi-agent-ide-lint/src/registry.ts +87 -30
  239. package/node_modules/pi-agent-ide-lsp/index.ts +35 -134
  240. package/node_modules/pi-agent-ide-lsp/package.json +9 -8
  241. package/node_modules/pi-agent-ide-lsp/runtime/entry-32.js +2 -0
  242. package/node_modules/pi-agent-ide-lsp/src/catalog.ts +161 -7
  243. package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +1 -1
  244. package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +110 -0
  245. package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +108 -55
  246. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +248 -38
  247. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +2 -1
  248. package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +76 -0
  249. package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +137 -144
  250. package/node_modules/pi-agent-ide-lsp/src/lsp/file-watchers.ts +88 -0
  251. package/node_modules/pi-agent-ide-lsp/src/lsp/initialization-options.ts +14 -0
  252. package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +2 -2
  253. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +17 -36
  254. package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +139 -68
  255. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +1 -0
  256. package/node_modules/pi-agent-ide-lsp/src/lsp/transport-writer.ts +24 -0
  257. package/node_modules/pi-agent-ide-lsp/src/lsp/types.ts +13 -6
  258. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +5 -5
  259. package/node_modules/pi-agent-image/package.json +3 -3
  260. package/node_modules/pi-agent-image/runtime/entry-33.js +1 -0
  261. package/node_modules/pi-agent-invariant/package.json +12 -0
  262. package/node_modules/pi-agent-invariant/runtime/entry-34.js +1 -0
  263. package/node_modules/pi-agent-pdf/package.json +3 -3
  264. package/node_modules/pi-agent-pdf/runtime/entry-35.js +1 -0
  265. package/node_modules/pi-agent-pdf/src/pdf-converter.ts +3 -2
  266. package/node_modules/pi-agent-read/package.json +11 -9
  267. package/node_modules/pi-agent-read/runtime/entry-36.js +1 -0
  268. package/node_modules/pi-agent-read/runtime/entry-37.js +1 -0
  269. package/node_modules/pi-agent-read/runtime/entry-38.js +1 -0
  270. package/node_modules/pi-agent-read/runtime/entry-39.js +1 -0
  271. package/node_modules/pi-agent-read/runtime/entry-40.js +2 -0
  272. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  273. package/node_modules/pi-agent-read/src/api/tools/read.ts +113 -2
  274. package/node_modules/pi-agent-read/src/core/extension.ts +19 -0
  275. package/node_modules/pi-agent-read/src/core/read-core.ts +85 -13
  276. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +26 -10
  277. package/node_modules/pi-agent-read/src/core/tools/read/persisted-result.ts +72 -0
  278. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +102 -12
  279. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +27 -3
  280. package/node_modules/pi-agent-read/src/core/tools/read/views.ts +29 -0
  281. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +532 -46
  282. package/node_modules/pi-agent-resource/package.json +5 -2
  283. package/node_modules/pi-agent-resource/runtime/entry-41.js +1 -0
  284. package/node_modules/pi-agent-resource/src/content-conversion/content-converter.ts +1 -1
  285. package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +1 -1
  286. package/node_modules/pi-agent-resource/src/content-conversion/content-runner.ts +1 -1
  287. package/node_modules/pi-agent-resource/src/content-conversion/validation.ts +1 -1
  288. package/node_modules/pi-agent-search/package.json +7 -6
  289. package/node_modules/pi-agent-search/runtime/entry-42.js +1 -0
  290. package/node_modules/pi-agent-search/runtime/entry-43.js +1 -0
  291. package/node_modules/pi-agent-search/runtime/entry-44.js +1 -0
  292. package/node_modules/pi-agent-search/runtime/entry-45.js +2 -0
  293. package/node_modules/pi-agent-search/src/api/search.ts +4 -0
  294. package/node_modules/pi-agent-search/src/core/extension.ts +99 -27
  295. package/node_modules/pi-agent-search/src/core/search-config.ts +98 -0
  296. package/node_modules/pi-agent-search/src/core/search-core.ts +32 -28
  297. package/node_modules/pi-agent-search/src/core/search-timeout.ts +54 -0
  298. package/node_modules/pi-agent-search-text/index.ts +53 -3
  299. package/node_modules/pi-agent-search-text/package.json +9 -9
  300. package/node_modules/pi-agent-search-text/runtime/entry-46.js +2 -0
  301. package/node_modules/pi-agent-search-text/runtime/entry-47.js +1 -0
  302. package/node_modules/pi-agent-search-text/src/doctor-plugin.ts +20 -1
  303. package/node_modules/pi-agent-search-text/src/persisted-result.ts +56 -0
  304. package/node_modules/pi-agent-search-text/src/resolvers.ts +36 -34
  305. package/node_modules/pi-agent-search-text/src/search-query.ts +254 -71
  306. package/node_modules/pi-agent-search-text/src/search-recipe.ts +68 -0
  307. package/node_modules/pi-agent-search-text/src/search-renderer.ts +71 -117
  308. package/node_modules/pi-agent-search-text/src/search-result.ts +1 -0
  309. package/node_modules/pi-agent-search-text/src/search-session.ts +276 -110
  310. package/node_modules/pi-agent-text/package.json +6 -3
  311. package/node_modules/pi-agent-text/runtime/entry-48.js +1 -0
  312. package/node_modules/pi-agent-text/src/index.ts +23 -0
  313. package/node_modules/pi-agent-text/src/stored-text.ts +14 -0
  314. package/node_modules/pi-agent-text/src/text-anchor.ts +160 -16
  315. package/node_modules/pi-agent-text/src/text-document.ts +26 -5
  316. package/node_modules/pi-agent-text/src/text-target.ts +105 -0
  317. package/node_modules/pi-agent-text-anchor-constant/package.json +7 -4
  318. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-49.js +2 -0
  319. package/node_modules/pi-agent-text-anchor-constant/src/resolver.ts +6 -0
  320. package/node_modules/pi-agent-text-anchor-exact/index.ts +34 -0
  321. package/node_modules/pi-agent-text-anchor-exact/package.json +27 -0
  322. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-50.js +1 -0
  323. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-51.js +2 -0
  324. package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +230 -0
  325. package/node_modules/pi-agent-text-anchor-exact/src/config.ts +159 -0
  326. package/node_modules/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +100 -0
  327. package/node_modules/pi-agent-text-anchor-exact/src/recovery.ts +151 -0
  328. package/node_modules/pi-agent-text-anchor-line-hash/index.ts +8 -2
  329. package/node_modules/pi-agent-text-anchor-line-hash/package.json +10 -6
  330. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-52.js +1 -0
  331. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-53.js +2 -0
  332. package/node_modules/pi-agent-text-anchor-line-hash/src/anchor.ts +32 -1
  333. package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +20 -12
  334. package/node_modules/pi-agent-text-editor/package.json +22 -21
  335. package/node_modules/pi-agent-text-editor/runtime/entry-54.js +1 -0
  336. package/node_modules/pi-agent-text-editor/runtime/entry-55.js +1 -0
  337. package/node_modules/pi-agent-text-editor/runtime/entry-56.js +1 -0
  338. package/node_modules/pi-agent-text-editor/runtime/entry-57.js +1 -0
  339. package/node_modules/pi-agent-text-editor/runtime/entry-58.js +1 -0
  340. package/node_modules/pi-agent-text-editor/runtime/entry-59.js +1 -0
  341. package/node_modules/pi-agent-text-editor/runtime/entry-60.js +1 -0
  342. package/node_modules/pi-agent-text-editor/runtime/entry-61.js +1 -0
  343. package/node_modules/pi-agent-text-editor/runtime/entry-62.js +1 -0
  344. package/node_modules/pi-agent-text-editor/runtime/entry-63.js +1 -0
  345. package/node_modules/pi-agent-text-editor/runtime/entry-64.js +1 -0
  346. package/node_modules/pi-agent-text-editor/runtime/entry-65.js +1 -0
  347. package/node_modules/pi-agent-text-editor/runtime/entry-66.js +1 -0
  348. package/node_modules/pi-agent-text-editor/runtime/entry-67.js +1 -0
  349. package/node_modules/pi-agent-text-editor/runtime/entry-68.js +1 -0
  350. package/node_modules/pi-agent-text-editor/runtime/entry-69.js +2 -0
  351. package/node_modules/pi-agent-text-editor/src/api/anchor-inspection.ts +2 -0
  352. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +1 -0
  353. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +38 -0
  354. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +30 -15
  355. package/node_modules/pi-agent-text-editor/src/api/text-selection-anchor.ts +10 -13
  356. package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -1
  357. package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +12 -5
  358. package/node_modules/pi-agent-text-editor/src/core/extension.ts +15 -1
  359. package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +14 -10
  360. package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +1 -1
  361. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +3 -2
  362. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +19 -2
  363. package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +64 -0
  364. package/node_modules/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +1 -1
  365. package/node_modules/pi-agent-text-editor/src/core/read-fragment-resolver.ts +83 -0
  366. package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +96 -8
  367. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +4 -1
  368. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +1 -1
  369. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +194 -35
  370. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +43 -13
  371. package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +95 -0
  372. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +75 -5
  373. package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +7 -0
  374. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +541 -130
  375. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +5 -9
  376. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +2 -0
  377. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +228 -6
  378. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +50 -70
  379. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +25 -26
  380. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +30 -21
  381. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +57 -71
  382. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +30 -27
  383. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -0
  384. package/node_modules/pi-agent-text-editor-argument-order/package.json +3 -3
  385. package/node_modules/pi-agent-text-editor-argument-order/runtime/entry-70.js +2 -0
  386. package/node_modules/pi-agent-text-editor-overwrite/index.ts +1 -1
  387. package/node_modules/pi-agent-text-editor-overwrite/package.json +4 -3
  388. package/node_modules/pi-agent-text-editor-overwrite/runtime/entry-71.js +2 -0
  389. package/node_modules/pi-agent-text-editor-renderer/index.ts +21 -1
  390. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -3
  391. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-72.js +2 -0
  392. package/node_modules/pi-agent-text-editor-renderer/src/animation-pressure.ts +50 -0
  393. package/node_modules/pi-agent-text-editor-renderer/src/config.ts +73 -0
  394. package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +1 -1
  395. package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +77 -22
  396. package/node_modules/pi-agent-text-editor-renderer/src/diff-theme.ts +1 -1
  397. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +140 -24
  398. package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +274 -43
  399. package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +33 -6
  400. package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +47 -0
  401. package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +7 -0
  402. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +265 -105
  403. package/node_modules/pi-agent-text-editor-renderer/src/typing-interpolation.ts +96 -15
  404. package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +22 -6
  405. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -4
  406. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
  407. package/node_modules/pi-agent-tool-call-interception/package.json +5 -2
  408. package/node_modules/pi-agent-tool-call-interception/runtime/entry-74.js +1 -0
  409. package/node_modules/pi-agent-tool-call-interception/src/index.ts +175 -32
  410. package/node_modules/pi-agent-tool-ui/package.json +15 -0
  411. package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +1 -0
  412. package/node_modules/pi-agent-tool-ui/src/index.ts +318 -0
  413. package/node_modules/pi-agent-web/index.ts +16 -6
  414. package/node_modules/pi-agent-web/package.json +8 -6
  415. package/node_modules/pi-agent-web/runtime/entry-76.js +2 -0
  416. package/node_modules/pi-agent-web/src/browser-loader.ts +180 -0
  417. package/node_modules/pi-agent-web/src/doctor-plugin.ts +41 -0
  418. package/node_modules/pi-agent-web/src/resolver.ts +128 -24
  419. package/node_modules/pi-agent-web-html/package.json +6 -3
  420. package/node_modules/pi-agent-web-html/runtime/entry-77.js +2 -0
  421. package/node_modules/pi-agent-web-html/src/extract-readable-html.ts +19 -6
  422. package/node_modules/pi-agent-web-image/package.json +4 -4
  423. package/node_modules/pi-agent-web-image/runtime/entry-78.js +2 -0
  424. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  425. package/node_modules/pi-agent-web-pdf/runtime/entry-79.js +2 -0
  426. package/node_modules/pi-agent-web-text/package.json +4 -4
  427. package/node_modules/pi-agent-web-text/runtime/entry-80.js +2 -0
  428. package/package.json +68 -54
  429. package/src/api/code-view.ts +4 -0
  430. package/src/api/connect-tip-provider.ts +49 -0
  431. package/src/api/plugin-protocol.ts +41 -2
  432. package/src/api/tips.ts +77 -0
  433. package/src/api/tool-config/formatters.json +273 -0
  434. package/src/api/tool-config/linters.json +339 -0
  435. package/src/api/tool-config/lsp-servers.json +410 -0
  436. package/src/api/tool-config.ts +248 -12
  437. package/src/api/toolchain.ts +0 -5
  438. package/src/code-view/diagnostic-view.ts +121 -26
  439. package/src/code-view/source-view.ts +1 -1
  440. package/src/composite/builtin-extensions.ts +12 -6
  441. package/src/composite/extensions-config.ts +137 -0
  442. package/src/composite/selection.ts +58 -3
  443. package/src/core/diagnostic-store.ts +244 -0
  444. package/src/core/extension.ts +40 -0
  445. package/src/core/ide-core.ts +48 -3
  446. package/src/doctor/config-writer.ts +15 -2
  447. package/src/doctor/core.ts +47 -0
  448. package/src/doctor/discovery.ts +23 -70
  449. package/src/doctor/extension.ts +12 -1
  450. package/src/doctor/inventory.ts +24 -6
  451. package/src/doctor/run.ts +100 -87
  452. package/src/doctor/tip-provider.ts +92 -0
  453. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +4 -3
  454. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  455. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  456. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-22.js +2 -0
  457. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  458. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-23.js +2 -0
  459. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  460. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-24.js +2 -0
  461. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-21.js +2 -0
  462. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +16 -6
  463. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -6
  464. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +6 -3
  465. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-77.js +2 -0
  466. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/extract-readable-html.ts +19 -6
  467. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  468. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-78.js +2 -0
  469. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  470. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-79.js +2 -0
  471. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  472. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +2 -0
  473. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +2 -0
  474. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +180 -0
  475. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/doctor-plugin.ts +41 -0
  476. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +128 -24
  477. package/src/extensions/pi-agent-read/package.json +11 -9
  478. package/src/extensions/pi-agent-read/runtime/entry-36.js +1 -0
  479. package/src/extensions/pi-agent-read/runtime/entry-37.js +1 -0
  480. package/src/extensions/pi-agent-read/runtime/entry-38.js +1 -0
  481. package/src/extensions/pi-agent-read/runtime/entry-39.js +1 -0
  482. package/src/extensions/pi-agent-read/runtime/entry-40.js +2 -0
  483. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  484. package/src/extensions/pi-agent-read/src/api/tools/read.ts +113 -2
  485. package/src/extensions/pi-agent-read/src/core/extension.ts +19 -0
  486. package/src/extensions/pi-agent-read/src/core/read-core.ts +85 -13
  487. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +26 -10
  488. package/src/extensions/pi-agent-read/src/core/tools/read/persisted-result.ts +72 -0
  489. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +102 -12
  490. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +27 -3
  491. package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +29 -0
  492. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +532 -46
  493. package/src/extensions/pi-agent-search/package.json +7 -6
  494. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +53 -3
  495. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
  496. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-46.js +2 -0
  497. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-47.js +1 -0
  498. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/doctor-plugin.ts +20 -1
  499. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +56 -0
  500. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +36 -34
  501. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +254 -71
  502. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +68 -0
  503. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +71 -117
  504. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +1 -0
  505. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +276 -110
  506. package/src/extensions/pi-agent-search/runtime/entry-42.js +1 -0
  507. package/src/extensions/pi-agent-search/runtime/entry-43.js +1 -0
  508. package/src/extensions/pi-agent-search/runtime/entry-44.js +1 -0
  509. package/src/extensions/pi-agent-search/runtime/entry-45.js +2 -0
  510. package/src/extensions/pi-agent-search/src/api/search.ts +4 -0
  511. package/src/extensions/pi-agent-search/src/core/extension.ts +99 -27
  512. package/src/extensions/pi-agent-search/src/core/search-config.ts +98 -0
  513. package/src/extensions/pi-agent-search/src/core/search-core.ts +32 -28
  514. package/src/extensions/pi-agent-search/src/core/search-timeout.ts +54 -0
  515. package/src/extensions/pi-agent-text-editor/package.json +22 -21
  516. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +7 -4
  517. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-49.js +2 -0
  518. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/src/resolver.ts +6 -0
  519. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +34 -0
  520. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +27 -0
  521. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-50.js +1 -0
  522. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-51.js +2 -0
  523. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +230 -0
  524. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/config.ts +159 -0
  525. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +100 -0
  526. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/recovery.ts +151 -0
  527. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +8 -2
  528. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +10 -6
  529. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-52.js +1 -0
  530. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-53.js +2 -0
  531. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/anchor.ts +32 -1
  532. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +20 -12
  533. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +3 -3
  534. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-70.js +2 -0
  535. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +1 -1
  536. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +4 -3
  537. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/runtime/entry-71.js +2 -0
  538. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +21 -1
  539. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -3
  540. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-72.js +2 -0
  541. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/animation-pressure.ts +50 -0
  542. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/config.ts +73 -0
  543. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +1 -1
  544. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +77 -22
  545. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-theme.ts +1 -1
  546. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +140 -24
  547. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +274 -43
  548. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +33 -6
  549. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +47 -0
  550. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +7 -0
  551. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +265 -105
  552. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/typing-interpolation.ts +96 -15
  553. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +22 -6
  554. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -4
  555. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
  556. package/src/extensions/pi-agent-text-editor/runtime/entry-54.js +1 -0
  557. package/src/extensions/pi-agent-text-editor/runtime/entry-55.js +1 -0
  558. package/src/extensions/pi-agent-text-editor/runtime/entry-56.js +1 -0
  559. package/src/extensions/pi-agent-text-editor/runtime/entry-57.js +1 -0
  560. package/src/extensions/pi-agent-text-editor/runtime/entry-58.js +1 -0
  561. package/src/extensions/pi-agent-text-editor/runtime/entry-59.js +1 -0
  562. package/src/extensions/pi-agent-text-editor/runtime/entry-60.js +1 -0
  563. package/src/extensions/pi-agent-text-editor/runtime/entry-61.js +1 -0
  564. package/src/extensions/pi-agent-text-editor/runtime/entry-62.js +1 -0
  565. package/src/extensions/pi-agent-text-editor/runtime/entry-63.js +1 -0
  566. package/src/extensions/pi-agent-text-editor/runtime/entry-64.js +1 -0
  567. package/src/extensions/pi-agent-text-editor/runtime/entry-65.js +1 -0
  568. package/src/extensions/pi-agent-text-editor/runtime/entry-66.js +1 -0
  569. package/src/extensions/pi-agent-text-editor/runtime/entry-67.js +1 -0
  570. package/src/extensions/pi-agent-text-editor/runtime/entry-68.js +1 -0
  571. package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +2 -0
  572. package/src/extensions/pi-agent-text-editor/src/api/anchor-inspection.ts +2 -0
  573. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +1 -0
  574. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +38 -0
  575. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +30 -15
  576. package/src/extensions/pi-agent-text-editor/src/api/text-selection-anchor.ts +10 -13
  577. package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -1
  578. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +12 -5
  579. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +15 -1
  580. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +14 -10
  581. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +1 -1
  582. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +3 -2
  583. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +19 -2
  584. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +64 -0
  585. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +1 -1
  586. package/src/extensions/pi-agent-text-editor/src/core/read-fragment-resolver.ts +83 -0
  587. package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +96 -8
  588. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +4 -1
  589. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +1 -1
  590. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +194 -35
  591. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +43 -13
  592. package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +95 -0
  593. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +75 -5
  594. package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +7 -0
  595. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +541 -130
  596. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +5 -9
  597. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +2 -0
  598. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +228 -6
  599. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +50 -70
  600. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +25 -26
  601. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +30 -21
  602. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +57 -71
  603. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +30 -27
  604. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -0
  605. package/src/pi-agent-ide.ts +15 -3
  606. package/src/plugins/pi-agent-ide-ast/package.json +11 -10
  607. package/src/plugins/pi-agent-ide-ast/runtime/entry-25.js +1 -0
  608. package/src/plugins/pi-agent-ide-ast/runtime/entry-26.js +2 -0
  609. package/src/plugins/pi-agent-ide-ast/src/api/scope.ts +1 -1
  610. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +3 -0
  611. package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +4 -1
  612. package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +25 -0
  613. package/src/plugins/pi-agent-ide-ast/src/extension.ts +13 -5
  614. package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +6 -0
  615. package/src/plugins/pi-agent-ide-changes/index.ts +6 -2
  616. package/src/plugins/pi-agent-ide-changes/package.json +8 -7
  617. package/src/plugins/pi-agent-ide-changes/runtime/entry-27.js +1 -0
  618. package/src/plugins/pi-agent-ide-changes/runtime/entry-28.js +2 -0
  619. package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +6 -0
  620. package/src/plugins/pi-agent-ide-changes/src/changes/change-groups.ts +1 -1
  621. package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +1 -1
  622. package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +1 -0
  623. package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +1 -1
  624. package/src/plugins/pi-agent-ide-changes/src/doctor-plugin.ts +31 -1
  625. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +5 -0
  626. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +7 -0
  627. package/src/plugins/pi-agent-ide-diagnostics/index.ts +1 -0
  628. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +199 -0
  629. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  630. package/src/plugins/pi-agent-ide-formatter/runtime/entry-29.js +2 -0
  631. package/src/plugins/pi-agent-ide-formatter/src/catalog.ts +165 -13
  632. package/src/plugins/pi-agent-ide-formatter/src/doctor-plugin.ts +115 -63
  633. package/src/plugins/pi-agent-ide-formatter/src/registry.ts +86 -31
  634. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  635. package/src/plugins/pi-agent-ide-languages/runtime/entry-30.js +2 -0
  636. package/src/plugins/pi-agent-ide-languages/src/languages.ts +15 -0
  637. package/src/plugins/pi-agent-ide-lint/index.ts +30 -155
  638. package/src/plugins/pi-agent-ide-lint/package.json +8 -7
  639. package/src/plugins/pi-agent-ide-lint/runtime/entry-31.js +2 -0
  640. package/src/plugins/pi-agent-ide-lint/src/catalog.ts +210 -41
  641. package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +80 -4
  642. package/src/plugins/pi-agent-ide-lint/src/diagnostics.ts +76 -34
  643. package/src/plugins/pi-agent-ide-lint/src/doctor-plugin.ts +115 -64
  644. package/src/plugins/pi-agent-ide-lint/src/registry.ts +87 -30
  645. package/src/plugins/pi-agent-ide-lsp/index.ts +35 -134
  646. package/src/plugins/pi-agent-ide-lsp/package.json +9 -8
  647. package/src/plugins/pi-agent-ide-lsp/runtime/entry-32.js +2 -0
  648. package/src/plugins/pi-agent-ide-lsp/src/catalog.ts +161 -7
  649. package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +1 -1
  650. package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +110 -0
  651. package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +108 -55
  652. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +248 -38
  653. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +2 -1
  654. package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +76 -0
  655. package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +137 -144
  656. package/src/plugins/pi-agent-ide-lsp/src/lsp/file-watchers.ts +88 -0
  657. package/src/plugins/pi-agent-ide-lsp/src/lsp/initialization-options.ts +14 -0
  658. package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +2 -2
  659. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +17 -36
  660. package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +139 -68
  661. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +1 -0
  662. package/src/plugins/pi-agent-ide-lsp/src/lsp/transport-writer.ts +24 -0
  663. package/src/plugins/pi-agent-ide-lsp/src/lsp/types.ts +13 -6
  664. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +5 -5
  665. package/src/post-edit/gate.ts +17 -141
  666. package/src/tips/core.ts +86 -0
  667. package/src/tips/extension.ts +115 -0
  668. package/src/tips/persistence.ts +225 -0
  669. package/src/tips/tip-callout.ts +77 -0
  670. package/src/toolchain/registry.ts +8 -23
  671. package/src/toolchain/types.ts +8 -74
  672. package/node_modules/pi-agent-search-semantic/index.ts +0 -97
  673. package/node_modules/pi-agent-search-semantic/package.json +0 -17
  674. package/node_modules/pi-agent-search-text/src/lucene-query-parser.d.ts +0 -20
  675. package/node_modules/pi-agent-search-web/index.ts +0 -82
  676. package/node_modules/pi-agent-search-web/package.json +0 -20
  677. package/node_modules/pi-agent-search-web/src/config.ts +0 -560
  678. package/node_modules/pi-agent-search-web/src/doctor-plugin.ts +0 -40
  679. package/node_modules/pi-agent-search-web/src/providers/duckduckgo-html.ts +0 -74
  680. package/node_modules/pi-agent-search-web/src/providers/endpoints.ts +0 -81
  681. package/node_modules/pi-agent-search-web/src/providers/request.ts +0 -427
  682. package/node_modules/pi-agent-search-web/src/providers/response.ts +0 -353
  683. package/node_modules/pi-agent-search-web/src/search-format.ts +0 -24
  684. package/node_modules/pi-agent-search-web/src/search.ts +0 -376
  685. package/node_modules/pi-agent-search-web/src/types.ts +0 -141
  686. package/src/composite/config.ts +0 -100
  687. package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/index.ts +0 -97
  688. package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/package.json +0 -17
  689. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/lucene-query-parser.d.ts +0 -20
  690. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/index.ts +0 -82
  691. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/package.json +0 -20
  692. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/config.ts +0 -560
  693. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/doctor-plugin.ts +0 -40
  694. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/duckduckgo-html.ts +0 -74
  695. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/endpoints.ts +0 -81
  696. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/request.ts +0 -427
  697. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/response.ts +0 -353
  698. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search-format.ts +0 -24
  699. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search.ts +0 -376
  700. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/types.ts +0 -141
  701. package/src/toolchain/gate.ts +0 -305
  702. /package/{src/utils/required-value.ts → node_modules/pi-agent-invariant/src/index.ts} +0 -0
@@ -1,15 +1,19 @@
1
- import { access } from "node:fs/promises";
2
- import path from "node:path";
3
-
4
1
  import { DOCTOR_API_VERSION, DOCTOR_PROTOCOL } from "pi-agent-doctor/api/plugin-protocol";
5
- import { projectIdeConfigPath } from "pi-agent-ide/api/tool-config";
6
2
  import { URI } from "vscode-uri";
7
3
 
4
+ import { hasConfiguredExecutable } from "pi-agent-ide/api/tool-config";
5
+
8
6
  import { LSP_RECIPES } from "./catalog.js";
9
7
  import { LspClient } from "./lsp/client.js";
10
8
  import { LspServerRegistry } from "./lsp/registry.js";
11
9
 
12
- import type { DoctorFinding, DoctorPlugin } from "pi-agent-doctor/api/plugin-protocol";
10
+ import type {
11
+ DoctorContext,
12
+ DoctorFinding,
13
+ DoctorPlugin,
14
+ DoctorSetupInspection,
15
+ } from "pi-agent-doctor/api/plugin-protocol";
16
+ import type { ResolvedServer } from "./lsp/types.js";
13
17
 
14
18
  /**
15
19
  Doctor contribution owned by the LSP plugin.
@@ -23,67 +27,65 @@ export const lspDoctorPlugin: DoctorPlugin = {
23
27
  api.addToolRecipe(recipe);
24
28
  }
25
29
 
30
+ api.addSetupCheck({
31
+ id: "effective-config",
32
+ inspect: inspectLspSetup,
33
+ });
34
+
26
35
  api.addCheck({
27
36
  id: "config",
28
37
  title: "LSP",
29
38
  async run(context) {
30
- const file = projectIdeConfigPath(context.cwd, "lsp-servers");
31
-
32
39
  try {
33
- await access(file);
34
- const registry = await LspServerRegistry.fromPackageDir(context.cwd);
35
- const findings: DoctorFinding[] = [
36
- {
37
- status: "pass",
38
- message: `${Object.keys(registry.servers).length} language servers loaded`,
39
- detail: file,
40
- },
41
- ];
40
+ const registry = await LspServerRegistry.fromPackageDir(context.cwd, {
41
+ environment: context.env,
42
+ });
43
+ const applicable = applicableServers(registry, context.files);
42
44
 
43
- for (const [id, server] of Object.entries(registry.servers)) {
44
- if (
45
- !Object.values(server.languages).some((language) =>
46
- context.files.some((file) =>
47
- language.extensions.includes(path.extname(file).toLowerCase()),
48
- ),
49
- )
50
- ) {
51
- continue;
52
- }
53
- const client = new LspClient({
54
- serverId: id,
55
- rootUri: URI.file(context.cwd).toString(),
56
- command: server.command,
57
- env: definedEnvironment(context.env, server.env),
58
- ...(server.initializationOptions && { initOptions: server.initializationOptions }),
59
- ...(server.settings && { settings: server.settings }),
60
- ...(server.timeoutMs && { timeoutMs: server.timeoutMs }),
61
- });
62
-
63
- try {
64
- await client.start();
65
- findings.push({ status: "pass", message: `${id} initialized` });
66
- } catch (error) {
67
- findings.push({
68
- status: "fail",
69
- message: `${id}: ${error instanceof Error ? error.message : String(error)}`,
70
- });
71
- } finally {
72
- await client.shutdown().catch(() => {});
73
- }
45
+ if (applicable.length === 0) {
46
+ return [
47
+ { status: "skip", message: "No language server matches the inspected project files" },
48
+ ];
74
49
  }
75
50
 
76
- return findings;
77
- } catch (error) {
78
- if (isMissing(error)) {
79
- return [{ status: "warn", message: "LSP config is not created", detail: file }];
80
- }
51
+ return await Promise.all(
52
+ applicable.map(async (server): Promise<DoctorFinding> => {
53
+ const label = `${server.serverId} [${server.layer}] command ${JSON.stringify(server.config.command)}`;
54
+ const client = new LspClient({
55
+ serverId: server.serverId,
56
+ rootUri: URI.file(context.cwd).toString(),
57
+ command: server.config.command,
58
+ env: definedEnvironment(context.env, server.config.env),
59
+ ...(server.config.initializationOptions && {
60
+ initOptions: server.config.initializationOptions,
61
+ }),
62
+ ...(server.config.settings && { settings: server.config.settings }),
63
+ ...(server.config.timeoutMs && { timeoutMs: server.config.timeoutMs }),
64
+ });
81
65
 
66
+ try {
67
+ await client.start();
68
+ return {
69
+ status: "pass",
70
+ message: `${label}: initialized`,
71
+ detail: server.sourcePath,
72
+ };
73
+ } catch (error) {
74
+ return {
75
+ status: "fail",
76
+ message: `${label}: ${error instanceof Error ? error.message : String(error)}`,
77
+ detail: server.sourcePath,
78
+ };
79
+ } finally {
80
+ await client.shutdown().catch(() => {});
81
+ }
82
+ }),
83
+ );
84
+ } catch (error) {
82
85
  return [
83
86
  {
84
87
  status: "fail",
85
88
  message: error instanceof Error ? error.message : String(error),
86
- detail: file,
87
89
  },
88
90
  ];
89
91
  }
@@ -92,8 +94,59 @@ export const lspDoctorPlugin: DoctorPlugin = {
92
94
  },
93
95
  };
94
96
 
95
- function isMissing(error: unknown): boolean {
96
- return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
97
+ async function inspectLspSetup(context: DoctorContext): Promise<DoctorSetupInspection> {
98
+ try {
99
+ const registry = await LspServerRegistry.fromPackageDir(context.cwd, {
100
+ environment: context.env,
101
+ });
102
+ const selections = [];
103
+ const actions = new Map<string, { readonly id: string; readonly message: string }>();
104
+
105
+ for (const [languageId, files] of context.detectedLanguages) {
106
+ const selected = files
107
+ .flatMap((file) => registry.resolve(file))
108
+ .find((server) => server.languageId === languageId);
109
+ if (selected === undefined) {
110
+ continue;
111
+ }
112
+
113
+ selections.push({ kind: "lsp" as const, languageId, toolId: selected.serverId });
114
+ if (!(await hasConfiguredExecutable(selected.config, context.cwd, context.env))) {
115
+ actions.set(selected.serverId, {
116
+ id: `lsp-${selected.serverId}-unavailable`,
117
+ message: `Configured language server ${selected.serverId} cannot run ${JSON.stringify(selected.config.command)}`,
118
+ });
119
+ }
120
+ }
121
+
122
+ return { selections, actions: [...actions.values()] };
123
+ } catch (error) {
124
+ return {
125
+ actions: [
126
+ {
127
+ id: "lsp-config-invalid",
128
+ message: `Language server configuration cannot load: ${error instanceof Error ? error.message : String(error)}`,
129
+ },
130
+ ],
131
+ };
132
+ }
133
+ }
134
+
135
+ function applicableServers(
136
+ registry: LspServerRegistry,
137
+ files: readonly string[],
138
+ ): readonly ResolvedServer[] {
139
+ const applicable = new Map<string, ResolvedServer>();
140
+
141
+ for (const file of files) {
142
+ const server = registry.resolve(file)[0];
143
+
144
+ if (server !== undefined && !applicable.has(server.serverId)) {
145
+ applicable.set(server.serverId, server);
146
+ }
147
+ }
148
+
149
+ return [...applicable.values()];
97
150
  }
98
151
 
99
152
  function definedEnvironment(
@@ -1,15 +1,30 @@
1
- import { requiredValue } from "../../../../utils/required-value.js";
1
+ import { requiredValue } from "pi-agent-invariant";
2
2
  import { type ChildProcess } from "node:child_process";
3
3
 
4
+ import path from "node:path";
5
+
4
6
  import spawnProcess from "cross-spawn";
7
+ import { createConfiguredProcessEnvironment } from "pi-agent-ide/api/tool-config";
5
8
  import {
6
9
  createMessageConnection,
10
+ CancellationTokenSource,
7
11
  type MessageConnection,
8
12
  StreamMessageReader,
9
- StreamMessageWriter,
10
13
  } from "vscode-jsonrpc/node";
11
14
  import { URI } from "vscode-uri";
12
15
 
16
+ import type { LspDiagnostic } from "./types.js";
17
+
18
+ import { LspFileWatchers } from "./file-watchers.js";
19
+
20
+ import { TransportWriter } from "./transport-writer.js";
21
+
22
+ /** Latest push observation for an open document, without a completion guarantee. */
23
+ export interface LspDiagnosticPublication {
24
+ readonly version?: number;
25
+ readonly diagnostics: LspDiagnostic[];
26
+ }
27
+
13
28
  /**
14
29
  * Generic LSP client — JSON-RPC over stdio.
15
30
  *
@@ -24,8 +39,16 @@ export class LspClient {
24
39
  private _disposed = false;
25
40
 
26
41
  private _crashed = false;
42
+
43
+ private _stderr = "";
44
+
45
+ private _fileWatchers: LspFileWatchers | undefined;
27
46
  private readonly _handlers = new Map<string, ((parameters: unknown) => void)[]>();
28
47
  private readonly _documentVersions = new Map<string, number>();
48
+
49
+ private readonly _documentContents = new Map<string, string>();
50
+
51
+ private readonly _diagnosticPublications = new Map<string, LspDiagnosticPublication>();
29
52
  private _diagnosticMode: "unknown" | "pull" | "push" = "unknown";
30
53
  private readonly _activeDiagnosticRequests = new Set<string>();
31
54
 
@@ -79,28 +102,17 @@ export class LspClient {
79
102
  this._diagnosticMode = mode;
80
103
  }
81
104
 
82
- get hasServerDiagnosticsCapability(): boolean {
83
- if (!this._serverCapabilities) {
84
- return false;
85
- }
86
-
87
- const td = this._serverCapabilities.textDocument as Record<string, unknown> | undefined;
88
-
89
- if (!td) {
90
- return false;
91
- }
92
-
93
- // Pull-model diagnostic (LSP 3.17+)
94
- if (td.diagnostic) {
95
- return true;
96
- }
97
-
98
- // Push-model publishDiagnostics
99
- if (td.publishDiagnostics) {
100
- return true;
101
- }
105
+ /** Maximum wait for a server response, including pushed diagnostics. */
106
+ get timeoutMs(): number {
107
+ return this._timeoutMs;
108
+ }
102
109
 
103
- return false;
110
+ /** Whether initialization advertised a server-specific executeCommand capability. */
111
+ supportsCommand(command: string): boolean {
112
+ const provider = this._serverCapabilities?.executeCommandProvider as
113
+ | { commands?: unknown }
114
+ | undefined;
115
+ return Array.isArray(provider?.commands) && provider.commands.includes(command);
104
116
  }
105
117
 
106
118
  get hasFoldingRangeCapability(): boolean {
@@ -112,6 +124,11 @@ export class LspClient {
112
124
  return this._documentVersions.get(uri);
113
125
  }
114
126
 
127
+ /** Reuse a push that arrived after the latest synchronization, including an empty publication. */
128
+ diagnosticPublication(uri: string): LspDiagnosticPublication | undefined {
129
+ return this._diagnosticPublications.get(uri);
130
+ }
131
+
115
132
  beginDiagnosticRequest(uri: string): void {
116
133
  this._activeDiagnosticRequests.add(uri);
117
134
  }
@@ -134,11 +151,20 @@ export class LspClient {
134
151
  }
135
152
 
136
153
  const bin = requiredValue(this._command[0]);
154
+ const projectRoot = URI.parse(this.rootUri).fsPath;
155
+
156
+ const workspaceFolders = [
157
+ { uri: this.rootUri, name: path.basename(projectRoot) || projectRoot },
158
+ ];
137
159
 
138
160
  const childProcess = spawnProcess(bin, this._args, {
139
161
  stdio: ["pipe", "pipe", "pipe"],
140
- cwd: URI.parse(this.rootUri).fsPath,
141
- env: { ...process.env, ...this._env },
162
+ cwd: projectRoot,
163
+ env: createConfiguredProcessEnvironment(
164
+ { command: this._command, env: this._env },
165
+ projectRoot,
166
+ process.env,
167
+ ),
142
168
  });
143
169
  this._process = childProcess;
144
170
  const spawnPromise = waitForSpawn(childProcess);
@@ -149,6 +175,12 @@ export class LspClient {
149
175
  childProcess.stdout?.on("error", () => void 0);
150
176
  childProcess.stderr?.on("error", () => void 0);
151
177
 
178
+ this._stderr = "";
179
+ childProcess.stderr?.setEncoding("utf8");
180
+ childProcess.stderr?.on("data", (chunk: string) => {
181
+ this._stderr = (this._stderr + chunk).slice(-4096);
182
+ });
183
+
152
184
  childProcess.on("error", (error) => {
153
185
  const code = "code" in error ? (error as { code?: unknown }).code : undefined;
154
186
 
@@ -163,6 +195,7 @@ export class LspClient {
163
195
  });
164
196
 
165
197
  childProcess.on("exit", (code, _signal) => {
198
+ this._fileWatchers?.dispose();
166
199
  if (!this._disposed && code !== 0 && code !== null) {
167
200
  this._crashed = true;
168
201
  }
@@ -174,24 +207,106 @@ export class LspClient {
174
207
  });
175
208
 
176
209
  await spawnPromise;
177
- this._connection = createMessageConnection(
210
+ const connection = createMessageConnection(
178
211
  new StreamMessageReader(requiredValue(childProcess.stdout)),
179
- new StreamMessageWriter(requiredValue(childProcess.stdin)),
212
+ new TransportWriter(requiredValue(childProcess.stdin), (error) => {
213
+ if (this._connection !== connection || this._disposed) return;
214
+ this._crashed = true;
215
+ this._initialized = false;
216
+ this._fileWatchers?.dispose();
217
+ connection.dispose();
218
+ console.error(`[lsp] ${this.serverId}: transport write failed:`, error);
219
+ }),
180
220
  );
221
+ this._connection = connection;
181
222
 
182
223
  this._connection.onError((error) => {
183
224
  console.error(`[lsp] ${this.serverId}: connection error:`, error);
184
225
  });
185
226
 
227
+ this._fileWatchers = new LspFileWatchers(
228
+ projectRoot,
229
+ (change) => {
230
+ this._sendNotification("workspace/didChangeWatchedFiles", { changes: [change] });
231
+ },
232
+ (error) => console.error(`[lsp] ${this.serverId}: file watcher failed:`, error),
233
+ );
234
+ this._connection.onRequest(
235
+ "client/registerCapability",
236
+ async (parameters: {
237
+ registrations: {
238
+ id: string;
239
+ method: string;
240
+ registerOptions?: { watchers?: Parameters<LspFileWatchers["register"]>[1] };
241
+ }[];
242
+ }) => {
243
+ for (const registration of parameters.registrations) {
244
+ // Settings are fixed for this client and already served by workspace/configuration.
245
+ if (registration.method === "workspace/didChangeConfiguration") continue;
246
+ if (registration.method !== "workspace/didChangeWatchedFiles")
247
+ throw new Error(`Unsupported dynamic capability: ${registration.method}`);
248
+ await this._fileWatchers?.register(
249
+ registration.id,
250
+ registration.registerOptions?.watchers ?? [],
251
+ );
252
+ }
253
+ return null;
254
+ },
255
+ );
256
+ this._connection.onRequest(
257
+ "client/unregisterCapability",
258
+ (parameters: { unregisterations: { id: string }[] }) => {
259
+ for (const registration of parameters.unregisterations)
260
+ this._fileWatchers?.unregister(registration.id);
261
+ return null;
262
+ },
263
+ );
264
+ this._connection.onRequest("window/workDoneProgress/create", () => null);
265
+
266
+ this._connection.onRequest(
267
+ "workspace/configuration",
268
+ (parameters: { items: { section?: string }[] }) =>
269
+ parameters.items.map((item) => {
270
+ let value: unknown = this._settings ?? null;
271
+ for (const segment of item.section?.split(".").filter(Boolean) ?? []) {
272
+ value =
273
+ typeof value === "object" && value !== null
274
+ ? ((value as Record<string, unknown>)[segment] ?? null)
275
+ : null;
276
+ }
277
+ return value;
278
+ }),
279
+ );
280
+
186
281
  this._connection.listen();
187
282
 
188
283
  // Forward all incoming notifications to registered handlers
189
284
  this._connection.onNotification((method, ...parameters) => {
285
+ if (method === "textDocument/publishDiagnostics") {
286
+ const publication = parameters[0] as
287
+ | { uri?: unknown; version?: unknown; diagnostics?: unknown }
288
+ | undefined;
289
+ if (
290
+ publication &&
291
+ typeof publication.uri === "string" &&
292
+ Array.isArray(publication.diagnostics) &&
293
+ this._documentVersions.has(publication.uri) &&
294
+ (publication.version === undefined ||
295
+ publication.version === this.documentVersion(publication.uri))
296
+ ) {
297
+ this._diagnosticPublications.set(publication.uri, {
298
+ diagnostics: publication.diagnostics as LspDiagnostic[],
299
+ ...(typeof publication.version === "number" && { version: publication.version }),
300
+ });
301
+ }
302
+ }
190
303
  for (const handler of this._handlers.get(method) ?? []) {
191
304
  handler(parameters[0] as unknown);
192
305
  }
193
306
  });
194
307
 
308
+ this._connection.onRequest("workspace/workspaceFolders", () => workspaceFolders);
309
+
195
310
  interface InitResult {
196
311
  capabilities: Record<string, unknown>;
197
312
  }
@@ -200,14 +315,24 @@ export class LspClient {
200
315
  this._connection.sendRequest<InitResult>("initialize", {
201
316
  processId: process.pid,
202
317
  rootUri: this.rootUri,
318
+
319
+ workspaceFolders,
203
320
  capabilities: {
204
321
  workspace: {
205
322
  applyEdit: false,
323
+
324
+ configuration: true,
325
+
326
+ workspaceFolders: true,
327
+
328
+ didChangeWatchedFiles: { dynamicRegistration: true, relativePatternSupport: true },
206
329
  symbol: { dynamicRegistration: false },
207
330
  },
208
331
  textDocument: {
209
332
  synchronization: { didOpen: true, didChange: true, didClose: true },
210
333
  publishDiagnostics: { relatedInformation: true },
334
+
335
+ diagnostic: { dynamicRegistration: false, relatedDocumentSupport: false },
211
336
  documentSymbol: { hierarchicalDocumentSymbolSupport: true },
212
337
  foldingRange: { lineFoldingOnly: true },
213
338
  },
@@ -216,20 +341,30 @@ export class LspClient {
216
341
  }),
217
342
  this._timeoutMs,
218
343
  `[lsp] ${this.serverId}: initialize timed out`,
219
- );
344
+ ).catch((error: unknown) => {
345
+ const detail = this._stderr.trim();
346
+ if (!detail) throw error;
347
+ throw new Error(`[lsp] ${this.serverId}: ${detail}`, { cause: error });
348
+ });
220
349
 
221
- void this._connection.sendNotification("initialized", {
350
+ await this._connection.sendNotification("initialized", {
222
351
  capabilities: initResult.capabilities,
223
352
  });
224
353
 
225
354
  if (this._settings !== undefined) {
226
- void this._connection.sendNotification("workspace/didChangeConfiguration", {
355
+ await this._connection.sendNotification("workspace/didChangeConfiguration", {
227
356
  settings: this._settings,
228
357
  });
229
358
  }
230
359
 
360
+ if (this._crashed)
361
+ throw new Error(`[lsp] ${this.serverId}: transport failed during initialization`);
362
+
231
363
  this._initialized = true;
232
364
  this._serverCapabilities = initResult.capabilities;
365
+
366
+ // Unadvertised methods may return null or internal errors rather than MethodNotFound.
367
+ this._diagnosticMode = initResult.capabilities.diagnosticProvider ? "pull" : "push";
233
368
  }
234
369
 
235
370
  touch(): void {
@@ -237,6 +372,7 @@ export class LspClient {
237
372
  }
238
373
 
239
374
  async restart(): Promise<void> {
375
+ this._fileWatchers?.dispose();
240
376
  this._connection?.dispose();
241
377
  this._connection = null;
242
378
  this._process = null;
@@ -244,6 +380,8 @@ export class LspClient {
244
380
  this._crashed = false;
245
381
  this._disposed = false;
246
382
  this._documentVersions.clear();
383
+ this._documentContents.clear();
384
+ this._diagnosticPublications.clear();
247
385
  this._diagnosticMode = "unknown";
248
386
  this._activeDiagnosticRequests.clear();
249
387
  this._serverCapabilities = null;
@@ -252,14 +390,56 @@ export class LspClient {
252
390
 
253
391
  // ── LSP protocol ───────────────────────────────────────────────────
254
392
 
255
- async sendRequest<T = unknown>(method: string, parameters: unknown): Promise<T> {
393
+ /** Send a request, forwarding optional cancellation to the language server. */
394
+ async sendRequest<T = unknown>(
395
+ method: string,
396
+ parameters: unknown,
397
+ signal?: AbortSignal,
398
+ ): Promise<T> {
256
399
  this._assertReady();
257
- return requiredValue(this._connection).sendRequest(method, parameters);
400
+ signal?.throwIfAborted();
401
+ if (!signal) return requiredValue(this._connection).sendRequest(method, parameters);
402
+ const cancellation = new CancellationTokenSource();
403
+ let onAbort: (() => void) | undefined;
404
+ try {
405
+ const request = requiredValue(this._connection).sendRequest<T>(
406
+ method,
407
+ parameters,
408
+ cancellation.token,
409
+ );
410
+ return await Promise.race([
411
+ request,
412
+ new Promise<never>((_resolve, reject) => {
413
+ onAbort = () => {
414
+ cancellation.cancel();
415
+ reject(signal.reason);
416
+ };
417
+ signal.addEventListener("abort", onAbort, { once: true });
418
+ }),
419
+ ]);
420
+ } finally {
421
+ if (onAbort) signal.removeEventListener("abort", onAbort);
422
+ cancellation.dispose();
423
+ }
258
424
  }
259
425
 
426
+ /** Queue a notification; a failed write makes this client unavailable without escaping to Pi. */
260
427
  sendNotification(method: string, parameters: unknown): void {
261
428
  this._assertReady();
262
- void requiredValue(this._connection).sendNotification(method, parameters);
429
+ this._sendNotification(method, parameters);
430
+ }
431
+
432
+ private _sendNotification(method: string, parameters: unknown): void {
433
+ const connection = this._connection;
434
+ if (!connection) return;
435
+ void connection.sendNotification(method, parameters).catch((error: unknown) => {
436
+ if (this._connection !== connection || this._disposed) return;
437
+ this._crashed = true;
438
+ this._initialized = false;
439
+ this._fileWatchers?.dispose();
440
+ connection.dispose();
441
+ console.error(`[lsp] ${this.serverId}: notification ${method} failed:`, error);
442
+ });
263
443
  }
264
444
 
265
445
  /**
@@ -299,36 +479,58 @@ export class LspClient {
299
479
  return;
300
480
  }
301
481
 
482
+ this._diagnosticPublications.delete(uri);
302
483
  this.sendNotification("textDocument/didOpen", {
303
484
  textDocument: { uri, languageId, version, text },
304
485
  });
305
486
  this._documentVersions.set(uri, version);
487
+
488
+ this._documentContents.set(uri, text);
306
489
  }
307
490
 
308
- syncDocument(uri: string, text: string, languageId: string): void {
491
+ /** Sync content, optionally reporting a completed disk write to servers that request saves. */
492
+ syncDocument(uri: string, text: string, languageId: string, saved = false): void {
493
+ if (this._documentContents.get(uri) === text) return;
309
494
  const currentVersion = this._documentVersions.get(uri);
310
495
 
311
496
  if (currentVersion === undefined) {
312
497
  this.openDocument(uri, text, languageId);
313
- return;
498
+ } else {
499
+ this.changeDocument(uri, text, currentVersion + 1);
500
+ }
501
+ const synchronization = this._serverCapabilities?.textDocumentSync;
502
+ const save =
503
+ typeof synchronization === "object" && synchronization !== null
504
+ ? (synchronization as { save?: boolean | { includeText?: boolean } }).save
505
+ : undefined;
506
+ if (saved && save) {
507
+ this.sendNotification("textDocument/didSave", {
508
+ textDocument: { uri },
509
+ ...(typeof save === "object" && save.includeText && { text }),
510
+ });
314
511
  }
315
-
316
- this.changeDocument(uri, text, currentVersion + 1);
317
512
  }
318
513
 
319
514
  changeDocument(uri: string, text: string, version: number): void {
320
515
  const currentVersion = this._documentVersions.get(uri);
321
516
  const nextVersion = Math.max(version, (currentVersion ?? 0) + 1);
517
+ this._diagnosticPublications.delete(uri);
322
518
  this.sendNotification("textDocument/didChange", {
323
519
  textDocument: { uri, version: nextVersion },
324
520
  contentChanges: [{ text }],
325
521
  });
326
522
  this._documentVersions.set(uri, nextVersion);
523
+
524
+ this._documentContents.set(uri, text);
327
525
  }
328
526
 
329
527
  closeDocument(uri: string): void {
330
528
  this.sendNotification("textDocument/didClose", { textDocument: { uri } });
331
529
  this._documentVersions.delete(uri);
530
+
531
+ this._documentContents.delete(uri);
532
+
533
+ this._diagnosticPublications.delete(uri);
332
534
  }
333
535
 
334
536
  // ── cleanup ────────────────────────────────────────────────────────
@@ -340,9 +542,15 @@ export class LspClient {
340
542
 
341
543
  this._disposed = true;
342
544
 
545
+ this._fileWatchers?.dispose();
546
+
343
547
  if (this._connection && this._initialized) {
344
548
  try {
345
- await this._connection.sendRequest("shutdown");
549
+ await withTimeout(
550
+ this._connection.sendRequest("shutdown"),
551
+ Math.min(this._timeoutMs, 1000),
552
+ `[lsp] ${this.serverId}: shutdown timed out`,
553
+ );
346
554
  await this._connection.sendNotification("exit").catch(() => {
347
555
  /* ok */
348
556
  });
@@ -367,6 +575,8 @@ export class LspClient {
367
575
 
368
576
  this._initialized = false;
369
577
  this._documentVersions.clear();
578
+ this._documentContents.clear();
579
+ this._diagnosticPublications.clear();
370
580
  this._diagnosticMode = "unknown";
371
581
  this._activeDiagnosticRequests.clear();
372
582
  this._serverCapabilities = null;
@@ -1,4 +1,4 @@
1
- import { requiredValue } from "../../../../utils/required-value.js";
1
+ import { requiredValue } from "pi-agent-invariant";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
@@ -511,6 +511,7 @@ function filePathFromUri(uri: string): string {
511
511
  function displayFilePath(filePath: string, cwd: string): string {
512
512
  const relative = path.relative(cwd, filePath);
513
513
 
514
+ // oxlint-disable-next-line repo/no-parent-paths -- defensive check against traversal, not a traversal
514
515
  if (relative.length === 0 || relative.startsWith("..") || path.isAbsolute(relative)) {
515
516
  return filePath;
516
517
  }