pi-agent-ide 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (494) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/{chunk-XNXQYPVT.js → chunk-4LUW26BX.js} +1 -1
  3. package/dist/{chunk-2ZMYT6ZC.js → chunk-4U6KGABH.js} +1 -1
  4. package/dist/chunk-4ZTEPMJO.js +14 -0
  5. package/dist/{chunk-KNMWCDDK.js → chunk-6ACQQBUY.js} +1 -1
  6. package/dist/chunk-76WHES5H.js +7 -0
  7. package/dist/chunk-BHSO2MDK.js +6 -0
  8. package/dist/chunk-BMOJTJJJ.js +3 -0
  9. package/dist/chunk-GFWDXTOB.js +4 -0
  10. package/dist/{chunk-VSP2QQPQ.js → chunk-GIRAEVUJ.js} +1 -1
  11. package/dist/chunk-JJVXUL5U.js +2 -0
  12. package/dist/chunk-KCEOTU5Z.js +3 -0
  13. package/dist/chunk-KVGQG43U.js +1 -0
  14. package/dist/{chunk-MTTKFJV6.js → chunk-LQYZG62K.js} +1 -1
  15. package/dist/chunk-N34ATN52.js +1 -0
  16. package/dist/{chunk-PETQCA7G.js → chunk-P6T3Q7LB.js} +1 -1
  17. package/dist/chunk-QIJMV2P2.js +2 -0
  18. package/dist/chunk-QJFRAMK7.js +2 -0
  19. package/dist/{chunk-2SKAED2I.js → chunk-RAZOACDD.js} +2 -2
  20. package/dist/chunk-RIGRP3FD.js +1 -0
  21. package/dist/chunk-S3ZPXWX7.js +2 -0
  22. package/dist/{chunk-266RH77Z.js → chunk-THSCUT2L.js} +1 -1
  23. package/dist/{chunk-EEH4WYI7.js → chunk-WNMGUALD.js} +1 -1
  24. package/dist/chunk-WZI4YC2O.js +1 -0
  25. package/dist/{chunk-5A25RATC.js → chunk-X6MPU7UO.js} +3 -3
  26. package/dist/{chunk-QNZVPFSP.js → chunk-XF5PVZOS.js} +1 -1
  27. package/dist/{chunk-SJYDLHEF.js → chunk-ZXN3TWWW.js} +1 -1
  28. package/dist/entry-0.js +1 -1
  29. package/dist/entry-10.js +1 -1
  30. package/dist/entry-11.js +1 -1
  31. package/dist/entry-13.js +1 -1
  32. package/dist/entry-14.js +1 -1
  33. package/dist/entry-18.js +1 -1
  34. package/dist/entry-19.js +1 -1
  35. package/dist/entry-20.js +1 -1
  36. package/dist/entry-21.js +2 -1
  37. package/dist/entry-22.js +1 -1
  38. package/dist/entry-23.js +1 -1
  39. package/dist/entry-24.js +1 -1
  40. package/dist/entry-25.js +1 -1
  41. package/dist/entry-26.js +7 -1
  42. package/dist/entry-27.js +1 -1
  43. package/dist/entry-28.js +1 -1
  44. package/dist/entry-29.js +1 -1
  45. package/dist/entry-30.js +1 -1
  46. package/dist/entry-31.js +4 -1
  47. package/dist/entry-32.js +8 -1
  48. package/dist/entry-33.js +1 -1
  49. package/dist/entry-34.js +1 -1
  50. package/dist/entry-35.js +1 -1
  51. package/dist/entry-36.js +1 -1
  52. package/dist/entry-37.js +1 -1
  53. package/dist/entry-38.js +1 -1
  54. package/dist/entry-39.js +1 -1
  55. package/dist/entry-4.js +1 -1
  56. package/dist/entry-40.js +14 -1
  57. package/dist/entry-41.js +1 -1
  58. package/dist/entry-42.js +1 -1
  59. package/dist/entry-43.js +1 -1
  60. package/dist/entry-44.js +1 -1
  61. package/dist/entry-45.js +7 -1
  62. package/dist/entry-46.js +11 -1
  63. package/dist/entry-47.js +1 -1
  64. package/dist/entry-48.js +1 -1
  65. package/dist/entry-49.js +1 -1
  66. package/dist/entry-50.js +1 -1
  67. package/dist/entry-51.js +1 -1
  68. package/dist/entry-52.js +1 -1
  69. package/dist/entry-53.js +1 -0
  70. package/dist/entry-54.js +0 -1
  71. package/dist/entry-55.js +1 -0
  72. package/dist/entry-56.js +0 -1
  73. package/dist/entry-57.js +1 -1
  74. package/dist/entry-58.js +1 -1
  75. package/dist/entry-59.js +1 -1
  76. package/dist/entry-60.js +1 -1
  77. package/dist/entry-61.js +1 -1
  78. package/dist/entry-62.js +1 -0
  79. package/dist/entry-63.js +0 -1
  80. package/dist/entry-64.js +1 -0
  81. package/dist/entry-65.js +0 -1
  82. package/dist/entry-66.js +1 -1
  83. package/dist/entry-67.js +1 -1
  84. package/dist/entry-68.js +1 -1
  85. package/dist/entry-69.js +59 -1
  86. package/dist/entry-70.js +4 -1
  87. package/dist/entry-71.js +1 -1
  88. package/dist/entry-72.js +29 -1
  89. package/dist/entry-73.js +2 -1
  90. package/dist/entry-74.js +1 -1
  91. package/dist/entry-75.js +1 -1
  92. package/dist/entry-76.js +1 -1
  93. package/dist/entry-77.js +3 -1
  94. package/dist/entry-78.js +1 -1
  95. package/dist/entry-79.js +1 -1
  96. package/dist/entry-80.js +1 -0
  97. package/dist/pi-agent-ide.js +2 -13
  98. package/docs/configuration.md +57 -1
  99. package/docs/extensions.md +4 -2
  100. package/docs/generated/tool-catalog/cmake.md +5 -5
  101. package/docs/generated/tool-catalog/csharp.md +5 -5
  102. package/docs/generated/tool-catalog/css.md +7 -7
  103. package/docs/generated/tool-catalog/dart.md +9 -0
  104. package/docs/generated/tool-catalog/dockerfile.md +5 -5
  105. package/docs/generated/tool-catalog/elixir.md +9 -0
  106. package/docs/generated/tool-catalog/html.md +7 -6
  107. package/docs/generated/tool-catalog/index.md +9 -0
  108. package/docs/generated/tool-catalog/javascript.md +8 -8
  109. package/docs/generated/tool-catalog/json.md +7 -7
  110. package/docs/generated/tool-catalog/julia.md +8 -0
  111. package/docs/generated/tool-catalog/kotlin.md +6 -5
  112. package/docs/generated/tool-catalog/markdown.md +6 -6
  113. package/docs/generated/tool-catalog/powershell.md +9 -0
  114. package/docs/generated/tool-catalog/python.md +6 -6
  115. package/docs/generated/tool-catalog/r.md +9 -0
  116. package/docs/generated/tool-catalog/scala.md +9 -0
  117. package/docs/generated/tool-catalog/svelte.md +9 -0
  118. package/docs/generated/tool-catalog/typescript.md +9 -8
  119. package/docs/generated/tool-catalog/vue.md +9 -0
  120. package/docs/generated/tool-catalog/yaml.md +6 -6
  121. package/docs/generated/tool-catalog/zig.md +9 -0
  122. package/docs/tools.md +1 -1
  123. package/node_modules/pi-agent-doctor/package.json +10 -3
  124. package/node_modules/pi-agent-doctor/runtime/entry-20.js +1 -0
  125. package/node_modules/pi-agent-doctor/src/catalog.ts +27 -1
  126. package/node_modules/pi-agent-doctor/src/evidence.ts +118 -0
  127. package/node_modules/pi-agent-doctor/src/executable.ts +63 -17
  128. package/node_modules/pi-agent-filesystem/index.ts +2 -2
  129. package/node_modules/pi-agent-filesystem/package.json +7 -7
  130. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  131. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  132. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  133. package/node_modules/pi-agent-filesystem-text/runtime/entry-24.js +2 -0
  134. package/node_modules/pi-agent-ide-ast/package.json +11 -11
  135. package/node_modules/pi-agent-ide-ast/runtime/entry-25.js +0 -1
  136. package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +2 -0
  137. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +3 -0
  138. package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +92 -19
  139. package/node_modules/pi-agent-ide-ast/src/extension.ts +9 -14
  140. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +60 -0
  141. package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
  142. package/node_modules/pi-agent-ide-changes/index.ts +1 -5
  143. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  144. package/node_modules/pi-agent-ide-changes/runtime/entry-27.js +0 -1
  145. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +1 -7
  146. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
  147. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  148. package/node_modules/pi-agent-ide-formatter/src/catalog.ts +131 -13
  149. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +12 -7
  150. package/node_modules/pi-agent-ide-formatter/src/registry.ts +20 -8
  151. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  152. package/node_modules/pi-agent-ide-languages/src/languages.ts +15 -0
  153. package/node_modules/pi-agent-ide-lint/index.ts +4 -1
  154. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  155. package/node_modules/pi-agent-ide-lint/src/catalog.ts +196 -39
  156. package/node_modules/pi-agent-ide-lint/src/command-linter.ts +23 -3
  157. package/node_modules/pi-agent-ide-lint/src/diagnostics.ts +73 -33
  158. package/node_modules/pi-agent-ide-lint/src/registry.ts +20 -8
  159. package/node_modules/pi-agent-ide-lsp/index.ts +1 -12
  160. package/node_modules/pi-agent-ide-lsp/package.json +9 -9
  161. package/node_modules/pi-agent-ide-lsp/runtime/entry-32.js +2 -0
  162. package/node_modules/pi-agent-ide-lsp/src/catalog.ts +161 -7
  163. package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +10 -10
  164. package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +2 -4
  165. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +162 -12
  166. package/node_modules/pi-agent-ide-lsp/src/lsp/file-watchers.ts +88 -0
  167. package/node_modules/pi-agent-ide-lsp/src/lsp/initialization-options.ts +14 -0
  168. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -4
  169. package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +69 -34
  170. package/node_modules/pi-agent-ide-lsp/src/lsp/transport-writer.ts +24 -0
  171. package/node_modules/pi-agent-ide-lsp/src/lsp/types.ts +5 -0
  172. package/node_modules/pi-agent-image/package.json +3 -3
  173. package/node_modules/pi-agent-image/src/image-converter.ts +1 -1
  174. package/node_modules/pi-agent-invariant/package.json +2 -2
  175. package/node_modules/pi-agent-pdf/package.json +3 -3
  176. package/node_modules/pi-agent-pdf/src/pdf-converter.ts +1 -1
  177. package/node_modules/pi-agent-read/package.json +11 -11
  178. package/node_modules/pi-agent-read/runtime/entry-39.js +0 -1
  179. package/node_modules/pi-agent-read/runtime/entry-40.js +2 -0
  180. package/node_modules/pi-agent-read/src/api/rendering.ts +3 -0
  181. package/node_modules/pi-agent-read/src/core/read-core.ts +6 -26
  182. package/node_modules/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
  183. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +28 -7
  184. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +35 -30
  185. package/node_modules/pi-agent-resource/package.json +2 -2
  186. package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +1 -8
  187. package/node_modules/pi-agent-search/package.json +7 -7
  188. package/node_modules/pi-agent-search/runtime/entry-44.js +0 -1
  189. package/node_modules/pi-agent-search/src/core/extension.ts +7 -5
  190. package/node_modules/pi-agent-search/src/core/search-core.ts +10 -0
  191. package/node_modules/pi-agent-search-text/index.ts +42 -33
  192. package/node_modules/pi-agent-search-text/package.json +9 -9
  193. package/node_modules/pi-agent-search-text/runtime/entry-46.js +1 -0
  194. package/node_modules/pi-agent-search-text/src/file-search.ts +9 -1
  195. package/node_modules/pi-agent-search-text/src/resolvers.ts +1 -1
  196. package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -0
  197. package/node_modules/pi-agent-search-text/src/search-session.ts +48 -0
  198. package/node_modules/pi-agent-text/package.json +3 -3
  199. package/node_modules/pi-agent-text/runtime/entry-48.js +1 -0
  200. package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
  201. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  202. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-49.js +2 -0
  203. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  204. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
  205. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-51.js +2 -0
  206. package/node_modules/pi-agent-text-anchor-line-hash/index.ts +2 -6
  207. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  208. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
  209. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-53.js +2 -0
  210. package/node_modules/pi-agent-text-editor/package.json +22 -22
  211. package/node_modules/pi-agent-text-editor/runtime/entry-68.js +0 -1
  212. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
  213. package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +71 -1
  214. package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
  215. package/node_modules/pi-agent-text-editor/src/core/extension.ts +7 -9
  216. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +27 -2
  217. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +38 -0
  218. package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
  219. package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
  220. package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
  221. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +23 -0
  222. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +5 -9
  223. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +54 -14
  224. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
  225. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
  226. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
  227. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
  228. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
  229. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
  230. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
  231. package/node_modules/pi-agent-text-editor-argument-order/package.json +3 -3
  232. package/node_modules/pi-agent-text-editor-overwrite/package.json +4 -4
  233. package/node_modules/pi-agent-text-editor-renderer/index.ts +5 -1
  234. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  235. package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
  236. package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
  237. package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
  238. package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
  239. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +52 -4
  240. package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
  241. package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
  242. package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
  243. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +5 -3
  244. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  245. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
  246. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  247. package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
  248. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  249. package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +1 -0
  250. package/node_modules/pi-agent-web/index.ts +1 -6
  251. package/node_modules/pi-agent-web/package.json +7 -7
  252. package/node_modules/pi-agent-web-html/package.json +3 -3
  253. package/node_modules/pi-agent-web-html/src/html-converter.ts +1 -1
  254. package/node_modules/pi-agent-web-image/package.json +4 -4
  255. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  256. package/node_modules/pi-agent-web-text/package.json +4 -4
  257. package/node_modules/pi-agent-web-text/runtime/entry-80.js +2 -0
  258. package/package.json +35 -35
  259. package/src/api/plugin-protocol.ts +2 -0
  260. package/src/api/text-editor.ts +7 -0
  261. package/src/api/tool-config/formatters.json +70 -12
  262. package/src/api/tool-config/linters.json +148 -66
  263. package/src/api/tool-config/lsp-servers.json +142 -7
  264. package/src/api/tool-config.ts +60 -24
  265. package/src/code-view/diagnostic-view.ts +14 -10
  266. package/src/composite/builtin-extensions.ts +148 -66
  267. package/src/composite/extensions-config.ts +18 -0
  268. package/src/core/diagnostic-entry.ts +94 -0
  269. package/src/core/diagnostic-store.ts +43 -21
  270. package/src/core/extension.ts +39 -17
  271. package/src/doctor/config-writer.ts +14 -1
  272. package/src/doctor/discovery.ts +13 -68
  273. package/src/doctor/run.ts +33 -1
  274. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +2 -2
  275. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  276. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  277. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  278. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  279. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-24.js +2 -0
  280. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-21.js +2 -0
  281. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +1 -6
  282. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  283. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  284. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +1 -1
  285. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  286. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  287. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  288. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +2 -0
  289. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +2 -0
  290. package/src/extensions/pi-agent-read/package.json +11 -11
  291. package/src/extensions/pi-agent-read/runtime/entry-39.js +0 -1
  292. package/src/extensions/pi-agent-read/runtime/entry-40.js +2 -0
  293. package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -0
  294. package/src/extensions/pi-agent-read/src/core/read-core.ts +6 -26
  295. package/src/extensions/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
  296. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +28 -7
  297. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +35 -30
  298. package/src/extensions/pi-agent-search/package.json +7 -7
  299. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +42 -33
  300. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
  301. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-46.js +1 -0
  302. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-47.js +1 -0
  303. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +9 -1
  304. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +1 -1
  305. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -0
  306. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +48 -0
  307. package/src/extensions/pi-agent-search/runtime/entry-44.js +0 -1
  308. package/src/extensions/pi-agent-search/runtime/entry-45.js +2 -0
  309. package/src/extensions/pi-agent-search/src/core/extension.ts +7 -5
  310. package/src/extensions/pi-agent-search/src/core/search-core.ts +10 -0
  311. package/src/extensions/pi-agent-text-editor/package.json +22 -22
  312. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  313. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-49.js +2 -0
  314. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  315. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
  316. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-51.js +2 -0
  317. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +2 -6
  318. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  319. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
  320. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-53.js +2 -0
  321. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +3 -3
  322. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +4 -4
  323. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +5 -1
  324. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  325. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
  326. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
  327. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
  328. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
  329. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +52 -4
  330. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
  331. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
  332. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
  333. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +5 -3
  334. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  335. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
  336. package/src/extensions/pi-agent-text-editor/runtime/entry-68.js +0 -1
  337. package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +2 -0
  338. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
  339. package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +71 -1
  340. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
  341. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +7 -9
  342. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +27 -2
  343. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +38 -0
  344. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
  345. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
  346. package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
  347. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +23 -0
  348. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +5 -9
  349. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +54 -14
  350. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
  351. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
  352. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
  353. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
  354. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
  355. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
  356. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
  357. package/src/pi-agent-ide.ts +11 -0
  358. package/src/plugins/pi-agent-ide-ast/package.json +11 -11
  359. package/src/plugins/pi-agent-ide-ast/runtime/entry-25.js +0 -1
  360. package/src/plugins/pi-agent-ide-ast/runtime/entry-26.js +2 -0
  361. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +3 -0
  362. package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +92 -19
  363. package/src/plugins/pi-agent-ide-ast/src/extension.ts +9 -14
  364. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +60 -0
  365. package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
  366. package/src/plugins/pi-agent-ide-changes/index.ts +1 -5
  367. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  368. package/src/plugins/pi-agent-ide-changes/runtime/entry-27.js +0 -1
  369. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +1 -7
  370. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
  371. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +1 -8
  372. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  373. package/src/plugins/pi-agent-ide-formatter/src/catalog.ts +131 -13
  374. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +12 -7
  375. package/src/plugins/pi-agent-ide-formatter/src/registry.ts +20 -8
  376. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  377. package/src/plugins/pi-agent-ide-languages/src/languages.ts +15 -0
  378. package/src/plugins/pi-agent-ide-lint/index.ts +4 -1
  379. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  380. package/src/plugins/pi-agent-ide-lint/src/catalog.ts +196 -39
  381. package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +23 -3
  382. package/src/plugins/pi-agent-ide-lint/src/diagnostics.ts +73 -33
  383. package/src/plugins/pi-agent-ide-lint/src/registry.ts +20 -8
  384. package/src/plugins/pi-agent-ide-lsp/index.ts +1 -12
  385. package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
  386. package/src/plugins/pi-agent-ide-lsp/runtime/entry-32.js +2 -0
  387. package/src/plugins/pi-agent-ide-lsp/src/catalog.ts +161 -7
  388. package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +10 -10
  389. package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +2 -4
  390. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +162 -12
  391. package/src/plugins/pi-agent-ide-lsp/src/lsp/file-watchers.ts +88 -0
  392. package/src/plugins/pi-agent-ide-lsp/src/lsp/initialization-options.ts +14 -0
  393. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -4
  394. package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +69 -34
  395. package/src/plugins/pi-agent-ide-lsp/src/lsp/transport-writer.ts +24 -0
  396. package/src/plugins/pi-agent-ide-lsp/src/lsp/types.ts +5 -0
  397. package/src/post-edit/gate.ts +44 -15
  398. package/src/toolchain/types.ts +4 -0
  399. package/dist/chunk-34ZQTTU2.js +0 -2
  400. package/dist/chunk-476MR2QB.js +0 -1
  401. package/dist/chunk-4KQOODGE.js +0 -13
  402. package/dist/chunk-4SQQKEVD.js +0 -16
  403. package/dist/chunk-52BM6J6I.js +0 -6
  404. package/dist/chunk-5BWUVAR4.js +0 -1
  405. package/dist/chunk-6DN7NO7L.js +0 -1
  406. package/dist/chunk-6SMFVLTY.js +0 -1
  407. package/dist/chunk-7NDBZ4WX.js +0 -1
  408. package/dist/chunk-AP7Z3VWC.js +0 -1
  409. package/dist/chunk-BYWAG6X3.js +0 -6
  410. package/dist/chunk-E4SECPF4.js +0 -1
  411. package/dist/chunk-EW2KVKCN.js +0 -2
  412. package/dist/chunk-F6SESI3P.js +0 -4
  413. package/dist/chunk-GTK5AREE.js +0 -2
  414. package/dist/chunk-HOBTFFQR.js +0 -1
  415. package/dist/chunk-IMVCVPMP.js +0 -3
  416. package/dist/chunk-IOCABSRL.js +0 -1
  417. package/dist/chunk-KP37XTDI.js +0 -1
  418. package/dist/chunk-KYVOMBO5.js +0 -1
  419. package/dist/chunk-LFV6G5Z3.js +0 -1
  420. package/dist/chunk-MB6VVVAF.js +0 -2
  421. package/dist/chunk-NI2NK4JU.js +0 -1
  422. package/dist/chunk-OIL6BB2S.js +0 -33
  423. package/dist/chunk-PODWLGNO.js +0 -6
  424. package/dist/chunk-QW5O42QJ.js +0 -2
  425. package/dist/chunk-SSZB66C3.js +0 -3
  426. package/dist/chunk-TG6H6EOI.js +0 -1
  427. package/dist/chunk-TNWYEXFG.js +0 -1
  428. package/dist/chunk-U4D6FT66.js +0 -1
  429. package/dist/chunk-VUNCBASK.js +0 -10
  430. package/dist/chunk-VWVLBOMU.js +0 -8
  431. package/dist/chunk-W3XYKJ5H.js +0 -1
  432. package/dist/chunk-XGUAL3CA.js +0 -1
  433. package/dist/chunk-YQTLJ5ZV.js +0 -58
  434. package/node_modules/pi-agent-filesystem/runtime/entry-20.js +0 -2
  435. package/node_modules/pi-agent-ide-ast/runtime/entry-24.js +0 -1
  436. package/node_modules/pi-agent-ide-changes/runtime/entry-26.js +0 -1
  437. package/node_modules/pi-agent-image/runtime/entry-32.js +0 -1
  438. package/node_modules/pi-agent-read/src/core/tools/read/views.ts +0 -29
  439. package/node_modules/pi-agent-resource/runtime/entry-40.js +0 -1
  440. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-48.js +0 -2
  441. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-49.js +0 -1
  442. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-51.js +0 -1
  443. package/node_modules/pi-agent-text-editor/runtime/entry-53.js +0 -1
  444. package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +0 -1
  445. package/node_modules/pi-agent-web/runtime/entry-75.js +0 -2
  446. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-21.js +0 -2
  447. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-20.js +0 -2
  448. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +0 -2
  449. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +0 -2
  450. package/src/extensions/pi-agent-read/runtime/entry-35.js +0 -1
  451. package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +0 -29
  452. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-45.js +0 -2
  453. package/src/extensions/pi-agent-search/runtime/entry-41.js +0 -1
  454. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-48.js +0 -2
  455. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-49.js +0 -1
  456. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-51.js +0 -1
  457. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-69.js +0 -2
  458. package/src/extensions/pi-agent-text-editor/runtime/entry-53.js +0 -1
  459. package/src/plugins/pi-agent-ide-ast/runtime/entry-24.js +0 -1
  460. package/src/plugins/pi-agent-ide-changes/runtime/entry-26.js +0 -1
  461. /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-21.js +0 -0
  462. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-22.js +0 -0
  463. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-23.js +0 -0
  464. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-28.js +0 -0
  465. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-29.js +0 -0
  466. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-30.js +0 -0
  467. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-31.js +0 -0
  468. /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-33.js +0 -0
  469. /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-34.js +0 -0
  470. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-35.js +0 -0
  471. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-41.js +0 -0
  472. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-45.js +0 -0
  473. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-47.js +0 -0
  474. /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-69.js +0 -0
  475. /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-argument-order}/runtime/entry-70.js +0 -0
  476. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-overwrite}/runtime/entry-71.js +0 -0
  477. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
  478. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-74.js +0 -0
  479. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-76.js +0 -0
  480. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
  481. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
  482. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
  483. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-22.js +0 -0
  484. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-23.js +0 -0
  485. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
  486. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
  487. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
  488. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-argument-order}/runtime/entry-70.js +0 -0
  489. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-overwrite}/runtime/entry-71.js +0 -0
  490. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
  491. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-28.js +0 -0
  492. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-29.js +0 -0
  493. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-30.js +0 -0
  494. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-31.js +0 -0
@@ -1,19 +1,27 @@
1
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";
5
- import { createConfiguredProcessEnvironment } from "pi-agent-ide/api/tool-config";
7
+ import {
8
+ configuredExecutableName,
9
+ createConfiguredProcessEnvironment,
10
+ } from "pi-agent-ide/api/tool-config";
6
11
  import {
7
12
  createMessageConnection,
8
13
  CancellationTokenSource,
9
14
  type MessageConnection,
10
15
  StreamMessageReader,
11
- StreamMessageWriter,
12
16
  } from "vscode-jsonrpc/node";
13
17
  import { URI } from "vscode-uri";
14
18
 
15
19
  import type { LspDiagnostic } from "./types.js";
16
20
 
21
+ import { LspFileWatchers } from "./file-watchers.js";
22
+
23
+ import { TransportWriter } from "./transport-writer.js";
24
+
17
25
  /** Latest push observation for an open document, without a completion guarantee. */
18
26
  export interface LspDiagnosticPublication {
19
27
  readonly version?: number;
@@ -34,9 +42,15 @@ export class LspClient {
34
42
  private _disposed = false;
35
43
 
36
44
  private _crashed = false;
45
+
46
+ private _stderr = "";
47
+
48
+ private _fileWatchers: LspFileWatchers | undefined;
37
49
  private readonly _handlers = new Map<string, ((parameters: unknown) => void)[]>();
38
50
  private readonly _documentVersions = new Map<string, number>();
39
51
 
52
+ private readonly _documentContents = new Map<string, string>();
53
+
40
54
  private readonly _diagnosticPublications = new Map<string, LspDiagnosticPublication>();
41
55
  private _diagnosticMode: "unknown" | "pull" | "push" = "unknown";
42
56
  private readonly _activeDiagnosticRequests = new Set<string>();
@@ -83,6 +97,10 @@ export class LspClient {
83
97
  return this._process?.pid ?? null;
84
98
  }
85
99
 
100
+ /** Executable used to start this server, independent of its configured ID. */
101
+ get commandName(): string {
102
+ return configuredExecutableName(this._command);
103
+ }
86
104
  get diagnosticMode(): "unknown" | "pull" | "push" {
87
105
  return this._diagnosticMode;
88
106
  }
@@ -142,6 +160,10 @@ export class LspClient {
142
160
  const bin = requiredValue(this._command[0]);
143
161
  const projectRoot = URI.parse(this.rootUri).fsPath;
144
162
 
163
+ const workspaceFolders = [
164
+ { uri: this.rootUri, name: path.basename(projectRoot) || projectRoot },
165
+ ];
166
+
145
167
  const childProcess = spawnProcess(bin, this._args, {
146
168
  stdio: ["pipe", "pipe", "pipe"],
147
169
  cwd: projectRoot,
@@ -160,6 +182,12 @@ export class LspClient {
160
182
  childProcess.stdout?.on("error", () => void 0);
161
183
  childProcess.stderr?.on("error", () => void 0);
162
184
 
185
+ this._stderr = "";
186
+ childProcess.stderr?.setEncoding("utf8");
187
+ childProcess.stderr?.on("data", (chunk: string) => {
188
+ this._stderr = (this._stderr + chunk).slice(-4096);
189
+ });
190
+
163
191
  childProcess.on("error", (error) => {
164
192
  const code = "code" in error ? (error as { code?: unknown }).code : undefined;
165
193
 
@@ -174,6 +202,7 @@ export class LspClient {
174
202
  });
175
203
 
176
204
  childProcess.on("exit", (code, _signal) => {
205
+ this._fileWatchers?.dispose();
177
206
  if (!this._disposed && code !== 0 && code !== null) {
178
207
  this._crashed = true;
179
208
  }
@@ -185,15 +214,77 @@ export class LspClient {
185
214
  });
186
215
 
187
216
  await spawnPromise;
188
- this._connection = createMessageConnection(
217
+ const connection = createMessageConnection(
189
218
  new StreamMessageReader(requiredValue(childProcess.stdout)),
190
- new StreamMessageWriter(requiredValue(childProcess.stdin)),
219
+ new TransportWriter(requiredValue(childProcess.stdin), (error) => {
220
+ if (this._connection !== connection || this._disposed) return;
221
+ this._crashed = true;
222
+ this._initialized = false;
223
+ this._fileWatchers?.dispose();
224
+ connection.dispose();
225
+ console.error(`[lsp] ${this.serverId}: transport write failed:`, error);
226
+ }),
191
227
  );
228
+ this._connection = connection;
192
229
 
193
230
  this._connection.onError((error) => {
194
231
  console.error(`[lsp] ${this.serverId}: connection error:`, error);
195
232
  });
196
233
 
234
+ this._fileWatchers = new LspFileWatchers(
235
+ projectRoot,
236
+ (change) => {
237
+ this._sendNotification("workspace/didChangeWatchedFiles", { changes: [change] });
238
+ },
239
+ (error) => console.error(`[lsp] ${this.serverId}: file watcher failed:`, error),
240
+ );
241
+ this._connection.onRequest(
242
+ "client/registerCapability",
243
+ async (parameters: {
244
+ registrations: {
245
+ id: string;
246
+ method: string;
247
+ registerOptions?: { watchers?: Parameters<LspFileWatchers["register"]>[1] };
248
+ }[];
249
+ }) => {
250
+ for (const registration of parameters.registrations) {
251
+ // Settings are fixed for this client and already served by workspace/configuration.
252
+ if (registration.method === "workspace/didChangeConfiguration") continue;
253
+ if (registration.method !== "workspace/didChangeWatchedFiles")
254
+ throw new Error(`Unsupported dynamic capability: ${registration.method}`);
255
+ await this._fileWatchers?.register(
256
+ registration.id,
257
+ registration.registerOptions?.watchers ?? [],
258
+ );
259
+ }
260
+ return null;
261
+ },
262
+ );
263
+ this._connection.onRequest(
264
+ "client/unregisterCapability",
265
+ (parameters: { unregisterations: { id: string }[] }) => {
266
+ for (const registration of parameters.unregisterations)
267
+ this._fileWatchers?.unregister(registration.id);
268
+ return null;
269
+ },
270
+ );
271
+ this._connection.onRequest("window/workDoneProgress/create", () => null);
272
+
273
+ this._connection.onRequest(
274
+ "workspace/configuration",
275
+ (parameters: { items: { section?: string }[] }) =>
276
+ parameters.items.map((item) => {
277
+ let value: unknown = this._settings ?? null;
278
+ for (const segment of item.section?.split(".").filter(Boolean) ?? []) {
279
+ value =
280
+ typeof value === "object" && value !== null
281
+ ? ((value as Record<string, unknown>)[segment] ?? null)
282
+ : null;
283
+ }
284
+ return value;
285
+ }),
286
+ );
287
+
197
288
  this._connection.listen();
198
289
 
199
290
  // Forward all incoming notifications to registered handlers
@@ -221,6 +312,8 @@ export class LspClient {
221
312
  }
222
313
  });
223
314
 
315
+ this._connection.onRequest("workspace/workspaceFolders", () => workspaceFolders);
316
+
224
317
  interface InitResult {
225
318
  capabilities: Record<string, unknown>;
226
319
  }
@@ -229,14 +322,24 @@ export class LspClient {
229
322
  this._connection.sendRequest<InitResult>("initialize", {
230
323
  processId: process.pid,
231
324
  rootUri: this.rootUri,
325
+
326
+ workspaceFolders,
232
327
  capabilities: {
233
328
  workspace: {
234
329
  applyEdit: false,
330
+
331
+ configuration: true,
332
+
333
+ workspaceFolders: true,
334
+
335
+ didChangeWatchedFiles: { dynamicRegistration: true, relativePatternSupport: true },
235
336
  symbol: { dynamicRegistration: false },
236
337
  },
237
338
  textDocument: {
238
339
  synchronization: { didOpen: true, didChange: true, didClose: true },
239
340
  publishDiagnostics: { relatedInformation: true },
341
+
342
+ diagnostic: { dynamicRegistration: false, relatedDocumentSupport: false },
240
343
  documentSymbol: { hierarchicalDocumentSymbolSupport: true },
241
344
  foldingRange: { lineFoldingOnly: true },
242
345
  },
@@ -245,20 +348,30 @@ export class LspClient {
245
348
  }),
246
349
  this._timeoutMs,
247
350
  `[lsp] ${this.serverId}: initialize timed out`,
248
- );
351
+ ).catch((error: unknown) => {
352
+ const detail = this._stderr.trim();
353
+ if (!detail) throw error;
354
+ throw new Error(`[lsp] ${this.serverId}: ${detail}`, { cause: error });
355
+ });
249
356
 
250
- void this._connection.sendNotification("initialized", {
357
+ await this._connection.sendNotification("initialized", {
251
358
  capabilities: initResult.capabilities,
252
359
  });
253
360
 
254
361
  if (this._settings !== undefined) {
255
- void this._connection.sendNotification("workspace/didChangeConfiguration", {
362
+ await this._connection.sendNotification("workspace/didChangeConfiguration", {
256
363
  settings: this._settings,
257
364
  });
258
365
  }
259
366
 
367
+ if (this._crashed)
368
+ throw new Error(`[lsp] ${this.serverId}: transport failed during initialization`);
369
+
260
370
  this._initialized = true;
261
371
  this._serverCapabilities = initResult.capabilities;
372
+
373
+ // Unadvertised methods may return null or internal errors rather than MethodNotFound.
374
+ this._diagnosticMode = initResult.capabilities.diagnosticProvider ? "pull" : "push";
262
375
  }
263
376
 
264
377
  touch(): void {
@@ -266,6 +379,7 @@ export class LspClient {
266
379
  }
267
380
 
268
381
  async restart(): Promise<void> {
382
+ this._fileWatchers?.dispose();
269
383
  this._connection?.dispose();
270
384
  this._connection = null;
271
385
  this._process = null;
@@ -273,6 +387,7 @@ export class LspClient {
273
387
  this._crashed = false;
274
388
  this._disposed = false;
275
389
  this._documentVersions.clear();
390
+ this._documentContents.clear();
276
391
  this._diagnosticPublications.clear();
277
392
  this._diagnosticMode = "unknown";
278
393
  this._activeDiagnosticRequests.clear();
@@ -315,9 +430,23 @@ export class LspClient {
315
430
  }
316
431
  }
317
432
 
433
+ /** Queue a notification; a failed write makes this client unavailable without escaping to Pi. */
318
434
  sendNotification(method: string, parameters: unknown): void {
319
435
  this._assertReady();
320
- void requiredValue(this._connection).sendNotification(method, parameters);
436
+ this._sendNotification(method, parameters);
437
+ }
438
+
439
+ private _sendNotification(method: string, parameters: unknown): void {
440
+ const connection = this._connection;
441
+ if (!connection) return;
442
+ void connection.sendNotification(method, parameters).catch((error: unknown) => {
443
+ if (this._connection !== connection || this._disposed) return;
444
+ this._crashed = true;
445
+ this._initialized = false;
446
+ this._fileWatchers?.dispose();
447
+ connection.dispose();
448
+ console.error(`[lsp] ${this.serverId}: notification ${method} failed:`, error);
449
+ });
321
450
  }
322
451
 
323
452
  /**
@@ -362,17 +491,31 @@ export class LspClient {
362
491
  textDocument: { uri, languageId, version, text },
363
492
  });
364
493
  this._documentVersions.set(uri, version);
494
+
495
+ this._documentContents.set(uri, text);
365
496
  }
366
497
 
367
- syncDocument(uri: string, text: string, languageId: string): void {
498
+ /** Sync content, optionally reporting a completed disk write to servers that request saves. */
499
+ syncDocument(uri: string, text: string, languageId: string, saved = false): void {
500
+ if (this._documentContents.get(uri) === text) return;
368
501
  const currentVersion = this._documentVersions.get(uri);
369
502
 
370
503
  if (currentVersion === undefined) {
371
504
  this.openDocument(uri, text, languageId);
372
- return;
505
+ } else {
506
+ this.changeDocument(uri, text, currentVersion + 1);
507
+ }
508
+ const synchronization = this._serverCapabilities?.textDocumentSync;
509
+ const save =
510
+ typeof synchronization === "object" && synchronization !== null
511
+ ? (synchronization as { save?: boolean | { includeText?: boolean } }).save
512
+ : undefined;
513
+ if (saved && save) {
514
+ this.sendNotification("textDocument/didSave", {
515
+ textDocument: { uri },
516
+ ...(typeof save === "object" && save.includeText && { text }),
517
+ });
373
518
  }
374
-
375
- this.changeDocument(uri, text, currentVersion + 1);
376
519
  }
377
520
 
378
521
  changeDocument(uri: string, text: string, version: number): void {
@@ -384,12 +527,16 @@ export class LspClient {
384
527
  contentChanges: [{ text }],
385
528
  });
386
529
  this._documentVersions.set(uri, nextVersion);
530
+
531
+ this._documentContents.set(uri, text);
387
532
  }
388
533
 
389
534
  closeDocument(uri: string): void {
390
535
  this.sendNotification("textDocument/didClose", { textDocument: { uri } });
391
536
  this._documentVersions.delete(uri);
392
537
 
538
+ this._documentContents.delete(uri);
539
+
393
540
  this._diagnosticPublications.delete(uri);
394
541
  }
395
542
 
@@ -402,6 +549,8 @@ export class LspClient {
402
549
 
403
550
  this._disposed = true;
404
551
 
552
+ this._fileWatchers?.dispose();
553
+
405
554
  if (this._connection && this._initialized) {
406
555
  try {
407
556
  await withTimeout(
@@ -433,6 +582,7 @@ export class LspClient {
433
582
 
434
583
  this._initialized = false;
435
584
  this._documentVersions.clear();
585
+ this._documentContents.clear();
436
586
  this._diagnosticPublications.clear();
437
587
  this._diagnosticMode = "unknown";
438
588
  this._activeDiagnosticRequests.clear();
@@ -0,0 +1,88 @@
1
+ import { watch, type FSWatcher } from "node:fs";
2
+ import { readdir, stat } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { URI } from "vscode-uri";
5
+
6
+ interface WatchPattern {
7
+ globPattern: string | { baseUri: string | { uri: string }; pattern: string };
8
+ kind?: number;
9
+ }
10
+
11
+ /** A native filesystem event translated to the LSP file change types. */
12
+ export interface WatchedFileChange {
13
+ uri: string;
14
+ type: 1 | 2 | 3;
15
+ }
16
+
17
+ /** Own the filesystem subscriptions requested by one language server. */
18
+ export class LspFileWatchers {
19
+ private readonly registrations = new Map<string, FSWatcher[]>();
20
+
21
+ private disposed = false;
22
+
23
+ constructor(
24
+ private readonly root: string,
25
+ private readonly changed: (change: WatchedFileChange) => void,
26
+ private readonly failed: (error: Error) => void,
27
+ ) {}
28
+
29
+ /** Install all patterns for one workspace/didChangeWatchedFiles registration. */
30
+ async register(id: string, patterns: readonly WatchPattern[]): Promise<void> {
31
+ const watchers: FSWatcher[] = [];
32
+ try {
33
+ for (const pattern of patterns) {
34
+ const glob = pattern.globPattern;
35
+ const root =
36
+ typeof glob === "string"
37
+ ? this.root
38
+ : URI.parse(typeof glob.baseUri === "string" ? glob.baseUri : glob.baseUri.uri).fsPath;
39
+ const expression = typeof glob === "string" ? glob : glob.pattern;
40
+ const matches = (file: string) =>
41
+ path.matchesGlob(path.isAbsolute(expression) ? path.join(root, file) : file, expression);
42
+ const existing = new Set((await readdir(root, { recursive: true })).filter(matches));
43
+
44
+ if (this.disposed) throw new Error("Language server file watchers are disposed");
45
+ const watcher = watch(root, { recursive: true }, (_event, name) => {
46
+ if (!name || !matches(name)) return;
47
+ void stat(path.join(root, name)).then(
48
+ () => {
49
+ if (!this.registrations.get(id)?.includes(watcher)) return;
50
+ const type = existing.has(name) ? 2 : 1;
51
+ existing.add(name);
52
+ if ((pattern.kind ?? 7) & (type === 1 ? 1 : 2))
53
+ this.changed({ uri: URI.file(path.join(root, name)).toString(), type });
54
+ },
55
+ (error: NodeJS.ErrnoException) => {
56
+ if (!this.registrations.get(id)?.includes(watcher)) return;
57
+ if (error.code !== "ENOENT") {
58
+ this.failed(error);
59
+ return;
60
+ }
61
+ if (existing.delete(name) && (pattern.kind ?? 7) & 4)
62
+ this.changed({ uri: URI.file(path.join(root, name)).toString(), type: 3 });
63
+ },
64
+ );
65
+ });
66
+ watcher.on("error", this.failed);
67
+ watchers.push(watcher);
68
+ }
69
+ } catch (error) {
70
+ for (const watcher of watchers) watcher.close();
71
+ throw error;
72
+ }
73
+ this.unregister(id);
74
+ this.registrations.set(id, watchers);
75
+ }
76
+
77
+ /** Stop a server registration without affecting its other subscriptions. */
78
+ unregister(id: string): void {
79
+ for (const watcher of this.registrations.get(id) ?? []) watcher.close();
80
+ this.registrations.delete(id);
81
+ }
82
+
83
+ /** Close all subscriptions when the server exits or the session ends. */
84
+ dispose(): void {
85
+ this.disposed = true;
86
+ for (const id of this.registrations.keys()) this.unregister(id);
87
+ }
88
+ }
@@ -0,0 +1,14 @@
1
+ /** Expand the project path in JSON initialization options, including plugin locations. */
2
+ export function resolveInitializationOptions(
3
+ value: Record<string, unknown>,
4
+ projectRoot: string,
5
+ ): Record<string, unknown> {
6
+ const expand = (item: unknown): unknown => {
7
+ if (typeof item === "string") return item.replaceAll("{project}", () => projectRoot);
8
+ if (Array.isArray(item)) return item.map(expand);
9
+ if (item !== null && typeof item === "object")
10
+ return Object.fromEntries(Object.entries(item).map(([key, child]) => [key, expand(child)]));
11
+ return item;
12
+ };
13
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, expand(item)]));
14
+ }
@@ -4,6 +4,8 @@ import path from "node:path";
4
4
  import { URI } from "vscode-uri";
5
5
 
6
6
  import { LspClient } from "./client.js";
7
+
8
+ import { resolveInitializationOptions } from "./initialization-options.js";
7
9
  import { toDiagnostic } from "./diagnostics.js";
8
10
  import { type LspDiagnostic, type ResolvedServer } from "./types.js";
9
11
 
@@ -159,7 +161,10 @@ export class LspManager {
159
161
  command: match.config.command,
160
162
  ...(match.config.env && { env: match.config.env }),
161
163
  ...(match.config.initializationOptions && {
162
- initOptions: match.config.initializationOptions,
164
+ initOptions: resolveInitializationOptions(
165
+ match.config.initializationOptions,
166
+ URI.parse(rootUri).fsPath,
167
+ ),
163
168
  }),
164
169
  ...(match.config.settings && { settings: match.config.settings }),
165
170
  ...(match.config.timeoutMs && { timeoutMs: match.config.timeoutMs }),
@@ -299,16 +304,15 @@ export class LspManager {
299
304
  cwd: string,
300
305
  capability: "diagnostics" | "symbols" = "diagnostics",
301
306
  ): Promise<{ client: LspClient; uri: string; languageId: string } | null> {
302
- const extension = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
303
307
  const absolutePath = path.resolve(cwd, filePath);
304
- const client = await this.getOrStart(extension, cwd, capability);
308
+ const client = await this.getOrStart(absolutePath, cwd, capability);
305
309
 
306
310
  if (!client) {
307
311
  return null;
308
312
  }
309
313
 
310
314
  const uri = client.toUri(absolutePath);
311
- const resolved = this._registry.resolve(extension);
315
+ const resolved = this._registry.resolve(absolutePath);
312
316
  const languageId = resolved[0]?.languageId ?? "plaintext";
313
317
 
314
318
  // Read file content for didOpen
@@ -1,4 +1,6 @@
1
- import { requiredValue } from "pi-agent-invariant";
1
+ import path from "node:path";
2
+
3
+ import { existsSync } from "node:fs";
2
4
 
3
5
  import { hasConfiguredExecutable, loadLayeredToolConfig } from "pi-agent-ide/api/tool-config";
4
6
 
@@ -16,15 +18,14 @@ LSP server configuration in project, global, and built-in priority order.
16
18
  export class LspServerRegistry {
17
19
  private readonly _servers: Record<string, ServerConfig>;
18
20
  private readonly _entries: readonly EffectiveToolConfigEntry<ServerConfig>[];
19
- private readonly _entriesById: ReadonlyMap<string, EffectiveToolConfigEntry<ServerConfig>>;
20
21
  private readonly _lookup: LanguageLookup;
21
22
 
22
23
  private constructor(
23
24
  entries: readonly EffectiveToolConfigEntry<ServerConfig>[],
24
25
  availableBuiltIns: ReadonlySet<string>,
26
+ private readonly _projectRoot: string,
25
27
  ) {
26
28
  this._entries = entries;
27
- this._entriesById = new Map(entries.map((entry) => [entry.id, entry]));
28
29
  const activeEntries = entries.filter(
29
30
  (entry) => entry.layer !== "built-in" || availableBuiltIns.has(entry.id),
30
31
  );
@@ -57,13 +58,14 @@ export class LspServerRegistry {
57
58
  return new LspServerRegistry(
58
59
  effective.entries,
59
60
  new Set(available.filter((entry) => entry.available).map((entry) => entry.id)),
61
+ path.resolve(packageDir),
60
62
  );
61
63
  }
62
64
 
63
65
  /**
64
66
  Creates a project-layer registry from an already-parsed config.
65
67
  */
66
- static fromConfig(config: LspServersConfig): LspServerRegistry {
68
+ static fromConfig(config: LspServersConfig, projectRoot = process.cwd()): LspServerRegistry {
67
69
  return new LspServerRegistry(
68
70
  Object.entries(config.servers).map(([id, server]) => ({
69
71
  id,
@@ -72,38 +74,56 @@ export class LspServerRegistry {
72
74
  sourcePath: "<memory>",
73
75
  })),
74
76
  new Set(),
77
+ path.resolve(projectRoot),
75
78
  );
76
79
  }
77
80
 
78
- /**
79
- Resolves a file extension to matching LSP servers in layer priority order.
80
- */
81
- resolve(extension: string): ResolvedServer[] {
82
- const normalized = extension.startsWith(".")
83
- ? extension.toLowerCase()
84
- : `.${extension.toLowerCase()}`;
85
- const serverIds = this._lookup.extToServerIds.get(normalized);
86
-
87
- if (!serverIds || serverIds.length === 0) {
88
- return [];
81
+ /** Resolve a file path or extension to servers in layer priority order. */
82
+ resolve(file: string): ResolvedServer[] {
83
+ const basename = path.basename(file);
84
+ const extension = path.extname(file) || (file.startsWith(".") ? file : `.${file}`);
85
+ const normalizeName = (name: string) =>
86
+ process.platform === "win32" ? name.toLowerCase() : name;
87
+ const matches: ResolvedServer[] = [];
88
+ for (const entry of this._entries) {
89
+ if (!this._servers[entry.id]) continue;
90
+
91
+ if (entry.config.requireRootMarker && !this.hasRootMarker(file, entry.config.rootMarkers))
92
+ continue;
93
+ for (const [languageId, language] of Object.entries(entry.config.languages)) {
94
+ if (
95
+ language.extensions.some(
96
+ (candidate) => candidate.toLowerCase() === extension.toLowerCase(),
97
+ ) ||
98
+ language.fileNames?.some((name) => normalizeName(name) === normalizeName(basename))
99
+ ) {
100
+ matches.push({
101
+ serverId: entry.id,
102
+ config: entry.config,
103
+ languageId,
104
+ layer: entry.layer,
105
+ sourcePath: entry.sourcePath,
106
+ });
107
+ break;
108
+ }
109
+ }
89
110
  }
111
+ return matches;
112
+ }
90
113
 
91
- const languageId = this._lookup.extToLanguageId.get(normalized);
92
-
93
- if (!languageId) {
94
- return [];
114
+ private hasRootMarker(file: string, markers: readonly string[]): boolean {
115
+ let directory = path.dirname(path.resolve(this._projectRoot, file));
116
+ if (file.startsWith(".") && !file.includes(path.sep)) directory = this._projectRoot;
117
+ for (;;) {
118
+ const relative = path.relative(this._projectRoot, directory);
119
+ // This checks containment; it does not construct a parent-relative path.
120
+ // eslint-disable-next-line repo/no-parent-paths
121
+ if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative))
122
+ return false;
123
+ if (markers.some((marker) => existsSync(path.join(directory, marker)))) return true;
124
+ if (directory === this._projectRoot) return false;
125
+ directory = path.dirname(directory);
95
126
  }
96
-
97
- return serverIds.map((serverId) => {
98
- const entry = requiredValue(this._entriesById.get(serverId));
99
- return {
100
- serverId,
101
- config: entry.config,
102
- languageId,
103
- layer: entry.layer,
104
- sourcePath: entry.sourcePath,
105
- };
106
- });
107
127
  }
108
128
 
109
129
  /**
@@ -131,10 +151,7 @@ export class LspServerRegistry {
131
151
  Resolves a file extension to the canonical LSP languageId.
132
152
  */
133
153
  languageId(extension: string): string {
134
- const normalized = extension.startsWith(".")
135
- ? extension.toLowerCase()
136
- : `.${extension.toLowerCase()}`;
137
- return this._lookup.extToLanguageId.get(normalized) ?? extension.slice(1);
154
+ return this.resolve(extension)[0]?.languageId ?? extension.slice(1);
138
155
  }
139
156
  }
140
157
 
@@ -182,6 +199,13 @@ export function parseLspConfig(value: unknown): LspServersConfig {
182
199
  throw new Error(`LSP server ${id}.rootMarkers must be a string array`);
183
200
  }
184
201
 
202
+ if (server.requireRootMarker !== undefined && typeof server.requireRootMarker !== "boolean") {
203
+ throw new TypeError(`LSP server ${id}.requireRootMarker must be a boolean`);
204
+ }
205
+ if (server.requireRootMarker && (server.rootMarkers as string[]).length === 0) {
206
+ throw new Error(`LSP server ${id}.requireRootMarker requires rootMarkers`);
207
+ }
208
+
185
209
  if (
186
210
  typeof server.languages !== "object" ||
187
211
  server.languages === null ||
@@ -205,6 +229,17 @@ export function parseLspConfig(value: unknown): LspServersConfig {
205
229
  ) {
206
230
  throw new Error(`LSP server ${id} language ${language} requires extensions`);
207
231
  }
232
+
233
+ const fileNames = (languageValue as Record<string, unknown>).fileNames;
234
+ if (
235
+ fileNames !== undefined &&
236
+ (!Array.isArray(fileNames) ||
237
+ fileNames.some(
238
+ (name) => typeof name !== "string" || name.length === 0 || /[/\\]/u.test(name),
239
+ ))
240
+ ) {
241
+ throw new Error(`LSP server ${id} language ${language}.fileNames must contain basenames`);
242
+ }
208
243
  }
209
244
 
210
245
  if (!Array.isArray(server.capabilities)) {
@@ -0,0 +1,24 @@
1
+ import type { Writable } from "node:stream";
2
+ import { StreamMessageWriter, type Message } from "vscode-jsonrpc/node";
3
+
4
+ /**
5
+ * Ends the connection on write failure instead of rejecting into JSON-RPC 9's
6
+ * async Promise executor. The owner must dispose the connection so pending
7
+ * requests reject; a failed transport must never look like a successful request.
8
+ */
9
+ export class TransportWriter extends StreamMessageWriter {
10
+ constructor(
11
+ stream: Writable,
12
+ private readonly fail: (error: unknown) => void,
13
+ ) {
14
+ super(stream);
15
+ }
16
+
17
+ override async write(message: Message): Promise<void> {
18
+ try {
19
+ await super.write(message);
20
+ } catch (error) {
21
+ this.fail(error);
22
+ }
23
+ }
24
+ }