pi-agent-ide 0.7.3 → 0.8.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 (664) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +63 -17
  3. package/dist/{chunk-2ZMMRINH.js → chunk-2K65BSXS.js} +1 -1
  4. package/dist/chunk-3G54ZL2L.js +1 -0
  5. package/dist/chunk-3ZGDMTMD.js +25 -0
  6. package/dist/{chunk-ZIWPKIBZ.js → chunk-4OYVLXWD.js} +1 -1
  7. package/dist/chunk-4W7GH3T7.js +10 -0
  8. package/dist/chunk-4XPUN4QN.js +2 -0
  9. package/dist/chunk-5KFVDYCI.js +1 -0
  10. package/dist/chunk-6EDOLYOV.js +1 -0
  11. package/dist/chunk-756K3LJY.js +1 -0
  12. package/dist/chunk-75SWXD2Z.js +9 -0
  13. package/dist/chunk-7HDK3NRQ.js +1 -0
  14. package/dist/chunk-7JV4VN73.js +1 -0
  15. package/dist/chunk-7NS3QUIE.js +9 -0
  16. package/dist/chunk-7TJ6DWW3.js +2 -0
  17. package/dist/chunk-ABFCAOU5.js +1 -0
  18. package/dist/chunk-BIG45IPN.js +2 -0
  19. package/dist/chunk-BQ67M4NC.js +3 -0
  20. package/dist/chunk-BXGMMZT3.js +1 -0
  21. package/dist/chunk-CPZJPGLG.js +1 -0
  22. package/dist/chunk-CSXHCSTH.js +9 -0
  23. package/dist/chunk-CTJV77FR.js +1 -0
  24. package/dist/chunk-DUUOCBS3.js +3 -0
  25. package/dist/chunk-E4HPRLRB.js +1 -0
  26. package/dist/chunk-EY65TFHJ.js +1 -0
  27. package/dist/{chunk-WLZIUMJL.js → chunk-GW6NZQTQ.js} +1 -1
  28. package/dist/chunk-HCN5W76B.js +1 -0
  29. package/dist/chunk-ICDI27GZ.js +1 -0
  30. package/dist/{chunk-TXOTNK6B.js → chunk-IH5NW5JX.js} +1 -1
  31. package/dist/chunk-IMGIDBCC.js +1 -0
  32. package/dist/chunk-IUSLSROY.js +1 -0
  33. package/dist/chunk-KL776TGR.js +1 -0
  34. package/dist/chunk-L2B4DTVS.js +1 -0
  35. package/dist/chunk-LEKC4GQK.js +5 -0
  36. package/dist/chunk-MKEC3U2M.js +4 -0
  37. package/dist/chunk-MOJ5RR35.js +1 -0
  38. package/dist/{chunk-H445SHSJ.js → chunk-MZXX353D.js} +1 -1
  39. package/dist/{chunk-ZTYWHL2F.js → chunk-N7LMRL64.js} +1 -1
  40. package/dist/chunk-NULNW6GK.js +1 -0
  41. package/dist/chunk-O36UC74T.js +1 -0
  42. package/dist/chunk-OFILFO6D.js +1 -0
  43. package/dist/chunk-OJX3RJ5A.js +1 -0
  44. package/dist/chunk-OLI3JPHJ.js +28 -0
  45. package/dist/{chunk-S6QRG3TQ.js → chunk-OM4LYD3S.js} +1 -1
  46. package/dist/chunk-PNP2KNGP.js +5 -0
  47. package/dist/chunk-QP2QSQ4U.js +2 -0
  48. package/dist/chunk-R2U5WXYR.js +1 -0
  49. package/dist/chunk-R5XJSEOE.js +3 -0
  50. package/dist/{chunk-7UGNGK7Y.js → chunk-RAZP42IQ.js} +1 -1
  51. package/dist/chunk-S72FVLUX.js +1 -0
  52. package/dist/chunk-SBLKPTL3.js +1 -0
  53. package/dist/chunk-SBNR4WZF.js +1 -0
  54. package/dist/chunk-SSWUUBIR.js +1 -0
  55. package/dist/chunk-T4FTT3U4.js +1 -0
  56. package/dist/chunk-TOYN4W4F.js +1 -0
  57. package/dist/chunk-TWWND6NI.js +1 -0
  58. package/dist/chunk-UBH6X3D3.js +1 -0
  59. package/dist/{chunk-QFTBY67N.js → chunk-UEVGZUII.js} +3 -3
  60. package/dist/chunk-UUJJRXHG.js +29 -0
  61. package/dist/chunk-VDP5CQHM.js +3 -0
  62. package/dist/chunk-WE42GBGU.js +4 -0
  63. package/dist/chunk-XZDOVPRC.js +1 -0
  64. package/dist/chunk-YJ6T3PEP.js +1 -0
  65. package/dist/chunk-Z3PGADVA.js +3 -0
  66. package/dist/{chunk-QDLTO5PH.js → chunk-ZAWRSA7N.js} +1 -1
  67. package/dist/entry-0.js +1 -1
  68. package/dist/entry-1.js +1 -1
  69. package/dist/entry-10.js +1 -1
  70. package/dist/entry-11.js +1 -1
  71. package/dist/entry-13.js +1 -1
  72. package/dist/entry-14.js +1 -1
  73. package/dist/entry-15.js +1 -1
  74. package/dist/entry-17.js +1 -1
  75. package/dist/entry-2.js +1 -1
  76. package/dist/entry-20.js +1 -1
  77. package/dist/entry-21.js +1 -1
  78. package/dist/entry-22.js +1 -1
  79. package/dist/entry-23.js +1 -1
  80. package/dist/entry-24.js +1 -1
  81. package/dist/entry-25.js +1 -2
  82. package/dist/entry-26.js +2 -1
  83. package/dist/entry-27.js +1 -2
  84. package/dist/entry-28.js +4 -1
  85. package/dist/entry-29.js +1 -1
  86. package/dist/entry-30.js +1 -1
  87. package/dist/entry-31.js +1 -17
  88. package/dist/entry-32.js +18 -1
  89. package/dist/entry-33.js +1 -3
  90. package/dist/entry-34.js +1 -1
  91. package/dist/entry-35.js +1 -1
  92. package/dist/entry-36.js +1 -4
  93. package/dist/entry-37.js +1 -9
  94. package/dist/entry-38.js +1 -1
  95. package/dist/entry-39.js +1 -1
  96. package/dist/entry-4.js +1 -1
  97. package/dist/entry-40.js +1 -1
  98. package/dist/entry-41.js +1 -1
  99. package/dist/entry-42.js +1 -1
  100. package/dist/entry-43.js +1 -1
  101. package/dist/entry-44.js +1 -1
  102. package/dist/entry-45.js +1 -25
  103. package/dist/entry-46.js +25 -1
  104. package/dist/entry-47.js +1 -1
  105. package/dist/entry-48.js +1 -1
  106. package/dist/entry-49.js +1 -1
  107. package/dist/entry-50.js +1 -3
  108. package/dist/entry-51.js +3 -13
  109. package/dist/entry-52.js +13 -1
  110. package/dist/entry-53.js +1 -1
  111. package/dist/entry-54.js +1 -1
  112. package/dist/entry-55.js +1 -1
  113. package/dist/entry-56.js +1 -1
  114. package/dist/entry-57.js +1 -1
  115. package/dist/entry-58.js +1 -1
  116. package/dist/entry-59.js +1 -1
  117. package/dist/entry-60.js +1 -1
  118. package/dist/entry-61.js +1 -0
  119. package/dist/entry-62.js +0 -1
  120. package/dist/entry-63.js +1 -0
  121. package/dist/entry-64.js +0 -1
  122. package/dist/entry-65.js +1 -1
  123. package/dist/entry-66.js +1 -1
  124. package/dist/entry-67.js +1 -1
  125. package/dist/entry-68.js +1 -1
  126. package/dist/entry-69.js +1 -1
  127. package/dist/entry-70.js +1 -1
  128. package/dist/entry-71.js +1 -0
  129. package/dist/entry-72.js +0 -1
  130. package/dist/entry-73.js +1 -0
  131. package/dist/entry-74.js +0 -1
  132. package/dist/entry-75.js +1 -1
  133. package/dist/entry-76.js +1 -1
  134. package/dist/entry-77.js +1 -80
  135. package/dist/entry-78.js +76 -15
  136. package/dist/entry-79.js +21 -2
  137. package/dist/entry-8.js +1 -1
  138. package/dist/entry-80.js +2 -1
  139. package/dist/entry-81.js +1 -1
  140. package/dist/entry-82.js +1 -5
  141. package/dist/entry-83.js +1 -3
  142. package/dist/entry-84.js +3 -1
  143. package/dist/entry-85.js +1 -1
  144. package/dist/entry-86.js +1 -1
  145. package/dist/entry-87.js +1 -0
  146. package/dist/pi-agent-ide.js +19 -19
  147. package/docs/agent-guides/debugger.md +2 -0
  148. package/docs/agent-guides/editing.md +1 -1
  149. package/docs/agent-guides/search-code.md +4 -1
  150. package/docs/agent-guides/ssh.md +58 -0
  151. package/docs/agent-guides/vision.md +6 -0
  152. package/docs/configuration.md +34 -0
  153. package/docs/tools.md +21 -14
  154. package/docs/user-hooks.md +5 -3
  155. package/node_modules/pi-agent-doctor/package.json +6 -2
  156. package/node_modules/pi-agent-doctor/src/evidence.ts +49 -4
  157. package/node_modules/pi-agent-doctor/src/executable.ts +46 -16
  158. package/node_modules/pi-agent-doctor/src/fixtures/executable-probe.ts +78 -0
  159. package/node_modules/pi-agent-doctor/src/fixtures/probe-executable-wait.mjs +10 -0
  160. package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +6 -0
  161. package/node_modules/pi-agent-doctor/src/project-probes.ts +73 -0
  162. package/node_modules/pi-agent-doctor/src/workspace.ts +106 -0
  163. package/node_modules/pi-agent-documentation/package.json +2 -2
  164. package/node_modules/pi-agent-documentation/runtime/entry-25.js +1 -0
  165. package/node_modules/pi-agent-filesystem/package.json +8 -8
  166. package/node_modules/pi-agent-filesystem/src/resolver.ts +23 -7
  167. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  168. package/node_modules/pi-agent-filesystem-jq/index.ts +33 -6
  169. package/node_modules/pi-agent-filesystem-jq/package.json +6 -6
  170. package/node_modules/pi-agent-filesystem-jq/src/jq.ts +67 -0
  171. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  172. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  173. package/node_modules/pi-agent-filesystem-text/runtime/entry-30.js +2 -0
  174. package/node_modules/pi-agent-ide-ast/package.json +15 -15
  175. package/node_modules/pi-agent-ide-ast/runtime/entry-31.js +0 -1
  176. package/node_modules/pi-agent-ide-ast/runtime/entry-32.js +2 -0
  177. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +2 -1
  178. package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +10 -3
  179. package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +4 -1
  180. package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +3 -3
  181. package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +13 -10
  182. package/node_modules/pi-agent-ide-ast/src/extension.ts +17 -1
  183. package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +32 -4
  184. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +2 -2
  185. package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +1 -1
  186. package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +4 -3
  187. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +100 -42
  188. package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +3 -2
  189. package/node_modules/pi-agent-ide-ast/src/tool-select.ts +2 -1
  190. package/node_modules/pi-agent-ide-changes/index.ts +10 -2
  191. package/node_modules/pi-agent-ide-changes/package.json +10 -10
  192. package/node_modules/pi-agent-ide-changes/runtime/entry-33.js +0 -1
  193. package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +7 -2
  194. package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +18 -1
  195. package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +3 -0
  196. package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +59 -7
  197. package/node_modules/pi-agent-ide-changes/src/changes/git-paths.ts +49 -0
  198. package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +10 -2
  199. package/node_modules/pi-agent-ide-changes/src/doctor-plugin.ts +13 -14
  200. package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +2 -1
  201. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +47 -11
  202. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +6 -1
  203. package/node_modules/pi-agent-ide-formatter/index.ts +14 -2
  204. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  205. package/node_modules/pi-agent-ide-formatter/src/doctor-plugin.ts +47 -35
  206. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +41 -11
  207. package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -28
  208. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  209. package/node_modules/pi-agent-ide-lint/index.ts +35 -4
  210. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  211. package/node_modules/pi-agent-ide-lint/src/command-linter.ts +14 -10
  212. package/node_modules/pi-agent-ide-lint/src/doctor-plugin.ts +47 -39
  213. package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -25
  214. package/node_modules/pi-agent-ide-lsp/index.ts +107 -25
  215. package/node_modules/pi-agent-ide-lsp/package.json +10 -10
  216. package/node_modules/pi-agent-ide-lsp/runtime/entry-38.js +2 -0
  217. package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +6 -2
  218. package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +5 -1
  219. package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +5 -3
  220. package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +27 -11
  221. package/node_modules/pi-agent-ide-lsp/src/lsp/abort.ts +62 -0
  222. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +245 -103
  223. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +26 -45
  224. package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +1 -1
  225. package/node_modules/pi-agent-ide-lsp/src/lsp/document-uri.ts +40 -0
  226. package/node_modules/pi-agent-ide-lsp/src/lsp/file-watchers.ts +8 -1
  227. package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +24 -17
  228. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +255 -56
  229. package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +51 -11
  230. package/node_modules/pi-agent-ide-lsp/src/lsp/owner-transport.ts +67 -0
  231. package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +149 -18
  232. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +79 -31
  233. package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +15 -12
  234. package/node_modules/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +16 -0
  235. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +67 -46
  236. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +50 -19
  237. package/node_modules/pi-agent-image/package.json +3 -3
  238. package/node_modules/pi-agent-invariant/package.json +2 -2
  239. package/node_modules/pi-agent-pdf/package.json +3 -3
  240. package/node_modules/pi-agent-read/package.json +12 -12
  241. package/node_modules/pi-agent-read/runtime/entry-45.js +0 -1
  242. package/node_modules/pi-agent-read/runtime/entry-46.js +2 -0
  243. package/node_modules/pi-agent-read/src/api/tools/read.ts +4 -2
  244. package/node_modules/pi-agent-read/src/core/extension.ts +4 -1
  245. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +143 -69
  246. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +25 -1
  247. package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +67 -44
  248. package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +8 -3
  249. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +20 -5
  250. package/node_modules/pi-agent-resource/package.json +2 -2
  251. package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +75 -16
  252. package/node_modules/pi-agent-resource/src/index.ts +3 -0
  253. package/node_modules/pi-agent-resource/src/resource-error.ts +17 -0
  254. package/node_modules/pi-agent-resource/src/resource.ts +23 -0
  255. package/node_modules/pi-agent-resource/src/result-targets.ts +16 -2
  256. package/node_modules/pi-agent-resource/src/validation.ts +2 -1
  257. package/node_modules/pi-agent-search/package.json +9 -9
  258. package/node_modules/pi-agent-search/runtime/entry-50.js +0 -1
  259. package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  260. package/node_modules/pi-agent-search/src/api/search-parameters.ts +6 -2
  261. package/node_modules/pi-agent-search/src/api/search.ts +44 -2
  262. package/node_modules/pi-agent-search/src/core/extension.ts +2 -3
  263. package/node_modules/pi-agent-search/src/core/search-core.ts +78 -8
  264. package/node_modules/pi-agent-search-text/index.ts +35 -1
  265. package/node_modules/pi-agent-search-text/package.json +14 -12
  266. package/node_modules/pi-agent-search-text/runtime/entry-52.js +1 -0
  267. package/node_modules/pi-agent-search-text/src/doctor-plugin.ts +10 -5
  268. package/node_modules/pi-agent-search-text/src/file-search.ts +26 -3
  269. package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +54 -3
  270. package/node_modules/pi-agent-search-text/src/resolvers.ts +22 -5
  271. package/node_modules/pi-agent-search-text/src/scoped-search.ts +4 -5
  272. package/node_modules/pi-agent-search-text/src/search-backend.ts +110 -12
  273. package/node_modules/pi-agent-search-text/src/search-recipe.ts +5 -1
  274. package/node_modules/pi-agent-search-text/src/search-result.ts +1 -0
  275. package/node_modules/pi-agent-search-text/src/search-session.ts +100 -24
  276. package/node_modules/pi-agent-text/package.json +3 -3
  277. package/node_modules/pi-agent-text/runtime/entry-56.js +1 -0
  278. package/node_modules/pi-agent-text/src/text-document.ts +2 -0
  279. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  280. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-57.js +2 -0
  281. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  282. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-58.js +0 -1
  283. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-59.js +2 -0
  284. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  285. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-60.js +0 -1
  286. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-61.js +2 -0
  287. package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +3 -1
  288. package/node_modules/pi-agent-text-editor/package.json +26 -26
  289. package/node_modules/pi-agent-text-editor/runtime/entry-77.js +0 -1
  290. package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +29 -2
  291. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +3 -0
  292. package/node_modules/pi-agent-text-editor/src/api/file-operations.ts +55 -0
  293. package/node_modules/pi-agent-text-editor/src/api/file-transfers.ts +41 -0
  294. package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +2 -0
  295. package/node_modules/pi-agent-text-editor/src/api/native-files.ts +127 -0
  296. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +20 -1
  297. package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +1 -0
  298. package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +94 -80
  299. package/node_modules/pi-agent-text-editor/src/core/extension.ts +14 -2
  300. package/node_modules/pi-agent-text-editor/src/core/file-operation-guards.ts +81 -0
  301. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +21 -4
  302. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +123 -27
  303. package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +30 -1
  304. package/node_modules/pi-agent-text-editor/src/core/file-transfers.ts +147 -105
  305. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
  306. package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +91 -14
  307. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +72 -7
  308. package/node_modules/pi-agent-text-editor/src/core/temporary-directories.ts +40 -20
  309. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +4 -3
  310. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +307 -32
  311. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +79 -23
  312. package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +4 -1
  313. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  314. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +117 -27
  315. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  316. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
  317. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  318. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  319. package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +1 -0
  320. package/node_modules/pi-agent-web/index.ts +28 -4
  321. package/node_modules/pi-agent-web/package.json +8 -8
  322. package/node_modules/pi-agent-web/src/doctor-plugin.ts +21 -6
  323. package/node_modules/pi-agent-web/src/resolver.ts +12 -2
  324. package/node_modules/pi-agent-web/src/search.ts +2 -1
  325. package/node_modules/pi-agent-web-html/package.json +3 -3
  326. package/node_modules/pi-agent-web-image/package.json +4 -4
  327. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  328. package/node_modules/pi-agent-web-text/package.json +4 -4
  329. package/node_modules/pi-agent-web-text/runtime/entry-87.js +2 -0
  330. package/package.json +35 -35
  331. package/src/api/doctor-runtime.ts +80 -0
  332. package/src/api/doctor.ts +6 -0
  333. package/src/api/hooks.ts +3 -0
  334. package/src/api/plugin-protocol.ts +11 -1
  335. package/src/api/tool-config.ts +143 -24
  336. package/src/backend/config.ts +85 -0
  337. package/src/backend/configured-process.ts +59 -0
  338. package/src/backend/dap-java-transport.ts +112 -0
  339. package/src/backend/dap-java-worker.py +218 -0
  340. package/src/backend/dap-node-transport.ts +112 -0
  341. package/src/backend/dap-powershell-worker.py +44 -0
  342. package/src/backend/dap-r-worker.py +210 -0
  343. package/src/backend/dap-tcp-transport.ts +42 -0
  344. package/src/backend/dap-tcp-worker.py +125 -0
  345. package/src/backend/dap-transport.ts +69 -0
  346. package/src/backend/dap-unix-worker.py +63 -0
  347. package/src/backend/debugger-registration.ts +62 -0
  348. package/src/backend/debugger-workspace-owner.ts +413 -0
  349. package/src/backend/doctor-inventory-worker.py +54 -0
  350. package/src/backend/doctor-probe-worker.py +140 -0
  351. package/src/backend/doctor-registration.ts +18 -0
  352. package/src/backend/doctor-workspace.ts +381 -0
  353. package/src/backend/file-operation-resolver.ts +58 -0
  354. package/src/backend/file-revision.ts +13 -0
  355. package/src/backend/file-transfer.ts +302 -0
  356. package/src/backend/file-watch-worker.py +119 -0
  357. package/src/backend/formatter-registration.ts +114 -0
  358. package/src/backend/git-registration.ts +60 -0
  359. package/src/backend/identity.ts +47 -0
  360. package/src/backend/index.ts +12 -0
  361. package/src/backend/lint-registration.ts +102 -0
  362. package/src/backend/lsp-file-watchers.ts +220 -0
  363. package/src/backend/lsp-registration.ts +83 -0
  364. package/src/backend/lsp-transport.ts +87 -0
  365. package/src/backend/lsp-workspace-owner.ts +50 -0
  366. package/src/backend/object-transfer.ts +299 -0
  367. package/src/backend/owned-command.ts +105 -0
  368. package/src/backend/owned-process-stop.ts +36 -0
  369. package/src/backend/owned-read-command.ts +20 -0
  370. package/src/backend/process-environment.ts +77 -0
  371. package/src/backend/process-metadata-worker.py +98 -0
  372. package/src/backend/process-metadata.ts +99 -0
  373. package/src/backend/recipe-evidence-worker.py +26 -0
  374. package/src/backend/recipe-evidence.ts +77 -0
  375. package/src/backend/registration.ts +124 -0
  376. package/src/backend/registry.ts +29 -0
  377. package/src/backend/resource-resolver.ts +147 -0
  378. package/src/backend/search-environment.ts +100 -0
  379. package/src/backend/ssh-channel-worker.py +306 -0
  380. package/src/backend/ssh-channel.ts +376 -0
  381. package/src/backend/ssh-transfer-worker.py +99 -0
  382. package/src/backend/ssh-transport.ts +54 -0
  383. package/src/backend/ssh-worker.py +730 -0
  384. package/src/backend/ssh.ts +610 -0
  385. package/src/backend/tool-config-access.ts +63 -0
  386. package/src/backend/tool-project.ts +71 -0
  387. package/src/backend/vision-capture-worker.py +319 -0
  388. package/src/backend/vision-capture.ts +165 -0
  389. package/src/backend/vision-registration.ts +104 -0
  390. package/src/backend/web-browser-worker.mjs +182 -0
  391. package/src/backend/web-browser.ts +128 -0
  392. package/src/backend/web-http-worker.py +62 -0
  393. package/src/backend/web-http.ts +79 -0
  394. package/src/backend/web-owner.ts +68 -0
  395. package/src/backend/web-registration.ts +14 -0
  396. package/src/code-view/diagnostic-view.ts +2 -2
  397. package/src/code-view/reference.ts +9 -0
  398. package/src/composite/builtin-extensions.ts +9 -14
  399. package/src/composite/module-labels.ts +1 -0
  400. package/src/composite/nested-tool-rendering.ts +10 -1
  401. package/src/core/diagnostic-store.ts +32 -10
  402. package/src/core/ide-core.ts +22 -2
  403. package/src/doctor/arguments.ts +19 -0
  404. package/src/doctor/config-writer.ts +72 -29
  405. package/src/doctor/discovery.ts +53 -15
  406. package/src/doctor/extension.ts +27 -10
  407. package/src/doctor/run.ts +42 -7
  408. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
  409. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  410. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +33 -6
  411. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +6 -6
  412. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +67 -0
  413. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  414. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  415. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-30.js +2 -0
  416. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-26.js +2 -0
  417. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +23 -7
  418. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +28 -4
  419. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
  420. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  421. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  422. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  423. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  424. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-87.js +2 -0
  425. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +2 -0
  426. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/doctor-plugin.ts +21 -6
  427. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +12 -2
  428. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +2 -1
  429. package/src/extensions/pi-agent-read/package.json +12 -12
  430. package/src/extensions/pi-agent-read/runtime/entry-45.js +0 -1
  431. package/src/extensions/pi-agent-read/runtime/entry-46.js +2 -0
  432. package/src/extensions/pi-agent-read/src/api/tools/read.ts +4 -2
  433. package/src/extensions/pi-agent-read/src/core/extension.ts +4 -1
  434. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +143 -69
  435. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +25 -1
  436. package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +67 -44
  437. package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +8 -3
  438. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +20 -5
  439. package/src/extensions/pi-agent-search/package.json +9 -9
  440. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +35 -1
  441. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +14 -12
  442. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-52.js +1 -0
  443. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-55.js +1 -0
  444. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/doctor-plugin.ts +10 -5
  445. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +26 -3
  446. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +54 -3
  447. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +22 -5
  448. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +4 -5
  449. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +110 -12
  450. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +5 -1
  451. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +1 -0
  452. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +100 -24
  453. package/src/extensions/pi-agent-search/runtime/entry-50.js +0 -1
  454. package/src/extensions/pi-agent-search/runtime/entry-51.js +2 -0
  455. package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  456. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +6 -2
  457. package/src/extensions/pi-agent-search/src/api/search.ts +44 -2
  458. package/src/extensions/pi-agent-search/src/core/extension.ts +2 -3
  459. package/src/extensions/pi-agent-search/src/core/search-core.ts +78 -8
  460. package/src/extensions/pi-agent-text-editor/package.json +26 -26
  461. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  462. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-57.js +2 -0
  463. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  464. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-58.js +0 -1
  465. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-59.js +2 -0
  466. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  467. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-60.js +0 -1
  468. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-61.js +2 -0
  469. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +3 -1
  470. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  471. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +117 -27
  472. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  473. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
  474. package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +0 -1
  475. package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +2 -0
  476. package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +29 -2
  477. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +3 -0
  478. package/src/extensions/pi-agent-text-editor/src/api/file-operations.ts +55 -0
  479. package/src/extensions/pi-agent-text-editor/src/api/file-transfers.ts +41 -0
  480. package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +2 -0
  481. package/src/extensions/pi-agent-text-editor/src/api/native-files.ts +127 -0
  482. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +20 -1
  483. package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +1 -0
  484. package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +94 -80
  485. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +14 -2
  486. package/src/extensions/pi-agent-text-editor/src/core/file-operation-guards.ts +81 -0
  487. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +21 -4
  488. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +123 -27
  489. package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +30 -1
  490. package/src/extensions/pi-agent-text-editor/src/core/file-transfers.ts +147 -105
  491. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
  492. package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +91 -14
  493. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +72 -7
  494. package/src/extensions/pi-agent-text-editor/src/core/temporary-directories.ts +40 -20
  495. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +4 -3
  496. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +307 -32
  497. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +79 -23
  498. package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +4 -1
  499. package/src/plugins/pi-agent-ide-ast/package.json +15 -15
  500. package/src/plugins/pi-agent-ide-ast/runtime/entry-31.js +0 -1
  501. package/src/plugins/pi-agent-ide-ast/runtime/entry-32.js +2 -0
  502. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +2 -1
  503. package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +10 -3
  504. package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +4 -1
  505. package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +3 -3
  506. package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +13 -10
  507. package/src/plugins/pi-agent-ide-ast/src/extension.ts +17 -1
  508. package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +32 -4
  509. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +2 -2
  510. package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +1 -1
  511. package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +4 -3
  512. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +100 -42
  513. package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +3 -2
  514. package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +2 -1
  515. package/src/plugins/pi-agent-ide-changes/index.ts +10 -2
  516. package/src/plugins/pi-agent-ide-changes/package.json +10 -10
  517. package/src/plugins/pi-agent-ide-changes/runtime/entry-33.js +0 -1
  518. package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +7 -2
  519. package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +18 -1
  520. package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +3 -0
  521. package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +59 -7
  522. package/src/plugins/pi-agent-ide-changes/src/changes/git-paths.ts +49 -0
  523. package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +10 -2
  524. package/src/plugins/pi-agent-ide-changes/src/doctor-plugin.ts +13 -14
  525. package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +2 -1
  526. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +47 -11
  527. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +6 -1
  528. package/src/plugins/pi-agent-ide-debugger/index.ts +62 -25
  529. package/src/plugins/pi-agent-ide-debugger/src/adapter-executables.ts +3 -1
  530. package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +33 -0
  531. package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +150 -171
  532. package/src/plugins/pi-agent-ide-debugger/src/process-provider.ts +2 -0
  533. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +152 -58
  534. package/src/plugins/pi-agent-ide-debugger/src/workspace-owner.ts +28 -0
  535. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +4 -1
  536. package/src/plugins/pi-agent-ide-formatter/index.ts +14 -2
  537. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  538. package/src/plugins/pi-agent-ide-formatter/src/doctor-plugin.ts +47 -35
  539. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +41 -11
  540. package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -28
  541. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  542. package/src/plugins/pi-agent-ide-lint/index.ts +35 -4
  543. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  544. package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +14 -10
  545. package/src/plugins/pi-agent-ide-lint/src/doctor-plugin.ts +47 -39
  546. package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -25
  547. package/src/plugins/pi-agent-ide-lsp/index.ts +107 -25
  548. package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
  549. package/src/plugins/pi-agent-ide-lsp/runtime/entry-38.js +2 -0
  550. package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +6 -2
  551. package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +5 -1
  552. package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +5 -3
  553. package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +27 -11
  554. package/src/plugins/pi-agent-ide-lsp/src/lsp/abort.ts +62 -0
  555. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +245 -103
  556. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +26 -45
  557. package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +1 -1
  558. package/src/plugins/pi-agent-ide-lsp/src/lsp/document-uri.ts +40 -0
  559. package/src/plugins/pi-agent-ide-lsp/src/lsp/file-watchers.ts +8 -1
  560. package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +24 -17
  561. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +255 -56
  562. package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +51 -11
  563. package/src/plugins/pi-agent-ide-lsp/src/lsp/owner-transport.ts +67 -0
  564. package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +149 -18
  565. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +79 -31
  566. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +15 -12
  567. package/src/plugins/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +16 -0
  568. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +67 -46
  569. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +50 -19
  570. package/src/plugins/pi-agent-ide-processes/src/registry.ts +8 -1
  571. package/src/plugins/pi-agent-ide-terminal/index.ts +7 -0
  572. package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +5 -1
  573. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +5 -2
  574. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +161 -42
  575. package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +7 -0
  576. package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +11 -0
  577. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +33 -8
  578. package/src/plugins/pi-agent-ide-terminal/src/types.ts +5 -0
  579. package/src/plugins/pi-agent-ide-vision/index.ts +170 -9
  580. package/src/plugins/pi-agent-ide-vision/src/doctor-plugin.ts +47 -0
  581. package/src/plugins/pi-agent-ide-vision/src/vision.ts +42 -1
  582. package/src/post-edit/gate.ts +4 -1
  583. package/src/toolchain/types.ts +2 -0
  584. package/dist/chunk-3YK4XMWB.js +0 -0
  585. package/dist/chunk-5JELU6RV.js +0 -7
  586. package/dist/chunk-6U5OU77O.js +0 -3
  587. package/dist/chunk-7LD2OQH3.js +0 -14
  588. package/dist/chunk-BYZSBXUK.js +0 -2
  589. package/dist/chunk-CEX73RI5.js +0 -28
  590. package/dist/chunk-DZWTKF2K.js +0 -1
  591. package/dist/chunk-EOKEQ3YH.js +0 -25
  592. package/dist/chunk-HZ5BNF3A.js +0 -1
  593. package/dist/chunk-IG56UGSO.js +0 -2
  594. package/dist/chunk-KVHDMIZS.js +0 -3
  595. package/dist/chunk-M5IVSCR2.js +0 -1
  596. package/dist/chunk-M5MJP7Z2.js +0 -1
  597. package/dist/chunk-MGCHOGQD.js +0 -1
  598. package/dist/chunk-N34ATN52.js +0 -1
  599. package/dist/chunk-NHKPP2AI.js +0 -28
  600. package/dist/chunk-OB46OPMZ.js +0 -1
  601. package/dist/chunk-Q6CZ6GBR.js +0 -3
  602. package/dist/chunk-QIK2E64R.js +0 -1
  603. package/dist/chunk-SBP3ABH4.js +0 -5
  604. package/dist/chunk-STBJO3Z3.js +0 -2
  605. package/dist/chunk-T6LX2RX5.js +0 -1
  606. package/dist/chunk-WZI4YC2O.js +0 -1
  607. package/node_modules/pi-agent-filesystem/runtime/entry-25.js +0 -2
  608. package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +0 -1
  609. package/node_modules/pi-agent-ide-changes/runtime/entry-32.js +0 -1
  610. package/node_modules/pi-agent-image/runtime/entry-38.js +0 -1
  611. package/node_modules/pi-agent-resource/runtime/entry-46.js +0 -1
  612. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-56.js +0 -2
  613. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-57.js +0 -1
  614. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-59.js +0 -1
  615. package/node_modules/pi-agent-text-editor/runtime/entry-61.js +0 -1
  616. package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +0 -1
  617. package/node_modules/pi-agent-web/runtime/entry-82.js +0 -2
  618. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-26.js +0 -2
  619. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-25.js +0 -2
  620. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +0 -2
  621. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +0 -2
  622. package/src/extensions/pi-agent-read/runtime/entry-41.js +0 -1
  623. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-51.js +0 -2
  624. package/src/extensions/pi-agent-search/runtime/entry-47.js +0 -1
  625. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-56.js +0 -2
  626. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-57.js +0 -1
  627. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-59.js +0 -1
  628. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +0 -2
  629. package/src/extensions/pi-agent-text-editor/runtime/entry-61.js +0 -1
  630. package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +0 -1
  631. package/src/plugins/pi-agent-ide-changes/runtime/entry-32.js +0 -1
  632. /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-24.js +0 -0
  633. /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-26.js +0 -0
  634. /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-27.js +0 -0
  635. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-28.js +0 -0
  636. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-29.js +0 -0
  637. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-34.js +0 -0
  638. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-35.js +0 -0
  639. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-36.js +0 -0
  640. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-37.js +0 -0
  641. /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-39.js +0 -0
  642. /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-40.js +0 -0
  643. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-41.js +0 -0
  644. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-47.js +0 -0
  645. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-51.js +0 -0
  646. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-55.js +0 -0
  647. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-78.js +0 -0
  648. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
  649. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-81.js +0 -0
  650. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-83.js +0 -0
  651. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
  652. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
  653. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
  654. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-27.js +0 -0
  655. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-28.js +0 -0
  656. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-29.js +0 -0
  657. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
  658. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
  659. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
  660. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
  661. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-34.js +0 -0
  662. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-35.js +0 -0
  663. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-36.js +0 -0
  664. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-37.js +0 -0
@@ -1,6 +1,8 @@
1
1
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
  import { ResultPanel } from "pi-agent-tool-ui";
3
3
  import { connectAgentDocumentation, loadPackagedAgentGuide } from "pi-agent-documentation";
4
+ import { connectDoctorPlugin } from "pi-agent-doctor/api/connect-plugin";
5
+ import { visionDoctorPlugin } from "./src/doctor-plugin.js";
4
6
 
5
7
  import type { BuiltinExtensionContext } from "#src/composite/selection.js";
6
8
  import { connectReadPlugin } from "pi-agent-read/api/connect-plugin";
@@ -16,23 +18,56 @@ import {
16
18
  createCaptureBackend,
17
19
  getVisionDefaults,
18
20
  isExecutableAllowed,
21
+ isNativeExecutableAllowed,
19
22
  listProcesses,
20
23
  parseDisplaySource,
21
24
  parseVisionView,
22
25
  readProcess,
23
26
  type VisionOptions,
27
+ type ProcessMetadata,
28
+ type RemoteProcessMetadata,
29
+ withRemoteProcessOwnership,
24
30
  } from "#src/plugins/pi-agent-ide-vision/src/vision.js";
25
31
 
32
+ /** Target-native capture. Registration checks opt-in and current target ownership before each frame. */
33
+ export interface CaptureOwnerAccess {
34
+ /** Capture an explicitly owned web resource; never select a local browser for it. */
35
+ captureWeb?(source: string, signal?: AbortSignal): Promise<Uint8Array>;
36
+ captureWindow(
37
+ source: string,
38
+ process: RemoteProcessMetadata,
39
+ signal?: AbortSignal,
40
+ ): Promise<Uint8Array>;
41
+ captureDisplay(source: string, index: number, signal?: AbortSignal): Promise<Uint8Array>;
42
+ }
43
+ /** Optional resource-owner metadata. Undefined means unclaimed, never a remote-to-local fallback. */
44
+ export interface ProcessOwnerAccess {
45
+ read(source: string, signal?: AbortSignal): Promise<RemoteProcessMetadata | undefined>;
46
+ list(scope: string, signal?: AbortSignal): Promise<readonly RemoteProcessMetadata[] | undefined>;
47
+ }
26
48
  /** Register process discovery and guarded visual capture resources. */
27
49
  export default async function registerVision(
28
50
  pi: ExtensionAPI,
29
51
  context?: BuiltinExtensionContext,
52
+ ): Promise<void> {
53
+ await registerVisionWithOwner(pi, context);
54
+ }
55
+
56
+ /** Register existing process and capture interfaces with optional target-owned metadata. */
57
+ export async function registerVisionWithOwner(
58
+ pi: ExtensionAPI,
59
+ context?: BuiltinExtensionContext,
60
+ processOwner?: ProcessOwnerAccess,
61
+ captureOwner?: CaptureOwnerAccess,
30
62
  ): Promise<void> {
31
63
  connectAgentDocumentation(pi, [
32
64
  await loadPackagedAgentGuide({
33
65
  id: "vision",
34
66
  description: "Window, display, image, and sequence capture",
35
- triggers: [{ tool: "read", resourcePrefixes: ["window:", "display:"] }],
67
+ triggers: [
68
+ { tool: "read", resourcePrefixes: ["process:", "window:", "display:"] },
69
+ { tool: "read", resourcePrefixes: ["web:ssh://"], viewPrefixes: ["image", "sequence"] },
70
+ ],
36
71
  }),
37
72
  ]);
38
73
  const preferences = context?.preferences ?? {};
@@ -45,6 +80,7 @@ export default async function registerVision(
45
80
  const registry = agentIdeProcessRegistry(pi);
46
81
  const backend = createCaptureBackend();
47
82
  await Promise.all([
83
+ connectDoctorPlugin(pi, visionDoctorPlugin),
48
84
  connectReadPlugin(pi, {
49
85
  protocol: READ_PROTOCOL,
50
86
  apiVersion: READ_API_VERSION,
@@ -62,6 +98,92 @@ export default async function registerVision(
62
98
  async handler(context) {
63
99
  const source = context.request.path;
64
100
  if (source === undefined) return { kind: "continue", context };
101
+ if (source.startsWith("window:ssh://") || source.startsWith("display:ssh://")) {
102
+ try {
103
+ const window = source.startsWith("window:");
104
+ const uri = new URL(source.slice(window ? "window:".length : "display:".length));
105
+ if (
106
+ uri.username ||
107
+ uri.password ||
108
+ uri.port ||
109
+ uri.search ||
110
+ (window
111
+ ? uri.hash !== "" || !/^\/[1-9][0-9]*$/u.test(uri.pathname)
112
+ : uri.pathname !== "/" || (uri.hash !== "" && !/^#\d+$/u.test(uri.hash)))
113
+ )
114
+ throw new Error(`Invalid target capture resource: ${source}`);
115
+ if (!window && pi.getFlag("pi-agent-ide-vision-displays") !== true)
116
+ return failed(
117
+ source,
118
+ "Display capture is disabled. Enable --pi-agent-ide-vision-displays to allow it.",
119
+ );
120
+ if (!captureOwner)
121
+ return failed(source, `Target capture is unavailable: ${source}`);
122
+ const index = window
123
+ ? Number(uri.pathname.slice(1))
124
+ : Number(uri.hash.slice(1) || "0");
125
+ if (!Number.isSafeInteger(index))
126
+ throw new Error(`Invalid target capture resource: ${source}`);
127
+ const content = await captureImages(
128
+ async () => {
129
+ if (!window)
130
+ return captureOwner.captureDisplay(
131
+ source,
132
+ index,
133
+ context.resolverContext.signal,
134
+ );
135
+ const processSource = `process:ssh://${uri.hostname}/${index}`;
136
+ const snapshot = await processOwner?.read(
137
+ processSource,
138
+ context.resolverContext.signal,
139
+ );
140
+ if (
141
+ !snapshot ||
142
+ snapshot.resource !== processSource ||
143
+ snapshot.pid !== index ||
144
+ snapshot.target !== uri.hostname
145
+ )
146
+ throw new Error(`Target process identity is unavailable: ${source}`);
147
+ const metadata = withRemoteProcessOwnership(snapshot, registry);
148
+ const executable = metadata.executable;
149
+ // Use the native executable, not a command-line prefix or controller PID.
150
+ if (
151
+ !metadata.owned &&
152
+ (!executable || !isNativeExecutableAllowed(executable)) &&
153
+ pi.getFlag("pi-agent-ide-vision-arbitrary-windows") !== true
154
+ )
155
+ throw new Error(
156
+ `Window capture is denied for the target executable: ${source}`,
157
+ );
158
+ return captureOwner.captureWindow(
159
+ source,
160
+ metadata,
161
+ context.resolverContext.signal,
162
+ );
163
+ },
164
+ options(context.request),
165
+ context.resolverContext.signal,
166
+ );
167
+ return returned(source, content);
168
+ } catch (error) {
169
+ return failed(source, errorMessage(error));
170
+ }
171
+ }
172
+ if (source.startsWith("web:") && requestsScreenshot(context.request)) {
173
+ try {
174
+ const captureWeb = captureOwner?.captureWeb?.bind(captureOwner);
175
+ if (!captureWeb)
176
+ return failed(source, `Target web capture is unavailable: ${source}`);
177
+ const content = await captureImages(
178
+ () => captureWeb(source, context.resolverContext.signal),
179
+ options(context.request),
180
+ context.resolverContext.signal,
181
+ );
182
+ return returned(source, content);
183
+ } catch (error) {
184
+ return failed(source, errorMessage(error));
185
+ }
186
+ }
65
187
  const displayIndex = parseDisplaySource(source);
66
188
  if (displayIndex !== undefined) {
67
189
  if (pi.getFlag("pi-agent-ide-vision-displays") !== true) {
@@ -81,6 +203,18 @@ export default async function registerVision(
81
203
  return failed(source, errorMessage(error));
82
204
  }
83
205
  }
206
+ try {
207
+ const owned = await processOwner?.read(source, context.resolverContext.signal);
208
+ if (owned)
209
+ return returned(source, [
210
+ {
211
+ type: "text",
212
+ text: formatProcess(withRemoteProcessOwnership(owned, registry)),
213
+ },
214
+ ]);
215
+ } catch (error) {
216
+ return failed(source, errorMessage(error));
217
+ }
84
218
  const processPid = prefixedPid(source, "process:");
85
219
  if (processPid !== undefined) {
86
220
  const metadata = await readProcess(processPid, registry);
@@ -130,7 +264,7 @@ export default async function registerVision(
130
264
  });
131
265
  api.describe({
132
266
  path: () =>
133
- `process:PID — process metadata. window:PID — capture a window of an IDE-owned or allowlisted process${pi.getFlag("pi-agent-ide-vision-arbitrary-windows") === true ? "; arbitrary windows are enabled" : "; other processes require --pi-agent-ide-vision-arbitrary-windows"}. display: or display:#N — display capture with a zero-based index; ${pi.getFlag("pi-agent-ide-vision-displays") === true ? "enabled" : "requires --pi-agent-ide-vision-displays"}. HTTP(S) URLs accept image or sequence screenshots.`,
267
+ `process:ssh://target/PID, window:ssh://target/PID and display:ssh://target/ select configured Linux SSH targets; missing target facilities fail without local fallback. web:ssh://target/https://… captures with target-installed Playwright/Chromium. process:PID — process metadata. window:PID — capture a window of an IDE-owned or allowlisted process${pi.getFlag("pi-agent-ide-vision-arbitrary-windows") === true ? "; arbitrary windows are enabled" : "; other processes require --pi-agent-ide-vision-arbitrary-windows"}. display: or display:#N — display capture with a zero-based index; ${pi.getFlag("pi-agent-ide-vision-displays") === true ? "enabled" : "requires --pi-agent-ide-vision-displays"}. HTTP(S) URLs accept image or sequence screenshots.`,
134
268
  views: () => {
135
269
  const defaults = getVisionDefaults();
136
270
  return `image or image:scale=S,region=X,Y,W,H — one screenshot. sequence or sequence:duration=D,interval=I,scale=S,region=X,Y,W,H — timed frames. Only one image/sequence view per request. duration and interval are seconds and only valid for sequence: 0 < D <= 10, I > 0, at most 20 frames (floor(D/I)+1). Scale satisfies 0 < S <= 1. Region uses normalized x,y,width,height: x,y >= 0, width,height > 0, and the rectangle must fit in 0..1; crop runs before scaling. Settings are optional; defaults: duration=${defaults.durationSeconds}, interval=${defaults.intervalSeconds}, scale=${defaults.scale}.`;
@@ -153,20 +287,43 @@ export default async function registerVision(
153
287
  id: "processes",
154
288
  readResources: (request) => (/^process:/iu.test(request.query) ? undefined : []),
155
289
  toScriptData(payload) {
156
- const processes = payload as Awaited<ReturnType<typeof listProcesses>>;
290
+ const processes = payload as readonly (ProcessMetadata | RemoteProcessMetadata)[];
157
291
  return {
158
292
  kind: "custom",
159
293
  resolverId: "processes",
160
294
  value: {
161
- processes: processes.map((item) => ({ pid: item.pid, command: item.command })),
295
+ processes: processes.map((item) => ({
296
+ pid: item.pid,
297
+ command: item.command,
298
+ ...(item.host === "ssh"
299
+ ? {
300
+ host: item.host,
301
+ target: item.target,
302
+ resource: item.resource,
303
+ identity: item.identity,
304
+ owned: item.owned,
305
+ parentPid: item.parentPid,
306
+ started: item.started,
307
+ executable: item.executable,
308
+ ...(item.source === undefined ? {} : { source: item.source }),
309
+ }
310
+ : {}),
311
+ })),
162
312
  },
163
313
  };
164
314
  },
165
- async tryResolve(request) {
315
+ async tryResolve(request, context) {
166
316
  const match = /^process:(.*)$/isu.exec(request.query);
167
317
  if (match === null) return { kind: "not-handled" as const };
168
318
  const query = (match[1] ?? "").trim().toLowerCase();
169
- const matches = (await listProcesses(registry))
319
+ const scope = request.path ?? context.cwd;
320
+ const remote = await processOwner?.list(scope, context.signal);
321
+ if (scope.includes("://") && remote === undefined)
322
+ throw new Error("Process scope has no resource owner");
323
+ const matches = (
324
+ remote?.map((item) => withRemoteProcessOwnership(item, registry)) ??
325
+ (await listProcesses(registry))
326
+ )
170
327
  .filter(
171
328
  (item) =>
172
329
  query.length === 0 ||
@@ -195,7 +352,7 @@ export default async function registerVision(
195
352
  );
196
353
  },
197
354
  format(payload) {
198
- const processes = payload as Awaited<ReturnType<typeof listProcesses>>;
355
+ const processes = payload as readonly (ProcessMetadata | RemoteProcessMetadata)[];
199
356
  return {
200
357
  content: [
201
358
  {
@@ -212,7 +369,7 @@ export default async function registerVision(
212
369
  },
213
370
  });
214
371
  api.describe(
215
- "process:<query> finds running processes by PID or command for process:PID metadata reads and guarded window:PID capture.",
372
+ "process:<query> finds running processes by PID or command. Select a configured Linux target with an SSH path; its results retain process:ssh://target/PID, target and kernel start identity. Use process:PID for local metadata. Use window:ssh://target/PID for authorized target capture, never window:PID with a remote PID. Discovery alone does not grant capture or process control.",
216
373
  );
217
374
  },
218
375
  }),
@@ -266,11 +423,15 @@ function failed(source: string, message: string) {
266
423
  function errorMessage(error: unknown): string {
267
424
  return error instanceof Error ? error.message : String(error);
268
425
  }
269
- function formatProcess(item: Awaited<ReturnType<typeof readProcess>>): string {
426
+ function formatProcess(item: ProcessMetadata | RemoteProcessMetadata): string {
270
427
  return [
271
428
  `PID: ${item.pid}`,
429
+ ...(item.host === "ssh"
430
+ ? [`Target: ${item.target}`, `Resource: ${item.resource}`, `Identity: ${item.identity}`]
431
+ : []),
272
432
  `Command: ${item.command}`,
273
433
  `Owned by Agent IDE: ${item.owned ? "yes" : "no"}`,
434
+ ...(item.host === "ssh" && item.executable !== null ? [`Executable: ${item.executable}`] : []),
274
435
  ...(item.parentPid === undefined ? [] : [`Parent PID: ${item.parentPid}`]),
275
436
  ...(item.started === undefined ? [] : [`Started: ${item.started}`]),
276
437
  ...(item.source === undefined ? [] : [`Agent IDE source: ${item.source}`]),
@@ -0,0 +1,47 @@
1
+ import { DOCTOR_API_VERSION, DOCTOR_PROTOCOL } from "pi-agent-doctor/api/plugin-protocol";
2
+ import type { DoctorPlugin } from "pi-agent-doctor/api/plugin-protocol";
3
+
4
+ /** Native graphics readiness only. This does not grant capture or read any pixels. */
5
+ export const visionDoctorPlugin: DoctorPlugin = {
6
+ protocol: DOCTOR_PROTOCOL,
7
+ apiVersion: DOCTOR_API_VERSION,
8
+ id: "vision",
9
+ setup(api) {
10
+ api.addCheck({
11
+ id: "target-graphics",
12
+ title: "Target screen capture readiness",
13
+ async run(context) {
14
+ // Local capture has its own platform backend; never substitute it for a target probe.
15
+ if (!context.workspace) return [];
16
+ try {
17
+ context.signal?.throwIfAborted();
18
+ if (!context.workspace.probeCapture)
19
+ throw new Error("Project owner does not provide a capture readiness probe");
20
+ const result = await context.workspace.probeCapture(context.signal);
21
+ context.signal?.throwIfAborted();
22
+ return [
23
+ {
24
+ status: result.display.ok ? "pass" : "warn",
25
+ message: "Native display connection",
26
+ detail: result.display.detail,
27
+ },
28
+ {
29
+ status: result.window.ok ? "pass" : "warn",
30
+ message: "Trusted native window identity",
31
+ detail: result.window.detail,
32
+ },
33
+ ];
34
+ } catch (error) {
35
+ context.signal?.throwIfAborted();
36
+ return [
37
+ {
38
+ status: "warn",
39
+ message: "Native capture readiness is unavailable",
40
+ detail: error instanceof Error ? error.message : String(error),
41
+ },
42
+ ];
43
+ }
44
+ },
45
+ });
46
+ },
47
+ };
@@ -49,6 +49,39 @@ export interface ProcessMetadata {
49
49
  readonly host: "local" | "windows";
50
50
  }
51
51
 
52
+ /** Target-scoped read-only process metadata; discovery alone does not grant control or capture. */
53
+ export interface RemoteProcessMetadata {
54
+ readonly pid: number;
55
+ readonly parentPid: number;
56
+ readonly command: string;
57
+ readonly started: string;
58
+ readonly identity: string;
59
+ readonly executable: string | null;
60
+ readonly owned: boolean;
61
+ readonly source?: string;
62
+ readonly host: "ssh";
63
+ readonly target: string;
64
+ readonly resource: string;
65
+ }
66
+ /** Match a read-only target snapshot to an active channel without granting ownership after PID reuse. */
67
+ export function withRemoteProcessOwnership(
68
+ metadata: RemoteProcessMetadata,
69
+ registry: AgentIdeProcessRegistry,
70
+ ): RemoteProcessMetadata {
71
+ const owner = registry
72
+ .list()
73
+ .find(
74
+ (entry) =>
75
+ entry.owned === true &&
76
+ entry.remote?.target === metadata.target &&
77
+ entry.remote.pid === metadata.pid &&
78
+ entry.remote.identity === metadata.identity &&
79
+ (entry.status === "running" || entry.status === "stopping" || entry.status === "paused"),
80
+ );
81
+ return owner
82
+ ? { ...metadata, owned: true, source: owner.source }
83
+ : { ...metadata, owned: false, source: undefined };
84
+ }
52
85
  export interface CaptureBackend {
53
86
  captureWindow(
54
87
  pid: number,
@@ -100,6 +133,10 @@ export function isExecutableAllowed(command: string): boolean {
100
133
  return allowedExecutables.has((command.includes("\\") ? windowsName : unixName).toLowerCase());
101
134
  }
102
135
 
136
+ /** Check a native target executable path without treating its filename as command-line text. */
137
+ export function isNativeExecutableAllowed(executable: string): boolean {
138
+ return allowedExecutables.has(executable.slice(executable.lastIndexOf("/") + 1).toLowerCase());
139
+ }
103
140
  /** Parses image and sequence view strings with named capture parameters. */
104
141
  export function parseVisionView(
105
142
  views: readonly string[] | undefined,
@@ -177,7 +214,11 @@ export async function listProcesses(registry: AgentIdeProcessRegistry): Promise<
177
214
  const owned = new Map(
178
215
  registry
179
216
  .list()
180
- .flatMap((process) => (process.pid === undefined ? [] : [[process.pid, process] as const])),
217
+ .flatMap((process) =>
218
+ process.remote !== undefined || process.pid === undefined
219
+ ? []
220
+ : [[process.pid, process] as const],
221
+ ),
181
222
  );
182
223
  if (process.platform !== "linux" && process.platform !== "darwin") {
183
224
  return [...owned].map(([pid, item]) => ({
@@ -11,7 +11,10 @@ import type {
11
11
  export async function runIdePostEditGate(
12
12
  transaction: TextPostEditTransaction,
13
13
  ): Promise<{ formatting: MutationFormatting } & Partial<TextPostEditStatusContribution>> {
14
- if (!path.isAbsolute(transaction.resourceSource))
14
+ if (
15
+ !path.isAbsolute(transaction.resourceSource) &&
16
+ !transaction.resourceSource.startsWith("ssh://")
17
+ )
15
18
  return { formatting: { status: "unavailable" } };
16
19
  let formatterName: string | undefined;
17
20
  try {
@@ -19,6 +19,8 @@ export interface Diagnostic {
19
19
  }
20
20
 
21
21
  export interface ToolContext {
22
+ /** Requested cancellation; implementations should check before starting work and before publishing. */
23
+ readonly signal?: AbortSignal;
22
24
  cwd: string;
23
25
  }
24
26
 
File without changes
@@ -1,7 +0,0 @@
1
- import"./chunk-3YK4XMWB.js";import{a as J,b as V,c as z,d as U,f as q}from"./chunk-T6LX2RX5.js";import{d as L,e as h}from"./chunk-M5MJP7Z2.js";import{a as E}from"./chunk-WZI4YC2O.js";import{d as N}from"./chunk-N34ATN52.js";import{a as O}from"./chunk-ZC65Z3CK.js";import{a as _,b as F,c as M}from"./chunk-JMVDFOTQ.js";import{a as d}from"./chunk-EI7MMDWY.js";import{mkdir as ie,readFile as B,writeFile as re}from"node:fs/promises";async function G(n,t){await ie(L(n),{recursive:!0});let e=[],o=t.filter(s=>s.recipe.formatter!==void 0),i=t.filter(s=>s.recipe.linter!==void 0),r=t.filter(s=>s.recipe.lsp!==void 0);if(o.length>0){let s=h(n,"formatters"),c=await S(s,{version:1,formatters:{}}),u=P(c,"formatters");for(let l of o)u[l.recipe.id]??=l.recipe.formatter;await R(s,c)&&e.push(s)}if(i.length>0){let s=h(n,"linters"),c=await S(s,{version:1,linters:{}}),u=P(c,"linters");for(let l of i)u[l.recipe.id]??=l.recipe.linter;await R(s,c)&&e.push(s)}if(r.length>0){let s=h(n,"lsp-servers"),c=await S(s,{version:1,servers:{}}),u=P(c,"servers");for(let l of r){let a=O(l.recipe.lsp);u[l.recipe.id]??={command:a.command,transport:"stdio",rootMarkers:a.rootMarkers,...a.initializationOptions!==void 0&&{initializationOptions:a.initializationOptions},...a.settings!==void 0&&{settings:a.settings},...a.requireRootMarker!==void 0&&{requireRootMarker:a.requireRootMarker},languages:Object.fromEntries(Object.entries(a.languageIds).map(([p,f])=>[p,{extensions:f,...a.fileNames?.[p]&&{fileNames:a.fileNames[p]}}])),capabilities:["diagnostics"]}}await R(s,c)&&e.push(s)}return e}d(G,"writeSuggestedConfigs");async function S(n,t){try{let e=JSON.parse(await B(n,"utf8"));if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${n} must contain an object`);return e}catch(e){if(typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT")return t;throw e}}d(S,"readObject");function P(n,t){let e=n[t];if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${t} must be an object`);return e}d(P,"objectMember");async function R(n,t){let e=`${JSON.stringify(t,null,2)}
2
- `;return await B(n,"utf8").catch(()=>{})===e?!1:(await re(n,e,"utf8"),!0)}d(R,"writeJson");var C=class{static{d(this,"DoctorCore")}plugins=new Map;languages=[];recipes=[];setupChecks=[];checks=[];queue=Promise.resolve();registerPlugin(t){let e=this.plugins.get(t.id);if(e!==void 0)return e;let o=this.queue.then(async()=>{let i=!0,r=[],s=[],c=[],u=[],l={addLanguage:d(a=>{b(a,r,t.id,"language",()=>i)},"addLanguage"),addToolRecipe:d(a=>{b(a,s,t.id,"tool recipe",()=>i)},"addToolRecipe"),addSetupCheck:d(a=>{b(a,c,t.id,"setup check",()=>i)},"addSetupCheck"),addCheck:d(a=>{b(a,u,t.id,"check",()=>i)},"addCheck")};try{await t.setup(l)}finally{i=!1}W(this.languages,r,"language"),W(this.recipes,s,"tool recipe"),this.languages.push(...r),this.recipes.push(...s),this.setupChecks.push(...c),this.checks.push(...u)});return this.plugins.set(t.id,o),this.queue=o.catch(()=>{}),o.catch(()=>{this.plugins.delete(t.id)}),o}async waitForPlugins(){await Promise.all(this.plugins.values())}snapshot(){return{languages:[...this.languages],recipes:[...this.recipes],setupChecks:[...this.setupChecks],checks:[...this.checks]}}};async function H(n,t){let e=[],o=[];for(let i of n.setupChecks)try{let r=await i.value.inspect(t);e.push(...(r.selections??[]).map(s=>({...s,pluginId:i.pluginId}))),o.push(...(r.actions??[]).map(s=>({...s,pluginId:i.pluginId})))}catch{}return{selections:e,actions:o}}d(H,"runContributedSetupChecks");async function X(n,t){let e=[];for(let o of n.checks)try{e.push({pluginId:o.pluginId,title:o.value.title,findings:await o.value.run(t)})}catch(i){e.push({pluginId:o.pluginId,title:o.value.title,findings:[{status:"fail",message:i instanceof Error?i.message:String(i)}]})}return e}d(X,"runContributedChecks");function W(n,t,e){for(let o of t){let i=n.find(r=>r.value.id===o.value.id)?.pluginId;if(i!==void 0)throw new Error(`${e} ${o.value.id} is already owned by doctor plugin ${i}`)}}d(W,"assertAvailable");function b(n,t,e,o,i){if(!i())throw new Error(`Doctor plugin ${e} setup is complete`);if(!/^[a-z0-9][a-z0-9.-]*$/u.test(n.id))throw new Error(`Invalid ${o} ID: ${n.id}`);if(t.some(r=>r.value.id===n.id))throw new Error(`Doctor plugin ${e} registered ${o} ${n.id} twice`);t.push({pluginId:e,value:n})}d(b,"add");import fe from"node:path";import{readFile as se}from"node:fs/promises";async function Y(n,t,e,o=process.env){let i=await E(n,e.map(c=>c.value)),r=await ce(n),s=[];for(let c of e){let u=c.value;if(u.languages.every(v=>!t.has(v)))continue;let l=[],a=1,p=i.get(u.id),f=p?.config;f!==void 0&&(a+=6,l.push(`project config: ${f}`)),r.has(`${u.kind}:${u.id}`)&&(a+=6,l.push("Pi Agent IDE config"));let w=p?.dependency;w!==void 0&&(a+=4,l.push(`project dependency: ${w}`));let m=await ae(n,u.executables,o);m!==void 0&&(a+=3,l.push(`executable: ${m}`)),s.push({pluginId:c.pluginId,recipe:u,score:a,evidence:l,...m&&{executable:m}})}return s.sort((c,u)=>u.score-c.score||c.recipe.id.localeCompare(u.recipe.id))}d(Y,"discoverRecipeCandidates");function K(n,t,e=[]){let o=new Map,i=new Map(e.map(r=>[`${r.kind}:${r.languageId}`,r.toolId]));for(let r of t)for(let s of["formatter","linter","lsp"]){let c=i.get(`${s}:${r}`),u=c===void 0?4:7,l=n.filter(p=>p.recipe.kind===s&&p.recipe.languages.includes(r)&&p.executable!==void 0&&p.recipe.id!==c&&p.score>=u),a=l[0];a!==void 0&&(l.filter(p=>p.score===a.score).length>1||o.set(`${a.recipe.kind}:${a.recipe.id}`,a))}return[...o.values()]}d(K,"selectSuggestedRecipes");async function ae(n,t,e){for(let o of t)if(await N(o,n,e))return o}d(ae,"firstExecutable");async function ce(n){let t=new Set;for(let[e,o,i]of[["formatters","formatters","formatter"],["linters","linters","linter"],["lsp-servers","servers","lsp"]])try{let r=JSON.parse(await se(h(n,e),"utf8"));if(typeof r!="object"||r===null||Array.isArray(r))continue;let c=r[o];if(typeof c=="object"&&c!==null&&!Array.isArray(c))for(let u of Object.keys(c))t.add(`${i}:${u}`)}catch{}return t}d(ce,"managedRecipeIds");import{execFile as de}from"node:child_process";import{readdir as ue}from"node:fs/promises";import y from"node:path";import{promisify as le}from"node:util";var pe=le(de),ge=new Set([".git",".hg",".svn","node_modules","vendor","build","dist","coverage",".cache",".next","target"]);async function Q(n,t){t?.throwIfAborted();try{let o=(await pe("git",["ls-files","--cached","--others","--exclude-standard","-z"],{cwd:n,encoding:"utf8",maxBuffer:16777216,signal:t})).stdout.split("\0").filter(Boolean).map(i=>y.resolve(n,i)).filter(i=>!ee(i));return t?.throwIfAborted(),o.length>0?o:await k(n,t)}catch{return t?.throwIfAborted(),k(n,t)}}d(Q,"collectProjectFiles");function Z(n,t,e=process.platform){let o=new Map,i=e==="win32"?y.win32:y;for(let r of t){let s=new Set(r.extensions.map(a=>a.toLowerCase())),c=d(a=>e==="win32"?a.toLowerCase():a,"normalizeName"),u=new Set(r.fileNames?.map(c)),l=n.filter(a=>!a.split(y.sep).join("/").includes("/.pi/pi-agent-ide/")&&(s.has(i.extname(a).toLowerCase())||u.has(c(i.basename(a)))));l.length>0&&o.set(r.id,l)}return o}d(Z,"detectProjectLanguages");async function k(n,t){t?.throwIfAborted();let e=[];for(let o of await ue(n,{withFileTypes:!0})){if(o.isDirectory()&&ge.has(o.name))continue;let i=y.join(n,o.name);ee(i)||(o.isDirectory()?e.push(...await k(i,t)):o.isFile()&&e.push(i))}return e}d(k,"walk");function ee(n){return n.split(y.sep).join("/").includes("/.pi/pi-agent-ide/")}d(ee,"isManagedIdeConfig");async function $(n,t,e=process.env,o){o?.throwIfAborted();let i=await Q(t,o);o?.throwIfAborted();let r=Z(i,n.languages.map(p=>p.value)),s=new Set(r.keys()),c={cwd:t,files:i,detectedLanguageIds:s,detectedLanguages:r,env:e},[u,l]=await Promise.all([Y(t,s,n.recipes,e),H(n,c)]),a=new Map;for(let p of s)for(let f of["formatter","linter","lsp"]){if(l.selections.some(g=>g.languageId===p&&g.kind===f))continue;let w=u.filter(g=>g.recipe.kind===f&&g.recipe.languages.includes(p)),m=d(g=>g.score-(g.executable===void 0?0:3),"nativeScore"),v=Math.max(1,...w.map(m));for(let g of w){if(g.executable!==void 0||m(g)!==v||v<=1)continue;let T=`${f}-${g.recipe.id}-unavailable`;a.set(T,{id:T,pluginId:g.pluginId,message:`Native project setup selects ${g.recipe.id}, but its executable is unavailable. Install ${g.recipe.executables.join(" or ")} and run Doctor again.`})}}return{cwd:t,files:i,detectedLanguages:r,candidates:u,selections:l.selections,actions:[...l.actions,...a.values()],suggestions:K(u,s,l.selections)}}d($,"inspectDoctorSetup");async function I(n,t,e=process.env){let o=await $(n,t,e),i=new Set(o.detectedLanguages.keys()),r={cwd:t,files:o.files,detectedLanguageIds:i,detectedLanguages:o.detectedLanguages,env:e},s=await X(n,r),c=[{status:"pass",message:`Project: ${t}`},o.files.length>0?{status:"pass",message:`${o.files.length} project files inspected`}:{status:"warn",message:"No project files found"},i.size>0?{status:"pass",message:`Detected: ${[...i].join(", ")}`}:{status:"warn",message:"No registered project languages detected"}];return{...o,sections:[{title:"Project",pluginId:"doctor",findings:c},...s]}}d(I,"runDoctor");function D(n){let t=["Pi Agent IDE doctor",""];for(let e of n.sections){t.push(`${e.title} (${e.pluginId})`);for(let o of e.findings)t.push(` ${o.status.toUpperCase().padEnd(4)} ${o.message}`),o.detail!==void 0&&t.push(` \`${o.detail}\``);t.push("")}if(n.actions.length>0){t.push("Setup needs attention");for(let e of n.actions)t.push(` ${e.message} [${e.pluginId}]`);t.push("")}if(n.suggestions.length>0){t.push("Suggested configuration");for(let e of n.suggestions){let o=e.evidence.length>0?` \u2014 ${e.evidence.join(", ")}`:"";t.push(` ${e.recipe.kind.padEnd(9)} ${e.recipe.id} [${e.pluginId}]${o}`)}t.push("")}return t.join(`
3
- `).trimEnd()}d(D,"formatDoctorReport");function j(n){return n.actions.length>0||n.suggestions.length>0||n.sections.some(t=>t.findings.some(e=>e.status==="fail"))}d(j,"doctorNeedsWork");function te(n){let t=n.candidates.map(e=>({owner:e.pluginId,id:e.recipe.id,kind:e.recipe.kind,languages:e.recipe.languages,evidence:e.evidence,documentation:e.recipe.documentation}));return["Finish configuring Pi Agent IDE for this project.","Preserve existing formatter, linter, compiler, and style rules. Do not invent or replace native project settings.","Do not install packages, write credentials, or change source files without the user's normal confirmation.","Pi Agent IDE project configs live in .pi/pi-agent-ide/.","Use only the relevant plugin contributions listed below; each owner remains responsible for its own scope.","",D(n),"","Relevant registered recipes:",JSON.stringify(t,null,2),"",`Project root: ${fe.resolve(n.cwd)}`].join(`
4
- `)}d(te,"buildDoctorAgentPrompt");import{createHash as me}from"node:crypto";var he="doctor",x=3;function ne(n,t){let e=_(n,ye(t));e!==void 0&&e.catch(()=>{})}d(ne,"registerDoctorTipProvider");function ye(n){return{protocol:F,apiVersion:M,id:he,async getTip(t){let e=await n(t),o=we(e);if(o.length===0)return;let i=o.slice(0,x).map(r=>`\u2022 ${r.message}`);return o.length>x&&i.push(`\u2022 ${o.length-x} more`),{id:`doctor-setup-${De(o)}`,title:o.length===1?"Project setup needs attention":`${o.length} project setup items`,body:[...i,"Run /pi-agent-ide-doctor"].join(`
5
- `)}}}}d(ye,"createDoctorTipProvider");function we(n){let t=n.actions.map(o=>({id:`action:${o.pluginId}:${o.id}`,message:o.message})),e=n.suggestions.map(o=>{let i=o.recipe.languages.filter(s=>n.detectedLanguages.has(s)).join(", "),r={debugger:"debugging",formatter:"formatting",linter:"linting",lsp:"language support"}[o.recipe.kind];return{id:`suggestion:${o.pluginId}:${o.recipe.kind}:${o.recipe.id}`,message:`Use ${o.recipe.name} for ${i} ${r}`}});return[...t,...e].sort((o,i)=>o.id.localeCompare(i.id))}d(we,"setupItems");function De(n){return me("sha256").update(n.map(t=>`${t.id}\0${t.message}`).join("\0")).digest("hex").slice(0,12)}d(De,"fingerprint");async function oe(n){let t=new C;ne(n,async i=>(await t.waitForPlugins(),$(t.snapshot(),i.cwd,process.env,i.signal)));let e,o=n.events.on(U,i=>{if(!q(i))throw new Error("Invalid doctor plugin registration request");i.accept(t.registerPlugin(i.plugin))});n.on("session_shutdown",o),n.registerCommand("pi-agent-ide-doctor",{description:"Check and configure Pi Agent IDE for this project",handler:d(async(i,r)=>{await t.waitForPlugins();let s=await I(t.snapshot(),r.cwd);A(n,D(s));let c=new Set(i.trim().split(/\s+/u).filter(Boolean));if(s.suggestions.length>0&&!c.has("--no-apply")&&(c.has("--apply")||r.hasUI&&await r.ui.confirm("Apply suggested configuration?","Add detected tools to .pi/pi-agent-ide/. Existing entries and native tool settings are kept."))){let a=await G(r.cwd,s.suggestions),p=a.length===0?"Pi Agent IDE configs are already up to date":`Updated ${a.length} Pi Agent IDE config ${a.length===1?"file":"files"}`;r.ui.notify(p,"info"),s=await I(t.snapshot(),r.cwd),A(n,D(s))}if(!j(s)&&!c.has("--agent"))return;(c.has("--agent")||r.hasUI&&await r.ui.confirm("Ask the agent to finish setup?","The agent will receive this redacted report and relevant plugin recipes."))&&(e=r.cwd,n.sendUserMessage(te(s)))},"handler")}),n.on("agent_end",async(i,r)=>{let s=e;if(s===void 0)return;e=void 0;let c=await I(t.snapshot(),s,process.env);A(n,`Doctor recheck after agent setup
6
-
7
- ${D(c)}`),j(c)?r.ui.notify("Pi Agent IDE setup still needs attention","warning"):r.ui.notify("Pi Agent IDE setup is ready","info")}),n.events.emit(z,{protocol:J,apiVersion:1}),await t.waitForPlugins()}d(oe,"registerDoctor");function A(n,t){n.sendMessage({customType:"pi-agent-ide-doctor",content:t,display:!0},{triggerTurn:!1})}d(A,"sendReport");export{oe as default};
@@ -1,3 +0,0 @@
1
- import{a as i}from"./chunk-EI7MMDWY.js";import{AsyncLocalStorage as Re}from"node:async_hooks";function se(){return{pending:new Set,active:new Re}}i(se,"createSchedulerState");function we(r,e){return r===void 0||e===void 0?!0:r.some(t=>e.some(n=>(t.mode==="write"||n.mode==="write")&&(t.resource==="*"||n.resource==="*"||t.resource===n.resource||t.recursive===!0&&n.resource.startsWith(t.resource.endsWith("/")?t.resource:`${t.resource}/`)||n.recursive===!0&&t.resource.startsWith(n.resource.endsWith("/")?n.resource:`${n.resource}/`))))}i(we,"conflicts");function Te(r,e,t){if(e===void 0||!t&&e.some(o=>o.mode!=="read"))return!1;if(r===void 0)return!0;let n=new Map;for(let o of e){let s=o.group??o.resource;n.set(s,[...n.get(s)??[],o])}return[...n.values()].every(o=>o.some(s=>r.some(a=>(s.mode==="read"||a.mode==="write")&&(a.resource==="*"||s.resource===a.resource&&(s.recursive!==!0||a.recursive===!0)||a.recursive===!0&&s.resource.startsWith(a.resource.endsWith("/")?a.resource:`${a.resource}/`)))))}i(Te,"coveredAccess");async function Se(r,e){if(e===void 0)return await r;e.throwIfAborted();let t,n=new Promise((o,s)=>{t=i(()=>s(e.reason),"abort"),e.addEventListener("abort",t,{once:!0})});try{return await Promise.race([r,n])}finally{e.removeEventListener("abort",t)}}i(Se,"waitForDependencies");var U=class r{constructor(e=se()){this.state=e}static{i(this,"ResourceScheduler")}run(e,t,n,o={}){let s=Promise.resolve(e),a=this.state.active.getStore();if(a?.open){let h=s.then(S=>{if(n?.throwIfAborted(),!Te(a.accesses,S,a.allowNestedWrites))throw Object.assign(new Error("Nested resource access must be covered by its parent reservation and permitted by its owner."),{code:"UNDECLARED_RESOURCE_ACCESS"});return S});a.nested??=new r;let y=a.nested.run(h,t,n,{allowNestedWrites:a.allowNestedWrites});return a.children.add(y),y.then(()=>a.children.delete(y),()=>a.children.delete(y)),y}let l=[...this.state.pending],u=s.catch(()=>{}),p,f=new Promise(h=>{p=h}),m={accesses:u,done:f};return this.state.pending.add(m),(async()=>{try{n?.throwIfAborted();let h=await Se(s.then(async S=>(await Promise.all(l.map(q=>Promise.race([q.done,q.accesses.then(Ce=>we(S,Ce)?q.done:void 0)]))),S)),n);n?.throwIfAborted();let y={accesses:h,children:new Set,open:!0,allowNestedWrites:o.allowNestedWrites===!0};try{return await this.state.active.run(y,t)}finally{for(;y.children.size>0;)await Promise.allSettled([...y.children]);y.open=!1}}finally{this.state.pending.delete(m),p()}})()}},be=Symbol.for("pi-agent-resource.resource-scheduler-state"),Ee=globalThis,xe=Ee[be]??=se(),Ae=new U(xe);import{realpath as Oe,stat as ke}from"node:fs/promises";import P from"node:path";import{fileURLToPath as Ne}from"node:url";async function ie(r,e,t){if(/^[a-z][a-z\d+.-]*:/iu.test(r)&&!/^[a-z]:[\\/]/iu.test(r)&&!r.startsWith("file:"))return[{resource:r,mode:t}];let n=P.resolve(e,r.startsWith("file:")?Ne(r):r),[o,s]=await Promise.allSettled([Oe(n),ke(n,{bigint:!0})]),a;if(o.status==="fulfilled")a=o.value;else{let f=o.reason;if(!(f instanceof Error)||!("code"in f)||f.code!=="ENOENT")throw f;let m=P.dirname(n);if(m===n)a=n;else{let y=(await ie(m,e,t)).find(S=>S.resource.startsWith("file:"));a=P.join(y?.resource.slice(5)??m,P.basename(n))}}let l=a.split(P.sep).join("/"),u=`file:${process.platform==="win32"?l.toLowerCase():l}`,p=[{resource:u,group:u,mode:t}];if(s.status==="fulfilled"){let f=s.value;f.isDirectory()&&(p[0]={resource:u,group:u,mode:t,recursive:!0}),f.ino!==0n&&p.push({resource:`inode:${f.dev}:${f.ino}`,group:u,mode:t,recursive:f.isDirectory()})}else{let f=s.reason;if(!(f instanceof Error)||!("code"in f)||f.code!=="ENOENT")throw f}return p}i(ie,"resourceAccesses");import{randomUUID as Pe}from"node:crypto";import{mkdir as je,mkdtemp as Ie,readFile as _e,rm as Ue,writeFile as De}from"node:fs/promises";import{tmpdir as $e}from"node:os";import ae from"node:path";var z=class{static{i(this,"TempResourceStore")}resolver;#e=new Map;#o=new Set;#n;#t;#r;constructor(e={}){this.#n=e.parentDirectory??$e(),this.resolver={id:"temp",tryResolve:i(t=>Promise.resolve(this.#c(t)),"tryResolve")}}save(e){return this.#s(e,!1)}saveFile(e){return this.#s(e,!0)}async#s(e,t){if(this.#r!==void 0)throw new Error("Temporary resource store is closed");let n=this.#i(e,t);this.#o.add(n);try{return await n}finally{this.#o.delete(n)}}dispose(){return this.#r??=this.#a(),this.#r}async#i(e,t){let n=await this.#d(),o=Pe(),s=`temp:${o}`,a=ae.join(n,`${o}.txt`);return await De(a,e,{encoding:"utf8",flag:"wx",mode:384}),t||this.#e.set(s,a),t?a:s}async#a(){await Promise.allSettled(this.#o),this.#e.clear(),this.#t!==void 0&&await Ue(await this.#t,{recursive:!0,force:!0})}#c(e){return e.startsWith("temp:")?this.#r!==void 0||!this.#e.has(e)?{kind:"failed",error:new Error(`Temporary resource ${e} does not exist in this runtime`)}:{kind:"resolved",resource:{source:e,read:i(()=>this.#u(e),"read")}}:{kind:"not-handled"}}async#u(e){let t=this.#e.get(e);if(this.#r!==void 0||t===void 0)throw new Error(`Temporary resource ${e} does not exist in this runtime`);return[{type:"text",text:await _e(t,"utf8")}]}async#d(){return this.#t??=(async()=>(await je(this.#n,{recursive:!0}),Ie(ae.join(this.#n,"pi-agent-read-"))))(),this.#t}};import{Type as g}from"typebox";import{Value as Le}from"typebox/value";var D=g.Object({code:g.String(),message:g.String(),source:g.Optional(g.String())},{additionalProperties:!1});function ce(r){return{...g.Union([g.Object({status:g.Literal("success"),data:r,errors:g.Array(D,{maxItems:0})},{additionalProperties:!1}),g.Object({status:g.Union([g.Literal("error"),g.Literal("partial")]),data:g.Optional(r),errors:g.Array(D,{minItems:1})},{additionalProperties:!1})]),type:"object",properties:{status:g.Union([g.Literal("success"),g.Literal("error"),g.Literal("partial")]),data:g.Optional(r),errors:g.Array(D)},required:["status","errors"],additionalProperties:!1}}i(ce,"structuredResultSchema");var ue=1024*1024;function J(r){let e=new Set,t=i(n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(typeof n!="object"||e.has(n))throw new TypeError("Structured data must be finite, acyclic JSON");if(!Array.isArray(n)&&Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw new TypeError("Structured data must not contain classes or raw byte buffers");e.add(n);for(let o of Array.isArray(n)?n:Object.values(n))t(o);e.delete(n)}},"visit");if(t(r),Buffer.byteLength(JSON.stringify(r))>ue)throw new RangeError("Structured data exceeds 1 MiB; return a smaller window or a full-result reference")}i(J,"assertJsonData");function de(r,e="EXECUTION_FAILED",t){return{code:typeof r=="object"&&r!==null&&"code"in r&&typeof r.code=="string"?r.code:e,message:r instanceof Error?r.message:String(r),...t===void 0?{}:{source:t}}}i(de,"resultError");function We(r,e,t){try{if(J(t),!Le.Check(ce(e),t))throw new TypeError("Result adapter returned data outside its public schema");return{...r,structuredContent:t,isError:t.status!=="success"}}catch(n){let o=de(n,"INVALID_STRUCTURED_RESULT"),s={status:"error",errors:[o]};return J(s),{...r,content:[...r.content,{type:"text",text:o.message}],structuredContent:s,isError:!0}}}i(We,"withStructuredResult");function Ve(r,e){if(e.length===0)return;let t=r.trim();if(t.length===0||/[\r\n]/u.test(t))throw new TypeError("Content provider summary must be one non-empty line");return[t,...e.map(({description:n})=>n)].join(`
2
- `)}i(Ve,"renderContentDescription");import{Type as d}from"typebox";import{Value as Ge}from"typebox/value";import{Type as c}from"typebox";import{Value as He}from"typebox/value";var v={additionalProperties:!0},j=c.Function([],c.Unknown()),C=c.String({minLength:1}),Me=c.Object({type:c.Literal("text"),text:c.String(),textSignature:c.Optional(c.String())},v),Fe=c.Object({type:c.Literal("image"),data:c.String(),mimeType:c.String()},v),Ke=c.Object({type:c.Literal("custom"),kind:C,data:c.Unknown()},v),qe=c.Array(c.Union([Me,Fe,Ke]),{minItems:1}),le=c.Union([c.Object({source:C,link:c.Optional(C),read:j,write:c.Optional(c.Never())},v),c.Object({source:C,link:c.Optional(C),read:c.Optional(c.Never()),write:j},v),c.Object({source:C,link:c.Optional(C),read:j,write:j},v)]),ze=c.Object({id:C,tryResolve:j},v),Je=c.Union([c.Object({kind:c.Literal("not-handled")},v),c.Object({kind:c.Literal("resolved"),resource:le},v),c.Object({kind:c.Literal("failed"),error:c.Unknown()},v)]);function B(r){return $(qe,r)?L(()=>r.every(e=>e.type!=="text"||!("textSignature"in e)||typeof e.textSignature=="string")):!1}i(B,"isAgentContent");function fe(r){return $(le,r)?L(()=>{let e=r,t=!("read"in e)||typeof e.read=="function",n=!("write"in e)||typeof e.write=="function";return t&&n}):!1}i(fe,"isResource");function Be(r){return $(ze,r)}i(Be,"isResourceResolver");function Ye(r){return $(Je,r)?L(()=>{let e=r;return e.kind!=="resolved"||fe(e.resource)}):!1}i(Ye,"isResourceResolutionAttempt");function $(r,e){return L(()=>He.Check(r,e))}i($,"safeCheck");function L(r){try{return r()}catch{return!1}}i(L,"safeEvaluate");var R={additionalProperties:!0},Xe=d.Function([],d.Unknown()),W=d.String({minLength:1}),Qe=d.Object({provider:W,capability:d.Union([d.Literal("read"),d.Literal("write")])},R),Ze=d.Object({source:W,bytes:d.Unknown(),mediaType:d.Optional(d.String())},R),et=d.Object({signal:d.Optional(d.Unknown())},R),tt=d.Object({id:W,description:W,tryConvert:Xe},R),rt=d.Union([d.Object({kind:d.Literal("not-handled")},R),d.Object({kind:d.Literal("converted"),content:d.Unknown()},R),d.Object({kind:d.Literal("failed"),error:d.Unknown()},R)]),nt=d.Object({target:d.Unknown(),converter:d.Unknown(),priority:d.Optional(d.Number())},R);function A(r){return O(Qe,r)&&E(()=>r.provider.trim().length>0)}i(A,"isContentTarget");function Y(r){return O(Ze,r)?E(()=>{let e=r;return e.bytes instanceof Uint8Array&&(!("mediaType"in e)||typeof e.mediaType=="string")}):!1}i(Y,"isContentInput");function G(r){return O(et,r)?E(()=>{let e=r;return!("signal"in e)||e.signal instanceof AbortSignal}):!1}i(G,"isContentConversionContext");function pe(r){return O(tt,r)?E(()=>{let e=r;return e.id.trim().length>0&&e.description.trim().length>0&&!/[\r\n]/u.test(e.description)}):!1}i(pe,"isContentConverter");function X(r){return O(rt,r)?E(()=>{let e=r;return e.kind!=="converted"||B(e.content)}):!1}i(X,"isContentConversionAttempt");function b(r){return O(nt,r)?E(()=>{let e=r;return A(e.target)&&pe(e.converter)&&(!("priority"in e)||typeof e.priority=="number"&&Number.isFinite(e.priority))}):!1}i(b,"isContentConverterRegistration");function O(r,e){return E(()=>Ge.Check(r,e))}i(O,"safeCheck");function E(r){try{return r()}catch{return!1}}i(E,"safeEvaluate");var V=class extends Error{static{i(this,"UnsupportedContentError")}source;target;constructor(e,t){super(`No content converter for ${e} in ${t.provider}/${t.capability}`),this.name="UnsupportedContentError",this.source=e,this.target=t}};function Z(r){if(!A(r))throw new TypeError("Invalid content target");let e={...r},t=[],n=i(()=>[...t].sort((o,s)=>o.priority-s.priority||o.order-s.order),"snapshotConverters");return{target:e,register(o){if(!b(o))throw new TypeError("Invalid content converter registration");if(!k(e,o.target))throw new Error(`Content converter ${o.converter.id} targets ${o.target.provider}/${o.target.capability}, not ${e.provider}/${e.capability}`);if(t.some(({converter:s})=>s.id===o.converter.id))throw new Error(`Content converter ${o.converter.id} is already registered for ${e.provider}/${e.capability}`);t.push({converter:o.converter,priority:o.priority??0,order:t.length})},listDescriptions(){return n().map(({converter:o})=>({id:o.id,description:o.description}))},async convert(o,s){if(!Y(o))throw new TypeError("Invalid content input");if(!G(s))throw new TypeError("Invalid content conversion context");Q(s.signal);let a=n();for(let{converter:l}of a){Q(s.signal);let u=await l.tryConvert(o,s);if(Q(s.signal),!X(u))throw new TypeError(`Content converter ${l.id} returned an invalid outcome`);if(u.kind!=="not-handled"){if(u.kind==="failed")throw u.error;return u.content}}throw new V(o.source,e)}}}i(Z,"createContentRunner");function k(r,e){return r.provider===e.provider&&r.capability===e.capability}i(k,"targetsEqual");function Q(r){r?.throwIfAborted()}i(Q,"throwIfAborted");import{Type as w}from"typebox";import{Value as ot}from"typebox/value";var N="pi-agent-resource/content-conversion",H=2,I=`${N}/host/ready`,_=`${N}/converter/register`,ge={additionalProperties:!0},st=w.Function([],w.Unknown()),it=w.Object({protocol:w.Literal(N),apiVersion:w.Literal(H),target:w.Unknown()},ge),at=w.Object({registration:w.Unknown(),accept:st},ge);function ee(r){return me(it,r)&&re(()=>A(r.target))}i(ee,"isContentHostReady");function te(r){return me(at,r)&&re(()=>b(r.registration))}i(te,"isContentConverterRegistrationRequest");function me(r,e){return re(()=>ot.Check(r,e))}i(me,"safeCheck");function re(r){try{return r()}catch{return!1}}i(re,"safeEvaluate");function ct(r,e){let t=Z(e),n=r.events.on(_,o=>{if(!te(o))throw new Error("Invalid content converter registration request");if(!k(t.target,o.registration.target))return;let s;try{t.register(o.registration),s=Promise.resolve()}catch(a){s=Promise.reject(a instanceof Error?a:new Error("Content converter registration failed",{cause:a}))}o.accept(s)});return r.on("session_shutdown",n),r.events.emit(I,{protocol:N,apiVersion:H,target:t.target}),{target:t.target,listDescriptions(){return t.listDescriptions()},convert(o,s){return t.convert(o,s)}}}i(ct,"createContentHost");function ut(r,e){if(!b(e))throw new TypeError("Invalid content converter registration");let t=i(()=>{let s,a={registration:e,accept(l){if(s!==void 0)throw new Error(`Content converter ${e.converter.id} registration was accepted more than once`);s=l}};return r.events.emit(_,a),s},"announce"),n=i(()=>{},"unsubscribe");n=r.events.on(I,s=>{if(!ee(s))throw new Error("Invalid content conversion host readiness event");if(!k(e.target,s.target))return;let a=t();if(a===void 0)throw new Error(`${s.target.provider}/${s.target.capability} announced readiness without accepting content converter ${e.converter.id}`);n(),a.catch(()=>{})}),r.on("session_shutdown",n);let o=t();if(o!==void 0)return n(),o}i(ut,"connectContentConverter");import{createHash as he,randomUUID as ne}from"node:crypto";import{statSync as dt}from"node:fs";import{readFile as lt}from"node:fs/promises";import T from"node:path";import{fileURLToPath as ft}from"node:url";import{Type as M}from"typebox";var pt=M.Union([M.String(),M.Array(M.String())]),x="RESULT#",ye="pi-agent-resource:result-targets",K=class{static{i(this,"ResultTargetStore")}#e=new Map;#o=new Map;#n=new Map;#t=new Map;clear(){this.#e.clear(),this.#o.clear(),this.#n.clear(),this.#t.clear()}register(e,t,n=!0){for(let s of e)this.refresh(s.source,t);let o=`${x}${ne()}`;return this.#e.set(o,{state:"ready",targets:oe(e),complete:n,cwd:T.resolve(t)}),o}reserve(e){let t=`${x}${ne()}`;return this.#e.set(t,{state:"pending",cwd:T.resolve(e)}),t}confirm(e,t,n){let o=this.#e.get(e);if(o?.state!=="pending"||o.cwd!==T.resolve(n))throw new Error("Only a pending result in this worktree can be confirmed.");for(let s of t)this.refresh(s.source,n);this.#e.set(e,{state:"ready",cwd:o.cwd,targets:oe(t),complete:!0})}reject(e,t){let n=this.#e.get(e);n?.state==="pending"&&this.#e.set(e,{state:"rejected",cwd:n.cwd,reason:t})}resolve(e,t){e=this.source(e,t);let n=this.#r(e),o=[],s=!0;for(let a of n){let l=this.#e.get(a);if(l===void 0)throw new Error("Result target expired or unknown; repeat Read/Search.");if(l.cwd!==T.resolve(t))throw new Error("Result target belongs to another worktree.");if(l.state==="pending")throw new Error("Result target is pending; its write has not been confirmed.");if(l.state==="rejected")throw new Error(l.reason);for(let u of l.targets)this.refresh(u.source,t);if(!this.#e.has(a))throw new Error("Result target expired after its snapshot changed; repeat Read/Search.");s&&=l.complete,o.push(...l.targets)}return{targets:oe(o),complete:s}}resolveOrdered(e,t){let n=this.resolve(e,t),o=[],s=new Set;for(let a of new Set(this.#r(this.source(e,t))))for(let l of this.resolve(a,t).targets)for(let u of l.ranges){let p=JSON.stringify([l.source,u]);s.has(p)||(s.add(p),o.push({...l,ranges:[u]}))}return{targets:o,complete:n.complete}}async verify(e,t){try{await ve(e,t)}catch(n){if(!t?.aborted)for(let o of e.targets)this.invalidate(o.source);throw n}}publish(e,t,n,o=[]){let s=ne();for(let p of o)this.refresh(p,n);let a=[];try{a=this.#r(e)}catch{}let l=`<system-result note="Internal reference; not part of the file. Do not edit."><uuid>${s}</uuid></system-result>
3
- ${t}`,u=e!==null&&typeof e=="object"&&"status"in e&&e.status==="success";if(u&&"data"in e){let p=e.data;if(p!==null&&typeof p=="object"&&"matches"in p&&Array.isArray(p.matches)){let f=p.matches;for(let m of f){if(m===null||typeof m!="object"||!("target"in m)||typeof m.target!="string"||!this.#e.has(m.target)||!("references"in m))continue;let h=m.references;h!==null&&typeof h=="object"&&"match"in h&&typeof h.match=="string"&&/^SEARCH#[A-F\d]+:\d+:match$/u.test(h.match)&&this.#o.set(h.match,m.target)}}}return this.#t.set(s,{cwd:T.resolve(n),digest:he("sha256").update(l).digest("hex"),consumable:u,references:a,resources:o}),l}source(e,t,n=!1){if(Array.isArray(e))return e.map(f=>this.source(f,t,n));if(typeof e!="string")return e;let o=this.#o.get(e);if(o)return this.source(o,t,n);let s=/^<system-result\b[^>]*><uuid>([a-f\d-]{36})<\/uuid><\/system-result>(?:\n|$)/u.exec(e),a=s?.[1]??(e.startsWith(x)?e.slice(x.length):e),l=/^[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}$/u.test(a);if(!s&&!l){if(e.startsWith("<system-result"))throw new Error("Invalid system result reference.");return e}let u=this.#t.get(a);if(!u&&!s&&e.startsWith(x)&&this.#e.has(e))return e;if(!u)throw new Error("Result reference expired or unknown. Run Read/Search again and use the new result.");if(u.cwd!==T.resolve(t))throw new Error("Result belongs to another worktree.");if(s&&he("sha256").update(e).digest("hex")!==u.digest)throw new Error("Result text changed; pass the original result or its UUID.");for(let f of u.resources)this.refresh(f,t);if(!this.#t.has(a))throw new Error("Result reference expired. Run Read/Search again and use the new result.");if(!u.consumable)throw new Error("Only successful source results can be consumed.");for(let f of u.references)if(!this.#e.has(f))throw this.#t.delete(a),new Error("Result reference expired. Run Read/Search again and use the new result.");if(u.references.length===1)return u.references[0];if(u.references.length>1)return u.references;let p=u.resources.length===1?u.resources[0]:void 0;if(p&&(n===!0||n==="live"&&/^(?:shell|debug):/u.test(p)))return p;throw new Error("This result has no reusable text selection.")}invalidate(e){let t=new Set;for(let[n,o]of this.#e)o.state==="ready"&&o.targets.some(s=>F(s.source,o.cwd)===e)&&(this.#e.delete(n),t.add(n));for(let[n,o]of this.#t)(o.resources.some(s=>F(s,o.cwd)===e)||o.references.some(s=>t.has(s)))&&this.#t.delete(n)}refresh(e,t){let n=F(e,t),o=JSON.stringify([T.resolve(t),n]),s=gt(e,t),a=this.#n.get(o);a&&a.stamp!==s&&this.invalidate(n),this.#n.set(o,{source:e,cwd:t,stamp:s})}refreshAll(){for(let e of[...this.#n.values()])this.refresh(e.source,e.cwd)}#r(e){if(typeof e=="string"&&e.startsWith(x))return[e];if(Array.isArray(e))return e.flatMap(n=>this.#r(n));if(e===null||typeof e!="object")throw new Error("Unsupported result input.");let t=e;if("status"in t){if(t.status!=="success")throw new Error("Only successful source results can be consumed.");return this.#r(t.data)}if(typeof t.target=="string"&&t.target.startsWith(x))return[t.target];if(t.kind==="resources"&&Array.isArray(t.resources))return this.#r(t.resources);throw new Error("This result has no supported source target; do not use preview text as a source.")}};function F(r,e){let t=r.startsWith("raw:")?r.slice(4):r;if(t.startsWith("file:"))try{return ft(t)}catch{}return T.resolve(e,t)}i(F,"sourcePath");function gt(r,e){try{let t=dt(F(r,e),{bigint:!0});return`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`}catch{return}}i(gt,"fileStamp");async function ve(r,e){let t=new Map;for(let n of r.targets){e?.throwIfAborted();let o=t.get(n.source);if(o===void 0&&(o=await lt(n.source,{encoding:"utf8",signal:e}),t.set(n.source,o)),o!==n.expectedContent)throw new Error("Result target is stale; repeat Read/Search.")}}i(ve,"verifyResultTargets");function oe(r){let e=new Map;for(let t of r){let n=e.get(t.source);if(n!==void 0&&n.expectedContent!==t.expectedContent)throw new Error("Result targets refer to different snapshots of the same source.");let o=n??{source:t.source,expectedContent:t.expectedContent,ranges:[],seen:new Set};for(let s of t.ranges){let a=JSON.stringify(s);o.seen.has(a)||(o.seen.add(a),o.ranges.push(structuredClone(s)))}e.set(t.source,o)}return[...e.values()].filter(t=>t.ranges.length>0).map(({seen:t,...n})=>({...n,ranges:n.ranges.sort((o,s)=>o.start.lineNumber-s.start.lineNumber||o.start.column-s.start.column||o.end.lineNumber-s.end.lineNumber||o.end.column-s.end.column)}))}i(oe,"combineTargets");function mt(r){let e;if(r.events.emit(ye,{accept:i(o=>{e=o},"accept")}),e!==void 0)return e;let t=new K,n=r.events.on(ye,o=>{o!==null&&typeof o=="object"&&"accept"in o&&typeof o.accept=="function"&&o.accept(t)});return r.on("session_start",()=>{t.clear()}),r.on("session_shutdown",()=>{t.clear(),n()}),t}i(mt,"connectResultTargets");export{U as a,Ae as b,ie as c,z as d,D as e,ce as f,ue as g,J as h,de as i,We as j,Ve as k,B as l,fe as m,Be as n,Ye as o,A as p,Y as q,G as r,pe as s,X as t,b as u,V as v,Z as w,k as x,N as y,H as z,I as A,_ as B,ee as C,te as D,ct as E,ut as F,pt as G,K as H,ve as I,mt as J};
@@ -1,14 +0,0 @@
1
- import{a as k,b as I,c as A}from"./chunk-QFTBY67N.js";import{j as E,k as S}from"./chunk-KVHDMIZS.js";import"./chunk-ZPT5D4VP.js";import"./chunk-KINKBPPX.js";import{a as b}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{readdir as K}from"node:fs/promises";import W from"node:path";async function T(e){let n=[],t=await K(e,{withFileTypes:!0});for(let i of t){let o=W.join(e,i.name);i.isDirectory()?n.push(...await T(o)):(i.isFile()||i.isSymbolicLink())&&n.push(o)}return n}s(T,"collectFiles");import{readFile as X}from"node:fs/promises";var v=256*1024;async function w(e){let n=await X(e);if(n.byteLength>v)throw new Error(`File exceeds the ${v}-byte AST outline limit: ${e}`);if(n.includes(0))throw new Error(`File appears to be binary and cannot be read as text: ${e}`);let t=n.toString("utf8").replaceAll(`\r
2
- `,`
3
- `),i=t.endsWith(`
4
- `)?t.slice(0,-1):t,o=i.length===0?[]:i.split(`
5
- `);return{content:t,lines:o}}s(w,"readTextFile");var H=new Set([...Object.keys(k),".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".py",".pyi",".rs",".c",".cc",".hh",".hxx",".cpp",".cxx",".h",".hpp",".json",".jsonc",".yaml",".yml",".toml"]),G=new Set([".json",".jsonc",".yaml",".yml",".toml"]),B=new Set(["class_declaration","class_definition","class_specifier","enum_declaration","enum_definition","enum_item","enum_specifier","export_statement","function_declaration","function_definition","function_item","impl_item","interface_declaration","lexical_declaration","namespace_definition","mod_item","public_field_definition","method_definition","method_signature","property_signature","field_declaration","struct_item","struct_specifier","trait_item","type_alias_declaration","type_item","variable_declaration","assignment"]),q=new Set(["module","program","source_file"]),Z=new Set(["import_declaration","import_from_statement","import_statement","use_declaration"]),M=new Set(["arrow_function","function_declaration","function_definition","function_item","function_expression","method_definition"]),z=new Set(["public_field_definition","variable_declarator","assignment"]),C=new Set(["field_identifier","identifier","property_identifier","shorthand_property_identifier_pattern","type_identifier"]);function N(e){return H.has(h.extname(e).toLowerCase())}s(N,"isSupportedOutlinePath");var L={failureLabel:"PEEK_FAILED",emptyReason:"no entries to peek.",recovery:['Call peek with { peers: [{ path: "path/to/file.ts" }, ...] }.']},J={failureLabel:"AST_OUTLINE_FAILED",emptyReason:"no AST outline was produced."};function Ce(e){return S([e],J)}s(Ce,"formatAstOutline");var R=class{constructor(n=Number.POSITIVE_INFINITY){this.maxDepth=n}static{s(this,"AstOutlineManager")}fallbackScopeManager=new A;async readFileOutline(n,t){let i=P(n,t),o=h.relative(t,i)||i;if(!N(i))throw new Error(`AST outline is not supported for ${o}.`);let r=await w(i);return this.readDocumentOutline(i,t,r.lines)}async readDocumentOutline(n,t,i,o){let r=P(n,t),c=h.relative(t,r)||r;if(!N(r))throw new Error(`AST outline is not supported for ${c}.`);let a=await I(r,t,i);if(!a)throw new Error(`No AST parser is available for ${c}.`);if(Number.isFinite(this.maxDepth)&&a.rootNode.hasError)throw new Error(`Cannot build an automatic outline from invalid syntax in ${c}.`);let u=i.join(`
6
- `);for(let d=this.maxDepth;;d-=1){let l=await this.createSourceViewBlock(a.rootNode,r,c,t,i,u,h.extname(r).toLowerCase(),void 0,void 0,d);if(o===void 0||o(l)||d<=0||!Number.isFinite(d))return l}}async formatFile(n,t){let i=P(n,t),o=h.relative(t,i)||i;if(!N(i)){let r=await w(i);return S([Q(i,o,r.lines)],L)}try{return S([await this.readFileOutline(i,t)],L)}catch(r){let c=r instanceof Error?r.message:String(r);return S([j(o,c)],L)}}async formatSymbol(n,t){let o=(await T(t)).filter(r=>N(r)).sort();for(let r of o){let c;try{c=await w(r)}catch{continue}let a;try{a=await I(r,t,c.lines)}catch{continue}if(!a)continue;let u=ne(a.rootNode,n);if(!u)continue;let d=h.relative(t,r)||r,l=await this.createSourceViewBlock(u,r,d,t,c.lines,c.content,h.extname(r).toLowerCase(),n,[`defined in: ${d}:${u.startPosition.row+1}`]);return S([l],L)}return S([j("",`symbol not found: ${n}`,"PEEK_NOT_FOUND")],L)}async createSourceViewBlock(n,t,i,o,r,c,a,u,d,l=this.maxDepth){let f=oe(n,c,a,l),m=await ee(this.fallbackScopeManager,t,o,r),x=te(m),g=f.map(y=>{let p=y.sourceLine,_=p===void 0?void 0:r[p-1]??"",O=(p===void 0?void 0:x.get(p))?.map(Y=>` <!-- ${Y} -->`).join("")??"";return E({content:y.content,...!(p===void 0||_===void 0)&&{sourceLine:{source:t,lineNumber:p,content:_}},...O.length>0&&{suffix:O}})});return{path:i,...u!==void 0&&{heading:u},...d!==void 0&&{details:d},startLine:n.startPosition.row+1,endLine:n.endPosition.row+1,totalLines:r.length,renderedLines:g}}};function Q(e,n,t){return{path:n,startLine:t.length>0?1:0,endLine:t.length,totalLines:t.length,renderedLines:t.map((i,o)=>E({content:i,sourceLine:{source:e,lineNumber:o+1,content:i}}))}}s(Q,"formatUnsupportedSourceBlock");function j(e,n,t="PEEK_FAILED"){return{path:e,startLine:0,endLine:0,totalLines:0,renderedLines:[],status:"failed",error:n,code:t}}s(j,"failedSourceViewBlock");function ee(e,n,t,i){return e.getDocumentScopes(n,t,i)}s(ee,"getOutlineScopes");function te(e){let n=new Map;for(let t of e){let i=n.get(t.startLine)??[];i.push(t.beginAnchor.value),n.set(t.startLine,i);let o=n.get(t.endLine)??[];o.push(t.endScopeAnchor.value),n.set(t.endLine,o)}return n}s(te,"buildScopeMarkers");function P(e,n){return e.startsWith("file://")?decodeURIComponent(e.slice(7)):h.isAbsolute(e)?e:h.resolve(n,e)}s(P,"resolvePath");function ne(e,n){let t,i=s(o=>{if(!t){if(B.has(o.type)&&re(o)===n){t=ie(o);return}for(let r of o.namedChildren)i(r)}},"visit");return i(e),t}s(ne,"findSymbol");function re(e){let n=e.childForFieldName("name");if(n&&C.has(n.type))return n.text;for(let t of e.namedChildren)if(C.has(t.type))return t.text;if(e.type==="lexical_declaration"||e.type==="variable_declaration")return e.namedChildren.find(o=>o.type==="variable_declarator")?.childForFieldName("name")?.text;if(e.type==="function_definition"){let t=e.childForFieldName("declarator");return t?V(t):void 0}}s(re,"getNodeName");function V(e){if(C.has(e.type))return e.text;for(let n of e.namedChildren){let t=V(n);if(t)return t}}s(V,"findNestedName");function ie(e){let n=e.parent;return n&&(n.type==="export_statement"||n.type==="decorated_definition"||n.type==="template_declaration")?n:e}s(ie,"unwrapDeclaration");function oe(e,n,t,i){let o=[];G.has(t)?$(e,t,o,i):U(e,t,o,!1,i);let r=se(n,e.startIndex),c=ae(n,e.endIndex),a=o.filter(l=>l.start>=r&&l.end<=c).sort((l,f)=>f.start-l.start),u=ce(n,r,c);for(let l of a){let f=l.start-r,m=l.end-r,x=le(l);u.splice(f,m-f,...x)}for(;u.length>0&&/\s/u.test(b(u.at(-1)).char);)u.pop();let d=[[]];for(let l of u)l.char===`
7
- `?d.push([]):b(d.at(-1)).push(l);return d.map(l=>{let f=[...new Set(l.flatMap(m=>m.sourceLine===void 0?[]:[m.sourceLine]))];return{content:l.map(m=>m.char).join(""),...f.length===1&&{sourceLine:f[0]}}})}s(oe,"renderNodeLines");function se(e,n){return e.lastIndexOf(`
8
- `,Math.max(0,n-1))+1}s(se,"lineStartAt");function ae(e,n){let t=e.indexOf(`
9
- `,n);return t===-1?e.length:t}s(ae,"lineEndAt");function ce(e,n,t){let i=e.slice(0,n).split(`
10
- `).length,o=[];for(let r=n;r<t;r+=1){let c=b(e[r]);o.push({char:c,sourceLine:i}),c===`
11
- `&&(i+=1)}return o}s(ce,"mapSourceRange");function le(e){let n=e.lineSourceLines??[],t=0,i=[];for(let o=0;o<e.text.length;o+=1){let r=b(e.text[o]),c=n[t];i.push(c===void 0?{char:r}:{char:r,sourceLine:c}),r===`
12
- `&&(t+=1)}return i}s(le,"mapReplacement");function D(e,n,t,i){return t<i||e.namedChildCount===0?!1:(n.push({start:e.startIndex,end:e.endIndex,text:"\u2026",lineSourceLines:[e.startPosition.row+1]}),!0)}s(D,"collapseDeepNode");function $(e,n,t,i,o=0){if(!D(e,t,o,i))for(let r of e.namedChildren){if(ue(r,n)){de(r)||t.push({start:r.startIndex,end:r.endIndex,text:"\u2026",lineSourceLines:[r.startPosition.row+1]});continue}$(r,n,t,i,o+1)}}s($,"collectDataReplacements");function ue(e,n){return(n===".json"||n===".jsonc"?["string","number","true","false","null"]:n===".yaml"||n===".yml"?["string_scalar","integer_scalar","float_scalar","boolean_scalar","null_scalar","block_scalar"]:["string","integer","float","boolean","date_time","offset_date_time","local_date_time","local_date","local_time"]).includes(e.type)}s(ue,"isDataScalar");function de(e){let n=e.parent;for(;n&&!n.type.endsWith("pair")&&n.type!=="pair"&&n.type!=="table";)n=n.parent;let t=n?.namedChildren[0];return t!==void 0&&t.startIndex<=e.startIndex&&t.endIndex>=e.endIndex}s(de,"isDataKey");function U(e,n,t,i,o,r=0){if(D(e,t,r,o))return;let c=Number.isFinite(o)&&e.type==="expression_statement";if(i&&!pe(e)&&!c){t.push({start:e.startIndex,end:e.endIndex,text:"\u2026",lineSourceLines:[e.startPosition.row+1]});return}if(M.has(e.type)){let a=fe(e);if(a){let u=me(a,n);t.push({start:a.startIndex,end:a.endIndex,text:u.text,lineSourceLines:u.lineSourceLines});return}}if(z.has(e.type)){let a=e.childForFieldName("value");if(a&&!M.has(a.type)){t.push({start:a.startIndex,end:a.endIndex,text:"\u2026",lineSourceLines:[a.startPosition.row+1]});return}}for(let a of e.namedChildren)U(a,n,t,q.has(e.type),o,r+1)}s(U,"collectReplacements");function pe(e){return B.has(e.type)||Z.has(e.type)||e.type==="comment"||e.type.startsWith("preproc")}s(pe,"isTopLevelInterfaceNode");function fe(e){let n=e.childForFieldName("body");return n||e.namedChildren.find(t=>t.type==="block"||t.type==="compound_statement"||t.type==="statement_block")}s(fe,"findBody");function me(e,n){let t=e.startPosition.row+1,i=e.endPosition.row+1;if(n===".py")return{text:"...",lineSourceLines:[t]};let o=e.text.split(`
13
- `),r=o[0]??"",c=o.at(-1)??"",a=r.indexOf("{"),u=c.lastIndexOf("}");if(a===-1||u===-1)return{text:"\u2026",lineSourceLines:[t]};if(o.length===1){let p=r.slice(a+1,u);return p.trim()===""?{text:e.text,lineSourceLines:[t]}:{text:r.slice(0,a+1)+F(p)+r.slice(u),lineSourceLines:[t]}}let d=r.slice(a+1),l=c.slice(0,u),f=o.slice(1,-1).some(p=>p.trim()!==""),m=d.trim()!=="",x=l.trim()!=="";if(!f&&!m&&!x)return{text:e.text,lineSourceLines:o.map((p,_)=>t+_)};let g=[],y=[];if(g.push(m?r.slice(0,a+1)+F(d):r),y.push(t),!m&&f){let p=o.slice(1,-1).find(_=>_.trim()!=="")?.match(/^\s*/u)?.[0]??"";g.push(`${p}\u2026`),y.push(void 0)}return g.push(x?F(l)+c.slice(u):c),y.push(i),{text:g.join(`
14
- `),lineSourceLines:y}}s(me,"renderBodyPlaceholder");function F(e){let n=/^\s*/u.exec(e)?.[0]??"",t=/\s*$/u.exec(e)?.[0]??"";return`${n}\u2026${t}`}s(F,"maskSegment");export{R as AstOutlineManager,Ce as formatAstOutline,N as isSupportedOutlinePath};
@@ -1,2 +0,0 @@
1
- import{e as E,f as b}from"./chunk-T7I2VX3J.js";import{d as q}from"./chunk-DZWTKF2K.js";import"./chunk-HZ5BNF3A.js";import"./chunk-NNCZYO4Q.js";import{d as S}from"./chunk-IICJXZBU.js";import{a as T}from"./chunk-BU7IZLKB.js";import{a as N,b as O}from"./chunk-S5PL5DFQ.js";import"./chunk-PS2B6THP.js";import"./chunk-6U5OU77O.js";import{e as h,f as w,g as P,h as k,i as y,l as I}from"./chunk-KVHDMIZS.js";import"./chunk-ZPT5D4VP.js";import{a as A}from"./chunk-QDLTO5PH.js";import{a as v,b as C}from"./chunk-QIK2E64R.js";import"./chunk-KINKBPPX.js";import"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import H from"node:path";var M="diagnostics",L=S({kind:"code-view",label:"Diagnostics"});async function V(r){b(r,[await E({id:"diagnostics",description:"Diagnostic resources, readiness, and verification",triggers:[{tool:"read",resourcePrefixes:["diagnostics:"]}]})]);let n,t=l((c,f,e)=>{if(n===void 0)throw new Error("IDE diagnostics are not connected");return n(c,{cwd:f,...e})},"collect"),i={protocol:v,apiVersion:4,id:"diagnostics",setup(c){n=c.readDiagnostics}},o=new WeakMap,s=new WeakMap,a=new WeakMap,u=new WeakMap,W={protocol:N,apiVersion:O,id:"diagnostics",setup(c){c.addResolver({resolver:j(t,s),renderResult:L});let f=I();c.addView({view:"diagnostics",priority:100,presenter:B(t,u)}),c.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler(e){if(e.state?.resolvedBy==="diagnostics"){let p=e.state.content[0],g=s.get(p);return g&&o.set(e.request,g),f(e)}return e.state?.contentKind==="text"&&e.request.views?.includes("diagnostics")&&a.set(e.request,e.state.text),{kind:"continue",context:e}}}),c.addHandler({stage:"post-read",handler(e){let p=o.get(e.request);if(p&&e.result)return{kind:"continue",context:e,transform:l(d=>({...d,details:{...d.details,diagnosticCheck:p}}),"transform")};let g=a.get(e.request),R=g&&u.get(g),m=e.result,_=m?.content[0];return!R||!m||_?.type!=="text"?{kind:"continue",context:e}:{kind:"continue",context:e,transform(d){let D=d.content[0];return D?.type!=="text"?d:{...d,content:[{...D,text:`${R}
2
- ${D.text}`},...d.content.slice(1)],details:{...d.details,diagnosticStatus:R}}}}}}),c.describe({path:"diagnostics:<path> \u2014 lint and language-server diagnostics with reporting tool and readiness.",views:"diagnostics \u2014 diagnostics alongside source text, with reporting tool and readiness."})}};await Promise.all([A(r,i),T(r,W)])}l(V,"registerDiagnostics");function j(r,n){return{id:"diagnostics",tryResolve(t,i){return Promise.resolve(x(t,i.cwd,r,n,{signal:i.signal,...i.audience==="script"&&{mode:"complete"}}))}}}l(j,"createDiagnosticResolver");function x(r,n,t,i,o){let s;try{s=h(r,M,n)}catch(a){return{kind:"failed",error:a}}return s===void 0?{kind:"not-handled"}:{kind:"resolved",resource:{source:w(M,s),async read(){let a=await t(s,n,o),u=P(s,a.content,a.results);return i.set(u,u.diagnosticCheck),[u]}}}}l(x,"resolveDiagnosticSource");function B(r,n){return{id:"diagnostics",async present(t,i){if(i.purpose!=="read"||!H.isAbsolute(t.source))return t;let o=i.audience==="script"&&!i.requestedViews?.includes("diagnostics");if(o&&q(t.source))return t;let s=await r(t.source,i.cwd,{signal:i.signal,...i.audience==="script"&&{mode:o?"snapshot":"complete"}}).catch(a=>{if(i.signal?.throwIfAborted(),!o)throw a});if(s===void 0||o&&s.content!==t.content)return t;if(s.content!==t.content)throw new Error("File changed during diagnostic read; read it again for current source lines.");return n.set(t,y(s.results)),k(t,s.results)}}}l(B,"createDiagnosticPresenter");export{V as default};