pi-agent-ide 0.6.0 → 0.6.2

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 (448) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +146 -68
  3. package/assets/social-preview.png +0 -0
  4. package/assets/summary/debugging.png +0 -0
  5. package/assets/summary/editing.png +0 -0
  6. package/assets/summary/read.png +0 -0
  7. package/assets/summary/search-and-replace.png +0 -0
  8. package/assets/summary/search.png +0 -0
  9. package/assets/summary/settings.png +0 -0
  10. package/assets/summary/terminal.png +0 -0
  11. package/assets/summary/thumbs/debugging.png +0 -0
  12. package/assets/summary/thumbs/editing.png +0 -0
  13. package/assets/summary/thumbs/read.png +0 -0
  14. package/assets/summary/thumbs/search-and-replace.png +0 -0
  15. package/assets/summary/thumbs/search.png +0 -0
  16. package/assets/summary/thumbs/settings.png +0 -0
  17. package/assets/summary/thumbs/terminal.png +0 -0
  18. package/assets/summary/thumbs/user_terminal.png +0 -0
  19. package/assets/summary/user_terminal.png +0 -0
  20. package/dist/chunk-3E2NTWCN.js +2 -0
  21. package/dist/chunk-7WCZOO5I.js +1 -0
  22. package/dist/chunk-CEX3VOJ7.js +2 -0
  23. package/dist/chunk-FA6BKC5Y.js +1 -0
  24. package/dist/{chunk-2527OQ4Y.js → chunk-HMLH43ZS.js} +1 -1
  25. package/dist/chunk-LVWMWWWF.js +28 -0
  26. package/dist/chunk-MPT3R4BL.js +0 -0
  27. package/dist/chunk-PZFOOHY2.js +15 -0
  28. package/dist/{chunk-HKMBQLEK.js → chunk-QDLTO5PH.js} +1 -1
  29. package/dist/{chunk-Z3VC3S2T.js → chunk-QIK2E64R.js} +1 -1
  30. package/dist/{chunk-OYWIZII6.js → chunk-S6QRG3TQ.js} +1 -1
  31. package/dist/chunk-T7CZIACQ.js +27 -0
  32. package/dist/chunk-T7I2VX3J.js +1 -0
  33. package/dist/chunk-VCTK4JSN.js +3 -0
  34. package/dist/chunk-VXD6FZP5.js +5 -0
  35. package/dist/chunk-W7CASEO3.js +1 -0
  36. package/dist/chunk-YT42LKFV.js +16 -0
  37. package/dist/entry-1.js +1 -1
  38. package/dist/entry-10.js +1 -1
  39. package/dist/entry-11.js +1 -1
  40. package/dist/entry-12.js +1 -1
  41. package/dist/entry-13.js +1 -1
  42. package/dist/entry-14.js +1 -1
  43. package/dist/entry-15.js +1 -1
  44. package/dist/entry-16.js +1 -1
  45. package/dist/entry-17.js +1 -0
  46. package/dist/entry-19.js +1 -1
  47. package/dist/entry-2.js +1 -1
  48. package/dist/entry-20.js +1 -1
  49. package/dist/entry-21.js +1 -1
  50. package/dist/entry-22.js +1 -1
  51. package/dist/entry-23.js +1 -2
  52. package/dist/entry-24.js +1 -1
  53. package/dist/entry-25.js +2 -1
  54. package/dist/entry-26.js +1 -1
  55. package/dist/entry-27.js +2 -1
  56. package/dist/entry-28.js +1 -12
  57. package/dist/entry-29.js +1 -1
  58. package/dist/entry-30.js +1 -1
  59. package/dist/entry-31.js +13 -1
  60. package/dist/entry-32.js +1 -1
  61. package/dist/entry-33.js +1 -4
  62. package/dist/entry-34.js +1 -9
  63. package/dist/entry-35.js +1 -1
  64. package/dist/entry-36.js +4 -1
  65. package/dist/entry-37.js +9 -1
  66. package/dist/entry-38.js +1 -1
  67. package/dist/entry-39.js +1 -1
  68. package/dist/entry-40.js +1 -1
  69. package/dist/entry-41.js +1 -1
  70. package/dist/entry-42.js +1 -18
  71. package/dist/entry-43.js +1 -1
  72. package/dist/entry-44.js +1 -1
  73. package/dist/entry-45.js +17 -1
  74. package/dist/entry-46.js +1 -1
  75. package/dist/entry-47.js +1 -7
  76. package/dist/entry-48.js +1 -11
  77. package/dist/entry-49.js +1 -1
  78. package/dist/entry-50.js +6 -1
  79. package/dist/entry-51.js +10 -1
  80. package/dist/entry-52.js +1 -1
  81. package/dist/entry-53.js +1 -1
  82. package/dist/entry-54.js +1 -1
  83. package/dist/entry-55.js +1 -1
  84. package/dist/entry-56.js +1 -1
  85. package/dist/entry-57.js +1 -0
  86. package/dist/entry-58.js +1 -1
  87. package/dist/entry-59.js +1 -0
  88. package/dist/entry-60.js +1 -1
  89. package/dist/entry-61.js +1 -1
  90. package/dist/entry-62.js +0 -1
  91. package/dist/entry-63.js +1 -1
  92. package/dist/entry-64.js +0 -1
  93. package/dist/entry-65.js +1 -1
  94. package/dist/entry-66.js +1 -0
  95. package/dist/entry-67.js +1 -1
  96. package/dist/entry-68.js +1 -0
  97. package/dist/entry-69.js +1 -1
  98. package/dist/entry-70.js +1 -1
  99. package/dist/entry-71.js +0 -1
  100. package/dist/entry-72.js +1 -259
  101. package/dist/entry-73.js +0 -30
  102. package/dist/entry-74.js +1 -2
  103. package/dist/entry-75.js +1 -1
  104. package/dist/entry-76.js +1 -1
  105. package/dist/entry-77.js +315 -3
  106. package/dist/entry-78.js +30 -3
  107. package/dist/entry-79.js +2 -1
  108. package/dist/entry-80.js +1 -1
  109. package/dist/entry-81.js +1 -1
  110. package/dist/entry-82.js +3 -0
  111. package/dist/entry-83.js +3 -0
  112. package/dist/entry-84.js +1 -0
  113. package/dist/entry-85.js +1 -0
  114. package/dist/entry-86.js +1 -0
  115. package/dist/entry-9.js +1 -1
  116. package/dist/pi-agent-ide.js +3 -3
  117. package/docs/agent-guides/apply.md +333 -0
  118. package/docs/agent-guides/debugger.md +5 -0
  119. package/docs/agent-guides/diagnostics.md +5 -0
  120. package/docs/agent-guides/editing.md +44 -0
  121. package/docs/agent-guides/git-changes.md +5 -0
  122. package/docs/agent-guides/json-reading.md +41 -0
  123. package/docs/agent-guides/read-resources.md +44 -0
  124. package/docs/agent-guides/search-code.md +29 -0
  125. package/docs/agent-guides/terminal.md +7 -0
  126. package/docs/agent-guides/vision.md +5 -0
  127. package/docs/configuration.md +6 -14
  128. package/docs/research/apply-read-latency.md +219 -0
  129. package/node_modules/pi-agent-doctor/package.json +6 -6
  130. package/node_modules/pi-agent-doctor/runtime/entry-23.js +1 -0
  131. package/node_modules/pi-agent-documentation/package.json +15 -0
  132. package/node_modules/pi-agent-documentation/runtime/entry-24.js +1 -0
  133. package/node_modules/pi-agent-documentation/src/index.ts +69 -0
  134. package/node_modules/pi-agent-filesystem/index.ts +0 -4
  135. package/node_modules/pi-agent-filesystem/package.json +7 -7
  136. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  137. package/node_modules/pi-agent-filesystem-jq/index.ts +134 -0
  138. package/node_modules/pi-agent-filesystem-jq/package.json +23 -0
  139. package/node_modules/pi-agent-filesystem-jq/runtime/entry-27.js +2 -0
  140. package/node_modules/pi-agent-filesystem-jq/src/jq.ts +107 -0
  141. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  142. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  143. package/node_modules/pi-agent-filesystem-text/runtime/entry-29.js +2 -0
  144. package/node_modules/pi-agent-ide-ast/package.json +12 -11
  145. package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +1 -0
  146. package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +117 -0
  147. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +20 -2
  148. package/node_modules/pi-agent-ide-changes/index.ts +8 -0
  149. package/node_modules/pi-agent-ide-changes/package.json +9 -8
  150. package/node_modules/pi-agent-ide-changes/runtime/entry-32.js +1 -0
  151. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  152. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +1 -1
  153. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  154. package/node_modules/pi-agent-ide-languages/runtime/entry-35.js +2 -0
  155. package/node_modules/pi-agent-ide-lint/index.ts +1 -1
  156. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  157. package/node_modules/pi-agent-ide-lint/runtime/entry-36.js +2 -0
  158. package/node_modules/pi-agent-ide-lint/src/command-linter.ts +17 -1
  159. package/node_modules/pi-agent-ide-lsp/index.ts +0 -3
  160. package/node_modules/pi-agent-ide-lsp/package.json +10 -10
  161. package/node_modules/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
  162. package/node_modules/pi-agent-image/package.json +3 -3
  163. package/node_modules/pi-agent-invariant/package.json +2 -2
  164. package/node_modules/pi-agent-pdf/package.json +3 -3
  165. package/node_modules/pi-agent-read/package.json +12 -11
  166. package/node_modules/pi-agent-read/runtime/entry-42.js +0 -1
  167. package/node_modules/pi-agent-read/runtime/entry-45.js +2 -0
  168. package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
  169. package/node_modules/pi-agent-read/src/core/extension.ts +16 -2
  170. package/node_modules/pi-agent-read/src/core/read-core.ts +4 -5
  171. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
  172. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +19 -12
  173. package/node_modules/pi-agent-resource/package.json +2 -2
  174. package/node_modules/pi-agent-search/package.json +8 -7
  175. package/node_modules/pi-agent-search/runtime/entry-47.js +0 -1
  176. package/node_modules/pi-agent-search/runtime/entry-48.js +1 -0
  177. package/node_modules/pi-agent-search/runtime/entry-50.js +2 -0
  178. package/node_modules/pi-agent-search/src/core/extension.ts +29 -10
  179. package/node_modules/pi-agent-search-text/package.json +17 -9
  180. package/node_modules/pi-agent-search-text/runtime/entry-53.js +1 -0
  181. package/node_modules/pi-agent-search-text/src/persisted-result.ts +9 -7
  182. package/node_modules/pi-agent-search-text/src/search-renderer.ts +10 -4
  183. package/node_modules/pi-agent-search-text/src/search-result.ts +8 -1
  184. package/node_modules/pi-agent-text/package.json +3 -3
  185. package/node_modules/pi-agent-text/runtime/entry-55.js +1 -0
  186. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  187. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-56.js +2 -0
  188. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  189. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-58.js +2 -0
  190. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  191. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-60.js +2 -0
  192. package/node_modules/pi-agent-text-editor/index.ts +15 -0
  193. package/node_modules/pi-agent-text-editor/package.json +26 -25
  194. package/node_modules/pi-agent-text-editor/runtime/entry-72.js +0 -1
  195. package/node_modules/pi-agent-text-editor/runtime/entry-73.js +1 -0
  196. package/node_modules/pi-agent-text-editor/runtime/entry-74.js +1 -0
  197. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +24 -18
  198. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +4 -2
  199. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +5 -44
  200. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +13 -5
  201. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +124 -26
  202. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +2 -6
  203. package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +186 -1
  204. package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
  205. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
  206. package/node_modules/pi-agent-text-editor/src/core/extension.ts +0 -11
  207. package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +1 -1
  208. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
  209. package/node_modules/pi-agent-text-editor-renderer/index.ts +17 -4
  210. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  211. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
  212. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
  213. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  214. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  215. package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +1 -0
  216. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  217. package/node_modules/pi-agent-tool-ui/runtime/entry-81.js +1 -0
  218. package/node_modules/pi-agent-web/package.json +7 -7
  219. package/node_modules/pi-agent-web/runtime/entry-82.js +2 -0
  220. package/node_modules/pi-agent-web-html/package.json +3 -3
  221. package/node_modules/pi-agent-web-html/runtime/entry-83.js +2 -0
  222. package/node_modules/pi-agent-web-image/package.json +4 -4
  223. package/node_modules/pi-agent-web-image/runtime/entry-84.js +2 -0
  224. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  225. package/node_modules/pi-agent-web-pdf/runtime/entry-85.js +2 -0
  226. package/node_modules/pi-agent-web-text/package.json +4 -4
  227. package/node_modules/pi-agent-web-text/runtime/entry-86.js +2 -0
  228. package/package.json +108 -44
  229. package/src/api/documentation.ts +2 -0
  230. package/src/api/plugin-protocol.ts +10 -4
  231. package/src/composite/builtin-extensions.ts +7 -0
  232. package/src/composite/extensions-config.ts +6 -0
  233. package/src/composite/module-labels.ts +5 -0
  234. package/src/composite/module-settings-store.ts +3 -0
  235. package/src/composite/module-settings.ts +39 -5
  236. package/src/composite/preferences.ts +37 -0
  237. package/src/composite/presentation.ts +14 -0
  238. package/src/composite/presets.ts +57 -0
  239. package/src/documentation/extension.ts +295 -0
  240. package/src/documentation/registry.ts +98 -0
  241. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +0 -4
  242. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  243. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  244. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +134 -0
  245. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +23 -0
  246. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-27.js +2 -0
  247. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +107 -0
  248. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  249. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-28.js +2 -0
  250. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  251. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-29.js +2 -0
  252. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-25.js +2 -0
  253. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  254. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  255. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +2 -0
  256. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  257. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-84.js +2 -0
  258. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  259. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-85.js +2 -0
  260. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  261. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-86.js +2 -0
  262. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +2 -0
  263. package/src/extensions/pi-agent-read/package.json +12 -11
  264. package/src/extensions/pi-agent-read/runtime/entry-42.js +0 -1
  265. package/src/extensions/pi-agent-read/runtime/entry-43.js +1 -0
  266. package/src/extensions/pi-agent-read/runtime/entry-45.js +2 -0
  267. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
  268. package/src/extensions/pi-agent-read/src/core/extension.ts +16 -2
  269. package/src/extensions/pi-agent-read/src/core/read-core.ts +4 -5
  270. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
  271. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +19 -12
  272. package/src/extensions/pi-agent-search/package.json +8 -7
  273. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +17 -9
  274. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +1 -0
  275. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +9 -7
  276. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +10 -4
  277. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +8 -1
  278. package/src/extensions/pi-agent-search/runtime/entry-47.js +0 -1
  279. package/src/extensions/pi-agent-search/runtime/entry-48.js +1 -0
  280. package/src/extensions/pi-agent-search/runtime/entry-49.js +1 -0
  281. package/src/extensions/pi-agent-search/runtime/entry-50.js +2 -0
  282. package/src/extensions/pi-agent-search/src/core/extension.ts +29 -10
  283. package/src/extensions/pi-agent-text-editor/index.ts +15 -0
  284. package/src/extensions/pi-agent-text-editor/package.json +26 -25
  285. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  286. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-56.js +2 -0
  287. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  288. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-57.js +1 -0
  289. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-58.js +2 -0
  290. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  291. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-59.js +1 -0
  292. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-60.js +2 -0
  293. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +17 -4
  294. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  295. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +2 -0
  296. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
  297. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
  298. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  299. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-79.js +2 -0
  300. package/src/extensions/pi-agent-text-editor/runtime/entry-72.js +0 -1
  301. package/src/extensions/pi-agent-text-editor/runtime/entry-73.js +1 -0
  302. package/src/extensions/pi-agent-text-editor/runtime/entry-74.js +1 -0
  303. package/src/extensions/pi-agent-text-editor/runtime/entry-75.js +1 -0
  304. package/src/extensions/pi-agent-text-editor/runtime/entry-76.js +1 -0
  305. package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +2 -0
  306. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +24 -18
  307. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +4 -2
  308. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +5 -44
  309. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +13 -5
  310. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +124 -26
  311. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +2 -6
  312. package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +186 -1
  313. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
  314. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
  315. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +0 -11
  316. package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +1 -1
  317. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
  318. package/src/pi-agent-ide.ts +7 -10
  319. package/src/plugins/pi-agent-ide-ast/package.json +12 -11
  320. package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +1 -0
  321. package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +117 -0
  322. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +20 -2
  323. package/src/plugins/pi-agent-ide-changes/index.ts +8 -0
  324. package/src/plugins/pi-agent-ide-changes/package.json +9 -8
  325. package/src/plugins/pi-agent-ide-changes/runtime/entry-32.js +1 -0
  326. package/src/plugins/pi-agent-ide-debugger/index.ts +44 -14
  327. package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +10 -1
  328. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +39 -0
  329. package/src/plugins/pi-agent-ide-debugger/src/ui.ts +42 -5
  330. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +9 -4
  331. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  332. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +1 -1
  333. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  334. package/src/plugins/pi-agent-ide-languages/runtime/entry-35.js +2 -0
  335. package/src/plugins/pi-agent-ide-lint/index.ts +1 -1
  336. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  337. package/src/plugins/pi-agent-ide-lint/runtime/entry-36.js +2 -0
  338. package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +17 -1
  339. package/src/plugins/pi-agent-ide-lsp/index.ts +0 -3
  340. package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
  341. package/src/plugins/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
  342. package/src/plugins/pi-agent-ide-terminal/index.ts +27 -2
  343. package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +27 -2
  344. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +88 -12
  345. package/src/plugins/pi-agent-ide-terminal/src/screen-image.ts +6 -2
  346. package/src/plugins/pi-agent-ide-terminal/src/search.ts +0 -3
  347. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +7 -4
  348. package/src/plugins/pi-agent-ide-vision/index.ts +10 -7
  349. package/src/plugins/pi-agent-ide-vision/src/vision.ts +17 -3
  350. package/assets/gallery/apply-editing.png +0 -0
  351. package/assets/gallery/debugging.png +0 -0
  352. package/assets/gallery/read-web.png +0 -0
  353. package/assets/gallery/search-replace.png +0 -0
  354. package/assets/gallery/terminal.png +0 -0
  355. package/assets/gallery/tool-editing.png +0 -0
  356. package/dist/chunk-22CLOM2D.js +0 -1
  357. package/dist/chunk-3XJ3KDPZ.js +0 -16
  358. package/dist/chunk-526E364R.js +0 -3
  359. package/dist/chunk-DDKHZZDO.js +0 -5
  360. package/dist/chunk-EJ5OACQM.js +0 -1
  361. package/dist/chunk-HSM6R7IB.js +0 -27
  362. package/dist/chunk-PCZH7GOX.js +0 -26
  363. package/dist/chunk-SQ7ZTGOP.js +0 -2
  364. package/dist/entry-18.js +0 -1
  365. package/node_modules/pi-agent-doctor/runtime/entry-18.js +0 -1
  366. package/node_modules/pi-agent-filesystem/runtime/entry-23.js +0 -2
  367. package/node_modules/pi-agent-filesystem-image/runtime/entry-24.js +0 -2
  368. package/node_modules/pi-agent-ide-ast/runtime/entry-27.js +0 -1
  369. package/node_modules/pi-agent-ide-changes/runtime/entry-29.js +0 -1
  370. package/node_modules/pi-agent-ide-changes/runtime/entry-30.js +0 -2
  371. package/node_modules/pi-agent-ide-languages/runtime/entry-32.js +0 -2
  372. package/node_modules/pi-agent-image/runtime/entry-35.js +0 -1
  373. package/node_modules/pi-agent-invariant/runtime/entry-36.js +0 -1
  374. package/node_modules/pi-agent-pdf/runtime/entry-37.js +0 -1
  375. package/node_modules/pi-agent-search/runtime/entry-45.js +0 -1
  376. package/node_modules/pi-agent-search-text/runtime/entry-48.js +0 -2
  377. package/node_modules/pi-agent-text/runtime/entry-50.js +0 -1
  378. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-53.js +0 -2
  379. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-55.js +0 -2
  380. package/node_modules/pi-agent-text-editor/runtime/entry-56.js +0 -1
  381. package/node_modules/pi-agent-text-editor/runtime/entry-58.js +0 -1
  382. package/node_modules/pi-agent-text-editor/runtime/entry-60.js +0 -1
  383. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-73.js +0 -2
  384. package/node_modules/pi-agent-text-editor-renderer/src/config.ts +0 -73
  385. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +0 -2
  386. package/node_modules/pi-agent-web-pdf/runtime/entry-80.js +0 -2
  387. package/node_modules/pi-agent-web-text/runtime/entry-81.js +0 -2
  388. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-24.js +0 -2
  389. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-25.js +0 -2
  390. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-23.js +0 -2
  391. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-78.js +0 -2
  392. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-79.js +0 -2
  393. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-80.js +0 -2
  394. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-81.js +0 -2
  395. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-77.js +0 -2
  396. package/src/extensions/pi-agent-read/runtime/entry-38.js +0 -1
  397. package/src/extensions/pi-agent-read/runtime/entry-39.js +0 -1
  398. package/src/extensions/pi-agent-read/runtime/entry-40.js +0 -1
  399. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +0 -2
  400. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-49.js +0 -1
  401. package/src/extensions/pi-agent-search/runtime/entry-45.js +0 -1
  402. package/src/extensions/pi-agent-search/runtime/entry-46.js +0 -1
  403. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-53.js +0 -2
  404. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-55.js +0 -2
  405. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-73.js +0 -2
  406. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/config.ts +0 -73
  407. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +0 -2
  408. package/src/extensions/pi-agent-text-editor/runtime/entry-56.js +0 -1
  409. package/src/extensions/pi-agent-text-editor/runtime/entry-57.js +0 -1
  410. package/src/extensions/pi-agent-text-editor/runtime/entry-58.js +0 -1
  411. package/src/extensions/pi-agent-text-editor/runtime/entry-59.js +0 -1
  412. package/src/extensions/pi-agent-text-editor/runtime/entry-60.js +0 -1
  413. package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +0 -1
  414. package/src/plugins/pi-agent-ide-ast/runtime/entry-28.js +0 -2
  415. package/src/plugins/pi-agent-ide-changes/runtime/entry-29.js +0 -1
  416. package/src/plugins/pi-agent-ide-changes/runtime/entry-30.js +0 -2
  417. package/src/plugins/pi-agent-ide-languages/runtime/entry-32.js +0 -2
  418. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem}/runtime/entry-25.js +0 -0
  419. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-image}/runtime/entry-26.js +0 -0
  420. /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-pdf}/runtime/entry-28.js +0 -0
  421. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
  422. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
  423. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-34.js +0 -0
  424. /package/node_modules/{pi-agent-read → pi-agent-image}/runtime/entry-38.js +0 -0
  425. /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-39.js +0 -0
  426. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-40.js +0 -0
  427. /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-43.js +0 -0
  428. /package/node_modules/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
  429. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-46.js +0 -0
  430. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-49.js +0 -0
  431. /package/node_modules/{pi-agent-text-anchor-constant → pi-agent-search-text}/runtime/entry-51.js +0 -0
  432. /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-search-text}/runtime/entry-52.js +0 -0
  433. /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-search-text}/runtime/entry-54.js +0 -0
  434. /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-exact}/runtime/entry-57.js +0 -0
  435. /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-59.js +0 -0
  436. /package/node_modules/{pi-agent-tool-call-interception → pi-agent-text-editor}/runtime/entry-75.js +0 -0
  437. /package/node_modules/{pi-agent-tool-ui → pi-agent-text-editor}/runtime/entry-76.js +0 -0
  438. /package/node_modules/{pi-agent-web → pi-agent-text-editor}/runtime/entry-77.js +0 -0
  439. /package/node_modules/{pi-agent-web-html → pi-agent-text-editor-renderer}/runtime/entry-78.js +0 -0
  440. /package/node_modules/{pi-agent-web-image → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
  441. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-image}/runtime/entry-26.js +0 -0
  442. /package/src/extensions/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
  443. /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-constant → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-51.js +0 -0
  444. /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-exact → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-52.js +0 -0
  445. /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-54.js +0 -0
  446. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
  447. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
  448. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-34.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.2 — 2026-09-18
4
+
5
+ ### Debugging and terminals
6
+
7
+ - Let agents evaluate expressions in the selected stopped debugger frame and show the result directly in the debugger UI.
8
+ - Add timed image sequences for live terminal resources, including configurable duration, frame interval, and scale.
9
+
10
+ ### Search and vision
11
+
12
+ - Render structural AST search results with the same grouped files, match highlighting, context, and compact expansion behavior as ordinary text search, while preserving exact `SEARCH#` references for agents.
13
+ - Route Agent IDE-owned Linux application windows through native Linux capture under WSL instead of treating their PIDs as Windows-host processes.
14
+
15
+ ## 0.6.1 — 2026-09-17
16
+
17
+ ### Progressive guidance
18
+
19
+ - Add addressable `docs:` resources for focused debugger, diagnostics, editing, Git, JSON, reading, search, terminal, and vision guidance.
20
+ - Stop the first matching tool call before execution, return its complete guide, and let the agent retry with the required instructions in context. Explicitly reading the guide first skips this gate.
21
+ - Keep shell commands for execution and direct agents to guarded editing tools instead of shell-based file edits.
22
+
23
+ ### JSON reading
24
+
25
+ - Add parameterized `jq:` views for filtering and transforming filesystem JSON with the real `jq` executable.
26
+ - Apply normal Read pagination to transformed JSON output and return clear parser and execution failures.
27
+
28
+ ### Apply
29
+
30
+ - Add composable selection sets for slicing occurrences, combining non-overlapping ranges, limiting candidates to scopes, and expanding matches to complete lines.
31
+ - Add zero-width start, end, before, and after destinations for inserting copied or moved text without replacing existing content.
32
+ - Add symmetric global and document mutation forms, document-scoped flush checkpoints, and deletion through opened document handles.
33
+ - Separate the complete Apply scripting reference from the lighter standalone editing guide and prefer content boundaries over unverified line ranges.
34
+ - Make batched standalone edits the default for independent, predetermined changes in one or several files; reserve Apply scripts for computed, conditional, or transactional workflows.
35
+ - Speed up large Apply transactions by batching text operations while preserving snapshot guards and per-operation outcomes.
36
+
37
+ ### Tool behavior and presentation
38
+
39
+ - Require project evidence before running built-in formatters, so an installed formatter no longer changes files in an otherwise unconfigured workspace.
40
+ - Add Full IDE and Text Editor capability presets, with explicit module choices layered on top.
41
+ - Add Full, Compact, and Disabled presentation modes for Apply previews, diffs, Read, Search, and terminal output.
42
+ - Bound compact Read rendering for large results so the terminal stays responsive without reducing the content available to the agent.
43
+
3
44
  ## 0.6.0 — 2026-09-16
4
45
 
5
46
  ### Agent vision
package/README.md CHANGED
@@ -4,109 +4,175 @@
4
4
 
5
5
  <h1 align="center">Pi Agent IDE</h1>
6
6
 
7
- <p align="center">Pi Agent IDE is an agent-native IDE extension for the <a href="https://pi.dev/">Pi coding agent</a>. It adds guarded editing, code search, AST/LSP navigation, persistent terminals, debugging, transactional changes, and observability tools.</p>
7
+ <p align="center">Give your Pi agent a real IDE: one semantic interface for understanding, changing, running, debugging, and observing software.</p>
8
8
 
9
- <p align="center">
10
- <a href="https://www.npmjs.com/package/pi-agent-ide"><img src="https://img.shields.io/npm/v/pi-agent-ide" alt="npm version"></a>
11
- <a href="https://www.npmjs.com/package/pi-agent-ide"><img src="https://img.shields.io/npm/dm/pi-agent-ide" alt="npm downloads"></a>
12
- <a href="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml"><img src="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI status"></a>
13
- <a href="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Falexshpunt%2F0d28d39557e2a9976c4548e7737c102d%2Fraw%2Funit.json" alt="Unit test count"></a>
14
- <a href="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Falexshpunt%2F0d28d39557e2a9976c4548e7737c102d%2Fraw%2Fintegration.json" alt="Integration test count"></a>
15
- <a href="https://huggingface.co/spaces/alexshpunt/benchmark-explorer?card=harness%3Api-agent-ide%40latest"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fhuggingface.co%2Fdatasets%2Falexshpunt%2Fexplicit-edit-benchmark%2Fresolve%2Fmain%2Fbadges%2Fpi-agent-ide.json" alt="Explicit Edit Benchmark score"></a>
16
- <a href="./LICENSE"><img src="https://img.shields.io/npm/l/pi-agent-ide" alt="MIT license"></a>
17
- </p>
9
+ <div align="center">
10
+
11
+ [![npm version](https://img.shields.io/npm/v/pi-agent-ide)](https://www.npmjs.com/package/pi-agent-ide)
12
+ [![npm downloads](https://img.shields.io/npm/dm/pi-agent-ide)](https://www.npmjs.com/package/pi-agent-ide)
13
+ [![CI status](https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml)
14
+ [![MIT license](https://img.shields.io/npm/l/pi-agent-ide)](./LICENSE)
15
+
16
+ </div>
17
+
18
+ <div align="center">
19
+
20
+ [![Unit test count](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Falexshpunt%2F0d28d39557e2a9976c4548e7737c102d%2Fraw%2Funit.json)](https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml)
21
+ [![Integration test count](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Falexshpunt%2F0d28d39557e2a9976c4548e7737c102d%2Fraw%2Fintegration.json)](https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml)
22
+
23
+ </div>
24
+
25
+ <div align="center">
26
+
27
+ [![Explicit Edit Benchmark score](https://img.shields.io/endpoint?url=https%3A%2F%2Fhuggingface.co%2Fdatasets%2Falexshpunt%2Fexplicit-edit-benchmark%2Fresolve%2Fmain%2Fbadges%2Fpi-agent-ide.json)](https://huggingface.co/spaces/alexshpunt/benchmark-explorer?card=harness%3Api-agent-ide%40latest)
28
+
29
+ </div>
18
30
 
19
31
  ## Summary
20
32
 
21
- Pi Agent IDE is a set of agent-facing tools built to give a coding agent the same practical capabilities that a programmer expects from an IDE.
33
+ Pi Agent IDE gives the [Pi coding agent](https://pi.dev/) a unified set of first-class development tools. Each tool represents an intent instead of one particular implementation. The agent uses the same small set of semantic interfaces across files, source code, terminals, debuggers, web pages, images, processes, application windows, and displays.
22
34
 
23
- There are two common views of coding agents. One says that an agent only needs a shell and can build everything else for itself. The other says that useful tooling makes an agent more effective. Both are partly right. Stronger models can often make precise edits and recover with little help. Smaller models are more likely to lose context, choose an unsafe edit, or fail on the mechanics of the task. Pi Agent IDE gives models direct tools without taking the shell away.
35
+ The interfaces are designed to combine. A search result can become an edit selection. A running process can become a terminal, debugger, or visual resource. A source read can expose anchors, syntax, diagnostics, or language-server information without sending the agent through a separate workflow for each capability.
24
36
 
25
- The project started as another take on hash-based editing. It later brought back edits by exact string occurrence, with every occurrence checked before a change is applied. The result is a hybrid approach rather than one required selection method.
37
+ ### Read anything through `read`
26
38
 
27
- ## Gallery
39
+ `read` is one interface for inspecting:
28
40
 
29
- | Read and guarded tool editing | Transactional Apply |
30
- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
31
- | ![Reading source with anchors, then replacing, inserting, and deleting guarded selections](assets/gallery/tool-editing.png) | ![A multi-step file edit staged and committed through Apply](assets/gallery/apply-editing.png) |
32
- | Web reading | Search and replace |
33
- | ![Reading a web page through the unified read interface](assets/gallery/read-web.png) | ![Searching local code and reusing the returned match in replace](assets/gallery/search-replace.png) |
34
- | Background processes | Source-level debugging |
35
- | ![A long-running terminal command continuing in the background process view](assets/gallery/terminal.png) | ![Setting a breakpoint, inspecting locals, stepping, and continuing a debugger session](assets/gallery/debugging.png) |
41
+ - files, directories, source code, and raw bytes;
42
+ - JSON transformed through real `jq` filters;
43
+ - web pages, PDFs, images, and image sequences;
44
+ - diagnostics and Git changes;
45
+ - terminal and debugger sessions;
46
+ - running processes, application windows, and full displays.
36
47
 
37
- ## Core principles
48
+ Views change how the same resource is presented. The agent can request source structure, editable anchors, diagnostics, an image, a sequence, or another supported projection without learning a separate tool for every source.
38
49
 
39
- ### One interface for each intent
50
+ <div align="center">
40
51
 
41
- The agent should express what it wants to do without choosing a different tool for every implementation behind it.
52
+ [![Pi Agent IDE read examples](assets/summary/thumbs/read.png)](assets/summary/read.png)
42
53
 
43
- `read` is the main interface to the environment. It reads text, source code, raw bytes, web pages, images, PDFs, terminal sessions, debugger sessions, diagnostics, running processes, application windows, and full displays. The same interface can ask for AST structure, language-server information, anchors, or other views. The agent chooses the information it needs while the parsing, conversion, and resource handling stay behind one facade.
54
+ </div>
44
55
 
45
- `search` follows the same rule. It searches files, text, symbols, syntax trees, and supported live resources through one interface.
56
+ ### Find anything through `search`
46
57
 
47
- Editing tools state concrete intentions such as `write`, `replace`, `insert`, `delete`, `copy`, and `move`. Simple edits use guarded operations that verify the selected text or resource. Independent edits can be submitted together as a tool-call batch. For conditional or multi-file work, `apply` gives the agent isolated JavaScript over immutable file snapshots and the same guarded editing model, then validates and commits the staged changes as one transaction. This lets models use scripts for complex work without reducing an edit to an unchecked rewrite.
58
+ `search` provides one interface for paths, exact text, regular expressions, AST patterns, symbols, references, code relationships, process discovery, and retained terminal output. Results are reusable guarded references, so the agent can find an intended target once and pass that selection directly to `read` or an editing tool.
48
59
 
49
- ### IDE tools
60
+ <div align="center">
50
61
 
51
- The shell remains available, but it behaves like part of an IDE. The agent can start long-running and interactive processes, leave them in the background, reconnect after an extension reload, and receive completion or stale-process notifications. Aborting an agent turn does not kill the process.
62
+ [![Pi Agent IDE search examples](assets/summary/thumbs/search.png)](assets/summary/search.png)
52
63
 
53
- Debugger sessions are also addressable resources. The agent can set breakpoints, inspect source and variables, step through a program, and reconnect after a reload. Formatting, diagnostics, AST views, language-server views, terminal output, and debugger state work through the same resource model. This support is currently focused on Linux and WSL.
64
+ </div>
54
65
 
55
- Agent vision uses that resource model instead of adding a separate screenshot workflow. The agent can discover a process, inspect its metadata, read an application window, capture a full display, or render a web page through `read`. Image and sequence views support downscaling, normalized regions, and grid-cell selection, so the model can inspect a useful area without loading every source pixel. Window and display access is guarded by ownership, executable allowlists, and separate opt-in settings.
66
+ ### Express edits as intentions
56
67
 
57
- ### Extensible by protocol
68
+ Editing uses direct semantic operations:
58
69
 
59
- The visible tools stay small because their internals are protocols. HTTP reads, filesystem reads, terminal and debugger resources, file formats, AST views, language-server views, converters, search backends, anchors, formatters, and diagnostics can be added or replaced independently.
70
+ - `write` creates a file or deliberately replaces its complete contents;
71
+ - `replace` changes selected text;
72
+ - `insert` adds text around a selection;
73
+ - `delete` removes selected text or a resource;
74
+ - `copy` and `move` duplicate or relocate text and files;
75
+ - `undo` restores an edit or a complete transaction.
60
76
 
61
- The goal is simple primitives on the outside and composable complexity on the inside. New capabilities should extend an existing intent-shaped interface instead of adding another one-off tool.
77
+ Independent edits can be submitted together as a tool-call batch. Conditional and multi-file work uses Apply, a code mode that exposes the same guarded operations through transactional JavaScript. Diffing and staging are first-class tools too.
62
78
 
63
- ### Make recovery cheap
79
+ <div align="center">
64
80
 
65
- Agents can edit through exact strings, hash anchors, search results, AST matches, and language-server symbols. If one method fails, the tool explains why, shows the available alternatives, and points the agent to a more precise method. The goal is not to punish a bad selection with stricter guardrails. Smaller models will make mistakes. Recovery should cost as little time and context as possible.
81
+ [![Pi Agent IDE editing examples](assets/summary/thumbs/editing.png)](assets/summary/editing.png)
66
82
 
67
- The tools are designed to combine. A common flow is `search` followed by `replace`: the agent finds the intended occurrences, then edits all selected matches in one guarded operation. The same model supports structural changes and renames through search, AST, and LSP without requiring a separate workflow for each one.
83
+ </div>
68
84
 
69
- ### Observability
85
+ Selections can come from exact text, anchors, search results, AST matches, or language-server symbols. Stale, ambiguous, and failed operations do not apply silently. If one selection method is a poor fit, the agent can recover through another without throwing away the rest of its work.
70
86
 
71
- Powerful agents still need to be observable. A person should be able to see whether the harness is efficient, whether the agent is solving the real task, which tools fit its work, and where weak points or corner cases appear.
87
+ <div align="center">
72
88
 
73
- This is more than presentation. Observable behavior provides the evidence that drives tool design, regression fixes, and benchmark work.
89
+ [![Searching and replacing through guarded selections](assets/summary/thumbs/search-and-replace.png)](assets/summary/search-and-replace.png)
74
90
 
75
- ### Data-driven development
91
+ </div>
76
92
 
77
- Daily use and judgement still matter, but features should not be built on vibes alone. Changes are measured on real tasks to find where agents fail, which model families work better or worse with the tools, and how Pi Agent IDE compares with other harnesses.
93
+ ### Run through persistent terminal sessions
78
94
 
79
- The [Explicit Edit Benchmark](https://github.com/alexshpunt/explicit-edit-benchmark) was created for this purpose. It measures how easily agents can use editing tools on exact, deterministic tasks. These tasks are especially useful for smaller models and models with limited reasoning, where tool design has a larger effect on reliability.
95
+ The terminal is a first-class cross-platform interface. The agent can run commands, keep interactive sessions and background tasks alive across turns and extension reloads, read retained output, send exact input or named keys, and inspect terminal applications through images and sequences.
80
96
 
81
- Version 0.5.1 scores **93.8%** on `gpt-5.6-luna` with low reasoning: 224 of the 226 tasks solved
82
- in the end, 208 of them on the first attempt. The full observation, including the two tasks it
83
- did not solve, is in the [published data](https://huggingface.co/datasets/alexshpunt/explicit-edit-benchmark).
97
+ <div align="center">
84
98
 
85
- Agent results are stochastic and no benchmark captures everything. We publish the score we actually get and build broader statistics instead of selecting only favorable runs.
99
+ [![Running and interacting with a persistent terminal session](assets/summary/thumbs/terminal.png)](assets/summary/terminal.png)
86
100
 
87
- Pi Agent IDE is experimental and under active development. Interfaces and behavior may change.
101
+ </div>
88
102
 
89
- ## Customization
103
+ ### Debug programs interactively
90
104
 
91
- Pi Agent IDE follows Pi's permissive, YOLO-style default: the agent can use the tools without asking for approval at every step. You can make it as strict as your work requires.
105
+ Debugger sessions use the same resource model. The agent can set breakpoints, inspect stack frames and variables, evaluate expressions, step through execution, and return to a running session later.
92
106
 
93
- - [Settings](./docs/configuration.md) control built-in tools, project mappings, search, and presentation.
94
- - [File hooks](./docs/user-hooks.md) can inspect, change, or deny reads and edits.
95
- - [Extensions](./docs/extensions.md) can add or replace protocols, resolvers, anchors, search backends, and other behavior.
107
+ <div align="center">
108
+
109
+ [![Setting breakpoints, inspecting locals, and stepping through a debugger session](assets/summary/thumbs/debugging.png)](assets/summary/debugging.png)
110
+
111
+ </div>
112
+
113
+ ### See the environment
114
+
115
+ The agent can render websites as images, observe changing interfaces over time, and inspect windows opened by its own processes. Arbitrary windows and full displays require separate explicit opt-in settings. Images can be downscaled, limited to normalized regions, or divided into grid cells so the model receives the useful area instead of every source pixel.
116
+
117
+ ### Keep context focused through progressive disclosure
118
+
119
+ Pi Agent IDE does not load every capability guide into the system prompt. Detailed instructions are disclosed when the agent first uses the relevant tool and remain available as readable documentation through `read`.
120
+
121
+ The agent receives the complete contract when it needs it. Unrelated capabilities do not consume context throughout the rest of the task, and large results remain progressively readable instead of flooding the context or terminal.
122
+
123
+ ### Extend the interfaces through protocols
124
+
125
+ Filesystem and HTTP reads, resource views, content converters, search backends, anchors, formatters, diagnostics, terminals, and debugger resources are independent protocols behind the public tools. Extensions can add or replace those capabilities without creating another one-off interface for the agent. See [Writing extensions](./docs/extensions.md).
126
+
127
+ ### Observe the work and recover cheaply
128
+
129
+ A person can see the agent's edits, diffs, diagnostics, running processes, debugger state, and failures. Bounded presentation keeps live output readable without discarding the underlying result. Guarded snapshots and first-class undo make mistakes visible and recovery inexpensive.
130
+
131
+ <div align="center">
132
+
133
+ [![User-facing process view for active terminal sessions](assets/summary/thumbs/user_terminal.png)](assets/summary/user_terminal.png)
134
+
135
+ </div>
136
+
137
+ ### Work across languages and platforms
138
+
139
+ Built-in debugger recipes cover C, C++, C#, Dart, Elixir, Go, Java, JavaScript, Julia, Kotlin, Lua, PHP, PowerShell, Python, R, Ruby, Rust, shell scripts, Swift, TypeScript, and Zig. Formatting, linting, AST, language-server, and debugger support follows the tools and configuration available in each project.
140
+
141
+ Windows and WSL are first-class supported environments alongside Linux. Run `/pi-agent-ide-doctor` to see the exact capabilities available on the current machine.
142
+
143
+ ### Built through data-driven development
144
+
145
+ Pi Agent IDE is developed through daily use on real software and measured with the [Explicit Edit Benchmark](https://github.com/alexshpunt/explicit-edit-benchmark). Every release is exercised against real editing tasks, and the measured result becomes part of the release evidence. The badge above links to the [latest accepted observation](https://huggingface.co/spaces/alexshpunt/benchmark-explorer?card=harness%3Api-agent-ide%40latest), with its score and run details; the underlying observations are available in the [published dataset](https://huggingface.co/datasets/alexshpunt/explicit-edit-benchmark).
146
+
147
+ The project is also used to develop itself. Weak interactions, missing affordances, and agent failure modes appear in real work instead of remaining theoretical. Problems are fixed as they are found, and the tools evolve through regular releases.
148
+
149
+ Pi Agent IDE is experimental and under active development. Interfaces and behavior may change.
96
150
 
97
151
  ## Installation
98
152
 
99
- Install [Pi](https://pi.dev/) first, then install Pi Agent IDE:
153
+ Install [Pi](https://pi.dev/) first, then install Pi Agent IDE from npm:
100
154
 
101
155
  ```bash
102
156
  pi install npm:pi-agent-ide
103
157
  ```
104
158
 
159
+ Or install it directly from GitHub:
160
+
161
+ ```bash
162
+ pi install git:github.com/alexshpunt/pi-agent-ide
163
+ ```
164
+
165
+ To pin a Git installation, append a release tag or commit. To try the package for one session without adding it to your settings:
166
+
167
+ ```bash
168
+ pi -e npm:pi-agent-ide
169
+ ```
170
+
105
171
  Pi packages run with your full system permissions. Review the package before installing it.
106
172
 
107
173
  ## Check project tools
108
174
 
109
- Pi Agent IDE includes formatter, linter, LSP, and debugger mappings. It finds each tool from the project that owns the file, including project-local binaries and commands on your `PATH`. Settings from one project do not leak into another.
175
+ Pi Agent IDE includes formatter, linter, LSP, and debugger mappings. It discovers each tool from the project that owns the file, including project-local binaries and commands on your `PATH`. Settings from one project do not leak into another.
110
176
 
111
177
  Start Pi in your project directory, then run:
112
178
 
@@ -114,30 +180,42 @@ Start Pi in your project directory, then run:
114
180
  /pi-agent-ide-doctor
115
181
  ```
116
182
 
117
- Doctor checks the effective project, global, and built-in mappings. It reports each applicable ID, its source layer and command, and the real probe result. It also checks AST support, search, and Git.
183
+ Doctor reports the effective project, global, and built-in mappings, their source layers and commands, and the real probe results. It also checks AST support, search, Git, and optional Chrome or Chromium support for browser-rendered web reads.
118
184
 
119
185
  Doctor shows its report before changing anything. If project evidence points to a different installed tool, it can write a project-only override under `.pi/pi-agent-ide/`. It never changes global or built-in configuration. Native files such as `eslint.config.js`, `.clang-format`, and `pyproject.toml` remain unchanged.
120
186
 
121
- Doctor also reports optional system Chrome/Chromium support for browser-rendered web reads. When setup still needs work, you can ask the agent to finish it; doctor runs the checks again afterward.
187
+ Run `/pi-agent-ide-doctor` again after installing or changing project tools. For configuration paths, precedence, and command flags, see [Configuration](./docs/configuration.md#doctor).
188
+
189
+ ## Customization
190
+
191
+ Pi Agent IDE follows Pi's permissive, YOLO-style default: the agent can use the tools without asking for approval at every step. You can make it as strict as your work requires.
192
+
193
+ - [Settings](./docs/configuration.md) control built-in tools, project mappings, search, vision, and presentation.
194
+ - [File hooks](./docs/user-hooks.md) can inspect, change, or deny reads and edits.
195
+ - [Extensions](./docs/extensions.md) can add or replace protocols, resolvers, views, anchors, search backends, and other behavior.
196
+
197
+ <div align="center">
198
+
199
+ [![Agent IDE settings](assets/summary/thumbs/settings.png)](assets/summary/settings.png)
122
200
 
123
- Run doctor again after installing or changing project tools. For configuration paths, precedence, and command flags, see [Configuration](./docs/configuration.md#doctor).
201
+ </div>
124
202
 
125
203
  ## Feedback and contributions
126
204
 
127
- Pi Agent IDE is used actively in real development, but I can only reproduce the models, tools, environments, and workflows available to me. Everyone works differently, and I cannot find or cover every case on my own. I can fix problems when I encounter them or when someone reports them.
205
+ Pi Agent IDE is used actively in real development, but I can only reproduce the models, tools, environments, and workflows available to me. Everyone works differently, and I cannot find or cover every case on my own.
128
206
 
129
- If something breaks, behaves badly, or does not fit your workflow, please [open an issue](https://github.com/alexshpunt/pi-agent-ide/issues). Bug reports, ideas, and questions are welcome. Pull requests are welcome too. Every contribution will be considered, and I am fully open to making the project much better with help from its users.
207
+ If something breaks, behaves badly, or does not fit your workflow, please [open an issue](https://github.com/alexshpunt/pi-agent-ide/issues). Bug reports, ideas, questions, and pull requests are welcome.
130
208
 
131
209
  ## Documentation
132
210
 
133
- | Document | Contents |
134
- | ------------------------------------------ | -------------------------------------------------------------------- |
135
- | [Tools and workflow](./docs/tools.md) | Read, vision, search, editing, anchors, and feedback |
136
- | [Architecture](./docs/architecture.md) | Module boundaries, protocols, and the umbrella extension |
137
- | [Configuration](./docs/configuration.md) | Run doctor, configure project tools and search, or disable built-ins |
138
- | [File hooks](./docs/user-hooks.md) | Inspect, change, or deny reads and edits |
139
- | [Writing extensions](./docs/extensions.md) | Add resolvers, anchors, search backends, and IDE plugins |
140
- | [Development](./docs/development.md) | Work from a checkout, test, and run modular mode |
211
+ | Document | Contents |
212
+ | ------------------------------------------ | ------------------------------------------------------------------------------------ |
213
+ | [Tools and workflow](./docs/tools.md) | Read, vision, search, editing, anchors, and feedback |
214
+ | [Architecture](./docs/architecture.md) | Module boundaries, protocols, and the umbrella extension |
215
+ | [Configuration](./docs/configuration.md) | Run `/pi-agent-ide-doctor`, configure project tools and search, or disable built-ins |
216
+ | [File hooks](./docs/user-hooks.md) | Inspect, change, or deny reads and edits |
217
+ | [Writing extensions](./docs/extensions.md) | Add resolvers, views, anchors, search backends, and IDE plugins |
218
+ | [Development](./docs/development.md) | Work from a checkout, test, and run modular mode |
141
219
 
142
220
  ## License
143
221
 
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ import{e as A,f as E}from"./chunk-T7I2VX3J.js";import{d as q}from"./chunk-FEDVTZJG.js";import"./chunk-O6LE42GK.js";import"./chunk-NNCZYO4Q.js";import{d as T}from"./chunk-VCTK4JSN.js";import"./chunk-YHUTTZC6.js";import{a as O}from"./chunk-6CZO43OH.js";import{a as b,b as N}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{e as m,f as h,g as w,h as P,i as k,l as y}from"./chunk-NTYXZ3EL.js";import"./chunk-5VSE5X5R.js";import{a as C}from"./chunk-QDLTO5PH.js";import{a as I,b as v}from"./chunk-QIK2E64R.js";import"./chunk-KINKBPPX.js";import"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import W from"node:path";var M="diagnostics",_=T({kind:"code-view",label:"Diagnostics"});async function S(r){E(r,[await A({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"),s={protocol:I,apiVersion:4,id:"diagnostics",setup(c){n=c.readDiagnostics}},o=new WeakMap,i=new WeakMap,a=new WeakMap,d=new WeakMap,V={protocol:b,apiVersion:N,id:"diagnostics",setup(c){c.addResolver({resolver:H(t,i),renderResult:_});let f=y();c.addView({view:"diagnostics",priority:100,presenter:j(t,d)}),c.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler(e){if(e.state?.resolvedBy==="diagnostics"){let g=e.state.content[0],u=i.get(g);return u&&o.set(e.request,u),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 g=o.get(e.request);if(g&&e.result)return{kind:"continue",context:{...e,result:{...e.result,details:{...e.result.details,diagnosticCheck:g}}}};let u=a.get(e.request),D=u&&d.get(u),p=e.result,R=p?.content[0];return!D||!p||R?.type!=="text"?{kind:"continue",context:e}:{kind:"continue",context:{...e,result:{...p,content:[{...R,text:`${D}
2
+ ${R.text}`},...p.content.slice(1)]}}}}}),c.describe('diagnostics:<path> \u2014 lint and language-server diagnostics. views: ["diagnostics"] \u2014 diagnostics alongside source text. Results identify their reporting tool and readiness; pending results and snapshots are not completed checks.')}};await Promise.all([C(r,s),O(r,V)])}l(S,"registerDiagnostics");function H(r,n){return{id:"diagnostics",tryResolve(t,s){return Promise.resolve(L(t,s.cwd,r,n,{signal:s.signal,...s.audience==="script"&&{mode:"complete"}}))}}}l(H,"createDiagnosticResolver");function L(r,n,t,s,o){let i;try{i=m(r,M,n)}catch(a){return{kind:"failed",error:a}}return i===void 0?{kind:"not-handled"}:{kind:"resolved",resource:{source:h(M,i),async read(){let a=await t(i,n,o),d=w(i,a.content,a.results);return s.set(d,d.diagnosticCheck),[d]}}}}l(L,"resolveDiagnosticSource");function j(r,n){return{id:"diagnostics",async present(t,s){if(s.purpose!=="read"||!W.isAbsolute(t.source))return t;let o=s.audience==="script"&&!s.requestedViews?.includes("diagnostics");if(o&&q(t.source))return t;let i=await r(t.source,s.cwd,{signal:s.signal,...s.audience==="script"&&{mode:o?"snapshot":"complete"}}).catch(a=>{if(s.signal?.throwIfAborted(),!o)throw a});if(i===void 0||o&&i.content!==t.content)return t;if(i.content!==t.content)throw new Error("File changed during diagnostic read; read it again for current source lines.");return n.set(t,k(i.results)),P(t,i.results)}}}l(j,"createDiagnosticPresenter");export{S as default};
@@ -0,0 +1 @@
1
+ import{a as c}from"./chunk-EI7MMDWY.js";import f from"node:path";import{pathToFileURL as p}from"node:url";function g(e,t){let o=new Map;for(let r of e){let n=o.get(r.source)??[];n.push(r),o.set(r.source,n)}let i=new Set,a=e.length,s=[...o].sort(([r,n],[h,u])=>u.length-n.length||r.localeCompare(h));for(let[r,n]of s){if(a<=t)break;i.add(r),a-=n.length}return{files:[...o].sort(([r],[n])=>r.localeCompare(n)).map(([r,n])=>{if(!i.has(r))return{kind:"detailed",source:r,matches:n};let h=new Map;for(let u of n)h.set(u.lineText,(h.get(u.lineText)??0)+1);return{kind:"compacted",source:r,matchCount:n.length,uniqueLineCount:h.size,groups:o.size===1?[...h].sort(([u,y],[b,C])=>C-y||u.localeCompare(b)).slice(0,t).map(([u,y])=>({text:u,matchCount:y})):[]}})}}c(g,"planSearchPresentation");function F(e,t,o,i,a,s=50){let r=g(t,s).files.map(n=>n.kind==="detailed"?x(n.source,n.matches,i):{path:S(n.source,i),link:p(n.source).href,matchCount:n.matchCount,uniqueLineCount:n.uniqueLineCount,groups:n.groups,lines:[]});return{...a!==void 0&&{sessionId:a},query:e,matchCount:t.length,fileCount:r.length,complete:o,files:r}}c(F,"createSearchToolDetails");function I(e){if(!d(e)||typeof e.query!="string"||!m(e.matchCount)||!m(e.fileCount)||typeof e.complete!="boolean"||e.sessionId!==void 0&&typeof e.sessionId!="string"||!Array.isArray(e.files)||!e.files.every(R))return!1;let t=e.files;return e.fileCount===t.length&&e.matchCount===t.reduce((o,i)=>o+i.matchCount,0)}c(I,"isSearchToolDetails");function x(e,t,o){let i=new Map;for(let s of t){let l=i.get(s.lineNumber);if(l!==void 0&&l.text!==s.lineText)throw new Error(`Search results disagree about line ${String(s.lineNumber)} in ${e}.`);let r=l??{lineNumber:s.lineNumber,text:s.lineText,ranges:[]};r.ranges.push({from:s.startColumn,to:s.endColumn}),i.set(s.lineNumber,r)}let a=[...i.values()].sort((s,l)=>s.lineNumber-l.lineNumber).map(s=>{let l=[...s.ranges].sort((r,n)=>r.from-n.from||r.to-n.to);return{lineNumber:s.lineNumber,text:s.text,matchCount:l.length,ranges:l}});return{path:S(e,o),link:p(e).href,matchCount:t.length,lines:a}}c(x,"createSearchResultFile");function R(e){if(!d(e)||typeof e.path!="string"||typeof e.link!="string"||!m(e.matchCount)||!Array.isArray(e.lines)||!e.lines.every(M))return!1;let t=e.lines,o=e.groups,i=new Set(t.flatMap(a=>a.logicalMatchIds??[]));return(o===void 0||Array.isArray(o)&&o.every(a=>d(a)&&typeof a.text=="string"&&m(a.matchCount)))&&(e.uniqueLineCount===void 0||m(e.uniqueLineCount))&&(t.length===0||(i.size>0?i.size===e.matchCount:e.matchCount===t.reduce((a,s)=>a+s.matchCount,0)))}c(R,"isSearchResultFile");function M(e){return d(e)&&Number.isSafeInteger(e.lineNumber)&&e.lineNumber>=1&&typeof e.text=="string"&&m(e.matchCount)&&Array.isArray(e.ranges)&&e.ranges.length===e.matchCount&&(e.logicalMatchIds===void 0||Array.isArray(e.logicalMatchIds)&&e.logicalMatchIds.every(t=>typeof t=="string"))&&e.ranges.every(t=>k(t,e.text))}c(M,"isSearchResultLine");function k(e,t){return d(e)&&Number.isSafeInteger(e.from)&&Number.isSafeInteger(e.to)&&e.from>=0&&e.to>e.from&&e.to<=t.length}c(k,"isSearchResultRange");function d(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}c(d,"isRecord");function m(e){return Number.isSafeInteger(e)&&e>=0}c(m,"isCount");function S(e,t){let o=f.relative(t,e);return o.length>0&&!o.startsWith("..")&&!f.isAbsolute(o)?o:e}c(S,"displaySource");export{g as a,F as b,I as c};
@@ -0,0 +1,2 @@
1
+ import{c as R}from"./chunk-7WCZOO5I.js";import{t as y,u as T}from"./chunk-5VSE5X5R.js";import{a as x}from"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import L from"node:path";import{keyText as D}from"@earendil-works/pi-coding-agent";import{Text as F,truncateToWidth as f,visibleWidth as u,wrapTextWithAnsi as O}from"@earendil-works/pi-tui";function $(e){return e.replaceAll("\u27E6","").replaceAll("\u27E7","")}l($,"sourceText");function w(e,t){let{files:r,...n}=e,a=$(t);return{...n,storedFiles:r.map(({lines:s,...o})=>({...o,lines:s.map(i=>{let d=[i.lineNumber,y(i.text,a),i.ranges];return i.logicalMatchIds===void 0?d:[...d,i.logicalMatchIds]})}))}}l(w,"compactSearchDetails");function C(e,t){if("files"in e)return e;let{storedFiles:r,...n}=e,a=$(t);return{...n,files:r.map(({lines:s,...o})=>({...o,lines:s.map(([i,d,c,m])=>({lineNumber:i,text:T(d,a),ranges:c,matchCount:c.length,...m===void 0?{}:{logicalMatchIds:m}}))}))}}l(C,"restoreSearchDetails");var M=new WeakMap,g=12,W={".ts":{label:"TS",color:"accent"},".tsx":{label:"TX",color:"accent"},".js":{label:"JS",color:"warning"},".jsx":{label:"JX",color:"warning"},".json":{label:"{}",color:"warning"},".md":{label:"MD",color:"mdHeading"},".py":{label:"PY",color:"accent"},".rs":{label:"RS",color:"accent"},".go":{label:"GO",color:"accent"},".css":{label:"CS",color:"accent"},".html":{label:"<>",color:"accent"}};function Z(e,t,r,n){if(typeof e.details=="object"){let o=M.get(e.details);o===void 0&&(o=C(e.details,e.content.flatMap(i=>i.type==="text"?[i.text]:[]).join(`
2
+ `)),M.set(e.details,o)),e={...e,details:o}}if(t.isPartial||n.isError||!R(e.details)){let o=e.content[0],i=o?.type==="text"?o.text:"",d=n.isError?"error":t.isPartial?"dim":"toolOutput";return new F(r.fg(d,i),0,0)}let s=(n.lastComponent instanceof S?n.lastComponent:void 0)??new S(e.details,r,t.expanded);return s.update(e.details,r,t.expanded),s}l(Z,"renderSearchResult");var S=class{constructor(t,r,n){this.details=t;this.theme=r;this.expanded=n}static{l(this,"SearchResultPanel")}cached;update(t,r,n){this.details===t&&this.theme===r&&this.expanded===n||(this.details=t,this.theme=r,this.expanded=n,this.invalidate())}render(t){if(this.cached?.width===t)return this.cached.lines;if(t<4){let c=[f(k(this.details),Math.max(1,t))];return this.cached={width:t,lines:c},c}let r=t-2,n=v(this.details,this.expanded),a=G(this.details.files),s=n.flatMap(c=>A(c,r,a,this.theme)),o=P(s,this.expanded,r,this.theme),i=[I(this.details,r,this.theme),...o];i.push(this.theme.fg("borderMuted",`\u2570${"\u2500".repeat(r)}\u256F`));let d=i.map(c=>f(c,t));return this.cached={width:t,lines:d},d}invalidate(){this.cached=void 0}};function v(e,t){let r=e.files.length===0?[{kind:"empty"}]:e.files.flatMap(o=>[{kind:"file",file:o},...o.uniqueLineCount===void 0?o.lines.map(i=>({kind:"line",file:o,line:i})):[{kind:"summary",text:`${String(o.uniqueLineCount)} unique line texts \xB7 search this path with a narrower query`},...(o.groups??[]).map(i=>({kind:"summary",text:`\xD7${String(i.matchCount)} ${i.text}`}))]]);if(t||r.length<=g)return r;let n=r.slice(0,g-1);for(;n.at(-1)?.kind==="file";)n.pop();let a=new Set(n.flatMap(o=>o.kind==="line"?o.line.logicalMatchIds??[]:[])),s=a.size>0?a.size:n.reduce((o,i)=>o+(i.kind==="line"?i.line.matchCount:0),0);return[...n,{kind:"omitted",matches:Math.max(0,e.matchCount-s)}]}l(v,"searchViewport");function P(e,t,r,n){if(t||e.length<=g)return e;let a=`${D("app.tools.expand")} to expand`,s=h(n.fg("dim",` \u2026 output truncated \xB7 ${a}`),r,n);return[...e.slice(0,g-1),s]}l(P,"compactRenderedRows");function A(e,t,r,n){if(e.kind==="file")return[h(B(e.file,t,n),t,n,!0)];if(e.kind==="line")return j(e.line,t,r,n);if(e.kind==="summary")return[h(n.fg("dim",` ${p(e.text)}`),t,n)];if(e.kind==="omitted"){let a=`${D("app.tools.expand")} to expand`;return[h(n.fg("dim",` \u2026 ${String(e.matches)} more ${b(e.matches,"match","matches")} \xB7 ${a}`),t,n)]}return[h(n.fg("dim"," No matches found"),t,n)]}l(A,"renderPanelRow");function B(e,t,r){let n=N(e.path,r),a=r.fg("accent",r.bold(String(e.matchCount))),s=u(n)+u(a)+4,o=Math.max(1,t-s),i=H(e.path,o),d=q(i,e.link,r),c=` ${n} ${d}`,m=" ".repeat(Math.max(1,t-u(c)-u(a)-1));return f(`${c}${m}${a} `,t)}l(B,"renderFileHeader");function j(e,t,r,n){let a=String(e.lineNumber).padStart(r),s=` ${n.fg("dim",a)} ${n.fg("borderMuted","\u2502")} `,o=Math.max(1,t-u(s)-1),i=O(E(e,n),o),d=" ".repeat(u(s));return i.map((c,m)=>h(`${m===0?s:d}${c}`,t,n))}l(j,"renderMatchLine");function E(e,t){let r="",n=0;for(let a of e.ranges){a.from>n&&(r+=t.fg("toolOutput",p(e.text.slice(n,a.from))));let s=p(e.text.slice(a.from,a.to));r+=t.bg("selectedBg",t.fg("accent",t.bold(s))),n=a.to}return n<e.text.length&&(r+=t.fg("toolOutput",p(e.text.slice(n)))),r}l(E,"renderHighlightedLine");function I(e,t,r){let n=l(o=>r.fg("borderMuted",o),"frame"),a=f(` ${k(e)} `,Math.max(0,t-1),""),s="\u2500".repeat(Math.max(0,t-u(a)-1));return`${n("\u256D\u2500")}${r.fg("accent",a)}${n(`${s}\u256E`)}`}l(I,"renderTopBorder");function k(e){return e.matchCount===0?"No matches":`${`${String(e.matchCount)}${e.complete?"":"+"}`} ${b(e.matchCount,"match","matches")} in ${String(e.fileCount)} ${b(e.fileCount,"file","files")}`}l(k,"searchSummary");function h(e,t,r,n=!1){let a=f(e,t),s=`${a}${" ".repeat(Math.max(0,t-u(a)))}`,o=n?r.bg("selectedBg",s):s,i=r.fg("borderMuted","\u2502");return`${i}${o}${i}`}l(h,"framed");function N(e,t){let r=L.extname(e).toLowerCase(),n=W[r]??{label:"\u25C7 ",color:r.length===0?"muted":"accent"};return t.fg(n.color,t.bold(n.label))}l(N,"fileBadge");function q(e,t,r){let n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),a=n===-1?"":e.slice(0,n+1),s=n===-1?e:e.slice(n+1),o=r.fg("muted",a)+r.underline(r.fg("accent",s));return t.includes("\x07")||t.includes("\x1B")?o:`\x1B]8;;${t}\x07${o}\x1B]8;;\x07`}l(q,"fileLink");function H(e,t){return u(e)<=t?e:t<=1?"\u2026":`\u2026${e.slice(-(t-1))}`}l(H,"truncatePath");function p(e){let t="";for(let r of e){if(r===" "){t+=" ".repeat(4);continue}let n=x(r.codePointAt(0));t+=n<32||n===127?"\uFFFD":r}return t}l(p,"safeText");function G(e){let t=1;for(let r of e)for(let n of r.lines)t=Math.max(t,n.lineNumber);return Math.max(3,String(t).length)}l(G,"maximumLineNumberWidth");function b(e,t,r){return e===1?t:r}l(b,"plural");export{w as a,Z as b,S as c};
@@ -0,0 +1 @@
1
+ import{d as s}from"./chunk-S3ZPXWX7.js";import{a as o}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as i}from"typebox/value";import{Type as n}from"typebox";var l=n.Object({path:n.Optional(n.String({description:"What to read: a supported resource such as a file or directory path, URL, returned temp: reference, SEARCH# reference, or registered protocol source. Supply a path; an empty call cannot select a source."})),offset:n.Optional(n.Number({description:"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor or a SEARCH selection, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit."})),limit:n.Optional(n.Number({description:"For raw: sources, use a non-negative byte count (0 reads no bytes). Otherwise, maximum lines from the selected starting position. Output is bounded; omit for the default read. For image and sequence views, limit is the square grid cell size in pixels; omit offset to select cell 0, or omit both for the bounded full image."})),views:n.Optional(n.Array(n.String(),{description:`Optional source-specific presentations. Combine views when both presentations are needed, for example ["anchors", "ast"]. Omit for the source's default presentation.`}))});var a=e.Function([],e.Unknown()),u=e.Object({resolver:e.Unknown(),matchesCall:e.Optional(a),renderCall:e.Optional(a),priority:e.Optional(e.Number()),renderResult:e.Optional(a),preserveTruncatedOutput:e.Optional(e.Boolean())}),R=e.Object({resolver:e.Unknown(),priority:e.Optional(e.Number())}),c=e.Object({id:e.String({pattern:"\\S"}),priority:e.Optional(e.Number()),resolve:a}),y=e.Object({view:e.String({pattern:"\\S"}),includes:e.Optional(e.Array(e.String({pattern:"\\S"}))),presenter:e.Object({id:e.String(),present:a}),priority:e.Optional(e.Number())}),p=e.Object({resolvedBy:e.String({pattern:"\\S"}),contentKind:e.Union([e.Literal("text"),e.Literal("any")])}),g=e.Union([e.Object({stage:e.Literal("pre-read"),handler:a}),e.Object({stage:e.Literal("read"),when:p,handler:a}),e.Object({stage:e.Literal("post-read"),handler:a})]);function h(r){if(!i.Check(R,r))return!1;let t=r,d=t.resolver;return typeof d.id=="string"&&d.id.length>0&&typeof d.tryResolve=="function"&&(!("priority"in t)||typeof t.priority=="number")}o(h,"isTextTargetResolverRegistration");function O(r){if(!i.Check(u,r))return!1;let t=r;return s(t.resolver)?t.resolver.id!=="any"&&(!("priority"in t)||typeof t.priority=="number")&&(!("matchesCall"in t)||typeof t.matchesCall=="function")&&(!("renderCall"in t)||typeof t.renderCall=="function")&&"matchesCall"in t=="renderCall"in t&&(!("renderResult"in t)||typeof t.renderResult=="function"):!1}o(O,"isResourceResolverRegistration");function S(r){return i.Check(g,r)}o(S,"isReadHandlerRegistration");function C(r){return i.Check(y,r)}o(C,"isReadViewRegistration");function k(r){return i.Check(c,r)}o(k,"isFragmentResolverRegistration");function P(r){return m(r)?r.kind==="not-handled"?!0:r.kind==="failed"?typeof r.message=="string"&&r.message.length>0:r.kind==="resolved"&&typeof r.originLine=="number":!1}o(P,"isReadFragmentResolution");function m(r){return typeof r=="object"&&r!==null}o(m,"isRecord");export{l as a,h as b,O as c,S as d,C as e,k as f,P as g};
@@ -1,4 +1,4 @@
1
- import{a as j,m as M}from"./chunk-FEDVTZJG.js";import{a as _}from"./chunk-L7JMDDSD.js";import{a as N,b as O}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import{a as C,b as R,c as A,d as $,g as F}from"./chunk-Z3VC3S2T.js";import{a as k}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";var h=[],y=[],P=[];function b(n,t,e){if(t.some(i=>i.name===e))throw new Error(`[pi-agent-ide] ${n} "${e}" is already registered. Use a unique name.`)}c(b,"assertUniqueName");function q(n){let t=new Set;for(let e of n){let i=`${e.kind}:${e.name}`;if(t.has(i))throw new Error(`[pi-agent-ide] ${e.kind} "${e.name}" is registered twice by one plugin.`);switch(t.add(i),e.kind){case"compiler":{b(e.kind,y,e.name);break}case"formatter":{b(e.kind,h,e.name);break}case"linter":{b(e.kind,P,e.name);break}}}for(let e of n)switch(e.kind){case"compiler":{y.push(e);break}case"formatter":{h.push(e);break}case"linter":{P.push(e);break}}}c(q,"registerTools");async function L(n,t){let e=[];for(let i of n)try{await i.detect(t)&&e.push(i)}catch(o){console.error(`[pi-agent-ide] detect failed for "${i.name}":`,o)}return e.sort((i,o)=>o.priority-i.priority),H(e),e}c(L,"filterActive");function H(n){let t=new Map;for(let e of n)for(let i of e.extensions){let o=`${i}@${e.priority}`,a=t.get(o);if(a!==void 0)throw new Error(`[pi-agent-ide] priority conflict: tools "${a}" and "${e.name}" both claim "${i}" at priority ${e.priority}.`);t.set(o,e.name)}}c(H,"assertNoPriorityConflicts");async function G(n){let[t,e]=await Promise.all([L(h,n),L(y.filter(i=>i.syntaxOnly===!0),n)]);return{ctx:n,formatters:t,compilers:e,linters:[]}}c(G,"warmupFormatting");function T(){h.length=0,y.length=0,P.length=0}c(T,"resetRegistry");import{readFile as D}from"node:fs/promises";import g from"node:path";var v=class{constructor(t,e={}){this.sources=t;this.options=e}static{c(this,"DiagnosticStore")}files=new Map;dirty=new Set;sent=new Map;queue=[];running=0;disposed=!1;changeListeners=new Set;onDidChange(t){return this.changeListeners.add(t),()=>this.changeListeners.delete(t)}schedule(t,e,{cwd:i}){this.disposed||this.ensure(t,e,i)}async read(t,{cwd:e,mode:i,signal:o}){o?.throwIfAborted(),this.assertActive();let a=g.resolve(e,t),s=await D(a,"utf8");this.assertActive();let r=this.ensure(a,s,e);i==="complete"?await this.waitComplete(r,o):i!=="snapshot"&&await K(Promise.all(r.jobs),this.options.readWaitMs??5e3),o?.throwIfAborted(),this.assertActive();let d=await D(a,"utf8");this.assertActive();let l=this.ensure(a,d,e);if(i==="complete"&&l!==r)throw Object.assign(new Error("File changed during diagnostics"),{code:"DIAGNOSTICS_STALE"});return{filePath:a,content:l.content,results:[...l.results.values()]}}async waitComplete(t,e){let i=e?AbortSignal.any([e,t.controller.signal]):t.controller.signal;i.throwIfAborted();let o=[];await new Promise((a,s)=>{let r=c(m=>s(Object.assign(new Error(m),{code:m,details:[...t.results.values()]})),"fail"),d=c(()=>{let m=[...t.results.values()];m.some(w=>w.status==="unavailable")?r("DIAGNOSTICS_UNAVAILABLE"):m.every(w=>w.status==="ready")&&a()},"check"),l=c(()=>s(i.reason),"abort"),f=this.onDidChange(d),u=setTimeout(()=>r("DIAGNOSTICS_TIMEOUT"),this.options.checkTimeoutMs??3e4);i.addEventListener("abort",l,{once:!0});let p=c(()=>{clearTimeout(u),f(),i.removeEventListener("abort",l)},"cleanup");Promise.resolve().then(d),o.push(p)}).finally(()=>{for(let a of o)a()})}async takeNotifications(t){let e=[];for(let i of[...this.dirty]){if(i.cwd!==g.resolve(t)||(this.dirty.delete(i),!await this.isCurrent(i)))continue;let o=[...i.results.values()].filter(d=>d.status!=="pending"&&d.status!=="unavailable"&&d.diagnostics.length>0),a=this.key(i.filePath,i.cwd),s=JSON.stringify(o);if(this.sent.get(a)===s||(this.sent.set(a,s),o.length===0))continue;let r=o.map(d=>{let l=["error","warning","info","hint"].flatMap(f=>{let u=d.diagnostics.filter(p=>p.severity===f).length;return u>0?[`${u} ${f}`]:[]});return`${d.source} ${l.join(", ")}${d.status==="snapshot"?" (snapshot; completion unknown)":d.status==="unversioned"?" (unversioned)":""}`}).join("; ");e.push({filePath:g.relative(t,i.filePath),results:o,text:`${JSON.stringify(g.relative(t,i.filePath))}: ${r}.`})}return e}dispose(){this.disposed=!0,this.changeListeners.clear();for(let t of this.files.values())t.controller.abort();this.files.clear(),this.dirty.clear(),this.sent.clear(),this.pump()}key(t,e){return JSON.stringify([g.resolve(e),g.resolve(e,t)])}ensure(t,e,i){let o=this.key(t,i),a=this.files.get(o);if(a?.content===e)return a;a?.controller.abort(),a&&this.dirty.delete(a);let s={cwd:g.resolve(i),filePath:g.resolve(i,t),content:e,controller:new AbortController,results:new Map,jobs:[],publications:new Map};this.files.set(o,s),this.sources.length===0&&s.results.set("diagnostics",{source:"diagnostics",status:"unavailable",diagnostics:[],reason:"No diagnostic sources registered"}),this.dirty.add(s);for(let r of this.sources){s.results.set(r.id,{source:r.id,status:"pending",diagnostics:[]});let d=new Promise(l=>{this.queue.push(async()=>{try{await this.check(s,r)}finally{l()}})});s.jobs.push(d)}return queueMicrotask(()=>this.pump()),s}pump(){for(;this.running<(this.options.concurrency??4)&&this.queue.length>0;){let t=this.queue.shift();if(!t)break;this.running++,t().finally(()=>{this.running--,this.pump()})}}active(t){return!this.disposed&&!t.controller.signal.aborted}assertActive(){if(this.disposed)throw new Error("Diagnostics session has ended")}async isCurrent(t){if(!this.active(t))return!1;let e=await D(t.filePath,"utf8").catch(()=>{});return this.active(t)&&e===t.content}async publish(t,e,i){let o=(t.publications.get(e)??0)+1;if(t.publications.set(e,o),!await this.isCurrent(t)||t.publications.get(e)!==o)return;let a={...i,source:i.source??e};if(JSON.stringify(t.results.get(e))===JSON.stringify(a))return;t.results.set(e,a),this.dirty.add(t);let s=[...t.results.values()].some(r=>r.status!=="pending"&&r.status!=="unavailable"&&r.diagnostics.length>0);s||this.sent.delete(this.key(t.filePath,t.cwd));for(let r of this.changeListeners)r(t.cwd,s)}async check(t,e){if(!await this.isCurrent(t))return;let i=new AbortController,o=AbortSignal.any([i.signal,t.controller.signal]);if(o.aborted)return;let a,s;try{let r=new Promise((l,f)=>{s=c(()=>f(o.reason),"onAbort"),o.addEventListener("abort",s,{once:!0}),a=setTimeout(()=>i.abort(new Error("Diagnostic check timed out")),this.options.checkTimeoutMs??3e4)}),d=await Promise.race([e.diagnose(t.filePath,{cwd:t.cwd,content:t.content,signal:o,publish:c(l=>{o.aborted||this.publish(t,e.id,l)},"publish")}),r]);await this.publish(t,e.id,d)}catch(r){await this.publish(t,e.id,{status:"unavailable",diagnostics:[],reason:r instanceof Error?r.message:String(r)})}finally{clearTimeout(a),s&&o.removeEventListener("abort",s)}}};async function K(n,t){let e;try{await Promise.race([n,new Promise(i=>{e=setTimeout(i,t)})])}finally{clearTimeout(e)}}c(K,"waitAtMost");function V(){let n=new Map,t=[],e=new v(t),i=Promise.resolve();return{diagnostics:e,registerPlugin(o){if(o.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let a=n.get(o.id);if(a!==void 0)return a;let s=i.then(async()=>{let r=[],d=[],l=!0,f={addTool(u){if(!l)throw new Error(`Plugin ${o.id} setup is already complete`);Z(u),r.push(u)},addDiagnosticSource(u){if(!l)throw new Error(`Plugin ${o.id} setup is already complete`);tt(u),d.push(u)},readDiagnostics(u,p){return e.read(u,p)}};try{await o.setup(f)}catch(u){throw l=!1,u}l=!1,Q(t,d),q(r),t.push(...d)});return n.set(o.id,s),i=s.catch(()=>{}),s.catch(()=>{n.delete(o.id)}),s},async waitForPendingPlugins(){await Promise.all(n.values())}}}c(V,"createIdeCore");function Q(n,t){let e=new Set(n.map(i=>i.id));for(let i of t){if(e.has(i.id))throw new Error(`Diagnostic source ${i.id} is already registered`);e.add(i.id)}}c(Q,"assertUniqueDiagnosticSources");function Z(n){if(!U(n))throw new TypeError("IDE tool must be an object");let t=n.kind,e=t==="compiler"?n.compile:t==="formatter"?n.format:t==="linter"?n.lint:void 0;if(e===void 0||typeof e!="function"||typeof n.detect!="function"||typeof n.name!="string"||n.name.trim().length===0||typeof n.priority!="number"||!Number.isFinite(n.priority)||!Array.isArray(n.extensions)||n.extensions.length===0||n.extensions.some(i=>typeof i!="string"||i.length===0))throw new TypeError("Invalid pi-agent-ide tool contribution")}c(Z,"assertIdeTool");function tt(n){if(!U(n)||typeof n.id!="string"||n.id.trim().length===0||typeof n.diagnose!="function")throw new TypeError("Invalid pi-agent-ide diagnostic source contribution")}c(tt,"assertDiagnosticSource");function U(n){return typeof n=="object"&&n!==null}c(U,"isRecord");function J(n,t,e=console.error){let i=new Map,o=!1,a=Promise.resolve();return{schedule(s){if(o||i.has(s))return;let r=setTimeout(()=>{i.delete(s),a=a.then(async()=>{o||await n(s)}).catch(e)},t);i.set(s,r)},dispose(){o=!0;for(let s of i.values())clearTimeout(s);i.clear()}}}c(J,"createDiagnosticDelivery");import{Text as Y}from"@earendil-works/pi-tui";var S="ide-diagnostic-summary";function W(n){return{filePath:n.filePath,sources:n.results.map(t=>{let e={error:0,warning:0,info:0,hint:0};for(let i of t.diagnostics)e[i.severity]++;return{source:t.source,status:t.status,counts:e}})}}c(W,"diagnosticEntryData");function E(n,t,e=!1){return{render(i){let o=n.sources.filter(r=>r.status!=="pending"&&r.status!=="unavailable"&&Object.values(r.counts).some(d=>d>0));if(o.length===0)return[];let a=o.map(r=>`${x(r.counts,t)} ${t.fg("dim",`(${I(r.source)})`)}`+(r.status==="ready"?"":` \xB7 ${t.fg("dim",r.status)}`)).join(" \xB7 "),s=[`${t.fg("accent","Diagnostics")} ${t.fg("toolTitle",I(n.filePath))} \xB7 ${a}`];if(e)for(let r of o)s.push(` ${t.fg("dim",I(r.source))} \xB7 ${x(r.counts,t)} \xB7 ${t.fg("dim",r.status)}`);return new Y(s.join(`
1
+ import{a as j,m as M}from"./chunk-FEDVTZJG.js";import{a as _}from"./chunk-L7JMDDSD.js";import{a as N,b as O}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import{a as C,b as R,c as A,d as $,g as F}from"./chunk-QIK2E64R.js";import{a as k}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";var h=[],y=[],P=[];function b(n,t,e){if(t.some(i=>i.name===e))throw new Error(`[pi-agent-ide] ${n} "${e}" is already registered. Use a unique name.`)}c(b,"assertUniqueName");function q(n){let t=new Set;for(let e of n){let i=`${e.kind}:${e.name}`;if(t.has(i))throw new Error(`[pi-agent-ide] ${e.kind} "${e.name}" is registered twice by one plugin.`);switch(t.add(i),e.kind){case"compiler":{b(e.kind,y,e.name);break}case"formatter":{b(e.kind,h,e.name);break}case"linter":{b(e.kind,P,e.name);break}}}for(let e of n)switch(e.kind){case"compiler":{y.push(e);break}case"formatter":{h.push(e);break}case"linter":{P.push(e);break}}}c(q,"registerTools");async function L(n,t){let e=[];for(let i of n)try{await i.detect(t)&&e.push(i)}catch(o){console.error(`[pi-agent-ide] detect failed for "${i.name}":`,o)}return e.sort((i,o)=>o.priority-i.priority),H(e),e}c(L,"filterActive");function H(n){let t=new Map;for(let e of n)for(let i of e.extensions){let o=`${i}@${e.priority}`,a=t.get(o);if(a!==void 0)throw new Error(`[pi-agent-ide] priority conflict: tools "${a}" and "${e.name}" both claim "${i}" at priority ${e.priority}.`);t.set(o,e.name)}}c(H,"assertNoPriorityConflicts");async function G(n){let[t,e]=await Promise.all([L(h,n),L(y.filter(i=>i.syntaxOnly===!0),n)]);return{ctx:n,formatters:t,compilers:e,linters:[]}}c(G,"warmupFormatting");function T(){h.length=0,y.length=0,P.length=0}c(T,"resetRegistry");import{readFile as D}from"node:fs/promises";import g from"node:path";var v=class{constructor(t,e={}){this.sources=t;this.options=e}static{c(this,"DiagnosticStore")}files=new Map;dirty=new Set;sent=new Map;queue=[];running=0;disposed=!1;changeListeners=new Set;onDidChange(t){return this.changeListeners.add(t),()=>this.changeListeners.delete(t)}schedule(t,e,{cwd:i}){this.disposed||this.ensure(t,e,i)}async read(t,{cwd:e,mode:i,signal:o}){o?.throwIfAborted(),this.assertActive();let a=g.resolve(e,t),s=await D(a,"utf8");this.assertActive();let r=this.ensure(a,s,e);i==="complete"?await this.waitComplete(r,o):i!=="snapshot"&&await K(Promise.all(r.jobs),this.options.readWaitMs??5e3),o?.throwIfAborted(),this.assertActive();let d=await D(a,"utf8");this.assertActive();let l=this.ensure(a,d,e);if(i==="complete"&&l!==r)throw Object.assign(new Error("File changed during diagnostics"),{code:"DIAGNOSTICS_STALE"});return{filePath:a,content:l.content,results:[...l.results.values()]}}async waitComplete(t,e){let i=e?AbortSignal.any([e,t.controller.signal]):t.controller.signal;i.throwIfAborted();let o=[];await new Promise((a,s)=>{let r=c(m=>s(Object.assign(new Error(m),{code:m,details:[...t.results.values()]})),"fail"),d=c(()=>{let m=[...t.results.values()];m.some(w=>w.status==="unavailable")?r("DIAGNOSTICS_UNAVAILABLE"):m.every(w=>w.status==="ready")&&a()},"check"),l=c(()=>s(i.reason),"abort"),f=this.onDidChange(d),u=setTimeout(()=>r("DIAGNOSTICS_TIMEOUT"),this.options.checkTimeoutMs??3e4);i.addEventListener("abort",l,{once:!0});let p=c(()=>{clearTimeout(u),f(),i.removeEventListener("abort",l)},"cleanup");Promise.resolve().then(d),o.push(p)}).finally(()=>{for(let a of o)a()})}async takeNotifications(t){let e=[];for(let i of[...this.dirty]){if(i.cwd!==g.resolve(t)||(this.dirty.delete(i),!await this.isCurrent(i)))continue;let o=[...i.results.values()].filter(d=>d.status!=="pending"&&d.status!=="unavailable"&&d.diagnostics.length>0),a=this.key(i.filePath,i.cwd),s=JSON.stringify(o);if(this.sent.get(a)===s||(this.sent.set(a,s),o.length===0))continue;let r=o.map(d=>{let l=["error","warning","info","hint"].flatMap(f=>{let u=d.diagnostics.filter(p=>p.severity===f).length;return u>0?[`${u} ${f}`]:[]});return`${d.source} ${l.join(", ")}${d.status==="snapshot"?" (snapshot; completion unknown)":d.status==="unversioned"?" (unversioned)":""}`}).join("; ");e.push({filePath:g.relative(t,i.filePath),results:o,text:`${JSON.stringify(g.relative(t,i.filePath))}: ${r}.`})}return e}dispose(){this.disposed=!0,this.changeListeners.clear();for(let t of this.files.values())t.controller.abort();this.files.clear(),this.dirty.clear(),this.sent.clear(),this.pump()}key(t,e){return JSON.stringify([g.resolve(e),g.resolve(e,t)])}ensure(t,e,i){let o=this.key(t,i),a=this.files.get(o);if(a?.content===e)return a;a?.controller.abort(),a&&this.dirty.delete(a);let s={cwd:g.resolve(i),filePath:g.resolve(i,t),content:e,controller:new AbortController,results:new Map,jobs:[],publications:new Map};this.files.set(o,s),this.sources.length===0&&s.results.set("diagnostics",{source:"diagnostics",status:"unavailable",diagnostics:[],reason:"No diagnostic sources registered"}),this.dirty.add(s);for(let r of this.sources){s.results.set(r.id,{source:r.id,status:"pending",diagnostics:[]});let d=new Promise(l=>{this.queue.push(async()=>{try{await this.check(s,r)}finally{l()}})});s.jobs.push(d)}return queueMicrotask(()=>this.pump()),s}pump(){for(;this.running<(this.options.concurrency??4)&&this.queue.length>0;){let t=this.queue.shift();if(!t)break;this.running++,t().finally(()=>{this.running--,this.pump()})}}active(t){return!this.disposed&&!t.controller.signal.aborted}assertActive(){if(this.disposed)throw new Error("Diagnostics session has ended")}async isCurrent(t){if(!this.active(t))return!1;let e=await D(t.filePath,"utf8").catch(()=>{});return this.active(t)&&e===t.content}async publish(t,e,i){let o=(t.publications.get(e)??0)+1;if(t.publications.set(e,o),!await this.isCurrent(t)||t.publications.get(e)!==o)return;let a={...i,source:i.source??e};if(JSON.stringify(t.results.get(e))===JSON.stringify(a))return;t.results.set(e,a),this.dirty.add(t);let s=[...t.results.values()].some(r=>r.status!=="pending"&&r.status!=="unavailable"&&r.diagnostics.length>0);s||this.sent.delete(this.key(t.filePath,t.cwd));for(let r of this.changeListeners)r(t.cwd,s)}async check(t,e){if(!await this.isCurrent(t))return;let i=new AbortController,o=AbortSignal.any([i.signal,t.controller.signal]);if(o.aborted)return;let a,s;try{let r=new Promise((l,f)=>{s=c(()=>f(o.reason),"onAbort"),o.addEventListener("abort",s,{once:!0}),a=setTimeout(()=>i.abort(new Error("Diagnostic check timed out")),this.options.checkTimeoutMs??3e4)}),d=await Promise.race([e.diagnose(t.filePath,{cwd:t.cwd,content:t.content,signal:o,publish:c(l=>{o.aborted||this.publish(t,e.id,l)},"publish")}),r]);await this.publish(t,e.id,d)}catch(r){await this.publish(t,e.id,{status:"unavailable",diagnostics:[],reason:r instanceof Error?r.message:String(r)})}finally{clearTimeout(a),s&&o.removeEventListener("abort",s)}}};async function K(n,t){let e;try{await Promise.race([n,new Promise(i=>{e=setTimeout(i,t)})])}finally{clearTimeout(e)}}c(K,"waitAtMost");function V(){let n=new Map,t=[],e=new v(t),i=Promise.resolve();return{diagnostics:e,registerPlugin(o){if(o.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let a=n.get(o.id);if(a!==void 0)return a;let s=i.then(async()=>{let r=[],d=[],l=!0,f={addTool(u){if(!l)throw new Error(`Plugin ${o.id} setup is already complete`);Z(u),r.push(u)},addDiagnosticSource(u){if(!l)throw new Error(`Plugin ${o.id} setup is already complete`);tt(u),d.push(u)},readDiagnostics(u,p){return e.read(u,p)}};try{await o.setup(f)}catch(u){throw l=!1,u}l=!1,Q(t,d),q(r),t.push(...d)});return n.set(o.id,s),i=s.catch(()=>{}),s.catch(()=>{n.delete(o.id)}),s},async waitForPendingPlugins(){await Promise.all(n.values())}}}c(V,"createIdeCore");function Q(n,t){let e=new Set(n.map(i=>i.id));for(let i of t){if(e.has(i.id))throw new Error(`Diagnostic source ${i.id} is already registered`);e.add(i.id)}}c(Q,"assertUniqueDiagnosticSources");function Z(n){if(!U(n))throw new TypeError("IDE tool must be an object");let t=n.kind,e=t==="compiler"?n.compile:t==="formatter"?n.format:t==="linter"?n.lint:void 0;if(e===void 0||typeof e!="function"||typeof n.detect!="function"||typeof n.name!="string"||n.name.trim().length===0||typeof n.priority!="number"||!Number.isFinite(n.priority)||!Array.isArray(n.extensions)||n.extensions.length===0||n.extensions.some(i=>typeof i!="string"||i.length===0))throw new TypeError("Invalid pi-agent-ide tool contribution")}c(Z,"assertIdeTool");function tt(n){if(!U(n)||typeof n.id!="string"||n.id.trim().length===0||typeof n.diagnose!="function")throw new TypeError("Invalid pi-agent-ide diagnostic source contribution")}c(tt,"assertDiagnosticSource");function U(n){return typeof n=="object"&&n!==null}c(U,"isRecord");function J(n,t,e=console.error){let i=new Map,o=!1,a=Promise.resolve();return{schedule(s){if(o||i.has(s))return;let r=setTimeout(()=>{i.delete(s),a=a.then(async()=>{o||await n(s)}).catch(e)},t);i.set(s,r)},dispose(){o=!0;for(let s of i.values())clearTimeout(s);i.clear()}}}c(J,"createDiagnosticDelivery");import{Text as Y}from"@earendil-works/pi-tui";var S="ide-diagnostic-summary";function W(n){return{filePath:n.filePath,sources:n.results.map(t=>{let e={error:0,warning:0,info:0,hint:0};for(let i of t.diagnostics)e[i.severity]++;return{source:t.source,status:t.status,counts:e}})}}c(W,"diagnosticEntryData");function E(n,t,e=!1){return{render(i){let o=n.sources.filter(r=>r.status!=="pending"&&r.status!=="unavailable"&&Object.values(r.counts).some(d=>d>0));if(o.length===0)return[];let a=o.map(r=>`${x(r.counts,t)} ${t.fg("dim",`(${I(r.source)})`)}`+(r.status==="ready"?"":` \xB7 ${t.fg("dim",r.status)}`)).join(" \xB7 "),s=[`${t.fg("accent","Diagnostics")} ${t.fg("toolTitle",I(n.filePath))} \xB7 ${a}`];if(e)for(let r of o)s.push(` ${t.fg("dim",I(r.source))} \xB7 ${x(r.counts,t)} \xB7 ${t.fg("dim",r.status)}`);return new Y(s.join(`
2
2
  `),0,0).render(i)},invalidate(){}}}c(E,"renderDiagnosticEntry");function B(n){n.registerEntryRenderer(S,(t,e,i)=>{let o=k(t.data);return"files"in o?et(o.files,i,e.expanded):E(o,i,e.expanded)})}c(B,"registerDiagnosticEntryRenderer");function et(n,t,e=!1){return{render(i){let o=n.filter(d=>d.sources.some(l=>l.status!=="pending"&&l.status!=="unavailable"&&Object.values(l.counts).some(f=>f>0)));if(o.length===1&&o[0])return E(o[0],t,e).render(i);if(o.length===0)return[];let a={error:0,warning:0,info:0,hint:0},s=new Set;for(let d of o)for(let l of d.sources)if(!(l.status==="pending"||l.status==="unavailable")){s.add(l.source);for(let f of["error","warning","info","hint"])a[f]+=l.counts[f]}let r=new Y(`${t.fg("accent","Diagnostics")} \xB7 ${o.length} files \xB7 ${x(a,t)} \xB7 ${s.size} tools`,0,0).render(i);return e?[...r,...o.flatMap(d=>E(d,t,!0).render(i))]:r},invalidate(){}}}c(et,"renderDiagnosticBatch");function x(n,t){return["error","warning","info","hint"].filter(e=>n[e]>0).map(e=>{let i=n[e],o=e==="info"||i===1?e:`${e}s`,a=i>0&&(e==="error"||e==="warning")?e:"muted";return t.fg(a,`${i} ${o}`)}).join(", ")}c(x,"renderCounts");function I(n){return n.replace(/[\u0000-\u001f\u007f-\u009f]/g," ")}c(I,"plain");import X from"node:path";async function z(n){if(!X.isAbsolute(n.resourceSource))return{formatting:{status:"unavailable"}};let t;try{let e=await G({cwd:n.cwd}),i=X.extname(n.resourceSource).toLowerCase(),o=c(d=>d.extensions.includes(i)||d.extensions.includes("*"),"matches"),a=e.compilers.find(o);if(a&&(await a.compile({filePath:n.resourceSource},e.ctx)).syntaxErrors.length>0)return{formatting:{status:"skipped-syntax"}};let s=e.formatters.find(o);if(!s)return{formatting:{status:"unavailable"}};t=s.name;let r=await s.format({filePath:n.resourceSource},e.ctx);return r.formatter===null?{formatting:{status:"unavailable"}}:(t=r.formatter??s.name,{formatting:{status:r.ok?r.edits>0?"changed":"unchanged":"failed",formatter:t},...r.ok?{diffStatuses:[{text:`Formatted (${t})`,tone:"success",formatter:t}]}:{diffStatuses:[{text:`Formatting failed (${t})`,tone:"error"}]}})}catch{return{diffStatuses:[{text:"Formatting failed",tone:"error"}],formatting:{status:"failed",...t===void 0?{}:{formatter:t}}}}}c(z,"runIdePostEditGate");import it from"node:path";async function nt(n){T();let t=V();B(n);let e=n.events.on($,s=>{if(!F(s))throw new Error("Invalid pi-agent-ide plugin registration request");s.accept(t.registerPlugin(s.plugin))});n.on("session_shutdown",()=>{e(),t.diagnostics.dispose(),T()}),M(n,{id:"pi-agent-ide",handler:c(s=>n.getFlag("pi-agent-ide-no-post-processing")===!0?Promise.resolve({formatting:{status:"disabled"}}):z(s),"handler")}),n.events.emit(A,{protocol:C,apiVersion:4}),await _(n,{protocol:N,apiVersion:O,id:"ide-diagnostics",setup(s){s.onDidEdit(r=>{n.getFlag("pi-agent-ide-no-post-processing")===!0||r.postProcessing==="deferred"||it.isAbsolute(r.resourceSource)&&j(()=>t.diagnostics.schedule(r.resourceSource,r.after.content,{cwd:r.cwd}))})}});let i=!1,o=J(async s=>{let r=await t.diagnostics.takeNotifications(s);i||r.length===0||(n.sendMessage({customType:"ide-diagnostics",display:!1,content:`File diagnostics:
3
3
  ${r.map(d=>d.text).join(`
4
4
  `)}`},{triggerTurn:!0,deliverAs:"steer"}),n.appendEntry(S,{files:r.map(W)}))},n.getFlag("pi-agent-ide-no-diagnostic-buffer")===!0?0:5e3),a=t.diagnostics.onDidChange((s,r)=>{r&&o.schedule(s)});n.on("session_shutdown",()=>{i=!0,o.dispose(),a()}),await t.waitForPendingPlugins()}c(nt,"registerPiAgentIde");export{nt as default};