pi-agent-ide 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (841) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +38 -10
  3. package/dist/chunk-266RH77Z.js +1 -0
  4. package/dist/chunk-2SKAED2I.js +2 -0
  5. package/dist/chunk-2ZMYT6ZC.js +1 -0
  6. package/dist/chunk-34ZQTTU2.js +2 -0
  7. package/dist/chunk-3H2EU7VQ.js +0 -0
  8. package/dist/chunk-3YK4XMWB.js +0 -0
  9. package/dist/chunk-476MR2QB.js +1 -0
  10. package/dist/chunk-4KQOODGE.js +13 -0
  11. package/dist/chunk-4SQQKEVD.js +16 -0
  12. package/dist/chunk-52BM6J6I.js +6 -0
  13. package/dist/chunk-5A25RATC.js +3 -0
  14. package/dist/chunk-5BWUVAR4.js +1 -0
  15. package/dist/chunk-6DN7NO7L.js +1 -0
  16. package/dist/chunk-6SMFVLTY.js +1 -0
  17. package/dist/chunk-7NDBZ4WX.js +1 -0
  18. package/dist/chunk-AP7Z3VWC.js +1 -0
  19. package/dist/chunk-BYWAG6X3.js +6 -0
  20. package/dist/chunk-DEP55R35.js +1 -0
  21. package/dist/chunk-E2RESHYR.js +1 -0
  22. package/dist/chunk-E4SECPF4.js +1 -0
  23. package/dist/chunk-EEH4WYI7.js +1 -0
  24. package/dist/chunk-EI7MMDWY.js +1 -0
  25. package/dist/chunk-ERVMDQGX.js +1 -0
  26. package/dist/chunk-EW2KVKCN.js +2 -0
  27. package/dist/chunk-F6SESI3P.js +4 -0
  28. package/dist/chunk-GTK5AREE.js +2 -0
  29. package/dist/chunk-HOBTFFQR.js +1 -0
  30. package/dist/chunk-IMVCVPMP.js +3 -0
  31. package/dist/chunk-IOCABSRL.js +1 -0
  32. package/dist/chunk-JASLOB2X.js +1 -0
  33. package/dist/chunk-JMVDFOTQ.js +1 -0
  34. package/dist/chunk-K4ZMRDEI.js +0 -0
  35. package/dist/chunk-KINKBPPX.js +1 -0
  36. package/dist/chunk-KNMWCDDK.js +7 -0
  37. package/dist/chunk-KP37XTDI.js +1 -0
  38. package/dist/chunk-KYVOMBO5.js +1 -0
  39. package/dist/chunk-KZBAJFCV.js +1 -0
  40. package/dist/chunk-LFV6G5Z3.js +1 -0
  41. package/dist/chunk-MB6VVVAF.js +2 -0
  42. package/dist/chunk-MBUXFKIW.js +3 -0
  43. package/dist/chunk-MTTKFJV6.js +1 -0
  44. package/dist/chunk-NI2NK4JU.js +1 -0
  45. package/dist/chunk-NNCZYO4Q.js +0 -0
  46. package/dist/chunk-OBWZ5RYN.js +1 -0
  47. package/dist/chunk-OIL6BB2S.js +33 -0
  48. package/dist/chunk-ORAPGW7W.js +1 -0
  49. package/dist/chunk-OVUYPHDE.js +1 -0
  50. package/dist/chunk-PETQCA7G.js +1 -0
  51. package/dist/chunk-PODWLGNO.js +6 -0
  52. package/dist/chunk-QNZVPFSP.js +3 -0
  53. package/dist/chunk-QW5O42QJ.js +2 -0
  54. package/dist/chunk-SJYDLHEF.js +108 -0
  55. package/dist/chunk-SSZB66C3.js +3 -0
  56. package/dist/chunk-STUZZM5B.js +1 -0
  57. package/dist/chunk-T2RPMEM2.js +1 -0
  58. package/dist/chunk-TG6H6EOI.js +1 -0
  59. package/dist/chunk-TNWYEXFG.js +1 -0
  60. package/dist/chunk-U4D6FT66.js +1 -0
  61. package/dist/chunk-VCCMVQXU.js +1 -0
  62. package/dist/chunk-VFBLX4TG.js +1 -0
  63. package/dist/chunk-VSP2QQPQ.js +2 -0
  64. package/dist/chunk-VUNCBASK.js +10 -0
  65. package/dist/chunk-VWVLBOMU.js +8 -0
  66. package/dist/chunk-W3XYKJ5H.js +1 -0
  67. package/dist/chunk-XGUAL3CA.js +1 -0
  68. package/dist/chunk-XNXQYPVT.js +10 -0
  69. package/dist/chunk-YHUTTZC6.js +2 -0
  70. package/dist/chunk-YPHXLAQF.js +1 -0
  71. package/dist/chunk-YQTLJ5ZV.js +58 -0
  72. package/dist/chunk-ZC65Z3CK.js +1 -0
  73. package/dist/entry-0.js +1 -0
  74. package/dist/entry-1.js +1 -0
  75. package/dist/entry-10.js +1 -0
  76. package/dist/entry-11.js +1 -0
  77. package/dist/entry-12.js +1 -0
  78. package/dist/entry-13.js +1 -0
  79. package/dist/entry-14.js +1 -0
  80. package/dist/entry-16.js +1 -0
  81. package/dist/entry-17.js +1 -0
  82. package/dist/entry-18.js +1 -0
  83. package/dist/entry-19.js +1 -0
  84. package/dist/entry-2.js +1 -0
  85. package/dist/entry-20.js +1 -0
  86. package/dist/entry-21.js +1 -0
  87. package/dist/entry-22.js +1 -0
  88. package/dist/entry-23.js +1 -0
  89. package/dist/entry-24.js +1 -0
  90. package/dist/entry-25.js +1 -0
  91. package/dist/entry-26.js +1 -0
  92. package/dist/entry-27.js +1 -0
  93. package/dist/entry-28.js +1 -0
  94. package/dist/entry-29.js +1 -0
  95. package/dist/entry-3.js +1 -0
  96. package/dist/entry-30.js +1 -0
  97. package/dist/entry-31.js +1 -0
  98. package/dist/entry-32.js +1 -0
  99. package/dist/entry-33.js +1 -0
  100. package/dist/entry-34.js +1 -0
  101. package/dist/entry-35.js +1 -0
  102. package/dist/entry-36.js +1 -0
  103. package/dist/entry-37.js +1 -0
  104. package/dist/entry-38.js +1 -0
  105. package/dist/entry-39.js +1 -0
  106. package/dist/entry-4.js +1 -0
  107. package/dist/entry-40.js +1 -0
  108. package/dist/entry-41.js +1 -0
  109. package/dist/entry-42.js +1 -0
  110. package/dist/entry-43.js +1 -0
  111. package/dist/entry-44.js +1 -0
  112. package/dist/entry-45.js +1 -0
  113. package/dist/entry-46.js +1 -0
  114. package/dist/entry-47.js +1 -0
  115. package/dist/entry-48.js +1 -0
  116. package/dist/entry-49.js +1 -0
  117. package/dist/entry-5.js +1 -0
  118. package/dist/entry-50.js +1 -0
  119. package/dist/entry-51.js +1 -0
  120. package/dist/entry-52.js +1 -0
  121. package/dist/entry-53.js +0 -0
  122. package/dist/entry-54.js +1 -0
  123. package/dist/entry-55.js +0 -0
  124. package/dist/entry-56.js +1 -0
  125. package/dist/entry-57.js +1 -0
  126. package/dist/entry-58.js +1 -0
  127. package/dist/entry-59.js +1 -0
  128. package/dist/entry-6.js +1 -0
  129. package/dist/entry-60.js +1 -0
  130. package/dist/entry-61.js +1 -0
  131. package/dist/entry-62.js +0 -0
  132. package/dist/entry-63.js +1 -0
  133. package/dist/entry-64.js +0 -0
  134. package/dist/entry-65.js +1 -0
  135. package/dist/entry-66.js +1 -0
  136. package/dist/entry-67.js +1 -0
  137. package/dist/entry-68.js +1 -0
  138. package/dist/entry-69.js +1 -0
  139. package/dist/entry-7.js +1 -0
  140. package/dist/entry-70.js +1 -0
  141. package/dist/entry-71.js +1 -0
  142. package/dist/entry-72.js +1 -0
  143. package/dist/entry-73.js +1 -0
  144. package/dist/entry-74.js +1 -0
  145. package/dist/entry-75.js +1 -0
  146. package/dist/entry-76.js +1 -0
  147. package/dist/entry-77.js +1 -0
  148. package/dist/entry-78.js +1 -0
  149. package/dist/entry-79.js +1 -0
  150. package/dist/entry-8.js +1 -0
  151. package/dist/entry-9.js +1 -0
  152. package/dist/pi-agent-ide.js +13 -0
  153. package/docs/architecture.md +30 -14
  154. package/docs/configuration.md +180 -53
  155. package/docs/development.md +116 -4
  156. package/docs/extensions.md +196 -154
  157. package/docs/generated/tool-catalog/c.md +9 -0
  158. package/docs/generated/tool-catalog/cmake.md +9 -0
  159. package/docs/generated/tool-catalog/cpp.md +9 -0
  160. package/docs/generated/tool-catalog/csharp.md +9 -0
  161. package/docs/generated/tool-catalog/css.md +11 -0
  162. package/docs/generated/tool-catalog/dockerfile.md +9 -0
  163. package/docs/generated/tool-catalog/go.md +10 -0
  164. package/docs/generated/tool-catalog/html.md +10 -0
  165. package/docs/generated/tool-catalog/index.md +30 -0
  166. package/docs/generated/tool-catalog/java.md +9 -0
  167. package/docs/generated/tool-catalog/javascript.md +12 -0
  168. package/docs/generated/tool-catalog/json.md +11 -0
  169. package/docs/generated/tool-catalog/kotlin.md +9 -0
  170. package/docs/generated/tool-catalog/lua.md +9 -0
  171. package/docs/generated/tool-catalog/markdown.md +10 -0
  172. package/docs/generated/tool-catalog/php.md +9 -0
  173. package/docs/generated/tool-catalog/python.md +10 -0
  174. package/docs/generated/tool-catalog/ruby.md +9 -0
  175. package/docs/generated/tool-catalog/rust.md +9 -0
  176. package/docs/generated/tool-catalog/shell.md +9 -0
  177. package/docs/generated/tool-catalog/sql.md +9 -0
  178. package/docs/generated/tool-catalog/swift.md +9 -0
  179. package/docs/generated/tool-catalog/terraform.md +9 -0
  180. package/docs/generated/tool-catalog/toml.md +10 -0
  181. package/docs/generated/tool-catalog/typescript.md +12 -0
  182. package/docs/generated/tool-catalog/xml.md +9 -0
  183. package/docs/generated/tool-catalog/yaml.md +10 -0
  184. package/docs/tools.md +88 -6
  185. package/node_modules/pi-agent-doctor/package.json +29 -0
  186. package/node_modules/pi-agent-doctor/runtime/entry-16.js +1 -0
  187. package/node_modules/pi-agent-doctor/runtime/entry-17.js +1 -0
  188. package/node_modules/pi-agent-doctor/runtime/entry-18.js +1 -0
  189. package/node_modules/pi-agent-doctor/runtime/entry-19.js +1 -0
  190. package/node_modules/pi-agent-doctor/src/catalog.ts +55 -0
  191. package/node_modules/pi-agent-doctor/src/connect-plugin.ts +53 -0
  192. package/node_modules/pi-agent-doctor/src/executable.ts +80 -0
  193. package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +147 -0
  194. package/node_modules/pi-agent-filesystem/index.ts +43 -44
  195. package/node_modules/pi-agent-filesystem/package.json +11 -11
  196. package/node_modules/pi-agent-filesystem/runtime/entry-20.js +2 -0
  197. package/node_modules/pi-agent-filesystem/src/resolver.ts +112 -135
  198. package/node_modules/pi-agent-filesystem-image/index.ts +5 -6
  199. package/node_modules/pi-agent-filesystem-image/package.json +8 -8
  200. package/node_modules/pi-agent-filesystem-image/runtime/entry-21.js +2 -0
  201. package/node_modules/pi-agent-filesystem-pdf/index.ts +5 -6
  202. package/node_modules/pi-agent-filesystem-pdf/package.json +6 -6
  203. package/node_modules/pi-agent-filesystem-pdf/runtime/entry-22.js +2 -0
  204. package/node_modules/pi-agent-filesystem-text/index.ts +11 -12
  205. package/node_modules/pi-agent-filesystem-text/package.json +8 -8
  206. package/node_modules/pi-agent-filesystem-text/runtime/entry-23.js +2 -0
  207. package/node_modules/pi-agent-ide-ast/index.ts +1 -1
  208. package/node_modules/pi-agent-ide-ast/package.json +15 -13
  209. package/node_modules/pi-agent-ide-ast/runtime/entry-24.js +1 -0
  210. package/node_modules/pi-agent-ide-ast/runtime/entry-25.js +2 -0
  211. package/node_modules/pi-agent-ide-ast/src/api/scope.ts +1 -1
  212. package/node_modules/pi-agent-ide-ast/src/ast/collect-files.ts +11 -16
  213. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +292 -322
  214. package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +591 -656
  215. package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +15 -19
  216. package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +130 -0
  217. package/node_modules/pi-agent-ide-ast/src/extension.ts +75 -64
  218. package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +51 -54
  219. package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +168 -185
  220. package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +36 -36
  221. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +118 -129
  222. package/node_modules/pi-agent-ide-changes/index.ts +57 -51
  223. package/node_modules/pi-agent-ide-changes/package.json +14 -12
  224. package/node_modules/pi-agent-ide-changes/runtime/entry-26.js +1 -0
  225. package/node_modules/pi-agent-ide-changes/runtime/entry-27.js +2 -0
  226. package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +74 -78
  227. package/node_modules/pi-agent-ide-changes/src/changes/change-groups.ts +230 -245
  228. package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +189 -192
  229. package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +75 -79
  230. package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +259 -276
  231. package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +164 -190
  232. package/node_modules/pi-agent-ide-changes/src/doctor-plugin.ts +59 -0
  233. package/node_modules/pi-agent-ide-changes/src/index-mutation-queue.ts +10 -9
  234. package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +49 -62
  235. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +98 -93
  236. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +131 -126
  237. package/node_modules/pi-agent-ide-formatter/index.ts +22 -23
  238. package/node_modules/pi-agent-ide-formatter/package.json +6 -3
  239. package/node_modules/pi-agent-ide-formatter/runtime/entry-28.js +2 -0
  240. package/node_modules/pi-agent-ide-formatter/src/catalog.ts +281 -0
  241. package/node_modules/pi-agent-ide-formatter/src/doctor-plugin.ts +156 -0
  242. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +38 -40
  243. package/node_modules/pi-agent-ide-formatter/src/registry.ts +94 -27
  244. package/node_modules/pi-agent-ide-languages/index.ts +24 -0
  245. package/{src/extensions/pi-agent-search/plugins/pi-agent-search-semantic → node_modules/pi-agent-ide-languages}/package.json +6 -7
  246. package/node_modules/pi-agent-ide-languages/runtime/entry-29.js +2 -0
  247. package/node_modules/pi-agent-ide-languages/src/languages.ts +84 -0
  248. package/node_modules/pi-agent-ide-lint/index.ts +66 -225
  249. package/node_modules/pi-agent-ide-lint/package.json +10 -8
  250. package/node_modules/pi-agent-ide-lint/runtime/entry-30.js +2 -0
  251. package/node_modules/pi-agent-ide-lint/src/catalog.ts +295 -0
  252. package/node_modules/pi-agent-ide-lint/src/command-linter.ts +98 -144
  253. package/node_modules/pi-agent-ide-lint/src/diagnostics.ts +182 -0
  254. package/node_modules/pi-agent-ide-lint/src/doctor-plugin.ts +155 -0
  255. package/node_modules/pi-agent-ide-lint/src/registry.ts +94 -27
  256. package/node_modules/pi-agent-ide-lsp/index.ts +111 -231
  257. package/node_modules/pi-agent-ide-lsp/package.json +13 -11
  258. package/node_modules/pi-agent-ide-lsp/runtime/entry-31.js +2 -0
  259. package/node_modules/pi-agent-ide-lsp/src/catalog.ts +248 -0
  260. package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +109 -116
  261. package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +113 -0
  262. package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +163 -0
  263. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +439 -396
  264. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +421 -458
  265. package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +76 -0
  266. package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +143 -159
  267. package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +25 -20
  268. package/node_modules/pi-agent-ide-lsp/src/lsp/language-map.ts +31 -33
  269. package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +49 -57
  270. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +350 -415
  271. package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +58 -63
  272. package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +196 -77
  273. package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +36 -36
  274. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +118 -127
  275. package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +108 -107
  276. package/node_modules/pi-agent-ide-lsp/src/lsp/types.ts +76 -57
  277. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +36 -32
  278. package/node_modules/pi-agent-image/package.json +3 -3
  279. package/node_modules/pi-agent-image/runtime/entry-32.js +1 -0
  280. package/node_modules/pi-agent-image/src/image-converter.ts +210 -249
  281. package/node_modules/pi-agent-image/src/index.ts +4 -4
  282. package/node_modules/pi-agent-invariant/package.json +12 -0
  283. package/node_modules/pi-agent-invariant/runtime/entry-33.js +1 -0
  284. package/node_modules/pi-agent-invariant/src/index.ts +8 -0
  285. package/node_modules/pi-agent-pdf/package.json +3 -3
  286. package/node_modules/pi-agent-pdf/runtime/entry-34.js +1 -0
  287. package/node_modules/pi-agent-pdf/src/index.ts +1 -5
  288. package/node_modules/pi-agent-pdf/src/pdf-converter.ts +133 -155
  289. package/node_modules/pi-agent-read/index.ts +1 -1
  290. package/node_modules/pi-agent-read/package.json +15 -13
  291. package/node_modules/pi-agent-read/runtime/entry-35.js +1 -0
  292. package/node_modules/pi-agent-read/runtime/entry-36.js +1 -0
  293. package/node_modules/pi-agent-read/runtime/entry-37.js +1 -0
  294. package/node_modules/pi-agent-read/runtime/entry-38.js +1 -0
  295. package/node_modules/pi-agent-read/runtime/entry-39.js +2 -0
  296. package/node_modules/pi-agent-read/src/api/connect-plugin.ts +38 -51
  297. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +27 -33
  298. package/node_modules/pi-agent-read/src/api/rendering.ts +3 -4
  299. package/node_modules/pi-agent-read/src/api/tools/read.ts +237 -134
  300. package/node_modules/pi-agent-read/src/core/extension.ts +51 -33
  301. package/node_modules/pi-agent-read/src/core/read-core.ts +353 -330
  302. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +169 -156
  303. package/node_modules/pi-agent-read/src/core/tools/read/persisted-result.ts +72 -0
  304. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +381 -313
  305. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +169 -154
  306. package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +165 -187
  307. package/node_modules/pi-agent-read/src/core/tools/read/views.ts +29 -0
  308. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +1117 -680
  309. package/node_modules/pi-agent-resource/package.json +5 -2
  310. package/node_modules/pi-agent-resource/runtime/entry-40.js +1 -0
  311. package/node_modules/pi-agent-resource/src/content-conversion/connect-plugin.ts +50 -62
  312. package/node_modules/pi-agent-resource/src/content-conversion/content-converter.ts +28 -34
  313. package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +16 -20
  314. package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +53 -58
  315. package/node_modules/pi-agent-resource/src/content-conversion/content-runner.ts +116 -135
  316. package/node_modules/pi-agent-resource/src/content-conversion/plugin-protocol.ts +38 -39
  317. package/node_modules/pi-agent-resource/src/content-conversion/validation.ts +118 -108
  318. package/node_modules/pi-agent-resource/src/content.ts +5 -9
  319. package/node_modules/pi-agent-resource/src/index.ts +51 -40
  320. package/node_modules/pi-agent-resource/src/resolver.ts +11 -13
  321. package/node_modules/pi-agent-resource/src/resource.ts +17 -24
  322. package/node_modules/pi-agent-resource/src/validation.ts +106 -92
  323. package/node_modules/pi-agent-search/package.json +11 -10
  324. package/node_modules/pi-agent-search/runtime/entry-41.js +1 -0
  325. package/node_modules/pi-agent-search/runtime/entry-42.js +1 -0
  326. package/node_modules/pi-agent-search/runtime/entry-43.js +1 -0
  327. package/node_modules/pi-agent-search/runtime/entry-44.js +2 -0
  328. package/node_modules/pi-agent-search/src/api/connect-plugin.ts +37 -47
  329. package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +26 -30
  330. package/node_modules/pi-agent-search/src/api/search.ts +65 -67
  331. package/node_modules/pi-agent-search/src/core/extension.ts +184 -92
  332. package/node_modules/pi-agent-search/src/core/search-config.ts +98 -0
  333. package/node_modules/pi-agent-search/src/core/search-core.ts +332 -357
  334. package/node_modules/pi-agent-search/src/core/search-timeout.ts +54 -0
  335. package/node_modules/pi-agent-search-text/index.ts +90 -38
  336. package/node_modules/pi-agent-search-text/package.json +13 -12
  337. package/node_modules/pi-agent-search-text/runtime/entry-45.js +2 -0
  338. package/node_modules/pi-agent-search-text/runtime/entry-46.js +1 -0
  339. package/node_modules/pi-agent-search-text/src/doctor-plugin.ts +48 -0
  340. package/node_modules/pi-agent-search-text/src/file-search.ts +90 -86
  341. package/node_modules/pi-agent-search-text/src/persisted-result.ts +56 -0
  342. package/node_modules/pi-agent-search-text/src/resolvers.ts +158 -161
  343. package/node_modules/pi-agent-search-text/src/ripgrep.ts +16 -0
  344. package/node_modules/pi-agent-search-text/src/search-backend.ts +215 -249
  345. package/node_modules/pi-agent-search-text/src/search-query.ts +262 -102
  346. package/node_modules/pi-agent-search-text/src/search-recipe.ts +68 -0
  347. package/node_modules/pi-agent-search-text/src/search-renderer.ts +275 -345
  348. package/node_modules/pi-agent-search-text/src/search-result.ts +152 -157
  349. package/node_modules/pi-agent-search-text/src/search-session.ts +438 -278
  350. package/node_modules/pi-agent-text/package.json +6 -3
  351. package/node_modules/pi-agent-text/runtime/entry-47.js +1 -0
  352. package/node_modules/pi-agent-text/src/index.ts +53 -22
  353. package/node_modules/pi-agent-text/src/presented-text.ts +15 -17
  354. package/node_modules/pi-agent-text/src/source-line.ts +33 -36
  355. package/node_modules/pi-agent-text/src/stored-text.ts +14 -0
  356. package/node_modules/pi-agent-text/src/text-anchor.ts +264 -117
  357. package/node_modules/pi-agent-text/src/text-converter.ts +71 -84
  358. package/node_modules/pi-agent-text/src/text-document.ts +120 -110
  359. package/node_modules/pi-agent-text/src/text-target.ts +105 -0
  360. package/node_modules/pi-agent-text-anchor-constant/index.ts +18 -20
  361. package/node_modules/pi-agent-text-anchor-constant/package.json +9 -6
  362. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-48.js +2 -0
  363. package/node_modules/pi-agent-text-anchor-constant/src/resolver.ts +35 -36
  364. package/node_modules/pi-agent-text-anchor-exact/index.ts +34 -0
  365. package/node_modules/pi-agent-text-anchor-exact/package.json +27 -0
  366. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-49.js +1 -0
  367. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-50.js +2 -0
  368. package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +230 -0
  369. package/node_modules/pi-agent-text-anchor-exact/src/config.ts +159 -0
  370. package/node_modules/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +100 -0
  371. package/node_modules/pi-agent-text-anchor-exact/src/recovery.ts +151 -0
  372. package/node_modules/pi-agent-text-anchor-line-hash/index.ts +40 -36
  373. package/node_modules/pi-agent-text-anchor-line-hash/package.json +16 -12
  374. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-51.js +1 -0
  375. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-52.js +2 -0
  376. package/node_modules/pi-agent-text-anchor-line-hash/src/anchor.ts +105 -84
  377. package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +43 -42
  378. package/node_modules/pi-agent-text-editor/index.ts +7 -9
  379. package/node_modules/pi-agent-text-editor/package.json +26 -25
  380. package/node_modules/pi-agent-text-editor/runtime/entry-53.js +1 -0
  381. package/node_modules/pi-agent-text-editor/runtime/entry-54.js +1 -0
  382. package/node_modules/pi-agent-text-editor/runtime/entry-55.js +1 -0
  383. package/node_modules/pi-agent-text-editor/runtime/entry-56.js +1 -0
  384. package/node_modules/pi-agent-text-editor/runtime/entry-57.js +1 -0
  385. package/node_modules/pi-agent-text-editor/runtime/entry-58.js +1 -0
  386. package/node_modules/pi-agent-text-editor/runtime/entry-59.js +1 -0
  387. package/node_modules/pi-agent-text-editor/runtime/entry-60.js +1 -0
  388. package/node_modules/pi-agent-text-editor/runtime/entry-61.js +1 -0
  389. package/node_modules/pi-agent-text-editor/runtime/entry-62.js +1 -0
  390. package/node_modules/pi-agent-text-editor/runtime/entry-63.js +1 -0
  391. package/node_modules/pi-agent-text-editor/runtime/entry-64.js +1 -0
  392. package/node_modules/pi-agent-text-editor/runtime/entry-65.js +1 -0
  393. package/node_modules/pi-agent-text-editor/runtime/entry-66.js +1 -0
  394. package/node_modules/pi-agent-text-editor/runtime/entry-67.js +1 -0
  395. package/node_modules/pi-agent-text-editor/runtime/entry-68.js +2 -0
  396. package/node_modules/pi-agent-text-editor/src/api/anchor-inspection.ts +18 -18
  397. package/node_modules/pi-agent-text-editor/src/api/connect-plugin.ts +40 -50
  398. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +10 -13
  399. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +31 -36
  400. package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +25 -27
  401. package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +26 -31
  402. package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +18 -21
  403. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +20 -19
  404. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +154 -131
  405. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +173 -144
  406. package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +93 -103
  407. package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +17 -14
  408. package/node_modules/pi-agent-text-editor/src/api/text-selection-anchor.ts +85 -99
  409. package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +10 -10
  410. package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +18 -22
  411. package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +49 -48
  412. package/node_modules/pi-agent-text-editor/src/core/extension.ts +136 -127
  413. package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +279 -313
  414. package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +85 -95
  415. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +233 -289
  416. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +553 -582
  417. package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +64 -0
  418. package/node_modules/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +86 -98
  419. package/node_modules/pi-agent-text-editor/src/core/read-fragment-resolver.ts +83 -0
  420. package/node_modules/pi-agent-text-editor/src/core/text-anchor-recovery.ts +12 -11
  421. package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +369 -335
  422. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +184 -214
  423. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +476 -511
  424. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-execution.ts +93 -105
  425. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +31 -33
  426. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +526 -372
  427. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +111 -87
  428. package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +95 -0
  429. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +1899 -2027
  430. package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +26 -22
  431. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +1043 -634
  432. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +979 -1032
  433. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/partial-json-resolver.ts +19 -23
  434. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/partial-tool-recovery.ts +270 -273
  435. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +4 -2
  436. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +353 -403
  437. package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +9 -11
  438. package/node_modules/pi-agent-text-editor/src/tools/extension.ts +7 -8
  439. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +289 -75
  440. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +100 -106
  441. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +73 -66
  442. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +64 -42
  443. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +116 -124
  444. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +78 -58
  445. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +26 -17
  446. package/node_modules/pi-agent-text-editor-argument-order/index.ts +16 -19
  447. package/node_modules/pi-agent-text-editor-argument-order/package.json +5 -5
  448. package/node_modules/pi-agent-text-editor-argument-order/runtime/entry-69.js +2 -0
  449. package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +79 -91
  450. package/node_modules/pi-agent-text-editor-overwrite/index.ts +297 -323
  451. package/node_modules/pi-agent-text-editor-overwrite/package.json +6 -5
  452. package/node_modules/pi-agent-text-editor-overwrite/runtime/entry-70.js +2 -0
  453. package/node_modules/pi-agent-text-editor-renderer/index.ts +31 -12
  454. package/node_modules/pi-agent-text-editor-renderer/package.json +10 -7
  455. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-71.js +2 -0
  456. package/node_modules/pi-agent-text-editor-renderer/src/animation-pressure.ts +50 -0
  457. package/node_modules/pi-agent-text-editor-renderer/src/config.ts +73 -0
  458. package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +347 -359
  459. package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +255 -216
  460. package/node_modules/pi-agent-text-editor-renderer/src/diff-theme.ts +297 -329
  461. package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +19 -25
  462. package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +160 -168
  463. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +284 -180
  464. package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +550 -329
  465. package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +142 -118
  466. package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +47 -0
  467. package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +10 -4
  468. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +744 -631
  469. package/node_modules/pi-agent-text-editor-renderer/src/typing-interpolation.ts +215 -157
  470. package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +335 -335
  471. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +7 -6
  472. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-72.js +2 -0
  473. package/node_modules/pi-agent-tool-call-interception/package.json +5 -2
  474. package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +1 -0
  475. package/node_modules/pi-agent-tool-call-interception/src/index.ts +473 -350
  476. package/node_modules/pi-agent-tool-ui/package.json +15 -0
  477. package/node_modules/pi-agent-tool-ui/runtime/entry-74.js +1 -0
  478. package/node_modules/pi-agent-tool-ui/src/index.ts +318 -0
  479. package/node_modules/pi-agent-web/index.ts +35 -26
  480. package/node_modules/pi-agent-web/package.json +12 -10
  481. package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
  482. package/node_modules/pi-agent-web/src/browser-loader.ts +180 -0
  483. package/node_modules/pi-agent-web/src/doctor-plugin.ts +41 -0
  484. package/node_modules/pi-agent-web/src/resolver.ts +228 -146
  485. package/node_modules/pi-agent-web-html/index.ts +5 -6
  486. package/node_modules/pi-agent-web-html/package.json +9 -6
  487. package/node_modules/pi-agent-web-html/runtime/entry-76.js +2 -0
  488. package/node_modules/pi-agent-web-html/src/extract-readable-html.ts +72 -77
  489. package/node_modules/pi-agent-web-html/src/html-converter.ts +62 -75
  490. package/node_modules/pi-agent-web-image/index.ts +5 -6
  491. package/node_modules/pi-agent-web-image/package.json +6 -6
  492. package/node_modules/pi-agent-web-image/runtime/entry-77.js +2 -0
  493. package/node_modules/pi-agent-web-pdf/index.ts +5 -6
  494. package/node_modules/pi-agent-web-pdf/package.json +6 -6
  495. package/node_modules/pi-agent-web-pdf/runtime/entry-78.js +2 -0
  496. package/node_modules/pi-agent-web-text/index.ts +5 -6
  497. package/node_modules/pi-agent-web-text/package.json +6 -6
  498. package/node_modules/pi-agent-web-text/runtime/entry-79.js +2 -0
  499. package/package.json +101 -67
  500. package/src/api/code-view.ts +21 -17
  501. package/src/api/connect-doctor-plugin.ts +1 -0
  502. package/src/api/connect-plugin.ts +38 -48
  503. package/src/api/connect-tip-provider.ts +49 -0
  504. package/src/api/doctor.ts +1 -0
  505. package/src/api/plugin-protocol.ts +71 -40
  506. package/src/api/read.ts +6 -1
  507. package/src/api/resource.ts +3 -1
  508. package/src/api/search.ts +5 -1
  509. package/src/api/text-editor.ts +4 -1
  510. package/src/api/text.ts +3 -1
  511. package/src/api/tips.ts +77 -0
  512. package/src/api/tool-catalog.ts +1 -0
  513. package/src/api/tool-config/formatters.json +215 -0
  514. package/src/api/tool-config/linters.json +257 -0
  515. package/src/api/tool-config/lsp-servers.json +275 -0
  516. package/src/api/tool-config.ts +569 -0
  517. package/src/api/toolchain.ts +13 -18
  518. package/src/code-view/diagnostic-view.ts +150 -58
  519. package/src/code-view/reference.ts +64 -82
  520. package/src/code-view/source-view.ts +159 -180
  521. package/src/composite/builtin-extensions.ts +47 -37
  522. package/src/composite/extensions-config.ts +137 -0
  523. package/src/composite/selection.ts +109 -52
  524. package/src/core/diagnostic-store.ts +244 -0
  525. package/src/core/extension.ts +71 -35
  526. package/src/core/ide-core.ts +126 -98
  527. package/src/doctor/config-writer.ts +115 -0
  528. package/src/doctor/core.ts +221 -0
  529. package/src/doctor/discovery.ts +223 -0
  530. package/src/doctor/extension.ts +119 -0
  531. package/src/doctor/index.ts +1 -0
  532. package/src/doctor/inventory.ts +109 -0
  533. package/src/doctor/run.ts +177 -0
  534. package/src/doctor/tip-provider.ts +92 -0
  535. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +43 -44
  536. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +11 -11
  537. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/index.ts +5 -6
  538. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +8 -8
  539. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-21.js +2 -0
  540. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/index.ts +5 -6
  541. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +6 -6
  542. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-22.js +2 -0
  543. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/index.ts +11 -12
  544. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +8 -8
  545. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-23.js +2 -0
  546. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-20.js +2 -0
  547. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +112 -135
  548. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +35 -26
  549. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +12 -10
  550. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/index.ts +5 -6
  551. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +9 -6
  552. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +2 -0
  553. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/extract-readable-html.ts +72 -77
  554. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +62 -75
  555. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/index.ts +5 -6
  556. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +6 -6
  557. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-77.js +2 -0
  558. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/index.ts +5 -6
  559. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +6 -6
  560. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-78.js +2 -0
  561. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/index.ts +5 -6
  562. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +6 -6
  563. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-79.js +2 -0
  564. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +2 -0
  565. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +180 -0
  566. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/doctor-plugin.ts +41 -0
  567. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +228 -146
  568. package/src/extensions/pi-agent-read/index.ts +1 -1
  569. package/src/extensions/pi-agent-read/package.json +15 -13
  570. package/src/extensions/pi-agent-read/runtime/entry-35.js +1 -0
  571. package/src/extensions/pi-agent-read/runtime/entry-36.js +1 -0
  572. package/src/extensions/pi-agent-read/runtime/entry-37.js +1 -0
  573. package/src/extensions/pi-agent-read/runtime/entry-38.js +1 -0
  574. package/src/extensions/pi-agent-read/runtime/entry-39.js +2 -0
  575. package/src/extensions/pi-agent-read/src/api/connect-plugin.ts +38 -51
  576. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +27 -33
  577. package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -4
  578. package/src/extensions/pi-agent-read/src/api/tools/read.ts +237 -134
  579. package/src/extensions/pi-agent-read/src/core/extension.ts +51 -33
  580. package/src/extensions/pi-agent-read/src/core/read-core.ts +353 -330
  581. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +169 -156
  582. package/src/extensions/pi-agent-read/src/core/tools/read/persisted-result.ts +72 -0
  583. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +381 -313
  584. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +169 -154
  585. package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +165 -187
  586. package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +29 -0
  587. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +1117 -680
  588. package/src/extensions/pi-agent-search/package.json +11 -10
  589. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +90 -38
  590. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +13 -12
  591. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-45.js +2 -0
  592. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-46.js +1 -0
  593. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/doctor-plugin.ts +48 -0
  594. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +90 -86
  595. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +56 -0
  596. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +158 -161
  597. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/ripgrep.ts +16 -0
  598. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +215 -249
  599. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +262 -102
  600. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +68 -0
  601. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +275 -345
  602. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +152 -157
  603. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +438 -278
  604. package/src/extensions/pi-agent-search/runtime/entry-41.js +1 -0
  605. package/src/extensions/pi-agent-search/runtime/entry-42.js +1 -0
  606. package/src/extensions/pi-agent-search/runtime/entry-43.js +1 -0
  607. package/src/extensions/pi-agent-search/runtime/entry-44.js +2 -0
  608. package/src/extensions/pi-agent-search/src/api/connect-plugin.ts +37 -47
  609. package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +26 -30
  610. package/src/extensions/pi-agent-search/src/api/search.ts +65 -67
  611. package/src/extensions/pi-agent-search/src/core/extension.ts +184 -92
  612. package/src/extensions/pi-agent-search/src/core/search-config.ts +98 -0
  613. package/src/extensions/pi-agent-search/src/core/search-core.ts +332 -357
  614. package/src/extensions/pi-agent-search/src/core/search-timeout.ts +54 -0
  615. package/src/extensions/pi-agent-text-editor/index.ts +7 -9
  616. package/src/extensions/pi-agent-text-editor/package.json +26 -25
  617. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/index.ts +18 -20
  618. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +9 -6
  619. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-48.js +2 -0
  620. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/src/resolver.ts +35 -36
  621. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +34 -0
  622. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +27 -0
  623. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-49.js +1 -0
  624. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-50.js +2 -0
  625. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +230 -0
  626. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/config.ts +159 -0
  627. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +100 -0
  628. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/recovery.ts +151 -0
  629. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +40 -36
  630. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +16 -12
  631. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-51.js +1 -0
  632. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-52.js +2 -0
  633. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/anchor.ts +105 -84
  634. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +43 -42
  635. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +16 -19
  636. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +5 -5
  637. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-69.js +2 -0
  638. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +79 -91
  639. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +297 -323
  640. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +6 -5
  641. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/runtime/entry-70.js +2 -0
  642. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +31 -12
  643. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +10 -7
  644. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-71.js +2 -0
  645. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/animation-pressure.ts +50 -0
  646. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/config.ts +73 -0
  647. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +347 -359
  648. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +255 -216
  649. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-theme.ts +297 -329
  650. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +19 -25
  651. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +160 -168
  652. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +284 -180
  653. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +550 -329
  654. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +142 -118
  655. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +47 -0
  656. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +10 -4
  657. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +744 -631
  658. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/typing-interpolation.ts +215 -157
  659. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +335 -335
  660. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +7 -6
  661. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-72.js +2 -0
  662. package/src/extensions/pi-agent-text-editor/runtime/entry-53.js +1 -0
  663. package/src/extensions/pi-agent-text-editor/runtime/entry-54.js +1 -0
  664. package/src/extensions/pi-agent-text-editor/runtime/entry-55.js +1 -0
  665. package/src/extensions/pi-agent-text-editor/runtime/entry-56.js +1 -0
  666. package/src/extensions/pi-agent-text-editor/runtime/entry-57.js +1 -0
  667. package/src/extensions/pi-agent-text-editor/runtime/entry-58.js +1 -0
  668. package/src/extensions/pi-agent-text-editor/runtime/entry-59.js +1 -0
  669. package/src/extensions/pi-agent-text-editor/runtime/entry-60.js +1 -0
  670. package/src/extensions/pi-agent-text-editor/runtime/entry-61.js +1 -0
  671. package/src/extensions/pi-agent-text-editor/runtime/entry-62.js +1 -0
  672. package/src/extensions/pi-agent-text-editor/runtime/entry-63.js +1 -0
  673. package/src/extensions/pi-agent-text-editor/runtime/entry-64.js +1 -0
  674. package/src/extensions/pi-agent-text-editor/runtime/entry-65.js +1 -0
  675. package/src/extensions/pi-agent-text-editor/runtime/entry-66.js +1 -0
  676. package/src/extensions/pi-agent-text-editor/runtime/entry-67.js +1 -0
  677. package/src/extensions/pi-agent-text-editor/runtime/entry-68.js +2 -0
  678. package/src/extensions/pi-agent-text-editor/src/api/anchor-inspection.ts +18 -18
  679. package/src/extensions/pi-agent-text-editor/src/api/connect-plugin.ts +40 -50
  680. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +10 -13
  681. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +31 -36
  682. package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +25 -27
  683. package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +26 -31
  684. package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +18 -21
  685. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +20 -19
  686. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +154 -131
  687. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +173 -144
  688. package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +93 -103
  689. package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +17 -14
  690. package/src/extensions/pi-agent-text-editor/src/api/text-selection-anchor.ts +85 -99
  691. package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +10 -10
  692. package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +18 -22
  693. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +49 -48
  694. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +136 -127
  695. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +279 -313
  696. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +85 -95
  697. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +233 -289
  698. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +553 -582
  699. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +64 -0
  700. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +86 -98
  701. package/src/extensions/pi-agent-text-editor/src/core/read-fragment-resolver.ts +83 -0
  702. package/src/extensions/pi-agent-text-editor/src/core/text-anchor-recovery.ts +12 -11
  703. package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +369 -335
  704. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +184 -214
  705. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +476 -511
  706. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-execution.ts +93 -105
  707. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +31 -33
  708. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +526 -372
  709. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +111 -87
  710. package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +95 -0
  711. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +1899 -2027
  712. package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +26 -22
  713. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +1043 -634
  714. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +979 -1032
  715. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/partial-json-resolver.ts +19 -23
  716. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/partial-tool-recovery.ts +270 -273
  717. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +4 -2
  718. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +353 -403
  719. package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +9 -11
  720. package/src/extensions/pi-agent-text-editor/src/tools/extension.ts +7 -8
  721. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +289 -75
  722. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +100 -106
  723. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +73 -66
  724. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +64 -42
  725. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +116 -124
  726. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +78 -58
  727. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +26 -17
  728. package/src/pi-agent-ide.ts +22 -10
  729. package/src/plugins/pi-agent-ide-ast/index.ts +1 -1
  730. package/src/plugins/pi-agent-ide-ast/package.json +15 -13
  731. package/src/plugins/pi-agent-ide-ast/runtime/entry-24.js +1 -0
  732. package/src/plugins/pi-agent-ide-ast/runtime/entry-25.js +2 -0
  733. package/src/plugins/pi-agent-ide-ast/src/api/scope.ts +1 -1
  734. package/src/plugins/pi-agent-ide-ast/src/ast/collect-files.ts +11 -16
  735. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +292 -322
  736. package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +591 -656
  737. package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +15 -19
  738. package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +130 -0
  739. package/src/plugins/pi-agent-ide-ast/src/extension.ts +75 -64
  740. package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +51 -54
  741. package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +168 -185
  742. package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +36 -36
  743. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +118 -129
  744. package/src/plugins/pi-agent-ide-changes/index.ts +57 -51
  745. package/src/plugins/pi-agent-ide-changes/package.json +14 -12
  746. package/src/plugins/pi-agent-ide-changes/runtime/entry-26.js +1 -0
  747. package/src/plugins/pi-agent-ide-changes/runtime/entry-27.js +2 -0
  748. package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +74 -78
  749. package/src/plugins/pi-agent-ide-changes/src/changes/change-groups.ts +230 -245
  750. package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +189 -192
  751. package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +75 -79
  752. package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +259 -276
  753. package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +164 -190
  754. package/src/plugins/pi-agent-ide-changes/src/doctor-plugin.ts +59 -0
  755. package/src/plugins/pi-agent-ide-changes/src/index-mutation-queue.ts +10 -9
  756. package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +49 -62
  757. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +98 -93
  758. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +131 -126
  759. package/src/plugins/pi-agent-ide-diagnostics/index.ts +1 -0
  760. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +191 -0
  761. package/src/plugins/pi-agent-ide-formatter/index.ts +22 -23
  762. package/src/plugins/pi-agent-ide-formatter/package.json +6 -3
  763. package/src/plugins/pi-agent-ide-formatter/runtime/entry-28.js +2 -0
  764. package/src/plugins/pi-agent-ide-formatter/src/catalog.ts +281 -0
  765. package/src/plugins/pi-agent-ide-formatter/src/doctor-plugin.ts +156 -0
  766. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +38 -40
  767. package/src/plugins/pi-agent-ide-formatter/src/registry.ts +94 -27
  768. package/src/plugins/pi-agent-ide-languages/index.ts +24 -0
  769. package/{node_modules/pi-agent-search-semantic → src/plugins/pi-agent-ide-languages}/package.json +6 -7
  770. package/src/plugins/pi-agent-ide-languages/runtime/entry-29.js +2 -0
  771. package/src/plugins/pi-agent-ide-languages/src/languages.ts +84 -0
  772. package/src/plugins/pi-agent-ide-lint/index.ts +66 -225
  773. package/src/plugins/pi-agent-ide-lint/package.json +10 -8
  774. package/src/plugins/pi-agent-ide-lint/runtime/entry-30.js +2 -0
  775. package/src/plugins/pi-agent-ide-lint/src/catalog.ts +295 -0
  776. package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +98 -144
  777. package/src/plugins/pi-agent-ide-lint/src/diagnostics.ts +182 -0
  778. package/src/plugins/pi-agent-ide-lint/src/doctor-plugin.ts +155 -0
  779. package/src/plugins/pi-agent-ide-lint/src/registry.ts +94 -27
  780. package/src/plugins/pi-agent-ide-lsp/index.ts +111 -231
  781. package/src/plugins/pi-agent-ide-lsp/package.json +13 -11
  782. package/src/plugins/pi-agent-ide-lsp/runtime/entry-31.js +2 -0
  783. package/src/plugins/pi-agent-ide-lsp/src/catalog.ts +248 -0
  784. package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +109 -116
  785. package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +113 -0
  786. package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +163 -0
  787. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +439 -396
  788. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +421 -458
  789. package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +76 -0
  790. package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +143 -159
  791. package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +25 -20
  792. package/src/plugins/pi-agent-ide-lsp/src/lsp/language-map.ts +31 -33
  793. package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +49 -57
  794. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +350 -415
  795. package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +58 -63
  796. package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +196 -77
  797. package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +36 -36
  798. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +118 -127
  799. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +108 -107
  800. package/src/plugins/pi-agent-ide-lsp/src/lsp/types.ts +76 -57
  801. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +36 -32
  802. package/src/post-edit/gate.ts +18 -150
  803. package/src/tips/core.ts +86 -0
  804. package/src/tips/extension.ts +115 -0
  805. package/src/tips/persistence.ts +225 -0
  806. package/src/tips/tip-callout.ts +77 -0
  807. package/src/toolchain/diagnostic.ts +3 -4
  808. package/src/toolchain/registry.ts +133 -170
  809. package/src/toolchain/types.ts +83 -128
  810. package/node_modules/pi-agent-ide-formatter/src/types.ts +0 -10
  811. package/node_modules/pi-agent-ide-lint/src/command-runner.ts +0 -51
  812. package/node_modules/pi-agent-ide-lint/src/types.ts +0 -10
  813. package/node_modules/pi-agent-search-semantic/index.ts +0 -105
  814. package/node_modules/pi-agent-search-text/src/lucene-query-parser.d.ts +0 -22
  815. package/node_modules/pi-agent-search-web/index.ts +0 -74
  816. package/node_modules/pi-agent-search-web/package.json +0 -19
  817. package/node_modules/pi-agent-search-web/src/config.ts +0 -499
  818. package/node_modules/pi-agent-search-web/src/providers/duckduckgo-html.ts +0 -78
  819. package/node_modules/pi-agent-search-web/src/providers/endpoints.ts +0 -89
  820. package/node_modules/pi-agent-search-web/src/providers/request.ts +0 -430
  821. package/node_modules/pi-agent-search-web/src/providers/response.ts +0 -402
  822. package/node_modules/pi-agent-search-web/src/search-format.ts +0 -29
  823. package/node_modules/pi-agent-search-web/src/search.ts +0 -434
  824. package/node_modules/pi-agent-search-web/src/types.ts +0 -153
  825. package/src/composite/config.ts +0 -94
  826. package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/index.ts +0 -105
  827. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/lucene-query-parser.d.ts +0 -22
  828. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/index.ts +0 -74
  829. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/package.json +0 -19
  830. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/config.ts +0 -499
  831. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/duckduckgo-html.ts +0 -78
  832. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/endpoints.ts +0 -89
  833. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/request.ts +0 -430
  834. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/response.ts +0 -402
  835. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search-format.ts +0 -29
  836. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search.ts +0 -434
  837. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/types.ts +0 -153
  838. package/src/plugins/pi-agent-ide-formatter/src/types.ts +0 -10
  839. package/src/plugins/pi-agent-ide-lint/src/command-runner.ts +0 -51
  840. package/src/plugins/pi-agent-ide-lint/src/types.ts +0 -10
  841. package/src/toolchain/gate.ts +0 -322
@@ -1,11 +1,12 @@
1
+ import { requiredValue } from "pi-agent-invariant";
1
2
  import path from "node:path";
2
3
 
3
4
  import {
4
- formatSourceViewResults,
5
- renderSourceViewLine,
6
- type SourceMappedTextContent,
7
- type SourceViewBlock,
8
- type SourceViewLine,
5
+ formatSourceViewResults,
6
+ renderSourceViewLine,
7
+ type SourceMappedTextContent,
8
+ type SourceViewBlock,
9
+ type SourceViewLine,
9
10
  } from "pi-agent-ide/api/code-view";
10
11
 
11
12
  import { collectFiles } from "./collect-files.js";
@@ -15,615 +16,554 @@ import { readTextFile } from "./read-text.js";
15
16
  import type * as WTS from "web-tree-sitter";
16
17
 
17
18
  const SUPPORTED_EXTENSIONS = new Set([
18
- ".ts",
19
- ".tsx",
20
- ".js",
21
- ".jsx",
22
- ".mjs",
23
- ".cjs",
24
- ".py",
25
- ".rs",
26
- ".c",
27
- ".cpp",
28
- ".cxx",
29
- ".h",
30
- ".hpp",
31
- ".json",
32
- ".jsonc",
33
- ".yaml",
34
- ".yml",
35
- ".toml",
19
+ ".ts",
20
+ ".tsx",
21
+ ".js",
22
+ ".jsx",
23
+ ".mjs",
24
+ ".cjs",
25
+ ".py",
26
+ ".rs",
27
+ ".c",
28
+ ".cpp",
29
+ ".cxx",
30
+ ".h",
31
+ ".hpp",
32
+ ".json",
33
+ ".jsonc",
34
+ ".yaml",
35
+ ".yml",
36
+ ".toml",
36
37
  ]);
37
38
 
38
39
  const DATA_EXTENSIONS = new Set([".json", ".jsonc", ".yaml", ".yml", ".toml"]);
39
40
 
40
41
  const DECLARATION_TYPES = new Set([
41
- "class_declaration",
42
- "class_definition",
43
- "class_specifier",
44
- "enum_declaration",
45
- "enum_definition",
46
- "enum_item",
47
- "enum_specifier",
48
- "export_statement",
49
- "function_declaration",
50
- "function_definition",
51
- "function_item",
52
- "impl_item",
53
- "interface_declaration",
54
- "lexical_declaration",
55
- "namespace_definition",
56
- "mod_item",
57
- "public_field_definition",
58
- "method_definition",
59
- "method_signature",
60
- "property_signature",
61
- "field_declaration",
62
- "struct_item",
63
- "struct_specifier",
64
- "trait_item",
65
- "type_alias_declaration",
66
- "type_item",
67
- "variable_declaration",
68
- "assignment",
42
+ "class_declaration",
43
+ "class_definition",
44
+ "class_specifier",
45
+ "enum_declaration",
46
+ "enum_definition",
47
+ "enum_item",
48
+ "enum_specifier",
49
+ "export_statement",
50
+ "function_declaration",
51
+ "function_definition",
52
+ "function_item",
53
+ "impl_item",
54
+ "interface_declaration",
55
+ "lexical_declaration",
56
+ "namespace_definition",
57
+ "mod_item",
58
+ "public_field_definition",
59
+ "method_definition",
60
+ "method_signature",
61
+ "property_signature",
62
+ "field_declaration",
63
+ "struct_item",
64
+ "struct_specifier",
65
+ "trait_item",
66
+ "type_alias_declaration",
67
+ "type_item",
68
+ "variable_declaration",
69
+ "assignment",
69
70
  ]);
70
71
 
71
72
  const ROOT_TYPES = new Set(["module", "program", "source_file"]);
72
73
 
73
74
  const IMPORT_TYPES = new Set([
74
- "import_declaration",
75
- "import_from_statement",
76
- "import_statement",
77
- "use_declaration",
75
+ "import_declaration",
76
+ "import_from_statement",
77
+ "import_statement",
78
+ "use_declaration",
78
79
  ]);
79
80
 
80
81
  const FUNCTION_TYPES = new Set([
81
- "arrow_function",
82
- "function_declaration",
83
- "function_definition",
84
- "function_item",
85
- "function_expression",
86
- "method_definition",
82
+ "arrow_function",
83
+ "function_declaration",
84
+ "function_definition",
85
+ "function_item",
86
+ "function_expression",
87
+ "method_definition",
87
88
  ]);
88
89
 
89
- const INITIALIZER_TYPES = new Set([
90
- "public_field_definition",
91
- "variable_declarator",
92
- "assignment",
93
- ]);
90
+ const INITIALIZER_TYPES = new Set(["public_field_definition", "variable_declarator", "assignment"]);
94
91
 
95
92
  const NAME_TYPES = new Set([
96
- "field_identifier",
97
- "identifier",
98
- "property_identifier",
99
- "shorthand_property_identifier_pattern",
100
- "type_identifier",
93
+ "field_identifier",
94
+ "identifier",
95
+ "property_identifier",
96
+ "shorthand_property_identifier_pattern",
97
+ "type_identifier",
101
98
  ]);
102
99
 
103
- interface Replacement
104
- {
105
- readonly start: number;
106
- readonly end: number;
107
- readonly text: string;
108
- readonly lineSourceLines?: readonly (number | undefined)[];
100
+ interface Replacement {
101
+ readonly start: number;
102
+ readonly end: number;
103
+ readonly text: string;
104
+ readonly lineSourceLines?: readonly (number | undefined)[];
109
105
  }
110
106
 
111
- interface ProjectedLine
112
- {
113
- readonly content: string;
114
- readonly sourceLine?: number;
107
+ interface ProjectedLine {
108
+ readonly content: string;
109
+ readonly sourceLine?: number;
115
110
  }
116
111
 
117
- export function isSupportedOutlinePath(filePath: string): boolean
118
- {
119
- return SUPPORTED_EXTENSIONS.has(path.extname(filePath).toLowerCase());
112
+ export function isSupportedOutlinePath(filePath: string): boolean {
113
+ return SUPPORTED_EXTENSIONS.has(path.extname(filePath).toLowerCase());
120
114
  }
121
115
 
122
116
  const PEEK_FORMAT_OPTIONS = {
123
- failureLabel: "PEEK_FAILED",
124
- emptyReason: "no entries to peek.",
125
- recovery: ["Call peek with { peers: [{ path: \"path/to/file.ts\" }, ...] }."],
117
+ failureLabel: "PEEK_FAILED",
118
+ emptyReason: "no entries to peek.",
119
+ recovery: ['Call peek with { peers: [{ path: "path/to/file.ts" }, ...] }.'],
126
120
  } as const;
127
121
 
128
122
  const AST_OUTLINE_FORMAT_OPTIONS = {
129
- failureLabel: "AST_OUTLINE_FAILED",
130
- emptyReason: "no AST outline was produced.",
123
+ failureLabel: "AST_OUTLINE_FAILED",
124
+ emptyReason: "no AST outline was produced.",
131
125
  } as const;
132
126
 
133
- export function formatAstOutline(block: SourceViewBlock): SourceMappedTextContent
134
- {
135
- return formatSourceViewResults([block], AST_OUTLINE_FORMAT_OPTIONS);
127
+ export function formatAstOutline(block: SourceViewBlock): SourceMappedTextContent {
128
+ return formatSourceViewResults([block], AST_OUTLINE_FORMAT_OPTIONS);
136
129
  }
137
130
 
138
- export class AstOutlineManager
139
- {
140
- private readonly fallbackScopeManager = new AstScopeManager();
141
-
142
- public async readFileOutline(filePath: string, cwd: string): Promise<SourceViewBlock>
143
- {
144
- const absolutePath = resolvePath(filePath, cwd);
145
- const displayPath = path.relative(cwd, absolutePath) || absolutePath;
146
-
147
- if (!isSupportedOutlinePath(absolutePath))
148
- {
149
- throw new Error(`AST outline is not supported for ${displayPath}.`);
150
- }
151
-
152
- const snapshot = await readTextFile(absolutePath);
153
- const tree = await parseDocument(absolutePath, cwd, snapshot.lines);
154
-
155
- if (!tree)
156
- {
157
- throw new Error(`No AST parser is available for ${displayPath}.`);
158
- }
159
-
160
- return await this.createSourceViewBlock(
161
- tree.rootNode,
162
- absolutePath,
163
- displayPath,
164
- cwd,
165
- snapshot.lines,
166
- snapshot.content,
167
- path.extname(absolutePath).toLowerCase(),
168
- );
169
- }
131
+ export class AstOutlineManager {
132
+ private readonly fallbackScopeManager = new AstScopeManager();
170
133
 
171
- public async formatFile(filePath: string, cwd: string): Promise<SourceMappedTextContent>
172
- {
173
- const absolutePath = resolvePath(filePath, cwd);
174
- const displayPath = path.relative(cwd, absolutePath) || absolutePath;
175
-
176
- if (!isSupportedOutlinePath(absolutePath))
177
- {
178
- const snapshot = await readTextFile(absolutePath);
179
- return formatSourceViewResults(
180
- [formatUnsupportedSourceBlock(absolutePath, displayPath, snapshot.lines)],
181
- PEEK_FORMAT_OPTIONS,
182
- );
183
- }
184
-
185
- try
186
- {
187
- return formatSourceViewResults([await this.readFileOutline(absolutePath, cwd)], PEEK_FORMAT_OPTIONS);
188
- }
189
- catch (error)
190
- {
191
- const message = error instanceof Error ? error.message : String(error);
192
- return formatSourceViewResults([failedSourceViewBlock(displayPath, message)], PEEK_FORMAT_OPTIONS);
193
- }
194
- }
134
+ public async readFileOutline(filePath: string, cwd: string): Promise<SourceViewBlock> {
135
+ const absolutePath = resolvePath(filePath, cwd);
136
+ const displayPath = path.relative(cwd, absolutePath) || absolutePath;
195
137
 
196
- public async formatSymbol(symbol: string, cwd: string): Promise<SourceMappedTextContent>
197
- {
198
- const files = await collectFiles(cwd);
199
- const supportedFiles = files
200
- .filter((filePath) => isSupportedOutlinePath(filePath))
201
- .sort();
202
-
203
- for (const filePath of supportedFiles)
204
- {
205
- let snapshot;
206
-
207
- try
208
- {
209
- snapshot = await readTextFile(filePath);
210
- }
211
- catch
212
- {
213
- continue;
214
- }
215
-
216
- let tree;
217
-
218
- try
219
- {
220
- tree = await parseDocument(filePath, cwd, snapshot.lines);
221
- }
222
- catch
223
- {
224
- continue;
225
- }
226
-
227
- if (!tree)
228
- {
229
- continue;
230
- }
231
-
232
- const match = findSymbol(tree.rootNode, symbol);
233
-
234
- if (!match)
235
- {
236
- continue;
237
- }
238
-
239
- const displayPath = path.relative(cwd, filePath) || filePath;
240
- const block = await this.createSourceViewBlock(
241
- match,
242
- filePath,
243
- displayPath,
244
- cwd,
245
- snapshot.lines,
246
- snapshot.content,
247
- path.extname(filePath).toLowerCase(),
248
- symbol,
249
- [`defined in: ${displayPath}:${match.startPosition.row + 1}`],
250
- );
251
- return formatSourceViewResults([block], PEEK_FORMAT_OPTIONS);
252
- }
253
-
254
- return formatSourceViewResults(
255
- [failedSourceViewBlock("", `symbol not found: ${symbol}`, "PEEK_NOT_FOUND")],
256
- PEEK_FORMAT_OPTIONS,
257
- );
138
+ if (!isSupportedOutlinePath(absolutePath)) {
139
+ throw new Error(`AST outline is not supported for ${displayPath}.`);
258
140
  }
259
141
 
260
- private async createSourceViewBlock(
261
- node: WTS.Node,
262
- filePath: string,
263
- displayPath: string,
264
- cwd: string,
265
- sourceLines: readonly string[],
266
- source: string,
267
- extension: string,
268
- heading?: string,
269
- details?: readonly string[],
270
- ): Promise<SourceViewBlock>
271
- {
272
- const projectedLines = renderNodeLines(node, source, extension);
273
- const scopes = await getOutlineScopes(this.fallbackScopeManager, filePath, cwd, sourceLines);
274
- const markersByLine = buildScopeMarkers(scopes);
275
- const renderedLines = projectedLines.map((line) =>
276
- {
277
- const sourceLineNumber = line.sourceLine;
278
- const sourceContent = sourceLineNumber === undefined ? undefined : sourceLines[sourceLineNumber - 1] ?? "";
279
- const markers = sourceLineNumber === undefined ? undefined : markersByLine.get(sourceLineNumber);
280
- const suffix = markers?.map((marker) => ` <!-- ${marker} -->`).join("") ?? "";
281
-
282
- return renderSourceViewLine({
283
- content: line.content,
284
- ...(sourceLineNumber === undefined || sourceContent === undefined
285
- ? {}
286
- : {
287
- sourceLine: {
288
- source: filePath,
289
- lineNumber: sourceLineNumber,
290
- content: sourceContent,
291
- },
292
- }),
293
- ...(suffix.length === 0 ? {} : { suffix }),
294
- } satisfies SourceViewLine);
295
- });
142
+ const snapshot = await readTextFile(absolutePath);
143
+ const tree = await parseDocument(absolutePath, cwd, snapshot.lines);
296
144
 
297
- return {
298
- path: displayPath,
299
- ...(heading === undefined ? {} : { heading }),
300
- ...(details === undefined ? {} : { details }),
301
- startLine: node.startPosition.row + 1,
302
- endLine: node.endPosition.row + 1,
303
- totalLines: sourceLines.length,
304
- renderedLines,
305
- };
145
+ if (!tree) {
146
+ throw new Error(`No AST parser is available for ${displayPath}.`);
306
147
  }
307
- }
308
148
 
309
- function formatUnsupportedSourceBlock(
310
- sourcePath: string,
149
+ return await this.createSourceViewBlock(
150
+ tree.rootNode,
151
+ absolutePath,
152
+ displayPath,
153
+ cwd,
154
+ snapshot.lines,
155
+ snapshot.content,
156
+ path.extname(absolutePath).toLowerCase(),
157
+ );
158
+ }
159
+
160
+ public async formatFile(filePath: string, cwd: string): Promise<SourceMappedTextContent> {
161
+ const absolutePath = resolvePath(filePath, cwd);
162
+ const displayPath = path.relative(cwd, absolutePath) || absolutePath;
163
+
164
+ if (!isSupportedOutlinePath(absolutePath)) {
165
+ const snapshot = await readTextFile(absolutePath);
166
+ return formatSourceViewResults(
167
+ [formatUnsupportedSourceBlock(absolutePath, displayPath, snapshot.lines)],
168
+ PEEK_FORMAT_OPTIONS,
169
+ );
170
+ }
171
+
172
+ try {
173
+ return formatSourceViewResults(
174
+ [await this.readFileOutline(absolutePath, cwd)],
175
+ PEEK_FORMAT_OPTIONS,
176
+ );
177
+ } catch (error) {
178
+ const message = error instanceof Error ? error.message : String(error);
179
+ return formatSourceViewResults(
180
+ [failedSourceViewBlock(displayPath, message)],
181
+ PEEK_FORMAT_OPTIONS,
182
+ );
183
+ }
184
+ }
185
+
186
+ public async formatSymbol(symbol: string, cwd: string): Promise<SourceMappedTextContent> {
187
+ const files = await collectFiles(cwd);
188
+ const supportedFiles = files.filter((filePath) => isSupportedOutlinePath(filePath)).sort();
189
+
190
+ for (const filePath of supportedFiles) {
191
+ let snapshot;
192
+
193
+ try {
194
+ snapshot = await readTextFile(filePath);
195
+ } catch {
196
+ continue;
197
+ }
198
+
199
+ let tree;
200
+
201
+ try {
202
+ tree = await parseDocument(filePath, cwd, snapshot.lines);
203
+ } catch {
204
+ continue;
205
+ }
206
+
207
+ if (!tree) {
208
+ continue;
209
+ }
210
+
211
+ const match = findSymbol(tree.rootNode, symbol);
212
+
213
+ if (!match) {
214
+ continue;
215
+ }
216
+
217
+ const displayPath = path.relative(cwd, filePath) || filePath;
218
+ const block = await this.createSourceViewBlock(
219
+ match,
220
+ filePath,
221
+ displayPath,
222
+ cwd,
223
+ snapshot.lines,
224
+ snapshot.content,
225
+ path.extname(filePath).toLowerCase(),
226
+ symbol,
227
+ [`defined in: ${displayPath}:${match.startPosition.row + 1}`],
228
+ );
229
+ return formatSourceViewResults([block], PEEK_FORMAT_OPTIONS);
230
+ }
231
+
232
+ return formatSourceViewResults(
233
+ [failedSourceViewBlock("", `symbol not found: ${symbol}`, "PEEK_NOT_FOUND")],
234
+ PEEK_FORMAT_OPTIONS,
235
+ );
236
+ }
237
+
238
+ private async createSourceViewBlock(
239
+ node: WTS.Node,
240
+ filePath: string,
311
241
  displayPath: string,
242
+ cwd: string,
312
243
  sourceLines: readonly string[],
313
- ): SourceViewBlock
314
- {
315
- return {
316
- path: displayPath,
317
- startLine: sourceLines.length > 0 ? 1 : 0,
318
- endLine: sourceLines.length,
319
- totalLines: sourceLines.length,
320
- renderedLines: sourceLines.map((content, index) =>
321
- renderSourceViewLine({
322
- content,
323
- sourceLine: {
324
- source: sourcePath,
325
- lineNumber: index + 1,
326
- content,
327
- },
328
- })
329
- ),
330
- };
331
- }
244
+ source: string,
245
+ extension: string,
246
+ heading?: string,
247
+ details?: readonly string[],
248
+ ): Promise<SourceViewBlock> {
249
+ const projectedLines = renderNodeLines(node, source, extension);
250
+ const scopes = await getOutlineScopes(this.fallbackScopeManager, filePath, cwd, sourceLines);
251
+ const markersByLine = buildScopeMarkers(scopes);
252
+ const renderedLines = projectedLines.map((line) => {
253
+ const sourceLineNumber = line.sourceLine;
254
+ const sourceContent =
255
+ sourceLineNumber === undefined ? undefined : (sourceLines[sourceLineNumber - 1] ?? "");
256
+ const markers =
257
+ sourceLineNumber === undefined ? undefined : markersByLine.get(sourceLineNumber);
258
+ const suffix = markers?.map((marker) => ` <!-- ${marker} -->`).join("") ?? "";
259
+
260
+ return renderSourceViewLine({
261
+ content: line.content,
262
+ ...(!(sourceLineNumber === undefined || sourceContent === undefined) && {
263
+ sourceLine: {
264
+ source: filePath,
265
+ lineNumber: sourceLineNumber,
266
+ content: sourceContent,
267
+ },
268
+ }),
269
+ ...(suffix.length > 0 && { suffix }),
270
+ } satisfies SourceViewLine);
271
+ });
332
272
 
333
- function failedSourceViewBlock(path: string, error: string, code = "PEEK_FAILED"): SourceViewBlock
334
- {
335
273
  return {
336
- path,
337
- startLine: 0,
338
- endLine: 0,
339
- totalLines: 0,
340
- renderedLines: [],
341
- status: "failed",
342
- error,
343
- code,
274
+ path: displayPath,
275
+ ...(heading !== undefined && { heading }),
276
+ ...(details !== undefined && { details }),
277
+ startLine: node.startPosition.row + 1,
278
+ endLine: node.endPosition.row + 1,
279
+ totalLines: sourceLines.length,
280
+ renderedLines,
344
281
  };
282
+ }
345
283
  }
346
284
 
347
- function getOutlineScopes(
348
- fallback: AstScopeManager,
349
- filePath: string,
350
- cwd: string,
351
- lines: readonly string[],
352
- ): Promise<ScopeEntry[]>
353
- {
354
- return fallback.getDocumentScopes(filePath, cwd, lines);
285
+ function formatUnsupportedSourceBlock(
286
+ sourcePath: string,
287
+ displayPath: string,
288
+ sourceLines: readonly string[],
289
+ ): SourceViewBlock {
290
+ return {
291
+ path: displayPath,
292
+ startLine: sourceLines.length > 0 ? 1 : 0,
293
+ endLine: sourceLines.length,
294
+ totalLines: sourceLines.length,
295
+ renderedLines: sourceLines.map((content, index) =>
296
+ renderSourceViewLine({
297
+ content,
298
+ sourceLine: {
299
+ source: sourcePath,
300
+ lineNumber: index + 1,
301
+ content,
302
+ },
303
+ }),
304
+ ),
305
+ };
355
306
  }
356
307
 
357
- function buildScopeMarkers(scopes: readonly ScopeEntry[]): Map<number, string[]>
358
- {
359
- const markers = new Map<number, string[]>();
308
+ function failedSourceViewBlock(path: string, error: string, code = "PEEK_FAILED"): SourceViewBlock {
309
+ return {
310
+ path,
311
+ startLine: 0,
312
+ endLine: 0,
313
+ totalLines: 0,
314
+ renderedLines: [],
315
+ status: "failed",
316
+ error,
317
+ code,
318
+ };
319
+ }
360
320
 
361
- for (const scope of scopes)
362
- {
363
- const begin = markers.get(scope.startLine) ?? [];
364
- begin.push(scope.beginAnchor.value);
365
- markers.set(scope.startLine, begin);
321
+ function getOutlineScopes(
322
+ fallback: AstScopeManager,
323
+ filePath: string,
324
+ cwd: string,
325
+ lines: readonly string[],
326
+ ): Promise<ScopeEntry[]> {
327
+ return fallback.getDocumentScopes(filePath, cwd, lines);
328
+ }
366
329
 
367
- const end = markers.get(scope.endLine) ?? [];
368
- end.push(scope.endScopeAnchor.value);
369
- markers.set(scope.endLine, end);
370
- }
330
+ function buildScopeMarkers(scopes: readonly ScopeEntry[]): Map<number, string[]> {
331
+ const markers = new Map<number, string[]>();
371
332
 
372
- return markers;
373
- }
333
+ for (const scope of scopes) {
334
+ const begin = markers.get(scope.startLine) ?? [];
335
+ begin.push(scope.beginAnchor.value);
336
+ markers.set(scope.startLine, begin);
374
337
 
375
- function resolvePath(filePath: string, cwd: string): string
376
- {
377
- if (filePath.startsWith("file://"))
378
- {
379
- return decodeURIComponent(filePath.slice("file://".length));
380
- }
338
+ const end = markers.get(scope.endLine) ?? [];
339
+ end.push(scope.endScopeAnchor.value);
340
+ markers.set(scope.endLine, end);
341
+ }
381
342
 
382
- return path.isAbsolute(filePath) ? filePath : path.resolve(cwd, filePath);
343
+ return markers;
383
344
  }
384
345
 
385
- function findSymbol(root: WTS.Node, symbol: string): WTS.Node | undefined
386
- {
387
- let result: WTS.Node | undefined;
388
-
389
- const visit = (node: WTS.Node): void =>
390
- {
391
- if (result)
392
- {
393
- return;
394
- }
395
-
396
- if (DECLARATION_TYPES.has(node.type) && getNodeName(node) === symbol)
397
- {
398
- result = unwrapDeclaration(node);
399
- return;
400
- }
401
-
402
- for (const child of node.namedChildren)
403
- {
404
- visit(child);
405
- }
406
- };
346
+ function resolvePath(filePath: string, cwd: string): string {
347
+ if (filePath.startsWith("file://")) {
348
+ return decodeURIComponent(filePath.slice("file://".length));
349
+ }
407
350
 
408
- visit(root);
409
- return result;
351
+ return path.isAbsolute(filePath) ? filePath : path.resolve(cwd, filePath);
410
352
  }
411
353
 
412
- function getNodeName(node: WTS.Node): string | undefined
413
- {
414
- const nameField = node.childForFieldName("name");
354
+ function findSymbol(root: WTS.Node, symbol: string): WTS.Node | undefined {
355
+ let result: WTS.Node | undefined;
415
356
 
416
- if (nameField && NAME_TYPES.has(nameField.type))
417
- {
418
- return nameField.text;
357
+ const visit = (node: WTS.Node): void => {
358
+ if (result) {
359
+ return;
419
360
  }
420
361
 
421
- for (const child of node.namedChildren)
422
- {
423
- if (NAME_TYPES.has(child.type))
424
- {
425
- return child.text;
426
- }
362
+ if (DECLARATION_TYPES.has(node.type) && getNodeName(node) === symbol) {
363
+ result = unwrapDeclaration(node);
364
+ return;
427
365
  }
428
366
 
429
- if (node.type === "lexical_declaration" || node.type === "variable_declaration")
430
- {
431
- const declarator = node.namedChildren.find((child) => child.type === "variable_declarator");
432
- const name = declarator?.childForFieldName("name");
433
- return name?.text;
367
+ for (const child of node.namedChildren) {
368
+ visit(child);
434
369
  }
370
+ };
435
371
 
436
- if (node.type === "function_definition")
437
- {
438
- const declarator = node.childForFieldName("declarator");
439
- return declarator ? findNestedName(declarator) : undefined;
440
- }
441
-
442
- return undefined;
372
+ visit(root);
373
+ return result;
443
374
  }
444
375
 
445
- function findNestedName(node: WTS.Node): string | undefined
446
- {
447
- if (NAME_TYPES.has(node.type))
448
- {
449
- return node.text;
450
- }
376
+ function getNodeName(node: WTS.Node): string | undefined {
377
+ const nameField = node.childForFieldName("name");
451
378
 
452
- for (const child of node.namedChildren)
453
- {
454
- const name = findNestedName(child);
379
+ if (nameField && NAME_TYPES.has(nameField.type)) {
380
+ return nameField.text;
381
+ }
455
382
 
456
- if (name)
457
- {
458
- return name;
459
- }
383
+ for (const child of node.namedChildren) {
384
+ if (NAME_TYPES.has(child.type)) {
385
+ return child.text;
460
386
  }
387
+ }
461
388
 
462
- return undefined;
463
- }
389
+ if (node.type === "lexical_declaration" || node.type === "variable_declaration") {
390
+ const declarator = node.namedChildren.find((child) => child.type === "variable_declarator");
391
+ const name = declarator?.childForFieldName("name");
392
+ return name?.text;
393
+ }
464
394
 
465
- function unwrapDeclaration(node: WTS.Node): WTS.Node
466
- {
467
- const parent = node.parent;
468
-
469
- if (
470
- parent
471
- && (parent.type === "export_statement" || parent.type === "decorated_definition"
472
- || parent.type === "template_declaration")
473
- )
474
- {
475
- return parent;
476
- }
395
+ if (node.type === "function_definition") {
396
+ const declarator = node.childForFieldName("declarator");
397
+ return declarator ? findNestedName(declarator) : undefined;
398
+ }
477
399
 
478
- return node;
400
+ return undefined;
479
401
  }
480
402
 
481
- interface MappedCharacter
482
- {
483
- readonly char: string;
484
- readonly sourceLine?: number;
485
- }
403
+ function findNestedName(node: WTS.Node): string | undefined {
404
+ if (NAME_TYPES.has(node.type)) {
405
+ return node.text;
406
+ }
486
407
 
487
- function renderNodeLines(node: WTS.Node, source: string, extension: string): ProjectedLine[]
488
- {
489
- const replacements: Replacement[] = [];
408
+ for (const child of node.namedChildren) {
409
+ const name = findNestedName(child);
490
410
 
491
- if (DATA_EXTENSIONS.has(extension))
492
- {
493
- collectDataReplacements(node, extension, replacements);
494
- }
495
- else
496
- {
497
- collectReplacements(node, extension, replacements);
411
+ if (name) {
412
+ return name;
498
413
  }
414
+ }
499
415
 
500
- const start = lineStartAt(source, node.startIndex);
501
- const end = lineEndAt(source, node.endIndex);
502
- const relevant = replacements
503
- .filter((replacement) => replacement.start >= start && replacement.end <= end)
504
- .sort((a, b) => b.start - a.start);
505
- const mapped = mapSourceRange(source, start, end);
506
-
507
- for (const replacement of relevant)
508
- {
509
- const relativeStart = replacement.start - start;
510
- const relativeEnd = replacement.end - start;
511
- const inserted = mapReplacement(replacement);
512
- mapped.splice(relativeStart, relativeEnd - relativeStart, ...inserted);
513
- }
416
+ return undefined;
417
+ }
514
418
 
515
- while (mapped.length > 0 && /\s/u.test(mapped.at(-1)!.char))
516
- {
517
- mapped.pop();
518
- }
419
+ function unwrapDeclaration(node: WTS.Node): WTS.Node {
420
+ const parent = node.parent;
519
421
 
520
- const lines: MappedCharacter[][] = [[]];
521
-
522
- for (const item of mapped)
523
- {
524
- if (item.char === "\n")
525
- {
526
- lines.push([]);
527
- }
528
- else
529
- {
530
- lines.at(-1)!.push(item);
531
- }
532
- }
422
+ if (
423
+ parent &&
424
+ (parent.type === "export_statement" ||
425
+ parent.type === "decorated_definition" ||
426
+ parent.type === "template_declaration")
427
+ ) {
428
+ return parent;
429
+ }
533
430
 
534
- return lines.map((line) =>
535
- {
536
- const sourceLines = [
537
- ...new Set(line.flatMap((item) => item.sourceLine === undefined ? [] : [item.sourceLine])),
538
- ];
539
- return {
540
- content: line.map((item) => item.char).join(""),
541
- ...(sourceLines.length === 1 ? { sourceLine: sourceLines[0] } : {}),
542
- };
543
- });
431
+ return node;
432
+ }
433
+
434
+ interface MappedCharacter {
435
+ readonly char: string;
436
+ readonly sourceLine?: number;
437
+ }
438
+
439
+ function renderNodeLines(node: WTS.Node, source: string, extension: string): ProjectedLine[] {
440
+ const replacements: Replacement[] = [];
441
+
442
+ if (DATA_EXTENSIONS.has(extension)) {
443
+ collectDataReplacements(node, extension, replacements);
444
+ } else {
445
+ collectReplacements(node, extension, replacements);
446
+ }
447
+
448
+ const start = lineStartAt(source, node.startIndex);
449
+ const end = lineEndAt(source, node.endIndex);
450
+ const relevant = replacements
451
+ .filter((replacement) => replacement.start >= start && replacement.end <= end)
452
+ .sort((a, b) => b.start - a.start);
453
+ const mapped = mapSourceRange(source, start, end);
454
+
455
+ for (const replacement of relevant) {
456
+ const relativeStart = replacement.start - start;
457
+ const relativeEnd = replacement.end - start;
458
+ const inserted = mapReplacement(replacement);
459
+ mapped.splice(relativeStart, relativeEnd - relativeStart, ...inserted);
460
+ }
461
+
462
+ while (mapped.length > 0 && /\s/u.test(requiredValue(mapped.at(-1)).char)) {
463
+ mapped.pop();
464
+ }
465
+
466
+ const lines: MappedCharacter[][] = [[]];
467
+
468
+ for (const item of mapped) {
469
+ if (item.char === "\n") {
470
+ lines.push([]);
471
+ } else {
472
+ requiredValue(lines.at(-1)).push(item);
473
+ }
474
+ }
475
+
476
+ return lines.map((line) => {
477
+ const sourceLines = [
478
+ ...new Set(line.flatMap((item) => (item.sourceLine === undefined ? [] : [item.sourceLine]))),
479
+ ];
480
+ return {
481
+ content: line.map((item) => item.char).join(""),
482
+ ...(sourceLines.length === 1 && { sourceLine: sourceLines[0] }),
483
+ };
484
+ });
544
485
  }
545
486
 
546
- function lineStartAt(source: string, index: number): number
547
- {
548
- const newline = source.lastIndexOf("\n", Math.max(0, index - 1));
549
- return newline + 1;
487
+ function lineStartAt(source: string, index: number): number {
488
+ const newline = source.lastIndexOf("\n", Math.max(0, index - 1));
489
+ return newline + 1;
550
490
  }
551
491
 
552
- function lineEndAt(source: string, index: number): number
553
- {
554
- const newline = source.indexOf("\n", index);
555
- return newline === -1 ? source.length : newline;
492
+ function lineEndAt(source: string, index: number): number {
493
+ const newline = source.indexOf("\n", index);
494
+ return newline === -1 ? source.length : newline;
556
495
  }
557
496
 
558
- function mapSourceRange(source: string, start: number, end: number): MappedCharacter[]
559
- {
560
- let sourceLine = source.slice(0, start).split("\n").length;
561
- const mapped: MappedCharacter[] = [];
497
+ function mapSourceRange(source: string, start: number, end: number): MappedCharacter[] {
498
+ let sourceLine = source.slice(0, start).split("\n").length;
499
+ const mapped: MappedCharacter[] = [];
562
500
 
563
- for (const char of source.slice(start, end))
564
- {
565
- mapped.push({ char, sourceLine });
501
+ for (const char of source.slice(start, end)) {
502
+ mapped.push({ char, sourceLine });
566
503
 
567
- if (char === "\n")
568
- {
569
- sourceLine += 1;
570
- }
504
+ if (char === "\n") {
505
+ sourceLine += 1;
571
506
  }
507
+ }
572
508
 
573
- return mapped;
509
+ return mapped;
574
510
  }
575
511
 
576
- function mapReplacement(replacement: Replacement): MappedCharacter[]
577
- {
578
- const lineSources = replacement.lineSourceLines ?? [];
579
- let lineIndex = 0;
512
+ function mapReplacement(replacement: Replacement): MappedCharacter[] {
513
+ const lineSources = replacement.lineSourceLines ?? [];
514
+ let lineIndex = 0;
580
515
 
581
- const mapped: MappedCharacter[] = [];
516
+ const mapped: MappedCharacter[] = [];
582
517
 
583
- for (let index = 0; index < replacement.text.length; index += 1)
584
- {
585
- const char = replacement.text[index]!;
586
- const sourceLine = lineSources[lineIndex];
587
- mapped.push(sourceLine === undefined ? { char } : { char, sourceLine });
518
+ for (let index = 0; index < replacement.text.length; index += 1) {
519
+ const char = requiredValue(replacement.text[index]);
520
+ const sourceLine = lineSources[lineIndex];
521
+ mapped.push(sourceLine === undefined ? { char } : { char, sourceLine });
588
522
 
589
- if (char === "\n")
590
- {
591
- lineIndex += 1;
592
- }
523
+ if (char === "\n") {
524
+ lineIndex += 1;
593
525
  }
526
+ }
594
527
 
595
- return mapped;
528
+ return mapped;
596
529
  }
597
530
 
598
- function collectDataReplacements(node: WTS.Node, extension: string, replacements: Replacement[]): void
599
- {
600
- for (const child of node.namedChildren)
601
- {
602
- if (isDataScalar(child, extension))
603
- {
604
- if (!isDataKey(child))
605
- {
606
- replacements.push({
607
- start: child.startIndex,
608
- end: child.endIndex,
609
- text: "…",
610
- lineSourceLines: [child.startPosition.row + 1],
611
- });
612
- }
613
-
614
- continue;
615
- }
616
-
617
- collectDataReplacements(child, extension, replacements);
531
+ function collectDataReplacements(
532
+ node: WTS.Node,
533
+ extension: string,
534
+ replacements: Replacement[],
535
+ ): void {
536
+ for (const child of node.namedChildren) {
537
+ if (isDataScalar(child, extension)) {
538
+ if (!isDataKey(child)) {
539
+ replacements.push({
540
+ start: child.startIndex,
541
+ end: child.endIndex,
542
+ text: "…",
543
+ lineSourceLines: [child.startPosition.row + 1],
544
+ });
545
+ }
546
+
547
+ continue;
618
548
  }
549
+
550
+ collectDataReplacements(child, extension, replacements);
551
+ }
619
552
  }
620
553
 
621
- function isDataScalar(node: WTS.Node, extension: string): boolean
622
- {
623
- const scalarTypes = extension === ".json" || extension === ".jsonc"
624
- ? ["string", "number", "true", "false", "null"]
625
- : extension === ".yaml" || extension === ".yml"
626
- ? ["string_scalar", "integer_scalar", "float_scalar", "boolean_scalar", "null_scalar", "block_scalar"]
554
+ function isDataScalar(node: WTS.Node, extension: string): boolean {
555
+ const scalarTypes =
556
+ extension === ".json" || extension === ".jsonc"
557
+ ? ["string", "number", "true", "false", "null"]
558
+ : extension === ".yaml" || extension === ".yml"
559
+ ? [
560
+ "string_scalar",
561
+ "integer_scalar",
562
+ "float_scalar",
563
+ "boolean_scalar",
564
+ "null_scalar",
565
+ "block_scalar",
566
+ ]
627
567
  : [
628
568
  "string",
629
569
  "integer",
@@ -634,180 +574,175 @@ function isDataScalar(node: WTS.Node, extension: string): boolean
634
574
  "local_date_time",
635
575
  "local_date",
636
576
  "local_time",
637
- ];
577
+ ];
638
578
 
639
- return scalarTypes.includes(node.type);
579
+ return scalarTypes.includes(node.type);
640
580
  }
641
581
 
642
- function isDataKey(node: WTS.Node): boolean
643
- {
644
- let ancestor = node.parent;
582
+ function isDataKey(node: WTS.Node): boolean {
583
+ let ancestor = node.parent;
645
584
 
646
- while (ancestor && !ancestor.type.endsWith("pair") && ancestor.type !== "pair" && ancestor.type !== "table")
647
- {
648
- ancestor = ancestor.parent;
649
- }
585
+ while (
586
+ ancestor &&
587
+ !ancestor.type.endsWith("pair") &&
588
+ ancestor.type !== "pair" &&
589
+ ancestor.type !== "table"
590
+ ) {
591
+ ancestor = ancestor.parent;
592
+ }
650
593
 
651
- const key = ancestor?.namedChildren[0];
652
- return key !== undefined && key.startIndex <= node.startIndex && key.endIndex >= node.endIndex;
594
+ const key = ancestor?.namedChildren[0];
595
+ return key !== undefined && key.startIndex <= node.startIndex && key.endIndex >= node.endIndex;
653
596
  }
654
597
 
655
598
  function collectReplacements(
656
- node: WTS.Node,
657
- extension: string,
658
- replacements: Replacement[],
659
- topLevel = false,
660
- ): void
661
- {
662
- if (topLevel && !isTopLevelInterfaceNode(node))
663
- {
664
- replacements.push({
665
- start: node.startIndex,
666
- end: node.endIndex,
667
- text: "…",
668
- lineSourceLines: [node.startPosition.row + 1],
669
- });
670
- return;
671
- }
672
-
673
- if (FUNCTION_TYPES.has(node.type))
674
- {
675
- const body = findBody(node);
676
-
677
- if (body)
678
- {
679
- const placeholder = renderBodyPlaceholder(body, extension);
680
- replacements.push({
681
- start: body.startIndex,
682
- end: body.endIndex,
683
- text: placeholder.text,
684
- lineSourceLines: placeholder.lineSourceLines,
685
- });
686
- return;
687
- }
688
- }
689
-
690
- if (INITIALIZER_TYPES.has(node.type))
691
- {
692
- const value = node.childForFieldName("value");
693
-
694
- if (value && !FUNCTION_TYPES.has(value.type))
695
- {
696
- replacements.push({
697
- start: value.startIndex,
698
- end: value.endIndex,
699
- text: "…",
700
- lineSourceLines: [value.startPosition.row + 1],
701
- });
702
- return;
703
- }
704
- }
705
-
706
- for (const child of node.namedChildren)
707
- {
708
- collectReplacements(child, extension, replacements, ROOT_TYPES.has(node.type));
709
- }
599
+ node: WTS.Node,
600
+ extension: string,
601
+ replacements: Replacement[],
602
+ topLevel = false,
603
+ ): void {
604
+ if (topLevel && !isTopLevelInterfaceNode(node)) {
605
+ replacements.push({
606
+ start: node.startIndex,
607
+ end: node.endIndex,
608
+ text: "…",
609
+ lineSourceLines: [node.startPosition.row + 1],
610
+ });
611
+ return;
612
+ }
613
+
614
+ if (FUNCTION_TYPES.has(node.type)) {
615
+ const body = findBody(node);
616
+
617
+ if (body) {
618
+ const placeholder = renderBodyPlaceholder(body, extension);
619
+ replacements.push({
620
+ start: body.startIndex,
621
+ end: body.endIndex,
622
+ text: placeholder.text,
623
+ lineSourceLines: placeholder.lineSourceLines,
624
+ });
625
+ return;
626
+ }
627
+ }
628
+
629
+ if (INITIALIZER_TYPES.has(node.type)) {
630
+ const value = node.childForFieldName("value");
631
+
632
+ if (value && !FUNCTION_TYPES.has(value.type)) {
633
+ replacements.push({
634
+ start: value.startIndex,
635
+ end: value.endIndex,
636
+ text: "…",
637
+ lineSourceLines: [value.startPosition.row + 1],
638
+ });
639
+ return;
640
+ }
641
+ }
642
+
643
+ for (const child of node.namedChildren) {
644
+ collectReplacements(child, extension, replacements, ROOT_TYPES.has(node.type));
645
+ }
710
646
  }
711
647
 
712
- function isTopLevelInterfaceNode(node: WTS.Node): boolean
713
- {
714
- return DECLARATION_TYPES.has(node.type)
715
- || IMPORT_TYPES.has(node.type)
716
- || node.type === "comment"
717
- || node.type.startsWith("preproc");
648
+ function isTopLevelInterfaceNode(node: WTS.Node): boolean {
649
+ return (
650
+ DECLARATION_TYPES.has(node.type) ||
651
+ IMPORT_TYPES.has(node.type) ||
652
+ node.type === "comment" ||
653
+ node.type.startsWith("preproc")
654
+ );
718
655
  }
719
656
 
720
- function findBody(node: WTS.Node): WTS.Node | undefined
721
- {
722
- const fieldBody = node.childForFieldName("body");
657
+ function findBody(node: WTS.Node): WTS.Node | undefined {
658
+ const fieldBody = node.childForFieldName("body");
723
659
 
724
- if (fieldBody)
725
- {
726
- return fieldBody;
727
- }
660
+ if (fieldBody) {
661
+ return fieldBody;
662
+ }
728
663
 
729
- return node.namedChildren.find((child) =>
730
- child.type === "block" || child.type === "compound_statement" || child.type === "statement_block"
731
- );
664
+ return node.namedChildren.find(
665
+ (child) =>
666
+ child.type === "block" ||
667
+ child.type === "compound_statement" ||
668
+ child.type === "statement_block",
669
+ );
732
670
  }
733
671
 
734
- interface BodyPlaceholder
735
- {
736
- readonly text: string;
737
- readonly lineSourceLines: readonly (number | undefined)[];
672
+ interface BodyPlaceholder {
673
+ readonly text: string;
674
+ readonly lineSourceLines: readonly (number | undefined)[];
738
675
  }
739
676
 
740
- function renderBodyPlaceholder(body: WTS.Node, extension: string): BodyPlaceholder
741
- {
742
- const startLine = body.startPosition.row + 1;
743
- const endLine = body.endPosition.row + 1;
677
+ function renderBodyPlaceholder(body: WTS.Node, extension: string): BodyPlaceholder {
678
+ const startLine = body.startPosition.row + 1;
679
+ const endLine = body.endPosition.row + 1;
744
680
 
745
- if (extension === ".py")
746
- {
747
- return { text: "...", lineSourceLines: [startLine] };
748
- }
681
+ if (extension === ".py") {
682
+ return { text: "...", lineSourceLines: [startLine] };
683
+ }
749
684
 
750
- const bodyLines = body.text.split("\n");
751
- const firstLine = bodyLines[0] ?? "";
752
- const lastLine = bodyLines.at(-1) ?? "";
753
- const openIndex = firstLine.indexOf("{");
754
- const closeIndex = lastLine.lastIndexOf("}");
685
+ const bodyLines = body.text.split("\n");
686
+ const firstLine = bodyLines[0] ?? "";
687
+ const lastLine = bodyLines.at(-1) ?? "";
688
+ const openIndex = firstLine.indexOf("{");
689
+ const closeIndex = lastLine.lastIndexOf("}");
755
690
 
756
- if (openIndex === -1 || closeIndex === -1)
757
- {
758
- return { text: "…", lineSourceLines: [startLine] };
759
- }
691
+ if (openIndex === -1 || closeIndex === -1) {
692
+ return { text: "…", lineSourceLines: [startLine] };
693
+ }
760
694
 
761
- if (bodyLines.length === 1)
762
- {
763
- const inner = firstLine.slice(openIndex + 1, closeIndex);
695
+ if (bodyLines.length === 1) {
696
+ const inner = firstLine.slice(openIndex + 1, closeIndex);
764
697
 
765
- if (inner.trim() === "")
766
- {
767
- return { text: body.text, lineSourceLines: [startLine] };
768
- }
769
-
770
- return {
771
- text: firstLine.slice(0, openIndex + 1) + maskSegment(inner) + firstLine.slice(closeIndex),
772
- lineSourceLines: [startLine],
773
- };
774
- }
775
-
776
- const afterOpen = firstLine.slice(openIndex + 1);
777
- const beforeClose = lastLine.slice(0, closeIndex);
778
- const interiorHasContent = bodyLines.slice(1, -1).some((line) => line.trim() !== "");
779
- const firstHasContent = afterOpen.trim() !== "";
780
- const lastHasContent = beforeClose.trim() !== "";
781
-
782
- if (!interiorHasContent && !firstHasContent && !lastHasContent)
783
- {
784
- return {
785
- text: body.text,
786
- lineSourceLines: bodyLines.map((_, index) => startLine + index),
787
- };
698
+ if (inner.trim() === "") {
699
+ return { text: body.text, lineSourceLines: [startLine] };
788
700
  }
789
701
 
790
- const output: string[] = [];
791
- const lineSourceLines: (number | undefined)[] = [];
792
- output.push(firstHasContent ? firstLine.slice(0, openIndex + 1) + maskSegment(afterOpen) : firstLine);
793
- lineSourceLines.push(startLine);
794
-
795
- if (!firstHasContent && interiorHasContent)
796
- {
797
- const indentation = bodyLines.slice(1, -1).find((line) => line.trim() !== "")?.match(/^\s*/u)?.[0] ?? "";
798
- output.push(`${indentation}…`);
799
- lineSourceLines.push(undefined);
800
- }
702
+ return {
703
+ text: firstLine.slice(0, openIndex + 1) + maskSegment(inner) + firstLine.slice(closeIndex),
704
+ lineSourceLines: [startLine],
705
+ };
706
+ }
801
707
 
802
- output.push(lastHasContent ? maskSegment(beforeClose) + lastLine.slice(closeIndex) : lastLine);
803
- lineSourceLines.push(endLine);
708
+ const afterOpen = firstLine.slice(openIndex + 1);
709
+ const beforeClose = lastLine.slice(0, closeIndex);
710
+ const isInteriorHasContent = bodyLines.slice(1, -1).some((line) => line.trim() !== "");
711
+ const isFirstHasContent = afterOpen.trim() !== "";
712
+ const isLastHasContent = beforeClose.trim() !== "";
804
713
 
805
- return { text: output.join("\n"), lineSourceLines };
714
+ if (!isInteriorHasContent && !isFirstHasContent && !isLastHasContent) {
715
+ return {
716
+ text: body.text,
717
+ lineSourceLines: bodyLines.map((_, index) => startLine + index),
718
+ };
719
+ }
720
+
721
+ const output: string[] = [];
722
+ const lineSourceLines: (number | undefined)[] = [];
723
+ output.push(
724
+ isFirstHasContent ? firstLine.slice(0, openIndex + 1) + maskSegment(afterOpen) : firstLine,
725
+ );
726
+ lineSourceLines.push(startLine);
727
+
728
+ if (!isFirstHasContent && isInteriorHasContent) {
729
+ const indentation =
730
+ bodyLines
731
+ .slice(1, -1)
732
+ .find((line) => line.trim() !== "")
733
+ ?.match(/^\s*/u)?.[0] ?? "";
734
+ output.push(`${indentation}…`);
735
+ lineSourceLines.push(undefined);
736
+ }
737
+
738
+ output.push(isLastHasContent ? maskSegment(beforeClose) + lastLine.slice(closeIndex) : lastLine);
739
+ lineSourceLines.push(endLine);
740
+
741
+ return { text: output.join("\n"), lineSourceLines };
806
742
  }
807
743
 
808
- function maskSegment(segment: string): string
809
- {
810
- const leading = /^\s*/u.exec(segment)?.[0] ?? "";
811
- const trailing = /\s*$/u.exec(segment)?.[0] ?? "";
812
- return `${leading}…${trailing}`;
744
+ function maskSegment(segment: string): string {
745
+ const leading = /^\s*/u.exec(segment)?.[0] ?? "";
746
+ const trailing = /\s*$/u.exec(segment)?.[0] ?? "";
747
+ return `${leading}…${trailing}`;
813
748
  }