pi-agent-ide 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +74 -22
  3. package/assets/gallery/apply-editing.png +0 -0
  4. package/assets/gallery/debugging.png +0 -0
  5. package/assets/gallery/read-web.png +0 -0
  6. package/assets/gallery/search-replace.png +0 -0
  7. package/assets/gallery/terminal.png +0 -0
  8. package/assets/gallery/tool-editing.png +0 -0
  9. package/dist/chunk-25CZ5ZIU.js +3 -0
  10. package/dist/chunk-526E364R.js +3 -0
  11. package/dist/chunk-5PLV4HLG.js +1 -0
  12. package/dist/chunk-5QQABP47.js +14 -0
  13. package/dist/{chunk-72EEL2DW.js → chunk-6CZO43OH.js} +1 -1
  14. package/dist/chunk-7ALCBKCW.js +26 -0
  15. package/dist/chunk-AWXVJ5AC.js +1 -0
  16. package/dist/{chunk-GFW5QPQV.js → chunk-DQXPQOF7.js} +1 -1
  17. package/dist/chunk-ESPNEJHK.js +1 -0
  18. package/dist/chunk-G725MARR.js +16 -0
  19. package/dist/{chunk-M5L42DWE.js → chunk-HKXDP2FD.js} +2 -2
  20. package/dist/chunk-IQD6PON5.js +0 -0
  21. package/dist/chunk-IRECDTJG.js +27 -0
  22. package/dist/chunk-J4RTW44E.js +1 -0
  23. package/dist/{chunk-HGPUI7F3.js → chunk-KII2JQC5.js} +1 -1
  24. package/dist/{chunk-TI5GMJ7Q.js → chunk-L7JMDDSD.js} +1 -1
  25. package/dist/{chunk-6DZA4CLO.js → chunk-LY6U5EAD.js} +1 -1
  26. package/dist/{chunk-ERVMDQGX.js → chunk-MGCHOGQD.js} +1 -1
  27. package/dist/chunk-NZYDMBM6.js +1 -0
  28. package/dist/{chunk-Y7ZMR4LT.js → chunk-O6LE42GK.js} +1 -1
  29. package/dist/{chunk-KAB3AYA2.js → chunk-OBNING2A.js} +1 -1
  30. package/dist/chunk-P7XO5CIP.js +2 -0
  31. package/dist/{chunk-VFBLX4TG.js → chunk-T6LX2RX5.js} +1 -1
  32. package/dist/{chunk-AADJ2KIB.js → chunk-U22JNO6N.js} +1 -1
  33. package/dist/chunk-U2JKHKLK.js +0 -0
  34. package/dist/{chunk-DQF5QMJ2.js → chunk-WGGIQ7IJ.js} +1 -1
  35. package/dist/entry-10.js +1 -1
  36. package/dist/entry-11.js +1 -1
  37. package/dist/entry-12.js +1 -1
  38. package/dist/entry-13.js +1 -1
  39. package/dist/entry-14.js +1 -1
  40. package/dist/entry-15.js +1 -0
  41. package/dist/entry-17.js +1 -1
  42. package/dist/entry-18.js +1 -1
  43. package/dist/entry-19.js +1 -1
  44. package/dist/entry-20.js +1 -1
  45. package/dist/entry-21.js +1 -2
  46. package/dist/entry-22.js +2 -1
  47. package/dist/entry-23.js +1 -1
  48. package/dist/entry-24.js +1 -1
  49. package/dist/entry-25.js +1 -1
  50. package/dist/entry-26.js +1 -12
  51. package/dist/entry-27.js +12 -1
  52. package/dist/entry-28.js +1 -1
  53. package/dist/entry-29.js +1 -1
  54. package/dist/entry-30.js +1 -1
  55. package/dist/entry-31.js +1 -4
  56. package/dist/entry-32.js +3 -8
  57. package/dist/entry-33.js +9 -1
  58. package/dist/entry-34.js +1 -1
  59. package/dist/entry-35.js +1 -1
  60. package/dist/entry-36.js +1 -1
  61. package/dist/entry-37.js +1 -1
  62. package/dist/entry-38.js +1 -1
  63. package/dist/entry-39.js +1 -1
  64. package/dist/entry-40.js +1 -18
  65. package/dist/entry-41.js +18 -1
  66. package/dist/entry-42.js +1 -1
  67. package/dist/entry-43.js +1 -1
  68. package/dist/entry-44.js +1 -1
  69. package/dist/entry-45.js +1 -7
  70. package/dist/entry-46.js +7 -11
  71. package/dist/entry-47.js +11 -1
  72. package/dist/entry-48.js +1 -1
  73. package/dist/entry-49.js +1 -1
  74. package/dist/entry-50.js +1 -1
  75. package/dist/entry-51.js +1 -1
  76. package/dist/entry-52.js +1 -1
  77. package/dist/entry-53.js +1 -1
  78. package/dist/entry-54.js +1 -1
  79. package/dist/entry-55.js +1 -0
  80. package/dist/entry-56.js +0 -1
  81. package/dist/entry-57.js +1 -0
  82. package/dist/entry-58.js +0 -1
  83. package/dist/entry-59.js +1 -1
  84. package/dist/entry-60.js +1 -1
  85. package/dist/entry-61.js +1 -1
  86. package/dist/entry-62.js +1 -1
  87. package/dist/entry-63.js +1 -1
  88. package/dist/entry-64.js +1 -0
  89. package/dist/entry-65.js +0 -1
  90. package/dist/entry-66.js +1 -0
  91. package/dist/entry-67.js +0 -1
  92. package/dist/entry-68.js +1 -1
  93. package/dist/entry-69.js +1 -1
  94. package/dist/entry-70.js +1 -123
  95. package/dist/entry-71.js +198 -25
  96. package/dist/entry-72.js +30 -2
  97. package/dist/entry-73.js +2 -1
  98. package/dist/entry-74.js +1 -1
  99. package/dist/entry-75.js +1 -1
  100. package/dist/entry-76.js +3 -3
  101. package/dist/entry-77.js +3 -1
  102. package/dist/entry-78.js +1 -1
  103. package/dist/entry-79.js +1 -1
  104. package/dist/entry-8.js +1 -1
  105. package/dist/entry-80.js +1 -0
  106. package/dist/entry-9.js +1 -1
  107. package/dist/pi-agent-ide.js +3 -3
  108. package/docs/configuration.md +1 -1
  109. package/docs/development.md +0 -6
  110. package/docs/user-hooks.md +68 -0
  111. package/node_modules/pi-agent-doctor/package.json +6 -6
  112. package/node_modules/pi-agent-doctor/runtime/entry-21.js +1 -0
  113. package/node_modules/pi-agent-doctor/src/catalog.ts +9 -1
  114. package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +5 -0
  115. package/node_modules/pi-agent-filesystem/package.json +7 -7
  116. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  117. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  118. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  119. package/node_modules/pi-agent-filesystem-text/runtime/entry-25.js +2 -0
  120. package/node_modules/pi-agent-ide-ast/package.json +32 -11
  121. package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +0 -1
  122. package/node_modules/pi-agent-ide-ast/runtime/entry-27.js +2 -0
  123. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +16 -8
  124. package/node_modules/pi-agent-ide-ast/src/ast/native-parser.ts +151 -0
  125. package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +22 -17
  126. package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +25 -0
  127. package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +52 -1
  128. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +4 -1
  129. package/node_modules/pi-agent-ide-changes/index.ts +3 -1
  130. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  131. package/node_modules/pi-agent-ide-changes/runtime/entry-28.js +0 -1
  132. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +42 -9
  133. package/node_modules/pi-agent-ide-formatter/package.json +9 -4
  134. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  135. package/node_modules/pi-agent-ide-lint/package.json +13 -8
  136. package/node_modules/pi-agent-ide-lsp/index.ts +4 -1
  137. package/node_modules/pi-agent-ide-lsp/package.json +15 -10
  138. package/node_modules/pi-agent-ide-lsp/runtime/entry-33.js +2 -0
  139. package/node_modules/pi-agent-image/package.json +3 -3
  140. package/node_modules/pi-agent-invariant/package.json +2 -2
  141. package/node_modules/pi-agent-pdf/package.json +3 -3
  142. package/node_modules/pi-agent-read/package.json +11 -11
  143. package/node_modules/pi-agent-read/runtime/entry-40.js +0 -1
  144. package/node_modules/pi-agent-read/runtime/entry-41.js +2 -0
  145. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  146. package/node_modules/pi-agent-read/src/api/rendering.ts +1 -1
  147. package/node_modules/pi-agent-read/src/api/tools/read.ts +32 -0
  148. package/node_modules/pi-agent-read/src/core/read-core.ts +8 -0
  149. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +38 -4
  150. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +63 -4
  151. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +105 -5
  152. package/node_modules/pi-agent-resource/package.json +2 -2
  153. package/node_modules/pi-agent-search/package.json +7 -7
  154. package/node_modules/pi-agent-search/runtime/entry-45.js +0 -1
  155. package/node_modules/pi-agent-search/src/api/search-parameters.ts +5 -1
  156. package/node_modules/pi-agent-search-text/index.ts +1 -1
  157. package/node_modules/pi-agent-search-text/package.json +9 -9
  158. package/node_modules/pi-agent-search-text/runtime/entry-47.js +1 -0
  159. package/node_modules/pi-agent-search-text/src/resolvers.ts +72 -39
  160. package/node_modules/pi-agent-search-text/src/search-backend.ts +6 -15
  161. package/node_modules/pi-agent-search-text/src/search-presentation.ts +80 -0
  162. package/node_modules/pi-agent-search-text/src/search-renderer.ts +17 -1
  163. package/node_modules/pi-agent-search-text/src/search-result.ts +32 -12
  164. package/node_modules/pi-agent-search-text/src/search-session.ts +33 -4
  165. package/node_modules/pi-agent-text/package.json +3 -3
  166. package/node_modules/pi-agent-text/runtime/entry-49.js +1 -0
  167. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  168. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-50.js +2 -0
  169. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  170. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
  171. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-52.js +2 -0
  172. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  173. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
  174. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-54.js +2 -0
  175. package/node_modules/pi-agent-text-editor/package.json +25 -25
  176. package/node_modules/pi-agent-text-editor/runtime/entry-70.js +0 -1
  177. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +7 -1
  178. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +3 -0
  179. package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
  180. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +47 -0
  181. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +6 -1
  182. package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +155 -0
  183. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +56 -77
  184. package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +7 -12
  185. package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +2 -0
  186. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +37 -8
  187. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +42 -37
  188. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +51 -15
  189. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +119 -20
  190. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +28 -7
  191. package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +387 -0
  192. package/node_modules/pi-agent-text-editor/src/core/extension.ts +3 -2
  193. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +68 -71
  194. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +4 -4
  195. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +11 -0
  196. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
  197. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +141 -6
  198. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +123 -4
  199. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +9 -4
  200. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +3 -2
  201. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -4
  202. package/node_modules/pi-agent-text-editor-renderer/index.ts +5 -0
  203. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  204. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +59 -0
  205. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  206. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
  207. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  208. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  209. package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +1 -0
  210. package/node_modules/pi-agent-web/package.json +7 -7
  211. package/node_modules/pi-agent-web/src/resolver.ts +128 -1
  212. package/node_modules/pi-agent-web-html/package.json +3 -3
  213. package/node_modules/pi-agent-web-image/package.json +4 -4
  214. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  215. package/node_modules/pi-agent-web-text/package.json +4 -4
  216. package/node_modules/pi-agent-web-text/runtime/entry-80.js +2 -0
  217. package/package.json +59 -39
  218. package/src/api/hooks.ts +168 -0
  219. package/src/api/text-editor.ts +2 -0
  220. package/src/composite/builtin-extensions.ts +7 -0
  221. package/src/composite/module-labels.ts +8 -0
  222. package/src/composite/preferences.ts +3 -3
  223. package/src/core/reload-resource-store.ts +34 -0
  224. package/src/doctor/tip-provider.ts +1 -0
  225. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  226. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  227. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  228. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  229. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-25.js +2 -0
  230. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-22.js +2 -0
  231. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  232. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  233. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  234. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  235. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  236. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +2 -0
  237. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +2 -0
  238. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +128 -1
  239. package/src/extensions/pi-agent-read/package.json +11 -11
  240. package/src/extensions/pi-agent-read/runtime/entry-40.js +0 -1
  241. package/src/extensions/pi-agent-read/runtime/entry-41.js +2 -0
  242. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  243. package/src/extensions/pi-agent-read/src/api/rendering.ts +1 -1
  244. package/src/extensions/pi-agent-read/src/api/tools/read.ts +32 -0
  245. package/src/extensions/pi-agent-read/src/core/read-core.ts +8 -0
  246. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +38 -4
  247. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +63 -4
  248. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +105 -5
  249. package/src/extensions/pi-agent-search/package.json +7 -7
  250. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +1 -1
  251. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
  252. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-47.js +1 -0
  253. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +1 -0
  254. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +72 -39
  255. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +6 -15
  256. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +80 -0
  257. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +17 -1
  258. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +32 -12
  259. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +33 -4
  260. package/src/extensions/pi-agent-search/runtime/entry-45.js +0 -1
  261. package/src/extensions/pi-agent-search/runtime/entry-46.js +2 -0
  262. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +5 -1
  263. package/src/extensions/pi-agent-text-editor/package.json +25 -25
  264. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  265. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-50.js +2 -0
  266. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  267. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
  268. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-52.js +2 -0
  269. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  270. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
  271. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-54.js +2 -0
  272. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +5 -0
  273. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  274. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +59 -0
  275. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  276. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
  277. package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +0 -1
  278. package/src/extensions/pi-agent-text-editor/runtime/entry-71.js +2 -0
  279. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +7 -1
  280. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +3 -0
  281. package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
  282. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +47 -0
  283. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +6 -1
  284. package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +155 -0
  285. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +56 -77
  286. package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +7 -12
  287. package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +2 -0
  288. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +37 -8
  289. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +42 -37
  290. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +51 -15
  291. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +119 -20
  292. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +28 -7
  293. package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +387 -0
  294. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +3 -2
  295. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +68 -71
  296. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +4 -4
  297. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +11 -0
  298. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
  299. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +141 -6
  300. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +123 -4
  301. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +9 -4
  302. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +3 -2
  303. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -4
  304. package/src/plugins/pi-agent-ide-ast/package.json +32 -11
  305. package/src/plugins/pi-agent-ide-ast/runtime/entry-26.js +0 -1
  306. package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +2 -0
  307. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +16 -8
  308. package/src/plugins/pi-agent-ide-ast/src/ast/native-parser.ts +151 -0
  309. package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +22 -17
  310. package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +25 -0
  311. package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +52 -1
  312. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +4 -1
  313. package/src/plugins/pi-agent-ide-changes/index.ts +3 -1
  314. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  315. package/src/plugins/pi-agent-ide-changes/runtime/entry-28.js +0 -1
  316. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +42 -9
  317. package/src/plugins/pi-agent-ide-debugger/index.ts +573 -0
  318. package/src/plugins/pi-agent-ide-debugger/src/breakpoint-view.ts +73 -0
  319. package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +306 -0
  320. package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +338 -0
  321. package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +349 -0
  322. package/src/plugins/pi-agent-ide-debugger/src/process-provider.ts +39 -0
  323. package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +152 -0
  324. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +1344 -0
  325. package/src/plugins/pi-agent-ide-debugger/src/ui.ts +14 -0
  326. package/src/plugins/pi-agent-ide-formatter/package.json +9 -4
  327. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  328. package/src/plugins/pi-agent-ide-lint/package.json +13 -8
  329. package/src/plugins/pi-agent-ide-lsp/index.ts +4 -1
  330. package/src/plugins/pi-agent-ide-lsp/package.json +15 -10
  331. package/src/plugins/pi-agent-ide-lsp/runtime/entry-33.js +2 -0
  332. package/src/plugins/pi-agent-ide-processes/index.ts +28 -0
  333. package/src/plugins/pi-agent-ide-processes/src/registry.ts +83 -0
  334. package/src/plugins/pi-agent-ide-processes/src/ui.ts +260 -0
  335. package/src/plugins/pi-agent-ide-terminal/index.ts +19 -13
  336. package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +52 -0
  337. package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +31 -0
  338. package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +24 -58
  339. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +5 -14
  340. package/src/plugins/pi-agent-ide-terminal/src/search.ts +32 -2
  341. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +114 -1
  342. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +23 -29
  343. package/src/plugins/pi-agent-ide-terminal/src/types.ts +14 -1
  344. package/src/plugins/pi-agent-ide-terminal/src/ui.ts +116 -240
  345. package/dist/chunk-3SE372WC.js +0 -3
  346. package/dist/chunk-5MSNYFDE.js +0 -1
  347. package/dist/chunk-7JYQMAEL.js +0 -14
  348. package/dist/chunk-B5KB2I7J.js +0 -3
  349. package/dist/chunk-NMFQGKPE.js +0 -2
  350. package/dist/chunk-OVUYPHDE.js +0 -1
  351. package/dist/chunk-TPIHQYK2.js +0 -14
  352. package/dist/chunk-XSTHESNR.js +0 -25
  353. package/dist/entry-16.js +0 -1
  354. package/docs/evaluation.md +0 -14
  355. package/node_modules/pi-agent-doctor/runtime/entry-16.js +0 -1
  356. package/node_modules/pi-agent-filesystem/runtime/entry-21.js +0 -2
  357. package/node_modules/pi-agent-ide-ast/runtime/entry-25.js +0 -1
  358. package/node_modules/pi-agent-ide-changes/runtime/entry-27.js +0 -1
  359. package/node_modules/pi-agent-image/runtime/entry-33.js +0 -1
  360. package/node_modules/pi-agent-resource/runtime/entry-41.js +0 -1
  361. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-49.js +0 -2
  362. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
  363. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
  364. package/node_modules/pi-agent-text-editor/runtime/entry-54.js +0 -1
  365. package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +0 -1
  366. package/node_modules/pi-agent-web/runtime/entry-75.js +0 -2
  367. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-22.js +0 -2
  368. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-21.js +0 -2
  369. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +0 -2
  370. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +0 -2
  371. package/src/extensions/pi-agent-read/runtime/entry-36.js +0 -1
  372. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-46.js +0 -2
  373. package/src/extensions/pi-agent-search/runtime/entry-42.js +0 -1
  374. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-49.js +0 -2
  375. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
  376. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
  377. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-71.js +0 -2
  378. package/src/extensions/pi-agent-text-editor/runtime/entry-54.js +0 -1
  379. package/src/plugins/pi-agent-ide-ast/runtime/entry-25.js +0 -1
  380. package/src/plugins/pi-agent-ide-changes/runtime/entry-27.js +0 -1
  381. /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-22.js +0 -0
  382. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-23.js +0 -0
  383. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-24.js +0 -0
  384. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-29.js +0 -0
  385. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-30.js +0 -0
  386. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-31.js +0 -0
  387. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-32.js +0 -0
  388. /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-34.js +0 -0
  389. /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-35.js +0 -0
  390. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-36.js +0 -0
  391. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-42.js +0 -0
  392. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-46.js +0 -0
  393. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-48.js +0 -0
  394. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-71.js +0 -0
  395. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
  396. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-74.js +0 -0
  397. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-76.js +0 -0
  398. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
  399. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
  400. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
  401. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-23.js +0 -0
  402. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-24.js +0 -0
  403. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
  404. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
  405. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
  406. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
  407. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-29.js +0 -0
  408. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-30.js +0 -0
  409. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-31.js +0 -0
  410. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-32.js +0 -0
@@ -11,18 +11,23 @@ import {
11
11
 
12
12
  import { collectFiles } from "./collect-files.js";
13
13
  import { AstScopeManager, parseDocument, type ScopeEntry } from "./manager.js";
14
+ import { EXTENSION_LANGUAGES } from "./native-parser.js";
14
15
  import { readTextFile } from "./read-text.js";
15
16
 
16
- import type * as WTS from "web-tree-sitter";
17
+ import type { SyntaxNode } from "./syntax-tree.js";
17
18
 
18
19
  const SUPPORTED_EXTENSIONS = new Set([
20
+ ...Object.keys(EXTENSION_LANGUAGES),
19
21
  ".ts",
20
22
  ".tsx",
23
+ ".mts",
24
+ ".cts",
21
25
  ".js",
22
26
  ".jsx",
23
27
  ".mjs",
24
28
  ".cjs",
25
29
  ".py",
30
+ ".pyi",
26
31
  ".rs",
27
32
  ".c",
28
33
  ".cc",
@@ -271,7 +276,7 @@ export class AstOutlineManager {
271
276
  }
272
277
 
273
278
  private async createSourceViewBlock(
274
- node: WTS.Node,
279
+ node: SyntaxNode,
275
280
  filePath: string,
276
281
  displayPath: string,
277
282
  cwd: string,
@@ -387,10 +392,10 @@ function resolvePath(filePath: string, cwd: string): string {
387
392
  return path.isAbsolute(filePath) ? filePath : path.resolve(cwd, filePath);
388
393
  }
389
394
 
390
- function findSymbol(root: WTS.Node, symbol: string): WTS.Node | undefined {
391
- let result: WTS.Node | undefined;
395
+ function findSymbol(root: SyntaxNode, symbol: string): SyntaxNode | undefined {
396
+ let result: SyntaxNode | undefined;
392
397
 
393
- const visit = (node: WTS.Node): void => {
398
+ const visit = (node: SyntaxNode): void => {
394
399
  if (result) {
395
400
  return;
396
401
  }
@@ -409,7 +414,7 @@ function findSymbol(root: WTS.Node, symbol: string): WTS.Node | undefined {
409
414
  return result;
410
415
  }
411
416
 
412
- function getNodeName(node: WTS.Node): string | undefined {
417
+ function getNodeName(node: SyntaxNode): string | undefined {
413
418
  const nameField = node.childForFieldName("name");
414
419
 
415
420
  if (nameField && NAME_TYPES.has(nameField.type)) {
@@ -436,7 +441,7 @@ function getNodeName(node: WTS.Node): string | undefined {
436
441
  return undefined;
437
442
  }
438
443
 
439
- function findNestedName(node: WTS.Node): string | undefined {
444
+ function findNestedName(node: SyntaxNode): string | undefined {
440
445
  if (NAME_TYPES.has(node.type)) {
441
446
  return node.text;
442
447
  }
@@ -452,7 +457,7 @@ function findNestedName(node: WTS.Node): string | undefined {
452
457
  return undefined;
453
458
  }
454
459
 
455
- function unwrapDeclaration(node: WTS.Node): WTS.Node {
460
+ function unwrapDeclaration(node: SyntaxNode): SyntaxNode {
456
461
  const parent = node.parent;
457
462
 
458
463
  if (
@@ -473,7 +478,7 @@ interface MappedCharacter {
473
478
  }
474
479
 
475
480
  function renderNodeLines(
476
- node: WTS.Node,
481
+ node: SyntaxNode,
477
482
  source: string,
478
483
  extension: string,
479
484
  maxDepth: number,
@@ -573,7 +578,7 @@ function mapReplacement(replacement: Replacement): MappedCharacter[] {
573
578
  }
574
579
 
575
580
  function collapseDeepNode(
576
- node: WTS.Node,
581
+ node: SyntaxNode,
577
582
  replacements: Replacement[],
578
583
  depth: number,
579
584
  maxDepth: number,
@@ -588,7 +593,7 @@ function collapseDeepNode(
588
593
  return true;
589
594
  }
590
595
  function collectDataReplacements(
591
- node: WTS.Node,
596
+ node: SyntaxNode,
592
597
  extension: string,
593
598
  replacements: Replacement[],
594
599
  maxDepth: number,
@@ -613,7 +618,7 @@ function collectDataReplacements(
613
618
  }
614
619
  }
615
620
 
616
- function isDataScalar(node: WTS.Node, extension: string): boolean {
621
+ function isDataScalar(node: SyntaxNode, extension: string): boolean {
617
622
  const scalarTypes =
618
623
  extension === ".json" || extension === ".jsonc"
619
624
  ? ["string", "number", "true", "false", "null"]
@@ -641,7 +646,7 @@ function isDataScalar(node: WTS.Node, extension: string): boolean {
641
646
  return scalarTypes.includes(node.type);
642
647
  }
643
648
 
644
- function isDataKey(node: WTS.Node): boolean {
649
+ function isDataKey(node: SyntaxNode): boolean {
645
650
  let ancestor = node.parent;
646
651
 
647
652
  while (
@@ -658,7 +663,7 @@ function isDataKey(node: WTS.Node): boolean {
658
663
  }
659
664
 
660
665
  function collectReplacements(
661
- node: WTS.Node,
666
+ node: SyntaxNode,
662
667
  extension: string,
663
668
  replacements: Replacement[],
664
669
  topLevel: boolean,
@@ -718,7 +723,7 @@ function collectReplacements(
718
723
  }
719
724
  }
720
725
 
721
- function isTopLevelInterfaceNode(node: WTS.Node): boolean {
726
+ function isTopLevelInterfaceNode(node: SyntaxNode): boolean {
722
727
  return (
723
728
  DECLARATION_TYPES.has(node.type) ||
724
729
  IMPORT_TYPES.has(node.type) ||
@@ -727,7 +732,7 @@ function isTopLevelInterfaceNode(node: WTS.Node): boolean {
727
732
  );
728
733
  }
729
734
 
730
- function findBody(node: WTS.Node): WTS.Node | undefined {
735
+ function findBody(node: SyntaxNode): SyntaxNode | undefined {
731
736
  const fieldBody = node.childForFieldName("body");
732
737
 
733
738
  if (fieldBody) {
@@ -747,7 +752,7 @@ interface BodyPlaceholder {
747
752
  readonly lineSourceLines: readonly (number | undefined)[];
748
753
  }
749
754
 
750
- function renderBodyPlaceholder(body: WTS.Node, extension: string): BodyPlaceholder {
755
+ function renderBodyPlaceholder(body: SyntaxNode, extension: string): BodyPlaceholder {
751
756
  const startLine = body.startPosition.row + 1;
752
757
  const endLine = body.endPosition.row + 1;
753
758
 
@@ -0,0 +1,25 @@
1
+ export interface SyntaxPosition {
2
+ readonly row: number;
3
+ readonly column: number;
4
+ }
5
+
6
+ /** Parser-neutral syntax node used by AST outlines and scope anchors. */
7
+ export interface SyntaxNode {
8
+ readonly type: string;
9
+ readonly text: string;
10
+ readonly isNamed: boolean;
11
+ readonly hasError: boolean;
12
+ readonly startIndex: number;
13
+ readonly endIndex: number;
14
+ readonly startPosition: SyntaxPosition;
15
+ readonly endPosition: SyntaxPosition;
16
+ readonly parent: SyntaxNode | null;
17
+ readonly namedChildren: readonly SyntaxNode[];
18
+ readonly namedChildCount: number;
19
+ childForFieldName(name: string): SyntaxNode | null;
20
+ }
21
+
22
+ /** Parser-neutral syntax tree used by AST read views. */
23
+ export interface SyntaxTree {
24
+ readonly rootNode: SyntaxNode;
25
+ }
@@ -9,9 +9,38 @@ import { parseDocument } from "./ast/manager.js";
9
9
 
10
10
  import type { DoctorPlugin } from "pi-agent-doctor/api/plugin-protocol";
11
11
 
12
+ const unsupportedReasons: Readonly<Record<string, string>> = {
13
+ cmake: "no compatible Tree-sitter parser is packaged",
14
+ dockerfile: "no compatible Tree-sitter parser is packaged",
15
+ julia: "no compatible Tree-sitter parser is packaged",
16
+ powershell: "no compatible Tree-sitter parser is packaged",
17
+ r: "no compatible Tree-sitter parser is packaged",
18
+ svelte: "the container grammar is not available as an ast-grep language package",
19
+ terraform: "the HCL grammar is not available as an ast-grep language package",
20
+ vue: "the container grammar is not available as an ast-grep language package",
21
+ xml: "no compatible Tree-sitter parser is packaged",
22
+ zig: "no compatible Tree-sitter parser is packaged",
23
+ };
24
+
12
25
  const supported = new Set([
13
26
  "c",
14
27
  "cpp",
28
+ "csharp",
29
+ "css",
30
+ "dart",
31
+ "elixir",
32
+ "go",
33
+ "html",
34
+ "java",
35
+ "kotlin",
36
+ "lua",
37
+ "markdown",
38
+ "php",
39
+ "ruby",
40
+ "scala",
41
+ "shell",
42
+ "sql",
43
+ "swift",
15
44
  "javascript",
16
45
  "typescript",
17
46
  "python",
@@ -59,9 +88,15 @@ export const astDoctorPlugin: DoctorPlugin = {
59
88
  const findings = [];
60
89
 
61
90
  for (const language of context.detectedLanguageIds) {
62
- if (!supported.has(language)) {
91
+ const unsupportedReason = unsupportedReasons[language];
92
+ if (unsupportedReason !== undefined) {
93
+ findings.push({
94
+ status: "skip" as const,
95
+ message: `${language} AST is unavailable: ${unsupportedReason}`,
96
+ });
63
97
  continue;
64
98
  }
99
+ if (!supported.has(language)) continue;
65
100
 
66
101
  const file = context.files.find((candidate) => matchesLanguage(candidate, language));
67
102
 
@@ -118,6 +153,22 @@ function matchesLanguage(file: string, language: string): boolean {
118
153
  const extensions: Record<string, readonly string[]> = {
119
154
  c: [".c", ".h"],
120
155
  cpp: [".cc", ".cpp", ".cxx", ".hh", ".hpp", ".hxx"],
156
+ csharp: [".cs"],
157
+ css: [".css", ".scss", ".less"],
158
+ dart: [".dart"],
159
+ elixir: [".ex", ".exs"],
160
+ go: [".go"],
161
+ html: [".html", ".htm"],
162
+ java: [".java"],
163
+ kotlin: [".kt", ".kts"],
164
+ lua: [".lua"],
165
+ markdown: [".md", ".mdx"],
166
+ php: [".php"],
167
+ ruby: [".rb", ".rake"],
168
+ scala: [".scala", ".sc"],
169
+ shell: [".sh", ".bash"],
170
+ sql: [".sql"],
171
+ swift: [".swift"],
121
172
  javascript: [".js", ".jsx", ".mjs", ".cjs"],
122
173
  typescript: [".ts", ".tsx", ".mts", ".cts"],
123
174
  python: [".py", ".pyi"],
@@ -59,7 +59,10 @@ export function createAstSearchResolver(
59
59
  kind: "resolved",
60
60
  payload: {
61
61
  pattern,
62
- matches: selected.raw,
62
+ matches: selected.raw.map((match, index) => ({
63
+ ...match,
64
+ selection: selected.matches[index],
65
+ })),
63
66
  complete: selected.complete,
64
67
  sessionId: session.id,
65
68
  },
@@ -57,7 +57,9 @@ export default async function registerGitChanges(pi: ExtensionAPI): Promise<void
57
57
  api.onDidEdit((completion) => {
58
58
  transactions.observe(completion);
59
59
  });
60
- api.addMutationTool(createUndoMutationTool(executor, transactions, indexQueue));
60
+ api.addMutationTool(
61
+ createUndoMutationTool(executor, transactions, indexQueue, api.restoreApplyUndo),
62
+ );
61
63
  for (const action of ["stage", "unstage"] as const) {
62
64
  const tool = createIndexChangeTool(action, executor, indexQueue);
63
65
  api.addScriptIndexOperation({
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-ide-changes",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -8,20 +8,20 @@
8
8
  "exports": {
9
9
  "./changes/change-groups": {
10
10
  "types": "./src/changes/change-groups.ts",
11
- "default": "./runtime/entry-27.js"
11
+ "default": "./runtime/entry-28.js"
12
12
  }
13
13
  },
14
14
  "dependencies": {
15
15
  "diff": "^9.0.0",
16
- "pi-agent-doctor": "0.4.0",
17
- "pi-agent-invariant": "0.4.0",
18
- "pi-agent-read": "0.4.0",
19
- "pi-agent-text": "0.4.0",
20
- "pi-agent-text-editor": "0.4.0"
16
+ "pi-agent-doctor": "0.5.1",
17
+ "pi-agent-invariant": "0.5.1",
18
+ "pi-agent-read": "0.5.1",
19
+ "pi-agent-text": "0.5.1",
20
+ "pi-agent-text-editor": "0.5.1"
21
21
  },
22
22
  "pi": {
23
23
  "extensions": [
24
- "./runtime/entry-28.js"
24
+ "./runtime/entry-29.js"
25
25
  ]
26
26
  },
27
27
  "peerDependencies": {
@@ -1,2 +1 @@
1
1
  export * from "../../../../dist/entry-28.js";
2
- export { default } from "../../../../dist/entry-28.js";
@@ -16,31 +16,62 @@ export const undoSchema = Type.Object(
16
16
  description: "File to restore; may be omitted to inherit the previous batched source",
17
17
  }),
18
18
  ),
19
- change: Type.String({
20
- description:
21
- "Complete CHANGE#HASH anchor shown by read, or last for this file's latest text-editor transaction",
22
- pattern: "^(?:CHANGE#[0-9A-F]{4,64}|last)$",
23
- }),
19
+ change: Type.Optional(
20
+ Type.String({
21
+ description:
22
+ "Complete CHANGE#HASH anchor shown by read, or last for this file's latest text-editor transaction",
23
+ pattern: "^(?:CHANGE#[0-9A-F]{4,64}|last)$",
24
+ }),
25
+ ),
26
+ transaction: Type.Optional(
27
+ Type.String({
28
+ description: "APPLY# receipt returned by a successful Apply transaction",
29
+ pattern: "^APPLY#[0-9A-F]{12}$",
30
+ }),
31
+ ),
24
32
  },
25
33
  { additionalProperties: false },
26
34
  );
27
35
 
28
36
  interface UndoParameters {
29
37
  readonly file?: string;
30
- readonly change: string;
38
+ readonly change?: string;
39
+ readonly transaction?: string;
31
40
  }
32
41
 
33
42
  export function createUndoMutationTool(
34
43
  executor: GitCommandExecutor,
35
44
  transactions: LastTextTransactionStore,
36
45
  queue: IndexMutationQueue,
46
+ restoreApplyUndo: (
47
+ transaction: string,
48
+ signal?: AbortSignal,
49
+ ) => Promise<{ readonly transaction: string; readonly restored: readonly string[] }>,
37
50
  ): TextMutationToolRegistration<typeof undoSchema> {
38
51
  return {
39
52
  name: "undo",
40
53
  description:
41
- "Use undo to revert a selected uncommitted Git change or the latest text-editor transaction for one file. A CHANGE# anchor restores that change to HEAD in both worktree and index; last restores the file's state before its latest text-editor transaction.",
42
-
43
- promptSnippet: "Restore a Git change or the latest text edit",
54
+ "Use undo to revert an APPLY# transaction receipt, a selected uncommitted Git change, or the latest text-editor transaction for one file. Apply receipts restore every touched path atomically; CHANGE# restores that change to HEAD in both worktree and index; last restores one file's latest text edit.",
55
+
56
+ promptSnippet: "Restore an Apply transaction, Git change, or latest text edit",
57
+ direct: {
58
+ matches: (input) =>
59
+ input !== null &&
60
+ typeof input === "object" &&
61
+ "transaction" in input &&
62
+ typeof input.transaction === "string",
63
+ async execute(context, input) {
64
+ if ((input as UndoParameters).change !== undefined)
65
+ throw new Error("transaction cannot be combined with change");
66
+ const transaction = String((input as UndoParameters).transaction);
67
+ const restored = await restoreApplyUndo(transaction, context.signal);
68
+ return {
69
+ source: transaction,
70
+ summary: `Restored ${String(restored.restored.length)} paths from ${transaction}.`,
71
+ data: { kind: "apply-undo", ok: true, transaction, restored: restored.restored },
72
+ };
73
+ },
74
+ },
44
75
  parameters: undoSchema,
45
76
  intent: "restore",
46
77
  source: { field: "file", inherited: true },
@@ -53,6 +84,8 @@ export function createUndoMutationTool(
53
84
  },
54
85
  ],
55
86
  async mutate(context, parameters: UndoParameters) {
87
+ if (parameters.change === undefined)
88
+ throw new Error("change is required when transaction is omitted");
56
89
  const source = context.sourceFor("file");
57
90
  let restoredText: string;
58
91
  let afterWrite: (() => Promise<void>) | undefined;