pi-agent-ide 0.9.8 → 1.0.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 (900) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/README.md +5 -3
  3. package/dist/chunk-2EY3LEZ7.js +1 -0
  4. package/dist/chunk-2QCE7GOV.js +1 -0
  5. package/dist/chunk-3V3OQO5S.js +118 -0
  6. package/dist/chunk-45EJ4762.js +33 -0
  7. package/dist/chunk-4AEYLVSR.js +5 -0
  8. package/dist/chunk-4DLSZYUO.js +1 -0
  9. package/dist/chunk-54EFJYUB.js +1 -0
  10. package/dist/{chunk-5DN2XBVI.js → chunk-5TPYHUJV.js} +1 -1
  11. package/dist/{chunk-KQV2ZXLP.js → chunk-6DC2Q5BI.js} +1 -1
  12. package/dist/chunk-72WO7H5T.js +1 -0
  13. package/dist/chunk-72X24ARV.js +2 -0
  14. package/dist/chunk-AB6RSWMB.js +23 -0
  15. package/dist/chunk-AKUBFJAR.js +1 -0
  16. package/dist/chunk-ASVMQMPX.js +10 -0
  17. package/dist/chunk-BW3XONMZ.js +1 -0
  18. package/dist/{chunk-R2U5WXYR.js → chunk-D23NS4VV.js} +1 -1
  19. package/dist/chunk-DSB6A5P5.js +53 -0
  20. package/dist/chunk-E4V4VNRM.js +3 -0
  21. package/dist/chunk-E6G3UVS7.js +1 -0
  22. package/dist/chunk-E7JBYW43.js +1 -0
  23. package/dist/chunk-FVWMI4GP.js +1 -0
  24. package/dist/chunk-GDIF3WT6.js +12 -0
  25. package/dist/chunk-GNYFA6FS.js +2 -0
  26. package/dist/{chunk-DHOIQZUF.js → chunk-GQXZEOND.js} +1 -1
  27. package/dist/chunk-GT2JPOBM.js +1 -0
  28. package/dist/chunk-GTZOIJCH.js +1 -0
  29. package/dist/chunk-HRZAIZGR.js +1 -0
  30. package/dist/{chunk-H6FEBUAP.js → chunk-HSAGZWPO.js} +1 -1
  31. package/dist/chunk-HUICUICD.js +3 -0
  32. package/dist/{chunk-2DSY4U73.js → chunk-I3G6K7QU.js} +1 -1
  33. package/dist/chunk-IRLWXPL4.js +7 -0
  34. package/dist/chunk-IZTOXSTR.js +6 -0
  35. package/dist/chunk-J5CKSIH7.js +1 -0
  36. package/dist/chunk-JKM4E5VB.js +5 -0
  37. package/dist/chunk-JMCI2ZE2.js +3 -0
  38. package/dist/{chunk-YZTVC7ME.js → chunk-JY63UUC2.js} +1 -1
  39. package/dist/chunk-KJ6HZC6L.js +7 -0
  40. package/dist/chunk-LG22ELG4.js +2 -0
  41. package/dist/chunk-LRAMFOUP.js +37 -0
  42. package/dist/chunk-MJMRV76H.js +1 -0
  43. package/dist/chunk-MMQIHUU5.js +1 -0
  44. package/dist/chunk-MNAIMZRO.js +9 -0
  45. package/dist/chunk-NGWQRV25.js +13 -0
  46. package/dist/chunk-NKI4TZSS.js +2 -0
  47. package/dist/chunk-NWCTAVGR.js +4 -0
  48. package/dist/chunk-O2C3F3MA.js +1 -0
  49. package/dist/chunk-OA26FH5G.js +1 -0
  50. package/dist/chunk-OEEE5BLN.js +16 -0
  51. package/dist/chunk-OLMACWQX.js +11 -0
  52. package/dist/{chunk-72FL5FHZ.js → chunk-PBMHSK6J.js} +1 -1
  53. package/dist/chunk-QC6VFZSB.js +2 -0
  54. package/dist/chunk-QCAGAJHJ.js +1 -0
  55. package/dist/{chunk-P7FUD4WY.js → chunk-QR7JR3P2.js} +1 -1
  56. package/dist/chunk-QSU5AEKW.js +1 -0
  57. package/dist/chunk-R7576HPO.js +25 -0
  58. package/dist/{chunk-B5UJCNQU.js → chunk-RNDSWVJF.js} +1 -1
  59. package/dist/chunk-S4GTWS2J.js +6 -0
  60. package/dist/chunk-SF44YQCB.js +2 -0
  61. package/dist/chunk-SJQGFUXR.js +6 -0
  62. package/dist/chunk-SKHD2QIT.js +1 -0
  63. package/dist/chunk-SKZTIAE4.js +4 -0
  64. package/dist/chunk-SZRC24OB.js +1 -0
  65. package/dist/chunk-T5PXAYWC.js +1 -0
  66. package/dist/chunk-TIZ4QDF3.js +1 -0
  67. package/dist/chunk-UHGHVYAW.js +4 -0
  68. package/dist/chunk-V2LLMBTA.js +1 -0
  69. package/dist/chunk-VB5P3TXJ.js +111 -0
  70. package/dist/chunk-VNG4QPPT.js +12 -0
  71. package/dist/chunk-VNNAVC4S.js +15 -0
  72. package/dist/chunk-VPBGKSFI.js +3 -0
  73. package/dist/chunk-WZ7MNISG.js +5 -0
  74. package/dist/chunk-X4CU7CMR.js +19 -0
  75. package/dist/chunk-X7CHS7JB.js +1 -0
  76. package/dist/chunk-XEPCURYZ.js +1 -0
  77. package/dist/chunk-XKVU6AAS.js +7 -0
  78. package/dist/chunk-XLTAP5YC.js +24 -0
  79. package/dist/chunk-XQMNVPNS.js +1 -0
  80. package/dist/chunk-YI32H7Z2.js +4 -0
  81. package/dist/chunk-YSGPCH52.js +18 -0
  82. package/dist/chunk-ZYG5E3DI.js +9 -0
  83. package/dist/entry-0.js +1 -1
  84. package/dist/entry-12.js +1 -1
  85. package/dist/entry-15.js +1 -1
  86. package/dist/entry-17.js +1 -1
  87. package/dist/entry-18.js +1 -1
  88. package/dist/entry-19.js +1 -1
  89. package/dist/entry-20.js +1 -1
  90. package/dist/entry-21.js +1 -1
  91. package/dist/entry-22.js +1 -1
  92. package/dist/entry-27.js +1 -1
  93. package/dist/entry-28.js +1 -1
  94. package/dist/entry-31.js +2 -2
  95. package/dist/entry-32.js +1 -1
  96. package/dist/entry-33.js +1 -1
  97. package/dist/entry-34.js +1 -1
  98. package/dist/entry-35.js +1 -1
  99. package/dist/entry-36.js +1 -1
  100. package/dist/entry-37.js +1 -1
  101. package/dist/entry-38.js +19 -13
  102. package/dist/entry-4.js +1 -1
  103. package/dist/entry-40.js +1 -1
  104. package/dist/entry-41.js +1 -1
  105. package/dist/entry-43.js +1 -1
  106. package/dist/entry-44.js +1 -1
  107. package/dist/entry-45.js +1 -1
  108. package/dist/entry-48.js +1 -1
  109. package/dist/entry-49.js +1 -1
  110. package/dist/entry-50.js +1 -1
  111. package/dist/entry-51.js +1 -1
  112. package/dist/entry-52.js +1 -1
  113. package/dist/entry-53.js +1 -1
  114. package/dist/entry-54.js +1 -1
  115. package/dist/entry-55.js +1 -1
  116. package/dist/entry-56.js +1 -1
  117. package/dist/entry-57.js +1 -1
  118. package/dist/entry-58.js +1 -1
  119. package/dist/entry-59.js +1 -1
  120. package/dist/entry-60.js +1 -1
  121. package/dist/entry-61.js +1 -1
  122. package/dist/entry-62.js +1 -1
  123. package/dist/entry-63.js +1 -1
  124. package/dist/entry-64.js +1 -1
  125. package/dist/entry-65.js +1 -1
  126. package/dist/entry-66.js +1 -1
  127. package/dist/entry-67.js +1 -1
  128. package/dist/entry-68.js +1 -0
  129. package/dist/entry-69.js +1 -1
  130. package/dist/entry-71.js +1 -1
  131. package/dist/entry-72.js +0 -1
  132. package/dist/entry-73.js +1 -1
  133. package/dist/entry-74.js +1 -1
  134. package/dist/entry-75.js +1 -1
  135. package/dist/entry-76.js +1 -1
  136. package/dist/entry-77.js +1 -1
  137. package/dist/entry-78.js +1 -0
  138. package/dist/entry-79.js +1 -1
  139. package/dist/entry-8.js +1 -1
  140. package/dist/entry-80.js +1 -0
  141. package/dist/entry-81.js +0 -1
  142. package/dist/entry-82.js +1 -1
  143. package/dist/entry-83.js +1 -1
  144. package/dist/entry-84.js +0 -1
  145. package/dist/entry-85.js +1 -1
  146. package/dist/entry-86.js +1 -2
  147. package/dist/entry-87.js +1 -1
  148. package/dist/entry-88.js +1 -1
  149. package/dist/entry-89.js +1 -1
  150. package/dist/entry-90.js +1 -1
  151. package/dist/entry-91.js +1 -3
  152. package/dist/entry-92.js +1 -1
  153. package/dist/entry-93.js +1 -1
  154. package/dist/entry-94.js +1 -1
  155. package/dist/entry-95.js +3 -0
  156. package/dist/entry-96.js +1 -0
  157. package/dist/entry-97.js +1 -0
  158. package/dist/entry-98.js +1 -0
  159. package/dist/pi-agent-ide.js +26 -13
  160. package/docs/agent-guides/ast-search.md +15 -4
  161. package/docs/agent-guides/debugger.md +1 -1
  162. package/docs/agent-guides/git-changes.md +1 -0
  163. package/docs/agent-guides/ssh.md +27 -7
  164. package/docs/agent-guides/terminal.md +4 -0
  165. package/docs/configuration.md +65 -11
  166. package/docs/development.md +4 -0
  167. package/docs/extensions.md +6 -4
  168. package/docs/structured-results.md +29 -15
  169. package/docs/tools.md +95 -29
  170. package/docs/user-hooks.md +1 -1
  171. package/node_modules/pi-agent-doctor/package.json +1 -1
  172. package/node_modules/pi-agent-doctor/src/catalog.ts +2 -0
  173. package/node_modules/pi-agent-doctor/src/executable.ts +1 -1
  174. package/node_modules/pi-agent-documentation/package.json +1 -1
  175. package/node_modules/pi-agent-filesystem/package.json +7 -7
  176. package/node_modules/pi-agent-filesystem/src/file-write-lock.ts +6 -4
  177. package/node_modules/pi-agent-filesystem/src/replace-file.ts +5 -2
  178. package/node_modules/pi-agent-filesystem/src/resolver.ts +26 -10
  179. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  180. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  181. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  182. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  183. package/node_modules/pi-agent-ide-ast/package.json +13 -13
  184. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +56 -65
  185. package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +197 -130
  186. package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +2 -1
  187. package/node_modules/pi-agent-ide-ast/src/ast-grep-binary.ts +46 -0
  188. package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +119 -97
  189. package/node_modules/pi-agent-ide-ast/src/extension.ts +9 -24
  190. package/node_modules/pi-agent-ide-ast/src/outline-page.ts +96 -0
  191. package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +42 -78
  192. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +5 -1
  193. package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +2 -1
  194. package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +24 -5
  195. package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +2 -1
  196. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +406 -200
  197. package/node_modules/pi-agent-ide-ast/src/tool-ast-search.ts +27 -9
  198. package/node_modules/pi-agent-ide-ast/src/tool-outline.ts +191 -0
  199. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  200. package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +63 -20
  201. package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +1 -0
  202. package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +25 -0
  203. package/node_modules/pi-agent-ide-changes/src/changes/git-paths.ts +13 -6
  204. package/node_modules/pi-agent-ide-changes/src/index-mutation-queue.ts +12 -8
  205. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +88 -78
  206. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +29 -3
  207. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  208. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +39 -3
  209. package/node_modules/pi-agent-ide-formatter/src/rustfmt.ts +101 -0
  210. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  211. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  212. package/node_modules/pi-agent-ide-lint/src/catalog.ts +20 -14
  213. package/node_modules/pi-agent-ide-lint/src/registry.ts +2 -2
  214. package/node_modules/pi-agent-ide-lsp/index.ts +15 -88
  215. package/node_modules/pi-agent-ide-lsp/package.json +12 -12
  216. package/node_modules/pi-agent-ide-lsp/src/catalog.ts +21 -9
  217. package/node_modules/pi-agent-ide-lsp/src/lsp/clang-coverage.ts +265 -0
  218. package/node_modules/pi-agent-ide-lsp/src/lsp/clangd-launch.ts +48 -0
  219. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +66 -11
  220. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +514 -207
  221. package/node_modules/pi-agent-ide-lsp/src/lsp/corrected-names.ts +211 -0
  222. package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +20 -1
  223. package/node_modules/pi-agent-ide-lsp/src/lsp/files-containing.ts +70 -0
  224. package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +1 -1
  225. package/node_modules/pi-agent-ide-lsp/src/lsp/line-breaks.ts +16 -0
  226. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +60 -16
  227. package/node_modules/pi-agent-ide-lsp/src/lsp/missing-sources.ts +21 -0
  228. package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +44 -0
  229. package/node_modules/pi-agent-ide-lsp/src/lsp/position-map.ts +17 -0
  230. package/node_modules/pi-agent-ide-lsp/src/lsp/range-match.ts +49 -0
  231. package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +16 -5
  232. package/node_modules/pi-agent-ide-lsp/src/lsp/server-request-handlers.mjs +7 -1
  233. package/node_modules/pi-agent-ide-lsp/src/lsp/shared-server-host.mjs +133 -37
  234. package/node_modules/pi-agent-ide-lsp/src/lsp/shared-servers.ts +164 -13
  235. package/node_modules/pi-agent-ide-lsp/src/lsp/source-changes.ts +18 -6
  236. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +346 -164
  237. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-selectors.ts +376 -0
  238. package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +6 -0
  239. package/node_modules/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +10 -0
  240. package/node_modules/pi-agent-ide-lsp/src/name-captures.ts +66 -0
  241. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +383 -92
  242. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +305 -77
  243. package/node_modules/pi-agent-ide-lsp/src/tool-lsp-search.ts +33 -11
  244. package/node_modules/pi-agent-image/package.json +2 -2
  245. package/node_modules/pi-agent-image/src/image-converter.ts +13 -2
  246. package/node_modules/pi-agent-invariant/package.json +1 -1
  247. package/node_modules/pi-agent-pdf/package.json +2 -2
  248. package/node_modules/pi-agent-read/package.json +7 -7
  249. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  250. package/node_modules/pi-agent-read/src/api/read-parameters.ts +51 -12
  251. package/node_modules/pi-agent-read/src/api/tools/read.ts +39 -3
  252. package/node_modules/pi-agent-read/src/core/extension.ts +80 -3
  253. package/node_modules/pi-agent-read/src/core/read-core.ts +6 -0
  254. package/node_modules/pi-agent-read/src/core/tools/read/list-result.ts +79 -0
  255. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +45 -4
  256. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +18 -9
  257. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +16 -3
  258. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +37 -9
  259. package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +15 -4
  260. package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +49 -18
  261. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +158 -51
  262. package/node_modules/pi-agent-resource/package.json +5 -1
  263. package/node_modules/pi-agent-resource/src/file-text-read.ts +86 -0
  264. package/node_modules/pi-agent-resource/src/index.ts +54 -0
  265. package/node_modules/pi-agent-resource/src/json-structured-arguments.ts +131 -0
  266. package/node_modules/pi-agent-resource/src/line-map.ts +750 -0
  267. package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
  268. package/node_modules/pi-agent-resource/src/resource-scheduler.ts +63 -23
  269. package/node_modules/pi-agent-resource/src/resource.ts +5 -0
  270. package/node_modules/pi-agent-resource/src/result-targets.ts +693 -66
  271. package/node_modules/pi-agent-resource/src/script-calls.ts +21 -0
  272. package/node_modules/pi-agent-resource/src/tool-deadline.ts +199 -0
  273. package/node_modules/pi-agent-resource/src/tool-result.ts +14 -5
  274. package/node_modules/pi-agent-resource/src/unchanged-read.ts +62 -0
  275. package/node_modules/pi-agent-search/package.json +8 -9
  276. package/node_modules/pi-agent-search/runtime/entry-57.js +0 -1
  277. package/node_modules/pi-agent-search/src/api/fuzzy.ts +2 -1
  278. package/node_modules/pi-agent-search/src/api/null-fields.ts +50 -0
  279. package/node_modules/pi-agent-search/src/api/path-list.ts +68 -0
  280. package/node_modules/pi-agent-search/src/api/presentation.ts +2 -1
  281. package/node_modules/pi-agent-search/src/api/search-call-policy.ts +16 -0
  282. package/node_modules/pi-agent-search/src/api/search-capture.ts +56 -0
  283. package/node_modules/pi-agent-search/src/api/search-parameters.ts +26 -4
  284. package/node_modules/pi-agent-search/src/api/search-scope.ts +38 -2
  285. package/node_modules/pi-agent-search/src/api/search.ts +46 -3
  286. package/node_modules/pi-agent-search/src/api/structured-result.ts +96 -25
  287. package/node_modules/pi-agent-search/src/core/extension.ts +75 -42
  288. package/node_modules/pi-agent-search/src/core/search-config.ts +2 -2
  289. package/node_modules/pi-agent-search/src/core/search-core.ts +103 -39
  290. package/node_modules/pi-agent-search-text/index.ts +62 -20
  291. package/node_modules/pi-agent-search-text/package.json +15 -15
  292. package/node_modules/pi-agent-search-text/runtime/entry-59.js +1 -0
  293. package/node_modules/pi-agent-search-text/src/current-matches.ts +314 -0
  294. package/node_modules/pi-agent-search-text/src/file-search.ts +178 -99
  295. package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +40 -17
  296. package/node_modules/pi-agent-search-text/src/persisted-result.ts +3 -8
  297. package/node_modules/pi-agent-search-text/src/resolvers.ts +395 -103
  298. package/node_modules/pi-agent-search-text/src/ripgrep.ts +142 -0
  299. package/node_modules/pi-agent-search-text/src/scoped-search.ts +24 -12
  300. package/node_modules/pi-agent-search-text/src/search-backend.ts +333 -108
  301. package/node_modules/pi-agent-search-text/src/search-presentation.ts +6 -0
  302. package/node_modules/pi-agent-search-text/src/search-query.ts +69 -34
  303. package/node_modules/pi-agent-search-text/src/search-recipe.ts +80 -8
  304. package/node_modules/pi-agent-search-text/src/search-renderer.ts +2 -1
  305. package/node_modules/pi-agent-search-text/src/search-result.ts +10 -1
  306. package/node_modules/pi-agent-search-text/src/search-session.ts +449 -58
  307. package/node_modules/pi-agent-search-text/src/tool-file-search.ts +51 -6
  308. package/node_modules/pi-agent-text/package.json +3 -3
  309. package/node_modules/pi-agent-text/runtime/entry-63.js +1 -0
  310. package/node_modules/pi-agent-text/src/index.ts +18 -0
  311. package/node_modules/pi-agent-text/src/line-anchors.ts +211 -0
  312. package/node_modules/pi-agent-text/src/no-final-line-break.ts +12 -0
  313. package/node_modules/pi-agent-text/src/search-highlight.ts +8 -0
  314. package/node_modules/pi-agent-text/src/source-line.ts +7 -1
  315. package/node_modules/pi-agent-text/src/text-anchor.ts +34 -3
  316. package/node_modules/pi-agent-text/src/text-converter.ts +2 -1
  317. package/node_modules/pi-agent-text/src/text-document.ts +9 -23
  318. package/node_modules/pi-agent-text/src/text-target.ts +14 -6
  319. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  320. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-64.js +2 -0
  321. package/node_modules/pi-agent-text-anchor-exact/index.ts +1 -65
  322. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  323. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-65.js +0 -1
  324. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-66.js +2 -0
  325. package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +185 -184
  326. package/node_modules/pi-agent-text-anchor-exact/src/anchored-literal-view.ts +122 -0
  327. package/node_modules/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +2 -1
  328. package/node_modules/pi-agent-text-anchor-exact/src/literal-match.ts +359 -0
  329. package/node_modules/pi-agent-text-anchor-exact/src/recovery.ts +1 -0
  330. package/node_modules/pi-agent-text-anchor-line-hash/index.ts +5 -3
  331. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  332. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-67.js +0 -1
  333. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-68.js +2 -0
  334. package/node_modules/pi-agent-text-anchor-line-hash/src/anchor.ts +92 -67
  335. package/node_modules/pi-agent-text-anchor-line-hash/src/range-history.ts +105 -0
  336. package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +22 -17
  337. package/node_modules/pi-agent-text-editor/index.ts +0 -10
  338. package/node_modules/pi-agent-text-editor/package.json +37 -26
  339. package/node_modules/pi-agent-text-editor/runtime/entry-84.js +0 -1
  340. package/node_modules/pi-agent-text-editor/runtime/entry-85.js +1 -0
  341. package/node_modules/pi-agent-text-editor/runtime/entry-86.js +1 -0
  342. package/node_modules/pi-agent-text-editor/runtime/entry-88.js +2 -0
  343. package/node_modules/pi-agent-text-editor/src/api/anchor-excerpt.ts +7 -0
  344. package/node_modules/pi-agent-text-editor/src/api/anchor-inspection.ts +2 -1
  345. package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +2 -0
  346. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +40 -8
  347. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +6 -1
  348. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +37 -2
  349. package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
  350. package/node_modules/pi-agent-text-editor/src/api/native-files.ts +16 -2
  351. package/node_modules/pi-agent-text-editor/src/api/pi-edit-text.ts +82 -0
  352. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +9 -2
  353. package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +1 -0
  354. package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +13 -2
  355. package/node_modules/pi-agent-text-editor/src/api/text-selector-fields.ts +210 -0
  356. package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -0
  357. package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
  358. package/node_modules/pi-agent-text-editor/src/core/already-done.ts +123 -0
  359. package/node_modules/pi-agent-text-editor/src/core/anchor-candidates.ts +116 -0
  360. package/node_modules/pi-agent-text-editor/src/core/anchor-preview.ts +32 -0
  361. package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +109 -23
  362. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +19 -5
  363. package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +6 -5
  364. package/node_modules/pi-agent-text-editor/src/core/extension.ts +54 -21
  365. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +7 -3
  366. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +14 -5
  367. package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +32 -11
  368. package/node_modules/pi-agent-text-editor/src/core/file-transfers.ts +67 -38
  369. package/node_modules/pi-agent-text-editor/src/core/file-write-observations.ts +287 -0
  370. package/node_modules/pi-agent-text-editor/src/core/image-write.ts +16 -4
  371. package/node_modules/pi-agent-text-editor/src/core/lookalike-bytes.ts +254 -0
  372. package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +29 -12
  373. package/node_modules/pi-agent-text-editor/src/core/mutation-result/compact-receipt.ts +48 -0
  374. package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +2 -1
  375. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +24 -34
  376. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +13 -20
  377. package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +32 -3
  378. package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +36 -2
  379. package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +26 -19
  380. package/node_modules/pi-agent-text-editor/src/core/native-snapshot-source.ts +13 -0
  381. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +526 -148
  382. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +28 -3
  383. package/node_modules/pi-agent-text-editor/src/core/read-fragment-resolver.ts +34 -14
  384. package/node_modules/pi-agent-text-editor/src/core/reference-list.ts +95 -0
  385. package/node_modules/pi-agent-text-editor/src/core/result-scope.ts +129 -0
  386. package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +20 -8
  387. package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +86 -69
  388. package/node_modules/pi-agent-text-editor/src/core/source-aliases.ts +92 -0
  389. package/node_modules/pi-agent-text-editor/src/core/source-change-retry.ts +92 -7
  390. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +2 -0
  391. package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +162 -47
  392. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +321 -101
  393. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +206 -134
  394. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -2
  395. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +133 -18
  396. package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +13 -0
  397. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +823 -226
  398. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +51 -1
  399. package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +7 -4
  400. package/node_modules/pi-agent-text-editor/src/tools/display-marker.ts +15 -0
  401. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +268 -159
  402. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +37 -32
  403. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +24 -70
  404. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +23 -36
  405. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +31 -45
  406. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +33 -65
  407. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +80 -42
  408. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +27 -16
  409. package/node_modules/pi-agent-text-editor-renderer/index.ts +0 -14
  410. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  411. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-89.js +2 -0
  412. package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +204 -78
  413. package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +75 -8
  414. package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +4 -1
  415. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +4 -3
  416. package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +44 -30
  417. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +170 -26
  418. package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +83 -83
  419. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -6
  420. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  421. package/node_modules/pi-agent-tool-call-interception/runtime/entry-91.js +1 -0
  422. package/node_modules/pi-agent-tool-ui/package.json +3 -3
  423. package/node_modules/pi-agent-tool-ui/runtime/entry-92.js +1 -0
  424. package/node_modules/pi-agent-tool-ui/runtime/entry-93.js +1 -0
  425. package/node_modules/pi-agent-web/index.ts +0 -3
  426. package/node_modules/pi-agent-web/package.json +8 -8
  427. package/node_modules/pi-agent-web/src/search.ts +1 -2
  428. package/node_modules/pi-agent-web-html/package.json +3 -3
  429. package/node_modules/pi-agent-web-html/runtime/entry-95.js +2 -0
  430. package/node_modules/pi-agent-web-image/package.json +4 -4
  431. package/node_modules/pi-agent-web-image/runtime/entry-96.js +2 -0
  432. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  433. package/node_modules/pi-agent-web-pdf/runtime/entry-97.js +2 -0
  434. package/node_modules/pi-agent-web-text/package.json +4 -4
  435. package/node_modules/pi-agent-web-text/runtime/entry-98.js +2 -0
  436. package/package.json +38 -38
  437. package/skills/capture-code-review-rule/SKILL.md +1 -1
  438. package/skills/configure-agent-ide/SKILL.md +1 -1
  439. package/src/api/code-view.ts +0 -2
  440. package/src/api/tool-config/linters.json +1 -0
  441. package/src/api/tool-config/lsp-servers.json +5 -0
  442. package/src/api/tool-config.ts +23 -2
  443. package/src/backend/config.ts +2 -0
  444. package/src/backend/configured-process.ts +1 -0
  445. package/src/backend/dap-java-transport.ts +4 -2
  446. package/src/backend/dap-java-worker.py +11 -4
  447. package/src/backend/dap-node-transport.ts +4 -2
  448. package/src/backend/dap-tcp-transport.ts +2 -3
  449. package/src/backend/debugger-workspace-owner.ts +6 -6
  450. package/src/backend/doctor-probe-worker.py +23 -15
  451. package/src/backend/doctor-workspace.ts +19 -18
  452. package/src/backend/file-transfer.ts +160 -56
  453. package/src/backend/formatter-registration.ts +54 -2
  454. package/src/backend/identity.ts +81 -12
  455. package/src/backend/lsp-file-watchers.ts +7 -9
  456. package/src/backend/lsp-workspace-owner.ts +25 -1
  457. package/src/backend/object-transfer.ts +28 -15
  458. package/src/backend/owned-command.ts +2 -1
  459. package/src/backend/owned-read-command.ts +2 -1
  460. package/src/backend/packaged-source.ts +12 -0
  461. package/src/backend/process-environment.ts +7 -9
  462. package/src/backend/process-metadata.ts +5 -5
  463. package/src/backend/recipe-evidence-worker.py +2 -0
  464. package/src/backend/recipe-evidence.ts +7 -8
  465. package/src/backend/registration.ts +2 -1
  466. package/src/backend/registry.ts +12 -2
  467. package/src/backend/resource-resolver.ts +11 -32
  468. package/src/backend/search-environment.ts +61 -4
  469. package/src/backend/ssh-channel-worker.py +6 -304
  470. package/src/backend/ssh-channel.ts +287 -36
  471. package/src/backend/ssh-connection-loss.ts +123 -0
  472. package/src/backend/ssh-file-stream.ts +216 -0
  473. package/src/backend/ssh-master.ts +443 -0
  474. package/src/backend/ssh-transfer-worker-windows.py +84 -0
  475. package/src/backend/ssh-transfer-worker.py +43 -10
  476. package/src/backend/ssh-transport.ts +238 -24
  477. package/src/backend/ssh-worker.py +7 -728
  478. package/src/backend/ssh.ts +83 -35
  479. package/src/backend/ssh_channel_common.py +68 -0
  480. package/src/backend/ssh_channel_posix.py +324 -0
  481. package/src/backend/ssh_channel_windows.py +527 -0
  482. package/src/backend/ssh_paths.py +23 -0
  483. package/src/backend/ssh_windows_files.py +254 -0
  484. package/src/backend/ssh_worker_common.py +96 -0
  485. package/src/backend/ssh_worker_posix.py +780 -0
  486. package/src/backend/ssh_worker_windows.py +687 -0
  487. package/src/backend/tool-config-access.ts +14 -11
  488. package/src/backend/tool-project.ts +4 -3
  489. package/src/backend/web-browser.ts +2 -3
  490. package/src/backend/web-http.ts +5 -5
  491. package/src/code-view/diagnostic-view.ts +12 -30
  492. package/src/code-view/reference.ts +9 -18
  493. package/src/code-view/source-view.ts +2 -1
  494. package/src/composite/codemode-tool-names.ts +79 -0
  495. package/src/composite/detached-results.ts +25 -6
  496. package/src/composite/ide-alias-rendering.ts +26 -4
  497. package/src/composite/module-labels.ts +2 -2
  498. package/src/composite/module-settings.ts +1 -0
  499. package/src/composite/nested-tool-rendering.ts +70 -24
  500. package/src/composite/output-limits.ts +12 -5
  501. package/src/composite/parallel-tool-guidance.ts +38 -0
  502. package/src/composite/script-values/ast-search.ts +56 -0
  503. package/src/composite/script-values/copy.ts +8 -0
  504. package/src/composite/script-values/delete.ts +5 -0
  505. package/src/composite/script-values/diff.ts +28 -0
  506. package/src/composite/script-values/edit-selection.ts +48 -0
  507. package/src/composite/script-values/failures.ts +170 -0
  508. package/src/composite/script-values/file-receipts.ts +63 -0
  509. package/src/composite/script-values/file-search.ts +10 -0
  510. package/src/composite/script-values/index.ts +55 -0
  511. package/src/composite/script-values/insert.ts +5 -0
  512. package/src/composite/script-values/lsp-search.ts +92 -0
  513. package/src/composite/script-values/match.ts +53 -0
  514. package/src/composite/script-values/move.ts +8 -0
  515. package/src/composite/script-values/path-list.ts +25 -0
  516. package/src/composite/script-values/provider-value.ts +21 -0
  517. package/src/composite/script-values/read.ts +206 -0
  518. package/src/composite/script-values/replace.ts +5 -0
  519. package/src/composite/script-values/result-reference.ts +9 -0
  520. package/src/composite/script-values/search-matches.ts +113 -0
  521. package/src/composite/script-values/search.ts +64 -0
  522. package/src/composite/script-values/semantic-search.ts +8 -0
  523. package/src/composite/script-values/terminal.ts +112 -0
  524. package/src/composite/script-values/text.ts +7 -0
  525. package/src/composite/script-values/types.ts +56 -0
  526. package/src/composite/script-values/undo.ts +5 -0
  527. package/src/composite/script-values/write.ts +8 -0
  528. package/src/composite/settings-panel.ts +18 -2
  529. package/src/composite/text-results.ts +488 -175
  530. package/src/composite/tool-availability.ts +29 -16
  531. package/src/composite/tool-discovery-guidance.ts +97 -0
  532. package/src/documentation/attachment.ts +31 -0
  533. package/src/documentation/extension.ts +6 -2
  534. package/src/documentation/search.ts +1 -7
  535. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  536. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  537. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  538. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  539. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  540. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/file-write-lock.ts +6 -4
  541. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/replace-file.ts +5 -2
  542. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +26 -10
  543. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +0 -3
  544. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
  545. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  546. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-95.js +2 -0
  547. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  548. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-96.js +2 -0
  549. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  550. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-97.js +2 -0
  551. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  552. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-98.js +2 -0
  553. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-94.js +2 -0
  554. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +1 -2
  555. package/src/extensions/pi-agent-read/package.json +7 -7
  556. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  557. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +51 -12
  558. package/src/extensions/pi-agent-read/src/api/tools/read.ts +39 -3
  559. package/src/extensions/pi-agent-read/src/core/extension.ts +80 -3
  560. package/src/extensions/pi-agent-read/src/core/read-core.ts +6 -0
  561. package/src/extensions/pi-agent-read/src/core/tools/read/list-result.ts +79 -0
  562. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +45 -4
  563. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +18 -9
  564. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +16 -3
  565. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +37 -9
  566. package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +15 -4
  567. package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +49 -18
  568. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +158 -51
  569. package/src/extensions/pi-agent-search/package.json +8 -9
  570. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +62 -20
  571. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +15 -15
  572. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-59.js +1 -0
  573. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-62.js +1 -0
  574. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/current-matches.ts +314 -0
  575. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +178 -99
  576. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +40 -17
  577. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +3 -8
  578. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +395 -103
  579. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/ripgrep.ts +142 -0
  580. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +24 -12
  581. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +333 -108
  582. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +6 -0
  583. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +69 -34
  584. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +80 -8
  585. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +2 -1
  586. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +10 -1
  587. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +449 -58
  588. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/tool-file-search.ts +51 -6
  589. package/src/extensions/pi-agent-search/runtime/entry-57.js +0 -1
  590. package/src/extensions/pi-agent-search/runtime/entry-58.js +2 -0
  591. package/src/extensions/pi-agent-search/src/api/fuzzy.ts +2 -1
  592. package/src/extensions/pi-agent-search/src/api/null-fields.ts +50 -0
  593. package/src/extensions/pi-agent-search/src/api/path-list.ts +68 -0
  594. package/src/extensions/pi-agent-search/src/api/presentation.ts +2 -1
  595. package/src/extensions/pi-agent-search/src/api/search-call-policy.ts +16 -0
  596. package/src/extensions/pi-agent-search/src/api/search-capture.ts +56 -0
  597. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +26 -4
  598. package/src/extensions/pi-agent-search/src/api/search-scope.ts +38 -2
  599. package/src/extensions/pi-agent-search/src/api/search.ts +46 -3
  600. package/src/extensions/pi-agent-search/src/api/structured-result.ts +96 -25
  601. package/src/extensions/pi-agent-search/src/core/extension.ts +75 -42
  602. package/src/extensions/pi-agent-search/src/core/search-config.ts +2 -2
  603. package/src/extensions/pi-agent-search/src/core/search-core.ts +103 -39
  604. package/src/extensions/pi-agent-text-editor/index.ts +0 -10
  605. package/src/extensions/pi-agent-text-editor/package.json +37 -26
  606. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  607. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-64.js +2 -0
  608. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +1 -65
  609. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  610. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-65.js +0 -1
  611. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-66.js +2 -0
  612. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +185 -184
  613. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchored-literal-view.ts +122 -0
  614. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +2 -1
  615. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/literal-match.ts +359 -0
  616. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/recovery.ts +1 -0
  617. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +5 -3
  618. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  619. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-67.js +0 -1
  620. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-68.js +2 -0
  621. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/anchor.ts +92 -67
  622. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/range-history.ts +105 -0
  623. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +22 -17
  624. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +0 -14
  625. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  626. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-89.js +2 -0
  627. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +204 -78
  628. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +75 -8
  629. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +4 -1
  630. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +4 -3
  631. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +44 -30
  632. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +170 -26
  633. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +83 -83
  634. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -6
  635. package/src/extensions/pi-agent-text-editor/runtime/entry-84.js +0 -1
  636. package/src/extensions/pi-agent-text-editor/runtime/entry-85.js +1 -0
  637. package/src/extensions/pi-agent-text-editor/runtime/entry-86.js +1 -0
  638. package/src/extensions/pi-agent-text-editor/runtime/entry-87.js +1 -0
  639. package/src/extensions/pi-agent-text-editor/runtime/entry-88.js +2 -0
  640. package/src/extensions/pi-agent-text-editor/src/api/anchor-excerpt.ts +7 -0
  641. package/src/extensions/pi-agent-text-editor/src/api/anchor-inspection.ts +2 -1
  642. package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +2 -0
  643. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +40 -8
  644. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +6 -1
  645. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +37 -2
  646. package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
  647. package/src/extensions/pi-agent-text-editor/src/api/native-files.ts +16 -2
  648. package/src/extensions/pi-agent-text-editor/src/api/pi-edit-text.ts +82 -0
  649. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +9 -2
  650. package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +1 -0
  651. package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +13 -2
  652. package/src/extensions/pi-agent-text-editor/src/api/text-selector-fields.ts +210 -0
  653. package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -0
  654. package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
  655. package/src/extensions/pi-agent-text-editor/src/core/already-done.ts +123 -0
  656. package/src/extensions/pi-agent-text-editor/src/core/anchor-candidates.ts +116 -0
  657. package/src/extensions/pi-agent-text-editor/src/core/anchor-preview.ts +32 -0
  658. package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +109 -23
  659. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +19 -5
  660. package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +6 -5
  661. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +54 -21
  662. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +7 -3
  663. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +14 -5
  664. package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +32 -11
  665. package/src/extensions/pi-agent-text-editor/src/core/file-transfers.ts +67 -38
  666. package/src/extensions/pi-agent-text-editor/src/core/file-write-observations.ts +287 -0
  667. package/src/extensions/pi-agent-text-editor/src/core/image-write.ts +16 -4
  668. package/src/extensions/pi-agent-text-editor/src/core/lookalike-bytes.ts +254 -0
  669. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +29 -12
  670. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/compact-receipt.ts +48 -0
  671. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +2 -1
  672. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +24 -34
  673. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +13 -20
  674. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +32 -3
  675. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +36 -2
  676. package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +26 -19
  677. package/src/extensions/pi-agent-text-editor/src/core/native-snapshot-source.ts +13 -0
  678. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +526 -148
  679. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +28 -3
  680. package/src/extensions/pi-agent-text-editor/src/core/read-fragment-resolver.ts +34 -14
  681. package/src/extensions/pi-agent-text-editor/src/core/reference-list.ts +95 -0
  682. package/src/extensions/pi-agent-text-editor/src/core/result-scope.ts +129 -0
  683. package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +20 -8
  684. package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +86 -69
  685. package/src/extensions/pi-agent-text-editor/src/core/source-aliases.ts +92 -0
  686. package/src/extensions/pi-agent-text-editor/src/core/source-change-retry.ts +92 -7
  687. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +2 -0
  688. package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +162 -47
  689. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +321 -101
  690. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +206 -134
  691. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -2
  692. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +133 -18
  693. package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +13 -0
  694. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +823 -226
  695. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +51 -1
  696. package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +7 -4
  697. package/src/extensions/pi-agent-text-editor/src/tools/display-marker.ts +15 -0
  698. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +268 -159
  699. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +37 -32
  700. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +24 -70
  701. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +23 -36
  702. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +31 -45
  703. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +33 -65
  704. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +80 -42
  705. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +27 -16
  706. package/src/pi-agent-ide.ts +41 -32
  707. package/src/plugins/pi-agent-ide-ast/package.json +13 -13
  708. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +56 -65
  709. package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +197 -130
  710. package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +2 -1
  711. package/src/plugins/pi-agent-ide-ast/src/ast-grep-binary.ts +46 -0
  712. package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +119 -97
  713. package/src/plugins/pi-agent-ide-ast/src/extension.ts +9 -24
  714. package/src/plugins/pi-agent-ide-ast/src/outline-page.ts +96 -0
  715. package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +42 -78
  716. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +5 -1
  717. package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +2 -1
  718. package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +24 -5
  719. package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +2 -1
  720. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +406 -200
  721. package/src/plugins/pi-agent-ide-ast/src/tool-ast-search.ts +27 -9
  722. package/src/plugins/pi-agent-ide-ast/src/tool-outline.ts +191 -0
  723. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  724. package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +63 -20
  725. package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +1 -0
  726. package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +25 -0
  727. package/src/plugins/pi-agent-ide-changes/src/changes/git-paths.ts +13 -6
  728. package/src/plugins/pi-agent-ide-changes/src/index-mutation-queue.ts +12 -8
  729. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +88 -78
  730. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +29 -3
  731. package/src/plugins/pi-agent-ide-debugger/index.ts +42 -32
  732. package/src/plugins/pi-agent-ide-debugger/src/string-enum.ts +14 -0
  733. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +124 -79
  734. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  735. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +39 -3
  736. package/src/plugins/pi-agent-ide-formatter/src/rustfmt.ts +101 -0
  737. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  738. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  739. package/src/plugins/pi-agent-ide-lint/src/catalog.ts +20 -14
  740. package/src/plugins/pi-agent-ide-lint/src/registry.ts +2 -2
  741. package/src/plugins/pi-agent-ide-lsp/index.ts +15 -88
  742. package/src/plugins/pi-agent-ide-lsp/package.json +12 -12
  743. package/src/plugins/pi-agent-ide-lsp/src/catalog.ts +21 -9
  744. package/src/plugins/pi-agent-ide-lsp/src/lsp/clang-coverage.ts +265 -0
  745. package/src/plugins/pi-agent-ide-lsp/src/lsp/clangd-launch.ts +48 -0
  746. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +66 -11
  747. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +514 -207
  748. package/src/plugins/pi-agent-ide-lsp/src/lsp/corrected-names.ts +211 -0
  749. package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +20 -1
  750. package/src/plugins/pi-agent-ide-lsp/src/lsp/files-containing.ts +70 -0
  751. package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +1 -1
  752. package/src/plugins/pi-agent-ide-lsp/src/lsp/line-breaks.ts +16 -0
  753. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +60 -16
  754. package/src/plugins/pi-agent-ide-lsp/src/lsp/missing-sources.ts +21 -0
  755. package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +44 -0
  756. package/src/plugins/pi-agent-ide-lsp/src/lsp/position-map.ts +17 -0
  757. package/src/plugins/pi-agent-ide-lsp/src/lsp/range-match.ts +49 -0
  758. package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +16 -5
  759. package/src/plugins/pi-agent-ide-lsp/src/lsp/server-request-handlers.mjs +7 -1
  760. package/src/plugins/pi-agent-ide-lsp/src/lsp/shared-server-host.mjs +133 -37
  761. package/src/plugins/pi-agent-ide-lsp/src/lsp/shared-servers.ts +164 -13
  762. package/src/plugins/pi-agent-ide-lsp/src/lsp/source-changes.ts +18 -6
  763. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +346 -164
  764. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-selectors.ts +376 -0
  765. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +6 -0
  766. package/src/plugins/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +10 -0
  767. package/src/plugins/pi-agent-ide-lsp/src/name-captures.ts +66 -0
  768. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +383 -92
  769. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +305 -77
  770. package/src/plugins/pi-agent-ide-lsp/src/tool-lsp-search.ts +33 -11
  771. package/src/plugins/pi-agent-ide-processes/src/registry.ts +64 -3
  772. package/src/plugins/pi-agent-ide-processes/src/ui.ts +57 -1
  773. package/src/plugins/pi-agent-ide-semantic/src/backend.ts +18 -6
  774. package/src/plugins/pi-agent-ide-semantic/src/vera-backend.ts +16 -9
  775. package/src/plugins/pi-agent-ide-terminal/index.ts +23 -7
  776. package/src/plugins/pi-agent-ide-terminal/src/list.ts +79 -0
  777. package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +22 -0
  778. package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +3 -0
  779. package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +18 -6
  780. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +132 -18
  781. package/src/plugins/pi-agent-ide-terminal/src/search.ts +117 -50
  782. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +94 -10
  783. package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +24 -1
  784. package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +5 -2
  785. package/src/plugins/pi-agent-ide-terminal/src/terminal-text.ts +173 -0
  786. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +266 -112
  787. package/src/plugins/pi-agent-ide-terminal/src/types.ts +6 -1
  788. package/src/plugins/pi-agent-ide-terminal/src/ui.ts +11 -6
  789. package/src/plugins/pi-agent-ide-terminal/src/unix-pty-output.ts +47 -0
  790. package/src/post-edit/gate.ts +16 -1
  791. package/src/semantic/extension.ts +8 -2
  792. package/src/standalone/scoped-api.ts +85 -18
  793. package/src/toolchain/types.ts +4 -0
  794. package/dist/chunk-2AANEKFS.js +0 -1
  795. package/dist/chunk-33U3RUM3.js +0 -12
  796. package/dist/chunk-34IYWKY5.js +0 -1
  797. package/dist/chunk-4CSNQX54.js +0 -23
  798. package/dist/chunk-53IV6EKV.js +0 -1
  799. package/dist/chunk-5AROEOJB.js +0 -1
  800. package/dist/chunk-5D4C225L.js +0 -1
  801. package/dist/chunk-5W6QQZFI.js +0 -2
  802. package/dist/chunk-6W4OJLCJ.js +0 -1
  803. package/dist/chunk-6ZYCTWQE.js +0 -1
  804. package/dist/chunk-756K3LJY.js +0 -1
  805. package/dist/chunk-AMSNDWBT.js +0 -2
  806. package/dist/chunk-APWMLLSE.js +0 -17
  807. package/dist/chunk-BMSAVDRD.js +0 -13
  808. package/dist/chunk-BRJIXNFU.js +0 -5
  809. package/dist/chunk-C2GZLLSP.js +0 -5
  810. package/dist/chunk-ECSMTGVM.js +0 -6
  811. package/dist/chunk-EWTVVPUA.js +0 -11
  812. package/dist/chunk-FBR7ZLLN.js +0 -1
  813. package/dist/chunk-FGN2ZMEN.js +0 -1
  814. package/dist/chunk-FJSYWOE6.js +0 -1
  815. package/dist/chunk-FTECKRK6.js +0 -1
  816. package/dist/chunk-GRZTKMXQ.js +0 -1
  817. package/dist/chunk-HFCHOFLV.js +0 -2
  818. package/dist/chunk-HFF4GY7R.js +0 -3
  819. package/dist/chunk-HJXSEPO7.js +0 -111
  820. package/dist/chunk-HSEDKYH4.js +0 -1
  821. package/dist/chunk-II7AOJNH.js +0 -9
  822. package/dist/chunk-J34VKQGJ.js +0 -1
  823. package/dist/chunk-J6CDIH3S.js +0 -84
  824. package/dist/chunk-JHWLRL4U.js +0 -1
  825. package/dist/chunk-JMQ67UNK.js +0 -3
  826. package/dist/chunk-JRIP33PC.js +0 -13
  827. package/dist/chunk-K5M65CAF.js +0 -1
  828. package/dist/chunk-KJAR2WDO.js +0 -1
  829. package/dist/chunk-KX7MG72M.js +0 -1
  830. package/dist/chunk-L2B4DTVS.js +0 -1
  831. package/dist/chunk-LEKC4GQK.js +0 -5
  832. package/dist/chunk-LIGOOMJS.js +0 -10
  833. package/dist/chunk-LY2UANKU.js +0 -6
  834. package/dist/chunk-M7P7V4WI.js +0 -25
  835. package/dist/chunk-MXLSGMRZ.js +0 -3
  836. package/dist/chunk-N2NEFXHB.js +0 -13
  837. package/dist/chunk-NF74ITWT.js +0 -2
  838. package/dist/chunk-NQYUIQRH.js +0 -1
  839. package/dist/chunk-OCU6NW5Y.js +0 -1
  840. package/dist/chunk-OIEA4QWF.js +0 -4
  841. package/dist/chunk-ON5HDFNL.js +0 -10
  842. package/dist/chunk-P43GGKUC.js +0 -28
  843. package/dist/chunk-PPCWY4BB.js +0 -1
  844. package/dist/chunk-QGXZ4RWX.js +0 -1
  845. package/dist/chunk-S3T5NOSL.js +0 -1
  846. package/dist/chunk-S7E2D5K7.js +0 -5
  847. package/dist/chunk-SIYPD5MM.js +0 -3
  848. package/dist/chunk-STUZZM5B.js +0 -1
  849. package/dist/chunk-T4FTT3U4.js +0 -1
  850. package/dist/chunk-T5ACAOKJ.js +0 -4
  851. package/dist/chunk-TILMPAF2.js +0 -1
  852. package/dist/chunk-TSNY2FSU.js +0 -1
  853. package/dist/chunk-TWJINFQB.js +0 -9
  854. package/dist/chunk-TWQ6ACOI.js +0 -1
  855. package/dist/chunk-UDVVKVG4.js +0 -1
  856. package/dist/chunk-V2D5MLGE.js +0 -1
  857. package/dist/chunk-VDSSAP6Y.js +0 -1
  858. package/dist/chunk-VHYJTAXX.js +0 -1
  859. package/dist/chunk-WCSWQDJ2.js +0 -22
  860. package/dist/chunk-WQTF6Q2X.js +0 -3
  861. package/dist/chunk-XE4W5YTE.js +0 -2
  862. package/dist/chunk-YFPU2LRR.js +0 -23
  863. package/dist/chunk-YLEERRX3.js +0 -33
  864. package/dist/chunk-YOJHCARZ.js +0 -1
  865. package/dist/chunk-YPTDPMK5.js +0 -1
  866. package/docs/agent-guides/editing.md +0 -43
  867. package/docs/agent-guides/search.md +0 -38
  868. package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +0 -73
  869. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-63.js +0 -2
  870. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-64.js +0 -1
  871. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-66.js +0 -1
  872. package/node_modules/pi-agent-text-editor/runtime/entry-68.js +0 -1
  873. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-85.js +0 -2
  874. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +0 -2
  875. package/node_modules/pi-agent-tool-ui/runtime/entry-88.js +0 -1
  876. package/node_modules/pi-agent-tool-ui/runtime/entry-89.js +0 -1
  877. package/node_modules/pi-agent-web-html/runtime/entry-91.js +0 -2
  878. package/node_modules/pi-agent-web-image/runtime/entry-92.js +0 -2
  879. package/node_modules/pi-agent-web-pdf/runtime/entry-93.js +0 -2
  880. package/src/composite/search-facts.ts +0 -45
  881. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-91.js +0 -2
  882. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-92.js +0 -2
  883. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-93.js +0 -2
  884. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-94.js +0 -2
  885. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-58.js +0 -2
  886. package/src/extensions/pi-agent-search/runtime/entry-54.js +0 -1
  887. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-63.js +0 -2
  888. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-64.js +0 -1
  889. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-66.js +0 -1
  890. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-85.js +0 -2
  891. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +0 -2
  892. package/src/extensions/pi-agent-text-editor/runtime/entry-68.js +0 -1
  893. package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +0 -73
  894. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-54.js +0 -0
  895. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-58.js +0 -0
  896. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-62.js +0 -0
  897. /package/node_modules/{pi-agent-tool-call-interception → pi-agent-text-editor}/runtime/entry-87.js +0 -0
  898. /package/node_modules/{pi-agent-web → pi-agent-text-editor-stale-anchor}/runtime/entry-90.js +0 -0
  899. /package/node_modules/{pi-agent-web-text → pi-agent-web}/runtime/entry-94.js +0 -0
  900. /package/src/extensions/{pi-agent-read/extensions/pi-agent-web → pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor}/runtime/entry-90.js +0 -0
@@ -0,0 +1,6 @@
1
+ import{B as ce,j as ae}from"./chunk-OEEE5BLN.js";import{a as i}from"./chunk-EI7MMDWY.js";import D from"node:path";function cn(r){if(/^\/[A-Z]:\/?$/u.test(r))return;let e=D.posix.dirname(r);return e===r?void 0:e}i(cn,"remoteParent");function S(r,e,t="linux"){if(!/^[a-z0-9][a-z0-9_-]*$/u.test(r))throw new TypeError("SSH target IDs must contain lowercase letters, digits, underscores or hyphens");if(e.includes("\0"))throw new TypeError("Remote paths must contain no NUL characters");let n=t==="windows"?Ue(e):Fe(e),s=n.split("/").map(o=>encodeURIComponent(o).replaceAll("%3A",":")).join("/");return{target:r,path:n,source:`ssh://${r}${s}`}}i(S,"remoteLocation");function Fe(r){if(!r.startsWith("/"))throw new TypeError("Remote paths must be absolute");return D.posix.normalize(r)}i(Fe,"posixPath");function Ue(r){let e=r.replaceAll("\\","/"),t=/^\/?(?<drive>[A-Za-z]):(?<rest>\/.*)?$/u.exec(e);if(!t?.groups?.drive)throw new TypeError("Windows remote paths must start with a drive, such as C:/Users; UNC and drive-relative paths are not supported");return`/${t.groups.drive.toUpperCase()}:${D.posix.normalize(t.groups.rest??"/")}`}i(Ue,"windowsPath");function J(r,e,t=()=>{}){if(r.startsWith("ssh:")){let o=new URL(r);if(!r.startsWith("ssh://")||!o.hostname||o.username||o.password||o.port||o.search||o.hash||r.includes("?")||r.includes("#"))throw new TypeError("SSH references require a configured target and an absolute path, without credentials or selectors");return S(o.hostname,decodeURIComponent(o.pathname),t(o.hostname))}if(!e?.startsWith("ssh:"))return;let n=J(e,void 0,t);if(!n)throw new TypeError("Invalid remote workspace");let s=t(n.target);if(s==="windows"&&/^[A-Za-z]:/u.test(r))return S(n.target,r,"windows");if(!/^[A-Za-z][A-Za-z\d+.-]*:/u.test(r))return s==="windows"?We(n,r):S(n.target,D.posix.resolve(n.path,r))}i(J,"resolveRemoteLocation");function We(r,e){let t=e.replaceAll("\\","/");if(t.startsWith("//"))throw new TypeError("UNC paths are not supported on Windows SSH targets");let s=`${r.path.slice(0,3)}${D.posix.resolve(r.path.slice(3)||"/",t)}`;return S(r.target,s,"windows")}i(We,"resolveWindowsPath");import{readFile as He}from"node:fs/promises";function de(r){let e=He(r,"utf8");return e.catch(()=>{}),e}i(de,"packagedSource");function b(r){return r.os??"linux"}i(b,"targetOs");function U(r){return b(r)==="windows"?`${r.workspace.slice(0,3)}/`:"/"}i(U,"neutralDirectory");function W(r){if(S(r.id,r.workspace,b(r)),!/^(?:[A-Za-z0-9_][A-Za-z0-9_.-]*@)?[A-Za-z0-9_][A-Za-z0-9_.-]*$/u.test(r.host))throw new TypeError("SSH host must be an OpenSSH host alias, not a command or URI")}i(W,"validateSshTarget");function H(r){return{python:r}}i(H,"remotePython");var qe=["ssh-channel-worker.py","ssh_channel_common.py","ssh_channel_posix.py","ssh_channel_windows.py","ssh-worker.py","ssh_worker_common.py","ssh_worker_posix.py","ssh_worker_windows.py","ssh_paths.py","ssh_windows_files.py","ssh-transfer-worker.py","ssh-transfer-worker-windows.py"],ze=new Map(qe.map(r=>[r,de(new URL(`./${r}`,new URL("../src/backend/ssh-transport.ts",import.meta.url).href))]));function x(r){let e=ze.get(r);if(e===void 0)throw new Error(`Unknown SSH worker source: ${r}`);return e}i(x,"workerSource");function he(r,e){return["import importlib.abc as _pi_abc, importlib.util as _pi_util, sys as _pi_sys",`_pi_modules = {${Object.entries(e).map(([n,s])=>`${JSON.stringify(n)}:${JSON.stringify(s)}`).join(",")}}`,"class _PiLoader(_pi_abc.Loader):"," def __init__(self, source): self.source = source"," def create_module(self, spec): return None"," def exec_module(self, module):"," exec(compile(self.source, '<pi-agent-ide/' + module.__name__ + '>', 'exec'), module.__dict__)","class _PiFinder(_pi_abc.MetaPathFinder):"," def find_spec(self, name, path=None, target=None):"," source = _pi_modules.get(name)"," return None if source is None else _pi_util.spec_from_loader(name, _PiLoader(source))","_pi_sys.meta_path.insert(0, _PiFinder())",r].join(`
2
+ `)}i(he,"bundlePython");var Ve={channel:{entry:"ssh-channel-worker.py",common:"ssh_channel_common",platform:"ssh_channel"},file:{entry:"ssh-worker.py",common:"ssh_worker_common",platform:"ssh_worker"}},j="ssh_windows_files",F=new Map;function A(r,e){let t=`${r}:${e}`,n=F.get(t);if(!n){let s=Ve[e],o=`${s.platform}_${r==="windows"?"windows":"posix"}.py`,c=r==="windows"&&e==="file"?x(`${j}.py`):void 0;n=Promise.all([x(s.entry),x(`${s.common}.py`),x("ssh_paths.py"),x(o),c]).then(([h,d,l,m,p])=>he(h,{[s.common]:d,ssh_paths:l,[`${s.platform}_platform`]:m,...p===void 0?{}:{[j]:p}})),F.set(t,n)}return n}i(A,"sshWorkerBundle");function gn(r){let e=`${r}:transfer`,t=F.get(e);return t||(t=r==="windows"?Promise.all([x("ssh-transfer-worker-windows.py"),x("ssh_worker_common.py"),x("ssh_paths.py"),x(`${j}.py`)]).then(([n,s,o,c])=>he(n,{ssh_worker_common:s,ssh_paths:o,[j]:c})):x("ssh-transfer-worker.py"),F.set(e,t)),t}i(gn,"sshTransferProgram");function ue(r){return r==="windows"?["py -3","python"]:["python3"]}i(ue,"interpreterCandidates");var Ye="import sys;exec(sys.stdin.buffer.raw.readline())";function le(r){return`${r} -c "${Ye}"`}i(le,"sshBootstrapCommand");var Z="pi-agent-ide-worker:";function pe(r,e){let n=["import json,os,sys","def _pi_read(n):"," b=bytearray()"," while len(b)<n:"," c=os.read(0,n-len(b))"," if not c:raise SystemExit(70)"," b+=c"," return bytes(b)",`_pi_ok=${r==="windows"?'sys.platform=="win32"':'sys.platform.startswith("linux")'}`,`os.write(1,b"\\n${Z}"+json.dumps({"platform":sys.platform,"accepted":_pi_ok}).encode()+b"\\n")`,"if not _pi_ok:raise SystemExit(0)","exec(compile(_pi_read(int(_pi_read(10))),'<pi-agent-ide>','exec'))"].join(`
3
+ `),s=Buffer.from(e,"utf8");return Buffer.concat([Buffer.from(`exec(${JSON.stringify(n)})
4
+ `,"utf8"),Buffer.from(String(s.length).padStart(10,"0"),"ascii"),s])}i(pe,"sshBootstrapInput");function q(r){let e=["-o","BatchMode=yes","-o","StrictHostKeyChecking=yes","-o","ForwardAgent=no","-o","PermitLocalCommand=no","-o","ClearAllForwardings=yes"];return r.configFile!==void 0&&e.push("-F",r.configFile),e}i(q,"sshSecurityOptions");function fe(r,e,t=[]){return["-T","-o","LogLevel=VERBOSE",...q(r),...t,"--",r.host,e]}i(fe,"systemSshArguments");function me(r,e,t="python3"){if(/Host key verification failed|REMOTE HOST IDENTIFICATION HAS CHANGED|No .* host key is known/u.test(e))return"HOST_KEY_FAILED";if(/Permission denied \([^)]*\)/u.test(e))return"AUTH_FAILED";if(r===255)return"TRANSPORT_FAILED";let[n=""]=t.split(" "),s=n.replaceAll(/[^A-Za-z0-9_-]/gu,"");return new RegExp([`\\b${s}:\\s*(?:command\\s+)?not found`,`Unknown command:?\\s*'?${s}\\b`,`'${s}' is not recognized`,"Python was not found"].join("|"),"u").test(e)?"DEPENDENCY_UNAVAILABLE":"TRANSPORT_FAILED"}i(me,"sshFailureCode");import{createHash as Yt}from"node:crypto";import{Type as a}from"typebox";import{Value as De}from"typebox/value";import{spawn as $t}from"node:child_process";import{PassThrough as Ce}from"node:stream";import{setTimeout as jt}from"node:timers/promises";import{Type as g}from"typebox";import{Value as _e}from"typebox/value";var Je=/^Authenticated to /mu;function K(r){return Je.test(r)}i(K,"sshAuthenticated");var Ze=[["keepalive-timeout",/Timeout, server .* not responding/u],["reset",/Connection reset/u],["closed-by-target",/Connection closed by|closed by remote host/u],["broken-pipe",/Broken pipe/u],["timed-out",/(?:Connection|Operation) timed out/u],["refused",/Connection refused/u],["unreachable",/No route to host|Network is unreachable|Host is down/u],["unresolved",/Could not resolve hostname/u]];function G(r,e){let t=e.split(/\r?\n/u);for(let n=t.length-1;n>=0;n--){let s=t[n]??"";for(let[o,c]of Ze)if(c.test(s))return o}return r===null?"signal":"unexplained"}i(G,"sshConnectionLossReason");var Ke=/^Transferred: /mu;function ye(r){let e=G(0,r);return e==="unexplained"&&Ke.test(r)?"closed-by-target":e}i(ye,"sshMasterConnectionLossReason");var Ge=new Set(["keepalive-timeout","reset","closed-by-target","broken-pipe","timed-out","unreachable"]);function we(r){return Ge.has(r)}i(we,"sshConnectionLossTransient");var Xe={"keepalive-timeout":"the target stopped answering keepalive probes, so this side closed the connection",reset:"the connection was reset (by the target or the network)","closed-by-target":"the target closed the connection","broken-pipe":"the connection broke as this side sent data to the target","timed-out":"the network stopped delivering data (TCP timed out)",refused:"the target refused the connection",unreachable:"the network has no route to the target",unresolved:"the host name did not resolve","stop-unconfirmed":"the target did not confirm a stop in time, so this side closed the connection",signal:"the local SSH client was killed by a signal",unexplained:"the SSH connection ended without the command's exit status"},Qe={connecting:"while connecting",starting:"while the command was starting",running:"while the command was running"};function ge(r){let e=r/1e3;return`${e<10?e.toFixed(1):Math.round(e)} s`}i(ge,"seconds");function Se(r){let e=r.silentMs!==void 0&&r.silentMs>=1e3?`; nothing had arrived from the target for ${ge(r.silentMs)} before that`:"",t=r.phase==="connecting"?"; nothing ran on the target":"";return`${Xe[r.reason]} ${Qe[r.phase]}, ${ge(r.afterMs)} after the connection attempt began${e}${t}`}i(Se,"describeSshConnectionLoss");import{execFile as et,spawn as tt,spawnSync as nt}from"node:child_process";import{createHash as rt,randomUUID as st}from"node:crypto";import{closeSync as ot,existsSync as it,fstatSync as at,openSync as ct,readSync as dt,rmSync as be}from"node:fs";import{lstat as ht,mkdir as ut,readdir as lt,unlink as $}from"node:fs/promises";import pt from"node:net";import Ee from"node:path";var ft=8,mt=4,gt=60,yt=3e4,wt=2e3,St=3e4,I={options:[],release(){},masterDiagnostics:i(()=>"","masterDiagnostics")},z=".log",bt=4096,kt=15,Et=3,X=new Map,Tt=st(),ke=Symbol.for("pi-agent-ide.ssh-master.own-sockets"),Pt;async function Te(r,e,t){if(process.platform==="win32")return I;let n=Date.now()+e,s=`${r.host}\0${r.configFile??""}`,o=X.get(s);o===void 0&&(o=vt(s,r),X.set(s,o));let c=await o;if(c===void 0)return I;for(;;){if(t?.aborted)return I;let h=c.members.find(p=>p.started&&p.sessions<ft);if(h!==void 0){let p=_t(c,h);if(await ee(h.socket))return p;p.release(),Pe(c,h);continue}let d=c.members.find(p=>!p.started);if(d!==void 0){if(!await ve(d.ready,n-Date.now(),t))return I;continue}let l=c.failedAt!==void 0&&Date.now()-c.failedAt<yt;if(c.members.length<mt&&!l){Ct(c);continue}let m=Math.min(wt,n-Date.now());if(c.members.length===0||m<=0||!await Ot(c,m,t))return I}}i(Te,"sshRoute");function xt(){let r=Q();for(let[e,t]of r)be(`${e}${z}`,{force:!0}),it(e)&&(nt("ssh",[...q(t),"-o",`ControlPath=${e}`,"-O","exit","--",t.host],{stdio:"ignore",timeout:2e3}),be(e,{force:!0}));r.clear(),X.clear()}i(xt,"stopSshMasters");async function vt(r,e){let t=await It(e);if(t===void 0||At(t))return;let n=await(Pt??=Rt());if(n===void 0)return;let s=Ee.join(n,`${process.pid}-${rt("sha256").update(`${Tt}\0${r}`).digest("hex").slice(0,16)}`),o=Nt(t);return{target:e,name:s,keepalive:o,members:[],waiters:[],launched:0}}i(vt,"createPool");function Ct(r){let e=`${r.name}-${r.launched++}`;Q().set(e,r.target);let t={socket:e,sessions:0,started:!1,ready:Lt(r.target,e,r.keepalive)};t.ready.then(n=>{n?t.started=!0:(r.failedAt=Date.now(),Pe(r,t))}),r.members.push(t)}i(Ct,"launchMember");function _t(r,e){e.sessions++;let t=!1;return{options:["-o","ControlMaster=no","-o",`ControlPath=${e.socket}`],masterDiagnostics:i(()=>Mt(`${e.socket}${z}`,bt),"masterDiagnostics"),release(){t||(t=!0,e.sessions--,r.waiters.shift()?.())}}}i(_t,"take");function Pe(r,e){let t=r.members.indexOf(e);t>=0&&r.members.splice(t,1),Q().delete(e.socket),$(e.socket).catch(()=>{}),$(`${e.socket}${z}`).catch(()=>{})}i(Pe,"remove");function Q(){let r=globalThis,e=r[ke];return e===void 0&&(e=new Map,r[ke]=e,process.once("exit",xt)),e}i(Q,"ownSockets");function Ot(r,e,t){let n,s=new Promise(o=>{n=i(()=>o(!0),"wake"),r.waiters.push(n)});return ve(s,e,t).finally(()=>{let o=n===void 0?-1:r.waiters.indexOf(n);o>=0&&r.waiters.splice(o,1)})}i(Ot,"slot");async function Lt(r,e,t){let n=`${e}${z}`;await Promise.all([$(e).catch(()=>{}),$(n).catch(()=>{})]);let s=tt("ssh",[...q(r),"-o","ControlMaster=yes","-o",`ControlPath=${e}`,"-o",`ControlPersist=${gt}`,...t,"-o","LogLevel=VERBOSE","-E",n,"-f","-N","--",r.host],{stdio:"ignore"});return await new Promise(c=>{let h=setTimeout(()=>{s.kill("SIGKILL"),c(null)},St);s.once("error",()=>{clearTimeout(h),c(null)}),s.once("exit",d=>{clearTimeout(h),c(d)})})===0&&await ee(e)}i(Lt,"launch");async function It(r){return await new Promise(e=>{et("ssh",[...r.configFile===void 0?[]:["-F",r.configFile],"-G","--",r.host],{timeout:1e4,maxBuffer:1024*1024},(t,n)=>e(t?void 0:n))})}i(It,"userConfiguration");function xe(r){return new Map(r.split(`
5
+ `).map(e=>{let[t="",...n]=e.trim().split(" ");return[t.toLowerCase(),n.join(" ")]}))}i(xe,"configurationOptions");function At(r){let e=xe(r),t=e.get("controlpath");return(e.get("controlmaster")??"false")!=="false"||t!==void 0&&t!=="none"}i(At,"multiplexingConfigured");function Nt(r){let e=xe(r),t=Number(e.get("serveraliveinterval")),n=Number(e.get("serveralivecountmax")),s=Number.isSafeInteger(t)&&t>0;return["-o",`ServerAliveInterval=${s?t:kt}`,"-o",`ServerAliveCountMax=${s&&Number.isSafeInteger(n)&&n>0?n:Et}`]}i(Nt,"masterKeepaliveOptions");async function Rt(){let r=process.getuid?.();if(r===void 0)return;let e=`/tmp/pi-ssh-${r}`;try{await ut(e,{mode:448}).catch(n=>{if(n.code!=="EEXIST")throw n});let t=await ht(e);if(!t.isDirectory()||t.uid!==r||(t.mode&63)!==0)return}catch{return}return await Bt(e),e}i(Rt,"privateSocketDirectory");async function Bt(r){let e=await lt(r).catch(()=>[]);await Promise.all(e.map(async t=>{let n=Number(/^(\d+)-[0-9a-f]{16}-\d+(?:\.log)?$/u.exec(t)?.[1]);if(!Number.isSafeInteger(n)||n===process.pid||Dt(n))return;let s=Ee.join(r,t);await ee(s)||await $(s).catch(()=>{})}))}i(Bt,"removeStaleSockets");function Mt(r,e){let t;try{t=ct(r,"r");let n=at(t).size,s=Buffer.alloc(Math.min(n,e));return dt(t,s,0,s.length,n-s.length),s.toString("utf8")}catch{return""}finally{t!==void 0&&ot(t)}}i(Mt,"fileTail");function Dt(r){try{return process.kill(r,0),!0}catch(e){return e.code==="EPERM"}}i(Dt,"running");function ee(r){return new Promise(e=>{let t=pt.connect(r),n=i(o=>{clearTimeout(s),t.destroy(),e(o)},"finish"),s=setTimeout(()=>n(!1),1e3);t.once("connect",()=>n(!0)),t.once("error",()=>n(!1))})}i(ee,"listening");async function ve(r,e,t){if(t?.aborted)return!1;let n,s;try{return await Promise.race([r,new Promise(o=>{n=setTimeout(()=>o(!1),e),s=i(()=>o(!1),"abort"),t?.addEventListener("abort",s,{once:!0})})])}finally{clearTimeout(n),s&&t?.removeEventListener("abort",s)}}i(ve,"settled");var Oe=Buffer.from(Z,"ascii"),Ft=g.Object({platform:g.String(),accepted:g.Boolean()}),Ut=g.Union([g.Object({kind:g.Literal("ready"),pid:g.Integer({minimum:1}),identity:g.Optional(g.String({pattern:"^[a-f0-9-]+:[0-9]+$"}))}),g.Object({kind:g.Literal("ack"),id:g.Integer({minimum:1})}),g.Object({kind:g.Union([g.Literal("stdout"),g.Literal("stderr")]),bytes:g.String({maxLength:32768})}),g.Object({kind:g.Literal("exit"),exitCode:g.Integer()}),g.Object({kind:g.Literal("error"),code:g.String({pattern:"^[A-Z][A-Z0-9_]*$"}),effect:g.Union([g.Literal("not-applied"),g.Literal("unknown")])})]),te=16384,Ae=128,Wt=Ae*te,Le=new Map;async function N(r,e,t,n,s={}){W(r),s.pty&&Ne(s.pty.cols,s.pty.rows);let o=b(r),c=S(r.id,n,o).source,h=s.timeoutMs??3e4;if(!Number.isFinite(h)||h<=0)throw new TypeError("SSH startup deadline must be positive");s.signal?.throwIfAborted();let d=pe(o,await A(o,"channel"));s.signal?.throwIfAborted();let l=JSON.stringify({...typeof e=="string"?{command:e}:{python:e.python},args:t,cwd:n,...s.pty?{pty:s.pty}:{},...s.gracefulStop===!0?{gracefulStop:!0}:{}});if(Buffer.byteLength(l)>48*1024*1024)throw new f("FRAME_LIMIT",c,"not-applied");let m=`${r.host}\0${r.configFile??""}`,p=Le.get(m),y=[...p===void 0?[]:[p],...ue(o).filter(u=>u!==p)],C=performance.now()+h,_=!0,w=0;for(let u=0;u<y.length;){let v=y[u]??"",T=_?await Te(r,Math.max(1,C-performance.now()),s.signal):I;s.signal?.aborted&&(T.release(),s.signal.throwIfAborted());let M=$t("ssh",fe(r,le(v),T.options),{stdio:"overlapped"});M.once("close",()=>T.release()),M.once("error",()=>T.release());let P=new ne(M,c,s.pty!==void 0,v,s.signal,T.masterDiagnostics),O=setTimeout(()=>P.cancel("TIMEOUT"),Math.max(1,C-performance.now()));try{let L=P.sendInitial(d,l);return L.catch(()=>{}),await P.ready,await L,Le.set(m,v),P}catch(L){if(T.options.length>0&&P.transportLost&&!s.signal?.aborted){_=!1;continue}if(P.reconnectable&&w<Ie.length){let ie=Ie[w++]??0;if(C-performance.now()>ie){if(!await jt(ie,!0,{signal:s.signal}).catch(()=>!1))throw new f("CANCELLED",c,"not-applied");continue}}if(!P.interpreterMissing||u===y.length-1)throw L;u++}finally{clearTimeout(O)}}throw new f("DEPENDENCY_UNAVAILABLE",c,"not-applied")}i(N,"startSshProcess");var Ie=[1e3,2e3];function Ne(r,e){if(![r,e].every(t=>Number.isSafeInteger(t)&&t>0&&t<=1e3))throw new TypeError("PTY dimensions must be integers between 1 and 1000")}i(Ne,"validateDimensions");var ne=class{constructor(e,t,n,s,o,c=()=>""){this.child=e;this.source=t;this.pty=n;this.interpreter=s;this.masterDiagnostics=c;this.ready=new Promise((d,l)=>{this.#o=d,this.#d=l}),this.completion=new Promise((d,l)=>{this.#h=d,this.#i=l}),this.ready.catch(()=>{}),this.completion.catch(()=>{}),e.stdout.on("data",d=>{this.#f=performance.now(),this.#t=Buffer.concat([this.#t,d]),this.parse()}),e.stderr.on("data",d=>{let l=d.toString();this.#l.length<16384&&(this.#l+=l),this.#p=(this.#p+l).slice(-4096)}),e.stdin.on("error",()=>{}),e.once("error",()=>{this.#s="DEPENDENCY_UNAVAILABLE"});let h=i(()=>{if(this.#r)return;this.#s??="CANCELLED";let d=this.stop();ae(d)},"abort");o?.addEventListener("abort",h,{once:!0}),e.once("close",d=>{this.#r=!0,this.#_=d,clearTimeout(this.#L),o?.removeEventListener("abort",h);let l=d!==0?me(d,this.#l,this.interpreter):void 0,m=this.#s??(l==="DEPENDENCY_UNAVAILABLE"&&this.#a?"TRANSPORT_FAILED":l??(this.#c===void 0?"TRANSPORT_FAILED":void 0));this.#g=l,m==="TRANSPORT_FAILED"&&(this.#u=this.connectionLoss(d)),this.stdout.end(),this.stderr.end();let p=this.error(m??"INPUT_CLOSED");for(let y of this.#e.values())y.reject(p);this.#e.clear();for(let y of this.#k.splice(0))y();if(m){let y=this.error(m);this.#d(y),this.#i(y)}else this.#c!==void 0&&this.#h({exitCode:this.#c})});for(let d of[this.stdout,this.stderr]){let l=i(()=>{this.#n.delete(d),this.parse(),this.#n.size===0&&e.stdout.resume()},"resume");d.on("drain",l),d.on("close",l)}o?.aborted&&h()}static{i(this,"ProcessChannel")}stdout=new Ce({highWaterMark:65536});stderr=new Ce({highWaterMark:65536});completion;ready;#e=new Map;#n=new Set;#o;#d;#h;#i;#t=Buffer.alloc(0);#l="";#p="";#I=performance.now();#f;#E=!1;#u;#s;#T;#P=!1;#a=!1;#g;#y=!1;#x=0;#v;#r=!1;#C=!1;#m=!1;#c;#_;#A=0;#w=0;#O=Promise.resolve();#S=Promise.resolve();#b=0;#k=[];#L;get pid(){return this.#x}get identity(){return this.#v}get transportLost(){return this.#r&&!this.#a&&this.#s===void 0&&this.#g==="TRANSPORT_FAILED"}get reconnectable(){return this.#r&&this.#u?.phase==="connecting"&&we(this.#u.reason)}get interpreterMissing(){return this.#r&&!this.#a&&this.#g==="DEPENDENCY_UNAVAILABLE"}async sendInitial(e,t){this.#P=!0,await this.sendBytes(e),await this.sendLine(t)}async write(e){if(this.#r||this.#C||this.#m)throw this.error("INPUT_CLOSED");if(this.#w+e.length>Wt)throw this.error("INPUT_LIMIT");let t=Buffer.from(e);this.#w+=t.length;let n=this.#O.then(async()=>{let o=[];for(let c=0;c<t.length;c+=te){if(await this.openInputWindow(),this.#m||this.#r){let d=Promise.reject(this.error("INPUT_CLOSED"));d.catch(()=>{}),o.push(d);break}this.#b++;let h=this.sendAcknowledged({kind:"input",bytes:t.subarray(c,c+te).toString("base64")}).finally(()=>{this.#b--,this.#k.shift()?.()});h.catch(()=>{}),o.push(h)}return o});this.#O=n.then(()=>{});let s=n.then(o=>Promise.allSettled(o));this.#S=Promise.all([this.#S,s]).then(()=>{});try{await Promise.all(await n)}finally{await s,this.#w-=t.length}}async end(){if(this.pty)throw new f("PTY_INPUT_NOT_CLOSABLE",this.source,"not-applied");this.#C=!0,await this.#S,await this.send({kind:"end"})}async resize(e,t){if(!this.pty)throw new f("PTY_REQUIRED",this.source,"not-applied");Ne(e,t),await this.sendAcknowledged({kind:"resize",cols:e,rows:t})}stop(){return!this.#r&&!this.#m&&(this.#m=!0,this.send({kind:"stop"}).catch(()=>{}),this.#L=setTimeout(()=>{this.#s===void 0&&(this.#s="TRANSPORT_FAILED",this.#E=!0),this.child.kill("SIGKILL")},5e3),this.child.stdout.resume(),this.stdout.resume(),this.stderr.resume()),this.completion.catch(e=>{if(this.#s==="CANCELLED"&&this.#_===0&&this.#c!==void 0)return{exitCode:this.#c};throw e})}cancel(e){this.#r||(this.#s??=e,this.stop().catch(()=>{}))}error(e){let t=["HOST_KEY_FAILED","AUTH_FAILED","DEPENDENCY_UNAVAILABLE","TARGET_OS_MISMATCH"].includes(e),n=this.#T??(!this.#P||!this.#a||t?"not-applied":"unknown");return new f(e,this.source,n,e==="TRANSPORT_FAILED"&&this.#u?{connection:this.#u}:void 0)}connected(){return this.#f!==void 0||K(this.#l)||K(this.#p)}connectionLoss(e){let t=performance.now(),n=this.#E?"stop-unconfirmed":G(e,this.#p);return n==="unexplained"&&(n=ye(this.masterDiagnostics())),{reason:n,phase:this.#y?"running":this.connected()?"starting":"connecting",afterMs:Math.round(t-this.#I),...this.#f===void 0?{}:{silentMs:Math.round(t-this.#f)}}}async openInputWindow(){for(;this.#b>=Ae&&!this.#r;)await new Promise(e=>this.#k.push(e))}async sendAcknowledged(e){let t=++this.#A,n=new Promise((s,o)=>{this.#e.set(t,{resolve:s,reject:o})});n.catch(()=>{});try{await this.send({...e,id:t}),await n}finally{this.#e.delete(t)}}async send(e){await this.sendLine(JSON.stringify(e))}sendLine(e){return this.sendBytes(Buffer.from(`${e}
6
+ `,"utf8"))}sendBytes(e){return this.#r?Promise.reject(this.error("INPUT_CLOSED")):new Promise((t,n)=>{this.child.stdin.write(e,s=>{s?n(this.error("INPUT_CLOSED")):t()})})}handshake(){let e=this.#t.indexOf(Oe),t=e<0?-1:this.#t.indexOf(10,e);if(t<0)return this.#t.length>65536&&this.cancel("INVALID_RESPONSE"),!1;let n;try{n=JSON.parse(this.#t.subarray(e+Oe.length,t).toString("utf8"))}catch{return this.cancel("INVALID_RESPONSE"),!1}return this.#t=this.#t.subarray(t+1),_e.Check(Ft,n)?n.accepted?(this.#a=!0,!0):(this.cancel("TARGET_OS_MISMATCH"),!1):(this.cancel("INVALID_RESPONSE"),!1)}parse(){if(!(!this.#a&&!this.handshake())){for(;this.#n.size===0;){let e=this.#t.indexOf(10);if(e<0){this.#t.length>65536&&this.cancel("FRAME_LIMIT");return}if(e>65536){this.cancel("FRAME_LIMIT");return}let t=this.#t.subarray(0,e);this.#t=this.#t.subarray(e+1);let n;try{n=JSON.parse(t.toString("utf8"))}catch{this.cancel("INVALID_RESPONSE");return}if(!_e.Check(Ut,n)){this.cancel("INVALID_RESPONSE");return}this.receive(n)}this.child.stdout.pause()}}receive(e){if(e.kind==="ready"){if(this.#y){this.cancel("INVALID_RESPONSE");return}this.#y=!0,this.#x=e.pid,this.#v=e.identity,this.#o()}else if(e.kind==="ack"){let t=this.#e.get(e.id);if(!t){this.cancel("INVALID_RESPONSE");return}this.#e.delete(e.id),t.resolve()}else if(e.kind==="exit")this.#c=e.exitCode;else if(e.kind==="error")this.#s=e.code,this.#T=e.effect;else{let t=Buffer.from(e.bytes,"base64");if(t.toString("base64")!==e.bytes){this.cancel("INVALID_RESPONSE");return}let n=e.kind==="stdout"?this.stdout:this.stderr;!n.destroyed&&!n.write(t)&&this.#n.add(n)}}};async function re(r,e,t,n,s){if(!Number.isFinite(s.timeoutMs)||s.timeoutMs<=0||!Number.isSafeInteger(s.maxBytes)||s.maxBytes<=0)throw new TypeError("Owned command deadlines and byte limits must be positive");s.signal?.throwIfAborted();let o=new AbortController,c=s.signal?AbortSignal.any([s.signal,o.signal]):o.signal,h=setTimeout(()=>o.abort(new f("TIMEOUT",n,s.effect)),s.timeoutMs),d,l,m;try{d=await N(r,e,t,r.workspace,{signal:c,timeoutMs:s.timeoutMs});let p=[],y=[],C=0,_=i((u,v)=>{C+=u.length,C>s.maxBytes?o.abort(new f(s.limitCode??"BYTE_LIMIT",n,s.effect)):v.push(u)},"consume");if(d.stdout.on("data",u=>_(u,p)),d.stderr.on("data",u=>_(u,y)),s.input!==void 0)for(let u=0;u<s.input.length;u+=65536)await d.write(s.input.subarray(u,u+65536));if(s.closeInput||s.input!==void 0)try{await d.end()}catch(u){if(!(u instanceof f)||u.code!=="INPUT_CLOSED")throw u}let{exitCode:w}=await d.completion;m={stdout:Buffer.concat(p),stderr:Buffer.concat(y),exitCode:w}}catch(p){let y=o.signal.aborted?o.signal.reason:p;l=y instanceof f&&(y.source!==n||y.effect==="unknown"&&s.effect==="not-applied")?new f(y.code,n,y.effect==="not-applied"?"not-applied":s.effect,{cause:y}):y}finally{clearTimeout(h)}try{await d?.stop()}catch(p){throw m===void 0?new AggregateError([l,p],"Target command and cleanup failed",{cause:p}):p}if(m===void 0)throw l;return m}i(re,"runOwnedSshCommand");import{Type as k}from"typebox";import{Value as V}from"typebox/value";var Ht=1024*1024,qt=64*1024,Me="^[a-f0-9]{64}$",zt=k.Object({size:k.Integer({minimum:0}),revision:k.String({pattern:Me}),offset:k.Integer({minimum:0}),length:k.Integer({minimum:0})}),Re=k.Object({ok:k.Literal(!1),code:k.String({pattern:"^[A-Z][A-Z0-9_]*$"})}),Vt=k.Object({ok:k.Literal(!0),data:k.Object({sha256:k.String({pattern:Me})})}),se=class{static{i(this,"ByteReader")}#e;#n=[];#o=0;constructor(e){this.#e=e[Symbol.asyncIterator]()}async exactly(e){for(;this.#o<e;)if(!await this.#d())return;let t=this.#h();return this.#i(t.subarray(e)),t.subarray(0,e)}async line(){for(;;){let e=this.#h(),t=e.indexOf(10);if(t>=0)return this.#i(e.subarray(t+1)),e.subarray(0,t).toString("utf8");if(this.#i(e),e.length>qt||!await this.#d())return}}async#d(){let e=await this.#e.next();return e.done===!0?!1:(this.#n.push(e.value),this.#o+=e.value.length,!0)}#h(){let[e]=this.#n,t=this.#n.length===1&&e!==void 0?e:Buffer.concat(this.#n);return this.#n=[],this.#o=0,t}#i(e){e.length!==0&&(this.#n.push(e),this.#o+=e.length)}};function Be(r){if(r!==void 0)try{return JSON.parse(r)}catch{return}}i(Be,"parsed");async function oe(r,e,t,n,s={}){let o=S(r.id,e,b(r)).source,c=await A(b(r),"file"),h=await N(r,H(c),[],U(r),s);h.completion.catch(()=>{}),h.stderr.resume();let d={stalled:!1},l=i(w=>{clearTimeout(d.timer),!(!w||t.idleMs===void 0)&&(d.timer=setTimeout(()=>{d.stalled=!0,h.stdout.destroy()},t.idleMs))},"watch"),m=i(()=>new f("TIMEOUT",o,"not-applied"),"timedOut"),p=i(async()=>{if(d.stalled)throw m();let w;h.stdout.destroy();try{await h.stop()}catch(u){w=u}throw w instanceof f?new f(w.code,o,"not-applied",{cause:w}):new f("INVALID_RESPONSE",o,"not-applied")},"broken"),{revision:y,offset:C,limit:_}=t;try{l(!0),await h.write(Buffer.from(JSON.stringify({operation:"stream",path:e,revision:y,offset:C,limit:_}))),await h.end();let w=new se(h.stdout),u=Be(await w.line());if(V.Check(Re,u))throw new f(u.code,o,"not-applied");if(!V.Check(zt,u)||u.offset+u.length>u.size)return await p();if(y!==void 0&&u.revision!==y)throw new f("CONFLICT",o,"not-applied");let v=0;for(;;){let P=await w.exactly(4);if(P===void 0)return await p();let O=P.readUInt32BE(0);if(O===0)break;if(O>Ht||v+O>u.length)return await p();let L=await w.exactly(O);if(L===void 0)return await p();v+=O,l(!1),await n(L),l(!0)}let T=Be(await w.line());if(V.Check(Re,T))throw new f(T.code,o,"not-applied");if(!V.Check(Vt,T)||v!==u.length)return await p();let{exitCode:M}=await h.completion;if(M!==0)throw new f("REMOTE_OPERATION_FAILED",o,"not-applied");return{size:u.size,revision:u.revision,offset:u.offset,length:u.length,sha256:T.data.sha256}}catch(w){throw d.stalled?m():w}finally{l(!1),h.stdout.destroy(),await h.stop().catch(()=>{})}}i(oe,"readSshFileStream");var f=class extends ce{static{i(this,"SshBackendError")}connection;constructor(e,t,n,s){super(e,t,n,s?.cause?{cause:s.cause}:void 0),this.name=e==="CANCELLED"?"AbortError":"SshBackendError",s?.connection&&(this.connection=s.connection,this.message=`${this.message}: ${Se(s.connection)}`)}},Jt=a.Object({bytes:a.String(),version:a.String({pattern:"^[a-f0-9]{64}$"})}),Zt=a.Object({directory:a.String(),path:a.String(),revision:a.String({pattern:"^[a-f0-9]{64}$"}),sourceRevision:a.String({pattern:"^[a-f0-9]{64}$"}),sha256:a.String({pattern:"^[a-f0-9]{64}$"})}),Kt=a.Array(a.Object({name:a.String(),kind:a.Union([a.Literal("file"),a.Literal("directory"),a.Literal("symlink"),a.Literal("other")])})),Gt=a.Object({kind:a.Union([a.Literal("file"),a.Literal("directory"),a.Literal("other")]),size:a.Integer({minimum:0}),mode:a.Integer({minimum:0})}),Y=a.Object({kind:a.Union([a.Literal("file"),a.Literal("directory"),a.Literal("symlink"),a.Literal("other")]),size:a.Integer({minimum:0}),mode:a.Integer({minimum:0}),links:a.Integer({minimum:0}),identity:a.Object({device:a.String({pattern:"^[0-9]+$"}),inode:a.String({pattern:"^[0-9]+$"})}),revision:a.String({pattern:"^[a-f0-9]{64}$"})}),Xt=a.Object({path:a.String({minLength:1}),entries:a.Array(a.Object({relativePath:a.String(),kind:Y.properties.kind,revision:Y.properties.revision,identity:Y.properties.identity,mode:a.Integer({minimum:0}),link:a.Optional(a.String())}))}),Qt=a.Union([a.Object({ok:a.Literal(!0),data:a.Unknown()}),a.Object({ok:a.Literal(!1),code:a.String({pattern:"^[A-Z][A-Z0-9_]*$"}),effect:a.Union([a.Literal("not-applied"),a.Literal("applied"),a.Literal("unknown")])})]),R=class{static{i(this,"SshBackend")}target;constructor(e){W(e);let t=S(e.id,e.workspace,b(e)).path;this.target={...e,workspace:t}}async stat(e,t={}){let n=await this.request({operation:"stat",path:e},!1,t);return this.checked(Gt,n,e,!1),n}async lstat(e,t={}){let n=await this.request({operation:"lstat",path:e},!1,t);return this.checked(Y,n,e,!1),n}async temporaryEnvironment(e={}){let t=await this.request({operation:"temporary-environment",path:this.target.workspace},!1,e);return this.checked(a.Object({home:a.String({minLength:1,pattern:"^/"}),temporary:a.String({minLength:1,pattern:"^/"}),agentDirectory:a.Optional(a.String({minLength:1,pattern:"^/"}))}),t,this.target.workspace,!1),t}async objectSnapshot(e,t={}){let n=await this.request({operation:"object-snapshot",path:e},!1,t);return this.checked(Xt,n,e,!1),n}async ensureObjectDirectory(e,t,n,s={}){let o=await this.request({operation:"mkdir-object",path:e,mode:t,revision:n},!0,s);return this.checked(a.Object({device:a.String(),inode:a.String()}),o,e,!0),o}async createObjectLink(e,t,n={}){let s=await this.request({operation:"symlink-object",path:e,link:t,revision:null},!0,n);this.checked(a.Null(),s,e,!0)}async setObjectMode(e,t,n,s={}){let o=await this.request({operation:"chmod-object",path:e,mode:t,revision:n},!0,s);this.checked(a.Null(),o,e,!0)}async moveObject(e,t,n={}){let s=await this.request({operation:"move-object",path:e.path,destination:t.path,sourceSnapshot:e,targetSnapshot:t},!0,n);return this.checked(a.Boolean(),s,e.path,!0),s}async captureJournal(e,t={}){let n=await this.request({operation:"journal",path:e},!1,t);return this.checked(Zt,n,e,!1),n}async releaseJournal(e,t={}){let n=await this.request({operation:"journal-release",path:e},!1,t);this.checked(a.Null(),n,e,!1)}async read(e,t={}){let n=await this.request({operation:"read",path:e},!1,t);return this.checked(Jt,n,e,!1),{bytes:Buffer.from(n.bytes,"base64"),version:n.version}}async readRange(e,t,n,s={}){if(!Number.isSafeInteger(t)||n!==void 0&&!(Number.isSafeInteger(n)&&n>=0))throw new TypeError("Byte offset and limit must be safe integers; limit must be nonnegative");let o=[],c=await oe(this.target,e,{offset:t,limit:n,idleMs:s.timeoutMs??3e4},async h=>{o.push(h)},s);return{bytes:Buffer.concat(o,c.length),offset:c.offset,totalBytes:c.size,revision:c.revision}}async readStream(e,t,n,s={}){let o=await oe(this.target,e,{revision:t},n,s);return{totalBytes:o.length,sha256:o.sha256}}async list(e,t={}){let n=await this.request({operation:"list",path:e},!1,t);return this.checked(Kt,n,e,!1),n}async write(e,t,n,s={}){let o=await this.request({operation:"write",path:e,bytes:Buffer.from(t).toString("base64"),expected:n},!0,s);return this.checked(a.String({pattern:"^[a-f0-9]{64}$"}),o,e,!0),o}async copy(e,t,n,s,o={}){return this.copyEntry("copy",e,t,n,s,o)}async restoreJournal(e,t,n,s,o={}){return this.copyEntry("restore",e,t,n,s,o)}async copyEntry(e,t,n,s,o,c){let h=await this.request({operation:e,path:t,destination:n,sourceRevision:s,targetRevision:o},!0,c);this.checked(a.Null(),h,t,!0)}async move(e,t,n,s,o={}){let c=await this.request({operation:"move",path:e,destination:t,sourceRevision:n,targetRevision:s},!0,o);this.checked(a.Null(),c,e,!0)}async realpath(e,t={}){let n=await this.request({operation:"realpath",path:e},!1,t);if(this.checked(a.String({minLength:1}),n,e,!1),!n.startsWith("/"))throw new f("INVALID_RESPONSE",e,"not-applied");return n}async queryGit(e,t,n={}){let s=await this.request({operation:"git-query",path:e,args:t},!1,{...n,timeoutMs:5e3});return this.checked(a.String(),s,e,!1),s}async removeObject(e,t,n={}){let s=await this.request({operation:"delete-object",path:e,revision:t},!0,n);this.checked(a.Null(),s,e,!0)}async removeEntry(e,t,n={}){let s=await this.request({operation:"unlink",path:e,revision:t},!0,n);this.checked(a.Null(),s,e,!0)}async remove(e,t,n={}){let s=await this.request({operation:"remove",path:e,expected:t},!0,n);this.checked(a.Null(),s,e,!0)}async writeGitIndex(e,t,n={}){let s=Buffer.from(t.text,"utf8");if(s.length>32*1024*1024)throw new f("CONTENT_LIMIT",S(this.target.id,e).source,"not-applied");let{text:o,expectedIndexText:c,expectedWorktreeText:h,...d}=t,l=i(p=>Yt("sha256").update(p,"utf8").digest("hex"),"digest"),m=await this.request({operation:"gitIndex",path:e,...d,bytes:s.toString("base64"),expectedIndexHash:l(c),...h!==void 0&&{expectedWorktreeHash:l(h)}},!0,n);this.checked(a.Null(),m,e,!0)}async execute(e,t,n,s={}){return re({...this.target,workspace:n},e,t,S(this.target.id,n).source,{signal:s.signal,timeoutMs:s.timeoutMs??3e4,maxBytes:32*1024*1024,limitCode:"CONTENT_LIMIT",closeInput:!0,effect:"unknown"})}async startProcess(e,t,n,s={}){return N(this.target,e,t,n,s)}checked(e,t,n,s){if(!De.Check(e,t))throw new f("INVALID_RESPONSE",S(this.target.id,n).source,s?"unknown":"not-applied")}async request(e,t,n){let s=typeof e.path=="string"?e.path:typeof e.cwd=="string"?e.cwd:this.target.workspace,o=S(this.target.id,s).source,c=n.timeoutMs??3e4;if(!Number.isFinite(c)||c<=0)throw new TypeError("SSH operation deadline must be positive");n.signal?.throwIfAborted();let h=await A(b(this.target),"file"),d=U(this.target),l=await re({...this.target,workspace:e.operation==="gitIndex"?s:d},H(h),[],o,{signal:n.signal,timeoutMs:c,maxBytes:48*1024*1024,limitCode:"CONTENT_LIMIT",effect:t?"unknown":"not-applied",input:Buffer.from(JSON.stringify(e))});if(l.exitCode!==0)throw new f("REMOTE_OPERATION_FAILED",o,t?"unknown":"not-applied");let m;try{m=JSON.parse(l.stdout.toString("utf8"))}catch{throw new f("INVALID_RESPONSE",o,t?"unknown":"not-applied")}if(!en(m))throw new f("INVALID_RESPONSE",o,t?"unknown":"not-applied");if(!m.ok)throw new f(m.code,o,m.effect);return m.data}};function en(r){return De.Check(Qt,r)}i(en,"isReply");import{readFile as tn}from"node:fs/promises";import B from"node:path";import{Type as E}from"typebox";import{Value as nn}from"typebox/value";var rn=E.Object({targets:E.Array(E.Object({id:E.String(),host:E.String(),workspace:E.String(),configFile:E.Optional(E.String({minLength:1})),os:E.Optional(E.Union([E.Literal("linux"),E.Literal("windows")]))},{additionalProperties:!1}))},{additionalProperties:!1});function wr(r){return{globalPath:B.join(B.dirname(r.globalPath),"ssh.json"),projectPath:B.join(B.dirname(r.projectPath),"ssh.json")}}i(wr,"resolveSshConfigPaths");async function Sr(r){let e=await $e(r.globalPath),t=await $e(r.projectPath),n=new Map(e.map(s=>[s.id,s]));for(let s of t)n.set(s.id,s);return[...n.values()]}i(Sr,"readSshTargets");async function $e(r){let e;try{e=await tn(r,"utf8")}catch(t){if(typeof t=="object"&&t!==null&&"code"in t&&t.code==="ENOENT")return[];throw new Error(`Cannot read SSH settings at ${r}`,{cause:t})}try{let t=JSON.parse(e);if(!nn.Check(rn,t))throw new Error("Invalid settings");return sn(t,r)}catch{throw new Error(`Invalid SSH settings at ${r}`)}}i($e,"readScope");function sn(r,e){let t=new Set;return r.targets.map(n=>{if(t.has(n.id))throw new Error("Duplicate target");t.add(n.id);let s={id:n.id,host:n.host,workspace:n.workspace,...n.os===void 0?{}:{os:n.os},...n.configFile===void 0?{}:{configFile:B.resolve(B.dirname(e),n.configFile)}};return new R(s).target})}i(sn,"validateScope");var je=class{static{i(this,"SshBackendRegistry")}#e=new Map;constructor(e){for(let t of e){if(this.#e.has(t.id))throw new TypeError(`Duplicate SSH target: ${t.id}`);this.#e.set(t.id,new R(t))}}hasTargetOs(e){return[...this.#e.values()].some(t=>b(t.target)===e)}resolve(e,t){let n=J(e,t,o=>this.#e.get(o)?.target.os);if(!n)return;let s=this.#e.get(n.target);if(!s)throw new f("UNKNOWN_TARGET",n.source,"not-applied");return{location:n,backend:s}}};export{cn as a,S as b,de as c,b as d,U as e,H as f,gn as g,N as h,re as i,f as j,wr as k,Sr as l,je as m};
@@ -0,0 +1,2 @@
1
+ import{a as s}from"./chunk-EI7MMDWY.js";import{execFile as f}from"node:child_process";import{existsSync as l}from"node:fs";import c from"node:os";import d from"node:path";function y(n=process.env.PI_CODING_AGENT_DIR??d.join(c.homedir(),".pi","agent"),e=process.platform){let t=d.join(n,"bin",e==="win32"?"rg.exe":"rg");return l(t)?t:"rg"}s(y,"resolveRipgrepExecutable");async function w(n,e,t){let r=["check-ignore","-q","."],i;try{e===void 0?i=await g("git",r,n,t):e.execute!==void 0&&(i=(await e.execute("git",r,n,t)).code)}catch{}return t?.throwIfAborted(),i===1?[]:["--no-ignore-parent"]}s(w,"parentIgnoreArguments");function g(n,e,t,r){return new Promise((i,h)=>{f(n,e,{cwd:t,windowsHide:!0,timeout:1e4,...r===void 0?{}:{signal:r}},o=>{o===null?i(0):typeof o.code=="number"?i(o.code):h(o)})})}s(g,"localExitCode");var a=64*1024,m=/^rg: (.+?): (.+\(os error \d+\))$/u,u=class{static{s(this,"RipgrepStderr")}#e="";#t="";#n="";#i=!1;#s=0;#r;#o;constructor(e=t=>t){this.#o=e}write(e){this.#t.length<a&&(this.#t+=e.slice(0,a-this.#t.length));let t=(this.#e+e).split(/\r?\n/u);this.#e=t.pop()??"";for(let r of t)this.#d(r)}get message(){return this.#a(),this.#n.trim()||this.#t.trim()}unreadable(e){if(this.#a(),!(e!==2||this.#r===void 0||this.#i))return{count:this.#s,first:this.#r}}failed(e){return e!==0&&e!==1&&this.unreadable(e)===void 0}#a(){this.#d(this.#e),this.#e=""}#d(e){if(e.length===0)return;let t=m.exec(e);if(t===null){this.#i||=/PCRE2: error matching/iu.test(e),this.#n.length<a&&(this.#n+=`${e}
2
+ `);return}this.#s+=1,this.#r??={path:this.#o(t[1]??""),error:t[2]??""}}};function E(n,e){return n===void 0||e===void 0?n??e:{count:n.count+e.count,first:n.first}}s(E,"mergeUnreadablePaths");export{y as a,w as b,u as c,E as d};
@@ -0,0 +1,6 @@
1
+ import{A as E,B as h,D as P,H as C,M as A,ka as k,v as w}from"./chunk-OEEE5BLN.js";import{C as B,m as D,o as I}from"./chunk-IRLWXPL4.js";import{a as l}from"./chunk-EI7MMDWY.js";import{Type as s}from"typebox";import{Value as S}from"typebox/value";import{Type as R}from"typebox";var F="File or resource address, or an unchanged result or its id.",U=`${F} An array reads each source separately, in order.`,_=R.Object({path:R.Optional(R.Union(k.anyOf,{description:F})),offset:R.Optional(R.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:R.Optional(R.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:R.Optional(R.Array(R.String(),{description:`Optional source-specific presentations. Combine views when both presentations are needed, for example ["anchors", "ast"]. Omit for the source's default presentation.`}))});function v(e){let{path:t,...o}=e;return t===void 0?o:{...o,path:typeof t=="string"?t:t.id}}l(v,"readRequestOf");var b=R.Object({..._.properties,path:R.Optional(R.Union([...k.anyOf,R.Array(k,{minItems:1})],{description:U}))});function Ee(e){let{path:t,...o}=e;return Array.isArray(t)?t.map(n=>v({...o,path:n})):[v(t===void 0?o:{...o,path:t})]}l(Ee,"readRequestsOf");var Q={path:U,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 Ce(e){let t=l((o,n)=>({...o,description:[Q[n],n==="path"?void 0:e[n]].filter(a=>a!==void 0).join(`
2
+ `)}),"describe");return{...b,properties:{path:t(b.properties.path,"path"),offset:t(b.properties.offset,"offset"),limit:t(b.properties.limit,"limit"),views:t(b.properties.views,"views")}}}l(Ce,"describeReadParameters");import{readFile as Y}from"node:fs/promises";function X(e,t,o=(a,i)=>["filesystem","ssh"].includes(i),n){return async a=>{let i=a.state;if(i?.contentKind!=="text"||!o(i.source,i.resolvedBy)||a.sourceText!==i.text.content)return{kind:"continue",context:a};if(i.resolvedBy==="filesystem")try{if(await Y(i.source,{encoding:"utf8",signal:a.resolverContext.signal})!==i.text.content)return{kind:"continue",context:a}}catch{return a.resolverContext.signal?.throwIfAborted(),{kind:"continue",context:a}}let d=a.sourceTarget===void 0?void 0:e.resolve(a.sourceTarget,a.resolverContext.cwd),c=d?.targets.filter(u=>u.source===i.source);return c?.some(u=>u.expectedContent!==i.text.content)?{kind:"continue",context:a}:{kind:"continue",context:a,transform(u){let y=u.script;if(u.isError||y?.kind!=="text"||y.source!==i.source||!y.lines.every(x=>{let O=i.text.lines[x.lineNumber-1];return O?.content===x.content&&O.lineEnding===x.lineEnding}))return u;let m=y.lines[0],f=y.lines.at(-1),p=m===void 0||f===void 0?i.text.content.length===0?{start:{lineNumber:1,column:0},end:{lineNumber:1,column:0}}:void 0:{start:{lineNumber:m.lineNumber,column:0},end:f.lineEnding.length>0?{lineNumber:f.lineNumber+1,column:0}:{lineNumber:f.lineNumber,column:f.content.length},linewise:!0},L=e.register(p===void 0?[]:[{source:i.source,expectedContent:i.text.content,ranges:c===void 0?[p]:c.flatMap(x=>x.ranges.flatMap(O=>ee(O,p))),readCurrent:Z(t,i.source,a.resolverContext.cwd)}],a.resolverContext.cwd,d?.complete??!0,void 0,n);return{...u,script:{...y,target:L,...(i.resolvedBy==="filesystem"||i.resolvedBy==="ssh")&&i.entries===void 0&&{fileDigest:w(i.text.content)}}}}}}}l(X,"createReadResultTargetHandler");function Z(e,t,o){return async n=>{let a=await e({path:t},{cwd:o,...n===void 0?{}:{signal:n}},"script");if(a.isError||a.script?.kind!=="text"||a.script.source!==t)throw new Error("Could not verify the owning source; repeat Read/Search.");return a.script.content}}l(Z,"ownedReader");function ee(e,t){let o=l((i,d)=>i.lineNumber-d.lineNumber||i.column-d.column,"compare"),n=o(e.start,t.start)>=0?e.start:t.start,a=o(e.end,t.end)<=0?e.end:t.end;return o(n,a)>0||o(n,a)===0&&o(e.start,e.end)!==0?[]:[{start:n,end:a}]}l(ee,"intersectRange");import{Type as r}from"typebox";function Ie(e,t,o,n){if(!se(e))return{content:e,source:t,resolvedBy:o,preserveTruncatedOutput:n.preserveTruncatedOutput,textMode:n.textMode,contentKind:"other"};let a=e[0].text;return{content:e,source:t,resolvedBy:o,...n.entries===void 0?{}:{entries:[...n.entries]},preserveTruncatedOutput:n.preserveTruncatedOutput,textMode:n.textMode,contentKind:"text",text:D(t,a)}}l(Ie,"createReadState");function Be(e,t,o){if(e.contentKind!=="text"){if(t.offset!==void 0||t.limit!==void 0)return re({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 p=oe(e.content);return{script:{kind:"native",source:e.source,blocks:e.content},content:p.content,details:{...j(e),...p.unsupportedContentBlocks!==void 0&&{unsupportedContentBlocks:p.unsupportedContentBlocks}}}}let n=e.text.lines.length,a=ae(t,n,o?.originLine),i=e.text.lines.slice(a.startIndex,a.endIndex),d=a.endIndex<n,c=e.textMode==="final"||i.every(p=>p.presentation===void 0),u=c?te(i,d):I({...e.text,lines:i.map((p,L)=>({...p,lineEnding:L===i.length-1&&d?"":p.lineEnding}))}),y=e.textMode==="normal"&&(e.resolvedBy==="filesystem"||e.resolvedBy==="ssh")&&e.entries===void 0&&!d&&i.at(-1)?.lineEnding==="",m=e.content[0],f=[{type:"text",text:y?`${u}
3
+ ${B}`:u,...m.textSignature!==void 0&&{textSignature:m.textSignature}}];return{script:{kind:"text",...e.text.references===void 0?{}:{references:e.text.references},source:e.source,content:c&&!d?u:i.map(p=>p.content+p.lineEnding).join(""),...c?{}:{presented:u},...e.entries===void 0?{}:{entries:e.entries},lines:i,startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:n},content:f,details:{...j(e),startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:n,lines:i,...y&&{noFinalLineBreak:y}}}}l(Be,"projectReadState");function te(e,t){return e.map((o,n)=>`${o.content}${n===e.length-1&&t?"":o.lineEnding}`).join("")}l(te,"renderFinalTextLines");function M(e){let t=e.cause,o,n=new Set;for(;t instanceof Error&&!n.has(t);)n.add(t),o=t,t=t.cause;return o}l(M,"deepestCause");var q="Supply path with a source or an unchanged result reference.";function H(e){let t=e.retry??(e.code==="FRAGMENT_FAILED"&&e.source!==void 0?{path:e.source,views:["anchors"]}:void 0);return t===void 0?void 0:`Run read(${JSON.stringify(t)}).`}l(H,"readRetry");function V(e){return e.candidates?.length?["Possible matches:",...e.candidates.map(t=>`- ${JSON.stringify(t.path)}`),"","Retry read with an exact candidate path."]:[]}l(V,"candidateLines");function $(e){let t=M(e),o=t!==void 0&&"code"in t?t.code:void 0,n=[];o==="ENOENT"&&!e.candidates?.length&&n.push("Search for the correct path.");let a=H(e);return e.code==="INVALID_REQUEST"?n.push(q):a!==void 0?n.push(a):e.code==="NO_RESOLVER"?n.push("Choose a supported source from the path parameter."):e.code==="NO_FRAGMENT_RESOLVER"&&n.push("Read the source without the anchor."),[...n,...V(e)]}l($,"readFailureRecovery");function ne(e){let t=M(e),o=t!==void 0&&"code"in t?t.code:void 0,n=t?.message||e.message;o==="ENOENT"?n=e.candidates?.length?"Source not found.":"Source not found. Search for the correct path.":o==="EACCES"||o==="EPERM"?n="Access denied.":e.code==="INVALID_RESOLVER_RESULT"?n="The source provider returned an invalid result.":e.code==="INVALID_RESOURCE_CONTENT"?n="The source provider returned invalid content.":e.code==="UNSUPPORTED_CAPABILITY"?n="This source does not support reading.":e.code==="NO_RESOLVER"?n="This source is not supported. Choose a supported source from the path parameter.":e.code==="NO_FRAGMENT_RESOLVER"&&(n="This anchor is not supported. Read the source without the anchor.");let a=H(e);return e.code==="INVALID_REQUEST"?n+=`. ${q}`:a!==void 0&&(n+=`
4
+ ${a}`),`Read failed${e.source===void 0?"":` for ${JSON.stringify(e.source)}`}: ${n}`}l(ne,"readFailureMessage");function Fe(e,t,o){if(!o?.aborted||!e.isError)return e;let n=e.details.source??e.details.failure?.source??t;return{...e,content:[{type:"text",text:`Read cancelled${n===void 0?"":` for ${JSON.stringify(n)}`}. No completed result was returned.`}]}}l(Fe,"withReadCancellation");function re(e){let t=e.cause instanceof h?e.cause:void 0;return t!==void 0?e={...e,source:e.source??t.source,message:`${t.code}: ${e.source??t.source}`,cause:new h(t.code,t.source,t.effect,{metadata:E(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:[ne(e),...e.candidates?.length?["",...V(e)]:[]].join(`
5
+ `)}],details:{failure:e},isError:!0}}l(re,"failureResult");function j(e){return{source:e.source,resolvedBy:e.resolvedBy}}l(j,"readDetails");function oe(e){let t=[],o=[];for(let[a,i]of e.entries()){if(i.type!=="custom"){t.push(i);continue}o.push({index:a,kind:i.kind}),t.push({type:"text",text:`[unsupported_content_block kind=${i.kind} index=${a}]`})}let n=o[0];return{content:t,...n!==void 0&&{unsupportedContentBlocks:[n,...o.slice(1)]}}}l(oe,"projectAgentContent");function ae(e,t,o){let n=e.offset===void 0?1:Math.trunc(e.offset),a=ie(n,t,o),i=e.limit===void 0?t:Math.max(0,Math.trunc(e.limit));return{startIndex:Math.min(t,a-1),endIndex:Math.min(t,a-1+i)}}l(ae,"resolveTextRange");function ie(e,t,o){if(o===void 0)return e<0?Math.max(1,t+e+1):Math.max(1,e);let n=e<0?o+e:o+Math.max(1,e)-1;return Math.max(1,n)}l(ie,"anchoredStartLine");function se(e){return e.length===1&&e[0].type==="text"}l(se,"isSingleTextContent");var de=r.Object({value:r.String(),kind:r.String(),state:r.Optional(r.String())},{additionalProperties:!1}),le=r.Object({lineNumber:r.Integer(),content:r.String(),lineEnding:r.String(),anchors:r.Optional(r.Array(r.String()))},{additionalProperties:!1}),ce=r.Object({path:r.String(),offset:r.Integer()},{additionalProperties:!1}),N={source:r.String(),truncated:r.Boolean(),continuation:r.Optional(ce),fullResult:r.Optional(r.String())},G=r.Object({...N,kind:r.Literal("text"),target:r.Optional(r.String()),text:r.Optional(r.String()),entries:r.Optional(r.Array(r.String())),lines:r.Array(le),startLine:r.Integer(),endLine:r.Integer(),totalLines:r.Integer(),references:r.Optional(r.Array(de))},{additionalProperties:!1}),K=r.Object({...N,kind:r.Literal("bytes"),bytes:r.Array(r.Integer({minimum:0,maximum:255})),byteOffset:r.Integer(),byteLength:r.Integer(),totalBytes:r.Integer()},{additionalProperties:!1}),ue=r.Union([r.Object({type:r.Literal("text"),text:r.String()},{additionalProperties:!1}),r.Object({type:r.Literal("image"),mimeType:r.String()},{additionalProperties:!1})]),J=r.Object({...N,kind:r.Literal("native"),blocks:r.Array(ue)},{additionalProperties:!1}),W=r.Union([r.Object({kind:r.Literal("recovery"),source:r.String(),candidates:r.Array(r.Object({path:r.String()},{additionalProperties:!1}))},{additionalProperties:!1}),G,K,J,r.Object({kind:r.Literal("resources"),source:r.Optional(r.String()),resources:r.Array(r.Union([G,K,J])),truncated:r.Boolean(),fullResult:r.Optional(r.String())},{additionalProperties:!1})]),T=r.Union([...W.anyOf,r.Object({kind:r.Literal("list"),items:r.Array(P(W))},{additionalProperties:!1})]),pe=P(T);function Re(e){return{lineNumber:e.lineNumber,content:e.content,lineEnding:e.lineEnding,...e.anchors===void 0?{}:{anchors:[...e.anchors]}}}l(Re,"publicLine");function z(e,t){if(e.kind==="resources"){let d=e.resources.map(c=>z(c,t));return{kind:e.kind,...e.source===void 0?{}:{source:e.source},resources:d,truncated:d.some(c=>typeof c=="object"&&c!==null&&"truncated"in c&&c.truncated===!0)}}if(e.kind==="bytes"){let d=t?[...e.bytes]:e.bytes.slice(0,32768),c=e.truncated===!0||d.length<e.bytes.length;return{kind:e.kind,source:e.source,bytes:d,byteOffset:e.byteOffset,byteLength:d.length,totalBytes:e.totalBytes,truncated:c,...e.byteOffset+d.length<e.totalBytes?{continuation:{path:e.source,offset:e.byteOffset+d.length}}:{}}}if(e.kind==="native")return{kind:e.kind,source:e.source,truncated:!1,blocks:e.blocks.map(d=>{if(d.type==="text")return{type:d.type,text:d.text};if(d.type==="image")return{type:d.type,mimeType:d.mimeType};throw new TypeError("Custom content requires a structured adapter")})};let o=[],n=0;for(let d of e.lines){let c=Re(d);if(!t&&(n+=Buffer.byteLength(JSON.stringify(c)),o.length>=2e3||n>512*1024))break;o.push(c)}if(o.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 a=o.length<e.lines.length,i=o.at(-1)?.lineNumber??e.startLine-1;return{kind:e.kind,source:e.source,...e.target===void 0?{}:{target:e.target},...t&&{text:e.presented??e.content},...t&&e.entries!==void 0&&{entries:[...e.entries]},lines:o,startLine:o[0]?.lineNumber??0,endLine:o.at(-1)?.lineNumber??0,totalLines:e.totalLines,truncated:a,...e.target===void 0?{}:{target:e.target},...e.references===void 0?{}:{references:e.references},...a||i<e.totalLines?{continuation:{path:e.source,offset:i+1}}:{}}}l(z,"publicData");function ye(e,t={}){let o=t.complete===!0,n=e.details.failure,a=n?.cause instanceof h?n.cause:void 0,i=a===void 0?void 0:E(a);if(e.isError||n!==void 0)return C(e,T,{status:"error",...n?.candidates?.length&&n.source!==void 0?{data:{kind:"recovery",source:n.source,candidates:n.candidates}}:{},errors:[{code:a?.code??n?.code??"READ_FAILED",message:a===void 0?[n?.message??"Read failed",...n===void 0?[]:$(n)].join(`
6
+ `):`${a.code}: ${n?.source??a.source}`,...n?.source===void 0?{}:{source:n.source},...i===void 0?{}:{metadata:i}}]});try{if(e.script===void 0)throw new TypeError("Read handler must return structured script data");let d=z(e.script,o);return C(e,T,{status:"success",data:e.details.temporarySource!==void 0&&typeof d=="object"&&d!==null?{...d,fullResult:e.details.temporarySource}:d,errors:[]},o?{maxBytes:1/0}:{})}catch(d){return C(e,T,{status:"error",errors:[{code:d instanceof RangeError?"STRUCTURED_RESULT_TOO_LARGE":"STRUCTURED_ADAPTER_REQUIRED",message:d instanceof Error?d.message:String(d)}]})}}l(ye,"structuredRead");var g=s.Function([],s.Unknown()),ge=s.Object({resolver:s.Unknown(),matchesCall:s.Optional(g),renderCall:s.Optional(g),priority:s.Optional(s.Number()),renderResult:s.Optional(g),preserveTruncatedOutput:s.Optional(s.Boolean())}),fe=s.Object({resolver:s.Unknown(),priority:s.Optional(s.Number())}),me=s.Object({id:s.String({pattern:"\\S"}),priority:s.Optional(s.Number()),resolve:g}),xe=s.Object({view:s.String({pattern:"\\S"}),contentKind:s.Optional(s.Union([s.Literal("text"),s.Literal("any")])),includes:s.Optional(s.Array(s.String({pattern:"\\S"}))),showsLinesOutsideRange:s.Optional(s.Boolean()),presenter:s.Object({id:s.String(),present:g}),priority:s.Optional(s.Number())}),he=s.Object({resolvedBy:s.String({pattern:"\\S"}),contentKind:s.Union([s.Literal("text"),s.Literal("any")])}),be=s.Union([s.Object({stage:s.Literal("pre-read"),handler:g}),s.Object({stage:s.Literal("read"),when:he,handler:g}),s.Object({stage:s.Literal("post-read"),handler:g})]);function Je(e){if(!S.Check(fe,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")}l(Je,"isTextTargetResolverRegistration");function We(e){if(!S.Check(ge,e))return!1;let t=e;return A(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}l(We,"isResourceResolverRegistration");function ze(e){return S.Check(be,e)}l(ze,"isReadHandlerRegistration");function Qe(e){return S.Check(xe,e)}l(Qe,"isReadViewRegistration");function Ye(e){return S.Check(me,e)}l(Ye,"isFragmentResolverRegistration");function Xe(e){return Te(e)?e.kind==="not-handled"?!0:e.kind==="failed"?typeof e.message=="string"&&e.message.length>0&&(e.retryPath===void 0||typeof e.retryPath=="string"&&e.retryPath.length>0):e.kind==="resolved"&&typeof e.originLine=="number":!1}l(Xe,"isReadFragmentResolution");function Te(e){return typeof e=="object"&&e!==null}l(Te,"isRecord");export{X as a,ee as b,Ie as c,Be as d,Fe as e,re as f,ae as g,ie as h,_ as i,v as j,Ee as k,Ce as l,T as m,pe as n,ye as o,Je as p,We as q,ze as r,Qe as s,Ye as t,Xe as u};
@@ -0,0 +1 @@
1
+ import{v as b,w as x}from"./chunk-4AEYLVSR.js";import{a as h}from"./chunk-EI7MMDWY.js";import R from"node:path";import{pathToFileURL as M}from"node:url";function q(e,t="this path"){return e<=1e3?`Search ${t} with limit: ${String(e)}`:`Read a bounded window of ${t}, then Search that result`}h(q,"searchCompactionHint");function z(e,t){let r=new Map;for(let n of e){let s=r.get(n.source)??[];s.push(n),r.set(n.source,s)}let a=new Set,c=e.length,i=[...r].sort(([n,s],[m,d])=>d.length-s.length||n.localeCompare(m));for(let[n,s]of i){if(c<=t)break;a.add(n),c-=s.length-1}let u=[],o=t,l=[...r].sort(([n],[s])=>Number(a.has(n))-Number(a.has(s))||n.localeCompare(s));for(let[n,s]of l){if(!a.has(n)){if(s.length>o)continue;u.push({kind:"detailed",source:n,matches:s}),o-=s.length;continue}if(o<1)continue;o--;let m=new Map;for(let y of s){let p=m.get(y.lineText);p===void 0?m.set(y.lineText,{matchCount:1,first:y}):p.matchCount++}let d=[...m].sort(([y,p],[N,P])=>P.matchCount-p.matchCount||y.localeCompare(N)).map(([y,p])=>({text:y,...p})),C=r.size===1?Math.min(o,d.length-1):0,w=d.slice(0,1+C);o-=C,u.push({kind:"compacted",source:n,matchCount:s.length,uniqueLineCount:m.size,groups:w})}return u.sort((n,s)=>n.source.localeCompare(s.source)),{files:u}}h(z,"planSearchPresentation");function T(e,t,r,a,c,i=50){let u=z(t,i),o=new Set(t.map(n=>n.source)).size,l=u.files.map(n=>n.kind==="detailed"?k(n.source,n.matches,a):{path:S(n.source,a),link:M(n.source).href,matchCount:n.matchCount,uniqueLineCount:n.uniqueLineCount,groups:n.groups.map(({text:s,matchCount:m})=>({text:s,matchCount:m})),lines:[]});return{...c!==void 0&&{sessionId:c},query:e,matchCount:t.length,fileCount:o,...u.files.length<o?{omittedFileCount:o-l.length,omittedMatchCount:t.length-l.reduce((n,s)=>n+s.matchCount,0)}:{},complete:r,files:l}}h(T,"createSearchToolDetails");function H(e,t){return{fileCount:new Set(e.flatMap(r=>r.matches.map(a=>a.source))).size,groups:e.map(r=>{let c=T(r.identifier,r.matches.slice(0,b.previewMatches),r.complete,t).files.map(i=>{let u=i.lines.map(o=>{let l=Math.max(0,(o.ranges[0]?.from??0)-64),n=Math.min(o.text.length,(o.ranges[0]?.to??0)+64),s=l>0?"\u2026":"",m=o.ranges.filter(d=>d.from>=l&&d.to<=n).map(d=>({from:d.from-l+s.length,to:d.to-l+s.length}));return{...o,text:s+o.text.slice(l,n)+(n<o.text.length?"\u2026":""),ranges:m,matchCount:m.length}});return{...i,lines:u,matchCount:u.reduce((o,l)=>o+l.matchCount,0)}});return{identifier:r.identifier,files:c}})}}h(H,"createFuzzyPresentation");function L(e){return g(e)&&f(e.fileCount)&&Array.isArray(e.groups)&&e.groups.every(t=>g(t)&&typeof t.identifier=="string"&&Array.isArray(t.files)&&t.files.every(F))}h(L,"isFuzzyPresentation");function W(e){if(!g(e)||typeof e.query!="string"||!f(e.matchCount)||!f(e.fileCount)||e.omittedFileCount!==void 0&&!f(e.omittedFileCount)||e.omittedMatchCount!==void 0&&!f(e.omittedMatchCount)||typeof e.complete!="boolean"||e.sessionId!==void 0&&typeof e.sessionId!="string"||e.fuzzy!==void 0&&!x(e.fuzzy)||e.fuzzyPresentation!==void 0&&!L(e.fuzzyPresentation)||!Array.isArray(e.files)||!e.files.every(F))return!1;let t=e.files;return e.fileCount===t.length+(e.omittedFileCount??0)&&e.matchCount===t.reduce((r,a)=>r+a.matchCount,0)+(e.omittedMatchCount??0)}h(W,"isSearchToolDetails");function k(e,t,r){let a=new Map;for(let i of t){let u=a.get(i.lineNumber);if(u!==void 0&&u.text!==i.lineText)throw new Error(`Search results disagree about line ${String(i.lineNumber)} in ${e}.`);let o=u??{lineNumber:i.lineNumber,text:i.lineText,ranges:[]};o.ranges.push({from:i.startColumn,to:i.endLineNumber===void 0?i.endColumn:i.lineText.length}),a.set(i.lineNumber,o)}let c=[...a.values()].sort((i,u)=>i.lineNumber-u.lineNumber).map(i=>{let u=[...i.ranges].sort((o,l)=>o.from-l.from||o.to-l.to);return{lineNumber:i.lineNumber,text:i.text,matchCount:u.length,ranges:u}});return{path:S(e,r),link:M(e).href,matchCount:t.length,lines:c}}h(k,"createSearchResultFile");function F(e){if(!g(e)||typeof e.path!="string"||typeof e.link!="string"||!f(e.matchCount)||!Array.isArray(e.lines)||!e.lines.every(A))return!1;let t=e.lines,r=e.groups,a=new Set(t.flatMap(c=>c.logicalMatchIds??[]));return(r===void 0||Array.isArray(r)&&r.every(c=>g(c)&&typeof c.text=="string"&&f(c.matchCount)))&&(e.uniqueLineCount===void 0||f(e.uniqueLineCount))&&(t.length===0||(a.size>0?a.size===e.matchCount:e.matchCount===t.reduce((c,i)=>c+i.matchCount,0)))}h(F,"isSearchResultFile");function A(e){return g(e)&&Number.isSafeInteger(e.lineNumber)&&e.lineNumber>=1&&typeof e.text=="string"&&f(e.matchCount)&&Array.isArray(e.ranges)&&e.ranges.length===e.matchCount&&(e.logicalMatchIds===void 0||Array.isArray(e.logicalMatchIds)&&e.logicalMatchIds.every(t=>typeof t=="string"))&&e.ranges.every(t=>I(t,e.text))}h(A,"isSearchResultLine");function I(e,t){return g(e)&&Number.isSafeInteger(e.from)&&Number.isSafeInteger(e.to)&&e.from>=0&&e.to>e.from&&e.to<=t.length}h(I,"isSearchResultRange");function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}h(g,"isRecord");function f(e){return Number.isSafeInteger(e)&&e>=0}h(f,"isCount");function S(e,t){if(e.includes("://"))return e;let r=R.relative(t,e);return r.length>0&&!r.startsWith("..")&&!R.isAbsolute(r)?r:e}h(S,"displaySource");function J(e,t){let r=e.count===1?"1 path":`${e.count} paths`,{path:a,error:c}=e.first;return`Search notice: could not read ${r}, so matches in them are missing. First: ${S(a,t)}: ${c}`}h(J,"unreadableNotice");export{q as a,z as b,T as c,H as d,W as e,S as f,J as g};
@@ -0,0 +1,4 @@
1
+ import{a as U}from"./chunk-MMQIHUU5.js";import{a as A}from"./chunk-54EFJYUB.js";import{a as k,b as x}from"./chunk-VPBGKSFI.js";import{b as C}from"./chunk-V2LLMBTA.js";import{b,d as v,f as S,j as m,k as O,l as R,m as T}from"./chunk-S4GTWS2J.js";import{a as h,b as N,c as I,e as F}from"./chunk-SZRC24OB.js";import{c as P}from"./chunk-XHFAV2NI.js";import"./chunk-PBMHSK6J.js";import{c as y,l as u,m as E}from"./chunk-OA26FH5G.js";import"./chunk-BXGMMZT3.js";import"./chunk-2YO6RVX4.js";import"./chunk-MLFJU2US.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import"./chunk-2EY3LEZ7.js";import"./chunk-ZC65Z3CK.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import{a as l}from"./chunk-EI7MMDWY.js";import f from"node:path";import{realpath as D}from"node:fs/promises";function _(s){let p=k(s),g=A(s),w=new Map;return{async resolveProject(n,e){if(n.startsWith("ssh://")||e.startsWith("ssh://")){let i=s.resolve(n,e);if(!i)throw new m("UNSUPPORTED_SOURCE",n,"not-applied");let o=s.resolve(e);if(o&&o.location.target!==i.location.target)throw new m("UNSUPPORTED_SOURCE",n,"not-applied");return U(i.backend,i.location.path,o?.location.path,"formatters",h)}if(n.includes("://")||e.includes("://"))throw new m("UNSUPPORTED_SOURCE",n,"not-applied");let t=await y(e,n,"formatters",h);return t===void 0?void 0:{cwd:t,external:t!==f.resolve(e)}},async loadRegistry(n,e){let t=JSON.stringify([n,e]),i=w.get(t);if(!i){let o=s.resolve(n);i=N.fromDirectory(n,{includeGlobal:!e,requireBuiltInEvidence:!0,...o?{layerAccess:p,executableAvailability:l(r=>C(o.backend,o.location.path,r),"executableAvailability"),recipeEvidence:l(r=>x(o.backend,o.location.path,r),"recipeEvidence")}:{}}),w.set(t,i)}return i},async rustfmtAccess(n,e){let t=s.resolve(e);if(!t)return{file:f.join(await D(f.dirname(e)),f.basename(e)),access:I(n,e)};let i=v(t.backend.target),o=await t.backend.execute(S(`import json,os
2
+ home=os.path.expanduser('~')
3
+ config=os.environ.get('APPDATA') if os.name == 'nt' else (os.environ.get('XDG_CONFIG_HOME') or os.path.join(home,'.config'))
4
+ print(json.dumps([home,os.path.join(config,'rustfmt') if config else '']))`),[],f.posix.dirname(t.location.path));if(o.exitCode!==0)throw new m("CONFIG_ENVIRONMENT_FAILED",e,"not-applied");let r=JSON.parse(o.stdout.toString("utf8"));if(!Array.isArray(r)||!r.every(a=>typeof a=="string"))throw new TypeError("Invalid rustfmt configuration environment");return{file:f.posix.join(await t.backend.realpath(f.posix.dirname(t.location.path)),f.posix.basename(t.location.path)),access:{paths:f.posix,userConfigDirectories:r.filter(Boolean).map(a=>b(t.location.target,a,i).path),async readText(a){try{return(await t.backend.read(a)).bytes.toString("utf8")}catch(c){if(c instanceof m&&["ENOENT","ENOTDIR","EISDIR"].includes(c.code))return;throw c}},run:l((a,c)=>u(a,{projectRoot:n,filePath:e,processAccess:g,input:c}),"run")}}},async run(n,e,t,i){let o=s.resolve(t);if(!o){if(t.includes("://")||e.includes("://"))throw new m("UNSUPPORTED_SOURCE",t,"not-applied");return E(n,{projectRoot:e,filePath:t,stdin:i})}let r=await o.backend.read(o.location.path),a=await u(n.run,{projectRoot:e,filePath:t,processAccess:g,input:i?r.bytes.toString("utf8"):void 0}),c=await o.backend.read(o.location.path);if(!a.ok)return{ok:!1,changed:!c.bytes.equals(r.bytes)};if(n.output==="stdout"){if(c.version!==r.version)throw new m("CONFLICT",t,"not-applied");let d=Buffer.from(a.stdout);return d.equals(r.bytes)||await o.backend.write(o.location.path,d,r.version),{ok:!0,changed:!d.equals(r.bytes)}}return{ok:!0,changed:!c.bytes.equals(r.bytes)}}}}l(_,"createOwnedFormatterRuntime");async function j(s){let p=new T(await R(O(P())));await F(s,_(p))}l(j,"registerOwnedFormatter");export{_ as createOwnedFormatterRuntime,j as default};
@@ -0,0 +1 @@
1
+ import{a as b,c as $,d as z}from"./chunk-PBMHSK6J.js";import{b as P,c as T,g as I,i as A,k as O,l as S,m as h,n as D}from"./chunk-OA26FH5G.js";import{a as v}from"./chunk-2YO6RVX4.js";import{b as R,c as k}from"./chunk-MLFJU2US.js";import{a as F}from"./chunk-ZAWRSA7N.js";import{a as E,b as x}from"./chunk-OFILFO6D.js";import{a as c}from"./chunk-EI7MMDWY.js";var W=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".html",".md",".yaml",".yml",".vue",".svelte"],U=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".less",".html",".htm",".md",".markdown",".mdx",".yaml",".yml",".toml"],u=[a("dart-format",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],[".dart"],["dart","format","{file}"],"https://dart.dev/tools/dart-format"),a("zig-format",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","fmt","{file}"],"https://ziglang.org/documentation/master/"),a("styler",["r"],["Rscript"],[".Rprofile","DESCRIPTION"],[".r"],["Rscript","-e","styler::style_file(commandArgs(TRUE)[1])","{file}"],"https://styler.r-lib.org/"),a("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"),a("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"],W,["prettier","--write","{file}"],"https://prettier.io/docs/",["prettier"],{"package.json":["prettier"]}),a("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"]),a("oxfmt",["javascript","typescript","json","css","html","markdown","yaml","toml"],["oxfmt"],[".oxfmtrc.json",".oxfmtrc.jsonc","oxfmt.config.ts","oxfmt.config.mts"],U,["oxfmt","--write","{file}"],"https://oxc.rs/docs/guide/usage/formatter.html",["oxfmt"]),a("ruff-format",["python"],["ruff"],["ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","format","{file}"],"https://docs.astral.sh/ruff/formatter/",["ruff"],{"pyproject.toml":["tool.ruff"]}),a("black",["python"],["black"],[],[".py",".pyi"],["black","--quiet","{file}"],"https://black.readthedocs.io/",["black"],{"pyproject.toml":["tool.black"]}),a("gofmt",["go"],["gofmt"],["go.mod"],[".go"],["gofmt","-w","{file}"],"https://pkg.go.dev/cmd/gofmt"),a("goimports",["go"],["goimports"],["go.mod"],[".go"],["goimports","-w","{file}"],"https://pkg.go.dev/golang.org/x/tools/cmd/goimports"),a("rustfmt",["rust"],["rustfmt"],["rustfmt.toml",".rustfmt.toml","Cargo.toml"],[".rs"],["rustfmt","{file}"],"https://github.com/rust-lang/rustfmt"),a("csharpier",["csharp"],["csharpier"],[".csharpierrc",".csharpierrc.json",".csharpierrc.yaml",".csharpierrc.yml"],[".cs"],["csharpier","format","{file}"],"https://csharpier.com/"),a("google-java-format",["java"],["google-java-format"],["pom.xml","build.gradle"],[".java"],["google-java-format","--replace","{file}"],"https://github.com/google/google-java-format"),a("ktlint-format",["kotlin"],["ktlint"],[".editorconfig","build.gradle.kts"],[".kt",".kts"],["ktlint","-F","{file}"],"https://pinterest.github.io/ktlint/"),a("rubocop-format",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--fix-layout","{file}"],"https://docs.rubocop.org/"),a("pint",["php"],["pint"],["pint.json","composer.json"],[".php"],["pint","{file}"],"https://laravel.com/docs/pint"),a("swift-format",["swift"],["swift-format"],[".swift-format","Package.swift"],[".swift"],["swift-format","format","--in-place","{file}"],"https://github.com/swiftlang/swift-format"),a("stylua",["lua"],["stylua"],["stylua.toml",".stylua.toml"],[".lua"],["stylua","{file}"],"https://github.com/JohnnyMorganz/StyLua"),a("shfmt",["shell"],["shfmt"],[".editorconfig"],[".sh",".bash",".zsh"],["shfmt","-w","{file}"],"https://github.com/mvdan/sh"),a("taplo",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","format","{file}"],"https://taplo.tamasfe.dev/"),a("sqlfluff-format",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","format","{file}"],"https://docs.sqlfluff.com/"),a("terraform-fmt",["terraform"],["terraform"],[".terraform.lock.hcl"],[".tf",".tfvars"],["terraform","fmt","{file}"],"https://developer.hashicorp.com/terraform/cli/commands/fmt"),a("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"]),a("xmlformat",["xml"],["xmlformat"],[".xmlformat.conf"],[".xml",".xsd",".xsl"],["xmlformat","--overwrite","{file}"],"https://github.com/pamoller/xmlformatter"),a("mix-format",["elixir"],["mix"],["mix.exs",".formatter.exs"],[".ex",".exs"],["mix","format","{file}"],"https://hexdocs.pm/mix/Mix.Tasks.Format.html"),a("scalafmt",["scala"],["scalafmt"],[".scalafmt.conf"],[".scala",".sc",".sbt"],["scalafmt","{file}"],"https://scalameta.org/scalafmt/"),a("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"),a("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"),a("dockfmt",["dockerfile"],["dockfmt"],["Dockerfile","Containerfile"],[".dockerfile"],["dockfmt","fmt","--write","{file}"],"https://github.com/jessfraz/dockfmt",void 0,void 0,["Dockerfile","Containerfile"])];function a(r,t,o,i,e,n,f,m,s,p){return{id:r,name:r,kind:"formatter",languages:t,executables:o,configFiles:i,documentation:f,...m&&{dependencies:m},...s&&{configSections:s},formatter:{extensions:e,...p&&{fileNames:p},run:{command:n},output:"in-place"}}}c(a,"recipe");var d=class r{constructor(t,o,i=new Map){this.formatters=t;this.availableBuiltIns=o;this.evidence=i}static{c(this,"FormatterCommandRegistry")}static async fromDirectory(t,o={}){let i=await I(t,"formatters",m=>D(m).formatters,o),{available:e,evidence:n}=await O(t,i.entries.filter(m=>m.layer==="built-in").map(m=>({id:m.id,config:m.config.run})),u,o),f=[...i.entries].sort((m,s)=>m.layer==="built-in"&&s.layer==="built-in"?(n.get(s.id)?.score??0)-(n.get(m.id)?.score??0):0);return new r(f,e,n)}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 A(this.formatters,this.availableBuiltIns,this.evidence,t,o)}get entries(){return this.formatters}};var N={protocol:R,apiVersion:k,id:"formatter",setup(r){for(let t of u)r.addToolRecipe(t);r.addSetupCheck({id:"effective-config",inspect:V}),r.addCheck({id:"config",title:"Formatter",async run(t){try{let o=await d.fromDirectory(t.cwd,b(t)),i=B(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:e,source:n})=>{let f=`${e.id} [${e.layer}] command ${JSON.stringify(e.config.run.command)}`;return z(t,n,async m=>{try{let s=t.workspace?await t.workspace.run(e.config.run,m,t.signal):await h(e.config,{projectRoot:t.cwd,filePath:m,env:t.env});return t.signal?.throwIfAborted(),s.ok?{status:"pass",message:`${f}: probe passed`,detail:e.sourcePath}:{status:"fail",message:`${f}: probe failed`,detail:e.sourcePath}}catch(s){return t.signal?.throwIfAborted(),{status:"fail",message:`${f}: ${s instanceof Error?s.message:String(s)}`,detail:e.sourcePath}}})}))}catch(o){return t.signal?.throwIfAborted(),[{status:"fail",message:o instanceof Error?o.message:String(o)}]}}})}};async function V(r){try{let t=await d.fromDirectory(r.cwd,b(r)),o=[],i=new Map;for(let[e,n]of r.detectedLanguages){let f=n.map(m=>t.resolveEntry(m,r.cwd)).find(m=>m!==void 0);f!==void 0&&(o.push({kind:"formatter",languageId:e,toolId:f.id}),await $(r,f.config.run)||i.set(f.id,{id:`formatter-${f.id}-unavailable`,message:`Configured formatter ${f.id} cannot run ${JSON.stringify(f.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)}`}]}}}c(V,"inspectFormatterSetup");function B(r,t,o){let i=new Map;for(let e of t){let n=r.resolveEntry(e,o);n!==void 0&&!i.has(n.id)&&i.set(n.id,{entry:n,source:e})}return[...i.values()]}c(B,"applicableFormatters");import C from"node:path";import{realpath as Z}from"node:fs/promises";import w from"node:path";import j from"node:os";import{readFile as H}from"node:fs/promises";import{parse as X}from"smol-toml";function _(r,t){let o=process.platform==="win32"?process.env.APPDATA:process.platform==="darwin"?w.join(j.homedir(),"Library","Application Support"):process.env.XDG_CONFIG_HOME||w.join(j.homedir(),".config");return{paths:w,userConfigDirectories:[j.homedir(),...o?[w.join(o,"rustfmt")]:[]],async readText(i){try{return await H(i,"utf8")}catch(e){if(typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR"||e.code==="EISDIR"))return;throw e}},run:c((i,e)=>S(i,{projectRoot:r,filePath:t,input:e}),"run")}}c(_,"localRustfmtAccess");async function M(r,t,o){let i=[],e=o.paths.dirname(t);for(;;){i.push(e);let s=o.paths.dirname(e);if(s===e||/^\/[A-Z]:\/?$/u.test(e))break;e=s}i.push(...o.userConfigDirectories);let n=!1;for(let s of i){for(let p of[".rustfmt.toml","rustfmt.toml"]){let g=await o.readText(o.paths.join(s,p));if(g!==void 0){if(n=!0,Object.hasOwn(X(g),"edition"))return r;break}}if(n)break}let f;try{f=await o.run({command:["cargo","read-manifest","--offline"],cwd:"file"})}catch(s){if(typeof s=="object"&&s!==null&&"code"in s&&s.code==="ENOENT")return r;throw s}if(!f.ok)return r;let m=JSON.parse(f.stdout);return typeof m!="object"||m===null||!("edition"in m)||typeof m.edition!="string"?r:{...r,run:{...r.run,command:["rustfmt","--edition",m.edition,"{file}"]}}}c(M,"rustfmtWithEdition");var q=new Map;function J(r){return{kind:"formatter",name:"formatter",priority:100,extensions:["*"],detect:c(async t=>(r?await r.loadRegistry(t.cwd,!1):await L(t.cwd),!0),"detect"),async format({filePath:t,before:o},i){if(!r&&(t.includes("://")||i.cwd.includes("://")))throw Object.assign(new Error("Formatter requires its resource owner"),{code:"UNSUPPORTED_SOURCE"});let e=r?await r.resolveProject(t,i.cwd):await T(i.cwd,t,"formatters",u).then(l=>l===void 0?void 0:{cwd:l,external:l!==C.resolve(i.cwd)});if(e===void 0)return{ok:!0,edits:0,formatter:null};let n=e.cwd,m=(r?await r.loadRegistry(n,e.external):await L(n,e.external)).resolveEntry(t,n),s=m?.config;if(s===void 0)return{ok:!0,edits:0,formatter:null};let p=!1;if(m?.layer==="built-in"&&m.id==="rustfmt")try{let l=r?.rustfmtAccess?await r.rustfmtAccess(n,t):{file:C.join(await Z(C.dirname(t)),C.basename(t)),access:_(n,t)};s=await M(s,l.file,l.access);let G=s.run.command.filter(y=>y!=="{file}");if(s={...s,output:"stdout",run:{...s.run,command:[...G,"--emit","stdout"],cwd:"file"}},p=!0,o!==void 0&&o.length>0){let y=await l.access.run(s.run,o);if(!y.ok)return{ok:!1,edits:0,formatter:"rustfmt"};if(y.stdout!==o)return{ok:!0,edits:0,formatter:"rustfmt",skipped:"style"}}}catch{return{ok:!1,edits:0,formatter:"rustfmt"}}let g=P(s.run.command);if(r){let l=await r.run(s,n,t,p);return{ok:l.ok,edits:l.changed?1:0,formatter:g}}try{let l=await h(s,{projectRoot:n,filePath:t,stdin:p});return{ok:l.ok,edits:l.changed?1:0,formatter:g}}catch{return{ok:!1,edits:0,formatter:g}}}}}c(J,"createFormatter");async function L(r,t=!1){let o=JSON.stringify([r,t]),i=q.get(o);return i===void 0&&(i=d.fromDirectory(r,{includeGlobal:!t,requireBuiltInEvidence:!0}),q.set(o,i)),i}c(L,"loadRegistry");async function K(r){await Q(r)}c(K,"registerFormatter");async function Q(r,t){let o=J(t),i={kind:"formatter",name:"pi-agent-ide-formatter",priority:200,extensions:["*"],detect:c(()=>Promise.resolve(!0),"detect"),async format(n,f){return o.format(n,f)}},e={protocol:E,apiVersion:5,id:"formatter",setup(n){n.addTool(i)}};await Promise.all([F(r,e),v(r,N)])}c(Q,"registerFormatterWithOwner");export{u as a,d as b,_ as c,K as d,Q as e};
@@ -0,0 +1 @@
1
+ import{c as p,f as S,j as n}from"./chunk-S4GTWS2J.js";import{a as d}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as f}from"typebox/value";var w=e.Object({pid:e.Integer({minimum:1}),parentPid:e.Integer({minimum:0}),command:e.String(),started:e.String(),identity:e.String({pattern:"^[a-f0-9-]+:[0-9]+$"}),executable:e.Union([e.String(),e.Null()])}),y=e.Object({processes:e.Array(w)}),u=p(new URL("./process-metadata-worker.py",new URL("../src/backend/process-metadata.ts",import.meta.url).href));async function m(s,o,a,r){if(r?.throwIfAborted(),!Number.isSafeInteger(a)||a<1)throw new Error("Invalid process PID");let i=s.resolve(o);if(!i)throw new n("UNSUPPORTED_SOURCE",o,"not-applied");let c=await i.backend.execute(S(await u),[String(a)],i.location.path,{signal:r});if(r?.throwIfAborted(),c.exitCode!==0)throw new n("CAPABILITY_UNAVAILABLE",o,"not-applied");let t;try{t=JSON.parse(c.stdout.toString("utf8"))}catch{throw new n("INVALID_RESPONSE",o,"not-applied")}if(typeof t=="object"&&t!==null&&"error"in t){if(t.error==="ENOENT")return;let h=new Set(["CAPABILITY_UNAVAILABLE","EACCES","BYTE_LIMIT"]);throw new n(typeof t.error=="string"&&h.has(t.error)?t.error:"INVALID_RESPONSE",o,"not-applied")}if(!f.Check(y,t)||t.processes.length!==1||t.processes[0]?.pid!==a)throw new n("INVALID_RESPONSE",o,"not-applied");return t.processes[0]}d(m,"findSshProcessMetadata");async function R(s,o,a){try{await s.stop()}catch(r){if(!(r instanceof n)||r.code!=="TRANSPORT_FAILED"||!s.identity)throw r;let i;try{i=await m(o,a,s.pid)}catch(c){throw new AggregateError([r,c],"Owned SSH cleanup could not be reconciled",{cause:c})}if(i===void 0||i.identity!==s.identity)return;throw r}}d(R,"stopOwnedSshProcess");export{R as a};
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as a}from"typebox/value";var t=e.Function([],e.Unknown()),i=e.Union([e.Object({stage:e.Literal("text-pre-edit"),when:e.Optional(t),handler:t}),e.Object({stage:e.Literal("text-edit"),handler:t}),e.Object({stage:e.Literal("text-post-edit"),handler:t})]);function l(r){return a.Check(i,r)}n(l,"isTextEditHandlerRegistration");export{l as a};
@@ -0,0 +1,4 @@
1
+ import{c as O,o as T}from"./chunk-4AEYLVSR.js";import{a as I}from"./chunk-47SPPIXK.js";import{a as S,b as P}from"./chunk-VAXLSPPU.js";import{a as v}from"./chunk-XKVU6AAS.js";import{a as C,b,c as _,d as N}from"./chunk-KN6VPARZ.js";import{a as x}from"./chunk-I3G6K7QU.js";import{a as k,b as E}from"./chunk-HSAGZWPO.js";import{a as s}from"./chunk-EI7MMDWY.js";var W=/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/,R=class{static{s(this,"AgentDocumentationRegistry")}#e=new Map;register(t){let n=new Set(this.#e.keys());for(let r of t)V(r,n),n.add(r.id);for(let r of t)this.#e.set(r.id,z(r))}list(){return[...this.#e.values()].sort((t,n)=>t.id.localeCompare(n.id))}get(t){return this.#e.get(t)}matching(t,n){let r=B(n);return r?.startsWith("docs:")===!0?[]:this.list().filter(c=>c.triggers.some(i=>{if(i.tool!==t)return!1;let l=i.resourcePrefixes===void 0||r!==void 0&&i.resourcePrefixes.some(o=>r.startsWith(o)),u=i.viewPrefixes===void 0||L(n).some(o=>i.viewPrefixes?.some(a=>o.startsWith(a)));return l&&u}))}};function V(e,t){if(!W.test(e.id))throw new Error(`Invalid documentation ID: ${e.id}`);if(e.description.trim().length===0)throw new Error(`Documentation ${e.id} has no description`);if(e.markdown.trim().length===0)throw new Error(`Documentation ${e.id} has no Markdown content`);if(e.triggers.length===0||e.triggers.some(n=>n.tool.trim().length===0||n.resourcePrefixes?.some(r=>r.length===0)===!0||n.viewPrefixes?.some(r=>r.length===0)===!0))throw new Error(`Documentation ${e.id} has no valid triggers`);if(t.has(e.id))throw new Error(`Documentation ${e.id} is already registered`)}s(V,"validateDocument");function z(e){let t={...e,triggers:Object.freeze(e.triggers.map(r=>Object.freeze({...r,...r.resourcePrefixes===void 0?{}:{resourcePrefixes:Object.freeze([...r.resourcePrefixes])},...r.viewPrefixes===void 0?{}:{viewPrefixes:Object.freeze([...r.viewPrefixes])}})))},n=Object.getOwnPropertyDescriptor(e,"markdown");return n?.get!==void 0&&Object.defineProperty(t,"markdown",{get:n.get.bind(e),enumerable:!0}),Object.freeze(t)}s(z,"freezeDocument");function L(e){if(typeof e!="object"||e===null)return[];let t=e.views;return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}s(L,"readViews");function B(e){if(typeof e!="object"||e===null)return;let t=e.path;return typeof t=="string"?t:void 0}s(B,"readPath");function j(e){return{id:"agent-documentation",readResources:s(t=>t.path?.startsWith("docs:")===!0?[t.path]:[],"readResources"),async tryResolve(t,n){let r=t.path;if(r===void 0||!r.startsWith("docs:"))return{kind:"not-handled"};if(t.include!==void 0||t.exclude!==void 0)return{kind:"failed",error:new Error("File include/exclude globs do not apply to docs: resources.")};let c=r.slice(5);if(c.length===0)return{kind:"failed",error:new Error("Use docs:all to search all guides or docs:<id> for one guide. Read docs: to list IDs.")};let i=c==="all"?void 0:e.get(c);if(c!=="all"&&i===void 0)return{kind:"failed",error:new Error(`Unknown documentation ID: ${c}`)};let l=H(t),u=[],o=t.limit??50,a=0;for(let f of i===void 0?e.list():[i]){n.signal?.throwIfAborted();for(let[h,m]of f.markdown.split(/\r\n|\n|\r/u).entries()){n.signal?.throwIfAborted();for(let d of m.matchAll(l)){if(d[0].length===0)continue;let p=d.index,w=p+d[0].length;if(t.wholeWord===!0&&(/[\p{L}\p{N}_]/u.test(m[p-1]??"")||/[\p{L}\p{N}_]/u.test(m[w]??"")))continue;if(u.length===o)return{kind:"resolved",payload:{source:r,matches:u,complete:!1,reason:"limit"}};let D={source:`docs:${f.id}`,lineNumber:h+1,startColumn:p,endColumn:w,matchedText:d[0],lineText:m};if(a+=Buffer.byteLength(M(D))+1,a>48*1024)return{kind:"resolved",payload:{source:r,matches:u,complete:!1,reason:"output"}};u.push(D)}}}return{kind:"resolved",payload:{source:r,matches:u,complete:!0}}},toScriptData(t){let n=t;return O(n.matches,n.complete)},format(t){let n=t,r=`${n.matches.length}${n.complete?"":"+"}`;return{content:[{type:"text",text:[n.matches.length===0&&n.complete?`No matches in ${n.source}`:`${r} matches in ${n.source}`,...$(n),...n.matches.map(M)].join(`
2
+ `)}],details:n}},renderResult(t,n,r){let c=t.details;return T(c.matches,c.complete,r,n.expanded,void 0,$(c))}}}s(j,"createDocumentationSearchResolver");function $(e){return["Packaged guides \xB7 read-only. Read docs:<id> for the full guide; search excerpts do not mark it read.",...e.reason==="limit"?["Limit reached \xB7 incomplete results. Narrow the query or raise limit."]:[],...e.reason==="output"?["Output shortened \xB7 incomplete results. Narrow the query."]:[]]}s($,"notices");function M(e){let t=Math.max(0,e.startColumn-64),n=Math.min(e.lineText.length,e.startColumn+192),r=`${t>0?"\u2026":""}${e.lineText.slice(t,n)}${n<e.lineText.length?"\u2026":""}`;return`${e.source}:${e.lineNumber}:${e.startColumn+1} ${r}`}s(M,"matchRow");function H(e){if(/\r|\n/u.test(e.query))throw new Error("Search supports one-line patterns only.");let t=e.query,n=t.startsWith("regex:")?t.slice(6):t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(n,e.caseSensitive===!0?"gu":"giu")}s(H,"searchPattern");var y="agent-documentation-read";async function G(e,t={}){let n=new R,r=new Set,c=new Map,i=new Map,l=s(o=>{let a=o.filter(f=>!r.has(f));if(a.length!==0){e.appendEntry(t.recordType??y,{ids:a});for(let f of a)r.add(f)}},"remember"),u=e.events.on(N,o=>{if(!Y(o))throw new Error("Invalid agent documentation registration");n.register(o.documents)});e.on("session_shutdown",u),e.on("before_agent_start",o=>{let a=t.recordType?.replaceAll("/","_")??"ide_documentation";o.systemPromptOptions.sections[a]=F(n.list())??""}),await x(e,{protocol:k,apiVersion:E,id:"agent-documentation",setup(o){o.addResolver({resolver:{id:"agent-documentation",tryResolve(a){if(!a.startsWith("docs:"))return Promise.resolve({kind:"not-handled"});let f=a.slice(5),h=f.length===0?void 0:n.get(f),m=f.length===0?q(n.list()):h?.markdown;return m===void 0?Promise.resolve({kind:"failed",error:new Error(`Unknown documentation ID: ${f}`)}):Promise.resolve({kind:"resolved",resource:{source:a,read:s(()=>Promise.resolve([{type:"text",text:m}]),"read")}})}}}),o.describe({path:s(()=>n.list().length===0?void 0:"docs: \u2014 list of guides; docs:<id> \u2014 one guide.","path")})}}),await I(e,{protocol:S,apiVersion:P,id:"agent-documentation",setup(o){o.addResolver({resolver:j(n),priority:-20})}}),e.on("session_start",(o,a)=>{A(a.sessionManager.getBranch(),n,r,t)}),e.on("session_tree",(o,a)=>{A(a.sessionManager.getBranch(),n,r,t)}),e.on("session_compact",(o,a)=>{A(a.sessionManager.getBranch(),n,r,t)}),e.on("tool_call",o=>{o.toolCallId.includes("-preflight-")||o.parentToolCallId!==void 0&&c.set(o.toolCallId,o.parentToolCallId)}),e.on("tool_result",o=>{if(o.toolCallId.includes("-preflight-"))return;let a=c.get(o.toolCallId);c.delete(o.toolCallId);let f=i.get(o.toolCallId)??[];i.delete(o.toolCallId);let h=o.toolName==="read"?K(o.input):void 0;if(h!==void 0){let d=h.slice(5),p=d.length===0||n.get(d)!==void 0,w=n.get(d);return w!==void 0&&!o.isError&&U(o.content,w)&&l([d]),{content:o.content,structuredContent:o.structuredContent,details:{...g(o.details)?o.details:{},documentation:{owner:t.recordType??y,...p?d.length===0?{kind:"list",ids:n.list().map(D=>D.id)}:{kind:"document",id:d}:{kind:"error",code:"UNKNOWN_DOCUMENTATION",id:d}}},isError:o.isError}}let m=[...f,...n.matching(o.toolName,o.input).filter(d=>!r.has(d.id))];if(m.length!==0){if(l(m.map(d=>d.id)),a!==void 0){i.set(a,[...i.get(a)??[],...m]);return}return{content:[...o.content,...m.map(d=>({type:"text",text:v(d.id)+d.markdown.trim()}))],structuredContent:o.structuredContent,details:{...g(o.details)?o.details:{},documentation:{owner:t.recordType??y,kind:"attachment",ids:m.map(d=>d.id)}},isError:o.isError}}}),e.events.emit(_,{protocol:C,apiVersion:b})}s(G,"registerProgressiveDocumentation");function q(e){return e.length===0?"No agent documentation is currently available.":["# Available agent documentation","",...e.map(t=>`- \`${t.id}\` \u2014 ${t.description}`)].join(`
3
+ `)}s(q,"renderListing");function F(e){if(e.length!==0)return["Before using a tool or feature that has a guide below, read its docs:<id> once.","Available documents:",...e.map(t=>` - ${t.id} \u2014 ${t.description}`)].join(`
4
+ `)}s(F,"renderPromptGuideline");function A(e,t,n,r){n.clear();for(let i of e){if(!g(i))continue;if(i.type==="custom"&&i.customType===(r.recordType??y)&&g(i.data)){c(i.data.ids);continue}if(i.type!=="message"||!g(i.message))continue;let l=i.message;if(r.ownsTool!==void 0&&!r.ownsTool(l.toolName)||l.role!=="toolResult"||!g(l.details))continue;let u=l.details.documentation;if(g(u)&&!(u.owner!==void 0&&u.owner!==(r.recordType??y))&&(u.kind==="attachment"&&c(u.ids),u.kind==="document"&&!l.isError&&typeof u.id=="string")){let o=t.get(u.id);o!==void 0&&U(l.content,o)&&c([o.id])}}function c(i){if(Array.isArray(i))for(let l of i)typeof l=="string"&&t.get(l)!==void 0&&n.add(l)}s(c,"addIds")}s(A,"restoreClaims");function U(e,t){return Array.isArray(e)&&e.some(n=>g(n)&&n.type==="text"&&typeof n.text=="string"&&n.text.includes(t.markdown.trim()))}s(U,"containsFullGuide");function K(e){if(!(!g(e)||typeof e.path!="string"||!e.path.startsWith("docs:")))return e.path}s(K,"documentationSource");function Y(e){return g(e)&&Array.isArray(e.documents)}s(Y,"isRegistrationRequest");function g(e){return typeof e=="object"&&e!==null}s(g,"isRecord");export{G as a};
@@ -0,0 +1 @@
1
+ import{f as m,j as d}from"./chunk-S4GTWS2J.js";import{a as p}from"./chunk-EI7MMDWY.js";import h from"node:path";async function A(o,e,t={},r){r?.throwIfAborted();for(let n of Object.keys(t))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(n))throw new TypeError("Invalid remote process environment key");let i=await o.execute(m('import os; print(os.environ.get("PATH", os.defpath), end="")'),[],e,{signal:r});if(i.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",o.target.id,"not-applied");return{...t,PATH:[...["node_modules/.bin",".venv/bin","venv/bin","vendor/bin"].map(n=>h.posix.join(e,n)),t.PATH??i.stdout].join(":")}}p(A,"sshProjectEnvironment");async function f(o,e,t,r){r?.throwIfAborted();let i=t.map(s=>{for(let l of Object.keys(s.env??{}))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(l))throw new TypeError("Invalid remote process environment key");return{command:s.command[0]?.replaceAll("{project}",e)??"",path:s.env?.PATH}}),n=await o.execute(m("import json,os,shutil,sys; candidates=json.loads(sys.argv[1]); root=sys.argv[2]; root=root[1:] if os.name=='nt' and root[:1]=='/' and root[2:3]==':' else root; prefixes=[os.path.join(root,p) for p in ['node_modules/.bin','.venv/bin','venv/bin','vendor/bin']]; print(json.dumps([bool(shutil.which(c['command'],path=os.pathsep.join(prefixes+[c.get('path',os.environ.get('PATH',os.defpath))]))) for c in candidates]))"),[JSON.stringify(i),e],e,{signal:r});if(n.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",o.target.id,"not-applied");let a=JSON.parse(n.stdout.toString("utf8"));if(!Array.isArray(a)||a.length!==t.length||a.some(s=>typeof s!="boolean"))throw new d("INVALID_RESPONSE",o.target.id,"not-applied");return a}p(f,"sshProjectExecutableAvailability");export{A as a,f as b};