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
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts
ADDED
|
@@ -0,0 +1,728 @@
|
|
|
1
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
2
|
+
|
|
3
|
+
import { createDiffModel } from "./diff-model.js";
|
|
4
|
+
import { freezeMutationViewports, type FrozenMutationViewports } from "./frozen-viewport.js";
|
|
5
|
+
import { MutationPanel } from "./mutation-panel.js";
|
|
6
|
+
import {
|
|
7
|
+
advanceTypingProjectionResources,
|
|
8
|
+
extendTypingPreviewResources,
|
|
9
|
+
projectTypingResources,
|
|
10
|
+
} from "./mutation-projection.js";
|
|
11
|
+
import { resolveMutationResultResources } from "./mutation-result.js";
|
|
12
|
+
import { TYPING_FRAME_INTERVAL_MS, TypingInterpolation } from "./typing-interpolation.js";
|
|
13
|
+
|
|
14
|
+
import type { MutationRenderResource } from "./render-resource.js";
|
|
15
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
16
|
+
import type { TextMutationPreviewResource } from "pi-agent-text-editor/api/mutation-preview";
|
|
17
|
+
import type { FileMutationBatchResult } from "pi-agent-text-editor/api/mutation-result";
|
|
18
|
+
import type { AnyTextMutationToolRegistration } from "pi-agent-text-editor/api/mutation-tool";
|
|
19
|
+
import type { TextEditorPluginApi } from "pi-agent-text-editor/api/plugin-protocol";
|
|
20
|
+
import type { TextEditorToolRendererRegistration } from "pi-agent-text-editor/api/tool-renderer";
|
|
21
|
+
|
|
22
|
+
type MutationRenderOutcome =
|
|
23
|
+
| { readonly kind: "completed"; readonly resources: readonly MutationRenderResource[]; }
|
|
24
|
+
| { readonly kind: "failed"; readonly reason: string; };
|
|
25
|
+
|
|
26
|
+
interface PreviewRequest
|
|
27
|
+
{
|
|
28
|
+
readonly identity: string;
|
|
29
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
30
|
+
readonly generated: string;
|
|
31
|
+
readonly cwd: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface PreviewTarget
|
|
35
|
+
{
|
|
36
|
+
readonly identity: string;
|
|
37
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
38
|
+
readonly generated: string;
|
|
39
|
+
readonly resources: readonly TextMutationPreviewResource[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface PendingResult
|
|
43
|
+
{
|
|
44
|
+
readonly details: FileMutationBatchResult | undefined;
|
|
45
|
+
readonly expanded: boolean;
|
|
46
|
+
readonly theme: Theme;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface RenderState
|
|
50
|
+
{
|
|
51
|
+
registration: AnyTextMutationToolRegistration;
|
|
52
|
+
epoch?: number;
|
|
53
|
+
controller?: AbortController;
|
|
54
|
+
key?: string;
|
|
55
|
+
preview?: MutationRenderOutcome;
|
|
56
|
+
viewports?: FrozenMutationViewports;
|
|
57
|
+
panel?: MutationPanel;
|
|
58
|
+
input?: Readonly<Record<string, unknown>>;
|
|
59
|
+
theme?: Theme;
|
|
60
|
+
invalidate?: () => void;
|
|
61
|
+
latestGenerated?: string;
|
|
62
|
+
typing?: TypingInterpolation;
|
|
63
|
+
target?: PreviewTarget;
|
|
64
|
+
queuedPreview?: PreviewRequest;
|
|
65
|
+
previewRunning?: boolean;
|
|
66
|
+
timer?: ReturnType<typeof setInterval>;
|
|
67
|
+
displayedResources?: readonly MutationRenderResource[];
|
|
68
|
+
displayedText?: string;
|
|
69
|
+
pendingResult?: PendingResult;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function registerMutationRenderers(api: TextEditorPluginApi): void
|
|
73
|
+
{
|
|
74
|
+
api.onMutationTool((registration) =>
|
|
75
|
+
{
|
|
76
|
+
api.addToolRenderer(createRenderer(api, registration));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function createRenderer(
|
|
81
|
+
api: TextEditorPluginApi,
|
|
82
|
+
registration: AnyTextMutationToolRegistration,
|
|
83
|
+
): TextEditorToolRendererRegistration
|
|
84
|
+
{
|
|
85
|
+
const tool = registration.name;
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
tool,
|
|
89
|
+
fallback: true,
|
|
90
|
+
renderCall(args, theme, context)
|
|
91
|
+
{
|
|
92
|
+
const component = panel(context.lastComponent, theme);
|
|
93
|
+
const input = asInput(args);
|
|
94
|
+
const state = context.state as RenderState;
|
|
95
|
+
state.registration = registration;
|
|
96
|
+
const now = performance.now();
|
|
97
|
+
state.panel = component;
|
|
98
|
+
state.input = input;
|
|
99
|
+
state.theme = theme;
|
|
100
|
+
state.invalidate = context.invalidate;
|
|
101
|
+
component.setExpanded(false);
|
|
102
|
+
component.setBackground(
|
|
103
|
+
context.isPartial ? "toolPendingBg" : context.isError ? "toolErrorBg" : "toolSuccessBg",
|
|
104
|
+
);
|
|
105
|
+
component.setHeader(renderHeader(registration, input, state.preview, theme));
|
|
106
|
+
|
|
107
|
+
if (!context.isPartial && !context.argsComplete)
|
|
108
|
+
{
|
|
109
|
+
disposeRenderState(state);
|
|
110
|
+
return component;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const argsComplete = context.argsComplete;
|
|
114
|
+
const key = `${argsComplete ? "complete" : "typing"}:${JSON.stringify(input)}`;
|
|
115
|
+
const generated = generatedText(tool, input);
|
|
116
|
+
|
|
117
|
+
if (generated !== undefined)
|
|
118
|
+
{
|
|
119
|
+
const typing = state.typing ??= new TypingInterpolation();
|
|
120
|
+
typing.observe(generated, now);
|
|
121
|
+
state.latestGenerated = generated;
|
|
122
|
+
|
|
123
|
+
if (argsComplete)
|
|
124
|
+
{
|
|
125
|
+
typing.finish();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (state.key !== key && generated.length > 0)
|
|
129
|
+
{
|
|
130
|
+
state.key = key;
|
|
131
|
+
const request = {
|
|
132
|
+
identity: previewIdentity(tool, input),
|
|
133
|
+
input,
|
|
134
|
+
generated,
|
|
135
|
+
cwd: context.cwd,
|
|
136
|
+
} satisfies PreviewRequest;
|
|
137
|
+
|
|
138
|
+
if (!advancePreviewTarget(state, request, now))
|
|
139
|
+
{
|
|
140
|
+
queuePreview(state, request, api, tool);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
ensureTypingTimer(state);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (state.preview?.kind === "completed" && !component.hasResources())
|
|
148
|
+
{
|
|
149
|
+
component.setPreviewResources(state.preview.resources);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return component;
|
|
153
|
+
},
|
|
154
|
+
renderResult(result, options, theme, context)
|
|
155
|
+
{
|
|
156
|
+
const state = context.state as RenderState;
|
|
157
|
+
state.registration = registration;
|
|
158
|
+
const viewports = state.viewports;
|
|
159
|
+
state.theme = theme;
|
|
160
|
+
state.invalidate = context.invalidate;
|
|
161
|
+
cancelPreviewWorker(state);
|
|
162
|
+
const resources = resolveMutationResultResources(result.details, viewports);
|
|
163
|
+
|
|
164
|
+
if (!context.isError && resources.length > 0)
|
|
165
|
+
{
|
|
166
|
+
const typing = state.typing;
|
|
167
|
+
const canFinishTyping = typing !== undefined
|
|
168
|
+
&& state.target !== undefined
|
|
169
|
+
&& state.latestGenerated === state.target.generated;
|
|
170
|
+
|
|
171
|
+
if (canFinishTyping && !typing.caughtUp)
|
|
172
|
+
{
|
|
173
|
+
typing.finish();
|
|
174
|
+
state.pendingResult = { details: result.details, expanded: options.expanded, theme };
|
|
175
|
+
ensureTypingTimer(state);
|
|
176
|
+
return new Text("", 0, 0);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
applyResultResources(state, resources, options.expanded, theme);
|
|
180
|
+
return new Text("", 0, 0);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
clearTypingRuntime(state);
|
|
184
|
+
delete state.preview;
|
|
185
|
+
delete state.viewports;
|
|
186
|
+
state.panel?.setHeader(renderHeader(registration, state.input ?? {}, undefined, theme));
|
|
187
|
+
state.panel?.setPreviewResources([]);
|
|
188
|
+
|
|
189
|
+
const output = result.content
|
|
190
|
+
.filter((item): item is { readonly type: "text"; readonly text: string; } => item.type === "text")
|
|
191
|
+
.map((item) => item.text)
|
|
192
|
+
.join("\n");
|
|
193
|
+
return new Text(
|
|
194
|
+
output.length === 0 ? "" : theme.fg(context.isError ? "error" : "toolOutput", output),
|
|
195
|
+
0,
|
|
196
|
+
0,
|
|
197
|
+
);
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function panel(previous: unknown, theme: Theme): MutationPanel
|
|
203
|
+
{
|
|
204
|
+
const component = previous instanceof MutationPanel ? previous : new MutationPanel(theme);
|
|
205
|
+
component.setTheme(theme);
|
|
206
|
+
return component;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function advancePreviewTarget(state: RenderState, request: PreviewRequest, now: number): boolean
|
|
210
|
+
{
|
|
211
|
+
const target = state.target;
|
|
212
|
+
|
|
213
|
+
if (target?.identity !== request.identity)
|
|
214
|
+
{
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const resources = extendTypingPreviewResources(target.resources, target.generated, request.generated);
|
|
219
|
+
|
|
220
|
+
if (resources === undefined)
|
|
221
|
+
{
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (state.previewRunning || state.queuedPreview !== undefined)
|
|
226
|
+
{
|
|
227
|
+
cancelPreviewWorker(state);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
state.target = {
|
|
231
|
+
identity: request.identity,
|
|
232
|
+
input: request.input,
|
|
233
|
+
generated: request.generated,
|
|
234
|
+
resources,
|
|
235
|
+
};
|
|
236
|
+
state.typing?.setTarget(request.generated, now);
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function queuePreview(
|
|
241
|
+
state: RenderState,
|
|
242
|
+
request: PreviewRequest,
|
|
243
|
+
api: TextEditorPluginApi,
|
|
244
|
+
tool: string,
|
|
245
|
+
): void
|
|
246
|
+
{
|
|
247
|
+
state.queuedPreview = request;
|
|
248
|
+
|
|
249
|
+
if (state.previewRunning)
|
|
250
|
+
{
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const epoch = state.epoch ?? 0;
|
|
255
|
+
state.epoch = epoch;
|
|
256
|
+
state.previewRunning = true;
|
|
257
|
+
void runPreviewWorker(state, api, tool, epoch).finally(() =>
|
|
258
|
+
{
|
|
259
|
+
if (state.epoch !== epoch)
|
|
260
|
+
{
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
state.previewRunning = false;
|
|
265
|
+
|
|
266
|
+
if (state.queuedPreview !== undefined)
|
|
267
|
+
{
|
|
268
|
+
queuePreview(state, state.queuedPreview, api, tool);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
async function runPreviewWorker(
|
|
274
|
+
state: RenderState,
|
|
275
|
+
api: TextEditorPluginApi,
|
|
276
|
+
tool: string,
|
|
277
|
+
epoch: number,
|
|
278
|
+
): Promise<void>
|
|
279
|
+
{
|
|
280
|
+
while (state.epoch === epoch)
|
|
281
|
+
{
|
|
282
|
+
const request = state.queuedPreview;
|
|
283
|
+
|
|
284
|
+
if (request === undefined)
|
|
285
|
+
{
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
delete state.queuedPreview;
|
|
290
|
+
const controller = new AbortController();
|
|
291
|
+
state.controller = controller;
|
|
292
|
+
|
|
293
|
+
try
|
|
294
|
+
{
|
|
295
|
+
const preview = await api.previewMutation({
|
|
296
|
+
tool,
|
|
297
|
+
input: request.input,
|
|
298
|
+
cwd: request.cwd,
|
|
299
|
+
signal: controller.signal,
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
if (state.epoch !== epoch || controller.signal.aborted)
|
|
303
|
+
{
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (preview.kind === "completed")
|
|
308
|
+
{
|
|
309
|
+
acceptPreview(state, request, preview.resources, performance.now());
|
|
310
|
+
}
|
|
311
|
+
else if (!hasQueuedPreview(state))
|
|
312
|
+
{
|
|
313
|
+
showPreviewFailure(state, preview.reason);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
catch (error)
|
|
317
|
+
{
|
|
318
|
+
if (state.epoch !== epoch || controller.signal.aborted)
|
|
319
|
+
{
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (!hasQueuedPreview(state))
|
|
324
|
+
{
|
|
325
|
+
showPreviewFailure(state, error instanceof Error ? error.message : String(error));
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
finally
|
|
329
|
+
{
|
|
330
|
+
if (state.controller === controller)
|
|
331
|
+
{
|
|
332
|
+
delete state.controller;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function hasQueuedPreview(state: RenderState): boolean
|
|
339
|
+
{
|
|
340
|
+
return state.queuedPreview !== undefined;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function acceptPreview(
|
|
344
|
+
state: RenderState,
|
|
345
|
+
request: PreviewRequest,
|
|
346
|
+
resources: readonly TextMutationPreviewResource[],
|
|
347
|
+
now: number,
|
|
348
|
+
): void
|
|
349
|
+
{
|
|
350
|
+
let targetRequest = request;
|
|
351
|
+
let targetResources = resources;
|
|
352
|
+
const queued = state.queuedPreview;
|
|
353
|
+
|
|
354
|
+
if (queued?.identity === request.identity)
|
|
355
|
+
{
|
|
356
|
+
const promoted = extendTypingPreviewResources(resources, request.generated, queued.generated);
|
|
357
|
+
|
|
358
|
+
if (promoted !== undefined)
|
|
359
|
+
{
|
|
360
|
+
targetRequest = queued;
|
|
361
|
+
targetResources = promoted;
|
|
362
|
+
delete state.queuedPreview;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
state.target = {
|
|
367
|
+
identity: targetRequest.identity,
|
|
368
|
+
input: targetRequest.input,
|
|
369
|
+
generated: targetRequest.generated,
|
|
370
|
+
resources: targetResources,
|
|
371
|
+
};
|
|
372
|
+
const typing = state.typing;
|
|
373
|
+
const rewound = typing?.setTarget(targetRequest.generated, now) ?? false;
|
|
374
|
+
ensureTypingTimer(state);
|
|
375
|
+
|
|
376
|
+
if ((rewound || typing?.hasVisibleText === true) && updateTypingPanel(state))
|
|
377
|
+
{
|
|
378
|
+
invalidateState(state);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function showPreviewFailure(state: RenderState, reason: string): void
|
|
383
|
+
{
|
|
384
|
+
const preview = { kind: "failed", reason } as const;
|
|
385
|
+
state.preview = preview;
|
|
386
|
+
|
|
387
|
+
if (state.panel !== undefined && state.theme !== undefined)
|
|
388
|
+
{
|
|
389
|
+
state.panel.setHeader(renderHeader(state.registration, state.input ?? {}, preview, state.theme));
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
invalidateState(state);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function ensureTypingTimer(state: RenderState): void
|
|
396
|
+
{
|
|
397
|
+
if (state.timer !== undefined || state.typing === undefined || state.target === undefined)
|
|
398
|
+
{
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
state.timer = setInterval(() =>
|
|
403
|
+
{
|
|
404
|
+
const typing = state.typing;
|
|
405
|
+
let changed = false;
|
|
406
|
+
|
|
407
|
+
if (typing?.advance(performance.now()) === true)
|
|
408
|
+
{
|
|
409
|
+
changed = updateTypingPanel(state);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (
|
|
413
|
+
state.pendingResult !== undefined
|
|
414
|
+
&& typing?.caughtUp === true
|
|
415
|
+
&& state.target?.generated === state.latestGenerated
|
|
416
|
+
)
|
|
417
|
+
{
|
|
418
|
+
changed = finishPendingResult(state) || changed;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
if (changed)
|
|
422
|
+
{
|
|
423
|
+
invalidateState(state);
|
|
424
|
+
}
|
|
425
|
+
}, TYPING_FRAME_INTERVAL_MS);
|
|
426
|
+
state.timer.unref();
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function updateTypingPanel(state: RenderState): boolean
|
|
430
|
+
{
|
|
431
|
+
const target = state.target;
|
|
432
|
+
const typing = state.typing;
|
|
433
|
+
const component = state.panel;
|
|
434
|
+
const theme = state.theme;
|
|
435
|
+
|
|
436
|
+
if (target === undefined || typing === undefined || component === undefined || theme === undefined)
|
|
437
|
+
{
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (!typing.hasVisibleText && target.generated.length > 0)
|
|
442
|
+
{
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
const visibleText = typing.visibleText;
|
|
447
|
+
const advanced = state.displayedResources === undefined || state.displayedText === undefined
|
|
448
|
+
? undefined
|
|
449
|
+
: advanceTypingProjectionResources(
|
|
450
|
+
target.resources,
|
|
451
|
+
target.generated,
|
|
452
|
+
state.displayedResources,
|
|
453
|
+
state.displayedText,
|
|
454
|
+
visibleText,
|
|
455
|
+
);
|
|
456
|
+
const resources = advanced ?? projectTypingResources(target.resources, target.generated, visibleText);
|
|
457
|
+
state.displayedResources = resources;
|
|
458
|
+
state.displayedText = visibleText;
|
|
459
|
+
const preview = { kind: "completed", resources } as const;
|
|
460
|
+
state.preview = preview;
|
|
461
|
+
state.viewports = freezeMutationViewports(resources);
|
|
462
|
+
component.setPreviewResources(resources);
|
|
463
|
+
component.setHeader(renderHeader(state.registration, state.input ?? target.input, preview, theme));
|
|
464
|
+
return true;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function finishPendingResult(state: RenderState): boolean
|
|
468
|
+
{
|
|
469
|
+
const pending = state.pendingResult;
|
|
470
|
+
|
|
471
|
+
if (pending === undefined)
|
|
472
|
+
{
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
const resources = resolveMutationResultResources(pending.details, state.viewports);
|
|
477
|
+
delete state.pendingResult;
|
|
478
|
+
|
|
479
|
+
if (resources.length === 0)
|
|
480
|
+
{
|
|
481
|
+
clearTypingRuntime(state);
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
applyResultResources(state, resources, pending.expanded, pending.theme);
|
|
486
|
+
return true;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function applyResultResources(
|
|
490
|
+
state: RenderState,
|
|
491
|
+
resources: readonly MutationRenderResource[],
|
|
492
|
+
expanded: boolean,
|
|
493
|
+
theme: Theme,
|
|
494
|
+
): void
|
|
495
|
+
{
|
|
496
|
+
const preview = { kind: "completed", resources } as const;
|
|
497
|
+
state.preview = preview;
|
|
498
|
+
state.panel?.setHeader(renderHeader(state.registration, state.input ?? {}, preview, theme));
|
|
499
|
+
state.panel?.setResultResources(resources);
|
|
500
|
+
state.panel?.setExpanded(expanded);
|
|
501
|
+
clearTypingRuntime(state);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function cancelPreviewWorker(state: RenderState): void
|
|
505
|
+
{
|
|
506
|
+
state.epoch = (state.epoch ?? 0) + 1;
|
|
507
|
+
state.controller?.abort();
|
|
508
|
+
delete state.controller;
|
|
509
|
+
delete state.queuedPreview;
|
|
510
|
+
state.previewRunning = false;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function clearTypingRuntime(state: RenderState): void
|
|
514
|
+
{
|
|
515
|
+
if (state.timer !== undefined)
|
|
516
|
+
{
|
|
517
|
+
clearInterval(state.timer);
|
|
518
|
+
delete state.timer;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
delete state.typing;
|
|
522
|
+
delete state.target;
|
|
523
|
+
delete state.latestGenerated;
|
|
524
|
+
delete state.displayedResources;
|
|
525
|
+
delete state.displayedText;
|
|
526
|
+
delete state.pendingResult;
|
|
527
|
+
delete state.key;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
function disposeRenderState(state: RenderState): void
|
|
531
|
+
{
|
|
532
|
+
cancelPreviewWorker(state);
|
|
533
|
+
clearTypingRuntime(state);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function invalidateState(state: RenderState): void
|
|
537
|
+
{
|
|
538
|
+
if (state.invalidate === undefined || invalidateActiveRenderer(state.invalidate))
|
|
539
|
+
{
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
disposeRenderState(state);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
function invalidateActiveRenderer(invalidate: () => void): boolean
|
|
547
|
+
{
|
|
548
|
+
try
|
|
549
|
+
{
|
|
550
|
+
invalidate();
|
|
551
|
+
return true;
|
|
552
|
+
}
|
|
553
|
+
catch
|
|
554
|
+
{
|
|
555
|
+
// Session replacement disposes the renderer before pending previews finish.
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function previewIdentity(tool: string, input: Readonly<Record<string, unknown>>): string
|
|
561
|
+
{
|
|
562
|
+
const field = generatedField(tool);
|
|
563
|
+
return JSON.stringify(Object.fromEntries(Object.entries(input).filter(([key]) => key !== field)));
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function generatedField(tool: string): string | undefined
|
|
567
|
+
{
|
|
568
|
+
return tool === "write" ? "content" : tool === "insert" || tool === "replace" ? "text" : undefined;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
function generatedText(tool: string, input: Readonly<Record<string, unknown>>): string | undefined
|
|
572
|
+
{
|
|
573
|
+
const field = generatedField(tool);
|
|
574
|
+
const value = field === undefined ? undefined : input[field];
|
|
575
|
+
return typeof value === "string" ? value : undefined;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function asInput(value: unknown): Readonly<Record<string, unknown>>
|
|
579
|
+
{
|
|
580
|
+
return typeof value === "object" && value !== null ? value as Readonly<Record<string, unknown>> : {};
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function renderHeader(
|
|
584
|
+
registration: AnyTextMutationToolRegistration,
|
|
585
|
+
input: Readonly<Record<string, unknown>>,
|
|
586
|
+
preview: MutationRenderOutcome | undefined,
|
|
587
|
+
theme: Theme,
|
|
588
|
+
): string
|
|
589
|
+
{
|
|
590
|
+
const source = registration.source;
|
|
591
|
+
const path = stringValue(input[source.field]);
|
|
592
|
+
const previewResources = preview?.kind === "completed" ? preview.resources : [];
|
|
593
|
+
const displayedPath = path
|
|
594
|
+
?? (previewResources.length === 1
|
|
595
|
+
? previewResources[0]!.path
|
|
596
|
+
: previewResources.length > 1
|
|
597
|
+
? `${String(previewResources.length)} files`
|
|
598
|
+
: "");
|
|
599
|
+
const sourceLink = path === undefined && previewResources.length === 1
|
|
600
|
+
? previewResources[0]!.link
|
|
601
|
+
: resourceLink(preview, path);
|
|
602
|
+
const targets = (source.targets ?? [])
|
|
603
|
+
.map(({ field }) => ({ field, path: stringValue(input[field]) }))
|
|
604
|
+
.filter((target): target is { readonly field: string; readonly path: string; } =>
|
|
605
|
+
target.path !== undefined && target.path !== path
|
|
606
|
+
);
|
|
607
|
+
const sourceFallback = targets.length === 0 ? 0 : undefined;
|
|
608
|
+
let header = `${theme.fg("toolTitle", theme.bold(registration.name))} ${
|
|
609
|
+
renderPath(displayedPath, sourceLink, theme)
|
|
610
|
+
}${renderAnchorRange(registration, source.field, input, theme)}${
|
|
611
|
+
renderStats(preview, path, theme, sourceFallback)
|
|
612
|
+
}`;
|
|
613
|
+
|
|
614
|
+
for (const target of targets)
|
|
615
|
+
{
|
|
616
|
+
header += ` ${theme.fg("muted", "->")} ${renderPath(target.path, resourceLink(preview, target.path), theme)}`;
|
|
617
|
+
header += renderAnchorRange(registration, target.field, input, theme);
|
|
618
|
+
header += renderStats(preview, target.path, theme);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
return header;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
function renderAnchorRange(
|
|
625
|
+
registration: AnyTextMutationToolRegistration,
|
|
626
|
+
sourceField: string,
|
|
627
|
+
input: Readonly<Record<string, unknown>>,
|
|
628
|
+
theme: Theme,
|
|
629
|
+
): string
|
|
630
|
+
{
|
|
631
|
+
const anchors = (registration.anchors ?? []).filter((anchor) => anchor.sourceField === sourceField);
|
|
632
|
+
const fields = sourceField === registration.source.field && registration.pair !== undefined
|
|
633
|
+
? registration.pair
|
|
634
|
+
: anchors.slice(0, 2).map(({ field }) => field);
|
|
635
|
+
const startField = fields.at(0);
|
|
636
|
+
const endField = fields.at(1);
|
|
637
|
+
return range(
|
|
638
|
+
startField === undefined ? undefined : stringValue(input[startField]),
|
|
639
|
+
endField === undefined ? undefined : stringValue(input[endField]),
|
|
640
|
+
theme,
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function resourceLink(preview: MutationRenderOutcome | undefined, path: string | undefined): string | undefined
|
|
645
|
+
{
|
|
646
|
+
return preview?.kind === "completed"
|
|
647
|
+
? preview.resources.find((resource) => resource.path === path)?.link
|
|
648
|
+
: undefined;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
function renderStats(
|
|
652
|
+
preview: MutationRenderOutcome | undefined,
|
|
653
|
+
path: string | undefined,
|
|
654
|
+
theme: Theme,
|
|
655
|
+
fallbackIndex?: number,
|
|
656
|
+
): string
|
|
657
|
+
{
|
|
658
|
+
if (preview?.kind !== "completed")
|
|
659
|
+
{
|
|
660
|
+
return "";
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
if (path === undefined)
|
|
664
|
+
{
|
|
665
|
+
const totals = { added: 0, modified: 0, removed: 0 };
|
|
666
|
+
|
|
667
|
+
for (const resource of preview.resources)
|
|
668
|
+
{
|
|
669
|
+
const model = resource.model
|
|
670
|
+
?? createDiffModel(resource.beforeContent, resource.afterContent, resource.ranges);
|
|
671
|
+
totals.added += model.added;
|
|
672
|
+
totals.modified += model.modified;
|
|
673
|
+
totals.removed += model.removed;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
return renderStatCounts(totals, theme);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
const resource =
|
|
680
|
+
preview.resources.find((candidate) => candidate.path === path || candidate.path.endsWith(`/${path}`))
|
|
681
|
+
?? (fallbackIndex === undefined ? undefined : preview.resources[fallbackIndex]);
|
|
682
|
+
|
|
683
|
+
if (resource === undefined)
|
|
684
|
+
{
|
|
685
|
+
return renderStatCounts({ added: 0, modified: 0, removed: 0 }, theme);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
const model = resource.model ?? createDiffModel(resource.beforeContent, resource.afterContent, resource.ranges);
|
|
689
|
+
return renderStatCounts(model, theme);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function renderStatCounts(
|
|
693
|
+
counts: { readonly added: number; readonly modified: number; readonly removed: number; },
|
|
694
|
+
theme: Theme,
|
|
695
|
+
): string
|
|
696
|
+
{
|
|
697
|
+
return ` ${theme.fg("success", `+${counts.added}`)} ${theme.fg("warning", `~${counts.modified}`)} ${
|
|
698
|
+
theme.fg("error", `-${counts.removed}`)
|
|
699
|
+
}`;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
function renderPath(path: string, link: string | undefined, theme: Theme): string
|
|
703
|
+
{
|
|
704
|
+
if (path.length === 0)
|
|
705
|
+
{
|
|
706
|
+
return theme.fg("muted", "...");
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
const label = theme.underline(theme.fg("accent", path));
|
|
710
|
+
return link === undefined || link.includes("\u0007") || link.includes("\u001B")
|
|
711
|
+
? label
|
|
712
|
+
: `\u001B]8;;${link}\u0007${label}\u001B]8;;\u0007`;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
function range(start: string | undefined, end: string | undefined, theme: Theme): string
|
|
716
|
+
{
|
|
717
|
+
if (start === undefined)
|
|
718
|
+
{
|
|
719
|
+
return "";
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
return theme.fg("warning", `:${start}${end === undefined ? "" : `-${end}`}`);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function stringValue(value: unknown): string | undefined
|
|
726
|
+
{
|
|
727
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
728
|
+
}
|