pi-agent-ide 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/assets/banner.png +0 -0
  4. package/docs/architecture.md +100 -0
  5. package/docs/configuration.md +104 -0
  6. package/docs/development.md +102 -0
  7. package/docs/evaluation.md +14 -0
  8. package/docs/extensions.md +298 -0
  9. package/docs/tools.md +104 -0
  10. package/node_modules/pi-agent-filesystem/index.ts +60 -0
  11. package/node_modules/pi-agent-filesystem/package.json +23 -0
  12. package/node_modules/pi-agent-filesystem/src/resolver.ts +175 -0
  13. package/node_modules/pi-agent-filesystem-image/index.ts +14 -0
  14. package/node_modules/pi-agent-filesystem-image/package.json +20 -0
  15. package/node_modules/pi-agent-filesystem-pdf/index.ts +14 -0
  16. package/node_modules/pi-agent-filesystem-pdf/package.json +17 -0
  17. package/node_modules/pi-agent-filesystem-text/index.ts +23 -0
  18. package/node_modules/pi-agent-filesystem-text/package.json +20 -0
  19. package/node_modules/pi-agent-ide-ast/index.ts +1 -0
  20. package/node_modules/pi-agent-ide-ast/package.json +39 -0
  21. package/node_modules/pi-agent-ide-ast/src/api/scope.ts +1 -0
  22. package/node_modules/pi-agent-ide-ast/src/ast/collect-files.ts +24 -0
  23. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +374 -0
  24. package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +813 -0
  25. package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +30 -0
  26. package/node_modules/pi-agent-ide-ast/src/extension.ts +85 -0
  27. package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +69 -0
  28. package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +221 -0
  29. package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +45 -0
  30. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +141 -0
  31. package/node_modules/pi-agent-ide-changes/index.ts +68 -0
  32. package/node_modules/pi-agent-ide-changes/package.json +29 -0
  33. package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +103 -0
  34. package/node_modules/pi-agent-ide-changes/src/changes/change-groups.ts +309 -0
  35. package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +223 -0
  36. package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +105 -0
  37. package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +325 -0
  38. package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +232 -0
  39. package/node_modules/pi-agent-ide-changes/src/index-mutation-queue.ts +11 -0
  40. package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +88 -0
  41. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +116 -0
  42. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +153 -0
  43. package/node_modules/pi-agent-ide-formatter/index.ts +33 -0
  44. package/node_modules/pi-agent-ide-formatter/package.json +14 -0
  45. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +50 -0
  46. package/node_modules/pi-agent-ide-formatter/src/registry.ts +30 -0
  47. package/node_modules/pi-agent-ide-formatter/src/types.ts +10 -0
  48. package/node_modules/pi-agent-ide-lint/index.ts +237 -0
  49. package/node_modules/pi-agent-ide-lint/package.json +19 -0
  50. package/node_modules/pi-agent-ide-lint/src/command-linter.ts +160 -0
  51. package/node_modules/pi-agent-ide-lint/src/command-runner.ts +51 -0
  52. package/node_modules/pi-agent-ide-lint/src/registry.ts +30 -0
  53. package/node_modules/pi-agent-ide-lint/src/types.ts +10 -0
  54. package/node_modules/pi-agent-ide-lsp/index.ts +250 -0
  55. package/node_modules/pi-agent-ide-lsp/package.json +23 -0
  56. package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +139 -0
  57. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +463 -0
  58. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +577 -0
  59. package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +179 -0
  60. package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +59 -0
  61. package/node_modules/pi-agent-ide-lsp/src/lsp/language-map.ts +57 -0
  62. package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +85 -0
  63. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +485 -0
  64. package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +85 -0
  65. package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +97 -0
  66. package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +50 -0
  67. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +149 -0
  68. package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +151 -0
  69. package/node_modules/pi-agent-ide-lsp/src/lsp/types.ts +95 -0
  70. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +42 -0
  71. package/node_modules/pi-agent-image/package.json +18 -0
  72. package/node_modules/pi-agent-image/src/image-converter.ts +318 -0
  73. package/node_modules/pi-agent-image/src/index.ts +6 -0
  74. package/node_modules/pi-agent-pdf/package.json +16 -0
  75. package/node_modules/pi-agent-pdf/src/index.ts +5 -0
  76. package/node_modules/pi-agent-pdf/src/pdf-converter.ts +197 -0
  77. package/node_modules/pi-agent-read/index.ts +1 -0
  78. package/node_modules/pi-agent-read/package.json +41 -0
  79. package/node_modules/pi-agent-read/src/api/connect-plugin.ts +67 -0
  80. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +67 -0
  81. package/node_modules/pi-agent-read/src/api/rendering.ts +11 -0
  82. package/node_modules/pi-agent-read/src/api/tools/read.ts +208 -0
  83. package/node_modules/pi-agent-read/src/core/extension.ts +40 -0
  84. package/node_modules/pi-agent-read/src/core/read-core.ts +390 -0
  85. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +193 -0
  86. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +400 -0
  87. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +187 -0
  88. package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +218 -0
  89. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +828 -0
  90. package/node_modules/pi-agent-resource/package.json +17 -0
  91. package/node_modules/pi-agent-resource/src/content-conversion/connect-plugin.ts +84 -0
  92. package/node_modules/pi-agent-resource/src/content-conversion/content-converter.ts +49 -0
  93. package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +29 -0
  94. package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +73 -0
  95. package/node_modules/pi-agent-resource/src/content-conversion/content-runner.ts +152 -0
  96. package/node_modules/pi-agent-resource/src/content-conversion/plugin-protocol.ts +74 -0
  97. package/node_modules/pi-agent-resource/src/content-conversion/validation.ts +149 -0
  98. package/node_modules/pi-agent-resource/src/content.ts +17 -0
  99. package/node_modules/pi-agent-resource/src/index.ts +65 -0
  100. package/node_modules/pi-agent-resource/src/resolver.ts +23 -0
  101. package/node_modules/pi-agent-resource/src/resource.ts +41 -0
  102. package/node_modules/pi-agent-resource/src/validation.ts +139 -0
  103. package/node_modules/pi-agent-search/index.ts +1 -0
  104. package/node_modules/pi-agent-search/package.json +35 -0
  105. package/node_modules/pi-agent-search/src/api/connect-plugin.ts +61 -0
  106. package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +60 -0
  107. package/node_modules/pi-agent-search/src/api/search.ts +91 -0
  108. package/node_modules/pi-agent-search/src/core/extension.ts +126 -0
  109. package/node_modules/pi-agent-search/src/core/search-core.ts +400 -0
  110. package/node_modules/pi-agent-search-semantic/index.ts +105 -0
  111. package/node_modules/pi-agent-search-semantic/package.json +17 -0
  112. package/node_modules/pi-agent-search-text/index.ts +54 -0
  113. package/node_modules/pi-agent-search-text/package.json +33 -0
  114. package/node_modules/pi-agent-search-text/src/file-search.ts +105 -0
  115. package/node_modules/pi-agent-search-text/src/lucene-query-parser.d.ts +22 -0
  116. package/node_modules/pi-agent-search-text/src/resolvers.ts +192 -0
  117. package/node_modules/pi-agent-search-text/src/search-backend.ts +295 -0
  118. package/node_modules/pi-agent-search-text/src/search-query.ts +139 -0
  119. package/node_modules/pi-agent-search-text/src/search-renderer.ts +420 -0
  120. package/node_modules/pi-agent-search-text/src/search-result.ts +193 -0
  121. package/node_modules/pi-agent-search-text/src/search-session.ts +338 -0
  122. package/node_modules/pi-agent-search-web/index.ts +74 -0
  123. package/node_modules/pi-agent-search-web/package.json +19 -0
  124. package/node_modules/pi-agent-search-web/src/config.ts +499 -0
  125. package/node_modules/pi-agent-search-web/src/providers/duckduckgo-html.ts +78 -0
  126. package/node_modules/pi-agent-search-web/src/providers/endpoints.ts +89 -0
  127. package/node_modules/pi-agent-search-web/src/providers/request.ts +430 -0
  128. package/node_modules/pi-agent-search-web/src/providers/response.ts +402 -0
  129. package/node_modules/pi-agent-search-web/src/search-format.ts +29 -0
  130. package/node_modules/pi-agent-search-web/src/search.ts +434 -0
  131. package/node_modules/pi-agent-search-web/src/types.ts +153 -0
  132. package/node_modules/pi-agent-text/package.json +18 -0
  133. package/node_modules/pi-agent-text/src/index.ts +31 -0
  134. package/node_modules/pi-agent-text/src/presented-text.ts +24 -0
  135. package/node_modules/pi-agent-text/src/source-line.ts +49 -0
  136. package/node_modules/pi-agent-text/src/text-anchor.ts +157 -0
  137. package/node_modules/pi-agent-text/src/text-converter.ts +109 -0
  138. package/node_modules/pi-agent-text/src/text-document.ts +149 -0
  139. package/node_modules/pi-agent-text-anchor-constant/index.ts +30 -0
  140. package/node_modules/pi-agent-text-anchor-constant/package.json +17 -0
  141. package/node_modules/pi-agent-text-anchor-constant/src/resolver.ts +47 -0
  142. package/node_modules/pi-agent-text-anchor-line-hash/index.ts +48 -0
  143. package/node_modules/pi-agent-text-anchor-line-hash/package.json +24 -0
  144. package/node_modules/pi-agent-text-anchor-line-hash/src/anchor.ts +110 -0
  145. package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +47 -0
  146. package/node_modules/pi-agent-text-editor/index.ts +19 -0
  147. package/node_modules/pi-agent-text-editor/package.json +92 -0
  148. package/node_modules/pi-agent-text-editor/src/api/anchor-inspection.ts +24 -0
  149. package/node_modules/pi-agent-text-editor/src/api/connect-plugin.ts +67 -0
  150. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +19 -0
  151. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +64 -0
  152. package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +46 -0
  153. package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +46 -0
  154. package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +30 -0
  155. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +23 -0
  156. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +180 -0
  157. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +217 -0
  158. package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +147 -0
  159. package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +17 -0
  160. package/node_modules/pi-agent-text-editor/src/api/text-selection-anchor.ts +121 -0
  161. package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +11 -0
  162. package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +39 -0
  163. package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +59 -0
  164. package/node_modules/pi-agent-text-editor/src/core/extension.ts +150 -0
  165. package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +386 -0
  166. package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +129 -0
  167. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +359 -0
  168. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +648 -0
  169. package/node_modules/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +117 -0
  170. package/node_modules/pi-agent-text-editor/src/core/text-anchor-recovery.ts +24 -0
  171. package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +381 -0
  172. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +273 -0
  173. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +607 -0
  174. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-execution.ts +127 -0
  175. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +45 -0
  176. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +432 -0
  177. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +115 -0
  178. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +2348 -0
  179. package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +28 -0
  180. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +756 -0
  181. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1235 -0
  182. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/partial-json-resolver.ts +43 -0
  183. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/partial-tool-recovery.ts +308 -0
  184. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +4 -0
  185. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +467 -0
  186. package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +16 -0
  187. package/node_modules/pi-agent-text-editor/src/tools/extension.ts +19 -0
  188. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +106 -0
  189. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +121 -0
  190. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +79 -0
  191. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +56 -0
  192. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +142 -0
  193. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +72 -0
  194. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +28 -0
  195. package/node_modules/pi-agent-text-editor-argument-order/index.ts +29 -0
  196. package/node_modules/pi-agent-text-editor-argument-order/package.json +16 -0
  197. package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +112 -0
  198. package/node_modules/pi-agent-text-editor-overwrite/index.ts +391 -0
  199. package/node_modules/pi-agent-text-editor-overwrite/package.json +16 -0
  200. package/node_modules/pi-agent-text-editor-renderer/index.ts +22 -0
  201. package/node_modules/pi-agent-text-editor-renderer/package.json +21 -0
  202. package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +452 -0
  203. package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +271 -0
  204. package/node_modules/pi-agent-text-editor-renderer/src/diff-theme.ts +411 -0
  205. package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +38 -0
  206. package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +205 -0
  207. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +229 -0
  208. package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +407 -0
  209. package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +153 -0
  210. package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +8 -0
  211. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +728 -0
  212. package/node_modules/pi-agent-text-editor-renderer/src/typing-interpolation.ts +219 -0
  213. package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +375 -0
  214. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +17 -0
  215. package/node_modules/pi-agent-tool-call-interception/package.json +17 -0
  216. package/node_modules/pi-agent-tool-call-interception/src/index.ts +418 -0
  217. package/node_modules/pi-agent-web/index.ts +37 -0
  218. package/node_modules/pi-agent-web/package.json +24 -0
  219. package/node_modules/pi-agent-web/src/resolver.ts +182 -0
  220. package/node_modules/pi-agent-web-html/index.ts +15 -0
  221. package/node_modules/pi-agent-web-html/package.json +18 -0
  222. package/node_modules/pi-agent-web-html/src/extract-readable-html.ts +101 -0
  223. package/node_modules/pi-agent-web-html/src/html-converter.ts +91 -0
  224. package/node_modules/pi-agent-web-image/index.ts +14 -0
  225. package/node_modules/pi-agent-web-image/package.json +17 -0
  226. package/node_modules/pi-agent-web-pdf/index.ts +14 -0
  227. package/node_modules/pi-agent-web-pdf/package.json +17 -0
  228. package/node_modules/pi-agent-web-text/index.ts +14 -0
  229. package/node_modules/pi-agent-web-text/package.json +17 -0
  230. package/package.json +176 -0
  231. package/src/api/code-view.ts +25 -0
  232. package/src/api/connect-plugin.ts +64 -0
  233. package/src/api/plugin-protocol.ts +63 -0
  234. package/src/api/read.ts +5 -0
  235. package/src/api/resource.ts +2 -0
  236. package/src/api/search.ts +4 -0
  237. package/src/api/text-editor.ts +3 -0
  238. package/src/api/text.ts +2 -0
  239. package/src/api/toolchain.ts +24 -0
  240. package/src/code-view/diagnostic-view.ts +82 -0
  241. package/src/code-view/reference.ts +113 -0
  242. package/src/code-view/source-view.ts +229 -0
  243. package/src/composite/builtin-extensions.ts +68 -0
  244. package/src/composite/config.ts +94 -0
  245. package/src/composite/selection.ts +66 -0
  246. package/src/core/extension.ts +48 -0
  247. package/src/core/ide-core.ts +117 -0
  248. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +60 -0
  249. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +23 -0
  250. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/index.ts +14 -0
  251. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +20 -0
  252. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/index.ts +14 -0
  253. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +17 -0
  254. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/index.ts +23 -0
  255. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +20 -0
  256. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +175 -0
  257. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +37 -0
  258. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +24 -0
  259. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/index.ts +15 -0
  260. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +18 -0
  261. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/extract-readable-html.ts +101 -0
  262. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +91 -0
  263. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/index.ts +14 -0
  264. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +17 -0
  265. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/index.ts +14 -0
  266. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +17 -0
  267. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/index.ts +14 -0
  268. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +17 -0
  269. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +182 -0
  270. package/src/extensions/pi-agent-read/index.ts +1 -0
  271. package/src/extensions/pi-agent-read/package.json +41 -0
  272. package/src/extensions/pi-agent-read/src/api/connect-plugin.ts +67 -0
  273. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +67 -0
  274. package/src/extensions/pi-agent-read/src/api/rendering.ts +11 -0
  275. package/src/extensions/pi-agent-read/src/api/tools/read.ts +208 -0
  276. package/src/extensions/pi-agent-read/src/core/extension.ts +40 -0
  277. package/src/extensions/pi-agent-read/src/core/read-core.ts +390 -0
  278. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +193 -0
  279. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +400 -0
  280. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +187 -0
  281. package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +218 -0
  282. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +828 -0
  283. package/src/extensions/pi-agent-search/index.ts +1 -0
  284. package/src/extensions/pi-agent-search/package.json +35 -0
  285. package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/index.ts +105 -0
  286. package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/package.json +17 -0
  287. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +54 -0
  288. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +33 -0
  289. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +105 -0
  290. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/lucene-query-parser.d.ts +22 -0
  291. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +192 -0
  292. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +295 -0
  293. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +139 -0
  294. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +420 -0
  295. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +193 -0
  296. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +338 -0
  297. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/index.ts +74 -0
  298. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/package.json +19 -0
  299. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/config.ts +499 -0
  300. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/duckduckgo-html.ts +78 -0
  301. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/endpoints.ts +89 -0
  302. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/request.ts +430 -0
  303. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/response.ts +402 -0
  304. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search-format.ts +29 -0
  305. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search.ts +434 -0
  306. package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/types.ts +153 -0
  307. package/src/extensions/pi-agent-search/src/api/connect-plugin.ts +61 -0
  308. package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +60 -0
  309. package/src/extensions/pi-agent-search/src/api/search.ts +91 -0
  310. package/src/extensions/pi-agent-search/src/core/extension.ts +126 -0
  311. package/src/extensions/pi-agent-search/src/core/search-core.ts +400 -0
  312. package/src/extensions/pi-agent-text-editor/index.ts +19 -0
  313. package/src/extensions/pi-agent-text-editor/package.json +92 -0
  314. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/index.ts +30 -0
  315. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +17 -0
  316. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/src/resolver.ts +47 -0
  317. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +48 -0
  318. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +24 -0
  319. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/anchor.ts +110 -0
  320. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +47 -0
  321. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +29 -0
  322. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +16 -0
  323. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +112 -0
  324. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +391 -0
  325. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +16 -0
  326. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +22 -0
  327. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +21 -0
  328. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +452 -0
  329. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +271 -0
  330. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-theme.ts +411 -0
  331. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +38 -0
  332. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +205 -0
  333. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +229 -0
  334. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +407 -0
  335. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +153 -0
  336. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +8 -0
  337. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +728 -0
  338. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/typing-interpolation.ts +219 -0
  339. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +375 -0
  340. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +17 -0
  341. package/src/extensions/pi-agent-text-editor/src/api/anchor-inspection.ts +24 -0
  342. package/src/extensions/pi-agent-text-editor/src/api/connect-plugin.ts +67 -0
  343. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +19 -0
  344. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +64 -0
  345. package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +46 -0
  346. package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +46 -0
  347. package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +30 -0
  348. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +23 -0
  349. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +180 -0
  350. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +217 -0
  351. package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +147 -0
  352. package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +17 -0
  353. package/src/extensions/pi-agent-text-editor/src/api/text-selection-anchor.ts +121 -0
  354. package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +11 -0
  355. package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +39 -0
  356. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +59 -0
  357. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +150 -0
  358. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +386 -0
  359. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +129 -0
  360. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +359 -0
  361. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +648 -0
  362. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +117 -0
  363. package/src/extensions/pi-agent-text-editor/src/core/text-anchor-recovery.ts +24 -0
  364. package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +381 -0
  365. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +273 -0
  366. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +607 -0
  367. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-execution.ts +127 -0
  368. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +45 -0
  369. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +432 -0
  370. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +115 -0
  371. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +2348 -0
  372. package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +28 -0
  373. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +756 -0
  374. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1235 -0
  375. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/partial-json-resolver.ts +43 -0
  376. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/partial-tool-recovery.ts +308 -0
  377. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +4 -0
  378. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +467 -0
  379. package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +16 -0
  380. package/src/extensions/pi-agent-text-editor/src/tools/extension.ts +19 -0
  381. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +106 -0
  382. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +121 -0
  383. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +79 -0
  384. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +56 -0
  385. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +142 -0
  386. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +72 -0
  387. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +28 -0
  388. package/src/index.ts +1 -0
  389. package/src/pi-agent-ide.ts +17 -0
  390. package/src/plugins/pi-agent-ide-ast/index.ts +1 -0
  391. package/src/plugins/pi-agent-ide-ast/package.json +39 -0
  392. package/src/plugins/pi-agent-ide-ast/src/api/scope.ts +1 -0
  393. package/src/plugins/pi-agent-ide-ast/src/ast/collect-files.ts +24 -0
  394. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +374 -0
  395. package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +813 -0
  396. package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +30 -0
  397. package/src/plugins/pi-agent-ide-ast/src/extension.ts +85 -0
  398. package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +69 -0
  399. package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +221 -0
  400. package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +45 -0
  401. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +141 -0
  402. package/src/plugins/pi-agent-ide-changes/index.ts +68 -0
  403. package/src/plugins/pi-agent-ide-changes/package.json +29 -0
  404. package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +103 -0
  405. package/src/plugins/pi-agent-ide-changes/src/changes/change-groups.ts +309 -0
  406. package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +223 -0
  407. package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +105 -0
  408. package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +325 -0
  409. package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +232 -0
  410. package/src/plugins/pi-agent-ide-changes/src/index-mutation-queue.ts +11 -0
  411. package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +88 -0
  412. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +116 -0
  413. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +153 -0
  414. package/src/plugins/pi-agent-ide-formatter/index.ts +33 -0
  415. package/src/plugins/pi-agent-ide-formatter/package.json +14 -0
  416. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +50 -0
  417. package/src/plugins/pi-agent-ide-formatter/src/registry.ts +30 -0
  418. package/src/plugins/pi-agent-ide-formatter/src/types.ts +10 -0
  419. package/src/plugins/pi-agent-ide-lint/index.ts +237 -0
  420. package/src/plugins/pi-agent-ide-lint/package.json +19 -0
  421. package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +160 -0
  422. package/src/plugins/pi-agent-ide-lint/src/command-runner.ts +51 -0
  423. package/src/plugins/pi-agent-ide-lint/src/registry.ts +30 -0
  424. package/src/plugins/pi-agent-ide-lint/src/types.ts +10 -0
  425. package/src/plugins/pi-agent-ide-lsp/index.ts +250 -0
  426. package/src/plugins/pi-agent-ide-lsp/package.json +23 -0
  427. package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +139 -0
  428. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +463 -0
  429. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +577 -0
  430. package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +179 -0
  431. package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +59 -0
  432. package/src/plugins/pi-agent-ide-lsp/src/lsp/language-map.ts +57 -0
  433. package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +85 -0
  434. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +485 -0
  435. package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +85 -0
  436. package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +97 -0
  437. package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +50 -0
  438. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +149 -0
  439. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +151 -0
  440. package/src/plugins/pi-agent-ide-lsp/src/lsp/types.ts +95 -0
  441. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +42 -0
  442. package/src/post-edit/gate.ts +153 -0
  443. package/src/toolchain/diagnostic.ts +7 -0
  444. package/src/toolchain/gate.ts +322 -0
  445. package/src/toolchain/registry.ts +223 -0
  446. package/src/toolchain/types.ts +164 -0
@@ -0,0 +1,65 @@
1
+ export type { AgentContent, AgentContentBlock, CustomContent, ImageContent, TextContent } from "./content.js";
2
+
3
+ export type {
4
+ ContentCapability,
5
+ ContentConversionAttempt,
6
+ ContentConversionContext,
7
+ ContentConverter,
8
+ ContentConverterRegistration,
9
+ ContentDescription,
10
+ ContentInput,
11
+ ContentTarget,
12
+ } from "./content-conversion/content-converter.js";
13
+
14
+ export { renderContentDescription } from "./content-conversion/content-description.js";
15
+
16
+ export { type ContentHost, createContentHost } from "./content-conversion/content-host.js";
17
+
18
+ export {
19
+ type ContentRunner,
20
+ createContentRunner,
21
+ targetsEqual,
22
+ UnsupportedContentError,
23
+ } from "./content-conversion/content-runner.js";
24
+
25
+ export { connectContentConverter } from "./content-conversion/connect-plugin.js";
26
+
27
+ export {
28
+ CONTENT_API_VERSION,
29
+ CONTENT_CONVERTER_REGISTER_EVENT,
30
+ CONTENT_HOST_READY_EVENT,
31
+ CONTENT_PROTOCOL,
32
+ type ContentConverterRegistrationRequest,
33
+ type ContentHostReady,
34
+ isContentConverterRegistrationRequest,
35
+ isContentHostReady,
36
+ } from "./content-conversion/plugin-protocol.js";
37
+
38
+ export {
39
+ isContentConversionAttempt,
40
+ isContentConversionContext,
41
+ isContentConverter,
42
+ isContentConverterRegistration,
43
+ isContentInput,
44
+ isContentTarget,
45
+ } from "./content-conversion/validation.js";
46
+
47
+ export type {
48
+ ReadableResource,
49
+ ReadWriteResource,
50
+ Resource,
51
+ ResourceBase,
52
+ ResourceOperationContext,
53
+ ResourceRead,
54
+ ResourceWrite,
55
+ WritableResource,
56
+ } from "./resource.js";
57
+
58
+ export type {
59
+ ResourceResolutionAttempt,
60
+ ResourceResolver,
61
+ ResourceResolverContext,
62
+ ResourceTryResolve,
63
+ } from "./resolver.js";
64
+
65
+ export { isAgentContent, isResource, isResourceResolutionAttempt, isResourceResolver } from "./validation.js";
@@ -0,0 +1,23 @@
1
+ import type { Resource } from "./resource.js";
2
+
3
+ export interface ResourceResolverContext
4
+ {
5
+ readonly cwd: string;
6
+ readonly signal?: AbortSignal;
7
+ }
8
+
9
+ export type ResourceResolutionAttempt =
10
+ | { readonly kind: "not-handled"; }
11
+ | { readonly kind: "resolved"; readonly resource: Resource; }
12
+ | { readonly kind: "failed"; readonly error: unknown; };
13
+
14
+ export type ResourceTryResolve = (
15
+ source: string,
16
+ context: ResourceResolverContext,
17
+ ) => Promise<ResourceResolutionAttempt>;
18
+
19
+ export interface ResourceResolver
20
+ {
21
+ readonly id: string;
22
+ readonly tryResolve: ResourceTryResolve;
23
+ }
@@ -0,0 +1,41 @@
1
+ import type { AgentContent } from "./content.js";
2
+
3
+ export interface ResourceOperationContext
4
+ {
5
+ readonly signal?: AbortSignal;
6
+ }
7
+
8
+ export type ResourceRead = (
9
+ context: ResourceOperationContext,
10
+ ) => Promise<AgentContent>;
11
+
12
+ export type ResourceWrite = (
13
+ content: AgentContent,
14
+ context: ResourceOperationContext,
15
+ ) => Promise<void>;
16
+
17
+ export interface ResourceBase
18
+ {
19
+ readonly source: string;
20
+ readonly link?: string;
21
+ }
22
+
23
+ export interface ReadableResource extends ResourceBase
24
+ {
25
+ readonly read: ResourceRead;
26
+ readonly write?: never;
27
+ }
28
+
29
+ export interface WritableResource extends ResourceBase
30
+ {
31
+ readonly read?: never;
32
+ readonly write: ResourceWrite;
33
+ }
34
+
35
+ export interface ReadWriteResource extends ResourceBase
36
+ {
37
+ readonly read: ResourceRead;
38
+ readonly write: ResourceWrite;
39
+ }
40
+
41
+ export type Resource = ReadableResource | WritableResource | ReadWriteResource;
@@ -0,0 +1,139 @@
1
+ import { type TSchema, Type } from "typebox";
2
+ import { Value } from "typebox/value";
3
+
4
+ import type { AgentContent } from "./content.js";
5
+ import type { ResourceResolutionAttempt, ResourceResolver } from "./resolver.js";
6
+ import type { Resource } from "./resource.js";
7
+
8
+ const objectOptions = { additionalProperties: true } as const;
9
+ const functionSchema = Type.Function([], Type.Unknown());
10
+ const nonEmptyStringSchema = Type.String({ minLength: 1 });
11
+
12
+ const textContentSchema = Type.Object({
13
+ type: Type.Literal("text"),
14
+ text: Type.String(),
15
+ textSignature: Type.Optional(Type.String()),
16
+ }, objectOptions);
17
+
18
+ const imageContentSchema = Type.Object({
19
+ type: Type.Literal("image"),
20
+ data: Type.String(),
21
+ mimeType: Type.String(),
22
+ }, objectOptions);
23
+
24
+ const customContentSchema = Type.Object({
25
+ type: Type.Literal("custom"),
26
+ kind: nonEmptyStringSchema,
27
+ data: Type.Unknown(),
28
+ }, objectOptions);
29
+
30
+ const agentContentSchema = Type.Array(
31
+ Type.Union([textContentSchema, imageContentSchema, customContentSchema]),
32
+ { minItems: 1 },
33
+ );
34
+
35
+ const resourceSchema = Type.Union([
36
+ Type.Object({
37
+ source: nonEmptyStringSchema,
38
+ link: Type.Optional(nonEmptyStringSchema),
39
+ read: functionSchema,
40
+ write: Type.Optional(Type.Never()),
41
+ }, objectOptions),
42
+ Type.Object({
43
+ source: nonEmptyStringSchema,
44
+ link: Type.Optional(nonEmptyStringSchema),
45
+ read: Type.Optional(Type.Never()),
46
+ write: functionSchema,
47
+ }, objectOptions),
48
+ Type.Object({
49
+ source: nonEmptyStringSchema,
50
+ link: Type.Optional(nonEmptyStringSchema),
51
+ read: functionSchema,
52
+ write: functionSchema,
53
+ }, objectOptions),
54
+ ]);
55
+
56
+ const resourceResolverSchema = Type.Object({
57
+ id: nonEmptyStringSchema,
58
+ tryResolve: functionSchema,
59
+ }, objectOptions);
60
+
61
+ const resourceResolutionAttemptSchema = Type.Union([
62
+ Type.Object({ kind: Type.Literal("not-handled") }, objectOptions),
63
+ Type.Object({
64
+ kind: Type.Literal("resolved"),
65
+ resource: resourceSchema,
66
+ }, objectOptions),
67
+ Type.Object({
68
+ kind: Type.Literal("failed"),
69
+ error: Type.Unknown(),
70
+ }, objectOptions),
71
+ ]);
72
+
73
+ export function isAgentContent(value: unknown): value is AgentContent
74
+ {
75
+ if (!safeCheck(agentContentSchema, value))
76
+ {
77
+ return false;
78
+ }
79
+
80
+ return safeEvaluate(() =>
81
+ (value as readonly Record<PropertyKey, unknown>[]).every((block) =>
82
+ block.type !== "text"
83
+ || !("textSignature" in block)
84
+ || typeof block.textSignature === "string"
85
+ )
86
+ );
87
+ }
88
+
89
+ export function isResource(value: unknown): value is Resource
90
+ {
91
+ if (!safeCheck(resourceSchema, value))
92
+ {
93
+ return false;
94
+ }
95
+
96
+ return safeEvaluate(() =>
97
+ {
98
+ const resource = value as Record<PropertyKey, unknown>;
99
+ const readIsValid = !("read" in resource) || typeof resource.read === "function";
100
+ const writeIsValid = !("write" in resource) || typeof resource.write === "function";
101
+ return readIsValid && writeIsValid;
102
+ });
103
+ }
104
+
105
+ export function isResourceResolver(value: unknown): value is ResourceResolver
106
+ {
107
+ return safeCheck(resourceResolverSchema, value);
108
+ }
109
+
110
+ export function isResourceResolutionAttempt(value: unknown): value is ResourceResolutionAttempt
111
+ {
112
+ if (!safeCheck(resourceResolutionAttemptSchema, value))
113
+ {
114
+ return false;
115
+ }
116
+
117
+ return safeEvaluate(() =>
118
+ {
119
+ const attempt = value as Record<PropertyKey, unknown>;
120
+ return attempt.kind !== "resolved" || isResource(attempt.resource);
121
+ });
122
+ }
123
+
124
+ function safeCheck(schema: TSchema, value: unknown): boolean
125
+ {
126
+ return safeEvaluate(() => Value.Check(schema, value));
127
+ }
128
+
129
+ function safeEvaluate(check: () => boolean): boolean
130
+ {
131
+ try
132
+ {
133
+ return check();
134
+ }
135
+ catch
136
+ {
137
+ return false;
138
+ }
139
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./src/core/extension.js";
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "pi-agent-search",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "pi": {
6
+ "extensions": [
7
+ "./index.ts"
8
+ ]
9
+ },
10
+ "imports": {
11
+ "#src/*": "./src/*"
12
+ },
13
+ "exports": {
14
+ "./api/connect-plugin": {
15
+ "types": "./src/api/connect-plugin.ts",
16
+ "default": "./src/api/connect-plugin.ts"
17
+ },
18
+ "./api/plugin-protocol": {
19
+ "types": "./src/api/plugin-protocol.ts",
20
+ "default": "./src/api/plugin-protocol.ts"
21
+ },
22
+ "./api/search": {
23
+ "types": "./src/api/search.ts",
24
+ "default": "./src/api/search.ts"
25
+ }
26
+ },
27
+ "dependencies": {
28
+ "pi-agent-tool-call-interception": "0.1.0"
29
+ },
30
+ "peerDependencies": {
31
+ "@earendil-works/pi-coding-agent": "*",
32
+ "@earendil-works/pi-tui": "*",
33
+ "typebox": "*"
34
+ }
35
+ }
@@ -0,0 +1,61 @@
1
+ import {
2
+ isSearchCoreReady,
3
+ SEARCH_CORE_READY_EVENT,
4
+ SEARCH_PLUGIN_REGISTER_EVENT,
5
+ type SearchPlugin,
6
+ type SearchPluginRegistrationRequest,
7
+ } from "#src/api/plugin-protocol.js";
8
+
9
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
10
+
11
+ export function connectSearchPlugin(pi: ExtensionAPI, plugin: SearchPlugin): void | Promise<void>
12
+ {
13
+ const announce = (): Promise<void> | undefined =>
14
+ {
15
+ let registration: Promise<void> | undefined;
16
+ const request = {
17
+ plugin,
18
+ accept(value): void
19
+ {
20
+ if (registration !== undefined)
21
+ {
22
+ throw new Error(`Plugin ${plugin.id} registration was accepted more than once`);
23
+ }
24
+
25
+ registration = value;
26
+ },
27
+ } satisfies SearchPluginRegistrationRequest;
28
+ pi.events.emit(SEARCH_PLUGIN_REGISTER_EVENT, request);
29
+ return registration;
30
+ };
31
+ let unsubscribe = (): void =>
32
+ {};
33
+ unsubscribe = pi.events.on(SEARCH_CORE_READY_EVENT, (ready) =>
34
+ {
35
+ if (!isSearchCoreReady(ready))
36
+ {
37
+ throw new Error("Invalid pi-agent-search core readiness event");
38
+ }
39
+
40
+ const registration = announce();
41
+
42
+ if (registration === undefined)
43
+ {
44
+ throw new Error("pi-agent-search core announced readiness without accepting the plugin");
45
+ }
46
+
47
+ unsubscribe();
48
+ void registration.catch(() =>
49
+ {});
50
+ });
51
+ pi.on("session_shutdown", unsubscribe);
52
+ const registration = announce();
53
+
54
+ if (registration === undefined)
55
+ {
56
+ return;
57
+ }
58
+
59
+ unsubscribe();
60
+ return registration;
61
+ }
@@ -0,0 +1,60 @@
1
+ import { Type } from "typebox";
2
+ import { Value } from "typebox/value";
3
+
4
+ import type { SearchPluginApi } from "#src/api/search.js";
5
+
6
+ export const SEARCH_PROTOCOL = "pi-agent-search" as const;
7
+
8
+ export const SEARCH_API_VERSION = 1 as const;
9
+
10
+ export const SEARCH_CORE_READY_EVENT = "pi-agent-search/core/ready" as const;
11
+
12
+ export const SEARCH_PLUGIN_REGISTER_EVENT = "pi-agent-search/plugin/register" as const;
13
+
14
+ export interface SearchCoreReady
15
+ {
16
+ readonly protocol: typeof SEARCH_PROTOCOL;
17
+ readonly apiVersion: typeof SEARCH_API_VERSION;
18
+ }
19
+
20
+ export interface SearchPlugin
21
+ {
22
+ readonly protocol: typeof SEARCH_PROTOCOL;
23
+ readonly apiVersion: typeof SEARCH_API_VERSION;
24
+ readonly id: string;
25
+ readonly setup: (api: SearchPluginApi) => void | Promise<void>;
26
+ }
27
+
28
+ export interface SearchPluginRegistrationRequest
29
+ {
30
+ readonly plugin: SearchPlugin;
31
+ accept(registration: Promise<void>): void;
32
+ }
33
+
34
+ const functionSchema = Type.Unsafe<(...args: never[]) => unknown>({ type: "Function" });
35
+ const coreReadySchema = Type.Object({
36
+ protocol: Type.Literal(SEARCH_PROTOCOL),
37
+ apiVersion: Type.Literal(SEARCH_API_VERSION),
38
+ });
39
+ const pluginSchema = Type.Object({
40
+ protocol: Type.Literal(SEARCH_PROTOCOL),
41
+ apiVersion: Type.Literal(SEARCH_API_VERSION),
42
+ id: Type.String({ minLength: 1 }),
43
+ setup: functionSchema,
44
+ });
45
+ const registrationSchema = Type.Object({ plugin: pluginSchema, accept: functionSchema });
46
+
47
+ export function isSearchCoreReady(value: unknown): value is SearchCoreReady
48
+ {
49
+ return Value.Check(coreReadySchema, value);
50
+ }
51
+
52
+ export function isSearchPlugin(value: unknown): value is SearchPlugin
53
+ {
54
+ return Value.Check(pluginSchema, value);
55
+ }
56
+
57
+ export function isSearchPluginRegistrationRequest(value: unknown): value is SearchPluginRegistrationRequest
58
+ {
59
+ return Value.Check(registrationSchema, value);
60
+ }
@@ -0,0 +1,91 @@
1
+ import type { AgentToolResult, ToolDefinition } from "@earendil-works/pi-coding-agent";
2
+
3
+ export interface SearchRequest
4
+ {
5
+ readonly query: string;
6
+ readonly path?: string;
7
+ readonly include?: string;
8
+ readonly exclude?: string;
9
+ readonly caseSensitive?: boolean;
10
+ readonly wholeWord?: boolean;
11
+ readonly limit?: number;
12
+ }
13
+
14
+ export interface SearchContext
15
+ {
16
+ readonly cwd: string;
17
+ readonly signal?: AbortSignal;
18
+ readonly onUpdate?: (result: AgentToolResult<unknown>) => void;
19
+ }
20
+
21
+ export type SearchResolutionAttempt =
22
+ | { readonly kind: "not-handled"; }
23
+ | { readonly kind: "resolved"; readonly payload: unknown; }
24
+ | { readonly kind: "failed"; readonly error: unknown; };
25
+
26
+ export interface SearchResolver
27
+ {
28
+ readonly id: string;
29
+ tryResolve(
30
+ request: SearchRequest,
31
+ context: SearchContext,
32
+ ): SearchResolutionAttempt | Promise<SearchResolutionAttempt>;
33
+ format(payload: unknown, context: SearchContext): AgentToolResult<unknown> | Promise<AgentToolResult<unknown>>;
34
+ readonly renderResult?: ToolDefinition["renderResult"];
35
+ }
36
+
37
+ export interface SearchResolverRegistration
38
+ {
39
+ readonly resolver: SearchResolver;
40
+ readonly priority?: number;
41
+ }
42
+
43
+ export type SearchDescriptionSource = string | (() => string | undefined);
44
+
45
+ export interface SearchReference
46
+ {
47
+ readonly value: string;
48
+ readonly resolverId: string;
49
+ readonly capabilities: readonly string[];
50
+ }
51
+
52
+ export interface SearchActionRequest
53
+ {
54
+ readonly reference: string;
55
+ readonly resolverId: string;
56
+ readonly capability: string;
57
+ readonly input: unknown;
58
+ }
59
+
60
+ export interface SearchActionRegistration
61
+ {
62
+ readonly resolverId: string;
63
+ readonly capability: string;
64
+ execute(reference: string, input: unknown, context: SearchContext): Promise<unknown>;
65
+ }
66
+
67
+ export interface SearchPluginApi
68
+ {
69
+ addResolver(registration: SearchResolverRegistration): void;
70
+ addAction(registration: SearchActionRegistration): void;
71
+ describe(description: SearchDescriptionSource): void;
72
+ search(request: SearchRequest, context: SearchContext): Promise<AgentToolResult<unknown>>;
73
+ runAction(request: SearchActionRequest, context: SearchContext): Promise<unknown>;
74
+ }
75
+
76
+ export interface SearchToolDetails
77
+ {
78
+ readonly resolverId?: string;
79
+ readonly payload?: unknown;
80
+ readonly failure?: {
81
+ readonly code:
82
+ | "INVALID_REQUEST"
83
+ | "NO_RESOLVER"
84
+ | "RESOLVE_FAILED"
85
+ | "INVALID_RESOLVER_RESULT"
86
+ | "FORMAT_FAILED";
87
+ readonly message: string;
88
+ readonly resolverId?: string;
89
+ readonly cause?: unknown;
90
+ };
91
+ }
@@ -0,0 +1,126 @@
1
+ import {
2
+ type AgentToolResult,
3
+ type ExtensionAPI,
4
+ keyText,
5
+ type Theme,
6
+ type ToolRenderResultOptions,
7
+ } from "@earendil-works/pi-coding-agent";
8
+ import { type Component, Text } from "@earendil-works/pi-tui";
9
+ import { ToolCallInterceptionRenderStore, withToolCallInterceptionRendering } from "pi-agent-tool-call-interception";
10
+ import { type Static, Type } from "typebox";
11
+
12
+ import {
13
+ isSearchPluginRegistrationRequest,
14
+ SEARCH_API_VERSION,
15
+ SEARCH_CORE_READY_EVENT,
16
+ SEARCH_PLUGIN_REGISTER_EVENT,
17
+ SEARCH_PROTOCOL,
18
+ } from "#src/api/plugin-protocol.js";
19
+ import { createSearchCore } from "#src/core/search-core.js";
20
+
21
+ import type { SearchToolDetails } from "#src/api/search.js";
22
+
23
+ const searchSchema = Type.Object({
24
+ query: Type.String({
25
+ minLength: 1,
26
+ description: "Search query. Installed prefixes select specialized search protocols.",
27
+ }),
28
+ path: Type.Optional(Type.String({ description: "Optional file or directory scope for local search" })),
29
+ include: Type.Optional(Type.String({ description: "Optional include glob for local search" })),
30
+ exclude: Type.Optional(Type.String({ description: "Optional exclude glob for local search" })),
31
+ caseSensitive: Type.Optional(Type.Boolean({ description: "Match letter case in local search" })),
32
+ wholeWord: Type.Optional(Type.Boolean({ description: "Match complete words in local search" })),
33
+ limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 1000, description: "Maximum results (default 100)" })),
34
+ }, { additionalProperties: false });
35
+
36
+ type SearchParams = Static<typeof searchSchema>;
37
+
38
+ export default async function registerSearchCore(pi: ExtensionAPI): Promise<void>
39
+ {
40
+ const core = createSearchCore();
41
+ const interceptionRendering = new ToolCallInterceptionRenderStore();
42
+ const unsubscribe = pi.events.on(SEARCH_PLUGIN_REGISTER_EVENT, (request) =>
43
+ {
44
+ if (!isSearchPluginRegistrationRequest(request))
45
+ {
46
+ throw new Error("Invalid pi-agent-search plugin registration request");
47
+ }
48
+
49
+ request.accept(core.registerPlugin(request.plugin));
50
+ });
51
+ pi.on("session_shutdown", unsubscribe);
52
+ pi.registerTool(withToolCallInterceptionRendering({
53
+ name: "search",
54
+ label: "search",
55
+ description: "Search through installed local, semantic, web, language, and structural search protocols.",
56
+ promptSnippet: "Search workspace text and paths and return reusable anchors for text edits",
57
+ get promptGuidelines(): string[]
58
+ {
59
+ const pluginGuideline = core.renderPromptGuideline();
60
+ return [
61
+ "Use the narrowest useful search query and scope; broaden when needed.",
62
+ "Do not use search to rediscover a file path already named in the request; use that path directly and search only if access fails.",
63
+ "When exact text that may need editing is already known, use search directly instead of repeating the lookup with grep or find; search returns reusable anchors.",
64
+ "When every exact search match needs the same replacement, pass the returned SEARCH#HASH:all anchor to replace.",
65
+ ...(pluginGuideline === undefined ? [] : [pluginGuideline]),
66
+ ];
67
+ },
68
+ parameters: searchSchema,
69
+ renderShell: "self",
70
+ renderCall(args, theme): Component
71
+ {
72
+ const query = typeof args.query === "string" ? args.query : "";
73
+ const scope = typeof args.path === "string" ? ` ${theme.fg("dim", args.path)}` : "";
74
+ return new Text(
75
+ `${theme.fg("toolTitle", theme.bold("search"))} ${theme.fg("accent", JSON.stringify(query))}${scope}`,
76
+ 0,
77
+ 0,
78
+ );
79
+ },
80
+ renderResult(result, options, theme, context): Component
81
+ {
82
+ const details = result.details as SearchToolDetails | undefined;
83
+ const renderer = details?.resolverId === undefined ? undefined : core.renderer(details.resolverId);
84
+
85
+ if (renderer !== undefined)
86
+ {
87
+ const inner = { ...result, details: details?.payload };
88
+ return renderer(inner, options, theme, context);
89
+ }
90
+
91
+ return fallbackResult(result, options, theme);
92
+ },
93
+ async execute(_id, params: SearchParams, signal, onUpdate, context): Promise<AgentToolResult<SearchToolDetails>>
94
+ {
95
+ await core.waitForPendingPlugins();
96
+ return core.execute(params, {
97
+ cwd: context.cwd,
98
+ ...(signal === undefined ? {} : { signal }),
99
+ ...(onUpdate === undefined
100
+ ? {}
101
+ : {
102
+ onUpdate: (update) =>
103
+ {
104
+ onUpdate(update);
105
+ },
106
+ }),
107
+ });
108
+ },
109
+ }, interceptionRendering));
110
+ pi.events.emit(SEARCH_CORE_READY_EVENT, { protocol: SEARCH_PROTOCOL, apiVersion: SEARCH_API_VERSION });
111
+ await core.waitForPendingPlugins();
112
+ }
113
+
114
+ function fallbackResult(
115
+ result: AgentToolResult<unknown>,
116
+ options: ToolRenderResultOptions,
117
+ theme: Theme,
118
+ ): Component
119
+ {
120
+ const text = result.content.flatMap((part) => part.type === "text" ? [part.text] : []).join("\n");
121
+ const preview = options.expanded ? text : text.split("\n").slice(0, 8).join("\n");
122
+ const hint = !options.expanded && text.split("\n").length > 8
123
+ ? `\n${theme.fg("dim", `${keyText("app.tools.expand")} to expand`)}`
124
+ : "";
125
+ return new Text(`${theme.fg("muted", preview)}${hint}`, 0, 0);
126
+ }