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.
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/assets/banner.png +0 -0
- package/docs/architecture.md +100 -0
- package/docs/configuration.md +104 -0
- package/docs/development.md +102 -0
- package/docs/evaluation.md +14 -0
- package/docs/extensions.md +298 -0
- package/docs/tools.md +104 -0
- package/node_modules/pi-agent-filesystem/index.ts +60 -0
- package/node_modules/pi-agent-filesystem/package.json +23 -0
- package/node_modules/pi-agent-filesystem/src/resolver.ts +175 -0
- package/node_modules/pi-agent-filesystem-image/index.ts +14 -0
- package/node_modules/pi-agent-filesystem-image/package.json +20 -0
- package/node_modules/pi-agent-filesystem-pdf/index.ts +14 -0
- package/node_modules/pi-agent-filesystem-pdf/package.json +17 -0
- package/node_modules/pi-agent-filesystem-text/index.ts +23 -0
- package/node_modules/pi-agent-filesystem-text/package.json +20 -0
- package/node_modules/pi-agent-ide-ast/index.ts +1 -0
- package/node_modules/pi-agent-ide-ast/package.json +39 -0
- package/node_modules/pi-agent-ide-ast/src/api/scope.ts +1 -0
- package/node_modules/pi-agent-ide-ast/src/ast/collect-files.ts +24 -0
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +374 -0
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +813 -0
- package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +30 -0
- package/node_modules/pi-agent-ide-ast/src/extension.ts +85 -0
- package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +69 -0
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +221 -0
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +45 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +141 -0
- package/node_modules/pi-agent-ide-changes/index.ts +68 -0
- package/node_modules/pi-agent-ide-changes/package.json +29 -0
- package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +103 -0
- package/node_modules/pi-agent-ide-changes/src/changes/change-groups.ts +309 -0
- package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +223 -0
- package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +105 -0
- package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +325 -0
- package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +232 -0
- package/node_modules/pi-agent-ide-changes/src/index-mutation-queue.ts +11 -0
- package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +88 -0
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +116 -0
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +153 -0
- package/node_modules/pi-agent-ide-formatter/index.ts +33 -0
- package/node_modules/pi-agent-ide-formatter/package.json +14 -0
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +50 -0
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +30 -0
- package/node_modules/pi-agent-ide-formatter/src/types.ts +10 -0
- package/node_modules/pi-agent-ide-lint/index.ts +237 -0
- package/node_modules/pi-agent-ide-lint/package.json +19 -0
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +160 -0
- package/node_modules/pi-agent-ide-lint/src/command-runner.ts +51 -0
- package/node_modules/pi-agent-ide-lint/src/registry.ts +30 -0
- package/node_modules/pi-agent-ide-lint/src/types.ts +10 -0
- package/node_modules/pi-agent-ide-lsp/index.ts +250 -0
- package/node_modules/pi-agent-ide-lsp/package.json +23 -0
- package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +139 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +463 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +577 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +179 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +59 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/language-map.ts +57 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +85 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +485 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +85 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +97 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +50 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +149 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +151 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/types.ts +95 -0
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +42 -0
- package/node_modules/pi-agent-image/package.json +18 -0
- package/node_modules/pi-agent-image/src/image-converter.ts +318 -0
- package/node_modules/pi-agent-image/src/index.ts +6 -0
- package/node_modules/pi-agent-pdf/package.json +16 -0
- package/node_modules/pi-agent-pdf/src/index.ts +5 -0
- package/node_modules/pi-agent-pdf/src/pdf-converter.ts +197 -0
- package/node_modules/pi-agent-read/index.ts +1 -0
- package/node_modules/pi-agent-read/package.json +41 -0
- package/node_modules/pi-agent-read/src/api/connect-plugin.ts +67 -0
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +67 -0
- package/node_modules/pi-agent-read/src/api/rendering.ts +11 -0
- package/node_modules/pi-agent-read/src/api/tools/read.ts +208 -0
- package/node_modules/pi-agent-read/src/core/extension.ts +40 -0
- package/node_modules/pi-agent-read/src/core/read-core.ts +390 -0
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +193 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +400 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +187 -0
- package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +218 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +828 -0
- package/node_modules/pi-agent-resource/package.json +17 -0
- package/node_modules/pi-agent-resource/src/content-conversion/connect-plugin.ts +84 -0
- package/node_modules/pi-agent-resource/src/content-conversion/content-converter.ts +49 -0
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +29 -0
- package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +73 -0
- package/node_modules/pi-agent-resource/src/content-conversion/content-runner.ts +152 -0
- package/node_modules/pi-agent-resource/src/content-conversion/plugin-protocol.ts +74 -0
- package/node_modules/pi-agent-resource/src/content-conversion/validation.ts +149 -0
- package/node_modules/pi-agent-resource/src/content.ts +17 -0
- package/node_modules/pi-agent-resource/src/index.ts +65 -0
- package/node_modules/pi-agent-resource/src/resolver.ts +23 -0
- package/node_modules/pi-agent-resource/src/resource.ts +41 -0
- package/node_modules/pi-agent-resource/src/validation.ts +139 -0
- package/node_modules/pi-agent-search/index.ts +1 -0
- package/node_modules/pi-agent-search/package.json +35 -0
- package/node_modules/pi-agent-search/src/api/connect-plugin.ts +61 -0
- package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +60 -0
- package/node_modules/pi-agent-search/src/api/search.ts +91 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +126 -0
- package/node_modules/pi-agent-search/src/core/search-core.ts +400 -0
- package/node_modules/pi-agent-search-semantic/index.ts +105 -0
- package/node_modules/pi-agent-search-semantic/package.json +17 -0
- package/node_modules/pi-agent-search-text/index.ts +54 -0
- package/node_modules/pi-agent-search-text/package.json +33 -0
- package/node_modules/pi-agent-search-text/src/file-search.ts +105 -0
- package/node_modules/pi-agent-search-text/src/lucene-query-parser.d.ts +22 -0
- package/node_modules/pi-agent-search-text/src/resolvers.ts +192 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +295 -0
- package/node_modules/pi-agent-search-text/src/search-query.ts +139 -0
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +420 -0
- package/node_modules/pi-agent-search-text/src/search-result.ts +193 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +338 -0
- package/node_modules/pi-agent-search-web/index.ts +74 -0
- package/node_modules/pi-agent-search-web/package.json +19 -0
- package/node_modules/pi-agent-search-web/src/config.ts +499 -0
- package/node_modules/pi-agent-search-web/src/providers/duckduckgo-html.ts +78 -0
- package/node_modules/pi-agent-search-web/src/providers/endpoints.ts +89 -0
- package/node_modules/pi-agent-search-web/src/providers/request.ts +430 -0
- package/node_modules/pi-agent-search-web/src/providers/response.ts +402 -0
- package/node_modules/pi-agent-search-web/src/search-format.ts +29 -0
- package/node_modules/pi-agent-search-web/src/search.ts +434 -0
- package/node_modules/pi-agent-search-web/src/types.ts +153 -0
- package/node_modules/pi-agent-text/package.json +18 -0
- package/node_modules/pi-agent-text/src/index.ts +31 -0
- package/node_modules/pi-agent-text/src/presented-text.ts +24 -0
- package/node_modules/pi-agent-text/src/source-line.ts +49 -0
- package/node_modules/pi-agent-text/src/text-anchor.ts +157 -0
- package/node_modules/pi-agent-text/src/text-converter.ts +109 -0
- package/node_modules/pi-agent-text/src/text-document.ts +149 -0
- package/node_modules/pi-agent-text-anchor-constant/index.ts +30 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +17 -0
- package/node_modules/pi-agent-text-anchor-constant/src/resolver.ts +47 -0
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +48 -0
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +24 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/anchor.ts +110 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +47 -0
- package/node_modules/pi-agent-text-editor/index.ts +19 -0
- package/node_modules/pi-agent-text-editor/package.json +92 -0
- package/node_modules/pi-agent-text-editor/src/api/anchor-inspection.ts +24 -0
- package/node_modules/pi-agent-text-editor/src/api/connect-plugin.ts +67 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +19 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +64 -0
- package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +46 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +46 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +30 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +23 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +180 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +217 -0
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +147 -0
- package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +17 -0
- package/node_modules/pi-agent-text-editor/src/api/text-selection-anchor.ts +121 -0
- package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +11 -0
- package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +39 -0
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +59 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +150 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +386 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +129 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +359 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +648 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +117 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-recovery.ts +24 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +381 -0
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +273 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +607 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-execution.ts +127 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +45 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +432 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +115 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +2348 -0
- package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +28 -0
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +756 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1235 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/partial-json-resolver.ts +43 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/partial-tool-recovery.ts +308 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +467 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +16 -0
- package/node_modules/pi-agent-text-editor/src/tools/extension.ts +19 -0
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +106 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +121 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +79 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +56 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +142 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +72 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +28 -0
- package/node_modules/pi-agent-text-editor-argument-order/index.ts +29 -0
- package/node_modules/pi-agent-text-editor-argument-order/package.json +16 -0
- package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +112 -0
- package/node_modules/pi-agent-text-editor-overwrite/index.ts +391 -0
- package/node_modules/pi-agent-text-editor-overwrite/package.json +16 -0
- package/node_modules/pi-agent-text-editor-renderer/index.ts +22 -0
- package/node_modules/pi-agent-text-editor-renderer/package.json +21 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +452 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +271 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-theme.ts +411 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +38 -0
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +205 -0
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +229 -0
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +407 -0
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +153 -0
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +8 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +728 -0
- package/node_modules/pi-agent-text-editor-renderer/src/typing-interpolation.ts +219 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +375 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +17 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +17 -0
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +418 -0
- package/node_modules/pi-agent-web/index.ts +37 -0
- package/node_modules/pi-agent-web/package.json +24 -0
- package/node_modules/pi-agent-web/src/resolver.ts +182 -0
- package/node_modules/pi-agent-web-html/index.ts +15 -0
- package/node_modules/pi-agent-web-html/package.json +18 -0
- package/node_modules/pi-agent-web-html/src/extract-readable-html.ts +101 -0
- package/node_modules/pi-agent-web-html/src/html-converter.ts +91 -0
- package/node_modules/pi-agent-web-image/index.ts +14 -0
- package/node_modules/pi-agent-web-image/package.json +17 -0
- package/node_modules/pi-agent-web-pdf/index.ts +14 -0
- package/node_modules/pi-agent-web-pdf/package.json +17 -0
- package/node_modules/pi-agent-web-text/index.ts +14 -0
- package/node_modules/pi-agent-web-text/package.json +17 -0
- package/package.json +176 -0
- package/src/api/code-view.ts +25 -0
- package/src/api/connect-plugin.ts +64 -0
- package/src/api/plugin-protocol.ts +63 -0
- package/src/api/read.ts +5 -0
- package/src/api/resource.ts +2 -0
- package/src/api/search.ts +4 -0
- package/src/api/text-editor.ts +3 -0
- package/src/api/text.ts +2 -0
- package/src/api/toolchain.ts +24 -0
- package/src/code-view/diagnostic-view.ts +82 -0
- package/src/code-view/reference.ts +113 -0
- package/src/code-view/source-view.ts +229 -0
- package/src/composite/builtin-extensions.ts +68 -0
- package/src/composite/config.ts +94 -0
- package/src/composite/selection.ts +66 -0
- package/src/core/extension.ts +48 -0
- package/src/core/ide-core.ts +117 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +60 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +23 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +20 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +17 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/index.ts +23 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +20 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +175 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +37 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +24 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/index.ts +15 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +18 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/extract-readable-html.ts +101 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +91 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +17 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +17 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +17 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +182 -0
- package/src/extensions/pi-agent-read/index.ts +1 -0
- package/src/extensions/pi-agent-read/package.json +41 -0
- package/src/extensions/pi-agent-read/src/api/connect-plugin.ts +67 -0
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +67 -0
- package/src/extensions/pi-agent-read/src/api/rendering.ts +11 -0
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +208 -0
- package/src/extensions/pi-agent-read/src/core/extension.ts +40 -0
- package/src/extensions/pi-agent-read/src/core/read-core.ts +390 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +193 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +400 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +187 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +218 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +828 -0
- package/src/extensions/pi-agent-search/index.ts +1 -0
- package/src/extensions/pi-agent-search/package.json +35 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/index.ts +105 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/package.json +17 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +54 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +33 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +105 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/lucene-query-parser.d.ts +22 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +192 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +295 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +139 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +420 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +193 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +338 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/index.ts +74 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/package.json +19 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/config.ts +499 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/duckduckgo-html.ts +78 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/endpoints.ts +89 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/request.ts +430 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/response.ts +402 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search-format.ts +29 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search.ts +434 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/types.ts +153 -0
- package/src/extensions/pi-agent-search/src/api/connect-plugin.ts +61 -0
- package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +60 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +91 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +126 -0
- package/src/extensions/pi-agent-search/src/core/search-core.ts +400 -0
- package/src/extensions/pi-agent-text-editor/index.ts +19 -0
- package/src/extensions/pi-agent-text-editor/package.json +92 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/index.ts +30 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +17 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/src/resolver.ts +47 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +48 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +24 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/anchor.ts +110 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +47 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +29 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +16 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +112 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +391 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +16 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +22 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +21 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +452 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +271 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-theme.ts +411 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +38 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +205 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +229 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +407 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +153 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +8 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +728 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/typing-interpolation.ts +219 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +375 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +17 -0
- package/src/extensions/pi-agent-text-editor/src/api/anchor-inspection.ts +24 -0
- package/src/extensions/pi-agent-text-editor/src/api/connect-plugin.ts +67 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +19 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +64 -0
- package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +46 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +46 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +30 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +23 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +180 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +217 -0
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +147 -0
- package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +17 -0
- package/src/extensions/pi-agent-text-editor/src/api/text-selection-anchor.ts +121 -0
- package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +11 -0
- package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +39 -0
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +59 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +150 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +386 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +129 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +359 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +648 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +117 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-recovery.ts +24 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +381 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +273 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +607 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-execution.ts +127 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +45 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +432 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +115 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +2348 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +28 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +756 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1235 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/partial-json-resolver.ts +43 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/partial-tool-recovery.ts +308 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +467 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +16 -0
- package/src/extensions/pi-agent-text-editor/src/tools/extension.ts +19 -0
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +106 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +121 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +79 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +56 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +142 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +72 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +28 -0
- package/src/index.ts +1 -0
- package/src/pi-agent-ide.ts +17 -0
- package/src/plugins/pi-agent-ide-ast/index.ts +1 -0
- package/src/plugins/pi-agent-ide-ast/package.json +39 -0
- package/src/plugins/pi-agent-ide-ast/src/api/scope.ts +1 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/collect-files.ts +24 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +374 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +813 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +30 -0
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +85 -0
- package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +69 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +221 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +45 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +141 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +68 -0
- package/src/plugins/pi-agent-ide-changes/package.json +29 -0
- package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +103 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/change-groups.ts +309 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +223 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +105 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +325 -0
- package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +232 -0
- package/src/plugins/pi-agent-ide-changes/src/index-mutation-queue.ts +11 -0
- package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +88 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +116 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +153 -0
- package/src/plugins/pi-agent-ide-formatter/index.ts +33 -0
- package/src/plugins/pi-agent-ide-formatter/package.json +14 -0
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +50 -0
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +30 -0
- package/src/plugins/pi-agent-ide-formatter/src/types.ts +10 -0
- package/src/plugins/pi-agent-ide-lint/index.ts +237 -0
- package/src/plugins/pi-agent-ide-lint/package.json +19 -0
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +160 -0
- package/src/plugins/pi-agent-ide-lint/src/command-runner.ts +51 -0
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +30 -0
- package/src/plugins/pi-agent-ide-lint/src/types.ts +10 -0
- package/src/plugins/pi-agent-ide-lsp/index.ts +250 -0
- package/src/plugins/pi-agent-ide-lsp/package.json +23 -0
- package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +139 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +463 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +577 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +179 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +59 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/language-map.ts +57 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +85 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +485 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +85 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +97 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +50 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +149 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +151 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/types.ts +95 -0
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +42 -0
- package/src/post-edit/gate.ts +153 -0
- package/src/toolchain/diagnostic.ts +7 -0
- package/src/toolchain/gate.ts +322 -0
- package/src/toolchain/registry.ts +223 -0
- package/src/toolchain/types.ts +164 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Defuddle } from "defuddle/node";
|
|
2
|
+
import { parseHTML } from "linkedom";
|
|
3
|
+
|
|
4
|
+
interface HtmlElementView
|
|
5
|
+
{
|
|
6
|
+
readonly textContent: string | null;
|
|
7
|
+
remove(): void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface HtmlDocumentView
|
|
11
|
+
{
|
|
12
|
+
readonly body: HtmlElementView | null;
|
|
13
|
+
readonly documentElement: HtmlElementView | null;
|
|
14
|
+
querySelector(selector: string): HtmlElementView | null;
|
|
15
|
+
querySelectorAll(selector: string): Iterable<HtmlElementView>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ExtractedHtml
|
|
19
|
+
{
|
|
20
|
+
readonly content: string;
|
|
21
|
+
readonly title: string;
|
|
22
|
+
readonly usedFallback: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type HtmlExtractor = (
|
|
26
|
+
html: string,
|
|
27
|
+
source: string,
|
|
28
|
+
) => Promise<{ readonly content: string; readonly title: string; }>;
|
|
29
|
+
|
|
30
|
+
export async function extractReadableHtml(
|
|
31
|
+
html: string,
|
|
32
|
+
source: string,
|
|
33
|
+
extractor: HtmlExtractor = extractWithDefuddle,
|
|
34
|
+
): Promise<ExtractedHtml>
|
|
35
|
+
{
|
|
36
|
+
try
|
|
37
|
+
{
|
|
38
|
+
const result = await extractor(html, source);
|
|
39
|
+
return {
|
|
40
|
+
content: result.content.trim(),
|
|
41
|
+
title: result.title.trim(),
|
|
42
|
+
usedFallback: false,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch
|
|
46
|
+
{
|
|
47
|
+
const fallback = extractPlainText(html);
|
|
48
|
+
return { ...fallback, usedFallback: true };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function extractWithDefuddle(
|
|
53
|
+
html: string,
|
|
54
|
+
source: string,
|
|
55
|
+
): Promise<{ readonly content: string; readonly title: string; }>
|
|
56
|
+
{
|
|
57
|
+
const document = parseDocument(html);
|
|
58
|
+
const result = await Defuddle(
|
|
59
|
+
document,
|
|
60
|
+
source,
|
|
61
|
+
{
|
|
62
|
+
markdown: true,
|
|
63
|
+
useAsync: false,
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
content: result.content,
|
|
69
|
+
title: result.title,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function extractPlainText(html: string): { readonly content: string; readonly title: string; }
|
|
74
|
+
{
|
|
75
|
+
const document = parseDocument(html);
|
|
76
|
+
|
|
77
|
+
for (
|
|
78
|
+
const element of document.querySelectorAll(
|
|
79
|
+
"script, style, nav, footer, header, aside, noscript, template",
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
{
|
|
83
|
+
element.remove();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const root = document.querySelector("article, main") ?? document.body ?? document.documentElement;
|
|
87
|
+
const content = normalizeWhitespace(root?.textContent ?? "");
|
|
88
|
+
const title = normalizeWhitespace(document.querySelector("title")?.textContent ?? "");
|
|
89
|
+
return { content, title };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function parseDocument(html: string): HtmlDocumentView
|
|
93
|
+
{
|
|
94
|
+
const parsed = parseHTML(html) as unknown as { readonly document: HtmlDocumentView; };
|
|
95
|
+
return parsed.document;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function normalizeWhitespace(value: string): string
|
|
99
|
+
{
|
|
100
|
+
return value.replace(/\s+/gu, " ").trim();
|
|
101
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { extractReadableHtml } from "./extract-readable-html.js";
|
|
2
|
+
|
|
3
|
+
import type { ContentConverter } from "pi-agent-resource";
|
|
4
|
+
|
|
5
|
+
const htmlMediaTypes = new Set(["application/xhtml+xml", "text/html"]);
|
|
6
|
+
const htmlSignature = /^\uFEFF?\s*(?:<!doctype\s+html\b|<(?:article|body|head|html)\b)/iu;
|
|
7
|
+
|
|
8
|
+
export function createHtmlContentConverter(): ContentConverter
|
|
9
|
+
{
|
|
10
|
+
return {
|
|
11
|
+
id: "html",
|
|
12
|
+
description: "HTML and XHTML pages converted to Markdown.",
|
|
13
|
+
async tryConvert(input, context)
|
|
14
|
+
{
|
|
15
|
+
if (!isHtmlInput(input.bytes, input.mediaType))
|
|
16
|
+
{
|
|
17
|
+
return { kind: "not-handled" };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const initialCancellation = cancellationError(context.signal);
|
|
21
|
+
|
|
22
|
+
if (initialCancellation !== undefined)
|
|
23
|
+
{
|
|
24
|
+
return { kind: "failed", error: initialCancellation };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let html: string;
|
|
28
|
+
|
|
29
|
+
try
|
|
30
|
+
{
|
|
31
|
+
html = new TextDecoder("utf8", { fatal: true }).decode(input.bytes);
|
|
32
|
+
}
|
|
33
|
+
catch (error)
|
|
34
|
+
{
|
|
35
|
+
return {
|
|
36
|
+
kind: "failed",
|
|
37
|
+
error: new TypeError(`${input.source} is not valid UTF-8 HTML`, { cause: error }),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const extracted = await extractReadableHtml(html, input.source);
|
|
42
|
+
const finalCancellation = cancellationError(context.signal);
|
|
43
|
+
|
|
44
|
+
if (finalCancellation !== undefined)
|
|
45
|
+
{
|
|
46
|
+
return { kind: "failed", error: finalCancellation };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const text = extracted.title.length === 0
|
|
50
|
+
? extracted.content
|
|
51
|
+
: extracted.content.length === 0
|
|
52
|
+
? `# ${extracted.title}`
|
|
53
|
+
: `# ${extracted.title}\n\n${extracted.content}`;
|
|
54
|
+
|
|
55
|
+
return { kind: "converted", content: [{ type: "text", text }] };
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function isHtmlInput(bytes: Uint8Array, mediaType: string | undefined): boolean
|
|
61
|
+
{
|
|
62
|
+
if (mediaType !== undefined)
|
|
63
|
+
{
|
|
64
|
+
const normalized = mediaType.split(";", 1)[0]?.trim().toLowerCase() ?? "";
|
|
65
|
+
|
|
66
|
+
if (htmlMediaTypes.has(normalized))
|
|
67
|
+
{
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const prefix = new TextDecoder("utf8").decode(bytes.subarray(0, 1024));
|
|
73
|
+
return htmlSignature.test(prefix);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function cancellationError(signal: AbortSignal | undefined): Error | undefined
|
|
77
|
+
{
|
|
78
|
+
if (signal?.aborted !== true)
|
|
79
|
+
{
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return signal.reason instanceof Error ? signal.reason : abortError();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function abortError(): Error
|
|
87
|
+
{
|
|
88
|
+
const error = new Error("The operation was aborted");
|
|
89
|
+
error.name = "AbortError";
|
|
90
|
+
return error;
|
|
91
|
+
}
|
package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { createImageContentConverter } from "pi-agent-image";
|
|
3
|
+
import { connectContentConverter, type ContentConverterRegistration } from "pi-agent-resource";
|
|
4
|
+
|
|
5
|
+
const registration = {
|
|
6
|
+
target: { provider: "web", capability: "read" },
|
|
7
|
+
converter: createImageContentConverter(),
|
|
8
|
+
priority: 100,
|
|
9
|
+
} satisfies ContentConverterRegistration;
|
|
10
|
+
|
|
11
|
+
export default async function registerWebImage(pi: ExtensionAPI): Promise<void>
|
|
12
|
+
{
|
|
13
|
+
await connectContentConverter(pi, registration);
|
|
14
|
+
}
|
package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-agent-web-image",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"pi": {
|
|
6
|
+
"extensions": [
|
|
7
|
+
"./index.ts"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"pi-agent-image": "0.1.0",
|
|
12
|
+
"pi-agent-resource": "0.1.0"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { createPdfContentConverter } from "pi-agent-pdf";
|
|
3
|
+
import { connectContentConverter, type ContentConverterRegistration } from "pi-agent-resource";
|
|
4
|
+
|
|
5
|
+
const registration = {
|
|
6
|
+
target: { provider: "web", capability: "read" },
|
|
7
|
+
converter: createPdfContentConverter(),
|
|
8
|
+
priority: 200,
|
|
9
|
+
} satisfies ContentConverterRegistration;
|
|
10
|
+
|
|
11
|
+
export default async function registerWebPdf(pi: ExtensionAPI): Promise<void>
|
|
12
|
+
{
|
|
13
|
+
await connectContentConverter(pi, registration);
|
|
14
|
+
}
|
package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-agent-web-pdf",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"pi": {
|
|
6
|
+
"extensions": [
|
|
7
|
+
"./index.ts"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"pi-agent-pdf": "0.1.0",
|
|
12
|
+
"pi-agent-resource": "0.1.0"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { connectContentConverter, type ContentConverterRegistration } from "pi-agent-resource";
|
|
3
|
+
import { createTextContentConverter } from "pi-agent-text";
|
|
4
|
+
|
|
5
|
+
const registration = {
|
|
6
|
+
target: { provider: "web", capability: "read" },
|
|
7
|
+
converter: createTextContentConverter(),
|
|
8
|
+
priority: 300,
|
|
9
|
+
} satisfies ContentConverterRegistration;
|
|
10
|
+
|
|
11
|
+
export default async function registerWebText(pi: ExtensionAPI): Promise<void>
|
|
12
|
+
{
|
|
13
|
+
await connectContentConverter(pi, registration);
|
|
14
|
+
}
|
package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-agent-web-text",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"pi": {
|
|
6
|
+
"extensions": [
|
|
7
|
+
"./index.ts"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"pi-agent-resource": "0.1.0",
|
|
12
|
+
"pi-agent-text": "0.1.0"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import type { ContentHost, ResourceResolutionAttempt, ResourceResolver } from "pi-agent-resource";
|
|
2
|
+
|
|
3
|
+
type WebContentHost = Pick<ContentHost, "convert">;
|
|
4
|
+
|
|
5
|
+
export interface WebResolverOptions
|
|
6
|
+
{
|
|
7
|
+
readonly timeoutMs?: number;
|
|
8
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function createWebResolver(
|
|
12
|
+
contentHost: WebContentHost,
|
|
13
|
+
options: WebResolverOptions = {},
|
|
14
|
+
): ResourceResolver
|
|
15
|
+
{
|
|
16
|
+
const timeoutMs = options.timeoutMs ?? 30_000;
|
|
17
|
+
|
|
18
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0)
|
|
19
|
+
{
|
|
20
|
+
throw new TypeError("Web timeout must be a positive finite number");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const fetchResource = options.fetch ?? globalThis.fetch;
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
id: "web",
|
|
27
|
+
tryResolve(source)
|
|
28
|
+
{
|
|
29
|
+
return Promise.resolve(resolveWebSource(source, contentHost, fetchResource, timeoutMs));
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function resolveWebSource(
|
|
35
|
+
source: string,
|
|
36
|
+
contentHost: WebContentHost,
|
|
37
|
+
fetchResource: typeof globalThis.fetch,
|
|
38
|
+
timeoutMs: number,
|
|
39
|
+
): ResourceResolutionAttempt
|
|
40
|
+
{
|
|
41
|
+
let url: URL;
|
|
42
|
+
|
|
43
|
+
try
|
|
44
|
+
{
|
|
45
|
+
url = new URL(source);
|
|
46
|
+
}
|
|
47
|
+
catch (error)
|
|
48
|
+
{
|
|
49
|
+
return claimsHttpScheme(source)
|
|
50
|
+
? {
|
|
51
|
+
kind: "failed",
|
|
52
|
+
error: new TypeError(`Invalid HTTP source ${source}`, { cause: error }),
|
|
53
|
+
}
|
|
54
|
+
: { kind: "not-handled" };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
58
|
+
{
|
|
59
|
+
return { kind: "not-handled" };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
kind: "resolved",
|
|
64
|
+
resource: {
|
|
65
|
+
source: url.href,
|
|
66
|
+
read({ signal })
|
|
67
|
+
{
|
|
68
|
+
return readWebContent(url, contentHost, fetchResource, timeoutMs, signal);
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function readWebContent(
|
|
75
|
+
url: URL,
|
|
76
|
+
contentHost: WebContentHost,
|
|
77
|
+
fetchResource: typeof globalThis.fetch,
|
|
78
|
+
timeoutMs: number,
|
|
79
|
+
parentSignal: AbortSignal | undefined,
|
|
80
|
+
)
|
|
81
|
+
{
|
|
82
|
+
const operation = createOperationSignal(parentSignal, timeoutMs);
|
|
83
|
+
|
|
84
|
+
try
|
|
85
|
+
{
|
|
86
|
+
operation.signal.throwIfAborted();
|
|
87
|
+
const response = await fetchResource(url, {
|
|
88
|
+
method: "GET",
|
|
89
|
+
redirect: "follow",
|
|
90
|
+
signal: operation.signal,
|
|
91
|
+
headers: {
|
|
92
|
+
"User-Agent": "Mozilla/5.0 (compatible; Pi-LPT/1.0; +https://github.com/alexshpunt/sasha-pi)",
|
|
93
|
+
Accept: "text/html,application/xhtml+xml,application/pdf,application/json,text/plain,image/*,*/*;q=0.8",
|
|
94
|
+
"Accept-Language": "en-US,en;q=0.5",
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
if (!response.ok)
|
|
99
|
+
{
|
|
100
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
104
|
+
operation.signal.throwIfAborted();
|
|
105
|
+
const source = response.url.length === 0 ? url.href : response.url;
|
|
106
|
+
const mediaType = response.headers.get("content-type") ?? undefined;
|
|
107
|
+
return await contentHost.convert(
|
|
108
|
+
{
|
|
109
|
+
source,
|
|
110
|
+
bytes,
|
|
111
|
+
...(mediaType === undefined ? {} : { mediaType }),
|
|
112
|
+
},
|
|
113
|
+
{ signal: operation.signal },
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
finally
|
|
117
|
+
{
|
|
118
|
+
operation.dispose();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface OperationSignal
|
|
123
|
+
{
|
|
124
|
+
readonly signal: AbortSignal;
|
|
125
|
+
dispose(): void;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function createOperationSignal(parent: AbortSignal | undefined, timeoutMs: number): OperationSignal
|
|
129
|
+
{
|
|
130
|
+
const controller = new AbortController();
|
|
131
|
+
const abortFromParent = (): void =>
|
|
132
|
+
{
|
|
133
|
+
controller.abort(abortReason(parent));
|
|
134
|
+
};
|
|
135
|
+
const timeout = setTimeout(() =>
|
|
136
|
+
{
|
|
137
|
+
controller.abort(timeoutError(timeoutMs));
|
|
138
|
+
}, timeoutMs);
|
|
139
|
+
timeout.unref();
|
|
140
|
+
|
|
141
|
+
if (parent?.aborted === true)
|
|
142
|
+
{
|
|
143
|
+
abortFromParent();
|
|
144
|
+
}
|
|
145
|
+
else
|
|
146
|
+
{
|
|
147
|
+
parent?.addEventListener("abort", abortFromParent, { once: true });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
signal: controller.signal,
|
|
152
|
+
dispose(): void
|
|
153
|
+
{
|
|
154
|
+
clearTimeout(timeout);
|
|
155
|
+
parent?.removeEventListener("abort", abortFromParent);
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function claimsHttpScheme(source: string): boolean
|
|
161
|
+
{
|
|
162
|
+
return /^https?:/iu.test(source);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function abortReason(signal: AbortSignal | undefined): Error
|
|
166
|
+
{
|
|
167
|
+
return signal?.reason instanceof Error ? signal.reason : abortError();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function abortError(): Error
|
|
171
|
+
{
|
|
172
|
+
const error = new Error("The operation was aborted");
|
|
173
|
+
error.name = "AbortError";
|
|
174
|
+
return error;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function timeoutError(timeoutMs: number): Error
|
|
178
|
+
{
|
|
179
|
+
const error = new Error(`Web read timed out after ${timeoutMs}ms`);
|
|
180
|
+
error.name = "TimeoutError";
|
|
181
|
+
return error;
|
|
182
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./src/core/extension.js";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-agent-read",
|
|
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/rendering": {
|
|
19
|
+
"types": "./src/api/rendering.ts",
|
|
20
|
+
"default": "./src/api/rendering.ts"
|
|
21
|
+
},
|
|
22
|
+
"./api/plugin-protocol": {
|
|
23
|
+
"types": "./src/api/plugin-protocol.ts",
|
|
24
|
+
"default": "./src/api/plugin-protocol.ts"
|
|
25
|
+
},
|
|
26
|
+
"./api/tools/read": {
|
|
27
|
+
"types": "./src/api/tools/read.ts",
|
|
28
|
+
"default": "./src/api/tools/read.ts"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"pi-agent-resource": "0.1.0",
|
|
33
|
+
"pi-agent-text": "0.1.0",
|
|
34
|
+
"pi-agent-tool-call-interception": "0.1.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
38
|
+
"@earendil-works/pi-tui": "*",
|
|
39
|
+
"typebox": "*"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
isReadCoreReady,
|
|
5
|
+
READ_CORE_READY_EVENT,
|
|
6
|
+
READ_PLUGIN_REGISTER_EVENT,
|
|
7
|
+
type ReadPlugin,
|
|
8
|
+
type ReadPluginRegistrationRequest,
|
|
9
|
+
} from "#src/api/plugin-protocol.js";
|
|
10
|
+
|
|
11
|
+
export function connectReadPlugin(
|
|
12
|
+
pi: ExtensionAPI,
|
|
13
|
+
plugin: ReadPlugin,
|
|
14
|
+
): void | Promise<void>
|
|
15
|
+
{
|
|
16
|
+
const announce = (): Promise<void> | undefined =>
|
|
17
|
+
{
|
|
18
|
+
let registration: Promise<void> | undefined;
|
|
19
|
+
const request = {
|
|
20
|
+
plugin,
|
|
21
|
+
accept(value): void
|
|
22
|
+
{
|
|
23
|
+
if (registration !== undefined)
|
|
24
|
+
{
|
|
25
|
+
throw new Error(`Plugin ${plugin.id} registration was accepted more than once`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
registration = value;
|
|
29
|
+
},
|
|
30
|
+
} satisfies ReadPluginRegistrationRequest;
|
|
31
|
+
|
|
32
|
+
pi.events.emit(READ_PLUGIN_REGISTER_EVENT, request);
|
|
33
|
+
return registration;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
let unsubscribe = (): void =>
|
|
37
|
+
{};
|
|
38
|
+
unsubscribe = pi.events.on(READ_CORE_READY_EVENT, (ready) =>
|
|
39
|
+
{
|
|
40
|
+
if (!isReadCoreReady(ready))
|
|
41
|
+
{
|
|
42
|
+
throw new Error("Invalid pi-agent-read core readiness event");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const registration = announce();
|
|
46
|
+
|
|
47
|
+
if (registration === undefined)
|
|
48
|
+
{
|
|
49
|
+
throw new Error("pi-agent-read core announced readiness without accepting the plugin");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
unsubscribe();
|
|
53
|
+
void registration.catch(() =>
|
|
54
|
+
{});
|
|
55
|
+
});
|
|
56
|
+
pi.on("session_shutdown", unsubscribe);
|
|
57
|
+
|
|
58
|
+
const registration = announce();
|
|
59
|
+
|
|
60
|
+
if (registration === undefined)
|
|
61
|
+
{
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
unsubscribe();
|
|
66
|
+
return registration;
|
|
67
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { Value } from "typebox/value";
|
|
3
|
+
|
|
4
|
+
import type { ReadToolPluginApi } from "#src/api/tools/read.js";
|
|
5
|
+
|
|
6
|
+
export const READ_PROTOCOL = "pi-agent-read";
|
|
7
|
+
|
|
8
|
+
export const READ_API_VERSION = 6;
|
|
9
|
+
|
|
10
|
+
export const READ_CORE_READY_EVENT = `${READ_PROTOCOL}/core/ready`;
|
|
11
|
+
|
|
12
|
+
export const READ_PLUGIN_REGISTER_EVENT = `${READ_PROTOCOL}/plugin/register`;
|
|
13
|
+
|
|
14
|
+
export interface ReadCoreReady
|
|
15
|
+
{
|
|
16
|
+
readonly protocol: typeof READ_PROTOCOL;
|
|
17
|
+
readonly apiVersion: typeof READ_API_VERSION;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type ReadPluginApi = ReadToolPluginApi;
|
|
21
|
+
|
|
22
|
+
export interface ReadPlugin
|
|
23
|
+
{
|
|
24
|
+
readonly protocol: typeof READ_PROTOCOL;
|
|
25
|
+
readonly apiVersion: typeof READ_API_VERSION;
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly setup: (api: ReadPluginApi) => void | Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ReadPluginRegistrationRequest
|
|
31
|
+
{
|
|
32
|
+
readonly plugin: ReadPlugin;
|
|
33
|
+
accept(registration: Promise<void>): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const functionSchema = Type.Function([], Type.Unknown());
|
|
37
|
+
const readCoreReadySchema = Type.Object({
|
|
38
|
+
protocol: Type.Literal(READ_PROTOCOL),
|
|
39
|
+
apiVersion: Type.Literal(READ_API_VERSION),
|
|
40
|
+
});
|
|
41
|
+
const readPluginSchema = Type.Object({
|
|
42
|
+
protocol: Type.Literal(READ_PROTOCOL),
|
|
43
|
+
apiVersion: Type.Literal(READ_API_VERSION),
|
|
44
|
+
id: Type.String(),
|
|
45
|
+
setup: functionSchema,
|
|
46
|
+
});
|
|
47
|
+
const readPluginRegistrationRequestSchema = Type.Object({
|
|
48
|
+
plugin: readPluginSchema,
|
|
49
|
+
accept: functionSchema,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export function isReadCoreReady(value: unknown): value is ReadCoreReady
|
|
53
|
+
{
|
|
54
|
+
return Value.Check(readCoreReadySchema, value);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function isReadPlugin(value: unknown): value is ReadPlugin
|
|
58
|
+
{
|
|
59
|
+
return Value.Check(readPluginSchema, value);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function isReadPluginRegistrationRequest(
|
|
63
|
+
value: unknown,
|
|
64
|
+
): value is ReadPluginRegistrationRequest
|
|
65
|
+
{
|
|
66
|
+
return Value.Check(readPluginRegistrationRequestSchema, value);
|
|
67
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ReadPresentationKind = "code-view" | "markdown" | "source";
|
|
2
|
+
|
|
3
|
+
export interface ReadResultRendererOptions
|
|
4
|
+
{
|
|
5
|
+
readonly kind: ReadPresentationKind;
|
|
6
|
+
readonly label?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { createReadResultRenderer } from "#src/core/tools/read/read-renderer.js";
|
|
10
|
+
|
|
11
|
+
export type { ReadResultRenderer } from "#src/api/tools/read.js";
|