pi-agent-ide 0.8.3 → 0.9.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 (606) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +24 -29
  3. package/dist/chunk-2AY526TN.js +3 -0
  4. package/dist/{chunk-LEJKDYCK.js → chunk-2TZDG2JH.js} +1 -1
  5. package/dist/{chunk-XBQR74IK.js → chunk-4GBFIGH3.js} +1 -1
  6. package/dist/{chunk-PJL3UVMJ.js → chunk-4IWEKRSP.js} +1 -1
  7. package/dist/chunk-52PFWQMU.js +5 -0
  8. package/dist/chunk-5BGWNYQS.js +1 -0
  9. package/dist/{chunk-QUYXINGZ.js → chunk-5S74Z6Y4.js} +3 -3
  10. package/dist/chunk-64JTD2DJ.js +1 -0
  11. package/dist/{chunk-XAHU42FP.js → chunk-6A3ORNW3.js} +2 -2
  12. package/dist/{chunk-ANM3Y5FO.js → chunk-6WCHBHFW.js} +5 -5
  13. package/dist/{chunk-IMGIDBCC.js → chunk-7D7PXIVV.js} +1 -1
  14. package/dist/chunk-7PVDTMEM.js +1 -0
  15. package/dist/chunk-7SG756UO.js +4 -0
  16. package/dist/{chunk-GBUJOR6V.js → chunk-7URANI6I.js} +14 -14
  17. package/dist/{chunk-4W7GH3T7.js → chunk-AJZVKDYC.js} +1 -1
  18. package/dist/chunk-AMIIOWFL.js +1 -0
  19. package/dist/{chunk-TOYN4W4F.js → chunk-B25LXXNV.js} +1 -1
  20. package/dist/chunk-C2JT2G5K.js +1 -0
  21. package/dist/chunk-CVOYSEBE.js +1 -0
  22. package/dist/chunk-DDH3FP4G.js +3 -0
  23. package/dist/chunk-FEZLTM4L.js +1 -0
  24. package/dist/{chunk-CPELC6JE.js → chunk-FHRHYY4M.js} +1 -1
  25. package/dist/chunk-FKKAHI62.js +11 -0
  26. package/dist/chunk-FS3KCKFX.js +9 -0
  27. package/dist/chunk-FYOU4RBH.js +2 -0
  28. package/dist/chunk-G4PRFO6G.js +1 -0
  29. package/dist/chunk-GS5ZRTUG.js +1 -0
  30. package/dist/{chunk-XXLLY66B.js → chunk-GXL4NMHR.js} +1 -1
  31. package/dist/{chunk-QT3EAHOG.js → chunk-H3GEEOOL.js} +1 -1
  32. package/dist/chunk-H5Z54BEU.js +25 -0
  33. package/dist/chunk-H7WAM5RH.js +23 -0
  34. package/dist/chunk-HT7LZN5A.js +9 -0
  35. package/dist/chunk-IG5DXVDJ.js +1 -0
  36. package/dist/chunk-K4UTEMDU.js +1 -0
  37. package/dist/chunk-KFBRL2V4.js +3 -0
  38. package/dist/chunk-KN6VPARZ.js +1 -0
  39. package/dist/{chunk-RW2GTYQI.js → chunk-LF325WYO.js} +1 -1
  40. package/dist/chunk-LTADNZKW.js +2 -0
  41. package/dist/{chunk-YJ6T3PEP.js → chunk-MDD5ORB6.js} +1 -1
  42. package/dist/{chunk-S72FVLUX.js → chunk-MLFJU2US.js} +1 -1
  43. package/dist/chunk-NA2NEU4V.js +1 -0
  44. package/dist/chunk-OBTT5INC.js +6 -0
  45. package/dist/{chunk-IICJXZBU.js → chunk-OMNKD7WW.js} +3 -3
  46. package/dist/chunk-PLMHBXWI.js +10 -0
  47. package/dist/{chunk-235QMMVA.js → chunk-PQWANILR.js} +1 -1
  48. package/dist/{chunk-QRJLIV6P.js → chunk-QJ6V5IAY.js} +6 -6
  49. package/dist/chunk-QM5WDEFI.js +1 -0
  50. package/dist/{chunk-SMIFCAAX.js → chunk-RIJRPAL2.js} +1 -1
  51. package/dist/chunk-RIOPUTUJ.js +6 -0
  52. package/dist/chunk-RVFMH77U.js +82 -0
  53. package/dist/{chunk-NJ7C4KMA.js → chunk-SRFWT562.js} +1 -1
  54. package/dist/{chunk-U22JNO6N.js → chunk-STUZZM5B.js} +1 -1
  55. package/dist/{chunk-PT35ZFLH.js → chunk-TNAUCNUT.js} +12 -12
  56. package/dist/{chunk-DUUOCBS3.js → chunk-TVH2ND35.js} +1 -1
  57. package/dist/chunk-TVSZYABY.js +5 -0
  58. package/dist/chunk-TVXZE4KW.js +4 -0
  59. package/dist/chunk-U7YDLVFL.js +1 -0
  60. package/dist/{chunk-KZC7TI5M.js → chunk-UD3DMY3Q.js} +1 -1
  61. package/dist/{chunk-VXP5BMW7.js → chunk-USG6WHAT.js} +1 -1
  62. package/dist/{chunk-RMI3NMQY.js → chunk-V4J3TLCV.js} +2 -2
  63. package/dist/{chunk-ZPT5D4VP.js → chunk-VDJSH3DQ.js} +2 -2
  64. package/dist/{chunk-VMTOFEXF.js → chunk-VMLPXSMK.js} +1 -1
  65. package/dist/{chunk-6T7PSDQW.js → chunk-VN3XBH2Q.js} +1 -1
  66. package/dist/chunk-WAJW4G4F.js +22 -0
  67. package/dist/chunk-WEE3NM6L.js +1 -0
  68. package/dist/{chunk-IM24DB3K.js → chunk-WES2E4VR.js} +1 -1
  69. package/dist/{chunk-RIJMXO43.js → chunk-WQIMM4SU.js} +1 -1
  70. package/dist/chunk-WUO3UW4J.js +17 -0
  71. package/dist/chunk-XE4W5YTE.js +2 -0
  72. package/dist/chunk-XUYIK4TX.js +1 -0
  73. package/dist/{chunk-ZJQRLVVV.js → chunk-Y74EKJOY.js} +1 -1
  74. package/dist/{chunk-AAC77UD4.js → chunk-YPYROPQF.js} +1 -1
  75. package/dist/chunk-ZXO4D5UB.js +1 -0
  76. package/dist/entry-0.js +1 -1
  77. package/dist/entry-1.js +1 -1
  78. package/dist/entry-10.js +1 -1
  79. package/dist/entry-11.js +1 -1
  80. package/dist/entry-12.js +1 -1
  81. package/dist/entry-13.js +1 -1
  82. package/dist/entry-14.js +1 -1
  83. package/dist/entry-15.js +1 -1
  84. package/dist/entry-16.js +1 -1
  85. package/dist/entry-17.js +1 -1
  86. package/dist/entry-18.js +1 -1
  87. package/dist/entry-19.js +1 -1
  88. package/dist/entry-2.js +1 -1
  89. package/dist/entry-20.js +1 -1
  90. package/dist/entry-21.js +1 -0
  91. package/dist/entry-23.js +1 -1
  92. package/dist/entry-24.js +1 -1
  93. package/dist/entry-25.js +1 -1
  94. package/dist/entry-26.js +1 -1
  95. package/dist/entry-27.js +1 -1
  96. package/dist/entry-28.js +1 -1
  97. package/dist/entry-29.js +1 -2
  98. package/dist/entry-3.js +1 -1
  99. package/dist/entry-30.js +2 -1
  100. package/dist/entry-31.js +1 -4
  101. package/dist/entry-32.js +1 -1
  102. package/dist/entry-33.js +1 -1
  103. package/dist/entry-34.js +1 -1
  104. package/dist/entry-35.js +1 -18
  105. package/dist/entry-36.js +1 -1
  106. package/dist/entry-37.js +15 -1
  107. package/dist/entry-38.js +1 -1
  108. package/dist/entry-39.js +1 -1
  109. package/dist/entry-4.js +1 -1
  110. package/dist/entry-40.js +1 -1
  111. package/dist/entry-41.js +1 -1
  112. package/dist/entry-42.js +1 -1
  113. package/dist/entry-43.js +1 -1
  114. package/dist/entry-44.js +1 -1
  115. package/dist/entry-45.js +1 -1
  116. package/dist/entry-46.js +1 -1
  117. package/dist/entry-47.js +1 -1
  118. package/dist/entry-48.js +1 -1
  119. package/dist/entry-49.js +1 -25
  120. package/dist/entry-5.js +1 -1
  121. package/dist/entry-50.js +1 -1
  122. package/dist/entry-51.js +1 -1
  123. package/dist/entry-52.js +1 -1
  124. package/dist/entry-53.js +1 -1
  125. package/dist/entry-54.js +1 -3
  126. package/dist/entry-55.js +1 -13
  127. package/dist/entry-56.js +1 -1
  128. package/dist/entry-57.js +1 -1
  129. package/dist/entry-58.js +1 -1
  130. package/dist/entry-59.js +1 -1
  131. package/dist/entry-6.js +1 -1
  132. package/dist/entry-60.js +1 -1
  133. package/dist/entry-61.js +1 -1
  134. package/dist/entry-62.js +1 -1
  135. package/dist/entry-63.js +1 -1
  136. package/dist/entry-64.js +1 -1
  137. package/dist/entry-65.js +1 -0
  138. package/dist/entry-66.js +1 -1
  139. package/dist/entry-68.js +1 -1
  140. package/dist/entry-69.js +0 -1
  141. package/dist/entry-7.js +1 -1
  142. package/dist/entry-70.js +1 -1
  143. package/dist/entry-71.js +1 -1
  144. package/dist/entry-72.js +1 -1
  145. package/dist/entry-73.js +1 -1
  146. package/dist/entry-74.js +1 -1
  147. package/dist/entry-75.js +1 -0
  148. package/dist/entry-76.js +1 -1
  149. package/dist/entry-78.js +1 -1
  150. package/dist/entry-79.js +0 -1
  151. package/dist/entry-8.js +1 -1
  152. package/dist/entry-80.js +1 -1
  153. package/dist/entry-81.js +1 -80
  154. package/dist/entry-82.js +1 -22
  155. package/dist/entry-83.js +1 -2
  156. package/dist/entry-84.js +1 -1
  157. package/dist/entry-85.js +2 -1
  158. package/dist/entry-86.js +1 -1
  159. package/dist/entry-87.js +1 -1
  160. package/dist/entry-88.js +1 -3
  161. package/dist/entry-89.js +1 -1
  162. package/dist/entry-9.js +1 -1
  163. package/dist/entry-90.js +3 -1
  164. package/dist/entry-91.js +1 -1
  165. package/dist/entry-92.js +1 -0
  166. package/dist/entry-93.js +1 -0
  167. package/dist/pi-agent-ide.js +10 -34
  168. package/docs/agent-guides/ast-search.md +58 -0
  169. package/docs/agent-guides/debugger.md +1 -1
  170. package/docs/agent-guides/editing.md +26 -58
  171. package/docs/agent-guides/git-changes.md +4 -14
  172. package/docs/agent-guides/search.md +38 -0
  173. package/docs/agent-guides/ssh.md +17 -49
  174. package/docs/agent-guides/terminal.md +9 -15
  175. package/docs/configuration.md +9 -13
  176. package/docs/extensions.md +82 -0
  177. package/docs/settings-help.md +2 -2
  178. package/docs/structured-results.md +33 -11
  179. package/docs/tools.md +23 -22
  180. package/node_modules/pi-agent-doctor/package.json +7 -7
  181. package/node_modules/pi-agent-doctor/src/workspace.ts +0 -5
  182. package/node_modules/pi-agent-documentation/package.json +2 -2
  183. package/node_modules/pi-agent-documentation/runtime/entry-29.js +1 -0
  184. package/node_modules/pi-agent-documentation/src/index.ts +26 -10
  185. package/node_modules/pi-agent-filesystem/index.ts +1 -1
  186. package/node_modules/pi-agent-filesystem/package.json +8 -8
  187. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  188. package/node_modules/pi-agent-filesystem-jq/index.ts +9 -63
  189. package/node_modules/pi-agent-filesystem-jq/package.json +12 -6
  190. package/node_modules/pi-agent-filesystem-jq/runtime/entry-32.js +1 -0
  191. package/node_modules/pi-agent-filesystem-jq/src/api/jq.ts +112 -0
  192. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  193. package/node_modules/pi-agent-filesystem-pdf/runtime/entry-34.js +2 -0
  194. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  195. package/node_modules/pi-agent-ide-ast/package.json +15 -15
  196. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +13 -1
  197. package/node_modules/pi-agent-ide-ast/src/extension.ts +8 -8
  198. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +104 -26
  199. package/node_modules/pi-agent-ide-ast/src/tool-ast-search.ts +210 -0
  200. package/node_modules/pi-agent-ide-changes/index.ts +1 -2
  201. package/node_modules/pi-agent-ide-changes/package.json +10 -10
  202. package/node_modules/pi-agent-ide-changes/runtime/entry-38.js +1 -0
  203. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +3 -3
  204. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  205. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  206. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  207. package/node_modules/pi-agent-ide-lint/runtime/entry-42.js +2 -0
  208. package/node_modules/pi-agent-ide-lsp/index.ts +22 -28
  209. package/node_modules/pi-agent-ide-lsp/package.json +14 -10
  210. package/node_modules/pi-agent-ide-lsp/runtime/entry-43.js +2 -0
  211. package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +1 -1
  212. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +8 -84
  213. package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +1 -6
  214. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +11 -11
  215. package/node_modules/pi-agent-ide-lsp/src/manager-provider.ts +8 -0
  216. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +1 -1
  217. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +234 -36
  218. package/node_modules/pi-agent-ide-lsp/src/tool-lsp-search.ts +212 -0
  219. package/node_modules/pi-agent-image/package.json +3 -3
  220. package/node_modules/pi-agent-image/src/image-converter.ts +24 -1
  221. package/node_modules/pi-agent-invariant/package.json +2 -2
  222. package/node_modules/pi-agent-pdf/package.json +3 -3
  223. package/node_modules/pi-agent-pdf/src/pdf-converter.ts +23 -1
  224. package/node_modules/pi-agent-read/package.json +12 -12
  225. package/node_modules/pi-agent-read/runtime/entry-49.js +0 -1
  226. package/node_modules/pi-agent-read/runtime/entry-51.js +2 -0
  227. package/node_modules/pi-agent-read/src/api/read-parameters.ts +4 -7
  228. package/node_modules/pi-agent-read/src/api/tools/read.ts +2 -0
  229. package/node_modules/pi-agent-read/src/core/extension.ts +0 -8
  230. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +47 -14
  231. package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +3 -1
  232. package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +14 -2
  233. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +21 -8
  234. package/node_modules/pi-agent-resource/package.json +2 -2
  235. package/node_modules/pi-agent-resource/src/index.ts +8 -0
  236. package/node_modules/pi-agent-resource/src/resource-error-metadata.ts +89 -0
  237. package/node_modules/pi-agent-resource/src/resource-error.ts +6 -1
  238. package/node_modules/pi-agent-resource/src/result-images.ts +87 -0
  239. package/node_modules/pi-agent-resource/src/result-targets.ts +9 -3
  240. package/node_modules/pi-agent-resource/src/tool-result.ts +17 -0
  241. package/node_modules/pi-agent-search/package.json +9 -9
  242. package/node_modules/pi-agent-search/runtime/entry-54.js +0 -1
  243. package/node_modules/pi-agent-search/runtime/entry-55.js +1 -0
  244. package/node_modules/pi-agent-search/runtime/entry-56.js +2 -0
  245. package/node_modules/pi-agent-search/src/api/glob-list.ts +35 -0
  246. package/node_modules/pi-agent-search/src/api/search-parameters.ts +8 -8
  247. package/node_modules/pi-agent-search/src/api/search.ts +14 -2
  248. package/node_modules/pi-agent-search/src/core/extension.ts +11 -20
  249. package/node_modules/pi-agent-search/src/core/search-core.ts +30 -10
  250. package/node_modules/pi-agent-search-text/index.ts +34 -12
  251. package/node_modules/pi-agent-search-text/package.json +17 -15
  252. package/node_modules/pi-agent-search-text/runtime/entry-57.js +1 -0
  253. package/node_modules/pi-agent-search-text/runtime/entry-60.js +1 -0
  254. package/node_modules/pi-agent-search-text/src/file-search.ts +59 -25
  255. package/node_modules/pi-agent-search-text/src/resolvers.ts +61 -16
  256. package/node_modules/pi-agent-search-text/src/scoped-search.ts +9 -3
  257. package/node_modules/pi-agent-search-text/src/search-backend.ts +44 -48
  258. package/node_modules/pi-agent-search-text/src/search-presentation.ts +19 -15
  259. package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -1
  260. package/node_modules/pi-agent-search-text/src/search-result.ts +6 -2
  261. package/node_modules/pi-agent-search-text/src/search-session.ts +1 -0
  262. package/node_modules/pi-agent-search-text/src/tool-file-search.ts +146 -0
  263. package/node_modules/pi-agent-text/package.json +3 -3
  264. package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
  265. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  266. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  267. package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +6 -1
  268. package/node_modules/pi-agent-text-anchor-line-hash/index.ts +1 -2
  269. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  270. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-66.js +2 -0
  271. package/node_modules/pi-agent-text-editor/package.json +26 -26
  272. package/node_modules/pi-agent-text-editor/runtime/entry-81.js +0 -1
  273. package/node_modules/pi-agent-text-editor/runtime/entry-82.js +1 -0
  274. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +2 -0
  275. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +23 -0
  276. package/node_modules/pi-agent-text-editor/src/api/text-selection-anchor.ts +31 -1
  277. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +11 -21
  278. package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +5 -5
  279. package/node_modules/pi-agent-text-editor/src/core/extension.ts +13 -7
  280. package/node_modules/pi-agent-text-editor/src/core/file-operation-guards.ts +22 -4
  281. package/node_modules/pi-agent-text-editor/src/core/image-write.ts +111 -0
  282. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +3 -0
  283. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +5 -1
  284. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +8 -2
  285. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +103 -20
  286. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +146 -62
  287. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +14 -19
  288. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +43 -12
  289. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +5 -5
  290. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +6 -5
  291. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +3 -7
  292. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +6 -8
  293. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -6
  294. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +3 -4
  295. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +37 -22
  296. package/node_modules/pi-agent-text-editor-renderer/index.ts +6 -1
  297. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  298. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-84.js +2 -0
  299. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +18 -5
  300. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +6 -6
  301. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-85.js +2 -0
  302. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  303. package/node_modules/pi-agent-tool-ui/package.json +3 -3
  304. package/node_modules/pi-agent-tool-ui/runtime/entry-87.js +1 -0
  305. package/node_modules/pi-agent-tool-ui/runtime/entry-88.js +1 -0
  306. package/node_modules/pi-agent-web/index.ts +28 -6
  307. package/node_modules/pi-agent-web/package.json +8 -8
  308. package/node_modules/pi-agent-web-html/package.json +3 -3
  309. package/node_modules/pi-agent-web-html/src/html-converter.ts +1 -1
  310. package/node_modules/pi-agent-web-image/package.json +4 -4
  311. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  312. package/node_modules/pi-agent-web-pdf/runtime/entry-92.js +2 -0
  313. package/node_modules/pi-agent-web-text/package.json +4 -4
  314. package/node_modules/pi-agent-web-text/runtime/entry-93.js +2 -0
  315. package/package.json +61 -58
  316. package/src/api/approval.ts +2 -0
  317. package/src/api/read.ts +2 -0
  318. package/src/api/standalone.ts +7 -0
  319. package/src/backend/doctor-workspace.ts +0 -3
  320. package/src/backend/process-metadata-worker.py +9 -18
  321. package/src/backend/process-metadata.ts +11 -44
  322. package/src/backend/registration.ts +0 -10
  323. package/src/backend/web-browser-worker.mjs +2 -17
  324. package/src/backend/web-browser.ts +1 -26
  325. package/src/composite/builtin-extensions.ts +8 -6
  326. package/src/composite/ide-alias-rendering.ts +18 -2
  327. package/src/composite/module-labels.ts +0 -4
  328. package/src/composite/preferences.ts +0 -36
  329. package/src/composite/settings-documentation.ts +1 -2
  330. package/src/composite/text-results.ts +61 -23
  331. package/src/documentation/extension.ts +39 -15
  332. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +1 -1
  333. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
  334. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  335. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +9 -63
  336. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +12 -6
  337. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-32.js +1 -0
  338. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/api/jq.ts +112 -0
  339. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  340. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-34.js +2 -0
  341. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  342. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-35.js +2 -0
  343. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-30.js +2 -0
  344. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +28 -6
  345. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
  346. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  347. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +1 -1
  348. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  349. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  350. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-92.js +2 -0
  351. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  352. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-93.js +2 -0
  353. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-89.js +2 -0
  354. package/src/extensions/pi-agent-read/package.json +12 -12
  355. package/src/extensions/pi-agent-read/runtime/entry-49.js +0 -1
  356. package/src/extensions/pi-agent-read/runtime/entry-50.js +1 -0
  357. package/src/extensions/pi-agent-read/runtime/entry-51.js +2 -0
  358. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +4 -7
  359. package/src/extensions/pi-agent-read/src/api/tools/read.ts +2 -0
  360. package/src/extensions/pi-agent-read/src/core/extension.ts +0 -8
  361. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +47 -14
  362. package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +3 -1
  363. package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +14 -2
  364. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +21 -8
  365. package/src/extensions/pi-agent-search/package.json +9 -9
  366. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +34 -12
  367. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +17 -15
  368. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-57.js +1 -0
  369. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-59.js +1 -0
  370. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-60.js +1 -0
  371. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +59 -25
  372. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +61 -16
  373. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +9 -3
  374. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +44 -48
  375. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +19 -15
  376. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -1
  377. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +6 -2
  378. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +1 -0
  379. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/tool-file-search.ts +146 -0
  380. package/src/extensions/pi-agent-search/runtime/entry-54.js +0 -1
  381. package/src/extensions/pi-agent-search/runtime/entry-55.js +1 -0
  382. package/src/extensions/pi-agent-search/runtime/entry-56.js +2 -0
  383. package/src/extensions/pi-agent-search/src/api/glob-list.ts +35 -0
  384. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +8 -8
  385. package/src/extensions/pi-agent-search/src/api/search.ts +14 -2
  386. package/src/extensions/pi-agent-search/src/core/extension.ts +11 -20
  387. package/src/extensions/pi-agent-search/src/core/search-core.ts +30 -10
  388. package/src/extensions/pi-agent-text-editor/package.json +26 -26
  389. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  390. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  391. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +6 -1
  392. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +1 -2
  393. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  394. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-65.js +1 -0
  395. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-66.js +2 -0
  396. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +6 -1
  397. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  398. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-84.js +2 -0
  399. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +18 -5
  400. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +6 -6
  401. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-85.js +2 -0
  402. package/src/extensions/pi-agent-text-editor/runtime/entry-81.js +0 -1
  403. package/src/extensions/pi-agent-text-editor/runtime/entry-82.js +1 -0
  404. package/src/extensions/pi-agent-text-editor/runtime/entry-83.js +2 -0
  405. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +2 -0
  406. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +23 -0
  407. package/src/extensions/pi-agent-text-editor/src/api/text-selection-anchor.ts +31 -1
  408. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +11 -21
  409. package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +5 -5
  410. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +13 -7
  411. package/src/extensions/pi-agent-text-editor/src/core/file-operation-guards.ts +22 -4
  412. package/src/extensions/pi-agent-text-editor/src/core/image-write.ts +111 -0
  413. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +3 -0
  414. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +5 -1
  415. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +8 -2
  416. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +103 -20
  417. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +146 -62
  418. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +14 -19
  419. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +43 -12
  420. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +5 -5
  421. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +6 -5
  422. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +3 -7
  423. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +6 -8
  424. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -6
  425. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +3 -4
  426. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +37 -22
  427. package/src/pi-agent-ide.ts +8 -15
  428. package/src/plugins/pi-agent-ide-ast/package.json +15 -15
  429. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +13 -1
  430. package/src/plugins/pi-agent-ide-ast/src/extension.ts +8 -8
  431. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +104 -26
  432. package/src/plugins/pi-agent-ide-ast/src/tool-ast-search.ts +210 -0
  433. package/src/plugins/pi-agent-ide-changes/index.ts +1 -2
  434. package/src/plugins/pi-agent-ide-changes/package.json +10 -10
  435. package/src/plugins/pi-agent-ide-changes/runtime/entry-38.js +1 -0
  436. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +3 -3
  437. package/src/plugins/pi-agent-ide-debugger/index.ts +17 -4
  438. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +2 -11
  439. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  440. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  441. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  442. package/src/plugins/pi-agent-ide-lint/runtime/entry-42.js +2 -0
  443. package/src/plugins/pi-agent-ide-lsp/index.ts +22 -28
  444. package/src/plugins/pi-agent-ide-lsp/package.json +14 -10
  445. package/src/plugins/pi-agent-ide-lsp/runtime/entry-43.js +2 -0
  446. package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +1 -1
  447. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +8 -84
  448. package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +1 -6
  449. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +11 -11
  450. package/src/plugins/pi-agent-ide-lsp/src/manager-provider.ts +8 -0
  451. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +1 -1
  452. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +234 -36
  453. package/src/plugins/pi-agent-ide-lsp/src/tool-lsp-search.ts +212 -0
  454. package/src/plugins/pi-agent-ide-processes/src/ui.ts +61 -16
  455. package/src/plugins/pi-agent-ide-terminal/index.ts +1 -1
  456. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +10 -7
  457. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +1 -3
  458. package/src/standalone/resource-host.ts +147 -0
  459. package/src/standalone/scoped-api.ts +457 -0
  460. package/dist/chunk-2RTCSZB3.js +0 -1
  461. package/dist/chunk-4DIUPEDF.js +0 -2
  462. package/dist/chunk-6EDOLYOV.js +0 -1
  463. package/dist/chunk-6FGLAVPJ.js +0 -1
  464. package/dist/chunk-6H32W35W.js +0 -1
  465. package/dist/chunk-6OJ565FL.js +0 -2
  466. package/dist/chunk-6R3Y4AD3.js +0 -1
  467. package/dist/chunk-6TJPMBUQ.js +0 -1
  468. package/dist/chunk-6XFUICD7.js +0 -1
  469. package/dist/chunk-BHSO2MDK.js +0 -6
  470. package/dist/chunk-GSOYVIQS.js +0 -1
  471. package/dist/chunk-HSRH76JN.js +0 -3
  472. package/dist/chunk-HSZ4AQ6L.js +0 -9
  473. package/dist/chunk-I6NPILT5.js +0 -1
  474. package/dist/chunk-K7SRNBIV.js +0 -1
  475. package/dist/chunk-LCWBVOII.js +0 -3
  476. package/dist/chunk-MKEC3U2M.js +0 -4
  477. package/dist/chunk-NUM3YQGK.js +0 -1
  478. package/dist/chunk-OM4LYD3S.js +0 -1
  479. package/dist/chunk-PLKYHUNT.js +0 -1
  480. package/dist/chunk-QIJMV2P2.js +0 -2
  481. package/dist/chunk-RVU73VKN.js +0 -2
  482. package/dist/chunk-SDAH3ECM.js +0 -5
  483. package/dist/chunk-SGQWRIRJ.js +0 -10
  484. package/dist/chunk-SWBJS3U4.js +0 -1
  485. package/dist/chunk-T7I2VX3J.js +0 -1
  486. package/dist/chunk-T7MWQQIF.js +0 -3
  487. package/dist/chunk-UEVGZUII.js +0 -3
  488. package/dist/chunk-VDP5CQHM.js +0 -3
  489. package/dist/chunk-XG7QNAKW.js +0 -9
  490. package/dist/chunk-XLWCSJMR.js +0 -1
  491. package/dist/chunk-YFP4P2FV.js +0 -1
  492. package/dist/chunk-YIXP2ALP.js +0 -9
  493. package/dist/entry-22.js +0 -1
  494. package/docs/agent-guides/diagnostics.md +0 -5
  495. package/docs/agent-guides/json-reading.md +0 -57
  496. package/docs/agent-guides/read-resources.md +0 -17
  497. package/docs/agent-guides/search-code.md +0 -76
  498. package/docs/agent-guides/select-code.md +0 -119
  499. package/docs/agent-guides/vision.md +0 -11
  500. package/node_modules/pi-agent-doctor/runtime/entry-22.js +0 -1
  501. package/node_modules/pi-agent-filesystem/runtime/entry-29.js +0 -2
  502. package/node_modules/pi-agent-filesystem-pdf/runtime/entry-32.js +0 -2
  503. package/node_modules/pi-agent-ide-ast/runtime/entry-34.js +0 -1
  504. package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +0 -193
  505. package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +0 -59
  506. package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +0 -204
  507. package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +0 -184
  508. package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +0 -105
  509. package/node_modules/pi-agent-ide-ast/src/select-schema.ts +0 -387
  510. package/node_modules/pi-agent-ide-ast/src/selection-region.ts +0 -41
  511. package/node_modules/pi-agent-ide-ast/src/source-text.ts +0 -92
  512. package/node_modules/pi-agent-ide-ast/src/text-selection.ts +0 -214
  513. package/node_modules/pi-agent-ide-ast/src/tool-select.ts +0 -277
  514. package/node_modules/pi-agent-ide-formatter/runtime/entry-38.js +0 -2
  515. package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +0 -136
  516. package/node_modules/pi-agent-image/runtime/entry-42.js +0 -1
  517. package/node_modules/pi-agent-invariant/runtime/entry-43.js +0 -1
  518. package/node_modules/pi-agent-search/runtime/entry-51.js +0 -1
  519. package/node_modules/pi-agent-search-text/runtime/entry-55.js +0 -2
  520. package/node_modules/pi-agent-search-text/runtime/entry-56.js +0 -1
  521. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-60.js +0 -2
  522. package/node_modules/pi-agent-text-editor/runtime/entry-66.js +0 -1
  523. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-82.js +0 -2
  524. package/node_modules/pi-agent-tool-call-interception/runtime/entry-84.js +0 -1
  525. package/node_modules/pi-agent-tool-ui/runtime/entry-85.js +0 -1
  526. package/node_modules/pi-agent-web/runtime/entry-87.js +0 -2
  527. package/node_modules/pi-agent-web-html/runtime/entry-88.js +0 -2
  528. package/src/backend/vision-capture-worker.py +0 -319
  529. package/src/backend/vision-capture.ts +0 -165
  530. package/src/backend/vision-registration.ts +0 -104
  531. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-30.js +0 -2
  532. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-32.js +0 -2
  533. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-29.js +0 -2
  534. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-88.js +0 -2
  535. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-89.js +0 -2
  536. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-87.js +0 -2
  537. package/src/extensions/pi-agent-read/runtime/entry-45.js +0 -1
  538. package/src/extensions/pi-agent-read/runtime/entry-46.js +0 -1
  539. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-55.js +0 -2
  540. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-56.js +0 -1
  541. package/src/extensions/pi-agent-search/runtime/entry-51.js +0 -1
  542. package/src/extensions/pi-agent-search/runtime/entry-52.js +0 -1
  543. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-60.js +0 -2
  544. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-61.js +0 -1
  545. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-82.js +0 -2
  546. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-83.js +0 -2
  547. package/src/extensions/pi-agent-text-editor/runtime/entry-65.js +0 -1
  548. package/src/extensions/pi-agent-text-editor/runtime/entry-66.js +0 -1
  549. package/src/plugins/pi-agent-ide-ast/runtime/entry-34.js +0 -1
  550. package/src/plugins/pi-agent-ide-ast/runtime/entry-35.js +0 -2
  551. package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +0 -193
  552. package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +0 -59
  553. package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +0 -204
  554. package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +0 -184
  555. package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +0 -105
  556. package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +0 -387
  557. package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +0 -41
  558. package/src/plugins/pi-agent-ide-ast/src/source-text.ts +0 -92
  559. package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +0 -214
  560. package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +0 -277
  561. package/src/plugins/pi-agent-ide-formatter/runtime/entry-38.js +0 -2
  562. package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +0 -136
  563. package/src/plugins/pi-agent-ide-vision/index.ts +0 -439
  564. package/src/plugins/pi-agent-ide-vision/src/doctor-plugin.ts +0 -47
  565. package/src/plugins/pi-agent-ide-vision/src/vision.ts +0 -585
  566. package/src/plugins/pi-agent-ide-vision/src/windows-display-capture.ps1 +0 -30
  567. package/src/plugins/pi-agent-ide-vision/src/windows-window-capture.ps1 +0 -33
  568. /package/dist/{chunk-U2JKHKLK.js → chunk-3PMHFEJY.js} +0 -0
  569. /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-28.js +0 -0
  570. /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-30.js +0 -0
  571. /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-31.js +0 -0
  572. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-jq}/runtime/entry-33.js +0 -0
  573. /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-text}/runtime/entry-35.js +0 -0
  574. /package/node_modules/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-36.js +0 -0
  575. /package/node_modules/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-37.js +0 -0
  576. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-changes}/runtime/entry-39.js +0 -0
  577. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-formatter}/runtime/entry-40.js +0 -0
  578. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-languages}/runtime/entry-41.js +0 -0
  579. /package/node_modules/{pi-agent-pdf → pi-agent-image}/runtime/entry-44.js +0 -0
  580. /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-45.js +0 -0
  581. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-46.js +0 -0
  582. /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-50.js +0 -0
  583. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-52.js +0 -0
  584. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-59.js +0 -0
  585. /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text}/runtime/entry-61.js +0 -0
  586. /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-62.js +0 -0
  587. /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-63.js +0 -0
  588. /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-64.js +0 -0
  589. /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-65.js +0 -0
  590. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor}/runtime/entry-83.js +0 -0
  591. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-86.js +0 -0
  592. /package/node_modules/{pi-agent-web-image → pi-agent-web}/runtime/entry-89.js +0 -0
  593. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-html}/runtime/entry-90.js +0 -0
  594. /package/node_modules/{pi-agent-web-text → pi-agent-web-image}/runtime/entry-91.js +0 -0
  595. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-31.js +0 -0
  596. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-jq}/runtime/entry-33.js +0 -0
  597. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-html}/runtime/entry-90.js +0 -0
  598. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-image}/runtime/entry-91.js +0 -0
  599. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-62.js +0 -0
  600. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-63.js +0 -0
  601. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-64.js +0 -0
  602. /package/src/plugins/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-36.js +0 -0
  603. /package/src/plugins/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-37.js +0 -0
  604. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-changes}/runtime/entry-39.js +0 -0
  605. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-formatter}/runtime/entry-40.js +0 -0
  606. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-languages}/runtime/entry-41.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,70 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.0 — 2026-10-26
4
+
5
+ ### Search split into focused tools
6
+
7
+ - `select` is removed. Narrow a `read`, `search` or edit result by searching inside it: a regex for a span between markers or part of a line, `ast_search` captures for construct parts, and `SEARCH#…:line` references for whole lines.
8
+ - New `ast_search` finds code by syntax with ast-grep, in files or inside a `read`, `search` or edit result, for every language ast-grep supports. Pass a `pattern` with `$NAME` and `$$$ARGS` captures, or an ast-grep `rule` with a `language` for relations such as `inside`, `has`, `not`, `follows` and `precedes`. With a result as `path`, `relation: "enclosing"` returns the function, class or call that contains each range, for example the function around a text match.
9
+ - New `lsp_search` asks language servers for symbols and references (`query`, with `references: true` to follow them outside the scope), one declaration as an editable selection (`declaration: "file#selector"`), and references with incoming and outgoing calls (`calls`). It replaces the `symbols:` query and `navigation` in `search` and the `symbol:` and `graph:` sources in `read`. Editing through `symbol:<file>#<selector>` paths and native rename are unchanged.
10
+ - New `file_search` finds files by glob or partial name, locally or over SSH. It replaces the `files:` query in `search`.
11
+ - `include` and `exclude` in `file_search`, `ast_search` and `lsp_search` keep brace alternatives such as `**/*.{cmake,txt,h}` as one glob. Before, the commas inside the braces split it into broken parts.
12
+ - `file_search` on a very large tree no longer crashes Pi with `Invalid string length`. It returns the first matches and reports that the list is incomplete.
13
+ - `search` now covers text in files, web pages, guides and terminal output. The `ast:`, `symbols:` and `files:` prefixes are searched as plain text.
14
+ - In Codemode, `ast_search`, `lsp_search` and `file_search` return `{ result, hasMatches, complete }`, like `search`.
15
+
16
+ ### Smaller prompt
17
+
18
+ - Tool descriptions, IDE rules and agent guides are shorter: with only Pi Agent IDE loaded, tool declarations shrink from about 36,000 to 23,000 characters and the attached guides from about 40,000 to 13,000. Enabled plugins add their details to individual tool fields, so a disabled plugin adds nothing.
19
+
20
+ ### `search`
21
+
22
+ - `multiline: true` lets a text or `regex:` query match across lines, in files and inside a result's ranges. A match never crosses a range boundary. Matches show their end line and the matched lines.
23
+ - A search with a small `limit` now always shows a matching line and its reference for each compacted file, instead of only a count.
24
+
25
+ ### Editing
26
+
27
+ - `write` can save images that `read` returned, such as a screenshot or an image file. Several frames are written as numbered files.
28
+ - Paired `start`/`end` selectors keep character boundaries when an endpoint is part of a line, so an edit inside a sentence changes only that span. When both endpoints are whole lines, such as BEGIN/END marker lines, the selection still takes those lines. A literal start that begins with blank lines no longer deletes the preceding paragraph.
29
+ - An empty optional anchor, such as `end: ""`, behaves like an omitted one instead of failing the edit.
30
+ - `copy` or `move` of a whole-line literal over an exact character range no longer adds an extra line break.
31
+ - Failed edits keep the provider's retry timing, such as a rate-limit cooldown.
32
+
33
+ ### `read`
34
+
35
+ - The `jq:` view also works on JSON that a provider returns, not only on files. A jq result is read-only: to edit, read the source normally.
36
+ - Text files that mention a PDF header or start like a BMP or GIF signature, such as source code, read as text instead of failing. Files declared as PDF or image still fail clearly when they are invalid.
37
+ - In Codemode, a failed `read` returns `{ status: "error", errors }` with the provider's retry timing, instead of a plain string. Each error message keeps the recovery steps a direct call shows, such as close path matches.
38
+ - When a resource provider reports its own failure for `source#fragment`, `read` shows that failure instead of retrying the fragment as a text anchor.
39
+
40
+ ### Processes
41
+
42
+ - In fullscreen mode, click a process in the panel below the editor to open its details. The command and keyboard navigation work as before.
43
+
44
+ ### Sessions
45
+
46
+ - IDE tools no longer disappear when Pi switches sessions, for example on resume or fork, after the installed package files changed while Pi was running.
47
+ - A provider request that finishes after Pi replaced its session, such as a cache-warming refresh, no longer reports `This extension ctx is stale` errors from Pi Agent IDE.
48
+
49
+ ### Removed
50
+
51
+ - Window and display capture, website screenshots and sequences, and process discovery (`process:` resources and search) are removed. Desktop observation moves to Pi Agent Computer Use (to be released). Terminal images and sequences, web page text and ordinary image and PDF reading stay.
52
+
53
+ ### Claude subscription connectors
54
+
55
+ - IDE tools appear once in the system prompt and the Codemode catalogue when a Claude subscription connector also registers aliases for them. The aliases still work.
56
+
57
+ ### For extension authors
58
+
59
+ - `pi-agent-ide/api/standalone` hosts resource tools with namespaced, deferred declarations without loading the full IDE.
60
+ - Semantic `write` and `insert` actions can return images to the model alongside their text summary.
61
+
62
+ ## 0.8.4 — 2026-10-22
63
+
64
+ ### Editing
65
+
66
+ - Saving an edit to a deeply nested file, such as a large C++ source, no longer freezes Pi.
67
+
3
68
  ## 0.8.3 — 2026-10-21
4
69
 
5
70
  ### Debugger and terminal
package/README.md CHANGED
@@ -36,28 +36,29 @@ To configure it yourself, read the [short settings guide](./docs/settings-help.m
36
36
 
37
37
  Pi Agent IDE gives the [Pi coding agent](https://pi.dev/) a small set of development tools for understanding, changing, running, debugging, and observing software. The same tools work with local resources and configured Linux SSH targets.
38
38
 
39
- | Work | Interfaces |
40
- | ------------------------------------ | ------------------------------------------------------------- |
41
- | Inspect content and state | `read` with source-specific views |
42
- | Find text, paths, code and processes | `search` |
43
- | Derive exact text and AST selections | `select` |
44
- | Change text and filesystem objects | `write`, `replace`, `insert`, `delete`, `copy`, `move` |
45
- | Compare, stage and restore changes | `diff`, `stage`, `unstage`, `undo` |
46
- | Run and interact with commands | `bash` or `powershell`, then `shell:` resources |
47
- | Debug programs | `debug`, then `debug:` resources |
48
- | Work remotely | The same supported tools with `ssh://` paths and remote `cwd` |
39
+ | Work | Interfaces |
40
+ | ---------------------------------- | ------------------------------------------------------------- |
41
+ | Inspect content and state | `read` with source-specific views |
42
+ | Find text and terminal output | `search` |
43
+ | Find files by path | `file_search` |
44
+ | Find code by syntax structure | `ast_search` |
45
+ | Find symbols, references and calls | `lsp_search` |
46
+ | Change text and filesystem objects | `write`, `replace`, `insert`, `delete`, `copy`, `move` |
47
+ | Compare, stage and restore changes | `diff`, `stage`, `unstage`, `undo` |
48
+ | Run and interact with commands | `bash` or `powershell`, then `shell:` resources |
49
+ | Debug programs | `debug`, then `debug:` resources |
50
+ | Work remotely | The same supported tools with `ssh://` paths and remote `cwd` |
49
51
 
50
52
  ### Combine tools through direct calls or native Codemode
51
53
 
52
54
  All IDE tools support direct calls and Pi's built-in Codemode. The agent can combine reading, search, selection and editing into one workflow, with the same source checks in both modes.
53
55
 
54
- For example, this script finds a checklist item, selects its complete line, and marks it done:
56
+ For example, this script reads a section, finds a checklist item inside it, and marks it done:
55
57
 
56
58
  ```js
57
- const source = await tools.read({ path: "notes.md" });
58
- const matches = await tools.search({ path: source, query: "- [ ] Update docs" });
59
- const lines = await tools.select({ path: matches, operation: { kind: "linesOf" } });
60
- text(await tools.replace({ path: lines, text: "- [x] Update docs\n" }));
59
+ const section = await tools.read({ path: "notes.md", offset: 10, limit: 20 });
60
+ const item = await tools.search({ path: section, query: "- [ ] Update docs" });
61
+ text(await tools.replace({ path: item.result, text: "- [x] Update docs" }));
61
62
  ```
62
63
 
63
64
  ### Read anything through `read`
@@ -66,10 +67,9 @@ text(await tools.replace({ path: lines, text: "- [x] Update docs\n" }));
66
67
 
67
68
  - files, directories, source code, and raw bytes;
68
69
  - JSON transformed through real `jq` filters;
69
- - web pages, PDFs, images, and image sequences;
70
+ - web pages, PDFs, and images;
70
71
  - diagnostics and Git changes;
71
- - terminal and debugger sessions;
72
- - running processes, application windows, and full displays.
72
+ - terminal and debugger sessions.
73
73
 
74
74
  Views change how the same resource is presented. The agent can request source structure, editable anchors, diagnostics, an image, a sequence, or another supported projection without learning a separate tool for every source.
75
75
 
@@ -81,7 +81,7 @@ Views change how the same resource is presented. The agent can request source st
81
81
 
82
82
  ### Find anything through `search`
83
83
 
84
- `search` provides one interface for paths, exact text, regular expressions, AST patterns, symbols, references, code relationships, process discovery, and retained terminal output. File matches are reusable guarded references, so the agent can pass a selection directly to `read` or an editing tool. Search packaged guides through `docs:all` or one `docs:<id>`; guide matches are read-only and do not authorize edits.
84
+ `search` provides one interface for exact text, regular expressions, and retained terminal output. File matches are reusable guarded references, so the agent can pass a selection directly to `read` or an editing tool. Search packaged guides through `docs:all` or one `docs:<id>`; guide matches are read-only and do not authorize edits.
85
85
 
86
86
  <div align="center">
87
87
 
@@ -89,11 +89,11 @@ Views change how the same resource is presented. The agent can request source st
89
89
 
90
90
  </div>
91
91
 
92
- ### Select and change exactly what you mean
92
+ ### Narrow and change exactly what you mean
93
93
 
94
- `select` helps the agent change the intended part of a file: a line, a function body, a parameter list, or the overlap between selections. JavaScript and TypeScript structure is supported without JSX/TSX, so the agent can work with code boundaries rather than guessing line numbers.
94
+ The agent narrows a Read or Search result by searching inside it: a regex for a span between markers or part of a line, or an `ast_search` pattern whose captures select a function body or an argument list. Edits then change only those exact ranges, so the agent works with real code boundaries rather than guessing line numbers.
95
95
 
96
- Language-server support adds declarations, references, call graphs, diagnostics, and semantic rename across references. Available features depend on the project's language server. See [selection](docs/agent-guides/select-code.md) and [code navigation](docs/agent-guides/search-code.md).
96
+ Language-server support adds `lsp_search` for declarations, references and call graphs, plus diagnostics and semantic rename across references. Available features depend on the project's language server.
97
97
 
98
98
  ### Review edits against your own rules
99
99
 
@@ -152,15 +152,11 @@ When the project is open in VS Code with the [DebugMCP](https://github.com/micro
152
152
 
153
153
  </div>
154
154
 
155
- ### See the environment
156
-
157
- The agent can render websites as images, observe changing interfaces over time, and inspect windows opened by its own processes. Arbitrary windows and full displays require separate explicit opt-in settings. Images can be downscaled, limited to normalized regions, or divided into grid cells so the model receives the useful area instead of every source pixel.
158
-
159
155
  ### Use the same tools over SSH
160
156
 
161
157
  Ask the agent to work on a remote Linux environment. It can read, search and edit files, copy between your machine and the server, work with Git, and run interactive commands through the same IDE tools. Language servers, linters, formatters and debugger adapters use the remote machine's tools and project settings.
162
158
 
163
- Remote process inspection, supported window/display capture and remote web reads are available too. Missing remote dependencies are reported rather than silently replaced by local tools.
159
+ Remote web text reads are available too. Missing remote dependencies are reported rather than silently replaced by local tools.
164
160
 
165
161
  SSH uses your existing OpenSSH authentication and host-key trust. The remote machine needs Python 3; no permanent agent is installed there. Operations have the permissions of the SSH account. The agent sets up project-local access by default unless you ask for global settings. See [SSH configuration](docs/configuration.md#ssh-targets).
166
162
 
@@ -246,7 +242,7 @@ Run `/pi-agent-ide-doctor` again after installing or changing project tools. For
246
242
 
247
243
  Pi Agent IDE follows Pi's permissive, YOLO-style default: the agent can use the tools without asking for approval at every step. You can make it as strict as your work requires.
248
244
 
249
- - [Settings](./docs/configuration.md) control built-in tools, project mappings, search, vision, and presentation.
245
+ - [Settings](./docs/configuration.md) control built-in tools, project mappings, search, and presentation.
250
246
  - [File hooks](./docs/user-hooks.md) can inspect, change, or deny reads and edits.
251
247
  - [Extensions](./docs/extensions.md) can add or replace protocols, resolvers, views, anchors, search backends, and other behavior.
252
248
 
@@ -268,7 +264,6 @@ If something breaks, behaves badly, or does not fit your workflow, please [open
268
264
  | ------------------------------------------------------ | ------------------------------------------------------------------------ |
269
265
  | [Tools and workflow](./docs/tools.md) | Reading, search, selections, editing, terminals, and feedback |
270
266
  | [Result composition](./docs/structured-results.md) | Passing results between tools, reference lifetime, and commit boundaries |
271
- | [Selection](./docs/agent-guides/select-code.md) | Text ranges, AST parts, and combining selections |
272
267
  | [Directory operations](./docs/directory-operations.md) | Copy, Move, Delete, symlinks, guards, and partial failures |
273
268
  | [Settings guide](./docs/settings-help.md) | Choosing settings, scope, saving and output presentation |
274
269
  | [Configuration](./docs/configuration.md) | Project tools, SSH targets, Doctor, and presentation settings |
@@ -0,0 +1,3 @@
1
+ import{a as S}from"./chunk-VDJSH3DQ.js";import{a as c}from"./chunk-EI7MMDWY.js";import{createRequire as F}from"node:module";import{Lang as y,parse as R,registerDynamicLanguage as B}from"@ast-grep/napi";var D=F(new URL("../src/plugins/pi-agent-ide-ast/src/ast/native-parser.ts",import.meta.url).href),$={bash:"@ast-grep/lang-bash",csharp:"@ast-grep/lang-csharp",dart:"@ast-grep/lang-dart",elixir:"@ast-grep/lang-elixir",go:"@ast-grep/lang-go",html:"@ast-grep/lang-html",java:"@ast-grep/lang-java",kotlin:"@ast-grep/lang-kotlin",lua:"@ast-grep/lang-lua",markdown:"@ast-grep/lang-markdown",php:"@ast-grep/lang-php",ruby:"@ast-grep/lang-ruby",scala:"@ast-grep/lang-scala",sql:"@ast-grep/lang-sql",swift:"@ast-grep/lang-swift"},O={".bash":"bash",".cs":"csharp",".css":y.Css,".less":y.Css,".scss":y.Css,".dart":"dart",".ex":"elixir",".exs":"elixir",".go":"go",".htm":"html",".html":"html",".java":"java",".kt":"kotlin",".kts":"kotlin",".lua":"lua",".md":"markdown",".mdx":"markdown",".php":"php",".rb":"ruby",".rake":"ruby",".scala":"scala",".sc":"scala",".sql":"sql",".sh":"bash",".swift":"swift"},N=!1;function q(){if(N)return;let s={};for(let[e,t]of Object.entries($))s[e]=D(t);B(s),N=!0}c(q,"ensureLanguagesRegistered");function k(s,e){let t=O[s];if(t)return q(),{rootNode:new b(R(t,e).root(),e)}}c(k,"parseNativeDocument");var b=class s{constructor(e,t){this.node=e;this.source=t}static{c(this,"NativeSyntaxNode")}get type(){return String(this.node.kind())}get text(){return this.node.text()}get isNamed(){return this.node.isNamed()}get hasError(){return this.type==="ERROR"||this.node.children().some(e=>new s(e,this.source).hasError)}get startIndex(){return C(this.source,this.node.range().start.index)}get endIndex(){return C(this.source,this.node.range().end.index)}get startPosition(){let{line:e,column:t}=this.node.range().start;return{row:e,column:t}}get endPosition(){let{line:e,column:t}=this.node.range().end;return{row:e,column:t}}get parent(){let e=this.node.parent();return e?new s(e,this.source):null}get namedChildCount(){return this.namedChildren.length}get namedChildren(){return this.node.children().filter(e=>e.isNamed()).map(e=>new s(e,this.source))}childForFieldName(e){let t=this.node.field(e);return t?new s(t,this.source):null}};function C(s,e){return Buffer.from(s).subarray(0,e).toString("utf8").length}c(C,"byteOffsetToStringIndex");import{createHash as W}from"node:crypto";import{createRequire as I}from"node:module";import L from"node:path";import*as p from"web-tree-sitter";var M=I(new URL("../src/plugins/pi-agent-ide-ast/src/ast/manager.ts",import.meta.url).href),G=new Set(["program","module"]),x=new Set(["body","consequence","alternative","handler","finalizer"]);function P(s){let{startPosition:e,endPosition:t}=s;return`${s.type}:${e.row}:${e.column}:${t.row}:${t.column}`}c(P,"siblingKey");var A,v=new Map;function U(s){switch(s){case".ts":case".tsx":case".mts":case".cts":return"tree-sitter-typescript/tree-sitter-typescript.wasm";case".js":case".jsx":case".mjs":case".cjs":return"tree-sitter-javascript/tree-sitter-javascript.wasm";case".py":case".pyi":return"tree-sitter-python/tree-sitter-python.wasm";case".rs":return"tree-sitter-rust/tree-sitter-rust.wasm";case".c":case".cc":case".hh":case".hxx":case".cpp":case".cxx":case".h":case".hpp":return"tree-sitter-cpp/tree-sitter-cpp.wasm";case".json":case".jsonc":return"tree-sitter-json/tree-sitter-json.wasm";case".yaml":case".yml":return"@tree-sitter-grammars/tree-sitter-yaml/tree-sitter-yaml.wasm";case".toml":return"@tree-sitter-grammars/tree-sitter-toml/tree-sitter-toml.wasm";default:return}}c(U,"grammarWasmPath");async function H(s){let e=U(s);if(!e)return;A??=p.Parser.init(),await A;let t=v.get(e);if(t===void 0){let a=M.resolve(e);t=p.Language.load(a),v.set(e,t)}let i=await t,o=new p.Parser;return o.setLanguage(i),o}c(H,"ensureParser");async function K(s,e,t){if(t.length===0)return;let i=s.includes("://")||L.isAbsolute(s)?s:L.resolve(e,s),o=L.extname(i).toLowerCase(),a=t.join(`
2
+ `),d=await H(o);if(d)try{return d.parse(a)??void 0}finally{d.delete()}return k(o,a)}c(K,"parseDocument");function E(s,e,t){let i=s.slice(Math.max(0,e-1),Math.max(0,t)).join(`
3
+ `);return W("sha1").update(i).digest("hex").slice(0,4).toUpperCase()}c(E,"hashScope");var w=class extends S{static{c(this,"AstScopeTextAnchor")}constructor(e,t,i,o){super(`scope-${e}-${t}${o===void 0?"":`-${o}`}`,i)}};function h(s,e,t,i){return new w(s,e,t,i)}c(h,"createScopeAnchor");var j=class{static{c(this,"AstScopeManager")}async getDocumentScopes(e,t,i){if(i.length===0)return[];let o=await K(e,t,i);if(!o)return[];let a=[];return this.collectCandidates(o.rootNode,a),this.buildEntries(a,i)}collectCandidates(e,t,i=0,o=!1){if(i>100||!e.isNamed)return;let a=e.type;if(!a||G.has(a)){for(let n of e.namedChildren)this.collectCandidates(n,t,i+1);return}let d=new Set;for(let n of x){let r=e.childForFieldName(n);if(!r?.isNamed)continue;d.add(P(r));let u=r.startPosition.row+1,m=r.endPosition.row+1,l=m-u>=3,g=[...x].some(T=>r.childForFieldName(T)!==null);l&&!g&&t.push({startLine:u,endLine:m,kind:`${a}.${n}`,fromBodyField:!0}),this.collectCandidates(r,t,i+1,!0)}if(![...x].some(n=>e.childForFieldName(n)!==null)&&!o){let n=e.startPosition.row+1,r=e.endPosition.row+1;r-n>=3&&e.namedChildren.length>0&&t.push({startLine:n,endLine:r,kind:a,fromBodyField:!1})}for(let n of e.namedChildren)d.has(P(n))||this.collectCandidates(n,t,i+1)}buildEntries(e,t){let i=new Map;for(let n of e){let r=i.get(n.startLine);(!r||n.endLine>r.endLine||n.endLine===r.endLine&&n.fromBodyField&&!r.fromBodyField)&&i.set(n.startLine,n)}let o=[...i.values()].sort((n,r)=>n.startLine-r.startLine||r.endLine-n.endLine),a=[];for(let n of o)a.some(u=>u.startLine<n.startLine&&u.endLine===n.endLine)||a.push(n);let d=new Map;for(let n of a){let r=E(t,n.startLine,n.endLine);d.set(r,(d.get(r)??0)+1)}let f=new Map;return a.map(n=>{let r=E(t,n.startLine,n.endLine),u=d.get(r)??1,m=(f.get(r)??0)+1;f.set(r,m);let l=u>1?m:void 0;return{name:n.kind,kind:n.kind,startLine:n.startLine,endLine:n.endLine,depth:a.filter(g=>g!==n&&g.startLine<=n.startLine&&g.endLine>=n.endLine&&(g.startLine<n.startLine||g.endLine>n.endLine)).length,hash:r,blockHash:r,...l!==void 0&&{occurrence:l},beginAnchor:h("begin",r,n.startLine,l),endScopeAnchor:h("end",r,n.endLine,l),scopeBeginAnchor:h("begin",r,n.startLine,l),scopeEndAnchor:h("end",r,n.endLine,l)}})}};export{O as a,K as b,j as c};
@@ -1,2 +1,2 @@
1
- import{d as R}from"./chunk-6TJPMBUQ.js";import{a as S}from"./chunk-PS2B6THP.js";import{t as p,u as y}from"./chunk-ZPT5D4VP.js";import{a as c}from"./chunk-EI7MMDWY.js";import{keyText as T}from"@earendil-works/pi-coding-agent";import{Text as $}from"@earendil-works/pi-tui";function x(e){return e.replaceAll("\u27E6","").replaceAll("\u27E7","")}c(x,"sourceText");function w(e,r){let{files:o,...t}=e,s=x(r);return{...t,storedFiles:o.map(({lines:l,...a})=>({...a,lines:l.map(n=>{let i=[n.lineNumber,p(n.text,s),n.ranges];return n.logicalMatchIds===void 0?i:[...i,n.logicalMatchIds]})}))}}c(w,"compactSearchDetails");function g(e,r){if("files"in e)return e;let{storedFiles:o,...t}=e,s=x(r);return{...t,files:o.map(({lines:l,...a})=>({...a,lines:l.map(([n,i,h,u])=>({lineNumber:n,text:y(i,s),ranges:h,matchCount:h.length,...u===void 0?{}:{logicalMatchIds:u}}))}))}}c(g,"restoreSearchDetails");var k=new WeakMap,C=12;function v(e,r,o,t){if(typeof e.details=="object"){let a=k.get(e.details);a===void 0&&(a=g(e.details,e.content.flatMap(n=>n.type==="text"?[n.text]:[]).join(`
1
+ import{d as R}from"./chunk-IG5DXVDJ.js";import{a as S}from"./chunk-PS2B6THP.js";import{t as p,u as y}from"./chunk-VDJSH3DQ.js";import{a as c}from"./chunk-EI7MMDWY.js";import{keyText as T}from"@earendil-works/pi-coding-agent";import{Text as $}from"@earendil-works/pi-tui";function x(e){return e.replaceAll("\u27E6","").replaceAll("\u27E7","")}c(x,"sourceText");function w(e,r){let{files:o,...t}=e,s=x(r);return{...t,storedFiles:o.map(({lines:l,...a})=>({...a,lines:l.map(n=>{let i=[n.lineNumber,p(n.text,s),n.ranges];return n.logicalMatchIds===void 0?i:[...i,n.logicalMatchIds]})}))}}c(w,"compactSearchDetails");function g(e,r){if("files"in e)return e;let{storedFiles:o,...t}=e,s=x(r);return{...t,files:o.map(({lines:l,...a})=>({...a,lines:l.map(([n,i,h,u])=>({lineNumber:n,text:y(i,s),ranges:h,matchCount:h.length,...u===void 0?{}:{logicalMatchIds:u}}))}))}}c(g,"restoreSearchDetails");var k=new WeakMap,C=12;function v(e,r,o,t){if(typeof e.details=="object"){let a=k.get(e.details);a===void 0&&(a=g(e.details,e.content.flatMap(n=>n.type==="text"?[n.text]:[]).join(`
2
2
  `)),k.set(e.details,a)),e={...e,details:a}}if(r.isPartial||t.isError||!R(e.details)){let a=e.content[0],n=a?.type==="text"?a.text:"",i=t.isError?"error":r.isPartial?"dim":"toolOutput";return new $(o.fg(i,n),0,0)}let l=(t.lastComponent instanceof m?t.lastComponent:void 0)??new m(e.details,o,r.expanded);return l.updateSearch(e.details,o,r.expanded),l}c(v,"renderSearchResult");var m=class extends S{static{c(this,"SearchResultPanel")}constructor(r,o,t){super(z(r,t),o,t)}updateSearch(r,o,t){super.update(z(r,t),o,t)}};function z(e,r){let o=D(e,r).map(t=>t.kind==="file"?{kind:"source",label:t.file.path,link:t.file.link,count:t.file.matchCount}:t.kind==="line"?{kind:"line",...t.line}:t.kind==="candidate"?{kind:"note",text:t.identifier}:t.kind==="summary"?{kind:"note",text:t.text}:t.kind==="omitted"?{kind:"note",text:`\u2026 ${t.matches} more ${d(t.matches,"match","matches")} \xB7 ${T("app.tools.expand")} to expand`}:{kind:"note",text:"No matches found"});return{summary:P(e),rows:o}}c(z,"searchModel");function D(e,r){let o=e.fuzzy?.status==="ready"&&e.fuzzy.candidates.length>0,t=e.files.length===0?o?[]:[{kind:"empty"}]:e.files.flatMap(n=>[{kind:"file",file:n},...n.uniqueLineCount===void 0?n.lines.map(i=>({kind:"line",file:n,line:i})):[{kind:"summary",text:`${String(n.uniqueLineCount)} unique line texts \xB7 search this path with a narrower query`},...(n.groups??[]).map(i=>({kind:"summary",text:`\xD7${String(i.matchCount)} ${i.text}`}))]]);if(e.fuzzy!==void 0&&(e.fuzzy.status==="skipped"?t.push({kind:"summary",text:"Fuzzy search unavailable"}):e.fuzzy.candidates.length>0&&t.push(...e.fuzzy.candidates.flatMap(n=>{let i=e.fuzzyPresentation?.groups.find(u=>u.identifier===n.identifier)?.files??[],h=i.reduce((u,f)=>u+f.matchCount,0);return[{kind:"candidate",identifier:n.identifier},...i.length===0?[]:[{kind:"summary",text:`Shown ${String(h)} of ${String(n.matchCount)}${n.selection.complete?"":"+"}`},...i.flatMap(u=>[{kind:"file",file:u},...u.lines.map(f=>({kind:"line",file:u,line:f}))])]]}))),(e.omittedFileCount??0)>0&&t.push({kind:"summary",text:`\u2026 ${e.omittedFileCount} more files (${e.omittedMatchCount} matches) \xB7 narrow path, include, or query`}),e.fuzzy!==void 0||r||t.length<=C)return t;let s=t.slice(0,C-1);for(;s.at(-1)?.kind==="file";)s.pop();let l=new Set(s.flatMap(n=>n.kind==="line"?n.line.logicalMatchIds??[]:[])),a=l.size>0?l.size:s.reduce((n,i)=>n+(i.kind==="line"?i.line.matchCount:0),0);return[...s,{kind:"omitted",matches:Math.max(0,e.matchCount-a)}]}c(D,"searchViewport");function P(e){if(e.matchCount===0&&e.fuzzy?.status==="ready"&&e.fuzzy.candidates.length>0&&e.fuzzyPresentation!==void 0){let o=e.fuzzy.candidates.reduce((l,a)=>l+a.matchCount,0),t=e.fuzzy.candidates.every(l=>l.selection.complete)?"":"+",s=e.fuzzyPresentation.fileCount;return`0 exact \xB7 ${String(o)}${t} fuzzy ${d(o,"match","matches")} \xB7 ${String(s)}${t} ${d(s,"file","files")}`}return e.matchCount===0?e.complete?"No matches":"No matches \xB7 incomplete":`${`${String(e.matchCount)}${e.complete?"":"+"}`} ${d(e.matchCount,"match","matches")} in ${String(e.fileCount)} ${d(e.fileCount,"file","files")}`}c(P,"searchSummary");function d(e,r,o){return e===1?r:o}c(d,"plural");export{w as a,v as b,m as c};
@@ -1 +1 @@
1
- import{a as d,b as u,c as w}from"./chunk-RIJMXO43.js";import"./chunk-PJL3UVMJ.js";import{b as f}from"./chunk-XAHU42FP.js";import"./chunk-DEP55R35.js";import"./chunk-R2U5WXYR.js";import{c}from"./chunk-W7CASEO3.js";import"./chunk-T7I2VX3J.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-XXLLY66B.js";import"./chunk-235QMMVA.js";import"./chunk-BU7IZLKB.js";import"./chunk-S5PL5DFQ.js";import"./chunk-LCWBVOII.js";import"./chunk-ZPT5D4VP.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import{a as i}from"./chunk-EI7MMDWY.js";import{readFile as x}from"node:fs/promises";async function g(o){let n=new w(await u(d(c())));await f(o,m(o,n))}i(g,"registerOwnedGit");function m(o,n){return{exec:i(async(t,r,e)=>{let a=n.resolve(e.cwd);if(!a){if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(e.cwd))throw new Error(`Unsupported Git resource: ${e.cwd}`);return o.exec(t,r,e)}let s=await a.backend.execute(t,r,a.location.path,e);return{code:s.exitCode,stdout:s.stdout.toString("utf8"),stderr:s.stderr.toString("utf8")}},"exec"),async writeIndex(t,r){let e=n.resolve(r.cwd);return e?(await e.backend.writeGitIndex(e.location.path,t,r),!0):!1},async readText(t,r){let e=n.resolve(t);if(e)return(await e.backend.read(e.location.path,{signal:r})).bytes.toString("utf8");if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(t))throw new Error(`Unsupported Git resource: ${t}`);return x(t,{encoding:"utf8",signal:r})}}}i(m,"createOwnedGitExecutor");export{m as createOwnedGitExecutor,g as default};
1
+ import{a as d,b as u,c as w}from"./chunk-WQIMM4SU.js";import"./chunk-4IWEKRSP.js";import{b as f}from"./chunk-6A3ORNW3.js";import"./chunk-DEP55R35.js";import{c}from"./chunk-W7CASEO3.js";import"./chunk-R2U5WXYR.js";import"./chunk-KN6VPARZ.js";import"./chunk-MDD5ORB6.js";import"./chunk-MLFJU2US.js";import"./chunk-GXL4NMHR.js";import"./chunk-PQWANILR.js";import"./chunk-BU7IZLKB.js";import"./chunk-S5PL5DFQ.js";import"./chunk-DDH3FP4G.js";import"./chunk-VDJSH3DQ.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import{a as i}from"./chunk-EI7MMDWY.js";import{readFile as x}from"node:fs/promises";async function g(o){let n=new w(await u(d(c())));await f(o,m(o,n))}i(g,"registerOwnedGit");function m(o,n){return{exec:i(async(t,r,e)=>{let a=n.resolve(e.cwd);if(!a){if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(e.cwd))throw new Error(`Unsupported Git resource: ${e.cwd}`);return o.exec(t,r,e)}let s=await a.backend.execute(t,r,a.location.path,e);return{code:s.exitCode,stdout:s.stdout.toString("utf8"),stderr:s.stderr.toString("utf8")}},"exec"),async writeIndex(t,r){let e=n.resolve(r.cwd);return e?(await e.backend.writeGitIndex(e.location.path,t,r),!0):!1},async readText(t,r){let e=n.resolve(t);if(e)return(await e.backend.read(e.location.path,{signal:r})).bytes.toString("utf8");if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(t))throw new Error(`Unsupported Git resource: ${t}`);return x(t,{encoding:"utf8",signal:r})}}}i(m,"createOwnedGitExecutor");export{m as createOwnedGitExecutor,g as default};
@@ -1 +1 @@
1
- import{k as f}from"./chunk-LCWBVOII.js";import{a}from"./chunk-EI7MMDWY.js";import k from"node:path";function p(i,t){if(!/^[a-z0-9][a-z0-9_-]*$/u.test(i))throw new TypeError("SSH target IDs must contain lowercase letters, digits, underscores or hyphens");if(!t.startsWith("/")||t.includes("\0"))throw new TypeError("Remote paths must be absolute and contain no NUL characters");let r=k.posix.normalize(t),e=r.split("/").map(encodeURIComponent).join("/");return{target:i,path:r,source:`ssh://${i}${e}`}}a(p,"remoteLocation");function O(i,t){if(i.startsWith("ssh:")){let e=new URL(i);if(!i.startsWith("ssh://")||!e.hostname||e.username||e.password||e.port||e.search||e.hash||i.includes("?")||i.includes("#"))throw new TypeError("SSH references require a configured target and an absolute path, without credentials or selectors");return p(e.hostname,decodeURIComponent(e.pathname))}if(!t?.startsWith("ssh:")||/^[A-Za-z][A-Za-z\d+.-]*:/u.test(i))return;let r=O(t);if(!r)throw new TypeError("Invalid remote workspace");return p(r.target,k.posix.resolve(r.path,i))}a(O,"resolveRemoteLocation");import{readFile as C}from"node:fs/promises";function S(i){if(p(i.id,i.workspace),!/^(?:[A-Za-z0-9_][A-Za-z0-9_.-]*@)?[A-Za-z0-9_][A-Za-z0-9_.-]*$/u.test(i.host))throw new TypeError("SSH host must be an OpenSSH host alias, not a command or URI")}a(S,"validateSshTarget");async function y(i){return`exec(__import__("base64").b64decode("${(await C(i)).toString("base64")}"))`}a(y,"sshWorkerProgram");async function F(i){return`python3 -c '${await y(i)}'`}a(F,"sshWorkerCommand");function D(i,t){let r=["-T","-o","BatchMode=yes","-o","StrictHostKeyChecking=yes","-o","ForwardAgent=no","-o","PermitLocalCommand=no","-o","ClearAllForwardings=yes"];return i.configFile!==void 0&&r.push("-F",i.configFile),r.push("--",i.host,t),r}a(D,"systemSshArguments");function H(i,t){return/Host key verification failed|REMOTE HOST IDENTIFICATION HAS CHANGED|No .* host key is known/u.test(t)?"HOST_KEY_FAILED":/Permission denied \([^)]*\)/u.test(t)?"AUTH_FAILED":i===127&&/\bpython3:\s*(?:command\s+)?not found\b/u.test(t)?"DEPENDENCY_UNAVAILABLE":"TRANSPORT_FAILED"}a(H,"sshFailureCode");import{createHash as I}from"node:crypto";import{Type as n}from"typebox";import{Value as x}from"typebox/value";var d=class extends f{static{a(this,"SshBackendError")}constructor(t,r,e,o){super(t,r,e,o),this.name=t==="CANCELLED"?"AbortError":"SshBackendError"}},L=n.Object({bytes:n.String(),version:n.String({pattern:"^[a-f0-9]{64}$"})}),v=n.Object({directory:n.String(),path:n.String(),revision:n.String({pattern:"^[a-f0-9]{64}$"}),sourceRevision:n.String({pattern:"^[a-f0-9]{64}$"}),sha256:n.String({pattern:"^[a-f0-9]{64}$"})}),E=n.Object({revision:n.String({pattern:"^[a-f0-9]{64}$"}),bytes:n.String(),offset:n.Integer({minimum:0}),totalBytes:n.Integer({minimum:0})}),T=n.Array(n.Object({name:n.String(),kind:n.Union([n.Literal("file"),n.Literal("directory"),n.Literal("symlink"),n.Literal("other")])})),B=n.Object({kind:n.Union([n.Literal("file"),n.Literal("directory"),n.Literal("other")]),size:n.Integer({minimum:0}),mode:n.Integer({minimum:0})}),m=n.Object({kind:n.Union([n.Literal("file"),n.Literal("directory"),n.Literal("symlink"),n.Literal("other")]),size:n.Integer({minimum:0}),mode:n.Integer({minimum:0}),links:n.Integer({minimum:0}),identity:n.Object({device:n.String({pattern:"^[0-9]+$"}),inode:n.String({pattern:"^[0-9]+$"})}),revision:n.String({pattern:"^[a-f0-9]{64}$"})}),N=n.Object({path:n.String({minLength:1}),entries:n.Array(n.Object({relativePath:n.String(),kind:m.properties.kind,revision:m.properties.revision,identity:m.properties.identity,mode:n.Integer({minimum:0}),link:n.Optional(n.String())}))}),A=n.Union([n.Object({ok:n.Literal(!0),data:n.Unknown()}),n.Object({ok:n.Literal(!1),code:n.String({pattern:"^[A-Z][A-Z0-9_]*$"}),effect:n.Union([n.Literal("not-applied"),n.Literal("applied"),n.Literal("unknown")])})]),w=class{static{a(this,"SshBackend")}target;constructor(t){S(t),this.target={...t}}async stat(t,r={}){let e=await this.request({operation:"stat",path:t},!1,r);return this.checked(B,e,t,!1),e}async lstat(t,r={}){let e=await this.request({operation:"lstat",path:t},!1,r);return this.checked(m,e,t,!1),e}async temporaryEnvironment(t={}){let r=await this.request({operation:"temporary-environment",path:this.target.workspace},!1,t);return this.checked(n.Object({home:n.String({minLength:1,pattern:"^/"}),temporary:n.String({minLength:1,pattern:"^/"}),agentDirectory:n.Optional(n.String({minLength:1,pattern:"^/"}))}),r,this.target.workspace,!1),r}async objectSnapshot(t,r={}){let e=await this.request({operation:"object-snapshot",path:t},!1,r);return this.checked(N,e,t,!1),e}async ensureObjectDirectory(t,r,e,o={}){let s=await this.request({operation:"mkdir-object",path:t,mode:r,revision:e},!0,o);this.checked(n.Null(),s,t,!0)}async createObjectLink(t,r,e={}){let o=await this.request({operation:"symlink-object",path:t,link:r,revision:null},!0,e);this.checked(n.Null(),o,t,!0)}async setObjectMode(t,r,e,o={}){let s=await this.request({operation:"chmod-object",path:t,mode:r,revision:e},!0,o);this.checked(n.Null(),s,t,!0)}async moveObject(t,r,e={}){let o=await this.request({operation:"move-object",path:t.path,destination:r.path,sourceSnapshot:t,targetSnapshot:r},!0,e);return this.checked(n.Boolean(),o,t.path,!0),o}async captureJournal(t,r={}){let e=await this.request({operation:"journal",path:t},!1,r);return this.checked(v,e,t,!1),e}async releaseJournal(t,r={}){let e=await this.request({operation:"journal-release",path:t},!1,r);this.checked(n.Null(),e,t,!1)}async read(t,r={}){let e=await this.request({operation:"read",path:t},!1,r);return this.checked(L,e,t,!1),{bytes:Buffer.from(e.bytes,"base64"),version:e.version}}async readRange(t,r,e,o={}){if(!Number.isSafeInteger(r)||!Number.isSafeInteger(e)||e<0)throw new TypeError("Byte offset and limit must be safe integers; limit must be nonnegative");let s=await this.request({operation:"range",path:t,offset:r,limit:e},!1,o);return this.checked(E,s,t,!1),{bytes:Buffer.from(s.bytes,"base64"),offset:s.offset,totalBytes:s.totalBytes,revision:s.revision}}async list(t,r={}){let e=await this.request({operation:"list",path:t},!1,r);return this.checked(T,e,t,!1),e}async write(t,r,e,o={}){let s=await this.request({operation:"write",path:t,bytes:Buffer.from(r).toString("base64"),expected:e},!0,o);return this.checked(n.String({pattern:"^[a-f0-9]{64}$"}),s,t,!0),s}async copy(t,r,e,o,s={}){return this.copyEntry("copy",t,r,e,o,s)}async restoreJournal(t,r,e,o,s={}){return this.copyEntry("restore",t,r,e,o,s)}async copyEntry(t,r,e,o,s,c){let u=await this.request({operation:t,path:r,destination:e,sourceRevision:o,targetRevision:s},!0,c);this.checked(n.Null(),u,r,!0)}async move(t,r,e,o,s={}){let c=await this.request({operation:"move",path:t,destination:r,sourceRevision:e,targetRevision:o},!0,s);this.checked(n.Null(),c,t,!0)}async realpath(t,r={}){let e=await this.request({operation:"realpath",path:t},!1,r);if(this.checked(n.String({minLength:1}),e,t,!1),!e.startsWith("/"))throw new d("INVALID_RESPONSE",t,"not-applied");return e}async queryGit(t,r,e={}){let o=await this.request({operation:"git-query",path:t,args:r},!1,{...e,timeoutMs:5e3});return this.checked(n.String(),o,t,!1),o}async removeObject(t,r,e={}){let o=await this.request({operation:"delete-object",path:t,revision:r},!0,e);this.checked(n.Null(),o,t,!0)}async removeEntry(t,r,e={}){let o=await this.request({operation:"unlink",path:t,revision:r},!0,e);this.checked(n.Null(),o,t,!0)}async remove(t,r,e={}){let o=await this.request({operation:"remove",path:t,expected:r},!0,e);this.checked(n.Null(),o,t,!0)}async writeGitIndex(t,r,e={}){let o=Buffer.from(r.text,"utf8");if(o.length>32*1024*1024)throw new d("CONTENT_LIMIT",p(this.target.id,t).source,"not-applied");let{text:s,expectedIndexText:c,expectedWorktreeText:u,...g}=r,l=a(b=>I("sha256").update(b,"utf8").digest("hex"),"digest"),h=await this.request({operation:"gitIndex",path:t,...g,bytes:o.toString("base64"),expectedIndexHash:l(c),...u!==void 0&&{expectedWorktreeHash:l(u)}},!0,e);this.checked(n.Null(),h,t,!0)}async execute(t,r,e,o={}){let{runOwnedSshCommand:s}=await import("./chunk-K7SRNBIV.js");return s({...this.target,workspace:e},t,r,p(this.target.id,e).source,{signal:o.signal,timeoutMs:o.timeoutMs??3e4,maxBytes:32*1024*1024,limitCode:"CONTENT_LIMIT",closeInput:!0,effect:"unknown"})}async startProcess(t,r,e,o={}){let{startSshProcess:s}=await import("./chunk-SWBJS3U4.js");return s(this.target,t,r,e,o)}checked(t,r,e,o){if(!x.Check(t,r))throw new d("INVALID_RESPONSE",p(this.target.id,e).source,o?"unknown":"not-applied")}async request(t,r,e){let o=typeof t.path=="string"?t.path:typeof t.cwd=="string"?t.cwd:this.target.workspace,s=p(this.target.id,o).source,c=e.timeoutMs??3e4;if(!Number.isFinite(c)||c<=0)throw new TypeError("SSH operation deadline must be positive");e.signal?.throwIfAborted();let{runOwnedSshCommand:u}=await import("./chunk-K7SRNBIV.js"),g=await y(new URL("./ssh-worker.py",new URL("../src/backend/ssh.ts",import.meta.url).href)),l=await u({...this.target,workspace:t.operation==="gitIndex"?o:"/"},"python3",["-c",g],s,{signal:e.signal,timeoutMs:c,maxBytes:48*1024*1024,limitCode:"CONTENT_LIMIT",effect:r?"unknown":"not-applied",input:Buffer.from(JSON.stringify(t))});if(l.exitCode!==0)throw new d("REMOTE_OPERATION_FAILED",s,r?"unknown":"not-applied");let h;try{h=JSON.parse(l.stdout.toString("utf8"))}catch{throw new d("INVALID_RESPONSE",s,r?"unknown":"not-applied")}if(!j(h))throw new d("INVALID_RESPONSE",s,r?"unknown":"not-applied");if(!h.ok)throw new d(h.code,s,h.effect);return h.data}};function j(i){return x.Check(A,i)}a(j,"isReply");export{p as a,O as b,S as c,F as d,D as e,H as f,d as g,w as h};
1
+ import{h as f}from"./chunk-DDH3FP4G.js";import{a}from"./chunk-EI7MMDWY.js";import k from"node:path";function p(i,t){if(!/^[a-z0-9][a-z0-9_-]*$/u.test(i))throw new TypeError("SSH target IDs must contain lowercase letters, digits, underscores or hyphens");if(!t.startsWith("/")||t.includes("\0"))throw new TypeError("Remote paths must be absolute and contain no NUL characters");let r=k.posix.normalize(t),e=r.split("/").map(encodeURIComponent).join("/");return{target:i,path:r,source:`ssh://${i}${e}`}}a(p,"remoteLocation");function O(i,t){if(i.startsWith("ssh:")){let e=new URL(i);if(!i.startsWith("ssh://")||!e.hostname||e.username||e.password||e.port||e.search||e.hash||i.includes("?")||i.includes("#"))throw new TypeError("SSH references require a configured target and an absolute path, without credentials or selectors");return p(e.hostname,decodeURIComponent(e.pathname))}if(!t?.startsWith("ssh:")||/^[A-Za-z][A-Za-z\d+.-]*:/u.test(i))return;let r=O(t);if(!r)throw new TypeError("Invalid remote workspace");return p(r.target,k.posix.resolve(r.path,i))}a(O,"resolveRemoteLocation");import{readFile as C}from"node:fs/promises";function S(i){if(p(i.id,i.workspace),!/^(?:[A-Za-z0-9_][A-Za-z0-9_.-]*@)?[A-Za-z0-9_][A-Za-z0-9_.-]*$/u.test(i.host))throw new TypeError("SSH host must be an OpenSSH host alias, not a command or URI")}a(S,"validateSshTarget");async function y(i){return`exec(__import__("base64").b64decode("${(await C(i)).toString("base64")}"))`}a(y,"sshWorkerProgram");async function F(i){return`python3 -c '${await y(i)}'`}a(F,"sshWorkerCommand");function D(i,t){let r=["-T","-o","BatchMode=yes","-o","StrictHostKeyChecking=yes","-o","ForwardAgent=no","-o","PermitLocalCommand=no","-o","ClearAllForwardings=yes"];return i.configFile!==void 0&&r.push("-F",i.configFile),r.push("--",i.host,t),r}a(D,"systemSshArguments");function H(i,t){return/Host key verification failed|REMOTE HOST IDENTIFICATION HAS CHANGED|No .* host key is known/u.test(t)?"HOST_KEY_FAILED":/Permission denied \([^)]*\)/u.test(t)?"AUTH_FAILED":i===127&&/\bpython3:\s*(?:command\s+)?not found\b/u.test(t)?"DEPENDENCY_UNAVAILABLE":"TRANSPORT_FAILED"}a(H,"sshFailureCode");import{createHash as I}from"node:crypto";import{Type as n}from"typebox";import{Value as x}from"typebox/value";var d=class extends f{static{a(this,"SshBackendError")}constructor(t,r,e,o){super(t,r,e,o),this.name=t==="CANCELLED"?"AbortError":"SshBackendError"}},L=n.Object({bytes:n.String(),version:n.String({pattern:"^[a-f0-9]{64}$"})}),v=n.Object({directory:n.String(),path:n.String(),revision:n.String({pattern:"^[a-f0-9]{64}$"}),sourceRevision:n.String({pattern:"^[a-f0-9]{64}$"}),sha256:n.String({pattern:"^[a-f0-9]{64}$"})}),E=n.Object({revision:n.String({pattern:"^[a-f0-9]{64}$"}),bytes:n.String(),offset:n.Integer({minimum:0}),totalBytes:n.Integer({minimum:0})}),T=n.Array(n.Object({name:n.String(),kind:n.Union([n.Literal("file"),n.Literal("directory"),n.Literal("symlink"),n.Literal("other")])})),B=n.Object({kind:n.Union([n.Literal("file"),n.Literal("directory"),n.Literal("other")]),size:n.Integer({minimum:0}),mode:n.Integer({minimum:0})}),m=n.Object({kind:n.Union([n.Literal("file"),n.Literal("directory"),n.Literal("symlink"),n.Literal("other")]),size:n.Integer({minimum:0}),mode:n.Integer({minimum:0}),links:n.Integer({minimum:0}),identity:n.Object({device:n.String({pattern:"^[0-9]+$"}),inode:n.String({pattern:"^[0-9]+$"})}),revision:n.String({pattern:"^[a-f0-9]{64}$"})}),N=n.Object({path:n.String({minLength:1}),entries:n.Array(n.Object({relativePath:n.String(),kind:m.properties.kind,revision:m.properties.revision,identity:m.properties.identity,mode:n.Integer({minimum:0}),link:n.Optional(n.String())}))}),A=n.Union([n.Object({ok:n.Literal(!0),data:n.Unknown()}),n.Object({ok:n.Literal(!1),code:n.String({pattern:"^[A-Z][A-Z0-9_]*$"}),effect:n.Union([n.Literal("not-applied"),n.Literal("applied"),n.Literal("unknown")])})]),w=class{static{a(this,"SshBackend")}target;constructor(t){S(t),this.target={...t}}async stat(t,r={}){let e=await this.request({operation:"stat",path:t},!1,r);return this.checked(B,e,t,!1),e}async lstat(t,r={}){let e=await this.request({operation:"lstat",path:t},!1,r);return this.checked(m,e,t,!1),e}async temporaryEnvironment(t={}){let r=await this.request({operation:"temporary-environment",path:this.target.workspace},!1,t);return this.checked(n.Object({home:n.String({minLength:1,pattern:"^/"}),temporary:n.String({minLength:1,pattern:"^/"}),agentDirectory:n.Optional(n.String({minLength:1,pattern:"^/"}))}),r,this.target.workspace,!1),r}async objectSnapshot(t,r={}){let e=await this.request({operation:"object-snapshot",path:t},!1,r);return this.checked(N,e,t,!1),e}async ensureObjectDirectory(t,r,e,o={}){let s=await this.request({operation:"mkdir-object",path:t,mode:r,revision:e},!0,o);this.checked(n.Null(),s,t,!0)}async createObjectLink(t,r,e={}){let o=await this.request({operation:"symlink-object",path:t,link:r,revision:null},!0,e);this.checked(n.Null(),o,t,!0)}async setObjectMode(t,r,e,o={}){let s=await this.request({operation:"chmod-object",path:t,mode:r,revision:e},!0,o);this.checked(n.Null(),s,t,!0)}async moveObject(t,r,e={}){let o=await this.request({operation:"move-object",path:t.path,destination:r.path,sourceSnapshot:t,targetSnapshot:r},!0,e);return this.checked(n.Boolean(),o,t.path,!0),o}async captureJournal(t,r={}){let e=await this.request({operation:"journal",path:t},!1,r);return this.checked(v,e,t,!1),e}async releaseJournal(t,r={}){let e=await this.request({operation:"journal-release",path:t},!1,r);this.checked(n.Null(),e,t,!1)}async read(t,r={}){let e=await this.request({operation:"read",path:t},!1,r);return this.checked(L,e,t,!1),{bytes:Buffer.from(e.bytes,"base64"),version:e.version}}async readRange(t,r,e,o={}){if(!Number.isSafeInteger(r)||!Number.isSafeInteger(e)||e<0)throw new TypeError("Byte offset and limit must be safe integers; limit must be nonnegative");let s=await this.request({operation:"range",path:t,offset:r,limit:e},!1,o);return this.checked(E,s,t,!1),{bytes:Buffer.from(s.bytes,"base64"),offset:s.offset,totalBytes:s.totalBytes,revision:s.revision}}async list(t,r={}){let e=await this.request({operation:"list",path:t},!1,r);return this.checked(T,e,t,!1),e}async write(t,r,e,o={}){let s=await this.request({operation:"write",path:t,bytes:Buffer.from(r).toString("base64"),expected:e},!0,o);return this.checked(n.String({pattern:"^[a-f0-9]{64}$"}),s,t,!0),s}async copy(t,r,e,o,s={}){return this.copyEntry("copy",t,r,e,o,s)}async restoreJournal(t,r,e,o,s={}){return this.copyEntry("restore",t,r,e,o,s)}async copyEntry(t,r,e,o,s,c){let u=await this.request({operation:t,path:r,destination:e,sourceRevision:o,targetRevision:s},!0,c);this.checked(n.Null(),u,r,!0)}async move(t,r,e,o,s={}){let c=await this.request({operation:"move",path:t,destination:r,sourceRevision:e,targetRevision:o},!0,s);this.checked(n.Null(),c,t,!0)}async realpath(t,r={}){let e=await this.request({operation:"realpath",path:t},!1,r);if(this.checked(n.String({minLength:1}),e,t,!1),!e.startsWith("/"))throw new d("INVALID_RESPONSE",t,"not-applied");return e}async queryGit(t,r,e={}){let o=await this.request({operation:"git-query",path:t,args:r},!1,{...e,timeoutMs:5e3});return this.checked(n.String(),o,t,!1),o}async removeObject(t,r,e={}){let o=await this.request({operation:"delete-object",path:t,revision:r},!0,e);this.checked(n.Null(),o,t,!0)}async removeEntry(t,r,e={}){let o=await this.request({operation:"unlink",path:t,revision:r},!0,e);this.checked(n.Null(),o,t,!0)}async remove(t,r,e={}){let o=await this.request({operation:"remove",path:t,expected:r},!0,e);this.checked(n.Null(),o,t,!0)}async writeGitIndex(t,r,e={}){let o=Buffer.from(r.text,"utf8");if(o.length>32*1024*1024)throw new d("CONTENT_LIMIT",p(this.target.id,t).source,"not-applied");let{text:s,expectedIndexText:c,expectedWorktreeText:u,...g}=r,l=a(b=>I("sha256").update(b,"utf8").digest("hex"),"digest"),h=await this.request({operation:"gitIndex",path:t,...g,bytes:o.toString("base64"),expectedIndexHash:l(c),...u!==void 0&&{expectedWorktreeHash:l(u)}},!0,e);this.checked(n.Null(),h,t,!0)}async execute(t,r,e,o={}){let{runOwnedSshCommand:s}=await import("./chunk-G4PRFO6G.js");return s({...this.target,workspace:e},t,r,p(this.target.id,e).source,{signal:o.signal,timeoutMs:o.timeoutMs??3e4,maxBytes:32*1024*1024,limitCode:"CONTENT_LIMIT",closeInput:!0,effect:"unknown"})}async startProcess(t,r,e,o={}){let{startSshProcess:s}=await import("./chunk-U7YDLVFL.js");return s(this.target,t,r,e,o)}checked(t,r,e,o){if(!x.Check(t,r))throw new d("INVALID_RESPONSE",p(this.target.id,e).source,o?"unknown":"not-applied")}async request(t,r,e){let o=typeof t.path=="string"?t.path:typeof t.cwd=="string"?t.cwd:this.target.workspace,s=p(this.target.id,o).source,c=e.timeoutMs??3e4;if(!Number.isFinite(c)||c<=0)throw new TypeError("SSH operation deadline must be positive");e.signal?.throwIfAborted();let{runOwnedSshCommand:u}=await import("./chunk-G4PRFO6G.js"),g=await y(new URL("./ssh-worker.py",new URL("../src/backend/ssh.ts",import.meta.url).href)),l=await u({...this.target,workspace:t.operation==="gitIndex"?o:"/"},"python3",["-c",g],s,{signal:e.signal,timeoutMs:c,maxBytes:48*1024*1024,limitCode:"CONTENT_LIMIT",effect:r?"unknown":"not-applied",input:Buffer.from(JSON.stringify(t))});if(l.exitCode!==0)throw new d("REMOTE_OPERATION_FAILED",s,r?"unknown":"not-applied");let h;try{h=JSON.parse(l.stdout.toString("utf8"))}catch{throw new d("INVALID_RESPONSE",s,r?"unknown":"not-applied")}if(!j(h))throw new d("INVALID_RESPONSE",s,r?"unknown":"not-applied");if(!h.ok)throw new d(h.code,s,h.effect);return h.data}};function j(i){return x.Check(A,i)}a(j,"isReply");export{p as a,O as b,S as c,F as d,D as e,H as f,d as g,w as h};
@@ -0,0 +1,5 @@
1
+ import{g as m,h as y,j as T,n as x,r as S}from"./chunk-DDH3FP4G.js";import{m as O,o as E}from"./chunk-VDJSH3DQ.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Type as a}from"typebox";import{Value as f}from"typebox/value";import{Type as l}from"typebox";var R=l.Object({path:l.Optional(l.String({description:"What to read: a supported resource such as a file or directory path, URL, returned temp: reference, SEARCH# or RESULT# reference, or registered protocol source. Supply a path; an empty call cannot select a source."})),offset:l.Optional(l.Number({description:"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor, SEARCH or RESULT# selections, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit."})),limit:l.Optional(l.Number({description:"For raw: sources, use a non-negative byte count (0 reads no bytes). Otherwise, maximum lines from the selected starting position. Output is bounded; omit for the default read. For image and sequence views, limit is the square grid cell size in pixels; omit offset to select cell 0, or omit both for the bounded full image."})),views:l.Optional(l.Array(l.String(),{description:`Optional source-specific presentations. Combine views when both presentations are needed, for example ["anchors", "ast"]. Omit for the source's default presentation.`}))}),B={path:"What to read: a path, URL, unchanged Read/Search result or its UUID, or one of the forms below. temp:<id> \u2014 saved output; raw:<file> \u2014 original bytes.",offset:"First line, from 1; negative counts from the end. For raw:, a byte offset.",limit:"Maximum lines. For raw:, bytes.",views:"Extra presentations; combine them unless a view says otherwise."};function ie(e){let t=s((o,r)=>({...o,description:[B[r],e[r]].filter(d=>d!==void 0).join(`
2
+ `)}),"describe");return{...R,properties:{path:t(R.properties.path,"path"),offset:t(R.properties.offset,"offset"),limit:t(R.properties.limit,"limit"),views:t(R.properties.views,"views")}}}s(ie,"describeReadParameters");import{Type as n}from"typebox";function ue(e,t,o,r){if(!$(e))return{content:e,source:t,resolvedBy:o,preserveTruncatedOutput:r.preserveTruncatedOutput,textMode:r.textMode,contentKind:"other"};let d=e[0].text;return{content:e,source:t,resolvedBy:o,preserveTruncatedOutput:r.preserveTruncatedOutput,textMode:r.textMode,contentKind:"text",text:O(t,d)}}s(ue,"createReadState");function pe(e,t,o){if(e.contentKind!=="text"){if(t.offset!==void 0||t.limit!==void 0)return M({code:"UNSUPPORTED_RANGE",source:e.source,resolverId:e.resolvedBy,message:"Line ranges require textual content. Omit offset and limit to read this content without a line range."});let u=V(e.content);return{script:{kind:"native",source:e.source,blocks:e.content},content:u.content,details:{...C(e),...u.unsupportedContentBlocks!==void 0&&{unsupportedContentBlocks:u.unsupportedContentBlocks}}}}let r=e.text.lines.length,d=H(t,r,o?.originLine),i=e.text.lines.slice(d.startIndex,d.endIndex),c=e.textMode==="final"?j(i,d.endIndex<r):E({...e.text,lines:i.map((u,U)=>({...u,lineEnding:U===i.length-1&&d.endIndex<r?"":u.lineEnding}))}),b=e.content[0],F=[{type:"text",text:c,...b.textSignature!==void 0&&{textSignature:b.textSignature}}];return{script:{kind:"text",...e.text.references===void 0?{}:{references:e.text.references},source:e.source,content:i.map(u=>u.content+u.lineEnding).join(""),lines:i,startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:r},content:F,details:{...C(e),startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:r,lines:i}}}s(pe,"projectReadState");function j(e,t){return e.map((o,r)=>`${o.content}${r===e.length-1&&t?"":o.lineEnding}`).join("")}s(j,"renderFinalTextLines");function L(e){let t=e.cause,o,r=new Set;for(;t instanceof Error&&!r.has(t);)r.add(t),o=t,t=t.cause;return o}s(L,"deepestCause");var k="Supply path with a source or an unchanged result reference.",v=s(e=>`Read ${JSON.stringify(e)} with views=["anchors"] and choose a current anchor.`,"fragmentRecovery");function w(e){return e.candidates?.length?["Possible matches:",...e.candidates.map(t=>`- ${JSON.stringify(t.path)}`),"","Retry read with an exact candidate path."]:[]}s(w,"candidateLines");function P(e){let t=L(e),o=t!==void 0&&"code"in t?t.code:void 0,r=[];return o==="ENOENT"&&!e.candidates?.length&&r.push("Search for the correct path."),e.code==="INVALID_REQUEST"?r.push(k):e.code==="FRAGMENT_FAILED"&&e.source!==void 0?r.push(v(e.source)):e.code==="NO_RESOLVER"?r.push("Choose a supported source from the path parameter."):e.code==="NO_FRAGMENT_RESOLVER"&&r.push("Read the source without the anchor."),[...r,...w(e)]}s(P,"readFailureRecovery");function _(e){let t=L(e),o=t!==void 0&&"code"in t?t.code:void 0,r=t?.message||e.message;return o==="ENOENT"?r=e.candidates?.length?"Source not found.":"Source not found. Search for the correct path.":o==="EACCES"||o==="EPERM"?r="Access denied.":e.code==="INVALID_RESOLVER_RESULT"?r="The source provider returned an invalid result.":e.code==="INVALID_RESOURCE_CONTENT"?r="The source provider returned invalid content.":e.code==="UNSUPPORTED_CAPABILITY"?r="This source does not support reading.":e.code==="NO_RESOLVER"?r="This source is not supported. Choose a supported source from the path parameter.":e.code==="NO_FRAGMENT_RESOLVER"&&(r="This anchor is not supported. Read the source without the anchor."),e.code==="INVALID_REQUEST"?r+=`. ${k}`:e.code==="FRAGMENT_FAILED"&&e.source!==void 0&&(r+=`
3
+ ${v(e.source)}`),`Read failed${e.source===void 0?"":` for ${JSON.stringify(e.source)}`}: ${r}`}s(_,"readFailureMessage");function Re(e,t,o){if(!o?.aborted||!e.isError)return e;let r=e.details.source??e.details.failure?.source??t;return{...e,content:[{type:"text",text:`Read cancelled${r===void 0?"":` for ${JSON.stringify(r)}`}. No completed result was returned.`}]}}s(Re,"withReadCancellation");function M(e){let t=e.cause instanceof y?e.cause:void 0;return t!==void 0?e={...e,source:e.source??t.source,message:`${t.code}: ${e.source??t.source}`,cause:new y(t.code,t.source,t.effect,{metadata:m(t)})}:e.cause instanceof Error&&"code"in e.cause&&!["ENOENT","EACCES","EPERM"].includes(String(e.cause.code))&&(e={...e,message:`${e.code}: ${e.source??"source"}`,cause:void 0}),{content:[{type:"text",text:[_(e),...e.candidates?.length?["",...w(e)]:[]].join(`
4
+ `)}],details:{failure:e},isError:!0}}s(M,"failureResult");function C(e){return{source:e.source,resolvedBy:e.resolvedBy}}s(C,"readDetails");function V(e){let t=[],o=[];for(let[d,i]of e.entries()){if(i.type!=="custom"){t.push(i);continue}o.push({index:d,kind:i.kind}),t.push({type:"text",text:`[unsupported_content_block kind=${i.kind} index=${d}]`})}let r=o[0];return{content:t,...r!==void 0&&{unsupportedContentBlocks:[r,...o.slice(1)]}}}s(V,"projectAgentContent");function H(e,t,o){let r=e.offset===void 0?1:Math.trunc(e.offset),d=q(r,t,o),i=e.limit===void 0?t:Math.max(0,Math.trunc(e.limit));return{startIndex:Math.min(t,d-1),endIndex:Math.min(t,d-1+i)}}s(H,"resolveTextRange");function q(e,t,o){if(o===void 0)return e<0?Math.max(1,t+e+1):Math.max(1,e);let r=e<0?o+e:o+Math.max(1,e)-1;return Math.max(1,r)}s(q,"anchoredStartLine");function $(e){return e.length===1&&e[0].type==="text"}s($,"isSingleTextContent");var G=n.Object({value:n.String(),kind:n.String(),state:n.Optional(n.String())},{additionalProperties:!1}),K=n.Object({lineNumber:n.Integer(),content:n.String(),lineEnding:n.String(),anchors:n.Optional(n.Array(n.String()))},{additionalProperties:!1}),W=n.Object({path:n.String(),offset:n.Integer()},{additionalProperties:!1}),h={source:n.String(),truncated:n.Boolean(),continuation:n.Optional(W),fullResult:n.Optional(n.String())},N=n.Object({...h,kind:n.Literal("text"),target:n.Optional(n.String()),lines:n.Array(K),startLine:n.Integer(),endLine:n.Integer(),totalLines:n.Integer(),references:n.Optional(n.Array(G))},{additionalProperties:!1}),D=n.Object({...h,kind:n.Literal("bytes"),bytes:n.Array(n.Integer({minimum:0,maximum:255})),byteOffset:n.Integer(),byteLength:n.Integer(),totalBytes:n.Integer()},{additionalProperties:!1}),J=n.Union([n.Object({type:n.Literal("text"),text:n.String()},{additionalProperties:!1}),n.Object({type:n.Literal("image"),mimeType:n.String()},{additionalProperties:!1})]),A=n.Object({...h,kind:n.Literal("native"),blocks:n.Array(J)},{additionalProperties:!1}),g=n.Union([n.Object({kind:n.Literal("recovery"),source:n.String(),candidates:n.Array(n.Object({path:n.String()},{additionalProperties:!1}))},{additionalProperties:!1}),N,D,A,n.Object({kind:n.Literal("resources"),source:n.Optional(n.String()),resources:n.Array(n.Union([N,D,A])),truncated:n.Boolean(),fullResult:n.Optional(n.String())},{additionalProperties:!1})]),z=T(g);function Q(e){return{lineNumber:e.lineNumber,content:e.content,lineEnding:e.lineEnding,...e.anchors===void 0?{}:{anchors:[...e.anchors]}}}s(Q,"publicLine");function I(e){if(e.kind==="resources"){let i=e.resources.map(c=>I(c));return{kind:e.kind,...e.source===void 0?{}:{source:e.source},resources:i,truncated:i.some(c=>typeof c=="object"&&c!==null&&"truncated"in c&&c.truncated===!0)}}if(e.kind==="bytes"){let i=e.bytes.slice(0,32768),c=e.truncated===!0||i.length<e.bytes.length;return{kind:e.kind,source:e.source,bytes:i,byteOffset:e.byteOffset,byteLength:i.length,totalBytes:e.totalBytes,truncated:c,...e.byteOffset+i.length<e.totalBytes?{continuation:{path:e.source,offset:e.byteOffset+i.length}}:{}}}if(e.kind==="native")return{kind:e.kind,source:e.source,truncated:!1,blocks:e.blocks.map(i=>{if(i.type==="text")return{type:i.type,text:i.text};if(i.type==="image")return{type:i.type,mimeType:i.mimeType};throw new TypeError("Custom content requires a structured adapter")})};let t=[],o=0;for(let i of e.lines){let c=Q(i);if(o+=Buffer.byteLength(JSON.stringify(c)),t.length>=2e3||o>512*1024)break;t.push(c)}if(t.length===0&&e.lines.length>0)throw new RangeError("Selected line exceeds the structured window; use a raw byte range or a source-specific view");let r=t.length<e.lines.length,d=t.at(-1)?.lineNumber??e.startLine-1;return{kind:e.kind,source:e.source,...e.target===void 0?{}:{target:e.target},lines:t,startLine:t[0]?.lineNumber??0,endLine:t.at(-1)?.lineNumber??0,totalLines:e.totalLines,truncated:r,...e.target===void 0?{}:{target:e.target},...e.references===void 0?{}:{references:e.references},...r||d<e.totalLines?{continuation:{path:e.source,offset:d+1}}:{}}}s(I,"publicData");function Y(e){let t=e.details.failure,o=t?.cause instanceof y?t.cause:void 0,r=o===void 0?void 0:m(o);if(e.isError||t!==void 0)return x(e,g,{status:"error",...t?.candidates?.length&&t.source!==void 0?{data:{kind:"recovery",source:t.source,candidates:t.candidates}}:{},errors:[{code:o?.code??t?.code??"READ_FAILED",message:o===void 0?[t?.message??"Read failed",...t===void 0?[]:P(t)].join(`
5
+ `):`${o.code}: ${t?.source??o.source}`,...t?.source===void 0?{}:{source:t.source},...r===void 0?{}:{metadata:r}}]});try{if(e.script===void 0)throw new TypeError("Read handler must return structured script data");let d=I(e.script);return x(e,g,{status:"success",data:e.details.temporarySource!==void 0&&typeof d=="object"&&d!==null?{...d,fullResult:e.details.temporarySource}:d,errors:[]})}catch(d){return x(e,g,{status:"error",errors:[{code:d instanceof RangeError?"STRUCTURED_RESULT_TOO_LARGE":"STRUCTURED_ADAPTER_REQUIRED",message:d instanceof Error?d.message:String(d)}]})}}s(Y,"structuredRead");var p=a.Function([],a.Unknown()),X=a.Object({resolver:a.Unknown(),matchesCall:a.Optional(p),renderCall:a.Optional(p),priority:a.Optional(a.Number()),renderResult:a.Optional(p),preserveTruncatedOutput:a.Optional(a.Boolean())}),Z=a.Object({resolver:a.Unknown(),priority:a.Optional(a.Number())}),ee=a.Object({id:a.String({pattern:"\\S"}),priority:a.Optional(a.Number()),resolve:p}),te=a.Object({view:a.String({pattern:"\\S"}),contentKind:a.Optional(a.Union([a.Literal("text"),a.Literal("any")])),includes:a.Optional(a.Array(a.String({pattern:"\\S"}))),presenter:a.Object({id:a.String(),present:p}),priority:a.Optional(a.Number())}),ne=a.Object({resolvedBy:a.String({pattern:"\\S"}),contentKind:a.Union([a.Literal("text"),a.Literal("any")])}),re=a.Union([a.Object({stage:a.Literal("pre-read"),handler:p}),a.Object({stage:a.Literal("read"),when:ne,handler:p}),a.Object({stage:a.Literal("post-read"),handler:p})]);function Ee(e){if(!f.Check(Z,e))return!1;let t=e,o=t.resolver;return typeof o.id=="string"&&o.id.length>0&&typeof o.tryResolve=="function"&&(!("priority"in t)||typeof t.priority=="number")}s(Ee,"isTextTargetResolverRegistration");function Ce(e){if(!f.Check(X,e))return!1;let t=e;return S(t.resolver)?t.resolver.id!=="any"&&(!("priority"in t)||typeof t.priority=="number")&&(!("matchesCall"in t)||typeof t.matchesCall=="function")&&(!("renderCall"in t)||typeof t.renderCall=="function")&&"matchesCall"in t=="renderCall"in t&&(!("renderResult"in t)||typeof t.renderResult=="function"):!1}s(Ce,"isResourceResolverRegistration");function Le(e){return f.Check(re,e)}s(Le,"isReadHandlerRegistration");function ke(e){return f.Check(te,e)}s(ke,"isReadViewRegistration");function ve(e){return f.Check(ee,e)}s(ve,"isFragmentResolverRegistration");function we(e){return oe(e)?e.kind==="not-handled"?!0:e.kind==="failed"?typeof e.message=="string"&&e.message.length>0:e.kind==="resolved"&&typeof e.originLine=="number":!1}s(we,"isReadFragmentResolution");function oe(e){return typeof e=="object"&&e!==null}s(oe,"isRecord");export{R as a,ie as b,ue as c,pe as d,Re as e,M as f,q as g,g as h,z as i,Y as j,Ee as k,Ce as l,Le as m,ke as n,ve as o,we as p};
@@ -0,0 +1 @@
1
+ import{a as u}from"./chunk-VDJSH3DQ.js";import{a as d}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";var y=Symbol.for("pi-agent-text-editor/TextSelectionAnchor"),x=class extends u{constructor(t,o,i,p){let c=i.map(r=>({start:{...r.start},end:{...r.end},...r.linewise===!0&&{linewise:!0}}));m(c);super(t,d(c[0]).start.lineNumber);this.source=o;if(o.length===0)throw new TypeError("Text selection anchor source must be non-empty");if(this.ranges=c,p!==void 0){let r=p.map(s=>({start:{...s.start},end:{...s.end},...s.linewise===!0&&{linewise:!0}}));if(m(r),r.length!==c.length||r.some((s,h)=>{let f=d(c[h]);return l(s.start,f.start)<0||l(s.end,f.end)>0}))throw new RangeError("Endpoint ranges must stay within their corresponding selection ranges");this.endpointRanges=r}}static{a(this,"TextSelectionAnchor")}[y]=!0;ranges;endpointRanges;static is(t){if(!u.is(t))return!1;try{let o=t,i=o.ranges;return o[y]===!0&&typeof o.source=="string"&&o.source.length>0&&Array.isArray(i)&&i.length>0&&i.every(g)&&(o.endpointRanges===void 0||Array.isArray(o.endpointRanges)&&o.endpointRanges.length===i.length&&o.endpointRanges.every(g))}catch{return!1}}};function m(n){if(n.length===0)throw new TypeError("Text selection anchor must contain at least one range");let e;for(let t of n){if(!g(t)||l(t.start,t.end)>0)throw new RangeError("Text selection anchor contains an invalid range");if(e!==void 0&&l(t.start,e.end)<0)throw new Error("Text selection anchor ranges must be ordered and must not overlap");e=t}}a(m,"assertSelectionRanges");function g(n){if(typeof n!="object"||n===null)return!1;let e=n;return T(e.start)&&T(e.end)&&(e.linewise===void 0||typeof e.linewise=="boolean")}a(g,"isTextSelectionRange");function T(n){if(typeof n!="object"||n===null)return!1;let e=n;return Number.isSafeInteger(e.lineNumber)&&(e.lineNumber??0)>=1&&Number.isSafeInteger(e.column)&&(e.column??-1)>=0}a(T,"isTextSelectionPosition");function l(n,e){return n.lineNumber-e.lineNumber||n.column-e.column}a(l,"comparePositions");export{x as a};
@@ -1,7 +1,7 @@
1
- import{a as o}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";var f=class i{static{s(this,"FileRange")}start;end;constructor(e,t=e){t.lineNumber<e.lineNumber&&([e,t]=[t,e]),this.start=e,this.end=t}static fromLines(e,t){let n=t??e;return new i({lineNumber:e},{lineNumber:n})}},l=class i{static{s(this,"FileMutationResult")}data;constructor(e){let t=e?.formatting;this.data=t===void 0||e?.diffStatuses===void 0?e??{}:{...e,diffStatuses:e.diffStatuses.map(n=>n.formattingStatus!==void 0||t.formatter===void 0||n.formatter!==t.formatter||n.tone!=="success"&&n.tone!=="error"?n:{...n,formattingStatus:t.status})}}get ok(){return this.data.ok??!1}get isPartial(){return this.data.isPartial??!1}get diffs(){return this.data.diffs??[]}get files(){return this.data.files??[]}get warnings(){return this.data.warnings??[]}get errors(){return this.data.errors??[]}get lintViolations(){return this.data.lintViolations??[]}get hints(){return this.data.hints??[]}get syntaxErrorSummary(){return this.data.syntaxErrorSummary}get path(){return this.data.path}get editRange(){let e=this.data.activeEdits,t=e?.[0];if(t?.range){let n=t.range.start,a=o(e).at(-1)?.range?.end??n;return new f(n,a)}return this.data.editRange}get resolvedStartLine(){return this.editRange?.start.lineNumber}get resolvedEndLine(){return this.editRange?.end.lineNumber}get freshAnchors(){return this.data.freshAnchors}get failurePoint(){return this.data.failurePoint}get recovery(){return this.data.recovery}get expectedAnchor(){return this.data.expectedAnchor}get currentAnchor(){return this.data.currentAnchor}get internalErrorType(){return this.data.internalErrorType}get internalErrorMessage(){return this.data.internalErrorMessage}get editCount(){return this.data.editCount}get editRanges(){return this.data.editRanges}get addedLines(){return this.data.addedLines}get removedLines(){return this.data.removedLines}get appliedPaths(){return this.data.appliedPaths}get beforeContentMap(){return this.data.beforeContentMap}get afterContent(){return this.data.afterContent}get skipCount(){return this.data.skipCount??0}get staleEdits(){return this.data.staleEdits??[]}get proposedDiff(){return this.data.proposedDiff}get editIndex(){return this.data.editIndex}get editIndices(){return this.data.editIndices}get staleDiagnostic(){return this.data.staleDiagnostic}get fileChangedStatement(){return this.data.fileChangedStatement}get affectedPaths(){let e=new Set;for(let t of this.files)e.add(t.path);for(let t of this.errors)t.path&&e.add(t.path);for(let t of this.warnings)t.file&&e.add(t.file);return[...e]}get didChange(){return this.ok&&(this.files.length>0||this.diffs.length>0)}get createdFiles(){return this.files.filter(e=>e.action==="created")}get overwrittenFiles(){return this.files.filter(e=>e.action==="overwritten"||e.action==="edited")}get staleCount(){return this.staleEdits.length}get summary(){if(!this.ok){let r=this.errors[0];return r?`Failed: ${r.code??"ERROR"}${r.reason?` \u2014 ${r.reason}`:""}`:"Mutation failed"}if(this.files.length===0&&this.diffs.length===0){let r=this.appliedPaths;return r&&r.length>0?`${r.length} path${r.length===1?"":"s"} affected`:"No changes"}let e=this.createdFiles.length,t=this.overwrittenFiles.length,n=[];if(e>0&&n.push(`Created ${e} ${e===1?"file":"files"}`),t>0&&n.push(`Edited ${t} ${t===1?"file":"files"}`),this.diffs.length>0){let r=0,a=0;for(let d of this.diffs)for(let u of d.split(`
2
- `))u.startsWith("+")&&!u.startsWith("+++")?r++:u.startsWith("-")&&!u.startsWith("---")&&a++;(r>0||a>0)&&n.push(`+${r}/-${a} lines`)}return n.join(", ")}getFileChange(e){return this.files.find(t=>t.path===e)}getDiffFor(e){let t=g(e);for(let n of this.diffs){let r=n.match(/^---\s+(.+)$/m);if(r&&(g(o(r[1]))===t||r[1]===e))return n}}getErrorsFor(e){return this.errors.filter(t=>t.path===e)}getWarningsFor(e){return this.warnings.filter(t=>t.file===e)}static fromFailureOptions(e){return new i({ok:!1,path:e.path,errors:[{path:e.path,code:e.code,reason:e.reason}],failurePoint:e.failurePoint,recovery:e.recovery,expectedAnchor:e.expectedAnchor,currentAnchor:e.currentAnchor,freshAnchors:e.freshLines?[...e.freshLines]:void 0,internalErrorType:e.internalError instanceof Error?e.internalError.name:void 0,internalErrorMessage:e.internalError instanceof Error?e.internalError.message:void 0})}static ensure(e){if(e instanceof i)return e;if(e&&typeof e=="object"){let t=e;return t.data&&typeof t.data=="object"?(Object.setPrototypeOf(t,i.prototype),t):new i(t)}return new i}};function g(i){return i.replace(/\\/g,"/").replace(/^a\//,"").replace(/^b\//,"")}s(g,"normalisePath");import{createTwoFilesPatch as p,diffLines as c}from"diff";function D(i,e,t,n=i){return{diff:p(i,n,e,t,"","",{context:3}).replace(/^(?:Index: .*\n)?={3,}\n?/m,"").trimEnd(),stats:m(e,t)}}s(D,"createUnifiedDiff");function m(i,e){let t=0,n=0;for(let r of c(i,e)){let a=h(r.value);r.removed&&(t+=a),r.added&&(n+=a)}return{removed:t,added:n}}s(m,"computeStats");function h(i){if(i.length===0)return 0;let e=i.replaceAll(`\r
1
+ import{a as s}from"./chunk-ZC65Z3CK.js";import{a as o}from"./chunk-EI7MMDWY.js";var f=class i{static{o(this,"FileRange")}start;end;constructor(e,t=e){t.lineNumber<e.lineNumber&&([e,t]=[t,e]),this.start=e,this.end=t}static fromLines(e,t){let n=t??e;return new i({lineNumber:e},{lineNumber:n})}},l=class i{static{o(this,"FileMutationResult")}data;constructor(e){let t=e?.formatting;this.data=t===void 0||e?.diffStatuses===void 0?e??{}:{...e,diffStatuses:e.diffStatuses.map(n=>n.formattingStatus!==void 0||t.formatter===void 0||n.formatter!==t.formatter||n.tone!=="success"&&n.tone!=="error"?n:{...n,formattingStatus:t.status})}}get ok(){return this.data.ok??!1}get isPartial(){return this.data.isPartial??!1}get diffs(){return this.data.diffs??[]}get files(){return this.data.files??[]}get warnings(){return this.data.warnings??[]}get errors(){return this.data.errors??[]}get lintViolations(){return this.data.lintViolations??[]}get hints(){return this.data.hints??[]}get syntaxErrorSummary(){return this.data.syntaxErrorSummary}get path(){return this.data.path}get editRange(){let e=this.data.activeEdits,t=e?.[0];if(t?.range){let n=t.range.start,a=s(e).at(-1)?.range?.end??n;return new f(n,a)}return this.data.editRange}get resolvedStartLine(){return this.editRange?.start.lineNumber}get resolvedEndLine(){return this.editRange?.end.lineNumber}get freshAnchors(){return this.data.freshAnchors}get failurePoint(){return this.data.failurePoint}get recovery(){return this.data.recovery}get expectedAnchor(){return this.data.expectedAnchor}get currentAnchor(){return this.data.currentAnchor}get internalErrorType(){return this.data.internalErrorType}get internalErrorMessage(){return this.data.internalErrorMessage}get editCount(){return this.data.editCount}get editRanges(){return this.data.editRanges}get addedLines(){return this.data.addedLines}get removedLines(){return this.data.removedLines}get appliedPaths(){return this.data.appliedPaths}get beforeContentMap(){return this.data.beforeContentMap}get afterContent(){return this.data.afterContent}get skipCount(){return this.data.skipCount??0}get staleEdits(){return this.data.staleEdits??[]}get proposedDiff(){return this.data.proposedDiff}get editIndex(){return this.data.editIndex}get editIndices(){return this.data.editIndices}get staleDiagnostic(){return this.data.staleDiagnostic}get fileChangedStatement(){return this.data.fileChangedStatement}get affectedPaths(){let e=new Set;for(let t of this.files)e.add(t.path);for(let t of this.errors)t.path&&e.add(t.path);for(let t of this.warnings)t.file&&e.add(t.file);return[...e]}get didChange(){return this.ok&&(this.files.length>0||this.diffs.length>0)}get createdFiles(){return this.files.filter(e=>e.action==="created")}get overwrittenFiles(){return this.files.filter(e=>e.action==="overwritten"||e.action==="edited")}get staleCount(){return this.staleEdits.length}get summary(){if(!this.ok){let r=this.errors[0];return r?`Failed: ${r.code??"ERROR"}${r.reason?` \u2014 ${r.reason}`:""}`:"Mutation failed"}if(this.files.length===0&&this.diffs.length===0){let r=this.appliedPaths;return r&&r.length>0?`${r.length} path${r.length===1?"":"s"} affected`:"No changes"}let e=this.createdFiles.length,t=this.overwrittenFiles.length,n=[];if(e>0&&n.push(`Created ${e} ${e===1?"file":"files"}`),t>0&&n.push(`Edited ${t} ${t===1?"file":"files"}`),this.diffs.length>0){let r=0,a=0;for(let d of this.diffs)for(let u of d.split(`
2
+ `))u.startsWith("+")&&!u.startsWith("+++")?r++:u.startsWith("-")&&!u.startsWith("---")&&a++;(r>0||a>0)&&n.push(`+${r}/-${a} lines`)}return n.join(", ")}getFileChange(e){return this.files.find(t=>t.path===e)}getDiffFor(e){let t=g(e);for(let n of this.diffs){let r=n.match(/^---\s+(.+)$/m);if(r&&(g(s(r[1]))===t||r[1]===e))return n}}getErrorsFor(e){return this.errors.filter(t=>t.path===e)}getWarningsFor(e){return this.warnings.filter(t=>t.file===e)}static fromFailureOptions(e){return new i({ok:!1,path:e.path,errors:[{path:e.path,code:e.code,reason:e.reason}],failurePoint:e.failurePoint,recovery:e.recovery,expectedAnchor:e.expectedAnchor,currentAnchor:e.currentAnchor,freshAnchors:e.freshLines?[...e.freshLines]:void 0,internalErrorType:e.internalError instanceof Error?e.internalError.name:void 0,internalErrorMessage:e.internalError instanceof Error?e.internalError.message:void 0})}static ensure(e){if(e instanceof i)return e;if(e&&typeof e=="object"){let t=e;return t.data&&typeof t.data=="object"?(Object.setPrototypeOf(t,i.prototype),t):new i(t)}return new i}};function g(i){return i.replace(/\\/g,"/").replace(/^a\//,"").replace(/^b\//,"")}o(g,"normalisePath");import{createTwoFilesPatch as p,diffLines as c}from"diff";function D(i,e,t,n=i){return{diff:p(i,n,e,t,"","",{context:3}).replace(/^(?:Index: .*\n)?={3,}\n?/m,"").trimEnd(),stats:m(e,t)}}o(D,"createUnifiedDiff");function m(i,e){let t=0,n=0;for(let r of c(i,e)){let a=h(r.value);r.removed&&(t+=a),r.added&&(n+=a)}return{removed:t,added:n}}o(m,"computeStats");function h(i){if(i.length===0)return 0;let e=i.replaceAll(`\r
3
3
  `,`
4
4
  `);return e.endsWith(`
5
5
  `)?e.slice(0,-1).split(`
6
6
  `).length:e.split(`
7
- `).length}s(h,"countDiffLines");function y(i,e){let t=c(i,e),n=[],r=0;for(let a of t){let d=h(a.value);d!==0&&(a.removed||(a.added&&n.push({start:r+1,end:r+d}),r+=d))}return E(n)}s(y,"computeChangedRanges");function E(i){if(i.length===0)return[];let e=[...i].sort((n,r)=>n.start-r.start),t=[o(e[0])];for(let n=1;n<e.length;n++){let r=o(t.at(-1)),a=o(e[n]);a.start<=r.end+1?r.end=Math.max(r.end,a.end):t.push(a)}return t}s(E,"mergeAdjacentRanges");export{f as a,l as b,D as c,y as d};
7
+ `).length}o(h,"countDiffLines");function y(i,e){let t=c(i,e),n=[],r=0;for(let a of t){let d=h(a.value);d!==0&&(a.removed||(a.added&&n.push({start:r+1,end:r+d}),r+=d))}return E(n)}o(y,"computeChangedRanges");function E(i){if(i.length===0)return[];let e=[...i].sort((n,r)=>n.start-r.start),t=[s(e[0])];for(let n=1;n<e.length;n++){let r=s(t.at(-1)),a=s(e[n]);a.start<=r.end+1?r.end=Math.max(r.end,a.end):t.push(a)}return t}o(E,"mergeAdjacentRanges");export{f as a,l as b,D as c,y as d};
@@ -0,0 +1 @@
1
+ import{a as g,c as P,d as T}from"./chunk-B25LXXNV.js";import{a as w}from"./chunk-MDD5ORB6.js";import{b as y,c as h}from"./chunk-MLFJU2US.js";import{a as v}from"./chunk-ZAWRSA7N.js";import{a as b,b as j}from"./chunk-OFILFO6D.js";import{b as C,c as k,g as R,i as E,k as F,m as d,n as x}from"./chunk-7D7PXIVV.js";import{a as f}from"./chunk-EI7MMDWY.js";var A=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".html",".md",".yaml",".yml",".vue",".svelte"],z=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".less",".html",".htm",".md",".markdown",".mdx",".yaml",".yml",".toml"],p=[e("dart-format",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],[".dart"],["dart","format","{file}"],"https://dart.dev/tools/dart-format"),e("zig-format",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","fmt","{file}"],"https://ziglang.org/documentation/master/"),e("styler",["r"],["Rscript"],[".Rprofile","DESCRIPTION"],[".r"],["Rscript","-e","styler::style_file(commandArgs(TRUE)[1])","{file}"],"https://styler.r-lib.org/"),e("clang-format",["c","cpp"],["clang-format"],[".clang-format","_clang-format"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-format","-i","{file}"],"https://clang.llvm.org/docs/ClangFormat.html"),e("prettier",["javascript","typescript","html","css","json","yaml","markdown","vue","svelte"],["prettier"],[".prettierrc",".prettierrc.json",".prettierrc.json5",".prettierrc.yaml",".prettierrc.yml",".prettierrc.toml",".prettierrc.js",".prettierrc.cjs",".prettierrc.mjs","prettier.config.js","prettier.config.cjs","prettier.config.mjs","prettier.config.ts","prettier.config.mts","prettier.config.cts"],A,["prettier","--write","{file}"],"https://prettier.io/docs/",["prettier"],{"package.json":["prettier"]}),e("biome",["javascript","typescript","json","css"],["biome"],["biome.json","biome.jsonc"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css"],["biome","format","--write","{file}"],"https://biomejs.dev/",["@biomejs/biome"]),e("oxfmt",["javascript","typescript","json","css","html","markdown","yaml","toml"],["oxfmt"],[".oxfmtrc.json",".oxfmtrc.jsonc","oxfmt.config.ts","oxfmt.config.mts"],z,["oxfmt","--write","{file}"],"https://oxc.rs/docs/guide/usage/formatter.html",["oxfmt"]),e("ruff-format",["python"],["ruff"],["ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","format","{file}"],"https://docs.astral.sh/ruff/formatter/",["ruff"],{"pyproject.toml":["tool.ruff"]}),e("black",["python"],["black"],[],[".py",".pyi"],["black","--quiet","{file}"],"https://black.readthedocs.io/",["black"],{"pyproject.toml":["tool.black"]}),e("gofmt",["go"],["gofmt"],["go.mod"],[".go"],["gofmt","-w","{file}"],"https://pkg.go.dev/cmd/gofmt"),e("goimports",["go"],["goimports"],["go.mod"],[".go"],["goimports","-w","{file}"],"https://pkg.go.dev/golang.org/x/tools/cmd/goimports"),e("rustfmt",["rust"],["rustfmt"],["rustfmt.toml",".rustfmt.toml","Cargo.toml"],[".rs"],["rustfmt","{file}"],"https://github.com/rust-lang/rustfmt"),e("csharpier",["csharp"],["csharpier"],[".csharpierrc",".csharpierrc.json",".csharpierrc.yaml",".csharpierrc.yml"],[".cs"],["csharpier","format","{file}"],"https://csharpier.com/"),e("google-java-format",["java"],["google-java-format"],["pom.xml","build.gradle"],[".java"],["google-java-format","--replace","{file}"],"https://github.com/google/google-java-format"),e("ktlint-format",["kotlin"],["ktlint"],[".editorconfig","build.gradle.kts"],[".kt",".kts"],["ktlint","-F","{file}"],"https://pinterest.github.io/ktlint/"),e("rubocop-format",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--fix-layout","{file}"],"https://docs.rubocop.org/"),e("pint",["php"],["pint"],["pint.json","composer.json"],[".php"],["pint","{file}"],"https://laravel.com/docs/pint"),e("swift-format",["swift"],["swift-format"],[".swift-format","Package.swift"],[".swift"],["swift-format","format","--in-place","{file}"],"https://github.com/swiftlang/swift-format"),e("stylua",["lua"],["stylua"],["stylua.toml",".stylua.toml"],[".lua"],["stylua","{file}"],"https://github.com/JohnnyMorganz/StyLua"),e("shfmt",["shell"],["shfmt"],[".editorconfig"],[".sh",".bash",".zsh"],["shfmt","-w","{file}"],"https://github.com/mvdan/sh"),e("taplo",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","format","{file}"],"https://taplo.tamasfe.dev/"),e("sqlfluff-format",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","format","{file}"],"https://docs.sqlfluff.com/"),e("terraform-fmt",["terraform"],["terraform"],[".terraform.lock.hcl"],[".tf",".tfvars"],["terraform","fmt","{file}"],"https://developer.hashicorp.com/terraform/cli/commands/fmt"),e("cmake-format",["cmake"],["cmake-format"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-format","-i","{file}"],"https://cmake-format.readthedocs.io/",void 0,void 0,["CMakeLists.txt"]),e("xmlformat",["xml"],["xmlformat"],[".xmlformat.conf"],[".xml",".xsd",".xsl"],["xmlformat","--overwrite","{file}"],"https://github.com/pamoller/xmlformatter"),e("mix-format",["elixir"],["mix"],["mix.exs",".formatter.exs"],[".ex",".exs"],["mix","format","{file}"],"https://hexdocs.pm/mix/Mix.Tasks.Format.html"),e("scalafmt",["scala"],["scalafmt"],[".scalafmt.conf"],[".scala",".sc",".sbt"],["scalafmt","{file}"],"https://scalameta.org/scalafmt/"),e("julia-format",["julia"],["julia"],[".JuliaFormatter.toml","Project.toml"],[".jl"],["julia","--startup-file=no","--history-file=no","-e","using JuliaFormatter; format_file(ARGS[1])","{file}"],"https://github.com/domluna/JuliaFormatter.jl"),e("powershell-format",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$p=$args[0];$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};[IO.File]::WriteAllText($p,(Invoke-Formatter -ScriptDefinition ([IO.File]::ReadAllText($p)) @options))',"{file}"],"https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-formatter"),e("dockfmt",["dockerfile"],["dockfmt"],["Dockerfile","Containerfile"],[".dockerfile"],["dockfmt","fmt","--write","{file}"],"https://github.com/jessfraz/dockfmt",void 0,void 0,["Dockerfile","Containerfile"])];function e(r,t,o,i,a,l,n,s,m,u){return{id:r,name:r,kind:"formatter",languages:t,executables:o,configFiles:i,documentation:n,...s&&{dependencies:s},...m&&{configSections:m},formatter:{extensions:a,...u&&{fileNames:u},run:{command:l},output:"in-place"}}}f(e,"recipe");var c=class r{constructor(t,o,i=new Map){this.formatters=t;this.availableBuiltIns=o;this.evidence=i}static{f(this,"FormatterCommandRegistry")}static async fromDirectory(t,o={}){let i=await R(t,"formatters",s=>x(s).formatters,o),{available:a,evidence:l}=await F(t,i.entries.filter(s=>s.layer==="built-in").map(s=>({id:s.id,config:s.config.run})),p,o),n=[...i.entries].sort((s,m)=>s.layer==="built-in"&&m.layer==="built-in"?(l.get(m.id)?.score??0)-(l.get(s.id)?.score??0):0);return new r(n,a,l)}static fromConfig(t){return new r(Object.entries(t.formatters).map(([o,i])=>({id:o,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(t,o){return this.resolveEntry(t,o)?.config}resolveEntry(t,o){return E(this.formatters,this.availableBuiltIns,this.evidence,t,o)}get entries(){return this.formatters}};var I={protocol:y,apiVersion:h,id:"formatter",setup(r){for(let t of p)r.addToolRecipe(t);r.addSetupCheck({id:"effective-config",inspect:$}),r.addCheck({id:"config",title:"Formatter",async run(t){try{let o=await c.fromDirectory(t.cwd,g(t)),i=M(o,t.files,t.cwd);return i.length===0?[{status:"skip",message:"No formatter matches the inspected project files"}]:await Promise.all(i.map(async({entry:a,source:l})=>{let n=`${a.id} [${a.layer}] command ${JSON.stringify(a.config.run.command)}`;return T(t,l,async s=>{try{let m=t.workspace?await t.workspace.run(a.config.run,s,t.signal):await d(a.config,{projectRoot:t.cwd,filePath:s,env:t.env});return t.signal?.throwIfAborted(),m.ok?{status:"pass",message:`${n}: probe passed`,detail:a.sourcePath}:{status:"fail",message:`${n}: probe failed`,detail:a.sourcePath}}catch(m){return t.signal?.throwIfAborted(),{status:"fail",message:`${n}: ${m instanceof Error?m.message:String(m)}`,detail:a.sourcePath}}})}))}catch(o){return t.signal?.throwIfAborted(),[{status:"fail",message:o instanceof Error?o.message:String(o)}]}}})}};async function $(r){try{let t=await c.fromDirectory(r.cwd,g(r)),o=[],i=new Map;for(let[a,l]of r.detectedLanguages){let n=l.map(s=>t.resolveEntry(s,r.cwd)).find(s=>s!==void 0);n!==void 0&&(o.push({kind:"formatter",languageId:a,toolId:n.id}),await P(r,n.config.run)||i.set(n.id,{id:`formatter-${n.id}-unavailable`,message:`Configured formatter ${n.id} cannot run ${JSON.stringify(n.config.run.command)}`}))}return{selections:o,actions:[...i.values()]}}catch(t){return r.signal?.throwIfAborted(),{actions:[{id:"formatter-config-invalid",message:`Formatter configuration cannot load: ${t instanceof Error?t.message:String(t)}`}]}}}f($,"inspectFormatterSetup");function M(r,t,o){let i=new Map;for(let a of t){let l=r.resolveEntry(a,o);l!==void 0&&!i.has(l.id)&&i.set(l.id,{entry:l,source:a})}return[...i.values()]}f(M,"applicableFormatters");import _ from"node:path";var S=new Map;function D(r){return{kind:"formatter",name:"formatter",priority:100,extensions:["*"],detect:f(async t=>(r?await r.loadRegistry(t.cwd,!1):await O(t.cwd),!0),"detect"),async format({filePath:t},o){if(!r&&(t.includes("://")||o.cwd.includes("://")))throw Object.assign(new Error("Formatter requires its resource owner"),{code:"UNSUPPORTED_SOURCE"});let i=r?await r.resolveProject(t,o.cwd):await k(o.cwd,t,"formatters",p).then(m=>m===void 0?void 0:{cwd:m,external:m!==_.resolve(o.cwd)});if(i===void 0)return{ok:!0,edits:0,formatter:null};let a=i.cwd,n=(r?await r.loadRegistry(a,i.external):await O(a,i.external)).resolve(t,a);if(n===void 0)return{ok:!0,edits:0,formatter:null};let s=C(n.run.command);if(r){let m=await r.run(n,a,t);return{ok:m.ok,edits:m.changed?1:0,formatter:s}}try{let m=await d(n,{projectRoot:a,filePath:t});return{ok:m.ok,edits:m.changed?1:0,formatter:s}}catch{return{ok:!1,edits:0,formatter:s}}}}}f(D,"createFormatter");async function O(r,t=!1){let o=JSON.stringify([r,t]),i=S.get(o);return i===void 0&&(i=c.fromDirectory(r,{includeGlobal:!t,requireBuiltInEvidence:!0}),S.set(o,i)),i}f(O,"loadRegistry");async function q(r){await N(r)}f(q,"registerFormatter");async function N(r,t){let o=D(t),i={kind:"formatter",name:"pi-agent-ide-formatter",priority:200,extensions:["*"],detect:f(()=>Promise.resolve(!0),"detect"),async format(l,n){return o.format(l,n)}},a={protocol:b,apiVersion:5,id:"formatter",setup(l){l.addTool(i)}};await Promise.all([v(r,a),w(r,I)])}f(N,"registerFormatterWithOwner");export{p as a,c as b,q as c,N as d};
@@ -1,4 +1,4 @@
1
- import{a as re,b as ie,c as oe}from"./chunk-DEP55R35.js";import{a as ee,b as te,c as ne}from"./chunk-R2U5WXYR.js";import{e as B,f as W}from"./chunk-T7I2VX3J.js";import{a as V}from"./chunk-YJ6T3PEP.js";import{b as M,c as _}from"./chunk-S72FVLUX.js";import{a as J}from"./chunk-XXLLY66B.js";import{c as Z,d as Y}from"./chunk-235QMMVA.js";import{a as K}from"./chunk-BU7IZLKB.js";import{a as z,b as Q}from"./chunk-S5PL5DFQ.js";import{H as q,f as X,i as S,j as H}from"./chunk-LCWBVOII.js";import{a as F}from"./chunk-ZPT5D4VP.js";import{a as w}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import we from"node:path";var ae={protocol:M,apiVersion:_,id:"changes",setup(n){n.addSetupCheck({id:"git",async inspect(e){return await ee(e,e.workspace?`${e.cwd}/.git`:we.join(e.cwd,".git"))?await ne(e,"git")?{}:{actions:[{id:"git-unavailable",message:"Git integration is unavailable because Git was not found"}]}:{}}}),n.addCheck({id:"git",title:"Git changes",async run(e){let t=await te(e,"git",["--version"]);return[t.ok?{status:"pass",message:"Git is available",detail:t.detail}:{status:"warn",message:"Git is not available; change anchors and index tools are disabled",detail:t.detail}]}})}};import{mkdtemp as be,rm as Te,writeFile as Ee}from"node:fs/promises";import Ce from"node:os";import C from"node:path";import b from"node:path";var x=/^[a-z][a-z0-9+.-]*:\/\//iu;function T(n,e){if(x.test(n))return E(n).href;if(!x.test(e))return b.resolve(e,n);let t=E(e);return t.pathname=b.posix.resolve(decodeURIComponent(t.pathname),n).split("/").map(encodeURIComponent).join("/"),t.href}s(T,"resolveGitSource");function se(n,e){if(!x.test(n)&&!x.test(e))return b.relative(n,e);if(!x.test(n)||!x.test(e))return;let t=E(n),r=E(e);if(t.host===r.host)return b.posix.relative(decodeURIComponent(t.pathname),decodeURIComponent(r.pathname))}s(se,"relativeGitSource");function m(n,e){let t=T(n,e);if(!x.test(t))return b.dirname(t);let r=E(t);return r.pathname=b.posix.dirname(decodeURIComponent(r.pathname)).split("/").map(encodeURIComponent).join("/"),r.href}s(m,"gitSourceDirectory");function E(n){let e=new URL(n);if(e.protocol!=="ssh:"||e.username||e.password||e.port||e.search||e.hash)throw new Error(`Unsupported Git resource: ${n}`);return e}s(E,"remoteUrl");var v=class n{constructor(e,t){this.executor=e;this.repositoryRoot=t}static{s(this,"GitChangesBackend")}static async create(e,t,r){let o=await e.exec("git",["rev-parse","--show-toplevel"],{cwd:t,...r!==void 0&&{signal:r}});return o.code!==0?{status:"unavailable",reason:"no-worktree",message:o.stderr.trim()||"not inside a Git worktree"}:{status:"ready",backend:new n(e,T(o.stdout.trim(),t))}}async readTrackedFile(e,t,r){let o=T(e,t),i=se(this.repositoryRoot,o);return i===void 0||i===".."||i.startsWith(`..${C.sep}`)||C.isAbsolute(i)?{status:"unavailable",reason:"outside-worktree",message:`${o} is outside ${this.repositoryRoot}`}:this.readTrackedRepositoryFile(i.split(C.sep).join("/"),r)}async readTrackedRepositoryFile(e,t){let r=await this.git(["rev-parse","--verify","HEAD"],t);if(r.code!==0)return{status:"unavailable",reason:"missing-head",message:r.stderr.trim()||"Git HEAD does not exist"};let o=await this.git(["--literal-pathspecs","ls-tree","-z","HEAD","--",e],t);if(o.code!==0)return{status:"unavailable",reason:"head-file-lookup-failed",message:o.stderr.trim()||`could not inspect HEAD:${e}`};let i=ke(o.stdout);if(i===void 0)return{status:"untracked"};let d=await this.readBlob(i.blob,"HEAD",e,t);if(d.status!=="found")return d;let c=await this.git(["--literal-pathspecs","ls-files","--stage","-z","--",e],t);if(c.code!==0)return{status:"unavailable",reason:"index-file-lookup-failed",message:c.stderr.trim()||`could not inspect the index entry for ${e}`};let a=ve(c.stdout);if(a.some(({stage:u})=>u!==0))return{status:"unavailable",reason:"conflicted",message:`${e} has unresolved Git index entries`};let l=a.find(({stage:u})=>u===0),f="";if(l!==void 0){let u=await this.readBlob(l.blob,"index",e,t);if(u.status!=="found")return u;f=u.text}return{status:"found",head:r.stdout.trim(),repositoryPath:e,repositoryRoot:this.repositoryRoot,headText:d.text,indexText:f,indexMode:l?.mode??i.mode,indexExists:l!==void 0}}async writeIndexFile(e,t,r,o,i){if(i&&this.executor.writeIndex&&await this.executor.writeIndex({repositoryPath:e,mode:t,text:r,...i},{cwd:this.repositoryRoot,...o!==void 0&&{signal:o}}))return;if(this.repositoryRoot.startsWith("ssh://"))throw new Error("Remote Git index writes require a guarded owner index writer");let d=await be(C.join(Ce.tmpdir(),"pi-agent-index-")),c=C.join(d,"content");try{await Ee(c,r,"utf8");let a=await this.git(["hash-object","-w",`--path=${e}`,c],o);if(a.code!==0||a.stdout.trim().length===0)throw new Error(a.stderr.trim()||`could not write a Git blob for ${e}`);let l=await this.git(["update-index","--add","--cacheinfo",t,a.stdout.trim(),e],o);if(l.code!==0)throw new Error(l.stderr.trim()||`could not update the Git index entry for ${e}`)}finally{await Te(d,{recursive:!0,force:!0})}}async readBlob(e,t,r,o){let i=await this.git(["cat-file","blob",e],o);return i.code!==0?{status:"unavailable",reason:t==="HEAD"?"head-file-lookup-failed":"index-file-lookup-failed",message:i.stderr.trim()||`could not read ${t}:${r}`}:{status:"found",text:i.stdout}}git(e,t){return this.executor.exec("git",e,{cwd:this.repositoryRoot,...t!==void 0&&{signal:t}})}};function ke(n){let e=n.split("\0",1)[0];if(e===void 0||e.length===0)return;let t=e.indexOf(" ");if(t===-1)return;let[r,o,i]=e.slice(0,t).split(" ",3);return r===void 0||o!=="blob"||i===void 0?void 0:{mode:r,blob:i,path:e.slice(t+1)}}s(ke,"parseTreeEntry");function ve(n){return n.split("\0").filter(Boolean).flatMap(e=>{let t=e.indexOf(" ");if(t===-1)return[];let[r,o,i]=e.slice(0,t).split(" ",3),d=Number(i);return r===void 0||o===void 0||!Number.isInteger(d)?[]:[{mode:r,blob:o,stage:d,path:e.slice(t+1)}]})}s(ve,"parseIndexEntries");function de(n){return{exec:s((e,t,r)=>{if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(r.cwd))throw new Error(`No Git executor owns ${r.cwd}`);return n.exec(e,t,r)},"exec")}}s(de,"extensionGitExecutor");var h=class n{constructor(e){this.git=e}static{s(this,"ChangeService")}static async create(e,t,r){let o=await v.create(e,t,r);return o.status==="unavailable"?o:{status:"ready",service:new n(o.backend)}}async inspect(e){if(e.worktreeText.includes("\0"))return{status:"unavailable",reason:"binary",message:"worktree file contains binary content"};let t=await this.git.readTrackedFile(e.source,e.cwd,e.signal);if(t.status!=="found")return t.status==="untracked"?{status:"not-applicable",reason:"untracked"}:t;if(t.headText.includes("\0")||t.indexText.includes("\0"))return{status:"unavailable",reason:"binary",message:"Git file state contains binary content"};let r=re(t.repositoryPath,t.headText,t.indexText,e.worktreeText);return r.length===0?{status:"not-applicable",reason:"clean"}:{status:"applicable",head:t.head,repositoryRoot:t.repositoryRoot,repositoryPath:t.repositoryPath,groups:r}}async changeIndex(e,t,r){let o=await this.inspect(e);if(o.status!=="applicable")return o;let i=o.groups.find(l=>l.selector===t);if(i===void 0)return D(t,o.groups.map(({selector:l})=>l));let d=r==="stage"?"staged":"unstaged";if(i.state===d)return{status:"unchanged",state:d,group:i};let c=w(i.segments[0]),a={expectedWorktreeText:e.worktreeText,head:o.head,repositoryPath:o.repositoryPath,headStart:c.headStart,headEnd:c.headEnd,replacementText:r==="stage"?c.worktreeText:c.headText};try{await this.applyIndexUpdate(a,e.signal)}catch(l){return{status:"unavailable",reason:"index-write-failed",message:ce(l),failure:l instanceof Error?l:new Error(ce(l))}}return{status:"applied",state:d,group:i}}async prepareUndo(e,t){let r=await this.inspect(e);if(r.status!=="applicable")return r;let o=r.groups.find(a=>a.selector===t);if(o===void 0)return D(t,r.groups.map(({selector:a})=>a));let i=ie(e.worktreeText,o);if(i===void 0)return D(t,r.groups.map(({selector:a})=>a));let d=w(o.segments[0]),c=o.state==="unstaged"?void 0:{head:r.head,repositoryPath:r.repositoryPath,headStart:d.headStart,headEnd:d.headEnd,replacementText:d.headText,expectedWorktreeText:i};return{status:"applied",worktreeText:i,group:o,...c!==void 0&&{indexUpdate:c}}}async applyIndexUpdate(e,t){let r=await this.git.readTrackedRepositoryFile(e.repositoryPath,t);if(r.status!=="found")throw new Error(r.status==="untracked"?`${e.repositoryPath} is no longer tracked by HEAD`:r.message);if(r.head!==e.head)throw new Error(`Git HEAD changed while updating ${e.repositoryPath}`);let o=oe(r.headText,r.indexText,e.headStart,e.headEnd,e.replacementText);o!==r.indexText&&await this.git.writeIndexFile(e.repositoryPath,r.indexMode,o,t,{expectedHead:r.head,expectedIndexText:r.indexText,expectedIndexMode:r.indexMode,expectedIndexExists:r.indexExists,...e.expectedWorktreeText!==void 0&&{expectedWorktreeText:e.expectedWorktreeText}})}};function D(n,e){return{status:"unavailable",reason:"stale-selector",message:`${n} is not available in the current file state`,availableSelectors:e}}s(D,"staleSelector");function ce(n){return n instanceof Error?n.message:String(n)}s(ce,"errorMessage");var I="pi-agent-ide-changes/change",Ie=/^CHANGE#[0-9A-F]{4,64}$/,Ge=/^[A-Za-z][A-Za-z\d+.-]*:\/\//,$=class extends F{static{s(this,"ChangeTextAnchor")}constructor(e){super(e.selector,e.currentStartLine)}};function ue(n){return{resolver:Pe(s(async t=>{if(Ge.test(t.source)&&!t.source.startsWith("ssh://"))return;let r=await h.create(n,m(t.source,t.cwd),t.signal);if(r.status!=="ready")throw new Error(r.message);return r.service.inspect({source:t.source,worktreeText:t.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}})},"inspect"))}}s(ue,"createChangeAnchorRegistration");function Pe(n){return{id:"git-change",description:"Use the complete `CHANGE#HASH` shown beside a current Git change.",renderFull(e){return e},renderCompact(e){return e},async tryResolve(e,t){if(!Ie.test(e))return{kind:"not-handled"};try{let r=await n(t);if(r===void 0)return{kind:"not-handled"};if(r.status==="unavailable")return{kind:"failed",error:new Error(r.message)};let o=r.status==="applicable"?r.groups.find(i=>i.selector===e):void 0;return o===void 0?{kind:"rejected",rejection:{code:"stale",reason:`Change anchor ${e} is stale or unknown`}}:{kind:"resolved",anchor:new $(o)}}catch(r){return{kind:"failed",error:r}}}}}s(Pe,"createChangeAnchorResolver");import{diffLines as Ae}from"diff";var Re="filesystem";function le(n){return{id:"current-git-changes",async present(e,t){if(t.purpose!=="read"||t.resolvedBy!==Re&&!t.source.startsWith("ssh://"))return e;let r=await h.create(n,m(t.source,t.cwd),t.signal);if(r.status!=="ready")return e;let o=await r.service.inspect({source:t.source,worktreeText:e.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}});return o.status!=="applicable"?e:Se(e,o.groups)}}}s(le,"createCurrentChangePresenter");function Se(n,e){let t=new Map;for(let r of e)He(n,r,t);return{...n,references:e.map(r=>({value:r.selector,kind:"change",state:r.state})),lines:n.lines.map(r=>$e(r,t.get(r.lineNumber)))}}s(Se,"presentChangeGroups");function He(n,e,t){let r=w(e.segments[0]),o=Ae(r.headText,r.worktreeText),i=e.currentStartLine,d,c;for(let a of o){let l=Le(a.value);if(a.removed){let f=Ue(n,i),u=L(t,f.lineNumber),p=f.after?u.after:u.before;for(let j of l){let y={kind:"synthetic",rows:p,index:p.length};p.push({marker:"-",prefix:"|",content:j}),d??=y,c=y}continue}if(a.added){for(let f of l){let u=L(t,i),p={kind:"current",lineNumber:i};u.added=!0,d??=p,c=p,i++}continue}i+=l.length}if(d!==void 0&&c!==void 0){let a=`${e.selector} \xB7 ${e.state}`;De(d,c)?U(t,d,`<!-- change: ${a} -->`):(U(t,d,`<!-- change-begin: ${a} -->`),U(t,c,`<!-- change-end: ${a} -->`))}}s(He,"presentChangeGroup");function De(n,e){return n.kind==="current"&&e.kind==="current"?n.lineNumber===e.lineNumber:n.kind==="synthetic"&&e.kind==="synthetic"?n.rows===e.rows&&n.index===e.index:!1}s(De,"sameTarget");function U(n,e,t){if(e.kind==="current"){L(n,e.lineNumber).annotations.push(t);return}let r=w(e.rows[e.index]);e.rows[e.index]={...r,suffix:`${r.suffix??""} ${t}`}}s(U,"annotateTarget");function $e(n,e){if(e===void 0)return n;let t=e.annotations.length===0?"":` ${e.annotations.join(" ")}`;return{...n,presentation:{...n.presentation,...e.added&&{marker:"+"},before:[...n.presentation?.before??[],...e.before],after:[...e.after,...n.presentation?.after??[]],suffix:`${n.presentation?.suffix??""}${t}`}}}s($e,"presentLine");function L(n,e){let t=n.get(e);if(t!==void 0)return t;let r={before:[],after:[],annotations:[],added:!1};return n.set(e,r),r}s(L,"presentationsFor");function Ue(n,e){return e<=n.lines.length?{lineNumber:Math.max(1,e),after:!1}:{lineNumber:n.lines.length,after:!0}}s(Ue,"placementFor");function Le(n){if(n.length===0)return[];let e=n.split(/\r\n|\r|\n/u);return e.at(-1)===""&&e.pop(),e}s(Le,"splitLines");var G=class{static{s(this,"IndexMutationQueue")}tail=Promise.resolve();run(e){let t=this.tail.then(e,e);return this.tail=t.then(()=>{},()=>{}),t}};import{createHash as Ne}from"node:crypto";import{realpathSync as Oe}from"node:fs";import pe from"node:path";import{fileURLToPath as je}from"node:url";var A=class{static{s(this,"LastTextTransactionStore")}#e=new Map;observe(e){let t=ge(e.resourceSource,e.cwd);if(e.postProcessing==="final"){let r=this.#e.get(t),o=e.beforePostProcessing??e.before;r&&r.afterDigest===P(o.content)?this.#e.set(t,{...r,afterDigest:P(e.after.content)}):this.#e.delete(t);return}if(e.intent!=="edit"||!e.existed||e.before.content===e.after.content){this.#e.delete(t);return}this.#e.set(t,{before:e.before.content,afterDigest:P(e.after.content)})}restore(e,t,r){let o=ge(e,t),i=this.#e.get(o);if(i===void 0)throw new Error(`No last text transaction is available for ${e}.`);if(i.afterDigest!==P(r))throw this.#e.delete(o),new Error(`${e} changed after its last text transaction; refusing to overwrite newer text.`);return i.before}};function ge(n,e){return n.startsWith("file://")?fe(je(new URL(n))):/^[a-z][a-z\d+.-]*:/iu.test(n)?n:fe(pe.resolve(e,n))}s(ge,"sourceKey");function fe(n){try{return Oe.native(n)}catch{return pe.normalize(n)}}s(fe,"canonicalFile");function P(n){return Ne("sha256").update(n).digest("hex")}s(P,"textDigest");import{readFile as Fe}from"node:fs/promises";import{defineTool as Me,withFileMutationQueue as _e}from"@earendil-works/pi-coding-agent";import{Text as Be}from"@earendil-works/pi-tui";import{Type as g}from"typebox";var N=g.Object({action:g.Union([g.Literal("stage"),g.Literal("unstage")]),change:g.String(),file:g.String(),state:g.Optional(g.Union([g.Literal("staged"),g.Literal("unstaged")])),effect:g.Union([g.Literal("applied"),g.Literal("not-applied"),g.Literal("unknown")]),unchanged:g.Optional(g.Boolean())},{additionalProperties:!1}),We=X(N),k=g.Object({file:g.String({description:"Path to the tracked text file"}),change:g.String({description:"Complete CHANGE#HASH anchor shown by read",pattern:"^CHANGE#[0-9A-F]{4,64}$"})},{additionalProperties:!1}),Ve=g.Object({file:{...k.properties.file,description:"Path to a tracked text file in the current Git worktree. Relative paths resolve from the workspace."},change:{...k.properties.change,description:'Select one complete current CHANGE#HASH anchor returned by read with views: ["changes"].'}},{additionalProperties:!1});function me(n,e,t){n.registerTool(he("stage",e,t)),n.registerTool(he("unstage",e,t))}s(me,"registerIndexChangeTools");function he(n,e,t){let r=ze(n,e,t),o=n==="stage"?"Staged":"Unstaged",i=n==="stage"?{...k,properties:{file:{...k.properties.file,description:"Path to the tracked text file, absolute or relative to the current working directory."},change:{...k.properties.change,description:'Use the complete current CHANGE#HASH anchor shown by read with views: ["changes"].'}}}:Ve;return Me({name:n,exposure:"deferred",namespace:{name:"ide_git",description:"Stage or unstage selected Git changes without changing worktree files."},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},label:n,promptSnippet:`${o.slice(0,-1)} a selected Git change`,description:n==="stage"?"Use stage to add one selected Git change to the index without changing the worktree file.":"Use unstage to remove one selected Git change from the index. Worktree content is kept.",parameters:i,outputSchema:We,...n==="stage"&&{renderResult(d,c,a){return new Be(a.fg("toolOutput",d.content.flatMap(l=>l.type==="text"?[l.text]:[]).join(`
1
+ import{a as re,b as ie,c as oe}from"./chunk-DEP55R35.js";import{a as ee,b as te,c as ne}from"./chunk-R2U5WXYR.js";import{f as K,g as X}from"./chunk-KN6VPARZ.js";import{a as Y}from"./chunk-MDD5ORB6.js";import{b as q,c as Z}from"./chunk-MLFJU2US.js";import{a as J}from"./chunk-GXL4NMHR.js";import{c as z,d as Q}from"./chunk-PQWANILR.js";import{a as W}from"./chunk-BU7IZLKB.js";import{a as _,b as B}from"./chunk-S5PL5DFQ.js";import{K as M,j as F,m as S,n as H}from"./chunk-DDH3FP4G.js";import{a as V}from"./chunk-VDJSH3DQ.js";import{a as w}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import we from"node:path";var ae={protocol:q,apiVersion:Z,id:"changes",setup(n){n.addSetupCheck({id:"git",async inspect(e){return await ee(e,e.workspace?`${e.cwd}/.git`:we.join(e.cwd,".git"))?await ne(e,"git")?{}:{actions:[{id:"git-unavailable",message:"Git integration is unavailable because Git was not found"}]}:{}}}),n.addCheck({id:"git",title:"Git changes",async run(e){let t=await te(e,"git",["--version"]);return[t.ok?{status:"pass",message:"Git is available",detail:t.detail}:{status:"warn",message:"Git is not available; change anchors and index tools are disabled",detail:t.detail}]}})}};import{mkdtemp as be,rm as Te,writeFile as Ee}from"node:fs/promises";import Ce from"node:os";import C from"node:path";import b from"node:path";var x=/^[a-z][a-z0-9+.-]*:\/\//iu;function T(n,e){if(x.test(n))return E(n).href;if(!x.test(e))return b.resolve(e,n);let t=E(e);return t.pathname=b.posix.resolve(decodeURIComponent(t.pathname),n).split("/").map(encodeURIComponent).join("/"),t.href}s(T,"resolveGitSource");function se(n,e){if(!x.test(n)&&!x.test(e))return b.relative(n,e);if(!x.test(n)||!x.test(e))return;let t=E(n),r=E(e);if(t.host===r.host)return b.posix.relative(decodeURIComponent(t.pathname),decodeURIComponent(r.pathname))}s(se,"relativeGitSource");function m(n,e){let t=T(n,e);if(!x.test(t))return b.dirname(t);let r=E(t);return r.pathname=b.posix.dirname(decodeURIComponent(r.pathname)).split("/").map(encodeURIComponent).join("/"),r.href}s(m,"gitSourceDirectory");function E(n){let e=new URL(n);if(e.protocol!=="ssh:"||e.username||e.password||e.port||e.search||e.hash)throw new Error(`Unsupported Git resource: ${n}`);return e}s(E,"remoteUrl");var k=class n{constructor(e,t){this.executor=e;this.repositoryRoot=t}static{s(this,"GitChangesBackend")}static async create(e,t,r){let o=await e.exec("git",["rev-parse","--show-toplevel"],{cwd:t,...r!==void 0&&{signal:r}});return o.code!==0?{status:"unavailable",reason:"no-worktree",message:o.stderr.trim()||"not inside a Git worktree"}:{status:"ready",backend:new n(e,T(o.stdout.trim(),t))}}async readTrackedFile(e,t,r){let o=T(e,t),i=se(this.repositoryRoot,o);return i===void 0||i===".."||i.startsWith(`..${C.sep}`)||C.isAbsolute(i)?{status:"unavailable",reason:"outside-worktree",message:`${o} is outside ${this.repositoryRoot}`}:this.readTrackedRepositoryFile(i.split(C.sep).join("/"),r)}async readTrackedRepositoryFile(e,t){let r=await this.git(["rev-parse","--verify","HEAD"],t);if(r.code!==0)return{status:"unavailable",reason:"missing-head",message:r.stderr.trim()||"Git HEAD does not exist"};let o=await this.git(["--literal-pathspecs","ls-tree","-z","HEAD","--",e],t);if(o.code!==0)return{status:"unavailable",reason:"head-file-lookup-failed",message:o.stderr.trim()||`could not inspect HEAD:${e}`};let i=ve(o.stdout);if(i===void 0)return{status:"untracked"};let d=await this.readBlob(i.blob,"HEAD",e,t);if(d.status!=="found")return d;let c=await this.git(["--literal-pathspecs","ls-files","--stage","-z","--",e],t);if(c.code!==0)return{status:"unavailable",reason:"index-file-lookup-failed",message:c.stderr.trim()||`could not inspect the index entry for ${e}`};let a=ke(c.stdout);if(a.some(({stage:u})=>u!==0))return{status:"unavailable",reason:"conflicted",message:`${e} has unresolved Git index entries`};let l=a.find(({stage:u})=>u===0),f="";if(l!==void 0){let u=await this.readBlob(l.blob,"index",e,t);if(u.status!=="found")return u;f=u.text}return{status:"found",head:r.stdout.trim(),repositoryPath:e,repositoryRoot:this.repositoryRoot,headText:d.text,indexText:f,indexMode:l?.mode??i.mode,indexExists:l!==void 0}}async writeIndexFile(e,t,r,o,i){if(i&&this.executor.writeIndex&&await this.executor.writeIndex({repositoryPath:e,mode:t,text:r,...i},{cwd:this.repositoryRoot,...o!==void 0&&{signal:o}}))return;if(this.repositoryRoot.startsWith("ssh://"))throw new Error("Remote Git index writes require a guarded owner index writer");let d=await be(C.join(Ce.tmpdir(),"pi-agent-index-")),c=C.join(d,"content");try{await Ee(c,r,"utf8");let a=await this.git(["hash-object","-w",`--path=${e}`,c],o);if(a.code!==0||a.stdout.trim().length===0)throw new Error(a.stderr.trim()||`could not write a Git blob for ${e}`);let l=await this.git(["update-index","--add","--cacheinfo",t,a.stdout.trim(),e],o);if(l.code!==0)throw new Error(l.stderr.trim()||`could not update the Git index entry for ${e}`)}finally{await Te(d,{recursive:!0,force:!0})}}async readBlob(e,t,r,o){let i=await this.git(["cat-file","blob",e],o);return i.code!==0?{status:"unavailable",reason:t==="HEAD"?"head-file-lookup-failed":"index-file-lookup-failed",message:i.stderr.trim()||`could not read ${t}:${r}`}:{status:"found",text:i.stdout}}git(e,t){return this.executor.exec("git",e,{cwd:this.repositoryRoot,...t!==void 0&&{signal:t}})}};function ve(n){let e=n.split("\0",1)[0];if(e===void 0||e.length===0)return;let t=e.indexOf(" ");if(t===-1)return;let[r,o,i]=e.slice(0,t).split(" ",3);return r===void 0||o!=="blob"||i===void 0?void 0:{mode:r,blob:i,path:e.slice(t+1)}}s(ve,"parseTreeEntry");function ke(n){return n.split("\0").filter(Boolean).flatMap(e=>{let t=e.indexOf(" ");if(t===-1)return[];let[r,o,i]=e.slice(0,t).split(" ",3),d=Number(i);return r===void 0||o===void 0||!Number.isInteger(d)?[]:[{mode:r,blob:o,stage:d,path:e.slice(t+1)}]})}s(ke,"parseIndexEntries");function de(n){return{exec:s((e,t,r)=>{if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(r.cwd))throw new Error(`No Git executor owns ${r.cwd}`);return n.exec(e,t,r)},"exec")}}s(de,"extensionGitExecutor");var h=class n{constructor(e){this.git=e}static{s(this,"ChangeService")}static async create(e,t,r){let o=await k.create(e,t,r);return o.status==="unavailable"?o:{status:"ready",service:new n(o.backend)}}async inspect(e){if(e.worktreeText.includes("\0"))return{status:"unavailable",reason:"binary",message:"worktree file contains binary content"};let t=await this.git.readTrackedFile(e.source,e.cwd,e.signal);if(t.status!=="found")return t.status==="untracked"?{status:"not-applicable",reason:"untracked"}:t;if(t.headText.includes("\0")||t.indexText.includes("\0"))return{status:"unavailable",reason:"binary",message:"Git file state contains binary content"};let r=re(t.repositoryPath,t.headText,t.indexText,e.worktreeText);return r.length===0?{status:"not-applicable",reason:"clean"}:{status:"applicable",head:t.head,repositoryRoot:t.repositoryRoot,repositoryPath:t.repositoryPath,groups:r}}async changeIndex(e,t,r){let o=await this.inspect(e);if(o.status!=="applicable")return o;let i=o.groups.find(l=>l.selector===t);if(i===void 0)return D(t,o.groups.map(({selector:l})=>l));let d=r==="stage"?"staged":"unstaged";if(i.state===d)return{status:"unchanged",state:d,group:i};let c=w(i.segments[0]),a={expectedWorktreeText:e.worktreeText,head:o.head,repositoryPath:o.repositoryPath,headStart:c.headStart,headEnd:c.headEnd,replacementText:r==="stage"?c.worktreeText:c.headText};try{await this.applyIndexUpdate(a,e.signal)}catch(l){return{status:"unavailable",reason:"index-write-failed",message:ce(l),failure:l instanceof Error?l:new Error(ce(l))}}return{status:"applied",state:d,group:i}}async prepareUndo(e,t){let r=await this.inspect(e);if(r.status!=="applicable")return r;let o=r.groups.find(a=>a.selector===t);if(o===void 0)return D(t,r.groups.map(({selector:a})=>a));let i=ie(e.worktreeText,o);if(i===void 0)return D(t,r.groups.map(({selector:a})=>a));let d=w(o.segments[0]),c=o.state==="unstaged"?void 0:{head:r.head,repositoryPath:r.repositoryPath,headStart:d.headStart,headEnd:d.headEnd,replacementText:d.headText,expectedWorktreeText:i};return{status:"applied",worktreeText:i,group:o,...c!==void 0&&{indexUpdate:c}}}async applyIndexUpdate(e,t){let r=await this.git.readTrackedRepositoryFile(e.repositoryPath,t);if(r.status!=="found")throw new Error(r.status==="untracked"?`${e.repositoryPath} is no longer tracked by HEAD`:r.message);if(r.head!==e.head)throw new Error(`Git HEAD changed while updating ${e.repositoryPath}`);let o=oe(r.headText,r.indexText,e.headStart,e.headEnd,e.replacementText);o!==r.indexText&&await this.git.writeIndexFile(e.repositoryPath,r.indexMode,o,t,{expectedHead:r.head,expectedIndexText:r.indexText,expectedIndexMode:r.indexMode,expectedIndexExists:r.indexExists,...e.expectedWorktreeText!==void 0&&{expectedWorktreeText:e.expectedWorktreeText}})}};function D(n,e){return{status:"unavailable",reason:"stale-selector",message:`${n} is not available in the current file state`,availableSelectors:e}}s(D,"staleSelector");function ce(n){return n instanceof Error?n.message:String(n)}s(ce,"errorMessage");var I="pi-agent-ide-changes/change",Ie=/^CHANGE#[0-9A-F]{4,64}$/,Ge=/^[A-Za-z][A-Za-z\d+.-]*:\/\//,$=class extends V{static{s(this,"ChangeTextAnchor")}constructor(e){super(e.selector,e.currentStartLine)}};function ue(n){return{resolver:Ae(s(async t=>{if(Ge.test(t.source)&&!t.source.startsWith("ssh://"))return;let r=await h.create(n,m(t.source,t.cwd),t.signal);if(r.status!=="ready")throw new Error(r.message);return r.service.inspect({source:t.source,worktreeText:t.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}})},"inspect"))}}s(ue,"createChangeAnchorRegistration");function Ae(n){return{id:"git-change",description:"Use the complete `CHANGE#HASH` shown beside a current Git change.",renderFull(e){return e},renderCompact(e){return e},async tryResolve(e,t){if(!Ie.test(e))return{kind:"not-handled"};try{let r=await n(t);if(r===void 0)return{kind:"not-handled"};if(r.status==="unavailable")return{kind:"failed",error:new Error(r.message)};let o=r.status==="applicable"?r.groups.find(i=>i.selector===e):void 0;return o===void 0?{kind:"rejected",rejection:{code:"stale",reason:`Change anchor ${e} is stale or unknown`}}:{kind:"resolved",anchor:new $(o)}}catch(r){return{kind:"failed",error:r}}}}}s(Ae,"createChangeAnchorResolver");import{diffLines as Pe}from"diff";var Re="filesystem";function le(n){return{id:"current-git-changes",async present(e,t){if(t.purpose!=="read"||t.resolvedBy!==Re&&!t.source.startsWith("ssh://"))return e;let r=await h.create(n,m(t.source,t.cwd),t.signal);if(r.status!=="ready")return e;let o=await r.service.inspect({source:t.source,worktreeText:e.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}});return o.status!=="applicable"?e:Se(e,o.groups)}}}s(le,"createCurrentChangePresenter");function Se(n,e){let t=new Map;for(let r of e)He(n,r,t);return{...n,references:e.map(r=>({value:r.selector,kind:"change",state:r.state})),lines:n.lines.map(r=>$e(r,t.get(r.lineNumber)))}}s(Se,"presentChangeGroups");function He(n,e,t){let r=w(e.segments[0]),o=Pe(r.headText,r.worktreeText),i=e.currentStartLine,d,c;for(let a of o){let l=Ue(a.value);if(a.removed){let f=Le(n,i),u=U(t,f.lineNumber),p=f.after?u.after:u.before;for(let j of l){let y={kind:"synthetic",rows:p,index:p.length};p.push({marker:"-",prefix:"|",content:j}),d??=y,c=y}continue}if(a.added){for(let f of l){let u=U(t,i),p={kind:"current",lineNumber:i};u.added=!0,d??=p,c=p,i++}continue}i+=l.length}if(d!==void 0&&c!==void 0){let a=`${e.selector} \xB7 ${e.state}`;De(d,c)?L(t,d,`<!-- change: ${a} -->`):(L(t,d,`<!-- change-begin: ${a} -->`),L(t,c,`<!-- change-end: ${a} -->`))}}s(He,"presentChangeGroup");function De(n,e){return n.kind==="current"&&e.kind==="current"?n.lineNumber===e.lineNumber:n.kind==="synthetic"&&e.kind==="synthetic"?n.rows===e.rows&&n.index===e.index:!1}s(De,"sameTarget");function L(n,e,t){if(e.kind==="current"){U(n,e.lineNumber).annotations.push(t);return}let r=w(e.rows[e.index]);e.rows[e.index]={...r,suffix:`${r.suffix??""} ${t}`}}s(L,"annotateTarget");function $e(n,e){if(e===void 0)return n;let t=e.annotations.length===0?"":` ${e.annotations.join(" ")}`;return{...n,presentation:{...n.presentation,...e.added&&{marker:"+"},before:[...n.presentation?.before??[],...e.before],after:[...e.after,...n.presentation?.after??[]],suffix:`${n.presentation?.suffix??""}${t}`}}}s($e,"presentLine");function U(n,e){let t=n.get(e);if(t!==void 0)return t;let r={before:[],after:[],annotations:[],added:!1};return n.set(e,r),r}s(U,"presentationsFor");function Le(n,e){return e<=n.lines.length?{lineNumber:Math.max(1,e),after:!1}:{lineNumber:n.lines.length,after:!0}}s(Le,"placementFor");function Ue(n){if(n.length===0)return[];let e=n.split(/\r\n|\r|\n/u);return e.at(-1)===""&&e.pop(),e}s(Ue,"splitLines");var G=class{static{s(this,"IndexMutationQueue")}tail=Promise.resolve();run(e){let t=this.tail.then(e,e);return this.tail=t.then(()=>{},()=>{}),t}};import{createHash as Ne}from"node:crypto";import{realpathSync as Oe}from"node:fs";import pe from"node:path";import{fileURLToPath as je}from"node:url";var P=class{static{s(this,"LastTextTransactionStore")}#e=new Map;observe(e){let t=ge(e.resourceSource,e.cwd);if(e.postProcessing==="final"){let r=this.#e.get(t),o=e.beforePostProcessing??e.before;r&&r.afterDigest===A(o.content)?this.#e.set(t,{...r,afterDigest:A(e.after.content)}):this.#e.delete(t);return}if(e.intent!=="edit"||!e.existed||e.before.content===e.after.content){this.#e.delete(t);return}this.#e.set(t,{before:e.before.content,afterDigest:A(e.after.content)})}restore(e,t,r){let o=ge(e,t),i=this.#e.get(o);if(i===void 0)throw new Error(`No last text transaction is available for ${e}.`);if(i.afterDigest!==A(r))throw this.#e.delete(o),new Error(`${e} changed after its last text transaction; refusing to overwrite newer text.`);return i.before}};function ge(n,e){return n.startsWith("file://")?fe(je(new URL(n))):/^[a-z][a-z\d+.-]*:/iu.test(n)?n:fe(pe.resolve(e,n))}s(ge,"sourceKey");function fe(n){try{return Oe.native(n)}catch{return pe.normalize(n)}}s(fe,"canonicalFile");function A(n){return Ne("sha256").update(n).digest("hex")}s(A,"textDigest");import{readFile as Fe}from"node:fs/promises";import{defineTool as Me,withFileMutationQueue as _e}from"@earendil-works/pi-coding-agent";import{Text as Be}from"@earendil-works/pi-tui";import{Type as g}from"typebox";var N=g.Object({action:g.Union([g.Literal("stage"),g.Literal("unstage")]),change:g.String(),file:g.String(),state:g.Optional(g.Union([g.Literal("staged"),g.Literal("unstaged")])),effect:g.Union([g.Literal("applied"),g.Literal("not-applied"),g.Literal("unknown")]),unchanged:g.Optional(g.Boolean())},{additionalProperties:!1}),We=F(N),v=g.Object({file:g.String({description:"Path to the tracked text file"}),change:g.String({description:"Complete CHANGE#HASH anchor shown by read",pattern:"^CHANGE#[0-9A-F]{4,64}$"})},{additionalProperties:!1}),Ve=g.Object({file:{...v.properties.file,description:"Path to a tracked text file in the current Git worktree. Relative paths resolve from the workspace."},change:{...v.properties.change,description:'Select one complete current CHANGE#HASH anchor returned by read with views: ["changes"].'}},{additionalProperties:!1});function me(n,e,t){n.registerTool(he("stage",e,t)),n.registerTool(he("unstage",e,t))}s(me,"registerIndexChangeTools");function he(n,e,t){let r=ze(n,e,t),o=n==="stage"?"Staged":"Unstaged",i=n==="stage"?{...v,properties:{file:{...v.properties.file,description:"Path to the tracked text file, absolute or relative to the current working directory."},change:{...v.properties.change,description:'Use the complete current CHANGE#HASH anchor shown by read with views: ["changes"].'}}}:Ve;return Me({name:n,exposure:"deferred",namespace:{name:"ide_git",description:"Stage or unstage selected Git changes without changing worktree files."},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},label:n,promptSnippet:`${o.slice(0,-1)} a selected Git change`,description:n==="stage"?"Use stage to add one selected Git change to the index without changing the worktree file.":"Use unstage to remove one selected Git change from the index. Worktree content is kept.",parameters:i,outputSchema:We,...n==="stage"&&{renderResult(d,c,a){return new Be(a.fg("toolOutput",d.content.flatMap(l=>l.type==="text"?[l.text]:[]).join(`
2
2
  `)),0,0)}},async execute(d,c,a,l,f){try{let u=await r(c,a,f);return H(u,N,{status:"success",data:{...u.details,effect:u.details.unchanged?"not-applied":"applied"},errors:[]})}catch(u){if(a?.aborted)throw u;let p=S(u,"INDEX_CHANGE_FAILED",c.file);return H({content:[{type:"text",text:p.message}],details:{action:n,change:c.change,file:O(c.file,f.cwd)}},N,{status:"error",data:{action:n,change:c.change,file:O(c.file,f.cwd),effect:xe(u)},errors:[p]})}}})}s(he,"createIndexChangeTool");function ze(n,e,t){let r=n==="stage"?"staged":"unstaged",o=n==="stage"?"Staged":"Unstaged";return async(i,d,c)=>{let a=O(i.file,c.cwd);return _e(a,()=>t.run(async()=>{let l=e.readText?await e.readText(a,d):await Fe(a,"utf8"),f=await h.create(e,m(a,c.cwd),d);if(f.status!=="ready")throw new Error(n==="stage"?`Cannot stage ${i.file}: ${f.message}`:f.message);let u=await f.service.changeIndex({source:a,worktreeText:l,cwd:c.cwd,...d!==void 0&&{signal:d}},i.change,n);if(u.status==="unavailable"){if("failure"in u&&u.failure!==void 0){if(n==="stage"&&u.reason==="index-write-failed"){let y=S(u.failure,"INDEX_CHANGE_FAILED",i.file);throw Object.assign(new Error(`${y.message}
3
3
  The index may have changed. Read ${i.file} with views: ["changes"] before retrying.`,{cause:u.failure}),{effect:xe(u.failure)})}throw u.failure}throw n==="stage"&&u.reason==="stale-selector"?Object.assign(new Error(`${u.message}. Read ${i.file} with views: ["changes"] and use a current CHANGE# anchor.`),{effect:"not-applied"}):n==="stage"&&u.reason==="index-write-failed"&&!d?.aborted?new Error(`${u.message}
4
- The index may have changed. Read ${i.file} with views: ["changes"] before retrying.`):Object.assign(new Error(n==="stage"&&u.reason!=="index-write-failed"?`Cannot stage ${i.file}: ${u.message}`:u.message),{effect:"not-applied"})}if(u.status==="not-applicable"){if(n==="stage"){let y=u.reason==="clean"?"the worktree text matches HEAD":"the file is not present in HEAD";throw new Error(`Cannot stage ${i.file}: ${y}.`)}throw new Error(`${n} is not applicable to ${a}: ${u.reason}`)}let p=u.status==="unchanged";return{content:[{type:"text",text:p?`${i.change} is already ${r} in ${i.file}.`:`${o} ${i.change} in ${i.file}.`}],details:{action:n,change:i.change,file:a,state:r,unchanged:p}}}))}}s(ze,"createIndexChangeExecutor");function O(n,e){let t=n.startsWith("@")?n.slice(1):n;return T(t,e)}s(O,"resolveFile");function xe(n){return n!==null&&typeof n=="object"&&"effect"in n&&(n.effect==="applied"||n.effect==="not-applied")?n.effect:"unknown"}s(xe,"publicationEffect");import{diffChars as Qe}from"diff";import{Type as R}from"typebox";var Ke=R.Object({file:R.Optional(R.Union(q.anyOf,{description:"File path or one whole-file source result. Partial and multi-file selections are rejected. Omit file to use the supplied CHANGE anchor's file or the last resolved source."})),change:R.String({description:`Use a complete current CHANGE#HASH anchor from read with views: ["changes"] to restore that change to HEAD in both worktree and index. Use last to restore the file's latest saved text-editor transaction.`,pattern:"^(?:CHANGE#[0-9A-F]{4,64}|last)$"})},{additionalProperties:!1});function ye(n,e,t){return{name:"undo",description:"Use undo to restore one selected uncommitted Git change or a file's latest text-editor transaction.",promptSnippet:"Restore a Git change or latest text edit",parameters:Ke,intent:"restore",source:{field:"file",inherited:!0},anchors:[{field:"change",sourceField:"file",kinds:[I],nonAnchorValues:["last"]}],async mutate(r,o){let i=r.sourceFor("file"),d,c;if(o.change==="last")d=e.restore(i,r.cwd,r.sourceDocument.content);else{await r.resolveAnchor("change");let a=await h.create(n,m(i,r.cwd),r.signal);if(a.status!=="ready")throw new Error(a.message);let l=await a.service.prepareUndo({source:i,worktreeText:r.sourceDocument.content,cwd:r.cwd,...r.signal!==void 0&&{signal:r.signal}},o.change);if(l.status!=="applied")throw l.status==="unavailable"?new Error(l.message):new Error(`Undo is not applicable to ${i}: ${l.reason}`);if(d=l.worktreeText,l.indexUpdate!==void 0){let f=l.indexUpdate;c=s(()=>t.run(()=>a.service.applyIndexUpdate(f,r.signal)),"afterWrite")}}return{edits:new Map([[i,{changes:Xe(r.sourceDocument.content,d),action:"edited"}]]),...c!==void 0&&{afterWrite:c}}}}}s(ye,"createUndoMutationTool");function Xe(n,e){let t=[],r=0,o,i=0,d="",c=s(()=>{o!==void 0&&(t.push({from:o,to:o+i,insert:d}),o=void 0,i=0,d="")},"flush");for(let a of Qe(n,e)){if(!a.added&&!a.removed){c(),r+=a.value.length;continue}o??=r,a.removed?(r+=a.value.length,i+=a.value.length):d+=a.value}return c(),t}s(Xe,"createTextChanges");function qe(n){return Ze(n,de(n))}s(qe,"registerGitChanges");async function Ze(n,e){W(n,[await B({id:"git-changes",description:"Git change anchors, staging, and safe undo",triggers:["stage","unstage","undo"].map(a=>({tool:a}))})]);let t=new A,r=new G,o=le(e),i=ue(e),d={protocol:z,apiVersion:Q,id:"current-git-changes",setup(a){a.addView({view:"changes",presenter:o}),a.describe({views:"changes \u2014 uncommitted edits in tracked files, staged/unstaged state, and CHANGE# anchors for stage, unstage and undo."})}},c={protocol:Z,apiVersion:Y,id:"current-git-changes",setup(a){a.addAnchorResolver({...i,kind:I,type:"auxiliary"}),a.onDidEdit(l=>{t.observe(l)}),a.addMutationTool(ye(e,t,r)),a.addTextPresenter({presenter:o})}};await Promise.all([V(n,ae),K(n,d),J(n,c)]),me(n,e,r)}s(Ze,"registerGitChangesWithExecutor");export{qe as a,Ze as b};
4
+ The index may have changed. Read ${i.file} with views: ["changes"] before retrying.`):Object.assign(new Error(n==="stage"&&u.reason!=="index-write-failed"?`Cannot stage ${i.file}: ${u.message}`:u.message),{effect:"not-applied"})}if(u.status==="not-applicable"){if(n==="stage"){let y=u.reason==="clean"?"the worktree text matches HEAD":"the file is not present in HEAD";throw new Error(`Cannot stage ${i.file}: ${y}.`)}throw new Error(`${n} is not applicable to ${a}: ${u.reason}`)}let p=u.status==="unchanged";return{content:[{type:"text",text:p?`${i.change} is already ${r} in ${i.file}.`:`${o} ${i.change} in ${i.file}.`}],details:{action:n,change:i.change,file:a,state:r,unchanged:p}}}))}}s(ze,"createIndexChangeExecutor");function O(n,e){let t=n.startsWith("@")?n.slice(1):n;return T(t,e)}s(O,"resolveFile");function xe(n){return n!==null&&typeof n=="object"&&"effect"in n&&(n.effect==="applied"||n.effect==="not-applied")?n.effect:"unknown"}s(xe,"publicationEffect");import{diffChars as Qe}from"diff";import{Type as R}from"typebox";var Ke=R.Object({file:R.Optional(R.Union(M.anyOf,{description:"File path or an unchanged whole-file result. Omit to use the file of the CHANGE# anchor or the last file read."})),change:R.String({description:`A CHANGE#HASH anchor from read with views: ["changes"] reverts that change to HEAD in the worktree and index; last reverts the file's last tool edit.`,pattern:"^(?:CHANGE#[0-9A-F]{4,64}|last)$"})},{additionalProperties:!1});function ye(n,e,t){return{name:"undo",description:"Use undo to revert one uncommitted Git change or the last edit a tool made to a file.",promptSnippet:"Restore a Git change or latest text edit",parameters:Ke,intent:"restore",source:{field:"file",inherited:!0},anchors:[{field:"change",sourceField:"file",kinds:[I],nonAnchorValues:["last"]}],async mutate(r,o){let i=r.sourceFor("file"),d,c;if(o.change==="last")d=e.restore(i,r.cwd,r.sourceDocument.content);else{await r.resolveAnchor("change");let a=await h.create(n,m(i,r.cwd),r.signal);if(a.status!=="ready")throw new Error(a.message);let l=await a.service.prepareUndo({source:i,worktreeText:r.sourceDocument.content,cwd:r.cwd,...r.signal!==void 0&&{signal:r.signal}},o.change);if(l.status!=="applied")throw l.status==="unavailable"?new Error(l.message):new Error(`Undo is not applicable to ${i}: ${l.reason}`);if(d=l.worktreeText,l.indexUpdate!==void 0){let f=l.indexUpdate;c=s(()=>t.run(()=>a.service.applyIndexUpdate(f,r.signal)),"afterWrite")}}return{edits:new Map([[i,{changes:Xe(r.sourceDocument.content,d),action:"edited"}]]),...c!==void 0&&{afterWrite:c}}}}}s(ye,"createUndoMutationTool");function Xe(n,e){let t=[],r=0,o,i=0,d="",c=s(()=>{o!==void 0&&(t.push({from:o,to:o+i,insert:d}),o=void 0,i=0,d="")},"flush");for(let a of Qe(n,e)){if(!a.added&&!a.removed){c(),r+=a.value.length;continue}o??=r,a.removed?(r+=a.value.length,i+=a.value.length):d+=a.value}return c(),t}s(Xe,"createTextChanges");function qe(n){return Ze(n,de(n))}s(qe,"registerGitChanges");async function Ze(n,e){X(n,[await K({id:"git-changes",description:"Git change anchors, staging, and safe undo",triggers:["stage","unstage","undo"].map(a=>({tool:a}))})]);let t=new P,r=new G,o=le(e),i=ue(e),d={protocol:_,apiVersion:B,id:"current-git-changes",setup(a){a.addView({view:"changes",presenter:o}),a.describe({views:"changes \u2014 uncommitted Git edits with CHANGE# anchors."})}},c={protocol:z,apiVersion:Q,id:"current-git-changes",setup(a){a.addAnchorResolver({...i,kind:I,type:"auxiliary"}),a.onDidEdit(l=>{t.observe(l)}),a.addMutationTool(ye(e,t,r)),a.addTextPresenter({presenter:o})}};await Promise.all([Y(n,ae),W(n,d),J(n,c)]),me(n,e,r)}s(Ze,"registerGitChangesWithExecutor");export{qe as a,Ze as b};