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,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";
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type AgentContent,
|
|
3
|
+
type ImageContent,
|
|
4
|
+
isResourceResolver,
|
|
5
|
+
type ResourceResolver,
|
|
6
|
+
type ResourceResolverContext,
|
|
7
|
+
type TextContent,
|
|
8
|
+
} from "pi-agent-resource";
|
|
9
|
+
import { Type } from "typebox";
|
|
10
|
+
import { Value } from "typebox/value";
|
|
11
|
+
|
|
12
|
+
import type { ToolDefinition, TruncationResult } from "@earendil-works/pi-coding-agent";
|
|
13
|
+
import type { TextDocument, TextLine, TextLinePresentation, TextPresenterRegistration } from "pi-agent-text";
|
|
14
|
+
|
|
15
|
+
export type ReadPipelineStage = "pre-read" | "read" | "post-read";
|
|
16
|
+
|
|
17
|
+
export type ReadContentKind = "text" | "other";
|
|
18
|
+
|
|
19
|
+
export interface ReadRequest
|
|
20
|
+
{
|
|
21
|
+
readonly path?: string;
|
|
22
|
+
readonly offset?: number;
|
|
23
|
+
readonly limit?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ReadFailure
|
|
27
|
+
{
|
|
28
|
+
readonly code:
|
|
29
|
+
| "INVALID_REQUEST"
|
|
30
|
+
| "INVALID_RESOLVER_RESULT"
|
|
31
|
+
| "INVALID_RESOURCE_CONTENT"
|
|
32
|
+
| "NO_RESOLVER"
|
|
33
|
+
| "PIPELINE_FAILED"
|
|
34
|
+
| "READ_FAILED"
|
|
35
|
+
| "RESOLVE_FAILED"
|
|
36
|
+
| "UNSUPPORTED_CAPABILITY"
|
|
37
|
+
| "UNSUPPORTED_CONTENT"
|
|
38
|
+
| "UNSUPPORTED_RANGE";
|
|
39
|
+
readonly source?: string;
|
|
40
|
+
readonly resolverId?: string;
|
|
41
|
+
readonly pluginId?: string;
|
|
42
|
+
readonly stage?: ReadPipelineStage;
|
|
43
|
+
readonly message: string;
|
|
44
|
+
readonly cause?: unknown;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type ReadResultRenderer = NonNullable<ToolDefinition["renderResult"]>;
|
|
48
|
+
|
|
49
|
+
export interface ResourceResolverRegistration
|
|
50
|
+
{
|
|
51
|
+
readonly resolver: ResourceResolver;
|
|
52
|
+
readonly priority?: number;
|
|
53
|
+
readonly renderResult?: ReadResultRenderer;
|
|
54
|
+
readonly preserveTruncatedOutput?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type ReadTextLinePresentation = TextLinePresentation;
|
|
58
|
+
|
|
59
|
+
export type ReadTextLine = TextLine;
|
|
60
|
+
|
|
61
|
+
export type ReadTextSnapshot = TextDocument;
|
|
62
|
+
|
|
63
|
+
interface ReadStateBase
|
|
64
|
+
{
|
|
65
|
+
readonly source: string;
|
|
66
|
+
readonly resolvedBy: string;
|
|
67
|
+
readonly preserveTruncatedOutput: boolean;
|
|
68
|
+
readonly textMode: "final" | "normal";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface ReadTextState extends ReadStateBase
|
|
72
|
+
{
|
|
73
|
+
readonly content: readonly [TextContent];
|
|
74
|
+
readonly contentKind: "text";
|
|
75
|
+
readonly text: ReadTextSnapshot;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ReadNativeState extends ReadStateBase
|
|
79
|
+
{
|
|
80
|
+
readonly content: AgentContent;
|
|
81
|
+
readonly contentKind: "other";
|
|
82
|
+
readonly text?: never;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type ReadState = ReadTextState | ReadNativeState;
|
|
86
|
+
|
|
87
|
+
export interface ReadPipelineContext
|
|
88
|
+
{
|
|
89
|
+
readonly request: ReadRequest;
|
|
90
|
+
readonly resolverContext: ResourceResolverContext;
|
|
91
|
+
readonly state?: ReadState;
|
|
92
|
+
readonly result?: ReadToolResult;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface UnsupportedContentBlockDetail
|
|
96
|
+
{
|
|
97
|
+
readonly index: number;
|
|
98
|
+
readonly kind: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface UnsupportedContentDetails
|
|
102
|
+
{
|
|
103
|
+
readonly unsupportedContentBlocks?: readonly [
|
|
104
|
+
UnsupportedContentBlockDetail,
|
|
105
|
+
...UnsupportedContentBlockDetail[],
|
|
106
|
+
];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface ReadResultDetails extends UnsupportedContentDetails
|
|
110
|
+
{
|
|
111
|
+
readonly source?: string;
|
|
112
|
+
readonly resolvedBy?: string;
|
|
113
|
+
readonly startLine?: number;
|
|
114
|
+
readonly endLine?: number;
|
|
115
|
+
readonly totalLines?: number;
|
|
116
|
+
readonly truncation?: TruncationResult;
|
|
117
|
+
readonly temporarySource?: string;
|
|
118
|
+
readonly lines?: readonly ReadTextLine[];
|
|
119
|
+
readonly failure?: ReadFailure;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface ReadToolResult
|
|
123
|
+
{
|
|
124
|
+
readonly content: (TextContent | ImageContent)[];
|
|
125
|
+
readonly details: ReadResultDetails;
|
|
126
|
+
readonly isError?: boolean;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type ReadStageOutcome =
|
|
130
|
+
| { readonly kind: "continue"; readonly context: ReadPipelineContext; }
|
|
131
|
+
| { readonly kind: "return"; readonly result: ReadToolResult; };
|
|
132
|
+
|
|
133
|
+
export type ReadPreReadHandler = ReadPipelineHandler;
|
|
134
|
+
|
|
135
|
+
export type ReadHandler = ReadPipelineHandler;
|
|
136
|
+
|
|
137
|
+
export type ReadPostReadHandler = ReadPipelineHandler;
|
|
138
|
+
|
|
139
|
+
export type ReadPipelineHandler = (
|
|
140
|
+
context: ReadPipelineContext,
|
|
141
|
+
) => ReadStageOutcome | Promise<ReadStageOutcome>;
|
|
142
|
+
|
|
143
|
+
export interface ReadHandlerWhen
|
|
144
|
+
{
|
|
145
|
+
readonly resolvedBy: string;
|
|
146
|
+
readonly contentKind: "text" | "any";
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export type ReadHandlerRegistration =
|
|
150
|
+
| { readonly stage: "pre-read"; readonly handler: ReadPreReadHandler; }
|
|
151
|
+
| { readonly stage: "read"; readonly when: ReadHandlerWhen; readonly handler: ReadHandler; }
|
|
152
|
+
| { readonly stage: "post-read"; readonly handler: ReadPostReadHandler; };
|
|
153
|
+
|
|
154
|
+
export type PromptDescriptionSource = string | (() => string | undefined);
|
|
155
|
+
|
|
156
|
+
export interface ReadToolPluginApi
|
|
157
|
+
{
|
|
158
|
+
read(request: ReadRequest, context: ResourceResolverContext): Promise<ReadToolResult>;
|
|
159
|
+
addResolver(registration: ResourceResolverRegistration): void;
|
|
160
|
+
addHandler(registration: ReadHandlerRegistration): void;
|
|
161
|
+
addTextPresenter(registration: TextPresenterRegistration): void;
|
|
162
|
+
describe(description: PromptDescriptionSource): void;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const functionSchema = Type.Function([], Type.Unknown());
|
|
166
|
+
const resourceResolverRegistrationSchema = Type.Object({
|
|
167
|
+
resolver: Type.Unknown(),
|
|
168
|
+
priority: Type.Optional(Type.Number()),
|
|
169
|
+
renderResult: Type.Optional(functionSchema),
|
|
170
|
+
preserveTruncatedOutput: Type.Optional(Type.Boolean()),
|
|
171
|
+
});
|
|
172
|
+
const readHandlerWhenSchema = Type.Object({
|
|
173
|
+
resolvedBy: Type.String({ pattern: "\\S" }),
|
|
174
|
+
contentKind: Type.Union([Type.Literal("text"), Type.Literal("any")]),
|
|
175
|
+
});
|
|
176
|
+
const readHandlerRegistrationSchema = Type.Union([
|
|
177
|
+
Type.Object({ stage: Type.Literal("pre-read"), handler: functionSchema }),
|
|
178
|
+
Type.Object({
|
|
179
|
+
stage: Type.Literal("read"),
|
|
180
|
+
when: readHandlerWhenSchema,
|
|
181
|
+
handler: functionSchema,
|
|
182
|
+
}),
|
|
183
|
+
Type.Object({ stage: Type.Literal("post-read"), handler: functionSchema }),
|
|
184
|
+
]);
|
|
185
|
+
|
|
186
|
+
export function isResourceResolverRegistration(value: unknown): value is ResourceResolverRegistration
|
|
187
|
+
{
|
|
188
|
+
if (!Value.Check(resourceResolverRegistrationSchema, value))
|
|
189
|
+
{
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const registration = value as Record<PropertyKey, unknown>;
|
|
194
|
+
|
|
195
|
+
if (!isResourceResolver(registration.resolver))
|
|
196
|
+
{
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return registration.resolver.id !== "any"
|
|
201
|
+
&& (!("priority" in registration) || typeof registration.priority === "number")
|
|
202
|
+
&& (!("renderResult" in registration) || typeof registration.renderResult === "function");
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function isReadHandlerRegistration(value: unknown): value is ReadHandlerRegistration
|
|
206
|
+
{
|
|
207
|
+
return Value.Check(readHandlerRegistrationSchema, value);
|
|
208
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { ToolCallInterceptionRenderStore, withToolCallInterceptionRendering } from "pi-agent-tool-call-interception";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
isReadPluginRegistrationRequest,
|
|
6
|
+
READ_API_VERSION,
|
|
7
|
+
READ_CORE_READY_EVENT,
|
|
8
|
+
READ_PLUGIN_REGISTER_EVENT,
|
|
9
|
+
READ_PROTOCOL,
|
|
10
|
+
} from "#src/api/plugin-protocol.js";
|
|
11
|
+
import { createReadCore } from "#src/core/read-core.js";
|
|
12
|
+
|
|
13
|
+
export default async function registerReadCore(pi: ExtensionAPI): Promise<void>
|
|
14
|
+
{
|
|
15
|
+
const core = createReadCore();
|
|
16
|
+
|
|
17
|
+
const unsubscribeRegistration = pi.events.on(READ_PLUGIN_REGISTER_EVENT, (request) =>
|
|
18
|
+
{
|
|
19
|
+
if (!isReadPluginRegistrationRequest(request))
|
|
20
|
+
{
|
|
21
|
+
throw new Error("Invalid pi-agent-read plugin registration request");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
request.accept(core.registerPlugin(request.plugin));
|
|
25
|
+
});
|
|
26
|
+
pi.on("session_shutdown", async () =>
|
|
27
|
+
{
|
|
28
|
+
unsubscribeRegistration();
|
|
29
|
+
await core.read.dispose();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const interceptionRendering = new ToolCallInterceptionRenderStore();
|
|
33
|
+
pi.registerTool(withToolCallInterceptionRendering(core.read.tool, interceptionRendering));
|
|
34
|
+
pi.events.emit(READ_CORE_READY_EVENT, {
|
|
35
|
+
protocol: READ_PROTOCOL,
|
|
36
|
+
apiVersion: READ_API_VERSION,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
await core.waitForPendingPlugins();
|
|
40
|
+
}
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import { isTextPresenterRegistration, type TextPresenterRegistration } from "pi-agent-text";
|
|
2
|
+
|
|
3
|
+
import { READ_API_VERSION, READ_PROTOCOL, type ReadPlugin, type ReadPluginApi } from "#src/api/plugin-protocol.js";
|
|
4
|
+
import {
|
|
5
|
+
isReadHandlerRegistration,
|
|
6
|
+
isResourceResolverRegistration,
|
|
7
|
+
type PromptDescriptionSource,
|
|
8
|
+
type ReadHandlerRegistration,
|
|
9
|
+
type ResourceResolverRegistration,
|
|
10
|
+
} from "#src/api/tools/read.js";
|
|
11
|
+
import { createReadTool, type ReadTool } from "#src/core/tools/tool-read.js";
|
|
12
|
+
|
|
13
|
+
type PluginStatus = "active" | "pending";
|
|
14
|
+
|
|
15
|
+
interface PluginLifecycle
|
|
16
|
+
{
|
|
17
|
+
status: PluginStatus;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface RegisteredPlugin
|
|
21
|
+
{
|
|
22
|
+
readonly lifecycle: PluginLifecycle;
|
|
23
|
+
readonly plugin: ReadPlugin;
|
|
24
|
+
readonly promptContributions: PromptDescriptionSource[];
|
|
25
|
+
readonly ready: Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface PluginContributionController
|
|
29
|
+
{
|
|
30
|
+
readonly api: ReadPluginApi;
|
|
31
|
+
close(): void;
|
|
32
|
+
commit(): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ReadCore
|
|
36
|
+
{
|
|
37
|
+
readonly read: ReadTool;
|
|
38
|
+
registerPlugin(plugin: ReadPlugin): Promise<void>;
|
|
39
|
+
waitForPendingPlugins(): Promise<void>;
|
|
40
|
+
renderPluginPromptGuideline(): string | undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function createReadCore(): ReadCore
|
|
44
|
+
{
|
|
45
|
+
const pendingPlugins = new Set<Promise<void>>();
|
|
46
|
+
const plugins = new Map<string, RegisteredPlugin>();
|
|
47
|
+
const read = createReadTool(() => renderPluginPromptGuideline(plugins));
|
|
48
|
+
let registrationQueue = Promise.resolve();
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
read,
|
|
52
|
+
registerPlugin(plugin): Promise<void>
|
|
53
|
+
{
|
|
54
|
+
const validationError = getPluginValidationError(plugin);
|
|
55
|
+
|
|
56
|
+
if (validationError !== undefined)
|
|
57
|
+
{
|
|
58
|
+
return Promise.reject(validationError);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const existing = plugins.get(plugin.id);
|
|
62
|
+
|
|
63
|
+
if (existing?.plugin === plugin)
|
|
64
|
+
{
|
|
65
|
+
return existing.ready;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (existing !== undefined)
|
|
69
|
+
{
|
|
70
|
+
return Promise.reject(new Error(`Plugin ${plugin.id} is already registered`));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const lifecycle: PluginLifecycle = { status: "pending" };
|
|
74
|
+
const promptContributions: PromptDescriptionSource[] = [];
|
|
75
|
+
const contributions = createPluginContributionController(
|
|
76
|
+
plugin.id,
|
|
77
|
+
read,
|
|
78
|
+
promptContributions,
|
|
79
|
+
);
|
|
80
|
+
const ready = registrationQueue.then(async () =>
|
|
81
|
+
{
|
|
82
|
+
try
|
|
83
|
+
{
|
|
84
|
+
await plugin.setup(contributions.api);
|
|
85
|
+
contributions.commit();
|
|
86
|
+
lifecycle.status = "active";
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
catch (error)
|
|
90
|
+
{
|
|
91
|
+
contributions.close();
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const registeredPlugin: RegisteredPlugin = {
|
|
96
|
+
lifecycle,
|
|
97
|
+
plugin,
|
|
98
|
+
promptContributions,
|
|
99
|
+
ready,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
plugins.set(plugin.id, registeredPlugin);
|
|
103
|
+
pendingPlugins.add(ready);
|
|
104
|
+
registrationQueue = ready.catch(() =>
|
|
105
|
+
{});
|
|
106
|
+
void ready.then(
|
|
107
|
+
() =>
|
|
108
|
+
{
|
|
109
|
+
pendingPlugins.delete(ready);
|
|
110
|
+
return;
|
|
111
|
+
},
|
|
112
|
+
() =>
|
|
113
|
+
{
|
|
114
|
+
pendingPlugins.delete(ready);
|
|
115
|
+
|
|
116
|
+
if (plugins.get(plugin.id) === registeredPlugin)
|
|
117
|
+
{
|
|
118
|
+
plugins.delete(plugin.id);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return;
|
|
122
|
+
},
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
return ready;
|
|
126
|
+
},
|
|
127
|
+
renderPluginPromptGuideline: () => renderPluginPromptGuideline(plugins),
|
|
128
|
+
async waitForPendingPlugins(): Promise<void>
|
|
129
|
+
{
|
|
130
|
+
await Promise.all(pendingPlugins);
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function getPluginValidationError(plugin: {
|
|
136
|
+
readonly apiVersion: number;
|
|
137
|
+
readonly id: string;
|
|
138
|
+
readonly protocol: string;
|
|
139
|
+
}): Error | undefined
|
|
140
|
+
{
|
|
141
|
+
if (plugin.protocol !== READ_PROTOCOL)
|
|
142
|
+
{
|
|
143
|
+
return new Error(`Plugin ${plugin.id} uses an unsupported protocol`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (plugin.apiVersion !== READ_API_VERSION)
|
|
147
|
+
{
|
|
148
|
+
return new Error(`Plugin ${plugin.id} uses an unsupported API version`);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (plugin.id.trim().length === 0)
|
|
152
|
+
{
|
|
153
|
+
return new Error("Plugin ID must not be empty");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function createPluginContributionController(
|
|
160
|
+
pluginId: string,
|
|
161
|
+
read: ReadTool,
|
|
162
|
+
promptContributions: PromptDescriptionSource[],
|
|
163
|
+
): PluginContributionController
|
|
164
|
+
{
|
|
165
|
+
const setupPromptContributions: PromptDescriptionSource[] = [];
|
|
166
|
+
const setupResolvers: ResourceResolverRegistration[] = [];
|
|
167
|
+
const setupReadHandlers: ReadHandlerRegistration[] = [];
|
|
168
|
+
const setupTextPresenters: TextPresenterRegistration[] = [];
|
|
169
|
+
let state: "active" | "closed" | "setup" = "setup";
|
|
170
|
+
const assertAvailable = (): void =>
|
|
171
|
+
{
|
|
172
|
+
if (state === "closed")
|
|
173
|
+
{
|
|
174
|
+
throw new Error(`Plugin ${pluginId} API is closed`);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
const api: ReadPluginApi = {
|
|
178
|
+
read(request, context)
|
|
179
|
+
{
|
|
180
|
+
assertAvailable();
|
|
181
|
+
return read.execute(request, context);
|
|
182
|
+
},
|
|
183
|
+
addResolver(registration): void
|
|
184
|
+
{
|
|
185
|
+
assertAvailable();
|
|
186
|
+
|
|
187
|
+
if (!isResourceResolverRegistration(registration))
|
|
188
|
+
{
|
|
189
|
+
throw new TypeError(`Plugin ${pluginId} provided an invalid resource resolver`);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (state === "setup")
|
|
193
|
+
{
|
|
194
|
+
setupResolvers.push(registration);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
read.registerContributions(pluginId, { resolvers: [registration] });
|
|
199
|
+
},
|
|
200
|
+
addHandler(registration): void
|
|
201
|
+
{
|
|
202
|
+
assertAvailable();
|
|
203
|
+
|
|
204
|
+
if (!isReadHandlerRegistration(registration))
|
|
205
|
+
{
|
|
206
|
+
throw new TypeError(`Plugin ${pluginId} provided an invalid read handler`);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (state === "setup")
|
|
210
|
+
{
|
|
211
|
+
setupReadHandlers.push(registration);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
read.registerContributions(pluginId, { handlers: [registration] });
|
|
216
|
+
},
|
|
217
|
+
addTextPresenter(registration): void
|
|
218
|
+
{
|
|
219
|
+
assertAvailable();
|
|
220
|
+
|
|
221
|
+
if (!isTextPresenterRegistration(registration))
|
|
222
|
+
{
|
|
223
|
+
throw new TypeError(`Plugin ${pluginId} provided an invalid text presenter`);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (state === "setup")
|
|
227
|
+
{
|
|
228
|
+
setupTextPresenters.push(registration);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
read.registerContributions(pluginId, { presenters: [registration] });
|
|
233
|
+
},
|
|
234
|
+
describe(description): void
|
|
235
|
+
{
|
|
236
|
+
assertAvailable();
|
|
237
|
+
|
|
238
|
+
if (setupPromptContributions.length > 0 || promptContributions.length > 0)
|
|
239
|
+
{
|
|
240
|
+
throw new Error(`Plugin ${pluginId} provides more than one description`);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const normalized = normalizeDescriptionSource(description);
|
|
244
|
+
|
|
245
|
+
if (state === "setup")
|
|
246
|
+
{
|
|
247
|
+
setupPromptContributions.push(normalized);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
promptContributions.push(normalized);
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
return {
|
|
256
|
+
api,
|
|
257
|
+
close(): void
|
|
258
|
+
{
|
|
259
|
+
state = "closed";
|
|
260
|
+
},
|
|
261
|
+
commit(): void
|
|
262
|
+
{
|
|
263
|
+
if (state !== "setup")
|
|
264
|
+
{
|
|
265
|
+
throw new Error(`Plugin ${pluginId} setup contributions cannot be committed`);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
read.registerContributions(pluginId, {
|
|
269
|
+
resolvers: setupResolvers,
|
|
270
|
+
handlers: setupReadHandlers,
|
|
271
|
+
presenters: setupTextPresenters,
|
|
272
|
+
});
|
|
273
|
+
promptContributions.push(...setupPromptContributions);
|
|
274
|
+
state = "active";
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function renderPluginPromptGuideline(
|
|
280
|
+
plugins: ReadonlyMap<string, RegisteredPlugin>,
|
|
281
|
+
): string | undefined
|
|
282
|
+
{
|
|
283
|
+
const entries: string[] = [];
|
|
284
|
+
|
|
285
|
+
for (const registeredPlugin of plugins.values())
|
|
286
|
+
{
|
|
287
|
+
if (registeredPlugin.lifecycle.status !== "active")
|
|
288
|
+
{
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const source = registeredPlugin.promptContributions[0];
|
|
293
|
+
|
|
294
|
+
if (source === undefined)
|
|
295
|
+
{
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const description = renderDescriptionSource(source);
|
|
300
|
+
|
|
301
|
+
if (description !== undefined)
|
|
302
|
+
{
|
|
303
|
+
entries.push(renderPromptEntry(registeredPlugin.plugin.id, description));
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return entries.length === 0
|
|
308
|
+
? undefined
|
|
309
|
+
: indentGuidelineContinuation(["Read supports these installed protocols:", ...entries].join("\n"));
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function normalizeDescriptionSource(value: unknown): PromptDescriptionSource
|
|
313
|
+
{
|
|
314
|
+
if (typeof value === "string")
|
|
315
|
+
{
|
|
316
|
+
return normalizeDescription(value);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (typeof value === "function")
|
|
320
|
+
{
|
|
321
|
+
return value as () => string | undefined;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
throw new TypeError("Read plugin prompt description must be a string or callback");
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function renderDescriptionSource(source: PromptDescriptionSource): string | undefined
|
|
328
|
+
{
|
|
329
|
+
if (typeof source === "string")
|
|
330
|
+
{
|
|
331
|
+
return source;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const value: unknown = source();
|
|
335
|
+
return value === undefined ? undefined : normalizeDescription(value);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function normalizeDescription(value: unknown): string
|
|
339
|
+
{
|
|
340
|
+
if (typeof value !== "string")
|
|
341
|
+
{
|
|
342
|
+
throw new TypeError("Read plugin prompt description must be a string");
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const lines = value
|
|
346
|
+
.replaceAll("\r\n", "\n")
|
|
347
|
+
.replaceAll("\r", "\n")
|
|
348
|
+
.split("\n")
|
|
349
|
+
.map((line) => line.trimEnd());
|
|
350
|
+
|
|
351
|
+
while (lines[0]?.trim().length === 0)
|
|
352
|
+
{
|
|
353
|
+
lines.shift();
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
while (lines.at(-1)?.trim().length === 0)
|
|
357
|
+
{
|
|
358
|
+
lines.pop();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const description = lines.join("\n");
|
|
362
|
+
|
|
363
|
+
if (description.trim().length === 0)
|
|
364
|
+
{
|
|
365
|
+
throw new Error("Read plugin prompt description is empty");
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
return description;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function renderPromptEntry(pluginId: string, description: string): string
|
|
372
|
+
{
|
|
373
|
+
const [firstLine, ...continuationLines] = description.split("\n");
|
|
374
|
+
|
|
375
|
+
return [
|
|
376
|
+
`- \`${escapeInlineCode(pluginId)}\` — ${firstLine ?? ""}`,
|
|
377
|
+
...continuationLines.map((line) => ` ${line}`),
|
|
378
|
+
].join("\n");
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function indentGuidelineContinuation(guideline: string): string
|
|
382
|
+
{
|
|
383
|
+
const [firstLine, ...continuationLines] = guideline.split("\n");
|
|
384
|
+
return [firstLine ?? "", ...continuationLines.map((line) => line.length === 0 ? line : ` ${line}`)].join("\n");
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function escapeInlineCode(value: string): string
|
|
388
|
+
{
|
|
389
|
+
return value.replaceAll("`", "\\`");
|
|
390
|
+
}
|