pi-agent-ide 0.2.2 → 0.4.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 (403) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +13 -8
  3. package/dist/chunk-3SE372WC.js +3 -0
  4. package/dist/chunk-5MSNYFDE.js +1 -0
  5. package/dist/chunk-5VSE5X5R.js +2 -0
  6. package/dist/chunk-6DZA4CLO.js +4 -0
  7. package/dist/chunk-6EYWFBNG.js +0 -0
  8. package/dist/{chunk-ORAPGW7W.js → chunk-72EEL2DW.js} +1 -1
  9. package/dist/chunk-7JYQMAEL.js +14 -0
  10. package/dist/{chunk-T2RPMEM2.js → chunk-7UGNGK7Y.js} +1 -1
  11. package/dist/{chunk-STUZZM5B.js → chunk-AADJ2KIB.js} +1 -1
  12. package/dist/{chunk-XF5PVZOS.js → chunk-B5KB2I7J.js} +1 -1
  13. package/dist/chunk-DQF5QMJ2.js +1 -0
  14. package/dist/chunk-EJ5OACQM.js +1 -0
  15. package/dist/chunk-GFW5QPQV.js +2 -0
  16. package/dist/{chunk-LQYZG62K.js → chunk-GUTQ3PWL.js} +1 -1
  17. package/dist/chunk-HGPUI7F3.js +1 -0
  18. package/dist/{chunk-OBWZ5RYN.js → chunk-HKMBQLEK.js} +1 -1
  19. package/dist/chunk-ITSNK5YG.js +7 -0
  20. package/dist/chunk-J34VKQGJ.js +1 -0
  21. package/dist/chunk-KAB3AYA2.js +1 -0
  22. package/dist/{chunk-76WHES5H.js → chunk-M5L42DWE.js} +5 -5
  23. package/dist/chunk-M5MJP7Z2.js +1 -0
  24. package/dist/chunk-NMFQGKPE.js +2 -0
  25. package/dist/chunk-NTYXZ3EL.js +3 -0
  26. package/dist/{chunk-P6T3Q7LB.js → chunk-QDST6VIU.js} +1 -1
  27. package/dist/chunk-ROXXK6TW.js +0 -0
  28. package/dist/{chunk-WNMGUALD.js → chunk-TI5GMJ7Q.js} +1 -1
  29. package/dist/{chunk-4ZTEPMJO.js → chunk-TPIHQYK2.js} +1 -1
  30. package/dist/chunk-XSTHESNR.js +25 -0
  31. package/dist/{chunk-THSCUT2L.js → chunk-Y7ZMR4LT.js} +1 -1
  32. package/dist/chunk-YHADTHQM.js +1 -0
  33. package/dist/{chunk-KZBAJFCV.js → chunk-Z3VC3S2T.js} +1 -1
  34. package/dist/{chunk-ZXN3TWWW.js → chunk-ZM4L5AGN.js} +1 -1
  35. package/dist/{chunk-E2RESHYR.js → chunk-ZTYWHL2F.js} +1 -1
  36. package/dist/entry-0.js +1 -1
  37. package/dist/entry-1.js +1 -1
  38. package/dist/entry-10.js +1 -1
  39. package/dist/entry-12.js +1 -1
  40. package/dist/entry-13.js +1 -1
  41. package/dist/entry-14.js +1 -1
  42. package/dist/entry-2.js +1 -1
  43. package/dist/entry-21.js +1 -1
  44. package/dist/entry-24.js +1 -1
  45. package/dist/entry-25.js +1 -1
  46. package/dist/entry-26.js +10 -5
  47. package/dist/entry-28.js +1 -1
  48. package/dist/entry-29.js +1 -1
  49. package/dist/entry-31.js +3 -3
  50. package/dist/entry-32.js +6 -5
  51. package/dist/entry-36.js +1 -1
  52. package/dist/entry-37.js +1 -1
  53. package/dist/entry-38.js +1 -1
  54. package/dist/entry-39.js +1 -1
  55. package/dist/entry-4.js +1 -1
  56. package/dist/entry-40.js +12 -8
  57. package/dist/entry-42.js +1 -1
  58. package/dist/entry-43.js +1 -1
  59. package/dist/entry-44.js +1 -1
  60. package/dist/entry-45.js +4 -4
  61. package/dist/entry-46.js +10 -10
  62. package/dist/entry-47.js +1 -1
  63. package/dist/entry-48.js +1 -1
  64. package/dist/entry-49.js +1 -1
  65. package/dist/entry-50.js +1 -1
  66. package/dist/entry-51.js +1 -1
  67. package/dist/entry-52.js +1 -1
  68. package/dist/entry-53.js +1 -1
  69. package/dist/entry-54.js +1 -0
  70. package/dist/entry-55.js +0 -1
  71. package/dist/entry-56.js +1 -0
  72. package/dist/entry-57.js +0 -1
  73. package/dist/entry-58.js +1 -1
  74. package/dist/entry-59.js +1 -1
  75. package/dist/entry-60.js +1 -1
  76. package/dist/entry-61.js +1 -1
  77. package/dist/entry-62.js +1 -1
  78. package/dist/entry-63.js +1 -0
  79. package/dist/entry-64.js +0 -1
  80. package/dist/entry-65.js +1 -0
  81. package/dist/entry-66.js +0 -1
  82. package/dist/entry-67.js +1 -1
  83. package/dist/entry-68.js +1 -1
  84. package/dist/entry-69.js +1 -59
  85. package/dist/entry-70.js +123 -4
  86. package/dist/entry-71.js +30 -1
  87. package/dist/entry-72.js +2 -29
  88. package/dist/entry-73.js +1 -2
  89. package/dist/entry-74.js +1 -1
  90. package/dist/entry-75.js +1 -1
  91. package/dist/entry-76.js +3 -1
  92. package/dist/entry-77.js +1 -3
  93. package/dist/entry-78.js +1 -1
  94. package/dist/entry-79.js +1 -1
  95. package/dist/pi-agent-ide.js +3 -2
  96. package/docs/configuration.md +32 -11
  97. package/docs/tools.md +17 -0
  98. package/node_modules/pi-agent-doctor/package.json +1 -1
  99. package/node_modules/pi-agent-filesystem/package.json +6 -6
  100. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  101. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  102. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  103. package/node_modules/pi-agent-ide-ast/package.json +9 -9
  104. package/node_modules/pi-agent-ide-ast/src/extension.ts +4 -3
  105. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +68 -45
  106. package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +8 -1
  107. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +83 -5
  108. package/node_modules/pi-agent-ide-changes/index.ts +21 -5
  109. package/node_modules/pi-agent-ide-changes/package.json +6 -6
  110. package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
  111. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +4 -2
  112. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  113. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +26 -8
  114. package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -1
  115. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  116. package/node_modules/pi-agent-ide-lint/index.ts +46 -17
  117. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  118. package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -1
  119. package/node_modules/pi-agent-ide-lsp/index.ts +126 -8
  120. package/node_modules/pi-agent-ide-lsp/package.json +9 -8
  121. package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
  122. package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +18 -3
  123. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +4 -0
  124. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
  125. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
  126. package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
  127. package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
  128. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
  129. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
  130. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
  131. package/node_modules/pi-agent-image/package.json +2 -2
  132. package/node_modules/pi-agent-invariant/package.json +1 -1
  133. package/node_modules/pi-agent-pdf/package.json +2 -2
  134. package/node_modules/pi-agent-read/package.json +6 -6
  135. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  136. package/node_modules/pi-agent-read/src/api/read-parameters.ts +29 -0
  137. package/node_modules/pi-agent-read/src/api/tools/read.ts +73 -1
  138. package/node_modules/pi-agent-read/src/core/read-core.ts +26 -2
  139. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
  140. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
  141. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +64 -14
  142. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
  143. package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
  144. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +73 -44
  145. package/node_modules/pi-agent-resource/package.json +1 -1
  146. package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
  147. package/node_modules/pi-agent-resource/src/resource.ts +2 -0
  148. package/node_modules/pi-agent-search/package.json +3 -3
  149. package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  150. package/node_modules/pi-agent-search/src/api/search-parameters.ts +25 -0
  151. package/node_modules/pi-agent-search/src/api/search.ts +55 -1
  152. package/node_modules/pi-agent-search/src/core/extension.ts +2 -23
  153. package/node_modules/pi-agent-search/src/core/search-core.ts +28 -3
  154. package/node_modules/pi-agent-search-text/index.ts +44 -4
  155. package/node_modules/pi-agent-search-text/package.json +6 -6
  156. package/node_modules/pi-agent-search-text/src/search-session.ts +65 -25
  157. package/node_modules/pi-agent-text/package.json +2 -2
  158. package/node_modules/pi-agent-text/src/text-document.ts +5 -0
  159. package/node_modules/pi-agent-text/src/text-target.ts +4 -0
  160. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  161. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  162. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  163. package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
  164. package/node_modules/pi-agent-text-editor/index.ts +1 -3
  165. package/node_modules/pi-agent-text-editor/package.json +34 -24
  166. package/node_modules/pi-agent-text-editor/runtime/entry-69.js +0 -1
  167. package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
  168. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
  169. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
  170. package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
  171. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
  172. package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +3 -0
  173. package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
  174. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
  175. package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
  176. package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
  177. package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
  178. package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
  179. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +216 -0
  180. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
  181. package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
  182. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
  183. package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +133 -0
  184. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
  185. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
  186. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
  187. package/node_modules/pi-agent-text-editor/src/core/extension.ts +6 -0
  188. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
  189. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +153 -0
  190. package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
  191. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +1 -0
  192. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +6 -1
  193. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
  194. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
  195. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +17 -0
  196. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +212 -51
  197. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +273 -11
  198. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
  199. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -1
  200. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
  201. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
  202. package/node_modules/pi-agent-text-editor-renderer/index.ts +88 -1
  203. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  204. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +42 -25
  205. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +20 -12
  206. package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
  207. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  208. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  209. package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +1 -0
  210. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  211. package/node_modules/pi-agent-web/package.json +7 -7
  212. package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
  213. package/node_modules/pi-agent-web/src/browser-loader.ts +1 -0
  214. package/node_modules/pi-agent-web-html/package.json +3 -3
  215. package/node_modules/pi-agent-web-image/package.json +4 -4
  216. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  217. package/node_modules/pi-agent-web-text/package.json +4 -4
  218. package/package.json +41 -38
  219. package/src/api/plugin-protocol.ts +10 -2
  220. package/src/api/tool-config.ts +73 -2
  221. package/src/code-view/diagnostic-view.ts +22 -3
  222. package/src/composite/builtin-extensions.ts +10 -15
  223. package/src/composite/extensions-config.ts +59 -0
  224. package/src/composite/feature-flags.ts +32 -0
  225. package/src/composite/module-labels.ts +59 -0
  226. package/src/composite/module-settings-store.ts +60 -0
  227. package/src/composite/module-settings.ts +162 -0
  228. package/src/composite/preferences.ts +26 -0
  229. package/src/composite/selection.ts +4 -4
  230. package/src/composite/settings-panel.ts +103 -0
  231. package/src/core/diagnostic-delivery.ts +29 -0
  232. package/src/core/diagnostic-entry.ts +51 -3
  233. package/src/core/diagnostic-store.ts +56 -5
  234. package/src/core/extension.ts +34 -33
  235. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -6
  236. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  237. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  238. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  239. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  240. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  241. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +2 -0
  242. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  243. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  244. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  245. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +2 -0
  246. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +1 -0
  247. package/src/extensions/pi-agent-read/package.json +6 -6
  248. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  249. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +29 -0
  250. package/src/extensions/pi-agent-read/src/api/tools/read.ts +73 -1
  251. package/src/extensions/pi-agent-read/src/core/read-core.ts +26 -2
  252. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
  253. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
  254. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +64 -14
  255. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
  256. package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
  257. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +73 -44
  258. package/src/extensions/pi-agent-search/package.json +3 -3
  259. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +44 -4
  260. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
  261. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +65 -25
  262. package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  263. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +25 -0
  264. package/src/extensions/pi-agent-search/src/api/search.ts +55 -1
  265. package/src/extensions/pi-agent-search/src/core/extension.ts +2 -23
  266. package/src/extensions/pi-agent-search/src/core/search-core.ts +28 -3
  267. package/src/extensions/pi-agent-text-editor/index.ts +1 -3
  268. package/src/extensions/pi-agent-text-editor/package.json +34 -24
  269. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  270. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  271. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  272. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
  273. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +88 -1
  274. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  275. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +42 -25
  276. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +20 -12
  277. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
  278. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  279. package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +0 -1
  280. package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +2 -0
  281. package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
  282. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
  283. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
  284. package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
  285. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
  286. package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +3 -0
  287. package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
  288. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
  289. package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
  290. package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
  291. package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
  292. package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
  293. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +216 -0
  294. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
  295. package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
  296. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
  297. package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +133 -0
  298. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
  299. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
  300. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
  301. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +6 -0
  302. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
  303. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +153 -0
  304. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
  305. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +1 -0
  306. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +6 -1
  307. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
  308. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
  309. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +17 -0
  310. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +212 -51
  311. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +273 -11
  312. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
  313. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -1
  314. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
  315. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
  316. package/src/pi-agent-ide.ts +43 -8
  317. package/src/plugins/pi-agent-ide-ast/package.json +9 -9
  318. package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -3
  319. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +68 -45
  320. package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +8 -1
  321. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +83 -5
  322. package/src/plugins/pi-agent-ide-changes/index.ts +21 -5
  323. package/src/plugins/pi-agent-ide-changes/package.json +6 -6
  324. package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
  325. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +4 -2
  326. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +62 -11
  327. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  328. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +26 -8
  329. package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -1
  330. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  331. package/src/plugins/pi-agent-ide-lint/index.ts +46 -17
  332. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  333. package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -1
  334. package/src/plugins/pi-agent-ide-lsp/index.ts +126 -8
  335. package/src/plugins/pi-agent-ide-lsp/package.json +9 -8
  336. package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
  337. package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +18 -3
  338. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +4 -0
  339. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
  340. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
  341. package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
  342. package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
  343. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
  344. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
  345. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
  346. package/src/plugins/pi-agent-ide-terminal/index.ts +34 -0
  347. package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +238 -0
  348. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +461 -0
  349. package/src/plugins/pi-agent-ide-terminal/src/screen-image.ts +127 -0
  350. package/src/plugins/pi-agent-ide-terminal/src/search.ts +159 -0
  351. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +529 -0
  352. package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +56 -0
  353. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +157 -0
  354. package/src/plugins/pi-agent-ide-terminal/src/types.ts +66 -0
  355. package/src/plugins/pi-agent-ide-terminal/src/ui.ts +336 -0
  356. package/src/post-edit/gate.ts +15 -2
  357. package/dist/chunk-4U6KGABH.js +0 -1
  358. package/dist/chunk-6ACQQBUY.js +0 -7
  359. package/dist/chunk-GFWDXTOB.js +0 -4
  360. package/dist/chunk-JASLOB2X.js +0 -1
  361. package/dist/chunk-JJVXUL5U.js +0 -2
  362. package/dist/chunk-KCEOTU5Z.js +0 -3
  363. package/dist/chunk-KVGQG43U.js +0 -1
  364. package/dist/chunk-QJFRAMK7.js +0 -2
  365. package/dist/chunk-RAZOACDD.js +0 -2
  366. package/dist/chunk-RIGRP3FD.js +0 -1
  367. package/dist/chunk-VCCMVQXU.js +0 -1
  368. package/dist/chunk-X6MPU7UO.js +0 -3
  369. package/dist/chunk-YPHXLAQF.js +0 -1
  370. package/dist/entry-80.js +0 -1
  371. package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +0 -14
  372. package/node_modules/pi-agent-text-editor-argument-order/index.ts +0 -26
  373. package/node_modules/pi-agent-text-editor-argument-order/package.json +0 -16
  374. package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
  375. package/node_modules/pi-agent-text-editor-overwrite/index.ts +0 -365
  376. package/node_modules/pi-agent-text-editor-overwrite/package.json +0 -17
  377. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
  378. package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +0 -1
  379. package/node_modules/pi-agent-web-text/runtime/entry-80.js +0 -2
  380. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +0 -2
  381. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +0 -2
  382. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +0 -26
  383. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +0 -16
  384. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-70.js +0 -2
  385. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
  386. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +0 -365
  387. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +0 -17
  388. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
  389. package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +0 -14
  390. /package/dist/{chunk-3H2EU7VQ.js → chunk-4U2GUKNJ.js} +0 -0
  391. /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-70.js +0 -0
  392. /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
  393. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
  394. /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-74.js +0 -0
  395. /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-76.js +0 -0
  396. /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
  397. /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
  398. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
  399. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
  400. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
  401. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
  402. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
  403. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
@@ -1,4 +0,0 @@
1
- import{g as F}from"./chunk-RIGRP3FD.js";import{a as A}from"./chunk-WNMGUALD.js";import{a as $,b as C}from"./chunk-THSCUT2L.js";import"./chunk-S3ZPXWX7.js";import"./chunk-RAZOACDD.js";import{a as I,b as E,c as S,d as k,g as R}from"./chunk-KZBAJFCV.js";import{a as D}from"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";var p=[],m=[],v=[];function w(i,t,e){if(t.some(o=>o.name===e))throw new Error(`[pi-agent-ide] ${i} "${e}" is already registered. Use a unique name.`)}d(w,"assertUniqueName");function j(i){let t=new Set;for(let e of i){let o=`${e.kind}:${e.name}`;if(t.has(o))throw new Error(`[pi-agent-ide] ${e.kind} "${e.name}" is registered twice by one plugin.`);switch(t.add(o),e.kind){case"compiler":{w(e.kind,m,e.name);break}case"formatter":{w(e.kind,p,e.name);break}case"linter":{w(e.kind,v,e.name);break}}}for(let e of i)switch(e.kind){case"compiler":{m.push(e);break}case"formatter":{p.push(e);break}case"linter":{v.push(e);break}}}d(j,"registerTools");async function N(i,t){let e=[];for(let o of i)try{await o.detect(t)&&e.push(o)}catch(n){console.error(`[pi-agent-ide] detect failed for "${o.name}":`,n)}return e.sort((o,n)=>n.priority-o.priority),U(e),e}d(N,"filterActive");function U(i){let t=new Map;for(let e of i)for(let o of e.extensions){let n=`${o}@${e.priority}`,c=t.get(n);if(c!==void 0)throw new Error(`[pi-agent-ide] priority conflict: tools "${c}" and "${e.name}" both claim "${o}" at priority ${e.priority}.`);t.set(n,e.name)}}d(U,"assertNoPriorityConflicts");async function _(i){let[t,e]=await Promise.all([N(p,i),N(m.filter(o=>o.syntaxOnly===!0),i)]);return{ctx:i,formatters:t,compilers:e,linters:[]}}d(_,"warmupFormatting");function P(){p.length=0,m.length=0,v.length=0}d(P,"resetRegistry");import{readFile as b}from"node:fs/promises";import g from"node:path";var h=class{constructor(t,e={}){this.sources=t;this.options=e}static{d(this,"DiagnosticStore")}files=new Map;dirty=new Set;sent=new Map;queue=[];running=0;disposed=!1;changeListeners=new Set;onDidChange(t){return this.changeListeners.add(t),()=>this.changeListeners.delete(t)}schedule(t,e,{cwd:o}){this.disposed||this.ensure(t,e,o)}async read(t,{cwd:e}){this.assertActive();let o=g.resolve(e,t),n=await b(o,"utf8");this.assertActive();let c=this.ensure(o,n,e);await Y(Promise.all(c.jobs),this.options.readWaitMs??5e3),this.assertActive();let s=await b(o,"utf8");this.assertActive();let r=this.ensure(o,s,e);return{filePath:o,content:r.content,results:[...r.results.values()]}}async takeNotifications(t){let e=[];for(let o of[...this.dirty]){if(o.cwd!==g.resolve(t)||(this.dirty.delete(o),!await this.isCurrent(o)))continue;let n=[...o.results.values()].filter(a=>a.status!=="pending"&&a.status!=="unavailable"&&a.diagnostics.length>0),c=this.key(o.filePath,o.cwd),s=JSON.stringify(n);if(this.sent.get(c)===s||(this.sent.set(c,s),n.length===0))continue;let r=n.map(a=>{let l=["error","warning","info","hint"].flatMap(f=>{let u=a.diagnostics.filter(y=>y.severity===f).length;return u>0?[`${u} ${f}`]:[]});return`${a.source} ${l.join(", ")}${a.status==="snapshot"?" (snapshot; completion unknown)":a.status==="unversioned"?" (unversioned)":""}`}).join("; ");e.push({filePath:g.relative(t,o.filePath),results:n,text:`${JSON.stringify(g.relative(t,o.filePath))}: ${r}.`})}return e}dispose(){this.disposed=!0,this.changeListeners.clear();for(let t of this.files.values())t.controller.abort();this.files.clear(),this.dirty.clear(),this.sent.clear(),this.pump()}key(t,e){return JSON.stringify([g.resolve(e),g.resolve(e,t)])}ensure(t,e,o){let n=this.key(t,o),c=this.files.get(n);if(c?.content===e)return c;c?.controller.abort(),c&&this.dirty.delete(c);let s={cwd:g.resolve(o),filePath:g.resolve(o,t),content:e,controller:new AbortController,results:new Map,jobs:[],publications:new Map};this.files.set(n,s),this.sources.length===0&&s.results.set("diagnostics",{source:"diagnostics",status:"unavailable",diagnostics:[],reason:"No diagnostic sources registered"}),this.dirty.add(s);for(let r of this.sources){s.results.set(r.id,{source:r.id,status:"pending",diagnostics:[]});let a=new Promise(l=>{this.queue.push(async()=>{try{await this.check(s,r)}finally{l()}})});s.jobs.push(a)}return queueMicrotask(()=>this.pump()),s}pump(){for(;this.running<(this.options.concurrency??4)&&this.queue.length>0;){let t=this.queue.shift();if(!t)break;this.running++,t().finally(()=>{this.running--,this.pump()})}}active(t){return!this.disposed&&!t.controller.signal.aborted}assertActive(){if(this.disposed)throw new Error("Diagnostics session has ended")}async isCurrent(t){if(!this.active(t))return!1;let e=await b(t.filePath,"utf8").catch(()=>{});return this.active(t)&&e===t.content}async publish(t,e,o){let n=(t.publications.get(e)??0)+1;if(t.publications.set(e,n),!await this.isCurrent(t)||t.publications.get(e)!==n)return;let c={...o,source:o.source??e};if(JSON.stringify(t.results.get(e))!==JSON.stringify(c)){t.results.set(e,c),this.dirty.add(t);for(let s of this.changeListeners)s(t.cwd)}}async check(t,e){if(!await this.isCurrent(t))return;let o=new AbortController,n=AbortSignal.any([o.signal,t.controller.signal]);if(n.aborted)return;let c,s;try{let r=new Promise((l,f)=>{s=d(()=>f(n.reason),"onAbort"),n.addEventListener("abort",s,{once:!0}),c=setTimeout(()=>o.abort(new Error("Diagnostic check timed out")),this.options.checkTimeoutMs??3e4)}),a=await Promise.race([e.diagnose(t.filePath,{cwd:t.cwd,content:t.content,signal:n,publish:d(l=>{n.aborted||this.publish(t,e.id,l)},"publish")}),r]);await this.publish(t,e.id,a)}catch(r){await this.publish(t,e.id,{status:"unavailable",diagnostics:[],reason:r instanceof Error?r.message:String(r)})}finally{clearTimeout(c),s&&n.removeEventListener("abort",s)}}};async function Y(i,t){let e;try{await Promise.race([i,new Promise(o=>{e=setTimeout(o,t)})])}finally{clearTimeout(e)}}d(Y,"waitAtMost");function O(){let i=new Map,t=[],e=new h(t),o=Promise.resolve();return{diagnostics:e,registerPlugin(n){if(n.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let c=i.get(n.id);if(c!==void 0)return c;let s=o.then(async()=>{let r=[],a=[],l=!0,f={addTool(u){if(!l)throw new Error(`Plugin ${n.id} setup is already complete`);X(u),r.push(u)},addDiagnosticSource(u){if(!l)throw new Error(`Plugin ${n.id} setup is already complete`);H(u),a.push(u)},readDiagnostics(u,y){return e.read(u,y)}};try{await n.setup(f)}catch(u){throw l=!1,u}l=!1,W(t,a),j(r),t.push(...a)});return i.set(n.id,s),o=s.catch(()=>{}),s.catch(()=>{i.delete(n.id)}),s},async waitForPendingPlugins(){await Promise.all(i.values())}}}d(O,"createIdeCore");function W(i,t){let e=new Set(i.map(o=>o.id));for(let o of t){if(e.has(o.id))throw new Error(`Diagnostic source ${o.id} is already registered`);e.add(o.id)}}d(W,"assertUniqueDiagnosticSources");function X(i){if(!M(i))throw new TypeError("IDE tool must be an object");let t=i.kind,e=t==="compiler"?i.compile:t==="formatter"?i.format:t==="linter"?i.lint:void 0;if(e===void 0||typeof e!="function"||typeof i.detect!="function"||typeof i.name!="string"||i.name.trim().length===0||typeof i.priority!="number"||!Number.isFinite(i.priority)||!Array.isArray(i.extensions)||i.extensions.length===0||i.extensions.some(o=>typeof o!="string"||o.length===0))throw new TypeError("Invalid pi-agent-ide tool contribution")}d(X,"assertIdeTool");function H(i){if(!M(i)||typeof i.id!="string"||i.id.trim().length===0||typeof i.diagnose!="function")throw new TypeError("Invalid pi-agent-ide diagnostic source contribution")}d(H,"assertDiagnosticSource");function M(i){return typeof i=="object"&&i!==null}d(M,"isRecord");import{Text as z}from"@earendil-works/pi-tui";var x="ide-diagnostic-summary";function q(i){return{filePath:i.filePath,sources:i.results.map(t=>{let e={error:0,warning:0,info:0,hint:0};for(let o of t.diagnostics)e[o.severity]++;return{source:t.source,status:t.status,counts:e}})}}d(q,"diagnosticEntryData");function B(i,t,e=!1){return{render(o){let n=i.sources.filter(r=>r.status!=="pending"&&r.status!=="unavailable"&&Object.values(r.counts).some(a=>a>0));if(n.length===0)return[];let c=n.map(r=>`${L(r.counts,t)} ${t.fg("dim",`(${T(r.source)})`)}`+(r.status==="ready"?"":` \xB7 ${t.fg("dim",r.status)}`)).join(" \xB7 "),s=[`${t.fg("accent","Diagnostics")} ${t.fg("toolTitle",T(i.filePath))} \xB7 ${c}`];if(e)for(let r of n)s.push(` ${t.fg("dim",T(r.source))} \xB7 ${L(r.counts,t)} \xB7 ${t.fg("dim",r.status)}`);return new z(s.join(`
2
- `),0,0).render(o)},invalidate(){}}}d(B,"renderDiagnosticEntry");function V(i){i.registerEntryRenderer(x,(t,e,o)=>B(D(t.data),o,e.expanded))}d(V,"registerDiagnosticEntryRenderer");function L(i,t){return["error","warning","info","hint"].filter(e=>i[e]>0).map(e=>{let o=i[e],n=e==="info"||o===1?e:`${e}s`,c=o>0&&(e==="error"||e==="warning")?e:"muted";return t.fg(c,`${o} ${n}`)}).join(", ")}d(L,"renderCounts");function T(i){return i.replace(/[\u0000-\u001f\u007f-\u009f]/g," ")}d(T,"plain");import G from"node:path";async function J(i){if(!G.isAbsolute(i.resourceSource))return{formatting:{status:"unavailable"}};let t;try{let e=await _({cwd:i.cwd}),o=G.extname(i.resourceSource).toLowerCase(),n=d(a=>a.extensions.includes(o)||a.extensions.includes("*"),"matches"),c=e.compilers.find(n);if(c&&(await c.compile({filePath:i.resourceSource},e.ctx)).syntaxErrors.length>0)return{formatting:{status:"skipped-syntax"}};let s=e.formatters.find(n);if(!s)return{formatting:{status:"unavailable"}};t=s.name;let r=await s.format({filePath:i.resourceSource},e.ctx);return r.formatter===null?{formatting:{status:"unavailable"}}:(t=r.formatter??s.name,{formatting:{status:r.ok?r.edits>0?"changed":"unchanged":"failed",formatter:t},...r.ok?{diffStatuses:[{text:`Formatted (${t})`,tone:"success"}]}:{}})}catch{return{formatting:{status:"failed",...t===void 0?{}:{formatter:t}}}}}d(J,"runIdePostEditGate");import K from"node:path";async function Q(i){i.registerFlag("old-tools",{description:"Use the old IDE and text editor tools",type:"boolean",default:!1}),P();let t=O();V(i);let e=i.events.on(k,r=>{if(!R(r))throw new Error("Invalid pi-agent-ide plugin registration request");r.accept(t.registerPlugin(r.plugin))});i.on("session_shutdown",()=>{e(),t.diagnostics.dispose(),P()}),F(i,{id:"pi-agent-ide",handler:d(r=>i.getFlag("pi-agent-ide-no-post-processing")===!0?Promise.resolve({formatting:{status:"disabled"}}):J(r),"handler")}),i.events.emit(S,{protocol:I,apiVersion:3}),await A(i,{protocol:$,apiVersion:C,id:"ide-diagnostics",setup(r){r.onDidEdit(a=>{i.getFlag("pi-agent-ide-no-post-processing")!==!0&&K.isAbsolute(a.resourceSource)&&t.diagnostics.schedule(a.resourceSource,a.after.content,{cwd:a.cwd})})}});let o=Promise.resolve(),n=!1,c=d(()=>n,"isClosed"),s=t.diagnostics.onDidChange(r=>{o=o.then(async()=>{if(n)return;let a=await t.diagnostics.takeNotifications(r);if(!(c()||a.length===0)){i.sendMessage({customType:"ide-diagnostics",display:!1,content:`File diagnostics:
3
- ${a.map(l=>l.text).join(`
4
- `)}`},{triggerTurn:!0,deliverAs:"steer"});for(let l of a)i.appendEntry(x,q(l))}}).catch(a=>{console.error("Diagnostic delivery failed",a)})});i.on("session_shutdown",()=>{n=!0,s()}),await t.waitForPendingPlugins()}d(Q,"registerPiAgentIde");export{Q as default};
@@ -1 +0,0 @@
1
- import{a as i}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as n}from"typebox/value";var t="pi-agent-read",r=9,c=`${t}/core/ready`,s=`${t}/plugin/register`,a=e.Function([],e.Unknown()),p=e.Object({protocol:e.Literal(t),apiVersion:e.Literal(r)}),R=e.Object({protocol:e.Literal(t),apiVersion:e.Literal(r),id:e.String(),setup:a}),l=e.Object({plugin:R,accept:a});function g(o){return n.Check(p,o)}i(g,"isReadCoreReady");function P(o){return n.Check(R,o)}i(P,"isReadPlugin");function y(o){return n.Check(l,o)}i(y,"isReadPluginRegistrationRequest");export{t as a,r as b,c,s as d,g as e,P as f,y as g};
@@ -1,2 +0,0 @@
1
- import{a as H}from"./chunk-LQYZG62K.js";import{m as w}from"./chunk-RAZOACDD.js";import{a as S}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import{createHash as le}from"node:crypto";import{readFile as q}from"node:fs/promises";import h from"node:path";import{spawn as Z}from"node:child_process";import W from"node:path";import{createInterface as ee}from"node:readline";import{existsSync as X}from"node:fs";import Y from"node:os";import F from"node:path";function L(e=process.env.PI_CODING_AGENT_DIR??F.join(Y.homedir(),".pi","agent"),n=process.platform){let t=F.join(e,"bin",n==="win32"?"rg.exe":"rg");return X(t)?t:"rg"}c(L,"resolveRipgrepExecutable");async function A(e,n,t){if(e.query.length===0)throw new Error("Search query must not be empty.");if(/\r|\n/u.test(e.query))throw new Error("Search supports one-line patterns only.");let r=e.limit??100,o=W.resolve(n,re(e.path??".")),s=["--json","--no-config","--no-ignore-parent","--color=never","--with-filename","--line-number",e.caseSensitive===!0?"--case-sensitive":"--ignore-case",...e.wholeWord===!0?["--word-regexp"]:[],...O(e.include).flatMap(i=>["--glob",i]),...O(e.exclude).flatMap(i=>["--glob",`!${i}`]),"--",e.query,o];if(e.regex!==!0)return R(["--fixed-strings",...s],r,t);try{return await R(["--engine","auto",...s],r,t)}catch(i){if(!te(i))throw i;return R(["--engine","default",...s],r,t)}}c(A,"searchText");function R(e,n,t){return new Promise((r,o)=>{let s=Z(L(),e,{stdio:["ignore","pipe","pipe"]}),i=ee({input:s.stdout}),a=[],l="",u=!1,d,p=c(()=>{s.kill()},"abort"),m=c(()=>{t?.removeEventListener("abort",p),i.close()},"cleanup");s.stderr.setEncoding("utf8"),s.stderr.on("data",f=>{l+=f}),i.on("line",f=>{if(!(u||d!==void 0||f.length===0))try{let g=JSON.parse(f);if(g.type!=="match")return;for(let V of ne(g)){if(a.length===n){u=!0,s.kill();return}a.push(V)}}catch(g){d=g,s.kill()}}),s.once("error",f=>{m(),o(f)}),s.once("close",f=>{if(m(),t?.aborted===!0){let g=new Error("Search was aborted.");g.name="AbortError",o(g);return}if(d!==void 0){o(new Error("Unable to parse ripgrep search output.",{cause:d}));return}if(!u&&f!==0&&f!==1){o(new Error(l.trim()||`ripgrep exited with code ${String(f)}.`));return}a.sort(oe),r({matches:a,complete:!u})}),t?.addEventListener("abort",p,{once:!0}),t?.aborted===!0&&p()})}c(R,"runRipgrep");function te(e){return e instanceof Error&&/PCRE2: error matching: match limit exceeded/iu.test(e.message)}c(te,"isPcre2MatchLimitError");function ne(e){let n=e.data.path.text,t=e.data.lines.text;if(n===void 0||t===void 0||!Number.isSafeInteger(e.data.line_number))return[];let r=t.replace(/(?:\r\n|\n)$/u,""),o=Buffer.from(t),s=[];for(let i of e.data.submatches){if(i.start<0||i.end<=i.start||i.end>o.length)continue;let a=o.subarray(0,i.start).toString("utf8").length,l=o.subarray(0,i.end).toString("utf8").length;s.push({source:W.resolve(n),lineNumber:e.data.line_number,startColumn:a,endColumn:l,matchedText:r.slice(a,l),lineText:r})}return s}c(ne,"matchesFromEvent");function O(e){if(e===void 0)return[];let n=[],t=0,r="";for(let o of e){if(o==="{"?t+=1:o==="}"&&(t=Math.max(0,t-1)),t===0&&(o===","||/\s/u.test(o))){r.length>0&&(n.push(r),r="");continue}r+=o}return r.length>0&&n.push(r),n}c(O,"splitGlobList");function re(e){return e.startsWith("@")?e.slice(1):e}c(re,"stripFilePrefix");function oe(e,n){return e.source.localeCompare(n.source)||e.lineNumber-n.lineNumber||e.startColumn-n.startColumn||e.endColumn-n.endColumn}c(oe,"compareMatches");function C(e,n=!1){let t=$(e);if(!M(t))return n?e:B(e);let r=E(new v(e,t).parse(),n);return`^${r.condition}.*?\\K(${r.match})`}c(C,"compileSearchQuery");function D(e){if(M($(e)))return;let n=[...new Set(e.trim().split(/\s+/u).filter(Boolean))];return n.length>1?`(?:${n.map(B).join("|")})`:void 0}c(D,"compileSearchFallbackQuery");function M(e){return e.some(n=>n.quoted===!0||n.type==="and"||n.type==="or"||n.type==="not")}c(M,"containsBooleanSyntax");var v=class{static{c(this,"BooleanQueryParser")}#t;#r;#i=0;constructor(n,t){this.#t=n,this.#r=t}parse(){let n=this.#s(),t=this.#e();if(t.type!=="end"){let r=t.type==="right"?"unexpected ')'.":`unexpected ${ae(t)}.`;throw y(t.offset,r)}return n}#s(){let n=this.#n();for(;this.#e().type==="or";){let t=this.#o(),r=this.#a(`after ${t.value}`);n={kind:"or",left:n,right:this.#c(r)}}return n}#n(){return this.#c(this.#a())}#c(n){let t=n;for(;;){let r=this.#e();if(r.type==="and"||r.type==="not"){this.#o();let o=this.#a(`after ${r.value}`);t={kind:r.type,left:t,right:o};continue}if(r.type==="term"||r.type==="left"){t={kind:"and",left:t,right:this.#a()};continue}return t}}#a(n){let t=this.#e();if(t.type==="term")return this.#o(),{kind:"term",value:t.value,quoted:t.quoted};if(t.type==="left"){if(this.#o(),this.#e().type==="right"||this.#e().type==="end")throw y(this.#e().offset,"expected a term after '('.");let o=this.#s();if(this.#e().type!=="right")throw y(this.#e().offset,"expected ')'.");return this.#o(),o}if(n===void 0&&(t.type==="and"||t.type==="or"||t.type==="not"))throw y(t.offset,`expected a term before ${t.value}.`);let r=n===void 0?"":` ${n}`;throw y(t.offset,`expected a term${r}.`)}#e(){return this.#r[this.#i]??{type:"end",value:"",offset:this.#t.length}}#o(){let n=this.#e();return this.#i+=1,n}};function $(e){let n=[],t=0;for(;t<e.length;){let r=e.charAt(t);if(/\s/u.test(r)){t+=1;continue}if(r==="("&&ie(e,t)){n.push({type:"left",value:r,offset:t}),t+=1;continue}if(r===")"){n.push({type:"right",value:r,offset:t}),t+=1;continue}if(_(e,t)){let i=e.charAt(t+1)==="|"?2:1;n.push({type:"or",value:e.slice(t,t+i),offset:t}),t+=i;continue}if(r==="'"||r==='"'){let i=t,a=r,l="";for(t+=1;t<e.length&&e.charAt(t)!==a;)e.charAt(t)==="\\"&&(e.charAt(t+1)===a||e.charAt(t+1)==="\\")&&(t+=1),l+=e.charAt(t++);if(t>=e.length)throw y(i,`unterminated ${a==="'"?"single":"double"}-quoted term.`);if(t+=1,l.length===0)throw y(i,"quoted terms must not be empty.");n.push({type:"term",value:l,offset:i,quoted:!0});continue}let o=t;for(;t<e.length;){let i=e.charAt(t);if(/\s/u.test(i)||i===")"||_(e,t))break;i==="\\"&&t+1<e.length?t+=2:i==="["||i==="("?t=N(e,t)??t+1:t+=1}let s=e.slice(o,t);n.push({type:se(s),value:s,offset:o})}return n.push({type:"end",value:"",offset:e.length}),n}c($,"tokenize");function _(e,n){return e.charAt(n)==="|"&&(e.charAt(n+1)==="|"||/\s/u.test(e.charAt(n-1))&&/\s/u.test(e.charAt(n+1)))}c(_,"isBooleanPipe");function N(e,n){let t=e.charAt(n)==="["?"]":")",r=n+1;for(;r<e.length;){let o=e.charAt(r);if(o==="\\")r+=2;else{if(o===t)return r+1;if(t===")"&&(o==="("||o==="[")){let s=N(e,r);if(s===void 0)return;r=s}else r+=1}}}c(N,"regexBlockEnd");function ie(e,n){let t=N(e,n);if(t===void 0)return!0;let r=e.slice(n+1,t-1);return r.trim().length===0?!0:M($(r))}c(ie,"isBooleanGroup");function se(e){return e==="AND"?"and":e==="OR"?"or":e==="NOT"?"not":"term"}c(se,"operatorType");function ae(e){return e.value.length>0?JSON.stringify(e.value):"the end of the query"}c(ae,"quoteToken");function y(e,n){return new SyntaxError(`Invalid Boolean search query at column ${String(e+1)}: ${n}`)}c(y,"syntaxError");function E(e,n){if(e.kind==="term"){let o=n&&!e.quoted?e.value:B(e.value);return{condition:`(?=.*(?:${o}))`,match:o}}let t=E(e.left,n),r=E(e.right,n);return e.kind==="or"?{condition:`(?:${t.condition}|${r.condition})`,match:`(?:${t.match}|${r.match})`}:e.kind==="not"?{condition:`${t.condition}(?!${r.condition})`,match:t.match}:{condition:`${t.condition}${r.condition}`,match:`(?:${t.match}|${r.match})`}}c(E,"compileExpression");function B(e){return e.replace(/[\\^$.*+?()[\]{}|]/gu,"\\$&")}c(B,"escapeRegex");function $e(e){let n=C(e.query),t=C(e.query,!0),r=D(e.query),o=[];return t!==n&&o.push({query:t,mode:"regex"}),r!==void 0&&r!==n&&r!==t&&o.push({query:r,mode:"words"}),{...e,query:n,regex:!0,fallbacks:o}}c($e,"createSearchRecipe");async function P(e,n,t){let r=e.query,o=await A(e,n,t),s=[];for(let i of e.fallbacks??[]){if(o.matches.length>0||!o.complete)break;t?.throwIfAborted();try{o=await A({...e,query:i.query,regex:!0},n,t),r=i.query,s.push(i.mode==="regex"?"Search fallback: no literal matches; tried unquoted terms as regex.":"Search fallback: no matches in earlier modes; tried separate words.")}catch(a){if(i.mode!=="regex"||!ce(a)||t?.aborted)throw a;s.push("Search fallback: invalid regex skipped; literal search found no matches.")}}return{...o,query:r,notices:s}}c(P,"runSearchRecipe");function ce(e){return e instanceof Error&&/regex parse error:|PCRE2: error compiling pattern/iu.test(e.message)}c(ce,"isRegexSyntaxError");var ue=/^SEARCH#([A-F0-9]{4,64}):(all|[1-9]\d*):(line|match)$/u,z=4;function We(e,n,t,r){return U(e,n,t,r).slice(0,z)}c(We,"createSearchSessionId");function U(e,n,t,r){let o=t===void 0?fe(n.map(a=>a.source)):h.resolve(t),s=n.map(a=>({match:a,source:h.relative(o,h.resolve(a.source))})).sort((a,l)=>a.source.localeCompare(l.source)||j(a.match,l.match)).map(({match:a,source:l})=>[l,a.lineNumber,a.startColumn,a.endColumn,a.matchedText,a.lineText]),i=K(r??{query:e,regex:!0},o);return le("sha256").update(JSON.stringify([e,o,i,s])).digest("hex").toUpperCase()}c(U,"createSearchSessionIdentity");function de(e,n){if(!/^[A-F0-9]{64}$/u.test(e))throw new Error("Search session identity must be a 64-character uppercase hexadecimal value.");for(let t=z;t<=e.length;t+=1){let r=e.slice(0,t);if(!n.has(r))return r}throw new Error("Could not allocate a unique search session id.")}c(de,"allocateSearchSessionId");function K(e,n){return{query:e.query,path:h.resolve(n,e.path??"."),include:e.include??"",exclude:e.exclude??"",caseSensitive:e.caseSensitive===!0,wholeWord:e.wholeWord===!0,limit:e.limit??100,regex:e.regex===!0,fallbacks:e.fallbacks??[]}}c(K,"normalizeRecipe");var Q=class{constructor(n=U){this.createIdentity=n}static{c(this,"SearchSessionStore")}#t=new Map;#r=new Map;async register(n,t,r,o,s,i={query:n,regex:!0}){let a=t.map(f=>({...f,source:h.resolve(f.source)})).sort(j),l=await J(a,s),u=this.createIdentity(n,a,o,i),p=this.#r.get(u)??de(u,new Set(this.#t.keys())),m={id:p,query:n,matches:a,complete:r,contentBySource:l,recipe:i,cwd:h.resolve(o)};return this.#r.set(u,p),this.#t.set(p,m),m}async observeAfterEdit(n,t){let r=new Set(n.flatMap(s=>{let i=typeof s=="string"?T(s):void 0;return i===void 0?[]:[i.id]})),o=[];for(let s of r){let i=this.#t.get(s);if(i===void 0)continue;let a={sessionId:s,query:i.recipe.originalQuery??i.query,scope:K(i.recipe,i.cwd)};try{let l=await P(i.recipe,i.cwd,t);o.push({...a,matches:l.matches.length,complete:l.complete,notices:l.notices})}catch(l){o.push({...a,error:l instanceof Error?l.message:String(l)})}}return o}anchorResolver(){return{id:"search",description:["`SEARCH#HASH:N:line` selects one result's full line; `SEARCH#HASH:N:match` selects its exact match.","`SEARCH#HASH:all:line` selects each unique containing line; `SEARCH#HASH:all:match` selects every exact match.","Omit `path` when `all` spans files."].join(`
2
- `),renderFull(n){return n},renderCompact(n){let t=T(n);return t===void 0?"selected result":t.selector==="all"?t.mode==="match"?"all matches":"all lines":t.mode==="match"?`match ${String(t.selector)}`:`line ${String(t.selector)}`},tryResolve:c((n,t)=>this.#i(n,t.source,t.signal),"tryResolve")}}resourceResolver(){return{id:"search-targets",tryResolve:c((n,t)=>this.#s(n,t.cwd),"tryResolve")}}async#i(n,t,r){let o=T(n);if(o===void 0)return{kind:"not-handled"};let s=this.#t.get(o.id);if(s===void 0)return b();if(o.selector==="all"&&!s.complete)return x();let i=h.resolve(t),a=s;if(o.selector==="all"){if(s.refreshedComplete?.complete===!0)a=s.refreshedComplete;else if(s.refreshedComplete!==void 0&&(a=await this.#n(s,r),!a.complete))return x()}let l=k(a,o.selector,o.mode),u=l.filter(m=>m.source===i);if(u.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};let d=await I(i,r);if(d===void 0)return b(S(u[0]).lineNumber);if(o.selector==="all"&&d!==a.contentBySource.get(i)){if(a=await this.#n(s,r),!a.complete)return x();l=k(a,o.selector,o.mode),u=l.filter(m=>m.source===i)}if(u.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};if(o.selector!=="all"&&d!==s.contentBySource.get(i))return b(S(u[0]).lineNumber);let p=w(i,d);return{kind:"resolved",anchor:new H(n,i,u.map(m=>G(p,m,o.mode)))}}async#s(n,t){let r=T(n);if(r===void 0)return{kind:"not-handled"};let o=this.#t.get(r.id);if(o===void 0)return b();if(r.selector==="all"&&!o.complete)return x();let s=o;if(r.selector==="all"){if(o.refreshedComplete?.complete===!0)s=o.refreshedComplete;else if(o.refreshedComplete!==void 0&&(s=await this.#n(o),!s.complete))return x();let u=new Set(k(s,r.selector,r.mode).map(d=>d.source));for(let d of u)if(await I(d)!==s.contentBySource.get(d)){if(s=await this.#n(o),!s.complete)return x();break}}let i=k(s,r.selector,r.mode);if(r.selector!=="all"){let u=i[0]?.source;if(u!==void 0&&await I(u)!==s.contentBySource.get(u))return b(i[0]?.lineNumber)}let a=new Map;for(let u of i){let d=a.get(u.source)??[];d.push(G(w(u.source,s.contentBySource.get(u.source)??u.lineText),u,r.mode)),a.set(u.source,d)}let l=[...a].map(([u,d])=>({source:u,ranges:d}));return l.length===0?{kind:"rejected",rejection:{code:"missing",reason:"search anchor has no matches"}}:{kind:"resolved",targets:l}}async#n(n,t){let r=await P(n.recipe,n.cwd,t),o=r.matches.map(i=>({...i,source:h.resolve(i.source)})).sort(j),s={matches:o,complete:r.complete,contentBySource:await J(o,t)};return this.#t.set(n.id,{...n,refreshedComplete:s}),s}};function T(e){let n=ue.exec(e);if(n!==null)return{id:S(n[1]),selector:n[2]==="all"?"all":Number(n[2]),mode:n[3]==="line"?"line":"match"}}c(T,"parseSearchAnchor");function k(e,n,t){let r=n==="all"?e.matches:[e.matches[n-1]].filter(he);if(t==="match"||n!=="all")return r;let o=new Set;return r.filter(s=>{let i=`${s.source}\0${String(s.lineNumber)}`;return o.has(i)?!1:(o.add(i),!0)})}c(k,"selectMatches");function he(e){return e!==void 0}c(he,"isMatch");function G(e,n,t){if(t==="match")return{start:{lineNumber:n.lineNumber,column:n.startColumn},end:{lineNumber:n.lineNumber,column:n.endColumn}};let r=S(e.lines[n.lineNumber-1]);return{start:{lineNumber:n.lineNumber,column:0},end:{lineNumber:n.lineNumber+(r.lineEnding.length>0?1:0),column:r.lineEnding.length>0?0:r.content.length},linewise:!0}}c(G,"selectionRange");async function J(e,n){let t=new Map;for(let r of new Set(e.map(o=>o.source))){let o=await q(r,{encoding:"utf8",...n!==void 0&&{signal:n}}),s=w(r,o);for(let i of e.filter(a=>a.source===r)){let a=s.lines[i.lineNumber-1]?.content;if(a!==i.lineText||a.slice(i.startColumn,i.endColumn)!==i.matchedText)throw new Error(`Search result in ${r} changed before its anchors were registered.`)}t.set(r,o)}return t}c(J,"snapshotContents");async function I(e,n){try{return await q(e,{encoding:"utf8",...n!==void 0&&{signal:n}})}catch{return}}c(I,"readCurrent");function b(e=1){return{kind:"rejected",rejection:{code:"stale",reason:"search anchor is stale",contextRange:{offset:Math.max(1,e-2),limit:5}}}}c(b,"staleAnchor");function x(){return{kind:"rejected",rejection:{code:"missing",reason:"search did not register an all anchor because its result was limited"}}}c(x,"missingCompleteAnchor");function fe(e){if(e.length===0)return".";let n=h.dirname(h.resolve(S(e[0])));for(let t of e.slice(1)){let r=h.resolve(t);for(;!me(n,r);){let o=h.dirname(n);if(o===n)return n;n=o}}return n}c(fe,"commonSourceDirectory");function me(e,n){let t=h.relative(e,n);return t!==".."&&!t.startsWith(`..${h.sep}`)&&!h.isAbsolute(t)}c(me,"isWithin");function j(e,n){return e.source.localeCompare(n.source)||e.lineNumber-n.lineNumber||e.startColumn-n.startColumn||e.endColumn-n.endColumn}c(j,"compareMatches");export{L as a,$e as b,P as c,We as d,U as e,de as f,Q as g};
@@ -1,3 +0,0 @@
1
- import{c as A}from"./chunk-YHUTTZC6.js";import{i as y,o as D,t as T,u as b}from"./chunk-RAZOACDD.js";import{a as R}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";function fe(e,t){let{lines:n,truncation:r,...o}=e,i=n?.map(u=>{let l=[u.lineNumber,T(u.content,t),u.lineEnding];return(u.presentation!==void 0||u.metadata!==void 0)&&l.push(u.presentation),u.metadata!==void 0&&l.push(u.metadata),l}),{content:d,...s}=r??{};return{...o,...i===void 0?{}:{storedLines:i},...r===void 0?{}:{truncation:s,truncatedText:T(d??"",t)}}}a(fe,"compactReadDetails");function k(e,t){let n=e;if(n.storedLines===void 0&&n.truncatedText===void 0)return e;let{storedLines:r,truncatedText:o,truncation:i,...d}=n;return{...d,...r===void 0?{}:{lines:r.map(([s,u,l,f,m])=>({lineNumber:s,content:b(u,t),lineEnding:l,...f==null?{}:{presentation:f},...m==null?{}:{metadata:m}}))},...i===void 0?{}:{truncation:{...i,content:b(o??"",t)}}}}a(k,"restoreReadDetails");import c from"node:path";import{homedir as H}from"node:os";import{createReadToolDefinition as I,getReadmePath as V}from"@earendil-works/pi-coding-agent";import{Text as q}from"@earendil-works/pi-tui";var w=I(process.cwd()),J=new Set(["AGENTS.override.md","AGENTS.md","AGENTS.MD","CLAUDE.md","CLAUDE.MD"]);function S(e,t=process.cwd()){if(typeof e!="object"||e===null)return;let n=e,r=n.path;if(typeof r!="string"||r.length===0||r.includes("#")||!c.isAbsolute(r)&&/^[a-z][a-z\d+.-]*:/iu.test(r)||n.views!==void 0&&(!Array.isArray(n.views)||n.views.length>0)||n.offset!==void 0&&(typeof n.offset!="number"||!Number.isInteger(n.offset)||n.offset<1)||n.limit!==void 0&&(typeof n.limit!="number"||!Number.isInteger(n.limit)||n.limit<1))return;let o=r.startsWith("~/")?c.join(H(),r.slice(2)):r,i=c.resolve(t,o),d=c.basename(i),s=c.relative(c.dirname(V()),i),u=!c.isAbsolute(s)&&(s==="README.md"||s.startsWith(`docs${c.sep}`)||s.startsWith(`examples${c.sep}`));if(!(d!=="SKILL.md"&&!J.has(d)&&!u))return{path:r,...n.offset===void 0?{}:{offset:n.offset},...n.limit===void 0?{}:{limit:n.limit}}}a(S,"nativeReadArguments");function L(e,t){return{...e,args:t,lastComponent:e.lastComponent instanceof q?e.lastComponent:void 0}}a(L,"nativeReadContext");import{getLanguageFromPath as O,getMarkdownTheme as Z,highlightCode as z,keyHint as K}from"@earendil-works/pi-coding-agent";import{Container as M,Markdown as X,Text as Y,truncateToWidth as g,visibleWidth as p,wrapTextWithAnsi as Q}from"@earendil-works/pi-tui";var P=12;function De(e,t,n){let r=S(e,n.cwd);if(r!==void 0)return R(w.renderCall)(r,t,L(n,r));let o=typeof e.path=="string"?e.path:"inherited source",i=typeof e.offset=="number"?e.offset:void 0,d=typeof e.limit=="number"?e.limit:void 0,s=Array.isArray(e.views)?e.views.filter(f=>typeof f=="string"):[],u=[...i===void 0?[]:[{text:i<0?`tail ${String(Math.abs(i))}`:`offset ${String(i)}`}],...d===void 0?[]:[{text:`limit ${String(d)}`}],...s.length===0?[]:[{text:`views ${s.join(",")}`}]],l=[...typeof e.path=="string"?[{label:"path",value:e.path}]:[],...i===void 0?[]:[{label:"offset",value:String(i)}],...d===void 0?[]:[{label:"limit",value:String(d)}],...s.length===0?[]:[{label:"views",value:s.join(",")}]];return A(n.lastComponent,{tool:"read",primary:{text:o,color:typeof e.path=="string"?"accent":"muted",underline:typeof e.path=="string",truncate:"start"},qualifiers:u,details:l,expanded:n.expanded},t)}a(De,"renderReadCall");function Ae(e){let t=new WeakMap;return(n,r,o,i)=>{let d=e.nativeResources?S(i.args,i.cwd):void 0;if(d!==void 0&&!r.isPartial)return R(w.renderResult)({...n,details:{truncation:W(n.details).truncation}},r,o,L(i,d));if(r.isPartial||i.isError){let f=$(n),m=i.isError?"error":"dim";return new Y(o.fg(m,f),0,0)}if(!ae(n))return i.lastComponent instanceof M?i.lastComponent:new M;let s=t.get(n);s===void 0&&(s=k(W(n.details),$(n)),t.set(n,s));let l=(i.lastComponent instanceof h?i.lastComponent:void 0)??new h({result:n,details:s,options:e,expanded:r.expanded,theme:o});return l.update({result:n,details:s,options:e,expanded:r.expanded,theme:o}),l}}a(Ae,"createReadResultRenderer");var h=class{constructor(t){this.state=t}static{a(this,"ReadResultPanel")}cached;update(t){this.state.result===t.result&&this.state.details===t.details&&this.state.options===t.options&&this.state.expanded===t.expanded&&this.state.theme===t.theme||(this.state=t,this.invalidate())}render(t){if(this.cached?.width===t)return this.cached.lines;if(t<8){let l=[g(B(this.state,t),Math.max(1,t))];return this.cached={width:t,lines:l},l}let n=t-2,r=Math.max(1,n-2),o=_(this.state,r),i=te(o,this.state.expanded,this.state.theme),d=[ne(this.state,n,this.state.theme)];for(let l of i)for(let f of Q(l,r))d.push(N(f,n,this.state.theme));let s=ie(this.state.details,this.state.theme);s!==void 0&&d.push(N(s,n,this.state.theme)),d.push(this.state.theme.fg("borderMuted",`\u2570${"\u2500".repeat(n)}\u256F`));let u=d.map(l=>g(l,t));return this.cached={width:t,lines:u},u}invalidate(){this.cached=void 0}};function _(e,t){let n=G(e.details),r=oe(e.result,n,e.details,!e.expanded);if(e.options.kind==="markdown"||se(e.details,n,e.options.kind)){let s=new X(r,0,0,Z());return v(s.render(t),e.theme)}if(e.options.kind==="code-view"){let s=n===void 0||E(n)?j(r).map(u=>U(u,e.theme,!1)):ee(n,e.theme);return v(s,e.theme)}let o=n===void 0||E(n)?j(r).map(x):n.map(({content:s})=>x(s)),i=C(e.details,n),d=i===void 0?o.map(s=>e.theme.fg("toolOutput",s)):z(o.join(`
2
- `),i);return v(d,e.theme)}a(_,"renderContentRows");function ee(e,t){return e.map(n=>{let r=y(n);if(r===void 0)return U(n.content,t);let o=O(r.source),i=x(F(n.content));return o===void 0?t.fg("toolOutput",i):z(i,o)[0]??t.fg("toolOutput",i)})}a(ee,"renderCodeViewLines");function F(e){return e.replace(/(?:[ \t]{2,}<!--[ \t]+scope-(?:begin|end)-[^\s>]+[ \t]+-->)+[ \t]*$/u,"")}a(F,"stripScopeMarkers");function U(e,t,n=!0){let r=x(n?F(e):e);return/^#{2,3}\s/u.test(r)?t.fg("mdHeading",t.bold(r.replace(/^#{2,3}\s+/u,""))):/^(?:Lines|Reason|Recovery):/u.test(r)?t.fg("dim",r):/^[\p{L}][^:]*:$/u.test(r)?t.fg("accent",t.bold(r)):/^\s*[-*]\s/u.test(r)?t.fg("mdListBullet",r):t.fg("toolOutput",r)}a(U,"renderCodeViewLabel");function te(e,t,n){if(t||e.length<=P)return e;let r=e.slice(0,P-1),o=e.length-r.length;return[...r,`${n.fg("dim",`\u2026 ${String(o)} more ${o===1?"row":"rows"} \xB7 `)}${K("app.tools.expand","to expand")}`]}a(te,"compactRows");function ne(e,t,n){let r=a(d=>n.fg("borderMuted",d),"frame"),o=g(` ${B(e,Math.max(1,t-1))} `,Math.max(0,t-1),""),i="\u2500".repeat(Math.max(0,t-p(o)-1));return`${r("\u256D\u2500")}${o}${r(`${i}\u256E`)}`}a(ne,"renderTopBorder");function B(e,t){let n=e.options.label??ue(C(e.details,G(e.details))),r=e.details.source??"read result",o=re(e.details),i=e.theme.fg("accent",e.theme.bold(n)),d=o===void 0?"":e.theme.fg("dim",` \xB7 ${o}`),s=Math.max(1,t-p(i)-p(d)-2),u=le(r,s);return`${i} ${e.theme.fg("muted",u)}${d}`}a(B,"readTitle");function re(e){if(!(e.startLine===void 0||e.endLine===void 0||e.totalLines===void 0||e.totalLines<=0))return`${String(e.startLine)}\u2013${String(e.endLine)} / ${String(e.totalLines)}`}a(re,"sourceRange");function ie(e,t){let n=e.truncation;if(n?.firstLineExceedsLimit===!0)return t.fg("warning","First source line is larger than the saved read limit");if(n?.truncated===!0)return t.fg("warning",`Saved result contains ${String(n.outputLines)} of ${String(n.totalLines)} rendered rows`)}a(ie,"readStatus");function N(e,t,n){let r=Math.max(0,t-2),o=g(e,r),i=` ${o}${" ".repeat(Math.max(0,r-p(o)))} `,d=n.fg("borderMuted","\u2502");return`${d}${i}${d}`}a(N,"framed");function oe(e,t,n,r){if(t!==void 0)return D({source:n.source??"",content:"",lines:t},{compact:r});let o=$(e);return n.truncation===void 0&&!(n.totalLines!==void 0&&n.endLine!==void 0&&n.endLine<n.totalLines)?o:o.replace(/\n\n\[(?:Showing lines|Output truncated|\d+ more lines in source)[\s\S]*\]$/u,"")}a(oe,"cleanText");function E(e){return e.some(t=>t.presentation!==void 0)}a(E,"hasPresentation");function j(e){let t=e.split(/\r\n|\r|\n/u);return t.at(-1)===""&&/(?:\r\n|\r|\n)$/u.test(e)&&t.pop(),t}a(j,"splitTextRows");function $(e){return e.content.flatMap(t=>t.type==="text"?[t.text]:[]).join(`
3
- `)}a($,"textBlocks");function G(e){return e.lines}a(G,"readLines");function W(e){return typeof e=="object"&&e!==null?e:{}}a(W,"readDetails");function ae(e){return e.content.some(t=>t.type==="text")}a(ae,"hasTextContent");function C(e,t){let r=t?.map(y).find(o=>o!==void 0)?.source??e.source;return r===void 0?void 0:O(de(r))}a(C,"languageFor");function se(e,t,n){return n==="source"&&C(e,t)==="markdown"}a(se,"isMarkdownSource");function de(e){try{let t=new URL(e);return t.protocol==="file:"?t.pathname:`${t.pathname}${t.search}`}catch{return e.replace(/#[^/\\]*$/u,"").replace(/^[A-Za-z][A-Za-z\d+.-]*:(?=[/\\])/u,"")}}a(de,"normalizeSourcePath");function x(e){let t="";for(let n of e.replaceAll(" "," ".repeat(4))){let r=R(n.codePointAt(0));t+=r<32||r===127?"\uFFFD":n}return t}a(x,"normalizeText");function ue(e){return e===void 0?"TEXT":{javascript:"JS",json:"JSON",markdown:"MD",python:"PY",rust:"RS",typescript:"TS"}[e]??e.slice(0,4).toUpperCase()}a(ue,"languageLabel");function v(e,t){return e.length===0?[t.fg("dim","Empty content")]:[...e]}a(v,"nonEmptyRows");function le(e,t){return p(e)<=t?e:t<=1?"\u2026":`\u2026${e.slice(-(t-1))}`}a(le,"truncateFromStart");export{fe as a,De as b,Ae as c};
@@ -1 +0,0 @@
1
- import{b as P,c as $,d as j}from"./chunk-N34ATN52.js";import{a as y}from"./chunk-ZC65Z3CK.js";import{a as i}from"./chunk-EI7MMDWY.js";import S from"cross-spawn";import{readFile as w,writeFile as R}from"node:fs/promises";import I from"node:os";import l from"node:path";import{fileURLToPath as A}from"node:url";var N=1;function Z(e){return l.win32.basename(y(e[0]))}i(Z,"configuredExecutableName");function M(e){return l.join(e,".pi","pi-agent-ide")}i(M,"projectIdeConfigDirectory");function D(e,n){return l.join(M(e),`${n}.json`)}i(D,"projectIdeConfigPath");function _(e,n,o={}){let t=(o.environment??process.env).PI_CODING_AGENT_DIR?.trim(),a=t===void 0||t.length===0?l.join(o.homeDirectory??I.homedir(),".pi","agent"):l.resolve(t);return{project:D(e,n),global:l.join(a,"extensions","pi-agent-ide",`${n}.json`),builtIn:A(new URL(`tool-config/${n}.json`,new URL("../src/api/tool-config.ts",import.meta.url).href))}}i(_,"resolveToolConfigPaths");async function ee(e,n,o,r={}){let t=_(e,n,r),a=[{layer:"project",sourcePath:t.project,optional:!0},{layer:"global",sourcePath:t.global,optional:!0},{layer:"built-in",sourcePath:t.builtIn,optional:!1}],s=[],f=new Set;for(let d of a){let c=await V(d,n,o);for(let[u,h]of Object.entries(c))f.has(u)||(f.add(u),s.push({id:u,config:h,layer:d.layer,sourcePath:d.sourcePath}))}return{entries:s,paths:t}}i(ee,"loadLayeredToolConfig");function G(e,n,o){let r=l.extname(n).toLowerCase();if(e.extensions.every(s=>!(B(s)===r||s==="*"))&&!e.fileNames?.some(s=>process.platform==="win32"?s.toLowerCase()===l.basename(n).toLowerCase():s===l.basename(n)))return!1;let t=l.relative(o,n).split(l.sep).join("/"),a=i(s=>s?.some(f=>l.matchesGlob(t,f))??!1,"matches");return(e.include===void 0||a(e.include))&&!a(e.exclude)}i(G,"matchesConfiguredFile");function ne(e,n,o,r,t){let a=l.resolve(t,r),s=e.filter(c=>G(c.config,a,t)),f=s.find(c=>c.layer!=="built-in");if(f!==void 0)return f;let d=Math.max(0,...s.map(c=>o.get(c.id)?.score??0));return s.find(c=>n.has(c.id)&&(o.get(c.id)?.score??0)===d)}i(ne,"selectConfiguredEntry");async function oe(e,n,o=process.env){C(e,"process");let r=y(e.command[0]).replaceAll("{project}",n),t=O(e,n,o);return j(r,n,t)}i(oe,"hasConfiguredExecutable");async function J(e,n){C(e,"process");let o=e.command.map(d=>q(d,n)),r=y(o[0]),t=o.slice(1),a=e.cwd==="file"?l.dirname(n.filePath):n.projectRoot,s=e.successExitCodes??[0],f=O(e,n.projectRoot,n.env??process.env);return new Promise((d,c)=>{let u=S(r,t,{cwd:a,env:f,signal:n.signal,killSignal:"SIGKILL",stdio:["ignore","pipe","pipe"]}),h="",v="",E=y(u.stdout),x=y(u.stderr),T=!1,b=setTimeout(()=>{T=!0,u.kill("SIGKILL")},e.timeoutMs??3e4);E.setEncoding("utf8"),x.setEncoding("utf8"),E.on("data",g=>{h+=g}),x.on("data",g=>{v+=g}),u.on("error",g=>{clearTimeout(b),c(g)}),u.on("close",g=>{clearTimeout(b),d({ok:!T&&g!==null&&s.includes(g),exitCode:g,stdout:h,stderr:v})})})}i(J,"runConfiguredProcess");async function re(e,n){let o=await w(n.filePath,"utf8"),r=await J(e.run,n);if(!r.ok)return e.output==="in-place"&&await w(n.filePath,"utf8")!==o&&await R(n.filePath,o,"utf8"),{ok:!1,changed:!1};e.output==="stdout"&&r.stdout!==o&&await R(n.filePath,r.stdout,"utf8");let t=await w(n.filePath,"utf8");return{ok:!0,changed:o!==t}}i(re,"runConfiguredFormatter");function te(e){let n=k(e,"formatters");for(let[o,r]of Object.entries(n.entries)){let t=m(r,`formatter ${o}`);if(F(t,`formatter ${o}`),C(t.run,`formatter ${o}.run`),t.output!=="in-place"&&t.output!=="stdout")throw new Error(`formatter ${o}.output must be in-place or stdout`)}return e}i(te,"parseFormattersConfig");function ie(e){let n=k(e,"linters"),o=new Set(["pi-json","eslint-json","sarif","checkstyle","gcc","clang","regex"]);for(let[r,t]of Object.entries(n.entries)){let a=m(t,`linter ${r}`);F(a,`linter ${r}`),C(a.check,`linter ${r}.check`),a.fix!==void 0&&C(a.fix,`linter ${r}.fix`);let s=m(a.diagnostics,`linter ${r}.diagnostics`);if(!o.has(String(s.format)))throw new Error(`linter ${r} has an unsupported diagnostics format`);if(s.columnBase!==void 0&&(s.format!=="regex"||s.columnBase!==0&&s.columnBase!==1))throw new Error(`linter ${r} columnBase must be 0 or 1 for regex diagnostics`);if(s.format==="regex"&&typeof s.pattern!="string")throw new Error(`linter ${r} regex diagnostics require pattern`)}return e}i(ie,"parseLintersConfig");function k(e,n){let o=m(e,"tool config");if(o.version!==N)throw new Error(`tool config version must be ${N}`);return{entries:m(o[n],n)}}i(k,"configRoot");function F(e,n){p(e.extensions,`${n}.extensions`,!1),e.fileNames!==void 0&&p(e.fileNames,`${n}.fileNames`,!1),e.include!==void 0&&p(e.include,`${n}.include`,!1),e.exclude!==void 0&&p(e.exclude,`${n}.exclude`,!0)}i(F,"assertMatcher");function C(e,n){let o=m(e,n);if(p(o.command,`${n}.command`,!1),o.cwd!==void 0&&o.cwd!=="project"&&o.cwd!=="file")throw new Error(`${n}.cwd must be project or file`);if(o.timeoutMs!==void 0&&(!Number.isFinite(o.timeoutMs)||Number(o.timeoutMs)<=0))throw new Error(`${n}.timeoutMs must be positive`);if(o.successExitCodes!==void 0&&(!Array.isArray(o.successExitCodes)||o.successExitCodes.some(r=>!Number.isInteger(r))))throw new Error(`${n}.successExitCodes must contain integers`);if(o.env!==void 0){let r=m(o.env,`${n}.env`);if(Object.values(r).some(t=>typeof t!="string"))throw new Error(`${n}.env values must be strings`)}}i(C,"assertProcessConfig");function p(e,n,o){if(!Array.isArray(e)||!o&&e.length===0||e.some(r=>typeof r!="string"||r.length===0))throw new Error(`${n} must be ${o?"an":"a non-empty"} array of strings`)}i(p,"assertStringArray");function m(e,n){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${n} must be an object`);return e}i(m,"configRecord");function B(e){return e.startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`}i(B,"normalizeExtension");async function V(e,n,o){let r;try{r=await w(e.sourcePath,"utf8")}catch(t){if(e.optional&&U(t))return{};throw new Error(`Cannot read ${e.layer} ${n} config at ${e.sourcePath}: ${L(t)}`,{cause:t})}try{return o(JSON.parse(r))}catch(t){throw new Error(`Invalid ${e.layer} ${n} config at ${e.sourcePath}: ${L(t)}`,{cause:t})}}i(V,"readToolConfigLayer");function U(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}i(U,"isMissingFile");function L(e){return e instanceof Error?e.message:String(e)}i(L,"errorMessage");function O(e,n,o){return $(n,{...P(o),...P(e.env??{})})}i(O,"createConfiguredProcessEnvironment");function q(e,n){let o=l.relative(n.projectRoot,n.filePath);return e.replaceAll("{project}",n.projectRoot).replaceAll("{fileDir}",l.dirname(n.filePath)).replaceAll("{relativeFile}",o).replaceAll("{file}",n.filePath)}i(q,"expandPlaceholders");export{N as a,Z as b,M as c,D as d,_ as e,ee as f,G as g,ne as h,oe as i,J as j,re as k,te as l,ie as m,O as n};
@@ -1,2 +0,0 @@
1
- import"./chunk-NNCZYO4Q.js";import{c as E}from"./chunk-KCEOTU5Z.js";import"./chunk-YHUTTZC6.js";import{a as A}from"./chunk-ORAPGW7W.js";import{a as I,b as k}from"./chunk-JASLOB2X.js";import{e as f,f as m,g as R,h as D,i as h,l as P}from"./chunk-X6MPU7UO.js";import"./chunk-RAZOACDD.js";import{a as y}from"./chunk-OBWZ5RYN.js";import{a as v,b as w}from"./chunk-KZBAJFCV.js";import"./chunk-KINKBPPX.js";import"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import O from"node:path";var x="diagnostics",S=E({kind:"code-view",label:"Diagnostics"});async function T(o){let i,e=a((r,d)=>{if(i===void 0)throw new Error("IDE diagnostics are not connected");return i(r,{cwd:d})},"collect"),s={protocol:v,apiVersion:3,id:"diagnostics",setup(r){i=r.readDiagnostics}},n=new WeakMap,l=new WeakMap,C={protocol:I,apiVersion:k,id:"diagnostics",setup(r){r.addResolver({resolver:V(e),renderResult:S});let d=P();r.addView({view:"diagnostics",priority:100,presenter:q(e,l)}),r.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler(t){return t.state?.resolvedBy==="diagnostics"?d(t):(t.state?.contentKind==="text"&&t.request.views?.includes("diagnostics")&&n.set(t.request,t.state.text),{kind:"continue",context:t})}}),r.addHandler({stage:"post-read",handler(t){let g=n.get(t.request),p=g&&l.get(g),c=t.result,u=c?.content[0];return!p||!c||u?.type!=="text"?{kind:"continue",context:t}:{kind:"continue",context:{...t,result:{...c,content:[{...u,text:`${p}
2
- ${u.text}`},...c.content.slice(1)]}}}}}),r.describe('diagnostics:<path> \u2014 lint and language-server diagnostics. views: ["diagnostics"] \u2014 diagnostics alongside source text. Diagnostic sources name the actual reporting tools. Automatic notices include findings only and wake an idle agent as soon as results arrive; silence does not prove the file is clean. Use an explicit diagnostic read to check readiness. Pending results and snapshots are not completed checks; an empty snapshot does not prove the file is clean.'),r.addPromptGuideline("Use read with `diagnostics:<path>` or the `diagnostics` view for per-file diagnostics instead of running equivalent checks through Bash. Project builds and tests remain separate verification.")}};await Promise.all([y(o,s),A(o,C)])}a(T,"registerDiagnostics");function V(o){return{id:"diagnostics",tryResolve(i,e){return Promise.resolve(_(i,e.cwd,o))}}}a(V,"createDiagnosticResolver");function _(o,i,e){let s;try{s=f(o,x,i)}catch(n){return{kind:"failed",error:n}}return s===void 0?{kind:"not-handled"}:{kind:"resolved",resource:{source:m(x,s),async read(){let n=await e(s,i);return[R(s,n.content,n.results)]}}}}a(_,"resolveDiagnosticSource");function q(o,i){return{id:"diagnostics",async present(e,s){if(s.purpose!=="read"||!O.isAbsolute(e.source))return e;let n=await o(e.source,s.cwd);if(n.content!==e.content)throw new Error("File changed during diagnostic read; read it again for current source lines.");return i.set(e,h(n.results)),D(e,n.results)}}}a(q,"createDiagnosticPresenter");export{T as default};
@@ -1,2 +0,0 @@
1
- import{a as r}from"./chunk-EI7MMDWY.js";import{Type as n}from"typebox";import{Value as C}from"typebox/value";var f=Symbol.for("pi-agent-text/TextAnchor"),u=class{constructor(t,o){this.value=t;this.lineNumber=o;if(t.length===0)throw new TypeError("Text anchor value must be non-empty");if(!Number.isSafeInteger(o)||o<1)throw new RangeError("Text anchor line number must be a positive safe integer")}static{r(this,"TextAnchor")}[f]=!0;static is(t){if(typeof t!="object"||t===null)return!1;try{let o=t;return o[f]===!0&&typeof o.value=="string"&&Number.isSafeInteger(o.lineNumber)&&o.lineNumber>=1}catch{return!1}}toString(){return this.value}},x=new WeakMap;function w(e,t,o){x.set(e,{renderer:t,resolverId:o})}r(w,"attachTextAnchorRenderer");function S(e){return x.get(e)?.renderer}r(S,"getTextAnchorRenderer");function P(e,t,o){let i=x.get(e);if(i===void 0)throw new Error(`No renderer is attached to text anchor "${t}"`);return{...i.renderer,resolverId:i.resolverId,full:i.renderer.renderFull(t,o),compact:i.renderer.renderCompact(t,o)}}r(P,"renderTextAnchor");var a={additionalProperties:!0},l=n.Function([],n.Unknown()),g=n.Object({lineNumber:n.Integer({minimum:1}),column:n.Integer({minimum:0})},a),j=n.Object({rank:n.Integer({minimum:1}),range:n.Object({start:g,end:g},a)},a),L=n.Object({id:n.String({minLength:1}),description:n.Union([n.String(),l]),normalize:n.Optional(l),renderFull:l,renderCompact:l,tryResolve:l,recover:n.Optional(l)},a),O=n.Object({code:n.Union([n.Literal("invalid"),n.Literal("stale"),n.Literal("missing"),n.Literal("ambiguous")]),reason:n.String(),contextRange:n.Optional(n.Object({offset:n.Number(),limit:n.Number()}))}),E=n.Union([n.Object({kind:n.Literal("not-handled")},a),n.Object({kind:n.Literal("resolved"),anchor:n.Unknown()},a),n.Object({kind:n.Literal("rejected"),rejection:O},a),n.Object({kind:n.Literal("failed"),error:n.Unknown()},a)]),N=n.Union([n.Object({kind:n.Literal("unavailable")},a),n.Object({kind:n.Literal("candidates"),candidates:n.Array(j),total:n.Integer({minimum:0})},a),n.Object({kind:n.Literal("timed-out")},a),n.Object({kind:n.Literal("failed"),error:n.Unknown()},a)]);function D(e){return p(L,e)&&y(()=>e.id.trim().length>0)}r(D,"isTextAnchorResolver");function I(e){return p(E,e)&&y(()=>{let t=e;return t.kind!=="resolved"||u.is(t.anchor)})}r(I,"isTextAnchorResolutionAttempt");function M(e){return p(N,e)}r(M,"isTextAnchorRecoveryOutcome");function p(e,t){return y(()=>C.Check(e,t))}r(p,"safeCheck");function y(e){try{return e()}catch{return!1}}r(y,"safeEvaluate");function T(e){if(!e.some(i=>i.marker!==void 0))return e.map(i=>`${i.prefix??""}${i.content}${i.suffix??""}`);let o=Math.max(0,...e.map(i=>i.prefix?.length??0));return e.map(i=>`${i.marker??" "}|${(i.prefix??"").padStart(o," ")}${i.content}${i.suffix??""}`)}r(T,"renderPresentedTextRows");var h="pi-agent-text/source-line";function $(e){let t=e.metadata?.[h];if(F(t))return t}r($,"getTextSourceLine");function U(e,t){return{...e,metadata:{...e.metadata,[h]:t}}}r(U,"withTextSourceLine");function F(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.source=="string"&&t.source.length>0&&typeof t.lineNumber=="number"&&Number.isInteger(t.lineNumber)&&t.lineNumber>0&&typeof t.content=="string"}r(F,"isTextSourceLine");import{Type as d}from"typebox";import{Value as W}from"typebox/value";var q=d.Function([],d.Unknown()),R=d.Object({id:d.String({minLength:1}),present:q}),B=d.Object({presenter:R,priority:d.Optional(d.Number())});function _(e){return A(R,e)}r(_,"isTextLinePresenter");function z(e){return A(B,e)}r(z,"isTextPresenterRegistration");function K(e,t){return{source:e,content:t,lines:H(t)}}r(K,"createTextDocument");function V(e){return e.lines.map(t=>`${t.content}${t.lineEnding}`).join("")}r(V,"renderTextDocument");function Y(e,t={}){let o=e.lines.flatMap(s=>[...s.presentation?.before??[],G(s,t.compact===!0),...s.presentation?.after??[]]),i=T(o),c=0;return e.lines.map(s=>{let m=1+(s.presentation?.before?.length??0)+(s.presentation?.after?.length??0),k=i.slice(c,c+m).join(`
2
- `);return c+=m,`${k}${s.lineEnding}`}).join("")}r(Y,"renderPresentedTextDocument");function G(e,t){let o=t&&e.presentation?.compactPrefix!==void 0?e.presentation.compactPrefix:e.presentation?.prefix,i=t&&e.presentation?.compactSuffix!==void 0?e.presentation.compactSuffix:e.presentation?.suffix;return{content:e.content,...o!==void 0&&{prefix:o},...i!==void 0&&{suffix:i},...e.presentation?.marker!==void 0&&{marker:e.presentation.marker}}}r(G,"presentedRowFor");function H(e){if(e.length===0)return[];let t=[],o=/([^\r\n]*)(\r\n|\r|\n|$)/gu,i;for(;(i=o.exec(e))!==null&&i[0].length!==0;)t.push({lineNumber:t.length+1,content:i[1]??"",lineEnding:i[2]??""});return t}r(H,"splitTextLines");function A(e,t){try{return W.Check(e,t)}catch{return!1}}r(A,"safeCheck");var J=new Set(["application/ecmascript","application/graphql","application/javascript","application/json","application/sql","application/toml","application/x-httpd-php","application/x-javascript","application/x-ndjson","application/x-www-form-urlencoded","application/x-yaml","application/xml","application/yaml"]);function Q(){return{id:"text",description:"Text file paths and URLs return their text.",tryConvert(e,t){return Promise.resolve(X(e,t))}}}r(Q,"createTextContentConverter");function X(e,t){let o=ee(t.signal);if(o!==void 0)return{kind:"failed",error:o};try{return{kind:"converted",content:[{type:"text",text:new TextDecoder("utf8",{fatal:!0}).decode(e.bytes)}]}}catch(i){return b(e.mediaType)?{kind:"failed",error:new TypeError(`${e.source} is not valid UTF-8 text`,{cause:i})}:{kind:"not-handled"}}}r(X,"convertText");function b(e){if(e===void 0)return!1;let t=e.split(";",1)[0]?.trim().toLowerCase()??"";return t.startsWith("text/")||J.has(t)||t.endsWith("+json")||t.endsWith("+xml")}r(b,"isTextualMediaType");function Z(e){let t=e[0];if(e.length!==1||t.type!=="text")throw new TypeError("Text resources require exactly one text block");return t.text}r(Z,"textFromAgentContent");function ee(e){if(e?.aborted===!0)return e.reason instanceof Error?e.reason:te()}r(ee,"cancellationError");function te(){let e=new Error("The operation was aborted");return e.name="AbortError",e}r(te,"abortError");function ne(e){if(e===null||typeof e!="object")return!1;let t=e;if(t.kind==="not-handled")return!0;if(t.kind==="failed")return"error"in t;if(t.kind==="rejected"){let o=t.rejection;return o!==null&&typeof o=="object"&&["invalid","stale","missing","ambiguous"].includes(o.code)&&typeof o.reason=="string"}return t.kind!=="resolved"||!Array.isArray(t.targets)||t.targets.length===0?!1:t.targets.every(o=>{if(o===null||typeof o!="object")return!1;let i=o.source,c=o.ranges;return typeof i=="string"&&i.length>0&&(c===void 0||Array.isArray(c)&&c.every(re))})}r(ne,"isTextTargetResolutionAttempt");function re(e){if(e===null||typeof e!="object")return!1;let t=e;return v(t.start)&&v(t.end)&&(t.linewise===void 0||typeof t.linewise=="boolean")}r(re,"isTextSelectionRange");function v(e){if(e===null||typeof e!="object")return!1;let t=e;return Number.isInteger(t.lineNumber)&&t.lineNumber>=1&&Number.isInteger(t.column)&&t.column>=0}r(v,"isTextSelectionPosition");function oe(e,t){if(e.length<16)return e;let o=t.indexOf(e);return o<0?e:[o,e.length]}r(oe,"storeText");function ie(e,t){return typeof e=="string"?e:t.slice(e[0],e[0]+e[1])}r(ie,"restoreText");export{u as a,w as b,S as c,P as d,D as e,I as f,M as g,T as h,$ as i,U as j,_ as k,z as l,K as m,V as n,Y as o,Q as p,b as q,Z as r,ne as s,oe as t,ie as u};
@@ -1 +0,0 @@
1
- import{a as u,e as c,k as l}from"./chunk-THSCUT2L.js";import{a as r}from"./chunk-EI7MMDWY.js";import{Type as t}from"typebox";import{Value as a}from"typebox/value";var g=`${u}/post-edit/register`;function h(e){return a.Check(t.Object({formatting:t.Object({status:t.Union(["disabled","unavailable","skipped-syntax","unchanged","changed","failed","not-reported"].map(n=>t.Literal(n))),formatter:t.Optional(t.String())})}),e)}r(h,"isFormattingContribution");function w(e){return a.Check(t.Object({diffStatuses:t.Array(t.Object({text:t.String({minLength:1}),tone:t.Optional(t.Union(["muted","success","warning","error"].map(n=>t.Literal(n))))}))}),e)}r(w,"isDiffStatusContribution");var p=t.Function([],t.Unknown()),x=t.Object({id:t.String({minLength:1}),handler:p}),y=t.Object({registration:x,accept:p});function E(e){return a.Check(x,e)}r(E,"isTextPostEditHandlerRegistration");function b(e){return a.Check(y,e)}r(b,"isTextPostEditHandlerRegistrationRequest");function P(e){if(typeof e!="object"||e===null)return!1;let n=e;return Array.isArray(n.hints)&&typeof n.scopeMarkers=="object"&&n.scopeMarkers!==null&&Array.isArray(n.warnings)}r(P,"isTextMutationResultContributionData");function S(e,n){if(!E(n))throw new TypeError("Invalid text editor post-edit handler registration");let o,d=r(()=>{let s={registration:n,accept(f){if(o!==void 0)throw new Error(`Post-edit handler ${n.id} was accepted more than once`);o=f}};return e.events.emit(g,s),o!==void 0},"announce"),i=r(()=>{},"unsubscribeReady");i=e.events.on(c,s=>{if(!l(s))throw new Error("Invalid pi-agent-text-editor core readiness event");if(!d())throw new Error("pi-agent-text-editor core announced readiness without accepting the post-edit handler");i()}),e.on("session_shutdown",()=>{i(),o?.()}),d()&&i()}r(S,"connectTextEditorPostEditHandler");export{g as a,h as b,w as c,E as d,b as e,P as f,S as g};
@@ -1 +0,0 @@
1
- import{a as t}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as n}from"typebox/value";var r=e.Function([],e.Unknown()),i=e.Object({tool:e.String({pattern:"\\S"}),fallback:e.Optional(e.Boolean()),renderCall:e.Optional(r),renderResult:e.Optional(r),renderShell:e.Optional(e.Union([e.Literal("default"),e.Literal("self")]))});function d(o){return n.Check(i,o)?o.renderCall!==void 0||o.renderResult!==void 0:!1}t(d,"isTextEditorToolRendererRegistration");export{d as a};
@@ -1,3 +0,0 @@
1
- import{j as V}from"./chunk-RAZOACDD.js";import{a as m}from"./chunk-KINKBPPX.js";import{a as y}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import x from"node:path";import{fileURLToPath as R}from"node:url";function T(e,n){let t=`${n}:`;if(!e.startsWith(t))return;let o=e.slice(t.length),r=o.indexOf("#"),i=r===-1?o:o.slice(0,r);if(i.length===0)throw new TypeError(`${n}: requires a file path.`);let s=$(i,`${n}: path`),c=r===-1?void 0:o.slice(r+1);if(n==="ast"){if(c!==void 0)throw new TypeError("ast: accepts only a file path and does not accept a symbol selector.");return{scheme:n,path:s}}if(n==="symbol"&&c===void 0)throw new TypeError("symbol: requires #<symbol-selector> after the file path.");if(c===void 0)return{scheme:n,path:s};if(c.length===0)throw new TypeError(`${n}: symbol selector must not be empty.`);let d=c.split("/").map(f=>{if(f.length===0)throw new TypeError(`${n}: symbol selector contains an empty segment.`);return $(f,`${n}: symbol selector`)});return{scheme:n,path:s,selector:d}}a(T,"parseCodeViewReference");function D(e,n){return e.startsWith("file://")?R(new URL(e)):x.isAbsolute(e)?x.normalize(e):x.resolve(n,e)}a(D,"resolveCodeViewPath");function C(e,n,t){let o=n.replaceAll("%","%25").replaceAll("#","%23"),r=t===void 0?"":`#${t.map(i=>encodeURIComponent(i)).join("/")}`;return`${e}:${o}${r}`}a(C,"formatCodeViewReference");function k(e){return e.map(n=>encodeURIComponent(n)).join("/")}a(k,"formatSymbolSelector");function $(e,n){try{return decodeURIComponent(e)}catch(t){throw new TypeError(`${n} contains invalid percent encoding.`,{cause:t})}}a($,"decodePart");import v from"node:path";function N(e,n,t){let o=`${n}:`;if(!e.startsWith(o))return;let r=e.slice(o.length);if(r.length===0)throw new Error(`${n}: requires a file path.`);return v.resolve(t,r)}a(N,"resolveDiagnosticViewPath");function M(e,n){return`${e}:${n}`}a(M,"formatDiagnosticViewSource");function j(e,n,t,o={}){let r=n.split(/\r\n|\r|\n/u),i=b(t,r.length);if(i.size===0)return{type:"text",text:w(t)||"No diagnostics.",sourceLines:{}};let s=o.contextLines??5;if(!Number.isInteger(s)||s<0)throw new TypeError("Diagnostic contextLines must be a non-negative integer.");let c=new Set;for(let l of i.keys()){let u=Math.max(1,l-s),p=Math.min(r.length,l+s);for(let g=u;g<=p;g+=1)c.add(g)}let d=w(t),f=d?[d]:[],S={};for(let l of[...c].sort((u,p)=>u-p)){let u=r[l-1]??"",p=(i.get(l)??[]).map(({diagnostic:g,source:h})=>`<!-- ${h}: ${m(g,h)} -->`).join(" ");f.push(p.length===0?u:`${u} ${p}`),S[String(f.length)]={source:e,lineNumber:l,content:u}}return{type:"text",text:f.join(`
2
- `),sourceLines:S}}a(j,"createDiagnosticViewContent");function O(e,n){let t=b(n,e.lines.length,/[\r\n]$/u.test(e.content)),o=e.lines.map(r=>{let i=t.get(r.lineNumber);if(i===void 0)return r;let s=i.map(({diagnostic:c,source:d})=>`<!-- ${d}: ${m(c,d)}${c.line===r.lineNumber?"":` @${c.line}:${c.column}`} -->`).join(" ");return{...r,presentation:{...r.presentation,suffix:`${r.presentation?.suffix??""} ${s}`}}});return{...e,lines:o}}a(O,"addDiagnosticAnnotations");function w(e){return e.filter(n=>n.status&&n.status!=="ready").map(n=>`${n.source}: ${n.status}${n.reason?` (${n.reason})`:""}.`).join(" ")}a(w,"diagnosticStatus");function b(e,n,t=!1){let o=new Map;for(let{diagnostics:r,source:i}of e)for(let s of r){let c=t&&s.line===n+1?n:s.line;if(!Number.isInteger(s.line)||c<1||c>n)continue;let d=o.get(c)??[];d.push({diagnostic:s,source:i}),o.set(c,d)}return o}a(b,"diagnosticsByValidLine");function B(e){return{text:`${e.content}${e.suffix??""}`,...e.sourceLine!==void 0&&{sourceLine:e.sourceLine}}}a(B,"renderSourceViewLine");function E(e,n){if(e.length===0)return L([{text:"<empty-result>"}]);if(e.length===1&&y(e[0]).status==="failed"&&y(e[0]).path===""){let o=y(e[0]),r=n.recovery===void 0?[]:["","Recovery:",...n.recovery],i=n.includeNoChange===!0?["","No file was changed."]:[];return L([o.code??n.failureLabel,"",`Reason: ${o.error??n.unknownFailure??"unknown failure"}`,...i,...r].map(s=>({text:s})))}let t=[];for(let[o,r]of e.entries())o>0&&t.push({text:""},{text:""}),t.push(...P(r,n));return L(t)}a(E,"formatSourceViewResults");function F(){return e=>{let n=e.state;if(n?.contentKind!=="text")return{kind:"continue",context:e};let t=A(n.content[0]);if(t===void 0)return{kind:"continue",context:e};let o=n.text.lines.map(r=>{let i=t[String(r.lineNumber)];return i===void 0?r:V(r,i)});return{kind:"continue",context:{...e,state:{...n,text:{...n.text,lines:o}}}}}}a(F,"createSourceMappedTextReadHandler");function P(e,n){if(e.status==="failed")return[...e.heading===void 0?[`## file: ${e.path||"<unknown>"}`]:[`## ${e.heading}`,...e.details??[]],`${n.failureLabel} | ${e.error??n.unknownFailure??"unknown failure"}`].map(s=>({text:s}));let t=e.heading===void 0?[`## file: ${e.path}`]:[`## ${e.heading}`,...e.details??[]],o=e.continuation??"",r=e.warning===void 0?[]:[{text:""},{text:e.warning}];return[...t.map(i=>({text:i})),{text:`Lines: ${e.startLine}-${e.endLine} of ${e.totalLines}${o}`},{text:""},...e.renderedLines,...r]}a(P,"formatSourceViewBlock");function L(e){let n={};for(let[t,o]of e.entries())o.sourceLine!==void 0&&(n[String(t+1)]=o.sourceLine);return{type:"text",text:e.map(t=>t.text).join(`
3
- `),sourceLines:n}}a(L,"sourceMappedContent");function A(e){if(typeof e!="object"||e===null||!("sourceLines"in e))return;let n=e.sourceLines;if(!(typeof n!="object"||n===null)){for(let t of Object.values(n))if(!I(t))return;return n}}a(A,"sourceLineMap");function I(e){if(typeof e!="object"||e===null)return!1;let n=e;return typeof n.source=="string"&&n.source.length>0&&Number.isInteger(n.lineNumber)&&(n.lineNumber??0)>0&&typeof n.content=="string"}a(I,"isTextSourceLine");export{T as a,D as b,C as c,k as d,N as e,M as f,j as g,O as h,w as i,B as j,E as k,F as l};
@@ -1 +0,0 @@
1
- import{a as o}from"./chunk-EI7MMDWY.js";var s=Symbol.for("pi-agent-text-editor.last-resolved-resource");function u(e,n){if(!c(n))return;let r=n.source,t=n.resolvedBy;typeof r!="string"||r.length===0||typeof t!="string"||t.length===0||(e[s]={source:r,resolverId:t})}o(u,"rememberLastResolvedResource");function i(e){return e[s]}o(i,"getLastResolvedResource");function d(e){e[s]=void 0}o(d,"clearLastResolvedResource");function c(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}o(c,"isRecord");export{u as a,i as b,d as c};
package/dist/entry-80.js DELETED
@@ -1 +0,0 @@
1
- import{v as r}from"./chunk-S3ZPXWX7.js";import{p as e}from"./chunk-RAZOACDD.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"web",capability:"read"},converter:e(),priority:300};async function i(o){await r(o,n)}t(i,"registerWebText");export{i as default};
@@ -1,14 +0,0 @@
1
- import type { TSchema } from "typebox";
2
-
3
- export function appendSchemaFieldOrder(description: string, schema: TSchema): string {
4
- const properties = (schema as { readonly properties?: unknown }).properties;
5
-
6
- if (properties === null || typeof properties !== "object" || Array.isArray(properties)) {
7
- return description;
8
- }
9
-
10
- const fields = Object.keys(properties);
11
- return fields.length === 0
12
- ? description
13
- : `${description}\nArgument order: ${fields.map((field) => `\`${field}\``).join(", ")}.`;
14
- }
@@ -1,26 +0,0 @@
1
- import { connectTextEditorPlugin } from "pi-agent-text-editor/api/connect-plugin";
2
- import {
3
- TEXT_EDITOR_API_VERSION,
4
- TEXT_EDITOR_PROTOCOL,
5
- type TextEditorPlugin,
6
- } from "pi-agent-text-editor/api/plugin-protocol";
7
-
8
- import { registerArgumentOrderGuard } from "./src/argument-order-guard.js";
9
-
10
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
11
-
12
- export default async function registerTextEditorArgumentOrder(pi: ExtensionAPI): Promise<void> {
13
- const plugin = {
14
- protocol: TEXT_EDITOR_PROTOCOL,
15
- apiVersion: TEXT_EDITOR_API_VERSION,
16
- id: "text-editor-argument-order",
17
- setup(api) {
18
- const addRegistration = registerArgumentOrderGuard(pi);
19
- api.onMutationTool((registration) => {
20
- addRegistration({ name: registration.name, schema: registration.parameters });
21
- });
22
- },
23
- } satisfies TextEditorPlugin;
24
-
25
- await connectTextEditorPlugin(pi, plugin);
26
- }
@@ -1,16 +0,0 @@
1
- {
2
- "name": "pi-agent-text-editor-argument-order",
3
- "version": "0.2.2",
4
- "type": "module",
5
- "dependencies": {
6
- "pi-agent-text-editor": "0.2.2"
7
- },
8
- "pi": {
9
- "extensions": [
10
- "./runtime/entry-70.js"
11
- ]
12
- },
13
- "peerDependencies": {
14
- "@earendil-works/pi-coding-agent": "*"
15
- }
16
- }
@@ -1,100 +0,0 @@
1
- import {
2
- type InterceptorContext,
3
- type InterceptResult,
4
- registerToolCallInterceptor,
5
- type ToolCallInterceptorHandler,
6
- } from "pi-agent-text-editor/api/tool-call-interceptor";
7
-
8
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
9
-
10
- export interface ArgumentSchema {
11
- readonly properties?: Readonly<Record<string, unknown>>;
12
- readonly additionalProperties?: boolean;
13
- }
14
-
15
- export interface ArgumentSchemaRegistration {
16
- readonly name: string;
17
- readonly schema: ArgumentSchema;
18
- }
19
-
20
- interface ArgumentOrderViolation {
21
- readonly observedOrder: readonly string[];
22
- readonly expectedOrder: readonly string[];
23
- readonly unknownKey?: string;
24
- }
25
-
26
- function checkArgumentOrder(
27
- value: Record<string, unknown>,
28
- schema: ArgumentSchema,
29
- ): ArgumentOrderViolation | undefined {
30
- const expectedOrder = Object.keys(schema.properties ?? {});
31
- const observedOrder = Object.keys(value);
32
- let lastIndex = -1;
33
-
34
- for (const key of observedOrder) {
35
- const index = expectedOrder.indexOf(key);
36
-
37
- if (index === -1) {
38
- if (schema.additionalProperties === false) {
39
- return { observedOrder, expectedOrder, unknownKey: key };
40
- }
41
-
42
- continue;
43
- }
44
-
45
- if (index < lastIndex) {
46
- return { observedOrder, expectedOrder };
47
- }
48
-
49
- lastIndex = index;
50
- }
51
-
52
- return undefined;
53
- }
54
-
55
- function makeBlockResult(toolName: string, violation: ArgumentOrderViolation): InterceptResult {
56
- const unknown = violation.unknownKey ? ` Unknown key: "${violation.unknownKey}".` : "";
57
-
58
- return {
59
- annotation: { kind: "custom", label: "Argument Order", color: "warning" },
60
- message: {
61
- customType: "text-editor-argument-order-block",
62
- content:
63
- `[SYSTEM] ${toolName} blocked: argument order violation.${unknown}\n` +
64
- `Observed order: ${violation.observedOrder.join(", ") || "(none)"}.\n` +
65
- `Expected schema order: ${violation.expectedOrder.join(", ") || "(none)"}.\n` +
66
- `Call ${toolName} again with arguments in schema order.`,
67
- display: false,
68
- details: violation,
69
- },
70
- };
71
- }
72
-
73
- export function registerArgumentOrderGuard(
74
- pi: ExtensionAPI,
75
- ): (registration: ArgumentSchemaRegistration) => void {
76
- const schemas = new Map<string, ArgumentSchema>();
77
- const toolNames: string[] = [];
78
- const handler: ToolCallInterceptorHandler = {
79
- name: "text-editor-argument-order-guard",
80
- blockExecution: true,
81
- toolNames,
82
- intercept(context: InterceptorContext): InterceptResult | undefined {
83
- const schema = schemas.get(context.toolCall.name);
84
-
85
- if (!schema) {
86
- return undefined;
87
- }
88
-
89
- const violation = checkArgumentOrder(context.partialArgs ?? context.args, schema);
90
- return violation ? makeBlockResult(context.toolCall.name, violation) : undefined;
91
- },
92
- };
93
-
94
- registerToolCallInterceptor(pi, handler);
95
- return (registration) => {
96
- schemas.set(registration.name, registration.schema);
97
- toolNames.push(registration.name);
98
- registerToolCallInterceptor(pi, handler);
99
- };
100
- }